From patchwork Thu Aug 8 09:37:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 11083853 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 CE6981399 for ; Thu, 8 Aug 2019 09:37:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDF0328A60 for ; Thu, 8 Aug 2019 09:37:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B262E28AFD; Thu, 8 Aug 2019 09:37:23 +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 7293B28A60 for ; Thu, 8 Aug 2019 09:37:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F7C36E802; Thu, 8 Aug 2019 09:37:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 206B06E7B2 for ; Thu, 8 Aug 2019 09:37:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B145E316D798; Thu, 8 Aug 2019 09:37:07 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-144.ams2.redhat.com [10.36.116.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id 647B560BE1; Thu, 8 Aug 2019 09:37:04 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id AE46F9D21; Thu, 8 Aug 2019 11:37:03 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v3 6/8] drm/ttm: add drm_gem_ttm_bo_driver_verify_access() Date: Thu, 8 Aug 2019 11:37:00 +0200 Message-Id: <20190808093702.29512-7-kraxel@redhat.com> In-Reply-To: <20190808093702.29512-1-kraxel@redhat.com> References: <20190808093702.29512-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 08 Aug 2019 09:37:07 +0000 (UTC) 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: Maxime Ripard , open list , David Airlie , Gerd Hoffmann , tzimmermann@suse.de, Sean Paul MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gerd Hoffmann --- include/drm/drm_gem_ttm_helper.h | 2 ++ drivers/gpu/drm/drm_gem_ttm_helper.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/drm/drm_gem_ttm_helper.h b/include/drm/drm_gem_ttm_helper.h index 43c9db3583cc..78e4d8930fec 100644 --- a/include/drm/drm_gem_ttm_helper.h +++ b/include/drm/drm_gem_ttm_helper.h @@ -26,5 +26,7 @@ int drm_gem_ttm_bo_device_init(struct drm_device *dev, struct ttm_bo_device *bdev, struct ttm_bo_driver *driver, bool need_dma32); +int drm_gem_ttm_bo_driver_verify_access(struct ttm_buffer_object *bo, + struct file *filp); #endif diff --git a/drivers/gpu/drm/drm_gem_ttm_helper.c b/drivers/gpu/drm/drm_gem_ttm_helper.c index 0c57e9fd50b9..159768c7ec63 100644 --- a/drivers/gpu/drm/drm_gem_ttm_helper.c +++ b/drivers/gpu/drm/drm_gem_ttm_helper.c @@ -34,3 +34,25 @@ int drm_gem_ttm_bo_device_init(struct drm_device *dev, need_dma32); } EXPORT_SYMBOL(drm_gem_ttm_bo_device_init); + +/** + * drm_gem_ttm_bo_driver_verify_access() - \ + Implements &struct ttm_bo_driver.verify_access + * @bo: TTM buffer object. + * @filp: File pointer. + * + * This function assumes filp->private_data refers to the + * corresponding &struct drm_file. + * + * Returns: + * 0 on success, or + * a negative errno code otherwise. + */ +int drm_gem_ttm_bo_driver_verify_access(struct ttm_buffer_object *bo, + struct file *filp) +{ + struct drm_file *ptr = filp->private_data; + + return drm_vma_node_verify_access(&bo->base.vma_node, ptr); +} +EXPORT_SYMBOL(drm_gem_ttm_bo_driver_verify_access);