From: Manish Mandlik <mmandlik@google.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: Archie Pusaka <apusaka@chromium.org>,
linux-bluetooth@vger.kernel.org,
Alain Michaud <alainm@chromium.org>,
chromeos-bluetooth-upstreaming@chromium.org,
Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
Miao-chen Chou <mcchou@chromium.org>,
Manish Mandlik <mmandlik@google.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v5] Bluetooth: Keep MSFT ext info throughout a hci_dev's life cycle
Date: Thu, 19 Aug 2021 20:28:22 -0700 [thread overview]
Message-ID: <20210819202819.v5.1.Id9bc5434114de07512661f002cdc0ada8b3d6d02@changeid> (raw)
From: Miao-chen Chou <mcchou@chromium.org>
This moves msft_do_close() from hci_dev_do_close() to
hci_unregister_dev() to avoid clearing MSFT extension info. This also
re-reads MSFT info upon every msft_do_open() even if MSFT extension has
been initialized.
The following test steps were performed.
(1) boot the test device and verify the MSFT support debug log in syslog
(2) restart bluetoothd and verify msft_do_close() doesn't get invoked
and msft_do_open re-reads the MSFT support.
Signed-off-by: Miao-chen Chou <mcchou@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Archie Pusaka <apusaka@chromium.org>
Reviewed-by: Alain Michaud <alainm@chromium.org>
Signed-off-by: Manish Mandlik <mmandlik@google.com>
---
Changes in v5:
- Rebase on ToT and remove extra blank line
Changes in v4:
- Re-read the MSFT data instead of skipping if it's initiated already
Changes in v3:
- Remove the accepted commits from the series
net/bluetooth/hci_core.c | 3 ++-
net/bluetooth/msft.c | 20 +++++++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index fb296478b86e..681c6dabb550 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1798,7 +1798,6 @@ int hci_dev_do_close(struct hci_dev *hdev)
hci_sock_dev_event(hdev, HCI_DEV_DOWN);
aosp_do_close(hdev);
- msft_do_close(hdev);
if (hdev->flush)
hdev->flush(hdev);
@@ -4026,6 +4025,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
cancel_work_sync(&hdev->suspend_prepare);
}
+ msft_do_close(hdev);
+
hci_dev_do_close(hdev);
if (!test_bit(HCI_INIT, &hdev->flags) &&
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index b4bfae41e8a5..c2568e93598a 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -184,16 +184,30 @@ static void reregister_monitor_on_restart(struct hci_dev *hdev, int handle)
void msft_do_open(struct hci_dev *hdev)
{
- struct msft_data *msft;
+ struct msft_data *msft = NULL;
if (hdev->msft_opcode == HCI_OP_NOP)
return;
bt_dev_dbg(hdev, "Initialize MSFT extension");
- msft = kzalloc(sizeof(*msft), GFP_KERNEL);
- if (!msft)
+ /* If MSFT data exists, reset its members */
+ if (hdev->msft_data) {
+ msft = hdev->msft_data;
+ hdev->msft_data = NULL;
+
+ msft->features = 0;
+ kfree(msft->evt_prefix);
+ msft->evt_prefix = NULL;
+ msft->evt_prefix_len = 0;
+ } else {
+ msft = kzalloc(sizeof(*msft), GFP_KERNEL);
+ }
+
+ if (!msft) {
+ bt_dev_err(hdev, "Failed to init MSFT extension");
return;
+ }
if (!read_supported_features(hdev, msft)) {
kfree(msft);
--
2.33.0.rc2.250.ged5fa647cd-goog
next reply other threads:[~2021-08-20 3:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 3:28 Manish Mandlik [this message]
2021-08-20 4:11 ` [v5] Bluetooth: Keep MSFT ext info throughout a hci_dev's life cycle bluez.test.bot
2021-08-30 15:02 ` [PATCH v5] " Marcel Holtmann
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=20210819202819.v5.1.Id9bc5434114de07512661f002cdc0ada8b3d6d02@changeid \
--to=mmandlik@google.com \
--cc=abhishekpandit@chromium.org \
--cc=alainm@chromium.org \
--cc=apusaka@chromium.org \
--cc=chromeos-bluetooth-upstreaming@chromium.org \
--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=mcchou@chromium.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.