[PATCH 4.9 03/30] drm/vc4: crtc: Use an union to store the page flip callback

Greg Kroah-Hartman posted 30 patches 3 years, 6 months ago
[PATCH 4.9 03/30] drm/vc4: crtc: Use an union to store the page flip callback
Posted by Greg Kroah-Hartman 3 years, 6 months ago
From: Maxime Ripard <maxime@cerno.tech>

[ Upstream commit 2523e9dcc3be91bf9fdc0d1e542557ca00bbef42 ]

We'll need to extend the vc4_async_flip_state structure to rely on
another callback implementation, so let's move the current one into a
union.

Reviewed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220610115149.964394-10-maxime@cerno.tech
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
index 51d34e7275ab..9d97f535a4d6 100644
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -717,17 +717,17 @@ struct vc4_async_flip_state {
 	struct drm_framebuffer *fb;
 	struct drm_pending_vblank_event *event;
 
-	struct vc4_seqno_cb cb;
+	union {
+		struct vc4_seqno_cb seqno;
+	} cb;
 };
 
 /* Called when the V3D execution for the BO being flipped to is done, so that
  * we can actually update the plane's address to point to it.
  */
 static void
-vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
+vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state)
 {
-	struct vc4_async_flip_state *flip_state =
-		container_of(cb, struct vc4_async_flip_state, cb);
 	struct drm_crtc *crtc = flip_state->crtc;
 	struct drm_device *dev = crtc->dev;
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -749,6 +749,14 @@ vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
 	up(&vc4->async_modeset);
 }
 
+static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb)
+{
+	struct vc4_async_flip_state *flip_state =
+		container_of(cb, struct vc4_async_flip_state, cb.seqno);
+
+	vc4_async_page_flip_complete(flip_state);
+}
+
 /* Implements async (non-vblank-synced) page flips.
  *
  * The page flip ioctl needs to return immediately, so we grab the
@@ -794,8 +802,8 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,
 	drm_atomic_set_fb_for_plane(plane->state, fb);
 	plane->fb = fb;
 
-	vc4_queue_seqno_cb(dev, &flip_state->cb, bo->seqno,
-			   vc4_async_page_flip_complete);
+	vc4_queue_seqno_cb(dev, &flip_state->cb.seqno, bo->seqno,
+			   vc4_async_page_flip_seqno_complete);
 
 	/* Driver takes ownership of state on successful async commit. */
 	return 0;
-- 
2.35.1
Re: [PATCH 4.9 03/30] drm/vc4: crtc: Use an union to store the page flip callback
Posted by Pavel Machek 3 years, 6 months ago
Hi!

> From: Maxime Ripard <maxime@cerno.tech>
> 
> [ Upstream commit 2523e9dcc3be91bf9fdc0d1e542557ca00bbef42 ]
> 
> We'll need to extend the vc4_async_flip_state structure to rely on
> another callback implementation, so let's move the current one into a
> union.

AFAICT this is preparation, not a bugfix; and I don't see patch this
prepares for queued. So we should not have this one, either.

Best regards,
								Pavel

> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -717,17 +717,17 @@ struct vc4_async_flip_state {
>  	struct drm_framebuffer *fb;
>  	struct drm_pending_vblank_event *event;
>  
> -	struct vc4_seqno_cb cb;
> +	union {
> +		struct vc4_seqno_cb seqno;
> +	} cb;
>  };
>  
>  /* Called when the V3D execution for the BO being flipped to is done, so that
>   * we can actually update the plane's address to point to it.
>   */
>  static void
> -vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
> +vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state)
>  {
> -	struct vc4_async_flip_state *flip_state =
> -		container_of(cb, struct vc4_async_flip_state, cb);
>  	struct drm_crtc *crtc = flip_state->crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct vc4_dev *vc4 = to_vc4_dev(dev);
> @@ -749,6 +749,14 @@ vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
>  	up(&vc4->async_modeset);
>  }
>  
> +static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb)
> +{
> +	struct vc4_async_flip_state *flip_state =
> +		container_of(cb, struct vc4_async_flip_state, cb.seqno);
> +
> +	vc4_async_page_flip_complete(flip_state);
> +}
> +
>  /* Implements async (non-vblank-synced) page flips.
>   *
>   * The page flip ioctl needs to return immediately, so we grab the
> @@ -794,8 +802,8 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,
>  	drm_atomic_set_fb_for_plane(plane->state, fb);
>  	plane->fb = fb;
>  
> -	vc4_queue_seqno_cb(dev, &flip_state->cb, bo->seqno,
> -			   vc4_async_page_flip_complete);
> +	vc4_queue_seqno_cb(dev, &flip_state->cb.seqno, bo->seqno,
> +			   vc4_async_page_flip_seqno_complete);
>  
>  	/* Driver takes ownership of state on successful async commit. */
>  	return 0;

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Re: [PATCH 4.9 03/30] drm/vc4: crtc: Use an union to store the page flip callback
Posted by Greg Kroah-Hartman 3 years, 6 months ago
On Mon, Sep 26, 2022 at 12:38:00PM +0200, Pavel Machek wrote:
> Hi!
> 
> > From: Maxime Ripard <maxime@cerno.tech>
> > 
> > [ Upstream commit 2523e9dcc3be91bf9fdc0d1e542557ca00bbef42 ]
> > 
> > We'll need to extend the vc4_async_flip_state structure to rely on
> > another callback implementation, so let's move the current one into a
> > union.
> 
> AFAICT this is preparation, not a bugfix; and I don't see patch this
> prepares for queued. So we should not have this one, either.

Dropped.

For some reason we had a bunch of 4.9-only patches that were not in any
other stable tree, so they shouldn't have only gone to 4.9.  I'll review
them all again and then push out a -rc2.

thanks,

greg k-h