From patchwork Fri Jul 26 10:09:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2833959 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0A47CC0319 for ; Fri, 26 Jul 2013 10:10:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD21220148 for ; Fri, 26 Jul 2013 10:10:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8B79720113 for ; Fri, 26 Jul 2013 10:10:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 87479E7324 for ; Fri, 26 Jul 2013 03:10:20 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C86FE6086 for ; Fri, 26 Jul 2013 03:10:02 -0700 (PDT) Received: by mail-ea0-f171.google.com with SMTP id n15so1453612ead.16 for ; Fri, 26 Jul 2013 03:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=pC5qJZzNd9LSaXqhJ3y8vu4lBKL7sl6UgLhOk1R00FE=; b=VSIwIoWRIE4OJfwq8PLdBOjQDdEGgUZJR/i6RyVDT/IYM3IOPd0kUvevLeEjEl3xWA WIfIX/1ez7FyN2giu+veL6zVqiB3AVE3/vTU5A6VG844kLtuuMbzdCEvyPLYF4nlx6Ai OTb1py+TDQIVijs/TghqKBcW9HUTUXGmmdJrPC/DhemhXjIO3ccg2US1xTjw4tJFqTi6 SHn4i7AT4lA5vtIyxdo/Cc/0U1zIPKTr85RaIROs2K5DiDrHClLZ4MM7CT7qfkGf34WI 0NSHRz2KsgbG3Mi0eUEZjYkstkCNHJl5F5A2QksS08MANMvsLF9y1EZmAKBwPWH1W1le MztQ== X-Received: by 10.15.44.67 with SMTP id y43mr46947277eev.20.1374833401612; Fri, 26 Jul 2013 03:10:01 -0700 (PDT) Received: from localhost.localdomain (stgt-5f718745.pool.mediaWays.net. [95.113.135.69]) by mx.google.com with ESMTPSA id l42sm79924805eeo.14.2013.07.26.03.09.59 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Jul 2013 03:10:00 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/gem: fix mmap vma size calculations Date: Fri, 26 Jul 2013 12:09:32 +0200 Message-Id: <1374833372-21926-1-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1374830685-21602-1-git-send-email-dh.herrmann@gmail.com> References: <1374830685-21602-1-git-send-email-dh.herrmann@gmail.com> Cc: Sedat Dilek , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The VMA manager is page-size based so drm_vma_node_size() returns the size in pages. However, drm_gem_mmap_obj() requires the size in bytes. Apply PAGE_SHIFT so we no longer get EINVAL during mmaps due to too small buffers. This bug was introduced in commit: 0de23977cfeb5b357ec884ba15417ae118ff9e9b "drm/gem: convert to new unified vma manager" Fixes i915 gtt mmap failure reported by Sedat Dilek in: Re: linux-next: Tree for Jul 25 [ call-trace: drm | drm-intel related? ] Cc: Daniel Vetter Cc: Chris Wilson Signed-off-by: David Herrmann Reported-by: Sedat Dilek Tested-by: Sedat Dilek Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 3613b50..1f76572 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -666,7 +666,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) } obj = container_of(node, struct drm_gem_object, vma_node); - ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node), vma); + ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node) << PAGE_SHIFT, vma); mutex_unlock(&dev->struct_mutex);