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: 154389 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp750491ljp; Fri, 21 Dec 2018 02:34:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN5zsUOV3WN0aX7Qqa00T3LLt2l/GzRadMhuXTc9AZ9x0QQLspztoTZvKAM0jtMe0jlP5F1G X-Received: by 2002:a63:165e:: with SMTP id 30mr1853875pgw.103.1545388452174; Fri, 21 Dec 2018 02:34:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545388452; cv=none; d=google.com; s=arc-20160816; b=hIooRb/JeKP8gUVPY7xTJWwQG9U0zWuwX+nBrA3/5hxfho7qXJD4TRVZFXU/XRu/9G JmOFLgS4nviWJxNmzg6hMuoBJMLudNqPp4XhhG+0Gi2/IKnx3ei2qrPk4CFL0FVQ6lkp O+Ub4jd3GaP1P1w0mopHSMm395xS43ap14tBlyNWa2aIaSEPCL10eN2I0oC2IX69l5CW NibMLplkzEyiakUXZsFCMpyPnIWyg9oNNPG2tcUOgIRNXomiCRfwKfGFH8RPduHtjlaG E+TKkHIiiU6XOkb9VyuK7k1bdpzHhPNloLJROZXaDoI7z/liTKtzhnYJle2u+JT6j2mY YatQ== 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=fVWT1vaYNXVIV9YpC1BnhoRlKzNZ7hugduVFCmYnFxw=; b=upZspEn2fChriXc8xbVXQauk4QY7dkwwSErIBIR+r75kguxurp8xTr+U1L6JVAUN5W HTGSx8oeGRKQTmVk6xKDx6+Tk8qSOZwz9hvWFgFTGHkM+CULF5pFz7Pjvy7e+KuzlsqC jvMEkt9WwqX59p/V5ZlgqSTHCofFdvxLpnz2pKPHE6BAkaeIldURhRr/J/AYYf5J2mBv aUS6BIUk/xYVrZTnSeh54W9zfee8wJq7cPXz9sHlIrlTsxw+LNkYx0Lv+aBWFfew/A2C X36sfBYWp6iO1LyMl7kT/Hl09fQZVBXUxXoKFHlb1GnVJIDsAatX2iMQAKHrEUydi68/ uRTA== 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 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id y10si19461844pgp.348.2018.12.21.02.34.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Dec 2018 02:34:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 262CC6F5BE; Fri, 21 Dec 2018 10:34:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id C8FBD6E01C for ; Fri, 21 Dec 2018 10:34:05 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id q18so4688915wrx.9 for ; Fri, 21 Dec 2018 02:34:05 -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=Ep7ki1gNWA79DVfUoUUmYu7v+nAqJfeGtUHFVJPz20Y=; b=I5rkOZq5G5QiEMyCjqfhTp40znBGPweYJK6AuIIf8JC9U7M00gJFUMvoCxKqQPdQbz Vl5Ls8zMnQoXwXJIKw46kfJKFH1CAt3iNO1x8u76PysZ4Hj0z3DQ+XEC97mGfaRhYMe0 4CH5TDffQFkNYPVDggOKjs7GtATDEhyko9Jbq3mfXLAJzmm5T+vQKxurqU+VJJvZJkct yuuT+W3QVeyc7Vw0FFzySZYL+jGz1YzO6TMbiBVbpZvEhib6YAOSX9zc9QkE5d1kMojC z3bD1vkNdCe5msDG45TPmMUVZ7EsBHXPtKsXaNjiZArAOEUt+5KrCZsLUZ0Miz1f02X8 Rl8w== X-Gm-Message-State: AJcUukdrp3p52vxvXVXhVFOoCoa7lbegWiYspRP6pm5V5zCMjbaZquIT MVymVIX07cYCp6B/oioK7d2q9cNAlALMNw== 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 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> 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. 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; }