public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Måns Rullgård" <mans@mansr•com>
To: Christophe Leroy <christophe.leroy@csgroup•eu>
Cc: Pantelis Antoniou <pantelis.antoniou@gmail•com>,
	"David S. Miller" <davem@davemloft•net>,
	Eric Dumazet <edumazet@google•com>,
	Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
	Vitaly Bordug <vbordug@ru•mvista.com>,
	Dan Malek <dan@embeddededge•com>,
	Joakim Tjernlund <joakim.tjernlund@lumentis•se>,
	"linuxppc-dev@lists•ozlabs.org" <linuxppc-dev@lists•ozlabs.org>,
	"netdev@vger•kernel.org" <netdev@vger•kernel.org>,
	"linux-kernel@vger•kernel.org" <linux-kernel@vger•kernel.org>
Subject: Re: [PATCH] net: fs_enet: sync rx dma buffer before reading
Date: Fri, 20 May 2022 13:35:48 +0100	[thread overview]
Message-ID: <yw1xmtfc9yaj.fsf@mansr.com> (raw)
In-Reply-To: <03f24864-9d4d-b4f9-354a-f3b271c0ae66@csgroup.eu> (Christophe Leroy's message of "Fri, 20 May 2022 05:39:38 +0000")

Christophe Leroy <christophe.leroy@csgroup•eu> writes:

> Le 19/05/2022 à 21:24, Mans Rullgard a écrit :
>> The dma_sync_single_for_cpu() call must precede reading the received
>> data. Fix this.
>
> See original commit 070e1f01827c. It explicitely says that the cache 
> must be invalidate _AFTER_ the copy.
>
> The cache is initialy invalidated by dma_map_single(), so before the 
> copy the cache is already clean.
>
> After the copy, data is in the cache. In order to allow re-use of the 
> skb, it must be put back in the same condition as before, in extenso the 
> cache must be invalidated in order to be in the same situation as after 
> dma_map_single().
>
> So I think your change is wrong.

OK, looking at it more closely, the change is at least unnecessary since
there will be a cache invalidation between each use of the buffer either
way.  Please disregard the patch.  Sorry for the noise.

>> 
>> Fixes: 070e1f01827c ("net: fs_enet: don't unmap DMA when packet len is below copybreak")
>> Signed-off-by: Mans Rullgard <mans@mansr•com>
>> ---
>>   drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
>> index b3dae17e067e..432ce10cbfd0 100644
>> --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
>> +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
>> @@ -240,14 +240,14 @@ static int fs_enet_napi(struct napi_struct *napi, int budget)
>>                                  /* +2 to make IP header L1 cache aligned */
>>                                  skbn = netdev_alloc_skb(dev, pkt_len + 2);
>>                                  if (skbn != NULL) {
>> +                                       dma_sync_single_for_cpu(fep->dev,
>> +                                               CBDR_BUFADDR(bdp),
>> +                                               L1_CACHE_ALIGN(pkt_len),
>> +                                               DMA_FROM_DEVICE);
>>                                          skb_reserve(skbn, 2);   /* align IP header */
>>                                          skb_copy_from_linear_data(skb,
>>                                                        skbn->data, pkt_len);
>>                                          swap(skb, skbn);
>> -                                       dma_sync_single_for_cpu(fep->dev,
>> -                                               CBDR_BUFADDR(bdp),
>> -                                               L1_CACHE_ALIGN(pkt_len),
>> -                                               DMA_FROM_DEVICE);
>>                                  }
>>                          } else {
>>                                  skbn = netdev_alloc_skb(dev, ENET_RX_FRSIZE);
>> --
>> 2.35.1
>> 

-- 
Måns Rullgård

  reply	other threads:[~2022-05-20 12:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 19:24 [PATCH] net: fs_enet: sync rx dma buffer before reading Mans Rullgard
2022-05-20  5:39 ` Christophe Leroy
2022-05-20 12:35   ` Måns Rullgård [this message]
2022-05-20 12:54     ` Christophe Leroy
2022-05-20 17:43       ` Jakub Kicinski
2022-05-21  6:44         ` Christophe Leroy
2022-05-21 17:44           ` Jakub Kicinski
2022-05-23 20:23             ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yw1xmtfc9yaj.fsf@mansr.com \
    --to=mans@mansr$(echo .)com \
    --cc=christophe.leroy@csgroup$(echo .)eu \
    --cc=dan@embeddededge$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=joakim.tjernlund@lumentis$(echo .)se \
    --cc=kuba@kernel$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=pantelis.antoniou@gmail$(echo .)com \
    --cc=vbordug@ru$(echo .)mvista.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox