Skip to content

Commit db96c2c

Browse files
Adi Sureshdavem330
authored andcommitted
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: 9cfeeb5 ("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>
1 parent 075e238 commit db96c2c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/net/ethernet/google/gve/gve_tx.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,13 @@ static void gve_tx_fill_seg_desc(union gve_tx_desc *seg_desc,
393393
static void gve_dma_sync_for_device(struct device *dev, dma_addr_t *page_buses,
394394
u64 iov_offset, u64 iov_len)
395395
{
396+
u64 last_page = (iov_offset + iov_len - 1) / PAGE_SIZE;
397+
u64 first_page = iov_offset / PAGE_SIZE;
396398
dma_addr_t dma;
397-
u64 addr;
399+
u64 page;
398400

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];
402403
dma_sync_single_for_device(dev, dma, PAGE_SIZE, DMA_TO_DEVICE);
403404
}
404405
}

0 commit comments

Comments
 (0)