public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ben Widawsky <benjamin.widawsky@intel.com>
To: Damien Lespiau <damien.lespiau@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/i915: Protect the argument expansion in LRI and SRM macros
Date: Mon, 7 Apr 2014 13:47:05 -0700	[thread overview]
Message-ID: <20140407204705.GC18726@intel.com> (raw)
In-Reply-To: <1396898674-22510-2-git-send-email-damien.lespiau@intel.com>

On Mon, Apr 07, 2014 at 08:24:32PM +0100, Damien Lespiau wrote:
> It seems like it wouldn't be too unlikely to be wanting to use a an
> expression in the macro argument and things could go very wrong.
> 
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_reg.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 2315366..22d8b14 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -265,8 +265,8 @@
>   * - One can actually load arbitrary many arbitrary registers: Simply issue x
>   *   address/value pairs. Don't overdue it, though, x <= 2^4 must hold!
>   */
> -#define MI_LOAD_REGISTER_IMM(x)	MI_INSTR(0x22, 2*x-1)
> -#define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*x-1)
> +#define MI_LOAD_REGISTER_IMM(x)	MI_INSTR(0x22, 2*(x)-1)
> +#define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*(x)-1)
>  #define   MI_SRM_LRM_GLOBAL_GTT		(1<<22)
>  #define MI_FLUSH_DW		MI_INSTR(0x26, 1) /* for GEN6 */
>  #define   MI_FLUSH_DW_STORE_INDEX	(1<<21)

I was just looking at this macro myself recently (well, LRI, not SRM). I
think it would be good to WARN_ON values of X which are too large. (I'd
rather BUG, but we don't have to go that route). Any thoughts on that?

Reviewed-by: Ben Widawsky <ben@bwidawsk.net>


-- 
Ben Widawsky, Intel Open Source Technology Center

  reply	other threads:[~2014-04-07 23:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-07 19:24 [PATCH 0/3] GEN8 SRM changes Damien Lespiau
2014-04-07 19:24 ` [PATCH 1/3] drm/i915: Protect the argument expansion in LRI and SRM macros Damien Lespiau
2014-04-07 20:47   ` Ben Widawsky [this message]
2014-04-09 12:57     ` Daniel Vetter
2014-04-07 19:24 ` [PATCH 2/3] drm/i915/bdw: Provide a gen8 version of SRM Damien Lespiau
2014-04-07 19:24 ` [PATCH 3/3] drm/i915/bdw: Use the GEN8 SRM when qeueing a flip Damien Lespiau
2014-04-07 20:59   ` Ben Widawsky
2014-04-07 22:20     ` Damien Lespiau
2014-04-08  6:24       ` Chris Wilson
2014-04-08  6:54         ` Damien Lespiau
2014-04-09 12:59     ` Daniel Vetter

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=20140407204705.GC18726@intel.com \
    --to=benjamin.widawsky@intel.com \
    --cc=damien.lespiau@intel.com \
    --cc=intel-gfx@lists.freedesktop.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