From nobody@FreeBSD.org  Wed Aug  4 16:31:50 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A171C1065679
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  4 Aug 2010 16:31:50 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 902188FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  4 Aug 2010 16:31:50 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o74GVnIn078903
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 4 Aug 2010 16:31:50 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o74GVnQb078902;
	Wed, 4 Aug 2010 16:31:49 GMT
	(envelope-from nobody)
Message-Id: <201008041631.o74GVnQb078902@www.freebsd.org>
Date: Wed, 4 Aug 2010 16:31:49 GMT
From: Bogdan <exkilla@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Permanent DOWN/UP network interface ste0 on 8.1-RELEASE
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         149285
>Category:       kern
>Synopsis:       [ste] Permanent DOWN/UP network interface ste0 on 8.1-RELEASE
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 04 16:40:08 UTC 2010
>Closed-Date:    Sun Aug 15 21:59:30 UTC 2010
>Last-Modified:  Sun Aug 15 21:59:30 UTC 2010
>Originator:     Bogdan
>Release:        RELEASE 8.1
>Organization:
>Environment:
FreeBSD server 8.0-RELEASE-p4 FreeBSD 8.0-RELEASE-p4 #0: Wed Aug  4 11:57:56 EEST 2010     root@server:/usr/obj/usr/src2/src/sys/GENERIC  i386
>Description:
After update from 8.0-RELEASE to 8.1-RELEASE i see in /var/log/messages:

Aug  4 19:12:40 server kernel: ste0: link state changed to DOWN
Aug  4 19:12:41 server kernel: ste0: link state changed to UP
Aug  4 19:12:41 server kernel: ste0: link state changed to DOWN
Aug  4 19:12:42 server kernel: ste0: link state changed to UP
Aug  4 19:12:42 server kernel: ste0: link state changed to DOWN
Aug  4 19:12:42 server kernel: ste0: link state changed to UP
Aug  4 19:12:45 server kernel: ste0: link state changed to DOWN
Aug  4 19:12:46 server kernel: ste0: link state changed to UP
Aug  4 19:12:47 server kernel: ste0: link state changed to DOWN
Aug  4 19:12:48 server kernel: ste0: link state changed to UP
Aug  4 19:13:13 server kernel: ste0: link state changed to DOWN
Aug  4 19:13:14 server kernel: ste0: link state changed to UP
Aug  4 19:13:18 server kernel: ste0: link state changed to DOWN
Aug  4 19:13:19 server kernel: ste0: link state changed to UP
Aug  4 19:13:19 server kernel: ste0: link state changed to DOWN
Aug  4 19:13:19 server kernel: ste0: link state changed to UP
Aug  4 19:13:19 server kernel: ste0: link state changed to DOWN
Aug  4 19:13:19 server kernel: ste0: link state changed to UP


After return to kernel 8.0-RELEASE problem was solved.
I used Asus "NX1001 10/100Mb PCI" network card.
ste0: <Sundance ST201 10/100BaseTX> port 0xa400-0xa47f mem 0xf9008000-0xf90081ff irq 16 at device 3.0 on pci2
>How-To-Repeat:
Use Asus "NX1001 10/100Mb PCI" network card with 8.1-RELEASE kernel.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Aug 4 21:01:54 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=149285 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Wed Aug 4 23:49:17 UTC 2010 
State-Changed-Why:  
I don't think this regression was caused by ste(4) overhauling. The 
message is printed by mii(4) layer to note link state changes. I 
have no idea how this does not happen on 8.0-RELEASE though as it 
has nothing to do with ste(4). But after ste(4) overhauling, ste(4) 
now correctly keeps track of current reported link state such that it 
wouldn't try to send packets if it know link is in DOWN state. 

Would you show me the output of "devinfo -rv | grep phy" both 
8.1-RELEASE and 8.0-RELEASE? 


