From: "Souza, Jose" Subject: Re: [PATCH] drm/i915/psr: Get pipe id following atomic guidelines Date: Wed, 28 Nov 2018 18:21:05 +0000 Message-ID: References: <20181128072838.22773-1-jose.souza@intel.com> <20181128165533.GA5161@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0775992261==" Return-path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 39AD86E14C for ; Wed, 28 Nov 2018 18:21:08 +0000 (UTC) In-Reply-To: <20181128165533.GA5161@intel.com> Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: "Vivi, Rodrigo" Cc: "intel-gfx@lists.freedesktop.org" , "Pandiyan, Dhinakaran" List-Id: intel-gfx@lists.freedesktop.org --===============0775992261== Content-Language: en-US Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="=-xz2gO9CiNpggtfgl4BZc" --=-xz2gO9CiNpggtfgl4BZc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2018-11-28 at 08:55 -0800, Rodrigo Vivi wrote: > On Tue, Nov 27, 2018 at 11:28:38PM -0800, Jos=C3=A9 Roberto de Souza > wrote: > > As stated in struct drm_encoder, crtc field should only be used > > by non-atomic drivers. > >=20 > > So here caching the pipe id in intel_psr_enable() what is way more > > simple and efficient than at every call to > > intel_psr_flush()/invalidate() get the > > drm.mode_config.connection_mutex lock to safely be able to get the > > pipe id by reading drm_connector_state.crtc. > >=20 > > This should fix the null pointer dereference crash below as the > > previous way to get the pipe id was prone to race conditions. > >=20 > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=3D105959 > > Cc: Dhinakaran Pandiyan > > Cc: Rodrigo Vivi > > Signed-off-by: Jos=C3=A9 Roberto de Souza > > --- > > drivers/gpu/drm/i915/i915_drv.h | 1 + > > drivers/gpu/drm/i915/intel_psr.c | 19 ++++--------------- > > 2 files changed, 5 insertions(+), 15 deletions(-) > >=20 > > diff --git a/drivers/gpu/drm/i915/i915_drv.h > > b/drivers/gpu/drm/i915/i915_drv.h > > index f763b30f98d9..9ea39b82836f 100644 > > --- a/drivers/gpu/drm/i915/i915_drv.h > > +++ b/drivers/gpu/drm/i915/i915_drv.h > > @@ -494,6 +494,7 @@ struct i915_psr { > > bool sink_support; > > bool prepared, enabled; > > struct intel_dp *dp; > > + enum pipe pipe; > > bool active; > > struct work_struct work; > > unsigned busy_frontbuffer_bits; > > diff --git a/drivers/gpu/drm/i915/intel_psr.c > > b/drivers/gpu/drm/i915/intel_psr.c > > index 572e626eadff..11a520074f06 100644 > > --- a/drivers/gpu/drm/i915/intel_psr.c > > +++ b/drivers/gpu/drm/i915/intel_psr.c > > @@ -705,6 +705,7 @@ void intel_psr_enable(struct intel_dp > > *intel_dp, > > dev_priv->psr.psr2_enabled =3D intel_psr2_enabled(dev_priv, > > crtc_state); > > dev_priv->psr.busy_frontbuffer_bits =3D 0; > > dev_priv->psr.prepared =3D true; > > + dev_priv->psr.pipe =3D to_intel_crtc(crtc_state->base.crtc)- > > >pipe; > > =20 > > if (psr_global_enabled(dev_priv->psr.debug)) > > intel_psr_enable_locked(dev_priv, crtc_state); > > @@ -1012,9 +1013,6 @@ static void intel_psr_work(struct work_struct > > *work) > > void intel_psr_invalidate(struct drm_i915_private *dev_priv, > > unsigned frontbuffer_bits, enum fb_op_origin > > origin) > > { > > - struct drm_crtc *crtc; > > - enum pipe pipe; > > - > > if (!CAN_PSR(dev_priv)) > > return; > > =20 > > @@ -1027,10 +1025,7 @@ void intel_psr_invalidate(struct > > drm_i915_private *dev_priv, > > return; > > } > > =20 > > - crtc =3D dp_to_dig_port(dev_priv->psr.dp)->base.base.crtc; > > - pipe =3D to_intel_crtc(crtc)->pipe; > > - > > - frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(pipe); > > + frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(dev_priv- > > >psr.pipe); > > dev_priv->psr.busy_frontbuffer_bits |=3D frontbuffer_bits; > > =20 > > if (frontbuffer_bits) > > @@ -1055,9 +1050,6 @@ void intel_psr_invalidate(struct > > drm_i915_private *dev_priv, > > void intel_psr_flush(struct drm_i915_private *dev_priv, > > unsigned frontbuffer_bits, enum fb_op_origin > > origin) > > { > > - struct drm_crtc *crtc; > > - enum pipe pipe; > > - > > if (!CAN_PSR(dev_priv)) > > return; > > =20 > > @@ -1070,10 +1062,7 @@ void intel_psr_flush(struct drm_i915_private > > *dev_priv, > > return; > > } > > =20 > > - crtc =3D dp_to_dig_port(dev_priv->psr.dp)->base.base.crtc; > > - pipe =3D to_intel_crtc(crtc)->pipe; > > - > > - frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(pipe); > > + frontbuffer_bits &=3D INTEL_FRONTBUFFER_ALL_MASK(dev_priv- > > >psr.pipe); >=20 > This approach will introduce another bug. >=20 > Any frontbuffer tracking from any connector on another pipe will > trigger > psr actions on eDP. Why that would happen? dev_priv->psr.pipe will be set with the pipe id that is used by the eDP panel so INTEL_FRONTBUFFER_ALL_MASK() will return only the frontbuffer bits of that pipe. >=20 > > dev_priv->psr.busy_frontbuffer_bits &=3D ~frontbuffer_bits; > > =20 > > /* By definition flush =3D invalidate + flush */ > > @@ -1087,7 +1076,7 @@ void intel_psr_flush(struct drm_i915_private > > *dev_priv, > > * but it makes more sense write to the current active > > * pipe. > > */ > > - I915_WRITE(CURSURFLIVE(pipe), 0); > > + I915_WRITE(CURSURFLIVE(dev_priv->psr.pipe), 0); > > } > > =20 > > if (!dev_priv->psr.active && !dev_priv- > > >psr.busy_frontbuffer_bits) > > --=20 > > 2.19.2 > >=20 > > _______________________________________________ > > Intel-gfx mailing list > > Intel-gfx@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx --=-xz2gO9CiNpggtfgl4BZc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEVNG051EijGa0MiaQVenbO/mOWkkFAlv+3I8ACgkQVenbO/mO WklgKwgAts3V5FwI6/dGchndAnqPr6J5ocGev/og7Qrrpep2NjwHm8Hg+ley9XF2 kE6L5Tf0wnT5/5PjzgPTUeinvabb87go+P1G4Ng8kvlV/oIUeCxLaN7yp8PPpFGD xaO9XW3Bptcl1UmEMmnhWO7Uvs47YLSPQruChB0SbFqMzuBws6SOxy/SLXU+BCbj eUIVODHjPu5iApa9XZZ/WijRioq65p7is12QYXOJPHaEYi5gt2Mhb9nSbY9myjui hxCJTfhzv12NbWv8tRj7enTwNCAl01fdhLYNlNtWPeoL5RIYdds74w4Rshf165Y7 Ik0lIrkTTpPaykrRBDhrB1KUpzsTRg== =dEIM -----END PGP SIGNATURE----- --=-xz2gO9CiNpggtfgl4BZc-- --===============0775992261== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============0775992261==--