On Wed, Jun 05, 2019 at 02:39:24PM -0300, Jason Gunthorpe wrote: > From: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > > No reason for every driver to emit code to set this, just make it part of > the driver's existing static const ops structure. > > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > --- > drivers/infiniband/core/device.c | 12 +++++++++--- > drivers/infiniband/core/uverbs_uapi.c | 2 +- > drivers/infiniband/hw/bnxt_re/main.c | 3 ++- > drivers/infiniband/hw/cxgb3/iwch_provider.c | 3 ++- > drivers/infiniband/hw/cxgb4/provider.c | 3 ++- > drivers/infiniband/hw/efa/efa_main.c | 3 ++- > drivers/infiniband/hw/hfi1/verbs.c | 4 +++- > drivers/infiniband/hw/hns/hns_roce_main.c | 3 ++- > drivers/infiniband/hw/i40iw/i40iw_verbs.c | 3 ++- > drivers/infiniband/hw/mlx4/main.c | 3 ++- > drivers/infiniband/hw/mlx5/main.c | 3 ++- > drivers/infiniband/hw/mthca/mthca_provider.c | 3 ++- > drivers/infiniband/hw/nes/nes_verbs.c | 3 ++- > drivers/infiniband/hw/ocrdma/ocrdma_main.c | 3 ++- > drivers/infiniband/hw/qedr/main.c | 3 ++- > drivers/infiniband/hw/qib/qib_verbs.c | 4 +++- > drivers/infiniband/hw/usnic/usnic_ib_main.c | 3 ++- > drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 3 ++- > drivers/infiniband/sw/rdmavt/vt.c | 3 +-- > drivers/infiniband/sw/rxe/rxe_verbs.c | 3 ++- > include/rdma/ib_verbs.h | 3 ++- > include/rdma/rdma_vt.h | 2 +- > 22 files changed, 50 insertions(+), 25 deletions(-) > > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c > index 29f7b15c81d946..021eb68230270e 100644 > --- a/drivers/infiniband/core/device.c > +++ b/drivers/infiniband/core/device.c > @@ -375,7 +375,7 @@ struct ib_device *ib_device_get_by_name(const char *name, > down_read(&devices_rwsem); > device = __ib_device_get_by_name(name); > if (device && driver_id != RDMA_DRIVER_UNKNOWN && > - device->driver_id != driver_id) > + device->ops.driver_id != driver_id) > device = NULL; > > if (device) { > @@ -1479,7 +1479,7 @@ void ib_unregister_driver(enum rdma_driver_id driver_id) > > down_read(&devices_rwsem); > xa_for_each (&devices, index, ib_dev) { > - if (ib_dev->driver_id != driver_id) > + if (ib_dev->ops.driver_id != driver_id) > continue; > > get_device(&ib_dev->dev); > @@ -2039,7 +2039,7 @@ struct ib_device *ib_device_get_by_netdev(struct net_device *ndev, > (uintptr_t)ndev) { > if (rcu_access_pointer(cur->netdev) == ndev && > (driver_id == RDMA_DRIVER_UNKNOWN || > - cur->ib_dev->driver_id == driver_id) && > + cur->ib_dev->ops.driver_id == driver_id) && > ib_device_try_get(cur->ib_dev)) { > res = cur->ib_dev; > break; > @@ -2344,6 +2344,12 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) > > #define SET_OBJ_SIZE(ptr, name) SET_DEVICE_OP(ptr, size_##name) > > + if (ops->driver_id != RDMA_DRIVER_UNKNOWN) { > + WARN_ON(dev_ops->driver_id != RDMA_DRIVER_UNKNOWN && > + dev_ops->driver_id != ops->driver_id); > + dev_ops->driver_id = ops->driver_id; > + } I prefer to see WARN() and now WARN_ON(), it allows more easily correlate some randomly compiled code with upstream version. Other than that, Reviewed-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>