Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1099619pxb; Thu, 19 Aug 2021 20:30:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWf3M+0Q1LRdWg5x+qgQV69mCbVZSi8M2qJ6HXIwJDtT3e5Ew7bQL1gH1YbCiNRlx89xHu X-Received: by 2002:a05:6402:50:: with SMTP id f16mr19577545edu.346.1629430211915; Thu, 19 Aug 2021 20:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629430211; cv=none; d=google.com; s=arc-20160816; b=JeWA/KjVD8e/9BS11YH90TtNqtGrPg7ZFhHAOP3tlRtAFp41oLUcQpGoypCkG4qgXj s/tUXK27rxHCMUt9XuDxe1b8nQvvBCFIoyDNppp/mE1g81bOmi/cyqHiuR0+rQ7Vhg+L mWBuOeDj6rD4Loo1bz+gpdhw73Di2O/oFaj5gabCVcg6Yplb8tY4lyPtG8VcdiMIae7V R65mQnERaILUrRejZkhEtCdZf+Zf/3ea2qq+J542npbPwuiwJcyRqD6ihbQarwPR3JBp U+2dILSbcC/kUHBnQVv5ID2J/xKWPGxzJfZr14rH4Qh9GVJG7hK9f1Vn2QhV1sQ1WGkm dwhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=PPVWx1bdM2r6k6HCDP6FMLkldqZlCb3M27xZWJhcudQ=; b=DK+Uzx1LHFrK1LI3Pr3fcGxauCt+MxYeNrmVggEy89bL3jIC3Cpaqu0w32i87JLW3D 3oAJ4SMEcqmFeFxTe3bewXJ356BYvW5X0tcX0HlLu8LLMVjtoP3OxbtqimS/w3i7bdS7 Su45E059BpZgsM65/6OzlFy2Tpr/tfLdRmJ7wD7+0EbpE+Bldqmg5p6Rkotllo4jpxl5 7g8lnFMYLsnOktgdBvYAKD+Wkkog81DtQg80R/hR0sYL2h5PR2+M2GOEJvXdbi5SB5Tm qmsAwjsb6Acc7et0BH6HNbFvW2olq0mqa0dva1aD+aK6pBhPLuzDiHDW+sxsQy+ym/+o EfHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gJN5GOKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id br21si5039300ejb.258.2021.08.19.20.29.47; Thu, 19 Aug 2021 20:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gJN5GOKf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238135AbhHTD3F (ORCPT + 99 others); Thu, 19 Aug 2021 23:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237998AbhHTD3E (ORCPT ); Thu, 19 Aug 2021 23:29:04 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 809ABC061757 for ; Thu, 19 Aug 2021 20:28:27 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k4-20020a25b284000000b0059844c88867so1699731ybj.6 for ; Thu, 19 Aug 2021 20:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=PPVWx1bdM2r6k6HCDP6FMLkldqZlCb3M27xZWJhcudQ=; b=gJN5GOKfS246dQiqnCnxZvxuC/yXOqjmoGhZvQVQ2BLGma8RRmBU3gem6jqeHf+y4z I/L1/iYKjkKHs3cQflrmo/FHJ9ltxCadW1advCtd+c0D0MO6WJiYxV2LjQG6kQoJwOuT a5QEMxVkRWM/WDwb4JRs48V0egXca37UP7kdkA3VVU8jxtyw9ApSKkTAGX7G7XdO1Fmw nOcFn7JwJbENq4wX3k6NV+rqoZyYqJdwU+kisrl8NmfDj9WaMsgCmC7G55hUQZZW8xEn Jr5jt2xH84vG8N5ZXfw5J+6Nd/Z+1lMtP8ZbTqWVwWRVMtRUmbtT4nzDctfNmKFXh45l xzAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=PPVWx1bdM2r6k6HCDP6FMLkldqZlCb3M27xZWJhcudQ=; b=FR0o+A9Uoir6QjaXnks3Ah7gTPHg7wBjN/IkVKisSj9wjZYkEdpVhji43NKASSWtKO w4u3eTECJNgJZ4OhrvYSuOoQM/PTIAzyIVIOs7UIAPEyab4pzUibmxMa7Q0RGzyB6x9+ RGvdfDJRjgKWIEluzN++lgzWYpeI4QcdiWcjLblPbK4M8XI28A6zNg/K3HRZkWpwn2H7 5G5Iw6vqRvlkwVIyNReZIUBxHPkLX4gA+duCyPPUT7jZFuiU2L5pu48gU+TrgBusNktK cQhi9U4qPtejTeZXWVzhBqCmX64KAwaBEbqZKi8wzIpiT7fE2omz2XyJh1ifoDAemuTy +ccA== X-Gm-Message-State: AOAM531450oxEHXacaCE/SNdEdNoJQ7YDdEIOoAsYoK6PYt8p05ns2vE 43sLfYWVLSzOlUFWxCtwfVCLWH16XiyMvA== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:f6f9:890a:ebc2:929c]) (user=mmandlik job=sendgmr) by 2002:a25:cec6:: with SMTP id x189mr21255905ybe.89.1629430106592; Thu, 19 Aug 2021 20:28:26 -0700 (PDT) Date: Thu, 19 Aug 2021 20:28:22 -0700 Message-Id: <20210819202819.v5.1.Id9bc5434114de07512661f002cdc0ada8b3d6d02@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog Subject: [PATCH v5] Bluetooth: Keep MSFT ext info throughout a hci_dev's life cycle From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: Archie Pusaka , linux-bluetooth@vger.kernel.org, Alain Michaud , chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi , Miao-chen Chou , Manish Mandlik , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miao-chen Chou 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 Reviewed-by: Abhishek Pandit-Subedi Reviewed-by: Archie Pusaka Reviewed-by: Alain Michaud Signed-off-by: Manish Mandlik --- 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