Skip to contentSkip to conversation

Misc OMAP GPIO/UART fixes

PATCH RESEND Superseded Judith Mendez 5 participants 11 messages Oct 11, 2024 – Oct 17, 2024 1 message not in the archive

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Misc OMAP GPIO/UART fixes

This patch series carries some miscellaneous OMAP driver fixes for GPIO and UART drivers.

For GPIO, add gpio_enable and gpio_disable calls to gpio-omap which fixes an issue where if there is an irq storm, serial console is unresponsive.

For UART, move pm_runtime_get_sync since the current order of omap_8250_rx_dma_flush and pm_runtime_get_sync calls are set in a way that when omap_8250_shutdown returns, dma->rx_running is set and this causes issues next time the UART is re-opened.

Changes since v1:
- Fix CC list
- Drop Fixes tag

Judith Mendez (2):
gpio: omap: Add omap_gpio_disable/enable_irq calls
serial: 8250: omap: Move pm_runtime_get_sync

 drivers/gpio/gpio-omap.c            | 29 +++++++++++++++++++++++++++++
 drivers/tty/serial/8250/8250_omap.c |  4 ++--
 2 files changed, 31 insertions(+), 2 deletions(-)

base-commit: f45840d172a06d07a1a408b38bdb0be9ab3fd8cb

Signature · 1 line
2.47.0
#1 lore raw

PATCH RESEND 1/2 gpio: omap: Add omap_gpio_disable/enable_irq calls

Add omap_gpio_disable_irq and omap_gpio_enable_irq calls in gpio-omap.

Currently, kernel cannot disable gpio interrupts in case of a irq storm, so add omap_gpio_disable_irq so that interrupts can be disabled/enabled.

---
 drivers/gpio/gpio-omap.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/gpio/gpio-omap.c +29 -0
index 76d5d87e9681..913e6ece1238 100644
@@ -711,6 +711,31 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
 	raw_spin_unlock_irqrestore(&bank->lock, flags);
 }
 
