Skip to content

Commit 1d5a474

Browse files
habetsm-xilinxkuba-moo
authored andcommitted
sfc: The RX page_ring is optional
The RX page_ring is an optional feature that improves performance. When allocation fails the driver can still function, but possibly with a lower bandwidth. Guard against dereferencing a NULL page_ring. Fixes: 2768935 ("sfc: reuse pages to avoid DMA mapping/unmapping costs") Signed-off-by: Martin Habets <[email protected]> Reported-by: Jiasheng Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6f89ecf commit 1d5a474

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/net/ethernet/sfc/falcon/rx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ static struct page *ef4_reuse_page(struct ef4_rx_queue *rx_queue)
110110
struct ef4_rx_page_state *state;
111111
unsigned index;
112112

113+
if (unlikely(!rx_queue->page_ring))
114+
return NULL;
113115
index = rx_queue->page_remove & rx_queue->page_ptr_mask;
114116
page = rx_queue->page_ring[index];
115117
if (page == NULL)
@@ -293,6 +295,9 @@ static void ef4_recycle_rx_pages(struct ef4_channel *channel,
293295
{
294296
struct ef4_rx_queue *rx_queue = ef4_channel_get_rx_queue(channel);
295297

298+
if (unlikely(!rx_queue->page_ring))
299+
return;
300+
296301
do {
297302
ef4_recycle_rx_page(channel, rx_buf);
298303
rx_buf = ef4_rx_buf_next(rx_queue, rx_buf);

drivers/net/ethernet/sfc/rx_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue)
4545
unsigned int index;
4646
struct page *page;
4747

48+
if (unlikely(!rx_queue->page_ring))
49+
return NULL;
4850
index = rx_queue->page_remove & rx_queue->page_ptr_mask;
4951
page = rx_queue->page_ring[index];
5052
if (page == NULL)
@@ -114,6 +116,9 @@ void efx_recycle_rx_pages(struct efx_channel *channel,
114116
{
115117
struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel);
116118

119+
if (unlikely(!rx_queue->page_ring))
120+
return;
121+
117122
do {
118123
efx_recycle_rx_page(channel, rx_buf);
119124
rx_buf = efx_rx_buf_next(rx_queue, rx_buf);

0 commit comments

Comments
 (0)