Commit 81f2fbe6 authored by Clément Péron's avatar Clément Péron Committed by Rob Herring

drm/panfrost: properly handle error in probe

Introduce a boolean to know if opp table has been added.

With this, we can call panfrost_devfreq_fini() in case of error
and release what has been initialised.
Reviewed-by: default avatarSteven Price <steven.price@arm.com>
Reviewed-by: default avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: default avatarClément Péron <peron.clem@gmail.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200710095409.407087-7-peron.clem@gmail.com
parent ed85df3f
...@@ -101,6 +101,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) ...@@ -101,6 +101,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
return 0; return 0;
else if (ret) else if (ret)
return ret; return ret;
pfdevfreq->opp_of_table_added = true;
spin_lock_init(&pfdevfreq->lock); spin_lock_init(&pfdevfreq->lock);
...@@ -109,8 +110,10 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) ...@@ -109,8 +110,10 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
cur_freq = clk_get_rate(pfdev->clock); cur_freq = clk_get_rate(pfdev->clock);
opp = devfreq_recommended_opp(dev, &cur_freq, 0); opp = devfreq_recommended_opp(dev, &cur_freq, 0);
if (IS_ERR(opp)) if (IS_ERR(opp)) {
return PTR_ERR(opp); ret = PTR_ERR(opp);
goto err_fini;
}
panfrost_devfreq_profile.initial_freq = cur_freq; panfrost_devfreq_profile.initial_freq = cur_freq;
dev_pm_opp_put(opp); dev_pm_opp_put(opp);
...@@ -119,8 +122,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) ...@@ -119,8 +122,8 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL); DEVFREQ_GOV_SIMPLE_ONDEMAND, NULL);
if (IS_ERR(devfreq)) { if (IS_ERR(devfreq)) {
DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n"); DRM_DEV_ERROR(dev, "Couldn't initialize GPU devfreq\n");
dev_pm_opp_of_remove_table(dev); ret = PTR_ERR(devfreq);
return PTR_ERR(devfreq); goto err_fini;
} }
pfdevfreq->devfreq = devfreq; pfdevfreq->devfreq = devfreq;
...@@ -131,15 +134,25 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) ...@@ -131,15 +134,25 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev)
pfdevfreq->cooling = cooling; pfdevfreq->cooling = cooling;
return 0; return 0;
err_fini:
panfrost_devfreq_fini(pfdev);
return ret;
} }
void panfrost_devfreq_fini(struct panfrost_device *pfdev) void panfrost_devfreq_fini(struct panfrost_device *pfdev)
{ {
struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq;
if (pfdevfreq->cooling) if (pfdevfreq->cooling) {
devfreq_cooling_unregister(pfdevfreq->cooling); devfreq_cooling_unregister(pfdevfreq->cooling);
pfdevfreq->cooling = NULL;
}
if (pfdevfreq->opp_of_table_added) {
dev_pm_opp_of_remove_table(&pfdev->pdev->dev); dev_pm_opp_of_remove_table(&pfdev->pdev->dev);
pfdevfreq->opp_of_table_added = false;
}
} }
void panfrost_devfreq_resume(struct panfrost_device *pfdev) void panfrost_devfreq_resume(struct panfrost_device *pfdev)
......
...@@ -15,6 +15,7 @@ struct panfrost_device; ...@@ -15,6 +15,7 @@ struct panfrost_device;
struct panfrost_devfreq { struct panfrost_devfreq {
struct devfreq *devfreq; struct devfreq *devfreq;
struct thermal_cooling_device *cooling; struct thermal_cooling_device *cooling;
bool opp_of_table_added;
ktime_t busy_time; ktime_t busy_time;
ktime_t idle_time; ktime_t idle_time;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment