From patchwork Mon Apr 13 14:52:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 6210041 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 C542E9F1C4 for ; Mon, 13 Apr 2015 14:52:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1256C2034B for ; Mon, 13 Apr 2015 14:52:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 53B142021F for ; Mon, 13 Apr 2015 14:52:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB54D6E547; Mon, 13 Apr 2015 07:52:31 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pegasos-out.vodafone.de (pegasos-out.vodafone.de [80.84.1.38]) by gabe.freedesktop.org (Postfix) with ESMTP id 844C56E549 for ; Mon, 13 Apr 2015 07:52:30 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix1 Daemon) with ESMTP id 3A1392607DF; Mon, 13 Apr 2015 16:52:29 +0200 (CEST) X-Virus-Scanned: amavisd-new at vodafone.de X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Authentication-Results: rohrpostix1.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de Received: from pegasos-out.vodafone.de ([127.0.0.1]) by localhost (rohrpostix1.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cGujCuHVFfrD; Mon, 13 Apr 2015 16:52:29 +0200 (CEST) Received: from smtp-01.vodafone.de (xsmail-dmz5.prod.vfnet.de [10.215.254.36]) by pegasos-out.vodafone.de (Rohrpostix1 Daemon) with ESMTP id B91AD26084E; Mon, 13 Apr 2015 16:52:26 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de B91AD26084E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1428936746; bh=t0yZBj+Yj25lcO90zQZru2IDIoHaSmFv6GNCgttSJGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KNyrKMNCxjM3ytyywY4dGNoJ1qIu04XXP6tEK1aZ8CEbVaszDleRoI7QOBnhPVdo3 ubFbRLVLghubgNtHyowWoT2npXmHXsxfg44yhKEQtQOAqitrmF8+tRGBjfZ+AOdlDj 6uLT2ozADBvHd4nagFAHv1cgzeDDvGhABXcDcF+U= X-Virus-Scanned: amavisd-new at vodafone.de Received: from smtp-01.vodafone.de ([127.0.0.1]) by localhost (xsmail-dmz5.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VfhPUnLrCDeH; Mon, 13 Apr 2015 16:52:25 +0200 (CEST) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/radeon: cleanup radeon_cs_get_ring Date: Mon, 13 Apr 2015 16:52:16 +0200 Message-Id: <1428936737-19103-3-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428936737-19103-1-git-send-email-deathsimple@vodafone.de> References: <1428936737-19103-1-git-send-email-deathsimple@vodafone.de> MIME-Version: 1.0 Cc: Serguei.Sagalovitch@amd.com 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-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König That makes it possible to call it from elsewhere as well. Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon.h | 2 +- drivers/gpu/drm/radeon/radeon_cs.c | 55 ++++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 6e6b49a..57d63c4 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -1093,7 +1093,6 @@ struct radeon_cs_parser { int parser_error; u32 cs_flags; u32 ring; - s32 priority; struct ww_acquire_ctx ticket; }; @@ -1122,6 +1121,7 @@ typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p, typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p, struct radeon_cs_packet *pkt); +int radeon_cs_get_ring(struct radeon_device *rdev, u32 ring, s32 priority); /* * AGP diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 4d0f96c..4b92762 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c @@ -187,47 +187,46 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) return r; } -static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority) +int radeon_cs_get_ring(struct radeon_device *rdev, u32 ring, s32 priority) { - p->priority = priority; - switch (ring) { default: DRM_ERROR("unknown ring id: %d\n", ring); - return -EINVAL; - case RADEON_CS_RING_GFX: - p->ring = RADEON_RING_TYPE_GFX_INDEX; break; + + case RADEON_CS_RING_GFX: + return RADEON_RING_TYPE_GFX_INDEX; + case RADEON_CS_RING_COMPUTE: - if (p->rdev->family >= CHIP_TAHITI) { - if (p->priority > 0) - p->ring = CAYMAN_RING_TYPE_CP1_INDEX; + if (rdev->family >= CHIP_TAHITI) { + if (priority > 0) + return CAYMAN_RING_TYPE_CP1_INDEX; else - p->ring = CAYMAN_RING_TYPE_CP2_INDEX; + return CAYMAN_RING_TYPE_CP2_INDEX; } else - p->ring = RADEON_RING_TYPE_GFX_INDEX; - break; + return RADEON_RING_TYPE_GFX_INDEX; + case RADEON_CS_RING_DMA: - if (p->rdev->family >= CHIP_CAYMAN) { - if (p->priority > 0) - p->ring = R600_RING_TYPE_DMA_INDEX; + if (rdev->family >= CHIP_CAYMAN) { + if (priority > 0) + return R600_RING_TYPE_DMA_INDEX; else - p->ring = CAYMAN_RING_TYPE_DMA1_INDEX; - } else if (p->rdev->family >= CHIP_RV770) { - p->ring = R600_RING_TYPE_DMA_INDEX; + return CAYMAN_RING_TYPE_DMA1_INDEX; + } else if (rdev->family >= CHIP_RV770) { + return R600_RING_TYPE_DMA_INDEX; } else { return -EINVAL; } - break; + case RADEON_CS_RING_UVD: - p->ring = R600_RING_TYPE_UVD_INDEX; - break; + return R600_RING_TYPE_UVD_INDEX; + case RADEON_CS_RING_VCE: /* TODO: only use the low priority ring for now */ - p->ring = TN_RING_TYPE_VCE1_INDEX; - break; + return TN_RING_TYPE_VCE1_INDEX; + } - return 0; + return -EINVAL; } static int radeon_cs_sync_rings(struct radeon_cs_parser *p) @@ -348,14 +347,18 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data) /* these are KMS only */ if (p->rdev) { + int r; + if ((p->cs_flags & RADEON_CS_USE_VM) && !p->rdev->vm_manager.enabled) { DRM_ERROR("VM not active on asic!\n"); return -EINVAL; } - if (radeon_cs_get_ring(p, ring, priority)) - return -EINVAL; + r = radeon_cs_get_ring(p->rdev, ring, priority); + if (r < 0) + return r; + p->ring = r; /* we only support VM on some SI+ rings */ if ((p->cs_flags & RADEON_CS_USE_VM) == 0) {