1. 10 Jun, 2019 11 commits
    • David S. Miller's avatar
      Merge branch 'Avoid-local_irq_save-and-use-napi_alloc_frag-where-possible' · e8a492cd
      David S. Miller authored
      Sebastian Andrzej says:
      
      ====================
      Avoid local_irq_save() and use napi_alloc_frag() where possible
      
      The first two patches remove local_irq_save() around
      `netdev_alloc_cache' which does not work on -RT. Besides helping -RT it
      whould benefit the users of the function since they can avoid disabling
      interrupts and save a few cycles.
      The remaining patches are from a time when I tried to remove
      `netdev_alloc_cache' but then noticed that we still have non-NAPI
      drivers using netdev_alloc_skb() and I dropped that idea. Using
      napi_alloc_frag() over netdev_alloc_frag() would skip the not required
      local_bh_disable() around the allocation.
      
      v1…v2:
        - 1/7 + 2/7 use now "(in_irq() || irqs_disabled())" instead just
          "irqs_disabled()" to align with __dev_kfree_skb_any(). Pointed out
          by Eric Dumazet.
      
        - 6/7 has a typo less. Pointed out by Sergei Shtylyov.
      
        - 3/7 + 4/7 added acks from Ioana Radulescu.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e8a492cd
    • Sebastian Andrzej Siewior's avatar
      net: hwbm: Make the hwbm_pool lock a mutex · 6dcdd884
      Sebastian Andrzej Siewior authored
      Based on review, `lock' is only acquired in hwbm_pool_add() which is
      invoked via ->probe(), ->resume() and ->ndo_change_mtu(). Based on this
      the lock can become a mutex and there is no need to disable interrupts
      during the procedure.
      Now that the lock is a mutex, hwbm_pool_add() no longer invokes
      hwbm_pool_refill() in an atomic context so we can pass GFP_KERNEL to
      hwbm_pool_refill() and remove the `gfp' argument from hwbm_pool_add().
      
      Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6dcdd884
    • Sebastian Andrzej Siewior's avatar
      tg3: Use napi_alloc_frag() · 49eef82d
      Sebastian Andrzej Siewior authored
      tg3_alloc_rx_data() uses netdev_alloc_frag() for skb allocation. All
      callers of tg3_alloc_rx_data() either hold tp->lock (which is held with
      BH disabled) or run in NAPI context.
      
      Use napi_alloc_frag() for skb allocations.
      
      Cc: Siva Reddy Kallam <siva.kallam@broadcom.com>
      Cc: Prashant Sreedharan <prashant@broadcom.com>
      Cc: Michael Chan <mchan@broadcom.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      49eef82d
    • Sebastian Andrzej Siewior's avatar
      bnx2x: Use napi_alloc_frag() · 3a89aae4
      Sebastian Andrzej Siewior authored
      SKB allocation via bnx2x_frag_alloc() is always performed in NAPI
      context. Preemptible context passes GFP_KERNEL and bnx2x_frag_alloc()
      uses then __get_free_page() for the allocation.
      
      Use napi_alloc_frag() for memory allocation.
      
      Cc: Ariel Elior <aelior@marvell.com>
      Cc: Sudarsana Kalluru <skalluru@marvell.com>
      Cc: GR-everest-linux-l2@marvell.com
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3a89aae4
    • Sebastian Andrzej Siewior's avatar
      dpaa2-eth: Use napi_alloc_frag() · 90bc6d4b
      Sebastian Andrzej Siewior authored
      The driver is using netdev_alloc_frag() for allocation in the
      ->ndo_start_xmit() path. That one is always invoked in a BH disabled
      region so we could also use napi_alloc_frag().
      
      Use napi_alloc_frag() for skb allocation.
      
      Cc: Ioana Radulescu <ruxandra.radulescu@nxp.com>
      Acked-by: default avatarIoana Radulescu <ruxandra.radulescu@nxp.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      90bc6d4b
    • Sebastian Andrzej Siewior's avatar
      dpaa2-eth: Remove preempt_disable() from seed_pool() · f9dae555
      Sebastian Andrzej Siewior authored
      According to the comment, the preempt_disable() statement is required
      due to synchronisation in napi_alloc_frag(). The awful truth is that
      local_bh_disable() is required because otherwise the NAPI poll callback
      can be invoked while the open function setup buffers. This isn't
      unlikely since the dpaa2 provides multiple devices.
      
      The usage of napi_alloc_frag() has been removed in commit
      
       27c87486 ("dpaa2-eth: Use a single page per Rx buffer")
      
      which means that the comment is not accurate and the preempt_disable()
      statement is not required.
      
      Remove the outdated comment and the no longer required
      preempt_disable().
      
      Cc: Ioana Radulescu <ruxandra.radulescu@nxp.com>
      Acked-by: default avatarIoana Radulescu <ruxandra.radulescu@nxp.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f9dae555
    • Sebastian Andrzej Siewior's avatar
      net: Don't disable interrupts in __netdev_alloc_skb() · 92dcabd7
      Sebastian Andrzej Siewior authored
      __netdev_alloc_skb() can be used from any context and is used by NAPI
      and non-NAPI drivers. Non-NAPI drivers use it in interrupt context and
      NAPI drivers use it during initial allocation (->ndo_open() or
      ->ndo_change_mtu()). Some NAPI drivers share the same function for the
      initial allocation and the allocation in their NAPI callback.
      
      The interrupts are disabled in order to ensure locked access from every
      context to `netdev_alloc_cache'.
      
      Let __netdev_alloc_skb() check if interrupts are disabled. If they are, use
      `netdev_alloc_cache'. Otherwise disable BH and use `napi_alloc_cache.page'.
      The IRQ check is cheaper compared to disabling & enabling interrupts and
      memory allocation with disabled interrupts does not work on -RT.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      92dcabd7
    • Sebastian Andrzej Siewior's avatar
      net: Don't disable interrupts in napi_alloc_frag() · 7ba7aeab
      Sebastian Andrzej Siewior authored
      netdev_alloc_frag() can be used from any context and is used by NAPI
      and non-NAPI drivers. Non-NAPI drivers use it in interrupt context
      and NAPI drivers use it during initial allocation (->ndo_open() or
      ->ndo_change_mtu()). Some NAPI drivers share the same function for the
      initial allocation and the allocation in their NAPI callback.
      
      The interrupts are disabled in order to ensure locked access from every
      context to `netdev_alloc_cache'.
      
      Let netdev_alloc_frag() check if interrupts are disabled. If they are,
      use `netdev_alloc_cache' otherwise disable BH and invoke
      __napi_alloc_frag() for the allocation. The IRQ check is cheaper
      compared to disabling & enabling interrupts and memory allocation with
      disabled interrupts does not work on -RT.
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7ba7aeab
    • David S. Miller's avatar
      Merge branch 'SFP-polling-fixes' · 9e49fe4d
      David S. Miller authored
      Robert Hancock says:
      
      ====================
      SFP polling fixes
      
      This has an updated version of an earlier patch to ensure that SFP
      operations are stopped during shutdown, and another patch suggested by
      Russell King to address a potential concurrency issue with SFP state
      checks.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9e49fe4d
    • Robert Hancock's avatar
      net: sfp: add mutex to prevent concurrent state checks · 2158e856
      Robert Hancock authored
      sfp_check_state can potentially be called by both a threaded IRQ handler
      and delayed work. If it is concurrently called, it could result in
      incorrect state management. Add a st_mutex to protect the state - this
      lock gets taken outside of code that checks and handle state changes, and
      the existing sm_mutex nests inside of it.
      Suggested-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarRobert Hancock <hancock@sedsystems.ca>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2158e856
    • Robert Hancock's avatar
      net: sfp: Stop SFP polling and interrupt handling during shutdown · 257c2559
      Robert Hancock authored
      SFP device polling can cause problems during the shutdown process if the
      parent devices of the network controller have been shut down already.
      This problem was seen on the iMX6 platform with PCIe devices, where
      accessing the device after the bus is shut down causes a hang.
      
      Free any acquired GPIO interrupts and stop all delayed work in the SFP
      driver during the shutdown process, so that we ensure that no pending
      operations are still occurring after the SFP shutdown completes.
      Signed-off-by: default avatarRobert Hancock <hancock@sedsystems.ca>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      257c2559
  2. 09 Jun, 2019 29 commits