linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v1] drm/msm/dpu: Fix reservation failures in modeset
@ 2020-08-05 13:34 Kalyan Thota
  2020-08-05 15:48 ` Rob Clark
  0 siblings, 1 reply; 6+ messages in thread
From: Kalyan Thota @ 2020-08-05 13:34 UTC (permalink / raw)
  To: dri-devel, linux-arm-msm, freedreno, devicetree
  Cc: Kalyan Thota, linux-kernel, robdclark, seanpaul, hoegsberg,
	dianders, mkrishn, travitej, nganji, swboyd, abhinavk,
	ddavenport

In TEST_ONLY commit, rm global_state will duplicate the
object and request for new reservations, once they pass
then the new state will be swapped with the old and will
be available for the Atomic Commit.

This patch fixes some of missing links in the resource
reservation sequence mentioned above.

1) Creation of a duplicate state in test_only commit (Rob)
2) Allow resource release only during crtc_active false.

For #2
In a modeset operation, swap state happens well before disable.
Hence clearing reservations in disable will cause failures
in modeset enable.

Sequence:
    Swap state --> old, new
    modeset disables --> virt disable
    modeset enable --> virt modeset

Allow reservations to be cleared only when crtc active is false
as in that case there wont be any modeset enable after disable.

Signed-off-by: Kalyan Thota <kalyan_t@codeaurora.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 63976dc..b85a576 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -582,7 +582,7 @@ static int dpu_encoder_virt_atomic_check(
 	dpu_kms = to_dpu_kms(priv->kms);
 	mode = &crtc_state->mode;
 	adj_mode = &crtc_state->adjusted_mode;
-	global_state = dpu_kms_get_existing_global_state(dpu_kms);
+	global_state = dpu_kms_get_global_state(crtc_state->state);
 	trace_dpu_enc_atomic_check(DRMID(drm_enc));
 
 	/*
@@ -1172,6 +1172,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
 	struct msm_drm_private *priv;
 	struct dpu_kms *dpu_kms;
 	struct dpu_global_state *global_state;
+	struct drm_crtc_state *crtc_state;
 	int i = 0;
 
 	if (!drm_enc) {
@@ -1191,6 +1192,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
 	priv = drm_enc->dev->dev_private;
 	dpu_kms = to_dpu_kms(priv->kms);
 	global_state = dpu_kms_get_existing_global_state(dpu_kms);
+	crtc_state = drm_enc->crtc->state;
 
 	trace_dpu_enc_disable(DRMID(drm_enc));
 
@@ -1220,7 +1222,8 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
 
 	DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n");
 
-	dpu_rm_release(global_state, drm_enc);
+	if (crtc_state->active_changed && !crtc_state->active)
+		dpu_rm_release(global_state, drm_enc);
 
 	mutex_unlock(&dpu_enc->enc_lock);
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [v1] drm/msm/dpu: Fix reservation failures in modeset
  2020-08-05 13:34 [v1] drm/msm/dpu: Fix reservation failures in modeset Kalyan Thota
@ 2020-08-05 15:48 ` Rob Clark
  2020-08-06 14:45   ` [Freedreno] " kalyan_t
  2020-08-07  8:57   ` daniel
  0 siblings, 2 replies; 6+ messages in thread
From: Rob Clark @ 2020-08-05 15:48 UTC (permalink / raw)
  To: Kalyan Thota
  Cc: dri-devel, linux-arm-msm, freedreno,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Linux Kernel Mailing List, Sean Paul, Kristian H. Kristensen,
	Douglas Anderson, Krishna Manikandan, Raviteja Tamatam, nganji,
	Stephen Boyd, Abhinav Kumar, Drew Davenport

