Re: [PATCH v3 net-next 3/9] net: mscc: ocelot: serialize access to the MAC table
From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2021-10-22 17:34:10
On 10/22/21 10:27 AM, Vladimir Oltean wrote:
quoted hunk ↗ jump to hunk
DSA would like to remove the rtnl_lock from its SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE handlers, and the felix driver uses the same MAC table functions as ocelot. This means that the MAC table functions will no longer be implicitly serialized with respect to each other by the rtnl_mutex, we need to add a dedicated lock in ocelot for the non-atomic operations of selecting a MAC table row, reading/writing what we want and polling for completion. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> --- drivers/net/ethernet/mscc/ocelot.c | 53 +++++++++++++++++++++++------- include/soc/mscc/ocelot.h | 3 ++ 2 files changed, 44 insertions(+), 12 deletions(-)diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 4e5ae687d2e2..72925529b27c 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c@@ -20,11 +20,13 @@ struct ocelot_mact_entry { enum macaccess_entry_type type; }; +/* Must be called with &ocelot->mact_lock held */
I don't know if the sparse annotations: __must_hold() would work here, but if they do, they serve as both comment and static verification, might as well use them? Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> -- Florian