From patchwork Sun Jul 7 18:58:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 2824613 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 BAD48C0AB2 for ; Sun, 7 Jul 2013 19:01:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA35B20122 for ; Sun, 7 Jul 2013 19:01:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C9A4320121 for ; Sun, 7 Jul 2013 19:01:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 88EFCE5C1F for ; Sun, 7 Jul 2013 12:01:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 4402BE60BB for ; Sun, 7 Jul 2013 11:59:05 -0700 (PDT) Received: by mail-pd0-f176.google.com with SMTP id t12so3367790pdi.35 for ; Sun, 07 Jul 2013 11:59:05 -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=3OqmEXzjLnLKVnyP8d4OhPMgYzCpzkPmyOaXfMBWAGc=; b=k5ap0rBjJI0vnmZRtuehog5pD264x5c7hhTgGfhv9VSjeTJjLM8mP6mNj7CDK47oJb F/JnhoXGjUpQPX37ja7uQDWarkWd88F+oNy6AuKd6tvuLuS0fMZTRualREBTUr4hTUfR wcYcL4dUG3itBLwtGQhKmPlgP/wFhQgQWQfvCcOrS+pscolgswmdgByUjGv/48BtrDmy fTwfpw5yartRfaU+NwmLlBV/VGjufJUfSaPmjQBS/WuW134zmD6DDzy5aVTmCwfpw4pH gWrrkCEwgz9kFaP60wripV4pM6fQ1KaTaSwtCKnX3rVdGlkkhB29DHKOhc8S3ACFQN4+ oV3w== X-Received: by 10.66.246.194 with SMTP id xy2mr15124025pac.131.1373223545023; Sun, 07 Jul 2013 11:59:05 -0700 (PDT) Received: from localhost (netblock-66-245-248-130.dslextreme.com. [66.245.248.130]) by mx.google.com with ESMTPSA id td4sm19702170pac.20.2013.07.07.11.59.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 07 Jul 2013 11:59:04 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/5] drm/gem: add drm_gem_create_mmap_offset_size() Date: Sun, 7 Jul 2013 14:58:47 -0400 Message-Id: <1373223531-19058-2-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1373223531-19058-1-git-send-email-robdclark@gmail.com> References: <1373223531-19058-1-git-send-email-robdclark@gmail.com> 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=-4.4 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=ham 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 Variant of drm_gem_create_mmap_offset() which doesn't make the assumption that virtual size and physical size (obj->size) are the same. This is needed in omapdrm to deal with tiled buffers. And lets us get rid of a duplicated and slightly modified version of drm_gem_create_mmap_offset() in omapdrm. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_gem.c | 28 ++++++++++++++++++++++++---- include/drm/drmP.h | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index cf919e3..443eeff 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -320,18 +320,21 @@ drm_gem_free_mmap_offset(struct drm_gem_object *obj) EXPORT_SYMBOL(drm_gem_free_mmap_offset); /** - * drm_gem_create_mmap_offset - create a fake mmap offset for an object + * drm_gem_create_mmap_offset_size - create a fake mmap offset for an object * @obj: obj in question + * @size: the virtual size * * GEM memory mapping works by handing back to userspace a fake mmap offset * it can use in a subsequent mmap(2) call. The DRM core code then looks * up the object based on the offset and sets up the various memory mapping * structures. * - * This routine allocates and attaches a fake offset for @obj. + * This routine allocates and attaches a fake offset for @obj, in cases where + * the virtual size differs from the physical size (ie. obj->size). Otherwise + * just use drm_gem_create_mmap_offset(). */ int -drm_gem_create_mmap_offset(struct drm_gem_object *obj) +drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size) { struct drm_device *dev = obj->dev; struct drm_gem_mm *mm = dev->mm_private; @@ -347,7 +350,7 @@ drm_gem_create_mmap_offset(struct drm_gem_object *obj) map = list->map; map->type = _DRM_GEM; - map->size = obj->size; + map->size = size; map->handle = obj; /* Get a DRM GEM mmap offset allocated... */ @@ -384,6 +387,23 @@ out_free_list: return ret; } +EXPORT_SYMBOL(drm_gem_create_mmap_offset_size); + +/** + * drm_gem_create_mmap_offset - create a fake mmap offset for an object + * @obj: obj in question + * + * GEM memory mapping works by handing back to userspace a fake mmap offset + * it can use in a subsequent mmap(2) call. The DRM core code then looks + * up the object based on the offset and sets up the various memory mapping + * structures. + * + * This routine allocates and attaches a fake offset for @obj. + */ +int drm_gem_create_mmap_offset(struct drm_gem_object *obj) +{ + return drm_gem_create_mmap_offset_size(obj, obj->size); +} EXPORT_SYMBOL(drm_gem_create_mmap_offset); /** Returns a reference to the object named by the handle. */ diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 63d17ee..3cb1672 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1728,6 +1728,7 @@ drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj) void drm_gem_free_mmap_offset(struct drm_gem_object *obj); int drm_gem_create_mmap_offset(struct drm_gem_object *obj); +int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size); struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev, struct drm_file *filp,