Subject: Re: kern/33742: Multiple bktr cards and changing PCI latency.
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-bugs
Date: 06/15/2006 19:40:03
The following reply was made to PR kern/33742; it has been noted by GNATS.

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: kern/33742: Multiple bktr cards and changing PCI latency.
Date: Thu, 15 Jun 2006 15:36:52 -0400

 On Jun 15,  7:25pm, srp@tworoads.net (srp@tworoads.net) wrote:
 -- Subject: kern/33742: Multiple bktr cards and changing PCI latency.
 
 | >Number:         33742
 | >Category:       kern
 | >Synopsis:       multiple bktr cards may require change in PCI latency.
 | >Confidential:   no
 | >Severity:       non-critical
 | >Priority:       low
 | >Responsible:    kern-bug-people
 | >State:          open
 | >Class:          change-request
 | >Submitter-Id:   net
 | >Arrival-Date:   Thu Jun 15 19:25:00 +0000 2006
 | >Originator:     Scott Presnell
 | >Release:        NetBSD 3.0_STABLE
 | >Organization:
 | 	Self
 | >Environment:
 | 
 | NetBSD 3.0_STABLE (SKOK) #4: Thu Jun 15 08:30:40 PDT 2006
 | 	srp@dirt.tworoads.net:/usr/src/sys/arch/i386/compile/SKOK
 | 
 | Architecture: i386
 | Machine: i386
 | 
 | >Description:
 | 
 | I use a webcam to monitor a remote location.  Recently I added a second
 | camera and second WinTV (bktr driver) card, but when I did one of the cards
 | started acting as though it was not getting a full frame capture, when
 | running in continuous capture mode (seemed to work OK when single capture
 | mode was used).
 | 
 | After checking the software and other possible souces of error, I
 | discovered that the manufacturer had in the past recommended reducing
 | the PCI latency under similar circumstances
 | 
 | (http://www.hauppauge.com/html/sw_wcst.htm) 
 | 
 | ...so I tried this first as a hack, it seemed to work, then rewrote it as a
 | bktr driver kernel option.  A latency value of 0x10 worked in my case.
 | 
 | >How-To-Repeat:
 | 
 | Find an old 180 MHz Pentium pro, install two bktr cards, start capturing in
 | continuous mode (a program called camserv was used).
 | 
 | NetBSD 3.0_STABLE (SKOK) #4: Thu Jun 15 08:30:40 PDT 2006
 | 	srp@dirt.tworoads.net:/usr/src/sys/arch/i386/compile/SKOK
 | total memory = 127 MB
 | avail memory = 120 MB
 | BIOS32 rev. 0 found at 0xffe90
 | mainbus0 (root)
 | cpu0 at mainbus0: (uniprocessor)
 | cpu0: Intel Pentium Pro (686-class), 179.64 MHz, id 0x619
 | cpu0: features fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
 | cpu0: features fbff<PGE,MCA,CMOV>
 | cpu0: I-cache 8 KB 32B/line 4-way, D-cache 8 KB 32B/line 2-way
 | cpu0: L2 cache 256 KB 32B/line 4-way
 | cpu0: ITLB 32 4 KB entries 4-way, 2 4 MB entries fully associative
 | cpu0: DTLB 64 4 KB entries 4-way, 8 4 MB entries 4-way
 | cpu0: 16 page colors
 | pci0 at mainbus0 bus 0: configuration mode 1
 | pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
 | pchb0 at pci0 dev 0 function 0
 | pchb0: Intel 82441FX (PMC) PCI and Memory Controller (rev. 0x02)
 | pcib0 at pci0 dev 13 function 0
 | pcib0: Intel 82371SB (PIIX3) PCI-ISA Bridge (rev. 0x01)
 | piixide0 at pci0 dev 13 function 1
 | piixide0: Intel 82371SB IDE Interface (PIIX3) (rev. 0x00)
 | piixide0: bus-master DMA support present
 | piixide0: primary channel wired to compatibility mode
 | piixide0: primary channel interrupting at irq 14
 | atabus0 at piixide0 channel 0
 | piixide0: secondary channel wired to compatibility mode
 | piixide0: secondary channel interrupting at irq 15
 | atabus1 at piixide0 channel 1
 | uhci0 at pci0 dev 13 function 2: Intel 82371SB (PIIX3) USB Host Controller (rev. 0x01)
 | uhci0: interrupting at irq 11
 | usb0 at uhci0: USB revision 1.0
 | uhub0 at usb0
 | uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
 | uhub0: 2 ports with 2 removable, self powered
 | ppb0 at pci0 dev 14 function 0: Digital Equipment DC21052 PCI-PCI Bridge (rev. 0x01)
 | pci1 at ppb0 bus 1
 | pci1: i/o space, memory space enabled, rd/line, wr/inv ok
 | ex0 at pci1 dev 8 function 0: 3Com 3c905-TX 10/100 Ethernet (rev. 0x0)
 | ex0: interrupting at irq 11
 | ex0: MAC address 00:c0:4f:b6:af:9e
 | exphy0 at ex0 phy 24: 3Com internal media interface
 | exphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
 | bktr0 at pci1 dev 9 function 0
 | bktr0: interrupting at irq 11
 | bktr0: Hauppauge Model 38101 B410
 | bktr0: Hauppauge WinCast/TV, Philips NTSC tuner.
 | Brooktree Bt878 Video Capture (Audio Section) (miscellaneous multimedia, revision 0x11) at pci1 dev 9 function 1 not configured
 | vga1 at pci0 dev 16 function 0: S3 Trio32/64 (rev. 0x54)
 | wsdisplay0 at vga1 kbdmux 1: console (80x25, vt100 emulation)
 | wsmux1: connecting to wsdisplay0
 | bktr1 at pci0 dev 17 function 0
 | bktr1: interrupting at irq 10
 | bktr1: Hauppauge Model 44801 C110
 | bktr1: Hauppauge WinCast/TV, Philips NTSC tuner.
 | Brooktree Bt878 Video Capture (Audio Section) (miscellaneous multimedia, revision 0x11) at pci0 dev 17 function 1 not configured
 | isa0 at pcib0
 | lpt0 at isa0 port 0x378-0x37b irq 7
 | com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
 | com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
 | com2 at isa0 port 0x3e8-0x3ef irq 5: ns16550a, working fifo
 | pckbc0 at isa0 port 0x60-0x64
 | pckbd0 at pckbc0 (kbd slot)
 | pckbc0: using irq 1 for kbd slot
 | wskbd0 at pckbd0: console keyboard, using wsdisplay0
 | pcppi0 at isa0 port 0x61
 | sysbeep0 at pcppi0
 | isapnp0 at isa0 port 0x279: ISA Plug 'n Play device support
 | npx0 at isa0 port 0xf0-0xff: using exception 16
 | fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
 | isapnp0: no ISA Plug 'n Play devices found
 | fd0 at fdc0 drive 0: 1.44MB, 80 cyl, 2 head, 18 sec
 | ulpt0 at uhub0 port 1 configuration 1 interface 0
 | ulpt0: HewLett Packard HP LaserJet 1200, rev 1.10/1.00, addr 2, iclass 7/1
 | ulpt0: using bi-directional mode
 | ugen0 at uhub0 port 2
 | ugen0: American Power Conversion Back-UPS NS 1050 FW:7.g3 .D USB FW:g3, rev 1.10/1.06, addr 3
 | wd0 at atabus0 drive 0: <WDC AC22100H>
 | wd0: drive supports 16-sector PIO transfers, LBA addressing
 | wd0: 2014 MB, 4092 cyl, 16 head, 63 sec, 512 bytes/sect x 4124736 sectors
 | wd0: 32-bit data port
 | wd0: drive supports PIO mode 4, DMA mode 2
 | wd0(piixide0:0:0): using PIO mode 4, DMA mode 2 (using DMA)
 | atapibus0 at atabus1: 2 targets
 | cd0 at atapibus0 drive 0: <NEC                 CD-ROM DRIVE:282, , 3.07> cdrom removable
 | cd0: 32-bit data port
 | cd0: drive supports PIO mode 3, DMA mode 1
 | cd0(piixide0:1:0): using PIO mode 0, DMA mode 1 (using DMA)
 | boot device: wd0
 | root on wd0a dumps on wd0b
 | root file system type: ffs
 | wsdisplay0: screen 1 added (80x25, vt100 emulation)
 | wsdisplay0: screen 2 added (80x25, vt100 emulation)
 | wsdisplay0: screen 3 added (80x25, vt100 emulation)
 | wsdisplay0: screen 4 added (80x25, vt100 emulation)
 | 
 | >Fix:
 | 
 | 
 | The following patch adds BKTR_OVERRIDE_LATENCY as a kernel option
 | for the bktr driver.
 | 
 | --- sys/dev/pci/files.pci.orig	2006-06-15 08:07:56.000000000 -0700
 | +++ sys/dev/pci/files.pci	2006-06-15 08:08:57.000000000 -0700
 | @@ -10,7 +10,7 @@
 |  defflag	opt_bktr.h	BKTR_430_FX_MODE BKTR_GPIO_ACCESS BKTR_NO_MSP_RESET
 |  			BKTR_REVERSE_MUTE BKTR_SIS_VIA_MODE BKTR_USE_PLL
 |  defparam opt_bktr.h	BKTR_OVERRIDE_CARD BKTR_OVERRIDE_TUNER BKTR_OVERRIDE_DBX
 | -			BKTR_OVERRIDE_MSP BKTR_SYSTEM_DEFAULT
 | +			BKTR_OVERRIDE_MSP BKTR_OVERRIDE_LATENCY BKTR_SYSTEM_DEFAULT
 |  
 |  defflag	opt_pciide.h	PCIIDE_CMD064x_DISABLE PCIIDE_AMD756_ENABLEDMA
 |  			PCIIDE_CMD0646U_ENABLEUDMA PCIIDE_I31244_DISABLEDMA
 | --- sys/dev/pci/bktr/bktr_os.c.orig	2006-06-15 10:38:53.000000000 -0700
 | +++ sys/dev/pci/bktr/bktr_os.c	2006-06-15 08:29:41.000000000 -0700
 | @@ -1520,18 +1520,33 @@
 |  #ifndef BROOKTREE_DEF_LATENCY_VALUE
 |  #define BROOKTREE_DEF_LATENCY_VALUE	0x10
 |  #endif
 | +
 | +	latency = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_LATENCY_TIMER);
 | +	latency = (latency >> 8) & 0xff;
 | +
 | +#if defined(BKTR_OVERRIDE_LATENCY)
 | +
 | +	printf("%s: overriding PCI bus latency was %d changing to %d\n",
 | +	       bktr_name(bktr), (int) latency, BKTR_OVERRIDE_LATENCY);
 | +	latency = BKTR_OVERRIDE_LATENCY;
 | +	pci_conf_write(pa->pa_pc, pa->pa_tag,
 | +		       PCI_LATENCY_TIMER, latency<<8);
 | +
 | +#else
 | +	
 |  	latency = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_LATENCY_TIMER);
 |  	latency = (latency >> 8) & 0xff;
 |  
 |  	if (!latency) {
 |  		if (bootverbose) {
 | -			printf("%s: PCI bus latency was 0 changing to %d",
 | +			printf("%s: PCI bus latency was 0 changing to %d\n",
 |  			       bktr_name(bktr), BROOKTREE_DEF_LATENCY_VALUE);
 |  		}
 |  		latency = BROOKTREE_DEF_LATENCY_VALUE;
 |  		pci_conf_write(pa->pa_pc, pa->pa_tag,
 |  			       PCI_LATENCY_TIMER, latency<<8);
 |  	}
 | +#endif
 |  
 |  	common_bktr_attach(bktr, unit, pa->pa_id, PCI_REVISION(pa->pa_class));
 |  
 | ===
 | 
 | The resulting dmesg changes when using 
 | 
 | options BKTR_OVERRIDE_LATENCY 0x10
 | 
 
 What are the valid values of latency? Shouldn't the driver check for those?
 
 christos