<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/net/bluetooth, branch v2.6.30.2</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Bluetooth: Remove useless flush_work() causing lockdep warnings</title>
<updated>2009-05-27T07:15:57+00:00</updated>
<author>
<name>Dave Young</name>
<email>hidave.darkstar@gmail.com</email>
</author>
<published>2009-05-27T07:10:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4c713189485dbea875aecd1990daed74908e181d'/>
<id>4c713189485dbea875aecd1990daed74908e181d</id>
<content type='text'>
The calls to flush_work() are pointless in a single thread workqueue
and they are actually causing a lockdep warning.

=============================================
[ INFO: possible recursive locking detected ]
2.6.30-rc6-02911-gbb803cf #16
---------------------------------------------
bluetooth/2518 is trying to acquire lock:
 (bluetooth){+.+.+.}, at: [&lt;c0130c14&gt;] flush_work+0x28/0xb0

but task is already holding lock:
 (bluetooth){+.+.+.}, at: [&lt;c0130424&gt;] worker_thread+0x149/0x25e

other info that might help us debug this:
2 locks held by bluetooth/2518:
 #0:  (bluetooth){+.+.+.}, at: [&lt;c0130424&gt;] worker_thread+0x149/0x25e
 #1:  (&amp;conn-&gt;work_del){+.+...}, at: [&lt;c0130424&gt;] worker_thread+0x149/0x25e

stack backtrace:
Pid: 2518, comm: bluetooth Not tainted 2.6.30-rc6-02911-gbb803cf #16
Call Trace:
 [&lt;c03d64d9&gt;] ? printk+0xf/0x11
 [&lt;c0140d96&gt;] __lock_acquire+0x7ce/0xb1b
 [&lt;c0141173&gt;] lock_acquire+0x90/0xad
 [&lt;c0130c14&gt;] ? flush_work+0x28/0xb0
 [&lt;c0130c2e&gt;] flush_work+0x42/0xb0
 [&lt;c0130c14&gt;] ? flush_work+0x28/0xb0
 [&lt;f8b84966&gt;] del_conn+0x1c/0x84 [bluetooth]
 [&lt;c0130469&gt;] worker_thread+0x18e/0x25e
 [&lt;c0130424&gt;] ? worker_thread+0x149/0x25e
 [&lt;f8b8494a&gt;] ? del_conn+0x0/0x84 [bluetooth]
 [&lt;c0133843&gt;] ? autoremove_wake_function+0x0/0x33
 [&lt;c01302db&gt;] ? worker_thread+0x0/0x25e
 [&lt;c013355a&gt;] kthread+0x45/0x6b
 [&lt;c0133515&gt;] ? kthread+0x0/0x6b
 [&lt;c01034a7&gt;] kernel_thread_helper+0x7/0x10

Based on a report by Oliver Hartkopp &lt;oliver@hartkopp.net&gt;

Signed-off-by: Dave Young &lt;hidave.darkstar@gmail.com&gt;
Tested-by: Oliver Hartkopp &lt;oliver@hartkopp.net&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The calls to flush_work() are pointless in a single thread workqueue
and they are actually causing a lockdep warning.

=============================================
[ INFO: possible recursive locking detected ]
2.6.30-rc6-02911-gbb803cf #16
---------------------------------------------
bluetooth/2518 is trying to acquire lock:
 (bluetooth){+.+.+.}, at: [&lt;c0130c14&gt;] flush_work+0x28/0xb0

but task is already holding lock:
 (bluetooth){+.+.+.}, at: [&lt;c0130424&gt;] worker_thread+0x149/0x25e

other info that might help us debug this:
2 locks held by bluetooth/2518:
 #0:  (bluetooth){+.+.+.}, at: [&lt;c0130424&gt;] worker_thread+0x149/0x25e
 #1:  (&amp;conn-&gt;work_del){+.+...}, at: [&lt;c0130424&gt;] worker_thread+0x149/0x25e

stack backtrace:
Pid: 2518, comm: bluetooth Not tainted 2.6.30-rc6-02911-gbb803cf #16
Call Trace:
 [&lt;c03d64d9&gt;] ? printk+0xf/0x11
 [&lt;c0140d96&gt;] __lock_acquire+0x7ce/0xb1b
 [&lt;c0141173&gt;] lock_acquire+0x90/0xad
 [&lt;c0130c14&gt;] ? flush_work+0x28/0xb0
 [&lt;c0130c2e&gt;] flush_work+0x42/0xb0
 [&lt;c0130c14&gt;] ? flush_work+0x28/0xb0
 [&lt;f8b84966&gt;] del_conn+0x1c/0x84 [bluetooth]
 [&lt;c0130469&gt;] worker_thread+0x18e/0x25e
 [&lt;c0130424&gt;] ? worker_thread+0x149/0x25e
 [&lt;f8b8494a&gt;] ? del_conn+0x0/0x84 [bluetooth]
 [&lt;c0133843&gt;] ? autoremove_wake_function+0x0/0x33
 [&lt;c01302db&gt;] ? worker_thread+0x0/0x25e
 [&lt;c013355a&gt;] kthread+0x45/0x6b
 [&lt;c0133515&gt;] ? kthread+0x0/0x6b
 [&lt;c01034a7&gt;] kernel_thread_helper+0x7/0x10

Based on a report by Oliver Hartkopp &lt;oliver@hartkopp.net&gt;

Signed-off-by: Dave Young &lt;hidave.darkstar@gmail.com&gt;
Tested-by: Oliver Hartkopp &lt;oliver@hartkopp.net&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Don't trigger disconnect timeout for security mode 3 pairing</title>
<updated>2009-05-10T01:09:52+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-05-09T19:09:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3d7a9d1c7ee251a04095d43eec5a3f4ff3f710a8'/>
<id>3d7a9d1c7ee251a04095d43eec5a3f4ff3f710a8</id>
<content type='text'>
A remote device in security mode 3 that tries to connect will require
the pairing during the connection setup phase. The disconnect timeout
is now triggered within 10 milliseconds and causes the pairing to fail.

If a connection is not fully established and a PIN code request is
received, don't trigger the disconnect timeout. The either successful
or failing connection complete event will make sure that the timeout
is triggered at the right time.

The biggest problem with security mode 3 is that many Bluetooth 2.0
device and before use a temporary security mode 3 for dedicated
bonding.

Based on a report by Johan Hedberg &lt;johan.hedberg@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Johan Hedberg &lt;johan.hedberg@nokia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A remote device in security mode 3 that tries to connect will require
the pairing during the connection setup phase. The disconnect timeout
is now triggered within 10 milliseconds and causes the pairing to fail.

If a connection is not fully established and a PIN code request is
received, don't trigger the disconnect timeout. The either successful
or failing connection complete event will make sure that the timeout
is triggered at the right time.

The biggest problem with security mode 3 is that many Bluetooth 2.0
device and before use a temporary security mode 3 for dedicated
bonding.

Based on a report by Johan Hedberg &lt;johan.hedberg@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Johan Hedberg &lt;johan.hedberg@nokia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Don't use hci_acl_connect_cancel() for incoming connections</title>
<updated>2009-05-10T01:09:45+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-05-09T19:04:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1b0336bb36f88976f1210a65b62f6a3e9578ee7b'/>
<id>1b0336bb36f88976f1210a65b62f6a3e9578ee7b</id>
<content type='text'>
The connection setup phase takes around 2 seconds or longer and in
that time it is possible that the need for an ACL connection is no
longer present. If that happens then, the connection attempt will
be canceled.

This only applies to outgoing connections, but currently it can also
be triggered by incoming connection. Don't call hci_acl_connect_cancel()
on incoming connection since these have to be either accepted or rejected
in this state. Once they are successfully connected they need to be
fully disconnected anyway.

Also remove the wrong hci_acl_disconn() call for SCO and eSCO links
since at this stage they can't be disconnected either, because the
connection handle is still unknown.

Based on a report by Johan Hedberg &lt;johan.hedberg@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Johan Hedberg &lt;johan.hedberg@nokia.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The connection setup phase takes around 2 seconds or longer and in
that time it is possible that the need for an ACL connection is no
longer present. If that happens then, the connection attempt will
be canceled.

This only applies to outgoing connections, but currently it can also
be triggered by incoming connection. Don't call hci_acl_connect_cancel()
on incoming connection since these have to be either accepted or rejected
in this state. Once they are successfully connected they need to be
fully disconnected anyway.

Also remove the wrong hci_acl_disconn() call for SCO and eSCO links
since at this stage they can't be disconnected either, because the
connection handle is still unknown.

Based on a report by Johan Hedberg &lt;johan.hedberg@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Johan Hedberg &lt;johan.hedberg@nokia.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Fix wrong module refcount when connection setup fails</title>
<updated>2009-05-10T01:09:38+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-05-09T01:20:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=384943ec1bb462e410390ad8f108ff1474cd882d'/>
<id>384943ec1bb462e410390ad8f108ff1474cd882d</id>
<content type='text'>
The module refcount is increased by hci_dev_hold() call in hci_conn_add()
and decreased by hci_dev_put() call in del_conn(). In case the connection
setup fails, hci_dev_put() is never called.

Procedure to reproduce the issue:

  # hciconfig hci0 up
  # lsmod | grep btusb                   -&gt; "used by" refcount = 1

  # hcitool cc &lt;non-exisiting bdaddr&gt;    -&gt; will get timeout

  # lsmod | grep btusb                   -&gt; "used by" refcount = 2
  # hciconfig hci0 down
  # lsmod | grep btusb                   -&gt; "used by" refcount = 1
  # rmmod btusb                          -&gt; ERROR: Module btusb is in use

The hci_dev_put() call got moved into del_conn() with the 2.6.25 kernel
to fix an issue with hci_dev going away before hci_conn. However that
change was wrong and introduced this problem.

When calling hci_conn_del() it has to call hci_dev_put() after freeing
the connection details. This handling should be fully symmetric. The
execution of del_conn() is done in a work queue and needs it own calls
to hci_dev_hold() and hci_dev_put() to ensure that the hci_dev stays
until the connection cleanup has been finished.

Based on a report by Bing Zhao &lt;bzhao@marvell.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Bing Zhao &lt;bzhao@marvell.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The module refcount is increased by hci_dev_hold() call in hci_conn_add()
and decreased by hci_dev_put() call in del_conn(). In case the connection
setup fails, hci_dev_put() is never called.

Procedure to reproduce the issue:

  # hciconfig hci0 up
  # lsmod | grep btusb                   -&gt; "used by" refcount = 1

  # hcitool cc &lt;non-exisiting bdaddr&gt;    -&gt; will get timeout

  # lsmod | grep btusb                   -&gt; "used by" refcount = 2
  # hciconfig hci0 down
  # lsmod | grep btusb                   -&gt; "used by" refcount = 1
  # rmmod btusb                          -&gt; ERROR: Module btusb is in use

The hci_dev_put() call got moved into del_conn() with the 2.6.25 kernel
to fix an issue with hci_dev going away before hci_conn. However that
change was wrong and introduced this problem.

When calling hci_conn_del() it has to call hci_dev_put() after freeing
the connection details. This handling should be fully symmetric. The
execution of del_conn() is done in a work queue and needs it own calls
to hci_dev_hold() and hci_dev_put() to ensure that the hci_dev stays
until the connection cleanup has been finished.

Based on a report by Bing Zhao &lt;bzhao@marvell.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Bing Zhao &lt;bzhao@marvell.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Move dev_set_name() to a context that can sleep</title>
<updated>2009-05-05T20:26:08+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-05-05T20:09:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=457ca7bb6bdf39d0832d3f88c65fa367a3b20de6'/>
<id>457ca7bb6bdf39d0832d3f88c65fa367a3b20de6</id>
<content type='text'>
Setting the name of a sysfs device has to be done in a context that can
actually sleep. It allocates its memory with GFP_KERNEL. Previously it
was a static (size limited) string and that got changed to accommodate
longer device names. So move the dev_set_name() just before calling
device_add() which is executed in a work queue.

This fixes the following error:

[  110.012125] BUG: sleeping function called from invalid context at mm/slub.c:1595
[  110.012135] in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper
[  110.012141] 2 locks held by swapper/0:
[  110.012145]  #0:  (hci_task_lock){++.-.+}, at: [&lt;ffffffffa01f822f&gt;] hci_rx_task+0x2f/0x2d0 [bluetooth]
[  110.012173]  #1:  (&amp;hdev-&gt;lock){+.-.+.}, at: [&lt;ffffffffa01fb9e2&gt;] hci_event_packet+0x72/0x25c0 [bluetooth]
[  110.012198] Pid: 0, comm: swapper Tainted: G        W 2.6.30-rc4-g953cdaa #1
[  110.012203] Call Trace:
[  110.012207]  &lt;IRQ&gt;  [&lt;ffffffff8023eabd&gt;] __might_sleep+0x14d/0x170
[  110.012228]  [&lt;ffffffff802cfbe1&gt;] __kmalloc+0x111/0x170
[  110.012239]  [&lt;ffffffff803c2094&gt;] kvasprintf+0x64/0xb0
[  110.012248]  [&lt;ffffffff803b7a5b&gt;] kobject_set_name_vargs+0x3b/0xa0
[  110.012257]  [&lt;ffffffff80465326&gt;] dev_set_name+0x76/0xa0
[  110.012273]  [&lt;ffffffffa01fb9e2&gt;] ? hci_event_packet+0x72/0x25c0 [bluetooth]
[  110.012289]  [&lt;ffffffffa01ffc1d&gt;] hci_conn_add_sysfs+0x3d/0x70 [bluetooth]
[  110.012303]  [&lt;ffffffffa01fba2c&gt;] hci_event_packet+0xbc/0x25c0 [bluetooth]
[  110.012312]  [&lt;ffffffff80516eb0&gt;] ? sock_def_readable+0x80/0xa0
[  110.012328]  [&lt;ffffffffa01fee0c&gt;] ? hci_send_to_sock+0xfc/0x1c0 [bluetooth]
[  110.012343]  [&lt;ffffffff80516eb0&gt;] ? sock_def_readable+0x80/0xa0
[  110.012347]  [&lt;ffffffff805e88c5&gt;] ? _read_unlock+0x75/0x80
[  110.012354]  [&lt;ffffffffa01fee0c&gt;] ? hci_send_to_sock+0xfc/0x1c0 [bluetooth]
[  110.012360]  [&lt;ffffffffa01f8403&gt;] hci_rx_task+0x203/0x2d0 [bluetooth]
[  110.012365]  [&lt;ffffffff80250ab5&gt;] tasklet_action+0xb5/0x160
[  110.012369]  [&lt;ffffffff8025116c&gt;] __do_softirq+0x9c/0x150
[  110.012372]  [&lt;ffffffff805e850f&gt;] ? _spin_unlock+0x3f/0x80
[  110.012376]  [&lt;ffffffff8020cbbc&gt;] call_softirq+0x1c/0x30
[  110.012380]  [&lt;ffffffff8020f01d&gt;] do_softirq+0x8d/0xe0
[  110.012383]  [&lt;ffffffff80250df5&gt;] irq_exit+0xc5/0xe0
[  110.012386]  [&lt;ffffffff8020e71d&gt;] do_IRQ+0x9d/0x120
[  110.012389]  [&lt;ffffffff8020c3d3&gt;] ret_from_intr+0x0/0xf
[  110.012391]  &lt;EOI&gt;  [&lt;ffffffff80431832&gt;] ? acpi_idle_enter_bm+0x264/0x2a6
[  110.012399]  [&lt;ffffffff80431828&gt;] ? acpi_idle_enter_bm+0x25a/0x2a6
[  110.012403]  [&lt;ffffffff804f50d5&gt;] ? cpuidle_idle_call+0xc5/0x130
[  110.012407]  [&lt;ffffffff8020a4b4&gt;] ? cpu_idle+0xc4/0x130
[  110.012411]  [&lt;ffffffff805d2268&gt;] ? rest_init+0x88/0xb0
[  110.012416]  [&lt;ffffffff807e2fbd&gt;] ? start_kernel+0x3b5/0x412
[  110.012420]  [&lt;ffffffff807e2281&gt;] ? x86_64_start_reservations+0x91/0xb5
[  110.012424]  [&lt;ffffffff807e2394&gt;] ? x86_64_start_kernel+0xef/0x11b

Based on a report by Davide Pesavento &lt;davidepesa@gmail.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Hugo Mildenberger &lt;hugo.mildenberger@namir.de&gt;
Tested-by: Bing Zhao &lt;bzhao@marvell.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Setting the name of a sysfs device has to be done in a context that can
actually sleep. It allocates its memory with GFP_KERNEL. Previously it
was a static (size limited) string and that got changed to accommodate
longer device names. So move the dev_set_name() just before calling
device_add() which is executed in a work queue.

This fixes the following error:

[  110.012125] BUG: sleeping function called from invalid context at mm/slub.c:1595
[  110.012135] in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper
[  110.012141] 2 locks held by swapper/0:
[  110.012145]  #0:  (hci_task_lock){++.-.+}, at: [&lt;ffffffffa01f822f&gt;] hci_rx_task+0x2f/0x2d0 [bluetooth]
[  110.012173]  #1:  (&amp;hdev-&gt;lock){+.-.+.}, at: [&lt;ffffffffa01fb9e2&gt;] hci_event_packet+0x72/0x25c0 [bluetooth]
[  110.012198] Pid: 0, comm: swapper Tainted: G        W 2.6.30-rc4-g953cdaa #1
[  110.012203] Call Trace:
[  110.012207]  &lt;IRQ&gt;  [&lt;ffffffff8023eabd&gt;] __might_sleep+0x14d/0x170
[  110.012228]  [&lt;ffffffff802cfbe1&gt;] __kmalloc+0x111/0x170
[  110.012239]  [&lt;ffffffff803c2094&gt;] kvasprintf+0x64/0xb0
[  110.012248]  [&lt;ffffffff803b7a5b&gt;] kobject_set_name_vargs+0x3b/0xa0
[  110.012257]  [&lt;ffffffff80465326&gt;] dev_set_name+0x76/0xa0
[  110.012273]  [&lt;ffffffffa01fb9e2&gt;] ? hci_event_packet+0x72/0x25c0 [bluetooth]
[  110.012289]  [&lt;ffffffffa01ffc1d&gt;] hci_conn_add_sysfs+0x3d/0x70 [bluetooth]
[  110.012303]  [&lt;ffffffffa01fba2c&gt;] hci_event_packet+0xbc/0x25c0 [bluetooth]
[  110.012312]  [&lt;ffffffff80516eb0&gt;] ? sock_def_readable+0x80/0xa0
[  110.012328]  [&lt;ffffffffa01fee0c&gt;] ? hci_send_to_sock+0xfc/0x1c0 [bluetooth]
[  110.012343]  [&lt;ffffffff80516eb0&gt;] ? sock_def_readable+0x80/0xa0
[  110.012347]  [&lt;ffffffff805e88c5&gt;] ? _read_unlock+0x75/0x80
[  110.012354]  [&lt;ffffffffa01fee0c&gt;] ? hci_send_to_sock+0xfc/0x1c0 [bluetooth]
[  110.012360]  [&lt;ffffffffa01f8403&gt;] hci_rx_task+0x203/0x2d0 [bluetooth]
[  110.012365]  [&lt;ffffffff80250ab5&gt;] tasklet_action+0xb5/0x160
[  110.012369]  [&lt;ffffffff8025116c&gt;] __do_softirq+0x9c/0x150
[  110.012372]  [&lt;ffffffff805e850f&gt;] ? _spin_unlock+0x3f/0x80
[  110.012376]  [&lt;ffffffff8020cbbc&gt;] call_softirq+0x1c/0x30
[  110.012380]  [&lt;ffffffff8020f01d&gt;] do_softirq+0x8d/0xe0
[  110.012383]  [&lt;ffffffff80250df5&gt;] irq_exit+0xc5/0xe0
[  110.012386]  [&lt;ffffffff8020e71d&gt;] do_IRQ+0x9d/0x120
[  110.012389]  [&lt;ffffffff8020c3d3&gt;] ret_from_intr+0x0/0xf
[  110.012391]  &lt;EOI&gt;  [&lt;ffffffff80431832&gt;] ? acpi_idle_enter_bm+0x264/0x2a6
[  110.012399]  [&lt;ffffffff80431828&gt;] ? acpi_idle_enter_bm+0x25a/0x2a6
[  110.012403]  [&lt;ffffffff804f50d5&gt;] ? cpuidle_idle_call+0xc5/0x130
[  110.012407]  [&lt;ffffffff8020a4b4&gt;] ? cpu_idle+0xc4/0x130
[  110.012411]  [&lt;ffffffff805d2268&gt;] ? rest_init+0x88/0xb0
[  110.012416]  [&lt;ffffffff807e2fbd&gt;] ? start_kernel+0x3b5/0x412
[  110.012420]  [&lt;ffffffff807e2281&gt;] ? x86_64_start_reservations+0x91/0xb5
[  110.012424]  [&lt;ffffffff807e2394&gt;] ? x86_64_start_kernel+0xef/0x11b

Based on a report by Davide Pesavento &lt;davidepesa@gmail.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Hugo Mildenberger &lt;hugo.mildenberger@namir.de&gt;
Tested-by: Bing Zhao &lt;bzhao@marvell.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Fix issue with sysfs handling for connections</title>
<updated>2009-05-04T21:29:02+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-05-03T01:24:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a67e899cf38ae542d1a028ccd021f9189f76fb74'/>
<id>a67e899cf38ae542d1a028ccd021f9189f76fb74</id>
<content type='text'>
Due to a semantic changes in flush_workqueue() the current approach of
synchronizing the sysfs handling for connections doesn't work anymore. The
whole approach is actually fully broken and based on assumptions that are
no longer valid.

With the introduction of Simple Pairing support, the creation of low-level
ACL links got changed. This change invalidates the reason why in the past
two independent work queues have been used for adding/removing sysfs
devices. The adding of the actual sysfs device is now postponed until the
host controller successfully assigns an unique handle to that link. So
the real synchronization happens inside the controller and not the host.

The only left-over problem is that some internals of the sysfs device
handling are not initialized ahead of time. This leaves potential access
to invalid data and can cause various NULL pointer dereferences. To fix
this a new function makes sure that all sysfs details are initialized
when an connection attempt is made. The actual sysfs device is only
registered when the connection has been successfully established. To
avoid a race condition with the registration, the check if a device is
registered has been moved into the removal work.

As an extra protection two flush_work() calls are left in place to
make sure a previous add/del work has been completed first.

Based on a report by Marc Pignat &lt;marc.pignat@hevs.ch&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Justin P. Mattock &lt;justinmattock@gmail.com&gt;
Tested-by: Roger Quadros &lt;ext-roger.quadros@nokia.com&gt;
Tested-by: Marc Pignat &lt;marc.pignat@hevs.ch&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Due to a semantic changes in flush_workqueue() the current approach of
synchronizing the sysfs handling for connections doesn't work anymore. The
whole approach is actually fully broken and based on assumptions that are
no longer valid.

With the introduction of Simple Pairing support, the creation of low-level
ACL links got changed. This change invalidates the reason why in the past
two independent work queues have been used for adding/removing sysfs
devices. The adding of the actual sysfs device is now postponed until the
host controller successfully assigns an unique handle to that link. So
the real synchronization happens inside the controller and not the host.

The only left-over problem is that some internals of the sysfs device
handling are not initialized ahead of time. This leaves potential access
to invalid data and can cause various NULL pointer dereferences. To fix
this a new function makes sure that all sysfs details are initialized
when an connection attempt is made. The actual sysfs device is only
registered when the connection has been successfully established. To
avoid a race condition with the registration, the check if a device is
registered has been moved into the removal work.

As an extra protection two flush_work() calls are left in place to
make sure a previous add/del work has been completed first.

Based on a report by Marc Pignat &lt;marc.pignat@hevs.ch&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Tested-by: Justin P. Mattock &lt;justinmattock@gmail.com&gt;
Tested-by: Roger Quadros &lt;ext-roger.quadros@nokia.com&gt;
Tested-by: Marc Pignat &lt;marc.pignat@hevs.ch&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Fix connection establishment with low security requirement</title>
<updated>2009-04-28T16:31:39+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-04-28T16:04:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3fdca1e1370ffe89980927cdef0583bebcd8caaf'/>
<id>3fdca1e1370ffe89980927cdef0583bebcd8caaf</id>
<content type='text'>
The Bluetooth 2.1 specification introduced four different security modes
that can be mapped using Legacy Pairing and Simple Pairing. With the
usage of Simple Pairing it is required that all connections (except
the ones for SDP) are encrypted. So even the low security requirement
mandates an encrypted connection when using Simple Pairing. When using
Legacy Pairing (for Bluetooth 2.0 devices and older) this is not required
since it causes interoperability issues.

To support this properly the low security requirement translates into
different host controller transactions depending if Simple Pairing is
supported or not. However in case of Simple Pairing the command to
switch on encryption after a successful authentication is not triggered
for the low security mode. This patch fixes this and actually makes
the logic to differentiate between Simple Pairing and Legacy Pairing
a lot simpler.

Based on a report by Ville Tervo &lt;ville.tervo@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The Bluetooth 2.1 specification introduced four different security modes
that can be mapped using Legacy Pairing and Simple Pairing. With the
usage of Simple Pairing it is required that all connections (except
the ones for SDP) are encrypted. So even the low security requirement
mandates an encrypted connection when using Simple Pairing. When using
Legacy Pairing (for Bluetooth 2.0 devices and older) this is not required
since it causes interoperability issues.

To support this properly the low security requirement translates into
different host controller transactions depending if Simple Pairing is
supported or not. However in case of Simple Pairing the command to
switch on encryption after a successful authentication is not triggered
for the low security mode. This patch fixes this and actually makes
the logic to differentiate between Simple Pairing and Legacy Pairing
a lot simpler.

Based on a report by Ville Tervo &lt;ville.tervo@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Add different pairing timeout for Legacy Pairing</title>
<updated>2009-04-28T16:31:38+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-04-26T18:01:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=052b30b0a8eec8db5b18ad49effdf2a9ba4c1e1a'/>
<id>052b30b0a8eec8db5b18ad49effdf2a9ba4c1e1a</id>
<content type='text'>
The Bluetooth stack uses a reference counting for all established ACL
links and if no user (L2CAP connection) is present, the link will be
terminated to save power. The problem part is the dedicated pairing
when using Legacy Pairing (Bluetooth 2.0 and before). At that point
no user is present and pairing attempts will be disconnected within
10 seconds or less. In previous kernel version this was not a problem
since the disconnect timeout wasn't triggered on incoming connections
for the first time. However this caused issues with broken host stacks
that kept the connections around after dedicated pairing. When the
support for Simple Pairing got added, the link establishment procedure
needed to be changed and now causes issues when using Legacy Pairing

When using Simple Pairing it is possible to do a proper reference
counting of ACL link users. With Legacy Pairing this is not possible
since the specification is unclear in some areas and too many broken
Bluetooth devices have already been deployed. So instead of trying to
deal with all the broken devices, a special pairing timeout will be
introduced that increases the timeout to 60 seconds when pairing is
triggered.

If a broken devices now puts the stack into an unforeseen state, the
worst that happens is the disconnect timeout triggers after 120 seconds
instead of 4 seconds. This allows successful pairings with legacy and
broken devices now.

Based on a report by Johan Hedberg &lt;johan.hedberg@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The Bluetooth stack uses a reference counting for all established ACL
links and if no user (L2CAP connection) is present, the link will be
terminated to save power. The problem part is the dedicated pairing
when using Legacy Pairing (Bluetooth 2.0 and before). At that point
no user is present and pairing attempts will be disconnected within
10 seconds or less. In previous kernel version this was not a problem
since the disconnect timeout wasn't triggered on incoming connections
for the first time. However this caused issues with broken host stacks
that kept the connections around after dedicated pairing. When the
support for Simple Pairing got added, the link establishment procedure
needed to be changed and now causes issues when using Legacy Pairing

When using Simple Pairing it is possible to do a proper reference
counting of ACL link users. With Legacy Pairing this is not possible
since the specification is unclear in some areas and too many broken
Bluetooth devices have already been deployed. So instead of trying to
deal with all the broken devices, a special pairing timeout will be
introduced that increases the timeout to 60 seconds when pairing is
triggered.

If a broken devices now puts the stack into an unforeseen state, the
worst that happens is the disconnect timeout triggers after 120 seconds
instead of 4 seconds. This allows successful pairings with legacy and
broken devices now.

Based on a report by Johan Hedberg &lt;johan.hedberg@nokia.com&gt;

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Ensure that HCI sysfs add/del is preempt safe</title>
<updated>2009-04-28T16:31:38+00:00</updated>
<author>
<name>Roger Quadros</name>
<email>ext-roger.quadros@nokia.com</email>
</author>
<published>2009-04-23T11:50:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f3784d834c71689336fa272df420b45345cb6b84'/>
<id>f3784d834c71689336fa272df420b45345cb6b84</id>
<content type='text'>
Use a different work_struct variables for add_conn() and del_conn() and
use single work queue instead of two for adding and deleting connections.

It eliminates the following error on a preemptible kernel:

[  204.358032] Unable to handle kernel NULL pointer dereference at virtual address 0000000c
[  204.370697] pgd = c0004000
[  204.373443] [0000000c] *pgd=00000000
[  204.378601] Internal error: Oops: 17 [#1] PREEMPT
[  204.383361] Modules linked in: vfat fat rfcomm sco l2cap sd_mod scsi_mod iphb pvr2d drm omaplfb ps
[  204.438537] CPU: 0    Not tainted  (2.6.28-maemo2 #1)
[  204.443664] PC is at klist_put+0x2c/0xb4
[  204.447601] LR is at klist_put+0x18/0xb4
[  204.451568] pc : [&lt;c0270f08&gt;]    lr : [&lt;c0270ef4&gt;]    psr: a0000113
[  204.451568] sp : cf1b3f10  ip : cf1b3f10  fp : cf1b3f2c
[  204.463104] r10: 00000000  r9 : 00000000  r8 : bf08029c
[  204.468353] r7 : c7869200  r6 : cfbe2690  r5 : c78692c8  r4 : 00000001
[  204.474945] r3 : 00000001  r2 : cf1b2000  r1 : 00000001  r0 : 00000000
[  204.481506] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM Segment kernel
[  204.488861] Control: 10c5387d  Table: 887fc018  DAC: 00000017
[  204.494628] Process btdelconn (pid: 515, stack limit = 0xcf1b22e0)

Signed-off-by: Roger Quadros &lt;ext-roger.quadros@nokia.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use a different work_struct variables for add_conn() and del_conn() and
use single work queue instead of two for adding and deleting connections.

It eliminates the following error on a preemptible kernel:

[  204.358032] Unable to handle kernel NULL pointer dereference at virtual address 0000000c
[  204.370697] pgd = c0004000
[  204.373443] [0000000c] *pgd=00000000
[  204.378601] Internal error: Oops: 17 [#1] PREEMPT
[  204.383361] Modules linked in: vfat fat rfcomm sco l2cap sd_mod scsi_mod iphb pvr2d drm omaplfb ps
[  204.438537] CPU: 0    Not tainted  (2.6.28-maemo2 #1)
[  204.443664] PC is at klist_put+0x2c/0xb4
[  204.447601] LR is at klist_put+0x18/0xb4
[  204.451568] pc : [&lt;c0270f08&gt;]    lr : [&lt;c0270ef4&gt;]    psr: a0000113
[  204.451568] sp : cf1b3f10  ip : cf1b3f10  fp : cf1b3f2c
[  204.463104] r10: 00000000  r9 : 00000000  r8 : bf08029c
[  204.468353] r7 : c7869200  r6 : cfbe2690  r5 : c78692c8  r4 : 00000001
[  204.474945] r3 : 00000001  r2 : cf1b2000  r1 : 00000001  r0 : 00000000
[  204.481506] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM Segment kernel
[  204.488861] Control: 10c5387d  Table: 887fc018  DAC: 00000017
[  204.494628] Process btdelconn (pid: 515, stack limit = 0xcf1b22e0)

Signed-off-by: Roger Quadros &lt;ext-roger.quadros@nokia.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Add workaround for wrong HCI event in eSCO setup</title>
<updated>2009-04-19T17:30:03+00:00</updated>
<author>
<name>Marcel Holtmann</name>
<email>marcel@holtmann.org</email>
</author>
<published>2009-04-19T17:30:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9499237a1c42a27fbcc7ed1d59e34df2b574cdfb'/>
<id>9499237a1c42a27fbcc7ed1d59e34df2b574cdfb</id>
<content type='text'>
The Broadcom chips with 2.1 firmware handle the fallback case to a SCO
link wrongly when setting up eSCO connections.

  &lt; HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
      handle 11 voice setting 0x0060
  &gt; HCI Event: Command Status (0x0f) plen 4
      Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
  &gt; HCI Event: Connect Complete (0x03) plen 11
      status 0x00 handle 1 bdaddr 00:1E:3A:xx:xx:xx type SCO encrypt 0x01

The Link Manager negotiates the fallback to SCO, but then sends out
a Connect Complete event. This is wrong and the Link Manager should
actually send a Synchronous Connection Complete event if the Setup
Synchronous Connection has been used. Only the remote side is allowed
to use Connect Complete to indicate the missing support for eSCO in
the host stack.

This patch adds a workaround for this which clearly should not be
needed, but reality is that broken Broadcom devices are deployed.

Based on a report by Ville Tervo &lt;ville.tervo@nokia.com&gt;

Signed-off-by: Marcel Holtman &lt;marcel@holtmann.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The Broadcom chips with 2.1 firmware handle the fallback case to a SCO
link wrongly when setting up eSCO connections.

  &lt; HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
      handle 11 voice setting 0x0060
  &gt; HCI Event: Command Status (0x0f) plen 4
      Setup Synchronous Connection (0x01|0x0028) status 0x00 ncmd 1
  &gt; HCI Event: Connect Complete (0x03) plen 11
      status 0x00 handle 1 bdaddr 00:1E:3A:xx:xx:xx type SCO encrypt 0x01

The Link Manager negotiates the fallback to SCO, but then sends out
a Connect Complete event. This is wrong and the Link Manager should
actually send a Synchronous Connection Complete event if the Setup
Synchronous Connection has been used. Only the remote side is allowed
to use Connect Complete to indicate the missing support for eSCO in
the host stack.

This patch adds a workaround for this which clearly should not be
needed, but reality is that broken Broadcom devices are deployed.

Based on a report by Ville Tervo &lt;ville.tervo@nokia.com&gt;

Signed-off-by: Marcel Holtman &lt;marcel@holtmann.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
