drm/armada: store plane in armada_plane_work
authorRussell King <rmk+kernel@armlinux.org.uk>
Fri, 7 Jul 2017 14:55:53 +0000 (15:55 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Fri, 8 Dec 2017 12:17:21 +0000 (12:17 +0000)
Store the plane in the armada_plane_work structure rather than passing
it around; it doesn't get used very much in the work structures, so
passing it around is a needless expense.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
drivers/gpu/drm/armada/armada_crtc.c
drivers/gpu/drm/armada/armada_crtc.h
drivers/gpu/drm/armada/armada_overlay.c

index 8606f6e35986d780e5de928fe40667dc9d2fa666..4d3db441466ecaae642e95c4d928acfbd8eb709e 100644 (file)
@@ -224,7 +224,7 @@ static void armada_drm_plane_work_run(struct armada_crtc *dcrtc,
 
        /* Handle any pending frame work. */
        if (work) {
-               work->fn(dcrtc, dplane, work);
+               work->fn(dcrtc, work);
                drm_crtc_vblank_put(&dcrtc->crtc);
        }
 
@@ -232,8 +232,9 @@ static void armada_drm_plane_work_run(struct armada_crtc *dcrtc,
 }
 
 int armada_drm_plane_work_queue(struct armada_crtc *dcrtc,
-       struct armada_plane *plane, struct armada_plane_work *work)
+       struct armada_plane_work *work)
 {
+       struct armada_plane *plane = drm_to_armada_plane(work->plane);
        int ret;
 
        ret = drm_crtc_vblank_get(&dcrtc->crtc);
@@ -263,16 +264,8 @@ void armada_drm_plane_work_cancel(struct armada_crtc *dcrtc,
                drm_crtc_vblank_put(&dcrtc->crtc);
 }
 
-static int armada_drm_crtc_queue_frame_work(struct armada_crtc *dcrtc,
-       struct armada_frame_work *work)
-{
-       struct armada_plane *plane = drm_to_armada_plane(dcrtc->crtc.primary);
-
-       return armada_drm_plane_work_queue(dcrtc, plane, &work->work);
-}
-
 static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc,
-       struct armada_plane *plane, struct armada_plane_work *work)
+       struct armada_plane_work *work)
 {
        struct armada_frame_work *fwork = container_of(work, struct armada_frame_work, work);
        struct drm_device *dev = dcrtc->crtc.dev;
@@ -293,7 +286,8 @@ static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc,
        kfree(fwork);
 }
 
-static struct armada_frame_work *armada_drm_crtc_alloc_frame_work(void)
+static struct armada_frame_work *
+armada_drm_crtc_alloc_frame_work(struct drm_plane *plane)
 {
        struct armada_frame_work *work;
        int i = 0;
@@ -302,6 +296,7 @@ static struct armada_frame_work *armada_drm_crtc_alloc_frame_work(void)
        if (!work)
                return NULL;
 
+       work->work.plane = plane;
        work->work.fn = armada_drm_crtc_complete_frame_work;
        armada_reg_queue_end(work->regs, i);
 
@@ -322,11 +317,11 @@ static void armada_drm_crtc_finish_fb(struct armada_crtc *dcrtc,
                return;
        }
 
-       work = armada_drm_crtc_alloc_frame_work();
+       work = armada_drm_crtc_alloc_frame_work(dcrtc->crtc.primary);
        if (work) {
                work->old_fb = fb;
 
-               if (armada_drm_crtc_queue_frame_work(dcrtc, work) == 0)
+               if (armada_drm_plane_work_queue(dcrtc, work) == 0)
                        return;
 
                kfree(work);
@@ -1044,7 +1039,7 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
        if (fb->format != crtc->primary->fb->format)
                return -EINVAL;
 
-       work = armada_drm_crtc_alloc_frame_work();
+       work = armada_drm_crtc_alloc_frame_work(dcrtc->crtc.primary);
        if (!work)
                return -ENOMEM;
 
@@ -1061,7 +1056,7 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
         */
        drm_framebuffer_get(fb);
 
-       ret = armada_drm_crtc_queue_frame_work(dcrtc, work);
+       ret = armada_drm_plane_work_queue(dcrtc, work);
        if (ret) {
                /* Undo our reference above */
                drm_framebuffer_put(fb);
index a054527eb9625a19d1f4c413c3ddcc861785d049..821c0dd21e45f175efd28fd0aa91e7a2ada8de71 100644 (file)
@@ -36,9 +36,8 @@ struct armada_plane;
 struct armada_variant;
 
 struct armada_plane_work {
-       void                    (*fn)(struct armada_crtc *,
-                                     struct armada_plane *,
-                                     struct armada_plane_work *);
+       void (*fn)(struct armada_crtc *, struct armada_plane_work *);
+       struct drm_plane *plane;
 };
 
 struct armada_plane_state {
@@ -60,7 +59,7 @@ struct armada_plane {
 
 int armada_drm_plane_init(struct armada_plane *plane);
 int armada_drm_plane_work_queue(struct armada_crtc *dcrtc,
-       struct armada_plane *plane, struct armada_plane_work *work);
+       struct armada_plane_work *work);
 int armada_drm_plane_work_wait(struct armada_plane *plane, long timeout);
 void armada_drm_plane_work_cancel(struct armada_crtc *dcrtc,
        struct armada_plane *plane);
index aba947696178e1a4e4e0e3953f506e366865f45b..1fa8ea8cb2deaceee6da6dad9796c8188eca1a79 100644 (file)
@@ -80,11 +80,12 @@ static void armada_ovl_retire_fb(struct armada_ovl_plane *dplane,
 
 /* === Plane support === */
 static void armada_ovl_plane_work(struct armada_crtc *dcrtc,
-       struct armada_plane *plane, struct armada_plane_work *work)
+       struct armada_plane_work *work)
 {
-       struct armada_ovl_plane *dplane = container_of(plane, struct armada_ovl_plane, base);
+       struct armada_ovl_plane *dplane = container_of(work->plane,
+                                       struct armada_ovl_plane, base.base);
 
-       trace_armada_ovl_plane_work(&dcrtc->crtc, &plane->base);
+       trace_armada_ovl_plane_work(&dcrtc->crtc, work->plane);
 
        armada_drm_crtc_update_regs(dcrtc, dplane->vbl.regs);
        armada_ovl_retire_fb(dplane, NULL);
@@ -252,8 +253,8 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
        }
        if (idx) {
                armada_reg_queue_end(dplane->vbl.regs, idx);
-               armada_drm_plane_work_queue(dcrtc, &dplane->base,
-                                           &dplane->vbl.work);
+               /* Queue it for update on the next interrupt if we are enabled */
+               armada_drm_plane_work_queue(dcrtc, &dplane->vbl.work);
        }
        return 0;
 }
@@ -454,6 +455,7 @@ int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
                return ret;
        }
 
+       dplane->vbl.work.plane = &dplane->base.base;
        dplane->vbl.work.fn = armada_ovl_plane_work;
 
        ret = drm_universal_plane_init(dev, &dplane->base.base, crtcs,