]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: dsa: felix: access QSYS_TAG_CONFIG under tas_lock in vsc9959_sched_speed_set
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 5 Sep 2022 17:01:25 +0000 (20:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Sep 2022 08:47:17 +0000 (10:47 +0200)
[ Upstream commit a4bb481aeb9d84cb53112a478e6db4705b794c34 ]

The read-modify-write of QSYS_TAG_CONFIG from vsc9959_sched_speed_set()
runs unlocked with respect to the other functions that access it, which
are vsc9959_tas_guard_bands_update(), vsc9959_qos_port_tas_set() and
vsc9959_tas_clock_adjust(). All the others are under ocelot->tas_lock,
so move the vsc9959_sched_speed_set() access under that lock as well, to
resolve the concurrency.

Fixes: 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/ocelot/felix_vsc9959.c

index 2a5822c619ef3662fb2f5e930ce5d215f22eb88b..f1767a6b9271c06bf08af72b347abc56e0ff0751 100644 (file)
@@ -1664,13 +1664,13 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port,
                break;
        }
 
+       mutex_lock(&ocelot->tas_lock);
+
        ocelot_rmw_rix(ocelot,
                       QSYS_TAG_CONFIG_LINK_SPEED(tas_speed),
                       QSYS_TAG_CONFIG_LINK_SPEED_M,
                       QSYS_TAG_CONFIG, port);
 
-       mutex_lock(&ocelot->tas_lock);
-
        if (ocelot_port->taprio)
                vsc9959_tas_guard_bands_update(ocelot, port);