Skip to contentSkip to conversation

ns16550: Re-order the serial port address checking

PATCH In review Wei Xu 3 participants 5 messages Feb 24, 2020 – Feb 26, 2020

lore
Share & tools
lore

Wei Xu

author
#0 lore raw

PATCH 1/1 ns16550: Re-order the serial port address checking

Check the serial port address space before checking the address.

---
 xen/drivers/char/ns16550.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
xen/drivers/char/ns16550.c +6 -6
index dc8ac4c..425e044 100644
@@ -1644,6 +1644,12 @@ static int __init ns16550_acpi_uart_init(const void *data)
 
     spcr = container_of(table, struct acpi_table_spcr, header);
 
+    if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) )
+    {
+        printk("ns16550: Address space type is not mmio\n");
+        return -EINVAL;
+    }
+
     /*
      * The serial port address may be 0 for example
      * if the console redirection is disabled.
@@ -1654,12 +1660,6 @@ static int __init ns16550_acpi_uart_init(const void *data)
         return -EINVAL;
     }
 
-    if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) )
-    {
-        printk("ns16550: Address space type is not mmio\n");
-        return -EINVAL;
-    }
-
     ns16550_init_common(uart);
 
     /*
Signature · 7 lines
2.8.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

Hi Wei,

Thank you for sending a follow-up.

Quoted 1 line · Wei Xu

Check the serial port address space before checking the address.

Could you explain in a sentence why you want to re-order?

Cheers,

Quoted 37 lines
---
  xen/drivers/char/ns16550.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
xen/drivers/char/ns16550.c +6 -6
index dc8ac4c..425e044 100644
@@ -1644,6 +1644,12 @@ static int __init ns16550_acpi_uart_init(const void *data)
 
      spcr = container_of(table, struct acpi_table_spcr, header);
 
+    if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) )
+    {
+        printk("ns16550: Address space type is not mmio\n");
+        return -EINVAL;
+    }
+
      /*
       * The serial port address may be 0 for example
       * if the console redirection is disabled.
@@ -1654,12 +1660,6 @@ static int __init ns16550_acpi_uart_init(const void *data)
          return -EINVAL;
      }
 
-    if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) )
-    {
-        printk("ns16550: Address space type is not mmio\n");
-        return -EINVAL;
-    }
-
      ns16550_init_common(uart);
 
      /*
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#2 lore raw

Hi Julien,

Quoted 8 lines · Julien Grall

Hi Wei,

Thank you for sending a follow-up.

Quoted 1 line · Wei Xu

Check the serial port address space before checking the address.

Could you explain in a sentence why you want to re-order?

Do you think is it OK to explain as following:

The serial port address space ID qualifies the address. Whether a value of zero for the serial port address can sensibly mean "disabled" depends on the address space ID. Hence check the address space ID before checking the address.

Thanks!

Best Regards,
Wei

Quoted 38 lines

Cheers,

Quoted 35 lines
---
  xen/drivers/char/ns16550.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
xen/drivers/char/ns16550.c +6 -6
index dc8ac4c..425e044 100644
@@ -1644,6 +1644,12 @@ static int __init ns16550_acpi_uart_init(const void *data)
 
      spcr = container_of(table, struct acpi_table_spcr, header);
 
+    if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) )
+    {
+        printk("ns16550: Address space type is not mmio\n");
+        return -EINVAL;
+    }
+
      /*
       * The serial port address may be 0 for example
       * if the console redirection is disabled.
@@ -1654,12 +1660,6 @@ static int __init ns16550_acpi_uart_init(const void *data)
          return -EINVAL;
      }
 
-    if ( unlikely(spcr->serial_port.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) )
-    {
-        printk("ns16550: Address space type is not mmio\n");
-        return -EINVAL;
-    }
-
      ns16550_init_common(uart);
 
Quoted 3 lines

xen/drivers/char/ns16550.c static int __init ns16550_acpi_uart_init(const void *data) · line 1665

Quoted 2 lines
xen/drivers/char/ns16550.c +0 -0
      /*

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by
#3 lore raw
Quoted 6 lines · Wei Xu
Quoted 5 lines · Julien Grall

Thank you for sending a follow-up.

Quoted 1 line · Wei Xu

Check the serial port address space before checking the address.

Quoted 8 lines
Quoted 1 line

Could you explain in a sentence why you want to re-order?

Do you think is it OK to explain as following:

The serial port address space ID qualifies the address. Whether a value of zero for the serial port address can sensibly mean "disabled" depends on the address space ID. Hence check the address space ID before checking the address.

With this description ...

Quoted 1 line
Quoted 1 line
Quoted 1 line

And I'm sorry for having forgotten to switch these around while committing your earlier patch.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#4 lore raw

Hi Jan,

Quoted 16 lines · Jan Beulich
Quoted 6 lines · Wei Xu
Quoted 5 lines · Julien Grall

Thank you for sending a follow-up.

Quoted 1 line · Wei Xu

Check the serial port address space before checking the address.

Quoted 8 lines
Quoted 1 line

Could you explain in a sentence why you want to re-order?

Do you think is it OK to explain as following:

The serial port address space ID qualifies the address. Whether a value of zero for the serial port address can sensibly mean "disabled" depends on the address space ID. Hence check the address space ID before checking the address.

Quoted 5 lines

With this description ...

Quoted 1 line
Quoted 1 line
Quoted 1 line

Thanks!

Best Regards,
Wei

Quoted 8 lines

And I'm sorry for having forgotten to switch these around while committing your earlier patch.

Jan

.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel