From patchwork Sun Jul 7 17:17:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2824598 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF59B9F9CA for ; Sun, 7 Jul 2013 17:28:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16F1C20122 for ; Sun, 7 Jul 2013 17:28:35 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 39AFB2011D for ; Sun, 7 Jul 2013 17:28:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0EB34E608E for ; Sun, 7 Jul 2013 10:28:34 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f173.google.com (mail-ea0-f173.google.com [209.85.215.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EA1AE5FF8 for ; Sun, 7 Jul 2013 10:18:05 -0700 (PDT) Received: by mail-ea0-f173.google.com with SMTP id g15so2459626eak.18 for ; Sun, 07 Jul 2013 10:18:04 -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=Qh81K+A5137VMsXl7pslNNBQP1kTKB0bZF0LaCwQY54=; b=RlWOcChTaac1Y1jozQK1UYCcS6f8CehIl8HNbKk6Iauahi7gg0O5B6slYjr1nXCeOx 4Z3xuEQvkcgZ/M7gYPePIHInsLHWppbDFHUBTzTmH197wlF3YJqIbkGDMtBmcF3iTBwH e2j1+R4MbDldHkFcapVDKHKcxmqHpDjMww+Qc1xmPEbg8yvJ3X1hWGaEDOXW0qlSavtS PgkU23TS8oxqjTJ5F8elm0C/VDA+3lgWqnXPLRy7quYl1NFfWoeUptBEqTjNMlBsC6/D DqtSsHB31A+HrtCVMVevUEgOfwFlbeDKBWChiBp9Bw9UR6vHsjBkRbLivtgcFaJ/rRn6 XdTw== X-Received: by 10.14.29.69 with SMTP id h45mr21265756eea.127.1373217484843; Sun, 07 Jul 2013 10:18:04 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71834a.pool.mediaWays.net. [95.113.131.74]) by mx.google.com with ESMTPSA id n45sm34781333eew.1.2013.07.07.10.18.03 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 07 Jul 2013 10:18:04 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 12/20] drm/mgag200: implement mmap access managament Date: Sun, 7 Jul 2013 19:17:28 +0200 Message-Id: <1373217456-32282-13-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1373217456-32282-1-git-send-email-dh.herrmann@gmail.com> References: <1373217456-32282-1-git-send-email-dh.herrmann@gmail.com> Cc: Daniel Vetter , Martin Peres , Dave Airlie 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=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 Correctly allow and revoke buffer access on each open/close via the new VMA offset manager. Cc: Dave Airlie Signed-off-by: David Herrmann --- drivers/gpu/drm/mgag200/mgag200_drv.c | 2 ++ drivers/gpu/drm/mgag200/mgag200_drv.h | 4 ++++ drivers/gpu/drm/mgag200/mgag200_main.c | 15 +++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 122b571..d26a244 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -102,6 +102,8 @@ static struct drm_driver driver = { .gem_init_object = mgag200_gem_init_object, .gem_free_object = mgag200_gem_free_object, + .gem_open_object = mgag200_gem_open_object, + .gem_close_object = mgag200_gem_close_object, .dumb_create = mgag200_dumb_create, .dumb_map_offset = mgag200_dumb_mmap_offset, .dumb_destroy = mgag200_dumb_destroy, diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 12e2499..4e674be 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -268,6 +268,10 @@ int mgag200_dumb_destroy(struct drm_file *file, struct drm_device *dev, uint32_t handle); void mgag200_gem_free_object(struct drm_gem_object *obj); +int mgag200_gem_open_object(struct drm_gem_object *obj, + struct drm_file *file_priv); +void mgag200_gem_close_object(struct drm_gem_object *obj, + struct drm_file *file_priv); int mgag200_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev, diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 1a75ea3..26bee28 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -346,6 +346,21 @@ void mgag200_gem_free_object(struct drm_gem_object *obj) mgag200_bo_unref(&mgag200_bo); } +int mgag200_gem_open_object(struct drm_gem_object *obj, + struct drm_file *file_priv) +{ + struct mgag200_bo *bo = gem_to_mga_bo(obj); + + return drm_vma_node_allow(&bo->bo.vma_node, file_priv->filp); +} + +void mgag200_gem_close_object(struct drm_gem_object *obj, + struct drm_file *file_priv) +{ + struct mgag200_bo *bo = gem_to_mga_bo(obj); + + drm_vma_node_revoke(&bo->bo.vma_node, file_priv->filp); +} static inline u64 mgag200_bo_mmap_offset(struct mgag200_bo *bo) {