Skip to contentSkip to conversation

drm/sti: do not sync legacy IOCTL on vblank if not ATOMIC

PATCH In review Fabien Dessenne 2 participants 9 messages Jan 3, 2017 – Jan 9, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/sti: do not sync legacy IOCTL on vblank if not ATOMIC

These patches allow a legacy framework (eg non-atomic Weston) to call several SETPLANE within the same Vsync cycle.
- [PATCH 1/5] drm/sti: use atomic_helper for commit
- [PATCH 2/5] drm/sti: add drm_file to sti_private
- [PATCH 3/5] drm/sti: do not sync SETPLANE on vblank if not ATOMIC
- [PATCH 4/5] drm/sti: do not sync SETPROPERTY on vblank if not ATOMIC
- [PATCH 5/5] drm/sti: do not check hw scaling if mode is not set

Fabien

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

#1 lore raw

PATCH 1/5 drm/sti: use atomic_helper for commit

Since nonblocking atomic commits are now supported, the driver can now use drm_atomic_helper_commit().

Change-Id I3e49872b0dc9e79ca652bec7e5cd29d912c86382
---
 drivers/gpu/drm/sti/sti_drv.c | 83 +------------------------------------------
 drivers/gpu/drm/sti/sti_drv.h |  6 ----
 2 files changed, 1 insertion(+), 88 deletions(-)
drivers/gpu/drm/sti/sti_drv.c +1 -82
index ff71e25..9a9b9a2 100644
@@ -150,52 +150,6 @@ static void sti_drm_dbg_cleanup(struct drm_minor *minor)
 				 1, minor);
 }
 
-static void sti_atomic_schedule(struct sti_private *private,
-				struct drm_atomic_state *state)
-{
-	private->commit.state = state;
-	schedule_work(&private->commit.work);
-}
-
-static void sti_atomic_complete(struct sti_private *private,
-				struct drm_atomic_state *state)
-{
-	struct drm_device *drm = private->drm_dev;
-
-	/*
-	 * Everything below can be run asynchronously without the need to grab
-	 * any modeset locks at all under one condition: It must be guaranteed
-	 * that the asynchronous work has either been cancelled (if the driver
-	 * supports it, which at least requires that the framebuffers get
-	 * cleaned up with drm_atomic_helper_cleanup_planes()) or completed
-	 * before the new state gets committed on the software side with
-	 * drm_atomic_helper_swap_state().
-	 *
-	 * This scheme allows new atomic state updates to be prepared and
-	 * checked in parallel to the asynchronous completion of the previous
-	 * update. Which is important since compositors need to figure out the
-	 * composition of the next frame right after having submitted the
-	 * current layout.
-	 */
-
-	drm_atomic_helper_commit_modeset_disables(drm, state);
-	drm_atomic_helper_commit_planes(drm, state, 0);
-	drm_atomic_helper_commit_modeset_enables(drm, state);
-
-	drm_atomic_helper_wait_for_vblanks(drm, state);
-
-	drm_atomic_helper_cleanup_planes(drm, state);
-	drm_atomic_state_put(state);
-}
-
-static void sti_atomic_work(struct work_struct *work)
-{
-	struct sti_private *private = container_of(work,
-			struct sti_private, commit.work);
-
-	sti_atomic_complete(private, private->commit.state);
-}
-
 static int sti_atomic_check(struct drm_device *dev,
 			    struct drm_atomic_state *state)
 {
@@ -216,38 +170,6 @@ static int sti_atomic_check(struct drm_device *dev,
 	return ret;
 }
 
-static int sti_atomic_commit(struct drm_device *drm,
-			     struct drm_atomic_state *state, bool nonblock)
-{
-	struct sti_private *private = drm->dev_private;
-	int err;
-
-	err = drm_atomic_helper_prepare_planes(drm, state);
-	if (err)
-		return err;
-
-	/* serialize outstanding nonblocking commits */
-	mutex_lock(&private->commit.lock);
-	flush_work(&private->commit.work);
-
-	/*
-	 * This is the point of no return - everything below never fails except
-	 * when the hw goes bonghits. Which means we can commit the new state on
-	 * the software side now.
-	 */
-
-	drm_atomic_helper_swap_state(state, true);
-
-	drm_atomic_state_get(state);
-	if (nonblock)
-		sti_atomic_schedule(private, state);
-	else
-		sti_atomic_complete(private, state);
-
-	mutex_unlock(&private->commit.lock);
-	return 0;
-}
-
 static void sti_output_poll_changed(struct drm_device *ddev)
 {
 	struct sti_private *private = ddev->dev_private;
@@ -271,7 +193,7 @@ static const struct drm_mode_config_funcs sti_mode_config_funcs = {
 	.fb_create = drm_fb_cma_create,
 	.output_poll_changed = sti_output_poll_changed,
 	.atomic_check = sti_atomic_check,
-	.atomic_commit = sti_atomic_commit,
+	.atomic_commit = drm_atomic_helper_commit,
 };
 
 static void sti_mode_config_init(struct drm_device *dev)
@@ -352,9 +274,6 @@ static int sti_init(struct drm_device *ddev)
 	dev_set_drvdata(ddev->dev, ddev);
 	private->drm_dev = ddev;
 
-	mutex_init(&private->commit.lock);
-	INIT_WORK(&private->commit.work, sti_atomic_work);
-
 	drm_mode_config_init(ddev);
 
 	sti_mode_config_init(ddev);
drivers/gpu/drm/sti/sti_drv.h +0 -6
index 78ebe5e..f9276cd 100644
@@ -25,12 +25,6 @@ struct sti_private {
 	struct drm_property *plane_zorder_property;
 	struct drm_device *drm_dev;
 	struct drm_fbdev_cma *fbdev;
-
-	struct {
-		struct drm_atomic_state *state;
-		struct work_struct work;
-		struct mutex lock;
-	} commit;
 };
 
 extern struct platform_driver sti_tvout_driver;
Signature · 6 lines
2.7.4

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

PATCH 2/5 drm/sti: add drm_file to sti_private

In reply to Fabien Dessenne

Store the drm_file *filp in sti_private, so the driver can access more configuration information like the client capabilities.

Change-Id Ib8f305f1a41b4fdfe56f80294cd79e5dc44433ee
---
 drivers/gpu/drm/sti/sti_drv.c | 10 ++++++++++
 drivers/gpu/drm/sti/sti_drv.h |  3 +++
 2 files changed, 13 insertions(+)
drivers/gpu/drm/sti/sti_drv.c +10 -0
index 9a9b9a2..63febf8 100644
@@ -170,6 +170,15 @@ static int sti_atomic_check(struct drm_device *dev,
 	return ret;
 }
 
+static int sti_drm_open(struct drm_device *ddev, struct drm_file *filp)
+{
+	struct sti_private *private = ddev->dev_private;
+
+	private->filp = filp;
+
+	return 0;
+}
+
 static void sti_output_poll_changed(struct drm_device *ddev)
 {
 	struct sti_private *private = ddev->dev_private;
@@ -226,6 +235,7 @@ static const struct file_operations sti_driver_fops = {
 static struct drm_driver sti_driver = {
 	.driver_features = DRIVER_MODESET |
 	    DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC,
+	.open = sti_drm_open,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
 	.gem_vm_ops = &drm_gem_cma_vm_ops,
 	.dumb_create = drm_gem_cma_dumb_create,
drivers/gpu/drm/sti/sti_drv.h +3 -0
index f9276cd..de22b0d 100644
@@ -19,12 +19,15 @@ struct sti_tvout;
  * @compo:                 compositor
  * @plane_zorder_property: z-order property for CRTC planes
  * @drm_dev:               drm device
+ * @fbdev:                 framebuffer dev cma struct
+ * @drm_file:              drm file private data
  */
 struct sti_private {
 	struct sti_compositor *compo;
 	struct drm_property *plane_zorder_property;
 	struct drm_device *drm_dev;
 	struct drm_fbdev_cma *fbdev;
+	struct drm_file *filp;
 };
 
 extern struct platform_driver sti_tvout_driver;
Signature · 6 lines
2.7.4

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

PATCH 3/5 drm/sti: do not sync SETPLANE on vblank if not ATOMIC

In reply to Fabien Dessenne

If the client does not set the ATOMIC capability, do not wait for vblank before returning an DRM_IOCTL_MODE_SETPLANE call.

In this way, a legacy framework (eg non-atomic Weston) can call several SETPLANE within the same Vsync cycle.

This is implemented by setting the legacy_cursor_update flag, to behave the same way as DRM_IOCTL_MODE_CURSOR (not vblank synced).

Change-Id Ia241b6c88411c675bf589c17d4a44db6d02f669f
---
 drivers/gpu/drm/sti/sti_cursor.c |   4 +-
 drivers/gpu/drm/sti/sti_gdp.c    |   4 +-
 drivers/gpu/drm/sti/sti_hqvdp.c  |   4 +-
 drivers/gpu/drm/sti/sti_plane.c  | 144 +++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/sti/sti_plane.h  |   8 +++
 5 files changed, 158 insertions(+), 6 deletions(-)
drivers/gpu/drm/sti/sti_cursor.c +2 -2
index cca75bd..ea0dbae 100644
@@ -346,8 +346,8 @@ static int sti_cursor_late_register(struct drm_plane *drm_plane)
 }
 
 static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
-	.update_plane = drm_atomic_helper_update_plane,
-	.disable_plane = drm_atomic_helper_disable_plane,
+	.update_plane = sti_plane_update_plane,
+	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_cursor_destroy,
 	.set_property = drm_atomic_helper_plane_set_property,
 	.reset = sti_plane_reset,
drivers/gpu/drm/sti/sti_gdp.c +2 -2
index 81df309..a379bbe 100644
@@ -882,8 +882,8 @@ static int sti_gdp_late_register(struct drm_plane *drm_plane)
 }
 
 static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
-	.update_plane = drm_atomic_helper_update_plane,
-	.disable_plane = drm_atomic_helper_disable_plane,
+	.update_plane = sti_plane_update_plane,
+	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_gdp_destroy,
 	.set_property = drm_atomic_helper_plane_set_property,
 	.reset = sti_plane_reset,
drivers/gpu/drm/sti/sti_hqvdp.c +2 -2
index f88130f..65ca43f 100644
@@ -1252,8 +1252,8 @@ static int sti_hqvdp_late_register(struct drm_plane *drm_plane)
 }
 
 static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = {
-	.update_plane = drm_atomic_helper_update_plane,
-	.disable_plane = drm_atomic_helper_disable_plane,
+	.update_plane = sti_plane_update_plane,
+	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_hqvdp_destroy,
 	.set_property = drm_atomic_helper_plane_set_property,
 	.reset = sti_plane_reset,
drivers/gpu/drm/sti/sti_plane.c +144 -0

153 lines not on this page · raw message

drivers/gpu/drm/sti/sti_plane.h +8 -0
index ce3e8d6..1372b9c 100644
@@ -83,4 +83,12 @@ void sti_plane_update_fps(struct sti_plane *plane,
 void sti_plane_init_property(struct sti_plane *plane,
 			     enum drm_plane_type type);
 void sti_plane_reset(struct drm_plane *plane);
+
+int sti_plane_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
+			   struct drm_framebuffer *fb,
+			   int crtc_x, int crtc_y,
+			   unsigned int crtc_w, unsigned int crtc_h,
+			   uint32_t src_x, uint32_t src_y,
+			   uint32_t src_w, uint32_t src_h);
+int sti_plane_disable_plane(struct drm_plane *plane);
 #endif
Signature · 6 lines
2.7.4

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

PATCH 4/5 drm/sti: do not sync SETPROPERTY on vblank if not ATOMIC

In reply to Fabien Dessenne

If the client does not set the ATOMIC capability, do not wait for vblank before returning an DRM_IOCTL_MODE_OBJ_SETPROPERTY call.

In this way, a legacy framework (eg non-atomic Weston) can call several SETPROPERTY within the same Vsync cycle.

This is implemented by setting the legacy_cursor_update flag, to behave the same way as DRM_IOCTL_MODE_CURSOR (not vblank synced).

Change-Id I6b6134eca57eca399bdda006ab1cb8280d4002d4
---
 drivers/gpu/drm/sti/sti_cursor.c |  2 +-
 drivers/gpu/drm/sti/sti_gdp.c    |  2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c  |  2 +-
 drivers/gpu/drm/sti/sti_plane.c  | 54 ++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/sti/sti_plane.h  |  2 ++
 5 files changed, 59 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_cursor.c +1 -1
index ea0dbae..d7e9f8a 100644
@@ -349,7 +349,7 @@ static const struct drm_plane_funcs sti_cursor_plane_helpers_funcs = {
 	.update_plane = sti_plane_update_plane,
 	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_cursor_destroy,
-	.set_property = drm_atomic_helper_plane_set_property,
+	.set_property = sti_plane_set_property,
 	.reset = sti_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
drivers/gpu/drm/sti/sti_gdp.c +1 -1
index a379bbe..6fa5042 100644
@@ -885,7 +885,7 @@ static const struct drm_plane_funcs sti_gdp_plane_helpers_funcs = {
 	.update_plane = sti_plane_update_plane,
 	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_gdp_destroy,
-	.set_property = drm_atomic_helper_plane_set_property,
+	.set_property = sti_plane_set_property,
 	.reset = sti_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
drivers/gpu/drm/sti/sti_hqvdp.c +1 -1
index 65ca43f..3fd6f3a 100644
@@ -1255,7 +1255,7 @@ static const struct drm_plane_funcs sti_hqvdp_plane_helpers_funcs = {
 	.update_plane = sti_plane_update_plane,
 	.disable_plane = sti_plane_disable_plane,
 	.destroy = sti_hqvdp_destroy,
-	.set_property = drm_atomic_helper_plane_set_property,
+	.set_property = sti_plane_set_property,
 	.reset = sti_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
drivers/gpu/drm/sti/sti_plane.c +54 -0

60 lines not on this page · raw message

drivers/gpu/drm/sti/sti_plane.h +2 -0
index 1372b9c..aa1b6ce 100644
@@ -82,6 +82,8 @@ void sti_plane_update_fps(struct sti_plane *plane,
 
 void sti_plane_init_property(struct sti_plane *plane,
 			     enum drm_plane_type type);
+int sti_plane_set_property(struct drm_plane *plane,
+			   struct drm_property *property, uint64_t val);
 void sti_plane_reset(struct drm_plane *plane);
 
 int sti_plane_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
Signature · 6 lines
2.7.4

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

PATCH 5/5 drm/sti: do not check hw scaling if mode is not set

In reply to Fabien Dessenne

Fix a division by 0 case : in some cases, when the HQVDP plane is being disabled atomic_check() is called with "mode->clock = 0".
In that case, do not check for scaling capabilities.

Change-Id I7fb752ab394211c3deafa149f52cfb2bca244e84
---
 drivers/gpu/drm/sti/sti_hqvdp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/sti/sti_hqvdp.c +3 -3
index 3fd6f3a..fe36e0f 100644
@@ -1035,9 +1035,9 @@ static int sti_hqvdp_atomic_check(struct drm_plane *drm_plane,
 	src_w = state->src_w >> 16;
 	src_h = state->src_h >> 16;
 
-	if (!sti_hqvdp_check_hw_scaling(hqvdp, mode,
-					src_w, src_h,
-					dst_w, dst_h)) {
+	if (mode->clock && !sti_hqvdp_check_hw_scaling(hqvdp, mode,
+						       src_w, src_h,
+						       dst_w, dst_h)) {
 		DRM_ERROR("Scaling beyond HW capabilities\n");
 		return -EINVAL;
 	}
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw
In reply to Fabien Dessenne
Quoted 7 lines · Fabien Dessenne

These patches allow a legacy framework (eg non-atomic Weston) to call several SETPLANE within the same Vsync cycle.
- [PATCH 1/5] drm/sti: use atomic_helper for commit
- [PATCH 2/5] drm/sti: add drm_file to sti_private
- [PATCH 3/5] drm/sti: do not sync SETPLANE on vblank if not ATOMIC
- [PATCH 4/5] drm/sti: do not sync SETPROPERTY on vblank if not ATOMIC
- [PATCH 5/5] drm/sti: do not check hw scaling if mode is not set

Upstream weston never really enabled plane support, why exactly do you need this? Also, if this really is required, I think we should implement something like this (aka async plane flips) in general for everyone. sti is by far not the only driver playing around with these games. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

Hi Daniel

I come to the conclusion that (only) Atomic Weston will solve all of my troubles, so let's forget these patches (and work for atomic weston).

By the way, is the expected behavior (Vblank - sync'ed or not) of drmModeSetPlane() described anywhere? The last time I browsed the related documentation I could not find the answer. Maybe something that needs to be clarified ?

I will also re-send patch 1 & 5 out of this abandoned series since they make sense independently of this (a)sync stuff.

BR.

Fabien

Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Fabien Dessenne

These patches allow a legacy framework (eg non-atomic Weston) to call several SETPLANE within the same Vsync cycle.
- [PATCH 1/5] drm/sti: use atomic_helper for commit
- [PATCH 2/5] drm/sti: add drm_file to sti_private
- [PATCH 3/5] drm/sti: do not sync SETPLANE on vblank if not ATOMIC
- [PATCH 4/5] drm/sti: do not sync SETPROPERTY on vblank if not ATOMIC
- [PATCH 5/5] drm/sti: do not check hw scaling if mode is not set

Quoted 5 lines

Upstream weston never really enabled plane support, why exactly do you need this? Also, if this really is required, I think we should implement something like this (aka async plane flips) in general for everyone. sti is by far not the only driver playing around with these games. -Daniel

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

#8 lore raw
Quoted 10 lines · Fabien DESSENNE

Hi Daniel

I come to the conclusion that (only) Atomic Weston will solve all of my troubles, so let's forget these patches (and work for atomic weston).

By the way, is the expected behavior (Vblank - sync'ed or not) of drmModeSetPlane() described anywhere? The last time I browsed the related documentation I could not find the answer. Maybe something that needs to be clarified ?

It's undefined and depends upon driver and platform and kernel version. And all the work is done already, we've taken all the lessons learned from legacy planes and made sure atomic sucks less ;-) There's no point in changing/clarifying legacy semantics, at worst you'll end up breaking more existing userspace. And we're not going to get uniform behaviour between all drivers anyway for the legacy interfaces. Imo not worth the trouble, let's just use atomic.
-Daniel

Quoted 24 lines

I will also re-send patch 1 & 5 out of this abandoned series since they make sense independently of this (a)sync stuff.

BR.

Fabien

Quoted 13 lines · Daniel Vetter
Quoted 7 lines · Fabien Dessenne

These patches allow a legacy framework (eg non-atomic Weston) to call several SETPLANE within the same Vsync cycle.
- [PATCH 1/5] drm/sti: use atomic_helper for commit
- [PATCH 2/5] drm/sti: add drm_file to sti_private
- [PATCH 3/5] drm/sti: do not sync SETPLANE on vblank if not ATOMIC
- [PATCH 4/5] drm/sti: do not sync SETPROPERTY on vblank if not ATOMIC
- [PATCH 5/5] drm/sti: do not check hw scaling if mode is not set

Upstream weston never really enabled plane support, why exactly do you need this? Also, if this really is required, I think we should implement something like this (aka async plane flips) in general for everyone. sti is by far not the only driver playing around with these games. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel