1. 04 5月, 2019 1 次提交
  2. 14 3月, 2019 1 次提交
  3. 13 1月, 2019 3 次提交
    • A
      net: macb: add missing barriers when reading descriptors · 98876c46
      Anssi Hannula 提交于
      [ Upstream commit 6e0af298066f3b6d99f58989bb0dca6f764b4c6d ]
      
      When reading buffer descriptors on RX or on TX completion, an
      RX_USED/TX_USED bit is checked first to ensure that the descriptors have
      been populated, i.e. the ownership has been transferred. However, there
      are no memory barriers to ensure that the data protected by the
      RX_USED/TX_USED bit is up-to-date with respect to that bit.
      
      Specifically:
      
      - TX timestamp descriptors may be loaded before ctrl is loaded for the
        TX_USED check, which is racy as the descriptors may be updated between
        the loads, causing old timestamp descriptor data to be used.
      
      - RX ctrl may be loaded before addr is loaded for the RX_USED check,
        which is racy as a new frame may be written between the loads, causing
        old ctrl descriptor data to be used.
        This issue exists for both macb_rx() and gem_rx() variants.
      
      Fix the races by adding DMA read memory barriers on those paths and
      reordering the reads in macb_rx().
      
      I have not observed any actual problems in practice caused by these
      being missing, though.
      
      Tested on a ZynqMP based system.
      
      Fixes: 89e5785f ("[PATCH] Atmel MACB ethernet driver")
      Signed-off-by: NAnssi Hannula <anssi.hannula@bitwise.fi>
      Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      98876c46
    • A
      net: macb: fix dropped RX frames due to a race · 6e48c0fc
      Anssi Hannula 提交于
      [ Upstream commit 8159ecab0db9095902d4c73605fb8787f5c7d653 ]
      
      Bit RX_USED set to 0 in the address field allows the controller to write
      data to the receive buffer descriptor.
      
      The driver does not ensure the ctrl field is ready (cleared) when the
      controller sees the RX_USED=0 written by the driver. The ctrl field might
      only be cleared after the controller has already updated it according to
      a newly received frame, causing the frame to be discarded in gem_rx() due
      to unexpected ctrl field contents.
      
      A message is logged when the above scenario occurs:
      
        macb ff0b0000.ethernet eth0: not whole frame pointed by descriptor
      
      Fix the issue by ensuring that when the controller sees RX_USED=0 the
      ctrl field is already cleared.
      
      This issue was observed on a ZynqMP based system.
      
      Fixes: 4df95131 ("net/macb: change RX path for GEM")
      Signed-off-by: NAnssi Hannula <anssi.hannula@bitwise.fi>
      Tested-by: NClaudiu Beznea <claudiu.beznea@microchip.com>
      Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6e48c0fc
    • A
      net: macb: fix random memory corruption on RX with 64-bit DMA · 873f9a55
      Anssi Hannula 提交于
      [ Upstream commit e100a897bf9b19089e57f236f2398c9e0538900e ]
      
      64-bit DMA addresses are split in upper and lower halves that are
      written in separate fields on GEM. For RX, bit 0 of the address is used
      as the ownership bit (RX_USED). When the RX_USED bit is unset the
      controller is allowed to write data to the buffer.
      
      The driver does not guarantee that the controller already sees the upper
      half when the RX_USED bit is cleared, possibly resulting in the
      controller writing an incoming frame to an address with an incorrect
      upper half and therefore possibly corrupting unrelated system memory.
      
      Fix that by adding the necessary DMA memory barrier between the writes.
      
      This corruption was observed on a ZynqMP based system.
      
      Fixes: fff8019a ("net: macb: Add 64 bit addressing support for GEM")
      Signed-off-by: NAnssi Hannula <anssi.hannula@bitwise.fi>
      Acked-by: NHarini Katakam <harini.katakam@xilinx.com>
      Tested-by: NClaudiu Beznea <claudiu.beznea@microchip.com>
      Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
      Cc: Michal Simek <michal.simek@xilinx.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      873f9a55
  4. 10 1月, 2019 1 次提交
  5. 26 9月, 2018 1 次提交
  6. 17 9月, 2018 1 次提交
  7. 03 9月, 2018 1 次提交
    • J
      net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx() · 16fe10cf
      Jia-Ju Bai 提交于
      The kernel module may sleep with holding a spinlock.
      
      The function call paths (from bottom to top) in Linux-4.16 are:
      
      [FUNC] usleep_range
      drivers/net/ethernet/cadence/macb_main.c, 648:
      	usleep_range in macb_halt_tx
      drivers/net/ethernet/cadence/macb_main.c, 730:
      	macb_halt_tx in macb_tx_error_task
      drivers/net/ethernet/cadence/macb_main.c, 721:
      	_raw_spin_lock_irqsave in macb_tx_error_task
      
      To fix this bug, usleep_range() is replaced with udelay().
      
      This bug is found by my static analysis tool DSAC.
      Signed-off-by: NJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      16fe10cf
  8. 26 8月, 2018 2 次提交
    • A
      net: macb: do not disable MDIO bus at open/close time · 0da70f80
      Anssi Hannula 提交于
      macb_reset_hw() is called from macb_close() and indirectly from
      macb_open(). macb_reset_hw() zeroes the NCR register, including the MPE
      (Management Port Enable) bit.
      
      This will prevent accessing any other PHYs for other Ethernet MACs on
      the MDIO bus, which remains registered at macb_reset_hw() time, until
      macb_init_hw() is called from macb_open() which sets the MPE bit again.
      
      I.e. currently the MDIO bus has a short disruption at open time and is
      disabled at close time until the interface is opened again.
      
      Fix that by only touching the RE and TE bits when enabling and disabling
      RX/TX.
      
      v2: Make macb_init_hw() NCR write a single statement.
      
      Fixes: 6c36a707 ("macb: Use generic PHY layer")
      Signed-off-by: NAnssi Hannula <anssi.hannula@bitwise.fi>
      Reviewed-by: NClaudiu Beznea <claudiu.beznea@microchip.com>
      Tested-by: NClaudiu Beznea <claudiu.beznea@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0da70f80
    • A
      net: macb: Fix regression breaking non-MDIO fixed-link PHYs · ab5f1105
      Ahmad Fatoum 提交于
      commit 739de9a1 ("net: macb: Reorganize macb_mii bringup") broke
      initializing macb on the EVB-KSZ9477 eval board.
      There, of_mdiobus_register was called even for the fixed-link representing
      the RGMII-link to the switch with the result that the driver attempts to
      enumerate PHYs on a non-existent MDIO bus:
      
      	libphy: MACB_mii_bus: probed
      	mdio_bus f0028000.ethernet-ffffffff: fixed-link has invalid PHY address
      	mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 0
              [snip]
      	mdio_bus f0028000.ethernet-ffffffff: scan phy fixed-link at address 31
      
      The "MDIO" bus registration succeeds regardless, having claimed the reset GPIO,
      and calling of_phy_register_fixed_link later on fails because it tries
      to claim the same GPIO:
      
      	macb f0028000.ethernet: broken fixed-link specification
      
      Fix this by registering the fixed-link before calling mdiobus_register.
      
      Fixes: 739de9a1 ("net: macb: Reorganize macb_mii bringup")
      Signed-off-by: NAhmad Fatoum <a.fatoum@pengutronix.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ab5f1105
  9. 08 8月, 2018 3 次提交
  10. 07 7月, 2018 2 次提交
  11. 28 6月, 2018 1 次提交
    • A
      net: macb: initialize bp->queues[0].bp for at91rm9200 · fec9d3b1
      Alexandre Belloni 提交于
      The macb driver currently crashes on at91rm9200 with the following trace:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000014
      [...]
      [<c031da44>] (macb_rx_desc) from [<c031f2bc>] (at91ether_open+0x2e8/0x3f8)
      [<c031f2bc>] (at91ether_open) from [<c041e8d8>] (__dev_open+0x120/0x13c)
      [<c041e8d8>] (__dev_open) from [<c041ec08>] (__dev_change_flags+0x17c/0x1a8)
      [<c041ec08>] (__dev_change_flags) from [<c041ec4c>] (dev_change_flags+0x18/0x4c)
      [<c041ec4c>] (dev_change_flags) from [<c07a5f4c>] (ip_auto_config+0x220/0x10b0)
      [<c07a5f4c>] (ip_auto_config) from [<c000a4fc>] (do_one_initcall+0x78/0x18c)
      [<c000a4fc>] (do_one_initcall) from [<c0783e50>] (kernel_init_freeable+0x184/0x1c4)
      [<c0783e50>] (kernel_init_freeable) from [<c0574d70>] (kernel_init+0x8/0xe8)
      [<c0574d70>] (kernel_init) from [<c00090e0>] (ret_from_fork+0x14/0x34)
      
      Solve that by initializing bp->queues[0].bp in at91ether_init (as is done
      in macb_init).
      
      Fixes: ae1f2a56 ("net: macb: Added support for many RX queues")
      Signed-off-by: NAlexandre Belloni <alexandre.belloni@bootlin.com>
      Acked-by: NNicolas Ferre <nicolas.ferre@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fec9d3b1
  12. 17 5月, 2018 1 次提交
  13. 30 3月, 2018 1 次提交
  14. 16 3月, 2018 3 次提交
  15. 30 1月, 2018 1 次提交
  16. 06 12月, 2017 5 次提交
  17. 01 12月, 2017 3 次提交
  18. 11 11月, 2017 2 次提交
  19. 01 11月, 2017 1 次提交
  20. 18 7月, 2017 1 次提交
  21. 08 7月, 2017 1 次提交
  22. 05 7月, 2017 1 次提交
  23. 01 7月, 2017 3 次提交