public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: chiffathefox <chiffathefoxx@gmail.com>
To: Marek Vasut <marex@denx.de>
Cc: chiffathefox <chiffathefoxx@gmail.com>,
	Andrew Goodbody <andrew.goodbody@linaro.org>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Kaustabh Chakraborty <kauschluss@disroot.org>,
	Lukasz Majewski <lukma@denx.de>,
	Maksim Kiselev <bigunclemax@gmail.com>,
	Minkyu Kang <mk7.kang@samsung.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Sam Protsenko <semen.protsenko@linaro.org>,
	Tom Rini <trini@konsulko.com>, Ye Li <ye.li@nxp.com>,
	u-boot@lists.denx.de
Subject: [PATCH 0/2] Improvements to the recent clock rework by marex.
Date: Thu, 15 Jan 2026 05:11:12 +0200	[thread overview]
Message-ID: <20260115031114.220888-1-chiffathefoxx@gmail.com> (raw)

Symptoms:
I ran into an issue with the generic ccf_clk_divider clock driver. ccf_clk_divider assumes that the pointer passed to clk_divider_recalc_rate() (https://github.com/u-boot/u-boot/blob/master/drivers/clk/clk-divider.c#L80) is the same that was kzalloc()'d during clock registration. This assumption was breaking when calling clk_get_rate() on a clock retrieved via clk_get_by_index(), since clk_get_by_index() returns a copy of `struct clk` rather than the original pointer. For example, in https://github.com/u-boot/u-boot/blob/master/drivers/serial/serial_s5p.c#L131 the serial driver retrieves a clock using clk_get_by_index(), and then indirectly passes a pointer to stack-allocated `struct clk` to clk_divider_recalc_rate(), which breaks the ccf_clk_divider driver.

Description:
The Clock API relies on the fact that you call it's functions with a pointer to the
kzalloc()'d `struct clk`, and not a copy of it. To ensure this, existing
clock drivers use ccf_clk_get_rate() and clk_get_by_id().
The clock rework path missed this fact, and instead was returning names
and pointers for the root device.

Testing:
I tested this on Samsung S10 (exynos9820 SoC) with a custom clock driver
and a device tree. Unfortunately, I don't own any other exynos devices
supported by u-boot.


chiffathefox (2):
  clk: clk_resolve_parent_clk(): resolve external clocks by id
  clk: exynos: do not reparent requested clock

 drivers/clk/clk-uclass.c | 7 ++++++-
 drivers/clk/exynos/clk.c | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.34.1

base-commit: d503633a36767d756c7de28305cf0de79440cbc0
branch: clk-rework-improvements

             reply	other threads:[~2026-01-15  4:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15  3:11 chiffathefox [this message]
2026-01-15  3:11 ` [PATCH 1/2] clk: clk_resolve_parent_clk(): resolve external clocks by id chiffathefox
2026-01-17  1:38   ` Marek Vasut
2026-01-19 16:59   ` Kaustabh Chakraborty
2026-01-15  3:11 ` [PATCH 2/2] clk: exynos: do not reparent requested clock chiffathefox
2026-01-19 17:00   ` Kaustabh Chakraborty

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=20260115031114.220888-1-chiffathefoxx@gmail.com \
    --to=chiffathefoxx@gmail.com \
    --cc=andrew.goodbody@linaro.org \
    --cc=ansuelsmth@gmail.com \
    --cc=bigunclemax@gmail.com \
    --cc=kauschluss@disroot.org \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=miquel.raynal@bootlin.com \
    --cc=mk7.kang@samsung.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=semen.protsenko@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=ye.li@nxp.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