1 .. SPDX-License-Identifier: GPL-2.0
6 Uacce (Unified/User-space-access-intended Accelerator Framework) targets to
7 provide Shared Virtual Addressing (SVA) between accelerators and processes.
8 So accelerator can access any data structure of the main cpu.
9 This differs from the data sharing between cpu and io device, which share
10 only data content rather than address.
11 Because of the unified address, hardware and user space of process can
12 share the same virtual address in the communication.
13 Uacce takes the hardware accelerator as a heterogeneous processor, while
14 IOMMU share the same CPU page tables and as a result the same translation
19 __________________________ __________________________
21 | User application (CPU) | | Hardware Accelerator |
22 |__________________________| |__________________________|
30 |__________| |__________|
34 _______________________________________
37 |_______________________________________|
44 Uacce is the kernel module, taking charge of iommu and address sharing.
45 The user drivers and libraries are called WarpDrive.
47 The uacce device, built around the IOMMU SVA API, can access multiple
48 address spaces, including the one without PASID.
50 A virtual concept, queue, is used for the communication. It provides a
51 FIFO-like interface. And it maintains a unified address space between the
52 application and all involved hardware.
56 ___________________ ________________
58 | WarpDrive library | ------------> | user driver |
59 |___________________| |________________|
66 ___________________ _________ |
68 | Other framework | | uacce | | r/w interface
69 | crypto/nic/others | |_________| |
70 |___________________| |
72 | register | register |
75 | _________________ __________ |
77 ------------- | Device Driver | | IOMMU | |
78 |_________________| |__________| |
83 -------------------------- | Device(Hardware) |
90 Uacce uses mmap and IOMMU to play the trick.
92 Uacce creates a chrdev for every device registered to it. New queue is
93 created when user application open the chrdev. The file descriptor is used
94 as the user handle of the queue.
95 The accelerator device present itself as an Uacce object, which exports as
96 a chrdev to the user space. The user application communicates with the
97 hardware by ioctl (as control path) or share memory (as data path).
99 The control path to the hardware is via file operation, while data path is
100 via mmap space of the queue fd.
102 The queue file address space:
107 * enum uacce_qfrt: qfrt type
108 * @UACCE_QFRT_MMIO: device mmio region
109 * @UACCE_QFRT_DUS: device user share region
116 All regions are optional and differ from device type to type.
117 Each region can be mmapped only once, otherwise -EEXIST returns.
119 The device mmio region is mapped to the hardware mmio space. It is generally
120 used for doorbell or other notification to the hardware. It is not fast enough
123 The device user share region is used for share data buffer between user process
127 The Uacce register API
128 ----------------------
130 The register API is defined in uacce.h.
134 struct uacce_interface {
135 char name[UACCE_MAX_NAME_SIZE];
137 const struct uacce_ops *ops;
140 According to the IOMMU capability, uacce_interface flags can be:
145 * UACCE Device flags:
146 * UACCE_DEV_SVA: Shared Virtual Addresses
148 * Support device page faults (PCI PRI or SMMU Stall)
150 #define UACCE_DEV_SVA BIT(0)
152 struct uacce_device *uacce_alloc(struct device *parent,
153 struct uacce_interface *interface);
154 int uacce_register(struct uacce_device *uacce);
155 void uacce_remove(struct uacce_device *uacce);
157 uacce_register results can be:
159 a. If uacce module is not compiled, ERR_PTR(-ENODEV)
161 b. Succeed with the desired flags
163 c. Succeed with the negotiated flags, for example
165 uacce_interface.flags = UACCE_DEV_SVA but uacce->flags = ~UACCE_DEV_SVA
167 So user driver need check return value as well as the negotiated uacce->flags.
173 The queue file mmap space will need a user driver to wrap the communication
174 protocol. Uacce provides some attributes in sysfs for the user driver to
175 match the right accelerator accordingly.
176 More details in Documentation/ABI/testing/sysfs-driver-uacce.