• Parav Pandit's avatar
    IB/core: Let IB core distribute cache update events · 6b57cea9
    Parav Pandit authored
    Currently when the low level driver notifies Pkey, GID, and port change
    events they are notified to the registered handlers in the order they are
    registered.
    
    IB core and other ULPs such as IPoIB are interested in GID, LID, Pkey
    change events.
    
    Since all GID queries done by ULPs are serviced by IB core, and the IB
    core deferes cache updates to a work queue, it is possible for other
    clients to see stale cache data when they handle their own events.
    
    For example, the below call tree shows how ipoib will call
    rdma_query_gid() concurrently with the update to the cache sitting in the
    WQ.
    
    mlx5_ib_handle_event()
      ib_dispatch_event()
        ib_cache_event()
           queue_work() -> slow cache update
    
        [..]
        ipoib_event()
         queue_work()
           [..]
           work handler
             ipoib_ib_dev_flush_light()
               __ipoib_ib_dev_flush()
                  ipoib_dev_addr_changed_valid()
                    rdma_query_gid() <- Returns old GID, cache not updated.
    
    Move all the event dispatch to a work queue so that the cache update is
    always done before any clients are notified.
    
    Fixes: f35faa4b ("IB/core: Simplify ib_query_gid to always refer to cache")
    Link: https://lore.kernel.org/r/20191212113024.336702-3-leon@kernel.orgSigned-off-by: default avatarParav Pandit <parav@mellanox.com>
    Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
    Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
    6b57cea9
device.c 73.8 KB