From patchwork Tue Apr 9 11:37:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 2414631 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 11E113FD8C for ; Tue, 9 Apr 2013 11:39:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F20AAE60C3 for ; Tue, 9 Apr 2013 04:39:43 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by gabe.freedesktop.org (Postfix) with ESMTP id DEF7CE6078 for ; Tue, 9 Apr 2013 04:38:01 -0700 (PDT) Received: by mail-we0-f170.google.com with SMTP id z2so5399761wey.29 for ; Tue, 09 Apr 2013 04:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=TrYC9GBbXyDsHu0sCI3K1zB6sNxRoMuenMI0Grt5gU4=; b=X6nP0MOn0cYNS27s/Z4CtOLsylYJFcieaBmbBJ4Byr7J4R/XnZYia7nzmj+1Zuj3Sw dglTJE0Hu86hpFu8n5ztcFI1raUL3f+wAI+KoiUyMQm2VYN5pS1OsJ9+Zrme976ugxo8 F9ObpN/UcjJKazuyf7B7/zO4xSLl5w3GpoHHyNw+8DxyWFQYhqWoK7JZ9Shv3Um/h+h2 roqJpV/bCJ/oSC51ncPoMALlF5m+jqD0tPLiifHbNzUY0FlVoYO3c/Goh1pDvBwisTv5 H6cXMi98b/tXf1Mel3pEXpSFTem+ESrfN5WLhqtySAQglvPx55rgX9sHp+kLrOrdwlaa PJ3Q== X-Received: by 10.194.158.161 with SMTP id wv1mr37960982wjb.38.1365507481137; Tue, 09 Apr 2013 04:38:01 -0700 (PDT) Received: from localhost (5ED48CEF.cm-7-5c.dynamic.ziggo.nl. [94.212.140.239]) by mx.google.com with ESMTPS id n2sm25212673wiy.6.2013.04.09.04.37.58 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Apr 2013 04:37:59 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Tue, 09 Apr 2013 13:37:58 +0200 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/7] drm/radeon: implement unpin function Date: Tue, 9 Apr 2013 13:37:42 +0200 Message-Id: <1365507466-11586-3-git-send-email-maarten.lankhorst@canonical.com> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1365507466-11586-1-git-send-email-maarten.lankhorst@canonical.com> References: <1365507466-11586-1-git-send-email-maarten.lankhorst@canonical.com> 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 Signed-off-by: Maarten Lankhorst Reviewed-by: Jerome Glisse --- drivers/gpu/drm/radeon/radeon_drv.c | 2 ++ drivers/gpu/drm/radeon/radeon_prime.c | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 66a7f0f..6800c5e 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -124,6 +124,7 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev, size_t size, struct sg_table *sg); int radeon_gem_prime_pin(struct drm_gem_object *obj); +void radeon_gem_prime_unpin(struct drm_gem_object *obj); void *radeon_gem_prime_vmap(struct drm_gem_object *obj); void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); extern long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd, @@ -415,6 +416,7 @@ static struct drm_driver kms_driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import = drm_gem_prime_import, .gem_prime_pin = radeon_gem_prime_pin, + .gem_prime_unpin = radeon_gem_prime_unpin, .gem_prime_get_sg_table = radeon_gem_prime_get_sg_table, .gem_prime_import_sg_table = radeon_gem_prime_import_sg_table, .gem_prime_vmap = radeon_gem_prime_vmap, diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c index 4940af7..e557da5 100644 --- a/drivers/gpu/drm/radeon/radeon_prime.c +++ b/drivers/gpu/drm/radeon/radeon_prime.c @@ -88,10 +88,20 @@ int radeon_gem_prime_pin(struct drm_gem_object *obj) /* pin buffer into GTT */ ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL); - if (ret) { - radeon_bo_unreserve(bo); - return ret; - } + radeon_bo_unreserve(bo); + return ret; +} + +void radeon_gem_prime_unpin(struct drm_gem_object *obj) +{ + struct radeon_bo *bo = gem_to_radeon_bo(obj); + int ret = 0; + + ret = radeon_bo_reserve(bo, false); + if (unlikely(ret != 0)) + return; + + radeon_bo_unpin(bo); radeon_bo_unreserve(bo); return 0;