Subject: kern/33433: bge doesn't handle changes in linkstate correctly
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <mlelstv@serpens.de>
List: netbsd-bugs
Date: 05/07/2006 09:15:01
>Number:         33433
>Category:       kern
>Synopsis:       bge doesn't handle changes in linkstate correctly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun May 07 09:15:00 +0000 2006
>Originator:     Michael van Elst
>Release:        NetBSD 3.0_STABLE
>Organization:
-- 
                                Michael van Elst
Internet: mlelstv@serpens.de
                                "A potential Snark may lurk in every tree."
>Environment:
	
	
System: NetBSD henery 3.0_STABLE NetBSD 3.0_STABLE (HENERY) #16: Sun May 7 10:50:11 CEST 2006 src@henery:/usr/obj/home/src/sys/arch/i386/compile/HENERY i386
Architecture: i386
Machine: i386
>Description:
On a Thinkpad T43 the bge driver doesn't handle the link state correctly
when the iwi driver is running. The symptom usually is that the driver
reports "no carrier" when the ethernet is plugged in and "active" when
it is not.

Both devices work on the same interrupt. The symptom is caused by
the bge driver handling an interrupt that it didn't generate. The
code in question only checks for a flag that doesn't correlate
to the interrupt.

                if (sc->bge_rdata->bge_status_block.bge_status &
                    BGE_STATFLAG_LINKSTATE_CHANGED) {

Reading the interrupt status register instead to discriminate between
link state interrupts and other interrupts helps:

                u_int32_t               status;
                status = CSR_READ_4(sc, BGE_MAC_STS);
                if (status & BGE_MACSTAT_LINK_CHANGED) {


>How-To-Repeat:

Try to use bge0 and iwi0 in parallel on a Thinkpad T43 or probably
any other machine that shares an interrupt between bge and some
other hardware.

>Fix:

The change as outlined above works for the T43, but I don't know
how this relates to BGE_QUIRK_LINK_STATE_BROKEN. It is possible
that reading the status register also helps against the quirk.

Reading the status register on the other hand is supposed to be
slow.

>Unformatted: