Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1028430rwb; Thu, 11 Aug 2022 14:30:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR5mjMoQaasmWkfSGpvfw4xggw2wuskUK7BkcKmO/sVJuQAmCKjXuadWNc9Fb+HrTFGj+5H2 X-Received: by 2002:a17:90b:4a05:b0:1f5:62d5:4155 with SMTP id kk5-20020a17090b4a0500b001f562d54155mr953726pjb.6.1660253412410; Thu, 11 Aug 2022 14:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660253412; cv=none; d=google.com; s=arc-20160816; b=zxYIfI4BmMsYaAKrxp+p+qbh4CrvsC1FXUpvu0JRkQw9/rgrS9xt9kivZeQqPlQF0B IAnaisUTbDkdNWYtUWB0yBspQ+4HhtdgPTRcfQqFDXrdqNEEa2JQFUizGHJ54X9IzgZ5 0e8GuSw2+SlJF88zEmru+XJqct72zK2iXRUvhdjS+pbxjS3LuwiRXbZTWrAEE/yAQFpT 4CwGEklKVGaMXKVNaOeMkRzCZK7OvQTAfXeVvfbA9hxl7ayyh4KD6VnzhUhpu4UoOzez Movquq6PC400kgcfRVlyd7JRJ0+u9dVeVxWcyuroJnwIq2FgHXklCrqNy1pZfpcnhVax S8gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=1QPj0z/Qx7jelduJGkvhcHUBIPKxbQMEWyLx9TGQ+aA=; b=tBIJJhygscMwrPH9Hboodthv5vOXpdI9fQihAY5+P2PEMPFPpPBNlTLHu4ZAHb/EzB xrulngexpPC75LOELZyIQJQA0i5EmCPn1t8cBi8q/7RT8E1C5NXIDcLHL61lmy20gJNT KJhFSH3k6F9QilkfvKRxqGpcxmv2g7hDR0SYZ5Kou2UY8CRfg9tSKSqwyk8wEqJpWpLP oLLM1PW3gPGbCpOvsXhJjsS6aPbg+iUT5d25Kl8Ob0qlzlvautPUhWqcn6XVrR4ydjqr eVUB7pUktr/vxHMoYpOe0gvnV+/sPq4g5cyzaNA8X8uNVnchDAeM+ej76OBOlsTRDIn7 Zvyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TupTOtT6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t29-20020a056a00139d00b0052d9c492c52si430369pfg.133.2022.08.11.14.29.58; Thu, 11 Aug 2022 14:30:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TupTOtT6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235759AbiHKVYt (ORCPT + 99 others); Thu, 11 Aug 2022 17:24:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236410AbiHKVYq (ORCPT ); Thu, 11 Aug 2022 17:24:46 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7C869F756 for ; Thu, 11 Aug 2022 14:24:41 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id s206so18183788pgs.3 for ; Thu, 11 Aug 2022 14:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc; bh=1QPj0z/Qx7jelduJGkvhcHUBIPKxbQMEWyLx9TGQ+aA=; b=TupTOtT6ChPnMEOIMLKcPXDA+gygO23Z3DZ7Q5//2fwxDeWHyIErC9Y01pW5kr2w3M rzUJVj/XkHikJxPoRcFHyHTafutuooI3r59LPJYMYmknY6xr66Ro37damXlKZkg2nV1T ZsKjK0tqEr/eJ3DnpGfwdYRqty6R5D0iTZrB+2ZkYMW/gS1aaw3YJvunkf6/Tt4R1TTK 9y/ldIoPvJzQY742GTSXVhBgNhLX4WbcghBiV01BLvov+wch/9ECgBZ0NqwO2bjM62pK OP+on4lsrUu/FCoKCLlczoyKlRKYZJTd+jei0g2mdkvmkdvb/6eyHBtXvpwYEKKLzrg0 zAow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc; bh=1QPj0z/Qx7jelduJGkvhcHUBIPKxbQMEWyLx9TGQ+aA=; b=Cg+YHpTOwVot3sYeGjL1fGVdDNpVDL0EJbxF0IJ02RC6dIG3dzi+RuTLwk/aV81M/U +14KhTITxpUpIp2WsTLuDopE6jeeD+rGVWgrke1lGtKqOBvTWHFR0aIPeDFVh8Cgnm0U AMEQVIH2DinwAunmD0aDpbk4dLSZlxDaM9EumiDaUDMPxrTSK6gEVIeCwfjOR7V5NyUT sxd5RhdrkAKQLSWb6XsaLfUoDMUPBJq+M/d64nM+TKZtqAGL5FFR3UV8pcJf66n9Kqtq +54DCgJcG2EpSJ/FZ8ZVOhthrVxfbKED+ooRxy5Pe3byFAJBDO0KcudBBLVs5ykZEi4n duhg== X-Gm-Message-State: ACgBeo11fO2yORS3lPAVfRvVpNJaAnnt5NHMQ/Dyn/joD8ClmS0W9GRS msQB1gZGW+OwE//uoMiUq0CXMX5PtxJdTQ== X-Received: by 2002:a63:4d4f:0:b0:412:a02e:2896 with SMTP id n15-20020a634d4f000000b00412a02e2896mr683985pgl.337.1660253080007; Thu, 11 Aug 2022 14:24:40 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id z7-20020aa79587000000b00528c22fbb45sm144846pfj.141.2022.08.11.14.24.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 14:24:38 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH] Bluetooth: hci_sync: Fix suspend performance regression Date: Thu, 11 Aug 2022 14:24:35 -0700 Message-Id: <20220811212435.273142-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This attempts to fix suspend performance when there is no connections by not updating the event mask. Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_sync.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 6de2ad730995..74a0cd5d0b37 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5549,17 +5549,21 @@ int hci_suspend_sync(struct hci_dev *hdev) /* Prevent disconnects from causing scanning to be re-enabled */ hci_pause_scan_sync(hdev); - /* Soft disconnect everything (power off) */ - err = hci_disconnect_all_sync(hdev, HCI_ERROR_REMOTE_POWER_OFF); - if (err) { - /* Set state to BT_RUNNING so resume doesn't notify */ - hdev->suspend_state = BT_RUNNING; - hci_resume_sync(hdev); - return err; - } + if (hci_conn_count(hdev)) { + /* Soft disconnect everything (power off) */ + err = hci_disconnect_all_sync(hdev, HCI_ERROR_REMOTE_POWER_OFF); + if (err) { + /* Set state to BT_RUNNING so resume doesn't notify */ + hdev->suspend_state = BT_RUNNING; + hci_resume_sync(hdev); + return err; + } - /* Update event mask so only the allowed event can wakeup the host */ - hci_set_event_mask_sync(hdev); + /* Update event mask so only the allowed event can wakeup the + * host. + */ + hci_set_event_mask_sync(hdev); + } /* Only configure accept list if disconnect succeeded and wake * isn't being prevented. -- 2.37.1