cxgb4: fix sleep in atomic when flashing PHY firmware

[ Upstream commit f046bd0ae15d8a0bbe57d4647da182420f720c3d ]

Before writing new PHY firmware to on-chip memory, driver queries
firmware for current running PHY firmware version, which can result
in sleep waiting for reply. So, move spinlock closer to the actual
on-chip memory write operation, instead of taking it at the callers.

Fixes: 5fff701c83 ("cxgb4: always sync access when flashing PHY firmware")
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Rahul Lakkireddy
2021-06-11 12:17:46 +05:30
committed by Greg Kroah-Hartman
parent 3d60457d74
commit b38ec782d0
3 changed files with 2 additions and 4 deletions

View File

@@ -1337,9 +1337,7 @@ static int cxgb4_ethtool_flash_phy(struct net_device *netdev,
return ret; return ret;
} }
spin_lock_bh(&adap->win0_lock);
ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size); ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size);
spin_unlock_bh(&adap->win0_lock);
if (ret) if (ret)
dev_err(adap->pdev_dev, "Failed to load PHY FW\n"); dev_err(adap->pdev_dev, "Failed to load PHY FW\n");

View File

@@ -4428,10 +4428,8 @@ static int adap_init0_phy(struct adapter *adap)
/* Load PHY Firmware onto adapter. /* Load PHY Firmware onto adapter.
*/ */
spin_lock_bh(&adap->win0_lock);
ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version, ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version,
(u8 *)phyf->data, phyf->size); (u8 *)phyf->data, phyf->size);
spin_unlock_bh(&adap->win0_lock);
if (ret < 0) if (ret < 0)
dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n", dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n",
-ret); -ret);

View File

@@ -3827,9 +3827,11 @@ int t4_load_phy_fw(struct adapter *adap, int win,
/* Copy the supplied PHY Firmware image to the adapter memory location /* Copy the supplied PHY Firmware image to the adapter memory location
* allocated by the adapter firmware. * allocated by the adapter firmware.
*/ */
spin_lock_bh(&adap->win0_lock);
ret = t4_memory_rw(adap, win, mtype, maddr, ret = t4_memory_rw(adap, win, mtype, maddr,
phy_fw_size, (__be32 *)phy_fw_data, phy_fw_size, (__be32 *)phy_fw_data,
T4_MEMORY_WRITE); T4_MEMORY_WRITE);
spin_unlock_bh(&adap->win0_lock);
if (ret) if (ret)
return ret; return ret;