All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k_hw: ignore eeprom magic mismatch on flash based devices
@ 2016-01-21 15:34 Felix Fietkau
  2016-01-21 16:46 ` Martin Blumenstingl
  2016-01-25 13:34 ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Felix Fietkau @ 2016-01-21 15:34 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo, martin.blumenstingl

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 <nbd@openwrt.org>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k_hw: ignore eeprom magic mismatch on flash based devices
  2016-01-21 15:34 [PATCH] ath9k_hw: ignore eeprom magic mismatch on flash based devices Felix Fietkau
@ 2016-01-21 16:46 ` Martin Blumenstingl
  2016-01-22 11:41   ` Kalle Valo
  2016-01-25 13:34 ` Kalle Valo
  1 sibling, 1 reply; 4+ messages in thread
From: Martin Blumenstingl @ 2016-01-21 16:46 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, kvalo

On Thu, Jan 21, 2016 at 4:34 PM, Felix Fietkau <nbd@openwrt.org> 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 <nbd@openwrt.org>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k_hw: ignore eeprom magic mismatch on flash based devices
  2016-01-21 16:46 ` Martin Blumenstingl
@ 2016-01-22 11:41   ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2016-01-22 11:41 UTC (permalink / raw)
  To: Martin Blumenstingl; +Cc: Felix Fietkau, linux-wireless

Martin Blumenstingl <martin.blumenstingl@googlemail.com> writes:

> On Thu, Jan 21, 2016 at 4:34 PM, Felix Fietkau <nbd@openwrt.org> 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 <nbd@openwrt.org>
>
> Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k_hw: ignore eeprom magic mismatch on flash based devices
  2016-01-21 15:34 [PATCH] ath9k_hw: ignore eeprom magic mismatch on flash based devices Felix Fietkau
  2016-01-21 16:46 ` Martin Blumenstingl
@ 2016-01-25 13:34 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2016-01-25 13:34 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, martin.blumenstingl

Felix Fietkau <nbd@openwrt.org> 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 <nbd@openwrt.org>

Applied to ath-current in ath.git, thanks.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-25 13:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-21 15:34 [PATCH] ath9k_hw: ignore eeprom magic mismatch on flash based devices Felix Fietkau
2016-01-21 16:46 ` Martin Blumenstingl
2016-01-22 11:41   ` Kalle Valo
2016-01-25 13:34 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.