Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

eth: fbnic: remove the debugging trick of super high page bias

Alex added page bias of LONG_MAX, which is admittedly quite
a clever way of catching overflows of the pp ref count.
The page pool code was "optimized" to leave the ref at 1
for freed pages so it can't catch basic bugs by itself any more.
(Something we should probably address under DEBUG_NET...)

Unfortunately for fbnic since commit f7dc3248dcfb ("skbuff: Optimization
of SKB coalescing for page pool") core _may_ actually take two extra
pp refcounts, if one of them is returned before driver gives up the bias
the ret < 0 check in page_pool_unref_netmem() will trigger.

While at it add a FBNIC_ to the name of the driver constant.

Fixes: 0cb4c0a13723 ("eth: fbnic: Implement Rx queue alloc/start/stop/free")
Link: https://patch.msgid.link/20250801170754.2439577-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+4 -6
+2 -2
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
··· 661 661 { 662 662 struct fbnic_rx_buf *rx_buf = &ring->rx_buf[idx]; 663 663 664 - page_pool_fragment_page(page, PAGECNT_BIAS_MAX); 665 - rx_buf->pagecnt_bias = PAGECNT_BIAS_MAX; 664 + page_pool_fragment_page(page, FBNIC_PAGECNT_BIAS_MAX); 665 + rx_buf->pagecnt_bias = FBNIC_PAGECNT_BIAS_MAX; 666 666 rx_buf->page = page; 667 667 } 668 668
+2 -4
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
··· 91 91 struct u64_stats_sync syncp; 92 92 }; 93 93 94 - /* Pagecnt bias is long max to reserve the last bit to catch overflow 95 - * cases where if we overcharge the bias it will flip over to be negative. 96 - */ 97 - #define PAGECNT_BIAS_MAX LONG_MAX 94 + #define FBNIC_PAGECNT_BIAS_MAX PAGE_SIZE 95 + 98 96 struct fbnic_rx_buf { 99 97 struct page *page; 100 98 long pagecnt_bias;