From: "Souza, Jose" Subject: Re: [PATCH 2/2] drm/i915/psr: Execute the default PSR code path when setting i915_edp_psr_debug Date: Tue, 4 Dec 2018 01:54:08 +0000 Message-ID: References: <20181130023133.31636-1-jose.souza@intel.com> <20181130023133.31636-2-jose.souza@intel.com> <8b1416065bfd3529ba2a6fb2e913f1a98492475e.camel@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2027531859==" Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9704B89CCB for ; Tue, 4 Dec 2018 01:54:13 +0000 (UTC) In-Reply-To: <8b1416065bfd3529ba2a6fb2e913f1a98492475e.camel@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: "intel-gfx@lists.freedesktop.org" , "Pandiyan, Dhinakaran" Cc: "Vivi, Rodrigo" List-Id: intel-gfx@lists.freedesktop.org --===============2027531859== Content-Language: en-US Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="=-l5/TFW2naEeda+8w8Oey" --=-l5/TFW2naEeda+8w8Oey Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2018-12-03 at 17:33 -0800, Dhinakaran Pandiyan wrote: > On Thu, 2018-11-29 at 18:31 -0800, Jos=C3=A9 Roberto de Souza wrote: > > Changing the i915_edp_psr_debug was enabling, disabling or > > switching > > PSR version by directly calling intel_psr_disable_locked() and > > intel_psr_enable_locked(), what is not the default PSR path that is > > executed in a regular modesets. > >=20 > > So lets force a modeset in the PSR CRTC to trigger the requested > > PSR > > state change and really stress the code path that matters for the > > regular user. > >=20 > > Also by doing this way it fixes the issue below, were DRRS was left > > enabled together with PSR when enabling PSR from debugfs. >=20 > While this patch does fix the issue, psr_compute_config() not > checking > crtc_state->has_drrs seems odd. We should change it to not set > crtc_state->has_psr if crtc_state->has_drrs happens to be set. Or do > it > the other way around. psr_compute_config() is not called when enabling PSR from debugfs, this issue was reported when PSR1 was not enabled by default so DRRS was being enabled by default but not PSR and when PSR was enabled from debugfs both were kept enabled. In the first version of this patch I was just disabling DRRS when enabling PSR but Maarten suggested to not do so and instead stress the default code path. >=20 > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=3D108341 > > Cc: Maarten Lankhorst > > Cc: Dhinakaran Pandiyan > > Cc: Rodrigo Vivi > > Signed-off-by: Jos=C3=A9 Roberto de Souza > > --- > > drivers/gpu/drm/i915/i915_debugfs.c | 14 +--- > > drivers/gpu/drm/i915/i915_drv.h | 2 +- > > drivers/gpu/drm/i915/intel_drv.h | 4 +- > > drivers/gpu/drm/i915/intel_psr.c | 119 ++++++++++++------------ > > ---- > > 4 files changed, 55 insertions(+), 84 deletions(-) > >=20 > > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c > > b/drivers/gpu/drm/i915/i915_debugfs.c > > index 129b9a6f8309..bc32f683dc46 100644 > > --- a/drivers/gpu/drm/i915/i915_debugfs.c > > +++ b/drivers/gpu/drm/i915/i915_debugfs.c > > @@ -2775,7 +2775,6 @@ static int > > i915_edp_psr_debug_set(void *data, u64 val) > > { > > struct drm_i915_private *dev_priv =3D data; > > - struct drm_modeset_acquire_ctx ctx; > > int ret; > > =20 > > if (!CAN_PSR(dev_priv)) > > @@ -2785,18 +2784,7 @@ i915_edp_psr_debug_set(void *data, u64 val) > > =20 > > intel_runtime_pm_get(dev_priv); > > =20 > > - drm_modeset_acquire_init(&ctx, > > DRM_MODESET_ACQUIRE_INTERRUPTIBLE); > > - > > -retry: > > - ret =3D intel_psr_set_debugfs_mode(dev_priv, &ctx, val); > > - if (ret =3D=3D -EDEADLK) { > > - ret =3D drm_modeset_backoff(&ctx); > > - if (!ret) > > - goto retry; > > - } > > - > > - drm_modeset_drop_locks(&ctx); > > - drm_modeset_acquire_fini(&ctx); > > + ret =3D intel_psr_set_debugfs_mode(dev_priv, val); > > =20 > > intel_runtime_pm_put(dev_priv); > > =20 > > diff --git a/drivers/gpu/drm/i915/i915_drv.h > > b/drivers/gpu/drm/i915/i915_drv.h > > index 43ac6873a2bb..93d8ca9c0375 100644 > > --- a/drivers/gpu/drm/i915/i915_drv.h > > +++ b/drivers/gpu/drm/i915/i915_drv.h > > @@ -493,7 +493,7 @@ struct i915_psr { > > =20 > > u32 debug; > > bool sink_support; > > - bool prepared, enabled; > > + bool enabled; > > struct intel_dp *dp; > > bool active; > > struct work_struct work; > > diff --git a/drivers/gpu/drm/i915/intel_drv.h > > b/drivers/gpu/drm/i915/intel_drv.h > > index 86ff57738cd9..89d4eed0dd89 100644 > > --- a/drivers/gpu/drm/i915/intel_drv.h > > +++ b/drivers/gpu/drm/i915/intel_drv.h > > @@ -2056,9 +2056,7 @@ void intel_psr_enable(struct intel_dp > > *intel_dp, > > const struct intel_crtc_state *crtc_state); > > void intel_psr_disable(struct intel_dp *intel_dp, > > const struct intel_crtc_state *old_crtc_state); > > -int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, > > - struct drm_modeset_acquire_ctx *ctx, > > - u64 value); > > +int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, > > u64 value); > > void intel_psr_invalidate(struct drm_i915_private *dev_priv, > > unsigned frontbuffer_bits, > > enum fb_op_origin origin); > > diff --git a/drivers/gpu/drm/i915/intel_psr.c > > b/drivers/gpu/drm/i915/intel_psr.c > > index 827b8c31783d..305848cceda7 100644 > > --- a/drivers/gpu/drm/i915/intel_psr.c > > +++ b/drivers/gpu/drm/i915/intel_psr.c > > @@ -52,6 +52,7 @@ > > */ > > =20 > > #include > > +#include > > =20 > > #include "intel_drv.h" > > #include "i915_drv.h" > > @@ -711,10 +712,6 @@ void intel_psr_enable(struct intel_dp > > *intel_dp, > > WARN_ON(dev_priv->drrs.dp); > > =20 > > mutex_lock(&dev_priv->psr.lock); > > - if (dev_priv->psr.prepared) { > > - DRM_DEBUG_KMS("PSR already in use\n"); > > - goto unlock; > > - } > > =20 > > if (!psr_global_enabled(dev_priv->psr.debug)) { > > DRM_DEBUG_KMS("PSR disabled by flag\n"); > > @@ -723,7 +720,6 @@ void intel_psr_enable(struct intel_dp > > *intel_dp, > > =20 > > 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; > > intel_psr_enable_locked(dev_priv, crtc_state); > > =20 > > unlock: > > @@ -807,14 +803,9 @@ void intel_psr_disable(struct intel_dp > > *intel_dp, > > return; > > =20 > > mutex_lock(&dev_priv->psr.lock); > > - if (!dev_priv->psr.prepared) { > > - mutex_unlock(&dev_priv->psr.lock); > > - return; > > - } > > =20 > > intel_psr_disable_locked(intel_dp); > > =20 > > - dev_priv->psr.prepared =3D false; > > mutex_unlock(&dev_priv->psr.lock); > > cancel_work_sync(&dev_priv->psr.work); > > } > > @@ -883,36 +874,61 @@ static bool __psr_wait_for_idle_locked(struct > > drm_i915_private *dev_priv) > > return err =3D=3D 0 && dev_priv->psr.enabled; > > } > > =20 > > -static bool switching_psr(struct drm_i915_private *dev_priv, > > - struct intel_crtc_state *crtc_state, > > - u32 mode) > > +static int intel_psr_modeset_force(struct drm_i915_private > > *dev_priv) > > { > > - /* Can't switch psr state anyway if PSR2 is not supported. */ > > - if (!crtc_state || !crtc_state->has_psr2) > > - return false; > > + struct drm_device *dev =3D &dev_priv->drm; > > + struct drm_modeset_acquire_ctx ctx; > > + struct drm_atomic_state *state; > > + struct drm_crtc_state *crtc_state; > > + struct drm_crtc *crtc; > > + int err, i; > > + > > + mutex_lock(&dev->mode_config.mutex); > > + drm_modeset_acquire_init(&ctx, 0); > > + > > +modeset_lock_retry: > > + err =3D drm_modeset_lock_all_ctx(dev, &ctx); > > + if (err) { > > + if (err =3D=3D -EDEADLK) { > > + err =3D drm_modeset_backoff(&ctx); > > + if (!err) > > + goto modeset_lock_retry; > > + } > > =20 > > - if (dev_priv->psr.psr2_enabled && mode =3D=3D > > I915_PSR_DEBUG_FORCE_PSR1) > > - return true; > > + goto unlock; > > + } > > =20 > > - if (!dev_priv->psr.psr2_enabled && mode !=3D > > I915_PSR_DEBUG_FORCE_PSR1) > > - return true; > > + state =3D drm_atomic_helper_duplicate_state(dev, &ctx); > > + if (IS_ERR(state)) { > > + err =3D PTR_ERR(state); > > + goto unlock; > > + } > > + > > + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { > > + struct intel_crtc_state *pipe_state; > > + > > + pipe_state =3D to_intel_crtc_state(crtc_state); > > + /* Mark mode as changed to force a modeset */ > > + if (pipe_state->has_psr) > > + crtc_state->mode_changed =3D true; > > + } > > + > > + err =3D drm_atomic_helper_commit_duplicated_state(state, &ctx); > > =20 > > - return false; > > + drm_atomic_state_put(state); > > +unlock: > > + drm_modeset_drop_locks(&ctx); > > + drm_modeset_acquire_fini(&ctx); > > + mutex_unlock(&dev->mode_config.mutex); > > + > > + return err; > > } > > =20 > > -int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, > > - struct drm_modeset_acquire_ctx *ctx, > > - u64 val) > > +int intel_psr_set_debugfs_mode(struct drm_i915_private *dev_priv, > > u64 val) > > { > > - struct drm_device *dev =3D &dev_priv->drm; > > - struct drm_connector_state *conn_state; > > - struct intel_crtc_state *crtc_state =3D NULL; > > - struct drm_crtc_commit *commit; > > - struct drm_crtc *crtc; > > - struct intel_dp *dp; > > + const u32 mode =3D val & I915_PSR_DEBUG_MODE_MASK; > > + u32 old_mode; > > int ret; > > - bool enable; > > - u32 mode =3D val & I915_PSR_DEBUG_MODE_MASK; > > =20 > > if (val & ~(I915_PSR_DEBUG_IRQ | I915_PSR_DEBUG_MODE_MASK) || > > mode > I915_PSR_DEBUG_FORCE_PSR1) { > > @@ -920,49 +936,18 @@ int intel_psr_set_debugfs_mode(struct > > drm_i915_private *dev_priv, > > return -EINVAL; > > } > > =20 > > - ret =3D drm_modeset_lock(&dev->mode_config.connection_mutex, > > ctx); > > - if (ret) > > - return ret; > > - > > - /* dev_priv->psr.dp should be set once and then never touched > > again. */ > > - dp =3D READ_ONCE(dev_priv->psr.dp); > > - conn_state =3D dp->attached_connector->base.state; > > - crtc =3D conn_state->crtc; > > - if (crtc) { > > - ret =3D drm_modeset_lock(&crtc->mutex, ctx); > > - if (ret) > > - return ret; > > - > > - crtc_state =3D to_intel_crtc_state(crtc->state); > > - commit =3D crtc_state->base.commit; > > - } else { > > - commit =3D conn_state->commit; > > - } > > - if (commit) { > > - ret =3D wait_for_completion_interruptible(&commit- > > > hw_done); > > - if (ret) > > - return ret; > > - } > > - > > ret =3D mutex_lock_interruptible(&dev_priv->psr.lock); > > if (ret) > > return ret; > > =20 > > - enable =3D psr_global_enabled(val); > > - > > - if (!enable || switching_psr(dev_priv, crtc_state, mode)) > > - intel_psr_disable_locked(dev_priv->psr.dp); > > - > > + old_mode =3D dev_priv->psr.debug & I915_PSR_DEBUG_MODE_MASK; > > dev_priv->psr.debug =3D val; > > - if (crtc) > > - dev_priv->psr.psr2_enabled =3D > > intel_psr2_enabled(dev_priv, crtc_state); > > =20 > > - intel_psr_irq_control(dev_priv, dev_priv->psr.debug); > > + mutex_unlock(&dev_priv->psr.lock); > > =20 > > - if (dev_priv->psr.prepared && enable) > > - intel_psr_enable_locked(dev_priv, crtc_state); > > + if (old_mode !=3D mode) > > + ret =3D intel_psr_modeset_force(dev_priv); > > =20 > > - mutex_unlock(&dev_priv->psr.lock); > > return ret; > > } > > =20 --=-l5/TFW2naEeda+8w8Oey 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/mOWkkFAlwF3j4ACgkQVenbO/mO Wkm4JggAjHwrg3pBZZlWAbnyVU2xoPRAT/o192iOeaNJvPqQeHZdman5Qna5ZAPa K5oAw9wpqocyxWrcCI2HSJbTLhyr+0OfT+WlGKuPqdiJFgkprgCE+9d9BttzCHM8 QSM21Fv++oYF8BU5Iuh/AiH24Cbzd++0MGMcYdxj1yMXx3qkTUzckUJn15kOTy1y dpSWFvcy0oiU2TyEs4mSTj+N0B/YVc9mid8tT7BujcuULMRSj97gN91sr9mk3aij XXt6b5n1pYRtIkSC5HMi3eg4TCjzWs7fRONzwLurg/Vf6B2makbOUP6nZw1o3cy0 3Ms5Q7gjLLoUs3q+0JVV1xI6vzK+MA== =cQyU -----END PGP SIGNATURE----- --=-l5/TFW2naEeda+8w8Oey-- --===============2027531859== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============2027531859==--