accel/ivpu: Load firmware on cold boot
Andrzej Kacprowski
maintainerPATCH 1/1 accel/ivpu: Load firmware on cold boot
Load the firmware image immediately before each cold boot instead of during probe or cold-boot preparation. This moves image loading to a single call site and aligns code for future driver changes.
--- drivers/accel/ivpu/ivpu_drv.c | 8 ++++++++ drivers/accel/ivpu/ivpu_fw.c | 5 ++--- drivers/accel/ivpu/ivpu_fw.h | 2 +- drivers/accel/ivpu/ivpu_pm.c | 1 - 4 files changed, 11 insertions(+), 5 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +8 -0
@@ -520,6 +520,14 @@ int ivpu_boot(struct ivpu_device *vdev)ivpu_fw_boot_params_setup (vdev,ivpu_bo_vaddr (vdev->fw->mem_bp)); vdev->fw->last_boot_mode = vdev->fw->next_boot_mode; +if (!ivpu_fw_is_warm_boot (vdev)) { + ret =ivpu_fw_load (vdev); +if (ret) { +ivpu_err (vdev,"Failed to load the firmware: %d\n" , ret); +return ret; + } + } + ret =ivpu_hw_boot_fw (vdev);if (ret) {ivpu_err (vdev,"Failed to start the firmware: %d\n" , ret);
drivers/accel/ivpu/ivpu_fw.c +2 -3
@@ -473,8 +473,6 @@ int ivpu_fw_init(struct ivpu_device *vdev)if (ret) goto err_fw_release; -ivpu_fw_load (vdev); -return 0 ; err_fw_release:
@@ -488,7 +486,7 @@ void ivpu_fw_fini(struct ivpu_device *vdev)ivpu_fw_release (vdev); } -void ivpu_fw_load (struct ivpu_device *vdev) +int ivpu_fw_load (struct ivpu_device *vdev) {struct ivpu_fw_info *fw = vdev->fw;u64 image_end_offset = fw->image_load_offset + fw->image_size;
@@ -505,6 +503,7 @@ void ivpu_fw_load(struct ivpu_device *vdev) }wmb ();/* Flush WC buffers after writing fw->mem */ +return 0 ; }static void ivpu_fw_boot_params_print (struct ivpu_device *vdev,struct vpu_boot_params *boot_params)
drivers/accel/ivpu/ivpu_fw.h +1 -1
@@ -55,7 +55,7 @@ struct ivpu_fw_info {bool ivpu_is_within_range (u64 addr,size_t size,struct ivpu_addr_range *range);int ivpu_fw_init (struct ivpu_device *vdev);void ivpu_fw_fini (struct ivpu_device *vdev); -void ivpu_fw_load (struct ivpu_device *vdev); +int ivpu_fw_load (struct ivpu_device *vdev);void ivpu_fw_boot_params_setup (struct ivpu_device *vdev,struct vpu_boot_params *boot_params);static inline bool ivpu_fw_is_warm_boot (struct ivpu_device *vdev)
drivers/accel/ivpu/ivpu_pm.c +0 -1
@@ -46,7 +46,6 @@ 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->last_heartbeat =0 ;ivpu_dbg (vdev,FW_BOOT ,"Cold boot entry point 0x%llx" , vdev->fw->cold_boot_entry_point);
Signature · 1 line
2.43.0
Quoted 6 lines · Andrzej Kacprowski
Load the firmware image immediately before each cold boot instead of during probe or cold-boot preparation. This moves image loading to a single call site and aligns code for future driver changes.
Signed-off-by Andrzej Kacprowski <[email protected]>
Quoted 81 lines
--- drivers/accel/ivpu/ivpu_drv.c | 8 ++++++++ drivers/accel/ivpu/ivpu_fw.c | 5 ++--- drivers/accel/ivpu/ivpu_fw.h | 2 +- drivers/accel/ivpu/ivpu_pm.c | 1 - 4 files changed, 11 insertions(+), 5 deletions(-)drivers/accel/ivpu/ivpu_drv.c +8
-0@@ -520,6 +520,14 @@ int ivpu_boot(struct ivpu_device *vdev)ivpu_fw_boot_params_setup (vdev,ivpu_bo_vaddr (vdev->fw->mem_bp)); vdev->fw->last_boot_mode = vdev->fw->next_boot_mode; +if (!ivpu_fw_is_warm_boot (vdev)) { + ret =ivpu_fw_load (vdev); +if (ret) { +ivpu_err (vdev,"Failed to load the firmware: %d\n" , ret); +return ret; + } + } + ret =ivpu_hw_boot_fw (vdev);if (ret) {ivpu_err (vdev,"Failed to start the firmware: %d\n" , ret);drivers/accel/ivpu/ivpu_fw.c +2
-3@@ -473,8 +473,6 @@ int ivpu_fw_init(struct ivpu_device *vdev)if (ret) goto err_fw_release; -ivpu_fw_load (vdev); -return 0 ; err_fw_release:@@ -488,7 +486,7 @@ void ivpu_fw_fini(struct ivpu_device *vdev)ivpu_fw_release (vdev); } -void ivpu_fw_load (struct ivpu_device *vdev) +int ivpu_fw_load (struct ivpu_device *vdev) {struct ivpu_fw_info *fw = vdev->fw;u64 image_end_offset = fw->image_load_offset + fw->image_size;@@ -505,6 +503,7 @@ void ivpu_fw_load(struct ivpu_device *vdev) }wmb ();/* Flush WC buffers after writing fw->mem */ +return 0 ; }static void ivpu_fw_boot_params_print (struct ivpu_device *vdev,struct vpu_boot_params *boot_params)drivers/accel/ivpu/ivpu_fw.h +1
-1@@ -55,7 +55,7 @@ struct ivpu_fw_info {bool ivpu_is_within_range (u64 addr,size_t size,struct ivpu_addr_range *range);int ivpu_fw_init (struct ivpu_device *vdev);void ivpu_fw_fini (struct ivpu_device *vdev); -void ivpu_fw_load (struct ivpu_device *vdev); +int ivpu_fw_load (struct ivpu_device *vdev);void ivpu_fw_boot_params_setup (struct ivpu_device *vdev,struct vpu_boot_params *boot_params);static inline bool ivpu_fw_is_warm_boot (struct ivpu_device *vdev)drivers/accel/ivpu/ivpu_pm.c +0
-1@@ -46,7 +46,6 @@ 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->last_heartbeat =0 ;ivpu_dbg (vdev,FW_BOOT ,"Cold boot entry point 0x%llx" , vdev->fw->cold_boot_entry_point);
Quoted 6 lines · Andrzej Kacprowski
Load the firmware image immediately before each cold boot instead of during probe or cold-boot preparation. This moves image loading to a single call site and aligns code for future driver changes.
Signed-off-by Andrzej Kacprowski <[email protected]>
Quoted 80 lines · Andrzej Kacprowski
Load the firmware image immediately before each cold boot instead of during probe or cold-boot preparation. This moves image loading to a single call site and aligns code for future driver changes.
Signed-off-by Andrzej Kacprowski <[email protected]>--- drivers/accel/ivpu/ivpu_drv.c | 8 ++++++++ drivers/accel/ivpu/ivpu_fw.c | 5 ++--- drivers/accel/ivpu/ivpu_fw.h | 2 +- drivers/accel/ivpu/ivpu_pm.c | 1 - 4 files changed, 11 insertions(+), 5 deletions(-)drivers/accel/ivpu/ivpu_drv.c +8
-0@@ -520,6 +520,14 @@ int ivpu_boot(struct ivpu_device *vdev)ivpu_fw_boot_params_setup (vdev,ivpu_bo_vaddr (vdev->fw->mem_bp)); vdev->fw->last_boot_mode = vdev->fw->next_boot_mode; +if (!ivpu_fw_is_warm_boot (vdev)) { + ret =ivpu_fw_load (vdev); +if (ret) { +ivpu_err (vdev,"Failed to load the firmware: %d\n" , ret); +return ret; + } + } + ret =ivpu_hw_boot_fw (vdev);if (ret) {ivpu_err (vdev,"Failed to start the firmware: %d\n" , ret);drivers/accel/ivpu/ivpu_fw.c +2
-3@@ -473,8 +473,6 @@ int ivpu_fw_init(struct ivpu_device *vdev)if (ret) goto err_fw_release; -ivpu_fw_load (vdev); -return 0 ; err_fw_release:@@ -488,7 +486,7 @@ void ivpu_fw_fini(struct ivpu_device *vdev)ivpu_fw_release (vdev); } -void ivpu_fw_load (struct ivpu_device *vdev) +int ivpu_fw_load (struct ivpu_device *vdev) {struct ivpu_fw_info *fw = vdev->fw;u64 image_end_offset = fw->image_load_offset + fw->image_size;@@ -505,6 +503,7 @@ void ivpu_fw_load(struct ivpu_device *vdev) }wmb ();/* Flush WC buffers after writing fw->mem */ +return 0 ; }static void ivpu_fw_boot_params_print (struct ivpu_device *vdev,struct vpu_boot_params *boot_params)drivers/accel/ivpu/ivpu_fw.h +1
-1@@ -55,7 +55,7 @@ struct ivpu_fw_info {bool ivpu_is_within_range (u64 addr,size_t size,struct ivpu_addr_range *range);int ivpu_fw_init (struct ivpu_device *vdev);void ivpu_fw_fini (struct ivpu_device *vdev); -void ivpu_fw_load (struct ivpu_device *vdev); +int ivpu_fw_load (struct ivpu_device *vdev);void ivpu_fw_boot_params_setup (struct ivpu_device *vdev,struct vpu_boot_params *boot_params);static inline bool ivpu_fw_is_warm_boot (struct ivpu_device *vdev)drivers/accel/ivpu/ivpu_pm.c +0
-0
drivers/accel/ivpu/ivpu_pm.c static void ivpu_pm_prepare_cold_boot(struct ivpu_device *vdev) · line 51
Quoted 7 lines
drivers/accel/ivpu/ivpu_pm.c +0
-1@@ -46,7 +46,6 @@ 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->last_heartbeat =0 ;ivpu_dbg (vdev,FW_BOOT ,"Cold boot entry point 0x%llx" , vdev->fw->cold_boot_entry_point);
Applied to drm-misc-next.