356-v5.4-brcmfmac-get-chip-s-default-RAM-info-during-PCIe-set.patch 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 82f93cf46d6007ffa003b2d4a2834563b6b84d21 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Thu, 29 Aug 2019 10:27:01 +0200
  4. Subject: [PATCH] brcmfmac: get chip's default RAM info during PCIe setup
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Getting RAM info just once per driver's lifetime (during chip
  9. recognition) is not enough as it may get adjusted later (depending on
  10. the used firmware). Subsequent inits may load different firmwares so a
  11. full RAM recognition is required on every PCIe setup. This is especially
  12. important since implementing hardware reset on a firmware crash.
  13. Moreover calling brcmf_chip_get_raminfo() makes sure that RAM core is
  14. up. It's important as having BCMA_CORE_SYS_MEM down on BCM4366 was
  15. resulting in firmware failing to initialize and following error:
  16. [ 65.657546] brcmfmac 0000:01:00.0: brcmf_pcie_download_fw_nvram: Invalid shared RAM address 0x04000001
  17. This change makes brcmf_chip_get_raminfo() call during chip recognition
  18. redundant for PCIe devices but SDIO and USB still need it and it's a
  19. very small overhead anyway.
  20. Fixes: 4684997d9eea ("brcmfmac: reset PCIe bus on a firmware crash")
  21. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  22. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  23. ---
  24. drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 6 ++++--
  25. drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h | 1 +
  26. drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++++
  27. 3 files changed, 11 insertions(+), 2 deletions(-)
  28. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
  29. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
  30. @@ -700,8 +700,10 @@ static u32 brcmf_chip_tcm_rambase(struct
  31. return 0;
  32. }
  33. -static int brcmf_chip_get_raminfo(struct brcmf_chip_priv *ci)
  34. +int brcmf_chip_get_raminfo(struct brcmf_chip *pub)
  35. {
  36. + struct brcmf_chip_priv *ci = container_of(pub, struct brcmf_chip_priv,
  37. + pub);
  38. struct brcmf_core_priv *mem_core;
  39. struct brcmf_core *mem;
  40. @@ -981,7 +983,7 @@ static int brcmf_chip_recognition(struct
  41. brcmf_chip_set_passive(&ci->pub);
  42. }
  43. - return brcmf_chip_get_raminfo(ci);
  44. + return brcmf_chip_get_raminfo(&ci->pub);
  45. }
  46. static void brcmf_chip_disable_arm(struct brcmf_chip_priv *chip, u16 id)
  47. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
  48. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
  49. @@ -80,6 +80,7 @@ struct brcmf_buscore_ops {
  50. void (*activate)(void *ctx, struct brcmf_chip *chip, u32 rstvec);
  51. };
  52. +int brcmf_chip_get_raminfo(struct brcmf_chip *pub);
  53. struct brcmf_chip *brcmf_chip_attach(void *ctx,
  54. const struct brcmf_buscore_ops *ops);
  55. void brcmf_chip_detach(struct brcmf_chip *chip);
  56. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  57. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  58. @@ -1761,6 +1761,12 @@ static void brcmf_pcie_setup(struct devi
  59. brcmf_pcie_attach(devinfo);
  60. + ret = brcmf_chip_get_raminfo(devinfo->ci);
  61. + if (ret) {
  62. + brcmf_err(bus, "Failed to get RAM info\n");
  63. + goto fail;
  64. + }
  65. +
  66. /* Some of the firmwares have the size of the memory of the device
  67. * defined inside the firmware. This is because part of the memory in
  68. * the device is shared and the devision is determined by FW. Parse