[Intel-gfx] [PATCH] drm/i915: prevent division by zero when asking for chipset power
Chris Wilson
chris at chris-wilson.co.uk
Thu Nov 10 14:21:38 CET 2011
On Thu, 10 Nov 2011 10:51:26 -0200, Eugeni Dodonov <eugeni.dodonov at intel.com> wrote:
> This prevents an in-kernel division by zero which happens when we are
> asking for i915_chipset_val too quickly, or within a race condition
> between the power monitoring thread and userspace accesses via debugfs.
>
> The issue can be reproduced easily via the following command:
> while ``; do cat /sys/kernel/debug/dri/0/i915_emon_status; done
>
> This is particularly dangerous because it can be triggered by
> a non-privileged user by just reading the debugfs entry.
>
> This issue was also found independently by Konstantin Belousov
> <kostikbel at gmail.com>, who proposed a similar patch.
>
> Reported-by: Konstantin Belousov <kostikbel at gmail.com>
> Acked-by: Jesse Barnes <jbarnes at virtuousgeek.org>
> Acked-by: Keith Packard <keithp at keithp.com>
> Cc: <stable at vger.kernel.org>
> Signed-off-by: Eugeni Dodonov <eugeni.dodonov at intel.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Just spotted a typo...
> ---
> drivers/gpu/drm/i915/i915_dma.c | 10 ++++++++++
> drivers/gpu/drm/i915/i915_drv.h | 1 +
> 2 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 8a3942c..de199e7 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1453,6 +1453,14 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv)
>
> diff1 = now - dev_priv->last_time1;
>
> + /* Prevent division-by-zero if we are asking too fast.
> + * Also, we don't get interesting results in we are polling
s/in/if/
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list