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

Commit 445fb754 authored by Jilai Wang's avatar Jilai Wang
Browse files

msm: npu: Don't send interrupt if command has been consumed



It is possible that the command is consumed by firmware before
the interrupt is triggered. If the command is power off
notification, npu will be woken up unexpected and run into error
state.

Change-Id: I994ee862d3cc172f2562ca378b5b88d71111f269
Signed-off-by: default avatarJilai Wang <jilaiw@codeaurora.org>
parent ed069e65
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 */

/* -------------------------------------------------------------------------
@@ -295,7 +295,7 @@ static int ipc_queue_write(struct npu_device *npu_dev,
	uint32_t packet_size, new_write_idx;
	uint32_t empty_space;
	void *write_ptr;
	uint32_t read_idx;
	uint32_t read_idx, write_idx;

	size_t offset = (size_t)IPC_ADDR +
		sizeof(struct hfi_queue_tbl_header) +
@@ -384,6 +384,23 @@ static int ipc_queue_write(struct npu_device *npu_dev,
		sizeof(queue.qhdr_rx_req));
	*is_rx_req_set = (queue.qhdr_rx_req == 1) ? 1 : 0;

	/* check if queue is empty (consumed by fw) */
	if (*is_rx_req_set) {
		MEMR(npu_dev, (void *)((size_t)(offset + (uint32_t)(
			(size_t)&(queue.qhdr_write_idx) - (size_t)&queue))),
			(uint8_t *)&write_idx,
			sizeof(queue.qhdr_write_idx));

		MEMR(npu_dev, (void *)((size_t)(offset + (uint32_t)(
			(size_t)&(queue.qhdr_read_idx) - (size_t)&queue))),
			(uint8_t *)&read_idx,
			sizeof(queue.qhdr_read_idx));

		/* cmd has been consumed by fw, no need to trigger irq */
		if (read_idx == write_idx)
			*is_rx_req_set = 0;
	}

	return status;
}

+2 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
 */

/* -------------------------------------------------------------------------
@@ -1661,6 +1661,7 @@ static int app_msg_proc(struct npu_host_ctx *host_ctx, uint32_t *msg)
	struct npu_misc_cmd *misc_cmd = NULL;
	int need_ctx_switch = 0;

	memset(&kevt, 0, sizeof(kevt));
	msg_id = msg[1];
	switch (msg_id) {
	case NPU_IPC_MSG_EXECUTE_DONE: