From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Heiko Stuebner <heiko@sntech.de>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>, <linux-pm@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-rockchip@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <imx@lists.linux.dev>,
<linux-arm-msm@vger.kernel.org>,
<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH 02/10] pmdomain: rockchip: Simplify locking with guard()
Date: Tue, 27 Aug 2024 10:59:27 +0100 [thread overview]
Message-ID: <20240827105927.00007ac7@Huawei.com> (raw)
In-Reply-To: <20240823-cleanup-h-guard-pm-domain-v1-2-8320722eaf39@linaro.org>
On Fri, 23 Aug 2024 14:51:06 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:
> Simplify error handling (smaller error handling) over locks with
> guard().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Musing inline.
LGTM
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/pmdomain/rockchip/pm-domains.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index 5679ad336a11..538dde58d924 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -910,7 +910,7 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
> * Prevent any rockchip_pmu_block() from racing with the remainder of
> * setup (clocks, register initialization).
> */
> - mutex_lock(&dmc_pmu_mutex);
> + guard(mutex)(&dmc_pmu_mutex);
>
> for_each_available_child_of_node_scoped(np, node) {
> error = rockchip_pm_add_one_domain(pmu, node);
> @@ -943,13 +943,10 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
> if (!WARN_ON_ONCE(dmc_pmu))
> dmc_pmu = pmu;
>
> - mutex_unlock(&dmc_pmu_mutex);
> -
> return 0;
>
> err_out:
> rockchip_pm_domain_cleanup(pmu);
I wonder. Could you use a devm_add_action_or_reset for this and allow early
returns throughout?
Would need to take the lock again perhaps and I haven't checked if there
is any issue in dropping and retaking the mutex however.
The block logic is non obvious so I couldn't quickly figure this out.
> - mutex_unlock(&dmc_pmu_mutex);
> return error;
> }
>
>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Heiko Stuebner <heiko@sntech.de>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>, <linux-pm@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-rockchip@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <imx@lists.linux.dev>,
<linux-arm-msm@vger.kernel.org>,
<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH 02/10] pmdomain: rockchip: Simplify locking with guard()
Date: Tue, 27 Aug 2024 10:59:27 +0100 [thread overview]
Message-ID: <20240827105927.00007ac7@Huawei.com> (raw)
In-Reply-To: <20240823-cleanup-h-guard-pm-domain-v1-2-8320722eaf39@linaro.org>
On Fri, 23 Aug 2024 14:51:06 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:
> Simplify error handling (smaller error handling) over locks with
> guard().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Musing inline.
LGTM
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/pmdomain/rockchip/pm-domains.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index 5679ad336a11..538dde58d924 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -910,7 +910,7 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
> * Prevent any rockchip_pmu_block() from racing with the remainder of
> * setup (clocks, register initialization).
> */
> - mutex_lock(&dmc_pmu_mutex);
> + guard(mutex)(&dmc_pmu_mutex);
>
> for_each_available_child_of_node_scoped(np, node) {
> error = rockchip_pm_add_one_domain(pmu, node);
> @@ -943,13 +943,10 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
> if (!WARN_ON_ONCE(dmc_pmu))
> dmc_pmu = pmu;
>
> - mutex_unlock(&dmc_pmu_mutex);
> -
> return 0;
>
> err_out:
> rockchip_pm_domain_cleanup(pmu);
I wonder. Could you use a devm_add_action_or_reset for this and allow early
returns throughout?
Would need to take the lock again perhaps and I haven't checked if there
is any issue in dropping and retaking the mutex however.
The block logic is non obvious so I couldn't quickly figure this out.
> - mutex_unlock(&dmc_pmu_mutex);
> return error;
> }
>
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2024-08-27 9:59 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 12:51 [PATCH 00/10] pmdomain: Simplify with cleanup.h Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 01/10] pmdomain: rockchip: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 9:53 ` Jonathan Cameron
2024-08-27 9:53 ` Jonathan Cameron
2024-08-23 12:51 ` [PATCH 02/10] pmdomain: rockchip: Simplify locking with guard() Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 9:59 ` Jonathan Cameron [this message]
2024-08-27 9:59 ` Jonathan Cameron
2024-08-27 10:30 ` Krzysztof Kozlowski
2024-08-27 10:30 ` Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 03/10] pmdomain: imx: gpc: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 04/10] pmdomain: imx: gpcv2: " Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-23 12:51 ` [PATCH 05/10] pmdomain: qcom: cpr: Simplify with dev_err_probe() Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 9:45 ` Konrad Dybcio
2024-08-27 9:45 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 06/10] pmdomain: qcom: cpr: Simplify locking with guard() Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 9:47 ` Konrad Dybcio
2024-08-27 9:47 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 07/10] pmdomain: qcom: rpmhpd: " Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 9:48 ` Konrad Dybcio
2024-08-27 9:48 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 08/10] pmdomain: qcom: rpmpd: " Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 9:49 ` Konrad Dybcio
2024-08-27 9:49 ` Konrad Dybcio
2024-08-23 12:51 ` [PATCH 09/10] pmdomain: renesas: rcar-gen4-sysc: Use scoped device node handling to simplify error paths Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 7:48 ` Geert Uytterhoeven
2024-08-27 7:48 ` Geert Uytterhoeven
2024-08-27 9:33 ` Krzysztof Kozlowski
2024-08-27 9:33 ` Krzysztof Kozlowski
2024-08-27 9:39 ` Krzysztof Kozlowski
2024-08-27 9:39 ` Krzysztof Kozlowski
2024-08-27 10:55 ` Geert Uytterhoeven
2024-08-27 10:55 ` Geert Uytterhoeven
2024-08-27 11:12 ` Krzysztof Kozlowski
2024-08-27 11:12 ` Krzysztof Kozlowski
2024-11-27 13:14 ` Geert Uytterhoeven
2024-11-27 13:14 ` Geert Uytterhoeven
2024-08-23 12:51 ` [PATCH 10/10] pmdomain: renesas: rcar-sysc: " Krzysztof Kozlowski
2024-08-23 12:51 ` Krzysztof Kozlowski
2024-08-27 7:55 ` Geert Uytterhoeven
2024-08-27 7:55 ` Geert Uytterhoeven
2024-09-13 12:01 ` [PATCH 00/10] pmdomain: Simplify with cleanup.h Ulf Hansson
2024-09-13 12:01 ` Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240827105927.00007ac7@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=andersson@kernel.org \
--cc=festevam@gmail.com \
--cc=geert+renesas@glider.be \
--cc=heiko@sntech.de \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=konradybcio@kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=magnus.damm@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.