From patchwork Fri Dec 21 10:33:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10740305 X-Patchwork-Delegate: rjw@sisk.pl 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 4228814E2 for ; Fri, 21 Dec 2018 10:34:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 324D22855E for ; Fri, 21 Dec 2018 10:34:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26045285E3; Fri, 21 Dec 2018 10:34:26 +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,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 C4FB22855E for ; Fri, 21 Dec 2018 10:34:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387625AbeLUKeY (ORCPT ); Fri, 21 Dec 2018 05:34:24 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:35366 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389754AbeLUKeG (ORCPT ); Fri, 21 Dec 2018 05:34:06 -0500 Received: by mail-wr1-f67.google.com with SMTP id 96so4712869wrb.2 for ; Fri, 21 Dec 2018 02:34:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ep7ki1gNWA79DVfUoUUmYu7v+nAqJfeGtUHFVJPz20Y=; b=GAu74PYLxL+6Wick3OFJyKDb6jXq0x9p1nEHjZ89VkLqLt/h4NnaIKBpLkulbyVGl3 p+9hX8vOzUoAi5UV70k4Hl46Mv7aoAPMJHLb0HehV0gUAJ+qqTJPFIeTv9HLWUmIRv63 3ZR+8RewAJEgcwFWwDaKD+xh66Bkbyl8jC7v4= 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; bh=Ep7ki1gNWA79DVfUoUUmYu7v+nAqJfeGtUHFVJPz20Y=; b=HPDPH7bDZBdwl9khAjAJ//QhdBP4udPs4MlEdtDuIKJP41NbpzjHeWQ2d5bhIz67wH dDpRHpnZvyXzPf3DDIN/tICJS8wBAjxnEQPx3JF4Yf6D75eak5OLo5kmsBW3SSxAFxjR gAT8/S0sCs0vN/Uyiw5bd0ReNiyBsyTF/plKfQY2u+xHqf8db/pvi6fTbyoPAe/0NLl1 lPj6LPSE7TsAxRfAMlakT8RHXTQM1CxZ3Mqj8/RnGyPlInStshnd0i7ZQgXT3WVs84Go 8xyUzQxV2+Vy2bex/YVJOZI7Xp2uXTNnwKG7V6h49GDhaE+7nOsiIVIhNlfqIjvqljjK T5sw== X-Gm-Message-State: AJcUukdk3Br6nKQt+RSPQqAnI34gsO4go9xYr79gH2zXr9Uf5uXxoLR2 0q6zjiJHCBx154z0QAmKQ+sFoKgh/mzubw== X-Google-Smtp-Source: ALg8bN4wjkJW3YmjRm7yuLqlqUPIK2Y/fHiGy1wakXSLaRrbSjXoVQZEO/6eTCscAFtVLPpsgClsmg== X-Received: by 2002:a5d:528e:: with SMTP id c14mr1974240wrv.236.1545388444380; Fri, 21 Dec 2018 02:34:04 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:ac05:2372:f02d:b03f]) by smtp.gmail.com with ESMTPSA id h10sm10573685wmf.44.2018.12.21.02.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Dec 2018 02:34:03 -0800 (PST) From: Vincent Guittot To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, thara.gopinath@linaro.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: ulf.hansson@linaro.org, Vincent Guittot Subject: [PATCH v5 1/3] PM/runtime: Add a new interface to get accounted time Date: Fri, 21 Dec 2018 11:33:54 +0100 Message-Id: <1545388436-7489-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> References: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> 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 Some drivers (like i915/drm) needs to get the accounted suspended time. pm_runtime_suspended_time() will return the suspended accounted time in ns unit. Reviewed-by: Ulf Hansson Signed-off-by: Vincent Guittot --- drivers/base/power/runtime.c | 16 ++++++++++++++++ include/linux/pm_runtime.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index beb85c3..e695544 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -86,6 +86,22 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status) dev->power.runtime_status = status; } +u64 pm_runtime_suspended_time(struct device *dev) +{ + unsigned long flags, time; + + spin_lock_irqsave(&dev->power.lock, flags); + + update_pm_runtime_accounting(dev); + + time = dev->power.suspended_jiffies; + + spin_unlock_irqrestore(&dev->power.lock, flags); + + return jiffies_to_nsecs(time); +} +EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); + /** * pm_runtime_deactivate_timer - Deactivate given device's suspend timer. * @dev: Device to handle. diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index f0fc470..d479707 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -113,6 +113,8 @@ static inline bool pm_runtime_is_irq_safe(struct device *dev) return dev->power.irq_safe; } +extern u64 pm_runtime_suspended_time(struct device *dev); + #else /* !CONFIG_PM */ static inline bool queue_pm_work(struct work_struct *work) { return false; }