All of lore.kernel.org
 help / color / mirror / Atom feed
From: "chris@chris-wilson.co.uk" <chris@chris-wilson.co.uk>
To: "Antoine, Peter" <peter.antoine@intel.com>
Cc: "intel-gfx@lists.freedesktop.org" <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v3] drm/i915 : Added Programming of the MOCS
Date: Wed, 17 Jun 2015 16:32:18 +0100	[thread overview]
Message-ID: <20150617153218.GK24012@nuc-i3427.alporthouse.com> (raw)
In-Reply-To: <1434553347.15415.21.camel@peterant-linux>

On Wed, Jun 17, 2015 at 03:02:31PM +0000, Antoine, Peter wrote:
> On Wed, 2015-06-10 at 11:37 +0100, Chris Wilson wrote:
> > > +/* Defines for the tables (XXX_MOCS_0 - XXX_MOCS_63) */
> > > +#define	MOCS_CACHEABILITY(value)	((value & 0x03) << 0)
> > 
> > value & mask? These macros should only be feed enums so the masking of
> > the input is superfluous and indicative of a programming bug.
> Superfluous yes, but it lets the coder know the layout of the field, but
> may hide a programming bug but does not indicate one (other coding
> standards (for safe systems) that I have used require this as it reduces
> the impact of coding errors).

I'm wary. Maybe not so much for the MOCS table, but it means that the
value being programmed to hw does not match what the programmer
intended. It's a bug either way, the hardware is being programmed to an
invalid value - and that may be catastrophic to use either the original
value of the transformed value.
 
> I have removed them.

I kind of liked it. With a bit of work we could make it catch
programming bugs at compile time. I think we have idly discussed such in
the past, something like a

#define SET_FIELD(x, shift, width) ({
  if (__builtin_constant_p(x)) {
  	BUILD_BUG_ON(x & -(1<<width));
  }
  x << shift;
 })

#define MOCS_CACHEABILITY(value) SET_FIELD(value, 0, 2)

may do the trick.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-06-17 15:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-04 18:27 [PATCH] drm/i915 : Added Programming of the MOCS Peter Antoine
2015-06-04 21:33 ` Matt Turner
2015-06-05  8:58   ` Antoine, Peter
2015-06-05 14:43 ` [PATCH v2] " Peter Antoine
2015-06-05 14:53   ` Damien Lespiau
2015-06-05 15:39     ` Antoine, Peter
2015-06-06  6:18   ` shuang.he
2015-06-05 17:16 ` [PATCH] " shuang.he
2015-06-10  8:12 ` [PATCH v3] " Peter Antoine
2015-06-10 10:37   ` Chris Wilson
2015-06-17 15:02     ` Antoine, Peter
2015-06-17 15:32       ` chris [this message]
2015-06-14  5:57   ` shuang.he
2015-06-15 12:51   ` Daniel Vetter
2015-06-17  7:03     ` Antoine, Peter

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=20150617153218.GK24012@nuc-i3427.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=peter.antoine@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.