]> git.baikalelectronics.ru Git - kernel.git/commitdiff
cxgb4: fix sleep in atomic when flashing PHY firmware
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Fri, 11 Jun 2021 06:47:46 +0000 (12:17 +0530)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Jun 2021 18:15:00 +0000 (11:15 -0700)
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: 5fff701c838e ("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>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c

index 61ea3ec5c3fcc980ddde91f1639a19908de3372a..bc2de01d05395dc38b8577a929777d646e248014 100644 (file)
@@ -1337,9 +1337,7 @@ static int cxgb4_ethtool_flash_phy(struct net_device *netdev,
                return ret;
        }
 
-       spin_lock_bh(&adap->win0_lock);
        ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size);
-       spin_unlock_bh(&adap->win0_lock);
        if (ret)
                dev_err(adap->pdev_dev, "Failed to load PHY FW\n");
 
index 1f601de02e7067397a6c0936be727e8e84508cce..762113a04dde6335bd6e2cb0b8cfdfe21bbaac6b 100644 (file)
@@ -4424,10 +4424,8 @@ static int adap_init0_phy(struct adapter *adap)
 
        /* Load PHY Firmware onto adapter.
         */
-       spin_lock_bh(&adap->win0_lock);
        ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version,
                             (u8 *)phyf->data, phyf->size);
-       spin_unlock_bh(&adap->win0_lock);
        if (ret < 0)
                dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n",
                        -ret);
index 1293505025c1a6318159f6408c89d22e2aa67048..a0555f4d76fc4ea091f00d6b0f6f53fe66d10702 100644 (file)
@@ -3820,9 +3820,11 @@ int t4_load_phy_fw(struct adapter *adap, int win,
        /* Copy the supplied PHY Firmware image to the adapter memory location
         * allocated by the adapter firmware.
         */
+       spin_lock_bh(&adap->win0_lock);
        ret = t4_memory_rw(adap, win, mtype, maddr,
                           phy_fw_size, (__be32 *)phy_fw_data,
                           T4_MEMORY_WRITE);
+       spin_unlock_bh(&adap->win0_lock);
        if (ret)
                return ret;