]> git.baikalelectronics.ru Git - kernel.git/commitdiff
sfc: The RX page_ring is optional
authorMartin Habets <habetsm.xilinx@gmail.com>
Sun, 2 Jan 2022 08:41:22 +0000 (08:41 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 5 Jan 2022 02:14:21 +0000 (18:14 -0800)
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: 7d8bfb495d1c ("sfc: reuse pages to avoid DMA mapping/unmapping costs")
Signed-off-by: Martin Habets <habetsm.xilinx@gmail.com>
Reported-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/164111288276.5798.10330502993729113868.stgit@palantir17.mph.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/sfc/falcon/rx.c
drivers/net/ethernet/sfc/rx_common.c

index 11a6aee852e92ec4e6a6556e4213837c6531736c..0c6cc219136938c4a6bdc19c4f6467442c2605e1 100644 (file)
@@ -110,6 +110,8 @@ static struct page *ef4_reuse_page(struct ef4_rx_queue *rx_queue)
        struct ef4_rx_page_state *state;
        unsigned index;
 
+       if (unlikely(!rx_queue->page_ring))
+               return NULL;
        index = rx_queue->page_remove & rx_queue->page_ptr_mask;
        page = rx_queue->page_ring[index];
        if (page == NULL)
@@ -293,6 +295,9 @@ static void ef4_recycle_rx_pages(struct ef4_channel *channel,
 {
        struct ef4_rx_queue *rx_queue = ef4_channel_get_rx_queue(channel);
 
+       if (unlikely(!rx_queue->page_ring))
+               return;
+
        do {
                ef4_recycle_rx_page(channel, rx_buf);
                rx_buf = ef4_rx_buf_next(rx_queue, rx_buf);
index 0983abc0cc5f08ad3cfac02e5362807bb1707e07..633ca77a26fd19133cb3b950884c364f7cab7b94 100644 (file)
@@ -45,6 +45,8 @@ static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue)
        unsigned int index;
        struct page *page;
 
+       if (unlikely(!rx_queue->page_ring))
+               return NULL;
        index = rx_queue->page_remove & rx_queue->page_ptr_mask;
        page = rx_queue->page_ring[index];
        if (page == NULL)
@@ -114,6 +116,9 @@ void efx_recycle_rx_pages(struct efx_channel *channel,
 {
        struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel);
 
+       if (unlikely(!rx_queue->page_ring))
+               return;
+
        do {
                efx_recycle_rx_page(channel, rx_buf);
                rx_buf = efx_rx_buf_next(rx_queue, rx_buf);