* [BUG] 2.6.29-rc7 broke r8169 MAC on Thecus n2100 ARM board
@ 2009-03-09 20:29 Mikael Pettersson
2009-03-13 20:15 ` Francois Romieu
0 siblings, 1 reply; 7+ messages in thread
From: Mikael Pettersson @ 2009-03-09 20:29 UTC (permalink / raw)
To: romieu; +Cc: linux-kernel, netdev
With the 2.6.29-rc7 kernel I'm unable to 'ifup' eth0 on my ARM-based
Thecus n2100 NAS box, which has an RTL8169 NIC (10ec:8169 (rev 10)).
A diff of the kernel logs from 2.6.29-rc6 and -rc7 shows that -rc7
first mangles and then zaps the MAC addresses:
--- dmesg-2.6.29-rc6 2009-03-09 20:27:49.000000000 +0100
+++ dmesg-2.6.29-rc7 2009-03-09 20:25:54.000000000 +0100
@@ -145,11 +145,13 @@
r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8169 0000:00:01.0: enabling Mem-Wr-Inval
r8169 0000:00:01.0: no PCI Express capability
-eth0: RTL8169sb/8110sb at 0xe080c200, 00:14:fd:30:11:78, XID 10000000 IRQ 27
+r8169 0000:00:01.0: MAC address found in EEPROM: 00:14:fd:10:00:00
+eth0: RTL8169sb/8110sb at 0xe080c200, 00:00:00:00:00:00, XID 10000000 IRQ 27
r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8169 0000:00:02.0: enabling Mem-Wr-Inval
r8169 0000:00:02.0: no PCI Express capability
-eth1: RTL8169sb/8110sb at 0xe0810300, 00:14:fd:30:11:79, XID 10000000 IRQ 30
+r8169 0000:00:02.0: MAC address found in EEPROM: 00:14:fd:10:00:00
+eth1: RTL8169sb/8110sb at 0xe0810300, 00:00:00:00:00:00, XID 10000000 IRQ 30
Driver 'sd' needs updating - please use bus_type methods
sata_sil 0000:00:03.0: version 2.4
sata_sil 0000:00:03.0: Applying R_ERR on DMA activate FIS errata fix
@@ -242,6 +244,4 @@
EXT3 FS on sda5, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
Adding 2008116k swap on /dev/sda3. Priority:-1 extents:1 across:2008116k
-r8169: eth0: link up
-r8169: eth0: link up
warning: `dbus-daemon' uses 32-bit capabilities (legacy support in use)
Reverting 6709fe9a27e43a4931938fe0d7f2cc5edef31386
"r8169: read MAC address from EEPROM on init (2nd attempt)"
fixes the problem on this machine.
/Mikael
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] 2.6.29-rc7 broke r8169 MAC on Thecus n2100 ARM board
2009-03-09 20:29 [BUG] 2.6.29-rc7 broke r8169 MAC on Thecus n2100 ARM board Mikael Pettersson
@ 2009-03-13 20:15 ` Francois Romieu
2009-03-14 2:23 ` Tim Durack
[not found] ` <9e246b4d0903131921k6fba9b04ge945c2902d4117d0@mail.gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Francois Romieu @ 2009-03-13 20:15 UTC (permalink / raw)
To: Mikael Pettersson; +Cc: linux-kernel, netdev, ivecera, tdurack
[-- Attachment #1: Type: text/plain, Size: 483 bytes --]
Mikael Pettersson <mikpe@it.uu.se> :
> With the 2.6.29-rc7 kernel I'm unable to 'ifup' eth0 on my ARM-based
> Thecus n2100 NAS box, which has an RTL8169 NIC (10ec:8169 (rev 10)).
> A diff of the kernel logs from 2.6.29-rc6 and -rc7 shows that -rc7
> first mangles and then zaps the MAC addresses:
Can you apply the attached patch and see if it fixes any of these
problems ?
Tim, could you give it a try too ? It applies with "patch -p1" from
the kernel tree directory.
--
Ueimor
[-- Attachment #2: r8169-init-mac-20.patch --]
[-- Type: text/plain, Size: 2081 bytes --]
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index b347340..5d2ae6b 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1833,7 +1833,13 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
RTL_W32(MAC4, high);
RTL_W8(Cfg9346, Cfg9346_Lock);
+ /* PCI commit */
+ RTL_R8(ChipCmd);
+
spin_unlock_irq(&tp->lock);
+
+ /* Hack. */
+ msleep_interruptible(1);
}
static int rtl_set_mac_address(struct net_device *dev, void *p)
@@ -1970,9 +1976,14 @@ static const struct net_device_ops rtl8169_netdev_ops = {
};
/* Delay between EEPROM clock transitions. Force out buffered PCI writes. */
-#define RTL_EEPROM_DELAY() RTL_R8(Cfg9346)
#define RTL_EEPROM_READ_CMD 6
+static void rtl_eeprom_delay(void __iomem *ioaddr)
+{
+ RTL_R8(Cfg9346);
+ ndelay(450);
+}
+
/* read 16bit word stored in EEPROM. EEPROM is addressed by words. */
static u16 rtl_eeprom_read(void __iomem *ioaddr, int addr)
{
@@ -1992,7 +2003,7 @@ static u16 rtl_eeprom_read(void __iomem *ioaddr, int addr)
/* enter programming mode */
RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS);
- RTL_EEPROM_DELAY();
+ rtl_eeprom_delay(ioaddr);
/* write command and requested address */
while (cmd_len--) {
@@ -2002,29 +2013,29 @@ static u16 rtl_eeprom_read(void __iomem *ioaddr, int addr)
/* write a bit */
RTL_W8(Cfg9346, x);
- RTL_EEPROM_DELAY();
+ rtl_eeprom_delay(ioaddr);
/* raise clock */
RTL_W8(Cfg9346, x | Cfg9346_EESK);
- RTL_EEPROM_DELAY();
+ rtl_eeprom_delay(ioaddr);
}
/* lower clock */
RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS);
- RTL_EEPROM_DELAY();
+ rtl_eeprom_delay(ioaddr);
/* read back 16bit value */
for (i = 16; i > 0; i--) {
/* raise clock */
RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS | Cfg9346_EESK);
- RTL_EEPROM_DELAY();
+ rtl_eeprom_delay(ioaddr);
result <<= 1;
result |= (RTL_R8(Cfg9346) & Cfg9346_EEDO) ? 1 : 0;
/* lower clock */
RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EECS);
- RTL_EEPROM_DELAY();
+ rtl_eeprom_delay(ioaddr);
}
RTL_W8(Cfg9346, Cfg9346_Program);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [BUG] 2.6.29-rc7 broke r8169 MAC on Thecus n2100 ARM board
2009-03-13 20:15 ` Francois Romieu
@ 2009-03-14 2:23 ` Tim Durack
[not found] ` <9e246b4d0903131921k6fba9b04ge945c2902d4117d0@mail.gmail.com>
1 sibling, 0 replies; 7+ messages in thread
From: Tim Durack @ 2009-03-14 2:23 UTC (permalink / raw)
To: Francois Romieu; +Cc: Mikael Pettersson, linux-kernel, netdev, ivecera
On Fri, Mar 13, 2009 at 4:15 PM, Francois Romieu <romieu@fr.zoreil.com> wrote:
> Mikael Pettersson <mikpe@it.uu.se> :
>> With the 2.6.29-rc7 kernel I'm unable to 'ifup' eth0 on my ARM-based
>> Thecus n2100 NAS box, which has an RTL8169 NIC (10ec:8169 (rev 10)).
>> A diff of the kernel logs from 2.6.29-rc6 and -rc7 shows that -rc7
>> first mangles and then zaps the MAC addresses:
>
> Can you apply the attached patch and see if it fixes any of these
> problems ?
>
> Tim, could you give it a try too ? It applies with "patch -p1" from
> the kernel tree directory.
>
> --
> Ueimor
>
No luck:
B-25-1NOC-CFG-1:~# modprobe -if r8169
[ 120.938729] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[ 120.945018] r8169 0000:00:09.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
[ 120.953409] r8169 0000:00:09.0: no PCI Express capability
[ 120.960359] r8169 0000:00:09.0: MAC address found in EEPROM:
00:30:18:ab:f0:34
[ 120.978441] eth1: RTL8169sc/8110sc at 0xf8154000,
00:00:00:00:f0:34, XID 18000000 IRQ 18
[ 120.988468] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[ 120.994119] r8169 0000:00:0b.0: PCI INT A -> GSI 19 (level, low) -> IRQ 19
[ 121.001139] r8169 0000:00:0b.0: no PCI Express capability
[ 121.006922] r8169 0000:00:0b.0: MAC address found in EEPROM:
00:30:18:ab:f0:35
[ 121.063615] eth2: RTL8169sc/8110sc at 0xf801e000,
00:00:00:00:f0:35, XID 18000000 IRQ 19
[ 121.072495] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
[ 121.078188] r8169 0000:00:0c.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
[ 121.085239] r8169 0000:00:0c.0: no PCI Express capability
[ 121.091025] r8169 0000:00:0c.0: MAC address found in EEPROM:
00:30:18:ab:f0:36
[ 121.147502] eth3: RTL8169sc/8110sc at 0xf8022000,
00:00:00:00:f0:36, XID 18000000 IRQ 16
Tim:>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] 2.6.29-rc7 broke r8169 MAC on Thecus n2100 ARM board
[not found] ` <9e246b4d0903131921k6fba9b04ge945c2902d4117d0@mail.gmail.com>
@ 2009-03-14 11:37 ` Mikael Pettersson
2009-03-15 10:09 ` Francois Romieu
0 siblings, 1 reply; 7+ messages in thread
From: Mikael Pettersson @ 2009-03-14 11:37 UTC (permalink / raw)
To: Tim Durack
Cc: Francois Romieu, Mikael Pettersson, linux-kernel, netdev, ivecera
Tim Durack writes:
> On Fri, Mar 13, 2009 at 4:15 PM, Francois Romieu <romieu@fr.zoreil.com>wrote:
>
> > Mikael Pettersson <mikpe@it.uu.se> :
> > > With the 2.6.29-rc7 kernel I'm unable to 'ifup' eth0 on my ARM-based
> > > Thecus n2100 NAS box, which has an RTL8169 NIC (10ec:8169 (rev 10)).
> > > A diff of the kernel logs from 2.6.29-rc6 and -rc7 shows that -rc7
> > > first mangles and then zaps the MAC addresses:
> >
> > Can you apply the attached patch and see if it fixes any of these
> > problems ?
> >
> > Tim, could you give it a try too ? It applies with "patch -p1" from
> > the kernel tree directory.
> >
> > --
> > Ueimor
> >
>
> No luck:
No joy here either. 2.6.29-rc8 + this patch shows the same misbehaviour
as 2.6.29-rc7 had. Here's a minicom log of an attempted boot:
(kernel messages)
r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8169 0000:00:01.0: no PCI Express capability
r8169 0000:00:01.0: MAC address found in EEPROM: 00:14:fd:10:00:00
eth0: RTL8169sb/8110sb at 0xe080c200, 00:00:00:00:00:00, XID 10000000 IRQ 27
r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8169 0000:00:02.0: no PCI Express capability
r8169 0000:00:02.0: MAC address found in EEPROM: 00:14:fd:10:00:00
eth1: RTL8169sb/8110sb at 0xe0810300, 00:00:00:00:00:00, XID 10000000 IRQ 30
(init messages)
Bringing up interface eth0: RTNETLINK answers: Cannot assign requested address
Failed to bring up eth0.
May I suggest that 6709fe9a27e43a4931938fe0d7f2cc5edef31386 is reverted
until this regression is debugged and fixed?
/Mikael
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] 2.6.29-rc7 broke r8169 MAC on Thecus n2100 ARM board
2009-03-14 11:37 ` Mikael Pettersson
@ 2009-03-15 10:09 ` Francois Romieu
2009-06-19 7:21 ` 3rd attempt to initialize MAC address on r8169 Ivan Vecera
0 siblings, 1 reply; 7+ messages in thread
From: Francois Romieu @ 2009-03-15 10:09 UTC (permalink / raw)
To: Mikael Pettersson; +Cc: Tim Durack, linux-kernel, netdev, ivecera
Mikael Pettersson <mikpe@it.uu.se> :
[...]
> May I suggest that 6709fe9a27e43a4931938fe0d7f2cc5edef31386 is reverted
> until this regression is debugged and fixed?
Yes.
--
Ueimor
^ permalink raw reply [flat|nested] 7+ messages in thread
* 3rd attempt to initialize MAC address on r8169
2009-03-15 10:09 ` Francois Romieu
@ 2009-06-19 7:21 ` Ivan Vecera
2009-06-19 11:30 ` Mikael Pettersson
0 siblings, 1 reply; 7+ messages in thread
From: Ivan Vecera @ 2009-06-19 7:21 UTC (permalink / raw)
To: Francois Romieu, Mikael Pettersson, Tim Durack; +Cc: netdev
Francois Romieu napsal(a):
> Mikael Pettersson <mikpe@it.uu.se> :
> [...]
>> May I suggest that 6709fe9a27e43a4931938fe0d7f2cc5edef31386 is reverted
>> until this regression is debugged and fixed?
>
> Yes.
>
Hello guys,
I made 3rd attempt to enable the ability to initialize r8169's MAC address
on initialization. The proposed patch below works for all my Realtek devices,
but you had some issues with the previous one. Could you please test it on your
devices? I would like to close finally this long term issue.
Thanks,
Ivan
---
drivers/net/r8169.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3b19e0c..60c8811 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -80,9 +80,9 @@ static const int multicast_filter_limit = 32;
#define RTL8169_TX_TIMEOUT (6*HZ)
#define RTL8169_PHY_TIMEOUT (10*HZ)
-#define RTL_EEPROM_SIG cpu_to_le32(0x8129)
-#define RTL_EEPROM_SIG_MASK cpu_to_le32(0xffff)
+#define RTL_EEPROM_SIG 0x8129
#define RTL_EEPROM_SIG_ADDR 0x0000
+#define RTL_EEPROM_MAC_ADDR 0x0007
/* write/read MMIO register */
#define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
@@ -292,6 +292,11 @@ enum rtl_register_content {
/* Cfg9346Bits */
Cfg9346_Lock = 0x00,
Cfg9346_Unlock = 0xc0,
+ Cfg9346_Program = 0x88, /* Programming mode */
+ Cfg9346_EECS = 0x08, /* Chip select */
+ Cfg9346_EESK = 0x04, /* Serial data clock */
+ Cfg9346_EEDI = 0x02, /* Data input */
+ Cfg9346_EEDO = 0x01, /* Data output */
/* rx_mode_bits */
AcceptErr = 0x20,
@@ -304,6 +309,7 @@ enum rtl_register_content {
/* RxConfigBits */
RxCfgFIFOShift = 13,
RxCfgDMAShift = 8,
+ RxCfg9356SEL = 6, /* EEPROM type: 0 = 9346, 1 = 9356 */
/* TxConfigBits */
TxInterFrameGapShift = 24,
@@ -1962,6 +1968,88 @@ static const struct net_device_ops rtl8169_netdev_ops = {
};
+/* delay between EEPROM clock transitions - force out buffered PCI writes. */
+#define RTL_EEPROM_DELAY() (void)RTL_R8(Cfg9346)
+#define RTL_EEPROM_READ_CMD 6
+
+/* read 16bit word stored in EEPROM. EEPROM is addressed by words. */
+static u16 rtl_eeprom_read(void __iomem *ioaddr, int addr)
+{
+ int read_cmd, addr_len, i;
+ u16 result = 0;
+
+ /* check for EEPROM address size (in bits) */
+ addr_len = (RTL_R32(RxConfig) & (1 << RxCfg9356SEL)) ? 8 : 6;
+ read_cmd = addr | (RTL_EEPROM_READ_CMD << addr_len);
+
+ /* enter programming mode */
+ RTL_W8(Cfg9346, Cfg9346_Program & ~Cfg9346_EECS);
+ RTL_W8(Cfg9346, Cfg9346_Program);
+ RTL_EEPROM_DELAY();
+
+ /* shift out read command and requested address */
+ for (i = 4 + addr_len; i >= 0; i--) {
+ int val = (read_cmd & (1 << i)) ? Cfg9346_EEDI : 0;
+ RTL_W8(Cfg9346, Cfg9346_Program | val);
+ RTL_EEPROM_DELAY();
+ RTL_W8(Cfg9346, Cfg9346_Program | val | Cfg9346_EESK);
+ RTL_EEPROM_DELAY();
+ }
+ RTL_W8(Cfg9346, Cfg9346_Program);
+ RTL_EEPROM_DELAY();
+
+ /* read back 16bit value */
+ for (i = 16; i > 0; i--) {
+ RTL_W8(Cfg9346, Cfg9346_Program | Cfg9346_EESK);
+ RTL_EEPROM_DELAY();
+
+ result <<= 1;
+ result |= (RTL_R8 (Cfg9346) & Cfg9346_EEDO) ? 1 : 0;
+
+ RTL_W8(Cfg9346, Cfg9346_Program);
+ RTL_EEPROM_DELAY();
+ }
+
+ /* leave programming mode - lock configuration */
+ RTL_W8(Cfg9346, Cfg9346_Lock);
+ RTL_EEPROM_DELAY();
+
+ return result;
+}
+
+static void rtl_init_mac_address(struct rtl8169_private *tp,
+ void __iomem *ioaddr)
+{
+ struct pci_dev *pdev = tp->pci_dev;
+ int i;
+ u16 x;
+ u8 mac[8];
+
+ /* read EEPROM signature */
+ x = rtl_eeprom_read(ioaddr, RTL_EEPROM_SIG_ADDR);
+ if (x != RTL_EEPROM_SIG) {
+ dev_info(&pdev->dev, "Missing EEPROM signature: %04x\n", x);
+ return;
+ }
+
+ /* read MAC address */
+ for (i = 0; i < 3; i++) {
+ x = rtl_eeprom_read(ioaddr, RTL_EEPROM_MAC_ADDR + i);
+ mac[i*2] = x & 0xff;
+ mac[i*2+1] = x >> 8;
+ }
+
+ if (netif_msg_probe(tp)) {
+ DECLARE_MAC_BUF(buf);
+
+ dev_info(&pdev->dev, "MAC address found in EEPROM: %s\n",
+ print_mac(buf, mac));
+ }
+
+ if (is_valid_ether_addr(mac))
+ rtl_rar_set(tp, mac);
+}
+
static int __devinit
rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
@@ -2141,6 +2229,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->mmio_addr = ioaddr;
+ rtl_init_mac_address(tp, ioaddr);
+
/* Get MAC address */
for (i = 0; i < MAC_ADDR_LEN; i++)
dev->dev_addr[i] = RTL_R8(MAC0 + i);
--
1.6.0.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: 3rd attempt to initialize MAC address on r8169
2009-06-19 7:21 ` 3rd attempt to initialize MAC address on r8169 Ivan Vecera
@ 2009-06-19 11:30 ` Mikael Pettersson
0 siblings, 0 replies; 7+ messages in thread
From: Mikael Pettersson @ 2009-06-19 11:30 UTC (permalink / raw)
To: Ivan Vecera; +Cc: Francois Romieu, Mikael Pettersson, Tim Durack, netdev
Ivan Vecera writes:
> Francois Romieu napsal(a):
> > Mikael Pettersson <mikpe@it.uu.se> :
> > [...]
> >> May I suggest that 6709fe9a27e43a4931938fe0d7f2cc5edef31386 is reverted
> >> until this regression is debugged and fixed?
> >
> > Yes.
> >
> Hello guys,
> I made 3rd attempt to enable the ability to initialize r8169's MAC address
> on initialization. The proposed patch below works for all my Realtek devices,
> but you had some issues with the previous one. Could you please test it on your
> devices? I would like to close finally this long term issue.
Sorry, this one breaks my Thecus n2100 NAS box just like before.
Here's a dmesg diff from 2.6.30 vanilla and 2.6.30 + this patch:
@@ -158,11 +158,13 @@
r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8169 0000:00:01.0: enabling Mem-Wr-Inval
r8169 0000:00:01.0: no PCI Express capability
-eth0: RTL8169sb/8110sb at 0xe0810200, 00:14:fd:30:11:78, XID 10000000 IRQ 27
+r8169 0000:00:01.0: MAC address found in EEPROM: 00:14:fd:10:00:00
+eth0: RTL8169sb/8110sb at 0xe0810200, 00:00:00:00:00:00, XID 10000000 IRQ 27
r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
r8169 0000:00:02.0: enabling Mem-Wr-Inval
r8169 0000:00:02.0: no PCI Express capability
-eth1: RTL8169sb/8110sb at 0xe0814300, 00:14:fd:30:11:79, XID 10000000 IRQ 30
+r8169 0000:00:02.0: MAC address found in EEPROM: 00:14:fd:10:00:00
+eth1: RTL8169sb/8110sb at 0xe0814300, 00:00:00:00:00:00, XID 10000000 IRQ 30
physmap platform flash device: 01000000 at f0000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
Intel/Sharp Extended Query Table at 0x0031
@@ -250,6 +246,4 @@
EXT3 FS on sda5, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
Adding 2008116k swap on /dev/sda3. Priority:-1 extents:1 across:2008116k
-r8169: eth0: link up
-r8169: eth0: link up
warning: `dbus-daemon' uses 32-bit capabilities (legacy support in use)
/Mikael
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-06-19 11:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-09 20:29 [BUG] 2.6.29-rc7 broke r8169 MAC on Thecus n2100 ARM board Mikael Pettersson
2009-03-13 20:15 ` Francois Romieu
2009-03-14 2:23 ` Tim Durack
[not found] ` <9e246b4d0903131921k6fba9b04ge945c2902d4117d0@mail.gmail.com>
2009-03-14 11:37 ` Mikael Pettersson
2009-03-15 10:09 ` Francois Romieu
2009-06-19 7:21 ` 3rd attempt to initialize MAC address on r8169 Ivan Vecera
2009-06-19 11:30 ` Mikael Pettersson
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).