Skip to contentSkip to conversation

ns16550: use poll mode if INTERRUPT_LINE is 0xff

PATCH Superseded Marek Marczykowski-Górecki 3 participants 8 messages May 11, 2022 – May 18, 2022

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 ns16550: use poll mode if INTERRUPT_LINE is 0xff

Intel LPSS has INTERRUPT_LINE set to 0xff by default, that is declared by the PCI Local Bus Specification Revision 3.0 (from 2004) as "unknown"/"no connection". Fallback to poll mode in this case. The 0xff handling is x86-specific, the surrounding code is guarded with CONFIG_X86 anyway.

---
Changes in v5:
- drop IRQ 0 from the log message
Changes in v4:
- adjust log message, change it from WARNING to INFO
- re-add x86 reference in the commit message
Changes in v3:
- change back to checking 0xff explicitly
- adjust commit message, include spec reference
- change warning to match the above
Changes in v2:
- add log message
- extend commit message
- code style fix

---
 xen/drivers/char/ns16550.c | 7 +++++++
 1 file changed, 7 insertions(+)
xen/drivers/char/ns16550.c +7 -0
index fb75cee4a13a..417c07cde3dc 100644
@@ -1238,6 +1238,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }
Signature · 1 line
2.35.1
#1 lore raw

PATCH v5 2/2 ns16550: Add more device IDs for Intel LPSS UART

This is purely based on the spec:
- Intel 500 Series PCH: 635218-006
- Intel 600 Series PCH: 691222-001, 648364-003

This is tested only on TGL-LP added initially, but according to the spec, they should behave the same.

---
Changes in v2:
- new patch, adding more IDs to the patch that went in already

---
 xen/drivers/char/ns16550.c | 80 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)
xen/drivers/char/ns16550.c +79 -1
index 417c07cde3dc..cb17947e002f 100644
@@ -1077,12 +1077,90 @@ static const struct ns16550_config __initconst uart_config[] =
         .dev_id = 0x0358,
         .param = param_exar_xr17v358
     },
-    /* Intel Corp. TGL-LP LPSS PCI */
+    /* Intel Corp. TGL-LP LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0xa0a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-LP LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0xa0a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-LP LPSS PCI UART #2 */
     {
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .dev_id = 0xa0c7,
         .param = param_intel_lpss
     },
