All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd: Add a sysfs file to detect whether a GPU is an APU
@ 2025-06-16 20:15 Mario Limonciello
  2025-06-17  2:53 ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2025-06-16 20:15 UTC (permalink / raw)
  To: amd-gfx; +Cc: Mario Limonciello

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd: Add a sysfs file to detect whether a GPU is an APU
  2025-06-16 20:15 [PATCH] drm/amd: Add a sysfs file to detect whether a GPU is an APU Mario Limonciello
@ 2025-06-17  2:53 ` Alex Deucher
  2025-06-17  3:46   ` Mario Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Deucher @ 2025-06-17  2:53 UTC (permalink / raw)
  To: Mario Limonciello; +Cc: amd-gfx, Mario Limonciello

On Mon, Jun 16, 2025 at 4:21 PM Mario Limonciello <superm1@kernel.org> wrote:
>
> 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.

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

Alex

>
> 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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd: Add a sysfs file to detect whether a GPU is an APU
  2025-06-17  2:53 ` Alex Deucher
@ 2025-06-17  3:46   ` Mario Limonciello
  0 siblings, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2025-06-17  3:46 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx, Mario Limonciello



On 6/16/25 9:53 PM, Alex Deucher wrote:
> On Mon, Jun 16, 2025 at 4:21 PM Mario Limonciello <superm1@kernel.org> wrote:
>>
>> 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.
> 
> 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 <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
>>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-17  3:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 20:15 [PATCH] drm/amd: Add a sysfs file to detect whether a GPU is an APU Mario Limonciello
2025-06-17  2:53 ` Alex Deucher
2025-06-17  3:46   ` Mario Limonciello

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.