sfc: The RX page_ring is optional
commit 1d5a474240407c38ca8c7484a656ee39f585399c upstream.
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: 2768935a46
("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
03fb6db4ad
commit
8fbbc33cf0
|
@ -110,6 +110,8 @@ static struct page *ef4_reuse_page(struct ef4_rx_queue *rx_queue)
|
||||||
struct ef4_rx_page_state *state;
|
struct ef4_rx_page_state *state;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
|
if (unlikely(!rx_queue->page_ring))
|
||||||
|
return NULL;
|
||||||
index = rx_queue->page_remove & rx_queue->page_ptr_mask;
|
index = rx_queue->page_remove & rx_queue->page_ptr_mask;
|
||||||
page = rx_queue->page_ring[index];
|
page = rx_queue->page_ring[index];
|
||||||
if (page == NULL)
|
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);
|
struct ef4_rx_queue *rx_queue = ef4_channel_get_rx_queue(channel);
|
||||||
|
|
||||||
|
if (unlikely(!rx_queue->page_ring))
|
||||||
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ef4_recycle_rx_page(channel, rx_buf);
|
ef4_recycle_rx_page(channel, rx_buf);
|
||||||
rx_buf = ef4_rx_buf_next(rx_queue, rx_buf);
|
rx_buf = ef4_rx_buf_next(rx_queue, rx_buf);
|
||||||
|
|
|
@ -45,6 +45,8 @@ static struct page *efx_reuse_page(struct efx_rx_queue *rx_queue)
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
|
||||||
|
if (unlikely(!rx_queue->page_ring))
|
||||||
|
return NULL;
|
||||||
index = rx_queue->page_remove & rx_queue->page_ptr_mask;
|
index = rx_queue->page_remove & rx_queue->page_ptr_mask;
|
||||||
page = rx_queue->page_ring[index];
|
page = rx_queue->page_ring[index];
|
||||||
if (page == NULL)
|
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);
|
struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel);
|
||||||
|
|
||||||
|
if (unlikely(!rx_queue->page_ring))
|
||||||
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
efx_recycle_rx_page(channel, rx_buf);
|
efx_recycle_rx_page(channel, rx_buf);
|
||||||
rx_buf = efx_rx_buf_next(rx_queue, rx_buf);
|
rx_buf = efx_rx_buf_next(rx_queue, rx_buf);
|
||||||
|
|
Loading…
Reference in New Issue