Skip to contentSkip to conversation

Refactor drm_writeback_connector structure

PATCH Superseded Suraj Kandpal 5 participants 18 messages Oct 7, 2025 – Mar 12

Subsystems (12)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover Refactor drm_writeback_connector structure

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not. This is due to the inheritance limitation in C.
This series intends to solve it by moving the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. This is done in union with hdmi connector within drm_connector to save memory and since drm_connector cannot be both hdmi and writeback it serves is well.
A RFC version was floated and discussion had taken place at [1] which kicked of this more cleaner series.
We do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
This series also contains some writeback API cleanups as a consequence of writeback connector moving into drm_connector
All drivers will be expected to allocate the drm_connector. This discussion was tiggered from [2] and sits on top of Dmitry's series see [3].

[1] https://patchwork.freedesktop.org/series/152758/
[2] https://patchwork.freedesktop.org/series/152106/
[3] https://patchwork.freedesktop.org/series/152420/

Suraj Kandpal (7):
drm: writeback: Refactor drm_writeback_connector structure
drm: writeback: Modify writeback init helpers
drm: writeback: Modify drm_writeback_queue_job params
drm: writeback: Modify drm_writeback_signal_completion param
drm: writeback: Modify params for drm_writeback_get_out_fence drm/connector: Modify prepare_writeback_job helper drm/connector: Modify cleanup_writeback_job helper

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 +--
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  | 12 +--
 .../gpu/drm/arm/display/komeda/komeda_crtc.c  |  2 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  | 11 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  7 +-
 drivers/gpu/drm/drm_atomic_uapi.c             |  4 +-
 drivers/gpu/drm/drm_writeback.c               | 51 ++++++++-----
 .../drm/msm/disp/dpu1/dpu_encoder_phys_wb.c   |  9 ++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c | 10 +--
 drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.h |  4 +-
 .../gpu/drm/renesas/rcar-du/rcar_du_crtc.h    |  4 +-
 .../drm/renesas/rcar-du/rcar_du_writeback.c   | 12 ++-
 drivers/gpu/drm/vc4/vc4_txp.c                 |  8 +-
 drivers/gpu/drm/vkms/vkms_drv.h               |  2 +-
 drivers/gpu/drm/vkms/vkms_writeback.c         | 15 ++--
 include/drm/drm_connector.h                   | 69 ++++++++++++++++-
 include/drm/drm_modeset_helper_vtables.h      |  4 +-
 include/drm/drm_writeback.h                   | 76 ++-----------------
 22 files changed, 162 insertions(+), 160 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/7 drm: writeback: Refactor drm_writeback_connector structure

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well. Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to
allow them to use this connector without breaking them. The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
 .../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----
 .../drm/msm/disp/dpu1/dpu_encoder_phys_wb.c   |  3 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c | 16 +++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.h |  4 +-
 .../gpu/drm/renesas/rcar-du/rcar_du_crtc.h    |  4 +-
 .../drm/renesas/rcar-du/rcar_du_writeback.c   | 19 ++---
 drivers/gpu/drm/vc4/vc4_txp.c                 | 14 ++--
 drivers/gpu/drm/vkms/vkms_composer.c          |  2 +-
 drivers/gpu/drm/vkms/vkms_drv.h               |  2 +-
 drivers/gpu/drm/vkms/vkms_writeback.c         | 13 ++--
 include/drm/drm_connector.h                   | 69 +++++++++++++++++--
 include/drm/drm_writeback.h                   | 66 +-----------------
 23 files changed, 161 insertions(+), 142 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2 -4
index a38378c723c1..28447fcf5498 100644
@@ -6995,11 +6995,9 @@ create_stream_for_sink(struct drm_connector *connector,
 		aconnector = to_amdgpu_dm_connector(connector);
 		link = aconnector->dc_link;
 	} else {
-		struct drm_writeback_connector *wbcon = NULL;
 		struct amdgpu_dm_wb_connector *dm_wbcon = NULL;
 
-		wbcon = drm_connector_to_writeback(connector);
-		dm_wbcon = to_amdgpu_dm_wb_connector(wbcon);
+		dm_wbcon = to_amdgpu_dm_wb_connector(connector);
 		link = dm_wbcon->link;
 	}
 
@@ -10158,7 +10156,7 @@ static void dm_set_writeback(struct amdgpu_display_manager *dm,
 			      struct drm_connector *connector,
 			      struct drm_connector_state *new_con_state)
 {
-	struct drm_writeback_connector *wb_conn = drm_connector_to_writeback(connector);
+	struct drm_writeback_connector *wb_conn = &connector->writeback;
 	struct amdgpu_device *adev = dm->adev;
 	struct amdgpu_crtc *acrtc;
 	struct dc_writeback_info *wb_info;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +1 -1
index 009f206226f0..fed061477534 100644
@@ -840,7 +840,7 @@ static inline void amdgpu_dm_set_mst_status(uint8_t *status,
 #define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base)
 
 struct amdgpu_dm_wb_connector {
-	struct drm_writeback_connector base;
+	struct drm_connector base;
 	struct dc_link *link;
 };
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c +4 -4
index 80c37487ca77..8fea29720989 100644
@@ -202,9 +202,9 @@ int amdgpu_dm_wb_connector_init(struct amdgpu_display_manager *dm,
 
 	wbcon->link = link;
 
-	drm_connector_helper_add(&wbcon->base.base, &amdgpu_dm_wb_conn_helper_funcs);
+	drm_connector_helper_add(&wbcon->base, &amdgpu_dm_wb_conn_helper_funcs);
 
-	res = drmm_writeback_connector_init(&dm->adev->ddev, &wbcon->base,
+	res = drmm_writeback_connector_init(&dm->adev->ddev, &wbcon->base.writeback,
 					    &amdgpu_dm_wb_connector_funcs,
 					    encoder,
 					    amdgpu_dm_wb_formats,
@@ -216,8 +216,8 @@ int amdgpu_dm_wb_connector_init(struct amdgpu_display_manager *dm,
 	 * Some of the properties below require access to state, like bpc.
 	 * Allocate some default initial connector state with our reset helper.
 	 */
-	if (wbcon->base.base.funcs->reset)
-		wbcon->base.base.funcs->reset(&wbcon->base.base);
+	if (wbcon->base.funcs->reset)
+		wbcon->base.funcs->reset(&wbcon->base);
 
 	return 0;
 }
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +3 -3
index 2ad33559a33a..1c2ba6eeb0e5 100644
@@ -210,7 +210,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
 		struct komeda_wb_connector *wb_conn = kcrtc->wb_conn;
 
 		if (wb_conn)
-			drm_writeback_signal_completion(&wb_conn->base, 0);
+			drm_writeback_signal_completion(&wb_conn->base.writeback, 0);
 		else
 			DRM_WARN("CRTC[%d]: EOW happen but no wb_connector.\n",
 				 drm_crtc_index(&kcrtc->base));
@@ -266,9 +266,9 @@ komeda_crtc_do_flush(struct drm_crtc *crtc,
 	if (slave && has_bit(slave->id, kcrtc_st->affected_pipes))
 		komeda_pipeline_update(slave, old->state);
 
-	conn_st = wb_conn ? wb_conn->base.base.state : NULL;
+	conn_st = wb_conn ? wb_conn->base.state : NULL;
 	if (conn_st && conn_st->writeback_job)
-		drm_writeback_queue_job(&wb_conn->base, conn_st);
+		drm_writeback_queue_job(&wb_conn->base.writeback, conn_st);
 
 	/* step 2: notify the HW to kickoff the update */
 	mdev->funcs->flush(mdev, master->id, kcrtc_st->active_pipes);
drivers/gpu/drm/arm/display/komeda/komeda_kms.h +3 -3
index 83e61c4080c2..9c34302782c0 100644
@@ -53,8 +53,8 @@ struct komeda_plane_state {
  * struct komeda_wb_connector
  */
 struct komeda_wb_connector {
-	/** @base: &drm_writeback_connector */
-	struct drm_writeback_connector base;
+	/** @base: &drm_connector */
+	struct drm_connector base;
 
 	/** @wb_layer: represents associated writeback pipeline of komeda */
 	struct komeda_layer *wb_layer;
@@ -139,7 +139,7 @@ struct komeda_kms_dev {
 static inline bool is_writeback_only(struct drm_crtc_state *st)
 {
 	struct komeda_wb_connector *wb_conn = to_kcrtc(st->crtc)->wb_conn;
-	struct drm_connector *conn = wb_conn ? &wb_conn->base.base : NULL;
+	struct drm_connector *conn = wb_conn ? &wb_conn->base : NULL;
 
 	return conn && (st->connector_mask == BIT(drm_connector_index(conn)));
 }
drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c +4 -4
index 210841b4453a..69822b9be574 100644
@@ -53,7 +53,7 @@ komeda_wb_encoder_atomic_check(struct drm_encoder *encoder,
 		return -EINVAL;
 	}
 
-	wb_layer = to_kconn(to_wb_conn(conn_st->connector))->wb_layer;
+	wb_layer = to_kconn(conn_st->connector)->wb_layer;
 
 	/*
 	 * No need for a full modested when the only connector changed is the
@@ -151,7 +151,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
 
 	kwb_conn->wb_layer = kcrtc->master->wb_layer;
 
-	wb_conn = &kwb_conn->base;
+	wb_conn = &kwb_conn->base.writeback;
 
 	formats = komeda_get_layer_fourcc_list(&mdev->fmt_tbl,
 					       kwb_conn->wb_layer->layer_type,
@@ -180,9 +180,9 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
 		return err;
 	}
 
-	drm_connector_helper_add(&wb_conn->base, &komeda_wb_conn_helper_funcs);
+	drm_connector_helper_add(&kwb_conn->base, &komeda_wb_conn_helper_funcs);
 
-	info = &kwb_conn->base.base.display_info;
+	info = &kwb_conn->base.display_info;
 	info->bpc = __fls(kcrtc->master->improc->supported_color_depths);
 	info->color_formats = kcrtc->master->improc->supported_color_formats;
 
drivers/gpu/drm/arm/malidp_crtc.c +1 -1
index d72c22dcf685..10e818439637 100644
@@ -425,7 +425,7 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
 		u32 new_mask = crtc_state->connector_mask;
 
 		if ((old_mask ^ new_mask) ==
-		    (1 << drm_connector_index(&malidp->mw_connector.base)))
+		    (1 << drm_connector_index(&malidp->mw_connector)))
 			crtc_state->connectors_changed = false;
 	}
 
drivers/gpu/drm/arm/malidp_drv.h +1 -1
index bc0387876dea..aa5599467d27 100644
@@ -32,7 +32,7 @@ struct malidp_drm {
 	struct drm_device base;
 	struct malidp_hw_device *dev;
 	struct drm_crtc crtc;
-	struct drm_writeback_connector mw_connector;
+	struct drm_connector mw_connector;
 	wait_queue_head_t wq;
 	struct drm_pending_vblank_event *event;
 	atomic_t config_valid;
drivers/gpu/drm/arm/malidp_hw.c +3 -3
index 9b845d3f34e1..5a7bd27d3718 100644
@@ -1315,15 +1315,15 @@ static irqreturn_t malidp_se_irq(int irq, void *arg)
 	if (status & se->vsync_irq) {
 		switch (hwdev->mw_state) {
 		case MW_ONESHOT:
-			drm_writeback_signal_completion(&malidp->mw_connector, 0);
+			drm_writeback_signal_completion(&malidp->mw_connector.writeback, 0);
 			break;
 		case MW_STOP:
-			drm_writeback_signal_completion(&malidp->mw_connector, 0);
+			drm_writeback_signal_completion(&malidp->mw_connector.writeback, 0);
 			/* disable writeback after stop */
 			hwdev->mw_state = MW_NOT_ENABLED;
 			break;
 		case MW_RESTART:
-			drm_writeback_signal_completion(&malidp->mw_connector, 0);
+			drm_writeback_signal_completion(&malidp->mw_connector.writeback, 0);
 			fallthrough;	/* to a new start */
 		case MW_START:
 			/* writeback started, need to emulate one-shot mode */
drivers/gpu/drm/arm/malidp_mw.c +4 -4
index 182275c0c29c..ea03cb98bfb4 100644
@@ -212,7 +212,7 @@ int malidp_mw_connector_init(struct drm_device *drm)
 	if (!malidp->dev->hw->enable_memwrite)
 		return 0;
 
-	drm_connector_helper_add(&malidp->mw_connector.base,
+	drm_connector_helper_add(&malidp->mw_connector,
 				 &malidp_mw_connector_helper_funcs);
 
 	formats = get_writeback_formats(malidp, &n_formats);
@@ -228,7 +228,7 @@ int malidp_mw_connector_init(struct drm_device *drm)
 
 	encoder->possible_crtcs = 1 << drm_crtc_index(&malidp->crtc);
 
-	ret = drmm_writeback_connector_init(drm, &malidp->mw_connector,
+	ret = drmm_writeback_connector_init(drm, &malidp->mw_connector.writeback,
 					    &malidp_mw_connector_funcs,
 					    encoder,
 					    formats, n_formats);
@@ -243,8 +243,8 @@ void malidp_mw_atomic_commit(struct drm_device *drm,
 			     struct drm_atomic_state *old_state)
 {
 	struct malidp_drm *malidp = drm_to_malidp(drm);
-	struct drm_writeback_connector *mw_conn = &malidp->mw_connector;
-	struct drm_connector_state *conn_state = mw_conn->base.state;
+	struct drm_writeback_connector *mw_conn = &malidp->mw_connector.writeback;
+	struct drm_connector_state *conn_state = malidp->mw_connector.state;
 	struct malidp_hw_device *hwdev = malidp->dev;
 	struct malidp_mw_connector_state *mw_state;
 
drivers/gpu/drm/drm_atomic_uapi.c +1 -1
index 85dbdaa4a2e2..a102738a8733 100644
@@ -1293,7 +1293,7 @@ static int prepare_signaling(struct drm_device *dev,
 		f[*num_fences].out_fence_ptr = fence_ptr;
 		*fence_state = f;
 
-		wb_conn = drm_connector_to_writeback(conn);
+		wb_conn = &conn->writeback;
 		fence = drm_writeback_get_out_fence(wb_conn);
 		if (!fence)
 			return -ENOMEM;
drivers/gpu/drm/drm_writeback.c +23 -12
index ec2575c4c21b..72277127f20e 100644
@@ -89,8 +89,10 @@ static const char *drm_writeback_fence_get_driver_name(struct dma_fence *fence)
 {
 	struct drm_writeback_connector *wb_connector =
 		fence_to_wb_connector(fence);
+	struct drm_connector *connector =
+		drm_writeback_to_connector(wb_connector);
 
-	return wb_connector->base.dev->driver->name;
+	return connector->dev->driver->name;
 }
 
 static const char *
@@ -187,7 +189,8 @@ static int __drm_writeback_connector_init(struct drm_device *dev,
 					  struct drm_encoder *enc, const u32 *formats,
 					  int n_formats)
 {
-	struct drm_connector *connector = &wb_connector->base;
+	struct drm_connector *connector =
+		drm_writeback_to_connector(wb_connector);
 	struct drm_mode_config *config = &dev->mode_config;
 	struct drm_property_blob *blob;
 	int ret = create_writeback_properties(dev);
@@ -269,7 +272,8 @@ int drm_writeback_connector_init(struct drm_device *dev,
 				 struct drm_encoder *enc,
 				 const u32 *formats, int n_formats)
 {
-	struct drm_connector *connector = &wb_connector->base;
+	struct drm_connector *connector =
+		drm_writeback_to_connector(wb_connector);
 	int ret;
 
 	ret = drm_connector_init(dev, connector, con_funcs,
@@ -339,7 +343,8 @@ int drmm_writeback_connector_init(struct drm_device *dev,
 				  struct drm_encoder *enc,
 				  const u32 *formats, int n_formats)
 {
-	struct drm_connector *connector = &wb_connector->base;
+	struct drm_connector *connector =
+		drm_writeback_to_connector(wb_connector);
 	int ret;
 
 	ret = drmm_connector_init(dev, connector, con_funcs,
@@ -373,7 +378,7 @@ int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 			return -ENOMEM;
 
 		conn_state->writeback_job->connector =
-			drm_connector_to_writeback(conn_state->connector);
+			&conn_state->connector->writeback;
 	}
 
 	drm_framebuffer_assign(&conn_state->writeback_job->fb, fb);
@@ -382,13 +387,15 @@ int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 
 int drm_writeback_prepare_job(struct drm_writeback_job *job)
 {
-	struct drm_writeback_connector *connector = job->connector;
+	struct drm_writeback_connector *wb_connector = job->connector;
+	struct drm_connector *connector =
+		drm_writeback_to_connector(wb_connector);
 	const struct drm_connector_helper_funcs *funcs =
-		connector->base.helper_private;
+		connector->helper_private;
 	int ret;
 
 	if (funcs->prepare_writeback_job) {
-		ret = funcs->prepare_writeback_job(connector, job);
+		ret = funcs->prepare_writeback_job(wb_connector, job);
 		if (ret < 0)
 			return ret;
 	}
@@ -434,12 +441,14 @@ EXPORT_SYMBOL(drm_writeback_queue_job);
 
 void drm_writeback_cleanup_job(struct drm_writeback_job *job)
 {
-	struct drm_writeback_connector *connector = job->connector;
+	struct drm_writeback_connector *wb_connector = job->connector;
+	struct drm_connector *connector	=
+		drm_writeback_to_connector(wb_connector);
 	const struct drm_connector_helper_funcs *funcs =
-		connector->base.helper_private;
+		connector->helper_private;
 
 	if (job->prepared && funcs->cleanup_writeback_job)
-		funcs->cleanup_writeback_job(connector, job);
+		funcs->cleanup_writeback_job(wb_connector, job);
 
 	if (job->fb)
 		drm_framebuffer_put(job->fb);
@@ -521,8 +530,10 @@ struct dma_fence *
 drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector)
 {
 	struct dma_fence *fence;
+	struct drm_connector *connector =
+		drm_writeback_to_connector(wb_connector);
 
-	if (WARN_ON(wb_connector->base.connector_type !=
+	if (WARN_ON(connector->connector_type !=
 		    DRM_MODE_CONNECTOR_WRITEBACK))
 		return NULL;
 
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +2 -1
index 46f348972a97..8b35ba0023d7 100644
@@ -484,7 +484,8 @@ static void dpu_encoder_phys_wb_prepare_for_kickoff(
 		return;
 	}
 
-	drm_conn = &wb_enc->wb_conn->base;
+	drm_conn =
+		container_of(wb_enc->wb_conn, struct drm_connector, writeback);
 	state = drm_conn->state;
 
 	if (wb_enc->wb_conn && wb_enc->wb_job)
drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c +9 -7
index cd73468e369a..49412d2ed9aa 100644
@@ -28,8 +28,7 @@ static int dpu_wb_conn_get_modes(struct drm_connector *connector)
 static int dpu_wb_conn_atomic_check(struct drm_connector *connector,
 				    struct drm_atomic_state *state)
 {
-	struct drm_writeback_connector *wb_conn = drm_connector_to_writeback(connector);
-	struct dpu_wb_connector *dpu_wb_conn = to_dpu_wb_conn(wb_conn);
+	struct dpu_wb_connector *dpu_wb_conn = to_dpu_wb_conn(connector);
 	struct drm_connector_state *conn_state =
 		drm_atomic_get_new_connector_state(state, connector);
 	struct drm_crtc *crtc;
@@ -84,10 +83,11 @@ static const struct drm_connector_funcs dpu_wb_conn_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static int dpu_wb_conn_prepare_job(struct drm_writeback_connector *connector,
+static int dpu_wb_conn_prepare_job(struct drm_writeback_connector *wb_conn,
 		struct drm_writeback_job *job)
 {
-
+	struct drm_connector *connector =
+		container_of(wb_conn, struct drm_connector, writeback);
 	struct dpu_wb_connector *dpu_wb_conn = to_dpu_wb_conn(connector);
 
 	if (!job->fb)
@@ -98,9 +98,11 @@ static int dpu_wb_conn_prepare_job(struct drm_writeback_connector *connector,
 	return 0;
 }
 
-static void dpu_wb_conn_cleanup_job(struct drm_writeback_connector *connector,
+static void dpu_wb_conn_cleanup_job(struct drm_writeback_connector *wb_connector,
 		struct drm_writeback_job *job)
 {
+	struct drm_connector *connector =
+		container_of(wb_connector, struct drm_connector, writeback);
 	struct dpu_wb_connector *dpu_wb_conn = to_dpu_wb_conn(connector);
 
 	if (!job->fb)
@@ -128,9 +130,9 @@ int dpu_writeback_init(struct drm_device *dev, struct drm_encoder *enc,
 
 	dpu_wb_conn->maxlinewidth = maxlinewidth;
 
-	drm_connector_helper_add(&dpu_wb_conn->base.base, &dpu_wb_conn_helper_funcs);
+	drm_connector_helper_add(&dpu_wb_conn->base, &dpu_wb_conn_helper_funcs);
 
-	rc = drmm_writeback_connector_init(dev, &dpu_wb_conn->base,
+	rc = drmm_writeback_connector_init(dev, &dpu_wb_conn->base.writeback,
 					   &dpu_wb_conn_funcs, enc,
 					   format_list, num_formats);
 
drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.h +2 -2
index 4b11cca8014c..9ebf15392b20 100644
@@ -16,12 +16,12 @@
 #include "dpu_encoder_phys.h"
 
 struct dpu_wb_connector {
-	struct drm_writeback_connector base;
+	struct drm_connector base;
 	struct drm_encoder *wb_enc;
 	u32 maxlinewidth;
 };
 
-static inline struct dpu_wb_connector *to_dpu_wb_conn(struct drm_writeback_connector *conn)
+static inline struct dpu_wb_connector *to_dpu_wb_conn(struct drm_connector *conn)
 {
 	return container_of(conn, struct dpu_wb_connector, base);
 }
drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.h +2 -2
index d0f38a8b3561..11937e70e308 100644
@@ -42,7 +42,7 @@ struct rcar_du_vsp;
  * @cmm: CMM associated with this CRTC
  * @vsp: VSP feeding video to this CRTC
  * @vsp_pipe: index of the VSP pipeline feeding video to this CRTC
- * @writeback: the writeback connector
+ * @writeback: the drm connector which contains the writeback connector
  */
 struct rcar_du_crtc {
 	struct drm_crtc crtc;
@@ -72,7 +72,7 @@ struct rcar_du_crtc {
 	const char *const *sources;
 	unsigned int sources_count;
 
-	struct drm_writeback_connector writeback;
+	struct drm_connector writeback;
 };
 
 #define to_rcar_crtc(c)		container_of(c, struct rcar_du_crtc, crtc)
drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c +11 -8
index 9986a10e8114..186efe019891 100644
@@ -50,7 +50,9 @@ static int rcar_du_wb_conn_get_modes(struct drm_connector *connector)
 static int rcar_du_wb_prepare_job(struct drm_writeback_connector *connector,
 				  struct drm_writeback_job *job)
 {
-	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(connector);
+	struct drm_connector *conn =
+		drm_writeback_to_connector(connector);
+	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(conn);
 	struct rcar_du_wb_job *rjob;
 	int ret;
 
@@ -75,7 +77,9 @@ static int rcar_du_wb_prepare_job(struct drm_writeback_connector *connector,
 static void rcar_du_wb_cleanup_job(struct drm_writeback_connector *connector,
 				   struct drm_writeback_job *job)
 {
-	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(connector);
+	struct drm_connector *conn =
+		drm_writeback_to_connector(connector);
+	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(conn);
 	struct rcar_du_wb_job *rjob = job->priv;
 
 	if (!job->fb)
@@ -199,8 +203,7 @@ static const u32 writeback_formats[] = {
 int rcar_du_writeback_init(struct rcar_du_device *rcdu,
 			   struct rcar_du_crtc *rcrtc)
 {
-	struct drm_writeback_connector *wb_conn = &rcrtc->writeback;
-
+	struct drm_writeback_connector *wb_conn = &rcrtc->writeback.writeback;
 	struct drm_encoder *encoder;
 
 	encoder = drmm_plain_encoder_alloc(&rcdu->ddev, NULL,
@@ -212,7 +215,7 @@ int rcar_du_writeback_init(struct rcar_du_device *rcdu,
 
 	encoder->possible_crtcs = 1 << drm_crtc_index(&rcrtc->crtc);
 
-	drm_connector_helper_add(&wb_conn->base,
+	drm_connector_helper_add(&rcrtc->writeback,
 				 &rcar_du_wb_conn_helper_funcs);
 
 	return drmm_writeback_connector_init(&rcdu->ddev, wb_conn,
@@ -231,7 +234,7 @@ void rcar_du_writeback_setup(struct rcar_du_crtc *rcrtc,
 	struct drm_framebuffer *fb;
 	unsigned int i;
 
-	state = rcrtc->writeback.base.state;
+	state = rcrtc->writeback.state;
 	if (!state || !state->writeback_job)
 		return;
 
@@ -246,10 +249,10 @@ void rcar_du_writeback_setup(struct rcar_du_crtc *rcrtc,
 		cfg->mem[i] = sg_dma_address(rjob->sg_tables[i].sgl)
 			    + fb->offsets[i];
 
-	drm_writeback_queue_job(&rcrtc->writeback, state);
+	drm_writeback_queue_job(&rcrtc->writeback.writeback, state);
 }
 
 void rcar_du_writeback_complete(struct rcar_du_crtc *rcrtc)
 {
-	drm_writeback_signal_completion(&rcrtc->writeback, 0);
+	drm_writeback_signal_completion(&rcrtc->writeback.writeback, 0);
 }
drivers/gpu/drm/vc4/vc4_txp.c +7 -7
index fef4e4ee47cf..2428807e9714 100644
@@ -167,7 +167,7 @@ struct vc4_txp {
 	struct platform_device *pdev;
 
 	struct vc4_encoder encoder;
-	struct drm_writeback_connector connector;
+	struct drm_connector connector;
 
 	void __iomem *regs;
 };
@@ -176,7 +176,7 @@ struct vc4_txp {
 	container_of_const(_encoder, struct vc4_txp, encoder.base)
 
 #define connector_to_vc4_txp(_connector)				\
-	container_of_const(_connector, struct vc4_txp, connector.base)
+	container_of_const(_connector, struct vc4_txp, connector)
 
 static const struct debugfs_reg32 txp_regs[] = {
 	VC4_REG32(TXP_DST_PTR),
@@ -356,7 +356,7 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
 
 	TXP_WRITE(TXP_DST_CTRL, ctrl);
 
-	drm_writeback_queue_job(&txp->connector, conn_state);
+	drm_writeback_queue_job(&txp->connector.writeback, conn_state);
 
 	drm_dev_exit(idx);
 }
@@ -504,7 +504,7 @@ static irqreturn_t vc4_txp_interrupt(int irq, void *data)
 	 */
 	TXP_WRITE(TXP_DST_CTRL, TXP_READ(TXP_DST_CTRL) & ~TXP_EI);
 	vc4_crtc_handle_vblank(vc4_crtc);
-	drm_writeback_signal_completion(&txp->connector, 0);
+	drm_writeback_signal_completion(&txp->connector.writeback, 0);
 
 	return IRQ_HANDLED;
 }
@@ -598,9 +598,9 @@ static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
 	if (ret)
 		return ret;
 
-	drm_connector_helper_add(&txp->connector.base,
+	drm_connector_helper_add(&txp->connector,
 				 &vc4_txp_connector_helper_funcs);
-	ret = drmm_writeback_connector_init(drm, &txp->connector,
+	ret = drmm_writeback_connector_init(drm, &txp->connector.writeback,
 					    &vc4_txp_connector_funcs,
 					    encoder,
 					    drm_fmts, ARRAY_SIZE(drm_fmts));
@@ -622,7 +622,7 @@ static void vc4_txp_unbind(struct device *dev, struct device *master,
 {
 	struct vc4_txp *txp = dev_get_drvdata(dev);
 
-	drm_connector_cleanup(&txp->connector.base);
+	drm_connector_cleanup(&txp->connector);
 }
 
 static const struct component_ops vc4_txp_ops = {
drivers/gpu/drm/vkms/vkms_composer.c +1 -1
index fa269d279e25..4d0bafdebcd1 100644
@@ -543,7 +543,7 @@ void vkms_composer_worker(struct work_struct *work)
 		return;
 
 	if (wb_pending) {
-		drm_writeback_signal_completion(&out->wb_connector, 0);
+		drm_writeback_signal_completion(&out->wb_connector.writeback, 0);
 		spin_lock_irq(&out->composer_lock);
 		crtc_state->wb_pending = false;
 		spin_unlock_irq(&out->composer_lock);
drivers/gpu/drm/vkms/vkms_drv.h +1 -1
index fb9711e1c6fb..ab9d4a71a227 100644
@@ -213,7 +213,7 @@ struct vkms_crtc_state {
  */
 struct vkms_output {
 	struct drm_crtc crtc;
-	struct drm_writeback_connector wb_connector;
+	struct drm_connector wb_connector;
 	struct drm_encoder wb_encoder;
 	struct workqueue_struct *composer_workq;
 	spinlock_t lock;
drivers/gpu/drm/vkms/vkms_writeback.c +8 -5
index 45d69a3b85f6..6b4d1c4a1830 100644
@@ -102,10 +102,13 @@ static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector,
 	return ret;
 }
 
-static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector,
+static void vkms_wb_cleanup_job(struct drm_writeback_connector *wb_conn,
 				struct drm_writeback_job *job)
 {
 	struct vkms_writeback_job *vkmsjob = job->priv;
+	struct drm_connector *connector = container_of(wb_conn,
+						       struct drm_connector,
+						       writeback);
 	struct vkms_output *vkms_output = container_of(connector,
 						       struct vkms_output,
 						       wb_connector);
@@ -127,8 +130,8 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 	struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state,
 											 conn);
 	struct vkms_output *output = drm_crtc_to_vkms_output(connector_state->crtc);
-	struct drm_writeback_connector *wb_conn = &output->wb_connector;
-	struct drm_connector_state *conn_state = wb_conn->base.state;
+	struct drm_writeback_connector *wb_conn = &output->wb_connector.writeback;
+	struct drm_connector_state *conn_state = output->wb_connector.state;
 	struct vkms_crtc_state *crtc_state = output->composer_state;
 	struct drm_framebuffer *fb = connector_state->writeback_job->fb;
 	u16 crtc_height = crtc_state->base.mode.vdisplay;
@@ -166,7 +169,7 @@ static const struct drm_connector_helper_funcs vkms_wb_conn_helper_funcs = {
 int vkms_enable_writeback_connector(struct vkms_device *vkmsdev,
 				    struct vkms_output *vkms_output)
 {
-	struct drm_writeback_connector *wb = &vkms_output->wb_connector;
+	struct drm_writeback_connector *wb = &vkms_output->wb_connector.writeback;
 	int ret;
 
 	ret = drmm_encoder_init(&vkmsdev->drm, &vkms_output->wb_encoder,
@@ -177,7 +180,7 @@ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev,
 	vkms_output->wb_encoder.possible_clones |=
 		drm_encoder_mask(&vkms_output->wb_encoder);
 
-	drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs);
+	drm_connector_helper_add(&vkms_output->wb_connector, &vkms_wb_conn_helper_funcs);
 
 	return drmm_writeback_connector_init(&vkmsdev->drm, wb,
 					     &vkms_wb_connector_funcs,
include/drm/drm_connector.h +65 -4

81 lines not on this page · raw message

include/drm/drm_writeback.h +3 -63

79 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 1/7
#2 lore raw

Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 21 lines · Suraj Kandpal

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well. Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to
allow them to use this connector without breaking them. The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)

Quoted 13 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
 .../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----

For the komeda and malidp drivers, as well as for the drm_writeback.c changes:

[snip]

Quoted 67 lines
include/drm/drm_connector.h +55 -0
index 8f34f4b8183d..1b090e6bddc1 100644
@@ -1882,6 +1882,61 @@ struct drm_connector_cec {
 	void *data;
 };
 
+/**
+ * struct drm_writeback_connector - DRM writeback connector
+ */
+struct drm_writeback_connector {
+	/**
+	 * @pixel_formats_blob_ptr:
+	 *
+	 * DRM blob property data for the pixel formats list on writeback
+	 * connectors
+	 * See also drm_writeback_connector_init()
+	 */
+	struct drm_property_blob *pixel_formats_blob_ptr;
+
+	/** @job_lock: Protects job_queue */
+	spinlock_t job_lock;
+
+	/**
+	 * @job_queue:
+	 *
+	 * Holds a list of a connector's writeback jobs; the last item is the
+	 * most recent. The first item may be either waiting for the hardware
+	 * to begin writing, or currently being written.
+	 *
+	 * See also: drm_writeback_queue_job() and
+	 * drm_writeback_signal_completion()
+	 */
+	struct list_head job_queue;
+
+	/**
+	 * @fence_context:
+	 *
+	 * timeline context used for fence operations.
+	 */
+	unsigned int fence_context;
+	/**
+	 * @fence_lock:
+	 *
+	 * spinlock to protect the fences in the fence_context.
+	 */
+	spinlock_t fence_lock;
+	/**
+	 * @fence_seqno:
+	 *
+	 * Seqno variable used as monotonic counter for the fences
+	 * created on the connector's timeline.
+	 */
+	unsigned long fence_seqno;
+	/**
+	 * @timeline_name:
+	 *
+	 * The name of the connector's fence timeline.
+	 */
+	char timeline_name[32];
+};
+
 /**
  * struct drm_connector - central DRM connector control structure
  *

include/drm/drm_connector.h struct drm_connector { · line 2349

Quoted 8 lines
include/drm/drm_connector.h +1 -4
@@ -2291,10 +2346,16 @@ struct drm_connector {
 	 */
 	struct llist_node free_node;
 
-	/**
-	 * @hdmi: HDMI-related variable and properties.
-	 */
-	struct drm_connector_hdmi hdmi;
+	union {

This is a surprising choice. Before this patch one had to have a separate writeback connector besides the HDMI connector. Going forward it looks like you still need two connectors, one that uses the writeback member and one that uses the hdmi one. Is that intended?

I was expecting that you're going to declare the writeback member next to the hdmi, without overlap. If you do that, then you also don't need to move the struct drm_writeback declaration from the header file and it should be enough to include the drm_writeback.h file.

Best regards,
Liviu

Quoted 100 lines
include/drm/drm_connector.h +9 -0
+		/**
+		 * @hdmi: HDMI-related variable and properties.
+		 */
+		struct drm_connector_hdmi hdmi;
+		/**
+		 * @writeback: Writeback related valriables.
+		 */
+		struct drm_writeback_connector writeback;
+	};
 
 	/**
 	 * @hdmi_audio: HDMI codec properties and non-DRM state.
include/drm/drm_writeback.h +3 -63
index 958466a05e60..702141099520 100644
@@ -15,66 +15,6 @@
 #include <drm/drm_encoder.h>
 #include <linux/workqueue.h>
 
-/**
- * struct drm_writeback_connector - DRM writeback connector
- */
-struct drm_writeback_connector {
-	/**
-	 * @base: base drm_connector object
-	 */
-	struct drm_connector base;
-
-	/**
-	 * @pixel_formats_blob_ptr:
-	 *
-	 * DRM blob property data for the pixel formats list on writeback
-	 * connectors
-	 * See also drm_writeback_connector_init()
-	 */
-	struct drm_property_blob *pixel_formats_blob_ptr;
-
-	/** @job_lock: Protects job_queue */
-	spinlock_t job_lock;
-
-	/**
-	 * @job_queue:
-	 *
-	 * Holds a list of a connector's writeback jobs; the last item is the
-	 * most recent. The first item may be either waiting for the hardware
-	 * to begin writing, or currently being written.
-	 *
-	 * See also: drm_writeback_queue_job() and
-	 * drm_writeback_signal_completion()
-	 */
-	struct list_head job_queue;
-
-	/**
-	 * @fence_context:
-	 *
-	 * timeline context used for fence operations.
-	 */
-	unsigned int fence_context;
-	/**
-	 * @fence_lock:
-	 *
-	 * spinlock to protect the fences in the fence_context.
-	 */
-	spinlock_t fence_lock;
-	/**
-	 * @fence_seqno:
-	 *
-	 * Seqno variable used as monotonic counter for the fences
-	 * created on the connector's timeline.
-	 */
-	unsigned long fence_seqno;
-	/**
-	 * @timeline_name:
-	 *
-	 * The name of the connector's fence timeline.
-	 */
-	char timeline_name[32];
-};
-
 /**
  * struct drm_writeback_job - DRM writeback job
  */
@@ -131,10 +71,10 @@ struct drm_writeback_job {
 	void *priv;
 };
 
-static inline struct drm_writeback_connector *
-drm_connector_to_writeback(struct drm_connector *connector)
+static inline struct drm_connector *
+drm_writeback_to_connector(struct drm_writeback_connector *wb_connector)
 {
-	return container_of(connector, struct drm_writeback_connector, base);
+	return container_of(wb_connector, struct drm_connector, writeback);
 }
 
 int drm_writeback_connector_init(struct drm_device *dev,
Signature · 1 line
2.34.1
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
#3 lore raw

RE: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 129 lines

Subject: Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 22 lines · Suraj Kandpal

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well.
Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to allow them to use this connector without breaking them.
The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)

Quoted 13 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
.../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----

For the komeda and malidp drivers, as well as for the drm_writeback.c changes:

[snip]

Quoted 66 lines
include/drm/drm_connector.h +54 -0
index 8f34f4b8183d..1b090e6bddc1 100644
@@ -1882,6 +1882,61 @@ struct drm_connector_cec {
 	void *data;
 };
 
+/**
+ * struct drm_writeback_connector - DRM writeback connector  */
+struct drm_writeback_connector {
+	/**
+	 * @pixel_formats_blob_ptr:
+	 *
+	 * DRM blob property data for the pixel formats list on writeback
+	 * connectors
+	 * See also drm_writeback_connector_init()
+	 */
+	struct drm_property_blob *pixel_formats_blob_ptr;
+
+	/** @job_lock: Protects job_queue */
+	spinlock_t job_lock;
+
+	/**
+	 * @job_queue:
+	 *
+	 * Holds a list of a connector's writeback jobs; the last item is the
+	 * most recent. The first item may be either waiting for the hardware
+	 * to begin writing, or currently being written.
+	 *
+	 * See also: drm_writeback_queue_job() and
+	 * drm_writeback_signal_completion()
+	 */
+	struct list_head job_queue;
+
+	/**
+	 * @fence_context:
+	 *
+	 * timeline context used for fence operations.
+	 */
+	unsigned int fence_context;
+	/**
+	 * @fence_lock:
+	 *
+	 * spinlock to protect the fences in the fence_context.
+	 */
+	spinlock_t fence_lock;
+	/**
+	 * @fence_seqno:
+	 *
+	 * Seqno variable used as monotonic counter for the fences
+	 * created on the connector's timeline.
+	 */
+	unsigned long fence_seqno;
+	/**
+	 * @timeline_name:
+	 *
+	 * The name of the connector's fence timeline.
+	 */
+	char timeline_name[32];
+};
+
 /**
  * struct drm_connector - central DRM connector control structure
  *

include/drm/drm_connector.h struct drm_connector { · line 2349

Quoted 8 lines
include/drm/drm_connector.h +1 -4
@@ -2291,10 +2346,16 @@ struct drm_connector {
 	 */
 	struct llist_node free_node;
 
-	/**
-	 * @hdmi: HDMI-related variable and properties.
-	 */
-	struct drm_connector_hdmi hdmi;
+	union {

This is a surprising choice. Before this patch one had to have a separate writeback connector besides the HDMI connector. Going forward it looks like you still need two connectors, one that uses the writeback member and one that uses the hdmi one. Is that intended?

Quoted 4 lines

I was expecting that you're going to declare the writeback member next to the hdmi, without overlap. If you do that, then you also don't need to move the struct drm_writeback declaration from the header file and it should be enough to include the drm_writeback.h file.

Hi,
Thanks for the review
The reason for this came from the discussion on previous patches and was suggested by Dmitry. The idea is that a connector can never be both an HDMI and writeback connector at the same time Hence we save space if we pack them together.

Regards,
Suraj Kandpal

Quoted 116 lines

Best regards,
Liviu

Quoted 84 lines
include/drm/drm_connector.h +9 -0
+		/**
+		 * @hdmi: HDMI-related variable and properties.
+		 */
+		struct drm_connector_hdmi hdmi;
+		/**
+		 * @writeback: Writeback related valriables.
+		 */
+		struct drm_writeback_connector writeback;
+	};
 
 	/**
 	 * @hdmi_audio: HDMI codec properties and non-DRM state.
include/drm/drm_writeback.h +0 -60
index 958466a05e60..702141099520 100644
@@ -15,66 +15,6 @@
 #include <drm/drm_encoder.h>
 #include <linux/workqueue.h>
 
-/**
- * struct drm_writeback_connector - DRM writeback connector
- */
-struct drm_writeback_connector {
-	/**
-	 * @base: base drm_connector object
-	 */
-	struct drm_connector base;
-
-	/**
-	 * @pixel_formats_blob_ptr:
-	 *
-	 * DRM blob property data for the pixel formats list on writeback
-	 * connectors
-	 * See also drm_writeback_connector_init()
-	 */
-	struct drm_property_blob *pixel_formats_blob_ptr;
-
-	/** @job_lock: Protects job_queue */
-	spinlock_t job_lock;
-
-	/**
-	 * @job_queue:
-	 *
-	 * Holds a list of a connector's writeback jobs; the last item is the
-	 * most recent. The first item may be either waiting for the hardware
-	 * to begin writing, or currently being written.
-	 *
-	 * See also: drm_writeback_queue_job() and
-	 * drm_writeback_signal_completion()
-	 */
-	struct list_head job_queue;
-
-	/**
-	 * @fence_context:
-	 *
-	 * timeline context used for fence operations.
-	 */
-	unsigned int fence_context;
-	/**
-	 * @fence_lock:
-	 *
-	 * spinlock to protect the fences in the fence_context.
-	 */
-	spinlock_t fence_lock;
-	/**
-	 * @fence_seqno:
-	 *
-	 * Seqno variable used as monotonic counter for the fences
-	 * created on the connector's timeline.
-	 */
-	unsigned long fence_seqno;
-	/**
-	 * @timeline_name:
-	 *
-	 * The name of the connector's fence timeline.
-	 */
-	char timeline_name[32];
-};
-
 /**
  * struct drm_writeback_job - DRM writeback job
  */

include/drm/drm_writeback.h struct drm_writeback_job { · line 137

Quoted 10 lines
include/drm/drm_writeback.h +3 -3
@@ -131,10 +71,10 @@ struct drm_writeback_job {
 	void *priv;
 };
 
-static inline struct drm_writeback_connector *
-drm_connector_to_writeback(struct drm_connector *connector)
+static inline struct drm_connector *
+drm_writeback_to_connector(struct drm_writeback_connector
+*wb_connector)
 {
-	return container_of(connector, struct drm_writeback_connector,

base);

Quoted 7 lines
include/drm/drm_writeback.h +1 -1
+	return container_of(wb_connector, struct drm_connector, writeback);
 }
 
 int drm_writeback_connector_init(struct drm_device *dev,
--

2.34.1

--
====================

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
maintainer
#4 lore raw

Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 134 lines · Suraj
Quoted 129 lines

Subject: Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 22 lines · Suraj Kandpal

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well.
Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to allow them to use this connector without breaking them.
The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)

Quoted 13 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
.../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----

For the komeda and malidp drivers, as well as for the drm_writeback.c changes:

[snip]

Quoted 66 lines
include/drm/drm_connector.h +54 -0
index 8f34f4b8183d..1b090e6bddc1 100644
@@ -1882,6 +1882,61 @@ struct drm_connector_cec {
 	void *data;
 };
 
+/**
+ * struct drm_writeback_connector - DRM writeback connector  */
+struct drm_writeback_connector {
+	/**
+	 * @pixel_formats_blob_ptr:
+	 *
+	 * DRM blob property data for the pixel formats list on writeback
+	 * connectors
+	 * See also drm_writeback_connector_init()
+	 */
+	struct drm_property_blob *pixel_formats_blob_ptr;
+
+	/** @job_lock: Protects job_queue */
+	spinlock_t job_lock;
+
+	/**
+	 * @job_queue:
+	 *
+	 * Holds a list of a connector's writeback jobs; the last item is the
+	 * most recent. The first item may be either waiting for the hardware
+	 * to begin writing, or currently being written.
+	 *
+	 * See also: drm_writeback_queue_job() and
+	 * drm_writeback_signal_completion()
+	 */
+	struct list_head job_queue;
+
+	/**
+	 * @fence_context:
+	 *
+	 * timeline context used for fence operations.
+	 */
+	unsigned int fence_context;
+	/**
+	 * @fence_lock:
+	 *
+	 * spinlock to protect the fences in the fence_context.
+	 */
+	spinlock_t fence_lock;
+	/**
+	 * @fence_seqno:
+	 *
+	 * Seqno variable used as monotonic counter for the fences
+	 * created on the connector's timeline.
+	 */
+	unsigned long fence_seqno;
+	/**
+	 * @timeline_name:
+	 *
+	 * The name of the connector's fence timeline.
+	 */
+	char timeline_name[32];
+};
+
 /**
  * struct drm_connector - central DRM connector control structure
  *

include/drm/drm_connector.h struct drm_connector { · line 2349

Quoted 8 lines
include/drm/drm_connector.h +1 -4
@@ -2291,10 +2346,16 @@ struct drm_connector {
 	 */
 	struct llist_node free_node;
 
-	/**
-	 * @hdmi: HDMI-related variable and properties.
-	 */
-	struct drm_connector_hdmi hdmi;
+	union {

This is a surprising choice. Before this patch one had to have a separate writeback connector besides the HDMI connector. Going forward it looks like you still need two connectors, one that uses the writeback member and one that uses the hdmi one. Is that intended?

Quoted 4 lines

I was expecting that you're going to declare the writeback member next to the hdmi, without overlap. If you do that, then you also don't need to move the struct drm_writeback declaration from the header file and it should be enough to include the drm_writeback.h file.

Quoted 5 lines

Hi,
Thanks for the review
The reason for this came from the discussion on previous patches and was suggested by Dmitry. The idea is that a connector can never be both an HDMI and writeback connector at the same time Hence we save space if we pack them together.

Hmm, but you can still have all the CEC and HDMI codecs data in that connector, which feels strange. Also, what's the issue with having a connector that has both a valid HDMI state and an associated writeback at the same time (i.e. don't use the union)? Writing back the memory the output that goes to HDMI is valid, right?

Maybe that is not something that you considered, but with this patch (without union) we can drop the need to have a separate connector just for writeback. We're breaking user space compatibility, true, but it feels like a good change to be able to attach a writeback to any connector and get its output. The drivers that don't support that can reject the commit that attaches the writeback to the existing connector.

Best regards,
Liviu

Quoted 120 lines

Regards,
Suraj Kandpal

Quoted 116 lines

Best regards,
Liviu

Quoted 84 lines
include/drm/drm_connector.h +9 -0
+		/**
+		 * @hdmi: HDMI-related variable and properties.
+		 */
+		struct drm_connector_hdmi hdmi;
+		/**
+		 * @writeback: Writeback related valriables.
+		 */
+		struct drm_writeback_connector writeback;
+	};
 
 	/**
 	 * @hdmi_audio: HDMI codec properties and non-DRM state.
include/drm/drm_writeback.h +0 -60
index 958466a05e60..702141099520 100644
@@ -15,66 +15,6 @@
 #include <drm/drm_encoder.h>
 #include <linux/workqueue.h>
 
-/**
- * struct drm_writeback_connector - DRM writeback connector
- */
-struct drm_writeback_connector {
-	/**
-	 * @base: base drm_connector object
-	 */
-	struct drm_connector base;
-
-	/**
-	 * @pixel_formats_blob_ptr:
-	 *
-	 * DRM blob property data for the pixel formats list on writeback
-	 * connectors
-	 * See also drm_writeback_connector_init()
-	 */
-	struct drm_property_blob *pixel_formats_blob_ptr;
-
-	/** @job_lock: Protects job_queue */
-	spinlock_t job_lock;
-
-	/**
-	 * @job_queue:
-	 *
-	 * Holds a list of a connector's writeback jobs; the last item is the
-	 * most recent. The first item may be either waiting for the hardware
-	 * to begin writing, or currently being written.
-	 *
-	 * See also: drm_writeback_queue_job() and
-	 * drm_writeback_signal_completion()
-	 */
-	struct list_head job_queue;
-
-	/**
-	 * @fence_context:
-	 *
-	 * timeline context used for fence operations.
-	 */
-	unsigned int fence_context;
-	/**
-	 * @fence_lock:
-	 *
-	 * spinlock to protect the fences in the fence_context.
-	 */
-	spinlock_t fence_lock;
-	/**
-	 * @fence_seqno:
-	 *
-	 * Seqno variable used as monotonic counter for the fences
-	 * created on the connector's timeline.
-	 */
-	unsigned long fence_seqno;
-	/**
-	 * @timeline_name:
-	 *
-	 * The name of the connector's fence timeline.
-	 */
-	char timeline_name[32];
-};
-
 /**
  * struct drm_writeback_job - DRM writeback job
  */

include/drm/drm_writeback.h struct drm_writeback_job { · line 137

Quoted 10 lines
include/drm/drm_writeback.h +3 -3
@@ -131,10 +71,10 @@ struct drm_writeback_job {
 	void *priv;
 };
 
-static inline struct drm_writeback_connector *
-drm_connector_to_writeback(struct drm_connector *connector)
+static inline struct drm_connector *
+drm_writeback_to_connector(struct drm_writeback_connector
+*wb_connector)
 {
-	return container_of(connector, struct drm_writeback_connector,

base);

Quoted 7 lines
include/drm/drm_writeback.h +1 -1
+	return container_of(wb_connector, struct drm_connector, writeback);
 }
 
 int drm_writeback_connector_init(struct drm_device *dev,
--

2.34.1

--
====================

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
#5 lore raw

Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 142 lines · Liviu Dudau
Quoted 134 lines · Suraj
Quoted 129 lines

Subject: Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 22 lines · Suraj Kandpal

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well.
Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to allow them to use this connector without breaking them.
The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)

Quoted 13 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
.../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----

For the komeda and malidp drivers, as well as for the drm_writeback.c changes:

[snip]

Quoted 66 lines
include/drm/drm_connector.h +54 -0
index 8f34f4b8183d..1b090e6bddc1 100644
@@ -1882,6 +1882,61 @@ struct drm_connector_cec {
  void *data;
 };
 
+/**
+ * struct drm_writeback_connector - DRM writeback connector  */
+struct drm_writeback_connector {
+ /**
+  * @pixel_formats_blob_ptr:
+  *
+  * DRM blob property data for the pixel formats list on writeback
+  * connectors
+  * See also drm_writeback_connector_init()
+  */
+ struct drm_property_blob *pixel_formats_blob_ptr;
+
+ /** @job_lock: Protects job_queue */
+ spinlock_t job_lock;
+
+ /**
+  * @job_queue:
+  *
+  * Holds a list of a connector's writeback jobs; the last item is the
+  * most recent. The first item may be either waiting for the hardware
+  * to begin writing, or currently being written.
+  *
+  * See also: drm_writeback_queue_job() and
+  * drm_writeback_signal_completion()
+  */
+ struct list_head job_queue;
+
+ /**
+  * @fence_context:
+  *
+  * timeline context used for fence operations.
+  */
+ unsigned int fence_context;
+ /**
+  * @fence_lock:
+  *
+  * spinlock to protect the fences in the fence_context.
+  */
+ spinlock_t fence_lock;
+ /**
+  * @fence_seqno:
+  *
+  * Seqno variable used as monotonic counter for the fences
+  * created on the connector's timeline.
+  */
+ unsigned long fence_seqno;
+ /**
+  * @timeline_name:
+  *
+  * The name of the connector's fence timeline.
+  */
+ char timeline_name[32];
+};
+
 /**
  * struct drm_connector - central DRM connector control structure
  *

include/drm/drm_connector.h struct drm_connector { · line 2349

Quoted 8 lines
include/drm/drm_connector.h +1 -4
@@ -2291,10 +2346,16 @@ struct drm_connector {
   */
  struct llist_node free_node;
 
- /**
-  * @hdmi: HDMI-related variable and properties.
-  */
- struct drm_connector_hdmi hdmi;
+ union {

This is a surprising choice. Before this patch one had to have a separate writeback connector besides the HDMI connector. Going forward it looks like you still need two connectors, one that uses the writeback member and one that uses the hdmi one. Is that intended?

Quoted 4 lines

I was expecting that you're going to declare the writeback member next to the hdmi, without overlap. If you do that, then you also don't need to move the struct drm_writeback declaration from the header file and it should be enough to include the drm_writeback.h file.

Quoted 5 lines

Hi,
Thanks for the review
The reason for this came from the discussion on previous patches and was suggested by Dmitry. The idea is that a connector can never be both an HDMI and writeback connector at the same time Hence we save space if we pack them together.

Quoted 5 lines

Hmm, but you can still have all the CEC and HDMI codecs data in that connector, which feels strange. Also, what's the issue with having a connector that has both a valid HDMI state and an associated writeback at the same time (i.e. don't use the union)? Writing back the memory the output that goes to HDMI is valid, right?

Writing back to memory requires a separate connector (with separate setup). The CRTC should also support outputting data to both HDMI _and_ Writeback connectors at the same time (aka cloning). Not all configurations are possible, writeback requires additional bandwidth, etc., etc.

Quoted 6 lines

Maybe that is not something that you considered, but with this patch (without union) we can drop the need to have a separate connector just for writeback. We're breaking user space compatibility, true, but it feels like a good change to be able to attach a writeback to any connector and get its output. The drivers that don't support that can reject the commit that attaches the writeback to the existing connector.

Well... No. It's not how it is being handled in the (existing) hardware. Nor does it make it easier to handle resources for the writeback.

Signature · 2 lines
With best wishes
Dmitry
maintainer
#6 lore raw

Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 162 lines · Dmitry Baryshkov
Quoted 142 lines · Liviu Dudau
Quoted 134 lines · Suraj
Quoted 129 lines

Subject: Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 22 lines · Suraj Kandpal

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well.
Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to allow them to use this connector without breaking them.
The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)

Quoted 13 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
.../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----

For the komeda and malidp drivers, as well as for the drm_writeback.c changes:

[snip]

Quoted 66 lines
include/drm/drm_connector.h +54 -0
index 8f34f4b8183d..1b090e6bddc1 100644
@@ -1882,6 +1882,61 @@ struct drm_connector_cec {
  void *data;
 };
 
+/**
+ * struct drm_writeback_connector - DRM writeback connector  */
+struct drm_writeback_connector {
+ /**
+  * @pixel_formats_blob_ptr:
+  *
+  * DRM blob property data for the pixel formats list on writeback
+  * connectors
+  * See also drm_writeback_connector_init()
+  */
+ struct drm_property_blob *pixel_formats_blob_ptr;
+
+ /** @job_lock: Protects job_queue */
+ spinlock_t job_lock;
+
+ /**
+  * @job_queue:
+  *
+  * Holds a list of a connector's writeback jobs; the last item is the
+  * most recent. The first item may be either waiting for the hardware
+  * to begin writing, or currently being written.
+  *
+  * See also: drm_writeback_queue_job() and
+  * drm_writeback_signal_completion()
+  */
+ struct list_head job_queue;
+
+ /**
+  * @fence_context:
+  *
+  * timeline context used for fence operations.
+  */
+ unsigned int fence_context;
+ /**
+  * @fence_lock:
+  *
+  * spinlock to protect the fences in the fence_context.
+  */
+ spinlock_t fence_lock;
+ /**
+  * @fence_seqno:
+  *
+  * Seqno variable used as monotonic counter for the fences
+  * created on the connector's timeline.
+  */
+ unsigned long fence_seqno;
+ /**
+  * @timeline_name:
+  *
+  * The name of the connector's fence timeline.
+  */
+ char timeline_name[32];
+};
+
 /**
  * struct drm_connector - central DRM connector control structure
  *

include/drm/drm_connector.h struct drm_connector { · line 2349

Quoted 8 lines
include/drm/drm_connector.h +1 -4
@@ -2291,10 +2346,16 @@ struct drm_connector {
   */
  struct llist_node free_node;
 
- /**
-  * @hdmi: HDMI-related variable and properties.
-  */
- struct drm_connector_hdmi hdmi;
+ union {

This is a surprising choice. Before this patch one had to have a separate writeback connector besides the HDMI connector. Going forward it looks like you still need two connectors, one that uses the writeback member and one that uses the hdmi one. Is that intended?

Quoted 4 lines

I was expecting that you're going to declare the writeback member next to the hdmi, without overlap. If you do that, then you also don't need to move the struct drm_writeback declaration from the header file and it should be enough to include the drm_writeback.h file.

Quoted 5 lines

Hi,
Thanks for the review
The reason for this came from the discussion on previous patches and was suggested by Dmitry. The idea is that a connector can never be both an HDMI and writeback connector at the same time Hence we save space if we pack them together.

Quoted 5 lines

Hmm, but you can still have all the CEC and HDMI codecs data in that connector, which feels strange. Also, what's the issue with having a connector that has both a valid HDMI state and an associated writeback at the same time (i.e. don't use the union)? Writing back the memory the output that goes to HDMI is valid, right?

Writing back to memory requires a separate connector (with separate setup). The CRTC should also support outputting data to both HDMI _and_ Writeback connectors at the same time (aka cloning). Not all configurations are possible, writeback requires additional bandwidth, etc., etc.

Quoted 6 lines

Maybe that is not something that you considered, but with this patch (without union) we can drop the need to have a separate connector just for writeback. We're breaking user space compatibility, true, but it feels like a good change to be able to attach a writeback to any connector and get its output. The drivers that don't support that can reject the commit that attaches the writeback to the existing connector.

Quoted 3 lines

Well... No. It's not how it is being handled in the (existing) hardware. Nor does it make it easier to handle resources for the writeback.

Which (existing) hardware? Komeda can do it mainly because it doesn't have an HDMI connector, but an output that can be cloned to writeback while it is being sent out on a bus to an encoder. You have to remember that writeback is a connector because we didn't have a better concept for it. It doesn't have to be a separate connector from an HDMI or eDP or DP.

Best regards,
Liviu

Quoted 4 lines
Signature · 3 lines
-- 
With best wishes
Dmitry
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
#7 lore raw

Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 164 lines · Liviu Dudau
Quoted 162 lines · Dmitry Baryshkov
Quoted 142 lines · Liviu Dudau
Quoted 134 lines · Suraj
Quoted 129 lines

Subject: Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 22 lines · Suraj Kandpal

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well.
Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to allow them to use this connector without breaking them.
The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)

Quoted 13 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
.../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----

For the komeda and malidp drivers, as well as for the drm_writeback.c changes:

[snip]

Quoted 66 lines
include/drm/drm_connector.h +54 -0
index 8f34f4b8183d..1b090e6bddc1 100644
@@ -1882,6 +1882,61 @@ struct drm_connector_cec {
  void *data;
 };
 
+/**
+ * struct drm_writeback_connector - DRM writeback connector  */
+struct drm_writeback_connector {
+ /**
+  * @pixel_formats_blob_ptr:
+  *
+  * DRM blob property data for the pixel formats list on writeback
+  * connectors
+  * See also drm_writeback_connector_init()
+  */
+ struct drm_property_blob *pixel_formats_blob_ptr;
+
+ /** @job_lock: Protects job_queue */
+ spinlock_t job_lock;
+
+ /**
+  * @job_queue:
+  *
+  * Holds a list of a connector's writeback jobs; the last item is the
+  * most recent. The first item may be either waiting for the hardware
+  * to begin writing, or currently being written.
+  *
+  * See also: drm_writeback_queue_job() and
+  * drm_writeback_signal_completion()
+  */
+ struct list_head job_queue;
+
+ /**
+  * @fence_context:
+  *
+  * timeline context used for fence operations.
+  */
+ unsigned int fence_context;
+ /**
+  * @fence_lock:
+  *
+  * spinlock to protect the fences in the fence_context.
+  */
+ spinlock_t fence_lock;
+ /**
+  * @fence_seqno:
+  *
+  * Seqno variable used as monotonic counter for the fences
+  * created on the connector's timeline.
+  */
+ unsigned long fence_seqno;
+ /**
+  * @timeline_name:
+  *
+  * The name of the connector's fence timeline.
+  */
+ char timeline_name[32];
+};
+
 /**
  * struct drm_connector - central DRM connector control structure
  *

include/drm/drm_connector.h struct drm_connector { · line 2349

Quoted 8 lines
include/drm/drm_connector.h +1 -4
@@ -2291,10 +2346,16 @@ struct drm_connector {
   */
  struct llist_node free_node;
 
- /**
-  * @hdmi: HDMI-related variable and properties.
-  */
- struct drm_connector_hdmi hdmi;
+ union {

This is a surprising choice. Before this patch one had to have a separate writeback connector besides the HDMI connector. Going forward it looks like you still need two connectors, one that uses the writeback member and one that uses the hdmi one. Is that intended?

Quoted 4 lines

I was expecting that you're going to declare the writeback member next to the hdmi, without overlap. If you do that, then you also don't need to move the struct drm_writeback declaration from the header file and it should be enough to include the drm_writeback.h file.

Quoted 5 lines

Hi,
Thanks for the review
The reason for this came from the discussion on previous patches and was suggested by Dmitry. The idea is that a connector can never be both an HDMI and writeback connector at the same time Hence we save space if we pack them together.

Quoted 5 lines

Hmm, but you can still have all the CEC and HDMI codecs data in that connector, which feels strange. Also, what's the issue with having a connector that has both a valid HDMI state and an associated writeback at the same time (i.e. don't use the union)? Writing back the memory the output that goes to HDMI is valid, right?

Writing back to memory requires a separate connector (with separate setup). The CRTC should also support outputting data to both HDMI _and_ Writeback connectors at the same time (aka cloning). Not all configurations are possible, writeback requires additional bandwidth, etc., etc.

Quoted 6 lines

Maybe that is not something that you considered, but with this patch (without union) we can drop the need to have a separate connector just for writeback. We're breaking user space compatibility, true, but it feels like a good change to be able to attach a writeback to any connector and get its output. The drivers that don't support that can reject the commit that attaches the writeback to the existing connector.

Quoted 8 lines
Quoted 3 lines

Well... No. It's not how it is being handled in the (existing) hardware. Nor does it make it easier to handle resources for the writeback.

Which (existing) hardware? Komeda can do it mainly because it doesn't have an HDMI connector, but an output that can be cloned to writeback while it is being sent out on a bus to an encoder. You have to remember that writeback is a connector because we didn't have a better concept for it. It doesn't have to be a separate connector from an HDMI or eDP or DP.

drm/msm. It requires a separate setup for the Writeback, which is described as an encoder. As such, we need a separate connector for the writeback.

Signature · 2 lines
With best wishes
Dmitry
#8 lore raw

RE: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

In reply to Liviu Dudau
Quoted 10 lines

Subject: Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 6 lines · Dmitry Baryshkov
Quoted 5 lines · Liviu Dudau
Quoted 3 lines · Suraj
Quoted 3 lines

Subject: Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 45 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Suraj Kandpal
Quoted 5 lines

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance

in C.

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 18 lines

To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well. Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present. Modify drivers using the drm_writeback_connector to allow them to use this connector without breaking them.
The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative
(Dmitry)

Quoted 13 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  6 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  2 +-
.../drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c  |  8 +--
.../gpu/drm/arm/display/komeda/komeda_crtc.c  |  6 +-
 .../gpu/drm/arm/display/komeda/komeda_kms.h   |  6 +-
 .../arm/display/komeda/komeda_wb_connector.c  |  8 +--
 drivers/gpu/drm/arm/malidp_crtc.c             |  2 +-
 drivers/gpu/drm/arm/malidp_drv.h              |  2 +-
 drivers/gpu/drm/arm/malidp_hw.c               |  6 +-
 drivers/gpu/drm/arm/malidp_mw.c               |  8 +--
 drivers/gpu/drm/drm_atomic_uapi.c             |  2 +-
 drivers/gpu/drm/drm_writeback.c               | 35 ++++++----

For the komeda and malidp drivers, as well as for the drm_writeback.c
changes:

Hi Liviu,
I am planning to refresh this series.
Can I take this Rb for the whole series or just this patch.

Regards,
Suraj Kandpal

Quoted 150 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines

[snip]

Quoted 71 lines
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 8f34f4b8183d..1b090e6bddc1 100644

include/drm/drm_connector.h +55 -0
@@ -1882,6 +1882,61 @@ struct drm_connector_cec {
  void *data;
 };
 
+/**
+ * struct drm_writeback_connector - DRM writeback connector
+*/ struct drm_writeback_connector {
+ /**
+  * @pixel_formats_blob_ptr:
+  *
+  * DRM blob property data for the pixel formats list on
+writeback
+  * connectors
+  * See also drm_writeback_connector_init()
+  */
+ struct drm_property_blob *pixel_formats_blob_ptr;
+
+ /** @job_lock: Protects job_queue */ spinlock_t job_lock;
+
+ /**
+  * @job_queue:
+  *
+  * Holds a list of a connector's writeback jobs; the last
+ item is the
+  * most recent. The first item may be either waiting for the
+ hardware
+  * to begin writing, or currently being written.
+  *
+  * See also: drm_writeback_queue_job() and
+  * drm_writeback_signal_completion()  */ struct list_head
+ job_queue;
+
+ /**
+  * @fence_context:
+  *
+  * timeline context used for fence operations.
+  */
+ unsigned int fence_context;
+ /**
+  * @fence_lock:
+  *
+  * spinlock to protect the fences in the fence_context.
+  */
+ spinlock_t fence_lock;
+ /**
+  * @fence_seqno:
+  *
+  * Seqno variable used as monotonic counter for the fences
+  * created on the connector's timeline.
+  */
+ unsigned long fence_seqno;
+ /**
+  * @timeline_name:
+  *
+  * The name of the connector's fence timeline.
+  */
+ char timeline_name[32];
+};
+
 /**
  * struct drm_connector - central DRM connector control structure
  *
@@ -2291,10 +2346,16 @@ struct drm_connector {
   */
  struct llist_node free_node;
 
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/drm/drm_connector.h struct drm_connector { · line 2349

Quoted 5 lines
include/drm/drm_connector.h +1 -4
- /**
-  * @hdmi: HDMI-related variable and properties.
-  */
- struct drm_connector_hdmi hdmi;
+ union {

This is a surprising choice. Before this patch one had to have a separate writeback connector besides the HDMI connector. Going forward it looks like you still need two connectors, one that uses the writeback member and one that uses the hdmi one. Is that

intended?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I was expecting that you're going to declare the writeback member next to the hdmi, without overlap. If you do that, then you also don't need to move the struct drm_writeback declaration from the header file and it should be enough to include the

drm_writeback.h file.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi,
Thanks for the review
The reason for this came from the discussion on previous patches and was

suggested by Dmitry.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The idea is that a connector can never be both an HDMI and writeback connector at the same time Hence we save space if we pack

them together.

Quoted 4 lines
Quoted 4 lines

Hmm, but you can still have all the CEC and HDMI codecs data in that connector, which feels strange. Also, what's the issue with having a connector that has both a valid HDMI state and an associated writeback at

the same time (i.e.

Quoted 15 lines
Quoted 2 lines

don't use the union)? Writing back the memory the output that goes to HDMI is valid, right?

Writing back to memory requires a separate connector (with separate setup). The CRTC should also support outputting data to both HDMI _and_ Writeback connectors at the same time (aka cloning). Not all configurations are possible, writeback requires additional bandwidth, etc., etc.

Quoted 6 lines

Maybe that is not something that you considered, but with this patch (without union) we can drop the need to have a separate connector just for writeback. We're breaking user space compatibility, true, but it feels like a good change to be able to attach a writeback to any connector and get its output. The drivers that don't support that can

reject the commit that attaches the writeback to the existing connector.

Quoted 4 lines

Well... No. It's not how it is being handled in the (existing) hardware. Nor does it make it easier to handle resources for the writeback.

Which (existing) hardware? Komeda can do it mainly because it doesn't have an HDMI connector, but an output that can be cloned to writeback while it is being sent out on a bus to an encoder.
You have to remember that writeback is a connector because we didn't have a better concept for it. It doesn't have to be a separate connector from an HDMI or eDP or DP.

Best regards,
Liviu

Quoted 4 lines

--
With best wishes
Dmitry

--
====================

| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
maintainer Reviewed-by on v2 1/7
#9 lore raw

Re: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

In reply to Suraj Kandpal

Le 07/10/2025 à 07:45, Suraj Kandpal a écrit :

Quoted 22 lines

Some drivers cannot work with the current design where the connector is embedded within the drm_writeback_connector such as Intel and some drivers that can get it working end up adding a lot of checks all around the code to check if it's a writeback conenctor or not, this is due to the limitation of inheritance in C.
To solve this move the drm_writeback_connector within the drm_connector and remove the drm_connector base which was in drm_writeback_connector. Make this drm_writeback_connector a union with hdmi connector to save memory and since a connector can never be both writeback and hdmi it should serve us well. Do all other required modifications that come with these changes along with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to
allow them to use this connector without breaking them. The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)
---

[...]

Quoted 3 lines
  drivers/gpu/drm/vkms/vkms_composer.c          |  2 +-
  drivers/gpu/drm/vkms/vkms_drv.h               |  2 +-
  drivers/gpu/drm/vkms/vkms_writeback.c         | 13 ++--

For the VKMS part:

Thanks,
Louis Chauvet

--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#10 lore raw

RE: [PATCH v2 1/7] drm: writeback: Refactor drm_writeback_connector structure

Quoted 15 lines
Quoted 12 lines

with addition of new function which returns the drm_connector when drm_writeback_connector is present.
Modify drivers using the drm_writeback_connector to allow them to use this connector without breaking them.
The drivers modified here are amd, komeda, mali, vc4, vkms, rcar_du, msm

---
V1 -> V2: Use &connector->writeback, make commit message imperative (Dmitry)
---

[...]

Quoted 8 lines
Quoted 3 lines
  drivers/gpu/drm/vkms/vkms_composer.c          |  2 +-
  drivers/gpu/drm/vkms/vkms_drv.h               |  2 +-
  drivers/gpu/drm/vkms/vkms_writeback.c         | 13 ++--

For the VKMS part:

Hi Louis,
I am planning to refresh this series can I take this RB for the whole series or just this patch

Regards,
Suraj Kandpal

Quoted 7 lines

Thanks,
Louis Chauvet

--
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#11 lore raw

PATCH v2 2/7 drm: writeback: Modify writeback init helpers

In reply to Suraj Kandpal

Now with drm_writeback_connector moved to drm_connector it makes more sense use drm_connector as an argument rather than drm_writeback_connector. The writeback connector can easily be derived from drm_connector.

---
V1 -> V2: Fix comment, use connector->writeback instead of the function (Dmitry)

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c   |  2 +-
 .../drm/arm/display/komeda/komeda_wb_connector.c   |  5 +----
 drivers/gpu/drm/arm/malidp_mw.c                    |  2 +-
 drivers/gpu/drm/drm_writeback.c                    | 14 ++++++--------
 drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c      |  2 +-
 .../gpu/drm/renesas/rcar-du/rcar_du_writeback.c    |  3 +--
 drivers/gpu/drm/vc4/vc4_txp.c                      |  2 +-
 drivers/gpu/drm/vkms/vkms_writeback.c              |  4 ++--
 include/drm/drm_writeback.h                        |  4 ++--
 9 files changed, 16 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c +1 -1
index 8fea29720989..84a9c1d2bd8e 100644
@@ -204,7 +204,7 @@ int amdgpu_dm_wb_connector_init(struct amdgpu_display_manager *dm,
 
 	drm_connector_helper_add(&wbcon->base, &amdgpu_dm_wb_conn_helper_funcs);
 
-	res = drmm_writeback_connector_init(&dm->adev->ddev, &wbcon->base.writeback,
+	res = drmm_writeback_connector_init(&dm->adev->ddev, &wbcon->base,
 					    &amdgpu_dm_wb_connector_funcs,
 					    encoder,
 					    amdgpu_dm_wb_formats,
drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c +1 -4
index 69822b9be574..d3dd07491630 100644
@@ -135,7 +135,6 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
 {
 	struct komeda_dev *mdev = kms->base.dev_private;
 	struct komeda_wb_connector *kwb_conn;
-	struct drm_writeback_connector *wb_conn;
 	struct drm_display_info *info;
 	struct drm_encoder *encoder;
 
@@ -151,8 +150,6 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
 
 	kwb_conn->wb_layer = kcrtc->master->wb_layer;
 
-	wb_conn = &kwb_conn->base.writeback;
-
 	formats = komeda_get_layer_fourcc_list(&mdev->fmt_tbl,
 					       kwb_conn->wb_layer->layer_type,
 					       &n_formats);
@@ -170,7 +167,7 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
 
 	encoder->possible_crtcs = BIT(drm_crtc_index(&kcrtc->base));
 
-	err = drmm_writeback_connector_init(&kms->base, wb_conn,
+	err = drmm_writeback_connector_init(&kms->base, &kwb_conn->base,
 					    &komeda_wb_connector_funcs,
 					    encoder,
 					    formats, n_formats);
drivers/gpu/drm/arm/malidp_mw.c +1 -1
index ea03cb98bfb4..a36a4c86a99e 100644
@@ -228,7 +228,7 @@ int malidp_mw_connector_init(struct drm_device *drm)
 
 	encoder->possible_crtcs = 1 << drm_crtc_index(&malidp->crtc);
 
-	ret = drmm_writeback_connector_init(drm, &malidp->mw_connector.writeback,
+	ret = drmm_writeback_connector_init(drm, &malidp->mw_connector,
 					    &malidp_mw_connector_funcs,
 					    encoder,
 					    formats, n_formats);
drivers/gpu/drm/drm_writeback.c +6 -8
index 72277127f20e..3436a742d403 100644
@@ -242,7 +242,7 @@ static int __drm_writeback_connector_init(struct drm_device *dev,
  * a custom encoder
  *
  * @dev: DRM device
- * @wb_connector: Writeback connector to initialize
+ * @connector: Drm connector which contains the writeback connector to initialize
  * @enc: handle to the already initialized drm encoder
  * @con_funcs: Connector funcs vtable
  * @formats: Array of supported pixel formats for the writeback engine
@@ -267,13 +267,12 @@ static int __drm_writeback_connector_init(struct drm_device *dev,
  * Returns: 0 on success, or a negative error code
  */
 int drm_writeback_connector_init(struct drm_device *dev,
-				 struct drm_writeback_connector *wb_connector,
+				 struct drm_connector *connector,
 				 const struct drm_connector_funcs *con_funcs,
 				 struct drm_encoder *enc,
 				 const u32 *formats, int n_formats)
 {
-	struct drm_connector *connector =
-		drm_writeback_to_connector(wb_connector);
+	struct drm_writeback_connector *wb_connector = &connector->writeback;
 	int ret;
 
 	ret = drm_connector_init(dev, connector, con_funcs,
@@ -322,7 +321,7 @@ static void drm_writeback_connector_cleanup(struct drm_device *dev,
  * a custom encoder
  *
  * @dev: DRM device
- * @wb_connector: Writeback connector to initialize
+ * @connector: Drm connector containing the writeback connector to initialize
  * @con_funcs: Connector funcs vtable
  * @enc: Encoder to connect this writeback connector
  * @formats: Array of supported pixel formats for the writeback engine
@@ -338,13 +337,12 @@ static void drm_writeback_connector_cleanup(struct drm_device *dev,
  * Returns: 0 on success, or a negative error code
  */
 int drmm_writeback_connector_init(struct drm_device *dev,
-				  struct drm_writeback_connector *wb_connector,
+				  struct drm_connector *connector,
 				  const struct drm_connector_funcs *con_funcs,
 				  struct drm_encoder *enc,
 				  const u32 *formats, int n_formats)
 {
-	struct drm_connector *connector =
-		drm_writeback_to_connector(wb_connector);
+	struct drm_writeback_connector *wb_connector = &connector->writeback;
 	int ret;
 
 	ret = drmm_connector_init(dev, connector, con_funcs,
drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c +1 -1
index 49412d2ed9aa..8d29e09952c5 100644
@@ -132,7 +132,7 @@ int dpu_writeback_init(struct drm_device *dev, struct drm_encoder *enc,
 
 	drm_connector_helper_add(&dpu_wb_conn->base, &dpu_wb_conn_helper_funcs);
 
-	rc = drmm_writeback_connector_init(dev, &dpu_wb_conn->base.writeback,
+	rc = drmm_writeback_connector_init(dev, &dpu_wb_conn->base,
 					   &dpu_wb_conn_funcs, enc,
 					   format_list, num_formats);
 
drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c +1 -2
index 186efe019891..fe6764620739 100644
@@ -203,7 +203,6 @@ static const u32 writeback_formats[] = {
 int rcar_du_writeback_init(struct rcar_du_device *rcdu,
 			   struct rcar_du_crtc *rcrtc)
 {
-	struct drm_writeback_connector *wb_conn = &rcrtc->writeback.writeback;
 	struct drm_encoder *encoder;
 
 	encoder = drmm_plain_encoder_alloc(&rcdu->ddev, NULL,
@@ -218,7 +217,7 @@ int rcar_du_writeback_init(struct rcar_du_device *rcdu,
 	drm_connector_helper_add(&rcrtc->writeback,
 				 &rcar_du_wb_conn_helper_funcs);
 
-	return drmm_writeback_connector_init(&rcdu->ddev, wb_conn,
+	return drmm_writeback_connector_init(&rcdu->ddev, &rcrtc->writeback,
 					     &rcar_du_wb_conn_funcs,
 					     encoder,
 					     writeback_formats,
drivers/gpu/drm/vc4/vc4_txp.c +1 -1
index 2428807e9714..a53e3aa41f63 100644
@@ -600,7 +600,7 @@ static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
 
 	drm_connector_helper_add(&txp->connector,
 				 &vc4_txp_connector_helper_funcs);
-	ret = drmm_writeback_connector_init(drm, &txp->connector.writeback,
+	ret = drmm_writeback_connector_init(drm, &txp->connector,
 					    &vc4_txp_connector_funcs,
 					    encoder,
 					    drm_fmts, ARRAY_SIZE(drm_fmts));
drivers/gpu/drm/vkms/vkms_writeback.c +2 -2
index 6b4d1c4a1830..d897a83e3b36 100644
@@ -169,7 +169,6 @@ static const struct drm_connector_helper_funcs vkms_wb_conn_helper_funcs = {
 int vkms_enable_writeback_connector(struct vkms_device *vkmsdev,
 				    struct vkms_output *vkms_output)
 {
-	struct drm_writeback_connector *wb = &vkms_output->wb_connector.writeback;
 	int ret;
 
 	ret = drmm_encoder_init(&vkmsdev->drm, &vkms_output->wb_encoder,
@@ -182,7 +181,8 @@ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev,
 
 	drm_connector_helper_add(&vkms_output->wb_connector, &vkms_wb_conn_helper_funcs);
 
-	return drmm_writeback_connector_init(&vkmsdev->drm, wb,
+	return drmm_writeback_connector_init(&vkmsdev->drm,
+					     &vkms_output->wb_connector,
 					     &vkms_wb_connector_funcs,
 					     &vkms_output->wb_encoder,
 					     vkms_wb_formats,
include/drm/drm_writeback.h +2 -2
index 702141099520..c6960c7e634e 100644
@@ -78,13 +78,13 @@ drm_writeback_to_connector(struct drm_writeback_connector *wb_connector)
 }
 
 int drm_writeback_connector_init(struct drm_device *dev,
-				 struct drm_writeback_connector *wb_connector,
+				 struct drm_connector *connector,
 				 const struct drm_connector_funcs *con_funcs,
 				 struct drm_encoder *enc,
 				 const u32 *formats, int n_formats);
 
 int drmm_writeback_connector_init(struct drm_device *dev,
-				  struct drm_writeback_connector *wb_connector,
+				  struct drm_connector *connector,
 				  const struct drm_connector_funcs *con_funcs,
 				  struct drm_encoder *enc,
 				  const u32 *formats, int n_formats);
Signature · 1 line
2.34.1
#12 lore raw

PATCH v2 3/7 drm: writeback: Modify drm_writeback_queue_job params

In reply to Suraj Kandpal

Move to using drm_connector structure instead of drm_writeback_connector since this now writeback resides within drm_connector.
This helps make sure drivers change drm_writeback_connector using helpers provided by drm core.

---
V1 -> V2: Use &connector->writeback (Dmitry)

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c   | 2 +-
 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c    | 2 +-
 drivers/gpu/drm/arm/malidp_mw.c                     | 3 +--
 drivers/gpu/drm/drm_writeback.c                     | 6 ++++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 4 ++--
 drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c | 2 +-
 drivers/gpu/drm/vc4/vc4_txp.c                       | 2 +-
 drivers/gpu/drm/vkms/vkms_writeback.c               | 3 +--
 include/drm/drm_writeback.h                         | 2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index 28447fcf5498..f9e7f8ab4e0b 100644
@@ -10247,7 +10247,7 @@ static void dm_set_writeback(struct amdgpu_display_manager *dm,
 
 	acrtc->wb_pending = true;
 	acrtc->wb_conn = wb_conn;
-	drm_writeback_queue_job(wb_conn, new_con_state);
+	drm_writeback_queue_job(connector, new_con_state);
 }
 
 static void amdgpu_dm_update_hdcp(struct drm_atomic_state *state)
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +1 -1
index 1c2ba6eeb0e5..b3f1d3ca23aa 100644
@@ -268,7 +268,7 @@ komeda_crtc_do_flush(struct drm_crtc *crtc,
 
 	conn_st = wb_conn ? wb_conn->base.state : NULL;
 	if (conn_st && conn_st->writeback_job)
-		drm_writeback_queue_job(&wb_conn->base.writeback, conn_st);
+		drm_writeback_queue_job(&wb_conn->base, conn_st);
 
 	/* step 2: notify the HW to kickoff the update */
 	mdev->funcs->flush(mdev, master->id, kcrtc_st->active_pipes);
drivers/gpu/drm/arm/malidp_mw.c +1 -2
index a36a4c86a99e..5d3eceae4651 100644
@@ -243,7 +243,6 @@ void malidp_mw_atomic_commit(struct drm_device *drm,
 			     struct drm_atomic_state *old_state)
 {
 	struct malidp_drm *malidp = drm_to_malidp(drm);
-	struct drm_writeback_connector *mw_conn = &malidp->mw_connector.writeback;
 	struct drm_connector_state *conn_state = malidp->mw_connector.state;
 	struct malidp_hw_device *hwdev = malidp->dev;
 	struct malidp_mw_connector_state *mw_state;
@@ -263,7 +262,7 @@ void malidp_mw_atomic_commit(struct drm_device *drm,
 				     &mw_state->addrs[0],
 				     mw_state->format);
 
-		drm_writeback_queue_job(mw_conn, conn_state);
+		drm_writeback_queue_job(&malidp->mw_connector, conn_state);
 		hwdev->hw->enable_memwrite(hwdev, mw_state->addrs,
 					   mw_state->pitches, mw_state->n_planes,
 					   fb->width, fb->height, mw_state->format,
drivers/gpu/drm/drm_writeback.c +4 -2
index 3436a742d403..b1ba859c36d1 100644
@@ -405,7 +405,8 @@ EXPORT_SYMBOL(drm_writeback_prepare_job);
 
 /**
  * drm_writeback_queue_job - Queue a writeback job for later signalling
- * @wb_connector: The writeback connector to queue a job on
+ * @connector: The drm connector  which contains the writeback connector to
+ * queue a job on
  * @conn_state: The connector state containing the job to queue
  *
  * This function adds the job contained in @conn_state to the job_queue for a
@@ -422,9 +423,10 @@ EXPORT_SYMBOL(drm_writeback_prepare_job);
  *
  * See also: drm_writeback_signal_completion()
  */
-void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
+void drm_writeback_queue_job(struct drm_connector *connector,
 			     struct drm_connector_state *conn_state)
 {
+	struct drm_writeback_connector *wb_connector = &connector->writeback;
 	struct drm_writeback_job *job;
 	unsigned long flags;
 
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +2 -2
index 8b35ba0023d7..e7216afa6bac 100644
@@ -485,11 +485,11 @@ static void dpu_encoder_phys_wb_prepare_for_kickoff(
 	}
 
 	drm_conn =
-		container_of(wb_enc->wb_conn, struct drm_connector, writeback);
+		drm_writeback_to_connector(wb_enc->wb_conn);
 	state = drm_conn->state;
 
 	if (wb_enc->wb_conn && wb_enc->wb_job)
-		drm_writeback_queue_job(wb_enc->wb_conn, state);
+		drm_writeback_queue_job(drm_conn, state);
 
 	dpu_encoder_phys_wb_setup(phys_enc);
 
drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c +1 -1
index fe6764620739..4e8fa7a5bc32 100644
@@ -248,7 +248,7 @@ void rcar_du_writeback_setup(struct rcar_du_crtc *rcrtc,
 		cfg->mem[i] = sg_dma_address(rjob->sg_tables[i].sgl)
 			    + fb->offsets[i];
 
-	drm_writeback_queue_job(&rcrtc->writeback.writeback, state);
+	drm_writeback_queue_job(&rcrtc->writeback, state);
 }
 
 void rcar_du_writeback_complete(struct rcar_du_crtc *rcrtc)
drivers/gpu/drm/vc4/vc4_txp.c +1 -1
index a53e3aa41f63..8afd1a50ab98 100644
@@ -356,7 +356,7 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
 
 	TXP_WRITE(TXP_DST_CTRL, ctrl);
 
-	drm_writeback_queue_job(&txp->connector.writeback, conn_state);
+	drm_writeback_queue_job(&txp->connector, conn_state);
 
 	drm_dev_exit(idx);
 }
drivers/gpu/drm/vkms/vkms_writeback.c +1 -2
index d897a83e3b36..28d361517a55 100644
@@ -130,7 +130,6 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 	struct drm_connector_state *connector_state = drm_atomic_get_new_connector_state(state,
 											 conn);
 	struct vkms_output *output = drm_crtc_to_vkms_output(connector_state->crtc);
-	struct drm_writeback_connector *wb_conn = &output->wb_connector.writeback;
 	struct drm_connector_state *conn_state = output->wb_connector.state;
 	struct vkms_crtc_state *crtc_state = output->composer_state;
 	struct drm_framebuffer *fb = connector_state->writeback_job->fb;
@@ -152,7 +151,7 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn,
 	crtc_state->active_writeback = active_wb;
 	crtc_state->wb_pending = true;
 	spin_unlock_irq(&output->composer_lock);
-	drm_writeback_queue_job(wb_conn, connector_state);
+	drm_writeback_queue_job(&output->wb_connector, connector_state);
 	active_wb->pixel_write = get_pixel_write_function(wb_format);
 	drm_rect_init(&wb_frame_info->src, 0, 0, crtc_width, crtc_height);
 	drm_rect_init(&wb_frame_info->dst, 0, 0, crtc_width, crtc_height);
include/drm/drm_writeback.h +1 -1
index c6960c7e634e..b4c11d380df0 100644
@@ -94,7 +94,7 @@ int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 
 int drm_writeback_prepare_job(struct drm_writeback_job *job);
 
-void drm_writeback_queue_job(struct drm_writeback_connector *wb_connector,
+void drm_writeback_queue_job(struct drm_connector *wb_connector,
 			     struct drm_connector_state *conn_state);
 
 void drm_writeback_cleanup_job(struct drm_writeback_job *job);
Signature · 1 line
2.34.1
#13 lore raw

PATCH v2 4/7 drm: writeback: Modify drm_writeback_signal_completion param

In reply to Suraj Kandpal

Move to using drm_connector instead of drm_writeback_connector since it now resides within drm_connector. This will also help make sure drivers do not need to access drm_writeback_connector as much.

---
V1 -> V2: Use &connector->writeback (Dmitry)

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c   | 2 +-
 drivers/gpu/drm/arm/display/komeda/komeda_crtc.c    | 2 +-
 drivers/gpu/drm/arm/malidp_hw.c                     | 6 +++---
 drivers/gpu/drm/drm_writeback.c                     | 6 ++++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 4 ++--
 drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c | 2 +-
 drivers/gpu/drm/vc4/vc4_txp.c                       | 2 +-
 drivers/gpu/drm/vkms/vkms_composer.c                | 2 +-
 include/drm/drm_writeback.h                         | 2 +-
 9 files changed, 15 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index f9e7f8ab4e0b..dc5a733202d2 100644
@@ -679,7 +679,7 @@ static void dm_crtc_high_irq(void *interrupt_params)
 					     100LL, (v_total * stream->timing.h_total));
 				mdelay(1000 / refresh_hz);
 
-				drm_writeback_signal_completion(acrtc->wb_conn, 0);
+				drm_writeback_signal_completion(acrtc->connector, 0);
 				dc_stream_fc_disable_writeback(adev->dm.dc,
 							       acrtc->dm_irq_params.stream, 0);
 			}
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +1 -1
index b3f1d3ca23aa..aa5f2776d6c0 100644
@@ -210,7 +210,7 @@ void komeda_crtc_handle_event(struct komeda_crtc   *kcrtc,
 		struct komeda_wb_connector *wb_conn = kcrtc->wb_conn;
 
 		if (wb_conn)
-			drm_writeback_signal_completion(&wb_conn->base.writeback, 0);
+			drm_writeback_signal_completion(&wb_conn->base, 0);
 		else
 			DRM_WARN("CRTC[%d]: EOW happen but no wb_connector.\n",
 				 drm_crtc_index(&kcrtc->base));
drivers/gpu/drm/arm/malidp_hw.c +3 -3
index 5a7bd27d3718..9b845d3f34e1 100644
@@ -1315,15 +1315,15 @@ static irqreturn_t malidp_se_irq(int irq, void *arg)
 	if (status & se->vsync_irq) {
 		switch (hwdev->mw_state) {
 		case MW_ONESHOT:
-			drm_writeback_signal_completion(&malidp->mw_connector.writeback, 0);
+			drm_writeback_signal_completion(&malidp->mw_connector, 0);
 			break;
 		case MW_STOP:
-			drm_writeback_signal_completion(&malidp->mw_connector.writeback, 0);
+			drm_writeback_signal_completion(&malidp->mw_connector, 0);
 			/* disable writeback after stop */
 			hwdev->mw_state = MW_NOT_ENABLED;
 			break;
 		case MW_RESTART:
-			drm_writeback_signal_completion(&malidp->mw_connector.writeback, 0);
+			drm_writeback_signal_completion(&malidp->mw_connector, 0);
 			fallthrough;	/* to a new start */
 		case MW_START:
 			/* writeback started, need to emulate one-shot mode */
drivers/gpu/drm/drm_writeback.c +4 -2
index b1ba859c36d1..da7be54f5b13 100644
@@ -478,7 +478,8 @@ static void cleanup_work(struct work_struct *work)
 
 /**
  * drm_writeback_signal_completion - Signal the completion of a writeback job
- * @wb_connector: The writeback connector whose job is complete
+ * @connector: The drm connector whicha has the drm_writeback_connector whose
+ * job is complete
  * @status: Status code to set in the writeback out_fence (0 for success)
  *
  * Drivers should call this to signal the completion of a previously queued
@@ -493,10 +494,11 @@ static void cleanup_work(struct work_struct *work)
  * See also: drm_writeback_queue_job()
  */
 void
-drm_writeback_signal_completion(struct drm_writeback_connector *wb_connector,
+drm_writeback_signal_completion(struct drm_connector *connector,
 				int status)
 {
 	unsigned long flags;
+	struct drm_writeback_connector *wb_connector = &connector->writeback;
 	struct drm_writeback_job *job;
 	struct dma_fence *out_fence;
 
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +2 -2
index e7216afa6bac..b0b7aa3a8b78 100644
@@ -373,7 +373,7 @@ static void dpu_encoder_phys_wb_done_irq(void *arg)
 	spin_unlock_irqrestore(phys_enc->enc_spinlock, lock_flags);
 
 	if (wb_enc->wb_conn)
-		drm_writeback_signal_completion(wb_enc->wb_conn, 0);
+		drm_writeback_signal_completion(drm_writeback_to_connector(wb_enc->wb_conn), 0);
 
 	/* Signal any waiting atomic commit thread */
 	wake_up_all(&phys_enc->pending_kickoff_wq);
@@ -434,7 +434,7 @@ static void _dpu_encoder_phys_wb_handle_wbdone_timeout(
 	phys_enc->enable_state = DPU_ENC_ERR_NEEDS_HW_RESET;
 
 	if (wb_enc->wb_conn)
-		drm_writeback_signal_completion(wb_enc->wb_conn, 0);
+		drm_writeback_signal_completion(drm_writeback_to_connector(wb_enc->wb_conn), 0);
 
 	dpu_encoder_frame_done_callback(phys_enc->parent, phys_enc, frame_event);
 }
drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c +1 -1
index 4e8fa7a5bc32..1ec9b4242c39 100644
@@ -253,5 +253,5 @@ void rcar_du_writeback_setup(struct rcar_du_crtc *rcrtc,
 
 void rcar_du_writeback_complete(struct rcar_du_crtc *rcrtc)
 {
-	drm_writeback_signal_completion(&rcrtc->writeback.writeback, 0);
+	drm_writeback_signal_completion(&rcrtc->writeback, 0);
 }
drivers/gpu/drm/vc4/vc4_txp.c +1 -1
index 8afd1a50ab98..ace13bfa1994 100644
@@ -504,7 +504,7 @@ static irqreturn_t vc4_txp_interrupt(int irq, void *data)
 	 */
 	TXP_WRITE(TXP_DST_CTRL, TXP_READ(TXP_DST_CTRL) & ~TXP_EI);
 	vc4_crtc_handle_vblank(vc4_crtc);
-	drm_writeback_signal_completion(&txp->connector.writeback, 0);
+	drm_writeback_signal_completion(&txp->connector, 0);
 
 	return IRQ_HANDLED;
 }
drivers/gpu/drm/vkms/vkms_composer.c +1 -1
index 4d0bafdebcd1..fa269d279e25 100644
@@ -543,7 +543,7 @@ void vkms_composer_worker(struct work_struct *work)
 		return;
 
 	if (wb_pending) {
-		drm_writeback_signal_completion(&out->wb_connector.writeback, 0);
+		drm_writeback_signal_completion(&out->wb_connector, 0);
 		spin_lock_irq(&out->composer_lock);
 		crtc_state->wb_pending = false;
 		spin_unlock_irq(&out->composer_lock);
include/drm/drm_writeback.h +1 -1
index b4c11d380df0..5e8ab51c2da4 100644
@@ -100,7 +100,7 @@ void drm_writeback_queue_job(struct drm_connector *wb_connector,
 void drm_writeback_cleanup_job(struct drm_writeback_job *job);
 
 void
-drm_writeback_signal_completion(struct drm_writeback_connector *wb_connector,
+drm_writeback_signal_completion(struct drm_connector *connector,
 				int status);
 
 struct dma_fence *
Signature · 1 line
2.34.1
#14 lore raw

PATCH v2 5/7 drm: writeback: Modify params for drm_writeback_get_out_fence

In reply to Suraj Kandpal

Use drm_connector instead of drm_writeback_connector since it now resides within drm_connector and also helps make sure drm_wrtieback_connector is being modified mostly by drm core provided helpers.

---
V1 -> V2: Use &connector->writeback (Dmitry)

---
 drivers/gpu/drm/drm_atomic_uapi.c | 4 +---
 drivers/gpu/drm/drm_writeback.c   | 6 +++---
 include/drm/drm_writeback.h       | 2 +-
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +1 -3
index a102738a8733..c38dfc61fb88 100644
@@ -1271,7 +1271,6 @@ 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_out_fence_state *f;
 		struct dma_fence *fence;
 		s32 __user *fence_ptr;
@@ -1293,8 +1292,7 @@ static int prepare_signaling(struct drm_device *dev,
 		f[*num_fences].out_fence_ptr = fence_ptr;
 		*fence_state = f;
 
-		wb_conn = &conn->writeback;
-		fence = drm_writeback_get_out_fence(wb_conn);
+		fence = drm_writeback_get_out_fence(conn);
 		if (!fence)
 			return -ENOMEM;
 
drivers/gpu/drm/drm_writeback.c +3 -3
index da7be54f5b13..da2acb932ac0 100644
@@ -529,11 +529,11 @@ drm_writeback_signal_completion(struct drm_connector *connector,
 EXPORT_SYMBOL(drm_writeback_signal_completion);
 
 struct dma_fence *
-drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector)
+drm_writeback_get_out_fence(struct drm_connector *connector)
 {
 	struct dma_fence *fence;
-	struct drm_connector *connector =
-		drm_writeback_to_connector(wb_connector);
+	struct drm_writeback_connector *wb_connector =
+		&connector->writeback;
 
 	if (WARN_ON(connector->connector_type !=
 		    DRM_MODE_CONNECTOR_WRITEBACK))
include/drm/drm_writeback.h +1 -1
index 5e8ab51c2da4..2afa48ea7c00 100644
@@ -104,5 +104,5 @@ drm_writeback_signal_completion(struct drm_connector *connector,
 				int status);
 
 struct dma_fence *
-drm_writeback_get_out_fence(struct drm_writeback_connector *wb_connector);
+drm_writeback_get_out_fence(struct drm_connector *connector);
 #endif
Signature · 1 line
2.34.1
#15 lore raw

PATCH v2 6/7 drm/connector: Modify prepare_writeback_job helper

In reply to Suraj Kandpal

Pass drm_connector to prepare_writeback_job since drm_writeback_connector now resides within drm_connector. It also makes it uniform with params passed to other drm_connector_helper_funcs.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c | 2 +-
 drivers/gpu/drm/drm_writeback.c                      | 2 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c        | 4 +---
 drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c  | 6 ++----
 drivers/gpu/drm/vkms/vkms_writeback.c                | 2 +-
 include/drm/drm_modeset_helper_vtables.h             | 2 +-
 6 files changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c +1 -1
index 84a9c1d2bd8e..d02f5d20f3b1 100644
@@ -80,7 +80,7 @@ static int amdgpu_dm_wb_connector_get_modes(struct drm_connector *connector)
 	return drm_add_modes_noedid(connector, 3840, 2160);
 }
 
-static int amdgpu_dm_wb_prepare_job(struct drm_writeback_connector *wb_connector,
+static int amdgpu_dm_wb_prepare_job(struct drm_connector *connector,
 			       struct drm_writeback_job *job)
 {
 	struct amdgpu_framebuffer *afb;
drivers/gpu/drm/drm_writeback.c +1 -1
index da2acb932ac0..62a11252b05f 100644
@@ -393,7 +393,7 @@ int drm_writeback_prepare_job(struct drm_writeback_job *job)
 	int ret;
 
 	if (funcs->prepare_writeback_job) {
-		ret = funcs->prepare_writeback_job(wb_connector, job);
+		ret = funcs->prepare_writeback_job(connector, job);
 		if (ret < 0)
 			return ret;
 	}
drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c +1 -3
index 8d29e09952c5..26a93c3cc454 100644
@@ -83,11 +83,9 @@ static const struct drm_connector_funcs dpu_wb_conn_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static int dpu_wb_conn_prepare_job(struct drm_writeback_connector *wb_conn,
+static int dpu_wb_conn_prepare_job(struct drm_connector *connector,
 		struct drm_writeback_job *job)
 {
-	struct drm_connector *connector =
-		container_of(wb_conn, struct drm_connector, writeback);
 	struct dpu_wb_connector *dpu_wb_conn = to_dpu_wb_conn(connector);
 
 	if (!job->fb)
drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c +2 -4
index 1ec9b4242c39..725981cc1d0c 100644
@@ -47,12 +47,10 @@ static int rcar_du_wb_conn_get_modes(struct drm_connector *connector)
 				    dev->mode_config.max_height);
 }
 
-static int rcar_du_wb_prepare_job(struct drm_writeback_connector *connector,
+static int rcar_du_wb_prepare_job(struct drm_connector *connector,
 				  struct drm_writeback_job *job)
 {
-	struct drm_connector *conn =
-		drm_writeback_to_connector(connector);
-	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(conn);
+	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(connector);
 	struct rcar_du_wb_job *rjob;
 	int ret;
 
drivers/gpu/drm/vkms/vkms_writeback.c +1 -1
index 28d361517a55..032896fb5c5b 100644
@@ -71,7 +71,7 @@ static int vkms_wb_connector_get_modes(struct drm_connector *connector)
 				    dev->mode_config.max_height);
 }
 
-static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector,
+static int vkms_wb_prepare_job(struct drm_connector *connector,
 			       struct drm_writeback_job *job)
 {
 	struct vkms_writeback_job *vkmsjob;
include/drm/drm_modeset_helper_vtables.h +1 -1
index fe32854b7ffe..806230129ad9 100644
@@ -1142,7 +1142,7 @@ struct drm_connector_helper_funcs {
 	 *
 	 * This callback is used by the atomic modeset helpers.
 	 */
-	int (*prepare_writeback_job)(struct drm_writeback_connector *connector,
+	int (*prepare_writeback_job)(struct drm_connector *connector,
 				     struct drm_writeback_job *job);
 	/**
 	 * @cleanup_writeback_job:
Signature · 1 line
2.34.1
#16 lore raw

PATCH v2 7/7 drm/connector: Modify cleanup_writeback_job helper

In reply to Suraj Kandpal

Pass drm_connector to prepare_writeback_job since drm_writeback_connector now resides within drm_connector. It also makes it uniform with params passed to other drm_connector_helper_funcs.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c | 4 ++--
 drivers/gpu/drm/drm_writeback.c                      | 2 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c        | 4 +---
 drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c  | 6 ++----
 drivers/gpu/drm/vkms/vkms_writeback.c                | 5 +----
 include/drm/drm_modeset_helper_vtables.h             | 2 +-
 6 files changed, 8 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c +2 -2
index d02f5d20f3b1..bf1ecf5d3027 100644
@@ -144,8 +144,8 @@ static int amdgpu_dm_wb_prepare_job(struct drm_connector *connector,
 	return r;
 }
 
-static void amdgpu_dm_wb_cleanup_job(struct drm_writeback_connector *connector,
-				struct drm_writeback_job *job)
+static void amdgpu_dm_wb_cleanup_job(struct drm_connector *connector,
+				     struct drm_writeback_job *job)
 {
 	struct amdgpu_bo *rbo;
 	int r;
drivers/gpu/drm/drm_writeback.c +1 -1
index 62a11252b05f..e071ae71973c 100644
@@ -448,7 +448,7 @@ void drm_writeback_cleanup_job(struct drm_writeback_job *job)
 		connector->helper_private;
 
 	if (job->prepared && funcs->cleanup_writeback_job)
-		funcs->cleanup_writeback_job(wb_connector, job);
+		funcs->cleanup_writeback_job(connector, job);
 
 	if (job->fb)
 		drm_framebuffer_put(job->fb);
drivers/gpu/drm/msm/disp/dpu1/dpu_writeback.c +1 -3
index 26a93c3cc454..03e63b6c5351 100644
@@ -96,11 +96,9 @@ static int dpu_wb_conn_prepare_job(struct drm_connector *connector,
 	return 0;
 }
 
-static void dpu_wb_conn_cleanup_job(struct drm_writeback_connector *wb_connector,
+static void dpu_wb_conn_cleanup_job(struct drm_connector *connector,
 		struct drm_writeback_job *job)
 {
-	struct drm_connector *connector =
-		container_of(wb_connector, struct drm_connector, writeback);
 	struct dpu_wb_connector *dpu_wb_conn = to_dpu_wb_conn(connector);
 
 	if (!job->fb)
drivers/gpu/drm/renesas/rcar-du/rcar_du_writeback.c +2 -4
index 725981cc1d0c..e3aab132ded1 100644
@@ -72,12 +72,10 @@ static int rcar_du_wb_prepare_job(struct drm_connector *connector,
 	return 0;
 }
 
-static void rcar_du_wb_cleanup_job(struct drm_writeback_connector *connector,
+static void rcar_du_wb_cleanup_job(struct drm_connector *connector,
 				   struct drm_writeback_job *job)
 {
-	struct drm_connector *conn =
-		drm_writeback_to_connector(connector);
-	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(conn);
+	struct rcar_du_crtc *rcrtc = wb_to_rcar_crtc(connector);
 	struct rcar_du_wb_job *rjob = job->priv;
 
 	if (!job->fb)
drivers/gpu/drm/vkms/vkms_writeback.c +1 -4
index 032896fb5c5b..320d553f5f1f 100644
@@ -102,13 +102,10 @@ static int vkms_wb_prepare_job(struct drm_connector *connector,
 	return ret;
 }
 
-static void vkms_wb_cleanup_job(struct drm_writeback_connector *wb_conn,
+static void vkms_wb_cleanup_job(struct drm_connector *connector,
 				struct drm_writeback_job *job)
 {
 	struct vkms_writeback_job *vkmsjob = job->priv;
-	struct drm_connector *connector = container_of(wb_conn,
-						       struct drm_connector,
-						       writeback);
 	struct vkms_output *vkms_output = container_of(connector,
 						       struct vkms_output,
 						       wb_connector);
include/drm/drm_modeset_helper_vtables.h +1 -1
index 806230129ad9..4ac568bac083 100644
@@ -1157,7 +1157,7 @@ struct drm_connector_helper_funcs {
 	 *
 	 * This callback is used by the atomic modeset helpers.
 	 */
-	void (*cleanup_writeback_job)(struct drm_writeback_connector *connector,
+	void (*cleanup_writeback_job)(struct drm_connector *connector,
 				      struct drm_writeback_job *job);
 
 	/**
Signature · 1 line
2.34.1
#17 lore raw

✗ Fi.CI.BUILD: failure for Refactor drm_writeback_connector structure (rev3)

In reply to Suraj Kandpal
== Series Details ==

== Series Details ==

Series: Refactor drm_writeback_connector structure (rev3)
URL : https://patchwork.freedesktop.org/series/152760/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/152760/revisions/3/mbox/ not applied
Applying: drm: writeback: Refactor drm_writeback_connector structure
error: sha1 information is lacking or useless (drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm: writeback: Refactor drm_writeback_connector structure When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced