Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp481429imw; Mon, 4 Jul 2022 13:11:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ubhH9XeOhZjXo/MWOCxboXTwYVP7PVv8x3xKUi3pN2PgMhIH3jWYy+oFtOL/lTtPZxiU/9 X-Received: by 2002:a17:906:8a62:b0:70c:81d9:d5b9 with SMTP id hy2-20020a1709068a6200b0070c81d9d5b9mr23171823ejc.597.1656965492448; Mon, 04 Jul 2022 13:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656965492; cv=none; d=google.com; s=arc-20160816; b=ADt0JD6/f/fxS9pcmSA3/KjPDyCe9XO9q1l8oc/MNwsnPJc8wrz6N5jd5PQZCI19j1 OuQRtexIOMQfa9BeVMpzm/yxSYw5LU9AyYY5tgfIQUXvM+f8lZwjKmrgcHVtSl6aTWnc CIa0LpFZy1epy8Bb4u1IxysXl8O1FBFh1LkoXT7O3dKS7Fc7exkKXKd1BWJXN+vGAmlF ErR8akZ9jAEML5jj6GZhGFzaHBe3c4NGnmX1+2nV3RX+5B5RSQUPhrl/1yOJltzSB6eX t5nuqgOWszbJJgJ5lw9ENm1rg4sgGUmP+kec9bDnC5KpgN9cAsC3THJYS2KvrgdfAQd5 3asw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=JAPDsnJCAOoJpyKrd8cy2v9k90C1Stc2pfXNgFAfZqU=; b=dmoGpfaTv874TjYvlp99ZUW2jOH04fTP+Z4hK9ypoFkGVcWqXdEZJKDhxOTiavk5Tb 8MCd69XmVEXTSx1wYIAwIb6DAaictA3Zto+sN9WbNeL5oSvbeG70tfB9+M2dCU0UmrkD tD+PTXOsCr3Htl+MNQ01zy3YWYleklahw3mZFmIz84EaTff6ddc7byTbXlzutnHvDZsd bnG4Za6bBd6EIvTGUJMYAmIj9fjWXIq4RDzppQTlJWqnxxuw0fbfhULOPrQNnQkYFyub rMap3IdDKnYrhCa2J1WMdmCrxtS6Txdebks56WWHb7KUtIGD2CRImT6xmq8zZvs12VEt 46hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@o2.pl header.s=1024a header.b=Bl7LEahp; 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=NONE dis=NONE) header.from=o2.pl Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a056402444500b0043a64cca77asi3364717edb.424.2022.07.04.13.10.50; Mon, 04 Jul 2022 13:11:32 -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 (test mode) header.i=@o2.pl header.s=1024a header.b=Bl7LEahp; 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=NONE dis=NONE) header.from=o2.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbiGDUDu (ORCPT + 99 others); Mon, 4 Jul 2022 16:03:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbiGDUDt (ORCPT ); Mon, 4 Jul 2022 16:03:49 -0400 X-Greylist: delayed 399 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 04 Jul 2022 13:03:47 PDT Received: from mx-out.tlen.pl (mx-out.tlen.pl [193.222.135.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCE4160C5 for ; Mon, 4 Jul 2022 13:03:47 -0700 (PDT) Received: (wp-smtpd smtp.tlen.pl 24291 invoked from network); 4 Jul 2022 21:57:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1656964625; bh=JAPDsnJCAOoJpyKrd8cy2v9k90C1Stc2pfXNgFAfZqU=; h=From:Subject:To:Cc; b=Bl7LEahpMO/syyT85vclH0SRb1OfXVYTWvJaZ78xyqVa7UHN2Fg7af1Lzg0YbJgCC 0ei2ecwLTEEwakGpvN+KSGBiJipSBajD8XillMdF0rve5GXmZqb5O+YITDhikq+NQ/ PYx9xxLLwdoa+ODb9gZHn1SYVkSprHrFPq4x0RTA= Received: from aafi210.neoplus.adsl.tpnet.pl (HELO [192.168.1.22]) (mat.jonczyk@o2.pl@[83.4.138.210]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 4 Jul 2022 21:57:04 +0200 Message-ID: <1236061d-95dd-c3ad-a38f-2dae7aae51ef@o2.pl> Date: Mon, 4 Jul 2022 21:56:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.0 From: =?UTF-8?Q?Mateusz_Jo=c5=84czyk?= Subject: Re: [PATCH v1] Revert "Bluetooth: core: Fix missing power_on work cancel on HCI close" To: Max Krummenacher , max.krummenacher@toradex.com, Vasyl Vavrychuk Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Luiz Augusto von Dentz , Marcel Holtmann , Paolo Abeni , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20220614181706.26513-1-max.oss.09@gmail.com> Content-Language: en-GB In-Reply-To: <20220614181706.26513-1-max.oss.09@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-WP-MailID: 9db1f93d5b2afb0feb3e16567f79cb6e X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000001 [EeJ1] 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,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 W dniu 14.06.2022 o 20:17, Max Krummenacher pisze: > From: Max Krummenacher > > This reverts commit ff7f2926114d3a50f5ffe461a9bce8d761748da5. > > The commit ff7f2926114d ("Bluetooth: core: Fix missing power_on work > cancel on HCI close") introduced between v5.18 and v5.19-rc1 makes > going to suspend freeze. v5.19-rc2 is equally affected. > > This has been seen on a Colibri iMX6ULL WB which has a Marvell 8997 > based WiFi / Bluetooth module connected over SDIO. > [...] Hello, commit ff7f2926114d ("Bluetooth: core: Fix missing power_on work cancel on HCI close") causes problems also on my laptop (HP 17-by0001nw with a Realtek Bluetooth adapter). I have Bluetooth disabled by default on startup (via systemd-rfkill.service ) and vanilla kernel 5.19.0-rc5 fails to suspend (the screen turns black, but I am then able to touch a trackpad and log in). Reverting that commit on top of 5.19.0-rc5 fixes the issue. On bare 5.19.0-rc5, after startup, the kworker/u9:0+hci0 process hangs indefinitely with this stacktrace (obtained through "cat /proc/163/stack" )         [<0>] __flush_work+0x143/0x220         [<0>] __cancel_work_timer+0x122/0x1a0         [<0>] cancel_work_sync+0x10/0x20         [<0>] hci_dev_close_sync+0x2a/0x550 [bluetooth]         [<0>] hci_dev_do_close+0x2a/0x60 [bluetooth]         [<0>] hci_power_on+0x91/0x200 [bluetooth]         [<0>] process_one_work+0x21c/0x3c0         [<0>] worker_thread+0x4a/0x3a0         [<0>] kthread+0xcf/0xf0         [<0>] ret_from_fork+0x22/0x30 It appears that the hci_power_on() function calls hci_dev_do_close() in this block:     if (hci_dev_test_flag(hdev, HCI_RFKILLED) ||          /* [...] */ ) {         hci_dev_clear_flag(hdev, HCI_AUTO_OFF);         hci_dev_do_close(hdev);     } else /* [...] */ which then calls hci_dev_close_sync(). With the problematic commit, that function calls        cancel_work_sync(&hdev->power_on) which tries to cancel the execution of the hci_power_on() function's itself, which leads to a deadlock. When trying to suspend, the "/lib/systemd/systemd-sleep suspend" process hangs on         [<0>] hci_suspend_dev+0x87/0xf0 [bluetooth]         [<0>] hci_suspend_notifier+0x38/0x80 [bluetooth]         [<0>] notifier_call_chain_robust+0x5e/0xc0         [<0>] blocking_notifier_call_chain_robust+0x42/0x60         [<0>] pm_notifier_call_chain_robust+0x1d/0x40         [<0>] pm_suspend+0x116/0x5a0         [<0>] state_store+0x82/0xe0         [<0>] kobj_attr_store+0x12/0x20         [<0>] sysfs_kf_write+0x3e/0x50         [<0>] kernfs_fop_write_iter+0x138/0x1c0         [<0>] new_sync_write+0x104/0x180         [<0>] vfs_write+0x1d7/0x260         [<0>] ksys_write+0x67/0xe0         [<0>] __x64_sys_write+0x1a/0x20         [<0>] do_syscall_64+0x3b/0x90         [<0>] entry_SYSCALL_64_after_hwframe+0x46/0xb0 My device is: Bus 001 Device 005: ID 0bda:b00b Realtek Semiconductor Corp. Bluetooth Radio So probably the commit ff7f2926114d ("Bluetooth: core: Fix missing power_on work cancel on HCI close") should be reverted or corrected. Greetings, Mateusz Jończyk > Signed-off-by: Max Krummenacher > --- > > net/bluetooth/hci_core.c | 2 ++ > net/bluetooth/hci_sync.c | 1 - > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 59a5c1341c26..19df3905c5f8 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -2675,6 +2675,8 @@ void hci_unregister_dev(struct hci_dev *hdev) > list_del(&hdev->list); > write_unlock(&hci_dev_list_lock); > > + cancel_work_sync(&hdev->power_on); > + > hci_cmd_sync_clear(hdev); > > if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) > diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c > index 286d6767f017..1739e8cb3291 100644 > --- a/net/bluetooth/hci_sync.c > +++ b/net/bluetooth/hci_sync.c > @@ -4088,7 +4088,6 @@ int hci_dev_close_sync(struct hci_dev *hdev) > > bt_dev_dbg(hdev, ""); > > - cancel_work_sync(&hdev->power_on); > cancel_delayed_work(&hdev->power_off); > cancel_delayed_work(&hdev->ncmd_timer); >