Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2370356ybg; Fri, 5 Jun 2020 12:07:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3yB0RRNEd+XJwJ1F3SU9G3df35XfiTAtrC80ldfiNAmBVkxrJlc1ytVWblMJW4iG1zDqa X-Received: by 2002:a05:6402:545:: with SMTP id i5mr8571614edx.179.1591384073593; Fri, 05 Jun 2020 12:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591384073; cv=none; d=google.com; s=arc-20160816; b=eiGJPhs8uR3u+m4JznQUJcGYlZrKIGgFUcjVwHhSg/5NuR/gf+kwpa/CWAcdcl31Jk GOwxxGUsH9PzCiU0WrJOKU3cfEZ8XsLhaFUVVlc53Y9olV8QCDONpGeOPU57AI/f+1rU 76mXVohb1dCJ9rfDNt7Wyq5YA+MnXqQPJmC3KLUX1nEtM/sx2tYVlfLAeWy4UMgaOYkP 3+VN38zl3r8DWLlUBMsf7fzjsXUFBVBP9fuockykKExSj0XXM7nyQWwYKY3jHWVDol14 I5Wn8l8Q3kAYfkjFRD1FsQ3zwic8tk/8NHnX3pjyTYaZPPvFXR+r/JGCaBA1TsbtzOAo dJYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=2Asw9sU+FXdSNMFd/cLoEV1TTVbD9Qr7eFiufiqd5os=; b=L7r89AVRnm6O6S8LghYMJLWWfytPWdA7/RrWkllsERDu2+9vko+U3uftLdtvpX82yM fHBOTZUDu+hsOkF9m8HHhnbSvbq3BNz13AJi90D16M7yEAAVQIbPcYd6yNNk6/U2m+kN 3THMobrDlrCfr8e4RQAYlJ6Z0mLfxK9up1KnHYHr5AhPWm/ACh0vLPygCeLE5XvscabL jgxDwJQoYGKi4RRUMHZFnc2gCM6mOlchtPsoo382PNZjDicnz4kVltv79hpZ6h+lVQF/ KY5DM7Ffukjnle7NYUEyrYUMrdZ5UfgVRs5JaKGw6+CzP0xsdvQ8+9zP6KxC+LEwmk0x qhfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si4026297eds.13.2020.06.05.12.07.18; Fri, 05 Jun 2020 12:07:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgFETEn (ORCPT + 99 others); Fri, 5 Jun 2020 15:04:43 -0400 Received: from mga14.intel.com ([192.55.52.115]:50454 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbgFETEn (ORCPT ); Fri, 5 Jun 2020 15:04:43 -0400 IronPort-SDR: rW0HTZkXGRYl8exAr0dUK3tEB/4l2MlUOulMr5CukNjXqwiYYiKZj4KdwxWulJn0HZ6kz8ZKsF yaySxo52vHIw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2020 12:04:42 -0700 IronPort-SDR: 6Pojt9FdQK/7USSH4893YJsD4mrDRG9mxHalIS169phCJ11TB/RczLClFRQRPT37qrF/8sgCpw UE82yFR831lQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,477,1583222400"; d="scan'208";a="417372180" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by orsmga004.jf.intel.com with ESMTP; 05 Jun 2020 12:04:40 -0700 From: Chen Yu To: "Rafael J . Wysocki" , Len Brown , Greg Kroah-Hartman , Michal Miroslaw Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH 1/2][RFC] PM-runtime: Move all runtime usage related function to runtime.c Date: Sat, 6 Jun 2020 03:05:35 +0800 Message-Id: <3e7c571eb9e444c6e326d5cbb1f6e2dce4bb52fe.1591380524.git.yu.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to track all the runtime usage count change, move the code related to runtime usage count change from pm_runtime.h to runtime.c, so that in runtime.c we can leverage trace event to do the tracking. Meanwhile export pm_runtime_get_noresume() and pm_runtime_put_noidle() so the module can use them. No functional change. Signed-off-by: Chen Yu --- drivers/base/power/runtime.c | 12 ++++++++++++ include/linux/pm_runtime.h | 14 ++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 9f62790f644c..85a248e196ca 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1738,6 +1738,18 @@ void pm_runtime_drop_link(struct device *dev) spin_unlock_irq(&dev->power.lock); } +void pm_runtime_get_noresume(struct device *dev) +{ + atomic_inc(&dev->power.usage_count); +} +EXPORT_SYMBOL_GPL(pm_runtime_get_noresume); + +void pm_runtime_put_noidle(struct device *dev) +{ + atomic_add_unless(&dev->power.usage_count, -1, 0); +} +EXPORT_SYMBOL_GPL(pm_runtime_put_noidle); + static bool pm_runtime_need_not_resume(struct device *dev) { return atomic_read(&dev->power.usage_count) <= 1 && diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index 3dbc207bff53..57afdb122d8a 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -59,6 +59,8 @@ extern void pm_runtime_get_suppliers(struct device *dev); extern void pm_runtime_put_suppliers(struct device *dev); extern void pm_runtime_new_link(struct device *dev); extern void pm_runtime_drop_link(struct device *dev); +extern void pm_runtime_get_noresume(struct device *dev); +extern void pm_runtime_put_noidle(struct device *dev); static inline int pm_runtime_get_if_in_use(struct device *dev) { @@ -70,16 +72,6 @@ static inline void pm_suspend_ignore_children(struct device *dev, bool enable) dev->power.ignore_children = enable; } -static inline void pm_runtime_get_noresume(struct device *dev) -{ - atomic_inc(&dev->power.usage_count); -} - -static inline void pm_runtime_put_noidle(struct device *dev) -{ - atomic_add_unless(&dev->power.usage_count, -1, 0); -} - static inline bool pm_runtime_suspended(struct device *dev) { return dev->power.runtime_status == RPM_SUSPENDED @@ -188,6 +180,8 @@ static inline void pm_runtime_get_suppliers(struct device *dev) {} static inline void pm_runtime_put_suppliers(struct device *dev) {} static inline void pm_runtime_new_link(struct device *dev) {} static inline void pm_runtime_drop_link(struct device *dev) {} +static inline void pm_runtime_get_noresume(struct device *dev) {} +static inline void pm_runtime_put_noidle(struct device *dev) {} #endif /* !CONFIG_PM */ -- 2.20.1