Subject: kern/19803: usbd_alloc_buffer fails often
To: None <gnats-bugs@gnats.netbsd.org>
From: None <toshii@netbsd.org>
List: netbsd-bugs
Date: 01/12/2003 12:21:56
>Number:         19803
>Category:       kern
>Synopsis:       usbd_alloc_buffer fails often
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 11 19:23:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     IWAMOTO Toshihiro
>Release:        NetBSD 1.6L
>Organization:
	
>Environment:
System: NetBSD pepper.my.domain 1.6L NetBSD 1.6L (PEPPER) #111: Sat Jan 11 00:53:18 JST 2003 root@pepper.my.domain:/sys/arch/i386/compile/PEPPER i386
Architecture: i386
Machine: i386
>Description:
	umass ATTACH and ulpt_do_write need to allocate some memory,
	but this fails often.  See kern/19326 for the umass case.
	For ulpt, write(2) returns ENOMEM.

>How-To-Repeat:
	Use enough memory (using X with gnome, emacs, mozilla... seems to
	be enough for my system (with 512M ram)) so that kernel memory
	allocation fails.
	Then plug a umass device or try to print something through ulpt.

	Then terminate mozilla to free some memory and try again. They
	should work.
>Fix:
	usbd_alloc_buffer calls ohci_allocm to allocate memory,
	which after all calls bus_dmamem_alloc(..., BUS_DMA_NOWAIT) in
	usb_block_allocmem.
	(This is my speculation and I haven't confirmed. Memory allocation
	 failures might be happening elsewhere.)

	I guess bus_dmamem_alloc with BUS_DMA_WAITOK would fix this problem,
	but doing this isn't trivial for me.
>Release-Note:
>Audit-Trail:
>Unformatted: