* [PATCH] memory: jz4780-nemc: publish drvdata before creating children
@ 2026-06-16 0:57 Pengpeng Hou
2026-06-30 17:22 ` Krzysztof Kozlowski
0 siblings, 1 reply; 4+ messages in thread
From: Pengpeng Hou @ 2026-06-16 0:57 UTC (permalink / raw)
To: Paul Cercueil, Krzysztof Kozlowski, linux-mips, linux-kernel; +Cc: Pengpeng Hou
The NEMC child drivers can call exported helpers that fetch the parent
controller state with dev_get_drvdata(dev->parent). jz4780_nemc_probe()
currently creates child platform devices before storing the controller
pointer in the parent drvdata, so a child that probes immediately can
observe a NULL parent drvdata pointer.
Store the controller pointer before creating child devices. Also
depopulate child devices during remove before disabling the controller
clock so child teardown still runs while the parent resources are
available.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/memory/jz4780-nemc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c
index 1a8161514d03..1c1d1d019f77 100644
--- a/drivers/memory/jz4780-nemc.c
+++ b/drivers/memory/jz4780-nemc.c
@@ -331,6 +331,8 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
return -EINVAL;
}
+ platform_set_drvdata(pdev, nemc);
+
/*
* Iterate over child devices, check that they do not conflict with
* each other, and register child devices for them. If a child device
@@ -379,7 +381,6 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
}
}
- platform_set_drvdata(pdev, nemc);
dev_info(dev, "JZ4780 NEMC initialised\n");
return 0;
}
@@ -388,6 +389,7 @@ static void jz4780_nemc_remove(struct platform_device *pdev)
{
struct jz4780_nemc *nemc = platform_get_drvdata(pdev);
+ of_platform_depopulate(&pdev->dev);
clk_disable_unprepare(nemc->clk);
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] memory: jz4780-nemc: publish drvdata before creating children
2026-06-16 0:57 [PATCH] memory: jz4780-nemc: publish drvdata before creating children Pengpeng Hou
@ 2026-06-30 17:22 ` Krzysztof Kozlowski
2026-12-03 3:52 ` Pengpeng Hou
0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-06-30 17:22 UTC (permalink / raw)
To: Pengpeng Hou, Paul Cercueil, linux-mips, linux-kernel
On 16/06/2026 02:57, Pengpeng Hou wrote:
> The NEMC child drivers can call exported helpers that fetch the parent
> controller state with dev_get_drvdata(dev->parent). jz4780_nemc_probe()
> currently creates child platform devices before storing the controller
> pointer in the parent drvdata, so a child that probes immediately can
> observe a NULL parent drvdata pointer.
>
> Store the controller pointer before creating child devices. Also
"Also" is indication you mix up two independent commits.
> depopulate child devices during remove before disabling the controller
> clock so child teardown still runs while the parent resources are
> available.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/memory/jz4780-nemc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c
> index 1a8161514d03..1c1d1d019f77 100644
> --- a/drivers/memory/jz4780-nemc.c
> +++ b/drivers/memory/jz4780-nemc.c
> @@ -331,6 +331,8 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> + platform_set_drvdata(pdev, nemc);
> +
> /*
> * Iterate over child devices, check that they do not conflict with
> * each other, and register child devices for them. If a child device
> @@ -379,7 +381,6 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
> }
> }
>
> - platform_set_drvdata(pdev, nemc);
> dev_info(dev, "JZ4780 NEMC initialised\n");
> return 0;
> }
> @@ -388,6 +389,7 @@ static void jz4780_nemc_remove(struct platform_device *pdev)
> {
> struct jz4780_nemc *nemc = platform_get_drvdata(pdev);
>
> + of_platform_depopulate(&pdev->dev);
This should be separate commit. Another problem is that driver does not
populate the bus, so calling of_platform_depopulate() feels not only
heavily confusing but actually wrong. Commit msg should explain why it
is correct, in your opinion. IMO, it might be not right since we never
set the OF_POPULATED_BUS flag.
How did you test it?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] memory: jz4780-nemc: publish drvdata before creating children
2026-06-30 17:22 ` Krzysztof Kozlowski
@ 2026-12-03 3:52 ` Pengpeng Hou
2026-12-03 10:17 ` Krzysztof Kozlowski
0 siblings, 1 reply; 4+ messages in thread
From: Pengpeng Hou @ 2026-12-03 3:52 UTC (permalink / raw)
To: Krzysztof Kozlowski; +Cc: Pengpeng Hou, Paul Cercueil, linux-mips, linux-kernel
Hi Krzysztof,
You're right that I combined two different changes. The children are
created individually with of_platform_device_create(); that doesn't
set OF_POPULATED_BUS on the parent. My of_platform_depopulate() call
isn't the inverse of that registration.
The drvdata ordering is separate: a child can probe during device
registration, before the parent reaches platform_set_drvdata(). My
evidence for that ordering is source inspection, not a failing board
test. I'll drop the teardown change rather than claim it fixes removal.
Thanks,
Pengpeng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory: jz4780-nemc: publish drvdata before creating children
2026-12-03 3:52 ` Pengpeng Hou
@ 2026-12-03 10:17 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-12-03 10:17 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: Paul Cercueil, linux-mips, linux-kernel
On 03/12/2026 04:52, Pengpeng Hou wrote:
> Hi Krzysztof,
>
> You're right that I combined two different changes. The children are
> created individually with of_platform_device_create(); that doesn't
> set OF_POPULATED_BUS on the parent. My of_platform_depopulate() call
> isn't the inverse of that registration.
>
> The drvdata ordering is separate: a child can probe during device
> registration, before the parent reaches platform_set_drvdata(). My
> evidence for that ordering is source inspection, not a failing board
> test. I'll drop the teardown change rather than claim it fixes removal.
>
What are you referring to? Half year old email without any context?
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-03 10:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-16 0:57 [PATCH] memory: jz4780-nemc: publish drvdata before creating children Pengpeng Hou
2026-06-30 17:22 ` Krzysztof Kozlowski
2026-12-03 3:52 ` Pengpeng Hou
2026-12-03 10:17 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox