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

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

Merge "serial: msm_geni_serial: Bailout from wait_for_transfers_inflight"

parents 5091ce20 c4314b02
Loading
Loading
Loading
Loading
+41 −6
Original line number Diff line number Diff line
@@ -531,16 +531,17 @@ static bool check_transfers_inflight(struct uart_port *uport)
	return xfer_on;
}

static void wait_for_transfers_inflight(struct uart_port *uport)
static int wait_for_transfers_inflight(struct uart_port *uport)
{
	int iter = 0;
	struct msm_geni_serial_port *port = GET_DEV_PORT(uport);
	unsigned int geni_status;
	u32 rx_len_in = 0;

	geni_status = geni_read_reg_nolog(uport->membase, SE_GENI_STATUS);
	/* Possible stop rx is called before this. */
	if (!(geni_status & S_GENI_CMD_ACTIVE))
		return;
		return 0;

	while (iter < WAIT_XFER_MAX_ITER) {
		if (check_transfers_inflight(uport)) {
@@ -552,9 +553,18 @@ static void wait_for_transfers_inflight(struct uart_port *uport)
		}
	}
	if (check_transfers_inflight(uport)) {
		rx_len_in =
			geni_read_reg_nolog(uport->membase, SE_DMA_RX_LEN_IN);
		if (rx_len_in) {
			IPC_LOG_MSG(port->ipc_log_misc,
				     "%s: Bailout rx_len_in is set\n",
				     __func__);
			return -EBUSY;
		}
		geni_se_dump_dbg_regs(&port->serial_rsc,
				uport->membase, port->ipc_log_misc);
	}
	return 0;
}

static int vote_clock_on(struct uart_port *uport)
@@ -581,6 +591,7 @@ static int vote_clock_off(struct uart_port *uport)
{
	struct msm_geni_serial_port *port = GET_DEV_PORT(uport);
	int usage_count;
	int ret = 0;

	if (!pm_runtime_enabled(uport->dev)) {
		dev_err(uport->dev, "RPM not available.Can't enable clocks\n");
@@ -594,7 +605,12 @@ static int vote_clock_off(struct uart_port *uport)
				__func__, port->ioctl_count);
		return -EPERM;
	}
	wait_for_transfers_inflight(uport);
	ret = wait_for_transfers_inflight(uport);
	if (ret)
		IPC_LOG_MSG(port->ipc_log_pwr,
			     "%s: wait_for_transfer_inflight return ret:%d\n",
			     __func__, ret);

	port->ioctl_count--;
	msm_geni_serial_power_off(uport);
	usage_count = atomic_read(&uport->dev->power.usage_count);
@@ -647,6 +663,7 @@ static int msm_geni_serial_ioctl(struct uart_port *uport, unsigned int cmd,
static void msm_geni_serial_break_ctl(struct uart_port *uport, int ctl)
{
	struct msm_geni_serial_port *port = GET_DEV_PORT(uport);
	int ret = 0;

	if (!uart_console(uport) && device_pending_suspend(uport)) {
		IPC_LOG_MSG(port->ipc_log_misc,
@@ -656,7 +673,12 @@ static void msm_geni_serial_break_ctl(struct uart_port *uport, int ctl)
	}

	if (ctl) {
		wait_for_transfers_inflight(uport);
		ret = wait_for_transfers_inflight(uport);
		if (ret)
			IPC_LOG_MSG(port->ipc_log_misc,
			     "%s: wait_for_transfer_inflight return ret:%d\n",
			     __func__, ret);

		geni_setup_m_cmd(uport->membase, UART_START_BREAK, 0);
	} else {
		geni_setup_m_cmd(uport->membase, UART_STOP_BREAK, 0);
@@ -2339,7 +2361,12 @@ static void msm_geni_serial_shutdown(struct uart_port *uport)
		disable_irq(uport->irq);
	} else {
		msm_geni_serial_power_on(uport);
		wait_for_transfers_inflight(uport);
		ret = wait_for_transfers_inflight(uport);
		if (ret)
			IPC_LOG_MSG(msm_port->ipc_log_misc,
			     "%s: wait_for_transfer_inflight return ret:%d\n",
			     __func__, ret);

		msm_geni_serial_stop_tx(uport);
	}

@@ -3532,7 +3559,15 @@ static int msm_geni_serial_runtime_suspend(struct device *dev)
	IPC_LOG_MSG(port->ipc_log_pwr, "%s: Start\n", __func__);
	/* Flow off from UART */
	msm_geni_serial_set_manual_flow(false, port);
	wait_for_transfers_inflight(&port->uport);
	ret = wait_for_transfers_inflight(&port->uport);
	if (ret) {
		IPC_LOG_MSG(port->ipc_log_pwr,
			     "%s: wait_for_transfer_inflight return ret:%d\n",
			     __func__, ret);
		/* Flow on from UART */
		msm_geni_serial_allow_rx(port);
		return -EBUSY;
	}
	/*
	 * Stop Rx.
	 * Disable Interrupt