Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9da3a1e1 authored by Steven Cahail's avatar Steven Cahail
Browse files

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: default avatarSteven Cahail <scahail@codeaurora.org>
parent 1acad2bb
Loading
Loading
Loading
Loading
+36 −10
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ struct glink_core_xprt_ctx {
 * @int_req_ack:		Remote side intent request ACK state
 * @int_req_ack_complete:	Intent tracking completion - received remote ACK
 * @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_list:		Active RX Intents queued by client
@@ -242,6 +244,7 @@ struct channel_ctx {
	bool int_req_ack;
	struct completion int_req_ack_complete;
	struct completion int_req_complete;
	unsigned long rx_intent_req_timeout_jiffies;

	spinlock_t local_rx_intent_lst_lock_lhc1;
	struct list_head local_rx_intent_list;
@@ -2399,6 +2402,8 @@ void *glink_open(const struct glink_open_config *cfg)

	/* initialize port structure */
	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_tx_done = cfg->notify_tx_done;
	ctx->notify_state = cfg->notify_state;
@@ -2419,6 +2424,9 @@ void *glink_open(const struct glink_open_config *cfg)
	if (!ctx->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->no_migrate = cfg->transport &&
				!(cfg->options & GLINK_OPT_INITIAL_XPORT);
@@ -2710,7 +2718,16 @@ static int glink_tx_common(void *handle, void *pkt_priv,
			}

			/* 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) {
				GLINK_ERR_CH(ctx,
				    "%s: Intent Request with size: %zu %s",
@@ -2721,7 +2738,16 @@ static int glink_tx_common(void *handle, void *pkt_priv,
			}

			/* 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);
			ch_st = ctx->local_open_state;
			if (ch_st == GLINK_CHANNEL_CLOSING ||
+12 −9
Original line number Diff line number Diff line
@@ -45,12 +45,14 @@ enum {
 *
 * priv:			Private data passed into user callbacks
 * options:			Open option flags
 * rx_intent_req_timeout_ms:	Timeout for requesting an RX intent, in
 *			milliseconds; if set to 0, timeout is infinite
 * notify_rx:			Receive notification function (required)
 * notify_tx_done:		Transmit-done notification function (required)
 * notify_state:		State-change notification (required)
 * notify_rx_intent_req:	Receive intent request (optional)
 * notify_rxv:	Receive notification function for vector buffers (required if
 *		notify_rx is not provided)
 * 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_remote_rx_intent:	Receive notification for remote-queued RX intent
@@ -67,6 +69,7 @@ struct glink_open_config {
	const char *transport;
	const char *edge;
	const char *name;
	unsigned int rx_intent_req_timeout_ms;

	void (*notify_rx)(void *handle, const void *priv, const void *pkt_priv,
			const void *ptr, size_t size);