Skip to contentSkip to conversation

ns16550: correct name/value pair parsing for PCI port/bridge

PATCH In review Jan Beulich 2 participants 3 messages Mar 29, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ns16550: correct name/value pair parsing for PCI port/bridge

First of all these were inverted: "bridge=" caused the port coordinates to be established, while "port=" controlled the bridge coordinates. And then the error messages being identical also wasn't helpful. While correcting this also move both case blocks close together.

Fixes 97fd49a7e074 ("ns16550: add support for UART parameters to be specifed with name-value pairs")

---
pci_serial_early_init() only dealing with I/O port variants is also bogus, but that's a separate topic (which arguably would better be taken care of by someone actually in the position of testing it). Additionally I think it would be a good idea if the function left the bridge windows alone if they're already configured suitably (perhaps with a wider range).

_ns16550_resume() also doesn't care about configuring the bridge correctly.

It further looks to be a shortcoming that pci_uart_config() doesn't determine the bridge behind which the selected device may be located (let alone a hierarchy of bridges).

xen/drivers/char/ns16550.c +8 -8
@@ -1631,13 +1631,6 @@ static bool __init parse_namevalue_pairs
             break;
 
 #ifdef CONFIG_HAS_PCI
-        case bridge_bdf:
-            if ( !parse_pci(param_value, NULL, &uart->ps_bdf[0],
-                            &uart->ps_bdf[1], &uart->ps_bdf[2]) )
-                PARSE_ERR_RET("Bad port PCI coordinates\n");
-            uart->ps_bdf_enable = true;
-            break;
-
         case device:
             if ( strncmp(param_value, "pci", 3) == 0 )
             {
@@ -1652,9 +1645,16 @@ static bool __init parse_namevalue_pairs
             break;
 
         case port_bdf:
+            if ( !parse_pci(param_value, NULL, &uart->ps_bdf[0],
+                            &uart->ps_bdf[1], &uart->ps_bdf[2]) )
+                PARSE_ERR_RET("Bad port PCI coordinates\n");
+            uart->ps_bdf_enable = true;
+            break;
+
+        case bridge_bdf:
             if ( !parse_pci(param_value, NULL, &uart->pb_bdf[0],
                             &uart->pb_bdf[1], &uart->pb_bdf[2]) )
-                PARSE_ERR_RET("Bad port PCI coordinates\n");
+                PARSE_ERR_RET("Bad bridge PCI coordinates\n");
             uart->pb_bdf_enable = true;
             break;
 #endif
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jan Beulich

First of all these were inverted: "bridge=" caused the port coordinates to be established, while "port=" controlled the bridge coordinates. And then the error messages being identical also wasn't helpful. While correcting this also move both case blocks close together.

Fixes 97fd49a7e074 ("ns16550: add support for UART parameters to be specifed with name-value pairs")
#2 lore raw
Quoted 10 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich

First of all these were inverted: "bridge=" caused the port coordinates to be established, while "port=" controlled the bridge coordinates. And then the error messages being identical also wasn't helpful. While correcting this also move both case blocks close together.

Fixes 97fd49a7e074 ("ns16550: add support for UART parameters to be specifed with name-value pairs")

Thanks; I'll assume you don't mind if I correct the domain name spelling while applying the tag.

Jan