From: Jakub Kicinski <kuba@kernel.org>
To: michael.dege@renesas.com
Cc: Jakub Kicinski <kuba@kernel.org>,
yoshihiro.shimoda.uh@renesas.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
niklas.soderlund@ragnatech.se, paul@pbarker.dev,
richardcochran@gmail.com, netdev@vger.kernel.org,
linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 08/14] net: renesas: rswitch: add locking for agent clock control
Date: Mon, 25 May 2026 13:41:14 -0700 [thread overview]
Message-ID: <20260525204114.2471390-1-kuba@kernel.org> (raw)
In-Reply-To: <20260522-rswitch_add_vlans-v5-8-53589d944a9f@renesas.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: renesas: rswitch: add locking for agent clock control
This commit introduces an agent_lock to serialize access to the shared RCEC
and RCDC agent clock registers. This aims to prevent potential race
conditions between ETHA and GWCA ports when enabling or disabling clocks.
> diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h
> --- a/drivers/net/ethernet/renesas/rswitch.h
> +++ b/drivers/net/ethernet/renesas/rswitch.h
[ ... ]
> @@ -1207,6 +1208,8 @@ struct rswitch_private {
> struct list_head port_list;
>
> spinlock_t lock; /* lock interrupt registers' control */
> + spinlock_t agent_lock; /* rswitch agent clock control */
> +
[Severity: High]
Is this lock initialized anywhere before it is used?
It looks like agent_lock is added to the structure, but spin_lock_init() is
missing from the driver probe path. Depending on kzalloc for
zero-initialization is not valid for spinlocks and can cause issues on
architectures or kernel configurations that require explicit initialization.
> diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethernet/renesas/rswitch_main.c
> --- a/drivers/net/ethernet/renesas/rswitch_main.c
> +++ b/drivers/net/ethernet/renesas/rswitch_main.c
> @@ -173,8 +173,12 @@ int rswitch_gwca_change_mode(struct rswitch_private *priv,
> {
> int ret;
>
> - if (!rswitch_agent_clock_is_enabled(priv->addr, priv->gwca.index))
> + if (!rswitch_agent_clock_is_enabled(priv->addr, priv->gwca.index)) {
> + spin_lock(&priv->agent_lock);
> rswitch_agent_clock_ctrl(priv->addr, priv->gwca.index, 1);
> + spin_lock(&priv->agent_lock);
> + }
[Severity: High]
Does this code cause an immediate deadlock?
Because spin_lock() is called twice consecutively without a spin_unlock(), it
appears the CPU will spin indefinitely waiting for the lock it already holds.
next prev parent reply other threads:[~2026-05-25 20:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 12:12 [net-next PATCH v5 00/14] net: renesas: rswitch: R-Car S4 add VLAN aware switching Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 01/14] net: renesas: rswitch: improve port change mode functions Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 02/14] net: renesas: rswitch: use device instead of net_device Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 03/14] net: renesas: rswitch: fix FWPC2 register access macros Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 04/14] net: renesas: rswitch: add register definitions for vlan support Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 05/14] net: renesas: rswitch: add exception path for packets with unknown dst MAC Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 06/14] net: renesas: rswitch: add forwarding rules for gwca Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 07/14] net: renesas: rswitch: make helper functions available to whole driver Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 08/14] net: renesas: rswitch: add locking for agent clock control Michael Dege
2026-05-25 20:41 ` Jakub Kicinski [this message]
2026-05-22 12:12 ` [PATCH net-next v5 09/14] net: renesas: rswitch: add basic vlan init to rswitch_fwd_init Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 10/14] net: renesas: rswitch: update port HW init Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 11/14] net: renesas: rswitch: clean up is_rdev rswitch_device checking Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 12/14] net: renesas: rswitch: add passing of rswitch_private into notifiers Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 13/14] net: renesas: rswitch: add handler for FDB notification Michael Dege
2026-05-25 20:40 ` Jakub Kicinski
2026-05-25 20:41 ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 14/14] net: renesas: rswitch: add vlan aware switching Michael Dege
2026-05-25 20:41 ` Jakub Kicinski
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=20260525204114.2471390-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=michael.dege@renesas.com \
--cc=netdev@vger.kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=pabeni@redhat.com \
--cc=paul@pbarker.dev \
--cc=richardcochran@gmail.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/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