linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, shahafs@mellanox.com,
	lulu@redhat.com, sgarzare@redhat.com, rdunlap@infradead.org
Subject: Re: [PATCH V3 17/19] vdpa: set the virtqueue num during register
Date: Fri, 5 Feb 2021 10:27:14 -0500	[thread overview]
Message-ID: <20210205102552-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210104065503.199631-18-jasowang@redhat.com>

On Mon, Jan 04, 2021 at 02:55:01PM +0800, Jason Wang wrote:
> This patch delay the queue number setting to vDPA device
> registering. This allows us to probe the virtqueue numbers between
> device allocation and registering.
> 
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>

Conflicts with other patches in the vhost tree.
Can you rebase please?

> ---
>  drivers/vdpa/ifcvf/ifcvf_main.c   | 5 ++---
>  drivers/vdpa/mlx5/net/mlx5_vnet.c | 5 ++---
>  drivers/vdpa/vdpa.c               | 8 ++++----
>  drivers/vdpa/vdpa_sim/vdpa_sim.c  | 4 ++--
>  include/linux/vdpa.h              | 7 +++----
>  5 files changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
> index 8b4028556cb6..d65f3221d8ed 100644
> --- a/drivers/vdpa/ifcvf/ifcvf_main.c
> +++ b/drivers/vdpa/ifcvf/ifcvf_main.c
> @@ -438,8 +438,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	}
>  
>  	adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
> -				    dev, &ifc_vdpa_ops,
> -				    IFCVF_MAX_QUEUE_PAIRS * 2);
> +				    dev, &ifc_vdpa_ops);
>  	if (adapter == NULL) {
>  		IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
>  		return -ENOMEM;
> @@ -463,7 +462,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++)
>  		vf->vring[i].irq = -EINVAL;
>  
> -	ret = vdpa_register_device(&adapter->vdpa);
> +	ret = vdpa_register_device(&adapter->vdpa, IFCVF_MAX_QUEUE_PAIRS * 2);
>  	if (ret) {
>  		IFCVF_ERR(pdev, "Failed to register ifcvf to vdpa bus");
>  		goto err;
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index f1d54814db97..a1b9260bf04d 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -1958,8 +1958,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
>  	max_vqs = MLX5_CAP_DEV_VDPA_EMULATION(mdev, max_num_virtio_queues);
>  	max_vqs = min_t(u32, max_vqs, MLX5_MAX_SUPPORTED_VQS);
>  
> -	ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops,
> -				 2 * mlx5_vdpa_max_qps(max_vqs));
> +	ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops);
>  	if (IS_ERR(ndev))
>  		return PTR_ERR(ndev);
>  
> @@ -1986,7 +1985,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
>  	if (err)
>  		goto err_res;
>  
> -	err = vdpa_register_device(&mvdev->vdev);
> +	err = vdpa_register_device(&mvdev->vdev, 2 * mlx5_vdpa_max_qps(max_vqs));
>  	if (err)
>  		goto err_reg;
>  
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index a69ffc991e13..ba89238f9898 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -61,7 +61,6 @@ static void vdpa_release_dev(struct device *d)
>   * initialized but before registered.
>   * @parent: the parent device
>   * @config: the bus operations that is supported by this device
> - * @nvqs: number of virtqueues supported by this device
>   * @size: size of the parent structure that contains private data
>   *
>   * Driver should use vdpa_alloc_device() wrapper macro instead of
> @@ -72,7 +71,6 @@ static void vdpa_release_dev(struct device *d)
>   */
>  struct vdpa_device *__vdpa_alloc_device(struct device *parent,
>  					const struct vdpa_config_ops *config,
> -					int nvqs,
>  					size_t size)
>  {
>  	struct vdpa_device *vdev;
> @@ -99,7 +97,6 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
>  	vdev->index = err;
>  	vdev->config = config;
>  	vdev->features_valid = false;
> -	vdev->nvqs = nvqs;
>  
>  	err = dev_set_name(&vdev->dev, "vdpa%u", vdev->index);
>  	if (err)
> @@ -122,11 +119,14 @@ EXPORT_SYMBOL_GPL(__vdpa_alloc_device);
>   * vdpa_register_device - register a vDPA device
>   * Callers must have a succeed call of vdpa_alloc_device() before.
>   * @vdev: the vdpa device to be registered to vDPA bus
> + * @nvqs: number of virtqueues supported by this device
>   *
>   * Returns an error when fail to add to vDPA bus
>   */
> -int vdpa_register_device(struct vdpa_device *vdev)
> +int vdpa_register_device(struct vdpa_device *vdev, int nvqs)
>  {
> +	vdev->nvqs = nvqs;
> +
>  	return device_add(&vdev->dev);
>  }
>  EXPORT_SYMBOL_GPL(vdpa_register_device);
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> index 6a90fdb9cbfc..b129cb4dd013 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -357,7 +357,7 @@ static struct vdpasim *vdpasim_create(void)
>  	else
>  		ops = &vdpasim_net_config_ops;
>  
> -	vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, VDPASIM_VQ_NUM);
> +	vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops);
>  	if (!vdpasim)
>  		goto err_alloc;
>  
> @@ -393,7 +393,7 @@ static struct vdpasim *vdpasim_create(void)
>  	vringh_set_iotlb(&vdpasim->vqs[1].vring, vdpasim->iommu);
>  
>  	vdpasim->vdpa.dma_dev = dev;
> -	ret = vdpa_register_device(&vdpasim->vdpa);
> +	ret = vdpa_register_device(&vdpasim->vdpa, VDPASIM_VQ_NUM);
>  	if (ret)
>  		goto err_iommu;
>  
> diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
> index 30bc7a7223bb..d9e9d17b9083 100644
> --- a/include/linux/vdpa.h
> +++ b/include/linux/vdpa.h
> @@ -244,18 +244,17 @@ struct vdpa_config_ops {
>  
>  struct vdpa_device *__vdpa_alloc_device(struct device *parent,
>  					const struct vdpa_config_ops *config,
> -					int nvqs,
>  					size_t size);
>  
> -#define vdpa_alloc_device(dev_struct, member, parent, config, nvqs)   \
> +#define vdpa_alloc_device(dev_struct, member, parent, config)   \
>  			  container_of(__vdpa_alloc_device( \
> -				       parent, config, nvqs, \
> +				       parent, config, \
>  				       sizeof(dev_struct) + \
>  				       BUILD_BUG_ON_ZERO(offsetof( \
>  				       dev_struct, member))), \
>  				       dev_struct, member)
>  
> -int vdpa_register_device(struct vdpa_device *vdev);
> +int vdpa_register_device(struct vdpa_device *vdev, int nvqs);
>  void vdpa_unregister_device(struct vdpa_device *vdev);
>  
>  /**
> -- 
> 2.25.1


  reply	other threads:[~2021-02-05 23:38 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-04  6:54 [PATCH V3 00/19] vDPA driver for virtio-pci device Jason Wang
2021-01-04  6:54 ` [PATCH V3 01/19] virtio-pci: do not access iomem via struct virtio_pci_device directly Jason Wang
2021-01-04  6:54 ` [PATCH V3 02/19] virtio-pci: split out modern device Jason Wang
2021-01-04  6:54 ` [PATCH V3 03/19] virtio-pci-modern: factor out modern device initialization logic Jason Wang
2021-01-04  6:54 ` [PATCH V3 04/19] virtio-pci-modern: introduce vp_modern_remove() Jason Wang
2021-01-04  6:54 ` [PATCH V3 05/19] virtio-pci-modern: introduce helper to set config vector Jason Wang
2021-01-04  6:54 ` [PATCH V3 06/19] virtio-pci-modern: introduce helpers for setting and getting status Jason Wang
2021-01-04  6:54 ` [PATCH V3 07/19] virtio-pci-modern: introduce helpers for setting and getting features Jason Wang
2021-01-04  6:54 ` [PATCH V3 08/19] virtio-pci-modern: introduce vp_modern_generation() Jason Wang
2021-01-04  6:54 ` [PATCH V3 09/19] virtio-pci-modern: introduce vp_modern_set_queue_vector() Jason Wang
2021-01-04  6:54 ` [PATCH V3 10/19] virtio-pci-modern: introduce vp_modern_queue_address() Jason Wang
2021-01-04  6:54 ` [PATCH V3 11/19] virtio-pci-modern: introduce helper to set/get queue_enable Jason Wang
2021-01-04  6:54 ` [PATCH V3 12/19] virtio-pci-modern: introduce helper for setting/geting queue size Jason Wang
2021-01-04  6:54 ` [PATCH V3 13/19] virtio-pci-modern: introduce helper for getting queue nums Jason Wang
2021-01-04  6:54 ` [PATCH V3 14/19] virtio-pci-modern: introduce helper to get notification offset Jason Wang
2021-01-04  6:54 ` [PATCH V3 15/19] virito-pci-modern: rename map_capability() to vp_modern_map_capability() Jason Wang
2021-01-04  6:55 ` [PATCH V3 16/19] virtio-pci: introduce modern device module Jason Wang
2021-02-05 15:34   ` Michael S. Tsirkin
2021-02-08  5:42     ` Jason Wang
2021-02-08 12:04       ` Michael S. Tsirkin
2021-02-09  3:29         ` Jason Wang
2021-02-09  9:23           ` Michael S. Tsirkin
2021-02-09 10:15   ` Naresh Kamboju
2021-02-10  4:38     ` Jason Wang
2021-02-09 14:20   ` Michael S. Tsirkin
2021-02-10  4:44     ` Jason Wang
2021-02-10 12:35       ` Michael S. Tsirkin
2021-02-18  5:49         ` Jason Wang
2021-02-12 20:14   ` Guenter Roeck
2021-02-19  8:31     ` Jason Wang
2021-01-04  6:55 ` [PATCH V3 17/19] vdpa: set the virtqueue num during register Jason Wang
2021-02-05 15:27   ` Michael S. Tsirkin [this message]
2021-02-08  4:16     ` Jason Wang
2021-01-04  6:55 ` [PATCH V3 18/19] virtio_vdpa: don't warn when fail to disable vq Jason Wang
2021-02-05 15:24   ` Michael S. Tsirkin
2021-02-08  4:15     ` Jason Wang
2021-01-04  6:55 ` [PATCH V3 19/19] vdpa: introduce virtio pci driver Jason Wang
2021-02-02  3:53 ` [PATCH V3 00/19] vDPA driver for virtio-pci device Jason Wang

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=20210205102552-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lulu@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=sgarzare@redhat.com \
    --cc=shahafs@mellanox.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).