hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/tty/serial/8250/8250_port.c
....@@ -15,6 +15,7 @@
1515 #include <linux/moduleparam.h>
1616 #include <linux/ioport.h>
1717 #include <linux/init.h>
18
+#include <linux/irq.h>
1819 #include <linux/console.h>
1920 #include <linux/gpio/consumer.h>
2021 #include <linux/sysrq.h>
....@@ -1909,6 +1910,7 @@
19091910 unsigned long flags;
19101911 struct uart_8250_port *up = up_to_u8250p(port);
19111912 #ifndef CONFIG_ARCH_ROCKCHIP
1913
+ struct tty_port *tport = &port->state->port;
19121914 bool skip_rx = false;
19131915 #endif
19141916
....@@ -1944,6 +1946,11 @@
19441946 skip_rx = true;
19451947
19461948 if (status & (UART_LSR_DR | UART_LSR_BI) && !skip_rx) {
1949
+ struct irq_data *d;
1950
+
1951
+ d = irq_get_irq_data(port->irq);
1952
+ if (d && irqd_is_wakeup_set(d))
1953
+ pm_wakeup_event(tport->tty->dev, 0);
19471954 if (!up->dma || handle_rx_dma(up, iir))
19481955 status = serial8250_rx_chars(up, status);
19491956 }
....@@ -2022,19 +2029,25 @@
20222029 static unsigned int serial8250_tx_empty(struct uart_port *port)
20232030 {
20242031 struct uart_8250_port *up = up_to_u8250p(port);
2032
+ unsigned int result = 0;
20252033 unsigned long flags;
20262034 unsigned int lsr;
20272035
20282036 serial8250_rpm_get(up);
20292037
20302038 spin_lock_irqsave(&port->lock, flags);
2031
- lsr = serial_port_in(port, UART_LSR);
2032
- up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
2039
+ if (!serial8250_tx_dma_running(up)) {
2040
+ lsr = serial_port_in(port, UART_LSR);
2041
+ up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
2042
+
2043
+ if ((lsr & BOTH_EMPTY) == BOTH_EMPTY)
2044
+ result = TIOCSER_TEMT;
2045
+ }
20332046 spin_unlock_irqrestore(&port->lock, flags);
20342047
20352048 serial8250_rpm_put(up);
20362049
2037
- return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0;
2050
+ return result;
20382051 }
20392052
20402053 unsigned int serial8250_do_get_mctrl(struct uart_port *port)
....@@ -3326,6 +3339,7 @@
33263339 struct uart_port *port = &up->port;
33273340
33283341 spin_lock_init(&port->lock);
3342
+ port->pm = NULL;
33293343 port->ops = &serial8250_pops;
33303344 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
33313345