All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Subject: [PATCH 18/25] drm/armada: disable planes at next blanking period
Date: Fri, 08 Dec 2017 12:30:31 +0000	[thread overview]
Message-ID: <E1eNHnT-00076Y-7p@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20171208122754.GA20895@n2100.armlinux.org.uk>

Disable planes at the next blanking period rather than immediately.
In order to achieve this, we need to delay the clearing of dcrtc->plane
until after the next blanking period, so move that into a separate
work function.  To avoid races, we also need to move its assignment in
the overlay code.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/gpu/drm/armada/armada_crtc.c    | 59 ++++++++++++++++++++++++---------
 drivers/gpu/drm/armada/armada_overlay.c | 23 ++++---------
 2 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 98fb955f6889..c38a1409a14e 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -293,6 +293,19 @@ static void armada_drm_crtc_complete_frame_work(struct armada_crtc *dcrtc,
 	spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
 }
 
+static void armada_drm_crtc_complete_disable_work(struct armada_crtc *dcrtc,
+	struct armada_plane_work *work)
+{
+	unsigned long flags;
+
+	if (dcrtc->plane == work->plane)
+		dcrtc->plane = NULL;
+
+	spin_lock_irqsave(&dcrtc->irq_lock, flags);
+	armada_drm_crtc_update_regs(dcrtc, work->regs);
+	spin_unlock_irqrestore(&dcrtc->irq_lock, flags);
+}
+
 static struct armada_plane_work *
 armada_drm_crtc_alloc_plane_work(struct drm_plane *plane)
 {
@@ -392,8 +405,11 @@ static void armada_drm_crtc_prepare(struct drm_crtc *crtc)
 	 * the new mode parameters.
 	 */
 	plane = dcrtc->plane;
-	if (plane)
+	if (plane) {
 		drm_plane_force_disable(plane);
+		WARN_ON(!armada_drm_plane_work_wait(drm_to_armada_plane(plane),
+						    HZ));
+	}
 }
 
 /* The mode_config.mutex will be held for this call */
@@ -1120,28 +1136,22 @@ int armada_drm_plane_disable(struct drm_plane *plane,
 {
 	struct armada_plane *dplane = drm_to_armada_plane(plane);
 	struct armada_crtc *dcrtc;
+	struct armada_plane_work *work;
+	unsigned int idx = 0;
 	u32 sram_para1, enable_mask;
 
 	if (!plane->crtc)
 		return 0;
 
 	/*
-	 * Drop our reference on any framebuffer attached to this plane.
-	 * We don't need to NULL this out as drm_plane_force_disable(),
-	 * and __setplane_internal() will do so for an overlay plane, and
-	 * __drm_helper_disable_unused_functions() will do so for the
-	 * primary plane.
+	 * Arrange to power down most RAMs and FIFOs if this is the primary
+	 * plane, otherwise just the YUV FIFOs for the overlay plane.
 	 */
-	if (plane->fb)
-		drm_framebuffer_put(plane->fb);
-
-	/* Power down most RAMs and FIFOs if this is the primary plane */
 	if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
 		sram_para1 = CFG_PDWN256x32 | CFG_PDWN256x24 | CFG_PDWN256x8 |
 			     CFG_PDWN32x32 | CFG_PDWN64x66;
 		enable_mask = CFG_GRA_ENA;
 	} else {
-		/* Power down the Y/U/V FIFOs */
 		sram_para1 = CFG_PDWN16x66 | CFG_PDWN32x66;
 		enable_mask = CFG_DMA_ENA;
 	}
@@ -1150,14 +1160,33 @@ int armada_drm_plane_disable(struct drm_plane *plane,
 
 	dcrtc = drm_to_armada_crtc(plane->crtc);
 
+	/*
+	 * Try to disable the plane and drop our ref on the framebuffer
+	 * at the next frame update. If we fail for any reason, disable
+	 * the plane immediately.
+	 */
+	work = &dplane->works[dplane->next_work];
+	work->fn = armada_drm_crtc_complete_disable_work;
+	work->cancel = armada_drm_crtc_complete_disable_work;
+	work->old_fb = plane->fb;
+
+	armada_reg_queue_mod(work->regs, idx,
+			     0, enable_mask, LCD_SPU_DMA_CTRL0);
+	armada_reg_queue_mod(work->regs, idx,
+			     sram_para1, 0, LCD_SPU_SRAM_PARA1);
+	armada_reg_queue_end(work->regs, idx);
+
 	/* Wait for any preceding work to complete, but don't wedge */
 	if (WARN_ON(!armada_drm_plane_work_wait(dplane, HZ)))
 		armada_drm_plane_work_cancel(dcrtc, dplane);
 
-	spin_lock_irq(&dcrtc->irq_lock);
-	armada_updatel(0, enable_mask, dcrtc->base + LCD_SPU_DMA_CTRL0);
-	armada_updatel(sram_para1, 0, dcrtc->base + LCD_SPU_SRAM_PARA1);
-	spin_unlock_irq(&dcrtc->irq_lock);
+	if (armada_drm_plane_work_queue(dcrtc, work)) {
+		work->fn(dcrtc, work);
+		if (work->old_fb)
+			drm_framebuffer_unreference(work->old_fb);
+	}
+
+	dplane->next_work = !dplane->next_work;
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/armada/armada_overlay.c b/drivers/gpu/drm/armada/armada_overlay.c
index bad966ae6758..0fe3f2db8ff5 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -140,11 +140,6 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 		     dplane->base.state.src_x != state.src.x1 >> 16 ||
 	             dplane->base.state.src_y != state.src.y1 >> 16;
 
-	if (!dcrtc->plane) {
-		dcrtc->plane = plane;
-		armada_ovl_update_attr(&dplane->prop, dcrtc);
-	}
-
 	/* FIXME: overlay on an interlaced display */
 	/* Just updating the position/size? */
 	if (!fb_changed && dplane->base.state.ctrl0 == ctrl0) {
@@ -173,6 +168,11 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (armada_drm_plane_work_wait(&dplane->base, HZ / 25) == 0)
 		armada_drm_plane_work_cancel(dcrtc, &dplane->base);
 
+	if (!dcrtc->plane) {
+		dcrtc->plane = plane;
+		armada_ovl_update_attr(&dplane->prop, dcrtc);
+	}
+
 	if (fb_changed) {
 		u32 addrs[3];
 
@@ -255,17 +255,6 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	return 0;
 }
 
-static int armada_ovl_plane_disable(struct drm_plane *plane,
-				    struct drm_modeset_acquire_ctx *ctx)
-{
-	armada_drm_plane_disable(plane, ctx);
-
-	if (plane->crtc)
-		drm_to_armada_crtc(plane->crtc)->plane = NULL;
-
-	return 0;
-}
-
 static void armada_ovl_plane_destroy(struct drm_plane *plane)
 {
 	struct armada_ovl_plane *dplane = drm_to_armada_ovl_plane(plane);
@@ -345,7 +334,7 @@ static int armada_ovl_plane_set_property(struct drm_plane *plane,
 
 static const struct drm_plane_funcs armada_ovl_plane_funcs = {
 	.update_plane	= armada_ovl_plane_update,
-	.disable_plane	= armada_ovl_plane_disable,
+	.disable_plane	= armada_drm_plane_disable,
 	.destroy	= armada_ovl_plane_destroy,
 	.set_property	= armada_ovl_plane_set_property,
 };
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-12-08 12:30 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 12:13 [PATCH v2 0/5] Armada DRM fixes Russell King - ARM Linux
2017-12-08 12:14 ` [PATCH 1/5] drm/armada: fix leak of crtc structure Russell King
2017-12-08 12:14 ` [PATCH 2/5] drm/armada: fix SRAM powerdown Russell King
2017-12-08 12:14 ` [PATCH 3/5] drm/armada: fix UV swap code Russell King
2017-12-08 12:14 ` [PATCH 4/5] drm/armada: improve efficiency of armada_drm_plane_calc_addrs() Russell King
2017-12-08 12:14 ` [PATCH 5/5] drm/armada: fix YUV planar format framebuffer offsets Russell King
2017-12-08 12:27 ` [PATCH 00/25] Armada DRM development for 4.16 Russell King - ARM Linux
2017-12-08 12:29   ` [PATCH 01/25] drm/armada: remove armada_drm_plane_work_cancel() return value Russell King
2017-12-08 12:29   ` [PATCH 02/25] drm/armada: add a common frame work allocator Russell King
2017-12-08 12:29   ` [PATCH 03/25] drm/armada: store plane in armada_plane_work Russell King
2017-12-08 12:29   ` [PATCH 04/25] drm/armada: add work cancel callback Russell King
2017-12-08 12:29   ` [PATCH 05/25] drm/armada: wait and cancel any pending frame work at disable Russell King
2017-12-08 12:29   ` [PATCH 06/25] drm/armada: allow the primary plane to be disabled Russell King
2017-12-08 12:29   ` [PATCH 07/25] drm/armada: clean up armada_drm_crtc_plane_disable() Russell King
2017-12-08 12:29   ` [PATCH 08/25] drm/armada: clear plane enable bit when disabling Russell King
2017-12-08 12:29   ` [PATCH 09/25] drm/armada: move overlay plane work out from under spinlock Russell King
2017-12-08 12:29   ` [PATCH 10/25] drm/armada: move fb retirement into armada_plane_work Russell King
2017-12-08 12:29   ` [PATCH 11/25] drm/armada: move event sending " Russell King
2017-12-08 12:29   ` [PATCH 12/25] drm/armada: move regs " Russell King
2017-12-08 12:30   ` [PATCH 13/25] drm/armada: move writes of LCD_SPU_SRAM_PARA1 under lock Russell King
2017-12-08 12:30   ` [PATCH 14/25] drm/armada: only enable HSMOOTH if scaling horizontally Russell King
2017-12-08 12:30   ` [PATCH 15/25] drm/armada: use drm_plane_helper_check_state() Russell King
2017-12-08 12:30   ` [PATCH 16/25] drm/armada: allow armada_drm_plane_work_queue() to silently fail Russell King
2017-12-08 12:30   ` [PATCH 17/25] drm/armada: avoid work allocation Russell King
2017-12-08 12:30   ` Russell King [this message]
2017-12-08 12:30   ` [PATCH 19/25] drm/armada: re-organise overlay register update generation Russell King
2017-12-08 12:30   ` [PATCH 20/25] drm/armada: move overlay plane " Russell King
2017-12-08 12:30   ` [PATCH 21/25] drm/armada: wait for previous work when moving overlay window Russell King
2017-12-08 12:30   ` [PATCH 22/25] drm/armada: extract register generation from armada_drm_primary_set() Russell King
2017-12-08 12:30   ` [PATCH 23/25] drm/armada: implement primary plane update Russell King
2017-12-08 12:31   ` [PATCH 24/25] drm/armada: expand overlay trace entry Russell King
2017-12-08 12:31   ` [PATCH 25/25] drm/armada: add iturbt_709 plane property to control YUV colorspace Russell King
2017-12-11 20:54     ` Daniel Vetter
2017-12-11 22:17       ` Russell King - ARM Linux
2017-12-13 15:02     ` Ville Syrjälä
2017-12-13 15:41     ` Daniel Stone
2017-12-13 16:07       ` Russell King - ARM Linux
2017-12-13 16:12       ` Ilia Mirkin
2017-12-13 16:22         ` Ville Syrjälä
2018-01-01 12:17           ` Russell King - ARM Linux
2018-07-20 11:39             ` Russell King - ARM Linux
2018-07-20 12:26               ` Ville Syrjälä

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1eNHnT-00076Y-7p@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.