From: Biju Das <biju.das.jz@bp.renesas.com>
To: Cosmin-Gabriel Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>,
William Breathitt Gray <wbg@kernel.org>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Cosmin-Gabriel Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Subject: RE: [PATCH v3 04/14] counter: rz-mtu3-cnt: read enable value from cache
Date: Tue, 17 Nov 2026 14:05:37 +0000 [thread overview]
Message-ID: <TYYPR01MB6603A6B6F2DB198791D2848D867B2@TYYPR01MB6603.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20261117102607.2504551-5-cosmin-gabriel.tanislav.xa@renesas.com>
> -----Original Message-----
> From: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
> Sent: 17 November 2026 10:26
> Subject: [PATCH v3 04/14] counter: rz-mtu3-cnt: read enable value from cache
>
> Reading the enable value when PWM is in use returns -EINVAL because of the checks inside
> rz_mtu3_lock_if_count_is_enabled(). Reading the enable value should not be an issue even if PWM on
> that specific MTU channel is enabled.
>
> There is no need to check whether the underlying MTU3 channel is enabled when determining whether a
> count is enabled, as we have a local count_is_enabled array containing exactly that information, which
> cannot be wrong.
>
> Use the information in the local count_is_enabled array and allow reading it even if PWM is in use.
>
> Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>
> V3:
> * no changes
>
> V2:
> * no changes
>
> drivers/counter/rz-mtu3-cnt.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/counter/rz-mtu3-cnt.c b/drivers/counter/rz-mtu3-cnt.c index
> b1848a0b17e5..db30470215c2 100644
> --- a/drivers/counter/rz-mtu3-cnt.c
> +++ b/drivers/counter/rz-mtu3-cnt.c
> @@ -469,21 +469,10 @@ static void rz_mtu3_terminate_counter(struct counter_device *counter, int id)
> static int rz_mtu3_count_enable_read(struct counter_device *counter,
> struct counter_count *count, u8 *enable) {
> - struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
> - struct rz_mtu3_channel *const ch1 = rz_mtu3_get_ch(counter, 0);
> - struct rz_mtu3_channel *const ch2 = rz_mtu3_get_ch(counter, 1);
> struct rz_mtu3_cnt *const priv = counter_priv(counter);
> - int ret;
> -
> - ret = rz_mtu3_lock_if_count_is_enabled(ch, priv, count->id);
> - if (ret)
> - return ret;
> -
> - if (count->id == RZ_MTU3_32_BIT_CH)
> - *enable = rz_mtu3_is_enabled(ch1) && rz_mtu3_is_enabled(ch2);
> - else
> - *enable = rz_mtu3_is_enabled(ch);
>
> + mutex_lock(&priv->lock);
> + *enable = priv->count_is_enabled[count->id];
> mutex_unlock(&priv->lock);
>
> return 0;
> --
> 2.56.0
next prev parent reply other threads:[~2026-11-17 14:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 10:25 [PATCH v3 00/14] MTU3 counter fixes and improvements Cosmin Tanislav
2026-11-17 10:25 ` [PATCH v3 01/14] counter: rz-mtu3-cnt: do not assign struct rz_mtu3_channel::dev Cosmin Tanislav
2026-11-17 14:04 ` Biju Das
2026-11-17 10:25 ` [PATCH v3 02/14] counter: rz-mtu3-cnt: remove manual runtime PM handling Cosmin Tanislav
2026-11-17 14:04 ` Biju Das
2026-11-17 10:25 ` [PATCH v3 03/14] counter: rz-mtu3-cnt: use device-managed pm_runtime_enable() Cosmin Tanislav
2026-11-17 10:25 ` [PATCH v3 04/14] counter: rz-mtu3-cnt: read enable value from cache Cosmin Tanislav
2026-11-17 14:05 ` Biju Das [this message]
2026-11-17 10:25 ` [PATCH v3 05/14] counter: rz-mtu3-cnt: disable channel before releasing Cosmin Tanislav
2026-11-17 14:05 ` Biju Das
2026-11-17 10:25 ` [PATCH v3 06/14] counter: rz-mtu3-cnt: unify ceiling values Cosmin Tanislav
2026-11-17 10:26 ` [PATCH v3 07/14] counter: rz-mtu3-cnt: cache " Cosmin Tanislav
2026-11-17 10:26 ` [PATCH v3 08/14] counter: rz-mtu3-cnt: cache count values Cosmin Tanislav
2026-11-17 10:26 ` [PATCH v3 09/14] counter: rz-mtu3-cnt: cache function values Cosmin Tanislav
2026-11-17 10:26 ` [PATCH v3 10/14] counter: rz-mtu3-cnt: cache external input phase clock value Cosmin Tanislav
2026-11-17 10:26 ` [PATCH v3 11/14] counter: rz-mtu3-cnt: cache direction values Cosmin Tanislav
2026-11-17 13:49 ` Biju Das
2026-11-17 10:26 ` [PATCH v3 12/14] counter: rz-mtu3-cnt: keep cascade_counts_enable in sync with usage Cosmin Tanislav
2026-11-17 14:28 ` Biju Das
2026-11-17 14:42 ` Cosmin-Gabriel Tanislav
2026-11-17 14:57 ` Biju Das
2026-11-17 15:01 ` Biju Das
2026-11-17 10:26 ` [PATCH v3 13/14] counter: rz-mtu3-cnt: drop conditional locks Cosmin Tanislav
2026-11-17 17:10 ` Biju Das
2026-11-17 10:26 ` [PATCH v3 14/14] counter: rz-mtu3-cnt: use pm_runtime_resume_and_get() Cosmin Tanislav
2026-11-17 17:04 ` Biju Das
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=TYYPR01MB6603A6B6F2DB198791D2848D867B2@TYYPR01MB6603.jpnprd01.prod.outlook.com \
--to=biju.das.jz@bp.renesas.com \
--cc=cosmin-gabriel.tanislav.xa@renesas.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wbg@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
all inboxes | Powered by JetHome®