virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: shahafs@mellanox.com, lulu@redhat.com, saugatm@xilinx.com,
	mhabets@solarflare.com, vmireyno@marvell.com,
	linux-kernel@vger.kernel.org, gdawar@xilinx.com,
	virtualization@lists.linux-foundation.org, eperezma@redhat.com,
	hanand@xilinx.com, zhangweining@ruijie.com.cn, eli@mellanox.com,
	lingshan.zhu@intel.com, rob.miller@broadcom.com
Subject: Re: [PATCH 4/4] vhost: vdpa: report iova range
Date: Wed, 5 Aug 2020 08:58:02 -0400	[thread overview]
Message-ID: <20200805085635-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20200617032947.6371-5-jasowang@redhat.com>

On Wed, Jun 17, 2020 at 11:29:47AM +0800, Jason Wang wrote:
> This patch introduces a new ioctl for vhost-vdpa device that can
> report the iova range by the device. For device that depends on
> platform IOMMU, we fetch the iova range via DOMAIN_ATTR_GEOMETRY. For
> devices that has its own DMA translation unit, we fetch it directly
> from vDPA bus operation.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  drivers/vhost/vdpa.c             | 27 +++++++++++++++++++++++++++
>  include/uapi/linux/vhost.h       |  4 ++++
>  include/uapi/linux/vhost_types.h |  5 +++++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 77a0c9fb6cc3..ad23e66cbf57 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -332,6 +332,30 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
>  
>  	return 0;
>  }
> +
> +static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
> +{
> +	struct iommu_domain_geometry geo;
> +	struct vdpa_device *vdpa = v->vdpa;
> +	const struct vdpa_config_ops *ops = vdpa->config;
> +	struct vhost_vdpa_iova_range range;
> +	struct vdpa_iova_range vdpa_range;
> +
> +	if (!ops->set_map && !ops->dma_map) {

Why not just check if (ops->get_iova_range) directly?




> +		iommu_domain_get_attr(v->domain,
> +				      DOMAIN_ATTR_GEOMETRY, &geo);
> +		range.start = geo.aperture_start;
> +		range.end = geo.aperture_end;
> +	} else {
> +		vdpa_range = ops->get_iova_range(vdpa);
> +		range.start = vdpa_range.start;
> +		range.end = vdpa_range.end;
> +	}
> +
> +	return copy_to_user(argp, &range, sizeof(range));
> +
> +}
> +
>  static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
>  				   void __user *argp)
>  {
> @@ -442,6 +466,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
>  	case VHOST_VDPA_SET_CONFIG_CALL:
>  		r = vhost_vdpa_set_config_call(v, argp);
>  		break;
> +	case VHOST_VDPA_GET_IOVA_RANGE:
> +		r = vhost_vdpa_get_iova_range(v, argp);
> +		break;
>  	default:
>  		r = vhost_dev_ioctl(&v->vdev, cmd, argp);
>  		if (r == -ENOIOCTLCMD)
> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index 0c2349612e77..850956980e27 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
> @@ -144,4 +144,8 @@
>  
>  /* Set event fd for config interrupt*/
>  #define VHOST_VDPA_SET_CONFIG_CALL	_IOW(VHOST_VIRTIO, 0x77, int)
> +
> +/* Get the valid iova range */
> +#define VHOST_VDPA_GET_IOVA_RANGE	_IOW(VHOST_VIRTIO, 0x78, \
> +					     struct vhost_vdpa_iova_range)
>  #endif
> diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h
> index 669457ce5c48..4025b5a36177 100644
> --- a/include/uapi/linux/vhost_types.h
> +++ b/include/uapi/linux/vhost_types.h
> @@ -127,6 +127,11 @@ struct vhost_vdpa_config {
>  	__u8 buf[0];
>  };
>  
> +struct vhost_vdpa_iova_range {
> +	__u64 start;
> +	__u64 end;
> +};
> +


Pls document fields. And I think first/last is a better API ...

>  /* Feature bits */
>  /* Log all write descriptors. Can be changed while device is active. */
>  #define VHOST_F_LOG_ALL 26
> -- 
> 2.20.1

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

  reply	other threads:[~2020-08-05 12:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  3:29 [PATCH 0/4] vDPA: API for reporting IOVA range Jason Wang
2020-06-17  3:29 ` [PATCH 1/4] vdpa: introduce config op to get valid iova range Jason Wang
2020-08-05 12:51   ` Michael S. Tsirkin
2020-08-06  3:25     ` Jason Wang
2020-08-06  5:54       ` Michael S. Tsirkin
     [not found]     ` <20200806120354.GA171218@mtl-vdi-166.wap.labs.mlnx>
2020-08-06 12:29       ` Michael S. Tsirkin
2020-08-07  3:23         ` Jason Wang
     [not found]         ` <20200806124354.GA172661@mtl-vdi-166.wap.labs.mlnx>
2020-08-10 12:05           ` Michael S. Tsirkin
2020-08-11  2:53             ` Jason Wang
2020-08-11  8:29               ` Michael S. Tsirkin
2020-08-12  2:02                 ` Jason Wang
     [not found]   ` <20200806121002.GA171574@mtl-vdi-166.wap.labs.mlnx>
2020-08-07  3:04     ` Jason Wang
2020-06-17  3:29 ` [PATCH 2/4] vdpa_sim: implement get_iova_range bus operation Jason Wang
2020-06-17  3:29 ` [PATCH 3/4] vdpa: get_iova_range() is mandatory for device specific DMA translation Jason Wang
2020-08-05 12:55   ` Michael S. Tsirkin
2020-08-06  3:27     ` Jason Wang
2020-06-17  3:29 ` [PATCH 4/4] vhost: vdpa: report iova range Jason Wang
2020-08-05 12:58   ` Michael S. Tsirkin [this message]
2020-08-06  3:29     ` Jason Wang
2020-08-06  5:55       ` Michael S. Tsirkin
2020-10-21 14:45 ` [PATCH 0/4] vDPA: API for reporting IOVA range Michael S. Tsirkin
2020-10-22  5:47   ` 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=20200805085635-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eli@mellanox.com \
    --cc=eperezma@redhat.com \
    --cc=gdawar@xilinx.com \
    --cc=hanand@xilinx.com \
    --cc=jasowang@redhat.com \
    --cc=lingshan.zhu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lulu@redhat.com \
    --cc=mhabets@solarflare.com \
    --cc=rob.miller@broadcom.com \
    --cc=saugatm@xilinx.com \
    --cc=shahafs@mellanox.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=vmireyno@marvell.com \
    --cc=zhangweining@ruijie.com.cn \
    /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).