mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 03:30:22 +01:00
amdgpu: Read model name from /proc/cpuinfo for APUs
The correct marketing name is encoded in the model name field that is read from the hardware on an APU. Try to read from /proc/cpuinfo when an APU is found to identify such hardware. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
This commit is contained in:
parent
f7013effc3
commit
2c1d39eff8
1 changed files with 45 additions and 0 deletions
|
|
@ -104,6 +104,45 @@ out:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void amdgpu_parse_proc_cpuinfo(struct amdgpu_device *dev)
|
||||||
|
{
|
||||||
|
const char *search_key = "model name";
|
||||||
|
char *line = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
fp = fopen("/proc/cpuinfo", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
fprintf(stderr, "%s\n", strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (getline(&line, &len, fp) != -1) {
|
||||||
|
char *saveptr;
|
||||||
|
char *value;
|
||||||
|
|
||||||
|
if (strncmp(line, search_key, strlen(search_key)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* get content after colon and strip whitespace */
|
||||||
|
value = strtok_r(line, ":", &saveptr);
|
||||||
|
value = strtok_r(NULL, ":", &saveptr);
|
||||||
|
if (value == NULL)
|
||||||
|
continue;
|
||||||
|
while (*value == ' ' || *value == '\t')
|
||||||
|
value++;
|
||||||
|
saveptr = strchr(value, '\n');
|
||||||
|
if (saveptr)
|
||||||
|
*saveptr = '\0';
|
||||||
|
|
||||||
|
dev->marketing_name = strdup(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(line);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
|
void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
@ -113,6 +152,12 @@ void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
|
||||||
int line_num = 1;
|
int line_num = 1;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
|
if (dev->info.ids_flags & AMDGPU_IDS_FLAGS_FUSION) {
|
||||||
|
amdgpu_parse_proc_cpuinfo(dev);
|
||||||
|
if (dev->marketing_name != NULL)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fp = fopen(AMDGPU_ASIC_ID_TABLE, "r");
|
fp = fopen(AMDGPU_ASIC_ID_TABLE, "r");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "%s: %s\n", AMDGPU_ASIC_ID_TABLE,
|
fprintf(stderr, "%s: %s\n", AMDGPU_ASIC_ID_TABLE,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue