• Parvi Kaustubhi's avatar
    IB/usnic: Fix deadlock · 5bb3c1e9
    Parvi Kaustubhi authored
    There is a dead lock in usnic ib_register and netdev_notify path.
    
    	usnic_ib_discover_pf()
    	| mutex_lock(&usnic_ib_ibdev_list_lock);
    	 | usnic_ib_device_add();
    	  | ib_register_device()
    	   | usnic_ib_query_port()
    	    | mutex_lock(&us_ibdev->usdev_lock);
    	     | ib_get_eth_speed()
    	      | rtnl_lock()
    
    order of lock: &usnic_ib_ibdev_list_lock -> usdev_lock -> rtnl_lock
    
    	rtnl_lock()
    	 | usnic_ib_netdevice_event()
    	  | mutex_lock(&usnic_ib_ibdev_list_lock);
    
    order of lock: rtnl_lock -> &usnic_ib_ibdev_list_lock
    
    Solution is to use the core's lock-free ib_device_get_by_netdev() scheme
    to lookup ib_dev while handling netdev & inet events.
    Signed-off-by: default avatarParvi Kaustubhi <pkaustub@cisco.com>
    Reviewed-by: default avatarGovindarajulu Varadarajan <gvaradar@cisco.com>
    Reviewed-by: default avatarTanmay Inamdar <tinamdar@cisco.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    5bb3c1e9
usnic_ib_main.c 19.9 KB