rt61 & enable_radio error : some debug info inside

Live forum: http://rt2x00.serialmonkey.com/viewtopic.php?t=4628

nand

21-02-2008 20:41:04

Hi,

Basically, I have an rt61 which was working with the legacy driver, and here the driver won't load, with the following error "phy4 -> rt61pci_enable_radio Error - Register initialization failed." And I did a bit of debugging.

I'm on a Linux nand-laptop 2.6.24-8-generic #1 SMP Thu Feb 14 204045 UTC 2008 i686 GNU/Linux (2.6.24.2 packaged by ubuntu), the device is a
0300.0 Network controller [0280] RaLink RT2561/RT61 rev B 802.11g [18140302]
Subsystem D-Link System Inc DWL-G630 Rev E [11863c08]
Control I/O- Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B-
Status Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- <TAbort- <MAbort- >SERR- <PERR-
Latency 64, Cache Line Size 64 bytes
Interrupt pin A routed to IRQ 16
Region 0 Memory at e8400000 (32-bit, non-prefetchable)
Capabilities [40] Power Management version 2
Flags PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status D0 PME-Enable- DSel=0 DScale=0 PME-

I have rebuild the module with ralink debug enabled, and I get the following output
[ 6849.363328] pccard CardBus card inserted into slot 0
[ 6849.363572] PCI Enabling device 00000300.0 (0000 -> 0002)
[ 6849.363587] ACPI PCI Interrupt 00000300.0[A] -> Link [LNK1] -> GSI 19 (level, low) -> IRQ 16
[ 6849.363603] PCI Setting latency timer of device 00000300.0 to 64
[ 6849.371446] phy6 -> rt61pci_validate_eeprom EEPROM recovery - NIC 0xff80
[ 6849.371452] phy6 -> rt61pci_validate_eeprom EEPROM recovery - Led 0xe0ff
[ 6849.371461] phy6 -> rt2x00_set_chip Info - Chipset detected - rt 0302, rf 0003, rev 0002661b.
[ 6849.417198] phy6 Selected rate control algorithm 'simple'
[ 6849.550838] udev renamed network interface wlan0 to wlan1
[ 6849.723193] phy6 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
[ 6849.723213] phy6 -> rt61pci_enable_radio Error - Register initialization failed.
[ 6852.030490] phy6 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
[ 6852.030510] phy6 -> rt61pci_enable_radio Error - Register initialization failed.
[ 6855.185305] pccard card ejected from slot 0
[ 6855.282325] ACPI PCI interrupt for device 00000300.0 disabled

I did some further debugging, and the faulty instruction seem to be
if(rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_AWAKE))
inside rt61pci_init_registers, which returns -EBUSY.

I'll do some further debugging. Meanwhile, if you have an idea, please tell me )

nand

21-02-2008 21:03:24

To clarify a bit, the if(rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_AWAKE)) condition was being met, so the next instruction return -EBUSY was executed.


Now, as the returned error seems to imply that the device is busy, I tried the following
instead of
if(rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_AWAKE))
return -EBUSY;

I have put

int ret=1;
int i;
for (i = 0; i < 100; i++) {
ret = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_AWAKE);

if (!ret)
break;
msleep(1);
}
if(ret)
{
ERROR(rt2x00dev, "Register initialization failed. - 4\n");
return -EBUSY;
}

But that didn't help, I got a lot of

Feb 21 215821 nand-laptop kernel [ 4312.469358] phy8 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
Feb 21 215821 nand-laptop kernel [ 4312.575518] phy8 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
Feb 21 215822 nand-laptop kernel [ 4312.703382] phy8 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
Feb 21 215822 nand-laptop kernel [ 4312.803284] phy8 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
Feb 21 215822 nand-laptop kernel [ 4312.891184] phy8 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
Feb 21 215822 nand-laptop kernel [ 4312.979087] phy8 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.
Feb 21 215822 nand-laptop kernel [ 4313.066988] phy8 -> rt61pci_set_state Notice - Device failed to enter state 1, current device state 0.

followed by
Feb 21 215822 nand-laptop kernel [ 4313.074972] phy8 -> rt61pci_init_registers Error - Register initialization failed. - 4

Now the function call seems to go inside the rt2x00 common code, a little help for debugging would be welcome )

Nicolas

nand

21-02-2008 21:46:04

Tried reverting the following patch
http//www.spinics.net/lists/linux-wire ... 04858.html
But still same error.

One noticeable effect
With the vanilla driver, when the driver fails, both of its LEDs are on.
With the unpatched driver, when the driver fails, both of its LEDs are off, after a quick blink.

nand

21-02-2008 22:11:22

Precision by "unpatched driver", I was meaning the one with the reverted patch.

