From patchwork Mon Apr 15 14:54:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10900967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DF4114DB for ; Mon, 15 Apr 2019 14:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16230284CE for ; Mon, 15 Apr 2019 14:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09A85285D2; Mon, 15 Apr 2019 14:57:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACC1426253 for ; Mon, 15 Apr 2019 14:57:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727730AbfDOOzy (ORCPT ); Mon, 15 Apr 2019 10:55:54 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:32974 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727669AbfDOOzu (ORCPT ); Mon, 15 Apr 2019 10:55:50 -0400 Received: by mail-lj1-f196.google.com with SMTP id f23so15990390ljc.0; Mon, 15 Apr 2019 07:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0m53QvjknqRp3ie0vm6CpfbAyiM0FVU3b4et23ofcuA=; b=F2VUKGeQdqeNwP0nOteb8rfuOpQaIP/fnuUKyn2O6Et18CEeZZbN9q3hj9obLt7Ip7 sjTdcdMe0UNSZ/xP3SSbOG/Fr3Mb6X8VRaiVwA9ANypifyHL3reKiZmUwEtlE55sshhe uDvfyoxBm7Q1Ye991Zdu5HeyIphGUUw5xPx9B0nDTqQWpSsKl2KEQcz4pYHlMvy4yEDZ MCo8FHdDFpCK/Uomh7Ry+e+0ggO2tB0kVrOARVQVET1ZL6kDp76atbAdBpD9YbKddfF8 02CV8kmhny1lUXNrqv3kXSLB8iCKXZIiWM2eDvI4NDccXvP6QlvQNRW6pDOSNlEj2I7x bZHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0m53QvjknqRp3ie0vm6CpfbAyiM0FVU3b4et23ofcuA=; b=ER5xjhVBpn4sHS+r1qB5Yb+h7AR0CF6Ep7ULFR59rHyvNf2gHhGPwZ2yWfsUefsI9C FrcMQlrVQPyqKRcMay75VKleJn8Feupu1fUo4u3WmNx1thp1R8Lt9QPbK5vdjhLzO1kI mJLMx5/7xI8WAS7efTH9Jv2qyr4d/HYm2S8OARuVi1abMN38CJaFg5BHyK/xKes1q6I3 LuHhMvEYIpiA5tsXIefxa6jxjWasuJoIAXhuC/0XSV8vHBjmDd1m0YhcngAn2yiedwWc ATEXDMBGTHu9m4/RsXSU2VAhzxChluBTohUprNb2C0Bpb/vcQmRts8yGy1xnOXUDsraT Cwtg== X-Gm-Message-State: APjAAAVpBB9Vhx6yRnMyGuYpXRi/5qRJ8HneWv4JpWWiA1mKYp7YAiJ/ xPTnag4pReVUJqksc4Ad7uI= X-Google-Smtp-Source: APXvYqzpTGE5/TikmNNDpIoscTEm2A9ggE6XFk7D7Ol09PySJOwV+H2gq5rqP1/BbtgyOUZ3DcXWdg== X-Received: by 2002:a2e:7d19:: with SMTP id y25mr18247204ljc.126.1555340148490; Mon, 15 Apr 2019 07:55:48 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-35-107.pppoe.spdop.ru. [94.29.35.107]) by smtp.gmail.com with ESMTPSA id l12sm9989932lfc.61.2019.04.15.07.55.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Apr 2019 07:55:47 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Tomeu Vizoso Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v2 12/19] PM / devfreq: tegra: Avoid inconsistency of current frequency value Date: Mon, 15 Apr 2019 17:54:58 +0300 Message-Id: <20190415145505.18397-13-digetx@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415145505.18397-1-digetx@gmail.com> References: <20190415145505.18397-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The frequency value potentially could change in-between. It doesn't cause any real problem at all right now, but that could change in the future. Hence let's avoid the inconsistency. Signed-off-by: Dmitry Osipenko Reviewed-by: Chanwoo Choi --- drivers/devfreq/tegra-devfreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c index a668e4fbc874..f1a6f951813a 100644 --- a/drivers/devfreq/tegra-devfreq.c +++ b/drivers/devfreq/tegra-devfreq.c @@ -496,13 +496,15 @@ static int tegra_devfreq_get_dev_status(struct device *dev, { struct tegra_devfreq *tegra = dev_get_drvdata(dev); struct tegra_devfreq_device *actmon_dev; + unsigned long cur_freq; - stat->current_frequency = tegra->cur_freq * KHZ; + cur_freq = READ_ONCE(tegra->cur_freq); /* To be used by the tegra governor */ stat->private_data = tegra; /* The below are to be used by the other governors */ + stat->current_frequency = cur_freq * KHZ; actmon_dev = &tegra->devices[MCALL]; @@ -513,7 +515,7 @@ static int tegra_devfreq_get_dev_status(struct device *dev, stat->busy_time *= 100 / BUS_SATURATION_RATIO; /* Number of cycles in a sampling period */ - stat->total_time = ACTMON_SAMPLING_PERIOD * tegra->cur_freq; + stat->total_time = ACTMON_SAMPLING_PERIOD * cur_freq; stat->busy_time = min(stat->busy_time, stat->total_time);