+static void omap_gpio_set_irq(struct irq_data *d, bool enable)
+{
+	struct gpio_bank *bank = omap_irq_data_get_bank(d);
+	unsigned int offset = d->hwirq;
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&bank->lock, flags);
+	omap_set_gpio_irqenable(bank, offset, enable);
+	raw_spin_unlock_irqrestore(&bank->lock, flags);
+}
+
+static void omap_gpio_disable_irq(struct irq_data *d)
+{
+	bool enable = 1;
+
+	omap_gpio_set_irq(d, !enable);
+}
+
+static void omap_gpio_enable_irq(struct irq_data *d)
+{
+	bool enable = 1;
+
+	omap_gpio_set_irq(d, enable);
+}
+
 static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
 {
 	struct gpio_bank *bank = omap_irq_data_get_bank(d);
@@ -723,6 +748,8 @@ static const struct irq_chip omap_gpio_irq_chip = {
 	.irq_shutdown = omap_gpio_irq_shutdown,
 	.irq_mask = omap_gpio_mask_irq,
 	.irq_unmask = omap_gpio_unmask_irq,
+	.irq_disable = omap_gpio_disable_irq,
+	.irq_enable = omap_gpio_enable_irq,
 	.irq_set_type = omap_gpio_irq_type,
 	.irq_set_wake = omap_gpio_wake_enable,
 	.irq_bus_lock = omap_gpio_irq_bus_lock,
@@ -737,6 +764,8 @@ static const struct irq_chip omap_gpio_irq_chip_nowake = {
 	.irq_shutdown = omap_gpio_irq_shutdown,
 	.irq_mask = omap_gpio_mask_irq,
 	.irq_unmask = omap_gpio_unmask_irq,
+	.irq_disable = omap_gpio_disable_irq,
+	.irq_enable = omap_gpio_enable_irq,
 	.irq_set_type = omap_gpio_irq_type,
 	.irq_bus_lock = omap_gpio_irq_bus_lock,
 	.irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
Signature · 1 line
2.47.0
#2 lore raw

Re: [PATCH RESEND 1/2] gpio: omap: Add omap_gpio_disable/enable_irq calls

Quoted 27 lines · Judith Mendez

Add omap_gpio_disable_irq and omap_gpio_enable_irq calls in gpio-omap.

Currently, kernel cannot disable gpio interrupts in case of a irq storm, so add omap_gpio_disable_irq so that interrupts can be disabled/enabled.

---
  drivers/gpio/gpio-omap.c | 29 +++++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)
drivers/gpio/gpio-omap.c +6 -0
index 76d5d87e9681..913e6ece1238 100644
@@ -711,6 +711,31 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
  	raw_spin_unlock_irqrestore(&bank->lock, flags);
  }
 
+static void omap_gpio_set_irq(struct irq_data *d, bool enable)
+{
+	struct gpio_bank *bank = omap_irq_data_get_bank(d);
+	unsigned int offset = d->hwirq;
+	unsigned long flags;
+

drivers/gpio/gpio-omap.c static void omap_gpio_unmask_irq(struct irq_data *d) · line 729

Quoted 10 lines
drivers/gpio/gpio-omap.c +10 -0
+	raw_spin_lock_irqsave(&bank->lock, flags);
+	omap_set_gpio_irqenable(bank, offset, enable);
+	raw_spin_unlock_irqrestore(&bank->lock, flags);
+}
+
+static void omap_gpio_disable_irq(struct irq_data *d)
+{
+	bool enable = 1;
+
+	omap_gpio_set_irq(d, !enable);

Seems like an odd way to make "false", why not:

omap_gpio_set_irq(d, false);

Andrew

Quoted 30 lines
drivers/gpio/gpio-omap.c +13 -0
+}
+
+static void omap_gpio_enable_irq(struct irq_data *d)
+{
+	bool enable = 1;
+
+	omap_gpio_set_irq(d, enable);
+}
+
  static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
  {
  	struct gpio_bank *bank = omap_irq_data_get_bank(d);
@@ -723,6 +748,8 @@ static const struct irq_chip omap_gpio_irq_chip = {
  	.irq_shutdown = omap_gpio_irq_shutdown,
  	.irq_mask = omap_gpio_mask_irq,
  	.irq_unmask = omap_gpio_unmask_irq,
+	.irq_disable = omap_gpio_disable_irq,
+	.irq_enable = omap_gpio_enable_irq,
  	.irq_set_type = omap_gpio_irq_type,
  	.irq_set_wake = omap_gpio_wake_enable,
  	.irq_bus_lock = omap_gpio_irq_bus_lock,
@@ -737,6 +764,8 @@ static const struct irq_chip omap_gpio_irq_chip_nowake = {
  	.irq_shutdown = omap_gpio_irq_shutdown,
  	.irq_mask = omap_gpio_mask_irq,
  	.irq_unmask = omap_gpio_unmask_irq,
+	.irq_disable = omap_gpio_disable_irq,
+	.irq_enable = omap_gpio_enable_irq,
  	.irq_set_type = omap_gpio_irq_type,
  	.irq_bus_lock = omap_gpio_irq_bus_lock,
  	.irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,
#3 lore raw

Re: [PATCH RESEND 1/2] gpio: omap: Add omap_gpio_disable/enable_irq calls

Hi Andrew,

Quoted 40 lines · Andrew Davis
Quoted 26 lines · Judith Mendez

Add omap_gpio_disable_irq and omap_gpio_enable_irq calls in gpio-omap.

Currently, kernel cannot disable gpio interrupts in case of a irq storm, so add omap_gpio_disable_irq so that interrupts can be disabled/enabled.

---
  drivers/gpio/gpio-omap.c | 29 +++++++++++++++++++++++++++++

  1 file changed, 29 insertions(+)
drivers/gpio/gpio-omap.c +6 -0
index 76d5d87e9681..913e6ece1238 100644
@@ -711,6 +711,31 @@ static void omap_gpio_unmask_irq(struct irq_data *d)
       raw_spin_unlock_irqrestore(&bank->lock, flags);
   }
+static void omap_gpio_set_irq(struct irq_data *d, bool enable)
+{
+    struct gpio_bank *bank = omap_irq_data_get_bank(d);
+    unsigned int offset = d->hwirq;
+    unsigned long flags;
+

drivers/gpio/gpio-omap.c static void omap_gpio_unmask_irq(struct irq_data *d) · line 728

Quoted 10 lines
drivers/gpio/gpio-omap.c +10 -0
+    raw_spin_lock_irqsave(&bank->lock, flags);
+    omap_set_gpio_irqenable(bank, offset, enable);
+    raw_spin_unlock_irqrestore(&bank->lock, flags);
+}
+
+static void omap_gpio_disable_irq(struct irq_data *d)
+{
+    bool enable = 1;
+
+    omap_gpio_set_irq(d, !enable);

Seems like an odd way to make "false", why not:

Quoted 1 line

omap_gpio_set_irq(d, false);

Thanks for your review, you are right, but I will be reverting to the original patch format. Where we do not used wrappers function around omap_gpio_set_irq().

~ Judith

Quoted 34 lines

Andrew

Quoted 31 lines
drivers/gpio/gpio-omap.c +13 -0
+}
+
+static void omap_gpio_enable_irq(struct irq_data *d)
+{
+    bool enable = 1;
+
+    omap_gpio_set_irq(d, enable);
+}
+
   static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
   {
       struct gpio_bank *bank = omap_irq_data_get_bank(d);
@@ -723,6 +748,8 @@ static const struct irq_chip omap_gpio_irq_chip = {
       .irq_shutdown = omap_gpio_irq_shutdown,
       .irq_mask = omap_gpio_mask_irq,
       .irq_unmask = omap_gpio_unmask_irq,
+    .irq_disable = omap_gpio_disable_irq,
+    .irq_enable = omap_gpio_enable_irq,
       .irq_set_type = omap_gpio_irq_type,
       .irq_set_wake = omap_gpio_wake_enable,
       .irq_bus_lock = omap_gpio_irq_bus_lock,
@@ -737,6 +764,8 @@ static const struct irq_chip 
 omap_gpio_irq_chip_nowake = {
       .irq_shutdown = omap_gpio_irq_shutdown,
       .irq_mask = omap_gpio_mask_irq,
       .irq_unmask = omap_gpio_unmask_irq,
+    .irq_disable = omap_gpio_disable_irq,
+    .irq_enable = omap_gpio_enable_irq,
       .irq_set_type = omap_gpio_irq_type,
       .irq_bus_lock = omap_gpio_irq_bus_lock,

      .irq_bus_sync_unlock = gpio_irq_bus_sync_unlock,

#4 lore raw

PATCH RESEND 2/2 serial: 8250: omap: Move pm_runtime_get_sync

In reply to Judith Mendez

Currently in omap_8250_shutdown, the dma->rx_running flag is set to zero in omap_8250_rx_dma_flush. Next pm_runtime_get_sync is called, which is a runtime resume call stack which can re-set the flag. When the call omap_8250_shutdown returns, the flag is expected to be UN-SET, but this is not the case. This is causing issues the next time UART is re-opened and omap_8250_rx_dma is called. Fix by moving pm_runtime_get_sync before the omap_8250_rx_dma_flush.

---
 drivers/tty/serial/8250/8250_omap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_omap.c +2 -2
index 88b58f44e4e9..0dd68bdbfbcf 100644
@@ -776,12 +776,12 @@ static void omap_8250_shutdown(struct uart_port *port)
 	struct uart_8250_port *up = up_to_u8250p(port);
 	struct omap8250_priv *priv = port->private_data;
 
+	pm_runtime_get_sync(port->dev);
+
 	flush_work(&priv->qos_work);
 	if (up->dma)
 		omap_8250_rx_dma_flush(up);
 
-	pm_runtime_get_sync(port->dev);
-
 	serial_out(up, UART_OMAP_WER, 0);
 	if (priv->habit & UART_HAS_EFR2)
 		serial_out(up, UART_OMAP_EFR2, 0x0);
Signature · 1 line
2.47.0
maintainer Reviewed-by Tested-by on v1 2/2
#5 lore raw

Re: [PATCH RESEND 2/2] serial: 8250: omap: Move pm_runtime_get_sync

Quoted 10 lines · Judith Mendez

Currently in omap_8250_shutdown, the dma->rx_running flag is set to zero in omap_8250_rx_dma_flush. Next pm_runtime_get_sync is called, which is a runtime resume call stack which can re-set the flag. When the call omap_8250_shutdown returns, the flag is expected to be UN-SET, but this is not the case. This is causing issues the next time UART is re-opened and omap_8250_rx_dma is called. Fix by moving pm_runtime_get_sync before the omap_8250_rx_dma_flush.

Quoted 2 lines

Gave this a quick boot test on am335x-boneblack and am57xx-beagle-x15.

I realize that doesn't really test the DMA paths involved here, but at least it doesn't break basic boot to serial console, and the change looks coorect.

Thanks for sending a fix for this.

Kevin

maintainer
#6 lore raw

Re: [PATCH RESEND 2/2] serial: 8250: omap: Move pm_runtime_get_sync

In reply to Judith Mendez
Quoted 9 lines · Judith Mendez

Currently in omap_8250_shutdown, the dma->rx_running flag is set to zero in omap_8250_rx_dma_flush. Next pm_runtime_get_sync is called, which is a runtime resume call stack which can re-set the flag. When the call omap_8250_shutdown returns, the flag is expected to be UN-SET, but this is not the case. This is causing issues the next time UART is re-opened and omap_8250_rx_dma is called. Fix by moving pm_runtime_get_sync before the omap_8250_rx_dma_flush.

You can go to 72 columns :)

Quoted 2 lines

Wait, who wrote this, Bin? If so, there needs to be a "From:" line saying so.

What commit id does this fix? Do you want it backported to older kernels? Why mix two different subsystems in the same patch series, who is supposed to take it?

thanks,

greg k-h

#7 lore raw

Re: [PATCH RESEND 2/2] serial: 8250: omap: Move pm_runtime_get_sync

Hi Greg,

Quoted 11 lines · Greg KH
Quoted 9 lines · Judith Mendez

Currently in omap_8250_shutdown, the dma->rx_running flag is set to zero in omap_8250_rx_dma_flush. Next pm_runtime_get_sync is called, which is a runtime resume call stack which can re-set the flag. When the call omap_8250_shutdown returns, the flag is expected to be UN-SET, but this is not the case. This is causing issues the next time UART is re-opened and omap_8250_rx_dma is called. Fix by moving pm_runtime_get_sync before the omap_8250_rx_dma_flush.

Quoted 1 line

You can go to 72 columns :)

ok, will fix, thanks!

Quoted 6 lines
Quoted 3 lines

Wait, who wrote this, Bin? If so, there needs to be a "From:" line saying so.

I did not realize I could create a patch for someone, apologies, I will be sending v3 with correct "From:".

Quoted 4 lines

What commit id does this fix? Do you want it backported to older kernels? Why mix two different subsystems in the same patch series, who is supposed to take it?

I suppose it should be backported to older kernels so I will add back the fixes tag.

Apologies for sending two different subsystems in one series, I thought describing as "misc" would be good enough to mix the two, but I can separate the patches and respin. Thanks.

~ Judith

Quoted 4 lines

thanks,

greg k-h

#8 lore raw

Re: [PATCH RESEND 2/2] serial: 8250: omap: Move pm_runtime_get_sync

In reply to Judith Mendez

Am Fri, 11 Oct 2024 12:33:56 -0500
schrieb Judith Mendez <[email protected]>:

Quoted 10 lines

Currently in omap_8250_shutdown, the dma->rx_running flag is set to zero in omap_8250_rx_dma_flush. Next pm_runtime_get_sync is called, which is a runtime resume call stack which can re-set the flag. When the call omap_8250_shutdown returns, the flag is expected to be UN-SET, but this is not the case. This is causing issues the next time UART is re-opened and omap_8250_rx_dma is called. Fix by moving pm_runtime_get_sync before the omap_8250_rx_dma_flush.

Quoted 2 lines

Is this a theorectical problem or some real practical problem? So you are running a system with runtime pm enabled on serial console.
How did you come across this issue?
I could run the serial console/getty with runtime pm autosuspend enabled without issues all the years.

Regards,
Andreas

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Re: [PATCH RESEND 2/2] serial: 8250: omap: Move pm_runtime_get_sync

Am Sun, 13 Oct 2024 21:52:05 -0500
schrieb Bin Liu <[email protected]>:

Quoted 33 lines

Hi,

Somehow this email wasn’t cc’d to my company email account [email protected], so I am replying from my personal email which subscribed to the mailing list, and sorry if the formatting is wrong since I am writing this response on my phone.

Quoted 17 lines · Andreas Kemnade

Am Fri, 11 Oct 2024 12:33:56 -0500
schrieb Judith Mendez <[email protected]>:

Currently in omap_8250_shutdown, the dma->rx_running

Quoted 9 lines

flag is set to zero in omap_8250_rx_dma_flush. Next pm_runtime_get_sync is called, which is a runtime resume call stack which can re-set the flag. When the call omap_8250_shutdown returns, the flag is expected to be UN-SET, but this is not the case. This is causing issues the next time UART is re-opened and omap_8250_rx_dma is called. Fix by moving pm_runtime_get_sync before the omap_8250_rx_dma_flush.

Quoted 3 lines
Quoted 7 lines

Is this a theorectical problem or some real practical problem? So you are running a system with runtime pm enabled on serial console.
How did you come across this issue?
I could run the serial console/getty with runtime pm autosuspend enabled without issues all the years.

Quoted 7 lines

Yes this is a real issue reported on AM335x. Please see the report linked below.

PROCESSOR-SDK-AM335X: Possible bug in 8250_omap UART driver - Processors forum - Processors - TI E2E support forums e2e.ti.com

Thanks for information, so it looks like material for backporting. Maybe add the link in the description and add the cc stable and add back the fixes tag.

Regards,
Andreas

maintainer
#11 lore raw
In reply to Judith Mendez
Quoted 7 lines · Judith Mendez

This patch series carries some miscellaneous OMAP driver fixes for GPIO and UART drivers.

For GPIO, add gpio_enable and gpio_disable calls to gpio-omap which fixes an issue where if there is an irq storm, serial console is unresponsive.

Quoted 6 lines

For UART, move pm_runtime_get_sync since the current order of omap_8250_rx_dma_flush and pm_runtime_get_sync calls are set in a way that when omap_8250_shutdown returns, dma->rx_running is set and this causes issues next time the UART is re-opened.

Could you summarize which OMAP platforms this was tested on?

Thanks,

Kevin