| Message ID | 20260901090912.585681-2-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path:
<linux-amarula+bncBCQ4XFG47UFRBS5M3LKAMGQEBDY6UOQ@amarulasolutions.com>
X-Original-To: linux-amarula@patchwork.amarulasolutions.com
Delivered-To: linux-amarula@patchwork.amarulasolutions.com
Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com
[209.85.208.71])
by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 181FE40D07
for <linux-amarula@patchwork.amarulasolutions.com>;
Tue, 1 Sep 2026 11:09:32 +0200 (CEST)
Received: by mail-ed1-f71.google.com with SMTP id
4fb4d7f45d1cf-6a36683ee94sf3606089a12.0
for <linux-amarula@patchwork.amarulasolutions.com>;
Tue, 01 Sep 2026 02:09:32 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1788253771; cv=pass;
d=google.com; s=arc-20260327;
b=Fpip6RIm0txx4VqQw2wjvz8MwKMHwMjjtMlY6ihZDHpyyJCwOAoC1rMXqQESOKR6OF
acx/qROKlG7E6dvrm0oPJsPdGfIVb48p1hmOBdYQGGhFmB5vHYQaRLv16xpT+gCY0HET
URu+Xa1QNDbNyfg7cuc2+NeLQc/XjPw4f/VqmorsWPzr4zq8L404mcPcHQrEwvFBym/Y
eQXUnCI8lNH69ZzbraZA6XrUo1C4dQf38pPlRrlJSR90U0FUBffF+RRJuEhnC8Mxff2C
+DRaoc2qlismdiZnedwRQYN1JMTfvNIpagAHhmt5AqAB3JNDfXZSY7C7N+URHGXAd+wL
mn8A==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20260327;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=jvVar7UDN6d2mxAOrqHGZ1Gz72/J1szmVwTjJyvdW4M=;
fh=5xZwx9IaP/97++La28EMpw9yKi2/pnJmw4V2opKg5lQ=;
b=WKs6Leq1F1oe9relDz827UtU7XP6uZNFVOhnAUfmT+qGttHNcaIAGX8YqTmONLAuqG
g0WIexLKFKFH/nrDFAQwFja2V3Tyl3mFQZoVeCA1u8KkHTKt3xXlcAag/9ZxwbgFamjh
PPEciuw/2t8w9g9thg+pBjliifvfNfQYX4nmAdSNW7vderdASGnDn3l9gL861vPvUKuZ
6tzt5i3KjlTjm0LkqhrLhkjY9pNu52v2/CJFeAKE0YxBB+umJbxooPGRFqzV3NsHN6gP
hx5lXebr0E+sceC5qfUOwkSQlG/fOgz54qZJW6/C8vLRlvqbsRNFE14H5fMNrUOIllTD
1yUw==;
darn=patchwork.amarulasolutions.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=Zd9kJfAi;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=amarulasolutions.com; s=google; t=1788253771; x=1788858571;
darn=patchwork.amarulasolutions.com;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:content-type
:x-original-authentication-results:x-original-sender:mime-version
:references:in-reply-to:message-id:date:subject:cc:to:from:from:to
:cc:subject:date:message-id:reply-to:content-type;
bh=jvVar7UDN6d2mxAOrqHGZ1Gz72/J1szmVwTjJyvdW4M=;
b=VxY7iRhMSdTrGUo0m8DqghfIJruUIOO1rBWCM1AmGY5/pUv3ivzP5dHxdlCETp2j8q
vuyEDPe/BJx07ds7Fy8cvzW/1cFLJTdlbFU76Uz7HuKW8H6nLSzkVqCT4x4WC+ic3ZUg
aPny/qVB3CPw2YhZSai+v9hzaAXwkvHUQkya8=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1788253771; x=1788858571;
h=list-unsubscribe:list-archive:list-help:list-post
:x-spam-checked-in-group:list-id:mailing-list:precedence
:content-type:x-original-authentication-results:x-original-sender
:mime-version:references:in-reply-to:message-id:date:subject:cc:to
:from:x-gm-gg:x-beenthere:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=jvVar7UDN6d2mxAOrqHGZ1Gz72/J1szmVwTjJyvdW4M=;
b=TvHdbIGrOAUTJ21grcUdLufzqKZYToo5lf739K7UtGwY1zQkhnecT2QWD+R0W6Caa/
3ZjQLkmpgB5n+EcnOXp03aaOqAXbmD8wHiuWLWYsM4h/On7sPS+tTWtybgUbO3gUPfg8
0bgSoJ+wY1FQMQozOu4daPbhP2sKp+ZkzbMp9q9AOOiIxAC7kS/Q4asLCISnFz9FV8W0
rv03G7+WMcNP7XcaDMlea9rVCcKvtZ3GgF9D0kLDIEPQwjJrq2LMF35eeOAlc6ZgPeHd
f3YaMch4B9F/rcpreiEkJCJj/sSMCm2g/5VE9CGbDeNZXeGxYUVGl7cBjgMNil4hBgtR
AFdg==
X-Forwarded-Encrypted: i=2;
AKwUvBwPOnbwH3eLrxmM1wNGp1t5UEYKTNzc9G2f8AvceMCA3kVFFK5gUfDcbcYVa/5d687dXjA2fQNSBKtYQDo2@patchwork.amarulasolutions.com
X-Gm-Message-State: AFuF++nfiYBZJHhIDcaq6ihVZFKB7LI3YxLbFig0x/5NMJlvd9eLBoDN
CbJQs41sfCD6U33vWTiQ4+eg9ZH0RhfUW5DsCkGPnKMeiDCH+na6kizL7tDR4xx+v178jg==
X-Received: by 2002:a05:6402:4554:b0:698:e614:e4bf with SMTP id
4fb4d7f45d1cf-6a60d061a16mr14941560a12.0.1788253771719;
Tue, 01 Sep 2026 02:09:31 -0700 (PDT)
X-BeenThere: linux-amarula@amarulasolutions.com;
h="ATskLdcBC99exFELtDjKfFtV+c88K/nCZx9hAlDBvEcrjT9BGA=="
Received: by 2002:a05:6402:44da:b0:6a5:d94f:b1f7 with SMTP id
4fb4d7f45d1cf-6a5f7d5fd16ls5000806a12.2.-pod-prod-05-eu; Tue, 01 Sep 2026
02:09:30 -0700 (PDT)
X-Received: by 2002:a05:6402:3509:b0:6a6:32f9:d7d0 with SMTP id
4fb4d7f45d1cf-6a632f9d92bmr10767327a12.21.1788253769808;
Tue, 01 Sep 2026 02:09:29 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1788253769; cv=none;
d=google.com; s=arc-20260327;
b=IZAEM5tGHmyYdFgsRnKIS+/aSgtJzl1/POBpU8v2ChaCNjDbaUns08HbDqqk/QMYoO
2J/h8R3fANmKSEo5FIocRVvwbpBEJ25LTMBUrM8nVycp6aARhajOW7Uv6FzKtXLqMPZx
xcRX4LaopV1jSMrHSKGC9EwWZ4H81bOjYZpn0m6NStLF6SP37OfktIRvpsBuFW28o52O
O+mrTmTQosYzB2DZcznOCHKwKCPgPoG3Pwuo3XVrgT3a3vAfMmernLCfvRaVIaAtlZwG
w7E7qeLM9b6UK+qdyATupAjj8BKLwWpZJT3kEuqCEzxorUdvqtdx2svnT/203+OafMWI
AB3g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20260327;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=SfZRa8H2WDMJkcsjpztb8rt8s89URmJ5lnAVHSoTHTw=;
fh=DvNWzYUbqLDEGKkj7xR+THG6wwif/P922HrkLzuVV6A=;
b=TpICbClod+5e+acQFx/GzD4UKTRQz8cOZrBWXGH0N6I16GXFEQIZSBeJhz3l/Hgjr+
R5CvxBw7uDr5i+naeFJ7D49rw5/y2Demx+sbhNpaRKCJ1ICHSFVi4lEy9XFouhsmExZg
DR9kkH8ap2b38ZQ+95VWRIaBxzmwdzDxktqy+9K5NVuw8d2rGllNQpZyY2rbBF3ofTnK
W191zmHDGtV5+7j5N/m7f3GbuUCqtaieT3hk6MXByHa2S3B9+1zRn4ecOMQHuArNubMr
I8amW0DXfPkggH85fT49xQCSaDf4Xdd/v/WZTBmBwRsK6uzeeO3HMaY66u+Rs5MS+Ukl
hEQQ==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=Zd9kJfAi;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com.
[209.85.220.41])
by mx.google.com with SMTPS id
ffacd0b85a97d-482fbb35a50sor2055461f8f.14.2026.09.01.02.09.29
for <linux-amarula@amarulasolutions.com>
(Google Transport Security);
Tue, 01 Sep 2026 02:09:29 -0700 (PDT)
Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Gm-Gg: AYBFou16Gv63eVyxg2izwD/KP98FV4hztJ6FZF22E8ESI9f1RyBJqgGsa+UnUaM2Xv+
A4+vTziB5k4ZZAegnGmxPqZaWRfa9q0dpHgPIBmO09vY/ZjgQPWV5cZuUj5hKwMxBMIv+wSPYs3
ifCx7oqYWb1DFokU93yGblh3+w+xvQ+WQ5Fg0FCt8xU9QwHoptpASN55w6ENjKWIIoPOZjHNpa8
5/7R2jaLu9sdwebgBpkcXE/q+gLGJfWhk3S71e43kp6q2DCictBVagdvWP2DL3txup82ZiNvuWC
5oZY15QuQA+AiQ6vroHybXW46q+WFFGBedWt8QdiuH/6Ng5Oa7a0eV8q//rFDWXFCgXiFhxezdO
cgVi39U6D39Jo0Dd6EfLcsQA/rZ/UgWSYRZBEgZCORAErhIKoYpIQIUIR8cazvvdaVNMnEAil1J
bEXZrmXPxBTiHFmvjOngmgpNoPsBl2CMB/1EA4mDlB7ytd4gZL1zGuBJzu1k3eP2ADyQnvrCLO0
K5I4K2xjQz0YOi6ixtzkE2vK2uCWYbZ0lBKsrYIqI/WcZ1OfPihGniesLaJuOqBeLLgWUetIur+
4G5zur8fRHW9VeQVb7dkRoLkxJbgGOuyh/TtiTpWwbopf6Hip6KzZ9DQFrU/Nxcj7Q==
X-Received: by 2002:a5d:4702:0:b0:481:bb82:3f31 with SMTP id
ffacd0b85a97d-482f79db522mr40181489f8f.10.1788253769303;
Tue, 01 Sep 2026 02:09:29 -0700 (PDT)
Received: from dario-ThinkPad-P14s-Gen-5.amarulasolutions.com
(host-87-9-102-148.retail.telecomitalia.it. [87.9.102.148])
by smtp.gmail.com with ESMTPSA id
ffacd0b85a97d-48442c425cesm3825273f8f.6.2026.09.01.02.09.28
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 01 Sep 2026 02:09:28 -0700 (PDT)
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: linux-kernel@vger.kernel.org
Cc: linux-amarula@amarulasolutions.com,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Peng Fan <peng.fan@nxp.com>,
Sebin Francis <sebin.francis@ti.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-clk@vger.kernel.org
Subject: [PATCH v11 1/2] clk: validate spread spectrum configuration
Date: Tue, 1 Sep 2026 11:05:17 +0200
Message-ID: <20260901090912.585681-2-dario.binacchi@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20260901090912.585681-1-dario.binacchi@amarulasolutions.com>
References: <20260901090912.585681-1-dario.binacchi@amarulasolutions.com>
MIME-Version: 1.0
X-Original-Sender: dario.binacchi@amarulasolutions.com
X-Original-Authentication-Results: mx.google.com; dkim=pass
header.i=@amarulasolutions.com header.s=google header.b=Zd9kJfAi;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
Content-Type: text/plain; charset="UTF-8"
Precedence: list
Mailing-list: list linux-amarula@amarulasolutions.com;
contact linux-amarula+owners@amarulasolutions.com
List-ID: <linux-amarula.amarulasolutions.com>
X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com
X-Google-Group-Id: 476853432473
List-Post:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>,
<mailto:linux-amarula@amarulasolutions.com>
List-Help:
<https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>,
<mailto:linux-amarula+help@amarulasolutions.com>
List-Archive:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/>
List-Unsubscribe:
<mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>,
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe>
|
| Series |
Support spread spectrum clocking for i.MX8M PLLs
|
|
Commit Message
Dario Binacchi
Sept. 1, 2026, 9:05 a.m. UTC
The spread spectrum configuration is passed to the provider's
set_spread_spectrum() callback without any validation, as clk-conf.c
only skips all-zero triplets from "assigned-clock-sscs". An invalid
device tree can hand providers a zero modulation frequency or a spread
ratio above 100%, and each provider would have to add the same checks
to protect e.g. divisions in its rate computations.
Fixes: c86814e70390 ("clk: Introduce clk_hw_set_spread_spectrum")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
(no changes since v1)
drivers/clk/clk.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Comments
On Tue, Sep 01, 2026 at 11:05:17AM +0200, Dario Binacchi wrote: >The spread spectrum configuration is passed to the provider's >set_spread_spectrum() callback without any validation, as clk-conf.c >only skips all-zero triplets from "assigned-clock-sscs". An invalid >device tree can hand providers a zero modulation frequency or a spread >ratio above 100%, and each provider would have to add the same checks >to protect e.g. divisions in its rate computations. > >Fixes: c86814e70390 ("clk: Introduce clk_hw_set_spread_spectrum") >Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> >--- > >(no changes since v1) > > drivers/clk/clk.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > >diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c >index fef87167a60b..208caf60eeb5 100644 >--- a/drivers/clk/clk.c >+++ b/drivers/clk/clk.c >@@ -2851,6 +2851,20 @@ int clk_hw_set_spread_spectrum(struct clk_hw *hw, const struct clk_spread_spectr > if (!hw) > return 0; > >+ switch (ss_conf->method) { >+ case CLK_SPREAD_NO: >+ break; >+ case CLK_SPREAD_CENTER: >+ case CLK_SPREAD_UP: >+ case CLK_SPREAD_DOWN: >+ if (!ss_conf->modfreq_hz || !ss_conf->spread_bp || >+ ss_conf->spread_bp > 10000) >+ return -EINVAL; I think sashiko comment is wrong. In [1], we reached an agreement that spread "in permyriad, i.e. 0.01%". So the input value must be the real value * 10000, saying 0.01% * 10000 [1] https://github.com/devicetree-org/dt-schema/pull/154 Regards Peng >+ break; >+ default: >+ return -EINVAL; >+ } >+ > core = hw->core; > > clk_prepare_lock(); >-- >2.43.0 > > To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
Hi Peng, On Wed, Sep 2, 2026 at 10:33 AM Peng Fan <peng.fan@oss.nxp.com> wrote: > > On Tue, Sep 01, 2026 at 11:05:17AM +0200, Dario Binacchi wrote: > >The spread spectrum configuration is passed to the provider's > >set_spread_spectrum() callback without any validation, as clk-conf.c > >only skips all-zero triplets from "assigned-clock-sscs". An invalid > >device tree can hand providers a zero modulation frequency or a spread > >ratio above 100%, and each provider would have to add the same checks > >to protect e.g. divisions in its rate computations. > > > >Fixes: c86814e70390 ("clk: Introduce clk_hw_set_spread_spectrum") > >Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> > >--- > > > >(no changes since v1) > > > > drivers/clk/clk.c | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > >diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > >index fef87167a60b..208caf60eeb5 100644 > >--- a/drivers/clk/clk.c > >+++ b/drivers/clk/clk.c > >@@ -2851,6 +2851,20 @@ int clk_hw_set_spread_spectrum(struct clk_hw *hw, const struct clk_spread_spectr > > if (!hw) > > return 0; > > > >+ switch (ss_conf->method) { > >+ case CLK_SPREAD_NO: > >+ break; > >+ case CLK_SPREAD_CENTER: > >+ case CLK_SPREAD_UP: > >+ case CLK_SPREAD_DOWN: > >+ if (!ss_conf->modfreq_hz || !ss_conf->spread_bp || > >+ ss_conf->spread_bp > 10000) > >+ return -EINVAL; > > I think sashiko comment is wrong. > In [1], we reached an agreement that spread "in permyriad, i.e. 0.01%". > So the input value must be the real value * 10000, saying 0.01% * 10000 The DT cell is a u32 holding the integer permyriad value, i.e. the ratio * 10000 as agreed in [1]: 1% is written as 100, 100% as 10000. extConfigValue[7:0] takes an integer percentage, so the conversion is a division by 100, not by 10000: depth DT value / 10000 / 100 0.1% 10 0 0 1% 100 0 1 3% 300 0 3 100% 10000 1 100 With integer arithmetic the current code programs 0% for any depth below 100%. I am sending the fix as the first patch of v12. [1] https://github.com/devicetree-org/dt-schema/pull/154 Thanks and regards, Dario > > [1] https://github.com/devicetree-org/dt-schema/pull/154 > > Regards > Peng > > >+ break; > >+ default: > >+ return -EINVAL; > >+ } > >+ > > core = hw->core; > > > > clk_prepare_lock(); > >-- > >2.43.0 > > > >
> Subject: Re: [PATCH v11 1/2] clk: validate spread spectrum > configuration > > Hi Peng, > NXP Confidential > On Wed, Sep 2, 2026 at 10:33 AM Peng Fan <peng.fan@oss.nxp.com> > wrote: > > > > On Tue, Sep 01, 2026 at 11:05:17AM +0200, Dario Binacchi wrote: > > >The spread spectrum configuration is passed to the provider's > > >set_spread_spectrum() callback without any validation, as clk-conf.c > > >only skips all-zero triplets from "assigned-clock-sscs". An invalid > > >device tree can hand providers a zero modulation frequency or a > > >spread ratio above 100%, and each provider would have to add the > same > > >checks to protect e.g. divisions in its rate computations. > > > > > >Fixes: c86814e70390 ("clk: Introduce clk_hw_set_spread_spectrum") > > >Signed-off-by: Dario Binacchi > <dario.binacchi@amarulasolutions.com> > > >--- > > > > > >(no changes since v1) > > > > > > drivers/clk/clk.c | 14 ++++++++++++++ > > > 1 file changed, 14 insertions(+) > > > > > >diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index > > >fef87167a60b..208caf60eeb5 100644 > > >--- a/drivers/clk/clk.c > > >+++ b/drivers/clk/clk.c > > >@@ -2851,6 +2851,20 @@ int clk_hw_set_spread_spectrum(struct > clk_hw *hw, const struct clk_spread_spectr > > > if (!hw) > > > return 0; > > > > > >+ switch (ss_conf->method) { > > >+ case CLK_SPREAD_NO: > > >+ break; > > >+ case CLK_SPREAD_CENTER: > > >+ case CLK_SPREAD_UP: > > >+ case CLK_SPREAD_DOWN: > > >+ if (!ss_conf->modfreq_hz || !ss_conf->spread_bp || > > >+ ss_conf->spread_bp > 10000) > > >+ return -EINVAL; > > > > I think sashiko comment is wrong. > > In [1], we reached an agreement that spread "in permyriad, i.e. > 0.01%". > > So the input value must be the real value * 10000, saying 0.01% * > > 10000 > > The DT cell is a u32 holding the integer permyriad value, i.e. the ratio * > 10000 as agreed in [1]: 1% is written as 100, 100% as 10000. > extConfigValue[7:0] takes an integer percentage, so the conversion is a > division by 100, not by 10000: > > depth DT value / 10000 / 100 > 0.1% 10 0 0 > 1% 100 0 1 > 3% 300 0 3 > 100% 10000 1 100 > > With integer arithmetic the current code programs 0% for any depth > below 100%. I am sending the fix as the first patch of v12. > ok, please include more pieces in your patch. The spread_bp field is documented as "Modulation percent in permyriad" (include/linux/clk-provider.h), where 1 unit = 0.01%, i.e. 10000 = 100%. So the > 10000 check here correctly rejects spreads above 100%. Actually 1000 should be enough. However, the existing KUnit test data in kunit_clk_assigned_rates.h uses: #define ASSIGNED_SSCS_0_SPREAD 30000 /* 300% in permyriad */ #define ASSIGNED_SSCS_1_SPREAD 40000 /* 400% in permyriad */ These values are above 10000 and would be rejected by the new validation. When clk_hw_set_spread_spectrum() returns -EINVAL, clk-conf.c prints an error but swallows it (rc = 0), and the dummy provider's set_spread_spectrum callback is never called. So the test assertions like: KUNIT_EXPECT_EQ(test, ctx->clk0.sscs.spread_bp, ASSIGNED_SSCS_0_SPREAD); will fail because ctx->clk0.sscs.spread_bp remains at its initial value. I believe the test values were intended to represent 3% and 4% spread (reasonable SSC values), which in permyriad should be 300 and 400, not 30000 and 40000. Similarly, the divisor in clk-scmi-oem.c: val = FIELD_PREP(..., ss_conf->spread_bp / 10000); should be / 10. ==> Here not / 100, because i.MX use 10 as %1 in SCMI firmware. The skip test data also has the same issue: .sscs = {50000, 60000, 3}, where 60000 should be 600 (6%) in permyriad. Could you fold a fix for the test data and clk-scmi-oem.c divisor into the series? Specifically: drivers/clk/kunit_clk_assigned_rates.h: ASSIGNED_SSCS_0_SPREAD: 30000 -> 300 (3%) ASSIGNED_SSCS_1_SPREAD: 40000 -> 400 (4%) drivers/clk/clk_test.c: .sscs = {50000, 60000, 3} -> {50000, 600, 3} (all six instances) drivers/clk/clk-scmi-oem.c: ss_conf->spread_bp / 10000 -> ss_conf->spread_bp / 10 Thanks, Peng. To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index fef87167a60b..208caf60eeb5 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2851,6 +2851,20 @@ int clk_hw_set_spread_spectrum(struct clk_hw *hw, const struct clk_spread_spectr if (!hw) return 0; + switch (ss_conf->method) { + case CLK_SPREAD_NO: + break; + case CLK_SPREAD_CENTER: + case CLK_SPREAD_UP: + case CLK_SPREAD_DOWN: + if (!ss_conf->modfreq_hz || !ss_conf->spread_bp || + ss_conf->spread_bp > 10000) + return -EINVAL; + break; + default: + return -EINVAL; + } + core = hw->core; clk_prepare_lock();