* [PATCH] serial: 8250_pci: Implement MSI(-X) support
@ 2019-08-12 11:21 Ralf Ramsauer
2019-08-29 22:33 ` Ralf Ramsauer
0 siblings, 1 reply; 3+ messages in thread
From: Ralf Ramsauer @ 2019-08-12 11:21 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, jailhouse-dev
Cc: Ralf Ramsauer, Jay Dolan
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 <ralf.ramsauer@oth-regensburg.de>
---
drivers/tty/serial/8250/8250_pci.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index bbe5cba21522..97992884c0ee 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -53,6 +53,16 @@ struct serial_private {
int line[0];
};
+static const struct pci_device_id pci_use_msi[] = {
+ { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
+ 0xA000, 0x1000) },
+ { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9912,
+ 0xA000, 0x1000) },
+ { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922,
+ 0xA000, 0x1000) },
+ { }
+};
+
static int pci_default_setup(struct serial_private*,
const struct pciserial_board*, struct uart_8250_port *, int);
@@ -3643,7 +3653,22 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board)
memset(&uart, 0, sizeof(uart));
uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
uart.port.uartclk = board->base_baud * 16;
- uart.port.irq = get_pci_irq(dev, board);
+
+ if (pci_match_id(pci_use_msi, dev)) {
+ dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n");
+ pci_set_master(dev);
+ rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
+ } else {
+ dev_dbg(&dev->dev, "Using legacy interrupts\n");
+ rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY);
+ }
+ if (rc < 0) {
+ kfree(priv);
+ priv = ERR_PTR(rc);
+ goto err_deinit;
+ }
+
+ uart.port.irq = pci_irq_vector(dev, 0);
uart.port.dev = &dev->dev;
for (i = 0; i < nr_ports; i++) {
--
2.22.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] serial: 8250_pci: Implement MSI(-X) support
2019-08-12 11:21 [PATCH] serial: 8250_pci: Implement MSI(-X) support Ralf Ramsauer
@ 2019-08-29 22:33 ` Ralf Ramsauer
2019-09-04 7:22 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Ralf Ramsauer @ 2019-08-29 22:33 UTC (permalink / raw)
To: Ralf Ramsauer, Greg Kroah-Hartman, Jiri Slaby, linux-serial,
jailhouse-dev
Cc: Jay Dolan
*ping* :)
On 8/12/19 1:21 PM, Ralf Ramsauer wrote:
> 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 <ralf.ramsauer@oth-regensburg.de>
> ---
> drivers/tty/serial/8250/8250_pci.c | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
> index bbe5cba21522..97992884c0ee 100644
> --- a/drivers/tty/serial/8250/8250_pci.c
> +++ b/drivers/tty/serial/8250/8250_pci.c
> @@ -53,6 +53,16 @@ struct serial_private {
> int line[0];
> };
>
> +static const struct pci_device_id pci_use_msi[] = {
> + { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
> + 0xA000, 0x1000) },
> + { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9912,
> + 0xA000, 0x1000) },
> + { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922,
> + 0xA000, 0x1000) },
> + { }
> +};
> +
> static int pci_default_setup(struct serial_private*,
> const struct pciserial_board*, struct uart_8250_port *, int);
>
> @@ -3643,7 +3653,22 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board)
> memset(&uart, 0, sizeof(uart));
> uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
> uart.port.uartclk = board->base_baud * 16;
> - uart.port.irq = get_pci_irq(dev, board);
> +
> + if (pci_match_id(pci_use_msi, dev)) {
> + dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n");
> + pci_set_master(dev);
> + rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
> + } else {
> + dev_dbg(&dev->dev, "Using legacy interrupts\n");
> + rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY);
> + }
> + if (rc < 0) {
> + kfree(priv);
> + priv = ERR_PTR(rc);
> + goto err_deinit;
> + }
> +
> + uart.port.irq = pci_irq_vector(dev, 0);
> uart.port.dev = &dev->dev;
>
> for (i = 0; i < nr_ports; i++) {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] serial: 8250_pci: Implement MSI(-X) support
2019-08-29 22:33 ` Ralf Ramsauer
@ 2019-09-04 7:22 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-09-04 7:22 UTC (permalink / raw)
To: Ralf Ramsauer; +Cc: Jiri Slaby, linux-serial, jailhouse-dev, Jay Dolan
On Fri, Aug 30, 2019 at 12:33:09AM +0200, Ralf Ramsauer wrote:
> *ping* :)
>
> On 8/12/19 1:21 PM, Ralf Ramsauer wrote:
> > 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 <ralf.ramsauer@oth-regensburg.de>
Ok, will queue this up, let's see what breaks :)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-04 7:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-12 11:21 [PATCH] serial: 8250_pci: Implement MSI(-X) support Ralf Ramsauer
2019-08-29 22:33 ` Ralf Ramsauer
2019-09-04 7:22 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).