From patchwork Tue Aug 13 19:38:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2843978 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 79A159F239 for ; Tue, 13 Aug 2013 19:48:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADE0620483 for ; Tue, 13 Aug 2013 19:48:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 657A120480 for ; Tue, 13 Aug 2013 19:48:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 61F01E7C32 for ; Tue, 13 Aug 2013 12:48:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f175.google.com (mail-ea0-f175.google.com [209.85.215.175]) by gabe.freedesktop.org (Postfix) with ESMTP id 63B58E7C5D for ; Tue, 13 Aug 2013 12:40:01 -0700 (PDT) Received: by mail-ea0-f175.google.com with SMTP id m14so1715674eaj.6 for ; Tue, 13 Aug 2013 12:40:00 -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:in-reply-to:references; bh=rTqBAmHyiCou4lGaKjOzUBuJy7HmCFag4cbu1IMjWTg=; b=h+HVKY97Qlvkts5EcAuqzzbmtcXl3QQAo5zUB2foNCug7g3Ij14HBjF5NeaS1VT3+l HUPBXbJ5t3Q5t3th+hbPUiPdoDELhyFHFvpLHK7HWWXUGePs/FFDSMMeyXOcMAPLzNXR EXpJxQqACEFm15XxfHzxabwCxK6OnEUhuobYxp8Z8qSZijwuOPGu1iZtiS9CyBLCsTZ3 48wcQgW9KnEuWgUmpQCEzWlo+E2EwN2rqWJgBxLX8xJtzbjFW4SbqvxTdj6nlLloKql9 FDDhuaVuKQo/KBLEgI1w+5TRw77Ss0jWW+YeD/uRyT1q5yjyvCMeremv3Tj9biA1FBCb gsrA== X-Received: by 10.14.225.199 with SMTP id z47mr8721210eep.24.1376422800588; Tue, 13 Aug 2013 12:40:00 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71b8eb.pool.mediaWays.net. [95.113.184.235]) by mx.google.com with ESMTPSA id a1sm68812938eem.1.2013.08.13.12.39.58 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Aug 2013 12:39:59 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 05/16] drm/nouveau: implement mmap access managament Date: Tue, 13 Aug 2013 21:38:26 +0200 Message-Id: <1376422717-12229-6-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1376422717-12229-1-git-send-email-dh.herrmann@gmail.com> References: <1376422717-12229-1-git-send-email-dh.herrmann@gmail.com> Cc: Ben Skeggs 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=-6.9 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: Ben Skeggs Signed-off-by: David Herrmann --- drivers/gpu/drm/nouveau/nouveau_gem.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 487242f..f2c4040 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -67,32 +67,41 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv) struct nouveau_vma *vma; int ret; + ret = drm_vma_node_allow(&nvbo->bo.vma_node, file_priv->filp); + if (ret) + return ret; + if (!cli->base.vm) return 0; ret = ttm_bo_reserve(&nvbo->bo, false, false, false, 0); if (ret) - return ret; + goto err_node; vma = nouveau_bo_vma_find(nvbo, cli->base.vm); if (!vma) { vma = kzalloc(sizeof(*vma), GFP_KERNEL); if (!vma) { ret = -ENOMEM; - goto out; + goto err_reserve; } ret = nouveau_bo_vma_add(nvbo, cli->base.vm, vma); if (ret) { kfree(vma); - goto out; + goto err_reserve; } } else { vma->refcount++; } -out: ttm_bo_unreserve(&nvbo->bo); + return 0; + +err_reserve: + ttm_bo_unreserve(&nvbo->bo); +err_node: + drm_vma_node_revoke(&nvbo->bo.vma_node, file_priv->filp); return ret; } @@ -139,6 +148,8 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv) struct nouveau_vma *vma; int ret; + drm_vma_node_revoke(&nvbo->bo.vma_node, file_priv->filp); + if (!cli->base.vm) return;