Skip to contentSkip to conversation

hw/mips: Fix the Fuloong 2E machine with PMON bios

PATCH In review Philippe Mathieu-Daudé 3 participants 17 messages Jun 24, 2021 – Jul 1, 2021

lore
Share & tools
lore
#0 lore raw

cover hw/mips: Fix the Fuloong 2E machine with PMON bios

Commit 911629e6d37 ("vt82c686: Fix SMBus IO base and configuration registers") exposed a "bug" in the Bonito north bridge. Fix it and add tests.

Thanks to Zoltan for support while debugging :)

Philippe Mathieu-Daudé (5):
hw/isa/vt82c686: Replace magic numbers by definitions hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit tests/acceptance: Test Linux on the Fuloong 2E machine tests/acceptance: Test PMON on the Fuloong 2E machine

 hw/isa/vt82c686.c                          |  50 ++++++----
 hw/pci-host/bonito.c                       |  12 ++-
 MAINTAINERS                                |   1 +
 hw/pci-host/trace-events                   |   3 +
 tests/acceptance/machine_mips_fuloong2e.py | 104 +++++++++++++++++++++
 5 files changed, 151 insertions(+), 19 deletions(-)
 create mode 100644 tests/acceptance/machine_mips_fuloong2e.py
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/5 hw/isa/vt82c686: Replace magic numbers by definitions

Replace magic values of the Power Management / SMBus function (#4) by definitions from the datasheet. The result is less compact, and we can follow what the code does without having to recur to the datasheet.

---
 hw/isa/vt82c686.c | 50 +++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 17 deletions(-)
hw/isa/vt82c686.c +33 -17
index f57f3e70679..4ddcf2d398c 100644
@@ -14,6 +14,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "hw/registerfields.h"
 #include "hw/isa/vt82c686.h"
 #include "hw/pci/pci.h"
 #include "hw/qdev-properties.h"
@@ -38,6 +39,16 @@
 #define TYPE_VIA_PM "via-pm"
 OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM)
 
