From patchwork Tue Mar 5 12:55:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159643 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4937684jad; Tue, 5 Mar 2019 04:55:39 -0800 (PST) X-Received: by 2002:ac2:52b6:: with SMTP id r22mr749798lfm.123.1551790539590; Tue, 05 Mar 2019 04:55:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551790539; cv=none; d=google.com; s=arc-20160816; b=TkdBQ7F+qt62kX9JQeP1yJjT5sfuySr7aMzMCI24+tiZ+LfcdE74ujUUGTnz98lyGw 8l6EbM2ArHmo5FmV3iqrjqxcJQoeDnrCJyZNOguINUKwmc0dKu0S9vS7VA+R2s9qNC67 b1DWIKUi4ImPDxPZg1vV6wlZ1+aeEA7F8+Z+kCh4zTRcMGLaJRyZxtlTuCiFxRMIJTQn RlkDZbrqq14KZyWWOAP3e6zpezSGsB4GN2ZU3vXwUyP1iL2SA15iGr2YU5aLI+awvB6j KCBWanvFtKdhgpNNFlHA28XsblQXDq3ICrWFNofQnPEFFPxLI9nEkwd0gUzLlbNtdX6x rtvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=lqBcCIf/d3yMHBCDc7uCjcM4/5sbo4a5Rm1FkoZ24m8=; b=nogYchS9Bl+jCukJXt8RgkmRmYLZzo6IJwHvRkMRmeO2P+12dRpAhbG7dwdSidHLBe 1RD04rz9YbPUVkjCxeNA9Ln+ZXASorxI1rD5S3Gd32rCoGqLuBSXk1wpa67lxRV3AFjX CzdClJuqTNDIAVRBPL2N2psgMbAE3eYX9ZSAQ4HwCCHNuiI3ZdR1O3WclKFRpJDHMT58 tmxt45/31Z4xBUvSSPBrX/KmCKMurXyUBD2a9J4IyUdrt+MPz7eW2m3sv5kGhTmAFqV1 s41FJmf2v6CigCE8ZuS47RNqVQ7GdfTEehFdtKfLUrK4Ok+mrXuL1aLjGWppohr5RX/B 8M3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p2DNdgdH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b16sor4782014lji.16.2019.03.05.04.55.39 for (Google Transport Security); Tue, 05 Mar 2019 04:55:39 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p2DNdgdH; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lqBcCIf/d3yMHBCDc7uCjcM4/5sbo4a5Rm1FkoZ24m8=; b=p2DNdgdH9eMxR2E++Lrar2GThCfCbYHvgcFwiJwd+ePO7f+tA7lQ96cnNnbNAqNnWP Pju+2X728td6pviAx3KqA9zUpXvon2i/iSdFEftfLYwVIKF0PXfZLtV1zclijEhJRzWJ nNyzfXRksVQdaI5OlYlNkdRbNCjYUIKy5r1iRSpGtxLrslZNZt1jk+3xP4kaoxgegHfb TcIH9krvOimL4kBuuwt6RLgM91wq1teTbgHh4H3IrE0pE5I/NVUnfx3KiQ2tRA3SHJtB XO5SlA+faA3NCuU70vpDtyzpzkE/L+5bY9yG3/PgFL+nfa8siydPRSPswY/klOtI0xyM 43sw== 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; bh=lqBcCIf/d3yMHBCDc7uCjcM4/5sbo4a5Rm1FkoZ24m8=; b=KSDAxLZTxCETeYFdcNhIFqXIv+iZbK313ESYa6I821pwWO2aRg61KJgpGtsWVivwKK kcs2ImuWpusBpcBhJx21J201OaZO7fo07a+AV4mgvLakbcdfEPN28OV+0xr1tT41CMMm Uybn9/GM1Tsvcbs37Iadvytzn9UTaIbx9GCMQoGmWsQia6ayDpwIGem3rdvCwC1NL1Hf ZCieNrJpIgNS8lG49AuABJw/42IiOQgK5ySUNCzSzMkYm/3zQGL7GSSIo+j4FWfjowG4 gLF9HmZcY8psVWRFHRGlzO3Q1fLo8Jrk7dWc6rjrSQW2+TDFhBVtU4l+iQAQvgGSSQlV LZmQ== X-Gm-Message-State: APjAAAVyy2IfQqIBI5fn9jYyHCF+982ky+KB4ijxvDAh5tbC3dspdfmm b26SS2MSt23lHse0UJnpLPLrpV+Y X-Google-Smtp-Source: APXvYqxTdspo6Pc6tE+bHBjMOehdXVbcah5poJiNRYfhzjPV7k6ExH/yenBBeF30aHV7t6Jul5Jlag== X-Received: by 2002:a2e:2285:: with SMTP id i127mr13833745lji.40.1551790539141; Tue, 05 Mar 2019 04:55:39 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m1sm443898lfh.36.2019.03.05.04.55.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 04:55:38 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] PM / Runtime: Use pm_runtime_active|suspended_time() from sysfs Date: Tue, 5 Mar 2019 13:55:35 +0100 Message-Id: <20190305125535.21412-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Let's avoid the open-coding in runtime_active|suspend_time_show() and convert to use pm_runtime_active|suspended_time() instead. Note that, this change also indirectly avoid us from keeping the dev->power.lock held, while doing the do_div() and the sprintf() operations, which is yet another improvement. Signed-off-by: Ulf Hansson --- drivers/base/power/runtime.c | 2 +- drivers/base/power/sysfs.c | 12 ++---------- include/linux/pm.h | 1 - 3 files changed, 3 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index d1908fc422cc..17136da0bb6a 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -64,7 +64,7 @@ static int rpm_suspend(struct device *dev, int rpmflags); * runtime_status field is updated, to account the time in the old state * correctly. */ -void update_pm_runtime_accounting(struct device *dev) +static void update_pm_runtime_accounting(struct device *dev) { u64 now, last, delta; diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index c6bf76124184..1226e441ddfe 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -125,13 +125,9 @@ static ssize_t runtime_active_time_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; - u64 tmp; - spin_lock_irq(&dev->power.lock); - update_pm_runtime_accounting(dev); - tmp = dev->power.active_time; + u64 tmp = pm_runtime_active_time(dev); do_div(tmp, NSEC_PER_MSEC); ret = sprintf(buf, "%llu\n", tmp); - spin_unlock_irq(&dev->power.lock); return ret; } @@ -141,13 +137,9 @@ static ssize_t runtime_suspended_time_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; - u64 tmp; - spin_lock_irq(&dev->power.lock); - update_pm_runtime_accounting(dev); - tmp = dev->power.suspended_time; + u64 tmp = pm_runtime_suspended_time(dev); do_div(tmp, NSEC_PER_MSEC); ret = sprintf(buf, "%llu\n", tmp); - spin_unlock_irq(&dev->power.lock); return ret; } diff --git a/include/linux/pm.h b/include/linux/pm.h index 06f7ed893928..66c19a65a514 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -643,7 +643,6 @@ struct dev_pm_info { struct dev_pm_qos *qos; }; -extern void update_pm_runtime_accounting(struct device *dev); extern int dev_pm_get_subsys_data(struct device *dev); extern void dev_pm_put_subsys_data(struct device *dev);