Subject: Re: [PATCH] xgmac: use bufsz not dma_buf_sz in rx_refill

From: Rob Herring <[email-masked]>
Date: Thu, 29 Aug 2013 15:24:30 -0500

On 08/29/2013 03:11 PM, Kyle McMartin wrote:
> Noticed while debugging another issue that DMA debug turned up, looks
> like commit ef468d23 missed a case when switching to bufsz instead of
> priv->dma_buf_sz? (tbf, the whole handling of DMA buffers seems slightly
> suspect since we're not tracking the size, but trusting the hardware
> between map and unmap...)

Please see my patch series of fixes:

http://www.spinics.net/lists/netdev/msg248076.html

> Signed-off-by: Kyle McMartin <[email-masked]>
> 
> --- a/drivers/net/ethernet/calxeda/xgmac.c
> +++ b/drivers/net/ethernet/calxeda/xgmac.c
> @@ -686,7 +686,7 @@ static void xgmac_rx_refill(struct xgmac_priv *priv)
>  			priv->rx_skbuff[entry] = skb;
>  			paddr = dma_map_single(priv->device, skb->data,
>  					       bufsz, DMA_FROM_DEVICE);
> -			desc_set_buf_addr(p, paddr, priv->dma_buf_sz);
> +			desc_set_buf_addr(p, paddr, bufsz);

This is not right because the h/w wants the size to include the 2 bytes
skipped at the beginning for NET_IP_ALIGN. The h/w may also corrupt 1-7
bytes of data at the head or tail if the frame is not 8 byte aligned and
padded. We are relying that skb allocations are aligned.

Rob