Loading drivers/media/platform/msm/npu/npu_mgr.c +46 −5 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,7 @@ static int wait_npu_cpc_power_off(struct npu_device *npu_dev) { { uint32_t reg_val = NPU_CPC_PWR_ON; uint32_t reg_val = NPU_CPC_PWR_ON; uint32_t wait_cnt = 0, max_wait_ms; uint32_t wait_cnt = 0, max_wait_ms; struct npu_host_ctx *host_ctx = &npu_dev->host_ctx; max_wait_ms = NPU_FW_TIMEOUT_MS; max_wait_ms = NPU_FW_TIMEOUT_MS; Loading @@ -107,6 +108,12 @@ static int wait_npu_cpc_power_off(struct npu_device *npu_dev) break; break; } } if ((host_ctx->wdg_irq_sts != 0) || (host_ctx->err_irq_sts != 0)) { NPU_WARN("fw is in bad state, skip wait\n"); return -EIO; } wait_cnt += NPU_FW_TIMEOUT_POLL_INTERVAL_MS; wait_cnt += NPU_FW_TIMEOUT_POLL_INTERVAL_MS; if (wait_cnt > max_wait_ms) { if (wait_cnt > max_wait_ms) { NPU_ERR("timeout wait for cpc power off\n"); NPU_ERR("timeout wait for cpc power off\n"); Loading Loading @@ -907,6 +914,9 @@ static int host_error_hdlr(struct npu_device *npu_dev, bool force) goto fw_start_done; goto fw_start_done; } } host_ctx->wdg_irq_sts = 0; host_ctx->err_irq_sts = 0; /* Keep reading ctrl status until NPU is ready */ /* Keep reading ctrl status until NPU is ready */ if (wait_for_status_ready(npu_dev, REG_NPU_FW_CTRL_STATUS, if (wait_for_status_ready(npu_dev, REG_NPU_FW_CTRL_STATUS, FW_CTRL_STATUS_MAIN_THREAD_READY_VAL, false)) { FW_CTRL_STATUS_MAIN_THREAD_READY_VAL, false)) { Loading @@ -933,8 +943,6 @@ static int host_error_hdlr(struct npu_device *npu_dev, bool force) } } complete(&host_ctx->fw_deinit_done); complete(&host_ctx->fw_deinit_done); host_ctx->wdg_irq_sts = 0; host_ctx->err_irq_sts = 0; /* flush all pending npu cmds */ /* flush all pending npu cmds */ for (i = 0; i < MAX_LOADED_NETWORK; i++) { for (i = 0; i < MAX_LOADED_NETWORK; i++) { Loading Loading @@ -1145,6 +1153,12 @@ static int wait_for_status_ready(struct npu_device *npu_dev, return -ETIMEDOUT; return -ETIMEDOUT; } } if ((host_ctx->wdg_irq_sts != 0) || (host_ctx->err_irq_sts != 0)) { NPU_WARN("fw is in bad state, skip wait\n"); return -EIO; } if (poll) if (poll) udelay(100); udelay(100); else else Loading Loading @@ -2237,7 +2251,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client, struct msm_npu_load_network_ioctl_v2 *load_ioctl, struct msm_npu_load_network_ioctl_v2 *load_ioctl, struct msm_npu_patch_info_v2 *patch_info) struct msm_npu_patch_info_v2 *patch_info) { { int ret = 0, i; int ret = 0, retry_cnt = 1, i; struct npu_device *npu_dev = client->npu_dev; struct npu_device *npu_dev = client->npu_dev; struct npu_pwrctrl *pwr = &npu_dev->pwrctrl; struct npu_pwrctrl *pwr = &npu_dev->pwrctrl; struct npu_network *network; struct npu_network *network; Loading Loading @@ -2330,6 +2344,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client, mutex_unlock(&host_ctx->lock); mutex_unlock(&host_ctx->lock); retry: ret = wait_for_completion_timeout( ret = wait_for_completion_timeout( &load_cmd->cmd_done, &load_cmd->cmd_done, (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? Loading @@ -2346,6 +2361,14 @@ int32_t npu_host_load_network_v2(struct npu_client *client, if (!ret) { if (!ret) { NPU_ERR("npu: NPU_IPC_CMD_LOAD time out %lld:%d\n", NPU_ERR("npu: NPU_IPC_CMD_LOAD time out %lld:%d\n", network->id, load_cmd->trans_id); network->id, load_cmd->trans_id); if (retry_cnt > 0) { NPU_WARN("Retry IPC queue\n"); retry_cnt--; mutex_unlock(&host_ctx->lock); host_session_msg_hdlr(npu_dev); goto retry; } ret = -ETIMEDOUT; ret = -ETIMEDOUT; goto free_load_cmd; goto free_load_cmd; } } Loading Loading @@ -2392,7 +2415,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client, int32_t npu_host_unload_network(struct npu_client *client, int32_t npu_host_unload_network(struct npu_client *client, struct msm_npu_unload_network_ioctl *unload) struct msm_npu_unload_network_ioctl *unload) { { int ret = 0; int ret = 0, retry_cnt = 1; struct npu_device *npu_dev = client->npu_dev; struct npu_device *npu_dev = client->npu_dev; struct ipc_cmd_unload_pkt unload_packet; struct ipc_cmd_unload_pkt unload_packet; struct npu_network *network; struct npu_network *network; Loading Loading @@ -2465,6 +2488,7 @@ int32_t npu_host_unload_network(struct npu_client *client, mutex_unlock(&host_ctx->lock); mutex_unlock(&host_ctx->lock); retry: ret = wait_for_completion_timeout( ret = wait_for_completion_timeout( &unload_cmd->cmd_done, &unload_cmd->cmd_done, (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? Loading @@ -2481,6 +2505,14 @@ int32_t npu_host_unload_network(struct npu_client *client, if (!ret) { if (!ret) { NPU_ERR("npu: NPU_IPC_CMD_UNLOAD time out %llx:%d\n", NPU_ERR("npu: NPU_IPC_CMD_UNLOAD time out %llx:%d\n", network->id, unload_cmd->trans_id); network->id, unload_cmd->trans_id); if (retry_cnt > 0) { NPU_WARN("Retry IPC queue\n"); retry_cnt--; mutex_unlock(&host_ctx->lock); host_session_msg_hdlr(npu_dev); goto retry; } ret = -ETIMEDOUT; ret = -ETIMEDOUT; goto free_unload_cmd; goto free_unload_cmd; } } Loading Loading @@ -2531,7 +2563,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, struct npu_host_ctx *host_ctx = &npu_dev->host_ctx; struct npu_host_ctx *host_ctx = &npu_dev->host_ctx; uint32_t num_patch_params, pkt_size; uint32_t num_patch_params, pkt_size; bool async_ioctl = !!exec_ioctl->async; bool async_ioctl = !!exec_ioctl->async; int i; int i, retry_cnt = 1; mutex_lock(&host_ctx->lock); mutex_lock(&host_ctx->lock); network = get_network_by_hdl(host_ctx, client, network = get_network_by_hdl(host_ctx, client, Loading Loading @@ -2631,6 +2663,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, mutex_unlock(&host_ctx->lock); mutex_unlock(&host_ctx->lock); retry: ret = wait_for_completion_timeout( ret = wait_for_completion_timeout( &exec_cmd->cmd_done, &exec_cmd->cmd_done, (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? Loading @@ -2646,6 +2679,14 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, if (!ret) { if (!ret) { NPU_ERR("npu: %llx:%d NPU_IPC_CMD_EXECUTE_V2 time out\n", NPU_ERR("npu: %llx:%d NPU_IPC_CMD_EXECUTE_V2 time out\n", network->id, exec_cmd->trans_id); network->id, exec_cmd->trans_id); if (retry_cnt > 0) { NPU_WARN("Retry IPC queue\n"); retry_cnt--; mutex_unlock(&host_ctx->lock); host_session_msg_hdlr(npu_dev); goto retry; } ret = -ETIMEDOUT; ret = -ETIMEDOUT; goto free_exec_packet; goto free_exec_packet; } } Loading Loading
drivers/media/platform/msm/npu/npu_mgr.c +46 −5 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,7 @@ static int wait_npu_cpc_power_off(struct npu_device *npu_dev) { { uint32_t reg_val = NPU_CPC_PWR_ON; uint32_t reg_val = NPU_CPC_PWR_ON; uint32_t wait_cnt = 0, max_wait_ms; uint32_t wait_cnt = 0, max_wait_ms; struct npu_host_ctx *host_ctx = &npu_dev->host_ctx; max_wait_ms = NPU_FW_TIMEOUT_MS; max_wait_ms = NPU_FW_TIMEOUT_MS; Loading @@ -107,6 +108,12 @@ static int wait_npu_cpc_power_off(struct npu_device *npu_dev) break; break; } } if ((host_ctx->wdg_irq_sts != 0) || (host_ctx->err_irq_sts != 0)) { NPU_WARN("fw is in bad state, skip wait\n"); return -EIO; } wait_cnt += NPU_FW_TIMEOUT_POLL_INTERVAL_MS; wait_cnt += NPU_FW_TIMEOUT_POLL_INTERVAL_MS; if (wait_cnt > max_wait_ms) { if (wait_cnt > max_wait_ms) { NPU_ERR("timeout wait for cpc power off\n"); NPU_ERR("timeout wait for cpc power off\n"); Loading Loading @@ -907,6 +914,9 @@ static int host_error_hdlr(struct npu_device *npu_dev, bool force) goto fw_start_done; goto fw_start_done; } } host_ctx->wdg_irq_sts = 0; host_ctx->err_irq_sts = 0; /* Keep reading ctrl status until NPU is ready */ /* Keep reading ctrl status until NPU is ready */ if (wait_for_status_ready(npu_dev, REG_NPU_FW_CTRL_STATUS, if (wait_for_status_ready(npu_dev, REG_NPU_FW_CTRL_STATUS, FW_CTRL_STATUS_MAIN_THREAD_READY_VAL, false)) { FW_CTRL_STATUS_MAIN_THREAD_READY_VAL, false)) { Loading @@ -933,8 +943,6 @@ static int host_error_hdlr(struct npu_device *npu_dev, bool force) } } complete(&host_ctx->fw_deinit_done); complete(&host_ctx->fw_deinit_done); host_ctx->wdg_irq_sts = 0; host_ctx->err_irq_sts = 0; /* flush all pending npu cmds */ /* flush all pending npu cmds */ for (i = 0; i < MAX_LOADED_NETWORK; i++) { for (i = 0; i < MAX_LOADED_NETWORK; i++) { Loading Loading @@ -1145,6 +1153,12 @@ static int wait_for_status_ready(struct npu_device *npu_dev, return -ETIMEDOUT; return -ETIMEDOUT; } } if ((host_ctx->wdg_irq_sts != 0) || (host_ctx->err_irq_sts != 0)) { NPU_WARN("fw is in bad state, skip wait\n"); return -EIO; } if (poll) if (poll) udelay(100); udelay(100); else else Loading Loading @@ -2237,7 +2251,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client, struct msm_npu_load_network_ioctl_v2 *load_ioctl, struct msm_npu_load_network_ioctl_v2 *load_ioctl, struct msm_npu_patch_info_v2 *patch_info) struct msm_npu_patch_info_v2 *patch_info) { { int ret = 0, i; int ret = 0, retry_cnt = 1, i; struct npu_device *npu_dev = client->npu_dev; struct npu_device *npu_dev = client->npu_dev; struct npu_pwrctrl *pwr = &npu_dev->pwrctrl; struct npu_pwrctrl *pwr = &npu_dev->pwrctrl; struct npu_network *network; struct npu_network *network; Loading Loading @@ -2330,6 +2344,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client, mutex_unlock(&host_ctx->lock); mutex_unlock(&host_ctx->lock); retry: ret = wait_for_completion_timeout( ret = wait_for_completion_timeout( &load_cmd->cmd_done, &load_cmd->cmd_done, (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? Loading @@ -2346,6 +2361,14 @@ int32_t npu_host_load_network_v2(struct npu_client *client, if (!ret) { if (!ret) { NPU_ERR("npu: NPU_IPC_CMD_LOAD time out %lld:%d\n", NPU_ERR("npu: NPU_IPC_CMD_LOAD time out %lld:%d\n", network->id, load_cmd->trans_id); network->id, load_cmd->trans_id); if (retry_cnt > 0) { NPU_WARN("Retry IPC queue\n"); retry_cnt--; mutex_unlock(&host_ctx->lock); host_session_msg_hdlr(npu_dev); goto retry; } ret = -ETIMEDOUT; ret = -ETIMEDOUT; goto free_load_cmd; goto free_load_cmd; } } Loading Loading @@ -2392,7 +2415,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client, int32_t npu_host_unload_network(struct npu_client *client, int32_t npu_host_unload_network(struct npu_client *client, struct msm_npu_unload_network_ioctl *unload) struct msm_npu_unload_network_ioctl *unload) { { int ret = 0; int ret = 0, retry_cnt = 1; struct npu_device *npu_dev = client->npu_dev; struct npu_device *npu_dev = client->npu_dev; struct ipc_cmd_unload_pkt unload_packet; struct ipc_cmd_unload_pkt unload_packet; struct npu_network *network; struct npu_network *network; Loading Loading @@ -2465,6 +2488,7 @@ int32_t npu_host_unload_network(struct npu_client *client, mutex_unlock(&host_ctx->lock); mutex_unlock(&host_ctx->lock); retry: ret = wait_for_completion_timeout( ret = wait_for_completion_timeout( &unload_cmd->cmd_done, &unload_cmd->cmd_done, (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? Loading @@ -2481,6 +2505,14 @@ int32_t npu_host_unload_network(struct npu_client *client, if (!ret) { if (!ret) { NPU_ERR("npu: NPU_IPC_CMD_UNLOAD time out %llx:%d\n", NPU_ERR("npu: NPU_IPC_CMD_UNLOAD time out %llx:%d\n", network->id, unload_cmd->trans_id); network->id, unload_cmd->trans_id); if (retry_cnt > 0) { NPU_WARN("Retry IPC queue\n"); retry_cnt--; mutex_unlock(&host_ctx->lock); host_session_msg_hdlr(npu_dev); goto retry; } ret = -ETIMEDOUT; ret = -ETIMEDOUT; goto free_unload_cmd; goto free_unload_cmd; } } Loading Loading @@ -2531,7 +2563,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, struct npu_host_ctx *host_ctx = &npu_dev->host_ctx; struct npu_host_ctx *host_ctx = &npu_dev->host_ctx; uint32_t num_patch_params, pkt_size; uint32_t num_patch_params, pkt_size; bool async_ioctl = !!exec_ioctl->async; bool async_ioctl = !!exec_ioctl->async; int i; int i, retry_cnt = 1; mutex_lock(&host_ctx->lock); mutex_lock(&host_ctx->lock); network = get_network_by_hdl(host_ctx, client, network = get_network_by_hdl(host_ctx, client, Loading Loading @@ -2631,6 +2663,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, mutex_unlock(&host_ctx->lock); mutex_unlock(&host_ctx->lock); retry: ret = wait_for_completion_timeout( ret = wait_for_completion_timeout( &exec_cmd->cmd_done, &exec_cmd->cmd_done, (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ? Loading @@ -2646,6 +2679,14 @@ int32_t npu_host_exec_network_v2(struct npu_client *client, if (!ret) { if (!ret) { NPU_ERR("npu: %llx:%d NPU_IPC_CMD_EXECUTE_V2 time out\n", NPU_ERR("npu: %llx:%d NPU_IPC_CMD_EXECUTE_V2 time out\n", network->id, exec_cmd->trans_id); network->id, exec_cmd->trans_id); if (retry_cnt > 0) { NPU_WARN("Retry IPC queue\n"); retry_cnt--; mutex_unlock(&host_ctx->lock); host_session_msg_hdlr(npu_dev); goto retry; } ret = -ETIMEDOUT; ret = -ETIMEDOUT; goto free_exec_packet; goto free_exec_packet; } } Loading