Many AR913x based devices (maybe others too) do not have a valid EEPROM
magic in their calibration data partition.
Fixes: 6fa658fd5ab2 ("ath9k: Simplify and fix eeprom endianness swapping")
Signed-off-by: Felix Fietkau <[email protected]>
---
drivers/net/wireless/ath/ath9k/eeprom.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index a7afdee..73fb423 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -150,18 +150,18 @@ int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size)
return -EIO;
}
- if (magic == AR5416_EEPROM_MAGIC) {
- *swap_needed = false;
- } else if (swab16(magic) == AR5416_EEPROM_MAGIC) {
+ *swap_needed = false;
+ if (swab16(magic) == AR5416_EEPROM_MAGIC) {
if (ah->ah_flags & AH_NO_EEP_SWAP) {
ath_info(common,
"Ignoring endianness difference in EEPROM magic bytes.\n");
-
- *swap_needed = false;
} else {
*swap_needed = true;
}
- } else {
+ } else if (magic != AR5416_EEPROM_MAGIC) {
+ if (ath9k_hw_use_flash(ah))
+ return 0;
+
ath_err(common,
"Invalid EEPROM Magic (0x%04x).\n", magic);
return -EINVAL;
--
2.2.2
Martin Blumenstingl <[email protected]> writes:
> On Thu, Jan 21, 2016 at 4:34 PM, Felix Fietkau <[email protected]> wrote:
>> Many AR913x based devices (maybe others too) do not have a valid EEPROM
>> magic in their calibration data partition.
>>
>> Fixes: 6fa658fd5ab2 ("ath9k: Simplify and fix eeprom endianness swapping")
>> Signed-off-by: Felix Fietkau <[email protected]>
>
> Acked-by: Martin Blumenstingl <[email protected]>
I'll queue this to 4.5.
> I wonder if we should also backport this to 4.4, because that is
> affected as well.
Is it? I don't see 6fa658fd5ab2 in 4.4. Can you double check, please?
--
Kalle Valo
On Thu, Jan 21, 2016 at 4:34 PM, Felix Fietkau <[email protected]> wrote:
> Many AR913x based devices (maybe others too) do not have a valid EEPROM
> magic in their calibration data partition.
>
> Fixes: 6fa658fd5ab2 ("ath9k: Simplify and fix eeprom endianness swapping")
> Signed-off-by: Felix Fietkau <[email protected]>
Acked-by: Martin Blumenstingl <[email protected]>
After I misread the patch in the first place here's an explanation
what the main point is:
there are (many) devices out there which have the EEPROM data provided
on a separate flash (for example in a calibration data partition). In
this case there are some manufacturers who have programmed invalid
EEPROM magic bytes, thus breaking the check I introduced earlier.
The "ath9k_hw_use_flash" check detects exactly this: whenever the
EEPROM data comes from an external source then the EEPROM magic check
is skipped.
I wonder if we should also backport this to 4.4, because that is
affected as well.
Thanks for fixing this Felix and sorry for breaking it!
> ---
> drivers/net/wireless/ath/ath9k/eeprom.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
> index a7afdee..73fb423 100644
> --- a/drivers/net/wireless/ath/ath9k/eeprom.c
> +++ b/drivers/net/wireless/ath/ath9k/eeprom.c
> @@ -150,18 +150,18 @@ int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size)
> return -EIO;
> }
>
> - if (magic == AR5416_EEPROM_MAGIC) {
> - *swap_needed = false;
> - } else if (swab16(magic) == AR5416_EEPROM_MAGIC) {
> + *swap_needed = false;
> + if (swab16(magic) == AR5416_EEPROM_MAGIC) {
> if (ah->ah_flags & AH_NO_EEP_SWAP) {
> ath_info(common,
> "Ignoring endianness difference in EEPROM magic bytes.\n");
> -
> - *swap_needed = false;
> } else {
> *swap_needed = true;
> }
> - } else {
> + } else if (magic != AR5416_EEPROM_MAGIC) {
> + if (ath9k_hw_use_flash(ah))
> + return 0;
> +
> ath_err(common,
> "Invalid EEPROM Magic (0x%04x).\n", magic);
> return -EINVAL;
> --
> 2.2.2
>
Felix Fietkau <[email protected]> writes:
> Many AR913x based devices (maybe others too) do not have a valid EEPROM
> magic in their calibration data partition.
>
> Fixes: 6fa658fd5ab2 ("ath9k: Simplify and fix eeprom endianness swapping")
> Signed-off-by: Felix Fietkau <[email protected]>
Applied to ath-current in ath.git, thanks.
--
Kalle Valo