From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 17A99CFD621 for ; Wed, 7 Jan 2026 12:44:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E44D610E5B2; Wed, 7 Jan 2026 12:44:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="lbj7L7/K"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F0E010E5AF; Wed, 7 Jan 2026 12:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=L6mH04hD42whu/M4ViJcZkGsZadbIBl2lBTOcCjBvZE=; b=lbj7L7/K6zqrxomQd0k0k8Zoro kwj0qHVWAc8nCohqUzJ+FzNH/tpuHLFMFo5CVEqjrEzJPd701219QOvj92DGNBWQihIe+IHNgSu7i Rx46VWTlaT7zBu8J5kms5ec9mPYlht0KZcWaZTbuSTQhyWWVkHy1ixbgq43WNLA8gXWfEPkkRQffM an0Zji4Z1kgIVkPlTmUVl4HgLtyeuShTcOKwn/wAgHy57AzmV1SSdJDWq6ffiqaRfDtEsbrI8vV3T XIQvVIJpB6YuqT24Pd51+SAUCHHuq3OgjeGtzdFu40En7L3t6gLpLQb+RZLEEUKenxYJTHo7j3lPr nyJPBrBQ==; Received: from [90.240.106.137] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vdStL-002YtA-Gu; Wed, 07 Jan 2026 13:43:59 +0100 From: Tvrtko Ursulin To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-dev@igalia.com, =?UTF-8?q?Christian=20K=C3=B6nig?= , Danilo Krummrich , Matthew Brost , Philipp Stanner , Tvrtko Ursulin Subject: [RFC 3/3] drm/sched: Disallow initializing entities with no schedulers Date: Wed, 7 Jan 2026 12:43:51 +0000 Message-ID: <20260107124351.94738-4-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260107124351.94738-1-tvrtko.ursulin@igalia.com> References: <20260107124351.94738-1-tvrtko.ursulin@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" 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 Cc: Christian König Cc: Danilo Krummrich Cc: Matthew Brost Cc: Philipp Stanner --- 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]) 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; 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. -- 2.52.0