Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net/mlx4_en: Fix pages never dma unmapped on rx
@ 2013-10-06 12:57 Amir Vadai
  2013-10-06 14:22 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Amir Vadai @ 2013-10-06 12:57 UTC (permalink / raw)
  To: netdev; +Cc: Amir Vadai, Or Gerlitz, Eugenia Emantayev, Eric Dumazet

This patch fixes a bug introduced by commit 51151a16 (mlx4: allow
order-0 memory allocations in RX path).

dma_unmap_page never reached because condition to detect last fragment
in page is wrong. offset+frag_stride can't be greater than size, need to
make sure no additional frag will fit in page => compare offset +
frag_stride + next_frag_size instead.
next_frag_size could be next frag in the same skb, or the first frag in
the next.

CC: Eric Dumazet <edumazet@google.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index dec455c..44d8865 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -131,8 +131,11 @@ static void mlx4_en_free_frag(struct mlx4_en_priv *priv,
 			      int i)
 {
 	const struct mlx4_en_frag_info *frag_info = &priv->frag_info[i];
+	u16 next_frag_end = frags[i].offset + frag_info->frag_stride;
 
-	if (frags[i].offset + frag_info->frag_stride > frags[i].size)
+	next_frag_end += frags[(i + 1) % priv->num_frags].size;
+
+	if (next_frag_end > frags[i].size)
 		dma_unmap_page(priv->ddev, frags[i].dma, frags[i].size,
 					 PCI_DMA_FROMDEVICE);
 
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-06 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-06 12:57 [PATCH net] net/mlx4_en: Fix pages never dma unmapped on rx Amir Vadai
2013-10-06 14:22 ` Eric Dumazet
2013-10-06 15:05   ` Amir Vadai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox