Linux-PM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] Add wakeup_source symlink and update documentation.
@ 2019-07-24 17:43 Ravi Chandra Sadineni
  2019-07-24 17:43 ` [PATCH 1/2] power: sysfs: Add link to wakeup class device Ravi Chandra Sadineni
  2019-07-24 17:43 ` [PATCH 2/2] power: sysfs: move wakeup related nodes in power dir to obselete Ravi Chandra Sadineni
  0 siblings, 2 replies; 4+ messages in thread
From: Ravi Chandra Sadineni @ 2019-07-24 17:43 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, x86, rjw, pavel, len.brown, gregkh,
	ravisadineni, bhe, dyoung, linux-kernel, linux-pm, tbroch, trong

As discussed in https://lkml.org/lkml/2019/7/23/687 this patch set
creates symlink from device node to wakeup_source virtual device. This
patch set also updates the documentation accordingly.

Ravi Chandra Sadineni (2):
  power: sysfs: Add link to wakeup class device.
  power: sysfs: move wakeup related nodes in power dir to obselete.

 Documentation/ABI/obsolete/sysfs-device-power | 93 ++++++++++++++++++
 Documentation/ABI/testing/sysfs-devices-power | 94 -------------------
 drivers/base/power/power.h                    |  2 +
 drivers/base/power/sysfs.c                    | 25 +++++
 drivers/base/power/wakeup.c                   |  2 +
 5 files changed, 122 insertions(+), 94 deletions(-)
 create mode 100644 Documentation/ABI/obsolete/sysfs-device-power

-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] power: sysfs: Add link to wakeup class device.
  2019-07-24 17:43 [PATCH 0/2] Add wakeup_source symlink and update documentation Ravi Chandra Sadineni
@ 2019-07-24 17:43 ` Ravi Chandra Sadineni
  2019-09-06 23:40   ` Matthias Kaehlcke
  2019-07-24 17:43 ` [PATCH 2/2] power: sysfs: move wakeup related nodes in power dir to obselete Ravi Chandra Sadineni
  1 sibling, 1 reply; 4+ messages in thread
From: Ravi Chandra Sadineni @ 2019-07-24 17:43 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, x86, rjw, pavel, len.brown, gregkh,
	ravisadineni, bhe, dyoung, linux-kernel, linux-pm, tbroch, trong

https://patchwork.kernel.org/patch/11045069/ creates a virtual device
under wakeup class for each wake capable device exposing all related
sysfs attributes. But there isn't a symlink from the actual device
node to these virtual devices. This patch creates a symlink from the
actual device to the corresponding wakeup_source device under wakeup
class.

Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>
---
 drivers/base/power/power.h  |  2 ++
 drivers/base/power/sysfs.c  | 25 +++++++++++++++++++++++++
 drivers/base/power/wakeup.c |  2 ++
 3 files changed, 29 insertions(+)

diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index c511def48b48..32b0f5c080a9 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -67,6 +67,8 @@ extern void dpm_sysfs_remove(struct device *dev);
 extern void rpm_sysfs_remove(struct device *dev);
 extern int wakeup_sysfs_add(struct device *dev);
 extern void wakeup_sysfs_remove(struct device *dev);
+extern void wakeup_source_sysfs_link_add(struct device *dev);
+extern void wakeup_source_sysfs_link_remove(struct device *dev);
 extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
 extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
 extern int pm_qos_sysfs_add_flags(struct device *dev);
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index d713738ce796..fbbdb7b16ac5 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -95,6 +95,7 @@
 const char power_group_name[] = "power";
 EXPORT_SYMBOL_GPL(power_group_name);
 
+static const char wakeup_source_symlink_name[] = "wakeup_source";
 static const char ctrl_auto[] = "auto";
 static const char ctrl_on[] = "on";
 
@@ -679,6 +680,30 @@ int dpm_sysfs_add(struct device *dev)
 	return rc;
 }
 
+void wakeup_source_sysfs_link_add(struct device *dev)
+{
+	struct wakeup_source *ws;
+	int err;
+
+	ws = dev->power.wakeup;
+	if (ws && ws->dev) {
+		err = sysfs_add_link_to_group(&dev->kobj, power_group_name,
+			&ws->dev->kobj, wakeup_source_symlink_name);
+		if (err) {
+			dev_err(dev,
+				"could not add %s symlink err %d\n",
+				wakeup_source_symlink_name,
+				err);
+		}
+	}
+}
+
+void wakeup_source_sysfs_link_remove(struct device *dev)
+{
+	sysfs_remove_link_from_group(&dev->kobj, power_group_name,
+		wakeup_source_symlink_name);
+}
+
 int wakeup_sysfs_add(struct device *dev)
 {
 	return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index fe779fe13a7f..87dfe401b035 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -270,6 +270,7 @@ static int device_wakeup_attach(struct device *dev, struct wakeup_source *ws)
 	if (dev->power.wakeirq)
 		device_wakeup_attach_irq(dev, dev->power.wakeirq);
 	spin_unlock_irq(&dev->power.lock);
+	wakeup_source_sysfs_link_add(dev);
 	return 0;
 }
 
@@ -391,6 +392,7 @@ static struct wakeup_source *device_wakeup_detach(struct device *dev)
 	ws = dev->power.wakeup;
 	dev->power.wakeup = NULL;
 	spin_unlock_irq(&dev->power.lock);
+	wakeup_source_sysfs_link_remove(dev);
 	return ws;
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] power: sysfs: move wakeup related nodes in power dir to obselete.
  2019-07-24 17:43 [PATCH 0/2] Add wakeup_source symlink and update documentation Ravi Chandra Sadineni
  2019-07-24 17:43 ` [PATCH 1/2] power: sysfs: Add link to wakeup class device Ravi Chandra Sadineni
