b43: update flushing many writes performed in a row
authorRafał Miłecki <zajec5@gmail.com>
Thu, 31 Jul 2014 19:59:42 +0000 (21:59 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 25 Aug 2014 20:00:42 +0000 (16:00 -0400)
Flush radio writes as well and add some tiny optimizations (e.g.
masksetting PHY reg involves reading it, so reset the counter).

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/bus.h
drivers/net/wireless/b43/phy_common.c
drivers/net/wireless/b43/phy_n.c

index f3205c6988bc4354a14a5226011f762868253936..460d9d90bddebe4bccfac2ed76413a3192918f9e 100644 (file)
@@ -60,7 +60,21 @@ static inline bool b43_bus_host_is_pcmcia(struct b43_bus_dev *dev)
 #else
        return false;
 #endif
+};
+
+static inline bool b43_bus_host_is_pci(struct b43_bus_dev *dev)
+{
+#ifdef CONFIG_B43_BCMA
+       if (dev->bus_type == B43_BUS_BCMA)
+               return (dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI);
+#endif
+#ifdef CONFIG_B43_SSB
+       if (dev->bus_type == B43_BUS_SSB)
+               return (dev->sdev->bus->bustype == SSB_BUSTYPE_PCI);
+#endif
+       return false;
 }
+
 static inline bool b43_bus_host_is_sdio(struct b43_bus_dev *dev)
 {
 #ifdef CONFIG_B43_SSB
index 3cbef21b4726dc106c5746f79689a10d0db6c4e0..c868748b3f9e69a0dbf1e669bb2989d9cd7c6f26 100644 (file)
@@ -222,12 +222,18 @@ static inline void assert_mac_suspended(struct b43_wldev *dev)
 u16 b43_radio_read(struct b43_wldev *dev, u16 reg)
 {
        assert_mac_suspended(dev);
+       dev->phy.writes_counter = 0;
        return dev->phy.ops->radio_read(dev, reg);
 }
 
 void b43_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
        assert_mac_suspended(dev);
+       if (b43_bus_host_is_pci(dev->dev) &&
+           ++dev->phy.writes_counter > B43_MAX_WRITES_IN_ROW) {
+               b43_read32(dev, B43_MMIO_MACCTL);
+               dev->phy.writes_counter = 1;
+       }
        dev->phy.ops->radio_write(dev, reg, value);
 }
 
@@ -274,11 +280,12 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
 void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
        assert_mac_suspended(dev);
-       dev->phy.ops->phy_write(dev, reg, value);
-       if (++dev->phy.writes_counter == B43_MAX_WRITES_IN_ROW) {
+       if (b43_bus_host_is_pci(dev->dev) &&
+           ++dev->phy.writes_counter > B43_MAX_WRITES_IN_ROW) {
                b43_read16(dev, B43_MMIO_PHY_VER);
-               dev->phy.writes_counter = 0;
+               dev->phy.writes_counter = 1;
        }
+       dev->phy.ops->phy_write(dev, reg, value);
 }
 
 void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
index e2a3f0d5bcc27cc5a2f960989ad866fb11a644b9..b04aa34b027711f2de379cef7fcdf1ba73b7a4b7 100644 (file)
@@ -6517,6 +6517,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
        check_phyreg(dev, reg);
        b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
+       dev->phy.writes_counter = 1;
 }
 
 static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg)