Message ID | 1680271114-1534-4-git-send-email-quic_vpolimer@quicinc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fixes for PSR | expand |
On Fri, 31 Mar 2023 at 16:59, Vinod Polimera <quic_vpolimer@quicinc.com> wrote: > > In certain CPU stress conditions, there can be a delay in scheduling commit > work and it was observed that PSR commit from a different work queue was > scheduled. Avoid these commits as display is already in PSR mode. > > Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com> > --- > drivers/gpu/drm/msm/msm_atomic.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c > index 645fe53..f8141bb 100644 > --- a/drivers/gpu/drm/msm/msm_atomic.c > +++ b/drivers/gpu/drm/msm/msm_atomic.c > @@ -192,6 +192,9 @@ int msm_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) > new_crtc_state->mode_changed = true; > state->allow_modeset = true; > } > + > + if (old_crtc_state->self_refresh_active && new_crtc_state->self_refresh_active) > + return -EINVAL; EINVAL here means that atomic_check will fail if both old and new states are in SR mode. For example, there might be a mode set for another CRTC (while keeping this one in SR mode). I don't think this is correct. We should skip/shortcut the commit, that's true. But I doubt that returning an error here is a proper way to do this. Please correct me if I'm wrong. > } > > return drm_atomic_helper_check(dev, state); > -- > 2.7.4 >
> On Fri, 31 Mar 2023 at 16:59, Vinod Polimera <quic_vpolimer@quicinc.com> > wrote: > > > > In certain CPU stress conditions, there can be a delay in scheduling commit > > work and it was observed that PSR commit from a different work queue > was > > scheduled. Avoid these commits as display is already in PSR mode. > > > > Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com> > > --- > > drivers/gpu/drm/msm/msm_atomic.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/gpu/drm/msm/msm_atomic.c > b/drivers/gpu/drm/msm/msm_atomic.c > > index 645fe53..f8141bb 100644 > > --- a/drivers/gpu/drm/msm/msm_atomic.c > > +++ b/drivers/gpu/drm/msm/msm_atomic.c > > @@ -192,6 +192,9 @@ int msm_atomic_check(struct drm_device *dev, > struct drm_atomic_state *state) > > new_crtc_state->mode_changed = true; > > state->allow_modeset = true; > > } > > + > > + if (old_crtc_state->self_refresh_active && new_crtc_state- > >self_refresh_active) > > + return -EINVAL; > > EINVAL here means that atomic_check will fail if both old and new > states are in SR mode. For example, there might be a mode set for > another CRTC (while keeping this one in SR mode). I don't think this > is correct. We should skip/shortcut the commit, that's true. But I > doubt that returning an error here is a proper way to do this. Please > correct me if I'm wrong. If there is a modeset on same crtc with a different connector. The new_crtc_state will not have self_refresh_active set. Self_refresh_active is set from the helper library, which will duplicate the old_state and just adds self_refresh_active to true and active to false. so we can be confident that if we are checking for self_refresh_active status then it should be coming from the library call. Also the EINVAL is returned to the self_refresh library API and the function will be retired. And self_refresh_active is cleared on every commit : https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/drm_atomic_state_helper.c#n158 The above is true for different crtc as well. please let me know your comments. Thanks, Vinod.
On 31/03/2023 16:58, Vinod Polimera wrote: > In certain CPU stress conditions, there can be a delay in scheduling commit > work and it was observed that PSR commit from a different work queue was > scheduled. Avoid these commits as display is already in PSR mode. > > Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com> > --- > drivers/gpu/drm/msm/msm_atomic.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c > index 645fe53..f8141bb 100644 > --- a/drivers/gpu/drm/msm/msm_atomic.c > +++ b/drivers/gpu/drm/msm/msm_atomic.c > @@ -192,6 +192,9 @@ int msm_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) The corresponding patch is not yet applied. I wonder how this was tested. > new_crtc_state->mode_changed = true; > state->allow_modeset = true; > } > + > + if (old_crtc_state->self_refresh_active && new_crtc_state->self_refresh_active) > + return -EINVAL; > } > > return drm_atomic_helper_check(dev, state);
On Mon, 3 Apr 2023 at 15:01, Vinod Polimera <vpolimer@qti.qualcomm.com> wrote: > > > On Fri, 31 Mar 2023 at 16:59, Vinod Polimera <quic_vpolimer@quicinc.com> > > wrote: > > > > > > In certain CPU stress conditions, there can be a delay in scheduling commit > > > work and it was observed that PSR commit from a different work queue > > was > > > scheduled. Avoid these commits as display is already in PSR mode. > > > > > > Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com> > > > --- > > > drivers/gpu/drm/msm/msm_atomic.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/drivers/gpu/drm/msm/msm_atomic.c > > b/drivers/gpu/drm/msm/msm_atomic.c > > > index 645fe53..f8141bb 100644 > > > --- a/drivers/gpu/drm/msm/msm_atomic.c > > > +++ b/drivers/gpu/drm/msm/msm_atomic.c > > > @@ -192,6 +192,9 @@ int msm_atomic_check(struct drm_device *dev, > > struct drm_atomic_state *state) > > > new_crtc_state->mode_changed = true; > > > state->allow_modeset = true; > > > } > > > + > > > + if (old_crtc_state->self_refresh_active && new_crtc_state- > > >self_refresh_active) > > > + return -EINVAL; > > > > EINVAL here means that atomic_check will fail if both old and new > > states are in SR mode. For example, there might be a mode set for > > another CRTC (while keeping this one in SR mode). I don't think this > > is correct. We should skip/shortcut the commit, that's true. But I > > doubt that returning an error here is a proper way to do this. Please > > correct me if I'm wrong. > > If there is a modeset on same crtc with a different connector. The new_crtc_state will not have self_refresh_active set. > Self_refresh_active is set from the helper library, which will duplicate the old_state and just adds self_refresh_active to true and active to false. > so we can be confident that if we are checking for self_refresh_active status then it should be coming from the library call. > > Also the EINVAL is returned to the self_refresh library API and the function will be retired. Maybe I misunderstand you here. However, in this way EINVAL is returned to drm_atomic_check_only() and not to the SR code. > And self_refresh_active is cleared on every commit : https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/drm_atomic_state_helper.c#n158 And this means that this check will not trigger at all, if I'm not mistaken. You've added code to msm_atomic_check(), so drm_self_refresh_helper_alter_state() was not called (yet) and thus new_crtc_state->self_refresh_active is set to false, fresh after crtc's duplicate_state. -- With best wishes Dmitry
On 03/04/2023 19:11, Dmitry Baryshkov wrote: > On Mon, 3 Apr 2023 at 15:01, Vinod Polimera <vpolimer@qti.qualcomm.com> wrote: >> >>> On Fri, 31 Mar 2023 at 16:59, Vinod Polimera <quic_vpolimer@quicinc.com> >>> wrote: >>>> >>>> In certain CPU stress conditions, there can be a delay in scheduling commit >>>> work and it was observed that PSR commit from a different work queue >>> was >>>> scheduled. Avoid these commits as display is already in PSR mode. >>>> >>>> Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com> >>>> --- >>>> drivers/gpu/drm/msm/msm_atomic.c | 3 +++ >>>> 1 file changed, 3 insertions(+) >>>> >>>> diff --git a/drivers/gpu/drm/msm/msm_atomic.c >>> b/drivers/gpu/drm/msm/msm_atomic.c >>>> index 645fe53..f8141bb 100644 >>>> --- a/drivers/gpu/drm/msm/msm_atomic.c >>>> +++ b/drivers/gpu/drm/msm/msm_atomic.c >>>> @@ -192,6 +192,9 @@ int msm_atomic_check(struct drm_device *dev, >>> struct drm_atomic_state *state) >>>> new_crtc_state->mode_changed = true; >>>> state->allow_modeset = true; >>>> } >>>> + >>>> + if (old_crtc_state->self_refresh_active && new_crtc_state- >>>> self_refresh_active) >>>> + return -EINVAL; >>> >>> EINVAL here means that atomic_check will fail if both old and new >>> states are in SR mode. For example, there might be a mode set for >>> another CRTC (while keeping this one in SR mode). I don't think this >>> is correct. We should skip/shortcut the commit, that's true. But I >>> doubt that returning an error here is a proper way to do this. Please >>> correct me if I'm wrong. >> >> If there is a modeset on same crtc with a different connector. The new_crtc_state will not have self_refresh_active set. >> Self_refresh_active is set from the helper library, which will duplicate the old_state and just adds self_refresh_active to true and active to false. >> so we can be confident that if we are checking for self_refresh_active status then it should be coming from the library call. >> >> Also the EINVAL is returned to the self_refresh library API and the function will be retired. > > Maybe I misunderstand you here. However, in this way EINVAL is > returned to drm_atomic_check_only() and not to the SR code. Unless anybody objects, I'm going to drop this patch now. The issue should be solved in the framework itself. > >> And self_refresh_active is cleared on every commit : https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/drm_atomic_state_helper.c#n158 > > And this means that this check will not trigger at all, if I'm not > mistaken. You've added code to msm_atomic_check(), so > drm_self_refresh_helper_alter_state() was not called (yet) and thus > new_crtc_state->self_refresh_active is set to false, fresh after > crtc's duplicate_state. > > -- > With best wishes > Dmitry
diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c index 645fe53..f8141bb 100644 --- a/drivers/gpu/drm/msm/msm_atomic.c +++ b/drivers/gpu/drm/msm/msm_atomic.c @@ -192,6 +192,9 @@ int msm_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) new_crtc_state->mode_changed = true; state->allow_modeset = true; } + + if (old_crtc_state->self_refresh_active && new_crtc_state->self_refresh_active) + return -EINVAL; } return drm_atomic_helper_check(dev, state);
In certain CPU stress conditions, there can be a delay in scheduling commit work and it was observed that PSR commit from a different work queue was scheduled. Avoid these commits as display is already in PSR mode. Signed-off-by: Vinod Polimera <quic_vpolimer@quicinc.com> --- drivers/gpu/drm/msm/msm_atomic.c | 3 +++ 1 file changed, 3 insertions(+)