From patchwork Tue Oct 3 15:27:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 9983109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B4837602B8 for ; Tue, 3 Oct 2017 15:27:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A65391FF1E for ; Tue, 3 Oct 2017 15:27:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B363289B1; Tue, 3 Oct 2017 15:27:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 282261FF1E for ; Tue, 3 Oct 2017 15:27:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A96C96E547; Tue, 3 Oct 2017 15:27:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id 979806E542; Tue, 3 Oct 2017 15:27:14 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8602A60D2D; Tue, 3 Oct 2017 15:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1507044434; bh=qaJGEpSKb9t9XcnmgNIudMoN3RMVSH7upbV73nVkDJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VgtOnslT5/n/zS0Un2HGJfS9Ez2I0OrUcz6fu9wNyu9kjwtlriz6puClvm9I5mSCH Qa8qSeaxy9Ly7gO/4YSQiihHtWdDNzExFIC7aS/uS7X2Gw5iQPWM6uObLOcCXZtkYL fwPhXDMpm40qVJ3W6ZISJC7TLE9JmFjfdggIAFHI= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8672560CDD; Tue, 3 Oct 2017 15:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1507044433; bh=qaJGEpSKb9t9XcnmgNIudMoN3RMVSH7upbV73nVkDJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UzGQUCcGkgY16l5s1sqoezeRjkUdKGihdy6VRDq/qcPxhnYOM+XJ04dBdrzTei7Qz +bzfMtuEG/J6K+WzZyuJNeKUcRfs0/mB1LHM1QXQh5kNDnTudjYzYAdVp+ldzEfFHQ 7dH45H8DslZaifOu+Ec8s3cGbL9sDDnn/5bL3b04= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8672560CDD Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Subject: [PATCH 6/6] drm/msm: Do priority checking during submitqueue create Date: Tue, 3 Oct 2017 09:27:06 -0600 Message-Id: <1507044426-4042-7-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507044426-4042-1-git-send-email-jcrouse@codeaurora.org> References: <1507044426-4042-1-git-send-email-jcrouse@codeaurora.org> Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that the priority must be set in the submitqueue we can check at create time that the requested priority is valid. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_gem_submit.c | 8 +++++--- drivers/gpu/drm/msm/msm_submitqueue.c | 25 +++++++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index 47a9e87..5b9210b 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -421,7 +421,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, struct msm_gpu_submitqueue *queue; int out_fence_fd = -1; unsigned i; - int ret, ring; + int ret; if (!gpu) return -ENXIO; @@ -439,6 +439,9 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, if (!queue) return -ENOENT; + if (queue->prio >= gpu->nr_rings) + return -EINVAL; + if (args->flags & MSM_SUBMIT_FENCE_FD_IN) { in_fence = sync_file_get_fence(args->fence_fd); @@ -545,8 +548,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data, submit->nr_cmds = i; - ring = clamp_t(uint32_t, queue->prio, 0, gpu->nr_rings - 1); - submit->ring = gpu->rb[ring]; + submit->ring = gpu->rb[queue->prio]; submit->fence = msm_fence_alloc(queue->fctx); if (IS_ERR(submit->fence)) { diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_submitqueue.c index f23b43e..da4bee8 100644 --- a/drivers/gpu/drm/msm/msm_submitqueue.c +++ b/drivers/gpu/drm/msm/msm_submitqueue.c @@ -64,6 +64,7 @@ void msm_submitqueue_close(struct msm_file_private *ctx) int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, u32 prio, u32 flags, u32 *id) { + struct msm_drm_private *priv = drm->dev_private; struct msm_gpu_submitqueue *queue; char name[32]; int ret = 0; @@ -77,7 +78,13 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, kref_init(&queue->ref); queue->flags = flags; - queue->prio = prio; + + if (priv->gpu) { + if (prio >= priv->gpu->nr_rings) + return -EINVAL; + + queue->prio = prio; + } write_lock(&ctx->queuelock); @@ -114,18 +121,24 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, int msm_submitqueue_init(struct drm_device *drm, struct msm_file_private *ctx) { + struct msm_drm_private *priv = drm->dev_private; + int default_prio; + if (!ctx) return 0; + /* + * Select priority 2 as the "default priority" unless nr_rings is less + * than 2 and then pick the lowest pirority + */ + default_prio = priv->gpu ? + clamp_t(uint32_t, 2, 0, priv->gpu->nr_rings - 1) : 0; + INIT_LIST_HEAD(&ctx->submitqueues); rwlock_init(&ctx->queuelock); - /* - * Add the "default" submitqueue with id 0 - * "low" priority (2) and no flags - */ - return msm_submitqueue_create(drm, ctx, 2, 0, NULL); + return msm_submitqueue_create(drm, ctx, default_prio, 0, NULL); } int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id)