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 X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8F26C2B9F4 for ; Mon, 28 Jun 2021 11:18:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9E71761879 for ; Mon, 28 Jun 2021 11:18:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E71761879 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 556B76E433; Mon, 28 Jun 2021 11:18:18 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id D61B26E431 for ; Mon, 28 Jun 2021 11:18:16 +0000 (UTC) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 699321F4241C; Mon, 28 Jun 2021 12:18:15 +0100 (BST) Date: Mon, 28 Jun 2021 13:18:11 +0200 From: Boris Brezillon To: Lucas Stach Subject: Re: [PATCH] drm/sched: Declare entity idle only after HW submission Message-ID: <20210628131811.792d4cad@collabora.com> In-Reply-To: References: <20210624140850.2229697-1-boris.brezillon@collabora.com> Organization: Collabora X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: , Cc: Tomeu Vizoso , dri-devel@lists.freedesktop.org, Steven Price , Rob Herring , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, 28 Jun 2021 11:46:08 +0200 Lucas Stach wrote: > Am Donnerstag, dem 24.06.2021 um 16:08 +0200 schrieb Boris Brezillon: > > The panfrost driver tries to kill in-flight jobs on FD close after > > destroying the FD scheduler entities. For this to work properly, we > > need to make sure the jobs popped from the scheduler entities have > > been queued at the HW level before declaring the entity idle, otherwise > > we might iterate over a list that doesn't contain those jobs. > > > > Suggested-by: Lucas Stach > > Signed-off-by: Boris Brezillon > > Cc: Lucas Stach > > Not sure how much it's worth to review my own suggestion, but the > implementation looks correct to me. > I don't see any downsides for the existing drivers and it solves the > race window for drivers that want to cancel jobs on the HW submission > queue, without introducing yet another synchronization point. > > Reviewed-by: Lucas Stach Queued to drm-misc-next. Thanks, Boris > > > --- > > drivers/gpu/drm/scheduler/sched_main.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c > > index 81496ae2602e..aa776ebe326a 100644 > > --- a/drivers/gpu/drm/scheduler/sched_main.c > > +++ b/drivers/gpu/drm/scheduler/sched_main.c > > @@ -811,10 +811,10 @@ static int drm_sched_main(void *param) > > > > sched_job = drm_sched_entity_pop_job(entity); > > > > - complete(&entity->entity_idle); > > - > > - if (!sched_job) > > + if (!sched_job) { > > + complete(&entity->entity_idle); > > continue; > > + } > > > > s_fence = sched_job->s_fence; > > > > @@ -823,6 +823,7 @@ static int drm_sched_main(void *param) > > > > trace_drm_run_job(sched_job, entity); > > fence = sched->ops->run_job(sched_job); > > + complete(&entity->entity_idle); > > drm_sched_fence_scheduled(s_fence); > > > > if (!IS_ERR_OR_NULL(fence)) { > >