* [PATCH net] net: dsa: Fix load order between DSA drivers and taggers
@ 2019-09-12 13:16 Andrew Lunn
2019-09-15 18:50 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Lunn @ 2019-09-12 13:16 UTC (permalink / raw)
To: David Miller; +Cc: Florian Fainelli, Vivien Didelot, netdev, Andrew Lunn
The DSA core, DSA taggers and DSA drivers all make use of
module_init(). Hence they get initialised at device_initcall() time.
The ordering is non-deterministic. It can be a DSA driver is bound to
a device before the needed tag driver has been initialised, resulting
in the message:
No tagger for this switch
Rather than have this be fatal, return -EPROBE_DEFER so that it is
tried again later once all the needed drivers have been loaded.
Fixes: d3b8c04988ca ("dsa: Add boilerplate helper to register DSA tag driver modules")
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
I did wonder if we should play with the core and tag drivers and make
them use subsystem_initcall(), but EPROBE_DEFER seems to be the more
preferred solution nowadays.
---
net/dsa/dsa2.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 3abd173ebacb..96f787cf9b6e 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -623,6 +623,8 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master)
tag_protocol = ds->ops->get_tag_protocol(ds, dp->index);
tag_ops = dsa_tag_driver_get(tag_protocol);
if (IS_ERR(tag_ops)) {
+ if (PTR_ERR(tag_ops) == -ENOPROTOOPT)
+ return -EPROBE_DEFER;
dev_warn(ds->dev, "No tagger for this switch\n");
return PTR_ERR(tag_ops);
}
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: dsa: Fix load order between DSA drivers and taggers
2019-09-12 13:16 [PATCH net] net: dsa: Fix load order between DSA drivers and taggers Andrew Lunn
@ 2019-09-15 18:50 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-09-15 18:50 UTC (permalink / raw)
To: andrew; +Cc: f.fainelli, vivien.didelot, netdev
From: Andrew Lunn <andrew@lunn.ch>
Date: Thu, 12 Sep 2019 15:16:45 +0200
> The DSA core, DSA taggers and DSA drivers all make use of
> module_init(). Hence they get initialised at device_initcall() time.
> The ordering is non-deterministic. It can be a DSA driver is bound to
> a device before the needed tag driver has been initialised, resulting
> in the message:
>
> No tagger for this switch
>
> Rather than have this be fatal, return -EPROBE_DEFER so that it is
> tried again later once all the needed drivers have been loaded.
>
> Fixes: d3b8c04988ca ("dsa: Add boilerplate helper to register DSA tag driver modules")
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>
> I did wonder if we should play with the core and tag drivers and make
> them use subsystem_initcall(), but EPROBE_DEFER seems to be the more
> preferred solution nowadays.
Yes that does indeed seem preferable these days and all of the init
types is usually quite fragile.
Applied and queued up for v5.2 -stable.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-15 18:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12 13:16 [PATCH net] net: dsa: Fix load order between DSA drivers and taggers Andrew Lunn
2019-09-15 18:50 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).