NetBSD Problem Report #34070

From www@NetBSD.org  Mon Jul 24 15:37:07 2006
Return-Path: <www@NetBSD.org>
Received: by narn.NetBSD.org (Postfix, from userid 31301)
	id 1AFE563B8C3; Mon, 24 Jul 2006 15:37:07 +0000 (UTC)
Message-Id: <20060724153707.1AFE563B8C3@narn.NetBSD.org>
Date: Mon, 24 Jul 2006 15:37:07 +0000 (UTC)
From: wulf@netbsd.org
Reply-To: wulf@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: ubt0: btconfig: SIOCSBTFLAGS: Resource temporarily unavailable
X-Send-Pr-Version: www-1.0

>Number:         34070
>Category:       kern
>Synopsis:       ubt0: btconfig: SIOCSBTFLAGS: Resource temporarily unavailable
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 24 15:40:00 +0000 2006
>Closed-Date:    Fri Dec 08 18:33:10 +0000 2006
>Last-Modified:  Fri Dec 08 18:33:10 +0000 2006
>Originator:     Berndt Josef Wulf
>Release:        NetBSD-i386-current
>Organization:
NTC-Electronics
>Environment:
NetBSD barossa 3.99.21 NetBSD 3.99.21 (BAROSSA) #1: Mon Jul 17 22:04:46 CST 2006  wulf@:/usr/src/sys/arch/i386/compile/BAROSSA i386
>Description:
Bluetooth is not working on Dell Inspiron 9400 running NetBSD-i386 3.99.21. Kernel reports SIOCSBTFLAGS: Resource temporarily unavailable when issuing "btconfig ubt0 up" command. This worked on a Dell Insprion 9300 laptop. The problem is thought to be due to the EHCI controller used on the Dell Inspiron 9400. For more detailed information read the following email thread:

http://mail-index.netbsd.org/tech-kern/2006/07/11/0005.html
http://mail-index.netbsd.org/tech-kern/2006/07/11/0019.html
http://mail-index.netbsd.org/tech-kern/2006/07/12/0007.html
http://mail-index.netbsd.org/tech-kern/2006/07/12/0008.html
http://mail-index.netbsd.org/tech-kern/2006/07/12/0025.html
http://mail-index.netbsd.org/tech-kern/2006/07/12/0027.html
http://mail-index.netbsd.org/tech-kern/2006/07/13/0001.html
http://mail-index.netbsd.org/tech-kern/2006/07/14/0008.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0001.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0005.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0010.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0012.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0013.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0015.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0016.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0017.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0018.html
http://mail-index.netbsd.org/tech-kern/2006/07/16/0020.html

bootlog:

Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 3.99.21 (BAROSSA) #1: Mon Jul 17 22:04:46 CST 2006
        wulf@:/usr/src/sys/arch/i386/compile/BAROSSA
total memory = 1022 MB
avail memory = 995 MB
timecounter: Timecounters tick every 10.000 msec
timecounter: Timecounter "i8254" frequency 1193182 Hz quality 100
timecounter: selected timecounter "i8254" frequency 1193182 Hz quality 100
BIOS32 rev. 0 found at 0xffa10
mainbus0 (root)
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel Pentium Pro, II or III (686-class), 1995.16 MHz, id 0x6e8
cpu0: features bfe9fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
cpu0: features bfe9fbff<PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX>
cpu0: features bfe9fbff<FXSR,SSE,SSE2,SS,HTT,TM,SBF>
cpu0: features2 c1a9<SSE3,MONITOR,VMX,EST,TM2,xTPR>
cpu0: "Genuine Intel(R) CPU           T2500  @ 2.00GHz"
cpu0: I-cache 32 KB 64B/line 8-way, D-cache 32 KB 64B/line 8-way
cpu0: L2 cache 2 MB 64B/line 8-way
cpu0: using thermal monitor 1
cpu0: Enhanced SpeedStep (1404 mV)  - unknown CPU or operating point.
cpu0: calibrating local timer
cpu0: apic clock running at 166 MHz
cpu0: 64 page colors
cpu1 at mainbus0: apid 1 (application processor)
cpu1: starting
cpu1: Intel Pentium Pro, II or III (686-class), 1995.00 MHz, id 0x6e8
cpu1: features bfe9fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
cpu1: features bfe9fbff<PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX>
cpu1: features bfe9fbff<FXSR,SSE,SSE2,SS,HTT,TM,SBF>
cpu1: features2 c1a9<SSE3,MONITOR,VMX,EST,TM2,xTPR>
cpu1: "Genuine Intel(R) CPU           T2500  @ 2.00GHz"
cpu1: I-cache 32 KB 64B/line 8-way, D-cache 32 KB 64B/line 8-way
cpu1: L2 cache 2 MB 64B/line 8-way
cpu1: using thermal monitor 1
cpu1: Enhanced SpeedStep (1404 mV)  - unknown CPU or operating point.
ioapic0 at mainbus0 apid 2 (I/O APIC)
ioapic0: pa 0xfec00000, version 20, 24 pins
ioapic0: misconfigured as apic 0
ioapic0: remapped to apic 2
acpi0 at mainbus0: Advanced Configuration and Power Interface
acpi0: using Intel ACPI CA subsystem version 20060217
acpi0: X/RSDT: OemId <DELL  , M07    ,27d60311>, AslId <ASL ,00000061>
acpi0: SCI interrupting at int 9
timecounter: Timecounter "ACPI-Safe" frequency 3579545 Hz quality 900
timecounter: selected timecounter "ACPI-Safe" frequency 3579545 Hz quality 900
ACPI-Safe 24-bit timer
mpacpi: could not get bus number, assuming bus 0
allocated pic ioapic0 type level pin 9 level 10 to cpu0 slot 16 idt entry 160
ACPI Object Type 'Processor' (0x0c) at acpi0 not configured
ACPI Object Type 'Processor' (0x0c) at acpi0 not configured
acpiacad0 at acpi0 (ACPI0003): ACPI AC Adapter
acpibat0 at acpi0 (PNP0C0A-1): ACPI Battery (Control Method)
acpilid0 at acpi0 (PNP0C0D): ACPI Lid Switch
acpibut0 at acpi0 (PNP0C0C): ACPI Power Button
acpibut1 at acpi0 (PNP0C0E): ACPI Sleep Button
PNP0C01 [System Board] at acpi0 not configured
PNP0A03 [PCI/PCI-X Host Bridge] at acpi0 not configured
PNP0C01 [System Board] at acpi0 not configured
PNP0C01 [System Board] at acpi0 not configured
pckbc0 at acpi0 (PNP0F13): aux port
pckbc0: irq 12
pckbc1 at acpi0 (PNP0303): kbd port
pckbc1: io 0x60,0x64,0x62,0x66 irq 1
PNP0B00 [AT Real-Time Clock] at acpi0 not configured
attimer1 at acpi0 (PNP0100): AT Timer
attimer1: io 0x40-0x43,0x50-0x53 irq 2
pcppi1 at acpi0 (PNP0800)
pcppi1: io 0x61,0x63,0x65,0x67
midi0 at pcppi1: PC speaker (CPU-intensive output)
sysbeep0 at pcppi1
PNP0C01 [System Board] at acpi0 not configured
PNP0000 [AT Interrupt Controller] at acpi0 not configured
PNP0200 [AT DMA Controller] at acpi0 not configured
PNP0C04 [Math Coprocessor] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
PNP0C0F [PCI interrupt link device] at acpi0 not configured
acpitz0 at acpi0: ACPI Thermal Zone
acpitz0: unable to get polling interval; using default of 30.0s
acpitz0: passive cooling mode only
acpitz0: critical 126.0C
pckbd0 at pckbc1 (kbd slot)
allocated pic ioapic0 type edge pin 1 level 9 to cpu0 slot 1 idt entry 144
pckbc1: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard
pms0 at pckbc1 (aux slot)
allocated pic ioapic0 type edge pin 12 level 9 to cpu0 slot 12 idt entry 145
pckbc1: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pcppi1: attached to attimer1
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 82945GM/PM/GMS Host Bridge (rev. 0x03)
ppb0 at pci0 dev 1 function 0: Intel product 0x27a1 (rev. 0x03)
pci1 at ppb0 bus 1
pci1: i/o space, memory space enabled, rd/line, wr/inv ok
vga0 at pci1 dev 0 function 0: ATI Technologies product 0x7145 (rev. 0x00)
wsdisplay0 at vga0 kbdmux 1: console (80x25, vt100 emulation), using wskbd0
wsmux1: connecting to wsdisplay0
azalia0 at pci0 dev 27 function 0: Generic High Definition Audio Controller
allocated pic ioapic0 type level pin 21 level 11 to cpu0 slot 11 idt entry 176
azalia0: interrupting at ioapic0 pin 21 (irq 11)
azalia0: host: Intel 82801GB/GR High Definition Audio Controller (rev. 1)
azalia0: host: High Definition Audio rev. 1.0
ppb1 at pci0 dev 28 function 0: Intel 82801GB/GR PCI Express Port #1 (rev. 0x01)
pci2 at ppb1 bus 2
pci2: i/o space, memory space enabled, rd/line, wr/inv ok
ppb2 at pci0 dev 28 function 1: Intel 82801GB/GR PCI Express Port #2 (rev. 0x01)
pci3 at ppb2 bus 3
pci3: i/o space, memory space enabled, rd/line, wr/inv ok
wpi0 at pci3 dev 0 function 0: Intel PRO/Wireless LAN 3945ABG Mini-PCI Adapter (
rev. 0x02)
allocated pic ioapic0 type level pin 17 level 7 to cpu0 slot 5 idt entry 112
wpi0: interrupting at ioapic0 pin 17 (irq 5)
wpi0: 802.11 address 00:13:02:9c:e3:ba
wpi0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
wpi0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36M
bps 48Mbps 54Mbps
ppb3 at pci0 dev 28 function 3: Intel 82801GB/GR PCI Express Port #4 (rev. 0x01)
pci4 at ppb3 bus 4
pci4: i/o space, memory space enabled, rd/line, wr/inv ok
uhci0 at pci0 dev 29 function 0: Intel 82801GB/GR USB UHCI Controller (rev. 0x01
)
allocated pic ioapic0 type level pin 20 level 6 to cpu0 slot 10 idt entry 96
uhci0: interrupting at ioapic0 pin 20 (irq 10)
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
uhci1 at pci0 dev 29 function 1: Intel 82801GB/GR USB UHCI Controller (rev. 0x01
)
allocated pic ioapic0 type level pin 21 level 6 to cpu0 slot 11 idt entry 97
uhci1: interrupting at ioapic0 pin 21 (irq 11)
usb1 at uhci1: USB revision 1.0
uhub1 at usb1
uhub1: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
uhci2 at pci0 dev 29 function 2: Intel 82801GB/GR USB UHCI Controller (rev. 0x01
)
allocated pic ioapic0 type level pin 22 level 6 to cpu0 slot 9 idt entry 98
uhci2: interrupting at ioapic0 pin 22 (irq 9)
usb2 at uhci2: USB revision 1.0
uhub2 at usb2
uhub2: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub2: 2 ports with 2 removable, self powered
uhci3 at pci0 dev 29 function 3: Intel 82801GB/GR USB UHCI Controller (rev. 0x01
)
allocated pic ioapic0 type level pin 23 level 6 to cpu0 slot 7 idt entry 99
uhci3: interrupting at ioapic0 pin 23 (irq 7)
usb3 at uhci3: USB revision 1.0
uhub3 at usb3
uhub3: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub3: 2 ports with 2 removable, self powered
ehci0 at pci0 dev 29 function 7: Intel 82801GB/GR USB EHCI Controller (rev. 0x01
)
allocated pic ioapic0 type level pin 20 level 6 to cpu0 slot 10 idt entry 96
ehci0: interrupting at ioapic0 pin 20 (irq 10)
ehci0: BIOS has given up ownership
ehci0: EHCI version 1.0
ehci0: companion controllers, 2 ports each: uhci0 uhci1 uhci2 uhci3
usb4 at ehci0: USB revision 2.0
uhub4 at usb4
uhub4: Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
uhub4: 8 ports with 8 removable, self powered
ppb4 at pci0 dev 30 function 0: Intel 82801BAM Hub-PCI Bridge (rev. 0xe1)
pci5 at ppb4 bus 5
pci5: i/o space, memory space enabled
bce0 at pci5 dev 0 function 0: Broadcom BCM4401-B0 10/100 Ethernet
allocated pic ioapic0 type level pin 17 level 7 to cpu0 slot 5 idt entry 112
bce0: interrupting at ioapic0 pin 17 (irq 5)
bmtphy0 at bce0 phy 1: BCM4401 10/100 media interface, rev. 0
bmtphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
bce0: Ethernet address 00:14:22:f7:28:8e
fwohci0 at pci5 dev 1 function 0: Ricoh product 0x0832 (rev. 0x00)
allocated pic ioapic0 type level pin 19 level 6 to cpu0 slot 3 idt entry 100
fwohci0: interrupting at ioapic0 pin 19 (irq 3)
fwohci0: OHCI version 1.10 (ROM=0)
fwohci0: No. of Isochronous channels is 4.
fwohci0: EUI64 47:4f:c0:00:19:8e:44:38
fwohci0: Phy 1394a available S400, 1 ports.
fwohci0: Link S400, max_rec 2048 bytes.
ieee1394if0 at fwohci0: IEEE1394 bus
fwip0 at ieee1394if0: IP over IEEE1394
fwohci0: Initiate bus reset
Ricoh product 0x0822 (SD Host Controller system, interface 0x01, revision 0x19)
at pci5 dev 1 function 1 not configured
Ricoh product 0x0843 (miscellaneous system, revision 0x01) at pci5 dev 1 functio
n 2 not configured
Ricoh product 0x0592 (miscellaneous system, revision 0x0a) at pci5 dev 1 functio
n 3 not configured
Ricoh product 0x0852 (miscellaneous system, revision 0x05) at pci5 dev 1 functio
n 4 not configured
pcib0 at pci0 dev 31 function 0
pcib0: Intel 82801GBM LPC Interface Bridge (rev. 0x01)
piixide0 at pci0 dev 31 function 2
piixide0: Intel 82801GBM/GHM Serial ATA Controller (ICH7) (rev. 0x01)
piixide0: bus-master DMA support present
piixide0: primary channel wired to compatibility mode
allocated pic ioapic0 type edge pin 14 level 6 to cpu0 slot 14 idt entry 101
piixide0: primary channel interrupting at ioapic0 pin 14 (irq 14)
atabus0 at piixide0 channel 0
piixide0: secondary channel wired to compatibility mode
allocated pic ioapic0 type edge pin 15 level 6 to cpu0 slot 15 idt entry 102
piixide0: secondary channel interrupting at ioapic0 pin 15 (irq 15)
atabus1 at piixide0 channel 1
Intel 82801GB/GR SMBus Controller (SMBus serial bus, revision 0x01) at pci0 dev
31 function 3 not configured
isa0 at pcib0
isapnp0 at isa0 port 0x279: ISA Plug 'n Play device support
npx0 at isa0 port 0xf0-0xff
npx0: using exception 16
isapnp0: no ISA Plug 'n Play devices found
ioapic0: enabling
WARNING: Callback scheduled before sysmon task queue thread present.
fwohci0: node_id=0xc800ffc0, gen=1, CYCLEMASTER mode
ieee1394if0: 1 nodes, maxhop <= 0, cable IRM = 0 (me)
ieee1394if0: bus manager 0 (me)
timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0
azalia0: codec[0]: Sigmatel STAC9220 (rev. 34.1)
azalia0: codec[0]: High Definition Audio rev. 1.0
azalia0: playback: max channels=2, encodings=1<PCM>
azalia0: playback: PCM formats=e07e0<24bit,20bit,16bit,192kHz,176.4kHz,96kHz,88.
2kHz,48kHz,44.1kHz>
azalia0: recording: max channels=2, encodings=1<PCM>
azalia0: recording: PCM formats=e07e0<24bit,20bit,16bit,192kHz,176.4kHz,96kHz,88
.2kHz,48kHz,44.1kHz>
azalia0: codec[1]: 0x14f1/0x2bfa (rev. 0.0)
azalia0: codec[1]: High Definition Audio rev. 0.9
azalia0: codec[1]: No support for modem function groups
azalia0: codec[1] has no audio function groups
audio0 at azalia0: full duplex, independent
Kernelized RAIDframe activated
acpibat0: battery info: Sanyo, LION, DELL C54476, 772
uhub5 at uhub4 port 1
uhub5: Dell product 0xa005, class 9/0, rev 2.00/50.18, addr 2
uhub5: multiple transaction translators
uhub5: 4 ports with 1 removable, self powered
ubt0 at uhub5 port 4 configuration 1 interface 0
ubt0: Dell TrueMobile 350 Bluetooth USB Adapter, rev 2.00/24.22, addr 3
wd0 at atabus0 drive 0: <FUJITSU MHV2100BH>
wd0: drive supports 16-sector PIO transfers, LBA48 addressing
wd0: 93958 MB, 190899 cyl, 16 head, 63 sec, 512 bytes/sect x 192426570 sectors
wd0: 32-bit data port
wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 5 (Ultra/100)
wd0(piixide0:0:0): using PIO mode 4, Ultra-DMA mode 5 (Ultra/100) (using DMA)
atapibus0 at atabus1: 2 targets
cd0 at atapibus0 drive 0: <_NEC DVD+/-RW ND-6650A, , 102C> cdrom removable
cd0: 32-bit data port
cd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 2 (Ultra/33)
cd0(piixide0:1:0): using PIO mode 4, Ultra-DMA mode 2 (Ultra/33) (using DMA)
boot device: wd0
root file system type: ffs
cpu1: CPU 1 running
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)
acpiacad0: AC adapter online.


>How-To-Repeat:
btconfig ubt0 up

on a bluetooth enabled kernel and system

>Fix:
N/A

>Release-Note:

>Audit-Trail:
From: Iain Hibbert <plunky@rya-online.net>
To: Berndt Josef Wulf <bwulf@ping.net.au>
Cc: gnats-bugs@netbsd.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily
 unavailable
Date: Thu, 16 Nov 2006 19:07:19 +0000 (GMT)

 Hi Berndt,
           This issue is cropping up again with somebody else (Matthias
 Drochner has a new laptop with the Dell 350 bluetooth module) and he did
 somehow disable EHCI in the bios (downgrades USB to v1) and it appears to
 make the bluetooth dongle work - can you try that by chance?

 This would appear to confirm my thought that the problem is somehow in the
 EHCI layer rather than the ubt driver..

 iain

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Thu, 16 Nov 2006 21:26:24 +0100

 plunky@rya-online.net said:
 >  he did
 >  somehow disable EHCI in the bios (downgrades USB to v1)

 Actually I did disable it in the kernel configuration.
 The BIOS is quite unusual, don't know whether this is
 possible at all.

 The box is a Latitude D820 btw; the hardware quite close
 to yours (except unrelated details).

 > it appears to make the bluetooth dongle work

 Yes, I could communicate with a mobile phone.

 best regards
 Matthias

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, wulf@NetBSD.org, plunky@rya-online.net
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Fri, 17 Nov 2006 19:20:29 +0100

 This is a multipart MIME message.

 --==_Exmh_13776008535290
 Content-Type: text/plain; charset=us-ascii


 With the appended patch the ubt initializes for me, even if usb2/ehci
 is used by the host controller.
 The "16" happens to be the "wMaxPacketSize" in the endpoint descriptor;
 I'm not sure yet whether it should be the driver's duty to check that
 or the framework should care.
 I'm also not sure whether the builtin Dell hub is somehow limited or
 the translation problems are to be expected under the timing/size conditions
 imposed by the ubt driver.

 best regards
 Matthias



 --==_Exmh_13776008535290
 Content-Type: text/plain ; name="btilen.txt"; charset=us-ascii
 Content-Description: btilen.txt
 Content-Disposition: attachment; filename="btilen.txt"

 Index: ubt.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/ubt.c,v
 retrieving revision 1.19
 diff -u -p -r1.19 ubt.c
 --- ubt.c	12 Oct 2006 01:31:59 -0000	1.19
 +++ ubt.c	17 Nov 2006 18:08:44 -0000
 @@ -832,7 +832,7 @@ ubt_enable(struct hci_unit *unit)
  				  &sc->sc_evt_pipe,
  				  sc,
  				  sc->sc_evt_buf,
 -				  UBT_BUFSIZ_EVENT,
 +				  16 /*UBT_BUFSIZ_EVENT*/,
  				  ubt_recv_event,
  				  UBT_EVENT_INTERVAL);
  	if (err != USBD_NORMAL_COMPLETION) {

 --==_Exmh_13776008535290--

From: Berndt Josef Wulf <wulf@ping.net.au>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, wulf@netbsd.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily  unavailable
Date: Sat, 18 Nov 2006 11:19:50 +1030

 This got me further too, but issuing btconfig ubt0 inquery will cause kernel 
 panic.

 cheerio Berndt

 On Saturday 18 November 2006 04:55, Matthias Drochner wrote:
 > The following reply was made to PR kern/34070; it has been noted by GNATS.
 >
 > From: Matthias Drochner <M.Drochner@fz-juelich.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
 > 	netbsd-bugs@NetBSD.org, wulf@NetBSD.org, plunky@rya-online.net
 > Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily
 >  unavailable
 > Date: Fri, 17 Nov 2006 19:20:29 +0100
 >
 >  This is a multipart MIME message.
 >
 >  --==_Exmh_13776008535290
 >  Content-Type: text/plain; charset=us-ascii
 >
 >
 >  With the appended patch the ubt initializes for me, even if usb2/ehci
 >  is used by the host controller.
 >  The "16" happens to be the "wMaxPacketSize" in the endpoint descriptor;
 >  I'm not sure yet whether it should be the driver's duty to check that
 >  or the framework should care.
 >  I'm also not sure whether the builtin Dell hub is somehow limited or
 >  the translation problems are to be expected under the timing/size
 > conditions imposed by the ubt driver.
 >
 >  best regards
 >  Matthias
 >
 >
 >
 >  --==_Exmh_13776008535290
 >  Content-Type: text/plain ; name="btilen.txt"; charset=us-ascii
 >  Content-Description: btilen.txt
 >  Content-Disposition: attachment; filename="btilen.txt"
 >
 >  Index: ubt.c
 >  ===================================================================
 >  RCS file: /cvsroot/src/sys/dev/usb/ubt.c,v
 >  retrieving revision 1.19
 >  diff -u -p -r1.19 ubt.c
 >  --- ubt.c	12 Oct 2006 01:31:59 -0000	1.19
 >  +++ ubt.c	17 Nov 2006 18:08:44 -0000
 >  @@ -832,7 +832,7 @@ ubt_enable(struct hci_unit *unit)
 >   				  &sc->sc_evt_pipe,
 >   				  sc,
 >   				  sc->sc_evt_buf,
 >  -				  UBT_BUFSIZ_EVENT,
 >  +				  16 /*UBT_BUFSIZ_EVENT*/,
 >   				  ubt_recv_event,
 >   				  UBT_EVENT_INTERVAL);
 >   	if (err != USBD_NORMAL_COMPLETION) {
 >
 >  --==_Exmh_13776008535290--


 Thanks for the patch. This works for me too!

 barossa: {3} btconfig -l
 ubt0
 barossa: {4} btconfig ubt0
 ubt0: bdaddr 00:16:41:57:68:6a flags 0x3<UP,RUNNING>
         num_cmd = 1
         num_acl = 8, acl_mtu = 384
         num_sco = 8, sco_mtu = 64


 cheerio Berndt

From: Iain Hibbert <plunky@rya-online.net>
To: Matthias Drochner <M.Drochner@fz-juelich.de>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Sat, 18 Nov 2006 00:07:40 +0000 (GMT)

 On Fri, 17 Nov 2006, Matthias Drochner wrote:

 > With the appended patch the ubt initializes for me, even if usb2/ehci
 > is used by the host controller.

 yaay

 > The "16" happens to be the "wMaxPacketSize" in the endpoint descriptor;
 > I'm not sure yet whether it should be the driver's duty to check that
 > or the framework should care.

 That is a good question - currently ubt provides an event buffer with the
 size that is the maximum Bluetooth event packet size and let the usb stack
 fill it in.  The wMaxPacketSize will so far as I know be the maximum USB
 packet size, so if we only allow for that then we need to cater for
 partial Bluetooth packets as some are going to overflow (see hci.h) ..
 what happens with this patch for instance when doing a 'btconfig -vvvv' ?
 eg, the Read_Local_Name response packet in particular is I think 256 bytes..

 I would say though, that since the uhci code does automatically catenate
 USB packets into a single transfer (the bluetooth packet), the ehci code
 should do that properly also..

 > I'm also not sure whether the builtin Dell hub is somehow limited or
 > the translation problems are to be expected under the timing/size conditions
 > imposed by the ubt driver.

 iain

From: Berndt Josef Wulf <wulf@ping.net.au>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily  unavailable
Date: Sat, 18 Nov 2006 11:52:53 +1030

 Some more info on the kernel panic:

 panic: m_copydata: m==NULL,len1
 stopped at netbsd breakpoint+0x4: popl %ebn

 debug trace output:

 hci_event_inquiry_result(c217418,de77e00,da2ff08,0) at netbsd: 
 hci_event_inquiry_result+0x110
 hci_event(...)
 hci_intr + 0xc0
 [...]

From: Berndt Josef Wulf <wulf@ping.net.au>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, wulf@netbsd.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily unavailable
Date: Tue, 21 Nov 2006 02:59:49 +1030

 On Friday 17 November 2006 05:40, Iain Hibbert wrote:
 > The following reply was made to PR kern/34070; it has been noted by GNATS.
 >
 > From: Iain Hibbert <plunky@rya-online.net>
 > To: Berndt Josef Wulf <bwulf@ping.net.au>
 > Cc: gnats-bugs@netbsd.org
 > Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily
 >  unavailable
 > Date: Thu, 16 Nov 2006 19:07:19 +0000 (GMT)
 >
 >  Hi Berndt,
 >            This issue is cropping up again with somebody else (Matthias
 >  Drochner has a new laptop with the Dell 350 bluetooth module) and he did
 >  somehow disable EHCI in the bios (downgrades USB to v1) and it appears to
 >  make the bluetooth dongle work - can you try that by chance?
 >
 >  This would appear to confirm my thought that the problem is somehow in the
 >  EHCI layer rather than the ubt driver..
 >
 >  iain

 Hi Iain,


 No such luck. There is an option to disable USB emulation after POST, but this 
 didn't make any difference.

 cheerio Berndt

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: Iain Hibbert <plunky@rya-online.net>
Cc: Matthias Drochner <M.Drochner@fz-juelich.de>,
	gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Tue, 21 Nov 2006 18:09:10 +0100

 plunky@rya-online.net said:
 > ubt provides an event buffer with the size that is the maximum
 > Bluetooth event packet size and let the usb stack fill it in

 This is definitely correct -- the USB spec (ch. 5.7.3) explicitely
 mentions the case that an interrupt transfer (the term "transfer"
 is used inconsistently) involves multiple transactions where all
 but the last have the maximum payload size.

 > what happens with this patch for instance when doing a 'btconfig -vvvv' ?
 > eg, the Read_Local_Name response packet in particular is I think 256 bytes..

 Yep, the device name gets truncated.
 Using the packet size of 16 at the driver request level is
 certainly not right. Reassembly should be done by the USB host
 adapter layer. Remains the question why transfers which consist
 of one USB packet get through while larger ones don't.

 > I would say though, that since the uhci code does automatically catenate
 > USB packets into a single transfer (the bluetooth packet), the ehci code
 > should do that properly also..

 As I understand it, the EHCI hardware is supposed to do that automatically.
 See the description of the "queue head" and the "queue element transfer
 descriptor" (ch 3.6/3.5) in the EHCI spec.
 It might be that the desciptors are not filled in correctly, or that
 there is a bug in interrupt handling which makes that the response
 is ignored, or something with the data toggle handshake, or with
 the translation...

 best regards
 Matthias

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: Berndt Josef Wulf <wulf@ping.net.au>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Tue, 21 Nov 2006 18:10:53 +0100

 wulf@ping.net.au said:
 > There is an option to disable USB emulation after POST, but this
 > didn't make any difference.

 Did you try to disable ehci in the kernel (by userconf or rebuild)?

 best regards
 Matthias

From: Iain Hibbert <plunky@rya-online.net>
To: Matthias Drochner <M.Drochner@fz-juelich.de>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Tue, 21 Nov 2006 20:11:10 +0000 (GMT)

 On Tue, 21 Nov 2006, Matthias Drochner wrote:

 >
 > plunky@rya-online.net said:
 > > ubt provides an event buffer with the size that is the maximum
 > > Bluetooth event packet size and let the usb stack fill it in
 >
 > This is definitely correct -- the USB spec (ch. 5.7.3) explicitely
 > mentions the case that an interrupt transfer (the term "transfer"
 > is used inconsistently) involves multiple transactions where all
 > but the last have the maximum payload size.
 >
 > > what happens with this patch for instance when doing a 'btconfig -vvvv' ?
 > > eg, the Read_Local_Name response packet in particular is I think 256 bytes..
 >
 > Yep, the device name gets truncated.
 > Using the packet size of 16 at the driver request level is
 > certainly not right. Reassembly should be done by the USB host
 > adapter layer. Remains the question why transfers which consist
 > of one USB packet get through while larger ones don't.
 >
 > > I would say though, that since the uhci code does automatically catenate
 > > USB packets into a single transfer (the bluetooth packet), the ehci code
 > > should do that properly also..
 >
 > As I understand it, the EHCI hardware is supposed to do that automatically.
 > See the description of the "queue head" and the "queue element transfer
 > descriptor" (ch 3.6/3.5) in the EHCI spec.
 > It might be that the desciptors are not filled in correctly, or that
 > there is a bug in interrupt handling which makes that the response
 > is ignored, or something with the data toggle handshake, or with
 > the translation...

 I'm looking at the FreeBSD CVS log for ehci.c and I see this commit
 mentioned:

   Revision 1.30 / (download) - annotate - [select for diffs], Tue Mar 8
   02:47:18 2005 UTC (20 months, 2 weeks ago) by iedowse
   Branch: MAIN
   Changes since 1.29: +3 -5 lines
   Diff to previous 1.29 (colored)

   Fix the silly bug that prevented most EHCI interrupt transfers from
   ever working correctly: the code was linking the QHs together but
   then immediately overwriting the "next" pointers. Oops. Also
   initialise qh_endphub, since the EHCI spec says that we should
   always set the pipe multiplier field to something sensible.

   This appears to make basic split transactions work, so enable split
   transactions for control, bulk and interrupt pipes (split isochronous
   transfers are not yet implemented). It should now be possible to
   use USB1 devices even when they are connected through a USB2 hub.

 So, I'm not really sure that this is relevant but it sounds plausible.
 From their diff below, I see that the removal of "sqh->next = NULL" has
 not happened on NetBSD and I wonder if this can be the problem? The
 comment at least does apply as next has previously been set..

 iain

 ===================================================================
 RCS file: /usr/local/www/cvsroot/FreeBSD/src/sys/dev/usb/ehci.c,v
 retrieving revision 1.29
 retrieving revision 1.30
 diff -u -p -r1.29 -r1.30
 --- src/sys/dev/usb/ehci.c	2005/01/09 23:49:45	1.29
 +++ src/sys/dev/usb/ehci.c	2005/03/08 02:47:18	1.30
 @@ -65,7 +65,7 @@
  */

  #include <sys/cdefs.h>
 -__FBSDID("$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/dev/usb/ehci.c,v 1.29 2005/01/09 23:49:45 julian Exp $");
 +__FBSDID("$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/dev/usb/ehci.c,v 1.30 2005/03/08 02:47:18 iedowse Exp $");

  #include <sys/param.h>
  #include <sys/systm.h>
 @@ -451,9 +451,8 @@ ehci_init(ehci_softc_t *sc)
  			    EHCI_LINK_QH);
  		}
  		sqh->qh.qh_endp = htole32(EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH));
 -		sqh->qh.qh_link = EHCI_NULL;
 +		sqh->qh.qh_endphub = htole32(EHCI_QH_SET_MULT(1));
  		sqh->qh.qh_curqtd = EHCI_NULL;
 -		sqh->next = NULL;
  		sqh->qh.qh_qtd.qtd_next = EHCI_NULL;
  		sqh->qh.qh_qtd.qtd_altnext = EHCI_NULL;
  		sqh->qh.qh_qtd.qtd_status = htole32(EHCI_QTD_HALTED);
 @@ -1408,14 +1407,13 @@ ehci_open(usbd_pipe_handle pipe)
  	case USB_SPEED_HIGH: speed = EHCI_QH_SPEED_HIGH; break;
  	default: panic("ehci_open: bad device speed %d", dev->speed);
  	}
 -	if (speed != EHCI_QH_SPEED_HIGH) {
 +	if (speed != EHCI_QH_SPEED_HIGH && xfertype == UE_ISOCHRONOUS) {
  		printf("%s: *** WARNING: opening low/full speed device, this "
  		       "does not work yet.\n",
  		       USBDEVNAME(sc->sc_bus.bdev));
  		DPRINTFN(1,("ehci_open: hshubaddr=%d hshubport=%d\n",
  			    hshubaddr, hshubport));
 -		if (xfertype != UE_CONTROL)
 -			return USBD_INVAL;
 +		return USBD_INVAL;
  	}

  	naks = 8;		/* XXX */

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: Iain Hibbert <plunky@rya-online.net>
Cc: Matthias Drochner <M.Drochner@fz-juelich.de>,
	gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Tue, 21 Nov 2006 21:53:57 +0100

 plunky@rya-online.net said:
 [FreeBSD]
 >   Fix the silly bug that prevented most EHCI interrupt transfers from
 >   ever working correctly: the code was linking the QHs together but
 >   then immediately overwriting the "next" pointers

 This might corrspond to NetBSD's
 revision 1.92
 date: 2005/04/27 02:12:20;  author: augustss;  state: Exp;  lines: +2 -3
 Don't null the qh_link point in the interrupt tree after it has been
 initialized.  From Dan Ellis in kern/30003.

 I don't think this is the problem. I believe now that the data toggle
 stuff is buggy. If I comment out the code after
 	/*
 	 * For a short transfer we need to update the toggle for the missing
 	 * packets within the qTD.
 	 */
 in the interrupt handler, the adapter initializes. If I try "btconfig -vvvv",
 it hangs, so it seems that transfers up to 16 bytes work which is more
 or less the same effect as I had before with the pipe size of 16.
 The code above looks bogus - I can't imagine how transactions which are
 not executed could contribute to the state of the data toggle protocol.
 To understand more I need to have a more thourough look at the specs.

 best regards
 Matthias

From: Iain Hibbert <plunky@rya-online.net>
To: Matthias Drochner <M.Drochner@fz-juelich.de>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Tue, 21 Nov 2006 21:45:10 +0000 (GMT)

 On Tue, 21 Nov 2006, Matthias Drochner wrote:

 >
 > plunky@rya-online.net said:
 > [FreeBSD]
 > >   Fix the silly bug that prevented most EHCI interrupt transfers from
 > >   ever working correctly: the code was linking the QHs together but
 > >   then immediately overwriting the "next" pointers
 >
 > This might corrspond to NetBSD's
 > revision 1.92
 > date: 2005/04/27 02:12:20;  author: augustss;  state: Exp;  lines: +2 -3
 > Don't null the qh_link point in the interrupt tree after it has been
 > initialized.  From Dan Ellis in kern/30003.

 Hm, yes - that is part of it, though the treatment of sqh->next still
 seems awry to me. However, I have zero understanding of the ehci
 internals, I should look at the specs..

 iain

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: Iain Hibbert <plunky@rya-online.net>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Fri, 24 Nov 2006 11:54:46 +0100

 This is a multipart MIME message.

 --==_Exmh_7070402042130
 Content-Type: text/plain; charset=us-ascii


 OK, another try...

 [data toggle code in ehci.c]
 M.Drochner@fz-juelich.de said:
 > The code above looks bogus - I can't imagine how transactions which
 > are not executed could contribute to the state of the data toggle
 > protocol. 

 Now I understand that that code (partially) rolls back a data toggle
 pre-computation in ehci_alloc_sqtd_chain().
 There is an obvious flaw however: It doesn't care about alignment
 wrt wMaxPacketSize, so it will miss a packet under some conditions.
 I'm not so eager to mess with that code right now, but I see an easy
 workaround which is at least good to prove that theory: Allocate
 transfer buffers in multiples of wMaxPacketSize.
 With the appended patch my ubt initializes, and an "btconfig -vvv"
 finishes successfully.

 best regards
 Matthias



 --==_Exmh_7070402042130
 Content-Type: text/plain ; name="ubtalign.txt"; charset=us-ascii
 Content-Description: ubtalign.txt
 Content-Disposition: attachment; filename="ubtalign.txt"

 Index: ubt.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/ubt.c,v
 retrieving revision 1.20
 diff -u -p -r1.20 ubt.c
 --- ubt.c	16 Nov 2006 01:33:26 -0000	1.20
 +++ ubt.c	24 Nov 2006 10:38:31 -0000
 @@ -151,7 +151,7 @@ SYSCTL_SETUP(sysctl_hw_ubt_debug_setup, 
   */
  #define UBT_BUFSIZ_CMD		(HCI_CMD_PKT_SIZE - 1)
  #define UBT_BUFSIZ_ACL		(2048 - 1)
 -#define UBT_BUFSIZ_EVENT	(HCI_EVENT_PKT_SIZE - 1)
 +#define UBT_BUFSIZ_EVENT	272 /*(HCI_EVENT_PKT_SIZE - 1)*/

  /* Interrupt Interval from (Bluetooth spec) */
  #define UBT_EVENT_INTERVAL	1	/* 1ms */

 --==_Exmh_7070402042130--

From: Iain Hibbert <plunky@rya-online.net>
To: Matthias Drochner <M.Drochner@fz-juelich.de>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Sat, 25 Nov 2006 09:32:02 +0000 (GMT)

 On Fri, 24 Nov 2006, Matthias Drochner wrote:

 > [data toggle code in ehci.c]
 > M.Drochner@fz-juelich.de said:
 > > The code above looks bogus - I can't imagine how transactions which
 > > are not executed could contribute to the state of the data toggle
 > > protocol.
 >
 > Now I understand that that code (partially) rolls back a data toggle
 > pre-computation in ehci_alloc_sqtd_chain().

 > There is an obvious flaw however: It doesn't care about alignment
 > wrt wMaxPacketSize, so it will miss a packet under some conditions.

 > I'm not so eager to mess with that code right now, but I see an easy
 > workaround which is at least good to prove that theory: Allocate
 > transfer buffers in multiples of wMaxPacketSize.

 > With the appended patch my ubt initializes, and an "btconfig -vvv"
 > finishes successfully.

 Why 272, does 256 work?  HCI_EVENT_PKT_SIZE is 256 - I only subtract the 1
 because USB adaptors do not provide the type octet, but it does not really
 matter if an extra byte is allocated.

 Not that I can suggest masking such a bug by conforming to a hidden magic
 number (I wonder if 16 is a generally used value)

 iain

From: Iain Hibbert <plunky@rya-online.net>
To: Matthias Drochner <M.Drochner@fz-juelich.de>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Sat, 25 Nov 2006 17:56:42 +0000 (GMT)

 On Sat, 25 Nov 2006, Iain Hibbert wrote:

 > Why 272, does 256 work?  HCI_EVENT_PKT_SIZE is 256

 Sigh. Of course, that is wrong .. I forget the header.

 iain

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: Iain Hibbert <plunky@rya-online.net>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Mon, 27 Nov 2006 21:18:27 +0100

 This is a multipart MIME message.

 --==_Exmh_12748434162970
 Content-Type: text/plain; charset=us-ascii


 plunky@rya-online.net said:
 > Not that I can suggest masking such a bug by conforming to a hidden
 > magic number (I wonder if 16 is a generally used value) 

 I think I have a fix which is not too invasive but still
 halfway clean: kill the code which tries to compute the
 toggle after a short transfer. To fix it to deal with block
 alignment would make it even more expensive; reading
 the updated toggle from the descriptor is cheaper imho.
 The appended patch makes ubt work as far as I could check
 without a device.

 best regards
 Matthias



 --==_Exmh_12748434162970
 Content-Type: text/plain ; name="ehci.txt"; charset=us-ascii
 Content-Description: ehci.txt
 Content-Disposition: attachment; filename="ehci.txt"

 # 
 # 
 # patch "sys/dev/usb/ehci.c"
 #  from [9719bcf04cebd0079d8570b78d59c267164aa1d1]
 #    to [7ae22e8f8c034f1a4b891e85526ec1e137128a51]
 # 
 ============================================================
 --- sys/dev/usb/ehci.c	9719bcf04cebd0079d8570b78d59c267164aa1d1
 +++ sys/dev/usb/ehci.c	7ae22e8f8c034f1a4b891e85526ec1e137128a51
 @@ -773,7 +773,6 @@ ehci_idone(struct ehci_xfer *ex)
  	ehci_soft_qtd_t *sqtd, *lsqtd;
  	u_int32_t status = 0, nstatus = 0;
  	int actlen;
 -	uint pkts_left;

  	DPRINTFN(/*12*/2, ("ehci_idone: ex=%p\n", ex));
  #ifdef DIAGNOSTIC
 @@ -823,10 +822,13 @@ ehci_idone(struct ehci_xfer *ex)
  	 * If there are left over TDs we need to update the toggle.
  	 * The default pipe doesn't need it since control transfers
  	 * start the toggle at 0 every time.
 +	 * For a short transfer we need to update the toggle for the missing
 +	 * packets within the qTD.
  	 */
 -	if (sqtd != lsqtd->nextqtd &&
 +	if ((sqtd != lsqtd->nextqtd || EHCI_QTD_GET_BYTES(status)) &&
  	    xfer->pipe->device->default_pipe != xfer->pipe) {
 -		printf("ehci_idone: need toggle update status=%08x nstatus=%08x\n", status, nstatus);
 +		DPRINTFN(2, ("ehci_idone: need toggle update "
 +			     "status=%08x nstatus=%08x\n", status, nstatus));
  #if 0
  		ehci_dump_sqh(epipe->sqh);
  		ehci_dump_sqtds(ex->sqtdstart);
 @@ -834,14 +836,6 @@ ehci_idone(struct ehci_xfer *ex)
  		epipe->nexttoggle = EHCI_QTD_GET_TOGGLE(nstatus);
  	}

 -	/*
 -	 * For a short transfer we need to update the toggle for the missing
 -	 * packets within the qTD.
 -	 */
 -	pkts_left = EHCI_QTD_GET_BYTES(status) /
 -	    UGETW(xfer->pipe->endpoint->edesc->wMaxPacketSize);
 -	epipe->nexttoggle ^= pkts_left % 2;
 -
  	DPRINTFN(/*10*/2, ("ehci_idone: len=%d, actlen=%d, status=0x%x\n",
  			   xfer->length, actlen, status));
  	xfer->actlen = actlen;

 --==_Exmh_12748434162970--

From: Iain Hibbert <plunky@rya-online.net>
To: Matthias Drochner <M.Drochner@fz-juelich.de>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Tue, 28 Nov 2006 19:42:36 +0000 (GMT)

 On Mon, 27 Nov 2006, Matthias Drochner wrote:

 > I think I have a fix which is not too invasive but still
 > halfway clean: kill the code which tries to compute the
 > toggle after a short transfer. To fix it to deal with block
 > alignment would make it even more expensive; reading
 > the updated toggle from the descriptor is cheaper imho.
 > The appended patch makes ubt work as far as I could check
 > without a device.

 This patch does seem to my eyes a simple and worthy fix.

 Do you have any other USB hardware running through the ehci driver? I'm a
 bit concerned that it looks as if this would affect all ehci transfers, so
 surely there would have been other failures reported..?

 iain

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: Iain Hibbert <plunky@rya-online.net>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org, wulf@NetBSD.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily 
 unavailable
Date: Tue, 28 Nov 2006 21:41:27 +0100

 plunky@rya-online.net said:
 > Do you have any other USB hardware running through the ehci driver?

 I've tried a mouse and an external harddisk, both still work.

 > I'm a
 > bit concerned that it looks as if this would affect all ehci transfers, so
 > surely there would have been other failures reported..?

 The change does only affect "short transfers", this is where the
 length of the read transfer isn't known in advance. I didn't check
 all the drivers in detail, but usually the length is known -- eg
 the report size for HIDs or the transfer size for mass storage.
 In addition, the bug causing the hangs did only strike if the
 difference between the attempted and the real transfer crossed
 a blocksize boundary, which at least requires that the attempted
 transfer is larger than the blocksize.
 In addition, full/low speed devices do only touch ehci if there
 is a high-speed hub in between.
 This all makes it prety plausible for me that there were no
 bug reports before.

 I'll just commit that change; it is small enough to have it
 backed out if serious problems show up.

 best regards
 Matthias

From: Matthias Drochner <drochner@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/34070 CVS commit: src/sys/dev/usb
Date: Tue, 28 Nov 2006 20:58:12 +0000 (UTC)

 Module Name:	src
 Committed By:	drochner
 Date:		Tue Nov 28 20:58:12 UTC 2006

 Modified Files:
 	src/sys/dev/usb: ehci.c

 Log Message:
 Remove the code which tried to guess the toggle bit after a short
 transfer. It was wrong because it didn't consider block boundaries.
 Instead, use the updated toggle from the transfer descriptor -- this
 is supposedly cheaper than modulo arithmetics.
 This fixes a problem similar to PR kern/34070 for me.


 To generate a diff of this commit:
 cvs rdiff -r1.116 -r1.117 src/sys/dev/usb/ehci.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Berndt Josef Wulf <wulf@ping.net.au>
To: M.Drochner@fz-juelich.de
Cc: Iain Hibbert <plunky@rya-online.net>, gnats-bugs@netbsd.org,
	kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, wulf@netbsd.org
Subject: Re: kern/34070: btconfig: SIOCSBTFLAGS: Resource temporarily  unavailable
Date: Wed, 29 Nov 2006 23:57:00 +1030

 On Tuesday 28 November 2006 06:48, Matthias Drochner wrote:
 > plunky@rya-online.net said:
 > > Not that I can suggest masking such a bug by conforming to a hidden
 > > magic number (I wonder if 16 is a generally used value)
 >
 > I think I have a fix which is not too invasive but still
 > halfway clean: kill the code which tries to compute the
 > toggle after a short transfer. To fix it to deal with block
 > alignment would make it even more expensive; reading
 > the updated toggle from the descriptor is cheaper imho.
 > The appended patch makes ubt work as far as I could check
 > without a device.
 >
 > best regards
 > Matthias

 Hi Matthias,

 I can confirm your patch working as far as the detection of BT devices is 
 concerned - see example below:

 barossa: {79} btconfig ubt0
 ubt0: bdaddr 00:16:41:57:68:6a flags 0x3<UP,RUNNING>
         num_cmd = 1
         num_acl = 8, acl_mtu = 384
         num_sco = 8, sco_mtu = 64
 barossa: {80} btconfig ubt0 inquiry
 Device Discovery from device: ubt0 .... 1 response
   1: bdaddr 06:10:09:d1:91:8a
    : name "Samsung WEP200"
    : class: [0x200404] Wearable Headset <Audio>
    : page scan rep mode 0x01
    : page scan period mode 0x02
    : page scan mode 0x00
    : clock offset 13339

 I'll test a BT mouse and keyboard at work tomorrow. Its looking very promising 
 sofar!!!

 Thanks,

 cheerio Berndt

State-Changed-From-To: open->closed
State-Changed-By: drochner@netbsd.org
State-Changed-When: Fri, 08 Dec 2006 18:33:10 +0000
State-Changed-Why:
the ehci toggle bit change fixed it for Berndt and me


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.