+    /* Intel Corp. TGL-H LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-H LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-H LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a7,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51c7,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #3 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51da,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7aa8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7aa9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7afe,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #3 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7adc,
+        .param = param_intel_lpss
+    },
 };
 
 static int __init
Signature · 1 line
2.35.1
#2 lore raw
In reply to Marek Marczykowski-Górecki
Quoted 6 lines · Marek Marczykowski-Górecki
xen/drivers/char/ns16550.c +0 -0
@@ -1238,6 +1238,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 

xen/drivers/char/ns16550.c pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx) · line 1250

Quoted 10 lines
xen/drivers/char/ns16550.c +7 -0
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }

While this code is inside a CONFIG_HAS_PCI conditional, I still think - as was previously suggested - that the 1st if() should be inside a CONFIG_X86 conditional, to not leave a trap for other architectures to fall into.

Jan

#3 lore raw
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Marek Marczykowski-Górecki
xen/drivers/char/ns16550.c +0 -0
@@ -1238,6 +1238,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 
Quoted 15 lines

xen/drivers/char/ns16550.c pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx) · line 1250

Quoted 10 lines
xen/drivers/char/ns16550.c +7 -0
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }

While this code is inside a CONFIG_HAS_PCI conditional, I still think - as was previously suggested - that the 1st if() should be inside a CONFIG_X86 conditional, to not leave a trap for other architectures to fall into.

The CONFIG_HAS_PCI region is itself inside of a (bigger) CONFIG_X86 region already.

Thanks, Roger.

#4 lore raw
Quoted 24 lines · Roger Pau Monné
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Marek Marczykowski-Górecki
xen/drivers/char/ns16550.c +0 -0
@@ -1238,6 +1238,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 
Quoted 15 lines

xen/drivers/char/ns16550.c pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx) · line 1250

Quoted 10 lines
xen/drivers/char/ns16550.c +7 -0
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }

While this code is inside a CONFIG_HAS_PCI conditional, I still think - as was previously suggested - that the 1st if() should be inside a CONFIG_X86 conditional, to not leave a trap for other architectures to fall into.

Quoted 2 lines

The CONFIG_HAS_PCI region is itself inside of a (bigger) CONFIG_X86 region already.

But that's likely to change sooner or later, I expect. I'd rather see the surrounding region be shrunk in scope. Already when that CONFIG_X86 was introduced I had reservations, as I don't think all of the enclosed code really is x86-specific.

Jan

#5 lore raw
Quoted 25 lines · Jan Beulich
Quoted 24 lines · Roger Pau Monné
Quoted 22 lines · Jan Beulich
Quoted 6 lines · Marek Marczykowski-Górecki
xen/drivers/char/ns16550.c +0 -0
@@ -1238,6 +1238,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 

xen/drivers/char/ns16550.c pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx) · line 1250

Quoted 10 lines
xen/drivers/char/ns16550.c +7 -0
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }

While this code is inside a CONFIG_HAS_PCI conditional, I still think - as was previously suggested - that the 1st if() should be inside a CONFIG_X86 conditional, to not leave a trap for other architectures to fall into.

Quoted 7 lines
Quoted 2 lines

The CONFIG_HAS_PCI region is itself inside of a (bigger) CONFIG_X86 region already.

But that's likely to change sooner or later, I expect. I'd rather see the surrounding region be shrunk in scope. Already when that CONFIG_X86 was introduced I had reservations, as I don't think all of the enclosed code really is x86-specific.

My though was that anyone removing the CONFIG_X86 guard will already have to deal with setting ->irq properly, as I expect this will differ between arches, at which point the check are likely to diverge anyway.

In any case, I don't see an issue with adding an extra guard, albeit a comment would also be acceptable IMO.

Thanks, Roger.

#6 lore raw
Quoted 29 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 26 lines · Roger Pau Monné
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Marek Marczykowski-Górecki
xen/drivers/char/ns16550.c +0 -0
@@ -1238,6 +1238,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 
Quoted 15 lines

xen/drivers/char/ns16550.c pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx) · line 1250

Quoted 10 lines
xen/drivers/char/ns16550.c +7 -0
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }

While this code is inside a CONFIG_HAS_PCI conditional, I still think - as was previously suggested - that the 1st if() should be inside a CONFIG_X86 conditional, to not leave a trap for other architectures to fall into.

The CONFIG_HAS_PCI region is itself inside of a (bigger) CONFIG_X86 region already.

Quoted 8 lines
Quoted 4 lines

But that's likely to change sooner or later, I expect. I'd rather see the surrounding region be shrunk in scope. Already when that CONFIG_X86 was introduced I had reservations, as I don't think all of the enclosed code really is x86-specific.

My though was that anyone removing the CONFIG_X86 guard will already have to deal with setting ->irq properly, as I expect this will differ between arches, at which point the check are likely to diverge anyway.

Hmm, true. What I would really like (and what I should have spelled out) is that the build would fail if this code was enabled for no-x86, such that it ends up very obvious that something needs doing there. Hence ...

Quoted 2 lines

In any case, I don't see an issue with adding an extra guard, albeit a comment would also be acceptable IMO.

... maybe

#ifdef CONFIG_X86
    ...
#else
# error
#endif

?

Jan

#7 lore raw
Quoted 46 lines · Jan Beulich
Quoted 29 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 26 lines · Roger Pau Monné
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Marek Marczykowski-Górecki
xen/drivers/char/ns16550.c +0 -0
@@ -1238,6 +1238,13 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 
Quoted 15 lines

xen/drivers/char/ns16550.c pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx) · line 1250

Quoted 10 lines
xen/drivers/char/ns16550.c +7 -0
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }

While this code is inside a CONFIG_HAS_PCI conditional, I still think - as was previously suggested - that the 1st if() should be inside a CONFIG_X86 conditional, to not leave a trap for other architectures to fall into.

The CONFIG_HAS_PCI region is itself inside of a (bigger) CONFIG_X86 region already.

Quoted 8 lines
Quoted 4 lines

But that's likely to change sooner or later, I expect. I'd rather see the surrounding region be shrunk in scope. Already when that CONFIG_X86 was introduced I had reservations, as I don't think all of the enclosed code really is x86-specific.

My though was that anyone removing the CONFIG_X86 guard will already have to deal with setting ->irq properly, as I expect this will differ between arches, at which point the check are likely to diverge anyway.

Hmm, true. What I would really like (and what I should have spelled out) is that the build would fail if this code was enabled for no-x86, such that it ends up very obvious that something needs doing there. Hence ...

Quoted 2 lines

In any case, I don't see an issue with adding an extra guard, albeit a comment would also be acceptable IMO.

Quoted 7 lines

... maybe

#ifdef CONFIG_X86
    ...
#else
# error
#endif

The whole section was wrapped in CONFIG_X86, so I haven't added it once again. But if that's desirable, I can wrap the 0xff IRQ handling in yet another CONFIG_X86 guard (since the spec says this value is x86 specific). I don't think having #error in non-x86 case makes much sense here.

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab