From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Tom St Denis <tom.stdenis-5C7GfCeVMHo@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/amd/amdgpu: Add a GPU_LOAD entry to sysfs (v2)
Date: Thu, 21 Jun 2018 11:23:38 +0200 [thread overview]
Message-ID: <af64317b-eaec-ffc1-7e27-1a0bae278fa3@gmail.com> (raw)
In-Reply-To: <20180620164852.26424-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
Am 20.06.2018 um 18:48 schrieb Tom St Denis:
> This adds what should be a stable interface to read GPU
> load from userspace.
>
> (v2): Fix comments and name of file per recommendations.
>
> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 47 ++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> index 113edffb5960..49138ac2be24 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> @@ -918,6 +918,43 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,
> return -EINVAL;
> }
>
> +/**
> + * DOC: busy_percent
> + *
> + * The firmware computes a percentage of load based on the activity
> + * level in the IP cores.
> + */
> +static ssize_t amdgpu_get_busy_percent(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;
> +
> + /* read the IP busy sensor */
> + 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_busy_percent(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf,
> + size_t count)
> +{
> + return -EINVAL;
> +}
> +
> +
For read only attributes the set function can be specified as NULL as well.
Apart from that this looks good to me,
Christian.
> 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 +988,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_percent, S_IRUGO | S_IWUSR,
> + amdgpu_get_busy_percent, amdgpu_set_busy_percent);
>
> static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
> struct device_attribute *attr,
> @@ -1854,6 +1893,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_percent);
> + 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 +1935,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_percent);
> }
>
> void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
prev parent reply other threads:[~2018-06-21 9:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 16:48 [PATCH] drm/amd/amdgpu: Add a GPU_LOAD entry to sysfs (v2) Tom St Denis
[not found] ` <20180620164852.26424-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2018-06-20 19:01 ` Abramov, Slava
2018-06-20 19:14 ` Alex Deucher
2018-06-21 9:23 ` Christian König [this message]
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=af64317b-eaec-ffc1-7e27-1a0bae278fa3@gmail.com \
--to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
--cc=tom.stdenis-5C7GfCeVMHo@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox