drm/msm/dpu: Add Concurrent Writeback Support for DPU 10.x+
v5 cover drm/msm/dpu: Add Concurrent Writeback Support for DPU 10.x+
DPU supports a single writeback session running concurrently with primary display when the CWB mux is configured properly. This series enables clone mode for DPU driver and adds support for programming the CWB mux in cases where the hardware has dedicated CWB pingpong blocks. Currently, the CWB hardware blocks have only been added to the SM8650 hardware catalog and only DSI has been exposed as a possible_clone of WB.
This changes are split into two parts:
The first part of the series will pull in Dmitry's patches to refactor the DPU resource manager to be based off of CRTC instead of encoder. This includes some changes (noted in the relevant commits) by me and Abhinav to fix some issues with getting the global state and refactoring the CDM allocation to work with Dmitry's changes.
The second part of the series will add support for CWB by doing the following:
1) Add the CWB mux to the hardware catalog and clarify the pingpong block index enum to specifiy which pingpong blocks are dedicated to CWB only and which ones are general use pingpong blocks
2) Add support for configuring the CWB mux via dpu_hw_cwb ops
3) Add pending flush support for CWB
4) Add support for validating clone mode in the DPU CRTC and setting up CWB within the encoder
5) Adjust the encoder trigger flush, trigger start, and kickoff order to accomodate clone mode
6) Adjust when the frame done timer is started for clone mode
7) Define the possible clones for DPU encoders so that WB encoders can be cloned by non-WB encoders
The feature was tested on SM8650 using IGT's kms_writeback test with the following change [1] and dumping the writeback framebuffer when in clone mode. I haven't gotten the chance to test it on DP yet, but I've validated both single and dual LM on DSI.
To test CWB with IGT, you'll need to apply this series [1] and run the following command to dump the writeback buffer:
IGT_FRAME_DUMP_PATH=<dump path> FRAME_PNG_FILE_NAME=<file name> \
./build/tests/kms_writeback -d [--run-subtest dump-valid-clones] \
You can also do CRC validation by running this command:
./build/tests/kms_writeback [--run-subtest dump-valid-clones]
NOTE: this series depends on Dmitry's modeset fixes [2]
[1] https://patchwork.freedesktop.org/series/137933/
[2] https://patchwork.freedesktop.org/series/142905/
---
Changes in v5:
- Rebased onto MSM modeset fixes series (Dmitry)
- Reordered RM refactor patches to prevent breaking CI and to avoid
breaking when partially applied (Dmitry)
- Switch CWB resource reservation to reserve CWB mux first (Dmitry)
- Reworded commit messages to be clearer (Dmitry)
- Change CDM check to fail only if both DP and WB outputs are
requesting the CDM block simultaneously (Dmitry)
- Use helper to grab dsc config in dpu_encoder_update_topology
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Rebased onto latest msm-next
- Added kunit tests for framework changes
- Skip valid clone check for encoders that don't have any possible clones set (this is to avoid failing kunit tests, specifically the HDMI state helper tests)
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Dropped support for CWB on DP connectors for now
- Dropped unnecessary PINGPONG array in *_setup_cwb()
- Add a check to make sure CWB and CDM aren't supported simultaneously (Dmitry)
- Document cwb_enabled checks in dpu_crtc_get_topology() (Dmitry)
- Moved implementation of drm_crtc_in_clone_mode() to drm_crtc.c (Jani)
- Dropped duplicate error message for reserving CWB resources (Dmitry)
- Added notes in framework changes about posting a separate series to
add proper KUnit tests (Maxime)
- Added commit message note addressing Sima's comment on handling mode_changed (Dmitry)
- Formatting fixes (Dmitry)
- Added proper kerneldocs (Dmitry)
- Renamed dpu_encoder_helper_get_cwb() -> *_get_cwb_mask() (Dmitry)
- Capitalize all instances of "pingpong" in comments (Dmitry)
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Moved CWB hardware programming to its own dpu_hw_cwb abstraction
(Dmitry)
- Reserve and get assigned CWB muxes using RM API and KMS global state (Dmitry)
- Dropped requirement to have only one CWB session at a time
- Moved valid clone mode check to DRM framework (Dmitry and Ville)
- Switch to default CWB tap point to LM as the DSPP
- Dropped printing clone mode status in atomic state (Dmitry)
- Call dpu_vbif_clear_errors() before dpu_encoder_kickoff() (Dmitry)
- Squashed setup_input_ctrl() and setup_input_mode() into a single
dpu_hw_cwb op (Dmitry)
- Moved function comment docs to correct place and fixed wording of comments/commit messages (Dmitry)
- Grabbed old CRTC state using proper drm_atomic_state API in dpu_crtc_atomic_check() (Dmitry)
- Split HW catalog changes of adding the CWB mux block and changing the dedicated CWB pingpong indices into 2 separate commits (Dmitry)
- Moved clearing the dpu_crtc_state.num_mixers to "drm/msm/dpu: fill
CRTC resources in dpu_crtc.c" (Dmitry)
- Fixed alignment and other formatting issues (Dmitry)
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Dmitry Baryshkov (3):
drm/msm/dpu: fill CRTC resources in dpu_crtc.c
drm/msm/dpu: move resource allocation to CRTC
drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation
Jessica Zhang (11):
drm/msm/dpu: Add CWB to msm_display_topology drm/msm/dpu: Require modeset if clone mode status changes drm/msm/dpu: Fail atomic_check if multiple outputs request CDM block drm/msm/dpu: Reserve resources for CWB
drm/msm/dpu: Configure CWB in writeback encoder drm/msm/dpu: Support CWB in dpu_hw_ctl
drm/msm/dpu: Adjust writeback phys encoder setup for CWB drm/msm/dpu: Start frame done timer after encoder kickoff drm/msm/dpu: Skip trigger flush and start for CWB drm/msm/dpu: Reorder encoder kickoff for CWB drm/msm/dpu: Set possible clones for all encoders
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 229 +++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 3 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 416 ++++++++++++--------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 7 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 30 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 15 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 27 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 13 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 293 ++++++++++----- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 14 +- 13 files changed, 752 insertions(+), 329 deletions(-)
---
base-commit: 86313a9cd152330c634b25d826a281c6a002eb77
change-id: 20240618-concurrent-wb-97d62387f952
prerequisite-change-id: 20241209-abhinavk-modeset-fix-74864f1de08d:v3
prerequisite-patch-id: a197a0cd4647cb189ea20a96583ea78d0c98b638
prerequisite-patch-id: 112c8f1795cbed989beb02b72561854c0ccd59dd
Best regards,
Signature · 1 line
Jessica Zhang <[email protected]>
PATCH v5 1/14 drm/msm/dpu: fill CRTC resources in dpu_crtc.c
From: Dmitry Baryshkov <[email protected]>
Stop poking into CRTC state from dpu_encoder.c, fill CRTC HW resources from dpu_crtc_assign_resources().
---
Changes in v5:
- Reordered to prevent breaking CI or upon partial application
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 66 +++++++++++++++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 37 ---------------- 2 files changed, 66 insertions(+), 37 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +66 -0
@@ -1230,6 +1230,66 @@ static int dpu_crtc_reassign_planes(struct drm_crtc *crtc, struct drm_crtc_statereturn ret; } +#define MAX_CHANNELS_PER_CRTC 2 + +static int dpu_crtc_assign_resources (struct drm_crtc *crtc, +struct drm_crtc_state *crtc_state) +{ +struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_CRTC ]; +struct dpu_hw_blk *hw_lm[MAX_CHANNELS_PER_CRTC ]; +struct dpu_hw_blk *hw_dspp[MAX_CHANNELS_PER_CRTC ]; +int i, num_lm, num_ctl, num_dspp; +struct dpu_kms *dpu_kms =_dpu_crtc_get_kms (crtc); +struct dpu_global_state *global_state; +struct dpu_crtc_state *cstate; +struct drm_encoder *drm_enc; + +if (!crtc_state->encoder_mask) +return 0 ; + +/* +* For now, grab the first encoder in the crtc state as we don't +* support clone mode yet +*/ +drm_for_each_encoder_mask (drm_enc, crtc->dev, crtc_state->encoder_mask) +break ; + + global_state =dpu_kms_get_global_state (crtc_state->state); +if (IS_ERR (global_state)) +return PTR_ERR (global_state); + +if (!crtc_state->enable) +return 0 ; + + cstate =to_dpu_crtc_state (crtc_state); + + num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->base.id, +DPU_HW_BLK_CTL , hw_ctl, +ARRAY_SIZE (hw_ctl)); + num_lm =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->base.id, +DPU_HW_BLK_LM , hw_lm, +ARRAY_SIZE (hw_lm)); + num_dspp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->base.id, +DPU_HW_BLK_DSPP , hw_dspp, +ARRAY_SIZE (hw_dspp)); + +for (i =0 ; i < num_lm; i++) { +int ctl_idx = (i < num_ctl) ? i : (num_ctl-1 ); + + cstate->mixers[i].hw_lm =to_dpu_hw_mixer (hw_lm[i]); + cstate->mixers[i].lm_ctl =to_dpu_hw_ctl (hw_ctl[ctl_idx]); +if (i < num_dspp) + cstate->mixers[i].hw_dspp =to_dpu_hw_dspp (hw_dspp[i]); + } + + cstate->num_mixers = num_lm; + +return 0 ; +} +static int dpu_crtc_atomic_check (struct drm_crtc *crtc,struct drm_atomic_state *state) {
@@ -1245,6 +1305,12 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,bool needs_dirtyfb =dpu_crtc_needs_dirtyfb (crtc_state); +if (drm_atomic_crtc_needs_modeset (crtc_state)) { + rc =dpu_crtc_assign_resources (crtc, crtc_state); +if (rc <0 ) +return rc; + } +if (dpu_use_virtual_planes && (crtc_state->planes_changed || crtc_state->zpos_changed)) { rc =dpu_crtc_reassign_planes (crtc, crtc_state);
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -37
@@ -719,40 +719,6 @@ static struct msm_display_topology dpu_encoder_get_topology(return topology; } -static void dpu_encoder_assign_crtc_resources (struct dpu_kms *dpu_kms, -struct drm_encoder *drm_enc, -struct dpu_global_state *global_state, -struct drm_crtc_state *crtc_state) -{ -struct dpu_crtc_state *cstate; -struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC ]; -struct dpu_hw_blk *hw_lm[MAX_CHANNELS_PER_ENC ]; -struct dpu_hw_blk *hw_dspp[MAX_CHANNELS_PER_ENC ]; -int num_lm, num_ctl, num_dspp, i; - - cstate =to_dpu_crtc_state (crtc_state); - -memset (cstate->mixers,0 ,sizeof (cstate->mixers)); - - num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl)); - num_lm =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id,DPU_HW_BLK_LM , hw_lm,ARRAY_SIZE (hw_lm)); - num_dspp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id,DPU_HW_BLK_DSPP , hw_dspp, -ARRAY_SIZE (hw_dspp)); - -for (i =0 ; i < num_lm; i++) { -int ctl_idx = (i < num_ctl) ? i : (num_ctl-1 ); - - cstate->mixers[i].hw_lm =to_dpu_hw_mixer (hw_lm[i]); - cstate->mixers[i].lm_ctl =to_dpu_hw_ctl (hw_ctl[ctl_idx]); - cstate->mixers[i].hw_dspp = i < num_dspp ?to_dpu_hw_dspp (hw_dspp[i]) :NULL ; - } - - cstate->num_mixers = num_lm; -} -/** * dpu_encoder_virt_check_mode_changed: check if full modeset is required * @drm_enc: Pointer to drm encoder structure
@@ -823,9 +789,6 @@ static int dpu_encoder_virt_atomic_check(if (crtc_state->enable) ret =dpu_rm_reserve (&dpu_kms->rm, global_state, drm_enc, crtc_state, &topology); -if (!ret) -dpu_encoder_assign_crtc_resources (dpu_kms, drm_enc, - global_state, crtc_state); }trace_dpu_enc_atomic_check_flags (DRMID (drm_enc), adj_mode->flags);
Signature · 1 line
2.34.1
PATCH v5 2/14 drm/msm/dpu: move resource allocation to CRTC
In reply to Jessica ZhangFrom: Dmitry Baryshkov <[email protected]>
All resource allocation is centered around the LMs. Then other blocks (except DSCs) are allocated basing on the LMs that was selected, and LM powers up the CRTC rather than the encoder.
Moreover if at some point the driver supports encoder cloning, allocating resources from the encoder will be incorrect, as all clones will have different encoder IDs, while LMs are to be shared by these encoders.
In addition, move mode_changed() to dpu_crtc as encoder no longer has access to topology information
---
Changes in v5:
- Reordered to prevent breaking CI and upon partial applciation
- Moved mode_changed() from dpu_encoder to dpu_crtc
- Dropped dpu_encoder_needs_dsc_merge() refactor to clean up commit
- In dpu_encoder_update_topology(), grab DSC config using dpu_encoder helper as dpu_encoder->dsc hasn't been set yet
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 79 +++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 174 +++++++++------------------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 11 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 19 +-- 5 files changed, 144 insertions(+), 141 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +79 -0
@@ -1231,6 +1231,50 @@ static int dpu_crtc_reassign_planes(struct drm_crtc *crtc, struct drm_crtc_state }#define MAX_CHANNELS_PER_CRTC 2 +#define MAX_HDISPLAY_SPLIT 1080 + +static struct msm_display_topology dpu_crtc_get_topology ( +struct drm_crtc *crtc, +struct dpu_kms *dpu_kms, +struct drm_crtc_state *crtc_state) +{ +struct drm_display_mode *mode = &crtc_state->adjusted_mode; +struct msm_display_topology topology = {0 }; +struct drm_encoder *drm_enc; + +drm_for_each_encoder_mask (drm_enc, crtc->dev, crtc_state->encoder_mask) +dpu_encoder_update_topology (drm_enc, &topology, crtc_state->state, + &crtc_state->adjusted_mode); + +/* +* Datapath topology selection +* +* Dual display +* 2 LM, 2 INTF ( Split display using 2 interfaces) +* +* Single display +* 1 LM, 1 INTF +* 2 LM, 1 INTF (stream merge to support high resolution interfaces) +* +* If DSC is enabled, use 2 LMs for 2:2:1 topology +* +* Add dspps to the reservation requirements if ctm is requested +*/ + +if (topology.num_intf ==2 ) + topology.num_lm =2 ; +else if (topology.num_dsc ==2 ) + topology.num_lm =2 ; +else if (dpu_kms->catalog->caps->has_3d_merge) + topology.num_lm = (mode->hdisplay >MAX_HDISPLAY_SPLIT ) ?2 :1 ; +else + topology.num_lm =1 ; + +if (crtc_state->ctm) + topology.num_dspp = topology.num_lm; + +return topology; +}static int dpu_crtc_assign_resources (struct drm_crtc *crtc,struct drm_crtc_state *crtc_state)
@@ -1243,6 +1287,8 @@ static int dpu_crtc_assign_resources(struct drm_crtc *crtc,struct dpu_global_state *global_state;struct dpu_crtc_state *cstate;struct drm_encoder *drm_enc; +struct msm_display_topology topology; +int ret;if (!crtc_state->encoder_mask)return 0 ;
@@ -1254,13 +1300,24 @@ static int dpu_crtc_assign_resources(struct drm_crtc *crtc,drm_for_each_encoder_mask (drm_enc, crtc->dev, crtc_state->encoder_mask)break ; +/* +* Release and Allocate resources on every modeset +*/ global_state =dpu_kms_get_global_state (crtc_state->state);if (IS_ERR (global_state))return PTR_ERR (global_state); +dpu_rm_release (global_state, drm_enc); +if (!crtc_state->enable)return 0 ; + topology =dpu_crtc_get_topology (crtc, dpu_kms, crtc_state); + ret =dpu_rm_reserve (&dpu_kms->rm, global_state, + drm_enc, crtc_state, &topology); +if (ret) +return ret; + cstate =to_dpu_crtc_state (crtc_state); num_ctl = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
@@ -1290,6 +1347,28 @@ static int dpu_crtc_assign_resources(struct drm_crtc *crtc,return 0 ; } +/** +* dpu_crtc_check_mode_changed: check if full modeset is required +* @crtc_state: Corresponding CRTC state to be checked +* +* Check if the changes in the object properties demand full mode set. +*/ +int dpu_crtc_check_mode_changed (struct drm_crtc_state *crtc_state) +{ +struct drm_encoder *drm_enc; +struct drm_crtc *crtc = crtc_state->crtc; + +DRM_DEBUG_ATOMIC ("%d\n" , crtc->base.id); + +/* there might be cases where encoder needs a modeset too */ +drm_for_each_encoder_mask (drm_enc, crtc->dev, crtc_state->encoder_mask) { +if (dpu_encoder_needs_modeset (drm_enc, crtc_state->state)) + crtc_state->mode_changed = true; + } + +return 0 ; +} +static int dpu_crtc_atomic_check (struct drm_crtc *crtc,struct drm_atomic_state *state) {
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h +2 -0
@@ -239,6 +239,8 @@ static inline int dpu_crtc_frame_pending(struct drm_crtc *crtc)return crtc ?atomic_read (&to_dpu_crtc (crtc)->frame_pending) : -EINVAL ; } +int dpu_crtc_check_mode_changed (struct drm_crtc_state *crtc_state); +int dpu_crtc_vblank (struct drm_crtc *crtc,bool en);void dpu_crtc_vblank_callback (struct drm_crtc *crtc);
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +53 -121
228 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +7 -4
@@ -80,6 +80,13 @@ int dpu_encoder_get_crc(const struct drm_encoder *drm_enc, u32 *crcs, int pos);bool dpu_encoder_use_dsc_merge (struct drm_encoder *drm_enc); +void dpu_encoder_update_topology (struct drm_encoder *drm_enc, +struct msm_display_topology *topology, +struct drm_atomic_state *state, +const struct drm_display_mode *adj_mode); + +bool dpu_encoder_needs_modeset (struct drm_encoder *drm_enc,struct drm_atomic_state *state); +void dpu_encoder_prepare_wb_job (struct drm_encoder *drm_enc,struct drm_writeback_job *job);
@@ -88,8 +95,4 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,bool dpu_encoder_is_valid_for_commit (struct drm_encoder *drm_enc); -int dpu_encoder_virt_check_mode_changed (struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state); -#endif /* __DPU_ENCODER_H__ */
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3 -16
@@ -449,24 +449,11 @@ static void dpu_kms_disable_commit(struct msm_kms *kms)static int dpu_kms_check_mode_changed (struct msm_kms *kms,struct drm_atomic_state *state) {struct drm_crtc_state *new_crtc_state; -struct drm_connector *connector; -struct drm_connector_state *new_conn_state; +struct drm_crtc *crtc;int i; -for_each_new_connector_in_state (state, connector, new_conn_state, i) { -struct drm_encoder *encoder; - -WARN_ON (!!new_conn_state->best_encoder != !!new_conn_state->crtc); - -if (!new_conn_state->crtc || !new_conn_state->best_encoder) -continue ; - - new_crtc_state =drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); - - encoder = new_conn_state->best_encoder; - -dpu_encoder_virt_check_mode_changed (encoder, new_crtc_state, new_conn_state); - } +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) +dpu_crtc_check_mode_changed (new_crtc_state);return 0 ; }
Signature · 1 line
2.34.1
Re: [PATCH v5 02/14] drm/msm/dpu: move resource allocation to CRTC
Quoted 115 lines · Jessica Zhang
From: Dmitry Baryshkov <[email protected]>
All resource allocation is centered around the LMs. Then other blocks (except DSCs) are allocated basing on the LMs that was selected, and LM powers up the CRTC rather than the encoder.
Moreover if at some point the driver supports encoder cloning, allocating resources from the encoder will be incorrect, as all clones will have different encoder IDs, while LMs are to be shared by these encoders.
In addition, move
mode_changed()todpu_crtcas encoder no longer has access to topology informationSigned-off-by Dmitry Baryshkov <[email protected]>[[email protected]: Refactored resource allocation for CDM]Signed-off-by Abhinav Kumar <[email protected]>[[email protected]: Changed to grabbing exising global state]Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Reordered to prevent breaking CI and upon partial applciation
- Movedmode_changed()fromdpu_encodertodpu_crtc
- Droppeddpu_encoder_needs_dsc_merge()refactor to clean up commit
- Indpu_encoder_update_topology(), grab DSC config usingdpu_encoderhelper asdpu_encoder->dschasn't been set yet--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 79 +++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 174 +++++++++------------------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 11 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 19 +-- 5 files changed, 144 insertions(+), 141 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +10
-63-/** -* dpu_encoder_virt_check_mode_changed: check if full modeset is required -* @drm_enc: Pointer to drm encoder structure -* @crtc_state: Corresponding CRTC state to be checked -* @conn_state: Corresponding Connector's state to be checked -* -* Check if the changes in the object properties demand full mode set. -*/ -int dpu_encoder_virt_check_mode_changed (struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state) +bool dpu_encoder_needs_modeset (struct drm_encoder *drm_enc,struct drm_atomic_state *state) { +struct drm_connector *connector; +struct drm_connector_state *conn_state; +struct drm_framebuffer *fb;struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); -struct msm_display_topology topology; - -DPU_DEBUG_ENC (dpu_enc,"\n" ); - -/* Using mode instead of adjusted_mode as it wasn't computed yet */ - topology =dpu_encoder_get_topology (dpu_enc, &crtc_state->mode, crtc_state, conn_state); - -if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; -else if (!topology.needs_cdm && dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; - -return 0 ; -} - -static int dpu_encoder_virt_atomic_check ( -struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state) -{ -struct dpu_encoder_virt *dpu_enc; -struct msm_drm_private *priv; -struct dpu_kms *dpu_kms; -struct drm_display_mode *adj_mode; -struct msm_display_topology topology; -struct dpu_global_state *global_state; -int ret =0 ; - -if (!drm_enc || !crtc_state || !conn_state) { -DPU_ERROR ("invalid arg(s), drm_enc %d, crtc/conn state %d/%d\n" , - drm_enc !=NULL , crtc_state !=NULL , conn_state !=NULL ); -return -EINVAL ; - } - - dpu_enc =to_dpu_encoder_virt (drm_enc); -DPU_DEBUG_ENC (dpu_enc,"\n" ); - - priv = drm_enc->dev->dev_private; - dpu_kms =to_dpu_kms (priv->kms); - adj_mode = &crtc_state->adjusted_mode; - global_state =dpu_kms_get_global_state (crtc_state->state); -if (IS_ERR (global_state)) -return PTR_ERR (global_state); -trace_dpu_enc_atomic_check (DRMID (drm_enc)); +if (!drm_enc || !state) +return false; - topology =dpu_encoder_get_topology (dpu_enc, adj_mode, crtc_state, conn_state); + connector =drm_atomic_get_new_connector_for_encoder (state, drm_enc); +if (!connector) +return false; -/* -* Release and Allocate resources on every modeset -*/ -if (drm_atomic_crtc_needs_modeset (crtc_state)) { -dpu_rm_release (global_state, drm_enc); + conn_state =drm_atomic_get_new_connector_state (state, connector); -if (crtc_state->enable) - ret = dpu_rm_reserve(&dpu_kms->rm, global_state,
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c struct drm_dsc_config *dpu_encoder_get_dsc_config(struct drm_encoder *drm_enc) · line 726
Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +9
-1- drm_enc, crtc_state, &topology); +if (dpu_enc->disp_info.intf_type ==INTF_WB && conn_state->writeback_job) { + fb = conn_state->writeback_job->fb; +if (fb &&MSM_FORMAT_IS_YUV (msm_framebuffer_format (fb))) { +if (!dpu_enc->cur_master->hw_cdm) +return true; + }else { +if (dpu_enc->cur_master->hw_cdm) +return true; + }
Nit: this is duplicating a part of the dpu_encoder_update_topology(). It would be nice to have a comment here. If there is no need for a new versoion, I can probably write something when applying.
Quoted 80 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +1
-4} -trace_dpu_enc_atomic_check_flags (DRMID (drm_enc), adj_mode->flags); - -return ret; +return false; } static void _dpu_encoder_update_vsync_source(struct dpu_encoder_virt *dpu_enc,@@ -2612,7 +2545,6 @@ static const struct drm_encoder_helper_funcs dpu_encoder_helper_funcs = { .atomic_mode_set = dpu_encoder_virt_atomic_mode_set, .atomic_disable = dpu_encoder_virt_atomic_disable, .atomic_enable = dpu_encoder_virt_atomic_enable, - .atomic_check = dpu_encoder_virt_atomic_check, };static const struct drm_encoder_funcs dpu_encoder_funcs = {drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +7
-4@@ -80,6 +80,13 @@ int dpu_encoder_get_crc(const struct drm_encoder *drm_enc, u32 *crcs, int pos);bool dpu_encoder_use_dsc_merge (struct drm_encoder *drm_enc); +void dpu_encoder_update_topology (struct drm_encoder *drm_enc, +struct msm_display_topology *topology, +struct drm_atomic_state *state, +const struct drm_display_mode *adj_mode); + +bool dpu_encoder_needs_modeset (struct drm_encoder *drm_enc,struct drm_atomic_state *state); +void dpu_encoder_prepare_wb_job (struct drm_encoder *drm_enc,struct drm_writeback_job *job);@@ -88,8 +95,4 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,bool dpu_encoder_is_valid_for_commit (struct drm_encoder *drm_enc); -int dpu_encoder_virt_check_mode_changed (struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state); -#endif /* __DPU_ENCODER_H__ */ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3
-16@@ -449,24 +449,11 @@ static void dpu_kms_disable_commit(struct msm_kms *kms)static int dpu_kms_check_mode_changed (struct msm_kms *kms,struct drm_atomic_state *state) {struct drm_crtc_state *new_crtc_state; -struct drm_connector *connector; -struct drm_connector_state *new_conn_state; +struct drm_crtc *crtc;int i; -for_each_new_connector_in_state (state, connector, new_conn_state, i) { -struct drm_encoder *encoder; - -WARN_ON (!!new_conn_state->best_encoder != !!new_conn_state->crtc); - -if (!new_conn_state->crtc || !new_conn_state->best_encoder) -continue ; - - new_crtc_state =drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); - - encoder = new_conn_state->best_encoder; - -dpu_encoder_virt_check_mode_changed (encoder, new_crtc_state, new_conn_state); - } +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) +dpu_crtc_check_mode_changed (new_crtc_state);return 0 ; }Signature · 2 lines
-- 2.34.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v5 02/14] drm/msm/dpu: move resource allocation to CRTC
Quoted 114 lines · Dmitry Baryshkov
Quoted 113 lines · Jessica Zhang
From: Dmitry Baryshkov <[email protected]>
All resource allocation is centered around the LMs. Then other blocks (except DSCs) are allocated basing on the LMs that was selected, and LM powers up the CRTC rather than the encoder.
Moreover if at some point the driver supports encoder cloning, allocating resources from the encoder will be incorrect, as all clones will have different encoder IDs, while LMs are to be shared by these encoders.
In addition, move
mode_changed()todpu_crtcas encoder no longer has access to topology informationSigned-off-by Dmitry Baryshkov <[email protected]>[[email protected]: Refactored resource allocation for CDM]Signed-off-by Abhinav Kumar <[email protected]>[[email protected]: Changed to grabbing exising global state]Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Reordered to prevent breaking CI and upon partial applciation
- Movedmode_changed()fromdpu_encodertodpu_crtc
- Droppeddpu_encoder_needs_dsc_merge()refactor to clean up commit
- Indpu_encoder_update_topology(), grab DSC config usingdpu_encoderhelper asdpu_encoder->dschasn't been set yet--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 79 +++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 174 +++++++++------------------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 11 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 19 +-- 5 files changed, 144 insertions(+), 141 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +10
-61-/** -* dpu_encoder_virt_check_mode_changed: check if full modeset is required -* @drm_enc: Pointer to drm encoder structure -* @crtc_state: Corresponding CRTC state to be checked -* @conn_state: Corresponding Connector's state to be checked -* -* Check if the changes in the object properties demand full mode set. -*/ -int dpu_encoder_virt_check_mode_changed (struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state) +bool dpu_encoder_needs_modeset (struct drm_encoder *drm_enc,struct drm_atomic_state *state) { +struct drm_connector *connector; +struct drm_connector_state *conn_state; +struct drm_framebuffer *fb;struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); -struct msm_display_topology topology; - -DPU_DEBUG_ENC (dpu_enc,"\n" ); - -/* Using mode instead of adjusted_mode as it wasn't computed yet */ - topology =dpu_encoder_get_topology (dpu_enc, &crtc_state->mode, crtc_state, conn_state); - -if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; -else if (!topology.needs_cdm && dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; - -return 0 ; -} - -static int dpu_encoder_virt_atomic_check ( -struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state) -{ -struct dpu_encoder_virt *dpu_enc; -struct msm_drm_private *priv; -struct dpu_kms *dpu_kms; -struct drm_display_mode *adj_mode; -struct msm_display_topology topology; -struct dpu_global_state *global_state; -int ret =0 ; - -if (!drm_enc || !crtc_state || !conn_state) { -DPU_ERROR ("invalid arg(s), drm_enc %d, crtc/conn state %d/%d\n" , - drm_enc !=NULL , crtc_state !=NULL , conn_state !=NULL ); -return -EINVAL ; - } - - dpu_enc =to_dpu_encoder_virt (drm_enc); -DPU_DEBUG_ENC (dpu_enc,"\n" ); - - priv = drm_enc->dev->dev_private; - dpu_kms =to_dpu_kms (priv->kms); - adj_mode = &crtc_state->adjusted_mode; - global_state =dpu_kms_get_global_state (crtc_state->state); -if (IS_ERR (global_state)) -return PTR_ERR (global_state); -trace_dpu_enc_atomic_check (DRMID (drm_enc)); +if (!drm_enc || !state) +return false; - topology =dpu_encoder_get_topology (dpu_enc, adj_mode, crtc_state, conn_state); + connector =drm_atomic_get_new_connector_for_encoder (state, drm_enc); +if (!connector) +return false; -/* -* Release and Allocate resources on every modeset -*/ -if (drm_atomic_crtc_needs_modeset (crtc_state)) { -dpu_rm_release (global_state, drm_enc); + conn_state =drm_atomic_get_new_connector_state (state, connector);
Quoted 16 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c struct drm_dsc_config *dpu_encoder_get_dsc_config(struct drm_encoder *drm_enc) · line 726
Quoted 12 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +9
-3-if (crtc_state->enable) - ret =dpu_rm_reserve (&dpu_kms->rm, global_state, - drm_enc, crtc_state, &topology); +if (dpu_enc->disp_info.intf_type ==INTF_WB && conn_state->writeback_job) { + fb = conn_state->writeback_job->fb; +if (fb &&MSM_FORMAT_IS_YUV (msm_framebuffer_format (fb))) { +if (!dpu_enc->cur_master->hw_cdm) +return true; + }else { +if (dpu_enc->cur_master->hw_cdm) +return true; + }Nit: this is duplicating a part of the
dpu_encoder_update_topology(). It would be nice to have a comment here. If there is no need for a new versoion, I can probably write something when applying.
Sure, I can add a note that we need to duplicate these checks in *_needs_modeset() since topology info is not stored in the encoder or crtc
Thanks,
Jessica Zhang
Quoted 85 lines
Quoted 81 lines
}drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +1
-4-trace_dpu_enc_atomic_check_flags (DRMID (drm_enc), adj_mode->flags); - -return ret; +return false; } static void _dpu_encoder_update_vsync_source(struct dpu_encoder_virt *dpu_enc,@@ -2612,7 +2545,6 @@ static const struct drm_encoder_helper_funcs dpu_encoder_helper_funcs = { .atomic_mode_set = dpu_encoder_virt_atomic_mode_set, .atomic_disable = dpu_encoder_virt_atomic_disable, .atomic_enable = dpu_encoder_virt_atomic_enable, - .atomic_check = dpu_encoder_virt_atomic_check, };static const struct drm_encoder_funcs dpu_encoder_funcs = {drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +7
-4@@ -80,6 +80,13 @@ int dpu_encoder_get_crc(const struct drm_encoder *drm_enc, u32 *crcs, int pos);bool dpu_encoder_use_dsc_merge (struct drm_encoder *drm_enc); +void dpu_encoder_update_topology (struct drm_encoder *drm_enc, +struct msm_display_topology *topology, +struct drm_atomic_state *state, +const struct drm_display_mode *adj_mode); + +bool dpu_encoder_needs_modeset (struct drm_encoder *drm_enc,struct drm_atomic_state *state); +void dpu_encoder_prepare_wb_job (struct drm_encoder *drm_enc,struct drm_writeback_job *job);@@ -88,8 +95,4 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,bool dpu_encoder_is_valid_for_commit (struct drm_encoder *drm_enc); -int dpu_encoder_virt_check_mode_changed (struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state); -#endif /* __DPU_ENCODER_H__ */ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3
-16@@ -449,24 +449,11 @@ static void dpu_kms_disable_commit(struct msm_kms *kms)static int dpu_kms_check_mode_changed (struct msm_kms *kms,struct drm_atomic_state *state) {struct drm_crtc_state *new_crtc_state; -struct drm_connector *connector; -struct drm_connector_state *new_conn_state; +struct drm_crtc *crtc;int i; -for_each_new_connector_in_state (state, connector, new_conn_state, i) { -struct drm_encoder *encoder; - -WARN_ON (!!new_conn_state->best_encoder != !!new_conn_state->crtc); - -if (!new_conn_state->crtc || !new_conn_state->best_encoder) -continue ; - - new_crtc_state =drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); - - encoder = new_conn_state->best_encoder; - -dpu_encoder_virt_check_mode_changed (encoder, new_crtc_state, new_conn_state); - } +for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) +dpu_crtc_check_mode_changed (new_crtc_state);return 0 ; }Signature · 2 lines
-- 2.34.1Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v5 02/14] drm/msm/dpu: move resource allocation to CRTC
Quoted 130 lines · Jessica Zhang
Quoted 118 lines · Dmitry Baryshkov
Quoted 117 lines · Jessica Zhang
From: Dmitry Baryshkov <[email protected]>
All resource allocation is centered around the LMs. Then other blocks (except DSCs) are allocated basing on the LMs that was selected, and LM powers up the CRTC rather than the encoder.
Moreover if at some point the driver supports encoder cloning, allocating resources from the encoder will be incorrect, as all clones will have different encoder IDs, while LMs are to be shared by these encoders.
In addition, move
mode_changed()todpu_crtcas encoder no longer has access to topology informationSigned-off-by Dmitry Baryshkov <[email protected]>[[email protected]: Refactored resource allocation for CDM]Signed-off-by Abhinav Kumar <[email protected]>[[email protected]: Changed to grabbing exising global state]Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Reordered to prevent breaking CI and upon partial applciation
- Movedmode_changed()fromdpu_encodertodpu_crtc
- Droppeddpu_encoder_needs_dsc_merge()refactor to clean up commit
- Indpu_encoder_update_topology(), grab DSC config usingdpu_encoderhelper asdpu_encoder->dschasn't been set yet--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 79 +++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 174 +++++++++------------------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 11 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 19 +-- 5 files changed, 144 insertions(+), 141 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +15
-64-/** -* dpu_encoder_virt_check_mode_changed: check if full modeset is required -* @drm_enc: Pointer to drm encoder structure -* @crtc_state: Corresponding CRTC state to be checked -* @conn_state: Corresponding Connector's state to be checked -* -* Check if the changes in the object properties demand full mode set. -*/ -int dpu_encoder_virt_check_mode_changed (struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state) +bool dpu_encoder_needs_modeset (struct drm_encoder *drm_enc,struct drm_atomic_state *state) { +struct drm_connector *connector; +struct drm_connector_state *conn_state; +struct drm_framebuffer *fb;struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc); -struct msm_display_topology topology; - -DPU_DEBUG_ENC (dpu_enc,"\n" ); - -/* Using mode instead of adjusted_mode as it wasn't computed yet */ - topology =dpu_encoder_get_topology (dpu_enc, &crtc_state->mode, crtc_state, conn_state); - -if (topology.needs_cdm && !dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; -else if (!topology.needs_cdm && dpu_enc->cur_master->hw_cdm) - crtc_state->mode_changed = true; - -return 0 ; -} - -static int dpu_encoder_virt_atomic_check ( -struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, -struct drm_connector_state *conn_state) -{ -struct dpu_encoder_virt *dpu_enc; -struct msm_drm_private *priv; -struct dpu_kms *dpu_kms; -struct drm_display_mode *adj_mode; -struct msm_display_topology topology; -struct dpu_global_state *global_state; -int ret =0 ; - -if (!drm_enc || !crtc_state || !conn_state) { -DPU_ERROR ("invalid arg(s), drm_enc %d, crtc/conn state %d/%d\n" , - drm_enc !=NULL , crtc_state !=NULL , conn_state !=NULL ); -return -EINVAL ; - } - - dpu_enc =to_dpu_encoder_virt (drm_enc); -DPU_DEBUG_ENC (dpu_enc,"\n" ); - - priv = drm_enc->dev->dev_private; - dpu_kms =to_dpu_kms (priv->kms); - adj_mode = &crtc_state->adjusted_mode; - global_state =dpu_kms_get_global_state (crtc_state->state); -if (IS_ERR (global_state)) -return PTR_ERR (global_state); -trace_dpu_enc_atomic_check (DRMID (drm_enc)); +if (!drm_enc || !state) +return false; - topology =dpu_encoder_get_topology (dpu_enc, adj_mode, crtc_state, conn_state); + connector =drm_atomic_get_new_connector_for_encoder (state, drm_enc); +if (!connector) +return false; -/* -* Release and Allocate resources on every modeset -*/ -if (drm_atomic_crtc_needs_modeset (crtc_state)) { -dpu_rm_release (global_state, drm_enc); + conn_state =drm_atomic_get_new_connector_state (state, connector); -if (crtc_state->enable) - ret =dpu_rm_reserve (&dpu_kms->rm, global_state, - drm_enc, crtc_state, &topology); +if (dpu_enc->disp_info.intf_type ==INTF_WB && conn_state->writeback_job) { + fb = conn_state->writeback_job->fb; +if (fb &&MSM_FORMAT_IS_YUV (msm_framebuffer_format (fb))) { +if (!dpu_enc->cur_master->hw_cdm) +return true;Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c struct drm_dsc_config *dpu_encoder_get_dsc_config(struct drm_encoder *drm_enc) · line 726
Quoted 4 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +4
-0+ }else { +if (dpu_enc->cur_master->hw_cdm) +return true; + }Nit: this is duplicating a part of the
dpu_encoder_update_topology(). It would be nice to have a comment here. If there is no need for a new versoion, I can probably write something when applying.
Quoted 2 lines
Sure, I can add a note that we need to duplicate these checks in
*_needs_modeset()since topology info is not stored in the encoder or crtc
Yes, please. I was thinking about having a helper function, but I don't think that it makes real sense.
Signature · 2 lines
With best wishes Dmitry
PATCH v5 3/14 drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation
In reply to Jessica ZhangFrom: Dmitry Baryshkov <[email protected]>
Up to now the driver has been using encoder to allocate hardware resources. Switch it to use CRTC id in preparation for the next step.
---
Changes in v5:
- Reordered to prevent breaking CI and upon partial application
Changes in v4 (due to rebase):
- moved *_get_assigned_resources() changes for DSPP and LM from encoder *_virt_atomic_mode_set() to *_assign_crtc_resources()
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 20 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 10 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 12 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 189 ++++++++++++++-------------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 7 +- 5 files changed, 113 insertions(+), 125 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +8 -12
@@ -1286,19 +1286,15 @@ static int dpu_crtc_assign_resources(struct drm_crtc *crtc,struct dpu_kms *dpu_kms =_dpu_crtc_get_kms (crtc);struct dpu_global_state *global_state;struct dpu_crtc_state *cstate; -struct drm_encoder *drm_enc;struct msm_display_topology topology;int ret;if (!crtc_state->encoder_mask)return 0 ; -/* -* For now, grab the first encoder in the crtc state as we don't -* support clone mode yet -*/ -drm_for_each_encoder_mask (drm_enc, crtc->dev, crtc_state->encoder_mask) -break ; + cstate =to_dpu_crtc_state (crtc_state); + +memset (cstate->mixers,0 ,sizeof (cstate->mixers));/* * Release and Allocate resources on every modeset
@@ -1307,29 +1303,29 @@ static int dpu_crtc_assign_resources(struct drm_crtc *crtc,if (IS_ERR (global_state))return PTR_ERR (global_state); -dpu_rm_release (global_state, drm_enc); +dpu_rm_release (global_state, crtc);if (!crtc_state->enable)return 0 ; topology =dpu_crtc_get_topology (crtc, dpu_kms, crtc_state); ret =dpu_rm_reserve (&dpu_kms->rm, global_state, - drm_enc, crtc_state, &topology); + crtc_state->crtc, &topology);if (ret)return ret; cstate =to_dpu_crtc_state (crtc_state); num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id, + crtc_state->crtc,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl)); num_lm =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id, + crtc_state->crtc,DPU_HW_BLK_LM , hw_lm,ARRAY_SIZE (hw_lm)); num_dspp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id, + crtc_state->crtc,DPU_HW_BLK_DSPP , hw_dspp,ARRAY_SIZE (hw_dspp));
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +5 -5
@@ -1162,17 +1162,17 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,/* Query resource that have been reserved in atomic check step. */ num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id,DPU_HW_BLK_PINGPONG , hw_pp, + drm_enc->crtc,DPU_HW_BLK_PINGPONG , hw_pp,ARRAY_SIZE (hw_pp)); num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl)); + drm_enc->crtc,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl));for (i =0 ; i <MAX_CHANNELS_PER_ENC ; i++) dpu_enc->hw_pp[i] = i < num_pp ?to_dpu_hw_pingpong (hw_pp[i]) :NULL ; num_dsc =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id,DPU_HW_BLK_DSC , + drm_enc->crtc,DPU_HW_BLK_DSC , hw_dsc,ARRAY_SIZE (hw_dsc));for (i =0 ; i < num_dsc; i++) { dpu_enc->hw_dsc[i] =to_dpu_hw_dsc (hw_dsc[i]);
@@ -1186,7 +1186,7 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,struct dpu_hw_blk *hw_cdm =NULL ;dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->base.id,DPU_HW_BLK_CDM , + drm_enc->crtc,DPU_HW_BLK_CDM , &hw_cdm,1 ); dpu_enc->cur_master->hw_cdm = hw_cdm ?to_dpu_hw_cdm (hw_cdm) :NULL ; }
@@ -2107,7 +2107,7 @@ static void dpu_encoder_helper_reset_mixers(struct dpu_encoder_phys *phys_enc) global_state =dpu_kms_get_existing_global_state (phys_enc->dpu_kms); num_lm =dpu_rm_get_assigned_resources (&phys_enc->dpu_kms->rm, global_state, - phys_enc->parent->base.id,DPU_HW_BLK_LM , hw_lm,ARRAY_SIZE (hw_lm)); + phys_enc->parent->crtc,DPU_HW_BLK_LM , hw_lm,ARRAY_SIZE (hw_lm));for (i =0 ; i < num_lm; i++) { hw_mixer[i] =to_dpu_hw_mixer (hw_lm[i]);
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +6 -6
@@ -124,12 +124,12 @@ struct dpu_global_state {struct dpu_rm *rm; -uint32_t pingpong_to_enc_id[PINGPONG_MAX -PINGPONG_0 ]; -uint32_t mixer_to_enc_id[LM_MAX -LM_0 ]; -uint32_t ctl_to_enc_id[CTL_MAX -CTL_0 ]; -uint32_t dspp_to_enc_id[DSPP_MAX -DSPP_0 ]; -uint32_t dsc_to_enc_id[DSC_MAX -DSC_0 ]; -uint32_t cdm_to_enc_id; +uint32_t pingpong_to_crtc_id[PINGPONG_MAX -PINGPONG_0 ]; +uint32_t mixer_to_crtc_id[LM_MAX -LM_0 ]; +uint32_t ctl_to_crtc_id[CTL_MAX -CTL_0 ]; +uint32_t dspp_to_crtc_id[DSPP_MAX -DSPP_0 ]; +uint32_t dsc_to_crtc_id[DSC_MAX -DSC_0 ]; +uint32_t cdm_to_crtc_id;uint32_t sspp_to_crtc_id[SSPP_MAX -SSPP_NONE ]; };
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +91 -98
508 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +3 -4
@@ -69,12 +69,11 @@ int dpu_rm_init(struct drm_device *dev,int dpu_rm_reserve (struct dpu_rm *rm,struct dpu_global_state *global_state, -struct drm_encoder *drm_enc, -struct drm_crtc_state *crtc_state, +struct drm_crtc *crtc,struct msm_display_topology *topology);void dpu_rm_release (struct dpu_global_state *global_state, -struct drm_encoder *enc); +struct drm_crtc *crtc); struct dpu_hw_sspp *dpu_rm_reserve_sspp(struct dpu_rm *rm, struct dpu_global_state *global_state,
@@ -85,7 +84,7 @@ void dpu_rm_release_all_sspp(struct dpu_global_state *global_state, struct drm_crtc *crtc);int dpu_rm_get_assigned_resources (struct dpu_rm *rm, -struct dpu_global_state *global_state,uint32_t enc_id, +struct dpu_global_state *global_state,struct drm_crtc *crtc,enum dpu_hw_blk_type type,struct dpu_hw_blk **blks,int blks_size); void dpu_rm_print_state(struct drm_printer *p,
Signature · 1 line
2.34.1
Re: [PATCH v5 03/14] drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation
Quoted 16 lines · Jessica Zhang
From: Dmitry Baryshkov <[email protected]>
Up to now the driver has been using encoder to allocate hardware resources. Switch it to use CRTC id in preparation for the next step.
Reviewed-by Abhinav Kumar <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>Reviewed-by Dmitry Baryshkov <[email protected]>Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Reordered to prevent breaking CI and upon partial applicationChanges in v4 (due to rebase):
- moved*_get_assigned_resources()changes for DSPP and LM from encoder*_virt_atomic_mode_set()to*_assign_crtc_resources()
Quoted 7 lines
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 20 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 10 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 12 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 189 ++++++++++++++-------------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 7 +- 5 files changed, 113 insertions(+), 125 deletions(-)
This patch seems to make kms_color@ctm-max and kms_writeback@writeback-check-output fail on sc7180-trogdor-kingoftown (limozeen didn't start job execution for this commit at this moment).
- https://gitlab.freedesktop.org/drm/msm/-/jobs/70213449
- https://gitlab.freedesktop.org/drm/msm/-/jobs/70213446
I've restarted the jobs, but it would be nice to understand the cause.
Signature · 2 lines
With best wishes Dmitry
PATCH v5 4/14 drm/msm/dpu: Add CWB to msm_display_topology
In reply to Jessica ZhangCurrently, the topology is calculated based on the assumption that the user cannot request real-time and writeback simultaneously. For example, the number of LMs and CTLs are currently based off the number of phys encoders under the assumption there will be at least 1 LM/CTL per phys encoder.
This will not hold true for concurrent writeback as both phys encoders (1 real-time and 1 writeback) must be driven by 1 LM/CTL when concurrent writeback is enabled.
To account for this, add a cwb_enabled flag and only adjust the number of CTL/LMs needed by a given topology based on the number of phys encoders only if CWB is not enabled.
---
Changes in v5:
- Reworded commit message to be more specific
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 11 ++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 14 ++++++++++++-- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 2 ++ 3 files changed, 24 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +10 -1
@@ -1246,6 +1246,8 @@ static struct msm_display_topology dpu_crtc_get_topology(dpu_encoder_update_topology (drm_enc, &topology, crtc_state->state, &crtc_state->adjusted_mode); + topology.cwb_enabled =drm_crtc_in_clone_mode (crtc_state); +/* * Datapath topology selection *
@@ -1259,9 +1261,16 @@ static struct msm_display_topology dpu_crtc_get_topology(* If DSC is enabled, use 2 LMs for 2:2:1 topology * * Add dspps to the reservation requirements if ctm is requested +* +* Only hardcode num_lm to 2 for cases where num_intf == 2 and CWB is not +* enabled. This is because in cases where CWB is enabled, num_intf will +* count both the WB and real-time phys encoders. +* +* For non-DSC CWB usecases, have the num_lm be decided by the +* (mode->hdisplay > MAX_HDISPLAY_SPLIT) check. */ -if (topology.num_intf ==2 ) +if (topology.num_intf ==2 && !topology.cwb_enabled) topology.num_lm =2 ;else if (topology.num_dsc ==2 ) topology.num_lm =2 ;
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +12 -2
@@ -381,8 +381,18 @@ static int _dpu_rm_reserve_ctls(int i =0 , j, num_ctls;bool needs_split_display; -/* each hw_intf needs its own hw_ctrl to program its control path */ - num_ctls = top->num_intf; +/* +* For non-CWB mode, each hw_intf needs its own hw_ctl to program its +* control path. +* +* Hardcode num_ctls to 1 if CWB is enabled because in CWB, both the +* writeback and real-time encoders must be driven by the same control +* path +*/ +if (top->cwb_enabled) + num_ctls =1 ; +else + num_ctls = top->num_intf; needs_split_display =_dpu_rm_needs_split_display (top);
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +2 -0
@@ -52,6 +52,7 @@ struct dpu_rm_sspp_requirements {* @num_dspp: number of dspp blocks used * @num_dsc: number of Display Stream Compression (DSC) blocks used * @needs_cdm: indicates whether cdm block is needed for this display topology +* @cwb_enabled: indicates whether CWB is enabled for this display topology */ struct msm_display_topology {u32 num_lm;
@@ -59,6 +60,7 @@ struct msm_display_topology {u32 num_dspp;u32 num_dsc;bool needs_cdm; +bool cwb_enabled; }; int dpu_rm_init(struct drm_device *dev,
Signature · 1 line
2.34.1
PATCH v5 5/14 drm/msm/dpu: Require modeset if clone mode status changes
In reply to Jessica ZhangIf the clone mode enabled status is changing, a modeset needs to happen so that the resources can be reassigned
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 17 ++++++++++++----- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 3 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 5 +++-- 3 files changed, 17 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +12 -5
@@ -1358,19 +1358,26 @@ static int dpu_crtc_assign_resources(struct drm_crtc *crtc,* * Check if the changes in the object properties demand full mode set. */ -int dpu_crtc_check_mode_changed (struct drm_crtc_state *crtc_state) +int dpu_crtc_check_mode_changed (struct drm_crtc_state *old_crtc_state, +struct drm_crtc_state *new_crtc_state) {struct drm_encoder *drm_enc; -struct drm_crtc *crtc = crtc_state->crtc; +struct drm_crtc *crtc = new_crtc_state->crtc; +bool clone_mode_enabled =drm_crtc_in_clone_mode (old_crtc_state); +bool clone_mode_requested =drm_crtc_in_clone_mode (new_crtc_state);DRM_DEBUG_ATOMIC ("%d\n" , crtc->base.id);/* there might be cases where encoder needs a modeset too */ -drm_for_each_encoder_mask (drm_enc, crtc->dev, crtc_state->encoder_mask) { -if (dpu_encoder_needs_modeset (drm_enc, crtc_state->state)) - crtc_state->mode_changed = true; +drm_for_each_encoder_mask (drm_enc, crtc->dev, new_crtc_state->encoder_mask) { +if (dpu_encoder_needs_modeset (drm_enc, new_crtc_state->state)) + new_crtc_state->mode_changed = true; } +if ((clone_mode_requested && !clone_mode_enabled) || + (!clone_mode_requested && clone_mode_enabled)) + new_crtc_state->mode_changed = true; +return 0 ; }
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h +2 -1
@@ -239,7 +239,8 @@ static inline int dpu_crtc_frame_pending(struct drm_crtc *crtc)return crtc ?atomic_read (&to_dpu_crtc (crtc)->frame_pending) : -EINVAL ; } -int dpu_crtc_check_mode_changed (struct drm_crtc_state *crtc_state); +int dpu_crtc_check_mode_changed (struct drm_crtc_state *old_crtc_state, +struct drm_crtc_state *new_crtc_state);int dpu_crtc_vblank (struct drm_crtc *crtc,bool en);
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3 -2
@@ -449,11 +449,12 @@ static void dpu_kms_disable_commit(struct msm_kms *kms)static int dpu_kms_check_mode_changed (struct msm_kms *kms,struct drm_atomic_state *state) {struct drm_crtc_state *new_crtc_state; +struct drm_crtc_state *old_crtc_state;struct drm_crtc *crtc;int i; -for_each_new_crtc_in_state (state, crtc, new_crtc_state, i) -dpu_crtc_check_mode_changed (new_crtc_state); +for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) +dpu_crtc_check_mode_changed (old_crtc_state, new_crtc_state);return 0 ; }
Signature · 1 line
2.34.1
PATCH v5 6/14 drm/msm/dpu: Fail atomic_check if multiple outputs request CDM block
In reply to Jessica ZhangCurrently, our hardware only supports a single output using CDM block at most. Because of this, we cannot support cases where both writeback and DP output request CDM simultaneously
To avoid this happening when CWB is enabled, change msm_display_topoloy.needs_cdm into a cdm_requested counter to track how many outputs are requesting CDM block. Return EINVAL if multiple outputs are trying to reserve CDM.
---
Changes in v5:
- Changed check to fail only if multiple outputs are requesting CDM simultaneously
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 12 +++++++++--- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -2
@@ -692,10 +692,10 @@ void dpu_encoder_update_topology(struct drm_encoder *drm_enc, fb = conn_state->writeback_job->fb;if (fb &&MSM_FORMAT_IS_YUV (msm_framebuffer_format (fb))) - topology->needs_cdm = true; + topology->cdm_requested++; }else if (disp_info->intf_type ==INTF_DP ) {if (msm_dp_is_yuv_420_enabled (priv->dp[disp_info->h_tile_instance[0 ]], adj_mode)) - topology->needs_cdm = true; + topology->cdm_requested++; } }
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +9 -3
@@ -585,7 +585,8 @@ static int _dpu_rm_reserve_dsc(struct dpu_rm *rm,static int _dpu_rm_reserve_cdm (struct dpu_rm *rm,struct dpu_global_state *global_state, -uint32_t crtc_id) +uint32_t crtc_id, +const struct msm_display_topology *top) {/* try allocating only one CDM block */ if (!rm->cdm_blk) {
@@ -593,6 +594,11 @@ static int _dpu_rm_reserve_cdm(struct dpu_rm *rm,return -EIO ; } +if (top->cdm_requested >1 ) { +DPU_ERROR ("More than 1 INTF requesting CDM\n" ); +return -EINVAL ; + } +if (global_state->cdm_to_crtc_id) {DPU_ERROR ("CDM_0 is already allocated\n" );return -EIO ;
@@ -629,8 +635,8 @@ static int _dpu_rm_make_reservation(if (ret)return ret; -if (topology->needs_cdm) { - ret =_dpu_rm_reserve_cdm (rm, global_state, crtc_id); +if (topology->cdm_requested >0 ) { + ret =_dpu_rm_reserve_cdm (rm, global_state, crtc_id, topology);if (ret) {DPU_ERROR ("unable to find CDM blk\n" );return ret;
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +3 -2
@@ -51,7 +51,8 @@ struct dpu_rm_sspp_requirements {* @num_intf: number of interfaces the panel is mounted on * @num_dspp: number of dspp blocks used * @num_dsc: number of Display Stream Compression (DSC) blocks used -* @needs_cdm: indicates whether cdm block is needed for this display topology +* @cdm_requested: indicates how many outputs are requesting cdm block for +* this display topology * @cwb_enabled: indicates whether CWB is enabled for this display topology */ struct msm_display_topology {
@@ -59,7 +60,7 @@ struct msm_display_topology {u32 num_intf;u32 num_dspp;u32 num_dsc; -bool needs_cdm; +int cdm_requested;bool cwb_enabled; };
Signature · 1 line
2.34.1
Re: [PATCH v5 06/14] drm/msm/dpu: Fail atomic_check if multiple outputs request CDM block
Quoted 42 lines · Jessica Zhang
Currently, our hardware only supports a single output using CDM block at most. Because of this, we cannot support cases where both writeback and DP output request CDM simultaneously
To avoid this happening when CWB is enabled, change msm_display_topoloy.needs_cdm into a
cdm_requestedcounter to track how many outputs are requesting CDM block. Return EINVAL if multiple outputs are trying to reserve CDM.Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Changed check to fail only if multiple outputs are requesting CDM simultaneously--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 12 +++++++++--- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 5 +++-- 3 files changed, 14 insertions(+), 7 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2
-2@@ -692,10 +692,10 @@ void dpu_encoder_update_topology(struct drm_encoder *drm_enc, fb = conn_state->writeback_job->fb;if (fb &&MSM_FORMAT_IS_YUV (msm_framebuffer_format (fb))) - topology->needs_cdm = true; + topology->cdm_requested++; }else if (disp_info->intf_type ==INTF_DP ) {if (msm_dp_is_yuv_420_enabled (priv->dp[disp_info->h_tile_instance[0 ]], adj_mode)) - topology->needs_cdm = true; + topology->cdm_requested++; } }drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +0
-0
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c static int _dpu_rm_reserve_dsc(struct dpu_rm *rm, · line 589
Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +2
-1@@ -585,7 +585,8 @@ static int _dpu_rm_reserve_dsc(struct dpu_rm *rm,static int _dpu_rm_reserve_cdm (struct dpu_rm *rm,struct dpu_global_state *global_state, -uint32_t crtc_id) +uint32_t crtc_id, +const struct msm_display_topology *top)
I think it's enough to pass num_cdm.
Quoted 41 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +7
-2{/* try allocating only one CDM block */ if (!rm->cdm_blk) {@@ -593,6 +594,11 @@ static int _dpu_rm_reserve_cdm(struct dpu_rm *rm,return -EIO ; } +if (top->cdm_requested >1 ) { +DPU_ERROR ("More than 1 INTF requesting CDM\n" ); +return -EINVAL ; + } +if (global_state->cdm_to_crtc_id) {DPU_ERROR ("CDM_0 is already allocated\n" );return -EIO ;@@ -629,8 +635,8 @@ static int _dpu_rm_make_reservation(if (ret)return ret; -if (topology->needs_cdm) { - ret =_dpu_rm_reserve_cdm (rm, global_state, crtc_id); +if (topology->cdm_requested >0 ) { + ret =_dpu_rm_reserve_cdm (rm, global_state, crtc_id, topology);if (ret) {DPU_ERROR ("unable to find CDM blk\n" );return ret;drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +2
-1@@ -51,7 +51,8 @@ struct dpu_rm_sspp_requirements {* @num_intf: number of interfaces the panel is mounted on * @num_dspp: number of dspp blocks used * @num_dsc: number of Display Stream Compression (DSC) blocks used -* @needs_cdm: indicates whether cdm block is needed for this display topology +* @cdm_requested: indicates how many outputs are requesting cdm block for +* this display topology * @cwb_enabled: indicates whether CWB is enabled for this display topology */ struct msm_display_topology {
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h struct msm_display_topology { · line 63
Quoted 5 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +1
-1@@ -59,7 +60,7 @@ struct msm_display_topology {u32 num_intf;u32 num_dspp;u32 num_dsc; -bool needs_cdm; +int cdm_requested;
u32 num_cdm, please.
Quoted 7 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +0
-0bool cwb_enabled; };Signature · 2 lines
-- 2.34.1
Signature · 2 lines
With best wishes Dmitry
PATCH v5 7/14 drm/msm/dpu: Reserve resources for CWB
In reply to Jessica ZhangAdd support for RM to reserve dedicated CWB PINGPONGs and CWB muxes
For concurrent writeback, even-indexed CWB muxes must be assigned to even-indexed LMs and odd-indexed CWB muxes for odd-indexed LMs. The same even/odd rule applies for dedicated CWB PINGPONGs.
Track the CWB muxes in the global state and add a CWB-specific helper to reserve the correct CWB muxes and dedicated PINGPONGs following the even/odd rule.
---
Changes in v5:
- Allocate CWB muxes first then allocate PINGPONG block based on CWB mux index
- Corrected comment doc on odd/even rule
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 34 ++++++++++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 82 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +30 -4
@@ -2,7 +2,7 @@/* * Copyright (C) 2013 Red Hat * Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved. -* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. * * Author: Rob Clark <[email protected]> */
@@ -28,6 +28,7 @@#include "dpu_hw_dsc.h" #include "dpu_hw_merge3d.h" #include "dpu_hw_cdm.h" +#include "dpu_hw_cwb.h" #include "dpu_formats.h" #include "dpu_encoder_phys.h" #include "dpu_crtc.h"
@@ -133,6 +134,9 @@ enum dpu_enc_rc_states {* @cur_slave: As above but for the slave encoder. * @hw_pp: Handle to the pingpong blocks used for the display. No. * pingpong blocks can be different than num_phys_encs. +* @hw_cwb: Handle to the CWB muxes used for concurrent writeback +* display. Number of CWB muxes can be different than +* num_phys_encs. * @hw_dsc: Handle to the DSC blocks used for the display. * @dsc_mask: Bitmask of used DSC blocks. * @intfs_swapped: Whether or not the phys_enc interfaces have been swapped
@@ -177,6 +181,7 @@ struct dpu_encoder_virt {struct dpu_encoder_phys *cur_master;struct dpu_encoder_phys *cur_slave;struct dpu_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_cwb *hw_cwb[MAX_CHANNELS_PER_ENC ];struct dpu_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC ];unsigned int dsc_mask;
@@ -1137,7 +1142,10 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,struct dpu_hw_blk *hw_pp[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_dsc[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_blk *hw_cwb[MAX_CHANNELS_PER_ENC ];int num_ctl, num_pp, num_dsc; +int num_cwb =0 ; +bool is_cwb_encoder;unsigned int dsc_mask =0 ;int i;
@@ -1151,6 +1159,8 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, priv = drm_enc->dev->dev_private; dpu_kms =to_dpu_kms (priv->kms); + is_cwb_encoder =drm_crtc_in_clone_mode (crtc_state) && + dpu_enc->disp_info.intf_type ==INTF_WB ; global_state =dpu_kms_get_existing_global_state (dpu_kms);if (IS_ERR_OR_NULL (global_state)) {
@@ -1161,9 +1171,25 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,trace_dpu_enc_mode_set (DRMID (drm_enc));/* Query resource that have been reserved in atomic check step. */ - num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->crtc,DPU_HW_BLK_PINGPONG , hw_pp, -ARRAY_SIZE (hw_pp)); +if (is_cwb_encoder) { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_DCWB_PINGPONG , + hw_pp,ARRAY_SIZE (hw_pp)); + num_cwb =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_CWB , + hw_cwb,ARRAY_SIZE (hw_cwb)); + }else { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_PINGPONG , hw_pp, +ARRAY_SIZE (hw_pp)); + } + +for (i =0 ; i < num_cwb; i++) + dpu_enc->hw_cwb[i] =to_dpu_hw_cwb (hw_cwb[i]); + num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, drm_enc->crtc,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl));
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h +2 -0
@@ -77,12 +77,14 @@ enum dpu_hw_blk_type {DPU_HW_BLK_LM ,DPU_HW_BLK_CTL ,DPU_HW_BLK_PINGPONG , +DPU_HW_BLK_DCWB_PINGPONG ,DPU_HW_BLK_INTF ,DPU_HW_BLK_WB ,DPU_HW_BLK_DSPP ,DPU_HW_BLK_MERGE_3D ,DPU_HW_BLK_DSC ,DPU_HW_BLK_CDM , +DPU_HW_BLK_CWB , DPU_HW_BLK_MAX, };
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +1 -0
@@ -132,6 +132,7 @@ struct dpu_global_state {uint32_t cdm_to_crtc_id;uint32_t sspp_to_crtc_id[SSPP_MAX -SSPP_NONE ]; +uint32_t cwb_to_crtc_id[CWB_MAX -CWB_0 ]; };struct dpu_global_state
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +82 -0
122 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v5 07/14] drm/msm/dpu: Reserve resources for CWB
Quoted 167 lines · Jessica Zhang
Add support for RM to reserve dedicated CWB PINGPONGs and CWB muxes
For concurrent writeback, even-indexed CWB muxes must be assigned to even-indexed LMs and odd-indexed CWB muxes for odd-indexed LMs. The same even/odd rule applies for dedicated CWB PINGPONGs.
Track the CWB muxes in the global state and add a CWB-specific helper to reserve the correct CWB muxes and dedicated PINGPONGs following the even/odd rule.
Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Allocate CWB muxes first then allocate PINGPONG block based on CWB mux index
- Corrected comment doc on odd/even rule--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 34 ++++++++++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 82 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +30
-4@@ -2,7 +2,7 @@/* * Copyright (C) 2013 Red Hat * Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved. -* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. * * Author: Rob Clark <[email protected]> */ @@ -28,6 +28,7 @@#include "dpu_hw_dsc.h" #include "dpu_hw_merge3d.h" #include "dpu_hw_cdm.h" +#include "dpu_hw_cwb.h" #include "dpu_formats.h" #include "dpu_encoder_phys.h" #include "dpu_crtc.h" @@ -133,6 +134,9 @@ enum dpu_enc_rc_states {* @cur_slave: As above but for the slave encoder. * @hw_pp: Handle to the pingpong blocks used for the display. No. * pingpong blocks can be different than num_phys_encs. +* @hw_cwb: Handle to the CWB muxes used for concurrent writeback +* display. Number of CWB muxes can be different than +* num_phys_encs. * @hw_dsc: Handle to the DSC blocks used for the display. * @dsc_mask: Bitmask of used DSC blocks. * @intfs_swapped: Whether or not the phys_enc interfaces have been swapped @@ -177,6 +181,7 @@ struct dpu_encoder_virt {struct dpu_encoder_phys *cur_master;struct dpu_encoder_phys *cur_slave;struct dpu_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_cwb *hw_cwb[MAX_CHANNELS_PER_ENC ];struct dpu_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC ];unsigned int dsc_mask;@@ -1137,7 +1142,10 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,struct dpu_hw_blk *hw_pp[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_dsc[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_blk *hw_cwb[MAX_CHANNELS_PER_ENC ];int num_ctl, num_pp, num_dsc; +int num_cwb =0 ; +bool is_cwb_encoder;unsigned int dsc_mask =0 ;int i;@@ -1151,6 +1159,8 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, priv = drm_enc->dev->dev_private; dpu_kms =to_dpu_kms (priv->kms); + is_cwb_encoder =drm_crtc_in_clone_mode (crtc_state) && + dpu_enc->disp_info.intf_type ==INTF_WB ; global_state =dpu_kms_get_existing_global_state (dpu_kms);if (IS_ERR_OR_NULL (global_state)) {@@ -1161,9 +1171,25 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,trace_dpu_enc_mode_set (DRMID (drm_enc));/* Query resource that have been reserved in atomic check step. */ - num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->crtc,DPU_HW_BLK_PINGPONG , hw_pp, -ARRAY_SIZE (hw_pp)); +if (is_cwb_encoder) { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_DCWB_PINGPONG , + hw_pp,ARRAY_SIZE (hw_pp)); + num_cwb =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_CWB , + hw_cwb,ARRAY_SIZE (hw_cwb)); + }else { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_PINGPONG , hw_pp, +ARRAY_SIZE (hw_pp)); + } + +for (i =0 ; i < num_cwb; i++) + dpu_enc->hw_cwb[i] =to_dpu_hw_cwb (hw_cwb[i]); + num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, drm_enc->crtc,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl));drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h +2
-0@@ -77,12 +77,14 @@ enum dpu_hw_blk_type {DPU_HW_BLK_LM ,DPU_HW_BLK_CTL ,DPU_HW_BLK_PINGPONG , +DPU_HW_BLK_DCWB_PINGPONG ,DPU_HW_BLK_INTF ,DPU_HW_BLK_WB ,DPU_HW_BLK_DSPP ,DPU_HW_BLK_MERGE_3D ,DPU_HW_BLK_DSC ,DPU_HW_BLK_CDM , +DPU_HW_BLK_CWB , DPU_HW_BLK_MAX, };drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +1
-0@@ -132,6 +132,7 @@ struct dpu_global_state {uint32_t cdm_to_crtc_id;uint32_t sspp_to_crtc_id[SSPP_MAX -SSPP_NONE ]; +uint32_t cwb_to_crtc_id[CWB_MAX -CWB_0 ]; };struct dpu_global_state drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +16
-0@@ -233,6 +233,54 @@ static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int primary_idx)return -EINVAL ; } +static int _dpu_rm_reserve_cwb_mux_and_pingpongs (struct dpu_rm *rm, +struct dpu_global_state *global_state, +uint32_t crtc_id, +struct msm_display_topology *topology) +{ +int num_cwb_mux = topology->num_lm, cwb_mux_count =0 ; +int cwb_pp_start_idx =PINGPONG_CWB_0 -PINGPONG_0 ; +int cwb_pp_idx[MAX_BLOCKS ]; +int cwb_mux_idx[MAX_BLOCKS ]; + +/* +* Reserve additional dedicated CWB PINGPONG blocks and muxes for each +* mixer +* +* TODO: add support reserving resources for platforms with no +* PINGPONG_CWB
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int primary_idx) · line 261
Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +10
-0+*/ +for (int i =0 ; i <ARRAY_SIZE (rm->mixer_blks) && + cwb_mux_count < num_cwb_mux; i++) { +for (int j =0 ; j <ARRAY_SIZE (rm->cwb_blks); j++) { +/* +* Odd LMs must be assigned to odd CWB muxes and even +* LMs with even CWB muxes +*/ +if (reserved_by_other (global_state->cwb_to_crtc_id, j, crtc_id) || + i %2 != j %2 )
Should't it be a loop over allocated LMs with the check that lm[i]->idx % 2 != j % 2 ?
Otherwise you are looping over some random LMs and trying to match CWB indices against them.
Quoted 103 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +56
-0+continue ; + + cwb_mux_idx[cwb_mux_count] = j; + cwb_pp_idx[cwb_mux_count] = j + cwb_pp_start_idx; + cwb_mux_count++; +break ; + } + } + +if (cwb_mux_count != num_cwb_mux) { +DPU_ERROR ("Unable to reserve all CWB PINGPONGs\n" ); +return -ENAVAIL ; + } + +for (int i =0 ; i < cwb_mux_count; i++) { + global_state->pingpong_to_crtc_id[cwb_pp_idx[i]] = crtc_id; + global_state->cwb_to_crtc_id[cwb_mux_idx[i]] = crtc_id; + } + +return 0 ; +} +/** * _dpu_rm_check_lm_and_get_connected_blks - check if proposed layer mixer meets * proposed use case requirements, incl. hardwired dependent blocks like @@ -623,6 +671,12 @@ static int _dpu_rm_make_reservation(return ret; } +if (topology->cwb_enabled) { + ret =_dpu_rm_reserve_cwb_mux_and_pingpongs (rm, global_state, + crtc_id, topology); +if (ret) +return ret; + } ret =_dpu_rm_reserve_ctls (rm, global_state, crtc_id, topology);@@ -680,6 +734,8 @@ void dpu_rm_release(struct dpu_global_state *global_state,_dpu_rm_clear_mapping (global_state->dspp_to_crtc_id,ARRAY_SIZE (global_state->dspp_to_crtc_id), crtc_id);_dpu_rm_clear_mapping (&global_state->cdm_to_crtc_id,1 , crtc_id); +_dpu_rm_clear_mapping (global_state->cwb_to_crtc_id, +ARRAY_SIZE (global_state->cwb_to_crtc_id), crtc_id); }/** @@ -824,6 +880,7 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,switch (type) {case DPU_HW_BLK_PINGPONG : +case DPU_HW_BLK_DCWB_PINGPONG : hw_blks = rm->pingpong_blks; hw_to_crtc_id = global_state->pingpong_to_crtc_id; max_blks =ARRAY_SIZE (rm->pingpong_blks);@@ -853,6 +910,11 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm, hw_to_crtc_id = &global_state->cdm_to_crtc_id; max_blks =1 ;break ; +case DPU_HW_BLK_CWB : + hw_blks = rm->cwb_blks; + hw_to_crtc_id = global_state->cwb_to_crtc_id; + max_blks =ARRAY_SIZE (rm->cwb_blks); +break ;default :DPU_ERROR ("blk type %d not managed by rm\n" , type);return 0 ;@@ -863,6 +925,20 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,if (hw_to_crtc_id[i] != crtc_id)continue ; +if (type ==DPU_HW_BLK_PINGPONG ) { +struct dpu_hw_pingpong *pp =to_dpu_hw_pingpong (hw_blks[i]); + +if (pp->idx >=PINGPONG_CWB_0 ) +continue ; + } + +if (type ==DPU_HW_BLK_DCWB_PINGPONG ) { +struct dpu_hw_pingpong *pp =to_dpu_hw_pingpong (hw_blks[i]); + +if (pp->idx <PINGPONG_CWB_0 ) +continue ; + } +if (num_blks == blks_size) {DPU_ERROR ("More than %d resources assigned to crtc %d\n" , blks_size, crtc_id);@@ -945,4 +1021,10 @@ void dpu_rm_print_state(struct drm_printer *p,dpu_rm_print_state_helper (p, rm->hw_sspp[i] ? &rm->hw_sspp[i]->base :NULL , global_state->sspp_to_crtc_id[i]);drm_puts (p,"\n" ); + +drm_puts (p,"\tcwb=" ); +for (i =0 ; i <ARRAY_SIZE (global_state->cwb_to_crtc_id); i++) +dpu_rm_print_state_helper (p, rm->cwb_blks[i], + global_state->cwb_to_crtc_id[i]); +drm_puts (p,"\n" ); }Signature · 2 lines
-- 2.34.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v5 07/14] drm/msm/dpu: Reserve resources for CWB
Quoted 175 lines · Dmitry Baryshkov
Quoted 174 lines · Jessica Zhang
Add support for RM to reserve dedicated CWB PINGPONGs and CWB muxes
For concurrent writeback, even-indexed CWB muxes must be assigned to even-indexed LMs and odd-indexed CWB muxes for odd-indexed LMs. The same even/odd rule applies for dedicated CWB PINGPONGs.
Track the CWB muxes in the global state and add a CWB-specific helper to reserve the correct CWB muxes and dedicated PINGPONGs following the even/odd rule.
Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Allocate CWB muxes first then allocate PINGPONG block based on CWB mux index
- Corrected comment doc on odd/even rule--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 34 ++++++++++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 82 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +30
-4@@ -2,7 +2,7 @@/* * Copyright (C) 2013 Red Hat * Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved. -* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. * * Author: Rob Clark <[email protected]> */ @@ -28,6 +28,7 @@#include "dpu_hw_dsc.h" #include "dpu_hw_merge3d.h" #include "dpu_hw_cdm.h" +#include "dpu_hw_cwb.h" #include "dpu_formats.h" #include "dpu_encoder_phys.h" #include "dpu_crtc.h" @@ -133,6 +134,9 @@ enum dpu_enc_rc_states {* @cur_slave: As above but for the slave encoder. * @hw_pp: Handle to the pingpong blocks used for the display. No. * pingpong blocks can be different than num_phys_encs. +* @hw_cwb: Handle to the CWB muxes used for concurrent writeback +* display. Number of CWB muxes can be different than +* num_phys_encs. * @hw_dsc: Handle to the DSC blocks used for the display. * @dsc_mask: Bitmask of used DSC blocks. * @intfs_swapped: Whether or not the phys_enc interfaces have been swapped @@ -177,6 +181,7 @@ struct dpu_encoder_virt {struct dpu_encoder_phys *cur_master;struct dpu_encoder_phys *cur_slave;struct dpu_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_cwb *hw_cwb[MAX_CHANNELS_PER_ENC ];struct dpu_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC ];unsigned int dsc_mask;@@ -1137,7 +1142,10 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,struct dpu_hw_blk *hw_pp[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_dsc[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_blk *hw_cwb[MAX_CHANNELS_PER_ENC ];int num_ctl, num_pp, num_dsc; +int num_cwb =0 ; +bool is_cwb_encoder;unsigned int dsc_mask =0 ;int i;@@ -1151,6 +1159,8 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, priv = drm_enc->dev->dev_private; dpu_kms =to_dpu_kms (priv->kms); + is_cwb_encoder =drm_crtc_in_clone_mode (crtc_state) && + dpu_enc->disp_info.intf_type ==INTF_WB ; global_state =dpu_kms_get_existing_global_state (dpu_kms);if (IS_ERR_OR_NULL (global_state)) {@@ -1161,9 +1171,25 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,trace_dpu_enc_mode_set (DRMID (drm_enc));/* Query resource that have been reserved in atomic check step. */ - num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->crtc,DPU_HW_BLK_PINGPONG , hw_pp, -ARRAY_SIZE (hw_pp)); +if (is_cwb_encoder) { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_DCWB_PINGPONG , + hw_pp,ARRAY_SIZE (hw_pp)); + num_cwb =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_CWB , + hw_cwb,ARRAY_SIZE (hw_cwb)); + }else { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_PINGPONG , hw_pp, +ARRAY_SIZE (hw_pp)); + } + +for (i =0 ; i < num_cwb; i++) + dpu_enc->hw_cwb[i] =to_dpu_hw_cwb (hw_cwb[i]); + num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, drm_enc->crtc,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl));drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h +2
-0@@ -77,12 +77,14 @@ enum dpu_hw_blk_type {DPU_HW_BLK_LM ,DPU_HW_BLK_CTL ,DPU_HW_BLK_PINGPONG , +DPU_HW_BLK_DCWB_PINGPONG ,DPU_HW_BLK_INTF ,DPU_HW_BLK_WB ,DPU_HW_BLK_DSPP ,DPU_HW_BLK_MERGE_3D ,DPU_HW_BLK_DSC ,DPU_HW_BLK_CDM , +DPU_HW_BLK_CWB , DPU_HW_BLK_MAX, };drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +1
-0@@ -132,6 +132,7 @@ struct dpu_global_state {uint32_t cdm_to_crtc_id;uint32_t sspp_to_crtc_id[SSPP_MAX -SSPP_NONE ]; +uint32_t cwb_to_crtc_id[CWB_MAX -CWB_0 ]; };struct dpu_global_state drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +23
-0@@ -233,6 +233,54 @@ static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int primary_idx)return -EINVAL ; } +static int _dpu_rm_reserve_cwb_mux_and_pingpongs (struct dpu_rm *rm, +struct dpu_global_state *global_state, +uint32_t crtc_id, +struct msm_display_topology *topology) +{ +int num_cwb_mux = topology->num_lm, cwb_mux_count =0 ; +int cwb_pp_start_idx =PINGPONG_CWB_0 -PINGPONG_0 ; +int cwb_pp_idx[MAX_BLOCKS ]; +int cwb_mux_idx[MAX_BLOCKS ]; + +/* +* Reserve additional dedicated CWB PINGPONG blocks and muxes for each +* mixer +* +* TODO: add support reserving resources for platforms with no +* PINGPONG_CWB +*/ +for (int i =0 ; i <ARRAY_SIZE (rm->mixer_blks) && + cwb_mux_count < num_cwb_mux; i++) { +for (int j =0 ; j <ARRAY_SIZE (rm->cwb_blks); j++) { +/* +* Odd LMs must be assigned to odd CWB muxes and even +* LMs with even CWB muxes
Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int primary_idx) · line 261
Quoted 3 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +3
-0+*/ +if (reserved_by_other (global_state->cwb_to_crtc_id, j, crtc_id) || + i %2 != j %2 )Should't it be a loop over allocated LMs with the check that lm[i]->idx % 2 != j % 2 ?
Otherwise you are looping over some random LMs and trying to match CWB indices against them.
Hi Dmitry,
The RM array idx are based of the hw block ids [1] so there isn't much difference using i and lm[i]->id.
Thanks,
Jessica Zhang
[1] https://elixir.bootlin.com/linux/v6.13.1/source/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c#L74
Quoted 108 lines
Quoted 104 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +56
-0+continue ; + + cwb_mux_idx[cwb_mux_count] = j; + cwb_pp_idx[cwb_mux_count] = j + cwb_pp_start_idx; + cwb_mux_count++; +break ; + } + } + +if (cwb_mux_count != num_cwb_mux) { +DPU_ERROR ("Unable to reserve all CWB PINGPONGs\n" ); +return -ENAVAIL ; + } + +for (int i =0 ; i < cwb_mux_count; i++) { + global_state->pingpong_to_crtc_id[cwb_pp_idx[i]] = crtc_id; + global_state->cwb_to_crtc_id[cwb_mux_idx[i]] = crtc_id; + } + +return 0 ; +} +/** * _dpu_rm_check_lm_and_get_connected_blks - check if proposed layer mixer meets * proposed use case requirements, incl. hardwired dependent blocks like @@ -623,6 +671,12 @@ static int _dpu_rm_make_reservation(return ret; } +if (topology->cwb_enabled) { + ret =_dpu_rm_reserve_cwb_mux_and_pingpongs (rm, global_state, + crtc_id, topology); +if (ret) +return ret; + } ret =_dpu_rm_reserve_ctls (rm, global_state, crtc_id, topology);@@ -680,6 +734,8 @@ void dpu_rm_release(struct dpu_global_state *global_state,_dpu_rm_clear_mapping (global_state->dspp_to_crtc_id,ARRAY_SIZE (global_state->dspp_to_crtc_id), crtc_id);_dpu_rm_clear_mapping (&global_state->cdm_to_crtc_id,1 , crtc_id); +_dpu_rm_clear_mapping (global_state->cwb_to_crtc_id, +ARRAY_SIZE (global_state->cwb_to_crtc_id), crtc_id); }/** @@ -824,6 +880,7 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,switch (type) {case DPU_HW_BLK_PINGPONG : +case DPU_HW_BLK_DCWB_PINGPONG : hw_blks = rm->pingpong_blks; hw_to_crtc_id = global_state->pingpong_to_crtc_id; max_blks =ARRAY_SIZE (rm->pingpong_blks);@@ -853,6 +910,11 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm, hw_to_crtc_id = &global_state->cdm_to_crtc_id; max_blks =1 ;break ; +case DPU_HW_BLK_CWB : + hw_blks = rm->cwb_blks; + hw_to_crtc_id = global_state->cwb_to_crtc_id; + max_blks =ARRAY_SIZE (rm->cwb_blks); +break ;default :DPU_ERROR ("blk type %d not managed by rm\n" , type);return 0 ;@@ -863,6 +925,20 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,if (hw_to_crtc_id[i] != crtc_id)continue ; +if (type ==DPU_HW_BLK_PINGPONG ) { +struct dpu_hw_pingpong *pp =to_dpu_hw_pingpong (hw_blks[i]); + +if (pp->idx >=PINGPONG_CWB_0 ) +continue ; + } + +if (type ==DPU_HW_BLK_DCWB_PINGPONG ) { +struct dpu_hw_pingpong *pp =to_dpu_hw_pingpong (hw_blks[i]); + +if (pp->idx <PINGPONG_CWB_0 ) +continue ; + } +if (num_blks == blks_size) {DPU_ERROR ("More than %d resources assigned to crtc %d\n" , blks_size, crtc_id);@@ -945,4 +1021,10 @@ void dpu_rm_print_state(struct drm_printer *p,dpu_rm_print_state_helper (p, rm->hw_sspp[i] ? &rm->hw_sspp[i]->base :NULL , global_state->sspp_to_crtc_id[i]);drm_puts (p,"\n" ); + +drm_puts (p,"\tcwb=" ); +for (i =0 ; i <ARRAY_SIZE (global_state->cwb_to_crtc_id); i++) +dpu_rm_print_state_helper (p, rm->cwb_blks[i], + global_state->cwb_to_crtc_id[i]); +drm_puts (p,"\n" ); }Signature · 2 lines
-- 2.34.1Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v5 07/14] drm/msm/dpu: Reserve resources for CWB
Quoted 177 lines · Jessica Zhang
Quoted 165 lines · Dmitry Baryshkov
Quoted 164 lines · Jessica Zhang
Add support for RM to reserve dedicated CWB PINGPONGs and CWB muxes
For concurrent writeback, even-indexed CWB muxes must be assigned to even-indexed LMs and odd-indexed CWB muxes for odd-indexed LMs. The same even/odd rule applies for dedicated CWB PINGPONGs.
Track the CWB muxes in the global state and add a CWB-specific helper to reserve the correct CWB muxes and dedicated PINGPONGs following the even/odd rule.
Signed-off-by Jessica Zhang <[email protected]>---
Changes in v5:
- Allocate CWB muxes first then allocate PINGPONG block based on CWB mux index
- Corrected comment doc on odd/even rule--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 34 ++++++++++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 82 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +30
-4@@ -2,7 +2,7 @@/* * Copyright (C) 2013 Red Hat * Copyright (c) 2014-2018, 2020-2021 The Linux Foundation. All rights reserved. -* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. * * Author: Rob Clark <[email protected]> */ @@ -28,6 +28,7 @@#include "dpu_hw_dsc.h" #include "dpu_hw_merge3d.h" #include "dpu_hw_cdm.h" +#include "dpu_hw_cwb.h" #include "dpu_formats.h" #include "dpu_encoder_phys.h" #include "dpu_crtc.h" @@ -133,6 +134,9 @@ enum dpu_enc_rc_states {* @cur_slave: As above but for the slave encoder. * @hw_pp: Handle to the pingpong blocks used for the display. No. * pingpong blocks can be different than num_phys_encs. +* @hw_cwb: Handle to the CWB muxes used for concurrent writeback +* display. Number of CWB muxes can be different than +* num_phys_encs. * @hw_dsc: Handle to the DSC blocks used for the display. * @dsc_mask: Bitmask of used DSC blocks. * @intfs_swapped: Whether or not the phys_enc interfaces have been swapped @@ -177,6 +181,7 @@ struct dpu_encoder_virt {struct dpu_encoder_phys *cur_master;struct dpu_encoder_phys *cur_slave;struct dpu_hw_pingpong *hw_pp[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_cwb *hw_cwb[MAX_CHANNELS_PER_ENC ];struct dpu_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC ];unsigned int dsc_mask;@@ -1137,7 +1142,10 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,struct dpu_hw_blk *hw_pp[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_ctl[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_dsc[MAX_CHANNELS_PER_ENC ]; +struct dpu_hw_blk *hw_cwb[MAX_CHANNELS_PER_ENC ];int num_ctl, num_pp, num_dsc; +int num_cwb =0 ; +bool is_cwb_encoder;unsigned int dsc_mask =0 ;int i;@@ -1151,6 +1159,8 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, priv = drm_enc->dev->dev_private; dpu_kms =to_dpu_kms (priv->kms); + is_cwb_encoder =drm_crtc_in_clone_mode (crtc_state) && + dpu_enc->disp_info.intf_type ==INTF_WB ; global_state =dpu_kms_get_existing_global_state (dpu_kms);if (IS_ERR_OR_NULL (global_state)) {@@ -1161,9 +1171,25 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,trace_dpu_enc_mode_set (DRMID (drm_enc));/* Query resource that have been reserved in atomic check step. */ - num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, - drm_enc->crtc,DPU_HW_BLK_PINGPONG , hw_pp, -ARRAY_SIZE (hw_pp)); +if (is_cwb_encoder) { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_DCWB_PINGPONG , + hw_pp,ARRAY_SIZE (hw_pp)); + num_cwb =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_CWB , + hw_cwb,ARRAY_SIZE (hw_cwb)); + }else { + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + drm_enc->crtc, +DPU_HW_BLK_PINGPONG , hw_pp, +ARRAY_SIZE (hw_pp)); + } + +for (i =0 ; i < num_cwb; i++) + dpu_enc->hw_cwb[i] =to_dpu_hw_cwb (hw_cwb[i]); + num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, drm_enc->crtc,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl));drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h +2
-0@@ -77,12 +77,14 @@ enum dpu_hw_blk_type {DPU_HW_BLK_LM ,DPU_HW_BLK_CTL ,DPU_HW_BLK_PINGPONG , +DPU_HW_BLK_DCWB_PINGPONG ,DPU_HW_BLK_INTF ,DPU_HW_BLK_WB ,DPU_HW_BLK_DSPP ,DPU_HW_BLK_MERGE_3D ,DPU_HW_BLK_DSC ,DPU_HW_BLK_CDM , +DPU_HW_BLK_CWB , DPU_HW_BLK_MAX, };drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +1
-0@@ -132,6 +132,7 @@ struct dpu_global_state {uint32_t cdm_to_crtc_id;uint32_t sspp_to_crtc_id[SSPP_MAX -SSPP_NONE ]; +uint32_t cwb_to_crtc_id[CWB_MAX -CWB_0 ]; };struct dpu_global_state drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +23
-0@@ -233,6 +233,54 @@ static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int primary_idx)return -EINVAL ; } +static int _dpu_rm_reserve_cwb_mux_and_pingpongs (struct dpu_rm *rm, +struct dpu_global_state *global_state, +uint32_t crtc_id, +struct msm_display_topology *topology) +{ +int num_cwb_mux = topology->num_lm, cwb_mux_count =0 ; +int cwb_pp_start_idx =PINGPONG_CWB_0 -PINGPONG_0 ; +int cwb_pp_idx[MAX_BLOCKS ]; +int cwb_mux_idx[MAX_BLOCKS ]; + +/* +* Reserve additional dedicated CWB PINGPONG blocks and muxes for each +* mixer +* +* TODO: add support reserving resources for platforms with no +* PINGPONG_CWB +*/ +for (int i =0 ; i <ARRAY_SIZE (rm->mixer_blks) && + cwb_mux_count < num_cwb_mux; i++) { +for (int j =0 ; j <ARRAY_SIZE (rm->cwb_blks); j++) { +/* +* Odd LMs must be assigned to odd CWB muxes and even +* LMs with even CWB muxes Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int primary_idx) · line 261
Quoted 3 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +3
-0+*/ +if (reserved_by_other (global_state->cwb_to_crtc_id, j, crtc_id) || + i %2 != j %2 )Should't it be a loop over allocated LMs with the check that lm[i]->idx % 2 != j % 2 ?
Otherwise you are looping over some random LMs and trying to match CWB indices against them.
Quoted 4 lines
Hi Dmitry,
The RM array idx are based of the hw block ids [1] so there isn't much difference using i and lm[i]->id.
Ack. Please add a comment (as I think there will be another revision).
Quoted 7 lines
Thanks,
Jessica Zhang
[1] https://elixir.bootlin.com/linux/v6.13.1/source/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c#L74
Signature · 2 lines
With best wishes Dmitry
PATCH v5 8/14 drm/msm/dpu: Configure CWB in writeback encoder
In reply to Jessica ZhangCache the CWB block mask in the DPU virtual encoder and configure CWB according to the CWB block mask within the writeback phys encoder
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 75 +++++++++++++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 7 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 4 +- 3 files changed, 83 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +74 -1
@@ -24,6 +24,7 @@#include "dpu_hw_catalog.h" #include "dpu_hw_intf.h" #include "dpu_hw_ctl.h" +#include "dpu_hw_cwb.h" #include "dpu_hw_dspp.h" #include "dpu_hw_dsc.h" #include "dpu_hw_merge3d.h"
@@ -139,6 +140,7 @@ enum dpu_enc_rc_states {* num_phys_encs. * @hw_dsc: Handle to the DSC blocks used for the display. * @dsc_mask: Bitmask of used DSC blocks. +* @cwb_mask Bitmask of used CWB muxes * @intfs_swapped: Whether or not the phys_enc interfaces have been swapped * for partial update right-only cases, such as pingpong * split where virtual pingpong does not generate IRQs
@@ -185,6 +187,7 @@ struct dpu_encoder_virt {struct dpu_hw_dsc *hw_dsc[MAX_CHANNELS_PER_ENC ];unsigned int dsc_mask; +unsigned int cwb_mask;bool intfs_swapped;
@@ -1147,6 +1150,7 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc,int num_cwb =0 ;bool is_cwb_encoder;unsigned int dsc_mask =0 ; +unsigned int cwb_mask =0 ;int i;if (!drm_enc) {
@@ -1187,8 +1191,12 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, ARRAY_SIZE(hw_pp)); } -for (i =0 ; i < num_cwb; i++) +for (i =0 ; i < num_cwb; i++) { dpu_enc->hw_cwb[i] =to_dpu_hw_cwb (hw_cwb[i]); + cwb_mask |=BIT (dpu_enc->hw_cwb[i]->idx -CWB_0 ); + } + + dpu_enc->cwb_mask = cwb_mask; num_ctl =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, drm_enc->crtc,DPU_HW_BLK_CTL , hw_ctl,ARRAY_SIZE (hw_ctl));
@@ -2225,6 +2233,9 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc) } } +if (dpu_enc->cwb_mask) +dpu_encoder_helper_phys_setup_cwb (phys_enc, false); +/* reset the merge 3D HW block */ if (phys_enc->hw_pp && phys_enc->hw_pp->merge_3d) { phys_enc->hw_pp->merge_3d->ops.setup_3d_mode(phys_enc->hw_pp->merge_3d,
@@ -2268,6 +2279,56 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc) ctl->ops.clear_pending_flush (ctl); } +void dpu_encoder_helper_phys_setup_cwb (struct dpu_encoder_phys *phys_enc, +bool enable) +{ +struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (phys_enc->parent); +struct dpu_hw_cwb *hw_cwb; +struct dpu_hw_cwb_setup_cfg cwb_cfg; + +struct dpu_kms *dpu_kms; +struct dpu_global_state *global_state; +struct dpu_hw_blk *rt_pp_list[MAX_CHANNELS_PER_ENC ]; +int num_pp; + +if (!phys_enc->hw_wb) +return ; + + dpu_kms = phys_enc->dpu_kms; + global_state =dpu_kms_get_existing_global_state (dpu_kms); + num_pp =dpu_rm_get_assigned_resources (&dpu_kms->rm, global_state, + phys_enc->parent->crtc, +DPU_HW_BLK_PINGPONG , rt_pp_list, +ARRAY_SIZE (rt_pp_list)); + +if (num_pp ==0 || num_pp >MAX_CHANNELS_PER_ENC ) { +DPU_DEBUG_ENC (dpu_enc,"invalid num_pp %d\n" , num_pp); +return ; + } + +/* +* The CWB mux supports using LM or DSPP as tap points. For now, +* always use LM tap point +*/ + cwb_cfg.input =INPUT_MODE_LM_OUT ; + +for (int i =0 ; i <MAX_CHANNELS_PER_ENC ; i++) { + hw_cwb = dpu_enc->hw_cwb[i]; +if (!hw_cwb) +continue ; + +if (enable) { +struct dpu_hw_pingpong *hw_pp = +to_dpu_hw_pingpong (rt_pp_list[i]); + cwb_cfg.pp_idx = hw_pp->idx; + }else { + cwb_cfg.pp_idx =PINGPONG_NONE ; + } + + hw_cwb->ops.config_cwb (hw_cwb, &cwb_cfg); + } +} +/** * dpu_encoder_helper_phys_setup_cdm - setup chroma down sampling block * @phys_enc: Pointer to physical encoder
@@ -2728,6 +2789,18 @@ enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder)return INTF_MODE_NONE ; } +/** +* dpu_encoder_helper_get_cwb_mask - get CWB blocks mask for the DPU encoder +* @phys_enc: Pointer to physical encoder structure +*/ +unsigned int dpu_encoder_helper_get_cwb_mask (struct dpu_encoder_phys *phys_enc) +{ +struct drm_encoder *encoder = phys_enc->parent; +struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (encoder); + +return dpu_enc->cwb_mask; +} +/** * dpu_encoder_helper_get_dsc - get DSC blocks mask for the DPU encoder * This helper function is used by physical encoder to get DSC blocks mask
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +6 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2015-2018 The Linux Foundation. All rights reserved. */
@@ -309,6 +309,8 @@ static inline enum dpu_3d_blend_mode dpu_encoder_helper_get_3d_blend_mode(return BLEND_3D_NONE ; } +unsigned int dpu_encoder_helper_get_cwb_mask (struct dpu_encoder_phys *phys_enc); +unsigned int dpu_encoder_helper_get_dsc (struct dpu_encoder_phys *phys_enc);struct drm_dsc_config *dpu_encoder_get_dsc_config (struct drm_encoder *drm_enc);
@@ -331,6 +333,9 @@ int dpu_encoder_helper_wait_for_irq(struct dpu_encoder_phys *phys_enc,void dpu_encoder_helper_phys_cleanup (struct dpu_encoder_phys *phys_enc); +void dpu_encoder_helper_phys_setup_cwb (struct dpu_encoder_phys *phys_enc, +bool enable); +void dpu_encoder_helper_phys_setup_cdm (struct dpu_encoder_phys *phys_enc,const struct msm_format *dpu_fmt,u32 output_type);
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +3 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #define pr_fmt (fmt) "[drm:%s:%d] " fmt, __func__, __LINE__
@@ -340,6 +340,8 @@ static void dpu_encoder_phys_wb_setup(dpu_encoder_helper_phys_setup_cdm (phys_enc, format,CDM_CDWN_OUTPUT_WB ); +dpu_encoder_helper_phys_setup_cwb (phys_enc, true); +dpu_encoder_phys_wb_setup_ctl (phys_enc); }
Signature · 1 line
2.34.1
PATCH v5 9/14 drm/msm/dpu: Support CWB in dpu_hw_ctl
In reply to Jessica ZhangThe CWB mux has a pending flush bit and *_active register.
Add support for configuring them within the dpu_hw_ctl layer.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 13 ++++++++++ .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 30 +++++++++++++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 15 ++++++++++- 4 files changed, 57 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +13 -0
@@ -2262,6 +2262,7 @@ void dpu_encoder_helper_phys_cleanup(struct dpu_encoder_phys *phys_enc) intf_cfg.stream_sel =0 ;/* Don't care value for video mode */ intf_cfg.mode_3d =dpu_encoder_helper_get_3d_blend_mode (phys_enc); intf_cfg.dsc =dpu_encoder_helper_get_dsc (phys_enc); + intf_cfg.cwb = dpu_enc->cwb_mask;if (phys_enc->hw_intf) intf_cfg.intf = phys_enc->hw_intf->idx;
@@ -2284,6 +2285,7 @@ void dpu_encoder_helper_phys_setup_cwb(struct dpu_encoder_phys *phys_enc, {struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (phys_enc->parent);struct dpu_hw_cwb *hw_cwb; +struct dpu_hw_ctl *hw_ctl;struct dpu_hw_cwb_setup_cfg cwb_cfg;struct dpu_kms *dpu_kms;
@@ -2294,6 +2296,14 @@ void dpu_encoder_helper_phys_setup_cwb(struct dpu_encoder_phys *phys_enc,if (!phys_enc->hw_wb)return ; + hw_ctl = phys_enc->hw_ctl; + +if (!phys_enc->hw_ctl) { +DPU_DEBUG ("[wb:%d] no ctl assigned\n" , + phys_enc->hw_wb->idx -WB_0 ); +return ; + } + dpu_kms = phys_enc->dpu_kms; global_state =dpu_kms_get_existing_global_state (dpu_kms); num_pp = dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state,
@@ -2326,6 +2336,9 @@ void dpu_encoder_helper_phys_setup_cwb(struct dpu_encoder_phys *phys_enc, } hw_cwb->ops.config_cwb (hw_cwb, &cwb_cfg); + +if (hw_ctl->ops.update_pending_flush_cwb) + hw_ctl->ops.update_pending_flush_cwb (hw_ctl, hw_cwb->idx); } }
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +1 -0
@@ -236,6 +236,7 @@ static void dpu_encoder_phys_wb_setup_ctl(struct dpu_encoder_phys *phys_enc) intf_cfg.intf =DPU_NONE ; intf_cfg.wb = hw_wb->idx; + intf_cfg.cwb =dpu_encoder_helper_get_cwb_mask (phys_enc);if (mode_3d && hw_pp && hw_pp->merge_3d) intf_cfg.merge_3d = hw_pp->merge_3d->idx;
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +29 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. -* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/delay.h>
@@ -31,12 +31,14 @@#define CTL_MERGE_3D_ACTIVE 0x0E4#define CTL_DSC_ACTIVE 0x0E8#define CTL_WB_ACTIVE 0x0EC +#define CTL_CWB_ACTIVE 0x0F0#define CTL_INTF_ACTIVE 0x0F4#define CTL_CDM_ACTIVE 0x0F8#define CTL_FETCH_PIPE_ACTIVE 0x0FC#define CTL_MERGE_3D_FLUSH 0x100#define CTL_DSC_FLUSH 0x104#define CTL_WB_FLUSH 0x108 +#define CTL_CWB_FLUSH 0x10C#define CTL_INTF_FLUSH 0x110#define CTL_CDM_FLUSH 0x114#define CTL_PERIPH_FLUSH 0x128
@@ -53,6 +55,7 @@#define PERIPH_IDX 30#define INTF_IDX 31#define WB_IDX 16 +#define CWB_IDX 28#define DSPP_IDX 29/* From DPU hw rev 7.x.x */ #define CTL_INVALID_BIT 0xffff#define CTL_DEFAULT_GROUP_ID 0xf
@@ -110,6 +113,7 @@ static inline void dpu_hw_ctl_clear_pending_flush(struct dpu_hw_ctl *ctx) ctx->pending_flush_mask =0x0 ; ctx->pending_intf_flush_mask =0 ; ctx->pending_wb_flush_mask =0 ; + ctx->pending_cwb_flush_mask =0 ; ctx->pending_merge_3d_flush_mask =0 ; ctx->pending_dsc_flush_mask =0 ; ctx->pending_cdm_flush_mask =0 ;
@@ -144,6 +148,9 @@ static inline void dpu_hw_ctl_trigger_flush_v1(struct dpu_hw_ctl *ctx)if (ctx->pending_flush_mask &BIT (WB_IDX ))DPU_REG_WRITE (&ctx->hw,CTL_WB_FLUSH , ctx->pending_wb_flush_mask); +if (ctx->pending_flush_mask &BIT (CWB_IDX )) +DPU_REG_WRITE (&ctx->hw,CTL_CWB_FLUSH , + ctx->pending_cwb_flush_mask);if (ctx->pending_flush_mask &BIT (DSPP_IDX ))for (dspp =DSPP_0 ; dspp <DSPP_MAX ; dspp++) {
@@ -310,6 +317,13 @@ static void dpu_hw_ctl_update_pending_flush_wb_v1(struct dpu_hw_ctl *ctx, ctx->pending_flush_mask |=BIT (WB_IDX ); } +static void dpu_hw_ctl_update_pending_flush_cwb_v1 (struct dpu_hw_ctl *ctx, +enum dpu_cwb cwb) +{ + ctx->pending_cwb_flush_mask |=BIT (cwb -CWB_0 ); + ctx->pending_flush_mask |=BIT (CWB_IDX ); +} +static void dpu_hw_ctl_update_pending_flush_intf_v1 (struct dpu_hw_ctl *ctx,enum dpu_intf intf) {
@@ -547,6 +561,7 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx,u32 intf_active =0 ;u32 dsc_active =0 ;u32 wb_active =0 ; +u32 cwb_active =0 ;u32 mode_sel =0 ;/* CTL_TOP[31:28] carries group_id to collate CTL paths
@@ -561,6 +576,7 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx, intf_active =DPU_REG_READ (c,CTL_INTF_ACTIVE ); wb_active =DPU_REG_READ (c,CTL_WB_ACTIVE ); + cwb_active =DPU_REG_READ (c,CTL_CWB_ACTIVE ); dsc_active =DPU_REG_READ (c,CTL_DSC_ACTIVE );if (cfg->intf)
@@ -569,12 +585,16 @@ static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx,if (cfg->wb) wb_active |=BIT (cfg->wb -WB_0 ); +if (cfg->cwb) + cwb_active |= cfg->cwb; +if (cfg->dsc) dsc_active |= cfg->dsc;DPU_REG_WRITE (c,CTL_TOP , mode_sel);DPU_REG_WRITE (c,CTL_INTF_ACTIVE , intf_active);DPU_REG_WRITE (c,CTL_WB_ACTIVE , wb_active); +DPU_REG_WRITE (c,CTL_CWB_ACTIVE , cwb_active);DPU_REG_WRITE (c,CTL_DSC_ACTIVE , dsc_active);if (cfg->merge_3d)
@@ -624,6 +644,7 @@ static void dpu_hw_ctl_reset_intf_cfg_v1(struct dpu_hw_ctl *ctx,struct dpu_hw_blk_reg_map *c = &ctx->hw;u32 intf_active =0 ;u32 wb_active =0 ; +u32 cwb_active =0 ;u32 merge3d_active =0 ;u32 dsc_active;u32 cdm_active;
@@ -651,6 +672,12 @@ static void dpu_hw_ctl_reset_intf_cfg_v1(struct dpu_hw_ctl *ctx,DPU_REG_WRITE (c,CTL_INTF_ACTIVE , intf_active); } +if (cfg->cwb) { + cwb_active =DPU_REG_READ (c,CTL_CWB_ACTIVE ); + cwb_active &= ~cfg->cwb; +DPU_REG_WRITE (c,CTL_CWB_ACTIVE , cwb_active); + } +if (cfg->wb) { wb_active =DPU_REG_READ (c,CTL_WB_ACTIVE ); wb_active &= ~BIT (cfg->wb -WB_0 );
@@ -703,6 +730,7 @@ static void _setup_ctl_ops(struct dpu_hw_ctl_ops *ops, ops->update_pending_flush_merge_3d = dpu_hw_ctl_update_pending_flush_merge_3d_v1; ops->update_pending_flush_wb = dpu_hw_ctl_update_pending_flush_wb_v1; + ops->update_pending_flush_cwb = dpu_hw_ctl_update_pending_flush_cwb_v1; ops->update_pending_flush_dsc = dpu_hw_ctl_update_pending_flush_dsc_v1; ops->update_pending_flush_cdm = dpu_hw_ctl_update_pending_flush_cdm_v1;
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h +14 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. -* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _DPU_HW_CTL_H
@@ -42,6 +42,7 @@ struct dpu_hw_stage_cfg {* @cdm: CDM block used * @stream_sel: Stream selection for multi-stream interfaces * @dsc: DSC BIT masks used +* @cwb: CWB BIT masks used */ struct dpu_hw_intf_cfg {enum dpu_intf intf;
@@ -51,6 +52,7 @@ struct dpu_hw_intf_cfg {enum dpu_ctl_mode_sel intf_mode_sel;enum dpu_cdm cdm;int stream_sel; +unsigned int cwb;unsigned int dsc; };
@@ -114,6 +116,15 @@ struct dpu_hw_ctl_ops {void (*update_pending_flush_wb)(struct dpu_hw_ctl *ctx,enum dpu_wb blk); +/** +* OR in the given flushbits to the cached pending_(cwb_)flush_mask +* No effect on hardware +* @ctx : ctl path ctx pointer +* @blk : concurrent writeback block index +*/ +void (*update_pending_flush_cwb)(struct dpu_hw_ctl *ctx, +enum dpu_cwb blk); +/** * OR in the given flushbits to the cached pending_(intf_)flush_mask * No effect on hardware
@@ -258,6 +269,7 @@ struct dpu_hw_ctl_ops {* @pending_flush_mask: storage for pending ctl_flush managed via ops * @pending_intf_flush_mask: pending INTF flush * @pending_wb_flush_mask: pending WB flush +* @pending_cwb_flush_mask: pending CWB flush * @pending_dsc_flush_mask: pending DSC flush * @pending_cdm_flush_mask: pending CDM flush * @ops: operation list
@@ -274,6 +286,7 @@ struct dpu_hw_ctl {u32 pending_flush_mask;u32 pending_intf_flush_mask;u32 pending_wb_flush_mask; +u32 pending_cwb_flush_mask;u32 pending_periph_flush_mask;u32 pending_merge_3d_flush_mask;u32 pending_dspp_flush_mask[DSPP_MAX -DSPP_0 ];
Signature · 1 line
2.34.1
PATCH v5 10/14 drm/msm/dpu: Adjust writeback phys encoder setup for CWB
In reply to Jessica ZhangAdjust QoS remapper, OT limit, and CDP parameters to account for concurrent writeback
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +8 -3
@@ -68,7 +68,7 @@ static void dpu_encoder_phys_wb_set_ot_limit( ot_params.num = hw_wb->idx -WB_0 ; ot_params.width = phys_enc->cached_mode.hdisplay; ot_params.height = phys_enc->cached_mode.vdisplay; - ot_params.is_wfd = true; + ot_params.is_wfd = !dpu_encoder_helper_get_cwb_mask (phys_enc); ot_params.frame_rate =drm_mode_vrefresh (&phys_enc->cached_mode); ot_params.vbif_idx = hw_wb->caps->vbif_idx; ot_params.rd = false;
@@ -111,7 +111,7 @@ static void dpu_encoder_phys_wb_set_qos_remap( qos_params.vbif_idx = hw_wb->caps->vbif_idx; qos_params.xin_id = hw_wb->caps->xin_id; qos_params.num = hw_wb->idx -WB_0 ; - qos_params.is_rt = false; + qos_params.is_rt =dpu_encoder_helper_get_cwb_mask (phys_enc); DPU_DEBUG("[qos_remap] wb:%d vbif:%d xin:%d is_rt:%d\n", qos_params.num,
@@ -174,6 +174,7 @@ static void dpu_encoder_phys_wb_setup_fb(struct dpu_encoder_phys *phys_enc,struct dpu_encoder_phys_wb *wb_enc =to_dpu_encoder_phys_wb (phys_enc);struct dpu_hw_wb *hw_wb;struct dpu_hw_wb_cfg *wb_cfg; +u32 cdp_usage;if (!phys_enc || !phys_enc->dpu_kms || !phys_enc->dpu_kms->catalog) {DPU_ERROR ("invalid encoder\n" );
@@ -182,6 +183,10 @@ static void dpu_encoder_phys_wb_setup_fb(struct dpu_encoder_phys *phys_enc, hw_wb = phys_enc->hw_wb; wb_cfg = &wb_enc->wb_cfg; +if (dpu_encoder_helper_get_cwb_mask (phys_enc)) + cdp_usage =DPU_PERF_CDP_USAGE_RT ; +else + cdp_usage =DPU_PERF_CDP_USAGE_NRT ; wb_cfg->intf_mode = phys_enc->intf_mode; wb_cfg->roi.x1 =0 ;
@@ -199,7 +204,7 @@ static void dpu_encoder_phys_wb_setup_fb(struct dpu_encoder_phys *phys_enc,const struct dpu_perf_cfg *perf = phys_enc->dpu_kms->catalog->perf; hw_wb->ops.setup_cdp (hw_wb, format, - perf->cdp_cfg[DPU_PERF_CDP_USAGE_NRT ].wr_enable); + perf->cdp_cfg[cdp_usage].wr_enable); }if (hw_wb->ops.setup_outaddress)
Signature · 1 line
2.34.1
PATCH v5 11/14 drm/msm/dpu: Start frame done timer after encoder kickoff
In reply to Jessica ZhangStarting the frame done timer before the encoder is finished kicking off can lead to unnecessary frame done timeouts when the device is experiencing heavy load (ex. when debug logs are enabled).
Thus, create a separate API for starting the encoder frame done timer and call it after the encoder kickoff is finished
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 4 +++- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 27 +++++++++++++++++++-------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 3 ++- 3 files changed, 24 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +3 -1
@@ -999,8 +999,10 @@ void dpu_crtc_commit_kickoff(struct drm_crtc *crtc)dpu_vbif_clear_errors (dpu_kms); -drm_for_each_encoder_mask (encoder, crtc->dev, crtc->state->encoder_mask) +drm_for_each_encoder_mask (encoder, crtc->dev, crtc->state->encoder_mask) {dpu_encoder_kickoff (encoder); +dpu_encoder_start_frame_done_timer (encoder); + }reinit_completion (&dpu_crtc->frame_done_comp);
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +19 -8
@@ -2086,6 +2086,25 @@ bool dpu_encoder_is_valid_for_commit(struct drm_encoder *drm_enc)return true; } +/** +* dpu_encoder_start_frame_done_timer - Start the encoder frame done timer +* @drm_enc: Pointer to drm encoder structure +*/ +void dpu_encoder_start_frame_done_timer (struct drm_encoder *drm_enc) +{ +struct dpu_encoder_virt *dpu_enc; +unsigned long timeout_ms; + + dpu_enc =to_dpu_encoder_virt (drm_enc); + timeout_ms =DPU_ENCODER_FRAME_DONE_TIMEOUT_FRAMES *1000 / +drm_mode_vrefresh (&drm_enc->crtc->state->adjusted_mode); + +atomic_set (&dpu_enc->frame_done_timeout_ms, timeout_ms); +mod_timer (&dpu_enc->frame_done_timer, + jiffies +msecs_to_jiffies (timeout_ms)); + +} +/** * dpu_encoder_kickoff - trigger a double buffer flip of the ctl path * (i.e. ctl flush and start) immediately.
@@ -2095,7 +2114,6 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc) {struct dpu_encoder_virt *dpu_enc;struct dpu_encoder_phys *phys; -unsigned long timeout_ms;unsigned int i;DPU_ATRACE_BEGIN ("encoder_kickoff" );
@@ -2103,13 +2121,6 @@ void dpu_encoder_kickoff(struct drm_encoder *drm_enc)trace_dpu_enc_kickoff (DRMID (drm_enc)); - timeout_ms =DPU_ENCODER_FRAME_DONE_TIMEOUT_FRAMES *1000 / -drm_mode_vrefresh (&drm_enc->crtc->state->adjusted_mode); - -atomic_set (&dpu_enc->frame_done_timeout_ms, timeout_ms); -mod_timer (&dpu_enc->frame_done_timer, - jiffies +msecs_to_jiffies (timeout_ms)); -/* All phys encs are ready to go, trigger the kickoff */ _dpu_encoder_kickoff_phys (dpu_enc);
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +2 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. * Copyright (C) 2013 Red Hat * Author: Rob Clark <[email protected]>
@@ -95,4 +95,5 @@ void dpu_encoder_cleanup_wb_job(struct drm_encoder *drm_enc,bool dpu_encoder_is_valid_for_commit (struct drm_encoder *drm_enc); +void dpu_encoder_start_frame_done_timer (struct drm_encoder *drm_enc);#endif /* __DPU_ENCODER_H__ */
Signature · 1 line
2.34.1
PATCH v5 12/14 drm/msm/dpu: Skip trigger flush and start for CWB
In reply to Jessica ZhangFor concurrent writeback, the real time encoder is responsible for trigger flush and trigger start. Return early for trigger start and trigger flush for the concurrent writeback encoders.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +18 -0
@@ -1606,6 +1606,7 @@ static void dpu_encoder_off_work(struct work_struct *work)static void _dpu_encoder_trigger_flush (struct drm_encoder *drm_enc,struct dpu_encoder_phys *phys,uint32_t extra_flush_bits) { +struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (drm_enc);struct dpu_hw_ctl *ctl;int pending_kickoff_cnt;u32 ret =UINT_MAX ;
@@ -1623,6 +1624,15 @@ static void _dpu_encoder_trigger_flush(struct drm_encoder *drm_enc, pending_kickoff_cnt =dpu_encoder_phys_inc_pending (phys); +/* Return early if encoder is writeback and in clone mode */ +if (drm_enc->encoder_type ==DRM_MODE_ENCODER_VIRTUAL && + dpu_enc->cwb_mask) { +DPU_DEBUG ("encoder %d skip flush for concurrent writeback encoder\n" , +DRMID (drm_enc)); +return ; + } + +if (extra_flush_bits && ctl->ops.update_pending_flush) ctl->ops.update_pending_flush (ctl, extra_flush_bits);
@@ -1645,6 +1655,8 @@ static void _dpu_encoder_trigger_flush(struct drm_encoder *drm_enc,*/ static void _dpu_encoder_trigger_start (struct dpu_encoder_phys *phys) { +struct dpu_encoder_virt *dpu_enc =to_dpu_encoder_virt (phys->parent); +if (!phys) {DPU_ERROR ("invalid argument(s)\n" );return ;
@@ -1655,6 +1667,12 @@ static void _dpu_encoder_trigger_start(struct dpu_encoder_phys *phys)return ; } +if (phys->parent->encoder_type ==DRM_MODE_ENCODER_VIRTUAL && + dpu_enc->cwb_mask) { +DPU_DEBUG ("encoder %d CWB enabled, skipping\n" ,DRMID (phys->parent)); +return ; + } +if (phys->ops.trigger_start && phys->enable_state !=DPU_ENC_DISABLED ) phys->ops.trigger_start (phys); }
Signature · 1 line
2.34.1
PATCH v5 13/14 drm/msm/dpu: Reorder encoder kickoff for CWB
In reply to Jessica ZhangAdd a helper that will handle the correct order of the encoder kickoffs for concurrent writeback.
For concurrent writeback, the realtime encoder must always kickoff last as it will call the trigger flush and start.
This avoids the following scenario where the writeback encoder increments the pending kickoff count after the WB_DONE interrupt is fired:
If the realtime encoder is kicked off first, the encoder kickoff will flush/start the encoder and increment the pending kickoff count. The WB_DONE interrupt then fires (before the writeback encoder is kicked off). When the writeback encoder enters its kickoff, it will skip the flush/start (due to CWB being enabled) and hit a frame done timeout as the frame was kicked off (and the WB_DONE interrupt fired) without the pending kickoff count being incremented.
In addition, the writeback timer should only start after the realtime encoder is kicked off to ensure that we don't get timeouts when the system has a heavy load (ex. when debug logs are enabled)
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 74 ++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 14 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +60 -14
@@ -953,6 +953,45 @@ static int _dpu_crtc_wait_for_frame_done(struct drm_crtc *crtc)return rc; } +static int dpu_crtc_kickoff_clone_mode (struct drm_crtc *crtc) +{ +struct drm_encoder *encoder; +struct drm_encoder *rt_encoder =NULL , *wb_encoder; +struct dpu_kms *dpu_kms =_dpu_crtc_get_kms (crtc); + +/* Find encoder for real time display */ +drm_for_each_encoder_mask (encoder, crtc->dev, + crtc->state->encoder_mask) { +if (encoder->encoder_type ==DRM_MODE_ENCODER_VIRTUAL ) + wb_encoder = encoder; +else + rt_encoder = encoder; + } + +if (!rt_encoder || !wb_encoder) { +DRM_DEBUG_ATOMIC ("real time or wb encoder not found\n" ); +return -EINVAL ; + } + +dpu_encoder_prepare_for_kickoff (wb_encoder); +dpu_encoder_prepare_for_kickoff (rt_encoder); + +dpu_vbif_clear_errors (dpu_kms); + +/* +* Kickoff real time encoder last as it's the encoder that +* will do the flush +*/ +dpu_encoder_kickoff (wb_encoder); +dpu_encoder_kickoff (rt_encoder); + +/* Don't start frame done timers until the kickoffs have finished */ +dpu_encoder_start_frame_done_timer (wb_encoder); +dpu_encoder_start_frame_done_timer (rt_encoder); + +return 0 ; +} +/** * dpu_crtc_commit_kickoff - trigger kickoff of the commit for this crtc * @crtc: Pointer to drm crtc object
@@ -981,13 +1020,27 @@ void dpu_crtc_commit_kickoff(struct drm_crtc *crtc) goto end; } } -/* -* Encoder will flush/start now, unless it has a tx pending. If so, it -* may delay and flush at an irq event (e.g. ppdone) -*/ -drm_for_each_encoder_mask (encoder, crtc->dev, - crtc->state->encoder_mask) -dpu_encoder_prepare_for_kickoff (encoder); + +if (drm_crtc_in_clone_mode (crtc->state)) { +if (dpu_crtc_kickoff_clone_mode (crtc)) + goto end; + }else { +/* +* Encoder will flush/start now, unless it has a tx pending. +* If so, it may delay and flush at an irq event (e.g. ppdone) +*/ +drm_for_each_encoder_mask (encoder, crtc->dev, + crtc->state->encoder_mask) +dpu_encoder_prepare_for_kickoff (encoder); + +dpu_vbif_clear_errors (dpu_kms); + +drm_for_each_encoder_mask (encoder, crtc->dev, + crtc->state->encoder_mask) { +dpu_encoder_kickoff (encoder); +dpu_encoder_start_frame_done_timer (encoder); + } + }if (atomic_inc_return (&dpu_crtc->frame_pending) ==1 ) {/* acquire bandwidth and other resources */
@@ -997,13 +1050,6 @@ void dpu_crtc_commit_kickoff(struct drm_crtc *crtc) dpu_crtc->play_count++; -dpu_vbif_clear_errors (dpu_kms); - -drm_for_each_encoder_mask (encoder, crtc->dev, crtc->state->encoder_mask) { -dpu_encoder_kickoff (encoder); -dpu_encoder_start_frame_done_timer (encoder); - } -reinit_completion (&dpu_crtc->frame_done_comp); end:
Signature · 1 line
2.34.1
PATCH v5 14/14 drm/msm/dpu: Set possible clones for all encoders
In reply to Jessica ZhangSet writeback encoders as possible clones for DSI encoders and vice versa.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 32 +++++++++++++++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 2 ++ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 7 +++++-- 3 files changed, 39 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +32 -0
@@ -2557,6 +2557,38 @@ static int dpu_encoder_virt_add_phys_encs(return 0 ; } +/** +* dpu_encoder_get_clones - Calculate the possible_clones for DPU encoder +* @drm_enc: DRM encoder pointer +* Returns: possible_clones mask +*/ +uint32_t dpu_encoder_get_clones (struct drm_encoder *drm_enc) +{ +struct drm_encoder *curr; +int type = drm_enc->encoder_type; +uint32_t clone_mask =drm_encoder_mask (drm_enc); + +/* +* Set writeback as possible clones of real-time DSI encoders and vice +* versa +* +* Writeback encoders can't be clones of each other and DSI +* encoders can't be clones of each other. +* +* TODO: Add DP encoders as valid possible clones for writeback encoders +* (and vice versa) once concurrent writeback has been validated for DP +*/ +drm_for_each_encoder (curr, drm_enc->dev) { +if ((type ==DRM_MODE_ENCODER_VIRTUAL && + curr->encoder_type ==DRM_MODE_ENCODER_DSI ) || + (type ==DRM_MODE_ENCODER_DSI && + curr->encoder_type ==DRM_MODE_ENCODER_VIRTUAL )) + clone_mask |=drm_encoder_mask (curr); + } + +return clone_mask; +} +static int dpu_encoder_setup_display (struct dpu_encoder_virt *dpu_enc,struct dpu_kms *dpu_kms,struct msm_display_info *disp_info)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +2 -0
@@ -60,6 +60,8 @@ enum dpu_intf_mode dpu_encoder_get_intf_mode(struct drm_encoder *encoder);void dpu_encoder_virt_runtime_resume (struct drm_encoder *encoder); +uint32_t dpu_encoder_get_clones (struct drm_encoder *drm_enc); +struct drm_encoder *dpu_encoder_init (struct drm_device *dev,int drm_enc_mode,struct msm_display_info *disp_info);
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +5 -2
@@ -2,7 +2,7 @@/* * Copyright (C) 2013 Red Hat * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. -* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. * * Author: Rob Clark <[email protected]> */
@@ -824,8 +824,11 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)return ret; num_encoders =0 ; -drm_for_each_encoder (encoder, dev) +drm_for_each_encoder (encoder, dev) { num_encoders++; +if (catalog->cwb_count >0 ) + encoder->possible_clones =dpu_encoder_get_clones (encoder); + } max_crtc_count =min (catalog->mixer_count, num_encoders);
Signature · 1 line
2.34.1
Quoted 144 lines · Jessica Zhang
DPU supports a single writeback session running concurrently with primary display when the CWB mux is configured properly. This series enables clone mode for DPU driver and adds support for programming the CWB mux in cases where the hardware has dedicated CWB pingpong blocks. Currently, the CWB hardware blocks have only been added to the SM8650 hardware catalog and only DSI has been exposed as a
possible_cloneof WB.This changes are split into two parts:
The first part of the series will pull in Dmitry's patches to refactor the DPU resource manager to be based off of CRTC instead of encoder. This includes some changes (noted in the relevant commits) by me and Abhinav to fix some issues with getting the global state and refactoring the CDM allocation to work with Dmitry's changes.
The second part of the series will add support for CWB by doing the following:
1) Add the CWB mux to the hardware catalog and clarify the pingpong block index enum to specifiy which pingpong blocks are dedicated to CWB only and which ones are general use pingpong blocks
2) Add support for configuring the CWB mux viadpu_hw_cwbops
3) Add pending flush support for CWB
4) Add support for validating clone mode in the DPU CRTC and setting up CWB within the encoder
5) Adjust the encoder trigger flush, trigger start, and kickoff order to accomodate clone mode
6) Adjust when the frame done timer is started for clone mode
7) Define the possible clones for DPU encoders so that WB encoders can be cloned by non-WB encodersThe feature was tested on SM8650 using IGT's
kms_writebacktest with the following change [1] and dumping the writeback framebuffer when in clone mode. I haven't gotten the chance to test it on DP yet, but I've validated both single and dual LM on DSI.To test CWB with IGT, you'll need to apply this series [1] and run the following command to dump the writeback buffer:
IGT_FRAME_DUMP_PATH=<dump path> FRAME_PNG_FILE_NAME=<file name> \
./build/tests/kms_writeback -d [--run-subtest dump-valid-clones] \You can also do CRC validation by running this command:
./build/tests/kms_writeback [--run-subtest dump-valid-clones]
NOTE: this series depends on Dmitry's modeset fixes [2]
[1] https://patchwork.freedesktop.org/series/137933/
[2] https://patchwork.freedesktop.org/series/142905/---
Changes in v5:
- Rebased onto MSM modeset fixes series (Dmitry)
- Reordered RM refactor patches to prevent breaking CI and to avoid
breaking when partially applied (Dmitry)
- Switch CWB resource reservation to reserve CWB mux first (Dmitry)
- Reworded commit messages to be clearer (Dmitry)
- Change CDM check to fail only if both DP and WB outputs are
requesting the CDM block simultaneously (Dmitry)
- Use helper to grab dsc config indpu_encoder_update_topology
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Rebased onto latest msm-next
- Added kunit tests for framework changes
- Skip valid clone check for encoders that don't have any possible clones set (this is to avoid failing kunit tests, specifically the HDMI state helper tests)
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Dropped support for CWB on DP connectors for now
- Dropped unnecessary PINGPONG array in*_setup_cwb()
- Add a check to make sure CWB and CDM aren't supported simultaneously (Dmitry)
- Documentcwb_enabledchecks indpu_crtc_get_topology()(Dmitry)
- Moved implementation ofdrm_crtc_in_clone_mode()todrm_crtc.c(Jani)
- Dropped duplicate error message for reserving CWB resources (Dmitry)
- Added notes in framework changes about posting a separate series to
add proper KUnit tests (Maxime)
- Added commit message note addressing Sima's comment on handlingmode_changed(Dmitry)
- Formatting fixes (Dmitry)
- Added proper kerneldocs (Dmitry)
- Renameddpu_encoder_helper_get_cwb()->*_get_cwb_mask()(Dmitry)
- Capitalize all instances of "pingpong" in comments (Dmitry)
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Moved CWB hardware programming to its owndpu_hw_cwbabstraction
(Dmitry)
- Reserve and get assigned CWB muxes using RM API and KMS global state (Dmitry)
- Dropped requirement to have only one CWB session at a time
- Moved valid clone mode check to DRM framework (Dmitry and Ville)
- Switch to default CWB tap point to LM as the DSPP
- Dropped printing clone mode status in atomic state (Dmitry)
- Calldpu_vbif_clear_errors()beforedpu_encoder_kickoff()(Dmitry)
- Squashedsetup_input_ctrl()andsetup_input_mode()into a single
dpu_hw_cwbop (Dmitry)
- Moved function comment docs to correct place and fixed wording of comments/commit messages (Dmitry)
- Grabbed old CRTC state using properdrm_atomic_stateAPI indpu_crtc_atomic_check()(Dmitry)
- Split HW catalog changes of adding the CWB mux block and changing the dedicated CWB pingpong indices into 2 separate commits (Dmitry)
- Moved clearing the dpu_crtc_state.num_mixers to "drm/msm/dpu: fill
CRTC resources indpu_crtc.c" (Dmitry)
- Fixed alignment and other formatting issues (Dmitry)
- Link to v1: https://lore.kernel.org/r/[email protected]---
Dmitry Baryshkov (3):
drm/msm/dpu: fill CRTC resources indpu_crtc.c
drm/msm/dpu: move resource allocation to CRTC
drm/msm/dpu: switch RM to usecrtc_idrather thanenc_idfor allocationJessica Zhang (11):
drm/msm/dpu: Add CWB tomsm_display_topologydrm/msm/dpu: Require modeset if clone mode status changes drm/msm/dpu: Failatomic_checkif multiple outputs request CDM block drm/msm/dpu: Reserve resources for CWB
drm/msm/dpu: Configure CWB in writeback encoder drm/msm/dpu: Support CWB indpu_hw_ctl
drm/msm/dpu: Adjust writeback phys encoder setup for CWB drm/msm/dpu: Start frame done timer after encoder kickoff drm/msm/dpu: Skip trigger flush and start for CWB drm/msm/dpu: Reorder encoder kickoff for CWB drm/msm/dpu: Set possible clones for all encodersdrivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 229 +++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 3 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 416 ++++++++++++--------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 7 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 30 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 15 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 27 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 13 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 293 ++++++++++----- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 14 +- 13 files changed, 752 insertions(+), 329 deletions(-)
Quoted 6 lines
---
base-commit:86313a9cd152330c634b25d826a281c6a002eb77
change-id: 20240618-concurrent-wb-97d62387f952
prerequisite-change-id: 20241209-abhinavk-modeset-fix-74864f1de08d:v3
prerequisite-patch-id:a197a0cd4647cb189ea20a96583ea78d0c98b638
prerequisite-patch-id:112c8f1795cbed989beb02b72561854c0ccd59dd
No, it's not a full list. Please use b4 prep --check-deps to check dependencies. See the following errors:
$ b4 shazam -H [email protected] Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz Checking for newer revisions Grabbing search results from lore.kernel.org Analyzing 15 messages in the thread Analyzing 174 code-review messages Checking attestation on all messages, may take a moment... --- ✓ [PATCH v5 1/14] drm/msm/dpu: fill CRTC resources in dpu_crtc.c ✓ [PATCH v5 2/14] drm/msm/dpu: move resource allocation to CRTC ✓ [PATCH v5 3/14] drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation ✓ [PATCH v5 4/14] drm/msm/dpu: Add CWB to msm_display_topology ✓ [PATCH v5 5/14] drm/msm/dpu: Require modeset if clone mode status changes ✓ [PATCH v5 6/14] drm/msm/dpu: Fail atomic_check if multiple outputs request CDM block ✓ [PATCH v5 7/14] drm/msm/dpu: Reserve resources for CWB ✓ [PATCH v5 8/14] drm/msm/dpu: Configure CWB in writeback encoder ✓ [PATCH v5 9/14] drm/msm/dpu: Support CWB in dpu_hw_ctl ✓ [PATCH v5 10/14] drm/msm/dpu: Adjust writeback phys encoder setup for CWB ✓ [PATCH v5 11/14] drm/msm/dpu: Start frame done timer after encoder kickoff ✓ [PATCH v5 12/14] drm/msm/dpu: Skip trigger flush and start for CWB ✓ [PATCH v5 13/14] drm/msm/dpu: Reorder encoder kickoff for CWB ✓ [PATCH v5 14/14] drm/msm/dpu: Set possible clones for all encoders --- ✗ No key: ed25519/[email protected] ✓ Signed: DKIM/quicinc.com --- Total patches: 14 --- Base: using specified base-commit 86313a9cd152330c634b25d826a281c6a002eb77 Deps: looking for dependencies matching 2 patch-ids Deps: Applying prerequisite patch: [PATCH v2 1/2] drm: allow encoder mode_set even when connectors change for crtc Deps: Applying prerequisite patch: [PATCH v3 2/2] drm/tests: Add test for drm_atomic_helper_commit_modeset_disables() Magic: Preparing a sparse worktree Unable to cleanly apply series, see failure log below --- Applying: drm: allow encoder mode_set even when connectors change for crtc Applying: drm/tests: Add test for drm_atomic_helper_commit_modeset_disables() Applying: drm/msm/dpu: fill CRTC resources in dpu_crtc.c Patch failed at 0003 drm/msm/dpu: fill CRTC resources in dpu_crtc.c 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". error: patch failed: drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c:1230 error: drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c: patch does not apply error: patch failed: drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c:719 error: drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c: patch does not apply hint: Use 'git am --show-current-patch=diff' to see the failed patch
Quoted 5 lines
Best regards,
Signature · 1 line
Jessica Zhang <[email protected]>
Signature · 2 lines
With best wishes Dmitry
Quoted 152 lines · Dmitry Baryshkov
Quoted 144 lines · Jessica Zhang
DPU supports a single writeback session running concurrently with primary display when the CWB mux is configured properly. This series enables clone mode for DPU driver and adds support for programming the CWB mux in cases where the hardware has dedicated CWB pingpong blocks. Currently, the CWB hardware blocks have only been added to the SM8650 hardware catalog and only DSI has been exposed as a
possible_cloneof WB.This changes are split into two parts:
The first part of the series will pull in Dmitry's patches to refactor the DPU resource manager to be based off of CRTC instead of encoder. This includes some changes (noted in the relevant commits) by me and Abhinav to fix some issues with getting the global state and refactoring the CDM allocation to work with Dmitry's changes.
The second part of the series will add support for CWB by doing the following:
1) Add the CWB mux to the hardware catalog and clarify the pingpong block index enum to specifiy which pingpong blocks are dedicated to CWB only and which ones are general use pingpong blocks
2) Add support for configuring the CWB mux viadpu_hw_cwbops
3) Add pending flush support for CWB
4) Add support for validating clone mode in the DPU CRTC and setting up CWB within the encoder
5) Adjust the encoder trigger flush, trigger start, and kickoff order to accomodate clone mode
6) Adjust when the frame done timer is started for clone mode
7) Define the possible clones for DPU encoders so that WB encoders can be cloned by non-WB encodersThe feature was tested on SM8650 using IGT's
kms_writebacktest with the following change [1] and dumping the writeback framebuffer when in clone mode. I haven't gotten the chance to test it on DP yet, but I've validated both single and dual LM on DSI.To test CWB with IGT, you'll need to apply this series [1] and run the following command to dump the writeback buffer:
IGT_FRAME_DUMP_PATH=<dump path> FRAME_PNG_FILE_NAME=<file name> \
./build/tests/kms_writeback -d [--run-subtest dump-valid-clones] \You can also do CRC validation by running this command:
./build/tests/kms_writeback [--run-subtest dump-valid-clones]
NOTE: this series depends on Dmitry's modeset fixes [2]
[1] https://patchwork.freedesktop.org/series/137933/
[2] https://patchwork.freedesktop.org/series/142905/---
Changes in v5:
- Rebased onto MSM modeset fixes series (Dmitry)
- Reordered RM refactor patches to prevent breaking CI and to avoid
breaking when partially applied (Dmitry)
- Switch CWB resource reservation to reserve CWB mux first (Dmitry)
- Reworded commit messages to be clearer (Dmitry)
- Change CDM check to fail only if both DP and WB outputs are
requesting the CDM block simultaneously (Dmitry)
- Use helper to grab dsc config indpu_encoder_update_topology
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Rebased onto latest msm-next
- Added kunit tests for framework changes
- Skip valid clone check for encoders that don't have any possible clones set (this is to avoid failing kunit tests, specifically the HDMI state helper tests)
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Dropped support for CWB on DP connectors for now
- Dropped unnecessary PINGPONG array in*_setup_cwb()
- Add a check to make sure CWB and CDM aren't supported simultaneously (Dmitry)
- Documentcwb_enabledchecks indpu_crtc_get_topology()(Dmitry)
- Moved implementation ofdrm_crtc_in_clone_mode()todrm_crtc.c(Jani)
- Dropped duplicate error message for reserving CWB resources (Dmitry)
- Added notes in framework changes about posting a separate series to
add proper KUnit tests (Maxime)
- Added commit message note addressing Sima's comment on handlingmode_changed(Dmitry)
- Formatting fixes (Dmitry)
- Added proper kerneldocs (Dmitry)
- Renameddpu_encoder_helper_get_cwb()->*_get_cwb_mask()(Dmitry)
- Capitalize all instances of "pingpong" in comments (Dmitry)
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Moved CWB hardware programming to its owndpu_hw_cwbabstraction
(Dmitry)
- Reserve and get assigned CWB muxes using RM API and KMS global state (Dmitry)
- Dropped requirement to have only one CWB session at a time
- Moved valid clone mode check to DRM framework (Dmitry and Ville)
- Switch to default CWB tap point to LM as the DSPP
- Dropped printing clone mode status in atomic state (Dmitry)
- Calldpu_vbif_clear_errors()beforedpu_encoder_kickoff()(Dmitry)
- Squashedsetup_input_ctrl()andsetup_input_mode()into a single
dpu_hw_cwbop (Dmitry)
- Moved function comment docs to correct place and fixed wording of comments/commit messages (Dmitry)
- Grabbed old CRTC state using properdrm_atomic_stateAPI indpu_crtc_atomic_check()(Dmitry)
- Split HW catalog changes of adding the CWB mux block and changing the dedicated CWB pingpong indices into 2 separate commits (Dmitry)
- Moved clearing the dpu_crtc_state.num_mixers to "drm/msm/dpu: fill
CRTC resources indpu_crtc.c" (Dmitry)
- Fixed alignment and other formatting issues (Dmitry)
- Link to v1: https://lore.kernel.org/r/[email protected]---
Dmitry Baryshkov (3):
drm/msm/dpu: fill CRTC resources indpu_crtc.cdrm/msm/dpu: move resource allocation to CRTC
drm/msm/dpu: switch RM to usecrtc_idrather thanenc_idfor allocationJessica Zhang (11):
drm/msm/dpu: Add CWB tomsm_display_topologydrm/msm/dpu: Require modeset if clone mode status changes drm/msm/dpu: Failatomic_checkif multiple outputs request CDM block drm/msm/dpu: Reserve resources for CWB
drm/msm/dpu: Configure CWB in writeback encoder drm/msm/dpu: Support CWB indpu_hw_ctl
drm/msm/dpu: Adjust writeback phys encoder setup for CWB drm/msm/dpu: Start frame done timer after encoder kickoff drm/msm/dpu: Skip trigger flush and start for CWB drm/msm/dpu: Reorder encoder kickoff for CWB drm/msm/dpu: Set possible clones for all encodersdrivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 229 +++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 3 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 416 ++++++++++++--------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 7 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 30 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 15 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 27 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 13 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 293 ++++++++++----- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 14 +- 13 files changed, 752 insertions(+), 329 deletions(-)Quoted 6 lines
---
base-commit:86313a9cd152330c634b25d826a281c6a002eb77
change-id: 20240618-concurrent-wb-97d62387f952
prerequisite-change-id: 20241209-abhinavk-modeset-fix-74864f1de08d:v3
prerequisite-patch-id:a197a0cd4647cb189ea20a96583ea78d0c98b638
prerequisite-patch-id:112c8f1795cbed989beb02b72561854c0ccd59dd
Quoted 2 lines
No, it's not a full list. Please use b4 prep --check-deps to check dependencies. See the following errors:
Hi Dmitry,
Ah, I should've put my changes on drm-misc-next instead of trying to pull in the merged drm changes on top of msm-next... The deps list is fixed now.
Thanks for the heads up,
Jessica Zhang
Quoted 59 lines
$ b4 shazam -H [email protected] Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz Checking for newer revisions Grabbing search results from lore.kernel.org Analyzing 15 messages in the thread Analyzing 174 code-review messages Checking attestation on all messages, may take a moment... --- ✓ [PATCH v5 1/14] drm/msm/dpu: fill CRTC resources in dpu_crtc.c ✓ [PATCH v5 2/14] drm/msm/dpu: move resource allocation to CRTC ✓ [PATCH v5 3/14] drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation ✓ [PATCH v5 4/14] drm/msm/dpu: Add CWB to msm_display_topology ✓ [PATCH v5 5/14] drm/msm/dpu: Require modeset if clone mode status changes ✓ [PATCH v5 6/14] drm/msm/dpu: Fail atomic_check if multiple outputs request CDM block ✓ [PATCH v5 7/14] drm/msm/dpu: Reserve resources for CWB ✓ [PATCH v5 8/14] drm/msm/dpu: Configure CWB in writeback encoder ✓ [PATCH v5 9/14] drm/msm/dpu: Support CWB in dpu_hw_ctl ✓ [PATCH v5 10/14] drm/msm/dpu: Adjust writeback phys encoder setup for CWB ✓ [PATCH v5 11/14] drm/msm/dpu: Start frame done timer after encoder kickoff ✓ [PATCH v5 12/14] drm/msm/dpu: Skip trigger flush and start for CWB ✓ [PATCH v5 13/14] drm/msm/dpu: Reorder encoder kickoff for CWB ✓ [PATCH v5 14/14] drm/msm/dpu: Set possible clones for all encoders --- ✗ No key: ed25519/[email protected] ✓ Signed: DKIM/quicinc.com --- Total patches: 14 --- Base: using specified base-commit 86313a9cd152330c634b25d826a281c6a002eb77 Deps: looking for dependencies matching 2 patch-ids Deps: Applying prerequisite patch: [PATCH v2 1/2] drm: allow encoder mode_set even when connectors change for crtc Deps: Applying prerequisite patch: [PATCH v3 2/2] drm/tests: Add test for drm_atomic_helper_commit_modeset_disables() Magic: Preparing a sparse worktree Unable to cleanly apply series, see failure log below --- Applying: drm: allow encoder mode_set even when connectors change for crtc Applying: drm/tests: Add test for drm_atomic_helper_commit_modeset_disables() Applying: drm/msm/dpu: fill CRTC resources in dpu_crtc.c Patch failed at 0003 drm/msm/dpu: fill CRTC resources in dpu_crtc.c 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". error: patch failed: drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c:1230 error: drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c: patch does not apply error: patch failed: drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c:719 error: drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c: patch does not apply hint: Use 'git am --show-current-patch=diff' to see the failed patchQuoted 5 lines
Best regards,
Signature · 1 line
Jessica Zhang <[email protected]>Signature · 2 lines
With best wishes Dmitry
Quoted 155 lines · Jessica Zhang
Quoted 152 lines · Dmitry Baryshkov
Quoted 150 lines · Jessica Zhang
DPU supports a single writeback session running concurrently with primary display when the CWB mux is configured properly. This series enables clone mode for DPU driver and adds support for programming the CWB mux in cases where the hardware has dedicated CWB pingpong blocks. Currently, the CWB hardware blocks have only been added to the SM8650 hardware catalog and only DSI has been exposed as a
possible_cloneof WB.This changes are split into two parts:
The first part of the series will pull in Dmitry's patches to refactor the DPU resource manager to be based off of CRTC instead of encoder. This includes some changes (noted in the relevant commits) by me and Abhinav to fix some issues with getting the global state and refactoring the CDM allocation to work with Dmitry's changes.
The second part of the series will add support for CWB by doing the following:
1) Add the CWB mux to the hardware catalog and clarify the pingpong block index enum to specifiy which pingpong blocks are dedicated to CWB only and which ones are general use pingpong blocks
2) Add support for configuring the CWB mux viadpu_hw_cwbops
3) Add pending flush support for CWB
4) Add support for validating clone mode in the DPU CRTC and setting up CWB within the encoder
5) Adjust the encoder trigger flush, trigger start, and kickoff order to accomodate clone mode
6) Adjust when the frame done timer is started for clone mode
7) Define the possible clones for DPU encoders so that WB encoders can be cloned by non-WB encodersThe feature was tested on SM8650 using IGT's
kms_writebacktest with the following change [1] and dumping the writeback framebuffer when in clone mode. I haven't gotten the chance to test it on DP yet, but I've validated both single and dual LM on DSI.To test CWB with IGT, you'll need to apply this series [1] and run the following command to dump the writeback buffer:
IGT_FRAME_DUMP_PATH=<dump path> FRAME_PNG_FILE_NAME=<file name> \
./build/tests/kms_writeback -d [--run-subtest dump-valid-clones] \You can also do CRC validation by running this command:
./build/tests/kms_writeback [--run-subtest dump-valid-clones]
NOTE: this series depends on Dmitry's modeset fixes [2]
[1] https://patchwork.freedesktop.org/series/137933/
[2] https://patchwork.freedesktop.org/series/142905/---
Changes in v5:
- Rebased onto MSM modeset fixes series (Dmitry)
- Reordered RM refactor patches to prevent breaking CI and to avoid
breaking when partially applied (Dmitry)
- Switch CWB resource reservation to reserve CWB mux first (Dmitry)
- Reworded commit messages to be clearer (Dmitry)
- Change CDM check to fail only if both DP and WB outputs are
requesting the CDM block simultaneously (Dmitry)
- Use helper to grab dsc config indpu_encoder_update_topology
- Link to v4: https://lore.kernel.org/r/[email protected]Changes in v4:
- Rebased onto latest msm-next
- Added kunit tests for framework changes
- Skip valid clone check for encoders that don't have any possible clones set (this is to avoid failing kunit tests, specifically the HDMI state helper tests)
- Link to v3: https://lore.kernel.org/r/[email protected]Changes in v3:
- Dropped support for CWB on DP connectors for now
- Dropped unnecessary PINGPONG array in*_setup_cwb()
- Add a check to make sure CWB and CDM aren't supported simultaneously (Dmitry)
- Documentcwb_enabledchecks indpu_crtc_get_topology()(Dmitry)
- Moved implementation ofdrm_crtc_in_clone_mode()todrm_crtc.c(Jani)
- Dropped duplicate error message for reserving CWB resources (Dmitry)
- Added notes in framework changes about posting a separate series to
add proper KUnit tests (Maxime)
- Added commit message note addressing Sima's comment on handlingmode_changed(Dmitry)
- Formatting fixes (Dmitry)
- Added proper kerneldocs (Dmitry)
- Renameddpu_encoder_helper_get_cwb()->*_get_cwb_mask()(Dmitry)
- Capitalize all instances of "pingpong" in comments (Dmitry)
- Link to v2: https://lore.kernel.org/r/[email protected]Changes in v2:
- Moved CWB hardware programming to its owndpu_hw_cwbabstraction
(Dmitry)
- Reserve and get assigned CWB muxes using RM API and KMS global state (Dmitry)
- Dropped requirement to have only one CWB session at a time
- Moved valid clone mode check to DRM framework (Dmitry and Ville)
- Switch to default CWB tap point to LM as the DSPP
- Dropped printing clone mode status in atomic state (Dmitry)
- Calldpu_vbif_clear_errors()beforedpu_encoder_kickoff()(Dmitry)
- Squashedsetup_input_ctrl()andsetup_input_mode()into a single
dpu_hw_cwbop (Dmitry)
- Moved function comment docs to correct place and fixed wording of comments/commit messages (Dmitry)
- Grabbed old CRTC state using properdrm_atomic_stateAPI indpu_crtc_atomic_check()(Dmitry)
- Split HW catalog changes of adding the CWB mux block and changing the dedicated CWB pingpong indices into 2 separate commits (Dmitry)
- Moved clearing the dpu_crtc_state.num_mixers to "drm/msm/dpu: fill
CRTC resources indpu_crtc.c" (Dmitry)
- Fixed alignment and other formatting issues (Dmitry)
- Link to v1: https://lore.kernel.org/r/[email protected]---
Dmitry Baryshkov (3):
drm/msm/dpu: fill CRTC resources indpu_crtc.cdrm/msm/dpu: move resource allocation to CRTC
drm/msm/dpu: switch RM to usecrtc_idrather thanenc_idfor allocationJessica Zhang (11):
drm/msm/dpu: Add CWB tomsm_display_topologydrm/msm/dpu: Require modeset if clone mode status changes drm/msm/dpu: Failatomic_checkif multiple outputs request CDM block drm/msm/dpu: Reserve resources for CWB
drm/msm/dpu: Configure CWB in writeback encoder drm/msm/dpu: Support CWB indpu_hw_ctl
drm/msm/dpu: Adjust writeback phys encoder setup for CWB drm/msm/dpu: Start frame done timer after encoder kickoff drm/msm/dpu: Skip trigger flush and start for CWB drm/msm/dpu: Reorder encoder kickoff for CWB drm/msm/dpu: Set possible clones for all encodersdrivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 229 +++++++++++- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.h | 3 + drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 416 ++++++++++++--------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 7 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 16 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 30 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 15 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 2 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 27 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 13 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 293 ++++++++++----- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 14 +- 13 files changed, 752 insertions(+), 329 deletions(-)---
base-commit:86313a9cd152330c634b25d826a281c6a002eb77
change-id: 20240618-concurrent-wb-97d62387f952
prerequisite-change-id: 20241209-abhinavk-modeset-fix-74864f1de08d:v3
prerequisite-patch-id:a197a0cd4647cb189ea20a96583ea78d0c98b638
prerequisite-patch-id:112c8f1795cbed989beb02b72561854c0ccd59dd
Quoted 7 lines
Quoted 2 lines
No, it's not a full list. Please use b4 prep --check-deps to check dependencies. See the following errors:
Hi Dmitry,
Ah, I should've put my changes on drm-misc-next instead of trying to pull in the merged drm changes on top of msm-next... The deps list is fixed now.
That's not a problem. I think your deps list was missing one series. I was able to pick up something that made your patches apply cleanly.
Quoted 64 lines
Thanks for the heads up,
Jessica Zhang
Quoted 59 lines
$ b4 shazam -H [email protected] Grabbing thread from lore.kernel.org/all/[email protected]/t.mbox.gz Checking for newer revisions Grabbing search results from lore.kernel.org Analyzing 15 messages in the thread Analyzing 174 code-review messages Checking attestation on all messages, may take a moment... --- ✓ [PATCH v5 1/14] drm/msm/dpu: fill CRTC resources in dpu_crtc.c ✓ [PATCH v5 2/14] drm/msm/dpu: move resource allocation to CRTC ✓ [PATCH v5 3/14] drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation ✓ [PATCH v5 4/14] drm/msm/dpu: Add CWB to msm_display_topology ✓ [PATCH v5 5/14] drm/msm/dpu: Require modeset if clone mode status changes ✓ [PATCH v5 6/14] drm/msm/dpu: Fail atomic_check if multiple outputs request CDM block ✓ [PATCH v5 7/14] drm/msm/dpu: Reserve resources for CWB ✓ [PATCH v5 8/14] drm/msm/dpu: Configure CWB in writeback encoder ✓ [PATCH v5 9/14] drm/msm/dpu: Support CWB in dpu_hw_ctl ✓ [PATCH v5 10/14] drm/msm/dpu: Adjust writeback phys encoder setup for CWB ✓ [PATCH v5 11/14] drm/msm/dpu: Start frame done timer after encoder kickoff ✓ [PATCH v5 12/14] drm/msm/dpu: Skip trigger flush and start for CWB ✓ [PATCH v5 13/14] drm/msm/dpu: Reorder encoder kickoff for CWB ✓ [PATCH v5 14/14] drm/msm/dpu: Set possible clones for all encoders --- ✗ No key: ed25519/[email protected] ✓ Signed: DKIM/quicinc.com --- Total patches: 14 --- Base: using specified base-commit 86313a9cd152330c634b25d826a281c6a002eb77 Deps: looking for dependencies matching 2 patch-ids Deps: Applying prerequisite patch: [PATCH v2 1/2] drm: allow encoder mode_set even when connectors change for crtc Deps: Applying prerequisite patch: [PATCH v3 2/2] drm/tests: Add test for drm_atomic_helper_commit_modeset_disables() Magic: Preparing a sparse worktree Unable to cleanly apply series, see failure log below --- Applying: drm: allow encoder mode_set even when connectors change for crtc Applying: drm/tests: Add test for drm_atomic_helper_commit_modeset_disables() Applying: drm/msm/dpu: fill CRTC resources in dpu_crtc.c Patch failed at 0003 drm/msm/dpu: fill CRTC resources in dpu_crtc.c 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". error: patch failed: drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c:1230 error: drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c: patch does not apply error: patch failed: drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c:719 error: drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c: patch does not apply hint: Use 'git am --show-current-patch=diff' to see the failed patchQuoted 5 lines
Best regards,
Signature · 1 line
Jessica Zhang <[email protected]>Signature · 2 lines
With best wishes Dmitry
Signature · 2 lines
With best wishes Dmitry