Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6630388yba; Wed, 1 May 2019 16:44:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwE7N3i1gF5xDaWrKL5F691TK2gpucHpK8KbPporjmOebcuY+Wks2DNr31GOPnB7Qem/7Nf X-Received: by 2002:a17:902:7d91:: with SMTP id a17mr382731plm.338.1556754259872; Wed, 01 May 2019 16:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556754259; cv=none; d=google.com; s=arc-20160816; b=sqJo5Z7M+PciHiqOUsTpfBsyHlXmKVlSnCp2Gq2tbaDZtUU/9cSsNR/k+ymrUj9VlL 3edwC7gFZs40i/y7gwKZP88Bab6+QU2bA+CDb8H+psxWcjt3IkxqSpvTISgrWOftp7nn qidr57bAsHDNAjIZdQjkz99fsNZrGFE5QqpDYdYRvNZyiI1N7DTTH0KhAbds+vvzJ0xD BU/zl1Y0j3c4dWaOco/6n7a7IlNzSwnCJ023vL/V2abggeuSl/lSbXqmIr2cTsnS/sXh KEheMPR1HwW9BM0Duu7/W+Lipv4damOsO74RHP0yb9zLzmztk7VSYdIvk6u1zi/ubmTy kDdw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VRrBRm+Zojzq1Xs8C9ndqMr3g130PwILxKvLl3EyBq0=; b=z8LiX5k7jQ0V9ySiHJscz/P9rZqNvw4t98Z7L1OqAMKL2SbsIDSfRd60QTHud1eG8Q qdW/8bVuelWAwkR/s/m4nhN/xHKKEgyX+0JnUsN5HBpNAvJNTBIIM0z2ijdBN2ZOaCte N2GWdJEJiIx3qzDgjmuVnDVxX26URjKmDuFFQd0rbRHxfLYGTwKeQeRUHJ6rdhF1dU02 P1g+bfrgniOMsWiPyKUG7Y24nPNyKcPfmmVd8HaayNrqtlaERSygUGpRQw6qGLvq0SEA n4C4GDSpfzAYpyVXPCvC4gI7EhTHwVRRCmGxqEgwktlW2RjDlnM2zvbNAYwbT5WHumGE m+Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PtzVkK4b; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e184si45282283pfe.118.2019.05.01.16.44.04; Wed, 01 May 2019 16:44:19 -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=@gmail.com header.s=20161025 header.b=PtzVkK4b; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbfEAXmw (ORCPT + 99 others); Wed, 1 May 2019 19:42:52 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:50822 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbfEAXmE (ORCPT ); Wed, 1 May 2019 19:42:04 -0400 Received: by mail-it1-f194.google.com with SMTP id q14so363161itk.0; Wed, 01 May 2019 16:42:03 -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=VRrBRm+Zojzq1Xs8C9ndqMr3g130PwILxKvLl3EyBq0=; b=PtzVkK4bXPQLQ1KxKJjRnLy9Jzk62yNT6LaV9ugG04rl3m8c+4SNYWw9jxCrfy+emv 6my1oaDPLEa4TqHkOv2ZgjI3dmlITKvT1dLQWcQ9qRxMs1I/UE5nI2aoI6ewOJwP2Rfj +FwRD7zjxU42dbvBHT4woq3VNXUvY48thJEhQvEJAvGDbjWTnRrL/cxOxU+CEdclEChl Ma5ohYxpAWZBdxeAaghiBmf63SLg445soW+ouBmIwwJ6Je3VA0IutwKvoZNvecRSnHbf rwGRkcpJ2Dkl8j6gIVSpfF8ccaavqMErUDpDqumpd9SinYUHLt3JlKai2a78VVyhtOiL uB+Q== 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=VRrBRm+Zojzq1Xs8C9ndqMr3g130PwILxKvLl3EyBq0=; b=BLLiCQ6DV1ZxP4u5bkfc7hpiTppX7VYkWWgTA3aTklGhPgqW1YHA8IIYYppbm884RR kWQSihLKL1fbH0pAak5kh+dSb/ggdSyxW6vIttnrPBxXvbUQc30idbAcVSkq4eaHdR8I QK2A1IVHy/XvSKbuvu8R/fZ4SP7mWd8Z0VLFkFL+kyx7XB1q8u3ti6Wsp7wqgkMpiYUT RFDv5UWG4qVzzk5ne4RRluKZkQQpHJr/RZl/GL91oe6fhTh5fILlQ7Mvc+xVJcGa9kub PxBIPqv2M3j7atXqfYbM35009jxAS3yO0eaBOnxYYdZ1lzkN6+vl7VfIfRZrksZK7/aT e2yw== X-Gm-Message-State: APjAAAXJ3RrUbWhTst+bfdP9RPSWM2+CWlJEIUYAm1YPIpfFVsTnDqd6 gU0TiesIZHo0jOvzOS4Grn0= X-Received: by 2002:a05:6638:209:: with SMTP id e9mr363429jaq.22.1556754123190; Wed, 01 May 2019 16:42:03 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-35-107.pppoe.spdop.ru. [94.29.35.107]) by smtp.gmail.com with ESMTPSA id m3sm2392507ion.69.2019.05.01.16.42.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 May 2019 16:42:02 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Tomeu Vizoso Cc: linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 09/16] PM / devfreq: tegra: Avoid inconsistency of current frequency value Date: Thu, 2 May 2019 02:38:08 +0300 Message-Id: <20190501233815.32643-10-digetx@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190501233815.32643-1-digetx@gmail.com> References: <20190501233815.32643-1-digetx@gmail.com> 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 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. Reviewed-by: Chanwoo Choi Signed-off-by: Dmitry Osipenko --- 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 ea0da05cd7f2..5265d735419f 100644 --- a/drivers/devfreq/tegra-devfreq.c +++ b/drivers/devfreq/tegra-devfreq.c @@ -509,13 +509,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]; @@ -526,7 +528,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); -- 2.21.0