Skip to contentSkip to conversation

drm/atomic: Add a way to call remove_fb atomically, v2.

PATCH New Maarten Lankhorst 2 participants 5 messages May 9, 2016 – May 10, 2016

Subsystems (3)
lore
Share & tools
lore

Maarten Lankhorst

author maintainer
#0 lore raw

PATCH 1/2 drm/atomic: Add a way to call remove_fb atomically, v2.

Use this in drm_framebuffer_remove, this is to remove the fb in an atomic way.

i915 doesn't export DRIVER_ATOMIC yet by default but is atomic, so add a function pointer to allow drivers to use the atomic framebuffer remove.

Changes since v1:
- Move the atomic framebuffer removal function from helpers to atomic core.
- Only override rmfb for i915, for atomic drivers it defaults to atomic rmfb.

---
 drivers/gpu/drm/drm_atomic.c    | 67 +++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc.c      | 65 ++++++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 include/drm/drmP.h              |  3 ++
 include/drm/drm_atomic.h        |  1 +
 5 files changed, 116 insertions(+), 21 deletions(-)
drivers/gpu/drm/drm_atomic.c +67 -0
index 86e89db02ed7..5a54d9e2d938 100644
@@ -1741,3 +1741,70 @@ out:
 
 	return ret;
 }
+
+int drm_atomic_remove_fb(struct drm_framebuffer *fb)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_device *dev = fb->dev;
+	struct drm_atomic_state *state;
+	struct drm_plane *plane;
+	int ret = 0;
+	unsigned plane_mask;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return -ENOMEM;
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->acquire_ctx = &ctx;
+
+retry:
+	plane_mask = 0;
+	ret = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (ret)
+		goto unlock;
+
+	drm_for_each_plane(plane, dev) {
+		struct drm_plane_state *plane_state;
+
+		if (plane->state->fb != fb)
+			continue;
+
+		plane_state = drm_atomic_get_plane_state(state, plane);
+		if (IS_ERR(plane_state)) {
+			ret = PTR_ERR(plane_state);
+			goto unlock;
+		}
+
+		drm_atomic_set_fb_for_plane(plane_state, NULL);
+		ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
+		if (ret)
+			goto unlock;
+
+		plane_mask |= BIT(drm_plane_index(plane));
+
+		plane->old_fb = plane->fb;
+		plane->fb = NULL;
+	}
+
+	if (plane_mask)
+		ret = drm_atomic_commit(state);
+
+unlock:
+	if (plane_mask)
+		drm_atomic_clean_old_fb(dev, plane_mask, ret);
+
+	if (ret == -EDEADLK) {
+		drm_modeset_backoff(&ctx);
+		goto retry;
+	}
+
+	if (ret || !plane_mask)
+		drm_atomic_state_free(state);
+
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+
+	return ret;
+}
+EXPORT_SYMBOL(drm_atomic_remove_fb);
drivers/gpu/drm/drm_crtc.c +44 -21

84 lines not on this page · raw message

