From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 968E3202C48 for ; Tue, 3 Feb 2026 02:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770087076; cv=none; b=u2hbG3F6vcvPDlJWWGReLMpje1tnS8S4wCcPX4u+AVXjD+d7Ihiv5CoZn0t2j+ZQUPCXhzgoStzVa91nh0MxoaUQFWiiizApOozTz1eu5Cy85m6BEQD3o/gHe3uyhu7px5jituxiLnrTwl/PS17AxCLzJsOR8uFy7UeulTl5OdA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770087076; c=relaxed/simple; bh=3RVhIHfJaJ0Sbuw4hJxBerQ9kkHrooWsvog0QFBpaaE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=taRI5UqCJhyUw4RG1YxUlv0f3AHneRViYZYA7ce3/h9/Rftmq+7cOH9Xq4gtrXqK7Co9u7NR3yX7xoq10ElahmBbsr7oGgtO8GPypTXfvMaNd2kkUDOe5SsLFqdOVe8ziN1BxBzaSl1XKWRr/Edq34yExlW7qOp9of9vBlqfwOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=CDWNTqpU; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=WaxZHuMl; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="CDWNTqpU"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="WaxZHuMl" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 612K7eTL3459139 for ; Tue, 3 Feb 2026 02:51:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 9zRpTKaQE4Hsgsve7rWWRdaOLoxINXvg2jaj1Jl+N9w=; b=CDWNTqpU8jZQt7TC 29C0WswuRMp0sVkGD5QqOiAStR97M6EfZNmnBxfwJHeHM7DuzWuuBbsDjDpC5MHQ eevv2auRdRoaoibk/kjvfHUN9jJmPYkbyO0dIUqkQy3UT4CkOHQLqttjhwP/ozt8 bFPqc5WmZh1Yc5i+9UbHKwYXx48kku19kQrPi22nzysAD573hrsTYONDHIIANdCF NBphsLxxwhJ9q26CqyLUTDi+7yPTxM/5eeXFJFvTK0Cx7Dx8ycwlkWUfcm4nYSAM V/fzqFky9kMRugeZkf7Ktz50ySIDFlJEKVrIU3QuU46/DQUKsEht4QrEROLyH3Ad O4IVgg== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4c2trbjjrm-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 03 Feb 2026 02:51:13 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2a78c094ad6so52752545ad.1 for ; Mon, 02 Feb 2026 18:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1770087072; x=1770691872; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=9zRpTKaQE4Hsgsve7rWWRdaOLoxINXvg2jaj1Jl+N9w=; b=WaxZHuMldjd4rMOsFHSeq6qCQHkpDGsgteS6mkBHU1aKtRqrGrws8aX82MDJPUNuGQ udJchUkzj21OC5oaSHQY7UrvTiMbXwLBPm+jLKJm+sugPbldwCWT2hbOIXnLCMUeWIYf oKikOeZvkpYT6KhWZm/l30llUiVBJ0iIaqruNXCXrGAH97hprRKvVB3j6HYgv/AeIqeE oBmQLNqwX3aHxNc0/kgcQutDFf0KcRr4bu4Xw1cX+Xv2EqiPc1mrdTUZ8gxBisCRPuLz W0D6A4V6fLrKMUm9Z/3ZL+z7IuNhYTofb1cBkOFn4ka6I6pOfYIoAspaA3Y2INtQKbjF hOPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770087072; x=1770691872; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9zRpTKaQE4Hsgsve7rWWRdaOLoxINXvg2jaj1Jl+N9w=; b=CgTivIvKXvEirOE78fmBeIgNhgw3owk1MFTn0X/zibseUkqhNEmB3Fa7xUgH6sflbk heFLEiMn3srLRiKu2eEeVNHYis8JPvzRVBegOUXclSRd3J4UWn/XgNXQc5aq/hX3DMcH ZEy/o5Rl9QY4Ttm4j0yJZcyAjcUcelUmsYspfERjR8j1EFhgyR4pZFEr9+AOi1sQT8yx N3vtQ1dVX2bVFCo6a3PSMvCSdJo1yohpAfbdb+PhmrzPIBb0PpPRNLGvRi8UE5L0RHGY U/BCndj1NYoD/yidr4g62ZTQuN7FpLZgm/RVp2q0FXjWZvmgkhv5YeaSTy+Jvxjx886c TYCQ== X-Forwarded-Encrypted: i=1; AJvYcCVYfJseVgPYHZf6yRcQnINBjVF0tZkyz7imaSQfqRMAJWgkwrz/zJNPLEqjLOGMc3XSNDK8chltWjaOmlI=@vger.kernel.org X-Gm-Message-State: AOJu0Yyj8ekReAvoR19ZPOMKLiC2rObR9mZV46QKwTBzhQyzYhflOPrj Pn/G4b30ZZW0pe520ehYU2bC3TP2Ieo/Efnw2PwpElKgvZXdJ2gMfiJGn9v/t2Ml7GD98MWiR66 FCXd42n+4qaecDWX0gWsC+qm6IjothdAmXep17AuSXai6JJXE3u22Xp01xsHhurH+H1Q= X-Gm-Gg: AZuq6aJ1W0908rdKqLRhHS+CIhGCcSYMx9AwxQwmn3kQbEzzlKQz+31mkX7iesalCWI FCMTqVD/Elo4pnVbUfpvRV5+flnNQKfdmhTHd++YrAap06wmcym//y94ZCFiTxGKbjFpVMNFxCA 0G/QrbMZu9i6Se8qSRosIfOjncIYx++FQx9MQVclL/3WmuUVRKJLKu3q9uYg8frVnf/lpcak0eQ vxj5Q8XZNjIn/F+AN01C4cIkpaYJRB2YcpK+3wyyfAqs37+wetiPT9IHoVWF/nFTsLjGJzFLPQS 11zWm2+sJCqINUU1PVC6CT+6HXbFjPmkWU8aKAjvWDUKyUdH8np/vM+dMsBsqhCbyxUNog5obqO hjl+nBlv0ihbEDx1hc3bEAuNT6OyhysligUbeZAyWalBr7LFOGXLiDW8us7Av5W2CfkfZsjeDW6 ifjPhd9A== X-Received: by 2002:a17:903:b4e:b0:295:24ab:fb06 with SMTP id d9443c01a7336-2a8d7ee71e8mr129794955ad.22.1770087072351; Mon, 02 Feb 2026 18:51:12 -0800 (PST) X-Received: by 2002:a17:903:b4e:b0:295:24ab:fb06 with SMTP id d9443c01a7336-2a8d7ee71e8mr129794715ad.22.1770087071876; Mon, 02 Feb 2026 18:51:11 -0800 (PST) Received: from [10.133.33.50] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a88b3eec76sm161929225ad.19.2026.02.02.18.51.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Feb 2026 18:51:11 -0800 (PST) Message-ID: <125f0ecb-79a5-4806-aa93-aecaf937885e@oss.qualcomm.com> Date: Tue, 3 Feb 2026 10:51:05 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] wifi: ath12k: fix CMA error and MHI state mismatch during resume To: Saikiran , 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 References: <20260202151720.49904-1-bjsaikiran@gmail.com> From: Baochen Qiang Content-Language: en-US In-Reply-To: <20260202151720.49904-1-bjsaikiran@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: Yo3jQpd8Oa2OdXTbsVFAlRDcgUMlnXh6 X-Authority-Analysis: v=2.4 cv=dcmNHHXe c=1 sm=1 tr=0 ts=698162a1 cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=pGLkceISAAAA:8 a=RdEeBsXcWOgqNyDsrIIA:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-GUID: Yo3jQpd8Oa2OdXTbsVFAlRDcgUMlnXh6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjAzMDAyMSBTYWx0ZWRfX3UUyya7cOGlM 5E+ijEtXaIisTpP0fWSLkuyXqZ/rzf/HyJPKPHHP2uYGeonHFtsNPR/1MBZqiz5Co3YQmkL4p3l f0gmMJG9yokKa8JvKPpG3TwenD6mp0c3rqhldHX9ioJ0YJrhaNTRFy30/xJVR71bvTcySByHJ5L nXcx5OC3tqgkx0TJePRcbDgzts24DcZYR1bDaLI3rb/lJfLud6sxkCN8nUlZQ5pDwsZfsKVuKWZ ZqDQeKS9twtq9r03XDfO3oLVZlDYdmkqQi+eN0p9/7T9nKiMbaxN5zMWSitvY8Y/508/hDELdoH RCdWpqqhKlC42P48daCMNp58/2I9Zl1gMxrpfJL1e6pZciLV3rtQRrfyp8ZdsbZNzUVLNkSsZX8 MVwTxcf6yUlN0OxwuJJKMmlDOW+6alAyPHmLdgVXJFy2C3rdFDiFYB9GpA1dwBAjMGaqJHqCCX5 4HQ2+LF7KuRi0u24wxQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-03_01,2026-02-02_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602030021 On 2/2/2026 11:17 PM, Saikiran wrote: > 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). How, FBC image and RDDM image get re-allocated at resume, no? > > 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/ath/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) > > ab_pci->mhi_ctrl->timeout_ms = MHI_TIMEOUT_DEFAULT_MS; > > - ret = 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 = ath12k_mhi_set_state(ab_pci, ATH12K_MHI_INIT); > + if (ret) > + goto out; > + } > > ret = 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) > > 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); > > - 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); > } > > void ath12k_mhi_suspend(struct ath12k_pci *ab_pci)