Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5410566pxu; Thu, 22 Oct 2020 01:15:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn6vHOTbObiCSsAzjs1EoICs2W0Dc3RdW8TXjRBvyyKVq5zo1MrpNZxtd5DIo0DDYtMwne X-Received: by 2002:a17:906:814:: with SMTP id e20mr1205037ejd.367.1603354517880; Thu, 22 Oct 2020 01:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603354517; cv=none; d=google.com; s=arc-20160816; b=nATGf8T+hVqN6oUtiHDDpGFFuhdApie9kjJcw/4XzNmVo9VbaGjXhU/grHKhMvaru/ mXlumBhq1kVN01l4Kd8efVlcP8tLvU3tDqqFyD+FQ6TJYLlupuMptB/g2aAtp86t1vXt nxnuJsuS9E3CFtxZbpBUK8IqOnbkkbpOoZdDn36JMvhzJ1PRPEkGoOyEamgiI3e5FMar Pdr4n2pGFDJrrLL7upUh/AZ7Vf020x73JZUdElvSPOceGUjeB2mIm25ILR4EY9HpkQLW hzxmUP05wHAvD+UbhkMc9tLplshnLVyvPlFo8e9m1XiyV6SP/dWsHJiajCK5qq2bRw3V RTLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=iek+bp/Cifwd+Zwu4YwN//l+0a41t0YyScf9lE/NXh0=; b=Yuj7D+u0o+opUGjrsfWnfZ36zuyIns8bdyOZL8DqZFpB0kiMdcHIu9l8nm9pRDQ036 2pK6se+ouShJAXCJ0DM0FflRH9cpDg25AVHEcmmbJSoh5WcrP6uG9aPCDZpmTl6ECEJR fbgC4VWGAj3u0UG7LOA2c/9bADg4hsvyED4J5cOyCvtHiJrQQHDW0zrF5EK5IbN2r7Mi 10tWWNkEN7ZcprHeK/yToYC3RpMtLccglKCCju/ewhLv5oDiKZ1xKqCtnB0qNeUhGtae VBSkeUmjAkp4ON+dPwqpliPkozsLLx8dlQgxzAan5WqzDvSIaZ/OplWLYosOqG2RkKbA l/uw== 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 v14si447179eja.230.2020.10.22.01.14.55; Thu, 22 Oct 2020 01:15:17 -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 S2895325AbgJVDVi (ORCPT + 99 others); Wed, 21 Oct 2020 23:21:38 -0400 Received: from mga02.intel.com ([134.134.136.20]:7623 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443456AbgJVDVi (ORCPT ); Wed, 21 Oct 2020 23:21:38 -0400 IronPort-SDR: 9ph1gteUXu2hpeelS5YSlshI3jECgdkZENqL9h0iMtgyU7MfdVmUgHyfdh82/+0x7k+ty3E29E DBa1mR6zXIqg== X-IronPort-AV: E=McAfee;i="6000,8403,9781"; a="154418920" X-IronPort-AV: E=Sophos;i="5.77,403,1596524400"; d="scan'208";a="154418920" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2020 20:21:37 -0700 IronPort-SDR: zVq9ZMmOMBwT1s+CtuqYsuoILt9sZOJdDNBiF4scm8qMmDbyRHIhtys6CJz6iXMwHUACl+8gy+ 73Hppwtn9ExA== X-IronPort-AV: E=Sophos;i="5.77,403,1596524400"; d="scan'208";a="302212891" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Oct 2020 20:21:35 -0700 From: Chen Yu To: "Rafael J. Wysocki" , Len Brown Cc: Andy Shevchenko , Greg Kroah-Hartman , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH] PM / sysfs: Expose suspend resume driver flags in sysfs Date: Thu, 22 Oct 2020 11:23:24 +0800 Message-Id: <20201022032324.25308-1-yu.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently there are 4 driver flags to control system suspend/resume behavior: DPM_FLAG_NO_DIRECT_COMPLETE, DPM_FLAG_SMART_PREPARE, DPM_FLAG_SMART_SUSPEND and DPM_FLAG_MAY_SKIP_RESUME. Make these flags visible in sysfs as read-only to get a brief understanding of the expected behavior of each device during suspend/resume, so as to facilitate suspend/resume debugging/tuning. For example: /sys/devices/pci0000:00/0000:00:15.1/power/driver_flags:4 (DPM_FLAG_SMART_SUSPEND) /sys/devices/pci0000:00/0000:00:07.3/power/driver_flags:5 (DPM_FLAG_NO_DIRECT_COMPLETE | DPM_FLAG_SMART_SUSPEND) Acked-by: Len Brown Signed-off-by: Chen Yu --- drivers/base/power/sysfs.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index a1474fb67db9..48313a1040a5 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -607,6 +607,13 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RW(async); +static ssize_t driver_flags_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%x\n", dev->power.driver_flags); +} +static DEVICE_ATTR_RO(driver_flags); + #endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_ADVANCED_DEBUG */ @@ -691,6 +698,20 @@ static const struct attribute_group pm_qos_flags_attr_group = { .attrs = pm_qos_flags_attrs, }; +static struct attribute *pm_driver_flags_attrs[] = { +#ifdef CONFIG_PM_ADVANCED_DEBUG +#ifdef CONFIG_PM_SLEEP + &dev_attr_driver_flags.attr, +#endif +#endif + NULL, +}; + +static const struct attribute_group pm_driver_flags_attr_group = { + .name = power_group_name, + .attrs = pm_driver_flags_attrs, +}; + int dpm_sysfs_add(struct device *dev) { int rc; @@ -719,11 +740,17 @@ int dpm_sysfs_add(struct device *dev) if (rc) goto err_wakeup; } - rc = pm_wakeup_source_sysfs_add(dev); + rc = sysfs_merge_group(&dev->kobj, &pm_driver_flags_attr_group); if (rc) goto err_latency; + + rc = pm_wakeup_source_sysfs_add(dev); + if (rc) + goto err_flags; return 0; + err_flags: + sysfs_unmerge_group(&dev->kobj, &pm_driver_flags_attr_group); err_latency: sysfs_unmerge_group(&dev->kobj, &pm_qos_latency_tolerance_attr_group); err_wakeup: -- 2.17.1