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.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 0224DC2B9F4 for ; Fri, 25 Jun 2021 15:55:23 +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 C759461963 for ; Fri, 25 Jun 2021 15:55:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C759461963 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 32A726EE07; Fri, 25 Jun 2021 15:55:22 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 7053D6EE07 for ; Fri, 25 Jun 2021 15:55: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 3A6961063; Fri, 25 Jun 2021 08:55:19 -0700 (PDT) Received: from [192.168.1.179] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 043083F719; Fri, 25 Jun 2021 08:55:17 -0700 (PDT) Subject: Re: [PATCH v3 10/15] drm/panfrost: Make sure job interrupts are masked before resetting To: Boris Brezillon , dri-devel@lists.freedesktop.org References: <20210625133327.2598825-1-boris.brezillon@collabora.com> <20210625133327.2598825-11-boris.brezillon@collabora.com> From: Steven Price Message-ID: <49a60b4f-911e-2c03-29ce-4b1b9f605b3d@arm.com> Date: Fri, 25 Jun 2021 16:55:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210625133327.2598825-11-boris.brezillon@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB 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 , Rob Herring , Alyssa Rosenzweig , Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 25/06/2021 14:33, Boris Brezillon wrote: > This is not yet needed because we let active jobs be killed during by > the reset and we don't really bother making sure they can be restarted. > But once we start adding soft-stop support, controlling when we deal > with the remaining interrrupts and making sure those are handled before > the reset is issued gets tricky if we keep job interrupts active. > > Let's prepare for that and mask+flush job IRQs before issuing a reset. > > Signed-off-by: Boris Brezillon > --- > drivers/gpu/drm/panfrost/panfrost_job.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c > index 88d34fd781e8..0566e2f7e84a 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_job.c > +++ b/drivers/gpu/drm/panfrost/panfrost_job.c > @@ -34,6 +34,7 @@ struct panfrost_queue_state { > struct panfrost_job_slot { > struct panfrost_queue_state queue[NUM_JOB_SLOTS]; > spinlock_t job_lock; > + int irq; > }; > > static struct panfrost_job * > @@ -400,7 +401,15 @@ static void panfrost_reset(struct panfrost_device *pfdev, > if (bad) > drm_sched_increase_karma(bad); > > - spin_lock(&pfdev->js->job_lock); I'm not sure it's safe to remove this lock as this protects the pfdev->jobs array: I can't see what would prevent panfrost_job_close() running at the same time without the lock. Am I missing something? > + /* Mask job interrupts and synchronize to make sure we won't be > + * interrupted during our reset. > + */ > + job_write(pfdev, JOB_INT_MASK, 0); > + synchronize_irq(pfdev->js->irq); > + > + /* Schedulers are stopped and interrupts are masked+flushed, we don't > + * need to protect the 'evict unfinished jobs' lock with the job_lock. > + */ > for (i = 0; i < NUM_JOB_SLOTS; i++) { > if (pfdev->jobs[i]) { > pm_runtime_put_noidle(pfdev->dev); > @@ -408,7 +417,6 @@ static void panfrost_reset(struct panfrost_device *pfdev, > pfdev->jobs[i] = NULL; > } > } > - spin_unlock(&pfdev->js->job_lock); > > panfrost_device_reset(pfdev); > > @@ -504,6 +512,7 @@ static void panfrost_job_handle_irq(struct panfrost_device *pfdev, u32 status) > > job = pfdev->jobs[j]; > /* Only NULL if job timeout occurred */ > + WARN_ON(!job); Was this WARN_ON intentional? Steve > if (job) { > pfdev->jobs[j] = NULL; > > @@ -563,7 +572,7 @@ static void panfrost_reset_work(struct work_struct *work) > int panfrost_job_init(struct panfrost_device *pfdev) > { > struct panfrost_job_slot *js; > - int ret, j, irq; > + int ret, j; > > INIT_WORK(&pfdev->reset.work, panfrost_reset_work); > > @@ -573,11 +582,11 @@ int panfrost_job_init(struct panfrost_device *pfdev) > > spin_lock_init(&js->job_lock); > > - irq = platform_get_irq_byname(to_platform_device(pfdev->dev), "job"); > - if (irq <= 0) > + js->irq = platform_get_irq_byname(to_platform_device(pfdev->dev), "job"); > + if (js->irq <= 0) > return -ENODEV; > > - ret = devm_request_threaded_irq(pfdev->dev, irq, > + ret = devm_request_threaded_irq(pfdev->dev, js->irq, > panfrost_job_irq_handler, > panfrost_job_irq_handler_thread, > IRQF_SHARED, KBUILD_MODNAME "-job", >