Skip to contentSkip to conversation

tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown()

PATCH Superseded Sherry Sun 3 participants 6 messages Nov 23, 2021 – Nov 24, 2021

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Sherry Sun

author
#0 lore raw

PATCH v2 1/1 tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown()

From: Fugang Duan <[email protected]>

Disable the UCR4_OREN bit in .stop_rx() before the uart receiver is disabled maybe better than in the .shutdown() function.

---
changes in V2:
- remove the UCR4_OREN clearing in imx_uart_shutdown as this is not needed any more.
- change the commit message.

---
 drivers/tty/serial/imx.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/serial/imx.c +5 -2
index fb75e3e0d828..df8a0c8b8b29 100644
@@ -486,18 +486,21 @@ static void imx_uart_stop_tx(struct uart_port *port)
 static void imx_uart_stop_rx(struct uart_port *port)
 {
 	struct imx_port *sport = (struct imx_port *)port;
-	u32 ucr1, ucr2;
+	u32 ucr1, ucr2, ucr4;
 
 	ucr1 = imx_uart_readl(sport, UCR1);
 	ucr2 = imx_uart_readl(sport, UCR2);
+	ucr4 = imx_uart_readl(sport, UCR4);
 
 	if (sport->dma_is_enabled) {
 		ucr1 &= ~(UCR1_RXDMAEN | UCR1_ATDMAEN);
 	} else {
 		ucr1 &= ~UCR1_RRDYEN;
 		ucr2 &= ~UCR2_ATEN;
+		ucr4 &= ~UCR4_OREN;
 	}
 	imx_uart_writel(sport, ucr1, UCR1);
+	imx_uart_writel(sport, ucr4, UCR4);
 
 	ucr2 &= ~UCR2_RXEN;
 	imx_uart_writel(sport, ucr2, UCR2);
@@ -1544,7 +1547,7 @@ static void imx_uart_shutdown(struct uart_port *port)
 	imx_uart_writel(sport, ucr1, UCR1);
 
 	ucr4 = imx_uart_readl(sport, UCR4);
-	ucr4 &= ~(UCR4_OREN | UCR4_TCEN);
+	ucr4 &= ~UCR4_TCEN;
 	imx_uart_writel(sport, ucr4, UCR4);
 
 	spin_unlock_irqrestore(&sport->port.lock, flags);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Sherry Sun

From: Fugang Duan <[email protected]>

Disable the UCR4_OREN bit in .stop_rx() before the uart receiver is disabled maybe better than in the .shutdown() function.

There should be a better incentive than "maybe it's better to do this". My expectation is that you verify there is indeed an issue and then fix that with a descriptive commit log that convinces this is indeed a fix.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
maintainer
#2 lore raw
In reply to Sherry Sun
Quoted 4 lines · Sherry Sun

From: Fugang Duan <[email protected]>

Disable the UCR4_OREN bit in .stop_rx() before the uart receiver is disabled maybe better than in the .shutdown() function.

Why is it better? What does this "fix"?

thanks,

greg k-h

author
#3 lore raw

Hi Greg,

Quoted 10 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: 2021年11月24日 17:59
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; dl-linux-imx <linux- [email protected]>
Subject: Re: [PATCH V2] tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown()

Quoted 7 lines
Quoted 4 lines · Sherry Sun

From: Fugang Duan <[email protected]>

Disable the UCR4_OREN bit in .stop_rx() before the uart receiver is disabled maybe better than in the .shutdown() function.

Why is it better? What does this "fix"?

Since I am not clear about the history of this patch, so I haven't found any obvious issues without this patch so far.

But after discussing with the IP owner, it is still recommended to disable the receiver-related interrupts like OREN before disabling the receiver.

If not, when we have the overrun error during the receiver disable process, the overrun interrupt will keep trigging until we disable the OREN interrupt in the .shutdown(), because the ORE status can only be cleared when read the rx FIFO or reset the controller. Although the called time between the receiver disable and OREN disable in .shutdown() is very short, there is still the risk of endless interrupt during this short period of time. So had better to disable OREN before the receiver been disabled in .stop_rx().

Best regards
Sherry

maintainer
#4 lore raw
Quoted 13 lines · Sherry Sun

Hi Greg,

Quoted 11 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: 2021年11月24日 17:59
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; dl-linux-imx <linux- [email protected]>
Subject: Re: [PATCH V2] tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown()

On Tue, Nov 23, 2021 at 06:51:22PM +0800, Sherry Sun wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

From: Fugang Duan <[email protected]>

Disable the UCR4_OREN bit in .stop_rx() before the uart receiver is disabled maybe better than in the .shutdown() function.

Why is it better? What does this "fix"?

Since I am not clear about the history of this patch, so I haven't found any obvious issues without this patch so far.

Then why submit it?

Quoted 1 line

But after discussing with the IP owner, it is still recommended to disable the receiver-related interrupts like OREN before disabling the receiver.

recommended by what? The hardware designers?

Quoted 1 line

If not, when we have the overrun error during the receiver disable process, the overrun interrupt will keep trigging until we disable the OREN interrupt in the .shutdown(), because the ORE status can only be cleared when read the rx FIFO or reset the controller. Although the called time between the receiver disable and OREN disable in .shutdown() is very short, there is still the risk of endless interrupt during this short period of time. So had better to disable OREN before the receiver been disabled in .stop_rx().

Please document this in the changelog, otherwise we have no idea why this is needed.

thanks,

greg k-h

author
#5 lore raw

Hi Greg,

Quoted 19 lines · Sherry Sun
Quoted 18 lines

Hi Greg,

Quoted 16 lines

-----Original Message-----
From: Greg KH <[email protected]>
Sent: 2021年11月24日 17:59
To: Sherry Sun <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; dl-linux-imx <linux- [email protected]>
Subject: Re: [PATCH V2] tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown()

Quoted 4 lines · Sherry Sun

From: Fugang Duan <[email protected]>

Disable the UCR4_OREN bit in .stop_rx() before the uart receiver is disabled maybe better than in the .shutdown() function.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Why is it better? What does this "fix"?

Since I am not clear about the history of this patch, so I haven't found any

obvious issues without this patch so far.

Then why submit it?

Because from the code logic, I think this patch is more reasonable.

Quoted 5 lines
Quoted 2 lines

But after discussing with the IP owner, it is still recommended to disable the

receiver-related interrupts like OREN before disabling the receiver.

recommended by what? The hardware designers?

Yes, the i.MX UART IP designer.

Quoted 11 lines
Quoted 2 lines

If not, when we have the overrun error during the receiver disable process,

the overrun interrupt will keep trigging until we disable the OREN interrupt in the .shutdown(), because the ORE status can only be cleared when read the rx FIFO or reset the controller. Although the called time between the receiver disable and OREN disable in .shutdown() is very short, there is still the risk of endless interrupt during this short period of time. So had better to disable OREN before the receiver been disabled in .stop_rx().

Please document this in the changelog, otherwise we have no idea why this is needed.

Sure, I will send V3 and add these info into the commit message. Thanks!

Best regards
Sherry