Skip to content

Commit a224a80

Browse files
rogerqintel-lab-lkp
authored andcommitted
net: ethernet: ti: cpsw_ale: Fix warning on some platforms
The number of register fields cannot be assumed to be ALE_FIELDS_MAX as some platforms can have lesser fields. Solve this by embedding the actual number of fields available in platform data and use that instead of ALE_FIELDS_MAX. Gets rid of the below warning on BeagleBone Black [ 1.007735] WARNING: CPU: 0 PID: 33 at drivers/base/regmap/regmap.c:1208 regmap_field_init+0x88/0x9c [ 1.007802] invalid empty mask defined [ 1.007812] Modules linked in: [ 1.007842] CPU: 0 UID: 0 PID: 33 Comm: kworker/u4:3 Not tainted 6.11.0-01459-g508403ab7b74-dirty torvalds#840 [ 1.007867] Hardware name: Generic AM33XX (Flattened Device Tree) [ 1.007890] Workqueue: events_unbound deferred_probe_work_func [ 1.007935] Call trace: [ 1.007957] unwind_backtrace from show_stack+0x10/0x14 [ 1.007999] show_stack from dump_stack_lvl+0x50/0x64 [ 1.008033] dump_stack_lvl from __warn+0x70/0x124 [ 1.008077] __warn from warn_slowpath_fmt+0x194/0x1a8 [ 1.008113] warn_slowpath_fmt from regmap_field_init+0x88/0x9c [ 1.008154] regmap_field_init from devm_regmap_field_alloc+0x48/0x64 [ 1.008193] devm_regmap_field_alloc from cpsw_ale_create+0xfc/0x320 [ 1.008251] cpsw_ale_create from cpsw_init_common+0x214/0x354 [ 1.008286] cpsw_init_common from cpsw_probe+0x4ac/0xb88 Reported-by: Geert Uytterhoeven <[email protected]> Closes: https://lore.kernel.org/netdev/CAMuHMdUf-tKRDzkz2_m8qdFTFutefddU0NTratVrEjRTzA3yQQ@mail.gmail.com/ Fixes: 11cbcfe ("net: ethernet: ti: cpsw_ale: use regfields for number of Entries and Policers") Signed-off-by: Roger Quadros <[email protected]>
1 parent 9410645 commit a224a80

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/net/ethernet/ti/cpsw_ale.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ enum {
9696
* @features: features supported by ALE
9797
* @tbl_entries: number of ALE entries
9898
* @reg_fields: pointer to array of register field configuration
99+
* @num_fields: number of fields in the reg_fields array
99100
* @nu_switch_ale: NU Switch ALE
100101
* @vlan_entry_tbl: ALE vlan entry fields description tbl
101102
*/
@@ -104,6 +105,7 @@ struct cpsw_ale_dev_id {
104105
u32 features;
105106
u32 tbl_entries;
106107
const struct reg_field *reg_fields;
108+
int num_fields;
107109
bool nu_switch_ale;
108110
const struct ale_entry_fld *vlan_entry_tbl;
109111
};
@@ -1400,19 +1402,22 @@ static const struct cpsw_ale_dev_id cpsw_ale_id_match[] = {
14001402
.dev_id = "cpsw",
14011403
.tbl_entries = 1024,
14021404
.reg_fields = ale_fields_cpsw,
1405+
.num_fields = ARRAY_SIZE(ale_fields_cpsw),
14031406
.vlan_entry_tbl = vlan_entry_cpsw,
14041407
},
14051408
{
14061409
/* 66ak2h_xgbe */
14071410
.dev_id = "66ak2h-xgbe",
14081411
.tbl_entries = 2048,
14091412
.reg_fields = ale_fields_cpsw,
1413+
.num_fields = ARRAY_SIZE(ale_fields_cpsw),
14101414
.vlan_entry_tbl = vlan_entry_cpsw,
14111415
},
14121416
{
14131417
.dev_id = "66ak2el",
14141418
.features = CPSW_ALE_F_STATUS_REG,
14151419
.reg_fields = ale_fields_cpsw_nu,
1420+
.num_fields = ARRAY_SIZE(ale_fields_cpsw_nu),
14161421
.nu_switch_ale = true,
14171422
.vlan_entry_tbl = vlan_entry_nu,
14181423
},
@@ -1421,6 +1426,7 @@ static const struct cpsw_ale_dev_id cpsw_ale_id_match[] = {
14211426
.features = CPSW_ALE_F_STATUS_REG,
14221427
.tbl_entries = 64,
14231428
.reg_fields = ale_fields_cpsw_nu,
1429+
.num_fields = ARRAY_SIZE(ale_fields_cpsw_nu),
14241430
.nu_switch_ale = true,
14251431
.vlan_entry_tbl = vlan_entry_nu,
14261432
},
@@ -1429,19 +1435,22 @@ static const struct cpsw_ale_dev_id cpsw_ale_id_match[] = {
14291435
.features = CPSW_ALE_F_STATUS_REG | CPSW_ALE_F_HW_AUTOAGING,
14301436
.tbl_entries = 64,
14311437
.reg_fields = ale_fields_cpsw_nu,
1438+
.num_fields = ARRAY_SIZE(ale_fields_cpsw_nu),
14321439
.nu_switch_ale = true,
14331440
.vlan_entry_tbl = vlan_entry_nu,
14341441
},
14351442
{
14361443
.dev_id = "j721e-cpswxg",
14371444
.features = CPSW_ALE_F_STATUS_REG | CPSW_ALE_F_HW_AUTOAGING,
14381445
.reg_fields = ale_fields_cpsw_nu,
1446+
.num_fields = ARRAY_SIZE(ale_fields_cpsw_nu),
14391447
.vlan_entry_tbl = vlan_entry_k3_cpswxg,
14401448
},
14411449
{
14421450
.dev_id = "am64-cpswxg",
14431451
.features = CPSW_ALE_F_STATUS_REG | CPSW_ALE_F_HW_AUTOAGING,
14441452
.reg_fields = ale_fields_cpsw_nu,
1453+
.num_fields = ARRAY_SIZE(ale_fields_cpsw_nu),
14451454
.vlan_entry_tbl = vlan_entry_k3_cpswxg,
14461455
.tbl_entries = 512,
14471456
},
@@ -1477,7 +1486,7 @@ static int cpsw_ale_regfield_init(struct cpsw_ale *ale)
14771486
struct regmap *regmap = ale->regmap;
14781487
int i;
14791488

1480-
for (i = 0; i < ALE_FIELDS_MAX; i++) {
1489+
for (i = 0; i < ale->params.num_fields; i++) {
14811490
ale->fields[i] = devm_regmap_field_alloc(dev, regmap,
14821491
reg_fields[i]);
14831492
if (IS_ERR(ale->fields[i])) {
@@ -1503,6 +1512,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
15031512
params->ale_entries = ale_dev_id->tbl_entries;
15041513
params->nu_switch_ale = ale_dev_id->nu_switch_ale;
15051514
params->reg_fields = ale_dev_id->reg_fields;
1515+
params->num_fields = ale_dev_id->num_fields;
15061516

15071517
ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
15081518
if (!ale)

drivers/net/ethernet/ti/cpsw_ale.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct cpsw_ale_params {
2424
*/
2525
bool nu_switch_ale;
2626
const struct reg_field *reg_fields;
27+
int num_fields;
2728
const char *dev_id;
2829
unsigned long bus_freq;
2930
};

0 commit comments

Comments
 (0)