NetBSD Problem Report #41258

From www@NetBSD.org  Tue Apr 21 07:48:09 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 8E72D63BC38
	for <gnats-bugs@gnats.netbsd.org>; Tue, 21 Apr 2009 07:48:09 +0000 (UTC)
Message-Id: <20090421074809.2F64F63B8A5@www.NetBSD.org>
Date: Tue, 21 Apr 2009 07:48:09 +0000 (UTC)
From: elptr@users.sourceforge.net
Reply-To: elptr@users.sourceforge.net
To: gnats-bugs@NetBSD.org
Subject: lii(4): fails to read the MAC address
X-Send-Pr-Version: www-1.0

>Number:         41258
>Category:       kern
>Synopsis:       lii(4): fails to read the MAC address
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 21 07:50:00 +0000 2009
>Closed-Date:    Sat May 21 05:14:46 +0000 2011
>Last-Modified:  Sat May 21 05:14:46 +0000 2011
>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;

>Release-Note:

>Audit-Trail:
From: Jeff Rizzo <riz@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/41258
Date: Thu, 23 Dec 2010 17:04:03 -0800

 This is a multi-part message in MIME format.
 --------------030303070002010003020405
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit

 *>Synopsis:*        lii(4): fails to read the MAC address


 Sorry this is coming so long after your initial PR, but can you confirm that
 the patch you attached to the PR both allows lii(4) to read the MAC address, but also
 makes the interface usable?  I was working with someone on IRC today who experienced
 similar problems - your patch made the MAC address read, and the interface attached,
 but the interface would not detect link up:

 lii0 at pci3 dev 0 function 0: Attansic/Atheros L2 Fast Ethernet
 lii0: Ethernet address 00:1e:8c:ac:24:08
 lii0: interrupting at ioapic0 pin 17
 ukphy0 at lii0 phy 1: OUI 0x00c82e, model 0x0002, rev. 2
 ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto

 but:

 lii0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>  mtu 1500
 	address: 00:1e:8c:ac:24:08
 	media: Ethernet autoselect (none)
 	status: no carrier
 	inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255
 	inet6 fe80::21e:8cff:feac:2408%lii0 prefixlen 64 scopeid 0x1


 ...obviously there may be a further problem, but if your patch works for you, I see no reason
 not to commit it, and continue working whatever problems remain.

 (Note that I do not actually have said hardware myself, so I can't directly test)




 --------------030303070002010003020405
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>

     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   </head>
   <body text="#000000" bgcolor="#ffffff">
     <span class="Apple-style-span" style="border-collapse: separate;
       color: rgb(0, 0, 0); font-family: Times; font-style: normal;
       font-variant: normal; font-weight: normal; letter-spacing: normal;
       line-height: normal; orphans: 2; text-indent: 0px; text-transform:
       none; white-space: normal; widows: 2; word-spacing: 0px;
       font-size: medium;">
       <pre>&gt;Synopsis:       lii(4): fails to read the MAC address


 Sorry this is coming so long after your initial PR, but can you confirm that
 the patch you attached to the PR both allows lii(4) to read the MAC address, but also
 makes the interface usable?  I was working with someone on IRC today who experienced
 similar problems - your patch made the MAC address read, and the interface attached,
 but the interface would not detect link up:

 lii0 at pci3 dev 0 function 0: Attansic/Atheros L2 Fast Ethernet
 lii0: Ethernet address 00:1e:8c:ac:24:08
 lii0: interrupting at ioapic0 pin 17
 ukphy0 at lii0 phy 1: OUI 0x00c82e, model 0x0002, rev. 2
 ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Times; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="color: rgb(24, 24, 24); font-family: monospace; font-size: 12px; line-height: 18px;"></span></span></pre>
     </span><span class="Apple-style-span" style="border-collapse:
       separate; color: rgb(0, 0, 0); font-family: Times; font-style:
       normal; font-variant: normal; font-weight: normal; letter-spacing:
       normal; line-height: normal; orphans: 2; text-indent: 0px;
       text-transform: none; white-space: normal; widows: 2;
       word-spacing: 0px; font-size: medium;">
       <pre>but:

 lii0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
 	address: 00:1e:8c:ac:24:08
 	media: Ethernet autoselect (none)
 	status: no carrier
 	inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255
 	inet6 fe80::21e:8cff:feac:2408%lii0 prefixlen 64 scopeid 0x1


 ...obviously there may be a further problem, but if your patch works for you, I see no reason
 not to commit it, and continue working whatever problems remain.

 (Note that I do not actually have said hardware myself, so I can't directly test)

 </pre>
     </span><br class="Apple-interchange-newline">
   </body>
 </html>

 --------------030303070002010003020405--

From: Dmitry Cherkassov <dcherkassov@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/41258
Date: Thu, 30 Dec 2010 21:56:23 +0300

 I have that hardware and i am ready to test if someone makes a patch.
 < dcherkassov at gmail.com >

From: Elias Benali <elptr@users.sourceforge.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/41258
Date: Mon, 18 Apr 2011 11:51:54 -0400

 I have used the patch multiple times before for my own system builds,
 and not only does it detect the MAC address it also links up and
 operates as it should.

 I have long since switched hardware configurations but I can confirm it worked.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41258 CVS commit: src/sys/dev/pci
Date: Wed, 20 Apr 2011 16:15:03 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed Apr 20 20:15:03 UTC 2011

 Modified Files:
 	src/sys/dev/pci: if_lii.c

 Log Message:
 PR/41258: Elias Benali: Try to get the ethernet address from the BIOS before
 failing.


 To generate a diff of this commit:
 cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/if_lii.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 01 May 2011 02:16:14 +0000
State-Changed-Why:
pullup-5 #1612


From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41258 CVS commit: [netbsd-5] src/sys/dev/pci
Date: Fri, 20 May 2011 19:19:57 +0000

 Module Name:	src
 Committed By:	bouyer
 Date:		Fri May 20 19:19:57 UTC 2011

 Modified Files:
 	src/sys/dev/pci [netbsd-5]: if_lii.c

 Log Message:
 Pull up following revision(s) (requested by dholland in ticket #1612):
 	sys/dev/pci/if_lii.c: revision 1.10
 PR/41258: Elias Benali: Try to get the ethernet address from the BIOS before
 failing.


 To generate a diff of this commit:
 cvs rdiff -u -r1.5 -r1.5.4.1 src/sys/dev/pci/if_lii.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 21 May 2011 05:14:46 +0000
State-Changed-Why:
Applied and pulled up to -5; thanks


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.