Subject: kern/8666: incorrect usb kernel DIAGNOSTIC printf in uhci.c
To: None <gnats-bugs@gnats.netbsd.org>
From: None <paul@plectere.com>
List: netbsd-bugs
Date: 10/22/1999 13:54:45
>Number:         8666
>Category:       kern
>Synopsis:       USB diagnostic printf in uhci.c is extremely noisy
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 22 13:54:00 1999
>Last-Modified:
>Originator:     Paul Shupak
>Organization:
>Release:        Fri Oct 22 13:11:35 PDT 1999
>Environment:
System: NetBSD cobalt 1.4L NetBSD 1.4L (COBALT) #213: Thu Oct 21 22:12:57 PDT 1999 paul@cobalt:/usr/src/sys/arch/i386/compile/COBALT i386


>Description:

	The code contains a DIAGNOSTIC printf which references an as yet
	uninitialized value AND the condition may be triggered by normal
	operation if interrupts are shared.

>How-To-Repeat:

	a)	Build a kernel w/ option DIAGNOSTIC and "uhci*  at pci?" line
	b)	Run the kernel on a machine which shares the interrupt
		mappings of both a uhci USB and some other device.
		e.g. 
			uhci0: interrupting at irq 9
			ahc0: interrupting at irq 9
	c) Watch the endless stream of "uhci_intr: suspended sts=0x..." messages

>Fix:

*** uhci.c-ORIG	Thu Oct 21 22:12:10 1999
--- uhci.c	Thu Oct 21 22:12:15 1999
***************
*** 846,857 ****
  	}
  #endif
  
  #if defined(DIAGNOSTIC) && defined(__NetBSD__)
  	if (sc->sc_suspend != PWR_RESUME)
  		printf("uhci_intr: suspended sts=0x%x\n", status);
  #endif
  
- 	status = UREAD2(sc, UHCI_STS);
  	ack = 0;
  	if (status & UHCI_STS_USBINT)
  		ack |= UHCI_STS_USBINT;
--- 846,861 ----
  	}
  #endif
  
+ 	status = UREAD2(sc, UHCI_STS);
+ 	/* We may be sharing this interrupt with another PCI device */
+ 	if (status == 0)
+ 		return 0;
+ 
  #if defined(DIAGNOSTIC) && defined(__NetBSD__)
  	if (sc->sc_suspend != PWR_RESUME)
  		printf("uhci_intr: suspended sts=0x%x\n", status);
  #endif
  
  	ack = 0;
  	if (status & UHCI_STS_USBINT)
  		ack |= UHCI_STS_USBINT;
>Audit-Trail:
>Unformatted: