* [PATCH v2] mt76x0: run calibration after scanning
@ 2018-10-31 13:11 Stanislaw Gruszka
2018-10-31 13:30 ` Stanislaw Gruszka
2018-10-31 13:45 ` Felix Fietkau
0 siblings, 2 replies; 3+ messages in thread
From: Stanislaw Gruszka @ 2018-10-31 13:11 UTC (permalink / raw)
To: Felix Fietkau; +Cc: Lorenzo Bianconi, linux-wireless
If we are associated and scanning is performed, sw_scan_complete callback
is done after we get back to operating channel, so we do not perform
queue cal work. Fix this queue cal work from sw_scan_complete().
We have to restore gain in MT_BBP(AGC, 8) register after scanning, as
it was multiple times modified by channel switch code. So queue cal work
without any delay and reset dev->cal.low_gain to assure calibration
code will AGC gain value.
Note patch was not tested on mt76x2, but should work and be needed
fix as well.
Fixes: bbd10586f0df ("mt76x0: phy: do not run calibration during channel switch")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
v1 -> v2:
only queue cal work with 0 delay an reset dev->cal.low_gain
drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 9f083008dbd4..747fd2c9ec45 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -553,6 +553,12 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
clear_bit(MT76_SCANNING, &dev->mt76.state);
if (mt76_is_mmio(dev))
tasklet_enable(&dev->pre_tbtt_tasklet);
+
+ if (vif->bss_conf.assoc) {
+ /* Restore AGC gain and resume calibration after scanning. */
+ dev->cal.low_gain = -1;
+ ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
+ }
}
EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);
--
2.7.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mt76x0: run calibration after scanning
2018-10-31 13:11 [PATCH v2] mt76x0: run calibration after scanning Stanislaw Gruszka
@ 2018-10-31 13:30 ` Stanislaw Gruszka
2018-10-31 13:45 ` Felix Fietkau
1 sibling, 0 replies; 3+ messages in thread
From: Stanislaw Gruszka @ 2018-10-31 13:30 UTC (permalink / raw)
To: Felix Fietkau; +Cc: Lorenzo Bianconi, linux-wireless
On Wed, Oct 31, 2018 at 02:11:26PM +0100, Stanislaw Gruszka wrote:
> If we are associated and scanning is performed, sw_scan_complete callback
> is done after we get back to operating channel, so we do not perform
> queue cal work. Fix this queue cal work from sw_scan_complete().
>
> We have to restore gain in MT_BBP(AGC, 8) register after scanning, as
> it was multiple times modified by channel switch code. So queue cal work
> without any delay and reset dev->cal.low_gain to assure calibration
> code will AGC gain value.
>
> Note patch was not tested on mt76x2, but should work and be needed
> fix as well.
>
> Fixes: bbd10586f0df ("mt76x0: phy: do not run calibration during channel switch")
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
> v1 -> v2:
> only queue cal work with 0 delay an reset dev->cal.low_gain
>
> drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 9f083008dbd4..747fd2c9ec45 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -553,6 +553,12 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
> clear_bit(MT76_SCANNING, &dev->mt76.state);
> if (mt76_is_mmio(dev))
> tasklet_enable(&dev->pre_tbtt_tasklet);
> +
> + if (vif->bss_conf.assoc) {
> + /* Restore AGC gain and resume calibration after scanning. */
> + dev->cal.low_gain = -1;
> + ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
> + }
> }
> EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);
I think this can not be sufficient fix. Something like seems
to be needed as wall to force AGC gain write to register:
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
index 1af2a1227924..fc4085ef3e16 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c
@@ -833,7 +833,7 @@ mt76x0_phy_update_channel_gain(struct mt76x02_dev *dev)
low_gain = (dev->cal.avg_rssi_all > mt76x02_get_rssi_gain_thresh(dev)) +
(dev->cal.avg_rssi_all > mt76x02_get_low_rssi_gain_thresh(dev));
- gain_change = (dev->cal.low_gain & 2) ^ (low_gain & 2);
+ gain_change = log_gain != dev->cal.low_gain;
dev->cal.low_gain = low_gain;
but I do not fully understand this xor logic, so I'm not sure.
Thanks
Stanislaw
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mt76x0: run calibration after scanning
2018-10-31 13:11 [PATCH v2] mt76x0: run calibration after scanning Stanislaw Gruszka
2018-10-31 13:30 ` Stanislaw Gruszka
@ 2018-10-31 13:45 ` Felix Fietkau
1 sibling, 0 replies; 3+ messages in thread
From: Felix Fietkau @ 2018-10-31 13:45 UTC (permalink / raw)
To: Stanislaw Gruszka; +Cc: Lorenzo Bianconi, linux-wireless
On 2018-10-31 14:11, Stanislaw Gruszka wrote:
> If we are associated and scanning is performed, sw_scan_complete callback
> is done after we get back to operating channel, so we do not perform
> queue cal work. Fix this queue cal work from sw_scan_complete().
>
> We have to restore gain in MT_BBP(AGC, 8) register after scanning, as
> it was multiple times modified by channel switch code. So queue cal work
> without any delay and reset dev->cal.low_gain to assure calibration
> code will AGC gain value.
>
> Note patch was not tested on mt76x2, but should work and be needed
> fix as well.
>
> Fixes: bbd10586f0df ("mt76x0: phy: do not run calibration during channel switch")
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
> v1 -> v2:
> only queue cal work with 0 delay an reset dev->cal.low_gain
>
> drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 9f083008dbd4..747fd2c9ec45 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -553,6 +553,12 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
> clear_bit(MT76_SCANNING, &dev->mt76.state);
> if (mt76_is_mmio(dev))
> tasklet_enable(&dev->pre_tbtt_tasklet);
> +
> + if (vif->bss_conf.assoc) {
> + /* Restore AGC gain and resume calibration after scanning. */
> + dev->cal.low_gain = -1;
> + ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
> + }
I think checking vif->bss_conf.assoc here is not enough, since we might
be using multiple interfaces (e.g. AP+STA)
- Felix
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-31 13:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31 13:11 [PATCH v2] mt76x0: run calibration after scanning Stanislaw Gruszka
2018-10-31 13:30 ` Stanislaw Gruszka
2018-10-31 13:45 ` Felix Fietkau
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).