AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: phasta@kernel.org, Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: kernel-dev@igalia.com, Danilo Krummrich <dakr@kernel.org>,
	Matthew Brost <matthew.brost@intel.com>
Subject: Re: [RFC 3/3] drm/sched: Disallow initializing entities with no schedulers
Date: Mon, 12 Jan 2026 13:51:37 +0100	[thread overview]
Message-ID: <207265df-4caf-4899-83be-ecd5b21d95cc@amd.com> (raw)
In-Reply-To: <87d5ab37bb3594ee8b1707ffaa28f4937a7f0ad4.camel@mailbox.org>

On 1/12/26 13:49, Philipp Stanner wrote:
> On Mon, 2026-01-12 at 10:29 +0000, Tvrtko Ursulin wrote:
>>
>> On 08/01/2026 13:54, Philipp Stanner wrote:
>>> What's the merge plan for this series? Christian?
>>
>> It sounds that staged merge would be safest. First two patches could go 
>> to amd-next and if everything will look fine, I would follow up by 
>> sending the DRM scheduler patch once amdgpu patches land to drm-next.
> 
> Works for me.

Sounds like a plan to me as well.

Regards,
Christian.

> 
>>
>> Or if DRM scheduler maintainers are happy for the DRM scheduler patch to 
>> also go via amd-next that is another option.
>>   > On Wed, 2026-01-07 at 12:43 +0000, Tvrtko Ursulin wrote:
>>>> Since we have removed the case where amdgpu was initializing entitites
>>>> with either no schedulers on the list, or with a single NULL scheduler,
>>>> and there appears no other drivers which rely on this, we can simplify the
>>>> scheduler by explictly rejecting that early.
>>>>
>>>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
>>>> Cc: Christian König <christian.koenig@amd.com>
>>>> Cc: Danilo Krummrich <dakr@kernel.org>
>>>> Cc: Matthew Brost <matthew.brost@intel.com>
>>>> Cc: Philipp Stanner <phasta@kernel.org>
>>>> ---
>>>>   drivers/gpu/drm/scheduler/sched_entity.c | 13 ++++---------
>>>>   1 file changed, 4 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
>>>> index fe174a4857be..bb7e5fc47f99 100644
>>>> --- a/drivers/gpu/drm/scheduler/sched_entity.c
>>>> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
>>>> @@ -61,32 +61,27 @@ int drm_sched_entity_init(struct drm_sched_entity *entity,
>>>>   			  unsigned int num_sched_list,
>>>>   			  atomic_t *guilty)
>>>>   {
>>>> -	if (!(entity && sched_list && (num_sched_list == 0 || sched_list[0])))
>>>> +	if (!entity || !sched_list || !num_sched_list || !sched_list[0])
>>>
>>> I personally am a fan of checking integers explicitly against a number,
>>> which would make the diff a bit more straightforward, too. But I accept
>>> that like that is common kernel practice.
>>>
>>>>   		return -EINVAL;
>>>>   
>>>>   	memset(entity, 0, sizeof(struct drm_sched_entity));
>>>>   	INIT_LIST_HEAD(&entity->list);
>>>>   	entity->rq = NULL;
>>>>   	entity->guilty = guilty;
>>>> -	entity->num_sched_list = num_sched_list;
>>>>   	entity->priority = priority;
>>>>   	entity->last_user = current->group_leader;
>>>> -	/*
>>>> -	 * It's perfectly valid to initialize an entity without having a valid
>>>> -	 * scheduler attached. It's just not valid to use the scheduler before it
>>>> -	 * is initialized itself.
>>>> -	 */
>>>> +	entity->num_sched_list = num_sched_list;
>>>
>>> Why do you move that line downwards? Just leave it where it was?
>>> num_sched_list isn't changed or anything, so I don't see a logical
>>> connection to the line below so that grouping would make sense.
>>
>> It looks completely logical to me to have both lines dealing with the
>> same scheduler list, accessing the same input parameter even, next to
>> each other:
>>
>>    entity->num_sched_list = num_sched_list;
>>    entity->sched_list = num_sched_list > 1 ? sched_list : NULL;
>>
>> No? In other words, I can respin if you insist but I don't see the need.
> 
> Fine by me. Though a little sentence about that cosmetical change in
> the commit message would have made that clearer.
> 
> 
> Greetings
> P.
> 
>>
>> Regards,
>>
>> Tvrtko
>>
>>>
>>> With that:
>>> Acked-by: Philipp Stanner <phasta@kernel.org>
>>>
>>>
>>> P.
>>>
>>>>   	entity->sched_list = num_sched_list > 1 ? sched_list : NULL;
>>>>   	RCU_INIT_POINTER(entity->last_scheduled, NULL);
>>>>   	RB_CLEAR_NODE(&entity->rb_tree_node);
>>>>   
>>>> -	if (num_sched_list && !sched_list[0]->sched_rq) {
>>>> +	if (!sched_list[0]->sched_rq) {
>>>>   		/* Since every entry covered by num_sched_list
>>>>   		 * should be non-NULL and therefore we warn drivers
>>>>   		 * not to do this and to fix their DRM calling order.
>>>>   		 */
>>>>   		pr_warn("%s: called with uninitialized scheduler\n", __func__);
>>>> -	} else if (num_sched_list) {
>>>> +	} else {
>>>>   		/* The "priority" of an entity cannot exceed the number of run-queues of a
>>>>   		 * scheduler. Protect against num_rqs being 0, by converting to signed. Choose
>>>>   		 * the lowest priority available.
>>>
>>
> 


  reply	other threads:[~2026-01-12 12:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07 12:43 [RFC 0/3] Simpler and more consistent handling of entities on missing hw blocks Tvrtko Ursulin
2026-01-07 12:43 ` [RFC 1/3] drm/amdgpu: Reject impossible entities early Tvrtko Ursulin
2026-01-08 13:13   ` Christian König
2026-01-07 12:43 ` [RFC 2/3] drm/amdgpu: Remove redundant missing hw ip handling Tvrtko Ursulin
2026-03-03 14:36   ` Christian König
2026-01-07 12:43 ` [RFC 3/3] drm/sched: Disallow initializing entities with no schedulers Tvrtko Ursulin
2026-01-08 13:54   ` Philipp Stanner
2026-01-12 10:29     ` Tvrtko Ursulin
2026-01-12 11:33       ` Danilo Krummrich
2026-01-12 12:49       ` Philipp Stanner
2026-01-12 12:51         ` Christian König [this message]
2026-01-22  8:52           ` Tvrtko Ursulin

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=207265df-4caf-4899-83be-ecd5b21d95cc@amd.com \
    --to=christian.koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-dev@igalia.com \
    --cc=matthew.brost@intel.com \
    --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