Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4158858ybl; Mon, 27 Jan 2020 17:59:33 -0800 (PST) X-Google-Smtp-Source: APXvYqw1LYxFi4fOBp7HraWQo9TkFg1le9sk1fXU2NfVnZkBaL9HdttLEJfHufTHvGSiTJ4Xh9Ar X-Received: by 2002:a9d:7b4e:: with SMTP id f14mr14872268oto.355.1580176773110; Mon, 27 Jan 2020 17:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580176773; cv=none; d=google.com; s=arc-20160816; b=ZX+UXfEgYWmbTcF08b49dH/B5mg60YCRz+Lfsfc+DJ7q6aSbhcSwM1S5tZvnpSzscy pQV7N0H4UkcfnGTjoE20XIGx6jam1KD3YjuNaU1O6gjjWX4YWOEZ6GRFw2DArY7cJ7vG ZHi172Mar0l7x5qSIf48GUk10cCUgIz65uyiZrMHwsXbJvXxy1mTh70bSYZ+o/a0NRDV ps8VWhb6s4ZHvu6hV/WR091Fj9kFIHrTVHk+S4XYTCnlz6qD8iKLuPho3b0y1SnmQ8Xg pn8nts2+1rE1NlgvCT5AjLCU47g6qgWqkcx3aJvREuv65+G6pPZjXk/Z52Lul/XN1qUn cv0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=R3FwTdU3+YYxJ9SH0Yd6M6zNVwXOrrZbQeuDM/vJ5Fw=; b=kYxKrVDlEi/JeE5GKoMH0XycT64au4LnBPjY32S2hK/l6wy4HDhVu+CZKW4EBbwJUJ hdxUhpdrvQJHnk7S2ZNo8WBXaY3af3AJkCV4VSafPE6rsZxiTvpgRYCjpYO7oQTXZy69 33UuXYS6kkmnB2RtUGYQJdV/Tf2/o0T4TCPUblwTf4fJbOVIcqkUmDOY0Odo9moyuTtf +QiP2RaLbTAJ5eriLJAvEIKc4H8LtcBLaIQ4L0vtLUOpRG8egn84vwZRqaANzJpmLe38 jh/s+aNaaJxAcgLTR8DIbPmz//pKnwYj5MfbACZ7fIcvGH8Hd+7acD8o64XsRWJQq5Gz 42hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=luBgcOEn; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s64si4289558oig.147.2020.01.27.17.58.58; Mon, 27 Jan 2020 17:59:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=luBgcOEn; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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 S1726267AbgA1B65 (ORCPT + 99 others); Mon, 27 Jan 2020 20:58:57 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35259 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbgA1B65 (ORCPT ); Mon, 27 Jan 2020 20:58:57 -0500 Received: by mail-pg1-f195.google.com with SMTP id l24so6135703pgk.2 for ; Mon, 27 Jan 2020 17:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R3FwTdU3+YYxJ9SH0Yd6M6zNVwXOrrZbQeuDM/vJ5Fw=; b=luBgcOEnWPjDt+cpT6KoP8uJi/NyTEjILoOu/xFOsfstZZ4hs0ZnNeftmkm1qLl4Zk BoTvNCtfRaBYdsE/zKSlCiM95nPfKXMjRLfqj8uNOZge+T3uJ4bcmK5S5p3ANJPREa8s 5HBk3/1H8fscF5HrR7a9CY7l2k2Lg9NZadM1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R3FwTdU3+YYxJ9SH0Yd6M6zNVwXOrrZbQeuDM/vJ5Fw=; b=WTJeqaX88I73xGoJwpi21D0rcVEvctNZHvhCR2ru13KbarZKpidmo8NusJdZqFzH7X 5SGqcruyj9Z9hL1wX5CHWqfPu+vBVkNUOswZOj2JFUbstGvjfuAWvglvyETkNl0h0tM6 PzvOqltWh+CAL4TsYB7lxzXewYFvDuP3W0Jxu+9vSejjWJn2aeSjHONQBRm8t5J64CCI NUt3q6oTNIUCExicmCEMVQa9g3vgfy/jaTjulLxTmpDGg/Y/YKv2dEDwlpqmYq4aQTLW mJY4LA8J4nhuKIe11Jbt50eWZEgARPjE33qi4JvEEEzXEmNADTO5Zw88lv5r1ZAfeakD sCVw== X-Gm-Message-State: APjAAAXBT7jhSlWKD8WW5ctoLqoIDtqa9/J0a4oJtvqEjhpBe8nKyiW6 3/cWEuzkAivK1Q9zzBNjrcgnIg== X-Received: by 2002:a63:d04c:: with SMTP id s12mr22613870pgi.105.1580176736512; Mon, 27 Jan 2020 17:58:56 -0800 (PST) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id a17sm364153pjv.6.2020.01.27.17.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 17:58:55 -0800 (PST) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, luiz.dentz@gmail.com, alainm@chromium.org Cc: linux-bluetooth@vger.kernel.org, chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi , "David S. Miller" , Johan Hedberg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski Subject: [RFC PATCH v2 0/4] Bluetooth: Handle system suspend gracefully Date: Mon, 27 Jan 2020 17:58:44 -0800 Message-Id: <20200128015848.226966-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi linux-bluetooth, This patch series prepares the Bluetooth controller for system suspend by disconnecting all devices and preparing the event filter and LE whitelist with devices that can wake the system from suspend. The main motivation for doing this is so we can enable Bluetooth as a wake up source during suspend without it being noisy. Bluetooth should wake the system when a HID device receives user input but otherwise not send any events to the host. This patch series was tested on several Chromebooks with both btusb and hci_serdev on kernel 4.19. The set of tests was basically the following: * Reconnects after suspend succeed * HID devices can wake the system from suspend (needs some related bluez changes to call the Set Wake Capable management command) * System properly pauses and unpauses discovery + advertising around suspend * System does not wake from any events from non wakeable devices Series 2 has refactored the change into multiple smaller commits as requested. I tried to simplify some of the whitelist filtering edge cases but unfortunately it remains quite complex. Please review and provide any feedback. Thanks Abhishek Changes in v2: * Moved pm notifier registration into its own patch and moved params out of separate suspend_state * Refactored filters and whitelist settings to its own patch * Refactored update_white_list to have clearer edge cases * Add connected devices to whitelist (previously missing corner case) * Refactored pause discovery + advertising into its own patch Abhishek Pandit-Subedi (4): Bluetooth: Add mgmt op set_wake_capable Bluetooth: Handle PM_SUSPEND_PREPARE and PM_POST_SUSPEND Bluetooth: Update filters/whitelists for suspend Bluetooth: Pause discovery and advertising during suspend include/net/bluetooth/hci.h | 17 +- include/net/bluetooth/hci_core.h | 38 ++++ include/net/bluetooth/mgmt.h | 7 + net/bluetooth/hci_core.c | 71 ++++++ net/bluetooth/hci_event.c | 28 ++- net/bluetooth/hci_request.c | 370 ++++++++++++++++++++++++++----- net/bluetooth/hci_request.h | 2 + net/bluetooth/mgmt.c | 89 ++++++++ 8 files changed, 554 insertions(+), 68 deletions(-) -- 2.25.0.341.g760bfbb309-goog