From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796134288; b=mkiP/NLMPMfjx41/vDgIu+20yem1+SrS1QfyOIljiWf9U9um26CbmRnCdDzAqVrLHoM7 GHoMwPszQuEEtgq/naiB9XQqA3wsn27+Y+UWxnGiW0bxJf7JPvRkK9/Gh+8mgO3WuEOs5 YUaV9obHNjpIIfMDcghYg0zxkXmBbogMs2+JjZOqkgB/zc2Du78EA4IPyj1ljK0o9zsEq AyDn2iSjNsElvXlLQKwgdi0YHsFbxMMoZDAAzqZdG/9K0YLXxrQ83CGksY3gEzWztocIE Yx1zQKflVCuO55af0mOCb/lQss26vlY6A9nNYVAoQ9q7NEBWnTvncwmha+fjG15vOtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796134288; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=7BuDxPJN69TGRAR2K19EFfKPVjFH3RdjiOF0mMfBhfE=; b=t9c5S6DmMgcu9yBjacb9IrHZU6GgBGAFlv0hTjt0rcXyn1yeDtFiFuspNxlju9gMvKdJ DwbcV3Biy8rS60NmxSCtLphYG5xvTC8oVG+qhmVk0WwtMsTlpE84WJeCODPy1ZCnkfN73 2IPxlCpYgcdDsqK1wFkxKMPejUeBakRHnX+mxay/7L1r9ugychonjBvBVPAUzmutZ05a3 STimARq/c+4PXir2nZsyzVryitZLBl5lpTJpkuCpEsnax4+jqT7Naqa560/jnYOou9rtz ey0IeeZ17QIeCcydUX+0+EQnVu/KZHTj4GZ/OMWr/yJ7+gQ+gsc0YayucExo5hhjOkw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=ursulin.net; spf=pass smtp.mailfrom=ursulin.net; dkim=pass header.d=ursulin.net header.i=@ursulin.net header.a=rsa-sha256 header.s=google header.b=OZ6x8SsD; arc=none smtp.remote-ip=209.85.208.44 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CA5A606A32A for ; Tue, 1 Dec 2026 14:11:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1CA5A606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ursulin.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ursulin.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ursulin.net header.i=@ursulin.net header.a=rsa-sha256 header.s=google header.b=OZ6x8SsD Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-6b86bbce3d1so15821125a12.0 for ; Tue, 01 Dec 2026 06:11:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin.net; s=google; t=1796134285; x=1796739085; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=7BuDxPJN69TGRAR2K19EFfKPVjFH3RdjiOF0mMfBhfE=; b=OZ6x8SsDaQ6jcQw1P+rcHpVtag9cPIyMkjN4gnYkYknoVxIe3hMA3fVf9yFfDceTyV /zz/peTjNzali5LG/MCTarhB2ZDxlOB61UwZSE9nZkB8q3AdMd1rJxv5O2l7YEStSdqZ yNBNUQPczriHtAEKLz6tFQHEhv+Wok1zyLBeU1xf9a/KdC2a8mMWb6+eqICgg7+549/F WywUY/ZzxGZb8B5uaSrkcr3j9wXnAICD0ssaWJGMaxOX5P22LjaMj4N9mDbgEunOHDYM 8ZOM8ax3K19Zc+YKKChSXt7Rh8D+JAFDNsvFr2Vw9wqlTDvNhivObt4U93BCBDgo43qc J3Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796134285; x=1796739085; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=7BuDxPJN69TGRAR2K19EFfKPVjFH3RdjiOF0mMfBhfE=; b=iAp5EAdU9kJNFvkAeJxz+NtHivhwLkhz80R+fxSCxMR85DIr57M3/pWxI3IkcXB07r wASfsmjpAL4jSYjyi69RX0i6Gfl8ei5T6iyt8A/rj2XqI/KOfb1mqDm+V7+zBtckgcCo VjUhWoWFO+tuWlpwvPs2Cp1j9kOQYB3bGvPmnP8f1zF1RvchMBMHheqC4zTyiRsRppUh 2dMvmR3Z5NzJ4gqHnEpSxTboMkp+WwOHxwZnBtS1UkwLDYNdriJj1OtPQs5+FMjnP55t 18pNdSs766ET7cqkfPUs0v82asVMjO9/UJ32WGNTPYoZrZRvnfssUeiBFxoIVnvo0tir Dh3g== X-Forwarded-Encrypted: i=1; AL+hErES7VFSQbBDxZyPoFGDLCwILq6EQfasNDOhVItTH2PsoJs1Ri9hvQYnuDlV5vOUm5rHjVEhr1rj9aIbK2E=@vger.kernel.org X-Gm-Message-State: APuU4Z/BYlSlJC98s3VUO0lG966zUfjXiobepU9LZ6d9uIgji/AKe2Ot QwxTS0X4guh3v9zu6S6Mgj5g10DE3FiqKN6m+d0ThezsWot1WZP8+xkZvyB4LoaSo08= X-Gm-Gg: AZFdTZcvR/SKmJX0ZyllnEQTBTU1Tuqn0BCAe6/G4aDT8GmtYmEVRckyQi/SppSTvgt NzNOOLwHj332EujnRqn0x+DkQ6cmD/LTR7YLAegxEi4HG/hKb1t4Y6/wlFp041F9EWaiDy07VE+ 5ZpQjC88ng0Em/xdJBR71TYVwj3jbj21uv2m9H2cihUuL8gpccQ8EP2RAOfLG+k0tvEnxonkMbE /pMrHSqOfJoI+3Hki++ooB9MJXDYMWoxcgpqt8Cojezv7npoNSJa3O7oqaN4JGew0awXMszSVyw IF2vHdHg65VUgBS8HlLyd6gWT+pkNh5V/+h3fIAw7nVFrrcGUxopfgI6qrMeUC9h3ah3uAamuZl Ec4WXXWcar0mawGOlOmmtsThggpc57HwD8GfM/HVSLHtynKLyUWWZYMNpt5HT30Plv7Bjy1tREp SOARWwENaMsMC/8KwiJ3qwI/pCScVZq4/8J8NGAFNMWXf4lzgshgVkjO2w0XLzvoOB+Su48xdL8 jWQIV0aWvOPqmDWHnJp/CfCRepWDahJFRUturAer2szOGw2MEy2dsAT0daIKkfQE0OhMs4EOoFQ WdEz9OT+nwP0bMx5wGsZnbF8ne2IcOtxtvO/qJgDdj2+ X-Received: by 2002:a05:6402:a592:10b0:6b8:8706:8e91 with SMTP id 4fb4d7f45d1cf-6ba37d6526dmr21562701a12.12.1796134285124; Tue, 01 Dec 2026 06:11:25 -0800 (PST) Received: from [192.168.0.116] ([81.79.79.1]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6ba6f8fa5b9sm14089542a12.37.2026.12.01.06.11.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 06:11:24 -0800 (PST) Message-ID: Date: Tue, 1 Dec 2026 14:11:23 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/panthor: Skip job dependencies when we can To: Boris Brezillon , Steven Price , Liviu Dudau , Akash Goel , Karunika Choo , Lukas Zapolskas , Chris Diamand Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Philipp Stanner , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Xianzhong Li References: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com> Content-Language: en-GB From: Tvrtko Ursulin In-Reply-To: <20261201-panhtor-dep-skip-v1-1-432f313dea0f@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 01/12/2026 13:58, Boris Brezillon wrote: > If a job is passed a dependency that's coming from the same queue the > job is targeting, we can get rid of the dependency because of the > implicit serialization provided by the queue. This will allow us to take > benefit of the pipelining provided by the ring buffer (no extra > MCU <-> CPU round-trip to have the job pushed to the ring buffer). > > Signed-off-by: Boris Brezillon > Cc: Xianzhong Li > --- > Some recent effort to improve job pipelining [1] showed that the > MCU <-> CPU round-trip that lets us signal job fences adds a > non-negligible overhead, and this problem seems to be easier and > more systematically fixed if it's addressed at the KMD side, so > here's a patch doing exactly that. > > [1]https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/46172 > --- > drivers/gpu/drm/panthor/panthor_drv.c | 41 +++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c > index dc8d0191aef4..cfffb9e2dec8 100644 > --- a/drivers/gpu/drm/panthor/panthor_drv.c > +++ b/drivers/gpu/drm/panthor/panthor_drv.c > @@ -7,6 +7,8 @@ > #include > #endif > > +#include > +#include > #include > #include > #include > @@ -591,6 +593,40 @@ panthor_submit_ctx_push_fences(struct panthor_submit_ctx *ctx) > } > } > > +static bool can_skip_dep(const struct drm_sched_job *job, struct dma_fence *fence) > +{ > + if (!fence) > + return true; > + > + /* This fence comes from our queue, and the serialization happening at > + * the queue level makes it so we can skip the CPU wait. > + */ > + if (fence->context == job->entity->fence_context || > + fence->context == job->entity->fence_context + 1) > + return true; > + > + if (dma_fence_is_chain(fence)) { > + dma_fence_chain_for_each(fence, fence) { > + if (!can_skip_dep(job, dma_fence_chain_contained(fence))) > + return false; > + } > + > + return true; > + } else if (dma_fence_is_array(fence)) { > + struct dma_fence *sub_fence; > + u32 index; > + > + dma_fence_array_for_each(sub_fence, index, fence) { > + if (!can_skip_dep(job, sub_fence)) > + return false; > + } > + > + return true; > + } > + > + return false; > +} > + > /** > * panthor_submit_ctx_add_sync_deps_to_job() - Add sync wait operations as > * job dependencies. > @@ -637,6 +673,11 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx, > return ret; > } > > + if (can_skip_dep(job, fence)) { > + dma_fence_put(fence); > + continue; > + } > + > ret = drm_sched_job_add_dependency(job, fence); > if (ret) > return ret; Alternatively you could do: dma_fence_unwrap_for_each(..) drm_sched_job_add_dependency(..) And no can_skip_dep would be required. As a side note this reminds me of my patch where I replaced job->dependencies XArray with a single dma_fence_array built with dma_fence_unwrap_merge as dependencies are added. So there is only one wq cycle for dependencies. Although the cost then moves to dma_fence_array signalling so I was never sure if it was fully worth it or not. Anyway, for this patch you can simplify as above. Regards, Tvrtko > > --- > base-commit: 28f286b0dfa9610d4ee2447415e964e8bc603056 > change-id: 20261201-panhtor-dep-skip-9c6a3e2f7cc7 > > Best regards,