All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtl8187b: do not do per packet TX AGC
@ 2010-08-28  5:54 Thadeu Lima de Souza Cascardo
  2010-08-28 21:32 ` Larry Finger
  0 siblings, 1 reply; 22+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-08-28  5:54 UTC (permalink / raw)
  To: linux-wireless
  Cc: Thadeu Lima de Souza Cascardo, Larry Finger, Rogerio Luz Coelho,
	Herton Ronaldo Krzesinski, Hin-Tak Leung

The code for rtl8187 does not do per packet TX AGC. Resetting the per
packet TX AGC for rtl8187b appears to increase its overall TX power.
This allows the device to associate and a connection be established
using APs a little further away.

Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: linux-wireless@vger.kernel.org
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Cc: Hin-Tak Leung <hintak.leung@gmail.com>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 38fa824..6e26149 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -775,10 +775,6 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	reg = rtl818x_ioread8(priv, &priv->map->CW_CONF);
 	reg |= RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT;
 	rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg);
-	reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL);
-	reg |= RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT |
-	       RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT;
-	rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg);
 
 	rtl818x_iowrite16_idx(priv, (__le16 *)0xFFE0, 0x0FFF, 1);
 
@@ -929,6 +925,12 @@ static int rtl8187_start(struct ieee80211_hw *dev)
 		priv->rx_conf = reg;
 		rtl818x_iowrite32(priv, &priv->map->RX_CONF, reg);
 
+		reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL);
+		reg &= ~RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT;
+		reg &= ~RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT;
+		reg &= ~RTL818X_TX_AGC_CTL_FEEDBACK_ANT;
+		rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg);
+
 		rtl818x_iowrite32(priv, &priv->map->TX_CONF,
 				  RTL818X_TX_CONF_HW_SEQNUM |
 				  RTL818X_TX_CONF_DISREQQSIZE |
-- 
1.7.1


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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-08-28  5:54 [PATCH] rtl8187b: do not do per packet TX AGC Thadeu Lima de Souza Cascardo
@ 2010-08-28 21:32 ` Larry Finger
  2010-08-30 14:12   ` John W. Linville
  2010-08-30 15:12   ` Thadeu Lima de Souza Cascardo
  0 siblings, 2 replies; 22+ messages in thread
From: Larry Finger @ 2010-08-28 21:32 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo
  Cc: linux-wireless, Rogerio Luz Coelho, Herton Ronaldo Krzesinski,
	Hin-Tak Leung

On 08/28/2010 12:54 AM, Thadeu Lima de Souza Cascardo wrote:
> The code for rtl8187 does not do per packet TX AGC. Resetting the per
> packet TX AGC for rtl8187b appears to increase its overall TX power.
> This allows the device to associate and a connection be established
> using APs a little further away.
> 
> Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> Cc: linux-wireless@vger.kernel.org
> Cc: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
> Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> Cc: Hin-Tak Leung <hintak.leung@gmail.com>
> ---

I'm a little confused here. The subject says not to set the per packet TX AGC,
while the submission text says that setting it helps. I don't have access to any
documents that describe this register, but I expect that clearing
RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT would disable that feature. As a result
the code change seems to match the subject.

I have not yet tested this code, but I do note that all the Realtek drivers for
the RTL8187B set this bit.

Until testing, I withhold judgment on the actual code change, but NACK for the
inconsistency.

Larry


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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-08-28 21:32 ` Larry Finger
@ 2010-08-30 14:12   ` John W. Linville
  2010-08-30 14:48     ` Larry Finger
  2010-08-30 15:12   ` Thadeu Lima de Souza Cascardo
  1 sibling, 1 reply; 22+ messages in thread
From: John W. Linville @ 2010-08-30 14:12 UTC (permalink / raw)
  To: Larry Finger
  Cc: Thadeu Lima de Souza Cascardo, linux-wireless,
	Rogerio Luz Coelho, Herton Ronaldo Krzesinski, Hin-Tak Leung

On Sat, Aug 28, 2010 at 04:32:48PM -0500, Larry Finger wrote:
> On 08/28/2010 12:54 AM, Thadeu Lima de Souza Cascardo wrote:
> > The code for rtl8187 does not do per packet TX AGC. Resetting the per
> > packet TX AGC for rtl8187b appears to increase its overall TX power.
> > This allows the device to associate and a connection be established
> > using APs a little further away.
> > 
> > Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> > Cc: linux-wireless@vger.kernel.org
> > Cc: Larry Finger <Larry.Finger@lwfinger.net>
> > Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
> > Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> > Cc: Hin-Tak Leung <hintak.leung@gmail.com>
> > ---
> 
> I'm a little confused here. The subject says not to set the per packet TX AGC,
> while the submission text says that setting it helps. I don't have access to any
> documents that describe this register, but I expect that clearing
> RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT would disable that feature. As a result
> the code change seems to match the subject.
> 
> I have not yet tested this code, but I do note that all the Realtek drivers for
> the RTL8187B set this bit.
> 
> Until testing, I withhold judgment on the actual code change, but NACK for the
> inconsistency.

Perhaps the word "clearing" rather than "resetting" would be less confusing?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-08-30 14:12   ` John W. Linville
@ 2010-08-30 14:48     ` Larry Finger
  2010-08-30 15:28       ` Thadeu Lima de Souza Cascardo
  0 siblings, 1 reply; 22+ messages in thread
From: Larry Finger @ 2010-08-30 14:48 UTC (permalink / raw)
  To: John W. Linville
  Cc: Thadeu Lima de Souza Cascardo, linux-wireless,
	Rogerio Luz Coelho, Herton Ronaldo Krzesinski, Hin-Tak Leung

On 08/30/2010 09:12 AM, John W. Linville wrote:
> On Sat, Aug 28, 2010 at 04:32:48PM -0500, Larry Finger wrote:
>> On 08/28/2010 12:54 AM, Thadeu Lima de Souza Cascardo wrote:
>>> The code for rtl8187 does not do per packet TX AGC. Resetting the per
>>> packet TX AGC for rtl8187b appears to increase its overall TX power.
>>> This allows the device to associate and a connection be established
>>> using APs a little further away.
>>>
>>> Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
>>> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
>>> Cc: linux-wireless@vger.kernel.org
>>> Cc: Larry Finger <Larry.Finger@lwfinger.net>
>>> Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
>>> Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
>>> Cc: Hin-Tak Leung <hintak.leung@gmail.com>
>>> ---
>>
>> I'm a little confused here. The subject says not to set the per packet TX AGC,
>> while the submission text says that setting it helps. I don't have access to any
>> documents that describe this register, but I expect that clearing
>> RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT would disable that feature. As a result
>> the code change seems to match the subject.
>>
>> I have not yet tested this code, but I do note that all the Realtek drivers for
>> the RTL8187B set this bit.
>>
>> Until testing, I withhold judgment on the actual code change, but NACK for the
>> inconsistency.
> 
> Perhaps the word "clearing" rather than "resetting" would be less confusing?

I see the source of my confusion. I am in the habit of using lower case to
indicate the driver and upper case for the device. I would rewrite the commit
code to say "The code for the RTL8187L does not do per packet TX AGC. Clearing
the per packet TX AGC for RTL8187B ..."

I have now tested the patch. For my RTL8187B device, I get the following:

Distance from AP      Indicated rate       Signal       Measured TX rate
      2m                   18 Mb/s         -17 dBm      10 Mb/s
     10m(original)         11 Mb/s         -48 dBm      2.6 Mb/s
     10m(with patch)       11 Mb/s         -43 dBm      4.1 Mb/s

The measured TX rates were obtained using tcpperf. At a distance of 2 m, the
results were the same with and without the patch. At 10 m, the patch went
through 2 exterior walls with drywall, insulation, and stucco. I'm not sure that
the increase from 2.6 to 4.1 Mb/s is reproducible. About all I can say is that
the change did not hurt the performance of the device, which is already pretty bad.

If the OP can post numbers documenting the improvement, I have no objection to
this patch, even though every Realtek driver that I have seen turns "per packet
TX AGC" on for the RTL8187B and turns it off for the RTL8187L.

Larry

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-08-28 21:32 ` Larry Finger
  2010-08-30 14:12   ` John W. Linville
@ 2010-08-30 15:12   ` Thadeu Lima de Souza Cascardo
  2010-09-16 18:44     ` John W. Linville
  1 sibling, 1 reply; 22+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-08-30 15:12 UTC (permalink / raw)
  To: Larry Finger
  Cc: linux-wireless, Rogerio Luz Coelho, Herton Ronaldo Krzesinski,
	Hin-Tak Leung

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

On Sat, Aug 28, 2010 at 04:32:48PM -0500, Larry Finger wrote:
> On 08/28/2010 12:54 AM, Thadeu Lima de Souza Cascardo wrote:
> > The code for rtl8187 does not do per packet TX AGC. Resetting the per
> > packet TX AGC for rtl8187b appears to increase its overall TX power.
> > This allows the device to associate and a connection be established
> > using APs a little further away.
> > 
> > Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> > Cc: linux-wireless@vger.kernel.org
> > Cc: Larry Finger <Larry.Finger@lwfinger.net>
> > Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
> > Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> > Cc: Hin-Tak Leung <hintak.leung@gmail.com>
> > ---
> 
> I'm a little confused here. The subject says not to set the per packet TX AGC,
> while the submission text says that setting it helps. I don't have access to any
> documents that describe this register, but I expect that clearing
> RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT would disable that feature. As a result
> the code change seems to match the subject.

Hello, Larry.

I meant rtl8187 versus rtl8187b, since the driver does that distinction.
You may note that in function rtl8187_start, if priv->is_rtl8187b fails,
it will reset RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT, just before
writing to TX_CONF. That's why I've decided to do it too before writing
in TX_CONF in the priv->is_rtl8187b true case.

And I meant resetting and "setting to zero". Perhaps, I may clarify that
too.

> 
> I have not yet tested this code, but I do note that all the Realtek drivers for
> the RTL8187B set this bit.
> 

Well, rtl8187B_linux_26.1056.1112.2009.release does reset it to zero
too. And that's what has hit me into trying it.

> Until testing, I withhold judgment on the actual code change, but NACK for the
> inconsistency.
> 

I will send another version, clarifying the commit message. Thanks for
the comments.

Regards,
Cascardo.

> Larry
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-08-30 14:48     ` Larry Finger
@ 2010-08-30 15:28       ` Thadeu Lima de Souza Cascardo
  2010-10-26 18:03         ` seno
  0 siblings, 1 reply; 22+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-08-30 15:28 UTC (permalink / raw)
  To: Larry Finger
  Cc: John W. Linville, linux-wireless, Rogerio Luz Coelho,
	Herton Ronaldo Krzesinski, Hin-Tak Leung

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

