linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] b43: Add fastpath to b43_mac_suspend()
@ 2008-04-15 19:13 Michael Buesch
  2008-04-16 18:36 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Buesch @ 2008-04-15 19:13 UTC (permalink / raw)
  To: John Linville; +Cc: bcm43xx-dev, linux-wireless, Stefano Brivio

This adds a fastpath for the common workloads to the
MAC suspend flushing.
In common workloads the FIFO flush will take between 100 and
200 microseconds. So we want to avoid calling msleep() in the
common case, as it will waste over 800 microseconds + scheduler
overhead.

This fastpath will hit in workloads where only small chunks
of data are transmitted (downloading a file) or when a TX rate bigger
or equal to 24MBit/s is used when transmitting lots of stuff (iperf).
So in the commonly used workloads it will basically always hit.

In case the fastpath is not hit, there's no real performance or latency
disadvantage from that.

And yes, I measured this. So this is not one of these
bad Programmer Likeliness Assumptions that are always wrong. ;)

Signed-off-by: Michael Buesch <mb@bu3sch.de>

---

Patch version without useless {}

John, please apply to 2.6.26
Stefano, you may port this, if you like to.


Index: wireless-testing/drivers/net/wireless/b43/main.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/b43/main.c	2008-04-15 19:52:08.000000000 +0200
+++ wireless-testing/drivers/net/wireless/b43/main.c	2008-04-15 21:12:06.000000000 +0200
@@ -2340,12 +2340,20 @@ static void b43_mac_suspend(struct b43_w
 		b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
 		b43_write32(dev, B43_MMIO_MACCTL,
 			    b43_read32(dev, B43_MMIO_MACCTL)
 			    & ~B43_MACCTL_ENABLED);
 		/* force pci to flush the write */
 		b43_read32(dev, B43_MMIO_MACCTL);
+		/* Finally wait for the microcode to flush the fifos. */
+		for (i = 35; i; i--) {
+			tmp = b43_read32(dev, B43_MMIO_GEN_IRQ_REASON);
+			if (tmp & B43_IRQ_MAC_SUSPENDED)
+				goto out;
+			udelay(10);
+		}
+		/* Hm, it seems this will take some time. Use msleep(). */
 		for (i = 40; i; i--) {
 			tmp = b43_read32(dev, B43_MMIO_GEN_IRQ_REASON);
 			if (tmp & B43_IRQ_MAC_SUSPENDED)
 				goto out;
 			msleep(1);
 		}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] b43: Add fastpath to b43_mac_suspend()
  2008-04-15 19:13 [PATCH v2] b43: Add fastpath to b43_mac_suspend() Michael Buesch
@ 2008-04-16 18:36 ` Johannes Berg
  2008-04-16 19:13   ` Michael Buesch
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2008-04-16 18:36 UTC (permalink / raw)
  To: Michael Buesch; +Cc: John Linville, bcm43xx-dev, linux-wireless, Stefano Brivio

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

On Tue, 2008-04-15 at 21:13 +0200, Michael Buesch wrote:
> This adds a fastpath for the common workloads to the
> MAC suspend flushing.


> @@ -2340,12 +2340,20 @@ static void b43_mac_suspend(struct b43_w
>  		b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
>  		b43_write32(dev, B43_MMIO_MACCTL,
>  			    b43_read32(dev, B43_MMIO_MACCTL)
>  			    & ~B43_MACCTL_ENABLED);
>  		/* force pci to flush the write */
>  		b43_read32(dev, B43_MMIO_MACCTL);
> +		/* Finally wait for the microcode to flush the fifos. */

That comment is wrong, the ucode won't flush the FIFOs, it'll just go to
sleep. If you want it to flush FIFOs you have to set a flush request bit
somewhere (mac command I think), but you don't actually, you just don't
want to have it processing stuff.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] b43: Add fastpath to b43_mac_suspend()
  2008-04-16 18:36 ` Johannes Berg
@ 2008-04-16 19:13   ` Michael Buesch
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Buesch @ 2008-04-16 19:13 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, bcm43xx-dev, linux-wireless, Stefano Brivio

On Wednesday 16 April 2008 20:36:39 Johannes Berg wrote:
> On Tue, 2008-04-15 at 21:13 +0200, Michael Buesch wrote:
> > This adds a fastpath for the common workloads to the
> > MAC suspend flushing.
> 
> 
> > @@ -2340,12 +2340,20 @@ static void b43_mac_suspend(struct b43_w
> >  		b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
> >  		b43_write32(dev, B43_MMIO_MACCTL,
> >  			    b43_read32(dev, B43_MMIO_MACCTL)
> >  			    & ~B43_MACCTL_ENABLED);
> >  		/* force pci to flush the write */
> >  		b43_read32(dev, B43_MMIO_MACCTL);
> > +		/* Finally wait for the microcode to flush the fifos. */
> 
> That comment is wrong, the ucode won't flush the FIFOs, it'll just go to
> sleep. If you want it to flush FIFOs you have to set a flush request bit
> somewhere (mac command I think), but you don't actually, you just don't
> want to have it processing stuff.

Ah yeah. Whatever. What was meant it it flushes everything from the host
point of view and goes to sleep. Feel free to remove that comment, John.
(simply remove the line from the patch before applying it).

-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-16 19:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-15 19:13 [PATCH v2] b43: Add fastpath to b43_mac_suspend() Michael Buesch
2008-04-16 18:36 ` Johannes Berg
2008-04-16 19:13   ` Michael Buesch

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).