From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795441306; b=Z+rDZRh3btMZ1ptQm6/uv2o/UwbtnEErWWRFaX3w+J355mD13zDMEE0kmtKFODXQtJly Bar9nDvMXvZMkiOy027oY2tSNFAcWjcjSDpx+7B9q87K4FLQBQCAU9iThGl4nyaj+LFrY KoEKWlWbfPoo6ovVghQREXvYG8qrbR9oGobC0AA7Eg3FlqlS3WRTwEBYQjUnnnxdd1iTy D/t6mFso0Q5YNasmGpnB7qGpALRuhvwZsz4ew7p8dkC8hoBFTaI1Ug0YR4f+SWd5AlyJ4 dkkrm/lFi0GPQPOSQz/n9dAU4nbnaxEgZMD0gzjLOhNX3TxmiFkuYxF9UP6rPZnEKsQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795441306; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=4MEsM5IzBbjIGBRXvKMxihftpdxum4eZahIiTlpBLrk=; b=eCDaVQqt9VjdxwmHkc2oouVIzmk0SZv3utXIRzQ3mi8YWtKEuG1pTO0y+UeRFHewB0dm j7T0Jx8s0LIqFDTbzupLLa3YSUCR5j5SJnMQ1GPosw75Pf+0Y1ao5AeY1yyXqVyeLu/sO fsrLtzTRSoB3TlA8dk7rFSJIjQL+6XTm2WFMplgDzU0Ms0HQbLxrZXD621d152dCNSEFc QLJFfv/A8GXwk9d05YhQ9QTxbHrt+unH9zldD4n/oMOvW3yM0FkpPgRNdtOuQWYpwsK0d LZ8VQ6EiVIMEe8ltQ/F/fHazyj3LU0N+WapSPSmI7aaN8e6kB1noOOyPzTVf/u5eKTw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bairaktaris.de; spf=pass smtp.mailfrom=bairaktaris.de; dkim=pass header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=iVDwr5J6; arc=none smtp.remote-ip=209.85.208.53 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DC99606A684 for ; Mon, 23 Nov 2026 13:41:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0DC99606A684 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bairaktaris.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bairaktaris.de header.i=@bairaktaris.de header.a=rsa-sha256 header.s=google header.b=iVDwr5J6 Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-6b88bc47e23so4032901a12.2 for ; Mon, 23 Nov 2026 05:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bairaktaris.de; s=google; t=1795441304; x=1796046104; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4MEsM5IzBbjIGBRXvKMxihftpdxum4eZahIiTlpBLrk=; b=iVDwr5J6LAWlo3ns1CFFFZKFkoBL6Uzm4H+AxvKmdAEfL04oN06PAgWvrG2yvXHA86 dRzfn224UEK3CCHrIIOWsjSvcy4WDhcvzttVN+YxX5q6SB40tOujsH+ab1eGycVWjLVL KhVVWUUgwHCXIE3Riw/I7I360ZSq+Nn+l4IiMaqU4xoZE0kQwjUiDv8TgBe1qBSb2CNk 3Hs0WxE0OiBKLKLwktckFXjyNCaVYXLXDeYs0kEblTvMqcjdWLs4Uv28PPRbNfbZckdf AornlaLZ8EQFpgFItjbPmzzuIBFTAy4MwTFkupe/tJbgDia4rmG8te8GI/+oPE+jSSEC iG0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795441304; x=1796046104; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4MEsM5IzBbjIGBRXvKMxihftpdxum4eZahIiTlpBLrk=; b=jzq0sQcEgpzAuljdXCNCcX13qV6hQ0jcAbkMOyVoMZZYnIm/7yfEcj+EQrEO3F4P/Y sCt4SQBACB0tUg8K41U/E1i+0tHmYWw/2ECvMdhzpNgCkjJ0iX4ZmtNsDke+YNqRbQtw BsYJWxLQh8G7IqGTkzTCf5J/EicoD6IwIQfqTT+wxIyQhmVEL8JJK4nwEt24fhxfRBMK iUWH9Pe1jJQmup6BAQ6Gho0UIOYsHwGwVjjQ9V202wuMJa1y56lICrXPWeYNN1M9JJR2 Pl1zM2nyIxAssQ19Gp3cFs86MqSxyPkaUrpnbVQKh5Cp0P2RswmoK9wrHDIPhQP19LtN bMNQ== X-Forwarded-Encrypted: i=1; AL+hErHBmd+VGEmj2LoXHa2gyxnf9PdylUfC+VfYbJJJHW57mz5qKxroeKu3uP7q/bst50tPQ7i7MJ6Ax9evPa8=@vger.kernel.org X-Gm-Message-State: APuU4Z+uXwW+pxONSDDtOg88xATSE4KRMn98bI4t052Dcwc7W/xEDFmD xCnX32e3wRIG6SmLAzHC909WpoX6tsUgKvudFlxRYUNR2E98eR2D5X1OdCFwqU/ZoQ== X-Gm-Gg: AZFdTZelP/0ECPRjIYO8Qd3bhSbqnqN+z7RRiWScPACkCsh1DRbpeohcnmv1ueFRP0b OI0unETXruDceKAjgIchFrZJsSnOJdcoWwMLYdOfe+4fRWCjA/fGZwhHx1LMfkZQA9RH4A3hyCq KUgbZ7Kbl05xARriJ5+voBjI+BIIkR8Mzk+DjA4fRt3t1tXaCT/lP8UC/khtUObHoPhfrxGGtL9 33sUFFR7K7hwDswrsjGCIqQzrtBGlKDUnX09iPWYfEL1EsIQpXYjImiDeAazIe9rc5zVi/YeJnw o7d5lWQwSzP8cdpTZHfz7MaMyh1XQ77Qo5yK91VfkCNhdnR+5gp0zW0IXRtBJaunZl5ix6MnWcz NH5c1p9A0fPF4d8uNHCOw8TUsPeKPz4Cmgweu8Dr2HRMPbTxz9ZV0ucpHUysFlUUaaWfKOJfCE2 SSW7ijmb2JFSsTm7T39Uu/W67ObWgp/XX+xDp8t36chZSf5AODFy2LcyTxl/mzSOEvQJagGrWVS cpdyM6kFcIofSEbf/I030Vjias2BmTrMBlGTr8boTTY7HDW3QvHEAsfwECND5byHYbOhwRpjYrt oYBBFGBuW6seklC5dIacQqTO6qgLRG/+jRfN6IuDn/1aOWVr64B9bwbAyUHs1L6haP/Nhyl/uww D3rNrc7JVNcZI3zaBeyQHaIMM23e6PedMmJEXglBwfALJfjFinUPn71Qlf6HVVAAt86q1SFU+Zf rHTeGaJRslliz/4SFG4mtGD4xT4kukwrlYUkGG8s5LFaRVWrgNKgBIoHEqO82TwNYEziwBWo0ec bHawYW+RQy76/cmy+BeDtagKVaMP/OE6o0KFeptxstf0oPTyW5SVFkToS03/o/y+qv+Ks4DujCs ANVJ2+151DtEIXvthdOp08wwUXqgE7PGT8VTRWJzq1bY/yRVnncx4vVOrNcQjJ2/arMMnQBPCFp 9oa7PJtLF28msSTTrPW8= X-Received: by 2002:a05:6402:1f07:b0:6b6:e808:9711 with SMTP id 4fb4d7f45d1cf-6ba37eae2f5mr7555038a12.29.1795441304531; Mon, 23 Nov 2026 05:41:44 -0800 (PST) Received: from Desktop.tail070c67.ts.net (p200300f247012000e9a6b19fb24a0d13.dip0.t-ipconnect.de. [2003:f2:4701:2000:e9a6:b19f:b24a:d13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba370fbf0esm5339576a12.23.2026.11.23.05.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 05:41:44 -0800 (PST) From: Julius Bairaktaris To: Jeff Johnson Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Baochen Qiang , Vasanthakumar Thiagarajan , Rameshkumar Sundaram , Praneesh P , Lorenzo Bianconi , Mark Ruvald Pedersen , Rosen Penev Subject: [PATCH ath-next v1 06/10] wifi: ath11k: prefetch the buffers of the REO entries ahead of their reap Date: Mon, 23 Nov 2026 14:41:33 +0100 Message-ID: <20261123134137.718575-7-julius@bairaktaris.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261123134137.718575-1-julius@bairaktaris.de> References: <20261123134137.718575-1-julius@bairaktaris.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The REO reap loads, for each frame, the buffer table entry its cookie names, then the sk_buff the entry holds, and after the reap the processing of the frame loads the descriptor TLVs and headers the device wrote. Each is a cache miss, taken one after the other: the table entry and the sk_buff were written when the buffer was posted and are cold when the frame comes back, and the frame's lines were just invalidated. In a profile of bridged uplink at 900 Mbit/s (IPQ8074, one run) the instruction after the table load in ath11k_dp_process_rx() takes 0.72 % of all samples, the ones after the first sk_buff loads in ath11k_dp_rx_unmap_buf() 2.26 %, after the attention load in ath11k_dp_rx_h_attn_mpdu_err() 1.10 %, after the source address load in ath11k_dp_rx_h_mpdu() 1.01 % and after the load of the data pointer in ath11k_dp_rx_process_msdu() 1.05 %. On a cached REO ring the entries ahead and their cookies are already in the cache, so start these loads early: as each entry is reaped, prefetch the table entry of the one after the next and the four lines of the next one's sk_buff, whose table entry the entry before prefetched; once a frame is handed to the CPU, prefetch the first three lines of its descriptor and the first two lines of the frame behind it. ath11k_hal_srng_dst_peek_ahead() returns an entry below the head pointer read last. The table is read for an address only, without its lock: a buffer the table no longer holds costs a prefetch to nothing. Rings in coherent memory, where each entry read is a read from uncached memory, are left as they are. Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1 Signed-off-by: Julius Bairaktaris --- drivers/net/wireless/ath/ath11k/dp_rx.c | 93 +++++++++++++++++++++++++ drivers/net/wireless/ath/ath11k/hal.c | 27 +++++++ drivers/net/wireless/ath/ath11k/hal.h | 1 + 3 files changed, 121 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index b027b76ea3f3..e8226b2b832c 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -2919,6 +2919,92 @@ static void ath11k_dp_rx_process_received_packets(struct ath11k_base *ab, } } +/* + * The refill buffer table entry a REO entry names, or NULL for a cookie that + * names none. + */ +static struct sk_buff ** +ath11k_dp_rx_reo_buf_slot(struct ath11k_base *ab, + const struct hal_reo_dest_ring *desc) +{ + u32 cookie = FIELD_GET(BUFFER_ADDR_INFO1_SW_COOKIE, + desc->buf_addr_info.info1); + u32 buf_id = FIELD_GET(DP_RXDMA_BUF_COOKIE_BUF_ID, cookie); + u32 mac_id = FIELD_GET(DP_RXDMA_BUF_COOKIE_PDEV_ID, cookie); + struct dp_rxdma_ring *rx_ring; + struct ath11k *ar; + + if (!buf_id || mac_id >= ab->num_radios) + return NULL; + + ar = ab->pdevs[mac_id].ar; + if (!ar) + return NULL; + + rx_ring = &ar->dp.rx_refill_buf_ring; + if (buf_id >= rx_ring->num_ids) + return NULL; + + return &rx_ring->bufs[buf_id]; +} + +/* + * Starts the loads of the reap of the next REO entries, which are cold by + * the time the frames come back: the buffer table entry of the entry after + * the next one, and the sk_buff of the next one, whose table entry the reap + * before prefetched. Only an address is read from the table, without its + * lock: a buffer it no longer holds costs a prefetch to nothing. + */ +static void ath11k_dp_rx_reo_prefetch(struct ath11k_base *ab, + struct hal_srng *srng) +{ + struct sk_buff **slot; + struct sk_buff *skb; + void *desc; + + desc = ath11k_hal_srng_dst_peek_ahead(srng, 1); + if (desc) { + slot = ath11k_dp_rx_reo_buf_slot(ab, desc); + if (slot) + prefetch(slot); + } + + desc = ath11k_hal_srng_dst_peek_ahead(srng, 0); + if (!desc) + return; + + slot = ath11k_dp_rx_reo_buf_slot(ab, desc); + if (!slot) + return; + + skb = READ_ONCE(*slot); + if (skb) { + prefetchw(skb); + prefetchw((u8 *)skb + L1_CACHE_BYTES); + prefetchw((u8 *)skb + 2 * L1_CACHE_BYTES); + prefetchw((u8 *)skb + 3 * L1_CACHE_BYTES); + } +} + +/* + * Starts the loads of the descriptor TLVs and the headers of a frame the + * device has handed back, which its processing reads once the reap is done: + * the first three lines of the descriptor, where its end, attention and start + * TLVs begin, and the first two lines past it. A line past what the device + * wrote is not read. + */ +static void ath11k_dp_rx_prefetch_frame(struct ath11k_base *ab, + struct sk_buff *msdu) +{ + u8 *data = msdu->data, *hdr = data + ab->hw_params.hal_desc_sz; + + prefetch(data); + prefetch(data + L1_CACHE_BYTES); + prefetch(data + 2 * L1_CACHE_BYTES); + prefetch(hdr); + prefetch(hdr + L1_CACHE_BYTES); +} + int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id, struct napi_struct *napi, int budget) { @@ -2936,12 +3022,14 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id, struct hal_reo_dest_ring *desc; enum hal_reo_dest_ring_push_reason push_reason; u32 cookie; + bool cached; int i; for (i = 0; i < MAX_RADIOS; i++) __skb_queue_head_init(&msdu_list[i]); srng = &ab->hal.srng_list[dp->reo_dst_ring[ring_id].ring_id]; + cached = srng->flags & HAL_SRNG_FLAGS_CACHED; spin_lock_bh(&srng->lock); @@ -2951,6 +3039,9 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id, while (likely(desc = (struct hal_reo_dest_ring *)ath11k_hal_srng_dst_get_next_entry(ab, srng))) { + if (cached) + ath11k_dp_rx_reo_prefetch(ab, srng); + cookie = FIELD_GET(BUFFER_ADDR_INFO1_SW_COOKIE, desc->buf_addr_info.info1); buf_id = FIELD_GET(DP_RXDMA_BUF_COOKIE_BUF_ID, @@ -2976,6 +3067,8 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id, rxcb = ATH11K_SKB_RXCB(msdu); ath11k_dp_rx_unmap_buf(ab, msdu, DMA_FROM_DEVICE); + if (cached) + ath11k_dp_rx_prefetch_frame(ab, msdu); num_buffs_reaped[mac_id]++; diff --git a/drivers/net/wireless/ath/ath11k/hal.c b/drivers/net/wireless/ath/ath11k/hal.c index e5c35647a136..fffecc077eac 100644 --- a/drivers/net/wireless/ath/ath11k/hal.c +++ b/drivers/net/wireless/ath/ath11k/hal.c @@ -627,6 +627,33 @@ u32 *ath11k_hal_srng_dst_peek(struct ath11k_base *ab, struct hal_srng *srng) return NULL; } +/** + * ath11k_hal_srng_dst_peek_ahead() - an entry of a destination ring past the next + * @srng: the ring, whose lock the caller holds + * @n: how many entries past the one ath11k_hal_srng_dst_get_next_entry() + * returns next + * + * Return: the entry, or NULL when the head pointer read last does not + * reach it. + */ +u32 *ath11k_hal_srng_dst_peek_ahead(struct hal_srng *srng, u32 n) +{ + u32 tp = srng->u.dst_ring.tp, hp = srng->u.dst_ring.cached_hp; + u32 avail, off = n * srng->entry_size; + + lockdep_assert_held(&srng->lock); + + avail = hp >= tp ? hp - tp : srng->ring_size - tp + hp; + if (off >= avail) + return NULL; + + tp += off; + if (tp >= srng->ring_size) + tp -= srng->ring_size; + + return srng->ring_base_vaddr + tp; +} + /* * Hands the CPU the entries of a cached destination ring from word @from up * to word @to, which the head pointer the caller just read shows the device diff --git a/drivers/net/wireless/ath/ath11k/hal.h b/drivers/net/wireless/ath/ath11k/hal.h index 82603a389bb9..45ac2391abd8 100644 --- a/drivers/net/wireless/ath/ath11k/hal.h +++ b/drivers/net/wireless/ath/ath11k/hal.h @@ -944,6 +944,7 @@ void ath11k_hal_srng_get_params(struct ath11k_base *ab, struct hal_srng *srng, u32 *ath11k_hal_srng_dst_get_next_entry(struct ath11k_base *ab, struct hal_srng *srng); u32 *ath11k_hal_srng_dst_peek(struct ath11k_base *ab, struct hal_srng *srng); +u32 *ath11k_hal_srng_dst_peek_ahead(struct hal_srng *srng, u32 n); int ath11k_hal_srng_dst_num_free(struct ath11k_base *ab, struct hal_srng *srng, bool sync_hw_ptr); u32 *ath11k_hal_srng_src_peek(struct ath11k_base *ab, struct hal_srng *srng); -- 2.53.0