325-v4.17-0002-brcmfmac-move-allocation-of-control-rx-buffer-to-brc.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. From 4b5adc736828dc25ca33e263ad8c0b9dcd3bf325 Mon Sep 17 00:00:00 2001
  2. From: Arend Van Spriel <[email protected]>
  3. Date: Tue, 20 Feb 2018 00:14:19 +0100
  4. Subject: [PATCH] brcmfmac: move allocation of control rx buffer to
  5. brcmf_sdio_bus_preinit()
  6. Allocate the control rx buffer needed for firmware control interface
  7. during brcmf_sdio_bus_preinit(). This relies on common layer setting
  8. struct brcmf_bus::maxctl during brcmf_attach(). By moving the allocation
  9. we can move brcmf_attach() in subsequent change.
  10. Reviewed-by: Hante Meuleman <[email protected]>
  11. Reviewed-by: Pieter-Paul Giesberts <[email protected]>
  12. Reviewed-by: Franky Lin <[email protected]>
  13. Signed-off-by: Arend van Spriel <[email protected]>
  14. Signed-off-by: Kalle Valo <[email protected]>
  15. ---
  16. .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 26 ++++++++++------------
  17. 1 file changed, 12 insertions(+), 14 deletions(-)
  18. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  19. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  20. @@ -1707,7 +1707,6 @@ brcmf_sdio_read_control(struct brcmf_sdi
  21. int sdret;
  22. brcmf_dbg(TRACE, "Enter\n");
  23. -
  24. if (bus->rxblen)
  25. buf = vzalloc(bus->rxblen);
  26. if (!buf)
  27. @@ -3411,6 +3410,18 @@ static int brcmf_sdio_bus_preinit(struct
  28. u32 value;
  29. int err;
  30. + /* maxctl provided by common layer */
  31. + if (WARN_ON(!bus_if->maxctl))
  32. + return -EINVAL;
  33. +
  34. + /* Allocate control receive buffer */
  35. + bus_if->maxctl += bus->roundup;
  36. + value = roundup((bus_if->maxctl + SDPCM_HDRLEN), ALIGNMENT);
  37. + value += bus->head_align;
  38. + bus->rxbuf = kmalloc(value, GFP_ATOMIC);
  39. + if (bus->rxbuf)
  40. + bus->rxblen = value;
  41. +
  42. /* the commands below use the terms tx and rx from
  43. * a device perspective, ie. bus:txglom affects the
  44. * bus transfers from device to host.
  45. @@ -4209,19 +4220,6 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
  46. bus->blocksize = bus->sdiodev->func2->cur_blksize;
  47. bus->roundup = min(max_roundup, bus->blocksize);
  48. - /* Allocate buffers */
  49. - if (bus->sdiodev->bus_if->maxctl) {
  50. - bus->sdiodev->bus_if->maxctl += bus->roundup;
  51. - bus->rxblen =
  52. - roundup((bus->sdiodev->bus_if->maxctl + SDPCM_HDRLEN),
  53. - ALIGNMENT) + bus->head_align;
  54. - bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC);
  55. - if (!(bus->rxbuf)) {
  56. - brcmf_err("rxbuf allocation failed\n");
  57. - goto fail;
  58. - }
  59. - }
  60. -
  61. sdio_claim_host(bus->sdiodev->func1);
  62. /* Disable F2 to clear any intermediate frame state on the dongle */