diff mbox series

[net,v2] gve: fix dma sync bug where not all pages synced

Message ID 20191118234240.191075-1-adisuresh@google.com
State Not Applicable
Delegated to: David Miller
Headers show
Series [net,v2] gve: fix dma sync bug where not all pages synced | expand

Commit Message

Adi Suresh Nov. 18, 2019, 11:42 p.m. UTC
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>
---
 Changes in v2:
 - Added Fixes tag and reference commit hash of previous commit
 - Moved variable declaration to top of method

 drivers/net/ethernet/google/gve/gve_tx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

David Miller Nov. 19, 2019, 2:03 a.m. UTC | #1
From: Adi Suresh <adisuresh@google.com>
Date: Mon, 18 Nov 2019 15:42:40 -0800

> 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")

12 digits of SHA1 hash signifigance in Fixes: tags please.

Thank you.
Adi Suresh Nov. 19, 2019, 2:48 a.m. UTC | #2
Addressed in v3


On Mon, Nov 18, 2019 at 6:03 PM David Miller <davem@davemloft.net> wrote:
>
> From: Adi Suresh <adisuresh@google.com>
> Date: Mon, 18 Nov 2019 15:42:40 -0800
>
> > 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")
>
> 12 digits of SHA1 hash signifigance in Fixes: tags please.
>
> Thank you.
>
diff mbox series

Patch

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);
 	}
 }