drm/msm: Better unknown GPU handling
Subsystems (4)
Rob Clark
maintainercover drm/msm: Better unknown GPU handling
Detect earlier if the GPU is supported, and skip binding the GPU sub-component if not. This way the rest of the driver can still probe and get working display if the only thing unsupported is the GPU.
Rob Clark (3):
drm/msm: Rename add_components_mdp() drm/msm/adreno: Pass device_node to find_chipid() drm/msm/adreno: Check for recognized GPU before bind
drivers/gpu/drm/msm/adreno/adreno_device.c | 39 ++++++++++++++++------ drivers/gpu/drm/msm/msm_drv.c | 6 ++-- drivers/gpu/drm/msm/msm_gpu.h | 1 + 3 files changed, 33 insertions(+), 13 deletions(-)
Signature · 1 line
2.49.0
Rob Clark
maintainerPATCH 1/3 drm/msm: Rename add_components_mdp()
To better match add_gpu_components().
--- drivers/gpu/drm/msm/msm_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +2 -2
@@ -852,7 +852,7 @@ static const struct drm_driver msm_driver = {* is no external component that we need to add since LVDS is within MDP4 * itself. */ -static int add_components_mdp (struct device *master_dev, +static int add_mdp_components (struct device *master_dev,struct component_match **matchptr) {struct device_node *np = master_dev->of_node;
@@ -997,7 +997,7 @@ int msm_drv_probe(struct device *master_dev,/* Add mdp components if we have KMS. */ if (kms_init) { - ret =add_components_mdp (master_dev, &match); + ret =add_mdp_components (master_dev, &match);if (ret)return ret; }
Signature · 1 line
2.49.0
Rob Clark
maintainerPATCH 2/3 drm/msm/adreno: Pass device_node to find_chipid()
In reply to Rob ClarkWe are going to want to re-use this before the component is bound, when we don't yet have the device pointer (but we do have the of node).
--- drivers/gpu/drm/msm/adreno/adreno_device.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +5 -5
@@ -133,9 +133,8 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)return NULL ; } -static int find_chipid (struct device *dev,uint32_t *chipid) +static int find_chipid (struct device_node *node,uint32_t *chipid) { -struct device_node *node = dev->of_node;const char *compat;int ret;
@@ -169,11 +168,12 @@ static int find_chipid(struct device *dev, uint32_t *chipid)/* and if that fails, fall back to legacy "qcom,chipid" property: */ ret =of_property_read_u32 (node,"qcom,chipid" , chipid);if (ret) { -DRM_DEV_ERROR (dev,"could not parse qcom,chipid: %d\n" , ret); +DRM_ERROR ("%s: could not parse qcom,chipid: %d\n" , + node->full_name, ret);return ret; } -dev_warn (dev,"Using legacy qcom,chipid binding!\n" ); +pr_warn ("%s: Using legacy qcom,chipid binding!\n" , node->full_name);return 0 ; }
@@ -187,7 +187,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)struct msm_gpu *gpu;int ret; - ret =find_chipid (dev, &config.chip_id); + ret =find_chipid (dev->of_node, &config.chip_id);if (ret)return ret;
Signature · 1 line
2.49.0
Rob Clark
maintainerPATCH 3/3 drm/msm/adreno: Check for recognized GPU before bind
In reply to Rob ClarkIf 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.
--- 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(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +24 -5
@@ -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" , + 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;
drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -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);
drivers/gpu/drm/msm/msm_gpu.h +1 -0
@@ -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);
Signature · 1 line
2.49.0
Re: [PATCH 3/3] drm/msm/adreno: Check for recognized GPU before bind
Quoted 23 lines · Rob Clark
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 <[email protected]>--- 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(-)drivers/gpu/drm/msm/adreno/adreno_device.c +3
-0@@ -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;
drivers/gpu/drm/msm/adreno/adreno_device.c static int find_chipid(struct device_node *node, uint32_t *chipid) · line 193
Quoted 10 lines
drivers/gpu/drm/msm/adreno/adreno_device.c +10
-0+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.
Quoted 58 lines
drivers/gpu/drm/msm/adreno/adreno_device.c +11
-5+ 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;drivers/gpu/drm/msm/msm_drv.c +1
-1@@ -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);drivers/gpu/drm/msm/msm_gpu.h +1
-0@@ -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);
Signature · 2 lines
With best wishes Dmitry