linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.ibm.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>, virtualization@lists.linux.dev
Cc: "Richard Weinberger" <richard@nod.at>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Vadim Pasternak" <vadimp@nvidia.com>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Mathieu Poirier" <mathieu.poirier@linaro.org>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	linux-um@lists.infradead.org,
	platform-driver-x86@vger.kernel.org,
	linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org,
	kvm@vger.kernel.org
Subject: Re: [PATCH vhost v2 1/4] virtio: find_vqs: pass struct instead of multi parameters
Date: Mon, 11 Mar 2024 11:52:19 -0400	[thread overview]
Message-ID: <77e02ecf8b87ab83ee6e34d1118f13c8fb83353b.camel@linux.ibm.com> (raw)
In-Reply-To: <20240311072113.67673-2-xuanzhuo@linux.alibaba.com>

On Mon, 2024-03-11 at 15:21 +0800, Xuan Zhuo wrote:
> Now, we pass multi parameters to find_vqs. These parameters
> may work for transport or work for vring.
> 
> And find_vqs has multi implements in many places:
> 
>  arch/um/drivers/virtio_uml.c
>  drivers/platform/mellanox/mlxbf-tmfifo.c
>  drivers/remoteproc/remoteproc_virtio.c
>  drivers/s390/virtio/virtio_ccw.c
>  drivers/virtio/virtio_mmio.c
>  drivers/virtio/virtio_pci_legacy.c
>  drivers/virtio/virtio_pci_modern.c
>  drivers/virtio/virtio_vdpa.c
> 
> Every time, we try to add a new parameter, that is difficult.
> We must change every find_vqs implement.
> 
> One the other side, if we want to pass a parameter to vring,
> we must change the call path from transport to vring.
> Too many functions need to be changed.
> 
> So it is time to refactor the find_vqs. We pass a structure
> cfg to find_vqs(), that will be passed to vring by transport.
> 
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Acked-by: Johannes Berg <johannes@sipsolutions.net>
> ---
>  arch/um/drivers/virtio_uml.c             | 23 +++----
>  drivers/platform/mellanox/mlxbf-tmfifo.c | 13 ++--
>  drivers/remoteproc/remoteproc_virtio.c   | 28 ++++-----
>  drivers/s390/virtio/virtio_ccw.c         | 29 +++++----
>  drivers/virtio/virtio_mmio.c             | 26 ++++----
>  drivers/virtio/virtio_pci_common.c       | 60 +++++++++---------
>  drivers/virtio/virtio_pci_common.h       |  9 +--
>  drivers/virtio/virtio_pci_legacy.c       | 11 ++--
>  drivers/virtio/virtio_pci_modern.c       | 33 ++++++----
>  drivers/virtio/virtio_vdpa.c             | 36 +++++------
>  include/linux/virtio_config.h            | 77 +++++++++++++++++++---
> --
>  11 files changed, 192 insertions(+), 153 deletions(-)
> 
> 

...snip...

