From: Nipun Gupta <nipun.gupta@amd.com>
To: <gregkh@linuxfoundation.org>, <alex.williamson@redhat.com>,
<linux-kernel@vger.kernel.org>
Cc: <git@amd.com>, <pieter.jansen-van-vuuren@amd.com>,
<nikhil.agarwal@amd.com>, <michal.simek@amd.com>,
<abhijit.gangurde@amd.com>, Nipun Gupta <nipun.gupta@amd.com>,
Shubham Rohila <shubham.rohila@amd.com>
Subject: [PATCH v6 2/3] vfio: add bus master feature to device feature ioctl
Date: Thu, 10 Aug 2023 14:14:08 +0530 [thread overview]
Message-ID: <20230810084409.4922-2-nipun.gupta@amd.com> (raw)
In-Reply-To: <20230810084409.4922-1-nipun.gupta@amd.com>
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 v5->v6:
- Updated description of VFIO_DEVICE_FEATURE_BUS_MASTER IOCTL
- Used 0 for clear and 1 for set bus master operation
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 | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 20c804bdc09c..6858cd80d597 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -1287,6 +1287,27 @@ struct vfio_device_feature_mig_data_size {
#define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9
+/**
+ * Upon VFIO_DEVICE_FEATURE_SET, set or clear the BUS mastering for the device
+ * based on the operation specified in op flag.
+ *
+ * The functionality is incorporated for devices that needs bus master control,
+ * but the in-band device interface lacks the support. Consequently, it is not
+ * applicable to PCI devices, as bus master control for PCI devices is managed
+ * in-band through the configuration space. At present, this feature is supported
+ * only for CDX devices.
+ * When the device's BUS MASTER setting is configured as CLEAR, it will result in
+ * blocking all incoming DMA requests from the device. On the other hand, configuring
+ * the device's BUS MASTER setting as SET (enable) will grant the device the
+ * capability to perform DMA to the host memory.
+ */
+struct vfio_device_feature_bus_master {
+ __u32 op;
+#define VFIO_DEVICE_FEATURE_CLEAR_MASTER 0 /* Clear Bus Master */
+#define VFIO_DEVICE_FEATURE_SET_MASTER 1 /* Set Bus Master */
+};
+#define VFIO_DEVICE_FEATURE_BUS_MASTER 10
+
/* -------- API for Type1 VFIO IOMMU -------- */
/**
--
2.17.1
next prev parent reply other threads:[~2023-08-10 8:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 8:44 [PATCH v6 1/3] cdx: add support for bus mastering Nipun Gupta
2023-08-10 8:44 ` Nipun Gupta [this message]
2023-08-10 8:44 ` [PATCH v6 3/3] vfio-cdx: add bus mastering device feature support Nipun Gupta
2023-08-16 17:46 ` Alex Williamson
2023-08-18 8:32 ` Gupta, Nipun
2023-08-18 14:37 ` Alex Williamson
2023-08-21 10:57 ` Gupta, Nipun
2023-08-21 21:07 ` Alex Williamson
2023-08-24 10:57 ` 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=20230810084409.4922-2-nipun.gupta@amd.com \
--to=nipun.gupta@amd.com \
--cc=abhijit.gangurde@amd.com \
--cc=alex.williamson@redhat.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=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