Message ID | 20220715134958.2605746-2-jouni.hogander@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fixes for damage clips handling | expand |
On Fri, Jul 15, 2022 at 04:49:56PM +0300, Jouni Högander wrote: > drm_plane_state->src might be modified by the driver. This is done > e.g. in i915 driver when there is bigger framebuffer than the plane > and there is some offset within framebuffer. I915 driver calculates > separate offset and adjusts src rect coords to be relative to this > offset. Damage clips are still relative to original src coords > provided by user-space. > > This patch ensures original coordinates provided by user-space are > used when initiliazing damage iterator. > > Signed-off-by: Jouni Högander <jouni.hogander@intel.com> Ah kunit test for this would be awesome. Iirc we have a few already for rect/damage stuff, defo should extend/fix those. -Daniel > --- > drivers/gpu/drm/drm_damage_helper.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c > index 937b699ac2a8..d8b2955e88fd 100644 > --- a/drivers/gpu/drm/drm_damage_helper.c > +++ b/drivers/gpu/drm/drm_damage_helper.c > @@ -224,6 +224,7 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, > const struct drm_plane_state *old_state, > const struct drm_plane_state *state) > { > + struct drm_rect src; > memset(iter, 0, sizeof(*iter)); > > if (!state || !state->crtc || !state->fb || !state->visible) > @@ -233,10 +234,12 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, > iter->num_clips = drm_plane_get_damage_clips_count(state); > > /* Round down for x1/y1 and round up for x2/y2 to catch all pixels */ > - iter->plane_src.x1 = state->src.x1 >> 16; > - iter->plane_src.y1 = state->src.y1 >> 16; > - iter->plane_src.x2 = (state->src.x2 >> 16) + !!(state->src.x2 & 0xFFFF); > - iter->plane_src.y2 = (state->src.y2 >> 16) + !!(state->src.y2 & 0xFFFF); > + src = drm_plane_state_src(state); > + > + iter->plane_src.x1 = src.x1 >> 16; > + iter->plane_src.y1 = src.y1 >> 16; > + iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF); > + iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF); > > if (!iter->clips || !drm_rect_equals(&state->src, &old_state->src)) { > iter->clips = NULL; > -- > 2.25.1 >
On Thu, 2022-08-11 at 18:23 +0200, Daniel Vetter wrote: > On Fri, Jul 15, 2022 at 04:49:56PM +0300, Jouni Högander wrote: > > drm_plane_state->src might be modified by the driver. This is done > > e.g. in i915 driver when there is bigger framebuffer than the plane > > and there is some offset within framebuffer. I915 driver calculates > > separate offset and adjusts src rect coords to be relative to this > > offset. Damage clips are still relative to original src coords > > provided by user-space. > > > > This patch ensures original coordinates provided by user-space are > > used when initiliazing damage iterator. > > > > Signed-off-by: Jouni Högander <jouni.hogander@intel.com> > > Ah kunit test for this would be awesome. Iirc we have a few already > for > rect/damage stuff, defo should extend/fix those. Can you please provide me some pointer to these tests? I have written earlier one igt test which reveals this issue: https://patchwork.freedesktop.org/series/103661/ https://patchwork.freedesktop.org/series/104488/ > -Daniel > > > --- > > drivers/gpu/drm/drm_damage_helper.c | 11 +++++++---- > > 1 file changed, 7 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_damage_helper.c > > b/drivers/gpu/drm/drm_damage_helper.c > > index 937b699ac2a8..d8b2955e88fd 100644 > > --- a/drivers/gpu/drm/drm_damage_helper.c > > +++ b/drivers/gpu/drm/drm_damage_helper.c > > @@ -224,6 +224,7 @@ drm_atomic_helper_damage_iter_init(struct > > drm_atomic_helper_damage_iter *iter, > > const struct drm_plane_state > > *old_state, > > const struct drm_plane_state *state) > > { > > + struct drm_rect src; > > memset(iter, 0, sizeof(*iter)); > > > > if (!state || !state->crtc || !state->fb || !state->visible) > > @@ -233,10 +234,12 @@ drm_atomic_helper_damage_iter_init(struct > > drm_atomic_helper_damage_iter *iter, > > iter->num_clips = drm_plane_get_damage_clips_count(state); > > > > /* Round down for x1/y1 and round up for x2/y2 to catch all > > pixels */ > > - iter->plane_src.x1 = state->src.x1 >> 16; > > - iter->plane_src.y1 = state->src.y1 >> 16; > > - iter->plane_src.x2 = (state->src.x2 >> 16) + !!(state->src.x2 & > > 0xFFFF); > > - iter->plane_src.y2 = (state->src.y2 >> 16) + !!(state->src.y2 & > > 0xFFFF); > > + src = drm_plane_state_src(state); > > + > > + iter->plane_src.x1 = src.x1 >> 16; > > + iter->plane_src.y1 = src.y1 >> 16; > > + iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF); > > + iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF); > > > > if (!iter->clips || !drm_rect_equals(&state->src, &old_state- > > >src)) { > > iter->clips = NULL; > > -- > > 2.25.1 > >
Hi Jouni, On 7/15/22 10:49, Jouni Högander wrote: > drm_plane_state->src might be modified by the driver. This is done > e.g. in i915 driver when there is bigger framebuffer than the plane > and there is some offset within framebuffer. I915 driver calculates > separate offset and adjusts src rect coords to be relative to this > offset. Damage clips are still relative to original src coords > provided by user-space. > > This patch ensures original coordinates provided by user-space are > used when initiliazing damage iterator. > drm_damage_helper has some KUnit tests on drivers/gpu/drm/tests, and by applying this patch the drm_damage_helper tests started to fail. Could you also refactor the drm_damage_helper tests? To run the tests, you can run: $ ./tools/testing/kunit/kunit.py run \ --kunitconfig=drivers/gpu/drm/tests \ --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y \ --kconfig_add CONFIG_VIRTIO_UML=y There is also some documentation on the DRM KUnit Tests on [1]. [1] https://docs.kernel.org/gpu/drm-internals.html#unit-testing Best Regards, - Maíra Canal > Signed-off-by: Jouni Högander <jouni.hogander@intel.com>> --- > drivers/gpu/drm/drm_damage_helper.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c > index 937b699ac2a8..d8b2955e88fd 100644 > --- a/drivers/gpu/drm/drm_damage_helper.c > +++ b/drivers/gpu/drm/drm_damage_helper.c > @@ -224,6 +224,7 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, > const struct drm_plane_state *old_state, > const struct drm_plane_state *state) > { > + struct drm_rect src; > memset(iter, 0, sizeof(*iter)); > > if (!state || !state->crtc || !state->fb || !state->visible) > @@ -233,10 +234,12 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, > iter->num_clips = drm_plane_get_damage_clips_count(state); > > /* Round down for x1/y1 and round up for x2/y2 to catch all pixels */ > - iter->plane_src.x1 = state->src.x1 >> 16; > - iter->plane_src.y1 = state->src.y1 >> 16; > - iter->plane_src.x2 = (state->src.x2 >> 16) + !!(state->src.x2 & 0xFFFF); > - iter->plane_src.y2 = (state->src.y2 >> 16) + !!(state->src.y2 & 0xFFFF); > + src = drm_plane_state_src(state); > + > + iter->plane_src.x1 = src.x1 >> 16; > + iter->plane_src.y1 = src.y1 >> 16; > + iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF); > + iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF); > > if (!iter->clips || !drm_rect_equals(&state->src, &old_state->src)) { > iter->clips = NULL;
On Fri, 2022-08-19 at 09:09 -0300, Maíra Canal wrote: > Hi Jouni, > > On 7/15/22 10:49, Jouni Högander wrote: > > drm_plane_state->src might be modified by the driver. This is done > > e.g. in i915 driver when there is bigger framebuffer than the plane > > and there is some offset within framebuffer. I915 driver calculates > > separate offset and adjusts src rect coords to be relative to this > > offset. Damage clips are still relative to original src coords > > provided by user-space. > > > > This patch ensures original coordinates provided by user-space are > > used when initiliazing damage iterator. > > > > drm_damage_helper has some KUnit tests on drivers/gpu/drm/tests, and > by > applying this patch the drm_damage_helper tests started to fail. > Could > you also refactor the drm_damage_helper tests? > > To run the tests, you can run: > $ ./tools/testing/kunit/kunit.py run \ > --kunitconfig=drivers/gpu/drm/tests \ > --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y \ > --kconfig_add CONFIG_VIRTIO_UML=y > > There is also some documentation on the DRM KUnit Tests on [1]. > > [1] https://docs.kernel.org/gpu/drm-internals.html#unit-testing Ok, thank you for these. I will take a look. > > Best Regards, > - Maíra Canal > > > Signed-off-by: Jouni Högander <jouni.hogander@intel.com>> --- > > drivers/gpu/drm/drm_damage_helper.c | 11 +++++++---- > > 1 file changed, 7 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_damage_helper.c > > b/drivers/gpu/drm/drm_damage_helper.c > > index 937b699ac2a8..d8b2955e88fd 100644 > > --- a/drivers/gpu/drm/drm_damage_helper.c > > +++ b/drivers/gpu/drm/drm_damage_helper.c > > @@ -224,6 +224,7 @@ drm_atomic_helper_damage_iter_init(struct > > drm_atomic_helper_damage_iter *iter, > > const struct drm_plane_state > > *old_state, > > const struct drm_plane_state *state) > > { > > + struct drm_rect src; > > memset(iter, 0, sizeof(*iter)); > > > > if (!state || !state->crtc || !state->fb || !state->visible) > > @@ -233,10 +234,12 @@ drm_atomic_helper_damage_iter_init(struct > > drm_atomic_helper_damage_iter *iter, > > iter->num_clips = drm_plane_get_damage_clips_count(state); > > > > /* Round down for x1/y1 and round up for x2/y2 to catch all > > pixels */ > > - iter->plane_src.x1 = state->src.x1 >> 16; > > - iter->plane_src.y1 = state->src.y1 >> 16; > > - iter->plane_src.x2 = (state->src.x2 >> 16) + !!(state->src.x2 & > > 0xFFFF); > > - iter->plane_src.y2 = (state->src.y2 >> 16) + !!(state->src.y2 & > > 0xFFFF); > > + src = drm_plane_state_src(state); > > + > > + iter->plane_src.x1 = src.x1 >> 16; > > + iter->plane_src.y1 = src.y1 >> 16; > > + iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF); > > + iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF); > > > > if (!iter->clips || !drm_rect_equals(&state->src, &old_state- > > >src)) { > > iter->clips = NULL;
diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c index 937b699ac2a8..d8b2955e88fd 100644 --- a/drivers/gpu/drm/drm_damage_helper.c +++ b/drivers/gpu/drm/drm_damage_helper.c @@ -224,6 +224,7 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, const struct drm_plane_state *old_state, const struct drm_plane_state *state) { + struct drm_rect src; memset(iter, 0, sizeof(*iter)); if (!state || !state->crtc || !state->fb || !state->visible) @@ -233,10 +234,12 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, iter->num_clips = drm_plane_get_damage_clips_count(state); /* Round down for x1/y1 and round up for x2/y2 to catch all pixels */ - iter->plane_src.x1 = state->src.x1 >> 16; - iter->plane_src.y1 = state->src.y1 >> 16; - iter->plane_src.x2 = (state->src.x2 >> 16) + !!(state->src.x2 & 0xFFFF); - iter->plane_src.y2 = (state->src.y2 >> 16) + !!(state->src.y2 & 0xFFFF); + src = drm_plane_state_src(state); + + iter->plane_src.x1 = src.x1 >> 16; + iter->plane_src.y1 = src.y1 >> 16; + iter->plane_src.x2 = (src.x2 >> 16) + !!(src.x2 & 0xFFFF); + iter->plane_src.y2 = (src.y2 >> 16) + !!(src.y2 & 0xFFFF); if (!iter->clips || !drm_rect_equals(&state->src, &old_state->src)) { iter->clips = NULL;
drm_plane_state->src might be modified by the driver. This is done e.g. in i915 driver when there is bigger framebuffer than the plane and there is some offset within framebuffer. I915 driver calculates separate offset and adjusts src rect coords to be relative to this offset. Damage clips are still relative to original src coords provided by user-space. This patch ensures original coordinates provided by user-space are used when initiliazing damage iterator. Signed-off-by: Jouni Högander <jouni.hogander@intel.com> --- drivers/gpu/drm/drm_damage_helper.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)