Skip to contentSkip to conversation

hw/loogarch: Fix UART ACPI properties and FDT

PATCH In review pillow 3 participants 9 messages Oct 25 – Nov 6

lore
Share & tools
lore

pillow

author
#0 lore raw

v5 cover hw/loogarch: Fix UART ACPI properties and FDT

This series fixes the UART description for LoongArch virt.

The ACPI _DSD property built for the UART has three problems: the property name is misspelled, the key and value order is reversed, and it describes a 100 MHz clock that does not match the device model. The property can be dropped directly because the UART model's input clock matches the Linux 8250 PnP driver default of 1,843,200 Hz, so no _DSD override is needed.

The _CCA property is also unnecessary. _CCA describes a device's DMA cache coherency attribute, and this UART does not support DMA, so there is no reason to declare it.

The UART clock frequency in the FDT is corrected to 1,843,200 Hz, and the expected ACPI tables are updated accordingly.

pillow (5):
bios-tables-test-allowed-diff.h: Allow LoongArch DSDT.* hw/loongarch/virt-acpi-build: Drop invalid _DSD UART clock property hw/loongarch/virt-acpi-build: Drop UART _CCA declaration hw/loongarch/virt: Fix UART clock frequency in FDT tests/data/acpi/loongarch64: Update expected DSDT.*

 hw/loongarch/virt-acpi-build.c                |  11 -----------
 hw/loongarch/virt-fdt-build.c                 |   2 +-
 tests/data/acpi/loongarch64/virt/DSDT         | Bin 4603 -> 4351 bytes
 tests/data/acpi/loongarch64/virt/DSDT.memhp   | Bin 5824 -> 5572 bytes
 tests/data/acpi/loongarch64/virt/DSDT.numamem | Bin 4609 -> 4357 bytes
 .../data/acpi/loongarch64/virt/DSDT.topology  | Bin 4905 -> 4653 bytes
 6 files changed, 1 insertion(+), 12 deletions(-)
Signature · 1 line
2.56.0
author
#1 lore raw

PATCH v5 1/5 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 v5 2/5 hw/loongarch/virt-acpi-build: Drop invalid _DSD UART clock property

In reply to pillow

Delete the code that constructs the _DSD property and its dedicated variables. The original property had three problems: its name was misspelled, the key and value order was reversed, and it described a 100 MHz clock, which does not match the device model.

The property can be removed directly because the UART model's input clock matches the Linux 8250 PnP driver default of 1,843,200 Hz, so no _DSD override is needed.

---
 hw/loongarch/virt-acpi-build.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/loongarch/virt-acpi-build.c +0 -10
index 54965f0..981e609 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;
@@ -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
author
#3 lore raw

PATCH v5 3/5 hw/loongarch/virt-acpi-build: Drop UART _CCA declaration

In reply to pillow

Remove the _CCA property from the UART device. _CCA describes a device's DMA cache coherency attributes. This UART does not support DMA, so there is no need to declare this property.

---
 hw/loongarch/virt-acpi-build.c | 1 -
 1 file changed, 1 deletion(-)
hw/loongarch/virt-acpi-build.c +0 -1
index 981e609..c560f25 100644
@@ -324,7 +324,6 @@ 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)));
     crs = aml_resource_template();
     aml_append(crs,
         aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
Signature · 1 line
2.56.0
author
#4 lore raw

PATCH v5 4/5 hw/loongarch/virt: Fix UART clock frequency in FDT

In reply to pillow

The UART uses baudbase = 115200, corresponding to an input clock of 1843200 Hz. Update the FDT clock-frequency property to match the model.

---
 hw/loongarch/virt-fdt-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/loongarch/virt-fdt-build.c +1 -1
index c6f5d02..7be71e2 100644
@@ -474,7 +474,7 @@ static void fdt_add_uart_node(LoongArchVirtMachineState *lvms,
     qemu_fdt_add_subnode(ms->fdt, nodename);
     qemu_fdt_setprop_string(ms->fdt, nodename, "compatible", "ns16550a");
     qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0x0, base, 0x0, size);
-    qemu_fdt_setprop_cell(ms->fdt, nodename, "clock-frequency", 100000000);
+    qemu_fdt_setprop_cell(ms->fdt, nodename, "clock-frequency", 1843200);
     if (chosen) {
         qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodename);
     }
Signature · 1 line
2.56.0
author
#5 lore raw

PATCH v5 5/5 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,6 @@
{
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 (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -21,18 +20,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 +29,6 @@
{
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 (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -57,18 +43,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 +52,6 @@
{
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 (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -93,18 +66,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 +75,6 @@
{
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 (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
@@ -127,18 +87,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 -> 4351 bytes
 tests/data/acpi/loongarch64/virt/DSDT.memhp   | Bin 5824 -> 5572 bytes
 tests/data/acpi/loongarch64/virt/DSDT.numamem | Bin 4609 -> 4357 bytes
 .../data/acpi/loongarch64/virt/DSDT.topology  | Bin 4905 -> 4653 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..9850873cfe67a9397149967c66690933f2b69d94 100644
GIT binary patch
tests/data/acpi/loongarch64/virt/DSDT.memhp binary +0 -0
index a069d6878fb45fa6b0e6342eedb0eb3d25eb20da..5a6a3bc29e75ff5a20b7aa1d87dfff0cf8595668 100644
GIT binary patch
tests/data/acpi/loongarch64/virt/DSDT.numamem binary +0 -0
index 78ece52f57a383db128c7d1a08526e15ab911bb7..3a6580b4ee93f9d2a44faffd6ffe9d3ae9ecd4d2 100644
GIT binary patch
tests/data/acpi/loongarch64/virt/DSDT.topology binary +0 -0
index 7ab23f47cc82dd7bc1975e17893a8cd61039e66d..7901fd9e07225a9d726f94e83e11724d9daae013 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
Reviewed-by on the v5 series
#6 lore raw
In reply to pillow
Quoted 23 lines · pillow

This series fixes the UART description for LoongArch virt.

The ACPI _DSD property built for the UART has three problems: the property name is misspelled, the key and value order is reversed, and it describes a 100 MHz clock that does not match the device model. The property can be dropped directly because the UART model's input clock matches the Linux 8250 PnP driver default of 1,843,200 Hz, so no _DSD override is needed.

The _CCA property is also unnecessary. _CCA describes a device's DMA cache coherency attribute, and this UART does not support DMA, so there is no reason to declare it.

The UART clock frequency in the FDT is corrected to 1,843,200 Hz, and the expected ACPI tables are updated accordingly.

pillow (5):
bios-tables-test-allowed-diff.h: Allow LoongArch DSDT.* hw/loongarch/virt-acpi-build: Drop invalid _DSD UART clock property hw/loongarch/virt-acpi-build: Drop UART _CCA declaration hw/loongarch/virt: Fix UART clock frequency in FDT tests/data/acpi/loongarch64: Update expected DSDT.*

Quoted 8 lines
  hw/loongarch/virt-acpi-build.c                |  11 -----------
  hw/loongarch/virt-fdt-build.c                 |   2 +-
  tests/data/acpi/loongarch64/virt/DSDT         | Bin 4603 -> 4351 bytes
  tests/data/acpi/loongarch64/virt/DSDT.memhp   | Bin 5824 -> 5572 bytes
  tests/data/acpi/loongarch64/virt/DSDT.numamem | Bin 4609 -> 4357 bytes
  .../data/acpi/loongarch64/virt/DSDT.topology  | Bin 4905 -> 4653 bytes
  6 files changed, 1 insertion(+), 12 deletions(-)

Removing _STA works on some x86 windows and linux guest OSs by testing, with LoongArch it works well on Linux guest OS.

For this series:

#7 lore raw
In reply to pillow
Quoted 23 lines · pillow

This series fixes the UART description for LoongArch virt.

The ACPI _DSD property built for the UART has three problems: the property name is misspelled, the key and value order is reversed, and it describes a 100 MHz clock that does not match the device model. The property can be dropped directly because the UART model's input clock matches the Linux 8250 PnP driver default of 1,843,200 Hz, so no _DSD override is needed.

The _CCA property is also unnecessary. _CCA describes a device's DMA cache coherency attribute, and this UART does not support DMA, so there is no reason to declare it.

The UART clock frequency in the FDT is corrected to 1,843,200 Hz, and the expected ACPI tables are updated accordingly.

pillow (5):
bios-tables-test-allowed-diff.h: Allow LoongArch DSDT.* hw/loongarch/virt-acpi-build: Drop invalid _DSD UART clock property hw/loongarch/virt-acpi-build: Drop UART _CCA declaration hw/loongarch/virt: Fix UART clock frequency in FDT tests/data/acpi/loongarch64: Update expected DSDT.*

Quoted 8 lines
  hw/loongarch/virt-acpi-build.c                |  11 -----------
  hw/loongarch/virt-fdt-build.c                 |   2 +-
  tests/data/acpi/loongarch64/virt/DSDT         | Bin 4603 -> 4351 bytes
  tests/data/acpi/loongarch64/virt/DSDT.memhp   | Bin 5824 -> 5572 bytes
  tests/data/acpi/loongarch64/virt/DSDT.numamem | Bin 4609 -> 4357 bytes
  .../data/acpi/loongarch64/virt/DSDT.topology  | Bin 4905 -> 4653 bytes
  6 files changed, 1 insertion(+), 12 deletions(-)

Hi!

Should this change be picked up fr current qemu stable releases?

Thanks,

/mjt

#8 lore raw
Quoted 33 lines · Michael Tokarev
Quoted 23 lines · pillow

This series fixes the UART description for LoongArch virt.

The ACPI _DSD property built for the UART has three problems: the property name is misspelled, the key and value order is reversed, and it describes a 100 MHz clock that does not match the device model. The property can be dropped directly because the UART model's input clock matches the Linux 8250 PnP driver default of 1,843,200 Hz, so no _DSD override is needed.

The _CCA property is also unnecessary.  _CCA describes a device's DMA cache coherency attribute, and this UART does not support DMA, so there is no reason to declare it.

The UART clock frequency in the FDT is corrected to 1,843,200 Hz, and the expected ACPI tables are updated accordingly.

pillow (5):
   bios-tables-test-allowed-diff.h: Allow LoongArch DSDT.* hw/loongarch/virt-acpi-build: Drop invalid _DSD UART clock property hw/loongarch/virt-acpi-build: Drop UART _CCA declaration hw/loongarch/virt: Fix UART clock frequency in FDT tests/data/acpi/loongarch64: Update expected DSDT.*

Quoted 8 lines

  hw/loongarch/virt-acpi-build.c                |  11 ----------- hw/loongarch/virt-fdt-build.c                 |   2 +- tests/data/acpi/loongarch64/virt/DSDT         | Bin 4603 -> 4351 bytes tests/data/acpi/loongarch64/virt/DSDT.memhp   | Bin 5824 -> 5572 bytes tests/data/acpi/loongarch64/virt/DSDT.numamem | Bin 4609 -> 4357 bytes .../data/acpi/loongarch64/virt/DSDT.topology  | Bin 4905 -> 4653 bytes

  6 files changed, 1 insertion(+), 12 deletions(-)
Quoted 3 lines

Hi!

Should this change be picked up fr current qemu stable releases?

The _DSD property name of UART is misspelled, OS will use the default clock and continue to execute.

It is a problem however not urgent, so I think it is not necessary to pickup for qemu stable releases.

Regards
Bibo Mao

Quoted 4 lines

Thanks,

/mjt