Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2663434pxa; Mon, 17 Aug 2020 15:55:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV1F4uNXow9WHma+9keodlYS/EPEqm0X08gmDJy8ZkBZwH80ZhVi/B4FtTM5xcDfl1CzcG X-Received: by 2002:aa7:c688:: with SMTP id n8mr17390318edq.345.1597704936631; Mon, 17 Aug 2020 15:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704936; cv=none; d=google.com; s=arc-20160816; b=XOZLosHBxxRV32rooCiN4kmW1OnKyMBX49FR104ntDzcTX08MQm6wKp2U00YtwTJkJ qYTOtWLw5GQEzNBLb41VhloMz8TQQoJasi2oW1iVES4umzRFi3VJN0L3/UKEUkGh+w4s rotWvZsWk3cTopc3k2jPM2w6ea5e5arip8jMvM1Bsi6nP86bjm7B9VkeMlfdq5zVQ+68 C0DKXVumRSwWn+mJK5tSfnBFM09teLKfTpjNFXFY/7KksU8roO4tUo83AY1MPVQTY3Sw 86n98dl+9hC4TvY/VaPqmJdyQ47ikMOMj+5intKYEeT68GJzXzNonW6638bw9uPyhPOA jYBw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7bNKcm7Z3u0qAnLE76RRwWnPjj13fFOi/0mSnWuraf4=; b=ZKl6u7LIsk9oKJGt7YMom33gkBkfKNFr8NZ44rrvHVIIg/KSYZUO1T4kjxLnDPoRuy mDyJDZ21vznXqXWuVmNuPpKWwSf/mC7TU1/50CaBzaXfl7CCFKgCK2iilCscaNshhzlP f87P4MV8BFFbGDqufK3dEsvSXIXM+QpSulpegynVHkbjA6p2lkmt0uH/xFXaznnEhoVA c4TOT4mcILsMIUT/TvucDlx4K+ExvCJyhYt5h5JzmfzssG2WTjVq01cPrZ/vI3AxhiM/ XsKxzh6WHVp1xL22F6NaVoL7Z4RFtJ4VbjiT/+trJKWeMvpYTPfXCyAu+ywPDz0zT7eN nSYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nHqV4QwZ; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt15si11846465ejb.319.2020.08.17.15.55.13; Mon, 17 Aug 2020 15:55:36 -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; dkim=pass header.i=@kernel.org header.s=default header.b=nHqV4QwZ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388365AbgHQTki (ORCPT + 99 others); Mon, 17 Aug 2020 15:40:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:60516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729599AbgHQPZj (ORCPT ); Mon, 17 Aug 2020 11:25:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64A6822DBF; Mon, 17 Aug 2020 15:25:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597677939; bh=F5BqKmNXCxfnTxyVjEeUfxaFpUE6H7uybZG57KnE4KI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nHqV4QwZjEdw5xoCg45wmkUWaOn+bHGxHOHKGUJWU1I4qHh03crJWJTqRB+iar4NT eA6KwED2+2r7Q5aMtUHxgDaFSOX1+DKHvp12F3nFLJwWyqbE+nKJXWk3Q0XrdHHYOW weVqawx6ealgpqfh63uS+Tn1UDw+KDD3l+28xLjU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alyssa Rosenzweig , Steven Price , Sasha Levin Subject: [PATCH 5.8 163/464] drm/panfrost: Fix inbalance of devfreq record_busy/idle() Date: Mon, 17 Aug 2020 17:11:56 +0200 Message-Id: <20200817143841.619947582@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Price [ Upstream commit b99773ef258e628bd53cab22d450a755b73b4d55 ] 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") Acked-by: Alyssa Rosenzweig Signed-off-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20200522153653.40754-1-steven.price@arm.com Signed-off-by: Sasha Levin --- 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 7914b15708412..f9519afca29d9 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.25.1