From: Stephen Boyd <sboyd@kernel.org>
To: Michal Wilczynski <m.wilczynski@samsung.com>,
alex@ghiti.fr, aou@eecs.berkeley.edu, conor+dt@kernel.org,
drew@pdp7.com, guoren@kernel.org, jszhang@kernel.org,
krzk+dt@kernel.org, m.szyprowski@samsung.com,
mturquette@baylibre.com, p.zabel@pengutronix.de,
palmer@dabbelt.com, paul.walmsley@sifive.com, robh@kernel.org,
wefu@redhat.com
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
Michal Wilczynski <m.wilczynski@samsung.com>
Subject: Re: [PATCH v1 4/4] clk: thead: Add GPU clock gate control with CLKGEN reset support
Date: Wed, 05 Mar 2025 15:47:20 -0800 [thread overview]
Message-ID: <de50dd55e1285726e8d5ebae73877486.sboyd@kernel.org> (raw)
In-Reply-To: <20250303143629.400583-5-m.wilczynski@samsung.com>
Quoting Michal Wilczynski (2025-03-03 06:36:29)
> The T-HEAD TH1520 has three GPU clocks: core, cfg, and mem. The mem
> clock gate is marked as "Reserved" in hardware, while core and cfg are
> configurable. In order for these clock gates to work properly, the
> CLKGEN reset must be managed in a specific sequence.
>
> Move the CLKGEN reset handling to the clock driver since it's
> fundamentally a clock-related workaround [1]. This ensures that clk_enabled
> GPU clocks stay physically enabled without external interference from
> the reset driver. The reset is now deasserted only when both core and
> cfg clocks are enabled, and asserted when either of them is disabled.
>
> The mem clock is configured to use nop operations since it cannot be
> controlled.
>
> Link: https://lore.kernel.org/all/945fb7e913a9c3dcb40697328b7e9842b75fea5c.camel@pengutronix.de [1]
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
[...]
> diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c
> index ea96d007aecd..1dfcde867233 100644
> --- a/drivers/clk/thead/clk-th1520-ap.c
> +++ b/drivers/clk/thead/clk-th1520-ap.c
> @@ -862,17 +863,70 @@ static CCU_GATE(CLK_SRAM1, sram1_clk, "sram1", axi_aclk_pd, 0x20c, BIT(3), 0);
[...]
>
> static CCU_GATE_CLK_OPS(CLK_GPU_MEM, gpu_mem_clk, "gpu-mem-clk",
> video_pll_clk_pd, 0x0, BIT(2), 0, clk_nop_ops);
> +static CCU_GATE_CLK_OPS(CLK_GPU_CORE, gpu_core_clk, "gpu-core-clk",
> + video_pll_clk_pd, 0x0, BIT(3), 0, ccu_gate_gpu_ops);
> +static CCU_GATE_CLK_OPS(CLK_GPU_CFG_ACLK, gpu_cfg_aclk, "gpu-cfg-aclk",
> + video_pll_clk_pd, 0x0, BIT(4), 0, ccu_gate_gpu_ops);
> +
> +static void ccu_gpu_clk_disable(struct clk_hw *hw)
> +{
> + struct ccu_gate *cg = hw_to_ccu_gate(hw);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&gpu_reset_lock, flags);
> +
> + ccu_disable_helper(&cg->common, cg->enable);
> +
> + if ((cg == &gpu_core_clk &&
> + !clk_hw_is_enabled(&gpu_cfg_aclk.common.hw)) ||
> + (cg == &gpu_cfg_aclk &&
> + !clk_hw_is_enabled(&gpu_core_clk.common.hw)))
> + reset_control_assert(gpu_reset);
Why can't the clk consumer control the reset itself? Doing this here is
not ideal because we hold the clk lock when we try to grab the reset
lock. These are all spinlocks that should be small in lines of code
where the lock is held, but we're calling into an entire other framework
under a spinlock. If an (unrelated) reset driver tries to grab the clk
lock it will deadlock.
I see the commit text talks about this being a workaround. I'm not sure
what the workaround is though. I've seen designs where the reset doesn't
work unless the clk is enabled because the flops have to be clocking for
the reset to propagate a few cycles, or the clk has to be disabled so
that the reset controller can do the clocking, or vice versa for the clk
not working unless the reset is deasserted. Long story short, it's
different between SoCs.
Likely the reset and clk control should be coordinated in a PM domain
for the device so that when the device is active, the clks are enabled
and the reset is deasserted in the correct order for the SoC. Can you do
that?
> +
> + spin_unlock_irqrestore(&gpu_reset_lock, flags);
> +}
next prev parent reply other threads:[~2025-03-05 23:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20250303143634eucas1p269281f72bdc4d764edd54b9427f68787@eucas1p2.samsung.com>
2025-03-03 14:36 ` [PATCH v1 0/4] Add T-Head TH1520 VO clock support for LicheePi 4A GPU enablement Michal Wilczynski
2025-03-03 14:36 ` [PATCH v1 1/4] dt-bindings: clock: thead: Add TH1520 VO clock controller Michal Wilczynski
2025-03-03 16:24 ` Conor Dooley
2025-03-03 17:41 ` Krzysztof Kozlowski
2025-03-03 17:46 ` Krzysztof Kozlowski
2025-03-04 7:39 ` Michal Wilczynski
2025-03-04 7:41 ` Krzysztof Kozlowski
2025-03-03 14:36 ` [PATCH v1 2/4] clk: thead: Add clock support for VO subsystem in T-Head TH1520 SoC Michal Wilczynski
2025-03-03 14:36 ` [PATCH v1 3/4] clk: thead: Add support for custom ops in CCU_GATE_CLK_OPS macro Michal Wilczynski
2025-03-03 14:36 ` [PATCH v1 4/4] clk: thead: Add GPU clock gate control with CLKGEN reset support Michal Wilczynski
2025-03-05 23:47 ` Stephen Boyd [this message]
2025-03-06 16:43 ` Michal Wilczynski
2025-03-13 9:25 ` Philipp Zabel
2025-03-19 9:22 ` Michal Wilczynski
2025-03-25 22:40 ` Stephen Boyd
2025-03-26 11:24 ` Ulf Hansson
2025-04-01 14:38 ` Michal Wilczynski
2025-04-07 17:02 ` Michal Wilczynski
2025-04-08 12:27 ` Ulf Hansson
2025-03-05 8:18 ` [PATCH v1 0/4] Add T-Head TH1520 VO clock support for LicheePi 4A GPU enablement Michal Wilczynski
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=de50dd55e1285726e8d5ebae73877486.sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=drew@pdp7.com \
--cc=guoren@kernel.org \
--cc=jszhang@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=m.szyprowski@samsung.com \
--cc=m.wilczynski@samsung.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh@kernel.org \
--cc=wefu@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).