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 44BF7E6BF34 for ; Fri, 30 Jan 2026 17:31:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD1EA10EA28; Fri, 30 Jan 2026 17:31:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="dOhdhy29"; dkim-atps=neutral Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012019.outbound.protection.outlook.com [40.107.200.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id C41EC10EA2C for ; Fri, 30 Jan 2026 17:31:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mAZABG4zSlBMskgh+YmtwXKw1qw2wahAjVb17VNriIPRw6J5HtgtqmczSbMdso6WqwUleXkSNTRSvbPSSBN9476zdap/uUvuV2LUpgj0udJlOiEhqIJZ3ciFV616FLFTutfZfCs/RtoVF5UIKZUZSyqh5BB+fW4l+puhTuyFRz682Ek19SNVecFck0+AGDtRAuStvhnbt5kbTmlSOX3dISR6L+mC9tdum+RUkiOq5aRRdmK1g1Kzpc0TLDj3rGQTHGPGkSq+KF6TBwMWygGbEGezhPslEUX4i1+5unF37PcGcOwHnOlboHiD/5JNbTFRaPjrr+kPkjwDJ3LZyj1DeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IEIf3eZY6MZ8O1ilv6uRam/j2k4OjsPIkJrxHs6nDPY=; b=K1BamuIzhKlXEDZWlSNd/6sABz6FLYHquILA/jI53e5EN6UmkEVpS5srVDxznou1b5CLV1W075ddJL+0BSmfd3MG3KO158AoTGsmiSRdTFEZ5c2AkviI1LMrULBTMy9kP+U8GN1jT7B6cYGkSCRAyB23KPs9kYTXiwIHRJH4R9EZpMq+k0lNZF9ZslwlsMChnrjNMF5FWX5AprI0QDUQJ1E3BhvMZ76rMn1F70PpKNkuIlx0FGC3Tj765imorZOnHjWs2OsMjc6zb+secbcGXK/M7aFExBJL4XpqfThX96cFvQ2pgaP+1z5d9XMeKiFQTVw/5fnLeYcjmcViQdzOsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IEIf3eZY6MZ8O1ilv6uRam/j2k4OjsPIkJrxHs6nDPY=; b=dOhdhy297lA91kQ135yGo9+fGt05rmu4nxIYS+uvftchKI5349rvCpa3MKp+2e2PKCKZczdK+zJrEKS3YIcdPD2YhEzDZPgMJyDA8MVAZHFvftv0ZZoSHbTt+LtQLwBvVypSNbgIoRBwJd+RBebT2O61I4d8v/wVQX2vU7Era/A= Received: from SJ0PR05CA0136.namprd05.prod.outlook.com (2603:10b6:a03:33d::21) by SN7PR12MB7107.namprd12.prod.outlook.com (2603:10b6:806:2a2::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.7; Fri, 30 Jan 2026 17:31:01 +0000 Received: from SJ1PEPF00002327.namprd03.prod.outlook.com (2603:10b6:a03:33d:cafe::e8) by SJ0PR05CA0136.outlook.office365.com (2603:10b6:a03:33d::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9587.4 via Frontend Transport; Fri, 30 Jan 2026 17:30:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF00002327.mail.protection.outlook.com (10.167.242.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9564.3 via Frontend Transport; Fri, 30 Jan 2026 17:31:01 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Fri, 30 Jan 2026 11:30:57 -0600 Received: from p8.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Fri, 30 Jan 2026 09:30:57 -0800 From: Alex Deucher To: , CC: Alex Deucher , Jesse Zhang Subject: [PATCH 04/12] drm/amdgpu: require a job to schedule an IB Date: Fri, 30 Jan 2026 12:30:34 -0500 Message-ID: <20260130173042.15008-5-alexander.deucher@amd.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130173042.15008-1-alexander.deucher@amd.com> References: <20260130173042.15008-1-alexander.deucher@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002327:EE_|SN7PR12MB7107:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b745ce0-30aa-4e86-a0c3-08de6025566a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?90eufl/dV8zMuWTWXVdd/P7+5pM6lzfHWj7tbTjg/zpV/756wJ+Aasfdj8Ai?= =?us-ascii?Q?6ph1H92bG+EuSLRfjlaTTjqUyOsj4fGtMslxLjw0ZLACGbKSZ2oCs/mqWLP9?= =?us-ascii?Q?Is7z+y4MNWV6hURMqH0cCpkJ13NsTBRCbya2vHkq6KSpsPFZqPiJ7D+e1rZ4?= =?us-ascii?Q?WdnaljsYouIj6VH12IvlggZPnApeJmtkK6SfCQV0LPpKTZVk6pjjTpmoA9uG?= =?us-ascii?Q?5Drf7EMGxZ2IpOFfXnENIDMPCGJyjQu12087f7CwWa4UnmuPERyENvuEZdMK?= =?us-ascii?Q?/C73KQpFKMQELpW1vw63tl8MGvnSj73FwVy+4wYgWjGAqesu3uUQvTX6NxKb?= =?us-ascii?Q?LO9Qg2FDXxohP9BqlkdA8ObQXCClOuYMg4oywljHliHzOhhJq0Q0XGfPrWWH?= =?us-ascii?Q?xsuzhrFwVu96KsNiHiunu8+CeckL6v8W0WjI0yWDqlwV7OTwoLWJFXOpJt+g?= =?us-ascii?Q?E2CmuKNQNK/iy7YoFJnYriITszUNhfq73ivurM6ftWZ+oiZb20/FzoamWJyt?= =?us-ascii?Q?34wD7FlDWR+kKVNpEJqyrtolg0cfP76l08F9O4U8OBm9uBaHfV2Pix7XL/4F?= =?us-ascii?Q?YZKdtwsuxmjqni2rOz1XS5rRl7ZY7ohJHlD5/SeW/XsqAWS2p7g67YDK4PgJ?= =?us-ascii?Q?WS+t8QwJ8ge1RSpP/GyHqf1UGcNGKwJNX0AE4rEJmmLKFZPKbOP37YUoNuau?= =?us-ascii?Q?aFoJ5wj6NGjK9aAjlG6gkIZenMrMoBEMPs0f4/xAh7vD4tqeBAmD3QrC970c?= =?us-ascii?Q?4x5YTGHPmjB0425r0PdGe7yWuHxI3HuesJkZ3aCIKT541xc6Sn9KUACYU6nT?= =?us-ascii?Q?IIaO/PfT0cOyVIek8D+g6Fc5C7wcd1ePLu8ldTs+qZMD2gvt7Dhnn7XrG9ql?= =?us-ascii?Q?GSOGjch7ATlW837aoM5Vi6zGw9XrjJx21RKUTQ1rzoiALhZWkgPyaSaKm+Ps?= =?us-ascii?Q?ByGuJNlyEJNXo4m5EAFNLJShEUGLUB2NzX8G16WccQ4Qv2NQGYTWd3urYB+M?= =?us-ascii?Q?AfSzTAlRT+xUL5zsVR9c0vufv/GE82SW0hOK0X01w+iuYRFyLTAmJwxSrWoy?= =?us-ascii?Q?t8j/voVU7uQR8afsNMitm57GWGd6ztpMzB27RjHsNQES0bC49h68ruKFAE/8?= =?us-ascii?Q?pN1eo/cY2UM0vqlI6ZhmIwyfmCj/4jrahbtriXmWwrzs6XNIp7JsXgOSmzan?= =?us-ascii?Q?wlQVGsJ8/CiyoXUNxUQp/Fmy3+ZC26gb/SYpfwwxz+FUNZrdC7VCRb0hflZX?= =?us-ascii?Q?CuRKc2Y+8uMwXLD6fcBeKGTDYbQBmlJYJ1NIw4gpeHJVTJq5Rt5k56Eb3/J/?= =?us-ascii?Q?ui6eFS/D/O74jSDPMalzvaXi+KBIlOdsbQvKC9Gt+5PCx1vxsNLy3j37ueHL?= =?us-ascii?Q?kp4iy8oJjHjO1WtotA6jAzo7M0WfXBnyteCcIC54tiS01lEMo/WEHQiDE2h5?= =?us-ascii?Q?Prz095SJUYvYm54rMsZH1SghO80cb/UUoXjVg7NdfrJ+72aJN7daLutUR6fX?= =?us-ascii?Q?3zFU11GwtBECzXEiwicH5hXOv0vyMutXGzbFo9ndlP9AZasvUhJNuT2fiVGJ?= =?us-ascii?Q?AqA6Rrzdi9jTIe3WeUbCUjI71/BGQ1h3ebenODX0Zr1xyRlCidlmIMmAU3lG?= =?us-ascii?Q?LgaJ6XVga7Z8RQDkZwoaCHXxTMs5bpJuP6BukIq6aGglCXZh5ilNJ3yzwMlV?= =?us-ascii?Q?UT83/w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(376014)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cgmQfh4LopOnoPA+fOe8tFLpNaxeF6RMXp8+ZCH+b9uUUZiGgN0a0xH25enCbiWl7dBoik0eYhhr5xZSXIzl5wQbsxI8O+M39QvPu6vZIgFIBi2rqaHoQljBgxoHPg+9Yd830FgThXpluqMbd/NB5IMac4NmN3hz21U3rnoOBnrJ79FtD+eL3PiMmvyjMcS8Ew7Xq8a8SGeEGt5nsnZKac4sq1LpRGPL5Plhs7qBGd1zetHPaNY/QAART2ZOVntbmEmBNIw2jOoObdih84iKbxgnu0wEIiL6TgrAB/N3AeLqmvxB2pSp5YAi8EpSDjIr+drNdjRofxZlTGG6TvQ7jgqivKy3rlEaWP5/AlYoEGgOPPIRepAM/u0WBzGqwmJB04Kja8+tN/atdutguGUJPZ4LWAbOePbmV9yBWJxeU2uzACLDatW4mazUNAu896/X X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2026 17:31:01.1739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b745ce0-30aa-4e86-a0c3-08de6025566a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002327.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7107 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" Remove the old direct submit path. This simplifies the code. v2: remove more local variables Reviewed-by: Jesse Zhang Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 111 ++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 3 +- 4 files changed, 44 insertions(+), 77 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index 89df26dd5ada7..f69eafb898540 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c @@ -686,7 +686,7 @@ int amdgpu_amdkfd_submit_ib(struct amdgpu_device *adev, job->vmid = vmid; job->num_ibs = 1; - ret = amdgpu_ib_schedule(ring, 1, ib, job, &f); + ret = amdgpu_ib_schedule(ring, job, &f); if (ret) { drm_err(adev_to_drm(adev), "failed to schedule IB.\n"); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index 23f73958663ad..1f60ccb8782ee 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c @@ -103,8 +103,6 @@ void amdgpu_ib_free(struct amdgpu_ib *ib, struct dma_fence *f) * amdgpu_ib_schedule - schedule an IB (Indirect Buffer) on the ring * * @ring: ring index the IB is associated with - * @num_ibs: number of IBs to schedule - * @ibs: IB objects to schedule * @job: job to schedule * @f: fence created during this submission * @@ -121,85 +119,64 @@ void amdgpu_ib_free(struct amdgpu_ib *ib, struct dma_fence *f) * a CONST_IB), it will be put on the ring prior to the DE IB. Prior * to SI there was just a DE IB. */ -int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, - struct amdgpu_ib *ibs, struct amdgpu_job *job, +int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job, struct dma_fence **f) { struct amdgpu_device *adev = ring->adev; - struct amdgpu_ib *ib = &ibs[0]; + struct amdgpu_ib *ib; struct dma_fence *tmp = NULL; struct amdgpu_fence *af; bool need_ctx_switch; - struct amdgpu_vm *vm; uint64_t fence_ctx; uint32_t status = 0, alloc_size; unsigned int fence_flags = 0; - bool secure, init_shadow; - u64 shadow_va, csa_va, gds_va; + bool secure; int vmid = AMDGPU_JOB_GET_VMID(job); bool need_pipe_sync = false; unsigned int cond_exec; unsigned int i; int r = 0; - if (num_ibs == 0) + if (!job) + return -EINVAL; + if (job->num_ibs == 0) return -EINVAL; - /* ring tests don't use a job */ - if (job) { - vm = job->vm; - fence_ctx = job->base.s_fence ? - job->base.s_fence->finished.context : 0; - shadow_va = job->shadow_va; - csa_va = job->csa_va; - gds_va = job->gds_va; - init_shadow = job->init_shadow; - af = job->hw_fence; - /* Save the context of the job for reset handling. - * The driver needs this so it can skip the ring - * contents for guilty contexts. - */ - af->context = fence_ctx; - /* the vm fence is also part of the job's context */ - job->hw_vm_fence->context = fence_ctx; - } else { - vm = NULL; - fence_ctx = 0; - shadow_va = 0; - csa_va = 0; - gds_va = 0; - init_shadow = false; - af = kzalloc(sizeof(*af), GFP_ATOMIC); - if (!af) - return -ENOMEM; - } + ib = &job->ibs[0]; + fence_ctx = job->base.s_fence ? + job->base.s_fence->finished.context : 0; + af = job->hw_fence; + /* Save the context of the job for reset handling. + * The driver needs this so it can skip the ring + * contents for guilty contexts. + */ + af->context = fence_ctx; + /* the vm fence is also part of the job's context */ + job->hw_vm_fence->context = fence_ctx; if (!ring->sched.ready) { dev_err(adev->dev, "couldn't schedule ib on ring <%s>\n", ring->name); - r = -EINVAL; - goto free_fence; + return -EINVAL; } - if (vm && !job->vmid) { + if (job->vm && !job->vmid) { dev_err(adev->dev, "VM IB without ID\n"); - r = -EINVAL; - goto free_fence; + return -EINVAL; } if ((ib->flags & AMDGPU_IB_FLAGS_SECURE) && (!ring->funcs->secure_submission_supported)) { dev_err(adev->dev, "secure submissions not supported on ring <%s>\n", ring->name); - r = -EINVAL; - goto free_fence; + return -EINVAL; } - alloc_size = ring->funcs->emit_frame_size + num_ibs * + alloc_size = ring->funcs->emit_frame_size + job->num_ibs * ring->funcs->emit_ib_size; r = amdgpu_ring_alloc(ring, alloc_size); if (r) { dev_err(adev->dev, "scheduling IB failed (%d).\n", r); - goto free_fence; + return r; } need_ctx_switch = ring->current_ctx != fence_ctx; @@ -225,19 +202,17 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, if (ring->funcs->insert_start) ring->funcs->insert_start(ring); - if (job) { - r = amdgpu_vm_flush(ring, job, need_pipe_sync); - if (r) { - amdgpu_ring_undo(ring); - return r; - } + r = amdgpu_vm_flush(ring, job, need_pipe_sync); + if (r) { + amdgpu_ring_undo(ring); + return r; } amdgpu_ring_ib_begin(ring); if (ring->funcs->emit_gfx_shadow && adev->gfx.cp_gfx_shadow) - amdgpu_ring_emit_gfx_shadow(ring, shadow_va, csa_va, gds_va, - init_shadow, vmid); + amdgpu_ring_emit_gfx_shadow(ring, job->shadow_va, job->csa_va, job->gds_va, + job->init_shadow, vmid); if (ring->funcs->init_cond_exec) cond_exec = amdgpu_ring_init_cond_exec(ring, @@ -248,7 +223,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, if (need_ctx_switch) status |= AMDGPU_HAVE_CTX_SWITCH; - if (job && ring->funcs->emit_cntxcntl) { + if (ring->funcs->emit_cntxcntl) { status |= job->preamble_status; status |= job->preemption_status; amdgpu_ring_emit_cntxcntl(ring, status); @@ -257,15 +232,15 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, /* Setup initial TMZiness and send it off. */ secure = false; - if (job && ring->funcs->emit_frame_cntl) { + if (ring->funcs->emit_frame_cntl) { secure = ib->flags & AMDGPU_IB_FLAGS_SECURE; amdgpu_ring_emit_frame_cntl(ring, true, secure); } - for (i = 0; i < num_ibs; ++i) { - ib = &ibs[i]; + for (i = 0; i < job->num_ibs; ++i) { + ib = &job->ibs[i]; - if (job && ring->funcs->emit_frame_cntl) { + if (ring->funcs->emit_frame_cntl) { if (secure != !!(ib->flags & AMDGPU_IB_FLAGS_SECURE)) { amdgpu_ring_emit_frame_cntl(ring, false, secure); secure = !secure; @@ -277,7 +252,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, status &= ~AMDGPU_HAVE_CTX_SWITCH; } - if (job && ring->funcs->emit_frame_cntl) + if (ring->funcs->emit_frame_cntl) amdgpu_ring_emit_frame_cntl(ring, false, secure); amdgpu_device_invalidate_hdp(adev, ring); @@ -286,7 +261,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, fence_flags |= AMDGPU_FENCE_FLAG_TC_WB_ONLY; /* wrap the last IB with fence */ - if (job && job->uf_addr) { + if (job->uf_addr) { amdgpu_ring_emit_fence(ring, job->uf_addr, job->uf_sequence, fence_flags | AMDGPU_FENCE_FLAG_64BIT); } @@ -300,15 +275,14 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, r = amdgpu_fence_emit(ring, af, fence_flags); if (r) { dev_err(adev->dev, "failed to emit fence (%d)\n", r); - if (job && job->vmid) + if (job->vmid) amdgpu_vmid_reset(adev, ring->vm_hub, job->vmid); amdgpu_ring_undo(ring); - goto free_fence; + return r; } *f = &af->base; /* get a ref for the job */ - if (job) - dma_fence_get(*f); + dma_fence_get(*f); if (ring->funcs->insert_end) ring->funcs->insert_end(ring); @@ -316,7 +290,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, amdgpu_ring_patch_cond_exec(ring, cond_exec); ring->current_ctx = fence_ctx; - if (job && ring->funcs->emit_switch_buffer) + if (ring->funcs->emit_switch_buffer) amdgpu_ring_emit_switch_buffer(ring); if (ring->funcs->emit_wave_limit && @@ -335,11 +309,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, amdgpu_ring_commit(ring); return 0; - -free_fence: - if (!job) - kfree(af); - return r; } /** diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index 9870dbefe414b..df06a271bdf99 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -379,7 +379,7 @@ int amdgpu_job_submit_direct(struct amdgpu_job *job, struct amdgpu_ring *ring, int r; job->base.sched = &ring->sched; - r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs, job, fence); + r = amdgpu_ib_schedule(ring, job, fence); if (r) return r; @@ -449,8 +449,7 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job) dev_dbg(adev->dev, "Skip scheduling IBs in ring(%s)", ring->name); } else { - r = amdgpu_ib_schedule(ring, job->num_ibs, job->ibs, job, - &fence); + r = amdgpu_ib_schedule(ring, job, &fence); if (r) dev_err(adev->dev, "Error scheduling IBs (%d) in ring(%s)", r, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index cb0fb1a989d2f..86a788d476957 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h @@ -569,8 +569,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, enum amdgpu_ib_pool_type pool, struct amdgpu_ib *ib); void amdgpu_ib_free(struct amdgpu_ib *ib, struct dma_fence *f); -int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs, - struct amdgpu_ib *ibs, struct amdgpu_job *job, +int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job, struct dma_fence **f); int amdgpu_ib_pool_init(struct amdgpu_device *adev); void amdgpu_ib_pool_fini(struct amdgpu_device *adev); -- 2.52.0