Skip to content

Commit

Permalink
uacce: add uacce driver
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Jonathan Cameron <[email protected]>
Signed-off-by: Kenneth Lee <[email protected]>
Signed-off-by: Zaibo Xu <[email protected]>
Signed-off-by: Zhou Wang <[email protected]>
Signed-off-by: Jean-Philippe Brucker <[email protected]>
Signed-off-by: Zhangfei Gao <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Kenneth Lee authored and herbertx committed Feb 22, 2020
1 parent aa017ab commit 015d239
Show file tree
Hide file tree
Showing 8 changed files with 872 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Documentation/ABI/testing/sysfs-driver-uacce
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
What: /sys/class/uacce/<dev_name>/api
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Api of the device
Can be any string and up to userspace to parse.
Application use the api to match the correct driver

What: /sys/class/uacce/<dev_name>/flags
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Attributes of the device, see UACCE_DEV_xxx flag defined in uacce.h

What: /sys/class/uacce/<dev_name>/available_instances
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Available instances left of the device
Return -ENODEV if uacce_ops get_available_instances is not provided

What: /sys/class/uacce/<dev_name>/algorithms
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Algorithms supported by this accelerator, separated by new line.
Can be any string and up to userspace to parse.

What: /sys/class/uacce/<dev_name>/region_mmio_size
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Size (bytes) of mmio region queue file

What: /sys/class/uacce/<dev_name>/region_dus_size
Date: Feb 2020
KernelVersion: 5.7
Contact: [email protected]
Description: Size (bytes) of dus region queue file
1 change: 1 addition & 0 deletions drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,5 @@ source "drivers/misc/cxl/Kconfig"
source "drivers/misc/ocxl/Kconfig"
source "drivers/misc/cardreader/Kconfig"
source "drivers/misc/habanalabs/Kconfig"
source "drivers/misc/uacce/Kconfig"
endmenu
1 change: 1 addition & 0 deletions drivers/misc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ obj-$(CONFIG_OCXL) += ocxl/
obj-y += cardreader/
obj-$(CONFIG_PVPANIC) += pvpanic.o
obj-$(CONFIG_HABANA_AI) += habanalabs/
obj-$(CONFIG_UACCE) += uacce/
obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o
13 changes: 13 additions & 0 deletions drivers/misc/uacce/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
config UACCE
tristate "Accelerator Framework for User Land"
depends on IOMMU_API
help
UACCE provides interface for the user process to access the hardware
without interaction with the kernel space in data path.

The user-space interface is described in
include/uapi/misc/uacce/uacce.h

See Documentation/misc-devices/uacce.rst for more details.

If you don't know what to do here, say N.
2 changes: 2 additions & 0 deletions drivers/misc/uacce/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-License-Identifier: GPL-2.0-or-later
obj-$(CONFIG_UACCE) += uacce.o
Loading

0 comments on commit 015d239

Please sign in to comment.