drm/msm/dpu: use managed memory allocations
cover drm/msm/dpu: use managed memory allocations
In a lots of places in DPU driver memory is allocated by using the kzalloc and then manually freed using kfree. However thes memory chunks have a well-defined life cycle. They are either a part of the driver's runtime and can be devm_kzalloc'ed or are exposed to userspace via the DRM objects and thus can be drmm_alloc'ed. Implement corresponding runtime resource manangement for the DPU driver.
Dependencies: [1].
[1] https://patchwork.freedesktop.org/series/118839/
Dmitry Baryshkov (13):
drm/msm/dpu: cleanup dpu_kms_hw_init error path drm/msm/dpu: remove IS_ERR_OR_NULL for dpu_hw_intr_init() error
handling
drm/msm/dpu: use devres-managed allocation for interrupts data drm/msm/dpu: use devres-managed allocation for VBIF data drm/msm/dpu: use devres-managed allocation for MDP TOP drm/msm/dpu: use devres-managed allocation for HW blocks drm/msm/dpu: drop unused dpu_plane::lock
drm/msm/dpu: remove QoS teardown on plane destruction drm/msm/dpu: use drmm-managed allocation for dpu_plane drm/msm/dpu: use drmm-managed allocation for dpu_crtc drm/msm/dpu: use drmm-managed allocation for dpu_encoder_phys drm/msm/dpu: drop dpu_encoder_phys_ops::destroy drm/msm/dpu: use drmm-managed allocation for dpu_encoder_virt
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 21 ++--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 71 +++------------ .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 10 +-- .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 15 +--- .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 13 +-- .../drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 21 +---- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 19 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 16 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 12 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h | 10 ++- .../gpu/drm/msm/disp/dpu1/dpu_hw_dsc_1_2.c | 7 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c | 16 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.h | 12 +-- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 14 ++- .../gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h | 11 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 15 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 12 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c | 14 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.h | 12 +-- .../gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.c | 14 ++- .../gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.h | 13 +-- .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c | 14 ++- .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.h | 13 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c | 15 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h | 7 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c | 17 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h | 8 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.c | 14 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h | 8 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c | 14 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.h | 12 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 51 ++++------- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 - drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 57 ++---------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 90 +++---------------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 11 +-- 36 files changed, 210 insertions(+), 470 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/13 drm/msm/dpu: cleanup dpu_kms_hw_init error path
It was noticed that dpu_kms_hw_init()'s error path contains several labels which point to the same code path. Replace all of them with a single label.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +9 -12
@@ -1037,7 +1037,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)if (!dpu_kms->catalog) {DPU_ERROR ("device config not known!\n" ); rc = -EINVAL ; - goto power_error; + goto err_pm_put; }/*
@@ -1047,13 +1047,13 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =_dpu_kms_mmu_init (dpu_kms);if (rc) {DPU_ERROR ("dpu_kms_mmu_init failed: %d\n" , rc); - goto power_error; + goto err_pm_put; } rc =dpu_rm_init (&dpu_kms->rm, dpu_kms->catalog, dpu_kms->mmio);if (rc) {DPU_ERROR ("rm init failed: %d\n" , rc); - goto power_error; + goto err_pm_put; } dpu_kms->rm_init = true;
@@ -1065,7 +1065,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =PTR_ERR (dpu_kms->hw_mdp);DPU_ERROR ("failed to get hw_mdp: %d\n" , rc); dpu_kms->hw_mdp =NULL ; - goto power_error; + goto err_pm_put; }for (i =0 ; i < dpu_kms->catalog->vbif_count; i++) {
@@ -1076,7 +1076,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)if (IS_ERR (hw)) { rc =PTR_ERR (hw);DPU_ERROR ("failed to init vbif %d: %d\n" , vbif->id, rc); - goto power_error; + goto err_pm_put; } dpu_kms->hw_vbif[vbif->id] = hw;
@@ -1092,7 +1092,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =dpu_core_perf_init (&dpu_kms->perf, dpu_kms->catalog->perf, max_core_clk_rate);if (rc) {DPU_ERROR ("failed to init perf %d\n" , rc); - goto perf_err; + goto err_pm_put; } dpu_kms->hw_intr =dpu_hw_intr_init (dpu_kms->mmio, dpu_kms->catalog);
@@ -1100,7 +1100,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =PTR_ERR (dpu_kms->hw_intr);DPU_ERROR ("hw_intr init failed: %d\n" , rc); dpu_kms->hw_intr =NULL ; - goto hw_intr_init_err; + goto err_pm_put; } dev->mode_config.min_width =0 ;
@@ -1125,7 +1125,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =_dpu_kms_drm_obj_init (dpu_kms);if (rc) {DPU_ERROR ("modeset init failed: %d\n" , rc); - goto drm_obj_init_err; + goto err_pm_put; }dpu_vbif_init_memtypes (dpu_kms);
@@ -1134,10 +1134,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)return 0 ; -drm_obj_init_err: -hw_intr_init_err: -perf_err: -power_error: +err_pm_put:pm_runtime_put_sync (&dpu_kms->pdev->dev); error:_dpu_kms_hw_destroy (dpu_kms);
Signature · 1 line
2.39.2
Re: [PATCH 01/13] drm/msm/dpu: cleanup dpu_kms_hw_init error path
Quoted 5 lines · Dmitry Baryshkov
It was noticed that dpu_kms_hw_init()'s error path contains several labels which point to the same code path. Replace all of them with a single label.
Suggested-by Konrad Dybcio <[email protected]>
it's the first time I'm seeing this code
Konrad
Quoted 91 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +9
-12@@ -1037,7 +1037,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)if (!dpu_kms->catalog) {DPU_ERROR ("device config not known!\n" ); rc = -EINVAL ; - goto power_error; + goto err_pm_put; }/* @@ -1047,13 +1047,13 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =_dpu_kms_mmu_init (dpu_kms);if (rc) {DPU_ERROR ("dpu_kms_mmu_init failed: %d\n" , rc); - goto power_error; + goto err_pm_put; } rc =dpu_rm_init (&dpu_kms->rm, dpu_kms->catalog, dpu_kms->mmio);if (rc) {DPU_ERROR ("rm init failed: %d\n" , rc); - goto power_error; + goto err_pm_put; } dpu_kms->rm_init = true;@@ -1065,7 +1065,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =PTR_ERR (dpu_kms->hw_mdp);DPU_ERROR ("failed to get hw_mdp: %d\n" , rc); dpu_kms->hw_mdp =NULL ; - goto power_error; + goto err_pm_put; }for (i =0 ; i < dpu_kms->catalog->vbif_count; i++) {@@ -1076,7 +1076,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)if (IS_ERR (hw)) { rc =PTR_ERR (hw);DPU_ERROR ("failed to init vbif %d: %d\n" , vbif->id, rc); - goto power_error; + goto err_pm_put; } dpu_kms->hw_vbif[vbif->id] = hw;@@ -1092,7 +1092,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =dpu_core_perf_init (&dpu_kms->perf, dpu_kms->catalog->perf, max_core_clk_rate);if (rc) {DPU_ERROR ("failed to init perf %d\n" , rc); - goto perf_err; + goto err_pm_put; } dpu_kms->hw_intr =dpu_hw_intr_init (dpu_kms->mmio, dpu_kms->catalog);@@ -1100,7 +1100,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =PTR_ERR (dpu_kms->hw_intr);DPU_ERROR ("hw_intr init failed: %d\n" , rc); dpu_kms->hw_intr =NULL ; - goto hw_intr_init_err; + goto err_pm_put; } dev->mode_config.min_width =0 ;@@ -1125,7 +1125,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =_dpu_kms_drm_obj_init (dpu_kms);if (rc) {DPU_ERROR ("modeset init failed: %d\n" , rc); - goto drm_obj_init_err; + goto err_pm_put; }dpu_vbif_init_memtypes (dpu_kms);@@ -1134,10 +1134,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)return 0 ; -drm_obj_init_err: -hw_intr_init_err: -perf_err: -power_error: +err_pm_put:pm_runtime_put_sync (&dpu_kms->pdev->dev); error:_dpu_kms_hw_destroy (dpu_kms);
Re: [PATCH 01/13] drm/msm/dpu: cleanup dpu_kms_hw_init error path
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Dmitry Baryshkov
It was noticed that dpu_kms_hw_init()'s error path contains several labels which point to the same code path. Replace all of them with a single label.
Suggested-by Konrad Dybcio <[email protected]>it's the first time I'm seeing this code
It is Suggested-by, not something else. And you pointed it out in https://lore.kernel.org/linux-arm-msm/[email protected]/
Quoted 92 lines
Konrad
Quoted 91 lines
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +9
-12@@ -1037,7 +1037,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)if (!dpu_kms->catalog) {DPU_ERROR ("device config not known!\n" ); rc = -EINVAL ; - goto power_error; + goto err_pm_put; }/* @@ -1047,13 +1047,13 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =_dpu_kms_mmu_init (dpu_kms);if (rc) {DPU_ERROR ("dpu_kms_mmu_init failed: %d\n" , rc); - goto power_error; + goto err_pm_put; } rc =dpu_rm_init (&dpu_kms->rm, dpu_kms->catalog, dpu_kms->mmio);if (rc) {DPU_ERROR ("rm init failed: %d\n" , rc); - goto power_error; + goto err_pm_put; } dpu_kms->rm_init = true;@@ -1065,7 +1065,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =PTR_ERR (dpu_kms->hw_mdp);DPU_ERROR ("failed to get hw_mdp: %d\n" , rc); dpu_kms->hw_mdp =NULL ; - goto power_error; + goto err_pm_put; }for (i =0 ; i < dpu_kms->catalog->vbif_count; i++) {@@ -1076,7 +1076,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)if (IS_ERR (hw)) { rc =PTR_ERR (hw);DPU_ERROR ("failed to init vbif %d: %d\n" , vbif->id, rc); - goto power_error; + goto err_pm_put; } dpu_kms->hw_vbif[vbif->id] = hw;@@ -1092,7 +1092,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =dpu_core_perf_init (&dpu_kms->perf, dpu_kms->catalog->perf, max_core_clk_rate);if (rc) {DPU_ERROR ("failed to init perf %d\n" , rc); - goto perf_err; + goto err_pm_put; } dpu_kms->hw_intr =dpu_hw_intr_init (dpu_kms->mmio, dpu_kms->catalog);@@ -1100,7 +1100,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =PTR_ERR (dpu_kms->hw_intr);DPU_ERROR ("hw_intr init failed: %d\n" , rc); dpu_kms->hw_intr =NULL ; - goto hw_intr_init_err; + goto err_pm_put; } dev->mode_config.min_width =0 ;@@ -1125,7 +1125,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc =_dpu_kms_drm_obj_init (dpu_kms);if (rc) {DPU_ERROR ("modeset init failed: %d\n" , rc); - goto drm_obj_init_err; + goto err_pm_put; }dpu_vbif_init_memtypes (dpu_kms);@@ -1134,10 +1134,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)return 0 ; -drm_obj_init_err: -hw_intr_init_err: -perf_err: -power_error: +err_pm_put:pm_runtime_put_sync (&dpu_kms->pdev->dev); error:_dpu_kms_hw_destroy (dpu_kms);
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 01/13] drm/msm/dpu: cleanup dpu_kms_hw_init error path
Quoted 11 lines · Dmitry Baryshkov
Quoted 8 lines · Konrad Dybcio
Quoted 5 lines · Dmitry Baryshkov
It was noticed that dpu_kms_hw_init()'s error path contains several labels which point to the same code path. Replace all of them with a single label.
Suggested-by Konrad Dybcio <[email protected]>it's the first time I'm seeing this code
It is Suggested-by, not something else. And you pointed it out in https://lore.kernel.org/linux-arm-msm/[email protected]/
Oh, thanks
Konrad
Quoted 84 lines
Quoted 83 lines
Konrad
Quoted 81 lines
Signed-off-by Dmitry Baryshkov <[email protected]>---
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c| 21 +++++++++------------1 file changed, 9 insertions(+), 12 deletions(-)drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +8
-8@@ -1037,7 +1037,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) if (!dpu_kms->catalog) { DPU_ERROR("device config not known!\n"); rc = -EINVAL; - goto power_error; + goto err_pm_put; } /*@@ -1047,13 +1047,13 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc = _dpu_kms_mmu_init(dpu_kms); if (rc) { DPU_ERROR("dpu_kms_mmu_init failed: %d\n", rc); - goto power_error; + goto err_pm_put; } rc = dpu_rm_init(&dpu_kms->rm, dpu_kms->catalog, dpu_kms->mmio); if (rc) { DPU_ERROR("rm init failed: %d\n", rc); - goto power_error; + goto err_pm_put; } dpu_kms->rm_init = true;@@ -1065,7 +1065,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc = PTR_ERR(dpu_kms->hw_mdp); DPU_ERROR("failed to get hw_mdp: %d\n", rc); dpu_kms->hw_mdp = NULL; - goto power_error; + goto err_pm_put; } for (i = 0; i < dpu_kms->catalog->vbif_count; i++) {@@ -1076,7 +1076,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) if (IS_ERR(hw)) { rc = PTR_ERR(hw); DPU_ERROR("failed to init vbif %d: %d\n", vbif->id, rc); - goto power_error; + goto err_pm_put; } dpu_kms->hw_vbif[vbif->id] = hw;@@ -1092,7 +1092,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc = dpu_core_perf_init(&dpu_kms->perf, dpu_kms->catalog->perf, max_core_clk_rate); if (rc) { DPU_ERROR("failed to init perf %d\n", rc); - goto perf_err; + goto err_pm_put; } dpu_kms->hw_intr = dpu_hw_intr_init(dpu_kms->mmio, dpu_kms->catalog);@@ -1100,7 +1100,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc = PTR_ERR(dpu_kms->hw_intr); DPU_ERROR("hw_intr init failed: %d\n", rc); dpu_kms->hw_intr = NULL; - goto hw_intr_init_err; + goto err_pm_put; } dev->mode_config.min_width = 0;@@ -1125,7 +1125,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) rc = _dpu_kms_drm_obj_init(dpu_kms); if (rc) { DPU_ERROR("modeset init failed: %d\n", rc); - goto drm_obj_init_err; + goto err_pm_put; } dpu_vbif_init_memtypes(dpu_kms);@@ -1134,10 +1134,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) return 0;-drm_obj_init_err:
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1
-3-hw_intr_init_err: -perf_err: -power_error: +err_pm_put:
pm_runtime_put_sync(&dpu_kms->pdev->dev);
error:
_dpu_kms_hw_destroy(dpu_kms);
PATCH 2/13 drm/msm/dpu: remove IS_ERR_OR_NULL for dpu_hw_intr_init() error handling
In reply to Dmitry BaryshkovUsing 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. Replace IS_ERR_OR_NULL() with IS_ERR() in the dpu_hw_intr_init() error check.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1 -1
@@ -1096,7 +1096,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) } dpu_kms->hw_intr =dpu_hw_intr_init (dpu_kms->mmio, dpu_kms->catalog); -if (IS_ERR_OR_NULL (dpu_kms->hw_intr)) { +if (IS_ERR (dpu_kms->hw_intr)) { rc =PTR_ERR (dpu_kms->hw_intr);DPU_ERROR ("hw_intr init failed: %d\n" , rc); dpu_kms->hw_intr =NULL ;
Signature · 1 line
2.39.2
PATCH 3/13 drm/msm/dpu: use devres-managed allocation for interrupts data
In reply to Dmitry BaryshkovUse devm_kzalloc to create interrupts data structure. This allows us to remove corresponding kfree and drop dpu_hw_intr_destroy() function.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c | 14 ++++++-------- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h | 11 ++++------- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 4 +--- 3 files changed, 11 insertions(+), 18 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c +6 -8
@@ -6,6 +6,8 @@#include <linux/debugfs.h> #include <linux/slab.h> +#include <drm/drm_managed.h> +#include "dpu_core_irq.h" #include "dpu_kms.h" #include "dpu_hw_interrupts.h"
@@ -441,8 +443,9 @@ static void __intr_offset(const struct dpu_mdss_cfg *m, hw->blk_addr = addr + m->mdp[0 ].base; } -struct dpu_hw_intr *dpu_hw_intr_init (void __iomem *addr, -const struct dpu_mdss_cfg *m) +struct dpu_hw_intr *dpu_hw_intr_init (struct drm_device *dev, +void __iomem *addr, +const struct dpu_mdss_cfg *m) {struct dpu_hw_intr *intr;int nirq =MDP_INTR_MAX *32 ;
@@ -450,7 +453,7 @@ struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr,if (!addr || !m)return ERR_PTR (-EINVAL ); - intr =kzalloc (struct_size (intr, irq_tbl, nirq),GFP_KERNEL ); + intr =drmm_kzalloc (dev,struct_size (intr, irq_tbl, nirq),GFP_KERNEL );if (!intr)return ERR_PTR (-ENOMEM );
@@ -465,11 +468,6 @@ struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr,return intr; } -void dpu_hw_intr_destroy (struct dpu_hw_intr *intr) -{ -kfree (intr); -} -int dpu_core_irq_register_callback (struct dpu_kms *dpu_kms,int irq_idx,void (*irq_cb)(void *arg,int irq_idx),void *irq_arg)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h +4 -7
@@ -70,15 +70,12 @@ struct dpu_hw_intr {/** * dpu_hw_intr_init(): Initializes the interrupts hw object +* @dev: Corresponding device for devres management * @addr: mapped register io address of MDP * @m: pointer to MDSS catalog data */ -struct dpu_hw_intr *dpu_hw_intr_init (void __iomem *addr, -const struct dpu_mdss_cfg *m); +struct dpu_hw_intr *dpu_hw_intr_init (struct drm_device *dev, +void __iomem *addr, +const struct dpu_mdss_cfg *m); -/** -* dpu_hw_intr_destroy(): Cleanup interrutps hw object -* @intr: pointer to interrupts hw object -*/ -void dpu_hw_intr_destroy (struct dpu_hw_intr *intr);#endif
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1 -3
@@ -807,8 +807,6 @@ 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 ;/* safe to call these more than once during shutdown */
@@ -1095,7 +1093,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) goto err_pm_put; } - dpu_kms->hw_intr =dpu_hw_intr_init (dpu_kms->mmio, dpu_kms->catalog); + dpu_kms->hw_intr =dpu_hw_intr_init (dev, dpu_kms->mmio, dpu_kms->catalog);if (IS_ERR (dpu_kms->hw_intr)) { rc =PTR_ERR (dpu_kms->hw_intr);DPU_ERROR ("hw_intr init failed: %d\n" , rc);
Signature · 1 line
2.39.2
PATCH 4/13 drm/msm/dpu: use devres-managed allocation for VBIF data
In reply to Dmitry BaryshkovUse devm_kzalloc to create VBIF data structure. This allows us to remove corresponding kfree and drop dpu_hw_intr_destroy() function.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.c | 14 ++++++-------- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h | 8 ++++---- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 11 +++-------- 3 files changed, 13 insertions(+), 20 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.c +6 -8
@@ -2,6 +2,8 @@/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ +#include <drm/drm_managed.h> +#include "dpu_hwio.h" #include "dpu_hw_catalog.h" #include "dpu_hw_vbif.h"
@@ -211,12 +213,13 @@ static void _setup_vbif_ops(struct dpu_hw_vbif_ops *ops, ops->set_write_gather_en = dpu_hw_set_write_gather_en; } -struct dpu_hw_vbif *dpu_hw_vbif_init (const struct dpu_vbif_cfg *cfg, -void __iomem *addr) +struct dpu_hw_vbif *dpu_hw_vbif_init (struct drm_device *dev, +const struct dpu_vbif_cfg *cfg, +void __iomem *addr) {struct dpu_hw_vbif *c; - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -234,8 +237,3 @@ struct dpu_hw_vbif *dpu_hw_vbif_init(const struct dpu_vbif_cfg *cfg,return c; } - -void dpu_hw_vbif_destroy (struct dpu_hw_vbif *vbif) -{ -kfree (vbif); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h +4 -4
@@ -108,12 +108,12 @@ struct dpu_hw_vbif {/** * dpu_hw_vbif_init() - Initializes the VBIF driver for the passed * VBIF catalog entry. +* @dev: Corresponding device for devres management * @cfg: VBIF catalog entry for which driver object is required * @addr: Mapped register io address of MDSS */ -struct dpu_hw_vbif *dpu_hw_vbif_init (const struct dpu_vbif_cfg *cfg, -void __iomem *addr); - -void dpu_hw_vbif_destroy (struct dpu_hw_vbif *vbif); +struct dpu_hw_vbif *dpu_hw_vbif_init (struct drm_device *dev, +const struct dpu_vbif_cfg *cfg, +void __iomem *addr);#endif /*_DPU_HW_VBIF_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +3 -8
@@ -812,13 +812,8 @@ 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 <ARRAY_SIZE (dpu_kms->hw_vbif); i++) { -if (dpu_kms->hw_vbif[i]) { -dpu_hw_vbif_destroy (dpu_kms->hw_vbif[i]); - dpu_kms->hw_vbif[i] =NULL ; - } - } +for (i =0 ; i <ARRAY_SIZE (dpu_kms->hw_vbif); i++) { + dpu_kms->hw_vbif[i] =NULL ; }if (dpu_kms->rm_init)
@@ -1070,7 +1065,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)struct dpu_hw_vbif *hw;const struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i]; - hw =dpu_hw_vbif_init (vbif, dpu_kms->vbif[vbif->id]); + hw =dpu_hw_vbif_init (dev, vbif, dpu_kms->vbif[vbif->id]);if (IS_ERR (hw)) { rc =PTR_ERR (hw);DPU_ERROR ("failed to init vbif %d: %d\n" , vbif->id, rc);
Signature · 1 line
2.39.2
PATCH 5/13 drm/msm/dpu: use devres-managed allocation for MDP TOP
In reply to Dmitry BaryshkovUse devm_kzalloc to create MDP TOP structure. This allows us to remove corresponding kfree and drop dpu_hw_mdp_destroy() function.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c | 17 +++++++---------- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h | 8 +++++--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 5 ++--- 3 files changed, 14 insertions(+), 16 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.c +7 -10
@@ -2,6 +2,8 @@/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ +#include <drm/drm_managed.h> +#include "dpu_hwio.h" #include "dpu_hw_catalog.h" #include "dpu_hw_top.h"
@@ -268,16 +270,17 @@ static void _setup_mdp_ops(struct dpu_hw_mdp_ops *ops, ops->intf_audio_select = dpu_hw_intf_audio_select; } -struct dpu_hw_mdp *dpu_hw_mdptop_init (const struct dpu_mdp_cfg *cfg, -void __iomem *addr, -const struct dpu_mdss_cfg *m) +struct dpu_hw_mdp *dpu_hw_mdptop_init (struct drm_device *dev, +const struct dpu_mdp_cfg *cfg, +void __iomem *addr, +const struct dpu_mdss_cfg *m) {struct dpu_hw_mdp *mdp;if (!addr)return ERR_PTR (-EINVAL ); - mdp =kzalloc (sizeof (*mdp),GFP_KERNEL ); + mdp =drmm_kzalloc (dev,sizeof (*mdp),GFP_KERNEL );if (!mdp)return ERR_PTR (-ENOMEM );
@@ -292,9 +295,3 @@ struct dpu_hw_mdp *dpu_hw_mdptop_init(const struct dpu_mdp_cfg *cfg,return mdp; } - -void dpu_hw_mdp_destroy (struct dpu_hw_mdp *mdp) -{ -kfree (mdp); -} -
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_top.h +5 -3
@@ -145,13 +145,15 @@ struct dpu_hw_mdp {/** * dpu_hw_mdptop_init - initializes the top driver for the passed config +* @dev: Corresponding device for devres management * @cfg: MDP TOP configuration from catalog * @addr: Mapped register io address of MDP * @m: Pointer to mdss catalog data */ -struct dpu_hw_mdp *dpu_hw_mdptop_init (const struct dpu_mdp_cfg *cfg, -void __iomem *addr, -const struct dpu_mdss_cfg *m); +struct dpu_hw_mdp *dpu_hw_mdptop_init (struct drm_device *dev, +const struct dpu_mdp_cfg *cfg, +void __iomem *addr, +const struct dpu_mdss_cfg *m);void dpu_hw_mdp_destroy (struct dpu_hw_mdp *mdp);
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +2 -3
@@ -822,8 +822,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms) dpu_kms->catalog =NULL ; -if (dpu_kms->hw_mdp) -dpu_hw_mdp_destroy (dpu_kms->hw_mdp); dpu_kms->hw_mdp =NULL ; }
@@ -1051,7 +1049,8 @@ static int dpu_kms_hw_init(struct msm_kms *kms) dpu_kms->rm_init = true; - dpu_kms->hw_mdp =dpu_hw_mdptop_init (dpu_kms->catalog->mdp, + dpu_kms->hw_mdp =dpu_hw_mdptop_init (dev, + dpu_kms->catalog->mdp, dpu_kms->mmio, dpu_kms->catalog);if (IS_ERR (dpu_kms->hw_mdp)) {
Signature · 1 line
2.39.2
PATCH 6/13 drm/msm/dpu: use devres-managed allocation for HW blocks
In reply to Dmitry BaryshkovUse devm_kzalloc to create HW block structure. This allows us to remove corresponding kfree and drop all dpu_hw_*_destroy() functions as well as dpu_rm_destroy(), which becomes empty afterwards.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 19 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 16 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 12 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h | 10 ++- .../gpu/drm/msm/disp/dpu1/dpu_hw_dsc_1_2.c | 7 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c | 16 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.h | 12 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 15 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h | 12 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c | 14 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.h | 12 +-- .../gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.c | 14 ++- .../gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.h | 13 +-- .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c | 14 ++- .../gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.h | 13 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c | 15 ++-- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h | 7 +- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c | 14 ++- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.h | 12 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 8 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 1 - drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 90 +++---------------- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 11 +-- 23 files changed, 119 insertions(+), 238 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c +9 -10
@@ -4,6 +4,9 @@*/ #include <linux/delay.h> + +#include <drm/drm_managed.h> +#include "dpu_hwio.h" #include "dpu_hw_ctl.h" #include "dpu_kms.h"
@@ -674,14 +677,15 @@ static void _setup_ctl_ops(struct dpu_hw_ctl_ops *ops, ops->set_active_pipes = dpu_hw_ctl_set_fetch_pipe_active; }; -struct dpu_hw_ctl *dpu_hw_ctl_init (const struct dpu_ctl_cfg *cfg, -void __iomem *addr, -u32 mixer_count, -const struct dpu_lm_cfg *mixer) +struct dpu_hw_ctl *dpu_hw_ctl_init (struct drm_device *dev, +const struct dpu_ctl_cfg *cfg, +void __iomem *addr, +u32 mixer_count, +const struct dpu_lm_cfg *mixer) {struct dpu_hw_ctl *c; - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -696,8 +700,3 @@ struct dpu_hw_ctl *dpu_hw_ctl_init(const struct dpu_ctl_cfg *cfg,return c; } - -void dpu_hw_ctl_destroy (struct dpu_hw_ctl *ctx) -{ -kfree (ctx); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h +6 -10
@@ -274,20 +274,16 @@ static inline struct dpu_hw_ctl *to_dpu_hw_ctl(struct dpu_hw_blk *hw)/** * dpu_hw_ctl_init() - Initializes the ctl_path hw driver object. * Should be called before accessing any ctl_path register. +* @dev: Corresponding device for devres management * @cfg: ctl_path catalog entry for which driver object is required * @addr: mapped register io address of MDP * @mixer_count: Number of mixers in @mixer * @mixer: Pointer to an array of Layer Mixers defined in the catalog */ -struct dpu_hw_ctl *dpu_hw_ctl_init (const struct dpu_ctl_cfg *cfg, -void __iomem *addr, -u32 mixer_count, -const struct dpu_lm_cfg *mixer); - -/** -* dpu_hw_ctl_destroy(): Destroys ctl driver context -* should be called to free the context -*/ -void dpu_hw_ctl_destroy (struct dpu_hw_ctl *ctx); +struct dpu_hw_ctl *dpu_hw_ctl_init (struct drm_device *dev, +const struct dpu_ctl_cfg *cfg, +void __iomem *addr, +u32 mixer_count, +const struct dpu_lm_cfg *mixer);#endif /*_DPU_HW_CTL_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c +5 -7
@@ -3,6 +3,8 @@* Copyright (c) 2020-2022, Linaro Limited */ +#include <drm/drm_managed.h> +#include <drm/display/drm_dsc_helper.h> #include "dpu_kms.h"
@@ -188,12 +190,13 @@ static void _setup_dsc_ops(struct dpu_hw_dsc_ops *ops, ops->dsc_bind_pingpong_blk = dpu_hw_dsc_bind_pingpong_blk; }; -struct dpu_hw_dsc *dpu_hw_dsc_init (const struct dpu_dsc_cfg *cfg, +struct dpu_hw_dsc *dpu_hw_dsc_init (struct drm_device *dev, +const struct dpu_dsc_cfg *cfg,void __iomem *addr) {struct dpu_hw_dsc *c; - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -206,8 +209,3 @@ struct dpu_hw_dsc *dpu_hw_dsc_init(const struct dpu_dsc_cfg *cfg,return c; } - -void dpu_hw_dsc_destroy (struct dpu_hw_dsc *dsc) -{ -kfree (dsc); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.h +7 -3
@@ -64,20 +64,24 @@ struct dpu_hw_dsc {/** * dpu_hw_dsc_init() - Initializes the DSC hw driver object. +* @dev: Corresponding device for devres management * @cfg: DSC catalog entry for which driver object is required * @addr: Mapped register io address of MDP * Return: Error code or allocated dpu_hw_dsc context */ -struct dpu_hw_dsc *dpu_hw_dsc_init (const struct dpu_dsc_cfg *cfg, -void __iomem *addr); +struct dpu_hw_dsc *dpu_hw_dsc_init (struct drm_device *dev, +const struct dpu_dsc_cfg *cfg, +void __iomem *addr);/** * dpu_hw_dsc_init_1_2() - initializes the v1.2 DSC hw driver object +* @dev: Corresponding device for devres management * @cfg: DSC catalog entry for which driver object is required * @addr: Mapped register io address of MDP * Returns: Error code or allocated dpu_hw_dsc context */ -struct dpu_hw_dsc *dpu_hw_dsc_init_1_2 (const struct dpu_dsc_cfg *cfg, +struct dpu_hw_dsc *dpu_hw_dsc_init_1_2 (struct drm_device *dev, +const struct dpu_dsc_cfg *cfg,void __iomem *addr);/**
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc_1_2.c +5 -2
@@ -4,6 +4,8 @@* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved */ +#include <drm/drm_managed.h> +#include <drm/display/drm_dsc_helper.h> #include "dpu_kms.h"
@@ -367,12 +369,13 @@ static void _setup_dcs_ops_1_2(struct dpu_hw_dsc_ops *ops, ops->dsc_bind_pingpong_blk = dpu_hw_dsc_bind_pingpong_blk_1_2; } -struct dpu_hw_dsc *dpu_hw_dsc_init_1_2 (const struct dpu_dsc_cfg *cfg, +struct dpu_hw_dsc *dpu_hw_dsc_init_1_2 (struct drm_device *dev, +const struct dpu_dsc_cfg *cfg,void __iomem *addr) {struct dpu_hw_dsc *c; - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.c +6 -10
@@ -2,6 +2,8 @@/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. */ +#include <drm/drm_managed.h> +#include "dpu_hwio.h" #include "dpu_hw_catalog.h" #include "dpu_hw_lm.h"
@@ -68,15 +70,16 @@ static void _setup_dspp_ops(struct dpu_hw_dspp *c, c->ops.setup_pcc = dpu_setup_dspp_pcc; } -struct dpu_hw_dspp *dpu_hw_dspp_init (const struct dpu_dspp_cfg *cfg, -void __iomem *addr) +struct dpu_hw_dspp *dpu_hw_dspp_init (struct drm_device *dev, +const struct dpu_dspp_cfg *cfg, +void __iomem *addr) {struct dpu_hw_dspp *c;if (!addr)return ERR_PTR (-EINVAL ); - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -90,10 +93,3 @@ struct dpu_hw_dspp *dpu_hw_dspp_init(const struct dpu_dspp_cfg *cfg,return c; } - -void dpu_hw_dspp_destroy (struct dpu_hw_dspp *dspp) -{ -kfree (dspp); -} - -
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dspp.h +4 -8
@@ -81,18 +81,14 @@ static inline struct dpu_hw_dspp *to_dpu_hw_dspp(struct dpu_hw_blk *hw)/** * dpu_hw_dspp_init() - Initializes the DSPP hw driver object. * should be called once before accessing every DSPP. +* @dev: Corresponding device for devres management * @cfg: DSPP catalog entry for which driver object is required * @addr: Mapped register io address of MDP * Return: pointer to structure or ERR_PTR */ -struct dpu_hw_dspp *dpu_hw_dspp_init (const struct dpu_dspp_cfg *cfg, -void __iomem *addr); - -/** -* dpu_hw_dspp_destroy(): Destroys DSPP driver context -* @dspp: Pointer to DSPP driver context -*/ -void dpu_hw_dspp_destroy (struct dpu_hw_dspp *dspp); +struct dpu_hw_dspp *dpu_hw_dspp_init (struct drm_device *dev, +const struct dpu_dspp_cfg *cfg, +void __iomem *addr);#endif /*_DPU_HW_DSPP_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c +6 -9
@@ -12,6 +12,8 @@#include <linux/iopoll.h> +#include <drm/drm_managed.h> +#define INTF_TIMING_ENGINE_EN 0x000#define INTF_CONFIG 0x004#define INTF_HSYNC_CTL 0x008
@@ -547,8 +549,9 @@ static void _setup_intf_ops(struct dpu_hw_intf_ops *ops, ops->enable_compression = dpu_hw_intf_enable_compression; } -struct dpu_hw_intf *dpu_hw_intf_init (const struct dpu_intf_cfg *cfg, -void __iomem *addr) +struct dpu_hw_intf *dpu_hw_intf_init (struct drm_device *dev, +const struct dpu_intf_cfg *cfg, +void __iomem *addr) {struct dpu_hw_intf *c;
@@ -557,7 +560,7 @@ struct dpu_hw_intf *dpu_hw_intf_init(const struct dpu_intf_cfg *cfg,return NULL ; } - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -573,9 +576,3 @@ struct dpu_hw_intf *dpu_hw_intf_init(const struct dpu_intf_cfg *cfg,return c; } - -void dpu_hw_intf_destroy (struct dpu_hw_intf *intf) -{ -kfree (intf); -} -
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.h +4 -8
@@ -125,16 +125,12 @@ struct dpu_hw_intf {/** * dpu_hw_intf_init() - Initializes the INTF driver for the passed * interface catalog entry. +* @dev: Corresponding device for devres management * @cfg: interface catalog entry for which driver object is required * @addr: mapped register io address of MDP */ -struct dpu_hw_intf *dpu_hw_intf_init (const struct dpu_intf_cfg *cfg, -void __iomem *addr); - -/** -* dpu_hw_intf_destroy(): Destroys INTF driver context -* @intf: Pointer to INTF driver context -*/ -void dpu_hw_intf_destroy (struct dpu_hw_intf *intf); +struct dpu_hw_intf *dpu_hw_intf_init (struct drm_device *dev, +const struct dpu_intf_cfg *cfg, +void __iomem *addr);#endif /*_DPU_HW_INTF_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c +6 -8
@@ -4,6 +4,8 @@* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. */ +#include <drm/drm_managed.h> +#include "dpu_kms.h" #include "dpu_hw_catalog.h" #include "dpu_hwio.h"
@@ -156,8 +158,9 @@ static void _setup_mixer_ops(struct dpu_hw_lm_ops *ops, ops->collect_misr = dpu_hw_lm_collect_misr; } -struct dpu_hw_mixer *dpu_hw_lm_init (const struct dpu_lm_cfg *cfg, -void __iomem *addr) +struct dpu_hw_mixer *dpu_hw_lm_init (struct drm_device *dev, +const struct dpu_lm_cfg *cfg, +void __iomem *addr) {struct dpu_hw_mixer *c;
@@ -166,7 +169,7 @@ struct dpu_hw_mixer *dpu_hw_lm_init(const struct dpu_lm_cfg *cfg,return NULL ; } - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -180,8 +183,3 @@ struct dpu_hw_mixer *dpu_hw_lm_init(const struct dpu_lm_cfg *cfg,return c; } - -void dpu_hw_lm_destroy (struct dpu_hw_mixer *lm) -{ -kfree (lm); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.h +4 -8
@@ -95,16 +95,12 @@ static inline struct dpu_hw_mixer *to_dpu_hw_mixer(struct dpu_hw_blk *hw)/** * dpu_hw_lm_init() - Initializes the mixer hw driver object. * should be called once before accessing every mixer. +* @dev: Corresponding device for devres management * @cfg: mixer catalog entry for which driver object is required * @addr: mapped register io address of MDP */ -struct dpu_hw_mixer *dpu_hw_lm_init (const struct dpu_lm_cfg *cfg, -void __iomem *addr); - -/** -* dpu_hw_lm_destroy(): Destroys layer mixer driver context -* @lm: Pointer to LM driver context -*/ -void dpu_hw_lm_destroy (struct dpu_hw_mixer *lm); +struct dpu_hw_mixer *dpu_hw_lm_init (struct drm_device *dev, +const struct dpu_lm_cfg *cfg, +void __iomem *addr);#endif /*_DPU_HW_LM_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.c +6 -8
@@ -4,6 +4,8 @@#include <linux/iopoll.h> +#include <drm/drm_managed.h> +#include "dpu_hw_mdss.h" #include "dpu_hwio.h" #include "dpu_hw_catalog.h"
@@ -37,12 +39,13 @@ static void _setup_merge_3d_ops(struct dpu_hw_merge_3d *c, c->ops.setup_3d_mode = dpu_hw_merge_3d_setup_3d_mode; }; -struct dpu_hw_merge_3d *dpu_hw_merge_3d_init (const struct dpu_merge_3d_cfg *cfg, -void __iomem *addr) +struct dpu_hw_merge_3d *dpu_hw_merge_3d_init (struct drm_device *dev, +const struct dpu_merge_3d_cfg *cfg, +void __iomem *addr) {struct dpu_hw_merge_3d *c; - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -55,8 +58,3 @@ struct dpu_hw_merge_3d *dpu_hw_merge_3d_init(const struct dpu_merge_3d_cfg *cfg,return c; } - -void dpu_hw_merge_3d_destroy (struct dpu_hw_merge_3d *hw) -{ -kfree (hw); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_merge3d.h +4 -9
@@ -48,18 +48,13 @@ static inline struct dpu_hw_merge_3d *to_dpu_hw_merge_3d(struct dpu_hw_blk *hw)/** * dpu_hw_merge_3d_init() - Initializes the merge_3d driver for the passed * merge3d catalog entry. +* @dev: Corresponding device for devres management * @cfg: Pingpong catalog entry for which driver object is required * @addr: Mapped register io address of MDP * Return: Error code or allocated dpu_hw_merge_3d context */ -struct dpu_hw_merge_3d *dpu_hw_merge_3d_init (const struct dpu_merge_3d_cfg *cfg, -void __iomem *addr); - -/** -* dpu_hw_merge_3d_destroy - destroys merge_3d driver context -* should be called to free the context -* @pp: Pointer to PP driver context returned by dpu_hw_merge_3d_init -*/ -void dpu_hw_merge_3d_destroy (struct dpu_hw_merge_3d *pp); +struct dpu_hw_merge_3d *dpu_hw_merge_3d_init (struct drm_device *dev, +const struct dpu_merge_3d_cfg *cfg, +void __iomem *addr);#endif /*_DPU_HW_MERGE3D_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.c +6 -8
@@ -4,6 +4,8 @@#include <linux/iopoll.h> +#include <drm/drm_managed.h> +#include "dpu_hw_mdss.h" #include "dpu_hwio.h" #include "dpu_hw_catalog.h"
@@ -302,12 +304,13 @@ static void _setup_pingpong_ops(struct dpu_hw_pingpong *c, c->ops.setup_dither = dpu_hw_pp_setup_dither; }; -struct dpu_hw_pingpong *dpu_hw_pingpong_init (const struct dpu_pingpong_cfg *cfg, -void __iomem *addr) +struct dpu_hw_pingpong *dpu_hw_pingpong_init (struct drm_device *dev, +const struct dpu_pingpong_cfg *cfg, +void __iomem *addr) {struct dpu_hw_pingpong *c; - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -320,8 +323,3 @@ struct dpu_hw_pingpong *dpu_hw_pingpong_init(const struct dpu_pingpong_cfg *cfg,return c; } - -void dpu_hw_pingpong_destroy (struct dpu_hw_pingpong *pp) -{ -kfree (pp); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_pingpong.h +4 -9
@@ -121,18 +121,13 @@ static inline struct dpu_hw_pingpong *to_dpu_hw_pingpong(struct dpu_hw_blk *hw)/** * dpu_hw_pingpong_init() - initializes the pingpong driver for the passed * pingpong catalog entry. +* @dev: Corresponding device for devres management * @cfg: Pingpong catalog entry for which driver object is required * @addr: Mapped register io address of MDP * Return: Error code or allocated dpu_hw_pingpong context */ -struct dpu_hw_pingpong *dpu_hw_pingpong_init (const struct dpu_pingpong_cfg *cfg, -void __iomem *addr); - -/** -* dpu_hw_pingpong_destroy - destroys pingpong driver context -* should be called to free the context -* @pp: Pointer to PP driver context returned by dpu_hw_pingpong_init -*/ -void dpu_hw_pingpong_destroy (struct dpu_hw_pingpong *pp); +struct dpu_hw_pingpong *dpu_hw_pingpong_init (struct drm_device *dev, +const struct dpu_pingpong_cfg *cfg, +void __iomem *addr);#endif /*_DPU_HW_PINGPONG_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.c +6 -9
@@ -9,6 +9,7 @@#include "dpu_kms.h" #include <drm/drm_file.h> +#include <drm/drm_managed.h> #define DPU_FETCH_CONFIG_RESET_VALUE 0x00000087
@@ -669,15 +670,17 @@ int _dpu_hw_sspp_init_debugfs(struct dpu_hw_sspp *hw_pipe, struct dpu_kms *kms, }#endif -struct dpu_hw_sspp *dpu_hw_sspp_init (const struct dpu_sspp_cfg *cfg, -void __iomem *addr,const struct dpu_ubwc_cfg *ubwc) +struct dpu_hw_sspp *dpu_hw_sspp_init (struct drm_device *dev, +const struct dpu_sspp_cfg *cfg, +void __iomem *addr, +const struct dpu_ubwc_cfg *ubwc) {struct dpu_hw_sspp *hw_pipe;if (!addr || !ubwc)return ERR_PTR (-EINVAL ); - hw_pipe =kzalloc (sizeof (*hw_pipe),GFP_KERNEL ); + hw_pipe =drmm_kzalloc (dev,sizeof (*hw_pipe),GFP_KERNEL );if (!hw_pipe)return ERR_PTR (-ENOMEM );
@@ -692,9 +695,3 @@ struct dpu_hw_sspp *dpu_hw_sspp_init(const struct dpu_sspp_cfg *cfg,return hw_pipe; } - -void dpu_hw_sspp_destroy (struct dpu_hw_sspp *ctx) -{ -kfree (ctx); -} -
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_sspp.h +5 -2
@@ -331,12 +331,15 @@ struct dpu_kms;/** * dpu_hw_sspp_init() - Initializes the sspp hw driver object. * Should be called once before accessing every pipe. +* @dev: Corresponding device for devres management * @cfg: Pipe catalog entry for which driver object is required * @addr: Mapped register io address of MDP * @ubwc: UBWC configuration data */ -struct dpu_hw_sspp *dpu_hw_sspp_init (const struct dpu_sspp_cfg *cfg, -void __iomem *addr,const struct dpu_ubwc_cfg *ubwc); +struct dpu_hw_sspp *dpu_hw_sspp_init (struct drm_device *dev, +const struct dpu_sspp_cfg *cfg, +void __iomem *addr, +const struct dpu_ubwc_cfg *ubwc);/** * dpu_hw_sspp_destroy(): Destroys SSPP driver context
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c +6 -8
@@ -3,6 +3,8 @@* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved */ +#include <drm/drm_managed.h> +#include "dpu_hw_mdss.h" #include "dpu_hwio.h" #include "dpu_hw_catalog.h"
@@ -194,15 +196,16 @@ static void _setup_wb_ops(struct dpu_hw_wb_ops *ops, ops->bind_pingpong_blk = dpu_hw_wb_bind_pingpong_blk; } -struct dpu_hw_wb *dpu_hw_wb_init (const struct dpu_wb_cfg *cfg, -void __iomem *addr) +struct dpu_hw_wb *dpu_hw_wb_init (struct drm_device *dev, +const struct dpu_wb_cfg *cfg, +void __iomem *addr) {struct dpu_hw_wb *c;if (!addr)return ERR_PTR (-EINVAL ); - c =kzalloc (sizeof (*c),GFP_KERNEL ); + c =drmm_kzalloc (dev,sizeof (*c),GFP_KERNEL );if (!c)return ERR_PTR (-ENOMEM );
@@ -216,8 +219,3 @@ struct dpu_hw_wb *dpu_hw_wb_init(const struct dpu_wb_cfg *cfg,return c; } - -void dpu_hw_wb_destroy (struct dpu_hw_wb *hw_wb) -{ -kfree (hw_wb); -}
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.h +4 -8
@@ -72,17 +72,13 @@ struct dpu_hw_wb {/** * dpu_hw_wb_init() - Initializes the writeback hw driver object. +* @dev: Corresponding device for devres management * @cfg: wb_path catalog entry for which driver object is required * @addr: mapped register io address of MDP * Return: Error code or allocated dpu_hw_wb context */ -struct dpu_hw_wb *dpu_hw_wb_init (const struct dpu_wb_cfg *cfg, -void __iomem *addr); - -/** -* dpu_hw_wb_destroy(): Destroy writeback hw driver object. -* @hw_wb: Pointer to writeback hw driver object -*/ -void dpu_hw_wb_destroy (struct dpu_hw_wb *hw_wb); +struct dpu_hw_wb *dpu_hw_wb_init (struct drm_device *dev, +const struct dpu_wb_cfg *cfg, +void __iomem *addr);#endif /*_DPU_HW_WB_H */
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +1 -7
@@ -816,10 +816,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms) dpu_kms->hw_vbif[i] =NULL ; } -if (dpu_kms->rm_init) -dpu_rm_destroy (&dpu_kms->rm); - dpu_kms->rm_init = false; - dpu_kms->catalog =NULL ; dpu_kms->hw_mdp =NULL ;
@@ -1041,14 +1037,12 @@ static int dpu_kms_hw_init(struct msm_kms *kms) goto err_pm_put; } - rc =dpu_rm_init (&dpu_kms->rm, dpu_kms->catalog, dpu_kms->mmio); + rc =dpu_rm_init (dev, &dpu_kms->rm, dpu_kms->catalog, dpu_kms->mmio);if (rc) {DPU_ERROR ("rm init failed: %d\n" , rc); goto err_pm_put; } - dpu_kms->rm_init = true; - dpu_kms->hw_mdp = dpu_hw_mdptop_init(dev, dpu_kms->catalog->mdp, dpu_kms->mmio,
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +0 -1
@@ -87,7 +87,6 @@ struct dpu_kms {struct drm_private_obj global_state;struct dpu_rm rm; -bool rm_init;struct dpu_hw_vbif *hw_vbif[VBIF_MAX ];struct dpu_hw_mdp *hw_mdp;
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +12 -78
157 lines not on this page · raw message
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +3 -8
@@ -38,22 +38,17 @@ struct dpu_rm {/** * dpu_rm_init - Read hardware catalog and create reservation tracking objects * for all HW blocks. +* @dev: Corresponding device for devres management * @rm: DPU Resource Manager handle * @cat: Pointer to hardware catalog * @mmio: mapped register io address of MDP * @Return: 0 on Success otherwise -ERROR */ -int dpu_rm_init (struct dpu_rm *rm, +int dpu_rm_init (struct drm_device *dev, +struct dpu_rm *rm,const struct dpu_mdss_cfg *cat,void __iomem *mmio); -/** -* dpu_rm_destroy - Free all memory allocated by dpu_rm_init -* @rm: DPU Resource Manager handle -* @Return: 0 on Success otherwise -ERROR -*/ -int dpu_rm_destroy (struct dpu_rm *rm); -/** * dpu_rm_reserve - Given a CRTC->Encoder->Connector display chain, analyze * the use connections and user requirements, specified through related
Signature · 1 line
2.39.2
PATCH 7/13 drm/msm/dpu: drop unused dpu_plane::lock
In reply to Dmitry BaryshkovThe field dpu_plane::lock was never used for protecting any kind of data. Drop it now.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0 -6
@@ -78,8 +78,6 @@ static const uint32_t qcom_compressed_supported_formats[] = {struct dpu_plane {struct drm_plane base; -struct mutex lock; -enum dpu_sspp pipe;uint32_t color_fill;
@@ -1186,8 +1184,6 @@ static void dpu_plane_destroy(struct drm_plane *plane)if (pstate->r_pipe.sspp)_dpu_plane_set_qos_ctrl (plane, &pstate->r_pipe, false); -mutex_destroy (&pdpu->lock); -/* this will destroy the states as well */ drm_plane_cleanup (plane);
@@ -1447,8 +1443,6 @@ struct drm_plane *dpu_plane_init(struct drm_device *dev,/* success! finalize initialization */ drm_plane_helper_add (plane, &dpu_plane_helper_funcs); -mutex_init (&pdpu->lock); -DPU_DEBUG ("%s created for pipe:%u id:%u\n" , plane->name, pipe, plane->base.id);return plane;
Signature · 1 line
2.39.2
PATCH 8/13 drm/msm/dpu: remove QoS teardown on plane destruction
In reply to Dmitry BaryshkovThere is little point in disabling QoS on plane destruction: it happens during DPU device destruction process, after which there will be no running planes.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +0 -7
@@ -1173,17 +1173,10 @@ static void dpu_plane_atomic_update(struct drm_plane *plane,static void dpu_plane_destroy (struct drm_plane *plane) {struct dpu_plane *pdpu = plane ?to_dpu_plane (plane) :NULL ; -struct dpu_plane_state *pstate;DPU_DEBUG_PLANE (pdpu,"\n" );if (pdpu) { - pstate =to_dpu_plane_state (plane->state); -_dpu_plane_set_qos_ctrl (plane, &pstate->pipe, false); - -if (pstate->r_pipe.sspp) -_dpu_plane_set_qos_ctrl (plane, &pstate->r_pipe, false); -/* this will destroy the states as well */ drm_plane_cleanup (plane);
Signature · 1 line
2.39.2
PATCH 9/13 drm/msm/dpu: use drmm-managed allocation for dpu_plane
In reply to Dmitry BaryshkovChange struct dpu_plane allocation to use drmm_universal_plane_alloc(). This removes the need to perform any actions on plane destruction.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 44 +++++------------------ 1 file changed, 9 insertions(+), 35 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +9 -35
@@ -1170,20 +1170,6 @@ static void dpu_plane_atomic_update(struct drm_plane *plane, } } -static void dpu_plane_destroy (struct drm_plane *plane) -{ -struct dpu_plane *pdpu = plane ?to_dpu_plane (plane) :NULL ; - -DPU_DEBUG_PLANE (pdpu,"\n" ); - -if (pdpu) { -/* this will destroy the states as well */ -drm_plane_cleanup (plane); - -kfree (pdpu); - } -} -static void dpu_plane_destroy_state (struct drm_plane *plane,struct drm_plane_state *state) {
@@ -1353,7 +1339,6 @@ static bool dpu_plane_format_mod_supported(struct drm_plane *plane,static const struct drm_plane_funcs dpu_plane_funcs = { .update_plane = drm_atomic_helper_update_plane, .disable_plane = drm_atomic_helper_disable_plane, - .destroy = dpu_plane_destroy, .reset = dpu_plane_reset, .atomic_duplicate_state = dpu_plane_duplicate_state, .atomic_destroy_state = dpu_plane_destroy_state,
@@ -1383,33 +1368,26 @@ struct drm_plane *dpu_plane_init(struct drm_device *dev,uint32_t supported_rotations;int ret = -EINVAL ; -/* create and zero local structure */ - pdpu =kzalloc (sizeof (*pdpu),GFP_KERNEL ); -if (!pdpu) { -DPU_ERROR ("[%u]failed to allocate local plane struct\n" , pipe); - ret = -ENOMEM ; -return ERR_PTR (ret); - } - -/* cache local stuff for later */ - plane = &pdpu->base; - pdpu->pipe = pipe; -/* initialize underlying h/w driver */ pipe_hw =dpu_rm_get_sspp (&kms->rm, pipe);if (!pipe_hw || !pipe_hw->cap || !pipe_hw->cap->sblk) {DPU_ERROR ("[%u]SSPP is invalid\n" , pipe); - goto clean_plane; +return ERR_CAST (pdpu); } format_list = pipe_hw->cap->sblk->format_list; num_formats = pipe_hw->cap->sblk->num_formats; - ret =drm_universal_plane_init (dev, plane,0xff , &dpu_plane_funcs, + pdpu = drmm_universal_plane_alloc(dev, struct dpu_plane, base, +0xff , &dpu_plane_funcs, format_list, num_formats, supported_format_modifiers, type,NULL ); -if (ret) - goto clean_plane; +if (IS_ERR (pdpu)) +return ERR_CAST (pdpu); + +/* cache local stuff for later */ + plane = &pdpu->base; + pdpu->pipe = pipe; pdpu->catalog = kms->catalog;
@@ -1439,8 +1417,4 @@ struct drm_plane *dpu_plane_init(struct drm_device *dev,DPU_DEBUG ("%s created for pipe:%u id:%u\n" , plane->name, pipe, plane->base.id);return plane; - -clean_plane: -kfree (pdpu); -return ERR_PTR (ret); }
Signature · 1 line
2.39.2
PATCH 10/13 drm/msm/dpu: use drmm-managed allocation for dpu_crtc
In reply to Dmitry BaryshkovChange struct dpu_crtc allocation to use drmm_crtc_alloc_with_planes(). This removes the need to perform any actions on CRTC destruction.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +5 -16
@@ -51,17 +51,6 @@ static struct dpu_kms *_dpu_crtc_get_kms(struct drm_crtc *crtc)return to_dpu_kms (priv->kms); } -static void dpu_crtc_destroy (struct drm_crtc *crtc) -{ -struct dpu_crtc *dpu_crtc =to_dpu_crtc (crtc); - -if (!crtc) -return ; - -drm_crtc_cleanup (crtc); -kfree (dpu_crtc); -} -static struct drm_encoder *get_encoder_from_crtc (struct drm_crtc *crtc) {struct drm_device *dev = crtc->dev;
@@ -1433,7 +1422,6 @@ static int dpu_crtc_late_register(struct drm_crtc *crtc)static const struct drm_crtc_funcs dpu_crtc_funcs = { .set_config = drm_atomic_helper_set_config, - .destroy = dpu_crtc_destroy, .page_flip = drm_atomic_helper_page_flip, .reset = dpu_crtc_reset, .atomic_duplicate_state = dpu_crtc_duplicate_state,
@@ -1467,7 +1455,11 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane,struct dpu_crtc *dpu_crtc =NULL ;int i, ret; - dpu_crtc =kzalloc (sizeof (*dpu_crtc),GFP_KERNEL ); + dpu_crtc = drmm_crtc_alloc_with_planes(dev, struct dpu_crtc, base, + plane, cursor, + &dpu_crtc_funcs, +NULL ); +if (!dpu_crtc)return ERR_PTR (-ENOMEM );
@@ -1489,9 +1481,6 @@ struct drm_crtc *dpu_crtc_init(struct drm_device *dev, struct drm_plane *plane, dpu_crtc_frame_event_work); } -drm_crtc_init_with_planes (dev, crtc, plane, cursor, &dpu_crtc_funcs, -NULL ); -drm_crtc_helper_add (crtc, &dpu_crtc_helper_funcs);if (dpu_kms->catalog->dspp_count)
Signature · 1 line
2.39.2
PATCH 11/13 drm/msm/dpu: use drmm-managed allocation for dpu_encoder_phys
In reply to Dmitry BaryshkovChange struct allocation of encoder's phys backend data to use drmm_kzalloc(). This removes the need to perform any actions on encoder destruction.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 9 ++++---- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 8 ++++--- .../drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c | 15 ++++--------- .../drm/msm/disp/dpu1/dpu_encoder_phys_vid.c | 13 ++++-------- .../drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 21 ++++--------------- 5 files changed, 22 insertions(+), 44 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +5 -4
@@ -2199,6 +2199,7 @@ static void dpu_encoder_early_unregister(struct drm_encoder *encoder) }static int dpu_encoder_virt_add_phys_encs ( +struct drm_device *dev,struct msm_display_info *disp_info,struct dpu_encoder_virt *dpu_enc,struct dpu_enc_phys_init_params *params)
@@ -2220,7 +2221,7 @@ static int dpu_encoder_virt_add_phys_encs(if (disp_info->intf_type ==INTF_WB ) { - enc =dpu_encoder_phys_wb_init (params); + enc =dpu_encoder_phys_wb_init (dev, params);if (IS_ERR (enc)) { DPU_ERROR_ENC(dpu_enc, "failed to init wb enc: %ld\n",
@@ -2231,7 +2232,7 @@ static int dpu_encoder_virt_add_phys_encs( dpu_enc->phys_encs[dpu_enc->num_phys_encs] = enc; ++dpu_enc->num_phys_encs; }else if (disp_info->is_cmd_mode) { - enc =dpu_encoder_phys_cmd_init (params); + enc =dpu_encoder_phys_cmd_init (dev, params);if (IS_ERR (enc)) { DPU_ERROR_ENC(dpu_enc, "failed to init cmd enc: %ld\n",
@@ -2242,7 +2243,7 @@ static int dpu_encoder_virt_add_phys_encs( dpu_enc->phys_encs[dpu_enc->num_phys_encs] = enc; ++dpu_enc->num_phys_encs; }else { - enc =dpu_encoder_phys_vid_init (params); + enc =dpu_encoder_phys_vid_init (dev, params);if (IS_ERR (enc)) { DPU_ERROR_ENC(dpu_enc, "failed to init vid enc: %ld\n",
@@ -2333,7 +2334,7 @@ static int dpu_encoder_setup_display(struct dpu_encoder_virt *dpu_enc,break ; } - ret =dpu_encoder_virt_add_phys_encs (disp_info, + ret =dpu_encoder_virt_add_phys_encs (dpu_kms->dev, disp_info, dpu_enc, &phys_params);if (ret) {DPU_ERROR_ENC (dpu_enc,"failed to add phys encs\n" );
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +5 -3
@@ -281,22 +281,24 @@ struct dpu_encoder_wait_info {* @p: Pointer to init params structure * Return: Error code or newly allocated encoder */ -struct dpu_encoder_phys *dpu_encoder_phys_vid_init ( +struct dpu_encoder_phys *dpu_encoder_phys_vid_init (struct drm_device *dev,struct dpu_enc_phys_init_params *p);/** * dpu_encoder_phys_cmd_init - Construct a new command mode physical encoder +* @dev: Corresponding device for devres management * @p: Pointer to init params structure * Return: Error code or newly allocated encoder */ -struct dpu_encoder_phys *dpu_encoder_phys_cmd_init ( +struct dpu_encoder_phys *dpu_encoder_phys_cmd_init (struct drm_device *dev,struct dpu_enc_phys_init_params *p);/** * dpu_encoder_phys_wb_init - initialize writeback encoder +* @dev: Corresponding device for devres management * @init: Pointer to init info structure with initialization params */ -struct dpu_encoder_phys *dpu_encoder_phys_wb_init ( +struct dpu_encoder_phys *dpu_encoder_phys_wb_init (struct drm_device *dev,struct dpu_enc_phys_init_params *p);/**
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_cmd.c +4 -11
@@ -13,6 +13,8 @@#include "dpu_trace.h" #include "disp/msm_disp_snapshot.h" +#include <drm/drm_managed.h> +#define DPU_DEBUG_CMDENC (e, fmt, ...) DPU_DEBUG("enc%d intf%d " fmt, \ (e) && (e)->base.parent ? \ (e)->base.parent->base.id : -1, \
@@ -563,14 +565,6 @@ static void dpu_encoder_phys_cmd_disable(struct dpu_encoder_phys *phys_enc) phys_enc->enable_state =DPU_ENC_DISABLED ; } -static void dpu_encoder_phys_cmd_destroy (struct dpu_encoder_phys *phys_enc) -{ -struct dpu_encoder_phys_cmd *cmd_enc = -to_dpu_encoder_phys_cmd (phys_enc); - -kfree (cmd_enc); -} -static void dpu_encoder_phys_cmd_prepare_for_kickoff (struct dpu_encoder_phys *phys_enc) {
@@ -736,7 +730,6 @@ static void dpu_encoder_phys_cmd_init_ops( ops->atomic_mode_set = dpu_encoder_phys_cmd_atomic_mode_set; ops->enable = dpu_encoder_phys_cmd_enable; ops->disable = dpu_encoder_phys_cmd_disable; - ops->destroy = dpu_encoder_phys_cmd_destroy; 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;
@@ -751,7 +744,7 @@ static void dpu_encoder_phys_cmd_init_ops( ops->get_line_count = dpu_encoder_phys_cmd_get_line_count; } -struct dpu_encoder_phys *dpu_encoder_phys_cmd_init ( +struct dpu_encoder_phys *dpu_encoder_phys_cmd_init (struct drm_device *dev,struct dpu_enc_phys_init_params *p) {struct dpu_encoder_phys *phys_enc =NULL ;
@@ -759,7 +752,7 @@ struct dpu_encoder_phys *dpu_encoder_phys_cmd_init(DPU_DEBUG ("intf\n" ); - cmd_enc =kzalloc (sizeof (*cmd_enc),GFP_KERNEL ); + cmd_enc =drmm_kzalloc (dev,sizeof (*cmd_enc),GFP_KERNEL );if (!cmd_enc) {DPU_ERROR ("failed to allocate\n" );return ERR_PTR (-ENOMEM );
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_vid.c +4 -9
@@ -11,6 +11,8 @@#include "dpu_trace.h" #include "disp/msm_disp_snapshot.h" +#include <drm/drm_managed.h> +#define DPU_DEBUG_VIDENC (e, fmt, ...) DPU_DEBUG("enc%d intf%d " fmt, \ (e) && (e)->parent ? \ (e)->parent->base.id : -1, \
@@ -438,12 +440,6 @@ static void dpu_encoder_phys_vid_enable(struct dpu_encoder_phys *phys_enc) phys_enc->enable_state =DPU_ENC_ENABLING ; } -static void dpu_encoder_phys_vid_destroy (struct dpu_encoder_phys *phys_enc) -{ -DPU_DEBUG_VIDENC (phys_enc,"\n" ); -kfree (phys_enc); -} -static int dpu_encoder_phys_vid_wait_for_vblank (struct dpu_encoder_phys *phys_enc) {
@@ -681,7 +677,6 @@ static void dpu_encoder_phys_vid_init_ops(struct dpu_encoder_phys_ops *ops) ops->atomic_mode_set = dpu_encoder_phys_vid_atomic_mode_set; ops->enable = dpu_encoder_phys_vid_enable; ops->disable = dpu_encoder_phys_vid_disable; - ops->destroy = dpu_encoder_phys_vid_destroy; 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;
@@ -694,7 +689,7 @@ static void dpu_encoder_phys_vid_init_ops(struct dpu_encoder_phys_ops *ops) ops->get_frame_count = dpu_encoder_phys_vid_get_frame_count; } -struct dpu_encoder_phys *dpu_encoder_phys_vid_init ( +struct dpu_encoder_phys *dpu_encoder_phys_vid_init (struct drm_device *dev,struct dpu_enc_phys_init_params *p) {struct dpu_encoder_phys *phys_enc =NULL ;
@@ -704,7 +699,7 @@ struct dpu_encoder_phys *dpu_encoder_phys_vid_init(return ERR_PTR (-EINVAL ); } - phys_enc =kzalloc (sizeof (*phys_enc),GFP_KERNEL ); + phys_enc =drmm_kzalloc (dev,sizeof (*phys_enc),GFP_KERNEL );if (!phys_enc) {DPU_ERROR ("failed to create encoder due to memory allocation error\n" );return ERR_PTR (-ENOMEM );
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +4 -17
@@ -8,6 +8,7 @@#include <linux/debugfs.h> #include <drm/drm_framebuffer.h> +#include <drm/drm_managed.h> #include "dpu_encoder_phys.h" #include "dpu_formats.h"
@@ -552,20 +553,6 @@ static void dpu_encoder_phys_wb_disable(struct dpu_encoder_phys *phys_enc) phys_enc->enable_state =DPU_ENC_DISABLED ; } -/** -* dpu_encoder_phys_wb_destroy - destroy writeback encoder -* @phys_enc: Pointer to physical encoder -*/ -static void dpu_encoder_phys_wb_destroy (struct dpu_encoder_phys *phys_enc) -{ -if (!phys_enc) -return ; - -DPU_DEBUG ("[wb:%d]\n" , phys_enc->hw_wb->idx -WB_0 ); - -kfree (phys_enc); -} -static void dpu_encoder_phys_wb_prepare_wb_job (struct dpu_encoder_phys *phys_enc,struct drm_writeback_job *job) {
@@ -661,7 +648,6 @@ static void dpu_encoder_phys_wb_init_ops(struct dpu_encoder_phys_ops *ops) ops->atomic_mode_set = dpu_encoder_phys_wb_atomic_mode_set; ops->enable = dpu_encoder_phys_wb_enable; ops->disable = dpu_encoder_phys_wb_disable; - ops->destroy = dpu_encoder_phys_wb_destroy; ops->atomic_check = dpu_encoder_phys_wb_atomic_check; ops->wait_for_commit_done = dpu_encoder_phys_wb_wait_for_commit_done; ops->prepare_for_kickoff = dpu_encoder_phys_wb_prepare_for_kickoff;
@@ -677,9 +663,10 @@ static void dpu_encoder_phys_wb_init_ops(struct dpu_encoder_phys_ops *ops)/** * dpu_encoder_phys_wb_init - initialize writeback encoder +* @dev: Corresponding device for devres management * @p: Pointer to init info structure with initialization params */ -struct dpu_encoder_phys *dpu_encoder_phys_wb_init ( +struct dpu_encoder_phys *dpu_encoder_phys_wb_init (struct drm_device *dev,struct dpu_enc_phys_init_params *p) {struct dpu_encoder_phys *phys_enc =NULL ;
@@ -692,7 +679,7 @@ struct dpu_encoder_phys *dpu_encoder_phys_wb_init(return ERR_PTR (-EINVAL ); } - wb_enc =kzalloc (sizeof (*wb_enc),GFP_KERNEL ); + wb_enc =drmm_kzalloc (dev,sizeof (*wb_enc),GFP_KERNEL );if (!wb_enc) {DPU_ERROR ("failed to allocate wb phys_enc enc\n" );return ERR_PTR (-ENOMEM );
Signature · 1 line
2.39.2
PATCH 12/13 drm/msm/dpu: drop dpu_encoder_phys_ops::destroy
In reply to Dmitry BaryshkovDrop the dpu_encoder_phys_ops' destroy() callback. No phys backend implements it anymore, so it is useless.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 18 ------------------ .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h | 2 -- 2 files changed, 20 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -18
@@ -456,24 +456,6 @@ static void dpu_encoder_destroy(struct drm_encoder *drm_enc) dpu_enc =to_dpu_encoder_virt (drm_enc);DPU_DEBUG_ENC (dpu_enc,"\n" ); -mutex_lock (&dpu_enc->enc_lock); - -for (i =0 ; i < dpu_enc->num_phys_encs; i++) { -struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; - -if (phys->ops.destroy) { - phys->ops.destroy (phys); - --dpu_enc->num_phys_encs; - dpu_enc->phys_encs[i] =NULL ; - } - } - -if (dpu_enc->num_phys_encs) -DPU_ERROR_ENC (dpu_enc,"expected 0 num_phys_encs not %d\n" , - dpu_enc->num_phys_encs); - dpu_enc->num_phys_encs =0 ; -mutex_unlock (&dpu_enc->enc_lock); -drm_encoder_cleanup (drm_enc);mutex_destroy (&dpu_enc->enc_lock); }
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys.h +0 -2
@@ -72,7 +72,6 @@ struct dpu_encoder_phys;* @enable: DRM Call. Enable a DRM mode. * @disable: DRM Call. Disable mode. * @atomic_check: DRM Call. Atomic check new DRM state. -* @destroy: DRM Call. Destroy and release resources. * @control_vblank_irq Register/Deregister for VBLANK IRQ * @wait_for_commit_done: Wait for hardware to have flushed the * current pending frames to hardware
@@ -102,7 +101,6 @@ struct dpu_encoder_phys_ops {int (*atomic_check)(struct dpu_encoder_phys *encoder,struct drm_crtc_state *crtc_state,struct drm_connector_state *conn_state); -void (*destroy)(struct dpu_encoder_phys *encoder);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);
Signature · 1 line
2.39.2
PATCH 13/13 drm/msm/dpu: use drmm-managed allocation for dpu_encoder_virt
In reply to Dmitry BaryshkovIt is incorrect to use devm-managed memory allocations for DRM data structures exposed to userspace. They should use drmm_ allocations. Change struct dpu_encoder allocation to use drmm_encoder_alloc(). This removes the need to perform any actions on encoder destruction.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 44 ++++----------------- 1 file changed, 7 insertions(+), 37 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +7 -37
@@ -443,23 +443,6 @@ int dpu_encoder_get_linecount(struct drm_encoder *drm_enc)return linecount; } -static void dpu_encoder_destroy (struct drm_encoder *drm_enc) -{ -struct dpu_encoder_virt *dpu_enc =NULL ; -int i =0 ; - -if (!drm_enc) { -DPU_ERROR ("invalid encoder\n" ); -return ; - } - - dpu_enc =to_dpu_encoder_virt (drm_enc); -DPU_DEBUG_ENC (dpu_enc,"\n" ); - -drm_encoder_cleanup (drm_enc); -mutex_destroy (&dpu_enc->enc_lock); -} -void dpu_encoder_helper_split_config (struct dpu_encoder_phys *phys_enc,enum dpu_intf interface)
@@ -2365,7 +2348,6 @@ static const struct drm_encoder_helper_funcs dpu_encoder_helper_funcs = { };static const struct drm_encoder_funcs dpu_encoder_funcs = { - .destroy = dpu_encoder_destroy, .late_register = dpu_encoder_late_register, .early_unregister = dpu_encoder_early_unregister, };
@@ -2376,21 +2358,14 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev, {struct msm_drm_private *priv = dev->dev_private;struct dpu_kms *dpu_kms =to_dpu_kms (priv->kms); -struct drm_encoder *drm_enc =NULL ; -struct dpu_encoder_virt *dpu_enc =NULL ; +struct dpu_encoder_virt *dpu_enc;int ret =0 ; - dpu_enc =devm_kzalloc (dev->dev,sizeof (*dpu_enc),GFP_KERNEL ); + dpu_enc = drmm_encoder_alloc(dev, struct dpu_encoder_virt, base, + &dpu_encoder_funcs, drm_enc_mode,NULL );if (!dpu_enc)return ERR_PTR (-ENOMEM ); - ret =drm_encoder_init (dev, &dpu_enc->base, &dpu_encoder_funcs, - drm_enc_mode,NULL ); -if (ret) { -devm_kfree (dev->dev, dpu_enc); -return ERR_PTR (ret); - } -drm_encoder_helper_add (&dpu_enc->base, &dpu_encoder_helper_funcs);spin_lock_init (&dpu_enc->enc_spinlock);
@@ -2399,8 +2374,10 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev,mutex_init (&dpu_enc->rc_lock); ret =dpu_encoder_setup_display (dpu_enc, dpu_kms, disp_info); -if (ret) - goto fail; +if (ret) { +DPU_ERROR ("failed to setup encoder\n" ); +return ERR_PTR (-ENOMEM ); + }atomic_set (&dpu_enc->frame_done_timeout_ms,0 ); timer_setup(&dpu_enc->frame_done_timer,
@@ -2426,13 +2403,6 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev,DPU_DEBUG_ENC (dpu_enc,"created\n" );return &dpu_enc->base; - -fail: -DPU_ERROR ("failed to create encoder\n" ); -if (drm_enc) -dpu_encoder_destroy (drm_enc); - -return ERR_PTR (ret); } int dpu_encoder_wait_for_event(struct drm_encoder *drm_enc,
Signature · 1 line
2.39.2