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

Commit 4c78f680 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: npu: Retry to read IPC queue if network commands time out"

parents 18eb0eb2 a2165ee1
Loading
Loading
Loading
Loading
+24 −13
Original line number Diff line number Diff line
@@ -114,8 +114,8 @@ static int npu_of_parse_pwrlevels(struct npu_device *npu_dev,
static int npu_pwrctrl_init(struct npu_device *npu_dev);
static int npu_probe(struct platform_device *pdev);
static int npu_remove(struct platform_device *pdev);
static int npu_suspend(struct platform_device *dev, pm_message_t state);
static int npu_resume(struct platform_device *dev);
static int npu_pm_suspend(struct device *dev);
static int npu_pm_resume(struct device *dev);
static int __init npu_init(void);
static void __exit npu_exit(void);

@@ -193,17 +193,17 @@ static const struct of_device_id npu_dt_match[] = {
	{}
};

static const struct dev_pm_ops npu_pm_ops = {
	SET_SYSTEM_SLEEP_PM_OPS(npu_pm_suspend, npu_pm_resume)
};

static struct platform_driver npu_driver = {
	.probe = npu_probe,
	.remove = npu_remove,
#if defined(CONFIG_PM)
	.suspend = npu_suspend,
	.resume = npu_resume,
#endif
	.driver = {
		.name = "msm_npu",
		.of_match_table = npu_dt_match,
		.pm = NULL,
		.pm = &npu_pm_ops,
	},
};

@@ -2211,7 +2211,7 @@ static int npu_probe(struct platform_device *pdev)
	npu_dev->pdev = pdev;
	mutex_init(&npu_dev->dev_lock);

	platform_set_drvdata(pdev, npu_dev);
	dev_set_drvdata(&pdev->dev, npu_dev);
	res = platform_get_resource_byname(pdev,
		IORESOURCE_MEM, "core");
	if (!res) {
@@ -2438,6 +2438,7 @@ static int npu_probe(struct platform_device *pdev)
	unregister_chrdev_region(npu_dev->dev_num, 1);
	npu_mbox_deinit(npu_dev);
error_get_dev_num:
	dev_set_drvdata(&pdev->dev, NULL);
	return rc;
}

@@ -2455,7 +2456,7 @@ static int npu_remove(struct platform_device *pdev)
	device_destroy(npu_dev->class, npu_dev->dev_num);
	class_destroy(npu_dev->class);
	unregister_chrdev_region(npu_dev->dev_num, 1);
	platform_set_drvdata(pdev, NULL);
	dev_set_drvdata(&pdev->dev, NULL);
	npu_mbox_deinit(npu_dev);
	msm_bus_scale_unregister_client(npu_dev->bwctrl.bus_client);

@@ -2468,17 +2469,27 @@ static int npu_remove(struct platform_device *pdev)
 * Suspend/Resume
 * -------------------------------------------------------------------------
 */
#if defined(CONFIG_PM)
static int npu_suspend(struct platform_device *dev, pm_message_t state)
static int npu_pm_suspend(struct device *dev)
{
	struct npu_device *npu_dev;

	npu_dev = dev_get_drvdata(dev);
	if (!npu_dev) {
		NPU_ERR("invalid NPU dev\n");
		return -EINVAL;
	}

	NPU_DBG("suspend npu\n");
	npu_host_suspend(npu_dev);

	return 0;
}

static int npu_resume(struct platform_device *dev)
static int npu_pm_resume(struct device *dev)
{
	NPU_DBG("resume npu\n");
	return 0;
}
#endif

/* -------------------------------------------------------------------------
 * Module Entry Points
+37 −3
Original line number Diff line number Diff line
@@ -2213,7 +2213,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
			struct msm_npu_load_network_ioctl_v2 *load_ioctl,
			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_pwrctrl *pwr = &npu_dev->pwrctrl;
	struct npu_network *network;
@@ -2307,6 +2307,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

retry:
	ret = wait_for_completion_timeout(
		&load_cmd->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
@@ -2323,6 +2324,14 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
	if (!ret) {
		NPU_ERR("npu: NPU_IPC_CMD_LOAD time out %lld:%d\n",
			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;
		}

		npu_dump_debug_info(npu_dev);
		ret = -ETIMEDOUT;
		goto error_load_network;
@@ -2372,7 +2381,7 @@ int32_t npu_host_load_network_v2(struct npu_client *client,
int32_t npu_host_unload_network(struct npu_client *client,
			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 ipc_cmd_unload_pkt unload_packet;
	struct npu_network *network;
@@ -2445,6 +2454,7 @@ int32_t npu_host_unload_network(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

retry:
	ret = wait_for_completion_timeout(
		&unload_cmd->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
@@ -2461,6 +2471,14 @@ int32_t npu_host_unload_network(struct npu_client *client,
	if (!ret) {
		NPU_ERR("npu: NPU_IPC_CMD_UNLOAD time out %llx:%d\n",
			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;
		}

		npu_dump_debug_info(npu_dev);
		ret = -ETIMEDOUT;
		goto free_unload_cmd;
@@ -2503,7 +2521,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
	uint32_t num_patch_params, pkt_size;
	bool async_ioctl = !!exec_ioctl->async;
	int i;
	int i, retry_cnt = 1;

	mutex_lock(&host_ctx->lock);
	network = get_network_by_hdl(host_ctx, client,
@@ -2603,6 +2621,7 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,

	mutex_unlock(&host_ctx->lock);

retry:
	ret = wait_for_completion_timeout(
		&exec_cmd->cmd_done,
		(host_ctx->fw_dbg_mode & FW_DBG_MODE_INC_TIMEOUT) ?
@@ -2618,6 +2637,14 @@ int32_t npu_host_exec_network_v2(struct npu_client *client,
	if (!ret) {
		NPU_ERR("npu: %llx:%d NPU_IPC_CMD_EXECUTE_V2 time out\n",
			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;
		}

		npu_dump_debug_info(npu_dev);
		ret = -ETIMEDOUT;
		goto free_exec_packet;
@@ -2839,3 +2866,10 @@ int32_t npu_host_get_perf_mode(struct npu_client *client, uint32_t network_hdl)

	return param_val;
}

void npu_host_suspend(struct npu_device *npu_dev)
{
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;

	flush_delayed_work(&host_ctx->disable_fw_work);
}
+1 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ int npu_host_update_power(struct npu_device *npu_dev);
int32_t npu_host_set_perf_mode(struct npu_client *client, uint32_t network_hdl,
	uint32_t perf_mode);
int32_t npu_host_get_perf_mode(struct npu_client *client, uint32_t network_hdl);
void npu_host_suspend(struct npu_device *npu_dev);
void npu_dump_debug_info(struct npu_device *npu_dev);
void npu_dump_ipc_packet(struct npu_device *npu_dev, void *cmd_ptr);