Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp447897ybr; Fri, 22 May 2020 10:19:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgy4tmADhT/dy6K5z3qnhkELYizq9yV6d0YzbBuCjrYL0Ok6XqmZzD1GBW3tR/nksx37Ju X-Received: by 2002:a17:907:40f3:: with SMTP id no3mr9267764ejb.336.1590167986673; Fri, 22 May 2020 10:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590167986; cv=none; d=google.com; s=arc-20160816; b=b1Pf0z21FoJDg8n0Qa413/wKt8+gM9qE9sFt1B1yAX1mlnC8BES8t+XS7xbF2OFAMX WK+YoK3rNUYnuXmAGGlxmYLjF2uf16mZPJpJQLukGk2JV63qkKV/aVerA4lpjUsl/MUG QgkS5ruXG4UKIa7xEO+yXdRdUZquP+JJIoZPdqieDDM1ogcM+JfK12owoGi1vkuVvRIM nUABMrshTX6ZjDM2J2e9bZixRnlHk+NloMYLM7Ef3zqc5GY9AjR89yGX0q6HAL7P7Do9 q4QBnNfMKETwKwVaYppDWOWBX7XKMxPsnf++qLPDWGUDc6vgcHua5I6glht7UDwgCviC qmLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=p+REXFiU6o9N0f8ZW/9/jXMoVgbQNcW77WNHD4G8Amg=; b=nLZuuwKrOKv047a5Pr/G0gY3vmO2zAb0JJgUXnczRr1/qSnuLDydHpTlSLuM9oroar vafY7H2x0l5K0ly2P3nE9ziqpPEjkgVvbL/nXZVsWQjILUTdHrkIrtmFfme7ER/keXHp dRc/ocTny74s8eKvPiOjaImjstgZVdYCRYIoIDXwbN9+0sRqcRjKgGDxqgpp6UFHR4g9 IpfNX4kJLgPVsuhVGqwAlTBp3vT+mSK+CxQwueq+zXyF3C3/R1zEW7ICxUoQkIfeY+HX FoX3DYV80poacwF3z4RAHNVG2uVmc/URz9vHXNWx4Y/vWjAPLQRoJ2uFpYil/H0d2Qia QtqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si4903306ede.53.2020.05.22.10.19.18; Fri, 22 May 2020 10:19:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730803AbgEVRN2 (ORCPT + 99 others); Fri, 22 May 2020 13:13:28 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:50660 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730536AbgEVRN2 (ORCPT ); Fri, 22 May 2020 13:13:28 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: alyssa) with ESMTPSA id 42B4F2A3A73 Date: Fri, 22 May 2020 13:13:19 -0400 From: Alyssa Rosenzweig To: Steven Price Cc: Rob Herring , Tomeu Vizoso , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/panfrost: Fix inbalance of devfreq record_busy/idle() Message-ID: <20200522171319.GA1836@kevin> References: <20200522153653.40754-1-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200522153653.40754-1-steven.price@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A-b On Fri, May 22, 2020 at 04:36:53PM +0100, Steven Price wrote: > The calls to panfrost_devfreq_record_busy() and > panfrost_devfreq_record_idle() must be balanced to ensure that the > devfreq utilisation is correctly reported. But there are two cases where > this doesn't work correctly. > > In panfrost_job_hw_submit() if pm_runtime_get_sync() fails or the > WARN_ON() fires then no call to panfrost_devfreq_record_busy() is made, > but when the job times out the corresponding _record_idle() call is > still made in panfrost_job_timedout(). Move the call up to ensure that > it always happens. > > Secondly panfrost_job_timedout() only makes a single call to > panfrost_devfreq_record_idle() even if it is cleaning up multiple jobs. > Move the call inside the loop to ensure that the number of > _record_idle() calls matches the number of _record_busy() calls. > > Fixes: 9e62b885f715 ("drm/panfrost: Simplify devfreq utilisation tracking") > Signed-off-by: Steven Price > --- > drivers/gpu/drm/panfrost/panfrost_job.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c > index b2f09c038d35..ac87ef675e8a 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_job.c > +++ b/drivers/gpu/drm/panfrost/panfrost_job.c > @@ -145,6 +145,8 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) > u64 jc_head = job->jc; > int ret; > > + panfrost_devfreq_record_busy(pfdev); > + > ret = pm_runtime_get_sync(pfdev->dev); > if (ret < 0) > return; > @@ -155,7 +157,6 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) > } > > cfg = panfrost_mmu_as_get(pfdev, &job->file_priv->mmu); > - panfrost_devfreq_record_busy(pfdev); > > job_write(pfdev, JS_HEAD_NEXT_LO(js), jc_head & 0xFFFFFFFF); > job_write(pfdev, JS_HEAD_NEXT_HI(js), jc_head >> 32); > @@ -410,12 +411,12 @@ static void panfrost_job_timedout(struct drm_sched_job *sched_job) > for (i = 0; i < NUM_JOB_SLOTS; i++) { > if (pfdev->jobs[i]) { > pm_runtime_put_noidle(pfdev->dev); > + panfrost_devfreq_record_idle(pfdev); > pfdev->jobs[i] = NULL; > } > } > spin_unlock_irqrestore(&pfdev->js->job_lock, flags); > > - panfrost_devfreq_record_idle(pfdev); > panfrost_device_reset(pfdev); > > for (i = 0; i < NUM_JOB_SLOTS; i++) > -- > 2.20.1 >