From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-acpi@vger.kernel.org, linux-media@vger.kernel.org,
rafael@kernel.org, jacopo.mondi@ideasonboard.com
Subject: Re: [PATCH v2 6/7] media: imx319: Put usage_count correctly in s_ctrl callback
Date: Tue, 21 Nov 2023 08:18:24 +0000 [thread overview]
Message-ID: <ZVxn0Em-RmfZP-Pm@kekkonen.localdomain> (raw)
In-Reply-To: <20231120094503.GB6824@pendragon.ideasonboard.com>
Hi Laurent,
On Mon, Nov 20, 2023 at 11:45:03AM +0200, Laurent Pinchart wrote:
> On Mon, Nov 20, 2023 at 09:32:10AM +0000, Sakari Ailus wrote:
> > On Sat, Nov 18, 2023 at 08:52:48PM +0200, Laurent Pinchart wrote:
> > > On Fri, Nov 17, 2023 at 01:14:32PM +0200, Sakari Ailus wrote:
> > > > pm_runtime_get_if_in_use() returns an error if Runtime PM is disabled for
> > > > the device, in which case it won't increment the use count.
> > > > pm_runtime_put() does that unconditionally however. Only call
> > > > pm_runtime_put() in case pm_runtime_get_if_in_use() has returned a value >
> > > > 0.
> > >
> > > Why don't you use pm_runtime_get_if_active() ?
> >
> > It's only meaningful if the driver uses autosuspend. The imx319 driver does
> > not.
>
> Does pm_runtime_get_if_active() causes issues with the driver uses
> autosuspend ? Standardizing on a single API that covers all the use
> cases would increase consistency and make the code base easier to
> understand. Beside, the driver should switch to autosuspend :-) Using
> the correct RPM calls already is a good thing, if they don't introduce
> any issue.
Both are fine but they're there for a different purpose. The driver should
consistently use either usage_count or status based calls (for autosuspend
to make sense).
>
> > > Other than that, same comment as for patch 5/7, I don't like the
> > > increased complexity.
> > >
> > > These comments apply to 7/7 as well.
> > >
> > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > > > ---
> > > > drivers/media/i2c/imx319.c | 8 +++++---
> > > > 1 file changed, 5 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/drivers/media/i2c/imx319.c b/drivers/media/i2c/imx319.c
> > > > index 5378f607f340..e7b2d0c20d29 100644
> > > > --- a/drivers/media/i2c/imx319.c
> > > > +++ b/drivers/media/i2c/imx319.c
> > > > @@ -1880,8 +1880,8 @@ static int imx319_set_ctrl(struct v4l2_ctrl *ctrl)
> > > > struct imx319 *imx319 = container_of(ctrl->handler,
> > > > struct imx319, ctrl_handler);
> > > > struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd);
> > > > + int ret, pm_status;
> > > > s64 max;
> > > > - int ret;
> > > >
> > > > /* Propagate change of current control to all related controls */
> > > > switch (ctrl->id) {
> > > > @@ -1898,7 +1898,8 @@ static int imx319_set_ctrl(struct v4l2_ctrl *ctrl)
> > > > * Applying V4L2 control value only happens
> > > > * when power is up for streaming
> > > > */
> > > > - if (!pm_runtime_get_if_in_use(&client->dev))
> > > > + pm_status = pm_runtime_get_if_in_use(&client->dev);
> > > > + if (!pm_status)
> > > > return 0;
> > > >
> > > > switch (ctrl->id) {
> > > > @@ -1937,7 +1938,8 @@ static int imx319_set_ctrl(struct v4l2_ctrl *ctrl)
> > > > break;
> > > > }
> > > >
> > > > - pm_runtime_put(&client->dev);
> > > > + if (pm_status > 0)
> > > > + pm_runtime_put(&client->dev);
> > > >
> > > > return ret;
> > > > }
>
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2023-11-21 8:18 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-17 11:14 [PATCH v2 0/7] Small Runtime PM API changes Sakari Ailus
2023-11-17 11:14 ` [PATCH v2 1/7] pm: runtime: Simplify pm_runtime_get_if_active() usage Sakari Ailus
2023-11-18 17:46 ` Laurent Pinchart
2023-11-17 11:14 ` [PATCH v2 2/7] pm: runtime: Add pm_runtime_put_mark_busy_autosusp() helper Sakari Ailus
2023-11-18 17:49 ` Laurent Pinchart
2023-11-18 21:20 ` Rafael J. Wysocki
2023-11-18 21:30 ` Laurent Pinchart
2023-11-20 9:27 ` Sakari Ailus
2023-11-20 9:47 ` Laurent Pinchart
2023-11-21 8:41 ` Sakari Ailus
2023-11-21 8:50 ` Laurent Pinchart
2023-11-21 10:00 ` Sakari Ailus
2023-11-17 11:14 ` [PATCH v2 3/7] ACPI: Documentation: Document acpi_dev_state_d0() Sakari Ailus
2023-11-18 18:50 ` Laurent Pinchart
2023-11-20 9:31 ` Sakari Ailus
2023-11-20 12:52 ` Rafael J. Wysocki
2023-11-20 20:03 ` Sakari Ailus
2023-11-20 20:22 ` Rafael J. Wysocki
2023-11-20 20:53 ` Sakari Ailus
2023-11-17 11:14 ` [PATCH v2 4/7] media: Documentation: Improve camera sensor runtime PM documentation Sakari Ailus
2023-11-18 18:49 ` Laurent Pinchart
2023-11-17 11:14 ` [PATCH v2 5/7] media: ov8858: Use pm_runtime_get_if_active(), put usage_count correctly Sakari Ailus
2023-11-17 15:30 ` Jacopo Mondi
2023-11-18 11:12 ` Sakari Ailus
2023-11-18 17:33 ` Laurent Pinchart
2023-11-20 8:31 ` Sakari Ailus
2023-11-17 11:14 ` [PATCH v2 6/7] media: imx319: Put usage_count correctly in s_ctrl callback Sakari Ailus
2023-11-18 18:52 ` Laurent Pinchart
2023-11-20 9:32 ` Sakari Ailus
2023-11-20 9:45 ` Laurent Pinchart
2023-11-21 8:18 ` Sakari Ailus [this message]
2023-11-21 8:25 ` Laurent Pinchart
2023-11-21 8:44 ` Sakari Ailus
2023-11-17 11:14 ` [PATCH v2 7/7] media: imx219: " Sakari Ailus
2023-11-17 14:20 ` Dave Stevenson
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=ZVxn0Em-RmfZP-Pm@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=jacopo.mondi@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--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