Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3715484ioo; Wed, 25 May 2022 06:47:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrLr39wepAjeWSl1B6rHjdmR6GVsfzrMxxw4iA/HR3Z181PYefLcDXAbRf4Qq2fRhpO8VZ X-Received: by 2002:a17:90b:17c1:b0:1e0:2434:8475 with SMTP id me1-20020a17090b17c100b001e024348475mr10590465pjb.42.1653486474651; Wed, 25 May 2022 06:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653486474; cv=none; d=google.com; s=arc-20160816; b=BewgLuW1SHWDt5WXxP4dfJABDtXbsmJ/p7z0fQLpgcV/R4WwisUsmvXqj2c/+J1420 FXyL9aiVpVBnpazqUtI0MgiakzHyS0M+e4lKw6QBRPuphuihFGU4jbCnPcvdHNPPPcPn Oowd45uFBsPw7uygfvfqgKJF7TkI+Y7oyU5C6MZupQDpX5mobiJWU3mJ4hiwVcCWVtlj ihmYtHG3qyK5rt8ps8q2y7xly2RIyL1RIYTVbZZuDGR8AeCUS0EyPaEbHU0bIN7Xq7H9 y+MB1xo8zmiNgRSrbSI2iSH3coENE1y2AuetsiFGbkh2iw2EZWTVm7Nk67cVoFCZPvIE t1Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nfd8GuZibV93hv9RFZEH/5/7YZjQFYEI7fvZmGryy4s=; b=xrs/iK3Mr7eluQGQU8kr9GQSYLVgmb5HKo5V4FCN5n4MjAE/Zy8y6SQ1l9jK6hltg5 xcYu4reJdzQdoqC/rV9DfMzxK1b4jTWMTHvVyBUW+6BlZNdwtDRfkE1+VdP78Wl0hBIt 4Y7DxGqh5Kp/SOVsmpipj+6psjY5KlwgGm0Ren8b0YSe+obEROSO61YjGQT7bJEuLQ+k HyP7R/TCK6iBpoenoOGsh9t5x2DXnXkBG5TDnaDu/V2CfMsBQZq9sqLUMYisyoCIdVE2 +ZyXRs02xNjPD47k5Qf+0WNLJZmPLRiiPnvJ1KrW2PmmAgJVo/C1StG4VaawAhM6EcJK nB0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TfAvOXi/"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a63de0b000000b003c1977e2008si17516461pgg.821.2022.05.25.06.47.24; Wed, 25 May 2022 06:47:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TfAvOXi/"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242674AbiEYKqd (ORCPT + 99 others); Wed, 25 May 2022 06:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242566AbiEYKq1 (ORCPT ); Wed, 25 May 2022 06:46:27 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58100D9 for ; Wed, 25 May 2022 03:46:09 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id q4so18212504plr.11 for ; Wed, 25 May 2022 03:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nfd8GuZibV93hv9RFZEH/5/7YZjQFYEI7fvZmGryy4s=; b=TfAvOXi/gD7eAIll7QchzF7Eta8mzPE79DQuQGqufw9MAXxEiSBkUhihxhjy4hVKku Ww6UrrdG8O2dEu71e4mxTyAq68P3xddG05R270g4Jq+MiOX6Ty6F43Xii72x4LZkgUS4 QfN498OGx3DN3QY0WPRX0i9eYTrnyKFkAVBVo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nfd8GuZibV93hv9RFZEH/5/7YZjQFYEI7fvZmGryy4s=; b=Xo9Jr0mAnOCBlItSPBqxAMGW6cgu+EJYU7INgxHPef+6DvbA02CmzftR+485gEPG9Z 0zFKG8XbxMhA7Z8FNh3IGuh7Z9wz531DLjHkRUakB2mvzp/N/hkCPkvJXwOK07LZGmbc 9ILIXr/Hjdi3rIPPFCuY9P7549OnjDaKFEcbrP0KSPX4zLpthteWyjWnLqwxL1lkUMru cAWEfvSfOAfYvJs+gIRLFvVV+lF3Khnv8vJCNPrtJSm1saN9OxrOiZ9Ly3eZTgDQ+/rR oBIWlZ2MPd9zpj5vudlFYIuTO8Cr2MPIKJkQhEsAeIw+1pUKxvSDzJPHh38Wy2TD3l16 Sk7A== X-Gm-Message-State: AOAM532AxCLS52rIhE4101AmaBzg5iCWtQ8ifGDsPZwgWDdtVansqq1f 8s8/MkEttqz2dE4th7KfJkKqCmwkRUac7w== X-Received: by 2002:a17:90b:4f81:b0:1e0:7643:36ae with SMTP id qe1-20020a17090b4f8100b001e0764336aemr8297282pjb.124.1653475568108; Wed, 25 May 2022 03:46:08 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id a21-20020a637055000000b003c14af505fesm8151397pgn.22.2022.05.25.03.46.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 03:46:07 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: josephsih@google.com, chromeos-bluetooth-upstreaming@chromium.org, Joseph Hwang , Archie Pusaka , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v5 5/5] Bluetooth: let HCI_QUALITY_REPORT persist over adapter power cycle Date: Wed, 25 May 2022 18:45:45 +0800 Message-Id: <20220525104545.2314653-3-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220525104545.2314653-1-josephsih@chromium.org> References: <20220525104545.2314653-1-josephsih@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The quality report specifications, including AOSP Bluetooth Quality Report and Intel Telemetry Event, do not define what happen when the adapter is turned off and then on. To be consistent among different specifications and vendors, the quality report feature is turned off when the adapter is powered off and is turned on when the adapter is powered on if the feature has been on before power cycle. Signed-off-by: Joseph Hwang Reviewed-by: Archie Pusaka --- Changes in v5: - This is a new patch in this series changes version. include/net/bluetooth/hci_core.h | 1 - net/bluetooth/hci_sync.c | 35 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9e48d606591e..5788350efa68 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -807,7 +807,6 @@ extern struct mutex hci_cb_list_lock; hci_dev_clear_flag(hdev, HCI_LE_ADV); \ hci_dev_clear_flag(hdev, HCI_LL_RPA_RESOLUTION);\ hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); \ - hci_dev_clear_flag(hdev, HCI_QUALITY_REPORT); \ } while (0) #define hci_dev_le_state_simultaneous(hdev) \ diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index a6ada9dcede5..12a18d046bb6 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -3849,6 +3849,31 @@ static const struct { "advertised, but not supported.") }; +static void suspend_resume_quality_report(struct hci_dev *hdev, bool enable) +{ + int err; + + /* Suspend and resume quality report only when the feature has + * already been enabled. The HCI_QUALITY_REPORT flag, as an indicator + * whether to re-enable the feature after resume, is not changed by + * suspend/resume. + */ + if (!hci_dev_test_flag(hdev, HCI_QUALITY_REPORT)) + return; + + if (hdev->set_quality_report) + err = hdev->set_quality_report(hdev, enable); + else + err = aosp_set_quality_report(hdev, enable); + + if (err) + bt_dev_err(hdev, "%s quality report error %d", + enable ? "resume" : "suspend", err); + else + bt_dev_info(hdev, "%s quality report", + enable ? "resume" : "suspend"); +} + int hci_dev_open_sync(struct hci_dev *hdev) { int ret = 0; @@ -4013,6 +4038,7 @@ int hci_dev_open_sync(struct hci_dev *hdev) if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { msft_do_open(hdev); aosp_do_open(hdev); + suspend_resume_quality_report(hdev, true); } clear_bit(HCI_INIT, &hdev->flags); @@ -4095,6 +4121,14 @@ int hci_dev_close_sync(struct hci_dev *hdev) hci_request_cancel_all(hdev); + /* Disable quality report and close aosp before shutdown() + * is called. Otherwise, some chips may panic. + */ + if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { + suspend_resume_quality_report(hdev, false); + aosp_do_close(hdev); + } + if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) && !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && test_bit(HCI_UP, &hdev->flags)) { @@ -4158,7 +4192,6 @@ int hci_dev_close_sync(struct hci_dev *hdev) hci_sock_dev_event(hdev, HCI_DEV_DOWN); if (!hci_dev_test_flag(hdev, HCI_USER_CHANNEL)) { - aosp_do_close(hdev); msft_do_close(hdev); } -- 2.36.1.124.g0e6072fb45-goog