public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Mårten Lindahl" <marten.lindahl@axis.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@ucw.cz>, Lars-Peter Clausen <lars@metafoo.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-pm@vger.kernel.org>, <linux-iio@vger.kernel.org>,
	<kernel@axis.com>
Subject: Re: [PATCH 0/2] Synchronize PM runtime enable state with parent
Date: Sun, 16 Oct 2022 17:41:41 +0100	[thread overview]
Message-ID: <20221016174141.0abc281d@jic23-huawei> (raw)
In-Reply-To: <20220929144618.1086985-1-marten.lindahl@axis.com>

On Thu, 29 Sep 2022 16:46:16 +0200
Mårten Lindahl <marten.lindahl@axis.com> wrote:

> Hi!
> 
> A device that creates a child character device with cdev_device_add by
> default creates a PM sysfs group with power attributes for userspace
> control. This means that the power attributes monitors the child device
> only and thus does not reflect the parent device PM runtime behavior.
> 
> But as the PM runtime framework (rpm_suspend/rpm_resume) operates not
> only on a single device that has been enabled for runtime PM, but also
> on its parent, it should be possible to synchronize the child and the
> parent so that the power attribute monitoring reflects the child and
> the parent as one.
> 
> As an example, if an i2c_client device registers an iio_device, the
> iio_device will create sysfs power/attribute nodes for userspace
> control. But if the dev_pm_ops with resume/suspend callbacks is
> attached to the struct i2c_driver.driver.pm, the PM runtime needs to be
> enabled for the i2c_client device and not for the child iio_device.
> 
> In this case PM runtime can be enabled for the i2c_client device and
> suspend/resume callbacks will be triggered, but the child sysfs power
> attributes will be visible but marked as 'unsupported' and can not be
> used for control or monitoring. This can be confusing as the sysfs
> device node presents the i2c_client and the iio_device as one device.
> 
> A solution to this is to enable runtime PM not only for the i2c_device
> but for the iio_device child also. As there already exists a link from
> the child to its parent and both are enabled, all sysfs
> control/monitoring now reflects both devices, which from a userspace
> perspective makes more sense.
> 
> These patches [1] adds a function to the PM runtime framework to
> synchronize the PM runtime enable state of a device with its parent,
> and [2] applies it to an iio device, where the described issue exists.

Hi Mårten,

This seems sensible to me. With hindsight we should have probably
disabled the pm interface for IIO devices. It's a fun question on 
whether we could do so now without 'breaking' some user.  Obviously
the users wouldn't work today, for the reasons you point out, but
that doesn't mean some program isn't relying on the files being there.

Anyhow, I'm looking forward to input from others on this.

Jonathan


 
> 
> Kind regards
> Mårten Lindahl
> 
> Mårten Lindahl (2):
>   PM: runtime: Synchronize PM runtime enable state with parent
>   iio: light: vcnl4000: Incorporate iio_device with PM runtime
> 
>  drivers/base/power/runtime.c | 18 ++++++++++++++++++
>  drivers/iio/light/vcnl4000.c |  1 +
>  include/linux/pm_runtime.h   |  2 ++
>  3 files changed, 21 insertions(+)
> 


      parent reply	other threads:[~2022-10-16 16:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 14:46 [PATCH 0/2] Synchronize PM runtime enable state with parent Mårten Lindahl
2022-09-29 14:46 ` [PATCH 1/2] PM: runtime: " Mårten Lindahl
2022-10-25 16:20   ` Rafael J. Wysocki
2022-10-31 16:48     ` Marten Lindahl
2022-11-06 15:33       ` Jonathan Cameron
2022-11-06 17:16         ` Rafael J. Wysocki
2022-11-12 15:33           ` Jonathan Cameron
2022-11-28 22:50             ` Marten Lindahl
2022-09-29 14:46 ` [PATCH 2/2] iio: light: vcnl4000: Incorporate iio_device with PM runtime Mårten Lindahl
2022-10-16 16:41 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221016174141.0abc281d@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@axis.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=marten.lindahl@axis.com \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox