]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.2/ath9k-avoid-of-no-eeprom-quirks-without-qca-no-eeprom.patch
Linux 5.0.2
[thirdparty/kernel/stable-queue.git] / releases / 5.0.2 / ath9k-avoid-of-no-eeprom-quirks-without-qca-no-eeprom.patch
CommitLineData
eb240234
GKH
1From ce938231bd3b1d7af3cbd8836f084801090470e1 Mon Sep 17 00:00:00 2001
2From: "Daniel F. Dickinson" <cshored@thecshore.com>
3Date: Sat, 22 Dec 2018 01:09:13 -0500
4Subject: ath9k: Avoid OF no-EEPROM quirks without qca,no-eeprom
5
6From: Daniel F. Dickinson <cshored@thecshore.com>
7
8commit ce938231bd3b1d7af3cbd8836f084801090470e1 upstream.
9
10ath9k_of_init() function[0] was initially written on the assumption that
11if someone had an explicit ath9k OF node that "there must be something
12wrong, why would someone add an OF node if everything is fine"[1]
13(Quoting Martin Blumenstingl <martin.blumenstingl@googlemail.com>)
14
15"it turns out it's not that simple. with your requirements I'm now aware
16of two use-cases where the current code in ath9k_of_init() doesn't work
17without modifications"[1]
18
19The "your requirements" Martin speaks of is the result of the fact that I
20have a device (PowerCloud Systems CR5000) has some kind of default - not
21unique mac address - set and requires to set the correct MAC address via
22mac-address devicetree property, however:
23
24"some cards come with a physical EEPROM chip [or OTP] so "qca,no-eeprom"
25should not be set (your use-case). in this case AH_USE_EEPROM should be
26set (which is the default when there is no OF node)"[1]
27
28The other use case is:
29
30the firmware on some PowerMac G5 seems to add a OF node for the ath9k
31card automatically. depending on the EEPROM on the card AH_NO_EEP_SWAP
32should be unset (which is the default when there is no OF node). see [3]
33
34After this patch to ath9k_of_init() the new behavior will be:
35
36 if there's no OF node then everything is the same as before
37 if there's an empty OF node then ath9k will use the hardware EEPROM
38 (before ath9k would fail to initialize because no EEPROM data was
39 provided by userspace)
40 if there's an OF node with only a MAC address then ath9k will use
41 the MAC address and the hardware EEPROM (see the case above)
42 with "qca,no-eeprom" EEPROM data from userspace will be requested.
43 the behavior here will not change
44[1]
45
46Martin provides additional background on EEPROM swapping[1].
47
48Thanks to Christian Lamparter <chunkeey@gmail.com> for all his help on
49troubleshooting this issue and the basis for this patch.
50
51[0]https://elixir.bootlin.com/linux/v4.20-rc7/source/drivers/net/wireless/ath/ath9k/init.c#L615
52[1]https://github.com/openwrt/openwrt/pull/1645#issuecomment-448027058
53[2]https://github.com/openwrt/openwrt/pull/1613
54[3]https://patchwork.kernel.org/patch/10241731/
55
56Fixes: 138b41253d9c ("ath9k: parse the device configuration from an OF node")
57Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
58Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
59Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
60Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
61Cc: Christian Lamparter <chunkeey@gmail.com>
62Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
63
64---
65 drivers/net/wireless/ath/ath9k/init.c | 6 +++---
66 1 file changed, 3 insertions(+), 3 deletions(-)
67
68--- a/drivers/net/wireless/ath/ath9k/init.c
69+++ b/drivers/net/wireless/ath/ath9k/init.c
70@@ -636,15 +636,15 @@ static int ath9k_of_init(struct ath_soft
71 ret = ath9k_eeprom_request(sc, eeprom_name);
72 if (ret)
73 return ret;
74+
75+ ah->ah_flags &= ~AH_USE_EEPROM;
76+ ah->ah_flags |= AH_NO_EEP_SWAP;
77 }
78
79 mac = of_get_mac_address(np);
80 if (mac)
81 ether_addr_copy(common->macaddr, mac);
82
83- ah->ah_flags &= ~AH_USE_EEPROM;
84- ah->ah_flags |= AH_NO_EEP_SWAP;
85-
86 return 0;
87 }
88