From: Alex Williamson <alex.williamson@redhat.com>
To: Nipun Gupta <nipun.gupta@amd.com>
Cc: <gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>,
<git@amd.com>, <pieter.jansen-van-vuuren@amd.com>,
<nikhil.agarwal@amd.com>, <michal.simek@amd.com>,
<abhijit.gangurde@amd.com>,
Shubham Rohila <shubham.rohila@amd.com>
Subject: Re: [PATCH v5 2/3] vfio: add bus master feature to device feature ioctl
Date: Thu, 3 Aug 2023 16:00:16 -0600 [thread overview]
Message-ID: <20230803160016.5b299ae7.alex.williamson@redhat.com> (raw)
In-Reply-To: <20230803143253.7817-2-nipun.gupta@amd.com>
On Thu, 3 Aug 2023 20:02:52 +0530
Nipun Gupta <nipun.gupta@amd.com> wrote:
> add bus mastering control to VFIO_DEVICE_FEATURE IOCTL. The VFIO user
> can use this feature to enable or disable the Bus Mastering of a
> device bound to VFIO.
>
> Co-developed-by: Shubham Rohila <shubham.rohila@amd.com>
> Signed-off-by: Shubham Rohila <shubham.rohila@amd.com>
> Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>
>
> Changes in v5:
> - This patch is newly added which proposes a new flag
> VFIO_DEVICE_FEATURE_BUS_MASTER in VFIO_DEVICE_FEATURE IOCTL.
>
> ---
> include/uapi/linux/vfio.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index 20c804bdc09c..05350a2f1eab 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -1287,6 +1287,22 @@ struct vfio_device_feature_mig_data_size {
>
> #define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9
>
> +/**
> + * Upon VFIO_DEVICE_FEATURE_SET, allow the BUS mastering for the device to be
> + * set or clear based on the operation specified in op flag.
> + *
> + * If the BUS MASTER of the device is configured to CLEAR,
> + * all the incoming DMA from the device will be blocked.
> + * If the BUS MASTER of the device is configured to SET (enable),
> + * device would be able to do DMA to host memory.
CDX is clearly not the only bus that has the concept of controlling a
device's ability to perform DMA, so I'm concerned about this
description. For example someone with no prior vfio-pci experience
might be confused reading the uAPI and then not having support for this
feature in vfio-pci.
One option would be to make this CDX specific through the name, ie.
VFIO_DEVICE_FEATURE_CDX_BUS_MASTER, but maybe it's sufficient to leave
it general but explain here that this is only implemented for devices
which require bus master control and have no means in the in-band
device interface to provide that control. Going on to state that PCI
bus master is controlled in-band through config space and that this is
initially only provided for CDX devices would be useful. Of course the
PROBE interface can be used to determine if this is available for a
given device.
> + */
> +struct vfio_device_feature_bus_master {
> + __u32 op;
> +#define VFIO_DEVICE_FEATURE_SET_MASTER 0 /* Set Bus Master */
> +#define VFIO_DEVICE_FEATURE_CLEAR_MASTER 1 /* Clear Bus Master */
Ultimately it doesn't matter, but this is a strange choice, set = 0,
clear = 1. I think the reverse would be better for raw debugging.
Thanks,
Alex
> +};
> +#define VFIO_DEVICE_FEATURE_BUS_MASTER 9
> +
> /* -------- API for Type1 VFIO IOMMU -------- */
>
> /**
next prev parent reply other threads:[~2023-08-03 22:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 14:32 [PATCH v5 1/3] cdx: add support for bus mastering Nipun Gupta
2023-08-03 14:32 ` [PATCH v5 2/3] vfio: add bus master feature to device feature ioctl Nipun Gupta
2023-08-03 22:00 ` Alex Williamson [this message]
2023-08-08 10:39 ` Gupta, Nipun
2023-08-03 14:32 ` [PATCH v5 3/3] vfio-cdx: add bus mastering device feature support Nipun Gupta
2023-08-03 22:17 ` Alex Williamson
2023-08-08 10:49 ` Gupta, Nipun
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=20230803160016.5b299ae7.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=abhijit.gangurde@amd.com \
--cc=git@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=nikhil.agarwal@amd.com \
--cc=nipun.gupta@amd.com \
--cc=pieter.jansen-van-vuuren@amd.com \
--cc=shubham.rohila@amd.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