diff mbox series

[V3,2/2] tty: serial: qcom_geni_serial: Fix RX cancel command failure

Message ID 1583477228-32231-3-git-send-email-skakit@codeaurora.org (mailing list archive)
State Accepted
Commit 679aac5ead2f18d223554a52b543e1195e181811
Headers show
Series Fix RX cancel command failure | expand

Commit Message

Satya Priya March 6, 2020, 6:47 a.m. UTC
RX cancel command fails when BT is switched on and off multiple times.

To handle this, poll for the cancel bit in SE_GENI_S_IRQ_STATUS register
instead of SE_GENI_S_CMD_CTRL_REG.

As per the HPG update, handle the RX last bit after cancel command
and flush out the RX FIFO buffer.

Signed-off-by: satya priya <skakit@codeaurora.org>
---
 drivers/tty/serial/qcom_geni_serial.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

Comments

Stephen Boyd March 9, 2020, 6:41 a.m. UTC | #1
Quoting satya priya (2020-03-05 22:47:08)
> RX cancel command fails when BT is switched on and off multiple times.
> 
> To handle this, poll for the cancel bit in SE_GENI_S_IRQ_STATUS register
> instead of SE_GENI_S_CMD_CTRL_REG.
> 
> As per the HPG update, handle the RX last bit after cancel command
> and flush out the RX FIFO buffer.
> 
> Signed-off-by: satya priya <skakit@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Greg KH March 12, 2020, 9:10 a.m. UTC | #2
On Fri, Mar 06, 2020 at 12:17:08PM +0530, satya priya wrote:
> RX cancel command fails when BT is switched on and off multiple times.
> 
> To handle this, poll for the cancel bit in SE_GENI_S_IRQ_STATUS register
> instead of SE_GENI_S_CMD_CTRL_REG.
> 
> As per the HPG update, handle the RX last bit after cancel command
> and flush out the RX FIFO buffer.
> 
> Signed-off-by: satya priya <skakit@codeaurora.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> ---
>  drivers/tty/serial/qcom_geni_serial.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)

This patch didn't apply :(
Satya Priya March 13, 2020, 1:53 p.m. UTC | #3
On 2020-03-12 14:40, Greg KH wrote:
> On Fri, Mar 06, 2020 at 12:17:08PM +0530, satya priya wrote:
>> RX cancel command fails when BT is switched on and off multiple times.
>> 
>> To handle this, poll for the cancel bit in SE_GENI_S_IRQ_STATUS 
>> register
>> instead of SE_GENI_S_CMD_CTRL_REG.
>> 
>> As per the HPG update, handle the RX last bit after cancel command
>> and flush out the RX FIFO buffer.
>> 
>> Signed-off-by: satya priya <skakit@codeaurora.org>
>> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
>> ---
>>  drivers/tty/serial/qcom_geni_serial.c | 18 ++++++++++++++----
>>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> This patch didn't apply :(

V1 of this patch is already picked in tty-next tree(commit id: 
679aac5ead2f18d223554a52b543e1195e181811). There is no change in this 
patch from V1 to V3[2/2].
There is a crash reported by Stephen with V1, to resolve that we posted 
next versions adding this patch 
https://patchwork.kernel.org/patch/11423231/, that is, V3[1/2]. So now 
only V3[1/2] needs to be picked.
Greg KH March 14, 2020, 8:07 a.m. UTC | #4
On Fri, Mar 13, 2020 at 07:23:50PM +0530, skakit@codeaurora.org wrote:
> On 2020-03-12 14:40, Greg KH wrote:
> > On Fri, Mar 06, 2020 at 12:17:08PM +0530, satya priya wrote:
> > > RX cancel command fails when BT is switched on and off multiple times.
> > > 
> > > To handle this, poll for the cancel bit in SE_GENI_S_IRQ_STATUS
> > > register
> > > instead of SE_GENI_S_CMD_CTRL_REG.
> > > 
> > > As per the HPG update, handle the RX last bit after cancel command
> > > and flush out the RX FIFO buffer.
> > > 
> > > Signed-off-by: satya priya <skakit@codeaurora.org>
> > > Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> > > ---
> > >  drivers/tty/serial/qcom_geni_serial.c | 18 ++++++++++++++----
> > >  1 file changed, 14 insertions(+), 4 deletions(-)
> > 
> > This patch didn't apply :(
> 
> V1 of this patch is already picked in tty-next tree(commit id:
> 679aac5ead2f18d223554a52b543e1195e181811). There is no change in this patch
> from V1 to V3[2/2].
> There is a crash reported by Stephen with V1, to resolve that we posted next
> versions adding this patch https://patchwork.kernel.org/patch/11423231/,
> that is, V3[1/2]. So now only V3[1/2] needs to be picked.

Ok, and I picked that up already, right?

Please be kind to maintainers and make it obvious what you want them to
do...

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index f74f8a8..d5621b6 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -129,6 +129,7 @@  static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop);
 static int handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop);
 static unsigned int qcom_geni_serial_tx_empty(struct uart_port *port);
 static void qcom_geni_serial_stop_rx(struct uart_port *uport);
+static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop);
 
 static const unsigned long root_freq[] = {7372800, 14745600, 19200000, 29491200,
 					32000000, 48000000, 64000000, 80000000,
@@ -597,7 +598,7 @@  static void qcom_geni_serial_stop_rx(struct uart_port *uport)
 	u32 irq_en;
 	u32 status;
 	struct qcom_geni_serial_port *port = to_dev_port(uport, uport);
-	u32 irq_clear = S_CMD_DONE_EN;
+	u32 s_irq_status;
 
 	irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN);
 	irq_en &= ~(S_RX_FIFO_WATERMARK_EN | S_RX_FIFO_LAST_EN);
@@ -613,10 +614,19 @@  static void qcom_geni_serial_stop_rx(struct uart_port *uport)
 		return;
 
 	geni_se_cancel_s_cmd(&port->se);
-	qcom_geni_serial_poll_bit(uport, SE_GENI_S_CMD_CTRL_REG,
-					S_GENI_CMD_CANCEL, false);
+	qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS,
+					S_CMD_CANCEL_EN, true);
+	/*
+	 * If timeout occurs secondary engine remains active
+	 * and Abort sequence is executed.
+	 */
+	s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS);
+	/* Flush the Rx buffer */
+	if (s_irq_status & S_RX_FIFO_LAST_EN)
+		qcom_geni_serial_handle_rx(uport, true);
+	writel(s_irq_status, uport->membase + SE_GENI_S_IRQ_CLEAR);
+
 	status = readl(uport->membase + SE_GENI_STATUS);
-	writel(irq_clear, uport->membase + SE_GENI_S_IRQ_CLEAR);
 	if (status & S_GENI_CMD_ACTIVE)
 		qcom_geni_serial_abort_rx(uport);
 }