diff mbox series

clk: Mark fwnodes when their clock provider is added

Message ID 20210210114435.122242-1-tudor.ambarus@microchip.com
State Superseded
Headers show
Series clk: Mark fwnodes when their clock provider is added | expand

Commit Message

Tudor Ambarus Feb. 10, 2021, 11:44 a.m. UTC
This is a follow-up for:
commit 3c9ea42802a1 ("clk: Mark fwnodes when their clock provider is added/removed")

The above commit updated the deprecated of_clk_add_provider(),
but missed to update the preferred of_clk_add_hw_provider().
Update it now.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 drivers/clk/clk.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Saravana Kannan March 30, 2021, 4:26 p.m. UTC | #1
On Tue, Mar 30, 2021 at 8:42 AM Guenter Roeck <linux@roeck-us.net> wrote:
>

> On Wed, Feb 10, 2021 at 01:44:34PM +0200, Tudor Ambarus wrote:

> > This is a follow-up for:

> > commit 3c9ea42802a1 ("clk: Mark fwnodes when their clock provider is added/removed")

> >

> > The above commit updated the deprecated of_clk_add_provider(),

> > but missed to update the preferred of_clk_add_hw_provider().

> > Update it now.

> >

> > Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>

> > Reviewed-by: Saravana Kannan <saravanak@google.com>

> > ---

> >  drivers/clk/clk.c | 2 ++

> >  1 file changed, 2 insertions(+)

> >

> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c

> > index 27ff90eacb1f..9370e4dfecae 100644

> > --- a/drivers/clk/clk.c

> > +++ b/drivers/clk/clk.c

> > @@ -4594,6 +4594,8 @@ int of_clk_add_hw_provider(struct device_node *np,

> >       if (ret < 0)

> >               of_clk_del_provider(np);

> >

> > +     fwnode_dev_initialized(&np->fwnode, true);

> > +

>

> This causes a crash when booting raspi2 images in qemu.

>

> [   22.123618] Unable to handle kernel NULL pointer dereference at virtual address 00000028

> [   22.123830] pgd = (ptrval)

> [   22.123992] [00000028] *pgd=00000000

> [   22.124579] Internal error: Oops: 5 [#1] SMP ARM

> ...

> [   22.141624] [<c0a2f4d8>] (of_clk_add_hw_provider) from [<c0a2f54c>] (devm_of_clk_add_hw_provider+0x48/0x80)

> [   22.141819] [<c0a2f54c>] (devm_of_clk_add_hw_provider) from [<c0a43ad8>] (raspberrypi_clk_probe+0x25c/0x384)

> [   22.141976] [<c0a43ad8>] (raspberrypi_clk_probe) from [<c0c18da0>] (platform_probe+0x5c/0xb8)

> [   22.142114] [<c0c18da0>] (platform_probe) from [<c0c16654>] (really_probe+0xf0/0x39c)

> [   22.142246] [<c0c16654>] (really_probe) from [<c0c16968>] (driver_probe_device+0x68/0xc0)

> [   22.142377] [<c0c16968>] (driver_probe_device) from [<c0c14834>] (bus_for_each_drv+0x84/0xc8)...

>

> np can (and will) be NULL here. See of_clk_set_defaults().


Thanks for the report. It was reported earlier by Marek and there's a
discussion going on about it in the thread.

-Saravana
diff mbox series

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 27ff90eacb1f..9370e4dfecae 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -4594,6 +4594,8 @@  int of_clk_add_hw_provider(struct device_node *np,
 	if (ret < 0)
 		of_clk_del_provider(np);
 
+	fwnode_dev_initialized(&np->fwnode, true);
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(of_clk_add_hw_provider);