drm/msm/dpu: simplity RM code
v2 cover drm/msm/dpu: simplity RM code
Implement several small simplifications for the DPU resource manager. The ideas behind these patches were suggested by Marijn.
Changes since v1:
- Reworded commit message for the patch 1 (Marijn)
- Fixed documentation for dpu_lm_cfg::pingpong (Marijn)
- Added Suggested-by to the last patch (Marijn)
Dmitry Baryshkov (4):
drm/msm/dpu: replace IS_ERR_OR_NULL with IS_ERR during DSC init drm/msm/dpu: remove futile checks from dpu_rm_init() drm/msm/dpu: use PINGPONG_NONE for LMs with no PP attached drm/msm/dpu: move PINGPONG_NONE check to dpu_lm_init()
.../msm/disp/dpu1/catalog/dpu_3_0_msm8998.h | 4 +- .../msm/disp/dpu1/catalog/dpu_4_0_sdm845.h | 4 +- .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c | 5 +++ drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 3 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 41 +------------------ 6 files changed, 13 insertions(+), 46 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/4 drm/msm/dpu: replace IS_ERR_OR_NULL with IS_ERR during DSC init
Using IS_ERR_OR_NULL() together with PTR_ERR() is a typical mistake. If the value is NULL, then the function will return 0 instead of a proper return code. Moreover dpu_hw_dsc_init() can not return NULL. Replace the IS_ERR_OR_NULL() call with IS_ERR().
This follows the commit 740828c73a36 ("drm/msm/dpu: fix error handling in dpu_rm_init"), which removed IS_ERR_OR_NULL() from RM init code, but then the commit f2803ee91a41 ("drm/msm/disp/dpu1: Add DSC support in RM") added it for DSC init.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +1 -1
@@ -247,7 +247,7 @@ int dpu_rm_init(struct dpu_rm *rm,const struct dpu_dsc_cfg *dsc = &cat->dsc[i]; hw =dpu_hw_dsc_init (dsc, mmio); -if (IS_ERR_OR_NULL (hw)) { +if (IS_ERR (hw)) { rc =PTR_ERR (hw);DPU_ERROR ("failed dsc object creation: err %d\n" , rc); goto fail;
Signature · 1 line
2.39.2
PATCH v2 2/4 drm/msm/dpu: remove futile checks from dpu_rm_init()
In reply to Dmitry Baryshkovdpu_rm_init() contains checks for block->id values. These were logical in the vendor driver, when one can not be sure which values were passed from DT. In the upstream driver this is not necessary: the catalog is a part of the driver, we control specified IDs.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 34 -------------------------- 1 file changed, 34 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +0 -34
@@ -122,10 +122,6 @@ int dpu_rm_init(struct dpu_rm *rm,continue ; } -if (lm->id <LM_0 || lm->id >=LM_MAX ) { -DPU_ERROR ("skip mixer %d with invalid id\n" , lm->id); -continue ; - } hw =dpu_hw_lm_init (lm, mmio);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
@@ -139,10 +135,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_merge_3d *hw;const struct dpu_merge_3d_cfg *merge_3d = &cat->merge_3d[i]; -if (merge_3d->id <MERGE_3D_0 || merge_3d->id >=MERGE_3D_MAX ) { -DPU_ERROR ("skip merge_3d %d with invalid id\n" , merge_3d->id); -continue ; - } hw =dpu_hw_merge_3d_init (merge_3d, mmio);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
@@ -157,10 +149,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_pingpong *hw;const struct dpu_pingpong_cfg *pp = &cat->pingpong[i]; -if (pp->id <PINGPONG_0 || pp->id >=PINGPONG_MAX ) { -DPU_ERROR ("skip pingpong %d with invalid id\n" , pp->id); -continue ; - } hw =dpu_hw_pingpong_init (pp, mmio);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
@@ -177,10 +165,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_intf *hw;const struct dpu_intf_cfg *intf = &cat->intf[i]; -if (intf->id <INTF_0 || intf->id >=INTF_MAX ) { -DPU_ERROR ("skip intf %d with invalid id\n" , intf->id); -continue ; - } hw =dpu_hw_intf_init (intf, mmio);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
@@ -194,11 +178,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_wb *hw;const struct dpu_wb_cfg *wb = &cat->wb[i]; -if (wb->id <WB_0 || wb->id >=WB_MAX ) { -DPU_ERROR ("skip intf %d with invalid id\n" , wb->id); -continue ; - } - hw =dpu_hw_wb_init (wb, mmio);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
@@ -212,10 +191,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_ctl *hw;const struct dpu_ctl_cfg *ctl = &cat->ctl[i]; -if (ctl->id <CTL_0 || ctl->id >=CTL_MAX ) { -DPU_ERROR ("skip ctl %d with invalid id\n" , ctl->id); -continue ; - } hw =dpu_hw_ctl_init (ctl, mmio, cat->mixer_count, cat->mixer);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
@@ -229,10 +204,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_dspp *hw;const struct dpu_dspp_cfg *dspp = &cat->dspp[i]; -if (dspp->id <DSPP_0 || dspp->id >=DSPP_MAX ) { -DPU_ERROR ("skip dspp %d with invalid id\n" , dspp->id); -continue ; - } hw =dpu_hw_dspp_init (dspp, mmio);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
@@ -259,11 +230,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_sspp *hw;const struct dpu_sspp_cfg *sspp = &cat->sspp[i]; -if (sspp->id <SSPP_NONE || sspp->id >=SSPP_MAX ) { -DPU_ERROR ("skip intf %d with invalid id\n" , sspp->id); -continue ; - } - hw =dpu_hw_sspp_init (sspp, mmio, cat->ubwc);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
Signature · 1 line
2.39.2
PATCH v2 3/4 drm/msm/dpu: use PINGPONG_NONE for LMs with no PP attached
In reply to Dmitry BaryshkovOn msm8998/sdm845 some LM blocks do not have corresponding PINGPONG block. Currently the driver uses PINGPONG_MAX for such cases. Switch that to use PINGPONG_NONE instead, which is more logical.
--- drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_3_0_msm8998.h | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_4_0_sdm845.h | 4 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h | 3 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_3_0_msm8998.h +2 -2
@@ -104,9 +104,9 @@ static const struct dpu_lm_cfg msm8998_lm[] = {LM_BLK ("lm_2" ,LM_2 ,0x46000 ,MIXER_MSM8998_MASK , &msm8998_lm_sblk,PINGPONG_2 ,LM_5 ,0 ),LM_BLK ("lm_3" ,LM_3 ,0x47000 ,MIXER_MSM8998_MASK , - &msm8998_lm_sblk,PINGPONG_MAX ,0 ,0 ), + &msm8998_lm_sblk,PINGPONG_NONE ,0 ,0 ),LM_BLK ("lm_4" ,LM_4 ,0x48000 ,MIXER_MSM8998_MASK , - &msm8998_lm_sblk,PINGPONG_MAX ,0 ,0 ), + &msm8998_lm_sblk,PINGPONG_NONE ,0 ,0 ),LM_BLK ("lm_5" ,LM_5 ,0x49000 ,MIXER_MSM8998_MASK , &msm8998_lm_sblk, PINGPONG_3, LM_2, 0), };
drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_4_0_sdm845.h +2 -2
@@ -102,9 +102,9 @@ static const struct dpu_lm_cfg sdm845_lm[] = {LM_BLK ("lm_2" ,LM_2 ,0x46000 ,MIXER_SDM845_MASK , &sdm845_lm_sblk,PINGPONG_2 ,LM_5 ,0 ),LM_BLK ("lm_3" ,LM_3 ,0x0 ,MIXER_SDM845_MASK , - &sdm845_lm_sblk,PINGPONG_MAX ,0 ,0 ), + &sdm845_lm_sblk,PINGPONG_NONE ,0 ,0 ),LM_BLK ("lm_4" ,LM_4 ,0x0 ,MIXER_SDM845_MASK , - &sdm845_lm_sblk,PINGPONG_MAX ,0 ,0 ), + &sdm845_lm_sblk,PINGPONG_NONE ,0 ,0 ),LM_BLK ("lm_5" ,LM_5 ,0x49000 ,MIXER_SDM845_MASK , &sdm845_lm_sblk, PINGPONG_3, LM_2, 0), };
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h +1 -1
@@ -529,7 +529,7 @@ struct dpu_sspp_cfg {* @base register offset of this block * @features bit mask identifying sub-blocks/features * @sblk: LM Sub-blocks information -* @pingpong: ID of connected PingPong, PINGPONG_MAX if unsupported +* @pingpong: ID of connected PingPong, PINGPONG_NONE if unsupported * @lm_pair_mask: Bitmask of LMs that can be controlled by same CTL */ struct dpu_lm_cfg {
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h +2 -1
@@ -191,7 +191,8 @@ enum dpu_dsc { };enum dpu_pingpong { -PINGPONG_0 =1 , +PINGPONG_NONE , +PINGPONG_0 ,PINGPONG_1 ,PINGPONG_2 ,PINGPONG_3 ,
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +1 -1
@@ -117,7 +117,7 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_mixer *hw;const struct dpu_lm_cfg *lm = &cat->mixer[i]; -if (lm->pingpong ==PINGPONG_MAX ) { +if (lm->pingpong ==PINGPONG_NONE ) {DPU_DEBUG ("skip mixer %d without pingpong\n" , lm->id);continue ; }
Signature · 1 line
2.39.2
PATCH v2 4/4 drm/msm/dpu: move PINGPONG_NONE check to dpu_lm_init()
In reply to Dmitry BaryshkovMove the check for lm->pingpong being not NONE from dpu_rm_init() to dpu_lm_init(), following the change to dpu_hw_intf_init().
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c | 5 +++++ drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c +5 -0
@@ -161,6 +161,11 @@ struct dpu_hw_mixer *dpu_hw_lm_init(const struct dpu_lm_cfg *cfg, {struct dpu_hw_mixer *c; +if (cfg->pingpong ==PINGPONG_NONE ) { +DPU_DEBUG ("skip mixer %d without pingpong\n" , cfg->id); +return NULL ; + } + c =kzalloc (sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +0 -5
@@ -117,11 +117,6 @@ int dpu_rm_init(struct dpu_rm *rm,struct dpu_hw_mixer *hw;const struct dpu_lm_cfg *lm = &cat->mixer[i]; -if (lm->pingpong ==PINGPONG_NONE ) { -DPU_DEBUG ("skip mixer %d without pingpong\n" , lm->id); -continue ; - } - hw =dpu_hw_lm_init (lm, mmio);if (IS_ERR (hw)) { rc =PTR_ERR (hw);
Signature · 1 line
2.39.2