323-0001-brcmfmac-analyze-descriptors-of-current-component-on.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  2. Date: Tue, 26 Jan 2016 17:57:01 +0100
  3. Subject: [PATCH] brcmfmac: analyze descriptors of current component only
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. So far we were looking for address descriptors without a check for
  8. crossing current component border. In case of dealing with unsupported
  9. descriptor or descriptor missing at all the code would incorrectly get
  10. data from another component.
  11. Consider this binary-described component from BCM4366 EROM:
  12. 4bf83b01 TAG==CI CID==0x83b
  13. 20080201 TAG==CI PORTS==0+1 WRAPPERS==0+1
  14. 18400035 TAG==ADDR SZ_SZD TYPE_SLAVE
  15. 00050000
  16. 18107085 TAG==ADDR SZ_4K TYPE_SWRAP
  17. Driver was assigning invalid base address to this core:
  18. brcmfmac: [6 ] core 0x83b:32 base 0x18109000 wrap 0x18107000
  19. which came from totally different component defined in EROM:
  20. 43b36701 TAG==CI CID==0x367
  21. 00000201 TAG==CI PORTS==0+1 WRAPPERS==0+0
  22. 18109005 TAG==ADDR SZ_4K TYPE_SLAVE
  23. This change will also allow us to support components without wrapper
  24. address in the future.
  25. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  26. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  27. ---
  28. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
  29. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
  30. @@ -803,7 +803,14 @@ static int brcmf_chip_dmp_get_regaddr(st
  31. *eromaddr -= 4;
  32. return -EFAULT;
  33. }
  34. - } while (desc != DMP_DESC_ADDRESS);
  35. + } while (desc != DMP_DESC_ADDRESS &&
  36. + desc != DMP_DESC_COMPONENT);
  37. +
  38. + /* stop if we crossed current component border */
  39. + if (desc == DMP_DESC_COMPONENT) {
  40. + *eromaddr -= 4;
  41. + return 0;
  42. + }
  43. /* skip upper 32-bit address descriptor */
  44. if (val & DMP_DESC_ADDRSIZE_GT32)