Merge branch 'android-msm-pixel-4.14-sc-security' into android-msm-pixel-4.14-sc-v2
May 2022.1
Bug: 218985197
Change-Id: If1d0f6c46d32e2c977ff24da78c807f5c1cfe6f2
diff --git a/drivers/media/platform/msm/npu/npu_common.h b/drivers/media/platform/msm/npu/npu_common.h
index 9481582..ee32871 100644
--- a/drivers/media/platform/msm/npu/npu_common.h
+++ b/drivers/media/platform/msm/npu/npu_common.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2021, 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
@@ -251,18 +251,9 @@
uint32_t hw_version;
};
-struct npu_kevent {
- struct list_head list;
- struct msm_npu_event evt;
- uint64_t reserved[4];
-};
-
struct npu_client {
struct npu_device *npu_dev;
- wait_queue_head_t wait;
-
struct mutex list_lock;
- struct list_head evt_list;
struct list_head mapped_buffer_list;
};
diff --git a/drivers/media/platform/msm/npu/npu_dev.c b/drivers/media/platform/msm/npu/npu_dev.c
index 8203859..0ef65b6 100644
--- a/drivers/media/platform/msm/npu/npu_dev.c
+++ b/drivers/media/platform/msm/npu/npu_dev.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2021, 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
@@ -112,8 +112,6 @@
unsigned long arg);
static int npu_exec_network_v2(struct npu_client *client,
unsigned long arg);
-static int npu_receive_event(struct npu_client *client,
- unsigned long arg);
static int npu_set_fw_state(struct npu_client *client, uint32_t enable);
static int npu_set_property(struct npu_client *client,
unsigned long arg);
@@ -121,7 +119,6 @@
unsigned long arg);
static long npu_ioctl(struct file *file, unsigned int cmd,
unsigned long arg);
-static unsigned int npu_poll(struct file *filp, struct poll_table_struct *p);
static int npu_parse_dt_clock(struct npu_device *npu_dev);
static int npu_parse_dt_regulator(struct npu_device *npu_dev);
static int npu_of_parse_pwrlevels(struct npu_device *npu_dev,
@@ -237,7 +234,6 @@
#ifdef CONFIG_COMPAT
.compat_ioctl = npu_ioctl,
#endif
- .poll = npu_poll,
};
static const struct thermal_cooling_device_ops npu_cooling_ops = {
@@ -1226,9 +1222,7 @@
return -ENOMEM;
client->npu_dev = npu_dev;
- init_waitqueue_head(&client->wait);
mutex_init(&client->list_lock);
- INIT_LIST_HEAD(&client->evt_list);
INIT_LIST_HEAD(&(client->mapped_buffer_list));
file->private_data = client;
@@ -1238,17 +1232,8 @@
static int npu_close(struct inode *inode, struct file *file)
{
struct npu_client *client = file->private_data;
- struct npu_kevent *kevent;
npu_host_cleanup_networks(client);
-
- while (!list_empty(&client->evt_list)) {
- kevent = list_first_entry(&client->evt_list,
- struct npu_kevent, list);
- list_del(&kevent->list);
- kfree(kevent);
- }
-
mutex_destroy(&client->list_lock);
kfree(client);
return 0;
@@ -1570,57 +1555,6 @@
return ret;
}
-static int npu_process_kevent(struct npu_kevent *kevt)
-{
- int ret = 0;
-
- switch (kevt->evt.type) {
- case MSM_NPU_EVENT_TYPE_EXEC_V2_DONE:
- ret = copy_to_user((void __user *)kevt->reserved[1],
- (void *)kevt->reserved[0],
- kevt->evt.u.exec_v2_done.stats_buf_size);
- if (ret) {
- pr_err("fail to copy to user\n");
- kevt->evt.u.exec_v2_done.stats_buf_size = 0;
- ret = -EFAULT;
- }
- break;
- default:
- break;
- }
-
- return ret;
-}
-
-static int npu_receive_event(struct npu_client *client,
- unsigned long arg)
-{
- void __user *argp = (void __user *)arg;
- struct npu_kevent *kevt;
- int ret = 0;
-
- mutex_lock(&client->list_lock);
- if (list_empty(&client->evt_list)) {
- pr_err("event list is empty\n");
- ret = -EINVAL;
- } else {
- kevt = list_first_entry(&client->evt_list,
- struct npu_kevent, list);
- list_del(&kevt->list);
- npu_process_kevent(kevt);
- ret = copy_to_user(argp, &kevt->evt,
- sizeof(struct msm_npu_event));
- if (ret) {
- pr_err("fail to copy to user\n");
- ret = -EFAULT;
- }
- kfree(kevt);
- }
- mutex_unlock(&client->list_lock);
-
- return ret;
-}
-
static int npu_set_fw_state(struct npu_client *client, uint32_t enable)
{
struct npu_device *npu_dev = client->npu_dev;
@@ -1772,9 +1706,6 @@
case MSM_NPU_EXEC_NETWORK_V2:
ret = npu_exec_network_v2(client, arg);
break;
- case MSM_NPU_RECEIVE_EVENT:
- ret = npu_receive_event(client, arg);
- break;
case MSM_NPU_SET_PROP:
ret = npu_set_property(client, arg);
break;
@@ -1788,23 +1719,6 @@
return ret;
}
-static unsigned int npu_poll(struct file *filp, struct poll_table_struct *p)
-{
- struct npu_client *client = filp->private_data;
- int rc = 0;
-
- poll_wait(filp, &client->wait, p);
-
- mutex_lock(&client->list_lock);
- if (!list_empty(&client->evt_list)) {
- pr_debug("poll cmd done\n");
- rc = POLLIN | POLLRDNORM;
- }
- mutex_unlock(&client->list_lock);
-
- return rc;
-}
-
/* -------------------------------------------------------------------------
* Device Tree Parsing
* -------------------------------------------------------------------------
diff --git a/drivers/media/platform/msm/npu/npu_mgr.c b/drivers/media/platform/msm/npu/npu_mgr.c
index 3298cf4..ae950a6 100644
--- a/drivers/media/platform/msm/npu/npu_mgr.c
+++ b/drivers/media/platform/msm/npu/npu_mgr.c
@@ -60,10 +60,9 @@
static void host_session_log_hdlr(struct npu_device *npu_dev);
static int host_error_hdlr(struct npu_device *npu_dev, bool force);
static int npu_send_network_cmd(struct npu_device *npu_dev,
- struct npu_network *network, void *cmd_ptr, bool async);
+ struct npu_network *network, void *cmd_ptr);
static int npu_send_misc_cmd(struct npu_device *npu_dev, uint32_t q_idx,
void *cmd_ptr);
-static int npu_queue_event(struct npu_client *client, struct npu_kevent *evt);
static int npu_notify_dsp(struct npu_device *npu_dev, bool pwr_up);
static int npu_notify_aop(struct npu_device *npu_dev, bool on);
static int update_dcvs_activity(struct npu_device *npu_dev, uint32_t activity);
@@ -355,7 +354,6 @@
{
struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
struct npu_network *network = NULL;
- struct npu_kevent kevt;
int i;
if ((host_ctx->wdg_irq_sts == 0) && (host_ctx->err_irq_sts == 0)
@@ -375,18 +373,10 @@
network = &host_ctx->networks[i];
if (network->is_valid && network->cmd_pending &&
network->fw_error) {
- if (network->cmd_async) {
- pr_debug("async cmd, queue ssr event\n");
- kevt.evt.type = MSM_NPU_EVENT_TYPE_SSR;
- kevt.evt.u.ssr.network_hdl =
- network->network_hdl;
- if (npu_queue_event(network->client, &kevt))
- pr_err("queue npu event failed\n");
- } else {
- pr_debug("complete network %llx\n",
- network->id);
- complete(&network->cmd_done);
- }
+ network->cmd_pending = false;
+ pr_debug("complete network %llx\n",
+ network->id);
+ complete(&network->cmd_done);
}
}
complete_all(&host_ctx->loopback_done);
@@ -701,31 +691,13 @@
* Function Definitions - IPC
* -------------------------------------------------------------------------
*/
-static int npu_queue_event(struct npu_client *client, struct npu_kevent *evt)
-{
- struct npu_kevent *kevt = kmalloc(sizeof(*kevt), GFP_KERNEL);
-
- if (!kevt)
- return -ENOMEM;
-
- *kevt = *evt;
- INIT_LIST_HEAD(&kevt->list);
- mutex_lock(&client->list_lock);
- list_add_tail(&kevt->list, &client->evt_list);
- mutex_unlock(&client->list_lock);
- wake_up_interruptible(&client->wait);
-
- return 0;
-}
static void app_msg_proc(struct npu_host_ctx *host_ctx, uint32_t *msg)
{
uint32_t msg_id;
struct npu_network *network = NULL;
- struct npu_kevent kevt;
struct npu_device *npu_dev = host_ctx->npu_dev;
- memset(&kevt, 0, sizeof(kevt));
msg_id = msg[1];
switch (msg_id) {
case NPU_IPC_MSG_EXECUTE_DONE:
@@ -764,18 +736,7 @@
network->cmd_pending = false;
network->cmd_ret_status = exe_rsp_pkt->header.status;
- if (!network->cmd_async) {
- complete(&network->cmd_done);
- } else {
- pr_debug("async cmd, queue event\n");
- kevt.evt.type = MSM_NPU_EVENT_TYPE_EXEC_DONE;
- kevt.evt.u.exec_done.network_hdl =
- exe_rsp_pkt->network_hdl;
- kevt.evt.u.exec_done.exec_result =
- exe_rsp_pkt->header.status;
- if (npu_queue_event(network->client, &kevt))
- pr_err("queue npu event failed\n");
- }
+ complete(&network->cmd_done);
network_put(network);
break;
@@ -819,22 +780,7 @@
network->stats_buf_size = stats_size;
network->cmd_pending = false;
network->cmd_ret_status = exe_rsp_pkt->header.status;
-
- if (network->cmd_async) {
- pr_debug("async cmd, queue event\n");
- kevt.evt.type = MSM_NPU_EVENT_TYPE_EXEC_V2_DONE;
- kevt.evt.u.exec_v2_done.network_hdl =
- exe_rsp_pkt->network_hdl;
- kevt.evt.u.exec_v2_done.exec_result =
- exe_rsp_pkt->header.status;
- kevt.evt.u.exec_v2_done.stats_buf_size = stats_size;
- kevt.reserved[0] = (uint64_t)network->stats_buf;
- kevt.reserved[1] = (uint64_t)network->stats_buf_u;
- if (npu_queue_event(network->client, &kevt))
- pr_err("queue npu event failed\n");
- } else {
- complete(&network->cmd_done);
- }
+ complete(&network->cmd_done);
network_put(network);
break;
}
@@ -1126,7 +1072,7 @@
}
static int npu_send_network_cmd(struct npu_device *npu_dev,
- struct npu_network *network, void *cmd_ptr, bool async)
+ struct npu_network *network, void *cmd_ptr)
{
struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
int ret = 0;
@@ -1142,7 +1088,6 @@
pr_debug("Send cmd %d network id %lld\n",
((struct ipc_cmd_header_pkt *)cmd_ptr)->cmd_type,
network->id);
- network->cmd_async = async;
network->cmd_ret_status = 0;
network->cmd_pending = true;
network->trans_id = atomic_read(&host_ctx->ipc_trans_id);
@@ -1477,7 +1422,7 @@
set_perf_mode(npu_dev);
/* NPU_IPC_CMD_LOAD will go onto IPC_QUEUE_APPS_EXEC */
reinit_completion(&network->cmd_done);
- ret = npu_send_network_cmd(npu_dev, network, &load_packet, false);
+ ret = npu_send_network_cmd(npu_dev, network, &load_packet);
if (ret) {
pr_err("NPU_IPC_CMD_LOAD sent failed: %d\n", ret);
goto error_free_network;
@@ -1598,7 +1543,7 @@
set_perf_mode(npu_dev);
/* NPU_IPC_CMD_LOAD_V2 will go onto IPC_QUEUE_APPS_EXEC */
reinit_completion(&network->cmd_done);
- ret = npu_send_network_cmd(npu_dev, network, load_packet, false);
+ ret = npu_send_network_cmd(npu_dev, network, load_packet);
if (ret) {
pr_debug("NPU_IPC_CMD_LOAD_V2 sent failed: %d\n", ret);
goto error_free_network;
@@ -1693,7 +1638,7 @@
retry:
/* NPU_IPC_CMD_UNLOAD will go onto IPC_QUEUE_APPS_EXEC */
reinit_completion(&network->cmd_done);
- ret = npu_send_network_cmd(npu_dev, network, &unload_packet, false);
+ ret = npu_send_network_cmd(npu_dev, network, &unload_packet);
if (ret) {
pr_err("NPU_IPC_CMD_UNLOAD sent failed: %d\n", ret);
@@ -1774,7 +1719,6 @@
int32_t ret;
struct npu_network *network;
struct npu_host_ctx *host_ctx = &npu_dev->host_ctx;
- bool async_ioctl = !!exec_ioctl->async;
mutex_lock(&host_ctx->lock);
network = get_network_by_hdl(host_ctx, client,
@@ -1838,18 +1782,13 @@
/* Send it on the high priority queue */
reinit_completion(&network->cmd_done);
- ret = npu_send_network_cmd(npu_dev, network, &exec_packet, async_ioctl);
+ ret = npu_send_network_cmd(npu_dev, network, &exec_packet);
if (ret) {
pr_err("NPU_IPC_CMD_EXECUTE sent failed: %d\n", ret);
goto exec_done;
}
- if (async_ioctl) {
- pr_debug("Async ioctl, return now\n");
- goto exec_done;
- }
-
mutex_unlock(&host_ctx->lock);
ret = wait_for_completion_interruptible_timeout(
@@ -1908,7 +1847,6 @@
struct npu_network *network;
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;
mutex_lock(&host_ctx->lock);
@@ -1981,18 +1919,13 @@
/* Send it on the high priority queue */
reinit_completion(&network->cmd_done);
- ret = npu_send_network_cmd(npu_dev, network, exec_packet, async_ioctl);
+ ret = npu_send_network_cmd(npu_dev, network, exec_packet);
if (ret) {
pr_err("NPU_IPC_CMD_EXECUTE_V2 sent failed: %d\n", ret);
goto free_exec_packet;
}
- if (async_ioctl) {
- pr_debug("Async ioctl, return now\n");
- goto free_exec_packet;
- }
-
mutex_unlock(&host_ctx->lock);
ret = wait_for_completion_interruptible_timeout(
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index 9bdc797..ffa90d4 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -393,6 +393,7 @@
return 0;
pipe->nrbufs++;
buf->ops = &page_cache_pipe_buf_ops;
+ buf->flags = 0;
get_page(buf->page = page);
buf->offset = offset;
buf->len = bytes;
@@ -517,6 +518,7 @@
break;
pipe->nrbufs++;
pipe->bufs[idx].ops = &default_pipe_buf_ops;
+ pipe->bufs[idx].flags = 0;
pipe->bufs[idx].page = page;
pipe->bufs[idx].offset = 0;
if (left <= PAGE_SIZE) {