From nobody@FreeBSD.org  Thu Jun 28 17:17:26 2012
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 0D524106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jun 2012 17:17:26 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id E9CD78FC1F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jun 2012 17:17:25 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SHHPS1003454
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 28 Jun 2012 17:17:25 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q5SHHPPA003453;
	Thu, 28 Jun 2012 17:17:25 GMT
	(envelope-from nobody)
Message-Id: <201206281717.q5SHHPPA003453@red.freebsd.org>
Date: Thu, 28 Jun 2012 17:17:25 GMT
From: Mike Watters <mike@mwatters.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] sys/dev/sym broken by r236061 on amd64 with more than 4GB RAM
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169526
>Category:       kern
>Synopsis:       [sym] [patch] sys/dev/sym broken by r236061 on amd64 with more than 4GB RAM
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    marius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 28 17:20:08 UTC 2012
>Closed-Date:    Sun Jul 22 14:44:34 UTC 2012
>Last-Modified:  Sun Jul 22 14:44:34 UTC 2012
>Originator:     Mike Watters
>Release:        8-STABLE
>Organization:
>Environment:
FreeBSD 8.3-STABLE #4: Wed Jun 27 00:13:04 MDT 2012
    srcbuild@:/usr/obj/usr/src-8/sys/GENERIC amd64
>Description:
Related PR: 168928 (different bug in same revision)

real memory  = 8589934592 (8192 MB)
avail memory = 7983443968 (7613 MB)

sym0: <1010-66> port 0xe000-0xe0ff mem 0xfbfffc00-0xfbffffff,0xfbffc000-0xfbffdfff irq 21 at device 7.0 on pci3
sym0: failed to create DMA tag.
device_attach: sym0 attach returned 6

(followed by memory-related errors and boot failure)


In r236061 to sys/dev/sym/sym_hipd.c, the flags parameter to
bus_dma_tag_create() was changed from 0 to BUS_DMA_ALLOCNOW, which
breaks the driver on my amd64 system with 8GB RAM.

If I follow the logic correctly, the BUS_DMA_ALLOCNOW flag combined
with the maxsize parameter being BUS_SPACE_MAXSIZE results in the
system trying to allocate 4GB worth of bounce pages, which I assume
exhausts kernel resources.
>How-To-Repeat:

>Fix:
Change flags parameter from BUS_DMA_ALLOCNOW back to 0, or change
maxsize parameter to a more appropriate smaller value.  Changing flags to 0
(BUS_DMA_WAITOK) fixes the problem on my system.

Patch attached with submission follows:

--- sym_hipd.c.orig	2012-06-17 03:43:04.000000000 -0600
+++ sym_hipd.c	2012-06-28 11:01:36.335984640 -0600
@@ -8538,7 +8538,7 @@
 	if (bus_dma_tag_create(np->bus_dmat, 1, SYM_CONF_DMA_BOUNDARY,
 	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
 	    BUS_SPACE_MAXSIZE, SYM_CONF_MAX_SG, SYM_CONF_DMA_BOUNDARY,
-	    BUS_DMA_ALLOCNOW, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
+	    BUS_DMA_WAITOK, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
 		device_printf(dev, "failed to create DMA tag.\n");
 		goto attach_failed;
 	}


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->marius 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Jul 16 02:41:55 UTC 2012 
Responsible-Changed-Why:  
Over to committer. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/169526: commit references a PR
Date: Thu, 19 Jul 2012 14:43:57 +0000 (UTC)

 Author: marius
 Date: Thu Jul 19 14:43:46 2012
 New Revision: 238621
 URL: http://svn.freebsd.org/changeset/base/238621
 
 Log:
   Revert the use of BUS_DMA_ALLOCNOW when creating the DMA tag for user
   data introduced in r236061. Using that flag doesn't make that much
   sense on this case as the DMA maps using it are also created during
   sym_pci_attach(). Moreover, due to the maxsegsz parameter used, doing
   so may exhaust the bounce pages pool on architectures requiring
   bounce pages. [1]
   While at it, use a slightly more appropriate maxsegsz parameter.
   
   PR:		169526
   Submitted by:	Mike Watters [1]
   MFC after:	3 days
 
 Modified:
   head/sys/dev/sym/sym_hipd.c
 
 Modified: head/sys/dev/sym/sym_hipd.c
 ==============================================================================
 --- head/sys/dev/sym/sym_hipd.c	Thu Jul 19 13:00:31 2012	(r238620)
 +++ head/sys/dev/sym/sym_hipd.c	Thu Jul 19 14:43:46 2012	(r238621)
 @@ -8537,8 +8537,8 @@ sym_pci_attach(device_t dev)
  	 */
  	if (bus_dma_tag_create(np->bus_dmat, 1, SYM_CONF_DMA_BOUNDARY,
  	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
 -	    BUS_SPACE_MAXSIZE, SYM_CONF_MAX_SG, SYM_CONF_DMA_BOUNDARY,
 -	    BUS_DMA_ALLOCNOW, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
 +	    BUS_SPACE_MAXSIZE_32BIT, SYM_CONF_MAX_SG, SYM_CONF_DMA_BOUNDARY,
 +	    0, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
  		device_printf(dev, "failed to create DMA tag.\n");
  		goto attach_failed;
  	}
 _______________________________________________
 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/169526: commit references a PR
Date: Sun, 22 Jul 2012 14:33:06 +0000 (UTC)

 Author: marius
 Date: Sun Jul 22 14:32:49 2012
 New Revision: 238689
 URL: http://svn.freebsd.org/changeset/base/238689
 
 Log:
   MFC: r238621
   
   Revert the use of BUS_DMA_ALLOCNOW when creating the DMA tag for user
   data introduced in r236061 (MFC'ed to stable/9 in r237186). Using that
   flag doesn't make that much sense on this case as the DMA maps using
   it are also created during sym_pci_attach(). Moreover, due to the
   maxsegsz parameter used, doing so may exhaust the bounce pages pool
   on architectures requiring bounce pages. [1]
   While at it, use a slightly more appropriate maxsegsz parameter.
   
   PR:		169526
   Submitted by:	Mike Watters [1]
   Approved by:	re (kib)
 
 Modified:
   stable/9/sys/dev/sym/sym_hipd.c
 Directory Properties:
   stable/9/sys/   (props changed)
   stable/9/sys/amd64/include/xen/   (props changed)
   stable/9/sys/boot/   (props changed)
   stable/9/sys/boot/i386/efi/   (props changed)
   stable/9/sys/boot/ia64/efi/   (props changed)
   stable/9/sys/boot/ia64/ski/   (props changed)
   stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
   stable/9/sys/boot/powerpc/ofw/   (props changed)
   stable/9/sys/cddl/contrib/opensolaris/   (props changed)
   stable/9/sys/conf/   (props changed)
   stable/9/sys/contrib/dev/acpica/   (props changed)
   stable/9/sys/contrib/octeon-sdk/   (props changed)
   stable/9/sys/contrib/pf/   (props changed)
   stable/9/sys/contrib/x86emu/   (props changed)
   stable/9/sys/dev/   (props changed)
   stable/9/sys/dev/e1000/   (props changed)
   stable/9/sys/dev/isp/   (props changed)
   stable/9/sys/dev/ixgbe/   (props changed)
   stable/9/sys/fs/   (props changed)
   stable/9/sys/fs/ntfs/   (props changed)
   stable/9/sys/modules/   (props changed)
 
 Modified: stable/9/sys/dev/sym/sym_hipd.c
 ==============================================================================
 --- stable/9/sys/dev/sym/sym_hipd.c	Sun Jul 22 14:31:42 2012	(r238688)
 +++ stable/9/sys/dev/sym/sym_hipd.c	Sun Jul 22 14:32:49 2012	(r238689)
 @@ -8537,8 +8537,8 @@ sym_pci_attach(device_t dev)
  	 */
  	if (bus_dma_tag_create(np->bus_dmat, 1, SYM_CONF_DMA_BOUNDARY,
  	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
 -	    BUS_SPACE_MAXSIZE, SYM_CONF_MAX_SG, SYM_CONF_DMA_BOUNDARY,
 -	    BUS_DMA_ALLOCNOW, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
 +	    BUS_SPACE_MAXSIZE_32BIT, SYM_CONF_MAX_SG, SYM_CONF_DMA_BOUNDARY,
 +	    0, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
  		device_printf(dev, "failed to create DMA tag.\n");
  		goto attach_failed;
  	}
 _______________________________________________
 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/169526: commit references a PR
Date: Sun, 22 Jul 2012 14:33:26 +0000 (UTC)

 Author: marius
 Date: Sun Jul 22 14:33:04 2012
 New Revision: 238690
 URL: http://svn.freebsd.org/changeset/base/238690
 
 Log:
   MFC: r238621
   
   Revert the use of BUS_DMA_ALLOCNOW when creating the DMA tag for user
   data introduced in r236061 (MFC'ed to stable/8 in r237187). Using that
   flag doesn't make that much sense on this case as the DMA maps using
   it are also created during sym_pci_attach(). Moreover, due to the
   maxsegsz parameter used, doing so may exhaust the bounce pages pool
   on architectures requiring bounce pages. [1]
   While at it, use a slightly more appropriate maxsegsz parameter.
   
   PR:		169526
   Submitted by:	Mike Watters [1]
 
 Modified:
   stable/8/sys/dev/sym/sym_hipd.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/boot/   (props changed)
   stable/8/sys/cddl/   (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/   (props changed)
   stable/8/sys/dev/e1000/   (props changed)
   stable/8/sys/dev/sound/   (props changed)
   stable/8/sys/dev/sound/pci/   (props changed)
 
 Modified: stable/8/sys/dev/sym/sym_hipd.c
 ==============================================================================
 --- stable/8/sys/dev/sym/sym_hipd.c	Sun Jul 22 14:32:49 2012	(r238689)
 +++ stable/8/sys/dev/sym/sym_hipd.c	Sun Jul 22 14:33:04 2012	(r238690)
 @@ -8537,8 +8537,8 @@ sym_pci_attach(device_t dev)
  	 */
  	if (bus_dma_tag_create(np->bus_dmat, 1, SYM_CONF_DMA_BOUNDARY,
  	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
 -	    BUS_SPACE_MAXSIZE, SYM_CONF_MAX_SG, SYM_CONF_DMA_BOUNDARY,
 -	    BUS_DMA_ALLOCNOW, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
 +	    BUS_SPACE_MAXSIZE_32BIT, SYM_CONF_MAX_SG, SYM_CONF_DMA_BOUNDARY,
 +	    0, busdma_lock_mutex, &np->mtx, &np->data_dmat)) {
  		device_printf(dev, "failed to create DMA tag.\n");
  		goto attach_failed;
  	}
 _______________________________________________
 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: open->closed 
State-Changed-By: marius 
State-Changed-When: Sun Jul 22 14:44:11 UTC 2012 
State-Changed-Why:  
close 

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