331-v4.18-0002-brcmfmac-coarse-support-for-PCIe-shared-structure-re.patch 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. From f56324baf329bc9362a52ad77a4a1a0f3356d1bc Mon Sep 17 00:00:00 2001
  2. From: Franky Lin <franky.lin@broadcom.com>
  3. Date: Thu, 26 Apr 2018 12:16:51 +0200
  4. Subject: [PATCH] brcmfmac: coarse support for PCIe shared structure rev7
  5. Revision 7 of PCIe dongle interface increases the item size of tx and rx
  6. complete rings to accommodate extra payload for new feature. This patch
  7. simply bump up the size of these two rings without adding the support
  8. for utilizing the new space. This makes brcmfmac compatible with rev7
  9. firmware.
  10. Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  11. Signed-off-by: Franky Lin <franky.lin@broadcom.com>
  12. Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  13. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  14. ---
  15. .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.h | 6 ++++--
  16. .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 23 ++++++++++++++++++----
  17. 2 files changed, 23 insertions(+), 6 deletions(-)
  18. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.h
  19. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.h
  20. @@ -27,8 +27,10 @@
  21. #define BRCMF_H2D_MSGRING_CONTROL_SUBMIT_ITEMSIZE 40
  22. #define BRCMF_H2D_MSGRING_RXPOST_SUBMIT_ITEMSIZE 32
  23. #define BRCMF_D2H_MSGRING_CONTROL_COMPLETE_ITEMSIZE 24
  24. -#define BRCMF_D2H_MSGRING_TX_COMPLETE_ITEMSIZE 16
  25. -#define BRCMF_D2H_MSGRING_RX_COMPLETE_ITEMSIZE 32
  26. +#define BRCMF_D2H_MSGRING_TX_COMPLETE_ITEMSIZE_PRE_V7 16
  27. +#define BRCMF_D2H_MSGRING_TX_COMPLETE_ITEMSIZE 24
  28. +#define BRCMF_D2H_MSGRING_RX_COMPLETE_ITEMSIZE_PRE_V7 32
  29. +#define BRCMF_D2H_MSGRING_RX_COMPLETE_ITEMSIZE 40
  30. #define BRCMF_H2D_TXFLOWRING_ITEMSIZE 48
  31. struct msgbuf_buf_addr {
  32. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  33. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  34. @@ -135,8 +135,9 @@ static struct brcmf_firmware_mapping brc
  35. BRCMF_PCIE_MB_INT_D2H3_DB0 | \
  36. BRCMF_PCIE_MB_INT_D2H3_DB1)
  37. +#define BRCMF_PCIE_SHARED_VERSION_7 7
  38. #define BRCMF_PCIE_MIN_SHARED_VERSION 5
  39. -#define BRCMF_PCIE_MAX_SHARED_VERSION 6
  40. +#define BRCMF_PCIE_MAX_SHARED_VERSION BRCMF_PCIE_SHARED_VERSION_7
  41. #define BRCMF_PCIE_SHARED_VERSION_MASK 0x00FF
  42. #define BRCMF_PCIE_SHARED_DMA_INDEX 0x10000
  43. #define BRCMF_PCIE_SHARED_DMA_2B_IDX 0x100000
  44. @@ -316,6 +317,14 @@ static const u32 brcmf_ring_max_item[BRC
  45. BRCMF_D2H_MSGRING_RX_COMPLETE_MAX_ITEM
  46. };
  47. +static const u32 brcmf_ring_itemsize_pre_v7[BRCMF_NROF_COMMON_MSGRINGS] = {
  48. + BRCMF_H2D_MSGRING_CONTROL_SUBMIT_ITEMSIZE,
  49. + BRCMF_H2D_MSGRING_RXPOST_SUBMIT_ITEMSIZE,
  50. + BRCMF_D2H_MSGRING_CONTROL_COMPLETE_ITEMSIZE,
  51. + BRCMF_D2H_MSGRING_TX_COMPLETE_ITEMSIZE_PRE_V7,
  52. + BRCMF_D2H_MSGRING_RX_COMPLETE_ITEMSIZE_PRE_V7
  53. +};
  54. +
  55. static const u32 brcmf_ring_itemsize[BRCMF_NROF_COMMON_MSGRINGS] = {
  56. BRCMF_H2D_MSGRING_CONTROL_SUBMIT_ITEMSIZE,
  57. BRCMF_H2D_MSGRING_RXPOST_SUBMIT_ITEMSIZE,
  58. @@ -999,8 +1008,14 @@ brcmf_pcie_alloc_dma_and_ring(struct brc
  59. struct brcmf_pcie_ringbuf *ring;
  60. u32 size;
  61. u32 addr;
  62. + const u32 *ring_itemsize_array;
  63. +
  64. + if (devinfo->shared.version < BRCMF_PCIE_SHARED_VERSION_7)
  65. + ring_itemsize_array = brcmf_ring_itemsize_pre_v7;
  66. + else
  67. + ring_itemsize_array = brcmf_ring_itemsize;
  68. - size = brcmf_ring_max_item[ring_id] * brcmf_ring_itemsize[ring_id];
  69. + size = brcmf_ring_max_item[ring_id] * ring_itemsize_array[ring_id];
  70. dma_buf = brcmf_pcie_init_dmabuffer_for_device(devinfo, size,
  71. tcm_ring_phys_addr + BRCMF_RING_MEM_BASE_ADDR_OFFSET,
  72. &dma_handle);
  73. @@ -1010,7 +1025,7 @@ brcmf_pcie_alloc_dma_and_ring(struct brc
  74. addr = tcm_ring_phys_addr + BRCMF_RING_MAX_ITEM_OFFSET;
  75. brcmf_pcie_write_tcm16(devinfo, addr, brcmf_ring_max_item[ring_id]);
  76. addr = tcm_ring_phys_addr + BRCMF_RING_LEN_ITEMS_OFFSET;
  77. - brcmf_pcie_write_tcm16(devinfo, addr, brcmf_ring_itemsize[ring_id]);
  78. + brcmf_pcie_write_tcm16(devinfo, addr, ring_itemsize_array[ring_id]);
  79. ring = kzalloc(sizeof(*ring), GFP_KERNEL);
  80. if (!ring) {
  81. @@ -1019,7 +1034,7 @@ brcmf_pcie_alloc_dma_and_ring(struct brc
  82. return NULL;
  83. }
  84. brcmf_commonring_config(&ring->commonring, brcmf_ring_max_item[ring_id],
  85. - brcmf_ring_itemsize[ring_id], dma_buf);
  86. + ring_itemsize_array[ring_id], dma_buf);
  87. ring->dma_handle = dma_handle;
  88. ring->devinfo = devinfo;
  89. brcmf_commonring_register_cb(&ring->commonring,