From patchwork Tue Sep 17 11:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonino Maniscalco X-Patchwork-Id: 13806138 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E84D4C36010 for ; Tue, 17 Sep 2024 11:14:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 675BC10E214; Tue, 17 Sep 2024 11:14:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OWcYIzP6"; dkim-atps=neutral Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id C49D510E466; Tue, 17 Sep 2024 11:14:31 +0000 (UTC) Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8d6d0fe021so889179666b.1; Tue, 17 Sep 2024 04:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726571670; x=1727176470; darn=lists.freedesktop.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=T53Fc1+tXbQoklFjHHb5K5Wy1HQMuvtm+3p3+subdyE=; b=OWcYIzP6FYlbrCZptSmP+UjzCQuS6rptJ0FJGW1S1CE6e8vQA+rxk1tUeKTsP9bcXF KT0CEPQckOrztrqqLDlNlxRgJ8Y1hzEro0pXHYqoqDKNYR12l7mBwlZkNQQ1SzToMSdJ PWsPA5Bhbl1NS79kXkPCvLLYUANXZmj1+I6hUj3lFzWgGK3unB478RSR3CCrEPvZywOu rq3+boXpAGhrIVi+OEYkFTDuN3n6ytdPw4XP7ArzZ7p3C2Yzm9dhQCfXBqxzTIMpEh/E 8HIYhhAxpzjUEA9Czp+0MnSG8G+bzkSCwfTjsyDI/VdiprAPluDMWZ30foDCFdsqtxzN aOew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726571670; x=1727176470; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T53Fc1+tXbQoklFjHHb5K5Wy1HQMuvtm+3p3+subdyE=; b=fzsJ2HBdZDHvT8Yod3AJT4OOMGJ+CcRXvxdOhjKQNKDWtX9VN8sntw9SDmEXveSpGe RZjs4MYKS9ZozP9iMFH/ueFjf7pNrixlzEv6b2FkmAuCG04HrLwgNfxrO2ZDNZ/1r02y WFaZpIPy7dnp8SMmFuEEYskb8f6P+8kyV7DTv914Z2Rkujn1RTXvYxqRFuzmN7Y0sjmr 9YbYinp8+3mOpx6PM97qpcaLNAjGOucImT+mH+KvwzDiMlYMTuQEqpjAaccLiXrvNSG9 KvP8soVS4XD57e3fPI38AAH5vxgw0rNtlb4M8PZ7vRkc9Xac+PABuZ8Fxu4cnmvmzqe+ jVdA== X-Forwarded-Encrypted: i=1; AJvYcCVjK3BZJ2vHpZgsO98zCwvsSMuG/cuE+yvjJavqH1R9G9j8rm8Z9nIkFGNbqMKCqvWhnEVTx4x2JXdI@lists.freedesktop.org, AJvYcCX03IJQXn2Jf8GxBX1dPxUU+EASeuEhXAoOCyRvQsbVYQhKYEeGO2cDn1fCyrYtoqV1JQOFxd3szZw=@lists.freedesktop.org X-Gm-Message-State: AOJu0YwcesILseQb5W1TG/AjoZISxBuuI/1lA/39tIXAvHQ83BDht//a Oa3B9ZMsGNObG33kisbqCOHtdY6DARTXor047HaHtLYC5xdeTa/pCnF4TZCK X-Google-Smtp-Source: AGHT+IEIzW4PRkk3JHcFfsn6c2qt4ToVwRDageTMuR+bxRM68CQPkrwM5fnvueWJBRzLCGtNcUPC7w== X-Received: by 2002:a17:907:6d14:b0:a8e:a578:2b63 with SMTP id a640c23a62f3a-a902966303amr2110761066b.55.1726571670103; Tue, 17 Sep 2024 04:14:30 -0700 (PDT) Received: from [192.168.1.17] (host-82-51-105-30.retail.telecomitalia.it. [82.51.105.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612e1a55sm430745166b.157.2024.09.17.04.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 04:14:29 -0700 (PDT) From: Antonino Maniscalco Date: Tue, 17 Sep 2024 13:14:19 +0200 Subject: [PATCH v4 09/11] drm/msm/A6XX: Add a flag to allow preemption to submitqueue_create MIME-Version: 1.0 Message-Id: <20240917-preemption-a750-t-v4-9-95d48012e0ac@gmail.com> References: <20240917-preemption-a750-t-v4-0-95d48012e0ac@gmail.com> In-Reply-To: <20240917-preemption-a750-t-v4-0-95d48012e0ac@gmail.com> To: Rob Clark , Sean Paul , Konrad Dybcio , Abhinav Kumar , Dmitry Baryshkov , Marijn Suijten , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Antonino Maniscalco , Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1726571652; l=3106; i=antomani103@gmail.com; s=20240815; h=from:subject:message-id; bh=uVBrI6wVx1n6T/pyX+S9UNsE7LkxG9VdyK6yWV2qSzc=; b=HOGcngbU7MQRl1pDL2NaJQtKGukFCPXEBThmDSzTkTooxD8JHEvoeKS5p6DcySSylehxuAqma EIpixhT2AdpBdiGMphbXXaHq0ehQx9biio4gYgmg2FzIRNuYs0WN9T6 X-Developer-Key: i=antomani103@gmail.com; a=ed25519; pk=0zicFb38tVla+iHRo4kWpOMsmtUrpGBEa7LkFF81lyY= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" Some userspace changes are necessary so add a flag for userspace to advertise support for preemption when creating the submitqueue. When this flag is not set preemption will not be allowed in the middle of the submitted IBs therefore mantaining compatibility with older userspace. The flag is rejected if preemption is not supported on the target, this allows userspace to know whether preemption is supported. Signed-off-by: Antonino Maniscalco Tested-by: Neil Armstrong # on SM8650-QRD --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 ++++++++---- drivers/gpu/drm/msm/msm_submitqueue.c | 3 +++ include/uapi/drm/msm_drm.h | 5 ++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 736f475d696f..edbcb6d229ba 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -430,8 +430,10 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) OUT_PKT7(ring, CP_SET_MARKER, 1); OUT_RING(ring, 0x101); /* IFPC disable */ - OUT_PKT7(ring, CP_SET_MARKER, 1); - OUT_RING(ring, 0x00d); /* IB1LIST start */ + if (submit->queue->flags & MSM_SUBMITQUEUE_ALLOW_PREEMPT) { + OUT_PKT7(ring, CP_SET_MARKER, 1); + OUT_RING(ring, 0x00d); /* IB1LIST start */ + } /* Submit the commands */ for (i = 0; i < submit->nr_cmds; i++) { @@ -462,8 +464,10 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) update_shadow_rptr(gpu, ring); } - OUT_PKT7(ring, CP_SET_MARKER, 1); - OUT_RING(ring, 0x00e); /* IB1LIST end */ + if (submit->queue->flags & MSM_SUBMITQUEUE_ALLOW_PREEMPT) { + OUT_PKT7(ring, CP_SET_MARKER, 1); + OUT_RING(ring, 0x00e); /* IB1LIST end */ + } get_stats_counter(ring, REG_A7XX_RBBM_PERFCTR_CP(0), rbmemptr_stats(ring, index, cpcycles_end)); diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_submitqueue.c index 0e803125a325..9b3ffca3f3b4 100644 --- a/drivers/gpu/drm/msm/msm_submitqueue.c +++ b/drivers/gpu/drm/msm/msm_submitqueue.c @@ -170,6 +170,9 @@ int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, if (!priv->gpu) return -ENODEV; + if (flags & MSM_SUBMITQUEUE_ALLOW_PREEMPT && priv->gpu->nr_rings == 1) + return -EINVAL; + ret = msm_gpu_convert_priority(priv->gpu, prio, &ring_nr, &sched_prio); if (ret) return ret; diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index 3fca72f73861..f37858db34e6 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -345,7 +345,10 @@ struct drm_msm_gem_madvise { * backwards compatibility as a "default" submitqueue */ -#define MSM_SUBMITQUEUE_FLAGS (0) +#define MSM_SUBMITQUEUE_ALLOW_PREEMPT 0x00000001 +#define MSM_SUBMITQUEUE_FLAGS ( \ + MSM_SUBMITQUEUE_ALLOW_PREEMPT | \ + 0) /* * The submitqueue priority should be between 0 and MSM_PARAM_PRIORITIES-1,