Subject: Re: btconfig: SIOCSBTFLAGS: Resource temporarily unavailable
To: Berndt Josef Wulf <wulf@ping.net.au>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-kern
Date: 07/16/2006 17:29:53
On Sun, 16 Jul 2006, Berndt Josef Wulf wrote:

> Jul 16 21:50:52  /netbsd: ubt_enable: sc=0xc1f89400
> Jul 16 21:50:52  /netbsd: ubt_recv_acl_start: sc=0xc1f89400
> Jul 16 21:50:52  /netbsd: hci_send_cmd: (ubt0) opcode (004|0009)
> Jul 16 21:50:52  /netbsd: hci_output_cmd: (ubt0) num_cmd_pkts=1
> Jul 16 21:50:52  /netbsd: ubt_xmit_cmd_start: ubt0: xmit CMD packet (4 bytes)
> Jul 16 21:50:52  /netbsd: hci_send_cmd: (ubt0) opcode (004|0005)
> Jul 16 21:50:52  /netbsd: hci_send_cmd: (ubt0) opcode (004|0003)
> Jul 16 21:50:52  /netbsd: ubt_xmit_cmd_complete: ubt0: CMD complete
> status=NORMAL_COMPLETION (0)
> Jul 16 21:50:52  /netbsd: ubt_recv_event: sc=0xc1f89400
> status=NORMAL_COMPLETION (0)
> Jul 16 21:50:52  /netbsd: hci_intr: (ubt0) recv event, len = 13
> Jul 16 21:50:52  /netbsd: hci_event: (ubt0) event COMMAND COMPLETE
> Jul 16 21:50:52  /netbsd: hci_event_command_compl: (ubt0) opcode (004|0009)
> num_cmd_pkts = 1
> Jul 16 21:50:52  /netbsd: hci_output_cmd: (ubt0) num_cmd_pkts=1
> Jul 16 21:50:52  /netbsd: ubt_xmit_cmd_start: ubt0: xmit CMD packet (4 bytes)
> Jul 16 21:50:52  /netbsd: hci_intr: done
> Jul 16 21:50:52  /netbsd: ubt_xmit_cmd_complete: ubt0: CMD complete
> status=NORMAL_COMPLETION (0)
> Jul 16 21:50:53  /netbsd: ubt_disable: sc=0xc1f89400
>
> How about that.... ;-)

Well thats good, though it leaves me with no clue as I can't see anything
going wrong..  The first command is sent and a response received, then the
second command is sent and appears to have been sent properly (we get
ubt_xmit_cmd_complete with NORMAL_COMPLETION) but no event is received to
indicate that the controller received and processed it. We may not send
any more commands until we receive notification that the buffer is clear,
so nothing more happens until the timeout wakes us up.

So, I'm uncertain if the problem is in the transmit or receive path but
both work fine with uhci, so my feeling points to the ehci code (which
notes incompleteness in the manpage and source file both) or the
combination of something I have not done but uhci does not need.

If you were feeling brave, you could enable EHCI_DEBUG but I'm not sure if
that would be useful. I dont have the expertise to interpret it, does
anybody else? You may need to send-pr this.

> I also noticed that when "btconfig ubt0 up" is issued the first time hcidump
> shows:
>
> < HCI Command: Read BD ADDR(0x04|0x0009) plen 0
> > HCI Event: Command Complete(0x0e) plen 10
> < HCI Command: Read Buffer Size(0x04|0x0005) plen 0
>
> however on second time
>
> < HCI Command: Read BD ADDR(0x04|0x0009) plen 0
> > HCI Event: Command Complete(0x0e) plen 10
> < HCI Command: Read Local Supported Features(0x04|0x0003) plen 0

That would be because the Read_Local_Supported_Features command got left
on the queue when the enable failed. Technically a bug though it wont
happen unless the device doesnt work and would be flushed on detach.

iain