558-ath9k-only-mask-use_eeprom-on-of-noeeprom.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ath9k: Avoid OF no-EEPROM quirks without qca,no-eeprom
  2. ath9k_of_init() function[0] was initially written on the assumption that
  3. if someone had an explicit ath9k OF node that "there must be something
  4. wrong, why would someone add an OF node if everything is fine"[1]
  5. (Quoting Martin Blumenstingl)
  6. "it turns out it's not that simple. with your requirements I'm now aware
  7. of two use-cases where the current code in ath9k_of_init() doesn't work
  8. without modifications"[1]
  9. The "your requirements" Martin speaks of is the result of the fact that I
  10. have a device (PowerCloud Systems CR5000) that uses the EEPROM for
  11. caldata and firmware but for which the MAC address is take from the MTD
  12. "art" partition[2], or more succinctly:
  13. "some cards come with a physical EEPROM chip so "qca,no-eeprom" should not
  14. be set (your use-case). in this case AH_USE_EEPROM should be set (which
  15. is the default when there is no OF node)"[1]
  16. The other use case is:
  17. the firmware on some PowerMac G5 seems to add a OF node for the ath9k
  18. card automatically. depending on the EEPROM on the card AH_NO_EEP_SWAP
  19. should be unset (which is the default when there is no OF node). see [3]
  20. After this patch to ath9k_of_init() the new behavior will be:
  21. if there's no OF node then everything is the same as before
  22. if there's an empty OF node then ath9k will use the hardware EEPROM
  23. (before ath9k would fail to initialize because no EEPROM data was
  24. provided by userspace)
  25. if there's an OF node with only a MAC address then ath9k will use
  26. the MAC address and the hardware EEPROM (see the case above)
  27. with "qca,no-eeprom" EEPROM data from userspace will be requested.
  28. the behavior here will not change
  29. [1]
  30. Martin provides additional background on EEPROM swapping[1] which I have
  31. included in the patch annotation but not the commit message.
  32. Thanks to Christian Lampartar <[email protected]> for all his help on
  33. troubleshooting this issue and the basis for this patch.
  34. Fixes: 138b41253d9c ("ath9k: parse the device configuration from an OF node")
  35. [0]https://elixir.bootlin.com/linux/v4.20-rc7/source/drivers/net/wireless/ath/ath9k/init.c#L615
  36. [1]https://github.com/openwrt/openwrt/pull/1645#issuecomment-448027058
  37. [2]https://github.com/openwrt/openwrt/pull/1613
  38. [3]https://patchwork.kernel.org/patch/10241731/
  39. Signed-off-by: Daniel F. Dickinson <[email protected]>
  40. --- a/drivers/net/wireless/ath/ath9k/init.c
  41. +++ b/drivers/net/wireless/ath/ath9k/init.c
  42. @@ -642,15 +642,15 @@ static int ath9k_of_init(struct ath_soft
  43. ret = ath9k_eeprom_request(sc, eeprom_name);
  44. if (ret)
  45. return ret;
  46. +
  47. + ah->ah_flags &= ~AH_USE_EEPROM;
  48. + ah->ah_flags |= AH_NO_EEP_SWAP;
  49. }
  50. mac = of_get_mac_address(np);
  51. if (mac)
  52. ether_addr_copy(common->macaddr, mac);
  53. - ah->ah_flags &= ~AH_USE_EEPROM;
  54. - ah->ah_flags |= AH_NO_EEP_SWAP;
  55. -
  56. return 0;
  57. }