From patchwork Thu Dec 20 14:16:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 154336 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6237927ljp; Thu, 20 Dec 2018 06:16:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/URUEbnPJUlINQy9vKg8/2V3mlV9IlG3ipKLh36Z6IH84wO3BSOwUQIlM/xJTWRcQaaR13o X-Received: by 2002:a62:4181:: with SMTP id g1mr24382223pfd.45.1545315398197; Thu, 20 Dec 2018 06:16:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545315398; cv=none; d=google.com; s=arc-20160816; b=b2Nx7OJjv4Z9gjRiemVRWI0My9/aeQ1mwcd1dsCeQF9t/tbo8JeQaPP3AF+TT6mgSz 5f8w+0ESdoV5i4uBZ9RTV3TWgc10s/mfApHFx2Tox4UiszHBx+/nQoG4mPnc2D/t+PQ8 PfFN+vMsoacZJyrlmmIdN9CtNSnHrwG5wiwTomDClbxdZupGm/osL++LeYz9CMCYbhlw UNzk9zRWQfyQ656xBa++LC6JFx+WI9vsSXvVEu7wniDSBia75qOYAZHN0cczFaCN5RcN uUQd2S1jzjpQnuzJ5Eq/08bCLje0Bg3CDu3CJVaAMx1fNHzdjUN0qlrfz9vCcIgmhBS9 SIYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:delivered-to; bh=UXgqEw400iR3KwAIXEwyYlRx1qZvb0gRoRXIA/vVb2E=; b=CgNv1vKjteALlp4rx5StaOaR9EzOAk3TZPQ99yVOXEcJVAIS9x2/UxrzFU3pnTgFZW J5IW52Xw9SrhlE+njdXDdwV3NllN7ZUOQbSxIz48tJWIIMxHHSxhd1ccNiwRsRgK2pSv iemsESaNupfwyAYwctnuDc3YTmcN6kzDgVNzubWMNxXOS30+nQlng8z3PEf4AvPZDmY8 8X2ukWpBVMOYDj67KCbLPSfnx6gpYhiZHDehxkL3n/HPzxTeXojwdgwnKq8Arye1q0E9 9DfIKunHEIKAWlDKpbs67trAUJ1Eu67vK1JegAtPyxm4GnzfS/LqLpcjY/o2ZEngYHuJ g32Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id r8si17650489plo.203.2018.12.20.06.16.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 06:16:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C77926F3C1; Thu, 20 Dec 2018 14:16:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 580D16F3C2 for ; Thu, 20 Dec 2018 14:16:33 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id q18so1924600wrx.9 for ; Thu, 20 Dec 2018 06:16:33 -0800 (PST) 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=8H/YiHauv71s0EVIedV1buJib0rVCedGsQtekdc1nA8=; b=IwtI++xTUhdF6HSC/tp+MtEpMZkm8xrJotZtjIjvI+ZRv2t4fvUH47Yzgv8KIy3EE2 gCr/ZtwbLdAsnLyBahYxqhDIyMmtBHGc7byrmT6gdOx8UpL6mVYRQ/AtBB83R9vjsTQV oYaBB/ImJryHyEBmAeClWkJaORz2o7vZZwkDmY294JzT4XJEsqZEi4htTTzq3s6Qy+Db m/O25HTiXYpnnBxZgdgUdaiN8Zqoxxw4bU9jmkukYSgOdltOPqy8/XPpDD+wrwH3FIqO R6i1uh/VBTfZqySscKh+r0AgK5d8UttFSFdJ4q7FLGZWGn7ZF9HGAPfZJCGWuvEibyf/ mDaQ== X-Gm-Message-State: AA+aEWYbyxVGbcjGh+m1I5B5562iBNB1GZmNJFcw7/K+O9iD4tsspx0F SZ9bYBIFhVoH2rKSoi/mJrxCjA== X-Received: by 2002:adf:db01:: with SMTP id s1mr22055723wri.214.1545315391844; Thu, 20 Dec 2018 06:16:31 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:f9b3:37c1:b11a:64ce]) by smtp.gmail.com with ESMTPSA id 127sm2313218wmm.45.2018.12.20.06.16.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 06:16:30 -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 Subject: [PATCH v4 1/3] PM/runtime: Add a new interface to get accounted time Date: Thu, 20 Dec 2018 15:16:23 +0100 Message-Id: <1545315385-14384-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545315385-14384-1-git-send-email-vincent.guittot@linaro.org> References: <1545315385-14384-1-git-send-email-vincent.guittot@linaro.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, Vincent Guittot MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. 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; }