diff mbox series

[4/5] mt76x02: minor beaconing init changes

Message ID 1541758814-2046-5-git-send-email-sgruszka@redhat.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series mt76x02: bssid setup corrections for STA | expand

Commit Message

Stanislaw Gruszka Nov. 9, 2018, 10:20 a.m. UTC
Disable BEACON timer during init and remove interrupt registers
initalization form generic conde since they are PCIe specific.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c      |  7 +++++++
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c    | 11 ++++-------
 drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  8 ++++++++
 3 files changed, 19 insertions(+), 7 deletions(-)

Comments

Lorenzo Bianconi Nov. 9, 2018, 11:33 a.m. UTC | #1
> Disable BEACON timer during init and remove interrupt registers
> initalization form generic conde since they are PCIe specific.
> 

Since the timer is actually disabled (MT_INT_TIMER_EN set to 0) and
we just set the timer timeout here, does it worth to copy/paste
the same code?

Regards,
Lorenzo

> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x0/pci.c      |  7 +++++++
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c    | 11 ++++-------
>  drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c |  8 ++++++++
>  3 files changed, 19 insertions(+), 7 deletions(-)
>
Stanislaw Gruszka Nov. 9, 2018, 1:16 p.m. UTC | #2
On Fri, Nov 09, 2018 at 12:33:32PM +0100, Lorenzo Bianconi wrote:
> > Disable BEACON timer during init and remove interrupt registers
> > initalization form generic conde since they are PCIe specific.
> > 
> 
> Since the timer is actually disabled (MT_INT_TIMER_EN set to 0) and
> we just set the timer timeout here, does it worth to copy/paste
> the same code?

As I pointed somwhere else I have some random, not easy to reproduce
performance drops on MT7610U sta mode, starting when AP mode support
was added. I'm can not be sure if this is by this setting this
timer, but I would rather accept slight code duplication, than 
do something that (even with very low probability) can cause
troubles and for sure is not necessary.

Thanks
Stanislaw
Lorenzo Bianconi Nov. 9, 2018, 1:59 p.m. UTC | #3
> On Fri, Nov 09, 2018 at 12:33:32PM +0100, Lorenzo Bianconi wrote:
> > > Disable BEACON timer during init and remove interrupt registers
> > > initalization form generic conde since they are PCIe specific.
> > > 
> > 
> > Since the timer is actually disabled (MT_INT_TIMER_EN set to 0) and
> > we just set the timer timeout here, does it worth to copy/paste
> > the same code?
> 
> As I pointed somwhere else I have some random, not easy to reproduce
> performance drops on MT7610U sta mode, starting when AP mode support
> was added. I'm can not be sure if this is by this setting this
> timer, but I would rather accept slight code duplication, than 
> do something that (even with very low probability) can cause
> troubles and for sure is not necessary.

I am fine with this patch but I do not see how original code can cause issues since
MT_INT_TIMER_EN is already set it to 0 (comment mt76_wr(dev, MT_INT_TIMER_EN, 0) out
in the original code)

Regards,
Lorenzo

> 
> Thanks
> Stanislaw
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 757816d2b1ab..d1d3c5706c4d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -129,6 +129,13 @@  static int mt76x0e_register_device(struct mt76x02_dev *dev)
 	if (err < 0)
 		return err;
 
+	/* Beaconing: fire a pre-TBTT interrupt 8 ms before TBTT */
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
+		       8 << 4);
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
+		       MT_DFS_GP_INTERVAL);
+	mt76_wr(dev, MT_INT_TIMER_EN, 0);
+
 	if (mt76_chip(&dev->mt76) == 0x7610) {
 		u16 val;
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index dbf9d89dd328..2bb79c6eb54b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -633,13 +633,10 @@  void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
 {
 	int i;
 
-	/* Fire a pre-TBTT interrupt 8 ms before TBTT */
-	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
-		       8 << 4);
-	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
-		       MT_DFS_GP_INTERVAL);
-	mt76_wr(dev, MT_INT_TIMER_EN, 0);
-
+	mt76_clear(dev, MT_BEACON_TIME_CFG, (MT_BEACON_TIME_CFG_TIMER_EN |
+					     MT_BEACON_TIME_CFG_SYNC_MODE |
+					     MT_BEACON_TIME_CFG_TBTT_EN |
+					     MT_BEACON_TIME_CFG_BEACON_TX));
 	mt76_wr(dev, MT_BCN_BYPASS_MASK, 0xffff);
 
 	for (i = 0; i < 8; i++)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
index d2ef68c48ea5..89941aea8a88 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
@@ -121,6 +121,14 @@  static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
 
 	mt76x02_mac_init_mbss(dev, macaddr);
 	mt76x02_init_beacon_config(dev);
+
+	/* Fire a pre-TBTT interrupt 8 ms before TBTT */
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
+		       8 << 4);
+	mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
+		       MT_DFS_GP_INTERVAL);
+	mt76_wr(dev, MT_INT_TIMER_EN, 0);
+
 	if (!hard)
 		return 0;