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

Commit abd849d9 authored by Steven Cahail's avatar Steven Cahail
Browse files

soc: qcom: glink: Add glink_wait_link_down() API



If a link needs to be torn down, then the client needs to know when
the remote side has completed the link tear-down before the link is
reset and able to start link-up negotiation again.

Add the glink_wait_link_down() API to handle this. This API calls into
the underlying transport and returns whether or not the tear-down has
completed. The client can poll this API to determine whether the
remote side has completed the link tear-down.

Change-Id: I2fb24a4912d70b4ee4050a1d5eaa8a0ac29b8532
Signed-off-by: default avatarSteven Cahail <scahail@codeaurora.org>
parent f0d4f54d
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -1538,6 +1538,18 @@ static int dummy_mask_rx_irq(struct glink_transport_if *if_ptr, uint32_t lcid,
	return -EOPNOTSUPP;
}

/**
 * dummy_wait_link_down() - a dummy wait_link_down() for transports that don't
 *			define one
 * @if_ptr:	The transport interface handle for this transport.
 *
 * Return: An error to indicate that this operation is unsupported.
 */
static int dummy_wait_link_down(struct glink_transport_if *if_ptr)
{
	return -EOPNOTSUPP;
}

/**
 * notif_if_up_all_xprts() - Check and notify existing transport state if up
 * @notif_info:	Data structure containing transport information to be notified.
@@ -2325,6 +2337,26 @@ int glink_rpm_mask_rx_interrupt(void *handle, bool mask, void *pstruct)
}
EXPORT_SYMBOL(glink_rpm_mask_rx_interrupt);

/**
 * glink_wait_link_down() - Get status of link
 * @handle:	Channel handle in which this operation is performed
 *
 * This function will query the transport for its status, to allow clients to
 * proceed in cleanup operations.
 */
int glink_wait_link_down(void *handle)
{
	struct channel_ctx *ctx = (struct channel_ctx *)handle;

	if (!ctx)
		return -EINVAL;
	if (!ctx->transport_ptr)
		return -EOPNOTSUPP;

	return ctx->transport_ptr->ops->wait_link_down(ctx->transport_ptr->ops);
}
EXPORT_SYMBOL(glink_wait_link_down);

/**
 * glink_xprt_ctx_release - Free the transport context
 * @ch_st_lock:	handle to the rwref_lock associated with the transport
@@ -2430,6 +2462,8 @@ int glink_core_register_transport(struct glink_transport_if *if_ptr,
		if_ptr->mask_rx_irq = dummy_mask_rx_irq;
	if (!if_ptr->reuse_rx_intent)
		if_ptr->reuse_rx_intent = dummy_reuse_rx_intent;
	if (!if_ptr->wait_link_down)
		if_ptr->wait_link_down = dummy_wait_link_down;
	xprt_ptr->capabilities = 0;
	xprt_ptr->ops = if_ptr;
	spin_lock_init(&xprt_ptr->xprt_ctx_lock_lhb1);
+22 −0
Original line number Diff line number Diff line
@@ -1151,6 +1151,27 @@ static int ssr(struct glink_transport_if *if_ptr)
	return 0;
}

/**
 * int wait_link_down() - Check status of read/write indices
 * @if_ptr:	The transport to check
 *
 * Return: 1 if indices are all zero, 0 otherwise
 */
int wait_link_down(struct glink_transport_if *if_ptr)
{
	struct edge_info *einfo;

	einfo = container_of(if_ptr, struct edge_info, xprt_if);

	if (einfo->tx_ch_desc->write_index == 0 &&
		einfo->tx_ch_desc->read_index == 0 &&
		einfo->rx_ch_desc->write_index == 0 &&
		einfo->rx_ch_desc->read_index == 0)
		return 1;
	else
		return 0;
}

/**
 * allocate_rx_intent() - allocate/reserve space for RX Intent
 * @if_ptr:	The transport the intent is associated with.
@@ -1640,6 +1661,7 @@ static void init_xprt_if(struct edge_info *einfo)
	einfo->xprt_if.tx_cmd_set_sigs = tx_cmd_set_sigs;
	einfo->xprt_if.poll = poll;
	einfo->xprt_if.mask_rx_irq = mask_rx_irq;
	einfo->xprt_if.wait_link_down = wait_link_down;
}

/**
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ struct glink_transport_if {
	int (*poll)(struct glink_transport_if *if_ptr, uint32_t lcid);
	int (*mask_rx_irq)(struct glink_transport_if *if_ptr, uint32_t lcid,
			bool mask, void *pstruct);
	int (*wait_link_down)(struct glink_transport_if *if_ptr);

	/*
	 * Keep data pointers at the end of the structure after all function
+15 −1
Original line number Diff line number Diff line
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -47,6 +47,16 @@ int glink_rpm_rx_poll(void *handle);
 */
int glink_rpm_mask_rx_interrupt(void *handle, bool mask, void *pstruct);

/**
 * glink_wait_link_down() - Return whether read/write indices in FIFO are all 0.
 * @handle:	Channel handle in which this operation is performed.
 *
 * This function returns the status of the read/write indices in the FIFO.
 *
 * Return: 1 if the indices are all 0, 0 otherwise.
 */
int glink_wait_link_down(void *handle);

#else
static inline int glink_rpm_rx_poll(void *handle)
{
@@ -58,6 +68,10 @@ static inline int glink_rpm_mask_rx_interrupt(void *handle, bool mask,
{
	return -ENODEV;
}
static inline int glink_wait_link_down(void *handle)
{
	return -ENODEV;
}

#endif /* CONFIG_MSM_GLINK */