* [PATCH] rtlwifi: rtl8192ce: fix dealing empty eeprom values
@ 2023-02-12 12:06 Lu jicong
2023-02-13 9:37 ` Ping-Ke Shih
0 siblings, 1 reply; 3+ messages in thread
From: Lu jicong @ 2023-02-12 12:06 UTC (permalink / raw)
To: pkshih, kvalo, davem, edumazet, kuba, pabeni
Cc: quic_srirrama, jiconglu58, johannes.berg, linux-wireless, netdev,
linux-kernel
In some cases, eeprom is empty or partly empty.
Load default values when the eeprom values are empty to avoid problems.
Signed-off-by: Lu jicong <jiconglu58@gmail.com>
---
.../wireless/realtek/rtlwifi/rtl8192ce/hw.c | 31 +++++++++++++------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
index b9c62640d2cb..8ddf0017af4c 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
@@ -1428,7 +1428,9 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
for (rf_path = 0; rf_path < 2; rf_path++) {
for (i = 0; i < 3; i++) {
- if (!autoload_fail) {
+ if (!autoload_fail &&
+ hwinfo[EEPROM_TXPOWERCCK + rf_path * 3 + i] != 0xff &&
+ hwinfo[EEPROM_TXPOWERHT40_1S + rf_path * 3 + i] != 0xff) {
rtlefuse->
eeprom_chnlarea_txpwr_cck[rf_path][i] =
hwinfo[EEPROM_TXPOWERCCK + rf_path * 3 + i];
@@ -1448,7 +1450,8 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
}
for (i = 0; i < 3; i++) {
- if (!autoload_fail)
+ if (!autoload_fail &&
+ hwinfo[EEPROM_TXPOWERHT40_2SDIFF + i] != 0xff)
tempval = hwinfo[EEPROM_TXPOWERHT40_2SDIFF + i];
else
tempval = EEPROM_DEFAULT_HT40_2SDIFF;
@@ -1518,7 +1521,9 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
}
for (i = 0; i < 3; i++) {
- if (!autoload_fail) {
+ if (!autoload_fail &&
+ hwinfo[EEPROM_TXPWR_GROUP + i] != 0xff &&
+ hwinfo[EEPROM_TXPWR_GROUP + 3 + i] != 0xff) {
rtlefuse->eeprom_pwrlimit_ht40[i] =
hwinfo[EEPROM_TXPWR_GROUP + i];
rtlefuse->eeprom_pwrlimit_ht20[i] =
@@ -1563,7 +1568,8 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
for (i = 0; i < 14; i++) {
index = rtl92c_get_chnl_group((u8)i);
- if (!autoload_fail)
+ if (!autoload_fail &&
+ hwinfo[EEPROM_TXPOWERHT20DIFF + index] != 0xff)
tempval = hwinfo[EEPROM_TXPOWERHT20DIFF + index];
else
tempval = EEPROM_DEFAULT_HT20_DIFF;
@@ -1580,7 +1586,8 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
index = rtl92c_get_chnl_group((u8)i);
- if (!autoload_fail)
+ if (!autoload_fail &&
+ hwinfo[EEPROM_TXPOWER_OFDMDIFF + index] != 0xff)
tempval = hwinfo[EEPROM_TXPOWER_OFDMDIFF + index];
else
tempval = EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF;
@@ -1610,14 +1617,16 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
"RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
- if (!autoload_fail)
+ if (!autoload_fail && hwinfo[RF_OPTION1] != 0xff)
rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7);
else
rtlefuse->eeprom_regulatory = 0;
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
"eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
- if (!autoload_fail) {
+ if (!autoload_fail &&
+ hwinfo[EEPROM_TSSI_A] != 0xff &&
+ hwinfo[EEPROM_TSSI_B] != 0xff) {
rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A];
rtlefuse->eeprom_tssi[RF90_PATH_B] = hwinfo[EEPROM_TSSI_B];
} else {
@@ -1628,7 +1637,7 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
rtlefuse->eeprom_tssi[RF90_PATH_A],
rtlefuse->eeprom_tssi[RF90_PATH_B]);
- if (!autoload_fail)
+ if (!autoload_fail && hwinfo[EEPROM_THERMAL_METER] != 0xff)
tempval = hwinfo[EEPROM_THERMAL_METER];
else
tempval = EEPROM_DEFAULT_THERMALMETER;
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] rtlwifi: rtl8192ce: fix dealing empty eeprom values
2023-02-12 12:06 [PATCH] rtlwifi: rtl8192ce: fix dealing empty eeprom values Lu jicong
@ 2023-02-13 9:37 ` Ping-Ke Shih
0 siblings, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2023-02-13 9:37 UTC (permalink / raw)
To: Lu jicong, kvalo, davem, edumazet, kuba, pabeni
Cc: quic_srirrama, johannes.berg, linux-wireless, netdev, linux-kernel
> -----Original Message-----
> From: Lu jicong <jiconglu58@gmail.com>
> Sent: Sunday, February 12, 2023 8:06 PM
> To: Ping-Ke Shih <pkshih@realtek.com>; kvalo@kernel.org; davem@davemloft.net; edumazet@google.com;
> kuba@kernel.org; pabeni@redhat.com
> Cc: quic_srirrama@quicinc.com; jiconglu58@gmail.com; johannes.berg@intel.com;
> linux-wireless@vger.kernel.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] rtlwifi: rtl8192ce: fix dealing empty eeprom values
>
> In some cases, eeprom is empty or partly empty.
This looks weird to me. Why does hardware could be programmed improper eeprom?
Where do you get the hardware? Can I have a picture of this module privately?
I think we only need to support MP hardware.
> Load default values when the eeprom values are empty to avoid problems.
>
> Signed-off-by: Lu jicong <jiconglu58@gmail.com>
> ---
> .../wireless/realtek/rtlwifi/rtl8192ce/hw.c | 31 +++++++++++++------
> 1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
> index b9c62640d2cb..8ddf0017af4c 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
> @@ -1428,7 +1428,9 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
>
> for (rf_path = 0; rf_path < 2; rf_path++) {
> for (i = 0; i < 3; i++) {
> - if (!autoload_fail) {
> + if (!autoload_fail &&
> + hwinfo[EEPROM_TXPOWERCCK + rf_path * 3 + i] != 0xff &&
> + hwinfo[EEPROM_TXPOWERHT40_1S + rf_path * 3 + i] != 0xff) {
> rtlefuse->
> eeprom_chnlarea_txpwr_cck[rf_path][i] =
> hwinfo[EEPROM_TXPOWERCCK + rf_path * 3 + i];
> @@ -1448,7 +1450,8 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
> }
>
> for (i = 0; i < 3; i++) {
> - if (!autoload_fail)
> + if (!autoload_fail &&
> + hwinfo[EEPROM_TXPOWERHT40_2SDIFF + i] != 0xff)
> tempval = hwinfo[EEPROM_TXPOWERHT40_2SDIFF + i];
> else
> tempval = EEPROM_DEFAULT_HT40_2SDIFF;
> @@ -1518,7 +1521,9 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
> }
>
> for (i = 0; i < 3; i++) {
> - if (!autoload_fail) {
> + if (!autoload_fail &&
> + hwinfo[EEPROM_TXPWR_GROUP + i] != 0xff &&
> + hwinfo[EEPROM_TXPWR_GROUP + 3 + i] != 0xff) {
> rtlefuse->eeprom_pwrlimit_ht40[i] =
> hwinfo[EEPROM_TXPWR_GROUP + i];
> rtlefuse->eeprom_pwrlimit_ht20[i] =
> @@ -1563,7 +1568,8 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
> for (i = 0; i < 14; i++) {
> index = rtl92c_get_chnl_group((u8)i);
>
> - if (!autoload_fail)
> + if (!autoload_fail &&
> + hwinfo[EEPROM_TXPOWERHT20DIFF + index] != 0xff)
> tempval = hwinfo[EEPROM_TXPOWERHT20DIFF + index];
> else
> tempval = EEPROM_DEFAULT_HT20_DIFF;
> @@ -1580,7 +1586,8 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
>
> index = rtl92c_get_chnl_group((u8)i);
>
> - if (!autoload_fail)
> + if (!autoload_fail &&
> + hwinfo[EEPROM_TXPOWER_OFDMDIFF + index] != 0xff)
> tempval = hwinfo[EEPROM_TXPOWER_OFDMDIFF + index];
> else
> tempval = EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF;
> @@ -1610,14 +1617,16 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
> "RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
> i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
>
> - if (!autoload_fail)
> + if (!autoload_fail && hwinfo[RF_OPTION1] != 0xff)
> rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7);
> else
> rtlefuse->eeprom_regulatory = 0;
> RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
> "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
>
> - if (!autoload_fail) {
> + if (!autoload_fail &&
> + hwinfo[EEPROM_TSSI_A] != 0xff &&
> + hwinfo[EEPROM_TSSI_B] != 0xff) {
> rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A];
> rtlefuse->eeprom_tssi[RF90_PATH_B] = hwinfo[EEPROM_TSSI_B];
> } else {
> @@ -1628,7 +1637,7 @@ static void _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
> rtlefuse->eeprom_tssi[RF90_PATH_A],
> rtlefuse->eeprom_tssi[RF90_PATH_B]);
>
> - if (!autoload_fail)
> + if (!autoload_fail && hwinfo[EEPROM_THERMAL_METER] != 0xff)
> tempval = hwinfo[EEPROM_THERMAL_METER];
> else
> tempval = EEPROM_DEFAULT_THERMALMETER;
> --
> 2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtlwifi: rtl8192ce: fix dealing empty eeprom values
[not found] <pkshih@realtek.com>
@ 2023-02-13 14:27 ` Lu jicong
0 siblings, 0 replies; 3+ messages in thread
From: Lu jicong @ 2023-02-13 14:27 UTC (permalink / raw)
To: kvalo, davem, edumazet, kuba, pabeni; +Cc: linux-wireless, netdev, linux-kernel
> This looks weird to me. Why does hardware could be programmed improper eeprom?> Where do you get the hardware? Can I have a picture of this module privately?
> I think we only need to support MP hardware.
This is a wireless router with soldered rtl8192ce chip.
It's an MP hardware too, with empty eeprom.
I don't know why they didn't write anything to the eeprom.
As far as I know, another person also reported this problem on an embedded
system.
I think add support for these devices have no disadvantage.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-13 14:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-12 12:06 [PATCH] rtlwifi: rtl8192ce: fix dealing empty eeprom values Lu jicong
2023-02-13 9:37 ` Ping-Ke Shih
[not found] <pkshih@realtek.com>
2023-02-13 14:27 ` Lu jicong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®