From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: phasta@kernel.org, Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
dri-devel@lists.freedesktop.org, dakr@kernel.org,
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/sched: add drm_sched_prealloc_dependency_slots
Date: Fri, 21 Mar 2025 14:25:03 +0100 [thread overview]
Message-ID: <09e28c34-657d-43c1-9f2e-e1870425b450@gmail.com> (raw)
In-Reply-To: <773a6105e1b448ecb2be8b2c80bb63c0e08f52d2.camel@mailbox.org>
Am 21.03.25 um 09:20 schrieb Philipp Stanner:
> On Thu, 2025-03-20 at 11:49 +0000, Tvrtko Ursulin wrote:
>> On 19/03/2025 11:23, Christian König wrote:
>>>>> + *
>>>>> + * Return:
>>>>> + * 0 on success, or an error on failing to expand the array.
>>>>> + */
>>>>> +int drm_sched_job_prealloc_dependency_slots(struct
>>>>> drm_sched_job
>>>>> *job,
>>>>> + unsigned int
>>>>> num_deps)
>>>>> +{
>>>>> + struct dma_fence *fence;
>>>>> + u32 id = 0;
>>>>> + int ret;
>>>>> +
>>>>> + while (num_deps--) {
>>>>> + fence = dma_fence_get_stub();
>>>>> + ret = xa_alloc(&job->dependencies, &id, fence,
>>>>> xa_limit_32b,
>>>>> + GFP_KERNEL);
>>>> So this would fill the xarr with already signaled fences which
>>>> then
>>>> later will be replaced with unsignaled fences?
>>> Yes, exactly that's the idea.
>>>
>>>> Help me out here: would it also work to add NULL instead of that
>>>> stub-
>>>> fence?
>>> Good question, idk. That's an implementation detail of the xarray.
>>>
>>> Tvrtko also correctly pointed out that it is most likely a bad idea
>>> to
>>> use dma_fence_is_signaled() in the critical code path.
>>>
>>> I will try to dig through the xarray behavior up and update the
>>> patch if
>>> possible.
>> I think NULL on its own is not possible, but the two low bits are
>> available for pointer tagging, or designating pointers vs integers,
>> which looks like it could work. Something like storing
>> xa_tag_pointer(NULL, 1) to reserved slots and at lookup time they
>> would
>> be detected with "xa_pointer_tag(fence) & 1".
> Almost!
>
> they would be detected with a super-readable
>
> #define DRM_SCHED_XARR_TAG_RESERVED_ENTRY 1
>
> or maybe …UNUSED_ENTRY?
NULL doesn't work because xa_for_each() skips NULL entries, but it looks like somebody else stumbled over the same problem we have here as well.
So there is already the solution to use XA_ZERO_ENTRY! That special value can then either be used with xa_alloc() or through xa_reserve().
It's just that the xarray documentation is not explicitly pointing that out, so I had to dig around in the code a bit to figure out how everything works.
Regards,
Christian.
>
> ^_^
>
> P.
>
>
>> Regards,
>>
>> Tvrtko
>>
next prev parent reply other threads:[~2025-03-21 13:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 12:03 Try to fix amdgpu's error handling Christian König
2025-03-18 12:03 ` [PATCH 1/2] drm/sched: add drm_sched_prealloc_dependency_slots Christian König
2025-03-18 12:39 ` Danilo Krummrich
2025-03-19 11:14 ` Christian König
2025-03-18 12:39 ` Philipp Stanner
2025-03-19 11:23 ` Christian König
2025-03-20 11:49 ` Tvrtko Ursulin
2025-03-21 8:20 ` Philipp Stanner
2025-03-21 13:25 ` Christian König [this message]
2025-03-18 13:03 ` Tvrtko Ursulin
2025-03-18 12:03 ` [PATCH 2/2] drm/amdgpu: fix gang submission error handling Christian König
2025-03-18 12:55 ` Tvrtko Ursulin
2025-03-18 12:36 ` Try to fix amdgpu's " Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=09e28c34-657d-43c1-9f2e-e1870425b450@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=phasta@kernel.org \
--cc=tvrtko.ursulin@igalia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox