Skip to content

Commit ff8ee11

Browse files
danish-tidavem330
authored andcommitted
net: ti: icssg-prueth: Fix race condition for VLAN table access
The VLAN table is a shared memory between the two ports/slices in a ICSSG cluster and this may lead to race condition when the common code paths for both ports are executed in different CPUs. Fix the race condition access by locking the shared memory access Fixes: 487f732 ("net: ti: icssg-prueth: Add helper functions to configure FDB") Signed-off-by: MD Danish Anwar <[email protected]> Reviewed-by: Roger Quadros <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 08c8acc commit ff8ee11

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

drivers/net/ethernet/ti/icssg/icssg_config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ void icssg_vtbl_modify(struct prueth_emac *emac, u8 vid, u8 port_mask,
735735
u8 fid_c1;
736736

737737
tbl = prueth->vlan_tbl;
738+
spin_lock(&prueth->vtbl_lock);
738739
fid_c1 = tbl[vid].fid_c1;
739740

740741
/* FID_C1: bit0..2 port membership mask,
@@ -750,6 +751,7 @@ void icssg_vtbl_modify(struct prueth_emac *emac, u8 vid, u8 port_mask,
750751
}
751752

752753
tbl[vid].fid_c1 = fid_c1;
754+
spin_unlock(&prueth->vtbl_lock);
753755
}
754756
EXPORT_SYMBOL_GPL(icssg_vtbl_modify);
755757

drivers/net/ethernet/ti/icssg/icssg_prueth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,7 @@ static int prueth_probe(struct platform_device *pdev)
14421442
icss_iep_init_fw(prueth->iep1);
14431443
}
14441444

1445+
spin_lock_init(&prueth->vtbl_lock);
14451446
/* setup netdev interfaces */
14461447
if (eth0_node) {
14471448
ret = prueth_netdev_init(prueth, eth0_node);

drivers/net/ethernet/ti/icssg/icssg_prueth.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ struct prueth {
296296
bool is_switchmode_supported;
297297
unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN];
298298
int default_vlan;
299+
/** @vtbl_lock: Lock for vtbl in shared memory */
300+
spinlock_t vtbl_lock;
299301
};
300302

301303
struct emac_tx_ts_response {

0 commit comments

Comments
 (0)