All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios
@ 2021-06-24 20:27 Philippe Mathieu-Daudé
  2021-06-24 20:27 ` [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions Philippe Mathieu-Daudé
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-24 20:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

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

-- 
2.31.1



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions
  2021-06-24 20:27 [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
@ 2021-06-24 20:27 ` Philippe Mathieu-Daudé
  2021-06-24 21:02   ` BALATON Zoltan
  2021-06-24 20:27 ` [PATCH 2/5] hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-24 20:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

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.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/isa/vt82c686.c | 50 +++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 17 deletions(-)

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index f57f3e70679..4ddcf2d398c 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -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);
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/5] hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit
  2021-06-24 20:27 [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
  2021-06-24 20:27 ` [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions Philippe Mathieu-Daudé
@ 2021-06-24 20:27 ` Philippe Mathieu-Daudé
  2021-06-24 20:27 ` [PATCH 3/5] hw/pci-host/bonito: Allow " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-24 20:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

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.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/pci-host/bonito.c     | 8 ++++++++
 hw/pci-host/trace-events | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index afb3d1f81d5..751fdcec689 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -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);
diff --git a/hw/pci-host/trace-events b/hw/pci-host/trace-events
index f4b3a50cb0b..630e9fcc5e7 100644
--- a/hw/pci-host/trace-events
+++ b/hw/pci-host/trace-events
@@ -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"
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/5] hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit
  2021-06-24 20:27 [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
  2021-06-24 20:27 ` [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions Philippe Mathieu-Daudé
  2021-06-24 20:27 ` [PATCH 2/5] hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit Philippe Mathieu-Daudé
@ 2021-06-24 20:27 ` Philippe Mathieu-Daudé
  2021-06-24 20:49   ` BALATON Zoltan
  2021-06-24 20:27 ` [PATCH 4/5] tests/acceptance: Test Linux on the Fuloong 2E machine Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-24 20:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

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").

Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
Suggested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/pci-host/bonito.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 751fdcec689..3c10608c9a2 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -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
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/5] tests/acceptance: Test Linux on the Fuloong 2E machine
  2021-06-24 20:27 [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-06-24 20:27 ` [PATCH 3/5] hw/pci-host/bonito: Allow " Philippe Mathieu-Daudé
@ 2021-06-24 20:27 ` Philippe Mathieu-Daudé
  2021-06-28 19:21   ` Wainer dos Santos Moschetta
  2021-06-24 20:27 ` [PATCH 5/5] tests/acceptance: Test PMON " Philippe Mathieu-Daudé
  2021-07-01 21:49 ` [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
  5 siblings, 1 reply; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-24 20:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 MAINTAINERS                                |  1 +
 tests/acceptance/machine_mips_fuloong2e.py | 42 ++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 tests/acceptance/machine_mips_fuloong2e.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 1a041eaf864..1c515b4ba14 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <chenhuacai@kernel.org>
diff --git a/tests/acceptance/machine_mips_fuloong2e.py b/tests/acceptance/machine_mips_fuloong2e.py
new file mode 100644
index 00000000000..0ac285e2af1
--- /dev/null
+++ b/tests/acceptance/machine_mips_fuloong2e.py
@@ -0,0 +1,42 @@
+# Functional tests for the Lemote Fuloong-2E machine.
+#
+# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
+#
+# 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)
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine
  2021-06-24 20:27 [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2021-06-24 20:27 ` [PATCH 4/5] tests/acceptance: Test Linux on the Fuloong 2E machine Philippe Mathieu-Daudé
@ 2021-06-24 20:27 ` Philippe Mathieu-Daudé
  2021-06-24 20:43   ` BALATON Zoltan
  2021-06-28 19:38   ` Wainer dos Santos Moschetta
  2021-07-01 21:49 ` [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
  5 siblings, 2 replies; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-24 20:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Philippe Mathieu-Daudé,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

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

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/tests/acceptance/machine_mips_fuloong2e.py b/tests/acceptance/machine_mips_fuloong2e.py
index 0ac285e2af1..4854ba98560 100644
--- a/tests/acceptance/machine_mips_fuloong2e.py
+++ b/tests/acceptance/machine_mips_fuloong2e.py
@@ -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):
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine
  2021-06-24 20:27 ` [PATCH 5/5] tests/acceptance: Test PMON " Philippe Mathieu-Daudé
@ 2021-06-24 20:43   ` BALATON Zoltan
  2021-06-29  4:51     ` Philippe Mathieu-Daudé
  2021-06-28 19:38   ` Wainer dos Santos Moschetta
  1 sibling, 1 reply; 17+ messages in thread
From: BALATON Zoltan @ 2021-06-24 20:43 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 6422 bytes --]

On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
> 1 file changed, 62 insertions(+)
>
> diff --git a/tests/acceptance/machine_mips_fuloong2e.py b/tests/acceptance/machine_mips_fuloong2e.py
> index 0ac285e2af1..4854ba98560 100644
> --- a/tests/acceptance/machine_mips_fuloong2e.py
> +++ b/tests/acceptance/machine_mips_fuloong2e.py
> @@ -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')

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

> +        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):
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/5] hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit
  2021-06-24 20:27 ` [PATCH 3/5] hw/pci-host/bonito: Allow " Philippe Mathieu-Daudé
@ 2021-06-24 20:49   ` BALATON Zoltan
  2021-06-29  4:54     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 17+ messages in thread
