> -----Original Message----- > From: Intel-wired-lan <intel-wired-lan-boun...@osuosl.org> On Behalf Of > Tarun K Singh > Sent: Tuesday, November 5, 2024 10:49 AM > To: intel-wired-...@lists.osuosl.org > Cc: net...@vger.kernel.org > Subject: [Intel-wired-lan] [PATCH iwl-net v1 3/4] idpf: Add init, reinit, and > deinit control lock > > Add new 'vport_init_lock' to prevent locking issue. > > The existing 'vport_cfg_lock' was controlling the vport initialization, > re-initialization due to reset, and de-initialization of code flow. > In addition to controlling the above behavior it was also controlling > the parallel netdevice calls such as open/close from Linux OS, which > can happen independent of re-init or de-init of the vport(s). If first > one such as re-init or de-init is going on then the second operation > to config the netdevice with OS should not take place. The first > operation (init or de-init) takes the precedence if both are to happen > simultaneously. > > Use of single lock cause deadlock and inconsistent behavior of code > flow. E.g. when driver undergoes reset via 'idpf_init_hard_reset', it > acquires the 'vport_cfg_lock', and during this process it tries to > unregister netdevice which may call 'idpf_stop' which tries to acquire > same lock causing it to deadlock. > > To address above, add new lock 'vport_init_lock' which control the > initialization, re-initialization, and de-initialization flow. > The 'vport_cfg_lock' now exclusively controls the vport config > operations. > > Add vport config lock around 'idpf_vport_stop()' and 'idpf_vport_open()' > to protect close and open operation at the same time. > > Add vport init lock around 'idpf_sriv_configure()' to protect it from > load and removal path. To accomplish it, use existing function > as wrapper and introduce another function 'idpf_sriov_config_vfs' > which is used inside the lock. > > In idpf_remove, change 'idpf_sriov_configure' to > 'idpf_sriov_config_vfs', and move inside the init lock. > > Use these two locks in the following precedence: > 'vport_init_lock' first, then 'vport_cfg_lock'. > > Fixes: 8077c727561a ("idpf: add controlq init and reset checks") > Reviewed-by: Przemek Kitszel <przemyslaw.kits...@intel.com> > Reviewed-by: Madhu Chittim <madhu.chit...@intel.com> > Signed-off-by: Tarun K Singh <tarun.k.si...@intel.com> > --- > drivers/net/ethernet/intel/idpf/idpf.h | 25 +++++++++++++ > drivers/net/ethernet/intel/idpf/idpf_lib.c | 41 ++++++++++++++++++--- > drivers/net/ethernet/intel/idpf/idpf_main.c | 7 +++- > 3 files changed, 67 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/ethernet/intel/idpf/idpf.h > b/drivers/net/ethernet/intel/idpf/idpf.h > index 8dea2dd784af..34dbdc7d6c88 100644 > --- a/drivers/net/ethernet/intel/idpf/idpf.h > +++ b/drivers/net/ethernet/intel/idpf/idpf.h
Tested-by: Krishneil Singh <krishneil.k.si...@intel.com>