From nobody@FreeBSD.org  Mon Jul  8 14:13:18 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id DB0E7672
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Jul 2013 14:13:18 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	by mx1.freebsd.org (Postfix) with ESMTP id BCC551330
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Jul 2013 14:13:18 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r68EDILx075534
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 8 Jul 2013 14:13:18 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r68EDI5Z075533;
	Mon, 8 Jul 2013 14:13:18 GMT
	(envelope-from nobody)
Message-Id: <201307081413.r68EDI5Z075533@oldred.freebsd.org>
Date: Mon, 8 Jul 2013 14:13:18 GMT
From: Claudiu Vasadi <claudiu.vasadi@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: kernel: ae0: watchdog timeout - resetting.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         180382
>Category:       kern
>Synopsis:       [ae] kernel: ae0: watchdog timeout - resetting.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 08 14:20:06 UTC 2013
>Closed-Date:    Fri Jul 26 06:39:00 UTC 2013
>Last-Modified:  Fri Jul 26 06:39:00 UTC 2013
>Originator:     Claudiu Vasadi
>Release:        9.1-STABLE
>Organization:
>Environment:
FreeBSD xxxxxxxxxx 9.1-STABLE FreeBSD 9.1-STABLE #0 r251065: Wed May 29 00:18:42 UTC 2013     root@xxxxxxxxxx:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
The machine is an Intel(R) Pentium(R) Dual  CPU  E2180  @ 2.00GHz, 2GB RAM, Asus P5LD2-X/1333, running as a backup machine.

The NIC (ae0) will eventually spit out the messages below and will stop any network traffic to or from it.


Jul  1 13:21:31 backup2 kernel: ae0: Size mismatch: TxS:98 TxD:24753
Jul  1 13:21:31 backup2 kernel: ae0: Received stray Tx interrupt(s).
Jul  1 13:21:31 backup2 kernel: ae0: Size mismatch: TxS:83 TxD:45903
Jul  1 13:21:31 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:53581
Jul  1 13:21:31 backup2 kernel: ae0: Size mismatch: TxS:78 TxD:13106
Jul  1 13:21:31 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:2568
Jul  1 13:21:31 backup2 kernel: ae0: Size mismatch: TxS:77 TxD:45463
Jul  1 13:21:32 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:46493
Jul  1 13:21:32 backup2 kernel: ae0: Size mismatch: TxS:84 TxD:38076
Jul  1 13:21:34 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:4100
Jul  1 13:21:34 backup2 kernel: ae0: Size mismatch: TxS:83 TxD:58458
Jul  1 13:21:34 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:183
Jul  1 13:21:34 backup2 kernel: ae0: Size mismatch: TxS:77 TxD:44993
Jul  1 13:21:35 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:23698
Jul  1 13:21:35 backup2 kernel: ae0: Size mismatch: TxS:76 TxD:21779
Jul  1 13:21:36 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:7389
Jul  1 13:21:36 backup2 kernel: ae0: Size mismatch: TxS:82 TxD:42380
Jul  1 13:21:37 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:42072
Jul  1 13:21:37 backup2 kernel: ae0: Size mismatch: TxS:81 TxD:63286
Jul  1 13:21:39 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:43501
Jul  1 13:21:39 backup2 kernel: ae0: Size mismatch: TxS:92 TxD:8475
Jul  1 13:21:39 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:0
Jul  1 13:21:39 backup2 kernel: ae0: Size mismatch: TxS:91 TxD:2568
Jul  1 13:21:41 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:600
Jul  1 13:21:41 backup2 kernel: ae0: Size mismatch: TxS:84 TxD:4100
Jul  1 13:21:42 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:14390
Jul  1 13:21:42 backup2 kernel: ae0: Size mismatch: TxS:83 TxD:24480
Jul  1 13:21:42 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:42380
Jul  1 13:21:42 backup2 kernel: ae0: Size mismatch: TxS:81 TxD:3720
Jul  1 13:21:43 backup2 kernel: ae0: Size mismatch: TxS:66 TxD:27749
Jul  1 13:21:43 backup2 kernel: ae0: Size mismatch: TxS:80 TxD:256
Jul  1 13:21:46 backup2 kernel: ae0: Size mismatch: TxS:73 TxD:46493
Jul  1 13:21:50 backup2 kernel: ae0: watchdog timeout - resetting.

The only solution is to "ifconfig ae0 down && ifconfig ae0 up".

The problem will normally happen in maximum 24 hours and I have seen no relation to network or CPU load (a.k.a the box can be idle or at full load but this does not influence when the error occurs).

I think this is related to http://www.freebsd.org/cgi/query-pr.cgi?pr=145918&cat=
>How-To-Repeat:
Siply wait for upto 24 hours and the error messages will appear.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Jul 9 04:37:27 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180382 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Tue Jul 9 11:21:13 UTC 2013 
State-Changed-Why:  
Would you try patch at the following URL? 
http://freefall.freebsd.org/~yongari/ae.diff 


Responsible-Changed-From-To: freebsd-net->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Tue Jul 9 11:21:13 UTC 2013 
Responsible-Changed-Why:  
Grab. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/180382: commit references a PR
Date: Wed, 17 Jul 2013 01:24:31 +0000 (UTC)

 Author: yongari
 Date: Wed Jul 17 01:24:23 2013
 New Revision: 253404
 URL: http://svnweb.freebsd.org/changeset/base/253404
 
 Log:
    o TxD ring requires 8 bytes alignment to work so change alignment
      constraint to 8. Previously it may have triggered watchdog
      timeouts.
    o Check whether interrupt is ours or not.
    o Enable interrupts before attemping to transmit queued packets.
      This will slightly improve TX performance.
    o No need to clear IFF_DRV_OACTIVE in a loop. AE_FLAG_TXAVAIL is
      used to know whether there are enough available TxD ring space.
    o Added missing bus_dmamap_sync(9) in ae_rx_intr() and rearranged
      code to avoid unncessary register access.
    o Make sure to clear TxD, TxS, RxD rings in driver initialization.
      Otherwise some data in these rings could be interpreted as
      'updated' which in turn will advance internally maintained
      pointers and can trigger watchdog timeouts.
   
   PR:	kern/180382
 
 Modified:
   head/sys/dev/ae/if_ae.c
 
 Modified: head/sys/dev/ae/if_ae.c
 ==============================================================================
 --- head/sys/dev/ae/if_ae.c	Wed Jul 17 00:58:23 2013	(r253403)
 +++ head/sys/dev/ae/if_ae.c	Wed Jul 17 01:24:23 2013	(r253404)
 @@ -585,6 +585,9 @@ ae_init_locked(ae_softc_t *sc)
  	val = eaddr[0] << 8 | eaddr[1];
  	AE_WRITE_4(sc, AE_EADDR1_REG, val);
  
 +	bzero(sc->rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + 120);
 +	bzero(sc->txd_base, AE_TXD_BUFSIZE_DEFAULT);
 +	bzero(sc->txs_base, AE_TXS_COUNT_DEFAULT * 4);
  	/*
  	 * Set ring buffers base addresses.
  	 */
 @@ -1115,7 +1118,7 @@ ae_alloc_rings(ae_softc_t *sc)
  	 * Create DMA tag for TxD.
  	 */
  	error = bus_dma_tag_create(sc->dma_parent_tag,
 -	    4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
 +	    8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
  	    NULL, NULL, AE_TXD_BUFSIZE_DEFAULT, 1,
  	    AE_TXD_BUFSIZE_DEFAULT, 0, NULL, NULL,
  	    &sc->dma_txd_tag);
 @@ -1128,7 +1131,7 @@ ae_alloc_rings(ae_softc_t *sc)
  	 * Create DMA tag for TxS.
  	 */
  	error = bus_dma_tag_create(sc->dma_parent_tag,
 -	    4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
 +	    8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
  	    NULL, NULL, AE_TXS_COUNT_DEFAULT * 4, 1,
  	    AE_TXS_COUNT_DEFAULT * 4, 0, NULL, NULL,
  	    &sc->dma_txs_tag);
 @@ -1761,6 +1764,10 @@ ae_int_task(void *arg, int pending)
  	ifp = sc->ifp;
  
  	val = AE_READ_4(sc, AE_ISR_REG);	/* Read interrupt status. */
 +	if (val == 0) {
 +		AE_UNLOCK(sc);
 +		return;
 +	}
  
  	/*
  	 * Clear interrupts and disable them.
 @@ -1783,12 +1790,16 @@ ae_int_task(void *arg, int pending)
  			ae_tx_intr(sc);
  		if ((val & AE_ISR_RX_EVENT) != 0)
  			ae_rx_intr(sc);
 -	}
 +		/*
 +		 * Re-enable interrupts.
 +		 */
 +		AE_WRITE_4(sc, AE_ISR_REG, 0);
  
 -	/*
 -	 * Re-enable interrupts.
 -	 */
 -	AE_WRITE_4(sc, AE_ISR_REG, 0);
 +		if ((sc->flags & AE_FLAG_TXAVAIL) != 0) {
 +			if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 +				ae_start_locked(ifp);
 +		}
 +	}
  
  	AE_UNLOCK(sc);
  }
 @@ -1849,10 +1860,10 @@ ae_tx_intr(ae_softc_t *sc)
  			ifp->if_oerrors++;
  
  		sc->tx_inproc--;
 -
 -		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  	}
  
 +	if ((sc->flags & AE_FLAG_TXAVAIL) != 0)
 +		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  	if (sc->tx_inproc < 0) {
  		if_printf(ifp, "Received stray Tx interrupt(s).\n");
  		sc->tx_inproc = 0;
 @@ -1860,11 +1871,6 @@ ae_tx_intr(ae_softc_t *sc)
  
  	if (sc->tx_inproc == 0)
  		sc->wd_timer = 0;	/* Unarm watchdog. */
 -	
 -	if ((sc->flags & AE_FLAG_TXAVAIL) != 0) {
 -		if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 -			ae_start_locked(ifp);
 -	}
  
  	/*
  	 * Syncronize DMA buffers.
 @@ -1923,7 +1929,7 @@ ae_rx_intr(ae_softc_t *sc)
  	ae_rxd_t *rxd;
  	struct ifnet *ifp;
  	uint16_t flags;
 -	int error;
 +	int count, error;
  
  	KASSERT(sc != NULL, ("[ae, %d]: sc is NULL!", __LINE__));
  
 @@ -1937,7 +1943,7 @@ ae_rx_intr(ae_softc_t *sc)
  	bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
  	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
  
 -	for (;;) {
 +	for (count = 0;; count++) {
  		rxd = (ae_rxd_t *)(sc->rxd_base + sc->rxd_cur);
  		flags = le16toh(rxd->flags);
  		if ((flags & AE_RXD_UPDATE) == 0)
 @@ -1964,10 +1970,14 @@ ae_rx_intr(ae_softc_t *sc)
  		}
  	}
  
 -	/*
 -	 * Update Rx index.
 -	 */
 -	AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur);
 +	if (count > 0) {
 +		bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
 +		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 +		/*
 +		 * Update Rx index.
 +		 */
 +		AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur);
 +	}
  }
  
  static void
 _______________________________________________
 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: Wed Jul 17 02:24:27 UTC 2013 
State-Changed-Why:  
Fixed in r253404. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/180382: commit references a PR
Date: Fri, 26 Jul 2013 06:24:10 +0000 (UTC)

 Author: yongari
 Date: Fri Jul 26 06:23:57 2013
 New Revision: 253664
 URL: http://svnweb.freebsd.org/changeset/base/253664
 
 Log:
   MFC r253404:
      o TxD ring requires 8 bytes alignment to work so change alignment
        constraint to 8. Previously it may have triggered watchdog
        timeouts.
      o Check whether interrupt is ours or not.
      o Enable interrupts before attemping to transmit queued packets.
        This will slightly improve TX performance.
      o No need to clear IFF_DRV_OACTIVE in a loop. AE_FLAG_TXAVAIL is
        used to know whether there are enough available TxD ring space.
      o Added missing bus_dmamap_sync(9) in ae_rx_intr() and rearranged
        code to avoid unncessary register access.
      o Make sure to clear TxD, TxS, RxD rings in driver initialization.
        Otherwise some data in these rings could be interpreted as
        'updated' which in turn will advance internally maintained
        pointers and can trigger watchdog timeouts.
   
     PR:	kern/180382
 
 Modified:
   stable/8/sys/dev/ae/if_ae.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/dev/   (props changed)
   stable/8/sys/dev/ae/   (props changed)
 
 Modified: stable/8/sys/dev/ae/if_ae.c
 ==============================================================================
 --- stable/8/sys/dev/ae/if_ae.c	Fri Jul 26 06:23:06 2013	(r253663)
 +++ stable/8/sys/dev/ae/if_ae.c	Fri Jul 26 06:23:57 2013	(r253664)
 @@ -586,6 +586,9 @@ ae_init_locked(ae_softc_t *sc)
  	val = eaddr[0] << 8 | eaddr[1];
  	AE_WRITE_4(sc, AE_EADDR1_REG, val);
  
 +	bzero(sc->rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + 120);
 +	bzero(sc->txd_base, AE_TXD_BUFSIZE_DEFAULT);
 +	bzero(sc->txs_base, AE_TXS_COUNT_DEFAULT * 4);
  	/*
  	 * Set ring buffers base addresses.
  	 */
 @@ -1116,7 +1119,7 @@ ae_alloc_rings(ae_softc_t *sc)
  	 * Create DMA tag for TxD.
  	 */
  	error = bus_dma_tag_create(sc->dma_parent_tag,
 -	    4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
 +	    8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
  	    NULL, NULL, AE_TXD_BUFSIZE_DEFAULT, 1,
  	    AE_TXD_BUFSIZE_DEFAULT, 0, NULL, NULL,
  	    &sc->dma_txd_tag);
 @@ -1129,7 +1132,7 @@ ae_alloc_rings(ae_softc_t *sc)
  	 * Create DMA tag for TxS.
  	 */
  	error = bus_dma_tag_create(sc->dma_parent_tag,
 -	    4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
 +	    8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
  	    NULL, NULL, AE_TXS_COUNT_DEFAULT * 4, 1,
  	    AE_TXS_COUNT_DEFAULT * 4, 0, NULL, NULL,
  	    &sc->dma_txs_tag);
 @@ -1762,6 +1765,10 @@ ae_int_task(void *arg, int pending)
  	ifp = sc->ifp;
  
  	val = AE_READ_4(sc, AE_ISR_REG);	/* Read interrupt status. */
 +	if (val == 0) {
 +		AE_UNLOCK(sc);
 +		return;
 +	}
  
  	/*
  	 * Clear interrupts and disable them.
 @@ -1784,12 +1791,16 @@ ae_int_task(void *arg, int pending)
  			ae_tx_intr(sc);
  		if ((val & AE_ISR_RX_EVENT) != 0)
  			ae_rx_intr(sc);
 -	}
 +		/*
 +		 * Re-enable interrupts.
 +		 */
 +		AE_WRITE_4(sc, AE_ISR_REG, 0);
  
 -	/*
 -	 * Re-enable interrupts.
 -	 */
 -	AE_WRITE_4(sc, AE_ISR_REG, 0);
 +		if ((sc->flags & AE_FLAG_TXAVAIL) != 0) {
 +			if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 +				ae_start_locked(ifp);
 +		}
 +	}
  
  	AE_UNLOCK(sc);
  }
 @@ -1850,10 +1861,10 @@ ae_tx_intr(ae_softc_t *sc)
  			ifp->if_oerrors++;
  
  		sc->tx_inproc--;
 -
 -		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  	}
  
 +	if ((sc->flags & AE_FLAG_TXAVAIL) != 0)
 +		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  	if (sc->tx_inproc < 0) {
  		if_printf(ifp, "Received stray Tx interrupt(s).\n");
  		sc->tx_inproc = 0;
 @@ -1861,11 +1872,6 @@ ae_tx_intr(ae_softc_t *sc)
  
  	if (sc->tx_inproc == 0)
  		sc->wd_timer = 0;	/* Unarm watchdog. */
 -	
 -	if ((sc->flags & AE_FLAG_TXAVAIL) != 0) {
 -		if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 -			ae_start_locked(ifp);
 -	}
  
  	/*
  	 * Syncronize DMA buffers.
 @@ -1924,7 +1930,7 @@ ae_rx_intr(ae_softc_t *sc)
  	ae_rxd_t *rxd;
  	struct ifnet *ifp;
  	uint16_t flags;
 -	int error;
 +	int count, error;
  
  	KASSERT(sc != NULL, ("[ae, %d]: sc is NULL!", __LINE__));
  
 @@ -1938,7 +1944,7 @@ ae_rx_intr(ae_softc_t *sc)
  	bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
  	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
  
 -	for (;;) {
 +	for (count = 0;; count++) {
  		rxd = (ae_rxd_t *)(sc->rxd_base + sc->rxd_cur);
  		flags = le16toh(rxd->flags);
  		if ((flags & AE_RXD_UPDATE) == 0)
 @@ -1965,10 +1971,14 @@ ae_rx_intr(ae_softc_t *sc)
  		}
  	}
  
 -	/*
 -	 * Update Rx index.
 -	 */
 -	AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur);
 +	if (count > 0) {
 +		bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
 +		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 +		/*
 +		 * Update Rx index.
 +		 */
 +		AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur);
 +	}
  }
  
  static void
 _______________________________________________
 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/180382: commit references a PR
Date: Fri, 26 Jul 2013 06:23:19 +0000 (UTC)

 Author: yongari
 Date: Fri Jul 26 06:23:06 2013
 New Revision: 253663
 URL: http://svnweb.freebsd.org/changeset/base/253663
 
 Log:
   MFC r253404:
      o TxD ring requires 8 bytes alignment to work so change alignment
        constraint to 8. Previously it may have triggered watchdog
        timeouts.
      o Check whether interrupt is ours or not.
      o Enable interrupts before attemping to transmit queued packets.
        This will slightly improve TX performance.
      o No need to clear IFF_DRV_OACTIVE in a loop. AE_FLAG_TXAVAIL is
        used to know whether there are enough available TxD ring space.
      o Added missing bus_dmamap_sync(9) in ae_rx_intr() and rearranged
        code to avoid unncessary register access.
      o Make sure to clear TxD, TxS, RxD rings in driver initialization.
        Otherwise some data in these rings could be interpreted as
        'updated' which in turn will advance internally maintained
        pointers and can trigger watchdog timeouts.
   
     PR:	kern/180382
     Approved by:	re (hrs)
 
 Modified:
   stable/9/sys/dev/ae/if_ae.c
 Directory Properties:
   stable/9/sys/   (props changed)
   stable/9/sys/dev/   (props changed)
 
 Modified: stable/9/sys/dev/ae/if_ae.c
 ==============================================================================
 --- stable/9/sys/dev/ae/if_ae.c	Fri Jul 26 02:00:06 2013	(r253662)
 +++ stable/9/sys/dev/ae/if_ae.c	Fri Jul 26 06:23:06 2013	(r253663)
 @@ -585,6 +585,9 @@ ae_init_locked(ae_softc_t *sc)
  	val = eaddr[0] << 8 | eaddr[1];
  	AE_WRITE_4(sc, AE_EADDR1_REG, val);
  
 +	bzero(sc->rxd_base_dma, AE_RXD_COUNT_DEFAULT * 1536 + 120);
 +	bzero(sc->txd_base, AE_TXD_BUFSIZE_DEFAULT);
 +	bzero(sc->txs_base, AE_TXS_COUNT_DEFAULT * 4);
  	/*
  	 * Set ring buffers base addresses.
  	 */
 @@ -1115,7 +1118,7 @@ ae_alloc_rings(ae_softc_t *sc)
  	 * Create DMA tag for TxD.
  	 */
  	error = bus_dma_tag_create(sc->dma_parent_tag,
 -	    4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
 +	    8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
  	    NULL, NULL, AE_TXD_BUFSIZE_DEFAULT, 1,
  	    AE_TXD_BUFSIZE_DEFAULT, 0, NULL, NULL,
  	    &sc->dma_txd_tag);
 @@ -1128,7 +1131,7 @@ ae_alloc_rings(ae_softc_t *sc)
  	 * Create DMA tag for TxS.
  	 */
  	error = bus_dma_tag_create(sc->dma_parent_tag,
 -	    4, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
 +	    8, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
  	    NULL, NULL, AE_TXS_COUNT_DEFAULT * 4, 1,
  	    AE_TXS_COUNT_DEFAULT * 4, 0, NULL, NULL,
  	    &sc->dma_txs_tag);
 @@ -1761,6 +1764,10 @@ ae_int_task(void *arg, int pending)
  	ifp = sc->ifp;
  
  	val = AE_READ_4(sc, AE_ISR_REG);	/* Read interrupt status. */
 +	if (val == 0) {
 +		AE_UNLOCK(sc);
 +		return;
 +	}
  
  	/*
  	 * Clear interrupts and disable them.
 @@ -1783,12 +1790,16 @@ ae_int_task(void *arg, int pending)
  			ae_tx_intr(sc);
  		if ((val & AE_ISR_RX_EVENT) != 0)
  			ae_rx_intr(sc);
 -	}
 +		/*
 +		 * Re-enable interrupts.
 +		 */
 +		AE_WRITE_4(sc, AE_ISR_REG, 0);
  
 -	/*
 -	 * Re-enable interrupts.
 -	 */
 -	AE_WRITE_4(sc, AE_ISR_REG, 0);
 +		if ((sc->flags & AE_FLAG_TXAVAIL) != 0) {
 +			if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 +				ae_start_locked(ifp);
 +		}
 +	}
  
  	AE_UNLOCK(sc);
  }
 @@ -1849,10 +1860,10 @@ ae_tx_intr(ae_softc_t *sc)
  			ifp->if_oerrors++;
  
  		sc->tx_inproc--;
 -
 -		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  	}
  
 +	if ((sc->flags & AE_FLAG_TXAVAIL) != 0)
 +		ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
  	if (sc->tx_inproc < 0) {
  		if_printf(ifp, "Received stray Tx interrupt(s).\n");
  		sc->tx_inproc = 0;
 @@ -1860,11 +1871,6 @@ ae_tx_intr(ae_softc_t *sc)
  
  	if (sc->tx_inproc == 0)
  		sc->wd_timer = 0;	/* Unarm watchdog. */
 -	
 -	if ((sc->flags & AE_FLAG_TXAVAIL) != 0) {
 -		if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
 -			ae_start_locked(ifp);
 -	}
  
  	/*
  	 * Syncronize DMA buffers.
 @@ -1923,7 +1929,7 @@ ae_rx_intr(ae_softc_t *sc)
  	ae_rxd_t *rxd;
  	struct ifnet *ifp;
  	uint16_t flags;
 -	int error;
 +	int count, error;
  
  	KASSERT(sc != NULL, ("[ae, %d]: sc is NULL!", __LINE__));
  
 @@ -1937,7 +1943,7 @@ ae_rx_intr(ae_softc_t *sc)
  	bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
  	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
  
 -	for (;;) {
 +	for (count = 0;; count++) {
  		rxd = (ae_rxd_t *)(sc->rxd_base + sc->rxd_cur);
  		flags = le16toh(rxd->flags);
  		if ((flags & AE_RXD_UPDATE) == 0)
 @@ -1964,10 +1970,14 @@ ae_rx_intr(ae_softc_t *sc)
  		}
  	}
  
 -	/*
 -	 * Update Rx index.
 -	 */
 -	AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur);
 +	if (count > 0) {
 +		bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
 +		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 +		/*
 +		 * Update Rx index.
 +		 */
 +		AE_WRITE_2(sc, AE_MB_RXD_IDX_REG, sc->rxd_cur);
 +	}
  }
  
  static void
 _______________________________________________
 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: Fri Jul 26 06:38:11 UTC 2013 
State-Changed-Why:  
MFC to stable/9 and stable/8 complete. 

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