aboutsummaryrefslogtreecommitdiff
path: root/kernel/ethosu_device.c
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2023-08-23 11:02:47 +0200
committerMikael Olsson <mikael.olsson@arm.com>2023-09-07 10:42:37 +0200
commit6fb238f4a2fe1592275449c419b5140c9eb9dd49 (patch)
tree4da0e3915fcd952e9f871238d43408049ae873e3 /kernel/ethosu_device.c
parent18257600f30afb78f4f82cd921073cef98f5ce81 (diff)
downloadethos-u-linux-driver-stack-6fb238f4a2fe1592275449c419b5140c9eb9dd49.tar.gz
Fix wait for TX buffer blocking receive callback
Currently, the mailbox uses the rpmsg_send function to send messages, which will block for up to 15 seconds if there is no TX buffer available for the message. This is an issue because the device mutex is locked while waiting and the receive callback for messages uses the same mutex to prevent concurrent access so no received messages can be handled while waiting for a TX buffer. To resolve this, the mailbox has been changed to use the rpmsg_trysend function, which will return directly if there is no TX buffer available, together with a wait queue. While waiting in the queue to send the message, the device mutex is released to not block the receive callback and other users of the mutex. Change-Id: I34fbfd21167b49fb83744ab2473ab02632a809ee Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'kernel/ethosu_device.c')
-rw-r--r--kernel/ethosu_device.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/ethosu_device.c b/kernel/ethosu_device.c
index 6866857..b889a7b 100644
--- a/kernel/ethosu_device.c
+++ b/kernel/ethosu_device.c
@@ -71,6 +71,7 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
{
struct ethosu_device *edev = dev_get_drvdata(&rpdev->dev);
struct device *dev = &edev->dev;
+ struct ethosu_mailbox *mbox = &edev->mailbox;
struct ethosu_core_rpmsg *rpmsg = data;
int length = len - sizeof(rpmsg->header);
int ret = 0;
@@ -106,7 +107,7 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
break;
case ETHOSU_CORE_MSG_PING:
dev_info(dev, "Msg: Ping");
- ret = ethosu_mailbox_pong(&edev->mailbox);
+ ret = ethosu_mailbox_pong(mbox);
break;
case ETHOSU_CORE_MSG_PONG:
dev_info(dev, "Msg: Pong");
@@ -124,7 +125,7 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
"Msg: Inference response. ofm_count=%u, status=%u",
rpmsg->inf_rsp.ofm_count, rpmsg->inf_rsp.status);
- ethosu_inference_rsp(&edev->mailbox, rpmsg->header.msg_id,
+ ethosu_inference_rsp(mbox, rpmsg->header.msg_id,
&rpmsg->inf_rsp);
break;
case ETHOSU_CORE_MSG_CANCEL_INFERENCE_RSP:
@@ -139,7 +140,7 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
dev_info(dev,
"Msg: Cancel Inference response. status=%u",
rpmsg->cancel_rsp.status);
- ethosu_cancel_inference_rsp(&edev->mailbox,
+ ethosu_cancel_inference_rsp(mbox,
rpmsg->header.msg_id,
&rpmsg->cancel_rsp);
break;
@@ -156,7 +157,7 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
rpmsg->version_rsp.major, rpmsg->version_rsp.minor,
rpmsg->version_rsp.patch);
- ethosu_version_rsp(&edev->mailbox, rpmsg->header.msg_id,
+ ethosu_version_rsp(mbox, rpmsg->header.msg_id,
&rpmsg->version_rsp);
break;
case ETHOSU_CORE_MSG_CAPABILITIES_RSP:
@@ -184,7 +185,7 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
rpmsg->cap_rsp.cmd_stream_version,
rpmsg->cap_rsp.custom_dma);
- ethosu_capability_rsp(&edev->mailbox, rpmsg->header.msg_id,
+ ethosu_capability_rsp(mbox, rpmsg->header.msg_id,
&rpmsg->cap_rsp);
break;
case ETHOSU_CORE_MSG_NETWORK_INFO_RSP:
@@ -200,7 +201,7 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
"Msg: Network info response. status=%u",
rpmsg->net_info_rsp.status);
- ethosu_network_info_rsp(&edev->mailbox,
+ ethosu_network_info_rsp(mbox,
rpmsg->header.msg_id,
&rpmsg->net_info_rsp);
@@ -215,6 +216,8 @@ static int ethosu_handle_rpmsg(struct rpmsg_device *rpdev,
device_unlock(dev);
+ wake_up(&mbox->send_queue);
+
return ret;
}