drm/amd/amdgpu: Add a GPU_LOAD entry to sysfs
Subsystems (2)
PATCH 1/1 drm/amd/amdgpu: Add a GPU_LOAD entry to sysfs
This adds what should be a stable interface to read GPU load from userspace.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +41 -0
@@ -918,6 +918,37 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,return -EINVAL ; } +static ssize_t amdgpu_get_busy_level (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +int r, value, size =sizeof (value); + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the temperature */ + r =amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_LOAD , + (void *)&value, &size); +if (r) +return r; + +return snprintf (buf,PAGE_SIZE ,"%d\n" , value); +} + +static ssize_t amdgpu_set_gpu_busy_level (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +return -EINVAL ; +} + + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state); static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, amdgpu_get_dpm_forced_performance_level,
@@ -951,6 +982,8 @@ static DEVICE_ATTR(pp_power_profile_mode, S_IRUGO | S_IWUSR, static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR, amdgpu_get_pp_od_clk_voltage, amdgpu_set_pp_od_clk_voltage); +static DEVICE_ATTR(gpu_busy_level, S_IRUGO | S_IWUSR, + amdgpu_get_busy_level, amdgpu_set_gpu_busy_level); static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,
@@ -1854,6 +1887,13 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) "pp_od_clk_voltage\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_gpu_busy_level); +if (ret) { +DRM_ERROR ("failed to create device file " +"gpu_busy_level\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) {DRM_ERROR ("Failed to register debugfs file for dpm!\n" );
@@ -1889,6 +1929,7 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev) &dev_attr_pp_power_profile_mode);device_remove_file (adev->dev, &dev_attr_pp_od_clk_voltage); +device_remove_file (adev->dev, &dev_attr_gpu_busy_level); }void amdgpu_pm_compute_clocks (struct amdgpu_device *adev)
Signature · 6 lines
2.14.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
I see some functions in amdgpu_pm.c have function level documentation, so that it would be good to have this for newly added functions.
Another comment is inline.
Quoted 27 lines
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Tom St Denis <[email protected]>
Sent: Wednesday, June 20, 2018 8:31 AM
To: [email protected]
Cc: StDenis, Tom
Subject: [PATCH] drm/amd/amdgpu: Add aGPU_LOADentry to sysfsThis adds what should be a stable interface to read GPU load from userspace.
Signed-off-by Tom St Denis <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c| 41 ++++++++++++++++++++++++++++++++++1 file changed, 41 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +4
-0@@ -918,6 +918,37 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,return -EINVAL ; } +static ssize_t amdgpu_get_busy_level (struct device *dev, +struct device_attribute *attr, +char *buf) +{
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, · line 934
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +int r, value, size =sizeof (value); + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the temperature */
Is load is the same thing as temperature?
[snap]
Slava A
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB13046D5BAB0653158D96EFAAFE770-rpdhrqHFk05fmUFYn07qFQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 1 line · Slava
I see some functions in
amdgpu_pm.chave function level documentation, so that it would be good to have this for newly added functions.
Sure I can add some comments/docs.
Quoted 29 lines
Another comment is inline.
Quoted 7 lines
From: amd-gfx <[email protected]> on behalf of Tom St Denis <[email protected]>
Sent: Wednesday, June 20, 2018 8:31 AM
To: [email protected]
Cc: StDenis, Tom
Subject: [PATCH] drm/amd/amdgpu: Add aGPU_LOADentry to sysfsQuoted 6 lines
This adds what should be a stable interface to read GPU load from userspace.
Signed-off-by Tom St Denis <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c| 41++++++++++++++++++++++++++++++++++
Review
Quoted 3 lines
1 file changed, 41 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cdrivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t
Quoted 4 lines
index
113edffb5960..d57b414ac228100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -918,6 +918,37 @@ static ssize_tamdgpu_set_pp_power_profile_mode(struct device *dev,
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0return -EINVAL; }
Quoted 16 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +4
-0+static ssize_t amdgpu_get_busy_level (struct device *dev, + struct device_attribute *attr, + char *buf) +{drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, · line 934
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+ struct drm_device *ddev = dev_get_drvdata(dev); + struct amdgpu_device *adev = ddev->dev_private; + int r, value, size = sizeof(value); + + /* sanity check PP is enabled */ + if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) + return -EINVAL; + + /* get the temperature */Is load is the same thing as temperature?
Nope, there is a separate sensor for that but it is included in hwmon and Alex would rather not duplicate it.
GPU_LOAD is a value returned by firmware based on the RLC busy status (I think...).
Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 8a588c4f-48d8-4095-9d27-f360bafa3f9b-5C7GfCeVMHo@public.gmane.org
Should the comment then say 'get the load' instead of 'get the temperature'?
________________________________
From: StDenis, Tom
Sent: Wednesday, June 20, 2018 10:39:25 AM
To: Abramov, Slava; [email protected]
Subject: Re: [PATCH] drm/amd/amdgpu: Add a GPU_LOAD entry to sysfs
Quoted 2 lines · Slava
I see some functions in
amdgpu_pm.chave function level documentation, so that it would be good to have this for newly added functions.
Sure I can add some comments/docs.
Quoted 29 lines
Another comment is inline.
Quoted 7 lines
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Tom St Denis <[email protected]>
Sent: Wednesday, June 20, 2018 8:31 AM
To: [email protected]
Cc: StDenis, Tom
Subject: [PATCH] drm/amd/amdgpu: Add aGPU_LOADentry to sysfsQuoted 6 lines
This adds what should be a stable interface to read GPU load from userspace.
Signed-off-by Tom St Denis <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c| 41++++++++++++++++++++++++++++++++++
Review
Quoted 3 lines
1 file changed, 41 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cdrivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t
Quoted 4 lines
index
113edffb5960..d57b414ac228100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -918,6 +918,37 @@ static ssize_tamdgpu_set_pp_power_profile_mode(struct device *dev,
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0return -EINVAL ; }
Quoted 16 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +4
-0+static ssize_t amdgpu_get_busy_level (struct device *dev, +struct device_attribute *attr, +char *buf) +{drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, · line 934
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +int r, value, size =sizeof (value); + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the temperature */ Is load is the same thing as temperature?
Nope, there is a separate sensor for that but it is included in hwmon and Alex would rather not duplicate it.
GPU_LOAD is a value returned by firmware based on the RLC busy status (I think...).
Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB13044BA8CF357D8794289827FE770-rpdhrqHFk05fmUFYn07qFQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Hi Slava,
Ah yes, I copied it from another function (because the struct path to the pp functions is annoying to look up hehehehe).
Thanks!
I'll submit a v2 in a bit.
Cheers,
Tom
Quoted 59 lines · Slava
Should the comment then say 'get the load' instead of 'get the temperature'?
------------------------------------------------------------------------
*From:* StDenis, Tom
*Sent:* Wednesday, June 20, 2018 10:39:25 AM
*To:* Abramov, Slava; [email protected] *Subject:* Re: [PATCH] drm/amd/amdgpu: Add aGPU_LOADentry to sysfsQuoted 1 line · Slava
I see some functions in
amdgpu_pm.chave function level documentation, so that it would be good to have this for newly added functions.Sure I can add some comments/docs.
Quoted 42 lines
Another comment is inline.
Quoted 1 line
From: amd-gfx <[email protected]> on behalf of Tom St Denis <[email protected]>
>Sent: Wednesday, June 20, 2018 8:31 AM
>To: [email protected]
>Cc: StDenis, Tom
>Subject: [PATCH] drm/amd/amdgpu: Add aGPU_LOADentry to sysfs
>
>This adds what should be a stable interface to read GPU
>load from userspace.
>
>Signed-off-by: Tom St Denis <[email protected]>
>---
>drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c| 41
++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
>diff --gita/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cb/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c>index113edffb5960..d57b414ac228100644
>---a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>+++b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>@@ -918,6 +918,37 @@ staticssize_tamdgpu_set_pp_power_profile_mode(struct device *dev, > return-EINVAL;
> }
>
>+staticssize_tamdgpu_get_busy_level(struct device *dev,
>+ structdevice_attribute*attr,
>+ char *buf)
>+{
>+ structdrm_device*ddev =dev_get_drvdata(dev);
>+ structamdgpu_device*adev =ddev->dev_private;
>+ int r, value, size = sizeof(value);
>+
>+ /* sanity check PP is enabled */
>+ if (!(adev->powerplay.pp_funcs &&
>+ adev->powerplay.pp_funcs->read_sensor))
>+ return-EINVAL;
>+
>+ /* get the temperature */Quoted 1 line
Is load is the same thing as temperature?
Quoted 7 lines
Nope, there is a separate sensor for that but it is included in hwmon and Alex would rather not duplicate it.
GPU_LOADis a value returned by firmware based on the RLC busy status (I think...).Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 61 lines · Tom St Denis
Quoted 3 lines · Slava
I see some functions in
amdgpu_pm.chave function level documentation, so that it would be good to have this for newly added functions.Sure I can add some comments/docs.
Quoted 31 lines
Another comment is inline.
Quoted 9 lines
From: amd-gfx <[email protected]> on behalf of Tom St Denis <[email protected]>
Sent: Wednesday, June 20, 2018 8:31 AM
To: [email protected]
Cc: StDenis, Tom
Subject: [PATCH] drm/amd/amdgpu: Add aGPU_LOADentry to sysfsQuoted 6 lines
This adds what should be a stable interface to read GPU load from userspace.
Signed-off-by Tom St Denis <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c| 41++++++++++++++++++++++++++++++++++
Review
Quoted 3 lines
1 file changed, 41 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.cdrivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t
Quoted 4 lines
index
113edffb5960..d57b414ac228100644drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0@@ -918,6 +918,37 @@ static ssize_tamdgpu_set_pp_power_profile_mode(struct device *dev,
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +0
-0return -EINVAL ; }Quoted 16 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +4
-0+static ssize_t amdgpu_get_busy_level (struct device *dev, +struct device_attribute *attr, +char *buf) +{drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, · line 934
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +10
-0+struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +int r, value, size =sizeof (value); + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the temperature */ Is load is the same thing as temperature?
Quoted 5 lines
Nope, there is a separate sensor for that but it is included in hwmon and Alex would rather not duplicate it.
GPU_LOADis a value returned by firmware based on the RLC busy status (I think...).
It's the overall busy status of all blocks that contribute to what the SMU considers busy for the purpose of dynamic clocking.
Alex
Quoted 7 lines
Tom
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 51 lines · Tom St Denis
This adds what should be a stable interface to read GPU load from userspace.
Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +31
-0@@ -918,6 +918,37 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,return -EINVAL ; } +static ssize_t amdgpu_get_busy_level (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev = ddev->dev_private; +int r, value, size =sizeof (value); + +/* sanity check PP is enabled */ +if (!(adev->powerplay.pp_funcs && + adev->powerplay.pp_funcs->read_sensor)) +return -EINVAL ; + +/* get the temperature */ + r =amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_LOAD , + (void *)&value, &size); +if (r) +return r; + +return snprintf (buf,PAGE_SIZE ,"%d\n" , value); +} + +static ssize_t amdgpu_set_gpu_busy_level (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +return -EINVAL ; +} + + static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, amdgpu_get_dpm_state, amdgpu_set_dpm_state); static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, amdgpu_get_dpm_forced_performance_level,
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c static DEVICE_ATTR(pp_power_profile_mode, S_IRUGO | S_IWUSR, · line 986
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2
-0@@ -951,6 +982,8 @@ static DEVICE_ATTR(pp_power_profile_mode, S_IRUGO | S_IWUSR, static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR, amdgpu_get_pp_od_clk_voltage, amdgpu_set_pp_od_clk_voltage); +static DEVICE_ATTR(gpu_busy_level, S_IRUGO | S_IWUSR, + amdgpu_get_busy_level, amdgpu_set_gpu_busy_level);
Maybe call the node gpu_busy_percent since it returns a percentage?
Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +8
-1static ssize_t amdgpu_hwmon_show_temp(struct device *dev, struct device_attribute *attr,@@ -1854,6 +1887,13 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) "pp_od_clk_voltage\n");return ret; } + ret =device_create_file (adev->dev, + &dev_attr_gpu_busy_level); +if (ret) { +DRM_ERROR ("failed to create device file " +"gpu_busy_level\n" ); +return ret; + } ret =amdgpu_debugfs_pm_init (adev);if (ret) {DRM_ERROR ("Failed to register debugfs file for dpm!\n" );@@ -1889,6 +1929,7 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev) &dev_attr_pp_power_profile_mode);device_remove_file (adev->dev, &dev_attr_pp_od_clk_voltage); +device_remove_file (adev->dev, &dev_attr_gpu_busy_level); }void amdgpu_pm_compute_clocks (struct amdgpu_device *adev) --2.14.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx