* [PATCH] ravb: do not invalidate cache for RX buffer twice
@ 2015-07-14 21:56 Sergei Shtylyov
2015-07-15 10:45 ` Sergei Shtylyov
2015-07-17 7:11 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-07-14 21:56 UTC (permalink / raw)
To: netdev; +Cc: linux-sh
First, dma_sync_single_for_cpu() shouldn't have been called in the first place
(it's a streaming DMA API). dma_unmap_single() should have been called instead.
Second, dma_unmap_single() call after handing the buffer to napi_gro_receive()
makes little sense.
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
The patch is against Dave Miller's 'net.git' repo.
Don't know why I missed this DMA API misuse while working on the driver. :-<
drivers/net/ethernet/renesas/ravb_main.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
Index: net/drivers/net/ethernet/renesas/ravb_main.c
===================================================================
--- net.orig/drivers/net/ethernet/renesas/ravb_main.c
+++ net/drivers/net/ethernet/renesas/ravb_main.c
@@ -543,10 +543,9 @@ static bool ravb_rx(struct net_device *n
skb = priv->rx_skb[q][entry];
priv->rx_skb[q][entry] = NULL;
- dma_sync_single_for_cpu(&ndev->dev,
- le32_to_cpu(desc->dptr),
- ALIGN(PKT_BUF_SZ, 16),
- DMA_FROM_DEVICE);
+ dma_unmap_single(&ndev->dev, le32_to_cpu(desc->dptr),
+ ALIGN(PKT_BUF_SZ, 16),
+ DMA_FROM_DEVICE);
get_ts &= (q == RAVB_NC) ?
RAVB_RXTSTAMP_TYPE_V2_L2_EVENT :
~RAVB_RXTSTAMP_TYPE_V2_L2_EVENT;
@@ -584,9 +583,6 @@ static bool ravb_rx(struct net_device *n
if (!skb)
break; /* Better luck next round. */
ravb_set_buffer_align(skb);
- dma_unmap_single(&ndev->dev, le32_to_cpu(desc->dptr),
- ALIGN(PKT_BUF_SZ, 16),
- DMA_FROM_DEVICE);
dma_addr = dma_map_single(&ndev->dev, skb->data,
le16_to_cpu(desc->ds_cc),
DMA_FROM_DEVICE);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ravb: do not invalidate cache for RX buffer twice
2015-07-14 21:56 [PATCH] ravb: do not invalidate cache for RX buffer twice Sergei Shtylyov
@ 2015-07-15 10:45 ` Sergei Shtylyov
2015-07-15 12:11 ` Sergei Shtylyov
2015-07-17 7:11 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Sergei Shtylyov @ 2015-07-15 10:45 UTC (permalink / raw)
To: netdev; +Cc: linux-sh
Hello.
On 7/15/2015 12:56 AM, Sergei Shtylyov wrote:
> First, dma_sync_single_for_cpu() shouldn't have been called in the first place
> (it's a streaming DMA API). dma_unmap_single() should have been called instead.
^
Oops, I meant comma here.
> Second, dma_unmap_single() call after handing the buffer to napi_gro_receive()
> makes little sense.
Moreover, 'desc->dptr' may not be valid at this point...
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>
> ---
> The patch is against Dave Miller's 'net.git' repo.
> Don't know why I missed this DMA API misuse while working on the driver. :-<
Dave, do you want me to resend the patch with fixed up changelog?
> drivers/net/ethernet/renesas/ravb_main.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> Index: net/drivers/net/ethernet/renesas/ravb_main.c
> ===================================================================
> --- net.orig/drivers/net/ethernet/renesas/ravb_main.c
> +++ net/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -584,9 +583,6 @@ static bool ravb_rx(struct net_device *n
> if (!skb)
> break; /* Better luck next round. */
> ravb_set_buffer_align(skb);
> - dma_unmap_single(&ndev->dev, le32_to_cpu(desc->dptr),
> - ALIGN(PKT_BUF_SZ, 16),
> - DMA_FROM_DEVICE);
> dma_addr = dma_map_single(&ndev->dev, skb->data,
> le16_to_cpu(desc->ds_cc),
> DMA_FROM_DEVICE);
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] ravb: do not invalidate cache for RX buffer twice
2015-07-15 10:45 ` Sergei Shtylyov
@ 2015-07-15 12:11 ` Sergei Shtylyov
0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-07-15 12:11 UTC (permalink / raw)
To: netdev, David Miller; +Cc: linux-sh
On 7/15/2015 1:45 PM, Sergei Shtylyov wrote:
>> First, dma_sync_single_for_cpu() shouldn't have been called in the first place
>> (it's a streaming DMA API). dma_unmap_single() should have been called instead.
> ^
> Oops, I meant comma here.
>> Second, dma_unmap_single() call after handing the buffer to napi_gro_receive()
>> makes little sense.
> Moreover, 'desc->dptr' may not be valid at this point...
>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>> ---
>> The patch is against Dave Miller's 'net.git' repo.
>> Don't know why I missed this DMA API misuse while working on the driver. :-<
> Dave, do you want me to resend the patch with fixed up changelog?
Oops, forgot to CC Dave. :-(
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ravb: do not invalidate cache for RX buffer twice
2015-07-14 21:56 [PATCH] ravb: do not invalidate cache for RX buffer twice Sergei Shtylyov
2015-07-15 10:45 ` Sergei Shtylyov
@ 2015-07-17 7:11 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2015-07-17 7:11 UTC (permalink / raw)
To: sergei.shtylyov; +Cc: netdev, linux-sh
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Wed, 15 Jul 2015 00:56:52 +0300
> First, dma_sync_single_for_cpu() shouldn't have been called in the first place
> (it's a streaming DMA API). dma_unmap_single() should have been called instead.
> Second, dma_unmap_single() call after handing the buffer to napi_gro_receive()
> makes little sense.
>
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Applied with fixed up commit log message, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-17 7:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-14 21:56 [PATCH] ravb: do not invalidate cache for RX buffer twice Sergei Shtylyov
2015-07-15 10:45 ` Sergei Shtylyov
2015-07-15 12:11 ` Sergei Shtylyov
2015-07-17 7:11 ` 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).