linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Cc: Eric Anholt <eric@anholt.net>,
	dri-devel@lists.freedesktop.org,
	linux-rpi-kernel@lists.infradead.org,
	bcm-kernel-feedback-list@broadcom.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Tim Gover <tim.gover@raspberrypi.com>,
	Phil Elwell <phil@raspberrypi.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	linux-clk@vger.kernel.org
Subject: Re: [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT
Date: Wed, 26 Feb 2020 16:01:13 +0100	[thread overview]
Message-ID: <20200226150113.oqymkr6h2cxs2uia@gilmour.lan> (raw)
In-Reply-To: <71cd7b35af81ee91c3b4dc5e7c05760ecd590c5d.camel@suse.de>

[-- Attachment #1: Type: text/plain, Size: 6024 bytes --]

Hi Nicolas,

On Tue, Feb 25, 2020 at 05:00:56PM +0100, Nicolas Saenz Julienne wrote:
> On Mon, 2020-02-24 at 10:06 +0100, Maxime Ripard wrote:
> > The current firmware clock driver for the RaspberryPi can only be probed by
> > manually registering an associated platform_device.
> >
> > While this works fine for cpufreq where the device gets attached a clkdev
> > lookup, it would be tedious to maintain a table of all the devices using
> > one of the clocks exposed by the firmware.
> >
> > Since the DT on the other hand is the perfect place to store those
> > associations, make the firmware clocks driver probe-able through the device
> > tree so that we can represent it as a node.
>
> I'm not convinced this is the right approach, and if we decide to go this way,
> there are more changes to take into account.

This was actually a shameless bait to start that discussion, so I'm
glad it worked ;)

> For one, if we create a dt node for this driver, we'd have to delete the
> platform device creation in firmware/raspberrypi.c and then we'd be even able
> to bypass raspberrypi-cpufreq altogether by creating opp tables in dt. But
> there are reasons we didn't go that way at the time.

Right, I missed that one since the check for the firmware phandle was
preventing the double-probe to happen, but it's bad indeed.

> We've made an effort to avoid using dt for firmware interfaces whenever
> possible as, on one hand, it's arguable they don't fit device-tree's hardware
> description paradigm and, on the other, the lack of flexibility they impose
> once the binding is defined. VC4's firmware interfaces are not set in stone,
> nor standardized like SCMI, so the more flexible we are to future changes the
> better.

The device tree isn't just about the hardware though, but also
contains the state the bootloader / firmware left the hardware
in. You're mentionning SCMI, and SCMI clocks IDs are stored in the
device tree. Just like pen release addresses, PSCI function ids, etc.

The firmware IDs of these clocks shouldn't change too.

But you also raise a valid point with the lack of flexibility,
especially since the clock tree isn't that well understood.

> Another thing I'm not all that happy about it's how dynamic clock registering
> is handled in patch #22 (but I'll keep it here as relevant to the discussion):
>
> - Some of those fw managed clocks you're creating have their mmio counterpart
>   being registered by clk-bcm238. IMO either register one or the other, giving
>   precedence to the mmio counterpart. Note that for pllb, we deleted the
>   relevant code from clk-bcm2385.

Indeed, and it's really that part of the discussion I wanted to
start. For some reason, it looks like a good chunk of those clocks are
non-functional at the moment (they all report 0). If we're going to
use the firmware clocks as I did here, we'd have to modify most of the
device clocks used so far (UART, especially) to derive from the core
clock.

I wasn't really sure of the implications though, since it's my first
experience with the RPi clock tree.

> - The same way we were able to map the fw CPU clock into the clk tree
>   (pllb/pllb_arm) there are no reasons we shouldn't be able to do the same for
>   the VPU clocks. It's way nicer and less opaque to users (this being a
>   learning platform adds to the argument).

This would make the Linux clock tree match the one in hardware, which
would indeed be more readable to a beginner, but I see three main
drawbacks with this:

  - The parent / child relationship is already encoded in the firmware
    discovery mechanism. It's not used yet by the driver, because the
    firmware reports all of them as root clocks, but that's pretty
    easy to fix.

  - It would make the code far more complicated and confusing than it
    could, especially to beginners. And as far as I know, only the RPi
    is doing that, while pretty much all the other platforms either
    have the clock tree entirely defined, or rely on the firmware, but
    don't have an hybrid. So they would learn something that cannot
    really be applied to anywhere else.

  - I have no idea what the clock tree is supposed to look like :)

> - On top of that, having a special case for the CPU clock registration is
>   nasty. Lets settle for one solution and make everyone follow it.

It seemed to me that the CPU clock had a factor between the actual CPU
frequency and its clock? If not, then yeah we should definitely get
rid of it.

> - I don't see what's so bad about creating clock lookups. IIUC there are only
>   two clocks that need this special handling CPU & HDMI, It's manageable. You
>   don't even have to mess with the consumer driver, if there was ever to be a
>   dt provided mmio option to this clock.

V3D needs one too, and I might have missed a bunch of them in that
series given how the current debugging of the remaining issues turn
out to be. And clk_lookups are local to devices, so you need to factor
that by the number of devices you have.

Sure, it works, but it feels to me like that's going to be an issue
pretty fast, especially with the lookups on the way out?

