bnxt_en: extend RTNL to VF check in devlink driver_reinit

The fixes the race condition between configuring SR-IOV and devlink
reload.  The SR-IOV configure logic already takes the RTNL lock,
setting sriov_cfg under the lock while changes are underway. Extend
the lock scope in devlink driver_reinit to cover the VF check and
don't run concurrently with SR-IOV configure.

Reported-by: Leon Romanovsky <leon@kernel.org>
Fixes: 228ea8c187 ("bnxt_en: implement devlink dev reload driver_reinit")
Cc: Leon Romanovsky <leon@kernel.org>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Edwin Peer 2021-11-15 02:37:59 -05:00 коммит произвёл David S. Miller
Родитель e97b21e946
Коммит 46d08f55d2
1 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -441,12 +441,13 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change,
switch (action) { switch (action) {
case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: { case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: {
if (BNXT_PF(bp) && bp->pf.active_vfs) { rtnl_lock();
if (BNXT_PF(bp) && (bp->pf.active_vfs || bp->sriov_cfg)) {
NL_SET_ERR_MSG_MOD(extack, NL_SET_ERR_MSG_MOD(extack,
"reload is unsupported when VFs are allocated"); "reload is unsupported while VFs are allocated or being configured");
rtnl_unlock();
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
rtnl_lock();
if (bp->dev->reg_state == NETREG_UNREGISTERED) { if (bp->dev->reg_state == NETREG_UNREGISTERED) {
rtnl_unlock(); rtnl_unlock();
return -ENODEV; return -ENODEV;