On Tue, Feb 25, 2020 at 6:46 PM Jason Gunthorpe <jgg@xxxxxxxxxxxx> wrote: > > On Tue, Feb 25, 2020 at 09:40:42AM +0530, Selvin Xavier wrote: > > On Mon, Feb 24, 2020 at 7:13 PM Jason Gunthorpe <jgg@xxxxxxxxxxxx> wrote: > > > > > > On Mon, Feb 24, 2020 at 02:49:55AM -0800, Selvin Xavier wrote: > > > > > > > > @@ -1785,32 +1777,23 @@ static int __init bnxt_re_mod_init(void) > > > > > > > > static void __exit bnxt_re_mod_exit(void) > > > > { > > > > - struct bnxt_re_dev *rdev, *next; > > > > - LIST_HEAD(to_be_deleted); > > > > + struct bnxt_re_dev *rdev; > > > > > > > > + flush_workqueue(bnxt_re_wq); > > > > > > What is this for? Usually flushing a work queue before preventing new > > > work from queueing (ie via unregister) is racy. > > To flush out any netdev events scheduled to be handled by > > bnxt_re_task. Mainly to wait for > > case where we are in the middle of NETDEV_REGISTER event handled from > > bnxt_re_task. > > Then the netdev notifer should be unregistered before doing the flush. > Agree that the netdev notifier should be unregistered before invoking ib_unregister_driver so that new device additions are prevented. I will move the unregister code to the beginning of the mod_exit. But still we have to flush the bnxt_re_wq work queue. bnxt_re_task work is scheduled from netdev notifier. We need to make sure that there are no pending work before proceeding with unregister. I will modify the code to unregister notifier and then delete bnxt_re_wq workqueue before calling ib_unregister_driver. > Jason