All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: amd-gfx@lists.freedesktop.org
Cc: Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH] drm/amd: Add a sysfs file to detect whether a GPU is an APU
Date: Mon, 16 Jun 2025 15:15:52 -0500	[thread overview]
Message-ID: <20250616201552.4022366-1-superm1@kernel.org> (raw)

From: Mario Limonciello <mario.limonciello@amd.com>

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.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 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


             reply	other threads:[~2025-06-16 20:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 20:15 Mario Limonciello [this message]
2025-06-17  2:53 ` [PATCH] drm/amd: Add a sysfs file to detect whether a GPU is an APU Alex Deucher
2025-06-17  3:46   ` Mario Limonciello

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250616201552.4022366-1-superm1@kernel.org \
    --to=superm1@kernel.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=mario.limonciello@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.