netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs
@ 2014-01-09 13:36 Michal Schmidt
  2014-01-09 17:52 ` Eric Dumazet
  2014-01-10 18:19 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Michal Schmidt @ 2014-01-09 13:36 UTC (permalink / raw)
  To: netdev; +Cc: Ariel Elior, Yuval Mintz, Dmitry Kravkov, David Miller

bnx2x triggers warnings with CONFIG_DMA_API_DEBUG=y:

  WARNING: CPU: 0 PID: 2253 at lib/dma-debug.c:887 check_unmap+0xf8/0x920()
  bnx2x 0000:28:00.0: DMA-API: device driver frees DMA memory with
  different size [device address=0x00000000da2b389e] [map size=1490 bytes]
  [unmap size=66 bytes]

The reason is that bnx2x splits a TSO BD into two BDs (headers + data)
using one DMA mapping for both, but it uses only the length of the first
BD when unmapping.

This patch fixes the bug by unmapping the whole length of the two BDs.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index ec96130..6b2704f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -160,6 +160,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
 	struct sk_buff *skb = tx_buf->skb;
 	u16 bd_idx = TX_BD(tx_buf->first_bd), new_cons;
 	int nbd;
+	u16 split_bd_len = 0;
 
 	/* prefetch skb end pointer to speedup dev_kfree_skb() */
 	prefetch(&skb->end);
@@ -167,10 +168,7 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
 	DP(NETIF_MSG_TX_DONE, "fp[%d]: pkt_idx %d  buff @(%p)->skb %p\n",
 	   txdata->txq_index, idx, tx_buf, skb);
 
-	/* unmap first bd */
 	tx_start_bd = &txdata->tx_desc_ring[bd_idx].start_bd;
-	dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
-			 BD_UNMAP_LEN(tx_start_bd), DMA_TO_DEVICE);
 
 	nbd = le16_to_cpu(tx_start_bd->nbd) - 1;
 #ifdef BNX2X_STOP_ON_ERROR
@@ -188,12 +186,19 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata,
 	--nbd;
 	bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
 
-	/* ...and the TSO split header bd since they have no mapping */
+	/* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */
 	if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) {
+		tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd;
+		split_bd_len = BD_UNMAP_LEN(tx_data_bd);
 		--nbd;
 		bd_idx = TX_BD(NEXT_TX_IDX(bd_idx));
 	}
 
+	/* unmap first bd */
+	dma_unmap_single(&bp->pdev->dev, BD_UNMAP_ADDR(tx_start_bd),
+			 BD_UNMAP_LEN(tx_start_bd) + split_bd_len,
+			 DMA_TO_DEVICE);
+
 	/* now free frags */
 	while (nbd > 0) {
 
-- 
1.8.4.2

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

* Re: [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs
  2014-01-09 13:36 [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs Michal Schmidt
@ 2014-01-09 17:52 ` Eric Dumazet
  2014-01-09 19:23   ` Dmitry Kravkov
  2014-01-10 18:19 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2014-01-09 17:52 UTC (permalink / raw)
  To: Michal Schmidt
  Cc: netdev, Ariel Elior, Yuval Mintz, Dmitry Kravkov, David Miller

On Thu, 2014-01-09 at 14:36 +0100, Michal Schmidt wrote:
> bnx2x triggers warnings with CONFIG_DMA_API_DEBUG=y:
> 
>   WARNING: CPU: 0 PID: 2253 at lib/dma-debug.c:887 check_unmap+0xf8/0x920()
>   bnx2x 0000:28:00.0: DMA-API: device driver frees DMA memory with
>   different size [device address=0x00000000da2b389e] [map size=1490 bytes]
>   [unmap size=66 bytes]
> 
> The reason is that bnx2x splits a TSO BD into two BDs (headers + data)
> using one DMA mapping for both, but it uses only the length of the first
> BD when unmapping.
> 
> This patch fixes the bug by unmapping the whole length of the two BDs.
> 
> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>

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

* RE: [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs
  2014-01-09 17:52 ` Eric Dumazet
@ 2014-01-09 19:23   ` Dmitry Kravkov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Kravkov @ 2014-01-09 19:23 UTC (permalink / raw)
  To: Eric Dumazet, Michal Schmidt
  Cc: netdev@vger.kernel.org, Ariel Elior, Yuval Mintz, David Miller

> -----Original Message-----
> From: Eric Dumazet [mailto:eric.dumazet@gmail.com]
> Sent: Thursday, January 09, 2014 7:52 PM
> To: Michal Schmidt
> Cc: netdev@vger.kernel.org; Ariel Elior; Yuval Mintz; Dmitry Kravkov; David
> Miller
> Subject: Re: [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs
> 
> On Thu, 2014-01-09 at 14:36 +0100, Michal Schmidt wrote:
> > bnx2x triggers warnings with CONFIG_DMA_API_DEBUG=y:
> >
> >   WARNING: CPU: 0 PID: 2253 at lib/dma-debug.c:887
> check_unmap+0xf8/0x920()
> >   bnx2x 0000:28:00.0: DMA-API: device driver frees DMA memory with
> >   different size [device address=0x00000000da2b389e] [map size=1490
> bytes]
> >   [unmap size=66 bytes]
> >
> > The reason is that bnx2x splits a TSO BD into two BDs (headers + data)
> > using one DMA mapping for both, but it uses only the length of the
> > first BD when unmapping.
> >
> > This patch fixes the bug by unmapping the whole length of the two BDs.
> >
> > Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
> > ---
> 
> Reviewed-by: Eric Dumazet <edumazet@google.com>
> 

Thanks you, Guys.

Acked-by: Dmitry Kravkov <dmitry@broadcom.com>


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

* Re: [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs
  2014-01-09 13:36 [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs Michal Schmidt
  2014-01-09 17:52 ` Eric Dumazet
@ 2014-01-10 18:19 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-01-10 18:19 UTC (permalink / raw)
  To: mschmidt; +Cc: netdev, ariele, yuvalmin, dmitry

From: Michal Schmidt <mschmidt@redhat.com>
Date: Thu,  9 Jan 2014 14:36:27 +0100

> bnx2x triggers warnings with CONFIG_DMA_API_DEBUG=y:
> 
>   WARNING: CPU: 0 PID: 2253 at lib/dma-debug.c:887 check_unmap+0xf8/0x920()
>   bnx2x 0000:28:00.0: DMA-API: device driver frees DMA memory with
>   different size [device address=0x00000000da2b389e] [map size=1490 bytes]
>   [unmap size=66 bytes]
> 
> The reason is that bnx2x splits a TSO BD into two BDs (headers + data)
> using one DMA mapping for both, but it uses only the length of the first
> BD when unmapping.
> 
> This patch fixes the bug by unmapping the whole length of the two BDs.
> 
> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>

Applied and queued up for -stable, thanks.

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

end of thread, other threads:[~2014-01-10 18:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-09 13:36 [PATCH net] bnx2x: fix DMA unmapping of TSO split BDs Michal Schmidt
2014-01-09 17:52 ` Eric Dumazet
2014-01-09 19:23   ` Dmitry Kravkov
2014-01-10 18:19 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).