Re: [PATCH rdma-next 3/3] RDMA/hns: Modify hns RoCE device's name

From: Jason Gunthorpe
Date: Fri Nov 23 2018 - 15:47:24 EST


On Fri, Nov 23, 2018 at 11:14:25PM +0800, Wei Hu (Xavier) wrote:
> This patch modifies the name of hns RoCE device's name in order
> to ensure that the name is consistent before and after reset.
>
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@xxxxxxxxxx>
> drivers/infiniband/hw/hns/hns_roce_device.h | 1 +
> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 +++
> drivers/infiniband/hw/hns/hns_roce_main.c | 4 +++-
> 3 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
> index 259977b..a8cfe76 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_device.h
> @@ -954,6 +954,7 @@ struct hns_roce_dev {
> struct pci_dev *pci_dev;
> struct device *dev;
> struct hns_roce_uar priv_uar;
> + char name[IB_DEVICE_NAME_MAX];
> const char *irq_names[HNS_ROCE_MAX_IRQ_NUM];
> spinlock_t sm_lock;
> spinlock_t bt_cmd_lock;
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> index 1d639a0..678c7ec 100644
> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> @@ -6110,6 +6110,9 @@ static int hns_roce_hw_v2_get_cfg(struct hns_roce_dev *hr_dev,
> hr_dev->irq[i] = pci_irq_vector(handle->pdev,
> i + handle->rinfo.base_vector);
>
> + snprintf(hr_dev->name, IB_DEVICE_NAME_MAX, "hns%s",
> + handle->rinfo.netdev->name);

Why is this making up its own driver name? How is this avoiding
colliding with an existing name?

This is very dangerous since we now have device renaming, the driver
could fail to load with no recovery.

Jason