Skip to content

Commit 5640039

Browse files
committed
Merge tag 'tty-6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull serial driver fixes from Greg KH: "Here are some small serial driver fixes for some reported problems. Nothing major, just: - sc16is7xx irq check fix - 8250 fifo underflow fix - serial_port and 8250 iotype fixes Most of these have been in linux-next already, and all have passed 0-day testing" * tag 'tty-6.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: serial: 8250: Fix fifo underflow on flush serial: 8250_pnp: Remove unneeded ->iotype assignment serial: 8250_platform: Remove unneeded ->iotype assignment serial: 8250_of: Remove unneeded ->iotype assignment serial: port: Make ->iotype validation global in __uart_read_properties() serial: port: Always update ->iotype in __uart_read_properties() serial: port: Assign ->iotype correctly when ->iobase is set serial: sc16is7xx: Fix IRQ number check behavior
2 parents 6bfcc5f + 9e512ea commit 5640039

File tree

8 files changed

+35
-26
lines changed

8 files changed

+35
-26
lines changed

drivers/tty/serial/8250/8250.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ static inline int is_omap1510_8250(struct uart_8250_port *pt)
374374

375375
#ifdef CONFIG_SERIAL_8250_DMA
376376
extern int serial8250_tx_dma(struct uart_8250_port *);
377+
extern void serial8250_tx_dma_flush(struct uart_8250_port *);
377378
extern int serial8250_rx_dma(struct uart_8250_port *);
378379
extern void serial8250_rx_dma_flush(struct uart_8250_port *);
379380
extern int serial8250_request_dma(struct uart_8250_port *);
@@ -406,6 +407,7 @@ static inline int serial8250_tx_dma(struct uart_8250_port *p)
406407
{
407408
return -1;
408409
}
410+
static inline void serial8250_tx_dma_flush(struct uart_8250_port *p) { }
409411
static inline int serial8250_rx_dma(struct uart_8250_port *p)
410412
{
411413
return -1;

drivers/tty/serial/8250/8250_dma.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,22 @@ int serial8250_tx_dma(struct uart_8250_port *p)
149149
return ret;
150150
}
151151

152+
void serial8250_tx_dma_flush(struct uart_8250_port *p)
153+
{
154+
struct uart_8250_dma *dma = p->dma;
155+
156+
if (!dma->tx_running)
157+
return;
158+
159+
/*
160+
* kfifo_reset() has been called by the serial core, avoid
161+
* advancing and underflowing in __dma_tx_complete().
162+
*/
163+
dma->tx_size = 0;
164+
165+
dmaengine_terminate_async(dma->rxchan);
166+
}
167+
152168
int serial8250_rx_dma(struct uart_8250_port *p)
153169
{
154170
struct uart_8250_dma *dma = p->dma;

drivers/tty/serial/8250/8250_of.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
110110
spin_lock_init(&port->lock);
111111

112112
if (resource_type(&resource) == IORESOURCE_IO) {
113-
port->iotype = UPIO_PORT;
114113
port->iobase = resource.start;
115114
} else {
116115
port->mapbase = resource.start;

drivers/tty/serial/8250/8250_platform.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ static int serial8250_probe_acpi(struct platform_device *pdev)
112112
struct device *dev = &pdev->dev;
113113
struct uart_8250_port uart = { };
114114
struct resource *regs;
115-
unsigned char iotype;
116115
int ret, line;
117116

118117
regs = platform_get_mem_or_io(pdev, 0);
@@ -122,13 +121,11 @@ static int serial8250_probe_acpi(struct platform_device *pdev)
122121
switch (resource_type(regs)) {
123122
case IORESOURCE_IO:
124123
uart.port.iobase = regs->start;
125-
iotype = UPIO_PORT;
126124
break;
127125
case IORESOURCE_MEM:
128126
uart.port.mapbase = regs->start;
129127
uart.port.mapsize = resource_size(regs);
130128
uart.port.flags = UPF_IOREMAP;
131-
iotype = UPIO_MEM;
132129
break;
133130
default:
134131
return -EINVAL;
@@ -147,12 +144,6 @@ static int serial8250_probe_acpi(struct platform_device *pdev)
147144
if (ret)
148145
return ret;
149146

150-
/*
151-
* The previous call may not set iotype correctly when reg-io-width
152-
* property is absent and it doesn't support IO port resource.
153-
*/
154-
uart.port.iotype = iotype;
155-
156147
line = serial8250_register_8250_port(&uart);
157148
if (line < 0)
158149
return line;

drivers/tty/serial/8250/8250_pnp.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
436436
{
437437
struct uart_8250_port uart, *port;
438438
int ret, flags = dev_id->driver_data;
439-
unsigned char iotype;
440439
long line;
441440

442441
if (flags & UNKNOWN_DEV) {
@@ -448,14 +447,11 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
448447
memset(&uart, 0, sizeof(uart));
449448
if ((flags & CIR_PORT) && pnp_port_valid(dev, 2)) {
450449
uart.port.iobase = pnp_port_start(dev, 2);
451-
iotype = UPIO_PORT;
452450
} else if (pnp_port_valid(dev, 0)) {
453451
uart.port.iobase = pnp_port_start(dev, 0);
454-
iotype = UPIO_PORT;
455452
} else if (pnp_mem_valid(dev, 0)) {
456453
uart.port.mapbase = pnp_mem_start(dev, 0);
457454
uart.port.mapsize = pnp_mem_len(dev, 0);
458-
iotype = UPIO_MEM;
459455
uart.port.flags = UPF_IOREMAP;
460456
} else
461457
return -ENODEV;
@@ -471,12 +467,6 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
471467
if (ret)
472468
return ret;
473469

474-
/*
475-
* The previous call may not set iotype correctly when reg-io-width
476-
* property is absent and it doesn't support IO port resource.
477-
*/
478-
uart.port.iotype = iotype;
479-
480470
if (flags & CIR_PORT) {
481471
uart.port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE;
482472
uart.port.type = PORT_8250_CIR;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,14 @@ static void serial8250_shutdown(struct uart_port *port)
25552555
serial8250_do_shutdown(port);
25562556
}
25572557

2558+
static void serial8250_flush_buffer(struct uart_port *port)
2559+
{
2560+
struct uart_8250_port *up = up_to_u8250p(port);
2561+
2562+
if (up->dma)
2563+
serial8250_tx_dma_flush(up);
2564+
}
2565+
25582566
static unsigned int serial8250_do_get_divisor(struct uart_port *port,
25592567
unsigned int baud,
25602568
unsigned int *frac)
@@ -3244,6 +3252,7 @@ static const struct uart_ops serial8250_pops = {
32443252
.break_ctl = serial8250_break_ctl,
32453253
.startup = serial8250_startup,
32463254
.shutdown = serial8250_shutdown,
3255+
.flush_buffer = serial8250_flush_buffer,
32473256
.set_termios = serial8250_set_termios,
32483257
.set_ldisc = serial8250_set_ldisc,
32493258
.pm = serial8250_pm,

drivers/tty/serial/sc16is7xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
15611561
/* Always ask for fixed clock rate from a property. */
15621562
device_property_read_u32(dev, "clock-frequency", &uartclk);
15631563

1564-
s->polling = !!irq;
1564+
s->polling = (irq <= 0);
15651565
if (s->polling)
15661566
dev_dbg(dev,
15671567
"No interrupt pin definition, falling back to polling mode\n");

drivers/tty/serial/serial_port.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ EXPORT_SYMBOL(uart_remove_one_port);
173173
* The caller is responsible to initialize the following fields of the @port
174174
* ->dev (must be valid)
175175
* ->flags
176+
* ->iobase
176177
* ->mapbase
177178
* ->mapsize
178179
* ->regshift (if @use_defaults is false)
@@ -214,7 +215,7 @@ static int __uart_read_properties(struct uart_port *port, bool use_defaults)
214215
/* Read the registers I/O access type (default: MMIO 8-bit) */
215216
ret = device_property_read_u32(dev, "reg-io-width", &value);
216217
if (ret) {
217-
port->iotype = UPIO_MEM;
218+
port->iotype = port->iobase ? UPIO_PORT : UPIO_MEM;
218219
} else {
219220
switch (value) {
220221
case 1:
@@ -227,15 +228,16 @@ static int __uart_read_properties(struct uart_port *port, bool use_defaults)
227228
port->iotype = device_is_big_endian(dev) ? UPIO_MEM32BE : UPIO_MEM32;
228229
break;
229230
default:
230-
if (!use_defaults) {
231-
dev_err(dev, "Unsupported reg-io-width (%u)\n", value);
232-
return -EINVAL;
233-
}
234231
port->iotype = UPIO_UNKNOWN;
235232
break;
236233
}
237234
}
238235

236+
if (!use_defaults && port->iotype == UPIO_UNKNOWN) {
237+
dev_err(dev, "Unsupported reg-io-width (%u)\n", value);
238+
return -EINVAL;
239+
}
240+
239241
/* Read the address mapping base offset (default: no offset) */
240242
ret = device_property_read_u32(dev, "reg-offset", &value);
241243
if (ret)

0 commit comments

Comments
 (0)