[PATCH 3/7] drm/udl: import prime-fds with proper page-alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of rounding down to the next lower page-boundary, round up.
dma-buf guarantees that we can map buffers in multiples of a page, so if
an exporter does not page-align, do it ourselves.

This avoids issues if the exported buffer contains an unaligned size and
we crop it. In this case, the buffer is too small for the UDL CRTC. So we
round up to page-size now and avoid black borders. Worst case is we end up
reading out some random kernel memory, but we can never fault as the whole
page has the same access-rights. And in this case it's an issue of the
buggy exporting driver, not the importing one.

Signed-off-by: David Herrmann <dh.herrmann@xxxxxxxxx>
---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index df963a1..1069e57 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -227,7 +227,7 @@ static int udl_prime_create(struct drm_device *dev,
 	struct udl_gem_object *obj;
 	int npages;
 
-	npages = size / PAGE_SIZE;
+	npages = PAGE_ALIGN(size) >> PAGE_SHIFT;
 
 	*obj_p = NULL;
 	obj = udl_gem_alloc_object(dev, npages * PAGE_SIZE);
-- 
1.8.5.3

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux