On Tue, Feb 12, 2019 at 09:12:46PM -0700, Jason Gunthorpe wrote: > From: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > > This creates a series of additional core entry points that meet the needs > of a driver like rxe, and other drivers, as it relates to their > register/unregister and netdev notifier paths. > > The existing driver code is generally full of races in this area, while > these new core routines sit on the new locking schemes and provide a > complete race free solution. > > rxe is used as an example conversion, but other drivers should be > converted as well. > > The approach uses a combination of the registration refcount (combined > with core level tracking and lookup) and a series of new lifecycle > callbacks that the driver can implement to reliably get the correct > destruction sequence. These work together with the new unregistration > entry points to allow the driver to have a robust lifetime model. > > To protect the typical asynchronous access via netdev notifiers from > racing with unregistration this adds ib_device_get_by_netdev(). It does > the lookup and holds the registration refcount under a proper core driven > locking scheme. > > usnic has already posted a patch to use this api, siw will need it, rxe is > converted here and other drivers should be adjusted as well. > > Jason Gunthorpe (10): > RDMA: Add and use rdma_for_each_port > RDMA/device: Consolidate ib_device per_port data into one place > RDMA/cache: Move the cache per-port data into the main ib_port_data > RDMA/device: Add ib_device_set_netdev() as an alternative to > get_netdev > RDMA/device: Add ib_device_get_by_netdev() > RDMA/rxe: Use ib_device_get_by_netdev() instead of open coding > RDMA/device: Provide APIs from the core code to help unregistration > RDMA/rxe: Use driver_unregister and new unregistration API > RDMA/rxe: Add ib_device_get_by_name() and use it in rxe > RDMA/rxe: Close a race after ib_register_device Applied to for-next Jason