From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C8B3C5B559 for ; Wed, 4 Jun 2025 14:45:53 +0000 (UTC) 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-Owner; bh=Xro+qNKwIeOOz/QbrjHH5ONYh4w3NLvdrnLonQzrdBY=; b=UhTWZd6ucmWsZJTdnOPi/9uUHi pVfTr5idUOgMTswDkvLjiTC2tQ7FmJ2P0TCKtRYIgE369qtBCdgybHBrob35l4nML0XLq+p+0JxOe Xt6ennpHUZ2QCWyxSBNHyT/70DcqomwFJuKRk4u4DDUUS3At7d38NprKmiwNfsvLQrqN9WX9g4qAy pIqa7vR72nEbu/nbxWWEE32F0C4K+FLV9sH3nccJmJbcQFkdJ+uBHxfZMRvRM08GJmGgVLK+XPvjx Qr92pAqcA7Y+bARcwf+ah/0KDqRBKd7zE2AkreQfQDZU/C7QgrrZfziiCB4pcqi23Oic8qIDvqEmr /KgBJjmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uMpNJ-0000000Dc22-0qZq; Wed, 04 Jun 2025 14:45:53 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uMpNF-0000000DbzC-3hpP for ath12k@lists.infradead.org; Wed, 04 Jun 2025 14:45:51 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 5C9B84A861; Wed, 4 Jun 2025 14:45:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36462C4AF0B; Wed, 4 Jun 2025 14:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749048349; bh=BgxRJHC6oF+kTQhHO5k63lZHrNXK0+LyXcoaTmPrZAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ilomGt0vO7G0ZKfNt9shwPqg1z2eu3gj4KxKipyJrApnoMZAXv8SbnhdgQisKqfDV 4eI2vhV8dwVK8/7vx5GcikdI4DFHVV9wHsca+7pypVYjXQ7jqXVDLHjK0mRJ6noK+B p8Mg5/eT4uc3Xvxeq24S8rvwdBgn1OGRUzi2ldq4ILg+ZztsvrIvz42FQCDQM+mHG7 QQUSixi7xWA8KfhS0c/lP6vjmaJOyApxOtZFGkO7lQAWN9hIEP7lJzagKMopW/wYjQ ripE/n4T/QHD2yFpDvkBN4fjedDsilTX6dOpRy/wqmJBzqjl4EzsEFfqFmMt89pPvw EnmGNbvtXumNw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1uMpND-000000007Od-1Vqg; Wed, 04 Jun 2025 16:45:47 +0200 From: Johan Hovold To: Jeff Johnson Cc: Miaoqing Pan , Remi Pommarel , Baochen Qiang , linux-wireless@vger.kernel.org, ath12k@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 3/4] wifi: ath12k: fix source ring-buffer corruption Date: Wed, 4 Jun 2025 16:45:08 +0200 Message-ID: <20250604144509.28374-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250604144509.28374-1-johan+linaro@kernel.org> References: <20250604144509.28374-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250604_074549_951710_459734A6 X-CRM114-Status: GOOD ( 11.03 ) X-BeenThere: ath12k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "ath12k" Errors-To: ath12k-bounces+ath12k=archiver.kernel.org@lists.infradead.org Add the missing memory barrier to make sure that LMAC source ring descriptors are written before updating the head pointer to avoid passing stale data to the firmware on weakly ordered architectures like aarch64. Note that non-LMAC rings use MMIO write accessors which have the required write memory barrier. Tested-on: WCN7850 hw2.0 WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Cc: stable@vger.kernel.org # 6.3 Signed-off-by: Johan Hovold --- drivers/net/wireless/ath/ath12k/hal.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath12k/hal.c b/drivers/net/wireless/ath/ath12k/hal.c index 8615578bb802..1e2d13cc2d19 100644 --- a/drivers/net/wireless/ath/ath12k/hal.c +++ b/drivers/net/wireless/ath/ath12k/hal.c @@ -2161,7 +2161,11 @@ void ath12k_hal_srng_access_end(struct ath12k_base *ab, struct hal_srng *srng) if (srng->ring_dir == HAL_SRNG_DIR_SRC) { srng->u.src_ring.last_tp = *(volatile u32 *)srng->u.src_ring.tp_addr; - *srng->u.src_ring.hp_addr = srng->u.src_ring.hp; + /* Make sure descriptor is written before updating the + * head pointer. + */ + dma_wmb(); + WRITE_ONCE(*srng->u.src_ring.hp_addr, srng->u.src_ring.hp); } else { srng->u.dst_ring.last_hp = *srng->u.dst_ring.hp_addr; *srng->u.dst_ring.tp_addr = srng->u.dst_ring.tp; @@ -2170,6 +2174,10 @@ void ath12k_hal_srng_access_end(struct ath12k_base *ab, struct hal_srng *srng) if (srng->ring_dir == HAL_SRNG_DIR_SRC) { srng->u.src_ring.last_tp = *(volatile u32 *)srng->u.src_ring.tp_addr; + /* Assume implementation use an MMIO write accessor + * which has the required wmb() so that the descriptor + * is written before the updating the head pointer. + */ ath12k_hif_write32(ab, (unsigned long)srng->u.src_ring.hp_addr - (unsigned long)ab->mem, -- 2.49.0