From patchwork Thu May 16 14:14:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 10947471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9ED941398 for ; Fri, 17 May 2019 07:55:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91425201CB for ; Fri, 17 May 2019 07:55:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 851342237D; Fri, 17 May 2019 07:55:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39281201CB for ; Fri, 17 May 2019 07:55:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C9AC6898ED; Fri, 17 May 2019 07:54:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EB7C89612 for ; Thu, 16 May 2019 14:15:05 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E46871AED; Thu, 16 May 2019 07:15:04 -0700 (PDT) Received: from e112269-lin.arm.com (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF8893F71E; Thu, 16 May 2019 07:15:01 -0700 (PDT) From: Steven Price To: Daniel Vetter , Rob Herring , Tomeu Vizoso Subject: [PATCH v2 2/3] drm: shmem: Add drm_gem_shmem_map_offset() wrapper Date: Thu, 16 May 2019 15:14:46 +0100 Message-Id: <20190516141447.46839-3-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190516141447.46839-1-steven.price@arm.com> References: <20190516141447.46839-1-steven.price@arm.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 17 May 2019 07:54:52 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Seung-Woo Kim , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Maxime Ripard , Kyungmin Park , Kukjin Kim , dri-devel@lists.freedesktop.org, Steven Price , Sean Paul , Alyssa Rosenzweig Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Provide a wrapper for drm_gem_map_offset() for clients of shmem. This wrapper provides the correct semantics for the drm_gem_shmem_mmap() callback. Signed-off-by: Steven Price --- drivers/gpu/drm/drm_gem_shmem_helper.c | 20 ++++++++++++++++++++ include/drm/drm_gem_shmem_helper.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 1ee208c2c85e..9dbebc4897d1 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -400,6 +400,26 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev, } EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create); +/** + * drm_gem_map_offset - return the fake mmap offset for a gem object + * @file: drm file-private structure containing the gem object + * @dev: corresponding drm_device + * @handle: gem object handle + * @offset: return location for the fake mmap offset + * + * This provides an offset suitable for user space to return to the + * drm_gem_shmem_mmap() callback via an mmap() call. + * + * Returns: + * 0 on success or a negative error code on failure. + */ +int drm_gem_shmem_map_offset(struct drm_file *file, struct drm_device *dev, + u32 handle, u64 *offset) +{ + return drm_gem_map_offset(file, dev, handle, offset); +} +EXPORT_SYMBOL_GPL(drm_gem_shmem_map_offset); + static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h index 038b6d313447..4239ddaaaa4f 100644 --- a/include/drm/drm_gem_shmem_helper.h +++ b/include/drm/drm_gem_shmem_helper.h @@ -128,6 +128,8 @@ drm_gem_shmem_create_with_handle(struct drm_file *file_priv, int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args); +int drm_gem_shmem_map_offset(struct drm_file *file, struct drm_device *dev, + u32 handle, u64 *offset); int drm_gem_shmem_mmap(struct file *filp, struct vm_area_struct *vma); extern const struct vm_operations_struct drm_gem_shmem_vm_ops;