@ 2019-07-24 17:43 ` Ravi Chandra Sadineni
  1 sibling, 0 replies; 4+ messages in thread
From: Ravi Chandra Sadineni @ 2019-07-24 17:43 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, x86, rjw, pavel, len.brown, gregkh,
	ravisadineni, bhe, dyoung, linux-kernel, linux-pm, tbroch, trong

As we have a new wakeup_source sub directory under power/ that
exposes all the wakeup_source related attributes, move the
documentation pointing to the existing attributes directly
under power/ directory to obselete.

Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>
---
 Documentation/ABI/obsolete/sysfs-device-power |  93 ++++++++++++++++
 Documentation/ABI/testing/sysfs-devices-power | 102 ++----------------
 2 files changed, 101 insertions(+), 94 deletions(-)
 create mode 100644 Documentation/ABI/obsolete/sysfs-device-power

diff --git a/Documentation/ABI/obsolete/sysfs-device-power b/Documentation/ABI/obsolete/sysfs-device-power
new file mode 100644
index 000000000000..fd780cdcf2c3
--- /dev/null
+++ b/Documentation/ABI/obsolete/sysfs-device-power
@@ -0,0 +1,93 @@
+What:		/sys/devices/.../power/wakeup_count
+Date:		September 2010
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_count attribute contains the number
+		of signaled wakeup events associated with the device.  This
+		attribute is read-only.  If the device is not capable to wake up
+		the system from sleep states, this attribute is not present.
+		If the device is not enabled to wake up the system from sleep
+		states, this attribute is empty.
+
+What:		/sys/devices/.../power/wakeup_active_count
+Date:		September 2010
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_active_count attribute contains the
+		number of times the processing of wakeup events associated with
+		the device was completed (at the kernel level).  This attribute
+		is read-only.  If the device is not capable to wake up the
+		system from sleep states, this attribute is not present.  If
+		the device is not enabled to wake up the system from sleep
+		states, this attribute is empty.
+
+What:		/sys/devices/.../power/wakeup_abort_count
+Date:		February 2012
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_abort_count attribute contains the
+		number of times the processing of a wakeup event associated with
+		the device might have aborted system transition into a sleep
+		state in progress.  This attribute is read-only.  If the device
+		is not capable to wake up the system from sleep states, this
+		attribute is not present.  If the device is not enabled to wake
+		up the system from sleep states, this attribute is empty.
+
+What:		/sys/devices/.../power/wakeup_expire_count
+Date:		February 2012
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_expire_count attribute contains the
+		number of times a wakeup event associated with the device has
+		been reported with a timeout that expired.  This attribute is
+		read-only.  If the device is not capable to wake up the system
+		from sleep states, this attribute is not present.  If the
+		device is not enabled to wake up the system from sleep states,
+		this attribute is empty.
+
+What:		/sys/devices/.../power/wakeup_total_time_ms
+Date:		September 2010
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_total_time_ms attribute contains
+		the total time of processing wakeup events associated with the
+		device, in milliseconds.  This attribute is read-only.  If the
+		device is not capable to wake up the system from sleep states,
+		this attribute is not present.  If the device is not enabled to
+		wake up the system from sleep states, this attribute is empty.
+
+What:		/sys/devices/.../power/wakeup_max_time_ms
+Date:		September 2010
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_max_time_ms attribute contains
+		the maximum time of processing a single wakeup event associated
+		with the device, in milliseconds.  This attribute is read-only.
+		If the device is not capable to wake up the system from sleep
+		states, this attribute is not present.  If the device is not
+		enabled to wake up the system from sleep states, this attribute
+		is empty.
+
+What:		/sys/devices/.../power/wakeup_last_time_ms
+Date:		September 2010
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_last_time_ms attribute contains
+		the value of the monotonic clock corresponding to the time of
+		signaling the last wakeup event associated with the device, in
+		milliseconds.  This attribute is read-only.  If the device is
+		not enabled to wake up the system from sleep states, this
+		attribute is not present.  If the device is not enabled to wake
+		up the system from sleep states, this attribute is empty.
+
+What:		/sys/devices/.../power/wakeup_prevent_sleep_time_ms
+Date:		February 2012
+Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
+Description:
+		The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute
+		contains the total time the device has been preventing
+		opportunistic transitions to sleep states from occurring.
+		This attribute is read-only.  If the device is not capable to
+		wake up the system from sleep states, this attribute is not
+		present.  If the device is not enabled to wake up the system
+		from sleep states, this attribute is empty.
\ No newline at end of file
diff --git a/Documentation/ABI/testing/sysfs-devices-power b/Documentation/ABI/testing/sysfs-devices-power
index 80a00f7b6667..30aff73c1dbd 100644
--- a/Documentation/ABI/testing/sysfs-devices-power
+++ b/Documentation/ABI/testing/sysfs-devices-power
@@ -77,53 +77,6 @@ Description:
 		device drivers and in that cases it should be safe to leave the
 		default value.
 
-What:		/sys/devices/.../power/wakeup_count
-Date:		September 2010
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_count attribute contains the number
-		of signaled wakeup events associated with the device.  This
-		attribute is read-only.  If the device is not capable to wake up
-		the system from sleep states, this attribute is not present.
-		If the device is not enabled to wake up the system from sleep
-		states, this attribute is empty.
-
-What:		/sys/devices/.../power/wakeup_active_count
-Date:		September 2010
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_active_count attribute contains the
-		number of times the processing of wakeup events associated with
-		the device was completed (at the kernel level).  This attribute
-		is read-only.  If the device is not capable to wake up the
-		system from sleep states, this attribute is not present.  If
-		the device is not enabled to wake up the system from sleep
-		states, this attribute is empty.
-
-What:		/sys/devices/.../power/wakeup_abort_count
-Date:		February 2012
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_abort_count attribute contains the
-		number of times the processing of a wakeup event associated with
-		the device might have aborted system transition into a sleep
-		state in progress.  This attribute is read-only.  If the device
-		is not capable to wake up the system from sleep states, this
-		attribute is not present.  If the device is not enabled to wake
-		up the system from sleep states, this attribute is empty.
-
-What:		/sys/devices/.../power/wakeup_expire_count
-Date:		February 2012
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_expire_count attribute contains the
-		number of times a wakeup event associated with the device has
-		been reported with a timeout that expired.  This attribute is
-		read-only.  If the device is not capable to wake up the system
-		from sleep states, this attribute is not present.  If the
-		device is not enabled to wake up the system from sleep states,
-		this attribute is empty.
-
 What:		/sys/devices/.../power/wakeup_active
 Date:		September 2010
 Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
@@ -136,53 +89,6 @@ Description:
 		enabled to wake up the system from sleep states, this attribute
 		is empty.
 
-What:		/sys/devices/.../power/wakeup_total_time_ms
-Date:		September 2010
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_total_time_ms attribute contains
-		the total time of processing wakeup events associated with the
-		device, in milliseconds.  This attribute is read-only.  If the
-		device is not capable to wake up the system from sleep states,
-		this attribute is not present.  If the device is not enabled to
-		wake up the system from sleep states, this attribute is empty.
-
-What:		/sys/devices/.../power/wakeup_max_time_ms
-Date:		September 2010
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_max_time_ms attribute contains
-		the maximum time of processing a single wakeup event associated
-		with the device, in milliseconds.  This attribute is read-only.
-		If the device is not capable to wake up the system from sleep
-		states, this attribute is not present.  If the device is not
-		enabled to wake up the system from sleep states, this attribute
-		is empty.
-
-What:		/sys/devices/.../power/wakeup_last_time_ms
-Date:		September 2010
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_last_time_ms attribute contains
-		the value of the monotonic clock corresponding to the time of
-		signaling the last wakeup event associated with the device, in
-		milliseconds.  This attribute is read-only.  If the device is
-		not enabled to wake up the system from sleep states, this
-		attribute is not present.  If the device is not enabled to wake
-		up the system from sleep states, this attribute is empty.
-
-What:		/sys/devices/.../power/wakeup_prevent_sleep_time_ms
-Date:		February 2012
-Contact:	Rafael J. Wysocki <rjw@rjwysocki.net>
-Description:
-		The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute
-		contains the total time the device has been preventing
-		opportunistic transitions to sleep states from occurring.
-		This attribute is read-only.  If the device is not capable to
-		wake up the system from sleep states, this attribute is not
-		present.  If the device is not enabled to wake up the system
-		from sleep states, this attribute is empty.
-
 What:		/sys/devices/.../power/autosuspend_delay_ms
 Date:		September 2010
 Contact:	Alan Stern <stern@rowland.harvard.edu>
@@ -260,3 +166,11 @@ Description:
 
 		This attribute has no effect on system-wide suspend/resume and
 		hibernation.
+
+What:		/sys/devices/.../power/wakeup_source
+Date:		July 2019
+Contact:	Ravi Chandra Sadineni <ravisadineni@chromium.org>
+Description:
+		The /sys/devices/.../power/wakeup_source directory contains
+		attributes allowing the user space to read several wakeup
+		related statistics of the device.
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] power: sysfs: Add link to wakeup class device.
  2019-07-24 17:43 ` [PATCH 1/2] power: sysfs: Add link to wakeup class device Ravi Chandra Sadineni