Responsible-Changed-From-To: freebsd-net->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Wed Aug 4 23:49:17 UTC 2010 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=149285 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/149285: commit references a PR
Date: Mon,  9 Aug 2010 01:47:22 +0000 (UTC)

 Author: yongari
 Date: Mon Aug  9 01:47:09 2010
 New Revision: 211089
 URL: http://svn.freebsd.org/changeset/base/211089
 
 Log:
   It seems some old Sundace(now IC Plus Corp.) controllers do not
   like memory mapped register access. Typical problem from the issue
   was MII access returned unreliable values. I'm not sure this comes
   from lack of register flushing in MII access after accessing
   STE_PHYCTL register though.
   To address the issue, read hints data that controls which type of
   memory mapping should be used in driver. ste(4) still prefers
   memory mapping to io mapping but honor hints entered by user except
   for controllers that have problems with memory mapping.
   The hint to use iomapping could be given by adding the following
   line to /boot/device.hints file.
   
   hint.ste.0.prefer_iomap="1"
   
   PR:	kern/149285
   MFC after:	5 days
 
 Modified:
   head/sys/dev/ste/if_ste.c
 
 Modified: head/sys/dev/ste/if_ste.c
 ==============================================================================
 --- head/sys/dev/ste/if_ste.c	Mon Aug  9 00:36:22 2010	(r211088)
 +++ head/sys/dev/ste/if_ste.c	Mon Aug  9 01:47:09 2010	(r211089)
 @@ -1059,7 +1059,7 @@ ste_attach(device_t dev)
  	struct ste_softc *sc;
  	struct ifnet *ifp;
  	uint16_t eaddr[ETHER_ADDR_LEN / 2];
 -	int error = 0, pmc, rid;
 +	int error = 0, pmc, prefer_iomap, rid;
  
  	sc = device_get_softc(dev);
  	sc->ste_dev = dev;
 @@ -1081,12 +1081,25 @@ ste_attach(device_t dev)
  	 */
  	pci_enable_busmaster(dev);
  
 -	/* Prefer memory space register mapping over IO space. */
 -	sc->ste_res_id = PCIR_BAR(1);
 -	sc->ste_res_type = SYS_RES_MEMORY;
 -	sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 -	    &sc->ste_res_id, RF_ACTIVE);
 -	if (sc->ste_res == NULL) {
 +	/*
 +	 * Prefer memory space register mapping over IO space but use
 +	 * IO space for a device that is known to have issues on memory
 +	 * mapping.
 +	 */
 +	prefer_iomap = 0;
 +	if (pci_get_device(dev) == ST_DEVICEID_ST201_1)
 +		prefer_iomap = 1;
 +	else
 +		resource_int_value(device_get_name(sc->ste_dev),
 +		    device_get_unit(sc->ste_dev), "prefer_iomap",
 +		    &prefer_iomap);
 +	if (prefer_iomap == 0) {
 +		sc->ste_res_id = PCIR_BAR(1);
 +		sc->ste_res_type = SYS_RES_MEMORY;
 +		sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 +		    &sc->ste_res_id, RF_ACTIVE);
 +	}
 +	if (prefer_iomap || sc->ste_res == NULL) {
  		sc->ste_res_id = PCIR_BAR(0);
  		sc->ste_res_type = SYS_RES_IOPORT;
  		sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: feedback->patched 
State-Changed-By: yongari 
State-Changed-When: Mon Aug 9 16:36:37 UTC 2010 
State-Changed-Why:  
Patch committed to HEAD. Thanks for testing and reporting. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=149285 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/149285: commit references a PR
Date: Sun, 15 Aug 2010 21:44:06 +0000 (UTC)

 Author: yongari
 Date: Sun Aug 15 21:43:51 2010
 New Revision: 211357
 URL: http://svn.freebsd.org/changeset/base/211357
 
 Log:
   MFC r211089:
     It seems some old Sundace(now IC Plus Corp.) controllers do not
     like memory mapped register access. Typical problem from the issue
     was MII access returned unreliable values. I'm not sure this comes
     from lack of register flushing in MII access after accessing
     STE_PHYCTL register though.
     To address the issue, read hints data that controls which type of
     memory mapping should be used in driver. ste(4) still prefers
     memory mapping to io mapping but honor hints entered by user except
     for controllers that have problems with memory mapping.
     The hint to use iomapping could be given by adding the following
     line to /boot/device.hints file.
   
     hint.ste.0.prefer_iomap="1"
   
     PR:	kern/149285
 
 Modified:
   stable/8/sys/dev/ste/if_ste.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cam/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/e1000/   (props changed)
   stable/8/sys/dev/xen/xenpci/   (props changed)
 
 Modified: stable/8/sys/dev/ste/if_ste.c
 ==============================================================================
 --- stable/8/sys/dev/ste/if_ste.c	Sun Aug 15 21:37:30 2010	(r211356)
 +++ stable/8/sys/dev/ste/if_ste.c	Sun Aug 15 21:43:51 2010	(r211357)
 @@ -1059,7 +1059,7 @@ ste_attach(device_t dev)
  	struct ste_softc *sc;
  	struct ifnet *ifp;
  	uint16_t eaddr[ETHER_ADDR_LEN / 2];
 -	int error = 0, pmc, rid;
 +	int error = 0, pmc, prefer_iomap, rid;
  
  	sc = device_get_softc(dev);
  	sc->ste_dev = dev;
 @@ -1081,12 +1081,25 @@ ste_attach(device_t dev)
  	 */
  	pci_enable_busmaster(dev);
  
 -	/* Prefer memory space register mapping over IO space. */
 -	sc->ste_res_id = PCIR_BAR(1);
 -	sc->ste_res_type = SYS_RES_MEMORY;
 -	sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 -	    &sc->ste_res_id, RF_ACTIVE);
 -	if (sc->ste_res == NULL) {
 +	/*
 +	 * Prefer memory space register mapping over IO space but use
 +	 * IO space for a device that is known to have issues on memory
 +	 * mapping.
 +	 */
 +	prefer_iomap = 0;
 +	if (pci_get_device(dev) == ST_DEVICEID_ST201_1)
 +		prefer_iomap = 1;
 +	else
 +		resource_int_value(device_get_name(sc->ste_dev),
 +		    device_get_unit(sc->ste_dev), "prefer_iomap",
 +		    &prefer_iomap);
 +	if (prefer_iomap == 0) {
 +		sc->ste_res_id = PCIR_BAR(1);
 +		sc->ste_res_type = SYS_RES_MEMORY;
 +		sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 +		    &sc->ste_res_id, RF_ACTIVE);
 +	}
 +	if (prefer_iomap || sc->ste_res == NULL) {
  		sc->ste_res_id = PCIR_BAR(0);
  		sc->ste_res_type = SYS_RES_IOPORT;
  		sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/149285: commit references a PR
Date: Sun, 15 Aug 2010 21:46:32 +0000 (UTC)

 Author: yongari
 Date: Sun Aug 15 21:46:23 2010
 New Revision: 211358
 URL: http://svn.freebsd.org/changeset/base/211358
 
 Log:
   MFC r211089:
     It seems some old Sundace(now IC Plus Corp.) controllers do not
     like memory mapped register access. Typical problem from the issue
     was MII access returned unreliable values. I'm not sure this comes
     from lack of register flushing in MII access after accessing
     STE_PHYCTL register though.
     To address the issue, read hints data that controls which type of
     memory mapping should be used in driver. ste(4) still prefers
     memory mapping to io mapping but honor hints entered by user except
     for controllers that have problems with memory mapping.
     The hint to use iomapping could be given by adding the following
     line to /boot/device.hints file.
   
     hint.ste.0.prefer_iomap="1"
   
     PR:	kern/149285
 
 Modified:
   stable/7/sys/dev/ste/if_ste.c
 Directory Properties:
   stable/7/sys/   (props changed)
   stable/7/sys/cddl/contrib/opensolaris/   (props changed)
   stable/7/sys/contrib/dev/acpica/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
 
 Modified: stable/7/sys/dev/ste/if_ste.c
 ==============================================================================
 --- stable/7/sys/dev/ste/if_ste.c	Sun Aug 15 21:43:51 2010	(r211357)
 +++ stable/7/sys/dev/ste/if_ste.c	Sun Aug 15 21:46:23 2010	(r211358)
 @@ -1053,7 +1053,7 @@ ste_attach(device_t dev)
  	struct ste_softc *sc;
  	struct ifnet *ifp;
  	uint16_t eaddr[ETHER_ADDR_LEN / 2];
 -	int error = 0, pmc, rid;
 +	int error = 0, pmc, prefer_iomap, rid;
  
  	sc = device_get_softc(dev);
  	sc->ste_dev = dev;
 @@ -1075,12 +1075,25 @@ ste_attach(device_t dev)
  	 */
  	pci_enable_busmaster(dev);
  
 -	/* Prefer memory space register mapping over IO space. */
 -	sc->ste_res_id = PCIR_BAR(1);
 -	sc->ste_res_type = SYS_RES_MEMORY;
 -	sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 -	    &sc->ste_res_id, RF_ACTIVE);
 -	if (sc->ste_res == NULL) {
 +	/*
 +	 * Prefer memory space register mapping over IO space but use
 +	 * IO space for a device that is known to have issues on memory
 +	 * mapping.
 +	 */
 +	prefer_iomap = 0;
 +	if (pci_get_device(dev) == ST_DEVICEID_ST201_1)
 +		prefer_iomap = 1;
 +	else
 +		resource_int_value(device_get_name(sc->ste_dev),
 +		    device_get_unit(sc->ste_dev), "prefer_iomap",
 +		    &prefer_iomap);
 +	if (prefer_iomap == 0) {
 +		sc->ste_res_id = PCIR_BAR(1);
 +		sc->ste_res_type = SYS_RES_MEMORY;
 +		sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 +		    &sc->ste_res_id, RF_ACTIVE);
 +	}
 +	if (prefer_iomap || sc->ste_res == NULL) {
  		sc->ste_res_id = PCIR_BAR(0);
  		sc->ste_res_type = SYS_RES_IOPORT;
  		sc->ste_res = bus_alloc_resource_any(dev, sc->ste_res_type,
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: yongari 
State-Changed-When: Sun Aug 15 21:58:53 UTC 2010 
State-Changed-Why:  
MFC to stable/8 and stable/7 done. 
Thanks a lot for testing and reporting! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=149285 
>Unformatted:
