linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "Larry.Finger@lwfinger.net" <Larry.Finger@lwfinger.net>,
	"s.l-h@gmx.de" <s.l-h@gmx.de>,
	"chewitt@libreelec.tv" <chewitt@libreelec.tv>
Subject: Re: [PATCH v3 06/12] wifi: rtlwifi: Add rtl8192du/phy.{c,h}
Date: Wed, 27 Mar 2024 00:13:26 +0200	[thread overview]
Message-ID: <387fa334-cc78-44fb-a638-0da9d104250c@gmail.com> (raw)
In-Reply-To: <59596a57735c713a135ec64b05b8031ad9149421.camel@realtek.com>

On 22/03/2024 07:22, Ping-Ke Shih wrote:
> On Wed, 2024-03-20 at 21:38 +0200, Bitterblue Smith wrote:

> [...]
> 
>> +void rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw, bool is2t)
>> +{
>> +       struct rtl_priv *rtlpriv = rtl_priv(hw);
>> +       struct rtl_hal *rtlhal = &rtlpriv->rtlhal;
>> +       struct rtl_phy *rtlphy = &rtlpriv->phy;
>> +       u32 timeout = 2000, timecount = 0;
>> +
>> +       while (rtlpriv->mac80211.act_scanning && timecount < timeout) {
>> +               udelay(50);
>> +               timecount += 50;
> 
> What is the purpose? 
> 
> Even if you really need it, just mdelay(2) or something like that? > 

This comes from rtl8192de. The TX power tracking can re-do LC
calibration. Someone decided that shouldn't happen while
scanning. I don't know why.

>> +       }
>> +
>> +       rtlphy->lck_inprogress = true;
>> +       RTPRINT(rtlpriv, FINIT, INIT_IQK,
>> +               "LCK:Start!!! currentband %x delay %d ms\n",
>> +               rtlhal->current_bandtype, timecount);
>> +
>> +       _rtl92d_phy_lc_calibrate_sw(hw, is2t);
>> +
>> +       rtlphy->lck_inprogress = false;
>> +       RTPRINT(rtlpriv, FINIT, INIT_IQK,  "LCK:Finish!!!\n");
>> +}
>> +
> 
> [...]
> 
>> +u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw)
>> +{
>> + 
> 
> [...]
> 
>> +       while (rtlphy->lck_inprogress && timecount < timeout) {
>> +               mdelay(50);
>> +               timecount += 50;
>> +       }
> 
> Could LCK and switch channel happen simultaneously?
> Can you point out the case?
> 

When a scan coincides with the TX power tracking deciding to
re-do LC calibration, I guess.

> 
>> +       if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY &&
>> +           rtlhal->bandset == BAND_ON_BOTH) {
>> +               ret_value = rtl_get_bbreg(hw, RFPGA0_XAB_RFPARAMETER,
>> +                                         MASKDWORD);
>> +               if (rtlphy->current_channel > 14 && !(ret_value & BIT(0)))
>> +                       rtl92d_phy_switch_wirelessband(hw, BAND_ON_5G);
>> +               else if (rtlphy->current_channel <= 14 && (ret_value & BIT(0)))
>> +                       rtl92d_phy_switch_wirelessband(hw, BAND_ON_2_4G);
>> +       }
>> +       switch (rtlhal->current_bandtype) {
>> +       case BAND_ON_5G:
>> +               /* Get first channel error when change between
>> +                * 5G and 2.4G band.
>> +                */
>> +               if (WARN_ONCE(channel <= 14, "rtl8192de: 5G but channel<=14\n"))
>> +                       return 0;
>> +               break;
>> +       case BAND_ON_2_4G:
>> +               /* Get first channel error when change between
>> +                * 5G and 2.4G band.
>> +                */
>> +               if (WARN_ONCE(channel > 14, "rtl8192de: 2G but channel>14\n"))
>> +                       return 0;
>> +               break;
>> +       default:
>> +               WARN_ONCE(true, "rtl8192de: Invalid WirelessMode(%#x)!!\n",
>> +                         rtlpriv->mac80211.mode);
>> +               break;
>> +       }
>> +       rtlphy->sw_chnl_inprogress = true;
>> +       if (channel == 0)
>> +               channel = 1;
> 
> Can this really happen? 
> 

I think it can't happen in rtl8192du. I will remove this check.

