All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/core: Do not preserve framebuffer on rmfb, v2.
@ 2016-03-22  9:58 Maarten Lankhorst
  2016-03-22 11:35 ` ✗ Fi.CI.BAT: failure for " Patchwork
  2016-03-31 11:26 ` [PATCH] drm/core: Do not preserve framebuffer on rmfb, v3 Maarten Lankhorst
  0 siblings, 2 replies; 15+ messages in thread
From: Maarten Lankhorst @ 2016-03-22  9:58 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Thomas Hellstrom, stable, David Herrmann

It turns out that preserving framebuffers after the rmfb call breaks
vmwgfx userspace. This was originally introduced because it was thought
nobody relied on the behavior, but unfortunately it seems there are
exceptions.

drm_framebuffer_remove may fail with -EINTR now, so a straight revert
is impossible. There is no way to remove the framebuffer from the lists
and active planes without introducing a race because of the different
locking requirements. Instead call drm_framebuffer_remove from a
workqueue, which is unaffected by signals.

Changes since v1:
- Add comment.

Cc: stable@vger.kernel.org #v4.4+
Fixes: 13803132818c ("drm/core: Preserve the framebuffer after removing it.")
Testcase: kms_flip.flip-vs-rmfb-interruptible
References: https://lists.freedesktop.org/archives/dri-devel/2016-March/102876.html
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_crtc.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e08f962288d9..aaf6ab42f2c1 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3434,6 +3434,18 @@ int drm_mode_addfb2(struct drm_device *dev,
 	return 0;
 }
 
+struct drm_mode_rmfb_work {
+	struct work_struct work;
+	struct drm_framebuffer *fb;
+};
+
+static void drm_mode_rmfb_work_fn(struct work_struct *w)
+{
+	struct drm_mode_rmfb_work *arg = container_of(w, typeof(*arg), work);
+
+	drm_framebuffer_remove(arg->fb);
+}
+
 /**
  * drm_mode_rmfb - remove an FB from the configuration
  * @dev: drm device for the ioctl
@@ -3454,6 +3466,7 @@ int drm_mode_rmfb(struct drm_device *dev,
 	struct drm_framebuffer *fbl = NULL;
 	uint32_t *id = data;
 	int found = 0;
+	struct drm_mode_rmfb_work arg;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EINVAL;
@@ -3474,7 +3487,17 @@ int drm_mode_rmfb(struct drm_device *dev,
 	mutex_unlock(&dev->mode_config.fb_lock);
 	mutex_unlock(&file_priv->fbs_lock);
 
-	drm_framebuffer_unreference(fb);
+	/*
+	 * drm_framebuffer_remove may fail with -EINTR on pending signals,
+	 * so run this in a separate stack as there's no way to correctly
+	 * handle this after the fb is already removed from the lookup table.
+	 */
+	INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn);
+	arg.fb = fb;
+
+	schedule_work(&arg.work);
+	flush_work(&arg.work);
+	destroy_work_on_stack(&arg.work);
 
 	return 0;
 
-- 
2.1.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-05-05 11:51 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22  9:58 [PATCH] drm/core: Do not preserve framebuffer on rmfb, v2 Maarten Lankhorst
2016-03-22 11:35 ` ✗ Fi.CI.BAT: failure for " Patchwork
2016-03-31 11:26 ` [PATCH] drm/core: Do not preserve framebuffer on rmfb, v3 Maarten Lankhorst
2016-04-11  7:30   ` Maarten Lankhorst
2016-04-12 10:42   ` Daniel Vetter
2016-04-12 10:42     ` Daniel Vetter
2016-05-02  9:07     ` [REBASED PATCH] " Maarten Lankhorst
2016-05-02  9:07       ` Maarten Lankhorst
2016-05-03 12:01   ` [PATCH] " Thomas Hellstrom
2016-05-04 12:10     ` [PATCH i-g-t] tests/kms: Add test for testing rmfb framebuffer removal handling Maarten Lankhorst
2016-05-05  9:11       ` [Intel-gfx] " Tvrtko Ursulin
2016-05-05 11:50         ` Daniel Vetter
2016-05-04 12:38     ` [PATCH] drm/core: Do not preserve framebuffer on rmfb, v4 Maarten Lankhorst
2016-05-05  9:07       ` Tvrtko Ursulin
2016-05-05 11:51         ` [Intel-gfx] " Daniel Vetter

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.