drm/msm: add a kernel param to select between MDP5 and DPU drivers
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 8 Feb 2024 15:01:10 +0000 (17:01 +0200)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Mon, 19 Feb 2024 11:39:39 +0000 (13:39 +0200)
For some of the platforms (e.g. SDM660, SDM630, MSM8996, etc.) it is
possible to support this platform via the DPU driver (e.g. to provide
support for DP, multirect, etc). Add a modparam to be able to switch
between these two drivers.

All platforms supported by both drivers are by default handled by the
MDP5 driver. To let them be handled by the DPU driver pass the
`msm.prefer_mdp5=false` kernel param.

Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Carl Vanderlip <quic_carlv@quicinc.com>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/577504/
Link: https://lore.kernel.org/r/20240208-fd-migrate-mdp5-v4-3-945d08ef3fa8@linaro.org
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_drv.h

index 0b1c238065906a0f3bd10cce85778ba0fb8625be..1c2975ea9c9cce679cd708a756d226aff41fd765 100644 (file)
@@ -1279,6 +1279,9 @@ static int dpu_dev_probe(struct platform_device *pdev)
        int irq;
        int ret = 0;
 
+       if (!msm_disp_drv_should_bind(&pdev->dev, true))
+               return -ENODEV;
+
        dpu_kms = devm_kzalloc(dev, sizeof(*dpu_kms), GFP_KERNEL);
        if (!dpu_kms)
                return -ENOMEM;
index 25279c724fe0d183abbf6d11390e4c51503225c6..e5f7052bcb87591dc17431138316a5be585a3262 100644 (file)
@@ -852,6 +852,9 @@ static int mdp5_dev_probe(struct platform_device *pdev)
 
        DBG("");
 
+       if (!msm_disp_drv_should_bind(&pdev->dev, false))
+               return -ENODEV;
+
        mdp5_kms = devm_kzalloc(&pdev->dev, sizeof(*mdp5_kms), GFP_KERNEL);
        if (!mdp5_kms)
                return -ENOMEM;
index 50b65ffc24b1cfa03856497c8c69bb89b1c0384d..f79134fc6cc0bbdffcdcfadf70cdeddf3e6627bb 100644 (file)
@@ -969,6 +969,37 @@ static int add_components_mdp(struct device *master_dev,
        return 0;
 }
 
+#if !IS_REACHABLE(CONFIG_DRM_MSM_MDP5) || !IS_REACHABLE(CONFIG_DRM_MSM_DPU)
+bool msm_disp_drv_should_bind(struct device *dev, bool dpu_driver)
+{
+       /* If just a single driver is enabled, use it no matter what */
+       return true;
+}
+#else
+
+static bool prefer_mdp5 = true;
+MODULE_PARM_DESC(prefer_mdp5, "Select whether MDP5 or DPU driver should be preferred");
+module_param(prefer_mdp5, bool, 0444);
+
+/* list all platforms supported by both mdp5 and dpu drivers */
+static const char *const msm_mdp5_dpu_migration[] = {
+       NULL,
+};
+
+bool msm_disp_drv_should_bind(struct device *dev, bool dpu_driver)
+{
+       /* If it is not an MDP5 device, do not try MDP5 driver */
+       if (!of_device_is_compatible(dev->of_node, "qcom,mdp5"))
+               return dpu_driver;
+
+       /* If it is not in the migration list, use MDP5 */
+       if (!of_device_compatible_match(dev->of_node, msm_mdp5_dpu_migration))
+               return !dpu_driver;
+
+       return prefer_mdp5 ? !dpu_driver : dpu_driver;
+}
+#endif
+
 /*
  * We don't know what's the best binding to link the gpu with the drm device.
  * Fow now, we just hunt for all the possible gpus that we support, and add them
index 01e783130054e25018072e2cf05138e4ea602ec6..762e13e2df7479f22b8276848b3017dc6be92243 100644 (file)
@@ -563,5 +563,6 @@ int msm_drv_probe(struct device *dev,
        struct msm_kms *kms);
 void msm_kms_shutdown(struct platform_device *pdev);
 
+bool msm_disp_drv_should_bind(struct device *dev, bool dpu_driver);
 
 #endif /* __MSM_DRV_H__ */