virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eli Cohen <elic@nvidia.com>
Cc: "gdawar@amd.com" <gdawar@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"tanuj.kamde@amd.com" <tanuj.kamde@amd.com>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>
Subject: Re: [PATCH 1/5] virtio_ring: per virtqueue dma device
Date: Wed, 11 Jan 2023 08:52:34 -0500	[thread overview]
Message-ID: <20230111085210-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <DM8PR12MB5400E61C7E968AC7604556EBABFC9@DM8PR12MB5400.namprd12.prod.outlook.com>

On Wed, Jan 11, 2023 at 01:32:20PM +0000, Eli Cohen wrote:
> > From: Jason Wang <jasowang@redhat.com>
> > Sent: Wednesday, 11 January 2023 8:28
> > To: mst@redhat.com; jasowang@redhat.com
> > Cc: Eli Cohen <elic@nvidia.com>; gdawar@amd.com;
> > virtualization@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> > tanuj.kamde@amd.com
> > Subject: [PATCH 1/5] virtio_ring: per virtqueue dma device
> > 
> > This patch introduces a per virtqueue dma device. This will be used
> > for virtio devices whose virtqueue are backed by different underlayer
> > devices.
> > 
> > One example is the vDPA that where the control virtqueue could be
> > implemented through software mediation.
> > 
> > Some of the work are actually done before since the helper like
> > vring_dma_device(). This work left are:
> > 
> > - Let vring_dma_device() return the per virtqueue dma device instead
> >   of the vdev's parent.
> > - Allow passing a dma_device when creating the virtqueue through a new
> >   helper, old vring creation helper will keep using vdev's parent.
> > 
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > ---
> >  drivers/virtio/virtio_ring.c | 133 ++++++++++++++++++++++++-----------
> >  include/linux/virtio_ring.h  |  16 +++++
> >  2 files changed, 109 insertions(+), 40 deletions(-)
> > 
> > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> > index 723c4e29e1d3..41144b5246a8 100644
> > --- a/drivers/virtio/virtio_ring.c
> > +++ b/drivers/virtio/virtio_ring.c
> > @@ -202,6 +202,9 @@ struct vring_virtqueue {
> >  	/* DMA, allocation, and size information */
> >  	bool we_own_ring;
> > 
> > +	/* Device used for doing DMA */
> > +	struct device *dma_dev;
> > +
> >  #ifdef DEBUG
> >  	/* They're supposed to lock for us. */
> >  	unsigned int in_use;
> > @@ -219,7 +222,8 @@ static struct virtqueue
> > *__vring_new_virtqueue(unsigned int index,
> >  					       bool context,
> >  					       bool (*notify)(struct virtqueue *),
> >  					       void (*callback)(struct virtqueue
> > *),
> > -					       const char *name);
> > +					       const char *name,
> > +					       struct device *dma_dev);
> >  static struct vring_desc_extra *vring_alloc_desc_extra(unsigned int num);
> >  static void vring_free(struct virtqueue *_vq);
> > 
> > @@ -297,10 +301,11 @@ size_t virtio_max_dma_size(struct virtio_device
> > *vdev)
> >  EXPORT_SYMBOL_GPL(virtio_max_dma_size);
> > 
> >  static void *vring_alloc_queue(struct virtio_device *vdev, size_t size,
> > -			      dma_addr_t *dma_handle, gfp_t flag)
> > +			       dma_addr_t *dma_handle, gfp_t flag,
> > +			       struct device *dma_dev)
> >  {
> >  	if (vring_use_dma_api(vdev)) {
> > -		return dma_alloc_coherent(vdev->dev.parent, size,
> > +		return dma_alloc_coherent(dma_dev, size,
> >  					  dma_handle, flag);
> >  	} else {
> >  		void *queue = alloc_pages_exact(PAGE_ALIGN(size), flag);
> > @@ -330,10 +335,11 @@ static void *vring_alloc_queue(struct virtio_device
> > *vdev, size_t size,
> >  }
> > 
> >  static void vring_free_queue(struct virtio_device *vdev, size_t size,
> > -			     void *queue, dma_addr_t dma_handle)
> > +			     void *queue, dma_addr_t dma_handle,
> > +			     struct device *dma_dev)
> >  {
> >  	if (vring_use_dma_api(vdev))
> > -		dma_free_coherent(vdev->dev.parent, size, queue,
> > dma_handle);
> > +		dma_free_coherent(dma_dev, size, queue, dma_handle);
> >  	else
> >  		free_pages_exact(queue, PAGE_ALIGN(size));
> >  }
> > @@ -341,11 +347,11 @@ static void vring_free_queue(struct virtio_device
> > *vdev, size_t size,
> >  /*
> >   * The DMA ops on various arches are rather gnarly right now, and
> >   * making all of the arch DMA ops work on the vring device itself
> > - * is a mess.  For now, we use the parent device for DMA ops.
> > + * is a mess.
> >   */
> >  static inline struct device *vring_dma_dev(const struct vring_virtqueue *vq)
> >  {
> > -	return vq->vq.vdev->dev.parent;
> > +	return vq->dma_dev;
> >  }
> 
> How about getting rid of this function and just use vq->dma_dev?

Will make the patch even bigger than it is.
If you do patch on top pls.

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  parent reply	other threads:[~2023-01-11 13:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  6:28 [PATCH 0/5] virtio_ring: per virtqueue DMA device Jason Wang
2023-01-11  6:28 ` [PATCH 1/5] virtio_ring: per virtqueue dma device Jason Wang
     [not found]   ` <DM8PR12MB5400E61C7E968AC7604556EBABFC9@DM8PR12MB5400.namprd12.prod.outlook.com>
2023-01-11 13:52     ` Michael S. Tsirkin [this message]
     [not found]       ` <DM8PR12MB54008B92885A8971C4CFED0EABFC9@DM8PR12MB5400.namprd12.prod.outlook.com>
2023-01-11 14:54         ` Michael S. Tsirkin
     [not found]           ` <DM8PR12MB54005A89EB05BF46AD7D2DFEABFC9@DM8PR12MB5400.namprd12.prod.outlook.com>
2023-01-11 16:26             ` Michael S. Tsirkin
2023-01-11  6:28 ` [PATCH 2/5] vdpa: introduce get_vq_dma_device() Jason Wang
2023-01-11  6:28 ` [PATCH 3/5] virtio-vdpa: support per vq dma device Jason Wang
2023-01-11  6:28 ` [PATCH 4/5] vdpa: set dma mask for vDPA device Jason Wang
2023-01-11  6:28 ` [PATCH 5/5] vdpa: mlx5: support per virtqueue dma device Jason Wang
2023-01-11 12:38   ` kernel test robot
2023-01-12  2:07   ` kernel test robot
     [not found]   ` <DM8PR12MB5400D84460E084D3459B49B1ABC09@DM8PR12MB5400.namprd12.prod.outlook.com>
2023-01-16  2:49     ` Jason Wang
     [not found] ` <DM8PR12MB540054712BACEF34E065C2BBABFC9@DM8PR12MB5400.namprd12.prod.outlook.com>
2023-01-12  4:03   ` [PATCH 0/5] virtio_ring: per virtqueue DMA 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=20230111085210-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=elic@nvidia.com \
    --cc=gdawar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tanuj.kamde@amd.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).