Skip to content

Commit b71121b

Browse files
shirazsaleemdledford
authored andcommitted
i40iw: Receive notification events correctly
Device notifications are not received after the first interface is closed; since there is an unregister for notifications on every interface close. Correct this by unregistering for device notifications only when the last interface is closed. Also, make all operations on the i40iw_notifiers_registered atomic as it can be read/modified concurrently. Fixes: 8e06af7 ("i40iw: add main, hdr, status") Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 866e0f4 commit b71121b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/infiniband/hw/i40iw/i40iw_main.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static struct notifier_block i40iw_net_notifier = {
100100
.notifier_call = i40iw_net_event
101101
};
102102

103-
static int i40iw_notifiers_registered;
103+
static atomic_t i40iw_notifiers_registered;
104104

105105
/**
106106
* i40iw_find_i40e_handler - find a handler given a client info
@@ -1342,12 +1342,11 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev,
13421342
*/
13431343
static void i40iw_register_notifiers(void)
13441344
{
1345-
if (!i40iw_notifiers_registered) {
1345+
if (atomic_inc_return(&i40iw_notifiers_registered) == 1) {
13461346
register_inetaddr_notifier(&i40iw_inetaddr_notifier);
13471347
register_inet6addr_notifier(&i40iw_inetaddr6_notifier);
13481348
register_netevent_notifier(&i40iw_net_notifier);
13491349
}
1350-
i40iw_notifiers_registered++;
13511350
}
13521351

13531352
/**
@@ -1429,8 +1428,7 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev, bool reset, bool del
14291428
i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx);
14301429
/* fallthrough */
14311430
case INET_NOTIFIER:
1432-
if (i40iw_notifiers_registered > 0) {
1433-
i40iw_notifiers_registered--;
1431+
if (!atomic_dec_return(&i40iw_notifiers_registered)) {
14341432
unregister_netevent_notifier(&i40iw_net_notifier);
14351433
unregister_inetaddr_notifier(&i40iw_inetaddr_notifier);
14361434
unregister_inet6addr_notifier(&i40iw_inetaddr6_notifier);

0 commit comments

Comments
 (0)