HW layer refactor
cover HW layer refactor
The NPU device consists of two parts: NPU buttress and NPU IP. Buttress is a platform specific part that integrates the NPU IP with the CPU.
NPU IP is the platform agnostic part that does the inference.
This refactor enables support for multiple platforms using a single NPU IP, so for example NPU IP 37XX could be integrated into MTL and LNL platforms.
Jacek Lawrynowicz (1):
accel/ivpu: Replace wake_thread with kfifo
Wachowski, Karol (2):
accel/ivpu: Split IP and buttress headers
accel/ivpu: Split IP and buttress code
drivers/accel/ivpu/Makefile | 5 +- drivers/accel/ivpu/ivpu_debugfs.c | 2 +- drivers/accel/ivpu/ivpu_drv.c | 32 +- drivers/accel/ivpu/ivpu_drv.h | 33 +- drivers/accel/ivpu/ivpu_fw.c | 20 +- drivers/accel/ivpu/ivpu_hw.c | 313 +++++ drivers/accel/ivpu/ivpu_hw.h | 196 ++-- drivers/accel/ivpu/ivpu_hw_37xx.c | 1070 ------------------ drivers/accel/ivpu/ivpu_hw_37xx_reg.h | 72 -- drivers/accel/ivpu/ivpu_hw_40xx.c | 1255 --------------------- drivers/accel/ivpu/ivpu_hw_40xx_reg.h | 94 +- drivers/accel/ivpu/ivpu_hw_btrs.c | 881 +++++++++++++++ drivers/accel/ivpu/ivpu_hw_btrs.h | 46 + drivers/accel/ivpu/ivpu_hw_btrs_lnl_reg.h | 108 ++ drivers/accel/ivpu/ivpu_hw_btrs_mtl_reg.h | 83 ++ drivers/accel/ivpu/ivpu_hw_ip.c | 1174 +++++++++++++++++++ drivers/accel/ivpu/ivpu_hw_ip.h | 36 + drivers/accel/ivpu/ivpu_ipc.c | 17 +- drivers/accel/ivpu/ivpu_ipc.h | 4 +- drivers/accel/ivpu/ivpu_job.c | 2 +- 20 files changed, 2799 insertions(+), 2644 deletions(-) create mode 100644 drivers/accel/ivpu/ivpu_hw.c delete mode 100644 drivers/accel/ivpu/ivpu_hw_37xx.c delete mode 100644 drivers/accel/ivpu/ivpu_hw_40xx.c create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs.c create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs.h create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs_lnl_reg.h create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs_mtl_reg.h create mode 100644 drivers/accel/ivpu/ivpu_hw_ip.c create mode 100644 drivers/accel/ivpu/ivpu_hw_ip.h
--
2.43.2
PATCH 1/3 accel/ivpu: Split IP and buttress headers
From: "Wachowski, Karol" <[email protected]>
Move buttress registers to ivpu_hw_btrs_*_reg.h headers. This is an intermediate step before HW layer refactor.
--- drivers/accel/ivpu/ivpu_hw_37xx.c | 153 ++++++++-------- drivers/accel/ivpu/ivpu_hw_37xx_reg.h | 72 -------- drivers/accel/ivpu/ivpu_hw_40xx.c | 211 +++++++++++----------- drivers/accel/ivpu/ivpu_hw_40xx_reg.h | 94 +--------- drivers/accel/ivpu/ivpu_hw_btrs_lnl_reg.h | 108 +++++++++++ drivers/accel/ivpu/ivpu_hw_btrs_mtl_reg.h | 83 +++++++++ 6 files changed, 383 insertions(+), 338 deletions(-) create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs_lnl_reg.h create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs_mtl_reg.h
drivers/accel/ivpu/ivpu_hw_37xx.c +77 -76
@@ -5,6 +5,7 @@#include "ivpu_drv.h" #include "ivpu_fw.h" +#include "ivpu_hw_btrs_mtl_reg.h" #include "ivpu_hw_37xx_reg.h" #include "ivpu_hw_reg_io.h" #include "ivpu_hw.h"
@@ -54,11 +55,11 @@#define ICB_0_1_IRQ_MASK ((((u64)ICB_1_IRQ_MASK) << 32) | ICB_0_IRQ_MASK) -#define BUTTRESS_IRQ_MASK ((REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, ATS_ERR)) | \ - (REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, UFI_ERR))) +#define BUTTRESS_IRQ_MASK ((REG_FLD(VPU_HW_BTRS_MTL_INTERRUPT_STAT, ATS_ERR)) | \ + (REG_FLD(VPU_HW_BTRS_MTL_INTERRUPT_STAT, UFI_ERR)))#define BUTTRESS_ALL_IRQ_MASK (BUTTRESS_IRQ_MASK | \ - (REG_FLD(VPU_37XX_BUTTRESS_INTERRUPT_STAT, FREQ_CHANGE))) + (REG_FLD(VPU_HW_BTRS_MTL_INTERRUPT_STAT, FREQ_CHANGE)))#define BUTTRESS_IRQ_ENABLE_MASK ((u32)~BUTTRESS_IRQ_MASK)#define BUTTRESS_IRQ_DISABLE_MASK ((u32)-1)
@@ -76,11 +77,11 @@ static void ivpu_hw_wa_init(struct ivpu_device *vdev) vdev->wa.punit_disabled = false; vdev->wa.clear_runtime_mem = false; -REGB_WR32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,BUTTRESS_ALL_IRQ_MASK ); -if (REGB_RD32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ) ==BUTTRESS_ALL_IRQ_MASK ) { +REGB_WR32 (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,BUTTRESS_ALL_IRQ_MASK ); +if (REGB_RD32 (VPU_HW_BTRS_MTL_INTERRUPT_STAT ) ==BUTTRESS_ALL_IRQ_MASK ) {/* Writing 1s does not clear the interrupt status register */ vdev->wa.interrupt_clear_with_0 = true; -REGB_WR32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,0x0 ); +REGB_WR32 (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,0x0 ); }IVPU_PRINT_WA (punit_disabled);
@@ -100,7 +101,7 @@ static void ivpu_hw_timeouts_init(struct ivpu_device *vdev)static int ivpu_pll_wait_for_cmd_send (struct ivpu_device *vdev) { -return REGB_POLL_FLD (VPU_37XX_BUTTRESS_WP_REQ_CMD ,SEND ,0 ,PLL_TIMEOUT_US ); +return REGB_POLL_FLD (VPU_HW_BTRS_MTL_WP_REQ_CMD ,SEND ,0 ,PLL_TIMEOUT_US ); }/* Send KMD initiated workpoint change */
@@ -116,23 +117,23 @@ static int ivpu_pll_cmd_send(struct ivpu_device *vdev, u16 min_ratio, u16 max_rareturn ret; } - val =REGB_RD32 (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD0 ); - val =REG_SET_FLD_NUM (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD0 ,MIN_RATIO , min_ratio, val); - val =REG_SET_FLD_NUM (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD0 ,MAX_RATIO , max_ratio, val); -REGB_WR32 (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD0 , val); + val =REGB_RD32 (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD0 ); + val =REG_SET_FLD_NUM (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD0 ,MIN_RATIO , min_ratio, val); + val =REG_SET_FLD_NUM (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD0 ,MAX_RATIO , max_ratio, val); +REGB_WR32 (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD0 , val); - val =REGB_RD32 (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD1 ); - val =REG_SET_FLD_NUM (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD1 ,TARGET_RATIO , target_ratio, val); - val =REG_SET_FLD_NUM (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD1 ,EPP ,PLL_DEFAULT_EPP_VALUE , val); -REGB_WR32 (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD1 , val); + val =REGB_RD32 (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD1 ); + val =REG_SET_FLD_NUM (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD1 ,TARGET_RATIO , target_ratio, val); + val =REG_SET_FLD_NUM (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD1 ,EPP ,PLL_DEFAULT_EPP_VALUE , val); +REGB_WR32 (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD1 , val); - val =REGB_RD32 (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD2 ); - val =REG_SET_FLD_NUM (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD2 ,CONFIG , config, val); -REGB_WR32 (VPU_37XX_BUTTRESS_WP_REQ_PAYLOAD2 , val); + val =REGB_RD32 (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD2 ); + val =REG_SET_FLD_NUM (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD2 ,CONFIG , config, val); +REGB_WR32 (VPU_HW_BTRS_MTL_WP_REQ_PAYLOAD2 , val); - val =REGB_RD32 (VPU_37XX_BUTTRESS_WP_REQ_CMD ); - val =REG_SET_FLD (VPU_37XX_BUTTRESS_WP_REQ_CMD ,SEND , val); -REGB_WR32 (VPU_37XX_BUTTRESS_WP_REQ_CMD , val); + val =REGB_RD32 (VPU_HW_BTRS_MTL_WP_REQ_CMD ); + val =REG_SET_FLD (VPU_HW_BTRS_MTL_WP_REQ_CMD ,SEND , val); +REGB_WR32 (VPU_HW_BTRS_MTL_WP_REQ_CMD , val); ret =ivpu_pll_wait_for_cmd_send (vdev);if (ret)
@@ -148,7 +149,7 @@ static int ivpu_pll_wait_for_lock(struct ivpu_device *vdev, bool enable)if (IVPU_WA (punit_disabled))return 0 ; -return REGB_POLL_FLD (VPU_37XX_BUTTRESS_PLL_STATUS ,LOCK , exp_val,PLL_TIMEOUT_US ); +return REGB_POLL_FLD (VPU_HW_BTRS_MTL_PLL_STATUS ,LOCK , exp_val,PLL_TIMEOUT_US ); }static int ivpu_pll_wait_for_status_ready (struct ivpu_device *vdev)
@@ -156,7 +157,7 @@ static int ivpu_pll_wait_for_status_ready(struct ivpu_device *vdev)if (IVPU_WA (punit_disabled))return 0 ; -return REGB_POLL_FLD (VPU_37XX_BUTTRESS_VPU_STATUS ,READY ,1 ,PLL_TIMEOUT_US ); +return REGB_POLL_FLD (VPU_HW_BTRS_MTL_VPU_STATUS ,READY ,1 ,PLL_TIMEOUT_US ); }static void ivpu_pll_init_frequency_ratios (struct ivpu_device *vdev)
@@ -165,12 +166,12 @@ static void ivpu_pll_init_frequency_ratios(struct ivpu_device *vdev)u8 fuse_min_ratio, fuse_max_ratio, fuse_pn_ratio;u32 fmin_fuse, fmax_fuse; - fmin_fuse =REGB_RD32 (VPU_37XX_BUTTRESS_FMIN_FUSE ); - fuse_min_ratio =REG_GET_FLD (VPU_37XX_BUTTRESS_FMIN_FUSE ,MIN_RATIO , fmin_fuse); - fuse_pn_ratio =REG_GET_FLD (VPU_37XX_BUTTRESS_FMIN_FUSE ,PN_RATIO , fmin_fuse); + fmin_fuse =REGB_RD32 (VPU_HW_BTRS_MTL_FMIN_FUSE ); + fuse_min_ratio =REG_GET_FLD (VPU_HW_BTRS_MTL_FMIN_FUSE ,MIN_RATIO , fmin_fuse); + fuse_pn_ratio =REG_GET_FLD (VPU_HW_BTRS_MTL_FMIN_FUSE ,PN_RATIO , fmin_fuse); - fmax_fuse =REGB_RD32 (VPU_37XX_BUTTRESS_FMAX_FUSE ); - fuse_max_ratio =REG_GET_FLD (VPU_37XX_BUTTRESS_FMAX_FUSE ,MAX_RATIO , fmax_fuse); + fmax_fuse =REGB_RD32 (VPU_HW_BTRS_MTL_FMAX_FUSE ); + fuse_max_ratio =REG_GET_FLD (VPU_HW_BTRS_MTL_FMAX_FUSE ,MAX_RATIO , fmax_fuse); hw->pll.min_ratio =clamp_t (u8, ivpu_pll_min_ratio, fuse_min_ratio, fuse_max_ratio); hw->pll.max_ratio =clamp_t (u8, ivpu_pll_max_ratio, hw->pll.min_ratio, fuse_max_ratio);
@@ -566,20 +567,20 @@ static int ivpu_boot_d0i3_drive(struct ivpu_device *vdev, bool enable)int ret;u32 val; - ret =REGB_POLL_FLD (VPU_37XX_BUTTRESS_VPU_D0I3_CONTROL ,INPROGRESS ,0 ,TIMEOUT_US ); + ret =REGB_POLL_FLD (VPU_HW_BTRS_MTL_VPU_D0I3_CONTROL ,INPROGRESS ,0 ,TIMEOUT_US );if (ret) {ivpu_err (vdev,"Failed to sync before D0i3 transition: %d\n" , ret);return ret; } - val =REGB_RD32 (VPU_37XX_BUTTRESS_VPU_D0I3_CONTROL ); + val =REGB_RD32 (VPU_HW_BTRS_MTL_VPU_D0I3_CONTROL );if (enable) - val =REG_SET_FLD (VPU_37XX_BUTTRESS_VPU_D0I3_CONTROL ,I3 , val); + val =REG_SET_FLD (VPU_HW_BTRS_MTL_VPU_D0I3_CONTROL ,I3 , val);else - val =REG_CLR_FLD (VPU_37XX_BUTTRESS_VPU_D0I3_CONTROL ,I3 , val); -REGB_WR32 (VPU_37XX_BUTTRESS_VPU_D0I3_CONTROL , val); + val =REG_CLR_FLD (VPU_HW_BTRS_MTL_VPU_D0I3_CONTROL ,I3 , val); +REGB_WR32 (VPU_HW_BTRS_MTL_VPU_D0I3_CONTROL , val); - ret =REGB_POLL_FLD (VPU_37XX_BUTTRESS_VPU_D0I3_CONTROL ,INPROGRESS ,0 ,TIMEOUT_US ); + ret =REGB_POLL_FLD (VPU_HW_BTRS_MTL_VPU_D0I3_CONTROL ,INPROGRESS ,0 ,TIMEOUT_US );if (ret)ivpu_err (vdev,"Failed to sync after D0i3 transition: %d\n" , ret);
@@ -617,17 +618,17 @@ static int ivpu_hw_37xx_ip_reset(struct ivpu_device *vdev)if (IVPU_WA (punit_disabled))return 0 ; - ret =REGB_POLL_FLD (VPU_37XX_BUTTRESS_VPU_IP_RESET ,TRIGGER ,0 ,TIMEOUT_US ); + ret =REGB_POLL_FLD (VPU_HW_BTRS_MTL_VPU_IP_RESET ,TRIGGER ,0 ,TIMEOUT_US );if (ret) {ivpu_err (vdev,"Timed out waiting for TRIGGER bit\n" );return ret; } - val =REGB_RD32 (VPU_37XX_BUTTRESS_VPU_IP_RESET ); - val =REG_SET_FLD (VPU_37XX_BUTTRESS_VPU_IP_RESET ,TRIGGER , val); -REGB_WR32 (VPU_37XX_BUTTRESS_VPU_IP_RESET , val); + val =REGB_RD32 (VPU_HW_BTRS_MTL_VPU_IP_RESET ); + val =REG_SET_FLD (VPU_HW_BTRS_MTL_VPU_IP_RESET ,TRIGGER , val); +REGB_WR32 (VPU_HW_BTRS_MTL_VPU_IP_RESET , val); - ret =REGB_POLL_FLD (VPU_37XX_BUTTRESS_VPU_IP_RESET ,TRIGGER ,0 ,TIMEOUT_US ); + ret =REGB_POLL_FLD (VPU_HW_BTRS_MTL_VPU_IP_RESET ,TRIGGER ,0 ,TIMEOUT_US );if (ret)ivpu_err (vdev,"Timed out waiting for RESET completion\n" );
@@ -742,14 +743,14 @@ static bool ivpu_hw_37xx_is_idle(struct ivpu_device *vdev)if (IVPU_WA (punit_disabled))return true; - val =REGB_RD32 (VPU_37XX_BUTTRESS_VPU_STATUS ); -return REG_TEST_FLD (VPU_37XX_BUTTRESS_VPU_STATUS ,READY , val) && -REG_TEST_FLD (VPU_37XX_BUTTRESS_VPU_STATUS ,IDLE , val); + val =REGB_RD32 (VPU_HW_BTRS_MTL_VPU_STATUS ); +return REG_TEST_FLD (VPU_HW_BTRS_MTL_VPU_STATUS ,READY , val) && +REG_TEST_FLD (VPU_HW_BTRS_MTL_VPU_STATUS ,IDLE , val); }static int ivpu_hw_37xx_wait_for_idle (struct ivpu_device *vdev) { -return REGB_POLL_FLD (VPU_37XX_BUTTRESS_VPU_STATUS ,IDLE ,0x1 ,IDLE_TIMEOUT_US ); +return REGB_POLL_FLD (VPU_HW_BTRS_MTL_VPU_STATUS ,IDLE ,0x1 ,IDLE_TIMEOUT_US ); }static void ivpu_hw_37xx_save_d0i3_entry_timestamp (struct ivpu_device *vdev)
@@ -826,8 +827,8 @@ static u32 ivpu_hw_37xx_reg_pll_freq_get(struct ivpu_device *vdev) {u32 pll_curr_ratio; - pll_curr_ratio =REGB_RD32 (VPU_37XX_BUTTRESS_CURRENT_PLL ); - pll_curr_ratio &=VPU_37XX_BUTTRESS_CURRENT_PLL_RATIO_MASK ; + pll_curr_ratio =REGB_RD32 (VPU_HW_BTRS_MTL_CURRENT_PLL ); + pll_curr_ratio &=VPU_HW_BTRS_MTL_CURRENT_PLL_RATIO_MASK ;if (!ivpu_is_silicon (vdev))return PLL_SIMULATION_FREQ ;
@@ -837,17 +838,17 @@ static u32 ivpu_hw_37xx_reg_pll_freq_get(struct ivpu_device *vdev)static u32 ivpu_hw_37xx_reg_telemetry_offset_get (struct ivpu_device *vdev) { -return REGB_RD32 (VPU_37XX_BUTTRESS_VPU_TELEMETRY_OFFSET ); +return REGB_RD32 (VPU_HW_BTRS_MTL_VPU_TELEMETRY_OFFSET ); }static u32 ivpu_hw_37xx_reg_telemetry_size_get (struct ivpu_device *vdev) { -return REGB_RD32 (VPU_37XX_BUTTRESS_VPU_TELEMETRY_SIZE ); +return REGB_RD32 (VPU_HW_BTRS_MTL_VPU_TELEMETRY_SIZE ); }static u32 ivpu_hw_37xx_reg_telemetry_enable_get (struct ivpu_device *vdev) { -return REGB_RD32 (VPU_37XX_BUTTRESS_VPU_TELEMETRY_ENABLE ); +return REGB_RD32 (VPU_HW_BTRS_MTL_VPU_TELEMETRY_ENABLE ); }static void ivpu_hw_37xx_reg_db_set (struct ivpu_device *vdev,u32 db_id)
@@ -884,14 +885,14 @@ static void ivpu_hw_37xx_irq_enable(struct ivpu_device *vdev) {REGV_WR32 (VPU_37XX_HOST_SS_FW_SOC_IRQ_EN ,ITF_FIREWALL_VIOLATION_MASK );REGV_WR64 (VPU_37XX_HOST_SS_ICB_ENABLE_0 ,ICB_0_1_IRQ_MASK ); -REGB_WR32 (VPU_37XX_BUTTRESS_LOCAL_INT_MASK ,BUTTRESS_IRQ_ENABLE_MASK ); -REGB_WR32 (VPU_37XX_BUTTRESS_GLOBAL_INT_MASK ,0x0 ); +REGB_WR32 (VPU_HW_BTRS_MTL_LOCAL_INT_MASK ,BUTTRESS_IRQ_ENABLE_MASK ); +REGB_WR32 (VPU_HW_BTRS_MTL_GLOBAL_INT_MASK ,0x0 ); }static void ivpu_hw_37xx_irq_disable (struct ivpu_device *vdev) { -REGB_WR32 (VPU_37XX_BUTTRESS_GLOBAL_INT_MASK ,0x1 ); -REGB_WR32 (VPU_37XX_BUTTRESS_LOCAL_INT_MASK ,BUTTRESS_IRQ_DISABLE_MASK ); +REGB_WR32 (VPU_HW_BTRS_MTL_GLOBAL_INT_MASK ,0x1 ); +REGB_WR32 (VPU_HW_BTRS_MTL_LOCAL_INT_MASK ,BUTTRESS_IRQ_DISABLE_MASK );REGV_WR64 (VPU_37XX_HOST_SS_ICB_ENABLE_0 ,0x0ull );REGV_WR32 (VPU_37XX_HOST_SS_FW_SOC_IRQ_EN ,0x0 ); }
@@ -949,30 +950,30 @@ static bool ivpu_hw_37xx_irqv_handler(struct ivpu_device *vdev, int irq, bool *w/* Handler for IRQs from Buttress core (irqB) */ static bool ivpu_hw_37xx_irqb_handler (struct ivpu_device *vdev,int irq) { -u32 status =REGB_RD32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ) &BUTTRESS_IRQ_MASK ; +u32 status =REGB_RD32 (VPU_HW_BTRS_MTL_INTERRUPT_STAT ) &BUTTRESS_IRQ_MASK ;bool schedule_recovery = false;if (!status)return false; -if (REG_TEST_FLD (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,FREQ_CHANGE , status)) +if (REG_TEST_FLD (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,FREQ_CHANGE , status))ivpu_dbg (vdev,IRQ ,"FREQ_CHANGE irq: %08x" , -REGB_RD32 (VPU_37XX_BUTTRESS_CURRENT_PLL )); +REGB_RD32 (VPU_HW_BTRS_MTL_CURRENT_PLL )); -if (REG_TEST_FLD (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,ATS_ERR , status)) { -ivpu_err (vdev,"ATS_ERR irq 0x%016llx" ,REGB_RD64 (VPU_37XX_BUTTRESS_ATS_ERR_LOG_0 )); -REGB_WR32 (VPU_37XX_BUTTRESS_ATS_ERR_CLEAR ,0x1 ); +if (REG_TEST_FLD (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,ATS_ERR , status)) { +ivpu_err (vdev,"ATS_ERR irq 0x%016llx" ,REGB_RD64 (VPU_HW_BTRS_MTL_ATS_ERR_LOG_0 )); +REGB_WR32 (VPU_HW_BTRS_MTL_ATS_ERR_CLEAR ,0x1 ); schedule_recovery = true; } -if (REG_TEST_FLD (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,UFI_ERR , status)) { -u32 ufi_log =REGB_RD32 (VPU_37XX_BUTTRESS_UFI_ERR_LOG ); +if (REG_TEST_FLD (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,UFI_ERR , status)) { +u32 ufi_log =REGB_RD32 (VPU_HW_BTRS_MTL_UFI_ERR_LOG );ivpu_err (vdev,"UFI_ERR irq (0x%08x) opcode: 0x%02lx axi_id: 0x%02lx cq_id: 0x%03lx" , - ufi_log,REG_GET_FLD (VPU_37XX_BUTTRESS_UFI_ERR_LOG ,OPCODE , ufi_log), -REG_GET_FLD (VPU_37XX_BUTTRESS_UFI_ERR_LOG ,AXI_ID , ufi_log), -REG_GET_FLD (VPU_37XX_BUTTRESS_UFI_ERR_LOG ,CQ_ID , ufi_log)); -REGB_WR32 (VPU_37XX_BUTTRESS_UFI_ERR_CLEAR ,0x1 ); + ufi_log,REG_GET_FLD (VPU_HW_BTRS_MTL_UFI_ERR_LOG ,OPCODE , ufi_log), +REG_GET_FLD (VPU_HW_BTRS_MTL_UFI_ERR_LOG ,AXI_ID , ufi_log), +REG_GET_FLD (VPU_HW_BTRS_MTL_UFI_ERR_LOG ,CQ_ID , ufi_log)); +REGB_WR32 (VPU_HW_BTRS_MTL_UFI_ERR_CLEAR ,0x1 ); schedule_recovery = true; }
@@ -982,9 +983,9 @@ static bool ivpu_hw_37xx_irqb_handler(struct ivpu_device *vdev, int irq)* Writing 1 triggers an interrupt, so we can't perform read update write. * Clear local interrupt status by writing 0 to all bits. */ -REGB_WR32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,0x0 ); +REGB_WR32 (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,0x0 ); else -REGB_WR32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,status ); +REGB_WR32 (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,status );if (schedule_recovery)ivpu_pm_trigger_recovery (vdev,"Buttress IRQ" );
@@ -997,13 +998,13 @@ static irqreturn_t ivpu_hw_37xx_irq_handler(int irq, void *ptr)struct ivpu_device *vdev = ptr;bool irqv_handled, irqb_handled, wake_thread = false; -REGB_WR32 (VPU_37XX_BUTTRESS_GLOBAL_INT_MASK ,0x1 ); +REGB_WR32 (VPU_HW_BTRS_MTL_GLOBAL_INT_MASK ,0x1 ); irqv_handled =ivpu_hw_37xx_irqv_handler (vdev, irq, &wake_thread); irqb_handled =ivpu_hw_37xx_irqb_handler (vdev, irq);/* Re-enable global interrupts to re-trigger MSI for pending interrupts */ -REGB_WR32 (VPU_37XX_BUTTRESS_GLOBAL_INT_MASK ,0x0 ); +REGB_WR32 (VPU_HW_BTRS_MTL_GLOBAL_INT_MASK ,0x0 );if (wake_thread)return IRQ_WAKE_THREAD ;
@@ -1015,7 +1016,7 @@ static irqreturn_t ivpu_hw_37xx_irq_handler(int irq, void *ptr)static void ivpu_hw_37xx_diagnose_failure (struct ivpu_device *vdev) {u32 irqv =REGV_RD32 (VPU_37XX_HOST_SS_ICB_STATUS_0 ) &ICB_0_IRQ_MASK ; -u32 irqb =REGB_RD32 (VPU_37XX_BUTTRESS_INTERRUPT_STAT ) &BUTTRESS_IRQ_MASK ; +u32 irqb =REGB_RD32 (VPU_HW_BTRS_MTL_INTERRUPT_STAT ) &BUTTRESS_IRQ_MASK ;if (ivpu_hw_37xx_reg_ipc_rx_count_get (vdev))ivpu_err (vdev,"IPC FIFO queue not empty, missed IPC IRQ" );
@@ -1029,16 +1030,16 @@ static void ivpu_hw_37xx_diagnose_failure(struct ivpu_device *vdev)if (REG_TEST_FLD (VPU_37XX_HOST_SS_ICB_STATUS_0 ,NOC_FIREWALL_INT , irqv))ivpu_err (vdev,"NOC Firewall irq detected\n" ); -if (REG_TEST_FLD (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,ATS_ERR , irqb)) -ivpu_err (vdev,"ATS_ERR irq 0x%016llx" ,REGB_RD64 (VPU_37XX_BUTTRESS_ATS_ERR_LOG_0 )); +if (REG_TEST_FLD (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,ATS_ERR , irqb)) +ivpu_err (vdev,"ATS_ERR irq 0x%016llx" ,REGB_RD64 (VPU_HW_BTRS_MTL_ATS_ERR_LOG_0 )); -if (REG_TEST_FLD (VPU_37XX_BUTTRESS_INTERRUPT_STAT ,UFI_ERR , irqb)) { -u32 ufi_log =REGB_RD32 (VPU_37XX_BUTTRESS_UFI_ERR_LOG ); +if (REG_TEST_FLD (VPU_HW_BTRS_MTL_INTERRUPT_STAT ,UFI_ERR , irqb)) { +u32 ufi_log =REGB_RD32 (VPU_HW_BTRS_MTL_UFI_ERR_LOG );ivpu_err (vdev,"UFI_ERR irq (0x%08x) opcode: 0x%02lx axi_id: 0x%02lx cq_id: 0x%03lx" , - ufi_log,REG_GET_FLD (VPU_37XX_BUTTRESS_UFI_ERR_LOG ,OPCODE , ufi_log), -REG_GET_FLD (VPU_37XX_BUTTRESS_UFI_ERR_LOG ,AXI_ID , ufi_log), -REG_GET_FLD (VPU_37XX_BUTTRESS_UFI_ERR_LOG ,CQ_ID , ufi_log)); + ufi_log,REG_GET_FLD (VPU_HW_BTRS_MTL_UFI_ERR_LOG ,OPCODE , ufi_log), +REG_GET_FLD (VPU_HW_BTRS_MTL_UFI_ERR_LOG ,AXI_ID , ufi_log), +REG_GET_FLD (VPU_HW_BTRS_MTL_UFI_ERR_LOG ,CQ_ID , ufi_log)); } }
drivers/accel/ivpu/ivpu_hw_37xx_reg.h +0 -72
78 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_40xx.c +106 -105
426 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_40xx_reg.h +9 -85
112 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_btrs_lnl_reg.h new file +108 -0
108 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_btrs_mtl_reg.h new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.43.2
PATCH 2/3 accel/ivpu: Split IP and buttress code
In reply to Jacek LawrynowiczFrom: "Wachowski, Karol" <[email protected]>
The NPU device consists of two parts: NPU buttress and NPU IP. Buttress is a platform specific part that integrates the NPU IP with the CPU.
NPU IP is the platform agnostic part that does the inference.
This separation enables support for multiple platforms using a single NPU IP, so for example NPU IP 37XX could be integrated into MTL and LNL platforms.
--- drivers/accel/ivpu/Makefile | 5 +- drivers/accel/ivpu/ivpu_debugfs.c | 2 +- drivers/accel/ivpu/ivpu_drv.c | 13 +- drivers/accel/ivpu/ivpu_drv.h | 33 +- drivers/accel/ivpu/ivpu_fw.c | 20 +- drivers/accel/ivpu/ivpu_hw.c | 310 +++++++ drivers/accel/ivpu/ivpu_hw.h | 191 ++--- drivers/accel/ivpu/ivpu_hw_37xx.c | 1071 ------------------------ drivers/accel/ivpu/ivpu_hw_40xx.c | 1256 ----------------------------- drivers/accel/ivpu/ivpu_hw_btrs.c | 881 ++++++++++++++++++++ drivers/accel/ivpu/ivpu_hw_btrs.h | 46 ++ drivers/accel/ivpu/ivpu_hw_ip.c | 1174 +++++++++++++++++++++++++++ drivers/accel/ivpu/ivpu_hw_ip.h | 36 + drivers/accel/ivpu/ivpu_ipc.c | 6 +- drivers/accel/ivpu/ivpu_job.c | 2 +- 15 files changed, 2566 insertions(+), 2480 deletions(-) create mode 100644 drivers/accel/ivpu/ivpu_hw.c delete mode 100644 drivers/accel/ivpu/ivpu_hw_37xx.c delete mode 100644 drivers/accel/ivpu/ivpu_hw_40xx.c create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs.c create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs.h create mode 100644 drivers/accel/ivpu/ivpu_hw_ip.c create mode 100644 drivers/accel/ivpu/ivpu_hw_ip.h
drivers/accel/ivpu/Makefile +3 -2
@@ -6,8 +6,9 @@ intel_vpu-y := \ ivpu_fw.o \ ivpu_fw_log.o \ ivpu_gem.o \ - ivpu_hw_37xx.o \ - ivpu_hw_40xx.o \ + ivpu_hw.o \ + ivpu_hw_btrs.o \ + ivpu_hw_ip.o \ ivpu_ipc.o \ ivpu_job.o \ ivpu_jsm_msg.o \
drivers/accel/ivpu/ivpu_debugfs.c +1 -1
@@ -409,7 +409,7 @@ void ivpu_debugfs_init(struct ivpu_device *vdev)debugfs_create_file ("resume_engine" ,0200 , debugfs_root, vdev, &ivpu_resume_engine_fops); -if (ivpu_hw_gen (vdev) >=IVPU_HW_40XX ) +if (ivpu_hw_ip_gen (vdev) >=IVPU_HW_IP_40XX )debugfs_create_file ("fw_profiling_freq_drive" ,0200 , debugfs_root, vdev, &fw_profiling_freq_fops); }
drivers/accel/ivpu/ivpu_drv.c +6 -7
@@ -464,9 +464,11 @@ static int ivpu_irq_init(struct ivpu_device *vdev)return ret; } +ivpu_irq_handlers_init (vdev); + vdev->irq =pci_irq_vector (pdev,0 ); - ret =devm_request_threaded_irq (vdev->drm.dev, vdev->irq, vdev->hw->ops->irq_handler, + ret =devm_request_threaded_irq (vdev->drm.dev, vdev->irq, ivpu_hw_irq_handler, ivpu_irq_thread_handler,IRQF_NO_AUTOEN ,DRIVER_NAME , vdev);if (ret)ivpu_err (vdev,"Failed to request an IRQ %d\n" , ret);
@@ -543,13 +545,10 @@ static int ivpu_dev_init(struct ivpu_device *vdev)if (!vdev->pm)return -ENOMEM ; -if (ivpu_hw_gen (vdev) >=IVPU_HW_40XX ) { - vdev->hw->ops = &ivpu_hw_40xx_ops; +if (ivpu_hw_ip_gen (vdev) >=IVPU_HW_IP_40XX ) vdev->hw->dma_bits =48 ; - }else { - vdev->hw->ops = &ivpu_hw_37xx_ops; +else vdev->hw->dma_bits =38 ; - } vdev->platform =IVPU_PLATFORM_INVALID ; vdev->context_xa_limit.min =IVPU_USER_CONTEXT_MIN_SSID ;
@@ -578,7 +577,7 @@ static int ivpu_dev_init(struct ivpu_device *vdev) goto err_xa_destroy;/* Init basic HW info based on buttress registers which are accessible before power up */ - ret =ivpu_hw_info_init (vdev); + ret =ivpu_hw_init (vdev);if (ret) goto err_xa_destroy;
drivers/accel/ivpu/ivpu_drv.h +27 -6
@@ -27,8 +27,13 @@#define PCI_DEVICE_ID_ARL 0xad1d#define PCI_DEVICE_ID_LNL 0x643e -#define IVPU_HW_37XX 37 -#define IVPU_HW_40XX 40 +#define IVPU_HW_IP_37XX 37 +#define IVPU_HW_IP_40XX 40 +#define IVPU_HW_IP_50XX 50 +#define IVPU_HW_IP_60XX 60 + +#define IVPU_HW_BTRS_MTL 1 +#define IVPU_HW_BTRS_LNL 2#define IVPU_GLOBAL_CONTEXT_MMU_SSID 0/* SSID 1 is used by the VPU to represent reserved context */
@@ -198,16 +203,32 @@ static inline u16 ivpu_device_id(struct ivpu_device *vdev)return to_pci_dev (vdev->drm.dev)->device; } -static inline int ivpu_hw_gen (struct ivpu_device *vdev) +static inline int ivpu_hw_ip_gen (struct ivpu_device *vdev) +{ +switch (ivpu_device_id (vdev)) { +case PCI_DEVICE_ID_MTL : +case PCI_DEVICE_ID_ARL : +return IVPU_HW_IP_37XX ; +case PCI_DEVICE_ID_LNL : +return IVPU_HW_IP_40XX ; +default : +dump_stack (); +ivpu_err (vdev,"Unknown NPU IP generation\n" ); +return 0 ; + } +} + +static inline int ivpu_hw_btrs_gen (struct ivpu_device *vdev) {switch (ivpu_device_id (vdev)) {case PCI_DEVICE_ID_MTL :case PCI_DEVICE_ID_ARL : -return IVPU_HW_37XX ; +return IVPU_HW_BTRS_MTL ;case PCI_DEVICE_ID_LNL : -return IVPU_HW_40XX ; +return IVPU_HW_BTRS_LNL ;default : -ivpu_err (vdev,"Unknown NPU device\n" ); +dump_stack (); +ivpu_err (vdev,"Unknown buttress generation\n" );return 0 ; } }
drivers/accel/ivpu/ivpu_fw.c +10 -10
@@ -54,10 +54,10 @@ static struct {int gen;const char *name; } fw_names[] = { - { IVPU_HW_37XX, "vpu_37xx.bin" }, - { IVPU_HW_37XX, "intel/vpu/vpu_37xx_v0.0.bin" }, - { IVPU_HW_40XX, "vpu_40xx.bin" }, - { IVPU_HW_40XX, "intel/vpu/vpu_40xx_v0.0.bin" }, + { IVPU_HW_IP_37XX, "vpu_37xx.bin" }, + { IVPU_HW_IP_37XX, "intel/vpu/vpu_37xx_v0.0.bin" }, + { IVPU_HW_IP_40XX, "vpu_40xx.bin" }, + { IVPU_HW_IP_40XX, "intel/vpu/vpu_40xx_v0.0.bin" }, }; static int ivpu_fw_request(struct ivpu_device *vdev)
@@ -73,7 +73,7 @@ static int ivpu_fw_request(struct ivpu_device *vdev) }for (i =0 ; i <ARRAY_SIZE (fw_names); i++) { -if (fw_names[i].gen !=ivpu_hw_gen (vdev)) +if (fw_names[i].gen !=ivpu_hw_ip_gen (vdev))continue ; ret =firmware_request_nowarn (&vdev->fw->file, fw_names[i].name, vdev->drm.dev);
@@ -246,7 +246,7 @@ static int ivpu_fw_update_global_range(struct ivpu_device *vdev)return -EINVAL ; } -ivpu_hw_init_range (&vdev->hw->ranges.global, start, size); +ivpu_hw_range_init (&vdev->hw->ranges.global, start, size);return 0 ; }
@@ -511,7 +511,7 @@ void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params boot_params->magic =VPU_BOOT_PARAMS_MAGIC ; boot_params->vpu_id =to_pci_dev (vdev->drm.dev)->bus->number; - boot_params->frequency =ivpu_hw_reg_pll_freq_get (vdev); + boot_params->frequency =ivpu_hw_pll_freq_get (vdev);/* * This param is a debug firmware feature. It switches default clock
@@ -568,9 +568,9 @@ void ivpu_fw_boot_params_setup(struct ivpu_device *vdev, struct vpu_boot_params boot_params->verbose_tracing_buff_addr = vdev->fw->mem_log_verb->vpu_addr; boot_params->verbose_tracing_buff_size =ivpu_bo_size (vdev->fw->mem_log_verb); - boot_params->punit_telemetry_sram_base =ivpu_hw_reg_telemetry_offset_get (vdev); - boot_params->punit_telemetry_sram_size =ivpu_hw_reg_telemetry_size_get (vdev); - boot_params->vpu_telemetry_enable =ivpu_hw_reg_telemetry_enable_get (vdev); + 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_focus_present_timer_ms =IVPU_FOCUS_PRESENT_TIMER_MS ;
drivers/accel/ivpu/ivpu_hw.c new file +310 -0
310 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw.h +68 -123
254 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_37xx.c deleted +0 -1071
1,071 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_40xx.c deleted +0 -1256
1,210 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_btrs.c new file +881 -0
881 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_btrs.h new file +46 -0
46 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_ip.c new file +1174 -0
1,174 lines not on this page · raw message
drivers/accel/ivpu/ivpu_hw_ip.h new file +36 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.2
Part of the diff is not shown here. View the raw message.
PATCH 3/3 accel/ivpu: Replace wake_thread with kfifo
In reply to Jacek LawrynowiczUse kfifo to pass IRQ sources to IRQ thread so it will be possible to use IRQ thread by multiple IRQ types.
--- drivers/accel/ivpu/ivpu_drv.c | 19 +++++++++++++++++-- drivers/accel/ivpu/ivpu_hw.c | 9 ++++++--- drivers/accel/ivpu/ivpu_hw.h | 13 ++++++++++--- drivers/accel/ivpu/ivpu_hw_ip.c | 8 ++++---- drivers/accel/ivpu/ivpu_hw_ip.h | 4 ++-- drivers/accel/ivpu/ivpu_ipc.c | 11 +++++------ drivers/accel/ivpu/ivpu_ipc.h | 4 ++-- 7 files changed, 46 insertions(+), 22 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +17 -2
@@ -320,7 +320,7 @@ static int ivpu_wait_for_ready(struct ivpu_device *vdev) timeout = jiffies +msecs_to_jiffies (vdev->timeout.boot);while (1 ) { -ivpu_ipc_irq_handler (vdev,NULL ); +ivpu_ipc_irq_handler (vdev); ret =ivpu_ipc_receive (vdev, &cons, &ipc_hdr,NULL ,0 );if (ret != -ETIMEDOUT ||time_after_eq (jiffies, timeout))break ;
@@ -449,8 +449,23 @@ static const struct drm_driver driver = {static irqreturn_t ivpu_irq_thread_handler (int irq,void *arg) {struct ivpu_device *vdev = arg; +u8 irq_src; -return ivpu_ipc_irq_thread_handler (vdev); +if (kfifo_is_empty (&vdev->hw->irq.fifo)) +return IRQ_NONE ; + +while (kfifo_get (&vdev->hw->irq.fifo, &irq_src)) { +switch (irq_src) { +case IVPU_HW_IRQ_SRC_IPC : +ivpu_ipc_irq_thread_handler (vdev); +break ; +default : +ivpu_err_ratelimited (vdev,"Unknown IRQ source: %u\n" , irq_src); +break ; + } + } + +return IRQ_HANDLED ; }static int ivpu_irq_init (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_hw.c +6 -3
@@ -263,6 +263,8 @@ void ivpu_hw_profiling_freq_drive(struct ivpu_device *vdev, bool enable)void ivpu_irq_handlers_init (struct ivpu_device *vdev) { +INIT_KFIFO (vdev->hw->irq.fifo); +if (ivpu_hw_ip_gen (vdev) ==IVPU_HW_IP_37XX ) vdev->hw->irq.ip_irq_handler = ivpu_hw_ip_irq_handler_37xx;else
@@ -276,6 +278,7 @@ void ivpu_irq_handlers_init(struct ivpu_device *vdev)void ivpu_hw_irq_enable (struct ivpu_device *vdev) { +kfifo_reset (&vdev->hw->irq.fifo);ivpu_hw_ip_irq_enable (vdev);ivpu_hw_btrs_irq_enable (vdev); }
@@ -288,21 +291,21 @@ void ivpu_hw_irq_disable(struct ivpu_device *vdev)irqreturn_t ivpu_hw_irq_handler (int irq,void *ptr) { -bool ip_handled, btrs_handled, wake_thread = false;struct ivpu_device *vdev = ptr; +bool ip_handled, btrs_handled;ivpu_hw_btrs_global_int_disable (vdev); btrs_handled =ivpu_hw_btrs_irq_handler (vdev, irq);if (!ivpu_hw_is_idle ((vdev)) || !btrs_handled) - ip_handled =ivpu_hw_ip_irq_handler (vdev, irq, &wake_thread); + ip_handled =ivpu_hw_ip_irq_handler (vdev, irq);else ip_handled = false;/* Re-enable global interrupts to re-trigger MSI for pending interrupts */ ivpu_hw_btrs_global_int_enable (vdev); -if (wake_thread) +if (!kfifo_is_empty (&vdev->hw->irq.fifo))return IRQ_WAKE_THREAD ;if (ip_handled || btrs_handled)return IRQ_HANDLED ;
drivers/accel/ivpu/ivpu_hw.h +10 -3
@@ -6,10 +6,16 @@ #ifndef __IVPU_HW_H__ #define __IVPU_HW_H__ +#include <linux/kfifo.h> + #include "ivpu_drv.h" #include "ivpu_hw_btrs.h" #include "ivpu_hw_ip.h" +#define IVPU_HW_IRQ_FIFO_LENGTH 1024 + +#define IVPU_HW_IRQ_SRC_IPC 1 + struct ivpu_addr_range { resource_size_t start; resource_size_t end;
@@ -18,7 +24,8 @@ struct ivpu_addr_range {struct ivpu_hw_info {struct {bool (*btrs_irq_handler)(struct ivpu_device *vdev,int irq); -bool (*ip_irq_handler)(struct ivpu_device *vdev,int irq,bool *wake_thread); +bool (*ip_irq_handler)(struct ivpu_device *vdev,int irq); + DECLARE_KFIFO(fifo, u8, IVPU_HW_IRQ_FIFO_LENGTH); } irq;struct {struct ivpu_addr_range global;
@@ -61,9 +68,9 @@ static inline u32 ivpu_hw_btrs_irq_handler(struct ivpu_device *vdev, int irq)return vdev->hw->irq.btrs_irq_handler (vdev, irq); } -static inline u32 ivpu_hw_ip_irq_handler (struct ivpu_device *vdev,int irq,bool *wake_thread) +static inline u32 ivpu_hw_ip_irq_handler (struct ivpu_device *vdev,int irq) { -return vdev->hw->irq.ip_irq_handler (vdev, irq, wake_thread); +return vdev->hw->irq.ip_irq_handler (vdev, irq); }static inline void ivpu_hw_range_init (struct ivpu_addr_range *range,u64 start,u64 size)
drivers/accel/ivpu/ivpu_hw_ip.c +4 -4
@@ -1066,7 +1066,7 @@ static void irq_noc_firewall_handler(struct ivpu_device *vdev) }/* Handler for IRQs from NPU core */ -bool ivpu_hw_ip_irq_handler_37xx (struct ivpu_device *vdev,int irq,bool *wake_thread) +bool ivpu_hw_ip_irq_handler_37xx (struct ivpu_device *vdev,int irq) {u32 status =REGV_RD32 (VPU_37XX_HOST_SS_ICB_STATUS_0 ) &ICB_0_IRQ_MASK_37XX ;
@@ -1079,7 +1079,7 @@ bool ivpu_hw_ip_irq_handler_37xx(struct ivpu_device *vdev, int irq, bool *wake_tivpu_mmu_irq_evtq_handler (vdev);if (REG_TEST_FLD (VPU_37XX_HOST_SS_ICB_STATUS_0 ,HOST_IPC_FIFO_INT , status)) -ivpu_ipc_irq_handler (vdev, wake_thread); +ivpu_ipc_irq_handler (vdev);if (REG_TEST_FLD (VPU_37XX_HOST_SS_ICB_STATUS_0 ,MMU_IRQ_1_INT , status))ivpu_dbg (vdev,IRQ ,"MMU sync complete\n" );
@@ -1100,7 +1100,7 @@ bool ivpu_hw_ip_irq_handler_37xx(struct ivpu_device *vdev, int irq, bool *wake_t }/* Handler for IRQs from NPU core */ -bool ivpu_hw_ip_irq_handler_40xx (struct ivpu_device *vdev,int irq,bool *wake_thread) +bool ivpu_hw_ip_irq_handler_40xx (struct ivpu_device *vdev,int irq) {u32 status =REGV_RD32 (VPU_40XX_HOST_SS_ICB_STATUS_0 ) &ICB_0_IRQ_MASK_40XX ;
@@ -1113,7 +1113,7 @@ bool ivpu_hw_ip_irq_handler_40xx(struct ivpu_device *vdev, int irq, bool *wake_tivpu_mmu_irq_evtq_handler (vdev);if (REG_TEST_FLD (VPU_40XX_HOST_SS_ICB_STATUS_0 ,HOST_IPC_FIFO_INT , status)) -ivpu_ipc_irq_handler (vdev, wake_thread); +ivpu_ipc_irq_handler (vdev);if (REG_TEST_FLD (VPU_40XX_HOST_SS_ICB_STATUS_0 ,MMU_IRQ_1_INT , status))ivpu_dbg (vdev,IRQ ,"MMU sync complete\n" );
drivers/accel/ivpu/ivpu_hw_ip.h +2 -2
@@ -22,8 +22,8 @@ void ivpu_hw_ip_wdt_disable(struct ivpu_device *vdev);void ivpu_hw_ip_diagnose_failure (struct ivpu_device *vdev);u32 ivpu_hw_ip_ipc_rx_count_get (struct ivpu_device *vdev);void ivpu_hw_ip_irq_clear (struct ivpu_device *vdev); -bool ivpu_hw_ip_irq_handler_37xx (struct ivpu_device *vdev,int irq,bool *wake_thread); -bool ivpu_hw_ip_irq_handler_40xx (struct ivpu_device *vdev,int irq,bool *wake_thread); +bool ivpu_hw_ip_irq_handler_37xx (struct ivpu_device *vdev,int irq); +bool ivpu_hw_ip_irq_handler_40xx (struct ivpu_device *vdev,int irq);void ivpu_hw_ip_db_set (struct ivpu_device *vdev,u32 db_id);u32 ivpu_hw_ip_ipc_rx_addr_get (struct ivpu_device *vdev);void ivpu_hw_ip_ipc_tx_set (struct ivpu_device *vdev,u32 vpu_addr);
drivers/accel/ivpu/ivpu_ipc.c +5 -6
@@ -378,7 +378,7 @@ ivpu_ipc_match_consumer(struct ivpu_device *vdev, struct ivpu_ipc_consumer *consreturn false; } -void ivpu_ipc_irq_handler (struct ivpu_device *vdev,bool *wake_thread) +void ivpu_ipc_irq_handler (struct ivpu_device *vdev) {struct ivpu_ipc_info *ipc = vdev->ipc;struct ivpu_ipc_consumer *cons;
@@ -442,11 +442,12 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev, bool *wake_thread) } } -if (wake_thread) - *wake_thread = !list_empty (&ipc->cb_msg_list); +if (!list_empty (&ipc->cb_msg_list)) +if (!kfifo_put (&vdev->hw->irq.fifo,IVPU_HW_IRQ_SRC_IPC )) +ivpu_err_ratelimited (vdev,"IRQ FIFO full\n" ); } -irqreturn_t ivpu_ipc_irq_thread_handler (struct ivpu_device *vdev) +void ivpu_ipc_irq_thread_handler (struct ivpu_device *vdev) {struct ivpu_ipc_info *ipc = vdev->ipc;struct ivpu_ipc_rx_msg *rx_msg, *r;
@@ -462,8 +463,6 @@ irqreturn_t ivpu_ipc_irq_thread_handler(struct ivpu_device *vdev) rx_msg->callback (vdev, rx_msg->ipc_hdr, rx_msg->jsm_msg);ivpu_ipc_rx_msg_del (vdev, rx_msg); } - -return IRQ_HANDLED ; }int ivpu_ipc_init (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_ipc.h +2 -2
@@ -89,8 +89,8 @@ void ivpu_ipc_enable(struct ivpu_device *vdev);void ivpu_ipc_disable (struct ivpu_device *vdev);void ivpu_ipc_reset (struct ivpu_device *vdev); -void ivpu_ipc_irq_handler (struct ivpu_device *vdev,bool *wake_thread); -irqreturn_t ivpu_ipc_irq_thread_handler (struct ivpu_device *vdev); +void ivpu_ipc_irq_handler (struct ivpu_device *vdev); +void ivpu_ipc_irq_thread_handler (struct ivpu_device *vdev);void ivpu_ipc_consumer_add (struct ivpu_device *vdev,struct ivpu_ipc_consumer *cons,u32 channel,ivpu_ipc_rx_callback_t callback);
Signature · 1 line
2.43.2
Jacek Lawrynowicz
AppliedApplied to drm-misc-next
Quoted 49 lines · Jacek Lawrynowicz
The NPU device consists of two parts: NPU buttress and NPU IP. Buttress is a platform specific part that integrates the NPU IP with the CPU.
NPU IP is the platform agnostic part that does the inference.This refactor enables support for multiple platforms using a single NPU IP, so for example NPU IP 37XX could be integrated into MTL and LNL platforms.
Jacek Lawrynowicz (1):
accel/ivpu: Replacewake_threadwith kfifoWachowski, Karol (2):
accel/ivpu: Split IP and buttress headers
accel/ivpu: Split IP and buttress codedrivers/accel/ivpu/Makefile | 5 +- drivers/accel/ivpu/ivpu_debugfs.c | 2 +- drivers/accel/ivpu/ivpu_drv.c | 32 +- drivers/accel/ivpu/ivpu_drv.h | 33 +- drivers/accel/ivpu/ivpu_fw.c | 20 +- drivers/accel/ivpu/ivpu_hw.c | 313 +++++ drivers/accel/ivpu/ivpu_hw.h | 196 ++-- drivers/accel/ivpu/ivpu_hw_37xx.c | 1070 ------------------ drivers/accel/ivpu/ivpu_hw_37xx_reg.h | 72 -- drivers/accel/ivpu/ivpu_hw_40xx.c | 1255 --------------------- drivers/accel/ivpu/ivpu_hw_40xx_reg.h | 94 +- drivers/accel/ivpu/ivpu_hw_btrs.c | 881 +++++++++++++++ drivers/accel/ivpu/ivpu_hw_btrs.h | 46 + drivers/accel/ivpu/ivpu_hw_btrs_lnl_reg.h | 108 ++ drivers/accel/ivpu/ivpu_hw_btrs_mtl_reg.h | 83 ++ drivers/accel/ivpu/ivpu_hw_ip.c | 1174 +++++++++++++++++++ drivers/accel/ivpu/ivpu_hw_ip.h | 36 + drivers/accel/ivpu/ivpu_ipc.c | 17 +- drivers/accel/ivpu/ivpu_ipc.h | 4 +- drivers/accel/ivpu/ivpu_job.c | 2 +- 20 files changed, 2799 insertions(+), 2644 deletions(-) create mode 100644 drivers/accel/ivpu/ivpu_hw.c delete mode 100644 drivers/accel/ivpu/ivpu_hw_37xx.c delete mode 100644 drivers/accel/ivpu/ivpu_hw_40xx.c create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs.c create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs.h create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs_lnl_reg.h create mode 100644 drivers/accel/ivpu/ivpu_hw_btrs_mtl_reg.h create mode 100644 drivers/accel/ivpu/ivpu_hw_ip.c create mode 100644 drivers/accel/ivpu/ivpu_hw_ip.h--
2.43.2