libdrm/amdgpu-apu.patch
Mika Penttilä 5f64c2c746 Update to 2.4.127
amdgpu-apu.patch: Read model name from /proc/cpuinfo for APUs
2025-10-20 13:08:06 +03:00

81 lines
2.0 KiB
Diff

From 2c1d39eff8b9c8296b57212bffd031029ce74491 Mon Sep 17 00:00:00 2001
From: Mario Limonciello <mario.limonciello@amd.com>
Date: Tue, 14 Oct 2025 11:54:41 -0500
Subject: [PATCH] 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>
---
amdgpu/amdgpu_asic_id.c | 45 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
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,
--
2.50.0