[PATCH v2 10/17] media/videbuf1|2: Mark follow_pfn usage as unsafe

Daniel Vetter daniel.vetter at ffwll.ch
Fri Oct 9 07:59:27 UTC 2020


The media model assumes that buffers are all preallocated, so that
when a media pipeline is running we never miss a deadline because the
buffers aren't allocated or available.

This means we cannot fix the v4l follow_pfn usage through
mmu_notifier, without breaking how this all works. The only real fix
is to deprecate userptr support for VM_IO | VM_PFNMAP mappings and
tell everyone to cut over to dma-buf memory sharing for zerocopy.

userptr for normal memory will keep working as-is.

Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
Cc: Jason Gunthorpe <jgg at ziepe.ca>
Cc: Kees Cook <keescook at chromium.org>
Cc: Dan Williams <dan.j.williams at intel.com>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: John Hubbard <jhubbard at nvidia.com>
Cc: Jérôme Glisse <jglisse at redhat.com>
Cc: Jan Kara <jack at suse.cz>
Cc: Dan Williams <dan.j.williams at intel.com>
Cc: linux-mm at kvack.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-media at vger.kernel.org
Cc: Pawel Osciak <pawel at osciak.com>
Cc: Marek Szyprowski <m.szyprowski at samsung.com>
Cc: Kyungmin Park <kyungmin.park at samsung.com>
Cc: Tomasz Figa <tfiga at chromium.org>
Cc: Laurent Dufour <ldufour at linux.ibm.com>
Cc: Vlastimil Babka <vbabka at suse.cz>
Cc: Daniel Jordan <daniel.m.jordan at oracle.com>
Cc: Michel Lespinasse <walken at google.com>
---
 drivers/media/common/videobuf2/frame_vector.c | 2 +-
 drivers/media/v4l2-core/videobuf-dma-contig.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/common/videobuf2/frame_vector.c b/drivers/media/common/videobuf2/frame_vector.c
index 2b0b97761d15..a1b85fe9e7c1 100644
--- a/drivers/media/common/videobuf2/frame_vector.c
+++ b/drivers/media/common/videobuf2/frame_vector.c
@@ -69,7 +69,7 @@ int get_vaddr_frames(unsigned long start, unsigned int nr_frames,
 			break;
 
 		while (ret < nr_frames && start + PAGE_SIZE <= vma->vm_end) {
-			err = follow_pfn(vma, start, &nums[ret]);
+			err = unsafe_follow_pfn(vma, start, &nums[ret]);
 			if (err) {
 				if (ret == 0)
 					ret = err;
diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c
index 52312ce2ba05..821c4a76ab96 100644
--- a/drivers/media/v4l2-core/videobuf-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf-dma-contig.c
@@ -183,7 +183,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem,
 	user_address = untagged_baddr;
 
 	while (pages_done < (mem->size >> PAGE_SHIFT)) {
-		ret = follow_pfn(vma, user_address, &this_pfn);
+		ret = unsafe_follow_pfn(vma, user_address, &this_pfn);
 		if (ret)
 			break;
 
-- 
2.28.0



More information about the dri-devel mailing list