From: BALATON Zoltan @ 2021-06-24 20:49 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 3689 bytes --]

On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
> 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").
>
> Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
> Suggested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/pci-host/bonito.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
> index 751fdcec689..3c10608c9a2 100644
> --- a/hw/pci-host/bonito.c
> +++ b/hw/pci-host/bonito.c
> @@ -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

> #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
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions
  2021-06-24 20:27 ` [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions Philippe Mathieu-Daudé
@ 2021-06-24 21:02   ` BALATON Zoltan
  0 siblings, 0 replies; 17+ messages in thread
From: BALATON Zoltan @ 2021-06-24 21:02 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 5275 bytes --]

On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
> 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

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/isa/vt82c686.c | 50 +++++++++++++++++++++++++++++++----------------
> 1 file changed, 33 insertions(+), 17 deletions(-)
>
> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
> index f57f3e70679..4ddcf2d398c 100644
> --- a/hw/isa/vt82c686.c
> +++ b/hw/isa/vt82c686.c
> @@ -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);
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/5] tests/acceptance: Test Linux on the Fuloong 2E machine
  2021-06-24 20:27 ` [PATCH 4/5] tests/acceptance: Test Linux on the Fuloong 2E machine Philippe Mathieu-Daudé
@ 2021-06-28 19:21   ` Wainer dos Santos Moschetta
  0 siblings, 0 replies; 17+ messages in thread
From: Wainer dos Santos Moschetta @ 2021-06-28 19:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Cleber Rosa, Aurelien Jarno


On 6/24/21 5:27 PM, Philippe Mathieu-Daudé wrote:
> 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   MAINTAINERS                                |  1 +
>   tests/acceptance/machine_mips_fuloong2e.py | 42 ++++++++++++++++++++++
>   2 files changed, 43 insertions(+)
>   create mode 100644 tests/acceptance/machine_mips_fuloong2e.py

Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>

>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1a041eaf864..1c515b4ba14 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -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 <chenhuacai@kernel.org>
> diff --git a/tests/acceptance/machine_mips_fuloong2e.py b/tests/acceptance/machine_mips_fuloong2e.py
> new file mode 100644
> index 00000000000..0ac285e2af1
> --- /dev/null
> +++ b/tests/acceptance/machine_mips_fuloong2e.py
> @@ -0,0 +1,42 @@
> +# Functional tests for the Lemote Fuloong-2E machine.
> +#
> +# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
> +#
> +# 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)



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine
  2021-06-24 20:27 ` [PATCH 5/5] tests/acceptance: Test PMON " Philippe Mathieu-Daudé
  2021-06-24 20:43   ` BALATON Zoltan
@ 2021-06-28 19:38   ` Wainer dos Santos Moschetta
  1 sibling, 0 replies; 17+ messages in thread
From: Wainer dos Santos Moschetta @ 2021-06-28 19:38 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Cleber Rosa, Aurelien Jarno

Hi,

On 6/24/21 5:27 PM, Philippe Mathieu-Daudé wrote:
> 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.
>
>    $ 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
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   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,

Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>

>
> diff --git a/tests/acceptance/machine_mips_fuloong2e.py b/tests/acceptance/machine_mips_fuloong2e.py
> index 0ac285e2af1..4854ba98560 100644
> --- a/tests/acceptance/machine_mips_fuloong2e.py
> +++ b/tests/acceptance/machine_mips_fuloong2e.py
> @@ -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):



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine
  2021-06-24 20:43   ` BALATON Zoltan
@ 2021-06-29  4:51     ` Philippe Mathieu-Daudé
  2021-06-29 10:47       ` BALATON Zoltan
  0 siblings, 1 reply; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-29  4:51 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

On 6/24/21 10:43 PM, BALATON Zoltan wrote:
> On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
>> 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
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
>> 1 file changed, 62 insertions(+)
>>
>> diff --git a/tests/acceptance/machine_mips_fuloong2e.py
>> b/tests/acceptance/machine_mips_fuloong2e.py
>> index 0ac285e2af1..4854ba98560 100644
>> --- a/tests/acceptance/machine_mips_fuloong2e.py
>> +++ b/tests/acceptance/machine_mips_fuloong2e.py
>> @@ -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')
> 
> 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/qemu-devel@nongnu.org/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.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/5] hw/pci-host/bonito: Allow PCI config accesses smaller than 32-bit
  2021-06-24 20:49   ` BALATON Zoltan
@ 2021-06-29  4:54     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-29  4:54 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

On 6/24/21 10:49 PM, BALATON Zoltan wrote:
> On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
>> 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").
>>
>> Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
>> Suggested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>> hw/pci-host/bonito.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
>> index 751fdcec689..3c10608c9a2 100644
>> --- a/hw/pci-host/bonito.c
>> +++ b/hw/pci-host/bonito.c
>> @@ -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.

> 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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine
  2021-06-29  4:51     ` Philippe Mathieu-Daudé
@ 2021-06-29 10:47       ` BALATON Zoltan
  2021-06-29 11:30         ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 17+ messages in thread
From: BALATON Zoltan @ 2021-06-29 10:47 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 8679 bytes --]

On Tue, 29 Jun 2021, Philippe Mathieu-Daudé wrote:
> On 6/24/21 10:43 PM, BALATON Zoltan wrote:
>> On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
>>> 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
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>> ---
>>> tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
>>> 1 file changed, 62 insertions(+)
>>>
>>> diff --git a/tests/acceptance/machine_mips_fuloong2e.py
>>> b/tests/acceptance/machine_mips_fuloong2e.py
>>> index 0ac285e2af1..4854ba98560 100644
>>> --- a/tests/acceptance/machine_mips_fuloong2e.py
>>> +++ b/tests/acceptance/machine_mips_fuloong2e.py
>>> @@ -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')
>>
>> 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/qemu-devel@nongnu.org/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.

> 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)

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

> 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.
>
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine
  2021-06-29 10:47       ` BALATON Zoltan
@ 2021-06-29 11:30         ` Philippe Mathieu-Daudé
  2021-06-29 12:08           ` BALATON Zoltan
  0 siblings, 1 reply; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-29 11:30 UTC (permalink / raw)
  To: BALATON Zoltan
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

On 6/29/21 12:47 PM, BALATON Zoltan wrote:
> On Tue, 29 Jun 2021, Philippe Mathieu-Daudé wrote:
>> On 6/24/21 10:43 PM, BALATON Zoltan wrote:
>>> On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
>>>> 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
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>> ---
>>>> tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
>>>> 1 file changed, 62 insertions(+)
>>>>
>>>> diff --git a/tests/acceptance/machine_mips_fuloong2e.py
>>>> b/tests/acceptance/machine_mips_fuloong2e.py
>>>> index 0ac285e2af1..4854ba98560 100644
>>>> --- a/tests/acceptance/machine_mips_fuloong2e.py
>>>> +++ b/tests/acceptance/machine_mips_fuloong2e.py
>>>> @@ -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')
>>>
>>> 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/qemu-devel@nongnu.org/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.
> 
>> 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)
> 
> 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.

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.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/5] tests/acceptance: Test PMON on the Fuloong 2E machine
  2021-06-29 11:30         ` Philippe Mathieu-Daudé
@ 2021-06-29 12:08           ` BALATON Zoltan
  0 siblings, 0 replies; 17+ messages in thread
