Thread (1 message) 1 message, 1 author, 2021-03-31

Re: [PATCH] clk: Mark fwnodes when their clock provider is added

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2021-03-31 07:05:50
Also in: linux-clk, linux-pm, lkml

Hi Stephen,

On Wed, Mar 31, 2021 at 4:22 AM Stephen Boyd [off-list ref] wrote:
Quoting Geert Uytterhoeven (2021-03-29 23:58:23)
quoted
On Tue, Mar 30, 2021 at 3:53 AM Stephen Boyd [off-list ref] wrote:
quoted
Quoting Saravana Kannan (2021-03-29 16:28:20)
quoted
On Mon, Mar 29, 2021 at 2:25 PM Stephen Boyd [off-list ref] wrote:
quoted
Quoting Geert Uytterhoeven (2021-03-26 11:29:55)
quoted
On Fri, Mar 26, 2021 at 7:13 PM Stephen Boyd [off-list ref] wrote:
quoted
Quoting Nicolas Saenz Julienne (2021-03-25 11:25:24)
quoted
quoted
This patch mainly revealed that clk/bcm/clk-raspberrypi.c driver calls
devm_of_clk_add_hw_provider(), with a device pointer, which has a NULL
dev->of_node. I'm not sure if adding a check for a NULL np in
of_clk_add_hw_provider() is a right fix, though.
I believe the right fix is not to call 'devm_of_clk_add_hw_provider()' if
'pdev->dev.of_node == NULL'. In such case, which is RPi3's, only the CPU clock
is used, and it's defined and queried later through
devm_clk_hw_register_clkdev().

@Marek, I don't mind taking care of it if it's OK with you.
Ah I see this is related to the patch I just reviewed. Can you reference
this in the commit text? And instead of putting the change into the clk
provider let's check for NULL 'np' in of_clk_add_hw_provider() instead
and return 0 if there's nothing to do. That way we don't visit this
problem over and over again.
I'm not sure the latter is what we reall want: shouldn't calling
*of*_clk_add_hw_provider() with a NULL np be a bug in the provider?
I don't have a strong opinion either way. Would it be useful if the
function returned an error when 'np' is NULL?
I lean towards returning an error. Not a strong opinion either.
Does it have any use?
of_clk_del_provider() removes the first provider found with node == NULL.
If there are two drivers calling of_clk_add_hw_provider(), and one of
hem calls of_clk_del_provider() later, the wrong provider may be
removed from the list.
So you're saying we shouldn't add a NULL device node pointer to the list
so that this can't happen? That doesn't mean returning an error from
of_clk_add_hw_provider() would be useful though.
of_clk_add_hw_provider() can return 0 if np == NULL and
of_clk_del_provider() can return early if np == NULL too.
I don't know if I grasp all meanings of the above.

The main question is if it is valid for a driver to call
of_clk_add_hw_provider()
with np == NULL.
  - If yes, should that register the provider?
      - If yes, how to handle two drivers calling of_clk_add_hw_provider()
        with np = NULL, as their unregistration order is not guaranteed to
        be correct.

If no, is that something to ignore (0), or a bug (error)?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help