Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da80174c authored by Da Hoon Pyun's avatar Da Hoon Pyun
Browse files

msm: npu: Increase timeout for NPU bringup to 60 seconds



The timeout to bringup the subsystem defined in PIL is 60 seconds.
This change is to set the timeout to wait for NPU bringup same
as the setting in PIL.

Change-Id: I2f76fc54ef711dd67404a4f06b2d1e4b4bfeba19
Signed-off-by: default avatarDa Hoon Pyun <dpyun@codeaurora.org>
parent 496daa01
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -32,9 +32,6 @@
#define LOG_MSG_TOTAL_SIZE_INDEX 0
#define LOG_MSG_MSG_ID_INDEX     1

#define NPU_FW_TIMEOUT_POLL_INTERVAL_MS  10
#define NPU_FW_TIMEOUT_MS                5000

/* -------------------------------------------------------------------------
 * File Scope Function Prototypes
 * -------------------------------------------------------------------------
@@ -46,7 +43,8 @@ static void npu_disable_fw_work(struct work_struct *work);
static void npu_update_pwr_work(struct work_struct *work);
static void turn_off_fw_logging(struct npu_device *npu_dev);
static int wait_for_status_ready(struct npu_device *npu_dev,
	uint32_t status_reg, uint32_t status_bits, bool poll);
	uint32_t status_reg, uint32_t status_bits, uint32_t timeout_ms,
	bool poll);
static int wait_npu_cpc_power_off(struct npu_device *npu_dev);
static struct npu_network *alloc_network(struct npu_host_ctx *ctx,
	struct npu_client *client);
@@ -106,7 +104,7 @@ static int wait_npu_cpc_power_off(struct npu_device *npu_dev)
	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_ACK_TIMEOUT_MS;

	do {
		reg_val = npu_tcsr_reg_read(npu_dev, TCSR_NPU_CPC_PWR_ON);
@@ -162,7 +160,8 @@ static int load_fw_nolock(struct npu_device *npu_dev, bool enable)

	/* Keep reading ctrl status until NPU is ready */
	ret = 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,
		NPU_FW_BRINGUP_TIMEOUT_MS, false);
	if (ret)
		goto load_fw_fail;

@@ -528,7 +527,8 @@ static int npu_notify_fw_pwr_state(struct npu_device *npu_dev,
		NPU_ERR("NPU_IPC_CMD_NOTIFY_PWR sent failed: %d\n", ret);
	} else {
		ret = wait_for_status_ready(npu_dev, REG_NPU_FW_CTRL_STATUS,
			FW_CTRL_STATUS_PWR_NOTIFY_DONE_VAL, true);
			FW_CTRL_STATUS_PWR_NOTIFY_DONE_VAL,
			NPU_FW_ACK_TIMEOUT_MS, true);
		if (!ret) {
			reg_val = REGR(npu_dev, REG_NPU_FW_CTRL_STATUS);
			if (reg_val & FW_CTRL_STATUS_PWR_NOTIFY_ERR_VAL) {
@@ -924,7 +924,8 @@ static int host_error_hdlr(struct npu_device *npu_dev, bool force)

	/* Keep reading ctrl status until NPU is ready */
	ret = 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,
		NPU_FW_BRINGUP_TIMEOUT_MS, false);
	if (ret) {
		NPU_ERR("wait for fw status ready timedout\n");
		goto fw_start_done;
@@ -1130,14 +1131,15 @@ static void turn_off_fw_logging(struct npu_device *npu_dev)
}

static int wait_for_status_ready(struct npu_device *npu_dev,
	uint32_t status_reg, uint32_t status_bits, bool poll)
	uint32_t status_reg, uint32_t status_bits, uint32_t timeout_ms,
	bool poll)
{
	uint32_t ctrl_sts = 0;
	uint32_t wait_cnt = 0, max_wait_ms;
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;

	max_wait_ms = (host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
		NW_DEBUG_TIMEOUT_MS : NPU_FW_TIMEOUT_MS;
		NW_DEBUG_TIMEOUT_MS : timeout_ms;
	if (poll)
		wait_cnt = max_wait_ms * 10;
	else
+4 −1
Original line number Diff line number Diff line
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -35,6 +35,9 @@
#define NW_DEBUG_TIMEOUT msecs_to_jiffies(NW_DEBUG_TIMEOUT_MS)
#define NPU_MBOX_IDLE_TIMEOUT_MS 500 /* set for 500ms */
#define NPU_MBOX_IDLE_TIMEOUT msecs_to_jiffies(NPU_MBOX_IDLE_TIMEOUT_MS)
#define NPU_FW_TIMEOUT_POLL_INTERVAL_MS 10
#define NPU_FW_ACK_TIMEOUT_MS 5000
#define NPU_FW_BRINGUP_TIMEOUT_MS (1000 * 60) /* set for 60 seconds */
#define FIRMWARE_VERSION 0x00001000
#define MAX_LOADED_NETWORK 32
#define NPU_IPC_BUF_LENGTH 4096