diff mbox

[08/20] drm/armada: use xchg() to atomically update dplane->old_fb

Message ID E1ZgzLt-0003lG-Aq@rmk-PC.arm.linux.org.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Russell King Sept. 29, 2015, 6:10 p.m. UTC
Rather than using a spinlock, use xchg() to atomically update
dplane->old_fb.  This allows us to eliminate dplane->lock.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/gpu/drm/armada/armada_overlay.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

Comments

Emil Velikov Sept. 30, 2015, 10:49 a.m. UTC | #1
Hi Russell,

On 29 September 2015 at 19:10, Russell King <rmk+kernel@arm.linux.org.uk> wrote:
> Rather than using a spinlock, use xchg() to atomically update
> dplane->old_fb.  This allows us to eliminate dplane->lock.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
[...]
> @@ -76,13 +75,10 @@ static void armada_ovl_retire_fb(struct armada_ovl_plane *dplane,
>  {
>         struct drm_framebuffer *old_fb;
>
> -       spin_lock(&dplane->lock);
> -       old_fb = dplane->old_fb;
> -       dplane->old_fb = fb;
> -       spin_unlock(&dplane->lock);
> +       old_fb = xchg(&dplane->old_fb, fb);
>
>         if (old_fb)
> -               armada_drm_queue_unref_work(dplane->base.dev, old_fb);
> +               armada_drm_queue_unref_work(dplane->base.base.dev, old_fb);
Shouldn't this be part of another patch ?

-Emil
Russell King - ARM Linux Oct. 1, 2015, 1:34 p.m. UTC | #2
On Wed, Sep 30, 2015 at 11:49:44AM +0100, Emil Velikov wrote:
> Hi Russell,
> 
> On 29 September 2015 at 19:10, Russell King <rmk+kernel@arm.linux.org.uk> wrote:
> > Rather than using a spinlock, use xchg() to atomically update
> > dplane->old_fb.  This allows us to eliminate dplane->lock.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > ---
> [...]
> > @@ -76,13 +75,10 @@ static void armada_ovl_retire_fb(struct armada_ovl_plane *dplane,
> >  {
> >         struct drm_framebuffer *old_fb;
> >
> > -       spin_lock(&dplane->lock);
> > -       old_fb = dplane->old_fb;
> > -       dplane->old_fb = fb;
> > -       spin_unlock(&dplane->lock);
> > +       old_fb = xchg(&dplane->old_fb, fb);
> >
> >         if (old_fb)
> > -               armada_drm_queue_unref_work(dplane->base.dev, old_fb);
> > +               armada_drm_queue_unref_work(dplane->base.base.dev, old_fb);
> Shouldn't this be part of another patch ?

Yes, you're right, it should be in:

drm/armada: introduce generic armada_plane struct

Now moved there, thanks.
diff mbox

Patch

diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index 093c2d4f2b79..8738b590abc2 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -31,7 +31,6 @@  struct armada_ovl_plane_properties {
 
 struct armada_ovl_plane {
 	struct drm_plane base;
-	spinlock_t lock;
 	struct drm_framebuffer *old_fb;
 	uint32_t src_hw;
 	uint32_t dst_hw;
@@ -76,13 +75,10 @@  static void armada_ovl_retire_fb(struct armada_ovl_plane *dplane,
 {
 	struct drm_framebuffer *old_fb;
 
-	spin_lock(&dplane->lock);
-	old_fb = dplane->old_fb;
-	dplane->old_fb = fb;
-	spin_unlock(&dplane->lock);
+	old_fb = xchg(&dplane->old_fb, fb);
 
 	if (old_fb)
-		armada_drm_queue_unref_work(dplane->base.dev, old_fb);
+		armada_drm_queue_unref_work(dplane->base.base.dev, old_fb);
 }
 
 /* === Plane support === */
@@ -289,10 +285,7 @@  static int armada_ovl_plane_disable(struct drm_plane *plane)
 	if (plane->fb)
 		drm_framebuffer_unreference(plane->fb);
 
-	spin_lock_irq(&dplane->lock);
-	fb = dplane->old_fb;
-	dplane->old_fb = NULL;
-	spin_unlock_irq(&dplane->lock);
+	fb = xchg(&dplane->old_fb, NULL);
 	if (fb)
 		drm_framebuffer_unreference(fb);
 
@@ -464,7 +457,6 @@  int armada_overlay_plane_create(struct drm_device *dev, unsigned long crtcs)
 	if (!dplane)
 		return -ENOMEM;
 
-	spin_lock_init(&dplane->lock);
 	init_waitqueue_head(&dplane->vbl.wait);
 	armada_drm_vbl_event_init(&dplane->vbl.update, armada_ovl_plane_vbl,
 				  dplane);