* [PATCH] Revert "memory: ti-aemif: don't needlessly iterate over child nodes"
@ 2024-08-24 8:02 Bartosz Golaszewski
2024-08-25 8:15 ` Krzysztof Kozlowski
2024-08-25 12:22 ` Krzysztof Kozlowski
0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-08-24 8:02 UTC (permalink / raw)
To: Krzysztof Kozlowski, Santosh Shilimkar; +Cc: linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This reverts commit 23a641d5c2bce4c723fff9118a5d865ee6b9d05a.
The first-level children of the aemif node are not the device nodes (ones
containing the 'compatible' property) but the chip-select nodes which
instead have their own children.
of_platform_populate() will skip such nodes so we must indeed iterate
over the direct children of the aemif node. The problem here is that we
never call of_platform_depopulate() as it takes the root device as
argument. We only have an unpopulated chip-select nodes so we will leak
these devices if any of the calls to of_platform_populate() fails.
I don't have a batter idea right now but my patch was not correct so we
need to revert it. While at it: at least use the scoped variant of the
OF node iterator. Down the line, we should find a better solution to fix
this potential resource leak in error path.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/memory/ti-aemif.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c
index 3b546eddf5fe9..d54dc3cfff73c 100644
--- a/drivers/memory/ti-aemif.c
+++ b/drivers/memory/ti-aemif.c
@@ -379,9 +379,11 @@ static int aemif_probe(struct platform_device *pdev)
* child will be probed after the AEMIF timing parameters are set.
*/
if (np) {
- ret = devm_of_platform_populate(dev);
- if (ret)
- return ret;
+ for_each_available_child_of_node_scoped(np, child_np) {
+ ret = of_platform_populate(child_np, NULL, NULL, dev);
+ if (ret < 0)
+ return ret;
+ }
}
return 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "memory: ti-aemif: don't needlessly iterate over child nodes"
2024-08-24 8:02 [PATCH] Revert "memory: ti-aemif: don't needlessly iterate over child nodes" Bartosz Golaszewski
@ 2024-08-25 8:15 ` Krzysztof Kozlowski
2024-08-25 8:28 ` Krzysztof Kozlowski
2024-08-25 12:22 ` Krzysztof Kozlowski
1 sibling, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 8:15 UTC (permalink / raw)
To: Bartosz Golaszewski, Santosh Shilimkar; +Cc: linux-kernel, Bartosz Golaszewski
On 24/08/2024 10:02, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> This reverts commit 23a641d5c2bce4c723fff9118a5d865ee6b9d05a.
>
> The first-level children of the aemif node are not the device nodes (ones
> containing the 'compatible' property) but the chip-select nodes which
> instead have their own children.
>
> of_platform_populate() will skip such nodes so we must indeed iterate
> over the direct children of the aemif node. The problem here is that we
> never call of_platform_depopulate() as it takes the root device as
> argument. We only have an unpopulated chip-select nodes so we will leak
> these devices if any of the calls to of_platform_populate() fails.
>
> I don't have a batter idea right now but my patch was not correct so we
> need to revert it. While at it: at least use the scoped variant of the
> OF node iterator. Down the line, we should find a better solution to fix
> this potential resource leak in error path.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> drivers/memory/ti-aemif.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
I'll drop the original commit, because my upstream (arm/soc) might
question this.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "memory: ti-aemif: don't needlessly iterate over child nodes"
2024-08-25 8:15 ` Krzysztof Kozlowski
@ 2024-08-25 8:28 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 8:28 UTC (permalink / raw)
To: Bartosz Golaszewski, Santosh Shilimkar; +Cc: linux-kernel, Bartosz Golaszewski
On 25/08/2024 10:15, Krzysztof Kozlowski wrote:
> On 24/08/2024 10:02, Bartosz Golaszewski wrote:
>> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>>
>> This reverts commit 23a641d5c2bce4c723fff9118a5d865ee6b9d05a.
>>
>> The first-level children of the aemif node are not the device nodes (ones
>> containing the 'compatible' property) but the chip-select nodes which
>> instead have their own children.
>>
>> of_platform_populate() will skip such nodes so we must indeed iterate
>> over the direct children of the aemif node. The problem here is that we
>> never call of_platform_depopulate() as it takes the root device as
>> argument. We only have an unpopulated chip-select nodes so we will leak
>> these devices if any of the calls to of_platform_populate() fails.
>>
>> I don't have a batter idea right now but my patch was not correct so we
>> need to revert it. While at it: at least use the scoped variant of the
>> OF node iterator. Down the line, we should find a better solution to fix
>> this potential resource leak in error path.
>>
>> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>> ---
>> drivers/memory/ti-aemif.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> I'll drop the original commit, because my upstream (arm/soc) might
> question this.
>
Dropping is non-trivial, so indeed revert.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "memory: ti-aemif: don't needlessly iterate over child nodes"
2024-08-24 8:02 [PATCH] Revert "memory: ti-aemif: don't needlessly iterate over child nodes" Bartosz Golaszewski
2024-08-25 8:15 ` Krzysztof Kozlowski
@ 2024-08-25 12:22 ` Krzysztof Kozlowski
1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-25 12:22 UTC (permalink / raw)
To: Krzysztof Kozlowski, Santosh Shilimkar, Bartosz Golaszewski
Cc: linux-kernel, Bartosz Golaszewski
On Sat, 24 Aug 2024 10:02:35 +0200, Bartosz Golaszewski wrote:
> This reverts commit 23a641d5c2bce4c723fff9118a5d865ee6b9d05a.
>
> The first-level children of the aemif node are not the device nodes (ones
> containing the 'compatible' property) but the chip-select nodes which
> instead have their own children.
>
> of_platform_populate() will skip such nodes so we must indeed iterate
> over the direct children of the aemif node. The problem here is that we
> never call of_platform_depopulate() as it takes the root device as
> argument. We only have an unpopulated chip-select nodes so we will leak
> these devices if any of the calls to of_platform_populate() fails.
>
> [...]
Applied, thanks!
[1/1] Revert "memory: ti-aemif: don't needlessly iterate over child nodes"
https://git.kernel.org/krzk/linux-mem-ctrl/c/c7d2f3fbdf59b206414ddc306b0fb74cd174c0ed
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-08-25 12:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-24 8:02 [PATCH] Revert "memory: ti-aemif: don't needlessly iterate over child nodes" Bartosz Golaszewski
2024-08-25 8:15 ` Krzysztof Kozlowski
2024-08-25 8:28 ` Krzysztof Kozlowski
2024-08-25 12:22 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox