All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Fixes managing AMP controller
@ 2012-06-29 12:06 Andrei Emeltchenko
  2012-06-29 12:07 ` [PATCH 1/3] Bluetooth: Do not auto off " Andrei Emeltchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andrei Emeltchenko @ 2012-06-29 12:06 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Those fixes make sure that AMP controller is not shut down by
management interface and is not used as normal BR/EDR controller.
The idea is that there is no need to expose AMP controller to user
space.

Andrei Emeltchenko (3):
  Bluetooth: Do not auto off AMP controller
  Bluetooth: mgmt: Fix managing AMP device
  Bluetooth: Route traffic only through BR/EDR controller

 include/net/bluetooth/hci_core.h |    2 +-
 net/bluetooth/hci_conn.c         |    3 ++-
 net/bluetooth/hci_core.c         |   11 ++++++++---
 net/bluetooth/mgmt.c             |   20 ++++++++++++++++++--
 4 files changed, 29 insertions(+), 7 deletions(-)

-- 
1.7.9.5


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

* [PATCH 1/3] Bluetooth: Do not auto off AMP controller
  2012-06-29 12:06 [PATCH 0/3] Fixes managing AMP controller Andrei Emeltchenko
@ 2012-06-29 12:07 ` Andrei Emeltchenko
  2012-06-30 15:36   ` Gustavo Padovan
  2012-06-29 12:07 ` [PATCH 2/3] Bluetooth: mgmt: Fix managing AMP device Andrei Emeltchenko
  2012-06-29 12:07 ` [PATCH 3/3] Bluetooth: Route traffic only through BR/EDR controller Andrei Emeltchenko
  2 siblings, 1 reply; 7+ messages in thread
From: Andrei Emeltchenko @ 2012-06-29 12:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Since AMP controller is not managed by user space do not shut it down.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/hci_core.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8b93491..37712d3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1743,8 +1743,11 @@ int hci_register_dev(struct hci_dev *hdev)
 		}
 	}
 
-	set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
 	set_bit(HCI_SETUP, &hdev->dev_flags);
+
+	if (hdev->dev_type != HCI_AMP)
+		set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
+
 	schedule_work(&hdev->power_on);
 
 	hci_notify(hdev, HCI_DEV_REG);
-- 
1.7.9.5


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

* [PATCH 2/3] Bluetooth: mgmt: Fix managing AMP device
  2012-06-29 12:06 [PATCH 0/3] Fixes managing AMP controller Andrei Emeltchenko
  2012-06-29 12:07 ` [PATCH 1/3] Bluetooth: Do not auto off " Andrei Emeltchenko
@ 2012-06-29 12:07 ` Andrei Emeltchenko
  2012-07-19  7:39   ` Johan Hedberg
  2012-06-29 12:07 ` [PATCH 3/3] Bluetooth: Route traffic only through BR/EDR controller Andrei Emeltchenko
  2 siblings, 1 reply; 7+ messages in thread
From: Andrei Emeltchenko @ 2012-06-29 12:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

AMP device shall not be managed by user space for now.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |    2 +-
 net/bluetooth/hci_core.c         |    6 ++++--
 net/bluetooth/mgmt.c             |   20 ++++++++++++++++++--
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 75766b7..4f7c866 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1050,7 +1050,7 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering);
 int mgmt_interleaved_discovery(struct hci_dev *hdev);
 int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
 int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
-
+bool mgmt_valid_hdev(struct hci_dev *hdev);
 int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent);
 
 /* HCI info for socket */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 37712d3..5ad508e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -696,7 +696,8 @@ int hci_dev_open(__u16 dev)
 		hci_dev_hold(hdev);
 		set_bit(HCI_UP, &hdev->flags);
 		hci_notify(hdev, HCI_DEV_UP);
-		if (!test_bit(HCI_SETUP, &hdev->dev_flags)) {
+		if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
+		    mgmt_valid_hdev(hdev)) {
 			hci_dev_lock(hdev);
 			mgmt_powered(hdev, 1);
 			hci_dev_unlock(hdev);
@@ -797,7 +798,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	 * and no tasks are scheduled. */
 	hdev->close(hdev);
 
-	if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
+	if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags) &&
+	    mgmt_valid_hdev(hdev)) {
 		hci_dev_lock(hdev);
 		mgmt_powered(hdev, 0);
 		hci_dev_unlock(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e83368f..ed9d150 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -193,6 +193,11 @@ static u8 mgmt_status_table[] = {
 	MGMT_STATUS_CONNECT_FAILED,	/* MAC Connection Failed */
 };
 
+bool mgmt_valid_hdev(struct hci_dev *hdev)
+{
+	return hdev->dev_type == HCI_BREDR;
+}
+
 static u8 mgmt_status(u8 hci_status)
 {
 	if (hci_status < ARRAY_SIZE(mgmt_status_table))
@@ -317,7 +322,6 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
 			   u16 data_len)
 {
 	struct mgmt_rp_read_index_list *rp;
-	struct list_head *p;
 	struct hci_dev *d;
 	size_t rp_len;
 	u16 count;
@@ -328,7 +332,10 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
 	read_lock(&hci_dev_list_lock);
 
 	count = 0;
-	list_for_each(p, &hci_dev_list) {
+	list_for_each_entry(d, &hci_dev_list, list) {
+		if (!mgmt_valid_hdev(d))
+			continue;
+
 		count++;
 	}
 
@@ -346,6 +353,9 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
 		if (test_bit(HCI_SETUP, &d->dev_flags))
 			continue;
 
+		if (!mgmt_valid_hdev(d))
+			continue;
+
 		rp->index[i++] = cpu_to_le16(d->id);
 		BT_DBG("Added hci%u", d->id);
 	}
@@ -2831,6 +2841,9 @@ static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
 
 int mgmt_index_added(struct hci_dev *hdev)
 {
+	if (!mgmt_valid_hdev(hdev))
+		return -ENOTSUPP;
+
 	return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL);
 }
 
@@ -2838,6 +2851,9 @@ int mgmt_index_removed(struct hci_dev *hdev)
 {
 	u8 status = MGMT_STATUS_INVALID_INDEX;
 
+	if (!mgmt_valid_hdev(hdev))
+		return -ENOTSUPP;
+
 	mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
 
 	return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);
-- 
1.7.9.5


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

* [PATCH 3/3] Bluetooth: Route traffic only through BR/EDR controller
  2012-06-29 12:06 [PATCH 0/3] Fixes managing AMP controller Andrei Emeltchenko
  2012-06-29 12:07 ` [PATCH 1/3] Bluetooth: Do not auto off " Andrei Emeltchenko
  2012-06-29 12:07 ` [PATCH 2/3] Bluetooth: mgmt: Fix managing AMP device Andrei Emeltchenko
@ 2012-06-29 12:07 ` Andrei Emeltchenko
  2 siblings, 0 replies; 7+ messages in thread
From: Andrei Emeltchenko @ 2012-06-29 12:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

If AMP controller is first in the list then Bluetooth traffic might
be routed through it (if source is not specified). The patch
prevents this case and also checks that source is BR/EDR.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/hci_conn.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 858907f..743572e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -442,7 +442,8 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
 
 	list_for_each_entry(d, &hci_dev_list, list) {
 		if (!test_bit(HCI_UP, &d->flags) ||
-		    test_bit(HCI_RAW, &d->flags))
+		    test_bit(HCI_RAW, &d->flags) ||
+		    d->dev_type != HCI_BREDR)
 			continue;
 
 		/* Simple routing:
-- 
1.7.9.5


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

* Re: [PATCH 1/3] Bluetooth: Do not auto off AMP controller
  2012-06-29 12:07 ` [PATCH 1/3] Bluetooth: Do not auto off " Andrei Emeltchenko
@ 2012-06-30 15:36   ` Gustavo Padovan
  0 siblings, 0 replies; 7+ messages in thread
From: Gustavo Padovan @ 2012-06-30 15:36 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-06-29 15:07:00 +0300]:

> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Since AMP controller is not managed by user space do not shut it down.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/hci_core.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

applied to bluetooth-next. Thanks.

	Gustavo

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

* Re: [PATCH 2/3] Bluetooth: mgmt: Fix managing AMP device
  2012-06-29 12:07 ` [PATCH 2/3] Bluetooth: mgmt: Fix managing AMP device Andrei Emeltchenko
@ 2012-07-19  7:39   ` Johan Hedberg
  2012-07-19  7:56     ` Andrei Emeltchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Johan Hedberg @ 2012-07-19  7:39 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

On Fri, Jun 29, 2012, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> AMP device shall not be managed by user space for now.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  include/net/bluetooth/hci_core.h |    2 +-
>  net/bluetooth/hci_core.c         |    6 ++++--
>  net/bluetooth/mgmt.c             |   20 ++++++++++++++++++--
>  3 files changed, 23 insertions(+), 5 deletions(-)

Acked-by: Johan Hedberg <johan.hedberg@intel.com>

Though you could have made a bit more descriptive commit message.

Johan

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

* Re: [PATCH 2/3] Bluetooth: mgmt: Fix managing AMP device
  2012-07-19  7:39   ` Johan Hedberg
@ 2012-07-19  7:56     ` Andrei Emeltchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andrei Emeltchenko @ 2012-07-19  7:56 UTC (permalink / raw)
  To: linux-bluetooth

Hi Johan,

On Thu, Jul 19, 2012 at 10:39:45AM +0300, Johan Hedberg wrote:
> Hi Andrei,
> 
> On Fri, Jun 29, 2012, Andrei Emeltchenko wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > 
> > AMP device shall not be managed by user space for now.
> > 
> > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > ---
> >  include/net/bluetooth/hci_core.h |    2 +-
> >  net/bluetooth/hci_core.c         |    6 ++++--
> >  net/bluetooth/mgmt.c             |   20 ++++++++++++++++++--
> >  3 files changed, 23 insertions(+), 5 deletions(-)
> 
> Acked-by: Johan Hedberg <johan.hedberg@intel.com>
> 
> Though you could have made a bit more descriptive commit message.

I will write more and this patch together with other patches.

Best regards 
Andrei Emeltchenko 


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

end of thread, other threads:[~2012-07-19  7:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-29 12:06 [PATCH 0/3] Fixes managing AMP controller Andrei Emeltchenko
2012-06-29 12:07 ` [PATCH 1/3] Bluetooth: Do not auto off " Andrei Emeltchenko
2012-06-30 15:36   ` Gustavo Padovan
2012-06-29 12:07 ` [PATCH 2/3] Bluetooth: mgmt: Fix managing AMP device Andrei Emeltchenko
2012-07-19  7:39   ` Johan Hedberg
2012-07-19  7:56     ` Andrei Emeltchenko
2012-06-29 12:07 ` [PATCH 3/3] Bluetooth: Route traffic only through BR/EDR controller Andrei Emeltchenko

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.