On Wed, 2024-03-27 at 00:13 +0200, Bitterblue Smith wrote: > > 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. I think you are right. While scanning, it will switch channels one by one, but LC calibration is only for a certain channel (mostly operating channel), so here is to wait for scanning completion with 2000 * 50us (100ms) timeout to prevent interrupting LC calibration. > > > + 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. You are also right here. After looking deeper, TX power tracking and scan are running on different work queues, and seemingly it would cause possibly race condition, which possibly gets lower RF performance.