@ 2019-09-06 23:40   ` Matthias Kaehlcke
  0 siblings, 0 replies; 4+ messages in thread
From: Matthias Kaehlcke @ 2019-09-06 23:40 UTC (permalink / raw)
  To: Ravi Chandra Sadineni
  Cc: tglx, mingo, bp, hpa, x86, rjw, pavel, len.brown, gregkh, bhe,
	dyoung, linux-kernel, linux-pm, tbroch, trong

Hi Ravi,

On Wed, Jul 24, 2019 at 10:43:54AM -0700, Ravi Chandra Sadineni wrote:
> https://patchwork.kernel.org/patch/11045069/ creates a virtual
> device

To refer to unsubmitted patches in the commit message it is
probably better to use the subject ("PM / wakeup: show wakeup
sources stats in sysfs") and add a link after '---', or say
"${subject}" [1] and put the link at the bottom of the commit message

You might want to try again now that the patch has landed :)

> under wakeup class for each wake capable device exposing all related
> sysfs attributes. But there isn't a symlink from the actual device
> node to these virtual devices. This patch creates a symlink from the
> actual device to the corresponding wakeup_source device under wakeup
> class.

> Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>
> ---
>  drivers/base/power/power.h  |  2 ++
>  drivers/base/power/sysfs.c  | 25 +++++++++++++++++++++++++
>  drivers/base/power/wakeup.c |  2 ++
>  3 files changed, 29 insertions(+)
> 
> diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
> index c511def48b48..32b0f5c080a9 100644
> --- a/drivers/base/power/power.h
> +++ b/drivers/base/power/power.h
> @@ -67,6 +67,8 @@ extern void dpm_sysfs_remove(struct device *dev);
>  extern void rpm_sysfs_remove(struct device *dev);
>  extern int wakeup_sysfs_add(struct device *dev);
>  extern void wakeup_sysfs_remove(struct device *dev);
> +extern void wakeup_source_sysfs_link_add(struct device *dev);
> +extern void wakeup_source_sysfs_link_remove(struct device *dev);

the names seem a bit clunky, how about wakeup_sysfs_add/remove_link()?

>  extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
>  extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
>  extern int pm_qos_sysfs_add_flags(struct device *dev);
> diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
> index d713738ce796..fbbdb7b16ac5 100644
> --- a/drivers/base/power/sysfs.c
> +++ b/drivers/base/power/sysfs.c
> @@ -95,6 +95,7 @@
>  const char power_group_name[] = "power";
>  EXPORT_SYMBOL_GPL(power_group_name);
>  
> +static const char wakeup_source_symlink_name[] = "wakeup_source";
>  static const char ctrl_auto[] = "auto";
>  static const char ctrl_on[] = "on";
>  
> @@ -679,6 +680,30 @@ int dpm_sysfs_add(struct device *dev)
>  	return rc;
>  }
>  
> +void wakeup_source_sysfs_link_add(struct device *dev)
> +{
> +	struct wakeup_source *ws;
> +	int err;
> +
> +	ws = dev->power.wakeup;
> +	if (ws && ws->dev) {
> +		err = sysfs_add_link_to_group(&dev->kobj, power_group_name,
> +			&ws->dev->kobj, wakeup_source_symlink_name);
> +		if (err) {
> +			dev_err(dev,
> +				"could not add %s symlink err %d\n",

I'd suggest

				"could not add '%s' symlink: %d\n",

or

				"could not add 'wakeup_source' symlink: %d\n",

the latter is easier to grep.

> +				wakeup_source_symlink_name,
> +				err);
> +		}
> +	}
> +}
> +
> +void wakeup_source_sysfs_link_remove(struct device *dev)
> +{
> +	sysfs_remove_link_from_group(&dev->kobj, power_group_name,
> +		wakeup_source_symlink_name);
> +}
> +
>  int wakeup_sysfs_add(struct device *dev)
>  {
>  	return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index fe779fe13a7f..87dfe401b035 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -270,6 +270,7 @@ static int device_wakeup_attach(struct device *dev, struct wakeup_source *ws)
>  	if (dev->power.wakeirq)
>  		device_wakeup_attach_irq(dev, dev->power.wakeirq);
>  	spin_unlock_irq(&dev->power.lock);
> +	wakeup_source_sysfs_link_add(dev);
>  	return 0;
>  }
>  
> @@ -391,6 +392,7 @@ static struct wakeup_source *device_wakeup_detach(struct device *dev)
>  	ws = dev->power.wakeup;
>  	dev->power.wakeup = NULL;
>  	spin_unlock_irq(&dev->power.lock);
> +	wakeup_source_sysfs_link_remove(dev);

you want to do this before the wakeup source is detached.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 17:43 [PATCH 0/2] Add wakeup_source symlink and update documentation Ravi Chandra Sadineni
2019-07-24 17:43 ` [PATCH 1/2] power: sysfs: Add link to wakeup class device Ravi Chandra Sadineni
2019-09-06 23:40   ` Matthias Kaehlcke
2019-07-24 17:43 ` [PATCH 2/2] power: sysfs: move wakeup related nodes in power dir to obselete Ravi Chandra Sadineni

Linux-PM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pm/0 linux-pm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pm linux-pm/ https://lore.kernel.org/linux-pm \
		linux-pm@vger.kernel.org linux-pm@archiver.kernel.org
	public-inbox-index linux-pm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox