* [bluetooth-next V2] Bluetooth: handle device reset event
@ 2010-02-22 13:05 Tomas Winkler
2010-02-22 13:05 ` [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul Tomas Winkler
2010-03-09 1:03 ` [bluetooth-next V2] Bluetooth: handle device reset event Marcel Holtmann
0 siblings, 2 replies; 10+ messages in thread
From: Tomas Winkler @ 2010-02-22 13:05 UTC (permalink / raw)
To: marcel, linux-bluetooth; +Cc: guy.cohen, ron.rindjunsky, Gregory Paskar
From: Gregory Paskar <gregory.paskar@intel.com>
A Bluetooth device experiencing hardware failure may issue
a HARDWARE_ERROR hci event. The reaction to this event is device
reset flow implemented in following sequence.
1. Notify: HCI_DEV_DOWN
2. Reinitialize internal structures.
3. Call driver flush function
4. Send HCI reset request to the device.
5. Send HCI init sequence reset to the device.
6. Notify HCI_DEV_UP.
Signed-off-by: Gregory Paskar <gregory.paskar@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Reviewed-by: Ron Rindjunsky <ron.rindjunsky@intel.com>
---
V2:
1. Fix email typo
2. Fix style issues
include/net/bluetooth/hci.h | 5 ++++
include/net/bluetooth/hci_core.h | 2 +
net/bluetooth/hci_core.c | 47 +++++++++++++++++++++++++++++++++++++-
net/bluetooth/hci_event.c | 3 ++
4 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ed3aea1..cd23eb4 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -691,6 +691,11 @@ struct hci_ev_cmd_status {
__le16 opcode;
} __attribute__ ((packed));
+#define HCI_EV_HARDWARE_ERROR 0x10
+struct hci_ev_hw_error {
+ __u8 hw_code;
+} __attribute__ ((packed));
+
#define HCI_EV_ROLE_CHANGE 0x12
struct hci_ev_role_change {
__u8 status;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7b86094..d2b1cba 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -110,6 +110,8 @@ struct hci_dev {
struct tasklet_struct rx_task;
struct tasklet_struct tx_task;
+ struct work_struct hw_err_work;
+
struct sk_buff_head rx_q;
struct sk_buff_head raw_q;
struct sk_buff_head cmd_q;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 94ba349..b7c0fbf 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -834,6 +834,51 @@ static int hci_rfkill_set_block(void *data, bool blocked)
return 0;
}
+static void hci_device_hw_error(struct hci_dev *hdev)
+{
+ hci_req_lock(hdev);
+
+ /* notify: going down */
+ clear_bit(HCI_UP, &hdev->flags);
+ hci_notify(hdev, HCI_DEV_DOWN);
+
+ tasklet_disable(&hdev->tx_task);
+ skb_queue_purge(&hdev->rx_q);
+ skb_queue_purge(&hdev->cmd_q);
+
+ hci_dev_lock_bh(hdev);
+ inquiry_cache_flush(hdev);
+ hci_conn_hash_flush(hdev);
+ hci_dev_unlock_bh(hdev);
+
+ if (hdev->flush)
+ hdev->flush(hdev);
+
+ /* reset device */
+ atomic_set(&hdev->cmd_cnt, 1);
+ hdev->acl_cnt = 0;
+ hdev->sco_cnt = 0;
+ hci_reset_req(hdev, 0);
+
+ /* init device */
+ atomic_set(&hdev->cmd_cnt, 1);
+ hci_init_req(hdev, 0);
+
+ tasklet_enable(&hdev->tx_task);
+
+ /* notify: going back up */
+ set_bit(HCI_UP, &hdev->flags);
+ hci_notify(hdev, HCI_DEV_UP);
+
+ hci_req_unlock(hdev);
+}
+
+static void hci_hw_err_work(struct work_struct *ws)
+{
+ struct hci_dev *hdev = container_of(ws, struct hci_dev, hw_err_work);
+ hci_device_hw_error(hdev);
+}
+
static const struct rfkill_ops hci_rfkill_ops = {
.set_block = hci_rfkill_set_block,
};
@@ -903,7 +948,7 @@ int hci_register_dev(struct hci_dev *hdev)
tasklet_init(&hdev->cmd_task, hci_cmd_task,(unsigned long) hdev);
tasklet_init(&hdev->rx_task, hci_rx_task, (unsigned long) hdev);
tasklet_init(&hdev->tx_task, hci_tx_task, (unsigned long) hdev);
-
+ INIT_WORK(&hdev->hw_err_work, hci_hw_err_work);
skb_queue_head_init(&hdev->rx_q);
skb_queue_head_init(&hdev->cmd_q);
skb_queue_head_init(&hdev->raw_q);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 28517ba..e8f48cc 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1953,6 +1953,9 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
case HCI_EV_REMOTE_HOST_FEATURES:
hci_remote_host_features_evt(hdev, skb);
break;
+ case HCI_EV_HARDWARE_ERROR:
+ schedule_work(&hdev->hw_err_work);
+ break;
default:
BT_DBG("%s event 0x%x", hdev->name, event);
--
1.6.0.6
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
2010-02-22 13:05 [bluetooth-next V2] Bluetooth: handle device reset event Tomas Winkler
@ 2010-02-22 13:05 ` Tomas Winkler
2010-03-09 1:03 ` Marcel Holtmann
2010-03-09 1:03 ` [bluetooth-next V2] Bluetooth: handle device reset event Marcel Holtmann
1 sibling, 1 reply; 10+ messages in thread
From: Tomas Winkler @ 2010-02-22 13:05 UTC (permalink / raw)
To: marcel, linux-bluetooth; +Cc: guy.cohen, ron.rindjunsky, Tomas Winkler
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
net/bluetooth/hci_sysfs.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 2bc6f6a..e4bfce5 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -286,11 +286,11 @@ static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *at
static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct hci_dev *hdev = dev_get_drvdata(dev);
- char *ptr;
- __u32 val;
+ unsigned long val;
+ int ret;
- val = simple_strtoul(buf, &ptr, 10);
- if (ptr == buf)
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret)
return -EINVAL;
if (val != 0 && (val < 500 || val > 3600000))
@@ -310,11 +310,11 @@ static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribu
static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct hci_dev *hdev = dev_get_drvdata(dev);
- char *ptr;
- __u16 val;
+ unsigned long val;
+ int ret;
- val = simple_strtoul(buf, &ptr, 10);
- if (ptr == buf)
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret)
return -EINVAL;
if (val < 0x0002 || val > 0xFFFE || val % 2)
@@ -337,11 +337,11 @@ static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribu
static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct hci_dev *hdev = dev_get_drvdata(dev);
- char *ptr;
- __u16 val;
+ unsigned long val;
+ int ret;
- val = simple_strtoul(buf, &ptr, 10);
- if (ptr == buf)
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret)
return -EINVAL;
if (val < 0x0002 || val > 0xFFFE || val % 2)
--
1.6.0.6
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [bluetooth-next V2] Bluetooth: handle device reset event
2010-02-22 13:05 [bluetooth-next V2] Bluetooth: handle device reset event Tomas Winkler
2010-02-22 13:05 ` [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul Tomas Winkler
@ 2010-03-09 1:03 ` Marcel Holtmann
2010-03-09 21:22 ` Winkler, Tomas
1 sibling, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2010-03-09 1:03 UTC (permalink / raw)
To: Tomas Winkler; +Cc: linux-bluetooth, guy.cohen, ron.rindjunsky, Gregory Paskar
Hi Tomas,
> A Bluetooth device experiencing hardware failure may issue
> a HARDWARE_ERROR hci event. The reaction to this event is device
> reset flow implemented in following sequence.
>
> 1. Notify: HCI_DEV_DOWN
> 2. Reinitialize internal structures.
> 3. Call driver flush function
> 4. Send HCI reset request to the device.
> 5. Send HCI init sequence reset to the device.
> 6. Notify HCI_DEV_UP.
I prefer if we create a generic per controller workqueue first before
having a workqueue for every task. Something similar to what the
mac80211 layer offers right now.
Also in a second step we might wanna move the HCI event processing
completely into a workqueue. If we get no performance hit with that,
then sysfs handling and device reset becomes a lot simpler and less
prone to race conditions with device removal.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
2010-02-22 13:05 ` [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul Tomas Winkler
@ 2010-03-09 1:03 ` Marcel Holtmann
2010-03-09 1:14 ` Winkler, Tomas
0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2010-03-09 1:03 UTC (permalink / raw)
To: Tomas Winkler; +Cc: linux-bluetooth, guy.cohen, ron.rindjunsky
Hi Tomas,
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
> net/bluetooth/hci_sysfs.c | 24 ++++++++++++------------
> 1 files changed, 12 insertions(+), 12 deletions(-)
can you please explain the rational behind this change. What is the
benefit? I just fail to see it right away.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
2010-03-09 1:03 ` Marcel Holtmann
@ 2010-03-09 1:14 ` Winkler, Tomas
2010-03-09 2:16 ` Marcel Holtmann
0 siblings, 1 reply; 10+ messages in thread
From: Winkler, Tomas @ 2010-03-09 1:14 UTC (permalink / raw)
To: Marcel Holtmann
Cc: linux-bluetooth@vger.kernel.org, Cohen, Guy, Rindjunsky, Ron
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogTWFyY2VsIEhvbHRtYW5u
IFttYWlsdG86bWFyY2VsQGhvbHRtYW5uLm9yZ10NCj4gU2VudDogVHVlc2RheSwgTWFyY2ggMDks
IDIwMTAgMzowNCBBTQ0KPiBUbzogV2lua2xlciwgVG9tYXMNCj4gQ2M6IGxpbnV4LWJsdWV0b290
aEB2Z2VyLmtlcm5lbC5vcmc7IENvaGVuLCBHdXk7IFJpbmRqdW5za3ksIFJvbg0KPiBTdWJqZWN0
OiBSZTogW2JsdWV0b290aC1uZXh0XSBibHVldG9vdGg6IGhjaV9zeXNmczogdXNlIHN0cmljdF9z
dHJ0b3VsDQo+IGluc3RlYWQgb2Ygc2ltcGxlX3N0cnRvdWwNCj4gDQo+IEhpIFRvbWFzLA0KPiAN
Cj4gPiBTaWduZWQtb2ZmLWJ5OiBUb21hcyBXaW5rbGVyIDx0b21hcy53aW5rbGVyQGludGVsLmNv
bT4NCj4gPiAtLS0NCj4gPiAgbmV0L2JsdWV0b290aC9oY2lfc3lzZnMuYyB8ICAgMjQgKysrKysr
KysrKysrLS0tLS0tLS0tLS0tDQo+ID4gIDEgZmlsZXMgY2hhbmdlZCwgMTIgaW5zZXJ0aW9ucygr
KSwgMTIgZGVsZXRpb25zKC0pDQo+IA0KPiBjYW4geW91IHBsZWFzZSBleHBsYWluIHRoZSByYXRp
b25hbCBiZWhpbmQgdGhpcyBjaGFuZ2UuIFdoYXQgaXMgdGhlDQo+IGJlbmVmaXQ/IEkganVzdCBm
YWlsIHRvIHNlZSBpdCByaWdodCBhd2F5Lg0KDQpUaGUgcmVhbCByZWFzb24gdXNpbmcgc3RyaWN0
IGluc3RlYWQgb2Ygc2ltcGxlIHN0cnRvdWwgaXMgZXhwbGFpbmVkIGhlcmUgdGh0dHA6Ly93d3cu
a2VybmVsLm9yZy9kb2MvaHRtbGRvY3Mva2VybmVsLWFwaS9yZTQyLmh0bWwNCkluIHRoZSBib3R0
b20gbGluZSBpdCBqdXN0IHNvbWV0aGluZyBhIGNoYWNrcGF0Y2ggaXMgY29tcGxhaW4gYWJvdXQu
IEkndmUgdG91Y2hlZCB0aGUgZmlsZSB0byBpbnNlcnQgc29tZSB0ZXN0IGhvb2sgZm9yIHRoZSBI
Q0kgcmVzZXQgc28gSSBmaXhlZCB0aGF0IG9uIHRoZSB3YXkuIA0KDQpUaGFua3MNClRvbWFzDQoN
Ci0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLQpJbnRlbCBJc3JhZWwgKDc0KSBMaW1pdGVkCgpUaGlzIGUtbWFpbCBhbmQg
YW55IGF0dGFjaG1lbnRzIG1heSBjb250YWluIGNvbmZpZGVudGlhbCBtYXRlcmlhbCBmb3IKdGhl
IHNvbGUgdXNlIG9mIHRoZSBpbnRlbmRlZCByZWNpcGllbnQocykuIEFueSByZXZpZXcgb3IgZGlz
dHJpYnV0aW9uCmJ5IG90aGVycyBpcyBzdHJpY3RseSBwcm9oaWJpdGVkLiBJZiB5b3UgYXJlIG5v
dCB0aGUgaW50ZW5kZWQKcmVjaXBpZW50LCBwbGVhc2UgY29udGFjdCB0aGUgc2VuZGVyIGFuZCBk
ZWxldGUgYWxsIGNvcGllcy4K
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul
2010-03-09 1:14 ` Winkler, Tomas
@ 2010-03-09 2:16 ` Marcel Holtmann
0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2010-03-09 2:16 UTC (permalink / raw)
To: Winkler, Tomas
Cc: linux-bluetooth@vger.kernel.org, Cohen, Guy, Rindjunsky, Ron
Hi Tomas,
> > > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> > > ---
> > > net/bluetooth/hci_sysfs.c | 24 ++++++++++++------------
> > > 1 files changed, 12 insertions(+), 12 deletions(-)
> >
> > can you please explain the rational behind this change. What is the
> > benefit? I just fail to see it right away.
>
> The real reason using strict instead of simple strtoul is explained here thttp://www.kernel.org/doc/htmldocs/kernel-api/re42.html
> In the bottom line it just something a chackpatch is complain about. I've touched the file to insert some test hook for the HCI reset so I fixed that on the way.
I am fine with that. However please use the following constructs:
if (strict_strtoul(...) < 0)
return -EINVAL;
There is no point in having ret variable if you don't use it.
Also I like to have a commit body and not only a subject line. It
doesn't have to be a novel, but only the subject is not good enough for
me.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [bluetooth-next V2] Bluetooth: handle device reset event
2010-03-09 1:03 ` [bluetooth-next V2] Bluetooth: handle device reset event Marcel Holtmann
@ 2010-03-09 21:22 ` Winkler, Tomas
2010-03-10 16:49 ` Marcel Holtmann
0 siblings, 1 reply; 10+ messages in thread
From: Winkler, Tomas @ 2010-03-09 21:22 UTC (permalink / raw)
To: Marcel Holtmann
Cc: linux-bluetooth@vger.kernel.org, Cohen, Guy, Rindjunsky, Ron,
Paskar, Gregory
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogTWFyY2VsIEhvbHRtYW5u
IFttYWlsdG86bWFyY2VsQGhvbHRtYW5uLm9yZ10NCj4gU2VudDogVHVlc2RheSwgTWFyY2ggMDks
IDIwMTAgMzowMyBBTQ0KPiBUbzogV2lua2xlciwgVG9tYXMNCj4gQ2M6IGxpbnV4LWJsdWV0b290
aEB2Z2VyLmtlcm5lbC5vcmc7IENvaGVuLCB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ljdGx5IHBy
b2hpYml0ZWQuIElmIHlvdSBhcmUgbm90IHRoZSBpbnRlbmRlZApyZWNpcGllbnQsIHBsZWFzZSBj
b250YWN0IHRoZSBzZW5kZXIgYW5kIGRlbGV0ZSBhbGwgY29waWVzLgo=
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [bluetooth-next V2] Bluetooth: handle device reset event
2010-03-09 21:22 ` Winkler, Tomas
@ 2010-03-10 16:49 ` Marcel Holtmann
2010-03-10 19:35 ` Winkler, Tomas
0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2010-03-10 16:49 UTC (permalink / raw)
To: Winkler, Tomas
Cc: linux-bluetooth@vger.kernel.org, Cohen, Guy, Rindjunsky, Ron,
Paskar, Gregory
Hi Tomas,
> > > A Bluetooth device experiencing hardware failure may issue
> > > a HARDWARE_ERROR hci event. The reaction to this event is device
> > > reset flow implemented in following sequence.
> > >
> > > 1. Notify: HCI_DEV_DOWN
> > > 2. Reinitialize internal structures.
> > > 3. Call driver flush function
> > > 4. Send HCI reset request to the device.
> > > 5. Send HCI init sequence reset to the device.
> > > 6. Notify HCI_DEV_UP.
> >
> > I prefer if we create a generic per controller workqueue first before
> > having a workqueue for every task. Something similar to what the
> > mac80211 layer offers right now.
>
> That would be good approach but we are using default kernel workqueue in this solution so there is no workqueue for every task.
> I'm not sure if this effort should block this patch.
I have an initial patch that I have to dig out. It is actually not that
complicated. And I would prefer to get that one first before we apply
this patch.
The reason why I really wanna solve this is because of potential race
conditions between the workqueue and a device removal. I have a bad
feeling that even with the current sysfs workqueue we have a race
condition hiding somewhere. So if going forward we have to shift more
and more code into workqueues we need a single point where this can be
fixed.
> > Also in a second step we might wanna move the HCI event processing
> > completely into a workqueue. If we get no performance hit with that,
> > then sysfs handling and device reset becomes a lot simpler and less
> > prone to race conditions with device removal.
>
> Looks good to me. So when this is ready we can move also the reset also to per controller queue.
I haven't done any performance testing with this approach. So I hope we
are not shooting ourselves in the foot with it.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [bluetooth-next V2] Bluetooth: handle device reset event
2010-03-10 16:49 ` Marcel Holtmann
@ 2010-03-10 19:35 ` Winkler, Tomas
2010-03-15 19:57 ` Marcel Holtmann
0 siblings, 1 reply; 10+ messages in thread
From: Winkler, Tomas @ 2010-03-10 19:35 UTC (permalink / raw)
To: Marcel Holtmann
Cc: linux-bluetooth@vger.kernel.org, Cohen, Guy, Rindjunsky, Ron,
Paskar, Gregory
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogTWFyY2VsIEhvbHRtYW5u
IFttYWlsdG86bWFyY2VsQGhvbHRtYW5uLm9yZ10NCj4gU2VudDogV2VkbmVzZGF5LCBNYXJjaCAx
MCwgMjAxMCA2OjQ5IFBNDQo+IFRvOiBXaW5rbGVyLCBUb21hcw0KPiBDYzogbGludXgtYmx1ZXRv
b3RoQHZnZXIua2VybmVsLm9yZzsgQ29oZW4sIEd1eTsgUmluZGp1bnNreSwgUm9uOyBQYXNrYXIs
DQo+IEdyZWdvcnkNCj4gU3ViamVjdDogUkU6IFtibHVldG9vdGgtbmV4dCBWMl0gQmx1ZXRvb3Ro
OiBoYW5kbGUgZGV2aWNlIHJlc2V0IGV2ZW50DQo+IA0KPiBIaSBUb21hcywNCj4gDQo+ID4gPiA+
IEEgQmx1ZXRvb3RoIGRldmljZSBleHBlcmllbmNpbmcgaGFyZHdhcmUgZmFpbHVyZSBtYXkgaXNz
dWUNCj4gPiA+ID4gYSBIQVJEV0FSRV9FUlJPUiBoY2kgZXZlbnQuIFRoZSByZWFjdGlvbiB0byB0
aGlzIGV2ZW50IGlzIGRldmljZQ0KPiA+ID4gPiByZXNldCBmbG93IGltcGxlbWVudGVkIGluIGZv
bGxvd2luZyBzZXF1ZW5jZS4NCj4gPiA+ID4NCj4gPiA+ID4gMS4gTm90aWZ5OiBIQ0lfREVWX0RP
V04NCj4gPiA+ID4gMi4gUmVpbml0aWFsa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GxlciBhbmQgbGVzcw0KPiA+ID4g
cHJvbmUgdG8gcmFjZSBjb25kaXRpb25zIHdpdGggZGV2aWNlIHJlbW92YWwuDQo+ID4NCj4gPiBM
b29rcyBnb29kIHRvIG1lLiBTbyB3aGVuIHRoaXMgaXMgcmVhZHkgd2UgY2FuIG1vdmUgYWxzbyB0
aGUgcmVzZXQgYWxzbyB0bw0KPiBwZXIgY29udHJvbGxlciBxdWV1ZS4NCj4gDQo+IEkgaGF2ZW4n
dCBkb25lIGFueSBwZXJmb3JtYW5jZSB0ZXN0aW5nIHdpdGggdGhpcyBhcHByb2FjaC4gU28gSSBo
b3BlIHdlDQo+IGFyZSBub3Qgc2hvb3Rpbmcgb3Vyc2VsdmVzIGluIHRoZSBmb290IHdpdGggaXQu
DQoNClRoYW5rcw0KVG9tYXMNCi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQpJbnRlbCBJc3JhZWwgKDc0KSBMaW1pdGVk
CgpUaGlzIGUtbWFpbCBhbmQgYW55IGF0dGFjaG1lbnRzIG1heSBjb250YWluIGNvbmZpZGVudGlh
bCBtYXRlcmlhbCBmb3IKdGhlIHNvbGUgdXNlIG9mIHRoZSBpbnRlbmRlZCByZWNpcGllbnQocyku
IEFueSByZXZpZXcgb3IgZGlzdHJpYnV0aW9uCmJ5IG90aGVycyBpcyBzdHJpY3RseSBwcm9oaWJp
dGVkLiBJZiB5b3UgYXJlIG5vdCB0aGUgaW50ZW5kZWQKcmVjaXBpZW50LCBwbGVhc2UgY29udGFj
dCB0aGUgc2VuZGVyIGFuZCBkZWxldGUgYWxsIGNvcGllcy4K
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [bluetooth-next V2] Bluetooth: handle device reset event
2010-03-10 19:35 ` Winkler, Tomas
@ 2010-03-15 19:57 ` Marcel Holtmann
0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2010-03-15 19:57 UTC (permalink / raw)
To: Winkler, Tomas
Cc: linux-bluetooth@vger.kernel.org, Cohen, Guy, Rindjunsky, Ron,
Paskar, Gregory
Hi Tomas,
> > > > > A Bluetooth device experiencing hardware failure may issue
> > > > > a HARDWARE_ERROR hci event. The reaction to this event is device
> > > > > reset flow implemented in following sequence.
> > > > >
> > > > > 1. Notify: HCI_DEV_DOWN
> > > > > 2. Reinitialize internal structures.
> > > > > 3. Call driver flush function
> > > > > 4. Send HCI reset request to the device.
> > > > > 5. Send HCI init sequence reset to the device.
> > > > > 6. Notify HCI_DEV_UP.
> > > >
> > > > I prefer if we create a generic per controller workqueue first before
> > > > having a workqueue for every task. Something similar to what the
> > > > mac80211 layer offers right now.
> > >
> > > That would be good approach but we are using default kernel workqueue in
> > this solution so there is no workqueue for every task.
> > > I'm not sure if this effort should block this patch.
> >
> > I have an initial patch that I have to dig out. It is actually not that
> > complicated. And I would prefer to get that one first before we apply
> > this patch.
>
> Okay, I can test this particular flow with your patch if you send it to me.
I pushed the per controller workqueue patch into bluetooth-testing.git
tree. Please adapt your patch to that and test it.
> > The reason why I really wanna solve this is because of potential race
> > conditions between the workqueue and a device removal. I have a bad
> > feeling that even with the current sysfs workqueue we have a race
> > condition hiding somewhere. So if going forward we have to shift more
> > and more code into workqueues we need a single point where this can be
> > fixed.
>
> Understood.
>
> In that context I would need to do some more instrumentation to test this kind of race for this feature.
I could be very well that we are protected against such a race. However
with moving from tasklet into workqueue I am always cautious. And I
wanna make sure that we keep the complexity simple. I want one place to
fix if it breaks and not twenty.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-03-15 19:57 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-22 13:05 [bluetooth-next V2] Bluetooth: handle device reset event Tomas Winkler
2010-02-22 13:05 ` [bluetooth-next] bluetooth: hci_sysfs: use strict_strtoul instead of simple_strtoul Tomas Winkler
2010-03-09 1:03 ` Marcel Holtmann
2010-03-09 1:14 ` Winkler, Tomas
2010-03-09 2:16 ` Marcel Holtmann
2010-03-09 1:03 ` [bluetooth-next V2] Bluetooth: handle device reset event Marcel Holtmann
2010-03-09 21:22 ` Winkler, Tomas
2010-03-10 16:49 ` Marcel Holtmann
2010-03-10 19:35 ` Winkler, Tomas
2010-03-15 19:57 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).