* [PATCH 1/1] net: macb: fix the RX queue reset in macb_rx()
@ 2016-11-25 8:49 Cyrille Pitchen
2016-11-25 9:11 ` Nicolas Ferre
2016-11-28 1:25 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Cyrille Pitchen @ 2016-11-25 8:49 UTC (permalink / raw)
To: nicolas.ferre, davem, netdev, soren.brinkmann
Cc: Andrei.Pistirica, linux-arm-kernel, linux-kernel, Cyrille Pitchen
On macb only (not gem), when a RX queue corruption was detected from
macb_rx(), the RX queue was reset: during this process the RX ring
buffer descriptor was initialized by macb_init_rx_ring() but we forgot
to also set bp->rx_tail to 0.
Indeed, when processing the received frames, bp->rx_tail provides the
macb driver with the index in the RX ring buffer of the next buffer to
process. So when the whole ring buffer is reset we must also reset
bp->rx_tail so the driver is synchronized again with the hardware.
Since macb_init_rx_ring() is called from many locations, currently from
macb_rx() and macb_init_rings(), we'd rather add the "bp->rx_tail = 0;"
line inside macb_init_rx_ring() than add the very same line after each
call of this function.
Without this fix, the rx queue is not reset properly to recover from
queue corruption and connection drop may occur.
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Fixes: 9ba723b081a2 ("net: macb: remove BUG_ON() and reset the queue to handle RX errors")
---
drivers/net/ethernet/cadence/macb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 0e489bb82456..8ee303b8da08 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -991,6 +991,7 @@ static inline void macb_init_rx_ring(struct macb *bp)
addr += bp->rx_buffer_size;
}
bp->rx_ring[bp->rx_ring_size - 1].addr |= MACB_BIT(RX_WRAP);
+ bp->rx_tail = 0;
}
static int macb_rx(struct macb *bp, int budget)
@@ -1736,8 +1737,6 @@ static void macb_init_rings(struct macb *bp)
bp->queues[0].tx_head = 0;
bp->queues[0].tx_tail = 0;
bp->queues[0].tx_ring[bp->tx_ring_size - 1].ctrl |= MACB_BIT(TX_WRAP);
-
- bp->rx_tail = 0;
}
static void macb_reset_hw(struct macb *bp)
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] net: macb: fix the RX queue reset in macb_rx()
2016-11-25 8:49 [PATCH 1/1] net: macb: fix the RX queue reset in macb_rx() Cyrille Pitchen
@ 2016-11-25 9:11 ` Nicolas Ferre
2016-11-28 1:25 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Ferre @ 2016-11-25 9:11 UTC (permalink / raw)
To: Cyrille Pitchen, davem, netdev, soren.brinkmann
Cc: Andrei.Pistirica, linux-arm-kernel, linux-kernel
Le 25/11/2016 à 09:49, Cyrille Pitchen a écrit :
> On macb only (not gem), when a RX queue corruption was detected from
> macb_rx(), the RX queue was reset: during this process the RX ring
> buffer descriptor was initialized by macb_init_rx_ring() but we forgot
> to also set bp->rx_tail to 0.
>
> Indeed, when processing the received frames, bp->rx_tail provides the
> macb driver with the index in the RX ring buffer of the next buffer to
> process. So when the whole ring buffer is reset we must also reset
> bp->rx_tail so the driver is synchronized again with the hardware.
>
> Since macb_init_rx_ring() is called from many locations, currently from
> macb_rx() and macb_init_rings(), we'd rather add the "bp->rx_tail = 0;"
> line inside macb_init_rx_ring() than add the very same line after each
> call of this function.
>
> Without this fix, the rx queue is not reset properly to recover from
> queue corruption and connection drop may occur.
>
> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
> Fixes: 9ba723b081a2 ("net: macb: remove BUG_ON() and reset the queue to handle RX errors")
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Thanks.
Regards,
> ---
> drivers/net/ethernet/cadence/macb.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 0e489bb82456..8ee303b8da08 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -991,6 +991,7 @@ static inline void macb_init_rx_ring(struct macb *bp)
> addr += bp->rx_buffer_size;
> }
> bp->rx_ring[bp->rx_ring_size - 1].addr |= MACB_BIT(RX_WRAP);
> + bp->rx_tail = 0;
> }
>
> static int macb_rx(struct macb *bp, int budget)
> @@ -1736,8 +1737,6 @@ static void macb_init_rings(struct macb *bp)
> bp->queues[0].tx_head = 0;
> bp->queues[0].tx_tail = 0;
> bp->queues[0].tx_ring[bp->tx_ring_size - 1].ctrl |= MACB_BIT(TX_WRAP);
> -
> - bp->rx_tail = 0;
> }
>
> static void macb_reset_hw(struct macb *bp)
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] net: macb: fix the RX queue reset in macb_rx()
2016-11-25 8:49 [PATCH 1/1] net: macb: fix the RX queue reset in macb_rx() Cyrille Pitchen
2016-11-25 9:11 ` Nicolas Ferre
@ 2016-11-28 1:25 ` David Miller
2016-11-28 13:43 ` Cyrille Pitchen
1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2016-11-28 1:25 UTC (permalink / raw)
To: cyrille.pitchen
Cc: nicolas.ferre, netdev, soren.brinkmann, Andrei.Pistirica,
linux-arm-kernel, linux-kernel
From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Date: Fri, 25 Nov 2016 09:49:32 +0100
> On macb only (not gem), when a RX queue corruption was detected from
> macb_rx(), the RX queue was reset: during this process the RX ring
> buffer descriptor was initialized by macb_init_rx_ring() but we forgot
> to also set bp->rx_tail to 0.
>
> Indeed, when processing the received frames, bp->rx_tail provides the
> macb driver with the index in the RX ring buffer of the next buffer to
> process. So when the whole ring buffer is reset we must also reset
> bp->rx_tail so the driver is synchronized again with the hardware.
>
> Since macb_init_rx_ring() is called from many locations, currently from
> macb_rx() and macb_init_rings(), we'd rather add the "bp->rx_tail = 0;"
> line inside macb_init_rx_ring() than add the very same line after each
> call of this function.
>
> Without this fix, the rx queue is not reset properly to recover from
> queue corruption and connection drop may occur.
>
> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
> Fixes: 9ba723b081a2 ("net: macb: remove BUG_ON() and reset the queue to handle RX errors")
This doesn't apply cleanly to the 'net' tree, where
RX_RING_SIZE is used instead of bp->rx_ring_size. It seems
you generated this against net-next, however you didn't say
that either in your Subject line nor the commit message.
As a bug fix this should be targetted at 'net'.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] net: macb: fix the RX queue reset in macb_rx()
2016-11-28 1:25 ` David Miller
@ 2016-11-28 13:43 ` Cyrille Pitchen
0 siblings, 0 replies; 4+ messages in thread
From: Cyrille Pitchen @ 2016-11-28 13:43 UTC (permalink / raw)
To: David Miller
Cc: nicolas.ferre, netdev, soren.brinkmann, Andrei.Pistirica,
linux-arm-kernel, linux-kernel
Hi David,
Le 28/11/2016 à 02:25, David Miller a écrit :
> From: Cyrille Pitchen <cyrille.pitchen@atmel.com>
> Date: Fri, 25 Nov 2016 09:49:32 +0100
>
>> On macb only (not gem), when a RX queue corruption was detected from
>> macb_rx(), the RX queue was reset: during this process the RX ring
>> buffer descriptor was initialized by macb_init_rx_ring() but we forgot
>> to also set bp->rx_tail to 0.
>>
>> Indeed, when processing the received frames, bp->rx_tail provides the
>> macb driver with the index in the RX ring buffer of the next buffer to
>> process. So when the whole ring buffer is reset we must also reset
>> bp->rx_tail so the driver is synchronized again with the hardware.
>>
>> Since macb_init_rx_ring() is called from many locations, currently from
>> macb_rx() and macb_init_rings(), we'd rather add the "bp->rx_tail = 0;"
>> line inside macb_init_rx_ring() than add the very same line after each
>> call of this function.
>>
>> Without this fix, the rx queue is not reset properly to recover from
>> queue corruption and connection drop may occur.
>>
>> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
>> Fixes: 9ba723b081a2 ("net: macb: remove BUG_ON() and reset the queue to handle RX errors")
>
> This doesn't apply cleanly to the 'net' tree, where
> RX_RING_SIZE is used instead of bp->rx_ring_size. It seems
> you generated this against net-next, however you didn't say
> that either in your Subject line nor the commit message.
>
> As a bug fix this should be targetted at 'net'.
>
Indeed, sorry. I've just sent a v2 based on net/master.
Best regards,
Cyrille
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-28 13:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-25 8:49 [PATCH 1/1] net: macb: fix the RX queue reset in macb_rx() Cyrille Pitchen
2016-11-25 9:11 ` Nicolas Ferre
2016-11-28 1:25 ` David Miller
2016-11-28 13:43 ` Cyrille Pitchen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox