Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Adi Suresh and committed by
David S. Miller
db96c2cb 075e238d

+5 -4
+5 -4
drivers/net/ethernet/google/gve/gve_tx.c
··· 393 393 static void gve_dma_sync_for_device(struct device *dev, dma_addr_t *page_buses, 394 394 u64 iov_offset, u64 iov_len) 395 395 { 396 + u64 last_page = (iov_offset + iov_len - 1) / PAGE_SIZE; 397 + u64 first_page = iov_offset / PAGE_SIZE; 396 398 dma_addr_t dma; 397 - u64 addr; 399 + u64 page; 398 400 399 - for (addr = iov_offset; addr < iov_offset + iov_len; 400 - addr += PAGE_SIZE) { 401 - dma = page_buses[addr / PAGE_SIZE]; 401 + for (page = first_page; page <= last_page; page++) { 402 + dma = page_buses[page]; 402 403 dma_sync_single_for_device(dev, dma, PAGE_SIZE, DMA_TO_DEVICE); 403 404 } 404 405 }