From patchwork Wed Mar 16 11:56:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 8599341 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 54CDE9F294 for ; Wed, 16 Mar 2016 11:57:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E5C920114 for ; Wed, 16 Mar 2016 11:57:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 66416202A1 for ; Wed, 16 Mar 2016 11:57:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CBA8A6E8F9; Wed, 16 Mar 2016 11:57:20 +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 AF2CD6E8F5 for ; Wed, 16 Mar 2016 11:56:57 +0000 (UTC) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 64477C049E15; Wed, 16 Mar 2016 11:56:57 +0000 (UTC) Received: from localhost.localdomain.com (vpn-60-117.rdu2.redhat.com [10.10.60.117]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2GBupO9003040; Wed, 16 Mar 2016 07:56:56 -0400 From: jglisse@redhat.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/radeon: uvd/vce properly pin/unpin firmware accross suspend/resume. Date: Wed, 16 Mar 2016 12:56:47 +0100 Message-Id: <1458129407-4940-3-git-send-email-jglisse@redhat.com> In-Reply-To: <1458129407-4940-1-git-send-email-jglisse@redhat.com> References: <1458129407-4940-1-git-send-email-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Cc: Alex Deucher , =?UTF-8?q?J=C3=A9rome=20Glisse?= , =?UTF-8?q?Christian=20K=C3=B6nig?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 From: Jérome Glisse We need to unpin on suspend and pin on resume. This shuffle code around to do just that. Signed-off-by: Jérôme Glisse Cc: Alex Deucher Cc: Christian König --- drivers/gpu/drm/radeon/radeon_uvd.c | 61 ++++++++++++++++--------------------- drivers/gpu/drm/radeon/radeon_vce.c | 37 +++++++++------------- 2 files changed, 41 insertions(+), 57 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c index 6fe9e4e..333b885 100644 --- a/drivers/gpu/drm/radeon/radeon_uvd.c +++ b/drivers/gpu/drm/radeon/radeon_uvd.c @@ -148,30 +148,6 @@ int radeon_uvd_init(struct radeon_device *rdev) return r; } - r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); - if (r) { - radeon_bo_unref(&rdev->uvd.vcpu_bo); - dev_err(rdev->dev, "(%d) failed to reserve UVD bo\n", r); - return r; - } - - r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM, - &rdev->uvd.gpu_addr); - if (r) { - radeon_bo_unreserve(rdev->uvd.vcpu_bo); - radeon_bo_unref(&rdev->uvd.vcpu_bo); - dev_err(rdev->dev, "(%d) UVD bo pin failed\n", r); - return r; - } - - r = radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr); - if (r) { - dev_err(rdev->dev, "(%d) UVD map failed\n", r); - return r; - } - - radeon_bo_unreserve(rdev->uvd.vcpu_bo); - for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { atomic_set(&rdev->uvd.handles[i], 0); rdev->uvd.filp[i] = NULL; @@ -183,18 +159,9 @@ int radeon_uvd_init(struct radeon_device *rdev) void radeon_uvd_fini(struct radeon_device *rdev) { - int r; - if (rdev->uvd.vcpu_bo == NULL) return; - r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); - if (!r) { - radeon_bo_kunmap(rdev->uvd.vcpu_bo); - radeon_bo_unpin(rdev->uvd.vcpu_bo); - radeon_bo_unreserve(rdev->uvd.vcpu_bo); - } - radeon_bo_unref(&rdev->uvd.vcpu_bo); radeon_ring_fini(rdev, &rdev->ring[R600_RING_TYPE_UVD_INDEX]); @@ -231,6 +198,13 @@ int radeon_uvd_suspend(struct radeon_device *rdev) } } + r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); + if (!r) { + radeon_bo_kunmap(rdev->uvd.vcpu_bo); + radeon_bo_unpin(rdev->uvd.vcpu_bo); + radeon_bo_unreserve(rdev->uvd.vcpu_bo); + } + return 0; } @@ -238,9 +212,26 @@ int radeon_uvd_resume(struct radeon_device *rdev) { unsigned size; void *ptr; + int r; - if (rdev->uvd.vcpu_bo == NULL) - return -EINVAL; + r = radeon_bo_reserve(rdev->uvd.vcpu_bo, false); + if (r) { + dev_err(rdev->dev, "(%d) failed to reserve UVD bo\n", r); + return r; + } + r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM, + &rdev->uvd.gpu_addr); + if (r) { + radeon_bo_unreserve(rdev->uvd.vcpu_bo); + dev_err(rdev->dev, "(%d) UVD bo pin failed\n", r); + return r; + } + r = radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr); + radeon_bo_unreserve(rdev->uvd.vcpu_bo); + if (r) { + dev_err(rdev->dev, "(%d) UVD map failed\n", r); + return r; + } memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); diff --git a/drivers/gpu/drm/radeon/radeon_vce.c b/drivers/gpu/drm/radeon/radeon_vce.c index c1c619f..4f7ae3c 100644 --- a/drivers/gpu/drm/radeon/radeon_vce.c +++ b/drivers/gpu/drm/radeon/radeon_vce.c @@ -147,22 +147,6 @@ int radeon_vce_init(struct radeon_device *rdev) return r; } - r = radeon_bo_reserve(rdev->vce.vcpu_bo, false); - if (r) { - radeon_bo_unref(&rdev->vce.vcpu_bo); - dev_err(rdev->dev, "(%d) failed to reserve VCE bo\n", r); - return r; - } - - r = radeon_bo_pin(rdev->vce.vcpu_bo, RADEON_GEM_DOMAIN_VRAM, - &rdev->vce.gpu_addr); - radeon_bo_unreserve(rdev->vce.vcpu_bo); - if (r) { - radeon_bo_unref(&rdev->vce.vcpu_bo); - dev_err(rdev->dev, "(%d) VCE bo pin failed\n", r); - return r; - } - for (i = 0; i < RADEON_MAX_VCE_HANDLES; ++i) { atomic_set(&rdev->vce.handles[i], 0); rdev->vce.filp[i] = NULL; @@ -196,7 +180,7 @@ void radeon_vce_fini(struct radeon_device *rdev) */ int radeon_vce_suspend(struct radeon_device *rdev) { - int i; + int i, r; if (rdev->vce.vcpu_bo == NULL) return 0; @@ -209,6 +193,13 @@ int radeon_vce_suspend(struct radeon_device *rdev) return 0; /* TODO: suspending running encoding sessions isn't supported */ + + r = radeon_bo_reserve(rdev->vce.vcpu_bo, false); + if (!r) { + radeon_bo_unpin(rdev->vce.vcpu_bo); + radeon_bo_unreserve(rdev->vce.vcpu_bo); + } + return -EINVAL; } @@ -223,15 +214,18 @@ int radeon_vce_resume(struct radeon_device *rdev) void *cpu_addr; int r; - if (rdev->vce.vcpu_bo == NULL) - return -EINVAL; - r = radeon_bo_reserve(rdev->vce.vcpu_bo, false); if (r) { dev_err(rdev->dev, "(%d) failed to reserve VCE bo\n", r); return r; } - + r = radeon_bo_pin(rdev->vce.vcpu_bo, RADEON_GEM_DOMAIN_VRAM, + &rdev->vce.gpu_addr); + if (r) { + radeon_bo_unreserve(rdev->vce.vcpu_bo); + dev_err(rdev->dev, "(%d) VCE bo pin failed\n", r); + return r; + } r = radeon_bo_kmap(rdev->vce.vcpu_bo, &cpu_addr); if (r) { radeon_bo_unreserve(rdev->vce.vcpu_bo); @@ -246,7 +240,6 @@ int radeon_vce_resume(struct radeon_device *rdev) memcpy(cpu_addr, rdev->vce_fw->data, rdev->vce_fw->size); radeon_bo_kunmap(rdev->vce.vcpu_bo); - radeon_bo_unreserve(rdev->vce.vcpu_bo); return r;