Skip to contentSkip to conversation

hw/loongarch/virt: Fix UART ACPI description and update DSDT blobs

PATCH Superseded pillow 2 participants 6 messages Oct 21 – Oct 22

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

pillow

author
#0 lore raw

v3 cover hw/loongarch/virt: Fix UART ACPI description and update DSDT blobs

The LoongArch virt UART ACPI description currently carries a _DSD clock property with a typo ("clock-frenquency"), a reversed key/value order, and a declared 100 MHz that does not match the QEMU model. The _DSD contains nothing but this clock property, so the whole object is dropped.

The Linux PNP serial driver uses uartclk = 1843200 Hz by default and the QEMU UART uses baudbase = 115200, i.e. uartclk / 16 = baudbase, so the Linux default clock already matches the model. QEMU's x86 ISA serial ACPI description also provides no clock property, which is consistent with this change.

Two further cleanups are folded into the same patch: _CCA is dropped because the emulated UART does not support DMA, and _STA = 0x0f is added to indicate the device is present, enabled, should be shown and functioning properly.

Patch 1 allows the LoongArch DSDT.* diffs in bios-tables-test, patch 2 makes the ACPI change, and patch 3 refreshes the expected DSDT blobs.

Testing: ran bios-tables-test with the updated blobs; no unexpected diffs remain.

pillow (3):
bios-tables-test-allowed-diff.h: Allow LoongArch DSDT.* hw/loongarch/virt: Drop UART _DSD/_CCA and add _STA tests/data/acpi/loongarch64: Update expected DSDT.*

 hw/loongarch/virt-acpi-build.c                |  12 +-----------
 tests/data/acpi/loongarch64/virt/DSDT         | Bin 4603 -> 4379 bytes
 tests/data/acpi/loongarch64/virt/DSDT.memhp   | Bin 5824 -> 5600 bytes
 tests/data/acpi/loongarch64/virt/DSDT.numamem | Bin 4609 -> 4385 bytes
 .../data/acpi/loongarch64/virt/DSDT.topology  | Bin 4905 -> 4681 bytes
 5 files changed, 1 insertion(+), 11 deletions(-)

base-commit: 8967b2fe1b2aaae3c29e207d85fab901d580a2dc

Signature · 1 line
2.56.0
author
#1 lore raw

PATCH v3 1/3 bios-tables-test-allowed-diff.h: Allow LoongArch DSDT.*

---
 tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++
 1 file changed, 4 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
index dfb8523..2ed837f 100644
@@ -1 +1,5 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/loongarch64/virt/DSDT",
+"tests/data/acpi/loongarch64/virt/DSDT.memhp",
+"tests/data/acpi/loongarch64/virt/DSDT.numamem",
+"tests/data/acpi/loongarch64/virt/DSDT.topology",
Signature · 1 line
2.56.0
author
#2 lore raw

PATCH v3 2/3 hw/loongarch/virt: Drop UART _DSD/_CCA and add _STA

In reply to pillow

The UART _DSD contains only a clock property, which has a typo ("clock-frenquency") and the key/value order is reversed. The declared 100 MHz also does not match the current QEMU model.

The Linux PNP serial driver uses uartclk = 1843200 Hz by default, and the QEMU UART uses baudbase = 115200. These correspond as uartclk / 16 = baudbase (1843200 / 16 = 115200), so the Linux default clock is consistent with the QEMU model. Since the clock property is the only content of the _DSD, remove the entire _DSD rather than keeping an empty one. The QEMU x86 ISA serial ACPI description also does not provide a clock property, which is consistent with this change.

Also drop _CCA because the emulated UART does not support DMA, and add _STA = 0x0f to indicate the device is present, enable, should be shown and functioning properly.

---
 hw/loongarch/virt-acpi-build.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
hw/loongarch/virt-acpi-build.c +1 -11
index 54965f0..55c7641 100644
@@ -314,7 +314,6 @@ static void build_uart_device_aml(Aml *table, int index)
 {
     Aml *dev;
     Aml *crs;
-    Aml *pkg0, *pkg1, *pkg2;
     Aml *scope;
     uint32_t uart_irq;
     uint64_t base;
@@ -325,7 +324,7 @@ static void build_uart_device_aml(Aml *table, int index)
     dev = aml_device("COM%d", index);
     aml_append(dev, aml_name_decl("_HID", aml_string("PNP0501")));
     aml_append(dev, aml_name_decl("_UID", aml_int(index)));
-    aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
+    aml_append(dev, aml_name_decl("_STA", aml_int(0x0f)));
     crs = aml_resource_template();
     aml_append(crs,
         aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
@@ -335,15 +334,6 @@ static void build_uart_device_aml(Aml *table, int index)
     aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
                                   AML_SHARED, &uart_irq, 1));
     aml_append(dev, aml_name_decl("_CRS", crs));
-    pkg0 = aml_package(0x2);
-    aml_append(pkg0, aml_int(0x05F5E100));
-    aml_append(pkg0, aml_string("clock-frenquency"));
-    pkg1 = aml_package(0x1);
-    aml_append(pkg1, pkg0);
-    pkg2 = aml_package(0x2);
-    aml_append(pkg2, aml_touuid("DAFFD814-6EBA-4D8C-8A91-BC9BBF4AA301"));
-    aml_append(pkg2, pkg1);
-    aml_append(dev, aml_name_decl("_DSD", pkg2));
     aml_append(scope, dev);
     aml_append(table, scope);
 }
Signature · 1 line
2.56.0
Reviewed-by on v3 2/3
#3 lore raw

Re: [PATCH v3 2/3] hw/loongarch/virt: Drop UART _DSD/_CCA and add _STA

Quoted 7 lines · pillow

The UART _DSD contains only a clock property, which has a typo ("clock-frenquency") and the key/value order is reversed. The declared 100 MHz also does not match the current QEMU model.

The Linux PNP serial driver uses uartclk = 1843200 Hz by default, and the QEMU UART uses baudbase = 115200. These correspond as uartclk / 16 = baudbase (1843200 / 16 = 115200), so the Linux default

baudrate = uartclk / 16 / divider, the default divider is 12, so the default baudrate is 9600. It can be referenced in function serial_reset():

    /* Default to 9600 baud, 1 start bit, 8 data bits */
    s->divider = 0x0C;

The clock freq in FDT table should be changed with 1843200 rather than 100000000, however it may be another issue.

Quoted 52 lines

clock is consistent with the QEMU model. Since the clock property is the only content of the _DSD, remove the entire _DSD rather than keeping an empty one. The QEMU x86 ISA serial ACPI description also does not provide a clock property, which is consistent with this change.

Also drop _CCA because the emulated UART does not support DMA, and add _STA = 0x0f to indicate the device is present, enable, should be shown and functioning properly.

---
  hw/loongarch/virt-acpi-build.c | 12 +-----------
  1 file changed, 1 insertion(+), 11 deletions(-)
hw/loongarch/virt-acpi-build.c +1 -11
index 54965f0..55c7641 100644
@@ -314,7 +314,6 @@ static void build_uart_device_aml(Aml *table, int index)
  {
      Aml *dev;
      Aml *crs;
-    Aml *pkg0, *pkg1, *pkg2;
      Aml *scope;
      uint32_t uart_irq;
      uint64_t base;
@@ -325,7 +324,7 @@ static void build_uart_device_aml(Aml *table, int index)
      dev = aml_device("COM%d", index);
      aml_append(dev, aml_name_decl("_HID", aml_string("PNP0501")));
      aml_append(dev, aml_name_decl("_UID", aml_int(index)));
-    aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
+    aml_append(dev, aml_name_decl("_STA", aml_int(0x0f)));
      crs = aml_resource_template();
      aml_append(crs,
          aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
@@ -335,15 +334,6 @@ static void build_uart_device_aml(Aml *table, int index)
      aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
                                    AML_SHARED, &uart_irq, 1));
      aml_append(dev, aml_name_decl("_CRS", crs));
-    pkg0 = aml_package(0x2);
-    aml_append(pkg0, aml_int(0x05F5E100));
-    aml_append(pkg0, aml_string("clock-frenquency"));
-    pkg1 = aml_package(0x1);
-    aml_append(pkg1, pkg0);
-    pkg2 = aml_package(0x2);
-    aml_append(pkg2, aml_touuid("DAFFD814-6EBA-4D8C-8A91-BC9BBF4AA301"));
-    aml_append(pkg2, pkg1);
-    aml_append(dev, aml_name_decl("_DSD", pkg2)); >       aml_append(scope, dev);
      aml_append(table, scope);
  }
 
author
#4 lore raw

Re: [PATCH v3 2/3] hw/loongarch/virt: Drop UART _DSD/_CCA and add _STA

Hi, all

Agreed. The reset baud rate is 9600, while 115200 is the baudbase.

I've sent v4 with a separate patch correcting the FDT UART clock to 1843200 Hz. I've alse carried your Reviewed-by on the ACPI patch.

Thanks,
pillow

Quoted 81 lines · Bibo Mao
Quoted 7 lines · pillow

The UART _DSD contains only a clock property, which has a typo ("clock-frenquency") and the key/value order is reversed. The declared 100 MHz also does not match the current QEMU model.

The Linux PNP serial driver uses uartclk = 1843200 Hz by default, and the QEMU UART uses baudbase = 115200. These correspond as uartclk / 16 = baudbase (1843200 / 16 = 115200), so the Linux default

baudrate = uartclk / 16 / divider, the default divider is 12, so the default baudrate is 9600. It can be referenced in function serial_reset():

     /* Default to 9600 baud, 1 start bit, 8 data bits */
     s->divider = 0x0C;

The clock freq in FDT table should be changed with 1843200 rather than 100000000, however it may be another issue.

Quoted 10 lines

clock is consistent with the QEMU model. Since the clock property is the only content of the _DSD, remove the entire _DSD rather than keeping an empty one. The QEMU x86 ISA serial ACPI description also does not provide a clock property, which is consistent with this change.

Also drop _CCA because the emulated UART does not support DMA, and add _STA = 0x0f to indicate the device is present, enable, should be shown and functioning properly.

Review

Quoted 6 lines
---
  hw/loongarch/virt-acpi-build.c | 12 +-----------
  1 file changed, 1 insertion(+), 11 deletions(-)
(quoted diff) +0 -0

b/hw/loongarch/virt-acpi-build.c

hw/loongarch/virt-acpi-build.c static void build_uart_device_aml(Aml *table, int

Quoted 4 lines

index 54965f0..55c7641 100644

hw/loongarch/virt-acpi-build.c +0 -0
@@ -314,7 +314,6 @@ static void build_uart_device_aml(Aml *table, int

index)

hw/loongarch/virt-acpi-build.c static void build_uart_device_aml(Aml *table, int

Quoted 8 lines
hw/loongarch/virt-acpi-build.c +0 -1
  {
      Aml *dev;
      Aml *crs;
-    Aml *pkg0, *pkg1, *pkg2;
      Aml *scope;
      uint32_t uart_irq;
      uint64_t base;
@@ -325,7 +324,7 @@ static void build_uart_device_aml(Aml *table, int

index)

hw/loongarch/virt-acpi-build.c static void build_uart_device_aml(Aml *table, int

Quoted 9 lines
hw/loongarch/virt-acpi-build.c +1 -1
      dev = aml_device("COM%d", index);
      aml_append(dev, aml_name_decl("_HID", aml_string("PNP0501")));
      aml_append(dev, aml_name_decl("_UID", aml_int(index)));
-    aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
+    aml_append(dev, aml_name_decl("_STA", aml_int(0x0f)));
      crs = aml_resource_template();
      aml_append(crs,
          aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
@@ -335,15 +334,6 @@ static void build_uart_device_aml(Aml *table, int

index)

hw/loongarch/virt-acpi-build.c static void build_uart_device_aml(Aml *table, int · line 334

Quoted 1 line
hw/loongarch/virt-acpi-build.c +0 -0
      aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL,

AML_ACTIVE_HIGH,

hw/loongarch/virt-acpi-build.c static void build_uart_device_aml(Aml *table, int index)

Quoted 9 lines
hw/loongarch/virt-acpi-build.c +0 -7
                                    AML_SHARED, &uart_irq, 1));
      aml_append(dev, aml_name_decl("_CRS", crs));
-    pkg0 = aml_package(0x2);
-    aml_append(pkg0, aml_int(0x05F5E100));
-    aml_append(pkg0, aml_string("clock-frenquency"));
-    pkg1 = aml_package(0x1);
-    aml_append(pkg1, pkg0);
-    pkg2 = aml_package(0x2);
-    aml_append(pkg2,

aml_touuid("DAFFD814-6EBA-4D8C-8A91-BC9BBF4AA301"));

hw/loongarch/virt-acpi-build.c static void build_uart_device_aml(Aml *table, int · line 346

Quoted 2 lines
hw/loongarch/virt-acpi-build.c +0 -2
-    aml_append(pkg2, pkg1);
-    aml_append(dev, aml_name_decl("_DSD", pkg2)); >

aml_append(scope, dev);

Quoted 3 lines
hw/loongarch/virt-acpi-build.c +0 -0
      aml_append(table, scope);
  }
 
author
#5 lore raw

PATCH v3 3/3 tests/data/acpi/loongarch64: Update expected DSDT.*

In reply to pillow

--- tests/data/acpi/loongarch64/virt/DSDT (before)
+++ tests/data/acpi/loongarch64/virt/DSDT (after)
@@ -6,7 +6,7 @@
{
Name (_HID, "PNP0501" /* 16550A-compatible COM Serial Port */) // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID
- Name (_CCA, One) // _CCA: Cache Coherency Attribute
+ Name (_STA, 0x0F) // _STA: Status
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -21,18 +21,6 @@
0x00000042,
}
})
- Name (_DSD, Package (0x02) // _DSD: Device-Specific Data
- {
- ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
- Package (0x01)
- {
- Package (0x02)
- {
- 0x05F5E100,
- "clock-frenquency"
- }
- }
- })
}
}

