[PATCH 5/6] drm/komeda: Update writeback signal for side_by_side

From: james qian wang (Arm Technology China)
Date: Thu Jul 04 2019 - 02:18:57 EST


In side by side mode, a writeback job is completed by two pipelines: left
by master and right by slave, we need to wait both pipeline finished (EOW),
then can signal the writeback job completion.

Signed-off-by: James Qian Wang (Arm Technology China) <james.qian.wang@xxxxxxx>
---
.../gpu/drm/arm/display/komeda/komeda_crtc.c | 23 ++++++++++---------
.../gpu/drm/arm/display/komeda/komeda_kms.h | 5 ++++
.../arm/display/komeda/komeda_wb_connector.c | 3 +++
3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index 133ea4728149..ca1bef8fb8dc 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -194,27 +194,28 @@ komeda_crtc_unprepare(struct komeda_crtc *kcrtc)
return err;
}

-void komeda_crtc_handle_event(struct komeda_crtc *kcrtc,
+void komeda_crtc_handle_event(struct komeda_crtc *kcrtc,
struct komeda_events *evts)
{
struct drm_crtc *crtc = &kcrtc->base;
+ struct komeda_wb_connector *wb_conn = kcrtc->wb_conn;
u32 events = evts->pipes[kcrtc->master->id];

if (events & KOMEDA_EVENT_VSYNC)
drm_crtc_handle_vblank(crtc);

- if (events & KOMEDA_EVENT_EOW) {
- struct komeda_wb_connector *wb_conn = kcrtc->wb_conn;
+ /* handles writeback event */
+ if (events & KOMEDA_EVENT_EOW)
+ wb_conn->complete_pipes |= BIT(kcrtc->master->id);

- if (wb_conn)
- 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));
+ if (kcrtc->side_by_side &&
+ (evts->pipes[kcrtc->slave->id] & KOMEDA_EVENT_EOW))
+ wb_conn->complete_pipes |= BIT(kcrtc->slave->id);
+
+ if (wb_conn->expected_pipes == wb_conn->complete_pipes) {
+ wb_conn->complete_pipes = 0;
+ drm_writeback_signal_completion(&wb_conn->base, 0);
}
- /* will handle it together with the write back support */
- if (events & KOMEDA_EVENT_EOW)
- DRM_DEBUG("EOW.\n");

if (events & KOMEDA_EVENT_FLIP) {
unsigned long flags;
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
index 0dbfd7ad7805..3cb57ea82192 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.h
@@ -66,6 +66,11 @@ struct komeda_wb_connector {

/** @wb_layer: represents associated writeback pipeline of komeda */
struct komeda_layer *wb_layer;
+
+ /** @expected_pipes: pipelines are used for the writeback job */
+ u32 expected_pipes;
+ /** @complete_pipes: pipelines which have finished writeback */
+ u32 complete_pipes;
};

/**
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
index ea584b1e5bd2..9787745713df 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_wb_connector.c
@@ -165,6 +165,9 @@ static int komeda_wb_connector_add(struct komeda_kms_dev *kms,
return -ENOMEM;

kwb_conn->wb_layer = kcrtc->master->wb_layer;
+ kwb_conn->expected_pipes = BIT(kcrtc->master->id);
+ if (kcrtc->side_by_side)
+ kwb_conn->expected_pipes |= BIT(kcrtc->slave->id);

wb_conn = &kwb_conn->base;
wb_conn->encoder.possible_crtcs = BIT(drm_crtc_index(&kcrtc->base));
--
2.20.1