950-0292-net-bcmgenet-Reset-RBUF-on-first-open.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From 87bb6f0edf9a4a14d9b41bcfe97216f74f730b43 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <[email protected]>
  3. Date: Fri, 25 Sep 2020 15:07:23 +0100
  4. Subject: [PATCH] net: bcmgenet: Reset RBUF on first open
  5. If the RBUF logic is not reset when the kernel starts then there
  6. may be some data left over from any network boot loader. If the
  7. 64-byte packet headers are enabled then this can be fatal.
  8. Extend bcmgenet_dma_disable to do perform the reset, but not when
  9. called from bcmgenet_resume in order to preserve a wake packet.
  10. N.B. This different handling of resume is just based on a hunch -
  11. why else wouldn't one reset the RBUF as well as the TBUF? If this
  12. isn't the case then it's easy to change the patch to make the RBUF
  13. reset unconditional.
  14. See: https://github.com/raspberrypi/linux/issues/3850
  15. Signed-off-by: Phil Elwell <[email protected]>
  16. ---
  17. drivers/net/ethernet/broadcom/genet/bcmgenet.c | 16 ++++++++++++----
  18. 1 file changed, 12 insertions(+), 4 deletions(-)
  19. --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
  20. +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
  21. @@ -3265,7 +3265,7 @@ static void bcmgenet_get_hw_addr(struct
  22. }
  23. /* Returns a reusable dma control register value */
  24. -static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv)
  25. +static u32 bcmgenet_dma_disable(struct bcmgenet_priv *priv, bool flush_rx)
  26. {
  27. unsigned int i;
  28. u32 reg;
  29. @@ -3290,6 +3290,14 @@ static u32 bcmgenet_dma_disable(struct b
  30. udelay(10);
  31. bcmgenet_umac_writel(priv, 0, UMAC_TX_FLUSH);
  32. + if (flush_rx) {
  33. + reg = bcmgenet_rbuf_ctrl_get(priv);
  34. + bcmgenet_rbuf_ctrl_set(priv, reg | BIT(0));
  35. + udelay(10);
  36. + bcmgenet_rbuf_ctrl_set(priv, reg);
  37. + udelay(10);
  38. + }
  39. +
  40. return dma_ctrl;
  41. }
  42. @@ -3353,8 +3361,8 @@ static int bcmgenet_open(struct net_devi
  43. bcmgenet_set_hw_addr(priv, dev->dev_addr);
  44. - /* Disable RX/TX DMA and flush TX queues */
  45. - dma_ctrl = bcmgenet_dma_disable(priv);
  46. + /* Disable RX/TX DMA and flush TX and RX queues */
  47. + dma_ctrl = bcmgenet_dma_disable(priv, true);
  48. /* Reinitialize TDMA and RDMA and SW housekeeping */
  49. ret = bcmgenet_init_dma(priv);
  50. @@ -4212,7 +4220,7 @@ static int bcmgenet_resume(struct device
  51. bcmgenet_hfb_create_rxnfc_filter(priv, rule);
  52. /* Disable RX/TX DMA and flush TX queues */
  53. - dma_ctrl = bcmgenet_dma_disable(priv);
  54. + dma_ctrl = bcmgenet_dma_disable(priv, false);
  55. /* Reinitialize TDMA and RDMA and SW housekeeping */
  56. ret = bcmgenet_init_dma(priv);