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

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

Merge "msm: npu: Use mutex to protect map/unmap to avoid race condition"

parents 3c166813 87ef5f34
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -1400,8 +1400,16 @@ int32_t npu_host_get_info(struct npu_device *npu_dev,
int32_t npu_host_map_buf(struct npu_client *client,
			struct msm_npu_map_buf_ioctl *map_ioctl)
{
	return npu_mem_map(client, map_ioctl->buf_ion_hdl, map_ioctl->size,
	struct npu_device *npu_dev = client->npu_dev;
	struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
	int ret;

	mutex_lock(&host_ctx->lock);
	ret = npu_mem_map(client, map_ioctl->buf_ion_hdl, map_ioctl->size,
		&map_ioctl->npu_phys_addr);
	mutex_unlock(&host_ctx->lock);

	return ret;
}

int32_t npu_host_unmap_buf(struct npu_client *client,
@@ -1419,8 +1427,11 @@ int32_t npu_host_unmap_buf(struct npu_client *client,
		&host_ctx->fw_deinit_done, NW_CMD_TIMEOUT))
		NPU_WARN("npu: wait for fw_deinit_done time out\n");

	mutex_lock(&host_ctx->lock);
	npu_mem_unmap(client, unmap_ioctl->buf_ion_hdl,
		unmap_ioctl->npu_phys_addr);
	mutex_unlock(&host_ctx->lock);

	return 0;
}