Skip to content
Snippets Groups Projects
  1. Sep 09, 2021
    • Joakim Zhang's avatar
      net: stmmac: platform: fix build warning when with !CONFIG_PM_SLEEP · 2a48d96f
      Joakim Zhang authored
      
      Use __maybe_unused for noirq_suspend()/noirq_resume() hooks to avoid
      build warning with !CONFIG_PM_SLEEP:
      
      >> drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:796:12: error: 'stmmac_pltfr_noirq_resume' defined but not used [-Werror=unused-function]
           796 | static int stmmac_pltfr_noirq_resume(struct device *dev)
               |            ^~~~~~~~~~~~~~~~~~~~~~~~~
      >> drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:775:12: error: 'stmmac_pltfr_noirq_suspend' defined but not used [-Werror=unused-function]
           775 | static int stmmac_pltfr_noirq_suspend(struct device *dev)
               |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
         cc1: all warnings being treated as errors
      
      Fixes: 276aae37 ("net: stmmac: fix system hang caused by eee_ctrl_timer during suspend/resume")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2a48d96f
  2. Sep 08, 2021
    • Joakim Zhang's avatar
      net: stmmac: fix system hang caused by eee_ctrl_timer during suspend/resume · 276aae37
      Joakim Zhang authored
      
      commit 5f585913 ("net: stmmac: delete the eee_ctrl_timer after
      napi disabled"), this patch tries to fix system hang caused by eee_ctrl_timer,
      unfortunately, it only can resolve it for system reboot stress test. System
      hang also can be reproduced easily during system suspend/resume stess test
      when mount NFS on i.MX8MP EVK board.
      
      In stmmac driver, eee feature is combined to phylink framework. When do
      system suspend, phylink_stop() would queue delayed work, it invokes
      stmmac_mac_link_down(), where to deactivate eee_ctrl_timer synchronizly.
      In above commit, try to fix issue by deactivating eee_ctrl_timer obviously,
      but it is not enough. Looking into eee_ctrl_timer expire callback
      stmmac_eee_ctrl_timer(), it could enable hareware eee mode again. What is
      unexpected is that LPI interrupt (MAC_Interrupt_Enable.LPIEN bit) is always
      asserted. This interrupt has chance to be issued when LPI state entry/exit
      from the MAC, and at that time, clock could have been already disabled.
      The result is that system hang when driver try to touch register from
      interrupt handler.
      
      The reason why above commit can fix system hang issue in stmmac_release()
      is that, deactivate eee_ctrl_timer not just after napi disabled, further
      after irq freed.
      
      In conclusion, hardware would generate LPI interrupt when clock has been
      disabled during suspend or resume, since hardware is in eee mode and LPI
      interrupt enabled.
      
      Interrupts from MAC, MTL and DMA level are enabled and never been disabled
      when system suspend, so postpone clocks management from suspend stage to
      noirq suspend stage should be more safe.
      
      Fixes: 5f585913 ("net: stmmac: delete the eee_ctrl_timer after napi disabled")
      Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      276aae37
  3. Jul 07, 2021
  4. Jun 16, 2021
  5. Jun 08, 2021
    • Matthew Hagan's avatar
      net: stmmac: explicitly deassert GMAC_AHB_RESET · e67f325e
      Matthew Hagan authored
      
      We are currently assuming that GMAC_AHB_RESET will already be deasserted
      by the bootloader. However if this has not been done, probing of the GMAC
      will fail. To remedy this we must ensure GMAC_AHB_RESET has been deasserted
      prior to probing.
      
      v2 changes:
       - remove NULL condition check for stmmac_ahb_rst in stmmac_main.c
       - unwrap dev_err() message in stmmac_main.c
       - add PTR_ERR() around plat->stmmac_ahb_rst in stmmac_platform.c
      
      v3 changes:
       - add error pointer to dev_err() output
       - add reset_control_assert(stmmac_ahb_rst) in stmmac_dvr_remove
       - revert PTR_ERR() around plat->stmmac_ahb_rst since this is performed
         on the returned value of ret by the calling function
      
      Signed-off-by: default avatarMatthew Hagan <mnhagan88@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e67f325e
  6. May 10, 2021
  7. Apr 13, 2021
    • Michael Walle's avatar
      of: net: pass the dst buffer to of_get_mac_address() · 83216e39
      Michael Walle authored
      
      of_get_mac_address() returns a "const void*" pointer to a MAC address.
      Lately, support to fetch the MAC address by an NVMEM provider was added.
      But this will only work with platform devices. It will not work with
      PCI devices (e.g. of an integrated root complex) and esp. not with DSA
      ports.
      
      There is an of_* variant of the nvmem binding which works without
      devices. The returned data of a nvmem_cell_read() has to be freed after
      use. On the other hand the return of_get_mac_address() points to some
      static data without a lifetime. The trick for now, was to allocate a
      device resource managed buffer which is then returned. This will only
      work if we have an actual device.
      
      Change it, so that the caller of of_get_mac_address() has to supply a
      buffer where the MAC address is written to. Unfortunately, this will
      touch all drivers which use the of_get_mac_address().
      
      Usually the code looks like:
      
        const char *addr;
        addr = of_get_mac_address(np);
        if (!IS_ERR(addr))
          ether_addr_copy(ndev->dev_addr, addr);
      
      This can then be simply rewritten as:
      
        of_get_mac_address(np, ndev->dev_addr);
      
      Sometimes is_valid_ether_addr() is used to test the MAC address.
      of_get_mac_address() already makes sure, it just returns a valid MAC
      address. Thus we can just test its return code. But we have to be
      careful if there are still other sources for the MAC address before the
      of_get_mac_address(). In this case we have to keep the
      is_valid_ether_addr() call.
      
      The following coccinelle patch was used to convert common cases to the
      new style. Afterwards, I've manually gone over the drivers and fixed the
      return code variable: either used a new one or if one was already
      available use that. Mansour Moufid, thanks for that coccinelle patch!
      
      <spml>
      @a@
      identifier x;
      expression y, z;
      @@
      - x = of_get_mac_address(y);
      + x = of_get_mac_address(y, z);
        <...
      - ether_addr_copy(z, x);
        ...>
      
      @@
      identifier a.x;
      @@
      - if (<+... x ...+>) {}
      
      @@
      identifier a.x;
      @@
        if (<+... x ...+>) {
            ...
        }
      - else {}
      
      @@
      identifier a.x;
      expression e;
      @@
      - if (<+... x ...+>@e)
      -     {}
      - else
      + if (!(e))
            {...}
      
      @@
      expression x, y, z;
      @@
      - x = of_get_mac_address(y, z);
      + of_get_mac_address(y, z);
        ... when != x
      </spml>
      
      All drivers, except drivers/net/ethernet/aeroflex/greth.c, were
      compile-time tested.
      
      Suggested-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarMichael Walle <michael@walle.cc>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      83216e39
  8. Mar 22, 2021
    • Wei Yongjun's avatar
      net: stmmac: platform: fix build error with !CONFIG_PM_SLEEP · 7ec05a60
      Wei Yongjun authored
      
      Get rid of the CONFIG_PM_SLEEP ifdefery to fix the build error
      and use __maybe_unused for the suspend()/resume() hooks to avoid
      build warning:
      
      drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:769:21:
       error: 'stmmac_runtime_suspend' undeclared here (not in a function); did you mean 'stmmac_suspend'?
        769 |  SET_RUNTIME_PM_OPS(stmmac_runtime_suspend, stmmac_runtime_resume, NULL)
            |                     ^~~~~~~~~~~~~~~~~~~~~~
      ./include/linux/pm.h:342:21: note: in definition of macro 'SET_RUNTIME_PM_OPS'
        342 |  .runtime_suspend = suspend_fn, \
            |                     ^~~~~~~~~~
      drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:769:45:
       error: 'stmmac_runtime_resume' undeclared here (not in a function)
        769 |  SET_RUNTIME_PM_OPS(stmmac_runtime_suspend, stmmac_runtime_resume, NULL)
            |                                             ^~~~~~~~~~~~~~~~~~~~~
      ./include/linux/pm.h:343:20: note: in definition of macro 'SET_RUNTIME_PM_OPS'
        343 |  .runtime_resume = resume_fn, \
            |                    ^~~~~~~~~
      
      Fixes: 5ec55823 ("net: stmmac: add clocks management for gmac driver")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7ec05a60
  9. Mar 15, 2021
    • Joakim Zhang's avatar
      net: stmmac: add clocks management for gmac driver · 5ec55823
      Joakim Zhang authored
      
      This patch intends to add clocks management for stmmac driver:
      
      If CONFIG_PM enabled:
      1. Keep clocks disabled after driver probed.
      2. Enable clocks when up the net device, and disable clocks when down
      the net device.
      
      If CONFIG_PM disabled:
      Keep clocks always enabled after driver probed.
      
      Note:
      1. It is fine for ethtool, since the way of implementing ethtool_ops::begin
      in stmmac is only can be accessed when interface is enabled, so the clocks
      are ticked.
      2. The MDIO bus has a different life cycle to the MAC, need ensure
      clocks are enabled when _mdio_read/write() need clocks, because these
      functions can be called while the interface it not opened.
      
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5ec55823
  10. Nov 14, 2020
  11. Sep 25, 2020
    • Jesse Brandeburg's avatar
      drivers/net/ethernet: clean up mis-targeted comments · d0ea5cbd
      Jesse Brandeburg authored
      
      As part of the W=1 cleanups for ethernet, a million [*] driver
      comments had to be cleaned up to get the W=1 compilation to
      succeed. This change finally makes the drivers/net/ethernet tree
      compile with W=1 set on the command line. NOTE: The kernel uses
      kdoc style (see Documentation/process/kernel-doc.rst) when
      documenting code, not doxygen or other styles.
      
      After this patch the x86_64 build has no warnings from W=1, however
      scripts/kernel-doc says there are 1545 more warnings in source files, that
      I need to develop a script to fix in a followup patch.
      
      The errors fixed here are all kdoc of a few classes, with a few outliers:
      In file included from drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c:10:
      drivers/net/ethernet/qlogic/netxen/netxen_nic.h:1193:18: warning: ‘FW_DUMP_LEVELS’ defined but not used [-Wunused-const-variable=]
       1193 | static const u32 FW_DUMP_LEVELS[] = { 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff };
            |                  ^~~~~~~~~~~~~~
      ... repeats 4 times...
      drivers/net/ethernet/sun/cassini.c:2084:24: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]
       2084 |    RX_USED_ADD(page, i);
      drivers/net/ethernet/natsemi/ns83820.c: In function ‘phy_intr’:
      drivers/net/ethernet/natsemi/ns83820.c:603:6: warning: variable ‘tbisr’ set but not used [-Wunused-but-set-variable]
        603 |  u32 tbisr, tanar, tanlpar;
            |      ^~~~~
      drivers/net/ethernet/natsemi/ns83820.c: In function ‘ns83820_get_link_ksettings’:
      drivers/net/ethernet/natsemi/ns83820.c:1207:11: warning: variable ‘tanar’ set but not used [-Wunused-but-set-variable]
       1207 |  u32 cfg, tanar, tbicr;
            |           ^~~~~
      drivers/net/ethernet/packetengines/yellowfin.c:1063:18: warning: variable ‘yf_size’ set but not used [-Wunused-but-set-variable]
       1063 |   int data_size, yf_size;
            |                  ^~~~~~~
      
      Normal kdoc fixes:
      warning: Function parameter or member 'x' not described in 'y'
      warning: Excess function parameter 'x' description in 'y'
      warning: Cannot understand <string> on line <NNN> - I thought it was a doc line
      
      [*] - ok it wasn't quite a million, but it felt like it.
      
      Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d0ea5cbd
  12. May 30, 2020
  13. Mar 15, 2020
  14. Feb 24, 2020
  15. Jan 25, 2020
  16. Jan 07, 2020
  17. Dec 21, 2019
  18. 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
  19. Sep 11, 2019
    • Alexandru Ardelean's avatar
      net: stmmac: implement support for passive mode converters via dt · 0060c878
      Alexandru Ardelean authored
      
      In-between the MAC & PHY there can be a mode converter, which converts one
      mode to another (e.g. GMII-to-RGMII).
      
      The converter, can be passive (i.e. no driver or OS/SW information
      required), so the MAC & PHY need to be configured differently.
      
      For the `stmmac` driver, this is implemented via a `mac-mode` property in
      the device-tree, which configures the MAC into a certain mode, and for the
      PHY a `phy_interface` field will hold the mode of the PHY. The mode of the
      PHY will be passed to the PHY and from there-on it work in a different
      mode. If unspecified, the default `phy-mode` will be used for both.
      
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0060c878
  20. Sep 06, 2019
  21. Jul 30, 2019
    • Stephen Boyd's avatar
      net: Remove dev_err() usage after platform_get_irq() · d1a55841
      Stephen Boyd authored
      
      We don't need dev_err() messages when platform_get_irq() fails now that
      platform_get_irq() prints an error message itself when something goes
      wrong. Let's remove these prints with a simple semantic patch.
      
      // <smpl>
      @@
      expression ret;
      struct platform_device *E;
      @@
      
      ret =
      (
      platform_get_irq(E, ...)
      |
      platform_get_irq_byname(E, ...)
      );
      
      if ( \( ret < 0 \| ret <= 0 \) )
      {
      (
      -if (ret != -EPROBE_DEFER)
      -{ ...
      -dev_err(...);
      -... }
      |
      ...
      -dev_err(...);
      )
      ...
      }
      // </smpl>
      
      While we're here, remove braces on if statements that only have one
      statement (manually).
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Kalle Valo <kvalo@codeaurora.org>
      Cc: Saeed Mahameed <saeedm@mellanox.com>
      Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Lorenzo Bianconi <lorenzo@kernel.org>
      Cc: netdev@vger.kernel.org
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarStephen Boyd <swboyd@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d1a55841
  22. Jul 29, 2019
  23. Jul 27, 2019
  24. Jun 15, 2019
  25. Jun 13, 2019
  26. Jun 05, 2019
    • Thomas Gleixner's avatar
      treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 291 · 4fa9c49f
      Thomas Gleixner authored
      
      Based on 2 normalized pattern(s):
      
        this program is free software you can redistribute it and or modify
        it under the terms and conditions of the gnu general public license
        version 2 as published by the free software foundation this program
        is distributed in the hope it will be useful but without any
        warranty without even the implied warranty of merchantability or
        fitness for a particular purpose see the gnu general public license
        for more details the full gnu general public license is included in
        this distribution in the file called copying
      
        this program is free software you can redistribute it and or modify
        it under the terms and conditions of the gnu general public license
        version 2 as published by the free software foundation this program
        is distributed in the hope [that] it will be useful but without any
        warranty without even the implied warranty of merchantability or
        fitness for a particular purpose see the gnu general public license
        for more details the full gnu general public license is included in
        this distribution in the file called copying
      
      extracted by the scancode license scanner the SPDX license identifier
      
        GPL-2.0-only
      
      has been chosen to replace the boilerplate/reference in 57 file(s).
      
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarAlexios Zavras <alexios.zavras@intel.com>
      Reviewed-by: default avatarAllison Randal <allison@lohutok.net>
      Cc: linux-spdx@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190529141901.515993066@linutronix.de
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fa9c49f
  27. May 25, 2019
  28. Mar 08, 2019
  29. Sep 16, 2018
  30. Aug 09, 2018
  31. Jul 16, 2018
  32. May 29, 2018
  33. Feb 20, 2018
  34. Nov 03, 2017
  35. Oct 27, 2017
  36. Sep 21, 2017
Loading