From patchwork Tue Dec 5 19:02:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 750581 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VGTyqItA" Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C156C0; Tue, 5 Dec 2023 11:02:39 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6ce7c1b07e1so503776b3a.2; Tue, 05 Dec 2023 11:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701802958; x=1702407758; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gr71sNINRYPArpI+CNr5Fv+CLv1NDL4SnaWZ3f+C3cc=; b=VGTyqItAKaJJ121VxwJgMSOYSwDBSM1hsX9x5Lfign6yRXzCDK+EX3nhdm57ZpxAp+ Y7Uj7495reVgDdusIl72X8E2wRHkDMfbx3gpLgd2ykd8W71kZdq9pKYUFoTjTX06OC9P bDSuhgwbh3NK47ISaCUiP01w6rNaqyKU1m6giMTQMJ89VxrR8zkVC4O9o3Ao5GIaLeRq kV7E8npIDa+WPmpS1tJ0GFAtJeqxIZeEof6zFmxY1+VV573xElwO2EW36OjJGFA3gj2X /4VDgRAi59RQcogoEqK3tAFcznVLs4fnY2vlFbtBGUPufqfm0WA8wou9q2ufhQwkTuyM vN/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701802958; x=1702407758; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gr71sNINRYPArpI+CNr5Fv+CLv1NDL4SnaWZ3f+C3cc=; b=mdTpePcADzD0gBBUP9Wte+R9cFY+glvUCcRWU6HjlAUpE0VHEIyhTxr9B2LysePfqQ 648odZ9v52TptvUc75f5/QjXIi9WH+r+e3i2G7MH71lzK66t22rSjXSW4xf5LBiyRMeg u537GsoCtphrxFqgw2oX0K4jFgiZvVd8F7C8XxeVj4vdvunFSnKnd65HmVhFoanGPQSf EwVqdI+kZDoZXLqUjtLMOtcyklulUgWouF4gJfrO7YrKc/rzWEmrz2ctccAjHZybwUOF UE9FXzDQg6sCSDXuin+BhIa/FzmpL08S9HWCXKF+zeF9bJu4ynK0zl/zgPuKHUq9Wc3q 4xPQ== X-Gm-Message-State: AOJu0Yy8XWmiCSzhqHSDYgPsEoQEh57oybkiEubkwbyxiEgUNmUU73Xi H/XysRtojuUyPyeOmMByRFg= X-Google-Smtp-Source: AGHT+IHU2ya8bSn4bAfwtnCaBXtL2UTM+QfuRrIn5PJLt281Wya4plXg44RgEht3EFWm/rTyANJk7g== X-Received: by 2002:a05:6a00:1806:b0:6ce:3f02:10a3 with SMTP id y6-20020a056a00180600b006ce3f0210a3mr2331731pfa.8.1701802958385; Tue, 05 Dec 2023 11:02:38 -0800 (PST) Received: from localhost ([2a00:79e1:2e00:1301:e1c5:6354:b45d:8ffc]) by smtp.gmail.com with ESMTPSA id r14-20020aa7844e000000b006ce467a2489sm4867944pfn.175.2023.12.05.11.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 11:02:37 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, =?utf-8?q?Christian_K=C3=B6nig?= , Rob Clark , Luben Tuikov , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sumit Semwal , linux-kernel@vger.kernel.org (open list), linux-media@vger.kernel.org (open list:DMA BUFFER SHARING FRAMEWORK:Keyword:\bdma_(?:buf|fence|resv)\b), linaro-mm-sig@lists.linaro.org (moderated list:DMA BUFFER SHARING FRAMEWORK:Keyword:\bdma_(?:buf|fence|resv)\b) Subject: [PATCH] drm/scheduler: Unwrap job dependencies Date: Tue, 5 Dec 2023 11:02:33 -0800 Message-ID: <20231205190234.371322-1-robdclark@gmail.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Rob Clark Container fences have burner contexts, which makes the trick to store at most one fence per context somewhat useless if we don't unwrap array or chain fences. Signed-off-by: Rob Clark --- drivers/gpu/drm/scheduler/sched_main.c | 47 ++++++++++++++++++-------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 9762464e3f99..16b550949c57 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -684,27 +685,14 @@ void drm_sched_job_arm(struct drm_sched_job *job) } EXPORT_SYMBOL(drm_sched_job_arm); -/** - * drm_sched_job_add_dependency - adds the fence as a job dependency - * @job: scheduler job to add the dependencies to - * @fence: the dma_fence to add to the list of dependencies. - * - * Note that @fence is consumed in both the success and error cases. - * - * Returns: - * 0 on success, or an error on failing to expand the array. - */ -int drm_sched_job_add_dependency(struct drm_sched_job *job, - struct dma_fence *fence) +static int drm_sched_job_add_single_dependency(struct drm_sched_job *job, + struct dma_fence *fence) { struct dma_fence *entry; unsigned long index; u32 id = 0; int ret; - if (!fence) - return 0; - /* Deduplicate if we already depend on a fence from the same context. * This lets the size of the array of deps scale with the number of * engines involved, rather than the number of BOs. @@ -728,6 +716,35 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job, return ret; } + +/** + * drm_sched_job_add_dependency - adds the fence as a job dependency + * @job: scheduler job to add the dependencies to + * @fence: the dma_fence to add to the list of dependencies. + * + * Note that @fence is consumed in both the success and error cases. + * + * Returns: + * 0 on success, or an error on failing to expand the array. + */ +int drm_sched_job_add_dependency(struct drm_sched_job *job, + struct dma_fence *fence) +{ + struct dma_fence_unwrap iter; + struct dma_fence *f; + int ret = 0; + + dma_fence_unwrap_for_each (f, &iter, fence) { + dma_fence_get(f); + ret = drm_sched_job_add_single_dependency(job, f); + if (ret) + break; + } + + dma_fence_put(fence); + + return ret; +} EXPORT_SYMBOL(drm_sched_job_add_dependency); /**