Skip to content
Snippets Groups Projects
  1. Oct 16, 2018
  2. Oct 11, 2018
  3. Oct 08, 2018
    • Quentin Schulz's avatar
      net: phy: mscc: add support for VSC8574 PHY · 00d70d8e
      Quentin Schulz authored
      
      The VSC8574 PHY is a 4-ports PHY that is 10/100/1000BASE-T, 100BASE-FX,
      1000BASE-X and triple-speed copper SFP capable, can communicate with
      the MAC via SGMII, QSGMII or 1000BASE-X, supports WOL, downshifting and
      can set the blinking pattern of each of its 4 LEDs, supports SyncE as
      well as HP Auto-MDIX detection.
      
      This adds support for 10/100/1000BASE-T, SGMII/QSGMII link with the MAC,
      WOL, downshifting, HP Auto-MDIX detection and blinking pattern for its 4
      LEDs.
      
      The VSC8574 has also an internal Intel 8051 microcontroller whose
      firmware needs to be patched when the PHY is reset. If the 8051's
      firmware has the expected CRC, its patching can be skipped. The
      microcontroller can be accessed from any port of the PHY, though the CRC
      function can only be done through the PHY that is the base PHY of the
      package (internal address 0) due to a limitation of the firmware.
      
      The GPIO register bank is a set of registers that are common to all PHYs
      in the package. So any modification in any register of this bank affects
      all PHYs of the package.
      
      If the PHYs haven't been reset before booting the Linux kernel and were
      configured to use interrupts for e.g. link status updates, it is
      required to clear the interrupts mask register of all PHYs before being
      able to use interrupts with any PHY. The first PHY of the package that
      will be init will take care of clearing all PHYs interrupts mask
      registers. Thus, we need to keep track of the init sequence in the
      package, if it's already been done or if it's to be done.
      
      Most of the init sequence of a PHY of the package is common to all PHYs
      in the package, thus we use the SMI broadcast feature which enables us
      to propagate a write in one register of one PHY to all PHYs in the same
      package.
      
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      00d70d8e
    • Quentin Schulz's avatar
      net: phy: mscc: add support for VSC8584 PHY · a5afc167
      Quentin Schulz authored
      
      The VSC8584 PHY is a 4-ports PHY that is 10/100/1000BASE-T, 100BASE-FX,
      1000BASE-X and triple-speed copper SFP capable, can communicate with the
      MAC via SGMII, QSGMII or 1000BASE-X, supports downshifting and can set
      the blinking pattern of each of its 4 LEDs, supports hardware offloading
      of MACsec and supports SyncE as well as HP Auto-MDIX detection.
      
      This adds support for 10/100/1000BASE-T, SGMII/QSGMII link with the MAC,
      downshifting, HP Auto-MDIX detection and blinking pattern for its 4
      LEDs.
      
      The VSC8584 has also an internal Intel 8051 microcontroller whose
      firmware needs to be patched when the PHY is reset. If the 8051's
      firmware has the expected CRC, its patching can be skipped. The
      microcontroller can be accessed from any port of the PHY, though the CRC
      function can only be done through the PHY that is the base PHY of the
      package (internal address 0) due to a limitation of the firmware.
      
      The GPIO register bank is a set of registers that are common to all PHYs
      in the package. So any modification in any register of this bank affects
      all PHYs of the package.
      
      If the PHYs haven't been reset before booting the Linux kernel and were
      configured to use interrupts for e.g. link status updates, it is
      required to clear the interrupts mask register of all PHYs before being
      able to use interrupts with any PHY. The first PHY of the package that
      will be init will take care of clearing all PHYs interrupts mask
      registers. Thus, we need to keep track of the init sequence in the
      package, if it's already been done or if it's to be done.
      
      Most of the init sequence of a PHY of the package is common to all PHYs
      in the package, thus we use the SMI broadcast feature which enables us
      to propagate a write in one register of one PHY to all PHYs in the same
      package.
      
      The revA of the VSC8584 PHY (which is not and will not be publicly
      released) should NOT patch the firmware of the microcontroller or it'll
      make things worse, the easiest way is just to not support it.
      
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a5afc167
    • Quentin Schulz's avatar
      net: phy: mscc: remove unneeded temporary variable · 629ea0f1
      Quentin Schulz authored
      
      Here, the rc variable is either used only for the condition right after
      the assignment or right before being used as the return value of the
      function it's being used in.
      
      So let's remove this unneeded temporary variable whenever possible.
      
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      629ea0f1
    • Quentin Schulz's avatar
      net: phy: mscc: shorten `x != 0` condition to `x` · 6f0430c7
      Quentin Schulz authored
      
      `if (x != 0)` is basically a more verbose version of `if (x)` so let's
      use the latter so it's consistent throughout the whole driver.
      
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6f0430c7
    • Quentin Schulz's avatar
      net: phy: mscc: remove unneeded parenthesis · b7d373c5
      Quentin Schulz authored
      
      The == operator precedes the || operator, so we can remove the
      parenthesis around (a == b) || (c == d).
      
      The condition is rather explicit and short so removing the parenthesis
      definitely does not make it harder to read.
      
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b7d373c5
    • Raju Lakkaraju's avatar
      net: phy: mscc: Add EEE init sequence · 96dae01f
      Raju Lakkaraju authored
      
      Microsemi PHYs (VSC 8530/31/40/41) need to update the Energy Efficient
      Ethernet initialization sequence.
      In order to avoid certain link state errors that could result in link
      drops and packet loss, the physical coding sublayer (PCS) must be
      updated with settings related to EEE in order to improve performance.
      
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRaju Lakkaraju <Raju.Lakkaraju@microchip.com>
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      96dae01f
    • Raju Lakkaraju's avatar
      net: phy: mscc: add ethtool statistics counters · f76178dc
      Raju Lakkaraju authored
      
      There are a few counters available in the PHY: receive errors, false
      carriers, link disconnects, media CRC errors and valids counters.
      
      So let's expose those in the PHY driver.
      
      Use the priv structure as the next PHY to be supported has a few
      additional counters.
      
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarRaju Lakkaraju <Raju.Lakkaraju@microsemi.com>
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f76178dc
    • Quentin Schulz's avatar
      net: phy: mscc: migrate to phy_select/restore_page functions · 6a0bfbbe
      Quentin Schulz authored
      
      The Microsemi PHYs have multiple banks of registers (called pages).
      Registers can only be accessed from one page, if we need a register from
      another page, we need to switch the page and the registers of all other
      pages are not accessible anymore.
      
      Basically, to read register 5 from page 0, 1, 2, etc., you do the same
      phy_read(phydev, 5); but you need to set the desired page beforehand.
      
      In order to guarantee that two concurrent functions do not change the
      page, we need to do some locking per page. This can be achieved with the
      use of phy_select_page and phy_restore_page functions but phy_write/read
      calls in-between those two functions shall be replaced by their
      lock-free alternative __phy_write/read.
      
      Let's migrate this driver to those functions.
      
      Suggested-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6a0bfbbe
  4. Oct 05, 2018
  5. Oct 02, 2018
  6. Sep 28, 2018
    • Arnd Bergmann's avatar
      net: phy: mdio-bcm-unimac: mark PM functions as __maybe_unused · 9b97123a
      Arnd Bergmann authored
      
      The newly added runtime-pm support causes a harmless warning
      when CONFIG_PM is disabled:
      
      drivers/net/phy/mdio-bcm-unimac.c:330:12: error: 'unimac_mdio_resume' defined but not used [-Werror=unused-function]
       static int unimac_mdio_resume(struct device *d)
      drivers/net/phy/mdio-bcm-unimac.c:321:12: error: 'unimac_mdio_suspend' defined but not used [-Werror=unused-function]
       static int unimac_mdio_suspend(struct device *d)
      
      Marking the functions as __maybe_unused is the easiest workaround
      and avoids adding #ifdef checks.
      
      Fixes: b78ac6ec ("net: phy: mdio-bcm-unimac: Allow configuring MDIO clock divider")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9b97123a
    • Arnd Bergmann's avatar
      phy: mscc: fix printf format · 31bae7da
      Arnd Bergmann authored
      
      gcc points out that the length of the temporary buffer may not be sufficient for
      large numbers of leds:
      
      drivers/net/phy/mscc.c: In function 'vsc85xx_probe':
      drivers/net/phy/mscc.c:460:45: error: '-mode' directive writing 5 bytes into a region of size between 0 and 9 [-Werror=format-overflow=]
         ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
                                                   ^~~~~
      drivers/net/phy/mscc.c:460:9: note: 'sprintf' output between 19 and 28 bytes into a destination of size 22
         ret = sprintf(led_dt_prop, "vsc8531,led-%d-mode", i);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      While we can make a reasonable assumption that the number of LEDs is small,
      the cost of making the buffer a little bigger is insignificant as well.
      
      Fixes: 11bfdabb ("net: phy: mscc: factorize code for LEDs mode")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      31bae7da
  7. Sep 27, 2018
    • Andrew Lunn's avatar
      net: phy: sfp: Fix unregistering of HWMON SFP device · 3e322474
      Andrew Lunn authored
      
      A HWMON device is only registered is the SFP module supports the
      diagnostic page and is complient to SFF8472. Don't unconditionally
      unregister the hwmon device when the SFP module is remove, otherwise
      we access data structures which don't exist.
      
      Reported-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Fixes: 1323061a ("net: phy: sfp: Add HWMON support for module sensors")
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3e322474
    • Heiner Kallweit's avatar
      net: phy: fix WoL handling when suspending the PHY · 93f41e67
      Heiner Kallweit authored
      
      Core of the problem is that phy_suspend() suspends the PHY when it
      should not because of WoL. phy_suspend() checks for WoL already, but
      this works only if the PHY driver handles WoL (what is rarely the case).
      Typically WoL is handled by the MAC driver.
      
      This patch uses new member wol_enabled of struct net_device as
      additional criteria in the check when not to suspend the PHY because
      of WoL.
      
      Last but not least change phy_detach() to call phy_suspend() before
      attached_dev is set to NULL. phy_suspend() accesses attached_dev
      when checking whether the MAC driver activated WoL.
      
      Fixes: f1e911d5 ("r8169: add basic phylib support")
      Fixes: e8cfd9d6 ("net: phy: call state machine synchronously in phy_stop")
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      93f41e67
    • David S. Miller's avatar
      Revert "net: phy: fix WoL handling when suspending the PHY" · d31d1d03
      David S. Miller authored
      
      This reverts commit e0511f6c.
      
      I commited the wrong version of these changes.
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d31d1d03
    • Heiner Kallweit's avatar
      net: phy: fix WoL handling when suspending the PHY · e0511f6c
      Heiner Kallweit authored
      
      Actually there's nothing wrong with the two changes marked as "Fixes",
      they just revealed a problem which has been existing before.
      After having switched r8169 to phylib it was reported that WoL from
      shutdown doesn't work any longer (WoL from suspend isn't affected).
      Reason is that during shutdown phy_disconnect()->phy_detach()->
      phy_suspend() is called.
      A similar issue occurs when the phylib state machine calls
      phy_suspend() when handling state PHY_HALTED.
      
      Core of the problem is that phy_suspend() suspends the PHY when it
      should not due to WoL. phy_suspend() checks for WoL already, but this
      works only if the PHY driver handles WoL (what is rarely the case).
      Typically WoL is handled by the MAC driver.
      
      phylib knows about this and handles it in mdio_bus_phy_may_suspend(),
      but that's used only when suspending the system, not in other cases
      like shutdown.
      
      Therefore factor out the relevant check from
      mdio_bus_phy_may_suspend() to a new function phy_may_suspend() and
      use it in phy_suspend().
      
      Last but not least change phy_detach() to call phy_suspend() before
      attached_dev is set to NULL. phy_suspend() accesses attached_dev
      when checking whether the MAC driver activated WoL.
      
      Fixes: f1e911d5 ("r8169: add basic phylib support")
      Fixes: e8cfd9d6 ("net: phy: call state machine synchronously in phy_stop")
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e0511f6c
  8. Sep 26, 2018
  9. Sep 22, 2018
  10. Sep 20, 2018
  11. Sep 19, 2018
    • Russell King's avatar
      sfp: fix oops with ethtool -m · 126d6848
      Russell King authored
      
      If a network interface is created prior to the SFP socket being
      available, ethtool can request module information.  This unfortunately
      leads to an oops:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000008
      pgd = (ptrval)
      [00000008] *pgd=7c400831, *pte=00000000, *ppte=00000000
      Internal error: Oops: 17 [#1] SMP ARM
      Modules linked in:
      CPU: 0 PID: 1480 Comm: ethtool Not tainted 4.19.0-rc3 #138
      Hardware name: Broadcom Northstar Plus SoC
      PC is at sfp_get_module_info+0x8/0x10
      LR is at dev_ethtool+0x218c/0x2afc
      
      Fix this by not filling in the network device's SFP bus pointer until
      SFP is fully bound, thereby avoiding the core calling into the SFP bus
      code.
      
      Fixes: ce0aa27f ("sfp: add sfp-bus to bridge between network devices and sfp cages")
      Reported-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      126d6848
  12. Sep 18, 2018
  13. Sep 16, 2018
  14. Sep 13, 2018
Loading