Skip to content

Commit 9635f14

Browse files
author
John W. Linville
committed
Revert "serial: 8250: Switch to nbcon console"
JIRA: https://issues.redhat.com/browse/RHEL-56242 This reverts commit b63e6f6. kernel test robot has found problems with this commit so revert it for now. Link: https://lore.kernel.org/r/[email protected] Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Cc: John Ogness <[email protected]> Cc: Petr Mladek <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit f79b163) Signed-off-by: John W. Linville <[email protected]>
1 parent 10e727d commit 9635f14

File tree

3 files changed

+3
-199
lines changed

3 files changed

+3
-199
lines changed

drivers/tty/serial/8250/8250_core.c

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -388,45 +388,13 @@ void __init serial8250_register_ports(struct uart_driver *drv, struct device *de
388388

389389
#ifdef CONFIG_SERIAL_8250_CONSOLE
390390

391-
#ifdef CONFIG_SERIAL_8250_LEGACY_CONSOLE
392391
static void univ8250_console_write(struct console *co, const char *s,
393392
unsigned int count)
394393
{
395394
struct uart_8250_port *up = &serial8250_ports[co->index];
396395

397396
serial8250_console_write(up, s, count);
398397
}
399-
#else
400-
static void univ8250_console_write_atomic(struct console *co,
401-
struct nbcon_write_context *wctxt)
402-
{
403-
struct uart_8250_port *up = &serial8250_ports[co->index];
404-
405-
serial8250_console_write_atomic(up, wctxt);
406-
}
407-
408-
static void univ8250_console_write_thread(struct console *co,
409-
struct nbcon_write_context *wctxt)
410-
{
411-
struct uart_8250_port *up = &serial8250_ports[co->index];
412-
413-
serial8250_console_write_thread(up, wctxt);
414-
}
415-
416-
static void univ8250_console_device_lock(struct console *con, unsigned long *flags)
417-
{
418-
struct uart_port *up = &serial8250_ports[con->index].port;
419-
420-
__uart_port_lock_irqsave(up, flags);
421-
}
422-
423-
static void univ8250_console_device_unlock(struct console *con, unsigned long flags)
424-
{
425-
struct uart_port *up = &serial8250_ports[con->index].port;
426-
427-
__uart_port_unlock_irqrestore(up, flags);
428-
}
429-
#endif /* CONFIG_SERIAL_8250_LEGACY_CONSOLE */
430398

431399
static int univ8250_console_setup(struct console *co, char *options)
432400
{
@@ -526,20 +494,12 @@ static int univ8250_console_match(struct console *co, char *name, int idx,
526494

527495
static struct console univ8250_console = {
528496
.name = "ttyS",
529-
#ifdef CONFIG_SERIAL_8250_LEGACY_CONSOLE
530497
.write = univ8250_console_write,
531-
.flags = CON_PRINTBUFFER | CON_ANYTIME,
532-
#else
533-
.write_atomic = univ8250_console_write_atomic,
534-
.write_thread = univ8250_console_write_thread,
535-
.device_lock = univ8250_console_device_lock,
536-
.device_unlock = univ8250_console_device_unlock,
537-
.flags = CON_PRINTBUFFER | CON_ANYTIME | CON_NBCON,
538-
#endif
539498
.device = uart_console_device,
540499
.setup = univ8250_console_setup,
541500
.exit = univ8250_console_exit,
542501
.match = univ8250_console_match,
502+
.flags = CON_PRINTBUFFER | CON_ANYTIME,
543503
.index = -1,
544504
.data = &serial8250_reg,
545505
};

drivers/tty/serial/8250/8250_port.c

Lines changed: 2 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -546,13 +546,6 @@ static int serial8250_em485_init(struct uart_8250_port *p)
546546
if (!p->em485)
547547
return -ENOMEM;
548548

549-
#ifndef CONFIG_SERIAL_8250_LEGACY_CONSOLE
550-
if (uart_console(&p->port)) {
551-
dev_warn(p->port.dev, "no atomic printing for rs485 consoles\n");
552-
p->port.cons->write_atomic = NULL;
553-
}
554-
#endif
555-
556549
hrtimer_init(&p->em485->stop_tx_timer, CLOCK_MONOTONIC,
557550
HRTIMER_MODE_REL);
558551
hrtimer_init(&p->em485->start_tx_timer, CLOCK_MONOTONIC,
@@ -698,23 +691,14 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep)
698691
serial8250_rpm_put(p);
699692
}
700693

701-
/*
702-
* Only to be used by write_atomic() and the legacy write(), which do not
703-
* require port lock.
704-
*/
705-
static void __serial8250_clear_IER(struct uart_8250_port *up)
694+
static void serial8250_clear_IER(struct uart_8250_port *up)
706695
{
707696
if (up->capabilities & UART_CAP_UUE)
708697
serial_out(up, UART_IER, UART_IER_UUE);
709698
else
710699
serial_out(up, UART_IER, 0);
711700
}
712701

713-
static inline void serial8250_clear_IER(struct uart_8250_port *up)
714-
{
715-
__serial8250_clear_IER(up);
716-
}
717-
718702
#ifdef CONFIG_SERIAL_8250_RSA
719703
/*
720704
* Attempts to turn on the RSA FIFO. Returns zero on failure.
@@ -3285,11 +3269,6 @@ static void serial8250_console_putchar(struct uart_port *port, unsigned char ch)
32853269

32863270
wait_for_xmitr(up, UART_LSR_THRE);
32873271
serial_port_out(port, UART_TX, ch);
3288-
3289-
if (ch == '\n')
3290-
up->console_newline_needed = false;
3291-
else
3292-
up->console_newline_needed = true;
32933272
}
32943273

32953274
/*
@@ -3318,7 +3297,6 @@ static void serial8250_console_restore(struct uart_8250_port *up)
33183297
serial8250_out_MCR(up, up->mcr | UART_MCR_DTR | UART_MCR_RTS);
33193298
}
33203299

3321-
#ifdef CONFIG_SERIAL_8250_LEGACY_CONSOLE
33223300
/*
33233301
* Print a string to the serial port using the device FIFO
33243302
*
@@ -3377,7 +3355,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
33773355
* First save the IER then disable the interrupts
33783356
*/
33793357
ier = serial_port_in(port, UART_IER);
3380-
__serial8250_clear_IER(up);
3358+
serial8250_clear_IER(up);
33813359

33823360
/* check scratch reg to see if port powered off during system sleep */
33833361
if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) {
@@ -3443,131 +3421,6 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
34433421
if (locked)
34443422
uart_port_unlock_irqrestore(port, flags);
34453423
}
3446-
#else
3447-
void serial8250_console_write_thread(struct uart_8250_port *up,
3448-
struct nbcon_write_context *wctxt)
3449-
{
3450-
struct uart_8250_em485 *em485 = up->em485;
3451-
struct uart_port *port = &up->port;
3452-
unsigned int ier;
3453-
3454-
touch_nmi_watchdog();
3455-
3456-
if (!nbcon_enter_unsafe(wctxt))
3457-
return;
3458-
3459-
/* First save IER then disable the interrupts. */
3460-
ier = serial_port_in(port, UART_IER);
3461-
serial8250_clear_IER(up);
3462-
3463-
/* Check scratch reg if port powered off during system sleep. */
3464-
if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) {
3465-
serial8250_console_restore(up);
3466-
up->canary = 0;
3467-
}
3468-
3469-
if (em485) {
3470-
if (em485->tx_stopped)
3471-
up->rs485_start_tx(up);
3472-
mdelay(port->rs485.delay_rts_before_send);
3473-
}
3474-
3475-
if (nbcon_exit_unsafe(wctxt)) {
3476-
int len = READ_ONCE(wctxt->len);
3477-
int i;
3478-
3479-
/*
3480-
* Write out the message. Toggle unsafe for each byte in order
3481-
* to give another (higher priority) context the opportunity
3482-
* for a friendly takeover. If such a takeover occurs, this
3483-
* context must reacquire ownership in order to perform final
3484-
* actions (such as re-enabling the interrupts).
3485-
*
3486-
* IMPORTANT: wctxt->outbuf and wctxt->len are no longer valid
3487-
* after a reacquire so writing the message must be
3488-
* aborted.
3489-
*/
3490-
for (i = 0; i < len; i++) {
3491-
if (!nbcon_enter_unsafe(wctxt)) {
3492-
nbcon_reacquire_nobuf(wctxt);
3493-
break;
3494-
}
3495-
3496-
uart_console_write(port, wctxt->outbuf + i, 1, serial8250_console_putchar);
3497-
3498-
if (!nbcon_exit_unsafe(wctxt)) {
3499-
nbcon_reacquire_nobuf(wctxt);
3500-
break;
3501-
}
3502-
}
3503-
} else {
3504-
nbcon_reacquire_nobuf(wctxt);
3505-
}
3506-
3507-
while (!nbcon_enter_unsafe(wctxt))
3508-
nbcon_reacquire_nobuf(wctxt);
3509-
3510-
/* Finally, wait for transmitter to become empty and restore IER. */
3511-
wait_for_xmitr(up, UART_LSR_BOTH_EMPTY);
3512-
if (em485) {
3513-
mdelay(port->rs485.delay_rts_after_send);
3514-
if (em485->tx_stopped)
3515-
up->rs485_stop_tx(up);
3516-
}
3517-
serial_port_out(port, UART_IER, ier);
3518-
3519-
/*
3520-
* The receive handling will happen properly because the receive ready
3521-
* bit will still be set; it is not cleared on read. However, modem
3522-
* control will not, we must call it if we have saved something in the
3523-
* saved flags while processing with interrupts off.
3524-
*/
3525-
if (up->msr_saved_flags)
3526-
serial8250_modem_status(up);
3527-
3528-
nbcon_exit_unsafe(wctxt);
3529-
}
3530-
3531-
void serial8250_console_write_atomic(struct uart_8250_port *up,
3532-
struct nbcon_write_context *wctxt)
3533-
{
3534-
struct uart_port *port = &up->port;
3535-
unsigned int ier;
3536-
3537-
/* Atomic console not supported for rs485 mode. */
3538-
if (WARN_ON_ONCE(up->em485))
3539-
return;
3540-
3541-
touch_nmi_watchdog();
3542-
3543-
if (!nbcon_enter_unsafe(wctxt))
3544-
return;
3545-
3546-
/*
3547-
* First save IER then disable the interrupts. The special variant to
3548-
* clear IER is used because atomic printing may occur without holding
3549-
* the port lock.
3550-
*/
3551-
ier = serial_port_in(port, UART_IER);
3552-
__serial8250_clear_IER(up);
3553-
3554-
/* Check scratch reg if port powered off during system sleep. */
3555-
if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) {
3556-
serial8250_console_restore(up);
3557-
up->canary = 0;
3558-
}
3559-
3560-
if (up->console_newline_needed)
3561-
uart_console_write(port, "\n", 1, serial8250_console_putchar);
3562-
uart_console_write(port, wctxt->outbuf, wctxt->len, serial8250_console_putchar);
3563-
3564-
/* Finally, wait for transmitter to become empty and restore IER. */
3565-
wait_for_xmitr(up, UART_LSR_BOTH_EMPTY);
3566-
serial_port_out(port, UART_IER, ier);
3567-
3568-
nbcon_exit_unsafe(wctxt);
3569-
}
3570-
#endif /* CONFIG_SERIAL_8250_LEGACY_CONSOLE */
35713424

35723425
static unsigned int probe_baud(struct uart_port *port)
35733426
{
@@ -3586,7 +3439,6 @@ static unsigned int probe_baud(struct uart_port *port)
35863439

35873440
int serial8250_console_setup(struct uart_port *port, char *options, bool probe)
35883441
{
3589-
struct uart_8250_port *up = up_to_u8250p(port);
35903442
int baud = 9600;
35913443
int bits = 8;
35923444
int parity = 'n';
@@ -3596,8 +3448,6 @@ int serial8250_console_setup(struct uart_port *port, char *options, bool probe)
35963448
if (!port->iobase && !port->membase)
35973449
return -ENODEV;
35983450

3599-
up->console_newline_needed = false;
3600-
36013451
if (options)
36023452
uart_parse_options(options, &baud, &parity, &bits, &flow);
36033453
else if (probe)

include/linux/serial_8250.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ struct uart_8250_port {
153153
#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
154154
unsigned char msr_saved_flags;
155155

156-
bool console_newline_needed;
157-
158156
struct uart_8250_dma *dma;
159157
const struct uart_8250_ops *ops;
160158

@@ -206,10 +204,6 @@ void serial8250_init_port(struct uart_8250_port *up);
206204
void serial8250_set_defaults(struct uart_8250_port *up);
207205
void serial8250_console_write(struct uart_8250_port *up, const char *s,
208206
unsigned int count);
209-
void serial8250_console_write_atomic(struct uart_8250_port *up,
210-
struct nbcon_write_context *wctxt);
211-
void serial8250_console_write_thread(struct uart_8250_port *up,
212-
struct nbcon_write_context *wctxt);
213207
int serial8250_console_setup(struct uart_port *port, char *options, bool probe);
214208
int serial8250_console_exit(struct uart_port *port);
215209

0 commit comments

Comments
 (0)