Skip to content

Commit 2ddaa56

Browse files
ahduyckkuba-moo
authored andcommitted
fbnic: Fixup rtnl_lock and devl_lock handling related to mailbox code
The exception handling path for the __fbnic_pm_resume function had a bug in that it was taking the devlink lock and then exiting to exception handling instead of waiting until after it released the lock to do so. In order to handle that I am swapping the placement of the unlock and the exception handling jump to label so that we don't trigger a deadlock by holding the lock longer than we need to. In addition this change applies the same ordering to the rtnl_lock/unlock calls in the same function as it should make the code easier to follow if it adheres to a consistent pattern. Fixes: 82534f4 ("eth: fbnic: Add devlink dev flash support") Signed-off-by: Alexander Duyck <alexanderduyck@fb.com> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Link: https://patch.msgid.link/175616256667.1963577.5543500806256052549.stgit@ahduyck-xeon-server.home.arpa Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 1cc8a5b commit 2ddaa56

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_pci.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,10 @@ static int __fbnic_pm_resume(struct device *dev)
443443

444444
/* Re-enable mailbox */
445445
err = fbnic_fw_request_mbx(fbd);
446+
devl_unlock(priv_to_devlink(fbd));
446447
if (err)
447448
goto err_free_irqs;
448449

449-
devl_unlock(priv_to_devlink(fbd));
450-
451450
/* Only send log history if log buffer is empty to prevent duplicate
452451
* log entries.
453452
*/
@@ -464,20 +463,20 @@ static int __fbnic_pm_resume(struct device *dev)
464463

465464
rtnl_lock();
466465

467-
if (netif_running(netdev)) {
466+
if (netif_running(netdev))
468467
err = __fbnic_open(fbn);
469-
if (err)
470-
goto err_free_mbx;
471-
}
472468

473469
rtnl_unlock();
470+
if (err)
471+
goto err_free_mbx;
474472

475473
return 0;
476474
err_free_mbx:
477475
fbnic_fw_log_disable(fbd);
478476

479-
rtnl_unlock();
477+
devl_lock(priv_to_devlink(fbd));
480478
fbnic_fw_free_mbx(fbd);
479+
devl_unlock(priv_to_devlink(fbd));
481480
err_free_irqs:
482481
fbnic_free_irqs(fbd);
483482
err_invalidate_uc_addr:

0 commit comments

Comments
 (0)