On Mon, Aug 30, 2010 at 09:48:57AM -0500, Larry Finger wrote:
> On 08/30/2010 09:12 AM, John W. Linville wrote:
> > On Sat, Aug 28, 2010 at 04:32:48PM -0500, Larry Finger wrote:
> >> On 08/28/2010 12:54 AM, Thadeu Lima de Souza Cascardo wrote:
> >>> The code for rtl8187 does not do per packet TX AGC. Resetting the per
> >>> packet TX AGC for rtl8187b appears to increase its overall TX power.
> >>> This allows the device to associate and a connection be established
> >>> using APs a little further away.
> >>>
> >>> Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> >>> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> >>> Cc: linux-wireless@vger.kernel.org
> >>> Cc: Larry Finger <Larry.Finger@lwfinger.net>
> >>> Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
> >>> Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> >>> Cc: Hin-Tak Leung <hintak.leung@gmail.com>
> >>> ---
> >>
> >> I'm a little confused here. The subject says not to set the per packet TX AGC,
> >> while the submission text says that setting it helps. I don't have access to any
> >> documents that describe this register, but I expect that clearing
> >> RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT would disable that feature. As a result
> >> the code change seems to match the subject.
> >>
> >> I have not yet tested this code, but I do note that all the Realtek drivers for
> >> the RTL8187B set this bit.
> >>
> >> Until testing, I withhold judgment on the actual code change, but NACK for the
> >> inconsistency.
> > 
> > Perhaps the word "clearing" rather than "resetting" would be less confusing?
> 

Thanks, John, for the clarification. Clearing is much better, really.

> I see the source of my confusion. I am in the habit of using lower case to
> indicate the driver and upper case for the device. I would rewrite the commit
> code to say "The code for the RTL8187L does not do per packet TX AGC. Clearing
> the per packet TX AGC for RTL8187B ..."
> 

I will use your rewriting. Thanks.

> I have now tested the patch. For my RTL8187B device, I get the following:
> 
> Distance from AP      Indicated rate       Signal       Measured TX rate
>       2m                   18 Mb/s         -17 dBm      10 Mb/s
>      10m(original)         11 Mb/s         -48 dBm      2.6 Mb/s
>      10m(with patch)       11 Mb/s         -43 dBm      4.1 Mb/s
> 
> The measured TX rates were obtained using tcpperf. At a distance of 2 m, the
> results were the same with and without the patch. At 10 m, the patch went
> through 2 exterior walls with drywall, insulation, and stucco. I'm not sure that
> the increase from 2.6 to 4.1 Mb/s is reproducible. About all I can say is that
> the change did not hurt the performance of the device, which is already pretty bad.
> 
> If the OP can post numbers documenting the improvement, I have no objection to
> this patch, even though every Realtek driver that I have seen turns "per packet
> TX AGC" on for the RTL8187B and turns it off for the RTL8187L.
> 

Hum. Did you take a look at the version I've pointed out in the last
message, rtl8187B_linux_26.1056.1112.2009.release? It does not clear
PERPACKET_GAIN in the same function that it does for non-RTL8187B
devices. But it does in what should be the code for RTL8225Z2, in the
function r8180_rtl8225z2.c:InitializeExtraRegsOn8185.

I did not measure the distances exactly here, while doing my tests. But
I could move the AP further away by about 5 or 6 meters. The AP
indicated a -84dB signal while receiving injected packages. It was a
rt73usb device. File transmission through scp was not working that
further away, but I could still get an improvement of about 3 to 4
meters of distance.

I am still going to do some more testing today in a customer's facility.
And I would like very much that Rogério, who has reported some problems
too, did some testing.

> Larry

Best regards,
Cascardo.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-08-30 15:12   ` Thadeu Lima de Souza Cascardo
@ 2010-09-16 18:44     ` John W. Linville
  0 siblings, 0 replies; 22+ messages in thread
From: John W. Linville @ 2010-09-16 18:44 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo
  Cc: Larry Finger, linux-wireless, Rogerio Luz Coelho,
	Herton Ronaldo Krzesinski, Hin-Tak Leung

On Mon, Aug 30, 2010 at 12:12:04PM -0300, Thadeu Lima de Souza Cascardo wrote:

> > Until testing, I withhold judgment on the actual code change, but NACK for the
> > inconsistency.
> > 
> 
> I will send another version, clarifying the commit message. Thanks for
> the comments.

Should I still be expecting to see this?

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

* Re:[PATCH] rtl8187b: do not do per packet TX AGC
  2010-08-30 15:28       ` Thadeu Lima de Souza Cascardo
@ 2010-10-26 18:03         ` seno
  2010-10-26 18:25           ` [PATCH] " Larry Finger
  0 siblings, 1 reply; 22+ messages in thread
From: seno @ 2010-10-26 18:03 UTC (permalink / raw)
  To: linux-wireless

I tried that patch on compat-wireless-2010-10-25 (Kernel 2.6.33.7).

Performance improves minimal, but thousands of errors occur in iwconfig output.
(Tx excessive retries, Invalid misc, Missed beacon).

The router also shows lots of errors 
(for Received (RX) / Transmitted (TX) packets)


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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-26 18:03         ` seno
@ 2010-10-26 18:25           ` Larry Finger
  2010-10-26 18:53             ` Thadeu Lima de Souza Cascardo
  0 siblings, 1 reply; 22+ messages in thread
