diff mbox series

[v2] drm/msm: dpu: Allow planes to extend past active display

Message ID 20180828205106.15168-1-sean@poorly.run (mailing list archive)
State New, archived
Headers show
Series [v2] drm/msm: dpu: Allow planes to extend past active display | expand

Commit Message

Sean Paul Aug. 28, 2018, 8:50 p.m. UTC
From: Sean Paul <seanpaul@chromium.org>

The atomic_check is a bit too aggressive with respect to planes which
leave the active area. This caused a bunch of log spew when the cursor
got to the edge of the screen and stopped it from going all the way.

This patch removes the conservative bounds checks from atomic and clips
the dst rect such that we properly display planes which go off the
screen.

Changes in v2:
- Apply the clip to src as well (taking into account scaling)

Cc: Sravanthi Kollukuduru <skolluku@codeaurora.org>
Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  3 +--
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

Comments

Jeykumar Sankaran Aug. 28, 2018, 10:04 p.m. UTC | #1
On 2018-08-28 13:50, Sean Paul wrote:
> From: Sean Paul <seanpaul@chromium.org>
> 
> The atomic_check is a bit too aggressive with respect to planes which
> leave the active area. This caused a bunch of log spew when the cursor
> got to the edge of the screen and stopped it from going all the way.
> 
> This patch removes the conservative bounds checks from atomic and clips
> the dst rect such that we properly display planes which go off the
> screen.
> 
> Changes in v2:
> - Apply the clip to src as well (taking into account scaling)
> 
> Cc: Sravanthi Kollukuduru <skolluku@codeaurora.org>
> Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  3 +--
>  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 14 +++++++++++++-
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 07c2d15b45f2..f0a5e776ba32 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -1551,8 +1551,7 @@ static int dpu_crtc_atomic_check(struct drm_crtc
> *crtc,
>  		cnt++;
> 
>  		dst = drm_plane_state_dest(pstate);
> -		if (!drm_rect_intersect(&clip, &dst) ||
> -		    !drm_rect_equals(&clip, &dst)) {
> +		if (!drm_rect_intersect(&clip, &dst)) {
>  			DPU_ERROR("invalid vertical/horizontal
> destination\n");
>  			DPU_ERROR("display: " DRM_RECT_FMT " plane: "
>  				  DRM_RECT_FMT "\n",
> DRM_RECT_ARG(&crtc_rect),
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> index efdf9b200dd9..adfd16625188 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> @@ -1254,7 +1254,8 @@ static int dpu_plane_sspp_atomic_update(struct
> drm_plane *plane,
>  	const struct dpu_format *fmt;
>  	struct drm_crtc *crtc;
>  	struct drm_framebuffer *fb;
> -	struct drm_rect src, dst;
> +	struct drm_rect clip = { 0 }, src, dst;
> +	int hscale, vscale;
> 
>  	if (!plane) {
>  		DPU_ERROR("invalid plane\n");
> @@ -1300,6 +1301,17 @@ static int dpu_plane_sspp_atomic_update(struct
> drm_plane *plane,
> 
>  	dst = drm_plane_state_dest(state);
> 
> +	hscale = drm_rect_calc_hscale(&src, &dst,
> +				      pdpu->pipe_sblk->maxupscale,
> +				      pdpu->pipe_sblk->maxdwnscale);
> +	vscale = drm_rect_calc_vscale(&src, &dst,
> +				      pdpu->pipe_sblk->maxupscale,
> +				      pdpu->pipe_sblk->maxdwnscale);
> +
> +	clip.x2 = crtc->state->adjusted_mode.hdisplay;
> +	clip.y2 = crtc->state->adjusted_mode.vdisplay;
> +	drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale);
> +
>  	DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FMT "->crtc%u "
> DRM_RECT_FMT
>  			", %4.4s ubwc %d\n", fb->base.id,
> DRM_RECT_ARG(&src),
>  			crtc->base.id, DRM_RECT_ARG(&dst),

Don't you have to update pdpu->pipe_cfg.src_rect and 
pdpu->pipe_cfg.dst_rect with clip?
Sean Paul Aug. 28, 2018, 10:52 p.m. UTC | #2
On Tue, Aug 28, 2018, 6:04 PM Jeykumar Sankaran <jsanka@codeaurora.org>
wrote:

> On 2018-08-28 13:50, Sean Paul wrote:
> > From: Sean Paul <seanpaul@chromium.org>
> >
> > The atomic_check is a bit too aggressive with respect to planes which
> > leave the active area. This caused a bunch of log spew when the cursor
> > got to the edge of the screen and stopped it from going all the way.
> >
> > This patch removes the conservative bounds checks from atomic and clips
> > the dst rect such that we properly display planes which go off the
> > screen.
> >
> > Changes in v2:
> > - Apply the clip to src as well (taking into account scaling)
> >
> > Cc: Sravanthi Kollukuduru <skolluku@codeaurora.org>
> > Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
> > Signed-off-by: Sean Paul <seanpaul@chromium.org>
> > ---
> >  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  3 +--
> >  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 14 +++++++++++++-
> >  2 files changed, 14 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > index 07c2d15b45f2..f0a5e776ba32 100644
> > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > @@ -1551,8 +1551,7 @@ static int dpu_crtc_atomic_check(struct drm_crtc
> > *crtc,
> >               cnt++;
> >
> >               dst = drm_plane_state_dest(pstate);
> > -             if (!drm_rect_intersect(&clip, &dst) ||
> > -                 !drm_rect_equals(&clip, &dst)) {
> > +             if (!drm_rect_intersect(&clip, &dst)) {
> >                       DPU_ERROR("invalid vertical/horizontal
> > destination\n");
> >                       DPU_ERROR("display: " DRM_RECT_FMT " plane: "
> >                                 DRM_RECT_FMT "\n",
> > DRM_RECT_ARG(&crtc_rect),
> > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > index efdf9b200dd9..adfd16625188 100644
> > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > @@ -1254,7 +1254,8 @@ static int dpu_plane_sspp_atomic_update(struct
> > drm_plane *plane,
> >       const struct dpu_format *fmt;
> >       struct drm_crtc *crtc;
> >       struct drm_framebuffer *fb;
> > -     struct drm_rect src, dst;
> > +     struct drm_rect clip = { 0 }, src, dst;
> > +     int hscale, vscale;
> >
> >       if (!plane) {
> >               DPU_ERROR("invalid plane\n");
> > @@ -1300,6 +1301,17 @@ static int dpu_plane_sspp_atomic_update(struct
> > drm_plane *plane,
> >
> >       dst = drm_plane_state_dest(state);
> >
> > +     hscale = drm_rect_calc_hscale(&src, &dst,
> > +                                   pdpu->pipe_sblk->maxupscale,
> > +                                   pdpu->pipe_sblk->maxdwnscale);
> > +     vscale = drm_rect_calc_vscale(&src, &dst,
> > +                                   pdpu->pipe_sblk->maxupscale,
> > +                                   pdpu->pipe_sblk->maxdwnscale);
> > +
> > +     clip.x2 = crtc->state->adjusted_mode.hdisplay;
> > +     clip.y2 = crtc->state->adjusted_mode.vdisplay;
> > +     drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale);
> > +
> >       DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FMT "->crtc%u "
> > DRM_RECT_FMT
> >                       ", %4.4s ubwc %d\n", fb->base.id,
> > DRM_RECT_ARG(&src),
> >                       crtc->base.id, DRM_RECT_ARG(&dst),
>
> Don't you have to update pdpu->pipe_cfg.src_rect and
> pdpu->pipe_cfg.dst_rect with clip?
>

No, clip is the active area, so it'll always be equal to the adjusted mode.

Sean


> --
> Jeykumar S
>
<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 28, 2018, 6:04 PM Jeykumar Sankaran &lt;<a href="mailto:jsanka@codeaurora.org">jsanka@codeaurora.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2018-08-28 13:50, Sean Paul wrote:<br>
&gt; From: Sean Paul &lt;<a href="mailto:seanpaul@chromium.org" target="_blank" rel="noreferrer">seanpaul@chromium.org</a>&gt;<br>
&gt; <br>
&gt; The atomic_check is a bit too aggressive with respect to planes which<br>
&gt; leave the active area. This caused a bunch of log spew when the cursor<br>
&gt; got to the edge of the screen and stopped it from going all the way.<br>
&gt; <br>
&gt; This patch removes the conservative bounds checks from atomic and clips<br>
&gt; the dst rect such that we properly display planes which go off the<br>
&gt; screen.<br>
&gt; <br>
&gt; Changes in v2:<br>
&gt; - Apply the clip to src as well (taking into account scaling)<br>
&gt; <br>
&gt; Cc: Sravanthi Kollukuduru &lt;<a href="mailto:skolluku@codeaurora.org" target="_blank" rel="noreferrer">skolluku@codeaurora.org</a>&gt;<br>
&gt; Cc: Jeykumar Sankaran &lt;<a href="mailto:jsanka@codeaurora.org" target="_blank" rel="noreferrer">jsanka@codeaurora.org</a>&gt;<br>
&gt; Signed-off-by: Sean Paul &lt;<a href="mailto:seanpaul@chromium.org" target="_blank" rel="noreferrer">seanpaul@chromium.org</a>&gt;<br>
&gt; ---<br>
&gt;  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  3 +--<br>
&gt;  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 14 +++++++++++++-<br>
&gt;  2 files changed, 14 insertions(+), 3 deletions(-)<br>
&gt; <br>
&gt; diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c<br>
&gt; b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c<br>
&gt; index 07c2d15b45f2..f0a5e776ba32 100644<br>
&gt; --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c<br>
&gt; +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c<br>
&gt; @@ -1551,8 +1551,7 @@ static int dpu_crtc_atomic_check(struct drm_crtc<br>
&gt; *crtc,<br>
&gt;               cnt++;<br>
&gt; <br>
&gt;               dst = drm_plane_state_dest(pstate);<br>
&gt; -             if (!drm_rect_intersect(&amp;clip, &amp;dst) ||<br>
&gt; -                 !drm_rect_equals(&amp;clip, &amp;dst)) {<br>
&gt; +             if (!drm_rect_intersect(&amp;clip, &amp;dst)) {<br>
&gt;                       DPU_ERROR(&quot;invalid vertical/horizontal<br>
&gt; destination\n&quot;);<br>
&gt;                       DPU_ERROR(&quot;display: &quot; DRM_RECT_FMT &quot; plane: &quot;<br>
&gt;                                 DRM_RECT_FMT &quot;\n&quot;,<br>
&gt; DRM_RECT_ARG(&amp;crtc_rect),<br>
&gt; diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c<br>
&gt; b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c<br>
&gt; index efdf9b200dd9..adfd16625188 100644<br>
&gt; --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c<br>
&gt; +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c<br>
&gt; @@ -1254,7 +1254,8 @@ static int dpu_plane_sspp_atomic_update(struct<br>
&gt; drm_plane *plane,<br>
&gt;       const struct dpu_format *fmt;<br>
&gt;       struct drm_crtc *crtc;<br>
&gt;       struct drm_framebuffer *fb;<br>
&gt; -     struct drm_rect src, dst;<br>
&gt; +     struct drm_rect clip = { 0 }, src, dst;<br>
&gt; +     int hscale, vscale;<br>
&gt; <br>
&gt;       if (!plane) {<br>
&gt;               DPU_ERROR(&quot;invalid plane\n&quot;);<br>
&gt; @@ -1300,6 +1301,17 @@ static int dpu_plane_sspp_atomic_update(struct<br>
&gt; drm_plane *plane,<br>
&gt; <br>
&gt;       dst = drm_plane_state_dest(state);<br>
&gt; <br>
&gt; +     hscale = drm_rect_calc_hscale(&amp;src, &amp;dst,<br>
&gt; +                                   pdpu-&gt;pipe_sblk-&gt;maxupscale,<br>
&gt; +                                   pdpu-&gt;pipe_sblk-&gt;maxdwnscale);<br>
&gt; +     vscale = drm_rect_calc_vscale(&amp;src, &amp;dst,<br>
&gt; +                                   pdpu-&gt;pipe_sblk-&gt;maxupscale,<br>
&gt; +                                   pdpu-&gt;pipe_sblk-&gt;maxdwnscale);<br>
&gt; +<br>
&gt; +     clip.x2 = crtc-&gt;state-&gt;adjusted_mode.hdisplay;<br>
&gt; +     clip.y2 = crtc-&gt;state-&gt;adjusted_mode.vdisplay;<br>
&gt; +     drm_rect_clip_scaled(&amp;src, &amp;dst, &amp;clip, hscale, vscale);<br>
&gt; +<br>
&gt;       DPU_DEBUG_PLANE(pdpu, &quot;FB[%u] &quot; DRM_RECT_FMT &quot;-&gt;crtc%u &quot;<br>
&gt; DRM_RECT_FMT<br>
&gt;                       &quot;, %4.4s ubwc %d\n&quot;, fb-&gt;<a href="http://base.id" rel="noreferrer noreferrer" target="_blank">base.id</a>,<br>
&gt; DRM_RECT_ARG(&amp;src),<br>
&gt;                       crtc-&gt;<a href="http://base.id" rel="noreferrer noreferrer" target="_blank">base.id</a>, DRM_RECT_ARG(&amp;dst),<br>
<br>
Don&#39;t you have to update pdpu-&gt;pipe_cfg.src_rect and <br>
pdpu-&gt;pipe_cfg.dst_rect with clip?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">No, clip is the active area, so it&#39;ll always be equal to the adjusted mode. </div><div dir="auto"><br></div><div dir="auto">Sean</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
-- <br>
Jeykumar S<br>
</blockquote></div></div></div>
Jeykumar Sankaran Aug. 29, 2018, 12:01 a.m. UTC | #3
On 2018-08-28 15:52, Sean Paul wrote:
> On Tue, Aug 28, 2018, 6:04 PM Jeykumar Sankaran
> <jsanka@codeaurora.org> wrote:
> 
>> On 2018-08-28 13:50, Sean Paul wrote:
>>> From: Sean Paul <seanpaul@chromium.org>
>>> 
>>> The atomic_check is a bit too aggressive with respect to planes
>> which
>>> leave the active area. This caused a bunch of log spew when the
>> cursor
>>> got to the edge of the screen and stopped it from going all the
>> way.
>>> 
>>> This patch removes the conservative bounds checks from atomic and
>> clips
>>> the dst rect such that we properly display planes which go off the
>>> screen.
>>> 
>>> Changes in v2:
>>> - Apply the clip to src as well (taking into account scaling)
>>> 
>>> Cc: Sravanthi Kollukuduru <skolluku@codeaurora.org>
>>> Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
>>> Signed-off-by: Sean Paul <seanpaul@chromium.org>
>>> ---
>>> drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  3 +--
>>> drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 14 +++++++++++++-
>>> 2 files changed, 14 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>>> index 07c2d15b45f2..f0a5e776ba32 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
>>> @@ -1551,8 +1551,7 @@ static int dpu_crtc_atomic_check(struct
>> drm_crtc
>>> *crtc,
>>> cnt++;
>>> 
>>> dst = drm_plane_state_dest(pstate);
>>> -             if (!drm_rect_intersect(&clip, &dst) ||
>>> -                 !drm_rect_equals(&clip, &dst)) {
>>> +             if (!drm_rect_intersect(&clip, &dst)) {
>>> DPU_ERROR("invalid vertical/horizontal
>>> destination\n");
>>> DPU_ERROR("display: " DRM_RECT_FMT " plane:
>> "
>>> DRM_RECT_FMT "\n",
>>> DRM_RECT_ARG(&crtc_rect),
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>>> index efdf9b200dd9..adfd16625188 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>>> @@ -1254,7 +1254,8 @@ static int
>> dpu_plane_sspp_atomic_update(struct
>>> drm_plane *plane,
>>> const struct dpu_format *fmt;
>>> struct drm_crtc *crtc;
>>> struct drm_framebuffer *fb;
>>> -     struct drm_rect src, dst;
>>> +     struct drm_rect clip = { 0 }, src, dst;
>>> +     int hscale, vscale;
>>> 
>>> if (!plane) {
>>> DPU_ERROR("invalid plane\n");
>>> @@ -1300,6 +1301,17 @@ static int
>> dpu_plane_sspp_atomic_update(struct
>>> drm_plane *plane,
>>> 
>>> dst = drm_plane_state_dest(state);
>>> 
>>> +     hscale = drm_rect_calc_hscale(&src, &dst,
>>> +                                   pdpu->pipe_sblk->maxupscale,
>>> +                                   pdpu->pipe_sblk->maxdwnscale);
>>> +     vscale = drm_rect_calc_vscale(&src, &dst,
>>> +                                   pdpu->pipe_sblk->maxupscale,
>>> +                                   pdpu->pipe_sblk->maxdwnscale);
>>> +
>>> +     clip.x2 = crtc->state->adjusted_mode.hdisplay;
>>> +     clip.y2 = crtc->state->adjusted_mode.vdisplay;
>>> +     drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale);
>>> +
>>> DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FMT "->crtc%u "
>>> DRM_RECT_FMT
>>> ", %4.4s ubwc %d\n", fb->base.id [1],
>>> DRM_RECT_ARG(&src),
>>> crtc->base.id [1], DRM_RECT_ARG(&dst),
>> 
>> Don't you have to update pdpu->pipe_cfg.src_rect and
>> pdpu->pipe_cfg.dst_rect with clip?
> 
> No, clip is the active area, so it'll always be equal to the adjusted
> mode.
> 
> Sean
> 

Got it! In that case, can drm_atomic_helper_check_plane_state helper be 
useful here?

>> --
>> Jeykumar S
> 
> 
> Links:
> ------
> [1] http://base.id
Ville Syrjala Aug. 29, 2018, 11:52 a.m. UTC | #4
On Tue, Aug 28, 2018 at 04:50:37PM -0400, Sean Paul wrote:
> From: Sean Paul <seanpaul@chromium.org>
> 
> The atomic_check is a bit too aggressive with respect to planes which
> leave the active area. This caused a bunch of log spew when the cursor
> got to the edge of the screen and stopped it from going all the way.
> 
> This patch removes the conservative bounds checks from atomic and clips
> the dst rect such that we properly display planes which go off the
> screen.
> 
> Changes in v2:
> - Apply the clip to src as well (taking into account scaling)
> 
> Cc: Sravanthi Kollukuduru <skolluku@codeaurora.org>
> Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  3 +--
>  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 14 +++++++++++++-
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 07c2d15b45f2..f0a5e776ba32 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -1551,8 +1551,7 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
>  		cnt++;
>  
>  		dst = drm_plane_state_dest(pstate);
> -		if (!drm_rect_intersect(&clip, &dst) ||
> -		    !drm_rect_equals(&clip, &dst)) {
> +		if (!drm_rect_intersect(&clip, &dst)) {
>  			DPU_ERROR("invalid vertical/horizontal destination\n");
>  			DPU_ERROR("display: " DRM_RECT_FMT " plane: "
>  				  DRM_RECT_FMT "\n", DRM_RECT_ARG(&crtc_rect),
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> index efdf9b200dd9..adfd16625188 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> @@ -1254,7 +1254,8 @@ static int dpu_plane_sspp_atomic_update(struct drm_plane *plane,
>  	const struct dpu_format *fmt;
>  	struct drm_crtc *crtc;
>  	struct drm_framebuffer *fb;
> -	struct drm_rect src, dst;
> +	struct drm_rect clip = { 0 }, src, dst;
> +	int hscale, vscale;
>  
>  	if (!plane) {
>  		DPU_ERROR("invalid plane\n");
> @@ -1300,6 +1301,17 @@ static int dpu_plane_sspp_atomic_update(struct drm_plane *plane,
>  
>  	dst = drm_plane_state_dest(state);
>  
> +	hscale = drm_rect_calc_hscale(&src, &dst,
> +				      pdpu->pipe_sblk->maxupscale,
> +				      pdpu->pipe_sblk->maxdwnscale);
> +	vscale = drm_rect_calc_vscale(&src, &dst,
> +				      pdpu->pipe_sblk->maxupscale,
> +				      pdpu->pipe_sblk->maxdwnscale);
> +
> +	clip.x2 = crtc->state->adjusted_mode.hdisplay;
> +	clip.y2 = crtc->state->adjusted_mode.vdisplay;
> +	drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale);

Can't use drm_atomic_helper_check_plane_state() ?

> +
>  	DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FMT "->crtc%u " DRM_RECT_FMT
>  			", %4.4s ubwc %d\n", fb->base.id, DRM_RECT_ARG(&src),
>  			crtc->base.id, DRM_RECT_ARG(&dst),
> -- 
> Sean Paul, Software Engineer, Google / Chromium OS
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul Aug. 29, 2018, 12:32 p.m. UTC | #5
On Tue, Aug 28, 2018 at 05:01:13PM -0700, Jeykumar Sankaran wrote:
> On 2018-08-28 15:52, Sean Paul wrote:
> > On Tue, Aug 28, 2018, 6:04 PM Jeykumar Sankaran
> > <jsanka@codeaurora.org> wrote:
> > 
> > > On 2018-08-28 13:50, Sean Paul wrote:
> > > > From: Sean Paul <seanpaul@chromium.org>
> > > > 
> > > > The atomic_check is a bit too aggressive with respect to planes
> > > which
> > > > leave the active area. This caused a bunch of log spew when the
> > > cursor
> > > > got to the edge of the screen and stopped it from going all the
> > > way.
> > > > 
> > > > This patch removes the conservative bounds checks from atomic and
> > > clips
> > > > the dst rect such that we properly display planes which go off the
> > > > screen.
> > > > 
> > > > Changes in v2:
> > > > - Apply the clip to src as well (taking into account scaling)
> > > > 
> > > > Cc: Sravanthi Kollukuduru <skolluku@codeaurora.org>
> > > > Cc: Jeykumar Sankaran <jsanka@codeaurora.org>
> > > > Signed-off-by: Sean Paul <seanpaul@chromium.org>
> > > > ---
> > > > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  |  3 +--
> > > > drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 14 +++++++++++++-
> > > > 2 files changed, 14 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > index 07c2d15b45f2..f0a5e776ba32 100644
> > > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> > > > @@ -1551,8 +1551,7 @@ static int dpu_crtc_atomic_check(struct
> > > drm_crtc
> > > > *crtc,
> > > > cnt++;
> > > > 
> > > > dst = drm_plane_state_dest(pstate);
> > > > -             if (!drm_rect_intersect(&clip, &dst) ||
> > > > -                 !drm_rect_equals(&clip, &dst)) {
> > > > +             if (!drm_rect_intersect(&clip, &dst)) {
> > > > DPU_ERROR("invalid vertical/horizontal
> > > > destination\n");
> > > > DPU_ERROR("display: " DRM_RECT_FMT " plane:
> > > "
> > > > DRM_RECT_FMT "\n",
> > > > DRM_RECT_ARG(&crtc_rect),
> > > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > > > b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > > > index efdf9b200dd9..adfd16625188 100644
> > > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> > > > @@ -1254,7 +1254,8 @@ static int
> > > dpu_plane_sspp_atomic_update(struct
> > > > drm_plane *plane,
> > > > const struct dpu_format *fmt;
> > > > struct drm_crtc *crtc;
> > > > struct drm_framebuffer *fb;
> > > > -     struct drm_rect src, dst;
> > > > +     struct drm_rect clip = { 0 }, src, dst;
> > > > +     int hscale, vscale;
> > > > 
> > > > if (!plane) {
> > > > DPU_ERROR("invalid plane\n");
> > > > @@ -1300,6 +1301,17 @@ static int
> > > dpu_plane_sspp_atomic_update(struct
> > > > drm_plane *plane,
> > > > 
> > > > dst = drm_plane_state_dest(state);
> > > > 
> > > > +     hscale = drm_rect_calc_hscale(&src, &dst,
> > > > +                                   pdpu->pipe_sblk->maxupscale,
> > > > +                                   pdpu->pipe_sblk->maxdwnscale);
> > > > +     vscale = drm_rect_calc_vscale(&src, &dst,
> > > > +                                   pdpu->pipe_sblk->maxupscale,
> > > > +                                   pdpu->pipe_sblk->maxdwnscale);
> > > > +
> > > > +     clip.x2 = crtc->state->adjusted_mode.hdisplay;
> > > > +     clip.y2 = crtc->state->adjusted_mode.vdisplay;
> > > > +     drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale);
> > > > +
> > > > DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FMT "->crtc%u "
> > > > DRM_RECT_FMT
> > > > ", %4.4s ubwc %d\n", fb->base.id [1],
> > > > DRM_RECT_ARG(&src),
> > > > crtc->base.id [1], DRM_RECT_ARG(&dst),
> > > 
> > > Don't you have to update pdpu->pipe_cfg.src_rect and
> > > pdpu->pipe_cfg.dst_rect with clip?
> > 
> > No, clip is the active area, so it'll always be equal to the adjusted
> > mode.
> > 
> > Sean
> > 
> 
> Got it! In that case, can drm_atomic_helper_check_plane_state helper be
> useful here?

Yeah, good call, I'll switch over to that.

Thanks,

Sean

> 
> > > --
> > > Jeykumar S
> > 
> > 
> > Links:
> > ------
> > [1] http://base.id
> 
> -- 
> Jeykumar S
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 07c2d15b45f2..f0a5e776ba32 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1551,8 +1551,7 @@  static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
 		cnt++;
 
 		dst = drm_plane_state_dest(pstate);
-		if (!drm_rect_intersect(&clip, &dst) ||
-		    !drm_rect_equals(&clip, &dst)) {
+		if (!drm_rect_intersect(&clip, &dst)) {
 			DPU_ERROR("invalid vertical/horizontal destination\n");
 			DPU_ERROR("display: " DRM_RECT_FMT " plane: "
 				  DRM_RECT_FMT "\n", DRM_RECT_ARG(&crtc_rect),
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index efdf9b200dd9..adfd16625188 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -1254,7 +1254,8 @@  static int dpu_plane_sspp_atomic_update(struct drm_plane *plane,
 	const struct dpu_format *fmt;
 	struct drm_crtc *crtc;
 	struct drm_framebuffer *fb;
-	struct drm_rect src, dst;
+	struct drm_rect clip = { 0 }, src, dst;
+	int hscale, vscale;
 
 	if (!plane) {
 		DPU_ERROR("invalid plane\n");
@@ -1300,6 +1301,17 @@  static int dpu_plane_sspp_atomic_update(struct drm_plane *plane,
 
 	dst = drm_plane_state_dest(state);
 
+	hscale = drm_rect_calc_hscale(&src, &dst,
+				      pdpu->pipe_sblk->maxupscale,
+				      pdpu->pipe_sblk->maxdwnscale);
+	vscale = drm_rect_calc_vscale(&src, &dst,
+				      pdpu->pipe_sblk->maxupscale,
+				      pdpu->pipe_sblk->maxdwnscale);
+
+	clip.x2 = crtc->state->adjusted_mode.hdisplay;
+	clip.y2 = crtc->state->adjusted_mode.vdisplay;
+	drm_rect_clip_scaled(&src, &dst, &clip, hscale, vscale);
+
 	DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FMT "->crtc%u " DRM_RECT_FMT
 			", %4.4s ubwc %d\n", fb->base.id, DRM_RECT_ARG(&src),
 			crtc->base.id, DRM_RECT_ARG(&dst),