2
0

865-brcmfmac-get-RAM-info-right-before-downloading-PCIe-.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  2. Subject: [PATCH] brcmfmac: get RAM info right before downloading PCIe firmware
  3. MIME-Version: 1.0
  4. Content-Type: text/plain; charset=UTF-8
  5. Content-Transfer-Encoding: 8bit
  6. It's important as brcmf_chip_get_raminfo() also makes sure that memory
  7. is properly setup. Without it the firmware could report invalid RAM
  8. address like 0x04000001.
  9. During a normal brcmfmac lifetime brcmf_chip_get_raminfo() is called on
  10. probe by the brcmf_chip_recognition(). This change allows implementing
  11. further improvements like handling errors by resetting a device with
  12. the brcmf_pcie_reset_device() and redownloading a firmware afterwards.
  13. Signed-off-by: Rafał Miłecki <[email protected]>
  14. ---
  15. drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 6 ++++--
  16. drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h | 1 +
  17. drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++++
  18. 3 files changed, 11 insertions(+), 2 deletions(-)
  19. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
  20. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
  21. @@ -707,8 +707,10 @@ static u32 brcmf_chip_tcm_rambase(struct
  22. return 0;
  23. }
  24. -static int brcmf_chip_get_raminfo(struct brcmf_chip_priv *ci)
  25. +int brcmf_chip_get_raminfo(struct brcmf_chip *pub)
  26. {
  27. + struct brcmf_chip_priv *ci = container_of(pub, struct brcmf_chip_priv,
  28. + pub);
  29. struct brcmf_core_priv *mem_core;
  30. struct brcmf_core *mem;
  31. @@ -990,7 +992,7 @@ static int brcmf_chip_recognition(struct
  32. brcmf_chip_set_passive(&ci->pub);
  33. }
  34. - return brcmf_chip_get_raminfo(ci);
  35. + return brcmf_chip_get_raminfo(&ci->pub);
  36. }
  37. static void brcmf_chip_disable_arm(struct brcmf_chip_priv *chip, u16 id)
  38. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
  39. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
  40. @@ -80,6 +80,7 @@ struct brcmf_buscore_ops {
  41. void (*activate)(void *ctx, struct brcmf_chip *chip, u32 rstvec);
  42. };
  43. +int brcmf_chip_get_raminfo(struct brcmf_chip *pub);
  44. struct brcmf_chip *brcmf_chip_attach(void *ctx,
  45. const struct brcmf_buscore_ops *ops);
  46. void brcmf_chip_detach(struct brcmf_chip *chip);
  47. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  48. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  49. @@ -1762,6 +1762,12 @@ static void brcmf_pcie_setup(struct devi
  50. nvram_len = fwreq->items[BRCMF_PCIE_FW_NVRAM].nv_data.len;
  51. kfree(fwreq);
  52. + ret = brcmf_chip_get_raminfo(devinfo->ci);
  53. + if (ret) {
  54. + brcmf_err(bus, "Failed to get RAM info\n");
  55. + goto fail;
  56. + }
  57. +
  58. /* Some of the firmwares have the size of the memory of the device
  59. * defined inside the firmware. This is because part of the memory in
  60. * the device is shared and the devision is determined by FW. Parse