From patchwork Fri Sep 18 03:11:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yun-hao Chung X-Patchwork-Id: 260672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94C86C43464 for ; Fri, 18 Sep 2020 03:12:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 307F5235F8 for ; Fri, 18 Sep 2020 03:12:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="lPnbMx9M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726990AbgIRDMg (ORCPT ); Thu, 17 Sep 2020 23:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730713AbgIRDMU (ORCPT ); Thu, 17 Sep 2020 23:12:20 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36F3EC061788 for ; Thu, 17 Sep 2020 20:12:20 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id o11so2323010pjj.9 for ; Thu, 17 Sep 2020 20:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=NxYLZaP4aGvAu+/UZ2/LCTJAGtRN+euo/YJvY78SnJI=; b=lPnbMx9MR7LP0g8yYqS8XX8PwdhoCbJLqS3Z0Z0JtuxwszJ9u0TKgULzYiNZpjdWBD 1pFWEgRbhds1BOQrRuitu8mMEDBNDuwU5LUhPPic6Zb0Oe8Cu9IUv4vX3N4HXaUTsqWN E3tLAgY5ThRFLx8JC8AtkuxBczzVFBpbeZu2koExJJHkSA5JVsuSRZSxuttC7ewNIl7W Yj4EwfyVNTayTJoqCUaNoujn8oMQLgP+QxsxmxT8TnmsrLc3wbbV03nlr+a1oxwen8aE Q7X003JemibbmOX6Tn5rBhnHC1uMggGUYmpZwFiCSGp9jwbAzfgo7EOJs9om+YsJ684o FBnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=NxYLZaP4aGvAu+/UZ2/LCTJAGtRN+euo/YJvY78SnJI=; b=uaPUm1rjDPosMzNR0Up/5L/zLOVosyF99QmeNB+540RnsmdDQNDrb01tbju08SUHCO X58Y8GQugktR4PLr4xRPFF3nIjUXwa9//nngBLmpbafd8oTycPtUig0i9j8BLKyWERIJ TVXJ6qB5w0/+WQ288RraWahYXkowX3AIVEgCWSVoNZotiZbnPlWFvnuwhAZkgZaWpl2Z 5R6tXA+jV+SiH4UF3OWq/WCusGzxYQuBl70AyWcz8zAvvd1hdztsrJv2XMNLbYk94H1I Ba9aeOc4l4iU4q6zwRpIanPBsKcdGqGh6VMXc6ajcOsCqKMkuQF8WIOUzA0BQGrY0sv1 +ktw== X-Gm-Message-State: AOAM533sMxYh+UjxxDd6SYt/23iRw5tvyVx0/VUlFNjOkef8bYTIkV9x /yfv/lgi9XVatvj5kMYGVcMHQfhPqjxfg7VSZg== X-Google-Smtp-Source: ABdhPJx6kM5DLLFGf2usi1qL12z1S/m8Hsz6v1BbQkAwPJVD0ivhgJmBq+H071e/KejErTX27f7V9MxscFhrpmdfXg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:aa7:8583:0:b029:13f:7096:5eb with SMTP id w3-20020aa785830000b029013f709605ebmr30016944pfn.0.1600398739505; Thu, 17 Sep 2020 20:12:19 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:48 +0800 Message-Id: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 1/6] Bluetooth: Update Adv monitor count upon removal From: Howard Chung To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Miao-chen Chou This fixes the count of Adv monitor upon monitor removal. The following test was performed. - Start two btmgmt consoles, issue a btmgmt advmon-remove command on one console and observe a MGMT_EV_ADV_MONITOR_REMOVED event on the other. Signed-off-by: Miao-chen Chou Signed-off-by: Howard Chung Reviewed-by: Alain Michaud --- Changes in v3: - Remove 'Bluez' prefix Changes in v2: - delete 'case 0x001c' in mgmt_config.c net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a2645a833013..f30a1f5950e15 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3061,6 +3061,7 @@ static int free_adv_monitor(int id, void *ptr, void *data) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; return 0; } @@ -3077,6 +3078,7 @@ int hci_remove_adv_monitor(struct hci_dev *hdev, u16 handle) idr_remove(&hdev->adv_monitors_idr, monitor->handle); hci_free_adv_monitor(monitor); + hdev->adv_monitors_cnt--; } else { /* Remove all monitors if handle is 0. */ idr_for_each(&hdev->adv_monitors_idr, &free_adv_monitor, hdev); From patchwork Fri Sep 18 03:11:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yun-hao Chung X-Patchwork-Id: 260671 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DD67C43465 for ; Fri, 18 Sep 2020 03:12:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CED9721582 for ; Fri, 18 Sep 2020 03:12:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="tzX8w74F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730293AbgIRDMe (ORCPT ); Thu, 17 Sep 2020 23:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbgIRDMY (ORCPT ); Thu, 17 Sep 2020 23:12:24 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6075C06178A for ; Thu, 17 Sep 2020 20:12:23 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id m186so2713835qkf.12 for ; Thu, 17 Sep 2020 20:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=2XmRDQUdgiUCXLjgBSHndxfu/U3AL11i4Ub5lRoe7R0=; b=tzX8w74Fl69bkT1fuRekk3Yej9sz1p+sVINXDr737cRNWeMl+XLBVOK2a2H0/gbs18 Uteg1+HYcXiSdUfhbnQicvFRotx4pj43Yc4fW36tr8Heiz4fRD8sQpYKYSvllygVcd0A xkuT05qTA+JmIK5f05enmUZ28D5g3H9MHYFzxpZpBaDdUSpx7BYg+gM4Yw3d88FLJ1ms +Vx9hoczHxmCaA1IKAcuAWej+DHGVqZm/4w+QsYhlF6k3BQ5dr8m3Yfy+IR0h4u/6xkd dq4v9k/P82oknrNxUTpZMex+uiAB60T391HA8RB0MOdr02Im6N06aKG0sZmsi2N5CYBz 9SLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2XmRDQUdgiUCXLjgBSHndxfu/U3AL11i4Ub5lRoe7R0=; b=G1okv0Ht6qbeu0a16qwe+FceFCyNxL/VFJigj6JXKy5JXAooXXPGZxqE54Twk2ssEn OGVko4OrW+KHJ7goiJG+EPDWnmPIOiUaMN2tPsw+SiWgACdFb2vqap3GWQupUGBd4T3L inFca0/iwAAWmuSKEmMb6XoTPuJJ9UNy5TxcXkVsichhokTVIfNKsd8UQO9SVXu7t81N 2MLuGTyWVmT2f/WuODP9uHUxCZQvyGsItdQ2Nhnulb1LJBOnNmwL6j4Zbzy49Evg75Q1 r1H2xYuvHegplaGNQik6D0PiJHtShWo1jC4+EZJ4cPRi7OiWJHirabLg/pS2T/qqlayv 68NA== X-Gm-Message-State: AOAM531WMNM75x0PQlfc7yPV+8aoKRLTiVaa9Q0TEJzapv2luFq2yKmC PEhVeoxWk6taDVHWBEYe1oZBJTzCmtwUm1lSgw== X-Google-Smtp-Source: ABdhPJwmWJFJNTTBFBXGPrIZyuSqnx1dWqO6oAbGMDrw5KopjYBA2KwiHRZ355u4CWsVx/4UV2f90s26M6BxkZjhrg== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:ad4:458f:: with SMTP id x15mr15602557qvu.33.1600398742980; Thu, 17 Sep 2020 20:12:22 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:49 +0800 In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200918111110.v3.2.I8aafface41460f81241717da0498419a533bd165@changeid> Mime-Version: 1.0 References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 2/6] Bluetooth: Set scan parameters for ADV Monitor From: Howard Chung To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Set scan parameters when there is at least one Advertisement monitor. Signed-off-by: Howard Chung Reviewed-by: Alain Michaud Reviewed-by: Manish Mandlik Reviewed-by: Abhishek Pandit-Subedi Reviewed-by: Miao-chen Chou --- (no changes since v1) net/bluetooth/hci_request.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 413e3a5aabf54..d2b06f5c93804 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1027,6 +1027,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) } else if (hci_is_le_conn_scanning(hdev)) { window = hdev->le_scan_window_connect; interval = hdev->le_scan_int_connect; + } else if (hci_is_adv_monitoring(hdev)) { + window = hdev->le_scan_window_adv_monitor; + interval = hdev->le_scan_int_adv_monitor; } else { window = hdev->le_scan_window; interval = hdev->le_scan_interval; From patchwork Fri Sep 18 03:11:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yun-hao Chung X-Patchwork-Id: 260670 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2EB0C43466 for ; Fri, 18 Sep 2020 03:13:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70C3420678 for ; Fri, 18 Sep 2020 03:13:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="FWdnEbfo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727321AbgIRDM5 (ORCPT ); Thu, 17 Sep 2020 23:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727024AbgIRDMc (ORCPT ); Thu, 17 Sep 2020 23:12:32 -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 1A235C06174A for ; Thu, 17 Sep 2020 20:12:32 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k3so4030792ybk.16 for ; Thu, 17 Sep 2020 20:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=Yq3AQHq0oby0gIEHvauwatHEbFOs+SQiwBq1B7FgTKo=; b=FWdnEbfoGFaKXpZHbnLC++79ZWY3a7aRIGxG2mH67sZoVYWZUYC4LcK2SJ2r8mq1IJ VN2fUkJ7EQnVl0TGDlhk3EWmIVC8FNtBt131mk65HSsyaCqmFj2XZ3dx837bKYLSTtTp KtiAl342ruTWqRQ7YjBWAyaixJN58jS/f+4kUhS9myHZl3p8TUEXUSbz/sbUF+agMq4K AAnNYh38Oh55uQbs3TtQ8IPZ8BVtJXVDqpmGk4u/rYTKeSVCH75gVy+RagaTyIrGQjPV ZQEzNtygW+Md++DGU88mU1D+gYeda6um7diigCHcmmmMcm3ee2Ge+VsOqtQCdC+PnjvA d8xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Yq3AQHq0oby0gIEHvauwatHEbFOs+SQiwBq1B7FgTKo=; b=HwVlVoUjkbZVIAWLb5toazT8LNZfWkqiu8lqYH7ifcD1hglixKMr/Q/QLmcoakLa3u l8+zHtafLxWeNOIzDJHmHal2wm4GpqdiY6OOP8Xf/tBOlY6hk/gS5oumX0F6wqDIetpO I3HORKMx69AR84uiB3SM3zRs7JYHsncSjV0sE4O+jAWWiKP6Qt2nuCtaXIdzwJSVjcc4 kZLUdINpZ3R31NGKG0B9A872FZlhPeZy+9Jz/noCnHTcSM0nBn8oPFzu6LbuCprjoPUp roIoIycVflixPKlOj6KkGvzKkUBum6jlHjQ1g3BE0axqCaHE/wDRSpZFpScroUhU6+X7 DNyA== X-Gm-Message-State: AOAM533eLjghIEJ/9D/pPyEViXu3wAv34JGNqivzLHguddwgJ+Ymc/A5 /x4MjlY8eA4OW8hohtNr6zwSjkuw4MgrvOe1VQ== X-Google-Smtp-Source: ABdhPJxpXqOdPBoIYXkioBEuMajlBbzI5RIYR8yLeXTdm8sYgj7Z8KPEw60I7kFQuiavazH6jfQ/uumb1tiOo/5KnA== X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:4e45]) (user=howardchung job=sendgmr) by 2002:a5b:3d2:: with SMTP id t18mr42152587ybp.333.1600398751314; Thu, 17 Sep 2020 20:12:31 -0700 (PDT) Date: Fri, 18 Sep 2020 11:11:51 +0800 In-Reply-To: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> Message-Id: <20200918111110.v3.4.I3774a8f0d748c7c6ec3402c4adcead32810c9164@changeid> Mime-Version: 1.0 References: <20200918111110.v3.1.I27ef2a783d8920c147458639f3fa91b69f6fd9ea@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 4/6] Bluetooth: Handle system suspend resume case From: Howard Chung To: linux-bluetooth@vger.kernel.org Cc: howardchung@google.com, luiz.dentz@gmail.com, marcel@holtmann.org, mcchou@chromium.org, mmandlik@chromium.org, alainm@chromium.org, Abhishek Pandit-Subedi , "David S. Miller" , Jakub Kicinski , Johan Hedberg , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds code to handle the system suspension during interleave scan. The interleave scan will be canceled when the system is going to sleep, and will be restarted after waking up. Signed-off-by: Howard Chung Reviewed-by: Alain Michaud Reviewed-by: Manish Mandlik Reviewed-by: Abhishek Pandit-Subedi Reviewed-by: Miao-chen Chou --- (no changes since v1) net/bluetooth/hci_request.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 89443b48d90ce..d9082019b6386 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -1081,6 +1081,9 @@ void hci_req_add_le_passive_scan(struct hci_request *req) filter_policy |= 0x02; if (hdev->suspended) { + /* Block suspend notifier on response */ + set_bit(SUSPEND_SCAN_ENABLE, hdev->suspend_tasks); + window = hdev->le_scan_window_suspend; interval = hdev->le_scan_int_suspend; } else if (hci_is_le_conn_scanning(hdev)) { @@ -1167,10 +1170,8 @@ static void hci_req_config_le_suspend_scan(struct hci_request *req) hci_req_add_le_scan_disable(req, false); /* Configure params and enable scanning */ - hci_req_add_le_passive_scan(req); + __hci_update_background_scan(req); - /* Block suspend notifier on response */ - set_bit(SUSPEND_SCAN_ENABLE, req->hdev->suspend_tasks); } static void cancel_adv_timeout(struct hci_dev *hdev) @@ -1282,8 +1283,10 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); /* Disable LE passive scan if enabled */ - if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) { + cancel_interleave_scan(hdev); hci_req_add_le_scan_disable(&req, false); + } /* Mark task needing completion */ set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks);