From: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
To: Lorenzo Bianconi <lorenzo@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, netdev@vger.kernel.org
Subject: Re: [PATCH net] net: airoha: Fix PPE table access in airoha_ppe_debugfs_foe_show()
Date: Mon, 28 Jul 2025 18:50:56 +0200 [thread overview]
Message-ID: <08e39788-8d1b-494d-87e3-e5b427875674@linux.intel.com> (raw)
In-Reply-To: <20250728-airoha_ppe_foe_get_entry_locked-v1-1-8630ec73f3d1@kernel.org>
On 2025-07-28 1:58 PM, Lorenzo Bianconi wrote:
> In order to avoid any possible race we need to hold the ppe_lock
> spinlock accessing the hw PPE table. airoha_ppe_foe_get_entry routine is
> always executed holding ppe_lock except in airoha_ppe_debugfs_foe_show
> routine. Fix the problem introducing airoha_ppe_foe_get_entry_locked
> routine.
>
> Fixes: 3fe15c640f380 ("net: airoha: Introduce PPE debugfs support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Thanks,
Dawid
> ---
> drivers/net/ethernet/airoha/airoha_eth.h | 4 ++--
> drivers/net/ethernet/airoha/airoha_ppe.c | 18 ++++++++++++++++--
> drivers/net/ethernet/airoha/airoha_ppe_debugfs.c | 2 +-
> 3 files changed, 19 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h
> index a970b789cf232c316e5ea27b0146493bf91c3767..cf33d731ad0db43bca8463fde76673b39a4f6796 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.h
> +++ b/drivers/net/ethernet/airoha/airoha_eth.h
> @@ -615,8 +615,8 @@ int airoha_ppe_setup_tc_block_cb(struct net_device *dev, void *type_data);
> int airoha_ppe_init(struct airoha_eth *eth);
> void airoha_ppe_deinit(struct airoha_eth *eth);
> void airoha_ppe_init_upd_mem(struct airoha_gdm_port *port);
> -struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
> - u32 hash);
> +struct airoha_foe_entry *
> +airoha_ppe_foe_get_entry_locked(struct airoha_ppe *ppe, u32 hash);
> void airoha_ppe_foe_entry_get_stats(struct airoha_ppe *ppe, u32 hash,
> struct airoha_foe_stats64 *stats);
>
> diff --git a/drivers/net/ethernet/airoha/airoha_ppe.c b/drivers/net/ethernet/airoha/airoha_ppe.c
> index 0e217acfc5ef748453b020e5713ace1910abc4a8..4dbf2bf187d02e3e8b9d2b966036c3aa58c867b1 100644
> --- a/drivers/net/ethernet/airoha/airoha_ppe.c
> +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
> @@ -498,9 +498,11 @@ static void airoha_ppe_foe_flow_stats_update(struct airoha_ppe *ppe,
> FIELD_PREP(AIROHA_FOE_IB2_NBQ, nbq);
> }
>
> -struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
> - u32 hash)
> +static struct airoha_foe_entry *
> +airoha_ppe_foe_get_entry(struct airoha_ppe *ppe, u32 hash)
> {
> + lockdep_assert_held(&ppe_lock);
> +
> if (hash < PPE_SRAM_NUM_ENTRIES) {
> u32 *hwe = ppe->foe + hash * sizeof(struct airoha_foe_entry);
> struct airoha_eth *eth = ppe->eth;
> @@ -527,6 +529,18 @@ struct airoha_foe_entry *airoha_ppe_foe_get_entry(struct airoha_ppe *ppe,
> return ppe->foe + hash * sizeof(struct airoha_foe_entry);
> }
>
> +struct airoha_foe_entry *
> +airoha_ppe_foe_get_entry_locked(struct airoha_ppe *ppe, u32 hash)
> +{
> + struct airoha_foe_entry *hwe;
> +
> + spin_lock_bh(&ppe_lock);
> + hwe = airoha_ppe_foe_get_entry(ppe, hash);
> + spin_unlock_bh(&ppe_lock);
> +
> + return hwe;
> +}
> +
> static bool airoha_ppe_foe_compare_entry(struct airoha_flow_table_entry *e,
> struct airoha_foe_entry *hwe)
> {
> diff --git a/drivers/net/ethernet/airoha/airoha_ppe_debugfs.c b/drivers/net/ethernet/airoha/airoha_ppe_debugfs.c
> index 05a756233f6a44fa51d1c57dd39d89c8ea488054..992bf2e9598414ee3f1f126be3f451e486b26640 100644
> --- a/drivers/net/ethernet/airoha/airoha_ppe_debugfs.c
> +++ b/drivers/net/ethernet/airoha/airoha_ppe_debugfs.c
> @@ -67,7 +67,7 @@ static int airoha_ppe_debugfs_foe_show(struct seq_file *m, void *private,
> u32 type, state, ib2, data;
> bool ipv6 = false;
>
> - hwe = airoha_ppe_foe_get_entry(ppe, i);
> + hwe = airoha_ppe_foe_get_entry_locked(ppe, i);
> if (!hwe)
> continue;
>
>
> ---
> base-commit: afd8c2c9e2e29c6c7705635bea2960593976dacc
> change-id: 20250728-airoha_ppe_foe_get_entry_locked-70e4ebbee984
>
> Best regards,
next prev parent reply other threads:[~2025-07-28 17:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 11:58 [PATCH net] net: airoha: Fix PPE table access in airoha_ppe_debugfs_foe_show() Lorenzo Bianconi
2025-07-28 16:50 ` Dawid Osuchowski [this message]
2025-07-31 1:12 ` Jakub Kicinski
2025-07-31 9:20 ` Lorenzo Bianconi
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=08e39788-8d1b-494d-87e3-e5b427875674@linux.intel.com \
--to=dawid.osuchowski@linux.intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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