From patchwork Fri Dec 8 21:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhengping Jiang X-Patchwork-Id: 176036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5720482vqy; Fri, 8 Dec 2023 13:07:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcR/WJh7ruOW9nw8OLdoCWIWe6cy3Atnkklg2OouWQCFIweQu/3YcLtvB7bJIt1MPBvD6r X-Received: by 2002:a05:6a00:18a3:b0:6ce:b86f:1b02 with SMTP id x35-20020a056a0018a300b006ceb86f1b02mr670638pfh.54.1702069643156; Fri, 08 Dec 2023 13:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702069643; cv=none; d=google.com; s=arc-20160816; b=aI/xoGM1MqSUZcltVgzLhpvOwg+a+c9K/xmri38EFY6yT9v9+5STHOVHVH0a/tAoqD ESUsY02iSJ+BJ4yQRMM0RECCH01f0MWe1EnRBNf9+VikA4JmWmYfENBit7xvL8JOOGO/ kFpfpTWMRgGo7+R6h5AHn5HjSFTpFqreJLJsFgjsWZbcM57smcU6X3mAPeQfwLOvHdMG nZS/9EFgjDucBf0L6rEKQ2qbW5gmGEkeSKa9+XjHESLKHafFzVO3FoKqQsID3VvK0381 F3e0d4lphHZE1Yb2tu9OsSHpkOo89bO3+xWhjAeWMKsaPYbdtK0CfjqwqV6IRljolQ6d SfjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=atKYixDgc1IYLIAixNFTtgRe8JLDt6J5MMwxSW6b7Pg=; fh=6RXQh2rH9NeUMzJfHEcN9bofYgyuIKJR94Pg26+qqHE=; b=psdDy8aXT0YbK89/dr2yQVSWwX0bDe8OP4qGarGWmSaoeCLkDT8EiKSHYUAubuzuAA BRDEsPS841ejhv3Rn8Hl5oxuaOT9zYkRQBpDG4DUCzsLI4o8KKp8uZNSUK2tFAaC+Wp3 ORNqfJif+yG6Dgmmqk08RrQvw5EgQC8hVqzMg4lTNSmDN9u9YVpG+ad0dPwapPQ+fSeB oCF9SqSeQ8lVBZypY9pX6i34c1bVihVn59P4XvcJaJWNqCZGiTBzCoaCLpdvsKr3rT0y PJxdvDty6x5XrZA6I1z+7gsszIeYxFa6IBv/DusJKzwJPS/BOC36zIfdtbrt6XpqJ+bs Znjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=r7BdHG8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id j18-20020a632312000000b005c6604d8a80si2050214pgj.121.2023.12.08.13.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 13:07:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=r7BdHG8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E936D83593A5; Fri, 8 Dec 2023 13:07:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574765AbjLHVHK (ORCPT + 99 others); Fri, 8 Dec 2023 16:07:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjLHVHI (ORCPT ); Fri, 8 Dec 2023 16:07:08 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D295198E for ; Fri, 8 Dec 2023 13:07:15 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-db5508d1beeso2740993276.2 for ; Fri, 08 Dec 2023 13:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702069634; x=1702674434; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=atKYixDgc1IYLIAixNFTtgRe8JLDt6J5MMwxSW6b7Pg=; b=r7BdHG8VStUbm+h4QyUFMMRIhoNDnQY0D3t/d7dmkMDYDKOyP4v1tYRszFTXTUO31n MxsZetvujkvUK41OaJBcqx0zUSrEdjFPyGJPUMcPxJK1oteunVwzTg48fuUuRaJAyy6d 7NWpv1EzHYhMIgyS6r57tlO22qtO711ZfbkMCADPpV+OPF4klJnRZ+1UBbuOSSarB3G8 NBAYeJHhb0DQHxsgNwPLd9ozu0J8gQMWNTD7YSwswLPzdhF+p2qVNWx/fzAendxYXIWJ pM63C4V06AW4dRnquvD5EepNv8eamaMt1UunBvdTvkKPajW05e5VgtXtEOyc1wcAMmMp Bh5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702069634; x=1702674434; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=atKYixDgc1IYLIAixNFTtgRe8JLDt6J5MMwxSW6b7Pg=; b=Qy/xVF6zF0tRqgA4TLlu8MzuwDAs8bzK6PxfeCcpxlE5cKrurL8wDhZPL29nH+vQio y1lclAYz9vZayy7zBx0edKhFe8hnjwzL3s/NJsAUy6vMmFLKmq5WkNHlixtM4IbgBc47 bLPELV//T+uPW5fsJcuVaEGX14BAG2UL1sGRs4sF7rmqYhHcJGivan9rkgSC1fmLfd8O Uz8dYKmsoGUtvSouKOl60pzLIqAJRWeKKVoGWx0L7bIyJveLRnAVHVJlezaSq+igk4Fk 5X5W9QY/hQIrPZWJfipDVHdXQZKP8sQlWRY7aljWVSsdsexGptrMJd8Do5QIPd/cUuD5 PcIw== X-Gm-Message-State: AOJu0YztWC9H12zz16+nAZrMPFsjR2EDciYMCO0B0GlOjqs50uRHlfeq /4zixM+BpUbDYSOIgN0Bh+8j2K52Jt4b X-Received: from jiangzp-glinux-dev.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:38e4]) (user=jiangzp job=sendgmr) by 2002:a25:ce4e:0:b0:d9a:61d2:38ca with SMTP id x75-20020a25ce4e000000b00d9a61d238camr7101ybe.10.1702069634325; Fri, 08 Dec 2023 13:07:14 -0800 (PST) Date: Fri, 8 Dec 2023 13:07:06 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231208130705.kernel.v1.1.Ic5024b3da99b11e39c247a5b8ba44876c18880a0@changeid> Subject: [kernel PATCH v1] Bluetooth: btmtksdio: clear BTMTKSDIO_BT_WAKE_ENABLED after resume From: Zhengping Jiang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Zhengping Jiang , AngeloGioacchino Del Regno , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Matthias Brugger , Paolo Abeni , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 08 Dec 2023 13:07:19 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784749377932665286 X-GMAIL-MSGID: 1784749377932665286 Always clear BTMTKSDIO_BT_WAKE_ENABLED bit after resume. When Bluetooth does not generate interrupts, the bit will not be cleared and causes premature wakeup. Fixes: 4ed924fc122f ("Bluetooth: btmtksdio: enable bluetooth wakeup in system suspend") Signed-off-by: Zhengping Jiang --- Changes in v1: - Clear BTMTKSDIO_BT_WAKE_ENABLED flag on resume drivers/bluetooth/btmtksdio.c | 10 ++++++++++ include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_sync.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index ff4868c83cd8..8f00b71573c8 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -1296,6 +1296,15 @@ static bool btmtksdio_sdio_inband_wakeup(struct hci_dev *hdev) return device_may_wakeup(bdev->dev); } +static void btmtksdio_disable_bt_wakeup(struct hci_dev *hdev) +{ + struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); + + if (!bdev) + return; + clear_bit(BTMTKSDIO_BT_WAKE_ENABLED, &bdev->tx_state); +} + static bool btmtksdio_sdio_wakeup(struct hci_dev *hdev) { struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); @@ -1363,6 +1372,7 @@ static int btmtksdio_probe(struct sdio_func *func, hdev->shutdown = btmtksdio_shutdown; hdev->send = btmtksdio_send_frame; hdev->wakeup = btmtksdio_sdio_wakeup; + hdev->clear_wakeup = btmtksdio_disable_bt_wakeup; /* * If SDIO controller supports wake on Bluetooth, sending a wakeon * command is not necessary. diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 0c1754f416bd..4bbd55335269 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -672,6 +672,7 @@ struct hci_dev { int (*get_codec_config_data)(struct hci_dev *hdev, __u8 type, struct bt_codec *codec, __u8 *vnd_len, __u8 **vnd_data); + void (*clear_wakeup)(struct hci_dev *hdev); }; #define HCI_PHY_HANDLE(handle) (handle & 0xff) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 3563a90ed2ac..6c4d5ce40524 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5947,6 +5947,8 @@ int hci_resume_sync(struct hci_dev *hdev) return 0; hdev->suspended = false; + if (hdev->clear_wakeup) + hdev->clear_wakeup(hdev); /* Restore event mask */ hci_set_event_mask_sync(hdev);