All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/8] drm/sched: Disallow initializing entities with un-initialized schedulers
Date: Tue, 20 Oct 2026 16:02:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-179327@kernel.org> (raw)
In-Reply-To: <20261020154123.33631-3-tvrtko.ursulin@igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/sched: drm_sched_entity_init() breaks v3d_open() on V3D 3.3
--

commit 607520d70e20fa56f0a8fa9eade2db9f019b764f
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>

drm/sched: Disallow initializing entities with un-initialized schedulers

This patch updates drm_sched_entity_init() to reject schedulers whose
run-queues have not been initialized, returning -EINVAL instead of logging
a warning and continuing.

> diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
> index e12709b7bd0c3..95bb79b3d003a 100644
> --- a/drivers/gpu/drm/scheduler/sched_entity.c
> +++ b/drivers/gpu/drm/scheduler/sched_entity.c
> @@ -119,9 +119,16 @@ 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 || !sched_list[0])
> +	unsigned int i;
> +
> +	if (!entity || !sched_list || !num_sched_list)
>  		return -EINVAL;
>  
> +	for (i = 0; i < num_sched_list; i++) {
> +		if (!sched_list[i] || !sched_list[i]->sched_rq)
> +			return -EINVAL;
> +	}

[Severity: High]
Does returning -EINVAL here when !sched_list[i]->sched_rq break
v3d_open() on V3D 3.3 hardware (V3D_GEN_33)?

During probe, v3d_sched_init() in drivers/gpu/drm/v3d/v3d_sched.c only
initializes the V3D_CSD and V3D_CACHE_CLEAN schedulers when
v3d_has_csd(v3d) is true:

drivers/gpu/drm/v3d/v3d_sched.c:v3d_sched_init() {
	...
	if (v3d_has_csd(v3d)) {
		ret = v3d_queue_sched_init(v3d, &v3d_csd_sched_ops, V3D_CSD,
					   "v3d_csd");
		if (ret)
			goto fail;

		ret = v3d_queue_sched_init(v3d, &v3d_cache_clean_sched_ops,
					   V3D_CACHE_CLEAN, "v3d_cache_clean");
		if (ret)
			goto fail;
	}
	...
}

On V3D 3.3 platforms where !v3d_has_csd(v3d), those two schedulers are
never initialized via drm_sched_init(), leaving their sched_rq pointers
NULL.

However, when userspace opens the DRM device node, v3d_open() in
drivers/gpu/drm/v3d/v3d_drv.c unconditionally loops over all
V3D_MAX_QUEUES queues and fails if drm_sched_entity_init() returns an
error:

drivers/gpu/drm/v3d/v3d_drv.c:v3d_open() {
	...
	for (i = 0; i < V3D_MAX_QUEUES; i++) {
		v3d_priv->stats[i] = v3d_stats_alloc();
		if (!v3d_priv->stats[i]) {
			ret = -ENOMEM;
			goto err_stats;
		}

		sched = &v3d->queue[i].sched;
		ret = drm_sched_entity_init(&v3d_priv->sched_entity[i],
					    DRM_SCHED_PRIORITY_NORMAL, &sched,
					    1, NULL);
		if (ret)
			goto err_sched;
	}
	...
}

Previously, drm_sched_entity_init() logged a warning via pr_warn() and
returned 0, allowing v3d_open() to succeed. With this change, won't
every v3d_open() call on V3D 3.3 fail with -EINVAL?

[ ... ]

>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261020154123.33631-1-tvrtko.ursulin@igalia.com?part=2

  reply	other threads:[~2026-10-20 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 15:41 [PATCH v2 0/8] DRM scheduler assorted cleanups Tvrtko Ursulin
2026-10-20 15:41 ` [PATCH v2 1/8] drm/sched: Fix out of bounds entity priority check Tvrtko Ursulin
2026-10-20 15:41 ` [PATCH v2 2/8] drm/sched: Disallow initializing entities with un-initialized schedulers Tvrtko Ursulin
2026-10-20 16:02   ` sashiko-bot [this message]
2026-10-20 15:41 ` [PATCH v2 3/8] drm/sched: Reject double scheduler initialization Tvrtko Ursulin
2026-10-20 15:41 ` [PATCH v2 4/8] drm/sched: Remove log message of questionable use Tvrtko Ursulin
2026-10-20 15:41 ` [PATCH v2 5/8] drm/sched: Remove useless log message on memory exhaustion Tvrtko Ursulin
2026-10-20 15:41 ` [PATCH v2 6/8] drm/sched: Ignore stopped entity attempt to change its run-queue Tvrtko Ursulin
2026-10-20 15:41 ` [PATCH v2 7/8] drm/sched: Replace completion with a flush Tvrtko Ursulin
2026-10-20 15:41 ` [PATCH v2 8/8] drm/sched: Untangle the scheduler list mess 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=sashiko-outbox-179327@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.