Skip to content

Commit 015d239

Browse files
Kenneth Leeherbertx
authored andcommitted
uacce: add uacce driver
Uacce (Unified/User-space-access-intended Accelerator Framework) targets to provide Shared Virtual Addressing (SVA) between accelerators and processes. So accelerator can access any data structure of the main cpu. This differs from the data sharing between cpu and io device, which share only data content rather than address. Since unified address, hardware and user space of process can share the same virtual address in the communication. Uacce create a chrdev for every registration, the queue is allocated to the process when the chrdev is opened. Then the process can access the hardware resource by interact with the queue file. By mmap the queue file space to user space, the process can directly put requests to the hardware without syscall to the kernel space. The IOMMU core only tracks mm<->device bonds at the moment, because it only needs to handle IOTLB invalidation and PASID table entries. However uacce needs a finer granularity since multiple queues from the same device can be bound to an mm. When the mm exits, all bound queues must be stopped so that the IOMMU can safely clear the PASID table entry and reallocate the PASID. An intermediate struct uacce_mm links uacce devices and queues. Note that an mm may be bound to multiple devices but an uacce_mm structure only ever belongs to a single device, because we don't need anything more complex (if multiple devices are bound to one mm, then we'll create one uacce_mm for each bond). uacce_device --+-- uacce_mm --+-- uacce_queue | '-- uacce_queue | '-- uacce_mm --+-- uacce_queue +-- uacce_queue '-- uacce_queue Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Kenneth Lee <liguozhu@hisilicon.com> Signed-off-by: Zaibo Xu <xuzaibo@huawei.com> Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent aa017ab commit 015d239

8 files changed

Lines changed: 872 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
What: /sys/class/uacce/<dev_name>/api
2+
Date: Feb 2020
3+
KernelVersion: 5.7
4+
Contact: linux-accelerators@lists.ozlabs.org
5+
Description: Api of the device
6+
Can be any string and up to userspace to parse.
7+
Application use the api to match the correct driver
8+
9+
What: /sys/class/uacce/<dev_name>/flags
10+
Date: Feb 2020
11+
KernelVersion: 5.7
12+
Contact: linux-accelerators@lists.ozlabs.org
13+
Description: Attributes of the device, see UACCE_DEV_xxx flag defined in uacce.h
14+
15+
What: /sys/class/uacce/<dev_name>/available_instances
16+
Date: Feb 2020
17+
KernelVersion: 5.7
18+
Contact: linux-accelerators@lists.ozlabs.org
19+
Description: Available instances left of the device
20+
Return -ENODEV if uacce_ops get_available_instances is not provided
21+
22+
What: /sys/class/uacce/<dev_name>/algorithms
23+
Date: Feb 2020
24+
KernelVersion: 5.7
25+
Contact: linux-accelerators@lists.ozlabs.org
26+
Description: Algorithms supported by this accelerator, separated by new line.
27+
Can be any string and up to userspace to parse.
28+
29+
What: /sys/class/uacce/<dev_name>/region_mmio_size
30+
Date: Feb 2020
31+
KernelVersion: 5.7
32+
Contact: linux-accelerators@lists.ozlabs.org
33+
Description: Size (bytes) of mmio region queue file
34+
35+
What: /sys/class/uacce/<dev_name>/region_dus_size
36+
Date: Feb 2020
37+
KernelVersion: 5.7
38+
Contact: linux-accelerators@lists.ozlabs.org
39+
Description: Size (bytes) of dus region queue file

‎drivers/misc/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,4 +480,5 @@ source "drivers/misc/cxl/Kconfig"
480480
source "drivers/misc/ocxl/Kconfig"
481481
source "drivers/misc/cardreader/Kconfig"
482482
source "drivers/misc/habanalabs/Kconfig"
483+
source "drivers/misc/uacce/Kconfig"
483484
endmenu

‎drivers/misc/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ obj-$(CONFIG_OCXL) += ocxl/
5656
obj-y += cardreader/
5757
obj-$(CONFIG_PVPANIC) += pvpanic.o
5858
obj-$(CONFIG_HABANA_AI) += habanalabs/
59+
obj-$(CONFIG_UACCE) += uacce/
5960
obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o

‎drivers/misc/uacce/Kconfig‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
config UACCE
2+
tristate "Accelerator Framework for User Land"
3+
depends on IOMMU_API
4+
help
5+
UACCE provides interface for the user process to access the hardware
6+
without interaction with the kernel space in data path.
7+
8+
The user-space interface is described in
9+
include/uapi/misc/uacce/uacce.h
10+
11+
See Documentation/misc-devices/uacce.rst for more details.
12+
13+
If you don't know what to do here, say N.

‎drivers/misc/uacce/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
obj-$(CONFIG_UACCE) += uacce.o

0 commit comments

Comments
 (0)