Re: [PATCH v3 12/12] mtd: mtdpart: Don't create platform device that'll never probe

From
Maxim Kiselev <hidden>
Date
2023-02-07 07:52:18
Also in
linux-acpi, linux-arm-kernel, linux-gpio, linux-renesas-soc, lkml
Reply to
Saravana Kannan, 2023-02-07
вт, 7 февр. 2023 г. в 04:42, Saravana Kannan [off-list ref]:
quoted hunk ↗ jump to hunk
These "nvmem-cells" platform devices never get probed because there's no
platform driver for it and it's never used anywhere else. So it's a
waste of memory. These devices also cause fw_devlink to block nvmem
consumers of "nvmem-cells" partition from probing because the supplier
device never probes.

So stop creating platform devices for nvmem-cells partitions to avoid
wasting memory and to avoid blocking probing of consumers.

Reported-by: Maxim Kiselev <redacted>
Fixes: bcdf0315a61a ("mtd: call of_platform_populate() for MTD partitions")
Signed-off-by: Saravana Kannan <redacted>
---
 drivers/mtd/mtdpart.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index d442fa94c872..85f5ee6f06fc 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -577,6 +577,7 @@ static int mtd_part_of_parse(struct mtd_info *master,
 {
        struct mtd_part_parser *parser;
        struct device_node *np;
+       struct device_node *child;
        struct property *prop;
        struct device *dev;
        const char *compat;
@@ -594,6 +595,15 @@ static int mtd_part_of_parse(struct mtd_info *master,
        else
                np = of_get_child_by_name(np, "partitions");

+       /*
+        * Don't create devices that are added to a bus but will never get
+        * probed. That'll cause fw_devlink to block probing of consumers of
+        * this partition until the partition device is probed.
+        */
+       for_each_child_of_node(np, child)
+               if (of_device_is_compatible(child, "nvmem-cells"))
+                       of_node_set_flag(child, OF_POPULATED);
+
        of_property_for_each_string(np, "compatible", prop, compat) {
                parser = mtd_part_get_compatible_parser(compat);
                if (!parser)
--
2.39.1.519.gcb327c4b5f-goog
Hi, Saravana!

Now it works pretty well. Thank you so much for your efforts.
Reported-by: Maxim Kiselev <redacted>
Fixes: bcdf0315a61a ("mtd: call of_platform_populate() for MTD partitions")
Signed-off-by: Saravana Kannan <redacted>
Tested-by: Maksim Kiselev <redacted>
Thread (41 messages) 41 messages, 11 authors, last reply 2023-02-25
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help