Skip to contentSkip to conversation

drm/vc4: Add support for the transposer IP

PATCH Superseded Boris Brezillon 4 participants 36 messages Jun 29, 2018 – Jul 2, 2018

Subsystems (6)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover drm/vc4: Add support for the transposer IP

Hello,

This is the second version of this series adding writeback support to the VC4 display engine.

This version is based on drm-misc-next and include a bunch of modifications to core that I had to add to make it work on VC4.

Feel free to comment on those modifications.

On the driver side, no much has changed except I modified a bit the implementation to adjust the latest revision of the writeback interface.

Regards,

Boris

Boris Brezillon (8):
drm/atomic: Avoid connector to writeback_connector casts drm/connector: Pass a drm_connector_state to ->atomic_commit() drm/vc4: Use wait_for_flip_done() instead of wait_for_vblanks() drm/crtc: Add a generic infrastructure to fake VBLANK events drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic
commit_tail() helpers
drm/vc4: Call drm_atomic_helper_fake_vblank() in the commit path drm/vc4: Add support for the transposer block
ARM: dts: bcm283x: Add Transposer block

 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |   6 +
 arch/arm/boot/dts/bcm283x.dtsi                     |   6 +
 drivers/gpu/drm/drm_atomic.c                       |   4 +-
 drivers/gpu/drm/drm_atomic_helper.c                |  46 +-
 drivers/gpu/drm/vc4/Makefile                       |   1 +
 drivers/gpu/drm/vc4/vc4_crtc.c                     | 139 +++++-
 drivers/gpu/drm/vc4/vc4_debugfs.c                  |   1 +
 drivers/gpu/drm/vc4/vc4_drv.c                      |   1 +
 drivers/gpu/drm/vc4/vc4_drv.h                      |   7 +
 drivers/gpu/drm/vc4/vc4_kms.c                      |  11 +-
 drivers/gpu/drm/vc4/vc4_regs.h                     |   1 +
 drivers/gpu/drm/vc4/vc4_txp.c                      | 487 +++++++++++++++++++++
 include/drm/drm_atomic_helper.h                    |   1 +
 include/drm/drm_crtc.h                             |  15 +
 include/drm/drm_modeset_helper_vtables.h           |   4 +-
 include/drm/drm_writeback.h                        |   6 +
 16 files changed, 700 insertions(+), 36 deletions(-)
 create mode 100644 drivers/gpu/drm/vc4/vc4_txp.c
Signature · 6 lines
2.14.1

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

PATCH v2 1/8 drm/atomic: Avoid connector to writeback_connector casts

Use container_of() instead of type casting so that it keeps working even if base is moved inside the drm_writeback_connector struct.

---
 drivers/gpu/drm/drm_atomic.c | 4 +++-
 include/drm/drm_writeback.h  | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +3 -1
index 178842380f75..6ea20d5dee66 100644
@@ -2423,6 +2423,7 @@ static int prepare_signaling(struct drm_device *dev,
 	}
 
 	for_each_new_connector_in_state(state, conn, conn_state, i) {
+		struct drm_writeback_connector *wb_conn;
 		struct drm_writeback_job *job;
 		struct drm_out_fence_state *f;
 		struct dma_fence *fence;
@@ -2446,7 +2447,8 @@ static int prepare_signaling(struct drm_device *dev,
 		f[*num_fences].out_fence_ptr = fence_ptr;
 		*fence_state = f;
 
-		fence = drm_writeback_get_out_fence((struct drm_writeback_connector *)conn);
+		wb_conn = drm_connector_to_writeback(conn);
+		fence = drm_writeback_get_out_fence(wb_conn);
 		if (!fence)
 			return -ENOMEM;
 
include/drm/drm_writeback.h +6 -0
index a10fe556dfd4..23df9d463003 100644
@@ -110,6 +110,12 @@ struct drm_writeback_job {
 	struct dma_fence *out_fence;
 };
 
+static inline struct drm_writeback_connector *
+drm_connector_to_writeback(struct drm_connector *connector)
+{
+	return container_of(connector, struct drm_writeback_connector, base);
+}
+
 int drm_writeback_connector_init(struct drm_device *dev,
 				 struct drm_writeback_connector *wb_connector,
 				 const struct drm_connector_funcs *con_funcs,
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 1/8
#2 lore raw

Re: [PATCH v2 1/8] drm/atomic: Avoid connector to writeback_connector casts

Quoted 4 lines · Boris Brezillon

Use container_of() instead of type casting so that it keeps working even if base is moved inside the drm_writeback_connector struct.

Quoted 47 lines
---
 drivers/gpu/drm/drm_atomic.c | 4 +++-
 include/drm/drm_writeback.h  | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +3 -1
index 178842380f75..6ea20d5dee66 100644
@@ -2423,6 +2423,7 @@ static int prepare_signaling(struct drm_device *dev,
 	}
 
 	for_each_new_connector_in_state(state, conn, conn_state, i) {
+		struct drm_writeback_connector *wb_conn;
 		struct drm_writeback_job *job;
 		struct drm_out_fence_state *f;
 		struct dma_fence *fence;
@@ -2446,7 +2447,8 @@ static int prepare_signaling(struct drm_device *dev,
 		f[*num_fences].out_fence_ptr = fence_ptr;
 		*fence_state = f;
 
-		fence = drm_writeback_get_out_fence((struct drm_writeback_connector *)conn);
+		wb_conn = drm_connector_to_writeback(conn);
+		fence = drm_writeback_get_out_fence(wb_conn);
 		if (!fence)
 			return -ENOMEM;
 
include/drm/drm_writeback.h +6 -0
index a10fe556dfd4..23df9d463003 100644
@@ -110,6 +110,12 @@ struct drm_writeback_job {
 	struct dma_fence *out_fence;
 };
 
+static inline struct drm_writeback_connector *
+drm_connector_to_writeback(struct drm_connector *connector)
+{
+	return container_of(connector, struct drm_writeback_connector, base);
+}
+
 int drm_writeback_connector_init(struct drm_device *dev,
 				 struct drm_writeback_connector *wb_connector,
 				 const struct drm_connector_funcs *con_funcs,
Signature · 1 line
2.14.1
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
#3 lore raw

PATCH v2 2/8 drm/connector: Pass a drm_connector_state to ->atomic_commit()

In reply to Boris Brezillon

Other atomic hooks are passed state objects, let's change this one to be consistent.

---
 drivers/gpu/drm/drm_atomic_helper.c      | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +1 -1
index 17baf5057132..69063bcf2334 100644
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,
 
 		if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {
 			WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK);
-			funcs->atomic_commit(connector, new_conn_state->writeback_job);
+			funcs->atomic_commit(connector, new_conn_state);
 		}
 	}
 }
include/drm/drm_modeset_helper_vtables.h +3 -1
index 3b289773297c..fb841f44949c 100644
@@ -980,11 +980,13 @@ struct drm_connector_helper_funcs {
 	 *
 	 * This hook is to be used by drivers implementing writeback connectors
 	 * that need a point when to commit the writeback job to the hardware.
+	 * The writeback_job to commit is available in
+	 * &drm_connector_state.writeback_job.
 	 *
 	 * This callback is used by the atomic modeset helpers.
 	 */
 	void (*atomic_commit)(struct drm_connector *connector,
-			      struct drm_writeback_job *writeback_job);
+			      struct drm_connector_state *state);
 };
 
 /**
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v2 2/8
#4 lore raw

Re: [PATCH v2 2/8] drm/connector: Pass a drm_connector_state to ->atomic_commit()

Quoted 4 lines · Boris Brezillon

Other atomic hooks are passed state objects, let's change this one to be consistent.

Quoted 40 lines
---
 drivers/gpu/drm/drm_atomic_helper.c      | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +1 -1
index 17baf5057132..69063bcf2334 100644
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,
 
 		if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {
 			WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK);
-			funcs->atomic_commit(connector, new_conn_state->writeback_job);
+			funcs->atomic_commit(connector, new_conn_state);
 		}
 	}
 }
include/drm/drm_modeset_helper_vtables.h +3 -1
index 3b289773297c..fb841f44949c 100644
@@ -980,11 +980,13 @@ struct drm_connector_helper_funcs {
 	 *
 	 * This hook is to be used by drivers implementing writeback connectors
 	 * that need a point when to commit the writeback job to the hardware.
+	 * The writeback_job to commit is available in
+	 * &drm_connector_state.writeback_job.
 	 *
 	 * This callback is used by the atomic modeset helpers.
 	 */
 	void (*atomic_commit)(struct drm_connector *connector,
-			      struct drm_writeback_job *writeback_job);
+			      struct drm_connector_state *state);
 };
 
 /**
Signature · 1 line
2.14.1
Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [PATCH v2 2/8] drm/connector: Pass a drm_connector_state to ->atomic_commit()

In reply to Boris Brezillon
Quoted 14 lines · Boris Brezillon

Other atomic hooks are passed state objects, let's change this one to be consistent.

---
 drivers/gpu/drm/drm_atomic_helper.c      | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 17baf5057132..69063bcf2334 100644

drivers/gpu/drm/drm_atomic_helper.c static void drm_atomic_helper_commit_writebacks(struct drm_device *dev, · line 1190

Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,
 
 		if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {
 			WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK);
-			funcs->atomic_commit(connector, new_conn_state->writeback_job);
+			funcs->atomic_commit(connector, new_conn_state);

Forgot to add: I think it is worth adding a check here that the hook has been implemented by the driver, AFAIK it is not a mandatory hook, even for writeback enabled drivers.

Let me know what you plan to do with this patch as I will have to update the malidp patches as well, otherwise linux-next is going to flag me.

Best regards,
Liviu

Quoted 25 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
 		}
 	}
 }
include/drm/drm_modeset_helper_vtables.h +3 -1
index 3b289773297c..fb841f44949c 100644
@@ -980,11 +980,13 @@ struct drm_connector_helper_funcs {
 	 *
 	 * This hook is to be used by drivers implementing writeback connectors
 	 * that need a point when to commit the writeback job to the hardware.
+	 * The writeback_job to commit is available in
+	 * &drm_connector_state.writeback_job.
 	 *
 	 * This callback is used by the atomic modeset helpers.
 	 */
 	void (*atomic_commit)(struct drm_connector *connector,
-			      struct drm_writeback_job *writeback_job);
+			      struct drm_connector_state *state);
 };
 
 /**
Signature · 1 line
2.14.1
Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by
#6 lore raw

Re: [PATCH v2 2/8] drm/connector: Pass a drm_connector_state to ->atomic_commit()

Quoted 16 lines · Liviu Dudau
Quoted 15 lines · Boris Brezillon

Other atomic hooks are passed state objects, let's change this one to be consistent.

---
 drivers/gpu/drm/drm_atomic_helper.c      | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 17baf5057132..69063bcf2334 100644
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,
 
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c static void drm_atomic_helper_commit_writebacks(struct drm_device *dev, · line 1190

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
 		if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {
 			WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK);
-			funcs->atomic_commit(connector, new_conn_state->writeback_job);
+			funcs->atomic_commit(connector, new_conn_state);

Forgot to add: I think it is worth adding a check here that the hook has been implemented by the driver, AFAIK it is not a mandatory hook, even for writeback enabled drivers.

Either way this should be documented in the hook (atm it says nothing about whether it's mandatory/optional and for whom).

Quoted 3 lines

Let me know what you plan to do with this patch as I will have to update the malidp patches as well, otherwise linux-next is going to flag me.

Probably simplest if you send a pull to Dave right away with the current malidp code, then we backmerge that into drm-misc-next, and Boris rebases. There's no point in hanging onto pull requests until right before the feature freeze, just makes things more complicated.

Patch itself lgtm.

Quoted 39 lines

Best regards,
Liviu

Quoted 25 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
 		}
 	}
 }
include/drm/drm_modeset_helper_vtables.h +3 -1
index 3b289773297c..fb841f44949c 100644
@@ -980,11 +980,13 @@ struct drm_connector_helper_funcs {
 	 *
 	 * This hook is to be used by drivers implementing writeback connectors
 	 * that need a point when to commit the writeback job to the hardware.
+	 * The writeback_job to commit is available in
+	 * &drm_connector_state.writeback_job.
 	 *
 	 * This callback is used by the atomic modeset helpers.
 	 */
 	void (*atomic_commit)(struct drm_connector *connector,
-			      struct drm_writeback_job *writeback_job);
+			      struct drm_connector_state *state);
 };
 
 /**
Signature · 1 line
2.14.1
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
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

Re: [PATCH v2 2/8] drm/connector: Pass a drm_connector_state to ->atomic_commit()

Quoted 17 lines · On Mon, 2 Jul 2018 09:51:46 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 16 lines · Liviu Dudau
Quoted 15 lines · Boris Brezillon

Other atomic hooks are passed state objects, let's change this one to be consistent.

---
 drivers/gpu/drm/drm_atomic_helper.c      | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 17baf5057132..69063bcf2334 100644
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,
 
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c static void drm_atomic_helper_commit_writebacks(struct drm_device *dev, · line 1190

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
 		if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {
 			WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK);
-			funcs->atomic_commit(connector, new_conn_state->writeback_job);
+			funcs->atomic_commit(connector, new_conn_state);  

Forgot to add: I think it is worth adding a check here that the hook has been implemented by the driver, AFAIK it is not a mandatory hook, even for writeback enabled drivers.

I'm just curious, from where do you queue the writeback job if you don't have a connector->atomic_commit() hook implemented? AFAICT, the encoder->enable() method is only called when the encoder is being enabled, and not every time you update the FB_ID prop of the writeback connector. Am I missing something?

Quoted 3 lines

Either way this should be documented in the hook (atm it says nothing about whether it's mandatory/optional and for whom).

I'm fine making this hook optional. I'll update the code and the doc in a separate commit.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Re: [PATCH v2 2/8] drm/connector: Pass a drm_connector_state to ->atomic_commit()

Quoted 29 lines · Boris Brezillon
Quoted 17 lines · On Mon, 2 Jul 2018 09:51:46 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 16 lines · Liviu Dudau
Quoted 15 lines · Boris Brezillon

Other atomic hooks are passed state objects, let's change this one to be consistent.

---
 drivers/gpu/drm/drm_atomic_helper.c      | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 17baf5057132..69063bcf2334 100644
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,
 
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c static void drm_atomic_helper_commit_writebacks(struct drm_device *dev, · line 1190

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
 		if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {
 			WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK);
-			funcs->atomic_commit(connector, new_conn_state->writeback_job);
+			funcs->atomic_commit(connector, new_conn_state);  

Forgot to add: I think it is worth adding a check here that the hook has been implemented by the driver, AFAIK it is not a mandatory hook, even for writeback enabled drivers.

Quoted 5 lines

I'm just curious, from where do you queue the writeback job if you don't have a connector->atomic_commit() hook implemented? AFAICT, the encoder->enable() method is only called when the encoder is being enabled, and not every time you update the FB_ID prop of the writeback connector. Am I missing something?

In malidp_drv.c:malidp_atomic_commit_tail() we call malidp_mw_atomic_commit() after drm_atomic_helper_commit_planes(drm, state, DRM_PLANE_COMMIT_ACTIVE_ONLY).

malidp_mw_atomic_commit() then checks the writeback job and if it has an fb associated with it then it calls drm_writeback_queue_job() before enabling the memwrite hardware bits.

You can see it all in action here:

https://github.com/ARM-software/linux/commit/f7a88ca52530958703bcfc30adc302841ac89989

Best regards,
Liviu

Quoted 7 lines
Quoted 4 lines

Either way this should be documented in the hook (atm it says nothing about whether it's mandatory/optional and for whom).

I'm fine making this hook optional. I'll update the code and the doc in a separate commit.

Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [PATCH v2 2/8] drm/connector: Pass a drm_connector_state to ->atomic_commit()

Quoted 36 lines · On Mon, 2 Jul 2018 12:14:20 +0100 Liviu Dudau <[email protected]> wrote:
Quoted 29 lines · Boris Brezillon
Quoted 17 lines · On Mon, 2 Jul 2018 09:51:46 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 16 lines · Liviu Dudau
Quoted 15 lines · Boris Brezillon

Other atomic hooks are passed state objects, let's change this one to be consistent.

---
 drivers/gpu/drm/drm_atomic_helper.c      | 2 +-
 include/drm/drm_modeset_helper_vtables.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +0 -0
index 17baf5057132..69063bcf2334 100644
@@ -1187,7 +1187,7 @@ static void drm_atomic_helper_commit_writebacks(struct drm_device *dev,
 
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c static void drm_atomic_helper_commit_writebacks(struct drm_device *dev, · line 1190

Quoted 4 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
 		if (new_conn_state->writeback_job && new_conn_state->writeback_job->fb) {
 			WARN_ON(connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK);
-			funcs->atomic_commit(connector, new_conn_state->writeback_job);
+			funcs->atomic_commit(connector, new_conn_state);    

Forgot to add: I think it is worth adding a check here that the hook has been implemented by the driver, AFAIK it is not a mandatory hook, even for writeback enabled drivers.

Quoted 5 lines

I'm just curious, from where do you queue the writeback job if you don't have a connector->atomic_commit() hook implemented? AFAICT, the encoder->enable() method is only called when the encoder is being enabled, and not every time you update the FB_ID prop of the writeback connector. Am I missing something?

Quoted 7 lines

In malidp_drv.c:malidp_atomic_commit_tail() we call malidp_mw_atomic_commit() after drm_atomic_helper_commit_planes(drm, state, DRM_PLANE_COMMIT_ACTIVE_ONLY).

malidp_mw_atomic_commit() then checks the writeback job and if it has an fb associated with it then it calls drm_writeback_queue_job() before enabling the memwrite hardware bits.

Okay. That's a good reason to make it optional.

Thanks,

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

#10 lore raw

PATCH v2 3/8 drm/vc4: Use wait_for_flip_done() instead of wait_for_vblanks()

In reply to Boris Brezillon

drm_atomic_helper_wait_for_vblanks() assumes the CRTC will continuously generate VBLANK events and the vblank counter will keep increasing. While this work for a regular pipeline, it doesn't when you have the CRTC is feeding the transposer block, because this block works in oneshot mode, and, by the time we reach drm_atomic_helper_wait_for_vblanks() the only VBLANK event might have already been sent and the VBLANK counter will stay unchanged, thus triggering a timeout.

Luckily, we can replace the drm_atomic_helper_wait_for_vblanks() call by drm_atomic_helper_wait_for_flip_done() because the only thing we want to check when calling drm_atomic_helper_wait_for_vblanks() from vc4_atomic_complete_commit() is that new FBs are in use and the old ones can be safely released.

---
 drivers/gpu/drm/vc4/vc4_kms.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/vc4/vc4_kms.c +1 -10
index 8a411e5f8776..91239b0a4fa0 100644
@@ -153,18 +153,9 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
-	/* Make sure that drm_atomic_helper_wait_for_vblanks()
-	 * actually waits for vblank.  If we're doing a full atomic
-	 * modeset (as opposed to a vc4_update_plane() short circuit),
-	 * then we need to wait for scanout to be done with our
-	 * display lists before we free it and potentially reallocate
-	 * and overwrite the dlist memory with a new modeset.
-	 */
-	state->legacy_cursor_update = false;
-
 	drm_atomic_helper_commit_hw_done(state);
 
-	drm_atomic_helper_wait_for_vblanks(dev, state);
+	drm_atomic_helper_wait_for_flip_done(dev, state);
 
 	drm_atomic_helper_cleanup_planes(dev, state);
 
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 3/8
#11 lore raw

Re: [PATCH v2 3/8] drm/vc4: Use wait_for_flip_done() instead of wait_for_vblanks()

Quoted 9 lines · Boris Brezillon

drm_atomic_helper_wait_for_vblanks() assumes the CRTC will continuously generate VBLANK events and the vblank counter will keep increasing. While this work for a regular pipeline, it doesn't when you have the CRTC is feeding the transposer block, because this block works in oneshot mode, and, by the time we reach drm_atomic_helper_wait_for_vblanks() the only VBLANK event might have already been sent and the VBLANK counter will stay unchanged, thus triggering a timeout.

Quoted 7 lines

Luckily, we can replace the drm_atomic_helper_wait_for_vblanks() call by drm_atomic_helper_wait_for_flip_done() because the only thing we want to check when calling drm_atomic_helper_wait_for_vblanks() from vc4_atomic_complete_commit() is that new FBs are in use and the old ones can be safely released.

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

#12 lore raw

v2 cover drm/vc4: Add support for the transposer IP

In reply to Boris Brezillon

Hello,

This is the second version of this series adding writeback support to the VC4 display engine.

This version is based on drm-misc-next and include a bunch of modifications to core that I had to add to make it work on VC4.

Feel free to comment on those modifications.

On the driver side, no much has changed except I modified a bit the implementation to adjust the latest revision of the writeback interface.

Regards,

Boris

Boris Brezillon (8):
drm/atomic: Avoid connector to writeback_connector casts drm/connector: Pass a drm_connector_state to ->atomic_commit() drm/vc4: Use wait_for_flip_done() instead of wait_for_vblanks() drm/crtc: Add a generic infrastructure to fake VBLANK events drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic
commit_tail() helpers
drm/vc4: Call drm_atomic_helper_fake_vblank() in the commit path drm/vc4: Add support for the transposer block
ARM: dts: bcm283x: Add Transposer block

 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |   6 +
 arch/arm/boot/dts/bcm283x.dtsi                     |   6 +
 drivers/gpu/drm/drm_atomic.c                       |   4 +-
 drivers/gpu/drm/drm_atomic_helper.c                |  46 +-
 drivers/gpu/drm/vc4/Makefile                       |   1 +
 drivers/gpu/drm/vc4/vc4_crtc.c                     | 139 +++++-
 drivers/gpu/drm/vc4/vc4_debugfs.c                  |   1 +
 drivers/gpu/drm/vc4/vc4_drv.c                      |   1 +
 drivers/gpu/drm/vc4/vc4_drv.h                      |   7 +
 drivers/gpu/drm/vc4/vc4_kms.c                      |  11 +-
 drivers/gpu/drm/vc4/vc4_regs.h                     |   1 +
 drivers/gpu/drm/vc4/vc4_txp.c                      | 487 +++++++++++++++++++++
 include/drm/drm_atomic_helper.h                    |   1 +
 include/drm/drm_crtc.h                             |  15 +
 include/drm/drm_modeset_helper_vtables.h           |   4 +-
 include/drm/drm_writeback.h                        |   6 +
 16 files changed, 700 insertions(+), 36 deletions(-)
 create mode 100644 drivers/gpu/drm/vc4/vc4_txp.c
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw
Quoted 5 lines · Boris Brezillon

Hello,

This is the second version of this series adding writeback support to the VC4 display engine.

Quoted 8 lines

This version is based on drm-misc-next and include a bunch of modifications to core that I had to add to make it work on VC4.

Feel free to comment on those modifications.

On the driver side, no much has changed except I modified a bit the implementation to adjust the latest revision of the writeback interface.

This is a duplicate of the cover letter.

I've reviewed / checked patches 1-5 and 8, so you can add my Reviewed-by tag from me if you want.

Best regards,
Liviu

Quoted 38 lines

Regards,

Boris

Boris Brezillon (8):
drm/atomic: Avoid connector to writeback_connector casts drm/connector: Pass a drm_connector_state to ->atomic_commit() drm/vc4: Use wait_for_flip_done() instead of wait_for_vblanks() drm/crtc: Add a generic infrastructure to fake VBLANK events drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic
commit_tail() helpers
drm/vc4: Call drm_atomic_helper_fake_vblank() in the commit path drm/vc4: Add support for the transposer block
ARM: dts: bcm283x: Add Transposer block

 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |   6 +
 arch/arm/boot/dts/bcm283x.dtsi                     |   6 +
 drivers/gpu/drm/drm_atomic.c                       |   4 +-
 drivers/gpu/drm/drm_atomic_helper.c                |  46 +-
 drivers/gpu/drm/vc4/Makefile                       |   1 +
 drivers/gpu/drm/vc4/vc4_crtc.c                     | 139 +++++-
 drivers/gpu/drm/vc4/vc4_debugfs.c                  |   1 +
 drivers/gpu/drm/vc4/vc4_drv.c                      |   1 +
 drivers/gpu/drm/vc4/vc4_drv.h                      |   7 +
 drivers/gpu/drm/vc4/vc4_kms.c                      |  11 +-
 drivers/gpu/drm/vc4/vc4_regs.h                     |   1 +
 drivers/gpu/drm/vc4/vc4_txp.c                      | 487 +++++++++++++++++++++
 include/drm/drm_atomic_helper.h                    |   1 +
 include/drm/drm_crtc.h                             |  15 +
 include/drm/drm_modeset_helper_vtables.h           |   4 +-
 include/drm/drm_writeback.h                        |   6 +
 16 files changed, 700 insertions(+), 36 deletions(-)
 create mode 100644 drivers/gpu/drm/vc4/vc4_txp.c
Signature · 1 line
2.14.1
Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw
Quoted 9 lines · On Fri, 29 Jun 2018 12:40:45 +0100 Liviu Dudau <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon

Hello,

This is the second version of this series adding writeback support to the VC4 display engine.

This version is based on drm-misc-next and include a bunch of modifications to core that I had to add to make it work on VC4.

Quoted 7 lines
Quoted 5 lines

Feel free to comment on those modifications.

On the driver side, no much has changed except I modified a bit the implementation to adjust the latest revision of the writeback interface.

This is a duplicate of the cover letter.

Yep, I forgot to clean the directory I used to generate my patches :-/

Quoted 3 lines

I've reviewed / checked patches 1-5 and 8, so you can add my Reviewed-by tag from me if you want.

Thanks for your review.

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

#15 lore raw

PATCH v2 4/8 drm/crtc: Add a generic infrastructure to fake VBLANK events

In reply to Boris Brezillon

In some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.

In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.

---
 drivers/gpu/drm/drm_atomic_helper.c | 40 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  1 +
 include/drm/drm_crtc.h              | 15 ++++++++++++++
 3 files changed, 56 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +40 -0
index 69063bcf2334..ca586993c2a2 100644
@@ -2051,6 +2051,46 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state)
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
 
+/**
+ * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
+ * @old_state: atomic state object with old state structures
+ *
+ * This function walks all CRTCs and fake VBLANK events on those with
+ * &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL.
+ * The primary use of this function is writeback connectors working in oneshot
+ * mode and faking VBLANK events. In this case they only fake the VBLANK event
+ * when a job is queued, and any change to the pipeline that does not touch the
+ * connector is leading to timeouts when calling
+ * drm_atomic_helper_wait_for_vblanks() or
+ * drm_atomic_helper_wait_for_flip_done().
+ *
+ * This is part of the atomic helper support for nonblocking commits, see
+ * drm_atomic_helper_setup_commit() for an overview.
+ */
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *old_state)
+{
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state,
+				      new_crtc_state, i) {
+		unsigned long flags;
+
+		if (!new_crtc_state->no_vblank && !old_crtc_state->no_vblank)
+			continue;
+
+		spin_lock_irqsave(&old_state->dev->event_lock, flags);
+		if (new_crtc_state->event) {
+			drm_crtc_send_vblank_event(crtc,
+						   new_crtc_state->event);
+			new_crtc_state->event = NULL;
+		}
+		spin_unlock_irqrestore(&old_state->dev->event_lock, flags);
+	}
+}
+EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
+
 /**
  * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
  * @old_state: atomic state object with old state structures
include/drm/drm_atomic_helper.h +1 -0
index 26aaba58d6ce..99e2a5297c69 100644
@@ -100,6 +100,7 @@ int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 				   bool nonblock);
 void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state);
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state);
 
include/drm/drm_crtc.h +15 -0
index 23eddbccab10..7435dc66c08a 100644
@@ -87,6 +87,20 @@ struct drm_plane_helper_funcs;
  * @zpos_changed: zpos values of planes on this crtc have been updated
  * @color_mgmt_changed: color management properties have changed (degamma or
  *	gamma LUT or CSC matrix)
+ * @no_vblank: reflects the ability of a CRTC to send VBLANK events. This state
+ *	usually depends on the pipeline configuration, and the main usuage is
+ *	CRTCs feeding a writeback connector operating in oneshot mode. In this
+ *	case the VBLANK event is only generated when a job is queued to the
+ *	writeback connector, and we want the core to fake VBLANK events when
+ *	this part of the pipeline hasn't changed but others had or when the
+ *	CRTC and connectors are disabled.
+ *	__drm_atomic_helper_crtc_duplicate_state() will the value from the
+ *	current state, the CRTC driver is then responsible for updating this
+ *	field when needed.
+ *	Note that, even when no_blank is set to true, the CRTC driver can still
+ *	steal the &drm_crtc_state.event object and send the event on its own.
+ *	That's usually what happens when a job is queued to the writeback
+ *	connector.
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
@@ -118,6 +132,7 @@ struct drm_crtc_state {
 	bool connectors_changed : 1;
 	bool zpos_changed : 1;
 	bool color_mgmt_changed : 1;
+	bool no_vblank : 1;
 
 	/* attached planes bitmask:
 	 * WARNING: transitional helpers do not maintain plane_mask so
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 4/8
#16 lore raw

Re: [PATCH v2 4/8] drm/crtc: Add a generic infrastructure to fake VBLANK events

Quoted 8 lines · Boris Brezillon

In some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.

Quoted 6 lines

In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.

Quoted 105 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 40 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  1 +
 include/drm/drm_crtc.h              | 15 ++++++++++++++
 3 files changed, 56 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +40 -0
index 69063bcf2334..ca586993c2a2 100644
@@ -2051,6 +2051,46 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state)
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
 
+/**
+ * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
+ * @old_state: atomic state object with old state structures
+ *
+ * This function walks all CRTCs and fake VBLANK events on those with
+ * &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL.
+ * The primary use of this function is writeback connectors working in oneshot
+ * mode and faking VBLANK events. In this case they only fake the VBLANK event
+ * when a job is queued, and any change to the pipeline that does not touch the
+ * connector is leading to timeouts when calling
+ * drm_atomic_helper_wait_for_vblanks() or
+ * drm_atomic_helper_wait_for_flip_done().
+ *
+ * This is part of the atomic helper support for nonblocking commits, see
+ * drm_atomic_helper_setup_commit() for an overview.
+ */
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *old_state)
+{
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state,
+				      new_crtc_state, i) {
+		unsigned long flags;
+
+		if (!new_crtc_state->no_vblank && !old_crtc_state->no_vblank)
+			continue;
+
+		spin_lock_irqsave(&old_state->dev->event_lock, flags);
+		if (new_crtc_state->event) {
+			drm_crtc_send_vblank_event(crtc,
+						   new_crtc_state->event);
+			new_crtc_state->event = NULL;
+		}
+		spin_unlock_irqrestore(&old_state->dev->event_lock, flags);
+	}
+}
+EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
+
 /**
  * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
  * @old_state: atomic state object with old state structures
include/drm/drm_atomic_helper.h +1 -0
index 26aaba58d6ce..99e2a5297c69 100644
@@ -100,6 +100,7 @@ int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 				   bool nonblock);
 void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state);
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state);
 
include/drm/drm_crtc.h +15 -0
index 23eddbccab10..7435dc66c08a 100644
@@ -87,6 +87,20 @@ struct drm_plane_helper_funcs;
  * @zpos_changed: zpos values of planes on this crtc have been updated
  * @color_mgmt_changed: color management properties have changed (degamma or
  *	gamma LUT or CSC matrix)
+ * @no_vblank: reflects the ability of a CRTC to send VBLANK events. This state
+ *	usually depends on the pipeline configuration, and the main usuage is
+ *	CRTCs feeding a writeback connector operating in oneshot mode. In this
+ *	case the VBLANK event is only generated when a job is queued to the
+ *	writeback connector, and we want the core to fake VBLANK events when
+ *	this part of the pipeline hasn't changed but others had or when the
+ *	CRTC and connectors are disabled.
+ *	__drm_atomic_helper_crtc_duplicate_state() will the value from the
+ *	current state, the CRTC driver is then responsible for updating this
+ *	field when needed.
+ *	Note that, even when no_blank is set to true, the CRTC driver can still
+ *	steal the &drm_crtc_state.event object and send the event on its own.
+ *	That's usually what happens when a job is queued to the writeback
+ *	connector.
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
@@ -118,6 +132,7 @@ struct drm_crtc_state {
 	bool connectors_changed : 1;
 	bool zpos_changed : 1;
 	bool color_mgmt_changed : 1;
+	bool no_vblank : 1;
 
 	/* attached planes bitmask:
 	 * WARNING: transitional helpers do not maintain plane_mask so
Signature · 1 line
2.14.1
Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 4/8
#17 lore raw

Re: [PATCH v2 4/8] drm/crtc: Add a generic infrastructure to fake VBLANK events

In reply to Boris Brezillon
Quoted 45 lines · Boris Brezillon

In some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.

In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.

---
 drivers/gpu/drm/drm_atomic_helper.c | 40 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  1 +
 include/drm/drm_crtc.h              | 15 ++++++++++++++
 3 files changed, 56 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +17 -0
index 69063bcf2334..ca586993c2a2 100644
@@ -2051,6 +2051,46 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state)
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
 
+/**
+ * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
+ * @old_state: atomic state object with old state structures
+ *
+ * This function walks all CRTCs and fake VBLANK events on those with
+ * &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL.
+ * The primary use of this function is writeback connectors working in oneshot
+ * mode and faking VBLANK events. In this case they only fake the VBLANK event
+ * when a job is queued, and any change to the pipeline that does not touch the
+ * connector is leading to timeouts when calling
+ * drm_atomic_helper_wait_for_vblanks() or
+ * drm_atomic_helper_wait_for_flip_done().
+ *
+ * This is part of the atomic helper support for nonblocking commits, see
+ * drm_atomic_helper_setup_commit() for an overview.
+ */
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *old_state)

drivers/gpu/drm/drm_atomic_helper.c void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state) · line 2080

Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10 -0
+{
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state,
+				      new_crtc_state, i) {
+		unsigned long flags;
+
+		if (!new_crtc_state->no_vblank && !old_crtc_state->no_vblank)

Uh, this essentially makes it impossible to reset no_vblank. For control flow state bits we only check the new state for it (see e.g. the various *_changed or plane_bits or whatever).

Quoted 33 lines
drivers/gpu/drm/drm_atomic_helper.c +13 -0
+			continue;
+
+		spin_lock_irqsave(&old_state->dev->event_lock, flags);
+		if (new_crtc_state->event) {
+			drm_crtc_send_vblank_event(crtc,
+						   new_crtc_state->event);
+			new_crtc_state->event = NULL;
+		}
+		spin_unlock_irqrestore(&old_state->dev->event_lock, flags);
+	}
+}
+EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
+
 /**
  * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
  * @old_state: atomic state object with old state structures
include/drm/drm_atomic_helper.h +1 -0
index 26aaba58d6ce..99e2a5297c69 100644
@@ -100,6 +100,7 @@ int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 				   bool nonblock);
 void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state);
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state);
 
include/drm/drm_crtc.h +0 -0
index 23eddbccab10..7435dc66c08a 100644

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 96

Quoted 10 lines
include/drm/drm_crtc.h +7 -0
@@ -87,6 +87,20 @@ struct drm_plane_helper_funcs;
  * @zpos_changed: zpos values of planes on this crtc have been updated
  * @color_mgmt_changed: color management properties have changed (degamma or
  *	gamma LUT or CSC matrix)
+ * @no_vblank: reflects the ability of a CRTC to send VBLANK events. This state
+ *	usually depends on the pipeline configuration, and the main usuage is
+ *	CRTCs feeding a writeback connector operating in oneshot mode. In this
+ *	case the VBLANK event is only generated when a job is queued to the
+ *	writeback connector, and we want the core to fake VBLANK events when
+ *	this part of the pipeline hasn't changed but others had or when the
+ *	CRTC and connectors are disabled.

s/are disabled/are getting disabled/

You'll never get a request for an event when it's already off.

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 99

Quoted 3 lines
include/drm/drm_crtc.h +3 -0
+ *	__drm_atomic_helper_crtc_duplicate_state() will the value from the
+ *	current state, the CRTC driver is then responsible for updating this
+ *	field when needed.

Not parsing the above ... probably missing a "... will not reset ..."

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 103

Quoted 4 lines
include/drm/drm_crtc.h +4 -0
+ *	Note that, even when no_blank is set to true, the CRTC driver can still
+ *	steal the &drm_crtc_state.event object and send the event on its own.
+ *	That's usually what happens when a job is queued to the writeback
+ *	connector.

The last sentence is confusing imo. Just drop it?

Please use the inline comment style for struct members, and then also polish the formatting a bit (e.g. paragraph breaks, which are only possible with the inline style).

With the nits addressed:

Quoted 14 lines
include/drm/drm_crtc.h +1 -0
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
@@ -118,6 +132,7 @@ struct drm_crtc_state {
 	bool connectors_changed : 1;
 	bool zpos_changed : 1;
 	bool color_mgmt_changed : 1;
+	bool no_vblank : 1;
 
 	/* attached planes bitmask:
 	 * WARNING: transitional helpers do not maintain plane_mask so
Signature · 1 line
2.14.1
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
#18 lore raw

Re: [PATCH v2 4/8] drm/crtc: Add a generic infrastructure to fake VBLANK events

Quoted 50 lines · On Mon, 2 Jul 2018 10:02:52 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 49 lines · Boris Brezillon

In some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.

In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.

---
 drivers/gpu/drm/drm_atomic_helper.c | 40 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  1 +
 include/drm/drm_crtc.h              | 15 ++++++++++++++
 3 files changed, 56 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +21 -0
index 69063bcf2334..ca586993c2a2 100644
@@ -2051,6 +2051,46 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state)
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
 
+/**
+ * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
+ * @old_state: atomic state object with old state structures
+ *
+ * This function walks all CRTCs and fake VBLANK events on those with
+ * &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL.
+ * The primary use of this function is writeback connectors working in oneshot
+ * mode and faking VBLANK events. In this case they only fake the VBLANK event
+ * when a job is queued, and any change to the pipeline that does not touch the
+ * connector is leading to timeouts when calling
+ * drm_atomic_helper_wait_for_vblanks() or
+ * drm_atomic_helper_wait_for_flip_done().
+ *
+ * This is part of the atomic helper support for nonblocking commits, see
+ * drm_atomic_helper_setup_commit() for an overview.
+ */
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *old_state)
+{
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state) · line 2080

Quoted 6 lines
drivers/gpu/drm/drm_atomic_helper.c +6 -0
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state,
+				      new_crtc_state, i) {
+		unsigned long flags;
+
+		if (!new_crtc_state->no_vblank && !old_crtc_state->no_vblank)  

Uh, this essentially makes it impossible to reset no_vblank.

I don't want ->no_vblank to be reset by the core. It's up to the CRTC driver to clear/set it when something changes in the pipeline.

Quoted 3 lines

For control
flow state bits we only check the new state for it (see e.g. the various *_changed or plane_bits or whatever).

I tried with !new_crtc_state->no_vblank only, but then it does not handle the case where the CRTC and connector are being disabled, and I end up with a timeout.

Quoted 47 lines
Quoted 34 lines
drivers/gpu/drm/drm_atomic_helper.c +13 -0
+			continue;
+
+		spin_lock_irqsave(&old_state->dev->event_lock, flags);
+		if (new_crtc_state->event) {
+			drm_crtc_send_vblank_event(crtc,
+						   new_crtc_state->event);
+			new_crtc_state->event = NULL;
+		}
+		spin_unlock_irqrestore(&old_state->dev->event_lock, flags);
+	}
+}
+EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
+
 /**
  * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
  * @old_state: atomic state object with old state structures
include/drm/drm_atomic_helper.h +1 -0
index 26aaba58d6ce..99e2a5297c69 100644
@@ -100,6 +100,7 @@ int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 				   bool nonblock);
 void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state);
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state);
 
include/drm/drm_crtc.h +0 -0
index 23eddbccab10..7435dc66c08a 100644

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 96

Quoted 10 lines
include/drm/drm_crtc.h +7 -0
@@ -87,6 +87,20 @@ struct drm_plane_helper_funcs;
  * @zpos_changed: zpos values of planes on this crtc have been updated
  * @color_mgmt_changed: color management properties have changed (degamma or
  *	gamma LUT or CSC matrix)
+ * @no_vblank: reflects the ability of a CRTC to send VBLANK events. This state
+ *	usually depends on the pipeline configuration, and the main usuage is
+ *	CRTCs feeding a writeback connector operating in oneshot mode. In this
+ *	case the VBLANK event is only generated when a job is queued to the
+ *	writeback connector, and we want the core to fake VBLANK events when
+ *	this part of the pipeline hasn't changed but others had or when the
+ *	CRTC and connectors are disabled.  

s/are disabled/are getting disabled/

Quoted 1 line

You'll never get a request for an event when it's already off.

That's true.

Quoted 6 lines

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 99

Quoted 4 lines
include/drm/drm_crtc.h +3 -0
+ *	__drm_atomic_helper_crtc_duplicate_state() will the value from the
+ *	current state, the CRTC driver is then responsible for updating this
+ *	field when needed.  

Not parsing the above ... probably missing a "... will not reset ..."

Exactly. Will add the missing words.

Quoted 7 lines

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 103

Quoted 5 lines
include/drm/drm_crtc.h +4 -0
+ *	Note that, even when no_blank is set to true, the CRTC driver can still
+ *	steal the &drm_crtc_state.event object and send the event on its own.
+ *	That's usually what happens when a job is queued to the writeback
+ *	connector.  

The last sentence is confusing imo. Just drop it?

Yes, I know, but it's also important to state that the ->no_blank + event == NULL is a valid combination, and just means that the driver decided to generate the event (that happens when a new WB job is queued).

Quoted 4 lines

Please use the inline comment style for struct members, and then also polish the formatting a bit (e.g. paragraph breaks, which are only possible with the inline style).

I considered that, but the other fields were already documented in the single block above the struct, so I thought keeping things consistent was better. Should I just add this field doc inline and keep the other ones where they are, or should I add a patch moving all docs inline?

Quoted 14 lines

With the nits addressed:

Quoted 9 lines
include/drm/drm_crtc.h +1 -0
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
@@ -118,6 +132,7 @@ struct drm_crtc_state {
 	bool connectors_changed : 1;
 	bool zpos_changed : 1;
 	bool color_mgmt_changed : 1;
+	bool no_vblank : 1;
 
Quoted 6 lines
Quoted 5 lines
include/drm/drm_crtc.h +0 -0
 	/* attached planes bitmask:
 	 * WARNING: transitional helpers do not maintain plane_mask so
Signature · 1 line
2.14.1

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

#19 lore raw

Re: [PATCH v2 4/8] drm/crtc: Add a generic infrastructure to fake VBLANK events

Quoted 65 lines · Boris Brezillon
Quoted 50 lines · On Mon, 2 Jul 2018 10:02:52 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 49 lines · Boris Brezillon

In some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.

In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.

---
 drivers/gpu/drm/drm_atomic_helper.c | 40 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  1 +
 include/drm/drm_crtc.h              | 15 ++++++++++++++
 3 files changed, 56 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +21 -0
index 69063bcf2334..ca586993c2a2 100644
@@ -2051,6 +2051,46 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state)
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
 
+/**
+ * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
+ * @old_state: atomic state object with old state structures
+ *
+ * This function walks all CRTCs and fake VBLANK events on those with
+ * &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL.
+ * The primary use of this function is writeback connectors working in oneshot
+ * mode and faking VBLANK events. In this case they only fake the VBLANK event
+ * when a job is queued, and any change to the pipeline that does not touch the
+ * connector is leading to timeouts when calling
+ * drm_atomic_helper_wait_for_vblanks() or
+ * drm_atomic_helper_wait_for_flip_done().
+ *
+ * This is part of the atomic helper support for nonblocking commits, see
+ * drm_atomic_helper_setup_commit() for an overview.
+ */
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *old_state)
+{
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state) · line 2080

Quoted 6 lines
drivers/gpu/drm/drm_atomic_helper.c +6 -0
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state,
+				      new_crtc_state, i) {
+		unsigned long flags;
+
+		if (!new_crtc_state->no_vblank && !old_crtc_state->no_vblank)  

Uh, this essentially makes it impossible to reset no_vblank.

I don't want ->no_vblank to be reset by the core. It's up to the CRTC driver to clear/set it when something changes in the pipeline.

Quoted 7 lines
Quoted 3 lines

For control
flow state bits we only check the new state for it (see e.g. the various *_changed or plane_bits or whatever).

I tried with !new_crtc_state->no_vblank only, but then it does not handle the case where the CRTC and connector are being disabled, and I end up with a timeout.

Why that? You should have a new_crtc_state even when you disable the crtc, and you can set the ->no_vblank on that one too. With your current code it's essentially impossible to reset ->no_vblank, since it will only have effect for the _next_ atomic update, not the one you're doing right now. That doesn't make sense.

E.g. try to do the same logic of checking both old&new state for e.g. needs_modeset and watch how all the logic totally falls to pieces. -Daniel

Quoted 105 lines
Quoted 48 lines
Quoted 35 lines
drivers/gpu/drm/drm_atomic_helper.c +13 -0
+			continue;
+
+		spin_lock_irqsave(&old_state->dev->event_lock, flags);
+		if (new_crtc_state->event) {
+			drm_crtc_send_vblank_event(crtc,
+						   new_crtc_state->event);
+			new_crtc_state->event = NULL;
+		}
+		spin_unlock_irqrestore(&old_state->dev->event_lock, flags);
+	}
+}
+EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
+
 /**
  * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
  * @old_state: atomic state object with old state structures
include/drm/drm_atomic_helper.h +1 -0
index 26aaba58d6ce..99e2a5297c69 100644
@@ -100,6 +100,7 @@ int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 				   bool nonblock);
 void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state);
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state);
 
include/drm/drm_crtc.h +0 -0
index 23eddbccab10..7435dc66c08a 100644

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 96

Quoted 10 lines
include/drm/drm_crtc.h +7 -0
@@ -87,6 +87,20 @@ struct drm_plane_helper_funcs;
  * @zpos_changed: zpos values of planes on this crtc have been updated
  * @color_mgmt_changed: color management properties have changed (degamma or
  *	gamma LUT or CSC matrix)
+ * @no_vblank: reflects the ability of a CRTC to send VBLANK events. This state
+ *	usually depends on the pipeline configuration, and the main usuage is
+ *	CRTCs feeding a writeback connector operating in oneshot mode. In this
+ *	case the VBLANK event is only generated when a job is queued to the
+ *	writeback connector, and we want the core to fake VBLANK events when
+ *	this part of the pipeline hasn't changed but others had or when the
+ *	CRTC and connectors are disabled.  

s/are disabled/are getting disabled/

Quoted 1 line

You'll never get a request for an event when it's already off.

That's true.

Quoted 6 lines

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 99

Quoted 4 lines
include/drm/drm_crtc.h +3 -0
+ *	__drm_atomic_helper_crtc_duplicate_state() will the value from the
+ *	current state, the CRTC driver is then responsible for updating this
+ *	field when needed.  

Not parsing the above ... probably missing a "... will not reset ..."

Exactly. Will add the missing words.

Quoted 7 lines

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 103

Quoted 5 lines
include/drm/drm_crtc.h +4 -0
+ *	Note that, even when no_blank is set to true, the CRTC driver can still
+ *	steal the &drm_crtc_state.event object and send the event on its own.
+ *	That's usually what happens when a job is queued to the writeback
+ *	connector.  

The last sentence is confusing imo. Just drop it?

Yes, I know, but it's also important to state that the ->no_blank + event == NULL is a valid combination, and just means that the driver decided to generate the event (that happens when a new WB job is queued).

Quoted 4 lines

Please use the inline comment style for struct members, and then also polish the formatting a bit (e.g. paragraph breaks, which are only possible with the inline style).

I considered that, but the other fields were already documented in the single block above the struct, so I thought keeping things consistent was better. Should I just add this field doc inline and keep the other ones where they are, or should I add a patch moving all docs inline?

Quoted 20 lines

With the nits addressed:

Quoted 14 lines
include/drm/drm_crtc.h +1 -0
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
@@ -118,6 +132,7 @@ struct drm_crtc_state {
 	bool connectors_changed : 1;
 	bool zpos_changed : 1;
 	bool color_mgmt_changed : 1;
+	bool no_vblank : 1;
 
 	/* attached planes bitmask:
 	 * WARNING: transitional helpers do not maintain plane_mask so
Signature · 1 line
2.14.1
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
#20 lore raw

Re: [PATCH v2 4/8] drm/crtc: Add a generic infrastructure to fake VBLANK events

Quoted 70 lines · On Mon, 2 Jul 2018 10:37:22 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 69 lines · Boris Brezillon
Quoted 50 lines · On Mon, 2 Jul 2018 10:02:52 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 49 lines · Boris Brezillon

In some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.

In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.

---
 drivers/gpu/drm/drm_atomic_helper.c | 40 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  1 +
 include/drm/drm_crtc.h              | 15 ++++++++++++++
 3 files changed, 56 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +21 -0
index 69063bcf2334..ca586993c2a2 100644
@@ -2051,6 +2051,46 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state)
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
 
+/**
+ * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
+ * @old_state: atomic state object with old state structures
+ *
+ * This function walks all CRTCs and fake VBLANK events on those with
+ * &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL.
+ * The primary use of this function is writeback connectors working in oneshot
+ * mode and faking VBLANK events. In this case they only fake the VBLANK event
+ * when a job is queued, and any change to the pipeline that does not touch the
+ * connector is leading to timeouts when calling
+ * drm_atomic_helper_wait_for_vblanks() or
+ * drm_atomic_helper_wait_for_flip_done().
+ *
+ * This is part of the atomic helper support for nonblocking commits, see
+ * drm_atomic_helper_setup_commit() for an overview.
+ */
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *old_state)
+{
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state) · line 2080

Quoted 6 lines
drivers/gpu/drm/drm_atomic_helper.c +6 -0
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state,
+				      new_crtc_state, i) {
+		unsigned long flags;
+
+		if (!new_crtc_state->no_vblank && !old_crtc_state->no_vblank)    

Uh, this essentially makes it impossible to reset no_vblank.

I don't want ->no_vblank to be reset by the core. It's up to the CRTC driver to clear/set it when something changes in the pipeline.

Quoted 3 lines

For control
flow state bits we only check the new state for it (see e.g. the various *_changed or plane_bits or whatever).

Quoted 6 lines
Quoted 3 lines

I tried with !new_crtc_state->no_vblank only, but then it does not handle the case where the CRTC and connector are being disabled, and I end up with a timeout.

Why that? You should have a new_crtc_state even when you disable the crtc, and you can set the ->no_vblank on that one too.

Hm, right. I'll have to check why I didn't have ->no_blank set to true when I disable the CRTC. Probably a problem in vc4_crtc.c.

Signature · 7 lines
Boris Brezillon, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#21 lore raw

Re: [PATCH v2 4/8] drm/crtc: Add a generic infrastructure to fake VBLANK events

In reply to Boris Brezillon

Forgot to address your other comments.

Quoted 138 lines · Boris Brezillon
Quoted 50 lines · On Mon, 2 Jul 2018 10:02:52 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 49 lines · Boris Brezillon

In some cases CRTCs are active but are not able to generating events, at least not at every frame at it's expected to.
This is typically the case when the CRTC is feeding a writeback connector that has no job queued. In this situation the CRTC is usually stopped until a new job is queued, and this can lead to timeouts when part of the pipeline is updated but no new jobs are queued to the active writeback connector.

In order to solve that, we add a ->no_vblank flag to drm_crtc_state and ask the CRTC drivers to set it to true when they know they're not able to generate VBLANK events. The core drm_atomic_helper_fake_vblank() helper can then be used to fake VBLANKs at commit time.

---
 drivers/gpu/drm/drm_atomic_helper.c | 40 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_atomic_helper.h     |  1 +
 include/drm/drm_crtc.h              | 15 ++++++++++++++
 3 files changed, 56 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +21 -0
index 69063bcf2334..ca586993c2a2 100644
@@ -2051,6 +2051,46 @@ void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state)
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_dependencies);
 
+/**
+ * drm_atomic_helper_fake_vblank - fake VBLANK events if needed
+ * @old_state: atomic state object with old state structures
+ *
+ * This function walks all CRTCs and fake VBLANK events on those with
+ * &drm_crtc_state.no_vblank set to true and &drm_crtc_state.event != NULL.
+ * The primary use of this function is writeback connectors working in oneshot
+ * mode and faking VBLANK events. In this case they only fake the VBLANK event
+ * when a job is queued, and any change to the pipeline that does not touch the
+ * connector is leading to timeouts when calling
+ * drm_atomic_helper_wait_for_vblanks() or
+ * drm_atomic_helper_wait_for_flip_done().
+ *
+ * This is part of the atomic helper support for nonblocking commits, see
+ * drm_atomic_helper_setup_commit() for an overview.
+ */
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *old_state)
+{
+	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
Quoted 8 lines

drivers/gpu/drm/drm_atomic_helper.c void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *old_state) · line 2080

Quoted 6 lines
drivers/gpu/drm/drm_atomic_helper.c +6 -0
+
+	for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state,
+				      new_crtc_state, i) {
+		unsigned long flags;
+
+		if (!new_crtc_state->no_vblank && !old_crtc_state->no_vblank)  

Uh, this essentially makes it impossible to reset no_vblank.

I don't want ->no_vblank to be reset by the core. It's up to the CRTC driver to clear/set it when something changes in the pipeline.

Quoted 3 lines

For control
flow state bits we only check the new state for it (see e.g. the various *_changed or plane_bits or whatever).

I tried with !new_crtc_state->no_vblank only, but then it does not handle the case where the CRTC and connector are being disabled, and I end up with a timeout.

Quoted 47 lines
Quoted 34 lines
drivers/gpu/drm/drm_atomic_helper.c +13 -0
+			continue;
+
+		spin_lock_irqsave(&old_state->dev->event_lock, flags);
+		if (new_crtc_state->event) {
+			drm_crtc_send_vblank_event(crtc,
+						   new_crtc_state->event);
+			new_crtc_state->event = NULL;
+		}
+		spin_unlock_irqrestore(&old_state->dev->event_lock, flags);
+	}
+}
+EXPORT_SYMBOL(drm_atomic_helper_fake_vblank);
+
 /**
  * drm_atomic_helper_commit_hw_done - setup possible nonblocking commit
  * @old_state: atomic state object with old state structures
include/drm/drm_atomic_helper.h +1 -0
index 26aaba58d6ce..99e2a5297c69 100644
@@ -100,6 +100,7 @@ int __must_check drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 int drm_atomic_helper_setup_commit(struct drm_atomic_state *state,
 				   bool nonblock);
 void drm_atomic_helper_wait_for_dependencies(struct drm_atomic_state *state);
+void drm_atomic_helper_fake_vblank(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_hw_done(struct drm_atomic_state *state);
 void drm_atomic_helper_commit_cleanup_done(struct drm_atomic_state *state);
 
include/drm/drm_crtc.h +0 -0
index 23eddbccab10..7435dc66c08a 100644

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 96

Quoted 10 lines
include/drm/drm_crtc.h +7 -0
@@ -87,6 +87,20 @@ struct drm_plane_helper_funcs;
  * @zpos_changed: zpos values of planes on this crtc have been updated
  * @color_mgmt_changed: color management properties have changed (degamma or
  *	gamma LUT or CSC matrix)
+ * @no_vblank: reflects the ability of a CRTC to send VBLANK events. This state
+ *	usually depends on the pipeline configuration, and the main usuage is
+ *	CRTCs feeding a writeback connector operating in oneshot mode. In this
+ *	case the VBLANK event is only generated when a job is queued to the
+ *	writeback connector, and we want the core to fake VBLANK events when
+ *	this part of the pipeline hasn't changed but others had or when the
+ *	CRTC and connectors are disabled.  

s/are disabled/are getting disabled/

Quoted 1 line

You'll never get a request for an event when it's already off.

That's true.

Quoted 6 lines

include/drm/drm_crtc.h struct drm_plane_helper_funcs; · line 99

Quoted 4 lines
include/drm/drm_crtc.h +3 -0
+ *	__drm_atomic_helper_crtc_duplicate_state() will the value from the
+ *	current state, the CRTC driver is then responsible for updating this
+ *	field when needed.  

Not parsing the above ... probably missing a "... will not reset ..."

Exactly. Will add the missing words.

Quoted 6 lines
Quoted 5 lines
include/drm/drm_crtc.h +4 -0
+ *	Note that, even when no_blank is set to true, the CRTC driver can still
+ *	steal the &drm_crtc_state.event object and send the event on its own.
+ *	That's usually what happens when a job is queued to the writeback
+ *	connector.  
Quoted 6 lines
Quoted 1 line

The last sentence is confusing imo. Just drop it?

Yes, I know, but it's also important to state that the ->no_blank + event == NULL is a valid combination, and just means that the driver decided to generate the event (that happens when a new WB job is queued).

Then make it more explicit, as-is I had no idea what you meant exactly. What about

Quoted 10 lines
Quoted 5 lines

Please use the inline comment style for struct members, and then also polish the formatting a bit (e.g. paragraph breaks, which are only possible with the inline style).

I considered that, but the other fields were already documented in the single block above the struct, so I thought keeping things consistent was better. Should I just add this field doc inline and keep the other ones where they are, or should I add a patch moving all docs inline?

There's _lots_ of inline comments already, and all new ones should be inline. The only reason I haven't done the conversion to all of them is that it would be a nice opportunity to update/clean up the comments (often there's a lot more to say than what's captured in the single line), which is why it didn't happen yet. Just moving the comments without updating them seems less useful imo.

I'd just do the inline comment for this, that's what everyone else is doing too.
-Daniel

Quoted 22 lines
Quoted 21 lines

With the nits addressed:

Quoted 14 lines
include/drm/drm_crtc.h +1 -0
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
@@ -118,6 +132,7 @@ struct drm_crtc_state {
 	bool connectors_changed : 1;
 	bool zpos_changed : 1;
 	bool color_mgmt_changed : 1;
+	bool no_vblank : 1;
 
 	/* attached planes bitmask:
 	 * WARNING: transitional helpers do not maintain plane_mask so
Signature · 1 line
2.14.1
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
#22 lore raw

Re: [PATCH v2 4/8] drm/crtc: Add a generic infrastructure to fake VBLANK events

Quoted 8 lines · On Mon, 2 Jul 2018 10:40:54 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines

+ * Note that, even when no_blank is set to true, the CRTC driver can still
+ * steal the &drm_crtc_state.event object and send the event on its own.
+ * That's usually what happens when a job is queued to the writeback
+ * connector.

The last sentence is confusing imo. Just drop it?

Quoted 7 lines
Quoted 4 lines

Yes, I know, but it's also important to state that the ->no_blank + event == NULL is a valid combination, and just means that the driver decided to generate the event (that happens when a new WB job is queued).

Then make it more explicit, as-is I had no idea what you meant exactly. What about

Your suggestion is missing :P.

Quoted 18 lines
Quoted 10 lines
Quoted 5 lines

Please use the inline comment style for struct members, and then also polish the formatting a bit (e.g. paragraph breaks, which are only possible with the inline style).

I considered that, but the other fields were already documented in the single block above the struct, so I thought keeping things consistent was better. Should I just add this field doc inline and keep the other ones where they are, or should I add a patch moving all docs inline?

There's _lots_ of inline comments already, and all new ones should be inline. The only reason I haven't done the conversion to all of them is that it would be a nice opportunity to update/clean up the comments (often there's a lot more to say than what's captured in the single line), which is why it didn't happen yet. Just moving the comments without updating them seems less useful imo.

Quoted 2 lines

I'd just do the inline comment for this, that's what everyone else is doing too.

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

#23 lore raw

PATCH v2 5/8 drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic commit_tail() helpers

In reply to Boris Brezillon

Now that we have a way to fake VBLANK events when requested by the CRTC hook it up to the generic commit_tail() helpers.

---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
index ca586993c2a2..1a088462bc42 100644
@@ -1448,6 +1448,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
@@ -1477,6 +1479,8 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
 	drm_atomic_helper_commit_planes(dev, old_state,
 					DRM_PLANE_COMMIT_ACTIVE_ONLY);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 5/8
#24 lore raw

Re: [PATCH v2 5/8] drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic commit_tail() helpers

Quoted 4 lines · Boris Brezillon

Now that we have a way to fake VBLANK events when requested by the CRTC hook it up to the generic commit_tail() helpers.

Quoted 29 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
index ca586993c2a2..1a088462bc42 100644
@@ -1448,6 +1448,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
@@ -1477,6 +1479,8 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
 	drm_atomic_helper_commit_planes(dev, old_state,
 					DRM_PLANE_COMMIT_ACTIVE_ONLY);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
Signature · 1 line
2.14.1
Signature · 12 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#25 lore raw

Re: [PATCH v2 5/8] drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic commit_tail() helpers

In reply to Boris Brezillon
Quoted 4 lines · Boris Brezillon

Now that we have a way to fake VBLANK events when requested by the CRTC hook it up to the generic commit_tail() helpers.

I really don't like this. We've had epic amounts of bugs with atomic drivers failing to send out vblank events when they should, and I added a bunch of debug checks to make sure that doesn't happen anymore.

Now there's no way anymore for drivers to spot this until they have misrenderings on wayland and no idea why. Imo this should only be used by specific drivers, with a comment why exactly they need it. -Daniel

Quoted 29 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
index ca586993c2a2..1a088462bc42 100644
@@ -1448,6 +1448,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
@@ -1477,6 +1479,8 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
 	drm_atomic_helper_commit_planes(dev, old_state,
 					DRM_PLANE_COMMIT_ACTIVE_ONLY);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
Signature · 1 line
2.14.1
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
Reviewed-by
#26 lore raw

Re: [PATCH v2 5/8] drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic commit_tail() helpers

Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Boris Brezillon

Now that we have a way to fake VBLANK events when requested by the CRTC hook it up to the generic commit_tail() helpers.

Quoted 7 lines

I really don't like this. We've had epic amounts of bugs with atomic drivers failing to send out vblank events when they should, and I added a bunch of debug checks to make sure that doesn't happen anymore.

Now there's no way anymore for drivers to spot this until they have misrenderings on wayland and no idea why. Imo this should only be used by specific drivers, with a comment why exactly they need it.

Meh I retract, you have the special no_vblank state flag to control this. Looks all good to me.

Quoted 36 lines

-Daniel

Quoted 29 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
index ca586993c2a2..1a088462bc42 100644
@@ -1448,6 +1448,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
@@ -1477,6 +1479,8 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
 	drm_atomic_helper_commit_planes(dev, old_state,
 					DRM_PLANE_COMMIT_ACTIVE_ONLY);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
Signature · 1 line
2.14.1
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
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
#27 lore raw

Re: [PATCH v2 5/8] drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic commit_tail() helpers

Quoted 11 lines · On Mon, 2 Jul 2018 09:57:30 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 10 lines · Daniel Vetter
Quoted 4 lines · Boris Brezillon

Now that we have a way to fake VBLANK events when requested by the CRTC hook it up to the generic commit_tail() helpers.

I really don't like this. We've had epic amounts of bugs with atomic drivers failing to send out vblank events when they should, and I added a bunch of debug checks to make sure that doesn't happen anymore.

Quoted 6 lines
Quoted 3 lines

Now there's no way anymore for drivers to spot this until they have misrenderings on wayland and no idea why. Imo this should only be used by specific drivers, with a comment why exactly they need it.

Meh I retract, you have the special no_vblank state flag to control this. Looks all good to me.

Hehe, just replied to your other email :-).

Quoted 40 lines
Quoted 36 lines

-Daniel

Quoted 29 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +4 -0
index ca586993c2a2..1a088462bc42 100644
@@ -1448,6 +1448,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
@@ -1477,6 +1479,8 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
 	drm_atomic_helper_commit_planes(dev, old_state,
 					DRM_PLANE_COMMIT_ACTIVE_ONLY);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
Signature · 1 line
2.14.1
Signature · 3 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

#28 lore raw

Re: [PATCH v2 5/8] drm/atomic: Call drm_atomic_helper_fake_vblank() from the generic commit_tail() helpers

In reply to Daniel Vetter
Quoted 6 lines · On Mon, 2 Jul 2018 09:54:32 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 4 lines · Boris Brezillon

Now that we have a way to fake VBLANK events when requested by the CRTC hook it up to the generic commit_tail() helpers.

Quoted 7 lines

I really don't like this. We've had epic amounts of bugs with atomic drivers failing to send out vblank events when they should, and I added a bunch of debug checks to make sure that doesn't happen anymore.

Now there's no way anymore for drivers to spot this until they have misrenderings on wayland and no idea why. Imo this should only be used by specific drivers, with a comment why exactly they need it.

Hm, that's not entirely true. Drivers have to explicitly set ->no_vblank to true for drm_atomic_helper_fake_vblank() to actually do something, and I seriously hope drivers won't set that field randomly. So, on all existing drivers but VC4 after the TXP patch, the behavior will be unchanged, and the core will spot misbehaving drivers just like before.

Quoted 23 lines

-Daniel

Quoted 21 lines
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +2 -0
index ca586993c2a2..1a088462bc42 100644
@@ -1448,6 +1448,8 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, old_state);
 
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
@@ -1477,6 +1479,8 @@ void drm_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)
 	drm_atomic_helper_commit_planes(dev, old_state,
 					DRM_PLANE_COMMIT_ACTIVE_ONLY);
 
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +2 -0
+	drm_atomic_helper_fake_vblank(old_state);
+
 	drm_atomic_helper_commit_hw_done(old_state);
 
 	drm_atomic_helper_wait_for_vblanks(dev, old_state);
Signature · 1 line
2.14.1

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

#29 lore raw

PATCH v2 6/8 drm/vc4: Call drm_atomic_helper_fake_vblank() in the commit path

In reply to Boris Brezillon

Mimic what is done in drm_atomic_commit_tail() and call drm_atomic_helper_fake_vblank() so that VBLANK events are faked when the drm_crtc_state.no_vblank is true. Will be needed when we'll add support for the transposer block.

---
 drivers/gpu/drm/vc4/vc4_kms.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/vc4/vc4_kms.c +2 -0
index 91239b0a4fa0..ca5aa7fba769 100644
@@ -153,6 +153,8 @@ vc4_atomic_complete_commit(struct drm_atomic_state *state)
 
 	drm_atomic_helper_commit_modeset_enables(dev, state);
 
+	drm_atomic_helper_fake_vblank(state);
+
 	drm_atomic_helper_commit_hw_done(state);
 
 	drm_atomic_helper_wait_for_flip_done(dev, state);
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 6/8
#30 lore raw

Re: [PATCH v2 6/8] drm/vc4: Call drm_atomic_helper_fake_vblank() in the commit path

Quoted 4 lines · Boris Brezillon

Mimic what is done in drm_atomic_commit_tail() and call drm_atomic_helper_fake_vblank() so that VBLANK events are faked when the drm_crtc_state.no_vblank is true. Will be needed when we'll add support for the transposer block.

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

#31 lore raw

PATCH v2 7/8 drm/vc4: Add support for the transposer block

In reply to Boris Brezillon

From: Boris Brezillon <[email protected]>

The transposer block is providing support for mem-to-mem composition, which is exposed as a drm_writeback connector in DRM.

Add a driver to support this feature.

---
 .../devicetree/bindings/display/brcm,bcm-vc4.txt   |   6 +
 drivers/gpu/drm/vc4/Makefile                       |   1 +
 drivers/gpu/drm/vc4/vc4_crtc.c                     | 139 +++++-
 drivers/gpu/drm/vc4/vc4_debugfs.c                  |   1 +
 drivers/gpu/drm/vc4/vc4_drv.c                      |   1 +
 drivers/gpu/drm/vc4/vc4_drv.h                      |   7 +
 drivers/gpu/drm/vc4/vc4_regs.h                     |   1 +
 drivers/gpu/drm/vc4/vc4_txp.c                      | 487 +++++++++++++++++++++
 8 files changed, 619 insertions(+), 24 deletions(-)
 create mode 100644 drivers/gpu/drm/vc4/vc4_txp.c
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt +6 -0
index 284e2b14cfbe..26649b4c4dd8 100644
@@ -74,6 +74,12 @@ Required properties for DSI:
 		The 3 clocks output from the DSI analog PHY: dsi[01]_byte,
 		dsi[01]_ddr2, and dsi[01]_ddr
 
+Required properties for the TXP (writeback) block:
+- compatible:	Should be "brcm,bcm2835-txp"
+- reg:		Physical base address and length of the TXP block's registers
+- interrupts:	The interrupt number
+		  See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
+
 [1] Documentation/devicetree/bindings/media/video-interfaces.txt
 
 Example:
drivers/gpu/drm/vc4/Makefile +1 -0
index 4a3a868235f8..b303703bc7f3 100644
@@ -19,6 +19,7 @@ vc4-y := \
 	vc4_plane.o \
 	vc4_render_cl.o \
 	vc4_trace_points.o \
+	vc4_txp.o \
 	vc4_v3d.o \
 	vc4_validate.o \
 	vc4_validate_shaders.o
drivers/gpu/drm/vc4/vc4_crtc.c +115 -24

244 lines not on this page · raw message

drivers/gpu/drm/vc4/vc4_debugfs.c +1 -0
index 5db06bdb5f27..7a0003de71ab 100644
@@ -21,6 +21,7 @@ static const struct drm_info_list vc4_debugfs_list[] = {
 	{"dsi1_regs", vc4_dsi_debugfs_regs, 0, (void *)(uintptr_t)1},
 	{"hdmi_regs", vc4_hdmi_debugfs_regs, 0},
 	{"vec_regs", vc4_vec_debugfs_regs, 0},
+	{"txp_regs", vc4_txp_debugfs_regs, 0},
 	{"hvs_regs", vc4_hvs_debugfs_regs, 0},
 	{"crtc0_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)0},
 	{"crtc1_regs", vc4_crtc_debugfs_regs, 0, (void *)(uintptr_t)1},
drivers/gpu/drm/vc4/vc4_drv.c +1 -0
index 466d0a27b415..e42fd5ec41cc 100644
@@ -344,6 +344,7 @@ static struct platform_driver *const component_drivers[] = {
 	&vc4_vec_driver,
 	&vc4_dpi_driver,
 	&vc4_dsi_driver,
+	&vc4_txp_driver,
 	&vc4_hvs_driver,
 	&vc4_crtc_driver,
 	&vc4_v3d_driver,
drivers/gpu/drm/vc4/vc4_drv.h +7 -0
index eace76c621a1..bd6ef1f31822 100644
@@ -73,6 +73,7 @@ struct vc4_dev {
 	struct vc4_dpi *dpi;
 	struct vc4_dsi *dsi1;
 	struct vc4_vec *vec;
+	struct vc4_txp *txp;
 
 	struct vc4_hang_state *hang_state;
 
@@ -698,6 +699,8 @@ bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
 			     bool in_vblank_irq, int *vpos, int *hpos,
 			     ktime_t *stime, ktime_t *etime,
 			     const struct drm_display_mode *mode);
+void vc4_crtc_handle_vblank(struct vc4_crtc *crtc);
+void vc4_crtc_txp_armed(struct drm_crtc_state *state);
 
 /* vc4_debugfs.c */
 int vc4_debugfs_init(struct drm_minor *minor);
@@ -745,6 +748,10 @@ int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);
 extern struct platform_driver vc4_vec_driver;
 int vc4_vec_debugfs_regs(struct seq_file *m, void *unused);
 
+/* vc4_txp.c */
+extern struct platform_driver vc4_txp_driver;
+int vc4_txp_debugfs_regs(struct seq_file *m, void *unused);
+
 /* vc4_irq.c */
 irqreturn_t vc4_irq(int irq, void *arg);
 void vc4_irq_preinstall(struct drm_device *dev);
drivers/gpu/drm/vc4/vc4_regs.h +1 -0
index d6864fa4bd14..744a689751f0 100644
@@ -330,6 +330,7 @@
 #define SCALER_DISPCTRL0                        0x00000040
 # define SCALER_DISPCTRLX_ENABLE		BIT(31)
 # define SCALER_DISPCTRLX_RESET			BIT(30)
+
 /* Generates a single frame when VSTART is seen and stops at the last
  * pixel read from the FIFO.
  */
drivers/gpu/drm/vc4/vc4_txp.c new file +487 -0

487 lines not on this page · raw message

Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 7/8
#32 lore raw

Re: [PATCH v2 7/8] drm/vc4: Add support for the transposer block

Quoted 26 lines · Boris Brezillon

From: Boris Brezillon <[email protected]>

The transposer block is providing support for mem-to-mem composition, which is exposed as a drm_writeback connector in DRM.

Add a driver to support this feature.

drivers/gpu/drm/vc4/vc4_crtc.c +17 -0
+static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct vc4_dev *vc4 = to_vc4_dev(dev);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
+	struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state);
+	struct drm_display_mode *mode = &crtc->state->adjusted_mode;
+	bool interlace = mode->flags & DRM_MODE_FLAG_INTERLACE;
+	bool debug_dump_regs = false;
+
+	if (debug_dump_regs) {
+		DRM_INFO("CRTC %d regs before:\n", drm_crtc_index(crtc));
+		vc4_crtc_dump_regs(vc4_crtc);
+	}
+
+	if (vc4_crtc->channel == 2) {
+		u32 dispctrl;

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc) · line 444

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_crtc.c +10 -0
+		u32 dsp3_mux;
+
+		/*
+		 * SCALER_DISPCTRL_DSP3 = X, where X < 2 means 'connect DSP3 to
+		 * FIFO X'.
+		 * SCALER_DISPCTRL_DSP3 = 3 means 'disable DSP 3'.
+		 *
+		 * DSP3 is connected to FIFO2 unless the transposer is
+		 * enabled. In this case, FIFO 2 is directly accessed by the
+		 * TXP IP, and we need to prevent disable the

s/prevent //

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc) · line 457

Quoted 13 lines
drivers/gpu/drm/vc4/vc4_crtc.c +13 -0
+		 * FIFO2 -> pixelvalve1 route.
+		 */
+		if (vc4_state->feed_txp)
+			dsp3_mux = VC4_SET_FIELD(3, SCALER_DISPCTRL_DSP3_MUX);
+		else
+			dsp3_mux = VC4_SET_FIELD(2, SCALER_DISPCTRL_DSP3_MUX);
+
+		/* Reconfigure the DSP3 mux if required. */
+		dispctrl = HVS_READ(SCALER_DISPCTRL);
+		if ((dispctrl & SCALER_DISPCTRL_DSP3_MUX_MASK) != dsp3_mux) {
+			dispctrl &= ~SCALER_DISPCTRL_DSP3_MUX_MASK;
+			HVS_WRITE(SCALER_DISPCTRL, dispctrl | dsp3_mux);
+		}

This is fine, but you could also skip the matching mux check here -- the read is the expensive part.

Quoted 54 lines
drivers/gpu/drm/vc4/vc4_crtc.c +20 -4
+	}
+
+	if (!vc4_state->feed_txp)
+		vc4_crtc_config_pv(crtc);
 
 	HVS_WRITE(SCALER_DISPBKGNDX(vc4_crtc->channel),
 		  SCALER_DISPBKGND_AUTOHS |
@@ -499,6 +539,13 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,
 	}
 }
 
+void vc4_crtc_txp_armed(struct drm_crtc_state *state)
+{
+	struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
+
+	vc4_state->txp_armed = true;
+}
+
 static void vc4_crtc_update_dlist(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -514,8 +561,11 @@ static void vc4_crtc_update_dlist(struct drm_crtc *crtc)
 		WARN_ON(drm_crtc_vblank_get(crtc) != 0);
 
 		spin_lock_irqsave(&dev->event_lock, flags);
-		vc4_crtc->event = crtc->state->event;
-		crtc->state->event = NULL;
+
+		if (!vc4_state->feed_txp || vc4_state->txp_armed) {
+			vc4_crtc->event = crtc->state->event;
+			crtc->state->event = NULL;
+		}
 
 		HVS_WRITE(SCALER_DISPLISTX(vc4_crtc->channel),
 			  vc4_state->mm.start);
@@ -533,8 +583,8 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
-	struct drm_crtc_state *state = crtc->state;
-	struct drm_display_mode *mode = &state->adjusted_mode;
+	struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state);
+	struct drm_display_mode *mode = &crtc->state->adjusted_mode;
 
 	require_hvs_enabled(dev);
 
@@ -546,15 +596,21 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,
 
 	/* Turn on the scaler, which will wait for vstart to start
 	 * compositing.
+	 * When feeding the transposer, we should operate in oneshot
+	 * mode.
 	 */
 	HVS_WRITE(SCALER_DISPCTRLX(vc4_crtc->channel),

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_atomic_enable(struct drm_crtc *crtc, · line 608

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_crtc.c +3 -4
 		  VC4_SET_FIELD(mode->hdisplay, SCALER_DISPCTRLX_WIDTH) |
 		  VC4_SET_FIELD(mode->vdisplay, SCALER_DISPCTRLX_HEIGHT) |
-		  SCALER_DISPCTRLX_ENABLE);
+		  SCALER_DISPCTRLX_ENABLE |
+		  (vc4_state->feed_txp ? SCALER_DISPCTRLX_ONESHOT : 0));
 
-	/* Turn on the pixel valve, which will emit the vstart signal. */
-	CRTC_WRITE(PV_V_CONTROL,
-		   CRTC_READ(PV_V_CONTROL) | PV_VCONTROL_VIDEN);
+	/* When feeding the composer block the pixelvalve is unneeded and

"transposer block"? composer block made me think HVS.

Quoted 44 lines
drivers/gpu/drm/vc4/vc4_crtc.c +24 -1
+	 * should not be enabled.
+	 */
+	if (!vc4_state->feed_txp)
+		CRTC_WRITE(PV_V_CONTROL,
+			   CRTC_READ(PV_V_CONTROL) | PV_VCONTROL_VIDEN);
 }
 
 static enum drm_mode_status vc4_crtc_mode_valid(struct drm_crtc *crtc,
@@ -579,8 +635,10 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
 	struct drm_plane *plane;
 	unsigned long flags;
 	const struct drm_plane_state *plane_state;
+	struct drm_connector *conn;
+	struct drm_connector_state *conn_state;
 	u32 dlist_count = 0;
-	int ret;
+	int ret, i;
 
 	/* The pixelvalve can only feed one encoder (and encoders are
 	 * 1:1 with connectors.)
@@ -600,6 +658,22 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
 	if (ret)
 		return ret;
 
+	state->no_vblank = false;
+	for_each_new_connector_in_state(state->state, conn, conn_state, i) {
+		if (conn_state->crtc != crtc)
+			continue;
+
+		/* The writeback connector is implemented using the transposer
+		 * block which is directly taking its data from the HVS FIFO.
+		 */
+		if (conn->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) {
+			state->no_vblank = true;
+			vc4_state->feed_txp = true;
+		}
+
+		break;
+	}
+
 	return 0;
 }
 

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc) · line 791

Quoted 6 lines
drivers/gpu/drm/vc4/vc4_crtc.c +2 -1
@@ -713,7 +787,8 @@ static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)
 
 	spin_lock_irqsave(&dev->event_lock, flags);
 	if (vc4_crtc->event &&
-	    (vc4_state->mm.start == HVS_READ(SCALER_DISPLACTX(chan)))) {
+	    (vc4_state->mm.start == HVS_READ(SCALER_DISPLACTX(chan)) ||
+	     vc4_state->feed_txp)) {

Can vc4_crtc->event even be set if vc4_state->feed_txp?

drivers/gpu/drm/vc4/vc4_regs.h line 336

Quoted 12 lines
drivers/gpu/drm/vc4/vc4_regs.h +1 -0
index d6864fa4bd14..744a689751f0 100644
@@ -330,6 +330,7 @@
 #define SCALER_DISPCTRL0                        0x00000040
 # define SCALER_DISPCTRLX_ENABLE		BIT(31)
 # define SCALER_DISPCTRLX_RESET			BIT(30)
+
 /* Generates a single frame when VSTART is seen and stops at the last
  * pixel read from the FIFO.
  */

stray hunk?

Quoted 9 lines
drivers/gpu/drm/vc4/vc4_regs.h +9 -0
+static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
+					struct drm_connector_state *conn_state)
+{
+	struct vc4_txp *txp = connector_to_vc4_txp(conn);
+	struct drm_gem_cma_object *gem;
+	struct drm_display_mode *mode;
+	struct drm_framebuffer *fb;
+	u32 ctrl = TXP_GO | TXP_VSTART_AT_EOF | TXP_EI;
+

drivers/gpu/drm/vc4/vc4_regs.h

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_regs.h +10 -0
+	if (WARN_ON(!conn_state->writeback_job ||
+		    !conn_state->writeback_job->fb))
+		return;
+
+	mode = &conn_state->crtc->state->adjusted_mode;
+	fb = conn_state->writeback_job->fb;
+
+	switch (fb->format->format) {
+	case DRM_FORMAT_ARGB8888:
+		ctrl |= TXP_ALPHA_ENABLE;

Optional suggestion: Have the txp_formats[] table be a struct with these register values in it.

All my feedback seems really minor, so with whatever components you like integrated, feel free to add:

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

#33 lore raw

Re: [PATCH v2 7/8] drm/vc4: Add support for the transposer block

Hi Eric,

Quoted 216 lines · On Fri, 29 Jun 2018 13:35:04 -0700 Eric Anholt <[email protected]> wrote:
Quoted 26 lines · Boris Brezillon

From: Boris Brezillon <[email protected]>

The transposer block is providing support for mem-to-mem composition, which is exposed as a drm_writeback connector in DRM.

Add a driver to support this feature.

drivers/gpu/drm/vc4/vc4_crtc.c +17 -0
+static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct vc4_dev *vc4 = to_vc4_dev(dev);
+	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
+	struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state);
+	struct drm_display_mode *mode = &crtc->state->adjusted_mode;
+	bool interlace = mode->flags & DRM_MODE_FLAG_INTERLACE;
+	bool debug_dump_regs = false;
+
+	if (debug_dump_regs) {
+		DRM_INFO("CRTC %d regs before:\n", drm_crtc_index(crtc));
+		vc4_crtc_dump_regs(vc4_crtc);
+	}
+
+	if (vc4_crtc->channel == 2) {
+		u32 dispctrl;

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc) · line 444

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_crtc.c +10 -0
+		u32 dsp3_mux;
+
+		/*
+		 * SCALER_DISPCTRL_DSP3 = X, where X < 2 means 'connect DSP3 to
+		 * FIFO X'.
+		 * SCALER_DISPCTRL_DSP3 = 3 means 'disable DSP 3'.
+		 *
+		 * DSP3 is connected to FIFO2 unless the transposer is
+		 * enabled. In this case, FIFO 2 is directly accessed by the
+		 * TXP IP, and we need to prevent disable the  

s/prevent //

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc) · line 457

Quoted 13 lines
drivers/gpu/drm/vc4/vc4_crtc.c +13 -0
+		 * FIFO2 -> pixelvalve1 route.
+		 */
+		if (vc4_state->feed_txp)
+			dsp3_mux = VC4_SET_FIELD(3, SCALER_DISPCTRL_DSP3_MUX);
+		else
+			dsp3_mux = VC4_SET_FIELD(2, SCALER_DISPCTRL_DSP3_MUX);
+
+		/* Reconfigure the DSP3 mux if required. */
+		dispctrl = HVS_READ(SCALER_DISPCTRL);
+		if ((dispctrl & SCALER_DISPCTRL_DSP3_MUX_MASK) != dsp3_mux) {
+			dispctrl &= ~SCALER_DISPCTRL_DSP3_MUX_MASK;
+			HVS_WRITE(SCALER_DISPCTRL, dispctrl | dsp3_mux);
+		}  

This is fine, but you could also skip the matching mux check here -- the read is the expensive part.

Quoted 54 lines
drivers/gpu/drm/vc4/vc4_crtc.c +20 -4
+	}
+
+	if (!vc4_state->feed_txp)
+		vc4_crtc_config_pv(crtc);
 
 	HVS_WRITE(SCALER_DISPBKGNDX(vc4_crtc->channel),
 		  SCALER_DISPBKGND_AUTOHS |
@@ -499,6 +539,13 @@ static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,
 	}
 }
 
+void vc4_crtc_txp_armed(struct drm_crtc_state *state)
+{
+	struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
+
+	vc4_state->txp_armed = true;
+}
+
 static void vc4_crtc_update_dlist(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -514,8 +561,11 @@ static void vc4_crtc_update_dlist(struct drm_crtc *crtc)
 		WARN_ON(drm_crtc_vblank_get(crtc) != 0);
 
 		spin_lock_irqsave(&dev->event_lock, flags);
-		vc4_crtc->event = crtc->state->event;
-		crtc->state->event = NULL;
+
+		if (!vc4_state->feed_txp || vc4_state->txp_armed) {
+			vc4_crtc->event = crtc->state->event;
+			crtc->state->event = NULL;
+		}
 
 		HVS_WRITE(SCALER_DISPLISTX(vc4_crtc->channel),
 			  vc4_state->mm.start);
@@ -533,8 +583,8 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
-	struct drm_crtc_state *state = crtc->state;
-	struct drm_display_mode *mode = &state->adjusted_mode;
+	struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state);
+	struct drm_display_mode *mode = &crtc->state->adjusted_mode;
 
 	require_hvs_enabled(dev);
 
@@ -546,15 +596,21 @@ static void vc4_crtc_atomic_enable(struct drm_crtc *crtc,
 
 	/* Turn on the scaler, which will wait for vstart to start
 	 * compositing.
+	 * When feeding the transposer, we should operate in oneshot
+	 * mode.
 	 */
 	HVS_WRITE(SCALER_DISPCTRLX(vc4_crtc->channel),

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_atomic_enable(struct drm_crtc *crtc, · line 608

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_crtc.c +3 -4
 		  VC4_SET_FIELD(mode->hdisplay, SCALER_DISPCTRLX_WIDTH) |
 		  VC4_SET_FIELD(mode->vdisplay, SCALER_DISPCTRLX_HEIGHT) |
-		  SCALER_DISPCTRLX_ENABLE);
+		  SCALER_DISPCTRLX_ENABLE |
+		  (vc4_state->feed_txp ? SCALER_DISPCTRLX_ONESHOT : 0));
 
-	/* Turn on the pixel valve, which will emit the vstart signal. */
-	CRTC_WRITE(PV_V_CONTROL,
-		   CRTC_READ(PV_V_CONTROL) | PV_VCONTROL_VIDEN);
+	/* When feeding the composer block the pixelvalve is unneeded and  

"transposer block"? composer block made me think HVS.

Quoted 44 lines
drivers/gpu/drm/vc4/vc4_crtc.c +24 -1
+	 * should not be enabled.
+	 */
+	if (!vc4_state->feed_txp)
+		CRTC_WRITE(PV_V_CONTROL,
+			   CRTC_READ(PV_V_CONTROL) | PV_VCONTROL_VIDEN);
 }
 
 static enum drm_mode_status vc4_crtc_mode_valid(struct drm_crtc *crtc,
@@ -579,8 +635,10 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
 	struct drm_plane *plane;
 	unsigned long flags;
 	const struct drm_plane_state *plane_state;
+	struct drm_connector *conn;
+	struct drm_connector_state *conn_state;
 	u32 dlist_count = 0;
-	int ret;
+	int ret, i;
 
 	/* The pixelvalve can only feed one encoder (and encoders are
 	 * 1:1 with connectors.)
@@ -600,6 +658,22 @@ static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
 	if (ret)
 		return ret;
 
+	state->no_vblank = false;
+	for_each_new_connector_in_state(state->state, conn, conn_state, i) {
+		if (conn_state->crtc != crtc)
+			continue;
+
+		/* The writeback connector is implemented using the transposer
+		 * block which is directly taking its data from the HVS FIFO.
+		 */
+		if (conn->connector_type == DRM_MODE_CONNECTOR_WRITEBACK) {
+			state->no_vblank = true;
+			vc4_state->feed_txp = true;
+		}
+
+		break;
+	}
+
 	return 0;
 }
 

drivers/gpu/drm/vc4/vc4_crtc.c static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc) · line 791

Quoted 6 lines
drivers/gpu/drm/vc4/vc4_crtc.c +2 -1
@@ -713,7 +787,8 @@ static void vc4_crtc_handle_page_flip(struct vc4_crtc *vc4_crtc)
 
 	spin_lock_irqsave(&dev->event_lock, flags);
 	if (vc4_crtc->event &&
-	    (vc4_state->mm.start == HVS_READ(SCALER_DISPLACTX(chan)))) {
+	    (vc4_state->mm.start == HVS_READ(SCALER_DISPLACTX(chan)) ||
+	     vc4_state->feed_txp)) {  

Can vc4_crtc->event even be set if vc4_state->feed_txp?

drivers/gpu/drm/vc4/vc4_regs.h line 336

Quoted 12 lines
drivers/gpu/drm/vc4/vc4_regs.h +1 -0
index d6864fa4bd14..744a689751f0 100644
@@ -330,6 +330,7 @@
 #define SCALER_DISPCTRL0                        0x00000040
 # define SCALER_DISPCTRLX_ENABLE		BIT(31)
 # define SCALER_DISPCTRLX_RESET			BIT(30)
+
 /* Generates a single frame when VSTART is seen and stops at the last
  * pixel read from the FIFO.
  */  

stray hunk?

Quoted 9 lines
drivers/gpu/drm/vc4/vc4_regs.h +9 -0
+static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
+					struct drm_connector_state *conn_state)
+{
+	struct vc4_txp *txp = connector_to_vc4_txp(conn);
+	struct drm_gem_cma_object *gem;
+	struct drm_display_mode *mode;
+	struct drm_framebuffer *fb;
+	u32 ctrl = TXP_GO | TXP_VSTART_AT_EOF | TXP_EI;
+

drivers/gpu/drm/vc4/vc4_regs.h

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_regs.h +10 -0
+	if (WARN_ON(!conn_state->writeback_job ||
+		    !conn_state->writeback_job->fb))
+		return;
+
+	mode = &conn_state->crtc->state->adjusted_mode;
+	fb = conn_state->writeback_job->fb;
+
+	switch (fb->format->format) {
+	case DRM_FORMAT_ARGB8888:
+		ctrl |= TXP_ALPHA_ENABLE;  

Optional suggestion: Have the txp_formats[] table be a struct with these register values in it.

Quoted 2 lines

All my feedback seems really minor, so with whatever components you like integrated, feel free to add:

Will fix all the things you pointed in your review.

Thanks,

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

#34 lore raw

PATCH v2 8/8 ARM: dts: bcm283x: Add Transposer block

In reply to Boris Brezillon

From: Boris Brezillon <[email protected]>

The transposer block is allowing one to write the result of the VC4 composition back to memory instead of displaying it on a screen.

---
 arch/arm/boot/dts/bcm283x.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/bcm283x.dtsi +6 -0
index ac00e730f898..740870898b1e 100644
@@ -66,6 +66,12 @@
 			clock-frequency = <1000000>;
 		};
 
+		txp@7e004000 {
+			compatible = "brcm,bcm2835-txp";
+			reg = <0x7e004000 0x20>;
+			interrupts = <1 11>;
+		};
+
 		dma: dma@7e007000 {
 			compatible = "brcm,bcm2835-dma";
 			reg = <0x7e007000 0xf00>;
Signature · 6 lines
2.14.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v2 8/8
#35 lore raw

Re: [PATCH v2 8/8] ARM: dts: bcm283x: Add Transposer block

Quoted 6 lines · Boris Brezillon

From: Boris Brezillon <[email protected]>

The transposer block is allowing one to write the result of the VC4 composition back to memory instead of displaying it on a screen.

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