On 6/16/25 9:53 PM, Alex Deucher wrote:
On Mon, Jun 16, 2025 at 4:21 PM Mario Limonciello <[email protected]> wrote:
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,>
Alex
Signed-off-by: Mario Limonciello <[email protected]>
---
drivers/gpu/drm/amd/pm/amdgpu_pm.c | 16 ++++++++++++++++
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 1 +
2 files changed, 17 insertions(+)
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index edd9895b46c02..4e4c77488e334 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -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,
diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
b/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
index c12ced32f7808..ffd008c1e6ec2 100644
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h
@@ -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