Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [Unstrung-hackers] [RFC net-next] ipv6: ext_header: add function to handle RPL extension header option 0x63
From: Andreas Bardoutsos @ 2017-05-05  7:55 UTC (permalink / raw)
  To: JANARDHANACHARI KELLA
  Cc: Jiri Pirko, Michael Richardson, netdev, netdev-owner,
	linux-bluetooth, linux-wpan, unstrung-hackers
In-Reply-To: <CAAK7Ti9iFFqM7vMyveNfaNeCi6PmAGptXdTYgEzh2gsMptqi4w@mail.gmail.com>

Yes I think we have faced the same problem,communication with RPL 
supporting devices was failing otherwise.Your patch is also more 
complete since it also implements #ifdef .About the comment,yes I have 
run checkpatch twice with no errors,but ok :)

Στις 2017-05-05 08:59, JANARDHANACHARI KELLA έγραψε:
> I was inserted this patch manually. It was working. on 4.9 kernel.
> 
> check this bellow link for your ref.
> 
> https://github.com/mwasilak/bluetooth-next/commit/f29c632ef6a6a1777815c97fd2f326faccc704f7
> [2]
> 
> On Thu, May 4, 2017 at 9:30 PM, Jiri Pirko <jiri@resnulli.us> wrote:
> 
>> Thu, May 04, 2017 at 05:17:18PM CEST, bardoutsos@ceid.upatras.gr
>> wrote:
>>> Signed-off-by: Andreas Bardoutsos <bardoutsos@ceid.upatras.gr>
>>> ---
>>> Hi all!
>>> 
>>> I have added a dump function(always return true) to recognise RPL
>> extension
>>> header(RFC6553)
>>> Otherwise packet was dropped by kernel resulting in failing
>> communication in
>>> RPL DAG's between
>>> linux running border routers and devices in the graph.For example
>>> communication
>>> with contiki OS running devices was previously impossible.
>>> 
>>> include/uapi/linux/in6.h | 1 +
>>> net/ipv6/exthdrs.c | 13 +++++++++++++
>>> 2 files changed, 14 insertions(+)
>>> 
>>> diff --git a/include/uapi/linux/in6.h b/include/uapi/linux/in6.h
>>> index 46444f8fbee4..5cc12d309dfe 100644
>>> --- a/include/uapi/linux/in6.h
>>> +++ b/include/uapi/linux/in6.h
>>> @@ -146,6 +146,7 @@ struct in6_flowlabel_req {
>>> #define IPV6_TLV_CALIPSO 7 /* RFC 5570 */
>>> #define IPV6_TLV_JUMBO 194
>>> #define IPV6_TLV_HAO 201 /* home address option */
>>> +#define IPV6_TLV_RPL 99 /* RFC 6553 */
>>> 
>>> /*
>>> * IPV6 socket options
>>> diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
>>> index b636f1da9aec..82ed60d3180e 100644
>>> --- a/net/ipv6/exthdrs.c
>>> +++ b/net/ipv6/exthdrs.c
>>> @@ -785,6 +785,15 @@ static bool ipv6_hop_calipso(struct sk_buff
>> *skb, int
>>> optoff)
>>> return false;
>>> }
>>> 
>>> +/* RPL RFC 6553 */
>>> +
>>> +static bool ipv6_hop_rpl(struct sk_buff *skb, int optoff)
>>> +{
>>> + /*Dump function which always return true
>>> + *when rpl option is detected*/
>> 
>> This is definitelly wrong formatting of comment. Did you run
>> checkpatch?
>> 
>>> + return true;
>>> +}
>>> +
>>> static const struct tlvtype_proc tlvprochopopt_lst[] = {
>>> {
>>> .type = IPV6_TLV_ROUTERALERT,
>>> @@ -798,6 +807,10 @@ static const struct tlvtype_proc
>> tlvprochopopt_lst[] = {
>>> .type = IPV6_TLV_CALIPSO,
>>> .func = ipv6_hop_calipso,
>>> },
>>> + {
>>> + .type = IPV6_TLV_RPL,
>>> + .func = ipv6_hop_rpl,
>>> + },
>>> { -1, }
>>> };
>>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe
>> linux-wpan" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> [1]
> 
> --
> 
> Sincerely Your's
> 
> Janardhanachari Kella
> 
> Contact:+91-9908469599
> E-mail: eni.chari@gmail.com
> 
> 
> Links:
> ------
> [1] http://vger.kernel.org/majordomo-info.html
> [2]
> https://github.com/mwasilak/bluetooth-next/commit/f29c632ef6a6a1777815c97fd2f326faccc704f7
> 
> _______________________________________________
> Unstrung-hackers mailing list
> Unstrung-hackers@lists.sandelman.ca
> https://lists.sandelman.ca/mailman/listinfo/unstrung-hackers


^ permalink raw reply

* Re: [PATCH 0/4] TI Bluetooth serdev support
From: Adam Ford @ 2017-05-05 14:51 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Rob Herring, Marcel Holtmann, linux-bluetooth, Mark Rutland,
	devicetree, Johan Hedberg, Gustavo Padovan, Satish Patel, Wei Xu,
	Eyal Reizer, netdev, linux-arm-kernel
In-Reply-To: <20170430160430.rmyuo6sdrkrjxjg6@earth>

On Sun, Apr 30, 2017 at 11:04 AM, Sebastian Reichel <sre@kernel.org> wrote:
> Hi,
>
> On Sun, Apr 30, 2017 at 10:14:20AM -0500, Adam Ford wrote:
>> On Wed, Apr 5, 2017 at 1:30 PM, Rob Herring <robh@kernel.org> wrote:
>> > This series adds serdev support to the HCI LL protocol used on TI BT
>> > modules and enables support on HiKey board with with the WL1835 module.
>> > With this the custom TI UIM daemon and btattach are no longer needed.
>>
>> Without UIM daemon, what instruction do you use to load the BT firmware?
>>
>> I was thinking 'hciattach' but I was having trouble.  I was hoping you
>> might have some insight.
>>
>>  hciattach -t 30 -s 115200 /dev/ttymxc1 texas 3000000 flow  Just
>> returns a timeout.
>>
>> I modified my i.MX6 device tree per the binding documentation and
>> setup the regulators and enable GPIO pins.
>
> If you configured everything correctly no userspace interaction is
> required. The driver should request the firmware automatically once
> you power up the bluetooth device.
>
> Apart from DT changes make sure, that the following options are
> enabled and check dmesg for any hints.
>
> CONFIG_SERIAL_DEV_BUS
> CONFIG_SERIAL_DEV_CTRL_TTYPORT
> CONFIG_BT_HCIUART
> CONFIG_BT_HCIUART_LL
>


I have enabled those flags, and I have updated my device tree.
I am testing this on an OMAP3630 (DM3730) board with a WL1283.  I am
getting a lot of timeout errors.  I tested this against the original
implemention I had in pdata-quirks.c using the ti-st driver, uim & and
the btwilink driver.

I pulled in some of the newer patches to enable the wl1283-st, but I
am obviously missing something.

I   58.717651] Bluetooth: hci0: Reading TI version information failed
(-110)
[   58.724853] Bluetooth: hci0: download firmware failed, retrying...
[   60.957641] Bluetooth: hci0 command 0x1001 tx timeout
[   68.957641] Bluetooth: hci0: Reading TI version information failed
(-110)
[   68.964843] Bluetooth: hci0: download firmware failed, retrying...
[   69.132171] Bluetooth: Unknown HCI packet type 06
[   69.138244] Bluetooth: Unknown HCI packet type 0c
[   69.143249] Bluetooth: Unknown HCI packet type 40
[   69.148498] Bluetooth: Unknown HCI packet type 20
[   69.153533] Bluetooth: Data length is too large
[   69.158569] Bluetooth: Unknown HCI packet type a0
[   69.163574] Bluetooth: Unknown HCI packet type 00
[   69.168731] Bluetooth: Unknown HCI packet type 00
[   69.173736] Bluetooth: Unknown HCI packet type 34
[   69.178924] Bluetooth: Unknown HCI packet type 91
[   71.197631] Bluetooth: hci0 command 0x1001 tx timeout
[   79.197662] Bluetooth: hci0: Reading TI version information failed (-110)

Since the pdata-quirks and original ti-st drivers work together, I
know the hardware is fine.  The only change to the device tree is the
addition of the Bluetooth container:

bluetooth {
  compatible = "ti,wl1283-st";
  enable-gpios = <&gpio6 2 GPIO_ACTIVE_HIGH>;
};

Any thoughts or suggestions to try?  I get similar behavior on an
i.MX6 board with a wl1837-st module as well.

adam
> -- Sebastian

^ permalink raw reply

* [PATCH V1 0/1] hci_ldisc: Use rwlocking to avoid closing proto races
From: Dean Jenkins @ 2017-05-05 15:27 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Dean Jenkins, Gustavo F . Padovan, Johan Hedberg, linux-bluetooth

Hi Marcel,

This is my 3rd patchset in my series of resolving a design flaw in
hci_uart_tty_close() related to the proper closure of the Data Link protocol
layer which can result in a kernel crash.

This patchset contains a single patch that adds rwlocking around the "proto"
function pointers. This provides a full fix to prevent a potential kernel crash
triggered by hu->proto->close() running before or during the execution of a
non-close "proto" function pointer.


Previous Discussions
====================

Please refer to the discussion on my 2nd patchset V1 that can be found here:
https://www.spinics.net/lists/linux-bluetooth/msg70370.html
You accepted the 3 patches of my patchset of commits namely:
  Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame()
  Bluetooth: hci_ldisc: Add protocol check to hci_uart_dequeue()
  Bluetooth: hci_ldisc: Add protocol check to hci_uart_tx_wakeup()

 drivers/bluetooth/hci_ldisc.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Please refer to the discussion on my 1st patchset V3 that can be found here:
https://www.spinics.net/lists/linux-bluetooth/msg70315.html
You accepted the 3 patches of my patchset of commits namely:
  Bluetooth: hci_ldisc: Add missing return in hci_uart_init_work()
  Bluetooth: hci_ldisc: Ensure hu->hdev set to NULL before freeing hdev
  Bluetooth: hci_ldisc: Add missing clear HCI_UART_PROTO_READY

 drivers/bluetooth/hci_ldisc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Please refer to the discussion on my 1st patchset V2 that can be found here:
https://www.spinics.net/lists/linux-bluetooth/msg70183.html

Please refer to the discussion on my 1st RFC patchset V1 that can be found here:
https://www.spinics.net/lists/linux-bluetooth/msg70077.html


Analysis
========

There are multiple threads that use "proto" function pointers that potentially
can be running concurrently with the thread of hci_uart_tty_close().

The threads include (not a complete list):

a) hci_uart_write_work() [hci_ldisc.c]
   which is executed by the work queue hu->write_work which creates the
   callstack:
   hci_uart_write_work()
   hci_uart_dequeue()
   hu->proto->dequeue()

b) hci_tx_work() [hci_core.c]
   which is executed by the work queue hdev->tx_work which creates the
   callstack:
   hci_tx_work()
   hci_send_frame()
   hdev->send()
   hci_uart_send_frame()
   hu->proto->enqueue()
   then calls
   hci_uart_tx_wakeup()
   schedule_work(&hu->write_work)
   triggering a)

c) hci_cmd_work() [hci_core.c]
   which is executed by the work queue hdev->cmd_work which creates the
   callstack:
   hci_cmd_work()
   hci_send_frame()
   hdev->send()
   hci_uart_send_frame()
   hu->proto->enqueue()
   then calls
   hci_uart_tx_wakeup()
   schedule_work(&hu->write_work)
   triggering a)

d) hci_dev_close() [hci_core.c]
   creates the callstack:
   hci_dev_close()
   hci_dev_do_close()
   hdev->flush()
   hci_uart_flush()
   hu->proto->flush()

e) When BCSP is used and a retransmission is needed:
   bcsp_timed_event() [hci_bcsp.c]
   creates the callstack:
   bcsp_timed_event()
   hci_uart_tx_wakeup()
   schedule_work(&hu->write_work)
   triggering a)


hci_ldisc.c: hci_uart_tty_close() currently has the construction:

	cancel_work_sync(&hu->write_work);

	if (test_and_clear_bit(HCI_UART_PROTO_READY, &hu->flags)) {
		if (hdev) {
			if (test_bit(HCI_UART_REGISTERED, &hu->flags))
				hci_unregister_dev(hdev);
			hci_free_dev(hdev);
		}
		hu->proto->close(hu);
	}

At first glance, the cancel_work_sync(&hu->write_work) would seem to inhibit
hci_uart_write_work() from running. Actually, the call to cancel_work_sync()
can be ineffective because:

a) hci_unregister_dev() calls hci_dev_do_close() and if HCI_UP flag is in the
   set state then it is possible for hci_dev_do_close() to send a HCI command.
   Such as sending a HCI RESET command which causes hci_send_frame() to schedule
   hci_uart_write_work() after the cancel_work_sync() has executed.

b) In the case of BCSP retransmissions, the callstack in e) runs periodically
   every 250ms. This can occur before and after the cancel_work_sync() executed.


The call to hu->proto->close(hu) is partially protected by the flag
HCI_UART_PROTO_READY but there is a small race condition. A race condition
exists because hci_uart_tty_close() can clear HCI_UART_PROTO_READY just after
the concurrent thread(s) detected the flag as set. The race potentially allows
the concurrent thread(s) to run a "proto" function pointer after or during
hci_uart_tty_close() is calling hu->proto->close(hu) which could trigger a
kernel crash.

Bear in mind that on systems with low resources, such as embedded systems, that
threads can get delayed by interrupts and pre-emption. This means that a
concurrent thread might sleep after it checks the HCI_UART_PROTO_READY flag.
Therefore, just using the flag HCI_UART_PROTO_READY is not 100% safe from
introducing race conditions.

Note that the elapsed run-time for hci_unregister_dev() is dependent on a
number of scenarios. This means hci_unregister_dev() can quickly return or take
up to 10 seconds (guess) to return. This means that the elapsed time between
clearing HCI_UART_PROTO_READY and executing hu->proto->close(hu) is variable
and therefore there is a variable risk in triggering the kernel crash.


Solution implemented by this patchset
=====================================

Modify hci_ldisc.c: hci_uart_tty_close() to use a rwlock solution:

	cancel_work_sync(&hu->write_work);

	if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
		write_lock_irqsave(&hu->proto_lock, flags);
		clear_bit(HCI_UART_PROTO_READY, &hu->flags);
		write_unlock_irqrestore(&hu->proto_lock, flags);

		if (hdev) {
			if (test_bit(HCI_UART_REGISTERED, &hu->flags))
				hci_unregister_dev(hdev);
			hci_free_dev(hdev);
		}
		hu->proto->close(hu);
	}
 
The call to write_lock_irqsave(&hu->proto_lock, flags) will block when a
concurrent thread has called read_lock(&hu->proto_lock). This ensures that
the flag HCI_UART_PROTO_READY is only cleared when no "proto" function pointers
are running in the concurrent threads. Therefore, it is not possible for
any "proto" function pointers to be running immediately before, during or after
hu->proto->close(hu) is called. This means the race condition is avoided.

Note that this solution will inhibit the Data Link layer protocol from
independently retransmitting because hu->proto->enqueue() cannot be called after
HCI_UART_PROTO_READY has been put into the clear state.


Test results from running the patchset
======================================

A x86 64-bit test kernel was created based on kernel v4.11.0 plus the 7 patches:

3rd Patchset
  Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto races
2nd Patchset 
  Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame()
  Bluetooth: hci_ldisc: Add protocol check to hci_uart_dequeue()
  Bluetooth: hci_ldisc: Add protocol check to hci_uart_tx_wakeup()
1st Patchset 
  Bluetooth: hci_ldisc: Add missing return in hci_uart_init_work()
  Bluetooth: hci_ldisc: Ensure hu->hdev set to NULL before freeing hdev
  Bluetooth: hci_ldisc: Add missing clear HCI_UART_PROTO_READY

The test used btattach with BCSP which fails to establish a link because BCSP
is not fully implemented in the kernel. However, this is ideal in forcing
BCSP retransmissions. btattach was killed after 5 seconds of running to force
hci_uart_tty_close() to execute.

Here is a snippet of a dmesg log with dynamic debug enabled:
[ 1039.415914] hci_uart_tty_close: tty ffff9861c691d800
[ 1039.415917] hci_uart_close: hdev ffff98625b422000
[ 1039.415920] hci_uart_flush: hdev ffff98625b422000 tty ffff9861c691d800
[ 1039.415922] bcsp_flush: hu ffff9861c27bd480
[ 1039.415928] hci_unregister_dev: ffff98625b422000 name hci1 bus 3
[ 1039.418767] bcsp_timed_event: hu ffff9861c27bd480 retransmitting 2 pkts
[ 1039.674810] Bluetooth: hci1 command 0x1001 tx timeout
[ 1039.674827] hci_cmd_work: hci1 cmd_cnt 1 cmd queued 1
[ 1039.674832] hci_send_frame: hci1 type 1 len 3
[ 1039.674836] hci_uart_send_frame: hci1: type 1 len 3
[ 1039.674838] Bluetooth: hci1 sending frame failed (-49)
[ 1041.722773] Bluetooth: hci1 command 0x1009 tx timeout
[ 1041.722811] hci_cmd_work: hci1 cmd_cnt 1 cmd queued 0
[ 1045.818847] hci_uart_close: hdev ffff98625b422000
[ 1045.818850] hci_uart_flush: hdev ffff98625b422000 tty ffff9861c691d800
[ 1045.818868] hci_dev_do_close: hci1 ffff98625b422000
[ 1045.819031] hci_conn_params_clear_all: All LE connection parameters were removed
[ 1045.819036] bcsp_close: hu ffff9861c27bd480

The following can be observed from the results:

1. hci_unregister_dev() ran which means HCI_UART_PROTO_READY has been cleared.

2. bcsp_timed_event() runs after HCI_UART_PROTO_READY has been cleared and
   so hci_uart_tx_wakeup() no longer appears in the log. This inhibits further
   BCSP retransmission attempts.

3. Bluetooth: hci1 command 0x1001 tx timeout
   This occurs because BCSP was unable to successfully transfer the HCI
   command. BCSP fails because the data plane to and from the UART driver is no
   longer working.

4. Bluetooth: hci1 sending frame failed (-49)
   This occurs because HCI_UART_PROTO_READY has been cleared which inhibits
   a new HCI command being sent from hci_cmd_work().

5. Bluetooth: hci1 command 0x1009 tx timeout
   BCSP never took the HCI command but the HCI core still performs the HCI
   command timeout. This means the thread gets blocked for 2 seconds for doing
   nothing.

6. hci_uart_close() runs twice which seems to be unnecessary. This causes
   hci_uart_flush() to run twice but notice the 2nd execution of
   hci_uart_flush() does not run bcsp_flush() because hdev->flush gets set to
   NULL in hci_uart_close(). This suggests a workaround was done in the past
   to prevent a kernel crash.


Outline of potential further work
=================================

With this patchset, the design flaw in hci_uart_tty_close() is further exposed.

It can be seen that hci_uart_tty_close() is systematically preventing
communications with the Bluetooth Radio Module. But hci_uart_tty_close() calls
hci_unregister_dev() which calls hci_dev_do_close(). If the flag HCI_UP is in
the set state then hci_dev_do_close() assumes that good communications with the
Bluetooth Radio Module are still possible. Therefore, there is a conflict in the
design because the design should not be closing the link and trying to use the
link to send HCI commands at the same time. This can trigger the protocol error
handling procedures to occur which are unsuccessful.

In addition, it is suspected that before hci_uart_tty_close() runs, the TTY
layer has cut the data plane between the Data Link protocol and the UART driver.
This means that if hci_uart_tty_close() is rearranged to allow
HCI_UART_PROTO_READY to be cleared after hci_unregister_dev() runs then any HCI
command will still fail to reach the Bluetooth Radio Module.

There are other issues in hci_ldisc.c: hci_uart_tty_close()

	/* Detach from the tty */
	tty->disc_data = NULL;

	if (!hu)
		return;

	hdev = hu->hdev;
	if (hdev)
		hci_uart_close(hdev);

It can be seen that tty->disc_data is set to NULL. This causes some of the HCI
UART LDISC functions to not perform any operation such as the functions:

hci_uart_tty_wakeup()
hci_uart_tty_receive()
hci_uart_tty_ioctl()

Doing "tty->disc_data = NULL" sabotages the communications with the Bluetooth
Radio Module. Therefore, this statement needs to be moved to after the
communications are going to be cleanly closed such as after hci_unregister_dev()
has completed.

Calling hci_uart_close(hdev) is likely to interfere with the communications with
the Bluetooth Radio Module. Therefore, this statement needs to be moved to after
the communications are going to be cleanly closed such as after
hci_unregister_dev() has completed.


Potential solution to the design flaw
=====================================

Suspect that a solution would be to get hci_uart_tty_close() to run
hci_unregister_dev() before tearing down the resources needed by the
Data Link protocol layer.


The patch was rebased onto the bluetooth-next master branch HEAD commit:
2da711a Bluetooth: Skip vendor diagnostic configuration for HCI User Channel

Dean Jenkins (1):
  Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto races

 drivers/bluetooth/hci_ldisc.c | 40 +++++++++++++++++++++++++++++++++++-----
 drivers/bluetooth/hci_uart.h  |  1 +
 2 files changed, 36 insertions(+), 5 deletions(-)

-- 
2.7.4

^ permalink raw reply

* [PATCH V1 1/1] Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto races
From: Dean Jenkins @ 2017-05-05 15:27 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Dean Jenkins, Gustavo F . Padovan, Johan Hedberg, linux-bluetooth
In-Reply-To: <1493998026-14355-1-git-send-email-Dean_Jenkins@mentor.com>

When HCI_UART_PROTO_READY is in the set state, the Data Link protocol
layer (proto) is bound to the HCI UART driver. This state allows the
registered proto function pointers to be used by the HCI UART driver.

When unbinding (closing) the Data Link protocol layer, the proto
function pointers much be prevented from being used immediately before
running the proto close function pointer. Otherwise, there is a risk
that a proto non-close function pointer is used during or after the
proto close function pointer is used. The consequences are likely to
be a kernel crash because the proto close function pointer will free
resources used in the Data Link protocol layer.

Therefore, add a reader writer lock (rwlock) solution to prevent the
close proto function pointer from running by using write_lock_irqsave()
whilst the other proto function pointers are protected using
read_lock(). This means HCI_UART_PROTO_READY can safely be cleared
in the knowledge that no proto function pointers are running.

When flag HCI_UART_PROTO_READY is put into the clear state,
proto close function pointer can safely be run. Note
flag HCI_UART_PROTO_SET being in the set state prevents the proto
open function pointer from being run so there is no race condition
between proto open and close function pointers.

Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com>
---
 drivers/bluetooth/hci_ldisc.c | 40 +++++++++++++++++++++++++++++++++++-----
 drivers/bluetooth/hci_uart.h  |  1 +
 2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 2edd305..8397b71 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -114,8 +114,12 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
 	struct sk_buff *skb = hu->tx_skb;
 
 	if (!skb) {
+		read_lock(&hu->proto_lock);
+
 		if (test_bit(HCI_UART_PROTO_READY, &hu->flags))
 			skb = hu->proto->dequeue(hu);
+
+		read_unlock(&hu->proto_lock);
 	} else {
 		hu->tx_skb = NULL;
 	}
@@ -125,18 +129,23 @@ static inline struct sk_buff *hci_uart_dequeue(struct hci_uart *hu)
 
 int hci_uart_tx_wakeup(struct hci_uart *hu)
 {
+	read_lock(&hu->proto_lock);
+
 	if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
-		return 0;
+		goto no_schedule;
 
 	if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) {
 		set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
-		return 0;
+		goto no_schedule;
 	}
 
 	BT_DBG("");
 
 	schedule_work(&hu->write_work);
 
+no_schedule:
+	read_unlock(&hu->proto_lock);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(hci_uart_tx_wakeup);
@@ -237,9 +246,13 @@ static int hci_uart_flush(struct hci_dev *hdev)
 	tty_ldisc_flush(tty);
 	tty_driver_flush_buffer(tty);
 
+	read_lock(&hu->proto_lock);
+
 	if (test_bit(HCI_UART_PROTO_READY, &hu->flags))
 		hu->proto->flush(hu);
 
+	read_unlock(&hu->proto_lock);
+
 	return 0;
 }
 
@@ -261,10 +274,15 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 	BT_DBG("%s: type %d len %d", hdev->name, hci_skb_pkt_type(skb),
 	       skb->len);
 
-	if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
+	read_lock(&hu->proto_lock);
+
+	if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+		read_unlock(&hu->proto_lock);
 		return -EUNATCH;
+	}
 
 	hu->proto->enqueue(hu, skb);
+	read_unlock(&hu->proto_lock);
 
 	hci_uart_tx_wakeup(hu);
 
@@ -460,6 +478,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 	INIT_WORK(&hu->init_ready, hci_uart_init_work);
 	INIT_WORK(&hu->write_work, hci_uart_write_work);
 
+	rwlock_init(&hu->proto_lock);
+
 	/* Flush any pending characters in the driver */
 	tty_driver_flush_buffer(tty);
 
@@ -475,6 +495,7 @@ static void hci_uart_tty_close(struct tty_struct *tty)
 {
 	struct hci_uart *hu = tty->disc_data;
 	struct hci_dev *hdev;
+	unsigned long flags;
 
 	BT_DBG("tty %p", tty);
 
@@ -490,7 +511,11 @@ static void hci_uart_tty_close(struct tty_struct *tty)
 
 	cancel_work_sync(&hu->write_work);
 
-	if (test_and_clear_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+	if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+		write_lock_irqsave(&hu->proto_lock, flags);
+		clear_bit(HCI_UART_PROTO_READY, &hu->flags);
+		write_unlock_irqrestore(&hu->proto_lock, flags);
+
 		if (hdev) {
 			if (test_bit(HCI_UART_REGISTERED, &hu->flags))
 				hci_unregister_dev(hdev);
@@ -549,13 +574,18 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
 	if (!hu || tty != hu->tty)
 		return;
 
-	if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
+	read_lock(&hu->proto_lock);
+
+	if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+		read_unlock(&hu->proto_lock);
 		return;
+	}
 
 	/* It does not need a lock here as it is already protected by a mutex in
 	 * tty caller
 	 */
 	hu->proto->recv(hu, data, count);
+	read_unlock(&hu->proto_lock);
 
 	if (hu->hdev)
 		hu->hdev->stat.byte_rx += count;
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 2b05e55..c6e9e1c 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -87,6 +87,7 @@ struct hci_uart {
 	struct work_struct	write_work;
 
 	const struct hci_uart_proto *proto;
+	rwlock_t		proto_lock;	/* Stop work for proto close */
 	void			*priv;
 
 	struct sk_buff		*tx_skb;
-- 
2.7.4

^ permalink raw reply related

* Re: [PATCH V1 0/1] hci_ldisc: Use rwlocking to avoid closing proto races
From: Marcel Holtmann @ 2017-05-05 15:55 UTC (permalink / raw)
  To: Dean Jenkins; +Cc: Gustavo F. Padovan, Johan Hedberg, linux-bluetooth
In-Reply-To: <1493998026-14355-1-git-send-email-Dean_Jenkins@mentor.com>

Hi Dean,

> This is my 3rd patchset in my series of resolving a design flaw in
> hci_uart_tty_close() related to the proper closure of the Data Link protocol
> layer which can result in a kernel crash.
> 
> This patchset contains a single patch that adds rwlocking around the "proto"
> function pointers. This provides a full fix to prevent a potential kernel crash
> triggered by hu->proto->close() running before or during the execution of a
> non-close "proto" function pointer.
> 
> 
> Previous Discussions
> ====================
> 
> Please refer to the discussion on my 2nd patchset V1 that can be found here:
> https://www.spinics.net/lists/linux-bluetooth/msg70370.html
> You accepted the 3 patches of my patchset of commits namely:
>  Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame()
>  Bluetooth: hci_ldisc: Add protocol check to hci_uart_dequeue()
>  Bluetooth: hci_ldisc: Add protocol check to hci_uart_tx_wakeup()
> 
> drivers/bluetooth/hci_ldisc.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
> 
> Please refer to the discussion on my 1st patchset V3 that can be found here:
> https://www.spinics.net/lists/linux-bluetooth/msg70315.html
> You accepted the 3 patches of my patchset of commits namely:
>  Bluetooth: hci_ldisc: Add missing return in hci_uart_init_work()
>  Bluetooth: hci_ldisc: Ensure hu->hdev set to NULL before freeing hdev
>  Bluetooth: hci_ldisc: Add missing clear HCI_UART_PROTO_READY
> 
> drivers/bluetooth/hci_ldisc.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
> 
> Please refer to the discussion on my 1st patchset V2 that can be found here:
> https://www.spinics.net/lists/linux-bluetooth/msg70183.html
> 
> Please refer to the discussion on my 1st RFC patchset V1 that can be found here:
> https://www.spinics.net/lists/linux-bluetooth/msg70077.html
> 
> 
> Analysis
> ========
> 
> There are multiple threads that use "proto" function pointers that potentially
> can be running concurrently with the thread of hci_uart_tty_close().
> 
> The threads include (not a complete list):
> 
> a) hci_uart_write_work() [hci_ldisc.c]
>   which is executed by the work queue hu->write_work which creates the
>   callstack:
>   hci_uart_write_work()
>   hci_uart_dequeue()
>   hu->proto->dequeue()
> 
> b) hci_tx_work() [hci_core.c]
>   which is executed by the work queue hdev->tx_work which creates the
>   callstack:
>   hci_tx_work()
>   hci_send_frame()
>   hdev->send()
>   hci_uart_send_frame()
>   hu->proto->enqueue()
>   then calls
>   hci_uart_tx_wakeup()
>   schedule_work(&hu->write_work)
>   triggering a)
> 
> c) hci_cmd_work() [hci_core.c]
>   which is executed by the work queue hdev->cmd_work which creates the
>   callstack:
>   hci_cmd_work()
>   hci_send_frame()
>   hdev->send()
>   hci_uart_send_frame()
>   hu->proto->enqueue()
>   then calls
>   hci_uart_tx_wakeup()
>   schedule_work(&hu->write_work)
>   triggering a)
> 
> d) hci_dev_close() [hci_core.c]
>   creates the callstack:
>   hci_dev_close()
>   hci_dev_do_close()
>   hdev->flush()
>   hci_uart_flush()
>   hu->proto->flush()
> 
> e) When BCSP is used and a retransmission is needed:
>   bcsp_timed_event() [hci_bcsp.c]
>   creates the callstack:
>   bcsp_timed_event()
>   hci_uart_tx_wakeup()
>   schedule_work(&hu->write_work)
>   triggering a)
> 
> 
> hci_ldisc.c: hci_uart_tty_close() currently has the construction:
> 
> 	cancel_work_sync(&hu->write_work);
> 
> 	if (test_and_clear_bit(HCI_UART_PROTO_READY, &hu->flags)) {
> 		if (hdev) {
> 			if (test_bit(HCI_UART_REGISTERED, &hu->flags))
> 				hci_unregister_dev(hdev);
> 			hci_free_dev(hdev);
> 		}
> 		hu->proto->close(hu);
> 	}
> 
> At first glance, the cancel_work_sync(&hu->write_work) would seem to inhibit
> hci_uart_write_work() from running. Actually, the call to cancel_work_sync()
> can be ineffective because:
> 
> a) hci_unregister_dev() calls hci_dev_do_close() and if HCI_UP flag is in the
>   set state then it is possible for hci_dev_do_close() to send a HCI command.
>   Such as sending a HCI RESET command which causes hci_send_frame() to schedule
>   hci_uart_write_work() after the cancel_work_sync() has executed.
> 
> b) In the case of BCSP retransmissions, the callstack in e) runs periodically
>   every 250ms. This can occur before and after the cancel_work_sync() executed.
> 
> 
> The call to hu->proto->close(hu) is partially protected by the flag
> HCI_UART_PROTO_READY but there is a small race condition. A race condition
> exists because hci_uart_tty_close() can clear HCI_UART_PROTO_READY just after
> the concurrent thread(s) detected the flag as set. The race potentially allows
> the concurrent thread(s) to run a "proto" function pointer after or during
> hci_uart_tty_close() is calling hu->proto->close(hu) which could trigger a
> kernel crash.
> 
> Bear in mind that on systems with low resources, such as embedded systems, that
> threads can get delayed by interrupts and pre-emption. This means that a
> concurrent thread might sleep after it checks the HCI_UART_PROTO_READY flag.
> Therefore, just using the flag HCI_UART_PROTO_READY is not 100% safe from
> introducing race conditions.
> 
> Note that the elapsed run-time for hci_unregister_dev() is dependent on a
> number of scenarios. This means hci_unregister_dev() can quickly return or take
> up to 10 seconds (guess) to return. This means that the elapsed time between
> clearing HCI_UART_PROTO_READY and executing hu->proto->close(hu) is variable
> and therefore there is a variable risk in triggering the kernel crash.
> 
> 
> Solution implemented by this patchset
> =====================================
> 
> Modify hci_ldisc.c: hci_uart_tty_close() to use a rwlock solution:
> 
> 	cancel_work_sync(&hu->write_work);
> 
> 	if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
> 		write_lock_irqsave(&hu->proto_lock, flags);
> 		clear_bit(HCI_UART_PROTO_READY, &hu->flags);
> 		write_unlock_irqrestore(&hu->proto_lock, flags);
> 
> 		if (hdev) {
> 			if (test_bit(HCI_UART_REGISTERED, &hu->flags))
> 				hci_unregister_dev(hdev);
> 			hci_free_dev(hdev);
> 		}
> 		hu->proto->close(hu);
> 	}
> 
> The call to write_lock_irqsave(&hu->proto_lock, flags) will block when a
> concurrent thread has called read_lock(&hu->proto_lock). This ensures that
> the flag HCI_UART_PROTO_READY is only cleared when no "proto" function pointers
> are running in the concurrent threads. Therefore, it is not possible for
> any "proto" function pointers to be running immediately before, during or after
> hu->proto->close(hu) is called. This means the race condition is avoided.
> 
> Note that this solution will inhibit the Data Link layer protocol from
> independently retransmitting because hu->proto->enqueue() cannot be called after
> HCI_UART_PROTO_READY has been put into the clear state.
> 
> 
> Test results from running the patchset
> ======================================
> 
> A x86 64-bit test kernel was created based on kernel v4.11.0 plus the 7 patches:
> 
> 3rd Patchset
>  Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto races
> 2nd Patchset 
>  Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame()
>  Bluetooth: hci_ldisc: Add protocol check to hci_uart_dequeue()
>  Bluetooth: hci_ldisc: Add protocol check to hci_uart_tx_wakeup()
> 1st Patchset 
>  Bluetooth: hci_ldisc: Add missing return in hci_uart_init_work()
>  Bluetooth: hci_ldisc: Ensure hu->hdev set to NULL before freeing hdev
>  Bluetooth: hci_ldisc: Add missing clear HCI_UART_PROTO_READY
> 
> The test used btattach with BCSP which fails to establish a link because BCSP
> is not fully implemented in the kernel. However, this is ideal in forcing
> BCSP retransmissions. btattach was killed after 5 seconds of running to force
> hci_uart_tty_close() to execute.
> 
> Here is a snippet of a dmesg log with dynamic debug enabled:
> [ 1039.415914] hci_uart_tty_close: tty ffff9861c691d800
> [ 1039.415917] hci_uart_close: hdev ffff98625b422000
> [ 1039.415920] hci_uart_flush: hdev ffff98625b422000 tty ffff9861c691d800
> [ 1039.415922] bcsp_flush: hu ffff9861c27bd480
> [ 1039.415928] hci_unregister_dev: ffff98625b422000 name hci1 bus 3
> [ 1039.418767] bcsp_timed_event: hu ffff9861c27bd480 retransmitting 2 pkts
> [ 1039.674810] Bluetooth: hci1 command 0x1001 tx timeout
> [ 1039.674827] hci_cmd_work: hci1 cmd_cnt 1 cmd queued 1
> [ 1039.674832] hci_send_frame: hci1 type 1 len 3
> [ 1039.674836] hci_uart_send_frame: hci1: type 1 len 3
> [ 1039.674838] Bluetooth: hci1 sending frame failed (-49)
> [ 1041.722773] Bluetooth: hci1 command 0x1009 tx timeout
> [ 1041.722811] hci_cmd_work: hci1 cmd_cnt 1 cmd queued 0
> [ 1045.818847] hci_uart_close: hdev ffff98625b422000
> [ 1045.818850] hci_uart_flush: hdev ffff98625b422000 tty ffff9861c691d800
> [ 1045.818868] hci_dev_do_close: hci1 ffff98625b422000
> [ 1045.819031] hci_conn_params_clear_all: All LE connection parameters were removed
> [ 1045.819036] bcsp_close: hu ffff9861c27bd480
> 
> The following can be observed from the results:
> 
> 1. hci_unregister_dev() ran which means HCI_UART_PROTO_READY has been cleared.
> 
> 2. bcsp_timed_event() runs after HCI_UART_PROTO_READY has been cleared and
>   so hci_uart_tx_wakeup() no longer appears in the log. This inhibits further
>   BCSP retransmission attempts.
> 
> 3. Bluetooth: hci1 command 0x1001 tx timeout
>   This occurs because BCSP was unable to successfully transfer the HCI
>   command. BCSP fails because the data plane to and from the UART driver is no
>   longer working.
> 
> 4. Bluetooth: hci1 sending frame failed (-49)
>   This occurs because HCI_UART_PROTO_READY has been cleared which inhibits
>   a new HCI command being sent from hci_cmd_work().
> 
> 5. Bluetooth: hci1 command 0x1009 tx timeout
>   BCSP never took the HCI command but the HCI core still performs the HCI
>   command timeout. This means the thread gets blocked for 2 seconds for doing
>   nothing.
> 
> 6. hci_uart_close() runs twice which seems to be unnecessary. This causes
>   hci_uart_flush() to run twice but notice the 2nd execution of
>   hci_uart_flush() does not run bcsp_flush() because hdev->flush gets set to
>   NULL in hci_uart_close(). This suggests a workaround was done in the past
>   to prevent a kernel crash.
> 
> 
> Outline of potential further work
> =================================
> 
> With this patchset, the design flaw in hci_uart_tty_close() is further exposed.
> 
> It can be seen that hci_uart_tty_close() is systematically preventing
> communications with the Bluetooth Radio Module. But hci_uart_tty_close() calls
> hci_unregister_dev() which calls hci_dev_do_close(). If the flag HCI_UP is in
> the set state then hci_dev_do_close() assumes that good communications with the
> Bluetooth Radio Module are still possible. Therefore, there is a conflict in the
> design because the design should not be closing the link and trying to use the
> link to send HCI commands at the same time. This can trigger the protocol error
> handling procedures to occur which are unsuccessful.
> 
> In addition, it is suspected that before hci_uart_tty_close() runs, the TTY
> layer has cut the data plane between the Data Link protocol and the UART driver.
> This means that if hci_uart_tty_close() is rearranged to allow
> HCI_UART_PROTO_READY to be cleared after hci_unregister_dev() runs then any HCI
> command will still fail to reach the Bluetooth Radio Module.
> 
> There are other issues in hci_ldisc.c: hci_uart_tty_close()
> 
> 	/* Detach from the tty */
> 	tty->disc_data = NULL;
> 
> 	if (!hu)
> 		return;
> 
> 	hdev = hu->hdev;
> 	if (hdev)
> 		hci_uart_close(hdev);
> 
> It can be seen that tty->disc_data is set to NULL. This causes some of the HCI
> UART LDISC functions to not perform any operation such as the functions:
> 
> hci_uart_tty_wakeup()
> hci_uart_tty_receive()
> hci_uart_tty_ioctl()
> 
> Doing "tty->disc_data = NULL" sabotages the communications with the Bluetooth
> Radio Module. Therefore, this statement needs to be moved to after the
> communications are going to be cleanly closed such as after hci_unregister_dev()
> has completed.
> 
> Calling hci_uart_close(hdev) is likely to interfere with the communications with
> the Bluetooth Radio Module. Therefore, this statement needs to be moved to after
> the communications are going to be cleanly closed such as after
> hci_unregister_dev() has completed.
> 
> 
> Potential solution to the design flaw
> =====================================
> 
> Suspect that a solution would be to get hci_uart_tty_close() to run
> hci_unregister_dev() before tearing down the resources needed by the
> Data Link protocol layer.
> 
> 
> The patch was rebased onto the bluetooth-next master branch HEAD commit:
> 2da711a Bluetooth: Skip vendor diagnostic configuration for HCI User Channel
> 
> Dean Jenkins (1):
>  Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto races
> 
> drivers/bluetooth/hci_ldisc.c | 40 +++++++++++++++++++++++++++++++++++-----
> drivers/bluetooth/hci_uart.h  |  1 +
> 2 files changed, 36 insertions(+), 5 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply

* BLE Advertisement frustrations with pydbus
From: Travis Griggs @ 2017-05-05 22:28 UTC (permalink / raw)
  To: Bluez mailing list

I=E2=80=99m trying to switch to using pydbus (instead of deprecated =
dbus-python, which the bluez examples are based on). I=E2=80=99m running =
on stretch with bluez 5.43. My code is at the bottom (and here -> =
https://gist.github.com/travisgriggs/d8e14dcccf46751804456dc74da1e5e6). =
I=E2=80=99m running into a problem when I try to RegisterAdvertisement. =
What I can=E2=80=99t seem to discern is what is different between this =
and the old approach. The bluetooth driver fails around =
advertising:c:175

    DBusMessageIter iter;
    const char *msg_type;

    if (!g_dbus_proxy_get_property(proxy, "Type", &iter))
        return false;

The g_dbus_proxy_get_property() call fails. What I don=E2=80=99t =
understand though is this. If I modify my program to NOT =
RegisterAdvertisement(), but just sit there with the advertisement =
object on the bus, I can do the following:

$ sudo busctl get-property :1.5 /nic/twigpilot =
org.bluez.LEAdvertisement1 Type
s =E2=80=9Cperipheral"

So I *am* able to get the Type using busctl. Why is that bluetoothd =
cannot? Using busctl introspect, I see that the pydbus variant =
automagically makes a lot more available than the dubs-python variant =
did.

Any hints? Pointers? Help?

TIA

=E2=80=94=E2=80=94

#!/usr/bin/env python3

import pydbus
from gi.repository import GLib

class Advertisement(object):
    """
      <node>
        <interface name=3D"org.bluez.LEAdvertisement1">
          <method name=3D"Release">
            <annotation name=3D"org.freedesktop.DBus.Method.NoReply" =
value=3D"true"/>
          </method>
          <annotation =
name=3D"org.freedesktop.DBus.Properties.PropertiesChanged" =
value=3D"const"/>
          <property name=3D"Type" type=3D"s" access=3D"read"/>
          <property name=3D"ServiceUUIDs" type=3D"as" access=3D"read"/>
          <property name=3D"ManufacturerData" type=3D"a{sv}" =
access=3D"read"/>
          <property name=3D"SolicitUUIDs" type=3D"as" access=3D"read"/>
          <property name=3D"ServiceData" type=3D"a{sv}" access=3D"read"/>
          <property name=3D"IncludeTxPower" type=3D"b" access=3D"read"/>
        </interface>
      </node>
    """

    def __init__(self, bus):
        self.Type =3D 'peripheral'
        self.ServiceUUIDs =3D []
        self.ManufacturerData =3D {}
        self.SolicitUUIDs =3D []
        self.ServiceData =3D {}
        self.IncludeTxPower =3D False
        bus.register_object('/nic/twigpilot', self, None)

    def Release(self):
        print('{}: Advertisement Released!'.format(self))


def main():
    bus =3D pydbus.SystemBus()
    adaptor =3D bus.get('org.bluez', '/org/bluez/hci0')
    adaptor.Powered =3D True
    adaptor.Alias =3D 'SeeMe'

    advertisement =3D Advertisement(bus)
    advertisement.IncludeTxPower =3D True

    #adaptor.RegisterAdvertisement('/nic/twigpilot', {})

    loop =3D GLib.MainLoop()
    try:
        loop.run()
    except KeyboardInterrupt:
        loop.quit()

if __name__ =3D=3D '__main__':
    main()=

^ permalink raw reply

* bluez5.44 and Debian?
From: Travis Griggs @ 2017-05-05 23:25 UTC (permalink / raw)
  To: Bluez mailing list

Does anyone know why bluez 5.44 (which was pushed in February) is still =
not available in debian-unstable? I thought unstable was usually pretty =
current.=

^ permalink raw reply

* Re: bluez5.44 and Debian?
From: Sebastian Reichel @ 2017-05-06  1:26 UTC (permalink / raw)
  To: Travis Griggs; +Cc: Bluez mailing list
In-Reply-To: <DB5F6CBF-43D4-492C-8542-346887D7C881@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

Hi,

On Fri, May 05, 2017 at 04:25:51PM -0700, Travis Griggs wrote:
> Does anyone know why bluez 5.44 (which was pushed in February) is
> still not available in debian-unstable? I thought unstable was
> usually pretty current.

Debian is currently preparing the stretch release, so Debian
maintainers avoid uploading new packages to unstable except
for fixing release-critical bugs.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [Unstrung-hackers] [RFC net-next] ipv6: ext_header: add function to handle RPL extension header option 0x63
From: Jiri Pirko @ 2017-05-06 10:37 UTC (permalink / raw)
  To: Andreas Bardoutsos
  Cc: JANARDHANACHARI KELLA, Michael Richardson, netdev, netdev-owner,
	linux-bluetooth, linux-wpan, unstrung-hackers
In-Reply-To: <96b9f3bc67da7c16249600990c2df4cc@ceid.upatras.gr>

Fri, May 05, 2017 at 09:55:54AM CEST, bardoutsos@ceid.upatras.gr wrote:
>Yes I think we have faced the same problem,communication with RPL supporting
>devices was failing otherwise.Your patch is also more complete since it also
>implements #ifdef .About the comment,yes I have run checkpatch twice with no
>errors,but ok :)

Top-posting is highly annoying. Please stop with that.

>
>Στις 2017-05-05 08:59, JANARDHANACHARI KELLA έγραψε:
>> I was inserted this patch manually. It was working. on 4.9 kernel.
>> 
>> check this bellow link for your ref.
>> 
>> https://github.com/mwasilak/bluetooth-next/commit/f29c632ef6a6a1777815c97fd2f326faccc704f7
>> [2]
>> 
>> On Thu, May 4, 2017 at 9:30 PM, Jiri Pirko <jiri@resnulli.us> wrote:
>> 
>> > Thu, May 04, 2017 at 05:17:18PM CEST, bardoutsos@ceid.upatras.gr
>> > wrote:
>> > > Signed-off-by: Andreas Bardoutsos <bardoutsos@ceid.upatras.gr>
>> > > ---
>> > > Hi all!
>> > > 
>> > > I have added a dump function(always return true) to recognise RPL
>> > extension
>> > > header(RFC6553)
>> > > Otherwise packet was dropped by kernel resulting in failing
>> > communication in
>> > > RPL DAG's between
>> > > linux running border routers and devices in the graph.For example
>> > > communication
>> > > with contiki OS running devices was previously impossible.
>> > > 
>> > > include/uapi/linux/in6.h | 1 +
>> > > net/ipv6/exthdrs.c | 13 +++++++++++++
>> > > 2 files changed, 14 insertions(+)
>> > > 
>> > > diff --git a/include/uapi/linux/in6.h b/include/uapi/linux/in6.h
>> > > index 46444f8fbee4..5cc12d309dfe 100644
>> > > --- a/include/uapi/linux/in6.h
>> > > +++ b/include/uapi/linux/in6.h
>> > > @@ -146,6 +146,7 @@ struct in6_flowlabel_req {
>> > > #define IPV6_TLV_CALIPSO 7 /* RFC 5570 */
>> > > #define IPV6_TLV_JUMBO 194
>> > > #define IPV6_TLV_HAO 201 /* home address option */
>> > > +#define IPV6_TLV_RPL 99 /* RFC 6553 */
>> > > 
>> > > /*
>> > > * IPV6 socket options
>> > > diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
>> > > index b636f1da9aec..82ed60d3180e 100644
>> > > --- a/net/ipv6/exthdrs.c
>> > > +++ b/net/ipv6/exthdrs.c
>> > > @@ -785,6 +785,15 @@ static bool ipv6_hop_calipso(struct sk_buff
>> > *skb, int
>> > > optoff)
>> > > return false;
>> > > }
>> > > 
>> > > +/* RPL RFC 6553 */
>> > > +
>> > > +static bool ipv6_hop_rpl(struct sk_buff *skb, int optoff)
>> > > +{
>> > > + /*Dump function which always return true
>> > > + *when rpl option is detected*/
>> > 
>> > This is definitelly wrong formatting of comment. Did you run
>> > checkpatch?
>> > 
>> > > + return true;
>> > > +}
>> > > +
>> > > static const struct tlvtype_proc tlvprochopopt_lst[] = {
>> > > {
>> > > .type = IPV6_TLV_ROUTERALERT,
>> > > @@ -798,6 +807,10 @@ static const struct tlvtype_proc
>> > tlvprochopopt_lst[] = {
>> > > .type = IPV6_TLV_CALIPSO,
>> > > .func = ipv6_hop_calipso,
>> > > },
>> > > + {
>> > > + .type = IPV6_TLV_RPL,
>> > > + .func = ipv6_hop_rpl,
>> > > + },
>> > > { -1, }
>> > > };
>> > > 
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe
>> > linux-wpan" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>> > [1]
>> 
>> --
>> 
>> Sincerely Your's
>> 
>> Janardhanachari Kella
>> 
>> Contact:+91-9908469599
>> E-mail: eni.chari@gmail.com
>> 
>> 
>> Links:
>> ------
>> [1] http://vger.kernel.org/majordomo-info.html
>> [2]
>> https://github.com/mwasilak/bluetooth-next/commit/f29c632ef6a6a1777815c97fd2f326faccc704f7
>> 
>> _______________________________________________
>> Unstrung-hackers mailing list
>> Unstrung-hackers@lists.sandelman.ca
>> https://lists.sandelman.ca/mailman/listinfo/unstrung-hackers
>

^ permalink raw reply

* Re: BLE Advertisement frustrations with pydbus
From: Luiz Augusto von Dentz @ 2017-05-08  8:01 UTC (permalink / raw)
  To: Travis Griggs; +Cc: Bluez mailing list
In-Reply-To: <8474DEA7-88A2-4AE7-953E-64AC24B1881F@gmail.com>

Hi Travis,

On Sat, May 6, 2017 at 1:28 AM, Travis Griggs <travisgriggs@gmail.com> wrot=
e:
> I=E2=80=99m trying to switch to using pydbus (instead of deprecated dbus-=
python, which the bluez examples are based on). I=E2=80=99m running on stre=
tch with bluez 5.43. My code is at the bottom (and here -> https://gist.git=
hub.com/travisgriggs/d8e14dcccf46751804456dc74da1e5e6). I=E2=80=99m running=
 into a problem when I try to RegisterAdvertisement. What I can=E2=80=99t s=
eem to discern is what is different between this and the old approach. The =
bluetooth driver fails around advertising:c:175
>
>     DBusMessageIter iter;
>     const char *msg_type;
>
>     if (!g_dbus_proxy_get_property(proxy, "Type", &iter))
>         return false;
>
> The g_dbus_proxy_get_property() call fails. What I don=E2=80=99t understa=
nd though is this. If I modify my program to NOT RegisterAdvertisement(), b=
ut just sit there with the advertisement object on the bus, I can do the fo=
llowing:
>
> $ sudo busctl get-property :1.5 /nic/twigpilot org.bluez.LEAdvertisement1=
 Type
> s =E2=80=9Cperipheral"
>
> So I *am* able to get the Type using busctl. Why is that bluetoothd canno=
t? Using busctl introspect, I see that the pydbus variant automagically mak=
es a lot more available than the dubs-python variant did.
>
> Any hints? Pointers? Help?

Does pydbus have ObjectManager support? What about GetAll properties?
You could perhaps try to sniff the message with eavesdrop option:

https://wiki.ubuntu.com/DebuggingDBus

> TIA
>
> =E2=80=94=E2=80=94
>
> #!/usr/bin/env python3
>
> import pydbus
> from gi.repository import GLib
>
> class Advertisement(object):
>     """
>       <node>
>         <interface name=3D"org.bluez.LEAdvertisement1">
>           <method name=3D"Release">
>             <annotation name=3D"org.freedesktop.DBus.Method.NoReply" valu=
e=3D"true"/>
>           </method>
>           <annotation name=3D"org.freedesktop.DBus.Properties.PropertiesC=
hanged" value=3D"const"/>
>           <property name=3D"Type" type=3D"s" access=3D"read"/>
>           <property name=3D"ServiceUUIDs" type=3D"as" access=3D"read"/>
>           <property name=3D"ManufacturerData" type=3D"a{sv}" access=3D"re=
ad"/>
>           <property name=3D"SolicitUUIDs" type=3D"as" access=3D"read"/>
>           <property name=3D"ServiceData" type=3D"a{sv}" access=3D"read"/>
>           <property name=3D"IncludeTxPower" type=3D"b" access=3D"read"/>
>         </interface>
>       </node>
>     """
>
>     def __init__(self, bus):
>         self.Type =3D 'peripheral'
>         self.ServiceUUIDs =3D []
>         self.ManufacturerData =3D {}
>         self.SolicitUUIDs =3D []
>         self.ServiceData =3D {}
>         self.IncludeTxPower =3D False
>         bus.register_object('/nic/twigpilot', self, None)
>
>     def Release(self):
>         print('{}: Advertisement Released!'.format(self))
>
>
> def main():
>     bus =3D pydbus.SystemBus()
>     adaptor =3D bus.get('org.bluez', '/org/bluez/hci0')
>     adaptor.Powered =3D True
>     adaptor.Alias =3D 'SeeMe'
>
>     advertisement =3D Advertisement(bus)
>     advertisement.IncludeTxPower =3D True
>
>     #adaptor.RegisterAdvertisement('/nic/twigpilot', {})
>
>     loop =3D GLib.MainLoop()
>     try:
>         loop.run()
>     except KeyboardInterrupt:
>         loop.quit()
>
> if __name__ =3D=3D '__main__':
>     main()--
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--=20
Luiz Augusto von Dentz

^ permalink raw reply

* Re: BLE Advertisement frustrations with pydbus
From: Barry Byford @ 2017-05-08  8:51 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Travis Griggs, Bluez mailing list
In-Reply-To: <CABBYNZJm0ViS8PZmHRno4T_rOjcJzvQbMfDMmAZ9W5xf-d9Bkg@mail.gmail.com>

Hello Luiz & Travis,

I've been taking a look at this also

On 8 May 2017 at 09:01, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote=
:
> On Sat, May 6, 2017 at 1:28 AM, Travis Griggs <travisgriggs@gmail.com> wr=
ote:
>> $ sudo busctl get-property :1.5 /nic/twigpilot org.bluez.LEAdvertisement=
1 Type
>> s =E2=80=9Cperipheral"
>>
>> So I *am* able to get the Type using busctl. Why is that bluetoothd cann=
ot? Using busctl introspect, I see that the pydbus variant automagically ma=
kes a lot more available than the dubs-python variant did.
>>
>> Any hints? Pointers? Help?
>
> Does pydbus have ObjectManager support?

Looking at the following entry in the libraries issue list it seems
like it does.
https://github.com/LEW21/pydbus/issues/28
Is there anything in particular we should be testing for?


> What about GetAll properties?
Yes it does. It creates these standard interfaces automatically based
on the XML in the Python class doc string. So for example Get and
GetAll give the following:


$ busctl call ukBaz.bluezero /ukBaz/bluezero
org.freedesktop.DBus.Properties Get ss org.bluez.LEAdvertisement1 Type

v s "peripheral"

$ busctl call ukBaz.bluezero /ukBaz/bluezero
org.freedesktop.DBus.Properties GetAll s org.bluez.LEAdvertisement1

a{sv} 3 "Type" s "peripheral" "SolicitUUIDs" as 1 "180F"
"IncludeTxPower" b false


> You could perhaps try to sniff the message with eavesdrop option:
>
> https://wiki.ubuntu.com/DebuggingDBus

Good suggestion. I'll try that later.

>
>> TIA
>>
>> =E2=80=94=E2=80=94
>>
>> #!/usr/bin/env python3
>>
>> import pydbus
>> from gi.repository import GLib
>>
>> class Advertisement(object):
>>     """
>>       <node>
>>         <interface name=3D"org.bluez.LEAdvertisement1">
>>           <method name=3D"Release">
>>             <annotation name=3D"org.freedesktop.DBus.Method.NoReply" val=
ue=3D"true"/>
>>           </method>
>>           <annotation name=3D"org.freedesktop.DBus.Properties.Properties=
Changed" value=3D"const"/>
>>           <property name=3D"Type" type=3D"s" access=3D"read"/>
>>           <property name=3D"ServiceUUIDs" type=3D"as" access=3D"read"/>
>>           <property name=3D"ManufacturerData" type=3D"a{sv}" access=3D"r=
ead"/>
>>           <property name=3D"SolicitUUIDs" type=3D"as" access=3D"read"/>
>>           <property name=3D"ServiceData" type=3D"a{sv}" access=3D"read"/=
>
>>           <property name=3D"IncludeTxPower" type=3D"b" access=3D"read"/>
>>         </interface>
>>       </node>
>>     """
>>
>>     def __init__(self, bus):
>>         self.Type =3D 'peripheral'
>>         self.ServiceUUIDs =3D []
>>         self.ManufacturerData =3D {}
>>         self.SolicitUUIDs =3D []
>>         self.ServiceData =3D {}
>>         self.IncludeTxPower =3D False
>>         bus.register_object('/nic/twigpilot', self, None)
>>
>>     def Release(self):
>>         print('{}: Advertisement Released!'.format(self))
>>
>>
>> def main():
>>     bus =3D pydbus.SystemBus()
>>     adaptor =3D bus.get('org.bluez', '/org/bluez/hci0')
>>     adaptor.Powered =3D True
>>     adaptor.Alias =3D 'SeeMe'
>>
>>     advertisement =3D Advertisement(bus)
>>     advertisement.IncludeTxPower =3D True
>>
>>     #adaptor.RegisterAdvertisement('/nic/twigpilot', {})
>>
>>     loop =3D GLib.MainLoop()
>>     try:
>>         loop.run()
>>     except KeyboardInterrupt:
>>         loop.quit()
>>
>> if __name__ =3D=3D '__main__':
>>     main()--
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoot=
h" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Luiz Augusto von Dentz
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH] Bluetooth: hci_nokia: select BT_HCIUART_H4
From: Tobias Regnery @ 2017-05-08  9:39 UTC (permalink / raw)
  To: marcel, gustavo, johan.hedberg, linux-bluetooth, linux-kernel
  Cc: sre, Tobias Regnery

We see the following build failure with CONFIG_BT_HCIUART_NOKIA=y and
CONFIG_BT_HCIUART_H4=n:

drivers/bluetooth/hci_nokia.c: In function 'nokia_recv':
drivers/bluetooth/hci_nokia.c:644:18: error: implicit declaration of function 'h4_recv_buf' [-Werror=implicit-function-declaration]
...

Fix this by selecting the BT_HCIUART_H4 symbol like all the other users
of the protocoll.

Fixes: 7bb318680e86 ("Bluetooth: add nokia driver")
Signed-off-by: Tobias Regnery <tobias.regnery@gmail.com>
---
 drivers/bluetooth/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index e5fd24d90b0a..35952a94875e 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -97,6 +97,7 @@ config BT_HCIUART_NOKIA
 	depends on BT_HCIUART
 	depends on BT_HCIUART_SERDEV
 	depends on PM
+	select BT_HCIUART_H4
 	help
 	  Nokia H4+ is serial protocol for communication between Bluetooth
 	  device and host. This protocol is required for Bluetooth devices
-- 
2.11.0

^ permalink raw reply related

* Re: BLE Advertisement frustrations with pydbus
From: Luiz Augusto von Dentz @ 2017-05-08 10:18 UTC (permalink / raw)
  To: Barry Byford; +Cc: Travis Griggs, Bluez mailing list
In-Reply-To: <CAAu3APZy=NAKySrY5xUJt+arxvk3KPG4_rZULYuK84MjYWfk0g@mail.gmail.com>

Hi Barry,

On Mon, May 8, 2017 at 11:51 AM, Barry Byford <31baz66@gmail.com> wrote:
> Hello Luiz & Travis,
>
> I've been taking a look at this also
>
> On 8 May 2017 at 09:01, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wro=
te:
>> On Sat, May 6, 2017 at 1:28 AM, Travis Griggs <travisgriggs@gmail.com> w=
rote:
>>> $ sudo busctl get-property :1.5 /nic/twigpilot org.bluez.LEAdvertisemen=
t1 Type
>>> s =E2=80=9Cperipheral"
>>>
>>> So I *am* able to get the Type using busctl. Why is that bluetoothd can=
not? Using busctl introspect, I see that the pydbus variant automagically m=
akes a lot more available than the dubs-python variant did.
>>>
>>> Any hints? Pointers? Help?
>>
>> Does pydbus have ObjectManager support?
>
> Looking at the following entry in the libraries issue list it seems
> like it does.
> https://github.com/LEW21/pydbus/issues/28
> Is there anything in particular we should be testing for?

This is support for ObjectManager as a client, I was asking for the
server side so we can query the advertisement objects. Though this
used to work even without ObjectManager support so perhaps there is
some regression.

>
>> What about GetAll properties?
> Yes it does. It creates these standard interfaces automatically based
> on the XML in the Python class doc string. So for example Get and
> GetAll give the following:
>
>
> $ busctl call ukBaz.bluezero /ukBaz/bluezero
> org.freedesktop.DBus.Properties Get ss org.bluez.LEAdvertisement1 Type
>
> v s "peripheral"
>
> $ busctl call ukBaz.bluezero /ukBaz/bluezero
> org.freedesktop.DBus.Properties GetAll s org.bluez.LEAdvertisement1
>
> a{sv} 3 "Type" s "peripheral" "SolicitUUIDs" as 1 "180F"
> "IncludeTxPower" b false
>
>
>> You could perhaps try to sniff the message with eavesdrop option:
>>
>> https://wiki.ubuntu.com/DebuggingDBus
>
> Good suggestion. I'll try that later.
>
>>
>>> TIA
>>>
>>> =E2=80=94=E2=80=94
>>>
>>> #!/usr/bin/env python3
>>>
>>> import pydbus
>>> from gi.repository import GLib
>>>
>>> class Advertisement(object):
>>>     """
>>>       <node>
>>>         <interface name=3D"org.bluez.LEAdvertisement1">
>>>           <method name=3D"Release">
>>>             <annotation name=3D"org.freedesktop.DBus.Method.NoReply" va=
lue=3D"true"/>
>>>           </method>
>>>           <annotation name=3D"org.freedesktop.DBus.Properties.Propertie=
sChanged" value=3D"const"/>
>>>           <property name=3D"Type" type=3D"s" access=3D"read"/>
>>>           <property name=3D"ServiceUUIDs" type=3D"as" access=3D"read"/>
>>>           <property name=3D"ManufacturerData" type=3D"a{sv}" access=3D"=
read"/>
>>>           <property name=3D"SolicitUUIDs" type=3D"as" access=3D"read"/>
>>>           <property name=3D"ServiceData" type=3D"a{sv}" access=3D"read"=
/>
>>>           <property name=3D"IncludeTxPower" type=3D"b" access=3D"read"/=
>
>>>         </interface>
>>>       </node>
>>>     """
>>>
>>>     def __init__(self, bus):
>>>         self.Type =3D 'peripheral'
>>>         self.ServiceUUIDs =3D []
>>>         self.ManufacturerData =3D {}
>>>         self.SolicitUUIDs =3D []
>>>         self.ServiceData =3D {}
>>>         self.IncludeTxPower =3D False
>>>         bus.register_object('/nic/twigpilot', self, None)
>>>
>>>     def Release(self):
>>>         print('{}: Advertisement Released!'.format(self))
>>>
>>>
>>> def main():
>>>     bus =3D pydbus.SystemBus()
>>>     adaptor =3D bus.get('org.bluez', '/org/bluez/hci0')
>>>     adaptor.Powered =3D True
>>>     adaptor.Alias =3D 'SeeMe'
>>>
>>>     advertisement =3D Advertisement(bus)
>>>     advertisement.IncludeTxPower =3D True
>>>
>>>     #adaptor.RegisterAdvertisement('/nic/twigpilot', {})
>>>
>>>     loop =3D GLib.MainLoop()
>>>     try:
>>>         loop.run()
>>>     except KeyboardInterrupt:
>>>         loop.quit()
>>>
>>> if __name__ =3D=3D '__main__':
>>>     main()--
>>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoo=
th" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>
>>
>> --
>> Luiz Augusto von Dentz
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoot=
h" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--=20
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH] tools: add logitech diNovo rules for hid2hci
From: Konrad Zapalowicz @ 2017-05-08 11:00 UTC (permalink / raw)
  To: marcel; +Cc: luiz.von.dentz, linux-bluetooth, Konrad Zapałowicz

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]

From: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>

It has been reported that th Lenovo diNovo set of BT wireless devices
works only when is managed by hidraw instead of hiddev. This patch adds
vendor and product ids for these devices so that it is possible to use.

This patch is based on work provided by:
 * Tommy <mesilliac@gmail.com>
 * Martin G Miller <mgmiller@optonline.net>
---
 tools/hid2hci.rules | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/hid2hci.rules b/tools/hid2hci.rules
index db6bb03..7273167 100644
--- a/tools/hid2hci.rules
+++ b/tools/hid2hci.rules
@@ -13,6 +13,12 @@ ATTR{bInterfaceClass}=="03", ATTR{bInterfaceSubClass}=="01", ATTR{bInterfaceProt
 # Logitech devices
 KERNEL=="hiddev*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[345abce]|c71[34bc]", \
   RUN+="hid2hci --method=logitech-hid --devpath=%p"
+# Logitech, Inc. diNovo Edge Keyboard
+KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c714", \
+  RUN+="hid2hci --method=logitech-hid --devpath=%p"
+# Logitech, Inc. diNovo 2
+KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c704", \
+  RUN+="hid2hci --method=logitech-hid --devpath=%p"
 
 ENV{DEVTYPE}!="usb_device", GOTO="hid2hci_end"
 
-- 
2.7.4

^ permalink raw reply related

* [PATCH] Bluetooth: btusb: set HCI_QUIRK_BROKEN_LOCAL_COMMANDS for 0x0a5c:0x21f3
From: Graham Gower @ 2017-05-08 11:08 UTC (permalink / raw)
  To: linux-bluetooth, graham.gower

Card labelled BCM943228HMB found in Lenovo X131e laptop.

$ usb-devices
...
T:  Bus=02 Lev=02 Prnt=02 Port=04 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0a5c ProdID=21f3 Rev=01.12
S:  Manufacturer=Broadcom Corp
S:  Product=BCM20702A0
S:  SerialNumber=B00594EAFD30
C:  #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=btusb
I:  If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
...

$ hcidump &hciconfig hci0 up
...
commands
< HCI Command: Set Event Mask Page 2 (0x03|0x0063) plen 8
    Mask: 0x0000000000000000
> HCI Event: Command Complete (0x0e) plen 4
    Set Event Mask Page 2 (0x03|0x0063) ncmd 1
    status 0x01
    Error: Unknown HCI Command
---
 drivers/bluetooth/btusb.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 7fa373b..7be8cf1 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -66,6 +66,7 @@ static struct usb_driver btusb_driver;
 #define BTUSB_BCM2045		0x40000
 #define BTUSB_IFNUM_2		0x80000
 #define BTUSB_CW6622		0x100000
+#define BTUSB_BCM21F3		0x200000
 
 static const struct usb_device_id btusb_table[] = {
 	/* Generic Bluetooth USB device */
@@ -127,6 +128,10 @@ static const struct usb_device_id btusb_table[] = {
 	/* Broadcom BCM20702A0 */
 	{ USB_DEVICE(0x413c, 0x8197) },
 
+	/* Broadcom BCM20702A0 */
+	{ USB_DEVICE(0x0a5c, 0x21f3),
+	  .driver_info = BTUSB_BCM21F3 | BTUSB_BCM_PATCHRAM },
+
 	/* Broadcom BCM20702B0 (Dynex/Insignia) */
 	{ USB_DEVICE(0x19ff, 0x0239), .driver_info = BTUSB_BCM_PATCHRAM },
 
@@ -2994,6 +2999,9 @@ static int btusb_probe(struct usb_interface *intf,
 	if (id->driver_info & BTUSB_BCM2045)
 		set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
 
+	if (id->driver_info & BTUSB_BCM21F3)
+		set_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks);
+
 	if (id->driver_info & BTUSB_BCM92035)
 		hdev->setup = btusb_setup_bcm92035;
 
-- 
2.9.0


^ permalink raw reply related

* Re: [PATCH] tools: add logitech diNovo rules for hid2hci
From: Von Dentz, Luiz @ 2017-05-08 11:19 UTC (permalink / raw)
  To: Konrad Zapalowicz; +Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org
In-Reply-To: <1494241210-27307-1-git-send-email-bergo.torino@gmail.com>

Hi Konrad,

On Mon, May 8, 2017 at 2:00 PM, Konrad Zapalowicz
<konrad.zapalowicz@canonical.com> wrote:
> From: Konrad Zapa=C5=82owicz <konrad.zapalowicz@canonical.com>
>
> It has been reported that th Lenovo diNovo set of BT wireless devices
> works only when is managed by hidraw instead of hiddev. This patch adds
> vendor and product ids for these devices so that it is possible to use.
>
> This patch is based on work provided by:
>  * Tommy <mesilliac@gmail.com>
>  * Martin G Miller <mgmiller@optonline.net>
> ---
>  tools/hid2hci.rules | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/tools/hid2hci.rules b/tools/hid2hci.rules
> index db6bb03..7273167 100644
> --- a/tools/hid2hci.rules
> +++ b/tools/hid2hci.rules
> @@ -13,6 +13,12 @@ ATTR{bInterfaceClass}=3D=3D"03", ATTR{bInterfaceSubCla=
ss}=3D=3D"01", ATTR{bInterfaceProt
>  # Logitech devices
>  KERNEL=3D=3D"hiddev*", ATTRS{idVendor}=3D=3D"046d", ATTRS{idProduct}=3D=
=3D"c70[345abce]|c71[34bc]", \
>    RUN+=3D"hid2hci --method=3Dlogitech-hid --devpath=3D%p"
> +# Logitech, Inc. diNovo Edge Keyboard
> +KERNEL=3D=3D"hidraw*", ATTRS{idVendor}=3D=3D"046d", ATTRS{idProduct}=3D=
=3D"c714", \
> +  RUN+=3D"hid2hci --method=3Dlogitech-hid --devpath=3D%p"
> +# Logitech, Inc. diNovo 2
> +KERNEL=3D=3D"hidraw*", ATTRS{idVendor}=3D=3D"046d", ATTRS{idProduct}=3D=
=3D"c704", \
> +  RUN+=3D"hid2hci --method=3Dlogitech-hid --devpath=3D%p"
>
>  ENV{DEVTYPE}!=3D"usb_device", GOTO=3D"hid2hci_end"
>
> --
> 2.7.4

Interesting, is this preferable than creating a kernel driver that
does the same thing? hid2hci was initially intended to switch the
controller from hid mode to hci mode, but in this case there is
nothing related to hci, or bluetooth, if it is just doing hiddev to
hidraw.

^ permalink raw reply

* Re: [PATCH] tools: add logitech diNovo rules for hid2hci
From: Konrad Zapalowicz @ 2017-05-08 11:45 UTC (permalink / raw)
  To: Von Dentz, Luiz; +Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org
In-Reply-To: <CACumGOKUj=FZOr99KyjJqu2bjdFpF73t1VBcLo6v1PScDV80sA@mail.gmail.com>

On 05/08, Von Dentz, Luiz wrote:
> Hi Konrad,
> 
> On Mon, May 8, 2017 at 2:00 PM, Konrad Zapalowicz
> <konrad.zapalowicz@canonical.com> wrote:
> > From: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>
> >
> > It has been reported that th Lenovo diNovo set of BT wireless devices
> > works only when is managed by hidraw instead of hiddev. This patch adds
> > vendor and product ids for these devices so that it is possible to use.
> >
> > This patch is based on work provided by:
> >  * Tommy <mesilliac@gmail.com>
> >  * Martin G Miller <mgmiller@optonline.net>
> > ---
> >  tools/hid2hci.rules | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/tools/hid2hci.rules b/tools/hid2hci.rules
> > index db6bb03..7273167 100644
> > --- a/tools/hid2hci.rules
> > +++ b/tools/hid2hci.rules
> > @@ -13,6 +13,12 @@ ATTR{bInterfaceClass}=="03", ATTR{bInterfaceSubClass}=="01", ATTR{bInterfaceProt
> >  # Logitech devices
> >  KERNEL=="hiddev*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[345abce]|c71[34bc]", \
> >    RUN+="hid2hci --method=logitech-hid --devpath=%p"
> > +# Logitech, Inc. diNovo Edge Keyboard
> > +KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c714", \
> > +  RUN+="hid2hci --method=logitech-hid --devpath=%p"
> > +# Logitech, Inc. diNovo 2
> > +KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c704", \
> > +  RUN+="hid2hci --method=logitech-hid --devpath=%p"
> >
> >  ENV{DEVTYPE}!="usb_device", GOTO="hid2hci_end"
> >
> > --
> > 2.7.4
> 
> Interesting, is this preferable than creating a kernel driver that
> does the same thing? hid2hci was initially intended to switch the
> controller from hid mode to hci mode, but in this case there is
> nothing related to hci, or bluetooth, if it is just doing hiddev to
> hidraw.

Hey,

Interesting suggestion. The reason I have proposed it this way is that
we have already a patch that we ship for a while now and know that it
works. Also this way is a bit easier for spreading the fix around as
updating bluez is simpler than the kernel. Last but not least I do not
have the diNovo set to work on the module. Having said that I understand
your point and I agree.

Thanks,
Konrad

^ permalink raw reply

* Re: BLE Advertisement frustrations with pydbus
From: Travis Griggs @ 2017-05-08 17:43 UTC (permalink / raw)
  To: Bluez mailing list
In-Reply-To: <CABBYNZJm0ViS8PZmHRno4T_rOjcJzvQbMfDMmAZ9W5xf-d9Bkg@mail.gmail.com>


> On May 8, 2017, at 1:01 AM, Luiz Augusto von Dentz =
<luiz.dentz@gmail.com> wrote:
>=20
> Hi Travis,
>=20
> On Sat, May 6, 2017 at 1:28 AM, Travis Griggs <travisgriggs@gmail.com> =
wrote:
>> I=E2=80=99m trying to switch to using pydbus (instead of deprecated =
dbus-python, which the bluez examples are based on). I=E2=80=99m running =
on stretch with bluez 5.43. My code is at the bottom (and here -> =
https://gist.github.com/travisgriggs/d8e14dcccf46751804456dc74da1e5e6). =
I=E2=80=99m running into a problem when I try to RegisterAdvertisement. =
What I can=E2=80=99t seem to discern is what is different between this =
and the old approach. The bluetooth driver fails around =
advertising:c:175
>>=20
>>    DBusMessageIter iter;
>>    const char *msg_type;
>>=20
>>    if (!g_dbus_proxy_get_property(proxy, "Type", &iter))
>>        return false;
>>=20
>> The g_dbus_proxy_get_property() call fails. What I don=E2=80=99t =
understand though is this. If I modify my program to NOT =
RegisterAdvertisement(), but just sit there with the advertisement =
object on the bus, I can do the following:
>>=20
>> $ sudo busctl get-property :1.5 /nic/twigpilot =
org.bluez.LEAdvertisement1 Type
>> s =E2=80=9Cperipheral"
>>=20
>> So I *am* able to get the Type using busctl. Why is that bluetoothd =
cannot? Using busctl introspect, I see that the pydbus variant =
automagically makes a lot more available than the dubs-python variant =
did.
>>=20
>> Any hints? Pointers? Help?
>=20
> Does pydbus have ObjectManager support? What about GetAll properties?
> You could perhaps try to sniff the message with eavesdrop option:
>=20
> https://wiki.ubuntu.com/DebuggingDBus
>=20
>>=20

That=E2=80=99s a great question. My neophyte skills with dbus are not =
that strong, but the following DOES seem odd to me:

$ sudo busctl introspect :1.5 /nic/twigpilot
NAME                                TYPE      SIGNATURE RESULT/VALUE =
FLAGS
org.bluez.LEAdvertisement1          interface -         -            -
.Release                            method    -         -            =
no-reply
.IncludeTxPower                     property  b         true         =
emits-change
.ManufacturerData                   property  a{sv}     0            =
emits-change
.ServiceData                        property  a{sv}     0            =
emits-change
.ServiceUUIDs                       property  as        0            =
emits-change
.SolicitUUIDs                       property  as        0            =
emits-change
.Type                               property  s         "peripheral" =
emits-change
org.freedesktop.DBus.Introspectable interface -         -            -
.Introspect                         method    -         s            -
org.freedesktop.DBus.Peer           interface -         -            -
.GetMachineId                       method    -         s            -
.Ping                               method    -         -            -
org.freedesktop.DBus.Properties     interface -         -            -
.Get                                method    ss        v            -
.GetAll                             method    s         a{sv}        -
.Set                                method    ssv       -            -
.PropertiesChanged                  signal    sa{sv}as  -            -

So it seems to think it does=E2=80=A6 And as aforementioned, I can get =
the Type:

$ sudo busctl get-property :1.5 /nic/twigpilot =
org.bluez.LEAdvertisement1 Type
s =E2=80=9Cperipheral"

BUT=E2=80=A6 if I try to access as GetAll as you suggest:

$ sudo busctl call :1.5 /nic/twigpilot org.freedesktop.DBus.Properties =
GetAll
No such interface 'org.freedesktop.DBus.Properties' on object at path =
/nic/twigpilot

Which is really weird, because the `introspect` command seems to show it =
is there.=20

(sorry if this is sent twice, I got a weird response back the first time =
I submitted this message)=

^ permalink raw reply

* Re: BLE Advertisement frustrations with pydbus
From: Cody P Schafer @ 2017-05-08 18:07 UTC (permalink / raw)
  To: Travis Griggs; +Cc: Bluez mailing list
In-Reply-To: <48520255-46C9-4696-8420-15DB4E8234B4@gmail.com>

> NAME                                TYPE      SIGNATURE RESULT/VALUE FLAG=
S
> .GetAll                             method    s         a{sv}        -

>
> BUT=E2=80=A6 if I try to access as GetAll as you suggest:
>
> $ sudo busctl call :1.5 /nic/twigpilot org.freedesktop.DBus.Properties Ge=
tAll
> No such interface 'org.freedesktop.DBus.Properties' on object at path /ni=
c/twigpilot

GetAll takes a string argument which is the interface name. Try:

$ sudo busctl call :1.5 /nic/twigpilot org.freedesktop.DBus.Properties
GetAll org.bluez.LEAdvertisement1

Or similar.

^ permalink raw reply

* Re: [PATCH] Bluetooth: hci_nokia: select BT_HCIUART_H4
From: Sebastian Reichel @ 2017-05-08 18:28 UTC (permalink / raw)
  To: Tobias Regnery; +Cc: marcel, johan.hedberg, linux-bluetooth, linux-kernel
In-Reply-To: <20170508093911.25228-1-tobias.regnery@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]

Hi,

On Mon, May 08, 2017 at 11:39:11AM +0200, Tobias Regnery wrote:
> We see the following build failure with CONFIG_BT_HCIUART_NOKIA=y and
> CONFIG_BT_HCIUART_H4=n:
> 
> drivers/bluetooth/hci_nokia.c: In function 'nokia_recv':
> drivers/bluetooth/hci_nokia.c:644:18: error: implicit declaration of function 'h4_recv_buf' [-Werror=implicit-function-declaration]
> ...
> 
> Fix this by selecting the BT_HCIUART_H4 symbol like all the other users
> of the protocoll.
> 
> Fixes: 7bb318680e86 ("Bluetooth: add nokia driver")
> Signed-off-by: Tobias Regnery <tobias.regnery@gmail.com>

Reviewed-by: Sebastian Reichel <sre@kernel.org>

-- Sebastian

> ---
>  drivers/bluetooth/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
> index e5fd24d90b0a..35952a94875e 100644
> --- a/drivers/bluetooth/Kconfig
> +++ b/drivers/bluetooth/Kconfig
> @@ -97,6 +97,7 @@ config BT_HCIUART_NOKIA
>  	depends on BT_HCIUART
>  	depends on BT_HCIUART_SERDEV
>  	depends on PM
> +	select BT_HCIUART_H4
>  	help
>  	  Nokia H4+ is serial protocol for communication between Bluetooth
>  	  device and host. This protocol is required for Bluetooth devices
> -- 
> 2.11.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: [PATCH 0/4] TI Bluetooth serdev support
From: Sebastian Reichel @ 2017-05-08 19:07 UTC (permalink / raw)
  To: Adam Ford
  Cc: Rob Herring, Marcel Holtmann, linux-bluetooth, Mark Rutland,
	devicetree, Johan Hedberg, Gustavo Padovan, Satish Patel, Wei Xu,
	Eyal Reizer, netdev, linux-arm-kernel
In-Reply-To: <CAHCN7x+Mq=b6RN-ezU0400W=H=D7DR+Es1FHtT4GyozpVd8ALA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3458 bytes --]

Hi,

On Fri, May 05, 2017 at 09:51:33AM -0500, Adam Ford wrote:
> On Sun, Apr 30, 2017 at 11:04 AM, Sebastian Reichel <sre@kernel.org> wrote:
> > On Sun, Apr 30, 2017 at 10:14:20AM -0500, Adam Ford wrote:
> >> On Wed, Apr 5, 2017 at 1:30 PM, Rob Herring <robh@kernel.org> wrote:
> >> > This series adds serdev support to the HCI LL protocol used on TI BT
> >> > modules and enables support on HiKey board with with the WL1835 module.
> >> > With this the custom TI UIM daemon and btattach are no longer needed.
> >>
> >> Without UIM daemon, what instruction do you use to load the BT firmware?
> >>
> >> I was thinking 'hciattach' but I was having trouble.  I was hoping you
> >> might have some insight.
> >>
> >>  hciattach -t 30 -s 115200 /dev/ttymxc1 texas 3000000 flow  Just
> >> returns a timeout.
> >>
> >> I modified my i.MX6 device tree per the binding documentation and
> >> setup the regulators and enable GPIO pins.
> >
> > If you configured everything correctly no userspace interaction is
> > required. The driver should request the firmware automatically once
> > you power up the bluetooth device.
> >
> > Apart from DT changes make sure, that the following options are
> > enabled and check dmesg for any hints.
> >
> > CONFIG_SERIAL_DEV_BUS
> > CONFIG_SERIAL_DEV_CTRL_TTYPORT
> > CONFIG_BT_HCIUART
> > CONFIG_BT_HCIUART_LL
> 
> I have enabled those flags, and I have updated my device tree.
> I am testing this on an OMAP3630 (DM3730) board with a WL1283.  I am
> getting a lot of timeout errors.  I tested this against the original
> implemention I had in pdata-quirks.c using the ti-st driver, uim & and
> the btwilink driver.
> 
> I pulled in some of the newer patches to enable the wl1283-st, but I
> am obviously missing something.
> 
> I   58.717651] Bluetooth: hci0: Reading TI version information failed
> (-110)
> [   58.724853] Bluetooth: hci0: download firmware failed, retrying...
> [   60.957641] Bluetooth: hci0 command 0x1001 tx timeout
> [   68.957641] Bluetooth: hci0: Reading TI version information failed
> (-110)
> [   68.964843] Bluetooth: hci0: download firmware failed, retrying...
> [   69.132171] Bluetooth: Unknown HCI packet type 06
> [   69.138244] Bluetooth: Unknown HCI packet type 0c
> [   69.143249] Bluetooth: Unknown HCI packet type 40
> [   69.148498] Bluetooth: Unknown HCI packet type 20
> [   69.153533] Bluetooth: Data length is too large
> [   69.158569] Bluetooth: Unknown HCI packet type a0
> [   69.163574] Bluetooth: Unknown HCI packet type 00
> [   69.168731] Bluetooth: Unknown HCI packet type 00
> [   69.173736] Bluetooth: Unknown HCI packet type 34
> [   69.178924] Bluetooth: Unknown HCI packet type 91
> [   71.197631] Bluetooth: hci0 command 0x1001 tx timeout
> [   79.197662] Bluetooth: hci0: Reading TI version information failed (-110)
>
> Since the pdata-quirks and original ti-st drivers work together, I
> know the hardware is fine.  The only change to the device tree is the
> addition of the Bluetooth container:
> 
> bluetooth {
>   compatible = "ti,wl1283-st";
>   enable-gpios = <&gpio6 2 GPIO_ACTIVE_HIGH>;
> };
> 
> Any thoughts or suggestions to try? I get similar behavior on an
> i.MX6 board with a wl1837-st module as well.

Looks like its loosing bytes. I suggest to have a look at
pinmuxing (esp. for cts & rts) and maybe add some debug
prints to see where it starts failing.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* Re: BLE Advertisement frustrations with pydbus
From: Travis Griggs @ 2017-05-08 20:26 UTC (permalink / raw)
  To: Bluez mailing list
In-Reply-To: <CAPoQQ-1UJ45tM4pcKPmDin=J-Tf__52Gomt6xE9OwJDULY5rLg@mail.gmail.com>


> On May 8, 2017, at 11:07 AM, Cody P Schafer <dev@codyps.com> wrote:
>=20
>> NAME                                TYPE      SIGNATURE RESULT/VALUE =
FLAGS
>> .GetAll                             method    s         a{sv}        =
-
>=20
>>=20
>> BUT=E2=80=A6 if I try to access as GetAll as you suggest:
>>=20
>> $ sudo busctl call :1.5 /nic/twigpilot =
org.freedesktop.DBus.Properties GetAll
>> No such interface 'org.freedesktop.DBus.Properties' on object at path =
/nic/twigpilot
>=20
> GetAll takes a string argument which is the interface name. Try:
>=20
> $ sudo busctl call :1.5 /nic/twigpilot org.freedesktop.DBus.Properties
> GetAll org.bluez.LEAdvertisement1

Argh (pun). I *thought* I had had that query working on Friday and was =
surprised when I was running it this morning to report that it =
wouldn=E2=80=99t work. So yes,

$ sudo busctl call :1.5 /nic/twigpilot org.freedesktop.DBus.Properties =
GetAll s org.bluez.LEAdvertisement1
a{sv} 6 "ServiceData" a{sv} 0 "ServiceUUIDs" as 0 "SolicitUUIDs" as 0 =
"Type" s "peripheral" "IncludeTxPower" b true "ManufacturerData" a{sv} 0

I *can* do the GetAll() query as Luis asked for. And resolves my =
intermediate question. But brings me back to the original question which =
behavior still persists.

As I said, dbus is a relatively new thing for me. I *think* naively that =
the problem lies somewhere around this call:

bus.register_object('/nic/twigpilot', self, None)

When I look at just simple `busctl` output, I see (amongst others):

$ busctl
NAME                             PID PROCESS         USER             =
CONNECTION    UNIT                      SESSION    DESCRIPTION       =20
...
:1.15                           1677 python3         root             =
:1.15         serial-getty@ttyS0.ser=E2=80=A6ce -          -             =
    =20
...
:1.4                            1385 bluetoothd      root             =
:1.4          bluetooth.service         -          -                 =20
org.bluez                       1385 bluetoothd      root             =
:1.4          bluetooth.service         -          -                 =20

In my naive understanding=E2=80=A6 my python3 has an unnamed connection =
to the system bus (i.e. :1.15). And the bluetoothd has an unnamed =
connection at :1.14. But bluetoothd has also set up a repeatably =
accessible service at org.bluez. My python program has registered an =
object that has the necessary interfaces at  the path /nic/twigpilot, =
but it hasn=E2=80=99t done anything to tie it in to the org.bluez =
service. And yet, when I look at the docs =
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-ap=
i.txt=E2=80=A6 It describes this object as belonging to the org.bluez =
service.

pydbus has an API higher up than register_object() called publish() =
(https://github.com/LEW21/pydbus/blob/master/doc/tutorial.rst#object-publi=
cation) which not only places the object at the given path, but also =
"binds the service to the given bus name=E2=80=9D. But if I use that api =
instead of register_object(), I get the following error=20

RuntimeError: name already exists on the bus

It could be that I=E2=80=99m barking up the completely wrong tree with =
this. I do find myself wishing BLE were exposed via a good old fashioned =
C library or some sort of pseudo file system thing like sysfs. But I=E2=80=
=99m trying to keep an open mind and hope the value-of-dbus light bulb =
will trigger soon.



^ permalink raw reply

* Re: BLE Advertisement frustrations with pydbus
From: Barry Byford @ 2017-05-08 20:46 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: Travis Griggs, Bluez mailing list
In-Reply-To: <CABBYNZKM=EsXfRB1EOiB+7ojaSwXypQWPSGqromVJYtoQ+7Kug@mail.gmail.com>

Hello,

On 8 May 2017 at 11:18, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote=
:
> Hi Barry,
>
> On Mon, May 8, 2017 at 11:51 AM, Barry Byford <31baz66@gmail.com> wrote:
>> Hello Luiz & Travis,
>>
>> I've been taking a look at this also
>>
>> On 8 May 2017 at 09:01, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wr=
ote:
>>> On Sat, May 6, 2017 at 1:28 AM, Travis Griggs <travisgriggs@gmail.com> =
wrote:
>>>> $ sudo busctl get-property :1.5 /nic/twigpilot org.bluez.LEAdvertiseme=
nt1 Type
>>>> s =E2=80=9Cperipheral"
>>>>
>>>> So I *am* able to get the Type using busctl. Why is that bluetoothd ca=
nnot? Using busctl introspect, I see that the pydbus variant automagically =
makes a lot more available than the dubs-python variant did.
>>>>
>>>> Any hints? Pointers? Help?
>>>
>>> Does pydbus have ObjectManager support?
>>
>> Looking at the following entry in the libraries issue list it seems
>> like it does.
>> https://github.com/LEW21/pydbus/issues/28
>> Is there anything in particular we should be testing for?
>
> This is support for ObjectManager as a client, I was asking for the
> server side so we can query the advertisement objects. Though this
> used to work even without ObjectManager support so perhaps there is
> some regression.

Given the information below, this seems like it is the issue.
Does this mean it is a bug in BlueZ?
Or is this how it is intend to work going forward?

>
>>
>>> What about GetAll properties?
>> Yes it does. It creates these standard interfaces automatically based
>> on the XML in the Python class doc string. So for example Get and
>> GetAll give the following:
>>
>>
>> $ busctl call ukBaz.bluezero /ukBaz/bluezero
>> org.freedesktop.DBus.Properties Get ss org.bluez.LEAdvertisement1 Type
>>
>> v s "peripheral"
>>
>> $ busctl call ukBaz.bluezero /ukBaz/bluezero
>> org.freedesktop.DBus.Properties GetAll s org.bluez.LEAdvertisement1
>>
>> a{sv} 3 "Type" s "peripheral" "SolicitUUIDs" as 1 "180F"
>> "IncludeTxPower" b false
>>
>>
>>> You could perhaps try to sniff the message with eavesdrop option:
>>>
>>> https://wiki.ubuntu.com/DebuggingDBus

This was a good suggestion. And you were correct about your suspicion
that it was missing ObjectManager.

method call time=3D1494270131.995970 sender=3D:1.13 ->
destination=3Dorg.freedesktop.DBus serial=3D78 path=3D/org/freedesktop/DBus=
;
interface=3Dorg.freedesktop.DBus; member=3DAddMatch
   string "type=3D'signal',sender=3D':1.51',path=3D'/ukBaz/bluezero',interf=
ace=3D'org.freedesktop.DBus.Properties',member=3D'PropertiesChanged',arg0=
=3D'org.bluez.LEAdvertisement1'"
method return time=3D1494270131.996002 sender=3Dorg.freedesktop.DBus ->
destination=3D:1.13 serial=3D33 reply_serial=3D78
method call time=3D1494270131.996317 sender=3D:1.13 -> destination=3D:1.51
serial=3D79 path=3D/ukBaz/bluezero;
interface=3Dorg.freedesktop.DBus.Properties; member=3DGetAll
   string "org.bluez.LEAdvertisement1"
method call time=3D1494270131.996358 sender=3D:1.13 -> destination=3D:1.51
serial=3D80 path=3D/ukBaz/bluezero;
interface=3Dorg.freedesktop.DBus.ObjectManager; member=3DGetManagedObjects
error time=3D1494270131.997525 sender=3D:1.51 -> destination=3D:1.13
error_name=3Dorg.freedesktop.DBus.Error.UnknownMethod reply_serial=3D80
   string "No such interface 'org.freedesktop.DBus.ObjectManager' on
object at path /ukBaz/bluezero"


I'll do some investigation as to how difficult it is to implement
ObjectManager for this.


>>
>> Good suggestion. I'll try that later.
>>
>>>
>>>> TIA
>>>>
>>>> =E2=80=94=E2=80=94
>>>>
>>>> #!/usr/bin/env python3
>>>>
>>>> import pydbus
>>>> from gi.repository import GLib
>>>>
>>>> class Advertisement(object):
>>>>     """
>>>>       <node>
>>>>         <interface name=3D"org.bluez.LEAdvertisement1">
>>>>           <method name=3D"Release">
>>>>             <annotation name=3D"org.freedesktop.DBus.Method.NoReply" v=
alue=3D"true"/>
>>>>           </method>
>>>>           <annotation name=3D"org.freedesktop.DBus.Properties.Properti=
esChanged" value=3D"const"/>
>>>>           <property name=3D"Type" type=3D"s" access=3D"read"/>
>>>>           <property name=3D"ServiceUUIDs" type=3D"as" access=3D"read"/=
>
>>>>           <property name=3D"ManufacturerData" type=3D"a{sv}" access=3D=
"read"/>
>>>>           <property name=3D"SolicitUUIDs" type=3D"as" access=3D"read"/=
>
>>>>           <property name=3D"ServiceData" type=3D"a{sv}" access=3D"read=
"/>
>>>>           <property name=3D"IncludeTxPower" type=3D"b" access=3D"read"=
/>
>>>>         </interface>
>>>>       </node>
>>>>     """
>>>>
>>>>     def __init__(self, bus):
>>>>         self.Type =3D 'peripheral'
>>>>         self.ServiceUUIDs =3D []
>>>>         self.ManufacturerData =3D {}
>>>>         self.SolicitUUIDs =3D []
>>>>         self.ServiceData =3D {}
>>>>         self.IncludeTxPower =3D False
>>>>         bus.register_object('/nic/twigpilot', self, None)
>>>>
>>>>     def Release(self):
>>>>         print('{}: Advertisement Released!'.format(self))
>>>>
>>>>
>>>> def main():
>>>>     bus =3D pydbus.SystemBus()
>>>>     adaptor =3D bus.get('org.bluez', '/org/bluez/hci0')
>>>>     adaptor.Powered =3D True
>>>>     adaptor.Alias =3D 'SeeMe'
>>>>
>>>>     advertisement =3D Advertisement(bus)
>>>>     advertisement.IncludeTxPower =3D True
>>>>
>>>>     #adaptor.RegisterAdvertisement('/nic/twigpilot', {})
>>>>
>>>>     loop =3D GLib.MainLoop()
>>>>     try:
>>>>         loop.run()
>>>>     except KeyboardInterrupt:
>>>>         loop.quit()
>>>>
>>>> if __name__ =3D=3D '__main__':
>>>>     main()--
>>>> To unsubscribe from this list: send the line "unsubscribe linux-blueto=
oth" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>>
>>>
>>> --
>>> Luiz Augusto von Dentz
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoo=
th" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH 0/4] TI Bluetooth serdev support
From: Rob Herring @ 2017-05-08 21:12 UTC (permalink / raw)
  To: Adam Ford
  Cc: Sebastian Reichel, Marcel Holtmann, open list:BLUETOOTH DRIVERS,
	Mark Rutland, devicetree@vger.kernel.org, Johan Hedberg,
	Gustavo Padovan, Satish Patel, Wei Xu, Eyal Reizer, netdev,
	linux-arm-kernel@lists.infradead.org
In-Reply-To: <CAHCN7x+Mq=b6RN-ezU0400W=H=D7DR+Es1FHtT4GyozpVd8ALA@mail.gmail.com>

On Fri, May 5, 2017 at 9:51 AM, Adam Ford <aford173@gmail.com> wrote:
> On Sun, Apr 30, 2017 at 11:04 AM, Sebastian Reichel <sre@kernel.org> wrote:
>> Hi,
>>
>> On Sun, Apr 30, 2017 at 10:14:20AM -0500, Adam Ford wrote:
>>> On Wed, Apr 5, 2017 at 1:30 PM, Rob Herring <robh@kernel.org> wrote:
>>> > This series adds serdev support to the HCI LL protocol used on TI BT
>>> > modules and enables support on HiKey board with with the WL1835 module.
>>> > With this the custom TI UIM daemon and btattach are no longer needed.
>>>
>>> Without UIM daemon, what instruction do you use to load the BT firmware?
>>>
>>> I was thinking 'hciattach' but I was having trouble.  I was hoping you
>>> might have some insight.
>>>
>>>  hciattach -t 30 -s 115200 /dev/ttymxc1 texas 3000000 flow  Just
>>> returns a timeout.
>>>
>>> I modified my i.MX6 device tree per the binding documentation and
>>> setup the regulators and enable GPIO pins.
>>
>> If you configured everything correctly no userspace interaction is
>> required. The driver should request the firmware automatically once
>> you power up the bluetooth device.
>>
>> Apart from DT changes make sure, that the following options are
>> enabled and check dmesg for any hints.
>>
>> CONFIG_SERIAL_DEV_BUS
>> CONFIG_SERIAL_DEV_CTRL_TTYPORT
>> CONFIG_BT_HCIUART
>> CONFIG_BT_HCIUART_LL
>>
>
>
> I have enabled those flags, and I have updated my device tree.
> I am testing this on an OMAP3630 (DM3730) board with a WL1283.  I am
> getting a lot of timeout errors.  I tested this against the original
> implemention I had in pdata-quirks.c using the ti-st driver, uim & and
> the btwilink driver.
>
> I pulled in some of the newer patches to enable the wl1283-st, but I
> am obviously missing something.
>
> I   58.717651] Bluetooth: hci0: Reading TI version information failed
> (-110)
> [   58.724853] Bluetooth: hci0: download firmware failed, retrying...
> [   60.957641] Bluetooth: hci0 command 0x1001 tx timeout
> [   68.957641] Bluetooth: hci0: Reading TI version information failed
> (-110)
> [   68.964843] Bluetooth: hci0: download firmware failed, retrying...
> [   69.132171] Bluetooth: Unknown HCI packet type 06
> [   69.138244] Bluetooth: Unknown HCI packet type 0c
> [   69.143249] Bluetooth: Unknown HCI packet type 40
> [   69.148498] Bluetooth: Unknown HCI packet type 20
> [   69.153533] Bluetooth: Data length is too large
> [   69.158569] Bluetooth: Unknown HCI packet type a0
> [   69.163574] Bluetooth: Unknown HCI packet type 00
> [   69.168731] Bluetooth: Unknown HCI packet type 00
> [   69.173736] Bluetooth: Unknown HCI packet type 34
> [   69.178924] Bluetooth: Unknown HCI packet type 91
> [   71.197631] Bluetooth: hci0 command 0x1001 tx timeout
> [   79.197662] Bluetooth: hci0: Reading TI version information failed (-110)

There's a bug in serdev_device_write(), so if you have that function
you need either the fix I sent or the patch to make
serdev_device_writebuf atomic again. Both are on the linux-serial
list, but not in any tree yet.

Rob

^ permalink raw reply

* Re: [PATCH 0/4] TI Bluetooth serdev support
From: Baruch Siach @ 2017-05-09  4:48 UTC (permalink / raw)
  To: Rob Herring
  Cc: Adam Ford, Mark Rutland, devicetree@vger.kernel.org,
	Johan Hedberg, Gustavo Padovan, Marcel Holtmann,
	Sebastian Reichel, Wei Xu, open list:BLUETOOTH DRIVERS,
	Eyal Reizer, netdev, Satish Patel,
	linux-arm-kernel@lists.infradead.org
In-Reply-To: <CAL_JsqKBAPUPRtn+pEtz8B8pCrA=45RkEq6X_0i_HYoWsVmtyw@mail.gmail.com>

Hi Rob,

On Mon, May 08, 2017 at 04:12:16PM -0500, Rob Herring wrote:
> On Fri, May 5, 2017 at 9:51 AM, Adam Ford <aford173@gmail.com> wrote:
> > On Sun, Apr 30, 2017 at 11:04 AM, Sebastian Reichel <sre@kernel.org> wrote:
> >> On Sun, Apr 30, 2017 at 10:14:20AM -0500, Adam Ford wrote:
> >>> On Wed, Apr 5, 2017 at 1:30 PM, Rob Herring <robh@kernel.org> wrote:
> >>> > This series adds serdev support to the HCI LL protocol used on TI BT
> >>> > modules and enables support on HiKey board with with the WL1835 module.
> >>> > With this the custom TI UIM daemon and btattach are no longer needed.
> >>>
> >>> Without UIM daemon, what instruction do you use to load the BT firmware?
> >>>
> >>> I was thinking 'hciattach' but I was having trouble.  I was hoping you
> >>> might have some insight.
> >>>
> >>>  hciattach -t 30 -s 115200 /dev/ttymxc1 texas 3000000 flow  Just
> >>> returns a timeout.
> >>>
> >>> I modified my i.MX6 device tree per the binding documentation and
> >>> setup the regulators and enable GPIO pins.
> >>
> >> If you configured everything correctly no userspace interaction is
> >> required. The driver should request the firmware automatically once
> >> you power up the bluetooth device.
> >>
> >> Apart from DT changes make sure, that the following options are
> >> enabled and check dmesg for any hints.
> >>
> >> CONFIG_SERIAL_DEV_BUS
> >> CONFIG_SERIAL_DEV_CTRL_TTYPORT
> >> CONFIG_BT_HCIUART
> >> CONFIG_BT_HCIUART_LL
> >
> > I have enabled those flags, and I have updated my device tree.
> > I am testing this on an OMAP3630 (DM3730) board with a WL1283.  I am
> > getting a lot of timeout errors.  I tested this against the original
> > implemention I had in pdata-quirks.c using the ti-st driver, uim & and
> > the btwilink driver.
> >
> > I pulled in some of the newer patches to enable the wl1283-st, but I
> > am obviously missing something.
> >
> > I   58.717651] Bluetooth: hci0: Reading TI version information failed
> > (-110)
> > [   58.724853] Bluetooth: hci0: download firmware failed, retrying...
> > [   60.957641] Bluetooth: hci0 command 0x1001 tx timeout
> > [   68.957641] Bluetooth: hci0: Reading TI version information failed
> > (-110)
> > [   68.964843] Bluetooth: hci0: download firmware failed, retrying...
> > [   69.132171] Bluetooth: Unknown HCI packet type 06
> > [   69.138244] Bluetooth: Unknown HCI packet type 0c
> > [   69.143249] Bluetooth: Unknown HCI packet type 40
> > [   69.148498] Bluetooth: Unknown HCI packet type 20
> > [   69.153533] Bluetooth: Data length is too large
> > [   69.158569] Bluetooth: Unknown HCI packet type a0
> > [   69.163574] Bluetooth: Unknown HCI packet type 00
> > [   69.168731] Bluetooth: Unknown HCI packet type 00
> > [   69.173736] Bluetooth: Unknown HCI packet type 34
> > [   69.178924] Bluetooth: Unknown HCI packet type 91
> > [   71.197631] Bluetooth: hci0 command 0x1001 tx timeout
> > [   79.197662] Bluetooth: hci0: Reading TI version information failed (-110)
> 
> There's a bug in serdev_device_write(), so if you have that function
> you need either the fix I sent or the patch to make
> serdev_device_writebuf atomic again. Both are on the linux-serial
> list, but not in any tree yet.

You refer to the patches below, right?

  [PATCH] tty: serdev: fix serdev_device_write return value, 
  http://www.spinics.net/lists/linux-serial/msg26117.html

  [PATCH] serdev: Restore serdev_device_write_buf for atomic context,
  http://www.spinics.net/lists/linux-serial/msg26113.html

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox