All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Weihang Li <liweihang@huawei.com>,
	dledford@redhat.com, linux-rdma@vger.kernel.org,
	linuxarm@huawei.com, selvin.xavier@broadcom.com,
	devesh.sharma@broadcom.com, somnath.kotur@broadcom.com,
	sriharsha.basavapatna@broadcom.com, bharat@chelsio.com,
	galpress@amazon.com, sleybo@amazon.com, faisal.latif@intel.com,
	shiraz.saleem@intel.com, yishaih@mellanox.com,
	mkalderon@marvell.com, aelior@marvell.com, benve@cisco.com,
	neescoba@cisco.com, pkaustub@cisco.com, aditr@vmware.com,
	pv-drivers@vmware.com, monis@mellanox.com, kamalheib1@gmail.com,
	parav@mellanox.com, markz@mellanox.com, rd.dunlab@gmail.com,
	dennis.dalessandro@intel.com
Subject: Re: [PATCH for-next] RDMA/core: Assign the name of device when allocating ib_device
Date: Mon, 27 Apr 2020 15:03:37 +0300	[thread overview]
Message-ID: <20200427120337.GD134660@unreal> (raw)
In-Reply-To: <20200427115201.GN26002@ziepe.ca>

On Mon, Apr 27, 2020 at 08:52:01AM -0300, Jason Gunthorpe wrote:
> On Mon, Apr 27, 2020 at 02:47:34PM +0300, Leon Romanovsky wrote:
> > On Sun, Apr 26, 2020 at 05:31:57PM +0800, Weihang Li wrote:
> > > If the name of a device is assigned during ib_register_device(), some
> > > drivers have to use dev_*() for printing before register device. Bring
> > > assign_name() into ib_alloc_device(), so that drivers can use ibdev_*()
> > > anywhere.
> > >
> > > Signed-off-by: Weihang Li <liweihang@huawei.com>
> > >  drivers/infiniband/core/device.c               | 85 +++++++++++++-------------
> > >  drivers/infiniband/hw/bnxt_re/main.c           |  4 +-
> > >  drivers/infiniband/hw/cxgb4/device.c           |  2 +-
> > >  drivers/infiniband/hw/cxgb4/provider.c         |  2 +-
> > >  drivers/infiniband/hw/efa/efa_main.c           |  4 +-
> > >  drivers/infiniband/hw/hns/hns_roce_hw_v1.c     |  2 +-
> > >  drivers/infiniband/hw/hns/hns_roce_hw_v2.c     |  2 +-
> > >  drivers/infiniband/hw/hns/hns_roce_main.c      |  2 +-
> > >  drivers/infiniband/hw/i40iw/i40iw_verbs.c      |  4 +-
> > >  drivers/infiniband/hw/mlx4/main.c              |  4 +-
> > >  drivers/infiniband/hw/mlx5/ib_rep.c            |  8 ++-
> > >  drivers/infiniband/hw/mlx5/main.c              | 18 +++---
> > >  drivers/infiniband/hw/mthca/mthca_main.c       |  2 +-
> > >  drivers/infiniband/hw/mthca/mthca_provider.c   |  2 +-
> > >  drivers/infiniband/hw/ocrdma/ocrdma_main.c     |  4 +-
> > >  drivers/infiniband/hw/qedr/main.c              |  4 +-
> > >  drivers/infiniband/hw/usnic/usnic_ib_main.c    |  4 +-
> > >  drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c |  4 +-
> > >  drivers/infiniband/sw/rxe/rxe.c                |  4 +-
> > >  drivers/infiniband/sw/rxe/rxe.h                |  2 +-
> > >  drivers/infiniband/sw/rxe/rxe_net.c            |  4 +-
> > >  drivers/infiniband/sw/rxe/rxe_verbs.c          |  4 +-
> > >  drivers/infiniband/sw/rxe/rxe_verbs.h          |  2 +-
> > >  include/rdma/ib_verbs.h                        |  8 +--
> > >  24 files changed, 95 insertions(+), 86 deletions(-)
> > >
> > > diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> > > index d0b3d35..30d28da 100644
> > > +++ b/drivers/infiniband/core/device.c
> > > @@ -557,9 +557,45 @@ static void rdma_init_coredev(struct ib_core_device *coredev,
> > >  	write_pnet(&coredev->rdma_net, net);
> > >  }
> > >
> > > +/*
> > > + * Assign the unique string device name and the unique device index. This is
> > > + * undone by ib_dealloc_device.
> > > + */
> > > +static int assign_name(struct ib_device *device, const char *name)
> > > +{
> > > +	static u32 last_id;
> > > +	int ret;
> > > +
> > > +	down_write(&devices_rwsem);
> > > +	/* Assign a unique name to the device */
> > > +	if (strchr(name, '%'))
> > > +		ret = alloc_name(device, name);
> > > +	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);
> > > +
> > > +	ret = xa_alloc_cyclic(&devices, &device->index, device, xa_limit_31b,
> > > +			      &last_id, GFP_KERNEL);
> > > +	if (ret > 0)
> > > +		ret = 0;
> > > +
> > > +out:
> > > +	up_write(&devices_rwsem);
> > > +	return ret;
> > > +}
> > > +
> > >  /**
> > >   * _ib_alloc_device - allocate an IB device struct
> > >   * @size:size of structure to allocate
> > > + * @name: unique string device name. This may include a '%' which will
> >
> > It looks like all drivers are setting "%" in their name and "name" can
> > be changed to be "prefix".
>
> Does hfi? I thought the name was forced there for some port swapped
> reason?

This patch doesn't touch HFI, nothing prohibits from us to make this
conversion work for all drivers except HFI and for the HFI add some
different callback. There is no need to make API harder just because
one driver needs it.

Thanks

>
> Jason

  reply	other threads:[~2020-04-27 12:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26  9:31 [PATCH for-next] RDMA/core: Assign the name of device when allocating ib_device Weihang Li
2020-04-27  8:45 ` Gal Pressman
2020-04-27  9:02   ` liweihang
2020-04-27 11:47 ` Leon Romanovsky
2020-04-27 11:52   ` Jason Gunthorpe
2020-04-27 12:03     ` Leon Romanovsky [this message]
2020-04-28  8:00       ` liweihang
2020-04-28 11:19         ` Leon Romanovsky
2020-04-28 12:39           ` liweihang
2020-04-29  8:37             ` Leon Romanovsky
2020-04-30  7:55               ` liweihang
2020-04-28  1:29   ` liweihang
2020-04-27 17:55 ` Saleem, Shiraz
2020-04-28  0:04   ` Jason Gunthorpe
2020-04-29 13:32     ` Dennis Dalessandro
2020-04-29 13:50       ` Jason Gunthorpe
2020-04-29 14:33         ` Dennis Dalessandro
2020-04-29 14:57           ` Jason Gunthorpe
2020-04-29 16:17             ` Dennis Dalessandro
2020-04-28  6:17   ` liweihang
2020-04-27 20:26 ` kbuild test robot
2020-04-27 20:26   ` kbuild test robot
2020-04-28  6:29 ` kbuild test robot
2020-04-28  6:29   ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200427120337.GD134660@unreal \
    --to=leon@kernel.org \
    --cc=aditr@vmware.com \
    --cc=aelior@marvell.com \
    --cc=benve@cisco.com \
    --cc=bharat@chelsio.com \
    --cc=dennis.dalessandro@intel.com \
    --cc=devesh.sharma@broadcom.com \
    --cc=dledford@redhat.com \
    --cc=faisal.latif@intel.com \
    --cc=galpress@amazon.com \
    --cc=jgg@ziepe.ca \
    --cc=kamalheib1@gmail.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=liweihang@huawei.com \
    --cc=markz@mellanox.com \
    --cc=mkalderon@marvell.com \
    --cc=monis@mellanox.com \
    --cc=neescoba@cisco.com \
    --cc=parav@mellanox.com \
    --cc=pkaustub@cisco.com \
    --cc=pv-drivers@vmware.com \
    --cc=rd.dunlab@gmail.com \
    --cc=selvin.xavier@broadcom.com \
    --cc=shiraz.saleem@intel.com \
    --cc=sleybo@amazon.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=sriharsha.basavapatna@broadcom.com \
    --cc=yishaih@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.