[Intel-gfx] [PATCH 2/2] drm/i915: Add current GPU freq to sysfs

Chris Wilson chris at chris-wilson.co.uk
Sun Sep 2 10:44:32 CEST 2012


On Sun,  2 Sep 2012 00:24:41 -0700, Ben Widawsky <ben at bwidawsk.net> wrote:
> Userspace applications such as PowerTOP are interesting in being able to
> read the current GPU frequency. The patch itself sets up a generic array
> for gen6 attributes so we can easily add other items in the future (and
> it also happens to be just about the cleanest way to do this).
> 
> The patch is a nice addition to
> commit 1ac02185dff3afac146d745ba220dc6672d1d162
> Author: Daniel Vetter <daniel.vetter at ffwll.ch>
> Date:   Thu Aug 30 13:26:48 2012 +0200
> 
>     drm/i915: add a tracepoint for gpu frequency changes
> 
> Reading the GPU frequncy can be done by reading a file like:
> /sys/class/drm/card0/render_frequency_mhz
> 
> CC: Arjan van de Ven <arjan at linux.intel.com>
> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>

> ---
>  drivers/gpu/drm/i915/i915_sysfs.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
> index da733a3..0cb479d 100644
> --- a/drivers/gpu/drm/i915/i915_sysfs.c
> +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> @@ -203,6 +203,30 @@ static struct bin_attribute dpf_attrs = {
>  	.mmap = NULL
>  };
>  
> +static ssize_t render_frequency_mhz_show(struct device *dev,
> +				     struct device_attribute *attr, char *buf)
> +{
> +	struct drm_minor *dminor = container_of(dev, struct drm_minor, kdev);
> +	struct drm_device *drm_dev = dminor->dev;
I would have called the struct device *kdev so that we could have our
standard nameing convention of struct drm_device *dev.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list