|
From: GitLab M. <git...@ke...> - 2025-10-15 18:16:21
|
amdgpu/amdgpu_asic_id.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
New commits:
commit 2c1d39eff8b9c8296b57212bffd031029ce74491
Author: Mario Limonciello <mar...@am...>
Date: Tue Oct 14 11:54:41 2025 -0500
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 <mar...@am...>
diff --git a/amdgpu/amdgpu_asic_id.c b/amdgpu/amdgpu_asic_id.c
index a5007ffc..7bdb2b67 100644
--- a/amdgpu/amdgpu_asic_id.c
+++ b/amdgpu/amdgpu_asic_id.c
@@ -104,6 +104,45 @@ out:
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)
{
FILE *fp;
@@ -113,6 +152,12 @@ void amdgpu_parse_asic_ids(struct amdgpu_device *dev)
int line_num = 1;
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");
if (!fp) {
fprintf(stderr, "%s: %s\n", AMDGPU_ASIC_ID_TABLE,
|