Skip to contentSkip to conversation

drm/amd: Add a sysfs file to detect whether a GPU is an APU

PATCH In review Mario Limonciello 2 participants 3 messages Jun 16, 2025 – Jun 17, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Add a sysfs file to detect whether a GPU is an APU

From: Mario Limonciello <[email protected]>

In order to discover whether a GPU is part of a dGPU or APU userspace has to do some mental gymnastics or heuristics. Add a sysfs file that clearly indicates to userspace.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c     | 16 ++++++++++++++++
 drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h |  1 +
 2 files changed, 17 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +16 -0
index edd9895b46c02..4e4c77488e334 100644
@@ -945,6 +945,21 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,
 	return size;
 }
 
+/**
+ * DOC: apu
+ *
+ * Represents whether GPU is on a dGPU (0) or APU (1)
+ */
+static ssize_t amdgpu_get_apu(struct device *dev,
+			      struct device_attribute *attr,
+			      char *buf)
+{
+	struct drm_device *ddev = dev_get_drvdata(dev);
+	struct amdgpu_device *adev = drm_to_adev(ddev);
+
+	return sysfs_emit(buf, "%d\n", adev->flags & AMD_IS_APU ? 1 : 0);
+}
+
 /**
  * DOC: pp_dpm_sclk pp_dpm_mclk pp_dpm_socclk pp_dpm_fclk pp_dpm_dcefclk pp_dpm_pcie
  *
@@ -2287,6 +2302,7 @@ static struct amdgpu_device_attr amdgpu_device_attrs[] = {
 			      .attr_update = ss_bias_attr_update),
 	AMDGPU_DEVICE_ATTR_RO(pm_metrics,				ATTR_FLAG_BASIC,
 			      .attr_update = amdgpu_pm_metrics_attr_update),
+	AMDGPU_DEVICE_ATTR_RO(apu,					ATTR_FLAG_BASIC),
 };
 
 static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_attr *attr,
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +1 -0
index c12ced32f7808..ffd008c1e6ec2 100644
@@ -78,6 +78,7 @@ enum amdgpu_device_attr_id {
 	device_attr_id__smartshift_dgpu_power,
 	device_attr_id__smartshift_bias,
 	device_attr_id__pm_metrics,
+	device_attr_id__apu,
 	device_attr_id__count,
 };
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

In order to discover whether a GPU is part of a dGPU or APU userspace has to do some mental gymnastics or heuristics. Add a sysfs file that clearly indicates to userspace.

You can already query this via the INFO IOCTL. What use case did you have in mind for this interface?

Alex

Quoted 56 lines
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c     | 16 ++++++++++++++++
 drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h |  1 +
 2 files changed, 17 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +16 -0
index edd9895b46c02..4e4c77488e334 100644
@@ -945,6 +945,21 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,
        return size;
 }
 
+/**
+ * DOC: apu
+ *
+ * Represents whether GPU is on a dGPU (0) or APU (1)
+ */
+static ssize_t amdgpu_get_apu(struct device *dev,
+                             struct device_attribute *attr,
+                             char *buf)
+{
+       struct drm_device *ddev = dev_get_drvdata(dev);
+       struct amdgpu_device *adev = drm_to_adev(ddev);
+
+       return sysfs_emit(buf, "%d\n", adev->flags & AMD_IS_APU ? 1 : 0);
+}
+
 /**
  * DOC: pp_dpm_sclk pp_dpm_mclk pp_dpm_socclk pp_dpm_fclk pp_dpm_dcefclk pp_dpm_pcie
  *
@@ -2287,6 +2302,7 @@ static struct amdgpu_device_attr amdgpu_device_attrs[] = {
                              .attr_update = ss_bias_attr_update),
        AMDGPU_DEVICE_ATTR_RO(pm_metrics,                               ATTR_FLAG_BASIC,
                              .attr_update = amdgpu_pm_metrics_attr_update),
+       AMDGPU_DEVICE_ATTR_RO(apu,                                      ATTR_FLAG_BASIC),
 };
 
 static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_attr *attr,
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +1 -1
index c12ced32f7808..ffd008c1e6ec2 100644
@@ -78,6 +78,7 @@ enum amdgpu_device_attr_id {
        device_attr_id__smartshift_dgpu_power,
        device_attr_id__smartshift_bias,
        device_attr_id__pm_metrics,
+       device_attr_id__apu,
        device_attr_id__count,
 };
 
--

2.43.0

#2 lore raw
Quoted 10 lines · Alex Deucher
Quoted 6 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

In order to discover whether a GPU is part of a dGPU or APU userspace has to do some mental gymnastics or heuristics. Add a sysfs file that clearly indicates to userspace.

You can already query this via the INFO IOCTL. What use case did you have in mind for this interface?

You're right; the IOCTL is totally fine for this. Disregard the patch.

Thanks,>

Quoted 58 lines

Alex

Quoted 56 lines
---
  drivers/gpu/drm/amd/pm/amdgpu_pm.c     | 16 ++++++++++++++++
  drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h |  1 +
  2 files changed, 17 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +16 -0
index edd9895b46c02..4e4c77488e334 100644
@@ -945,6 +945,21 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,
         return size;
  }
 
+/**
+ * DOC: apu
+ *
+ * Represents whether GPU is on a dGPU (0) or APU (1)
+ */
+static ssize_t amdgpu_get_apu(struct device *dev,
+                             struct device_attribute *attr,
+                             char *buf)
+{
+       struct drm_device *ddev = dev_get_drvdata(dev);
+       struct amdgpu_device *adev = drm_to_adev(ddev);
+
+       return sysfs_emit(buf, "%d\n", adev->flags & AMD_IS_APU ? 1 : 0);
+}
+
  /**
   * DOC: pp_dpm_sclk pp_dpm_mclk pp_dpm_socclk pp_dpm_fclk pp_dpm_dcefclk pp_dpm_pcie
   *
@@ -2287,6 +2302,7 @@ static struct amdgpu_device_attr amdgpu_device_attrs[] = {
                               .attr_update = ss_bias_attr_update),
         AMDGPU_DEVICE_ATTR_RO(pm_metrics,                               ATTR_FLAG_BASIC,
                               .attr_update = amdgpu_pm_metrics_attr_update),
+       AMDGPU_DEVICE_ATTR_RO(apu,                                      ATTR_FLAG_BASIC),
  };
 
  static int default_attr_update(struct amdgpu_device *adev, struct amdgpu_device_attr *attr,
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +1 -1
index c12ced32f7808..ffd008c1e6ec2 100644
@@ -78,6 +78,7 @@ enum amdgpu_device_attr_id {
         device_attr_id__smartshift_dgpu_power,
         device_attr_id__smartshift_bias,
         device_attr_id__pm_metrics,
+       device_attr_id__apu,
         device_attr_id__count,
  };
 
--

2.43.0