Skip to contentSkip to conversation

linux-next: manual merge of the tty tree with the tty.current tree

DISCUSSION Stephen Rothwell 2 participants 3 messages Apr 19, 2024 – Apr 23, 2024 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hi all,

Today's linux-next merge of the tty tree got a conflict in:

drivers/tty/serial/serial_core.c

between commit:

9cf7ea2eeb74 ("serial: core: Clearing the circular buffer before NULLifying it")

from the tty.current tree and commits:

1788cf6a91d9 ("tty: serial: switch from circ_buf to kfifo") abcd8632f26b ("serial: core: Extract uart_alloc_xmit_buf() and uart_free_xmit_buf()")

from the tty tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Signature · 62 lines
Cheers,
Stephen Rothwell

diff --cc drivers/tty/serial/serial_core.c
index c476d884356d,b9d631037ff6..000000000000
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@@ -285,6 -273,53 +273,54 @@@ static int uart_alloc_xmit_buf(struct t
  		free_page(page);
  	}
  
+ 	return 0;
+ }
+ 
+ static void uart_free_xmit_buf(struct tty_port *port)
+ {
+ 	struct uart_state *state = container_of(port, struct uart_state, port);
+ 	struct uart_port *uport;
+ 	unsigned long flags;
+ 	char *xmit_buf;
+ 
+ 	/*
+ 	 * Do not free() the transmit buffer page under the port lock since
+ 	 * this can create various circular locking scenarios. For instance,
+ 	 * console driver may need to allocate/free a debug object, which
+ 	 * can end up in printk() recursion.
+ 	 */
+ 	uport = uart_port_lock(state, flags);
++	kfifo_reset(&state->port.xmit_fifo);
+ 	xmit_buf = port->xmit_buf;
+ 	port->xmit_buf = NULL;
+ 	INIT_KFIFO(port->xmit_fifo);
+ 	uart_port_unlock(uport, flags);
+ 
+ 	free_page((unsigned long)xmit_buf);
+ }
+ 
+ /*
+  * Startup the port.  This will be called once per open.  All calls
+  * will be serialised by the per-port mutex.
+  */
+ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
+ 			     bool init_hw)
+ {
+ 	struct uart_port *uport = uart_port_check(state);
+ 	int retval;
+ 
+ 	if (uport->type == PORT_UNKNOWN)
+ 		return 1;
+ 
+ 	/*
+ 	 * Make sure the device is in D0 state.
+ 	 */
+ 	uart_change_pm(state, UART_PM_STATE_ON);
+ 
+ 	retval = uart_alloc_xmit_buf(&state->port);
+ 	if (retval)
+ 		return retval;
+ 
  	retval = uport->ops->startup(uport);
  	if (retval == 0) {
  		if (uart_console(uport) && uport->cons->cflag) {
#1 lore raw
Quoted 15 lines · Stephen Rothwell

Hi all,

Today's linux-next merge of the tty tree got a conflict in:

drivers/tty/serial/serial_core.c

between commit:

9cf7ea2eeb74 ("serial: core: Clearing the circular buffer before NULLifying it")

from the tty.current tree and commits:

1788cf6a91d9 ("tty: serial: switch from circ_buf to kfifo") abcd8632f26b ("serial: core: Extract uart_alloc_xmit_buf() and uart_free_xmit_buf()")

Quoted 8 lines

from the tty tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Looks good, thanks!

greg k-h

#2 lore raw
In reply to Stephen Rothwell
Quoted 47 lines · Stephen Rothwell

Hi all,

Today's linux-next merge of the tty tree got a conflict in:

drivers/tty/serial/serial_core.c

between commit:

9cf7ea2eeb74 ("serial: core: Clearing the circular buffer before NULLifying it")

from the tty.current tree and commits:

1788cf6a91d9 ("tty: serial: switch from circ_buf to kfifo") abcd8632f26b ("serial: core: Extract uart_alloc_xmit_buf() and uart_free_xmit_buf()")

from the tty tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Signature · 2 lines
Cheers,
Stephen Rothwell
drivers/tty/serial/serial_core.c +11 -0
diff --cc drivers/tty/serial/serial_core.c
index c476d884356d,b9d631037ff6..000000000000
@@@ -285,6 -273,53 +273,54 @@@ static int uart_alloc_xmit_buf(struct t
  		free_page(page);
  	}
 
+ 	return 0;
+ }
+ 
+ static void uart_free_xmit_buf(struct tty_port *port)
+ {
+ 	struct uart_state *state = container_of(port, struct uart_state, port);
+ 	struct uart_port *uport;
+ 	unsigned long flags;
+ 	char *xmit_buf;
+ 
+ 	/*

drivers/tty/serial/serial_core.c

Quoted 10 lines
drivers/tty/serial/serial_core.c +10 -0
+ 	 * Do not free() the transmit buffer page under the port lock since
+ 	 * this can create various circular locking scenarios. For instance,
+ 	 * console driver may need to allocate/free a debug object, which
+ 	 * can end up in printk() recursion.
+ 	 */
+ 	uport = uart_port_lock(state, flags);
++	kfifo_reset(&state->port.xmit_fifo);
+ 	xmit_buf = port->xmit_buf;
+ 	port->xmit_buf = NULL;
+ 	INIT_KFIFO(port->xmit_fifo);

The INIT_KFIFO() call here does the same (same plus more) than the kfifo_reset() call does, so I'll just drop the kfifo_reset() here and all should be fine. I'll do this in my tree now, thanks.

greg k-h