All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@gmail.com, mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, thierry.reding@gmail.com,
	sam@ravnborg.org, emma@anholt.net, david@lechnology.com,
	kamlesh.gurudasani@gmail.com, noralf@tronnes.org,
	javierm@redhat.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 8/8] drm/mipi-dbi: Move drm_dev_{enter, exit}() out from fb_dirty functions
Date: Mon, 21 Nov 2022 11:45:32 +0100	[thread overview]
Message-ID: <20221121104532.8301-9-tzimmermann@suse.de> (raw)
In-Reply-To: <20221121104532.8301-1-tzimmermann@suse.de>

Call drm_dev_enter() and drm_dev_exit() in the outer-most callbacks
of the modesetting pipeline. If drm_dev_enter() fails, the driver can
thus avoid unnecessary work.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_mipi_dbi.c | 13 +++++++------
 drivers/gpu/drm/tiny/ili9225.c | 13 +++++++------
 drivers/gpu/drm/tiny/st7586.c  | 13 +++++++------
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index d45824a65c9fd..fc1c8c536370a 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -261,13 +261,10 @@ static void mipi_dbi_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
 	unsigned int width = rect->x2 - rect->x1;
 	struct mipi_dbi *dbi = &dbidev->dbi;
 	bool swap = dbi->swap_bytes;
-	int idx, ret = 0;
+	int ret = 0;
 	bool full;
 	void *tr;
 
-	if (!drm_dev_enter(fb->dev, &idx))
-		return;
-
 	full = width == fb->width && height == fb->height;
 
 	DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect));
@@ -290,8 +287,6 @@ static void mipi_dbi_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
 err_msg:
 	if (ret)
 		drm_err_once(fb->dev, "Failed to update display %d\n", ret);
-
-	drm_dev_exit(idx);
 }
 
 /**
@@ -330,6 +325,7 @@ void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
 		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_rect rect;
+	int idx;
 
 	if (!pipe->crtc.state->active)
 		return;
@@ -337,8 +333,13 @@ void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
 	if (WARN_ON(!fb))
 		return;
 
+	if (!drm_dev_enter(fb->dev, &idx))
+		return;
+
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
 		mipi_dbi_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
+
+	drm_dev_exit(idx);
 }
 EXPORT_SYMBOL(mipi_dbi_pipe_update);
 
diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index ba5681b63ffbf..7ecbb8b141757 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -87,13 +87,10 @@ static void ili9225_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
 	bool swap = dbi->swap_bytes;
 	u16 x_start, y_start;
 	u16 x1, x2, y1, y2;
-	int idx, ret = 0;
+	int ret = 0;
 	bool full;
 	void *tr;
 
-	if (!drm_dev_enter(fb->dev, &idx))
-		return;
-
 	full = width == fb->width && height == fb->height;
 
 	DRM_DEBUG_KMS("Flushing [FB:%d] " DRM_RECT_FMT "\n", fb->base.id, DRM_RECT_ARG(rect));
@@ -156,8 +153,6 @@ static void ili9225_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
 err_msg:
 	if (ret)
 		dev_err_once(fb->dev->dev, "Failed to update display %d\n", ret);
-
-	drm_dev_exit(idx);
 }
 
 static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -170,12 +165,18 @@ static void ili9225_pipe_update(struct drm_simple_display_pipe *pipe,
 		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_rect rect;
+	int idx;
 
 	if (!pipe->crtc.state->active)
 		return;
 
+	if (!drm_dev_enter(fb->dev, &idx))
+		return;
+
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
 		ili9225_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
+
+	drm_dev_exit(idx);
 }
 
 static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
index ddaa82c2e58ae..0f5e532fe5d1d 100644
--- a/drivers/gpu/drm/tiny/st7586.c
+++ b/drivers/gpu/drm/tiny/st7586.c
@@ -113,10 +113,7 @@ static void st7586_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
 {
 	struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);
 	struct mipi_dbi *dbi = &dbidev->dbi;
-	int start, end, idx, ret = 0;
-
-	if (!drm_dev_enter(fb->dev, &idx))
-		return;
+	int start, end, ret = 0;
 
 	/* 3 pixels per byte, so grow clip to nearest multiple of 3 */
 	rect->x1 = rounddown(rect->x1, 3);
@@ -145,8 +142,6 @@ static void st7586_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
 err_msg:
 	if (ret)
 		dev_err_once(fb->dev->dev, "Failed to update display %d\n", ret);
-
-	drm_dev_exit(idx);
 }
 
 static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
@@ -159,12 +154,18 @@ static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
 		&mipi_dbi_plane_state->shadow_plane_state;
 	struct drm_framebuffer *fb = state->fb;
 	struct drm_rect rect;
+	int idx;
 
 	if (!pipe->crtc.state->active)
 		return;
 
+	if (!drm_dev_enter(fb->dev, &idx))
+		return;
+
 	if (drm_atomic_helper_damage_merged(old_state, state, &rect))
 		st7586_fb_dirty(&shadow_plane_state->data[0], fb, &rect);
+
+	drm_dev_exit(idx);
 }
 
 static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
-- 
2.38.1


  parent reply	other threads:[~2022-11-21 10:46 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 10:45 [PATCH 0/8] drm/mipi-dbi: Convert to shadow-plane helpers Thomas Zimmermann
2022-11-21 10:45 ` [PATCH 1/8] drm/simple-kms: Remove drm_gem_simple_display_pipe_prepare_fb() Thomas Zimmermann
2022-11-25 16:45   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 2/8] drm/ili9225: Call MIPI DBI mode_valid helper Thomas Zimmermann
2022-11-25 16:52   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 3/8] drm/st7586: " Thomas Zimmermann
2022-11-25 16:52   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 4/8] drm/mipi-dbi: Initialize default driver functions with macro Thomas Zimmermann
2022-11-25 17:05   ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 5/8] drm/mipi-dbi: Prepare framebuffer copy operation in pipe-update helpers Thomas Zimmermann
2022-11-25 17:39   ` Noralf Trønnes
2022-12-02 11:27     ` Thomas Zimmermann
2022-12-02 11:50       ` Thomas Zimmermann
2022-12-02 12:22         ` Noralf Trønnes
2022-12-02 12:04       ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 6/8] drm/mipi-dbi: Support shadow-plane state Thomas Zimmermann
2022-11-25 17:48   ` Noralf Trønnes
2022-11-28 12:10     ` Thomas Zimmermann
2022-11-28 13:06       ` Noralf Trønnes
2022-11-21 10:45 ` [PATCH 7/8] drm/mipi-dbi: Use shadow-plane mappings Thomas Zimmermann
2022-11-28 13:07   ` Noralf Trønnes
2022-11-21 10:45 ` Thomas Zimmermann [this message]
2022-11-25 17:56   ` [PATCH 8/8] drm/mipi-dbi: Move drm_dev_{enter,exit}() out from fb_dirty functions Noralf Trønnes
2022-11-21 12:27 ` [PATCH 0/8] drm/mipi-dbi: Convert to shadow-plane helpers Noralf Trønnes
2022-11-21 12:41   ` Thomas Zimmermann
2022-11-21 15:14     ` Noralf Trønnes
2022-11-21 15:22   ` Javier Martinez Canillas
2022-11-25 18:00 ` Noralf Trønnes
2022-11-30  7:19 ` Javier Martinez Canillas

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=20221121104532.8301-9-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=david@lechnology.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emma@anholt.net \
    --cc=javierm@redhat.com \
    --cc=kamlesh.gurudasani@gmail.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=sam@ravnborg.org \
    --cc=thierry.reding@gmail.com \
    /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.