From nobody Sat Feb 7 04:47:30 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 206A1248868 for ; Mon, 2 Feb 2026 15:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770045449; cv=none; b=jBvcO2GlVg5JaxlgvGP0Rlc0TNdg3HMbXZdlnDOXwr1fbcBBdEvdGwKALUdoY5CkDCuhLCZ78gBsHXzzIh2KXHiTSErnDNhPlOrE18pujZTpGekm3nn3RRXs+APfJapwfw+5Qw2+aebMNlzPk240Ab2clHN5g6rE7ttSrAThp38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770045449; c=relaxed/simple; bh=lSH4WdJZQFQKbcuOTcqByxROAsgttdinJuGz3TKVfQU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BnXwCMuTzRLqVjPoWyK+BpirurBpGSjVAdsWY3fSbr6he+n5rf/bqXVEH/qhFwK30qx/hbNkXTF9lQ2D7VScW9p2Rvam7zQyThR6Mby9CQ2jlvPD2uGcX/rtKjDRH8scGwYbofhZKd3ZNvF+G+EBVy9iRR7fKGeRz+osdB0NbTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lNzlokGC; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lNzlokGC" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-823081bb15fso2370961b3a.3 for ; Mon, 02 Feb 2026 07:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770045447; x=1770650247; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VUARgzGPJhRK4HrRb+3HfBCK/Wz2+3KoUtSkwanfWJY=; b=lNzlokGC6j/ZdoNNGXsVcFhFugiSeNN20OHJh2yg0aceVHgPTKmF3laego62adn9AD 00nFjQbqxKCqF8SxOoRDidgzD5cLuz/tji0s65OpwTkcME/Yy1lVYCdKJti5QQE+6PNQ zBlDGaJL6/7+hD/RMy1qJhG/X13iG1ADzCQg4b8iocwamsXhS1jaDNQ2Qj7RQfGiHpMe f2I5T/1Faju8Nm0FdJKJuRHUUj1IO7+lV3a6V0VYzK/5dqlhAy4f8EhdM5UAraOad9fQ /6DC6ZPTmpuG93VZCLZo1RFbdl3RekidijC2yLum3gBloqRY9O3lYxRAD1/cX0scBc/V 4AEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770045447; x=1770650247; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VUARgzGPJhRK4HrRb+3HfBCK/Wz2+3KoUtSkwanfWJY=; b=Na4Joa2mAdB8h1nkjhKaOYxw7Y3XPlAUzUcWE8p/PiTmn2ZP7ao4+04/DTOjfTFE72 wXP9zq9+Qlj9NGie+KkdWwf8HXDNo158OF9Sa06FyF+oHPjDPoOSp3VotHm4NhXX+Jr3 wdzDoaoU5giKOymDLASuf+JoedR/oRl/J54/1xlOGVKt3iEdmV7VhdEvJ6ZGASdqTODB slOSH9lx3XFZpn5jtCm6Oe44/vmse7TnROwDasWZZ4SnziXyvVPX9HqJ1nUBbm4Y7C4g SJdI8mz6I17AHBUdFoQE+yEMQs+bqLOsqHL4iBZd4l8nGP3lcuUQQhcMwb+t6AGiIkPn thyQ== X-Forwarded-Encrypted: i=1; AJvYcCU4KgZbk6Ucc37N4lPxDYyij773KCZMjIFTq6AAOpXAH9ZsrdPQzeJK889e/Q55Ve+Hnu0xInKg6sLiMlE=@vger.kernel.org X-Gm-Message-State: AOJu0YyezX85iPrDPCkclnW7SCiVpBdVqrjioN+I1vnxqJx6kQF5EHVo 0F4FZJaZKMiRxurSab3Wg78SmWhOAHBA8MA8QdoSacBy+gZkNU70Sz3F X-Gm-Gg: AZuq6aKUnMikKQsy32aoYsfD5aTye+Ls+CG25lkNQjA3ve5sOtOP2vTWGkvv8gS+jot HX4P9+5388TPYfkYlrt17X0lUVQVuIpcui4thwFJk4VQMCbzDiPFZl67H9bEO5X1T4mMC7sAwh5 67V4gX3LnW1axVJKL5KnQjYNSeyMfRXE0TjD3Lq6nKet2pKnOQVC5ZzVQbbLUjSAq0LB4/KQ0fQ bBGQ5BV0Oo8EwdGhkzIhuD3vLoY1h8dJnNyd6xmEqyqaOn1WIywlfXc5dOP2hnQWipG95Iv3ZSx DhYpR372CChjXgfrHQcmGp/5hmJcmxPW2J1t646F1wt4kDeH45scZ0oXq46HB7XrC/9c0gBNUMS ZTrySnuX+sMlJ5Kypr8uFwoaPR0FL/EBUDzjpRnwKT8Bddj2WzyzP3wVFKp7wPUUkF+P2tfVc11 Bm69s3IHlmlrxnUzkk4OX8KhoAQy1tIQjNTg== X-Received: by 2002:a05:6a00:3026:b0:7e8:4471:ae6d with SMTP id d2e1a72fcca58-823aa7376d1mr11367711b3a.57.1770045447289; Mon, 02 Feb 2026 07:17:27 -0800 (PST) Received: from saikiran-Yoga-Slim-7-14Q8X9 ([2402:e280:3d17:646:6b:a50d:4972:6cd4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82379b58f38sm16843432b3a.24.2026.02.02.07.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 07:17:26 -0800 (PST) From: Saikiran To: jjohnson@kernel.org, kvalo@kernel.org Cc: quic_bqiang@quicinc.com, linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, linux-kernel@vger.kernel.org, Saikiran Subject: [PATCH] wifi: ath12k: fix CMA error and MHI state mismatch during resume Date: Mon, 2 Feb 2026 20:47:20 +0530 Message-ID: <20260202151720.49904-1-bjsaikiran@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 8d5f4da8d70b ("wifi: ath12k: support suspend/resume") introduced system suspend/resume support but caused a critical regression where CMA pages are corrupted during resume. 1. CMA page corruption: Calling mhi_unprepare_after_power_down() during suspend (via ATH12K_MHI_DEINIT) prematurely frees the fbc_image and rddm_image DMA buffers. When these pages are accessed during resume, the kernel detects corruption (Bad page state). To fix this corruption, the driver must skip ATH12K_MHI_DEINIT during suspend, preserving the DMA buffers. However, implementing this fix exposes a second issue in the state machine: 2. Resume failure due to MHI state mismatch: When DEINIT is skipped during suspend to protect the memory, the ATH12K_MHI_INIT bit remains set. On resume, ath12k_mhi_start() blindly attempts to set INIT again, but the state machine rejects the transition: ath12k_wifi7_pci ...: failed to set mhi state INIT(0) in current mhi state (0x1) Fix the corruption and enable the correct suspend flow by: 1. In ath12k_mhi_stop(), skipping ATH12K_MHI_DEINIT if suspending. This prevents the memory corruption by keeping the device context valid (MHI_POWER_OFF_KEEP_DEV). 2. In ath12k_mhi_start(), checking if MHI_INIT is already set. This accommodates the new suspend flow where the device remains initialized, allowing the driver to proceed directly to POWER_ON. Tested with suspend/resume cycles on Qualcomm Snapdragon X Elite (SC8380XP) with WCN7850 WiFi. No CMA corruption observed, WiFi resumes successfully, and deep sleep works correctly. Fixes: 8d5f4da8d70b ("wifi: ath12k: support suspend/resume") Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302 (Lenovo Yoga Slim 7x) Signed-off-by: Saikiran --- drivers/net/wireless/ath/ath12k/mhi.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/mhi.c b/drivers/net/wireless/a= th/ath12k/mhi.c index 45c0f66dcc5e..1a0b3bcc6bbf 100644 --- a/drivers/net/wireless/ath/ath12k/mhi.c +++ b/drivers/net/wireless/ath/ath12k/mhi.c @@ -485,9 +485,14 @@ int ath12k_mhi_start(struct ath12k_pci *ab_pci) =20 ab_pci->mhi_ctrl->timeout_ms =3D MHI_TIMEOUT_DEFAULT_MS; =20 - ret =3D ath12k_mhi_set_state(ab_pci, ATH12K_MHI_INIT); - if (ret) - goto out; + /* In case of suspend/resume, MHI INIT is already done. + * So check if MHI INIT is set or not. + */ + if (!test_bit(ATH12K_MHI_INIT, &ab_pci->mhi_state)) { + ret =3D ath12k_mhi_set_state(ab_pci, ATH12K_MHI_INIT); + if (ret) + goto out; + } =20 ret =3D ath12k_mhi_set_state(ab_pci, ATH12K_MHI_POWER_ON); if (ret) @@ -501,16 +506,21 @@ int ath12k_mhi_start(struct ath12k_pci *ab_pci) =20 void ath12k_mhi_stop(struct ath12k_pci *ab_pci, bool is_suspend) { - /* During suspend we need to use mhi_power_down_keep_dev() - * workaround, otherwise ath12k_core_resume() will timeout - * during resume. + /* During suspend, we need to use mhi_power_down_keep_dev() + * and avoid calling MHI_DEINIT. The deinit frees BHIE tables + * which causes memory corruption when those pages are + * accessed/freed again during resume. We want to keep the + * device prepared for resume, otherwise ath12k_core_resume() + * will timeout. */ if (is_suspend) ath12k_mhi_set_state(ab_pci, ATH12K_MHI_POWER_OFF_KEEP_DEV); else ath12k_mhi_set_state(ab_pci, ATH12K_MHI_POWER_OFF); =20 - ath12k_mhi_set_state(ab_pci, ATH12K_MHI_DEINIT); + /* Only deinit when doing full power down, not during suspend */ + if (!is_suspend) + ath12k_mhi_set_state(ab_pci, ATH12K_MHI_DEINIT); } =20 void ath12k_mhi_suspend(struct ath12k_pci *ab_pci) --=20 2.51.0