From: Peng Fan <peng.fan@oss.nxp.com>
To: Stephen Boyd <sboyd@kernel.org>
Cc: Cristian Marussi <cristian.marussi@arm.com>,
Michael Turquette <mturquette@baylibre.com>,
Russell King <linux@armlinux.org.uk>,
Sudeep Holla <sudeep.holla@arm.com>,
linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
imx@lists.linux.dev, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 1/3] clk: Introduce clk_set_spread_spectrum
Date: Sun, 2 Feb 2025 18:42:56 +0800 [thread overview]
Message-ID: <20250202104256.GA13402@localhost.localdomain> (raw)
In-Reply-To: <ff801714249c492abc3781da55675a38.sboyd@kernel.org>
On Tue, Jan 28, 2025 at 12:25:28PM -0800, Stephen Boyd wrote:
>Quoting Peng Fan (OSS) (2025-01-24 06:25:17)
>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>> index cf7720b9172ff223d86227aad144e15375ddfd86..a4fe4a60f839244b736e3c2751eeb38dc4577b1f 100644
>> --- a/drivers/clk/clk.c
>> +++ b/drivers/clk/clk.c
>> @@ -2790,6 +2790,45 @@ int clk_set_max_rate(struct clk *clk, unsigned long rate)
>> }
>> EXPORT_SYMBOL_GPL(clk_set_max_rate);
>>
>> +int clk_set_spread_spectrum(struct clk *clk, unsigned int modfreq,
>> + unsigned int spreadpercent, unsigned int method,
>> + bool enable)
>> +{
>> + struct clk_spread_spectrum clk_ss;
>> + struct clk_core *core;
>> + int ret = 0;
>
>The assignment looks unnecessary.
To avoid uninitialized variable warning.
>
>> +
>> + if (!clk || !clk->core)
>
>How do you not have clk->core?
>
>> + return 0;
>> +
>> + clk_ss.modfreq = modfreq;
>> + clk_ss.spreadpercent = spreadpercent;
>> + clk_ss.method = method;
>> + clk_ss.enable = enable;
>> +
>> + clk_prepare_lock();
>> +
>> + core = clk->core;
>
>Why do we need to get the core under the lock?
Drop in v2.
>
>> +
>> + if (core->prepare_count) {
>
>Why does prepare count matter?
I was thinking to configure Spread Spectrum(SS) before
prepare/enable a clock. But it should be fine to not
check prepare count.
>
>> + ret = -EBUSY;
>> + goto fail;
>
>We just left without releasing the lock.
True. Dan also reported this. Fix in V2.
>
>> + }
>> +
>> + ret = clk_pm_runtime_get(core);
>> + if (ret)
>> + goto fail;
>
>We just left without releasing the lock.
>
>> +
>> + if (core->ops->set_spread_spectrum)
>> + ret = core->ops->set_spread_spectrum(core->hw, &clk_ss);
>> +
>> + clk_pm_runtime_put(core);
>> + clk_prepare_unlock();
>> +fail:
>> + return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(clk_set_spread_spectrum);
>> +
>> diff --git a/include/linux/clk.h b/include/linux/clk.h
>> index b607482ca77e987b9344c38f25ebb5c8d35c1d39..49a7f7eb8b03233e11cd3b92768896c4e45c4e7c 100644
>> --- a/include/linux/clk.h
>> +++ b/include/linux/clk.h
>> @@ -858,6 +858,21 @@ int clk_set_rate(struct clk *clk, unsigned long rate);
>> */
>> int clk_set_rate_exclusive(struct clk *clk, unsigned long rate);
>>
>> +/**
>> + * clk_set_spread_spectrum - set the spread spectrum for a clock
>> + * @clk: clock source
>> + * @modfreq: modulation freq
>> + * @spreadpercent: modulation percentage
>> + * @method: down spread, up spread, center spread or else
>
>Did we get cut off?
Sorry I not get this point.
>
>> + * @enable: enable or disable
>
>Isn't 'disable' equal to spread_percent of zero?
yeah. Drop the last parameter.
>
>> + *
>> + * Configure the spread spectrum parameters for a clock.
>> + *
>> + * Returns success (0) or negative errno.
>> + */
>> +int clk_set_spread_spectrum(struct clk *clk, unsigned int modfreq,
>
>Does this need to be a consumer API at all? Usually SSC is figured out
>when making a board and you have to pass some certification testing
>because some harmonics are interfering. Is the DT property sufficient
>for now and then we can do it when the driver probes in the framework?
I suppose 'DT property' you are refering the stm32 and i.MX8M SSC patchsets.
I am proposing a generic interface for drivers to enable SSC.
Otherwise we need to introduce vendor properties for each vendor.
And looking at clk-scmi.c, we need a generic way to enable SSC, I think SCMI
maintainers not agree to add vendor properties for it.
>
>> + unsigned int spreadpercent, unsigned int method,
>
>I'd assume 'method' would be some sort of enum?
sure. Fix in V2.
Thanks,
Peng
>
>> + bool enable);
>> /**
>> * clk_has_parent - check if a clock is a possible parent for another
>> * @clk: clock source
next prev parent reply other threads:[~2025-02-02 9:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 14:25 [PATCH 0/3] clk: Support spread spectrum and use it in clk-scmi Peng Fan (OSS)
2025-01-24 14:25 ` [PATCH 1/3] clk: Introduce clk_set_spread_spectrum Peng Fan (OSS)
2025-01-24 13:51 ` Dan Carpenter
2025-01-28 20:25 ` Stephen Boyd
2025-02-02 10:42 ` Peng Fan [this message]
2025-02-03 9:43 ` Cristian Marussi
2025-02-03 11:47 ` Peng Fan
2025-02-03 11:22 ` Cristian Marussi
2025-02-04 0:31 ` Peng Fan
2025-01-24 14:25 ` [PATCH 2/3] clk: conf: Support assigned-clock-sscs Peng Fan (OSS)
2025-01-24 14:25 ` [PATCH 3/3] clk: scmi: Support spread spectrum Peng Fan (OSS)
2025-01-24 21:33 ` kernel test robot
2025-01-28 12:07 ` Cristian Marussi
2025-01-25 12:58 ` [PATCH 0/3] clk: Support spread spectrum and use it in clk-scmi Dario Binacchi
2025-01-27 7:42 ` Krzysztof Kozlowski
2025-01-27 7:59 ` Dario Binacchi
2025-01-27 8:31 ` Krzysztof Kozlowski
2025-01-27 8:35 ` Dario Binacchi
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=20250202104256.GA13402@localhost.localdomain \
--to=peng.fan@oss.nxp.com \
--cc=arm-scmi@vger.kernel.org \
--cc=cristian.marussi@arm.com \
--cc=dario.binacchi@amarulasolutions.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@kernel.org \
--cc=sudeep.holla@arm.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).