All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Paul Elder <paul.elder@ideasonboard.com>,
	Steve Longerbeam <slongerbeam@gmail.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	"Paul J. Murphy" <paul.j.murphy@intel.com>,
	Martina Krasteva <martinax.krasteva@intel.com>,
	Shawn Tu <shawnx.tu@intel.com>, Arec Kao <arec.kao@intel.com>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Jimmy Su <jimmy.su@intel.com>,
	Martin Kepplinger <martink@posteo.de>,
	Daniel Scally <djrscally@gmail.com>,
	Jacopo Mondi <jmondi@jmondi.org>,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	linux-media@vger.kernel.org, rafael@kernel.org,
	linux-acpi@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Wolfram Sang <wsa@kernel.org>,
	linux-i2c@vger.kernel.org, tfiga@chromium.org,
	bingbu.cao@intel.com, andriy.shevchenko@intel.com
Subject: Re: [PATCH v2] media: ov5640: Use runtime PM
Date: Thu, 14 Apr 2022 12:29:57 +0300	[thread overview]
Message-ID: <YlfplRQYDYhFvc5U@paasikivi.fi.intel.com> (raw)
In-Reply-To: <YkMDfvuhAvsrjbON@pendragon.ideasonboard.com>

Hi Laurent,

On Tue, Mar 29, 2022 at 04:02:54PM +0300, Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Mon, Mar 14, 2022 at 11:11:18PM +0200, Sakari Ailus wrote:
> > On Mon, Mar 14, 2022 at 10:05:37PM +0200, Laurent Pinchart wrote:
> > ...
> > > > > Yes, after reading the version register (or doing any other harware
> > > > > access). Actually the full code would be
> > > > > 
> > > > > 
> > > > >  	pm_runtime_enable(dev);
> > > > >  	pm_runtime_resume_and_get(dev);
> > > > > 
> > > > > 	/* Hardware access */
> > > > > 
> > > > > 	pm_runtime_set_autosuspend_delay(dev, 1000);
> > > > > 	pm_runtime_use_autosuspend(dev);
> > > > > 	pm_runtime_put_autosuspend(dev);
> > > > > 
> > > > > (plus error handling).
> > > > > 
> > > > > If the probe function doesn't need to access the hardware, then
> > > > > the above becomes
> > > > > 
> > > > > 	pm_runtime_enable(dev);
> > > > > 	pm_runtime_set_autosuspend_delay(dev, 1000);
> > > > > 	pm_runtime_use_autosuspend(dev);
> > > > > 
> > > > > instead of having to power up the device just in case !PM.
> > > > > 
> > > > > > Also the latter only works on DT-based systems so it's not an option for
> > > > > > most of the drivers.
> 
> Does the former work on ACPI systems ?

Yes (i.e. the one that was above the quoted text).

> 
> > > > > How so, what's wrong with the above for ACPI-based system ?
> > > > 
> > > > I²C devices are already powered on for probe on ACPI based systems.
> > > 
> > > Not through RPM I suppose ?
> > 
> > Runtime PM isn't involved, this takes place in the ACPI framework (via
> > dev_pm_domain_attach() called in i2c_device_probe()).
> 
> How can we fix this ? It may have made sense a long time ago, but it's
> making RPM handling way too difficult in I2C drivers now. We need
> something better instead of continuing to rely on cargo-cult for probe
> functions. Most drivers are broken.

Some could be broken, there's no question of that. A lot of drivers support
either ACPI or DT, too, so not _that_ many need to work with both. Albeit
that number is probably increasing constantly for the same devices are used
on both.

Then there are drivers that prefer not powering on the device in probe (see
<URL:https://lore.kernel.org/linux-acpi/20210210230800.30291-2-sakari.ailus@linux.intel.com/T/>),
it gets complicated to support all the combinatios of DT/ACPI (with or
without the flag / property for waiving powering device on for probe) and
CONFIG_PM enabled/disabled.

What I think could be done to add a flag for drivers that handle power on
their own, or perhaps rather change how I2C_DRV_ACPI_WAIVE_D0_PROBE flag
works. Right now it expects a property on the device but that check could
be moved to existing drivers using the flag. Not many drivers are currently
using the flag. I think this would simplify driver implementation as both
firmware interfaces would work the same way in this respect.

You'd have to change one driver at a time, and people should be encouraged
to write new drivers with that flag. Or add the flag to all existing
drivers and not accept new ones with it.

These devices I think are all I²C but my understanding is that such
differences exist elsewhere in the kernel, too. If they are to be
addressed, it would probably be best to have a unified approach towards it.

Added a few more people and lists to cc.

-- 
Kind regards,

Sakari Ailus

  reply	other threads:[~2022-04-14  9:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 11:12 [PATCH v2] media: ov5640: Use runtime PM Paul Elder
2022-03-11 12:23 ` Sakari Ailus
2022-03-11 12:30   ` Laurent Pinchart
2022-03-11 13:15     ` Sakari Ailus
2022-03-11 13:20       ` Laurent Pinchart
2022-03-11 13:32         ` Sakari Ailus
2022-03-13 13:01           ` Laurent Pinchart
2022-03-13 13:38             ` Sakari Ailus
2022-03-13 14:16               ` Laurent Pinchart
2022-03-14 20:01                 ` Sakari Ailus
2022-03-14 20:05                   ` Laurent Pinchart
2022-03-14 21:11                     ` Sakari Ailus
2022-03-29 13:02                       ` Laurent Pinchart
2022-04-14  9:29                         ` Sakari Ailus [this message]
2022-08-01  7:17                           ` Tomasz Figa
2022-08-01  7:23                             ` Tomasz Figa
2022-08-01 13:47                               ` Laurent Pinchart
2022-08-01 20:39                               ` Sakari Ailus
2022-03-18 22:28 ` Laurent Pinchart
2022-03-21 10:58   ` Sakari Ailus
2022-03-21 11:24     ` Laurent Pinchart
2022-03-22 12:05       ` Sakari Ailus

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=YlfplRQYDYhFvc5U@paasikivi.fi.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=arec.kao@intel.com \
    --cc=bingbu.cao@intel.com \
    --cc=djrscally@gmail.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jimmy.su@intel.com \
    --cc=jmondi@jmondi.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=martinax.krasteva@intel.com \
    --cc=martink@posteo.de \
    --cc=mika.westerberg@linux.intel.com \
    --cc=paul.elder@ideasonboard.com \
    --cc=paul.j.murphy@intel.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=rafael@kernel.org \
    --cc=shawnx.tu@intel.com \
    --cc=slongerbeam@gmail.com \
    --cc=tfiga@chromium.org \
    --cc=wsa@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.