From 35b137630f08d913fc2e33df33ccc2570dff3f7d Mon Sep 17 00:00:00 2001 From: Jacek Lawrynowicz Date: Tue, 17 Jan 2023 10:27:17 +0100 Subject: accel/ivpu: Introduce a new DRM driver for Intel VPU VPU stands for Versatile Processing Unit and it's a CPU-integrated inference accelerator for Computer Vision and Deep Learning applications. The VPU device consist of following components: - Buttress - provides CPU to VPU integration, interrupt, frequency and power management. - Memory Management Unit (based on ARM MMU-600) - translates VPU to host DMA addresses, isolates user workloads. - RISC based microcontroller - executes firmware that provides job execution API for the kernel-mode driver - Neural Compute Subsystem (NCS) - does the actual work, provides Compute and Copy engines. - Network on Chip (NoC) - network fabric connecting all the components This driver supports VPU IP v2.7 integrated into Intel Meteor Lake client CPUs (14th generation). Module sources are at drivers/accel/ivpu and module name is "intel_vpu.ko". This patch includes only very besic functionality: - module, PCI device and IRQ initialization - register definitions and low level register manipulation functions - SET/GET_PARAM ioctls - power up without firmware Co-developed-by: Krystian Pradzynski Signed-off-by: Krystian Pradzynski Signed-off-by: Jacek Lawrynowicz Reviewed-by: Oded Gabbay Reviewed-by: Jeffrey Hugo Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20230117092723.60441-2-jacek.lawrynowicz@linux.intel.com --- drivers/accel/ivpu/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 drivers/accel/ivpu/Makefile (limited to 'drivers/accel/ivpu/Makefile') diff --git a/drivers/accel/ivpu/Makefile b/drivers/accel/ivpu/Makefile new file mode 100644 index 000000000000..2cc8394101cd --- /dev/null +++ b/drivers/accel/ivpu/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2023 Intel Corporation + +intel_vpu-y := \ + ivpu_drv.o \ + ivpu_hw_mtl.o + +obj-$(CONFIG_DRM_ACCEL_IVPU) += intel_vpu.o \ No newline at end of file -- cgit From 263b2ba5fc93c875129e0d2b4034d7d8a34b3d39 Mon Sep 17 00:00:00 2001 From: Jacek Lawrynowicz Date: Tue, 17 Jan 2023 10:27:18 +0100 Subject: accel/ivpu: Add Intel VPU MMU support VPU Memory Management Unit is based on ARM MMU-600. It allows the creation of multiple virtual address spaces for the device and map noncontinuous host memory (there is no dedicated memory on the VPU). Address space is implemented as a struct ivpu_mmu_context, it has an ID, drm_mm allocator for VPU addresses and struct ivpu_mmu_pgtable that holds actual 3-level, 4KB page table. Context with ID 0 (global context) is created upon driver initialization and it's mainly used for mapping memory required to execute the firmware. Contexts with non-zero IDs are user contexts allocated each time the devices is open()-ed and they map command buffers and other workload-related memory. Workloads executing in a given contexts have access only to the memory mapped in this context. This patch is has two main files: - ivpu_mmu_context.c handles MMU page tables and memory mapping - ivpu_mmu.c implements a driver that programs the MMU device Co-developed-by: Karol Wachowski Signed-off-by: Karol Wachowski Co-developed-by: Krystian Pradzynski Signed-off-by: Krystian Pradzynski Signed-off-by: Jacek Lawrynowicz Reviewed-by: Oded Gabbay Reviewed-by: Jeffrey Hugo Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20230117092723.60441-3-jacek.lawrynowicz@linux.intel.com --- drivers/accel/ivpu/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/accel/ivpu/Makefile') diff --git a/drivers/accel/ivpu/Makefile b/drivers/accel/ivpu/Makefile index 2cc8394101cd..59cd7843b218 100644 --- a/drivers/accel/ivpu/Makefile +++ b/drivers/accel/ivpu/Makefile @@ -3,6 +3,8 @@ intel_vpu-y := \ ivpu_drv.o \ - ivpu_hw_mtl.o + ivpu_hw_mtl.o \ + ivpu_mmu.o \ + ivpu_mmu_context.o obj-$(CONFIG_DRM_ACCEL_IVPU) += intel_vpu.o \ No newline at end of file -- cgit From 647371a6609ddf8700fe151af72e32daebb9baa7 Mon Sep 17 00:00:00 2001 From: Jacek Lawrynowicz Date: Tue, 17 Jan 2023 10:27:19 +0100 Subject: accel/ivpu: Add GEM buffer object management Adds four types of GEM-based BOs for the VPU: - shmem - internal - prime All types are implemented as struct ivpu_bo, based on struct drm_gem_object. VPU address is allocated when buffer is created except for imported prime buffers that allocate it in BO_INFO IOCTL due to missing file_priv arg in gem_prime_import callback. Internal buffers are pinned on creation, the rest of buffers types can be pinned on demand (in SUBMIT IOCTL). Buffer VPU address, allocated pages and mappings are released when the buffer is destroyed. Eviction mechanism is planned for future versions. Add two new IOCTLs: BO_CREATE, BO_INFO Signed-off-by: Jacek Lawrynowicz Reviewed-by: Oded Gabbay Reviewed-by: Jeffrey Hugo Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20230117092723.60441-4-jacek.lawrynowicz@linux.intel.com --- drivers/accel/ivpu/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/accel/ivpu/Makefile') diff --git a/drivers/accel/ivpu/Makefile b/drivers/accel/ivpu/Makefile index 59cd7843b218..5d7c5862399c 100644 --- a/drivers/accel/ivpu/Makefile +++ b/drivers/accel/ivpu/Makefile @@ -3,6 +3,7 @@ intel_vpu-y := \ ivpu_drv.o \ + ivpu_gem.o \ ivpu_hw_mtl.o \ ivpu_mmu.o \ ivpu_mmu_context.o -- cgit From 5d7422cfb498bf25c4a9ea6b9d82253cb5236364 Mon Sep 17 00:00:00 2001 From: Jacek Lawrynowicz Date: Tue, 17 Jan 2023 10:27:20 +0100 Subject: accel/ivpu: Add IPC driver and JSM messages The IPC driver is used to send and receive messages to/from firmware running on the VPU. The only supported IPC message format is Job Submission Model (JSM) defined in vpu_jsm_api.h header. Co-developed-by: Andrzej Kacprowski Signed-off-by: Andrzej Kacprowski Co-developed-by: Krystian Pradzynski Signed-off-by: Krystian Pradzynski Signed-off-by: Jacek Lawrynowicz Reviewed-by: Oded Gabbay Reviewed-by: Jeffrey Hugo Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20230117092723.60441-5-jacek.lawrynowicz@linux.intel.com --- drivers/accel/ivpu/Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/accel/ivpu/Makefile') diff --git a/drivers/accel/ivpu/Makefile b/drivers/accel/ivpu/Makefile index 5d7c5862399c..46595f0112e3 100644 --- a/drivers/accel/ivpu/Makefile +++ b/drivers/accel/ivpu/Makefile @@ -5,6 +5,8 @@ intel_vpu-y := \ ivpu_drv.o \ ivpu_gem.o \ ivpu_hw_mtl.o \ + ivpu_ipc.o \ + ivpu_jsm_msg.o \ ivpu_mmu.o \ ivpu_mmu_context.o -- cgit From 02d5b0aacd0590dbaf25f35834631e5bc11002e3 Mon Sep 17 00:00:00 2001 From: Jacek Lawrynowicz Date: Tue, 17 Jan 2023 10:27:21 +0100 Subject: accel/ivpu: Implement firmware parsing and booting Read, parse and boot VPU firmware image. Co-developed-by: Andrzej Kacprowski Signed-off-by: Andrzej Kacprowski Co-developed-by: Krystian Pradzynski Signed-off-by: Krystian Pradzynski Signed-off-by: Jacek Lawrynowicz Reviewed-by: Oded Gabbay Reviewed-by: Jeffrey Hugo Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20230117092723.60441-6-jacek.lawrynowicz@linux.intel.com --- drivers/accel/ivpu/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/accel/ivpu/Makefile') diff --git a/drivers/accel/ivpu/Makefile b/drivers/accel/ivpu/Makefile index 46595f0112e3..9fa6a76e9d79 100644 --- a/drivers/accel/ivpu/Makefile +++ b/drivers/accel/ivpu/Makefile @@ -3,6 +3,7 @@ intel_vpu-y := \ ivpu_drv.o \ + ivpu_fw.o \ ivpu_gem.o \ ivpu_hw_mtl.o \ ivpu_ipc.o \ -- cgit From cd7272215c44676dba236491941c6c406701cc5e Mon Sep 17 00:00:00 2001 From: Jacek Lawrynowicz Date: Tue, 17 Jan 2023 10:27:22 +0100 Subject: accel/ivpu: Add command buffer submission logic Each of the user contexts has two command queues, one for compute engine and one for the copy engine. Command queues are allocated and registered in the device when the first job (command buffer) is submitted from the user space to the VPU device. The userspace provides a list of GEM buffer object handles to submit to the VPU, the driver resolves buffer handles, pins physical memory if needed, increments ref count for each buffer and stores pointers to buffer objects in the ivpu_job objects that track jobs submitted to the device. The VPU signals job completion with an asynchronous message that contains the job id passed to firmware when the job was submitted. Currently, the driver supports simple scheduling logic where jobs submitted from user space are immediately pushed to the VPU device command queues. In the future, it will be extended to use hardware base scheduling and/or drm_sched. Co-developed-by: Andrzej Kacprowski Signed-off-by: Andrzej Kacprowski Signed-off-by: Jacek Lawrynowicz Reviewed-by: Oded Gabbay Reviewed-by: Jeffrey Hugo Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20230117092723.60441-7-jacek.lawrynowicz@linux.intel.com --- drivers/accel/ivpu/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/accel/ivpu/Makefile') diff --git a/drivers/accel/ivpu/Makefile b/drivers/accel/ivpu/Makefile index 9fa6a76e9d79..e61ece53a9ae 100644 --- a/drivers/accel/ivpu/Makefile +++ b/drivers/accel/ivpu/Makefile @@ -7,6 +7,7 @@ intel_vpu-y := \ ivpu_gem.o \ ivpu_hw_mtl.o \ ivpu_ipc.o \ + ivpu_job.o \ ivpu_jsm_msg.o \ ivpu_mmu.o \ ivpu_mmu_context.o -- cgit From 852be13f3bd32c1eab808840cfac41b1fea25991 Mon Sep 17 00:00:00 2001 From: Jacek Lawrynowicz Date: Tue, 17 Jan 2023 10:27:23 +0100 Subject: accel/ivpu: Add PM support - Implement cold and warm firmware boot flows - Add hang recovery support - Add runtime power management support Co-developed-by: Krystian Pradzynski Signed-off-by: Krystian Pradzynski Signed-off-by: Jacek Lawrynowicz Reviewed-by: Jeffrey Hugo Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20230117092723.60441-8-jacek.lawrynowicz@linux.intel.com --- drivers/accel/ivpu/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/accel/ivpu/Makefile') diff --git a/drivers/accel/ivpu/Makefile b/drivers/accel/ivpu/Makefile index e61ece53a9ae..80f1fb3548ae 100644 --- a/drivers/accel/ivpu/Makefile +++ b/drivers/accel/ivpu/Makefile @@ -10,6 +10,7 @@ intel_vpu-y := \ ivpu_job.o \ ivpu_jsm_msg.o \ ivpu_mmu.o \ - ivpu_mmu_context.o + ivpu_mmu_context.o \ + ivpu_pm.o obj-$(CONFIG_DRM_ACCEL_IVPU) += intel_vpu.o \ No newline at end of file -- cgit