Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion drivers/gpu/drm/vc4/vc4_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -2400,15 +2400,26 @@ u32 vc4_plane_dlist_size(const struct drm_plane_state *state)
*/
void vc4_plane_async_set_fb(struct drm_plane *plane, struct drm_framebuffer *fb)
{
struct vc4_plane_state *vc4_state = to_vc4_plane_state(plane->state);
struct drm_plane_state *state = plane->state;
struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
struct drm_gem_dma_object *bo = drm_fb_dma_get_gem_obj(fb, 0);
struct vc4_dev *vc4 = to_vc4_dev(plane->dev);
dma_addr_t dma_addr = bo->dma_addr + fb->offsets[0];
unsigned int rotation;
int idx;

if (!drm_dev_enter(plane->dev, &idx))
return;

rotation = drm_rotation_simplify(state->rotation,
DRM_MODE_ROTATE_0 |
DRM_MODE_REFLECT_X |
DRM_MODE_REFLECT_Y);

/* We must point to the last line when Y reflection is enabled. */
if (rotation & DRM_MODE_REFLECT_Y)
dma_addr += fb->pitches[0] * ((vc4_state->src_h[0] >> 16) - 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut feeling is this should be rounded up.
If height is 1.9*(1<<16) without flipping, then I'd expect the HVS to fetch line 0, then 1.

With flipping I'd expect it to fetch line 1, then 0.

It feels like with the round down, it will be fetching line 0, then line -1.

Note: I suspect there are other instances of vc4_state->src_h[0] >> 16 being used as height in this file which need thought about rounding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's matching the handling in the non-async path at https://github.com/raspberrypi/linux/blob/rpi-6.12.y/drivers/gpu/drm/vc4/vc4_plane.c#L1387-L1389.
Ideally the common bits should be extracted into a helper rather than duplicated, but I didn't fancy doing that right now.

Kivy is triggering this path due to waiting on the v3d buffer fence triggering vc4_async_page_flip_fence_complete / vc4_async_page_flip_complete. It looks like they just call DRM_IOCTL_MODE_PAGE_FLIP to trigger drm_atomic_set_fb_for_plane.
AIUI this is the legacy async flip hook, and applications should really be using the atomic async commits which would go through vc4_plane_atomic_async_[check|update] which would use vc4_plane_mode_set to generate a complete dlist using the normal path. I'm really loathed to expend too much energy on fixing up the legacy path.


/* We're skipping the address adjustment for negative origin,
* because this is only called on the primary plane.
*/
Expand Down