Skip to contentSkip to conversation

serial: Drivers for Altera UARTs

PATCH In review Tobias Klauser 4 participants 10 messages May 5, 2010 – May 6, 2010

Subsystems (2)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH v5 1/2 serial: Add driver for the Altera JTAG UART

In reply to Tobias Klauser

Add an UART driver for the JTAG UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.

---
 drivers/serial/Kconfig           |   21 ++
 drivers/serial/Makefile          |    1 +
 drivers/serial/altera_jtaguart.c |  504 ++++++++++++++++++++++++++++++++++++++
 include/linux/altera_jtaguart.h  |   16 ++
 include/linux/serial_core.h      |    3 +
 5 files changed, 545 insertions(+), 0 deletions(-)
 create mode 100644 drivers/serial/altera_jtaguart.c
 create mode 100644 include/linux/altera_jtaguart.h
drivers/serial/Kconfig +21 -0
index 9c2e743..2a36f3f 100644
@@ -1530,4 +1530,25 @@ config SERIAL_GRLIB_GAISLER_APBUART_CONSOLE
 	help
 	Support for running a console on the GRLIB APBUART
 
+config SERIAL_ALTERA_JTAGUART
+	tristate "Altera JTAG UART support"
+	select SERIAL_CORE
+	help
+	  This driver supports the Altera JTAG UART port.
+
+config SERIAL_ALTERA_JTAGUART_CONSOLE
+	bool "Altera JTAG UART console support"
+	depends on SERIAL_ALTERA_JTAGUART=y
+	select SERIAL_CORE_CONSOLE
+	help
+	  Enable a Altera JTAG UART port to be the system console.
+
+config SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS
+	bool "Bypass output when no connection"
+	depends on SERIAL_ALTERA_JTAGUART_CONSOLE
+	select SERIAL_CORE_CONSOLE
+	help
+	  Bypass console output and keep going even if there is no
+	  JTAG terminal connection with the host.
+
 endmenu
drivers/serial/Makefile +1 -0
index 6aa4723..a4b748f 100644
@@ -83,3 +83,4 @@ obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
 obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
 obj-$(CONFIG_SERIAL_TIMBERDALE)	+= timbuart.o
 obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o
+obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
drivers/serial/altera_jtaguart.c new file +504 -0

504 lines not on this page · raw message

include/linux/altera_jtaguart.h new file +16 -0
new file mode 100644
index 0000000..953b178
@@ -0,0 +1,16 @@
+/*
+ * altera_jtaguart.h -- Altera JTAG UART driver defines.
+ */
+
+#ifndef	__ALTJUART_H
+#define	__ALTJUART_H
+
+#define ALTERA_JTAGUART_MAJOR	204
+#define ALTERA_JTAGUART_MINOR	186
+
+struct altera_jtaguart_platform_uart {
+	unsigned long mapbase;	/* Physical address base */
+	unsigned int irq;	/* Interrupt vector */
+};
+
+#endif /* __ALTJUART_H */
include/linux/serial_core.h +3 -0
index ad83996..308863a 100644
@@ -182,6 +182,9 @@
 /* Aeroflex Gaisler GRLIB APBUART */
 #define PORT_APBUART    90
 
+/* Altera UARTs */
+#define PORT_ALTERA_JTAGUART	91
+
 #ifdef __KERNEL__
 
 #include <linux/compiler.h>
Signature · 1 line
1.6.3.3
author maintainer
#2 lore raw

PATCH v5 2/2 serial: Add driver for the Altera UART

Add an UART driver for the UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.

---
 drivers/serial/Kconfig       |   31 +++
 drivers/serial/Makefile      |    1 +
 drivers/serial/altera_uart.c |  570 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/altera_uart.h  |   14 +
 include/linux/serial_core.h  |    1 +
 5 files changed, 617 insertions(+), 0 deletions(-)
 create mode 100644 drivers/serial/altera_uart.c
 create mode 100644 include/linux/altera_uart.h
