Message ID | 20241030141440.1153887-1-gpiccoli@igalia.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Ping-Ke Shih |
Headers | show |
Series | [V2] wifi: rtlwifi: Drastically reduce the attempts to read efuse in case of failures | expand |
> diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c b/drivers/net/wireless/realtek/rtlwifi/efuse.c > index 82cf5fb5175f..f741066c06de 100644 > --- a/drivers/net/wireless/realtek/rtlwifi/efuse.c > +++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c > @@ -164,7 +164,17 @@ void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf) > struct rtl_priv *rtlpriv = rtl_priv(hw); > u32 value32; > u8 readbyte; > - u16 retry; > + u16 retry, max_attempts; > + Declarations should be in reverse X'mas tree order. Just add max_attempts to a new line at proper position.
On 30/10/2024 23:15, Ping-Ke Shih wrote: > >> diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c b/drivers/net/wireless/realtek/rtlwifi/efuse.c >> index 82cf5fb5175f..f741066c06de 100644 >> --- a/drivers/net/wireless/realtek/rtlwifi/efuse.c >> +++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c >> @@ -164,7 +164,17 @@ void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf) >> struct rtl_priv *rtlpriv = rtl_priv(hw); >> u32 value32; >> u8 readbyte; >> - u16 retry; >> + u16 retry, max_attempts; >> + > > Declarations should be in reverse X'mas tree order. > Just add max_attempts to a new line at proper position. Thanks, V3 just sent: https://lore.kernel.org/r/20241031155731.1253259-1-gpiccoli@igalia.com/
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c b/drivers/net/wireless/realtek/rtlwifi/efuse.c index 82cf5fb5175f..f741066c06de 100644 --- a/drivers/net/wireless/realtek/rtlwifi/efuse.c +++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c @@ -164,7 +164,17 @@ void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf) struct rtl_priv *rtlpriv = rtl_priv(hw); u32 value32; u8 readbyte; - u16 retry; + u16 retry, max_attempts; + + /* + * In case of USB devices, transfer speeds are limited, hence + * efuse I/O reads could be (way) slower. So, decrease (a lot) + * the read attempts in case of failures. + */ + if (rtlpriv->rtlhal.interface == INTF_PCI) + max_attempts = 10000; + else + max_attempts = 10; rtl_write_byte(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL] + 1, (_offset & 0xff)); @@ -178,7 +188,7 @@ void read_efuse_byte(struct ieee80211_hw *hw, u16 _offset, u8 *pbuf) retry = 0; value32 = rtl_read_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL]); - while (!(((value32 >> 24) & 0xff) & 0x80) && (retry < 10000)) { + while (!(((value32 >> 24) & 0xff) & 0x80) && (retry < max_attempts)) { value32 = rtl_read_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_CTRL]); retry++;