[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <951f781a-d823-4240-a1c8-b9ea85ba64e0@oss.qualcomm.com>
Date: Mon, 9 Jun 2025 20:37:31 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
To: Rob Clark <robin.clark@....qualcomm.com>, dri-devel@...ts.freedesktop.org
Cc: linux-arm-msm@...r.kernel.org, freedreno@...ts.freedesktop.org,
Rob Clark <robdclark@...il.com>, Sean Paul <sean@...rly.run>,
Konrad Dybcio <konradybcio@...nel.org>,
Abhinav Kumar <quic_abhinavk@...cinc.com>,
Dmitry Baryshkov <lumag@...nel.org>,
Marijn Suijten <marijn.suijten@...ainline.org>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] drm/msm/adreno: Check for recognized GPU before bind
On 09/06/2025 20:04, Rob Clark wrote:
> If we have a newer dtb than kernel, we could end up in a situation where
> the GPU device is present in the dtb, but not in the drivers device
> table. We don't want this to prevent the display from probing. So
> check that we recognize the GPU before adding the GPU component.
>
> Signed-off-by: Rob Clark <robin.clark@....qualcomm.com>
> ---
> drivers/gpu/drm/msm/adreno/adreno_device.c | 29 ++++++++++++++++++----
> drivers/gpu/drm/msm/msm_drv.c | 2 +-
> drivers/gpu/drm/msm/msm_gpu.h | 1 +
> 3 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
> index 504174dbe6d6..002aaf365322 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_device.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
> @@ -178,6 +178,26 @@ static int find_chipid(struct device_node *node, uint32_t *chipid)
> return 0;
> }
>
> +bool adreno_has_gpu(struct device_node *node)
> +{
> + const struct adreno_info *info;
> + uint32_t chip_id;
> + int ret;
> +
> + ret = find_chipid(node, &chip_id);
> + if (ret)
> + return false;
> +
> + info = adreno_info(chip_id);
> + if (!info) {
> + pr_warn("%s: Unknown GPU revision: %"ADRENO_CHIPID_FMT"\n",
Please use %pOFf instead of %s (and node instead of node->full_name).
Other than that, LGTM.
> + node->full_name, ADRENO_CHIPID_ARGS(chip_id));
> + return false;
> + }
> +
> + return true;
> +}
> +
> static int adreno_bind(struct device *dev, struct device *master, void *data)
> {
> static struct adreno_platform_config config = {};
> @@ -188,18 +208,17 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
> int ret;
>
> ret = find_chipid(dev->of_node, &config.chip_id);
> - if (ret)
> + /* We shouldn't have gotten this far if we can't parse the chip_id */
> + if (WARN_ON(ret))
> return ret;
>
> dev->platform_data = &config;
> priv->gpu_pdev = to_platform_device(dev);
>
> info = adreno_info(config.chip_id);
> - if (!info) {
> - dev_warn(drm->dev, "Unknown GPU revision: %"ADRENO_CHIPID_FMT"\n",
> - ADRENO_CHIPID_ARGS(config.chip_id));
> + /* We shouldn't have gotten this far if we don't recognize the GPU: */
> + if (!WARN_ON(info))
> return -ENXIO;
> - }
>
> config.info = info;
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 87ee9839ca4a..40eb04bab35e 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -956,7 +956,7 @@ static int add_gpu_components(struct device *dev,
> if (!np)
> return 0;
>
> - if (of_device_is_available(np))
> + if (of_device_is_available(np) && adreno_has_gpu(np))
> drm_of_component_match_add(dev, matchptr, component_compare_of, np);
>
> of_node_put(np);
> diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
> index 5508885d865f..56bd1a646b83 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.h
> +++ b/drivers/gpu/drm/msm/msm_gpu.h
> @@ -729,6 +729,7 @@ msm_gpu_create_private_vm(struct msm_gpu *gpu, struct task_struct *task,
> void msm_gpu_cleanup(struct msm_gpu *gpu);
>
> struct msm_gpu *adreno_load_gpu(struct drm_device *dev);
> +bool adreno_has_gpu(struct device_node *node);
> void __init adreno_register(void);
> void __exit adreno_unregister(void);
>
--
With best wishes
Dmitry
Powered by blists - more mailing lists