NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/41258: lii(4): fails to read the MAC address



>Number:         41258
>Category:       kern
>Synopsis:       lii(4): fails to read the MAC address
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 21 07:50:00 +0000 2009
>Originator:     Elias Benali
>Release:        NetBSD5.0_RC4
>Organization:
N/A
>Environment:
NetBSD  5.99.01 NetBSD 5.99.01 (CUSTOM) #10: Sat Nov  1 00:52:42 EDT 2008  
root@localhost:/usr/obj/sys/arch/i386/compile/CUSTOM i386

PS. This isn't the release kernel, it's an already-patched one.
>Description:
A failure to read the MAC address fatally interrupts the driver initialization 
and subsequently the hardware can't be used.

The code attempts to read the MAC addr from EEPROM memory, and failing that it 
simply quits.

The proposed patch attempts the 'BIOS method' (as the Linux driver calls it) by 
reading the appropriate registers, and if that fails it proceeds as before.
>How-To-Repeat:
Boot with the same hardware, mine was integrated, and watch the driver fail.
>Fix:
Index: if_lii.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_lii.c,v
retrieving revision 1.5
diff -u -p -r1.5 if_lii.c
--- if_lii.c    8 Jul 2008 12:39:27 -0000       1.5
+++ if_lii.c    11 Mar 2009 11:52:01 -0000
@@ -547,17 +547,17 @@ lii_read_macaddr(struct lii_softc *sc, u
        }
 
        if (found < 2) {
-               aprint_error_dev(sc->sc_dev, "error reading MAC address\n");
-               return 1;
-       }
-
-       addr0 = htole32(addr0);
-       addr1 = htole32(addr1);
-
-       if ((addr0 == 0xffffff && (addr1 & 0xffff) == 0xffff) ||
-           (addr0 == 0 && (addr1 & 0xffff) == 0)) {
+               /* Make sure we try the BIOS method before giving up */
                addr0 = htole32(AT_READ_4(sc, ATL2_MAC_ADDR_0));
                addr1 = htole32(AT_READ_4(sc, ATL2_MAC_ADDR_1));
+               if ((addr0 == 0xffffff && (addr1 & 0xffff) == 0xffff) ||
+                   (addr0 == 0 && (addr1 & 0xffff) == 0)) {
+                       aprint_error_dev(sc->sc_dev, "error reading MAC 
address\n");
+                       return 1;
+               }
+       } else {
+               addr0 = htole32(addr0);
+               addr1 = htole32(addr1);
        }
 
        ea[0] = (addr1 & 0x0000ff00) >> 8;



Home | Main Index | Thread Index | Old Index