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=-11.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 A83FFC4727C for ; Thu, 1 Oct 2020 15:07:24 +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 5BDD3207F7 for ; Thu, 1 Oct 2020 15:07:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BDD3207F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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 D4B276E21B; Thu, 1 Oct 2020 15:07:22 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C9216E218 for ; Thu, 1 Oct 2020 15:07:20 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 09EFCD6E; Thu, 1 Oct 2020 08:07:20 -0700 (PDT) Received: from [192.168.1.79] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B6DD53F70D; Thu, 1 Oct 2020 08:07:18 -0700 (PDT) Subject: Re: [PATCH] drm/sched: Avoid infinite waits in the drm_sched_entity_destroy() path To: Boris Brezillon , dri-devel@lists.freedesktop.org References: <20201001141253.1066836-1-boris.brezillon@collabora.com> From: Steven Price Message-ID: Date: Thu, 1 Oct 2020 16:07:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201001141253.1066836-1-boris.brezillon@collabora.com> Content-Language: en-GB 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: Rob Herring , Robin Murphy , Alyssa Rosenzweig Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 01/10/2020 15:12, Boris Brezillon wrote: > If we don't initialize the entity to idle and the entity is never > scheduled before being destroyed we end up with an infinite wait in the > destroy path. > > Signed-off-by: Boris Brezillon This seems reasonable to me - it looks like in theory if you very quickly open, submit a job and close you could trigger this (i.e. if drm_sched_main() never actually enters the while loop). You should CC some other folk as this doesn't just affect Panfrost. Reviewed-by: Steven Price > --- > This is something I noticed while debugging another issue on panfrost > causing the scheduler to be in a weird state where new entities were no > longer scheduled. This was causing all userspace threads trying to close > their DRM fd to be blocked in kernel space waiting for this "entity is > idle" event. I don't know if that fix is legitimate (now that we fixed > the other bug we don't seem to end up in that state anymore), but I > thought I'd share it anyway. > --- > drivers/gpu/drm/scheduler/sched_entity.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c > index 146380118962..f8ec277a6aa8 100644 > --- a/drivers/gpu/drm/scheduler/sched_entity.c > +++ b/drivers/gpu/drm/scheduler/sched_entity.c > @@ -73,6 +73,9 @@ int drm_sched_entity_init(struct drm_sched_entity *entity, > > init_completion(&entity->entity_idle); > > + /* We start in an idle state. */ > + complete(&entity->entity_idle); > + > spin_lock_init(&entity->rq_lock); > spsc_queue_init(&entity->job_queue); > > _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel