Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp690926ybh; Wed, 11 Mar 2020 08:54:34 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtt6+vTIEA/T9jcf7IUUunnnrURCfeHSZkRsacVhssTOs8oAeQl2FmvKAIjUyn5sXqFR9xM X-Received: by 2002:aca:4e47:: with SMTP id c68mr2501955oib.16.1583942074724; Wed, 11 Mar 2020 08:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583942074; cv=none; d=google.com; s=arc-20160816; b=JAozN9qS68FjeIH7BYG8l8prdwSTwsQ49+E+amF6Ie0y3yMpMJlxzW7ynmn0q4Qpvm JjtIGM6NERyaguOhx+4Rqd04SyemkRYuxzu1mvyZA3a8n2Do5wo86z2MpIEwMgNmKPb6 V6472hSPZ58LxVd4njmveXzPPPZ9RWcG4sDroxzD/Hl3wlgQDASYj15u0yWwtnDj3clv f8dXoUTwnvBaXEd7wVl4ajY+7vE8HnED3P1V4LdKnJAvrIsYRpb3JM2UKGf941ToL4lD PpFeWvl6M/IjFzNoE8/Buf/t7KoO91+xTlxrR+hEBf5rUhHfA7yLnJ9s11otajJjj5eo 4jfA== 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=zkKRih67nIXGMoMSRIIKy/nqbn5RrocuHsn8k5pVnAA=; b=Gw2RYAfnikcMv9y52w9687XyxTNtqYs9p+/GBz6In9YQYXcwL7geWFfolFe2zdROrJ xJchJziaz0gwQ7VnvlmmEE+dwabBOHGqTdqdRk/C9kUjGYlRVJvphfqju2BSOq5vVUZT vMe78J/A0LH/8hSNEyP2IGgcHZuLhqIUwasufvZdmm/KbmyaoSpfg7oEfNLGNo6Hmle7 GFO6Df+FUhcQXbC70WlALBbOFIBF0D8+9hQoGvWwtBfGyevENg/nIbsb6f7cdA+04fYR Lars9oXvTFwsfDPS0CKBwo63UsbKeosLxh/gefEmXe6pt3a7cel+3+HYRWCUkVT4Vv3G 98/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YUiQneiW; 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 l19si1207369oii.54.2020.03.11.08.54.16; Wed, 11 Mar 2020 08:54:34 -0700 (PDT) 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=YUiQneiW; 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 S1729989AbgCKPyM (ORCPT + 99 others); Wed, 11 Mar 2020 11:54:12 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35075 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729848AbgCKPyM (ORCPT ); Wed, 11 Mar 2020 11:54:12 -0400 Received: by mail-pl1-f193.google.com with SMTP id g6so1307444plt.2 for ; Wed, 11 Mar 2020 08:54:11 -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:mime-version :content-transfer-encoding; bh=zkKRih67nIXGMoMSRIIKy/nqbn5RrocuHsn8k5pVnAA=; b=YUiQneiW5Go1q+RAm5qkNRqk3wlN/KkqfhSfQx142Q7OOmktqS7t4LnMVhpRoBWGvI 9gV2+adL6yuTX3zJaT7ty49b60tC+SpVbeDFHkNAn2rQ6qC/A3p1vb5ObvLMiBS/oSEN RFq33e+VH7QZtv8oR7RT2rJzo4TIz+KGCBSPo= 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=zkKRih67nIXGMoMSRIIKy/nqbn5RrocuHsn8k5pVnAA=; b=n/NArPfIhSNBeAeJcBIks/YKp/vwfLJs6AF4Fg6iQbLg/madum7ZcU3Ptyn7nOoCS5 ZOiQ9FjN4bAw8jRK8tz66LNvry3yqewK2EmhBagLAdAwjsHL8cQXjxpU1klq3FF5sjWe x5i7tELdZIRG4eGv6P5mxG9ypX8O8vmARdpwmEXPFUs1KuW6Erf6nO/ALzI44bUYh6u6 3b8r2+pMd4v2671EC4AzTOks8qGhzO74E/NP4bNYywytHDG0Npb+9CYfOwiKmvi0fWa6 YrJhNt9P9WcgtwIC63A1cMyf59eTACkmr5/PgXaV61HLXGV5eUkZfzeNPzm59en7Q+Fb AeFQ== X-Gm-Message-State: ANhLgQ1kKawyHjiFq5Kz1mrWEVGShT23f8xlDHna1jGwOGszcYgSY+ZX Vr+8QVreFc4ZUAO27kuJ3rKHPw== X-Received: by 2002:a17:90b:19c3:: with SMTP id nm3mr4215441pjb.149.1583942050863; Wed, 11 Mar 2020 08:54:10 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id a71sm13756265pfa.162.2020.03.11.08.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 08:54:10 -0700 (PDT) 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 v6 0/5] Bluetooth: Handle system suspend gracefully Date: Wed, 11 Mar 2020 08:53:59 -0700 Message-Id: <20200311155404.209990-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-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. Series 3 has refactored it further and should have resolved the whitelisting complexity in series 2. Series 4 adds a fix to check for powered down and powering down adapters. Series 5 moves set_wake_capable to the last patch in the series and changes BT_DBG to bt_dev_dbg. Please review and provide any feedback. Thanks Abhishek Changes in v6: * Removed unused variables in hci_req_prepare_suspend * Add int old_state to this patch Changes in v5: * Convert BT_DBG to bt_dev_dbg * Added wakeable list and changed BT_DBG to bt_dev_dbg * Add wakeable to hci_conn_params and change BT_DBG to bt_dev_dbg * Changed BT_DBG to bt_dev_dbg * Wakeable entries moved to other commits * Patch moved to end of series Changes in v4: * Added check for mgmt_powering_down and hdev_is_powered in notifier Changes in v3: * Refactored to only handle BR/EDR devices * Split LE changes into its own commit * Added wakeable property to le_conn_param * Use wakeable list for BR/EDR and wakeable property for LE 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 (5): Bluetooth: Handle PM_SUSPEND_PREPARE and PM_POST_SUSPEND Bluetooth: Handle BR/EDR devices during suspend Bluetooth: Handle LE devices during suspend Bluetooth: Pause discovery and advertising during suspend Bluetooth: Add mgmt op set_wake_capable include/net/bluetooth/hci.h | 17 +- include/net/bluetooth/hci_core.h | 43 ++++ include/net/bluetooth/mgmt.h | 7 + net/bluetooth/hci_core.c | 102 ++++++++++ net/bluetooth/hci_event.c | 24 +++ net/bluetooth/hci_request.c | 331 ++++++++++++++++++++++++++----- net/bluetooth/hci_request.h | 2 + net/bluetooth/mgmt.c | 92 +++++++++ 8 files changed, 558 insertions(+), 60 deletions(-) -- 2.25.1.481.gfbce0eb801-goog