Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3978318ybf; Tue, 3 Mar 2020 17:07:21 -0800 (PST) X-Google-Smtp-Source: ADFU+vtu6xJSMgD3EA5YIjT5vEIC9sX+g8gXkn7Yrwb3t9XL5wDtH6eRxJWyc5027mQrC8aZ+nxQ X-Received: by 2002:a9d:6c1:: with SMTP id 59mr507198otx.281.1583284040930; Tue, 03 Mar 2020 17:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583284040; cv=none; d=google.com; s=arc-20160816; b=vyRI0/BOhcMFPvn3bTNE59Samo/qEcnw+2grSva8lOslea99EFxreykG5DJgqWiGdW WYTPVWIL4yntDptz84I5dx6S14wYPNQInNV4H/vC2yw3V2DxzSXTTpe9Djg85A3SbdgM T+LQc5zwhq0/oq7g1Pt4AuU8dmCdLuVp0ZgTyPpni0l5pmtoWEvyk3V/FK3olfH8l7P6 wLR7LyodUv/ibmcOhKGNqWqQCme5sdEW1t5EfrWx8mdMhEfImf8glUzdsyP2uuGmrdx1 H8eEcKUeFQ7xl6RK4eEUGnGK1yglbMASGCQSUJeHdC0jXQJbhtUiT/xsB6RF4O+MT865 ebCQ== 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=wqvCXfGj808uPbmqG51quPJGXzE0v6hUvwSV24GKnh8=; b=RJkkrh5YMM1CNDMcaoUJH/q8YYqb3Tj9R/GAV4IRai+esPFXWxci/Gd4utU14ZEl32 cQq/pu0tP0SX03WVqIeC7mXKj7NrZuFQjm3UJj5Fe25QrP76HBFkJyMSvlmyX0c9WMmM 24zmusa+zueQffc92niu6eGH9buYKGzP+PM+VDuelcCA1uyJFTLesvGcghdbkYAQ5zzR CqKghUbH5ukFn8PAmbz/0xZ8psTYdwBbo0hVXgHKO44QRfc6plcI9vJzbORDQrO5fyWL rV1fMwcA2AsqfqfeLT/rkcfhr/oNRkT1kj/mEAsX1nyF+OKlI9MsvBnDrbcZ3dpf0Am/ m80w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=idcee3dY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 o20si197925ota.17.2020.03.03.17.07.09; Tue, 03 Mar 2020 17:07:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=idcee3dY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S2387462AbgCDBG6 (ORCPT + 99 others); Tue, 3 Mar 2020 20:06:58 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34275 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387400AbgCDBG6 (ORCPT ); Tue, 3 Mar 2020 20:06:58 -0500 Received: by mail-pg1-f195.google.com with SMTP id t3so162137pgn.1 for ; Tue, 03 Mar 2020 17:06:58 -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=wqvCXfGj808uPbmqG51quPJGXzE0v6hUvwSV24GKnh8=; b=idcee3dYDzfJ0CM6iZp7JlkpSNl01PCMsrR59GXa9oGRh3kMhgsjo3eUALsnKzraqb G9rvT7THOdySxd+am6A1csXQjcAhL9RnC26h0PcC2Cvc4MZDoYqveFHur8Gl2/Rq2NCY UPAvwQeJA1mdMZGUgyS6vepHyX0sAut2v9iWk= 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=wqvCXfGj808uPbmqG51quPJGXzE0v6hUvwSV24GKnh8=; b=YP6EByrDvl/We+QPHWFw7STipy01aFLmE4NM9w+29mHId7ASrjwssBXzWJCzgY56vP 99L+R0ASBWdG0fcgHyZtCkk/fRQ/56482QpOaQ6gAy3SZvrxB4Vus8p5Id/B85Z7Kg6w Kl71E9dd4vauICeJJeR+Pj2+DaM1RGbO5f7eS+00kSQqX0u2clCHfRI8ONV3uyZiL31c NaO511U/IC/UcapbpiaHq8J/UGwZ/LBGcYqiEiKbwt8II3O0kA7L7P0zLCQbRQ70ef20 vA1nQ7qZI+UPj8GAaDSbSvQgylQYCpaWASRaLXK4V+fMThYb+Io7RwiPHJge+RqQoEUb OA2g== X-Gm-Message-State: ANhLgQ0TMLMJAogBkVOwjbiG6AMu49FNiCUHWkxKjVWjAcr8c9P4+nde nfBr6sOgNSxS7yyiKROBnzUqDA== X-Received: by 2002:a63:155c:: with SMTP id 28mr217571pgv.176.1583284017531; Tue, 03 Mar 2020 17:06:57 -0800 (PST) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id w2sm17780889pfb.138.2020.03.03.17.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 17:06:56 -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 v4 0/5] Bluetooth: Handle system suspend gracefully Date: Tue, 3 Mar 2020 17:06:45 -0800 Message-Id: <20200304010650.259961-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. Please review and provide any feedback. Thanks Abhishek Changes in v4: * Added check for mgmt_powering_down and hdev_is_powered in notifier Changes in v3: * Added wakeable property to le_conn_param * Use wakeable list for BR/EDR and wakeable property for LE * Refactored to only handle BR/EDR devices * Split LE changes into its own commit 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: Add mgmt op set_wake_capable 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 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 | 327 ++++++++++++++++++++++++++----- net/bluetooth/hci_request.h | 2 + net/bluetooth/mgmt.c | 92 +++++++++ 8 files changed, 554 insertions(+), 60 deletions(-) -- 2.25.0.265.gbab2e86ba0-goog