Skip to contentSkip to conversation

drm/msm: default separate_gpu_kms to auto selection

PATCH Applied Mahadevan P 3 participants 3 messages Sep 28 – Oct 6

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 drm/msm: default separate_gpu_kms to auto selection

On platforms with multiple display subsystems, such as SA8775P, the GPU binds to the first display subsystem that probes. This implicit binding prevents subsequent display subsystems from probing successfully, breaking multi-display support.

Use the tristate separate_gpu_kms module parameter with the default value set to auto (-1). In auto mode, the driver selects the binding behavior based on the number of GPUs and display subsystems. This allows display subsystems to probe independently when required, while preserving the existing single-card behavior on simpler systems.

The separate_gpu_kms module parameter has the following semantics:

-1 (auto, default):
Select the binding mode based on hardware topology. If exactly one GPU and one display subsystem are present, bind them together to form a single DRM device. Otherwise, expose the GPU and display subsystems as separate DRM devices.

0:
Always bind the GPU and display together to form a single DRM device.

1:
Always expose the GPU and display subsystems as separate DRM devices.

Additionally, ensure that display subsystems are always exposed as separate DRM devices when no recognized Adreno GPU is present, regardless of the separate_gpu_kms setting.

This ensures correct probing on multi-display platforms without affecting single-display, single-GPU systems.

---
Changes in v4:
- Fix OF node refcount leak in msm_separate_gpu_kms_components(). (sashiko-bot)
- Fix build errors when MDSS/MDP4 are disabled by adding stubs. (kernel test robot)
- Drop msm_count_mdp5(); MDP5 always sits under a qcom,mdss node, so it was
counted twice.
- adreno_probe(): don't create a standalone GPU device for an unrecognized
GPU.
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- Ensure display subsystems are always exposed as separate DRM devices when
no recognized Adreno GPU is present (!adreno_has_gpu()), regardless of separate_gpu_kms setting. (Dmitry)
- Extend auto-selection logic to account for legacy display controllers (MDP4 and MDP5). (Dmitry)
- Rename msm_mdss_count_masters() to msm_mdss_count() to better reflect functionality. (Dmitry)
- Common helper to determine presence of a valid Adreno GPU node, avoiding repeated adreno_has_gpu() and availability checks.
- Update commit message to reflect the above behavior.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Drop dependency on Lemans dual-DPU device tree changes as this patch
works independently (Dmitry)
- Switch separate_gpu_kms to tristate and default to auto mode (Rob)
- Rename msm_gpu_no_components() to msm_separate_gpu_kms_components() for clarity
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/gpu/drm/msm/adreno/adreno_device.c |  6 ++-
 drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c   | 14 +++++++
 drivers/gpu/drm/msm/msm_drv.c              | 65 ++++++++++++++++++++++++++----
 drivers/gpu/drm/msm/msm_drv.h              |  6 ++-
 drivers/gpu/drm/msm/msm_mdss.c             | 15 +++++++
 5 files changed, 95 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +4 -2
index 05c77fe27e62..7108d4aa59b5 100644
@@ -271,8 +271,10 @@ static const struct component_ops a3xx_ops = {
 
 static int adreno_probe(struct platform_device *pdev)
 {
-	if (of_device_is_compatible(pdev->dev.of_node, "amd,imageon") ||
-	    msm_gpu_no_components())
+	struct device_node *node = pdev->dev.of_node;
+
+	if (of_device_is_compatible(node, "amd,imageon") ||
+	    (msm_separate_gpu_kms_components() && adreno_has_gpu(node)))
 		return msm_gpu_probe(pdev, &a3xx_ops);
 
 	return component_add(&pdev->dev, &a3xx_ops);
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +14 -0
index 9b1d1982e683..c299fef1a400 100644
@@ -15,6 +15,20 @@
 #include "msm_mmu.h"
 #include "mdp4_kms.h"
 
+static const struct of_device_id mdp4_dt_match[];
+int msm_count_mdp4(void)
+{
+	struct device_node *np;
+	int count = 0;
+
+	for_each_matching_node(np, mdp4_dt_match) {
+		if (of_device_is_available(np))
+			count++;
+	}
+
+	return count;
+}
+
 static int mdp4_hw_init(struct msm_kms *kms)
 {
 	struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
drivers/gpu/drm/msm/msm_drv.c +57 -8

94 lines not on this page · raw message

drivers/gpu/drm/msm/msm_drv.h +5 -1
index eb4bbae8557b..2840e8a5052d 100644
@@ -394,9 +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);
 #else
 static inline void msm_mdp4_register(void) {}
 static inline void msm_mdp4_unregister(void) {}
+static inline int msm_count_mdp4(void) { return 0; }
 #endif
 
 #ifdef CONFIG_DRM_MSM_MDP5
@@ -418,9 +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);
 #else
 static inline void msm_mdss_register(void) {}
 static inline void msm_mdss_unregister(void) {}
+static inline int msm_count_mdss(void) { return 0; }
 #endif
 
 #ifdef CONFIG_DEBUG_FS
@@ -534,6 +538,6 @@ void msm_kms_shutdown(struct platform_device *pdev);
 
 bool msm_disp_drv_should_bind(struct device *dev, bool dpu_driver);
 
-bool msm_gpu_no_components(void);
+bool msm_separate_gpu_kms_components(void);
 
 #endif /* __MSM_DRV_H__ */
drivers/gpu/drm/msm/msm_mdss.c +15 -0
index 9087c4b290db..e69b122f2687 100644
@@ -73,6 +73,21 @@ static int msm_mdss_parse_data_bus_icc_path(struct device *dev,
 	return 0;
 }
 
+static const struct of_device_id mdss_dt_match[];
+
+int msm_count_mdss(void)
+{
+	struct device_node *np;
+	int count = 0;
+
+	for_each_matching_node(np, mdss_dt_match) {
+		if (of_device_is_available(np))
+			count++;
+	}
+
+	return count;
+}
+
 static void msm_mdss_irq(struct irq_desc *desc)
 {
 	struct msm_mdss *msm_mdss = irq_desc_get_handler_data(desc);

---
base-commit: 3f2425f5b5bbbdd991ca9cdfd5502e68d8895998
change-id: 20260316-separate_gpu_kms-04d2cf4d91e2

Best regards,

Signature · 1 line
Mahadevan P <[email protected]>
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] drm/msm: headless topologies incorrectly default to bound DRM device - [Medium] drm/msm: repeated…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm/msm: headless topologies incorrectly default to bound DRM device
- [Medium] drm/msm: repeated unknown GPU revision warnings during boot
--

commit 5b897e6c5890fde498e8d0fce3fbe51de1f1b4fc
Author: Mahadevan P <[email protected]>

drm/msm: default separate_gpu_kms to auto selection

On platforms with multiple display subsystems, such as SA8775P, the GPU binds to the first display subsystem that probes. This implicit binding prevents subsequent display subsystems from probing successfully, breaking multi-display support.

Quoted 4 lines
drivers/gpu/drm/msm/msm_drv.c +0 -0
index f3d2eaa04f142..2ac7fcd468d3b 100644

[ ... ]

drivers/gpu/drm/msm/msm_drv.c static bool modeset = true; · line 85

Quoted 9 lines
drivers/gpu/drm/msm/msm_drv.c +7 -1
+static int msm_count_gpus(void)
 {
-	return separate_gpu_kms;
+	struct device_node *np;
+	int count = 0;
+
+	for_each_matching_node(np, msm_gpu_match) {
+		if (msm_gpu_node_present(np))
+			count++;

[Severity: Medium]
Does this code cause repeated warnings on boot for unsupported hardware?

msm_gpu_node_present() calls adreno_has_gpu(), which prints a warning for unknown GPU revisions. Because msm_separate_gpu_kms_components() calls msm_count_gpus() multiple times during component probing (e.g., in adreno_probe(), msm_drv_probe(), msm_drm_bind()), the side-effecting adreno_has_gpu() will be evaluated several times per boot.

drivers/gpu/drm/msm/msm_drv.c static bool modeset = true; · line 97

Quoted 12 lines
drivers/gpu/drm/msm/msm_drv.c +12 -0
+	}
+
+	return count;
+}
+
+static bool msm_separate_gpu_kms_auto(void)
+{
+	int gpus = msm_count_gpus();
+	int display_subsystems = msm_count_mdss() + msm_count_mdp4();
+
+	if (gpus <= 0 || display_subsystems <= 0)
+		return false;

[Severity: High]
Does this force headless platforms (with 0 display subsystems) to use component binding?

If display_subsystems <= 0, the function returns false. This causes msm_separate_gpu_kms_components() to return false, directing adreno_probe() to call component_add() instead of msm_gpu_probe(). Without a display master to complete the component binding, won't the GPU remain indefinitely unbound on compute-only platforms when using the default auto configuration?

Quoted 4 lines
drivers/gpu/drm/msm/msm_drv.c +4 -0
+
+	/* Single card if there is exactly one GPU and one display subsystem */
+	return gpus > 1 || display_subsystems > 1;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Mahadevan P
Quoted 5 lines · Mahadevan P

On platforms with multiple display subsystems, such as SA8775P, the GPU binds to the first display subsystem that probes. This implicit binding prevents subsequent display subsystems from probing successfully, breaking multi-display support.

Quoted 7 lines

Use the tristate separate_gpu_kms module parameter with the default value set to auto (-1). In auto mode, the driver selects the binding behavior based on the number of GPUs and display subsystems. This allows display subsystems to probe independently when required, while preserving the existing single-card behavior on simpler systems.

[...]

Applied to msm-next, thanks!

[1/1] drm/msm: default separate_gpu_kms to auto selection
https://gitlab.freedesktop.org/lumag/msm/-/commit/cf27afc3bd6e

Best regards,

Signature · 2 lines
With best wishes
Dmitry