* [PATCH 3/5] cltest: Fix memory leak
From: Andre Guedes @ 2014-02-07 22:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391812125-19594-1-git-send-email-andre.guedes@openbossa.org>
---
tools/cltest.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/cltest.c b/tools/cltest.c
index 16b7553..4ddb98a 100644
--- a/tools/cltest.c
+++ b/tools/cltest.c
@@ -205,8 +205,8 @@ static bool find_controllers(void)
dl = malloc(HCI_MAX_DEV * sizeof(struct hci_dev_req) + sizeof(uint16_t));
if (!dl) {
perror("Failed allocate HCI device request memory");
- result = false;
- goto done;
+ close(fd);
+ return false;
}
dl->dev_num = HCI_MAX_DEV;
@@ -243,6 +243,7 @@ static bool find_controllers(void)
}
done:
+ free(dl);
close(fd);
return result;
}
--
1.8.5.3
^ permalink raw reply related
* [PATCH 2/5] hcidump: Fix memory leak
From: Andre Guedes @ 2014-02-07 22:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391812125-19594-1-git-send-email-andre.guedes@openbossa.org>
Memory pointed by frm.data variable was not freed in both failure and
success flows.
---
tools/hcidump.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/hcidump.c b/tools/hcidump.c
index 50123d2..2bbc207 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
@@ -309,7 +309,7 @@ static void read_dump(int fd)
if (err < 0)
goto failed;
if (!err)
- return;
+ goto done;
if (parser.flags & DUMP_PKTLOG) {
switch (ph.type) {
@@ -407,7 +407,7 @@ static void read_dump(int fd)
if (err < 0)
goto failed;
if (!err)
- return;
+ goto done;
frm.ptr = frm.data;
frm.len = frm.data_len;
@@ -432,8 +432,13 @@ static void read_dump(int fd)
parse(&frm);
}
+done:
+ free(frm.data);
+ return;
+
failed:
perror("Read failed");
+ free(frm.data);
exit(1);
}
--
1.8.5.3
^ permalink raw reply related
* [PATCH 1/5] hcitool: Fix memory leak in cmd_info
From: Andre Guedes @ 2014-02-07 22:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391812125-19594-1-git-send-email-andre.guedes@openbossa.org>
Free memory pointed by cr variable after it is used.
---
tools/hcitool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 8a92067..c2df8e3 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -961,6 +961,7 @@ static void cmd_info(int dev_id, int argc, char **argv)
htobs(di.pkt_type & ACL_PTYPE_MASK),
0, 0x01, &handle, 25000) < 0) {
perror("Can't create connection");
+ free(cr);
close(dd);
exit(1);
}
@@ -969,6 +970,8 @@ static void cmd_info(int dev_id, int argc, char **argv)
} else
handle = htobs(cr->conn_info->handle);
+ free(cr);
+
printf("\tBD Address: %s\n", argv[0]);
comp = batocomp(&bdaddr);
--
1.8.5.3
^ permalink raw reply related
* [PATCH 0/5] Fixes for memory leaks
From: Andre Guedes @ 2014-02-07 22:28 UTC (permalink / raw)
To: linux-bluetooth
Hi all,
This patch set fixes some memory leaks reported by clang static analyzer.
There is no relation between patches of this set so they can be applied
independently.
BR,
Andre
Andre Guedes (5):
hcitool: Fix memory leak in cmd_info
hcidump: Fix memory leak
cltest: Fix memory leak
amptest: Fix memory leak
rctest: Fix memory leak
tools/amptest.c | 12 ++++++++----
tools/cltest.c | 5 +++--
tools/hcidump.c | 9 +++++++--
tools/hcitool.c | 3 +++
tools/rctest.c | 5 ++++-
5 files changed, 25 insertions(+), 9 deletions(-)
--
1.8.5.3
^ permalink raw reply
* [PATCH] gitignore: Add cscope files
From: Andre Guedes @ 2014-02-07 22:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391812080-19529-1-git-send-email-andre.guedes@openbossa.org>
---
.gitignore | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.gitignore b/.gitignore
index b86deae..fe6636e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -121,3 +121,7 @@ android/android-tester
android/ipc-tester
android/bluetoothd-snoop
android/test-ipc
+
+cscope.in.out
+cscope.out
+cscope.po.out
--
1.8.5.3
^ permalink raw reply related
* [PATCH] btsnoop: Remove unused local function and macro
From: Andre Guedes @ 2014-02-07 22:27 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391812080-19529-1-git-send-email-andre.guedes@openbossa.org>
---
tools/btsnoop.c | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/tools/btsnoop.c b/tools/btsnoop.c
index a65d8c5..260dfdb 100644
--- a/tools/btsnoop.c
+++ b/tools/btsnoop.c
@@ -40,19 +40,6 @@
#include "monitor/btsnoop.h"
-static inline uint64_t ntoh64(uint64_t n)
-{
- uint64_t h;
- uint64_t tmp = ntohl(n & 0x00000000ffffffff);
-
- h = ntohl(n >> 32);
- h |= tmp << 32;
-
- return h;
-}
-
-#define hton64(x) ntoh64(x)
-
struct btsnoop_hdr {
uint8_t id[8]; /* Identification Pattern */
uint32_t version; /* Version Number = 1 */
--
1.8.5.3
^ permalink raw reply related
* [PATCH] health: Fix HealthDevice dbus registration
From: Andre Guedes @ 2014-02-07 22:27 UTC (permalink / raw)
To: linux-bluetooth
For some reason, HealthDevice property table wasn't been registered.
---
profiles/health/hdp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 622d95b..48dad52 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -2145,7 +2145,8 @@ static struct hdp_device *create_health_device(struct btd_device *device)
if (!g_dbus_register_interface(btd_get_dbus_connection(),
path, HEALTH_DEVICE,
health_device_methods,
- health_device_signals, NULL,
+ health_device_signals,
+ health_device_properties,
dev, health_device_destroy)) {
error("D-Bus failed to register %s interface", HEALTH_DEVICE);
goto fail;
--
1.8.5.3
^ permalink raw reply related
* [PATCH BlueZ 3/3] lib/sdp: Fix printing of multiple record fields
From: Anderson Lizardo @ 2014-02-07 20:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1391804086-14428-1-git-send-email-anderson.lizardo@openbossa.org>
If there are multiple fields to print, sdp_record_print() was missing a
newline between entries.
---
lib/sdp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/sdp.c b/lib/sdp.c
index 0a7cb6f..e5e4622 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -1605,13 +1605,13 @@ void sdp_record_print(const sdp_record_t *rec)
{
sdp_data_t *d = sdp_data_get(rec, SDP_ATTR_SVCNAME_PRIMARY);
if (d && SDP_IS_TEXT_STR(d->dtd))
- printf("Service Name: %.*s", d->unitSize, d->val.str);
+ printf("Service Name: %.*s\n", d->unitSize, d->val.str);
d = sdp_data_get(rec, SDP_ATTR_SVCDESC_PRIMARY);
if (d && SDP_IS_TEXT_STR(d->dtd))
- printf("Service Description: %.*s", d->unitSize, d->val.str);
+ printf("Service Description: %.*s\n", d->unitSize, d->val.str);
d = sdp_data_get(rec, SDP_ATTR_PROVNAME_PRIMARY);
if (d && SDP_IS_TEXT_STR(d->dtd))
- printf("Service Provider: %.*s", d->unitSize, d->val.str);
+ printf("Service Provider: %.*s\n", d->unitSize, d->val.str);
}
#ifdef SDP_DEBUG
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 2/3] tools/sdptool: Fix output formatting
From: Anderson Lizardo @ 2014-02-07 20:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1391804086-14428-1-git-send-email-anderson.lizardo@openbossa.org>
Print 8-bit and 16-bit integers with in a more readable format.
---
tools/sdptool.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/sdptool.c b/tools/sdptool.c
index d6b7006..1600c3e 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -1048,7 +1048,7 @@ static void print_service_desc(void *value, void *user)
if (proto == RFCOMM_UUID)
printf(" Channel: %d\n", p->val.uint8);
else
- printf(" uint8: 0x%x\n", p->val.uint8);
+ printf(" uint8: 0x%02x\n", p->val.uint8);
break;
case SDP_UINT16:
if (proto == L2CAP_UUID) {
@@ -1060,9 +1060,9 @@ static void print_service_desc(void *value, void *user)
if (i == 1)
printf(" Version: 0x%04x\n", p->val.uint16);
else
- printf(" uint16: 0x%x\n", p->val.uint16);
+ printf(" uint16: 0x%04x\n", p->val.uint16);
else
- printf(" uint16: 0x%x\n", p->val.uint16);
+ printf(" uint16: 0x%04x\n", p->val.uint16);
break;
case SDP_SEQ16:
printf(" SEQ16:");
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 1/3] lib/sdp: Add missing Service Class ID for GAP
From: Anderson Lizardo @ 2014-02-07 20:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Also reorder last ID so the list remains ordered.
---
lib/sdp.c | 3 ++-
lib/sdp.h | 7 ++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/sdp.c b/lib/sdp.c
index 3b26ec3..0a7cb6f 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -181,8 +181,9 @@ static struct tupla ServiceClass[] = {
{ HDP_SVCLASS_ID, "HDP" },
{ HDP_SOURCE_SVCLASS_ID, "HDP Source" },
{ HDP_SINK_SVCLASS_ID, "HDP Sink" },
- { APPLE_AGENT_SVCLASS_ID, "Apple Agent" },
+ { GENERIC_ACCESS_SVCLASS_ID, "Generic Access" },
{ GENERIC_ATTRIB_SVCLASS_ID, "Generic Attribute" },
+ { APPLE_AGENT_SVCLASS_ID, "Apple Agent" },
{ 0 }
};
diff --git a/lib/sdp.h b/lib/sdp.h
index c6dfc27..516d75d 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -150,8 +150,9 @@ extern "C" {
#define HDP_SVCLASS_ID 0x1400
#define HDP_SOURCE_SVCLASS_ID 0x1401
#define HDP_SINK_SVCLASS_ID 0x1402
-#define APPLE_AGENT_SVCLASS_ID 0x2112
+#define GENERIC_ACCESS_SVCLASS_ID 0x1800
#define GENERIC_ATTRIB_SVCLASS_ID 0x1801
+#define APPLE_AGENT_SVCLASS_ID 0x2112
/*
* Standard profile descriptor identifiers; note these
@@ -224,9 +225,9 @@ extern "C" {
#define HDP_PROFILE_ID HDP_SVCLASS_ID
#define HDP_SOURCE_PROFILE_ID HDP_SOURCE_SVCLASS_ID
#define HDP_SINK_PROFILE_ID HDP_SINK_SVCLASS_ID
-#define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
-#define GENERIC_ACCESS_PROFILE_ID 0x1800
+#define GENERIC_ACCESS_PROFILE_ID GENERIC_ACCESS_SVCLASS_ID
#define GENERIC_ATTRIB_PROFILE_ID GENERIC_ATTRIB_SVCLASS_ID
+#define APPLE_AGENT_PROFILE_ID APPLE_AGENT_SVCLASS_ID
/*
* Compatibility macros for the old MDP acronym
--
1.7.9.5
^ permalink raw reply related
* [PATCH] avrcp: Avoids unneeded memory allocation
From: Andrei Emeltchenko @ 2014-02-07 13:27 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Allocate as much memory as we need since we know this in advance.
Simplifies also length calculation.
---
profiles/audio/avrcp.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index be67fe5..7c7de38 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2263,11 +2263,9 @@ done:
static void avrcp_list_items(struct avrcp *session, uint32_t start,
uint32_t end)
{
- uint8_t buf[AVRCP_BROWSING_HEADER_LENGTH + 10 +
- AVRCP_MEDIA_ATTRIBUTE_LAST * sizeof(uint32_t)];
+ uint8_t buf[AVRCP_BROWSING_HEADER_LENGTH + 10 + sizeof(uint32_t)];
struct avrcp_player *player = session->controller->player;
struct avrcp_browsing_header *pdu = (void *) buf;
- uint16_t length = AVRCP_BROWSING_HEADER_LENGTH + 10;
uint32_t attribute;
memset(buf, 0, sizeof(buf));
@@ -2287,9 +2285,7 @@ static void avrcp_list_items(struct avrcp *session, uint32_t start,
attribute = htonl(AVRCP_MEDIA_ATTRIBUTE_TITLE);
memcpy(&pdu->params[10], &attribute, sizeof(uint32_t));
- length += sizeof(uint32_t);
-
- avctp_send_browsing_req(session->conn, buf, length,
+ avctp_send_browsing_req(session->conn, buf, sizeof(buf),
avrcp_list_items_rsp, session);
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 4/4] bnep: Calculate ifindex after NULL check
From: Andrei Emeltchenko @ 2014-02-07 12:11 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391775078-25010-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
profiles/network/bnep.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 1aa0783..ece979f 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -523,13 +523,15 @@ static int bnep_add_to_bridge(const char *devname, const char *bridge)
static int bnep_del_from_bridge(const char *devname, const char *bridge)
{
- int ifindex = if_nametoindex(devname);
+ int ifindex;
struct ifreq ifr;
int sk, err;
if (!devname || !bridge)
return -EINVAL;
+ ifindex = if_nametoindex(devname);
+
sk = socket(AF_INET, SOCK_STREAM, 0);
if (sk < 0)
return -1;
--
1.8.3.2
^ permalink raw reply related
* [PATCH 3/4] avdtp: Fix passing NULL pointer to memcpy
From: Andrei Emeltchenko @ 2014-02-07 12:11 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391775078-25010-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The patch fixes following clang warning:
...
profiles/audio/avdtp.c:3293:2: warning: Null pointer passed as an
argument to a 'nonnull' parameter
memcpy(cap->data, data, length);
^ ~~~~
1 warning generated.
...
---
profiles/audio/avdtp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index da10ab4..b7ddb6c 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -3290,7 +3290,9 @@ struct avdtp_service_capability *avdtp_service_cap_new(uint8_t category,
cap = g_malloc(sizeof(struct avdtp_service_capability) + length);
cap->category = category;
cap->length = length;
- memcpy(cap->data, data, length);
+
+ if (data)
+ memcpy(cap->data, data, length);
return cap;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 2/4] avdtp: Fix passing NULL pointer to memcpy
From: Andrei Emeltchenko @ 2014-02-07 12:11 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1391775078-25010-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
send_request can be called as
send_request(session, FALSE, NULL, AVDTP_DISCOVER, NULL, 0) with NULL
pointer which is passed to memcpy().
---
profiles/audio/avdtp.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index fbf61f0..da10ab4 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2731,11 +2731,14 @@ static int send_request(struct avdtp *session, gboolean priority,
req = g_new0(struct pending_req, 1);
req->signal_id = signal_id;
- req->data = g_malloc(size);
- memcpy(req->data, buffer, size);
- req->data_size = size;
req->stream = stream;
+ if (buffer && size) {
+ req->data = g_malloc(size);
+ memcpy(req->data, buffer, size);
+ req->data_size = size;
+ }
+
return send_req(session, priority, req);
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 1/4] android/haltest: Remove unneeded assignment
From: Andrei Emeltchenko @ 2014-02-07 12:11 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/client/if-audio.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/android/client/if-audio.c b/android/client/if-audio.c
index 8c640a1..5ab11a6 100644
--- a/android/client/if-audio.c
+++ b/android/client/if-audio.c
@@ -225,10 +225,8 @@ static void *playback_thread(void *data)
pthread_mutex_unlock(&outstream_mutex);
} while (len && w_len > 0);
- if (in) {
+ if (in)
fclose(in);
- in = NULL;
- }
pthread_cleanup_pop(1);
return NULL;
--
1.8.3.2
^ permalink raw reply related
* [RFC 2/2] bluetooth: Add initial support for BT chip over SMD
From: Lukasz Rymanowski @ 2014-02-07 11:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1391772937-12802-1-git-send-email-lukasz.rymanowski@tieto.com>
This patch adds support for Qualcomm chips which uses msm
shared memory driver as a transport layer.
This driver based on SMD driver found in msm kernel branch.
Signed-off-by: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
---
drivers/bluetooth/Kconfig | 9 +
drivers/bluetooth/Makefile | 1 +
drivers/bluetooth/hci_smd.c | 460 ++++++++++++++++++++++++++++++++++++++++++++
include/net/bluetooth/hci.h | 1 +
4 files changed, 471 insertions(+)
create mode 100644 drivers/bluetooth/hci_smd.c
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 11a6104..f8a46c5 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -242,4 +242,13 @@ config BT_WILINK
Say Y here to compile support for Texas Instrument's WiLink7 driver
into the kernel or say M to compile it as module.
+
+config BT_HCISMD
+ tristate "Qualcomm HCI Shared Memory Driver"
+ help
+ This enables the Bluetooth driver for Qualcomm BT devices uses SMD interface.
+
+ Say Y here to compile support for Qualcomm over SMD driver into kernel or
+ say M to compile it as module (hci_smd)
+
endmenu
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index 9fe8a87..0666e60 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_BT_ATH3K) += ath3k.o
obj-$(CONFIG_BT_MRVL) += btmrvl.o
obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o
obj-$(CONFIG_BT_WILINK) += btwilink.o
+obj-$(CONFIG_BT_HCISMD) += hci_smd.o
btmrvl-y := btmrvl_main.o
btmrvl-$(CONFIG_DEBUG_FS) += btmrvl_debugfs.o
diff --git a/drivers/bluetooth/hci_smd.c b/drivers/bluetooth/hci_smd.c
new file mode 100644
index 0000000..9eb3675
--- /dev/null
+++ b/drivers/bluetooth/hci_smd.c
@@ -0,0 +1,460 @@
+
+/*
+ *
+ * HCI_SMD (HCI Shared Memory Driver) is Qualcomm's Shared memory driver
+ * for the HCI protocol.
+ *
+ * Copyright (C) 2000-2001 Qualcomm Incorporated
+ * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
+ * Copyright (C) 2004-2006 Marcel Holtmann <marcel@holtmann.org>
+ * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
+ * Copyright (C) 2014, Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/skbuff.h>
+#include <linux/workqueue.h>
+#include <linux/platform_device.h>
+#include <linux/completion.h>
+#include <linux/jiffies.h>
+#include <linux/spinlock.h>
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+#include <linux/smd.h>
+
+#define VERSION "0.1"
+
+#define SMD_CMD_CHANNEL "APPS_RIVA_BT_CMD"
+#define SMD_ACL_CHANNEL "APPS_RIVA_BT_ACL"
+
+#define SMD_APPS_RIVA_BT_CMD_READY 0x01
+#define SMD_APPS_RIVA_BT_ACL_READY 0x02
+#define SMD_READY ((SMD_APPS_RIVA_BT_CMD_READY) | (SMD_APPS_RIVA_BT_ACL_READY))
+
+struct rx_work {
+ struct work_struct work;
+ struct smd_data *smd;
+ struct hci_dev *hdev;
+ u8 pkt_type;
+};
+
+struct smd_channel_data {
+ struct hci_dev *hdev;
+ struct workqueue_struct *wq;
+ struct smd_data *smd;
+};
+
+struct hci_smd_data {
+ struct hci_dev *hdev;
+
+ struct smd_channel_data *smd_cmd;
+ struct smd_channel_data *smd_acl;
+ u8 ready_flags;
+ struct completion smd_ready;
+
+ /* Protects ready_flags */
+ spinlock_t flags_lock;
+};
+
+static struct hci_smd_data hs;
+
+static void hci_smd_channel_open(struct smd_channel_data *scd)
+{
+ const char *name = scd->smd->pdev->name;
+
+ spin_lock(&hs.flags_lock);
+ if (scd->hdev) {
+ set_bit(HCI_RUNNING, &scd->hdev->flags);
+ spin_unlock(&hs.flags_lock);
+ return;
+ }
+
+ if (!strncmp(name, SMD_CMD_CHANNEL, sizeof(SMD_CMD_CHANNEL)))
+ hs.ready_flags |= SMD_APPS_RIVA_BT_CMD_READY;
+
+ if (!strncmp(name, SMD_ACL_CHANNEL, sizeof(SMD_ACL_CHANNEL)))
+ hs.ready_flags |= SMD_APPS_RIVA_BT_ACL_READY;
+
+ if ((SMD_READY & hs.ready_flags) != SMD_READY) {
+ spin_unlock(&hs.flags_lock);
+ return;
+ }
+
+ spin_unlock(&hs.flags_lock);
+ complete_all(&hs.smd_ready);
+}
+
+static void hci_smd_channel_close(struct smd_channel_data *scd)
+{
+ if (!scd->hdev)
+ return;
+
+ clear_bit(HCI_RUNNING, &scd->hdev->flags);
+}
+
+static int hci_smd_open(struct hci_dev *hdev)
+{
+ BT_DBG("hdev %s, %p", hdev->name, hdev);
+
+ set_bit(HCI_RUNNING, &hdev->flags);
+ return 0;
+}
+
+static int hci_smd_close(struct hci_dev *hdev)
+{
+ BT_DBG("hdev %s %p", hdev->name, hdev);
+
+ clear_bit(HCI_RUNNING, &hdev->flags);
+ return 0;
+}
+
+static void hci_smd_rx_work(struct work_struct *work)
+{
+ struct rx_work *wk = container_of(work, struct rx_work, work);
+ u8 type = wk->pkt_type;
+ struct smd_data *smd = wk->smd;
+ struct hci_dev *hdev = wk->hdev;
+ struct sk_buff *skb;
+ int len;
+
+ BT_DBG("hdev %p, %02x", hdev, type);
+
+ /*It s save to free work here */
+ kfree(wk);
+
+ len = smd->ops.read_avail(smd);
+ if (len > HCI_MAX_FRAME_SIZE)
+ return;
+
+ while (len) {
+ int rc = 0;
+ skb = bt_skb_alloc(len, GFP_KERNEL);
+ if (!skb)
+ return;
+
+ rc = smd->ops.read(smd, skb_put(skb, len), len);
+ if (rc < len) {
+ kfree_skb(skb);
+ return;
+ }
+
+ skb->dev = (void *)hdev;
+ bt_cb(skb)->pkt_type = type;
+ skb_orphan(skb);
+
+ rc = hci_recv_frame(hdev, skb);
+ if (rc < 0) {
+ BT_ERR("Failed to pass skb to Bluetooth module");
+ kfree_skb(skb);
+ return;
+ }
+
+ len = smd->ops.read_avail(smd);
+ if (len > HCI_MAX_FRAME_SIZE)
+ return;
+ }
+}
+
+static int hci_smd_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct hci_smd_data *hs = hci_get_drvdata(hdev);
+ struct smd_data *smd;
+ int sent;
+
+ if (!hdev) {
+ BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+ return -ENODEV;
+ }
+
+ if (!test_bit(HCI_RUNNING, &(hdev->flags)))
+ return -EBUSY;
+
+ switch (bt_cb(skb)->pkt_type) {
+ case HCI_COMMAND_PKT:
+ smd = hs->smd_cmd->smd;
+ sent = smd->ops.write(smd, skb->data, skb->len);
+ break;
+ case HCI_ACLDATA_PKT:
+ case HCI_SCODATA_PKT:
+ smd = hs->smd_acl->smd;
+ sent = smd->ops.write(smd, skb->data, skb->len);
+ break;
+ default:
+ BT_ERR("Unknown package");
+ kfree_skb(skb);
+ return -EPROTO;
+ }
+
+ kfree_skb(skb);
+
+ if (sent < 0) {
+ BT_ERR("Failed to send all data");
+ return -ENOSPC;
+ }
+
+ return 0;
+}
+
+static struct rx_work *alloc_rx_work(u8 pkt_type, struct smd_data *smd,
+ struct hci_dev *hdev)
+{
+ struct rx_work *w = kmalloc(sizeof(*w), GFP_ATOMIC);
+
+ if (!w) {
+ BT_ERR("Could not allocate work");
+ return NULL;
+ }
+
+ INIT_WORK(&w->work, hci_smd_rx_work);
+ w->pkt_type = pkt_type;
+ w->smd = smd;
+ w->hdev = hdev;
+
+ return w;
+}
+
+static void hci_smd_notify(struct platform_device *pdev,
+ unsigned int event, u8 pkt_type)
+{
+ struct smd_channel_data *scd = dev_get_drvdata(&pdev->dev);
+ struct hci_dev *hdev = scd->hdev;
+ struct rx_work *w;
+
+ if (!scd || !scd->smd) {
+ BT_ERR("SMD channel data not avaiable");
+ return;
+ }
+
+ switch (event) {
+ case SMD_EVENT_DATA:
+ w = alloc_rx_work(pkt_type, scd->smd, hdev);
+ if (w && hdev)
+ queue_work(scd->wq, &w->work);
+ else
+ BT_ERR("Read failed hdev:%p, work:%p ", hdev, w);
+ break;
+ case SMD_EVENT_OPEN:
+ hci_smd_channel_open(scd);
+ break;
+ case SMD_EVENT_CLOSE:
+ hci_smd_channel_close(scd);
+ break;
+ default:
+ break;
+ }
+}
+
+static void hci_smd_notify_cmd(struct platform_device *pdev,
+ unsigned int event)
+{
+ hci_smd_notify(pdev, event, HCI_EVENT_PKT);
+}
+
+static void hci_smd_notify_data(struct platform_device *pdev,
+ unsigned int event)
+{
+ hci_smd_notify(pdev, event, HCI_ACLDATA_PKT);
+}
+
+static int hci_smd_register(void)
+{
+ struct hci_dev *hdev;
+ int err;
+
+ BT_DBG("hci_smd_register");
+
+ /*
+ * Lets use two different worqueues for Event and ACL data so we make
+ * sure that Event will never be blocked by ACL data.
+ */
+ hs.smd_cmd->wq = alloc_workqueue("smd_event", WQ_HIGHPRI |
+ WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
+ if (!hs.smd_cmd->wq) {
+ BT_ERR("Error allocating event workqueue");
+ err = -ENOMEM;
+ goto close_smd;
+ }
+
+ hs.smd_acl->wq = alloc_workqueue("data_event", WQ_HIGHPRI |
+ WQ_UNBOUND | WQ_MEM_RECLAIM, 1);
+ if (!hs.smd_acl->wq) {
+ BT_ERR("Error allocating data workqueue");
+ destroy_workqueue(hs.smd_cmd->wq);
+ err = -ENOMEM;
+ goto close_smd;
+ }
+
+ /* Initialize and register HCI device */
+ hdev = hci_alloc_dev();
+ if (!hdev) {
+ BT_ERR("Error allocating HCI dev");
+ err = -ENOMEM;
+ goto cleanup;
+ }
+
+ hdev->bus = HCI_SMD;
+ hci_set_drvdata(hdev, &hs);
+
+ hdev->open = hci_smd_open;
+ hdev->close = hci_smd_close;
+ hdev->send = hci_smd_send_frame;
+
+ hs.smd_cmd->hdev = hdev;
+ hs.smd_acl->hdev = hdev;
+
+ err = hci_register_dev(hdev);
+ if (!err)
+ return 0;
+
+ BT_ERR("Can't register HCI device");
+ hci_free_dev(hdev);
+
+cleanup:
+ destroy_workqueue(hs.smd_cmd->wq);
+ destroy_workqueue(hs.smd_acl->wq);
+close_smd:
+ hs.smd_cmd->smd->ops.close(hs.smd_cmd->smd);
+ hs.smd_acl->smd->ops.close(hs.smd_acl->smd);
+
+ return err;
+}
+
+static int smd_cmd_channel_probe(struct platform_device *pdev)
+{
+ struct smd_data *smd = dev_get_platdata(&pdev->dev);
+ struct smd_channel_data *scd = kzalloc(sizeof(*scd), GFP_KERNEL);
+ int err;
+
+ scd->smd = smd;
+ hs.smd_cmd = scd;
+
+ dev_set_drvdata(&pdev->dev, scd);
+
+ err = smd->ops.open(smd, hci_smd_notify_cmd);
+ if (err < 0) {
+ BT_ERR("Can not open %s", SMD_CMD_CHANNEL);
+ return err;
+ }
+
+ return 0;
+}
+
+static int smd_data_channel_probe(struct platform_device *pdev)
+{
+ struct smd_data *smd = dev_get_platdata(&pdev->dev);
+ struct smd_channel_data *scd = kzalloc(sizeof(*scd), GFP_KERNEL);
+ int err;
+
+ scd->smd = smd;
+ hs.smd_acl = scd;
+
+ dev_set_drvdata(&pdev->dev, scd);
+
+ err = smd->ops.open(smd, hci_smd_notify_data);
+ if (err < 0) {
+ BT_ERR("Can not open %s", SMD_ACL_CHANNEL);
+ return err;
+ }
+
+ return 0;
+}
+
+
+static int smd_channel_remove(struct platform_device *pdev)
+{
+ struct smd_data *smd = dev_get_platdata(&pdev->dev);
+ return smd->ops.close(smd);
+}
+
+static struct platform_driver cmd_drv = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = SMD_CMD_CHANNEL,
+ },
+ .probe = smd_cmd_channel_probe,
+ .remove = smd_channel_remove,
+
+};
+
+static struct platform_driver acl_drv = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = SMD_ACL_CHANNEL,
+ },
+ .probe = smd_data_channel_probe,
+ .remove = smd_channel_remove,
+};
+
+static int __init hci_smd_init(void)
+{
+ int err;
+
+ BT_INFO("hci smd driver ver %s", VERSION);
+
+ memset(&hs, 0, sizeof(hs));
+
+ spin_lock_init(&hs.flags_lock);
+ init_completion(&hs.smd_ready);
+
+ /*
+ * SMD channels are represented by platform devices. We need them two
+ * for BT operations. Channel for BT CMD/EVENT traffic and BT ACL DATA
+ * traffic.
+ */
+ err = platform_driver_register(&cmd_drv);
+ if (err < 0) {
+ BT_ERR("Failed to register drv: %s err: %d",
+ cmd_drv.driver.name, err);
+ return err;
+ }
+
+ err = platform_driver_register(&acl_drv);
+ if (err < 0) {
+ BT_ERR("Failed to register drv: %s, err: %d",
+ acl_drv.driver.name, err);
+ platform_driver_unregister(&cmd_drv);
+ return err;
+ }
+
+ /* Let's wait until SMD channels are ready */
+ err = wait_for_completion_killable_timeout(&hs.smd_ready,
+ msecs_to_jiffies(5000));
+ if (err <= 0)
+ return err;
+
+ return hci_smd_register();
+}
+
+static void __exit hci_smd_exit(void)
+{
+ kfree(hs.smd_cmd);
+ kfree(hs.smd_acl);
+
+ platform_driver_unregister(&cmd_drv);
+ platform_driver_unregister(&acl_drv);
+}
+
+module_init(hci_smd_init);
+module_exit(hci_smd_exit);
+
+MODULE_AUTHOR("Lukasz Rymanowski <lukasz.rymanowski@tieto.com>");
+MODULE_AUTHOR("Ankur Nandwani <ankurn@codeaurora.org>");
+MODULE_DESCRIPTION("Bluetooth SMD driver ver " VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL v2");
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 352d3d7..149b06a 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -58,6 +58,7 @@
#define HCI_RS232 4
#define HCI_PCI 5
#define HCI_SDIO 6
+#define HCI_SMD 7
/* HCI controller types */
#define HCI_BREDR 0x00
--
1.8.4
^ permalink raw reply related
* [RFC 1/2] Add basic API for shared memory driver
From: Lukasz Rymanowski @ 2014-02-07 11:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
In-Reply-To: <1391772937-12802-1-git-send-email-lukasz.rymanowski@tieto.com>
This patch adds simple API to shared memory driver based on msm-smd.h
This is required in order to add support for support Qualcomm BT chips
via SMD
Signed-off-by: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
---
include/linux/smd.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
create mode 100644 include/linux/smd.h
diff --git a/include/linux/smd.h b/include/linux/smd.h
new file mode 100644
index 0000000..58de0d4
--- /dev/null
+++ b/include/linux/smd.h
@@ -0,0 +1,69 @@
+/*
+* smd.h - API for Shared Memory Driver
+*
+* Copyright (c) 2014 Intel Corporation
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*/
+
+#ifndef _SMD_H_
+#define _SMD_H_
+
+#include <linux/platform_device.h>
+
+/**
+* Events from smd device.
+*/
+#define SMD_EVENT_DATA 1
+#define SMD_EVENT_OPEN 2
+#define SMD_EVENT_CLOSE 3
+
+struct smd_channel;
+struct smd_notify_data;
+struct smd_data;
+
+/**
+* struct smd_ops - specific operation for smd channel
+*
+* @open: Open SMD channel. It should return zero once device is opened.
+* On open there is need to pass notification cb which is used
+* for notifications form SMD device.
+* @close Close SMD channel
+* @write: Write data to SMD channel. It should return number of written
+* bytes or negative value in case of error.
+* @read: Read data from SMD channel.It should return number of written
+* bytes or negative value in case of error.
+*@read_avail: Returns number of bytes ready to be read. This should be called
+* before read in order to allocate enought skb
+*
+*/
+struct smd_ops {
+ int (*open)(struct smd_data *s,
+ void (*notify)(struct platform_device *pdev,
+ unsigned int event));
+ int (*close)(struct smd_data *s);
+ int (*write)(struct smd_data *s, const void *data, int len);
+ int (*read)(struct smd_data *s, void *buf, int len);
+ int (*read_avail)(struct smd_data *s);
+};
+/**
+* struct smd_data - smd device data for shared memory channel
+*
+* @pdev: Platform device for given smd channel.
+* @ops: SMD specific operations for this smd channel.
+* @ch: SMD channel which is used by SMD device. Should not be
+* used by the driver
+* @notifier: SMD notifier data. Shall not be used by driver.
+*
+* smd_data are initialized by the platform and are available for driver
+* in platform_data.
+*/
+struct smd_data {
+ struct platform_device *pdev;
+ struct smd_ops ops;
+ struct smd_channel *ch;
+ struct smd_notify_data *notify_data;
+};
+#endif
--
1.8.4
^ permalink raw reply related
* [RFC 0/2] Add hci_smd driver
From: Lukasz Rymanowski @ 2014-02-07 11:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lukasz Rymanowski
Hello,
This is a try (long shoot) to upstream hci shared memory driver (hci_smd)
which is used on Qualcomm platforms and BT chips.
To make it build with upstream tree I had to introduce some simple SMD API.
The idea here is that since SMD channel is represented by platform device
(as it is done in mach-msm),
then platfrom_data contains smd_data which contains API for that channel.
Writing this SMD API I was inspired with MSM-SMD and since I'm not an expert
in this area I'm asking for comments here.
Maybe instead of SMD API I made, I should expose functions like smd_open(), smd_write()
etc. something similar how sdio does, and just deliver to upstream dummy device
implementing this SMD API?
Other options I was considering is to implement module inside mach-msm which
would handle registering SMD BT Channels and when it is done, it would register
new platform device like "smd-bt". Then I could move smd.h to some bluetooth includes
(althought don't now where at the moment) and hci_smd would register driver for "smd-bt"
In this case I would also could rid of one static variable I have now in hci_smd
Comments on those options are welcome.
Anyway, Hci_smd is based on one of the older version of this driver found in msm kernel
branch, so there are no wakelocks as in new version and also workqueues are used
instead of takslet.
Since SMD expose two channels, one for CMD/EVENT and one for ACL Data I decide to
do separate worqueues for this. This is to make sure that ACL data never blocks EVENT
packages
Lukasz Rymanowski (2):
Add basic API for shared memory driver
bluetooth: Add initial support for BT chip over SMD
drivers/bluetooth/Kconfig | 9 +
drivers/bluetooth/Makefile | 1 +
drivers/bluetooth/hci_smd.c | 461 ++++++++++++++++++++++++++++++++++++++++++++
include/linux/smd.h | 68 +++++++
include/net/bluetooth/hci.h | 1 +
5 files changed, 540 insertions(+)
create mode 100644 drivers/bluetooth/hci_smd.c
create mode 100644 include/linux/smd.h
--
1.8.4
^ permalink raw reply
* Re: [PATCHv2 1/2] android/haltest: Close file in case of error
From: Szymon Janc @ 2014-02-07 10:05 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1391696563-7478-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Thursday 06 of February 2014 16:22:42 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> ---
> android/client/if-audio.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/android/client/if-audio.c b/android/client/if-audio.c
> index 66f8364..3b34c95 100644
> --- a/android/client/if-audio.c
> +++ b/android/client/if-audio.c
> @@ -258,19 +258,26 @@ static void play_p(int argc, const char **argv)
>
> if (buffer_size == 0) {
> haltest_error("Invalid buffer size. Was stream_out opened?\n");
> - return;
> + goto fail;
> }
>
> pthread_mutex_lock(&state_mutex);
> if (current_state != STATE_STOPPED) {
> haltest_error("Already playing or stream suspended!\n");
> pthread_mutex_unlock(&state_mutex);
> - return;
> + goto fail;
> }
> pthread_mutex_unlock(&state_mutex);
>
> - if (pthread_create(&play_thread, NULL, playback_thread, in) != 0)
> + if (pthread_create(&play_thread, NULL, playback_thread, in) != 0) {
> haltest_error("Cannot create playback thread!\n");
> + goto fail;
> + }
> +
> + return;
> +fail:
> + if (in)
> + fclose(in);
> }
>
> static void stop_p(int argc, const char **argv)
>
This patch is now upstream, thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply
* Re: [PATCH 5/6] android/a2dp: Disconnect headset on IPC failure
From: Luiz Augusto von Dentz @ 2014-02-07 9:58 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZKZGX54FnUPEZWM_4A+5otRHk+wyA-xhppfD8FeZckMjg@mail.gmail.com>
Hi Andrzej,
On Fri, Feb 7, 2014 at 11:45 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Andrzej,
>
> On Thu, Feb 6, 2014 at 7:54 PM, Andrzej Kaczmarek
> <andrzej.kaczmarek@tieto.com> wrote:
>> In case audio IPC is suddenly disconnected (most likely due to crash of
>> mediaserver process) we should disconnect headset since it is no longer
>> associated with valid setup and cannot be used properly.
>> ---
>> android/a2dp.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/android/a2dp.c b/android/a2dp.c
>> index 8eabfeb..f67a593 100644
>> --- a/android/a2dp.c
>> +++ b/android/a2dp.c
>> @@ -1515,6 +1515,7 @@ static gboolean audio_retry_register(void *data)
>>
>> static void audio_disconnected(void *data)
>> {
>> + GSList *l;
>> bool restart;
>>
>> DBG("");
>> @@ -1526,6 +1527,12 @@ static void audio_disconnected(void *data)
>>
>> bt_audio_unregister();
>>
>> + for (l = devices; l; l = g_slist_next(l)) {
>> + struct a2dp_device *dev = l->data;
>> +
>> + avdtp_shutdown(dev->session);
>> + }
>> +
>> if (!restart)
>> return;
>
> If we are unregistering the endpoints properly this should not happen,
> perhaps what is wrong is avdtp_unregister_sep is not aborting existing
> streams properly. Btw we should probably add a unit test if this is
> happening in practice because otherwise the remote won't notice.
I checked the code and actually this should not be a problem since we
drop the stream transport connection it should indicate a unclean
abort as it should be, in the past we had many times this happening
with PA crashing and it seems the headsets react properly to the
stream transport dropping unexpectedly, we can still do abort though.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 5/6] android/a2dp: Disconnect headset on IPC failure
From: Luiz Augusto von Dentz @ 2014-02-07 9:45 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391709250-8047-5-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Thu, Feb 6, 2014 at 7:54 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> In case audio IPC is suddenly disconnected (most likely due to crash of
> mediaserver process) we should disconnect headset since it is no longer
> associated with valid setup and cannot be used properly.
> ---
> android/a2dp.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index 8eabfeb..f67a593 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -1515,6 +1515,7 @@ static gboolean audio_retry_register(void *data)
>
> static void audio_disconnected(void *data)
> {
> + GSList *l;
> bool restart;
>
> DBG("");
> @@ -1526,6 +1527,12 @@ static void audio_disconnected(void *data)
>
> bt_audio_unregister();
>
> + for (l = devices; l; l = g_slist_next(l)) {
> + struct a2dp_device *dev = l->data;
> +
> + avdtp_shutdown(dev->session);
> + }
> +
> if (!restart)
> return;
If we are unregistering the endpoints properly this should not happen,
perhaps what is wrong is avdtp_unregister_sep is not aborting existing
streams properly. Btw we should probably add a unit test if this is
happening in practice because otherwise the remote won't notice.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v3 0/8] Android PAN fixes
From: Luiz Augusto von Dentz @ 2014-02-07 9:37 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391700522-9036-1-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Thu, Feb 6, 2014 at 5:28 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> V3:
> - fixed not bringing bridge if down
> - add forward_delay with ioctl patch
> - other minor bugfixes
>
> V2:
> This is based on patch from Ravi (sent 23.01.2013). Changes include
> patch split and some bugfixes.
>
> Ravi kumar Veeramally (1):
> android/pan: Fix bnep interface name
>
> Szymon Janc (7):
> profiles/network: Use interface name passed to bnep_connadd
> profiles/network: Allow to pass interface name to bnep_new
> android/pan: Move functions up to avoid forward declarations
> android/pan: Fix unregistering NAP bridge
> android/pan: Use ioctl instead of sysfs for setting forward delay
> android/pan: Pass error in nap_remove_bridge
> android/pan: Bring bridge interface down before removing it
>
> android/pan.c | 205 ++++++++++++++++++++++++++----------------
> profiles/network/bnep.c | 10 ++-
> profiles/network/bnep.h | 3 +-
> profiles/network/connection.c | 6 +-
> profiles/network/server.c | 4 +
> 5 files changed, 146 insertions(+), 82 deletions(-)
>
> --
> 1.8.3.2
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH 1/6] android/a2dp: Close AVDTP gracefully
From: Luiz Augusto von Dentz @ 2014-02-07 9:18 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391709250-8047-1-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Thu, Feb 6, 2014 at 7:54 PM, Andrzej Kaczmarek
<andrzej.kaczmarek@tieto.com> wrote:
> When closing AVDTP we should wait for for CLOSE request to complete
> (so stream go to idle state) before disconnecting signalling socket.
> In case CLOSE is rejected, we simply abort stream.
> ---
> android/a2dp.c | 4 +++-
> android/avdtp.c | 21 +++++++++++++++++----
> 2 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index 8cff535..8d6e7bf 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -1166,8 +1166,10 @@ static void sep_close_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
>
> DBG("");
>
> - if (err)
> + if (err) {
> + avdtp_abort(session, stream);
> return;
> + }
>
> setup_remove_by_id(endpoint->id);
> }
> diff --git a/android/avdtp.c b/android/avdtp.c
> index e26d6ec..b9d1992 100644
> --- a/android/avdtp.c
> +++ b/android/avdtp.c
> @@ -398,6 +398,8 @@ struct avdtp {
> struct pending_req *req;
>
> GSList *disconnect;
> +
> + bool shutdown;
> };
>
> static GSList *lseps = NULL;
> @@ -913,6 +915,11 @@ static void avdtp_sep_set_state(struct avdtp *session,
> session->streams = g_slist_remove(session->streams, stream);
> stream_free(stream);
> }
> +
> + if (session->io && session->shutdown && session->streams == NULL) {
> + int sock = g_io_channel_unix_get_fd(session->io);
> + shutdown(sock, SHUT_RDWR);
> + }
> }
>
> static void finalize_discovery(struct avdtp *session, int err)
> @@ -2141,7 +2148,7 @@ gboolean avdtp_remove_disconnect_cb(struct avdtp *session, unsigned int id)
> void avdtp_shutdown(struct avdtp *session)
> {
> GSList *l;
> - int sock;
> + bool closing = false;
>
> if (!session->io)
> return;
> @@ -2149,12 +2156,18 @@ void avdtp_shutdown(struct avdtp *session)
> for (l = session->streams; l; l = g_slist_next(l)) {
> struct avdtp_stream *stream = l->data;
>
> - avdtp_close(session, stream, TRUE);
> + if (avdtp_close(session, stream, TRUE) == 0)
> + closing = true;
You could assign true directly to session->shutdown and return, also
it is probably a good idea to check if the flag is already set and if
it does call avdtp_abort, in fact I think we should call avdtp_abort
not avdtp_close anyway since we are shutting it down there is no point
of given the remote even a chance to reject.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: BISECTED Re: 3.14-mw regression: circular locking dependency (&tty->legacy_mutex){+.+.+.}, at: [<ffffffff81ad6344>] tty_lock_nested+0x44/0xa0
From: Gianluca Anzolin @ 2014-02-07 6:55 UTC (permalink / raw)
To: Sander Eikelenboom
Cc: Marcel Holtmann, Greg Kroah-Hartman, linux-wireless,
linux-bluetooth, linux-serial
In-Reply-To: <754206689.20140207013750@eikelenboom.it>
Hi Sander,
On Fri, Feb 07, 2014 at 01:37:50AM +0100, Sander Eikelenboom wrote:
> Hi Marcel / Gianluca,
>
> Bisection points to this commit:
>
> 4a2fb3ecc7467c775b154813861f25a0ddc11aa0 is the first bad commit
> commit 4a2fb3ecc7467c775b154813861f25a0ddc11aa0
> Author: Gianluca Anzolin <gianluca@sottospazio.it>
> Date: Mon Jan 6 21:23:52 2014 +0100
Thank you for you report. I'm aware of this bug, no need to investigate
further.
This and other bugs are being tackled by Peter Hurley, who knows the tty
code way better than me.
You just have to wait for his patches, I think they will come shortly.
Thank you,
Gianluca
^ permalink raw reply
* Re: possible bug in blueZ 5.8 gatt tool or library
From: Anderson Lizardo @ 2014-02-07 0:55 UTC (permalink / raw)
To: Caleb Reinhold; +Cc: BlueZ development
In-Reply-To: <000001cf238d$a774e310$f65ea930$@lampreynetworks.com>
Hi,
On Thu, Feb 6, 2014 at 6:48 PM, Caleb Reinhold
<creinhold@lampreynetworks.com> wrote:
> It seemed that calling g_attrib_register() in the connection callback might
> be causing the client to start listening for indications and notifications
> too late, but registering right after the gatt_connect() call doesn't seem
> to help. Nor does placing a watch on the GIOChannel inside bt_io_connect(),
> so registering earlier doesn't appear to be the right approach. Do you know
> why we keep missing this initial indication on medium security, and how we
> might fix this issue?
If I remember correctly, the issue is in the kernel: if connect() is
called when security level is medium, the socket only gets POLLOUT
once SMP pairing finishes, and any ATT PDU received during that time
is lost.
Note that it's almost certain that your device is sending the
indication without requiring encryption. Otherwise, it would have sent
a Security Request (which triggers a Pairing Request from the Linux
side) and wait for the encryption to be enabled before sending the
indication. If that was the case, the kernel would deliver the ATT PDU
to gatttool after encryption is enabled and it would work as expected.
PS: Please, as common netiquette, avoid top-posting (i.e. answer
before the original message) and quote only the text that gives
context to your answer.
Best Regards,
--
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox