Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3102852ybc; Mon, 18 Nov 2019 09:32:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxP7JG0JaLfx1s67JICXK1HaL+bFPN6CW2rskjM2HvUpUNXTlxYnCN+f6BhKDBFFLnCRCnO X-Received: by 2002:a2e:898d:: with SMTP id c13mr486087lji.54.1574098344033; Mon, 18 Nov 2019 09:32:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574098344; cv=none; d=google.com; s=arc-20160816; b=cU1UaqNtChRoYawM+fVOJMhT2QKhrZJPOd0DjyonsPkkWpkSrB8j7UB9b6Gv4FzFUY /7Rrzsx2hrn7oo6/kYSg65AD/XLSHUBjrjk6CszdltablOKy8Pki6LiEuzsYF14TmkA8 ZDOAtBNmtSjI6Oawc8cxYP5pKPU5Ne+UnIsOoe5PoMkpiRp9CRBzMhbbew2k6WkURyaL 49IUJUjT+0MfVTzzPGmE5krgewASaNSLMqYWAEdfk69kCZKnndhZsOWbjxcEAK0U0Tcl phvi+aK3HmBwHzb9xB1g6w3Jz6++s+pt0CcV2kAispWSG6UUhQSxA9DNBk5cIHLh5rmB d/cg== 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=w5Wq2cBZuY38RYXNdOqs192kn+O9TOArGIgO752hK9I=; b=nvHCUXvNYreGB1jy62tGU4fpKWmwM5PPQ5Y+tYBszDawRysv7XoroYr9Sg4WU4O/KU DLy+QUUWPfcsGgkPb8MH9ZLhr+6HX4NTep9hjO5yklN/SHtyGwoNi1OpYAyeNKelqFm0 SG0n3NkC3EH2nfEhLDgwCB+CcREFOcEKt7Qt/KfPMfdFR73adseicXXZJYULX7o9Iy+c 8RCsMFjGQQ8+CGQ9+g8/Q8U3ObVWPwVQEyPjsw2LajgqSvjI0kgYG1kUVDcNdS5OTVQn kkdUldRi0+R4omvS5RLWpFRY3RXTDXtDZglG2i3SCNV6Fcv4w/crMWUK2rqAHeUvhLvY oyfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h61si9510522edd.188.2019.11.18.09.31.59; Mon, 18 Nov 2019 09:32:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbfKRRaQ (ORCPT + 99 others); Mon, 18 Nov 2019 12:30:16 -0500 Received: from foss.arm.com ([217.140.110.172]:37536 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbfKRRaP (ORCPT ); Mon, 18 Nov 2019 12:30:15 -0500 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 E56321FB; Mon, 18 Nov 2019 09:30:14 -0800 (PST) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A35263F703; Mon, 18 Nov 2019 09:30:13 -0800 (PST) From: Steven Price To: Daniel Vetter , David Airlie , Rob Herring , Tomeu Vizoso Cc: Alyssa Rosenzweig , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Steven Price Subject: [PATCH] drm/panfrost: devfreq: Round frequencies to OPPs Date: Mon, 18 Nov 2019 17:30:02 +0000 Message-Id: <20191118173002.32015-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 Currently when setting a frequency in panfrost_devfreq_target the returned frequency is the actual frequency that the clock driver reports (the return of clk_get_rate()). However, where the provided OPPs don't precisely match the frequencies that the clock actually achieves devfreq will then complain (repeatedly): devfreq devfreq0: Couldn't update frequency transition information. To avoid this change panfrost_devfreq_target() to fetch the opp using devfreq_recommened_opp() and not actually query the clock for the frequency. A similar problem exists with panfrost_devfreq_get_cur_freq(), but in this case because the function is optional we can just remove it and devfreq will fall back to using the previously set frequency. Fixes: 221bc77914cb ("drm/panfrost: Use generic code for devfreq") Signed-off-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 4c4e8a30a1ac..536ba93b0f46 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -18,15 +18,18 @@ static void panfrost_devfreq_update_utilization(struct panfrost_device *pfdev); static int panfrost_devfreq_target(struct device *dev, unsigned long *freq, u32 flags) { - struct panfrost_device *pfdev = dev_get_drvdata(dev); + struct dev_pm_opp *opp; int err; + opp = devfreq_recommended_opp(dev, freq, flags); + if (IS_ERR(opp)) + return PTR_ERR(opp); + dev_pm_opp_put(opp); + err = dev_pm_opp_set_rate(dev, *freq); if (err) return err; - *freq = clk_get_rate(pfdev->clock); - return 0; } @@ -60,20 +63,10 @@ static int panfrost_devfreq_get_dev_status(struct device *dev, return 0; } -static int panfrost_devfreq_get_cur_freq(struct device *dev, unsigned long *freq) -{ - struct panfrost_device *pfdev = platform_get_drvdata(to_platform_device(dev)); - - *freq = clk_get_rate(pfdev->clock); - - return 0; -} - static struct devfreq_dev_profile panfrost_devfreq_profile = { .polling_ms = 50, /* ~3 frames */ .target = panfrost_devfreq_target, .get_dev_status = panfrost_devfreq_get_dev_status, - .get_cur_freq = panfrost_devfreq_get_cur_freq, }; int panfrost_devfreq_init(struct panfrost_device *pfdev) -- 2.20.1