From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 865373587A4; Tue, 16 Dec 2025 12:03:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765886629; cv=none; b=OhWGu0CymZmhChcYDUbIsY0SCTZRDimilCuOb3BDYAnCfkJ7mPbU1cJ1G6qGoeXRkJ7n9RNJHSVcQ+r8PnnlfPpC1fltje2cnonHVu4PF+Kd5ulQF7pdN04PPK8DsHseoSwrUj+Cxbs9o+RlRu8wPdjsUT/TGUavg0el7R/J0YQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765886629; c=relaxed/simple; bh=M7elHLJd/lwesp9JTCXLzUd1LELlzkQfjSHigsgy0CU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kjHzYnxn3A043+Y3+50R2fEHDKerDg1jdvebkkYZd9u1kjKK+n595cEmcFWDuZx3qidKJCpDVkCjbmLCDxh66OOdkpmPo01E/c7dmzkz+FAcD7gaCHF47ofX7YpF3jVqAey0mRrArfsxZBCVduSCXf4rVjWdJ338SWsOPW87Kzg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WrZO+7VH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WrZO+7VH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9443C4CEF1; Tue, 16 Dec 2025 12:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765886629; bh=M7elHLJd/lwesp9JTCXLzUd1LELlzkQfjSHigsgy0CU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WrZO+7VHpNKyQ57Lm5vqswQ4hGY+7+l6WC4323sJcjyWBxzwwgixOyq3+31jei3Zb Lk2WyWjH5tbrdoaX7xpowVWxtkpwNy2bWIOgUvZMydw2m33cGEIyzUbpcJkq2M6BqJ CdlRP0dU5RTnENVaViHCIv76dI3CaWeY/qitwtUI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cong Zhang , Jens Axboe , Sasha Levin Subject: [PATCH 6.17 460/507] blk-mq: Abort suspend when wakeup events are pending Date: Tue, 16 Dec 2025 12:15:01 +0100 Message-ID: <20251216111402.112974071@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251216111345.522190956@linuxfoundation.org> References: <20251216111345.522190956@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Zhang [ Upstream commit c196bf43d706592d8801a7513603765080e495fb ] During system suspend, wakeup capable IRQs for block device can be delayed, which can cause blk_mq_hctx_notify_offline() to hang indefinitely while waiting for pending request to complete. Skip the request waiting loop and abort suspend when wakeup events are pending to prevent the deadlock. Fixes: bf0beec0607d ("blk-mq: drain I/O when all CPUs in a hctx are offline") Signed-off-by: Cong Zhang Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 19f62b070ca9d..3e9f82c9a89d2 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -3721,6 +3722,7 @@ static int blk_mq_hctx_notify_offline(unsigned int cpu, struct hlist_node *node) { struct blk_mq_hw_ctx *hctx = hlist_entry_safe(node, struct blk_mq_hw_ctx, cpuhp_online); + int ret = 0; if (blk_mq_hctx_has_online_cpu(hctx, cpu)) return 0; @@ -3741,12 +3743,24 @@ static int blk_mq_hctx_notify_offline(unsigned int cpu, struct hlist_node *node) * frozen and there are no requests. */ if (percpu_ref_tryget(&hctx->queue->q_usage_counter)) { - while (blk_mq_hctx_has_requests(hctx)) + while (blk_mq_hctx_has_requests(hctx)) { + /* + * The wakeup capable IRQ handler of block device is + * not called during suspend. Skip the loop by checking + * pm_wakeup_pending to prevent the deadlock and improve + * suspend latency. + */ + if (pm_wakeup_pending()) { + clear_bit(BLK_MQ_S_INACTIVE, &hctx->state); + ret = -EBUSY; + break; + } msleep(5); + } percpu_ref_put(&hctx->queue->q_usage_counter); } - return 0; + return ret; } /* -- 2.51.0