From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: linux-media@vger.kernel.org, Rui Miguel Silva <rmfrfs@gmail.com>,
kernel@pengutronix.de, linux-imx@nxp.com,
Paul Elder <paul.elder@ideasonboard.com>,
Sakari Ailus <sakari.ailus@iki.fi>
Subject: Re: [PATCH 2/5] media: imx: imx-mipi-csis: Drop powered flag
Date: Tue, 15 Mar 2022 13:23:01 +0200 [thread overview]
Message-ID: <YjB3FX3Mdd0+cTTd@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220314103941.46021-3-jacopo@jmondi.org>
Hi Jacopo,
Thank you for the patch.
On Mon, Mar 14, 2022 at 11:39:38AM +0100, Jacopo Mondi wrote:
> The mipi_csis_device.powered flag only serves for the purpose of
> not accessing registers in mipi_csis_log_status() when the interface
> is not powered up.
>
> Instead of manually tracking the power state, rely on
> pm_runtime_get_if_in_use() to remove the 'powered' flag. Also remove
> the locking in the function as runtime_pm() is refcounted and there's no
> risk of the interface being powered down behind our backs.
>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
> drivers/media/platform/imx/imx-mipi-csis.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c
> index 60e7f0452582..b76bb129a416 100644
> --- a/drivers/media/platform/imx/imx-mipi-csis.c
> +++ b/drivers/media/platform/imx/imx-mipi-csis.c
> @@ -327,10 +327,9 @@ struct mipi_csis_device {
> u32 hs_settle;
> u32 clk_settle;
>
> - struct mutex lock; /* Protect csis_fmt, format_mbus and powered */
> + struct mutex lock; /* Protect csis_fmt and format_mbus */
> const struct csis_pix_format *csis_fmt;
> struct v4l2_mbus_framefmt format_mbus[CSIS_PADS_NUM];
> - bool powered;
>
> spinlock_t slock; /* Protect events */
> struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS];
> @@ -1174,11 +1173,11 @@ static int mipi_csis_log_status(struct v4l2_subdev *sd)
> {
> struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
>
> - mutex_lock(&csis->lock);
> mipi_csis_log_counters(csis, true);
> - if (csis->debug.enable && csis->powered)
> + if (csis->debug.enable && pm_runtime_get_if_in_use(csis->dev)) {
> mipi_csis_dump_regs(csis);
> - mutex_unlock(&csis->lock);
> + pm_runtime_put(csis->dev);
I was going to write that you could move runtime PM to
mipi_csis_dump_regs(), and then noticed patch 5/5 that does so. Is there
any reason it can't be done here already (essentially squashing this
with 5/5) ?
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> + }
>
> return 0;
> }
> @@ -1344,8 +1343,6 @@ static int __maybe_unused mipi_csis_runtime_suspend(struct device *dev)
>
> mipi_csis_clk_disable(csis);
>
> - csis->powered = false;
> -
> unlock:
> mutex_unlock(&csis->lock);
>
> @@ -1366,8 +1363,6 @@ static int __maybe_unused mipi_csis_runtime_resume(struct device *dev)
>
> mipi_csis_clk_enable(csis);
>
> - csis->powered = true;
> -
> unlock:
> mutex_unlock(&csis->lock);
>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2022-03-15 11:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 10:39 [PATCH 0/5] media: imx: imx-mipi-csis: Additional cleanups Jacopo Mondi
2022-03-14 10:39 ` [PATCH 1/5] media: imx: imx-mipi-csis: Simplify mipi_csis_s_stream() Jacopo Mondi
2022-03-15 11:19 ` Laurent Pinchart
2022-03-14 10:39 ` [PATCH 2/5] media: imx: imx-mipi-csis: Drop powered flag Jacopo Mondi
2022-03-15 11:23 ` Laurent Pinchart [this message]
2022-03-14 10:39 ` [PATCH 3/5] media: imx: imx-mipi-csis: Remove lock from s_stream Jacopo Mondi
2022-03-15 11:26 ` Laurent Pinchart
2022-03-14 10:39 ` [PATCH 4/5] media: imx: imx-mipi-csis: Remove duplicated check Jacopo Mondi
2022-03-15 11:30 ` Laurent Pinchart
2022-03-15 12:27 ` Jacopo Mondi
2022-03-15 13:03 ` Laurent Pinchart
2022-03-15 13:53 ` Rui Miguel Silva
2022-03-14 10:39 ` [PATCH 5/5] media: imx: imx-mipi-csis: Protect mipi_csis_dump_regs() Jacopo Mondi
2022-03-15 11:34 ` Laurent Pinchart
2022-03-14 12:02 ` [PATCH 0/5] media: imx: imx-mipi-csis: Additional cleanups Rui Miguel Silva
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=YjB3FX3Mdd0+cTTd@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=jacopo@jmondi.org \
--cc=kernel@pengutronix.de \
--cc=linux-imx@nxp.com \
--cc=linux-media@vger.kernel.org \
--cc=paul.elder@ideasonboard.com \
--cc=rmfrfs@gmail.com \
--cc=sakari.ailus@iki.fi \
/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