diff mbox

[2/2] mt7601u: run calibration works after finishing scanning

Message ID 1523630678-8100-2-git-send-email-sgruszka@redhat.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show

Commit Message

Stanislaw Gruszka April 13, 2018, 2:44 p.m. UTC
When finishing scanning we switch to operational channel sill with
SCANNING flag. This mean that we never perform calibration works after
scanning. To fix the problem cancel and queue calibration works on
.sw_scan_start() and .sw_scan_complete() routines.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt7601u/main.c |  9 +++++++++
 drivers/net/wireless/mediatek/mt7601u/phy.c  | 15 +--------------
 2 files changed, 10 insertions(+), 14 deletions(-)

Comments

Jakub Kicinski April 13, 2018, 6:06 p.m. UTC | #1
On Fri, 13 Apr 2018 16:44:38 +0200, Stanislaw Gruszka wrote:
> When finishing scanning we switch to operational channel sill with
> SCANNING flag. This mean that we never perform calibration works after
> scanning. To fix the problem cancel and queue calibration works on
> .sw_scan_start() and .sw_scan_complete() routines.
> 
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>

IOW the stack will potentially ask us to return to the original channel
before calling .sw_scan_complete()?  Hm.  That's unpleasant.

I'm not entirely on board with the patch.  Now normal channel setting
will happen while calibration is running.  Is that necessary?  Would it
not be sufficient to make sure work is scheduled
from .sw_scan_complete()?
Stanislaw Gruszka April 14, 2018, 10:56 a.m. UTC | #2
On Fri, Apr 13, 2018 at 11:06:13AM -0700, Jakub Kicinski wrote:
> On Fri, 13 Apr 2018 16:44:38 +0200, Stanislaw Gruszka wrote:
> > When finishing scanning we switch to operational channel sill with
> > SCANNING flag. This mean that we never perform calibration works after
> > scanning. To fix the problem cancel and queue calibration works on
> > .sw_scan_start() and .sw_scan_complete() routines.
> > 
> > Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> 
> IOW the stack will potentially ask us to return to the original channel
> before calling .sw_scan_complete()?  Hm.  That's unpleasant.

I think the stack need to assure we start and end scanning on
operational channel, otherwise we would have possibility to be on
undefined channel during normal work.

> I'm not entirely on board with the patch.  Now normal channel setting
> will happen while calibration is running.  Is that necessary? 
> Would it not be sufficient to make sure work is scheduled
> from .sw_scan_complete()?

Yes, that would be sufficient, I'll post v2.

Thanks
Stanislaw
Arend van Spriel April 16, 2018, 6:45 p.m. UTC | #3
On 4/14/2018 12:56 PM, Stanislaw Gruszka wrote:
> On Fri, Apr 13, 2018 at 11:06:13AM -0700, Jakub Kicinski wrote:
>> >On Fri, 13 Apr 2018 16:44:38 +0200, Stanislaw Gruszka wrote:
>>> > >When finishing scanning we switch to operational channel sill with
>>> > >SCANNING flag. This mean that we never perform calibration works after
>>> > >scanning. To fix the problem cancel and queue calibration works on
>>> > >.sw_scan_start() and .sw_scan_complete() routines.
>>> > >
>>> > >Signed-off-by: Stanislaw Gruszka<sgruszka@redhat.com>
>> >
>> >IOW the stack will potentially ask us to return to the original channel
>> >before calling .sw_scan_complete()?  Hm.  That's unpleasant.
> I think the stack need to assure we start and end scanning on
> operational channel, otherwise we would have possibility to be on
> undefined channel during normal work.

Returning to the operating channels during scanning is mostly important 
when connected so you can receive the beacon of your AP and mc/bc 
traffic and also to handle regular unicast traffic so you are not 
screwing up your TCP window too much for instance.

Regards,
Arend
diff mbox

Patch

diff --git a/drivers/net/wireless/mediatek/mt7601u/main.c b/drivers/net/wireless/mediatek/mt7601u/main.c
index 43ebd460ba86..a09b92a9137d 100644
--- a/drivers/net/wireless/mediatek/mt7601u/main.c
+++ b/drivers/net/wireless/mediatek/mt7601u/main.c
@@ -273,6 +273,9 @@  static int mt7601u_config(struct ieee80211_hw *hw, u32 changed)
 {
 	struct mt7601u_dev *dev = hw->priv;
 
+	cancel_delayed_work_sync(&dev->cal_work);
+	cancel_delayed_work_sync(&dev->freq_cal.work);
+
 	mt7601u_agc_save(dev);
 	set_bit(MT7601U_STATE_SCANNING, &dev->state);
 }
@@ -285,6 +288,12 @@  static int mt7601u_config(struct ieee80211_hw *hw, u32 changed)
 
 	mt7601u_agc_restore(dev);
 	clear_bit(MT7601U_STATE_SCANNING, &dev->state);
+
+	ieee80211_queue_delayed_work(dev->hw, &dev->cal_work,
+				     MT_CALIBRATE_INTERVAL);
+	if (dev->freq_cal.enabled)
+		ieee80211_queue_delayed_work(dev->hw, &dev->freq_cal.work,
+					     MT_FREQ_CAL_INIT_DELAY);
 }
 
 static int
diff --git a/drivers/net/wireless/mediatek/mt7601u/phy.c b/drivers/net/wireless/mediatek/mt7601u/phy.c
index d440c550bdb1..e5fe3bef596e 100644
--- a/drivers/net/wireless/mediatek/mt7601u/phy.c
+++ b/drivers/net/wireless/mediatek/mt7601u/phy.c
@@ -452,24 +452,11 @@  int mt7601u_phy_set_channel(struct mt7601u_dev *dev,
 {
 	int ret;
 
-	cancel_delayed_work_sync(&dev->cal_work);
-	cancel_delayed_work_sync(&dev->freq_cal.work);
-
 	mutex_lock(&dev->hw_atomic_mutex);
 	ret = __mt7601u_phy_set_channel(dev, chandef);
 	mutex_unlock(&dev->hw_atomic_mutex);
-	if (ret)
-		return ret;
-
-	if (test_bit(MT7601U_STATE_SCANNING, &dev->state))
-		return 0;
 
-	ieee80211_queue_delayed_work(dev->hw, &dev->cal_work,
-				     MT_CALIBRATE_INTERVAL);
-	if (dev->freq_cal.enabled)
-		ieee80211_queue_delayed_work(dev->hw, &dev->freq_cal.work,
-					     MT_FREQ_CAL_INIT_DELAY);
-	return 0;
+	return ret;
 }
 
 #define BBP_R47_FLAG		GENMASK(2, 0)