The patch titled Subject: mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3-fix has been added to the -mm tree. Its filename is mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3-fix.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3-fix.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jérôme Glisse <jglisse@xxxxxxxxxx> Subject: mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3-fix Was using wrong field and wrong enum for read only versus read and write mapping. Link: http://lkml.kernel.org/r/20190409175340.26614-1-jglisse@xxxxxxxxxx Signed-off-by: Jérôme Glisse <jglisse@xxxxxxxxxx> Cc: Ralph Campbell <rcampbell@xxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/hmm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/mm/hmm.c~mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3-fix +++ a/mm/hmm.c @@ -1200,7 +1200,7 @@ long hmm_range_dma_map(struct hmm_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; /* @@ -1224,7 +1224,7 @@ long hmm_range_dma_map(struct hmm_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); @@ -1240,7 +1240,7 @@ long hmm_range_dma_map(struct hmm_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_pfn_to_page(range, range->pfns[i]); @@ -1251,7 +1251,7 @@ unmap: 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); @@ -1295,7 +1295,7 @@ long hmm_range_dma_unmap(struct hmm_rang 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_pfn_to_page(range, range->pfns[i]); @@ -1303,7 +1303,7 @@ long hmm_range_dma_unmap(struct hmm_rang 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; /* _ Patches currently in -mm which might be from jglisse@xxxxxxxxxx are mm-hmm-select-mmu-notifier-when-selecting-hmm-v2.patch mm-hmm-use-reference-counting-for-hmm-struct-v3.patch mm-hmm-do-not-erase-snapshot-when-a-range-is-invalidated.patch mm-hmm-improve-and-rename-hmm_vma_get_pfns-to-hmm_range_snapshot-v2.patch mm-hmm-improve-and-rename-hmm_vma_fault-to-hmm_range_fault-v3.patch mm-hmm-improve-driver-api-to-work-and-wait-over-a-range-v3.patch mm-hmm-add-default-fault-flags-to-avoid-the-need-to-pre-fill-pfns-arrays-v2.patch mm-hmm-mirror-hugetlbfs-snapshoting-faulting-and-dma-mapping-v3.patch mm-hmm-allow-to-mirror-vma-of-a-file-on-a-dax-backed-filesystem-v3.patch mm-hmm-add-helpers-to-test-if-mm-is-still-alive-or-not.patch mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3.patch mm-hmm-add-an-helper-function-that-fault-pages-and-map-them-to-a-device-v3-fix.patch mm-hmm-convert-various-hmm_pfn_-to-device_entry-which-is-a-better-name.patch