aboutsummaryrefslogtreecommitdiff
path: root/plat/ti/k3/common/drivers/ti_sci/ti_sci.c
diff options
context:
space:
mode:
authorAndrew F. Davis <afd@ti.com>2019-04-10 12:40:12 -0400
committerAndrew F. Davis <afd@ti.com>2019-04-23 11:09:13 -0400
commit71a35273130798aa3f19e0baf793aa598577c323 (patch)
treea195b11269cce372cddcf30c41648004e103720a /plat/ti/k3/common/drivers/ti_sci/ti_sci.c
parent7a469035e96b1e6d9d31d502ed326d53c698a137 (diff)
downloadtrusted-firmware-a-71a35273130798aa3f19e0baf793aa598577c323.tar.gz
ti: k3: drivers: ti_sci: Retry message receive on bad sequence ID
When we get a sequence ID that does not match what we expect then the we are looking at is not the one we are expecting and so we error out. We can also assume this message is a stale message left in the queue, in this case we can read in the next message and check again for our message. Switch to doing that here. We only retry a set number of times so we don't lock the system if our message is actually lost and will never show up. Signed-off-by: Andrew F. Davis <afd@ti.com> Change-Id: I6c8186ccc45e646d3ba9d431f7d4c451dcd70c5c
Diffstat (limited to 'plat/ti/k3/common/drivers/ti_sci/ti_sci.c')
-rw-r--r--plat/ti/k3/common/drivers/ti_sci/ti_sci.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/plat/ti/k3/common/drivers/ti_sci/ti_sci.c b/plat/ti/k3/common/drivers/ti_sci/ti_sci.c
index a376e6ea58..ac33278a99 100644
--- a/plat/ti/k3/common/drivers/ti_sci/ti_sci.c
+++ b/plat/ti/k3/common/drivers/ti_sci/ti_sci.c
@@ -116,21 +116,28 @@ static inline int ti_sci_get_response(struct ti_sci_xfer *xfer,
{
struct k3_sec_proxy_msg *msg = &xfer->rx_message;
struct ti_sci_msg_hdr *hdr;
+ unsigned int retry = 5;
int ret;
- /* Receive the response */
- ret = k3_sec_proxy_recv(chan, msg);
- if (ret) {
- ERROR("Message receive failed (%d)\n", ret);
- return ret;
+ for (; retry > 0; retry--) {
+ /* Receive the response */
+ ret = k3_sec_proxy_recv(chan, msg);
+ if (ret) {
+ ERROR("Message receive failed (%d)\n", ret);
+ return ret;
+ }
+
+ /* msg is updated by Secure Proxy driver */
+ hdr = (struct ti_sci_msg_hdr *)msg->buf;
+
+ /* Sanity check for message response */
+ if (hdr->seq == info.seq)
+ break;
+ else
+ WARN("Message with sequence ID %u is not expected\n", hdr->seq);
}
-
- /* msg is updated by Secure Proxy driver */
- hdr = (struct ti_sci_msg_hdr *)msg->buf;
-
- /* Sanity check for message response */
- if (hdr->seq != info.seq) {
- ERROR("Message for %d is not expected\n", hdr->seq);
+ if (!retry) {
+ ERROR("Timed out waiting for message\n");
return -EINVAL;
}