From: Jacob Keller <jacob.e.keller@intel.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>, <netdev@vger.kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Claudiu Manoil" <claudiu.manoil@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
<UNGLinuxDriver@microchip.com>,
Colin Foster <colin.foster@in-advantage.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 8/8] net: mscc: ocelot: fix ineffective WARN_ON() in ocelot_stats.c
Date: Wed, 12 Apr 2023 14:23:06 -0700 [thread overview]
Message-ID: <529b10f7-6f74-9fdb-db45-0ba589ba0cb3@intel.com> (raw)
In-Reply-To: <20230412124737.2243527-9-vladimir.oltean@nxp.com>
On 4/12/2023 5:47 AM, Vladimir Oltean wrote:
> Since it is hopefully now clear that, since "last" and "layout[i].reg"
> are enum types and not addresses, the existing WARN_ON() is ineffective
> in checking that the _addresses_ are sorted in the proper order.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
This is definitely more clear after reviewing the other code dealing
with these encoded register addresses.
Nice fix.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Thanks,
Jake
> drivers/net/ethernet/mscc/ocelot_stats.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/mscc/ocelot_stats.c b/drivers/net/ethernet/mscc/ocelot_stats.c
> index e82c9d9d0ad3..5c55197c7327 100644
> --- a/drivers/net/ethernet/mscc/ocelot_stats.c
> +++ b/drivers/net/ethernet/mscc/ocelot_stats.c
> @@ -901,6 +901,17 @@ static int ocelot_prepare_stats_regions(struct ocelot *ocelot)
> if (!layout[i].reg)
> continue;
>
> + /* enum ocelot_stat must be kept sorted in the same order
> + * as the addresses behind layout[i].reg in order to have
> + * efficient bulking
> + */
> + if (last) {
> + WARN(ocelot->map[SYS][last & REG_MASK] >= ocelot->map[SYS][layout[i].reg & REG_MASK],
> + "reg 0x%x had address 0x%x but reg 0x%x has address 0x%x, bulking broken!",
> + last, ocelot->map[SYS][last & REG_MASK],
> + layout[i].reg, ocelot->map[SYS][layout[i].reg & REG_MASK]);
> + }
> +
> if (region && ocelot->map[SYS][layout[i].reg & REG_MASK] ==
> ocelot->map[SYS][last & REG_MASK] + 4) {
> region->count++;
> @@ -910,12 +921,6 @@ static int ocelot_prepare_stats_regions(struct ocelot *ocelot)
> if (!region)
> return -ENOMEM;
>
> - /* enum ocelot_stat must be kept sorted in the same
> - * order as layout[i].reg in order to have efficient
> - * bulking
> - */
> - WARN_ON(last >= layout[i].reg);
> -
> region->base = layout[i].reg;
> region->first_stat = i;
> region->count = 1;
next prev parent reply other threads:[~2023-04-12 21:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-12 12:47 [PATCH net-next 0/8] Ocelot/Felix driver cleanup Vladimir Oltean
2023-04-12 12:47 ` [PATCH net-next 1/8] net: mscc: ocelot: strengthen type of "u32 reg" in I/O accessors Vladimir Oltean
2023-04-12 21:11 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 2/8] net: mscc: ocelot: refactor enum ocelot_reg decoding to helper Vladimir Oltean
2023-04-12 21:16 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 3/8] net: mscc: ocelot: debugging print for statistics regions Vladimir Oltean
2023-04-12 21:17 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 4/8] net: mscc: ocelot: remove blank line at the end of ocelot_stats.c Vladimir Oltean
2023-04-12 15:59 ` Colin Foster
2023-04-12 21:18 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 5/8] net: dsa: felix: remove confusing/incorrect comment from felix_setup() Vladimir Oltean
2023-04-12 21:18 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 6/8] net: mscc: ocelot: strengthen type of "u32 reg" and "u32 base" in ocelot_stats.c Vladimir Oltean
2023-04-12 21:19 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 7/8] net: mscc: ocelot: strengthen type of "int i" " Vladimir Oltean
2023-04-12 21:21 ` Jacob Keller
2023-04-12 12:47 ` [PATCH net-next 8/8] net: mscc: ocelot: fix ineffective WARN_ON() " Vladimir Oltean
2023-04-12 21:23 ` Jacob Keller [this message]
2023-04-13 0:45 ` [PATCH net-next 0/8] Ocelot/Felix driver cleanup Colin Foster
2023-04-13 10:08 ` Vladimir Oltean
2023-04-14 5:20 ` patchwork-bot+netdevbpf
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=529b10f7-6f74-9fdb-db45-0ba589ba0cb3@intel.com \
--to=jacob.e.keller@intel.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=colin.foster@in-advantage.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).