From patchwork Tue Feb 28 22:58:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 62681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3303186wrd; Tue, 28 Feb 2023 15:09:07 -0800 (PST) X-Google-Smtp-Source: AK7set/dao2RdSag5Jx+sc9aEBGl2ircriXkRKtfzNleXbJgsMvTmRvAfay3M0lQLZ/silEkzUj7 X-Received: by 2002:a17:906:4fd1:b0:8b1:2867:380 with SMTP id i17-20020a1709064fd100b008b128670380mr5822296ejw.22.1677625747194; Tue, 28 Feb 2023 15:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677625747; cv=none; d=google.com; s=arc-20160816; b=mGLZCJUaX21edT/sjVX6CKrzEKnkDIJb7JMmHBeiD09RZFxRAT/1M0UFCQilBhzuB/ ydeFHN4S7t+MIwV2G5iMGJ5CV7i6JUr67d94qCq7oFUzC9oEtzdo9vQJQZEq6a/5VqVm lGzzmy9GY/dBVCg4oWsEZdVzJBAAUYLBP9MJgvtYd2Kw7krSeDtP9NSw7sO3pOh/M59E VbllGYQf+erca5cIxGs8AtMeY8CYk3XQoiVa72XDUnO4YxQEleO8G3w1mtCVWxcTL1Ij HtrN6ZQunmkJkUqW2cmsXrRzVwyUHSGU8ZBiZf3/S5KPMeltvLPKObBjvS21bjzI5SW8 NCOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0EqwRq/t+KHhVrbIAD1sooBDZlG3nzxQWus7/my7j0s=; b=YlXsKQpCGp4kAU22HaxnJvCceL3bsiCX73XwFsRbO4MBaINzJdapW053isB5SoUkrs p3vobE80pFOYIZUuYz6jrly3mcneLb5VkPTMqwEPbkHgIgGu/jcsImT12BSPJgYH38ff CHmumt89G4/8emQ+sTanoTjv9zMuJ2CyRA7FsYlDeSHzgtXovwFh/BVGMg4GGDnb1fTS D0dE2Eu+ffMdNovXAiZ6jG6Qu5C11At2P+ZBPXrzbp8H69Aq8Wj+EOetnlpEjKMIDaRR iR8OMOdi0oPVMeOxeI4EN8YO8gti9RoGpAagIDhKSmoYucZNxFGzV/jPWv6UkzWxURnO w2nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UnSWdr16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a056402060900b004acde7b604esi13987864edv.83.2023.02.28.15.08.44; Tue, 28 Feb 2023 15:09:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UnSWdr16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbjB1XAD (ORCPT + 99 others); Tue, 28 Feb 2023 18:00:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbjB1W7j (ORCPT ); Tue, 28 Feb 2023 17:59:39 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15C0C674; Tue, 28 Feb 2023 14:59:13 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id m20-20020a17090ab79400b00239d8e182efso4486823pjr.5; Tue, 28 Feb 2023 14:59:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677625147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0EqwRq/t+KHhVrbIAD1sooBDZlG3nzxQWus7/my7j0s=; b=UnSWdr16aXMzHwaqQUKdJgtIvnecRl8JsRO8gPCIfkQYXAP59se8TeJSGnJXX2XLyu 6iqpzR+1mM3f94dS4hB3xZAXTzW+pqf7C/G4uoYyifViaf7k4HFgnJosezvupc61Kc2n m7JuXjCKHoMsOK0DDOnedc74+vMB2PVRt5T1q5Lt+dPUeolQ9upyny8zvNk/QcmxyTja lk/vmHO5vQ4jV3IpTL4RRuBNKAX2brnppUH49X88ucSBvbhrJ1DW21KXGd56FBiavuzC 2Gsy34b6+z6AXIMB+Fdjzk7/jFKJM7K1h0QEcEzVuwt8YGkGC2NGLn5eo6RJZ1rZy/F3 j59Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677625147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0EqwRq/t+KHhVrbIAD1sooBDZlG3nzxQWus7/my7j0s=; b=h86pccJLVBVtWlVhhGdB898IPtgZ5ZHD/tZQDRBpbgOWrFbLIVa6CeHH7U+qRCWjXf +Yrjdme1ilhhPOZVAw0cxu6rT99FXfSNVRaVkExBNyXFUDsD9s0LENvkiONCFbbWzxDN oVuuqkr8KocYzbWxsJwW3orXMmr6u20tBjjXzHKGxQghSU+fj8P/ykpMGL/c00hjiuD6 SZE+IrSv7reOQCpUu0Toc0PpME0J96B2yqEiX9cpe/zRV/UFD8sNhtsVCAVDy55hZkd1 wSOaeEhe7Ad4Sh46aaaMZK6eEKlw0TQfmpOznVdwkhXoOnDaH+wWqUQiQ7eiECkMVjan BvDw== X-Gm-Message-State: AO0yUKUNx6hd2YekSDgrXj40dyxY1hPu3O6PBCmzdNC6NKll6Nf1H/4s +HwBrrKFxu52qrGFebJB+Bs= X-Received: by 2002:a05:6a20:4f08:b0:c7:6cb7:cfbf with SMTP id gi8-20020a056a204f0800b000c76cb7cfbfmr4376896pzb.10.1677625147658; Tue, 28 Feb 2023 14:59:07 -0800 (PST) Received: from localhost ([2a00:79e1:abd:4a00:61b:48ed:72ab:435b]) by smtp.gmail.com with ESMTPSA id m6-20020aa79006000000b005a8c16fcb78sm6582972pfo.56.2023.02.28.14.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 14:59:07 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: freedreno@lists.freedesktop.org, Daniel Vetter , =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?q?Michel_D=C3=A4nzer?= , Tvrtko Ursulin , Rodrigo Vivi , Alex Deucher , Pekka Paalanen , Simon Ser , Luben Tuikov , Rob Clark , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER FOR MSM ADRENO GPU), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v8 14/16] drm/msm: Add wait-boost support Date: Tue, 28 Feb 2023 14:58:18 -0800 Message-Id: <20230228225833.2920879-15-robdclark@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230228225833.2920879-1-robdclark@gmail.com> References: <20230228225833.2920879-1-robdclark@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759118095284065791?= X-GMAIL-MSGID: =?utf-8?q?1759118095284065791?= From: Rob Clark Add a way for various userspace waits to signal urgency. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_drv.c | 12 ++++++++---- drivers/gpu/drm/msm/msm_gem.c | 5 +++++ include/uapi/drm/msm_drm.h | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index aca48c868c14..f6764a86b2da 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -46,6 +46,7 @@ * - 1.8.0 - Add MSM_BO_CACHED_COHERENT for supported GPUs (a6xx) * - 1.9.0 - Add MSM_SUBMIT_FENCE_SN_IN * - 1.10.0 - Add MSM_SUBMIT_BO_NO_IMPLICIT + * - 1.11.0 - Add wait boost (MSM_WAIT_FENCE_BOOST, MSM_PREP_BOOST) */ #define MSM_VERSION_MAJOR 1 #define MSM_VERSION_MINOR 10 @@ -899,7 +900,7 @@ static int msm_ioctl_gem_info(struct drm_device *dev, void *data, } static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id, - ktime_t timeout) + ktime_t timeout, uint32_t flags) { struct dma_fence *fence; int ret; @@ -929,6 +930,9 @@ static int wait_fence(struct msm_gpu_submitqueue *queue, uint32_t fence_id, if (!fence) return 0; + if (flags & MSM_WAIT_FENCE_BOOST) + dma_fence_set_deadline(fence, ktime_get()); + ret = dma_fence_wait_timeout(fence, true, timeout_to_jiffies(&timeout)); if (ret == 0) { ret = -ETIMEDOUT; @@ -949,8 +953,8 @@ static int msm_ioctl_wait_fence(struct drm_device *dev, void *data, struct msm_gpu_submitqueue *queue; int ret; - if (args->pad) { - DRM_ERROR("invalid pad: %08x\n", args->pad); + if (args->flags & ~MSM_WAIT_FENCE_FLAGS) { + DRM_ERROR("invalid flags: %08x\n", args->flags); return -EINVAL; } @@ -961,7 +965,7 @@ static int msm_ioctl_wait_fence(struct drm_device *dev, void *data, if (!queue) return -ENOENT; - ret = wait_fence(queue, args->fence, to_ktime(args->timeout)); + ret = wait_fence(queue, args->fence, to_ktime(args->timeout), args->flags); msm_submitqueue_put(queue); diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c index 1dee0d18abbb..dd4a0d773f6e 100644 --- a/drivers/gpu/drm/msm/msm_gem.c +++ b/drivers/gpu/drm/msm/msm_gem.c @@ -846,6 +846,11 @@ int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout) op & MSM_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout); long ret; + if (op & MSM_PREP_BOOST) { + dma_resv_set_deadline(obj->resv, dma_resv_usage_rw(write), + ktime_get()); + } + ret = dma_resv_wait_timeout(obj->resv, dma_resv_usage_rw(write), true, remain); if (ret == 0) diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index 329100016e7c..dbf0d6f43fa9 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -151,8 +151,13 @@ struct drm_msm_gem_info { #define MSM_PREP_READ 0x01 #define MSM_PREP_WRITE 0x02 #define MSM_PREP_NOSYNC 0x04 +#define MSM_PREP_BOOST 0x08 -#define MSM_PREP_FLAGS (MSM_PREP_READ | MSM_PREP_WRITE | MSM_PREP_NOSYNC) +#define MSM_PREP_FLAGS (MSM_PREP_READ | \ + MSM_PREP_WRITE | \ + MSM_PREP_NOSYNC | \ + MSM_PREP_BOOST | \ + 0) struct drm_msm_gem_cpu_prep { __u32 handle; /* in */ @@ -286,6 +291,11 @@ struct drm_msm_gem_submit { }; +#define MSM_WAIT_FENCE_BOOST 0x00000001 +#define MSM_WAIT_FENCE_FLAGS ( \ + MSM_WAIT_FENCE_BOOST | \ + 0) + /* The normal way to synchronize with the GPU is just to CPU_PREP on * a buffer if you need to access it from the CPU (other cmdstream * submission from same or other contexts, PAGE_FLIP ioctl, etc, all @@ -295,7 +305,7 @@ struct drm_msm_gem_submit { */ struct drm_msm_wait_fence { __u32 fence; /* in */ - __u32 pad; + __u32 flags; /* in, bitmask of MSM_WAIT_FENCE_x */ struct drm_msm_timespec timeout; /* in */ __u32 queueid; /* in, submitqueue id */ };