+REG8(PM_GEN_CFG0,                   0x40)
+REG8(PM_GEN_CFG1,                   0x41)
+FIELD(PM_GEN_CFG1, ACPI_IO_ENABLE,  7, 1)
+REG32(PM_IO_BASE,                   0x48)
+FIELD(PM_IO_BASE, ADDR,             7, 9)
+REG32(SMBUS_IO_BASE,                0x90)
+FIELD(SMBUS_IO_BASE, ADDR,          4, 12)
+REG8(SMBUS_HOST_CONFIG,             0xd2)
+FIELD(SMBUS_HOST_CONFIG, ENABLE,    0, 1)
+
 struct ViaPMState {
     PCIDevice dev;
     MemoryRegion io;
@@ -48,21 +59,24 @@ struct ViaPMState {
 
 static void pm_io_space_update(ViaPMState *s)
 {
-    uint32_t pmbase = pci_get_long(s->dev.config + 0x48) & 0xff80UL;
+    uint32_t pmbase = pci_get_long(s->dev.config + A_PM_IO_BASE);
 
     memory_region_transaction_begin();
-    memory_region_set_address(&s->io, pmbase);
-    memory_region_set_enabled(&s->io, s->dev.config[0x41] & BIT(7));
+    memory_region_set_address(&s->io, pmbase & R_PM_IO_BASE_ADDR_MASK);
+    memory_region_set_enabled(&s->io, FIELD_EX32(s->dev.config[A_PM_GEN_CFG1],
+                                      PM_GEN_CFG1, ACPI_IO_ENABLE));
     memory_region_transaction_commit();
 }
 
 static void smb_io_space_update(ViaPMState *s)
 {
-    uint32_t smbase = pci_get_long(s->dev.config + 0x90) & 0xfff0UL;
+    uint32_t smbase = pci_get_long(s->dev.config + A_SMBUS_IO_BASE);
 
     memory_region_transaction_begin();
-    memory_region_set_address(&s->smb.io, smbase);
-    memory_region_set_enabled(&s->smb.io, s->dev.config[0xd2] & BIT(0));
+    memory_region_set_address(&s->smb.io, smbase & R_SMBUS_IO_BASE_ADDR_MASK);
+    memory_region_set_enabled(&s->smb.io,
+                              FIELD_EX32(s->dev.config[A_SMBUS_HOST_CONFIG],
+                                         SMBUS_HOST_CONFIG, ENABLE));
     memory_region_transaction_commit();
 }
 
@@ -98,19 +112,21 @@ static void pm_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len)
 
     trace_via_pm_write(addr, val, len);
     pci_default_write_config(d, addr, val, len);
-    if (ranges_overlap(addr, len, 0x48, 4)) {
-        uint32_t v = pci_get_long(s->dev.config + 0x48);
-        pci_set_long(s->dev.config + 0x48, (v & 0xff80UL) | 1);
+    if (ranges_overlap(addr, len, A_PM_IO_BASE, 4)) {
+        uint32_t v = pci_get_long(s->dev.config + A_PM_IO_BASE);
+        pci_set_long(s->dev.config + A_PM_IO_BASE,
+                     (v & R_PM_IO_BASE_ADDR_MASK) | 1);
     }
-    if (range_covers_byte(addr, len, 0x41)) {
+    if (range_covers_byte(addr, len, A_PM_GEN_CFG1)) {
         pm_io_space_update(s);
     }
-    if (ranges_overlap(addr, len, 0x90, 4)) {
-        uint32_t v = pci_get_long(s->dev.config + 0x90);
-        pci_set_long(s->dev.config + 0x90, (v & 0xfff0UL) | 1);
+    if (ranges_overlap(addr, len, A_SMBUS_IO_BASE, 4)) {
+        uint32_t v = pci_get_long(s->dev.config + A_SMBUS_IO_BASE);
+        pci_set_long(s->dev.config + A_SMBUS_IO_BASE,
+                     (v & R_SMBUS_IO_BASE_ADDR_MASK) | 1);
     }
-    if (range_covers_byte(addr, len, 0xd2)) {
-        s->dev.config[0xd2] &= 0xf;
+    if (range_covers_byte(addr, len, A_SMBUS_HOST_CONFIG)) {
+        s->dev.config[A_SMBUS_HOST_CONFIG] &= 0xf;
         smb_io_space_update(s);
     }
 }
@@ -176,9 +192,9 @@ static void via_pm_reset(DeviceState *d)
     memset(s->dev.config + PCI_CONFIG_HEADER_SIZE, 0,
            PCI_CONFIG_SPACE_SIZE - PCI_CONFIG_HEADER_SIZE);
     /* Power Management IO base */
-    pci_set_long(s->dev.config + 0x48, 1);
+    pci_set_long(s->dev.config + A_PM_IO_BASE, 1);
     /* SMBus IO base */
-    pci_set_long(s->dev.config + 0x90, 1);
+    pci_set_long(s->dev.config + A_SMBUS_IO_BASE, 1);
 
     acpi_pm1_evt_reset(&s->ar);
     acpi_pm1_cnt_reset(&s->ar);
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions

Quoted 4 lines · Philippe Mathieu-Daudé

Replace magic values of the Power Management / SMBus function (#4) by definitions from the datasheet. The result is less compact, and we can follow what the code does without having to recur to the datasheet.

I'm not sure this is an improvement. With the values it's clear what is done but I can't follow how these magic constants are defined or what they do so no idea if this is still correct. I think if you want to review a device model then you should be familiar with the device or consult the data sheet. Otherwise you can't spot problems in the definition of these constants either. I'm not a fan of hiding things behind cryptic macros when you could just write it in a straightforward way that could be understood more clearly.

Regards,
BALATON Zoltan

Quoted 109 lines

---
hw/isa/vt82c686.c | 50 +++++++++++++++++++++++++++++++----------------

1 file changed, 33 insertions(+), 17 deletions(-)
hw/isa/vt82c686.c +33 -17
index f57f3e70679..4ddcf2d398c 100644
@@ -14,6 +14,7 @@
 */
 
 #include "qemu/osdep.h"
+#include "hw/registerfields.h"
 #include "hw/isa/vt82c686.h"
 #include "hw/pci/pci.h"
 #include "hw/qdev-properties.h"
@@ -38,6 +39,16 @@
 #define TYPE_VIA_PM "via-pm"
 OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM)
 
+REG8(PM_GEN_CFG0,                   0x40)
+REG8(PM_GEN_CFG1,                   0x41)
+FIELD(PM_GEN_CFG1, ACPI_IO_ENABLE,  7, 1)
+REG32(PM_IO_BASE,                   0x48)
+FIELD(PM_IO_BASE, ADDR,             7, 9)
+REG32(SMBUS_IO_BASE,                0x90)
+FIELD(SMBUS_IO_BASE, ADDR,          4, 12)
+REG8(SMBUS_HOST_CONFIG,             0xd2)
+FIELD(SMBUS_HOST_CONFIG, ENABLE,    0, 1)
+
 struct ViaPMState {
    PCIDevice dev;
    MemoryRegion io;
@@ -48,21 +59,24 @@ struct ViaPMState {
 
 static void pm_io_space_update(ViaPMState *s)
 {
-    uint32_t pmbase = pci_get_long(s->dev.config + 0x48) & 0xff80UL;
+    uint32_t pmbase = pci_get_long(s->dev.config + A_PM_IO_BASE);
 
    memory_region_transaction_begin();
-    memory_region_set_address(&s->io, pmbase);
-    memory_region_set_enabled(&s->io, s->dev.config[0x41] & BIT(7));
+    memory_region_set_address(&s->io, pmbase & R_PM_IO_BASE_ADDR_MASK);
+    memory_region_set_enabled(&s->io, FIELD_EX32(s->dev.config[A_PM_GEN_CFG1],
+                                      PM_GEN_CFG1, ACPI_IO_ENABLE));
    memory_region_transaction_commit();
 }
 
 static void smb_io_space_update(ViaPMState *s)
 {
-    uint32_t smbase = pci_get_long(s->dev.config + 0x90) & 0xfff0UL;
+    uint32_t smbase = pci_get_long(s->dev.config + A_SMBUS_IO_BASE);
 
    memory_region_transaction_begin();
-    memory_region_set_address(&s->smb.io, smbase);
-    memory_region_set_enabled(&s->smb.io, s->dev.config[0xd2] & BIT(0));
+    memory_region_set_address(&s->smb.io, smbase & R_SMBUS_IO_BASE_ADDR_MASK);
+    memory_region_set_enabled(&s->smb.io,
+                              FIELD_EX32(s->dev.config[A_SMBUS_HOST_CONFIG],
+                                         SMBUS_HOST_CONFIG, ENABLE));
    memory_region_transaction_commit();
 }
 
@@ -98,19 +112,21 @@ static void pm_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len)
 
    trace_via_pm_write(addr, val, len);
    pci_default_write_config(d, addr, val, len);
-    if (ranges_overlap(addr, len, 0x48, 4)) {
-        uint32_t v = pci_get_long(s->dev.config + 0x48);
-        pci_set_long(s->dev.config + 0x48, (v & 0xff80UL) | 1);
+    if (ranges_overlap(addr, len, A_PM_IO_BASE, 4)) {
+        uint32_t v = pci_get_long(s->dev.config + A_PM_IO_BASE);
+        pci_set_long(s->dev.config + A_PM_IO_BASE,
+                     (v & R_PM_IO_BASE_ADDR_MASK) | 1);
    }
-    if (range_covers_byte(addr, len, 0x41)) {
+    if (range_covers_byte(addr, len, A_PM_GEN_CFG1)) {
        pm_io_space_update(s);
    }
-    if (ranges_overlap(addr, len, 0x90, 4)) {
-        uint32_t v = pci_get_long(s->dev.config + 0x90);
-        pci_set_long(s->dev.config + 0x90, (v & 0xfff0UL) | 1);
+    if (ranges_overlap(addr, len, A_SMBUS_IO_BASE, 4)) {
+        uint32_t v = pci_get_long(s->dev.config + A_SMBUS_IO_BASE);
+        pci_set_long(s->dev.config + A_SMBUS_IO_BASE,
+                     (v & R_SMBUS_IO_BASE_ADDR_MASK) | 1);
    }
-    if (range_covers_byte(addr, len, 0xd2)) {
-        s->dev.config[0xd2] &= 0xf;
+    if (range_covers_byte(addr, len, A_SMBUS_HOST_CONFIG)) {
+        s->dev.config[A_SMBUS_HOST_CONFIG] &= 0xf;
        smb_io_space_update(s);
    }
 }
@@ -176,9 +192,9 @@ static void via_pm_reset(DeviceState *d)
    memset(s->dev.config + PCI_CONFIG_HEADER_SIZE, 0,
           PCI_CONFIG_SPACE_SIZE - PCI_CONFIG_HEADER_SIZE);
    /* Power Management IO base */
-    pci_set_long(s->dev.config + 0x48, 1);
+    pci_set_long(s->dev.config + A_PM_IO_BASE, 1);
    /* SMBus IO base */
-    pci_set_long(s->dev.config + 0x90, 1);
+    pci_set_long(s->dev.config + A_SMBUS_IO_BASE, 1);
 
    acpi_pm1_evt_reset(&s->ar);
    acpi_pm1_cnt_reset(&s->ar);
#3 lore raw

PATCH 2/5 hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit

In reply to Philippe Mathieu-Daudé

Per the datasheet section "5.7.5. Accessing PCI configuration space" the address must be 32-bit aligned. Trace eventual accesses not aligned to 32-bit.

---
 hw/pci-host/bonito.c     | 8 ++++++++
 hw/pci-host/trace-events | 3 +++
 2 files changed, 11 insertions(+)
hw/pci-host/bonito.c +8 -0
index afb3d1f81d5..751fdcec689 100644
@@ -52,6 +52,7 @@
 #include "hw/misc/unimp.h"
 #include "hw/registerfields.h"
 #include "qom/object.h"
+#include "trace.h"
 
 /* #define DEBUG_BONITO */
 
@@ -185,6 +186,7 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define BONITO_PCICONF_IDSEL_OFFSET    11
 #define BONITO_PCICONF_FUN_MASK        0x700    /* [10:8] */
 #define BONITO_PCICONF_FUN_OFFSET      8
+#define BONITO_PCICONF_REG_MASK_DS     (~3)         /* Per datasheet */
 #define BONITO_PCICONF_REG_MASK        0xFC
 #define BONITO_PCICONF_REG_OFFSET      0
 
@@ -495,6 +497,9 @@ static void bonito_spciconf_write(void *opaque, hwaddr addr, uint64_t val,
     if (pciaddr == 0xffffffff) {
         return;
     }
+    if (addr & ~BONITO_PCICONF_REG_MASK_DS) {
+        trace_bonito_spciconf_small_access(addr, size);
+    }
 
     /* set the pci address in s->config_reg */
     phb->config_reg = (pciaddr) | (1u << 31);
@@ -521,6 +526,9 @@ static uint64_t bonito_spciconf_read(void *opaque, hwaddr addr, unsigned size)
     if (pciaddr == 0xffffffff) {
         return MAKE_64BIT_MASK(0, size * 8);
     }
+    if (addr & ~BONITO_PCICONF_REG_MASK_DS) {
+        trace_bonito_spciconf_small_access(addr, size);
+    }
 
     /* set the pci address in s->config_reg */
     phb->config_reg = (pciaddr) | (1u << 31);
hw/pci-host/trace-events +3 -0
index f4b3a50cb0b..630e9fcc5e7 100644
@@ -1,5 +1,8 @@
 # See docs/devel/tracing.rst for syntax documentation.
 
+# bonito.c
+bonito_spciconf_small_access(uint64_t addr, unsigned size) "PCI config address is smaller then 32-bit, addr: 0x%"PRIx64", size: %u"
+
 # grackle.c
 grackle_set_irq(int irq_num, int level) "set_irq num %d level %d"
 
Signature · 1 line
2.31.1
#4 lore raw

PATCH 3/5 hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit

In reply to Philippe Mathieu-Daudé

When running the official PMON firmware for the Fuloong 2E, we see 8-bit and 16-bit accesses to PCI config space:

  $ qemu-system-mips64el -M fuloong2e -bios pmon_2e.bin \
    -trace -trace bonito\* -trace pci_cfg\*

pci_cfg_write vt82c686b-pm 05:4 @0x90 <- 0xeee1
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x4d2, size: 2 pci_cfg_write vt82c686b-pm 05:4 @0xd2 <- 0x1
pci_cfg_write vt82c686b-pm 05:4 @0x4 <- 0x1
pci_cfg_write vt82c686b-isa 05:0 @0x4 <- 0x7
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x81, size: 1 pci_cfg_read vt82c686b-isa 05:0 @0x81 -> 0x0
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x81, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x81 <- 0x80
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x83, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x83 <- 0x89
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x85, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x85 <- 0x3
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x5a, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x5a <- 0x7
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x85, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x85 <- 0x1

Also this is what the Linux kernel does since it supports the Bonito north bridge:
https://elixir.bootlin.com/linux/v2.6.15/source/arch/mips/pci/ops-bonito64.c#L85

So it seems safe to assume the datasheet is incomplete or outdated regarding the address constraints.

This problem was exposed by commit 911629e6d3773a8adeab48b ("vt82c686: Fix SMBus IO base and configuration registers").

---
 hw/pci-host/bonito.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/bonito.c +2 -2
index 751fdcec689..3c10608c9a2 100644
@@ -187,7 +187,7 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define BONITO_PCICONF_FUN_MASK        0x700    /* [10:8] */
 #define BONITO_PCICONF_FUN_OFFSET      8
 #define BONITO_PCICONF_REG_MASK_DS     (~3)         /* Per datasheet */
-#define BONITO_PCICONF_REG_MASK        0xFC
+#define BONITO_PCICONF_REG_MASK_HW     0xff         /* As seen on hardware */
 #define BONITO_PCICONF_REG_OFFSET      0
 
 
@@ -466,7 +466,7 @@ static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)
              BONITO_PCICONF_IDSEL_OFFSET;
     devno = ctz32(idsel);
     funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
-    regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
+    regno = (cfgaddr & BONITO_PCICONF_REG_MASK_HW) >> BONITO_PCICONF_REG_OFFSET;
 
     if (idsel == 0) {
         error_report("error in bonito pci config address 0x" TARGET_FMT_plx
Signature · 1 line
2.31.1
#5 lore raw

Re: [PATCH 3/5] hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit

Quoted 46 lines · Philippe Mathieu-Daudé

When running the official PMON firmware for the Fuloong 2E, we see 8-bit and 16-bit accesses to PCI config space:

 $ qemu-system-mips64el -M fuloong2e -bios pmon_2e.bin \
   -trace -trace bonito\* -trace pci_cfg\*

pci_cfg_write vt82c686b-pm 05:4 @0x90 <- 0xeee1
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x4d2, size: 2 pci_cfg_write vt82c686b-pm 05:4 @0xd2 <- 0x1
pci_cfg_write vt82c686b-pm 05:4 @0x4 <- 0x1
pci_cfg_write vt82c686b-isa 05:0 @0x4 <- 0x7
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x81, size: 1 pci_cfg_read vt82c686b-isa 05:0 @0x81 -> 0x0
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x81, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x81 <- 0x80
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x83, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x83 <- 0x89
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x85, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x85 <- 0x3
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x5a, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x5a <- 0x7
bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x85, size: 1 pci_cfg_write vt82c686b-isa 05:0 @0x85 <- 0x1

Also this is what the Linux kernel does since it supports the Bonito north bridge:
https://elixir.bootlin.com/linux/v2.6.15/source/arch/mips/pci/ops-bonito64.c#L85

So it seems safe to assume the datasheet is incomplete or outdated regarding the address constraints.

This problem was exposed by commit 911629e6d3773a8adeab48b ("vt82c686: Fix SMBus IO base and configuration registers").

---
hw/pci-host/bonito.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci-host/bonito.c +0 -0
index 751fdcec689..3c10608c9a2 100644

hw/pci-host/bonito.c FIELD(BONGENCFG, PCIQUEUE, 12, 1) · line 190

Quoted 5 lines
hw/pci-host/bonito.c +1 -1
@@ -187,7 +187,7 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define BONITO_PCICONF_FUN_MASK        0x700    /* [10:8] */
 #define BONITO_PCICONF_FUN_OFFSET      8
 #define BONITO_PCICONF_REG_MASK_DS     (~3)         /* Per datasheet */
-#define BONITO_PCICONF_REG_MASK        0xFC
+#define BONITO_PCICONF_REG_MASK_HW     0xff         /* As seen on hardware */

I think we didn't really see it on hardware just inferred this from what the firmware does. That's a slight difference but may worth noting so people later don't think this was really tested with real hardware. Maybe "As seen with PMON"? Also if this is a loongson thing as was thought in the thread in December then maybe the #define could be named that instead of _HW so if somebody wants to reuse this model later ad Bonito then know that it implements the Loongson version.

Regards,
BALATON Zoltan

Quoted 13 lines
hw/pci-host/bonito.c +1 -1
 #define BONITO_PCICONF_REG_OFFSET      0
 
 
@@ -466,7 +466,7 @@ static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)
             BONITO_PCICONF_IDSEL_OFFSET;
    devno = ctz32(idsel);
    funno = (cfgaddr & BONITO_PCICONF_FUN_MASK) >> BONITO_PCICONF_FUN_OFFSET;
-    regno = (cfgaddr & BONITO_PCICONF_REG_MASK) >> BONITO_PCICONF_REG_OFFSET;
+    regno = (cfgaddr & BONITO_PCICONF_REG_MASK_HW) >> BONITO_PCICONF_REG_OFFSET;
 
    if (idsel == 0) {
        error_report("error in bonito pci config address 0x" TARGET_FMT_plx
#6 lore raw

Re: [PATCH 3/5] hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit

Quoted 50 lines · BALATON Zoltan
Quoted 49 lines · Philippe Mathieu-Daudé

When running the official PMON firmware for the Fuloong 2E, we see 8-bit and 16-bit accesses to PCI config space:

 $ qemu-system-mips64el -M fuloong2e -bios pmon_2e.bin \
   -trace -trace bonito\* -trace pci_cfg\*

 pci_cfg_write vt82c686b-pm 05:4 @0x90 <- 0xeee1 bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x4d2, size: 2
 pci_cfg_write vt82c686b-pm 05:4 @0xd2 <- 0x1 pci_cfg_write vt82c686b-pm 05:4 @0x4 <- 0x1 pci_cfg_write vt82c686b-isa 05:0 @0x4 <- 0x7 bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x81, size: 1
 pci_cfg_read vt82c686b-isa 05:0 @0x81 -> 0x0 bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x81, size: 1
 pci_cfg_write vt82c686b-isa 05:0 @0x81 <- 0x80 bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x83, size: 1
 pci_cfg_write vt82c686b-isa 05:0 @0x83 <- 0x89 bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x85, size: 1
 pci_cfg_write vt82c686b-isa 05:0 @0x85 <- 0x3 bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x5a, size: 1
 pci_cfg_write vt82c686b-isa 05:0 @0x5a <- 0x7 bonito_spciconf_small_access PCI config address is smaller then 32-bit, addr: 0x85, size: 1
 pci_cfg_write vt82c686b-isa 05:0 @0x85 <- 0x1

Also this is what the Linux kernel does since it supports the Bonito north bridge:
https://elixir.bootlin.com/linux/v2.6.15/source/arch/mips/pci/ops-bonito64.c#L85

So it seems safe to assume the datasheet is incomplete or outdated regarding the address constraints.

This problem was exposed by commit 911629e6d3773a8adeab48b ("vt82c686: Fix SMBus IO base and configuration registers").

---
hw/pci-host/bonito.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 11 lines
hw/pci-host/bonito.c +1 -1
index 751fdcec689..3c10608c9a2 100644
@@ -187,7 +187,7 @@ FIELD(BONGENCFG, PCIQUEUE,      12, 1)
 #define BONITO_PCICONF_FUN_MASK        0x700    /* [10:8] */
 #define BONITO_PCICONF_FUN_OFFSET      8
 #define BONITO_PCICONF_REG_MASK_DS     (~3)         /* Per datasheet */
-#define BONITO_PCICONF_REG_MASK        0xFC
+#define BONITO_PCICONF_REG_MASK_HW     0xff         /* As seen on

hardware */

I think we didn't really see it on hardware just inferred this from what the firmware does. That's a slight difference but may worth noting so people later don't think this was really tested with real hardware. Maybe "As seen with PMON"?

OK.

Quoted 4 lines

Also if this is a loongson thing as was
thought in the thread in December then maybe the #define could be named that instead of _HW so if somebody wants to reuse this model later ad Bonito then know that it implements the Loongson version.

Bonito64 is what is modelled. This is what I checked from the Linux kernel:
https://elixir.bootlin.com/linux/v2.6.15/source/arch/mips/pci/ops-bonito64.c#L85

#7 lore raw

PATCH 4/5 tests/acceptance: Test Linux on the Fuloong 2E machine

In reply to Philippe Mathieu-Daudé

Test the kernel from Lemote rescue image:
http://dev.lemote.com/files/resource/download/rescue/rescue-yl
Once downloaded, set the RESCUE_YL_PATH environment variable to point to the downloaded image and test as:

  $ RESCUE_YL_PATH=~/images/fuloong2e/rescue-yl \
    AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
    avocado --show=app,console run tests/acceptance/machine_mips_fuloong2e.py
  Fetching asset from tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial
   (1/1) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:
  console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
  console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
  console: console [early0] enabled
  console: CPU revision is: 00006302 (ICT Loongson-2)
  PASS (0.16 s)
  JOB TIME   : 0.51 s
---
 MAINTAINERS                                |  1 +
 tests/acceptance/machine_mips_fuloong2e.py | 42 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 tests/acceptance/machine_mips_fuloong2e.py
MAINTAINERS +1 -0
index 1a041eaf864..1c515b4ba14 100644
@@ -1176,6 +1176,7 @@ F: hw/isa/vt82c686.c
 F: hw/pci-host/bonito.c
 F: hw/usb/vt82c686-uhci-pci.c
 F: include/hw/isa/vt82c686.h
+F: tests/acceptance/machine_mips_fuloong2e.py
 
 Loongson-3 virtual platforms
 M: Huacai Chen <[email protected]>
tests/acceptance/machine_mips_fuloong2e.py new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.31.1
Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] tests/acceptance: Test Linux on the Fuloong 2E machine

Quoted 17 lines · Philippe Mathieu-Daudé

Test the kernel from Lemote rescue image:
http://dev.lemote.com/files/resource/download/rescue/rescue-yl
Once downloaded, set the RESCUE_YL_PATH environment variable to point to the downloaded image and test as:

   $ RESCUE_YL_PATH=~/images/fuloong2e/rescue-yl \
     AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
     avocado --show=app,console run tests/acceptance/machine_mips_fuloong2e.py
   Fetching asset from tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial
    (1/1) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:
   console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
   console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
   console: console [early0] enabled
   console: CPU revision is: 00006302 (ICT Loongson-2)
   PASS (0.16 s)
   JOB TIME   : 0.51 s
Quoted 6 lines
---
  MAINTAINERS                                |  1 +
  tests/acceptance/machine_mips_fuloong2e.py | 42 ++++++++++++++++++++++
  2 files changed, 43 insertions(+)

create mode 100644 tests/acceptance/machine_mips_fuloong2e.py

Quoted 61 lines
MAINTAINERS +1 -0
index 1a041eaf864..1c515b4ba14 100644
@@ -1176,6 +1176,7 @@ F: hw/isa/vt82c686.c
  F: hw/pci-host/bonito.c
  F: hw/usb/vt82c686-uhci-pci.c
  F: include/hw/isa/vt82c686.h
+F: tests/acceptance/machine_mips_fuloong2e.py
 
  Loongson-3 virtual platforms
  M: Huacai Chen <[email protected]>
tests/acceptance/machine_mips_fuloong2e.py new file +42 -0
new file mode 100644
index 00000000000..0ac285e2af1
@@ -0,0 +1,42 @@
+# Functional tests for the Lemote Fuloong-2E machine.
+#
+# Copyright (c) 2019 Philippe Mathieu-Daudé <[email protected]>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+
+from avocado import skipUnless
+from avocado_qemu import Test
+from avocado_qemu import wait_for_console_pattern
+
+class MipsFuloong2e(Test):
+
+    timeout = 60
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('RESCUE_YL_PATH'), 'RESCUE_YL_PATH not available')
+    def test_linux_kernel_isa_serial(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        # Recovery system for the Yeeloong laptop
+        # (enough to test the fuloong2e southbridge, accessing its ISA bus)
+        # http://dev.lemote.com/files/resource/download/rescue/rescue-yl
+        kernel_hash = 'ec4d1bd89a8439c41033ca63db60160cc6d6f09a'
+        kernel_path = self.fetch_asset('file://' + os.getenv('RESCUE_YL_PATH'),
+                                       asset_hash=kernel_hash)
+
+        self.vm.set_console()
+        self.vm.add_args('-kernel', kernel_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'Linux version 2.6.27.7lemote')
+        cpu_revision = 'CPU revision is: 00006302 (ICT Loongson-2)'
+        wait_for_console_pattern(self, cpu_revision)
#9 lore raw

PATCH 5/5 tests/acceptance: Test PMON on the Fuloong 2E machine

In reply to Philippe Mathieu-Daudé

Test the PMON firmware. As the firmware is not redistributable, it has to be downloaded manually first. Then it can be used by providing its path via the PMON_BIN_PATH environment variable:

  $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
    AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
    avocado --show=app,console run tests/acceptance/machine_mips_fuloong2e.py
  Fetching asset from tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial
   (1/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:
  console: PMON2000 MIPS Initializing. Standby...
  console: ERRORPC=00000000 CONFIG=00030932
  console: PRID=00006302
  console: Init SDRAM Done!
  console: Sizing caches...
  console: Init caches...
  console: godson2 caches found
  console: Init caches done, cfg = 00030932
  console: Copy PMON to execute location...
  console: copy text section done.
  console: Copy PMON to execute location done.
  Uncompressing Bios........................OK,Booting Bios
  PASS (0.25 s)
   (2/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:
  [...]
  Uncompressing Bios........................OK,Booting Bios
  console: FREQ
  console: FREI
  console: DONE
  console: TTYI
  console: TTYD
  console: ENVI
  console: MAPV
  console: Mfg  0, Id 60
  console: STDV
  console: SBDD
  console: PPCIH
  console: PCIS
  console: PCIR
  console: PCIW
  console: NETI
  console: RTCL
  console: PCID
  console: VGAI
  console: Default MODE_ID 2
  console: starting radeon init...
  console: radeon init done
  console: FRBI
  console: cfb_console init,fb=b4000000
  console: Video: Drawing the logo ...
  console: CONSOLE_SIZE 450560HSTI
  PASS (4.10 s)
   (3/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:
  console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
  console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
  console: console [early0] enabled
  console: CPU revision is: 00006302 (ICT Loongson-2)
  PASS (0.19 s)
  RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
  JOB TIME   : 5.10 s
---
 tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)
tests/acceptance/machine_mips_fuloong2e.py +62 -0
index 0ac285e2af1..4854ba98560 100644
@@ -8,15 +8,77 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 import os
+import time
 
 from avocado import skipUnless
 from avocado_qemu import Test
 from avocado_qemu import wait_for_console_pattern
 
+from tesseract_utils import tesseract_available, tesseract_ocr
+
 class MipsFuloong2e(Test):
 
     timeout = 60
 
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm')
+
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')
+        self.vm.launch()
+
+        wait_for_console_pattern(self, 'Video: Drawing the logo ...')
+        self.log.info('VM launched, waiting for logo on display')
+        time.sleep(2)
+        wait_for_console_pattern(self, 'CONSOLE_SIZE')
+        self.vm.command('human-monitor-command', command_line='stop')
+        self.vm.command('human-monitor-command',
+                        command_line='screendump %s' % screenshot_path)
+
+        lines = tesseract_ocr(screenshot_path, tesseract_version=4,
+                              tesseract_args='--dpi 128')
+        pmon_version = 'PNON2000 for Loongson, Version 1.1.2' # PNON is enough
+        self.assertIn(pmon_version, lines)
+
     @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
     @skipUnless(os.getenv('RESCUE_YL_PATH'), 'RESCUE_YL_PATH not available')
     def test_linux_kernel_isa_serial(self):
Signature · 1 line
2.31.1
#10 lore raw

Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine

Quoted 119 lines · Philippe Mathieu-Daudé

Test the PMON firmware. As the firmware is not redistributable, it has to be downloaded manually first. Then it can be used by providing its path via the PMON_BIN_PATH environment variable:

 $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
   AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
   avocado --show=app,console run tests/acceptance/machine_mips_fuloong2e.py
 Fetching asset from tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial
  (1/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:
 console: PMON2000 MIPS Initializing. Standby...
 console: ERRORPC=00000000 CONFIG=00030932
 console: PRID=00006302
 console: Init SDRAM Done!
 console: Sizing caches...
 console: Init caches...
 console: godson2 caches found
 console: Init caches done, cfg = 00030932
 console: Copy PMON to execute location...
 console: copy text section done.
 console: Copy PMON to execute location done.
 Uncompressing Bios........................OK,Booting Bios
 PASS (0.25 s)
  (2/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:
 [...]
 Uncompressing Bios........................OK,Booting Bios
 console: FREQ
 console: FREI
 console: DONE
 console: TTYI
 console: TTYD
 console: ENVI
 console: MAPV
 console: Mfg  0, Id 60
 console: STDV
 console: SBDD
 console: PPCIH
 console: PCIS
 console: PCIR
 console: PCIW
 console: NETI
 console: RTCL
 console: PCID
 console: VGAI
 console: Default MODE_ID 2
 console: starting radeon init...
 console: radeon init done
 console: FRBI
 console: cfb_console init,fb=b4000000
 console: Video: Drawing the logo ...
 console: CONSOLE_SIZE 450560HSTI
 PASS (4.10 s)
  (3/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:
 console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
 console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
 console: console [early0] enabled
 console: CPU revision is: 00006302 (ICT Loongson-2)
 PASS (0.19 s)
 RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 5.10 s

---
tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++

1 file changed, 62 insertions(+)
tests/acceptance/machine_mips_fuloong2e.py +0 -0
index 0ac285e2af1..4854ba98560 100644
@@ -8,15 +8,77 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 

import os
+import time

from avocado import skipUnless
from avocado_qemu import Test
from avocado_qemu import wait_for_console_pattern

tests/acceptance/machine_mips_fuloong2e.py +2 -0
+from tesseract_utils import tesseract_available, tesseract_ocr
+

class MipsFuloong2e(Test):

timeout = 60

tests/acceptance/machine_mips_fuloong2e.py +34 -0
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """

tests/acceptance/machine_mips_fuloong2e.py line 66

Quoted 10 lines
tests/acceptance/machine_mips_fuloong2e.py +10 -0
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm')
+
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')

I think this is the default if you just drop -vga std so I don't know why you have that in the first place but then you should not need to add ati-vga explicitely.

Regards,
BALATON Zoltan

Quoted 19 lines
tests/acceptance/machine_mips_fuloong2e.py +15 -0
+        self.vm.launch()
+
+        wait_for_console_pattern(self, 'Video: Drawing the logo ...')
+        self.log.info('VM launched, waiting for logo on display')
+        time.sleep(2)
+        wait_for_console_pattern(self, 'CONSOLE_SIZE')
+        self.vm.command('human-monitor-command', command_line='stop')
+        self.vm.command('human-monitor-command',
+                        command_line='screendump %s' % screenshot_path)
+
+        lines = tesseract_ocr(screenshot_path, tesseract_version=4,
+                              tesseract_args='--dpi 128')
+        pmon_version = 'PNON2000 for Loongson, Version 1.1.2' # PNON is enough
+        self.assertIn(pmon_version, lines)
+
    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
    @skipUnless(os.getenv('RESCUE_YL_PATH'), 'RESCUE_YL_PATH not available')
    def test_linux_kernel_isa_serial(self):
#11 lore raw

Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine

Quoted 152 lines · BALATON Zoltan
Quoted 151 lines · Philippe Mathieu-Daudé

Test the PMON firmware. As the firmware is not redistributable, it has to be downloaded manually first. Then it can be used by providing its path via the PMON_BIN_PATH environment variable:

 $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
   AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
   avocado --show=app,console run
tests/acceptance/machine_mips_fuloong2e.py
 Fetching asset from
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial

  (1/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:

 console: PMON2000 MIPS Initializing. Standby...
 console: ERRORPC=00000000 CONFIG=00030932
 console: PRID=00006302
 console: Init SDRAM Done!
 console: Sizing caches...
 console: Init caches...
 console: godson2 caches found
 console: Init caches done, cfg = 00030932
 console: Copy PMON to execute location...
 console: copy text section done.
 console: Copy PMON to execute location done.
 Uncompressing Bios........................OK,Booting Bios
 PASS (0.25 s)
  (2/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:

 [...]
 Uncompressing Bios........................OK,Booting Bios
 console: FREQ
 console: FREI
 console: DONE
 console: TTYI
 console: TTYD
 console: ENVI
 console: MAPV
 console: Mfg  0, Id 60
 console: STDV
 console: SBDD
 console: PPCIH
 console: PCIS
 console: PCIR
 console: PCIW
 console: NETI
 console: RTCL
 console: PCID
 console: VGAI
 console: Default MODE_ID 2
 console: starting radeon init...
 console: radeon init done
 console: FRBI
 console: cfb_console init,fb=b4000000
 console: Video: Drawing the logo ...
 console: CONSOLE_SIZE 450560HSTI
 PASS (4.10 s)
  (3/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:

 console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
 console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
 console: console [early0] enabled
 console: CPU revision is: 00006302 (ICT Loongson-2)
 PASS (0.19 s)
 RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 5.10 s

---
tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++

1 file changed, 62 insertions(+)
tests/acceptance/machine_mips_fuloong2e.py +0 -0
index 0ac285e2af1..4854ba98560 100644
@@ -8,15 +8,77 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 

import os
+import time

from avocado import skipUnless
from avocado_qemu import Test
from avocado_qemu import wait_for_console_pattern

tests/acceptance/machine_mips_fuloong2e.py +2 -0
+from tesseract_utils import tesseract_available, tesseract_ocr
+

class MipsFuloong2e(Test):

    timeout = 60

+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm') +
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+

Quoted 8 lines
Quoted 4 lines

+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')

I think this is the default if you just drop -vga std so I don't know why you have that in the first place but then you should not need to add ati-vga explicitely.

I thought this is what you asked me here:
https://www.mail-archive.com/[email protected]/msg753832.html

Currently:

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
console: iobase=bfd0a200,mmbase=b6064000
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: ppll_div_3 = 301f4
console: Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
console: Wrote: rd=67, fd=500, pd=3
console: VCLK_ECP_CNTL = 000000C3
console: radeon init done
console: FRBI
console: cfb_console init,fb=b5000000
console: Video: Drawing the logo ...
console: CONSOLE_SIZE 450560HSTI
PASS (4.53 s)

Without '-vga std -device ati-vga,model=rv100':

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
INTERRUPTED: Test interrupted by SIGTERM Runner error occurred: Timeout reached... (60.29 s)

With '-vga std':

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
console: iobase=bfd0a200,mmbase=b6064000
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: ppll_div_3 = 301f4
console: Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
console: Wrote: rd=67, fd=500, pd=3
console: VCLK_ECP_CNTL = 000000C3
console: radeon init done
console: FRBI
console: cfb_console init,fb=b5000000
console: Video: Drawing the logo ...
console: CONSOLE_SIZE 450560HSTI
PASS (4.34 s)

So I'll simply keep "-vga std".

Thanks,

Phil.

#12 lore raw

Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine

Quoted 162 lines · Philippe Mathieu-Daudé
Quoted 152 lines · BALATON Zoltan
Quoted 151 lines · Philippe Mathieu-Daudé

Test the PMON firmware. As the firmware is not redistributable, it has to be downloaded manually first. Then it can be used by providing its path via the PMON_BIN_PATH environment variable:

 $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
   AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
   avocado --show=app,console run
tests/acceptance/machine_mips_fuloong2e.py
 Fetching asset from
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial

  (1/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:

 console: PMON2000 MIPS Initializing. Standby...
 console: ERRORPC=00000000 CONFIG=00030932
 console: PRID=00006302
 console: Init SDRAM Done!
 console: Sizing caches...
 console: Init caches...
 console: godson2 caches found
 console: Init caches done, cfg = 00030932
 console: Copy PMON to execute location...
 console: copy text section done.
 console: Copy PMON to execute location done.
 Uncompressing Bios........................OK,Booting Bios
 PASS (0.25 s)
  (2/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:

 [...]
 Uncompressing Bios........................OK,Booting Bios
 console: FREQ
 console: FREI
 console: DONE
 console: TTYI
 console: TTYD
 console: ENVI
 console: MAPV
 console: Mfg  0, Id 60
 console: STDV
 console: SBDD
 console: PPCIH
 console: PCIS
 console: PCIR
 console: PCIW
 console: NETI
 console: RTCL
 console: PCID
 console: VGAI
 console: Default MODE_ID 2
 console: starting radeon init...
 console: radeon init done
 console: FRBI
 console: cfb_console init,fb=b4000000
 console: Video: Drawing the logo ...
 console: CONSOLE_SIZE 450560HSTI
 PASS (4.10 s)
  (3/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:

 console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
 console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
 console: console [early0] enabled
 console: CPU revision is: 00006302 (ICT Loongson-2)
 PASS (0.19 s)
 RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 5.10 s

---
tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++

1 file changed, 62 insertions(+)
tests/acceptance/machine_mips_fuloong2e.py +0 -0
index 0ac285e2af1..4854ba98560 100644
@@ -8,15 +8,77 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 

import os
+import time

from avocado import skipUnless
from avocado_qemu import Test
from avocado_qemu import wait_for_console_pattern

tests/acceptance/machine_mips_fuloong2e.py +2 -0
+from tesseract_utils import tesseract_available, tesseract_ocr
+

class MipsFuloong2e(Test):

    timeout = 60

+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm') +
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+

Quoted 8 lines
Quoted 4 lines

+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')

I think this is the default if you just drop -vga std so I don't know why you have that in the first place but then you should not need to add ati-vga explicitely.

Quoted 2 lines

I thought this is what you asked me here:
https://www.mail-archive.com/[email protected]/msg753832.html

No, I've said the same in that message that fuloong2e has an ati-vga as default so no -vga option should be needed at all.

Quoted 21 lines

Currently:

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
console: iobase=bfd0a200,mmbase=b6064000
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: ppll_div_3 = 301f4
console: Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
console: Wrote: rd=67, fd=500, pd=3
console: VCLK_ECP_CNTL = 000000C3
console: radeon init done
console: FRBI
console: cfb_console init,fb=b5000000
console: Video: Drawing the logo ...
console: CONSOLE_SIZE 450560HSTI
PASS (4.53 s)

Quoted 7 lines

Without '-vga std -device ati-vga,model=rv100':

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
INTERRUPTED: Test interrupted by SIGTERM Runner error occurred: Timeout reached... (60.29 s)

That's strange (with the REG_MASK fixed to 0xff in bonito.c) I get:

$ qemu-system-mips64el -M fuloong2e -bios pmon_2e.bin -serial stdio
[...]
VGAI
Default MODE_ID 2
starting radeon init...
iobase=bfd0a100,mmbase=b5050000
mc_status=5
mc_status=5
mc_status=5
mc_status=5
ppll_div_3 = 301f4
Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
Wrote: rd=67, fd=500, pd=3
VCLK_ECP_CNTL = 000000C3
radeon init done
FRBI
cfb_console init,fb=b4000000
Video: Drawing the logo ...
CONSOLE_SIZE 450560HSTI

So I think you should not need either -vga std nor -device ati-vga as those would add another VGA card to the one already on the board.

Regards,
BALATON Zoltan

Quoted 28 lines

With '-vga std':

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
console: iobase=bfd0a200,mmbase=b6064000
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: ppll_div_3 = 301f4
console: Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
console: Wrote: rd=67, fd=500, pd=3
console: VCLK_ECP_CNTL = 000000C3
console: radeon init done
console: FRBI
console: cfb_console init,fb=b5000000
console: Video: Drawing the logo ...
console: CONSOLE_SIZE 450560HSTI
PASS (4.34 s)

So I'll simply keep "-vga std".

Thanks,

Phil.

#13 lore raw

Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine

Quoted 224 lines · BALATON Zoltan
Quoted 166 lines · Philippe Mathieu-Daudé
Quoted 156 lines · BALATON Zoltan
Quoted 155 lines · Philippe Mathieu-Daudé

Test the PMON firmware. As the firmware is not redistributable, it has to be downloaded manually first. Then it can be used by providing its path via the PMON_BIN_PATH environment variable:

 $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
   AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
   avocado --show=app,console run
tests/acceptance/machine_mips_fuloong2e.py
 Fetching asset from
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial

  (1/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:

 console: PMON2000 MIPS Initializing. Standby...
 console: ERRORPC=00000000 CONFIG=00030932
 console: PRID=00006302
 console: Init SDRAM Done!
 console: Sizing caches...
 console: Init caches...
 console: godson2 caches found
 console: Init caches done, cfg = 00030932
 console: Copy PMON to execute location...
 console: copy text section done.
 console: Copy PMON to execute location done.
 Uncompressing Bios........................OK,Booting Bios
 PASS (0.25 s)
  (2/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:

 [...]
 Uncompressing Bios........................OK,Booting Bios
 console: FREQ
 console: FREI
 console: DONE
 console: TTYI
 console: TTYD
 console: ENVI
 console: MAPV
 console: Mfg  0, Id 60
 console: STDV
 console: SBDD
 console: PPCIH
 console: PCIS
 console: PCIR
 console: PCIW
 console: NETI
 console: RTCL
 console: PCID
 console: VGAI
 console: Default MODE_ID 2
 console: starting radeon init...
 console: radeon init done
 console: FRBI
 console: cfb_console init,fb=b4000000
 console: Video: Drawing the logo ...
 console: CONSOLE_SIZE 450560HSTI
 PASS (4.10 s)
  (3/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:

 console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
 console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
 console: console [early0] enabled
 console: CPU revision is: 00006302 (ICT Loongson-2)
 PASS (0.19 s)
 RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 5.10 s

---
tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++

1 file changed, 62 insertions(+)
tests/acceptance/machine_mips_fuloong2e.py +0 -0
index 0ac285e2af1..4854ba98560 100644
@@ -8,15 +8,77 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 

import os
+import time

from avocado import skipUnless
from avocado_qemu import Test
from avocado_qemu import wait_for_console_pattern

tests/acceptance/machine_mips_fuloong2e.py +2 -0
+from tesseract_utils import tesseract_available, tesseract_ocr
+

class MipsFuloong2e(Test):

    timeout = 60

+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm') +
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+

Quoted 8 lines
Quoted 4 lines

+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')

I think this is the default if you just drop -vga std so I don't know why you have that in the first place but then you should not need to add ati-vga explicitely.

Quoted 2 lines

I thought this is what you asked me here:
https://www.mail-archive.com/[email protected]/msg753832.html

No, I've said the same in that message that fuloong2e has an ati-vga as default so no -vga option should be needed at all.

Quoted 21 lines

Currently:

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
console: iobase=bfd0a200,mmbase=b6064000
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: ppll_div_3 = 301f4
console: Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
console: Wrote: rd=67, fd=500, pd=3
console: VCLK_ECP_CNTL = 000000C3
console: radeon init done
console: FRBI
console: cfb_console init,fb=b5000000
console: Video: Drawing the logo ...
console: CONSOLE_SIZE 450560HSTI
PASS (4.53 s)

Quoted 7 lines

Without '-vga std -device ati-vga,model=rv100':

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
INTERRUPTED: Test interrupted by SIGTERM Runner error occurred: Timeout reached... (60.29 s)

That's strange (with the REG_MASK fixed to 0xff in bonito.c) I get:

$ qemu-system-mips64el -M fuloong2e -bios pmon_2e.bin -serial stdio
[...]
VGAI
Default MODE_ID 2
starting radeon init...
iobase=bfd0a100,mmbase=b5050000
mc_status=5
mc_status=5
mc_status=5
mc_status=5
ppll_div_3 = 301f4
Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
Wrote: rd=67, fd=500, pd=3
VCLK_ECP_CNTL = 000000C3
radeon init done
FRBI
cfb_console init,fb=b4000000
Video: Drawing the logo ...
CONSOLE_SIZE 450560HSTI
Quoted 2 lines

So I think you should not need either -vga std nor -device ati-vga as those would add another VGA card to the one already on the board.

So after looking in git history, Avocado tests inherited iotests, and since commit 0fd05e8dd1e ("qemu-iotests: start vms in qtest mode") the VMs are started with -display none -vga none.
See in python/qemu/machine/machine.py:

    def _base_args(self) -> List[str]:
        args = ['-display', 'none', '-vga', 'none']

Which is why we have to use '-vga std' here.

Except if you disagree, I'll queue the patch using:

      self.vm.add_args('-bios', pmon_path,
                       '-vga', 'std')

Thanks,

Phil.

#14 lore raw

Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine

Quoted 236 lines · Philippe Mathieu-Daudé
Quoted 224 lines · BALATON Zoltan
Quoted 166 lines · Philippe Mathieu-Daudé
Quoted 156 lines · BALATON Zoltan
Quoted 155 lines · Philippe Mathieu-Daudé

Test the PMON firmware. As the firmware is not redistributable, it has to be downloaded manually first. Then it can be used by providing its path via the PMON_BIN_PATH environment variable:

 $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
   AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
   avocado --show=app,console run
tests/acceptance/machine_mips_fuloong2e.py
 Fetching asset from
tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial

  (1/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:

 console: PMON2000 MIPS Initializing. Standby...
 console: ERRORPC=00000000 CONFIG=00030932
 console: PRID=00006302
 console: Init SDRAM Done!
 console: Sizing caches...
 console: Init caches...
 console: godson2 caches found
 console: Init caches done, cfg = 00030932
 console: Copy PMON to execute location...
 console: copy text section done.
 console: Copy PMON to execute location done.
 Uncompressing Bios........................OK,Booting Bios
 PASS (0.25 s)
  (2/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:

 [...]
 Uncompressing Bios........................OK,Booting Bios
 console: FREQ
 console: FREI
 console: DONE
 console: TTYI
 console: TTYD
 console: ENVI
 console: MAPV
 console: Mfg  0, Id 60
 console: STDV
 console: SBDD
 console: PPCIH
 console: PCIS
 console: PCIR
 console: PCIW
 console: NETI
 console: RTCL
 console: PCID
 console: VGAI
 console: Default MODE_ID 2
 console: starting radeon init...
 console: radeon init done
 console: FRBI
 console: cfb_console init,fb=b4000000
 console: Video: Drawing the logo ...
 console: CONSOLE_SIZE 450560HSTI
 PASS (4.10 s)
  (3/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:

 console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
 console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
 console: console [early0] enabled
 console: CPU revision is: 00006302 (ICT Loongson-2)
 PASS (0.19 s)
 RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
 JOB TIME   : 5.10 s

---
tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++

1 file changed, 62 insertions(+)
tests/acceptance/machine_mips_fuloong2e.py +0 -0
index 0ac285e2af1..4854ba98560 100644
@@ -8,15 +8,77 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 

import os
+import time

from avocado import skipUnless
from avocado_qemu import Test
from avocado_qemu import wait_for_console_pattern

tests/acceptance/machine_mips_fuloong2e.py +2 -0
+from tesseract_utils import tesseract_available, tesseract_ocr
+

class MipsFuloong2e(Test):

    timeout = 60

+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm') +
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2 +        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+

Quoted 8 lines
Quoted 4 lines

+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')

I think this is the default if you just drop -vga std so I don't know why you have that in the first place but then you should not need to add ati-vga explicitely.

Quoted 2 lines

I thought this is what you asked me here:
https://www.mail-archive.com/[email protected]/msg753832.html

No, I've said the same in that message that fuloong2e has an ati-vga as default so no -vga option should be needed at all.

Quoted 21 lines

Currently:

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
console: iobase=bfd0a200,mmbase=b6064000
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: mc_status=5
console: ppll_div_3 = 301f4
console: Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
console: Wrote: rd=67, fd=500, pd=3
console: VCLK_ECP_CNTL = 000000C3
console: radeon init done
console: FRBI
console: cfb_console init,fb=b5000000
console: Video: Drawing the logo ...
console: CONSOLE_SIZE 450560HSTI
PASS (4.53 s)

Quoted 7 lines

Without '-vga std -device ati-vga,model=rv100':

console: VGAI
console: Default MODE_ID 2
console: starting radeon init...
INTERRUPTED: Test interrupted by SIGTERM Runner error occurred: Timeout reached... (60.29 s)

That's strange (with the REG_MASK fixed to 0xff in bonito.c) I get:

$ qemu-system-mips64el -M fuloong2e -bios pmon_2e.bin -serial stdio
[...]
VGAI
Default MODE_ID 2
starting radeon init...
iobase=bfd0a100,mmbase=b5050000
mc_status=5
mc_status=5
mc_status=5
mc_status=5
ppll_div_3 = 301f4
Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
Wrote: rd=67, fd=500, pd=3
VCLK_ECP_CNTL = 000000C3
radeon init done
FRBI
cfb_console init,fb=b4000000
Video: Drawing the logo ...
CONSOLE_SIZE 450560HSTI
Quoted 2 lines

So I think you should not need either -vga std nor -device ati-vga as those would add another VGA card to the one already on the board.

So after looking in git history, Avocado tests inherited iotests, and since commit 0fd05e8dd1e ("qemu-iotests: start vms in qtest mode") the VMs are started with -display none -vga none.
See in python/qemu/machine/machine.py:

   def _base_args(self) -> List[str]:
       args = ['-display', 'none', '-vga', 'none']
Quoted 6 lines

Which is why we have to use '-vga std' here.

Except if you disagree, I'll queue the patch using:

     self.vm.add_args('-bios', pmon_path,
                      '-vga', 'std')

I think it's better modelling the original machine if you use the ati-vga that the machine has instead of std vga that it doesn't. Also it tests ati-vga that way while it doesn't with -vga std. I also don't see the point having both. With this command I get:

$ qemu-system-mips64el -M fuloong2e -bios pmon_2e.bin -serial stdio -display none -vga none -device ati-vga,model=rv100

VGAI
Default MODE_ID 2
starting radeon init... iobase=bfd0a100,mmbase=b5050000
mc_status=5
mc_status=5
mc_status=5
mc_status=5
ppll_div_3 = 301f4
Wrote: 0x00000043 0x000301f4 0x00000000 (0x00000000)
Wrote: rd=67, fd=500, pd=3
VCLK_ECP_CNTL = 000000C3
radeon init done
FRBI
cfb_console init,fb=b4000000
Video: Drawing the logo ...
CONSOLE_SIZE 450560HSTI

and I think that matches the default config of the machine that -vga none turns off. What do you need std vga for?

Regards,
BALATON Zoltan

Reviewed-by on v1 5/5
#15 lore raw

Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine

In reply to Philippe Mathieu-Daudé

Hi,

Quoted 3 lines · Philippe Mathieu-Daudé

Test the PMON firmware. As the firmware is not redistributable, it has to be downloaded manually first. Then it can be used by providing its path via the PMON_BIN_PATH environment variable:

In the code it is used PMON2E_BIN_PATH.

Quoted 57 lines
   $ PMON2E_BIN_PATH=~/images/fuloong2e/pmon_2e.bin \
     AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
     avocado --show=app,console run tests/acceptance/machine_mips_fuloong2e.py
   Fetching asset from tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial
    (1/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_serial_console:
   console: PMON2000 MIPS Initializing. Standby...
   console: ERRORPC=00000000 CONFIG=00030932
   console: PRID=00006302
   console: Init SDRAM Done!
   console: Sizing caches...
   console: Init caches...
   console: godson2 caches found
   console: Init caches done, cfg = 00030932
   console: Copy PMON to execute location...
   console: copy text section done.
   console: Copy PMON to execute location done.
   Uncompressing Bios........................OK,Booting Bios
   PASS (0.25 s)
    (2/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_pmon_framebuffer_console:
   [...]
   Uncompressing Bios........................OK,Booting Bios
   console: FREQ
   console: FREI
   console: DONE
   console: TTYI
   console: TTYD
   console: ENVI
   console: MAPV
   console: Mfg  0, Id 60
   console: STDV
   console: SBDD
   console: PPCIH
   console: PCIS
   console: PCIR
   console: PCIW
   console: NETI
   console: RTCL
   console: PCID
   console: VGAI
   console: Default MODE_ID 2
   console: starting radeon init...
   console: radeon init done
   console: FRBI
   console: cfb_console init,fb=b4000000
   console: Video: Drawing the logo ...
   console: CONSOLE_SIZE 450560HSTI
   PASS (4.10 s)
    (3/3) tests/acceptance/machine_mips_fuloong2e.py:MipsFuloong2e.test_linux_kernel_isa_serial:
   console: Linux version 2.6.27.7lemote (root@debian) (gcc version 4.1.3 20080623 (prerelease) (Debian 4.1.2-23)) #6 Fri Dec 12 00:11:25 CST 2008
   console: busclock=33000000, cpuclock=-2145008360,memsize=256,highmemsize=0
   console: console [early0] enabled
   console: CPU revision is: 00006302 (ICT Loongson-2)
   PASS (0.19 s)
   RESULTS    : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
   JOB TIME   : 5.10 s
Quoted 4 lines
---
  tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
  1 file changed, 62 insertions(+)

Need to fix the commit message (or the code) as pointed above. With that,

Quoted 83 lines
tests/acceptance/machine_mips_fuloong2e.py +62 -0
index 0ac285e2af1..4854ba98560 100644
@@ -8,15 +8,77 @@
  # SPDX-License-Identifier: GPL-2.0-or-later
 
  import os
+import time
 
  from avocado import skipUnless
  from avocado_qemu import Test
  from avocado_qemu import wait_for_console_pattern
 
+from tesseract_utils import tesseract_available, tesseract_ocr
+
  class MipsFuloong2e(Test):
 
      timeout = 60
 
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_serial_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:via686b
+        """
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path)
+        self.vm.launch()
+        wait_for_console_pattern(self, 'PMON2000 MIPS Initializing. Standby...')
+        wait_for_console_pattern(self, 'Booting Bios')
+
+    @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
+    # Tesseract 4 adds a new OCR engine based on LSTM neural networks. The
+    # new version is faster and more accurate than version 3. The drawback is
+    # that it is still alpha-level software.
+    @skipUnless(tesseract_available(4), 'tesseract v4 OCR tool not available')
+    @skipUnless(os.getenv('PMON2E_BIN_PATH'), 'PMON2E_BIN_PATH not available')
+    def test_pmon_framebuffer_console(self):
+        """
+        :avocado: tags=arch:mips64el
+        :avocado: tags=machine:fuloong2e
+        :avocado: tags=endian:little
+        :avocado: tags=device:bonito64
+        :avocado: tags=device:ati-vga
+        """
+        screenshot_path = os.path.join(self.workdir, 'dump.ppm')
+
+        pmon_hash = 'c812e1695d7b2320036f3ef494976969' # v1.1.2
+        pmon_path = self.fetch_asset('file://' + os.getenv('PMON2E_BIN_PATH'),
+                                     asset_hash=pmon_hash, algorithm='md5')
+
+        self.vm.set_console()
+        self.vm.add_args('-bios', pmon_path,
+                         '-vga', 'std',
+                         '-device', 'ati-vga,model=rv100')
+        self.vm.launch()
+
+        wait_for_console_pattern(self, 'Video: Drawing the logo ...')
+        self.log.info('VM launched, waiting for logo on display')
+        time.sleep(2)
+        wait_for_console_pattern(self, 'CONSOLE_SIZE')
+        self.vm.command('human-monitor-command', command_line='stop')
+        self.vm.command('human-monitor-command',
+                        command_line='screendump %s' % screenshot_path)
+
+        lines = tesseract_ocr(screenshot_path, tesseract_version=4,
+                              tesseract_args='--dpi 128')
+        pmon_version = 'PNON2000 for Loongson, Version 1.1.2' # PNON is enough
+        self.assertIn(pmon_version, lines)
+
      @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
      @skipUnless(os.getenv('RESCUE_YL_PATH'), 'RESCUE_YL_PATH not available')
      def test_linux_kernel_isa_serial(self):
#16 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

Commit 911629e6d37 ("vt82c686: Fix SMBus IO base and configuration registers") exposed a "bug" in the Bonito north bridge. Fix it and add tests.

Quoted 8 lines

Thanks to Zoltan for support while debugging :)

Philippe Mathieu-Daudé (5):
hw/isa/vt82c686: Replace magic numbers by definitions hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit tests/acceptance: Test Linux on the Fuloong 2E machine tests/acceptance: Test PMON on the Fuloong 2E machine

Patches 2-4 queued to mips-next.