linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: jglisse@redhat.com
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Ralph Campbell" <rcampbell@nvidia.com>,
	"John Hubbard" <jhubbard@nvidia.com>
Subject: [PATCH] mm/hmm: fix hmm_range_dma_map()/hmm_range_dma_unmap()
Date: Tue,  9 Apr 2019 13:53:40 -0400	[thread overview]
Message-ID: <20190409175340.26614-1-jglisse@redhat.com> (raw)

From: Jérôme Glisse <jglisse@redhat.com>

Was using wrong field and wrong enum for read only versus read and
write mapping.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
---
 mm/hmm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index 90369fd2307b..ecd16718285e 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -1203,7 +1203,7 @@ long hmm_range_dma_map(struct hmm_range *range,
 
 	npages = (range->end - range->start) >> PAGE_SHIFT;
 	for (i = 0, mapped = 0; i < npages; ++i) {
-		enum dma_data_direction dir = DMA_FROM_DEVICE;
+		enum dma_data_direction dir = DMA_TO_DEVICE;
 		struct page *page;
 
 		/*
@@ -1227,7 +1227,7 @@ long hmm_range_dma_map(struct hmm_range *range,
 		}
 
 		/* If it is read and write than map bi-directional. */
-		if (range->pfns[i] & range->values[HMM_PFN_WRITE])
+		if (range->pfns[i] & range->flags[HMM_PFN_WRITE])
 			dir = DMA_BIDIRECTIONAL;
 
 		daddrs[i] = dma_map_page(device, page, 0, PAGE_SIZE, dir);
@@ -1243,7 +1243,7 @@ long hmm_range_dma_map(struct hmm_range *range,
 
 unmap:
 	for (npages = i, i = 0; (i < npages) && mapped; ++i) {
-		enum dma_data_direction dir = DMA_FROM_DEVICE;
+		enum dma_data_direction dir = DMA_TO_DEVICE;
 		struct page *page;
 
 		page = hmm_device_entry_to_page(range, range->pfns[i]);
@@ -1254,7 +1254,7 @@ long hmm_range_dma_map(struct hmm_range *range,
 			continue;
 
 		/* If it is read and write than map bi-directional. */
-		if (range->pfns[i] & range->values[HMM_PFN_WRITE])
+		if (range->pfns[i] & range->flags[HMM_PFN_WRITE])
 			dir = DMA_BIDIRECTIONAL;
 
 		dma_unmap_page(device, daddrs[i], PAGE_SIZE, dir);
@@ -1298,7 +1298,7 @@ long hmm_range_dma_unmap(struct hmm_range *range,
 
 	npages = (range->end - range->start) >> PAGE_SHIFT;
 	for (i = 0; i < npages; ++i) {
-		enum dma_data_direction dir = DMA_FROM_DEVICE;
+		enum dma_data_direction dir = DMA_TO_DEVICE;
 		struct page *page;
 
 		page = hmm_device_entry_to_page(range, range->pfns[i]);
@@ -1306,7 +1306,7 @@ long hmm_range_dma_unmap(struct hmm_range *range,
 			continue;
 
 		/* If it is read and write than map bi-directional. */
-		if (range->pfns[i] & range->values[HMM_PFN_WRITE]) {
+		if (range->pfns[i] & range->flags[HMM_PFN_WRITE]) {
 			dir = DMA_BIDIRECTIONAL;
 
 			/*
-- 
2.20.1


             reply	other threads:[~2019-04-09 17:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 17:53 jglisse [this message]
2019-04-09 21:52 ` [PATCH] mm/hmm: fix hmm_range_dma_map()/hmm_range_dma_unmap() Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190409175340.26614-1-jglisse@redhat.com \
    --to=jglisse@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rcampbell@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).