mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Lucas Stach <dev@lynxeye.de>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	barebox@lists.infradead.org
Subject: Re: [PATCH 3/4] net: mvneta: Remove unnecessary DMA ops
Date: Fri, 10 Apr 2015 10:18:12 +0200	[thread overview]
Message-ID: <55278744.5040304@gmail.com> (raw)
In-Reply-To: <1428650609.2182.7.camel@lynxeye.de>

On 10.04.2015 09:23, Lucas Stach wrote:
> Am Freitag, den 10.04.2015, 03:01 +0200 schrieb Sebastian Hesselbarth:
>> Commit a76c62f80d95860e6c5904ab5cb91667c43f61eb
>>   ("net: mvneta: convert to streaming DMA ops")
>> converted explicit ARM cache flushes to streaming DMA calls.
>>
>> However, in mvneta_send() we are not interested in the sent data buffer
>> anymore. Also, in mvneta_recv() the device does not care about received
>> data buffer.
>>
>> Remove unnecessary dma_sync_single_for_cpu() in mvneta_send() and
>> dma_sync_single_for_device() in mvneta_recv().
>>
>> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
>
> NACK: see below.
>
>> ---
>> Cc: barebox@lists.infradead.org
>> Cc: Lucas Stach <dev@lynxeye.de>
>> Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
>> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>> ---
>>   drivers/net/mvneta.c | 4 ----
>>   1 file changed, 4 deletions(-)
>>
>> diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
>> index 3be2ec531fb1..e1c7f15210e4 100644
>> --- a/drivers/net/mvneta.c
>> +++ b/drivers/net/mvneta.c
>> @@ -409,7 +409,6 @@ static int mvneta_send(struct eth_device *edev, void *data, int len)
>>   	 * the Tx port status register (PTXS).
>>   	 */
>>   	ret = wait_on_timeout(TRANSFER_TIMEOUT, !mvneta_pending_tx(priv));
>> -	dma_sync_single_for_cpu((unsigned long)data, len, DMA_TO_DEVICE);
>
> This makes sure the CPU has a consistent view of memory. If something
> got speculatively loaded into the cache you will write out invalid data
> on the next send.
>
>>   	if (ret) {
>>   		dev_err(&edev->dev, "transmit timeout\n");
>>   		return ret;
>> @@ -468,9 +467,6 @@ static int mvneta_recv(struct eth_device *edev)
>>   			  rxdesc->data_size - MVNETA_MH_SIZE);
>>   	ret = 0;
>>
>> -	dma_sync_single_for_device((unsigned long)rxdesc->buf_phys_addr,
>> -				   ALIGN(PKTSIZE, 8), DMA_FROM_DEVICE);
>> -
> The buffer is reused for the next receive operation. This isn't syncing
> the data to the device, but is actually a cache invalidate to make sure
> there is no pending cache writeback that may corrupt your received data.
>
>>   recv_err:
>>   	/* reset this and get next rx descriptor*/
>>   	rxdesc->data_size = 0;
>
> The DMA API has a notion of buffer ownership. Accessing a buffer without
> transferring the ownership to the appropriate entity (cpu or device) is
> illegal. Using the DMA API in a non balanced manner is skipping the
> ownership transfer.

Lucas,

I checked the Linux DMA-API documentation again, I guess this is what
you are referring to? The documents neither mention "owner" nor
"balance" in any way.

However, I do agree that balancing the calls makes sense as long as we
cannot guarantee that receive buffers are treated read-only and transmit
buffers write-only.

So, the NACK is correct, please drop this patch.

Sebastian


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-04-10  8:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10  1:01 [PATCH 0/4] Some fixes for PCI, mvneta, xHCI Sebastian Hesselbarth
2015-04-10  1:01 ` [PATCH 1/4] pci: fix device registration for directly attached devices Sebastian Hesselbarth
2015-04-10  7:15   ` Lucas Stach
2015-04-10  8:24     ` Sebastian Hesselbarth
2015-04-10  1:01 ` [PATCH 2/4] net: mvneta: Fix transmit errors due to dirty txdesc Sebastian Hesselbarth
2015-04-13  6:43   ` Sascha Hauer
2015-04-10  1:01 ` [PATCH 3/4] net: mvneta: Remove unnecessary DMA ops Sebastian Hesselbarth
2015-04-10  7:23   ` Lucas Stach
2015-04-10  8:18     ` Sebastian Hesselbarth [this message]
2015-04-10 16:09       ` Jan Lübbe
2015-04-10  1:01 ` [PATCH 4/4] USB: xHCI: Sync non-coherent DMA buffers Sebastian Hesselbarth
2015-04-10  7:25   ` Lucas Stach
2015-04-13 14:22   ` [PATCH v2] " Sebastian Hesselbarth
2015-04-14 18:52     ` Sascha Hauer
2015-04-14 19:29       ` Sebastian Hesselbarth
2015-04-15  9:11         ` Lucas Stach
2015-04-15  9:10     ` Lucas Stach
2015-04-15 12:06     ` Sascha Hauer

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=55278744.5040304@gmail.com \
    --to=sebastian.hesselbarth@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=dev@lynxeye.de \
    --cc=thomas.petazzoni@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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