Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2083937ybp; Thu, 10 Oct 2019 01:54:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLlafZflN9eNigfbauOm9YLyjEPOFc08aI2IRcqs5QS5toPX4vOd95iHLMsY0vmRCo+BQp X-Received: by 2002:a50:da0f:: with SMTP id z15mr7027713edj.137.1570697682266; Thu, 10 Oct 2019 01:54:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697682; cv=none; d=google.com; s=arc-20160816; b=cIHPAMFpOi1kFd15TQ8MLIGSJjzfMzYwR5H9KNg+yMAxiX1QY2bVTDEU3Mm6lrH8lr N45cXgYuKX+nd67Pzb3lt/0RRCnJZFoQroVYEAgLmAqoQnax3KqR4A0hJAQGPQzSaUPd 7gJYFOHARqHEVqj+k+HiigejfTY+cGWdxe8Jt/O/1/4zKAH7/xtnF8HrpA3aNnKv5rQ4 SuJ5+X3N7908YNFoPG/QQ8W6t56hbR+9bNfwXRD/zBbdfR+vf6ITxpFC4hizDlpYtZr0 w8VEoIj+g/ZWDuHc57LNIhobYo8KWOmpUjXHjfHf+vz1vHph2uTh18IA2lSQcyJmNEWs MQYg== 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=r1dMe4Y+9fEb3qzgXgye6QLj4a69p7XDY/zMXyQU3SY=; b=oEN1MJPnVSdjN8xKuvcDt5WdCU2q0DAxW0u33XifzrgnQnDsD7NmCjP4C38z3hVEut nWHDRIiVBnMoRRclJficE7v6U1SWlbQN+BKagpQzpI11S1EeozWRSmpkb4JG05PXta8i KCeVqeUp7Nau2Ir8ftA6qs8C5mto/vn8LEQmX1I94RzfpqVMP4iEb5fxgLA6S8XhEtpg RGrdCEiK6ZKya8TQVDmlfxYcmwkzURGF8Nl3brE4uSUXIUIO4QRbVq42hJkyoKCtvuSZ mqCU18b9a26mNFgQqL0+98Aeb2Oo16u7ojH3SOzZZpv7DTFs1AuURwHvqq/CNcqHnx4h anVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pet0gr8F; 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 o49si3061673edc.261.2019.10.10.01.54.19; Thu, 10 Oct 2019 01:54:42 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Pet0gr8F; 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 S2390004AbfJJIyO (ORCPT + 99 others); Thu, 10 Oct 2019 04:54:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:57860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389549AbfJJIul (ORCPT ); Thu, 10 Oct 2019 04:50:41 -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 B1C5F20B7C; Thu, 10 Oct 2019 08:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697441; bh=atpRPWQ8qwYkROn+LNS/DUOg/9/j3Q0ATKT7b689G24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pet0gr8Fb3Dwdem/X9CYTMdZczRY54NaMKRu3x8GF5p751vnL7Z/Su3GrSWuW3lRW U1ZJ4+E7+KppFVhOU0yQAZvptaUsQGABudeY96E4FzORPBcDeYI9FIyQh7XQBHSjL9 1qNTx55LSzagnCdP4Zt27Mr57CofVwa0cgMxuTag= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steev Klimaszewski , Chanwoo Choi , Dmitry Osipenko , Thierry Reding , MyungJoo Ham Subject: [PATCH 4.14 08/61] PM / devfreq: tegra: Fix kHz to Hz conversion Date: Thu, 10 Oct 2019 10:36:33 +0200 Message-Id: <20191010083454.260004216@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083449.500442342@linuxfoundation.org> References: <20191010083449.500442342@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: Dmitry Osipenko commit 62bacb06b9f08965c4ef10e17875450490c948c0 upstream. The kHz to Hz is incorrectly converted in a few places in the code, this results in a wrong frequency being calculated because devfreq core uses OPP frequencies that are given in Hz to clamp the rate, while tegra-devfreq gives to the core value in kHz and then it also expects to receive value in kHz from the core. In a result memory freq is always set to a value which is close to ULONG_MAX because of the bug. Hence the EMC frequency is always capped to the maximum and the driver doesn't do anything useful. This patch was tested on Tegra30 and Tegra124 SoC's, EMC frequency scaling works properly now. Cc: # 4.14+ Tested-by: Steev Klimaszewski Reviewed-by: Chanwoo Choi Signed-off-by: Dmitry Osipenko Acked-by: Thierry Reding Signed-off-by: MyungJoo Ham Signed-off-by: Greg Kroah-Hartman --- drivers/devfreq/tegra-devfreq.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/drivers/devfreq/tegra-devfreq.c +++ b/drivers/devfreq/tegra-devfreq.c @@ -485,11 +485,11 @@ static int tegra_devfreq_target(struct d { struct tegra_devfreq *tegra = dev_get_drvdata(dev); struct dev_pm_opp *opp; - unsigned long rate = *freq * KHZ; + unsigned long rate; - opp = devfreq_recommended_opp(dev, &rate, flags); + opp = devfreq_recommended_opp(dev, freq, flags); if (IS_ERR(opp)) { - dev_err(dev, "Failed to find opp for %lu KHz\n", *freq); + dev_err(dev, "Failed to find opp for %lu Hz\n", *freq); return PTR_ERR(opp); } rate = dev_pm_opp_get_freq(opp); @@ -498,8 +498,6 @@ static int tegra_devfreq_target(struct d clk_set_min_rate(tegra->emc_clock, rate); clk_set_rate(tegra->emc_clock, 0); - *freq = rate; - return 0; } @@ -509,7 +507,7 @@ static int tegra_devfreq_get_dev_status( struct tegra_devfreq *tegra = dev_get_drvdata(dev); struct tegra_devfreq_device *actmon_dev; - stat->current_frequency = tegra->cur_freq; + stat->current_frequency = tegra->cur_freq * KHZ; /* To be used by the tegra governor */ stat->private_data = tegra; @@ -564,7 +562,7 @@ static int tegra_governor_get_target(str target_freq = max(target_freq, dev->target_freq); } - *freq = target_freq; + *freq = target_freq * KHZ; return 0; }