drm/msm: rework MDSS drivers
v2 cover drm/msm: rework MDSS drivers
These patches coninue work started by AngeloGioacchino Del Regno in the previous cycle by further decoupling and dissecting MDSS and MDP drivers probe/binding paths.
This removes code duplication between MDP5 and DPU1 MDSS drivers, by merging them and moving to the top level.
This patchset depends on the patches 1 and 2 from [1]
Changes since v1:
- Rebased on top of [2] and [1]
[1] https://patchwork.freedesktop.org/series/99066/
[2] https://patchwork.freedesktop.org/series/98521/
Dmitry Baryshkov (4):
drm/msm: unify MDSS drivers
drm/msm: remove extra indirection for msm_mdss
drm/msm: split the main platform driver
drm/msm: stop using device's match data pointer
drivers/gpu/drm/msm/Makefile | 3 +- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 10 +- drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c | 260 ------------- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 68 +++- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 11 +- drivers/gpu/drm/msm/disp/mdp5/mdp5_mdss.c | 252 ------------- drivers/gpu/drm/msm/msm_drv.c | 260 +++---------- drivers/gpu/drm/msm/msm_drv.h | 16 + drivers/gpu/drm/msm/msm_kms.h | 18 - drivers/gpu/drm/msm/msm_mdss.c | 438 ++++++++++++++++++++++ 10 files changed, 578 insertions(+), 758 deletions(-) delete mode 100644 drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c delete mode 100644 drivers/gpu/drm/msm/disp/mdp5/mdp5_mdss.c create mode 100644 drivers/gpu/drm/msm/msm_mdss.c
base-commit: 6ed95285382d6f90a3c3a11d5806a5eb7db715c3
prerequisite-patch-id: b5572c353efa8ebefb32fc70e54bc537f78ff2bd
prerequisite-patch-id: 40a854aee69b6ddf5b1c33cac3647efae3e3ebf1
prerequisite-patch-id: 8b687a19047983e26262a1bb2feda8a9fd5bc97f
prerequisite-patch-id: e2d7f768b4b287c80797635f3ed5b6353b12adb5
prerequisite-patch-id: cac9fb235e3510b5bcb713f602658e6233cd308b
Signature · 1 line
2.34.1
PATCH v2 1/4 drm/msm: unify MDSS drivers
MDP5 and DPU1 both provide the driver handling the MDSS region, which handles the irq domain and (incase of DPU1) adds some init for the UBWC controller. Unify those two pieces of code into a common driver.
---
drivers/gpu/drm/msm/Makefile | 3 +-
drivers/gpu/drm/msm/disp/mdp5/mdp5_mdss.c | 252 ------------------
drivers/gpu/drm/msm/msm_drv.c | 4 +-
drivers/gpu/drm/msm/msm_kms.h | 3 +-
.../msm/{disp/dpu1/dpu_mdss.c => msm_mdss.c} | 160 ++++++-----
5 files changed, 98 insertions(+), 324 deletions(-)
delete mode 100644 drivers/gpu/drm/msm/disp/mdp5/mdp5_mdss.c
rename drivers/gpu/drm/msm/{disp/dpu1/dpu_mdss.c => msm_mdss.c} (58%)drivers/gpu/drm/msm/Makefile +1 -2
@@ -42,7 +42,6 @@ msm-y := \ disp/mdp5/mdp5_crtc.o \ disp/mdp5/mdp5_encoder.o \ disp/mdp5/mdp5_irq.o \ - disp/mdp5/mdp5_mdss.o \ disp/mdp5/mdp5_kms.o \ disp/mdp5/mdp5_pipe.o \ disp/mdp5/mdp5_mixer.o \
@@ -67,7 +66,6 @@ msm-y := \ disp/dpu1/dpu_hw_util.o \ disp/dpu1/dpu_hw_vbif.o \ disp/dpu1/dpu_kms.o \ - disp/dpu1/dpu_mdss.o \ disp/dpu1/dpu_plane.o \ disp/dpu1/dpu_rm.o \ disp/dpu1/dpu_vbif.o \
@@ -88,6 +86,7 @@ msm-y := \ msm_gpu_devfreq.o \ msm_io_utils.o \ msm_iommu.o \ + msm_mdss.o \ msm_perf.o \ msm_rd.o \ msm_ringbuffer.o \
drivers/gpu/drm/msm/disp/mdp5/mdp5_mdss.c deleted +0 -252
252 lines not on this page · raw message
drivers/gpu/drm/msm/msm_drv.c +2 -2
@@ -1211,10 +1211,10 @@ static int msm_pdev_probe(struct platform_device *pdev)switch (get_mdp_ver (pdev)) {case KMS_MDP5 : - ret =mdp5_mdss_init (pdev); + ret =msm_mdss_init (pdev, true);break ;case KMS_DPU : - ret =dpu_mdss_init (pdev); + ret =msm_mdss_init (pdev, false);break ;default : ret =0 ;
drivers/gpu/drm/msm/msm_kms.h +1 -2
@@ -212,8 +212,7 @@ struct msm_mdss {const struct msm_mdss_funcs *funcs; }; -int mdp5_mdss_init (struct platform_device *dev); -int dpu_mdss_init (struct platform_device *dev); +int msm_mdss_init (struct platform_device *pdev,bool mdp5);#define for_each_crtc_mask (dev, crtc, crtc_mask) \ drm_for_each_crtc(crtc, dev) \
drivers/gpu/drm/msm/msm_mdss.c renamed from drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c +94 -66
274 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 1/4] drm/msm: unify MDSS drivers
Quoting Dmitry Baryshkov (2022-01-19 14:40:02)
Quoted 27 lines
drivers/gpu/drm/msm/msm_mdss.c renamed from drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c +3
-8@@ -188,22 +182,64 @@ static void dpu_mdss_destroy(struct msm_mdss *mdss)pm_runtime_suspend (mdss->dev);pm_runtime_disable (mdss->dev); -_dpu_mdss_irq_domain_fini (dpu_mdss); +irq_domain_remove (dpu_mdss->irq_controller.domain); + dpu_mdss->irq_controller.domain =NULL ; irq =platform_get_irq (pdev,0 );irq_set_chained_handler_and_data (irq,NULL ,NULL ); - -if (dpu_mdss->mmio) -devm_iounmap (&pdev->dev, dpu_mdss->mmio); - dpu_mdss->mmio =NULL ; }static const struct msm_mdss_funcs mdss_funcs = { - .enable = dpu_mdss_enable, - .disable = dpu_mdss_disable, - .destroy = dpu_mdss_destroy, + .enable = msm_mdss_enable,
drivers/gpu/drm/msm/msm_mdss.c static void dpu_mdss_destroy(struct msm_mdss *mdss) · line 201
Quoted 10 lines
drivers/gpu/drm/msm/msm_mdss.c renamed from drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c +7
-1+ .disable = msm_mdss_disable, + .destroy = msm_mdss_destroy, }; -int dpu_mdss_init (struct platform_device *pdev) +/* +* MDP5 MDSS uses at most three specified clocks. +*/ +#define MDP5_MDSS_NUM_CLOCKS 3 +int mdp5_mdss_parse_clock (struct platform_device *pdev,struct clk_bulk_data **clocks)
static?
Quoted 31 lines
drivers/gpu/drm/msm/msm_mdss.c renamed from drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c +31
-0+{ +struct clk_bulk_data *bulk; +struct clk *clk; +int num_clocks =0 ; + +if (!pdev) +return -EINVAL ; + + bulk =devm_kcalloc (&pdev->dev,MDP5_MDSS_NUM_CLOCKS ,sizeof (struct clk_bulk_data ),GFP_KERNEL ); +if (!bulk) +return -ENOMEM ; + +/* We ignore all the errors except deferral: typically they mean that the clock is not provided in the dts. */ + clk =msm_clk_get (pdev,"iface" ); +if (!IS_ERR (clk)) { + bulk[num_clocks].id ="iface" ; + bulk[num_clocks].clk = clk; + num_clocks++; + }else if (clk ==ERR_PTR (-EPROBE_DEFER )) +return -EPROBE_DEFER ; + + clk =msm_clk_get (pdev,"bus" ); +if (!IS_ERR (clk)) { + bulk[num_clocks].id ="bus" ; + bulk[num_clocks].clk = clk; + num_clocks++; + }else if (clk ==ERR_PTR (-EPROBE_DEFER )) +return -EPROBE_DEFER ; + + clk =msm_clk_get (pdev,"vsync" ); +if (!IS_ERR (clk)) {
drivers/gpu/drm/msm/msm_mdss.c static void dpu_mdss_destroy(struct msm_mdss *mdss) · line 242
Quoted 10 lines
drivers/gpu/drm/msm/msm_mdss.c renamed from drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c +10
-0+ bulk[num_clocks].id ="vsync" ; + bulk[num_clocks].clk = clk; + num_clocks++; + }else if (clk ==ERR_PTR (-EPROBE_DEFER )) +return -EPROBE_DEFER ; + +return num_clocks; +} + +int msm_mdss_init (struct platform_device *pdev,bool mdp5)
Maybe is_mdp5 so the if reads simpler.
Quoted 19 lines
drivers/gpu/drm/msm/msm_mdss.c renamed from drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c +6
-3{struct msm_drm_private *priv =platform_get_drvdata (pdev);struct dpu_mdss *dpu_mdss;@@ -220,27 +256,28 @@ int dpu_mdss_init(struct platform_device *pdev)DRM_DEBUG ("mapped mdss address space @%pK\n" , dpu_mdss->mmio); - ret =msm_parse_clock (pdev, &dpu_mdss->clocks); +if (mdp5) + ret =mdp5_mdss_parse_clock (pdev, &dpu_mdss->clocks); +else + ret =msm_parse_clock (pdev, &dpu_mdss->clocks);if (ret <0 ) { -DPU_ERROR ("failed to parse clocks, ret=%d\n" , ret); - goto clk_parse_err; +DRM_ERROR ("failed to parse clocks, ret=%d\n" , ret); +return ret; } dpu_mdss->num_clocks = ret;
PATCH v2 2/4 drm/msm: remove extra indirection for msm_mdss
In reply to Dmitry BaryshkovSince now there is just one mdss subdriver, drop all the indirection, make msm_mdss struct completely opaque (and defined inside msm_mdss.c) and call mdss functions directly.
--- drivers/gpu/drm/msm/msm_drv.c | 44 ++++++++---- drivers/gpu/drm/msm/msm_kms.h | 16 ++--- drivers/gpu/drm/msm/msm_mdss.c | 125 ++++++++++++++------------------- 3 files changed, 88 insertions(+), 97 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +29 -15
@@ -951,8 +951,8 @@ static int __maybe_unused msm_runtime_suspend(struct device *dev)DBG ("" ); -if (mdss && mdss->funcs) -return mdss->funcs->disable (mdss); +if (mdss) +return msm_mdss_disable (mdss);return 0 ; }
@@ -964,8 +964,8 @@ static int __maybe_unused msm_runtime_resume(struct device *dev)DBG ("" ); -if (mdss && mdss->funcs) -return mdss->funcs->enable (mdss); +if (mdss) +return msm_mdss_enable (mdss);return 0 ; }
@@ -1200,6 +1200,7 @@ static const struct component_master_ops msm_drm_ops = {static int msm_pdev_probe (struct platform_device *pdev) {struct component_match *match =NULL ; +struct msm_mdss *mdss;struct msm_drm_private *priv;int ret;
@@ -1211,19 +1212,32 @@ static int msm_pdev_probe(struct platform_device *pdev)switch (get_mdp_ver (pdev)) {case KMS_MDP5 : - ret =msm_mdss_init (pdev, true); + mdss =msm_mdss_init (pdev, true); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + }else { + priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + }break ;case KMS_DPU : - ret =msm_mdss_init (pdev, false); + mdss =msm_mdss_init (pdev, false); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + }else { + priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + }break ;default : - ret =0 ;break ; } -if (ret) { -platform_set_drvdata (pdev,NULL ); -return ret; - }if (get_mdp_ver (pdev)) { ret =add_display_components (pdev, &match);
@@ -1251,8 +1265,8 @@ static int msm_pdev_probe(struct platform_device *pdev) fail:of_platform_depopulate (&pdev->dev); -if (priv->mdss && priv->mdss->funcs) - priv->mdss->funcs->destroy (priv->mdss); +if (priv->mdss) +msm_mdss_destroy (priv->mdss);return ret; }
@@ -1265,8 +1279,8 @@ static int msm_pdev_remove(struct platform_device *pdev)component_master_del (&pdev->dev, &msm_drm_ops);of_platform_depopulate (&pdev->dev); -if (mdss && mdss->funcs) - mdss->funcs->destroy (mdss); +if (mdss) +msm_mdss_destroy (mdss);return 0 ; }
drivers/gpu/drm/msm/msm_kms.h +5 -11
@@ -201,18 +201,12 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev);extern const struct of_device_id dpu_dt_match[];extern const struct of_device_id mdp5_dt_match[]; -struct msm_mdss_funcs { -int (*enable)(struct msm_mdss *mdss); -int (*disable)(struct msm_mdss *mdss); -void (*destroy)(struct msm_mdss *mdss); -}; - -struct msm_mdss { -struct device *dev; -const struct msm_mdss_funcs *funcs; -}; +struct msm_mdss ; -int msm_mdss_init (struct platform_device *pdev,bool mdp5); +struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5); +int msm_mdss_enable (struct msm_mdss *mdss); +int msm_mdss_disable (struct msm_mdss *mdss); +void msm_mdss_destroy (struct msm_mdss *mdss);#define for_each_crtc_mask (dev, crtc, crtc_mask) \ drm_for_each_crtc(crtc, dev) \
drivers/gpu/drm/msm/msm_mdss.c +54 -71
268 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 2/4] drm/msm: remove extra indirection for msm_mdss
Quoting Dmitry Baryshkov (2022-01-19 14:40:03)
Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -1211,19 +1212,32 @@ static int msm_pdev_probe(struct platform_device *pdev)
drivers/gpu/drm/msm/msm_drv.c static int msm_pdev_probe(struct platform_device *pdev) · line 1221
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +7
-1switch (get_mdp_ver (pdev)) {case KMS_MDP5 : - ret =msm_mdss_init (pdev, true); + mdss =msm_mdss_init (pdev, true); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + }else {
Drop else
Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +3
-1+ priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + }break ;case KMS_DPU : - ret =msm_mdss_init (pdev, false);
drivers/gpu/drm/msm/msm_drv.c static int msm_pdev_probe(struct platform_device *pdev) · line 1236
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +10
-0+ mdss =msm_mdss_init (pdev, false); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + }else { + priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + }
This is the same so why can't it be done below in the deleted if (ret)?
Quoted 17 lines
drivers/gpu/drm/msm/msm_drv.c +0
-5break ;default : - ret =0 ;break ; } -if (ret) { -platform_set_drvdata (pdev,NULL ); -return ret; - }if (get_mdp_ver (pdev)) { ret =add_display_components (pdev, &match);drivers/gpu/drm/msm/msm_kms.h +0
-0
drivers/gpu/drm/msm/msm_kms.h int mdp5_mdss_parse_clock(struct platform_device *pdev, struct clk_bulk_data **c · line 231
Quoted 5 lines
drivers/gpu/drm/msm/msm_kms.h +1
-1@@ -239,50 +228,44 @@ int mdp5_mdss_parse_clock(struct platform_device *pdev, struct clk_bulk_data **creturn num_clocks; } -int msm_mdss_init (struct platform_device *pdev,bool mdp5) +struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5)
Ah I see it will quickly become not static. Still should have static first and remove it here.
Re: [PATCH v2 2/4] drm/msm: remove extra indirection for msm_mdss
Quoted 38 lines · Stephen Boyd
Quoting Dmitry Baryshkov (2022-01-19 14:40:03)
Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +0
-0@@ -1211,19 +1212,32 @@ static int msm_pdev_probe(struct platform_device *pdev)drivers/gpu/drm/msm/msm_drv.c static int msm_pdev_probe(struct platform_device *pdev) · line 1221
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +7
-1switch (get_mdp_ver (pdev)) {case KMS_MDP5 : - ret =msm_mdss_init (pdev, true); + mdss =msm_mdss_init (pdev, true); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + }else {Drop else
Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +3
-1+ priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + }break ;case KMS_DPU : - ret =msm_mdss_init (pdev, false);drivers/gpu/drm/msm/msm_drv.c static int msm_pdev_probe(struct platform_device *pdev) · line 1236
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.c +10
-0+ mdss =msm_mdss_init (pdev, false); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + }else { + priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + }
Quoted 1 line
This is the same so why can't it be done below in the deleted if (ret)?
I didn't like the idea of checking the if (IS_ERR(mdss)) outside of the case blocks, but now I can move it back.
Quoted 26 lines
Quoted 18 lines
drivers/gpu/drm/msm/msm_drv.c +0
-5break ;default : - ret =0 ;break ; } -if (ret) { -platform_set_drvdata (pdev,NULL ); -return ret; - }if (get_mdp_ver (pdev)) { ret =add_display_components (pdev, &match);drivers/gpu/drm/msm/msm_kms.h +0
-0drivers/gpu/drm/msm/msm_kms.h int mdp5_mdss_parse_clock(struct platform_device *pdev, struct clk_bulk_data **c · line 231
Quoted 5 lines
drivers/gpu/drm/msm/msm_kms.h +1
-1@@ -239,50 +228,44 @@ int mdp5_mdss_parse_clock(struct platform_device *pdev, struct clk_bulk_data **creturn num_clocks; } -int msm_mdss_init (struct platform_device *pdev,bool mdp5) +struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5)Ah I see it will quickly become not static. Still should have static first and remove it here.
Signature · 2 lines
With best wishes Dmitry
PATCH v2 3/4 drm/msm: split the main platform driver
In reply to Dmitry BaryshkovCurrently the msm platform driver is a multiplex handling several cases:
- headless GPU-only driver,
- MDP4 with flat device nodes,
- MDP5/DPU MDSS with all the nodes being children of MDSS node.
This results in not-so-perfect code, checking the hardware version (MDP4/MDP5/DPU) in several places, checking for mdss even when it can not exist, etc. Split the code into three handling subdrivers (mdp4, mdss and headless msm).
--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 56 ++++++ drivers/gpu/drm/msm/msm_drv.c | 236 ++++------------------- drivers/gpu/drm/msm/msm_drv.h | 19 ++ drivers/gpu/drm/msm/msm_kms.h | 7 - drivers/gpu/drm/msm/msm_mdss.c | 178 ++++++++++++++++- 5 files changed, 287 insertions(+), 209 deletions(-)
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +56 -0
@@ -569,3 +569,59 @@ static struct mdp4_platform_config *mdp4_get_config(struct platform_device *dev)return &config; } + +static const struct dev_pm_ops mdp4_pm_ops = { + .prepare = msm_pm_prepare, + .complete = msm_pm_complete, +}; + +static int mdp4_probe (struct platform_device *pdev) +{ +struct msm_drm_private *priv; + + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +platform_set_drvdata (pdev, priv); + +/* +* on MDP4 based platforms, the MDP platform device is the component +* master that adds other display interface components to itself. +*/ +return msm_drv_probe (&pdev->dev, &pdev->dev); +} + +static int mdp4_remove (struct platform_device *pdev) +{ +component_master_del (&pdev->dev, &msm_drm_ops); + +return 0 ; +} + +static const struct of_device_id mdp4_dt_match[] = { + { .compatible ="qcom,mdp4" , .data = (void *)KMS_MDP4 }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, mdp4_dt_match); + +static struct platform_driver mdp4_platform_driver = { + .probe = mdp4_probe, + .remove = mdp4_remove, + .shutdown = msm_drv_shutdown, + .driver = { + .name ="mdp4" , + .of_match_table = mdp4_dt_match, + .pm = &mdp4_pm_ops, + }, +}; + +void __init msm_mdp4_register (void ) +{ +platform_driver_register (&mdp4_platform_driver); +} + +void __exit msm_mdp4_unregister(void) +{ +platform_driver_unregister (&mdp4_platform_driver); +}
drivers/gpu/drm/msm/msm_drv.c +38 -198
339 lines not on this page · raw message
drivers/gpu/drm/msm/msm_drv.h +19 -0
@@ -451,10 +451,18 @@ static inline void msm_dp_debugfs_init(struct msm_dp *dp_display,#endif +#define KMS_MDP4 4 +#define KMS_MDP5 5 +#define KMS_DPU 3 + +void __init msm_mdp4_register (void ); +void __exit msm_mdp4_unregister(void);void __init msm_mdp_register (void ); void __exit msm_mdp_unregister(void);void __init msm_dpu_register (void ); void __exit msm_dpu_unregister(void); +void __init msm_mdss_register (void ); +void __exit msm_mdss_unregister(void);#ifdef CONFIG_DEBUG_FS void msm_framebuffer_describe (struct drm_framebuffer *fb,struct seq_file *m);
@@ -555,4 +563,15 @@ static inline unsigned long timeout_to_jiffies(const ktime_t *timeout) return clamp(remaining_jiffies, 0LL, (s64)INT_MAX); } +/* Driver helpers */ + +extern const struct component_master_ops msm_drm_ops; + +int msm_pm_prepare (struct device *dev); +void msm_pm_complete (struct device *dev); + +int msm_drv_probe (struct device *master_dev,struct device *mdp_dev); +void msm_drv_shutdown (struct platform_device *pdev); + +#endif /* __MSM_DRV_H__ */
drivers/gpu/drm/msm/msm_kms.h +0 -7
@@ -201,13 +201,6 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev);extern const struct of_device_id dpu_dt_match[];extern const struct of_device_id mdp5_dt_match[]; -struct msm_mdss ; - -struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5); -int msm_mdss_enable (struct msm_mdss *mdss); -int msm_mdss_disable (struct msm_mdss *mdss); -void msm_mdss_destroy (struct msm_mdss *mdss); -#define for_each_crtc_mask (dev, crtc, crtc_mask) \ drm_for_each_crtc(crtc, dev) \ for_each_if (drm_crtc_mask(crtc) & (crtc_mask))
drivers/gpu/drm/msm/msm_mdss.c +174 -4
211 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 3/4] drm/msm: split the main platform driver
Quoting Dmitry Baryshkov (2022-01-19 14:40:04)
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.h +2
-0@@ -451,10 +451,18 @@ static inline void msm_dp_debugfs_init(struct msm_dp *dp_display,#endif +#define KMS_MDP4 4 +#define KMS_MDP5 5
drivers/gpu/drm/msm/msm_drv.h static inline void msm_dp_debugfs_init(struct msm_dp *dp_display, · line 465
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.h +6
-0+#define KMS_DPU 3 + +void __init msm_mdp4_register (void ); +void __exit msm_mdp4_unregister(void);void __init msm_mdp_register (void ); void __exit msm_mdp_unregister(void);void __init msm_dpu_register (void ); void __exit msm_dpu_unregister(void); +void __init msm_mdss_register (void ); +void __exit msm_mdss_unregister(void);
Don't need __init or __exit on prototypes.
drivers/gpu/drm/msm/msm_mdss.c line 11
Quoted 12 lines
drivers/gpu/drm/msm/msm_drv.h +0
-0#ifdef CONFIG_DEBUG_FS void msm_framebuffer_describe (struct drm_framebuffer *fb,struct seq_file *m);drivers/gpu/drm/msm/msm_mdss.c +1
-0@@ -8,6 +8,8 @@#include <linux/irqdesc.h> #include <linux/irqchip/chained_irq.h> +#include <drm/drm_of.h>
What's this include for?
Quoted 100 lines
drivers/gpu/drm/msm/msm_mdss.c +62
-4+#include "msm_drv.h" #include "msm_kms.h" @@ -127,7 +129,7 @@ static int _msm_mdss_irq_domain_add(struct msm_mdss *msm_mdss)return 0 ; } -int msm_mdss_enable (struct msm_mdss *msm_mdss) +static int msm_mdss_enable (struct msm_mdss *msm_mdss) {int ret;@@ -163,14 +165,14 @@ int msm_mdss_enable(struct msm_mdss *msm_mdss)return ret; } -int msm_mdss_disable (struct msm_mdss *msm_mdss) +static int msm_mdss_disable (struct msm_mdss *msm_mdss) {clk_bulk_disable_unprepare (msm_mdss->num_clocks, msm_mdss->clocks);return 0 ; } -void msm_mdss_destroy (struct msm_mdss *msm_mdss) +static void msm_mdss_destroy (struct msm_mdss *msm_mdss) {struct platform_device *pdev =to_platform_device (msm_mdss->dev);int irq;@@ -228,7 +230,7 @@ int mdp5_mdss_parse_clock(struct platform_device *pdev, struct clk_bulk_data **creturn num_clocks; } -struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5) +static struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5) {struct msm_mdss *msm_mdss;int ret;@@ -269,3 +271,171 @@ struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5)return msm_mdss; } + +static int __maybe_unused mdss_runtime_suspend (struct device *dev) +{ +struct msm_drm_private *priv =dev_get_drvdata (dev); + +DBG ("" ); + +return msm_mdss_disable (priv->mdss); +} + +static int __maybe_unused mdss_runtime_resume (struct device *dev) +{ +struct msm_drm_private *priv =dev_get_drvdata (dev); + +DBG ("" ); + +return msm_mdss_enable (priv->mdss); +} + +static int __maybe_unused mdss_pm_suspend (struct device *dev) +{ + +if (pm_runtime_suspended (dev)) +return 0 ; + +return mdss_runtime_suspend (dev); +} + +static int __maybe_unused mdss_pm_resume (struct device *dev) +{ +if (pm_runtime_suspended (dev)) +return 0 ; + +return mdss_runtime_resume (dev); +} + +static const struct dev_pm_ops mdss_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mdss_pm_suspend, mdss_pm_resume) +SET_RUNTIME_PM_OPS (mdss_runtime_suspend, mdss_runtime_resume,NULL ) + .prepare = msm_pm_prepare, + .complete = msm_pm_complete, +}; + +static int get_mdp_ver (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; + +return (int ) (unsigned long )of_device_get_match_data (dev); +} + +static int find_mdp_node (struct device *dev,void *data) +{ +return of_match_node (dpu_dt_match, dev->of_node) || +of_match_node (mdp5_dt_match, dev->of_node); +} + +static int mdss_probe (struct platform_device *pdev)
drivers/gpu/drm/msm/msm_mdss.c struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5) · line 340
Quoted 10 lines
drivers/gpu/drm/msm/msm_mdss.c +10
-0+{ +struct msm_mdss *mdss; +struct msm_drm_private *priv; +int mdp_ver =get_mdp_ver (pdev); +struct device *mdp_dev; +struct device *dev = &pdev->dev; +int ret; + +if (mdp_ver !=KMS_MDP5 && mdp_ver !=KMS_DPU ) +return -EINVAL ;
Is it possible anymore? Now that the driver is split it seems like no.
Quoted 31 lines
drivers/gpu/drm/msm/msm_mdss.c +31
-0+ + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +platform_set_drvdata (pdev, priv); + + mdss =msm_mdss_init (pdev, mdp_ver ==KMS_MDP5 ); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + } + + priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + +/* +* MDP5/DPU based devices don't have a flat hierarchy. There is a top +* level parent: MDSS, and children: MDP5/DPU, DSI, HDMI, eDP etc. +* Populate the children devices, find the MDP5/DPU node, and then add +* the interfaces to our components list. +*/ + ret =of_platform_populate (dev->of_node,NULL ,NULL , dev); +if (ret) { +DRM_DEV_ERROR (dev,"failed to populate children devices\n" ); + goto fail; + } + + mdp_dev =device_find_child (dev,NULL , find_mdp_node);
drivers/gpu/drm/msm/msm_mdss.c struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5) · line 381
Quoted 10 lines
drivers/gpu/drm/msm/msm_mdss.c +10
-0+if (!mdp_dev) { +DRM_DEV_ERROR (dev,"failed to find MDSS MDP node\n" ); +of_platform_depopulate (dev); + ret = -ENODEV ; + goto fail; + } + +/* +* on MDP5 based platforms, the MDSS platform device is the component +* master that adds MDP5 and other display interface components to
s/master//
Quoted 44 lines
drivers/gpu/drm/msm/msm_mdss.c +44
-0+* itself. +*/ + ret =msm_drv_probe (dev, mdp_dev); +put_device (mdp_dev); +if (ret) + goto fail; + +return 0 ; + +fail: +of_platform_depopulate (dev); +msm_mdss_destroy (priv->mdss); + +return ret; +} + +static int mdss_remove (struct platform_device *pdev) +{ +struct msm_drm_private *priv =platform_get_drvdata (pdev); +struct msm_mdss *mdss = priv->mdss; + +component_master_del (&pdev->dev, &msm_drm_ops); +of_platform_depopulate (&pdev->dev); + +msm_mdss_destroy (mdss); + +return 0 ; +} + +static const struct of_device_id mdss_dt_match[] = { + { .compatible ="qcom,mdss" , .data = (void *)KMS_MDP5 }, + { .compatible ="qcom,sdm845-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sc7180-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sc7280-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sm8150-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sm8250-mdss" , .data = (void *)KMS_DPU }, + {} +}; +MODULE_DEVICE_TABLE (of, dt_match); + +static struct platform_driver mdss_platform_driver = { + .probe = mdss_probe, + .remove = mdss_remove, + .shutdown = msm_drv_shutdown,
drivers/gpu/drm/msm/msm_mdss.c struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5) · line 435
Quoted 10 lines
drivers/gpu/drm/msm/msm_mdss.c +10
-0+ .driver = { + .name = "msm-mdss", + .of_match_table = mdss_dt_match, + .pm = &mdss_pm_ops, + }, +}; + +void __init msm_mdss_register (void ) +{ +platform_driver_register (&mdss_platform_driver);
I'd like to go a step further and not even compile drivers in that we don't use. Can we get some Kconfigs for these new drivers so that the number of drivers registered with the system is reduced and memory is conserved?
Re: [PATCH v2 3/4] drm/msm: split the main platform driver
Quoted 144 lines · Stephen Boyd
Quoting Dmitry Baryshkov (2022-01-19 14:40:04)
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.h +2
-0@@ -451,10 +451,18 @@ static inline void msm_dp_debugfs_init(struct msm_dp *dp_display,#endif +#define KMS_MDP4 4 +#define KMS_MDP5 5drivers/gpu/drm/msm/msm_drv.h static inline void msm_dp_debugfs_init(struct msm_dp *dp_display, · line 465
Quoted 10 lines
drivers/gpu/drm/msm/msm_drv.h +6
-0+#define KMS_DPU 3 + +void __init msm_mdp4_register (void ); +void __exit msm_mdp4_unregister(void);void __init msm_mdp_register (void ); void __exit msm_mdp_unregister(void);void __init msm_dpu_register (void ); void __exit msm_dpu_unregister(void); +void __init msm_mdss_register (void ); +void __exit msm_mdss_unregister(void);Don't need
__initor__exiton prototypes.drivers/gpu/drm/msm/msm_mdss.c line 11
Quoted 12 lines
drivers/gpu/drm/msm/msm_drv.h +0
-0#ifdef CONFIG_DEBUG_FS void msm_framebuffer_describe (struct drm_framebuffer *fb,struct seq_file *m);drivers/gpu/drm/msm/msm_mdss.c +1
-0@@ -8,6 +8,8 @@#include <linux/irqdesc.h> #include <linux/irqchip/chained_irq.h> +#include <drm/drm_of.h> What's this include for?
Quoted 104 lines
drivers/gpu/drm/msm/msm_mdss.c +66
-4+#include "msm_drv.h" #include "msm_kms.h" @@ -127,7 +129,7 @@ static int _msm_mdss_irq_domain_add(struct msm_mdss *msm_mdss)return 0 ; } -int msm_mdss_enable (struct msm_mdss *msm_mdss) +static int msm_mdss_enable (struct msm_mdss *msm_mdss) {int ret;@@ -163,14 +165,14 @@ int msm_mdss_enable(struct msm_mdss *msm_mdss)return ret; } -int msm_mdss_disable (struct msm_mdss *msm_mdss) +static int msm_mdss_disable (struct msm_mdss *msm_mdss) {clk_bulk_disable_unprepare (msm_mdss->num_clocks, msm_mdss->clocks);return 0 ; } -void msm_mdss_destroy (struct msm_mdss *msm_mdss) +static void msm_mdss_destroy (struct msm_mdss *msm_mdss) {struct platform_device *pdev =to_platform_device (msm_mdss->dev);int irq;@@ -228,7 +230,7 @@ int mdp5_mdss_parse_clock(struct platform_device *pdev, struct clk_bulk_data **creturn num_clocks; } -struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5) +static struct msm_mdss *msm_mdss_init (struct platform_device *pdev,bool mdp5) {struct msm_mdss *msm_mdss;int ret;@@ -269,3 +271,171 @@ struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5)return msm_mdss; } + +static int __maybe_unused mdss_runtime_suspend (struct device *dev) +{ +struct msm_drm_private *priv =dev_get_drvdata (dev); + +DBG ("" ); + +return msm_mdss_disable (priv->mdss); +} + +static int __maybe_unused mdss_runtime_resume (struct device *dev) +{ +struct msm_drm_private *priv =dev_get_drvdata (dev); + +DBG ("" ); + +return msm_mdss_enable (priv->mdss); +} + +static int __maybe_unused mdss_pm_suspend (struct device *dev) +{ + +if (pm_runtime_suspended (dev)) +return 0 ; + +return mdss_runtime_suspend (dev); +} + +static int __maybe_unused mdss_pm_resume (struct device *dev) +{ +if (pm_runtime_suspended (dev)) +return 0 ; + +return mdss_runtime_resume (dev); +} + +static const struct dev_pm_ops mdss_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mdss_pm_suspend, mdss_pm_resume) +SET_RUNTIME_PM_OPS (mdss_runtime_suspend, mdss_runtime_resume,NULL ) + .prepare = msm_pm_prepare, + .complete = msm_pm_complete, +}; + +static int get_mdp_ver (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; + +return (int ) (unsigned long )of_device_get_match_data (dev); +} + +static int find_mdp_node (struct device *dev,void *data) +{ +return of_match_node (dpu_dt_match, dev->of_node) || +of_match_node (mdp5_dt_match, dev->of_node); +} + +static int mdss_probe (struct platform_device *pdev) +{ +struct msm_mdss *mdss; +struct msm_drm_private *priv; +int mdp_ver =get_mdp_ver (pdev);
Quoted 8 lines
drivers/gpu/drm/msm/msm_mdss.c struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5) · line 340
Quoted 6 lines
drivers/gpu/drm/msm/msm_mdss.c +6
-0+struct device *mdp_dev; +struct device *dev = &pdev->dev; +int ret; + +if (mdp_ver !=KMS_MDP5 && mdp_ver !=KMS_DPU ) +return -EINVAL ;Is it possible anymore? Now that the driver is split it seems like no.
Yes, I'll drop this.
Quoted 96 lines
Quoted 32 lines
drivers/gpu/drm/msm/msm_mdss.c +31
-0+ + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + +platform_set_drvdata (pdev, priv); + + mdss =msm_mdss_init (pdev, mdp_ver ==KMS_MDP5 ); +if (IS_ERR (mdss)) { + ret =PTR_ERR (mdss); +platform_set_drvdata (pdev,NULL ); + +return ret; + } + + priv->mdss = mdss; +pm_runtime_enable (&pdev->dev); + +/* +* MDP5/DPU based devices don't have a flat hierarchy. There is a top +* level parent: MDSS, and children: MDP5/DPU, DSI, HDMI, eDP etc. +* Populate the children devices, find the MDP5/DPU node, and then add +* the interfaces to our components list. +*/ + ret =of_platform_populate (dev->of_node,NULL ,NULL , dev); +if (ret) { +DRM_DEV_ERROR (dev,"failed to populate children devices\n" ); + goto fail; + } + + mdp_dev =device_find_child (dev,NULL , find_mdp_node);drivers/gpu/drm/msm/msm_mdss.c struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5) · line 381
Quoted 10 lines
drivers/gpu/drm/msm/msm_mdss.c +10
-0+if (!mdp_dev) { +DRM_DEV_ERROR (dev,"failed to find MDSS MDP node\n" ); +of_platform_depopulate (dev); + ret = -ENODEV ; + goto fail; + } + +/* +* on MDP5 based platforms, the MDSS platform device is the component +* master that adds MDP5 and other display interface components to s/master//
Quoted 51 lines
drivers/gpu/drm/msm/msm_mdss.c +51
-0+* itself. +*/ + ret =msm_drv_probe (dev, mdp_dev); +put_device (mdp_dev); +if (ret) + goto fail; + +return 0 ; + +fail: +of_platform_depopulate (dev); +msm_mdss_destroy (priv->mdss); + +return ret; +} + +static int mdss_remove (struct platform_device *pdev) +{ +struct msm_drm_private *priv =platform_get_drvdata (pdev); +struct msm_mdss *mdss = priv->mdss; + +component_master_del (&pdev->dev, &msm_drm_ops); +of_platform_depopulate (&pdev->dev); + +msm_mdss_destroy (mdss); + +return 0 ; +} + +static const struct of_device_id mdss_dt_match[] = { + { .compatible ="qcom,mdss" , .data = (void *)KMS_MDP5 }, + { .compatible ="qcom,sdm845-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sc7180-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sc7280-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sm8150-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,sm8250-mdss" , .data = (void *)KMS_DPU }, + {} +}; +MODULE_DEVICE_TABLE (of, dt_match); + +static struct platform_driver mdss_platform_driver = { + .probe = mdss_probe, + .remove = mdss_remove, + .shutdown = msm_drv_shutdown, + .driver = { + .name ="msm-mdss" , + .of_match_table = mdss_dt_match, + .pm = &mdss_pm_ops, + }, +}; +
Quoted 8 lines
drivers/gpu/drm/msm/msm_mdss.c struct msm_mdss *msm_mdss_init(struct platform_device *pdev, bool mdp5) · line 435
Quoted 3 lines
drivers/gpu/drm/msm/msm_mdss.c +3
-0+void __init msm_mdss_register (void ) +{ +platform_driver_register (&mdss_platform_driver);I'd like to go a step further and not even compile drivers in that we don't use. Can we get some Kconfigs for these new drivers so that the number of drivers registered with the system is reduced and memory is conserved?
Sure. I'll add them, but in the separate commit, if you don't mind.
Signature · 2 lines
With best wishes Dmitry
PATCH v2 4/4 drm/msm: stop using device's match data pointer
In reply to Dmitry BaryshkovLet's make the match's data pointer a (sub-)driver's private data. The only user currently is the msm_drm_init() function, using this data to select kms_init callback. Pass this callback through the driver's private data instead.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 10 ++++--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 14 +++++---- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 11 ++++--- drivers/gpu/drm/msm/msm_drv.c | 38 ++++++------------------ drivers/gpu/drm/msm/msm_drv.h | 5 +--- drivers/gpu/drm/msm/msm_kms.h | 4 --- drivers/gpu/drm/msm/msm_mdss.c | 23 +++++++------- 7 files changed, 41 insertions(+), 64 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +6 -4
@@ -1175,7 +1175,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)return rc; } -struct msm_kms *dpu_kms_init (struct drm_device *dev) +static int dpu_kms_init (struct drm_device *dev) {struct msm_drm_private *priv;struct dpu_kms *dpu_kms;
@@ -1183,7 +1183,7 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev)if (!dev) {DPU_ERROR ("drm device node invalid\n" ); -return ERR_PTR (-EINVAL ); +return -EINVAL ; } priv = dev->dev_private;
@@ -1192,11 +1192,11 @@ struct msm_kms *dpu_kms_init(struct drm_device *dev) irq =irq_of_parse_and_map (dpu_kms->pdev->dev.of_node,0 );if (irq <0 ) {DPU_ERROR ("failed to get irq: %d\n" , irq); -return ERR_PTR (irq); +return irq; } dpu_kms->base.irq = irq; -return &dpu_kms->base; +return 0 ; }static int dpu_bind (struct device *dev,struct device *master,void *data)
@@ -1207,6 +1207,8 @@ static int dpu_bind(struct device *dev, struct device *master, void *data)struct dpu_kms *dpu_kms;int ret =0 ; + priv->kms_init = dpu_kms_init; + dpu_kms =devm_kzalloc (&pdev->dev,sizeof (*dpu_kms),GFP_KERNEL );if (!dpu_kms)return -ENOMEM ;
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +8 -6
@@ -389,7 +389,7 @@ static void read_mdp_hw_revision(struct mdp4_kms *mdp4_kms,DRM_DEV_INFO (dev->dev,"MDP4 version v%d.%d" , *major, *minor); } -struct msm_kms *mdp4_kms_init (struct drm_device *dev) +static int mdp4_kms_init (struct drm_device *dev) {struct platform_device *pdev =to_platform_device (dev->dev);struct mdp4_platform_config *config =mdp4_get_config (pdev);
@@ -403,8 +403,7 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) mdp4_kms =kzalloc (sizeof (*mdp4_kms),GFP_KERNEL );if (!mdp4_kms) {DRM_DEV_ERROR (dev->dev,"failed to allocate kms\n" ); - ret = -ENOMEM ; - goto fail; +return -ENOMEM ; } ret =mdp_kms_init (&mdp4_kms->base, &kms_funcs);
@@ -551,12 +550,13 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) dev->mode_config.max_width =2048 ; dev->mode_config.max_height =2048 ; -return kms; +return 0 ; fail:if (kms)mdp4_destroy (kms); -return ERR_PTR (ret); + +return ret; }static struct mdp4_platform_config *mdp4_get_config (struct platform_device *dev)
@@ -583,6 +583,8 @@ static int mdp4_probe(struct platform_device *pdev)if (!priv)return -ENOMEM ; + priv->kms_init = mdp4_kms_init; +platform_set_drvdata (pdev, priv);/*
@@ -600,7 +602,7 @@ static int mdp4_remove(struct platform_device *pdev) }static const struct of_device_id mdp4_dt_match[] = { - { .compatible ="qcom,mdp4" , .data = (void *)KMS_MDP4 }, + { .compatible ="qcom,mdp4" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, mdp4_dt_match);
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +7 -4
@@ -551,7 +551,7 @@ static int get_clk(struct platform_device *pdev, struct clk **clkp,return 0 ; } -struct msm_kms *mdp5_kms_init (struct drm_device *dev) +static int mdp5_kms_init (struct drm_device *dev) {struct msm_drm_private *priv = dev->dev_private;struct platform_device *pdev;
@@ -565,7 +565,7 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)/* priv->kms would have been populated by the MDP5 driver */ kms = priv->kms;if (!kms) -return NULL ; +return -ENOMEM ; mdp5_kms =to_mdp5_kms (to_mdp_kms (kms)); pdev = mdp5_kms->pdev;
@@ -644,11 +644,12 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) dev->max_vblank_count =0 ;/* max_vblank_count is set on each CRTC */ dev->vblank_disable_immediate = true; -return kms; +return 0 ; fail:if (kms)mdp5_kms_destroy (kms); -return ERR_PTR (ret); + +return ret; }static void mdp5_destroy (struct platform_device *pdev)
@@ -810,6 +811,8 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)u32 major, minor;int ret; + priv->kms_init = mdp5_kms_init; + mdp5_kms =devm_kzalloc (&pdev->dev,sizeof (*mdp5_kms),GFP_KERNEL );if (!mdp5_kms) { ret = -ENOMEM ;
drivers/gpu/drm/msm/msm_drv.c +9 -29
@@ -256,13 +256,6 @@ static int msm_drm_uninit(struct device *dev)return 0 ; } -static int get_mdp_ver (struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; - -return (int ) (unsigned long )of_device_get_match_data (dev); -} -#include <linux/of_address.h> bool msm_use_mmu (struct drm_device *dev)
@@ -349,7 +342,6 @@ static int msm_init_vram(struct drm_device *dev)static int msm_drm_init (struct device *dev,const struct drm_driver *drv) { -struct platform_device *pdev =to_platform_device (dev);struct msm_drm_private *priv =dev_get_drvdata (dev);struct drm_device *ddev;struct msm_kms *kms;
@@ -397,30 +389,18 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)msm_gem_shrinker_init (ddev); -switch (get_mdp_ver (pdev)) { -case KMS_MDP4 : - kms =mdp4_kms_init (ddev); - priv->kms = kms; -break ; -case KMS_MDP5 : - kms =mdp5_kms_init (ddev); -break ; -case KMS_DPU : - kms =dpu_kms_init (ddev); - priv->kms = kms; -break ; -default : +if (priv->kms_init) { + ret = priv->kms_init (ddev); +if (ret) { +DRM_DEV_ERROR (dev,"failed to load kms\n" ); + priv->kms =NULL ; + goto err_msm_uninit; + } + kms = priv->kms; + }else {/* valid only for the dummy headless case, where of_node=NULL */ WARN_ON (dev->of_node); kms =NULL ; -break ; - } - -if (IS_ERR (kms)) { -DRM_DEV_ERROR (dev,"failed to load kms\n" ); - ret =PTR_ERR (kms); - priv->kms =NULL ; - goto err_msm_uninit; }/* Enable normalization of plane zpos */
drivers/gpu/drm/msm/msm_drv.h +1 -4
@@ -139,6 +139,7 @@ struct msm_drm_private {struct drm_device *dev;struct msm_kms *kms; +int (*kms_init)(struct drm_device *dev);/* subordinate devices, if present: */ struct platform_device *gpu_pdev;
@@ -451,10 +452,6 @@ static inline void msm_dp_debugfs_init(struct msm_dp *dp_display,#endif -#define KMS_MDP4 4 -#define KMS_MDP5 5 -#define KMS_DPU 3 -void __init msm_mdp4_register (void ); void __exit msm_mdp4_unregister(void);void __init msm_mdp_register (void );
drivers/gpu/drm/msm/msm_kms.h +0 -4
@@ -194,10 +194,6 @@ static inline void msm_kms_destroy(struct msm_kms *kms)msm_atomic_destroy_pending_timer (&kms->pending_timers[i]); } -struct msm_kms *mdp4_kms_init (struct drm_device *dev); -struct msm_kms *mdp5_kms_init (struct drm_device *dev); -struct msm_kms *dpu_kms_init (struct drm_device *dev); -extern const struct of_device_id dpu_dt_match[];extern const struct of_device_id mdp5_dt_match[];
drivers/gpu/drm/msm/msm_mdss.c +10 -13
@@ -314,11 +314,11 @@ static const struct dev_pm_ops mdss_pm_ops = { .complete = msm_pm_complete, }; -static int get_mdp_ver (struct platform_device *pdev) +static bool get_is_mdp5 (struct platform_device *pdev) {struct device *dev = &pdev->dev; -return (int ) (unsigned long )of_device_get_match_data (dev); +return (bool ) (unsigned long )of_device_get_match_data (dev); }static int find_mdp_node (struct device *dev,void *data)
@@ -331,21 +331,18 @@ static int mdss_probe(struct platform_device *pdev) {struct msm_mdss *mdss;struct msm_drm_private *priv; -int mdp_ver =get_mdp_ver (pdev); +bool is_mdp5 =get_is_mdp5 (pdev);struct device *mdp_dev;struct device *dev = &pdev->dev;int ret; -if (mdp_ver !=KMS_MDP5 && mdp_ver !=KMS_DPU ) -return -EINVAL ; - priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ;platform_set_drvdata (pdev, priv); - mdss =msm_mdss_init (pdev, mdp_ver ==KMS_MDP5 ); + mdss =msm_mdss_init (pdev, is_mdp5);if (IS_ERR (mdss)) { ret =PTR_ERR (mdss);platform_set_drvdata (pdev,NULL );
@@ -409,12 +406,12 @@ static int mdss_remove(struct platform_device *pdev) }static const struct of_device_id mdss_dt_match[] = { - { .compatible ="qcom,mdss" , .data = (void *)KMS_MDP5 }, - { .compatible ="qcom,sdm845-mdss" , .data = (void *)KMS_DPU }, - { .compatible ="qcom,sc7180-mdss" , .data = (void *)KMS_DPU }, - { .compatible ="qcom,sc7280-mdss" , .data = (void *)KMS_DPU }, - { .compatible ="qcom,sm8150-mdss" , .data = (void *)KMS_DPU }, - { .compatible ="qcom,sm8250-mdss" , .data = (void *)KMS_DPU }, + { .compatible ="qcom,mdss" , .data = (void *)true }, + { .compatible ="qcom,sdm845-mdss" , .data = (void *)false }, + { .compatible ="qcom,sc7180-mdss" , .data = (void *)false }, + { .compatible ="qcom,sc7280-mdss" , .data = (void *)false }, + { .compatible ="qcom,sm8150-mdss" , .data = (void *)false }, + { .compatible ="qcom,sm8250-mdss" , .data = (void *)false }, {} };MODULE_DEVICE_TABLE (of, dt_match);
Signature · 1 line
2.34.1
Re: [PATCH v2 4/4] drm/msm: stop using device's match data pointer
Quoting Dmitry Baryshkov (2022-01-19 14:40:05)
Quoted 19 lines
drivers/gpu/drm/msm/msm_mdss.c +2
-2@@ -314,11 +314,11 @@ static const struct dev_pm_ops mdss_pm_ops = { .complete = msm_pm_complete, }; -static int get_mdp_ver (struct platform_device *pdev) +static bool get_is_mdp5 (struct platform_device *pdev) {struct device *dev = &pdev->dev; -return (int ) (unsigned long )of_device_get_match_data (dev); +return (bool ) (unsigned long )of_device_get_match_data (dev); }static int find_mdp_node (struct device *dev,void *data)
drivers/gpu/drm/msm/msm_mdss.c static int mdss_probe(struct platform_device *pdev) · line 334
Quoted 5 lines
drivers/gpu/drm/msm/msm_mdss.c +1
-1@@ -331,21 +331,18 @@ static int mdss_probe(struct platform_device *pdev) {struct msm_mdss *mdss;struct msm_drm_private *priv; -int mdp_ver =get_mdp_ver (pdev); +bool is_mdp5 =get_is_mdp5 (pdev);
is_mdp5 = of_device_is_compatible(pdev->dev.of_node, "qcom,mdss");
Quoted 24 lines
drivers/gpu/drm/msm/msm_mdss.c +1
-6struct device *mdp_dev;struct device *dev = &pdev->dev;int ret; -if (mdp_ver !=KMS_MDP5 && mdp_ver !=KMS_DPU ) -return -EINVAL ; - priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ;platform_set_drvdata (pdev, priv); - mdss =msm_mdss_init (pdev, mdp_ver ==KMS_MDP5 ); + mdss =msm_mdss_init (pdev, is_mdp5);if (IS_ERR (mdss)) { ret =PTR_ERR (mdss);platform_set_drvdata (pdev,NULL );@@ -409,12 +406,12 @@ static int mdss_remove(struct platform_device *pdev) }static const struct of_device_id mdss_dt_match[] = { - { .compatible ="qcom,mdss" , .data = (void *)KMS_MDP5 }, - { .compatible ="qcom,sdm845-mdss" , .data = (void *)KMS_DPU },
drivers/gpu/drm/msm/msm_mdss.c static int mdss_remove(struct platform_device *pdev) · line 414
Quoted 10 lines
drivers/gpu/drm/msm/msm_mdss.c +6
-4- { .compatible = "qcom,sc7180-mdss", .data = (void *)KMS_DPU }, - { .compatible = "qcom,sc7280-mdss", .data = (void *)KMS_DPU }, - { .compatible = "qcom,sm8150-mdss", .data = (void *)KMS_DPU }, - { .compatible = "qcom,sm8250-mdss", .data = (void *)KMS_DPU }, + { .compatible = "qcom,mdss", .data = (void *)true }, + { .compatible = "qcom,sdm845-mdss", .data = (void *)false }, + { .compatible = "qcom,sc7180-mdss", .data = (void *)false }, + { .compatible = "qcom,sc7280-mdss", .data = (void *)false }, + { .compatible = "qcom,sm8150-mdss", .data = (void *)false }, + { .compatible = "qcom,sm8250-mdss", .data = (void *)false },
And then no data needed?