From patchwork Mon Jan 20 16:52:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 13945277 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 1558AC02182 for ; Mon, 20 Jan 2025 16:52:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E62B010E44A; Mon, 20 Jan 2025 16:52:48 +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="AsJ5hGvk"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BD1A10E44A; Mon, 20 Jan 2025 16:52:47 +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: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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7H4QuAlO5JKO5RCWS7k3G/YRJZbKlVzlI/O/Cw6qPb4=; b=AsJ5hGvkcinD//mMnDQNnNE0/i 6yWqTk4onOJ2lSzqub9ypVYHKE6OwOShXQKgjHg1phAqLFjUGy3BKtm2CgjMc1JhZWquCghTja2Gn BLWR/yWtKhdHvuvTmTElzyEv4+Jbhd3wsXDsq3txKOBG0kpHUJsEmT+LtSiaW1cCZneiJAadI2QKg GZQV/i3D/A2DOD/nVF0Uq6hY+iJ3P10J0pfOA+Ys4jbdSvmisW+nZ+jLpIG9yEj5w8qX59f6XaDlL EXnQjAYDWiDbuqhuyQA1L3HegvM0NT8XYCzSGSjQwqgpzfxP7cH2Iiixg/przBX48cgg99BjjnL8Y XhhHNVxg==; Received: from [90.241.98.187] (helo=localhost) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1tZv12-000v9P-Pp; Mon, 20 Jan 2025 17:52:44 +0100 From: Tvrtko Ursulin To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-dev@igalia.com, Tvrtko Ursulin , =?utf-8?q?Christian_K=C3=B6nig?= , Danilo Krummrich , Matthew Brost , Philipp Stanner Subject: [PATCH 0/4] A bit of struct drm_sched_job cleanup Date: Mon, 20 Jan 2025 16:52:36 +0000 Message-ID: <20250120165240.9105-1-tvrtko.ursulin@igalia.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" At one point I thought I wanted to add a member to struct drm_sched_job. As I noticed there is a hole in the struct, I went to re-order some members to get rid of it (the hole), at which point I was greeted by a subtle bug cause by the frequent pattern of: job = to_drm_sched_job(spsc_queue_peek|pop(...)) Because to_drm_sched_job is a container of, it implies a lot of the scheduler (and amdgpu) assumes job->queue_node is the first struct element. Dare to change that, code will compile but weird things will happen at runtime. So I thought lets clean that up and remove that hardcoded sneaky assumption and that is what this series does. 1) Adds a helper so amdgpu can touch the scheduler internals a little bit less. 2) Removes the assumption job->queue_node must be the first element. 3) And finally removes the hole from struct drm_sched_job, fixing one instance of type confusion in passing too. Cc: Christian König Cc: Danilo Krummrich Cc: Matthew Brost Cc: Philipp Stanner Tvrtko Ursulin (4): drm/sched: Add job popping API drm/amdgpu: Use the new low level job popping helper drm/sched: Remove to_drm_sched_job internal helper drm/sched: Make the type of drm_sched_job->last_dependency consistent drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 +- drivers/gpu/drm/scheduler/sched_entity.c | 20 ++++---- drivers/gpu/drm/scheduler/sched_main.c | 10 ++-- include/drm/gpu_scheduler.h | 59 ++++++++++++++++-------- 4 files changed, 57 insertions(+), 37 deletions(-)