Patch "net: dsa: fall back to default tagger if we can't load the one from DT" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: dsa: fall back to default tagger if we can't load the one from DT

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-dsa-fall-back-to-default-tagger-if-we-can-t-load.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0ee13cd5dc554e3297cf5bc8017a61d9ff9a5ba1
Author: Vladimir Oltean <vladimir.oltean@xxxxxxx>
Date:   Thu Oct 27 17:54:39 2022 +0300

    net: dsa: fall back to default tagger if we can't load the one from DT
    
    [ Upstream commit a2c65a9d0568b6737c02b54f00b80716a53fac61 ]
    
    DSA tagging protocol drivers can be changed at runtime through sysfs and
    at probe time through the device tree (support for the latter was added
    later).
    
    When changing through sysfs, it is assumed that the module for the new
    tagging protocol was already loaded into the kernel (in fact this is
    only a concern for Ocelot/Felix switches, where we have tag_ocelot.ko
    and tag_ocelot_8021q.ko; for every other switch, the default and
    alternative protocols are compiled within the same .ko, so there is
    nothing for the user to load).
    
    The kernel cannot currently call request_module(), because it has no way
    of constructing the modalias name of the tagging protocol driver
    ("dsa_tag-%d", where the number is one of DSA_TAG_PROTO_*_VALUE).
    The device tree only contains the string name of the tagging protocol
    ("ocelot-8021q"), and the only mapping between the string and the
    DSA_TAG_PROTO_OCELOT_8021Q_VALUE is present in tag_ocelot_8021q.ko.
    So this is a chicken-and-egg situation and dsa_core.ko has nothing based
    on which it can automatically request the insertion of the module.
    
    As a consequence, if CONFIG_NET_DSA_TAG_OCELOT_8021Q is built as module,
    the switch will forever defer probing.
    
    The long-term solution is to make DSA call request_module() somehow,
    but that probably needs some refactoring.
    
    What we can do to keep operating with existing device tree blobs is to
    cancel the attempt to change the tagging protocol with the one specified
    there, and to remain operating with the default one. Depending on the
    situation, the default protocol might still allow some functionality
    (in the case of ocelot, it does), and it's better to have that than to
    fail to probe.
    
    Fixes: deff710703d8 ("net: dsa: Allow default tag protocol to be overridden from DT")
    Link: https://lore.kernel.org/lkml/20221027113248.420216-1-michael@xxxxxxxx/
    Reported-by: Heiko Thiery <heiko.thiery@xxxxxxxxx>
    Reported-by: Michael Walle <michael@xxxxxxxx>
    Signed-off-by: Vladimir Oltean <vladimir.oltean@xxxxxxx>
    Tested-by: Michael Walle <michael@xxxxxxxx>
    Reviewed-by: Florian Fainelli <f.fainelli@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20221027145439.3086017-1-vladimir.oltean@xxxxxxx
    Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index cac48a741f27..e537655e442b 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -1407,9 +1407,9 @@ static enum dsa_tag_protocol dsa_get_tag_protocol(struct dsa_port *dp,
 static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master,
 			      const char *user_protocol)
 {
+	const struct dsa_device_ops *tag_ops = NULL;
 	struct dsa_switch *ds = dp->ds;
 	struct dsa_switch_tree *dst = ds->dst;
-	const struct dsa_device_ops *tag_ops;
 	enum dsa_tag_protocol default_proto;
 
 	/* Find out which protocol the switch would prefer. */
@@ -1432,10 +1432,17 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master,
 		}
 
 		tag_ops = dsa_find_tagger_by_name(user_protocol);
-	} else {
-		tag_ops = dsa_tag_driver_get(default_proto);
+		if (IS_ERR(tag_ops)) {
+			dev_warn(ds->dev,
+				 "Failed to find a tagging driver for protocol %s, using default\n",
+				 user_protocol);
+			tag_ops = NULL;
+		}
 	}
 
+	if (!tag_ops)
+		tag_ops = dsa_tag_driver_get(default_proto);
+
 	if (IS_ERR(tag_ops)) {
 		if (PTR_ERR(tag_ops) == -ENOPROTOOPT)
 			return -EPROBE_DEFER;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux