From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8022360A262A for ; Wed, 11 Nov 2026 12:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Wm0a8Sot; dkim=pass (2048-bit key) header.d=deq.rocks header.i=@deq.rocks header.a=rsa-sha256 header.s=securedbylima-20251205 header.b=JP0bobUK DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=T7WXBDAH2fUx4nJrxNoYAO2bnzUVegPGfcbrAyJ9e80=; b=Wm0a8Sot62aXn+ /LMg65NapG/5LWZG/p4qPGc6V67kFiecTt8YQ+xSsH7UYePN7AqYPwAoVEenMYGHN5zCIeQGdTmuy V9pJRoHGoaA+5moCP08X2EjffhODul8wh4a5Gs2PfUBl+A/9YmZPvrIUl5tN3TeXJcW1cksTSWsFW 1L/7LT5CtbpoZ5enjKmMyMSg/F9r+EhWvObFlek6pRwbhRWsyEuGGdLnxbBoaPDdqBQoQGVGRUFPF QjcRAuuZIa8tpaWgnaLmc47pMVqmNpOwroD5rnQfz+/8fqicSURjuXFuJAqikG5koOUES5D9TIb8E e8d7R9HjxOh2Fea/4Wrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xR72e-00000006be1-35mG; Wed, 11 Nov 2026 12:03:04 +0000 Received: from mx5.mail-out.lima-city.de ([91.216.248.207]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xR72a-00000006bZy-0yf5 for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2026 12:03:03 +0000 From: Andre Eikmeyer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=deq.rocks; s=securedbylima-20251205; t=1794398577; bh=TvVgj1zdQCrisXNDq2ObvYC27hGriB3NRJwIIF7WrdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JP0bobUKG5WfYIHovH70OWguue48x9bN9+1MXbELdgGehV85wlJv1dQ5sAGskbzmN ix0rOKmZW25T0pdtHuER7Te/9UhMvE8LDo1INqVK70v/UXHB3pLB4IZB7FDhp+Z6rC RDFtph2QN+dD3CG9lapculM1GEchyI6+6CEBJyjV/TQxFaRybYYZQ6a4DqGrmIKwLt adePO1dPmmIUOnbbxy2GUgxLHKy0OVpF/buVJI6ySYYWhbM6ywOkLslUnQi4fjhUMm 5CQdGTmgGDRY65nboalVt03YYV6scV04VbHXcg5q2pkJYmYbCdlIPpkW0k4W7MDhCE 1owmnGln/Sy+A== To: sven@kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: j@jannau.net, neal@gompa.dev, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Andre Eikmeyer Subject: [PATCH v2 2/3] Bluetooth: hci_bcm4377: probe again after a resume through firmware Date: Wed, 11 Nov 2026 13:02:47 +0100 Message-ID: <20261111120248.21062-3-dev@deq.rocks> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261111120248.21062-1-dev@deq.rocks> References: <20261111120248.21062-1-dev@deq.rocks> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261111_040300_569552_DE58A432 X-CRM114-Status: GOOD ( 16.15 ) X-Spam-Score: -2.8 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The BCM4377 is powered off during ACPI S3 and loses its firmware. On resume the driver only unquiesces it, so every command times out. When the platform firmware handled the resume, probe the controller again from a work item and skip the ring teardown messages to the lost firmware. Suspend to idle keeps the quiesce path. Signed-off-by: Andre Eikmeyer --- drivers/bluetooth/hci_bcm4377.c | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/bluetooth/hci_bcm4377.c b/drivers/bluetooth/hci_bcm4377.c index da0a48c2be3..4e3630774c0 100644 --- a/drivers/bluetooth/hci_bcm4377.c +++ b/drivers/bluetooth/hci_bcm4377.c @@ -16,6 +16,9 @@ #include #include #include +#include +#include +#include #include @@ -566,6 +569,9 @@ struct bcm4377_data { struct pci_dev *pdev; struct hci_dev *hdev; + /* set when the controller lost its firmware during system sleep */ + bool fw_lost; + void __iomem *bar0; void __iomem *bar2; @@ -1017,6 +1023,11 @@ static int bcm4377_destroy_completion_ring(struct bcm4377_data *bcm4377, struct bcm4377_destroy_completion_ring_msg msg; int ret; + if (bcm4377->fw_lost) { + ring->enabled = false; + return 0; + } + memset(&msg, 0, sizeof(msg)); msg.msg_type = BCM4377_CONTROL_MSG_DESTROY_COMPLETION_RING; msg.ring_id = cpu_to_le16(ring->ring_id); @@ -1107,6 +1118,11 @@ static int bcm4377_destroy_transfer_ring(struct bcm4377_data *bcm4377, struct bcm4377_destroy_transfer_ring_msg msg; int ret; + if (bcm4377->fw_lost) { + ring->enabled = false; + return 0; + } + memset(&msg, 0, sizeof(msg)); msg.msg_type = BCM4377_CONTROL_MSG_DESTROY_XFER_RING; msg.ring_id = cpu_to_le16(ring->ring_id); @@ -2432,11 +2448,54 @@ static int bcm4377_suspend(struct device *dev) return 0; } +struct bcm4377_reprobe { + struct work_struct work; + struct pci_dev *pdev; +}; + +static void bcm4377_reprobe_work(struct work_struct *work) +{ + struct bcm4377_reprobe *reprobe = + container_of(work, struct bcm4377_reprobe, work); + int ret; + + /* + * Probing stays blocked until the system resume completes, the driver + * core then retries the deferred probe. + */ + ret = device_reprobe(&reprobe->pdev->dev); + if (ret && ret != -EPROBE_DEFER) + dev_err(&reprobe->pdev->dev, "re-probe after resume failed (%d)\n", + ret); + + pci_dev_put(reprobe->pdev); + kfree(reprobe); +} + static int bcm4377_resume(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct bcm4377_data *bcm4377 = pci_get_drvdata(pdev); + /* + * The controller is powered off when the platform firmware handles + * the system sleep, as with ACPI S3 on x86 Macs, and comes back + * without its firmware. Probe it again. + */ + if (pm_resume_via_firmware()) { + struct bcm4377_reprobe *reprobe; + + reprobe = kzalloc_obj(*reprobe); + if (!reprobe) + return -ENOMEM; + + bcm4377->fw_lost = true; + reprobe->pdev = pci_dev_get(pdev); + INIT_WORK(&reprobe->work, bcm4377_reprobe_work); + schedule_work(&reprobe->work); + return 0; + } + iowrite32(BCM4377_BAR0_SLEEP_CONTROL_UNQUIESCE, bcm4377->bar0 + BCM4377_BAR0_SLEEP_CONTROL);