drm/msm/dpu: simplify RM code
v4 cover drm/msm/dpu: simplify RM code
INTF blocks are not really handled by resource manager, they are assigned at dpu_encoder_setup_display using dpu_encoder_get_intf(). Then this allocation is passed to RM and then returned to then dpu_encoder. So allocate them outside of RM and use them directly.
While we are at it, drop the lm_max_width from the RM and simplify VBIF handling (move creation/destruction to the RM too). Once this and SSPP handling patches are merged, the RM would handle lifetime of all dpu_hw_* objects.
Changes since v3:
- Add missing DSPP blocks teardown
- Remove dpu_hw_blk from dpu_hw_intf
- move dpu_hw_vbif creation/destruction to the RM
Changes since v2:
- Dropped DSPP, PP and MERGE_3D patches for now.
Changes since v1:
- Split into separate patch series to ease review.
The following changes since commit 6ed95285382d6f90a3c3a11d5806a5eb7db715c3:
drm/msm/a5xx: Fix missing CP_PROTECT for SMMU on A540 (2021-12-17 15:09:46 -0800)
are available in the Git repository at:
https://git.linaro.org/people/dmitry.baryshkov/kernel.git dpu-rm-clean-4
for you to fetch changes up to 95f32a88ae0dd366700e2ebf98d793b41c53aeeb:
drm/msm/dpu: move VBIF blocks handling to dpu_rm (2021-12-27 03:41:20 +0300)
----------------------------------------------------------------
Dmitry Baryshkov (5):
drm/msm/dpu: drop unused lm_max_width from RM drm/msm/dpu: add DSPP blocks teardown drm/msm/dpu: get INTF blocks directly rather than through RM drm/msm/dpu: stop embedding dpu_hw_blk into dpu_hw_intf drm/msm/dpu: move VBIF blocks handling to dpu_rm
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 36 +------ drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 16 --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 5 - .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 8 -- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 8 -- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 11 -- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 28 +---- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 2 - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 116 ++++++--------------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 31 ++++-- drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c | 26 ++--- 12 files changed, 70 insertions(+), 218 deletions(-)
PATCH v4 1/5 drm/msm/dpu: drop unused lm_max_width from RM
No code uses lm_max_width from resource manager, so drop it. Instead of calculating the lm_max_width, code can use max_mixer_width field from the hw catalog.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 12 ------------ drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 4 ---- 2 files changed, 16 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +0 -12
@@ -114,18 +114,6 @@ int dpu_rm_init(struct dpu_rm *rm, goto fail; } rm->mixer_blks[lm->id -LM_0 ] = &hw->base; - -if (!rm->lm_max_width) { - rm->lm_max_width = lm->sblk->maxwidth; - }else if (rm->lm_max_width != lm->sblk->maxwidth) { -/* -* Don't expect to have hw where lm max widths differ. -* If found, take the min. -*/ -DPU_ERROR ("unsupported: lm maxwidth differs\n" ); -if (rm->lm_max_width > lm->sblk->maxwidth) - rm->lm_max_width = lm->sblk->maxwidth; - } }for (i =0 ; i < cat->merge_3d_count; i++) {
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +0 -4
@@ -20,8 +20,6 @@ struct dpu_global_state;* @ctl_blks: array of ctl hardware resources * @intf_blks: array of intf hardware resources * @dspp_blks: array of dspp hardware resources -* @lm_max_width: cached layer mixer maximum width -* @rm_lock: resource manager mutex */ struct dpu_rm {struct dpu_hw_blk *pingpong_blks[PINGPONG_MAX -PINGPONG_0 ];
@@ -30,8 +28,6 @@ struct dpu_rm {struct dpu_hw_blk *intf_blks[INTF_MAX -INTF_0 ];struct dpu_hw_blk *dspp_blks[DSPP_MAX -DSPP_0 ];struct dpu_hw_blk *merge_3d_blks[MERGE_3D_MAX -MERGE_3D_0 ]; - -uint32_t lm_max_width; };/**
Signature · 1 line
2.34.1
Re: [PATCH v4 1/5] drm/msm/dpu: drop unused lm_max_width from RM
Quoting Dmitry Baryshkov (2022-01-05 15:10:27)
Quoted 6 lines
No code uses
lm_max_widthfrom resource manager, so drop it. Instead of calculating thelm_max_width, code can usemax_mixer_widthfield from the hw catalog.Signed-off-by Dmitry Baryshkov <[email protected]>---
PATCH v4 2/5 drm/msm/dpu: add DSPP blocks teardown
In reply to Dmitry BaryshkovAdd missing calls to dpu_hw_dspp_destroy() to free resources allocated for DSPP hardware blocks.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +8 -0
@@ -35,6 +35,14 @@ int dpu_rm_destroy(struct dpu_rm *rm) {int i; +for (i =0 ; i <ARRAY_SIZE (rm->dspp_blks); i++) { +struct dpu_hw_dspp *hw; + +if (rm->dspp_blks[i]) { + hw =to_dpu_hw_dspp (rm->dspp_blks[i]); +dpu_hw_dspp_destroy (hw); + } + }for (i =0 ; i <ARRAY_SIZE (rm->pingpong_blks); i++) {struct dpu_hw_pingpong *hw;
Signature · 1 line
2.34.1
Re: [PATCH v4 2/5] drm/msm/dpu: add DSPP blocks teardown
Quoting Dmitry Baryshkov (2022-01-05 15:10:28)
Quoted 6 lines
Add missing calls to
dpu_hw_dspp_destroy()to free resources allocated for DSPP hardware blocks.Fixes e47616df008b ("drm/msm/dpu: add support for color processing blocks in dpu driver")Signed-off-by Dmitry Baryshkov <[email protected]>---
PATCH v4 3/5 drm/msm/dpu: get INTF blocks directly rather than through RM
In reply to Dmitry BaryshkovINTF blocks are not really handled by resource manager, they are assigned at dpu_encoder_setup_display using dpu_encoder_get_intf(). Then this allocation is passed to RM and then returned to then dpu_encoder.
So allocate them outside of RM and use them directly.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 36 +--------- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 16 ----- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 5 -- .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 8 --- .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 8 --- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 68 ++----------------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 8 +++ 8 files changed, 16 insertions(+), 134 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +3 -33
@@ -420,26 +420,6 @@ int dpu_encoder_get_linecount(struct drm_encoder *drm_enc)return linecount; } -void dpu_encoder_get_hw_resources (struct drm_encoder *drm_enc, -struct dpu_encoder_hw_resources *hw_res) -{ -struct dpu_encoder_virt *dpu_enc =NULL ; -int i =0 ; - - dpu_enc =to_dpu_encoder_virt (drm_enc); -DPU_DEBUG_ENC (dpu_enc,"\n" ); - -/* Query resources used by phys encs, expected to be without overlap */ -memset (hw_res,0 ,sizeof (*hw_res)); - -for (i =0 ; i < dpu_enc->num_phys_encs; i++) { -struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; - -if (phys->ops.get_hw_resources) - phys->ops.get_hw_resources (phys, hw_res); - } -} -static void dpu_encoder_destroy (struct drm_encoder *drm_enc) {struct dpu_encoder_virt *dpu_enc =NULL ;
@@ -973,7 +953,7 @@ static void dpu_encoder_virt_mode_set(struct drm_encoder *drm_enc,struct dpu_hw_blk *hw_lm[MAX_CHANNELS_PER_ENC ];struct dpu_hw_blk *hw_dspp[MAX_CHANNELS_PER_ENC ] = {NULL };int num_lm, num_ctl, num_pp; -int i, j; +int i;if (!drm_enc) {DPU_ERROR ("invalid encoder\n" );
@@ -1040,8 +1020,6 @@ static void dpu_encoder_virt_mode_set(struct drm_encoder *drm_enc, cstate->num_mixers = num_lm;for (i =0 ; i < dpu_enc->num_phys_encs; i++) { -int num_blk; -struct dpu_hw_blk *hw_blk[MAX_CHANNELS_PER_ENC ];struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];if (!dpu_enc->hw_pp[i]) {
@@ -1059,16 +1037,8 @@ static void dpu_encoder_virt_mode_set(struct drm_encoder *drm_enc, phys->hw_pp = dpu_enc->hw_pp[i]; phys->hw_ctl =to_dpu_hw_ctl (hw_ctl[i]); - num_blk =dpu_rm_get_assigned_resources (&dpu_kms->rm, - global_state, drm_enc->base.id,DPU_HW_BLK_INTF , - hw_blk,ARRAY_SIZE (hw_blk)); -for (j =0 ; j < num_blk; j++) { -struct dpu_hw_intf *hw_intf; - - hw_intf =to_dpu_hw_intf (hw_blk[i]); -if (hw_intf->idx == phys->intf_idx) - phys->hw_intf = hw_intf; - } +if (phys->intf_idx >=INTF_0 && phys->intf_idx <INTF_MAX ) + phys->hw_intf =dpu_rm_get_intf (&dpu_kms->rm, phys->intf_idx);if (!phys->hw_intf) { DPU_ERROR_ENC(dpu_enc,
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h +0 -16
@@ -18,22 +18,6 @@#define IDLE_TIMEOUT (66 - 16/2) -/** -* Encoder functions and data types -* @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused -*/ -struct dpu_encoder_hw_resources { -enum dpu_intf_mode intfs[INTF_MAX ]; -}; - -/** -* dpu_encoder_get_hw_resources - Populate table of required hardware resources -* @encoder: encoder pointer -* @hw_res: resource table to populate with encoder required resources -*/ -void dpu_encoder_get_hw_resources (struct drm_encoder *encoder, -struct dpu_encoder_hw_resources *hw_res); -/** * dpu_encoder_assign_crtc - Link the encoder to the crtc it's assigned to * @encoder: encoder pointer
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +0 -5
@@ -91,9 +91,6 @@ struct dpu_encoder_virt_ops {* @disable: DRM Call. Disable mode. * @atomic_check: DRM Call. Atomic check new DRM state. * @destroy: DRM Call. Destroy and release resources. -* @get_hw_resources: Populate the structure with the hardware -* resources that this phys_enc is using. -* Expect no overlap between phys_encs. * @control_vblank_irq Register/Deregister for VBLANK IRQ * @wait_for_commit_done: Wait for hardware to have flushed the * current pending frames to hardware
@@ -129,8 +126,6 @@ struct dpu_encoder_phys_ops {struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state);void (*destroy)(struct dpu_encoder_phys *encoder); -void (*get_hw_resources)(struct dpu_encoder_phys *encoder, -struct dpu_encoder_hw_resources *hw_res);int (*control_vblank_irq)(struct dpu_encoder_phys *enc,bool enable);int (*wait_for_commit_done)(struct dpu_encoder_phys *phys_enc);int (*wait_for_tx_complete)(struct dpu_encoder_phys *phys_enc);
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c +0 -8
@@ -534,13 +534,6 @@ static void dpu_encoder_phys_cmd_destroy(struct dpu_encoder_phys *phys_enc)kfree (cmd_enc); } -static void dpu_encoder_phys_cmd_get_hw_resources ( -struct dpu_encoder_phys *phys_enc, -struct dpu_encoder_hw_resources *hw_res) -{ - hw_res->intfs[phys_enc->intf_idx -INTF_0 ] =INTF_MODE_CMD ; -} -static void dpu_encoder_phys_cmd_prepare_for_kickoff (struct dpu_encoder_phys *phys_enc) {
@@ -736,7 +729,6 @@ static void dpu_encoder_phys_cmd_init_ops( ops->enable = dpu_encoder_phys_cmd_enable; ops->disable = dpu_encoder_phys_cmd_disable; ops->destroy = dpu_encoder_phys_cmd_destroy; - ops->get_hw_resources = dpu_encoder_phys_cmd_get_hw_resources; ops->control_vblank_irq = dpu_encoder_phys_cmd_control_vblank_irq; ops->wait_for_commit_done = dpu_encoder_phys_cmd_wait_for_commit_done; ops->prepare_for_kickoff = dpu_encoder_phys_cmd_prepare_for_kickoff;
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +0 -8
@@ -465,13 +465,6 @@ static void dpu_encoder_phys_vid_destroy(struct dpu_encoder_phys *phys_enc)kfree (phys_enc); } -static void dpu_encoder_phys_vid_get_hw_resources ( -struct dpu_encoder_phys *phys_enc, -struct dpu_encoder_hw_resources *hw_res) -{ - hw_res->intfs[phys_enc->intf_idx -INTF_0 ] =INTF_MODE_VIDEO ; -} -static int dpu_encoder_phys_vid_wait_for_vblank (struct dpu_encoder_phys *phys_enc) {
@@ -680,7 +673,6 @@ static void dpu_encoder_phys_vid_init_ops(struct dpu_encoder_phys_ops *ops) ops->enable = dpu_encoder_phys_vid_enable; ops->disable = dpu_encoder_phys_vid_disable; ops->destroy = dpu_encoder_phys_vid_destroy; - ops->get_hw_resources = dpu_encoder_phys_vid_get_hw_resources; ops->control_vblank_irq = dpu_encoder_phys_vid_control_vblank_irq; ops->wait_for_commit_done = dpu_encoder_phys_vid_wait_for_commit_done; ops->wait_for_vblank = dpu_encoder_phys_vid_wait_for_vblank;
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +0 -1
@@ -144,7 +144,6 @@ struct dpu_global_state {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 intf_to_enc_id[INTF_MAX -INTF_0 ];uint32_t dspp_to_enc_id[DSPP_MAX -DSPP_0 ]; };
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +5 -63
107 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +8 -0
@@ -84,5 +84,13 @@ void dpu_rm_release(struct dpu_global_state *global_state,int dpu_rm_get_assigned_resources (struct dpu_rm *rm,struct dpu_global_state *global_state,uint32_t enc_id,enum dpu_hw_blk_type type,struct dpu_hw_blk **blks,int blks_size); + +/** +* dpu_rm_get_intf - Return a struct dpu_hw_intf instance given it's index. +* @rm: DPU Resource Manager handle +* @intf_idx: INTF's index +*/ +struct dpu_hw_intf *dpu_rm_get_intf (struct dpu_rm *rm,enum dpu_intf intf_idx); +#endif /* __DPU_RM_H__ */
Signature · 1 line
2.34.1
Re: [PATCH v4 3/5] drm/msm/dpu: get INTF blocks directly rather than through RM
Quoting Dmitry Baryshkov (2022-01-05 15:10:29)
Quoted 8 lines
INTF blocks are not really handled by resource manager, they are assigned at
dpu_encoder_setup_displayusingdpu_encoder_get_intf(). Then this allocation is passed to RM and then returned to thendpu_encoder.
So allocate them outside of RM and use them directly.Signed-off-by Dmitry Baryshkov <[email protected]>---
PATCH v4 4/5 drm/msm/dpu: stop embedding dpu_hw_blk into dpu_hw_intf
In reply to Dmitry BaryshkovNow as dpu_hw_intf is not hanled by dpu_rm_get_assigned_resources, there is no point in embedding the (empty) struct dpu_hw_blk into dpu_hw_intf (and using typecasts between dpu_hw_blk and dpu_hw_intf). Drop it and use dpu_hw_intf directly.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 11 ----------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 17 ++++------------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 9 ++++++--- 3 files changed, 10 insertions(+), 27 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h +0 -11
@@ -78,7 +78,6 @@ struct dpu_hw_intf_ops { };struct dpu_hw_intf { -struct dpu_hw_blk base;struct dpu_hw_blk_reg_map hw;/* intf */
@@ -90,16 +89,6 @@ struct dpu_hw_intf {struct dpu_hw_intf_ops ops; }; -/** -* to_dpu_hw_intf - convert base object dpu_hw_base to container -* @hw: Pointer to base hardware block -* return: Pointer to hardware block container -*/ -static inline struct dpu_hw_intf *to_dpu_hw_intf (struct dpu_hw_blk *hw) -{ - return container_of(hw, struct dpu_hw_intf, base); -} -/** * dpu_hw_intf_init(): Initializes the intf driver for the passed * interface idx.
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +4 -13
@@ -74,13 +74,9 @@ int dpu_rm_destroy(struct dpu_rm *rm)dpu_hw_ctl_destroy (hw); } } -for (i =0 ; i <ARRAY_SIZE (rm->intf_blks); i++) { -struct dpu_hw_intf *hw; - -if (rm->intf_blks[i]) { - hw =to_dpu_hw_intf (rm->intf_blks[i]); -dpu_hw_intf_destroy (hw); - } +for (i =0 ; i <ARRAY_SIZE (rm->hw_intf); i++) { +if (rm->hw_intf[i]) +dpu_hw_intf_destroy (rm->hw_intf[i]); }return 0 ;
@@ -179,7 +175,7 @@ int dpu_rm_init(struct dpu_rm *rm,DPU_ERROR ("failed intf object creation: err %d\n" , rc); goto fail; } - rm->intf_blks[intf->id -INTF_0 ] = &hw->base; + rm->hw_intf[intf->id -INTF_0 ] = hw; }for (i =0 ; i < cat->ctl_count; i++) {
@@ -593,8 +589,3 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,return num_blks; } - -struct dpu_hw_intf *dpu_rm_get_intf (struct dpu_rm *rm,enum dpu_intf intf_idx) -{ -return to_dpu_hw_intf (rm->intf_blks[intf_idx -INTF_0 ]); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +6 -3
@@ -18,14 +18,14 @@ struct dpu_global_state;* @pingpong_blks: array of pingpong hardware resources * @mixer_blks: array of layer mixer hardware resources * @ctl_blks: array of ctl hardware resources -* @intf_blks: array of intf hardware resources +* @hw_intf: array of intf hardware resources * @dspp_blks: array of dspp hardware resources */ struct dpu_rm {struct dpu_hw_blk *pingpong_blks[PINGPONG_MAX -PINGPONG_0 ];struct dpu_hw_blk *mixer_blks[LM_MAX -LM_0 ];struct dpu_hw_blk *ctl_blks[CTL_MAX -CTL_0 ]; -struct dpu_hw_blk *intf_blks[INTF_MAX -INTF_0 ]; +struct dpu_hw_intf *hw_intf[INTF_MAX -INTF_0 ];struct dpu_hw_blk *dspp_blks[DSPP_MAX -DSPP_0 ];struct dpu_hw_blk *merge_3d_blks[MERGE_3D_MAX -MERGE_3D_0 ]; };
@@ -90,7 +90,10 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm,* @rm: DPU Resource Manager handle * @intf_idx: INTF's index */ -struct dpu_hw_intf *dpu_rm_get_intf (struct dpu_rm *rm,enum dpu_intf intf_idx); +static inline struct dpu_hw_intf *dpu_rm_get_intf (struct dpu_rm *rm,enum dpu_intf intf_idx) +{ +return rm->hw_intf[intf_idx -INTF_0 ]; +}#endif /* __DPU_RM_H__ */
Signature · 1 line
2.34.1
Re: [PATCH v4 4/5] drm/msm/dpu: stop embedding dpu_hw_blk into dpu_hw_intf
Quoting Dmitry Baryshkov (2022-01-05 15:10:30)
Quoted 7 lines
Now as
dpu_hw_intfis not hanled bydpu_rm_get_assigned_resources, there is no point in embedding the (empty) structdpu_hw_blkintodpu_hw_intf(and using typecasts betweendpu_hw_blkanddpu_hw_intf). Drop it and usedpu_hw_intfdirectly.Signed-off-by Dmitry Baryshkov <[email protected]>---
Re: [PATCH v4 4/5] drm/msm/dpu: stop embedding dpu_hw_blk into dpu_hw_intf
In reply to Dmitry BaryshkovQuoting Dmitry Baryshkov (2022-01-05 15:10:30)
Quoted 1 line
Now as
dpu_hw_intfis not hanled bydpu_rm_get_assigned_resources, there
s/hanled/handled/
Quoted 4 lines
is no point in embedding the (empty) struct
dpu_hw_blkintodpu_hw_intf(and using typecasts betweendpu_hw_blkanddpu_hw_intf). Drop it and usedpu_hw_intfdirectly.
PATCH v4 5/5 drm/msm/dpu: move VBIF blocks handling to dpu_rm
In reply to Dmitry BaryshkovMove handling of VBIF blocks into dpu_rm. This serves the purpose of unification of handling of all hardware blocks inside the DPU driver. This removes hand-coded loops in dpu_vbif (which look for necessary VBIF instance by looping through the dpu_kms->hw_vbif and comparing vbif_idx).
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h | 1 + drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 28 +-------------------- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 21 ++++++++++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 12 +++++++++ drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c | 26 ++++++------------- 6 files changed, 42 insertions(+), 47 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h +1 -0
@@ -8,6 +8,7 @@#include "dpu_hw_catalog.h" #include "dpu_hw_mdss.h" #include "dpu_hw_util.h" +#include "dpu_hw_blk.h" struct dpu_hw_vbif ;
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1 -27
@@ -782,8 +782,6 @@ static long dpu_kms_round_pixclk(struct msm_kms *kms, unsigned long rate,static void _dpu_kms_hw_destroy (struct dpu_kms *dpu_kms) { -int i; -if (dpu_kms->hw_intr)dpu_hw_intr_destroy (dpu_kms->hw_intr); dpu_kms->hw_intr =NULL ;
@@ -791,15 +789,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)/* safe to call these more than once during shutdown */ _dpu_kms_mmu_destroy (dpu_kms); -if (dpu_kms->catalog) { -for (i =0 ; i < dpu_kms->catalog->vbif_count; i++) { -u32 vbif_idx = dpu_kms->catalog->vbif[i].id; - -if ((vbif_idx <VBIF_MAX ) && dpu_kms->hw_vbif[vbif_idx]) -dpu_hw_vbif_destroy (dpu_kms->hw_vbif[vbif_idx]); - } - } -if (dpu_kms->rm_init)dpu_rm_destroy (&dpu_kms->rm); dpu_kms->rm_init = false;
@@ -1027,7 +1016,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) {struct dpu_kms *dpu_kms;struct drm_device *dev; -int i, rc = -EINVAL ; +int rc = -EINVAL ;if (!kms) {DPU_ERROR ("invalid kms\n" );
@@ -1116,21 +1105,6 @@ static int dpu_kms_hw_init(struct msm_kms *kms) goto power_error; } -for (i =0 ; i < dpu_kms->catalog->vbif_count; i++) { -u32 vbif_idx = dpu_kms->catalog->vbif[i].id; - - dpu_kms->hw_vbif[i] =dpu_hw_vbif_init (vbif_idx, - dpu_kms->vbif[vbif_idx], dpu_kms->catalog); -if (IS_ERR_OR_NULL (dpu_kms->hw_vbif[vbif_idx])) { - rc =PTR_ERR (dpu_kms->hw_vbif[vbif_idx]); -if (!dpu_kms->hw_vbif[vbif_idx]) - rc = -EINVAL ; -DPU_ERROR ("failed to init vbif %d: %d\n" , vbif_idx, rc); - dpu_kms->hw_vbif[vbif_idx] =NULL ; - goto power_error; - } - } - rc =dpu_core_perf_init (&dpu_kms->perf, dev, dpu_kms->catalog,_dpu_kms_get_clk (dpu_kms,"core" ));if (rc) {
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +0 -1
@@ -105,7 +105,6 @@ struct dpu_kms {struct dpu_rm rm;bool rm_init; -struct dpu_hw_vbif *hw_vbif[VBIF_MAX ];struct dpu_hw_mdp *hw_mdp;bool has_danger_ctrl;
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +21 -0
@@ -78,6 +78,10 @@ int dpu_rm_destroy(struct dpu_rm *rm)if (rm->hw_intf[i])dpu_hw_intf_destroy (rm->hw_intf[i]); } +for (i =0 ; i <ARRAY_SIZE (rm->hw_vbif); i++) { +if (rm->hw_vbif[i]) +dpu_hw_vbif_destroy (rm->hw_vbif[i]); + }return 0 ; }
@@ -212,6 +216,23 @@ int dpu_rm_init(struct dpu_rm *rm, rm->dspp_blks[dspp->id -DSPP_0 ] = &hw->base; } +for (i =0 ; i < cat->vbif_count; i++) { +struct dpu_hw_vbif *hw; +const struct dpu_vbif_cfg *vbif = &cat->vbif[i]; + +if (vbif->id <VBIF_0 || vbif->id >=VBIF_MAX ) { +DPU_ERROR ("skip vbif %d with invalid id\n" , vbif->id); +continue ; + } + hw =dpu_hw_vbif_init (vbif->id, mmio, cat); +if (IS_ERR_OR_NULL (hw)) { + rc =PTR_ERR (hw); +DPU_ERROR ("failed vbif object creation: err %d\n" , rc); + goto fail; + } + rm->hw_vbif[vbif->id -VBIF_0 ] = hw; + } +return 0 ; fail:
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +12 -0
@@ -20,6 +20,7 @@ struct dpu_global_state;* @ctl_blks: array of ctl hardware resources * @hw_intf: array of intf hardware resources * @dspp_blks: array of dspp hardware resources +* @hw_vbif: array of vbif hardware resources */ struct dpu_rm {struct dpu_hw_blk *pingpong_blks[PINGPONG_MAX -PINGPONG_0 ];
@@ -28,6 +29,7 @@ struct dpu_rm {struct dpu_hw_intf *hw_intf[INTF_MAX -INTF_0 ];struct dpu_hw_blk *dspp_blks[DSPP_MAX -DSPP_0 ];struct dpu_hw_blk *merge_3d_blks[MERGE_3D_MAX -MERGE_3D_0 ]; +struct dpu_hw_vbif *hw_vbif[VBIF_MAX -VBIF_0 ]; };/**
@@ -95,5 +97,15 @@ static inline struct dpu_hw_intf *dpu_rm_get_intf(struct dpu_rm *rm, enum dpu_in return rm->hw_intf[intf_idx - INTF_0]; } +/** +* dpu_rm_get_vbif - Return a struct dpu_hw_vbif instance given it's index. +* @rm: DPU Resource Manager handle +* @vbif_idx: VBIF's index +*/ +static inline struct dpu_hw_vbif *dpu_rm_get_vbif (struct dpu_rm *rm,enum dpu_vbif vbif_idx) +{ +return rm->hw_vbif[vbif_idx -VBIF_0 ]; +} +#endif /* __DPU_RM_H__ */
drivers/gpu/drm/msm/disp/dpu1/dpu_vbif.c +7 -19
@@ -152,15 +152,10 @@ void dpu_vbif_set_ot_limit(struct dpu_kms *dpu_kms,struct dpu_hw_mdp *mdp;bool forced_on = false;u32 ot_lim; -int ret, i; +int ret; mdp = dpu_kms->hw_mdp; - -for (i =0 ; i <ARRAY_SIZE (dpu_kms->hw_vbif); i++) { -if (dpu_kms->hw_vbif[i] && - dpu_kms->hw_vbif[i]->idx == params->vbif_idx) - vbif = dpu_kms->hw_vbif[i]; - } + vbif =dpu_rm_get_vbif (&dpu_kms->rm, params->vbif_idx);if (!vbif || !mdp) { DRM_DEBUG_ATOMIC("invalid arguments vbif %d mdp %d\n",
@@ -216,14 +211,7 @@ void dpu_vbif_set_qos_remap(struct dpu_kms *dpu_kms, } mdp = dpu_kms->hw_mdp; -for (i =0 ; i <ARRAY_SIZE (dpu_kms->hw_vbif); i++) { -if (dpu_kms->hw_vbif[i] && - dpu_kms->hw_vbif[i]->idx == params->vbif_idx) { - vbif = dpu_kms->hw_vbif[i]; -break ; - } - } - + vbif =dpu_rm_get_vbif (&dpu_kms->rm, params->vbif_idx);if (!vbif || !vbif->cap) {DPU_ERROR ("invalid vbif %d\n" , params->vbif_idx);return ;
@@ -261,8 +249,8 @@ void dpu_vbif_clear_errors(struct dpu_kms *dpu_kms)struct dpu_hw_vbif *vbif;u32 i, pnd, src; -for (i =0 ; i <ARRAY_SIZE (dpu_kms->hw_vbif); i++) { - vbif = dpu_kms->hw_vbif[i]; +for (i =VBIF_0 ; i <VBIF_MAX ; i++) { + vbif =dpu_rm_get_vbif (&dpu_kms->rm, i);if (vbif && vbif->ops.clear_errors) { vbif->ops.clear_errors (vbif, &pnd, &src);if (pnd || src) {
@@ -278,8 +266,8 @@ void dpu_vbif_init_memtypes(struct dpu_kms *dpu_kms)struct dpu_hw_vbif *vbif;int i, j; -for (i =0 ; i <ARRAY_SIZE (dpu_kms->hw_vbif); i++) { - vbif = dpu_kms->hw_vbif[i]; +for (i =VBIF_0 ; i <VBIF_MAX ; i++) { + vbif =dpu_rm_get_vbif (&dpu_kms->rm, i);if (vbif && vbif->cap && vbif->ops.set_mem_type) {for (j =0 ; j < vbif->cap->memtype_count; j++) vbif->ops.set_mem_type(
Signature · 1 line
2.34.1
Re: [PATCH v4 5/5] drm/msm/dpu: move VBIF blocks handling to dpu_rm
Quoting Dmitry Baryshkov (2022-01-05 15:10:31)
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c int dpu_rm_destroy(struct dpu_rm *rm) · line 83
Quoted 11 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +3
-0@@ -78,6 +78,10 @@ int dpu_rm_destroy(struct dpu_rm *rm)if (rm->hw_intf[i])dpu_hw_intf_destroy (rm->hw_intf[i]); } +for (i =0 ; i <ARRAY_SIZE (rm->hw_vbif); i++) { +if (rm->hw_vbif[i]) +dpu_hw_vbif_destroy (rm->hw_vbif[i]);
Maybe drop this check and pass NULL to dpu_hw_vbif_destroy() sometimes? Then the check can be omitted and the braces dropped
Quoted 11 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +4
-0+ }return 0 ; }@@ -212,6 +216,23 @@ int dpu_rm_init(struct dpu_rm *rm, rm->dspp_blks[dspp->id -DSPP_0 ] = &hw->base; } +for (i =0 ; i < cat->vbif_count; i++) { +struct dpu_hw_vbif *hw; +const struct dpu_vbif_cfg *vbif = &cat->vbif[i];
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c int dpu_rm_init(struct dpu_rm *rm, · line 231
Quoted 10 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +10
-0+ +if (vbif->id <VBIF_0 || vbif->id >=VBIF_MAX ) { +DPU_ERROR ("skip vbif %d with invalid id\n" , vbif->id); +continue ; + } + hw =dpu_hw_vbif_init (vbif->id, mmio, cat); +if (IS_ERR_OR_NULL (hw)) { + rc =PTR_ERR (hw); +DPU_ERROR ("failed vbif object creation: err %d\n" , rc); + goto fail;
If it's NULL then rc will be 0 and fail will return 0. Is that intentional?
Quoted 7 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +4
-0+ } + rm->hw_vbif[vbif->id -VBIF_0 ] = hw; + } +return 0 ; fail:
Re: [PATCH v4 5/5] drm/msm/dpu: move VBIF blocks handling to dpu_rm
Quoted 15 lines · Stephen Boyd
Quoting Dmitry Baryshkov (2022-01-05 15:10:31)
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c int dpu_rm_destroy(struct dpu_rm *rm) · line 83
Quoted 11 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +3
-0@@ -78,6 +78,10 @@ int dpu_rm_destroy(struct dpu_rm *rm)if (rm->hw_intf[i])dpu_hw_intf_destroy (rm->hw_intf[i]); } +for (i =0 ; i <ARRAY_SIZE (rm->hw_vbif); i++) { +if (rm->hw_vbif[i]) +dpu_hw_vbif_destroy (rm->hw_vbif[i]);Maybe drop this check and pass NULL to
dpu_hw_vbif_destroy()sometimes? Then the check can be omitted and the braces dropped
Nice idea. This also applies to dpu_hw_intf_destroy, so I'm going to apply it to the previous patch.
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +1
-0+ }return 0 ; }@@ -212,6 +216,23 @@ int dpu_rm_init(struct dpu_rm *rm, rm->dspp_blks[dspp->id -DSPP_0 ] = &hw->base; }
Quoted 16 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c int dpu_rm_init(struct dpu_rm *rm, · line 231
Quoted 13 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +13
-0+for (i =0 ; i < cat->vbif_count; i++) { +struct dpu_hw_vbif *hw; +const struct dpu_vbif_cfg *vbif = &cat->vbif[i]; + +if (vbif->id <VBIF_0 || vbif->id >=VBIF_MAX ) { +DPU_ERROR ("skip vbif %d with invalid id\n" , vbif->id); +continue ; + } + hw =dpu_hw_vbif_init (vbif->id, mmio, cat); +if (IS_ERR_OR_NULL (hw)) { + rc =PTR_ERR (hw); +DPU_ERROR ("failed vbif object creation: err %d\n" , rc); + goto fail;If it's NULL then rc will be 0 and fail will return 0. Is that intentional?
Actually no. And init functions can not return NULL. So let's fix it too.
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +4
-0+ } + rm->hw_vbif[vbif->id -VBIF_0 ] = hw; + } +return 0 ; fail:
Signature · 2 lines
With best wishes Dmitry