Skip to content

Commit a3bc5b1

Browse files
author
CKI KWF Bot
committed
Merge: Backport two upstream reverts of serial port patches found to cause timeouts.
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/878 Backport two upstream reverts of serial port patches found to cause timeouts. JIRA: https://issues.redhat.com/browse/RHEL-56242 Resolves: RHEL-56242 Signed-off-by: John W. Linville <[email protected]> Approved-by: Tony Camuso <[email protected]> Approved-by: Lenny Szubowicz <[email protected]> Approved-by: CKI KWF Bot <[email protected]> Merged-by: CKI GitLab Kmaint Pipeline Bot <[email protected]>
2 parents 2444f45 + 9635f14 commit a3bc5b1

File tree

3 files changed

+3
-202
lines changed

3 files changed

+3
-202
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 & 155 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,26 +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-
/* Port locked to synchronize UART_IER access against the console. */
716-
lockdep_assert_held_once(&up->port.lock);
717-
718-
__serial8250_clear_IER(up);
719-
}
720-
721702
#ifdef CONFIG_SERIAL_8250_RSA
722703
/*
723704
* Attempts to turn on the RSA FIFO. Returns zero on failure.
@@ -3288,11 +3269,6 @@ static void serial8250_console_putchar(struct uart_port *port, unsigned char ch)
32883269

32893270
wait_for_xmitr(up, UART_LSR_THRE);
32903271
serial_port_out(port, UART_TX, ch);
3291-
3292-
if (ch == '\n')
3293-
up->console_newline_needed = false;
3294-
else
3295-
up->console_newline_needed = true;
32963272
}
32973273

32983274
/*
@@ -3321,7 +3297,6 @@ static void serial8250_console_restore(struct uart_8250_port *up)
33213297
serial8250_out_MCR(up, up->mcr | UART_MCR_DTR | UART_MCR_RTS);
33223298
}
33233299

3324-
#ifdef CONFIG_SERIAL_8250_LEGACY_CONSOLE
33253300
/*
33263301
* Print a string to the serial port using the device FIFO
33273302
*
@@ -3380,7 +3355,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,
33803355
* First save the IER then disable the interrupts
33813356
*/
33823357
ier = serial_port_in(port, UART_IER);
3383-
__serial8250_clear_IER(up);
3358+
serial8250_clear_IER(up);
33843359

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

35753425
static unsigned int probe_baud(struct uart_port *port)
35763426
{
@@ -3589,7 +3439,6 @@ static unsigned int probe_baud(struct uart_port *port)
35893439

35903440
int serial8250_console_setup(struct uart_port *port, char *options, bool probe)
35913441
{
3592-
struct uart_8250_port *up = up_to_u8250p(port);
35933442
int baud = 9600;
35943443
int bits = 8;
35953444
int parity = 'n';
@@ -3599,8 +3448,6 @@ int serial8250_console_setup(struct uart_port *port, char *options, bool probe)
35993448
if (!port->iobase && !port->membase)
36003449
return -ENODEV;
36013450

3602-
up->console_newline_needed = false;
3603-
36043451
if (options)
36053452
uart_parse_options(options, &baud, &parity, &bits, &flow);
36063453
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)