Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1831823ybh; Sun, 8 Mar 2020 14:24:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvtQHfCPHAaOzQuQYi+9Yw9+IOqWBunRaRTtSWmtfbiONScxx6hhL8HLVrVZ6xbBmJxO9a1 X-Received: by 2002:a54:468a:: with SMTP id k10mr9763504oic.3.1583702664514; Sun, 08 Mar 2020 14:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583702664; cv=none; d=google.com; s=arc-20160816; b=EvZWKx9BLR+FxcDciT/UuSIR6k+4uS3YeSkLQHhJccz233P6nqtjzTdDfV/d0c69p0 3hEZc5TqzRSpqQhfr3IK1Iqkm+HwLf3GGeEvvfZ/7Z6CHRC7c9/QY2Qsbv37gpdndWjO 6t3ADEVtHaF3Kydu4YySQibSz9N0Pbc9Iwvm4XeDsTsKVc2OlPt18X+Kj1OQBUlF4fxn GQTAtgBX/8A1qAq0ZFVzogUYXRSDebDpym0JojZZLK9zNcrEDyEfR3nn0XQ1YrdRFuJb F8GwdNZ3967yQ5VT3h3eIm1b+o5Mn09BWV6PtHiOu0M3oVXWQEkDOgmdSllXeH6TE8Ap 27aw== 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=1tzW7HssZBtY3SvxCb22E4ke3jvHNoIbFs14WY4NcNA=; b=wIUDSw+17g+mxfPsw4Ko4sYGyq4UPQcOebGZiJXJIJJQmv62xgBr8vku+nAYoync2l 29x8+5Ka3cACpXb4K0GYdpPqTkUBKZ9/CHbryNrvqJ+A8Wnl9CFC07nw7Hepm7GD04kl YOYblHH41jzNu82dPQ7pSeYRuBnV4JQiEE+tBSoIIM1Al2YBCgf+rQQsEIWbnCwfrdzB cMEBXl3yMudLThCTXShOy0/m9sn4Wo7BKyNVfDi/NG2V3C7De5K59n7Mkd3UnTSBmz7x r9v89urr9Jw9w7wW6bEao8pb8jabixj9tGEzcaDILjwSVmi2F9gpaIFgXiB+u5laHYcs t1kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bsR7I29s; 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 g8si5555267otg.126.2020.03.08.14.24.10; Sun, 08 Mar 2020 14:24:24 -0700 (PDT) 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=bsR7I29s; 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 S1726332AbgCHVXv (ORCPT + 99 others); Sun, 8 Mar 2020 17:23:51 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:53761 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbgCHVXv (ORCPT ); Sun, 8 Mar 2020 17:23:51 -0400 Received: by mail-pj1-f65.google.com with SMTP id l36so681657pjb.3 for ; Sun, 08 Mar 2020 14:23:50 -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=1tzW7HssZBtY3SvxCb22E4ke3jvHNoIbFs14WY4NcNA=; b=bsR7I29sZ7HfQSRCAWI51eV06TbZfLHVY993eC6fVQqxIVQt1NptdMVXm/LrxLBCbl Tlz0S0zWxgO+UynwKVdIWh9nCHZxu74LqYXv2XWjUiTkt1XmFmUl9JG4kgka3YKjBTqL bzm6pFJdujJETyNaI9EGQk1oSgV0oqBlguB9s= 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=1tzW7HssZBtY3SvxCb22E4ke3jvHNoIbFs14WY4NcNA=; b=c4NUSUS3JwLerkpu+S6+rHPPLMO8CGFa3XE9zs7nd5V66u/8QE8IlyXfQ7FxsPm6bY gCU5x7nI+lpc1TGQ8PDGGxe+Rw16rUevYSW6lAQlU7WuF5dK2IcJpW95zjDaf9/KlVVl 4QJ6BK7aQvNhlcPZbFaLksHgJ6AA7S9tY8t8M5P0bfpjNTneGULYqV7nEdlVGkg62fPU f48jVTIfiPGEitJS69yyLgqxGiUiBOXRxA/xfgVkxx//cC4Gtr0126IcgCZySy2ghlcP 5iMAbpqqO/wbakZeQPK1Fo/cvxFADxfYxYw7ZFW+JihFAy2AERDZe5NASCJaRHl0sN6T 7eEg== X-Gm-Message-State: ANhLgQ2jz6jZEVp3PD/uQCEqINipE+zCtaaysgGLlCz2913ixMu/K5mk 1wjRz1OWFK6Us6/1DBEy1uEbZA== X-Received: by 2002:a17:902:6b48:: with SMTP id g8mr12825346plt.149.1583702630315; Sun, 08 Mar 2020 14:23:50 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id k1sm39509228pgt.70.2020.03.08.14.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2020 14:23:49 -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 v5 0/5] Bluetooth: Handle system suspend gracefully Date: Sun, 8 Mar 2020 14:23:29 -0700 Message-Id: <20200308212334.213841-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-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. 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 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