> 
> 
>> +
>> +       /* notice fw know band status  0x81[1]/0x53[1] = 0: 5G, 1: 2G */
>> +       if (rtlhal->current_bandtype == BAND_ON_2_4G) {
>> +               value8 = rtl_read_byte(rtlpriv, mac_reg);
>> +               value8 |= BIT(1);
>> +               rtl_write_byte(rtlpriv, mac_reg, value8);
>> +       } else {
>> +               value8 = rtl_read_byte(rtlpriv, mac_reg);
>> +               value8 &= (~BIT(1));
>> +               rtl_write_byte(rtlpriv, mac_reg, value8);
>> +       }
>> +
>> +       if (rtlhal->macphymode == SINGLEMAC_SINGLEPHY) {
>> +               value8 = rtl_read_byte(rtlpriv, REG_MAC0);
>> +               rtl_write_byte(rtlpriv, REG_MAC0, value8 | MAC0_ON);
>> +       } else {
>> +               mutex_lock(&globalmutex_power);
> 
> What do you need 'global' mutex? Usually, we want to support multiple instances
> run simultaneously. Does this mutext across instances? 
> I feel not. Please move them into struct rtl_priv.
> 

With the dual MAC version of RTL8192DU two instances of the
driver will access the same chip. This is why we have some
global mutexes. I think multiple devices can still work at the
same time, they will just slow each other down a little during
hardware init/deinit.

>> +               if (rtlhal->interfaceindex == 0) {
>> +                       value8 = rtl_read_byte(rtlpriv, REG_MAC0);
>> +                       rtl_write_byte(rtlpriv, REG_MAC0, value8 | MAC0_ON);
>> +               } else {
>> +                       value8 = rtl_read_byte(rtlpriv, REG_MAC1);
>> +                       rtl_write_byte(rtlpriv, REG_MAC1, value8 | MAC1_ON);
>> +               }
>> +               value8 = rtl_read_byte(rtlpriv, REG_POWER_OFF_IN_PROCESS);
>> +               mutex_unlock(&globalmutex_power);
> 

  reply	other threads:[~2024-03-26 22:13 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 19:32 [PATCH v3 00/12] wifi: rtlwifi: Add new rtl8192du driver Bitterblue Smith
2024-03-20 19:33 ` [PATCH v3 01/12] wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power Bitterblue Smith
2024-03-22  1:25   ` Ping-Ke Shih
2024-03-20 19:34 ` [PATCH v3 02/12] wifi: rtlwifi: Move code from rtl8192de to rtl8192d-common Bitterblue Smith
2024-03-22  2:14   ` Ping-Ke Shih
2024-03-26 13:02     ` Bitterblue Smith
2024-03-20 19:35 ` [PATCH v3 03/12] wifi: rtlwifi: Adjust rtl8192d-common for USB Bitterblue Smith
2024-03-22  3:41   ` Ping-Ke Shih
2024-03-20 19:36 ` [PATCH v3 04/12] wifi: rtlwifi: Add rtl8192du/table.{c,h} Bitterblue Smith
2024-03-22  3:46   ` Ping-Ke Shih
2024-03-26 17:30     ` Bitterblue Smith
2024-03-27  9:18       ` Kalle Valo
2024-03-27  9:30         ` Ping-Ke Shih
2024-03-27 12:36           ` Bitterblue Smith
2024-03-27 12:42             ` Ping-Ke Shih
2024-03-27 12:53             ` Kalle Valo
2024-03-27 16:34           ` Jeff Johnson
2024-03-20 19:37 ` [PATCH v3 05/12] wifi: rtlwifi: Add rtl8192du/hw.{c,h} Bitterblue Smith
2024-03-22  4:02   ` Ping-Ke Shih
2024-03-20 19:38 ` [PATCH v3 06/12] wifi: rtlwifi: Add rtl8192du/phy.{c,h} Bitterblue Smith
2024-03-22  5:22   ` Ping-Ke Shih
2024-03-26 22:13     ` Bitterblue Smith [this message]
2024-03-27  1:19       ` Ping-Ke Shih
2024-03-20 19:39 ` [PATCH v3 07/12] wifi: rtlwifi: Add rtl8192du/trx.{c,h} Bitterblue Smith
2024-03-22  5:32   ` Ping-Ke Shih
2024-03-20 19:40 ` [PATCH v3 08/12] wifi: rtlwifi: Add rtl8192du/rf.{c,h} Bitterblue Smith
2024-03-22  5:35   ` Ping-Ke Shih
2024-03-20 19:41 ` [PATCH v3 09/12] wifi: rtlwifi: Add rtl8192du/fw.{c,h} and rtl8192du/led.{c,h} Bitterblue Smith
2024-03-22  5:42   ` Ping-Ke Shih
2024-03-20 19:42 ` [PATCH v3 10/12] wifi: rtlwifi: Add rtl8192du/dm.{c,h} Bitterblue Smith
2024-03-22  5:48   ` Ping-Ke Shih
2024-03-20 19:43 ` [PATCH v3 11/12] wifi: rtlwifi: Add rtl8192du/sw.{c,h} Bitterblue Smith
2024-03-22  6:04   ` Ping-Ke Shih
2024-03-27 14:07     ` Bitterblue Smith
2024-03-27 18:48       ` Kalle Valo
2024-03-27 22:53         ` Bitterblue Smith
2024-03-28  1:46           ` Ping-Ke Shih
2024-03-28 13:31             ` Bitterblue Smith
2024-03-29  0:34               ` Ping-Ke Shih
2024-03-31 18:48                 ` Bitterblue Smith
2024-04-01  1:21                   ` Ping-Ke Shih
2024-04-07 12:03                     ` Bitterblue Smith
2024-04-08  2:45                       ` Ping-Ke Shih
2024-04-08  9:01                         ` Bitterblue Smith
2024-04-09  0:27                           ` Ping-Ke Shih
2024-04-09 11:16                             ` Bitterblue Smith
2024-03-28  1:49       ` Ping-Ke Shih
2024-03-20 19:44 ` [PATCH v3 12/12] wifi: rtlwifi: Enable the new rtl8192du driver Bitterblue Smith
2024-03-22  6:06   ` Ping-Ke Shih
2024-03-21  1:10 ` [PATCH v3 00/12] wifi: rtlwifi: Add " Stefan Lippers-Hollmann
2024-03-22  6:13 ` [PATCH v3 01/12] wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=387fa334-cc78-44fb-a638-0da9d104250c@gmail.com \
    --to=rtl8821cerfe2@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=chewitt@libreelec.tv \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=s.l-h@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).