]> www.infradead.org Git - users/willy/linux.git/commitdiff
phy: zynqmp: Take the phy mutex in xlate
authorSean Anderson <sean.anderson@linux.dev>
Fri, 28 Jun 2024 20:55:39 +0000 (16:55 -0400)
committerVinod Koul <vkoul@kernel.org>
Tue, 2 Jul 2024 13:18:09 +0000 (18:48 +0530)
Take the phy mutex in xlate to protect against concurrent
modification/access to gtr_phy. This does not typically cause any
issues, since in most systems the phys are only xlated once and
thereafter accessed with the phy API (which takes the locks). However,
we are about to allow userspace to access phys for debugging, so it's
important to avoid any data races.

Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Link: https://lore.kernel.org/r/20240628205540.3098010-5-sean.anderson@linux.dev
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/xilinx/phy-zynqmp.c

index 4d697e11d8eb7b6c46e9b4152d7d9e5771aca4ca..991be42eef3de021894005acb19bc71989303d8a 100644 (file)
@@ -759,6 +759,7 @@ static struct phy *xpsgtr_xlate(struct device *dev,
        phy_type = args->args[1];
        phy_instance = args->args[2];
 
+       guard(mutex)(&gtr_phy->phy->mutex);
        ret = xpsgtr_set_lane_type(gtr_phy, phy_type, phy_instance);
        if (ret < 0) {
                dev_err(gtr_dev->dev, "Invalid PHY type and/or instance\n");