From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Herrmann Subject: [PATCH 3/7] drm/udl: import prime-fds with proper page-alignment Date: Mon, 20 Jan 2014 20:26:25 +0100 Message-ID: <1390245989-13280-3-git-send-email-dh.herrmann@gmail.com> References: <1390245989-13280-1-git-send-email-dh.herrmann@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-bk0-f49.google.com (mail-bk0-f49.google.com [209.85.214.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 66386FAC2E for ; Mon, 20 Jan 2014 11:26:51 -0800 (PST) Received: by mail-bk0-f49.google.com with SMTP id v15so598013bkz.8 for ; Mon, 20 Jan 2014 11:26:50 -0800 (PST) In-Reply-To: <1390245989-13280-1-git-send-email-dh.herrmann@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org Cc: Daniel Vetter List-Id: dri-devel@lists.freedesktop.org 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 --- 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