On Thu, Jun 18, 2020 at 12:56 PM Cong Wang <xiyou.wangc...@gmail.com> wrote:
>
> On Thu, Jun 18, 2020 at 12:40 PM Vladimir Oltean <olte...@gmail.com> wrote:
> >
> > It's me with the stacked DSA devices again:
>
> It looks like DSA never uses netdev API to link master
> device with slave devices? If so, their dev->lower_level
> are always 1, therefore triggers this warning.
>
> I think it should call one of these netdev_upper_dev_link()
> API's when creating a slave device.
>

I don't know whether DSA is too special to use the API, but
something like this should work:

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 4c7f086a047b..f7a2a281e7f0 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1807,6 +1807,11 @@ int dsa_slave_create(struct dsa_port *port)
                           ret, slave_dev->name);
                goto out_phy;
        }
+       ret = netdev_upper_dev_link(slave_dev, master, NULL);
+       if (ret) {
+               unregister_netdevice(slave_dev);
+               goto out_phy;
+       }

        return 0;

@@ -1832,6 +1837,7 @@ void dsa_slave_destroy(struct net_device *slave_dev)
        netif_carrier_off(slave_dev);
        rtnl_lock();
        phylink_disconnect_phy(dp->pl);
+       netdev_upper_dev_unlink(slave_dev, dp->master);
        rtnl_unlock();

        dsa_slave_notify(slave_dev, DSA_PORT_UNREGISTER);

Reply via email to