From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0297606A697 for ; Wed, 2 Dec 2026 18:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gx/G7Ggg Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6197610EADA; Wed, 2 Dec 2026 18:46:06 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B594C10EADA for ; Wed, 2 Dec 2026 18:45:59 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 5FC5F43875; Wed, 2 Dec 2026 18:45:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 343A11F00893; Wed, 2 Dec 2026 18:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796237159; bh=xndd972A9FHuJh7V738eGFRW6iTLMOFgHH+zDH4I/bM=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=gx/G7GggdVhdpi4ZCcGECWIZlSrVi2iNNMZ7/agY8H269aaubSUKJtUbvMZw5vNcv QOfCKPsMwMkYZGvhrrcybVE1ZqqREWmypKyYkm7Mjn9OEWxnqTwJp5r5JUnxV4aIux GaFXcJ6SrTrbtr1EA/7E919PFnlScrM8sMibrVjy/K63ZRyjZFdHgf37LEUfwF5hMw 2Cr6f8j2k3KZydtfg73hgnd8wJI/E7ADNPUdbOl40u3HRTM17tCu7jFxJx6JNz7VLd F4aLuIbY0WS22AyS0LPM6PKzps5bsX/yrH85Gj7Er61NJXyvXuVVdZy2wtUujlPqgS U8ELGo6a37+3g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RFT PATCH] drm/msm: Fix separate_gpu_kms for multi-gpu To: "Rob Clark" , dri-devel@lists.freedesktop.org In-Reply-To: <20261202183415.22149-1-robin.clark@oss.qualcomm.com> References: <20261202183415.22149-1-robin.clark@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 18:45:58 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] drm/msm: inverted boolean return value in msm_separate_gpu_kms_auto() - [High] drm/msm: unmatched target_np returns total count in msm_count_*() - [High] drm/msm: add_gpu_components() passes NULL gpu_np and checks only first GPU - [Medium] drm/msm: device_node refcount leak on early return in msm_count_*() - [Low] drm/msm: leftover pr_err() debug print in add_gpu_components() -- commit 26bd8b0728ea32f5eae5c7537ac1e3cf8ad995f9 Author: Rob Clark drm/msm: Fix separate_gpu_kms for multi-gpu This commit updates separate_gpu_kms auto-selection and GPU component matching to pair GPU and display devices by index when a system has an equal number of GPUs and display subsystems. > diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/m= sm/disp/mdp4/mdp4_kms.c > index ad08a040982fa..e3d27e0020a01 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" > =20 > 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 =3D 0; > =20 > for_each_matching_node(np, mdp4_dt_match) { > - if (of_device_is_available(np)) > + if (of_device_is_available(np)) { > count++; > + if (target_np =3D=3D np) > + return count; > + } > } > =20 > return count; [Severity: Medium] Does returning directly from inside for_each_matching_node() leak the reference on np? for_each_matching_node() holds a reference on the loop cursor until the next iteration, so early returns in msm_count_mdp4(), msm_count_gpus(), and msm_count_mdss() need of_node_put(np). > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c > index cd59daa02bf94..49bac1ec64db9 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); > } > =20 > -static int msm_count_gpus(void) > +static int msm_count_gpus(struct device_node *target_np) > { > struct device_node *np; > int count =3D 0; > =20 > for_each_matching_node(np, msm_gpu_match) { > - if (msm_gpu_node_present(np)) > + if (msm_gpu_node_present(np)) { > count++; > + if (target_np =3D=3D np) > + return count; > + } > } > =20 > return count; > @@ -113,11 +116,10 @@ static int msm_count_gpus(void) > =20 > static bool msm_separate_gpu_kms_auto(void) > { > - int gpus =3D msm_count_gpus(); > - int display_subsystems =3D msm_count_mdss() + msm_count_mdp4(); > + int gpus =3D msm_count_gpus(NULL); > + int display_subsystems =3D msm_count_mdss(NULL) + msm_count_mdp4(NULL); > =20 > - /* Single card if there is exactly one GPU and one display subsystem */ > - if (gpus =3D=3D 1 && display_subsystems =3D=3D 1) > + if (gpus !=3D display_subsystems) > return false; > =20 > return true; [Severity: High] Is the boolean return value of msm_separate_gpu_kms_auto() inverted here? In msm_separate_gpu_kms_components(), returning true means separate GPU and KMS DRM devices (matching separate_gpu_kms =3D=3D 1), while false means combining them into a single DRM device (matching separate_gpu_kms =3D=3D 0= ). Returning true when gpus =3D=3D display_subsystems forces separate devices = on 1-GPU + 1-display and N-GPU + N-display systems, and returning false when gpus !=3D display_subsystems attempts to combine them on asymmetric or headless systems (leaving a standalone GPU unbound when display_subsystems is 0 because adreno_probe() skips msm_gpu_probe()). > @@ -1105,6 +1107,18 @@ static int add_gpu_components(struct device *dev, > if (!np || !msm_gpu_node_present(np)) > return 0; > =20 > + unsigned disp_idx =3D msm_count_mdss(dev->of_node) + msm_count_mdp4(dev= ->of_node); [Severity: High] What happens when target_np is non-NULL but not found by msm_count_mdss(), msm_count_mdp4(), or msm_count_gpus()? When target_np does not match any entry, those helpers finish the loop and return the total count of available nodes instead of 0. In add_gpu_components(), this causes two problems: 1. When called from msm_gpu_probe() for a standalone GPU master (kms_init is NULL), dev->of_node is a GPU node, so disp_idx becomes the total number of display subsystems in the system rather than 0. If disp_idx is non-zero and disp_idx !=3D gpu_idx, add_gpu_components() returns 0 without adding anything to matchptr, and msm_drv_probe() then passes match =3D=3D N= ULL to component_master_add_with_match(), causing a NULL pointer dereference on match->num. 2. When called from dpu_dev_probe() or mdp5_dev_probe(), dev is the child DPU or MDP5 device rather than the parent MDSS device, so dev->of_node never matches mdss_dt_match in msm_count_mdss() and disp_idx always evaluates to the total MDSS count instead of the display index. > + unsigned gpu_idx =3D msm_count_gpus(gpu_np); [Severity: High] Can this pair KMS devices with GPUs when gpu_np is NULL on KMS probe paths? dpu_dev_probe(), mdp5_dev_probe(), and mdp4_probe() all pass gpu_np =3D NULL to msm_drv_probe(). In add_gpu_components(), np is then always set to the first matching GPU node via of_find_matching_node(NULL, msm_gpu_match), and msm_count_gpus(gpu_np) is called with NULL, returning the total number of GPUs rather than a specific GPU index. On a 2-GPU system, gpu_idx is always 2 during KMS probe, so display 1 skips binding a GPU and display 2 binds the first GPU node. > + > + pr_err("disp_idx=3D%u, gpu_idx=3D%u\n", disp_idx, gpu_idx); [Severity: Low] This looks like a leftover debug printk that logs at KERN_ERR on every probe. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202183415.2214= 9-1-robin.clark@oss.qualcomm.com?part=3D1