Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp374887ybr; Fri, 22 May 2020 08:39:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcCSFcVsLWs/lB6lJpes4yBd7ImWxaHwVoWYSKo2PMIzqY5fRFRi5CR2qpH7AeaITeTNF9 X-Received: by 2002:a17:906:9493:: with SMTP id t19mr8410115ejx.407.1590161989037; Fri, 22 May 2020 08:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590161989; cv=none; d=google.com; s=arc-20160816; b=AlmQ3AbMjCyvdX87Lhph25TQpWzqD2JBenp/y3BY2RixXnlL6CizeZlaYwDkj52ELf 1vrEDb1CFq1v/PmM4Mo27NfKR2PnfzM6s0CJ9JRAHoXWp7Ie5QmFiK5ZSqaW7xzKjnFn uQvv8pVFNacmD9RpFStjfpv1Ed6ST7RGUVK8rOGX9hFbrCJq3a7DTGB9aFktfEf9apOW ZjwfIFcJxrtC6mQXCdrzhvBIMppwQ9Zi33/cjrQvibLFHPbx9vkJZ3QGXfCf/sF4q84M pEHENirDoniDCbuLtQ0ngIcLkMVJEopGHCt4KvmfwfGM4RGwB4TREyHXIaND4TC8sBoP 26fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=7BNfDJqIA7YWSCsG3qeJDZObA/aLz+rhcjYIzhNIiOY=; b=Eg2yMA+WXo3ezWnnWkfN1Px3SEL6hon8RaxGqN+0bNj0XAabArdZCdnSDqGuuU5TKb e2f1xw6ul8IcjdFYOPLD2WHNSviTiL/0RNQR4e9tIlDHDtB1/6Z68PEncUTKpItUoLyZ 5+a7qn6Qlm3IB1CGCPX4jUjZIW/AojoYF7cK771XjmjyND20hk4eBmvoi4P88dPHOw3I AjbjTx/Kpdf5o3Zk7Fj2z33eIkDu/cWIy7x1Vgw2oxiUEjAL/+yObZscHLSPlraKmB9w AMpNwuhxEBHoB8TXKGrp2Y0wLcGJSBYAIcqFYbjh48TUFTZEUeagA69zvssuriny+EcW HIdA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si4772949edf.371.2020.05.22.08.39.25; Fri, 22 May 2020 08:39:49 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730715AbgEVPhI (ORCPT + 99 others); Fri, 22 May 2020 11:37:08 -0400 Received: from foss.arm.com ([217.140.110.172]:38134 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730180AbgEVPhH (ORCPT ); Fri, 22 May 2020 11:37:07 -0400 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 3EE4F55D; Fri, 22 May 2020 08:37:06 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0046D3F305; Fri, 22 May 2020 08:37:04 -0700 (PDT) From: Steven Price To: Rob Herring , Tomeu Vizoso Cc: Daniel Vetter , David Airlie , Alyssa Rosenzweig , Steven Price , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/panfrost: Fix inbalance of devfreq record_busy/idle() Date: Fri, 22 May 2020 16:36:53 +0100 Message-Id: <20200522153653.40754-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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