From: BALATON Zoltan @ 2021-06-29 12:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Aleksandar Rikalo, Huacai Chen, qemu-devel,
	Wainer dos Santos Moschetta, Cleber Rosa, Aurelien Jarno

[-- Attachment #1: Type: text/plain, Size: 10004 bytes --]

On Tue, 29 Jun 2021, Philippe Mathieu-Daudé wrote:
> On 6/29/21 12:47 PM, BALATON Zoltan wrote:
>> On Tue, 29 Jun 2021, Philippe Mathieu-Daudé wrote:
>>> On 6/24/21 10:43 PM, BALATON Zoltan wrote:
>>>> On Thu, 24 Jun 2021, Philippe Mathieu-Daudé wrote:
>>>>> 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
>>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>>>> ---
>>>>> tests/acceptance/machine_mips_fuloong2e.py | 62 ++++++++++++++++++++++
>>>>> 1 file changed, 62 insertions(+)
>>>>>
>>>>> diff --git a/tests/acceptance/machine_mips_fuloong2e.py
>>>>> b/tests/acceptance/machine_mips_fuloong2e.py
>>>>> index 0ac285e2af1..4854ba98560 100644
>>>>> --- a/tests/acceptance/machine_mips_fuloong2e.py
>>>>> +++ b/tests/acceptance/machine_mips_fuloong2e.py
>>>>> @@ -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')
>>>>
>>>> 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/qemu-devel@nongnu.org/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.
>>
>>> 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)
>>
>> 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.
>
> 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')

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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios
  2021-06-24 20:27 [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2021-06-24 20:27 ` [PATCH 5/5] tests/acceptance: Test PMON " Philippe Mathieu-Daudé
@ 2021-07-01 21:49 ` Philippe Mathieu-Daudé
  5 siblings, 0 replies; 17+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-07-01 21:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Aleksandar Rikalo, Huacai Chen, Aurelien Jarno,
	Wainer dos Santos Moschetta, Cleber Rosa

On 6/24/21 10:27 PM, Philippe Mathieu-Daudé wrote:
> 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

Patches 2-4 queued to mips-next.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-07-01 21:51 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 20:27 [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé
2021-06-24 20:27 ` [PATCH 1/5] hw/isa/vt82c686: Replace magic numbers by definitions Philippe Mathieu-Daudé
2021-06-24 21:02   ` BALATON Zoltan
2021-06-24 20:27 ` [PATCH 2/5] hw/pci-host/bonito: Trace PCI config accesses smaller than 32-bit Philippe Mathieu-Daudé
2021-06-24 20:27 ` [PATCH 3/5] hw/pci-host/bonito: Allow " Philippe Mathieu-Daudé
2021-06-24 20:49   ` BALATON Zoltan
2021-06-29  4:54     ` Philippe Mathieu-Daudé
2021-06-24 20:27 ` [PATCH 4/5] tests/acceptance: Test Linux on the Fuloong 2E machine Philippe Mathieu-Daudé
2021-06-28 19:21   ` Wainer dos Santos Moschetta
2021-06-24 20:27 ` [PATCH 5/5] tests/acceptance: Test PMON " Philippe Mathieu-Daudé
2021-06-24 20:43   ` BALATON Zoltan
2021-06-29  4:51     ` Philippe Mathieu-Daudé
2021-06-29 10:47       ` BALATON Zoltan
2021-06-29 11:30         ` Philippe Mathieu-Daudé
2021-06-29 12:08           ` BALATON Zoltan
2021-06-28 19:38   ` Wainer dos Santos Moschetta
2021-07-01 21:49 ` [PATCH 0/5] hw/mips: Fix the Fuloong 2E machine with PMON bios Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.