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 33084CD4F21 for ; Wed, 13 May 2026 19:30:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF16910F026; Wed, 13 May 2026 19:30:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ETYxKu9g"; dkim-atps=neutral Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012038.outbound.protection.outlook.com [40.107.209.38]) by gabe.freedesktop.org (Postfix) with ESMTPS id 427D010F026 for ; Wed, 13 May 2026 19:30:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hswZuyG520G0+oYy/o0e6XD6i8ctkiFD66raXDMSMhjXxh7RgYueuBZpuhR0zG42CqfPjdd62DCKcr08CWn8NTIPgc6WFkRFwvT1kwivexC0FOmFVZBYaF5IYIyAGRVzvGsM/riqFKOEozQ8YqPnqo2DSp9v8Lxx1n9Lds7RoGkylr/vu0ytMleGc4y6047BDcYZEw/ZwsUpWu+k+4EGr77dPpYIvyD0J1yRIIyODgLXdzzbvw98xkm12cqTxczhgLunP1bVtnqpAsQnj1K8zTWQiML9+Su4E/ZrGL7UKYXur3Mn08jjL6WRi52+gRBNhYfqf/seh6qTQpy3ffsJEg== 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=zGoucRk93w2q5QPZ39tmMcp3vgsQITW33LU3duJvnMI=; b=uHPbiZqQFKK+xBhkfRO65HYumd4lsb0XLCdl/Cz66OuOjhXWcQWOFpiNfay1PR7Dl3iemjY7F2aJ6z6QBpZnKMsz0H+5CUWYdHBgAEAGmvEhtqKAJrHcFftJ7a6eCsiE/8dMM5ATuU49z5pLSERhuQUDPkkAvSSFlqQObC37AIk83NsiKtyYDlRkJ7Oyytn3BHr6prMuo4kr7v6C/KlpPeV81yIQpt92D14mBD8Oc8ugCZDP52qly+47gZPNWaWzB2+qhrLP6Rf4alTQG85AvOZ7I6VyKRS6wXKhjCADeTyTq529dNLEUoMPwHuYdy6wh8I6Xbrrp/J9lHhFCbLiug== 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=zGoucRk93w2q5QPZ39tmMcp3vgsQITW33LU3duJvnMI=; b=ETYxKu9gkWlVeXkKf7DyaYyVNlcIkWsjYeQyVnsk52R/TO6KVejD5t3AXVC5bg07+4LJ5JZgN11L7n+F5fr3bQgSZ6xgWvYAm5ANtTLVpAK7OOZ6Uumms3IBW3InSC52BQiylEX5Dq02FElT5Rax7SkPGtewDf4U0HBkXXC0aPQ= Received: from CYZPR20CA0017.namprd20.prod.outlook.com (2603:10b6:930:a2::24) by SA5PPFB1A5CE29A.namprd12.prod.outlook.com (2603:10b6:80f:fc04::8dc) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.25; Wed, 13 May 2026 19:30:33 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:930:a2:cafe::5) by CYZPR20CA0017.outlook.office365.com (2603:10b6:930:a2::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9913.12 via Frontend Transport; Wed, 13 May 2026 19:30:32 +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 CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.25.13 via Frontend Transport; Wed, 13 May 2026 19:30:32 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) 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.41; Wed, 13 May 2026 14:30:31 -0500 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Wed, 13 May 2026 12:30:31 -0700 Received: from p8.amd.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.41 via Frontend Transport; Wed, 13 May 2026 14:30:31 -0500 From: Alex Deucher To: CC: Alex Deucher , Jesse Zhang Subject: [PATCH 1/3] drm/amdgpu/job: use GFP_ATOMIC while in gpu reset Date: Wed, 13 May 2026 15:30:15 -0400 Message-ID: <20260513193017.38859-1-alexander.deucher@amd.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000143:EE_|SA5PPFB1A5CE29A:EE_ X-MS-Office365-Filtering-Correlation-Id: b54a07a4-001a-4a90-9f8a-08deb1261938 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700016|18002099003|56012099003|11063799003; X-Microsoft-Antispam-Message-Info: P+AdfbNiQPvx0/7U3vfB36GFsVX3Yj6lYDlHoUuCG8Lbzze5kR8ZQiMFv73Z/xI1yFsKVFS450prh8kax21LIdRdZSd7Jz2A8VToaewCWz0lyNPQos7qo8GcvVLOYjmnd+Raz3wDkkRcHmsbTsTBFMduul2Ws1xtvESa1L4CNKD9ELQlb1uRZaCPTnhMUKnlaq193vGRn6AbQdOz826RHR3BSSvy5xyASJkaaJdMhQ0dj2WcejHand7Fv9WIqhF6RkbsIo5iI2qwuaH/3+vEh26z/ff78zrwjqgY1DdGZWXFmQhJF+szTRMSSnVU0Tz0enY1Q/OrRnlVQjQUBUml2r4vhJbv24tRsdrHcZD5SGIOSnHMx1ALOkyHZvYl50wUXYiVpBP7WC27pA2NGZhaCzcosVamgeEpNuck/a7rjQ3/jvgBFXRPeZrSi8kiz9IyZqfRnI11skz9txIsCwX8ivvCKx3rGayLjZ7K1II7FB3xp3wW07WlYXt9K8+DKceodRx8ZnCRZOZK+5MD+f5t49yTrJW+rOKTT8pbLcaHsJKhdvjfIlyFrzR377eJxxL9yy7dKzAamT7YNx2EyJMYAT41IoPu9EVFTQ5KRNaxyp7rt5R/DmBedIOKFOKz2KsAktNJXNMCMxSoDwv+L6D6lz83yKzzd22lsqhanBE+0rsXDYI4EzLdicjqPA2FZC9kbD/WVR12BYeRiF1pLchbZjoHHuxhrZgf8gK/xhAhHRM= 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)(376014)(1800799024)(82310400026)(36860700016)(18002099003)(56012099003)(11063799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b79FZHJ4L7djNcysOi9JtMGBxuHz+7X3HwFyK3bcyBS541BtafoMAwkNLjLR/v3Kt/IphlS8aTAo0KmIRh6NW03/W4wIyS24s/tDJIscoUcLj+ICU5uSs4RVGxUiLAK7ZrixjBABTK8Ru51jSKzU8vs29hmLkO5QmxI40Z5zQloij5j5hFvz6YqMR6d1H6oQ7mUg/ZR3p1eOwULs7B9QIpCoRSMcIbmMjazXmZ6D0feR+ChIT+ahrpJArf6wGvbpz1vTMEaT6gmMzq59tPyuru6DQN5WRHS5mpO50p7QIwhaaQECLEGeddes90ojFoUf4b2LAGK7gkma5pFMyVo4Tri/w+Ps7Np3uJJZmDxChbwsYejc3wOnVosNiQXCdf7s744x5eOvDdr9/ILKQTXAh3JH7H9IQ0/9riihvhI4nDtEl1vctgZQhYxbendLoDzD X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2026 19:30:32.2672 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b54a07a4-001a-4a90-9f8a-08deb1261938 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA5PPFB1A5CE29A 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" If we need to allocate a job during GPU reset, use GFP_ATOMIC rather than GFP_KERNEL. v2: use pool type it determine alloc flags. Reviewed-by: Jesse Zhang Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 13 ++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | 5 +++-- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index 7b10bbe28caff..fa0f3300db3d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c @@ -671,7 +671,7 @@ int amdgpu_amdkfd_submit_ib(struct amdgpu_device *adev, goto err; } - ret = amdgpu_job_alloc(adev, NULL, NULL, NULL, 1, &job, 0); + ret = amdgpu_job_alloc(adev, NULL, NULL, NULL, 1, &job, 0, false); if (ret) goto err; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 10d8dcc3a9721..56640467cca58 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -275,7 +275,7 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, for (i = 0; i < p->gang_size; ++i) { ret = amdgpu_job_alloc(p->adev, vm, p->entities[i], vm, num_ibs[i], &p->jobs[i], - p->filp->client_id); + p->filp->client_id, false); if (ret) goto free_all_kdata; switch (p->adev->enforce_isolation[fpriv->xcp_id]) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c index f1ed4a436f5b4..80565c4a31bdf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c @@ -69,7 +69,7 @@ int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm, if (size) { r = amdgpu_sa_bo_new(&adev->ib_pools[pool_type], - &ib->sa_bo, size); + &ib->sa_bo, size, pool_type == AMDGPU_IB_POOL_DIRECT); if (r) { dev_err(adev->dev, "failed to get a new IB (%d)\n", r); return r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index 55172c2dcc355..95aa87b4406eb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c @@ -188,7 +188,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct drm_sched_entity *entity, void *owner, unsigned int num_ibs, struct amdgpu_job **job, - u64 drm_client_id) + u64 drm_client_id, bool need_atomic) { struct amdgpu_fence *af; int r; @@ -196,18 +196,21 @@ int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm, if (num_ibs == 0) return -EINVAL; - *job = kzalloc(struct_size(*job, ibs, num_ibs), GFP_KERNEL); + *job = kzalloc(struct_size(*job, ibs, num_ibs), + need_atomic ? GFP_ATOMIC : GFP_KERNEL); if (!*job) return -ENOMEM; - af = kzalloc(sizeof(struct amdgpu_fence), GFP_KERNEL); + af = kzalloc(sizeof(struct amdgpu_fence), + need_atomic ? GFP_ATOMIC : GFP_KERNEL); if (!af) { r = -ENOMEM; goto err_job; } (*job)->hw_fence = af; - af = kzalloc(sizeof(struct amdgpu_fence), GFP_KERNEL); + af = kzalloc(sizeof(struct amdgpu_fence), + need_atomic ? GFP_ATOMIC : GFP_KERNEL); if (!af) { r = -ENOMEM; goto err_fence; @@ -246,7 +249,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, int r; r = amdgpu_job_alloc(adev, NULL, entity, owner, 1, job, - k_job_id); + k_job_id, pool_type == AMDGPU_IB_POOL_DIRECT); if (r) return r; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h index 56a88e14a0448..9de2cae966fea 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h @@ -113,7 +113,7 @@ static inline struct amdgpu_ring *amdgpu_job_ring(struct amdgpu_job *job) int amdgpu_job_alloc(struct amdgpu_device *adev, struct amdgpu_vm *vm, struct drm_sched_entity *entity, void *owner, unsigned int num_ibs, struct amdgpu_job **job, - u64 drm_client_id); + u64 drm_client_id, bool need_atomic); int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, struct drm_sched_entity *entity, void *owner, size_t size, enum amdgpu_ib_pool_type pool_type, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index 912c9afaf9e11..8abff5fdae81d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -341,7 +341,7 @@ int amdgpu_sa_bo_manager_start(struct amdgpu_device *adev, struct amdgpu_sa_manager *sa_manager); int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager, struct drm_suballoc **sa_bo, - unsigned int size); + unsigned int size, bool need_atomic); void amdgpu_sa_bo_free(struct drm_suballoc **sa_bo, struct dma_fence *fence); #if defined(CONFIG_DEBUG_FS) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c index 39070b2a4c04f..1d44b95de7e55 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c @@ -78,10 +78,11 @@ void amdgpu_sa_bo_manager_fini(struct amdgpu_device *adev, int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager, struct drm_suballoc **sa_bo, - unsigned int size) + unsigned int size, bool need_atomic) { struct drm_suballoc *sa = drm_suballoc_new(&sa_manager->base, size, - GFP_KERNEL, false, 0); + need_atomic ? GFP_ATOMIC : GFP_KERNEL, + false, 0); if (IS_ERR(sa)) { *sa_bo = NULL; -- 2.54.0