diff mbox series

drm/msm/gpu: Drop qos request if devm_devfreq_add_device() fails

Message ID 20220708162632.3529864-1-bjorn.andersson@linaro.org
State Accepted
Commit 02b9f2636209beb843ca501d47f7fddc8792b2d7
Headers show
Series drm/msm/gpu: Drop qos request if devm_devfreq_add_device() fails | expand

Commit Message

Bjorn Andersson July 8, 2022, 4:26 p.m. UTC
In the event that devm_devfreq_add_device() fails the device's qos freq
list is left referencing df->idle_freq and df->boost_freq. Attempting to
initialize devfreq again after a probe deferral will then cause invalid
memory accesses in dev_pm_qos_add_request().

Fix this by dropping the requests in the error path.

Fixes: 7c0ffcd40b16 ("drm/msm/gpu: Respect PM QoS constraints")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Rob Clark Aug. 1, 2022, 5:38 p.m. UTC | #1
On Fri, Jul 8, 2022 at 9:24 AM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
>
> In the event that devm_devfreq_add_device() fails the device's qos freq
> list is left referencing df->idle_freq and df->boost_freq. Attempting to
> initialize devfreq again after a probe deferral will then cause invalid
> memory accesses in dev_pm_qos_add_request().
>
> Fix this by dropping the requests in the error path.
>
> Fixes: 7c0ffcd40b16 ("drm/msm/gpu: Respect PM QoS constraints")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>  drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/msm_gpu_devfreq.c b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
> index c2ea978c8921..21e271a318ee 100644
> --- a/drivers/gpu/drm/msm/msm_gpu_devfreq.c
> +++ b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
> @@ -198,6 +198,8 @@ void msm_devfreq_init(struct msm_gpu *gpu)
>
>         if (IS_ERR(df->devfreq)) {
>                 DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
> +               dev_pm_qos_remove_request(&df->idle_freq);
> +               dev_pm_qos_remove_request(&df->boost_freq);
>                 df->devfreq = NULL;
>                 return;
>         }
> --
> 2.35.1
>
Dmitry Baryshkov Aug. 2, 2022, 6:43 a.m. UTC | #2
On 08/07/2022 19:26, Bjorn Andersson wrote:
> In the event that devm_devfreq_add_device() fails the device's qos freq
> list is left referencing df->idle_freq and df->boost_freq. Attempting to
> initialize devfreq again after a probe deferral will then cause invalid
> memory accesses in dev_pm_qos_add_request().
> 
> Fix this by dropping the requests in the error path.
> 
> Fixes: 7c0ffcd40b16 ("drm/msm/gpu: Respect PM QoS constraints")
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---
>   drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 ++
>   1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/msm_gpu_devfreq.c b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
index c2ea978c8921..21e271a318ee 100644
--- a/drivers/gpu/drm/msm/msm_gpu_devfreq.c
+++ b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
@@ -198,6 +198,8 @@  void msm_devfreq_init(struct msm_gpu *gpu)
 
 	if (IS_ERR(df->devfreq)) {
 		DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
+		dev_pm_qos_remove_request(&df->idle_freq);
+		dev_pm_qos_remove_request(&df->boost_freq);
 		df->devfreq = NULL;
 		return;
 	}