@@ -42,7 +30,7 @@
{
Name (_HID, "PNP0501" /* 16550A-compatible COM Serial Port */) // _HID: Hardware ID Name (_UID, One) // _UID: Unique ID
- Name (_CCA, One) // _CCA: Cache Coherency Attribute
+ Name (_STA, 0x0F) // _STA: Status
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -57,18 +45,6 @@
0x00000043,
}
})
- Name (_DSD, Package (0x02) // _DSD: Device-Specific Data
- {
- ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
- Package (0x01)
- {
- Package (0x02)
- {
- 0x05F5E100,
- "clock-frenquency"
- }
- }
- })
}
}

@@ -78,7 +54,7 @@
{
Name (_HID, "PNP0501" /* 16550A-compatible COM Serial Port */) // _HID: Hardware ID Name (_UID, 0x02) // _UID: Unique ID
- Name (_CCA, One) // _CCA: Cache Coherency Attribute
+ Name (_STA, 0x0F) // _STA: Status
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -93,18 +69,6 @@
0x00000044,
}
})
- Name (_DSD, Package (0x02) // _DSD: Device-Specific Data
- {
- ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
- Package (0x01)
- {
- Package (0x02)
- {
- 0x05F5E100,
- "clock-frenquency"
- }
- }
- })
}
}

@@ -114,7 +78,7 @@
{
Name (_HID, "PNP0501" /* 16550A-compatible COM Serial Port */) // _HID: Hardware ID Name (_UID, 0x03) // _UID: Unique ID
- Name (_CCA, One) // _CCA: Cache Coherency Attribute
+ Name (_STA, 0x0F) // _STA: Status
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -127,18 +91,6 @@
Interrupt (ResourceConsumer, Level, ActiveHigh, Shared, ,, )
{
0x00000045,
- }
- })
- Name (_DSD, Package (0x02) // _DSD: Device-Specific Data
- {
- ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */,
- Package (0x01)
- {
- Package (0x02)
- {
- 0x05F5E100,
- "clock-frenquency"
- }
}
})
}

---
 tests/data/acpi/loongarch64/virt/DSDT         | Bin 4603 -> 4379 bytes
 tests/data/acpi/loongarch64/virt/DSDT.memhp   | Bin 5824 -> 5600 bytes
 tests/data/acpi/loongarch64/virt/DSDT.numamem | Bin 4609 -> 4385 bytes
 .../data/acpi/loongarch64/virt/DSDT.topology  | Bin 4905 -> 4681 bytes
 tests/qtest/bios-tables-test-allowed-diff.h   |   4 ----
 5 files changed, 4 deletions(-)
tests/data/acpi/loongarch64/virt/DSDT binary +0 -0
index 09aa903c4e875f541223e36f59b28e101599df20..686d9078e4d61558d65bdcfec76a2428b83ef56d 100644
GIT binary patch
tests/data/acpi/loongarch64/virt/DSDT.memhp binary +0 -0
index a069d6878fb45fa6b0e6342eedb0eb3d25eb20da..fb2104170a134bdd414f9f5456f2e37e3489b749 100644
GIT binary patch
tests/data/acpi/loongarch64/virt/DSDT.numamem binary +0 -0
index 78ece52f57a383db128c7d1a08526e15ab911bb7..62374112f9e83ead0be549c8e17bdfe7941017e3 100644
GIT binary patch
tests/data/acpi/loongarch64/virt/DSDT.topology binary +0 -0
index 7ab23f47cc82dd7bc1975e17893a8cd61039e66d..9c37939f91334659662ec9f6dc1f941572029e7f 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
index 2ed837f..dfb8523 100644
@@ -1,5 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/loongarch64/virt/DSDT",
-"tests/data/acpi/loongarch64/virt/DSDT.memhp",
-"tests/data/acpi/loongarch64/virt/DSDT.numamem",
-"tests/data/acpi/loongarch64/virt/DSDT.topology",
Signature · 1 line
2.56.0