soc: qcom: glink: Add RX intent request timeout to G-Link channels

During glink_tx(), G-Link can wait for an unlimited amount of time for
the remote side to queue an RX intent. In some cases, e.g. SSR, the wait
must be restricted to a short time, but in the current implementation,
glink_tx() can continue to block indefinitely.

Add a configurable timeout value to the G-Link channel context, which is
set in the channel open configuration. If the value is set to 0, treat
it as an infinite timeout. This allows a timeout to be put in place by
the client for sensitive cases such as SSR where a very limited amount of
time can be spent waiting for an intent.

Change-Id: I1e480fac286d285f871fe3059de7ae761fc4581e
Signed-off-by: Steven Cahail <scahail@codeaurora.org>
This commit is contained in:
Steven Cahail 2015-12-03 13:23:30 -07:00 committed by David Keitel
parent 945d3d962c
commit ea74beeae9
2 changed files with 48 additions and 19 deletions

View file

@ -159,14 +159,16 @@ struct glink_core_xprt_ctx {
* @notify_rx_tracer_pkt: Receive notification for tracer packet * @notify_rx_tracer_pkt: Receive notification for tracer packet
* @notify_remote_rx_intent: Receive notification for remote-queued RX intent * @notify_remote_rx_intent: Receive notification for remote-queued RX intent
* *
* @transport_ptr: Transport this channel uses * @transport_ptr: Transport this channel uses
* @lcid: Local channel ID * @lcid: Local channel ID
* @rcid: Remote channel ID * @rcid: Remote channel ID
* @local_open_state: Local channel state * @local_open_state: Local channel state
* @remote_opened: Remote channel state (opened or closed) * @remote_opened: Remote channel state (opened or closed)
* @int_req_ack: Remote side intent request ACK state * @int_req_ack: Remote side intent request ACK state
* @int_req_ack_complete: Intent tracking completion - received remote ACK * @int_req_ack_complete: Intent tracking completion - received remote ACK
* @int_req_complete: Intent tracking completion - received intent * @int_req_complete: Intent tracking completion - received intent
* @rx_intent_req_timeout_jiffies: Timeout for requesting an RX intent, in
* jiffies; if set to 0, timeout is infinite
* *
* @local_rx_intent_lst_lock_lhc1: RX intent list lock * @local_rx_intent_lst_lock_lhc1: RX intent list lock
* @local_rx_intent_list: Active RX Intents queued by client * @local_rx_intent_list: Active RX Intents queued by client
@ -244,6 +246,7 @@ struct channel_ctx {
bool int_req_ack; bool int_req_ack;
struct completion int_req_ack_complete; struct completion int_req_ack_complete;
struct completion int_req_complete; struct completion int_req_complete;
unsigned long rx_intent_req_timeout_jiffies;
spinlock_t local_rx_intent_lst_lock_lhc1; spinlock_t local_rx_intent_lst_lock_lhc1;
struct list_head local_rx_intent_list; struct list_head local_rx_intent_list;
@ -2401,6 +2404,8 @@ void *glink_open(const struct glink_open_config *cfg)
/* initialize port structure */ /* initialize port structure */
ctx->user_priv = cfg->priv; ctx->user_priv = cfg->priv;
ctx->rx_intent_req_timeout_jiffies =
msecs_to_jiffies(cfg->rx_intent_req_timeout_ms);
ctx->notify_rx = cfg->notify_rx; ctx->notify_rx = cfg->notify_rx;
ctx->notify_tx_done = cfg->notify_tx_done; ctx->notify_tx_done = cfg->notify_tx_done;
ctx->notify_state = cfg->notify_state; ctx->notify_state = cfg->notify_state;
@ -2421,6 +2426,9 @@ void *glink_open(const struct glink_open_config *cfg)
if (!ctx->notify_tx_abort) if (!ctx->notify_tx_abort)
ctx->notify_tx_abort = glink_dummy_notify_tx_abort; ctx->notify_tx_abort = glink_dummy_notify_tx_abort;
if (!ctx->rx_intent_req_timeout_jiffies)
ctx->rx_intent_req_timeout_jiffies = MAX_SCHEDULE_TIMEOUT;
ctx->local_xprt_req = best_id; ctx->local_xprt_req = best_id;
ctx->no_migrate = cfg->transport && ctx->no_migrate = cfg->transport &&
!(cfg->options & GLINK_OPT_INITIAL_XPORT); !(cfg->options & GLINK_OPT_INITIAL_XPORT);
@ -2712,7 +2720,16 @@ static int glink_tx_common(void *handle, void *pkt_priv,
} }
/* wait for the remote intent req ack */ /* wait for the remote intent req ack */
wait_for_completion(&ctx->int_req_ack_complete); if (!wait_for_completion_timeout(
&ctx->int_req_ack_complete,
ctx->rx_intent_req_timeout_jiffies)) {
GLINK_ERR_CH(ctx,
"%s: Intent request ack with size: %zu not granted for lcid\n",
__func__, size);
rwref_put(&ctx->ch_state_lhc0);
return -ETIMEDOUT;
}
if (!ctx->int_req_ack) { if (!ctx->int_req_ack) {
GLINK_ERR_CH(ctx, GLINK_ERR_CH(ctx,
"%s: Intent Request with size: %zu %s", "%s: Intent Request with size: %zu %s",
@ -2723,7 +2740,16 @@ static int glink_tx_common(void *handle, void *pkt_priv,
} }
/* wait for the rx_intent from remote side */ /* wait for the rx_intent from remote side */
wait_for_completion(&ctx->int_req_complete); if (!wait_for_completion_timeout(
&ctx->int_req_complete,
ctx->rx_intent_req_timeout_jiffies)) {
GLINK_ERR_CH(ctx,
"%s: Intent request with size: %zu not granted for lcid\n",
__func__, size);
rwref_put(&ctx->ch_state_lhc0);
return -ETIMEDOUT;
}
reinit_completion(&ctx->int_req_complete); reinit_completion(&ctx->int_req_complete);
ch_st = ctx->local_open_state; ch_st = ctx->local_open_state;
if (ch_st == GLINK_CHANNEL_CLOSING || if (ch_st == GLINK_CHANNEL_CLOSING ||

View file

@ -43,15 +43,17 @@ enum {
/** /**
* Open configuration. * Open configuration.
* *
* priv: Private data passed into user callbacks * priv: Private data passed into user callbacks
* options: Open option flags * options: Open option flags
* notify_rx: Receive notification function (required) * rx_intent_req_timeout_ms: Timeout for requesting an RX intent, in
* notify_tx_done: Transmit-done notification function (required) * milliseconds; if set to 0, timeout is infinite
* notify_state: State-change notification (required) * notify_rx: Receive notification function (required)
* notify_rx_intent_req: Receive intent request (optional) * notify_tx_done: Transmit-done notification function (required)
* notify_rxv: Receive notification function for vector buffers (required if * notify_state: State-change notification (required)
* notify_rx is not provided) * notify_rx_intent_req: Receive intent request (optional)
* notify_sig: Signal-change notification (optional) * notify_rxv: Receive notification function for vector buffers
* (required if notify_rx is not provided)
* notify_sig: Signal-change notification (optional)
* notify_rx_tracer_pkt: Receive notification for tracer packet * notify_rx_tracer_pkt: Receive notification for tracer packet
* notify_remote_rx_intent: Receive notification for remote-queued RX intent * notify_remote_rx_intent: Receive notification for remote-queued RX intent
* *
@ -67,6 +69,7 @@ struct glink_open_config {
const char *transport; const char *transport;
const char *edge; const char *edge;
const char *name; const char *name;
unsigned int rx_intent_req_timeout_ms;
void (*notify_rx)(void *handle, const void *priv, const void *pkt_priv, void (*notify_rx)(void *handle, const void *priv, const void *pkt_priv,
const void *ptr, size_t size); const void *ptr, size_t size);