From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@linux.ie, sam@ravnborg.org,
mripard@kernel.org, maarten.lankhorst@linux.intel.com,
christian.koenig@amd.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 10/10] drm/fb-helper: Acquire modeset lock around shadow-buffer flushing
Date: Mon, 16 Nov 2020 21:04:37 +0100 [thread overview]
Message-ID: <20201116200437.17977-11-tzimmermann@suse.de> (raw)
In-Reply-To: <20201116200437.17977-1-tzimmermann@suse.de>
Flushing the fbdev's shadow buffer requires vmap'ing the BO memory, which
in turn requires pinning the BO. While being pinned, the BO cannot be moved
into VRAM for scanout. Consequently, a concurrent modeset operation that
involves the fbdev framebuffer would likely fail.
Resolve this problem be acquiring the modeset lock of the planes that use
the fbdev framebuffer. On non-atomic drivers, also acquire the mode-config
lock. This serializes the flushing of the framebuffer with concurrent
modeset operations.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_fb_helper.c | 43 +++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 5a22c744378c..af485c71a42a 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -394,20 +394,59 @@ static void drm_fb_helper_damage_blit_real(struct drm_fb_helper *fb_helper,
static int drm_fb_helper_damage_blit(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip)
{
+ struct drm_device *dev = fb_helper->dev;
+ struct drm_framebuffer *fb = fb_helper->fb;
struct drm_client_buffer *buffer = fb_helper->buffer;
+ struct drm_modeset_acquire_ctx ctx;
+ struct drm_framebuffer *plane_fb;
+ struct drm_plane *plane;
struct dma_buf_map map, dst;
int ret;
+ if (!drm_drv_uses_atomic_modeset(dev))
+ mutex_lock(&dev->mode_config.mutex);
+
+ drm_modeset_acquire_init(&ctx, 0);
+
+retry:
+ drm_for_each_plane(plane, dev) {
+ ret = drm_modeset_lock(&plane->mutex, &ctx);
+ if (ret == -EDEADLK) {
+ ret = drm_modeset_backoff(&ctx);
+ if (!ret)
+ goto retry;
+ } else if (ret) {
+ goto out;
+ }
+
+ if (drm_drv_uses_atomic_modeset(dev))
+ plane_fb = plane->state->fb;
+ else
+ plane_fb = plane->fb;
+
+ if (plane_fb != fb) {
+ drm_modeset_unlock(&plane->mutex);
+ continue;
+ }
+ }
+
ret = drm_client_buffer_vmap(buffer, &map);
if (ret)
- return ret;
+ goto out;
dst = map;
drm_fb_helper_damage_blit_real(fb_helper, clip, &dst);
drm_client_buffer_vunmap(buffer);
- return 0;
+out:
+ drm_modeset_drop_locks(&ctx);
+ drm_modeset_acquire_fini(&ctx);
+
+ if (!drm_drv_uses_atomic_modeset(dev))
+ mutex_unlock(&dev->mode_config.mutex);
+
+ return ret;
}
static void drm_fb_helper_damage_work(struct work_struct *work)
--
2.29.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-11-16 20:05 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-16 20:04 [PATCH 00/10] drm/fb-helper: Various fixes and cleanups Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 01/10] drm/fb-helper: Call dirty helper after writing to fbdev Thomas Zimmermann
2020-11-16 20:04 ` Thomas Zimmermann
2020-11-17 16:22 ` Ville Syrjälä
2020-11-17 16:22 ` Ville Syrjälä
2020-11-18 7:56 ` Thomas Zimmermann
2020-11-18 7:56 ` Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 02/10] drm/fb-helper: Unmap client buffer during shutdown Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 03/10] drm/client: Depend on GEM object kmap ref-counting Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 04/10] drm/fb-helper: Rename dirty worker to damage worker Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 05/10] drm/fb-helper: Return early in dirty worker Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 06/10] drm/fb-helper: Separate shadow-buffer flushing and calling dirty callback Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 07/10] drm/fb-helper: Move damage blit code and its setup into separate routine Thomas Zimmermann
2020-11-16 20:04 ` [PATCH 08/10] drm/fb-helper: Restore damage area upon errors Thomas Zimmermann
2020-11-16 20:52 ` Daniel Vetter
2020-11-17 15:14 ` Sebastian Reichel
2020-11-17 16:54 ` Daniel Vetter
2020-11-16 20:04 ` [PATCH 09/10] drm/fb-helper: Copy dma-buf map before flushing shadow fb Thomas Zimmermann
2020-11-16 20:04 ` Thomas Zimmermann [this message]
2020-11-16 20:48 ` [PATCH 10/10] drm/fb-helper: Acquire modeset lock around shadow-buffer flushing Daniel Vetter
2020-11-17 8:05 ` Christian König
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=20201116200437.17977-11-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@linux.ie \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=sam@ravnborg.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.