From: Damien Lespiau Subject: Re: [PATCH v2] drm/i915: Rework workaround init functions for BDW and CHV Date: Tue, 2 Sep 2014 10:45:45 +0100 Message-ID: <20140902094545.GH1118@strange.amr.corp.intel.com> References: <1409578133-2800-2-git-send-email-arun.siluvery@linux.intel.com> <1409649257-12114-1-git-send-email-arun.siluvery@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 8936D6E434 for ; Tue, 2 Sep 2014 02:46:26 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1409649257-12114-1-git-send-email-arun.siluvery@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Arun Siluvery Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Tue, Sep 02, 2014 at 10:14:17AM +0100, Arun Siluvery wrote: > This rework is based on suggestion from Chris. > Now w/a are organized in an array and all of them are emitted in > single fn instead of sending them individually. This approach is > clean and new w/a can be added with minimal changes. > The same array can be used when exporting them to debugfs and the > temporary array in the current implementation is not required. > > v2: As suggested by Damien a new w/a reg definition is added. > This helps in initializing w/a that are unmasked registers. > > Signed-off-by: Arun Siluvery > --- > drivers/gpu/drm/i915/intel_ringbuffer.c | 158 ++++++++++++++------------------ > drivers/gpu/drm/i915/intel_ringbuffer.h | 26 ++++++ > 2 files changed, 93 insertions(+), 91 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c > index c5e4dc7..3ed0ad5 100644 > --- a/drivers/gpu/drm/i915/intel_ringbuffer.c > +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c > @@ -650,87 +650,80 @@ err: > return ret; > } > > -static inline void intel_ring_emit_wa(struct intel_engine_cs *ring, > - u32 addr, u32 value) > +static int i915_request_emit_lri(struct intel_engine_cs *ring, > + int num_registers, > + const struct intel_wa_reg *lri_list) > { [...] > + for (i = 0; i < num_registers; ++i) { > + u32 value; > + const struct intel_wa_reg *p = (lri_list + i); > > + if (p->masked_register) > + value = (p->mask << 16) | p->value; > + else > + value = (I915_READ(p->addr) & ~p->mask) | p->value; There's one case when this won't work, when several WAs for a single 'normal' register are defined. The read done here means only the last of those W/As will end up being applied (because the last LRI to that register will be the value that ends up in the register. We'll probably need to coalesce all W/A defined for a single normal register into one write. Considering that, and the comment about the define, maybe the simplest way to go forward with the patch is to forget the non-masked case for the moment, especially as it's not used in this patch. > +#define INIT_MASKED_WA(_addr, _value) \ > + INIT_WA_REG(1, _addr, ((_value) >> 16), ((_value) & 0xFFFF)) Those outer '()' look unnecessary > +#define INIT_UNMASKED_WA(_addr, _value) \ > + INIT_WA_REG(0, _addr, ~(_value), _value) > + ~value is not a mask. Consider values with one or more bits defined to 0. -- Damien