Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp327391ioo; Thu, 26 May 2022 04:45:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK5odPwBM2NnqaB0hI5RWH753zn3mkk9yBsHvVx6dN0LgeG1OKxMddbwTtZ3LBk/cuQwRQ X-Received: by 2002:aa7:d9cf:0:b0:42b:db5e:ec24 with SMTP id v15-20020aa7d9cf000000b0042bdb5eec24mr2625872eds.388.1653565527901; Thu, 26 May 2022 04:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653565527; cv=none; d=google.com; s=arc-20160816; b=c3Iq1FQ362dRXkP07aWeWlZm366W8lVTrlN1I1MzqjBjm9AzVrTyRTIRVkogLr8XNw N046GvIs8uJfhF2G/wVMy3xKGGdQuVaq+WV/zbyPedWiuwxbCfua9AvvCid2Mp90MHwn /vjDKP5dTgovLs0VWTAc6EnMCMLXQWlrC3eqEUBPa/UBYzoc6Iwy5JCEqNatMWPojyVV jLn+Rky7ZeVEF0mBlvRJsyrr4i2ERr6KbaeDS6YopoYBk3Jkg2ZZidejMUTx/WQKo7Di Jw0Y5qXgJYpgtj/LRwTlSosdobaZdtKgjTtuWiRWRAFza/0BWXmNK4bUPIowrBvf35dU nLfg== 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=wRyXjUnbuN8AArPJcHoUjYeWkLPL7LreNSYdLAK0u9k=; b=daKsUtM6/mA24CvsP6iKSPtBQmtpcwFBYLypa3Kuj6Kl2naTbKXgtpxmKPuZ+xCiaW v3lZZgf8UfIah0xjRYHWYwap16DmSZyS8szKkjTGwjvRjV/UYNE4NCDXjGvHqdy3ucZB dRj4zSu6p/3doYdz0kMOwQKSMFVwU0WoHRv/AFT2Eritu8B5QX6J1UnRffDJVkSx9esW UguZORO9zOr9p8J8vBbF9ts7Dz/7k1XtJnSOpIeQLh1PrJrRTAAZxs1PiYup4Xqgfep3 U0R7YcssF6AudujYUAN+n3El11CIRO/fE19qvn5wbNkn0j+WcA1RKnPckCe+8Pkget9W tgYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B0xy+3RU; 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 s4-20020a17090699c400b006f42f253aabsi1281659ejn.514.2022.05.26.04.45.02; Thu, 26 May 2022 04:45:27 -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=B0xy+3RU; 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 S1347067AbiEZLWc (ORCPT + 99 others); Thu, 26 May 2022 07:22:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347081AbiEZLWU (ORCPT ); Thu, 26 May 2022 07:22:20 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E9C112F for ; Thu, 26 May 2022 04:22:02 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id h186so1097536pgc.3 for ; Thu, 26 May 2022 04:22:02 -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=wRyXjUnbuN8AArPJcHoUjYeWkLPL7LreNSYdLAK0u9k=; b=B0xy+3RUGPdeJE34oJ+ShJjF1I809kPfObCH500XadV1bePmTTJKBRbAD2ieBC+ysO 2DT6QUCgLMqGimKyXkICXmUcppD2Ndob6ILn9uZGQyL1ZIT9blB4p4eiiaosTyo08Wwo DFzott6m4wObq8TjrTeBfoL9XLRrNnTPpZg8Y= 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=wRyXjUnbuN8AArPJcHoUjYeWkLPL7LreNSYdLAK0u9k=; b=Iu8QY6jdNDljkhAG+CpiONATO3TwRZTlT1LubvDRu5Fc+EA9jkqxMQPH6SL+NlYEal oP8ostmRjTkG9nsbvnOvji139XlE7B/iZL/oYJimNCclEaxkITanvSSgis/y+T5r/gg9 E1DTuEJNmuMf7yinTPSxwgIxL8HLS06+d3GBrq9EoYBuFzSXdzZvIybfEOIiyUi+8pF6 yY0w1w0V0bi3RXfe4S7VDBBMmSONkDYREV+hETJy5Vz3mJPBaO5q4Fl5+GSjk0A4vwY3 zwPm3aK8hod0wvSL0tbDdrwXx69E2IGpqjCu9d23Qnr66wHnTUfNOl2RlQEJoPvcj3PE dr8Q== X-Gm-Message-State: AOAM531oWVpaq/eiJbkVQAwg9Oz8wsOVSNkY8rWf3BTFf/DbPLuCzliH s/wNln59pNK+9sv38Gb0blaz0Btq+V7TRA== X-Received: by 2002:a63:82c7:0:b0:3f9:e153:6a54 with SMTP id w190-20020a6382c7000000b003f9e1536a54mr23972141pgd.409.1653564121453; Thu, 26 May 2022 04:22:01 -0700 (PDT) Received: from localhost (174.71.80.34.bc.googleusercontent.com. [34.80.71.174]) by smtp.gmail.com with UTF8SMTPSA id 2-20020a170902e9c200b001614cd997a8sm1230287plk.236.2022.05.26.04.21.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 May 2022 04:22:01 -0700 (PDT) From: Joseph Hwang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com, pali@kernel.org Cc: chromeos-bluetooth-upstreaming@chromium.org, josephsih@google.com, 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 v6 5/5] Bluetooth: let HCI_QUALITY_REPORT persist over adapter power cycle Date: Thu, 26 May 2022 19:21:34 +0800 Message-Id: <20220526112135.2486883-3-josephsih@chromium.org> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220526112135.2486883-1-josephsih@chromium.org> References: <20220526112135.2486883-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 --- (no changes since v5) 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