diff options
author | Adi Suresh <adisuresh@google.com> | 2019-11-19 08:02:47 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-11-19 12:58:18 -0800 |
commit | db96c2cb4870173ea9b08df130f1d1cc9b5dd53d (patch) | |
tree | 3c56f3cc0471de9ed5b273e73fc18328366c552a | |
parent | 075e238d12c21c8bde700d21fb48be7a3aa80194 (diff) | |
download | linux-stable-db96c2cb4870173ea9b08df130f1d1cc9b5dd53d.tar.gz linux-stable-db96c2cb4870173ea9b08df130f1d1cc9b5dd53d.tar.bz2 linux-stable-db96c2cb4870173ea9b08df130f1d1cc9b5dd53d.zip |
gve: fix dma sync bug where not all pages synced
The previous commit had a bug where the last page in the memory range
could not be synced. This change fixes the behavior so that all the
required pages are synced.
Fixes: 9cfeeb576d49 ("gve: Fixes DMA synchronization")
Signed-off-by: Adi Suresh <adisuresh@google.com>
Reviewed-by: Catherine Sullivan <csully@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/google/gve/gve_tx.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c index 0a9a7ee2a866..f4889431f9b7 100644 --- a/drivers/net/ethernet/google/gve/gve_tx.c +++ b/drivers/net/ethernet/google/gve/gve_tx.c @@ -393,12 +393,13 @@ static void gve_tx_fill_seg_desc(union gve_tx_desc *seg_desc, static void gve_dma_sync_for_device(struct device *dev, dma_addr_t *page_buses, u64 iov_offset, u64 iov_len) { + u64 last_page = (iov_offset + iov_len - 1) / PAGE_SIZE; + u64 first_page = iov_offset / PAGE_SIZE; dma_addr_t dma; - u64 addr; + u64 page; - for (addr = iov_offset; addr < iov_offset + iov_len; - addr += PAGE_SIZE) { - dma = page_buses[addr / PAGE_SIZE]; + for (page = first_page; page <= last_page; page++) { + dma = page_buses[page]; dma_sync_single_for_device(dev, dma, PAGE_SIZE, DMA_TO_DEVICE); } } |