IB/{rdmavt, hfi1, qib}: Self determine driver name
Currently the HFI and QIB drivers allow the IB core to assign a unit number to the driver name string. If multiple devices exist in a system, there is a possibility that the device unit number and the IB core number will be mismatched. Fix by using the driver defined unit number to generate the device name. Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
437ff786e2
commit
5084c8ff21
|
@ -1272,6 +1272,8 @@ struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra)
|
||||||
"Could not allocate unit ID: error %d\n", -ret);
|
"Could not allocate unit ID: error %d\n", -ret);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
rvt_set_ibdev_name(&dd->verbs_dev.rdi, "%s_%d", class_name(), dd->unit);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize all locks for the device. This needs to be as early as
|
* Initialize all locks for the device. This needs to be as early as
|
||||||
* possible so locks are usable.
|
* possible so locks are usable.
|
||||||
|
|
|
@ -1844,7 +1844,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
|
||||||
struct hfi1_ibport *ibp = &ppd->ibport_data;
|
struct hfi1_ibport *ibp = &ppd->ibport_data;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int ret;
|
int ret;
|
||||||
size_t lcpysz = IB_DEVICE_NAME_MAX;
|
|
||||||
|
|
||||||
for (i = 0; i < dd->num_pports; i++)
|
for (i = 0; i < dd->num_pports; i++)
|
||||||
init_ibport(ppd + i);
|
init_ibport(ppd + i);
|
||||||
|
@ -1872,8 +1871,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
|
||||||
*/
|
*/
|
||||||
if (!ib_hfi1_sys_image_guid)
|
if (!ib_hfi1_sys_image_guid)
|
||||||
ib_hfi1_sys_image_guid = ibdev->node_guid;
|
ib_hfi1_sys_image_guid = ibdev->node_guid;
|
||||||
lcpysz = strlcpy(ibdev->name, class_name(), lcpysz);
|
|
||||||
strlcpy(ibdev->name + lcpysz, "_%d", IB_DEVICE_NAME_MAX - lcpysz);
|
|
||||||
ibdev->owner = THIS_MODULE;
|
ibdev->owner = THIS_MODULE;
|
||||||
ibdev->phys_port_cnt = dd->num_pports;
|
ibdev->phys_port_cnt = dd->num_pports;
|
||||||
ibdev->dev.parent = &dd->pcidev->dev;
|
ibdev->dev.parent = &dd->pcidev->dev;
|
||||||
|
|
|
@ -1119,6 +1119,8 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
|
||||||
"Could not allocate unit ID: error %d\n", -ret);
|
"Could not allocate unit ID: error %d\n", -ret);
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
rvt_set_ibdev_name(&dd->verbs_dev.rdi, "%s%d", "qib", dd->unit);
|
||||||
|
|
||||||
dd->int_counter = alloc_percpu(u64);
|
dd->int_counter = alloc_percpu(u64);
|
||||||
if (!dd->int_counter) {
|
if (!dd->int_counter) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
|
|
@ -1571,7 +1571,6 @@ int qib_register_ib_device(struct qib_devdata *dd)
|
||||||
if (!ib_qib_sys_image_guid)
|
if (!ib_qib_sys_image_guid)
|
||||||
ib_qib_sys_image_guid = ppd->guid;
|
ib_qib_sys_image_guid = ppd->guid;
|
||||||
|
|
||||||
strlcpy(ibdev->name, "qib%d", IB_DEVICE_NAME_MAX);
|
|
||||||
ibdev->owner = THIS_MODULE;
|
ibdev->owner = THIS_MODULE;
|
||||||
ibdev->node_guid = ppd->guid;
|
ibdev->node_guid = ppd->guid;
|
||||||
ibdev->phys_port_cnt = dd->num_pports;
|
ibdev->phys_port_cnt = dd->num_pports;
|
||||||
|
|
|
@ -419,6 +419,19 @@ struct rvt_dev_info {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rvt_set_ibdev_name - Craft an IB device name from client info
|
||||||
|
* @rdi: pointer to the client rvt_dev_info structure
|
||||||
|
* @name: client specific name
|
||||||
|
* @unit: client specific unit number.
|
||||||
|
*/
|
||||||
|
static inline void rvt_set_ibdev_name(struct rvt_dev_info *rdi,
|
||||||
|
const char *fmt, const char *name,
|
||||||
|
const int unit)
|
||||||
|
{
|
||||||
|
snprintf(rdi->ibdev.name, sizeof(rdi->ibdev.name), fmt, name, unit);
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct rvt_pd *ibpd_to_rvtpd(struct ib_pd *ibpd)
|
static inline struct rvt_pd *ibpd_to_rvtpd(struct ib_pd *ibpd)
|
||||||
{
|
{
|
||||||
return container_of(ibpd, struct rvt_pd, ibpd);
|
return container_of(ibpd, struct rvt_pd, ibpd);
|
||||||
|
|
Loading…
Reference in New Issue