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 EF680C71136 for ; Tue, 17 Jun 2025 08:48:48 +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=XLFRjcKqUSnWRx2ze+Fkwivg9FSFg5qaYm4YFCn81x0=; b=Q5j+sCR1S5jT709g42IdNnqTaE FUXD3t4GbNEHNHWDYMwV2l7TKzCABjVkjAUt6VkKw49CnrwR7ZYhqL9iEArhe5s0gBK28rhVDewUT zNYigrDpXx9msCtP6KJZqTfhyJoWB72nzrb9aQk0J2bHzcovNNgn8YP7lT4e4E6XlrptU6xNWmzEt Fm7NhEEnUCOys5CxfT8Ko5LMZ3RFqCZ8jDP11mdjcic3F7IIiFGhyc9hnwNTcnYNfHYGEf8ahmjoa 7eF13FZ2hk0GYXtaDwYC16o5pxMNeiWt6J/sESfJ5FUVqg+GZO3H3vwMZGUUTnAsy+uH+FwSkZewJ ja3OcVoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uRRzs-00000006e7d-34Bu; Tue, 17 Jun 2025 08:48:48 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uRRw4-00000006dLF-2Roy for ath12k@lists.infradead.org; Tue, 17 Jun 2025 08:44:52 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id C962E629EF; Tue, 17 Jun 2025 08:44:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53BBDC4CEF6; Tue, 17 Jun 2025 08:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750149890; bh=+MUNkeZX4lfJkqkDUxXwsfHCfiNVsvvgpyJ+FU0nu4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eiG6I71H+yRSGnNvzn7KWYE8hPyV9oZX8el5NBvINVCLx3keaZadfp29ObB/xOMkj iUIzGcANaK/yegxiFSNfBhbfL2snUKvqJjgCPLRmIO4+86pn6DPwwjN77tAXxFr4uu 5DM138I5Wq5X0WvqWV7qTlsDqdKjhqWzdfSB7OStiMnTw8gH7Zd/znkplpdRWwJyKT 20C5uHpXLAQmaM4Y9LC6/ZFQ74sLFb89zOPLtmGnLj6nGZZ90Xcd9FviR2iYv9CvH5 sE7PJ+wcUAoLy/WKIT6HRNSsC5q7GGWVxBU+PLh9eQdO7hYeAbC38Pp8qMwoajy/B9 d9z+1vl7IRMBQ== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1uRRw0-000000003ms-0xB1; Tue, 17 Jun 2025 10:44:48 +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 v3 3/4] wifi: ath12k: fix source ring-buffer corruption Date: Tue, 17 Jun 2025 10:44:01 +0200 Message-ID: <20250617084402.14475-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617084402.14475-1-johan+linaro@kernel.org> References: <20250617084402.14475-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 726969cfcaec..d8193d9577bb 100644 --- a/drivers/net/wireless/ath/ath12k/hal.c +++ b/drivers/net/wireless/ath/ath12k/hal.c @@ -2178,7 +2178,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; @@ -2187,6 +2191,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