From: Philipp Zabel <p.zabel@pengutronix.de>
To: Christian Marangi <ansuelsmth@gmail.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Felix Fietkau <nbd@nbd.name>,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v12 3/5] clk: en7523: protect concurrent access to reset and PCI register
Date: Tue, 10 Nov 2026 12:33:50 +0100 [thread overview]
Message-ID: <0fb93159c97d446eb26ca18c75ff74c2bc8ceecc.camel@pengutronix.de> (raw)
In-Reply-To: <20261110000753.508-4-ansuelsmth@gmail.com>
On Di, 2026-11-10 at 01:07 +0100, Christian Marangi wrote:
> Use spinlock for concurrent access to reset and PCI register to catch case
> when clock is enabled/disabled while a reset is also operated at the same
> time.
Why do reset accesses need to be serialized against clock accesses?
>
> Some minor rework was needed for PCI unprepare case to permit calling it
> before clk_hw_register and reference the global spinlock.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
> drivers/clk/clk-en7523.c | 101 ++++++++++++++++++++++++++++++++++++---
> 1 file changed, 95 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> index 2baec734df9f..fbe10e4c3693 100644
> --- a/drivers/clk/clk-en7523.c
> +++ b/drivers/clk/clk-en7523.c
[...]
> @@ -788,21 +866,25 @@ static int en7523_reset_update(struct reset_controller_dev *rcdev,
> unsigned long id, bool assert)
> {
> struct en_rst_data *rst_data = container_of(rcdev, struct en_rst_data, rcdev);
> + struct en_clk_priv *priv = dev_get_drvdata(rcdev->dev);
> u32 offset = rst_data->bank_ofs[id / RST_NR_PER_BANK];
> void __iomem *addr = rst_data->base + offset;
> bool inverted = false;
> + unsigned long flags;
> u32 val;
>
> /* For PCIC reset logic is inverted, 0:assert 1:deassert */
> if (offset == REG_NP_SCU_PCIC)
> inverted = true;
>
> + spin_lock_irqsave(&priv->lock, flags);
Consider using guard(spinlock)(&priv->lock) to simplify this.
> val = readl(addr);
> if (assert ^ inverted)
> val |= BIT(id % RST_NR_PER_BANK);
> else
> val &= ~BIT(id % RST_NR_PER_BANK);
> writel(val, addr);
> + spin_unlock_irqrestore(&priv->lock, flags);
>
> return 0;
> }
> @@ -823,16 +905,21 @@ static int en7523_reset_status(struct reset_controller_dev *rcdev,
> unsigned long id)
> {
> struct en_rst_data *rst_data = container_of(rcdev, struct en_rst_data, rcdev);
> + struct en_clk_priv *priv = dev_get_drvdata(rcdev->dev);
> u32 offset = rst_data->bank_ofs[id / RST_NR_PER_BANK];
> void __iomem *addr = rst_data->base + offset;
> bool inverted = false;
> + unsigned long flags;
> u32 val;
>
> /* For PCIC reset logic is inverted, 0:assert 1:deassert */
> if (offset == REG_NP_SCU_PCIC)
> inverted = true;
>
> + spin_lock_irqsave(&priv->lock, flags);
> val = readl(addr) & BIT(id % RST_NR_PER_BANK);
> + spin_unlock_irqrestore(&priv->lock, flags);
Why is this read() under a lock? The commit message doesn't tell.
regards
Philipp
next prev parent reply other threads:[~2026-11-10 11:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 0:07 [PATCH v12 0/5] clk: add support for Airoha AN7583 clock Christian Marangi
2026-11-10 0:07 ` [PATCH v12 1/5] dt-bindings: clock: airoha: Document support for " Christian Marangi
2026-11-10 0:07 ` [PATCH v12 2/5] clk: en7523: use devm variant for clk_hw_register and fixed clock Christian Marangi
2026-11-10 0:07 ` [PATCH v12 3/5] clk: en7523: protect concurrent access to reset and PCI register Christian Marangi
2026-11-10 11:33 ` Philipp Zabel [this message]
2026-11-10 0:07 ` [PATCH v12 4/5] clk: en7523: generalize register clocks function Christian Marangi
2026-11-10 0:07 ` [PATCH v12 5/5] clk: en7523: add support for Airoha AN7583 clock Christian Marangi
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=0fb93159c97d446eb26ca18c75ff74c2bc8ceecc.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=ansuelsmth@gmail.com \
--cc=bmasney+clk@redhat.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jbrunet+clk@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nbd@nbd.name \
--cc=robh@kernel.org \
--cc=sboyd@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®