Skip to content
Snippets Groups Projects
  1. Nov 26, 2021
    • Oleksij Rempel's avatar
      net: dsa: microchip: implement multi-bridge support · b3612ccd
      Oleksij Rempel authored
      
      Current driver version is able to handle only one bridge at time.
      Configuring two bridges on two different ports would end up shorting this
      bridges by HW. To reproduce it:
      
      	ip l a name br0 type bridge
      	ip l a name br1 type bridge
      	ip l s dev br0 up
      	ip l s dev br1 up
      	ip l s lan1 master br0
      	ip l s dev lan1 up
      	ip l s lan2 master br1
      	ip l s dev lan2 up
      
      	Ping on lan1 and get response on lan2, which should not happen.
      
      This happened, because current driver version is storing one global "Port VLAN
      Membership" and applying it to all ports which are members of any
      bridge.
      To solve this issue, we need to handle each port separately.
      
      This patch is dropping the global port member storage and calculating
      membership dynamically depending on STP state and bridge participation.
      
      Note: STP support was broken before this patch and should be fixed
      separately.
      
      Fixes: c2e86691 ("net: dsa: microchip: break KSZ9477 DSA driver into two files")
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Link: https://lore.kernel.org/r/20211126123926.2981028-1-o.rempel@pengutronix.de
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      b3612ccd
  2. Oct 12, 2021
    • Arun Ramadoss's avatar
      net: dsa: microchip: Added the condition for scheduling ksz_mib_read_work · ef1100ef
      Arun Ramadoss authored
      
      When the ksz module is installed and removed using rmmod, kernel crashes
      with null pointer dereferrence error. During rmmod, ksz_switch_remove
      function tries to cancel the mib_read_workqueue using
      cancel_delayed_work_sync routine and unregister switch from dsa.
      
      During dsa_unregister_switch it calls ksz_mac_link_down, which in turn
      reschedules the workqueue since mib_interval is non-zero.
      Due to which queue executed after mib_interval and it tries to access
      dp->slave. But the slave is unregistered in the ksz_switch_remove
      function. Hence kernel crashes.
      
      To avoid this crash, before canceling the workqueue, resetted the
      mib_interval to 0.
      
      v1 -> v2:
      -Removed the if condition in ksz_mib_read_work
      
      Fixes: 469b390e ("net: dsa: microchip: use delayed_work instead of timer + work")
      Signed-off-by: default avatarArun Ramadoss <arun.ramadoss@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ef1100ef
  3. Jul 11, 2021
  4. Jan 21, 2021
  5. Jan 12, 2021
    • Vladimir Oltean's avatar
      net: dsa: remove the transactional logic from VLAN objects · 1958d581
      Vladimir Oltean authored
      
      It should be the driver's business to logically separate its VLAN
      offloading into a preparation and a commit phase, and some drivers don't
      need / can't do this.
      
      So remove the transactional shim from DSA and let drivers propagate
      errors directly from the .port_vlan_add callback.
      
      It would appear that the code has worse error handling now than it had
      before. DSA is the only in-kernel user of switchdev that offloads one
      switchdev object to more than one port: for every VLAN object offloaded
      to a user port, that VLAN is also offloaded to the CPU port. So the
      "prepare for user port -> check for errors -> prepare for CPU port ->
      check for errors -> commit for user port -> commit for CPU port"
      sequence appears to make more sense than the one we are using now:
      "offload to user port -> check for errors -> offload to CPU port ->
      check for errors", but it is really a compromise. In the new way, we can
      catch errors from the commit phase that we previously had to ignore.
      But we have our hands tied and cannot do any rollback now: if we add a
      VLAN on the CPU port and it fails, we can't do the rollback by simply
      deleting it from the user port, because the switchdev API is not so nice
      with us: it could have simply been there already, even with the same
      flags. So we don't even attempt to rollback anything on addition error,
      just leave whatever VLANs managed to get offloaded right where they are.
      This should not be a problem at all in practice.
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Acked-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      1958d581
    • Vladimir Oltean's avatar
      net: dsa: remove the transactional logic from MDB entries · a52b2da7
      Vladimir Oltean authored
      
      For many drivers, the .port_mdb_prepare callback was not a good opportunity
      to avoid any error condition, and they would suppress errors found during
      the actual commit phase.
      
      Where a logical separation between the prepare and the commit phase
      existed, the function that used to implement the .port_mdb_prepare
      callback still exists, but now it is called directly from .port_mdb_add,
      which was modified to return an int code.
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Acked-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de> # hellcreek
      Reviewed-by: Linus Wallei <linus.walleij@linaro.org> # RTL8366
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      a52b2da7
  6. Dec 03, 2020
  7. Nov 26, 2020
  8. Oct 12, 2020
    • Christian Eggers's avatar
      net: dsa: microchip: fix race condition · 8098bd69
      Christian Eggers authored
      
      Between queuing the delayed work and finishing the setup of the dsa
      ports, the process may sleep in request_module() (via
      phy_device_create()) and the queued work may be executed prior to the
      switch net devices being registered. In ksz_mib_read_work(), a NULL
      dereference will happen within netof_carrier_ok(dp->slave).
      
      Not queuing the delayed work in ksz_init_mib_timer() makes things even
      worse because the work will now be queued for immediate execution
      (instead of 2000 ms) in ksz_mac_link_down() via
      dsa_port_link_register_of().
      
      Call tree:
      ksz9477_i2c_probe()
      \--ksz9477_switch_register()
         \--ksz_switch_register()
            +--dsa_register_switch()
            |  \--dsa_switch_probe()
            |     \--dsa_tree_setup()
            |        \--dsa_tree_setup_switches()
            |           +--dsa_switch_setup()
            |           |  +--ksz9477_setup()
            |           |  |  \--ksz_init_mib_timer()
            |           |  |     |--/* Start the timer 2 seconds later. */
            |           |  |     \--schedule_delayed_work(&dev->mib_read, msecs_to_jiffies(2000));
            |           |  \--__mdiobus_register()
            |           |     \--mdiobus_scan()
            |           |        \--get_phy_device()
            |           |           +--get_phy_id()
            |           |           \--phy_device_create()
            |           |              |--/* sleeping, ksz_mib_read_work() can be called meanwhile */
            |           |              \--request_module()
            |           |
            |           \--dsa_port_setup()
            |              +--/* Called for non-CPU ports */
            |              +--dsa_slave_create()
            |              |  +--/* Too late, ksz_mib_read_work() may be called beforehand */
            |              |  \--port->slave = ...
            |             ...
            |              +--Called for CPU port */
            |              \--dsa_port_link_register_of()
            |                 \--ksz_mac_link_down()
            |                    +--/* mib_read must be initialized here */
            |                    +--/* work is already scheduled, so it will be executed after 2000 ms */
            |                    \--schedule_delayed_work(&dev->mib_read, 0);
            \-- /* here port->slave is setup properly, scheduling the delayed work should be safe */
      
      Solution:
      1. Do not queue (only initialize) delayed work in ksz_init_mib_timer().
      2. Only queue delayed work in ksz_mac_link_down() if init is completed.
      3. Queue work once in ksz_switch_register(), after dsa_register_switch()
      has completed.
      
      Fixes: 7c6ff470 ("net: dsa: microchip: add MIB counter reading support")
      Signed-off-by: default avatarChristian Eggers <ceggers@arri.de>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8098bd69
  9. Sep 25, 2020
  10. Sep 10, 2020
  11. Sep 09, 2020
  12. Jul 21, 2020
    • Helmut Grohne's avatar
      net: dsa: microchip: call phy_remove_link_mode during probe · 3506b2f4
      Helmut Grohne authored
      When doing "ip link set dev ... up" for a ksz9477 backed link,
      ksz9477_phy_setup is called and it calls phy_remove_link_mode to remove
      1000baseT HDX. During phy_remove_link_mode, phy_advertise_supported is
      called. Doing so reverts any previous change to advertised link modes
      e.g. using a udevd .link file.
      
      phy_remove_link_mode is not meant to be used while opening a link and
      should be called during phy probe when the link is not yet available to
      userspace.
      
      Therefore move the phy_remove_link_mode calls into
      ksz9477_switch_register. It indirectly calls dsa_register_switch, which
      creates the relevant struct phy_devices and we update the link modes
      right after that. At that time dev->features is already initialized by
      ksz9477_switch_detect.
      
      Remove phy_setup from ksz_dev_ops as no users remain.
      
      Link: https://lore.kernel.org/netdev/20200715192722.GD1256692@lunn.ch/
      
      
      Fixes: 42fc6a4c ("net: dsa: microchip: prepare PHY for proper advertisement")
      Signed-off-by: default avatarHelmut Grohne <helmut.grohne@intenta.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3506b2f4
  13. Jul 05, 2020
  14. Mar 10, 2020
  15. Nov 04, 2019
    • Andrew Lunn's avatar
      net: of_get_phy_mode: Change API to solve int/unit warnings · 0c65b2b9
      Andrew Lunn authored
      
      Before this change of_get_phy_mode() returned an enum,
      phy_interface_t. On error, -ENODEV etc, is returned. If the result of
      the function is stored in a variable of type phy_interface_t, and the
      compiler has decided to represent this as an unsigned int, comparision
      with -ENODEV etc, is a signed vs unsigned comparision.
      
      Fix this problem by changing the API. Make the function return an
      error, or 0 on success, and pass a pointer, of type phy_interface_t,
      where the phy mode should be stored.
      
      v2:
      Return with *interface set to PHY_INTERFACE_MODE_NA on error.
      Add error checks to all users of of_get_phy_mode()
      Fixup a few reverse christmas tree errors
      Fixup a few slightly malformed reverse christmas trees
      
      v3:
      Fix 0-day reported errors.
      
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0c65b2b9
  16. Oct 22, 2019
  17. Oct 17, 2019
    • Marek Vasut's avatar
      net: dsa: microchip: Add shared regmap mutex · 013572a2
      Marek Vasut authored
      
      The KSZ driver uses one regmap per register width (8/16/32), each with
      it's own lock, but accessing the same set of registers. In theory, it
      is possible to create a race condition between these regmaps, although
      the underlying bus (SPI or I2C) locking should assure nothing bad will
      really happen and the accesses would be correct.
      
      To make the driver do the right thing, add one single shared mutex for
      all the regmaps used by the driver instead. This assures that even if
      some future hardware is on a bus which does not serialize the accesses
      the same way SPI or I2C does, nothing bad will happen.
      
      Note that the status_mutex was unused and only initied, hence it was
      renamed and repurposed as the regmap mutex.
      
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: George McCollister <george.mccollister@gmail.com>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: Woojung Huh <woojung.huh@microchip.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      013572a2
  18. Aug 20, 2019
    • Vivien Didelot's avatar
      net: dsa: do not enable or disable non user ports · 74be4bab
      Vivien Didelot authored
      
      The .port_enable and .port_disable operations are currently only
      called for user ports, hence assuming they have a slave device. In
      preparation for using these operations for other port types as well,
      simply guard all implementations against non user ports and return
      directly in such case.
      
      Note that bcm_sf2_sw_suspend() currently calls bcm_sf2_port_disable()
      (and thus b53_disable_port()) against the user and CPU ports, so do
      not guards those functions. They will be called for unused ports in
      the future, but that was expected by those drivers anyway.
      
      Signed-off-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      74be4bab
  19. Aug 06, 2019
    • Marek Vasut's avatar
      net: dsa: ksz: Merge ksz_priv.h into ksz_common.h · 6a7abc61
      Marek Vasut authored
      
      Merge the two headers into one, no functional change.
      
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: Vivien Didelot <vivien.didelot@gmail.com>
      Cc: Woojung Huh <woojung.huh@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6a7abc61
    • Marek Vasut's avatar
      net: dsa: ksz: Remove dead code and fix warnings · ffc60b55
      Marek Vasut authored
      
      Remove ksz_port_cleanup(), which is unused. Add missing include
      "ksz_common.h", which fixes the following warning when built with
      make ... W=1
      
      drivers/net/dsa/microchip/ksz_common.c:23:6: warning: no previous prototype for ‘...’ [-Wmissing-prototypes]
      
      Note that the order of the headers cannot be swapped, as that would
      trigger missing forward declaration errors, which would indicate the
      way forward is to merge the two headers into one.
      
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: Vivien Didelot <vivien.didelot@gmail.com>
      Cc: Woojung Huh <woojung.huh@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ffc60b55
  20. Jul 30, 2019
  21. Jun 27, 2019
  22. Jun 26, 2019
  23. Jun 15, 2019
  24. Mar 03, 2019
  25. Feb 25, 2019
  26. Jan 04, 2019
  27. Dec 10, 2018
  28. Nov 21, 2018
Loading