Skip to content

Commit 8428413

Browse files
rralfgregkh
authored andcommitted
serial: 8250_pci: Implement MSI(-X) support
There may be setups, where legacy interrupts are not available. This is the caese, e.g., when Linux runs as guest (aka. non-root cell) of the partitioning hypervisor Jailhouse. There, only MSI(-X) interrupts are available for guests. But the 8250_pci driver currently only supports legacy ints. So let's enable MSI(-X) interrupts. Nevertheless, this needs to handled with care: while many 8250 devices actually claim to support MSI(-X) interrupts it should not be enabled be default. I had at least one device in my hands with broken MSI implementation. So better introduce a whitelist with devices that are known to support MSI(-X) interrupts. I tested all devices mentioned in the patch. Signed-off-by: Ralf Ramsauer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 68e26a8 commit 8428413

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/tty/serial/8250/8250_pci.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ struct serial_private {
5858
int line[0];
5959
};
6060

61+
static const struct pci_device_id pci_use_msi[] = {
62+
{ PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
63+
0xA000, 0x1000) },
64+
{ PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9912,
65+
0xA000, 0x1000) },
66+
{ PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922,
67+
0xA000, 0x1000) },
68+
{ }
69+
};
70+
6171
static int pci_default_setup(struct serial_private*,
6272
const struct pciserial_board*, struct uart_8250_port *, int);
6373

@@ -4155,7 +4165,22 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board)
41554165
memset(&uart, 0, sizeof(uart));
41564166
uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
41574167
uart.port.uartclk = board->base_baud * 16;
4158-
uart.port.irq = get_pci_irq(dev, board);
4168+
4169+
if (pci_match_id(pci_use_msi, dev)) {
4170+
dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n");
4171+
pci_set_master(dev);
4172+
rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
4173+
} else {
4174+
dev_dbg(&dev->dev, "Using legacy interrupts\n");
4175+
rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY);
4176+
}
4177+
if (rc < 0) {
4178+
kfree(priv);
4179+
priv = ERR_PTR(rc);
4180+
goto err_deinit;
4181+
}
4182+
4183+
uart.port.irq = pci_irq_vector(dev, 0);
41594184
uart.port.dev = &dev->dev;
41604185

41614186
for (i = 0; i < nr_ports; i++) {

0 commit comments

Comments
 (0)