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 A260FC83F27 for ; Wed, 16 Jul 2025 08:33:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E002710E6FE; Wed, 16 Jul 2025 08:33:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="pOVZ2p64"; dkim-atps=neutral Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by gabe.freedesktop.org (Postfix) with ESMTPS id 958C910E6FE for ; Wed, 16 Jul 2025 08:33:15 +0000 (UTC) Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4bhq7r29xzz9scY; Wed, 16 Jul 2025 10:33:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1752654792; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KjQJhG1pKpWS9IoU9EXIgMhnaY9UGlpALaosr4b14Gc=; b=pOVZ2p64nQCP0KVZPerSJNDSDQOVYEvBrz8ULKJksNh0/zgTUeSz+vyZyj6a+0n0YmQAzl ufYgwhSREM004jyUrUisP2QHvJXCFlSeQ2LCizUNkcOEvGUlb/9p0+mqymG+JBMEUsr2fJ S7EccryDV9SbOEQtvn0EKdsidtzpsvK4VLLASSLCyNS2R4uK1lfOOkqJTQd90WNqscqQan ITaMCh2AKYimBX918tlACo7Ailni6V6DsPzpdpXDv/n44r9Dze4VORBhxRAeiQBNr0lbuV RWozMHHAM6ftNIkdkFVX8KfsQ+nvMAg7DioCbE11us8mIN5bR9WkPzoQiboD1Q== Message-ID: Subject: Re: [PATCH] drm/sched: Remove optimization that causes hang when killing dependent jobs From: Philipp Stanner To: "Lin.Cao" , dri-devel@lists.freedesktop.org Cc: zhenguo.yin@amd.com, Emily.Deng@amd.com, Christian =?ISO-8859-1?Q?K=F6nig?= , phasta@kernel.org, dakr@kernel.org, matthew.brost@intel.com Date: Wed, 16 Jul 2025 10:33:08 +0200 In-Reply-To: <20250715135033.706126-1-lincao12@amd.com> References: <20250715135033.706126-1-lincao12@amd.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MBO-RS-META: zwn1k6tu1zni66mee7kc3w4u43wdikzx X-MBO-RS-ID: 1b72ff3abc724d82ca1 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: , Reply-To: phasta@kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, 2025-07-15 at 21:50 +0800, Lin.Cao wrote: > When application A submits jobs and application B submits a job with > a > dependency on A's fence, the normal flow wakes up the scheduler after > processing each job. However, the optimization in > drm_sched_entity_add_dependency_cb() uses a callback that only clears > dependencies without waking up the scheduler. >=20 > When application A is killed before its jobs can run, the callback > gets > triggered but only clears the dependency without waking up the > scheduler, > causing the scheduler to enter sleep state and application B to hang. >=20 > Remove the optimization by deleting drm_sched_entity_clear_dep() and > its > usage, ensuring the scheduler is always woken up when dependencies > are > cleared. >=20 > Signed-off-by: Lin.Cao This is, still, a bug fix, so it needs Fixes: and Cc: stable :) Could also include a Suggested-by: Christian P. > --- > =C2=A0drivers/gpu/drm/scheduler/sched_entity.c | 21 ++------------------- > =C2=A01 file changed, 2 insertions(+), 19 deletions(-) >=20 > diff --git a/drivers/gpu/drm/scheduler/sched_entity.c > b/drivers/gpu/drm/scheduler/sched_entity.c > index e671aa241720..ac678de7fe5e 100644 > --- a/drivers/gpu/drm/scheduler/sched_entity.c > +++ b/drivers/gpu/drm/scheduler/sched_entity.c > @@ -355,17 +355,6 @@ void drm_sched_entity_destroy(struct > drm_sched_entity *entity) > =C2=A0} > =C2=A0EXPORT_SYMBOL(drm_sched_entity_destroy); > =C2=A0 > -/* drm_sched_entity_clear_dep - callback to clear the entities > dependency */ > -static void drm_sched_entity_clear_dep(struct dma_fence *f, > - =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct dma_fence_cb *cb) > -{ > - struct drm_sched_entity *entity =3D > - container_of(cb, struct drm_sched_entity, cb); > - > - entity->dependency =3D NULL; > - dma_fence_put(f); > -} > - > =C2=A0/* > =C2=A0 * drm_sched_entity_wakeup - callback to clear the entity's > dependency and > =C2=A0 * wake up the scheduler > @@ -376,7 +365,8 @@ static void drm_sched_entity_wakeup(struct > dma_fence *f, > =C2=A0 struct drm_sched_entity *entity =3D > =C2=A0 container_of(cb, struct drm_sched_entity, cb); > =C2=A0 > - drm_sched_entity_clear_dep(f, cb); > + entity->dependency =3D NULL; > + dma_fence_put(f); > =C2=A0 drm_sched_wakeup(entity->rq->sched); > =C2=A0} > =C2=A0 > @@ -429,13 +419,6 @@ static bool > drm_sched_entity_add_dependency_cb(struct drm_sched_entity *entity) > =C2=A0 fence =3D dma_fence_get(&s_fence->scheduled); > =C2=A0 dma_fence_put(entity->dependency); > =C2=A0 entity->dependency =3D fence; > - if (!dma_fence_add_callback(fence, &entity->cb, > - =C2=A0=C2=A0=C2=A0 > drm_sched_entity_clear_dep)) > - return true; > - > - /* Ignore it when it is already scheduled */ > - dma_fence_put(fence); > - return false; > =C2=A0 } > =C2=A0 > =C2=A0 if (!dma_fence_add_callback(entity->dependency, &entity->cb,