Commit e349f858 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA: Fully setup the device name in ib_register_device

The current code has two copies of the device name, ibdev->dev and
dev_name(&ibdev->dev), and they are setup at different times, which is
very confusing.

Set them both up at the same time and make dev_name() the lead name, which
is the proper use of the driver core APIs. To make it very clear that the
name is not valid until registration pass it in to the
ib_register_device() call rather than messing with ibdev->name directly.

Also the reorganization now checks that dev_name is unique even if it does
not contain a %.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Acked-by: default avatarAdit Ranadive <aditr@vmware.com>
Reviewed-by: default avatarSteve Wise <swise@opengridcomputing.com>
Acked-by: default avatarDevesh Sharma <devesh.sharma@broadcom.com>
Reviewed-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
parent 46bdf777
...@@ -170,10 +170,9 @@ static struct ib_device *__ib_device_get_by_name(const char *name) ...@@ -170,10 +170,9 @@ static struct ib_device *__ib_device_get_by_name(const char *name)
return NULL; return NULL;
} }
static int alloc_name(char *name) static int alloc_name(struct ib_device *ibdev, const char *name)
{ {
unsigned long *inuse; unsigned long *inuse;
char buf[IB_DEVICE_NAME_MAX];
struct ib_device *device; struct ib_device *device;
int i; int i;
...@@ -182,24 +181,21 @@ static int alloc_name(char *name) ...@@ -182,24 +181,21 @@ static int alloc_name(char *name)
return -ENOMEM; return -ENOMEM;
list_for_each_entry(device, &device_list, core_list) { list_for_each_entry(device, &device_list, core_list) {
if (!sscanf(device->name, name, &i)) char buf[IB_DEVICE_NAME_MAX];
if (sscanf(device->name, name, &i) != 1)
continue; continue;
if (i < 0 || i >= PAGE_SIZE * 8) if (i < 0 || i >= PAGE_SIZE * 8)
continue; continue;
snprintf(buf, sizeof buf, name, i); snprintf(buf, sizeof buf, name, i);
if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX)) if (!strcmp(buf, dev_name(&device->dev)))
set_bit(i, inuse); set_bit(i, inuse);
} }
i = find_first_zero_bit(inuse, PAGE_SIZE * 8); i = find_first_zero_bit(inuse, PAGE_SIZE * 8);
free_page((unsigned long) inuse); free_page((unsigned long) inuse);
snprintf(buf, sizeof buf, name, i);
if (__ib_device_get_by_name(buf))
return -ENFILE;
strlcpy(name, buf, IB_DEVICE_NAME_MAX); return dev_set_name(&ibdev->dev, name, i);
return 0;
} }
static void ib_device_release(struct device *device) static void ib_device_release(struct device *device)
...@@ -454,9 +450,9 @@ static u32 __dev_new_index(void) ...@@ -454,9 +450,9 @@ static u32 __dev_new_index(void)
* callback for each device that is added. @device must be allocated * callback for each device that is added. @device must be allocated
* with ib_alloc_device(). * with ib_alloc_device().
*/ */
int ib_register_device(struct ib_device *device, int ib_register_device(struct ib_device *device, const char *name,
int (*port_callback)(struct ib_device *, int (*port_callback)(struct ib_device *, u8,
u8, struct kobject *)) struct kobject *))
{ {
int ret; int ret;
struct ib_client *client; struct ib_client *client;
...@@ -495,11 +491,20 @@ int ib_register_device(struct ib_device *device, ...@@ -495,11 +491,20 @@ int ib_register_device(struct ib_device *device,
mutex_lock(&device_mutex); mutex_lock(&device_mutex);
if (strchr(device->name, '%')) { if (strchr(name, '%')) {
ret = alloc_name(device->name); ret = alloc_name(device, name);
if (ret) if (ret)
goto out; goto out;
} else {
ret = dev_set_name(&device->dev, name);
if (ret)
goto out;
}
if (__ib_device_get_by_name(dev_name(&device->dev))) {
ret = -ENFILE;
goto out;
} }
strlcpy(device->name, dev_name(&device->dev), IB_DEVICE_NAME_MAX);
if (ib_device_check_mandatory(device)) { if (ib_device_check_mandatory(device)) {
ret = -EINVAL; ret = -EINVAL;
......
...@@ -1311,10 +1311,6 @@ int ib_device_register_sysfs(struct ib_device *device, ...@@ -1311,10 +1311,6 @@ int ib_device_register_sysfs(struct ib_device *device,
int ret; int ret;
int i; int i;
ret = dev_set_name(class_dev, "%s", device->name);
if (ret)
return ret;
device->groups[0] = &dev_attr_group; device->groups[0] = &dev_attr_group;
class_dev->groups = device->groups; class_dev->groups = device->groups;
......
...@@ -579,7 +579,6 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ...@@ -579,7 +579,6 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
/* ib device init */ /* ib device init */
ibdev->owner = THIS_MODULE; ibdev->owner = THIS_MODULE;
ibdev->node_type = RDMA_NODE_IB_CA; ibdev->node_type = RDMA_NODE_IB_CA;
strlcpy(ibdev->name, "bnxt_re%d", IB_DEVICE_NAME_MAX);
strlcpy(ibdev->node_desc, BNXT_RE_DESC " HCA", strlcpy(ibdev->node_desc, BNXT_RE_DESC " HCA",
strlen(BNXT_RE_DESC) + 5); strlen(BNXT_RE_DESC) + 5);
ibdev->phys_port_cnt = 1; ibdev->phys_port_cnt = 1;
...@@ -672,7 +671,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ...@@ -672,7 +671,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
ibdev->alloc_hw_stats = bnxt_re_ib_alloc_hw_stats; ibdev->alloc_hw_stats = bnxt_re_ib_alloc_hw_stats;
ibdev->driver_id = RDMA_DRIVER_BNXT_RE; ibdev->driver_id = RDMA_DRIVER_BNXT_RE;
return ib_register_device(ibdev, NULL); return ib_register_device(ibdev, "bnxt_re%d", NULL);
} }
static ssize_t show_rev(struct device *device, struct device_attribute *attr, static ssize_t show_rev(struct device *device, struct device_attribute *attr,
......
...@@ -1319,7 +1319,6 @@ int iwch_register_device(struct iwch_dev *dev) ...@@ -1319,7 +1319,6 @@ int iwch_register_device(struct iwch_dev *dev)
int i; int i;
pr_debug("%s iwch_dev %p\n", __func__, dev); pr_debug("%s iwch_dev %p\n", __func__, dev);
strlcpy(dev->ibdev.name, "cxgb3_%d", IB_DEVICE_NAME_MAX);
memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
dev->ibdev.owner = THIS_MODULE; dev->ibdev.owner = THIS_MODULE;
...@@ -1402,7 +1401,7 @@ int iwch_register_device(struct iwch_dev *dev) ...@@ -1402,7 +1401,7 @@ int iwch_register_device(struct iwch_dev *dev)
sizeof(dev->ibdev.iwcm->ifname)); sizeof(dev->ibdev.iwcm->ifname));
dev->ibdev.driver_id = RDMA_DRIVER_CXGB3; dev->ibdev.driver_id = RDMA_DRIVER_CXGB3;
ret = ib_register_device(&dev->ibdev, NULL); ret = ib_register_device(&dev->ibdev, "cxgb3_%d", NULL);
if (ret) if (ret)
goto bail1; goto bail1;
......
...@@ -535,7 +535,6 @@ void c4iw_register_device(struct work_struct *work) ...@@ -535,7 +535,6 @@ void c4iw_register_device(struct work_struct *work)
struct c4iw_dev *dev = ctx->dev; struct c4iw_dev *dev = ctx->dev;
pr_debug("c4iw_dev %p\n", dev); pr_debug("c4iw_dev %p\n", dev);
strlcpy(dev->ibdev.name, "cxgb4_%d", IB_DEVICE_NAME_MAX);
memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
memcpy(&dev->ibdev.node_guid, dev->rdev.lldi.ports[0]->dev_addr, 6); memcpy(&dev->ibdev.node_guid, dev->rdev.lldi.ports[0]->dev_addr, 6);
dev->ibdev.owner = THIS_MODULE; dev->ibdev.owner = THIS_MODULE;
...@@ -627,7 +626,7 @@ void c4iw_register_device(struct work_struct *work) ...@@ -627,7 +626,7 @@ void c4iw_register_device(struct work_struct *work)
sizeof(dev->ibdev.iwcm->ifname)); sizeof(dev->ibdev.iwcm->ifname));
dev->ibdev.driver_id = RDMA_DRIVER_CXGB4; dev->ibdev.driver_id = RDMA_DRIVER_CXGB4;
ret = ib_register_device(&dev->ibdev, NULL); ret = ib_register_device(&dev->ibdev, "cxgb4_%d", NULL);
if (ret) if (ret)
goto err_kfree_iwcm; goto err_kfree_iwcm;
......
...@@ -449,7 +449,6 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) ...@@ -449,7 +449,6 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
spin_lock_init(&iboe->lock); spin_lock_init(&iboe->lock);
ib_dev = &hr_dev->ib_dev; ib_dev = &hr_dev->ib_dev;
strlcpy(ib_dev->name, "hns_%d", IB_DEVICE_NAME_MAX);
ib_dev->owner = THIS_MODULE; ib_dev->owner = THIS_MODULE;
ib_dev->node_type = RDMA_NODE_IB_CA; ib_dev->node_type = RDMA_NODE_IB_CA;
...@@ -530,7 +529,7 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev) ...@@ -530,7 +529,7 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
ib_dev->disassociate_ucontext = hns_roce_disassociate_ucontext; ib_dev->disassociate_ucontext = hns_roce_disassociate_ucontext;
ib_dev->driver_id = RDMA_DRIVER_HNS; ib_dev->driver_id = RDMA_DRIVER_HNS;
ret = ib_register_device(ib_dev, NULL); ret = ib_register_device(ib_dev, "hns_%d", NULL);
if (ret) { if (ret) {
dev_err(dev, "ib_register_device failed!\n"); dev_err(dev, "ib_register_device failed!\n");
return ret; return ret;
......
...@@ -2752,7 +2752,6 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev ...@@ -2752,7 +2752,6 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev
i40iw_pr_err("iwdev == NULL\n"); i40iw_pr_err("iwdev == NULL\n");
return NULL; return NULL;
} }
strlcpy(iwibdev->ibdev.name, "i40iw%d", IB_DEVICE_NAME_MAX);
iwibdev->ibdev.owner = THIS_MODULE; iwibdev->ibdev.owner = THIS_MODULE;
iwdev->iwibdev = iwibdev; iwdev->iwibdev = iwibdev;
iwibdev->iwdev = iwdev; iwibdev->iwdev = iwdev;
...@@ -2897,7 +2896,7 @@ int i40iw_register_rdma_device(struct i40iw_device *iwdev) ...@@ -2897,7 +2896,7 @@ int i40iw_register_rdma_device(struct i40iw_device *iwdev)
iwibdev = iwdev->iwibdev; iwibdev = iwdev->iwibdev;
iwibdev->ibdev.driver_id = RDMA_DRIVER_I40IW; iwibdev->ibdev.driver_id = RDMA_DRIVER_I40IW;
ret = ib_register_device(&iwibdev->ibdev, NULL); ret = ib_register_device(&iwibdev->ibdev, "i40iw%d", NULL);
if (ret) if (ret)
goto error; goto error;
......
...@@ -2540,7 +2540,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) ...@@ -2540,7 +2540,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
ibdev->dev = dev; ibdev->dev = dev;
ibdev->bond_next_port = 0; ibdev->bond_next_port = 0;
strlcpy(ibdev->ib_dev.name, "mlx4_%d", IB_DEVICE_NAME_MAX);
ibdev->ib_dev.owner = THIS_MODULE; ibdev->ib_dev.owner = THIS_MODULE;
ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; ibdev->ib_dev.node_type = RDMA_NODE_IB_CA;
ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey; ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey;
...@@ -2803,7 +2802,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) ...@@ -2803,7 +2802,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
goto err_steer_free_bitmap; goto err_steer_free_bitmap;
ibdev->ib_dev.driver_id = RDMA_DRIVER_MLX4; ibdev->ib_dev.driver_id = RDMA_DRIVER_MLX4;
if (ib_register_device(&ibdev->ib_dev, NULL)) if (ib_register_device(&ibdev->ib_dev, "mlx4_%d", NULL))
goto err_diag_counters; goto err_diag_counters;
if (mlx4_ib_mad_init(ibdev)) if (mlx4_ib_mad_init(ibdev))
......
...@@ -5671,7 +5671,6 @@ void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev) ...@@ -5671,7 +5671,6 @@ void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev)
int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
{ {
struct mlx5_core_dev *mdev = dev->mdev; struct mlx5_core_dev *mdev = dev->mdev;
const char *name;
int err; int err;
int i; int i;
...@@ -5704,12 +5703,6 @@ int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) ...@@ -5704,12 +5703,6 @@ int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
if (mlx5_use_mad_ifc(dev)) if (mlx5_use_mad_ifc(dev))
get_ext_port_caps(dev); get_ext_port_caps(dev);
if (!mlx5_lag_is_active(mdev))
name = "mlx5_%d";
else
name = "mlx5_bond_%d";
strlcpy(dev->ib_dev.name, name, IB_DEVICE_NAME_MAX);
dev->ib_dev.owner = THIS_MODULE; dev->ib_dev.owner = THIS_MODULE;
dev->ib_dev.node_type = RDMA_NODE_IB_CA; dev->ib_dev.node_type = RDMA_NODE_IB_CA;
dev->ib_dev.local_dma_lkey = 0 /* not supported for now */; dev->ib_dev.local_dma_lkey = 0 /* not supported for now */;
...@@ -6122,7 +6115,13 @@ static int mlx5_ib_stage_populate_specs(struct mlx5_ib_dev *dev) ...@@ -6122,7 +6115,13 @@ static int mlx5_ib_stage_populate_specs(struct mlx5_ib_dev *dev)
int mlx5_ib_stage_ib_reg_init(struct mlx5_ib_dev *dev) int mlx5_ib_stage_ib_reg_init(struct mlx5_ib_dev *dev)
{ {
return ib_register_device(&dev->ib_dev, NULL); const char *name;
if (!mlx5_lag_is_active(dev->mdev))
name = "mlx5_%d";
else
name = "mlx5_bond_%d";
return ib_register_device(&dev->ib_dev, name, NULL);
} }
void mlx5_ib_stage_pre_ib_reg_umr_cleanup(struct mlx5_ib_dev *dev) void mlx5_ib_stage_pre_ib_reg_umr_cleanup(struct mlx5_ib_dev *dev)
......
...@@ -1198,7 +1198,6 @@ int mthca_register_device(struct mthca_dev *dev) ...@@ -1198,7 +1198,6 @@ int mthca_register_device(struct mthca_dev *dev)
if (ret) if (ret)
return ret; return ret;
strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX);
dev->ib_dev.owner = THIS_MODULE; dev->ib_dev.owner = THIS_MODULE;
dev->ib_dev.uverbs_abi_ver = MTHCA_UVERBS_ABI_VERSION; dev->ib_dev.uverbs_abi_ver = MTHCA_UVERBS_ABI_VERSION;
...@@ -1297,7 +1296,7 @@ int mthca_register_device(struct mthca_dev *dev) ...@@ -1297,7 +1296,7 @@ int mthca_register_device(struct mthca_dev *dev)
mutex_init(&dev->cap_mask_mutex); mutex_init(&dev->cap_mask_mutex);
dev->ib_dev.driver_id = RDMA_DRIVER_MTHCA; dev->ib_dev.driver_id = RDMA_DRIVER_MTHCA;
ret = ib_register_device(&dev->ib_dev, NULL); ret = ib_register_device(&dev->ib_dev, "mthca%d", NULL);
if (ret) if (ret)
return ret; return ret;
......
...@@ -3640,7 +3640,6 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev) ...@@ -3640,7 +3640,6 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
if (nesibdev == NULL) { if (nesibdev == NULL) {
return NULL; return NULL;
} }
strlcpy(nesibdev->ibdev.name, "nes%d", IB_DEVICE_NAME_MAX);
nesibdev->ibdev.owner = THIS_MODULE; nesibdev->ibdev.owner = THIS_MODULE;
nesibdev->ibdev.node_type = RDMA_NODE_RNIC; nesibdev->ibdev.node_type = RDMA_NODE_RNIC;
...@@ -3798,7 +3797,7 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev) ...@@ -3798,7 +3797,7 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev)
int i, ret; int i, ret;
nesvnic->nesibdev->ibdev.driver_id = RDMA_DRIVER_NES; nesvnic->nesibdev->ibdev.driver_id = RDMA_DRIVER_NES;
ret = ib_register_device(&nesvnic->nesibdev->ibdev, NULL); ret = ib_register_device(&nesvnic->nesibdev->ibdev, "nes%d", NULL);
if (ret) { if (ret) {
return ret; return ret;
} }
......
...@@ -116,7 +116,6 @@ static void get_dev_fw_str(struct ib_device *device, char *str) ...@@ -116,7 +116,6 @@ static void get_dev_fw_str(struct ib_device *device, char *str)
static int ocrdma_register_device(struct ocrdma_dev *dev) static int ocrdma_register_device(struct ocrdma_dev *dev)
{ {
strlcpy(dev->ibdev.name, "ocrdma%d", IB_DEVICE_NAME_MAX);
ocrdma_get_guid(dev, (u8 *)&dev->ibdev.node_guid); ocrdma_get_guid(dev, (u8 *)&dev->ibdev.node_guid);
BUILD_BUG_ON(sizeof(OCRDMA_NODE_DESC) > IB_DEVICE_NODE_DESC_MAX); BUILD_BUG_ON(sizeof(OCRDMA_NODE_DESC) > IB_DEVICE_NODE_DESC_MAX);
memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC, memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC,
...@@ -214,7 +213,7 @@ static int ocrdma_register_device(struct ocrdma_dev *dev) ...@@ -214,7 +213,7 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
dev->ibdev.post_srq_recv = ocrdma_post_srq_recv; dev->ibdev.post_srq_recv = ocrdma_post_srq_recv;
} }
dev->ibdev.driver_id = RDMA_DRIVER_OCRDMA; dev->ibdev.driver_id = RDMA_DRIVER_OCRDMA;
return ib_register_device(&dev->ibdev, NULL); return ib_register_device(&dev->ibdev, "ocrdma%d", NULL);
} }
static int ocrdma_alloc_resources(struct ocrdma_dev *dev) static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
......
...@@ -170,8 +170,6 @@ static int qedr_register_device(struct qedr_dev *dev) ...@@ -170,8 +170,6 @@ static int qedr_register_device(struct qedr_dev *dev)
{ {
int rc; int rc;
strlcpy(dev->ibdev.name, "qedr%d", IB_DEVICE_NAME_MAX);
dev->ibdev.node_guid = dev->attr.node_guid; dev->ibdev.node_guid = dev->attr.node_guid;
memcpy(dev->ibdev.node_desc, QEDR_NODE_DESC, sizeof(QEDR_NODE_DESC)); memcpy(dev->ibdev.node_desc, QEDR_NODE_DESC, sizeof(QEDR_NODE_DESC));
dev->ibdev.owner = THIS_MODULE; dev->ibdev.owner = THIS_MODULE;
...@@ -264,7 +262,7 @@ static int qedr_register_device(struct qedr_dev *dev) ...@@ -264,7 +262,7 @@ static int qedr_register_device(struct qedr_dev *dev)
dev->ibdev.get_dev_fw_str = qedr_get_dev_fw_str; dev->ibdev.get_dev_fw_str = qedr_get_dev_fw_str;
dev->ibdev.driver_id = RDMA_DRIVER_QEDR; dev->ibdev.driver_id = RDMA_DRIVER_QEDR;
return ib_register_device(&dev->ibdev, NULL); return ib_register_device(&dev->ibdev, "qedr%d", NULL);
} }
/* This function allocates fast-path status block memory */ /* This function allocates fast-path status block memory */
......
...@@ -364,7 +364,6 @@ static void *usnic_ib_device_add(struct pci_dev *dev) ...@@ -364,7 +364,6 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
us_ibdev->ib_dev.num_comp_vectors = USNIC_IB_NUM_COMP_VECTORS; us_ibdev->ib_dev.num_comp_vectors = USNIC_IB_NUM_COMP_VECTORS;
us_ibdev->ib_dev.dev.parent = &dev->dev; us_ibdev->ib_dev.dev.parent = &dev->dev;
us_ibdev->ib_dev.uverbs_abi_ver = USNIC_UVERBS_ABI_VERSION; us_ibdev->ib_dev.uverbs_abi_ver = USNIC_UVERBS_ABI_VERSION;
strlcpy(us_ibdev->ib_dev.name, "usnic_%d", IB_DEVICE_NAME_MAX);
us_ibdev->ib_dev.uverbs_cmd_mask = us_ibdev->ib_dev.uverbs_cmd_mask =
(1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
...@@ -416,7 +415,7 @@ static void *usnic_ib_device_add(struct pci_dev *dev) ...@@ -416,7 +415,7 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
us_ibdev->ib_dev.driver_id = RDMA_DRIVER_USNIC; us_ibdev->ib_dev.driver_id = RDMA_DRIVER_USNIC;
if (ib_register_device(&us_ibdev->ib_dev, NULL)) if (ib_register_device(&us_ibdev->ib_dev, "usnic_%d", NULL))
goto err_fwd_dealloc; goto err_fwd_dealloc;
usnic_fwd_set_mtu(us_ibdev->ufdev, us_ibdev->netdev->mtu); usnic_fwd_set_mtu(us_ibdev->ufdev, us_ibdev->netdev->mtu);
......
...@@ -162,7 +162,6 @@ static int pvrdma_register_device(struct pvrdma_dev *dev) ...@@ -162,7 +162,6 @@ static int pvrdma_register_device(struct pvrdma_dev *dev)
int ret = -1; int ret = -1;
int i = 0; int i = 0;
strlcpy(dev->ib_dev.name, "vmw_pvrdma%d", IB_DEVICE_NAME_MAX);
dev->ib_dev.node_guid = dev->dsr->caps.node_guid; dev->ib_dev.node_guid = dev->dsr->caps.node_guid;
dev->sys_image_guid = dev->dsr->caps.sys_image_guid; dev->sys_image_guid = dev->dsr->caps.sys_image_guid;
dev->flags = 0; dev->flags = 0;
...@@ -267,7 +266,7 @@ static int pvrdma_register_device(struct pvrdma_dev *dev) ...@@ -267,7 +266,7 @@ static int pvrdma_register_device(struct pvrdma_dev *dev)
dev->ib_dev.driver_id = RDMA_DRIVER_VMW_PVRDMA; dev->ib_dev.driver_id = RDMA_DRIVER_VMW_PVRDMA;
spin_lock_init(&dev->srq_tbl_lock); spin_lock_init(&dev->srq_tbl_lock);
ret = ib_register_device(&dev->ib_dev, NULL); ret = ib_register_device(&dev->ib_dev, "vmw_pvrdma%d", NULL);
if (ret) if (ret)
goto err_srq_free; goto err_srq_free;
......
...@@ -828,7 +828,8 @@ int rvt_register_device(struct rvt_dev_info *rdi, u32 driver_id) ...@@ -828,7 +828,8 @@ int rvt_register_device(struct rvt_dev_info *rdi, u32 driver_id)
rdi->ibdev.driver_id = driver_id; rdi->ibdev.driver_id = driver_id;
/* We are now good to announce we exist */ /* We are now good to announce we exist */
ret = ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback); ret = ib_register_device(&rdi->ibdev, dev_name(&rdi->ibdev.dev),
rdi->driver_f.port_callback);
if (ret) { if (ret) {
rvt_pr_err(rdi, "Failed to register driver with ib core.\n"); rvt_pr_err(rdi, "Failed to register driver with ib core.\n");
goto bail_mr; goto bail_mr;
......
...@@ -1159,7 +1159,6 @@ int rxe_register_device(struct rxe_dev *rxe) ...@@ -1159,7 +1159,6 @@ int rxe_register_device(struct rxe_dev *rxe)
struct ib_device *dev = &rxe->ib_dev; struct ib_device *dev = &rxe->ib_dev;
struct crypto_shash *tfm; struct crypto_shash *tfm;
strlcpy(dev->name, "rxe%d", IB_DEVICE_NAME_MAX);
strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc)); strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
dev->owner = THIS_MODULE; dev->owner = THIS_MODULE;
...@@ -1261,7 +1260,7 @@ int rxe_register_device(struct rxe_dev *rxe) ...@@ -1261,7 +1260,7 @@ int rxe_register_device(struct rxe_dev *rxe)
rxe->tfm = tfm; rxe->tfm = tfm;
dev->driver_id = RDMA_DRIVER_RXE; dev->driver_id = RDMA_DRIVER_RXE;
err = ib_register_device(dev, NULL); err = ib_register_device(dev, "rxe%d", NULL);
if (err) { if (err) {
pr_warn("%s failed with error %d\n", __func__, err); pr_warn("%s failed with error %d\n", __func__, err);
goto err1; goto err1;
......
...@@ -2625,9 +2625,9 @@ void ib_dealloc_device(struct ib_device *device); ...@@ -2625,9 +2625,9 @@ void ib_dealloc_device(struct ib_device *device);
void ib_get_device_fw_str(struct ib_device *device, char *str); void ib_get_device_fw_str(struct ib_device *device, char *str);
int ib_register_device(struct ib_device *device, int ib_register_device(struct ib_device *device, const char *name,
int (*port_callback)(struct ib_device *, int (*port_callback)(struct ib_device *, u8,
u8, struct kobject *)); struct kobject *));
void ib_unregister_device(struct ib_device *device); void ib_unregister_device(struct ib_device *device);
int ib_register_client (struct ib_client *client); int ib_register_client (struct ib_client *client);
......
...@@ -429,7 +429,14 @@ static inline void rvt_set_ibdev_name(struct rvt_dev_info *rdi, ...@@ -429,7 +429,14 @@ static inline void rvt_set_ibdev_name(struct rvt_dev_info *rdi,
const char *fmt, const char *name, const char *fmt, const char *name,
const int unit) const int unit)
{ {
snprintf(rdi->ibdev.name, sizeof(rdi->ibdev.name), fmt, name, unit); /*
* FIXME: rvt and its users want to touch the ibdev before
* registration and have things like the name work. We don't have the
* infrastructure in the core to support this directly today, hack it
* to work by setting the name manually here.
*/
dev_set_name(&rdi->ibdev.dev, fmt, name, unit);
strlcpy(rdi->ibdev.name, dev_name(&rdi->ibdev.dev), IB_DEVICE_NAME_MAX);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment