Commit cd1973a9 authored by Ilias Apalodimas's avatar Ilias Apalodimas Committed by David S. Miller

net: netsec: Sync dma for device on buffer allocation

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: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2bf8001e
...@@ -726,6 +726,7 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv, ...@@ -726,6 +726,7 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv,
{ {
struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
enum dma_data_direction dma_dir;
struct page *page; struct page *page;
page = page_pool_dev_alloc_pages(dring->page_pool); page = page_pool_dev_alloc_pages(dring->page_pool);
...@@ -741,6 +742,10 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv, ...@@ -741,6 +742,10 @@ static void *netsec_alloc_rx_data(struct netsec_priv *priv,
* cases and reserve enough space for headroom + skb_shared_info * cases and reserve enough space for headroom + skb_shared_info
*/ */
*desc_len = PAGE_SIZE - NETSEC_RX_BUF_NON_DATA; *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); return page_address(page);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment