[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210611101540.3379937-2-dmitry.baryshkov@linaro.org>
Date: Fri, 11 Jun 2021 13:15:39 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: "Rafael J. Wysocki" <rjw@...ysocki.net>,
Kevin Hilman <khilman@...nel.org>,
Ulf Hansson <ulf.hansson@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Bjorn Andersson <bjorn.andersson@...aro.org>,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] PM: domains: call mutex_destroy when removing the genpd
It is a good practice to destroy mutexes with mutex_destroy, so call
this function for releasing genpd->mlock.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
---
drivers/base/power/domain.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index b6a782c31613..74219d032910 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1910,6 +1910,11 @@ static void genpd_lock_init(struct generic_pm_domain *genpd)
}
}
+static void genpd_lock_destroy(struct generic_pm_domain *genpd) {
+ if (!(genpd->flags & GENPD_FLAG_IRQ_SAFE))
+ mutex_destroy(&genpd->mlock);
+}
+
/**
* pm_genpd_init - Initialize a generic I/O PM domain object.
* @genpd: PM domain object to initialize.
@@ -1960,12 +1965,16 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
/* Always-on domains must be powered on at initialization. */
if ((genpd_is_always_on(genpd) || genpd_is_rpm_always_on(genpd)) &&
- !genpd_status_on(genpd))
- return -EINVAL;
+ !genpd_status_on(genpd)) {
+ ret = -EINVAL;
+ goto fail;
+ }
if (genpd_is_cpu_domain(genpd) &&
- !zalloc_cpumask_var(&genpd->cpus, GFP_KERNEL))
- return -ENOMEM;
+ !zalloc_cpumask_var(&genpd->cpus, GFP_KERNEL)) {
+ ret = -ENOMEM;
+ goto fail;
+ }
/* Use only one "off" state if there were no states declared */
if (genpd->state_count == 0) {
@@ -1973,7 +1982,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
if (ret) {
if (genpd_is_cpu_domain(genpd))
free_cpumask_var(genpd->cpus);
- return ret;
+ goto fail;
}
} else if (!gov && genpd->state_count > 1) {
pr_warn("%s: no governor for states\n", genpd->name);
@@ -1988,6 +1997,11 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
mutex_unlock(&gpd_list_lock);
return 0;
+
+fail:
+ genpd_lock_destroy(genpd);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(pm_genpd_init);
@@ -2026,6 +2040,7 @@ static int genpd_remove(struct generic_pm_domain *genpd)
free_cpumask_var(genpd->cpus);
if (genpd->free_states)
genpd->free_states(genpd->states, genpd->state_count);
+ genpd_lock_destroy(genpd);
pr_debug("%s: removed %s\n", __func__, genpd->name);
--
2.30.2
Powered by blists - more mailing lists