All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset
@ 2015-01-28 13:13 Johan Hedberg
  2015-01-28 13:13 ` [PATCH 2/3] Bluetooth: Fix notifying discovery state when powering off Johan Hedberg
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Johan Hedberg @ 2015-01-28 13:13 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

When HCI_Reset is issued the discovery state is assumed to be stopped.
The hci_cc_reset() handler was trying to set the state but it was doing
it without using the hci_discovery_set_state() function. Because of this
e.g. the mgmt Discovering event could go without being sent. This patch
fixes the code to use the hci_discovery_set_state() function instead of
just blindly setting the state value.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/hci_event.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 00c160634e7b..4175470ff48e 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -200,7 +200,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
 	/* Reset all non-persistent flags */
 	hdev->dev_flags &= ~HCI_PERSISTENT_MASK;
 
-	hdev->discovery.state = DISCOVERY_STOPPED;
+	hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
+
 	hdev->inq_tx_power = HCI_TX_POWER_INVALID;
 	hdev->adv_tx_power = HCI_TX_POWER_INVALID;
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] Bluetooth: Fix notifying discovery state when powering off
  2015-01-28 13:13 [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset Johan Hedberg
@ 2015-01-28 13:13 ` Johan Hedberg
  2015-01-28 22:04   ` Marcel Holtmann
  2015-01-28 13:13 ` [PATCH 3/3] Bluetooth: Perform a power cycle when receiving a HW Error Johan Hedberg
  2015-01-28 21:55 ` [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset Marcel Holtmann
  2 siblings, 1 reply; 5+ messages in thread
From: Johan Hedberg @ 2015-01-28 13:13 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

The discovery state should be set to stopped when the HCI device is
powered off. This patch adds the appropriate call to the
hci_discovery_set_state() function from hci_dev_do_close() which is
responsible for the power-off procedure.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/hci_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index bb831d678868..46aa702c189d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1628,6 +1628,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 
 	hci_dev_lock(hdev);
 
+	hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
+
 	if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
 		if (hdev->dev_type == HCI_BREDR)
 			mgmt_powered(hdev, 0);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] Bluetooth: Perform a power cycle when receiving a HW Error
  2015-01-28 13:13 [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset Johan Hedberg
  2015-01-28 13:13 ` [PATCH 2/3] Bluetooth: Fix notifying discovery state when powering off Johan Hedberg
@ 2015-01-28 13:13 ` Johan Hedberg
  2015-01-28 21:55 ` [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset Marcel Holtmann
  2 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2015-01-28 13:13 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

When we receive a Hardware Error HCI event the controller should be
assumed to be non-functional until a full reset procedure has been
performed with it. This patch adds a new hci_reset() helper function
that can be triggered through a workqueue, and schedules the function to
be called whenever a Hardware Error event occurs.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_core.c         | 15 +++++++++++++++
 net/bluetooth/hci_event.c        |  2 ++
 3 files changed, 18 insertions(+)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 0f5e59f1e3cb..3e3380c1e2d9 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -293,6 +293,7 @@ struct hci_dev {
 
 	struct work_struct	power_on;
 	struct delayed_work	power_off;
+	struct work_struct	reset;
 
 	__u16			discov_timeout;
 	struct delayed_work	discov_off;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 46aa702c189d..a6afce413842 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2140,6 +2140,20 @@ static void hci_power_off(struct work_struct *work)
 	smp_unregister(hdev);
 }
 
+static void hci_reset(struct work_struct *work)
+{
+	struct hci_dev *hdev = container_of(work, struct hci_dev, reset);
+
+	BT_DBG("%s", hdev->name);
+
+	if (hci_dev_do_close(hdev))
+		return;
+
+	smp_unregister(hdev);
+
+	hci_dev_do_open(hdev);
+}
+
 static void hci_discov_off(struct work_struct *work)
 {
 	struct hci_dev *hdev;
@@ -2932,6 +2946,7 @@ struct hci_dev *hci_alloc_dev(void)
 	INIT_WORK(&hdev->cmd_work, hci_cmd_work);
 	INIT_WORK(&hdev->tx_work, hci_tx_work);
 	INIT_WORK(&hdev->power_on, hci_power_on);
+	INIT_WORK(&hdev->reset, hci_reset);
 
 	INIT_DELAYED_WORK(&hdev->power_off, hci_power_off);
 	INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4175470ff48e..0fd6f4d97b4a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3101,6 +3101,8 @@ static void hci_hardware_error_evt(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_ev_hardware_error *ev = (void *) skb->data;
 
 	BT_ERR("%s hardware error 0x%2.2x", hdev->name, ev->code);
+
+	queue_work(hdev->req_workqueue, &hdev->reset);
 }
 
 static void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset
  2015-01-28 13:13 [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset Johan Hedberg
  2015-01-28 13:13 ` [PATCH 2/3] Bluetooth: Fix notifying discovery state when powering off Johan Hedberg
  2015-01-28 13:13 ` [PATCH 3/3] Bluetooth: Perform a power cycle when receiving a HW Error Johan Hedberg
@ 2015-01-28 21:55 ` Marcel Holtmann
  2 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2015-01-28 21:55 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth

Hi Johan,

> When HCI_Reset is issued the discovery state is assumed to be stopped.
> The hci_cc_reset() handler was trying to set the state but it was doing
> it without using the hci_discovery_set_state() function. Because of this
> e.g. the mgmt Discovering event could go without being sent. This patch
> fixes the code to use the hci_discovery_set_state() function instead of
> just blindly setting the state value.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/hci_event.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] Bluetooth: Fix notifying discovery state when powering off
  2015-01-28 13:13 ` [PATCH 2/3] Bluetooth: Fix notifying discovery state when powering off Johan Hedberg
@ 2015-01-28 22:04   ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2015-01-28 22:04 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth

Hi Johan,

> The discovery state should be set to stopped when the HCI device is
> powered off. This patch adds the appropriate call to the
> hci_discovery_set_state() function from hci_dev_do_close() which is
> responsible for the power-off procedure.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/hci_core.c | 2 ++
> 1 file changed, 2 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-28 22:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28 13:13 [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset Johan Hedberg
2015-01-28 13:13 ` [PATCH 2/3] Bluetooth: Fix notifying discovery state when powering off Johan Hedberg
2015-01-28 22:04   ` Marcel Holtmann
2015-01-28 13:13 ` [PATCH 3/3] Bluetooth: Perform a power cycle when receiving a HW Error Johan Hedberg
2015-01-28 21:55 ` [PATCH 1/3] Bluetooth: Fix notifying discovery state upon reset Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.