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

Commit 2e111290 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: IPA : Tethering offload clean up on MHI PRIME"

parents 670bdb05 0a813325
Loading
Loading
Loading
Loading
+2 −40
Original line number Diff line number Diff line
@@ -2523,17 +2523,6 @@ int ipa_usb_xdci_disconnect(u32 ul_clnt_hdl, u32 dl_clnt_hdl,
		if (orig_state != IPA_USB_SUSPENDED) {
			spin_unlock_irqrestore(&ipa3_usb_ctx->state_lock,
				flags);

			/* Stop UL MHIP channel */
			if (ipa3_is_mhip_offload_enabled()) {
				result = ipa_mpm_mhip_ul_start_stop_data(
						MPM_MHIP_STOP, teth_prot);
				if (result) {
					IPA_USB_ERR("fail UL MHIP Data stop\n");
					goto bad_params;
				}
			}

			/* Stop UL channel */
			result = ipa3_xdci_disconnect(ul_clnt_hdl,
				true,
@@ -2738,21 +2727,12 @@ static int ipa3_usb_suspend_no_remote_wakeup(u32 ul_clnt_hdl, u32 dl_clnt_hdl,
	}

	if (!IPA3_USB_IS_TTYPE_DPL(ttype)) {
		/* Stop UL MHIP channel - enable HOLB */
		if (ipa3_is_mhip_offload_enabled()) {
			result = ipa_mpm_mhip_ul_start_stop_data(MPM_MHIP_STOP,
								teth_prot);
			if (result) {
				IPA_USB_ERR("fail UL MHIP Data stop\n");
				goto start_dl;
			}
		}
		/* Stop UL channel */
		result = ipa3_xdci_disconnect(ul_clnt_hdl, true,
			ipa3_usb_ctx->qmi_req_id);
		if (result) {
			IPA_USB_ERR("failed disconnect UL channel\n");
			goto start_mhip;
			goto start_dl;
		}
		ipa3_usb_ctx->qmi_req_id++;
	}
@@ -2796,10 +2776,6 @@ static int ipa3_usb_suspend_no_remote_wakeup(u32 ul_clnt_hdl, u32 dl_clnt_hdl,
start_ul:
	if (!IPA3_USB_IS_TTYPE_DPL(ttype))
		(void)ipa3_xdci_connect(ul_clnt_hdl);
start_mhip:
	if (ipa3_is_mhip_offload_enabled() && !IPA3_USB_IS_TTYPE_DPL(ttype))
		(void)ipa_mpm_mhip_ul_start_stop_data(MPM_MHIP_START,
							teth_prot);
start_dl:
	(void)ipa3_xdci_connect(dl_clnt_hdl);
fail_exit:
@@ -2962,19 +2938,10 @@ static int ipa3_usb_resume_no_remote_wakeup(u32 ul_clnt_hdl, u32 dl_clnt_hdl,

	/* Start MHIP channel */
	if (ipa3_is_mhip_offload_enabled()) {
		if (!IPA3_USB_IS_TTYPE_DPL(ttype)) {
			/* Start UL MHIP channel */
			result = ipa_mpm_mhip_ul_start_stop_data(MPM_MHIP_START,
								teth_prot);
			if (result) {
				IPA_USB_ERR("fail UL MHIP Data Start\n");
				goto stop_dl;
			}
		}
		result = ipa_mpm_mhip_xdci_pipe_enable(teth_prot);
		if (result) {
			IPA_USB_ERR("failed to enable MHIP pipe\n");
			goto stop_mhip_data;
			goto stop_dl;
		}
	}
	/* Change state to CONNECTED */
@@ -2988,11 +2955,6 @@ static int ipa3_usb_resume_no_remote_wakeup(u32 ul_clnt_hdl, u32 dl_clnt_hdl,
stop_mhip:
	if (ipa3_is_mhip_offload_enabled())
		(void)ipa_mpm_mhip_xdci_pipe_disable(teth_prot);
stop_mhip_data:
	/* Stop UL MHIP data */
	if (ipa3_is_mhip_offload_enabled() && !IPA3_USB_IS_TTYPE_DPL(ttype))
		(void)ipa_mpm_mhip_ul_start_stop_data(MPM_MHIP_STOP,
							teth_prot);
stop_dl:
	(void)ipa3_xdci_disconnect(dl_clnt_hdl, false, -1);
stop_ul:
+4 −16
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "ipa_defs.h"
#include <linux/mailbox_client.h>
#include <linux/mailbox/qmp.h>
#include <linux/rmnet_ipa_fd_ioctl.h>

#define IPA_DEV_NAME_MAX_LEN 15
#define DRV_NAME "ipa"
@@ -215,11 +216,6 @@ enum {
	NUM_SMEM_SUBSYSTEMS,
};

enum ipa_mpm_start_stop_type {
	MPM_MHIP_STOP,
	MPM_MHIP_START,
};

#define IPA_WDI_RX_RING_RES			0
#define IPA_WDI_RX_RING_RP_RES		1
#define IPA_WDI_RX_COMP_RING_RES	2
@@ -2987,10 +2983,7 @@ int ipa3_get_gsi_chan_info(struct gsi_chan_info *gsi_chan_info,
#ifdef CONFIG_IPA3_MHI_PRIME_MANAGER
int ipa_mpm_mhip_xdci_pipe_enable(enum ipa_usb_teth_prot prot);
int ipa_mpm_mhip_xdci_pipe_disable(enum ipa_usb_teth_prot xdci_teth_prot);
int ipa_mpm_notify_wan_state(void);
int ipa_mpm_mhip_ul_start_stop_data(
		enum ipa_mpm_start_stop_type start_stop,
		enum ipa_usb_teth_prot xdci_teth_prot);
int ipa_mpm_notify_wan_state(struct wan_ioctl_notify_wan_state *state);
int ipa3_is_mhip_offload_enabled(void);
int ipa_mpm_reset_dma_mode(enum ipa_client_type src_pipe,
	enum ipa_client_type dst_pipe);
@@ -3007,13 +3000,8 @@ static inline int ipa_mpm_mhip_xdci_pipe_disable(
{
	return 0;
}
static inline int ipa_mpm_notify_wan_state(void)
{
	return 0;
}
static inline int ipa_mpm_mhip_ul_start_stop_data(
		enum ipa_mpm_start_stop_type start_stop,
		enum ipa_usb_teth_prot xdci_teth_prot)
static inline int ipa_mpm_notify_wan_state(
	struct wan_ioctl_notify_wan_state *state)
{
	return 0;
}
+90 −94
Original line number Diff line number Diff line
@@ -126,6 +126,10 @@ enum mhip_smmu_domain_type {
	MHIP_SMMU_DOMAIN_NONE,
};

enum ipa_mpm_start_stop_type {
	MPM_MHIP_STOP,
	MPM_MHIP_START,
};
/* each pair of UL/DL channels are defined below */
static const struct mhi_device_id mhi_driver_match_table[] = {
	{ .chan = "IP_HW_MHIP_0" }, /* for rndis/Wifi teth pipes */
@@ -1545,15 +1549,17 @@ static enum mhip_status_type ipa_mpm_start_stop_mhip_chan(
	return MHIP_STATUS_FAIL;
}

int ipa_mpm_notify_wan_state(void)
int ipa_mpm_notify_wan_state(struct wan_ioctl_notify_wan_state *state)
{
	int probe_id = IPA_MPM_MHIP_CH_ID_MAX;
	int i;
	static enum mhip_status_type status;
	int ret = 0;
	enum ipa_client_type ul_chan, dl_chan;
	enum ipa_mpm_mhip_client_type mhip_client = IPA_MPM_MHIP_TETH;

	if (!state)
		return -EPERM;

	if (!ipa3_is_mhip_offload_enabled())
		return -EPERM;

@@ -1570,45 +1576,41 @@ int ipa_mpm_notify_wan_state(void)
	}

	IPA_MPM_DBG("WAN backhaul available for probe_id = %d\n", probe_id);
	get_ipa3_client(probe_id, &ul_chan, &dl_chan);

	/* Start UL MHIP channel for offloading the tethering connection */
	if (state->up) {
		/* Start UL MHIP channel for offloading tethering connection */
		ret = ipa_mpm_vote_unvote_pcie_clk(CLK_ON, probe_id);
		if (ret) {
		IPA_MPM_ERR("Error cloking on PCIe clk, err = %d\n", ret);
			IPA_MPM_ERR("Error cloking on PCIe clk, err = %d\n",
				ret);
			return ret;
		}

		status = ipa_mpm_start_stop_mhip_chan(
				IPA_MPM_MHIP_CHAN_UL, probe_id, MPM_MHIP_START);
		switch (status) {
		case MHIP_STATUS_SUCCESS:
	case MHIP_STATUS_NO_OP:
		ipa_mpm_change_teth_state(probe_id, IPA_MPM_TETH_CONNECTED);
		ret = ipa_mpm_start_stop_ul_mhip_data_path(probe_id,
							MPM_MHIP_START);

			ipa_mpm_ctx->md[probe_id].teth_state =
						IPA_MPM_TETH_CONNECTED;
			ret = ipa_mpm_start_stop_ul_mhip_data_path(
						probe_id, MPM_MHIP_START);
			if (ret) {
			IPA_MPM_ERR("Couldnt start UL GSI channel");
				IPA_MPM_ERR("err UL chan start\n");
				ipa_mpm_vote_unvote_pcie_clk(CLK_OFF, probe_id);
				return ret;
			}

		if (status == MHIP_STATUS_NO_OP) {
			/* Channels already have been started,
			 * we can devote for pcie clocks
			 */
			ipa_mpm_vote_unvote_pcie_clk(CLK_OFF, probe_id);
		}
			break;
		case MHIP_STATUS_EP_NOT_READY:
		ipa_mpm_change_teth_state(probe_id, IPA_MPM_TETH_INPROGRESS);
		break;
		case MHIP_STATUS_NO_OP:
			IPA_MPM_DBG("UL chan already start, status = %d\n",
					status);
			ret = ipa_mpm_vote_unvote_pcie_clk(CLK_OFF, probe_id);
			return ret;
		case MHIP_STATUS_FAIL:
		case MHIP_STATUS_BAD_STATE:
		case MHIP_STATUS_EP_NOT_FOUND:
		IPA_MPM_ERR("UL chan cant be started err =%d\n", status);
			IPA_MPM_ERR("UL chan start err =%d\n", status);
			ret = ipa_mpm_vote_unvote_pcie_clk(CLK_OFF, probe_id);
			ipa_assert();
			return -EFAULT;
		default:
			IPA_MPM_ERR("Err not found\n");
@@ -1616,7 +1618,43 @@ int ipa_mpm_notify_wan_state(void)
			ret = -EFAULT;
			break;
		}
		ipa_mpm_ctx->md[probe_id].mhip_client = mhip_client;
	} else {
		status = ipa_mpm_start_stop_mhip_chan(
					IPA_MPM_MHIP_CHAN_UL, probe_id,
					MPM_MHIP_STOP);
		switch (status) {
		case MHIP_STATUS_SUCCESS:
			ipa_mpm_change_teth_state(probe_id, IPA_MPM_TETH_INIT);
			ipa_mpm_start_stop_ul_mhip_data_path(probe_id,
							MPM_MHIP_STOP);
			break;
		case MHIP_STATUS_NO_OP:
		case MHIP_STATUS_EP_NOT_READY:
			IPA_MPM_DBG("UL chan already stop, status = %d\n",
					status);
			break;
		case MHIP_STATUS_FAIL:
		case MHIP_STATUS_BAD_STATE:
		case MHIP_STATUS_EP_NOT_FOUND:
			IPA_MPM_ERR("UL chan cant be stopped err =%d\n",
				status);
			ipa_assert();
			return -EFAULT;
		default:
			IPA_MPM_ERR("Err not found\n");
			return -EFAULT;
		}
		/* Stop UL MHIP channel for offloading tethering connection */
		ret = ipa_mpm_vote_unvote_pcie_clk(CLK_OFF, probe_id);

		if (ret) {
			IPA_MPM_ERR("Error cloking on PCIe clk, err = %d\n",
				ret);
			return ret;
		}
		ipa_mpm_ctx->md[probe_id].mhip_client = IPA_MPM_MHIP_NONE;
	}
	return ret;
}

@@ -2383,16 +2421,19 @@ int ipa_mpm_mhip_xdci_pipe_enable(enum ipa_usb_teth_prot xdci_teth_prot)
		ipa_mpm_set_dma_mode(IPA_CLIENT_USB_PROD,
			IPA_CLIENT_MHI_PRIME_RMNET_CONS);
		break;
	case IPA_MPM_MHIP_TETH:
		IPA_MPM_DBG("Teth for prot %d\n", mhip_client);
		return 0;
	case IPA_MPM_MHIP_USB_DPL:
		IPA_MPM_DBG("connecting DPL prot %d\n", mhip_client);
		ipa_mpm_change_teth_state(probe_id, IPA_MPM_TETH_CONNECTED);
		return 0;
	default:
		IPA_MPM_ERR("mhip_client = %d not supported\n", mhip_client);
		break;
		IPA_MPM_DBG("mhip_client = %d not processed\n", mhip_client);
		ret = ipa_mpm_vote_unvote_pcie_clk(CLK_OFF, probe_id);
		if (ret) {
			IPA_MPM_ERR("Error unvoting on PCIe clk, err = %d\n",
					ret);
			return ret;
		}
		return 0;
	}

	if (mhip_client != IPA_MPM_MHIP_USB_DPL)
@@ -2437,51 +2478,6 @@ int ipa_mpm_mhip_xdci_pipe_enable(enum ipa_usb_teth_prot xdci_teth_prot)
	return ret;
}

int ipa_mpm_mhip_ul_start_stop_data(enum ipa_mpm_start_stop_type start_stop,
	enum ipa_usb_teth_prot xdci_teth_prot)
{
	int probe_id = IPA_MPM_MHIP_CH_ID_MAX;
	int i;
	enum ipa_mpm_mhip_client_type mhip_client;
	int ret = 0;

	if (ipa_mpm_ctx == NULL) {
		IPA_MPM_ERR("MPM not platform probed, returning ..\n");
		return 0;
	}

	ipa_mpm_mhip_map_prot(xdci_teth_prot, &mhip_client);

	for (i = 0; i < IPA_MPM_MHIP_CH_ID_MAX; i++) {
		if (ipa_mpm_pipes[i].mhip_client == mhip_client) {
			probe_id = i;
			break;
		}
	}

	if (probe_id == IPA_MPM_MHIP_CH_ID_MAX) {
		IPA_MPM_ERR("Invalid probe_id\n");
		return 0;
	}

	IPA_MPM_DBG("Map xdci prot %d to mhip_client = %d probe_id = %d\n",
		xdci_teth_prot, mhip_client, probe_id);

	if (start_stop == MPM_MHIP_STOP) {
		ret = ipa_mpm_start_stop_ul_mhip_data_path(probe_id,
							MPM_MHIP_STOP);
		if (ret)
			IPA_MPM_ERR("Error stopping UL path, err = %d\n", ret);
	} else if (start_stop == MPM_MHIP_START) {
		ret = ipa_mpm_start_stop_ul_mhip_data_path(probe_id,
							MPM_MHIP_START);
		if (ret)
			IPA_MPM_ERR("Error starting UL path, err = %d\n", ret);
	}

	return ret;
}

int ipa_mpm_mhip_xdci_pipe_disable(enum ipa_usb_teth_prot xdci_teth_prot)
{
	int probe_id = IPA_MPM_MHIP_CH_ID_MAX;
@@ -2522,8 +2518,8 @@ int ipa_mpm_mhip_xdci_pipe_disable(enum ipa_usb_teth_prot xdci_teth_prot)
		}
		break;
	case IPA_MPM_MHIP_TETH:
		IPA_MPM_DBG("Teth Disconnecting for prot %d\n", mhip_client);
		break;
		IPA_MPM_DBG("Rndis Disconnect, wait for wan_state ioctl\n");
		return 0;
	case IPA_MPM_MHIP_USB_DPL:
		IPA_MPM_DBG("Teth Disconnecting for DPL\n");
		ipa_mpm_change_teth_state(probe_id, IPA_MPM_TETH_INIT);
+2 −1
Original line number Diff line number Diff line
@@ -382,7 +382,8 @@ static long ipa3_wan_ioctl(struct file *filp,
			break;
		}

		if (ipa_mpm_notify_wan_state()) {
		if (ipa_mpm_notify_wan_state(
			(struct wan_ioctl_notify_wan_state *)param)) {
			IPAWANERR("WAN_IOC_NOTIFY_WAN_STATE failed\n");
			retval = -EPERM;
		}