Commit 159c7976 authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Bjorn Andersson

rpmsg: glink: Tidy up RX advance handling

The operation of advancing the FIFO receive pointer is sprinkled between
the interrupt handler itself, and functions being called from this.

Push all the RX advancement operations to the individual handlers, to
unify the style across the handling of the various messages.
Signed-off-by: default avatarBjorn Andersson <quic_bjorande@quicinc.com>
Reviewed-by: default avatarChris Lew <quic_clew@quicinc.com>
Link: https://lore.kernel.org/r/20240805-glink-tracepoints-v1-1-a5f3293fb09e@quicinc.comSigned-off-by: default avatarBjorn Andersson <andersson@kernel.org>
parent 8400291e
......@@ -424,6 +424,8 @@ static void qcom_glink_handle_intent_req_ack(struct qcom_glink *glink,
struct glink_channel *channel;
unsigned long flags;
qcom_glink_rx_advance(glink, ALIGN(sizeof(struct glink_msg), 8));
spin_lock_irqsave(&glink->idr_lock, flags);
channel = idr_find(&glink->rcids, cid);
spin_unlock_irqrestore(&glink->idr_lock, flags);
......@@ -745,6 +747,8 @@ static void qcom_glink_handle_rx_done(struct qcom_glink *glink,
struct glink_channel *channel;
unsigned long flags;
qcom_glink_rx_advance(glink, ALIGN(sizeof(struct glink_msg), 8));
spin_lock_irqsave(&glink->idr_lock, flags);
channel = idr_find(&glink->rcids, cid);
spin_unlock_irqrestore(&glink->idr_lock, flags);
......@@ -952,6 +956,12 @@ static int qcom_glink_rx_data(struct qcom_glink *glink, size_t avail)
return ret;
}
static void qcom_glink_rx_read_notif(struct qcom_glink *glink)
{
qcom_glink_rx_advance(glink, ALIGN(sizeof(struct glink_msg), 8));
qcom_glink_tx_kick(glink);
}
static void qcom_glink_handle_intent(struct qcom_glink *glink,
unsigned int cid,
unsigned int count,
......@@ -1022,6 +1032,8 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid)
{
struct glink_channel *channel;
qcom_glink_rx_advance(glink, ALIGN(sizeof(struct glink_msg), 8));
spin_lock(&glink->idr_lock);
channel = idr_find(&glink->lcids, lcid);
spin_unlock(&glink->idr_lock);
......@@ -1067,6 +1079,8 @@ static void qcom_glink_handle_signals(struct qcom_glink *glink,
unsigned long flags;
bool enable;
qcom_glink_rx_advance(glink, ALIGN(sizeof(struct glink_msg), 8));
spin_lock_irqsave(&glink->idr_lock, flags);
channel = idr_find(&glink->rcids, rcid);
spin_unlock_irqrestore(&glink->idr_lock, flags);
......@@ -1114,7 +1128,6 @@ void qcom_glink_native_rx(struct qcom_glink *glink)
break;
case GLINK_CMD_OPEN_ACK:
ret = qcom_glink_rx_open_ack(glink, param1);
qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
break;
case GLINK_CMD_OPEN:
ret = qcom_glink_rx_defer(glink, param2);
......@@ -1124,27 +1137,22 @@ void qcom_glink_native_rx(struct qcom_glink *glink)
ret = qcom_glink_rx_data(glink, avail);
break;
case GLINK_CMD_READ_NOTIF:
qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
qcom_glink_tx_kick(glink);
qcom_glink_rx_read_notif(glink);
break;
case GLINK_CMD_INTENT:
qcom_glink_handle_intent(glink, param1, param2, avail);
break;
case GLINK_CMD_RX_DONE:
qcom_glink_handle_rx_done(glink, param1, param2, false);
qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
break;
case GLINK_CMD_RX_DONE_W_REUSE:
qcom_glink_handle_rx_done(glink, param1, param2, true);
qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
break;
case GLINK_CMD_RX_INTENT_REQ_ACK:
qcom_glink_handle_intent_req_ack(glink, param1, param2);
qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
break;
case GLINK_CMD_SIGNALS:
qcom_glink_handle_signals(glink, param1, param2);
qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
break;
default:
dev_err(glink->dev, "unhandled rx cmd: %d\n", cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment