[RFC 6/7] udmabuf/uapi: Add new ioctl to create a dmabuf from PCI bar regions
Vivek Kasireddy
vivek.kasireddy at intel.com
Thu Mar 28 08:32:59 UTC 2024
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 at redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
---
include/uapi/linux/udmabuf.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
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 */
--
2.43.0
More information about the dri-devel
mailing list