diff mbox series

[RFC,6/7] udmabuf/uapi: Add new ioctl to create a dmabuf from PCI bar regions

Message ID 20240328083615.2662516-7-vivek.kasireddy@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/virtio: Import scanout buffers from other devices | expand

Commit Message

Kasireddy, Vivek March 28, 2024, 8:32 a.m. UTC
This new ioctl can be used by a VMM such as Qemu or other userspace
applications to create a dmabuf from a PCI device's memory regions.
The PCI device's id that the userspace app is required to provide
needs to be encoded in the format specified by the following macro
(defined in include/linux/pci.h):
define PCI_DEVID(bus, devfn)	((((u16)(bus)) << 8) | (devfn))

where devfn is defined (in include/uapi/linux/pci.h) as
define PCI_DEVFN(slot, func)	((((slot) & 0x1f) << 3) | ((func) & 0x07))

In addition to the devid, the userspace needs to include the
offsets and sizes and also the bar number as part of this request.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 include/uapi/linux/udmabuf.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/uapi/linux/udmabuf.h b/include/uapi/linux/udmabuf.h
index 46b6532ed855..16fe41fdc4b9 100644
--- a/include/uapi/linux/udmabuf.h
+++ b/include/uapi/linux/udmabuf.h
@@ -15,7 +15,15 @@  struct udmabuf_create {
 };
 
 struct udmabuf_create_item {
-	__u32 memfd;
+	union {
+		struct {
+			__u32 memfd;
+		};
+		struct {
+			__u16 devid;
+			__u16 bar;
+		};
+	};
 	__u32 __pad;
 	__u64 offset;
 	__u64 size;
@@ -29,5 +37,6 @@  struct udmabuf_create_list {
 
 #define UDMABUF_CREATE       _IOW('u', 0x42, struct udmabuf_create)
 #define UDMABUF_CREATE_LIST  _IOW('u', 0x43, struct udmabuf_create_list)
+#define UDMABUF_CREATE_LIST_FOR_PCIDEV  _IOW('u', 0x44, struct udmabuf_create_list)
 
 #endif /* _UAPI_LINUX_UDMABUF_H */