Skip to content

Commit a387e73

Browse files
quic-bjorandeandersson
authored andcommitted
rpmsg: glink: Handle rejected intent request better
GLINK operates using pre-allocated buffers, aka intents, where incoming messages are aggregated before being passed up the stack. In the case that no suitable intents have been announced by the receiver, the sender can request an intent to be allocated. The initial implementation of the response to such request dealt with two outcomes; granted allocations, and all other cases being considered -ECANCELLED (likely from "cancelling the operation as the remote is going down"). But on some channels intent allocation is not supported, instead the remote will pre-allocate and announce a fixed number of intents for the sender to use. If for such channels an rpmsg_send() is being invoked before any channels have been announced, an intent request will be issued and as this comes back rejected the call fails with -ECANCELED. Given that this is reported in the same way as the remote being shut down, there's no way for the client to differentiate the two cases. In line with the original GLINK design, change the return value to -EAGAIN for the case where the remote rejects an intent allocation request. It's tempting to handle this case in the GLINK core, as we expect intents to show up in this case. But there's no way to distinguish between this case and a rejection for a too big allocation, nor is it possible to predict if a currently used (and seemingly suitable) intent will be returned for reuse or not. As such, returning the error to the client and allow it to react seems to be the only sensible solution. In addition to this, commit 'c05dfce0b89e ("rpmsg: glink: Wait for intent, not just request ack")' changed the logic such that the code always wait for an intent request response and an intent. This works out in most cases, but in the event that an intent request is rejected and no further intent arrives (e.g. client asks for a too big intent), the code will stall for 10 seconds and then return -ETIMEDOUT; instead of a more suitable error. This change also resulted in intent requests racing with the shutdown of the remote would be exposed to this same problem, unless some intent happens to arrive. A patch for this was developed and posted by Sarannya S [1], and has been incorporated here. To summarize, the intent request can end in 4 ways: - Timeout, no response arrived => return -ETIMEDOUT - Abort TX, the edge is going away => return -ECANCELLED - Intent request was rejected => return -EAGAIN - Intent request was accepted, and an intent arrived => return 0 This patch was developed with input from Sarannya S, Deepak Kumar Singh, and Chris Lew. [1] https://lore.kernel.org/all/[email protected]/ Fixes: c05dfce ("rpmsg: glink: Wait for intent, not just request ack") Cc: [email protected] Tested-by: Johan Hovold <[email protected]> Signed-off-by: Bjorn Andersson <[email protected]> Reviewed-by: Chris Lew <[email protected]> Link: https://lore.kernel.org/r/20241023-pmic-glink-ecancelled-v2-1-ebc268129407@oss.qualcomm.com Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 128fdbf commit a387e73

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/rpmsg/qcom_glink_native.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,14 +1440,18 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
14401440
goto unlock;
14411441

14421442
ret = wait_event_timeout(channel->intent_req_wq,
1443-
READ_ONCE(channel->intent_req_result) >= 0 &&
1444-
READ_ONCE(channel->intent_received),
1443+
READ_ONCE(channel->intent_req_result) == 0 ||
1444+
(READ_ONCE(channel->intent_req_result) > 0 &&
1445+
READ_ONCE(channel->intent_received)) ||
1446+
glink->abort_tx,
14451447
10 * HZ);
14461448
if (!ret) {
14471449
dev_err(glink->dev, "intent request timed out\n");
14481450
ret = -ETIMEDOUT;
1451+
} else if (glink->abort_tx) {
1452+
ret = -ECANCELED;
14491453
} else {
1450-
ret = READ_ONCE(channel->intent_req_result) ? 0 : -ECANCELED;
1454+
ret = READ_ONCE(channel->intent_req_result) ? 0 : -EAGAIN;
14511455
}
14521456

14531457
unlock:

0 commit comments

Comments
 (0)