From: Rob Clark <robin.clark@oss.qualcomm.com>
To: dri-devel@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
Rob Clark <robin.clark@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Sean Paul <sean@poorly.run>,
Marijn Suijten <marijn.suijten@somainline.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Mahadevan P <mahadevan.p@oss.qualcomm.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [RFT PATCH] drm/msm: Fix separate_gpu_kms for multi-gpu
Date: Wed, 2 Dec 2026 10:34:12 -0800 [thread overview]
Message-ID: <20261202183415.22149-1-robin.clark@oss.qualcomm.com> (raw)
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 <robin.clark@oss.qualcomm.com>
---
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
next reply other threads:[~2026-12-02 18:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 18:34 Rob Clark [this message]
2026-12-02 18:43 ` Rob Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202183415.22149-1-robin.clark@oss.qualcomm.com \
--to=robin.clark@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=lumag@kernel.org \
--cc=mahadevan.p@oss.qualcomm.com \
--cc=marijn.suijten@somainline.org \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®