From: Tom Rini <trini@konsulko.com>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: Andrew Goodbody <andrew.goodbody@linaro.org>,
Simon Glass <sjg@chromium.org>,
u-boot-amlogic@groups.io, u-boot@lists.denx.de,
Paul Barker <paul@pbarker.dev>,
uboot-snps-arc@synopsys.com,
Dai Okamura <okamura.dai@socionext.com>,
Aspeed BMC SW team <BMC-SW@aspeedtech.com>,
Joel Stanley <joel@jms.id.au>,
GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
adsp-linux@analog.com, uboot-stm32@st-md-mailman.stormreply.com,
Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Stefan Roese <stefan.roese@mailbox.org>,
Yao Zi <ziyao@disroot.org>,
Leo Yu-Chi Liang <ycliang@andestech.com>,
Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Philipp Tomsich <philipp.tomsich@vrull.eu>,
Kever Yang <kever.yang@rock-chips.com>,
Quentin Schulz <quentin.schulz@cherry.de>,
Lukasz Czechowski <lukasz.czechowski@thaumatec.com>,
Jonas Karlman <jonas@kwiboo.se>,
Finley Xiao <finley.xiao@rock-chips.com>,
Joseph Chen <chenjh@rock-chips.com>,
Elaine Zhang <zhangqing@rock-chips.com>,
Heiko Stuebner <heiko@sntech.de>,
Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
Peng Fan <peng.fan@nxp.com>,
Liviu Dudau <liviu.dudau@foss.arm.com>,
Michal Simek <michal.simek@amd.com>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Patrick Delaunay <patrick.delaunay@foss.st.com>,
Ye Li <ye.li@nxp.com>, Sam Protsenko <semen.protsenko@linaro.org>,
Marek Vasut <marex@denx.de>, Alice Guo <alice.guo@nxp.com>,
Valentin Caron <valentin.caron@foss.st.com>,
Padmarao Begari <padmarao.begari@amd.com>,
Minda Chen <minda.chen@starfivetech.com>,
Hal Feng <hal.feng@starfivetech.com>,
Sumit Garg <sumit.garg@kernel.org>,
Tien Fong Chee <tien.fong.chee@altera.com>,
Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>,
Naresh Kumar Ravulapalli <nareshkumar.ravulapalli@altera.com>,
Muhammad Hazim Izzat Zamri
<muhammad.hazim.izzat.zamri@altera.com>,
Tingting Meng <tingting.meng@altera.com>,
Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
Ryan Chen <ryan_chen@aspeedtech.com>,
Chia-Wei Wang <chiawei_wang@aspeedtech.com>,
Minkyu Kang <mk7.kang@samsung.com>,
Heiko Schocher <hs@nabladev.com>,
Jonathan Currier <dullfire@yahoo.com>,
Ryder Lee <ryder.lee@mediatek.com>,
Weijie Gao <weijie.gao@mediatek.com>,
Chunfeng Yun <chunfeng.yun@mediatek.com>,
Sam Shih <sam.shih@mediatek.com>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
Thierry Reding <treding@nvidia.com>,
Nathan Barrett-Morrison <nathan.morrison@timesys.com>,
Greg Malysa <malysagreg@gmail.com>,
Ian Roberts <ian.roberts@timesys.com>,
Vasileios Bimpikas <vasileios.bimpikas@analog.com>,
Utsav Agarwal <utsav.agarwal@analog.com>,
Arturs Artamonovs <arturs.artamonovs@analog.com>,
Gabriel Fernandez <gabriel.fernandez@foss.st.com>,
Marek Vasut <marek.vasut@mailbox.org>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>
Subject: Re: [PATCH 00/24] clk: Remove passing of negative errors through unsigned return
Date: Sun, 19 Oct 2025 10:21:04 -0600 [thread overview]
Message-ID: <20251019162104.GP6688@bill-the-cat> (raw)
In-Reply-To: <CAPVz0n2seuNyeJzhYgintpj0OR9qzutYER8LxxLDkssPtQbevg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 10708 bytes --]
On Sun, Oct 19, 2025 at 04:45:24PM +0300, Svyatoslav Ryhel wrote:
> нд, 19 жовт. 2025 р. о 16:05 Simon Glass <sjg@chromium.org> пише:
> >
> > Hi Tom, Andrew,
> >
> > On Sat, 18 Oct 2025 at 15:04, Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Sat, Oct 18, 2025 at 09:34:42AM +0100, Simon Glass wrote:
> > > > Hi Andrew,
> > > >
> > > > On Wed, 15 Oct 2025 at 15:32, Andrew Goodbody
> > > > <andrew.goodbody@linaro.org> wrote:
> > > > >
> > > > > This series removes the passing of negative errors through the .get_rate
> > > > > function in the clk_ops struct. This function returns an unsigned long.
> > > > > The only value guaranteed to not be a valid clock rate is 0. This will
> > > > > also bring the drivers more in sync with Linux to allow for easier code
> > > > > porting and other maintenance in the future.
> > > > > Another series will address the calling of clk_get_rate and associated
> > > > > error handling.
> > > >
> > > > Some indication of the problem you ran into would be useful here.
> > >
> > > The problem statement is in the paragraph you're quoting. The numerical
> > > value of -ENOENT is a valid clock rate.
> >
> > No, I mean a problem with a board, or something like that. We are
> > talking here about not being able to return a valid clock rate between
> > 4294967040 and 4294967295, which is only even a theoretical problem on
> > 32-bit machines. So I think it is reasonable to include a motivation.
> >
> >
> > >
> > > > > Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
> > > > > ---
> > > > > Andrew Goodbody (24):
> > > > > clk: meson: Remove negative error returns from clk_get_rate
> > > > > clk: sifive: Remove negative error returns from clk_get_rate
> > > > > clk: armada-37xx: Remove negative error returns from clk_get_rate
> > > > > clk: thead: th1520-ap: Remove negative error returns from clk_get_rate
> > > > > clk: ccf: Remove negative error returns from clk_get_rate
> > > > > clk: at91: Remove negative error returns from clk_get_rate
> > > > > clk: renesas: Remove negative error returns from clk_get_rate
> > > > > clk: rockchip: Remove negative error returns from clk_get_rate
> > > > > clk: Remove negative error returns from clk_get_rate
> > > > > clk: starfive: Remove negative error returns from clk_get_rate
> > > > > clk: altera: Remove negative error returns from clk_get_rate
> > > > > clk: uniphier: Remove negative error returns from clk_get_rate
> > > > > clk: aspeed: Remove negative error returns from clk_get_rate
> > > > > clk: nuvoton: Remove negative error returns from clk_get_rate
> > > > > clk: exynos: Remove negative error returns from clk_get_rate
> > > > > clk: imx: Remove negative error returns from clk_get_rate
> > > > > clk: ti: Remove negative error returns from clk_get_rate
> > > > > clk: mediatek: Remove negative error returns from clk_get_rate
> > > > > clk: owl: Remove negative error returns from clk_get_rate
> > > > > clk: tegra: Remove negative error returns from clk_get_rate
> > > > > clk: adi: Remove negative error returns from clk_get_rate
> > > > > clk: sophgo: Remove negative error returns from clk_get_rate
> > > > > clk: stm32: Remove negative error returns from clk_get_rate
> > > > > clk: x86: Remove negative error returns from clk_get_rate
> > > > >
> > > > > drivers/clk/adi/clk-shared.c | 2 +-
> > > > > drivers/clk/altera/clk-agilex.c | 2 +-
> > > > > drivers/clk/altera/clk-agilex5.c | 2 +-
> > > > > drivers/clk/altera/clk-n5x.c | 2 +-
> > > > > drivers/clk/aspeed/clk_ast2500.c | 2 +-
> > > > > drivers/clk/aspeed/clk_ast2600.c | 2 +-
> > > > > drivers/clk/at91/compat.c | 6 ++--
> > > > > drivers/clk/clk-hsdk-cgu.c | 2 +-
> > > > > drivers/clk/clk-uclass.c | 4 +--
> > > > > drivers/clk/clk.c | 2 +-
> > > > > drivers/clk/clk_fixed_factor.c | 4 +--
> > > > > drivers/clk/clk_k210.c | 6 ++--
> > > > > drivers/clk/clk_sandbox.c | 4 +--
> > > > > drivers/clk/clk_scmi.c | 4 +--
> > > > > drivers/clk/clk_vexpress_osc.c | 2 +-
> > > > > drivers/clk/clk_zynq.c | 4 +--
> > > > > drivers/clk/clk_zynqmp.c | 40 ++++++++++-----------
> > > > > drivers/clk/exynos/clk-exynos7420.c | 2 +-
> > > > > drivers/clk/imx/clk-imx8qm.c | 6 ++--
> > > > > drivers/clk/imx/clk-imx8qxp.c | 6 ++--
> > > > > drivers/clk/imx/clk-imxrt1170.c | 2 +-
> > > > > drivers/clk/imx/clk-pllv3.c | 2 +-
> > > > > drivers/clk/intel/clk_intel.c | 2 +-
> > > > > drivers/clk/mediatek/clk-mtk.c | 2 +-
> > > > > drivers/clk/meson/a1.c | 10 +++---
> > > > > drivers/clk/meson/axg.c | 10 +++---
> > > > > drivers/clk/meson/g12a.c | 36 +++++++++----------
> > > > > drivers/clk/meson/gxbb.c | 20 +++++------
> > > > > drivers/clk/mvebu/armada-37xx-periph.c | 2 +-
> > > > > drivers/clk/mvebu/armada-37xx-tbg.c | 2 +-
> > > > > drivers/clk/nuvoton/clk_npcm.c | 10 +++---
> > > > > drivers/clk/owl/clk_owl.c | 2 +-
> > > > > drivers/clk/renesas/clk-rcar-gen2.c | 8 ++---
> > > > > drivers/clk/renesas/rzg2l-cpg.c | 8 ++---
> > > > > drivers/clk/rockchip/clk_px30.c | 24 ++++++-------
> > > > > drivers/clk/rockchip/clk_rk3036.c | 2 +-
> > > > > drivers/clk/rockchip/clk_rk3066.c | 8 ++---
> > > > > drivers/clk/rockchip/clk_rk3128.c | 6 ++--
> > > > > drivers/clk/rockchip/clk_rk3188.c | 6 ++--
> > > > > drivers/clk/rockchip/clk_rk322x.c | 4 +--
> > > > > drivers/clk/rockchip/clk_rk3288.c | 6 ++--
> > > > > drivers/clk/rockchip/clk_rk3308.c | 26 +++++++-------
> > > > > drivers/clk/rockchip/clk_rk3328.c | 6 ++--
> > > > > drivers/clk/rockchip/clk_rk3368.c | 8 ++---
> > > > > drivers/clk/rockchip/clk_rk3399.c | 12 +++----
> > > > > drivers/clk/rockchip/clk_rk3528.c | 20 +++++------
> > > > > drivers/clk/rockchip/clk_rk3568.c | 62 ++++++++++++++++----------------
> > > > > drivers/clk/rockchip/clk_rk3576.c | 36 +++++++++----------
> > > > > drivers/clk/rockchip/clk_rk3588.c | 32 ++++++++---------
> > > > > drivers/clk/rockchip/clk_rv1108.c | 4 +--
> > > > > drivers/clk/rockchip/clk_rv1126.c | 52 +++++++++++++--------------
> > > > > drivers/clk/sifive/sifive-prci.c | 8 ++---
> > > > > drivers/clk/sophgo/clk-cv1800b.c | 2 +-
> > > > > drivers/clk/starfive/clk-jh7110-pll.c | 2 +-
> > > > > drivers/clk/stm32/clk-stm32-core.c | 4 +--
> > > > > drivers/clk/stm32/clk-stm32f.c | 6 ++--
> > > > > drivers/clk/stm32/clk-stm32h7.c | 4 +--
> > > > > drivers/clk/tegra/tegra-car-clk.c | 2 +-
> > > > > drivers/clk/tegra/tegra186-clk.c | 2 +-
> > > > > drivers/clk/thead/clk-th1520-ap.c | 2 +-
> > > > > drivers/clk/ti/clk-am3-dpll-x2.c | 4 +--
> > > > > drivers/clk/ti/clk-divider.c | 4 +--
> > > > > drivers/clk/ti/clk-mux.c | 2 +-
> > > > > drivers/clk/ti/clk-sci.c | 2 +-
> > > > > drivers/clk/uniphier/clk-uniphier-core.c | 2 +-
> > > > > 65 files changed, 290 insertions(+), 290 deletions(-)
> > > > > ---
> > > > > base-commit: ecdc3872a767fb045be3296d4317ae978a14b022
> > > > > change-id: 20251010-clk_ops-3b7cc9ccd070
> > > > >
> > > > > Best regards,
> > > > > --
> > > > > Andrew Goodbody <andrew.goodbody@linaro.org>
> > > > >
> > > >
> > > > If you don't return an error, we cannot tell if the operation
> > > > succeeded, or not. U-Boot needs to be deterministic and we need to be
> > > > able to debug errors and detect them at runtime.
> > > >
> > > > We use ulong for the return value as a bit of a compromise, since it
> > > > is inefficient to use 64-bit on a 32-bit machine. Ideally it would be
> > > > long, but some clock rates are 3GHz and it would be confusing to cast
> > > > to ulong before using the value.
> > > >
> > > > An alternative we discussed was to return an integer error with the
> > > > clock rate returned in a parameter, but that seemed less efficient.
> > > >
> > > > With 64-bit machines, there really isn't a problem. Just checking for
> > > > a negative value is good enough, since the clock rate isn't going to
> > > > be 9 exahertz(?). Values between -CONFIG_ERR_PTR_OFFSET and 0 are
> > > > errors and are defined to be so.
> > > >
> > > > If you want clk_get_rate() to work like Linux (suppress / ignore
> > > > errors?), that's fine, but please create a clk_get_rate_err() (or
> > > > similar) which actually returns the correct error, and keep the error
> > > > return on the uclass interface. It is not uncommon to have the uclass
> > > > do some processing on values passed to/from driver. This allows people
> > > > who care to obtain the error.
> > >
> > > This is moving things in the right direction of having the error
> > > reporting and handling done where it can be done correctly. If there's
> > > further parts of the Linux kernel-like API we need, we can take those
> > > next.
> >
> > Here is part of the patch:
> >
> > --- a/drivers/clk/meson/a1.c
> > +++ b/drivers/clk/meson/a1.c
> > @@ -359,7 +359,7 @@ static ulong meson_div_get_rate(struct clk *clk,
> > unsigned long id)
> >
> > info = meson_clk_get_info(clk, id, MESON_CLK_DIV);
> > if (IS_ERR(info))
> > - return PTR_ERR(info);
> > + return 0;
> >
> > I don't see anything in that fragment other than just ignoring errors.
> >
>
> I agree with Simon. This patchset may cause a lot of problems for all
> boards it changes in case clk ops fail, since it silences all error
> returns. Any clock error will be untrackable unless you know where and
> what to look specifically.
I think it's worth going back to the original thread:
https://lore.kernel.org/u-boot/f5c94319-8ef8-459d-88b2-836702779cfb@linaro.org/
As part of the problem is that what we have today does not work. This is
why I'm think it's OK to first return 0, always, as the invalid clock
rate and then re-introduce error checking that can work.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-10-20 4:32 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 14:32 [PATCH 00/24] clk: Remove passing of negative errors through unsigned return Andrew Goodbody
2025-10-15 14:32 ` [PATCH 01/24] clk: meson: Remove negative error returns from clk_get_rate Andrew Goodbody
2025-10-18 8:34 ` Simon Glass
2025-10-15 14:32 ` [PATCH 02/24] clk: sifive: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 03/24] clk: armada-37xx: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 04/24] clk: thead: th1520-ap: " Andrew Goodbody
2025-10-16 4:53 ` Yao Zi
2025-10-15 14:32 ` [PATCH 05/24] clk: ccf: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 06/24] clk: at91: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 07/24] clk: renesas: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 08/24] clk: rockchip: " Andrew Goodbody
2025-10-19 20:28 ` Jonas Karlman
2025-10-20 12:03 ` Andrew Goodbody
2025-10-20 14:23 ` Tom Rini
2025-10-20 15:30 ` Andrew Goodbody
2025-10-20 15:03 ` Jonas Karlman
2025-10-20 15:57 ` Andrew Goodbody
2025-10-15 14:32 ` [PATCH 09/24] clk: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 10/24] clk: starfive: " Andrew Goodbody
2025-10-17 6:16 ` Hal Feng
2025-10-15 14:32 ` [PATCH 11/24] clk: altera: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 12/24] clk: uniphier: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 13/24] clk: aspeed: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 14/24] clk: nuvoton: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 15/24] clk: exynos: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 16/24] clk: imx: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 17/24] clk: ti: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 18/24] clk: mediatek: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 19/24] clk: owl: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 20/24] clk: tegra: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 21/24] clk: adi: " Andrew Goodbody
2025-10-17 4:02 ` Greg Malysa
2025-10-15 14:32 ` [PATCH 22/24] clk: sophgo: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 23/24] clk: stm32: " Andrew Goodbody
2025-10-16 7:37 ` Patrice CHOTARD
2025-10-15 14:32 ` [PATCH 24/24] clk: x86: " Andrew Goodbody
2025-10-18 8:34 ` [PATCH 00/24] clk: Remove passing of negative errors through unsigned return Simon Glass
2025-10-18 14:04 ` Tom Rini
2025-10-18 18:16 ` Philipp Tomsich
2025-10-19 13:05 ` Simon Glass
2025-10-19 13:45 ` Svyatoslav Ryhel
2025-10-19 16:21 ` Tom Rini [this message]
2025-10-19 18:28 ` Simon Glass
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=20251019162104.GP6688@bill-the-cat \
--to=trini@konsulko.com \
--cc=BMC-SW@aspeedtech.com \
--cc=Eugeniy.Paltsev@synopsys.com \
--cc=GSS_MTK_Uboot_upstream@mediatek.com \
--cc=adsp-linux@analog.com \
--cc=alice.guo@nxp.com \
--cc=alif.zakuan.yuslaimi@altera.com \
--cc=andrew.goodbody@linaro.org \
--cc=arturs.artamonovs@analog.com \
--cc=chenjh@rock-chips.com \
--cc=chiawei_wang@aspeedtech.com \
--cc=chunfeng.yun@mediatek.com \
--cc=clamor95@gmail.com \
--cc=dario.binacchi@amarulasolutions.com \
--cc=dullfire@yahoo.com \
--cc=finley.xiao@rock-chips.com \
--cc=gabriel.fernandez@foss.st.com \
--cc=hal.feng@starfivetech.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=heiko@sntech.de \
--cc=hs@nabladev.com \
--cc=ian.roberts@timesys.com \
--cc=iwamatsu@nigauri.org \
--cc=joel@jms.id.au \
--cc=jonas@kwiboo.se \
--cc=kever.yang@rock-chips.com \
--cc=liviu.dudau@foss.arm.com \
--cc=lukasz.czechowski@thaumatec.com \
--cc=lukma@denx.de \
--cc=malysagreg@gmail.com \
--cc=manivannan.sadhasivam@linaro.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=marek.vasut@mailbox.org \
--cc=marex@denx.de \
--cc=michal.simek@amd.com \
--cc=minda.chen@starfivetech.com \
--cc=miquel.raynal@bootlin.com \
--cc=mk7.kang@samsung.com \
--cc=muhammad.hazim.izzat.zamri@altera.com \
--cc=nareshkumar.ravulapalli@altera.com \
--cc=nathan.morrison@timesys.com \
--cc=neil.armstrong@linaro.org \
--cc=okamura.dai@socionext.com \
--cc=padmarao.begari@amd.com \
--cc=patrice.chotard@foss.st.com \
--cc=patrick.delaunay@foss.st.com \
--cc=paul@pbarker.dev \
--cc=peng.fan@nxp.com \
--cc=philipp.tomsich@vrull.eu \
--cc=quentin.schulz@cherry.de \
--cc=ryan_chen@aspeedtech.com \
--cc=ryder.lee@mediatek.com \
--cc=sam.shih@mediatek.com \
--cc=seanga2@gmail.com \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=stefan.roese@mailbox.org \
--cc=sumit.garg@kernel.org \
--cc=tien.fong.chee@altera.com \
--cc=tingting.meng@altera.com \
--cc=treding@nvidia.com \
--cc=u-boot-amlogic@groups.io \
--cc=u-boot@lists.denx.de \
--cc=uboot-snps-arc@synopsys.com \
--cc=uboot-stm32@st-md-mailman.stormreply.com \
--cc=utsav.agarwal@analog.com \
--cc=valentin.caron@foss.st.com \
--cc=vasileios.bimpikas@analog.com \
--cc=weijie.gao@mediatek.com \
--cc=ycliang@andestech.com \
--cc=ye.li@nxp.com \
--cc=zhangqing@rock-chips.com \
--cc=ziyao@disroot.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