From patchwork Sun Jul 7 17:17:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2824599 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 D06EE9F9CA for ; Sun, 7 Jul 2013 17:29:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB266200E0 for ; Sun, 7 Jul 2013 17:29:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ED57C200D6 for ; Sun, 7 Jul 2013 17:29:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D8029E608D for ; Sun, 7 Jul 2013 10:29:17 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 76F12E606B for ; Sun, 7 Jul 2013 10:18:07 -0700 (PDT) Received: by mail-ea0-f171.google.com with SMTP id m14so2444122eaj.2 for ; Sun, 07 Jul 2013 10:18:06 -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=d3xrobbWLbiLcHmnbHlQlQq2l/3lONafUZB8HVwPQcQ=; b=NMuPrTsrHOD0I9VdOhwCSX6fQMcGoTjZa5sn4n8IxNT+W8EgmRTW7vMaTa9LkhnZZT 4s/0R9FwPtP/QboTK5r3TIsLA+K1Wsv8Iq9YHStLyMM1JIKHJhpNpdCXCsnScnk4ovpK +aZOiVV76k58/1tezi+3RnfU8kZd0An6TzItPETbRXU9VYYK8Cem+NePLHtYTlUFmFKa pEJRP732HCl2X1wYaM8FqIa/x/rqtx2NhCLzJobtkBw9adsHecxU9jwKhqED7Oezq5my 6rzT0oqmuWHUYDWsL/VqlRTGoC+iPxRHFvJPaIAcGab184NOKrhQektuFdm7tObspJe+ Mgcg== X-Received: by 10.15.52.5 with SMTP id o5mr21406040eew.58.1373217486812; Sun, 07 Jul 2013 10:18:06 -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.04 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 07 Jul 2013 10:18:05 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 13/20] drm/nouveau: implement mmap access managament Date: Sun, 7 Jul 2013 19:17:29 +0200 Message-Id: <1373217456-32282-14-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 , Ben Skeggs , 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: 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 86597eb..04d0a7d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -73,32 +73,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; } @@ -145,6 +154,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;