> 
> diff --git a/drivers/virtio/virtio_pci_modern.c
> b/drivers/virtio/virtio_pci_modern.c
> index f62b530aa3b5..b2cdf5d3824d 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -530,9 +530,7 @@ static bool vp_notify_with_data(struct virtqueue
> *vq)
>  static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
>  				  struct virtio_pci_vq_info *info,
>  				  unsigned int index,
> -				  void (*callback)(struct virtqueue
> *vq),
> -				  const char *name,
> -				  bool ctx,
> +				  struct virtio_vq_config *cfg,
>  				  u16 msix_vec)
>  {
>  
> @@ -563,8 +561,11 @@ static struct virtqueue *setup_vq(struct
> virtio_pci_device *vp_dev,
>  	/* create the vring */
>  	vq = vring_create_virtqueue(index, num,
>  				    SMP_CACHE_BYTES, &vp_dev->vdev,
> -				    true, true, ctx,
> -				    notify, callback, name);
> +				    true, true,
> +				    cfg->ctx ? cfg->ctx[cfg-
> >cfg_idx] : false,
> +				    notify,
> +				    cfg->callbacks[cfg->cfg_idx],
> +				    cfg->names[cfg->cfg_idx]);
>  	if (!vq)
>  		return ERR_PTR(-ENOMEM);
>  
> @@ -593,15 +594,11 @@ static struct virtqueue *setup_vq(struct
> virtio_pci_device *vp_dev,
>  	return ERR_PTR(err);
>  }
>  
> -static int vp_modern_find_vqs(struct virtio_device *vdev, unsigned
> int nvqs,
> -			      struct virtqueue *vqs[],
> -			      vq_callback_t *callbacks[],
> -			      const char * const names[], const bool
> *ctx,
> -			      struct irq_affinity *desc)
> +static int vp_modern_find_vqs(struct virtio_device *vdev, struct
> virtio_vq_config *cfg)
>  {
>  	struct virtio_pci_device *vp_dev = to_vp_device(vdev);
>  	struct virtqueue *vq;
> -	int rc = vp_find_vqs(vdev, nvqs, vqs, callbacks, names, ctx,
> desc);
> +	int rc = vp_find_vqs(vdev, cfg);
>  
>  	if (rc)
>  		return rc;
> @@ -739,10 +736,17 @@ static bool vp_get_shm_region(struct
> virtio_device *vdev,
>  static int vp_modern_create_avq(struct virtio_device *vdev)
>  {
>  	struct virtio_pci_device *vp_dev = to_vp_device(vdev);
> +	vq_callback_t *callbacks[] = { NULL };
> +	struct virtio_vq_config cfg = {};
>  	struct virtio_pci_admin_vq *avq;
>  	struct virtqueue *vq;
> +	const char *names[1];
>  	u16 admin_q_num;
>  
> +	cfg.nvqs = 1;
> +	cfg.callbacks = callbacks;
> +	cfg.names = names;
> +
>  	if (!virtio_has_feature(vdev, VIRTIO_F_ADMIN_VQ))
>  		return 0;
>  
> @@ -753,8 +757,11 @@ static int vp_modern_create_avq(struct
> virtio_device *vdev)
>  	avq = &vp_dev->admin_vq;
>  	avq->vq_index = vp_modern_avq_index(&vp_dev->mdev);
>  	sprintf(avq->name, "avq.%u", avq->vq_index);
> -	vq = vp_dev->setup_vq(vp_dev, &vp_dev->admin_vq.info, avq-
> >vq_index, NULL,
> -			      avq->name, NULL,
> VIRTIO_MSI_NO_VECTOR);
> +
> +	cfg.names[0] = avq->name;

While looking at the s390 changes, I observe that the above fails to
compile and is subsequently fixed in patch 2:

drivers/virtio/virtio_pci_modern.c: In function ‘vp_modern_create_avq’:
drivers/virtio/virtio_pci_modern.c:761:22: error: assignment of read-
only location ‘*cfg.names’
  761 |         cfg.names[0] = avq->name;
      |                      ^




  reply	other threads:[~2024-03-11 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11  7:21 [PATCH vhost v2 0/4] refactor the params of find_vqs() Xuan Zhuo
2024-03-11  7:21 ` [PATCH vhost v2 1/4] virtio: find_vqs: pass struct instead of multi parameters Xuan Zhuo
2024-03-11 15:52   ` Eric Farman [this message]
2024-03-11  7:21 ` [PATCH vhost v2 2/4] virtio: vring_create_virtqueue: " Xuan Zhuo
2024-03-11  7:21 ` [PATCH vhost v2 3/4] virtio: vring_new_virtqueue(): " Xuan Zhuo
2024-03-11  7:21 ` [PATCH vhost v2 4/4] virtio_ring: simplify the parameters of the funcs related to vring_create/new_virtqueue() Xuan Zhuo
2024-03-11 12:24 ` [PATCH vhost v2 0/4] refactor the params of find_vqs() Ilpo Järvinen

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=77e02ecf8b87ab83ee6e34d1118f13c8fb83353b.camel@linux.ibm.com \
    --to=farman@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=andersson@kernel.org \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jasowang@redhat.com \
    --cc=johannes@sipsolutions.net \
    --cc=kvm@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mst@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=svens@linux.ibm.com \
    --cc=vadimp@nvidia.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).