linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@kernel.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Siddharth Vadapalli <s-vadapalli@ti.com>,
	Julien Panis <jpanis@baylibre.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Simon Horman <horms@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	Joe Damato <jdamato@fastly.com>,
	srk@ti.com, vigneshr@ti.com, danishanwar@ti.com,
	pekka Varis <p-varis@ti.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-omap@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH net-next v4 3/6] net: ethernet: ti: cpsw_ale: use regfields for number of Entries and Policers
Date: Mon, 23 Sep 2024 17:06:55 +0300	[thread overview]
Message-ID: <42b347ec-df8e-44b8-ba19-150ebaf04771@kernel.org> (raw)
In-Reply-To: <CAMuHMdUf-tKRDzkz2_m8qdFTFutefddU0NTratVrEjRTzA3yQQ@mail.gmail.com>

Hi Geert,

On 23/09/2024 16:41, Geert Uytterhoeven wrote:
> Hi Roger,
> 
> On Tue, Sep 10, 2024 at 11:25 AM Roger Quadros <rogerq@kernel.org> wrote:
>> Use regfields for number of ALE Entries and Policers.
>>
>> The variants that support Policers/Classifiers have the number
>> of policers encoded in the ALE_STATUS register.
>>
>> Use that and show the number of Policers in the ALE info message.
>>
>> Signed-off-by: Roger Quadros <rogerq@kernel.org>
>> Reviewed-by: Simon Horman <horms@kernel.org>
>> ---
>> Changelog:
>> v4:
>> - reverse Xmas tree declaration order fixes
> 
> Thanks for your patch, which is now commit 11cbcfeaa79e5c76 ("net:
> ethernet: ti: cpsw_ale: use regfields for number of Entries
> and Policers").
> 
> This is causing the following warning on BeagleBone Black:
> 
>     WARNING: CPU: 0 PID: 34 at drivers/base/regmap/regmap.c:1208
> devm_regmap_field_alloc+0xac/0xc8
>     invalid empty mask defined
>     CPU: 0 UID: 0 PID: 34 Comm: kworker/u4:3 Not tainted
> 6.11.0-rc7-boneblack-01443-g11cbcfeaa79e #152
>     Hardware name: Generic AM33XX (Flattened Device Tree)
>     Workqueue: events_unbound deferred_probe_work_func
>     Call trace:
>      unwind_backtrace from show_stack+0x10/0x14
>      show_stack from dump_stack_lvl+0x68/0x88
>      dump_stack_lvl from __warn+0x6c/0x1a8
>      __warn from warn_slowpath_fmt+0x1bc/0x1d0
>      warn_slowpath_fmt from devm_regmap_field_alloc+0xac/0xc8
>      devm_regmap_field_alloc from cpsw_ale_create+0x10c/0x36c
>      cpsw_ale_create from cpsw_init_common+0x1fc/0x310
> 
>> --- a/drivers/net/ethernet/ti/cpsw_ale.c
>> +++ b/drivers/net/ethernet/ti/cpsw_ale.c
>> @@ -1303,6 +1303,9 @@ static const struct reg_field ale_fields_cpsw_nu[] = {
>>         /* CPSW_ALE_IDVER_REG */
>>         [MINOR_VER]     = REG_FIELD(ALE_IDVER, 0, 7),
>>         [MAJOR_VER]     = REG_FIELD(ALE_IDVER, 8, 10),
>> +       /* CPSW_ALE_STATUS_REG */
>> +       [ALE_ENTRIES]   = REG_FIELD(ALE_STATUS, 0, 7),
>> +       [ALE_POLICERS]  = REG_FIELD(ALE_STATUS, 8, 15),
> 
> You are adding these entries only to ale_fields_cpsw_nu[], not
> to ale_fields_cpsw[], while cpsw_ale_regfield_init() loops over
> ALE_FIELDS_MAX entries, whether they are valid or not:
> 
>     static int cpsw_ale_regfield_init(struct cpsw_ale *ale)
>     {
>             const struct reg_field *reg_fields = ale->params.reg_fields;
>             struct device *dev = ale->params.dev;
>             struct regmap *regmap = ale->regmap;
>             int i;
> 
>             for (i = 0; i < ALE_FIELDS_MAX; i++) {
>                     ale->fields[i] = devm_regmap_field_alloc(dev, regmap,
>                                                              reg_fields[i]);
> 
>                     [...]
>             }
> 
>             return 0;
>     }
> 
> I tried fixing this by skipping entries where all of .reg, .lsb,
> and .msb are zero, but that doesn't work as that runs beyond the
> end of ale_fields_cpsw[], thus operating on random data.
> I think you do have to store the size of the array, instead of assuming
> ALE_FIELDS_MAX entries everywhere.

Thanks for the report and suggestion. I will send a fix soon.

> 
>> --- a/drivers/net/ethernet/ti/cpsw_ale.h
>> +++ b/drivers/net/ethernet/ti/cpsw_ale.h
>> @@ -33,6 +34,8 @@ struct regmap;
>>  enum ale_fields {
>>         MINOR_VER,
>>         MAJOR_VER,
>> +       ALE_ENTRIES,
>> +       ALE_POLICERS,
>>         /* terminator */
>>         ALE_FIELDS_MAX,
>>  };
>>
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 

-- 
cheers,
-roger

  reply	other threads:[~2024-09-23 14:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10  9:23 [PATCH net-next v4 0/6] net: ethernet: ti: am65-cpsw: Add multi queue RX support Roger Quadros
2024-09-10  9:23 ` [PATCH net-next v4 1/6] net: ethernet: ti: am65-cpsw: Introduce multi queue Rx Roger Quadros
2024-09-10  9:23 ` [PATCH net-next v4 2/6] net: ethernet: ti: cpsw_ale: use regfields for ALE registers Roger Quadros
2024-09-10  9:24 ` [PATCH net-next v4 3/6] net: ethernet: ti: cpsw_ale: use regfields for number of Entries and Policers Roger Quadros
2024-09-23 13:41   ` Geert Uytterhoeven
2024-09-23 14:06     ` Roger Quadros [this message]
2024-09-10  9:24 ` [PATCH net-next v4 4/6] net: ethernet: ti: cpsw_ale: add Policer and Thread control register fields Roger Quadros
2024-09-10  9:24 ` [PATCH net-next v4 5/6] net: ethernet: ti: cpsw_ale: add policer/classifier helpers and setup defaults Roger Quadros
2024-09-11  7:40   ` Simon Horman
2024-09-10  9:24 ` [PATCH net-next v4 6/6] net: ethernet: ti: am65-cpsw: setup priority to flow mapping Roger Quadros
2024-09-11  8:17 ` [PATCH net-next v4 0/6] net: ethernet: ti: am65-cpsw: Add multi queue RX support MD Danish Anwar
2024-09-13 10:00 ` 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=42b347ec-df8e-44b8-ba19-150ebaf04771@kernel.org \
    --to=rogerq@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=geert@linux-m68k.org \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=jdamato@fastly.com \
    --cc=john.fastabend@gmail.com \
    --cc=jpanis@baylibre.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=p-varis@ti.com \
    --cc=pabeni@redhat.com \
    --cc=s-vadapalli@ti.com \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.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).