Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: 8250_fintek: Add resource check for Fintek F81504/508/512

Add resource type check for Fintek F81504/508/512, BAR3/4/5 must be
IORESOURCE_IO.

Fintek is trying to make F81504/508/512 works on MMIO interface, but
it's still in progress. We found some issue when the experiment IC
when the BAR3/4/5 is IORESOURCE_MEM. It'll cause wrong operation with
IO resource. So we'll add the resource check for this.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ji-Ze Hong (Peter Hong) and committed by
Greg Kroah-Hartman
6def047c 732dbf3a

+9 -4
+9 -4
drivers/tty/serial/8250/8250_pci.c
··· 1477 1477 { 1478 1478 unsigned long iobase; 1479 1479 u32 max_port, i; 1480 - u32 bar_data[3]; 1480 + resource_size_t bar_data[3]; 1481 1481 u8 config_base; 1482 1482 struct serial_private *priv = pci_get_drvdata(dev); 1483 1483 struct uart_8250_port *port; 1484 + 1485 + if (!(pci_resource_flags(dev, 5) & IORESOURCE_IO) || 1486 + !(pci_resource_flags(dev, 4) & IORESOURCE_IO) || 1487 + !(pci_resource_flags(dev, 3) & IORESOURCE_IO)) 1488 + return -ENODEV; 1484 1489 1485 1490 switch (dev->device) { 1486 1491 case 0x1104: /* 4 ports */ ··· 1500 1495 } 1501 1496 1502 1497 /* Get the io address dispatch from the BIOS */ 1503 - pci_read_config_dword(dev, 0x24, &bar_data[0]); 1504 - pci_read_config_dword(dev, 0x20, &bar_data[1]); 1505 - pci_read_config_dword(dev, 0x1c, &bar_data[2]); 1498 + bar_data[0] = pci_resource_start(dev, 5); 1499 + bar_data[1] = pci_resource_start(dev, 4); 1500 + bar_data[2] = pci_resource_start(dev, 3); 1506 1501 1507 1502 for (i = 0; i < max_port; ++i) { 1508 1503 /* UART0 configuration offset start from 0x40 */