From: Larry Finger @ 2010-10-26 18:25 UTC (permalink / raw)
  To: seno; +Cc: linux-wireless

On 10/26/2010 01:03 PM, seno wrote:
> I tried that patch on compat-wireless-2010-10-25 (Kernel 2.6.33.7).
> 
> Performance improves minimal, but thousands of errors occur in iwconfig output.
> (Tx excessive retries, Invalid misc, Missed beacon).
> 
> The router also shows lots of errors 
> (for Received (RX) / Transmitted (TX) packets)

I no longer remember the details of why this patch was abandoned, but I suspect
you found the answer.

Larry

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-26 18:25           ` [PATCH] " Larry Finger
@ 2010-10-26 18:53             ` Thadeu Lima de Souza Cascardo
  2010-10-28 21:13               ` Herton Ronaldo Krzesinski
  0 siblings, 1 reply; 22+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-10-26 18:53 UTC (permalink / raw)
  To: Larry Finger; +Cc: seno, linux-wireless

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

On Tue, Oct 26, 2010 at 01:25:03PM -0500, Larry Finger wrote:
> On 10/26/2010 01:03 PM, seno wrote:
> > I tried that patch on compat-wireless-2010-10-25 (Kernel 2.6.33.7).
> > 
> > Performance improves minimal, but thousands of errors occur in iwconfig output.
> > (Tx excessive retries, Invalid misc, Missed beacon).
> > 
> > The router also shows lots of errors 
> > (for Received (RX) / Transmitted (TX) packets)
> 
> I no longer remember the details of why this patch was abandoned, but I suspect
> you found the answer.
> 

It was because of the bad wording in the commit description. I was
expecting some more testing from my client before posting it again with
the wording fixed. They've been testing it and there is enough
improvement they require the patch. I don't get the thousands of errors
in iwconfig output. I can try to reproduce it here if I get more
details.

Thanks,
Cascardo.

> Larry
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-26 18:53             ` Thadeu Lima de Souza Cascardo
@ 2010-10-28 21:13               ` Herton Ronaldo Krzesinski
  2010-10-28 22:01                 ` Thadeu Lima de Souza Cascardo
  2010-10-28 23:21                 ` seno
  0 siblings, 2 replies; 22+ messages in thread
From: Herton Ronaldo Krzesinski @ 2010-10-28 21:13 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo; +Cc: Larry Finger, seno, linux-wireless

On Tue, 26 Oct 2010 16:53:42 -0200
Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> wrote:
> On Tue, Oct 26, 2010 at 01:25:03PM -0500, Larry Finger wrote:
> > On 10/26/2010 01:03 PM, seno wrote:
> > > I tried that patch on compat-wireless-2010-10-25 (Kernel 2.6.33.7).
> > > 
> > > Performance improves minimal, but thousands of errors occur in iwconfig output.
> > > (Tx excessive retries, Invalid misc, Missed beacon).
> > > 
> > > The router also shows lots of errors 
> > > (for Received (RX) / Transmitted (TX) packets)
> > 
> > I no longer remember the details of why this patch was abandoned, but I suspect
> > you found the answer.
> > 
> 
> It was because of the bad wording in the commit description. I was
> expecting some more testing from my client before posting it again with
> the wording fixed. They've been testing it and there is enough
> improvement they require the patch. I don't get the thousands of errors
> in iwconfig output. I can try to reproduce it here if I get more
> details.

The excessive retries etc. should be another issue. The patch from Thadeu
really improves the driver. In last days I got back a RTL8187B device for
testing, and for me it also improved the range and throughput doing some
scps or with iperf. And looking at newer realtek drivers for 8187B, they
also started to clear the flags. In fact, while doing a printk to see the
contents of the register after chip reset, it's already cleared, but I don't
see any problem to make sure we already have all *TX_AGC_CTL* flags cleared.
Also for 8180 and 8187L they are cleared. Unfortunately we don't have details
(documentation) on what these flags are exactly supposed to do...

But I really think the patch should go in, Thadeu can you post it again with
commit description fixed?

> 
> Thanks,
> Cascardo.
> 
> > Larry
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
[]'s
Herton

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

* [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-28 21:13               ` Herton Ronaldo Krzesinski
@ 2010-10-28 22:01                 ` Thadeu Lima de Souza Cascardo
  2010-10-29 13:15                   ` Herton Ronaldo Krzesinski
  2010-10-28 23:21                 ` seno
  1 sibling, 1 reply; 22+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-10-28 22:01 UTC (permalink / raw)
  To: linux-wireless
  Cc: Thadeu Lima de Souza Cascardo, Larry Finger, Rogerio Luz Coelho,
	Herton Ronaldo Krzesinski, Hin-Tak Leung, seno

Clearing the per packet TX AGC for the RTL8187B device appears to
increase its overall TX power. This allows the device to associate and a
connection to be established using APs a little further away.

This is in accordance to what is done for RTL8187L devices and also what
Realtek drivers do.

Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: linux-wireless@vger.kernel.org
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Cc: Hin-Tak Leung <hintak.leung@gmail.com>
Cc: seno <senada@t-online.de>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 38fa824..6e26149 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -775,10 +775,6 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	reg = rtl818x_ioread8(priv, &priv->map->CW_CONF);
 	reg |= RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT;
 	rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg);
-	reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL);
-	reg |= RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT |
-	       RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT;
-	rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg);
 
 	rtl818x_iowrite16_idx(priv, (__le16 *)0xFFE0, 0x0FFF, 1);
 
@@ -929,6 +925,12 @@ static int rtl8187_start(struct ieee80211_hw *dev)
 		priv->rx_conf = reg;
 		rtl818x_iowrite32(priv, &priv->map->RX_CONF, reg);
 
+		reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL);
+		reg &= ~RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT;
+		reg &= ~RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT;
+		reg &= ~RTL818X_TX_AGC_CTL_FEEDBACK_ANT;
+		rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg);
+
 		rtl818x_iowrite32(priv, &priv->map->TX_CONF,
 				  RTL818X_TX_CONF_HW_SEQNUM |
 				  RTL818X_TX_CONF_DISREQQSIZE |
-- 
1.7.1


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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-28 21:13               ` Herton Ronaldo Krzesinski
  2010-10-28 22:01                 ` Thadeu Lima de Souza Cascardo
@ 2010-10-28 23:21                 ` seno
  2010-10-29 13:54                   ` Thadeu Lima de Souza Cascardo
  1 sibling, 1 reply; 22+ messages in thread
From: seno @ 2010-10-28 23:21 UTC (permalink / raw)
  To: linux-wireless

Herton Ronaldo Krzesinski <herton@...> writes:

> The excessive retries etc. should be another issue. The patch from Thadeu
> really improves the driver.

Well, I tried once more today, maybe I'm doing something wrong?

- I run "./scripts/driver-select rtl818x" in compat-wireless-2010-10-28
- then "patch -p1 rtl8187_dev.c rtl8187b-do-not-do-per-packet-TX-AGC.patch"
- then "make"
- then "sudo make install"
- then reboot

"dmesg |grep compat" gives "Compat-wireless backport release: compat-
wireless-2010-10-22-5-g69fdc09" so the new module is used.

On speedtest.net, max speed is ~ 1mbit (on 10 mbit cable internet @10 meters 
distance)
The router reports an improved "Signal Quality", but iwconfig now shows:

"Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0"
"Tx excessive retries:2589  Invalid misc:17686   Missed beacon:0"

Herton: If I make something wrong, can you please post your rtl8187.ko.gz 
(Mandriva 2010.1 / 2.6.33.7-desktop-2mnb x86_64)?

Thank you.


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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-28 22:01                 ` Thadeu Lima de Souza Cascardo
@ 2010-10-29 13:15                   ` Herton Ronaldo Krzesinski
  0 siblings, 0 replies; 22+ messages in thread
From: Herton Ronaldo Krzesinski @ 2010-10-29 13:15 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo
  Cc: linux-wireless, Larry Finger, Rogerio Luz Coelho, Hin-Tak Leung, seno

On Thu, 28 Oct 2010 20:01:00 -0200
Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> wrote:

> Clearing the per packet TX AGC for the RTL8187B device appears to
> increase its overall TX power. This allows the device to associate and a
> connection to be established using APs a little further away.
> 
> This is in accordance to what is done for RTL8187L devices and also what
> Realtek drivers do.
> 
> Tested-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> Cc: linux-wireless@vger.kernel.org
> Cc: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Rogerio Luz Coelho <rogluz.news@gmail.com>
> Cc: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
> Cc: Hin-Tak Leung <hintak.leung@gmail.com>
> Cc: seno <senada@t-online.de>

Tested-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>

> ---
>  drivers/net/wireless/rtl818x/rtl8187_dev.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> index 38fa824..6e26149 100644
> --- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
> +++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
> @@ -775,10 +775,6 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
>  	reg = rtl818x_ioread8(priv, &priv->map->CW_CONF);
>  	reg |= RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT;
>  	rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg);
> -	reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL);
> -	reg |= RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT |
> -	       RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT;
> -	rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg);
>  
>  	rtl818x_iowrite16_idx(priv, (__le16 *)0xFFE0, 0x0FFF, 1);
>  
> @@ -929,6 +925,12 @@ static int rtl8187_start(struct ieee80211_hw *dev)
>  		priv->rx_conf = reg;
>  		rtl818x_iowrite32(priv, &priv->map->RX_CONF, reg);
>  
> +		reg = rtl818x_ioread8(priv, &priv->map->TX_AGC_CTL);
> +		reg &= ~RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT;
> +		reg &= ~RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT;
> +		reg &= ~RTL818X_TX_AGC_CTL_FEEDBACK_ANT;
> +		rtl818x_iowrite8(priv, &priv->map->TX_AGC_CTL, reg);
> +
>  		rtl818x_iowrite32(priv, &priv->map->TX_CONF,
>  				  RTL818X_TX_CONF_HW_SEQNUM |
>  				  RTL818X_TX_CONF_DISREQQSIZE |
> -- 
> 1.7.1
> 


-- 
[]'s
Herton

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-28 23:21                 ` seno
@ 2010-10-29 13:54                   ` Thadeu Lima de Souza Cascardo
  2010-10-29 22:31                     ` seno
  0 siblings, 1 reply; 22+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2010-10-29 13:54 UTC (permalink / raw)
  To: seno; +Cc: linux-wireless

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

On Thu, Oct 28, 2010 at 11:21:47PM +0000, seno wrote:
> Herton Ronaldo Krzesinski <herton@...> writes:
> 
> > The excessive retries etc. should be another issue. The patch from Thadeu
> > really improves the driver.
> 
> Well, I tried once more today, maybe I'm doing something wrong?
> 
> - I run "./scripts/driver-select rtl818x" in compat-wireless-2010-10-28
> - then "patch -p1 rtl8187_dev.c rtl8187b-do-not-do-per-packet-TX-AGC.patch"
> - then "make"
> - then "sudo make install"
> - then reboot
> 
> "dmesg |grep compat" gives "Compat-wireless backport release: compat-
> wireless-2010-10-22-5-g69fdc09" so the new module is used.
> 
> On speedtest.net, max speed is ~ 1mbit (on 10 mbit cable internet @10 meters 
> distance)
> The router reports an improved "Signal Quality", but iwconfig now shows:
> 
> "Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0"
> "Tx excessive retries:2589  Invalid misc:17686   Missed beacon:0"
> 
> Herton: If I make something wrong, can you please post your rtl8187.ko.gz 
> (Mandriva 2010.1 / 2.6.33.7-desktop-2mnb x86_64)?
> 
> Thank you.

Hello, seno.

Perhaps, the problem is related to using compat-wireless. Have you tried
using the module without the patch, using this same compat-wireless
version in the same linux version you are using?

Regards,
Cascardo.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-29 13:54                   ` Thadeu Lima de Souza Cascardo
@ 2010-10-29 22:31                     ` seno
  2010-10-30  0:00                       ` Larry Finger
  2010-11-01  4:39                       ` Herton Ronaldo Krzesinski
  0 siblings, 2 replies; 22+ messages in thread
From: seno @ 2010-10-29 22:31 UTC (permalink / raw)
  To: linux-wireless

Thadeu Lima de Souza Cascardo <cascardo@...> writes:

> Perhaps, the problem is related to using compat-wireless. Have you tried
> using the module without the patch, using this same compat-wireless
> version in the same linux version you are using?

Cascardo, you were right :-) Your patch did not cause the problem.
I get those errors also with an unpatched compat-wireless-2010-10-25 driver.

With a patched compat-wireless-2.6.33.6 there occur no errors.

The router reports a better signal quality compared to the unpatched module, but 
I can not really recognize a better throughput - usually still max 1 mbit @ 10 
meters.

I noticed that the connection is fast for a short time after booting (10 mbit @ 
10 meters), but a few seconds after the download on speedtest.net started 
(meaning the network gets under load), speed drops to 1 mbit and never recovers 
to faster speed again; somehow like an "unrecoverable fallback mechanism"...?


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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-29 22:31                     ` seno
@ 2010-10-30  0:00                       ` Larry Finger
  2010-10-30  2:12                         ` seno
  2010-11-01  4:39                       ` Herton Ronaldo Krzesinski
  1 sibling, 1 reply; 22+ messages in thread
From: Larry Finger @ 2010-10-30  0:00 UTC (permalink / raw)
  To: seno; +Cc: linux-wireless

On 10/29/2010 05:31 PM, seno wrote:
> I noticed that the connection is fast for a short time after booting (10 mbit @ 
> 10 meters), but a few seconds after the download on speedtest.net started 
> (meaning the network gets under load), speed drops to 1 mbit and never recovers 
> to faster speed again; somehow like an "unrecoverable fallback mechanism"...?

Is your device overheating?

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-30  0:00                       ` Larry Finger
@ 2010-10-30  2:12                         ` seno
  0 siblings, 0 replies; 22+ messages in thread
From: seno @ 2010-10-30  2:12 UTC (permalink / raw)
  To: linux-wireless

Larry Finger <Larry.Finger@...> writes:

> Is your device overheating?

I don't think so.

I reduced Tx-Power to 20 dBm (wireless regulatory domain DE).
That doesn't make any difference to 27 dBm (CA) or even 30 dBm (BO).
(Beside that: it performs fine in w7)

In contrast to the unchanged measured performance, web browsing feels 'snappier'
with the patched driver (websites load faster although speed peek never top > 140
kByte/s)


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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-10-29 22:31                     ` seno
  2010-10-30  0:00                       ` Larry Finger
@ 2010-11-01  4:39                       ` Herton Ronaldo Krzesinski
  2010-11-01 16:24                         ` Larry Finger
  1 sibling, 1 reply; 22+ messages in thread
From: Herton Ronaldo Krzesinski @ 2010-11-01  4:39 UTC (permalink / raw)
  To: seno; +Cc: linux-wireless, Larry.Finger, hintak.leung

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

On 29-10-2010 20:31, seno wrote:
> Thadeu Lima de Souza Cascardo<cascardo@...>  writes:
>
>> Perhaps, the problem is related to using compat-wireless. Have you tried
>> using the module without the patch, using this same compat-wireless
>> version in the same linux version you are using?
>
> Cascardo, you were right :-) Your patch did not cause the problem.
> I get those errors also with an unpatched compat-wireless-2010-10-25 driver.
>
> With a patched compat-wireless-2.6.33.6 there occur no errors.
>
> The router reports a better signal quality compared to the unpatched module, but
> I can not really recognize a better throughput - usually still max 1 mbit @ 10
> meters.
>
> I noticed that the connection is fast for a short time after booting (10 mbit @
> 10 meters), but a few seconds after the download on speedtest.net started
> (meaning the network gets under load), speed drops to 1 mbit and never recovers
> to faster speed again; somehow like an "unrecoverable fallback mechanism"...?

