2021-11-25 19:49:21

by Daniel Golle

[permalink] [raw]
Subject: [PATCH v2] mt76: eeprom: tolerate corrected bit-flips

mtd_read() returns -EUCLEAN in case of corrected bit-flips.
As data was read, don't error out in this case.

Signed-off-by: Daniel Golle <[email protected]>
---
v2: fix wrong variable name

drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
index 2d58aa31db934..4a5d14473ddc4 100644
--- a/drivers/net/wireless/mediatek/mt76/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
@@ -65,7 +65,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
offset = be32_to_cpup(list);
ret = mtd_read(mtd, offset, len, &retlen, eep);
put_mtd_device(mtd);
- if (ret) {
+ if (ret && !mtd_is_bitflip(ret)) {
dev_err(dev->dev, "reading EEPROM from mtd %s failed: %i\n",
part, ret);
goto out_put_node;
--
2.34.0



2021-11-28 18:38:37

by Hauke Mehrtens

[permalink] [raw]
Subject: Re: [PATCH v2] mt76: eeprom: tolerate corrected bit-flips

On 11/25/21 8:45 PM, Daniel Golle wrote:
> mtd_read() returns -EUCLEAN in case of corrected bit-flips.
> As data was read, don't error out in this case.
>
> Signed-off-by: Daniel Golle <[email protected]>

Acked-by: Hauke Mehrtens <[email protected]>

I tried a similar patch on my device before and it solved the problem too.

> ---
> v2: fix wrong variable name
>
> drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
> index 2d58aa31db934..4a5d14473ddc4 100644
> --- a/drivers/net/wireless/mediatek/mt76/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
> @@ -65,7 +65,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
> offset = be32_to_cpup(list);
> ret = mtd_read(mtd, offset, len, &retlen, eep);
> put_mtd_device(mtd);
> - if (ret) {
> + if (ret && !mtd_is_bitflip(ret)) {
> dev_err(dev->dev, "reading EEPROM from mtd %s failed: %i\n",
> part, ret);
> goto out_put_node;
>


2021-12-02 16:27:40

by Felix Fietkau

[permalink] [raw]
Subject: Re: [PATCH v2] mt76: eeprom: tolerate corrected bit-flips

Hi,

On 2021-11-25 20:45, Daniel Golle wrote:
> mtd_read() returns -EUCLEAN in case of corrected bit-flips.
> As data was read, don't error out in this case.
>
> Signed-off-by: Daniel Golle <[email protected]>
> ---
> v2: fix wrong variable name
>
> drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
> index 2d58aa31db934..4a5d14473ddc4 100644
> --- a/drivers/net/wireless/mediatek/mt76/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
> @@ -65,7 +65,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
> offset = be32_to_cpup(list);
> ret = mtd_read(mtd, offset, len, &retlen, eep);
> put_mtd_device(mtd);
> - if (ret) {
> + if (ret && !mtd_is_bitflip(ret)) {
unfortunately the patch is still incomplete. I will fold in the
following change to make it work:
---
--- a/drivers/net/wireless/mediatek/mt76/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
@@ -65,7 +65,9 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
offset = be32_to_cpup(list);
ret = mtd_read(mtd, offset, len, &retlen, eep);
put_mtd_device(mtd);
- if (ret && !mtd_is_bitflip(ret)) {
+ if (mtd_is_bitflip(ret))
+ ret = 0;
+ if (ret) {
dev_err(dev->dev, "reading EEPROM from mtd %s failed: %i\n",
part, ret);
goto out_put_node;