> >  drivers/clk/bcm/clk-raspberrypi.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-
> > raspberrypi.c
> > index 1654fd0eedc9..94870234824c 100644
> > --- a/drivers/clk/bcm/clk-raspberrypi.c
> > +++ b/drivers/clk/bcm/clk-raspberrypi.c
> > @@ -255,15 +255,13 @@ static int raspberrypi_clk_probe(struct platform_device
> > *pdev)
> >  	struct raspberrypi_clk *rpi;
> >  	int ret;
> >
> > -	firmware_node = of_find_compatible_node(NULL, NULL,
> > -					"raspberrypi,bcm2835-firmware");
> > +	firmware_node = of_parse_phandle(dev->of_node, "raspberrypi,firmware",
> > 0);
>
> There is no such phandle in the upstream device tree. Maybe this was aimed at
> the downstream dt?

raspberrypi,firmware is the property, it points to the /soc/firmware
node that is defined in bcm2835-rpi.dtsi

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2020-02-26 15:01 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.6c896ace9a5a7840e9cec008b553cbb004ca1f91.1582533919.git-series.maxime@cerno.tech>
2020-02-24  9:06 ` [PATCH 05/89] clk: Return error code when of provider pointer is NULL Maxime Ripard
2020-03-12 23:13   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 06/89] dt-bindings: clock: Add a binding for the RPi Firmware clocks Maxime Ripard
2020-02-25 18:16   ` Rob Herring
2020-03-12 23:14     ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT Maxime Ripard
2020-02-25 16:00   ` Nicolas Saenz Julienne
2020-02-26 15:01     ` Maxime Ripard [this message]
2020-02-28 19:57       ` Nicolas Saenz Julienne
2020-03-01 12:16   ` Stefan Wahren
2020-03-23 15:13     ` Maxime Ripard
2020-02-24  9:06 ` [PATCH 08/89] clk: bcm: rpi: Statically init clk_init_data Maxime Ripard
2020-02-25 16:05   ` Nicolas Saenz Julienne
2020-02-24  9:06 ` [PATCH 09/89] clk: bcm: rpi: Use clk_hw_register for pllb_arm Maxime Ripard
2020-02-25 16:11   ` Nicolas Saenz Julienne
2020-03-12 23:17   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 10/89] clk: bcm: rpi: Remove global pllb_arm clock pointer Maxime Ripard
2020-02-25 16:13   ` Nicolas Saenz Julienne
2020-02-26 14:26     ` Maxime Ripard
2020-02-26 14:57       ` Nicolas Saenz Julienne
2020-02-24  9:06 ` [PATCH 11/89] clk: bcm: rpi: Make sure pllb_arm is removed Maxime Ripard
2020-02-25 16:14   ` Nicolas Saenz Julienne
2020-03-12 23:20   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 12/89] clk: bcm: rpi: Remove pllb_arm_lookup global pointer Maxime Ripard
2020-02-25 16:16   ` Nicolas Saenz Julienne
2020-03-12 23:21   ` Stephen Boyd
2020-03-13  1:13   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 13/89] clk: bcm: rpi: Switch to clk_hw_register_clkdev Maxime Ripard
2020-02-25 16:17   ` Nicolas Saenz Julienne
2020-03-13  1:12   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 14/89] clk: bcm: rpi: Make sure the clkdev lookup is removed Maxime Ripard
2020-02-25 16:19   ` Nicolas Saenz Julienne
2020-03-13  1:11   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 15/89] clk: bcm: rpi: Create a data structure for the clocks Maxime Ripard
2020-02-25 16:24   ` Nicolas Saenz Julienne
2020-03-13  1:11   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 16/89] clk: bcm: rpi: Add clock id to data Maxime Ripard
2020-02-24 19:25   ` Stefan Wahren
2020-02-25  9:54     ` Maxime Ripard
2020-02-25 14:33       ` Nicolas Saenz Julienne
2020-02-25 16:24   ` Nicolas Saenz Julienne
2020-03-13  1:11   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 17/89] clk: bcm: rpi: Pass the clocks data to the firmware function Maxime Ripard
2020-02-25 16:26   ` Nicolas Saenz Julienne
2020-03-13  1:09   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 18/89] clk: bcm: rpi: Rename is_prepared function Maxime Ripard
2020-02-25 16:45   ` Nicolas Saenz Julienne
2020-03-13  1:09   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 19/89] clk: bcm: rpi: Split pllb clock hooks Maxime Ripard
2020-03-13  1:08   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 20/89] clk: bcm: rpi: Make the PLLB registration function return a clk_hw Maxime Ripard
2020-03-13  1:01   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 21/89] clk: bcm: rpi: Add DT provider for the clocks Maxime Ripard
2020-03-13  1:01   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 22/89] clk: bcm: rpi: Discover the firmware clocks Maxime Ripard
2020-02-24 16:47   ` kbuild test robot
2020-02-24 16:47   ` [PATCH] clk: bcm: rpi: fix noderef.cocci warnings kbuild test robot
2020-02-24 18:15   ` [PATCH 22/89] clk: bcm: rpi: Discover the firmware clocks Florian Fainelli
2020-02-26 14:15     ` Maxime Ripard
2020-02-24 20:24   ` kbuild test robot
2020-03-13  1:08   ` Stephen Boyd
2020-02-24  9:06 ` [PATCH 27/89] clk: bcm: Add BCM2711 DVP driver Maxime Ripard
2020-03-13  1:00   ` Stephen Boyd
2020-03-23 10:56     ` Maxime Ripard
2020-03-25  2:20       ` Stephen Boyd

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=20200226150113.oqymkr6h2cxs2uia@gilmour.lan \
    --to=maxime@cerno.tech \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric@anholt.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mturquette@baylibre.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=phil@raspberrypi.com \
    --cc=sboyd@kernel.org \
    --cc=tim.gover@raspberrypi.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).