The default of auto-pick was not handling the case of multiple GPU devices. Handle this by matching GPU and DPU devices, so if a SoC has an equal # of display and GPU devices, they get paired up one- by-one.
Signed-off-by: Rob Clark <[email protected]> --- I don't have such a device at hand. But this at least works when there is a single GPU+DPU. I'd appreciate if someone could test this on such a device. drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 7 ++++-- drivers/gpu/drm/msm/msm_drv.c | 28 ++++++++++++++++++------ drivers/gpu/drm/msm/msm_drv.h | 8 +++---- drivers/gpu/drm/msm/msm_mdss.c | 7 ++++-- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c index ad08a040982f..e3d27e0020a0 100644 --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c @@ -16,14 +16,17 @@ #include "mdp4_kms.h" static const struct of_device_id mdp4_dt_match[]; -int msm_count_mdp4(void) +int msm_count_mdp4(struct device_node *target_np) { struct device_node *np; int count = 0; for_each_matching_node(np, mdp4_dt_match) { - if (of_device_is_available(np)) + if (of_device_is_available(np)) { count++; + if (target_np == np) + return count; + } } return count; diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index cd59daa02bf9..49bac1ec64db 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -98,14 +98,17 @@ static inline bool msm_gpu_node_present(struct device_node *np) return np && of_device_is_available(np) && adreno_has_gpu(np); } -static int msm_count_gpus(void) +static int msm_count_gpus(struct device_node *target_np) { struct device_node *np; int count = 0; for_each_matching_node(np, msm_gpu_match) { - if (msm_gpu_node_present(np)) + if (msm_gpu_node_present(np)) { count++; + if (target_np == np) + return count; + } } return count; @@ -113,11 +116,10 @@ static int msm_count_gpus(void) static bool msm_separate_gpu_kms_auto(void) { - int gpus = msm_count_gpus(); - int display_subsystems = msm_count_mdss() + msm_count_mdp4(); + int gpus = msm_count_gpus(NULL); + int display_subsystems = msm_count_mdss(NULL) + msm_count_mdp4(NULL); - /* Single card if there is exactly one GPU and one display subsystem */ - if (gpus == 1 && display_subsystems == 1) + if (gpus != display_subsystems) return false; return true; @@ -125,7 +127,7 @@ static bool msm_separate_gpu_kms_auto(void) bool msm_separate_gpu_kms_components(void) { - if (msm_count_gpus() == 0) + if (msm_count_gpus(NULL) == 0) return true; switch (separate_gpu_kms) { @@ -1105,6 +1107,18 @@ static int add_gpu_components(struct device *dev, if (!np || !msm_gpu_node_present(np)) return 0; + unsigned disp_idx = msm_count_mdss(dev->of_node) + msm_count_mdp4(dev->of_node); + unsigned gpu_idx = msm_count_gpus(gpu_np); + + pr_err("disp_idx=%u, gpu_idx=%u\n", disp_idx, gpu_idx); + + /* + * If we have multiple GPUs, we should match the N'th GPU with the + * N'th DPU. + */ + if (disp_idx && (disp_idx != gpu_idx)) + return 0; + drm_of_component_match_add(dev, matchptr, component_compare_of, np); struct device_node *gmu_np __free(device_node) = of_parse_phandle(np, "qcom,gmu", 0); diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index b65702ac0140..63d9ded69bb7 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -394,11 +394,11 @@ static inline bool msm_dp_wide_bus_available(const struct msm_dp *dp_display) #ifdef CONFIG_DRM_MSM_MDP4 void msm_mdp4_register(void); void msm_mdp4_unregister(void); -int msm_count_mdp4(void); +int msm_count_mdp4(struct device_node *target_np); #else static inline void msm_mdp4_register(void) {} static inline void msm_mdp4_unregister(void) {} -static inline int msm_count_mdp4(void) { return 0; } +static inline int msm_count_mdp4(struct device_node *target_np) { return 0; } #endif #ifdef CONFIG_DRM_MSM_MDP5 @@ -420,11 +420,11 @@ static inline void msm_dpu_unregister(void) {} #ifdef CONFIG_DRM_MSM_MDSS void msm_mdss_register(void); void msm_mdss_unregister(void); -int msm_count_mdss(void); +int msm_count_mdss(struct device_node *target_np); #else static inline void msm_mdss_register(void) {} static inline void msm_mdss_unregister(void) {} -static inline int msm_count_mdss(void) { return 0; } +static inline int msm_count_mdss(struct device_node *target_np) { return 0; } #endif #ifdef CONFIG_DEBUG_FS diff --git a/drivers/gpu/drm/msm/msm_mdss.c b/drivers/gpu/drm/msm/msm_mdss.c index fb0261ae9c78..a320345a5736 100644 --- a/drivers/gpu/drm/msm/msm_mdss.c +++ b/drivers/gpu/drm/msm/msm_mdss.c @@ -77,14 +77,17 @@ static int msm_mdss_parse_data_bus_icc_path(struct device *dev, static const struct of_device_id mdss_dt_match[]; -int msm_count_mdss(void) +int msm_count_mdss(struct device_node *target_np) { struct device_node *np; int count = 0; for_each_matching_node(np, mdss_dt_match) { - if (of_device_is_available(np)) + if (of_device_is_available(np)) { count++; + if (target_np == np) + return count; + } } return count; -- 2.56.1