drivers/serial/Kconfig +31 -0
index 2a36f3f..f88fb97 100644
@@ -1551,4 +1551,35 @@ config SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS
 	  Bypass console output and keep going even if there is no
 	  JTAG terminal connection with the host.
 
+config SERIAL_ALTERA_UART
+	tristate "Altera UART support"
+	select SERIAL_CORE
+	help
+	  This driver supports the Altera softcore UART port.
+
+config SERIAL_ALTERA_UART_MAXPORTS
+	int "Maximum number of Altera UART ports"
+	depends on SERIAL_ALTERA_UART
+	default 4
+	help
+	  This setting lets you define the maximum number of the Altera
+	  UART ports. The usual default varies from board to board, and
+	  this setting is a way of catering for that.
+
+config SERIAL_ALTERA_UART_BAUDRATE
+	int "Default baudrate for Altera UART ports"
+	depends on SERIAL_ALTERA_UART
+	default 115200
+	help
+	  This setting lets you define what the default baudrate is for the
+	  Altera UART ports. The usual default varies from board to board,
+	  and this setting is a way of catering for that.
+
+config SERIAL_ALTERA_UART_CONSOLE
+	bool "Altera UART console support"
+	depends on SERIAL_ALTERA_UART=y
+	select SERIAL_CORE_CONSOLE
+	help
+	  Enable a Altera UART port to be the system console.
+
 endmenu
drivers/serial/Makefile +1 -0
index a4b748f..733a19a 100644
@@ -84,3 +84,4 @@ obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
 obj-$(CONFIG_SERIAL_TIMBERDALE)	+= timbuart.o
 obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o
 obj-$(CONFIG_SERIAL_ALTERA_JTAGUART) += altera_jtaguart.o
+obj-$(CONFIG_SERIAL_ALTERA_UART) += altera_uart.o
drivers/serial/altera_uart.c new file +570 -0

570 lines not on this page · raw message

include/linux/altera_uart.h new file +14 -0
new file mode 100644
index 0000000..8d44106
@@ -0,0 +1,14 @@
+/*
+ * altera_uart.h -- Altera UART driver defines.
+ */
+
+#ifndef	__ALTUART_H
+#define	__ALTUART_H
+
+struct altera_uart_platform_uart {
+	unsigned long mapbase;	/* Physical address base */
+	unsigned int irq;	/* Interrupt vector */
+	unsigned int uartclk;	/* UART clock rate */
+};
+
+#endif /* __ALTUART_H */
include/linux/serial_core.h +1 -0
index 308863a..f10db6e 100644
@@ -184,6 +184,7 @@
 
 /* Altera UARTs */
 #define PORT_ALTERA_JTAGUART	91
+#define PORT_ALTERA_UART	92
 
 #ifdef __KERNEL__
 
Signature · 1 line
1.6.3.3

Tobias Klauser

author maintainer
#0 lore raw

v5 cover serial: Drivers for Altera UARTs

This is the fifth version of the patchset to add the serial drivers for the Altera UARTs. The following changes were made on top of the fourth version submitted on 30 Mar 2010:

- Fix Kconfig so altera_uart and altera_jtaguart can be properly built as modules. Add dependecy SERIAL_ALTERA_JTAGUART=y (instead of just SERIAL_ALTERA_JTAGUART) to SERIAL_ALTERA_JTAGUART_CONSOLE to prevent build failure when building as module (accordingly for the altera_uart driver). Thanks to Stephen Rothwell for the help with this.

Tobias Klauser (2):
serial: Add driver for the Altera JTAG UART
serial: Add driver for the Altera UART

 drivers/serial/Kconfig           |   52 ++++
 drivers/serial/Makefile          |    2 +
 drivers/serial/altera_jtaguart.c |  504 +++++++++++++++++++++++++++++++++
 drivers/serial/altera_uart.c     |  570 ++++++++++++++++++++++++++++++++++++++
 include/linux/altera_jtaguart.h  |   16 +
 include/linux/altera_uart.h      |   14 +
 include/linux/serial_core.h      |    4 +
 7 files changed, 1162 insertions(+), 0 deletions(-)
 create mode 100644 drivers/serial/altera_jtaguart.c
 create mode 100644 drivers/serial/altera_uart.c
 create mode 100644 include/linux/altera_jtaguart.h
 create mode 100644 include/linux/altera_uart.h
#3 lore raw

Re: [Nios2-dev] [PATCH 2/2] serial: Add driver for the Altera UART

In reply to Tobias Klauser
Quoted 2 lines · Tobias Klauser

Add an UART driver for the UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.

[...]

Quoted 22 lines
drivers/serial/altera_uart.c new file +22 -0
+static void altera_uart_start_tx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void altera_uart_stop_tx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+

drivers/serial/altera_uart.c line 151

Quoted 10 lines
drivers/serial/altera_uart.c new file +10 -0
+static void altera_uart_stop_rx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}

Those four functions shouldn't grab port->lock because the caller in serial_core.c grabs it before calling them.

drivers/serial/altera_uart.c line 280

Quoted 13 lines
drivers/serial/altera_uart.c new file +13 -0
+static irqreturn_t altera_uart_interrupt(int irq, void *data)
+{
+       struct uart_port *port = data;
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned int isr;
+
+       isr = readl(port->membase + ALTERA_UART_STATUS_REG) & pp->imr;
+       if (isr & ALTERA_UART_STATUS_RRDY_MSK)
+               altera_uart_rx_chars(pp);
+       if (isr & ALTERA_UART_STATUS_TRDY_MSK)
+               altera_uart_tx_chars(pp);
+       return IRQ_RETVAL(isr);
+}

Either the interrupt routine should grab port->lock (see equivalent function in altera_jtaguart.c for an example), or this could be done lower down in altera_uart_rx_chars() and altera_uart_tx_chars(). (It's less messing about to do it here in the interrupt routine though.)

Quoted 7 lines
drivers/serial/altera_uart.c new file +7 -0
+static void altera_uart_console_putc(struct console *co, const char c)
+{
+       struct uart_port *port = &(altera_uart_ports + co->index)->port;
+       int i;
+
+       for (i = 0; i < 0x10000; i++) {
+               if (readl(port->membase + ALTERA_UART_STATUS_REG) &

drivers/serial/altera_uart.c line 421

Quoted 10 lines
drivers/serial/altera_uart.c new file +10 -0
+                   ALTERA_UART_STATUS_TRDY_MSK)
+                       break;
+       }
+       writel(c, port->membase + ALTERA_UART_TXDATA_REG);
+       for (i = 0; i < 0x10000; i++) {
+               if (readl(port->membase + ALTERA_UART_STATUS_REG) &
+                   ALTERA_UART_STATUS_TRDY_MSK)
+                       break;
+       }
+}

I'd suggest calling udelay(1) in each iteration of the loop. Perhaps the second loop is overkill.

I was also going to suggest using the port->lock spin lock, but I'm not sure about the policy regarding that for console output (the 8250 driver console output doesn't use the spin lock for example).

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
#8 lore raw

Re: [Nios2-dev] [PATCH 1/2] serial: Add driver for the Altera JTAG UART

In reply to Tobias Klauser
Quoted 4 lines · Tobias Klauser

Add an UART driver for the JTAG UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.

[...]

Quoted 28 lines
drivers/serial/altera_jtaguart.c new file +28 -0
+#if defined(CONFIG_SERIAL_ALTERA_JTAGUART_CONSOLE_BYPASS)
+static void altera_jtaguart_console_putc(struct console *co, const char c)
+{
+       struct uart_port *port = &(altera_jtaguart_ports + co->index)->port;
+       unsigned long status;
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       while (((status = readl(port->membase + ALTERA_JTAGUART_CONTROL_REG)) &
+               ALTERA_JTAGUART_CONTROL_WSPACE_MSK) == 0) {
+               if ((status & ALTERA_JTAGUART_CONTROL_AC_MSK) == 0) {
+                       spin_unlock_irqrestore(&port->lock, flags);
+                       return; /* no connection activity */
+               }
+               spin_unlock_irqrestore(&port->lock, flags);
+               cpu_relax();
+               spin_lock_irqsave(&port->lock, flags);
+       }
+       writel(c, port->membase + ALTERA_JTAGUART_DATA_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+#else
+static void altera_jtaguart_console_putc(struct console *co, const char c)
+{
+       struct uart_port *port = &(altera_jtaguart_ports + co->index)->port;
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);

drivers/serial/altera_jtaguart.c line 367

Quoted 10 lines
drivers/serial/altera_jtaguart.c new file +10 -0
+       while ((readl(port->membase + ALTERA_JTAGUART_CONTROL_REG) &
+               ALTERA_JTAGUART_CONTROL_WSPACE_MSK) == 0) {
+               spin_unlock_irqrestore(&port->lock, flags);
+               cpu_relax();
+               spin_lock_irqsave(&port->lock, flags);
+       }
+       writel(c, port->membase + ALTERA_JTAGUART_DATA_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+#endif

I was originally responsible for adding the spin locks to these console putc functions, but I'm not sure what the policy is regarding that, as the 8250 driver doesn't use them for console output for example.

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
#4 lore raw

Re: [Nios2-dev] [PATCH 2/2] serial: Add driver for the Altera UART

In reply to Ian Abbott
Quoted 32 lines · Ian Abbott
Quoted 2 lines · Tobias Klauser

Add an UART driver for the UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.

[...]

Quoted 27 lines
drivers/serial/altera_uart.c new file +27 -0
+static void altera_uart_start_tx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void altera_uart_stop_tx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void altera_uart_stop_rx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
Quoted 8 lines

drivers/serial/altera_uart.c line 151

Quoted 5 lines
drivers/serial/altera_uart.c new file +5 -0
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}

Those four functions shouldn't grab port->lock because the caller in serial_core.c grabs it before calling them.

Oh, and that also applies to altera_uart_set_mctrl() - the caller grabs port->lock before calling it.

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
#9 lore raw

Re: [Nios2-dev] [PATCH 1/2] serial: Add driver for the Altera JTAG UART

In reply to Ian Abbott
Quoted 3 lines

I was originally responsible for adding the spin locks to these console putc functions, but I'm not sure what the policy is regarding that, as the 8250 driver doesn't use them for console output for example.

For the console it depends if you need them for internal consistency as I understand the codebase. For the core stuff it currently protects port->port.tty against a hangup which would drop the tty under you.

#5 lore raw

Re: [Nios2-dev] [PATCH 2/2] serial: Add driver for the Altera UART

In reply to Ian Abbott
Quoted 6 lines · Ian Abbott
Quoted 2 lines · Ian Abbott

Those four functions shouldn't grab port->lock because the caller in serial_core.c grabs it before calling them.

Oh, and that also applies to altera_uart_set_mctrl() - the caller grabs port->lock before calling it.

And altera_uart_get_mctrl().

(And for completeness, altera_uart_enable_ms() but the current implementation doesn't grab it anyway as it's just an empty function.)

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
#6 lore raw

Re: [Nios2-dev] [PATCH 2/2] serial: Add driver for the Altera UART

In reply to Ian Abbott

Hi Ian,

Thanks a lot for your review. Please see my notes below.

Quoted 32 lines · Ian Abbott
Quoted 2 lines · Tobias Klauser

Add an UART driver for the UART component available as a SOPC (System on Programmable Chip) component for Altera FPGAs.

[...]

Quoted 27 lines
drivers/serial/altera_uart.c new file +27 -0
+static void altera_uart_start_tx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void altera_uart_stop_tx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void altera_uart_stop_rx(struct uart_port *port)
+{
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned long flags;
+
Quoted 8 lines

drivers/serial/altera_uart.c line 151

Quoted 5 lines
drivers/serial/altera_uart.c new file +5 -0
+       spin_lock_irqsave(&port->lock, flags);
+       pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK;
+       writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG);
+       spin_unlock_irqrestore(&port->lock, flags);
+}

Those four functions shouldn't grab port->lock because the caller in serial_core.c grabs it before calling them.

Agreed, I removed the lock grabbing from altera_uart_stop_rx, altera_uart_stop_tx, altera_uart_start_tx, altera_uart_set_mctrl and altera_uart_get_mctrl (as suggested in the original message and the two followups).

I also noticed, that altera_uart_break_ctl takes the lock which might be not necessary as the caller in serial_core.c already takes port->mutex which should be enough. Or am I wrong?

Quoted 10 lines
Quoted 10 lines
drivers/serial/altera_uart.c new file +10 -0
+static irqreturn_t altera_uart_interrupt(int irq, void *data)
+{
+       struct uart_port *port = data;
+       struct altera_uart *pp = container_of(port, struct altera_uart, port);
+       unsigned int isr;
+
+       isr = readl(port->membase + ALTERA_UART_STATUS_REG) & pp->imr;
+       if (isr & ALTERA_UART_STATUS_RRDY_MSK)
+               altera_uart_rx_chars(pp);
+       if (isr & ALTERA_UART_STATUS_TRDY_MSK)
Quoted 8 lines

drivers/serial/altera_uart.c line 280

Quoted 3 lines
drivers/serial/altera_uart.c new file +3 -0
+               altera_uart_tx_chars(pp);
+       return IRQ_RETVAL(isr);
+}

Either the interrupt routine should grab port->lock (see equivalent function in altera_jtaguart.c for an example), or this could be done lower down in altera_uart_rx_chars() and altera_uart_tx_chars(). (It's less messing about to do it here in the interrupt routine though.)

I added the lock to the interrupt routine (similar to altera_jtaguart.c).

Quoted 12 lines
Quoted 12 lines
drivers/serial/altera_uart.c new file +12 -0
+static void altera_uart_console_putc(struct console *co, const char c)
+{
+       struct uart_port *port = &(altera_uart_ports + co->index)->port;
+       int i;
+
+       for (i = 0; i < 0x10000; i++) {
+               if (readl(port->membase + ALTERA_UART_STATUS_REG) &
+                   ALTERA_UART_STATUS_TRDY_MSK)
+                       break;
+       }
+       writel(c, port->membase + ALTERA_UART_TXDATA_REG);
+       for (i = 0; i < 0x10000; i++) {
Quoted 8 lines

drivers/serial/altera_uart.c line 420

Quoted 5 lines
drivers/serial/altera_uart.c new file +5 -0
+               if (readl(port->membase + ALTERA_UART_STATUS_REG) &
+                   ALTERA_UART_STATUS_TRDY_MSK)
+                       break;
+       }
+}

I'd suggest calling udelay(1) in each iteration of the loop. Perhaps the second loop is overkill.

Those seem to come from mcf.c on which this driver was based. I added the udelay to the first loop and dropped the second loop which indeed isn't needed here. I also replace the first loop with the equivalent construct from altera_uart_tx_chars.

Quoted 3 lines

I was also going to suggest using the port->lock spin lock, but I'm not sure about the policy regarding that for console output (the 8250 driver console output doesn't use the spin lock for example).

As I understood from Alan's comment on altera_jtaguart.c the lock is needed to protect port->port.tty so I'll add it in altera_uart.c too.

Cheers,
Tobias

#7 lore raw

Re: [Nios2-dev] [PATCH 2/2] serial: Add driver for the Altera UART

Hi Tobias,

Quoted 3 lines · Tobias Klauser

I also noticed, that altera_uart_break_ctl takes the lock which might be not necessary as the caller in serial_core.c already takes port->mutex which should be enough. Or am I wrong?

It's not enough. The spin lock is needed to protect modification of pp->imr and writing this modified value to the control register. Not all paths that modify pp->imr and the control register grab port->mutex beforehand (for example, the interrupt routine doesn't and can't).

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-