On Wed, Aug 5, 2020 at 6:34 AM Kalyan Thota <kalyan_t@codeaurora.org> wrote:
>
> In TEST_ONLY commit, rm global_state will duplicate the
> object and request for new reservations, once they pass
> then the new state will be swapped with the old and will
> be available for the Atomic Commit.
>
> This patch fixes some of missing links in the resource
> reservation sequence mentioned above.
>
> 1) Creation of a duplicate state in test_only commit (Rob)
> 2) Allow resource release only during crtc_active false.
>
> For #2
> In a modeset operation, swap state happens well before disable.
> Hence clearing reservations in disable will cause failures
> in modeset enable.
>
> Sequence:
>     Swap state --> old, new
>     modeset disables --> virt disable
>     modeset enable --> virt modeset
>
> Allow reservations to be cleared only when crtc active is false
> as in that case there wont be any modeset enable after disable.
>
> Signed-off-by: Kalyan Thota <kalyan_t@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index 63976dc..b85a576 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -582,7 +582,7 @@ static int dpu_encoder_virt_atomic_check(
>         dpu_kms = to_dpu_kms(priv->kms);
>         mode = &crtc_state->mode;
>         adj_mode = &crtc_state->adjusted_mode;
> -       global_state = dpu_kms_get_existing_global_state(dpu_kms);
> +       global_state = dpu_kms_get_global_state(crtc_state->state);
>         trace_dpu_enc_atomic_check(DRMID(drm_enc));
>
>         /*
> @@ -1172,6 +1172,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
>         struct msm_drm_private *priv;
>         struct dpu_kms *dpu_kms;
>         struct dpu_global_state *global_state;
> +       struct drm_crtc_state *crtc_state;
>         int i = 0;
>
>         if (!drm_enc) {
> @@ -1191,6 +1192,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
>         priv = drm_enc->dev->dev_private;
>         dpu_kms = to_dpu_kms(priv->kms);
>         global_state = dpu_kms_get_existing_global_state(dpu_kms);
> +       crtc_state = drm_enc->crtc->state;
>
>         trace_dpu_enc_disable(DRMID(drm_enc));
>
> @@ -1220,7 +1222,8 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
>
>         DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n");
>
> -       dpu_rm_release(global_state, drm_enc);
> +       if (crtc_state->active_changed && !crtc_state->active)
> +               dpu_rm_release(global_state, drm_enc);

I still think releasing the state in the atomic_commit() path is the
wrong thing to do.  In the commit path, the various state objects
should be immutable.. ie. in the atomic_test() path you derive the new
hw state (including assignment/release of resources), and
atomic_commit() is simply pushing the state down to the hw.

Otherwise, this looks better than v1.

BR,
-R

>
>         mutex_unlock(&dpu_enc->enc_lock);
>  }
> --
> 1.9.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Freedreno] [v1] drm/msm/dpu: Fix reservation failures in modeset
  2020-08-05 15:48 ` Rob Clark
@ 2020-08-06 14:45   ` kalyan_t
  2020-08-06 16:45     ` Rob Clark
  2020-08-07  8:57   ` daniel
  1 sibling, 1 reply; 6+ messages in thread
From: kalyan_t @ 2020-08-06 14:45 UTC (permalink / raw)
  To: Rob Clark
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Krishna Manikandan, linux-arm-msm, Raviteja Tamatam,
	Linux Kernel Mailing List, dri-devel, Douglas Anderson, nganji,
	Sean Paul, Abhinav Kumar, Drew Davenport, Kristian H. Kristensen,
	Stephen Boyd, freedreno

On 2020-08-05 21:18, Rob Clark wrote:
> On Wed, Aug 5, 2020 at 6:34 AM Kalyan Thota <kalyan_t@codeaurora.org> 
> wrote:
>> 
>> In TEST_ONLY commit, rm global_state will duplicate the
>> object and request for new reservations, once they pass
>> then the new state will be swapped with the old and will
>> be available for the Atomic Commit.
>> 
>> This patch fixes some of missing links in the resource
>> reservation sequence mentioned above.
>> 
>> 1) Creation of a duplicate state in test_only commit (Rob)
>> 2) Allow resource release only during crtc_active false.
>> 
>> For #2
>> In a modeset operation, swap state happens well before disable.
>> Hence clearing reservations in disable will cause failures
>> in modeset enable.
>> 
>> Sequence:
>>     Swap state --> old, new
>>     modeset disables --> virt disable
>>     modeset enable --> virt modeset
>> 
>> Allow reservations to be cleared only when crtc active is false
>> as in that case there wont be any modeset enable after disable.
>> 
>> Signed-off-by: Kalyan Thota <kalyan_t@codeaurora.org>
>> ---
>>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> index 63976dc..b85a576 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> @@ -582,7 +582,7 @@ static int dpu_encoder_virt_atomic_check(
>>         dpu_kms = to_dpu_kms(priv->kms);
>>         mode = &crtc_state->mode;
>>         adj_mode = &crtc_state->adjusted_mode;
>> -       global_state = dpu_kms_get_existing_global_state(dpu_kms);
>> +       global_state = dpu_kms_get_global_state(crtc_state->state);
>>         trace_dpu_enc_atomic_check(DRMID(drm_enc));
>> 
>>         /*
>> @@ -1172,6 +1172,7 @@ static void dpu_encoder_virt_disable(struct 
>> drm_encoder *drm_enc)
>>         struct msm_drm_private *priv;
>>         struct dpu_kms *dpu_kms;
>>         struct dpu_global_state *global_state;
>> +       struct drm_crtc_state *crtc_state;
>>         int i = 0;
>> 
>>         if (!drm_enc) {
>> @@ -1191,6 +1192,7 @@ static void dpu_encoder_virt_disable(struct 
>> drm_encoder *drm_enc)
>>         priv = drm_enc->dev->dev_private;
>>         dpu_kms = to_dpu_kms(priv->kms);
>>         global_state = dpu_kms_get_existing_global_state(dpu_kms);
>> +       crtc_state = drm_enc->crtc->state;
>> 
>>         trace_dpu_enc_disable(DRMID(drm_enc));
>> 
>> @@ -1220,7 +1222,8 @@ static void dpu_encoder_virt_disable(struct 
>> drm_encoder *drm_enc)
>> 
>>         DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n");
>> 
>> -       dpu_rm_release(global_state, drm_enc);
>> +       if (crtc_state->active_changed && !crtc_state->active)
>> +               dpu_rm_release(global_state, drm_enc);
> 
> I still think releasing the state in the atomic_commit() path is the
> wrong thing to do.  In the commit path, the various state objects
> should be immutable.. ie. in the atomic_test() path you derive the new
> hw state (including assignment/release of resources), and
> atomic_commit() is simply pushing the state down to the hw.
> 
> Otherwise, this looks better than v1.
> 
> BR,
> -R
> 
okay. Should we avoid reservation all together if active=0 on that crtc 
and trigger rm_release on the enc during atomic_check ?
how do you see the approach ?

-Kalyan
>> 
>>         mutex_unlock(&dpu_enc->enc_lock);
>>  }
>> --
>> 1.9.1
>> 
> _______________________________________________
> Freedreno mailing list
> Freedreno@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/freedreno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Freedreno] [v1] drm/msm/dpu: Fix reservation failures in modeset
  2020-08-06 14:45   ` [Freedreno] " kalyan_t
@ 2020-08-06 16:45     ` Rob Clark
  2020-08-07 13:13       ` kalyan_t
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Clark @ 2020-08-06 16:45 UTC (permalink / raw)
  To: Kalyan Thota
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Krishna Manikandan, linux-arm-msm, Raviteja Tamatam,
	Linux Kernel Mailing List, dri-devel, Douglas Anderson, nganji,
	Sean Paul, Abhinav Kumar, Drew Davenport, Kristian H. Kristensen,
	Stephen Boyd, freedreno

On Thu, Aug 6, 2020 at 7:46 AM <kalyan_t@codeaurora.org> wrote:
>
> On 2020-08-05 21:18, Rob Clark wrote:
> > On Wed, Aug 5, 2020 at 6:34 AM Kalyan Thota <kalyan_t@codeaurora.org>
> > wrote:
> >>
> >> In TEST_ONLY commit, rm global_state will duplicate the
> >> object and request for new reservations, once they pass
> >> then the new state will be swapped with the old and will
> >> be available for the Atomic Commit.
> >>
> >> This patch fixes some of missing links in the resource
> >> reservation sequence mentioned above.
> >>
> >> 1) Creation of a duplicate state in test_only commit (Rob)
> >> 2) Allow resource release only during crtc_active false.
> >>
> >> For #2
> >> In a modeset operation, swap state happens well before disable.
> >> Hence clearing reservations in disable will cause failures
> >> in modeset enable.
> >>
> >> Sequence:
> >>     Swap state --> old, new
> >>     modeset disables --> virt disable
> >>     modeset enable --> virt modeset
> >>
> >> Allow reservations to be cleared only when crtc active is false
> >> as in that case there wont be any modeset enable after disable.
> >>
> >> Signed-off-by: Kalyan Thota <kalyan_t@codeaurora.org>
> >> ---
> >>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 7 +++++--
> >>  1 file changed, 5 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> >> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> >> index 63976dc..b85a576 100644
> >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> >> @@ -582,7 +582,7 @@ static int dpu_encoder_virt_atomic_check(
> >>         dpu_kms = to_dpu_kms(priv->kms);
> >>         mode = &crtc_state->mode;
> >>         adj_mode = &crtc_state->adjusted_mode;
> >> -       global_state = dpu_kms_get_existing_global_state(dpu_kms);
> >> +       global_state = dpu_kms_get_global_state(crtc_state->state);
> >>         trace_dpu_enc_atomic_check(DRMID(drm_enc));
> >>
> >>         /*
> >> @@ -1172,6 +1172,7 @@ static void dpu_encoder_virt_disable(struct
> >> drm_encoder *drm_enc)
> >>         struct msm_drm_private *priv;
> >>         struct dpu_kms *dpu_kms;
> >>         struct dpu_global_state *global_state;
> >> +       struct drm_crtc_state *crtc_state;
> >>         int i = 0;
> >>
> >>         if (!drm_enc) {
> >> @@ -1191,6 +1192,7 @@ static void dpu_encoder_virt_disable(struct
> >> drm_encoder *drm_enc)
> >>         priv = drm_enc->dev->dev_private;
> >>         dpu_kms = to_dpu_kms(priv->kms);
> >>         global_state = dpu_kms_get_existing_global_state(dpu_kms);
> >> +       crtc_state = drm_enc->crtc->state;
> >>
> >>         trace_dpu_enc_disable(DRMID(drm_enc));
> >>
> >> @@ -1220,7 +1222,8 @@ static void dpu_encoder_virt_disable(struct
> >> drm_encoder *drm_enc)
> >>
> >>         DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n");
> >>
> >> -       dpu_rm_release(global_state, drm_enc);
> >> +       if (crtc_state->active_changed && !crtc_state->active)
> >> +               dpu_rm_release(global_state, drm_enc);
> >
> > I still think releasing the state in the atomic_commit() path is the
> > wrong thing to do.  In the commit path, the various state objects
> > should be immutable.. ie. in the atomic_test() path you derive the new
> > hw state (including assignment/release of resources), and
> > atomic_commit() is simply pushing the state down to the hw.
> >
> > Otherwise, this looks better than v1.
> >
> > BR,
> > -R
> >
> okay. Should we avoid reservation all together if active=0 on that crtc
> and trigger rm_release on the enc during atomic_check ?
> how do you see the approach ?

Yeah, I suppose something like:

   if (drm_atomic_crtc_needs_modeset()) {
      reserve()
   } else if (active_changed && !active) {
      release()
   }

I think it could happen (at least with atomic api) that you get a
modeset without active_changed, so we might need to release() and then
reserve() in that case?  (This is probably where starting to run more
IGT tests would be useful)

BR,
-R

> -Kalyan
> >>
> >>         mutex_unlock(&dpu_enc->enc_lock);
> >>  }
> >> --
> >> 1.9.1
> >>
> > _______________________________________________
> > Freedreno mailing list
> > Freedreno@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/freedreno

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v1] drm/msm/dpu: Fix reservation failures in modeset
  2020-08-05 15:48 ` Rob Clark
  2020-08-06 14:45   ` [Freedreno] " kalyan_t
@ 2020-08-07  8:57   ` daniel
  1 sibling, 0 replies; 6+ messages in thread
From: daniel @ 2020-08-07  8:57 UTC (permalink / raw)
  Cc: Kalyan Thota,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Krishna Manikandan, linux-arm-msm, Raviteja Tamatam,
	Linux Kernel Mailing List, dri-devel, Douglas Anderson,
	Sean Paul, Abhinav Kumar, Drew Davenport, Kristian H. Kristensen,
	Stephen Boyd, freedreno

On Wed, Aug 05, 2020 at 08:48:34AM -0700, Rob Clark wrote:
> On Wed, Aug 5, 2020 at 6:34 AM Kalyan Thota <kalyan_t@codeaurora.org> wrote:
> >
> > In TEST_ONLY commit, rm global_state will duplicate the
> > object and request for new reservations, once they pass
> > then the new state will be swapped with the old and will
> > be available for the Atomic Commit.
> >
> > This patch fixes some of missing links in the resource
> > reservation sequence mentioned above.
> >
> > 1) Creation of a duplicate state in test_only commit (Rob)
> > 2) Allow resource release only during crtc_active false.
> >
> > For #2
> > In a modeset operation, swap state happens well before disable.
> > Hence clearing reservations in disable will cause failures
> > in modeset enable.
> >
> > Sequence:
> >     Swap state --> old, new
> >     modeset disables --> virt disable
> >     modeset enable --> virt modeset
> >
> > Allow reservations to be cleared only when crtc active is false
> > as in that case there wont be any modeset enable after disable.
> >
> > Signed-off-by: Kalyan Thota <kalyan_t@codeaurora.org>
> > ---
> >  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> > index 63976dc..b85a576 100644
> > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> > @@ -582,7 +582,7 @@ static int dpu_encoder_virt_atomic_check(
> >         dpu_kms = to_dpu_kms(priv->kms);
> >         mode = &crtc_state->mode;
> >         adj_mode = &crtc_state->adjusted_mode;
> > -       global_state = dpu_kms_get_existing_global_state(dpu_kms);
> > +       global_state = dpu_kms_get_global_state(crtc_state->state);
> >         trace_dpu_enc_atomic_check(DRMID(drm_enc));
> >
> >         /*
> > @@ -1172,6 +1172,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
> >         struct msm_drm_private *priv;
> >         struct dpu_kms *dpu_kms;
> >         struct dpu_global_state *global_state;
> > +       struct drm_crtc_state *crtc_state;
> >         int i = 0;
> >
> >         if (!drm_enc) {
> > @@ -1191,6 +1192,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
> >         priv = drm_enc->dev->dev_private;
> >         dpu_kms = to_dpu_kms(priv->kms);
> >         global_state = dpu_kms_get_existing_global_state(dpu_kms);
> > +       crtc_state = drm_enc->crtc->state;
> >
> >         trace_dpu_enc_disable(DRMID(drm_enc));
> >
> > @@ -1220,7 +1222,8 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
> >
> >         DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n");
> >
> > -       dpu_rm_release(global_state, drm_enc);
> > +       if (crtc_state->active_changed && !crtc_state->active)
> > +               dpu_rm_release(global_state, drm_enc);
> 
> I still think releasing the state in the atomic_commit() path is the
> wrong thing to do.  In the commit path, the various state objects
> should be immutable.. ie. in the atomic_test() path you derive the new
> hw state (including assignment/release of resources), and
> atomic_commit() is simply pushing the state down to the hw.
> 
> Otherwise, this looks better than v1.

Yeah this races and is total no-go. If you touch your state in commit
(except some very specific exceptions), then a next TEST_ONLY atomic_check
might duplicate the atomic state object in an incosistent state, and fail.

Worse, this looks like if you race like that then you might duplicate an
object with old reservations still in place, and then we've essentially
leaked those resources and need to reboot. Yes most compositors use
blocking modesets, but some actually do full nonblocking modesets.

This stuff needs to be moved into the atomic_check code, and your commit
code needs to be careful to use the right state (old or new) when pushing
it into hw.

Cheers, Daniel

> 
> BR,
> -R
> 
> >
> >         mutex_unlock(&dpu_enc->enc_lock);
> >  }
> > --
> > 1.9.1
> >
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Freedreno] [v1] drm/msm/dpu: Fix reservation failures in modeset
  2020-08-06 16:45     ` Rob Clark
@ 2020-08-07 13:13       ` kalyan_t
  0 siblings, 0 replies; 6+ messages in thread
From: kalyan_t @ 2020-08-07 13:13 UTC (permalink / raw)
  To: Rob Clark
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Krishna Manikandan, linux-arm-msm, Raviteja Tamatam,
	Linux Kernel Mailing List, dri-devel, Douglas Anderson, nganji,
	Sean Paul, Abhinav Kumar, Drew Davenport, Kristian H. Kristensen,
	Stephen Boyd, freedreno

On 2020-08-06 22:15, Rob Clark wrote:
> On Thu, Aug 6, 2020 at 7:46 AM <kalyan_t@codeaurora.org> wrote:
>> 
>> On 2020-08-05 21:18, Rob Clark wrote:
>> > On Wed, Aug 5, 2020 at 6:34 AM Kalyan Thota <kalyan_t@codeaurora.org>
>> > wrote:
>> >>
>> >> In TEST_ONLY commit, rm global_state will duplicate the
>> >> object and request for new reservations, once they pass
>> >> then the new state will be swapped with the old and will
>> >> be available for the Atomic Commit.
>> >>
>> >> This patch fixes some of missing links in the resource
>> >> reservation sequence mentioned above.
>> >>
>> >> 1) Creation of a duplicate state in test_only commit (Rob)
>> >> 2) Allow resource release only during crtc_active false.
>> >>
>> >> For #2
>> >> In a modeset operation, swap state happens well before disable.
>> >> Hence clearing reservations in disable will cause failures
>> >> in modeset enable.
>> >>
>> >> Sequence:
>> >>     Swap state --> old, new
>> >>     modeset disables --> virt disable
>> >>     modeset enable --> virt modeset
>> >>
>> >> Allow reservations to be cleared only when crtc active is false
>> >> as in that case there wont be any modeset enable after disable.
>> >>
>> >> Signed-off-by: Kalyan Thota <kalyan_t@codeaurora.org>
>> >> ---
>> >>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 7 +++++--
>> >>  1 file changed, 5 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> >> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> >> index 63976dc..b85a576 100644
>> >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
>> >> @@ -582,7 +582,7 @@ static int dpu_encoder_virt_atomic_check(
>> >>         dpu_kms = to_dpu_kms(priv->kms);
>> >>         mode = &crtc_state->mode;
>> >>         adj_mode = &crtc_state->adjusted_mode;
>> >> -       global_state = dpu_kms_get_existing_global_state(dpu_kms);
>> >> +       global_state = dpu_kms_get_global_state(crtc_state->state);
>> >>         trace_dpu_enc_atomic_check(DRMID(drm_enc));
>> >>
>> >>         /*
>> >> @@ -1172,6 +1172,7 @@ static void dpu_encoder_virt_disable(struct
>> >> drm_encoder *drm_enc)
>> >>         struct msm_drm_private *priv;
>> >>         struct dpu_kms *dpu_kms;
>> >>         struct dpu_global_state *global_state;
>> >> +       struct drm_crtc_state *crtc_state;
>> >>         int i = 0;
>> >>
>> >>         if (!drm_enc) {
>> >> @@ -1191,6 +1192,7 @@ static void dpu_encoder_virt_disable(struct
>> >> drm_encoder *drm_enc)
>> >>         priv = drm_enc->dev->dev_private;
>> >>         dpu_kms = to_dpu_kms(priv->kms);
>> >>         global_state = dpu_kms_get_existing_global_state(dpu_kms);
>> >> +       crtc_state = drm_enc->crtc->state;
>> >>
>> >>         trace_dpu_enc_disable(DRMID(drm_enc));
>> >>
>> >> @@ -1220,7 +1222,8 @@ static void dpu_encoder_virt_disable(struct
>> >> drm_encoder *drm_enc)
>> >>
>> >>         DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n");
>> >>
>> >> -       dpu_rm_release(global_state, drm_enc);
>> >> +       if (crtc_state->active_changed && !crtc_state->active)
>> >> +               dpu_rm_release(global_state, drm_enc);
>> >
>> > I still think releasing the state in the atomic_commit() path is the
>> > wrong thing to do.  In the commit path, the various state objects
>> > should be immutable.. ie. in the atomic_test() path you derive the new
>> > hw state (including assignment/release of resources), and
>> > atomic_commit() is simply pushing the state down to the hw.
>> >
>> > Otherwise, this looks better than v1.
>> >
>> > BR,
>> > -R
>> >
>> okay. Should we avoid reservation all together if active=0 on that 
>> crtc
>> and trigger rm_release on the enc during atomic_check ?
>> how do you see the approach ?
> 
> Yeah, I suppose something like:
> 
>    if (drm_atomic_crtc_needs_modeset()) {
>       reserve()
>    } else if (active_changed && !active) {
>       release()
>    }
> 
> I think it could happen (at least with atomic api) that you get a
> modeset without active_changed, so we might need to release() and then
> reserve() in that case?  (This is probably where starting to run more
> IGT tests would be useful)
> 
> BR,
> -R
> Thanks Rob, please review the v2 version.
>> -Kalyan
>> >>
>> >>         mutex_unlock(&dpu_enc->enc_lock);
>> >>  }
>> >> --
>> >> 1.9.1
>> >>
>> > _______________________________________________
>> > Freedreno mailing list
>> > Freedreno@lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/freedreno

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-07 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 13:34 [v1] drm/msm/dpu: Fix reservation failures in modeset Kalyan Thota
2020-08-05 15:48 ` Rob Clark
2020-08-06 14:45   ` [Freedreno] " kalyan_t
2020-08-06 16:45     ` Rob Clark
2020-08-07 13:13       ` kalyan_t
2020-08-07  8:57   ` daniel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).