Now today's last attempt

After digging on the rt61 legacy code, even if
current_state =
rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE);
looks correctly translated (in rt61pci_set_state) from the corresponding legacy function, I saw the following definition in the rt61 legacy driver

typedef union _MAC_CSR12_STRUC {
struct {
ULONG29;
ULONG ForceWakeup1; // ForceWake has high privilege than PutToSleep when both set
ULONG PutToSleep1;
ULONG CurrentPowerState1; // 0sleep, 1awake
} field;
ULONG word;
} MAC_CSR12_STRUC, *PMAC_CSR12_STRUC;

I may be confused with endianess here, but it seems to me that the PowerState bit is on the first bit (whereas MAC_CSR12_BBP_CURRENT_STATE == 0x00000008) So I did try this
//current_state =
// rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE);
current_state =
rt2x00_get_field32(reg, FIELD32(0x00000001));

But again without success. /

IvD

21-02-2008 22:21:03

Well the legacy code never won any beaty contest, but if you looked in rtmp_init.c you will find the following code
[code8uca1c6x]
//
// Before program BBP, we need to wait BBP/RF get wake up.
//
Index = 0;
do {
RTMP_IO_READ32(pAdapter, MAC_CSR12, &MacCsr12);

if (MacCsr12 & 0x08)
break;

RTMPusecDelay(1000);
} while (Index++ < 1000);
[/code8uca1c6x]

This is where the MAC_CSR12_BBP_CURRENT_STATE definition was based on.

nand

23-02-2008 19:57:52

Yes, I was just giving a try.
I don't know at all the driver, I just encountered this problem and wanted to provide to the author something more substantial than "it doesn't work", and some quick random tries.

The reason why I make the comparison with the legacy driver is that it worked with it.

I have tried to skip this section of code (as the legacy driver implies that after the while loop, it will eventually go on and doesn't return an error).
The result is I get an interface, with mac address, but the scanning does not return any result.

Right now, I'm heading toward register initialization comparison between rt2x00 and the legacy one.

Is it necessary? What do you recommend me to look to?

IvD

23-02-2008 20:06:05

Well the order of the initialization should be correct,
what you could do is use attached script to dump the registers using debugfs (you should build the legacy driver with "make debugfs").

after that you have a complete dump of the register contents. I can already say that the registers will match for most part and that the differences are quite small (At least that is commonly the case, it doesn't hurt to check).

After that I know there are some issues with current rt2x00.git where most drivers are broken. This is (probably) not caused by register initialization (since the bug affects most drivers) but is something in rt2x00lib, rt2x00pci/rt2x00usb.

IvD

23-02-2008 20:06:39

forgot to attach script...

nand

24-02-2008 00:15:38

I am not using the lastest git, but the latest ubuntu kernel git, which correspond to the latest 2.6.24 stable kernel concerning rt2x00.
More specifically, debugfs tells me
driver rt61pci
version 2.0.10
compiled Feb 23 2008 222519

I have the chance to have three different realtek devices here an rt2500, an rt61, and an rt73. Only the rt61 is broken (and a default rate selection pb in the 2500) so I guess the problem you mention is not here.

For now I give you the registers output for the rt2x00 driver once the driver has stuck. The legacy will come later. Hope it helps. The MAC_CSR12 looks strange (0x0).

nand

21-03-2008 13:03:06

A small update on the subject
I had the chance to test another rt61, and this one works
0603.0 Network controller [0280] RaLink RT2561/RT61 rev B 802.11g [18140302]
Subsystem Micro-Star International Co., Ltd. Unknown device [1462b833]
Control I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop-
ParErr- Stepping- SERR+ FastB2B-
Status Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort-
<TAbort- <MAbort- >SERR- <PERR-
Latency 32, Cache Line Size 32 bytes
Interrupt pin A routed to IRQ 18
Region 0 Memory at b0000000 (32-bit, non-prefetchable)
Capabilities [40] Power Management version 2
Flags PMEClk- DSI- D1- D2- AuxCurrent=0mA
PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status D0 PME-Enable- DSel=0 DScale=0 PME-

For info, the one that didn't work was
0300.0 Network controller [0280] RaLink RT2561/RT61 rev B 802.11g [18140302]
Subsystem D-Link System Inc DWL-G630 Rev E [11863c08]
Control I/O- Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr- Stepping- SERR- FastB2B-
Status Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=slow >TAbort- <TAbort- <MAbort- >SERR- <PERR-
Latency 64, Cache Line Size 64 bytes
Interrupt pin A routed to IRQ 16
Region 0 Memory at e8400000 (32-bit, non-prefetchable)
Capabilities <access denied>

I hope this can help...