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: 9983099 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 A281B602B8 for ; Tue, 3 Oct 2017 15:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94C0E289B1 for ; Tue, 3 Oct 2017 15:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89DC8289DA; Tue, 3 Oct 2017 15:27:17 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C858289B1 for ; Tue, 3 Oct 2017 15:27:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752060AbdJCP1Q (ORCPT ); Tue, 3 Oct 2017 11:27:16 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45482 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751969AbdJCP1O (ORCPT ); Tue, 3 Oct 2017 11:27:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4E28F60D51; 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 Cc: linux-arm-msm@vger.kernel.org, dri-devel@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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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)