From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, rob.miller@broadcom.com,
lingshan.zhu@intel.com, eperezma@redhat.com, lulu@redhat.com,
shahafs@mellanox.com, hanand@xilinx.com, mhabets@solarflare.com,
gdawar@xilinx.com, saugatm@xilinx.com, vmireyno@marvell.com,
zhangweining@ruijie.com.cn, eli@mellanox.com
Subject: Re: [PATCH 4/4] vhost: vdpa: report iova range
Date: Thu, 6 Aug 2020 11:29:16 +0800 [thread overview]
Message-ID: <357f681b-fdee-cc04-3cf3-04035c555893@redhat.com> (raw)
In-Reply-To: <20200805085635-mutt-send-email-mst@kernel.org>
On 2020/8/5 下午8:58, Michael S. Tsirkin wrote:
> 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?
Because set_map || dma_ops is a hint that the device has its own DMA
translation logic.
Device without get_iova_range does not necessarily meant it use IOMMU
driver.
Thanks
>
>
>
>
>> + 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
next prev parent reply other threads:[~2020-08-06 3:29 UTC|newest]
Thread overview: 25+ 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
2020-08-06 12:03 ` Eli Cohen
2020-08-06 12:29 ` Michael S. Tsirkin
2020-08-06 12:43 ` Eli Cohen
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
2020-08-07 3:23 ` Jason Wang
2020-08-06 12:10 ` Eli Cohen
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
2020-08-06 3:29 ` Jason Wang [this message]
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=357f681b-fdee-cc04-3cf3-04035c555893@redhat.com \
--to=jasowang@redhat.com \
--cc=eli@mellanox.com \
--cc=eperezma@redhat.com \
--cc=gdawar@xilinx.com \
--cc=hanand@xilinx.com \
--cc=lingshan.zhu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lulu@redhat.com \
--cc=mhabets@solarflare.com \
--cc=mst@redhat.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
all inboxes | Powered by JetHome®