drivers/gpu/drm/i915/i915_drv.c +1 -0
index 9fd221c97275..8736d15e8848 100644
@@ -1724,6 +1724,7 @@ static struct drm_driver driver = {
 	.dumb_create = i915_gem_dumb_create,
 	.dumb_map_offset = i915_gem_mmap_gtt,
 	.dumb_destroy = drm_gem_dumb_destroy,
+	.remove_fb = drm_atomic_remove_fb,
 	.ioctls = i915_ioctls,
 	.fops = &i915_driver_fops,
 	.name = DRIVER_NAME,
include/drm/drmP.h +3 -0
index 360b2a74e1ef..d63791039387 100644
@@ -647,6 +647,9 @@ struct drm_driver {
 			    struct drm_device *dev,
 			    uint32_t handle);
 
+	/* rmfb and drm_framebuffer_remove hook */
+	int (*remove_fb)(struct drm_framebuffer *fb);
+
 	/* Driver private ops for this object */
 	const struct vm_operations_struct *gem_vm_ops;
 
include/drm/drm_atomic.h +1 -0
index 92c84e9ab09a..0a04314534a5 100644
@@ -138,6 +138,7 @@ drm_atomic_clean_old_fb(struct drm_device *dev, unsigned plane_mask, int ret);
 int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
 int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
+int __must_check drm_atomic_remove_fb(struct drm_framebuffer *fb);
 
 #define for_each_connector_in_state(state, connector, connector_state, __i) \
 	for ((__i) = 0;							\
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author maintainer
#1 lore raw

PATCH 1/2 drm/atomic: Add a way to call remove_fb atomically, v2.

Use this in drm_framebuffer_remove, this is to remove the fb in an atomic way.

i915 doesn't export DRIVER_ATOMIC yet by default but is atomic, so add a function pointer to allow drivers to use the atomic framebuffer remove.

Changes since v1:
- Move the atomic framebuffer removal function from helpers to atomic core.
- Only override rmfb for i915, for atomic drivers it defaults to atomic rmfb.

---
 drivers/gpu/drm/drm_atomic.c    | 67 +++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_crtc.c      | 65 ++++++++++++++++++++++++++-------------
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 include/drm/drmP.h              |  3 ++
 include/drm/drm_atomic.h        |  1 +
 5 files changed, 116 insertions(+), 21 deletions(-)
drivers/gpu/drm/drm_atomic.c +67 -0
index 86e89db02ed7..5a54d9e2d938 100644
@@ -1741,3 +1741,70 @@ out:
 
 	return ret;
 }
+
+int drm_atomic_remove_fb(struct drm_framebuffer *fb)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_device *dev = fb->dev;
+	struct drm_atomic_state *state;
+	struct drm_plane *plane;
+	int ret = 0;
+	unsigned plane_mask;
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state)
+		return -ENOMEM;
+
+	drm_modeset_acquire_init(&ctx, 0);
+	state->acquire_ctx = &ctx;
+
+retry:
+	plane_mask = 0;
+	ret = drm_modeset_lock_all_ctx(dev, &ctx);
+	if (ret)
+		goto unlock;
+
+	drm_for_each_plane(plane, dev) {
+		struct drm_plane_state *plane_state;
+
+		if (plane->state->fb != fb)
+			continue;
+
+		plane_state = drm_atomic_get_plane_state(state, plane);
+		if (IS_ERR(plane_state)) {
+			ret = PTR_ERR(plane_state);
+			goto unlock;
+		}
+
+		drm_atomic_set_fb_for_plane(plane_state, NULL);
+		ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
+		if (ret)
+			goto unlock;
+
+		plane_mask |= BIT(drm_plane_index(plane));
+
+		plane->old_fb = plane->fb;
+		plane->fb = NULL;
+	}
+
+	if (plane_mask)
+		ret = drm_atomic_commit(state);
+
+unlock:
+	if (plane_mask)
+		drm_atomic_clean_old_fb(dev, plane_mask, ret);
+
+	if (ret == -EDEADLK) {
+		drm_modeset_backoff(&ctx);
+		goto retry;
+	}
+
+	if (ret || !plane_mask)
+		drm_atomic_state_free(state);
+
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+
+	return ret;
+}
+EXPORT_SYMBOL(drm_atomic_remove_fb);
drivers/gpu/drm/drm_crtc.c +44 -21

84 lines not on this page · raw message

drivers/gpu/drm/i915/i915_drv.c +1 -0
index 9fd221c97275..8736d15e8848 100644
@@ -1724,6 +1724,7 @@ static struct drm_driver driver = {
 	.dumb_create = i915_gem_dumb_create,
 	.dumb_map_offset = i915_gem_mmap_gtt,
 	.dumb_destroy = drm_gem_dumb_destroy,
+	.remove_fb = drm_atomic_remove_fb,
 	.ioctls = i915_ioctls,
 	.fops = &i915_driver_fops,
 	.name = DRIVER_NAME,
include/drm/drmP.h +3 -0
index 360b2a74e1ef..d63791039387 100644
@@ -647,6 +647,9 @@ struct drm_driver {
 			    struct drm_device *dev,
 			    uint32_t handle);
 
+	/* rmfb and drm_framebuffer_remove hook */
+	int (*remove_fb)(struct drm_framebuffer *fb);
+
 	/* Driver private ops for this object */
 	const struct vm_operations_struct *gem_vm_ops;
 
include/drm/drm_atomic.h +1 -0
index 92c84e9ab09a..0a04314534a5 100644
@@ -138,6 +138,7 @@ drm_atomic_clean_old_fb(struct drm_device *dev, unsigned plane_mask, int ret);
 int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
 int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
+int __must_check drm_atomic_remove_fb(struct drm_framebuffer *fb);
 
 #define for_each_connector_in_state(state, connector, connector_state, __i) \
 	for ((__i) = 0;							\
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author maintainer
#2 lore raw

PATCH 2/2 Reapply "drm/atomic: Call ww_acquire_done after check phase is complete"

In reply to Maarten Lankhorst

This reapplies commit 992cbf19b32900efa17850b9fa0031fd623edd4d. With atomic drm_framebuffer_remove and the fbdev emulation layer atomic this should be safe to apply again.

---
 drivers/gpu/drm/drm_atomic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_atomic.c +3 -0
index 5a54d9e2d938..d619a756587c 100644
@@ -1358,6 +1358,9 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
 		}
 	}
 
+	if (ret == 0)
+		ww_acquire_done(&state->acquire_ctx->ww_ctx);
+
 	return ret;
 }
 EXPORT_SYMBOL(drm_atomic_check_only);
Signature · 6 lines
2.5.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author maintainer
#3 lore raw

PATCH 2/2 Reapply "drm/atomic: Call ww_acquire_done after check phase is complete"

In reply to Maarten Lankhorst

This reapplies commit 992cbf19b32900efa17850b9fa0031fd623edd4d. With atomic drm_framebuffer_remove and the fbdev emulation layer atomic this should be safe to apply again.

---
 drivers/gpu/drm/drm_atomic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_atomic.c +3 -0
index 5a54d9e2d938..d619a756587c 100644
@@ -1358,6 +1358,9 @@ int drm_atomic_check_only(struct drm_atomic_state *state)
 		}
 	}
 
+	if (ret == 0)
+		ww_acquire_done(&state->acquire_ctx->ww_ctx);
+
 	return ret;
 }
 EXPORT_SYMBOL(drm_atomic_check_only);
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

✗ Fi.CI.BAT: failure for series starting with [1/2] drm/atomic: Add a way to call remove_fb atomically, v2.

In reply to Maarten Lankhorst
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/atomic: Add a way to call remove_fb atomically, v2.
URL : https://patchwork.freedesktop.org/series/6906/
State : failure

== Summary ==

Series 6906v1 Series without cover letter
http://patchwork.freedesktop.org/api/1.0/series/6906/revisions/1/mbox/

Test drv_getparams_basic:

        Subgroup basic-eu-total:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-subslice-total:
                pass       -> SKIP       (skl-nuci5)
Test drv_hangman:
        Subgroup error-state-basic:
                pass       -> SKIP       (skl-nuci5)
                pass       -> DMESG-WARN (bdw-ultra)
Test drv_module_reload_basic:
                dmesg-warn -> PASS       (bsw-nuc-2)
                pass       -> DMESG-WARN (bdw-nuci7-2)
                pass       -> TIMEOUT    (skl-nuci5)
                pass       -> DMESG-WARN (bdw-ultra)
Test gem_basic:
        Subgroup bad-close:
                pass       -> SKIP       (skl-nuci5)
        Subgroup create-close:
                pass       -> SKIP       (skl-nuci5)
        Subgroup create-fd-close:
                pass       -> SKIP       (skl-nuci5)
Test gem_busy:
        Subgroup basic-blt:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-bsd:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-bsd1:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-bsd2:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-parallel-blt:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-parallel-bsd:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-parallel-bsd1:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-parallel-bsd2:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-parallel-render:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-parallel-vebox:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-render:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-vebox:
                pass       -> SKIP       (skl-nuci5)
Test gem_close_race:
        Subgroup basic-process:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-threads:
                pass       -> SKIP       (skl-nuci5)
Test gem_cs_tlb:
        Subgroup basic-default:
                pass       -> SKIP       (skl-nuci5)
Test gem_ctx_exec:
        Subgroup basic:
                pass       -> SKIP       (skl-nuci5)
Test gem_ctx_param:
        Subgroup basic:
                pass       -> SKIP       (skl-nuci5)
        Subgroup basic-default:
                pass       -> SKIP       (skl-nuci5)
Test gem_exec_basic:
        Subgroup basic-blt:
                pass       -> FAIL       (skl-nuci5)
        Subgroup basic-bsd:
                pass       -> FAIL       (skl-nuci5)
        Subgroup basic-bsd1:
                pass       -> FAIL       (skl-nuci5)
        Subgroup basic-bsd2:
                pass       -> FAIL       (skl-nuci5)
        Subgroup basic-default:
                pass       -> FAIL       (skl-nuci5)
        Subgroup basic-render:
                pass       -> FAIL       (skl-nuci5)
        Subgroup basic-vebox:
                pass       -> FAIL       (skl-nuci5)
        Subgroup gtt-blt:
                pass       -> FAIL       (skl-nuci5)
        Subgroup gtt-bsd:
                pass       -> FAIL       (skl-nuci5)
        Subgroup gtt-bsd1:
                pass       -> FAIL       (skl-nuci5)
        Subgroup gtt-bsd2:
                pass       -> FAIL       (skl-nuci5)
        Subgroup gtt-default:
                pass       -> FAIL       (skl-nuci5)
        Subgroup gtt-render:
                pass       -> FAIL       (skl-nuci5)
        Subgroup gtt-vebox:
                pass       -> FAIL       (skl-nuci5)
        Subgroup readonly-blt:
                pass       -> FAIL       (skl-nuci5)
        Subgroup readonly-bsd:
                pass       -> FAIL       (skl-nuci5)
        Subgroup readonly-bsd1:
                pass       -> FAIL       (skl-nuci5)

WARNING: Long output truncated
hsw-gt2 failed to connect after reboot

Results at /archive/results/CI_IGT_test/Patchwork_2160/

61f856faa1e6ff9dddad214be1e372e8aacfc0f4 drm-intel-nightly: 2016y-05m-09d-16h-24m-01s UTC integration manifest 44108e4 Reapply "drm/atomic: Call ww_acquire_done after check phase is complete"
4265128 drm/atomic: Add a way to call remove_fb atomically, v2.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx