All of lore.kernel.org
 help / color / mirror / Atom feed
From: Koba Ko <koba.ko@canonical.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, apusaka@google.com
Subject: [PATCH] Bluetooth: msft: add a bluetooth parameter, msft_enable
Date: Thu, 12 Aug 2021 12:23:05 +0800	[thread overview]
Message-ID: <20210812042305.277642-1-koba.ko@canonical.com> (raw)

With Intel AC9560, follow this scenario and can't turn on bt since.
1. turn off BT
2. then suspend&resume multiple times
3. turn on BT

Get this error message after turn on bt.
[ 877.194032] Bluetooth: hci0: urb 0000000061b9a002 failed to resubmit (113)
[ 886.941327] Bluetooth: hci0: Failed to read MSFT supported features (-110)

Remove msft from compilation would be helpful.
Turn off msft would be also helpful.

Because msft is enabled as default and can't turn off without
compliation,
Introduce a bluetooth parameter, msft_enable, to control.

Signed-off-by: Koba Ko <koba.ko@canonical.com>
---
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_core.c         | 16 ++++++++++++++++
 net/bluetooth/msft.c             | 30 +++++++++++++++++++++++++++++-
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index a7d06d7da602..002753db936a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1229,6 +1229,7 @@ static inline void *hci_get_priv(struct hci_dev *hdev)
 	return (char *)hdev + sizeof(*hdev);
 }
 
+void hci_set_msft(bool enable);
 struct hci_dev *hci_dev_get(int index);
 struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src, u8 src_type);
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cb2e9e513907..9e1bdaea20a8 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1045,6 +1045,22 @@ static int hci_linkpol_req(struct hci_request *req, unsigned long opt)
 	return 0;
 }
 
+void hci_set_msft(bool enable)
+{
+	struct hci_dev *hdev = NULL, *d;
+
+	read_lock(&hci_dev_list_lock);
+	list_for_each_entry(d, &hci_dev_list, list) {
+		hdev = hci_dev_hold(d);
+		if (enable)
+			msft_do_open(hdev);
+		else
+			msft_do_close(hdev);
+		hci_dev_put(hdev);
+	}
+	read_unlock(&hci_dev_list_lock);
+}
+
 /* Get HCI device by index.
  * Device is held on return. */
 struct hci_dev *hci_dev_get(int index)
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index b4bfae41e8a5..0bb50ee11bf8 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -97,6 +97,34 @@ struct msft_data {
 	__u8 filter_enabled;
 };
 
+static bool msft_enable = true;
+
+static int msft_set_enable(const char *s, const struct kernel_param *kp)
+{
+	bool do_enable;
+	int ret;
+
+	if (!s)
+		return 0;
+
+	ret = strtobool(s, &do_enable);
+	if (ret || msft_enable == do_enable)
+		return ret;
+
+	hci_set_msft(do_enable);
+
+	msft_enable = do_enable;
+
+	return ret;
+}
+
+static const struct kernel_param_ops msft_enable_ops = {
+	.set = msft_set_enable,
+	.get = param_get_bool,
+};
+
+module_param_cb(msft_enable, &msft_enable_ops, &msft_enable, 0644);
+
 static int __msft_add_monitor_pattern(struct hci_dev *hdev,
 				      struct adv_monitor *monitor);
 
@@ -186,7 +214,7 @@ void msft_do_open(struct hci_dev *hdev)
 {
 	struct msft_data *msft;
 
-	if (hdev->msft_opcode == HCI_OP_NOP)
+	if (!msft_enable || hdev->msft_opcode == HCI_OP_NOP)
 		return;
 
 	bt_dev_dbg(hdev, "Initialize MSFT extension");
-- 
2.25.1


             reply	other threads:[~2021-08-12  4:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12  4:23 Koba Ko [this message]
2021-08-12  5:14 ` Bluetooth: msft: add a bluetooth parameter, msft_enable bluez.test.bot
2021-08-12  5:29 ` [PATCH] " Marcel Holtmann
2021-08-12  5:37   ` Koba Ko
2021-08-12  6:00     ` Koba Ko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210812042305.277642-1-koba.ko@canonical.com \
    --to=koba.ko@canonical.com \
    --cc=apusaka@google.com \
    --cc=davem@davemloft.net \
    --cc=johan.hedberg@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.