netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: netsec: Sync dma for device on buffer allocation
@ 2019-07-04 14:11 Ilias Apalodimas
  2019-07-05 22:42 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2019-07-04 14:11 UTC (permalink / raw)
  To: netdev, jaswinder.singh; +Cc: ard.biesheuvel, arnd, Ilias Apalodimas

Quoting Arnd,

We have to do a sync_single_for_device /somewhere/ before the
buffer is given to the device. On a non-cache-coherent machine with
a write-back cache, there may be dirty cache lines that get written back
after the device DMA's data into it (e.g. from a previous memset
from before the buffer got freed), so you absolutely need to flush any
dirty cache lines on it first.

Since the coherency is configurable in this device make sure we cover
all configurations by explicitly syncing the allocated buffer for the
device before refilling it's descriptors

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 drivers/net/ethernet/socionext/netsec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 5544a722543f..e05a7191336d 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -727,6 +727,7 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv,
 {
 
 	struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
+	enum dma_data_direction dma_dir;
 	struct page *page;
 
 	page = page_pool_dev_alloc_pages(dring->page_pool);
@@ -742,6 +743,10 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv,
 	 * cases and reserve enough space for headroom + skb_shared_info
 	 */
 	*desc_len = PAGE_SIZE - NETSEC_RX_BUF_NON_DATA;
+	dma_dir = page_pool_get_dma_dir(dring->page_pool);
+	dma_sync_single_for_device(priv->dev,
+				   *dma_handle - NETSEC_RXBUF_HEADROOM,
+				   PAGE_SIZE, dma_dir);
 
 	return page_address(page);
 }
-- 
2.20.1


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

* Re: [PATCH] net: netsec: Sync dma for device on buffer allocation
  2019-07-04 14:11 [PATCH] net: netsec: Sync dma for device on buffer allocation Ilias Apalodimas
@ 2019-07-05 22:42 ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-07-05 22:42 UTC (permalink / raw)
  To: ilias.apalodimas; +Cc: netdev, jaswinder.singh, ard.biesheuvel, arnd

From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Date: Thu,  4 Jul 2019 17:11:09 +0300

> Quoting Arnd,
> 
> We have to do a sync_single_for_device /somewhere/ before the
> buffer is given to the device. On a non-cache-coherent machine with
> a write-back cache, there may be dirty cache lines that get written back
> after the device DMA's data into it (e.g. from a previous memset
> from before the buffer got freed), so you absolutely need to flush any
> dirty cache lines on it first.
> 
> Since the coherency is configurable in this device make sure we cover
> all configurations by explicitly syncing the allocated buffer for the
> device before refilling it's descriptors
> 
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Please make it explicit in your Subject lines which tree a patch is
for, in this case it should have been "[PATCH net-next] ".

Applied, thanks.

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

* Re: [PATCH] net: netsec: Sync dma for device on buffer allocation
  2019-07-08  7:25 Ilias Apalodimas
@ 2019-07-08 19:00 ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-07-08 19:00 UTC (permalink / raw)
  To: ilias.apalodimas; +Cc: netdev, jaswinder.singh

From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Date: Mon,  8 Jul 2019 10:25:41 +0300

> cd1973a9215a ("net: netsec: Sync dma for device on buffer allocation")
> was merged on it's v1 instead of the v3.
> Merge the proper patch version
> 
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Applied to net-next, thanks.

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

* [PATCH] net: netsec: Sync dma for device on buffer allocation
@ 2019-07-08  7:25 Ilias Apalodimas
  2019-07-08 19:00 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2019-07-08  7:25 UTC (permalink / raw)
  To: netdev, jaswinder.singh, davem; +Cc: Ilias Apalodimas

cd1973a9215a ("net: netsec: Sync dma for device on buffer allocation")
was merged on it's v1 instead of the v3.
Merge the proper patch version

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 drivers/net/ethernet/socionext/netsec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index f6e261c6a059..460777449cd9 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -743,9 +743,7 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv,
 	 */
 	*desc_len = PAGE_SIZE - NETSEC_RX_BUF_NON_DATA;
 	dma_dir = page_pool_get_dma_dir(dring->page_pool);
-	dma_sync_single_for_device(priv->dev,
-				   *dma_handle - NETSEC_RXBUF_HEADROOM,
-				   PAGE_SIZE, dma_dir);
+	dma_sync_single_for_device(priv->dev, *dma_handle, *desc_len, dma_dir);
 
 	return page_address(page);
 }
-- 
2.20.1


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

end of thread, other threads:[~2019-07-08 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04 14:11 [PATCH] net: netsec: Sync dma for device on buffer allocation Ilias Apalodimas
2019-07-05 22:42 ` David Miller
2019-07-08  7:25 Ilias Apalodimas
2019-07-08 19:00 ` 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).