I have seen the throughput issue, but on my tests it wasn't so bad. 
Usually max I got on testing was 24M while close to the AP, and it goes 
into lower speeds when going more far away, but takes a good number of 
meters to go down to 1M.

Anyway of course something isn't right. I started reviewing realtek GPL 
code (their ieee80211 drivers) and code in rtl8187 in the kernel, doing 
many tests and verifying things, trying to understand and check some 
register writes etc. (hard with missing doc or other info).

I did some cleanups, and discovered two bad things in the code. After 
the fixes, I can get normal rates (up to 54M close to the AP) without 
issue. I'll soon post the patch series to be included in 
wireless-testing, for now just for test I attach them to be easier (hope 
it isn't stripped by ML, and yes they start on 0003 through 0011 :P), 
check if with it you get better results.

The patches that matter (shown by my tests) are:
0010-rtl8187-remove-uneeded-setting-of-anaparam-write.patch
0011-rtl8187-restore-anaparam-registers-after-reset-with-.patch

but they depend on some previous patches in the series (better apply 
all), and I diffed on a tree with Thadeu's patch applied already. There 
is more cleanups and checking to do, but I probably will submit this 
initial series and later come with more ones, as with this initial 
series the throughput issue should be solved.

>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
[]'s
Herton


[-- Attachment #2: 0003-rtl8187-remove-redundant-initialization-of-ARFR.patch --]
[-- Type: text/plain, Size: 2186 bytes --]

>From b7999be35d6a0b687ee55fd9af6d4dde07ce83a7 Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Fri, 29 Oct 2010 17:58:31 -0200
Subject: [PATCH] rtl8187: remove redundant initialization of ARFR

This removes redundant write to Auto Rate Fallback Register on RTL8187B.
The same value was being written to it on the same function. Avoid this
removing the duplicate initialization on rtl8187b_reg_table, and also
add comment for this write (information from Realtek source).

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 6e26149..3dbf305 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -712,10 +712,9 @@ static const u8 rtl8187b_reg_table[][3] = {
 
 	{0x58, 0x4B, 1}, {0x59, 0x00, 1}, {0x5A, 0x4B, 1}, {0x5B, 0x00, 1},
 	{0x60, 0x4B, 1}, {0x61, 0x09, 1}, {0x62, 0x4B, 1}, {0x63, 0x09, 1},
-	{0xCE, 0x0F, 1}, {0xCF, 0x00, 1}, {0xE0, 0xFF, 1}, {0xE1, 0x0F, 1},
-	{0xE2, 0x00, 1}, {0xF0, 0x4E, 1}, {0xF1, 0x01, 1}, {0xF2, 0x02, 1},
-	{0xF3, 0x03, 1}, {0xF4, 0x04, 1}, {0xF5, 0x05, 1}, {0xF6, 0x06, 1},
-	{0xF7, 0x07, 1}, {0xF8, 0x08, 1},
+	{0xCE, 0x0F, 1}, {0xCF, 0x00, 1}, {0xF0, 0x4E, 1}, {0xF1, 0x01, 1},
+	{0xF2, 0x02, 1}, {0xF3, 0x03, 1}, {0xF4, 0x04, 1}, {0xF5, 0x05, 1},
+	{0xF6, 0x06, 1}, {0xF7, 0x07, 1}, {0xF8, 0x08, 1},
 
 	{0x4E, 0x00, 2}, {0x0C, 0x04, 2}, {0x21, 0x61, 2}, {0x22, 0x68, 2},
 	{0x23, 0x6F, 2}, {0x24, 0x76, 2}, {0x25, 0x7D, 2}, {0x26, 0x84, 2},
@@ -776,7 +775,9 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	reg |= RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT;
 	rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg);
 
+	/* Auto Rate Fallback Register (ARFR): 1M-54M setting */
 	rtl818x_iowrite16_idx(priv, (__le16 *)0xFFE0, 0x0FFF, 1);
+	rtl818x_iowrite8_idx(priv, (u8 *)0xFFE2, 0x00, 1);
 
 	rtl818x_iowrite16(priv, &priv->map->BEACON_INTERVAL, 100);
 	rtl818x_iowrite16(priv, &priv->map->ATIM_WND, 2);
-- 
1.7.1



[-- Attachment #3: 0004-rtl8187-remove-setting-of-beacon-atim-registers-from.patch --]
[-- Type: text/plain, Size: 1231 bytes --]

>From e33c4770e112b2c67bc4d1572426693ac6b1e7ce Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Fri, 29 Oct 2010 15:41:02 -0200
Subject: [PATCH] rtl8187: remove setting of beacon/atim registers from initialization

On 8187B path, we set a initial value for beacon interval and atim
window on initialization. But this isn't needed, since same setup is
done on rtl8187_config.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 0c04654..e5f1269 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -776,8 +776,6 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	reg |= RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT;
 	rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg);
 
-	rtl818x_iowrite16(priv, &priv->map->BEACON_INTERVAL, 100);
-	rtl818x_iowrite16(priv, &priv->map->ATIM_WND, 2);
 	rtl818x_iowrite16_idx(priv, (__le16 *)0xFFD4, 0xFFFF, 1);
 
 	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-- 
1.7.1



[-- Attachment #4: 0005-rtl8187-fix-wrong-register-initialization-in-8187B.patch --]
[-- Type: text/plain, Size: 2386 bytes --]

>From 15bf87f344f5ca11c5e1f43bde35805e505f79c1 Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Fri, 29 Oct 2010 19:46:02 -0200
Subject: [PATCH] rtl8187: fix wrong register initialization in 8187B

We were using wrong address for BRSR (Basic Rate Set Register) while
initializing its value, comparing with Realtek sources, for 8187B case.

Also, the same register is initialized in rtl8187b_reg_table, so remove
the duplicate initialization from the table.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 30c2120..b9ce2a8 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -725,11 +725,11 @@ static const u8 rtl8187b_reg_table[][3] = {
 	{0x62, 0x08, 2}, {0x63, 0x08, 2}, {0x64, 0xCF, 2}, {0x72, 0x56, 2},
 	{0x73, 0x9A, 2},
 
-	{0x34, 0xF0, 0}, {0x35, 0x0F, 0}, {0x5B, 0x40, 0}, {0x84, 0x88, 0},
-	{0x85, 0x24, 0}, {0x88, 0x54, 0}, {0x8B, 0xB8, 0}, {0x8C, 0x07, 0},
-	{0x8D, 0x00, 0}, {0x94, 0x1B, 0}, {0x95, 0x12, 0}, {0x96, 0x00, 0},
-	{0x97, 0x06, 0}, {0x9D, 0x1A, 0}, {0x9F, 0x10, 0}, {0xB4, 0x22, 0},
-	{0xBE, 0x80, 0}, {0xDB, 0x00, 0}, {0xEE, 0x00, 0}, {0x4C, 0x00, 2},
+	{0x5B, 0x40, 0}, {0x84, 0x88, 0}, {0x85, 0x24, 0}, {0x88, 0x54, 0},
+	{0x8B, 0xB8, 0}, {0x8C, 0x07, 0}, {0x8D, 0x00, 0}, {0x94, 0x1B, 0},
+	{0x95, 0x12, 0}, {0x96, 0x00, 0}, {0x97, 0x06, 0}, {0x9D, 0x1A, 0},
+	{0x9F, 0x10, 0}, {0xB4, 0x22, 0}, {0xBE, 0x80, 0}, {0xDB, 0x00, 0},
+	{0xEE, 0x00, 0}, {0x4C, 0x00, 2},
 
 	{0x9F, 0x00, 3}, {0x8C, 0x01, 0}, {0x8D, 0x10, 0}, {0x8E, 0x08, 0},
 	{0x8F, 0x00, 0}
@@ -770,7 +770,11 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	if (res)
 		return res;
 
-	rtl818x_iowrite16(priv, (__le16 *)0xFF2D, 0x0FFF);
+	/* BRSR (Basic Rate Set Register) on 8187B looks to be the same as
+	 * RESP_RATE on 8187L in Realtek sources: each bit should be each
+	 * one of the 12 rates, all are enabled */
+	rtl818x_iowrite16(priv, (__le16 *)0xFF34, 0x0FFF);
+
 	reg = rtl818x_ioread8(priv, &priv->map->CW_CONF);
 	reg |= RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT;
 	rtl818x_iowrite8(priv, &priv->map->CW_CONF, reg);
-- 
1.7.1



[-- Attachment #5: 0006-rtl8187-avoid-redundant-write-to-register-FF72.patch --]
[-- Type: text/plain, Size: 1702 bytes --]

>From 6c7fb00e928d97e9f6aab3ea004e1642a242b5b5 Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Sat, 30 Oct 2010 15:06:46 -0200
Subject: [PATCH] rtl8187: avoid redundant write to register FF72 (RFSW_CTRL)

The table with misc register initialization were setting it, and later
on we would set it again with a explicity call to rtl818x_iowrite16_idx.

Remove duplicate initialization from the register table.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 7e6ebd0..21dc648 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -720,8 +720,7 @@ static const u8 rtl8187b_reg_table[][3] = {
 	{0x52, 0x04, 2}, {0x53, 0xA0, 2}, {0x54, 0x1F, 2}, {0x55, 0x23, 2},
 	{0x56, 0x45, 2}, {0x57, 0x67, 2}, {0x58, 0x08, 2}, {0x59, 0x08, 2},
 	{0x5A, 0x08, 2}, {0x5B, 0x08, 2}, {0x60, 0x08, 2}, {0x61, 0x08, 2},
-	{0x62, 0x08, 2}, {0x63, 0x08, 2}, {0x64, 0xCF, 2}, {0x72, 0x56, 2},
-	{0x73, 0x9A, 2},
+	{0x62, 0x08, 2}, {0x63, 0x08, 2}, {0x64, 0xCF, 2},
 
 	{0x5B, 0x40, 0}, {0x84, 0x88, 0}, {0x85, 0x24, 0}, {0x88, 0x54, 0},
 	{0x8B, 0xB8, 0}, {0x8C, 0x07, 0}, {0x8D, 0x00, 0}, {0x94, 0x1B, 0},
@@ -809,6 +808,7 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 
 	rtl818x_iowrite32(priv, &priv->map->RF_TIMING, 0x00004001);
 
+	/* RFSW_CTRL register */
 	rtl818x_iowrite16_idx(priv, (__le16 *)0xFF72, 0x569A, 2);
 
 	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-- 
1.7.1



[-- Attachment #6: 0007-rtl8187-move-pll-reset-at-start-out-of-ANAPARAM-writ.patch --]
[-- Type: text/plain, Size: 2116 bytes --]

>From e2d453c4cd574ac7de0b8852dcb576cf43b731fc Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Sat, 30 Oct 2010 17:02:03 -0200
Subject: [PATCH] rtl8187: move pll reset at start out of ANAPARAM write

On 8187B start, comment about pll reset, and move it out of ANAPARAM
write sequence, so that code is more readable.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 21dc648..72b0153 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -740,7 +740,6 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 
 	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
 			 RTL818X_EEPROM_CMD_CONFIG);
-
 	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
 	reg |= RTL818X_CONFIG3_ANAPARAM_WRITE | RTL818X_CONFIG3_GNT_SELECT;
 	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
@@ -750,19 +749,19 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 			  RTL8187B_RTL8225_ANAPARAM_ON);
 	rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
 			 RTL8187B_RTL8225_ANAPARAM3_ON);
-
-	rtl818x_iowrite8(priv, (u8 *)0xFF61, 0x10);
-	reg = rtl818x_ioread8(priv, (u8 *)0xFF62);
-	rtl818x_iowrite8(priv, (u8 *)0xFF62, reg & ~(1 << 5));
-	rtl818x_iowrite8(priv, (u8 *)0xFF62, reg | (1 << 5));
-
 	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
 	reg &= ~RTL818X_CONFIG3_ANAPARAM_WRITE;
 	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
-
 	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
 			 RTL818X_EEPROM_CMD_NORMAL);
 
+	/* Reset PLL sequence on 8187B. Realtek note: reduces power
+	 * consumption about 30 mA */
+	rtl818x_iowrite8(priv, (u8 *)0xFF61, 0x10);
+	reg = rtl818x_ioread8(priv, (u8 *)0xFF62);
+	rtl818x_iowrite8(priv, (u8 *)0xFF62, reg & ~(1 << 5));
+	rtl818x_iowrite8(priv, (u8 *)0xFF62, reg | (1 << 5));
+
 	res = rtl8187_cmd_reset(dev);
 	if (res)
 		return res;
-- 
1.7.1



[-- Attachment #7: 0008-rtl8187-don-t-set-RTL818X_CONFIG3_GNT_SELECT-flag-on.patch --]
[-- Type: text/plain, Size: 1471 bytes --]

>From d68a001d007914fa32a977a5cc0b15fd2c936afe Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Sat, 30 Oct 2010 19:39:26 -0200
Subject: [PATCH] rtl8187: don't set RTL818X_CONFIG3_GNT_SELECT flag on 8187B

The GNTSel bit should only concern pci devices by looking at RTL8180
spec, which is not the case of 8187B. Also testing shows that trying to
set this bit fails, a subsequent read from the register after trying to
set it shows that the bit isn't set, seems the hardware ignores it,
which makes sense. This setting was a left over from Realtek sources.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 72b0153..47c0b13 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -741,7 +741,7 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
 			 RTL818X_EEPROM_CMD_CONFIG);
 	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
-	reg |= RTL818X_CONFIG3_ANAPARAM_WRITE | RTL818X_CONFIG3_GNT_SELECT;
+	reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
 	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
 	rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
 			  RTL8187B_RTL8225_ANAPARAM2_ON);
-- 
1.7.1



[-- Attachment #8: 0009-rtl8187-consolidate-anaparam-on-off-write-sequences.patch --]
[-- Type: text/plain, Size: 6599 bytes --]

>From 06d221196dba00516c70113cf25509904373a9d6 Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Sat, 30 Oct 2010 22:26:19 -0200
Subject: [PATCH] rtl8187: consolidate anaparam on/off write sequences

There are repeated calls for anaparam on/off sequence in the code.
Consolidate the common code in rtl8187_set_anaparam and use it where
needed.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c     |   84 ++++++++++++-----------
 drivers/net/wireless/rtl818x/rtl8187_rtl8225.c |   22 ------
 2 files changed, 44 insertions(+), 62 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 47c0b13..896aba0 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -553,6 +553,46 @@ static int rtl8187b_init_status_urb(struct ieee80211_hw *dev)
 	return ret;
 }
 
+static void rtl8187_set_anaparam(struct rtl8187_priv *priv, bool rfon)
+{
+	u32 anaparam, anaparam2;
+	u8 anaparam3, reg;
+
+	if (!priv->is_rtl8187b) {
+		if (rfon) {
+			anaparam = RTL8187_RTL8225_ANAPARAM_ON;
+			anaparam2 = RTL8187_RTL8225_ANAPARAM2_ON;
+		} else {
+			anaparam = RTL8187_RTL8225_ANAPARAM_OFF;
+			anaparam2 = RTL8187_RTL8225_ANAPARAM2_OFF;
+		}
+	} else {
+		if (rfon) {
+			anaparam = RTL8187B_RTL8225_ANAPARAM_ON;
+			anaparam2 = RTL8187B_RTL8225_ANAPARAM2_ON;
+			anaparam3 = RTL8187B_RTL8225_ANAPARAM3_ON;
+		} else {
+			anaparam = RTL8187B_RTL8225_ANAPARAM_OFF;
+			anaparam2 = RTL8187B_RTL8225_ANAPARAM2_OFF;
+			anaparam3 = RTL8187B_RTL8225_ANAPARAM3_OFF;
+		}
+	}
+
+	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
+			 RTL818X_EEPROM_CMD_CONFIG);
+	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
+	reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
+        rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
+	rtl818x_iowrite32(priv, &priv->map->ANAPARAM, anaparam);
+	rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, anaparam2);
+	if (priv->is_rtl8187b)
+		rtl818x_iowrite8(priv, &priv->map->ANAPARAM3, anaparam3);
+	reg &= ~RTL818X_CONFIG3_ANAPARAM_WRITE;
+	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
+	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
+			 RTL818X_EEPROM_CMD_NORMAL);
+}
+
 static int rtl8187_cmd_reset(struct ieee80211_hw *dev)
 {
 	struct rtl8187_priv *priv = dev->priv;
@@ -603,19 +643,7 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
 	int res;
 
 	/* reset */
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-			 RTL818X_EEPROM_CMD_CONFIG);
-	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg |
-			 RTL818X_CONFIG3_ANAPARAM_WRITE);
-	rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
-			  RTL8187_RTL8225_ANAPARAM_ON);
-	rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
-			  RTL8187_RTL8225_ANAPARAM2_ON);
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg &
-			 ~RTL818X_CONFIG3_ANAPARAM_WRITE);
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-			 RTL818X_EEPROM_CMD_NORMAL);
+	rtl8187_set_anaparam(priv, true);
 
 	rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0);
 
@@ -629,17 +657,7 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
 	if (res)
 		return res;
 
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
-	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3,
-			reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
-	rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
-			  RTL8187_RTL8225_ANAPARAM_ON);
-	rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
-			  RTL8187_RTL8225_ANAPARAM2_ON);
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3,
-			reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
+	rtl8187_set_anaparam(priv, true);
 
 	/* setup card */
 	rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0);
@@ -738,22 +756,7 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	int res, i;
 	u8 reg;
 
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-			 RTL818X_EEPROM_CMD_CONFIG);
-	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
-	reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
-	rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
-			  RTL8187B_RTL8225_ANAPARAM2_ON);
-	rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
-			  RTL8187B_RTL8225_ANAPARAM_ON);
-	rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
-			 RTL8187B_RTL8225_ANAPARAM3_ON);
-	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
-	reg &= ~RTL818X_CONFIG3_ANAPARAM_WRITE;
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-			 RTL818X_EEPROM_CMD_NORMAL);
+	rtl8187_set_anaparam(priv, true);
 
 	/* Reset PLL sequence on 8187B. Realtek note: reduces power
 	 * consumption about 30 mA */
@@ -1005,6 +1008,7 @@ static void rtl8187_stop(struct ieee80211_hw *dev)
 	rtl818x_iowrite8(priv, &priv->map->CMD, reg);
 
 	priv->rf->stop(dev);
+	rtl8187_set_anaparam(priv, false);
 
 	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
 	reg = rtl818x_ioread8(priv, &priv->map->CONFIG4);
diff --git a/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c b/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
index 97eebdc..5c6666f 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
@@ -898,29 +898,7 @@ static void rtl8225z2_b_rf_init(struct ieee80211_hw *dev)
 
 static void rtl8225_rf_stop(struct ieee80211_hw *dev)
 {
-	u8 reg;
-	struct rtl8187_priv *priv = dev->priv;
-
 	rtl8225_write(dev, 0x4, 0x1f);
-
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
-	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
-	if (!priv->is_rtl8187b) {
-		rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
-				  RTL8187_RTL8225_ANAPARAM2_OFF);
-		rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
-				  RTL8187_RTL8225_ANAPARAM_OFF);
-	} else {
-		rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
-				  RTL8187B_RTL8225_ANAPARAM2_OFF);
-		rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
-				  RTL8187B_RTL8225_ANAPARAM_OFF);
-		rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
-				  RTL8187B_RTL8225_ANAPARAM3_OFF);
-	}
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
 }
 
 static void rtl8225_rf_set_channel(struct ieee80211_hw *dev,
-- 
1.7.1



[-- Attachment #9: 0010-rtl8187-remove-uneeded-setting-of-anaparam-write.patch --]
[-- Type: text/plain, Size: 1584 bytes --]

>From 8196a051927a3d2a679c0a41f470258d8f15c5c1 Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Sun, 31 Oct 2010 01:42:46 -0200
Subject: [PATCH] rtl8187: remove uneeded setting of anaparam write

Usually you set RTL818X_CONFIG3_ANAPARAM_WRITE when you are going to
change/write ANAPARAM registers. But in current initialization of
RTL8187B there is a place where ANAPARAM_WRITE bit is set without any
ANAPARAM register being written, without reason, so remove it.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 896aba0..c160c16 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -813,14 +813,6 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	/* RFSW_CTRL register */
 	rtl818x_iowrite16_idx(priv, (__le16 *)0xFF72, 0x569A, 2);
 
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-			 RTL818X_EEPROM_CMD_CONFIG);
-	reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
-	reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
-	rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
-	rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
-			 RTL818X_EEPROM_CMD_NORMAL);
-
 	rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, 0x0480);
 	rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0x2488);
 	rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, 0x1FFF);
-- 
1.7.1



[-- Attachment #10: 0011-rtl8187-restore-anaparam-registers-after-reset-with-.patch --]
[-- Type: text/plain, Size: 1295 bytes --]

>From 27c4daca2bacc85ba3e4b2a6901a55ac4a58c49c Mon Sep 17 00:00:00 2001
From: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Date: Sun, 31 Oct 2010 02:09:22 -0200
Subject: [PATCH] rtl8187: restore anaparam registers after reset with 8187B

Current 8187B initialization misses anaparam registers restore after
8187 reset. This causes ANAPARAM register to stay zeroed out (ANAPARAM2
kept its value on my tests). To avoid this, call rtl8187_set_anaparam
right after chip reset (to be on the safe side, as it makes sure we
restore all ANAPARAM registers).

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
---
 drivers/net/wireless/rtl818x/rtl8187_dev.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index c160c16..d62a313 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -769,6 +769,8 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
 	if (res)
 		return res;
 
+	rtl8187_set_anaparam(priv, true);
+
 	/* BRSR (Basic Rate Set Register) on 8187B looks to be the same as
 	 * RESP_RATE on 8187L in Realtek sources: each bit should be each
 	 * one of the 12 rates, all are enabled */
-- 
1.7.1



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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-11-01  4:39                       ` Herton Ronaldo Krzesinski
@ 2010-11-01 16:24                         ` Larry Finger
  2010-11-03  3:16                           ` Rogerio Luz Coelho
  2010-11-04 14:23                           ` Hin-Tak Leung
  0 siblings, 2 replies; 22+ messages in thread
From: Larry Finger @ 2010-11-01 16:24 UTC (permalink / raw)
  To: Herton Ronaldo Krzesinski; +Cc: seno, linux-wireless, hintak.leung

On 10/31/2010 11:39 PM, Herton Ronaldo Krzesinski wrote:
> I have seen the throughput issue, but on my tests it wasn't so bad.
> Usually max I got on testing was 24M while close to the AP, and it goes
> into lower speeds when going more far away, but takes a good number of
> meters to go down to 1M.
> 
> Anyway of course something isn't right. I started reviewing realtek GPL
> code (their ieee80211 drivers) and code in rtl8187 in the kernel, doing
> many tests and verifying things, trying to understand and check some
> register writes etc. (hard with missing doc or other info).
> 
> I did some cleanups, and discovered two bad things in the code. After
> the fixes, I can get normal rates (up to 54M close to the AP) without
> issue. I'll soon post the patch series to be included in
> wireless-testing, for now just for test I attach them to be easier (hope
> it isn't stripped by ML, and yes they start on 0003 through 0011 :P),
> check if with it you get better results.
> 
> The patches that matter (shown by my tests) are:
> 0010-rtl8187-remove-uneeded-setting-of-anaparam-write.patch
> 0011-rtl8187-restore-anaparam-registers-after-reset-with-.patch
> 
> but they depend on some previous patches in the series (better apply
> all), and I diffed on a tree with Thadeu's patch applied already. There
> is more cleanups and checking to do, but I probably will submit this
> initial series and later come with more ones, as with this initial
> series the throughput issue should be solved.

Good work. As you noted, patches 3 - 9 did not make any difference in the
transmit throughput. From a distance of 2 m from the AP, my 8187B yielded up to
11.4 Mb/s and an indicated rate of 24 M. Applying patch 10 raised those numbers
to 17.5 Mb/s and 48 M. Adding patch 11 raised them again to 26.9 Mb/s and 54 M,
thus getting full throughput for the 8187B and a transmit rate increase of 2.4X.

As expected, these changes had no affect on the RTL8187L. Note: The 8187L gets
values of 23.0 Mb/s and 54M - there may be a little performance gain to be
obtained from the driver.

You should submit these patches now, and feel free to add my "Acked-by:" to them.

Larry

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-11-01 16:24                         ` Larry Finger
@ 2010-11-03  3:16                           ` Rogerio Luz Coelho
  2010-11-04 14:23                           ` Hin-Tak Leung
  1 sibling, 0 replies; 22+ messages in thread
From: Rogerio Luz Coelho @ 2010-11-03  3:16 UTC (permalink / raw)
  To: Larry Finger
  Cc: Herton Ronaldo Krzesinski, seno, linux-wireless, hintak.leung

Ok I thought I got something wrong when I reviewed the thread I was
reading, this hole thread was in my trash folder (who would figure)

Will post results

Rogerio

2010/11/1 Larry Finger <Larry.Finger@lwfinger.net>:
> On 10/31/2010 11:39 PM, Herton Ronaldo Krzesinski wrote:
>> I have seen the throughput issue, but on my tests it wasn't so bad.
>> Usually max I got on testing was 24M while close to the AP, and it goes
>> into lower speeds when going more far away, but takes a good number of
>> meters to go down to 1M.
>>
>> Anyway of course something isn't right. I started reviewing realtek GPL
>> code (their ieee80211 drivers) and code in rtl8187 in the kernel, doing
>> many tests and verifying things, trying to understand and check some
>> register writes etc. (hard with missing doc or other info).
>>
>> I did some cleanups, and discovered two bad things in the code. After
>> the fixes, I can get normal rates (up to 54M close to the AP) without
>> issue. I'll soon post the patch series to be included in
>> wireless-testing, for now just for test I attach them to be easier (hope
>> it isn't stripped by ML, and yes they start on 0003 through 0011 :P),
>> check if with it you get better results.
>>
>> The patches that matter (shown by my tests) are:
>> 0010-rtl8187-remove-uneeded-setting-of-anaparam-write.patch
>> 0011-rtl8187-restore-anaparam-registers-after-reset-with-.patch
>>
>> but they depend on some previous patches in the series (better apply
>> all), and I diffed on a tree with Thadeu's patch applied already. There
>> is more cleanups and checking to do, but I probably will submit this
>> initial series and later come with more ones, as with this initial
>> series the throughput issue should be solved.
>
> Good work. As you noted, patches 3 - 9 did not make any difference in the
> transmit throughput. From a distance of 2 m from the AP, my 8187B yielded up to
> 11.4 Mb/s and an indicated rate of 24 M. Applying patch 10 raised those numbers
> to 17.5 Mb/s and 48 M. Adding patch 11 raised them again to 26.9 Mb/s and 54 M,
> thus getting full throughput for the 8187B and a transmit rate increase of 2.4X.
>
> As expected, these changes had no affect on the RTL8187L. Note: The 8187L gets
> values of 23.0 Mb/s and 54M - there may be a little performance gain to be
> obtained from the driver.
>
> You should submit these patches now, and feel free to add my "Acked-by:" to them.
>
> Larry
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH] rtl8187b: do not do per packet TX AGC
  2010-11-01 16:24                         ` Larry Finger
  2010-11-03  3:16                           ` Rogerio Luz Coelho
@ 2010-11-04 14:23                           ` Hin-Tak Leung
  1 sibling, 0 replies; 22+ messages in thread
From: Hin-Tak Leung @ 2010-11-04 14:23 UTC (permalink / raw)
  To: Larry Finger; +Cc: Herton Ronaldo Krzesinski, seno, linux-wireless

On Mon, Nov 1, 2010 at 4:24 PM, Larry Finger <Larry.Finger@lwfinger.net> wrote:
> On 10/31/2010 11:39 PM, Herton Ronaldo Krzesinski wrote:
>> I have seen the throughput issue, but on my tests it wasn't so bad.
>> Usually max I got on testing was 24M while close to the AP, and it goes
>> into lower speeds when going more far away, but takes a good number of
>> meters to go down to 1M.
>>
>> Anyway of course something isn't right. I started reviewing realtek GPL
>> code (their ieee80211 drivers) and code in rtl8187 in the kernel, doing
>> many tests and verifying things, trying to understand and check some
>> register writes etc. (hard with missing doc or other info).
>>
>> I did some cleanups, and discovered two bad things in the code. After
>> the fixes, I can get normal rates (up to 54M close to the AP) without
>> issue. I'll soon post the patch series to be included in
>> wireless-testing, for now just for test I attach them to be easier (hope
>> it isn't stripped by ML, and yes they start on 0003 through 0011 :P),
>> check if with it you get better results.
>>
>> The patches that matter (shown by my tests) are:
>> 0010-rtl8187-remove-uneeded-setting-of-anaparam-write.patch
>> 0011-rtl8187-restore-anaparam-registers-after-reset-with-.patch
>>
>> but they depend on some previous patches in the series (better apply
>> all), and I diffed on a tree with Thadeu's patch applied already. There
>> is more cleanups and checking to do, but I probably will submit this
>> initial series and later come with more ones, as with this initial
>> series the throughput issue should be solved.
>
> Good work. As you noted, patches 3 - 9 did not make any difference in the
> transmit throughput. From a distance of 2 m from the AP, my 8187B yielded up to
> 11.4 Mb/s and an indicated rate of 24 M. Applying patch 10 raised those numbers
> to 17.5 Mb/s and 48 M. Adding patch 11 raised them again to 26.9 Mb/s and 54 M,
> thus getting full throughput for the 8187B and a transmit rate increase of 2.4X.
>
> As expected, these changes had no affect on the RTL8187L. Note: The 8187L gets
> values of 23.0 Mb/s and 54M - there may be a little performance gain to be
> obtained from the driver.
>
> You should submit these patches now, and feel free to add my "Acked-by:" to them.
>
> Larry
>

Acked-by: Hin-Tak Leung <htl10@users.sourceforge.net>

Just to say I am following the thread from time to time. My AP machine
died (almost a year ago now...) so just haven't been using wireless
much lately.

HT

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

end of thread, other threads:[~2010-11-04 14:23 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-28  5:54 [PATCH] rtl8187b: do not do per packet TX AGC Thadeu Lima de Souza Cascardo
2010-08-28 21:32 ` Larry Finger
2010-08-30 14:12   ` John W. Linville
2010-08-30 14:48     ` Larry Finger
2010-08-30 15:28       ` Thadeu Lima de Souza Cascardo
2010-10-26 18:03         ` seno
2010-10-26 18:25           ` [PATCH] " Larry Finger
2010-10-26 18:53             ` Thadeu Lima de Souza Cascardo
2010-10-28 21:13               ` Herton Ronaldo Krzesinski
2010-10-28 22:01                 ` Thadeu Lima de Souza Cascardo
2010-10-29 13:15                   ` Herton Ronaldo Krzesinski
2010-10-28 23:21                 ` seno
2010-10-29 13:54                   ` Thadeu Lima de Souza Cascardo
2010-10-29 22:31                     ` seno
2010-10-30  0:00                       ` Larry Finger
2010-10-30  2:12                         ` seno
2010-11-01  4:39                       ` Herton Ronaldo Krzesinski
2010-11-01 16:24                         ` Larry Finger
2010-11-03  3:16                           ` Rogerio Luz Coelho
2010-11-04 14:23                           ` Hin-Tak Leung
2010-08-30 15:12   ` Thadeu Lima de Souza Cascardo
2010-09-16 18:44     ` John W. Linville

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.