2023-06-01 02:30:31

by Neal Sidhwaney

[permalink] [raw]
Subject: [PATCH] wifi: brcmfmac: Detect corner error case earlier with log

In some corner cases, an I/O read can fail and return -1, and this
patch detects this slightly earlier than is done today and logs an
appropriate message.

Signed-off-by: Neal Sidhwaney <[email protected]>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
index 9f9bf08a70bb..9b38c6f2f37f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
@@ -972,6 +972,7 @@ static int brcmf_chip_recognition(struct
brcmf_chip_priv *ci)
u32 regdata;
u32 socitype;
int ret;
+ u32 READ_FAILED = 0xFFFFFFFF;

/* Get CC core rev
* Chipid is assume to be at offset 0 from SI_ENUM_BASE
@@ -980,6 +981,11 @@ static int brcmf_chip_recognition(struct
brcmf_chip_priv *ci)
*/
regdata = ci->ops->read32(ci->ctx,
CORE_CC_REG(ci->pub.enum_base, chipid));
+ if (regdata == READ_FAILED) {
+ brcmf_err("MMIO read failed: 0x%08x\n", regdata);
+ return -ENODEV;
+ }
+
ci->pub.chip = regdata & CID_ID_MASK;
ci->pub.chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
--
2.40.1


2023-06-01 04:26:28

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] wifi: brcmfmac: Detect corner error case earlier with log

Neal Sidhwaney <[email protected]> writes:

> In some corner cases, an I/O read can fail and return -1, and this
> patch detects this slightly earlier than is done today and logs an
> appropriate message.
>
> Signed-off-by: Neal Sidhwaney <[email protected]>

From looking at patchwork the patch seems to be malformed:

https://patchwork.kernel.org/project/linux-wireless/patch/CAJ4cxaQiYWEOmf9sZHsvXqYc_SKSg2dm5jQvifa82+o+W41aNw@mail.gmail.com/

I strongly recommend using git-send-email to submit patches to avoid
issues like this, more info in the wiki link below.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2023-06-01 05:47:03

by Neal Sidhwaney

[permalink] [raw]
Subject: Re: [PATCH] wifi: brcmfmac: Detect corner error case earlier with log

>
> From looking at patchwork the patch seems to be malformed:
>

Sorry about that! I thought I clicked the right setting to send as
text but I must have missed it. New version submitted using 'git
send-email'. Thank you,

Neal