accel/ivpu: Fixes for 6.12-rc1
Subsystems (4)
v2 cover accel/ivpu: Fixes for 6.12-rc1
Most notable changes are coredump and tracing support. The rest are stability fixes, some refactoring and typos.
Changes in v2:
- Fix typos in FW API headers
- Split fw refactor commit into 2 commits and improved commit messages
- Fixed commit messages for state dump and power island commits
- Added limit and NULL termination for FW version string
- Documented sched_mode sysfs file
Andrzej Kacprowski (4):
accel/ivpu: Update VPU FW API headers accel/ivpu: Allow reading dvfs_mode debugfs file accel/ivpu: Add test_mode bit to force turbo accel/ivpu: Fix reset_engine debugfs file logic
Jacek Lawrynowicz (11):
accel/ivpu: Rename ivpu_log_level to fw_log_level accel/ivpu: Refactor functions in ivpu_fw_log.c accel/ivpu: Fix fw log printing
accel/ivpu: Limit FW version string length accel/ivpu: Stop using hardcoded DRIVER_DATE accel/ivpu: Add auto selection logic for job scheduler accel/ivpu: Remove invalid warnings accel/ivpu: Increase MS info buffer size accel/ivpu: Fix ivpu_jsm_dyndbg_control() accel/ivpu: Remove HWS_EXTRA_EVENTS from test modes accel/ivpu: Fix typos in ivpu_pm.c
Jakub Pawlak (1):
accel/ivpu: Add tracing for IPC/PM/JOB
Karol Wachowski (12):
accel/ivpu: Add coredump support
accel/ivpu: Set 500 ns delay between power island TRICKLE and ENABLE accel/ivpu: Turn on autosuspend on Simics
accel/ivpu: Add FW version debugfs entry
accel/ivpu: Remove 1-tile power up Simics workaround accel/ivpu: Add one jiffy to bo_wait_ioctl timeout value accel/ivpu: Print JSM message result in case of error accel/ivpu: Remove skip of clock own resource ack on Simics accel/ivpu: Prevent recovery invocation during probe and resume accel/ivpu: Refactor failure diagnostics during boot accel/ivpu: Do not fail on cmdq if failed to allocate preemption
buffers
accel/ivpu: Use whole user and shave ranges for preemption buffers
Tomasz Rusinowicz (3):
accel/ivpu: Reset fw log on cold boot accel/ivpu: Add FW state dump on TDR
accel/ivpu: Make DB_ID and JOB_ID allocations incremental
drivers/accel/ivpu/Kconfig | 1 + drivers/accel/ivpu/Makefile | 6 +- drivers/accel/ivpu/ivpu_coredump.c | 39 ++++ drivers/accel/ivpu/ivpu_coredump.h | 25 ++ drivers/accel/ivpu/ivpu_debugfs.c | 86 +++---- drivers/accel/ivpu/ivpu_drv.c | 52 +++-- drivers/accel/ivpu/ivpu_drv.h | 13 +- drivers/accel/ivpu/ivpu_fw.c | 26 ++- drivers/accel/ivpu/ivpu_fw.h | 9 +- drivers/accel/ivpu/ivpu_fw_log.c | 113 +++++---- drivers/accel/ivpu/ivpu_fw_log.h | 17 +- drivers/accel/ivpu/ivpu_gem.c | 3 + drivers/accel/ivpu/ivpu_hw.c | 5 +- drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_btrs.c | 9 - drivers/accel/ivpu/ivpu_hw_ip.c | 8 +- drivers/accel/ivpu/ivpu_ipc.c | 45 ++-- drivers/accel/ivpu/ivpu_ipc.h | 9 +- drivers/accel/ivpu/ivpu_job.c | 102 +++++---- drivers/accel/ivpu/ivpu_jsm_msg.c | 34 +-- drivers/accel/ivpu/ivpu_jsm_msg.h | 2 + drivers/accel/ivpu/ivpu_ms.c | 2 +- drivers/accel/ivpu/ivpu_pm.c | 24 +- drivers/accel/ivpu/ivpu_sysfs.c | 24 ++ drivers/accel/ivpu/ivpu_trace.h | 73 ++++++ drivers/accel/ivpu/ivpu_trace_points.c | 9 + drivers/accel/ivpu/vpu_boot_api.h | 45 ++-- drivers/accel/ivpu/vpu_jsm_api.h | 303 +++++++++++++++++++++---- include/uapi/drm/ivpu_accel.h | 3 - 29 files changed, 797 insertions(+), 291 deletions(-) create mode 100644 drivers/accel/ivpu/ivpu_coredump.c create mode 100644 drivers/accel/ivpu/ivpu_coredump.h create mode 100644 drivers/accel/ivpu/ivpu_trace.h create mode 100644 drivers/accel/ivpu/ivpu_trace_points.c
--
2.45.1
PATCH v2 1/31 accel/ivpu: Update VPU FW API headers
From: Andrzej Kacprowski <[email protected]>
This commit bumps:
- Boot API from 3.24.0 to 3.26.3
- JSM API from 3.16.0 to 3.25.0
--- drivers/accel/ivpu/ivpu_job.c | 2 +- drivers/accel/ivpu/ivpu_jsm_msg.c | 3 +- drivers/accel/ivpu/vpu_boot_api.h | 45 +++-- drivers/accel/ivpu/vpu_jsm_api.h | 303 +++++++++++++++++++++++++----- 4 files changed, 293 insertions(+), 60 deletions(-)
drivers/accel/ivpu/ivpu_job.c +1 -1
@@ -354,7 +354,7 @@ static int ivpu_cmdq_push_job(struct ivpu_cmdq *cmdq, struct ivpu_job *job)return -EBUSY ; } - entry = &cmdq->jobq->job[tail]; + entry = &cmdq->jobq->slot[tail].job; entry->batch_buf_addr = job->cmd_buf_vpu_addr; entry->job_id = job->job_id; entry->flags =0 ;
drivers/accel/ivpu/ivpu_jsm_msg.c +2 -1
@@ -48,9 +48,10 @@ const char *ivpu_jsm_msg_type_to_str(enum vpu_ipc_msg_type type)IVPU_CASE_TO_STR (VPU_JSM_MSG_HWS_RESUME_ENGINE_DONE );IVPU_CASE_TO_STR (VPU_JSM_MSG_STATE_DUMP );IVPU_CASE_TO_STR (VPU_JSM_MSG_STATE_DUMP_RSP ); -IVPU_CASE_TO_STR (VPU_JSM_MSG_BLOB_DEINIT ); +IVPU_CASE_TO_STR (VPU_JSM_MSG_BLOB_DEINIT_DEPRECATED );IVPU_CASE_TO_STR (VPU_JSM_MSG_DYNDBG_CONTROL );IVPU_CASE_TO_STR (VPU_JSM_MSG_JOB_DONE ); +IVPU_CASE_TO_STR (VPU_JSM_MSG_NATIVE_FENCE_SIGNALLED );IVPU_CASE_TO_STR (VPU_JSM_MSG_ENGINE_RESET_DONE );IVPU_CASE_TO_STR (VPU_JSM_MSG_ENGINE_PREEMPT_DONE );IVPU_CASE_TO_STR (VPU_JSM_MSG_REGISTER_DB_DONE );
drivers/accel/ivpu/vpu_boot_api.h +29 -16
108 lines not on this page · raw message
drivers/accel/ivpu/vpu_jsm_api.h +261 -42
444 lines not on this page · raw message
Signature · 1 line
2.45.1
PATCH v2 2/31 accel/ivpu: Rename ivpu_log_level to fw_log_level
In reply to Jacek LawrynowiczRename module param ivpu_log_level to fw_log_level, so it is clear what log level is actually changed.
--- drivers/accel/ivpu/ivpu_fw.c | 4 ++-- drivers/accel/ivpu/ivpu_fw_log.c | 12 ++++++------ drivers/accel/ivpu/ivpu_fw_log.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/accel/ivpu/ivpu_fw.c +2 -2
@@ -204,7 +204,7 @@ static int ivpu_fw_parse(struct ivpu_device *vdev) fw->cold_boot_entry_point = fw_hdr->entry_point; fw->entry_point = fw->cold_boot_entry_point; - fw->trace_level =min_t (u32, ivpu_log_level,IVPU_FW_LOG_FATAL ); + fw->trace_level =min_t (u32, ivpu_fw_log_level,IVPU_FW_LOG_FATAL ); fw->trace_destination_mask =VPU_TRACE_DESTINATION_VERBOSE_TRACING ; fw->trace_hw_component_mask =-1 ;
@@ -307,7 +307,7 @@ static int ivpu_fw_mem_init(struct ivpu_device *vdev) goto err_free_fw_mem; } -if (ivpu_log_level <=IVPU_FW_LOG_INFO ) +if (ivpu_fw_log_level <=IVPU_FW_LOG_INFO ) log_verb_size =IVPU_FW_VERBOSE_BUFFER_LARGE_SIZE ;else log_verb_size =IVPU_FW_VERBOSE_BUFFER_SMALL_SIZE ;
drivers/accel/ivpu/ivpu_fw_log.c +6 -6
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (C) 2020-2023 Intel Corporation +* Copyright (C) 2020-2024 Intel Corporation */ #include <linux/ctype.h>
@@ -15,12 +15,12 @@#include "ivpu_fw_log.h" #include "ivpu_gem.h" -#define IVPU_FW_LOG_LINE_LENGTH 256 +#define IVPU_FW_LOG_LINE_LENGTH 256 -unsigned int ivpu_log_level =IVPU_FW_LOG_ERROR ; -module_param (ivpu_log_level, uint,0444 ); -MODULE_PARM_DESC (ivpu_log_level, - "NPU firmware default trace level: debug=" __stringify(IVPU_FW_LOG_DEBUG) +unsigned int ivpu_fw_log_level =IVPU_FW_LOG_ERROR ; +module_param_named (fw_log_level, ivpu_fw_log_level, uint,0444 ); +MODULE_PARM_DESC (fw_log_level, + "NPU firmware default log level: debug=" __stringify(IVPU_FW_LOG_DEBUG) " info=" __stringify(IVPU_FW_LOG_INFO) " warn=" __stringify(IVPU_FW_LOG_WARN) " error=" __stringify(IVPU_FW_LOG_ERROR)
drivers/accel/ivpu/ivpu_fw_log.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Copyright (C) 2020-2023 Intel Corporation +* Copyright (C) 2020-2024 Intel Corporation */ #ifndef __IVPU_FW_LOG_H__
@@ -19,12 +19,12 @@#define IVPU_FW_LOG_ERROR 4#define IVPU_FW_LOG_FATAL 5 -extern unsigned int ivpu_log_level; -#define IVPU_FW_VERBOSE_BUFFER_SMALL_SIZE SZ_1M#define IVPU_FW_VERBOSE_BUFFER_LARGE_SIZE SZ_8M#define IVPU_FW_CRITICAL_BUFFER_SIZE SZ_512K +extern unsigned int ivpu_fw_log_level; +void ivpu_fw_log_print (struct ivpu_device *vdev,bool only_new_msgs,struct drm_printer *p);void ivpu_fw_log_clear (struct ivpu_device *vdev);
Signature · 1 line
2.45.1
PATCH v2 3/31 accel/ivpu: Reset fw log on cold boot
In reply to Jacek LawrynowiczFrom: Tomasz Rusinowicz <[email protected]>
Add ivpu_fw_log_reset() that resets the read_index of all FW logs on cold boot so logs are properly read.
--- drivers/accel/ivpu/ivpu_fw_log.c | 14 ++++++++++++++ drivers/accel/ivpu/ivpu_fw_log.h | 1 + drivers/accel/ivpu/ivpu_pm.c | 1 + 3 files changed, 16 insertions(+)
drivers/accel/ivpu/ivpu_fw_log.c +14 -0
@@ -140,3 +140,17 @@ void ivpu_fw_log_clear(struct ivpu_device *vdev)while (fw_log_ptr (vdev, vdev->fw->mem_log_verb, &next, &log_header) ==0 ) log_header->read_index = log_header->write_index; } + +void ivpu_fw_log_reset (struct ivpu_device *vdev) +{ +struct vpu_tracing_buffer_header *log_header; +u32 next; + + next =0 ; +while (fw_log_ptr (vdev, vdev->fw->mem_log_crit, &next, &log_header) ==0 ) + log_header->read_index =0 ; + + next =0 ; +while (fw_log_ptr (vdev, vdev->fw->mem_log_verb, &next, &log_header) ==0 ) + log_header->read_index =0 ; +}
drivers/accel/ivpu/ivpu_fw_log.h +1 -0
@@ -27,6 +27,7 @@ extern unsigned int ivpu_fw_log_level;void ivpu_fw_log_print (struct ivpu_device *vdev,bool only_new_msgs,struct drm_printer *p);void ivpu_fw_log_clear (struct ivpu_device *vdev); +void ivpu_fw_log_reset (struct ivpu_device *vdev);static inline void ivpu_fw_log_dump (struct ivpu_device *vdev) {
drivers/accel/ivpu/ivpu_pm.c +1 -0
@@ -37,6 +37,7 @@ static void ivpu_pm_prepare_cold_boot(struct ivpu_device *vdev)ivpu_cmdq_reset_all_contexts (vdev);ivpu_ipc_reset (vdev); +ivpu_fw_log_reset (vdev);ivpu_fw_load (vdev); fw->entry_point = fw->cold_boot_entry_point; }
Signature · 1 line
2.45.1
PATCH v2 4/31 accel/ivpu: Refactor functions in ivpu_fw_log.c
In reply to Jacek LawrynowiczMake function names more consistent and (arguably) readable in fw log code. Add fw_log_print_all_in_bo() that remove duplicated code in ivpu_fw_log_print().
--- drivers/accel/ivpu/ivpu_debugfs.c | 2 +- drivers/accel/ivpu/ivpu_fw_log.c | 62 ++++++++++++++++--------------- drivers/accel/ivpu/ivpu_fw_log.h | 2 +- 3 files changed, 35 insertions(+), 31 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +1 -1
@@ -192,7 +192,7 @@ fw_log_fops_write(struct file *file, const char __user *user_buf, size_t size, lif (!size)return -EINVAL ; -ivpu_fw_log_clear (vdev); +ivpu_fw_log_mark_read (vdev);return size; }
drivers/accel/ivpu/ivpu_fw_log.c +33 -29
117 lines not on this page · raw message
drivers/accel/ivpu/ivpu_fw_log.h +1 -1
@@ -26,7 +26,7 @@extern unsigned int ivpu_fw_log_level;void ivpu_fw_log_print (struct ivpu_device *vdev,bool only_new_msgs,struct drm_printer *p); -void ivpu_fw_log_clear (struct ivpu_device *vdev); +void ivpu_fw_log_mark_read (struct ivpu_device *vdev);void ivpu_fw_log_reset (struct ivpu_device *vdev);static inline void ivpu_fw_log_dump (struct ivpu_device *vdev)
Signature · 1 line
2.45.1
PATCH v2 5/31 accel/ivpu: Fix fw log printing
In reply to Jacek Lawrynowicz - Fix empty log detection that couldn't work without read_wrap_count
- Start printing wrapped log from correct position (log_start)
- Properly handle logs that are wrapped multiple times in reference to reader position
- Don't add a newline when log buffer is wrapped
- Always add a newline after printing a log buffer in case log does not end with one
--- drivers/accel/ivpu/ivpu_fw_log.c | 49 +++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 17 deletions(-)
drivers/accel/ivpu/ivpu_fw_log.c +32 -17
@@ -87,7 +87,7 @@ static void fw_log_print_lines(char *buffer, u32 size, struct drm_printer *p) } line[index] =0 ;if (index !=0 ) -drm_printf (p,"%s\n" , line); +drm_printf (p,"%s" , line); } static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const char *prefix,
@@ -95,23 +95,29 @@ static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const cha {char *log_data = (void *)log + log->header_size;u32 data_size = log->size - log->header_size; -u32 log_start = log->read_index; -u32 log_end = log->write_index; +u32 log_start = only_new_msgs ?READ_ONCE (log->read_index) :0 ; +u32 log_end =READ_ONCE (log->write_index); -if (!(log->write_index || log->wrap_count) || - (log->write_index == log->read_index && only_new_msgs)) { -drm_printf (p,"==== %s \"%s\" log empty ====\n" , prefix, log->name); -return ; +if (log->wrap_count == log->read_wrap_count) { +if (log_end <= log_start) { +drm_printf (p,"==== %s \"%s\" log empty ====\n" , prefix, log->name); +return ; + } + }else if (log->wrap_count == log->read_wrap_count +1 ) { +if (log_end > log_start) + log_start = log_end; + }else { + log_start = log_end; }drm_printf (p,"==== %s \"%s\" log start ====\n" , prefix, log->name); -if (log->write_index > log->read_index) { +if (log_end > log_start) {fw_log_print_lines (log_data + log_start, log_end - log_start, p); }else { -fw_log_print_lines (log_data + log_end, data_size - log_end, p); +fw_log_print_lines (log_data + log_start, data_size - log_start, p);fw_log_print_lines (log_data, log_end, p); } -drm_printf (p,"\x1b[0m" ); +drm_printf (p,"\n\x1b[0m" );/* add new line and clear formatting */ drm_printf (p,"==== %s \"%s\" log end ====\n" , prefix, log->name); }
@@ -135,14 +141,19 @@ void ivpu_fw_log_print(struct ivpu_device *vdev, bool only_new_msgs, struct drm_void ivpu_fw_log_mark_read (struct ivpu_device *vdev) {struct vpu_tracing_buffer_header *log; -u32 next =0 ; +u32 next; -while (fw_log_from_bo (vdev, vdev->fw->mem_log_crit, &next, &log) ==0 ) - log->read_index = log->write_index; + next =0 ; +while (fw_log_from_bo (vdev, vdev->fw->mem_log_crit, &next, &log) ==0 ) { + log->read_index =READ_ONCE (log->write_index); + log->read_wrap_count =READ_ONCE (log->wrap_count); + } next =0 ; -while (fw_log_from_bo (vdev, vdev->fw->mem_log_verb, &next, &log) ==0 ) - log->read_index = log->write_index; +while (fw_log_from_bo (vdev, vdev->fw->mem_log_verb, &next, &log) ==0 ) { + log->read_index =READ_ONCE (log->write_index); + log->read_wrap_count =READ_ONCE (log->wrap_count); + } }void ivpu_fw_log_reset (struct ivpu_device *vdev)
@@ -151,10 +162,14 @@ void ivpu_fw_log_reset(struct ivpu_device *vdev)u32 next; next =0 ; -while (fw_log_from_bo (vdev, vdev->fw->mem_log_crit, &next, &log) ==0 ) +while (fw_log_from_bo (vdev, vdev->fw->mem_log_crit, &next, &log) ==0 ) { log->read_index =0 ; + log->read_wrap_count =0 ; + } next =0 ; -while (fw_log_from_bo (vdev, vdev->fw->mem_log_verb, &next, &log) ==0 ) +while (fw_log_from_bo (vdev, vdev->fw->mem_log_verb, &next, &log) ==0 ) { log->read_index =0 ; + log->read_wrap_count =0 ; + } }
Signature · 1 line
2.45.1
PATCH v2 6/31 accel/ivpu: Limit FW version string length
In reply to Jacek LawrynowiczLimit FW version string, when parsing FW binary, to 256 bytes and always add NULL-terminate it.
--- drivers/accel/ivpu/ivpu_fw.c | 7 ++++--- drivers/accel/ivpu/ivpu_fw.h | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/accel/ivpu/ivpu_fw.c +4 -3
@@ -25,7 +25,6 @@#define FW_SHAVE_NN_MAX_SIZE SZ_2M#define FW_RUNTIME_MIN_ADDR (FW_GLOBAL_MEM_START)#define FW_RUNTIME_MAX_ADDR (FW_GLOBAL_MEM_END - FW_SHARED_MEM_SIZE) -#define FW_VERSION_HEADER_SIZE SZ_4K#define FW_FILE_IMAGE_OFFSET (VPU_FW_HEADER_SIZE + FW_VERSION_HEADER_SIZE)#define WATCHDOG_MSS_REDIRECT 32
@@ -187,8 +186,10 @@ static int ivpu_fw_parse(struct ivpu_device *vdev)ivpu_dbg (vdev,FW_BOOT ,"Header version: 0x%x, format 0x%x\n" , fw_hdr->header_version, fw_hdr->image_format); -ivpu_info (vdev,"Firmware: %s, version: %s" , fw->name, - (const char *)fw_hdr +VPU_FW_HEADER_SIZE ); +if (!scnprintf (fw->version,sizeof (fw->version),"%s" , fw->file->data +VPU_FW_HEADER_SIZE )) +ivpu_warn (vdev,"Missing firmware version\n" ); + +ivpu_info (vdev,"Firmware: %s, version: %s\n" , fw->name, fw->version);if (IVPU_FW_CHECK_API_COMPAT (vdev, fw_hdr,BOOT ,3 ))return -EINVAL ;
drivers/accel/ivpu/ivpu_fw.h +5 -1
@@ -1,11 +1,14 @@/* SPDX-License-Identifier: GPL-2.0-only */ /* -* Copyright (C) 2020-2023 Intel Corporation +* Copyright (C) 2020-2024 Intel Corporation */ #ifndef __IVPU_FW_H__#define __IVPU_FW_H__ +#define FW_VERSION_HEADER_SIZE SZ_4K +#define FW_VERSION_STR_SIZE SZ_256 +struct ivpu_device ;struct ivpu_bo ;struct vpu_boot_params ;
@@ -13,6 +16,7 @@ struct vpu_boot_params;struct ivpu_fw_info {const struct firmware *file;const char *name; +char version[FW_VERSION_STR_SIZE ];struct ivpu_bo *mem;struct ivpu_bo *mem_shave_nn;struct ivpu_bo *mem_log_crit;
Signature · 1 line
2.45.1
PATCH v2 7/31 accel/ivpu: Add coredump support
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Use coredump (if available) to collect FW logs in case of a FW crash. This makes dmesg more readable and allows to collect more log data.
--- drivers/accel/ivpu/Kconfig | 1 + drivers/accel/ivpu/Makefile | 1 + drivers/accel/ivpu/ivpu_coredump.c | 39 ++++++++++++++++++++++++++++++ drivers/accel/ivpu/ivpu_coredump.h | 25 +++++++++++++++++++ drivers/accel/ivpu/ivpu_drv.c | 5 ++-- drivers/accel/ivpu/ivpu_fw_log.h | 8 ------ drivers/accel/ivpu/ivpu_pm.c | 9 ++++--- 7 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 drivers/accel/ivpu/ivpu_coredump.c create mode 100644 drivers/accel/ivpu/ivpu_coredump.h
drivers/accel/ivpu/Kconfig +1 -0
@@ -8,6 +8,7 @@ config DRM_ACCEL_IVPU select FW_LOADER select DRM_GEM_SHMEM_HELPER select GENERIC_ALLOCATOR + select WANT_DEV_COREDUMP help Choose this option if you have a system with an 14th generation Intel CPU (Meteor Lake) or newer. Intel NPU (formerly called Intel VPU)
drivers/accel/ivpu/Makefile +1 -0
@@ -19,5 +19,6 @@ intel_vpu-y := \ ivpu_sysfs.o intel_vpu-$(CONFIG_DEBUG_FS) += ivpu_debugfs.o +intel_vpu-$(CONFIG_DEV_COREDUMP) += ivpu_coredump.o obj-$(CONFIG_DRM_ACCEL_IVPU) += intel_vpu.o
drivers/accel/ivpu/ivpu_coredump.c new file +39 -0
@@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2020-2024 Intel Corporation +*/ + +#include <linux/devcoredump.h> +#include <linux/firmware.h> + +#include "ivpu_coredump.h" +#include "ivpu_fw.h" +#include "ivpu_gem.h" +#include "vpu_boot_api.h" + +#define CRASH_DUMP_HEADER "Intel NPU crash dump" +#define CRASH_DUMP_HEADERS_SIZE SZ_4K + +void ivpu_dev_coredump (struct ivpu_device *vdev) +{ +struct drm_print_iterator pi = {}; +struct drm_printer p; +size_t coredump_size; +char *coredump; + + coredump_size =CRASH_DUMP_HEADERS_SIZE +FW_VERSION_HEADER_SIZE + +ivpu_bo_size (vdev->fw->mem_log_crit) +ivpu_bo_size (vdev->fw->mem_log_verb); + coredump =vmalloc (coredump_size); +if (!coredump) +return ; + + pi.data = coredump; + pi.remain = coredump_size; + p =drm_coredump_printer (&pi); + +drm_printf (&p,"%s\n" ,CRASH_DUMP_HEADER ); +drm_printf (&p,"FW version: %s\n" , vdev->fw->version); +ivpu_fw_log_print (vdev, false, &p); + +dev_coredumpv (vdev->drm.dev, coredump, pi.offset,GFP_KERNEL ); +}
drivers/accel/ivpu/ivpu_coredump.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2020-2024 Intel Corporation +*/ + +#ifndef __IVPU_COREDUMP_H__ +#define __IVPU_COREDUMP_H__ + +#include <drm/drm_print.h> + +#include "ivpu_drv.h" +#include "ivpu_fw_log.h" + +#ifdef CONFIG_DEV_COREDUMP +void ivpu_dev_coredump (struct ivpu_device *vdev); +#else +static inline void ivpu_dev_coredump (struct ivpu_device *vdev) +{ +struct drm_printer p =drm_info_printer (vdev->drm.dev); + +ivpu_fw_log_print (vdev, false, &p); +} +#endif + +#endif /* __IVPU_COREDUMP_H__ */
drivers/accel/ivpu/ivpu_drv.c +3 -2
@@ -14,7 +14,7 @@#include <drm/drm_ioctl.h> #include <drm/drm_prime.h> -#include "vpu_boot_api.h" +#include "ivpu_coredump.h" #include "ivpu_debugfs.h" #include "ivpu_drv.h" #include "ivpu_fw.h"
@@ -29,6 +29,7 @@#include "ivpu_ms.h" #include "ivpu_pm.h" #include "ivpu_sysfs.h" +#include "vpu_boot_api.h" #ifndef DRIVER_VERSION_STR #define DRIVER_VERSION_STR __stringify(DRM_IVPU_DRIVER_MAJOR) "." \
@@ -382,7 +383,7 @@ int ivpu_boot(struct ivpu_device *vdev)ivpu_err (vdev,"Failed to boot the firmware: %d\n" , ret);ivpu_hw_diagnose_failure (vdev);ivpu_mmu_evtq_dump (vdev); -ivpu_fw_log_dump (vdev); +ivpu_dev_coredump (vdev);return ret; }
drivers/accel/ivpu/ivpu_fw_log.h +0 -8
@@ -8,8 +8,6 @@#include <linux/types.h> -#include <drm/drm_print.h> -#include "ivpu_drv.h" #define IVPU_FW_LOG_DEFAULT 0
@@ -29,11 +27,5 @@ void ivpu_fw_log_print(struct ivpu_device *vdev, bool only_new_msgs, struct drm_void ivpu_fw_log_mark_read (struct ivpu_device *vdev);void ivpu_fw_log_reset (struct ivpu_device *vdev); -static inline void ivpu_fw_log_dump (struct ivpu_device *vdev) -{ -struct drm_printer p =drm_info_printer (vdev->drm.dev); - -ivpu_fw_log_print (vdev, false, &p); -}#endif /* __IVPU_FW_LOG_H__ */
drivers/accel/ivpu/ivpu_pm.c +5 -4
@@ -9,17 +9,18 @@#include <linux/pm_runtime.h> #include <linux/reboot.h> -#include "vpu_boot_api.h" +#include "ivpu_coredump.h" #include "ivpu_drv.h" -#include "ivpu_hw.h" #include "ivpu_fw.h" #include "ivpu_fw_log.h" +#include "ivpu_hw.h" #include "ivpu_ipc.h" #include "ivpu_job.h" #include "ivpu_jsm_msg.h" #include "ivpu_mmu.h" #include "ivpu_ms.h" #include "ivpu_pm.h" +#include "vpu_boot_api.h" static bool ivpu_disable_recovery;module_param_named_unsafe (disable_recovery, ivpu_disable_recovery, bool,0644 );
@@ -124,7 +125,7 @@ static void ivpu_pm_recovery_work(struct work_struct *work)if (ret)ivpu_err (vdev,"Failed to resume NPU: %d\n" , ret); -ivpu_fw_log_dump (vdev); +ivpu_dev_coredump (vdev);atomic_inc (&vdev->pm->reset_counter);atomic_set (&vdev->pm->reset_pending,1 );
@@ -263,7 +264,7 @@ int ivpu_pm_runtime_suspend_cb(struct device *dev)if (!is_idle || ret_d0i3) {ivpu_err (vdev,"Forcing cold boot due to previous errors\n" );atomic_inc (&vdev->pm->reset_counter); -ivpu_fw_log_dump (vdev); +ivpu_dev_coredump (vdev);ivpu_pm_prepare_cold_boot (vdev); }else {ivpu_pm_prepare_warm_boot (vdev);
Signature · 1 line
2.45.1
PATCH v2 8/31 accel/ivpu: Add FW state dump on TDR
In reply to Jacek LawrynowiczFrom: Tomasz Rusinowicz <[email protected]>
Send JSM state dump message at the beginning of TDR handler. This allows FW to collect debug info in the FW log before the state of the NPU is lost allowing to analyze the cause of a TDR.
Wait a predefined timeout (10 ms) so the FW has a chance to write debug logs. We cannot wait for JSM response at this point because IRQs are already disabled before TDR handler is invoked.
--- drivers/accel/ivpu/ivpu_drv.h | 1 + drivers/accel/ivpu/ivpu_hw.c | 3 +++ drivers/accel/ivpu/ivpu_ipc.c | 26 ++++++++++++++++++++++++++ drivers/accel/ivpu/ivpu_ipc.h | 2 ++ drivers/accel/ivpu/ivpu_jsm_msg.c | 8 ++++++++ drivers/accel/ivpu/ivpu_jsm_msg.h | 2 ++ drivers/accel/ivpu/ivpu_pm.c | 1 + 7 files changed, 43 insertions(+)
drivers/accel/ivpu/ivpu_drv.h +1 -0
@@ -152,6 +152,7 @@ struct ivpu_device {int tdr;int autosuspend;int d0i3_entry_msg; +int state_dump_msg; } timeout; };
drivers/accel/ivpu/ivpu_hw.c +3 -0
@@ -89,12 +89,14 @@ static void timeouts_init(struct ivpu_device *vdev) vdev->timeout.tdr =2000000 ; vdev->timeout.autosuspend =-1 ; vdev->timeout.d0i3_entry_msg =500 ; + vdev->timeout.state_dump_msg =10 ; }else if (ivpu_is_simics (vdev)) { vdev->timeout.boot =50 ; vdev->timeout.jsm =500 ; vdev->timeout.tdr =10000 ; vdev->timeout.autosuspend =-1 ; vdev->timeout.d0i3_entry_msg =100 ; + vdev->timeout.state_dump_msg =10 ; }else { vdev->timeout.boot =1000 ; vdev->timeout.jsm =500 ;
@@ -104,6 +106,7 @@ static void timeouts_init(struct ivpu_device *vdev)else vdev->timeout.autosuspend =100 ; vdev->timeout.d0i3_entry_msg =5 ; + vdev->timeout.state_dump_msg =10 ; } }
drivers/accel/ivpu/ivpu_ipc.c +26 -0
@@ -364,6 +364,32 @@ int ivpu_ipc_send_receive(struct ivpu_device *vdev, struct vpu_jsm_msg *req,return ret; } +int ivpu_ipc_send_and_wait (struct ivpu_device *vdev,struct vpu_jsm_msg *req, +u32 channel,unsigned long timeout_ms) +{ +struct ivpu_ipc_consumer cons; +int ret; + + ret =ivpu_rpm_get (vdev); +if (ret <0 ) +return ret; + +ivpu_ipc_consumer_add (vdev, &cons, channel,NULL ); + + ret =ivpu_ipc_send (vdev, &cons, req); +if (ret) { +ivpu_warn_ratelimited (vdev,"IPC send failed: %d\n" , ret); + goto consumer_del; + } + +msleep (timeout_ms); + +consumer_del: +ivpu_ipc_consumer_del (vdev, &cons); +ivpu_rpm_put (vdev); +return ret; +} +static bool ivpu_ipc_match_consumer (struct ivpu_device *vdev,struct ivpu_ipc_consumer *cons,struct ivpu_ipc_hdr *ipc_hdr,struct vpu_jsm_msg *jsm_msg)
drivers/accel/ivpu/ivpu_ipc.h +2 -0
@@ -108,5 +108,7 @@ int ivpu_ipc_send_receive_active(struct ivpu_device *vdev, struct vpu_jsm_msg *rint ivpu_ipc_send_receive (struct ivpu_device *vdev,struct vpu_jsm_msg *req,enum vpu_ipc_msg_type expected_resp,struct vpu_jsm_msg *resp,u32 channel,unsigned long timeout_ms); +int ivpu_ipc_send_and_wait (struct ivpu_device *vdev,struct vpu_jsm_msg *req, +u32 channel,unsigned long timeout_ms);#endif /* __IVPU_IPC_H__ */
drivers/accel/ivpu/ivpu_jsm_msg.c +8 -0
@@ -559,3 +559,11 @@ int ivpu_jsm_dct_disable(struct ivpu_device *vdev) &resp,VPU_IPC_CHAN_ASYNC_CMD , vdev->timeout.jsm); } + +int ivpu_jsm_state_dump (struct ivpu_device *vdev) +{ +struct vpu_jsm_msg req = { .type =VPU_JSM_MSG_STATE_DUMP }; + +return ivpu_ipc_send_and_wait (vdev, &req,VPU_IPC_CHAN_ASYNC_CMD , + vdev->timeout.state_dump_msg); +}
drivers/accel/ivpu/ivpu_jsm_msg.h +2 -0
@@ -43,4 +43,6 @@ int ivpu_jsm_metric_streamer_info(struct ivpu_device *vdev, u64 metric_group_mas u64 buffer_size, u32 *sample_size, u64 *info_size);int ivpu_jsm_dct_enable (struct ivpu_device *vdev,u32 active_us,u32 inactive_us);int ivpu_jsm_dct_disable (struct ivpu_device *vdev); +int ivpu_jsm_state_dump (struct ivpu_device *vdev); +#endif
drivers/accel/ivpu/ivpu_pm.c +1 -0
@@ -125,6 +125,7 @@ static void ivpu_pm_recovery_work(struct work_struct *work)if (ret)ivpu_err (vdev,"Failed to resume NPU: %d\n" , ret); +ivpu_jsm_state_dump (vdev);ivpu_dev_coredump (vdev);atomic_inc (&vdev->pm->reset_counter);
Signature · 1 line
2.45.1
PATCH v2 9/31 accel/ivpu: Set 500 ns delay between power island TRICKLE and ENABLE
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Follow HW documentation recommendation of 500 ns delay between setting AON_PWR_ISLAND_TRICKLE_EN and AON_PWR_ISLAND_EN registers during power island enabling. Previously this was only done correctly for VPU 4+. VPU 3.7 had the delay added after power island disable where it is not needed.
--- drivers/accel/ivpu/ivpu_hw_ip.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/accel/ivpu/ivpu_hw_ip.c +2 -6
@@ -311,9 +311,6 @@ static void pwr_island_trickle_drive_40xx(struct ivpu_device *vdev, bool enable) val =REG_CLR_FLD (VPU_40XX_HOST_SS_AON_PWR_ISLAND_TRICKLE_EN0 ,CSS_CPU , val);REGV_WR32 (VPU_40XX_HOST_SS_AON_PWR_ISLAND_TRICKLE_EN0 , val); - -if (enable) -ndelay (500 ); }static void pwr_island_drive_37xx (struct ivpu_device *vdev,bool enable)
@@ -326,9 +323,6 @@ static void pwr_island_drive_37xx(struct ivpu_device *vdev, bool enable) val =REG_CLR_FLD (VPU_40XX_HOST_SS_AON_PWR_ISLAND_EN0 ,CSS_CPU , val);REGV_WR32 (VPU_40XX_HOST_SS_AON_PWR_ISLAND_EN0 , val); - -if (!enable) -ndelay (500 ); }static void pwr_island_drive_40xx (struct ivpu_device *vdev,bool enable)
@@ -347,9 +341,11 @@ static void pwr_island_enable(struct ivpu_device *vdev) {if (ivpu_hw_ip_gen (vdev) ==IVPU_HW_IP_37XX ) {pwr_island_trickle_drive_37xx (vdev, true); +ndelay (500 );pwr_island_drive_37xx (vdev, true); }else {pwr_island_trickle_drive_40xx (vdev, true); +ndelay (500 );pwr_island_drive_40xx (vdev, true); } }
Signature · 1 line
2.45.1
PATCH v2 10/31 accel/ivpu: Turn on autosuspend on Simics
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
With recent Simics update DVFS flows using cdyn were fixed and it is possible to enable D0i3/D3 entry flows on autosuspend. Set autosuspend timeout to 100 ms by default on Simics.
--- drivers/accel/ivpu/ivpu_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_hw.c +1 -1
@@ -94,7 +94,7 @@ static void timeouts_init(struct ivpu_device *vdev) vdev->timeout.boot =50 ; vdev->timeout.jsm =500 ; vdev->timeout.tdr =10000 ; - vdev->timeout.autosuspend =-1 ; + vdev->timeout.autosuspend =100 ; vdev->timeout.d0i3_entry_msg =100 ; vdev->timeout.state_dump_msg =10 ; }else {
Signature · 1 line
2.45.1
PATCH v2 11/31 accel/ivpu: Add FW version debugfs entry
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Add debugfs that prints current firmware version string on read.
--- drivers/accel/ivpu/ivpu_debugfs.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/accel/ivpu/ivpu_debugfs.c +9 -0
@@ -45,6 +45,14 @@ static int fw_name_show(struct seq_file *s, void *v)return 0 ; } +static int fw_version_show (struct seq_file *s,void *v) +{ +struct ivpu_device *vdev =seq_to_ivpu (s); + +seq_printf (s,"%s\n" , vdev->fw->version); +return 0 ; +} +static int fw_trace_capability_show (struct seq_file *s,void *v) {struct ivpu_device *vdev =seq_to_ivpu (s);
@@ -111,6 +119,7 @@ static int reset_pending_show(struct seq_file *s, void *v)static const struct drm_debugfs_info vdev_debugfs_list[] = { {"bo_list" , bo_list_show,0 }, {"fw_name" , fw_name_show,0 }, + {"fw_version" , fw_version_show,0 }, {"fw_trace_capability" , fw_trace_capability_show,0 }, {"fw_trace_config" , fw_trace_config_show,0 }, {"last_bootmode" , last_bootmode_show,0 },
Signature · 1 line
2.45.1
PATCH v2 12/31 accel/ivpu: Stop using hardcoded DRIVER_DATE
In reply to Jacek LawrynowiczHardcoded driver date is useless, so use kernel version as a driver date to make identifying .ko file easier. Also allow to pass DRIVER_DATE on build time to allow versioning the driver in case it is built out of the tree.
--- drivers/accel/ivpu/ivpu_drv.c | 15 +++++++++++---- drivers/accel/ivpu/ivpu_drv.h | 1 - include/uapi/drm/ivpu_accel.h | 3 --- 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +11 -4
@@ -7,6 +7,7 @@#include <linux/module.h> #include <linux/pci.h> #include <linux/pm_runtime.h> +#include <generated/utsrelease.h> #include <drm/drm_accel.h> #include <drm/drm_file.h>
@@ -32,8 +33,7 @@#include "vpu_boot_api.h" #ifndef DRIVER_VERSION_STR -#define DRIVER_VERSION_STR __stringify(DRM_IVPU_DRIVER_MAJOR) "." \ - __stringify(DRM_IVPU_DRIVER_MINOR) "." +#define DRIVER_VERSION_STR "1.0.0 " UTS_RELEASE#endif static struct lock_class_key submitted_jobs_xa_lock_class_key;
@@ -447,9 +447,16 @@ static const struct drm_driver driver = { .name = DRIVER_NAME, .desc =DRIVER_DESC , + +#ifdef DRIVER_DATE .date =DRIVER_DATE , - .major = DRM_IVPU_DRIVER_MAJOR, - .minor = DRM_IVPU_DRIVER_MINOR, + .major = DRIVER_MAJOR, + .minor = DRIVER_MINOR, + .patchlevel = DRIVER_PATCHLEVEL, +#else + .date =UTS_RELEASE , + .major = 1, +#endif };static void ivpu_context_abort_invalid (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_drv.h +0 -1
@@ -21,7 +21,6 @@#define DRIVER_NAME "intel_vpu"#define DRIVER_DESC "Driver for Intel NPU (Neural Processing Unit)" -#define DRIVER_DATE "20230117"#define PCI_DEVICE_ID_MTL 0x7d1d#define PCI_DEVICE_ID_ARL 0xad1d
include/uapi/drm/ivpu_accel.h +0 -3
@@ -12,9 +12,6 @@extern "C" {#endif -#define DRM_IVPU_DRIVER_MAJOR 1 -#define DRM_IVPU_DRIVER_MINOR 0 -#define DRM_IVPU_GET_PARAM 0x00#define DRM_IVPU_SET_PARAM 0x01#define DRM_IVPU_BO_CREATE 0x02
Signature · 1 line
2.45.1
PATCH v2 13/31 accel/ivpu: Remove 1-tile power up Simics workaround
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Previously Simics was not providing workpoint for configurations with 0 tiles enabled, that had to be worked around in the KMD. This got fixed in Simics and workaround is no longer needed.
--- drivers/accel/ivpu/ivpu_hw_btrs.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/accel/ivpu/ivpu_hw_btrs.c +0 -4
@@ -315,10 +315,6 @@ static void prepare_wp_request(struct ivpu_device *vdev, struct wp_request *wp, wp->cdyn = enable ?PLL_CDYN_DEFAULT :0 ; wp->epp = enable ?PLL_EPP_DEFAULT :0 ; } - -/* Simics cannot start without at least one tile */ -if (enable &&ivpu_is_simics (vdev)) - wp->cfg =1 ; }static int wait_for_pll_lock (struct ivpu_device *vdev,bool enable)
Signature · 1 line
2.45.1
PATCH v2 14/31 accel/ivpu: Allow reading dvfs_mode debugfs file
In reply to Jacek LawrynowiczFrom: Andrzej Kacprowski <[email protected]>
Make the dvfs_mode read-write to allow checking current mode. Simplify the dvfs_mode implementation with the DEFINE_DEBUGFS_ATTRIBUTE.
--- drivers/accel/ivpu/ivpu_debugfs.c | 33 +++++++++++-------------------- 1 file changed, 12 insertions(+), 21 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +12 -21
@@ -127,32 +127,23 @@ static const struct drm_debugfs_info vdev_debugfs_list[] = { {"reset_pending", reset_pending_show, 0}, }; -static ssize_t -dvfs_mode_fops_write (struct file *file,const char __user *user_buf,size_t size,loff_t *pos) +static int dvfs_mode_get (void *data,u64 *dvfs_mode) { -struct ivpu_device *vdev = file->private_data; -struct ivpu_fw_info *fw = vdev->fw; -u32 dvfs_mode; -int ret; +struct ivpu_device *vdev = (struct ivpu_device *)data; - ret =kstrtou32_from_user (user_buf, size,0 , &dvfs_mode); -if (ret <0 ) -return ret; - - fw->dvfs_mode = dvfs_mode; + *dvfs_mode = vdev->fw->dvfs_mode; +return 0 ; +} - ret =pci_try_reset_function (to_pci_dev (vdev->drm.dev)); -if (ret) -return ret; +static int dvfs_mode_set (void *data,u64 dvfs_mode) +{ +struct ivpu_device *vdev = (struct ivpu_device *)data; -return size; + vdev->fw->dvfs_mode = (u32 )dvfs_mode; +return pci_try_reset_function (to_pci_dev (vdev->drm.dev)); } -static const struct file_operations dvfs_mode_fops = { - .owner =THIS_MODULE , - .open = simple_open, - .write = dvfs_mode_fops_write, -}; +DEFINE_DEBUGFS_ATTRIBUTE (dvfs_mode_fops, dvfs_mode_get, dvfs_mode_set,"%llu\n" );static ssize_t fw_dyndbg_fops_write (struct file *file,const char __user *user_buf,size_t size,loff_t *pos)
@@ -432,7 +423,7 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)debugfs_create_file ("force_recovery" ,0200 , debugfs_root, vdev, &ivpu_force_recovery_fops); -debugfs_create_file ("dvfs_mode" ,0200 , debugfs_root, vdev, +debugfs_create_file ("dvfs_mode" ,0644 , debugfs_root, vdev, &dvfs_mode_fops); debugfs_create_file("fw_dyndbg", 0200, debugfs_root, vdev,
Signature · 1 line
2.45.1
PATCH v2 15/31 accel/ivpu: Add one jiffy to bo_wait_ioctl timeout value
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Add one jiffy to ensure wait function never times out before intended timeout value, which could happen if absolute timeout value is less than (1s / CONFIG_HZ) in the future.
--- drivers/accel/ivpu/ivpu_gem.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/accel/ivpu/ivpu_gem.c +3 -0
@@ -384,6 +384,9 @@ int ivpu_bo_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file timeout =drm_timeout_abs_to_jiffies (args->timeout_ns); +/* Add 1 jiffy to ensure the wait function never times out before intended timeout_ns */ + timeout +=1 ; + obj =drm_gem_object_lookup (file, args->handle);if (!obj)return -EINVAL ;
Signature · 1 line
2.45.1
PATCH v2 16/31 accel/ivpu: Add auto selection logic for job scheduler
In reply to Jacek LawrynowiczAdd ivpu_fw_sched_mode_select() function that can select scheduling mode based on HW and FW versions. This prepares for a switch to HWS on selected platforms.
--- drivers/accel/ivpu/ivpu_drv.c | 6 +++--- drivers/accel/ivpu/ivpu_drv.h | 2 ++ drivers/accel/ivpu/ivpu_fw.c | 15 +++++++++++++-- drivers/accel/ivpu/ivpu_fw.h | 3 +++ drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_btrs.c | 2 -- drivers/accel/ivpu/ivpu_job.c | 14 +++++++------- drivers/accel/ivpu/ivpu_sysfs.c | 24 ++++++++++++++++++++++++ 8 files changed, 52 insertions(+), 15 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +3 -3
@@ -54,9 +54,9 @@ u8 ivpu_pll_max_ratio = U8_MAX;module_param_named (pll_max_ratio, ivpu_pll_max_ratio, byte,0644 );MODULE_PARM_DESC (pll_max_ratio,"Maximum PLL ratio used to set NPU frequency" ); -int ivpu_sched_mode; +int ivpu_sched_mode =IVPU_SCHED_MODE_AUTO ;module_param_named (sched_mode, ivpu_sched_mode, int,0444 ); -MODULE_PARM_DESC (sched_mode,"Scheduler mode: 0 - Default scheduler, 1 - Force HW scheduler" ); +MODULE_PARM_DESC (sched_mode,"Scheduler mode: -1 - Use default scheduler, 0 - Use OS scheduler, 1 - Use HW scheduler" );bool ivpu_disable_mmu_cont_pages;module_param_named (disable_mmu_cont_pages, ivpu_disable_mmu_cont_pages, bool,0444 );
@@ -347,7 +347,7 @@ static int ivpu_hw_sched_init(struct ivpu_device *vdev) {int ret =0 ; -if (vdev->hw->sched_mode ==VPU_SCHEDULING_MODE_HW ) { +if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW ) { ret =ivpu_jsm_hws_setup_priority_bands (vdev);if (ret) {ivpu_err (vdev,"Failed to enable hw scheduler: %d" , ret);
drivers/accel/ivpu/ivpu_drv.h +2 -0
@@ -56,6 +56,8 @@#define IVPU_PLATFORM_FPGA 3#define IVPU_PLATFORM_INVALID 8 +#define IVPU_SCHED_MODE_AUTO -1 +#define IVPU_DBG_REG BIT(0)#define IVPU_DBG_IRQ BIT(1)#define IVPU_DBG_MMU BIT(2)
drivers/accel/ivpu/ivpu_fw.c +13 -2
@@ -130,6 +130,15 @@ static bool is_within_range(u64 addr, size_t size, u64 range_start, size_t rangereturn true; } +static u32 +ivpu_fw_sched_mode_select (struct ivpu_device *vdev,const struct vpu_firmware_header *fw_hdr) +{ +if (ivpu_sched_mode !=IVPU_SCHED_MODE_AUTO ) +return ivpu_sched_mode; + +return VPU_SCHEDULING_MODE_OS ; +} +static int ivpu_fw_parse (struct ivpu_device *vdev) {struct ivpu_fw_info *fw = vdev->fw;
@@ -211,8 +220,10 @@ static int ivpu_fw_parse(struct ivpu_device *vdev) fw->dvfs_mode =0 ; + fw->sched_mode =ivpu_fw_sched_mode_select (vdev, fw_hdr); fw->primary_preempt_buf_size = fw_hdr->preemption_buffer_1_size; fw->secondary_preempt_buf_size = fw_hdr->preemption_buffer_2_size; +ivpu_info (vdev,"Scheduler mode: %s\n" , fw->sched_mode ?"HW" :"OS" ); if (fw_hdr->ro_section_start_address && !is_within_range(fw_hdr->ro_section_start_address, fw_hdr->ro_section_size,
@@ -601,8 +612,8 @@ void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params boot_params->punit_telemetry_sram_base =ivpu_hw_telemetry_offset_get (vdev); boot_params->punit_telemetry_sram_size =ivpu_hw_telemetry_size_get (vdev); boot_params->vpu_telemetry_enable =ivpu_hw_telemetry_enable_get (vdev); - boot_params->vpu_scheduling_mode = vdev->hw->sched_mode; -if (vdev->hw->sched_mode ==VPU_SCHEDULING_MODE_HW ) + boot_params->vpu_scheduling_mode = vdev->fw->sched_mode; +if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW ) boot_params->vpu_focus_present_timer_ms =IVPU_FOCUS_PRESENT_TIMER_MS ; boot_params->dvfs_mode = vdev->fw->dvfs_mode;if (!IVPU_WA (disable_d0i3_msg))
drivers/accel/ivpu/ivpu_fw.h +3 -0
@@ -6,6 +6,8 @@#ifndef __IVPU_FW_H__#define __IVPU_FW_H__ +#include "vpu_jsm_api.h" +#define FW_VERSION_HEADER_SIZE SZ_4K#define FW_VERSION_STR_SIZE SZ_256
@@ -36,6 +38,7 @@ struct ivpu_fw_info {u32 secondary_preempt_buf_size;u64 read_only_addr;u32 read_only_size; +u32 sched_mode; };int ivpu_fw_init (struct ivpu_device *vdev);
drivers/accel/ivpu/ivpu_hw.h +0 -1
@@ -46,7 +46,6 @@ struct ivpu_hw_info {u32 profiling_freq; } pll;u32 tile_fuse; -u32 sched_mode;u32 sku;u16 config;int dma_bits;
drivers/accel/ivpu/ivpu_hw_btrs.c +0 -2
@@ -163,7 +163,6 @@ static int info_init_mtl(struct ivpu_device *vdev) hw->tile_fuse =BTRS_MTL_TILE_FUSE_ENABLE_BOTH ; hw->sku =BTRS_MTL_TILE_SKU_BOTH ; hw->config =BTRS_MTL_WP_CONFIG_2_TILE_4_3_RATIO ; - hw->sched_mode = ivpu_sched_mode;return 0 ; }
@@ -178,7 +177,6 @@ static int info_init_lnl(struct ivpu_device *vdev)if (ret)return ret; - hw->sched_mode = ivpu_sched_mode; hw->tile_fuse = tile_fuse_config; hw->pll.profiling_freq =PLL_PROFILING_FREQ_DEFAULT ;
drivers/accel/ivpu/ivpu_job.c +7 -7
@@ -37,7 +37,7 @@ static int ivpu_preemption_buffers_create(struct ivpu_device *vdev,u64 secondary_size =ALIGN (vdev->fw->secondary_preempt_buf_size,PAGE_SIZE );struct ivpu_addr_range range; -if (vdev->hw->sched_mode !=VPU_SCHEDULING_MODE_HW ) +if (vdev->fw->sched_mode !=VPU_SCHEDULING_MODE_HW )return 0 ; range.start = vdev->hw->ranges.user.end - (primary_size *IVPU_NUM_CMDQS_PER_CTX );
@@ -68,7 +68,7 @@ static int ivpu_preemption_buffers_create(struct ivpu_device *vdev,static void ivpu_preemption_buffers_free (struct ivpu_device *vdev,struct ivpu_file_priv *file_priv,struct ivpu_cmdq *cmdq) { -if (vdev->hw->sched_mode !=VPU_SCHEDULING_MODE_HW ) +if (vdev->fw->sched_mode !=VPU_SCHEDULING_MODE_HW )return ;drm_WARN_ON (&vdev->drm, !cmdq->primary_preempt_buf);
@@ -149,7 +149,7 @@ static int ivpu_register_db(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *struct ivpu_device *vdev = file_priv->vdev;int ret; -if (vdev->hw->sched_mode ==VPU_SCHEDULING_MODE_HW ) +if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW ) ret =ivpu_jsm_hws_register_db (vdev, file_priv->ctx.id, cmdq->db_id, cmdq->db_id, cmdq->mem->vpu_addr,ivpu_bo_size (cmdq->mem));else
@@ -184,7 +184,7 @@ ivpu_cmdq_init(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq, u16 eng jobq_header->tail =0 ;wmb ();/* Flush WC buffer for jobq->header */ -if (vdev->hw->sched_mode ==VPU_SCHEDULING_MODE_HW ) { +if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW ) { ret =ivpu_hws_cmdq_init (file_priv, cmdq, engine, priority);if (ret)return ret;
@@ -211,7 +211,7 @@ static int ivpu_cmdq_fini(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cm cmdq->db_registered = false; -if (vdev->hw->sched_mode ==VPU_SCHEDULING_MODE_HW ) { +if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW ) { ret =ivpu_jsm_hws_destroy_cmdq (vdev, file_priv->ctx.id, cmdq->db_id);if (!ret)ivpu_dbg (vdev,JOB ,"Command queue %d destroyed\n" , cmdq->db_id);
@@ -335,7 +335,7 @@ void ivpu_context_abort_locked(struct ivpu_file_priv *file_priv)ivpu_cmdq_fini_all (file_priv); -if (vdev->hw->sched_mode ==VPU_SCHEDULING_MODE_OS ) +if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_OS )ivpu_jsm_context_release (vdev, file_priv->ctx.id); }
@@ -361,7 +361,7 @@ static int ivpu_cmdq_push_job(struct ivpu_cmdq *cmdq, struct ivpu_job *job)if (unlikely (ivpu_test_mode &IVPU_TEST_MODE_NULL_SUBMISSION )) entry->flags =VPU_JOB_FLAGS_NULL_SUBMISSION_MASK ; -if (vdev->hw->sched_mode ==VPU_SCHEDULING_MODE_HW && +if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW && (unlikely (!(ivpu_test_mode &IVPU_TEST_MODE_PREEMPTION_DISABLE )))) { entry->primary_preempt_buf_addr = cmdq->primary_preempt_buf->vpu_addr; entry->primary_preempt_buf_size =ivpu_bo_size (cmdq->primary_preempt_buf);
drivers/accel/ivpu/ivpu_sysfs.c +24 -0
@@ -6,6 +6,8 @@#include <linux/device.h> #include <linux/err.h> +#include "ivpu_drv.h" +#include "ivpu_fw.h" #include "ivpu_hw.h" #include "ivpu_sysfs.h"
@@ -39,8 +41,30 @@ npu_busy_time_us_show(struct device *dev, struct device_attribute *attr, char *bstatic DEVICE_ATTR_RO (npu_busy_time_us); +/** +* DOC: sched_mode +* +* The sched_mode is used to report current NPU scheduling mode. +* +* It returns following strings: +* - "HW" - Hardware Scheduler mode +* - "OS" - Operating System Scheduler mode +* +*/ +static ssize_t +sched_mode_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct drm_device *drm =dev_get_drvdata (dev); +struct ivpu_device *vdev =to_ivpu_device (drm); + +return sysfs_emit (buf,"%s\n" , vdev->fw->sched_mode ?"HW" :"HW" ); +} + +static DEVICE_ATTR_RO (sched_mode); +static struct attribute *ivpu_dev_attrs[] = { &dev_attr_npu_busy_time_us.attr, + &dev_attr_sched_mode.attr,NULL , };
Signature · 1 line
2.45.1
PATCH v2 17/31 accel/ivpu: Print JSM message result in case of error
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Change debug message to error level in case of receiving non-successful result of JSM message.
--- drivers/accel/ivpu/ivpu_ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_ipc.c +1 -1
@@ -278,7 +278,7 @@ int ivpu_ipc_receive(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,u32 size =min_t (int, rx_msg->ipc_hdr->data_size,sizeof (*jsm_msg));if (rx_msg->jsm_msg->result !=VPU_JSM_STATUS_SUCCESS ) { -ivpu_dbg (vdev,IPC ,"IPC resp result error: %d\n" , rx_msg->jsm_msg->result); +ivpu_err (vdev,"IPC resp result error: %d\n" , rx_msg->jsm_msg->result); ret = -EBADMSG ; }
Signature · 1 line
2.45.1
PATCH v2 18/31 accel/ivpu: Make DB_ID and JOB_ID allocations incremental
In reply to Jacek LawrynowiczFrom: Tomasz Rusinowicz <[email protected]>
Save last used ID and use it to limit the possible values for the ID. This should decrease the rate at which the IDs are reused, which will make debugging easier.
--- drivers/accel/ivpu/ivpu_drv.c | 9 +++++++++ drivers/accel/ivpu/ivpu_drv.h | 7 +++++++ drivers/accel/ivpu/ivpu_job.c | 37 +++++++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 10 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +9 -0
@@ -260,6 +260,11 @@ static int ivpu_open(struct drm_device *dev, struct drm_file *file)if (ret) goto err_xa_erase; + file_priv->default_job_limit.min =FIELD_PREP (IVPU_JOB_ID_CONTEXT_MASK , + (file_priv->ctx.id -1 )); + file_priv->default_job_limit.max = file_priv->default_job_limit.min |IVPU_JOB_ID_JOB_MASK ; + file_priv->job_limit = file_priv->default_job_limit; +mutex_unlock (&vdev->context_list_lock);drm_dev_exit (idx);
@@ -614,6 +619,10 @@ static int ivpu_dev_init(struct ivpu_device *vdev)lockdep_set_class (&vdev->submitted_jobs_xa.xa_lock, &submitted_jobs_xa_lock_class_key);INIT_LIST_HEAD (&vdev->bo_list); + vdev->default_db_limit.min =IVPU_MIN_DB ; + vdev->default_db_limit.max =IVPU_MAX_DB ; + vdev->db_limit = vdev->default_db_limit; + ret =drmm_mutex_init (&vdev->drm, &vdev->context_list_lock);if (ret) goto err_xa_destroy;
drivers/accel/ivpu/ivpu_drv.h +7 -0
@@ -45,6 +45,9 @@#define IVPU_MIN_DB 1#define IVPU_MAX_DB 255 +#define IVPU_JOB_ID_JOB_MASK GENMASK(7, 0) +#define IVPU_JOB_ID_CONTEXT_MASK GENMASK(31, 8) +#define IVPU_NUM_ENGINES 2#define IVPU_NUM_PRIORITIES 4#define IVPU_NUM_CMDQS_PER_CTX (IVPU_NUM_ENGINES * IVPU_NUM_PRIORITIES)
@@ -135,6 +138,8 @@ struct ivpu_device {struct xa_limit context_xa_limit;struct xarray db_xa; +struct xa_limit db_limit; +struct xa_limit default_db_limit;struct mutex bo_list_lock;/* Protects bo_list */ struct list_head bo_list;
@@ -170,6 +175,8 @@ struct ivpu_file_priv {struct mutex ms_lock;/* Protects ms_instance_list, ms_info_bo */ struct list_head ms_instance_list;struct ivpu_bo *ms_info_bo; +struct xa_limit job_limit; +struct xa_limit default_job_limit;bool has_mmu_faults;bool bound;bool aborted;
drivers/accel/ivpu/ivpu_job.c +27 -10
@@ -21,8 +21,6 @@#include "vpu_boot_api.h" #define CMD_BUF_IDX 0 -#define JOB_ID_JOB_MASK GENMASK(7, 0) -#define JOB_ID_CONTEXT_MASK GENMASK(31, 8)#define JOB_MAX_BUFFER_COUNT 65535static void ivpu_cmdq_ring_db (struct ivpu_device *vdev,struct ivpu_cmdq *cmdq)
@@ -77,9 +75,28 @@ static void ivpu_preemption_buffers_free(struct ivpu_device *vdev,ivpu_bo_free (cmdq->secondary_preempt_buf); } +static int ivpu_id_alloc (struct xarray *xa,u32 *id,void *entry,struct xa_limit *limit, +const struct xa_limit default_limit) +{ +int ret; + + ret =__xa_alloc (xa, id, entry, *limit,GFP_KERNEL ); +if (ret) { + limit->min = default_limit.min; + ret =__xa_alloc (xa, id, entry, *limit,GFP_KERNEL ); +if (ret) +return ret; + } + + limit->min = *id +1 ; +if (limit->min > limit->max) + limit->min = default_limit.min; + +return ret; +} +static struct ivpu_cmdq *ivpu_cmdq_alloc (struct ivpu_file_priv *file_priv) { -struct xa_limit db_xa_limit = {.max =IVPU_MAX_DB , .min =IVPU_MIN_DB };struct ivpu_device *vdev = file_priv->vdev;struct ivpu_cmdq *cmdq;int ret;
@@ -88,7 +105,10 @@ static struct ivpu_cmdq *ivpu_cmdq_alloc(struct ivpu_file_priv *file_priv)if (!cmdq)return NULL ; - ret =xa_alloc (&vdev->db_xa, &cmdq->db_id,NULL , db_xa_limit,GFP_KERNEL ); +xa_lock (&vdev->db_xa);/* lock here to protect db_limit */ + ret =ivpu_id_alloc (&vdev->db_xa, &cmdq->db_id,NULL , &vdev->db_limit, + vdev->default_db_limit); +xa_unlock (&vdev->db_xa);if (ret) {ivpu_err (vdev,"Failed to allocate doorbell id: %d\n" , ret); goto err_free_cmdq;
@@ -519,7 +539,6 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority) {struct ivpu_file_priv *file_priv = job->file_priv;struct ivpu_device *vdev = job->vdev; -struct xa_limit job_id_range;struct ivpu_cmdq *cmdq;bool is_first_job;int ret;
@@ -530,7 +549,7 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority)mutex_lock (&file_priv->lock); - cmdq =ivpu_cmdq_acquire (job->file_priv, job->engine_idx, priority); + cmdq =ivpu_cmdq_acquire (file_priv, job->engine_idx, priority);if (!cmdq) {ivpu_warn_ratelimited (vdev,"Failed to get job queue, ctx %d engine %d prio %d\n" , file_priv->ctx.id, job->engine_idx, priority);
@@ -538,12 +557,10 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority) goto err_unlock_file_priv; } - job_id_range.min =FIELD_PREP (JOB_ID_CONTEXT_MASK , (file_priv->ctx.id -1 )); - job_id_range.max = job_id_range.min |JOB_ID_JOB_MASK ; -xa_lock (&vdev->submitted_jobs_xa); is_first_job =xa_empty (&vdev->submitted_jobs_xa); - ret =__xa_alloc (&vdev->submitted_jobs_xa, &job->job_id, job, job_id_range,GFP_KERNEL ); + ret =ivpu_id_alloc (&vdev->submitted_jobs_xa, &job->job_id, job, &file_priv->job_limit, + file_priv->default_job_limit);if (ret) {ivpu_dbg (vdev,JOB ,"Too many active jobs in ctx %d\n" , file_priv->ctx.id);
Signature · 1 line
2.45.1
PATCH v2 19/31 accel/ivpu: Add test_mode bit to force turbo
In reply to Jacek LawrynowiczFrom: Andrzej Kacprowski <[email protected]>
Add new test_mode BIT(9) that forces firmware to
enable turbo burst mode.
--- drivers/accel/ivpu/ivpu_drv.h | 1 + drivers/accel/ivpu/ivpu_job.c | 5 +++++ 2 files changed, 6 insertions(+)
drivers/accel/ivpu/ivpu_drv.h +1 -0
@@ -197,6 +197,7 @@ extern bool ivpu_force_snoop;#define IVPU_TEST_MODE_PREEMPTION_DISABLE BIT(6)#define IVPU_TEST_MODE_HWS_EXTRA_EVENTS BIT(7)#define IVPU_TEST_MODE_DISABLE_TIMEOUTS BIT(8) +#define IVPU_TEST_MODE_TURBO BIT(9)extern int ivpu_test_mode;struct ivpu_file_priv *ivpu_file_priv_get (struct ivpu_file_priv *file_priv);
drivers/accel/ivpu/ivpu_job.c +5 -0
@@ -202,6 +202,11 @@ ivpu_cmdq_init(struct ivpu_file_priv *file_priv, struct ivpu_cmdq *cmdq, u16 eng jobq_header->engine_idx = engine; jobq_header->head =0 ; jobq_header->tail =0 ; +if (ivpu_test_mode &IVPU_TEST_MODE_TURBO ) { +ivpu_dbg (vdev,JOB ,"Turbo mode enabled" ); + jobq_header->flags =VPU_JOB_QUEUE_FLAGS_TURBO_MODE ; + } +wmb ();/* Flush WC buffer for jobq->header */ if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW ) {
Signature · 1 line
2.45.1
PATCH v2 20/31 accel/ivpu: Remove skip of clock own resource ack on Simics
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
With recent Simics model update CLOCK_RESOURCE_OWN_ACK signal was implemented as part of VPU STATUS register and workaround is no longer needed.
--- drivers/accel/ivpu/ivpu_hw_btrs.c | 3 --- 1 file changed, 3 deletions(-)
drivers/accel/ivpu/ivpu_hw_btrs.c +0 -3
@@ -459,9 +459,6 @@ int ivpu_hw_btrs_wait_for_clock_res_own_ack(struct ivpu_device *vdev)if (ivpu_hw_btrs_gen (vdev) ==IVPU_HW_BTRS_MTL )return 0 ; -if (ivpu_is_simics (vdev)) -return 0 ; -return REGB_POLL_FLD (VPU_HW_BTRS_LNL_VPU_STATUS ,CLOCK_RESOURCE_OWN_ACK ,1 ,TIMEOUT_US ); }
Signature · 1 line
2.45.1
PATCH v2 21/31 accel/ivpu: Fix reset_engine debugfs file logic
In reply to Jacek LawrynowiczFrom: Andrzej Kacprowski <[email protected]>
The current reset_engine implementation unconditionally resets all engines. Improve implementation to reset only the engine requested by the user space to allow more granular testing. Also use DEFINE_DEBUGFS_ATTRIBUTE() to simplify implementation.
Same changes applied to resume_engine debugfs file for consistency.
--- drivers/accel/ivpu/ivpu_debugfs.c | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +8 -34
@@ -337,49 +337,23 @@ static const struct file_operations ivpu_force_recovery_fops = { .write = ivpu_force_recovery_fn, }; -static ssize_t -ivpu_reset_engine_fn (struct file *file,const char __user *user_buf,size_t size,loff_t *pos) +static int ivpu_reset_engine_fn (void *data,u64 val) { -struct ivpu_device *vdev = file->private_data; - -if (!size) -return -EINVAL ; - -if (ivpu_jsm_reset_engine (vdev,DRM_IVPU_ENGINE_COMPUTE )) -return -ENODEV ; -if (ivpu_jsm_reset_engine (vdev,DRM_IVPU_ENGINE_COPY )) -return -ENODEV ; +struct ivpu_device *vdev = (struct ivpu_device *)data; -return size; +return ivpu_jsm_reset_engine (vdev, (u32 )val); } -static const struct file_operations ivpu_reset_engine_fops = { - .owner =THIS_MODULE , - .open = simple_open, - .write = ivpu_reset_engine_fn, -}; +DEFINE_DEBUGFS_ATTRIBUTE (ivpu_reset_engine_fops,NULL , ivpu_reset_engine_fn,"0x%02llx\n" ); -static ssize_t -ivpu_resume_engine_fn (struct file *file,const char __user *user_buf,size_t size,loff_t *pos) +static int ivpu_resume_engine_fn (void *data,u64 val) { -struct ivpu_device *vdev = file->private_data; - -if (!size) -return -EINVAL ; - -if (ivpu_jsm_hws_resume_engine (vdev,DRM_IVPU_ENGINE_COMPUTE )) -return -ENODEV ; -if (ivpu_jsm_hws_resume_engine (vdev,DRM_IVPU_ENGINE_COPY )) -return -ENODEV ; +struct ivpu_device *vdev = (struct ivpu_device *)data; -return size; +return ivpu_jsm_hws_resume_engine (vdev, (u32 )val); } -static const struct file_operations ivpu_resume_engine_fops = { - .owner =THIS_MODULE , - .open = simple_open, - .write = ivpu_resume_engine_fn, -}; +DEFINE_DEBUGFS_ATTRIBUTE (ivpu_resume_engine_fops,NULL , ivpu_resume_engine_fn,"0x%02llx\n" );static int dct_active_get (void *data,u64 *active_percent) {
Signature · 1 line
2.45.1
PATCH v2 22/31 accel/ivpu: Prevent recovery invocation during probe and resume
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Refactor IPC send and receive functions to allow correct handling of operations that should not trigger a recovery process.
Expose ivpu_send_receive_internal(), which is now utilized by the D0i3 entry, DCT initialization, and HWS initialization functions. These functions have been modified to return error codes gracefully, rather than initiating recovery.
The updated functions are invoked within ivpu_probe() and ivpu_resume(), ensuring that any errors encountered during these stages result in a proper teardown or shutdown sequence. The previous approach of triggering recovery within these functions could lead to a race condition, potentially causing undefined behavior and kernel crashes due to null pointer dereferences.
--- drivers/accel/ivpu/ivpu_ipc.c | 35 +++++++++++-------------------- drivers/accel/ivpu/ivpu_ipc.h | 7 +++---- drivers/accel/ivpu/ivpu_jsm_msg.c | 19 +++++++---------- 3 files changed, 23 insertions(+), 38 deletions(-)
drivers/accel/ivpu/ivpu_ipc.c +12 -23
@@ -291,15 +291,16 @@ int ivpu_ipc_receive(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,return ret; } -static int +int ivpu_ipc_send_receive_internal (struct ivpu_device *vdev,struct vpu_jsm_msg *req,enum vpu_ipc_msg_type expected_resp_type, -struct vpu_jsm_msg *resp,u32 channel, -unsigned long timeout_ms) +struct vpu_jsm_msg *resp,u32 channel,unsigned long timeout_ms) {struct ivpu_ipc_consumer cons;int ret; +drm_WARN_ON (&vdev->drm,pm_runtime_status_suspended (vdev->drm.dev)); +ivpu_ipc_consumer_add (vdev, &cons, channel,NULL ); ret =ivpu_ipc_send (vdev, &cons, req);
@@ -325,19 +326,21 @@ ivpu_ipc_send_receive_internal(struct ivpu_device *vdev, struct vpu_jsm_msg *reqreturn ret; } -int ivpu_ipc_send_receive_active (struct ivpu_device *vdev,struct vpu_jsm_msg *req, -enum vpu_ipc_msg_type expected_resp,struct vpu_jsm_msg *resp, -u32 channel,unsigned long timeout_ms) +int ivpu_ipc_send_receive (struct ivpu_device *vdev,struct vpu_jsm_msg *req, +enum vpu_ipc_msg_type expected_resp,struct vpu_jsm_msg *resp, +u32 channel,unsigned long timeout_ms) {struct vpu_jsm_msg hb_req = { .type =VPU_JSM_MSG_QUERY_ENGINE_HB };struct vpu_jsm_msg hb_resp;int ret, hb_ret; -drm_WARN_ON (&vdev->drm,pm_runtime_status_suspended (vdev->drm.dev)); + ret =ivpu_rpm_get (vdev); +if (ret <0 ) +return ret; ret =ivpu_ipc_send_receive_internal (vdev, req, expected_resp, resp, channel, timeout_ms);if (ret != -ETIMEDOUT ) -return ret; + goto rpm_put; hb_ret = ivpu_ipc_send_receive_internal(vdev, &hb_req, VPU_JSM_MSG_QUERY_ENGINE_HB_DONE, &hb_resp, VPU_IPC_CHAN_ASYNC_CMD,
@@ -345,21 +348,7 @@ int ivpu_ipc_send_receive_active(struct ivpu_device *vdev, struct vpu_jsm_msg *rif (hb_ret == -ETIMEDOUT )ivpu_pm_trigger_recovery (vdev,"IPC timeout" ); -return ret; -} - -int ivpu_ipc_send_receive (struct ivpu_device *vdev,struct vpu_jsm_msg *req, -enum vpu_ipc_msg_type expected_resp,struct vpu_jsm_msg *resp, -u32 channel,unsigned long timeout_ms) -{ -int ret; - - ret =ivpu_rpm_get (vdev); -if (ret <0 ) -return ret; - - ret =ivpu_ipc_send_receive_active (vdev, req, expected_resp, resp, channel, timeout_ms); - +rpm_put:ivpu_rpm_put (vdev);return ret; }
drivers/accel/ivpu/ivpu_ipc.h +3 -4
@@ -101,10 +101,9 @@ int ivpu_ipc_send(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,int ivpu_ipc_receive (struct ivpu_device *vdev,struct ivpu_ipc_consumer *cons,struct ivpu_ipc_hdr *ipc_buf,struct vpu_jsm_msg *jsm_msg,unsigned long timeout_ms); - -int ivpu_ipc_send_receive_active (struct ivpu_device *vdev,struct vpu_jsm_msg *req, -enum vpu_ipc_msg_type expected_resp,struct vpu_jsm_msg *resp, -u32 channel,unsigned long timeout_ms); +int ivpu_ipc_send_receive_internal (struct ivpu_device *vdev,struct vpu_jsm_msg *req, +enum vpu_ipc_msg_type expected_resp_type, +struct vpu_jsm_msg *resp,u32 channel,unsigned long timeout_ms);int ivpu_ipc_send_receive (struct ivpu_device *vdev,struct vpu_jsm_msg *req,enum vpu_ipc_msg_type expected_resp,struct vpu_jsm_msg *resp,u32 channel,unsigned long timeout_ms);
drivers/accel/ivpu/ivpu_jsm_msg.c +8 -11
@@ -271,9 +271,8 @@ int ivpu_jsm_pwr_d0i3_enter(struct ivpu_device *vdev) req.payload.pwr_d0i3_enter.send_response =1 ; - ret =ivpu_ipc_send_receive_active (vdev, &req,VPU_JSM_MSG_PWR_D0I3_ENTER_DONE , - &resp,VPU_IPC_CHAN_GEN_CMD , - vdev->timeout.d0i3_entry_msg); + ret =ivpu_ipc_send_receive_internal (vdev, &req,VPU_JSM_MSG_PWR_D0I3_ENTER_DONE , &resp, +VPU_IPC_CHAN_GEN_CMD , vdev->timeout.d0i3_entry_msg);if (ret)return ret;
@@ -431,8 +430,8 @@ int ivpu_jsm_hws_setup_priority_bands(struct ivpu_device *vdev) req.payload.hws_priority_band_setup.normal_band_percentage =10 ; - ret =ivpu_ipc_send_receive_active (vdev, &req,VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP , - &resp,VPU_IPC_CHAN_ASYNC_CMD , vdev->timeout.jsm); + ret =ivpu_ipc_send_receive_internal (vdev, &req,VPU_JSM_MSG_SET_PRIORITY_BAND_SETUP_RSP , + &resp,VPU_IPC_CHAN_ASYNC_CMD , vdev->timeout.jsm);if (ret)ivpu_warn_ratelimited (vdev,"Failed to set priority bands: %d\n" , ret);
@@ -545,9 +544,8 @@ int ivpu_jsm_dct_enable(struct ivpu_device *vdev, u32 active_us, u32 inactive_us req.payload.pwr_dct_control.dct_active_us = active_us; req.payload.pwr_dct_control.dct_inactive_us = inactive_us; -return ivpu_ipc_send_receive_active (vdev, &req,VPU_JSM_MSG_DCT_ENABLE_DONE , - &resp,VPU_IPC_CHAN_ASYNC_CMD , - vdev->timeout.jsm); +return ivpu_ipc_send_receive_internal (vdev, &req,VPU_JSM_MSG_DCT_ENABLE_DONE , &resp, +VPU_IPC_CHAN_ASYNC_CMD , vdev->timeout.jsm); }int ivpu_jsm_dct_disable (struct ivpu_device *vdev)
@@ -555,9 +553,8 @@ int ivpu_jsm_dct_disable(struct ivpu_device *vdev)struct vpu_jsm_msg req = { .type =VPU_JSM_MSG_DCT_DISABLE };struct vpu_jsm_msg resp; -return ivpu_ipc_send_receive_active (vdev, &req,VPU_JSM_MSG_DCT_DISABLE_DONE , - &resp,VPU_IPC_CHAN_ASYNC_CMD , - vdev->timeout.jsm); +return ivpu_ipc_send_receive_internal (vdev, &req,VPU_JSM_MSG_DCT_DISABLE_DONE , &resp, +VPU_IPC_CHAN_ASYNC_CMD , vdev->timeout.jsm); }int ivpu_jsm_state_dump (struct ivpu_device *vdev)
Signature · 1 line
2.45.1
PATCH v2 23/31 accel/ivpu: Refactor failure diagnostics during boot
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Move diagnostic functions to common error handling within ivpu_boot() function to ensure diagnostics are gathered even in cases where NPU fails after successful boot (DCT and HWS init failures).
--- drivers/accel/ivpu/ivpu_drv.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +11 -6
@@ -386,10 +386,7 @@ int ivpu_boot(struct ivpu_device *vdev) ret =ivpu_wait_for_ready (vdev);if (ret) {ivpu_err (vdev,"Failed to boot the firmware: %d\n" , ret); -ivpu_hw_diagnose_failure (vdev); -ivpu_mmu_evtq_dump (vdev); -ivpu_dev_coredump (vdev); -return ret; + goto err_diagnose_failure; }ivpu_hw_irq_clear (vdev);
@@ -400,12 +397,20 @@ int ivpu_boot(struct ivpu_device *vdev)if (ivpu_fw_is_cold_boot (vdev)) { ret =ivpu_pm_dct_init (vdev);if (ret) -return ret; + goto err_diagnose_failure; -return ivpu_hw_sched_init (vdev); + ret =ivpu_hw_sched_init (vdev); +if (ret) + goto err_diagnose_failure; }return 0 ; + +err_diagnose_failure: +ivpu_hw_diagnose_failure (vdev); +ivpu_mmu_evtq_dump (vdev); +ivpu_dev_coredump (vdev); +return ret; }void ivpu_prepare_for_reset (struct ivpu_device *vdev)
Signature · 1 line
2.45.1
PATCH v2 24/31 accel/ivpu: Remove invalid warnings
In reply to Jacek LawrynowiczWarn in ivpu_file_priv_put() checks a pointer that is previously accessed. Warn in ivpu_ipc_fini() can be triggered even in valid cases where IPC is disabled upon closing the device.
--- drivers/accel/ivpu/ivpu_drv.c | 2 -- drivers/accel/ivpu/ivpu_ipc.c | 1 - 2 files changed, 3 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +0 -2
@@ -117,8 +117,6 @@ void ivpu_file_priv_put(struct ivpu_file_priv **link)struct ivpu_file_priv *file_priv = *link;struct ivpu_device *vdev = file_priv->vdev; -drm_WARN_ON (&vdev->drm, !file_priv); -ivpu_dbg (vdev,KREF ,"file_priv put: ctx %u refcount %u\n" , file_priv->ctx.id,kref_read (&file_priv->ref));
drivers/accel/ivpu/ivpu_ipc.c +0 -1
@@ -533,7 +533,6 @@ void ivpu_ipc_fini(struct ivpu_device *vdev) {struct ivpu_ipc_info *ipc = vdev->ipc; -drm_WARN_ON (&vdev->drm, ipc->on);drm_WARN_ON (&vdev->drm, !list_empty (&ipc->cons_list));drm_WARN_ON (&vdev->drm, !list_empty (&ipc->cb_msg_list));drm_WARN_ON (&vdev->drm,atomic_read (&ipc->rx_msg_count) >0 );
Signature · 1 line
2.45.1
PATCH v2 25/31 accel/ivpu: Do not fail on cmdq if failed to allocate preemption buffers
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Allow to proceed with job command queue creation even if preemption buffers failed to be allocated, print warning that preemption on such command queue will be disabled.
--- drivers/accel/ivpu/ivpu_job.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/accel/ivpu/ivpu_job.c +16 -11
@@ -60,6 +60,7 @@ static int ivpu_preemption_buffers_create(struct ivpu_device *vdev, err_free_primary:ivpu_bo_free (cmdq->primary_preempt_buf); + cmdq->primary_preempt_buf =NULL ;return -ENOMEM ; }
@@ -69,10 +70,10 @@ static void ivpu_preemption_buffers_free(struct ivpu_device *vdev,if (vdev->fw->sched_mode !=VPU_SCHEDULING_MODE_HW )return ; -drm_WARN_ON (&vdev->drm, !cmdq->primary_preempt_buf); -drm_WARN_ON (&vdev->drm, !cmdq->secondary_preempt_buf); -ivpu_bo_free (cmdq->primary_preempt_buf); -ivpu_bo_free (cmdq->secondary_preempt_buf); +if (cmdq->primary_preempt_buf) +ivpu_bo_free (cmdq->primary_preempt_buf); +if (cmdq->secondary_preempt_buf) +ivpu_bo_free (cmdq->secondary_preempt_buf); } static int ivpu_id_alloc(struct xarray *xa, u32 *id, void *entry, struct xa_limit *limit,
@@ -120,12 +121,10 @@ static struct ivpu_cmdq *ivpu_cmdq_alloc(struct ivpu_file_priv *file_priv) ret =ivpu_preemption_buffers_create (vdev, file_priv, cmdq);if (ret) - goto err_free_cmdq_mem; +ivpu_warn (vdev,"Failed to allocate preemption buffers, preemption limited\n" );return cmdq; -err_free_cmdq_mem: -ivpu_bo_free (cmdq->mem); err_erase_xa:xa_erase (&vdev->db_xa, cmdq->db_id); err_free_cmdq:
@@ -388,10 +387,16 @@ static int ivpu_cmdq_push_job(struct ivpu_cmdq *cmdq, struct ivpu_job *job)if (vdev->fw->sched_mode ==VPU_SCHEDULING_MODE_HW && (unlikely (!(ivpu_test_mode &IVPU_TEST_MODE_PREEMPTION_DISABLE )))) { - entry->primary_preempt_buf_addr = cmdq->primary_preempt_buf->vpu_addr; - entry->primary_preempt_buf_size =ivpu_bo_size (cmdq->primary_preempt_buf); - entry->secondary_preempt_buf_addr = cmdq->secondary_preempt_buf->vpu_addr; - entry->secondary_preempt_buf_size =ivpu_bo_size (cmdq->secondary_preempt_buf); +if (cmdq->primary_preempt_buf) { + entry->primary_preempt_buf_addr = cmdq->primary_preempt_buf->vpu_addr; + entry->primary_preempt_buf_size =ivpu_bo_size (cmdq->primary_preempt_buf); + } + +if (cmdq->secondary_preempt_buf) { + entry->secondary_preempt_buf_addr = cmdq->secondary_preempt_buf->vpu_addr; + entry->secondary_preempt_buf_size = +ivpu_bo_size (cmdq->secondary_preempt_buf); + } }wmb ();/* Ensure that tail is updated after filling entry */
Signature · 1 line
2.45.1
PATCH v2 26/31 accel/ivpu: Use whole user and shave ranges for preemption buffers
In reply to Jacek LawrynowiczFrom: Karol Wachowski <[email protected]>
Do not restrict range for preemption buffers allocation just to the end of user and shave ranges, use them whole instead to avoid situation where end of range might be already allocated causing preemption buffers allocation to fail.
--- drivers/accel/ivpu/ivpu_job.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/accel/ivpu/ivpu_job.c +4 -9
@@ -33,24 +33,19 @@ static int ivpu_preemption_buffers_create(struct ivpu_device *vdev, {u64 primary_size =ALIGN (vdev->fw->primary_preempt_buf_size,PAGE_SIZE );u64 secondary_size =ALIGN (vdev->fw->secondary_preempt_buf_size,PAGE_SIZE ); -struct ivpu_addr_range range;if (vdev->fw->sched_mode !=VPU_SCHEDULING_MODE_HW )return 0 ; - range.start = vdev->hw->ranges.user.end - (primary_size *IVPU_NUM_CMDQS_PER_CTX ); - range.end = vdev->hw->ranges.user.end; - cmdq->primary_preempt_buf =ivpu_bo_create (vdev, &file_priv->ctx, &range, primary_size, -DRM_IVPU_BO_WC ); + cmdq->primary_preempt_buf =ivpu_bo_create (vdev, &file_priv->ctx, &vdev->hw->ranges.user, + primary_size,DRM_IVPU_BO_WC );if (!cmdq->primary_preempt_buf) {ivpu_err (vdev,"Failed to create primary preemption buffer\n" );return -ENOMEM ; } - range.start = vdev->hw->ranges.shave.end - (secondary_size *IVPU_NUM_CMDQS_PER_CTX ); - range.end = vdev->hw->ranges.shave.end; - cmdq->secondary_preempt_buf =ivpu_bo_create (vdev, &file_priv->ctx, &range, secondary_size, -DRM_IVPU_BO_WC ); + cmdq->secondary_preempt_buf =ivpu_bo_create (vdev, &file_priv->ctx, &vdev->hw->ranges.shave, + secondary_size,DRM_IVPU_BO_WC );if (!cmdq->secondary_preempt_buf) {ivpu_err (vdev,"Failed to create secondary preemption buffer\n" ); goto err_free_primary;
Signature · 1 line
2.45.1
PATCH v2 27/31 accel/ivpu: Increase MS info buffer size
In reply to Jacek LawrynowiczIncrease MS info BO to 64KB to allow collecting more metrics.
--- drivers/accel/ivpu/ivpu_ms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_ms.c +1 -1
@@ -11,7 +11,7 @@#include "ivpu_ms.h" #include "ivpu_pm.h" -#define MS_INFO_BUFFER_SIZE SZ_16K +#define MS_INFO_BUFFER_SIZE SZ_64K#define MS_NUM_BUFFERS 2#define MS_READ_PERIOD_MULTIPLIER 2#define MS_MIN_SAMPLE_PERIOD_NS 1000000
Signature · 1 line
2.45.1
PATCH v2 28/31 accel/ivpu: Fix ivpu_jsm_dyndbg_control()
In reply to Jacek LawrynowiczUse correct channel for dyndbg JSM message.
--- drivers/accel/ivpu/ivpu_jsm_msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_jsm_msg.c +1 -1
@@ -197,7 +197,7 @@ int ivpu_jsm_dyndbg_control(struct ivpu_device *vdev, char *command, size_t sizestrscpy (req.payload.dyndbg_control.dyndbg_cmd, command,VPU_DYNDBG_CMD_MAX_LEN ); ret =ivpu_ipc_send_receive (vdev, &req,VPU_JSM_MSG_DYNDBG_CONTROL_RSP , &resp, -VPU_IPC_CHAN_ASYNC_CMD , vdev->timeout.jsm); +VPU_IPC_CHAN_GEN_CMD , vdev->timeout.jsm);if (ret)ivpu_warn_ratelimited (vdev,"Failed to send command \"%s\": ret %d\n" , command, ret);
Signature · 1 line
2.45.1
PATCH v2 29/31 accel/ivpu: Remove HWS_EXTRA_EVENTS from test modes
In reply to Jacek LawrynowiczIVPU_TEST_MODE_HWS_EXTRA_EVENTS was never used and can be safely removed
--- drivers/accel/ivpu/ivpu_drv.h | 1 - drivers/accel/ivpu/ivpu_jsm_msg.c | 2 -- 2 files changed, 3 deletions(-)
drivers/accel/ivpu/ivpu_drv.h +0 -1
@@ -195,7 +195,6 @@ extern bool ivpu_force_snoop;#define IVPU_TEST_MODE_D0I3_MSG_DISABLE BIT(4)#define IVPU_TEST_MODE_D0I3_MSG_ENABLE BIT(5)#define IVPU_TEST_MODE_PREEMPTION_DISABLE BIT(6) -#define IVPU_TEST_MODE_HWS_EXTRA_EVENTS BIT(7)#define IVPU_TEST_MODE_DISABLE_TIMEOUTS BIT(8)#define IVPU_TEST_MODE_TURBO BIT(9)extern int ivpu_test_mode;
drivers/accel/ivpu/ivpu_jsm_msg.c +0 -2
@@ -394,8 +394,6 @@ int ivpu_jsm_hws_set_scheduling_log(struct ivpu_device *vdev, u32 engine_idx, u3 req.payload.hws_set_scheduling_log.host_ssid = host_ssid; req.payload.hws_set_scheduling_log.vpu_log_buffer_va = vpu_log_buffer_va; req.payload.hws_set_scheduling_log.notify_index =0 ; - req.payload.hws_set_scheduling_log.enable_extra_events = - ivpu_test_mode &IVPU_TEST_MODE_HWS_EXTRA_EVENTS ; ret =ivpu_ipc_send_receive (vdev, &req,VPU_JSM_MSG_HWS_SET_SCHEDULING_LOG_RSP , &resp,VPU_IPC_CHAN_ASYNC_CMD , vdev->timeout.jsm);
Signature · 1 line
2.45.1
PATCH v2 30/31 accel/ivpu: Add tracing for IPC/PM/JOB
In reply to Jacek LawrynowiczFrom: Jakub Pawlak <[email protected]>
Add multiple trace points in couple of key places to enable tracing with ftrace.
--- drivers/accel/ivpu/Makefile | 5 +- drivers/accel/ivpu/ivpu_ipc.c | 3 ++ drivers/accel/ivpu/ivpu_job.c | 4 ++ drivers/accel/ivpu/ivpu_pm.c | 9 ++++ drivers/accel/ivpu/ivpu_trace.h | 73 ++++++++++++++++++++++++++ drivers/accel/ivpu/ivpu_trace_points.c | 9 ++++ 6 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 drivers/accel/ivpu/ivpu_trace.h create mode 100644 drivers/accel/ivpu/ivpu_trace_points.c
drivers/accel/ivpu/Makefile +4 -1
@@ -16,9 +16,12 @@ intel_vpu-y := \ ivpu_mmu_context.o \ ivpu_ms.o \ ivpu_pm.o \ - ivpu_sysfs.o + ivpu_sysfs.o \ + ivpu_trace_points.o intel_vpu-$(CONFIG_DEBUG_FS) += ivpu_debugfs.o intel_vpu-$(CONFIG_DEV_COREDUMP) += ivpu_coredump.o obj-$(CONFIG_DRM_ACCEL_IVPU) += intel_vpu.o + +CFLAGS_ivpu_trace_points.o = -I$(src)
drivers/accel/ivpu/ivpu_ipc.c +3 -0
@@ -15,6 +15,7 @@#include "ivpu_ipc.h" #include "ivpu_jsm_msg.h" #include "ivpu_pm.h" +#include "ivpu_trace.h" #define IPC_MAX_RX_MSG 128
@@ -227,6 +228,7 @@ int ivpu_ipc_send(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons, stru goto unlock;ivpu_ipc_tx (vdev, cons->tx_vpu_addr); +trace_jsm ("[tx]" , req); unlock:mutex_unlock (&ipc->lock);
@@ -284,6 +286,7 @@ int ivpu_ipc_receive(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,if (jsm_msg)memcpy (jsm_msg, rx_msg->jsm_msg, size); +trace_jsm ("[rx]" , rx_msg->jsm_msg); }ivpu_ipc_rx_msg_del (vdev, rx_msg);
drivers/accel/ivpu/ivpu_job.c +4 -0
@@ -18,6 +18,7 @@#include "ivpu_job.h" #include "ivpu_jsm_msg.h" #include "ivpu_pm.h" +#include "ivpu_trace.h" #include "vpu_boot_api.h" #define CMD_BUF_IDX 0
@@ -482,6 +483,7 @@ ivpu_job_create(struct ivpu_file_priv *file_priv, u32 engine_idx, u32 bo_count) job->file_priv =ivpu_file_priv_get (file_priv); +trace_job ("create" , job);ivpu_dbg (vdev,JOB ,"Job created: ctx %2d engine %d" , file_priv->ctx.id, job->engine_idx);return job;
@@ -521,6 +523,7 @@ static int ivpu_job_signal_and_destroy(struct ivpu_device *vdev, u32 job_id, u32 job->bos[CMD_BUF_IDX ]->job_status = job_status;dma_fence_signal (job->done_fence); +trace_job ("done" , job);ivpu_dbg (vdev,JOB ,"Job complete: id %3u ctx %2d engine %d status 0x%x\n" , job->job_id, job->file_priv->ctx.id, job->engine_idx, job_status);
@@ -588,6 +591,7 @@ static int ivpu_job_submit(struct ivpu_job *job, u8 priority) vdev->busy_start_ts =ktime_get (); } +trace_job ("submit" , job);ivpu_dbg (vdev,JOB ,"Job submitted: id %3u ctx %2d engine %d prio %d addr 0x%llx next %d\n" , job->job_id, file_priv->ctx.id, job->engine_idx, priority, job->cmd_buf_vpu_addr, cmdq->jobq->header.tail);
drivers/accel/ivpu/ivpu_pm.c +9 -0
@@ -20,6 +20,7 @@#include "ivpu_mmu.h" #include "ivpu_ms.h" #include "ivpu_pm.h" +#include "ivpu_trace.h" #include "vpu_boot_api.h" static bool ivpu_disable_recovery;
@@ -198,6 +199,7 @@ int ivpu_pm_suspend_cb(struct device *dev)struct ivpu_device *vdev =to_ivpu_device (drm);unsigned long timeout; +trace_pm ("suspend" );ivpu_dbg (vdev,PM ,"Suspend..\n" ); timeout = jiffies +msecs_to_jiffies (vdev->timeout.tdr);
@@ -215,6 +217,7 @@ int ivpu_pm_suspend_cb(struct device *dev)ivpu_pm_prepare_warm_boot (vdev);ivpu_dbg (vdev,PM ,"Suspend done.\n" ); +trace_pm ("suspend done" );return 0 ; }
@@ -225,6 +228,7 @@ int ivpu_pm_resume_cb(struct device *dev)struct ivpu_device *vdev =to_ivpu_device (drm);int ret; +trace_pm ("resume" );ivpu_dbg (vdev,PM ,"Resume..\n" ); ret =ivpu_resume (vdev);
@@ -232,6 +236,7 @@ int ivpu_pm_resume_cb(struct device *dev)ivpu_err (vdev,"Failed to resume: %d\n" , ret);ivpu_dbg (vdev,PM ,"Resume done.\n" ); +trace_pm ("resume done" );return ret; }
@@ -246,6 +251,7 @@ int ivpu_pm_runtime_suspend_cb(struct device *dev)drm_WARN_ON (&vdev->drm, !xa_empty (&vdev->submitted_jobs_xa));drm_WARN_ON (&vdev->drm,work_pending (&vdev->pm->recovery_work)); +trace_pm ("runtime suspend" );ivpu_dbg (vdev,PM ,"Runtime suspend..\n" );ivpu_mmu_disable (vdev);
@@ -272,6 +278,7 @@ int ivpu_pm_runtime_suspend_cb(struct device *dev) }ivpu_dbg (vdev,PM ,"Runtime suspend done.\n" ); +trace_pm ("runtime suspend done" );return 0 ; }
@@ -282,6 +289,7 @@ int ivpu_pm_runtime_resume_cb(struct device *dev)struct ivpu_device *vdev =to_ivpu_device (drm);int ret; +trace_pm ("runtime resume" );ivpu_dbg (vdev,PM ,"Runtime resume..\n" ); ret =ivpu_resume (vdev);
@@ -289,6 +297,7 @@ int ivpu_pm_runtime_resume_cb(struct device *dev)ivpu_err (vdev,"Failed to set RESUME state: %d\n" , ret);ivpu_dbg (vdev,PM ,"Runtime resume done.\n" ); +trace_pm ("runtime resume done" );return ret; }
drivers/accel/ivpu/ivpu_trace.h new file +73 -0
73 lines not on this page · raw message
drivers/accel/ivpu/ivpu_trace_points.c new file +9 -0
@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2020-2024 Intel Corporation +*/ + +#ifndef __CHECKER__ +#define CREATE_TRACE_POINTS +#include "ivpu_trace.h" +#endif
Signature · 1 line
2.45.1
PATCH v2 31/31 accel/ivpu: Fix typos in ivpu_pm.c
In reply to Jacek LawrynowiczReplace "Filed" with an actual word.
--- drivers/accel/ivpu/ivpu_pm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/accel/ivpu/ivpu_pm.c +2 -2
@@ -423,7 +423,7 @@ int ivpu_pm_dct_enable(struct ivpu_device *vdev, u8 active_percent) ret =ivpu_jsm_dct_enable (vdev, active_us, inactive_us);if (ret) { -ivpu_err_ratelimited (vdev,"Filed to enable DCT: %d\n" , ret); +ivpu_err_ratelimited (vdev,"Failed to enable DCT: %d\n" , ret);return ret; }
@@ -440,7 +440,7 @@ int ivpu_pm_dct_disable(struct ivpu_device *vdev) ret =ivpu_jsm_dct_disable (vdev);if (ret) { -ivpu_err_ratelimited (vdev,"Filed to disable DCT: %d\n" , ret); +ivpu_err_ratelimited (vdev,"Failed to disable DCT: %d\n" , ret);return ret; }
Signature · 1 line
2.45.1
Jacek Lawrynowicz
AppliedApplied to drm-misc-fixes
Quoted 90 lines · Jacek Lawrynowicz
Most notable changes are coredump and tracing support. The rest are stability fixes, some refactoring and typos.
Changes in v2:
- Fix typos in FW API headers
- Split fw refactor commit into 2 commits and improved commit messages
- Fixed commit messages for state dump and power island commits
- Added limit and NULL termination for FW version string
- Documentedsched_modesysfs fileAndrzej Kacprowski (4):
accel/ivpu: Update VPU FW API headers accel/ivpu: Allow readingdvfs_modedebugfs file accel/ivpu: Addtest_modebit to force turbo accel/ivpu: Fixreset_enginedebugfs file logicJacek Lawrynowicz (11):
accel/ivpu: Renameivpu_log_leveltofw_log_levelaccel/ivpu: Refactor functions inivpu_fw_log.caccel/ivpu: Fix fw log printing
accel/ivpu: Limit FW version string length accel/ivpu: Stop using hardcodedDRIVER_DATEaccel/ivpu: Add auto selection logic for job scheduler accel/ivpu: Remove invalid warnings accel/ivpu: Increase MS info buffer size accel/ivpu: Fixivpu_jsm_dyndbg_control()accel/ivpu: RemoveHWS_EXTRA_EVENTSfrom test modes accel/ivpu: Fix typos inivpu_pm.cJakub Pawlak (1):
accel/ivpu: Add tracing for IPC/PM/JOBKarol Wachowski (12):
accel/ivpu: Add coredump support
accel/ivpu: Set 500 ns delay between power island TRICKLE and ENABLE accel/ivpu: Turn on autosuspend on Simics
accel/ivpu: Add FW version debugfs entry
accel/ivpu: Remove 1-tile power up Simics workaround accel/ivpu: Add one jiffy tobo_wait_ioctltimeout value accel/ivpu: Print JSM message result in case of error accel/ivpu: Remove skip of clock own resource ack on Simics accel/ivpu: Prevent recovery invocation during probe and resume accel/ivpu: Refactor failure diagnostics during boot accel/ivpu: Do not fail on cmdq if failed to allocate preemption
buffers
accel/ivpu: Use whole user and shave ranges for preemption buffersTomasz Rusinowicz (3):
accel/ivpu: Reset fw log on cold boot accel/ivpu: Add FW state dump on TDR
accel/ivpu: MakeDB_IDandJOB_IDallocations incrementaldrivers/accel/ivpu/Kconfig | 1 + drivers/accel/ivpu/Makefile | 6 +- drivers/accel/ivpu/ivpu_coredump.c | 39 ++++ drivers/accel/ivpu/ivpu_coredump.h | 25 ++ drivers/accel/ivpu/ivpu_debugfs.c | 86 +++---- drivers/accel/ivpu/ivpu_drv.c | 52 +++-- drivers/accel/ivpu/ivpu_drv.h | 13 +- drivers/accel/ivpu/ivpu_fw.c | 26 ++- drivers/accel/ivpu/ivpu_fw.h | 9 +- drivers/accel/ivpu/ivpu_fw_log.c | 113 +++++---- drivers/accel/ivpu/ivpu_fw_log.h | 17 +- drivers/accel/ivpu/ivpu_gem.c | 3 + drivers/accel/ivpu/ivpu_hw.c | 5 +- drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_btrs.c | 9 - drivers/accel/ivpu/ivpu_hw_ip.c | 8 +- drivers/accel/ivpu/ivpu_ipc.c | 45 ++-- drivers/accel/ivpu/ivpu_ipc.h | 9 +- drivers/accel/ivpu/ivpu_job.c | 102 +++++---- drivers/accel/ivpu/ivpu_jsm_msg.c | 34 +-- drivers/accel/ivpu/ivpu_jsm_msg.h | 2 + drivers/accel/ivpu/ivpu_ms.c | 2 +- drivers/accel/ivpu/ivpu_pm.c | 24 +- drivers/accel/ivpu/ivpu_sysfs.c | 24 ++ drivers/accel/ivpu/ivpu_trace.h | 73 ++++++ drivers/accel/ivpu/ivpu_trace_points.c | 9 + drivers/accel/ivpu/vpu_boot_api.h | 45 ++-- drivers/accel/ivpu/vpu_jsm_api.h | 303 +++++++++++++++++++++---- include/uapi/drm/ivpu_accel.h | 3 - 29 files changed, 797 insertions(+), 291 deletions(-) create mode 100644 drivers/accel/ivpu/ivpu_coredump.c create mode 100644 drivers/accel/ivpu/ivpu_coredump.h create mode 100644 drivers/accel/ivpu/ivpu_trace.h create mode 100644 drivers/accel/ivpu/ivpu_trace_points.c--
2.45.1
Thomas Zimmermann
maintainerHi
Am 02.10.24 um 15:26 schrieb Jacek Lawrynowicz:
Quoted 1 line
Applied to drm-misc-fixes
And removed from drm-misc-fixes.
The -misc-fixes branch is for fixing bugs that either regressed working code or to resolve serious bugs that affects upstream users. It is NOT a dumping ground for all kinds of things you want to get into upstream quickly. Your review process should have found these issues already.
Best regards
Thomas
Quoted 92 lines · Jacek Lawrynowicz
Quoted 90 lines
Most notable changes are coredump and tracing support. The rest are stability fixes, some refactoring and typos.
Changes in v2:
- Fix typos in FW API headers
- Split fw refactor commit into 2 commits and improved commit messages
- Fixed commit messages for state dump and power island commits
- Added limit and NULL termination for FW version string
- Documentedsched_modesysfs fileAndrzej Kacprowski (4):
accel/ivpu: Update VPU FW API headers accel/ivpu: Allow readingdvfs_modedebugfs file accel/ivpu: Addtest_modebit to force turbo accel/ivpu: Fixreset_enginedebugfs file logicJacek Lawrynowicz (11):
accel/ivpu: Renameivpu_log_leveltofw_log_levelaccel/ivpu: Refactor functions inivpu_fw_log.caccel/ivpu: Fix fw log printing
accel/ivpu: Limit FW version string length accel/ivpu: Stop using hardcodedDRIVER_DATEaccel/ivpu: Add auto selection logic for job scheduler accel/ivpu: Remove invalid warnings accel/ivpu: Increase MS info buffer size accel/ivpu: Fixivpu_jsm_dyndbg_control()accel/ivpu: RemoveHWS_EXTRA_EVENTSfrom test modes accel/ivpu: Fix typos inivpu_pm.cJakub Pawlak (1):
accel/ivpu: Add tracing for IPC/PM/JOBKarol Wachowski (12):
accel/ivpu: Add coredump support
accel/ivpu: Set 500 ns delay between power island TRICKLE and ENABLE accel/ivpu: Turn on autosuspend on Simics
accel/ivpu: Add FW version debugfs entry
accel/ivpu: Remove 1-tile power up Simics workaround accel/ivpu: Add one jiffy tobo_wait_ioctltimeout value accel/ivpu: Print JSM message result in case of error accel/ivpu: Remove skip of clock own resource ack on Simics accel/ivpu: Prevent recovery invocation during probe and resume accel/ivpu: Refactor failure diagnostics during boot accel/ivpu: Do not fail on cmdq if failed to allocate preemption
buffers
accel/ivpu: Use whole user and shave ranges for preemption buffersTomasz Rusinowicz (3):
accel/ivpu: Reset fw log on cold boot accel/ivpu: Add FW state dump on TDR accel/ivpu: MakeDB_IDandJOB_IDallocations incrementaldrivers/accel/ivpu/Kconfig | 1 + drivers/accel/ivpu/Makefile | 6 +- drivers/accel/ivpu/ivpu_coredump.c | 39 ++++ drivers/accel/ivpu/ivpu_coredump.h | 25 ++ drivers/accel/ivpu/ivpu_debugfs.c | 86 +++---- drivers/accel/ivpu/ivpu_drv.c | 52 +++-- drivers/accel/ivpu/ivpu_drv.h | 13 +- drivers/accel/ivpu/ivpu_fw.c | 26 ++- drivers/accel/ivpu/ivpu_fw.h | 9 +- drivers/accel/ivpu/ivpu_fw_log.c | 113 +++++---- drivers/accel/ivpu/ivpu_fw_log.h | 17 +- drivers/accel/ivpu/ivpu_gem.c | 3 + drivers/accel/ivpu/ivpu_hw.c | 5 +- drivers/accel/ivpu/ivpu_hw.h | 1 - drivers/accel/ivpu/ivpu_hw_btrs.c | 9 - drivers/accel/ivpu/ivpu_hw_ip.c | 8 +- drivers/accel/ivpu/ivpu_ipc.c | 45 ++-- drivers/accel/ivpu/ivpu_ipc.h | 9 +- drivers/accel/ivpu/ivpu_job.c | 102 +++++---- drivers/accel/ivpu/ivpu_jsm_msg.c | 34 +-- drivers/accel/ivpu/ivpu_jsm_msg.h | 2 + drivers/accel/ivpu/ivpu_ms.c | 2 +- drivers/accel/ivpu/ivpu_pm.c | 24 +- drivers/accel/ivpu/ivpu_sysfs.c | 24 ++ drivers/accel/ivpu/ivpu_trace.h | 73 ++++++ drivers/accel/ivpu/ivpu_trace_points.c | 9 + drivers/accel/ivpu/vpu_boot_api.h | 45 ++-- drivers/accel/ivpu/vpu_jsm_api.h | 303 +++++++++++++++++++++---- include/uapi/drm/ivpu_accel.h | 3 - 29 files changed, 797 insertions(+), 291 deletions(-)create mode 100644
drivers/accel/ivpu/ivpu_coredump.ccreate mode 100644drivers/accel/ivpu/ivpu_coredump.hcreate mode 100644drivers/accel/ivpu/ivpu_trace.hcreate mode 100644drivers/accel/ivpu/ivpu_trace_points.c--
2.45.1
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Hi,
Quoted 6 lines · Thomas Zimmermann
Hi
Am 02.10.24 um 15:26 schrieb Jacek Lawrynowicz:
Quoted 1 line
Applied to drm-misc-fixes
And removed from drm-misc-fixes.
:(
Quoted 1 line
The -misc-fixes branch is for fixing bugs that either regressed working code or to resolve serious bugs that affects upstream users. It is NOT a dumping ground for all kinds of things you want to get into upstream quickly. Your review process should have found these issues already.
Sorry about this. I guess I allowed my upstreaming backlog to grow beyond sensible size. I will apply small subset of these patches to -fixes and the rest to -next.
Regards,
Jacek