From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Ausmus, James" Subject: Re: [PATCH] drm/i915: Disable caches for Global GTT. Date: Fri, 31 Oct 2014 14:38:58 -0700 Message-ID: References: <20141031102051.GI18917@nuc-i3427.alporthouse.com> <1414758442-30878-1-git-send-email-rodrigo.vivi@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0368272132==" Return-path: Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 2ECA66E7B9 for ; Fri, 31 Oct 2014 14:39:38 -0700 (PDT) Received: by mail-la0-f48.google.com with SMTP id gq15so6790148lab.7 for ; Fri, 31 Oct 2014 14:39:38 -0700 (PDT) In-Reply-To: <1414758442-30878-1-git-send-email-rodrigo.vivi@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Rodrigo Vivi Cc: Intel GFX List-Id: intel-gfx@lists.freedesktop.org --===============0368272132== Content-Type: multipart/alternative; boundary=001a11c32bd6731e7e0506bed535 --001a11c32bd6731e7e0506bed535 Content-Type: text/plain; charset=UTF-8 On Fri, Oct 31, 2014 at 5:27 AM, Rodrigo Vivi wrote: > > Global GTT doesn't have pat_sel[2:0] so it always point to pat_sel = 000; > So the only way to avoid screen corruptions is setting PAT 0 to Uncached. > > MOCS can still be used though. But if userspace is trusting PTE for > cache selection the safest thing to do is to let caches disabled. > > BSpec: "For GGTT, there is NO pat_sel[2:0] from the entry, > so RTL will always use the value corresponding to pat_sel = 000" > > v2: Cleaner patch as suggested by Chris. > > Reference: https://bugs.freedesktop.org/show_bug.cgi?id=85576 > Cc: Chris Wilson > Cc: James Ausmus > Signed-off-by: Rodrigo Vivi > --- > drivers/gpu/drm/i915/i915_gem_gtt.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c > index cb7adab..ae568a2 100644 > --- a/drivers/gpu/drm/i915/i915_gem_gtt.c > +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c > @@ -1920,6 +1920,15 @@ static void bdw_setup_private_ppat(struct drm_i915_private *dev_priv) > GEN8_PPAT(6, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(2)) | > GEN8_PPAT(7, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(3)); > > + if (!USES_PPGTT(dev_priv->dev)) > + /* Spec: "For GGTT, there is NO pat_sel[2:0] from the entry, > + * so RTL will always use the value corresponding to > + * pat_sel = 000". > + * So let's disable cache for GGTT to avoid screen corruptions. > + * MOCS still can be used though. > + */ > + pat = GEN8_PPAT(0, GEN8_PPAT_UC); > + > /* XXX: spec defines this as 2 distinct registers. It's unclear if a 64b > * write would work. */ > I915_WRITE(GEN8_PRIVATE_PAT, pat); > -- > 1.9.3 > Tested-by: James Ausmus -- James Ausmus Sr. Software Engineer SSG-OTC ChromeOS Integration --001a11c32bd6731e7e0506bed535 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Fri, Oct 31, 2014 at 5:27 AM, Rodrigo Vivi <= rodrigo.vivi@intel.com> wr= ote:
>
> Global GTT doesn't have pat_sel[2:0] so it always = point to pat_sel =3D 000;
> So the only way to avoid screen corruptio= ns is setting PAT 0 to Uncached.
>
> MOCS can still be used tho= ugh. But if userspace is trusting PTE for
> cache selection the safes= t thing to do is to let caches disabled.
>
> BSpec: "For G= GTT, there is NO pat_sel[2:0] from the entry,
> so RTL will always us= e the value corresponding to pat_sel =3D 000"
>
> v2: Clea= ner patch as suggested by Chris.
>
> Reference: https://bugs.freedesktop.= org/show_bug.cgi?id=3D85576
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: = James Ausmus <james.ausmus@int= el.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> = =C2=A0drivers/gpu/drm/i915/i915_gem_gtt.c | 9 +++++++++
> =C2=A01 fil= e changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/i91= 5/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index cb7ada= b..ae568a2 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
>= +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -1920,6 +1920,15 @@ s= tatic void bdw_setup_private_ppat(struct drm_i915_private *dev_priv)
>= ; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 GEN8_PPAT(6, GEN8_PPAT_W= B | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(2)) |
> =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 GEN8_PPAT(7, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC |= GEN8_PPAT_AGE(3));
>
> + =C2=A0 =C2=A0 =C2=A0 if (!USES_PPGTT(= dev_priv->dev))
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 /* Spec: "For GGTT, there is NO pat_sel[2:0] from the entry,
&g= t; + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* so RTL will a= lways use the value corresponding to
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0* pat_sel =3D 000".
> + =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* So let's disable cache for = GGTT to avoid screen corruptions.
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0* MOCS still can be used though.
> + =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
> + =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pat =3D GEN8_PPAT(0, GEN8_PPAT_UC);
&= gt; +
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* XXX: spec defines this as 2 di= stinct registers. It's unclear if a 64b
> =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0* write would work. */
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 I91= 5_WRITE(GEN8_PRIVATE_PAT, pat);
> --
> 1.9.3
>

Tested<= /span>-<= span class=3D"" style=3D"font-family:arial,sans-serif;font-size:13px">by: James Aus= mus <james.ausmus@intel.com>


--


James Ausmus
Sr. Software Engineer=
SSG-OTC ChromeOS Integration
--001a11c32bd6731e7e0506bed535-- --===============0368272132== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHA6Ly9saXN0 cy5mcmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9pbnRlbC1nZngK --===============0368272132==--