Re: [PATCH] tests/avocado: update sunxi kernel from armbian to 6.6.16

2024-05-03 Thread Niek Linnenbank
On Tue, Apr 30, 2024 at 4:12 PM Peter Maydell 
wrote:

> On Mon, 29 Apr 2024 at 21:40, Niek Linnenbank 
> wrote:
> >
> > Hi Peter, Strahinja,
> >
> > I can confirm that the orangepi-pc and cubieboard based tests are
> working OK using the newer kernel 6.6.16:
> >
> >   $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
> ./build/pyvenv/bin/avocado --show=app,console run -t machine:orangepi-pc -t
> machine:cubieboard tests/avocado/boot_linux_console.py
> >   ...
> >   RESULTS: PASS 7 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0
> | CANCEL 1
> >   JOB TIME   : 177.65 s
> >
> > So for this patch:
> > Reviewed-by: Niek Linnenbank 
> > Tested-by: Niek Linnenbank 
>
> Great, thanks. (I'll put this patch into an upcoming arm pullreq.)
>
> > About the BootLinuxConsole.test_arm_orangepi_bionic_20_08 test, I'd be
> happy to provide a patch to revive that test.
> > Since that test is no longer working without having the image available,
> this could also be a good moment to re-consider if armbian is really the
> best input for testing
> > the orangepi-pc board. The image is relatively larger and slower
> compared to other images, like the two openwrt based tests for cubieboard
> and bpim2u.
> >
> > After some searching I've found that Openwrt also has orangepi-pc
> support:
> >   https://openwrt.org/toh/xunlong/orange_pi_pc
> >
> > That image works fine with our emulated orangepi-pc board:
> >
> > $ qemu-system-arm -M orangepi-pc -sd
> openwrt-23.05.0-sunxi-cortexa7-xunlong_orangepi-pc-ext4-sdcard.img
> -nographic
>
> > Using openwrt also for the orangepi-pc test instead of armbian also
> gives some consistency between the various tests, to some degree. What are
> you opinions on this?
>
> Yeah, seems reasonable. My main thing to think about would be
> that to understand what extra coverage this gives us that we
> don't already have (there's no point running a ton of tests
> which all amount to "boot a Linux kernel to a shell prompt").
> It looks like what we get from this one is that we are testing
> the "boot off an SD card image via u-boot" flow -- is that right?
>

Yes, correct.
Okey, I'll try to find some time the coming days to prepare a patch that
replaces test_arm_orangepi_bionic_20_08 with a test that uses openwrt
instead.

Niek



>
> thanks
> -- PMM
>


-- 
Niek Linnenbank


Re: [PATCH] tests/avocado: update sunxi kernel from armbian to 6.6.16

2024-04-29 Thread Niek Linnenbank
Hi Peter, Strahinja,

I can confirm that the orangepi-pc and cubieboard based tests are working
OK using the newer kernel 6.6.16:

  $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
./build/pyvenv/bin/avocado --show=app,console run -t machine:orangepi-pc -t
machine:cubieboard tests/avocado/boot_linux_console.py
  ...
  RESULTS: PASS 7 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 1
  JOB TIME   : 177.65 s

So for this patch:
Reviewed-by: Niek Linnenbank 
Tested-by: Niek Linnenbank 

About the BootLinuxConsole.test_arm_orangepi_bionic_20_08 test, I'd be
happy to provide a patch to revive that test.
Since that test is no longer working without having the image available,
this could also be a good moment to re-consider if armbian is really the
best input for testing
the orangepi-pc board. The image is relatively larger and slower compared
to other images, like the two openwrt based tests for cubieboard and bpim2u.

After some searching I've found that Openwrt also has orangepi-pc support:
  https://openwrt.org/toh/xunlong/orange_pi_pc

That image works fine with our emulated orangepi-pc board:

$ qemu-system-arm -M orangepi-pc -sd
openwrt-23.05.0-sunxi-cortexa7-xunlong_orangepi-pc-ext4-sdcard.img
-nographic
U-Boot SPL 2020.07-OpenWrt-r23497-6637af95aa (Oct 09 2023 - 21:45:35 +)
DRAM: 1024 MiB
Failed to set core voltage! Can't set CPU frequency
Trying to boot from MMC1


U-Boot 2020.07-OpenWrt-r23497-6637af95aa (Oct 09 2023 - 21:45:35 +)
Allwinner Technology

CPU:   Allwinner H3 (SUN8I )
Model: Xunlong Orange Pi PC
...
Starting kernel ...

[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 5.15.134 (builder@buildhost)
(arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 12.3.0 r23497-6637af95aa)
12.3.0, GNU ld (GNU Binutils) 2.40.0) #0 SMP Mon Oct 9 21:45:35 2023
[0.00] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7),
cr=30c5387d
[0.00] CPU: div instructions available: patching division code
[0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing
instruction cache
...
BusyBox v1.36.1 (2023-10-09 21:45:35 UTC) built-in shell (ash)

  ___ __
 |   |.-.-.-.|  |  |  |..|  |_
 |   -   ||  _  |  -__| ||  |  |  ||   _||   _|
 |___||   __|_|__|__||||__|  ||
  |__| W I R E L E S S   F R E E D O M
 -
 OpenWrt 23.05.0, r23497-6637af95aa
 -
=== WARNING! =
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--
root@(none):/# uname -a
Linux (none) 5.15.134 #0 SMP Mon Oct 9 21:45:35 2023 armv7l GNU/Linux

Using openwrt also for the orangepi-pc test instead of armbian also gives
some consistency between the various tests, to some degree. What are you
opinions on this?

Regards,
Niek


On Fri, Apr 26, 2024 at 12:24 AM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> Hi Peter,
>
> I ran the avocado tests and this patch looks good to me.
> The only comment I have would be that the `test_arm-Orangepi_bionic_20_08`
> is not executed anymore since the image is not available, but I guess that
> can be another patch.
>
>
>
> On Thu, Apr 25, 2024 at 9:31 PM Peter Maydell 
> wrote:
>
>> Whoops, forgot to cc the allwinner maintainers/reviewers on this.
>> Ping for review, please?
>>
>> thanks
>> -- PMM
>>
>> On Mon, 15 Apr 2024 at 16:18, Peter Maydell 
>> wrote:
>> >
>> > The Linux kernel 5.10.16 binary for sunxi has been removed from
>> > apt.armbian.com. This means that the avocado tests for these machines
>> > will be skipped (status CANCEL) if the old binary isn't present in
>> > the avocado cache.
>> >
>> > Update to 6.6.16, in the same way we did in commit e384db41d8661
>> > when we moved to 5.10.16 in 2021.
>> >
>> > Cc: qemu-sta...@nongnu.org
>> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2284
>> > Signed-off-by: Peter Maydell 
>> > ---
>> > At this point in the release cycle I don't think I really want
>> > to put this into 9.0, though I could just about squeeze it in.
>> >
>> > cc'ing stable as an FYI -- since the tests fall back to the
>> > CANCEL status this doesn't break CI, so it's not a requirement
>> > to backport to any stable branches. But it would probably be
>> > preferable to get the coverage back on the stable branches so
>> > we can detect if we get something wrong on a backport of a
>> > patch that affects these machines.
>>

Re: [PATCH v5 00/11] *** Add allwinner-r40 support ***

2023-06-07 Thread Niek Linnenbank
Hi Peter, Qianfan,

On Mon, Jun 5, 2023 at 5:31 PM Peter Maydell 
wrote:

> On Thu, 1 Jun 2023 at 19:48, Niek Linnenbank 
> wrote:
> >
> > Hi Qianfan,
> >
> > Thanks for sending the v5. From my side, I have no further comments on
> the content.
> > So please feel free to add the following to each of the patches 01-11 in
> the series:
> >
> > Reviewed-by: Niek Linnenbank 
> >
> > As a reminder and explained here on this page, you'll need to make sure
> these lines gets added to each of the commit messages:
> >
> https://www.qemu.org/docs/master/devel/submitting-a-patch.html#proper-use-of-reviewed-by-tags-can-aid-review
> >
> > Doing so would require you to send another updated v6, and baselined on
> the latest master.
>
> The rebase was simple, so I've applied this v5 to target-arm.next.
>
Great news!


> (The patch application tools can pick up Reviewed-by tags that are
> on-list without requiring a respin just for that.)
>
Ahh right, I wasn't aware of that. Thanks, I learned something new here.


>
> Qianfan: thanks for working on this feature and for your efforts
> in working through our patch review process.
>
Yes, great work indeed!

>
> Niek: thanks very much for taking the lead on the patch review of
> this series, it's been a tremendous help.
>
I'm glad to help. I only do qemu work in my spare time when I can, so it's
not much.
But I enjoy doing it and learn something new in the process also.

Regards,
Niek


>
> -- PMM
>


-- 
Niek Linnenbank


Re: [PATCH v5 00/11] *** Add allwinner-r40 support ***

2023-06-01 Thread Niek Linnenbank
Hi Qianfan,

Thanks for sending the v5. From my side, I have no further comments on the
content.
So please feel free to add the following to each of the patches 01-11 in
the series:

Reviewed-by: Niek Linnenbank 

As a reminder and explained here on this page, you'll need to make sure
these lines gets added to each of the commit messages:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#proper-use-of-reviewed-by-tags-can-aid-review

Doing so would require you to send another updated v6, and baselined on the
latest master.

Thanks again for contributing this to Qemu, hopefully we can see it merged
soon.

Regards,
Niek

On Tue, May 23, 2023 at 12:05 PM  wrote:

> From: qianfan Zhao 
>
> ***History***
> # v1: 2023-03-21
>
> The first version which add allwinner-r40 support, supported features:
>
> + ccu
> + dram controller
> + uart
> + i2c and pmic(axp221)
> + sdcard
> + emac/gmac
>
> Also provide a test case under avocado, running quickly test:
>
> $ AVOCADO_ALLOW_LARGE_STORAGE=yes tests/venv/bin/avocado \
> --verbose --show=app,console run -t machine:bpim2u \
> ../tests/avocado/boot_linux_console.py
>
> # v2: 2023-03-28
>
> 1. Fix the waring and error reported by checkpatch.pl
> 2. Remove the other i2c controllers except that i2c0
> 3. Use an array to register mmc and uart devices
> 4. Rename axp209 to axp22x and add axp221 support
> 5. Add a basic SRAM controller
>
> # v3: 2023-04-18
>
> 1. Update some commit messages
> 2. Squash those two commit about sdcard
>hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
>hw: arm: allwinner-r40: Fix the mmc controller's type
>
> # v4: 2023-05-10
>
> 1. Rebase to master
>
> # v5: 2023-05-23
>
> 1. Rebase to master
> 2. Update based on Niek Linnenbank's guide.
>
> qianfan Zhao (11):
>   hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
>   hw/arm/allwinner-r40: add Clock Control Unit
>   hw: allwinner-r40: Complete uart devices
>   hw: arm: allwinner-r40: Add i2c0 device
>   hw/misc: Rename axp209 to axp22x and add support AXP221 PMU
>   hw/arm/allwinner-r40: add SDRAM controller device
>   hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
>   hw: arm: allwinner-r40: Add emac and gmac support
>   hw: arm: allwinner-sramc: Add SRAM Controller support for R40
>   tests: avocado: boot_linux_console: Add test case for bpim2u
>   docs: system: arm: Introduce bananapi_m2u
>
>  docs/system/arm/bananapi_m2u.rst  | 138 +++
>  hw/arm/Kconfig|  14 +-
>  hw/arm/allwinner-r40.c| 526 ++
>  hw/arm/bananapi_m2u.c | 145 +++
>  hw/arm/meson.build|   1 +
>  hw/misc/Kconfig   |   5 +-
>  hw/misc/allwinner-r40-ccu.c   | 209 ++
>  hw/misc/allwinner-r40-dramc.c | 513 +
>  hw/misc/allwinner-sramc.c | 184 +
>  hw/misc/axp209.c  | 238 
>  hw/misc/axp2xx.c  | 283 ++
>  hw/misc/meson.build   |   5 +-
>  hw/misc/trace-events  |  26 +-
>  hw/sd/allwinner-sdhost.c  |  72 +++-
>  include/hw/arm/allwinner-r40.h| 143 +++
>  include/hw/misc/allwinner-r40-ccu.h   |  65 
>  include/hw/misc/allwinner-r40-dramc.h | 108 ++
>  include/hw/misc/allwinner-sramc.h |  69 
>  include/hw/sd/allwinner-sdhost.h  |   9 +
>  tests/avocado/boot_linux_console.py   | 176 +
>  20 files changed, 2681 insertions(+), 248 deletions(-)
>  create mode 100644 docs/system/arm/bananapi_m2u.rst
>  create mode 100644 hw/arm/allwinner-r40.c
>  create mode 100644 hw/arm/bananapi_m2u.c
>  create mode 100644 hw/misc/allwinner-r40-ccu.c
>  create mode 100644 hw/misc/allwinner-r40-dramc.c
>  create mode 100644 hw/misc/allwinner-sramc.c
>  delete mode 100644 hw/misc/axp209.c
>  create mode 100644 hw/misc/axp2xx.c
>  create mode 100644 include/hw/arm/allwinner-r40.h
>  create mode 100644 include/hw/misc/allwinner-r40-ccu.h
>  create mode 100644 include/hw/misc/allwinner-r40-dramc.h
>  create mode 100644 include/hw/misc/allwinner-sramc.h
>
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v4 00/11] *** Add allwinner r40 support ***

2023-05-15 Thread Niek Linnenbank
Hi Qianfan,

Thanks for sending the v4. I've reviewed all patches and replied to each
individual patch.

Great work so far!

One thing I wanted to mention is that when you receive a 'Reviewed-by:' or
'Tested-by:' line from a reviewer,
please feel free to include it in the commit message on the next version of
that patch. This helps you and reviewers
to keep track on what has been reviewed and what not.

For more details on this and the review process, also see this page:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#proper-use-of-reviewed-by-tags-can-aid-review

Kind regards,
Niek

On Wed, May 10, 2023 at 12:30 PM  wrote:

> From: qianfan Zhao 
>
>
> *** history ***
>
> # v1: 2023-03-21
>
> The first version which add allwinner-r40 support, supported features:
>
> + ccu
> + dram controller
> + uart
> + i2c and pmic(axp221)
> + sdcard
> + emac/gmac
>
> Also provide a test case under avocado, running quickly test:
>
> $ AVOCADO_ALLOW_LARGE_STORAGE=yes tests/venv/bin/avocado \
> --verbose --show=app,console run -t machine:bpim2u \
> ../tests/avocado/boot_linux_console.py
>
> # v2: 2023-03-28
>
> 1. Fix the waring and error reported by checkpatch.pl
> 2. Remove the other i2c controllers except that i2c0
> 3. Use an array to register mmc and uart devices
> 4. Rename axp209 to axp22x and add axp221 support
> 5. Add a basic SRAM controller
>
> # v3: 2023-04-18
>
> 1. Update some commit messages
> 2. Squash those two commit about sdcard
>hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
>hw: arm: allwinner-r40: Fix the mmc controller's type
>
> # v4: 2023-05-10
>
> 1. Rebase to master
>
> qianfan Zhao (11):
>   hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
>   hw/arm/allwinner-r40: add Clock Control Unit
>   hw: allwinner-r40: Complete uart devices
>   hw: arm: allwinner-r40: Add i2c0 device
>   hw/misc: Rename axp209 to axp22x and add support AXP221 PMU
>   hw/arm/allwinner-r40: add SDRAM controller device
>   hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
>   hw: arm: allwinner-r40: Add emac and gmac support
>   hw: arm: allwinner-sramc: Add SRAM Controller support for R40
>   tests: avocado: boot_linux_console: Add test case for bpim2u
>   docs: system: arm: Introduce bananapi_m2u
>
>  docs/system/arm/bananapi_m2u.rst  | 138 +++
>  hw/arm/Kconfig|  14 +-
>  hw/arm/allwinner-r40.c| 526 ++
>  hw/arm/bananapi_m2u.c | 145 +++
>  hw/arm/meson.build|   1 +
>  hw/misc/Kconfig   |   5 +-
>  hw/misc/allwinner-r40-ccu.c   | 209 ++
>  hw/misc/allwinner-r40-dramc.c | 513 +
>  hw/misc/allwinner-sramc.c | 184 +
>  hw/misc/axp209.c  | 238 
>  hw/misc/axp2xx.c  | 283 ++
>  hw/misc/meson.build   |   5 +-
>  hw/misc/trace-events  |  26 +-
>  hw/sd/allwinner-sdhost.c  |  70 +++-
>  include/hw/arm/allwinner-r40.h| 143 +++
>  include/hw/misc/allwinner-r40-ccu.h   |  65 
>  include/hw/misc/allwinner-r40-dramc.h | 108 ++
>  include/hw/misc/allwinner-sramc.h |  69 
>  include/hw/sd/allwinner-sdhost.h  |   9 +
>  tests/avocado/boot_linux_console.py   | 176 +
>  20 files changed, 2679 insertions(+), 248 deletions(-)
>  create mode 100644 docs/system/arm/bananapi_m2u.rst
>  create mode 100644 hw/arm/allwinner-r40.c
>  create mode 100644 hw/arm/bananapi_m2u.c
>  create mode 100644 hw/misc/allwinner-r40-ccu.c
>  create mode 100644 hw/misc/allwinner-r40-dramc.c
>  create mode 100644 hw/misc/allwinner-sramc.c
>  delete mode 100644 hw/misc/axp209.c
>  create mode 100644 hw/misc/axp2xx.c
>  create mode 100644 include/hw/arm/allwinner-r40.h
>  create mode 100644 include/hw/misc/allwinner-r40-ccu.h
>  create mode 100644 include/hw/misc/allwinner-r40-dramc.h
>  create mode 100644 include/hw/misc/allwinner-sramc.h
>
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v4 11/11] docs: system: arm: Introduce bananapi_m2u

2023-05-15 Thread Niek Linnenbank
On Wed, May 10, 2023 at 12:31 PM  wrote:

> From: qianfan Zhao 
>
> Add documents for Banana Pi M2U
>
> Signed-off-by: qianfan Zhao 
>
Reviewed-by: Niek Linnenbank 


> ---
>  docs/system/arm/bananapi_m2u.rst | 138 +++
>  1 file changed, 138 insertions(+)
>  create mode 100644 docs/system/arm/bananapi_m2u.rst
>
> diff --git a/docs/system/arm/bananapi_m2u.rst
> b/docs/system/arm/bananapi_m2u.rst
> new file mode 100644
> index 00..ae7194a9df
> --- /dev/null
> +++ b/docs/system/arm/bananapi_m2u.rst
> @@ -0,0 +1,138 @@
> +Banana Pi BPI-M2U (``bpim2u``)
> +^^
> +
> +Banana Pi BPI-M2 Ultra is a quad-core mini single board computer built
> with
> +Allwinner A40i/R40/V40 SoC. It features 2GB of RAM and 8GB eMMC. It also
>
+has onboard WiFi and BT. On the ports side, the BPI-M2 Ultra has 2 USB A
> +2.0 ports, 1 USB OTG port, 1 HDMI port, 1 audio jack, a DC power port,
> +and last but not least, a SATA port.
> +
> +Supported devices
> +"""""""""""""""""
> +
> +The Banana Pi M2U machine supports the following devices:
> +
> + * SMP (Quad Core Cortex-A7)
> + * Generic Interrupt Controller configuration
> + * SRAM mappings
> + * SDRAM controller
> + * Timer device (re-used from Allwinner A10)
> + * UART
> + * SD/MMC storage controller
> + * EMAC ethernet
> + * GMAC ethernet
> + * Clock Control Unit
> + * TWI (I2C)
> +
> +Limitations
> +"""""""""""
> +
> +Currently, Banana Pi M2U does *not* support the following features:
> +
> +- Graphical output via HDMI, GPU and/or the Display Engine
> +- Audio output
> +- Hardware Watchdog
> +- Real Time Clock
> +- USB 2.0 interfaces
> +
> +Also see the 'unimplemented' array in the Allwinner R40 SoC module
> +for a complete list of unimplemented I/O devices:
> ``./hw/arm/allwinner-r40.c``
> +
> +Boot options
> +""""""""""""
> +
> +The Banana Pi M2U machine can start using the standard -kernel
> functionality
> +for loading a Linux kernel or ELF executable. Additionally, the Banana Pi
> M2U
> +machine can also emulate the BootROM which is present on an actual
> Allwinner R40
> +based SoC, which loads the bootloader from a SD card, specified via the
> -sd
> +argument to qemu-system-arm.
> +
> +Running mainline Linux
> +""""""""""""""""""""""
> +
> +To build a Linux mainline kernel that can be booted by the Banana Pi M2U
> machine,
> +simply configure the kernel using the sunxi_defconfig configuration:
> +
> +.. code-block:: bash
> +
> +  $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make mrproper
> +  $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make sunxi_defconfig
> +
> +To boot the newly build linux kernel in QEMU with the Banana Pi M2U
> machine, use:
> +
> +.. code-block:: bash
> +
> +  $ qemu-system-arm -M bpim2u -nographic \
> +  -kernel /path/to/linux/arch/arm/boot/zImage \
> +  -append 'console=ttyS0,115200' \
> +  -dtb
> /path/to/linux/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb
> +
> +Banana Pi M2U images
> +""""""""""""""""""""
> +
> +Note that the mainline kernel does not have a root filesystem. You can
> choose
> +to build you own image with buildroot using the
> bananapi_m2_ultra_defconfig.
> +Also see https://buildroot.org for more information.
> +
> +Another possibility is to run an OpenWrt image for Banana Pi M2U which
> +can be downloaded from:
> +
> +   https://downloads.openwrt.org/releases/22.03.3/targets/sunxi/cortexa7/
> +
> +When using an image as an SD card, it must be resized to a power of two.
> This can be
> +done with the ``qemu-img`` command. It is recommended to only increase
> the image size
> +instead of shrinking it to a power of two, to avoid loss of data. For
> example,
> +to prepare a downloaded Armbian image, first extract it and then increase
> +its size to one gigabyte as follows:
> +
> +.. code-block:: bash
> +
> +  $ qemu-img resize \
> +
> openwrt-22.03.3-sunxi-cortexa7-sinovoip_bananapi-m2-ultra-ext4-sdcard.img \
> +1G
> +
> +Instead of providing a custom Linux kernel via the -kernel command you
> may also
> +choose to let the Banana Pi M2U machine load the bootloader from SD card,
> just like
> +a real board would do using the BootROM. Simply pass the select

Re: [PATCH v4 10/11] tests: avocado: boot_linux_console: Add test case for bpim2u

2023-05-15 Thread Niek Linnenbank
On Wed, May 10, 2023 at 12:30 PM  wrote:

> From: qianfan Zhao 
>
> Add test case for booting from initrd and sd card.
>

To make the commit message more complete and reflect the full contents,
maybe also mention the gmac and openwrt test?

Tests look fine to me, and are running OK on my machine:

$ AVOCADO_ALLOW_LARGE_STORAGE=yes ./build/tests/venv/bin/avocado
--show=app,console run -t machine:bpim2u tests/avocado/boot_linux_console.py
...
RESULTS: PASS 4 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 26.46 s

So for me feel free to add:

Reviewed-by: Niek Linnenbank 
Tested-by: Niek Linnenbank 

Regards,
Niek


>
> Signed-off-by: qianfan Zhao 
> ---
>  tests/avocado/boot_linux_console.py | 176 
>  1 file changed, 176 insertions(+)
>
> diff --git a/tests/avocado/boot_linux_console.py
> b/tests/avocado/boot_linux_console.py
> index c0675809e6..6ed660611f 100644
> --- a/tests/avocado/boot_linux_console.py
> +++ b/tests/avocado/boot_linux_console.py
> @@ -769,6 +769,182 @@ def test_arm_quanta_gsj_initrd(self):
>  self.wait_for_console_pattern(
>  'Give root password for system maintenance')
>
> +def test_arm_bpim2u(self):
> +"""
> +:avocado: tags=arch:arm
> +:avocado: tags=machine:bpim2u
> +:avocado: tags=accel:tcg
> +"""
> +deb_url = ('
> https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/'
> +   'linux-image-current-sunxi_21.02.2_armhf.deb')
> +deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
> +deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
> +kernel_path = self.extract_from_deb(deb_path,
> +'/boot/vmlinuz-5.10.16-sunxi')
> +dtb_path = ('/usr/lib/linux-image-current-sunxi/'
> +'sun8i-r40-bananapi-m2-ultra.dtb')
> +dtb_path = self.extract_from_deb(deb_path, dtb_path)
> +
> +self.vm.set_console()
> +kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
> +   'console=ttyS0,115200n8 '
> +   'earlycon=uart,mmio32,0x1c28000')
> +self.vm.add_args('-kernel', kernel_path,
> + '-dtb', dtb_path,
> + '-append', kernel_command_line)
> +self.vm.launch()
> +console_pattern = 'Kernel command line: %s' % kernel_command_line
> +self.wait_for_console_pattern(console_pattern)
> +
> +def test_arm_bpim2u_initrd(self):
> +"""
> +:avocado: tags=arch:arm
> +:avocado: tags=accel:tcg
> +:avocado: tags=machine:bpim2u
> +"""
> +deb_url = ('
> https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/'
> +   'linux-image-current-sunxi_21.02.2_armhf.deb')
> +deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
> +deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
> +kernel_path = self.extract_from_deb(deb_path,
> +'/boot/vmlinuz-5.10.16-sunxi')
> +dtb_path = ('/usr/lib/linux-image-current-sunxi/'
> +'sun8i-r40-bananapi-m2-ultra.dtb')
> +dtb_path = self.extract_from_deb(deb_path, dtb_path)
> +initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
> +  '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
> +  'arm/rootfs-armv7a.cpio.gz')
> +initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
> +initrd_path_gz = self.fetch_asset(initrd_url,
> asset_hash=initrd_hash)
> +initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
> +archive.gzip_uncompress(initrd_path_gz, initrd_path)
> +
> +self.vm.set_console()
> +kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
> +   'console=ttyS0,115200 '
> +   'panic=-1 noreboot')
> +self.vm.add_args('-kernel', kernel_path,
> + '-dtb', dtb_path,
> + '-initrd', initrd_path,
> + '-append', kernel_command_line,
> + '-no-reboot')
> +self.vm.launch()
> +self.wait_for_console_pattern('Boot successful.')
> +
> +exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
> +'Allwinner sun8i Family')
> +exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
> +'system-control@1c0')
> +

Re: [PATCH v4 09/11] hw: arm: allwinner-sramc: Add SRAM Controller support for R40

2023-05-15 Thread Niek Linnenbank
On Wed, May 10, 2023 at 12:30 PM  wrote:

> From: qianfan Zhao 
>
> Only a few important registers are added, especially the SRAM_VER
> register.
>
> Signed-off-by: qianfan Zhao 
>
Reviewed-by: Niek Linnenbank 


> ---
>  hw/arm/Kconfig|   1 +
>  hw/arm/allwinner-r40.c|   7 +-
>  hw/misc/Kconfig   |   3 +
>  hw/misc/allwinner-sramc.c | 184 ++
>  hw/misc/meson.build   |   1 +
>  hw/misc/trace-events  |   4 +
>  include/hw/arm/allwinner-r40.h|   3 +
>  include/hw/misc/allwinner-sramc.h |  69 +++
>  8 files changed, 271 insertions(+), 1 deletion(-)
>  create mode 100644 hw/misc/allwinner-sramc.c
>  create mode 100644 include/hw/misc/allwinner-sramc.h
>
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index bad4ea158c..ae6f3911c5 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -377,6 +377,7 @@ config ALLWINNER_H3
>  config ALLWINNER_R40
>  bool
>  default y if TCG && ARM
> +select ALLWINNER_SRAMC
>  select ALLWINNER_A10_PIT
>  select AXP2XX_PMU
>  select SERIAL
> diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
> index c018ad231a..7d29eb224f 100644
> --- a/hw/arm/allwinner-r40.c
> +++ b/hw/arm/allwinner-r40.c
> @@ -39,6 +39,7 @@ const hwaddr allwinner_r40_memmap[] = {
>  [AW_R40_DEV_SRAM_A2]= 0x4000,
>  [AW_R40_DEV_SRAM_A3]= 0x8000,
>  [AW_R40_DEV_SRAM_A4]= 0xb400,
> +[AW_R40_DEV_SRAMC]  = 0x01c0,
>  [AW_R40_DEV_EMAC]   = 0x01c0b000,
>  [AW_R40_DEV_MMC0]   = 0x01c0f000,
>  [AW_R40_DEV_MMC1]   = 0x01c1,
> @@ -76,7 +77,6 @@ struct AwR40Unimplemented {
>  static struct AwR40Unimplemented r40_unimplemented[] = {
>  { "d-engine",   0x0100, 4 * MiB },
>  { "d-inter",0x0140, 128 * KiB },
> -{ "sram-c", 0x01c0, 4 * KiB },
>  { "dma",0x01c02000, 4 * KiB },
>  { "nfdc",   0x01c03000, 4 * KiB },
>  { "ts", 0x01c04000, 4 * KiB },
> @@ -288,6 +288,8 @@ static void allwinner_r40_init(Object *obj)
>   "ram-addr");
>  object_property_add_alias(obj, "ram-size", OBJECT(>dramc),
>"ram-size");
> +
> +object_initialize_child(obj, "sramc", >sramc,
> TYPE_AW_SRAMC_SUN8I_R40);
>  }
>
>  static void allwinner_r40_realize(DeviceState *dev, Error **errp)
> @@ -382,6 +384,9 @@ static void allwinner_r40_realize(DeviceState *dev,
> Error **errp)
> AW_R40_GIC_SPI_TIMER1));
>
>  /* SRAM */
> +sysbus_realize(SYS_BUS_DEVICE(>sramc), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>sramc), 0,
> s->memmap[AW_R40_DEV_SRAMC]);
> +
>  memory_region_init_ram(>sram_a1, OBJECT(dev), "sram A1",
>  16 * KiB, _abort);
>  memory_region_init_ram(>sram_a2, OBJECT(dev), "sram A2",
> diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
> index efeb430a6c..e4c2149175 100644
> --- a/hw/misc/Kconfig
> +++ b/hw/misc/Kconfig
> @@ -170,6 +170,9 @@ config VIRT_CTRL
>  config LASI
>  bool
>
> +config ALLWINNER_SRAMC
> +bool
> +
>  config ALLWINNER_A10_CCM
>  bool
>
> diff --git a/hw/misc/allwinner-sramc.c b/hw/misc/allwinner-sramc.c
> new file mode 100644
> index 00..a8b731f8f2
> --- /dev/null
> +++ b/hw/misc/allwinner-sramc.c
> @@ -0,0 +1,184 @@
> +/*
> + * Allwinner R40 SRAM controller emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/units.h"
> +#include "hw/sysbus.h"
> +#include "migration/vmstate.h"
> +#include "qemu/log.h"
> +#include "qemu/module.h"
> +#include "qapi/error.h"
> +#include "h

Re: [PATCH v4 08/11] hw: arm: allwinner-r40: Add emac and gmac support

2023-05-15 Thread Niek Linnenbank
> +break;
> +default:
> +exit(1);
> +break;
> +}
> +}
> +
> +/* GMAC */
> +object_property_set_link(OBJECT(>gmac), "dma-memory",
> + OBJECT(get_system_memory()),
> _fatal);
> +sysbus_realize(SYS_BUS_DEVICE(>gmac), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>gmac), 0,
> s->memmap[AW_R40_DEV_GMAC]);
> +sysbus_connect_irq(SYS_BUS_DEVICE(>gmac), 0,
> +   qdev_get_gpio_in(DEVICE(>gic),
> AW_R40_GIC_SPI_GMAC));
> +
> +/* EMAC */
> +sysbus_realize(SYS_BUS_DEVICE(>emac), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>emac), 0,
> s->memmap[AW_R40_DEV_EMAC]);
> +sysbus_connect_irq(SYS_BUS_DEVICE(>emac), 0,
> +   qdev_get_gpio_in(DEVICE(>gic),
> AW_R40_GIC_SPI_EMAC));
> +
>  /* Unimplemented devices */
>  for (i = 0; i < ARRAY_SIZE(r40_unimplemented); i++) {
>  create_unimplemented_device(r40_unimplemented[i].device_name,
> diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c
> index 20a4550c68..74121d8966 100644
> --- a/hw/arm/bananapi_m2u.c
> +++ b/hw/arm/bananapi_m2u.c
> @@ -92,6 +92,9 @@ static void bpim2u_init(MachineState *machine)
>  object_property_set_int(OBJECT(r40), "ram-size",
>  r40->ram_size, _abort);
>
> +/* GMAC PHY */
> +object_property_set_uint(OBJECT(r40), "gmac-phy-addr", 1,
> _abort);
> +
>  /* Mark R40 object realized */
>  qdev_realize(DEVICE(r40), NULL, _abort);
>
> diff --git a/include/hw/arm/allwinner-r40.h
> b/include/hw/arm/allwinner-r40.h
> index 8243e8903b..5f2d08489e 100644
> --- a/include/hw/arm/allwinner-r40.h
> +++ b/include/hw/arm/allwinner-r40.h
> @@ -28,6 +28,8 @@
>  #include "hw/misc/allwinner-r40-ccu.h"
>  #include "hw/misc/allwinner-r40-dramc.h"
>  #include "hw/i2c/allwinner-i2c.h"
> +#include "hw/net/allwinner_emac.h"
> +#include "hw/net/allwinner-sun8i-emac.h"
>  #include "target/arm/cpu.h"
>  #include "sysemu/block-backend.h"
>
> @@ -36,6 +38,7 @@ enum {
>  AW_R40_DEV_SRAM_A2,
>  AW_R40_DEV_SRAM_A3,
>  AW_R40_DEV_SRAM_A4,
> +AW_R40_DEV_EMAC,
>  AW_R40_DEV_MMC0,
>  AW_R40_DEV_MMC1,
>  AW_R40_DEV_MMC2,
> @@ -51,6 +54,7 @@ enum {
>  AW_R40_DEV_UART6,
>  AW_R40_DEV_UART7,
>  AW_R40_DEV_TWI0,
> +AW_R40_DEV_GMAC,
>  AW_R40_DEV_GIC_DIST,
>  AW_R40_DEV_GIC_CPU,
>  AW_R40_DEV_GIC_HYP,
> @@ -103,6 +107,8 @@ struct AwR40State {
>  AwR40ClockCtlState ccu;
>  AwR40DramCtlState dramc;
>  AWI2CState i2c0;
> +AwEmacState emac;
> +AwSun8iEmacState gmac;
>  GICState gic;
>  MemoryRegion sram_a1;
>  MemoryRegion sram_a2;
> --
> 2.25.1
>
>
Regards,
Niek
-- 
Niek Linnenbank


Re: [PATCH v4 07/11] hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support

2023-05-15 Thread Niek Linnenbank
tic void allwinner_sdhost_realize(DeviceState *dev,
> Error **errp)
>  static void allwinner_sdhost_reset(DeviceState *dev)
>  {
>  AwSdHostState *s = AW_SDHOST(dev);
> +AwSdHostClass *sc = AW_SDHOST_GET_CLASS(s);
>
>  s->global_ctl = REG_SD_GCTL_RST;
>  s->clock_ctl = REG_SD_CKCR_RST;
> @@ -855,6 +883,10 @@ static void allwinner_sdhost_reset(DeviceState *dev)
>  }
>
>  s->status_crc = REG_SD_CRC_STA_RST;
> +
> +if (sc->can_calibrate) {
> +s->sample_delay = REG_SD_SAMPLE_DL_RST;
> +}
>  }
>
>  static void allwinner_sdhost_bus_class_init(ObjectClass *klass, void
> *data)
> @@ -888,6 +920,24 @@ static void
> allwinner_sdhost_sun5i_class_init(ObjectClass *klass, void *data)
>  sc->is_sun4i = false;
>  }
>
> +static void allwinner_sdhost_sun50i_a64_class_init(ObjectClass *klass,
> +   void *data)
> +{
> +AwSdHostClass *sc = AW_SDHOST_CLASS(klass);
> +sc->max_desc_size = 64 * KiB;
> +sc->is_sun4i = false;
> +sc->can_calibrate = true;
>

For the existing functions allwinner_sdhost_sun4i_class_init() and
allwinner_sdhost_sun5i_class_init(), could you please add
'sc->can_calibrate = false'?
That way, we make it explicit that those types do not support the sample
delay register.

With that resolved, the code looks good to me:

Reviewed-by: Niek Linnenbank 


> +}
> +
> +static void allwinner_sdhost_sun50i_a64_emmc_class_init(ObjectClass
> *klass,
> +void *data)
> +{
> +AwSdHostClass *sc = AW_SDHOST_CLASS(klass);
> +sc->max_desc_size = 8 * KiB;
> +sc->is_sun4i = false;
> +sc->can_calibrate = true;
> +}
> +
>  static const TypeInfo allwinner_sdhost_info = {
>  .name  = TYPE_AW_SDHOST,
>  .parent= TYPE_SYS_BUS_DEVICE,
> @@ -910,6 +960,18 @@ static const TypeInfo allwinner_sdhost_sun5i_info = {
>  .class_init= allwinner_sdhost_sun5i_class_init,
>  };
>
> +static const TypeInfo allwinner_sdhost_sun50i_a64_info = {
> +.name  = TYPE_AW_SDHOST_SUN50I_A64,
> +.parent= TYPE_AW_SDHOST,
> +.class_init= allwinner_sdhost_sun50i_a64_class_init,
> +};
> +
> +static const TypeInfo allwinner_sdhost_sun50i_a64_emmc_info = {
> +.name  = TYPE_AW_SDHOST_SUN50I_A64_EMMC,
> +.parent= TYPE_AW_SDHOST,
> +.class_init= allwinner_sdhost_sun50i_a64_emmc_class_init,
> +};
> +
>  static const TypeInfo allwinner_sdhost_bus_info = {
>  .name = TYPE_AW_SDHOST_BUS,
>  .parent = TYPE_SD_BUS,
> @@ -922,6 +984,8 @@ static void allwinner_sdhost_register_types(void)
>  type_register_static(_sdhost_info);
>  type_register_static(_sdhost_sun4i_info);
>  type_register_static(_sdhost_sun5i_info);
> +type_register_static(_sdhost_sun50i_a64_info);
> +type_register_static(_sdhost_sun50i_a64_emmc_info);
>  type_register_static(_sdhost_bus_info);
>  }
>
> diff --git a/include/hw/sd/allwinner-sdhost.h
> b/include/hw/sd/allwinner-sdhost.h
> index 30c1e60404..1b951177dd 100644
> --- a/include/hw/sd/allwinner-sdhost.h
> +++ b/include/hw/sd/allwinner-sdhost.h
> @@ -38,6 +38,12 @@
>  /** Allwinner sun5i family and newer (A13, H2+, H3, etc) */
>  #define TYPE_AW_SDHOST_SUN5I TYPE_AW_SDHOST "-sun5i"
>
> +/** Allwinner sun50i-a64 */
> +#define TYPE_AW_SDHOST_SUN50I_A64 TYPE_AW_SDHOST "-sun50i-a64"
> +
> +/** Allwinner sun50i-a64 emmc */
> +#define TYPE_AW_SDHOST_SUN50I_A64_EMMC  TYPE_AW_SDHOST "-sun50i-a64-emmc"
> +
>  /** @} */
>
>  /**
> @@ -110,6 +116,7 @@ struct AwSdHostState {
>  uint32_t startbit_detect;   /**< eMMC DDR Start Bit Detection Control
> */
>  uint32_t response_crc;  /**< Response CRC */
>  uint32_t data_crc[8];   /**< Data CRC */
> +uint32_t sample_delay;  /**< Sample delay control */
>  uint32_t status_crc;/**< Status CRC */
>
>  /** @} */
> @@ -132,6 +139,8 @@ struct AwSdHostClass {
>  size_t max_desc_size;
>  bool   is_sun4i;
>
> +/** does the IP block support autocalibration? */
> +bool can_calibrate;
>  };
>
>  #endif /* HW_SD_ALLWINNER_SDHOST_H */
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v4 06/11] hw/arm/allwinner-r40: add SDRAM controller device

2023-05-15 Thread Niek Linnenbank
ate i2c0;
>  GICState gic;
>  MemoryRegion sram_a1;
> diff --git a/include/hw/misc/allwinner-r40-dramc.h
> b/include/hw/misc/allwinner-r40-dramc.h
> new file mode 100644
> index 000000..6a1a3a7893
> --- /dev/null
> +++ b/include/hw/misc/allwinner-r40-dramc.h
> @@ -0,0 +1,108 @@
> +/*
> + * Allwinner R40 SDRAM Controller emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef HW_MISC_ALLWINNER_R40_DRAMC_H
> +#define HW_MISC_ALLWINNER_R40_DRAMC_H
> +
> +#include "qom/object.h"
> +#include "hw/sysbus.h"
> +#include "exec/hwaddr.h"
> +
> +/**
> + * Constants
> + * @{
> + */
> +
> +/** Highest register address used by DRAMCOM module */
> +#define AW_R40_DRAMCOM_REGS_MAXADDR  (0x804)
> +
> +/** Total number of known DRAMCOM registers */
> +#define AW_R40_DRAMCOM_REGS_NUM  (AW_R40_DRAMCOM_REGS_MAXADDR / \
> + sizeof(uint32_t))
> +
> +/** Highest register address used by DRAMCTL module */
> +#define AW_R40_DRAMCTL_REGS_MAXADDR  (0x88c)
> +
> +/** Total number of known DRAMCTL registers */
> +#define AW_R40_DRAMCTL_REGS_NUM  (AW_R40_DRAMCTL_REGS_MAXADDR / \
> + sizeof(uint32_t))
> +
> +/** Highest register address used by DRAMPHY module */
> +#define AW_R40_DRAMPHY_REGS_MAXADDR  (0x4)
> +
> +/** Total number of known DRAMPHY registers */
> +#define AW_R40_DRAMPHY_REGS_NUM  (AW_R40_DRAMPHY_REGS_MAXADDR / \
> + sizeof(uint32_t))
> +
> +/** @} */
> +
> +/**
> + * Object model
> + * @{
> + */
> +
> +#define TYPE_AW_R40_DRAMC "allwinner-r40-dramc"
> +OBJECT_DECLARE_SIMPLE_TYPE(AwR40DramCtlState, AW_R40_DRAMC)
> +
> +/** @} */
> +
> +/**
> + * Allwinner R40 SDRAM Controller object instance state.
> + */
> +struct AwR40DramCtlState {
> +/*< private >*/
> +SysBusDevice parent_obj;
> +/*< public >*/
> +
> +/** Physical base address for start of RAM */
> +hwaddr ram_addr;
> +
> +/** Total RAM size in megabytes */
> +uint32_t ram_size;
> +
> +uint8_t set_row_bits;
> +uint8_t set_bank_bits;
> +uint8_t set_col_bits;
> +
> +/**
> + * @name Memory Regions
> + * @{
> + */
> +MemoryRegion dramcom_iomem;/**< DRAMCOM module I/O registers */
> +MemoryRegion dramctl_iomem;/**< DRAMCTL module I/O registers */
> +MemoryRegion dramphy_iomem;/**< DRAMPHY module I/O registers */
> +MemoryRegion dram_high;/**< The high 1G dram for dualrank
> detect */
> +MemoryRegion detect_cells; /**< DRAM memory cells for auto detect
> */
> +
> +/** @} */
> +
> +/**
> + * @name Hardware Registers
> + * @{
> + */
> +
> +uint32_t dramcom[AW_R40_DRAMCOM_REGS_NUM]; /**< DRAMCOM registers */
> +uint32_t dramctl[AW_R40_DRAMCTL_REGS_NUM]; /**< DRAMCTL registers */
> +uint32_t dramphy[AW_R40_DRAMPHY_REGS_NUM] ;/**< DRAMPHY registers */
> +
> +/** @} */
> +
> +};
> +
> +#endif /* HW_MISC_ALLWINNER_R40_DRAMC_H */
> --
> 2.25.1
>
>
Looks good to me.

Reviewed-by: Niek Linnenbank 

-- 
Niek Linnenbank


Re: [PATCH v4 05/11] hw/misc: Rename axp209 to axp22x and add support AXP221 PMU

2023-05-15 Thread Niek Linnenbank
pped
here to match.


> +VMSTATE_END_OF_LIST()
>

Another question that comes to my mind here: is it allowed by the migration
API to have a new axp2xx device
show up while the previous axp209 disappears? (in case for the allwinner
A10 cubieboard).

My expectation with this code would be that during such a migration, any
current state of the axp209 device would be lost
and a new fresh device would show up to the guest.

I don't know enough about the migration support to tell if this is OK or
not.
If another reviewer could help clarify, that would be great.


> +}
> +};
> +
> +static void axp2xx_class_init(ObjectClass *oc, void *data)
> +{
> +DeviceClass *dc = DEVICE_CLASS(oc);
> +I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc);
> +ResettableClass *rc = RESETTABLE_CLASS(oc);
> +
> +rc->phases.enter = axp2xx_reset_enter;
> +dc->vmsd = _axp2xx;
> +isc->event = axp2xx_event;
> +isc->recv = axp2xx_rx;
> +isc->send = axp2xx_tx;
> +}
> +
> +static const TypeInfo axp2xx_info = {
> +.name = TYPE_AXP2XX,
> +.parent = TYPE_I2C_SLAVE,
> +.instance_size = sizeof(AXP2xxI2CState),
> +.class_size = sizeof(AXP2xxClass),
> +.class_init = axp2xx_class_init,
> +.abstract = true,
> +};
> +
> +static void axp209_class_init(ObjectClass *oc, void *data)
> +{
> +AXP2xxClass *sc = AXP2XX_CLASS(oc);
> +
> +sc->reset_enter = axp209_reset_enter;
> +}
> +
> +static const TypeInfo axp209_info = {
> +.name = TYPE_AXP209_PMU,
> +.parent = TYPE_AXP2XX,
> +.class_init = axp209_class_init
> +};
> +
> +static void axp221_class_init(ObjectClass *oc, void *data)
> +{
> +AXP2xxClass *sc = AXP2XX_CLASS(oc);
> +
> +sc->reset_enter = axp221_reset_enter;
> +}
> +
> +static const TypeInfo axp221_info = {
> +.name = TYPE_AXP221_PMU,
> +.parent = TYPE_AXP2XX,
> +.class_init = axp221_class_init,
> +};
> +
> +static void axp2xx_register_devices(void)
> +{
> +type_register_static(_info);
> +type_register_static(_info);
> +type_register_static(_info);
> +}
> +
> +type_init(axp2xx_register_devices);
> diff --git a/hw/misc/meson.build b/hw/misc/meson.build
> index 96e35f1cdb..1db034 100644
> --- a/hw/misc/meson.build
> +++ b/hw/misc/meson.build
> @@ -45,7 +45,7 @@ softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true:
> files('allwinner-h3-dramc.c
>  softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true:
> files('allwinner-h3-sysctrl.c'))
>  softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true:
> files('allwinner-sid.c'))
>  softmmu_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true:
> files('allwinner-r40-ccu.c'))
> -softmmu_ss.add(when: 'CONFIG_AXP209_PMU', if_true: files('axp209.c'))
> +softmmu_ss.add(when: 'CONFIG_AXP2XX_PMU', if_true: files('axp2xx.c'))
>  softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c'))
>  softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c'))
>  softmmu_ss.add(when: 'CONFIG_ECCMEMCTL', if_true: files('eccmemctl.c'))
> diff --git a/hw/misc/trace-events b/hw/misc/trace-events
> index c47876a902..24cdec83fe 100644
> --- a/hw/misc/trace-events
> +++ b/hw/misc/trace-events
> @@ -23,10 +23,10 @@ allwinner_sid_write(uint64_t offset, uint64_t data,
> unsigned size) "offset 0x%"
>  avr_power_read(uint8_t value) "power_reduc read value:%u"
>  avr_power_write(uint8_t value) "power_reduc write value:%u"
>
> -# axp209.c
> -axp209_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8
> -axp209_select(uint8_t reg) "Accessing reg 0x%" PRIx8
> -axp209_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8
> +# axp2xx
> +axp2xx_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8
> +axp2xx_select(uint8_t reg) "Accessing reg 0x%" PRIx8
> +axp2xx_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8
>
>  # eccmemctl.c
>  ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x"
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v4 04/11] hw: arm: allwinner-r40: Add i2c0 device

2023-05-14 Thread Niek Linnenbank
On Wed, May 10, 2023 at 12:30 PM  wrote:

> From: qianfan Zhao 
>
> TWI(i2c) is designed to be used as an interface between CPU host and the
> serial 2-Wire bus. It can support all standard 2-Wire transfer, can be
> operated in standard mode(100kbit/s) or fast-mode, supporting data rate
> up to 400kbit/s.
>
> Signed-off-by: qianfan Zhao 
>
Reviewed-by: Niek Linnenbank 

> ---
>  hw/arm/allwinner-r40.c | 11 ++-
>  include/hw/arm/allwinner-r40.h |  3 +++
>  2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
> index 537a90b23d..4bc582630c 100644
> --- a/hw/arm/allwinner-r40.c
> +++ b/hw/arm/allwinner-r40.c
> @@ -52,6 +52,7 @@ const hwaddr allwinner_r40_memmap[] = {
>  [AW_R40_DEV_UART5]  = 0x01c29400,
>  [AW_R40_DEV_UART6]  = 0x01c29800,
>  [AW_R40_DEV_UART7]  = 0x01c29c00,
> +[AW_R40_DEV_TWI0]   = 0x01c2ac00,
>  [AW_R40_DEV_GIC_DIST]   = 0x01c81000,
>  [AW_R40_DEV_GIC_CPU]= 0x01c82000,
>  [AW_R40_DEV_GIC_HYP]= 0x01c84000,
> @@ -115,7 +116,6 @@ static struct AwR40Unimplemented r40_unimplemented[] =
> {
>  { "uart7",  0x01c29c00, 1 * KiB },
>  { "ps20",   0x01c2a000, 1 * KiB },
>  { "ps21",   0x01c2a400, 1 * KiB },
> -{ "twi0",   0x01c2ac00, 1 * KiB },
>  { "twi1",   0x01c2b000, 1 * KiB },
>  { "twi2",   0x01c2b400, 1 * KiB },
>  { "twi3",   0x01c2b800, 1 * KiB },
> @@ -167,6 +167,7 @@ enum {
>  AW_R40_GIC_SPI_UART1 =  2,
>  AW_R40_GIC_SPI_UART2 =  3,
>  AW_R40_GIC_SPI_UART3 =  4,
> +AW_R40_GIC_SPI_TWI0  =  7,
>  AW_R40_GIC_SPI_UART4 = 17,
>  AW_R40_GIC_SPI_UART5 = 18,
>  AW_R40_GIC_SPI_UART6 = 19,
> @@ -270,6 +271,8 @@ static void allwinner_r40_init(Object *obj)
>  object_initialize_child(obj, mmc_names[i], >mmc[i],
>  TYPE_AW_SDHOST_SUN5I);
>  }
> +
> +object_initialize_child(obj, "twi0", >i2c0, TYPE_AW_I2C_SUN6I);
>  }
>
>  static void allwinner_r40_realize(DeviceState *dev, Error **errp)
> @@ -416,6 +419,12 @@ static void allwinner_r40_realize(DeviceState *dev,
> Error **errp)
> 115200, serial_hd(i), DEVICE_NATIVE_ENDIAN);
>  }
>
> +/* I2C */
> +sysbus_realize(SYS_BUS_DEVICE(>i2c0), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>i2c0), 0,
> s->memmap[AW_R40_DEV_TWI0]);
> +sysbus_connect_irq(SYS_BUS_DEVICE(>i2c0), 0,
> +   qdev_get_gpio_in(DEVICE(>gic),
> AW_R40_GIC_SPI_TWI0));
> +
>  /* Unimplemented devices */
>  for (i = 0; i < ARRAY_SIZE(r40_unimplemented); i++) {
>  create_unimplemented_device(r40_unimplemented[i].device_name,
> diff --git a/include/hw/arm/allwinner-r40.h
> b/include/hw/arm/allwinner-r40.h
> index 959b5dc4e0..95366f4eee 100644
> --- a/include/hw/arm/allwinner-r40.h
> +++ b/include/hw/arm/allwinner-r40.h
> @@ -26,6 +26,7 @@
>  #include "hw/intc/arm_gic.h"
>  #include "hw/sd/allwinner-sdhost.h"
>  #include "hw/misc/allwinner-r40-ccu.h"
> +#include "hw/i2c/allwinner-i2c.h"
>  #include "target/arm/cpu.h"
>  #include "sysemu/block-backend.h"
>
> @@ -48,6 +49,7 @@ enum {
>  AW_R40_DEV_UART5,
>  AW_R40_DEV_UART6,
>  AW_R40_DEV_UART7,
> +AW_R40_DEV_TWI0,
>  AW_R40_DEV_GIC_DIST,
>  AW_R40_DEV_GIC_CPU,
>  AW_R40_DEV_GIC_HYP,
> @@ -89,6 +91,7 @@ struct AwR40State {
>  AwA10PITState timer;
>  AwSdHostState mmc[AW_R40_NUM_MMCS];
>  AwR40ClockCtlState ccu;
> +AWI2CState i2c0;
>  GICState gic;
>  MemoryRegion sram_a1;
>  MemoryRegion sram_a2;
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v4 03/11] hw: allwinner-r40: Complete uart devices

2023-05-14 Thread Niek Linnenbank
Hi Qianfan,


On Wed, May 10, 2023 at 12:30 PM  wrote:

> From: qianfan Zhao 
>
> R40 has eight UARTs, support both 16450 and 16550 compatible modes.
>
> Signed-off-by: qianfan Zhao 
> ---
>  hw/arm/allwinner-r40.c | 31 ---
>  include/hw/arm/allwinner-r40.h |  8 
>  2 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
> index 128c0ca470..537a90b23d 100644
> --- a/hw/arm/allwinner-r40.c
> +++ b/hw/arm/allwinner-r40.c
> @@ -45,6 +45,13 @@ const hwaddr allwinner_r40_memmap[] = {
>  [AW_R40_DEV_CCU]= 0x01c2,
>  [AW_R40_DEV_PIT]= 0x01c20c00,
>  [AW_R40_DEV_UART0]  = 0x01c28000,
> +[AW_R40_DEV_UART1]  = 0x01c28400,
> +[AW_R40_DEV_UART2]  = 0x01c28800,
> +[AW_R40_DEV_UART3]  = 0x01c28c00,
> +[AW_R40_DEV_UART4]  = 0x01c29000,
> +[AW_R40_DEV_UART5]  = 0x01c29400,
> +[AW_R40_DEV_UART6]  = 0x01c29800,
> +[AW_R40_DEV_UART7]  = 0x01c29c00,
>

After adding the uarts to the memory map here, you should remove them from
the unimplemented array.

 [AW_R40_DEV_GIC_DIST]   = 0x01c81000,
>  [AW_R40_DEV_GIC_CPU]= 0x01c82000,
>  [AW_R40_DEV_GIC_HYP]= 0x01c84000,
> @@ -160,6 +167,10 @@ enum {
>  AW_R40_GIC_SPI_UART1 =  2,
>  AW_R40_GIC_SPI_UART2 =  3,
>  AW_R40_GIC_SPI_UART3 =  4,
>

Since you put the addition of UART1-7 in this patch, probably it makes
sense to have adding the lines 'AW_R40_GIC_SPI_UART1/2/3' also part of this
patch.

With the two above remarks resolved, the patch looks good to me.

Reviewed-by: Niek Linnenbank 

Regards,
Niek

> +AW_R40_GIC_SPI_UART4 = 17,
> +AW_R40_GIC_SPI_UART5 = 18,
> +AW_R40_GIC_SPI_UART6 = 19,
> +AW_R40_GIC_SPI_UART7 = 20,
>  AW_R40_GIC_SPI_TIMER0= 22,
>  AW_R40_GIC_SPI_TIMER1= 23,
>  AW_R40_GIC_SPI_MMC0  = 32,
> @@ -387,9 +398,23 @@ static void allwinner_r40_realize(DeviceState *dev,
> Error **errp)
>  }
>
>  /* UART0. For future clocktree API: All UARTS are connected to
> APB2_CLK. */
> -serial_mm_init(get_system_memory(), s->memmap[AW_R40_DEV_UART0], 2,
> -   qdev_get_gpio_in(DEVICE(>gic),
> AW_R40_GIC_SPI_UART0),
> -   115200, serial_hd(0), DEVICE_NATIVE_ENDIAN);
> +for (int i = 0; i < AW_R40_NUM_UARTS; i++) {
> +static const int uart_irqs[AW_R40_NUM_UARTS] = {
> +AW_R40_GIC_SPI_UART0,
> +AW_R40_GIC_SPI_UART1,
> +AW_R40_GIC_SPI_UART2,
> +AW_R40_GIC_SPI_UART3,
> +AW_R40_GIC_SPI_UART4,
> +AW_R40_GIC_SPI_UART5,
> +AW_R40_GIC_SPI_UART6,
> +AW_R40_GIC_SPI_UART7,
> +};
> +const hwaddr addr = s->memmap[AW_R40_DEV_UART0 + i];
> +
> +serial_mm_init(get_system_memory(), addr, 2,
> +   qdev_get_gpio_in(DEVICE(>gic), uart_irqs[i]),
> +   115200, serial_hd(i), DEVICE_NATIVE_ENDIAN);
> +}
>
>  /* Unimplemented devices */
>  for (i = 0; i < ARRAY_SIZE(r40_unimplemented); i++) {
> diff --git a/include/hw/arm/allwinner-r40.h
> b/include/hw/arm/allwinner-r40.h
> index 3be9dc962b..959b5dc4e0 100644
> --- a/include/hw/arm/allwinner-r40.h
> +++ b/include/hw/arm/allwinner-r40.h
> @@ -41,6 +41,13 @@ enum {
>  AW_R40_DEV_CCU,
>  AW_R40_DEV_PIT,
>  AW_R40_DEV_UART0,
> +AW_R40_DEV_UART1,
> +AW_R40_DEV_UART2,
> +AW_R40_DEV_UART3,
> +AW_R40_DEV_UART4,
> +AW_R40_DEV_UART5,
> +AW_R40_DEV_UART6,
> +AW_R40_DEV_UART7,
>  AW_R40_DEV_GIC_DIST,
>  AW_R40_DEV_GIC_CPU,
>  AW_R40_DEV_GIC_HYP,
> @@ -70,6 +77,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AwR40State, AW_R40)
>   * which are currently emulated by the R40 SoC code.
>   */
>  #define AW_R40_NUM_MMCS 4
> +#define AW_R40_NUM_UARTS8
>
>  struct AwR40State {
>  /*< private >*/
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v4 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support

2023-05-14 Thread Niek Linnenbank
!= 0) {
> +error_report("This board can only be used with cortex-a7 CPU");
> +exit(1);
> +}
> +
> +r40 = AW_R40(object_new(TYPE_AW_R40));
> +object_property_add_child(OBJECT(machine), "soc", OBJECT(r40));
> +object_unref(OBJECT(r40));
> +
> +/* Setup timer properties */
> +object_property_set_int(OBJECT(r40), "clk0-freq", 32768,
> _abort);
> +object_property_set_int(OBJECT(r40), "clk1-freq", 24 * 1000 * 1000,
> +_abort);
> +
> +/* Mark R40 object realized */
> +qdev_realize(DEVICE(r40), NULL, _abort);
> +
> +/*
> + * Plug in SD card and try load bootrom, R40 has 4 mmc controllers
> but can
> + * only booting from mmc0 and mmc2.
> + */
> +for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
> +switch (i) {
> +case 0:
> +case 2:
> +mmc_attach_drive(r40, >mmc[i], i,
> + !machine->kernel_filename &&
> !bootroom_loaded,
> + _loaded);
> +break;
> +default:
> +mmc_attach_drive(r40, >mmc[i], i, false, NULL);
> +break;
> +}
> +}
> +
> +/* SDRAM */
> +memory_region_add_subregion(get_system_memory(),
> +r40->memmap[AW_R40_DEV_SDRAM],
> machine->ram);
> +
> +bpim2u_binfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM];
> +bpim2u_binfo.ram_size = machine->ram_size;
> +bpim2u_binfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
> +arm_load_kernel(ARM_CPU(first_cpu), machine, _binfo);
> +}
> +
> +static void bpim2u_machine_init(MachineClass *mc)
> +{
> +mc->desc = "Bananapi M2U (Cortex-A7)";
> +mc->init = bpim2u_init;
> +mc->min_cpus = AW_R40_NUM_CPUS;
> +mc->max_cpus = AW_R40_NUM_CPUS;
> +mc->default_cpus = AW_R40_NUM_CPUS;
> +mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a7");
> +mc->default_ram_size = 1 * GiB;
> +mc->default_ram_id = "bpim2u.ram";
> +}
> +
> +DEFINE_MACHINE("bpim2u", bpim2u_machine_init)
> diff --git a/hw/arm/meson.build b/hw/arm/meson.build
> index b545ba0e4f..870ec67376 100644
> --- a/hw/arm/meson.build
> +++ b/hw/arm/meson.build
> @@ -37,6 +37,7 @@ arm_ss.add(when: 'CONFIG_OMAP', if_true:
> files('omap1.c', 'omap2.c'))
>  arm_ss.add(when: 'CONFIG_STRONGARM', if_true: files('strongarm.c'))
>  arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true:
> files('allwinner-a10.c', 'cubieboard.c'))
>  arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c',
> 'orangepi.c'))
> +arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true:
> files('allwinner-r40.c', 'bananapi_m2u.c'))
>  arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c'))
>  arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true:
> files('stm32f100_soc.c'))
>  arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true:
> files('stm32f205_soc.c'))
> diff --git a/include/hw/arm/allwinner-r40.h
> b/include/hw/arm/allwinner-r40.h
> new file mode 100644
> index 00..348bf25d6b
> --- /dev/null
> +++ b/include/hw/arm/allwinner-r40.h
> @@ -0,0 +1,110 @@
> +/*
> + * Allwinner R40/A40i/T3 System on Chip emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef HW_ARM_ALLWINNER_R40_H
> +#define HW_ARM_ALLWINNER_R40_H
> +
> +#include "qom/object.h"
> +#include "hw/arm/boot.h"
> +#include "hw/timer/allwinner-a10-pit.h"
> +#include "hw/intc/arm_gic.h"
> +#include "hw/sd/allwinner-sdhost.h"
> +#include "target/arm/cpu.h"
> +#include "sysemu/block-backend.h"
> +
> +enum {
> +AW_R40_DEV_SRAM_A1,
> +AW_R40_DEV_SRAM_A2,
> +AW_R40_DEV_SRAM_A3,
> +AW_R40_DEV_SRAM_A4,
> +AW_R40_DEV_MMC0,
> +AW_R40_DEV_MMC1,
> +AW_R40_DEV_MMC2,
> +AW_R40_DEV_MMC3,
> +AW_R40_DEV_CCU,
> +AW_R40_DEV_PIT,
> +AW_R40_DEV_UART0,
> +AW_R40_DEV_GIC_DIST,
> +AW_R40_DEV_GIC_CPU,
> +AW_R40_DEV_GIC_HYP,
> +AW_R40_DEV_GIC_VCPU,
> +AW_R40_DEV_SDRAM
> +};
> +
> +#define AW_R40_NUM_CPUS  (4)
> +
> +/**
> + * Allwinner R40 object model
> + * @{
> + */
> +
> +/** Object type for the Allwinner R40 SoC */
> +#define TYPE_AW_R40 "allwinner-r40"
> +
> +/** Convert input object to Allwinner R40 state object */
> +OBJECT_DECLARE_SIMPLE_TYPE(AwR40State, AW_R40)
> +
> +/** @} */
> +
> +/**
> + * Allwinner R40 object
> + *
> + * This struct contains the state of all the devices
> + * which are currently emulated by the R40 SoC code.
> + */
> +#define AW_R40_NUM_MMCS 4
> +
> +struct AwR40State {
> +/*< private >*/
> +DeviceState parent_obj;
> +/*< public >*/
> +
> +ARMCPU cpus[AW_R40_NUM_CPUS];
> +const hwaddr *memmap;
> +AwA10PITState timer;
> +AwSdHostState mmc[AW_R40_NUM_MMCS];
> +GICState gic;
> +MemoryRegion sram_a1;
> +MemoryRegion sram_a2;
> +MemoryRegion sram_a3;
> +MemoryRegion sram_a4;
> +};
> +
> +/**
> + * Emulate Boot ROM firmware setup functionality.
> + *
> + * A real Allwinner R40 SoC contains a Boot ROM
> + * which is the first code that runs right after
> + * the SoC is powered on. The Boot ROM is responsible
> + * for loading user code (e.g. a bootloader) from any
> + * of the supported external devices and writing the
> + * downloaded code to internal SRAM. After loading the SoC
> + * begins executing the code written to SRAM.
> + *
> + * This function emulates the Boot ROM by copying 32 KiB
> + * of data from the given block device and writes it to
> + * the start of the first internal SRAM memory.
> + *
> + * @s: Allwinner R40 state object pointer
> + * @blk: Block backend device object pointer
> + * @unit: the mmc control's unit
> + */
> +bool allwinner_r40_bootrom_setup(AwR40State *s, BlockBackend *blk, int
> unit);
> +
> +#endif /* HW_ARM_ALLWINNER_R40_H */
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v4 02/11] hw/arm/allwinner-r40: add Clock Control Unit

2023-05-14 Thread Niek Linnenbank
On Wed, May 10, 2023 at 12:30 PM  wrote:

> From: qianfan Zhao 
>
> The CCU provides the registers to program the PLLs and the controls
> most of the clock generation, division, distribution, synchronization
> and gating.
>
> This commit adds support for the Clock Control Unit which emulates
> a simple read/write register interface.
>
> Signed-off-by: qianfan Zhao 
>
Reviewed-by: Niek Linnenbank 


> ---
>  hw/arm/allwinner-r40.c  |   8 +-
>  hw/misc/allwinner-r40-ccu.c | 209 
>  hw/misc/meson.build |   1 +
>  include/hw/arm/allwinner-r40.h  |   2 +
>  include/hw/misc/allwinner-r40-ccu.h |  65 +
>  5 files changed, 284 insertions(+), 1 deletion(-)
>  create mode 100644 hw/misc/allwinner-r40-ccu.c
>  create mode 100644 include/hw/misc/allwinner-r40-ccu.h
>
> diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
> index b743d64253..128c0ca470 100644
> --- a/hw/arm/allwinner-r40.c
> +++ b/hw/arm/allwinner-r40.c
> @@ -42,6 +42,7 @@ const hwaddr allwinner_r40_memmap[] = {
>  [AW_R40_DEV_MMC1]   = 0x01c1,
>  [AW_R40_DEV_MMC2]   = 0x01c11000,
>  [AW_R40_DEV_MMC3]   = 0x01c12000,
> +[AW_R40_DEV_CCU]= 0x01c2,
>  [AW_R40_DEV_PIT]= 0x01c20c00,
>  [AW_R40_DEV_UART0]  = 0x01c28000,
>  [AW_R40_DEV_GIC_DIST]   = 0x01c81000,
> @@ -80,7 +81,6 @@ static struct AwR40Unimplemented r40_unimplemented[] = {
>  { "usb2-host",  0x01c1c000, 4 * KiB },
>  { "cs1",0x01c1d000, 4 * KiB },
>  { "spi3",   0x01c1f000, 4 * KiB },
> -{ "ccu",0x01c2, 1 * KiB },
>  { "rtc",0x01c20400, 1 * KiB },
>  { "pio",0x01c20800, 1 * KiB },
>  { "owa",0x01c21000, 1 * KiB },
> @@ -253,6 +253,8 @@ static void allwinner_r40_init(Object *obj)
>  object_property_add_alias(obj, "clk1-freq", OBJECT(>timer),
>"clk1-freq");
>
> +object_initialize_child(obj, "ccu", >ccu, TYPE_AW_R40_CCU);
> +
>  for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
>  object_initialize_child(obj, mmc_names[i], >mmc[i],
>  TYPE_AW_SDHOST_SUN5I);
> @@ -367,6 +369,10 @@ static void allwinner_r40_realize(DeviceState *dev,
> Error **errp)
>  memory_region_add_subregion(get_system_memory(),
>  s->memmap[AW_R40_DEV_SRAM_A4],
> >sram_a4);
>
> +/* Clock Control Unit */
> +sysbus_realize(SYS_BUS_DEVICE(>ccu), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>ccu), 0,
> s->memmap[AW_R40_DEV_CCU]);
> +
>  /* SD/MMC */
>  for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
>  qemu_irq irq = qdev_get_gpio_in(DEVICE(>gic),
> diff --git a/hw/misc/allwinner-r40-ccu.c b/hw/misc/allwinner-r40-ccu.c
> new file mode 100644
> index 00..d82fee12db
> --- /dev/null
> +++ b/hw/misc/allwinner-r40-ccu.c
> @@ -0,0 +1,209 @@
> +/*
> + * Allwinner R40 Clock Control Unit emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/units.h"
> +#include "hw/sysbus.h"
> +#include "migration/vmstate.h"
> +#include "qemu/log.h"
> +#include "qemu/module.h"
> +#include "hw/misc/allwinner-r40-ccu.h"
> +
> +/* CCU register offsets */
> +enum {
> +REG_PLL_CPUX_CTRL   = 0x,
> +REG_PLL_AUDIO_CTRL  = 0x0008,
> +REG_PLL_VIDEO0_CTRL = 0x0010,
> +REG_PLL_VE_CTRL = 0x0018,
> +REG_PLL_DDR0_CTRL   = 0x0020,
> +REG_PLL_PERIPH0_CTRL= 0x0028,
> +REG_PLL_PERIPH1_CTRL= 0x002c,
> +REG_PLL_VIDEO1_CTRL = 0x0030,
> +REG_PLL_SATA_CTRL   = 0x0034,
> +REG_PLL_GPU_CTRL= 0x0038,
> +REG_PLL_MIPI_CTRL

Re: [PATCH v4 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support

2023-05-14 Thread Niek Linnenbank
On Wed, May 10, 2023 at 12:30 PM  wrote:

> From: qianfan Zhao 
>
> Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU,
> and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3
> for In-Car Entertainment usage, A40i and A40pro are variants that
> differ in applicable temperatures range (industrial and military).
>
> Signed-off-by: qianfan Zhao 
>
Reviewed-by: Niek Linnenbank 


> ---
>  hw/arm/Kconfig |  10 +
>  hw/arm/allwinner-r40.c | 418 +
>  hw/arm/bananapi_m2u.c  | 129 ++
>  hw/arm/meson.build |   1 +
>  include/hw/arm/allwinner-r40.h | 110 +
>  5 files changed, 668 insertions(+)
>  create mode 100644 hw/arm/allwinner-r40.c
>  create mode 100644 hw/arm/bananapi_m2u.c
>  create mode 100644 include/hw/arm/allwinner-r40.h
>
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 2d7c457955..b7a84f6e3f 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -374,6 +374,16 @@ config ALLWINNER_H3
>  select USB_EHCI_SYSBUS
>  select SD
>
> +config ALLWINNER_R40
> +bool
> +default y if TCG && ARM
> +select ALLWINNER_A10_PIT
> +select SERIAL
> +select ARM_TIMER
> +select ARM_GIC
> +select UNIMP
> +select SD
> +
>  config RASPI
>  bool
>  default y if TCG && ARM
> diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
> new file mode 100644
> index 00..b743d64253
> --- /dev/null
> +++ b/hw/arm/allwinner-r40.c
> @@ -0,0 +1,418 @@
> +/*
> + * Allwinner R40/A40i/T3 System on Chip emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qapi/error.h"
> +#include "qemu/error-report.h"
> +#include "qemu/bswap.h"
> +#include "qemu/module.h"
> +#include "qemu/units.h"
> +#include "hw/qdev-core.h"
> +#include "hw/sysbus.h"
> +#include "hw/char/serial.h"
> +#include "hw/misc/unimp.h"
> +#include "hw/usb/hcd-ehci.h"
> +#include "hw/loader.h"
> +#include "sysemu/sysemu.h"
> +#include "hw/arm/allwinner-r40.h"
> +
> +/* Memory map */
> +const hwaddr allwinner_r40_memmap[] = {
> +[AW_R40_DEV_SRAM_A1]= 0x,
> +[AW_R40_DEV_SRAM_A2]= 0x4000,
> +[AW_R40_DEV_SRAM_A3]= 0x8000,
> +[AW_R40_DEV_SRAM_A4]= 0xb400,
> +[AW_R40_DEV_MMC0]   = 0x01c0f000,
> +[AW_R40_DEV_MMC1]   = 0x01c1,
> +[AW_R40_DEV_MMC2]   = 0x01c11000,
> +[AW_R40_DEV_MMC3]   = 0x01c12000,
> +[AW_R40_DEV_PIT]= 0x01c20c00,
> +[AW_R40_DEV_UART0]  = 0x01c28000,
> +[AW_R40_DEV_GIC_DIST]   = 0x01c81000,
> +[AW_R40_DEV_GIC_CPU]= 0x01c82000,
> +[AW_R40_DEV_GIC_HYP]= 0x01c84000,
> +[AW_R40_DEV_GIC_VCPU]   = 0x01c86000,
> +[AW_R40_DEV_SDRAM]  = 0x4000
> +};
> +
> +/* List of unimplemented devices */
> +struct AwR40Unimplemented {
> +const char *device_name;
> +hwaddr base;
> +hwaddr size;
> +};
> +
> +static struct AwR40Unimplemented r40_unimplemented[] = {
> +{ "d-engine",   0x0100, 4 * MiB },
> +{ "d-inter",0x0140, 128 * KiB },
> +{ "sram-c", 0x01c0, 4 * KiB },
> +{ "dma",0x01c02000, 4 * KiB },
> +{ "nfdc",   0x01c03000, 4 * KiB },
> +{ "ts", 0x01c04000, 4 * KiB },
> +{ "spi0",   0x01c05000, 4 * KiB },
> +{ "spi1",   0x01c06000, 4 * KiB },
> +{ "cs0",0x01c09000, 4 * KiB },
> +{ "keymem", 0x01c0a000, 4 * KiB },
> +{ "emac",   0x01c0b000, 4 * KiB },
> +{ "usb0-otg",   0x01c13000, 4 * KiB },
> +{ "usb0-host",  0x01c14000, 4 * KiB },
> +{ "crypto",

Re: [PATCH v3 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support

2023-05-02 Thread Niek Linnenbank
system_memory(),
> +s->memmap[AW_R40_DEV_SRAM_A3],
> >sram_a3);
> +memory_region_add_subregion(get_system_memory(),
> +s->memmap[AW_R40_DEV_SRAM_A4],
> >sram_a4);
> +
> +/* SD/MMC */
> +for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
> +qemu_irq irq = qdev_get_gpio_in(DEVICE(>gic),
> +AW_R40_GIC_SPI_MMC0 + i);
> +const hwaddr addr = s->memmap[AW_R40_DEV_MMC0 + i];
> +
> +object_property_set_link(OBJECT(>mmc[i]), "dma-memory",
> + OBJECT(get_system_memory()),
> _fatal);
> +sysbus_realize(SYS_BUS_DEVICE(>mmc[i]), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>mmc[i]), 0, addr);
> +sysbus_connect_irq(SYS_BUS_DEVICE(>mmc[i]), 0, irq);
> +}
> +
> +/* UART0. For future clocktree API: All UARTS are connected to
> APB2_CLK. */
> +serial_mm_init(get_system_memory(), s->memmap[AW_R40_DEV_UART0], 2,
> +   qdev_get_gpio_in(DEVICE(>gic),
> AW_R40_GIC_SPI_UART0),
> +   115200, serial_hd(0), DEVICE_NATIVE_ENDIAN);
> +
> +/* Unimplemented devices */
> +for (i = 0; i < ARRAY_SIZE(r40_unimplemented); i++) {
> +create_unimplemented_device(r40_unimplemented[i].device_name,
> +r40_unimplemented[i].base,
> +r40_unimplemented[i].size);
> +}
> +}
> +
> +static void allwinner_r40_class_init(ObjectClass *oc, void *data)
> +{
> +DeviceClass *dc = DEVICE_CLASS(oc);
> +
> +dc->realize = allwinner_r40_realize;
> +/* Reason: uses serial_hd() in realize function */
> +dc->user_creatable = false;
> +}
> +
> +static const TypeInfo allwinner_r40_type_info = {
> +.name = TYPE_AW_R40,
> +.parent = TYPE_DEVICE,
> +.instance_size = sizeof(AwR40State),
> +.instance_init = allwinner_r40_init,
> +.class_init = allwinner_r40_class_init,
> +};
> +
> +static void allwinner_r40_register_types(void)
> +{
> +type_register_static(_r40_type_info);
> +}
> +
> +type_init(allwinner_r40_register_types)
> diff --git a/hw/arm/bananapi_m2u.c b/hw/arm/bananapi_m2u.c
> new file mode 100644
> index 00..1d49a006b5
> --- /dev/null
> +++ b/hw/arm/bananapi_m2u.c
> @@ -0,0 +1,129 @@
> +/*
> + * Bananapi M2U emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/units.h"
> +#include "exec/address-spaces.h"
> +#include "qapi/error.h"
> +#include "qemu/error-report.h"
> +#include "hw/boards.h"
> +#include "hw/qdev-properties.h"
> +#include "hw/arm/allwinner-r40.h"
> +
> +static struct arm_boot_info bpim2u_binfo;
> +
> +/*
> + * R40 can boot from mmc0 and mmc2, and bpim2u has two mmc interface, one
> is
> + * connected to sdcard and another mount an emmc media.
> + * Attach the mmc driver and try loading bootloader.
> + */
> +static void mmc_attach_drive(AwR40State *s, AwSdHostState *mmc, int unit,
> + bool load_bootroom, bool *bootroom_loaded)
> +{
> +DriveInfo *di = drive_get(IF_SD, 0, unit);
> +BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL;
> +BusState *bus;
> +DeviceState *carddev;
> +
> +bus = qdev_get_child_bus(DEVICE(mmc), "sd-bus");
> +if (bus == NULL) {
> +error_report("No SD bus found in SOC object");
> +exit(1);
> +}
> +
> +carddev = qdev_new(TYPE_SD_CARD);
> +qdev_prop_set_drive_err(carddev, "drive", blk, _fatal);
> +qdev_realize_and_unref(carddev, bus, _fatal);
> +
> +if (load_bootroom && blk && blk_is_available(blk)) {
> +/* Use Boot ROM to copy data from SD card to SRAM */
> +*bootroom_loaded = allwinner_r40_bootrom_

Re: [PATCH v2 11/12] tests: avocado: boot_linux_console: Add test case for bpim2u

2023-04-06 Thread Niek Linnenbank
Hi Qianfan,

The tests look good to me and are working OK:

ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
./build/tests/venv/bin/avocado --show=app,console run -t machine:bpim2u
tests/avocado/boot_linux_console.py
 (1/4)
tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_bpim2u:
/console: [0.00] Booting Linux on physical CPU 0x0
console: [0.00] Linux version 5.10.16-sunxi (root@beast)
(arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture
8.3-2019.03 (arm-rel-8.36)) 8.3.0, GNU ld (GNU Toolchain for the A-profile
Architecture 8.3-2019.03 (arm-rel-8.36)) 2.32.0.20190321) #21.02.2 SMP Sun
Feb 14 21:12:17 CET 2021
console: [0.00] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7),
cr=50c5387d
...
PASS (15.77 s)
RESULTS: PASS 4 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 62.90 s

So for me:

Tested-by: Niek Linnenbank 


On Tue, Mar 28, 2023 at 7:49 AM  wrote:

> From: qianfan Zhao 
>
> Add test case for booting from initrd and sd card.
>
> Signed-off-by: qianfan Zhao 
> ---
>  tests/avocado/boot_linux_console.py | 176 
>  1 file changed, 176 insertions(+)
>
> diff --git a/tests/avocado/boot_linux_console.py
> b/tests/avocado/boot_linux_console.py
> index 574609bf43..d17417828c 100644
> --- a/tests/avocado/boot_linux_console.py
> +++ b/tests/avocado/boot_linux_console.py
> @@ -760,6 +760,182 @@ def test_arm_quanta_gsj_initrd(self):
>  self.wait_for_console_pattern(
>  'Give root password for system maintenance')
>
> +def test_arm_bpim2u(self):
> +"""
> +:avocado: tags=arch:arm
> +:avocado: tags=machine:bpim2u
> +:avocado: tags=accel:tcg
> +"""
> +deb_url = ('
> https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/'
> +   'linux-image-current-sunxi_21.02.2_armhf.deb')
> +deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
> +deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
> +kernel_path = self.extract_from_deb(deb_path,
> +'/boot/vmlinuz-5.10.16-sunxi')
> +dtb_path = ('/usr/lib/linux-image-current-sunxi/'
> +'sun8i-r40-bananapi-m2-ultra.dtb')
> +dtb_path = self.extract_from_deb(deb_path, dtb_path)
> +
> +self.vm.set_console()
> +kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
> +   'console=ttyS0,115200n8 '
> +   'earlycon=uart,mmio32,0x1c28000')
> +self.vm.add_args('-kernel', kernel_path,
> + '-dtb', dtb_path,
> + '-append', kernel_command_line)
> +self.vm.launch()
> +console_pattern = 'Kernel command line: %s' % kernel_command_line
> +self.wait_for_console_pattern(console_pattern)
> +
> +def test_arm_bpim2u_initrd(self):
> +"""
> +:avocado: tags=arch:arm
> +:avocado: tags=accel:tcg
> +:avocado: tags=machine:bpim2u
> +"""
> +deb_url = ('
> https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/'
> +   'linux-image-current-sunxi_21.02.2_armhf.deb')
> +deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
> +deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
> +kernel_path = self.extract_from_deb(deb_path,
> +'/boot/vmlinuz-5.10.16-sunxi')
> +dtb_path = ('/usr/lib/linux-image-current-sunxi/'
> +'sun8i-r40-bananapi-m2-ultra.dtb')
> +dtb_path = self.extract_from_deb(deb_path, dtb_path)
> +initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
> +  '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
> +  'arm/rootfs-armv7a.cpio.gz')
> +initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c'
> +initrd_path_gz = self.fetch_asset(initrd_url,
> asset_hash=initrd_hash)
> +initrd_path = os.path.join(self.workdir, 'rootfs.cpio')
> +archive.gzip_uncompress(initrd_path_gz, initrd_path)
> +
> +self.vm.set_console()
> +kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
> +   'console=ttyS0,115200 '
> +   'panic=-1 noreboot')
> +self.vm.add_args('-kernel', kernel_path,
> + '-dtb', dtb_path,
> + '-initrd', initrd_path,
> + '-append', kernel_command_line,
> + '-no-reboot')
> +   

Re: [PATCH v2 07/12] hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support

2023-04-06 Thread Niek Linnenbank
ta)
> @@ -867,6 +899,24 @@ static void
> allwinner_sdhost_sun5i_class_init(ObjectClass *klass, void *data)
>  sc->is_sun4i = false;
>  }
>
> +static void allwinner_sdhost_sun50i_a64_class_init(ObjectClass *klass,
> +   void *data)
> +{
> +AwSdHostClass *sc = AW_SDHOST_CLASS(klass);
> +sc->max_desc_size = 64 * KiB;
> +sc->is_sun4i = false;
> +sc->can_calibrate = true;
>

perhaps in the other two existing _init() functions for sun4i/sun5i, we
should also explicitly set the new can_calibrate value to false,
to avoid the risk of using uninitialized data in the other machines/socs.


> +}
> +
> +static void allwinner_sdhost_sun50i_a64_emmc_class_init(ObjectClass
> *klass,
> +void *data)
> +{
> +AwSdHostClass *sc = AW_SDHOST_CLASS(klass);
> +sc->max_desc_size = 8 * KiB;
> +sc->is_sun4i = false;
> +sc->can_calibrate = true;
> +}
> +
>  static const TypeInfo allwinner_sdhost_info = {
>  .name  = TYPE_AW_SDHOST,
>  .parent= TYPE_SYS_BUS_DEVICE,
> @@ -889,6 +939,18 @@ static const TypeInfo allwinner_sdhost_sun5i_info = {
>  .class_init= allwinner_sdhost_sun5i_class_init,
>  };
>
> +static const TypeInfo allwinner_sdhost_sun50i_a64_info = {
> +.name  = TYPE_AW_SDHOST_SUN50I_A64,
> +.parent= TYPE_AW_SDHOST,
> +.class_init= allwinner_sdhost_sun50i_a64_class_init,
> +};
> +
> +static const TypeInfo allwinner_sdhost_sun50i_a64_emmc_info = {
> +.name  = TYPE_AW_SDHOST_SUN50I_A64_EMMC,
> +.parent= TYPE_AW_SDHOST,
> +.class_init= allwinner_sdhost_sun50i_a64_emmc_class_init,
> +};
> +
>  static const TypeInfo allwinner_sdhost_bus_info = {
>  .name = TYPE_AW_SDHOST_BUS,
>  .parent = TYPE_SD_BUS,
> @@ -901,6 +963,8 @@ static void allwinner_sdhost_register_types(void)
>  type_register_static(_sdhost_info);
>  type_register_static(_sdhost_sun4i_info);
>  type_register_static(_sdhost_sun5i_info);
> +type_register_static(_sdhost_sun50i_a64_info);
> +type_register_static(_sdhost_sun50i_a64_emmc_info);
>  type_register_static(_sdhost_bus_info);
>  }
>
> diff --git a/include/hw/sd/allwinner-sdhost.h
> b/include/hw/sd/allwinner-sdhost.h
> index 30c1e60404..1b951177dd 100644
> --- a/include/hw/sd/allwinner-sdhost.h
> +++ b/include/hw/sd/allwinner-sdhost.h
> @@ -38,6 +38,12 @@
>  /** Allwinner sun5i family and newer (A13, H2+, H3, etc) */
>  #define TYPE_AW_SDHOST_SUN5I TYPE_AW_SDHOST "-sun5i"
>
> +/** Allwinner sun50i-a64 */
> +#define TYPE_AW_SDHOST_SUN50I_A64 TYPE_AW_SDHOST "-sun50i-a64"
> +
> +/** Allwinner sun50i-a64 emmc */
> +#define TYPE_AW_SDHOST_SUN50I_A64_EMMC  TYPE_AW_SDHOST "-sun50i-a64-emmc"
> +
>  /** @} */
>
>  /**
> @@ -110,6 +116,7 @@ struct AwSdHostState {
>  uint32_t startbit_detect;   /**< eMMC DDR Start Bit Detection Control
> */
>  uint32_t response_crc;  /**< Response CRC */
>  uint32_t data_crc[8];   /**< Data CRC */
> +uint32_t sample_delay;  /**< Sample delay control */
>  uint32_t status_crc;/**< Status CRC */
>
>  /** @} */
> @@ -132,6 +139,8 @@ struct AwSdHostClass {
>  size_t max_desc_size;
>  bool   is_sun4i;
>
> +/** does the IP block support autocalibration? */
> +bool can_calibrate;
>  };
>
>  #endif /* HW_SD_ALLWINNER_SDHOST_H */
> --
> 2.25.1
>
>
In this patch, I don't see any update to the new allwinner-r40.c file.
If you make the required changes to allwinner-r40.c in this patch, you can
also avoid having patch 08.

Regards,
Niek

-- 
Niek Linnenbank


Re: [PATCH v2 11/11] docs: system: arm: Introduce bananapi_m2u

2023-04-06 Thread Niek Linnenbank
On Tue, Mar 28, 2023 at 7:48 AM  wrote:

> From: qianfan Zhao 
>
> Add documents for Banana Pi M2U
>
> Signed-off-by: qianfan Zhao 
>
Reviewed-by: Niek Linnenbank 


> ---
>  docs/system/arm/bananapi_m2u.rst | 138 +++
>  1 file changed, 138 insertions(+)
>  create mode 100644 docs/system/arm/bananapi_m2u.rst
>
> diff --git a/docs/system/arm/bananapi_m2u.rst
> b/docs/system/arm/bananapi_m2u.rst
> new file mode 100644
> index 00..ae7194a9df
> --- /dev/null
> +++ b/docs/system/arm/bananapi_m2u.rst
> @@ -0,0 +1,138 @@
> +Banana Pi BPI-M2U (``bpim2u``)
> +^^
> +
> +Banana Pi BPI-M2 Ultra is a quad-core mini single board computer built
> with
> +Allwinner A40i/R40/V40 SoC. It features 2GB of RAM and 8GB eMMC. It also
> +has onboard WiFi and BT. On the ports side, the BPI-M2 Ultra has 2 USB A
> +2.0 ports, 1 USB OTG port, 1 HDMI port, 1 audio jack, a DC power port,
> +and last but not least, a SATA port.
> +
> +Supported devices
> +"""""""""""""""""
> +
> +The Banana Pi M2U machine supports the following devices:
> +
> + * SMP (Quad Core Cortex-A7)
> + * Generic Interrupt Controller configuration
> + * SRAM mappings
> + * SDRAM controller
> + * Timer device (re-used from Allwinner A10)
> + * UART
> + * SD/MMC storage controller
> + * EMAC ethernet
> + * GMAC ethernet
> + * Clock Control Unit
> + * TWI (I2C)
> +
> +Limitations
> +"""""""""""
> +
> +Currently, Banana Pi M2U does *not* support the following features:
> +
> +- Graphical output via HDMI, GPU and/or the Display Engine
> +- Audio output
> +- Hardware Watchdog
> +- Real Time Clock
> +- USB 2.0 interfaces
> +
> +Also see the 'unimplemented' array in the Allwinner R40 SoC module
> +for a complete list of unimplemented I/O devices:
> ``./hw/arm/allwinner-r40.c``
> +
> +Boot options
> +""""""""""""
> +
> +The Banana Pi M2U machine can start using the standard -kernel
> functionality
> +for loading a Linux kernel or ELF executable. Additionally, the Banana Pi
> M2U
> +machine can also emulate the BootROM which is present on an actual
> Allwinner R40
> +based SoC, which loads the bootloader from a SD card, specified via the
> -sd
> +argument to qemu-system-arm.
> +
> +Running mainline Linux
> +""""""""""""""""""""""
> +
> +To build a Linux mainline kernel that can be booted by the Banana Pi M2U
> machine,
> +simply configure the kernel using the sunxi_defconfig configuration:
> +
> +.. code-block:: bash
> +
> +  $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make mrproper
> +  $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make sunxi_defconfig
> +
> +To boot the newly build linux kernel in QEMU with the Banana Pi M2U
> machine, use:
> +
> +.. code-block:: bash
> +
> +  $ qemu-system-arm -M bpim2u -nographic \
> +  -kernel /path/to/linux/arch/arm/boot/zImage \
> +  -append 'console=ttyS0,115200' \
> +  -dtb
> /path/to/linux/arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb
> +
> +Banana Pi M2U images
> +""""""""""""""""""""
> +
> +Note that the mainline kernel does not have a root filesystem. You can
> choose
> +to build you own image with buildroot using the
> bananapi_m2_ultra_defconfig.
> +Also see https://buildroot.org for more information.
> +
> +Another possibility is to run an OpenWrt image for Banana Pi M2U which
> +can be downloaded from:
> +
> +   https://downloads.openwrt.org/releases/22.03.3/targets/sunxi/cortexa7/
> +
> +When using an image as an SD card, it must be resized to a power of two.
> This can be
> +done with the ``qemu-img`` command. It is recommended to only increase
> the image size
> +instead of shrinking it to a power of two, to avoid loss of data. For
> example,
> +to prepare a downloaded Armbian image, first extract it and then increase
> +its size to one gigabyte as follows:
> +
> +.. code-block:: bash
> +
> +  $ qemu-img resize \
> +
> openwrt-22.03.3-sunxi-cortexa7-sinovoip_bananapi-m2-ultra-ext4-sdcard.img \
> +1G
> +
> +Instead of providing a custom Linux kernel via the -kernel command you
> may also
> +choose to let the Banana Pi M2U machine load the bootloader from SD card,
> just like
> +a real board would do using the BootROM. Simply pass the select

Re: [PATCH v2 08/12] hw: arm: allwinner-r40: Fix the mmc controller's type

2023-04-06 Thread Niek Linnenbank
Hi Qianfan Zhao,

Is this change really needed as a separate patch?
Looks like it would make sense just to squash it with the original patch 01?

Regards,
Niek

On Tue, Mar 28, 2023 at 7:47 AM  wrote:

> From: qianfan Zhao 
>
> R40 has SAMP_DL_REG register and mmc2 controller has only 8K dma buffer.
> Fix it's compatible string.
>
> Signed-off-by: qianfan Zhao 
> ---
>  hw/arm/allwinner-r40.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
> index 0e4542d35f..b148c56449 100644
> --- a/hw/arm/allwinner-r40.c
> +++ b/hw/arm/allwinner-r40.c
> @@ -271,7 +271,7 @@ static void allwinner_r40_init(Object *obj)
>
>  for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
>  object_initialize_child(obj, mmc_names[i], >mmc[i],
> -TYPE_AW_SDHOST_SUN5I);
> +TYPE_AW_SDHOST_SUN50I_A64);
>  }
>
>  object_initialize_child(obj, "twi0", >i2c0, TYPE_AW_I2C_SUN6I);
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v2 02/12] hw/arm/allwinner-r40: add Clock Control Unit

2023-04-06 Thread Niek Linnenbank
On Tue, Mar 28, 2023 at 7:47 AM  wrote:

> From: qianfan Zhao 
>
> The CCU provides the registers to program the PLLs and the controls
> most of the clock generation, division, distribution, synchronization
> and gating.
>
> This commit adds support for the Clock Control Unit which emulates
> a simple read/write register interface.
>
> Signed-off-by: qianfan Zhao 
>
Reviewed-by: Niek Linnenbank 


> ---
>  hw/arm/allwinner-r40.c  |   8 +-
>  hw/misc/allwinner-r40-ccu.c | 209 
>  hw/misc/meson.build |   1 +
>  include/hw/arm/allwinner-r40.h  |   2 +
>  include/hw/misc/allwinner-r40-ccu.h |  65 +
>  5 files changed, 284 insertions(+), 1 deletion(-)
>  create mode 100644 hw/misc/allwinner-r40-ccu.c
>  create mode 100644 include/hw/misc/allwinner-r40-ccu.h
>
> diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
> index b743d64253..128c0ca470 100644
> --- a/hw/arm/allwinner-r40.c
> +++ b/hw/arm/allwinner-r40.c
> @@ -42,6 +42,7 @@ const hwaddr allwinner_r40_memmap[] = {
>  [AW_R40_DEV_MMC1]   = 0x01c1,
>  [AW_R40_DEV_MMC2]   = 0x01c11000,
>  [AW_R40_DEV_MMC3]   = 0x01c12000,
> +[AW_R40_DEV_CCU]= 0x01c2,
>  [AW_R40_DEV_PIT]= 0x01c20c00,
>  [AW_R40_DEV_UART0]  = 0x01c28000,
>  [AW_R40_DEV_GIC_DIST]   = 0x01c81000,
> @@ -80,7 +81,6 @@ static struct AwR40Unimplemented r40_unimplemented[] = {
>  { "usb2-host",  0x01c1c000, 4 * KiB },
>  { "cs1",0x01c1d000, 4 * KiB },
>  { "spi3",   0x01c1f000, 4 * KiB },
> -{ "ccu",0x01c2, 1 * KiB },
>  { "rtc",0x01c20400, 1 * KiB },
>  { "pio",0x01c20800, 1 * KiB },
>  { "owa",0x01c21000, 1 * KiB },
> @@ -253,6 +253,8 @@ static void allwinner_r40_init(Object *obj)
>  object_property_add_alias(obj, "clk1-freq", OBJECT(>timer),
>"clk1-freq");
>
> +object_initialize_child(obj, "ccu", >ccu, TYPE_AW_R40_CCU);
> +
>  for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
>  object_initialize_child(obj, mmc_names[i], >mmc[i],
>  TYPE_AW_SDHOST_SUN5I);
> @@ -367,6 +369,10 @@ static void allwinner_r40_realize(DeviceState *dev,
> Error **errp)
>  memory_region_add_subregion(get_system_memory(),
>  s->memmap[AW_R40_DEV_SRAM_A4],
> >sram_a4);
>
> +/* Clock Control Unit */
> +sysbus_realize(SYS_BUS_DEVICE(>ccu), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>ccu), 0,
> s->memmap[AW_R40_DEV_CCU]);
> +
>  /* SD/MMC */
>  for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
>  qemu_irq irq = qdev_get_gpio_in(DEVICE(>gic),
> diff --git a/hw/misc/allwinner-r40-ccu.c b/hw/misc/allwinner-r40-ccu.c
> new file mode 100644
> index 00..d82fee12db
> --- /dev/null
> +++ b/hw/misc/allwinner-r40-ccu.c
> @@ -0,0 +1,209 @@
> +/*
> + * Allwinner R40 Clock Control Unit emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/units.h"
> +#include "hw/sysbus.h"
> +#include "migration/vmstate.h"
> +#include "qemu/log.h"
> +#include "qemu/module.h"
> +#include "hw/misc/allwinner-r40-ccu.h"
> +
> +/* CCU register offsets */
> +enum {
> +REG_PLL_CPUX_CTRL   = 0x,
> +REG_PLL_AUDIO_CTRL  = 0x0008,
> +REG_PLL_VIDEO0_CTRL = 0x0010,
> +REG_PLL_VE_CTRL = 0x0018,
> +REG_PLL_DDR0_CTRL   = 0x0020,
> +REG_PLL_PERIPH0_CTRL= 0x0028,
> +REG_PLL_PERIPH1_CTRL= 0x002c,
> +REG_PLL_VIDEO1_CTRL = 0x0030,
> +REG_PLL_SATA_CTRL   = 0x0034,
> +REG_PLL_GPU_CTRL= 0x0038,
> +REG_PLL_MIPI_CTRL

Re: [PATCH v2 01/12] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support

2023-04-06 Thread Niek Linnenbank
gt; +AwR40State *r40;
> +
> +/* BIOS is not supported by this board */
> +if (machine->firmware) {
> +error_report("BIOS not supported for this machine");
> +exit(1);
> +}
> +
> +/* Only allow Cortex-A7 for this board */
> +if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a7")) != 0) {
> +error_report("This board can only be used with cortex-a7 CPU");
> +exit(1);
> +}
> +
> +r40 = AW_R40(object_new(TYPE_AW_R40));
> +object_property_add_child(OBJECT(machine), "soc", OBJECT(r40));
> +object_unref(OBJECT(r40));
> +
> +/* Setup timer properties */
> +object_property_set_int(OBJECT(r40), "clk0-freq", 32768,
> _abort);
> +object_property_set_int(OBJECT(r40), "clk1-freq", 24 * 1000 * 1000,
> +_abort);
> +
> +/* Mark R40 object realized */
> +qdev_realize(DEVICE(r40), NULL, _abort);
> +
> +/*
> + * Plug in SD card and try load bootrom, R40 has 4 mmc controllers
> but can
> + * only booting from mmc0 and mmc2.
> + */
> +for (int i = 0; i < AW_R40_NUM_MMCS; i++) {
> +switch (i) {
> +case 0:
> +case 2:
> +mmc_attach_drive(r40, >mmc[i], i,
> + !machine->kernel_filename &&
> !bootroom_loaded,
> + _loaded);
> +break;
> +default:
> +mmc_attach_drive(r40, >mmc[i], i, false, NULL);
> +break;
> +}
> +}
> +
> +/* SDRAM */
> +memory_region_add_subregion(get_system_memory(),
> +r40->memmap[AW_R40_DEV_SDRAM],
> machine->ram);
> +
> +bpim2u_binfo.loader_start = r40->memmap[AW_R40_DEV_SDRAM];
> +bpim2u_binfo.ram_size = machine->ram_size;
> +bpim2u_binfo.psci_conduit = QEMU_PSCI_CONDUIT_SMC;
> +arm_load_kernel(ARM_CPU(first_cpu), machine, _binfo);
> +}
> +
> +static void bpim2u_machine_init(MachineClass *mc)
> +{
> +mc->desc = "Bananapi M2U (Cortex-A7)";
>
+mc->init = bpim2u_init;
> +mc->min_cpus = AW_R40_NUM_CPUS;
> +mc->max_cpus = AW_R40_NUM_CPUS;
> +mc->default_cpus = AW_R40_NUM_CPUS;
> +mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a7");
> +mc->default_ram_size = 1 * GiB;
>

The board you are adding, is it the Banana Pi BPI-M2 Ultra?
If so, this page says the board has 2GiB of RAM:

https://wiki.banana-pi.org/Banana_Pi_BPI-M2U


> +mc->default_ram_id = "bpim2u.ram";
> +}
> +
> +DEFINE_MACHINE("bpim2u", bpim2u_machine_init)
> diff --git a/hw/arm/meson.build b/hw/arm/meson.build
> index b545ba0e4f..870ec67376 100644
> --- a/hw/arm/meson.build
> +++ b/hw/arm/meson.build
> @@ -37,6 +37,7 @@ arm_ss.add(when: 'CONFIG_OMAP', if_true:
> files('omap1.c', 'omap2.c'))
>  arm_ss.add(when: 'CONFIG_STRONGARM', if_true: files('strongarm.c'))
>  arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true:
> files('allwinner-a10.c', 'cubieboard.c'))
>  arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c',
> 'orangepi.c'))
> +arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true:
> files('allwinner-r40.c', 'bananapi_m2u.c'))
>  arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c'))
>  arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true:
> files('stm32f100_soc.c'))
>  arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true:
> files('stm32f205_soc.c'))
> diff --git a/include/hw/arm/allwinner-r40.h
> b/include/hw/arm/allwinner-r40.h
> new file mode 100644
> index 00..348bf25d6b
> --- /dev/null
> +++ b/include/hw/arm/allwinner-r40.h
> @@ -0,0 +1,110 @@
> +/*
> + * Allwinner R40/A40i/T3 System on Chip emulation
> + *
> + * Copyright (C) 2023 qianfan Zhao 
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef HW_ARM_ALLWINNER_R40_H
> +#define HW_ARM_ALLWINNER_R40_H
> +
> +#include "qom/object.h"
> +#include "hw/arm/boot.h"
> +#include "hw/timer/allwinner-a10-pit.h"
> +#include "hw/intc/arm_gic.h"
> +#include "hw/sd/allwinner-sdhost.h"
> +#include "target/arm/cpu.h"
> +#include "sysemu/block-backend.h"
> +
> +enum {
> +AW_R40_DEV_SRAM_A1,
> +AW_R40_DEV_SRAM_A2,
> +AW_R40_DEV_SRAM_A3,
> +AW_R40_DEV_SRAM_A4,
> +AW_R40_DEV_MMC0,
> +AW_R40_DEV_MMC1,
> +AW_R40_DEV_MMC2,
> +AW_R40_DEV_MMC3,
> +AW_R40_DEV_CCU,
> +AW_R40_DEV_PIT,
> +AW_R40_DEV_UART0,
> +AW_R40_DEV_GIC_DIST,
> +AW_R40_DEV_GIC_CPU,
> +AW_R40_DEV_GIC_HYP,
> +AW_R40_DEV_GIC_VCPU,
> +AW_R40_DEV_SDRAM
> +};
> +
> +#define AW_R40_NUM_CPUS  (4)
> +
> +/**
> + * Allwinner R40 object model
> + * @{
> + */
> +
> +/** Object type for the Allwinner R40 SoC */
> +#define TYPE_AW_R40 "allwinner-r40"
> +
> +/** Convert input object to Allwinner R40 state object */
> +OBJECT_DECLARE_SIMPLE_TYPE(AwR40State, AW_R40)
> +
> +/** @} */
> +
> +/**
> + * Allwinner R40 object
> + *
> + * This struct contains the state of all the devices
> + * which are currently emulated by the R40 SoC code.
> + */
> +#define AW_R40_NUM_MMCS 4
> +
> +struct AwR40State {
> +/*< private >*/
> +DeviceState parent_obj;
> +/*< public >*/
> +
> +ARMCPU cpus[AW_R40_NUM_CPUS];
> +const hwaddr *memmap;
> +AwA10PITState timer;
> +AwSdHostState mmc[AW_R40_NUM_MMCS];
> +GICState gic;
> +MemoryRegion sram_a1;
> +MemoryRegion sram_a2;
> +MemoryRegion sram_a3;
> +MemoryRegion sram_a4;
> +};
> +
> +/**
> + * Emulate Boot ROM firmware setup functionality.
> + *
> + * A real Allwinner R40 SoC contains a Boot ROM
> + * which is the first code that runs right after
> + * the SoC is powered on. The Boot ROM is responsible
> + * for loading user code (e.g. a bootloader) from any
> + * of the supported external devices and writing the
> + * downloaded code to internal SRAM. After loading the SoC
> + * begins executing the code written to SRAM.
> + *
> + * This function emulates the Boot ROM by copying 32 KiB
> + * of data from the given block device and writes it to
> + * the start of the first internal SRAM memory.
> + *
> + * @s: Allwinner R40 state object pointer
> + * @blk: Block backend device object pointer
> + * @unit: the mmc control's unit
> + */
> +bool allwinner_r40_bootrom_setup(AwR40State *s, BlockBackend *blk, int
> unit);
> +
> +#endif /* HW_ARM_ALLWINNER_R40_H */
> --
> 2.25.1
>
>
With the above resolved/answered:

Reviewed-by: Niek Linnenbank 

-- 
Niek Linnenbank


Re: [PATCH v2 1/4] hw/watchdog: Allwinner WDT emulation for system reset

2023-03-26 Thread Niek Linnenbank
Hi Strahinja,




On Fri, Mar 17, 2023 at 1:13 AM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> This patch adds basic support for Allwinner WDT.
> Both sun4i and sun6i variants are supported.
> However, interrupt generation is not supported, so WDT can be used only to
> trigger system reset.
>
> Signed-off-by: Strahinja Jankovic 
>
> ---
>  hw/watchdog/Kconfig |   4 +
>  hw/watchdog/allwinner-wdt.c | 416 
>  hw/watchdog/meson.build |   1 +
>  hw/watchdog/trace-events|   7 +
>  include/hw/watchdog/allwinner-wdt.h | 123 
>  5 files changed, 551 insertions(+)
>  create mode 100644 hw/watchdog/allwinner-wdt.c
>  create mode 100644 include/hw/watchdog/allwinner-wdt.h
>
> diff --git a/hw/watchdog/Kconfig b/hw/watchdog/Kconfig
> index 66e1d029e3..861fd00334 100644
> --- a/hw/watchdog/Kconfig
> +++ b/hw/watchdog/Kconfig
> @@ -20,3 +20,7 @@ config WDT_IMX2
>
>  config WDT_SBSA
>  bool
> +
> +config ALLWINNER_WDT
> +bool
> +select PTIMER
> diff --git a/hw/watchdog/allwinner-wdt.c b/hw/watchdog/allwinner-wdt.c
> new file mode 100644
> index 00..45a4a36ba7
> --- /dev/null
> +++ b/hw/watchdog/allwinner-wdt.c
> @@ -0,0 +1,416 @@
> +/*
> + * Allwinner Watchdog emulation
> + *
> + * Copyright (C) 2023 Strahinja Jankovic 
> + *
> + *  This file is derived from Allwinner RTC,
> + *  by Niek Linnenbank.
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/log.h"
> +#include "qemu/units.h"
> +#include "qemu/module.h"
> +#include "trace.h"
> +#include "hw/sysbus.h"
> +#include "hw/registerfields.h"
> +#include "hw/watchdog/allwinner-wdt.h"
> +#include "sysemu/watchdog.h"
> +#include "migration/vmstate.h"
> +
> +/* WDT registers */
> +enum {
> +REG_IRQ_EN = 0, /* Watchdog interrupt enable */
> +REG_IRQ_STA,/* Watchdog interrupt status */
> +REG_CTRL,   /* Watchdog control register */
> +REG_CFG,/* Watchdog configuration register */
> +REG_MODE,   /* Watchdog mode register */
> +};
> +
> +/* Universal WDT register flags */
> +#define WDT_RESTART_MASK(1 << 0)
> +#define WDT_EN_MASK (1 << 0)
> +
> +/* sun4i specific WDT register flags */
> +#define RST_EN_SUN4I_MASK   (1 << 1)
> +#define INTV_VALUE_SUN4I_SHIFT  (3)
> +#define INTV_VALUE_SUN4I_MASK   (0xfu << INTV_VALUE_SUN4I_SHIFT)
> +
> +/* sun6i specific WDT register flags */
> +#define RST_EN_SUN6I_MASK   (1 << 0)
> +#define KEY_FIELD_SUN6I_SHIFT   (1)
> +#define KEY_FIELD_SUN6I_MASK(0xfffu << KEY_FIELD_SUN6I_SHIFT)
> +#define KEY_FIELD_SUN6I (0xA57u)
> +#define INTV_VALUE_SUN6I_SHIFT  (4)
> +#define INTV_VALUE_SUN6I_MASK   (0xfu << INTV_VALUE_SUN6I_SHIFT)
> +
> +/* Map of INTV_VALUE to 0.5s units. */
> +static const uint8_t allwinner_wdt_count_map[] = {
> +1,
> +2,
> +4,
> +6,
> +8,
> +10,
> +12,
> +16,
> +20,
> +24,
> +28,
> +32
> +};
> +
> +/* WDT sun4i register map (offset to name) */
> +const uint8_t allwinner_wdt_sun4i_regmap[] = {
> +[0x] = REG_CTRL,
> +[0x0004] = REG_MODE,
> +};
> +
> +/* WDT sun6i register map (offset to name) */
> +const uint8_t allwinner_wdt_sun6i_regmap[] = {
> +[0x] = REG_IRQ_EN,
> +[0x0004] = REG_IRQ_STA,
> +[0x0010] = REG_CTRL,
> +[0x0014] = REG_CFG,
> +[0x0018] = REG_MODE,
> +};
> +
> +static bool allwinner_wdt_sun4i_read(AwWdtState *s, uint32_t offset)
> +{
> +/* no sun4i specific registers currently implemented */
> +return false;
> +}
> +
> +static bool allwinner_wdt_sun4i_write(AwWdtState *s, uint32_t offset,
> +  uint32_t data)
> +{
> +/* no sun4i specific registers currently 

Re: [PATCH 3/4] hw/arm: Add WDT to Allwinner-H3 and Orangepi-PC

2023-03-14 Thread Niek Linnenbank
On Sat, Mar 11, 2023 at 3:42 PM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> This patch adds WDT to Allwinner-H3 and Orangepi-PC.
> WDT is added as an overlay to the Timer module memory area.
>
> Signed-off-by: Strahinja Jankovic 
>

Reviewed-by: Niek Linnenbank 


> ---
>  docs/system/arm/orangepi.rst  | 1 +
>  hw/arm/Kconfig| 1 +
>  hw/arm/allwinner-h3.c | 8 
>  include/hw/arm/allwinner-h3.h | 5 -
>  4 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
> index e5973600a1..9afa54213b 100644
> --- a/docs/system/arm/orangepi.rst
> +++ b/docs/system/arm/orangepi.rst
> @@ -26,6 +26,7 @@ The Orange Pi PC machine supports the following devices:
>   * System Control module
>   * Security Identifier device
>   * TWI (I2C)
> + * Watchdog timer
>
>  Limitations
>  """""""""""
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index ec15248536..7d916f5450 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -337,6 +337,7 @@ config ALLWINNER_H3
>  select ALLWINNER_A10_PIT
>  select ALLWINNER_SUN8I_EMAC
>  select ALLWINNER_I2C
> +select ALLWINNER_WDT
>  select SERIAL
>  select ARM_TIMER
>  select ARM_GIC
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 69d0ad6f50..f05afddf7e 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -49,6 +49,7 @@ const hwaddr allwinner_h3_memmap[] = {
>  [AW_H3_DEV_OHCI3]  = 0x01c1d400,
>  [AW_H3_DEV_CCU]= 0x01c2,
>  [AW_H3_DEV_PIT]= 0x01c20c00,
> +[AW_H3_DEV_WDT]= 0x01c20ca0,
>  [AW_H3_DEV_UART0]  = 0x01c28000,
>  [AW_H3_DEV_UART1]  = 0x01c28400,
>  [AW_H3_DEV_UART2]  = 0x01c28800,
> @@ -234,6 +235,8 @@ static void allwinner_h3_init(Object *obj)
>  object_initialize_child(obj, "twi1",  >i2c1,  TYPE_AW_I2C_SUN6I);
>  object_initialize_child(obj, "twi2",  >i2c2,  TYPE_AW_I2C_SUN6I);
>  object_initialize_child(obj, "r_twi", >r_twi, TYPE_AW_I2C_SUN6I);
> +
> +object_initialize_child(obj, "wdt", >wdt, TYPE_AW_WDT_SUN6I);
>  }
>
>  static void allwinner_h3_realize(DeviceState *dev, Error **errp)
> @@ -453,6 +456,11 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>  sysbus_connect_irq(SYS_BUS_DEVICE(>r_twi), 0,
> qdev_get_gpio_in(DEVICE(>gic),
> AW_H3_GIC_SPI_R_TWI));
>
> +/* WDT */
> +sysbus_realize(SYS_BUS_DEVICE(>wdt), _fatal);
> +sysbus_mmio_map_overlap(SYS_BUS_DEVICE(>wdt), 0,
> +s->memmap[AW_H3_DEV_WDT], 1);
> +
>  /* Unimplemented devices */
>  for (i = 0; i < ARRAY_SIZE(unimplemented); i++) {
>  create_unimplemented_device(unimplemented[i].device_name,
> diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h
> index 59e0f822d2..f15d6d7cc7 100644
> --- a/include/hw/arm/allwinner-h3.h
> +++ b/include/hw/arm/allwinner-h3.h
> @@ -48,6 +48,7 @@
>  #include "hw/net/allwinner-sun8i-emac.h"
>  #include "hw/rtc/allwinner-rtc.h"
>  #include "hw/i2c/allwinner-i2c.h"
> +#include "hw/watchdog/allwinner-wdt.h"
>  #include "target/arm/cpu.h"
>  #include "sysemu/block-backend.h"
>
> @@ -96,7 +97,8 @@ enum {
>  AW_H3_DEV_RTC,
>  AW_H3_DEV_CPUCFG,
>  AW_H3_DEV_R_TWI,
> -AW_H3_DEV_SDRAM
> +AW_H3_DEV_SDRAM,
> +AW_H3_DEV_WDT
>  };
>
>  /** Total number of CPU cores in the H3 SoC */
> @@ -141,6 +143,7 @@ struct AwH3State {
>  AWI2CState r_twi;
>  AwSun8iEmacState emac;
>  AwRtcState rtc;
> +AwWdtState wdt;
>  GICState gic;
>  MemoryRegion sram_a1;
>  MemoryRegion sram_a2;
> --
> 2.30.2
>
>

-- 
Niek Linnenbank


Re: [PATCH 2/4] hw/arm: Add WDT to Allwinner-A10 and Cubieboard

2023-03-14 Thread Niek Linnenbank
Hi Strahinja,


On Sat, Mar 11, 2023 at 3:42 PM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> This patch adds WDT to Allwinner-A10 and Cubieboard.
> WDT is added as an overlay to the Timer module memory map.
>
> Signed-off-by: Strahinja Jankovic 
> ---
>  docs/system/arm/cubieboard.rst | 1 +
>  hw/arm/Kconfig | 1 +
>  hw/arm/allwinner-a10.c | 7 +++
>  include/hw/arm/allwinner-a10.h | 2 ++
>  4 files changed, 11 insertions(+)
>
> diff --git a/docs/system/arm/cubieboard.rst
> b/docs/system/arm/cubieboard.rst
> index 8d485f5435..58c4a2d3ea 100644
> --- a/docs/system/arm/cubieboard.rst
> +++ b/docs/system/arm/cubieboard.rst
> @@ -15,3 +15,4 @@ Emulated devices:
>  - USB controller
>  - SATA controller
>  - TWI (I2C) controller
> +- Watchdog timer
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index b5aed4aff5..ec15248536 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -325,6 +325,7 @@ config ALLWINNER_A10
>  select ALLWINNER_A10_PIC
>  select ALLWINNER_A10_CCM
>  select ALLWINNER_A10_DRAMC
> +select ALLWINNER_WDT
>  select ALLWINNER_EMAC
>  select ALLWINNER_I2C
>  select AXP209_PMU
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index b7ca795c71..b0ea3f7f66 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -38,6 +38,7 @@
>  #define AW_A10_EHCI_BASE0x01c14000
>  #define AW_A10_OHCI_BASE0x01c14400
>  #define AW_A10_SATA_BASE0x01c18000
> +#define AW_A10_WDT_BASE 0x01c20c90
>

Unfortunately I couldn't find any details about the watchdog in the
Allwinner A10 datasheet "A10_Datasheet.pdf", except for a very brief
summary in chapter 9.1 in the Timer Controller. But I did find that linux
is using this same base address and registers with the shared driver code
in drivers/watchdog/sunxi_wdt.c.

Looks good to me.

Reviewed-by: Niek Linnenbank 


>  #define AW_A10_RTC_BASE 0x01c20d00
>  #define AW_A10_I2C0_BASE0x01c2ac00
>
> @@ -92,6 +93,8 @@ static void aw_a10_init(Object *obj)
>  object_initialize_child(obj, "mmc0", >mmc0, TYPE_AW_SDHOST_SUN4I);
>
>  object_initialize_child(obj, "rtc", >rtc, TYPE_AW_RTC_SUN4I);
> +
> +object_initialize_child(obj, "wdt", >wdt, TYPE_AW_WDT_SUN4I);
>  }
>
>  static void aw_a10_realize(DeviceState *dev, Error **errp)
> @@ -203,6 +206,10 @@ static void aw_a10_realize(DeviceState *dev, Error
> **errp)
>  sysbus_realize(SYS_BUS_DEVICE(>i2c0), _fatal);
>  sysbus_mmio_map(SYS_BUS_DEVICE(>i2c0), 0, AW_A10_I2C0_BASE);
>  sysbus_connect_irq(SYS_BUS_DEVICE(>i2c0), 0, qdev_get_gpio_in(dev,
> 7));
> +
> +/* WDT */
> +sysbus_realize(SYS_BUS_DEVICE(>wdt), _fatal);
> +sysbus_mmio_map_overlap(SYS_BUS_DEVICE(>wdt), 0, AW_A10_WDT_BASE,
> 1);
>  }
>
>  static void aw_a10_class_init(ObjectClass *oc, void *data)
> diff --git a/include/hw/arm/allwinner-a10.h
> b/include/hw/arm/allwinner-a10.h
> index 095afb225d..cd1465c613 100644
> --- a/include/hw/arm/allwinner-a10.h
> +++ b/include/hw/arm/allwinner-a10.h
> @@ -13,6 +13,7 @@
>  #include "hw/misc/allwinner-a10-ccm.h"
>  #include "hw/misc/allwinner-a10-dramc.h"
>  #include "hw/i2c/allwinner-i2c.h"
> +#include "hw/watchdog/allwinner-wdt.h"
>  #include "sysemu/block-backend.h"
>
>  #include "target/arm/cpu.h"
> @@ -41,6 +42,7 @@ struct AwA10State {
>  AwSdHostState mmc0;
>  AWI2CState i2c0;
>  AwRtcState rtc;
> +AwWdtState wdt;
>  MemoryRegion sram_a;
>  EHCISysBusState ehci[AW_A10_NUM_USB];
>  OHCISysBusState ohci[AW_A10_NUM_USB];
> --
> 2.30.2
>
>

-- 
Niek Linnenbank


Re: [PATCH 1/4] hw/watchdog: Allwinner WDT emulation for system reset

2023-03-14 Thread Niek Linnenbank
Hi Strahinja,


On Sat, Mar 11, 2023 at 3:41 PM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> This patch adds basic support for Allwinner WDT.
> Both sun4i and sun6i variants are supported.
> However, interrupt generation is not supported, so WDT can be used only to
> trigger system reset.
>
> Signed-off-by: Strahinja Jankovic 
> ---
>  hw/watchdog/Kconfig |   4 +
>  hw/watchdog/allwinner-wdt.c | 428 
>  hw/watchdog/meson.build |   1 +
>  hw/watchdog/trace-events|   7 +
>  include/hw/watchdog/allwinner-wdt.h | 123 
>  5 files changed, 563 insertions(+)
>  create mode 100644 hw/watchdog/allwinner-wdt.c
>  create mode 100644 include/hw/watchdog/allwinner-wdt.h
>
> diff --git a/hw/watchdog/Kconfig b/hw/watchdog/Kconfig
> index 66e1d029e3..861fd00334 100644
> --- a/hw/watchdog/Kconfig
> +++ b/hw/watchdog/Kconfig
> @@ -20,3 +20,7 @@ config WDT_IMX2
>
>  config WDT_SBSA
>  bool
> +
> +config ALLWINNER_WDT
> +bool
> +select PTIMER
> diff --git a/hw/watchdog/allwinner-wdt.c b/hw/watchdog/allwinner-wdt.c
> new file mode 100644
> index 00..cf16ec7a56
> --- /dev/null
> +++ b/hw/watchdog/allwinner-wdt.c
> @@ -0,0 +1,428 @@
> +/*
> + * Allwinner Watchdog emulation
> + *
> + * Copyright (C) 2023 Strahinja Jankovic 
> + *
> + *  This file is derived from Allwinner RTC,
> + *  by Niek Linnenbank.
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/log.h"
> +#include "qemu/units.h"
> +#include "qemu/module.h"
> +#include "trace.h"
> +#include "hw/sysbus.h"
> +#include "hw/registerfields.h"
> +#include "hw/watchdog/allwinner-wdt.h"
> +#include "sysemu/watchdog.h"
> +#include "migration/vmstate.h"
> +
> +/* WDT registers */
> +enum {
> +REG_IRQ_EN = 0, /* Watchdog interrupt enable */
>

Since we are doing a check "if (!c->regmap[offset])" below, should the enum
values begin with 1 instead?


> +REG_IRQ_STA,/* Watchdog interrupt status */
> +REG_CTRL,   /* Watchdog control register */
> +REG_CFG,/* Watchdog configuration register */
> +REG_MODE,   /* Watchdog mode register */
> +};
> +
> +/* Universal WDT register flags */
> +#define WDT_RESTART_MASK(1 << 0)
> +#define WDT_EN_MASK (1 << 0)
> +
> +/* sun4i specific WDT register flags */
> +#define RST_EN_SUN4I_MASK   (1 << 1)
> +#define INTV_VALUE_SUN4I_SHIFT  (3)
> +#define INTV_VALUE_SUN4I_MASK   (0xfu << INTV_VALUE_SUN4I_SHIFT)
> +
> +/* sun6i specific WDT register flags */
> +#define RST_EN_SUN6I_MASK   (1 << 0)
> +#define KEY_FIELD_SUN6I_SHIFT   (1)
> +#define KEY_FIELD_SUN6I_MASK(0xfffu << KEY_FIELD_SUN6I_SHIFT)
> +#define KEY_FIELD_SUN6I (0xA57u)
> +#define INTV_VALUE_SUN6I_SHIFT  (4)
> +#define INTV_VALUE_SUN6I_MASK   (0xfu << INTV_VALUE_SUN6I_SHIFT)
> +
> +/* Map of INTV_VALUE to 0.5s units. */
> +static const uint8_t allwinner_wdt_count_map[] = {
> +1,
> +2,
> +4,
> +6,
> +8,
> +10,
> +12,
> +16,
> +20,
> +24,
> +28,
> +32
> +};
> +
> +/* WDT sun4i register map (offset to name) */
> +const uint8_t allwinner_wdt_sun4i_regmap[] = {
> +[0x] = REG_CTRL,
> +[0x0004] = REG_MODE,
> +};
> +
> +/* WDT sun6i register map (offset to name) */
> +const uint8_t allwinner_wdt_sun6i_regmap[] = {
> +[0x] = REG_IRQ_EN,
> +[0x0004] = REG_IRQ_STA,
> +[0x0010] = REG_CTRL,
> +[0x0014] = REG_CFG,
> +[0x0018] = REG_MODE,
> +};
> +
> +static bool allwinner_wdt_sun4i_read(AwWdtState *s, uint32_t offset)
> +{
> +/* no sun4i specific registers currently implemented */
> +return false;
> +}
> +
> +static bool allwinner_wdt_sun4i_write(AwWdtState *s, uint32_t

Re: [PATCH 4/4] tests/avocado: Add reboot tests to Cubieboard

2023-03-14 Thread Niek Linnenbank
Hi Strahinja,

Looks good! I re-ran the tests on my machine, and they work fine:

ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
./build/tests/venv/bin/avocado --show=app,console run -t
machine:orangepi-pc -t machine:cubieboard
tests/avocado/boot_linux_console.py
...
|console: Tue Mar 14 19:56:37 UTC 2023
\console: Starting root file system check:
PASS (22.45 s)
RESULTS: PASS 8 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 189.23 s

Reviewed-by: Niek Linnenbank 
Tested-by: Niek Linnenbank 

On Sat, Mar 11, 2023 at 3:42 PM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> Cubieboard tests end with comment "reboot not functioning; omit test".
> Fix this so reboot is done at the end of each test.
>
> Signed-off-by: Strahinja Jankovic 
> ---
>  tests/avocado/boot_linux_console.py | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/tests/avocado/boot_linux_console.py
> b/tests/avocado/boot_linux_console.py
> index 574609bf43..c0675809e6 100644
> --- a/tests/avocado/boot_linux_console.py
> +++ b/tests/avocado/boot_linux_console.py
> @@ -581,7 +581,10 @@ def test_arm_cubieboard_initrd(self):
>  'Allwinner sun4i/sun5i')
>  exec_command_and_wait_for_pattern(self, 'cat /proc/iomem',
>  'system-control@1c0')
> -# cubieboard's reboot is not functioning; omit reboot test.
> +exec_command_and_wait_for_pattern(self, 'reboot',
> +'reboot: Restarting
> system')
> +# Wait for VM to shut down gracefully
> +self.vm.wait()
>
>  def test_arm_cubieboard_sata(self):
>  """
> @@ -625,7 +628,10 @@ def test_arm_cubieboard_sata(self):
>  'Allwinner sun4i/sun5i')
>  exec_command_and_wait_for_pattern(self, 'cat /proc/partitions',
>  'sda')
> -# cubieboard's reboot is not functioning; omit reboot test.
> +exec_command_and_wait_for_pattern(self, 'reboot',
> +'reboot: Restarting
> system')
> +# Wait for VM to shut down gracefully
> +self.vm.wait()
>
>  @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage
> limited')
>  def test_arm_cubieboard_openwrt_22_03_2(self):
> @@ -672,7 +678,10 @@ def test_arm_cubieboard_openwrt_22_03_2(self):
>
>  exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
>  'Allwinner sun4i/sun5i')
> -# cubieboard's reboot is not functioning; omit reboot test.
> +exec_command_and_wait_for_pattern(self, 'reboot',
> +'reboot: Restarting
> system')
> +# Wait for VM to shut down gracefully
> +    self.vm.wait()
>
>  @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might
> timeout')
>  def test_arm_quanta_gsj(self):
> --
> 2.30.2
>
>

-- 
Niek Linnenbank


Re: [RFC PATCH v1 00/12] *** Add allwinner R40 device support ***

2023-03-08 Thread Niek Linnenbank
Hello Qianfan Zhao,

Thanks for contributing this work to Qemu! With your contribution, we would
get yet another Allwinner SoC supported, making it three in total
(A10/H3/R40). That's great.
My thoughts are that maybe we should try to re-use commonality between
these SoCs where we can. Ofcourse, that may be difficult as the
internals/peripherals of these SoCs often really are different.

Your patches look good already, and I saw patches 02 and 03 are already
merged too. I did a quick regression test with
avocado for cubieboard/orangepi-pc with your patches applied and that went
OK:

$ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
./build/tests/venv/bin/avocado --show=app,console run -t
machine:orangepi-pc -t machine:cubieboard
tests/avocado/boot_linux_console.py
...
PASS (22.09 s)
RESULTS: PASS 8 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 169.73 s

For now, I have only two suggestions for you to consider:
1) You could add a new acceptance test for the new bananapi board to
./tests/avocado/boot_linux_console.py.
This helps in your current work to (re)test your code quickly, and after
the code is merged it helps to keep to board working when other changes are
done.
2) If time permits, it may be interesting to document your board for
example in a new file at ./docs/system/arm/bananapi.rst
   If you do this, it will make the board a lot more valuable for other
people to use, since you can add some basic instructions on how to use the
board with qemu there.
   Additionally, it also helps yourself to store this information
somewhere, since it can be easy to forget all the specific
commands/flags/arguments and links to board specific images.

Once you have progressed with your patches beyond the RFC stage, I'll try
to find some time for a more detailed review of your patches.

Kind regards,
Niek Linnenbank

On Thu, Mar 2, 2023 at 12:41 PM  wrote:

> From: qianfan Zhao 
>
> v1: 2023-03-02
>
> The first three patches try fix allwinner i2c driver and I already send
> them
> as a standalone PR and can read it from:
>
>
> https://patchwork.kernel.org/project/qemu-devel/patch/20230220081252.25348-3-qianfangui...@163.com/
>
> Hope that patch can merged first before this.
>
> The next patches will add allwinner R40 device support, including ccu,
> mmc, i2c,
> axp221 pmic, sdram controller, emac and gmac. Now the mainline u-boot and
> kernel can work fine (It doesn't support booting allwinner bsp code and
> there
> are no plans to support it now).
>
> qianfan Zhao (12):
>   hw: allwinner-i2c: Make the trace message more readable
>   hw: allwinner-i2c: Fix TWI_CNTR_INT_FLAG on SUN6i SoCs
>   hw: arm: allwinner-h3: Fix and complete H3 i2c devices
>   hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
>   hw/arm/allwinner-r40: add Clock Control Unit
>   hw: allwinner-r40: Complete uart devices
>   hw: arm: allwinner-r40: Add 5 TWI controllers
>   hw/misc: AXP221 PMU Emulation
>   hw/arm/allwinner-r40: add SDRAM controller device
>   hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
>   hw: arm: allwinner-r40: Fix the mmc controller's type
>   hw: arm: allwinner-r40: Add emac and gmac support
>
>  configs/devices/arm-softmmu/default.mak |   1 +
>  hw/arm/Kconfig  |  10 +
>  hw/arm/allwinner-h3.c   |  29 +-
>  hw/arm/allwinner-r40.c  | 555 
>  hw/arm/bananapi_m2u.c   | 128 ++
>  hw/arm/meson.build  |   1 +
>  hw/i2c/allwinner-i2c.c  | 136 +-
>  hw/i2c/trace-events |   5 +-
>  hw/misc/Kconfig |   4 +
>  hw/misc/allwinner-r40-ccu.c | 207 +
>  hw/misc/allwinner-r40-dramc.c   | 499 +
>  hw/misc/axp221.c| 196 +
>  hw/misc/meson.build |   3 +
>  hw/misc/trace-events|  19 +
>  hw/sd/allwinner-sdhost.c|  70 ++-
>  include/hw/arm/allwinner-h3.h   |   6 +
>  include/hw/arm/allwinner-r40.h  | 148 +++
>  include/hw/i2c/allwinner-i2c.h  |   6 +
>  include/hw/misc/allwinner-r40-ccu.h |  65 +++
>  include/hw/misc/allwinner-r40-dramc.h   | 108 +
>  include/hw/sd/allwinner-sdhost.h|   9 +
>  21 files changed, 2191 insertions(+), 14 deletions(-)
>  create mode 100644 hw/arm/allwinner-r40.c
>  create mode 100644 hw/arm/bananapi_m2u.c
>  create mode 100644 hw/misc/allwinner-r40-ccu.c
>  create mode 100644 hw/misc/allwinner-r40-dramc.c
>  create mode 100644 hw/misc/axp221.c
>  create mode 100644 include/hw/arm/allwinner-r40.h
>  create mode 100644 include/hw/misc/allwinner-r40-ccu.h
>  create mode 100644 include/hw/misc/allwinner-r40-dramc.h
>
> --
> 2.25.1
>
>

-- 
Niek Linnenbank


Re: [PATCH v3 7/7] tests/avocado: Add SD boot test to Cubieboard

2022-12-28 Thread Niek Linnenbank
On Mon, Dec 26, 2022 at 11:03 PM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> Cubieboard now can boot directly from SD card, without the need to pass
> `-kernel` parameter. Update Avocado tests to cover this functionality.
>
> Signed-off-by: Strahinja Jankovic 
>

Test looks fine to me, and is also working well with:

$ AVOCADO_ALLOW_LARGE_STORAGE=yes ./build/tests/venv/bin/avocado
--show=app,console run -t machine:cubieboard
tests/avocado/boot_linux_console.py
...
 (3/3)
tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_cubieboard_openwrt_22_03_2:
 console: U-Boot SPL 2020.04-OpenWrt-r19803-9a599fee93 (Oct 14 2022 -
22:44:41 +)
console: DRAM: 1024 MiB
console: CPU: 100800Hz, AXI/AHB/APB: 3/2/2
...
console: Hardware : Allwinner sun4i/sun5i Families
PASS (13.98 s)
RESULTS: PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 36.82 s

So for me:

Reviewed-by: Niek Linnenbank 
Tested-by: Niek Linnenbank 

> ---
>  tests/avocado/boot_linux_console.py | 47 +
>  1 file changed, 47 insertions(+)
>
> diff --git a/tests/avocado/boot_linux_console.py
> b/tests/avocado/boot_linux_console.py
> index ec07c64291..8c1d981586 100644
> --- a/tests/avocado/boot_linux_console.py
> +++ b/tests/avocado/boot_linux_console.py
> @@ -620,6 +620,53 @@ def test_arm_cubieboard_sata(self):
>  'sda')
>  # cubieboard's reboot is not functioning; omit reboot test.
>
> +@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage
> limited')
> +def test_arm_cubieboard_openwrt_22_03_2(self):
> +"""
> +:avocado: tags=arch:arm
> +:avocado: tags=machine:cubieboard
> +:avocado: tags=device:sd
> +"""
> +
> +# This test download a 7.5 MiB compressed image and expand it
> +# to 126 MiB.
> +image_url = ('
> https://downloads.openwrt.org/releases/22.03.2/targets/'
> + 'sunxi/cortexa8/openwrt-22.03.2-sunxi-cortexa8-'
> + 'cubietech_a10-cubieboard-ext4-sdcard.img.gz')
> +image_hash = ('94b5ecbfbc0b3b56276e5146b899eafa'
> +  '2ac5dc2d08733d6705af9f144f39f554')
> +image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash,
> + algorithm='sha256')
> +image_path = archive.extract(image_path_gz, self.workdir)
> +image_pow2ceil_expand(image_path)
> +
> +self.vm.set_console()
> +self.vm.add_args('-drive', 'file=' + image_path +
> ',if=sd,format=raw',
> + '-nic', 'user',
> + '-no-reboot')
> +self.vm.launch()
> +
> +kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
> +   'usbcore.nousb '
> +   'noreboot')
> +
> +self.wait_for_console_pattern('U-Boot SPL')
> +
> +interrupt_interactive_console_until_pattern(
> +self, 'Hit any key to stop autoboot:', '=>')
> +exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
> +kernel_command_line +
> "'", '=>')
> +exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel
> ...');
> +
> +self.wait_for_console_pattern(
> +'Please press Enter to activate this console.')
> +
> +exec_command_and_wait_for_pattern(self, ' ', 'root@')
> +
> +exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
> +    'Allwinner sun4i/sun5i')
> +# cubieboard's reboot is not functioning; omit reboot test.
> +
>  @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might
> timeout')
>  def test_arm_quanta_gsj(self):
>  """
> --
> 2.30.2
>
>

-- 
Niek Linnenbank


Re: [PATCH v3 3/7] {hw/i2c, docs/system/arm}: Allwinner TWI/I2C Emulation

2022-12-28 Thread Niek Linnenbank
On Mon, Dec 26, 2022 at 11:03 PM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> This patch implements Allwinner TWI/I2C controller emulation. Only
> master-mode functionality is implemented.
>
> The SPL boot for Cubieboard expects AXP209 PMIC on TWI0/I2C0 bus, so this
> is
> first part enabling the TWI/I2C bus operation.
>
> Since both Allwinner A10 and H3 use the same module, it is added for
> both boards.
>
> Docs are also updated for Cubieboard and Orangepi-PC board to indicate
> I2C availability.
>
> Signed-off-by: Strahinja Jankovic 
>
Reviewed-by: Niek Linnenbank 


> ---
>  docs/system/arm/cubieboard.rst |   1 +
>  docs/system/arm/orangepi.rst   |   1 +
>  hw/arm/Kconfig |   2 +
>  hw/arm/allwinner-a10.c |   8 +
>  hw/arm/allwinner-h3.c  |  11 +-
>  hw/i2c/Kconfig |   4 +
>  hw/i2c/allwinner-i2c.c | 459 +
>  hw/i2c/meson.build |   1 +
>  hw/i2c/trace-events|   5 +
>  include/hw/arm/allwinner-a10.h |   2 +
>  include/hw/arm/allwinner-h3.h  |   3 +
>  include/hw/i2c/allwinner-i2c.h |  55 
>  12 files changed, 551 insertions(+), 1 deletion(-)
>  create mode 100644 hw/i2c/allwinner-i2c.c
>  create mode 100644 include/hw/i2c/allwinner-i2c.h
>
> diff --git a/docs/system/arm/cubieboard.rst
> b/docs/system/arm/cubieboard.rst
> index 344ff8cef9..8d485f5435 100644
> --- a/docs/system/arm/cubieboard.rst
> +++ b/docs/system/arm/cubieboard.rst
> @@ -14,3 +14,4 @@ Emulated devices:
>  - SDHCI
>  - USB controller
>  - SATA controller
> +- TWI (I2C) controller
> diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
> index 83c7445197..e5973600a1 100644
> --- a/docs/system/arm/orangepi.rst
> +++ b/docs/system/arm/orangepi.rst
> @@ -25,6 +25,7 @@ The Orange Pi PC machine supports the following devices:
>   * Clock Control Unit
>   * System Control module
>   * Security Identifier device
> + * TWI (I2C)
>
>  Limitations
>  """""""""""
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 140f142ae5..eefe1fd134 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -322,6 +322,7 @@ config ALLWINNER_A10
>  select ALLWINNER_A10_CCM
>  select ALLWINNER_A10_DRAMC
>  select ALLWINNER_EMAC
> +select ALLWINNER_I2C
>  select SERIAL
>  select UNIMP
>
> @@ -329,6 +330,7 @@ config ALLWINNER_H3
>  bool
>  select ALLWINNER_A10_PIT
>  select ALLWINNER_SUN8I_EMAC
> +select ALLWINNER_I2C
>  select SERIAL
>  select ARM_TIMER
>  select ARM_GIC
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index a5f7a36ac9..17e439777e 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -36,6 +36,7 @@
>  #define AW_A10_OHCI_BASE0x01c14400
>  #define AW_A10_SATA_BASE0x01c18000
>  #define AW_A10_RTC_BASE 0x01c20d00
> +#define AW_A10_I2C0_BASE0x01c2ac00
>
>  static void aw_a10_init(Object *obj)
>  {
> @@ -56,6 +57,8 @@ static void aw_a10_init(Object *obj)
>
>  object_initialize_child(obj, "sata", >sata, TYPE_ALLWINNER_AHCI);
>
> +object_initialize_child(obj, "i2c0", >i2c0, TYPE_AW_I2C);
> +
>  if (machine_usb(current_machine)) {
>  int i;
>
> @@ -176,6 +179,11 @@ static void aw_a10_realize(DeviceState *dev, Error
> **errp)
>  /* RTC */
>  sysbus_realize(SYS_BUS_DEVICE(>rtc), _fatal);
>  sysbus_mmio_map_overlap(SYS_BUS_DEVICE(>rtc), 0, AW_A10_RTC_BASE,
> 10);
> +
> +/* I2C */
> +sysbus_realize(SYS_BUS_DEVICE(>i2c0), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>i2c0), 0, AW_A10_I2C0_BASE);
> +sysbus_connect_irq(SYS_BUS_DEVICE(>i2c0), 0, qdev_get_gpio_in(dev,
> 7));
>  }
>
>  static void aw_a10_class_init(ObjectClass *oc, void *data)
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 308ed15552..bfce3c8d92 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -53,6 +53,7 @@ const hwaddr allwinner_h3_memmap[] = {
>  [AW_H3_DEV_UART1]  = 0x01c28400,
>  [AW_H3_DEV_UART2]  = 0x01c28800,
>  [AW_H3_DEV_UART3]  = 0x01c28c00,
> +[AW_H3_DEV_TWI0]   = 0x01c2ac00,
>  [AW_H3_DEV_EMAC]   = 0x01c3,
>  [AW_H3_DEV_DRAMCOM]= 0x01c62000,
>  [AW_H3_DEV_DRAMCTL]= 0x01c63000,
> @@ -106,7 +107,6 @@ struct AwH3Unimplemented {
>  { "uart1", 0x01c28400, 1 * KiB },
>  { "uart2", 0x01c28800, 1 * KiB },
>  { "uart3", 0x01c28c00, 1 * KiB },
> -   

Re: [PATCH 0/6] Enable Cubieboard A10 boot SPL from SD card

2022-12-08 Thread Niek Linnenbank
Hi Strahinja,

On Thu, Dec 8, 2022 at 8:24 PM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> Hi Niek,
>
> On Wed, Dec 7, 2022 at 9:25 PM Niek Linnenbank 
> wrote:
> >
> > Hello Strahinja,
> >
> > Thanks for contribution these patches, and also taking the H3 into
> account :-)
>
> Thank you for looking into these patches and all of the comments. I
> will try to submit V2 of this patch set in the following days.
>
> >
> > I've ran the avocado based acceptance tests for both boards and got
> these results:
> >
> > $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
> ./build/tests/venv/bin/avocado --show=app,console run -t
> machine:orangepi-pc tests/avocado/boot_linux_console.py
> > ...
> > RESULTS: PASS 5 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
> CANCEL 0
> > JOB TIME   : 114.24 s
> >
> > $ ./build/tests/venv/bin/avocado --show=app,console run -t
> machine:cubieboard tests/avocado/boot_linux_console.py
> > ...
> > RESULTS: PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
> CANCEL 0
> > JOB TIME   : 22.79 s
>
> I did not think initially about avocado, but maybe I could also add an
> SPL/SD boot test for the cubieboard, similarly to the way it is run
> for Orange Pi, for V2 of the patch set?
>

Yeah that would be great. It can help to make testing easier when working
on your current code, since its all automated.
And when covering the SPL/SD boot with an acceptance test, it also helps to
ensure it keeps working with future updates to Qemu code too.

One thing to be aware of is to select an image with an URL that is stable.
Once a new test is merged, and the image is subsequently deleted
from the remote server, the test can't run anymore. We've had such a
problem before with the orangepi-pc tests.

Regards,
Niek


>
> Best regards,
> Strahinja
>
>
>
> >
> > So that shows both machines are still running fine. During startup of
> the bionic 20.08 image for orangepi-pc it did show this message:
> >   console: i2c i2c-0: mv64xxx: I2C bus locked, block: 1, time_left: 0
> >   console: sy8106a: probe of 0-0065 failed with error -110
> >
> > The SY8106a appears to be an peripheral attached to the I2C bus on the
> orangepi-pc, and we don't emulate the SY8106a yet, so that's an error to be
> expected:
> >   https://linux-sunxi.org/SY8106A
> >
> > So for the series:
> > Tested-by: Niek Linnenbank 
> >
> > I'll try to reply to each patch as well.
> >
> > Kind regards,
> > Niek
> >
> > On Sun, Dec 4, 2022 at 12:19 AM Strahinja Jankovic <
> strahinjapjanko...@gmail.com> wrote:
> >>
> >> This patch series adds missing Allwinner A10 modules needed for
> >> successful SPL boot:
> >> - Clock controller module
> >> - DRAM controller
> >> - I2C0 controller (added also for Allwinner H3 since it is the same)
> >> - AXP-209 connected to I2C0 bus
> >>
> >> It also updates Allwinner A10 emulation so SPL is copied from attached
> >> SD card if `-kernel` parameter is not passed when starting QEMU
> >> (approach adapted from Allwinner H3 implementation).
> >>
> >> Boot from SD card has been tested with Cubieboard Armbian SD card image
> and custom
> >> Yocto image built for Cubieboard.
> >> Example usage for Armbian image:
> >> qemu-system-arm -M cubieboard -nographic -sd
> ~/Armbian_22.11.0-trunk_Cubieboard_kinetic_edge_6.0.7.img
> >>
> >>
> >> Strahinja Jankovic (6):
> >>   hw/misc: Allwinner-A10 Clock Controller Module Emulation
> >>   hw/misc: Allwinner A10 DRAM Controller Emulation
> >>   hw/i2c: Allwinner TWI/I2C Emulation
> >>   hw/misc: Allwinner AXP-209 Emulation
> >>   hw/arm: Add AXP-209 to Cubieboard
> >>   hw/arm: Allwinner A10 enable SPL load from MMC
> >>
> >>  hw/arm/Kconfig|   5 +
> >>  hw/arm/allwinner-a10.c|  40 +++
> >>  hw/arm/allwinner-h3.c |  11 +-
> >>  hw/arm/cubieboard.c   |  11 +
> >>  hw/i2c/Kconfig|   4 +
> >>  hw/i2c/allwinner-i2c.c| 417 ++
> >>  hw/i2c/meson.build|   1 +
> >>  hw/misc/Kconfig   |  10 +
> >>  hw/misc/allwinner-a10-ccm.c   | 224 ++
> >>  hw/misc/allwinner-a10-dramc.c | 179 +++
> >>  hw/misc/allwinner-axp-209.c   | 263 
> >>  hw/misc/meson.build 

Re: [PATCH 6/6] hw/arm: Allwinner A10 enable SPL load from MMC

2022-12-07 Thread Niek Linnenbank
Hi Strahinja,


On Sun, Dec 4, 2022 at 12:19 AM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> This patch enables copying of SPL from MMC if `-kernel` parameter is not
> passed when starting QEMU. SPL is copied to SRAM_A.
>
> The approach is reused from Allwinner H3 implementation.
>
> Tested with Armbian and custom Yocto image.
>
> Signed-off-by: Strahinja Jankovic 
> ---
>  hw/arm/allwinner-a10.c | 18 ++
>  hw/arm/cubieboard.c|  5 +
>  include/hw/arm/allwinner-a10.h | 21 +
>  3 files changed, 44 insertions(+)
>
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 17e439777e..dc1966ff7a 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -24,7 +24,9 @@
>  #include "sysemu/sysemu.h"
>  #include "hw/boards.h"
>  #include "hw/usb/hcd-ohci.h"
> +#include "hw/loader.h"
>
> +#define AW_A10_SRAM_A_BASE  0x
>  #define AW_A10_DRAMC_BASE   0x01c01000
>  #define AW_A10_MMC0_BASE0x01c0f000
>  #define AW_A10_CCM_BASE 0x01c2
> @@ -38,6 +40,22 @@
>  #define AW_A10_RTC_BASE 0x01c20d00
>  #define AW_A10_I2C0_BASE0x01c2ac00
>
> +void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk)
> +{
> +const int64_t rom_size = 32 * KiB;
> +g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
> +
> +if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
> +error_setg(_fatal, "%s: failed to read BlockBackend data",
> +   __func__);
> +return;
> +}
> +
> +rom_add_blob("allwinner-a10.bootrom", buffer, rom_size,
> +  rom_size, AW_A10_SRAM_A_BASE,
> +  NULL, NULL, NULL, NULL, false);
> +}
>

Its probably fine for now to do it in the same way here for the A10 indeed.
Perhaps in the future, we can try
to share some overlapping code between the A10 and H3.

So the patch looks fine to me:
Reviewed-by: Niek Linnenbank 

Regards,
Niek


> +
>  static void aw_a10_init(Object *obj)
>  {
>  AwA10State *s = AW_A10(obj);
> diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
> index afc7980414..37659c35fd 100644
> --- a/hw/arm/cubieboard.c
> +++ b/hw/arm/cubieboard.c
> @@ -99,6 +99,11 @@ static void cubieboard_init(MachineState *machine)
>  memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
>  machine->ram);
>
> +/* Load target kernel or start using BootROM */
> +if (!machine->kernel_filename && blk && blk_is_available(blk)) {
> +/* Use Boot ROM to copy data from SD card to SRAM */
> +allwinner_a10_bootrom_setup(a10, blk);
> +}
>  /* TODO create and connect IDE devices for ide_drive_get() */
>
>  cubieboard_binfo.ram_size = machine->ram_size;
> diff --git a/include/hw/arm/allwinner-a10.h
> b/include/hw/arm/allwinner-a10.h
> index 763935fca9..b3c9ed24c7 100644
> --- a/include/hw/arm/allwinner-a10.h
> +++ b/include/hw/arm/allwinner-a10.h
> @@ -15,6 +15,7 @@
>  #include "hw/misc/allwinner-a10-ccm.h"
>  #include "hw/misc/allwinner-a10-dramc.h"
>  #include "hw/i2c/allwinner-i2c.h"
> +#include "sysemu/block-backend.h"
>
>  #include "target/arm/cpu.h"
>  #include "qom/object.h"
> @@ -47,4 +48,24 @@ struct AwA10State {
>  OHCISysBusState ohci[AW_A10_NUM_USB];
>  };
>
> +/**
> + * Emulate Boot ROM firmware setup functionality.
> + *
> + * A real Allwinner A10 SoC contains a Boot ROM
> + * which is the first code that runs right after
> + * the SoC is powered on. The Boot ROM is responsible
> + * for loading user code (e.g. a bootloader) from any
> + * of the supported external devices and writing the
> + * downloaded code to internal SRAM. After loading the SoC
> + * begins executing the code written to SRAM.
> + *
> + * This function emulates the Boot ROM by copying 32 KiB
> + * of data from the given block device and writes it to
> + * the start of the first internal SRAM memory.
> + *
> + * @s: Allwinner A10 state object pointer
> + * @blk: Block backend device object pointer
> + */
> +void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk);
> +
>  #endif
> --
> 2.30.2
>
>

-- 
Niek Linnenbank


Re: [PATCH 1/6] hw/misc: Allwinner-A10 Clock Controller Module Emulation

2022-12-07 Thread Niek Linnenbank
Hi Strahinja,

On Sun, Dec 4, 2022 at 12:19 AM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> During SPL boot several Clock Controller Module (CCM) registers are
> read, most important are PLL and Tuning, as well as divisor registers.
>
> This patch adds these registers and initializes reset values from user's
> guide.
>
> Signed-off-by: Strahinja Jankovic 
>

Looks fine to me:

Reviewed-by: Niek Linnenbank 

Regards,
Niek

> ---
>  hw/arm/Kconfig  |   1 +
>  hw/arm/allwinner-a10.c  |   7 +
>  hw/misc/Kconfig |   3 +
>  hw/misc/allwinner-a10-ccm.c | 224 
>  hw/misc/meson.build |   1 +
>  include/hw/arm/allwinner-a10.h  |   2 +
>  include/hw/misc/allwinner-a10-ccm.h |  67 +
>  7 files changed, 305 insertions(+)
>  create mode 100644 hw/misc/allwinner-a10-ccm.c
>  create mode 100644 include/hw/misc/allwinner-a10-ccm.h
>
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 17fcde8e1c..14f52b41af 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -319,6 +319,7 @@ config ALLWINNER_A10
>  select AHCI
>  select ALLWINNER_A10_PIT
>  select ALLWINNER_A10_PIC
> +select ALLWINNER_A10_CCM
>  select ALLWINNER_EMAC
>  select SERIAL
>  select UNIMP
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 79082289ea..86baeeeca2 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -26,6 +26,7 @@
>  #include "hw/usb/hcd-ohci.h"
>
>  #define AW_A10_MMC0_BASE0x01c0f000
> +#define AW_A10_CCM_BASE 0x01c2
>  #define AW_A10_PIC_REG_BASE 0x01c20400
>  #define AW_A10_PIT_REG_BASE 0x01c20c00
>  #define AW_A10_UART0_REG_BASE   0x01c28000
> @@ -46,6 +47,8 @@ static void aw_a10_init(Object *obj)
>
>  object_initialize_child(obj, "timer", >timer, TYPE_AW_A10_PIT);
>
> +object_initialize_child(obj, "ccm", >ccm, TYPE_AW_A10_CCM);
> +
>  object_initialize_child(obj, "emac", >emac, TYPE_AW_EMAC);
>
>  object_initialize_child(obj, "sata", >sata, TYPE_ALLWINNER_AHCI);
> @@ -103,6 +106,10 @@ static void aw_a10_realize(DeviceState *dev, Error
> **errp)
>  memory_region_add_subregion(get_system_memory(), 0x,
> >sram_a);
>  create_unimplemented_device("a10-sram-ctrl", 0x01c0, 4 * KiB);
>
> +/* Clock Control Module */
> +sysbus_realize(SYS_BUS_DEVICE(>ccm), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>ccm), 0, AW_A10_CCM_BASE);
> +
>  /* FIXME use qdev NIC properties instead of nd_table[] */
>  if (nd_table[0].used) {
>  qemu_check_nic_model(_table[0], TYPE_AW_EMAC);
> diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
> index cbabe9f78c..ed07bf4133 100644
> --- a/hw/misc/Kconfig
> +++ b/hw/misc/Kconfig
> @@ -174,4 +174,7 @@ config VIRT_CTRL
>  config LASI
>  bool
>
> +config ALLWINNER_A10_CCM
> +bool
> +
>  source macio/Kconfig
> diff --git a/hw/misc/allwinner-a10-ccm.c b/hw/misc/allwinner-a10-ccm.c
> new file mode 100644
> index 00..68146ee340
> --- /dev/null
> +++ b/hw/misc/allwinner-a10-ccm.c
> @@ -0,0 +1,224 @@
> +/*
> + * Allwinner A10 Clock Control Module emulation
> + *
> + * Copyright (C) 2022 Strahinja Jankovic 
> + *
> + *  This file is derived from Allwinner H3 CCU,
> + *  by Niek Linnenbank.
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/units.h"
> +#include "hw/sysbus.h"
> +#include "migration/vmstate.h"
> +#include "qemu/log.h"
> +#include "qemu/module.h"
> +#include "hw/misc/allwinner-a10-ccm.h"
> +
> +/* CCM register offsets */
> +enum {
> +REG_PLL1_CFG = 0x, /* PLL1 Control */
> +REG_PLL1_TUN = 0x0004, /* PLL1 Tuning */
> +REG_PLL2_CFG = 0x0008, /* PLL2 Control */
> +REG_

Re: [PATCH 2/6] hw/misc: Allwinner A10 DRAM Controller Emulation

2022-12-07 Thread Niek Linnenbank
Hi Strahinja,

On Sun, Dec 4, 2022 at 12:19 AM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> During SPL boot several DRAM Controller registers are used. Most
> important registers are those related to DRAM initialization and
> calibration, where SPL initiates process and waits until certain bit is
> set/cleared.
>
> This patch adds these registers, initializes reset values from user's
> guide and updates state of registers as SPL expects it.
>
> Signed-off-by: Strahinja Jankovic 
> ---
>  hw/arm/Kconfig|   1 +
>  hw/arm/allwinner-a10.c|   7 +
>  hw/misc/Kconfig   |   3 +
>  hw/misc/allwinner-a10-dramc.c | 179 ++
>  hw/misc/meson.build   |   1 +
>  include/hw/arm/allwinner-a10.h|   2 +
>  include/hw/misc/allwinner-a10-dramc.h |  68 ++
>  7 files changed, 261 insertions(+)
>  create mode 100644 hw/misc/allwinner-a10-dramc.c
>  create mode 100644 include/hw/misc/allwinner-a10-dramc.h
>
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 14f52b41af..140f142ae5 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -320,6 +320,7 @@ config ALLWINNER_A10
>  select ALLWINNER_A10_PIT
>  select ALLWINNER_A10_PIC
>  select ALLWINNER_A10_CCM
> +select ALLWINNER_A10_DRAMC
>  select ALLWINNER_EMAC
>  select SERIAL
>  select UNIMP
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 86baeeeca2..a5f7a36ac9 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -25,6 +25,7 @@
>  #include "hw/boards.h"
>  #include "hw/usb/hcd-ohci.h"
>
> +#define AW_A10_DRAMC_BASE   0x01c01000
>  #define AW_A10_MMC0_BASE0x01c0f000
>  #define AW_A10_CCM_BASE 0x01c2
>  #define AW_A10_PIC_REG_BASE 0x01c20400
> @@ -49,6 +50,8 @@ static void aw_a10_init(Object *obj)
>
>  object_initialize_child(obj, "ccm", >ccm, TYPE_AW_A10_CCM);
>
> +object_initialize_child(obj, "dramc", >dramc, TYPE_AW_A10_DRAMC);
> +
>  object_initialize_child(obj, "emac", >emac, TYPE_AW_EMAC);
>
>  object_initialize_child(obj, "sata", >sata, TYPE_ALLWINNER_AHCI);
> @@ -110,6 +113,10 @@ static void aw_a10_realize(DeviceState *dev, Error
> **errp)
>  sysbus_realize(SYS_BUS_DEVICE(>ccm), _fatal);
>  sysbus_mmio_map(SYS_BUS_DEVICE(>ccm), 0, AW_A10_CCM_BASE);
>
> +/* DRAM Control Module */
> +sysbus_realize(SYS_BUS_DEVICE(>dramc), _fatal);
> +sysbus_mmio_map(SYS_BUS_DEVICE(>dramc), 0, AW_A10_DRAMC_BASE);
> +
>  /* FIXME use qdev NIC properties instead of nd_table[] */
>  if (nd_table[0].used) {
>  qemu_check_nic_model(_table[0], TYPE_AW_EMAC);
> diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
> index ed07bf4133..052fb54310 100644
> --- a/hw/misc/Kconfig
> +++ b/hw/misc/Kconfig
> @@ -177,4 +177,7 @@ config LASI
>  config ALLWINNER_A10_CCM
>  bool
>
> +config ALLWINNER_A10_DRAMC
> +bool
> +
>  source macio/Kconfig
> diff --git a/hw/misc/allwinner-a10-dramc.c b/hw/misc/allwinner-a10-dramc.c
> new file mode 100644
> index 00..e118b0c2fd
> --- /dev/null
> +++ b/hw/misc/allwinner-a10-dramc.c
> @@ -0,0 +1,179 @@
> +/*
> + * Allwinner A10 DRAM Controller emulation
> + *
> + * Copyright (C) 2022 Strahinja Jankovic 
> + *
> + *  This file is derived from Allwinner H3 DRAMC,
> + *  by Niek Linnenbank.
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/units.h"
> +#include "hw/sysbus.h"
> +#include "migration/vmstate.h"
> +#include "qemu/log.h"
> +#include "qemu/module.h"
> +#include "hw/misc/allwinner-a10-dramc.h"
> +
> +/* DRAMC register offsets */
> +enum {
> +REG_SDR_CCR = 0x,
> +REG_SDR_ZQCR0 = 0x00a8,
> +REG_SDR_ZQSR = 0x00b0
> +};
>

This matches indeed with what is curr

Re: [PATCH 3/6] hw/i2c: Allwinner TWI/I2C Emulation

2022-12-07 Thread Niek Linnenbank
w/rtc/allwinner-rtc.h"
> +#include "hw/i2c/allwinner-i2c.h"
>  #include "target/arm/cpu.h"
>  #include "sysemu/block-backend.h"
>
> @@ -82,6 +83,7 @@ enum {
>  AW_H3_DEV_UART2,
>  AW_H3_DEV_UART3,
>  AW_H3_DEV_EMAC,
> +AW_H3_DEV_TWI0,
>  AW_H3_DEV_DRAMCOM,
>  AW_H3_DEV_DRAMCTL,
>  AW_H3_DEV_DRAMPHY,
> @@ -130,6 +132,7 @@ struct AwH3State {
>  AwH3SysCtrlState sysctrl;
>  AwSidState sid;
>  AwSdHostState mmc0;
> +AWI2CState i2c0;
>  AwSun8iEmacState emac;
>  AwRtcState rtc;
>  GICState gic;
> diff --git a/include/hw/i2c/allwinner-i2c.h
> b/include/hw/i2c/allwinner-i2c.h
> new file mode 100644
> index 00..1e3169a5b9
> --- /dev/null
> +++ b/include/hw/i2c/allwinner-i2c.h
> @@ -0,0 +1,112 @@
> +/*
> + *  Allwinner I2C Bus Serial Interface registers definition
> + *
> + *  Copyright (C) 2022 Strahinja Jankovic. <
> strahinja.p.janko...@gmail.com>
> + *
> + *  This file is derived from IMX I2C controller,
> + *  by Jean-Christophe DUBOIS .
> + *
> + *  This program is free software; you can redistribute it and/or modify
> it
> + *  under the terms of the GNU General Public License as published by the
> + *  Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful, but
> WITHOUT
> + *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + *  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
> + *  for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> along
> + *  with this program; if not, see <http://www.gnu.org/licenses/>.
> + *
> + */
> +
> +#ifndef ALLWINNER_I2C_H
> +#define ALLWINNER_I2C_H
> +
> +#include "hw/sysbus.h"
> +#include "qom/object.h"
> +
> +#define TYPE_AW_I2C "allwinner.i2c"
> +OBJECT_DECLARE_SIMPLE_TYPE(AWI2CState, AW_I2C)
> +
> +#define AW_I2C_MEM_SIZE 0x24
> +
> +/* Allwinner I2C memory map */
> +#define TWI_ADDR_REG0x00  /* slave address register */
> +#define TWI_XADDR_REG   0x04  /* extended slave address register
> */
> +#define TWI_DATA_REG0x08  /* data register */
> +#define TWI_CNTR_REG0x0c  /* control register */
> +#define TWI_STAT_REG0x10  /* status register */
> +#define TWI_CCR_REG 0x14  /* clock control register */
> +#define TWI_SRST_REG0x18  /* software reset register */
> +#define TWI_EFR_REG 0x1c  /* enhance feature register */
> +#define TWI_LCR_REG 0x20  /* line control register */
> +
>
If no other modules except for the new driver need these defines, it may be
a good idea to move them to the .c file instead.
Doing so helps avoiding accidental or unintentional use of the defines.
Same for the other flags below.


> +/* Used only in slave mode, do not set */
> +#define TWI_ADDR_RESET  0
> +#define TWI_XADDR_RESET 0
> +
> +/* Data register */
> +#define TWI_DATA_MASK   0xFF
> +#define TWI_DATA_RESET  0
> +
> +/* Control register */
> +#define TWI_CNTR_INT_EN (1 << 7)
> +#define TWI_CNTR_BUS_EN (1 << 6)
> +#define TWI_CNTR_M_STA  (1 << 5)
> +#define TWI_CNTR_M_STP  (1 << 4)
> +#define TWI_CNTR_INT_FLAG   (1 << 3)
> +#define TWI_CNTR_A_ACK  (1 << 2)
> +#define TWI_CNTR_MASK   0xFC
> +#define TWI_CNTR_RESET  0
> +
> +/* Status register */
> +#define TWI_STAT_MASK   0xF8
> +#define TWI_STAT_RESET  0xF8
> +
> +/* Clock register */
> +#define TWI_CCR_CLK_M_MASK  0x78
> +#define TWI_CCR_CLK_N_MASK  0x07
> +#define TWI_CCR_MASK0x7F
> +#define TWI_CCR_RESET   0
> +
> +/* Soft reset */
> +#define TWI_SRST_MASK   0x01
> +#define TWI_SRST_RESET  0
> +
> +/* Enhance feature */
> +#define TWI_EFR_MASK0x03
> +#define TWI_EFR_RESET   0
> +
> +/* Line control */
> +#define TWI_LCR_SCL_STATE   (1 << 5)
> +#define TWI_LCR_SDA_STATE   (1 << 4)
> +#define TWI_LCR_SCL_CTL (1 << 3)
> +#define TWI_LCR_SCL_CTL_EN  (1 << 2)
> +#define TWI_LCR_SDA_CTL (1 << 1)
> +#define TWI_LCR_SDA_CTL_EN  (1 << 0)
> +#define TWI_LCR_MASK0x3F
> +#define TWI_LCR_RESET   0x3A
> +
> +struct AWI2CState {
> +/*< private >*/
> +SysBusDevice parent_obj;
> +
> +/*< public >*/
> +MemoryRegion iomem;
> +I2CBus *bus;
> +qemu_irq irq;
> +
> +uint8_t addr;
> +uint8_t xaddr;
> +uint8_t data;
> +uint8_t cntr;
> +uint8_t stat;
> +uint8_t ccr;
> +uint8_t srst;
> +uint8_t efr;
> +uint8_t lcr;
> +};
> +
> +#endif /* ALLWINNER_I2C_H */
> --
> 2.30.2
>
>
Regards,
Niek

-- 
Niek Linnenbank


Re: [PATCH 0/6] Enable Cubieboard A10 boot SPL from SD card

2022-12-07 Thread Niek Linnenbank
Hello Strahinja,

Thanks for contribution these patches, and also taking the H3 into account
:-)

I've ran the avocado based acceptance tests for both boards and got these
results:

$ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
./build/tests/venv/bin/avocado --show=app,console run -t
machine:orangepi-pc tests/avocado/boot_linux_console.py
...
RESULTS: PASS 5 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 114.24 s

$ ./build/tests/venv/bin/avocado --show=app,console run -t
machine:cubieboard tests/avocado/boot_linux_console.py
...
RESULTS: PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 22.79 s

So that shows both machines are still running fine. During startup of the
bionic 20.08 image for orangepi-pc it did show this message:
  console: i2c i2c-0: mv64xxx: I2C bus locked, block: 1, time_left: 0
  console: sy8106a: probe of 0-0065 failed with error -110

The SY8106a appears to be an peripheral attached to the I2C bus on the
orangepi-pc, and we don't emulate the SY8106a yet, so that's an error to be
expected:
  https://linux-sunxi.org/SY8106A

So for the series:
Tested-by: Niek Linnenbank 

I'll try to reply to each patch as well.

Kind regards,
Niek

On Sun, Dec 4, 2022 at 12:19 AM Strahinja Jankovic <
strahinjapjanko...@gmail.com> wrote:

> This patch series adds missing Allwinner A10 modules needed for
> successful SPL boot:
> - Clock controller module
> - DRAM controller
> - I2C0 controller (added also for Allwinner H3 since it is the same)
> - AXP-209 connected to I2C0 bus
>
> It also updates Allwinner A10 emulation so SPL is copied from attached
> SD card if `-kernel` parameter is not passed when starting QEMU
> (approach adapted from Allwinner H3 implementation).
>
> Boot from SD card has been tested with Cubieboard Armbian SD card image
> and custom
> Yocto image built for Cubieboard.
> Example usage for Armbian image:
> qemu-system-arm -M cubieboard -nographic -sd
> ~/Armbian_22.11.0-trunk_Cubieboard_kinetic_edge_6.0.7.img
>
>
> Strahinja Jankovic (6):
>   hw/misc: Allwinner-A10 Clock Controller Module Emulation
>   hw/misc: Allwinner A10 DRAM Controller Emulation
>   hw/i2c: Allwinner TWI/I2C Emulation
>   hw/misc: Allwinner AXP-209 Emulation
>   hw/arm: Add AXP-209 to Cubieboard
>   hw/arm: Allwinner A10 enable SPL load from MMC
>
>  hw/arm/Kconfig|   5 +
>  hw/arm/allwinner-a10.c|  40 +++
>  hw/arm/allwinner-h3.c |  11 +-
>  hw/arm/cubieboard.c   |  11 +
>  hw/i2c/Kconfig|   4 +
>  hw/i2c/allwinner-i2c.c| 417 ++
>  hw/i2c/meson.build|   1 +
>  hw/misc/Kconfig   |  10 +
>  hw/misc/allwinner-a10-ccm.c   | 224 ++
>  hw/misc/allwinner-a10-dramc.c | 179 +++
>  hw/misc/allwinner-axp-209.c   | 263 
>  hw/misc/meson.build   |   3 +
>  include/hw/arm/allwinner-a10.h|  27 ++
>  include/hw/arm/allwinner-h3.h |   3 +
>  include/hw/i2c/allwinner-i2c.h| 112 +++
>  include/hw/misc/allwinner-a10-ccm.h   |  67 +
>  include/hw/misc/allwinner-a10-dramc.h |  68 +
>  17 files changed, 1444 insertions(+), 1 deletion(-)
>  create mode 100644 hw/i2c/allwinner-i2c.c
>  create mode 100644 hw/misc/allwinner-a10-ccm.c
>  create mode 100644 hw/misc/allwinner-a10-dramc.c
>  create mode 100644 hw/misc/allwinner-axp-209.c
>  create mode 100644 include/hw/i2c/allwinner-i2c.h
>  create mode 100644 include/hw/misc/allwinner-a10-ccm.h
>  create mode 100644 include/hw/misc/allwinner-a10-dramc.h
>
> --
> 2.30.2
>
>

-- 
Niek Linnenbank


Re: [PATCH] memory: Make memory_region_readd_subregion() properly handle mapped aliases

2022-03-21 Thread Niek Linnenbank
Hi Paolo, Peter,

With the 7.0 release approaching, just a friendly reminder that the patch
in this thread is not yet in master
(2058fdbe81e2985c226a026851dd26b146d3395c).
It's currently preventing the orangepi-pc board to boot SD card images from
U-Boot, terminating with an assert:
   https://www.mail-archive.com/qemu-devel@nongnu.org/msg865382.html

If it helps, I did a full build with David's patch and re-ran all the
boot_linux_console.py tests and all passed OK.

Would it be possible to get this in before the upcoming release?

Thanks in advance,
Niek

On Mon, Feb 28, 2022 at 9:03 PM Niek Linnenbank 
wrote:

> Hi Paolo,
>
> Thanks for queing this patch. I did not yet see it appear in master. Do
> you know when we can expect to see it?
>
> Regards,
> Niek
>
> On Tue, Feb 1, 2022 at 11:51 AM Paolo Bonzini  wrote:
>
>> On 2/1/22 11:09, David Hildenbrand wrote:
>> > memory_region_readd_subregion() wants to readd a region by first
>> > removing it and then readding it. For readding, it doesn't use one of
>> > the memory_region_add_*() variants, which is why fail to re-increment
>> the
>> > mr->mapped_via_alias counters, resulting in the
>> > assert(alias->mapped_via_alias >= 0) in memory_region_del_subregion()
>> > triggering the next time we call memory_region_readd_subregion().
>> >
>> > Fix it by using memory_region_add_subregion_common() for readding the
>> > region.
>> >
>> > Reported-by: Niek Linnenbank 
>> > Fixes: 5ead62185d23 ("memory: Make memory_region_is_mapped() succeed
>> when mapped via an alias")
>> > Tested-by: Niek Linnenbank 
>> > Cc: Paolo Bonzini 
>> > Cc: Peter Xu 
>> > Cc: "Philippe Mathieu-Daudé" 
>> > Signed-off-by: David Hildenbrand 
>> > ---
>> >   softmmu/memory.c | 3 +--
>> >   1 file changed, 1 insertion(+), 2 deletions(-)
>> >
>> > diff --git a/softmmu/memory.c b/softmmu/memory.c
>> > index 678dc62f06..76bb1677fe 100644
>> > --- a/softmmu/memory.c
>> > +++ b/softmmu/memory.c
>> > @@ -2626,8 +2626,7 @@ static void
>> memory_region_readd_subregion(MemoryRegion *mr)
>> >   memory_region_transaction_begin();
>> >   memory_region_ref(mr);
>> >   memory_region_del_subregion(container, mr);
>> > -mr->container = container;
>> > -memory_region_update_container_subregions(mr);
>> > +memory_region_add_subregion_common(container, mr->addr, mr);
>> >   memory_region_unref(mr);
>> >   memory_region_transaction_commit();
>> >   }
>>
>> Queued, thanks.
>>
>> Paolo
>>
>
>
> --
> Niek Linnenbank
>
>

-- 
Niek Linnenbank


Re: [PATCH] memory: Make memory_region_readd_subregion() properly handle mapped aliases

2022-02-28 Thread Niek Linnenbank
Hi Paolo,

Thanks for queing this patch. I did not yet see it appear in master. Do you
know when we can expect to see it?

Regards,
Niek

On Tue, Feb 1, 2022 at 11:51 AM Paolo Bonzini  wrote:

> On 2/1/22 11:09, David Hildenbrand wrote:
> > memory_region_readd_subregion() wants to readd a region by first
> > removing it and then readding it. For readding, it doesn't use one of
> > the memory_region_add_*() variants, which is why fail to re-increment the
> > mr->mapped_via_alias counters, resulting in the
> > assert(alias->mapped_via_alias >= 0) in memory_region_del_subregion()
> > triggering the next time we call memory_region_readd_subregion().
> >
> > Fix it by using memory_region_add_subregion_common() for readding the
> > region.
> >
> > Reported-by: Niek Linnenbank 
> > Fixes: 5ead62185d23 ("memory: Make memory_region_is_mapped() succeed
> when mapped via an alias")
> > Tested-by: Niek Linnenbank 
> > Cc: Paolo Bonzini 
> > Cc: Peter Xu 
> > Cc: "Philippe Mathieu-Daudé" 
> > Signed-off-by: David Hildenbrand 
> > ---
> >   softmmu/memory.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/softmmu/memory.c b/softmmu/memory.c
> > index 678dc62f06..76bb1677fe 100644
> > --- a/softmmu/memory.c
> > +++ b/softmmu/memory.c
> > @@ -2626,8 +2626,7 @@ static void
> memory_region_readd_subregion(MemoryRegion *mr)
> >   memory_region_transaction_begin();
> >   memory_region_ref(mr);
> >   memory_region_del_subregion(container, mr);
> > -mr->container = container;
> > -memory_region_update_container_subregions(mr);
> > +memory_region_add_subregion_common(container, mr->addr, mr);
> >   memory_region_unref(mr);
> >   memory_region_transaction_commit();
> >   }
>
> Queued, thanks.
>
> Paolo
>


-- 
Niek Linnenbank


Re: [PATCH v3 2/3] memory: Make memory_region_is_mapped() succeed when mapped via an alias

2022-01-31 Thread Niek Linnenbank
Hi Philippe,

On Mon, Jan 31, 2022 at 12:29 AM Philippe Mathieu-Daudé 
wrote:

> Hi Niek!
>
> (+Mark FYI)
>
> On 30/1/22 23:50, Niek Linnenbank wrote:
> > Hi David,
> >
> > While I realize my response is quite late, I wanted to report this error
> > I found when running the acceptance
> > tests for the orangepi-pc machine using avocado:
>
> Unfortunately I only run the full SD/MMC tests when I send a SD/MMC pull
> request, so missed that here.
>

I understand. These tests are behind the AVOCADO_ALLOW_LARGE_STORAGE flag
in avocado, so I guess they
don't run on gitlab as well, but I'm not sure about that.


>
> > Basically the two tests freeze during the part where the U-Boot
> > bootloader needs to detect the amount of memory. We model this in the
> > hw/misc/allwinner-h3-dramc.c file.
> > And when running the machine manually it shows an assert on
> > 'alias->mapped_via_alias >= 0'. When running manually via gdb, I was
> > able to collect this backtrace:
> >
> > $ gdb ./build/qemu-system-arm
> > ...
> > gdb) run -M orangepi-pc -nographic
> > ./Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img
> > ...
> > U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
> > DRAM:
> > qemu-system-arm: ../softmmu/memory.c:2588: memory_region_del_subregion:
> > Assertion `alias->mapped_via_alias >= 0' failed.
> ...
>
> > So it seems that the hw/misc/allwinner-h3-dramc.c file is using the call
> > memory_region_set_address, where internally we are calling
> > memory_region_del_subregion.
> > The allwinner-h3-dramc.c file does use
> > memory_region_add_subregion_overlap once in the realize function, but
> > might use the memory_region_set_address multiple times.
> > It looks to me this is the path where the assert comes in. If I revert
> > this patch on current master, the machine boots without the assertion.
> >
> > Would you be able to help out how we can best resolve this? Ofcourse, if
> > there is anything needed to be changed on the allwinner-h3-dramc.c file,
> > I would be happy to prepare a patch for that.
>
> David's patch LGTM and I think your model might be somehow abusing the
> memory API, but I'd like to read on the DRAMCOM Control Register to
> understand the allwinner_h3_dramc_map_rows() logic. I couldn't find a
> reference looking at Allwinner_H3_Datasheet_V1.2.pdf.
> I wonder if we could ignore implementing it.
>

Yes David's fix using memory_region_add_subregion_common inside
memory_region_readd_subregion resolves the issue indeed.
Well the allwinner-h3-dramc.c module works OK for now, but it can certainly
use improvements indeed.
And you're right, unfortunately the DRAMCOM device isn't documented in the
datasheet as far as I know.


>
> Your use case is typically what I tried to solve with this model:
>
> https://lore.kernel.org/qemu-devel/20210419094329.1402767-2-f4...@amsat.org/
>
> In your case, @span_size is your amount of DRAM, and @region_size is the
> area u-boot is scanning (and @offset is zero).
> Could that work, or is DRAMCOM doing much more?
>

The current model in allwinner-h3-dramc.c is roughly based on the code that
is present in U-Boot in the file arm/arm/mach-sunxi/dram_sunxi_dw.c.
It implements the low-level initialization of the memory controller, and
when running using Qemu the most important thing it needs to do is
detect the amount of memory. If it cannot accomplish this task, the U-Boot
SPL won't boot properly or crash later. So what we have in
the allwinner-h3-dramc.c implementation comes from the information and code
in the dram_sunxi_dw.c file in U-Boot, not the datasheet.

The proposal you send with span_size/region_size looks interesting indeed.
It would be great if this could help
simplify the code in allwinner-h3-dramc.c. But it would require some effort
to figure out if it can indeed replace the current
behavior.

Kind regards,
Niek


>
> Thanks,
>
> Phil.
>
> P.D. reference to documentation welcome :)
>


-- 
Niek Linnenbank


Re: [PATCH v3 2/3] memory: Make memory_region_is_mapped() succeed when mapped via an alias

2022-01-31 Thread Niek Linnenbank
Hi David,

On Mon, Jan 31, 2022 at 9:11 AM David Hildenbrand  wrote:

> On 30.01.22 23:50, Niek Linnenbank wrote:
> > Hi David,
>
> Hi Niek,
>
> thanks for the report.
>
> >
> > While I realize my response is quite late, I wanted to report this error
> > I found when running the acceptance
> > tests for the orangepi-pc machine using avocado:
> >
> > ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado
> > --show=app,console run -t machine:orangepi-pc
> > tests/avocado/boot_linux_console.py
> > ...
> >  (4/5)
> >
> tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08:
> > -console: U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
> > \console: DRAM:
> > INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
> > reached\nOriginal status: ERROR\n{'name':
> >
> '4-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08',
> > 'logdir': '/home/fox/avocado/job-results/job-2022-01-30T23.09-af49e...
> > (90.64 s)
> >  (5/5)
> >
> tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
> > /console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
> > console: DRAM:
> > INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
> > reached\nOriginal status: ERROR\n{'name':
> >
> '5-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9',
> > 'logdir': '/home/fox/avocado/job-results/job-2022-01-30T23.09-af49...
> > (90.64 s)
> > RESULTS: PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 2 |
> > CANCEL 0
> > JOB TIME   : 221.25 s
> >
> > Basically the two tests freeze during the part where the U-Boot
> > bootloader needs to detect the amount of memory. We model this in the
> > hw/misc/allwinner-h3-dramc.c file.
> > And when running the machine manually it shows an assert on
> > 'alias->mapped_via_alias >= 0'. When running manually via gdb, I was
> > able to collect this backtrace:
> >
> > $ gdb ./build/qemu-system-arm
> > ...
> > gdb) run -M orangepi-pc -nographic
> > ./Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img
> > ...
> > U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
> > DRAM:
> > qemu-system-arm: ../softmmu/memory.c:2588: memory_region_del_subregion:
> > Assertion `alias->mapped_via_alias >= 0' failed.
> >
> > Thread 4 "qemu-system-arm" received signal SIGABRT, Aborted.
> > [Switching to Thread 0x75f72700 (LWP 32866)]
> > __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> > 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
> > (gdb) bt
> > #0  __GI_raise (sig=sig@entry=6) at
> ../sysdeps/unix/sysv/linux/raise.c:50
> > #1  0x77535859 in __GI_abort () at abort.c:79
> > #2  0x77535729 in __assert_fail_base
> > (fmt=0x776cb588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
> > assertion=0x5642fd65 "alias->mapped_via_alias >= 0",
> > file=0x5642f8cd "../softmmu/memory.c", line=2588,
> > function=)
> > at assert.c:92
> > #3  0x77546f36 in __GI___assert_fail
> > (assertion=0x5642fd65 "alias->mapped_via_alias >= 0",
> > file=0x5642f8cd "../softmmu/memory.c", line=2588,
> > function=0x56430690 <__PRETTY_FUNCTION__.8>
> > "memory_region_del_subregion") at assert.c:101
> > #4  0x55e587e0 in memory_region_del_subregion
> > (mr=0x56f0bc00, subregion=0x75fa1090) at ../softmmu/memory.c:2588
> > #5  0x55e589f3 in memory_region_readd_subregion
> > (mr=0x75fa1090) at ../softmmu/memory.c:2630
> > #6  0x55e58a5f in memory_region_set_address (mr=0x75fa1090,
> > addr=1090519040) at ../softmmu/memory.c:2642
> > #7  0x55ac352b in allwinner_h3_dramc_map_rows (s=0x75fa0c50,
> > row_bits=16 '\020', bank_bits=2 '\002', page_size=512) at
> > ../hw/misc/allwinner-h3-dramc.c:92
> > #8  0x55ac36c2 in allwinner_h3_dramcom_write
> > (opaque=0x75fa0c50, offset=0, val=4396785, size=4) at
> > ../hw/misc/allwinner-h3-dramc.c:131
> > #9  0x55e52561 in memory_region_write_accessor
> > (mr=0x75fa11a0, addr=0, value=0x75f710e8, size=4, shift=0,
> > mask=4294967295, attrs=...) at ../softmmu/memory.c:492
> > #10 0x55e527ad in access_with_adjusted_size (addr=0,
> > value=0x75f710e8, size=4, access_size_min=4, access_size_max=4,
>

Re: [PATCH v3 2/3] memory: Make memory_region_is_mapped() succeed when mapped via an alias

2022-01-30 Thread Niek Linnenbank
7182c) at ../accel/tcg/cpu-exec.c:357
#18 0x55f76366 in cpu_loop_exec_tb (cpu=0x75f730a0,
tb=0x7fffa802b400, last_tb=0x75f71840, tb_exit=0x75f7182c) at
../accel/tcg/cpu-exec.c:842
#19 0x55f76720 in cpu_exec (cpu=0x75f730a0) at
../accel/tcg/cpu-exec.c:1001
#20 0x55f993dd in tcg_cpus_exec (cpu=0x75f730a0) at
../accel/tcg/tcg-accel-ops.c:67
#21 0x55f9976d in mttcg_cpu_thread_fn (arg=0x75f730a0) at
../accel/tcg/tcg-accel-ops-mttcg.c:95
#22 0x5624bf4d in qemu_thread_start (args=0x572b6780) at
../util/qemu-thread-posix.c:556
#23 0x7770b609 in start_thread (arg=) at
pthread_create.c:477
#24 0x77632293 in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:95

So it seems that the hw/misc/allwinner-h3-dramc.c file is using the call
memory_region_set_address, where internally we are calling
memory_region_del_subregion.
The allwinner-h3-dramc.c file does use memory_region_add_subregion_overlap
once in the realize function, but might use the memory_region_set_address
multiple times.
It looks to me this is the path where the assert comes in. If I revert this
patch on current master, the machine boots without the assertion.

Would you be able to help out how we can best resolve this? Ofcourse, if
there is anything needed to be changed on the allwinner-h3-dramc.c file, I
would be happy to prepare a patch for that.

Kind regards,
Niek Linnenbank

On Tue, Nov 2, 2021 at 5:46 PM David Hildenbrand  wrote:

> memory_region_is_mapped() currently does not return "true" when a memory
> region is mapped via an alias.
>
> Assuming we have:
> alias (A0) -> alias (A1) -> region (R0)
> Mapping A0 would currently only make memory_region_is_mapped() succeed
> on A0, but not on A1 and R0.
>
> Let's fix that by adding a "mapped_via_alias" counter to memory regions and
> updating it accordingly when an alias gets (un)mapped.
>
> I am not aware of actual issues, this is rather a cleanup to make it
> consistent.
>
> Reviewed-by: Philippe Mathieu-Daudé 
> Reviewed-by: Peter Xu 
> Signed-off-by: David Hildenbrand 
> ---
>  include/exec/memory.h |  1 +
>  softmmu/memory.c  | 13 -
>  2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index 20f1b27377..fea1a493b9 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -738,6 +738,7 @@ struct MemoryRegion {
>  const MemoryRegionOps *ops;
>  void *opaque;
>  MemoryRegion *container;
> +int mapped_via_alias; /* Mapped via an alias, container might be NULL
> */
>  Int128 size;
>  hwaddr addr;
>  void (*destructor)(MemoryRegion *mr);
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index 7340e19ff5..b52b6a2f66 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -2535,8 +2535,13 @@ static void
> memory_region_add_subregion_common(MemoryRegion *mr,
> hwaddr offset,
> MemoryRegion *subregion)
>  {
> +MemoryRegion *alias;
> +
>  assert(!subregion->container);
>  subregion->container = mr;
> +for (alias = subregion->alias; alias; alias = alias->alias) {
> +alias->mapped_via_alias++;
> +}
>  subregion->addr = offset;
>  memory_region_update_container_subregions(subregion);
>  }
> @@ -2561,9 +2566,15 @@ void
> memory_region_add_subregion_overlap(MemoryRegion *mr,
>  void memory_region_del_subregion(MemoryRegion *mr,
>   MemoryRegion *subregion)
>  {
> +MemoryRegion *alias;
> +
>  memory_region_transaction_begin();
>  assert(subregion->container == mr);
>  subregion->container = NULL;
> +for (alias = subregion->alias; alias; alias = alias->alias) {
> +alias->mapped_via_alias--;
> +assert(alias->mapped_via_alias >= 0);
> +}
>  QTAILQ_REMOVE(>subregions, subregion, subregions_link);
>  memory_region_unref(subregion);
>  memory_region_update_pending |= mr->enabled && subregion->enabled;
> @@ -2660,7 +2671,7 @@ static FlatRange *flatview_lookup(FlatView *view,
> AddrRange addr)
>
>  bool memory_region_is_mapped(MemoryRegion *mr)
>  {
> -return mr->container ? true : false;
> +return !!mr->container || mr->mapped_via_alias;
>  }
>
>  /* Same as memory_region_find, but it does not add a reference to the
> --
> 2.31.1
>
>
>

-- 
Niek Linnenbank


Re: [PATCH 05/16] hw/arm: allwinner: Don't enable PSCI conduit when booting guest in EL3

2022-01-30 Thread Niek Linnenbank
Hi Peter,



On Thu, Jan 27, 2022 at 4:46 PM Peter Maydell 
wrote:

> Change the allwinner-h3 based board to use the new boot.c
> functionality to allow us to enable psci-conduit only if the guest is
> being booted in EL1 or EL2, so that if the user runs guest EL3
> firmware code our PSCI emulation doesn't get in its way.
>
> To do this we stop setting the psci-conduit property on the CPU
> objects in the SoC code, and instead set the psci_conduit field in
> the arm_boot_info struct to tell the common boot loader code that
> we'd like PSCI if the guest is starting at an EL that it makes sense
> with.
>
> This affects the orangepi-pc board.
>
> This commit leaves the secondary CPUs in the powered-down state if
> the guest is booting at EL3, which is the same behaviour as before
> this commit.  The secondaries can no longer be started by that EL3
> code making a PSCI call but can still be started via the CPU
> Configuration Module registers (which we model in
> hw/misc/allwinner-cpucfg.c).
>
> Signed-off-by: Peter Maydell 
>

While testing your patches on the orangepi-pc machine, I've found that two
acceptance tests BootLinuxConsole.test_arm_orangepi_bionic_20_08 and
BootLinuxConsole.test_arm_orangepi_uboot_netbsd9 of the orangepi-pc board
are no longer passing on current master:

  ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado
--show=app,console run -t machine:orangepi-pc
tests/avocado/boot_linux_console.py
  ...
 (4/5)
tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08:
-console: U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
\console: DRAM:
INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
reached\nOriginal status: ERROR\n{'name':
'4-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08',
'logdi>
 (5/5)
tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
/console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
console: DRAM:
INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
reached\nOriginal status: ERROR\n{'name':
'5-tests/avocado/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9',
'logd>
RESULTS: PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 2 |
CANCEL 0
JOB TIME   : 221.25 s

Bisecting the error I was able to trace it back to commit 5ead62185d
("memory: Make memory_region_is_mapped() succeed when mapped via an alias").
I'll try to find the original thread and respond to that with this
information.

However, with commit 5ead62185d reverted, all tested passed fine:

ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado
--show=app,console run -t machine:orangepi-pc
tests/avocado/boot_linux_console.py
...
PASS (16.48 s)
RESULTS: PASS 5 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 116.63 s

So for the orangepi-pc and allwinner-h3:

Reviewed-by: Niek Linnenbank 
Tested-by: Niek Linnenbank 


> ---
> If anybody knows for definite that the secondaries should be
> powered-down at startup for guest firmware, we can delete the TODO.
>

Looking at the Allwinner H3 datasheet in 4.4.3.7 page 146, it says that
for the CPU1 Status Register the default value indicates at least that its
not in a
wait for interrupt standby mode. And if I look in U-Boot's
arm/arm/cpu/armv7/sunxi/psci.c code
in the psci_cpu_on implementation, there is an explicit 'power on' part
there, suggesting the secondary CPUs
are by default off. So while I don't have any hard proof, these findings
suggest we are modeling the correct behavior
with secondary CPUs by default off.



> The allwinner-cpucfg.c code makes the reset value for the
> REG_CPU*_RST_CTRL registers "CPUX_RESET_RELEASED", which might
> suggest otherwise, but that could easily just be a QEMU error.
> ---
>  hw/arm/allwinner-h3.c | 9 -
>  hw/arm/orangepi.c | 1 +
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index f9b7ed18711..f54aff6d2d2 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -235,11 +235,10 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>  /* CPUs */
>  for (i = 0; i < AW_H3_NUM_CPUS; i++) {
>
> -/* Provide Power State Coordination Interface */
> -qdev_prop_set_int32(DEVICE(>cpus[i]), "psci-conduit",
> -QEMU_PSCI_CONDUIT_SMC);
> -
> -/* Disable secondary CPUs */
> +/*
> + * Disable secondary CPUs. TODO: check whether this is what
> + * guest EL3 firmware would really expect.
> + */
>  qdev_prop_set_bit(DEVICE(>cpus[i]), "start-powered-off",
>  

Re: [PATCH 0/1] tests/acceptance: rename tests acceptance to tests avocado

2021-11-03 Thread Niek Linnenbank
Hi Willian,

For the Orange Pi PC documentation:

Reviewed-by: Niek Linnenbank 


Op wo 3 nov. 2021 22:14 schreef Willian Rampazzo :

> In the discussion about renaming the `tests/acceptance` [1], the
> conclusion was that the folders inside `tests` are related to the
> framework running the tests and not directly related to the type of
> the tests.
>
> This changes the folder to `tests/avocado` and adjusts the MAKEFILE, the
> CI related files and the documentation.
>
> [1] https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg06553.html
>
> GitLab pipeline with new naming:
> https://gitlab.com/willianrampazzo/qemu/-/pipelines/401431592
> Signed-off-by: Willian Rampazzo 
>
> Willian Rampazzo (1):
>   tests/acceptance: rename tests acceptance to tests avocado
>
>  .gitlab-ci.d/buildtest-template.yml   |  2 +-
>  .gitlab-ci.d/buildtest.yml| 56 +--
>  MAINTAINERS   | 52 -
>  configure |  2 +-
>  docs/devel/build-system.rst   |  2 +-
>  docs/devel/ci-definitions.rst.inc |  2 +-
>  docs/devel/testing.rst| 49 
>  docs/system/arm/orangepi.rst  |  8 +--
>  python/qemu/machine/README.rst|  2 +-
>  python/qemu/qmp/README.rst|  2 +-
>  python/qemu/utils/README.rst  |  2 +-
>  tests/Makefile.include| 14 ++---
>  tests/acceptance/README.rst   | 10 
>  tests/avocado/README.rst  | 10 
>  .../avocado_qemu/__init__.py  |  2 +-
>  tests/{acceptance => avocado}/boot_linux.py   |  0
>  .../boot_linux_console.py |  0
>  tests/{acceptance => avocado}/boot_xen.py |  0
>  tests/{acceptance => avocado}/cpu_queries.py  |  0
>  .../empty_cpu_model.py|  0
>  tests/{acceptance => avocado}/hotplug_cpu.py  |  0
>  tests/{acceptance => avocado}/info_usernet.py |  0
>  tests/{acceptance => avocado}/intel_iommu.py  |  0
>  tests/{acceptance => avocado}/linux_initrd.py |  2 +-
>  .../linux_ssh_mips_malta.py   |  0
>  .../machine_arm_canona1100.py |  0
>  .../machine_arm_integratorcp.py   |  0
>  .../machine_arm_n8x0.py   |  0
>  tests/{acceptance => avocado}/machine_avr6.py |  2 +-
>  .../machine_m68k_nextcube.py  |  0
>  .../machine_microblaze.py |  0
>  .../machine_mips_fuloong2e.py |  0
>  .../machine_mips_loongson3v.py|  0
>  .../machine_mips_malta.py |  0
>  .../machine_rx_gdbsim.py  |  0
>  .../machine_s390_ccw_virtio.py|  0
>  .../machine_sparc64_sun4u.py  |  0
>  .../machine_sparc_leon3.py|  0
>  tests/{acceptance => avocado}/migration.py|  0
>  tests/{acceptance => avocado}/multiprocess.py |  0
>  .../pc_cpu_hotplug_props.py   |  0
>  tests/{acceptance => avocado}/ppc_405.py  |  0
>  tests/{acceptance => avocado}/ppc_bamboo.py   |  0
>  .../{acceptance => avocado}/ppc_mpc8544ds.py  |  0
>  tests/{acceptance => avocado}/ppc_prep_40p.py | 12 ++--
>  tests/{acceptance => avocado}/ppc_pseries.py  |  0
>  .../ppc_virtex_ml507.py   |  0
>  .../{acceptance => avocado}/replay_kernel.py  |  0
>  tests/{acceptance => avocado}/replay_linux.py |  0
>  .../reverse_debugging.py  |  0
>  tests/{acceptance => avocado}/smmu.py |  0
>  tests/{acceptance => avocado}/tcg_plugins.py  |  0
>  .../tesseract_utils.py|  0
>  tests/{acceptance => avocado}/version.py  |  0
>  tests/{acceptance => avocado}/virtio-gpu.py   |  0
>  .../virtio_check_params.py|  0
>  .../{acceptance => avocado}/virtio_version.py |  0
>  .../virtiofs_submounts.py |  0
>  .../virtiofs_submounts.py.data/cleanup.sh |  0
>  .../guest-cleanup.sh  |  0
>  .../virtiofs_submounts.py.data/guest.sh   |  0
>  .../virtiofs_submounts.py.data/host.sh|  0
>  tests/{acceptance => avocado}/vnc.py  |  0
>  .../x86_cpu_model_versions.py |  0
>  64 files changed, 113 insertions(+), 118 deletions(-)
>  delete mode 100644 tests/acceptance/README.rst
>  create mode 100644 tests/avocado/README.rst
>  rename tests/{acceptance => avocado}/avocado_qemu/__init__.py (99%)
>  rename tests/{acceptance => avocado}/boot_linux.py (100%)
>  rename tests/{acc

Re: [PATCH] allwinner-h3: Switch to SMC as PSCI conduit

2021-09-22 Thread Niek Linnenbank
Hi Alexander,

I've tested your patch on the acceptance tests and they all pass:

ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado
--show=app,console run -t machine:orangepi-pc
tests/acceptance/boot_linux_console.py
...
RESULTS: PASS 5 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 116.08 s

Also the latest linux kernel is working OK with all cores booting up fine.

At first I couldn't really figure out why simply changing the conduit there
works, without also changing the Linux kernel to match.
But it turns out we just override the provided DTB for this in
fdt_add_psci_node() in hw/arm/boot.c and the Linux kernel then uses that to
decide between HVC and SMC.

So looks fine to me:
  Reviewed-by: Niek Linnenbank 
  Tested-by: Niek Linnenbank 

Regards,
Niek

On Mon, Sep 20, 2021 at 10:39 PM Alexander Graf  wrote:

> The Allwinner H3 SoC uses Cortex-A7 cores which support virtualization.
> However, today we are configuring QEMU to use HVC as PSCI conduit.
>
> That means HVC calls get trapped into QEMU instead of the guest's own
> emulated CPU and thus break the guest's ability to execute virtualization.
>
> Fix this by moving to SMC as conduit, freeing up HYP completely to the VM.
>
> Signed-off-by: Alexander Graf 
> Fixes: 740dafc0ba0 ("hw/arm: add Allwinner H3 System-on-Chip")
> ---
>  hw/arm/allwinner-h3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 27f1070145..f9b7ed1871 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -237,7 +237,7 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>
>  /* Provide Power State Coordination Interface */
>  qdev_prop_set_int32(DEVICE(>cpus[i]), "psci-conduit",
> -QEMU_PSCI_CONDUIT_HVC);
> +QEMU_PSCI_CONDUIT_SMC);
>
>  /* Disable secondary CPUs */
>      qdev_prop_set_bit(DEVICE(>cpus[i]), "start-powered-off",
> --
> 2.30.1 (Apple Git-130)
>
>

-- 
Niek Linnenbank


Re: [RFC PATCH 6/9] tests/acceptance: Use image_expand() in test_arm_orangepi_bionic_20_08

2021-08-05 Thread Niek Linnenbank
Hi Philippe,

Op wo 23 jun. 2021 20:00 schreef Philippe Mathieu-Daudé :

> U-Boot expects the SD card size to be at least 2GiB, so
> expand the SD card image to this size before using it.
>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> TODO: U-Boot reference?
> ---
>  tests/acceptance/boot_linux_console.py | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/tests/acceptance/boot_linux_console.py
> b/tests/acceptance/boot_linux_console.py
> index b10f7257503..c4c0f0b393d 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -820,11 +820,13 @@ def test_arm_orangepi_bionic_20_08(self):
>  :avocado: tags=arch:arm
>  :avocado: tags=machine:orangepi-pc
>  :avocado: tags=device:sd
> +:avocado: tags=u-boot
>  """
>
> -# This test download a 275 MiB compressed image and expand it
> -# to 1036 MiB, but the underlying filesystem is 1552 MiB...
> -# As we expand it to 2 GiB we are safe.
> +# This test download a 275 MiB compressed image and inflate it
>

Only a few typos here:
  download -> downloads
  inflate -> inflates

Otherwise, looks fine:

Reviewed-by: Niek Linnenbank 

+# to 1036 MiB, but 1/ the underlying filesystem is 1552 MiB,
> +# 2/ U-Boot loads TFTP filenames from the last sector below
> +# 2 GiB, so we need to expand the image further more to 2 GiB.
>
>  image_url = ('https://archive.armbian.com/orangepipc/archive/'
>
> 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
> @@ -833,7 +835,7 @@ def test_arm_orangepi_bionic_20_08(self):
>  image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
>   algorithm='sha256')
>  image_path = archive.extract(image_path_xz, self.workdir)
> -image_pow2ceil_expand(image_path)
> +image_expand(image_path, 2 * 1024 * 1024 * 1024)
>
>  self.vm.set_console()
>  self.vm.add_args('-drive', 'file=' + image_path +
> ',if=sd,format=raw',
> --
> 2.31.1
>
>


Re: [PATCH 5/9] tests/acceptance: Use image_expand() in test_arm_orangepi_uboot_netbsd9

2021-08-05 Thread Niek Linnenbank
Hi Philippe,

Op wo 4 aug. 2021 22:55 schreef Philippe Mathieu-Daudé :

> Hi Niek,
>
> On 6/23/21 8:00 PM, Philippe Mathieu-Daudé wrote:
> > The NetBSD OrangePi image must be at least 2GiB, not less.
> > Expand the SD card image to this size before using it.
> >
> > Signed-off-by: Philippe Mathieu-Daudé 
> > ---
> >  tests/acceptance/boot_linux_console.py | 9 +++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/tests/acceptance/boot_linux_console.py
> b/tests/acceptance/boot_linux_console.py
> > index 61069f0064f..b10f7257503 100644
> > --- a/tests/acceptance/boot_linux_console.py
> > +++ b/tests/acceptance/boot_linux_console.py
> > @@ -868,7 +868,12 @@ def test_arm_orangepi_uboot_netbsd9(self):
> >  :avocado: tags=device:sd
> >  :avocado: tags=os:netbsd
> >  """
> > -# This test download a 304MB compressed image and expand it to
> 2GB
> > +# This test download a 304MB compressed image and expand it to
> 2GB,
> > +# which is the minimum card size required by the NetBSD
> installer:
> > +# https://wiki.netbsd.org/ports/evbarm/raspberry_pi/#index7h2
> > +# "A 2 GB card is the smallest workable size that the
> installation
> > +# image will fit on."
>
> Do you agree with this comment and the one in the next patch?
>

Yes, this change looks fine for me.

Reviewed-by: Niek Linnenbank 


> > +NETBSD_SDCARD_MINSIZE = 2 * 1024 * 1024 * 1024
> >  deb_url = ('http://snapshot.debian.org/archive/debian/'
> > '20200108T145233Z/pool/main/u/u-boot/'
> > 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
> > @@ -886,7 +891,7 @@ def test_arm_orangepi_uboot_netbsd9(self):
> >  image_path_gz = self.fetch_asset(image_url,
> asset_hash=image_hash)
> >  image_path = os.path.join(self.workdir, 'armv7.img')
> >  archive.gzip_uncompress(image_path_gz, image_path)
> > -image_pow2ceil_expand(image_path)
> > +image_expand(image_path, NETBSD_SDCARD_MINSIZE)
> >  image_drive_args = 'if=sd,format=raw,snapshot=on,file=' +
> image_path
> >
> >  # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8
> conv=notrunc
> >
>
>


Re: [PATCH 3/9] tests/acceptance: Tag NetBSD tests as 'os:netbsd'

2021-07-04 Thread Niek Linnenbank
for test_arm_orangepi_uboot_netbsd9:

Reviewed-by: Niek Linnenbank 

Op za 3 jul. 2021 10:44 schreef Philippe Mathieu-Daudé :

> On Sat, Jul 3, 2021 at 10:41 AM Philippe Mathieu-Daudé 
> wrote:
> >
> > CC'ing NetBSD maintainers.
> >
> > On 6/23/21 8:00 PM, Philippe Mathieu-Daudé wrote:
> > > Avocado allows us to select set of tests using tags.
> > > When wanting to run all tests using a NetBSD guest OS,
> > > it is convenient to have them tagged, add the 'os:netbsd'
> > > tag.
>
> I'll amend an command line example to run the NetBSD tests:
>
>$ avocado --show=app,console run -t os:netbsd tests/acceptance/
>
> > > Signed-off-by: Philippe Mathieu-Daudé 
> > > ---
> > >  tests/acceptance/boot_linux_console.py | 1 +
> > >  tests/acceptance/ppc_prep_40p.py   | 2 ++
> > >  2 files changed, 3 insertions(+)
> > >
> > > diff --git a/tests/acceptance/boot_linux_console.py
> b/tests/acceptance/boot_linux_console.py
> > > index cded547d1d4..20d57c1a8c6 100644
> > > --- a/tests/acceptance/boot_linux_console.py
> > > +++ b/tests/acceptance/boot_linux_console.py
> > > @@ -862,6 +862,7 @@ def test_arm_orangepi_uboot_netbsd9(self):
> > >  :avocado: tags=arch:arm
> > >  :avocado: tags=machine:orangepi-pc
> > >  :avocado: tags=device:sd
> > > +:avocado: tags=os:netbsd
> > >  """
> > >  # This test download a 304MB compressed image and expand it
> to 2GB
> > >  deb_url = ('http://snapshot.debian.org/archive/debian/'
> > > diff --git a/tests/acceptance/ppc_prep_40p.py
> b/tests/acceptance/ppc_prep_40p.py
> > > index 96ba13b8943..2993ee3b078 100644
> > > --- a/tests/acceptance/ppc_prep_40p.py
> > > +++ b/tests/acceptance/ppc_prep_40p.py
> > > @@ -27,6 +27,7 @@ def test_factory_firmware_and_netbsd(self):
> > >  """
> > >  :avocado: tags=arch:ppc
> > >  :avocado: tags=machine:40p
> > > +:avocado: tags=os:netbsd
> > >  :avocado: tags=slowness:high
> > >  """
> > >  bios_url = ('http://ftpmirror.your.org/pub/misc/'
> > > @@ -64,6 +65,7 @@ def test_openbios_and_netbsd(self):
> > >  """
> > >  :avocado: tags=arch:ppc
> > >  :avocado: tags=machine:40p
> > > +:avocado: tags=os:netbsd
> > >  """
> > >  drive_url = ('https://cdn.netbsd.org/pub/NetBSD/iso/7.1.2/'
> > >   'NetBSD-7.1.2-prep.iso')
> > >
> >
>


[PATCH v4 4/5] tests/acceptance: update sunxi kernel from armbian to 5.10.16

2021-03-10 Thread Niek Linnenbank
The linux kernel 4.20.7 binary for sunxi has been removed from apt.armbian.com:

  $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado 
--show=app,console run -t machine:orangepi-pc 
tests/acceptance/boot_linux_console.py
  Fetching asset from 
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi
  ...
  (1/6) 
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
CANCEL: Missing asset 
https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb
 (0.55 s)

This commit updates the sunxi kernel to 5.10.16 for the acceptance
tests of the orangepi-pc and cubieboard machines.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Willian Rampazzo 
---
 tests/acceptance/boot_linux_console.py | 40 +-
 tests/acceptance/replay_kernel.py  |  8 +++---
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 4a7a6830ca..04a8b23352 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -515,12 +515,12 @@ def test_arm_cubieboard_initrd(self):
 :avocado: tags=machine:cubieboard
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
-dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+'/boot/vmlinuz-5.10.16-sunxi')
+dtb_path = 
'/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
   '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
@@ -557,12 +557,12 @@ def test_arm_cubieboard_sata(self):
 :avocado: tags=machine:cubieboard
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
-dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+'/boot/vmlinuz-5.10.16-sunxi')
+dtb_path = 
'/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
   '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
@@ -686,12 +686,12 @@ def test_arm_orangepi(self):
 :avocado: tags=machine:orangepi-pc
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
-dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
+'/boot/vmlinuz-5.10.16-sunxi')
+dtb_path = 
'/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 
 self.vm.set_console()
@@ -713,12 +713,12 @@ def test_arm_orangepi_initrd(self):
 :avocado: tags=machine:orangepi-pc
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,

[PATCH v4 5/5] tests/acceptance: drop ARMBIAN_ARTIFACTS_CACHED condition for orangepi-pc, cubieboard tests

2021-03-10 Thread Niek Linnenbank
Previously the ARMBIAN_ARTIFACTS_CACHED pre-condition was added to allow running
tests that have already existing armbian.com artifacts stored in the local 
avocado cache,
but do not have working URLs to download a fresh copy.

At this time of writing the URLs for artifacts on the armbian.com server are 
updated and working.
Any future broken URLs will result in a skipped acceptance test, for example:

 (1/5) 
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
  CANCEL: Missing asset 
https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb
 (0.53 s)

This commits removes the ARMBIAN_ARTIFACTS_CACHED pre-condition such that
the acceptance tests for the orangepi-pc and cubieboard machines can run.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Willian Rampazzo 
---
 tests/acceptance/boot_linux_console.py | 12 
 tests/acceptance/replay_kernel.py  |  2 --
 2 files changed, 14 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 04a8b23352..1ca32ecf25 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -507,8 +507,6 @@ def test_arm_exynos4210_initrd(self):
 self.wait_for_console_pattern('Boot successful.')
 # TODO user command, for now the uart is stuck
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_initrd(self):
 """
 :avocado: tags=arch:arm
@@ -549,8 +547,6 @@ def test_arm_cubieboard_initrd(self):
 'system-control@1c0')
 # cubieboard's reboot is not functioning; omit reboot test.
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_sata(self):
 """
 :avocado: tags=arch:arm
@@ -678,8 +674,6 @@ def test_arm_quanta_gsj_initrd(self):
 self.wait_for_console_pattern(
 'Give root password for system maintenance')
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi(self):
 """
 :avocado: tags=arch:arm
@@ -705,8 +699,6 @@ def test_arm_orangepi(self):
 console_pattern = 'Kernel command line: %s' % kernel_command_line
 self.wait_for_console_pattern(console_pattern)
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi_initrd(self):
 """
 :avocado: tags=arch:arm
@@ -749,8 +741,6 @@ def test_arm_orangepi_initrd(self):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi_sd(self):
 """
 :avocado: tags=arch:arm
@@ -802,8 +792,6 @@ def test_arm_orangepi_sd(self):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
 def test_arm_orangepi_bionic_20_08(self):
 """
diff --git a/tests/acceptance/replay_kernel.py 
b/tests/acceptance/replay_kernel.py
index 8c68caae31..71facdaa75 100644
--- a/tests/acceptance/replay_kernel.py
+++ b/tests/acceptance/replay_kernel.py
@@ -177,8 +177,6 @@ def test_arm_virt(self):
 self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1)
 
 @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_initrd(self):
 """
 :avocado: tags=arch:arm
-- 
2.25.1




[PATCH v4 1/5] hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value

2021-03-10 Thread Niek Linnenbank
Currently the emulated EMAC for sun8i always traverses the transmit queue
from the head when transferring packets. It searches for a list of consecutive
descriptors whichs are flagged as ready for processing and transmits their 
payloads
accordingly. The controller stops processing once it finds a descriptor that is 
not
marked ready.

While the above behaviour works in most situations, it is not the same as the 
actual
EMAC in hardware. Actual hardware uses the TX_CUR_DESC register value to keep 
track
of the last position in the transmit queue and continues processing from that 
position
when software triggers the start of DMA processing. The currently emulated 
behaviour can
lead to packet loss on transmit when software fills the transmit queue with 
ready
descriptors that overlap the tail of the circular list.

This commit modifies the emulated EMAC for sun8i such that it processes
the transmit queue using the TX_CUR_DESC register in the same way as hardware.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Philippe Mathieu-Daudé 
---
 hw/net/allwinner-sun8i-emac.c | 58 +++
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index 042768922c..e586c147e5 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -339,35 +339,40 @@ static void 
allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
 qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
 }
 
-static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
-   FrameDescriptor *desc,
-   size_t min_size)
+static bool allwinner_sun8i_emac_desc_owned(FrameDescriptor *desc,
+size_t min_buf_size)
 {
-uint32_t paddr = desc->next;
+return (desc->status & DESC_STATUS_CTL) && (min_buf_size == 0 ||
+   (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_buf_size);
+}
 
-dma_memory_read(>dma_as, paddr, desc, sizeof(*desc));
+static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
+  FrameDescriptor *desc,
+  uint32_t phys_addr)
+{
+dma_memory_read(>dma_as, phys_addr, desc, sizeof(*desc));
+}
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
-return paddr;
-} else {
-return 0;
-}
+static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc)
+{
+const uint32_t nxt = desc->next;
+allwinner_sun8i_emac_get_desc(s, desc, nxt);
+return nxt;
 }
 
-static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
-  FrameDescriptor *desc,
-  uint32_t start_addr,
-  size_t min_size)
+static uint32_t allwinner_sun8i_emac_find_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc,
+   uint32_t start_addr,
+   size_t min_size)
 {
 uint32_t desc_addr = start_addr;
 
 /* Note that the list is a cycle. Last entry points back to the head. */
 while (desc_addr != 0) {
-dma_memory_read(>dma_as, desc_addr, desc, sizeof(*desc));
+allwinner_sun8i_emac_get_desc(s, desc, desc_addr);
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
+if (allwinner_sun8i_emac_desc_owned(desc, min_size)) {
 return desc_addr;
 } else if (desc->next == start_addr) {
 break;
@@ -383,14 +388,14 @@ static uint32_t 
allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s,
  FrameDescriptor *desc,
  size_t min_size)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size);
+return allwinner_sun8i_emac_find_desc(s, desc, s->rx_desc_curr, min_size);
 }
 
 static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
- FrameDescriptor *desc,
- size_t min_size)
+ FrameDescriptor *desc)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size);
+allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_curr);
+return s->tx_desc_curr;
 }
 
 static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
@@ -470,7 +475,8 @@ static ssize_t allwinner_sun8i_emac_receive(NetC

[PATCH v4 2/5] tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic test for orangepi-pc machine

2021-03-10 Thread Niek Linnenbank
The image for Armbian 19.11.3 bionic has been removed from the armbian server.
Without the image as input the test arm_orangepi_bionic_19_11 cannot run.

This commit removes the test completely and merges the code of the generic 
function
do_test_arm_orangepi_uboot_armbian back with the 20.08 test.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Willian Rampazzo 
---
 tests/acceptance/boot_linux_console.py | 72 --
 1 file changed, 23 insertions(+), 49 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index eb01286799..9fadea9958 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -802,7 +802,29 @@ def test_arm_orangepi_sd(self):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-def do_test_arm_orangepi_uboot_armbian(self, image_path):
+@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
+'Test artifacts fetched from unreliable apt.armbian.com')
+@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
+def test_arm_orangepi_bionic_20_08(self):
+"""
+:avocado: tags=arch:arm
+:avocado: tags=machine:orangepi-pc
+:avocado: tags=device:sd
+"""
+
+# This test download a 275 MiB compressed image and expand it
+# to 1036 MiB, but the underlying filesystem is 1552 MiB...
+# As we expand it to 2 GiB we are safe.
+
+image_url = ('https://dl.armbian.com/orangepipc/archive/'
+ 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
+image_hash = ('b4d6775f5673486329e45a0586bf06b6'
+  'dbe792199fd182ac6b9c7bb6c7d3e6dd')
+image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
+ algorithm='sha256')
+image_path = archive.extract(image_path_xz, self.workdir)
+image_pow2ceil_expand(image_path)
+
 self.vm.set_console()
 self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
  '-nic', 'user',
@@ -828,54 +850,6 @@ def do_test_arm_orangepi_uboot_armbian(self, image_path):
   'to ')
 self.wait_for_console_pattern('Starting Load Kernel Modules...')
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
-@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
-@skipUnless(P7ZIP_AVAILABLE, '7z not installed')
-def test_arm_orangepi_bionic_19_11(self):
-"""
-:avocado: tags=arch:arm
-:avocado: tags=machine:orangepi-pc
-:avocado: tags=device:sd
-"""
-
-# This test download a 196MB compressed image and expand it to 1GB
-image_url = ('https://dl.armbian.com/orangepipc/archive/'
- 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
-image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e'
-image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash)
-image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
-image_path = os.path.join(self.workdir, image_name)
-process.run("7z e -o%s %s" % (self.workdir, image_path_7z))
-image_pow2ceil_expand(image_path)
-
-self.do_test_arm_orangepi_uboot_armbian(image_path)
-
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
-@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
-def test_arm_orangepi_bionic_20_08(self):
-"""
-:avocado: tags=arch:arm
-:avocado: tags=machine:orangepi-pc
-:avocado: tags=device:sd
-"""
-
-# This test download a 275 MiB compressed image and expand it
-# to 1036 MiB, but the underlying filesystem is 1552 MiB...
-# As we expand it to 2 GiB we are safe.
-
-image_url = ('https://dl.armbian.com/orangepipc/archive/'
- 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
-image_hash = ('b4d6775f5673486329e45a0586bf06b6'
-  'dbe792199fd182ac6b9c7bb6c7d3e6dd')
-image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
- algorithm='sha256')
-image_path = archive.extract(image_path_xz, self.workdir)
-image_pow2ceil_expand(image_path)
-
-self.do_test_arm_orangepi_uboot_armbian(image_path)
-
 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
 def test_arm_orangepi_uboot_netbsd9(self):
 """
-- 
2.25.1




[PATCH v4 3/5] tests/acceptance/boot_linux_console: change URL for test_arm_orangepi_bionic_20_08

2021-03-10 Thread Niek Linnenbank
Update the download URL of the Armbian 20.08 Bionic image for
test_arm_orangepi_bionic_20_08 of the orangepi-pc machine.

The archive.armbian.com URL contains more images and should keep stable
for a longer period of time than dl.armbian.com.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Philippe Mathieu-Daudé 
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Willian Rampazzo 
---
 tests/acceptance/boot_linux_console.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 9fadea9958..4a7a6830ca 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -816,7 +816,7 @@ def test_arm_orangepi_bionic_20_08(self):
 # to 1036 MiB, but the underlying filesystem is 1552 MiB...
 # As we expand it to 2 GiB we are safe.
 
-image_url = ('https://dl.armbian.com/orangepipc/archive/'
+image_url = ('https://archive.armbian.com/orangepipc/archive/'
  'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
 image_hash = ('b4d6775f5673486329e45a0586bf06b6'
   'dbe792199fd182ac6b9c7bb6c7d3e6dd')
-- 
2.25.1




[PATCH v4 0/5] Allwinner H3 fixes for EMAC and acceptance tests

2021-03-10 Thread Niek Linnenbank
The following are maintenance patches for the Allwinner H3. The first patch
resolves artifact download errors by updating the URLs to the armbian.com 
server.

The second patch is a fix for the EMAC that is used by the Allwinner H3 / 
Orange Pi PC machine.

All these patches have been reviewed and tested and should be ready to pull in.

ChangeLog:

v4:
 - added Reviewed-By/Tested-By tags

v3:
 - fixed the acceptance tests by using up-to-date armbian.com URLs

v2:
 - added Reviewed-By tags
 - changed URL for artifacts to github.com/nieklinnenbank/QemuArtifacts

Kind regards,

Niek

Niek Linnenbank (5):
  hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC
register value
  tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic
test for orangepi-pc machine
  tests/acceptance/boot_linux_console: change URL for
test_arm_orangepi_bionic_20_08
  tests/acceptance: update sunxi kernel from armbian to 5.10.16
  tests/acceptance: drop ARMBIAN_ARTIFACTS_CACHED condition for
orangepi-pc, cubieboard tests

 hw/net/allwinner-sun8i-emac.c  |  58 ++--
 tests/acceptance/boot_linux_console.py | 120 +
 tests/acceptance/replay_kernel.py  |  10 +--
 3 files changed, 77 insertions(+), 111 deletions(-)

-- 
2.25.1




Re: [PATCH v3 2/5] tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic test for orangepi-pc machine

2021-03-08 Thread Niek Linnenbank
Hi Philippe, Willian,

On Mon, Mar 8, 2021 at 8:52 AM Philippe Mathieu-Daudé 
wrote:

> On 3/5/21 4:16 PM, Willian Rampazzo wrote:
> > On Thu, Mar 4, 2021 at 5:44 PM Niek Linnenbank 
> wrote:
> >>
> >> The image for Armbian 19.11.3 bionic has been removed from the armbian
> server.
> >> Without the image as input the test arm_orangepi_bionic_19_11 cannot
> run.
> >>
> >> This commit removes the test completely and merges the code of the
> generic function
> >> do_test_arm_orangepi_uboot_armbian back with the 20.08 test.
> >>
> >> Signed-off-by: Niek Linnenbank 
> >> ---
> >>  tests/acceptance/boot_linux_console.py | 72 --
> >>  1 file changed, 23 insertions(+), 49 deletions(-)
> >>
> >> diff --git a/tests/acceptance/boot_linux_console.py
> b/tests/acceptance/boot_linux_console.py
> >> index eb01286799..9fadea9958 100644
> >> --- a/tests/acceptance/boot_linux_console.py
> >> +++ b/tests/acceptance/boot_linux_console.py
> >> @@ -802,7 +802,29 @@ def test_arm_orangepi_sd(self):
> >>  # Wait for VM to shut down gracefully
> >>  self.vm.wait()
> >>
> >> -def do_test_arm_orangepi_uboot_armbian(self, image_path):
> >> +@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
> >> +'Test artifacts fetched from unreliable
> apt.armbian.com')
> >> +@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage
> limited')
> >> +def test_arm_orangepi_bionic_20_08(self):
> >> +"""
> >> +:avocado: tags=arch:arm
> >> +:avocado: tags=machine:orangepi-pc
> >> +:avocado: tags=device:sd
> >> +"""
> >> +
> >> +# This test download a 275 MiB compressed image and expand it
> >> +# to 1036 MiB, but the underlying filesystem is 1552 MiB...
> >> +# As we expand it to 2 GiB we are safe.
> >> +
> >> +image_url = ('https://dl.armbian.com/orangepipc/archive/'
> >> +
>  'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
> >
> > The Armbian 20 is not available on this link anymore. I can browse just
> 21.
>
> Cat-and-mouse game *sigh*.
>
>
Just to clarify here: in this patch I wanted to only make the change to
remove the test for the 19.11.3 image.
And in the 3rd patch (tests/acceptance/boot_linux_console: change URL for
test_arm_orangepi_bionic_20_08)
do the update for to correct the 20.08 link. So each patch fixes one
problem at a time.

Does that make sense, or do you prefer that I combine them in a single
patch instead?

Regards,
Niek

-- 
Niek Linnenbank


Re: [PATCH v3 4/5] tests/acceptance: update sunxi kernel from armbian to 5.10.16

2021-03-08 Thread Niek Linnenbank
Hi Philippe, Willian,

Thanks for reviewing!

On Mon, Mar 8, 2021 at 8:50 AM Philippe Mathieu-Daudé 
wrote:

> On 3/5/21 4:04 PM, Willian Rampazzo wrote:
> > On Thu, Mar 4, 2021 at 5:45 PM Niek Linnenbank 
> wrote:
> >>
> >> The linux kernel 4.20.7 binary for sunxi has been removed from
> apt.armbian.com:
> >>
> >>   $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes
> avocado --show=app,console run -t machine:orangepi-pc
> tests/acceptance/boot_linux_console.py
> >>   Fetching asset from
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi
> >>   ...
> >>   (1/6)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
> >> CANCEL: Missing asset
> https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb
> (0.55 s)
> >>
> >> This commit updates the sunxi kernel to 5.10.16 for the acceptance
> >> tests of the orangepi-pc and cubieboard machines.
> >>
> >> Signed-off-by: Niek Linnenbank 
> >> ---
> >>  tests/acceptance/boot_linux_console.py | 40 +-
> >>  tests/acceptance/replay_kernel.py  |  8 +++---
> >>  2 files changed, 24 insertions(+), 24 deletions(-)
> >>
> >
> > I think some devs will not like it,
> Maybe you refer to my previous NACKs regarding similar changes in
> integration tests. Niek is the author of the test and the maintainer
> of the machine, so if he is OK to stop testing the 4.20.7 kernels
> and test the 5.10.16 from now on, I won't object.
>

For me the 4.20.7 kernel would have been OK if it was still available. With
that version removed,
I looked at what is now available on https://apt.armbian.com/pool/main/l/.
There are quite a lot of packaged kernels there
and 5.10.16 seemed to me a good balance of running newer kernel code with a
version that will hopefully stay around for a while.


>
> > but, for me, it is fine as we
> > don't have the old kernel available anymore:
> >
> > Reviewed-by: Willian Rampazzo 
> >
>
> Thanks, will add your reviewed-by tag.

Regards,
Niek

-- 
Niek Linnenbank


[PATCH v3 5/5] tests/acceptance: drop ARMBIAN_ARTIFACTS_CACHED condition for orangepi-pc, cubieboard tests

2021-03-04 Thread Niek Linnenbank
Previously the ARMBIAN_ARTIFACTS_CACHED pre-condition was added to allow running
tests that have already existing armbian.com artifacts stored in the local 
avocado cache,
but do not have working URLs to download a fresh copy.

At this time of writing the URLs for artifacts on the armbian.com server are 
updated and working.
Any future broken URLs will result in a skipped acceptance test, for example:

 (1/5) 
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
  CANCEL: Missing asset 
https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb
 (0.53 s)

This commits removes the ARMBIAN_ARTIFACTS_CACHED pre-condition such that
the acceptance tests for the orangepi-pc and cubieboard machines can run.

Signed-off-by: Niek Linnenbank 
---
 tests/acceptance/boot_linux_console.py | 12 
 tests/acceptance/replay_kernel.py  |  2 --
 2 files changed, 14 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 04a8b23352..1ca32ecf25 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -507,8 +507,6 @@ def test_arm_exynos4210_initrd(self):
 self.wait_for_console_pattern('Boot successful.')
 # TODO user command, for now the uart is stuck
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_initrd(self):
 """
 :avocado: tags=arch:arm
@@ -549,8 +547,6 @@ def test_arm_cubieboard_initrd(self):
 'system-control@1c0')
 # cubieboard's reboot is not functioning; omit reboot test.
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_sata(self):
 """
 :avocado: tags=arch:arm
@@ -678,8 +674,6 @@ def test_arm_quanta_gsj_initrd(self):
 self.wait_for_console_pattern(
 'Give root password for system maintenance')
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi(self):
 """
 :avocado: tags=arch:arm
@@ -705,8 +699,6 @@ def test_arm_orangepi(self):
 console_pattern = 'Kernel command line: %s' % kernel_command_line
 self.wait_for_console_pattern(console_pattern)
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi_initrd(self):
 """
 :avocado: tags=arch:arm
@@ -749,8 +741,6 @@ def test_arm_orangepi_initrd(self):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi_sd(self):
 """
 :avocado: tags=arch:arm
@@ -802,8 +792,6 @@ def test_arm_orangepi_sd(self):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
 def test_arm_orangepi_bionic_20_08(self):
 """
diff --git a/tests/acceptance/replay_kernel.py 
b/tests/acceptance/replay_kernel.py
index 8c68caae31..71facdaa75 100644
--- a/tests/acceptance/replay_kernel.py
+++ b/tests/acceptance/replay_kernel.py
@@ -177,8 +177,6 @@ def test_arm_virt(self):
 self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1)
 
 @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_initrd(self):
 """
 :avocado: tags=arch:arm
-- 
2.25.1




[PATCH v3 4/5] tests/acceptance: update sunxi kernel from armbian to 5.10.16

2021-03-04 Thread Niek Linnenbank
The linux kernel 4.20.7 binary for sunxi has been removed from apt.armbian.com:

  $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado 
--show=app,console run -t machine:orangepi-pc 
tests/acceptance/boot_linux_console.py
  Fetching asset from 
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi
  ...
  (1/6) 
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
CANCEL: Missing asset 
https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb
 (0.55 s)

This commit updates the sunxi kernel to 5.10.16 for the acceptance
tests of the orangepi-pc and cubieboard machines.

Signed-off-by: Niek Linnenbank 
---
 tests/acceptance/boot_linux_console.py | 40 +-
 tests/acceptance/replay_kernel.py  |  8 +++---
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 4a7a6830ca..04a8b23352 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -515,12 +515,12 @@ def test_arm_cubieboard_initrd(self):
 :avocado: tags=machine:cubieboard
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
-dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+'/boot/vmlinuz-5.10.16-sunxi')
+dtb_path = 
'/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
   '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
@@ -557,12 +557,12 @@ def test_arm_cubieboard_sata(self):
 :avocado: tags=machine:cubieboard
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
-dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
+'/boot/vmlinuz-5.10.16-sunxi')
+dtb_path = 
'/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
   '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
@@ -686,12 +686,12 @@ def test_arm_orangepi(self):
 :avocado: tags=machine:orangepi-pc
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-'/boot/vmlinuz-4.20.7-sunxi')
-dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
+'/boot/vmlinuz-5.10.16-sunxi')
+dtb_path = 
'/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
 dtb_path = self.extract_from_deb(deb_path, dtb_path)
 
 self.vm.set_console()
@@ -713,12 +713,12 @@ def test_arm_orangepi_initrd(self):
 :avocado: tags=machine:orangepi-pc
 """
 deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
-deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
+   
'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
+deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
-   

[PATCH v3 2/5] tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic test for orangepi-pc machine

2021-03-04 Thread Niek Linnenbank
The image for Armbian 19.11.3 bionic has been removed from the armbian server.
Without the image as input the test arm_orangepi_bionic_19_11 cannot run.

This commit removes the test completely and merges the code of the generic 
function
do_test_arm_orangepi_uboot_armbian back with the 20.08 test.

Signed-off-by: Niek Linnenbank 
---
 tests/acceptance/boot_linux_console.py | 72 --
 1 file changed, 23 insertions(+), 49 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index eb01286799..9fadea9958 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -802,7 +802,29 @@ def test_arm_orangepi_sd(self):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-def do_test_arm_orangepi_uboot_armbian(self, image_path):
+@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
+'Test artifacts fetched from unreliable apt.armbian.com')
+@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
+def test_arm_orangepi_bionic_20_08(self):
+"""
+:avocado: tags=arch:arm
+:avocado: tags=machine:orangepi-pc
+:avocado: tags=device:sd
+"""
+
+# This test download a 275 MiB compressed image and expand it
+# to 1036 MiB, but the underlying filesystem is 1552 MiB...
+# As we expand it to 2 GiB we are safe.
+
+image_url = ('https://dl.armbian.com/orangepipc/archive/'
+ 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
+image_hash = ('b4d6775f5673486329e45a0586bf06b6'
+  'dbe792199fd182ac6b9c7bb6c7d3e6dd')
+image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
+ algorithm='sha256')
+image_path = archive.extract(image_path_xz, self.workdir)
+image_pow2ceil_expand(image_path)
+
 self.vm.set_console()
 self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
  '-nic', 'user',
@@ -828,54 +850,6 @@ def do_test_arm_orangepi_uboot_armbian(self, image_path):
   'to ')
 self.wait_for_console_pattern('Starting Load Kernel Modules...')
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
-@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
-@skipUnless(P7ZIP_AVAILABLE, '7z not installed')
-def test_arm_orangepi_bionic_19_11(self):
-"""
-:avocado: tags=arch:arm
-:avocado: tags=machine:orangepi-pc
-:avocado: tags=device:sd
-"""
-
-# This test download a 196MB compressed image and expand it to 1GB
-image_url = ('https://dl.armbian.com/orangepipc/archive/'
- 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
-image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e'
-image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash)
-image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
-image_path = os.path.join(self.workdir, image_name)
-process.run("7z e -o%s %s" % (self.workdir, image_path_7z))
-image_pow2ceil_expand(image_path)
-
-self.do_test_arm_orangepi_uboot_armbian(image_path)
-
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
-@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
-def test_arm_orangepi_bionic_20_08(self):
-"""
-:avocado: tags=arch:arm
-:avocado: tags=machine:orangepi-pc
-:avocado: tags=device:sd
-"""
-
-# This test download a 275 MiB compressed image and expand it
-# to 1036 MiB, but the underlying filesystem is 1552 MiB...
-# As we expand it to 2 GiB we are safe.
-
-image_url = ('https://dl.armbian.com/orangepipc/archive/'
- 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
-image_hash = ('b4d6775f5673486329e45a0586bf06b6'
-  'dbe792199fd182ac6b9c7bb6c7d3e6dd')
-image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
- algorithm='sha256')
-image_path = archive.extract(image_path_xz, self.workdir)
-image_pow2ceil_expand(image_path)
-
-self.do_test_arm_orangepi_uboot_armbian(image_path)
-
 @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
 def test_arm_orangepi_uboot_netbsd9(self):
 """
-- 
2.25.1




[PATCH v3 3/5] tests/acceptance/boot_linux_console: change URL for test_arm_orangepi_bionic_20_08

2021-03-04 Thread Niek Linnenbank
Update the download URL of the Armbian 20.08 Bionic image for
test_arm_orangepi_bionic_20_08 of the orangepi-pc machine.

The archive.armbian.com URL contains more images and should keep stable
for a longer period of time than dl.armbian.com.

Signed-off-by: Niek Linnenbank 
---
 tests/acceptance/boot_linux_console.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index 9fadea9958..4a7a6830ca 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -816,7 +816,7 @@ def test_arm_orangepi_bionic_20_08(self):
 # to 1036 MiB, but the underlying filesystem is 1552 MiB...
 # As we expand it to 2 GiB we are safe.
 
-image_url = ('https://dl.armbian.com/orangepipc/archive/'
+image_url = ('https://archive.armbian.com/orangepipc/archive/'
  'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
 image_hash = ('b4d6775f5673486329e45a0586bf06b6'
   'dbe792199fd182ac6b9c7bb6c7d3e6dd')
-- 
2.25.1




[PATCH v3 1/5] hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value

2021-03-04 Thread Niek Linnenbank
Currently the emulated EMAC for sun8i always traverses the transmit queue
from the head when transferring packets. It searches for a list of consecutive
descriptors whichs are flagged as ready for processing and transmits their 
payloads
accordingly. The controller stops processing once it finds a descriptor that is 
not
marked ready.

While the above behaviour works in most situations, it is not the same as the 
actual
EMAC in hardware. Actual hardware uses the TX_CUR_DESC register value to keep 
track
of the last position in the transmit queue and continues processing from that 
position
when software triggers the start of DMA processing. The currently emulated 
behaviour can
lead to packet loss on transmit when software fills the transmit queue with 
ready
descriptors that overlap the tail of the circular list.

This commit modifies the emulated EMAC for sun8i such that it processes
the transmit queue using the TX_CUR_DESC register in the same way as hardware.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Philippe Mathieu-Daudé 
---
 hw/net/allwinner-sun8i-emac.c | 58 +++
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index 042768922c..e586c147e5 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -339,35 +339,40 @@ static void 
allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
 qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
 }
 
-static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
-   FrameDescriptor *desc,
-   size_t min_size)
+static bool allwinner_sun8i_emac_desc_owned(FrameDescriptor *desc,
+size_t min_buf_size)
 {
-uint32_t paddr = desc->next;
+return (desc->status & DESC_STATUS_CTL) && (min_buf_size == 0 ||
+   (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_buf_size);
+}
 
-dma_memory_read(>dma_as, paddr, desc, sizeof(*desc));
+static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
+  FrameDescriptor *desc,
+  uint32_t phys_addr)
+{
+dma_memory_read(>dma_as, phys_addr, desc, sizeof(*desc));
+}
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
-return paddr;
-} else {
-return 0;
-}
+static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc)
+{
+const uint32_t nxt = desc->next;
+allwinner_sun8i_emac_get_desc(s, desc, nxt);
+return nxt;
 }
 
-static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
-  FrameDescriptor *desc,
-  uint32_t start_addr,
-  size_t min_size)
+static uint32_t allwinner_sun8i_emac_find_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc,
+   uint32_t start_addr,
+   size_t min_size)
 {
 uint32_t desc_addr = start_addr;
 
 /* Note that the list is a cycle. Last entry points back to the head. */
 while (desc_addr != 0) {
-dma_memory_read(>dma_as, desc_addr, desc, sizeof(*desc));
+allwinner_sun8i_emac_get_desc(s, desc, desc_addr);
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
+if (allwinner_sun8i_emac_desc_owned(desc, min_size)) {
 return desc_addr;
 } else if (desc->next == start_addr) {
 break;
@@ -383,14 +388,14 @@ static uint32_t 
allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s,
  FrameDescriptor *desc,
  size_t min_size)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size);
+return allwinner_sun8i_emac_find_desc(s, desc, s->rx_desc_curr, min_size);
 }
 
 static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
- FrameDescriptor *desc,
- size_t min_size)
+ FrameDescriptor *desc)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size);
+allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_curr);
+return s->tx_desc_curr;
 }
 
 static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
@@ -470,7 +475,8 @@ static ssize_t allwinner_sun8i_emac_receive(NetC

[PATCH v3 0/5] Allwinner H3 fixes for EMAC and acceptance tests

2021-03-04 Thread Niek Linnenbank
The following are maintenance patches for the Allwinner H3. The first patch
resolves artifact download errors by updating the URLs to the armbian.com 
server.

The second patch is a fix for the EMAC that is used by the Allwinner H3 / 
Orange Pi PC machine.

ChangeLog:

v3:
 - fixed the acceptance tests by using up-to-date armbian.com URLs

v2:
 - added Reviewed-By tags
 - changed URL for artifacts to github.com/nieklinnenbank/QemuArtifacts

Kind regards,

Niek

Niek Linnenbank (5):
  hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC
register value
  tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic
test for orangepi-pc machine
  tests/acceptance/boot_linux_console: change URL for
test_arm_orangepi_bionic_20_08
  tests/acceptance: update sunxi kernel from armbian to 5.10.16
  tests/acceptance: drop ARMBIAN_ARTIFACTS_CACHED condition for
orangepi-pc, cubieboard tests

 hw/net/allwinner-sun8i-emac.c  |  58 ++--
 tests/acceptance/boot_linux_console.py | 120 +
 tests/acceptance/replay_kernel.py  |  10 +--
 3 files changed, 77 insertions(+), 111 deletions(-)

-- 
2.25.1




Re: [PATCH v2 1/2] tests/acceptance: replace unstable apt.armbian.com URLs for orangepi-pc, cubieboard

2021-02-25 Thread Niek Linnenbank
Hi Philippe, Thomas, Daniel,

Thank you all. Then I'll just prepare a new version of the patch that uses
currently working archive.armbian.com links.

Kind regards,
Niek

On Thu, Feb 25, 2021 at 10:46 AM Daniel P. Berrangé 
wrote:

> On Wed, Feb 24, 2021 at 09:02:51PM +0100, Niek Linnenbank wrote:
> > Hi Philippe, Cleber,
> >
> > On Wed, Feb 24, 2021 at 8:14 PM Cleber Rosa  wrote:
> >
> > > On Wed, Feb 24, 2021 at 10:12:10AM +0100, Philippe Mathieu-Daudé wrote:
> > > > Hi Niek,
> > > >
> > > > On 2/23/21 11:53 PM, Niek Linnenbank wrote:
> > > > > Currently the automated acceptance tests for the Orange Pi PC and
> > > cubieboard
> > > > > machines are disabled by default. The tests for both machines
> require
> > > artifacts
> > > > > that are stored on the apt.armbian.com domain. Unfortunately,
> some of
> > > these artifacts
> > > > > have been removed from apt.armbian.com and it is uncertain whether
> > > more will be removed.
> > > > >
> > > > > This commit moves the artifacts previously stored on
> apt.armbian.com
> > > to github
> > > > > and retrieves them using the path: '//'.
> > > > >
> > > > > Signed-off-by: Niek Linnenbank 
> > > > > Reviewed-by: Willian Rampazzo 
> > > > > Reviewed-by: Cleber Rosa 
> > > >
> > > > > Tested-by: Cleber Rosa 
> > > >
> > > > Did Cleber test this new version?
> > > >
> > >
> >
> > You're right, it was the previous version (v1) that Cleber tested using
> my
> > own machine URL's.
> >
> > I was actually not sure whether I should or should not have added the
> > Tested-by/Reviewed-by tags in such scenario.
> > The content had to be changed due to the outcome of our discussion but
> also
> > I thought I don't want to silently drop
> > the tags since Cleber invested his time into it too.
> >
> > What should I do here, next time?
> >
> >
> >
> > >
> > > Nope, and I'm having issues with those URLs.  For instance:
> > >
> > >$ curl -L
> > >
> https://github.com/nieklinnenbank/QemuArtifacts/raw/master/cubieboard/linux-image-dev-sunxi_5.75_armhf.deb
> > >version https://git-lfs.github.com/spec/v1
> > >oid
> > > sha256:a4b765c851de76592f55023b1ff4104f7fd29bf90937e6054e0a64fdda56380b
> > >size 20331524
> > >
> > > Looks like it has to do with GitHub's behavior wrt quota.
> > >
> >
> > Indeed. Just this morning I received an e-mail from github with the
> > following text:
> >
> > "[GitHub] Git LFS disabled for nieklinnenbank
> >
> > Git LFS has been disabled on your personal account nieklinnenbank because
> > you’ve exceeded your data plan by at least 150%.
> > Please purchase additional data packs to cover your bandwidth and storage
> > usage:
> >
> >   https://github.com/account/billing/data/upgrade
> >
> > Current usage as of 24 Feb 2021 09:49AM UTC:
> >
> >   Bandwidth: 1.55 GB / 1 GB (155%)
> >   Storage: 0.48 GB / 1 GB (48%)"
> >
> > I wasn't aware of it but it appears that Github has these quota's for the
> > Large File Storage (LFS). I uploaded the files in the git LFS
> > because single files are also limited to 100MiB each on the regular Git
> > repositories.
> >
> > With those strict limits, in my opinion Github isn't really a solution
> > since the bandwidth limit will be reached very quickly. At least for the
> > LFS part that is. I don't know yet if there is any limit for regular
> access.
> >
> > My current ideas:
>
> >   - we can try to just update the URLs to armbian that are working now
> > (with the risk of breaking again in the near future). Ive also found this
> > link, which may be more stable:
> >  https://archive.armbian.com/orangepipc/archive/
>
> Just do this, as it is the simplest option that gets things working. We
> have already spent far too long talking about the problem instead of
> just fixing the URLs.
>
>
> Regards,
> Daniel
> --
> |: https://berrange.com  -o-
> https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o-
> https://fstop138.berrange.com :|
> |: https://entangle-photo.org-o-
> https://www.instagram.com/dberrange :|
>
>

-- 
Niek Linnenbank


Re: [PATCH v2 1/2] tests/acceptance: replace unstable apt.armbian.com URLs for orangepi-pc, cubieboard

2021-02-24 Thread Niek Linnenbank
Hi Philippe, Cleber,

On Wed, Feb 24, 2021 at 8:14 PM Cleber Rosa  wrote:

> On Wed, Feb 24, 2021 at 10:12:10AM +0100, Philippe Mathieu-Daudé wrote:
> > Hi Niek,
> >
> > On 2/23/21 11:53 PM, Niek Linnenbank wrote:
> > > Currently the automated acceptance tests for the Orange Pi PC and
> cubieboard
> > > machines are disabled by default. The tests for both machines require
> artifacts
> > > that are stored on the apt.armbian.com domain. Unfortunately, some of
> these artifacts
> > > have been removed from apt.armbian.com and it is uncertain whether
> more will be removed.
> > >
> > > This commit moves the artifacts previously stored on apt.armbian.com
> to github
> > > and retrieves them using the path: '//'.
> > >
> > > Signed-off-by: Niek Linnenbank 
> > > Reviewed-by: Willian Rampazzo 
> > > Reviewed-by: Cleber Rosa 
> >
> > > Tested-by: Cleber Rosa 
> >
> > Did Cleber test this new version?
> >
>

You're right, it was the previous version (v1) that Cleber tested using my
own machine URL's.

I was actually not sure whether I should or should not have added the
Tested-by/Reviewed-by tags in such scenario.
The content had to be changed due to the outcome of our discussion but also
I thought I don't want to silently drop
the tags since Cleber invested his time into it too.

What should I do here, next time?



>
> Nope, and I'm having issues with those URLs.  For instance:
>
>$ curl -L
> https://github.com/nieklinnenbank/QemuArtifacts/raw/master/cubieboard/linux-image-dev-sunxi_5.75_armhf.deb
>version https://git-lfs.github.com/spec/v1
>oid
> sha256:a4b765c851de76592f55023b1ff4104f7fd29bf90937e6054e0a64fdda56380b
>size 20331524
>
> Looks like it has to do with GitHub's behavior wrt quota.
>

Indeed. Just this morning I received an e-mail from github with the
following text:

"[GitHub] Git LFS disabled for nieklinnenbank

Git LFS has been disabled on your personal account nieklinnenbank because
you’ve exceeded your data plan by at least 150%.
Please purchase additional data packs to cover your bandwidth and storage
usage:

  https://github.com/account/billing/data/upgrade

Current usage as of 24 Feb 2021 09:49AM UTC:

  Bandwidth: 1.55 GB / 1 GB (155%)
  Storage: 0.48 GB / 1 GB (48%)"

I wasn't aware of it but it appears that Github has these quota's for the
Large File Storage (LFS). I uploaded the files in the git LFS
because single files are also limited to 100MiB each on the regular Git
repositories.

With those strict limits, in my opinion Github isn't really a solution
since the bandwidth limit will be reached very quickly. At least for the
LFS part that is. I don't know yet if there is any limit for regular access.

My current ideas:
  - we can try to splitup the larger files into sizes < 100MiB in order to
use github regular storage. and then download each part to combine into the
final image.
im not really in favour of this but it can work, if github doesnt have
any other limit/quota. the cost is that we have to add more complexity to
the acceptance test code.
  - we can try to just update the URLs to armbian that are working now
(with the risk of breaking again in the near future). Ive also found this
link, which may be more stable:
 https://archive.armbian.com/orangepipc/archive/
  - or use the server that im hosting - and i don't mind to add the license
files on it if needed (should be GPLv2 right?)

I'd be interested to hear your opinion and suggestions.

Kind regards,
Niek


>
> Regards,
> - Cleber.
>


-- 
Niek Linnenbank


[PATCH v2 2/2] hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value

2021-02-23 Thread Niek Linnenbank
Currently the emulated EMAC for sun8i always traverses the transmit queue
from the head when transferring packets. It searches for a list of consecutive
descriptors whichs are flagged as ready for processing and transmits their 
payloads
accordingly. The controller stops processing once it finds a descriptor that is 
not
marked ready.

While the above behaviour works in most situations, it is not the same as the 
actual
EMAC in hardware. Actual hardware uses the TX_CUR_DESC register value to keep 
track
of the last position in the transmit queue and continues processing from that 
position
when software triggers the start of DMA processing. The currently emulated 
behaviour can
lead to packet loss on transmit when software fills the transmit queue with 
ready
descriptors that overlap the tail of the circular list.

This commit modifies the emulated EMAC for sun8i such that it processes
the transmit queue using the TX_CUR_DESC register in the same way as hardware.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Philippe Mathieu-Daudé 
---
 hw/net/allwinner-sun8i-emac.c | 58 +++
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index 042768922c..e586c147e5 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -339,35 +339,40 @@ static void 
allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
 qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
 }
 
-static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
-   FrameDescriptor *desc,
-   size_t min_size)
+static bool allwinner_sun8i_emac_desc_owned(FrameDescriptor *desc,
+size_t min_buf_size)
 {
-uint32_t paddr = desc->next;
+return (desc->status & DESC_STATUS_CTL) && (min_buf_size == 0 ||
+   (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_buf_size);
+}
 
-dma_memory_read(>dma_as, paddr, desc, sizeof(*desc));
+static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
+  FrameDescriptor *desc,
+  uint32_t phys_addr)
+{
+dma_memory_read(>dma_as, phys_addr, desc, sizeof(*desc));
+}
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
-return paddr;
-} else {
-return 0;
-}
+static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc)
+{
+const uint32_t nxt = desc->next;
+allwinner_sun8i_emac_get_desc(s, desc, nxt);
+return nxt;
 }
 
-static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
-  FrameDescriptor *desc,
-  uint32_t start_addr,
-  size_t min_size)
+static uint32_t allwinner_sun8i_emac_find_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc,
+   uint32_t start_addr,
+   size_t min_size)
 {
 uint32_t desc_addr = start_addr;
 
 /* Note that the list is a cycle. Last entry points back to the head. */
 while (desc_addr != 0) {
-dma_memory_read(>dma_as, desc_addr, desc, sizeof(*desc));
+allwinner_sun8i_emac_get_desc(s, desc, desc_addr);
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
+if (allwinner_sun8i_emac_desc_owned(desc, min_size)) {
 return desc_addr;
 } else if (desc->next == start_addr) {
 break;
@@ -383,14 +388,14 @@ static uint32_t 
allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s,
  FrameDescriptor *desc,
  size_t min_size)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size);
+return allwinner_sun8i_emac_find_desc(s, desc, s->rx_desc_curr, min_size);
 }
 
 static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
- FrameDescriptor *desc,
- size_t min_size)
+ FrameDescriptor *desc)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size);
+allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_curr);
+return s->tx_desc_curr;
 }
 
 static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
@@ -470,7 +475,8 @@ static ssize_t allwinner_sun8i_emac_receive(NetC

[PATCH v2 0/2] Allwinner H3 fixes for EMAC and acceptance tests

2021-02-23 Thread Niek Linnenbank
The following are maintenance patches for the Allwinner H3. The first patch
is a proposal to relocate the binary artifacts of the acceptance tests away
from the apt.armbian.com domain. In the past we had problems with artifacts 
being
removed, and now the recently added Armbian 20.08.1 image has been removed as 
well:

$ wget 
https://dl.armbian.com/orangepipc/archive/Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz
Connecting to dl.armbian.com (dl.armbian.com)|2605:7900:20::5|:443... connected.
...
HTTP request sent, awaiting response... 404 Not Found
2021-02-11 22:34:45 ERROR 404: Not Found.

I've now added the artifacts to github as a short term solution:
  https://github.com/nieklinnenbank/QemuArtifacts

The second patch is a fix for the EMAC that is used by the Allwinner H3 / 
Orange Pi PC machine.

ChangeLog:

v2:
 - added Reviewed-By tags
 - changed URL for artifacts to github.com/nieklinnenbank/QemuArtifacts

Kind regards,

Niek

Niek Linnenbank (2):
  tests/acceptance: replace unstable apt.armbian.com URLs for
orangepi-pc, cubieboard
  hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC
register value

 hw/net/allwinner-sun8i-emac.c  | 58 ++
 tests/acceptance/boot_linux_console.py | 49 +-
 tests/acceptance/replay_kernel.py  |  6 +--
 3 files changed, 53 insertions(+), 60 deletions(-)

-- 
2.25.1




[PATCH v2 1/2] tests/acceptance: replace unstable apt.armbian.com URLs for orangepi-pc, cubieboard

2021-02-23 Thread Niek Linnenbank
Currently the automated acceptance tests for the Orange Pi PC and cubieboard
machines are disabled by default. The tests for both machines require artifacts
that are stored on the apt.armbian.com domain. Unfortunately, some of these 
artifacts
have been removed from apt.armbian.com and it is uncertain whether more will be 
removed.

This commit moves the artifacts previously stored on apt.armbian.com to github
and retrieves them using the path: '//'.

Signed-off-by: Niek Linnenbank 
Reviewed-by: Willian Rampazzo 
Reviewed-by: Cleber Rosa 
Tested-by: Cleber Rosa 
---
 tests/acceptance/boot_linux_console.py | 49 ++
 tests/acceptance/replay_kernel.py  |  6 ++--
 2 files changed, 21 insertions(+), 34 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index eb01286799..0f8a824c61 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -507,15 +507,13 @@ def test_arm_exynos4210_initrd(self):
 self.wait_for_console_pattern('Boot successful.')
 # TODO user command, for now the uart is stuck
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_initrd(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:cubieboard
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('https://github.com/nieklinnenbank/QemuArtifacts/raw/'
+   'master/cubieboard/linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -549,15 +547,13 @@ def test_arm_cubieboard_initrd(self):
 'system-control@1c0')
 # cubieboard's reboot is not functioning; omit reboot test.
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_sata(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:cubieboard
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('https://github.com/nieklinnenbank/QemuArtifacts/raw/'
+   'master/cubieboard/linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -678,15 +674,13 @@ def test_arm_quanta_gsj_initrd(self):
 self.wait_for_console_pattern(
 'Give root password for system maintenance')
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:orangepi-pc
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('https://github.com/nieklinnenbank/QemuArtifacts/raw/'
+   'master/orangepi-pc/linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -705,15 +699,13 @@ def test_arm_orangepi(self):
 console_pattern = 'Kernel command line: %s' % kernel_command_line
 self.wait_for_console_pattern(console_pattern)
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi_initrd(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:orangepi-pc
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('https://github.com/nieklinnenbank/QemuArtifacts/raw/'
+   'master/orangepi-pc/linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -749,24 +741,23 @@ def test_arm_orangepi_initrd(self):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS

Re: [PATCH 0/2] Allwinner H3 fixes for EMAC and acceptance tests

2021-02-21 Thread Niek Linnenbank
On Fri, Feb 19, 2021 at 7:24 PM Philippe Mathieu-Daudé 
wrote:

> Hi Niek,
>
> On 2/17/21 9:57 PM, Niek Linnenbank wrote:
> > Hi Daniel, Philippe,
> >
> > Op di 16 feb. 2021 10:49 schreef Daniel P. Berrangé  > <mailto:berra...@redhat.com>>:
> >
> > On Fri, Feb 12, 2021 at 03:10:00PM +0100, Philippe Mathieu-Daudé
> wrote:
> > > Hi Niek and QEMU community,
> > >
> > > On 2/11/21 11:00 PM, Niek Linnenbank wrote:
> > > > The following are maintenance patches for the Allwinner H3. The
> > first patch
> > > > is a proposal to relocate the binary artifacts of the acceptance
> > tests away
> > > > from the apt.armbian.com <http://apt.armbian.com> domain. In the
> > past we had problems with artifacts being
> > > > removed, and now the recently added Armbian 20.08.1 image has
> > been removed as well:
> > > >
> > > > $ wget
> >
> https://dl.armbian.com/orangepipc/archive/Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz
> > <
> https://dl.armbian.com/orangepipc/archive/Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz
> >
> > > > Connecting to dl.armbian.com <http://dl.armbian.com>
> > (dl.armbian.com <http://dl.armbian.com>)|2605:7900:20::5|:443...
> > connected.
> > > > ...
> > > > HTTP request sent, awaiting response... 404 Not Found
> > > > 2021-02-11 22:34:45 ERROR 404: Not Found.
> > > >
> > > > I've now added the artifacts to a server maintained by me. The
> > machine has a stable
> > > > uptime of several years, ~100Mbit bandwidth and plenty of
> > available storage.
> > > > Also for other artifacts if needed. I'm open to discuss if there
> > is a proposal
> > > > for a better location for these artifacts or a more generic qemu
> > location.
> > >
> > > Thanks for trying to fix this long standing problem.
> > >
> > > While this works in your case, this doesn't scale to the community,
> > > as not all contributors have access to such hardware and bandwidth
> /
> > > storage.
> > >
> > > While your first patch is useful in showing where the artifacts are
> > > stored doesn't matter - as long as we use cryptographic hashes - I
> > > think it is a step in the wrong direction, so I am not keen on
> > > accepting it.
> > >
> > > My personal view is that any contributor should have the same
> > > possibilities to add tests to the project. Now I am also open to
> > > discuss with the others :) I might be proven wrong, and it could
> > > be better to rely on good willing contributors rather than having
> > > nothing useful at all.
> >
> > There aren't many options here
> >
> >  1. Rely on a vendor to provide stable download URLs for images
> >
> >  2. QEMU host all images we use in testing
> >
> >  3. Contributor finds some site to upload images to
> >
> >
> > For the armbian images we rely on (1), but the URLs didn't turn out
> > to be
> > stable. In fact no OS vendor seems to have guaranteed stable URLs
> > forever,
> > regardless of distro, though most eventually do have an archive site
> > that
> > has good life. Armbian was an exception in this respect IIUC.
> >
> > (2) would solve the long term stability problem as QEMU would be in
> full
> > control, and could open it up for any images we need. The big
> challenge
> > there is that QEMU now owns the license compliance problem. Merely
> > uploading
> > binary images/packages without the corresponding source is generally
> > a license
> > violation. QEMU could provide hosting, but we need to be clear about
> > the fact
> > that we now own the license compliance problem ourselves. Many sites
> > hosting
> > images simply ignore this problem, but that doesn't make it right.
> >
> >
> > This series is proposing (3), with a site the contributor happens to
> > control
> > themselves, but using a free 3rd party hosting site is no different
> > really.
> > Again there is a the same need for license compliance, but it is now
> the
> > responsibility of the user, not QEMU project.
> >
> > In this http://www.

Re: [PATCH 0/2] Allwinner H3 fixes for EMAC and acceptance tests

2021-02-17 Thread Niek Linnenbank
Hi Daniel, Philippe,




Op di 16 feb. 2021 10:49 schreef Daniel P. Berrangé :

> On Fri, Feb 12, 2021 at 03:10:00PM +0100, Philippe Mathieu-Daudé wrote:
> > Hi Niek and QEMU community,
> >
> > On 2/11/21 11:00 PM, Niek Linnenbank wrote:
> > > The following are maintenance patches for the Allwinner H3. The first
> patch
> > > is a proposal to relocate the binary artifacts of the acceptance tests
> away
> > > from the apt.armbian.com domain. In the past we had problems with
> artifacts being
> > > removed, and now the recently added Armbian 20.08.1 image has been
> removed as well:
> > >
> > > $ wget
> https://dl.armbian.com/orangepipc/archive/Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz
> > > Connecting to dl.armbian.com (dl.armbian.com)|2605:7900:20::5|:443...
> connected.
> > > ...
> > > HTTP request sent, awaiting response... 404 Not Found
> > > 2021-02-11 22:34:45 ERROR 404: Not Found.
> > >
> > > I've now added the artifacts to a server maintained by me. The machine
> has a stable
> > > uptime of several years, ~100Mbit bandwidth and plenty of available
> storage.
> > > Also for other artifacts if needed. I'm open to discuss if there is a
> proposal
> > > for a better location for these artifacts or a more generic qemu
> location.
> >
> > Thanks for trying to fix this long standing problem.
> >
> > While this works in your case, this doesn't scale to the community,
> > as not all contributors have access to such hardware and bandwidth /
> > storage.
> >
> > While your first patch is useful in showing where the artifacts are
> > stored doesn't matter - as long as we use cryptographic hashes - I
> > think it is a step in the wrong direction, so I am not keen on
> > accepting it.
> >
> > My personal view is that any contributor should have the same
> > possibilities to add tests to the project. Now I am also open to
> > discuss with the others :) I might be proven wrong, and it could
> > be better to rely on good willing contributors rather than having
> > nothing useful at all.
>
> There aren't many options here
>
>  1. Rely on a vendor to provide stable download URLs for images
>
>  2. QEMU host all images we use in testing
>
>  3. Contributor finds some site to upload images to
>
>
> For the armbian images we rely on (1), but the URLs didn't turn out to be
> stable. In fact no OS vendor seems to have guaranteed stable URLs forever,
> regardless of distro, though most eventually do have an archive site that
> has good life. Armbian was an exception in this respect IIUC.
>
> (2) would solve the long term stability problem as QEMU would be in full
> control, and could open it up for any images we need. The big challenge
> there is that QEMU now owns the license compliance problem. Merely
> uploading
> binary images/packages without the corresponding source is generally a
> license
> violation. QEMU could provide hosting, but we need to be clear about the
> fact
> that we now own the license compliance problem ourselves. Many sites
> hosting
> images simply ignore this problem, but that doesn't make it right.
>
>
> This series is proposing (3), with a site the contributor happens to
> control
> themselves, but using a free 3rd party hosting site is no different really.
> Again there is a the same need for license compliance, but it is now the
> responsibility of the user, not QEMU project.
>
> In this http://www.freenos.org/pub/qemu/cubieboard/ site I can't even see
> a
> directory listing, so even if corresponding source does exist in this
> server,
> I can't find it.
>
> The isn't really a problem for QEMU CI to consume the images, but as a free
> software developer I don't like encouraging practices that are not
> compliant
> with licensing reuqirement.
>
> It is an open question whether the (3) is really better than (1) in terms
> of URL stability long term, especially if running off a user's personal
> server.
>

I understand your concerns. My goal here was to be able to re-activate the
orangepi tests, so we can capture bugs early on. So what I can do instead
is:

  - update the patch to use github to store the artifacts, and their
licenses (other tests also use github)
  - or change the patch to use updated armbian links that work (for now)

If we can agree on either of these solutions, so the orangepi tests can be
re-activated, that would be great.

Kind regards,
Niek



> Regards,
> Daniel
> --
> |: https://berrange.com  -o-
> https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o-
> https://fstop138.berrange.com :|
> |: https://entangle-photo.org-o-
> https://www.instagram.com/dberrange :|
>
>


Re: [PATCH 0/2] Allwinner H3 fixes for EMAC and acceptance tests

2021-02-15 Thread Niek Linnenbank
Op vr 12 feb. 2021 15:10 schreef Philippe Mathieu-Daudé :

> Hi Niek and QEMU community,
>
> On 2/11/21 11:00 PM, Niek Linnenbank wrote:
> > The following are maintenance patches for the Allwinner H3. The first
> patch
> > is a proposal to relocate the binary artifacts of the acceptance tests
> away
> > from the apt.armbian.com domain. In the past we had problems with
> artifacts being
> > removed, and now the recently added Armbian 20.08.1 image has been
> removed as well:
> >
> > $ wget
> https://dl.armbian.com/orangepipc/archive/Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz
> > Connecting to dl.armbian.com (dl.armbian.com)|2605:7900:20::5|:443...
> connected.
> > ...
> > HTTP request sent, awaiting response... 404 Not Found
> > 2021-02-11 22:34:45 ERROR 404: Not Found.
> >
> > I've now added the artifacts to a server maintained by me. The machine
> has a stable
> > uptime of several years, ~100Mbit bandwidth and plenty of available
> storage.
> > Also for other artifacts if needed. I'm open to discuss if there is a
> proposal
> > for a better location for these artifacts or a more generic qemu
> location.
>
> Thanks for trying to fix this long standing problem.
>
> While this works in your case, this doesn't scale to the community,
> as not all contributors have access to such hardware and bandwidth /
> storage.
>
> While your first patch is useful in showing where the artifacts are
> stored doesn't matter - as long as we use cryptographic hashes - I
> think it is a step in the wrong direction, so I am not keen on
> accepting it.


> My personal view is that any contributor should have the same
> possibilities to add tests to the project.


Hi Philippe,

I see your point. How about I simply upload the artifacts to github
instead? There are already multiple tests right now that use artifacts
stored on github. And github is available to everyone. For me that would
work fine. If you agree, I can respin the patch.

Regards
Niek

Now I am also open to
> discuss with the others :) I might be proven wrong, and it could
> be better to rely on good willing contributors rather than having
> nothing useful at all.


> Regards,
>
> Phil.
>
>


[PATCH 0/2] Allwinner H3 fixes for EMAC and acceptance tests

2021-02-11 Thread Niek Linnenbank
The following are maintenance patches for the Allwinner H3. The first patch
is a proposal to relocate the binary artifacts of the acceptance tests away
from the apt.armbian.com domain. In the past we had problems with artifacts 
being
removed, and now the recently added Armbian 20.08.1 image has been removed as 
well:

$ wget 
https://dl.armbian.com/orangepipc/archive/Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz
Connecting to dl.armbian.com (dl.armbian.com)|2605:7900:20::5|:443... connected.
...
HTTP request sent, awaiting response... 404 Not Found
2021-02-11 22:34:45 ERROR 404: Not Found.

I've now added the artifacts to a server maintained by me. The machine has a 
stable
uptime of several years, ~100Mbit bandwidth and plenty of available storage.
Also for other artifacts if needed. I'm open to discuss if there is a proposal
for a better location for these artifacts or a more generic qemu location.

The second patch is a fix for the EMAC that is used by the Allwinner H3 / 
Orange Pi PC machine.

Kind regards,

Niek

Niek Linnenbank (2):
  tests/acceptance: replace unstable apt.armbian.com URLs for
orangepi-pc, cubieboard
  hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC
register value

 hw/net/allwinner-sun8i-emac.c  | 58 ++
 tests/acceptance/boot_linux_console.py | 46 +++-
 tests/acceptance/replay_kernel.py  |  6 +--
 3 files changed, 50 insertions(+), 60 deletions(-)

-- 
2.25.1




[PATCH 1/2] tests/acceptance: replace unstable apt.armbian.com URLs for orangepi-pc, cubieboard

2021-02-11 Thread Niek Linnenbank
Currently the automated acceptance tests for the Orange Pi PC and cubieboard
machines are disabled by default. The tests for both machines require artifacts
that are stored on the apt.armbian.com domain. Unfortunately, some of these 
artifacts
have been removed from apt.armbian.com and it is uncertain whether more will be 
removed.

This commit moves the artifacts previously stored on apt.armbian.com to a 
different
domain that is maintainted by me and retrieves them using the path: 
'/pub/qemu//'.

Signed-off-by: Niek Linnenbank 
---
 tests/acceptance/boot_linux_console.py | 46 +-
 tests/acceptance/replay_kernel.py  |  6 ++--
 2 files changed, 18 insertions(+), 34 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index eb01286799..12fccbdb37 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -507,15 +507,13 @@ class BootLinuxConsole(LinuxKernelTest):
 self.wait_for_console_pattern('Boot successful.')
 # TODO user command, for now the uart is stuck
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_initrd(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:cubieboard
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('http://www.freenos.org/pub/qemu/cubieboard/'
+   'linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -549,15 +547,13 @@ class BootLinuxConsole(LinuxKernelTest):
 'system-control@1c0')
 # cubieboard's reboot is not functioning; omit reboot test.
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_cubieboard_sata(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:cubieboard
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('http://www.freenos.org/pub/qemu/cubieboard/'
+   'linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -678,15 +674,13 @@ class BootLinuxConsole(LinuxKernelTest):
 self.wait_for_console_pattern(
 'Give root password for system maintenance')
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:orangepi-pc
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('http://www.freenos.org/pub/qemu/orangepi-pc/'
+   'linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -705,15 +699,13 @@ class BootLinuxConsole(LinuxKernelTest):
 console_pattern = 'Kernel command line: %s' % kernel_command_line
 self.wait_for_console_pattern(console_pattern)
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi_initrd(self):
 """
 :avocado: tags=arch:arm
 :avocado: tags=machine:orangepi-pc
 """
-deb_url = ('https://apt.armbian.com/pool/main/l/'
-   'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
+deb_url = ('http://www.freenos.org/pub/qemu/orangepi-pc/'
+   'linux-image-dev-sunxi_5.75_armhf.deb')
 deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
 deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
 kernel_path = self.extract_from_deb(deb_path,
@@ -749,24 +741,23 @@ class BootLinuxConsole(LinuxKernelTest):
 # Wait for VM to shut down gracefully
 self.vm.wait()
 
-@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
-'Test artifacts fetched from unreliable apt.armbian.com')
 def test_arm_orangepi_sd(

[PATCH 2/2] hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value

2021-02-11 Thread Niek Linnenbank
Currently the emulated EMAC for sun8i always traverses the transmit queue
from the head when transferring packets. It searches for a list of consecutive
descriptors whichs are flagged as ready for processing and transmits their 
payloads
accordingly. The controller stops processing once it finds a descriptor that is 
not
marked ready.

While the above behaviour works in most situations, it is not the same as the 
actual
EMAC in hardware. Actual hardware uses the TX_CUR_DESC register value to keep 
track
of the last position in the transmit queue and continues processing from that 
position
when software triggers the start of DMA processing. The currently emulated 
behaviour can
lead to packet loss on transmit when software fills the transmit queue with 
ready
descriptors that overlap the tail of the circular list.

This commit modifies the emulated EMAC for sun8i such that it processes
the transmit queue using the TX_CUR_DESC register in the same way as hardware.

Signed-off-by: Niek Linnenbank 
---
 hw/net/allwinner-sun8i-emac.c | 58 +++
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index 042768922c..e586c147e5 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -339,35 +339,40 @@ static void 
allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
 qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
 }
 
-static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
-   FrameDescriptor *desc,
-   size_t min_size)
+static bool allwinner_sun8i_emac_desc_owned(FrameDescriptor *desc,
+size_t min_buf_size)
 {
-uint32_t paddr = desc->next;
+return (desc->status & DESC_STATUS_CTL) && (min_buf_size == 0 ||
+   (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_buf_size);
+}
 
-dma_memory_read(>dma_as, paddr, desc, sizeof(*desc));
+static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
+  FrameDescriptor *desc,
+  uint32_t phys_addr)
+{
+dma_memory_read(>dma_as, phys_addr, desc, sizeof(*desc));
+}
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
-return paddr;
-} else {
-return 0;
-}
+static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc)
+{
+const uint32_t nxt = desc->next;
+allwinner_sun8i_emac_get_desc(s, desc, nxt);
+return nxt;
 }
 
-static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
-  FrameDescriptor *desc,
-  uint32_t start_addr,
-  size_t min_size)
+static uint32_t allwinner_sun8i_emac_find_desc(AwSun8iEmacState *s,
+   FrameDescriptor *desc,
+   uint32_t start_addr,
+   size_t min_size)
 {
 uint32_t desc_addr = start_addr;
 
 /* Note that the list is a cycle. Last entry points back to the head. */
 while (desc_addr != 0) {
-dma_memory_read(>dma_as, desc_addr, desc, sizeof(*desc));
+allwinner_sun8i_emac_get_desc(s, desc, desc_addr);
 
-if ((desc->status & DESC_STATUS_CTL) &&
-(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
+if (allwinner_sun8i_emac_desc_owned(desc, min_size)) {
 return desc_addr;
 } else if (desc->next == start_addr) {
 break;
@@ -383,14 +388,14 @@ static uint32_t 
allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s,
  FrameDescriptor *desc,
  size_t min_size)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size);
+return allwinner_sun8i_emac_find_desc(s, desc, s->rx_desc_curr, min_size);
 }
 
 static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
- FrameDescriptor *desc,
- size_t min_size)
+ FrameDescriptor *desc)
 {
-return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size);
+allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_curr);
+return s->tx_desc_curr;
 }
 
 static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
@@ -470,7 +475,8 @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState 
*nc,
 bytes_left -= d

Re: [PATCH v3 6/6] hw/arm: Display CPU type in machine description

2021-01-31 Thread Niek Linnenbank
For Orange Pi PC:

Reviewed-by: Niek Linnenbank 

Op zo 31 jan. 2021 19:45 schreef Philippe Mathieu-Daudé :

> Most of ARM machines display their CPU when QEMU list the available
> machines (-M help). Some machines do not. Fix to unify the help
> output.
>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/arm/digic_boards.c  | 2 +-
>  hw/arm/microbit.c  | 2 +-
>  hw/arm/netduino2.c | 2 +-
>  hw/arm/netduinoplus2.c | 2 +-
>  hw/arm/orangepi.c  | 2 +-
>  hw/arm/stellaris.c | 4 ++--
>  6 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
> index be12873673b..6cdc1d83fca 100644
> --- a/hw/arm/digic_boards.c
> +++ b/hw/arm/digic_boards.c
> @@ -142,7 +142,7 @@ static void canon_a1100_init(MachineState *machine)
>
>  static void canon_a1100_machine_init(MachineClass *mc)
>  {
> -mc->desc = "Canon PowerShot A1100 IS";
> +mc->desc = "Canon PowerShot A1100 IS (ARM946)";
>  mc->init = _a1100_init;
>  mc->ignore_memory_transaction_failures = true;
>  mc->default_ram_size = 64 * MiB;
> diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c
> index 0947491cb97..e9494334ce7 100644
> --- a/hw/arm/microbit.c
> +++ b/hw/arm/microbit.c
> @@ -64,7 +64,7 @@ static void microbit_machine_class_init(ObjectClass *oc,
> void *data)
>  {
>  MachineClass *mc = MACHINE_CLASS(oc);
>
> -mc->desc = "BBC micro:bit";
> +mc->desc = "BBC micro:bit (Cortex-M0)";
>  mc->init = microbit_init;
>  mc->max_cpus = 1;
>  }
> diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c
> index 8f103341443..1733b71507c 100644
> --- a/hw/arm/netduino2.c
> +++ b/hw/arm/netduino2.c
> @@ -54,7 +54,7 @@ static void netduino2_init(MachineState *machine)
>
>  static void netduino2_machine_init(MachineClass *mc)
>  {
> -mc->desc = "Netduino 2 Machine";
> +mc->desc = "Netduino 2 Machine (Cortex-M3)";
>  mc->init = netduino2_init;
>  mc->ignore_memory_transaction_failures = true;
>  }
> diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c
> index 68abd3ec69d..d3ad7a2b675 100644
> --- a/hw/arm/netduinoplus2.c
> +++ b/hw/arm/netduinoplus2.c
> @@ -55,7 +55,7 @@ static void netduinoplus2_init(MachineState *machine)
>
>  static void netduinoplus2_machine_init(MachineClass *mc)
>  {
> -mc->desc = "Netduino Plus 2 Machine";
> +mc->desc = "Netduino Plus 2 Machine (Cortex-M4)";
>  mc->init = netduinoplus2_init;
>  }
>
> diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c
> index d6306dfddae..40cdb5c6d2c 100644
> --- a/hw/arm/orangepi.c
> +++ b/hw/arm/orangepi.c
> @@ -113,7 +113,7 @@ static void orangepi_init(MachineState *machine)
>
>  static void orangepi_machine_init(MachineClass *mc)
>  {
> -mc->desc = "Orange Pi PC";
> +mc->desc = "Orange Pi PC (Cortex-A7)";
>  mc->init = orangepi_init;
>  mc->block_default_type = IF_SD;
>  mc->units_per_default_bus = 1;
> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
> index ad72c0959f1..27292ec4113 100644
> --- a/hw/arm/stellaris.c
> +++ b/hw/arm/stellaris.c
> @@ -1538,7 +1538,7 @@ static void lm3s811evb_class_init(ObjectClass *oc,
> void *data)
>  {
>  MachineClass *mc = MACHINE_CLASS(oc);
>
> -mc->desc = "Stellaris LM3S811EVB";
> +mc->desc = "Stellaris LM3S811EVB (Cortex-M3)";
>  mc->init = lm3s811evb_init;
>  mc->ignore_memory_transaction_failures = true;
>  mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
> @@ -1554,7 +1554,7 @@ static void lm3s6965evb_class_init(ObjectClass *oc,
> void *data)
>  {
>  MachineClass *mc = MACHINE_CLASS(oc);
>
> -mc->desc = "Stellaris LM3S6965EVB";
> +mc->desc = "Stellaris LM3S6965EVB (Cortex-M3)";
>  mc->init = lm3s6965evb_init;
>  mc->ignore_memory_transaction_failures = true;
>  mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
> --
> 2.26.2
>
>


Re: [RFC PATCH-for-5.2] gitlab-ci: Do not automatically run Avocado integration tests anymore

2020-11-27 Thread Niek Linnenbank
Hi Philippe, Thomas,

Op vr 27 nov. 2020 18:57 schreef Philippe Mathieu-Daudé :

> On 11/27/20 6:47 PM, Thomas Huth wrote:
> > On 27/11/2020 18.41, Philippe Mathieu-Daudé wrote:
> >> We lately realized that the Avocado framework was not designed
> >> to be regularly run on CI environments. Therefore, as of 5.2
> >> we deprecate the gitlab-ci jobs using Avocado. To not disrupt
> >> current users, it is possible to keep the current behavior by
> >> setting the QEMU_CI_INTEGRATION_JOBS_PRE_5_2_RELEASE variable
> >> (see [*]).
> >> From now on, using these jobs (or adding new tests to them)
> >> is strongly discouraged.
> >>
> >> Tests based on Avocado will be ported to new job schemes during
> >> the next releases, with better documentation and templates.
> >
> > Why should we disable the jobs by default as long as there is no
> replacement
> > available yet?
>
> Why keep it enabled if it is failing randomly, if images hardcoded
> in tests are being removed from public servers, etc...?
>
>
> They are not disabled, they are still runnable manually or setting
> QEMU_CI_INTEGRATION_JOBS_PRE_5_2_RELEASE...
>
> We realized by default Avocado runs all tests on the CI jobs,
> triggering failures and complains. Developer stopped to contribute/
> review integration tests because of that. We want developers be
> able to contribute tests to the repository fearlessly.
>
> If we don't change anything, we'll keep having CI failures due
> to Avocado design issues (artifacts removed from remote servers,
> etc...).
>

I share your concern about the artifacts not being stored on a reliable
location that can be used for all Qemu acceptance tests. In particular for
the Orange Pi PC tests we have seen it happening, that the image we use was
removed from the armbian server.

As a temporary solution perhaps we can use github to store artifacts, until
we have a proper location?


> I haven't seen any attempt on this list to improve the current
> fragile situation, but better suggestions are certainly welcome.
>
> Thanks,
>
> Phil.
>
>
>


Re: [PATCH-for-5.2 4/6] MAINTAINERS: Fix system/arm/orangepi.rst path

2020-11-20 Thread Niek Linnenbank
Op vr 20 nov. 2020 16:46 schreef Philippe Mathieu-Daudé :

> Fixes: 0553ef42571 ("docs: add Orange Pi PC document")
> Signed-off-by: Philippe Mathieu-Daudé 
>
Reviewed-by: Niek Linnenbank 

---
> Cc: Niek Linnenbank 
> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2623cf85f66..311a55317ce 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -559,7 +559,7 @@ S: Maintained
>  F: hw/*/allwinner-h3*
>  F: include/hw/*/allwinner-h3*
>  F: hw/arm/orangepi.c
> -F: docs/system/orangepi.rst
> +F: docs/system/arm/orangepi.rst
>
>  ARM PrimeCell and CMSDK devices
>  M: Peter Maydell 
> --
> 2.26.2
>
>


Re: [PATCH] hw/sd: Zero out function selection fields before being populated

2020-10-27 Thread Niek Linnenbank
Hello Philippe, Bin,

Thanks for your support on this. I've just tried this patch and
unfortunately it doesn't seem to
resolve the issue, at least on my machine. This is the output that I get
when running the avocado test for NetBSD9.0:

 (5/5)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
|console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
console: DRAM: 1024 MiB
console: Failed to set core voltage! Can't set CPU frequency
console: Trying to boot from MMC1
console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +) Allwinner
Technology
console: CPU:   Allwinner H3 (SUN8I )
...
console: [   1.2957642] sdmmc0: SD card status: 4-bit, C0
console: [   1.3094731] ld0 at sdmmc0:
<0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
console: [   1.3159383] ld0: 1024 MB, 1040 cyl, 32 head, 63 sec, 512
bytes/sect x 2097152 sectors
console: [   1.3763222] ld0: 4-bit width, High-Speed/SDR25, 50.000 MHz
console: [   2.0592109] WARNING: 4 errors while detecting hardware; check
system log.
console: [   2.0693403] boot device: ld0
console: [   2.0798960] root on ld0a dumps on ld0b
console: [   2.0994141] vfs_mountroot: can't open root device
console: [   2.0994141] cannot mount root, error = 6


When starting NetBSD 9.0 manually, it shows clearly that the SD card is
recognized with 1GiB size, also from U-Boot:
$ qemu-system-arm -M orangepi-pc -nographic -nic user -sd ./armv7.img
WARNING: Image format was not specified for './armv7.img' and probing
guessed raw.
 Automatically detecting the format is dangerous for raw images,
write operations on block 0 will be restricted.
 Specify the 'raw' format explicitly to remove the restrictions.

U-Boot SPL 2020.07-00610-g610e1487c8 (Jul 11 2020 - 22:31:58 +0200)
DRAM: 1024 MiB
Failed to set core voltage! Can't set CPU frequency
Trying to boot from MMC1

U-Boot 2020.07-00610-g610e1487c8 (Jul 11 2020 - 22:31:58 +0200) Allwinner
Technology

CPU:   Allwinner H3 (SUN8I )
Model: Xunlong Orange Pi PC
DRAM:  1 GiB
MMC:   mmc@1c0f000: 0
...
Hit any key to stop autoboot:  0
=> mmc info
Device: mmc@1c0f000
Manufacturer ID: aa
OEM: 5859
Name: QEMU!
Bus Speed: 5000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 2.0
High Capacity: No
Capacity: 1 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
=>
=> boot
8846552 bytes read in 931 ms (9.1 MiB/s)
...
[   1.3447558] sdmmc0: SD card status: 4-bit, C0
[   1.3546801] ld0 at sdmmc0: <0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
[   1.3647790] ld0: 1024 MB, 1040 cyl, 32 head, 63 sec, 512 bytes/sect x
2097152 sectors
[   1.4150230] ld0: 4-bit width, High-Speed/SDR25, 50.000 MHz
[   2.0800893] WARNING: 4 errors while detecting hardware; check system log.
[   2.0800893] boot device: ld0
[   2.0900792] root on ld0a dumps on ld0b
[   2.1004160] vfs_mountroot: can't open root device
[   2.1004160] cannot mount root, error = 6
[   2.1004160] root device (default ld0a):


Note that the image has been resized to 2GiB with qemu-img:
$ ls -alh armv7.img
-rw-rw-r-- 1 user user 2,0G okt 28 22:45 armv7.img

The previous patch proposed by Bin did resolve the error ("hw/sd: Fix 2GiB
card CSD register values" ):
 https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg07318.html

Although I see that this patch is now in master
(89c6700fe7eed9195f10055751edbc6d5e7ab940),
can you please confirm that the issue is still present when testing this on
your machine as well?

With kind regards,
Niek


On Mon, Oct 26, 2020 at 9:10 AM Philippe Mathieu-Daudé 
wrote:

> On 10/24/20 3:49 AM, Bin Meng wrote:
> > From: Bin Meng 
> >
> > The function selection fields (399:376) should be zeroed out to
> > prevent leftover from being or'ed into the switch function status
> > data structure.
> >
> > This fixes the boot failure as seen in the acceptance testing on
> > the orangepi target.
> >
> > Fixes: b638627c723a ("hw/sd: Fix incorrect populated function switch
> status data structure")
> > Reported-by: Michael Roth 
> > Signed-off-by: Bin Meng 
> > ---
> >
> >   hw/sd/sd.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> > index c3febed243..bd10ec8fc4 100644
> > --- a/hw/sd/sd.c
> > +++ b/hw/sd/sd.c
> > @@ -824,6 +824,7 @@ static void sd_function_switch(SDState *sd, uint32_t
> arg)
> >   sd->data[12] = 0x80;/* Supported group 1 functions */
> >   sd->data[13] = 0x03;
> >
> > +memset(>data[14], 0, 3);
> >   for (i = 0; i < 6; i ++) {
> >   new_func = (arg >> (i * 4)) & 0x0f;
> >   if (mode && new_func != 0x0f)
> >
>
> Thanks, series applied to sd-next tree.
>
>

-- 
Niek Linnenbank


Re: [PATCH] tests/acceptance: expand Orange Pi PC SD images for NetBSD, Armbian above nearest power of two

2020-10-25 Thread Niek Linnenbank
Hi Philippe,

I've tested the patch by Bin on the 2G & Sd blocksize issue, see my
response there.
   https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg07318.html

So probably we do not need the patch I send here.

Regards,
Niek

On Mon, Oct 26, 2020 at 12:48 AM Niek Linnenbank 
wrote:

> Hello Philippe,
>
> On Sun, Oct 25, 2020 at 1:11 PM Philippe Mathieu-Daudé 
> wrote:
>
>> On 10/25/20 2:31 AM, Philippe Mathieu-Daudé wrote:
>> > Hi Niek,
>> >
>> > On 10/24/20 11:52 PM, Niek Linnenbank wrote:
>> >> The acceptance tests for the Orange Pi PC need to expand the SD card
>> >> images
>> >> to a size which is a power of two. As Qemu uses the size of the SD
>> >> image file
>> >> as well for the size of the emulated SD card, this can sometimes give
>> >> problems
>> >> for guests that assume a certain minimum size of the SD card.
>> >>
>> >> This commit resolves the following acceptance test error for the
>> >> NetBSD 9.0 test
>> >> of the Orange Pi PC by increasing the size of the expanded SD card
>> >> image to two times
>> >> the nearest power of two:
>> >>
>> >> (5/5)
>> >>
>> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
>>
>> >> |console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
>> >>console: DRAM: 1024 MiB
>> >>console: Failed to set core voltage! Can't set CPU frequency
>> >>/console: Trying to boot from MMC1
>> >>console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
>> >> Allwinner Technology
>> >>...
>> >>console: Starting kernel ...
>> >>console: [   1.000] NetBSD/evbarm (fdt) booting ...
>> >>...
>> >>console: [   1.3300167] sdmmc0: SD card status: 4-bit, C0
>> >>console: [   1.3300167] ld0 at sdmmc0:
>> >> <0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
>> >
>> > The test has this comment:
>> >
>> > # This test download a 304MB compressed image and expand it to 2GB
>> >
>> > Once uncompressed the image is ~1.2GB before rounding to 2GB.
>> >
>> >>console: [   1.3430678] ld0: 1024 MB, 1040 cyl, 32 head, 63 sec,
>> >> 512 bytes/sect x 2097152 sectors
>> >
>> > Why the card appears as 1GB?? ^^^
>>
>
> Very well spotted Philippe. Indeed that is strange and is probably also
> why we are getting these issues.
>
>
>> >
>> > Can you try reverting commit 6d2d4069c47?
>> > ("sd: Correct the maximum size of a Standard Capacity SD Memory Card")
>>
>>
> I've tried your suggestion and indeed for the NetBSD 9.0 test, reverting
> 6d2d4069c47 resolves the error for NetBSD 9.0.
> But the armbian tests fail with this output:
>
>  (4/6)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_19_11:
> /console: DRAM: 1024 MiB
> console: Failed to set core voltage! Can't set CPU frequency
> console: Trying to boot from MMC1
> console: U-Boot 2019.04-armbian (Nov 18 2019 - 23:08:35 +0100) Allwinner
> Technology
> console: CPU:   Allwinner H3 (SUN8I )
> ...
> console: Autoboot in 1 seconds, press  to stop
> /console: switch to partitions #0, OK
> console: mmc0 is current device
> ...
> console: Loading Device Tree to 49757000, end 497c6fff ... OK
> console: Starting kernel ...
> console: Uncompressing Linux... done, booting the kernel.
> /console: [  149.045498] debugfs: Directory '1c22c00.codec' with parent
> 'H3 Audio Codec' already present!
> INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
> reached\nOriginal status: ERROR\n
>
> The 'setenv extraargs' isn't done when 'Autoboot in' appears, which is why
> there is much less output from the kernel.
> And it looks like that is because 'U-Boot SPL' isn't printed in the output
> so the python test is still waiting for that.
>
> However with the new patch submitted by Bin just now on the list, all
> tests are passing again like before, including the new 20.08 armbian test:
>   https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg07318.html
>
> (I'll reply to that message shortly)
>
> Regards,
> Niek
>
>
>
>> Now I remember, I hit the similar problem 2 years ago :S
>>
>> See the description of the C_SIZE field in CSD register:
>>
>>"To indicate 2 GByte card, BLOCK_LEN shall be 1024 bytes."
>>
>> This model uses a fixed BLOCK

Re: [PATCH] hw/sd: Fix 2 GiB card CSD register values

2020-10-25 Thread Niek Linnenbank
Hello Bin,

On Sun, Oct 25, 2020 at 4:25 PM Bin Meng  wrote:

> From: Bin Meng 
>
> Per the SD spec, to indicate a 2 GiB card, BLOCK_LEN shall be 1024
> bytes, hence the READ_BL_LEN field in the CSD register shall be 10
> instead of 9.
>
> This fixes the acceptance test error for the NetBSD 9.0 test of the
> Orange Pi PC that has an expanded SD card image of 2 GiB size.
>

Thanks for your quick response on this. I re-ran all the avocado tests
again with this patch added to philips series
and now all tests are passing:

 (4/6)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_19_11:
-console: U-Boot SPL 2019.04-armbian (Nov 18 2019 - 23:08:35 +0100)
console: DRAM: 1024 MiB
console: Failed to set core voltage! Can't set CPU frequency
console: Trying to boot from MMC1
console: U-Boot 2019.04-armbian (Nov 18 2019 - 23:08:35 +0100) Allwinner
Technology
console: CPU:   Allwinner H3 (SUN8I )
...
console: [  OK  ] Listening on Journal Socket.
console: systemd[1]: Starting Create list of required static device nodes
for the current kernel...
console: Starting Create list of required st…ce nodes for the current
kernel...
console: systemd[1]: Starting Load Kernel Modules...
PASS (51.09 s)
 (5/6)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08:
\console: U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
|console: DRAM: 1024 MiB
console: Failed to set core voltage! Can't set CPU frequency
console: Trying to boot from MMC1
console: U-Boot 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200) Allwinner
Technology
...
console: [  OK  ] Listening on /dev/initctl Compatibility Named Pipe.
console: [  OK  ] Listening on Journal Audit Socket.
console: Starting Load Kernel Modules...
PASS (61.05 s)
 (6/6)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
\console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
console: DRAM: 1024 MiB
console: Failed to set core voltage! Can't set CPU frequency
console: Trying to boot from MMC1
console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +) Allwinner
Technology
...
console: [   3.6296962] root on ld0a dumps on ld0b
console: [   3.7250834] root file system type: ffs
console: [   3.7878476] kern.module.path=/stand/evbarm/9.0/modules
-console: Sun Oct 25 23:08:43 UTC 2020
|console: Starting root file system check:
PASS (21.12 s)
RESULTS: PASS 6 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 |
CANCEL 0
JOB TIME   : 183.41 s

I've also booted the Armbian 20.08 image manually and it starts up fine
till the login/setup prompt:

$ qemu-system-arm -M orangepi-pc -nographic -nic user -sd
Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img
...
WARNING: Image format was not specified for
'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img' and probing guessed
raw.
 Automatically detecting the format is dangerous for raw images,
write operations on block 0 will be restricted.
 Specify the 'raw' format explicitly to remove the restrictions.

U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
DRAM: 1024 MiB
Failed to set core voltage! Can't set CPU frequency
Trying to boot from MMC1

U-Boot 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200) Allwinner Technology

CPU:   Allwinner H3 (SUN8I )
Model: Xunlong Orange Pi PC
...
Autoboot in 1 seconds, press  to stop
=> setenv extraargs 'console=ttyS0,115200'
=> boot
...
Uncompressing Linux... done, booting the kernel.
Loading, please wait...
starting version 237
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ...
done.
Begin: Running /scripts/local-premount ... Scanning for Btrfs filesystems
done.
Begin: Will now check root file system ... fsck from util-linux 2.31.1
[/sbin/fsck.ext4 (1) -- /dev/mmcblk0p1] fsck.ext4 -a -C0 /dev/mmcblk0p1
/dev/mmcblk0p1: recovering journal
/dev/mmcblk0p1: clean, 38118/117504 files, 230861/497048 blocks
done.
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.

Welcome to Armbian 20.08.1 Bionic!
...
[  OK  ] Created slice system-getty.slice.
[  OK  ] Started Getty on tty1.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started Network Manager Script Dispatcher Service.

Armbian 20.08.1 Bionic ttyS0

orangepipc login:

>From these tests it looks to me that the change is working as expected. I'm
not an expert on SD internals
so perhaps Philippe would like to give more detailed review comments on the
code itself.

So for the Orange Pi PC machine & acceptance tests:

Tested-by: Niek Linnenbank 

Regards,
Niek


>
> Fixes: 6d2d4069c47e ("hw/sd: Correct the maximum size of a Standard
> Capacity SD Memory Card")
> Reported-by: Niek Linnenbank 
> Signed-off-by: Bin Meng 
> ---
>
>  hw/sd/sd.c | 15 +++
>  1 file changed, 11 i

Re: [PATCH] tests/acceptance: expand Orange Pi PC SD images for NetBSD, Armbian above nearest power of two

2020-10-25 Thread Niek Linnenbank
Hello Philippe,

On Sun, Oct 25, 2020 at 1:11 PM Philippe Mathieu-Daudé 
wrote:

> On 10/25/20 2:31 AM, Philippe Mathieu-Daudé wrote:
> > Hi Niek,
> >
> > On 10/24/20 11:52 PM, Niek Linnenbank wrote:
> >> The acceptance tests for the Orange Pi PC need to expand the SD card
> >> images
> >> to a size which is a power of two. As Qemu uses the size of the SD
> >> image file
> >> as well for the size of the emulated SD card, this can sometimes give
> >> problems
> >> for guests that assume a certain minimum size of the SD card.
> >>
> >> This commit resolves the following acceptance test error for the
> >> NetBSD 9.0 test
> >> of the Orange Pi PC by increasing the size of the expanded SD card
> >> image to two times
> >> the nearest power of two:
> >>
> >> (5/5)
> >>
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
>
> >> |console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
> >>console: DRAM: 1024 MiB
> >>console: Failed to set core voltage! Can't set CPU frequency
> >>/console: Trying to boot from MMC1
> >>console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
> >> Allwinner Technology
> >>...
> >>console: Starting kernel ...
> >>console: [   1.000] NetBSD/evbarm (fdt) booting ...
> >>...
> >>console: [   1.3300167] sdmmc0: SD card status: 4-bit, C0
> >>console: [   1.3300167] ld0 at sdmmc0:
> >> <0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
> >
> > The test has this comment:
> >
> > # This test download a 304MB compressed image and expand it to 2GB
> >
> > Once uncompressed the image is ~1.2GB before rounding to 2GB.
> >
> >>console: [   1.3430678] ld0: 1024 MB, 1040 cyl, 32 head, 63 sec,
> >> 512 bytes/sect x 2097152 sectors
> >
> > Why the card appears as 1GB?? ^^^
>

Very well spotted Philippe. Indeed that is strange and is probably also why
we are getting these issues.


> >
> > Can you try reverting commit 6d2d4069c47?
> > ("sd: Correct the maximum size of a Standard Capacity SD Memory Card")
>
>
I've tried your suggestion and indeed for the NetBSD 9.0 test, reverting
6d2d4069c47 resolves the error for NetBSD 9.0.
But the armbian tests fail with this output:

 (4/6)
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_19_11:
/console: DRAM: 1024 MiB
console: Failed to set core voltage! Can't set CPU frequency
console: Trying to boot from MMC1
console: U-Boot 2019.04-armbian (Nov 18 2019 - 23:08:35 +0100) Allwinner
Technology
console: CPU:   Allwinner H3 (SUN8I )
...
console: Autoboot in 1 seconds, press  to stop
/console: switch to partitions #0, OK
console: mmc0 is current device
...
console: Loading Device Tree to 49757000, end 497c6fff ... OK
console: Starting kernel ...
console: Uncompressing Linux... done, booting the kernel.
/console: [  149.045498] debugfs: Directory '1c22c00.codec' with parent 'H3
Audio Codec' already present!
INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
reached\nOriginal status: ERROR\n

The 'setenv extraargs' isn't done when 'Autoboot in' appears, which is why
there is much less output from the kernel.
And it looks like that is because 'U-Boot SPL' isn't printed in the output
so the python test is still waiting for that.

However with the new patch submitted by Bin just now on the list, all tests
are passing again like before, including the new 20.08 armbian test:
  https://lists.gnu.org/archive/html/qemu-devel/2020-10/msg07318.html

(I'll reply to that message shortly)

Regards,
Niek



> Now I remember, I hit the similar problem 2 years ago :S
>
> See the description of the C_SIZE field in CSD register:
>
>"To indicate 2 GByte card, BLOCK_LEN shall be 1024 bytes."
>
> This model uses a fixed BLOCK_LEN = 512 bytes.
>
> >
> >>console: [   1.4102580] ld0: 4-bit width, High-Speed/SDR25, 50.000
> MHz
> >>console: [   2.0674392] WARNING: 4 errors while detecting hardware;
> >> check system log.
> >>console: [   2.0674392] boot device: ld0
> >>console: [   2.0775401] root on ld0a dumps on ld0b
> >>console: [   2.0977679] vfs_mountroot: can't open root device
> >>console: [   2.0977679] cannot mount root, error = 6
> >>INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred:
> >> Timeout reached.
> >>
> >> Signed-off-by: Niek Linnenbank 
> >> Based-on: ("[RFC PATCH 0/4] tests/acceptance: Test U-Boot/Linux from
> >> Armbian 20.08 on Orange Pi PC")
> >> ---
> >>   tests/acceptance/boot_linux_console.py | 10 +-
> >>   1 file changed, 5 insertions(+), 5 deletions(-)
> >
>


-- 
Niek Linnenbank


Re: [RFC PATCH 4/4] tests/acceptance: Test U-Boot/Linux from Armbian 20.08 on Orange Pi PC

2020-10-25 Thread Niek Linnenbank
Hi Bin,

On Sun, Oct 25, 2020 at 3:17 AM Bin Meng  wrote:

> Hi Niek,
>
> On Sun, Oct 25, 2020 at 5:01 AM Niek Linnenbank
>  wrote:
> >
> > Hi Philippe,
> >
> > I have ran this series with the new Armbian 20.08 test and noticed this
> failure:
> >
> > -console: /dev/mmcblk0p1: The filesystem size (according to the
> superrandom: fast init done
> > console: block) is 264192 blocks
> > console: The physical size of the device is 261120 blocks
> > console: Either the superblock or the partition table is likely to be
> corrupt!
> > console: /dev/mmcblk0p1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
> > console: (i.e., without -a or -p options)
> > console: fsck exited with status code 4
> > console: done.
> > console: Failure: File system check of the root filesystem failed
> > console: The root filesystem on /dev/mmcblk0p1 requires a manual fsck
> > |console: BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3.2) built-in shell
> (ash)
> > console: Enter 'help' for a list of built-in commands.
> > INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
> reached\nOriginal status: ERROR\n{'name':
> '5-tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic_20_08',
> 'logdir': '/home/fox/avocado/job-results/job-2020-10-24T22.25-39... (90.47
> s)
> >
> > When I run the image manually I get the same error, but only if I resize
> the 20.08 image to 2G. If resized to 4G, the
> > 20.08 image boots fine.
> >
> > Additionally, I noticed that the NetBSD 9.0 test has the same problem,
> even in current master (4c5b97bfd0dd54dc27717ae8d1cd10e14eef1430):
> >
> >(5/5)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
> |console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
> > console: DRAM: 1024 MiB
> > console: Failed to set core voltage! Can't set CPU frequency
> > /console: Trying to boot from MMC1
> > console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +) Allwinner
> Technology
> > ...
> > console: Starting kernel ...
> > console: [   1.000] NetBSD/evbarm (fdt) booting ...
> > ...
> > console: [   1.3300167] sdmmc0: SD card status: 4-bit, C0
> > console: [   1.3300167] ld0 at sdmmc0:
> <0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
> > console: [   1.3430678] ld0: 1024 MB, 1040 cyl, 32 head, 63 sec, 512
> bytes/sect x 2097152 sectors
> > console: [   1.4102580] ld0: 4-bit width, High-Speed/SDR25, 50.000 MHz
> > console: [   2.0674392] WARNING: 4 errors while detecting hardware;
> check system log.
> > console: [   2.0674392] boot device: ld0
> > console: [   2.0775401] root on ld0a dumps on ld0b
> > console: [   2.0977679] vfs_mountroot: can't open root device
> > console: [   2.0977679] cannot mount root, error = 6
> > INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout
> reached\nOriginal status: ERROR\n{'name':
> '5-tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9',
> 'l>
> >
> > To resolve this error, I made a small patch that expands the SD image in
> both tests to the next power-of-two multiplied by 2:
> >
> > diff --git a/tests/acceptance/boot_linux_console.py
> b/tests/acceptance/boot_linux_console.py
> > index b604cfe7da..40835904bb 100644
> > --- a/tests/acceptance/boot_linux_console.py
> > +++ b/tests/acceptance/boot_linux_console.py
> > @@ -35,11 +35,11 @@ def pow2ceil(x):
> >  return 1 if x == 0 else 2**(x - 1).bit_length()
> >
> >  """
> > -Expand file size to next power of 2
> > +Expand file size to next power of 2 or higher
> >  """
> > -def image_pow2ceil_expand(path):
> > +def image_pow2ceil_expand(path, multiply_factor = 1):
> >  size = os.path.getsize(path)
> > -size_aligned = pow2ceil(size)
> > +size_aligned = pow2ceil(size) * multiply_factor
> >  if size != size_aligned:
> >  with open(path, 'ab+') as fd:
> >  fd.truncate(size_aligned)
> > @@ -850,7 +850,7 @@ class BootLinuxConsole(LinuxKernelTest):
> >  image_path_xz = self.fetch_asset(image_url,
> asset_hash=image_hash,
> >   algorithm='sha256')
> >  image_path = archive.extract(image_path_xz, self.workdir)
> > -image_pow2ceil_expand(image_path)
> > +image_pow2ceil_expand(image_path, 2)
> >
> >  self.do_test_arm_orangepi_uboot_armbian(image_path)
> >
> > @@ -879,7 +879,7 @@ class BootLinuxCon

[PATCH] tests/acceptance: expand Orange Pi PC SD images for NetBSD, Armbian above nearest power of two

2020-10-24 Thread Niek Linnenbank
The acceptance tests for the Orange Pi PC need to expand the SD card images
to a size which is a power of two. As Qemu uses the size of the SD image file
as well for the size of the emulated SD card, this can sometimes give problems
for guests that assume a certain minimum size of the SD card.

This commit resolves the following acceptance test error for the NetBSD 9.0 test
of the Orange Pi PC by increasing the size of the expanded SD card image to two 
times
the nearest power of two:

   (5/5) 
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
 |console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +)
  console: DRAM: 1024 MiB
  console: Failed to set core voltage! Can't set CPU frequency
  /console: Trying to boot from MMC1
  console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +) Allwinner 
Technology
  ...
  console: Starting kernel ...
  console: [   1.000] NetBSD/evbarm (fdt) booting ...
  ...
  console: [   1.3300167] sdmmc0: SD card status: 4-bit, C0
  console: [   1.3300167] ld0 at sdmmc0: 
<0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
  console: [   1.3430678] ld0: 1024 MB, 1040 cyl, 32 head, 63 sec, 512 
bytes/sect x 2097152 sectors
  console: [   1.4102580] ld0: 4-bit width, High-Speed/SDR25, 50.000 MHz
  console: [   2.0674392] WARNING: 4 errors while detecting hardware; check 
system log.
  console: [   2.0674392] boot device: ld0
  console: [   2.0775401] root on ld0a dumps on ld0b
  console: [   2.0977679] vfs_mountroot: can't open root device
  console: [   2.0977679] cannot mount root, error = 6
  INTERRUPTED: Test interrupted by SIGTERM\nRunner error occurred: Timeout 
reached.

Signed-off-by: Niek Linnenbank 
Based-on: ("[RFC PATCH 0/4] tests/acceptance: Test U-Boot/Linux from Armbian 
20.08 on Orange Pi PC")
---
 tests/acceptance/boot_linux_console.py | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/acceptance/boot_linux_console.py 
b/tests/acceptance/boot_linux_console.py
index b604cfe7da..40835904bb 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -35,11 +35,11 @@ def pow2ceil(x):
 return 1 if x == 0 else 2**(x - 1).bit_length()
 
 """
-Expand file size to next power of 2
+Expand file size to next power of 2 or higher
 """
-def image_pow2ceil_expand(path):
+def image_pow2ceil_expand(path, multiply_factor = 1):
 size = os.path.getsize(path)
-size_aligned = pow2ceil(size)
+size_aligned = pow2ceil(size) * multiply_factor
 if size != size_aligned:
 with open(path, 'ab+') as fd:
 fd.truncate(size_aligned)
@@ -850,7 +850,7 @@ class BootLinuxConsole(LinuxKernelTest):
 image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
  algorithm='sha256')
 image_path = archive.extract(image_path_xz, self.workdir)
-image_pow2ceil_expand(image_path)
+image_pow2ceil_expand(image_path, 2)
 
 self.do_test_arm_orangepi_uboot_armbian(image_path)
 
@@ -879,7 +879,7 @@ class BootLinuxConsole(LinuxKernelTest):
 image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash)
 image_path = os.path.join(self.workdir, 'armv7.img')
 archive.gzip_uncompress(image_path_gz, image_path)
-image_pow2ceil_expand(image_path)
+image_pow2ceil_expand(image_path, 2)
 image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path
 
 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 
conv=notrunc
-- 
2.25.1




Re: Should we keep using Avocado for functional testing? (was: Re: [PULL 22/23] hw/sd: Fix incorrect populated function switch status data structure)

2020-10-24 Thread Niek Linnenbank
Hi Philippe,

On Fri, Oct 23, 2020 at 11:34 AM Philippe Mathieu-Daudé 
wrote:

> On 10/23/20 11:23 AM, Philippe Mathieu-Daudé wrote:
> > On 10/23/20 4:02 AM, Bin Meng wrote:
> >> Hi Niek,
> >>
> >> On Thu, Oct 22, 2020 at 11:20 PM Niek Linnenbank
> >>  wrote:
> >>>
> >>> Hi Bin, Philippe,
> >>>
> >>> If im correct the acceptance tests for orange pi need to be run with
> >>> a flag ARMBIAN_ARTIFACTS_CACHED set that explicitly allows them to be
> >>> run using the armbian mirror. So if you pass that flag on the same
> >>> command that Philippe gave, the rests should run.
> >>
> >> Thank you for the hints. Actually I noticed the environment variable
> >> ARMBIAN_ARTIFACTS_CACHED when looking at the test codes, but after I
> >> turned on the flag it still could not download the test asset from the
> >> apt.armbian.com website.
> >
> > This patch could help you, but it use a different image [*]:
> > https://www.mail-archive.com/qemu-devel@nongnu.org/msg737760.html
> > (I haven't tested the image yet but I assume the same bug is present).
> >
> >>
> >>> I have a follow up question and Im interested to hear your opinion on
> >>> that Philippe. Should we perhaps update the orange pi tests (and
> >>> maybe others) so they use a reliable mirror that we can control, for
> >>> example a github repo? I would be happy to create a repo for that, at
> >>> least for the orange pi tests. But maybe there is already something
> >>> planned as a more general solution for artifacts of other machines as
> >>> well?
> >
> > This is a technical debt between the Avocado and QEMU communities
> > (or a misunderstanding?).
> >
> > QEMU community understood the Avocado caching would be an helpful
> > feature, but it ended being more of a problem.
> >
> >
> > I.e. here Niek, Michael Roth and myself still have the image cached,
> > so we can keep running the tests committed to the repository. You
> > Bin can not, as the armbian mirror is not stable and remove the old
> > image.
> >
> > The old image (Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img)
> > has been manually tested by Niek and myself, I enabled tracing and
> > look at the SD packets for some time, was happy how the model worked
> > and decided we should keep running a test with this particular image.
> >
> > Armbian released new images, in particular the one Cleber sent in [*]:
> > Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz. While it might
> > work similarly, I haven't tested it, and don't have time to do again
> > the same audit.
> >  From my experience with the Raspberry Pi, these images never work the
> > same way, as the Linux kernel evolves quickly with these kinda recent
> > embedded boards. The QEMU raspi models have to emulate new devices
> > (or complete current ones) every years, because Linux started to use
> > a device differently, or started to use a part of the SoC that was not
> > used before. Either the kernel doesn't boot, or there are side-effect
> > later when userspace program is executed. PITA to debug TBH. For this
> > reason I disagree with updating test images to the latest releases.
>

Yes, I agree that we should try to use stable artifacts for the acceptance
tests.


> >
> > It would be nice to know QEMU works with the latest Armbian, but
> > nobody popped up on the mailing list asking for it. I am personally
> > happy enough using the 19.11 release for now.
>
> Back to the cache problem, I started to ask 2 years ago,
> https://www.mail-archive.com/avocado-devel@redhat.com/msg00860.html
> note this is the exact situation we are having:
>
>  >> - What will happens if I add tests downloading running on their
>  >> compiled u-boot
>  >>
> (
> https://downloads.gumstix.com/images/angstrom/developer/2012-01-22-1750/u-boot.bin
> )
>  >> and the company decides to remove this old directory?
>  >> Since sometimes old open-source software are hard to rebuild with
>  >> recent compilers, should we consider to use a public storage to keep
>  >> open-source (signed) blobs we can use for integration testing?
>  >
>  > For Avocado-VT, there are the JeOS images[1], which we keep on a test
>  > "assets" directory.  We have a lot of storage/bandwidth availability,
>  > so it can be used for other assets proven to be necessary for tests.
>  >
>  > As long as distribution rights and licensing are not issues, we can
> 

Re: [RFC PATCH 1/4] Revert "hw/sd: Fix incorrect populated function switch status data structure"

2020-10-24 Thread Niek Linnenbank
Tested-by: Niek Linnenbank 
Reviewed-by: Niek Linnenbank 

On Fri, Oct 23, 2020 at 3:18 PM Philippe Mathieu-Daudé 
wrote:

> This reverts commit b638627c723a8d0d2bb73489bc6bf9ff09b8d53a.
>
> Currently booting U-Boot on the Orange Pi PC we get:
>
>   console: U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
>   ...
>   console: Autoboot in 1 seconds, press  to stop
>   console: =>
>   console: => setenv extraargs 'printk.time=0 console=ttyS0,115200
> loglevel=7 nosmp systemd.default_timeout_start_sec=9000
> systemd.mask=armbian-zram-config.service
> systemd.mask=armbian-ramlog.service'
>   console: => boot
>   console: unable to select a mode
>   console: Device 0: unknown device
>   console: BOOTP broadcast 1
>   console: DHCP client bound to address 10.0.2.15 (12 ms)
>   console: *** Warning: no boot file name; using '0A00020F.img'
>   console: Using ethernet@1c3 device
>   console: TFTP from server 10.0.2.2; our IP address is 10.0.2.15
>   console: Filename '0A00020F.img'.
>   console: Load address: 0x4200
>   console: Loading: *
>   console: TFTP error: 'Access violation' (2)
>   console: Not retrying...
>   console: missing environment variable: pxeuuid
>   console: missing environment variable: bootfile
>   ...
>
> With commit b638627c723 reverted:
>
>   console: U-Boot SPL 2020.04-armbian (Sep 02 2020 - 10:16:13 +0200)
>   ...
>   console: Autoboot in 1 seconds, press  to stop
>   console: =>
>   console: => setenv extraargs 'printk.time=0 console=ttyS0,115200
> loglevel=7 nosmp systemd.default_timeout_start_sec=9000
> systemd.mask=armbian-zram-config.service
> systemd.mask=armbian-ramlog.service'
>   console: => boot
>   console: switch to partitions #0, OK
>   console: mmc0 is current device
>   console: Scanning mmc 0:1...
>   console: Found U-Boot script /boot/boot.scr
>   console: 3967 bytes read in 16 ms (241.2 KiB/s)
>   console: ## Executing script at 4310
>   console: U-boot loaded from SD
>   console: Boot script loaded from mmc
>   console: 153 bytes read in 10 ms (14.6 KiB/s)
>   console: 11185760 bytes read in 6698 ms (1.6 MiB/s)
>   console: 7788240 bytes read in 2966 ms (2.5 MiB/s)
>   console: Found mainline kernel configuration
>   console: 32121 bytes read in 50 ms (627 KiB/s)
>   console: 4185 bytes read in 23 ms (176.8 KiB/s)
>   console: Applying kernel provided DT fixup script (sun8i-h3-fixup.scr)
>   console: ## Executing script at 4500
>   console: ## Loading init Ramdisk from Legacy Image at 4330 ...
>   console: Image Name:   uInitrd
>   console: Image Type:   ARM Linux RAMDisk Image (gzip compressed)
>   console: Data Size:11185696 Bytes = 10.7 MiB
>   console: Load Address: 
>   console: Entry Point:  
>   console: Verifying Checksum ... OK
>   console: ## Flattened Device Tree blob at 4300
>   console: Booting using the fdt blob at 0x4300
>   console: Loading Ramdisk to 49555000, end 49fffe20 ... OK
>   console: Loading Device Tree to 494e4000, end 49554fff ... OK
>   console: Starting kernel ...
>   console: Uncompressing Linux... done, booting the kernel.
>
> Fixes: b638627c723 ("hw/sd: Fix incorrect populated function switch status
> data structure")
> Reported-by: Michael Roth 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  hw/sd/sd.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index c3febed2434..c17197785bc 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -823,12 +823,11 @@ static void sd_function_switch(SDState *sd, uint32_t
> arg)
>  sd->data[11] = 0x43;
>  sd->data[12] = 0x80;   /* Supported group 1 functions */
>  sd->data[13] = 0x03;
> -
>  for (i = 0; i < 6; i ++) {
>  new_func = (arg >> (i * 4)) & 0x0f;
>  if (mode && new_func != 0x0f)
>  sd->function_group[i] = new_func;
> -sd->data[16 - (i >> 1)] |= new_func << ((i % 2) * 4);
> +sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4);
>  }
>  memset(>data[17], 0, 47);
>  stw_be_p(sd->data + 64, sd_crc16(sd->data, 64));
> --
> 2.26.2
>
>

-- 
Niek Linnenbank


Re: [RFC PATCH 2/4] tests/acceptance: Allow running Orange Pi test using cached artifacts

2020-10-24 Thread Niek Linnenbank
As a temporary solution this should be fine, until we have decided on which
reliable storage location to use.

Reviewed-by: Niek Linnenbank 

On Fri, Oct 23, 2020 at 3:18 PM Philippe Mathieu-Daudé 
wrote:

> Unfortunately the Armbian 19.11.3 image has been removed from the
> dl.armbian.com file server. Developers having the artifact cached
> can still run the test. Allow them to, until we find a proper
> solution to share binaries with the whole community.
>
> This avoids (when file manually added to cache):
>
>   BootLinuxConsole.test_arm_orangepi_bionic_19_11: CANCEL: Missing asset
> https://dl.armbian.com/orangepipc/archive/Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z
> (1.06 s)
>
> Reported-by: Bin Meng 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  tests/acceptance/boot_linux_console.py | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tests/acceptance/boot_linux_console.py
> b/tests/acceptance/boot_linux_console.py
> index 0118ed59156..032ac85978c 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -780,6 +780,8 @@ def test_arm_orangepi_sd(self):
>  # Wait for VM to shut down gracefully
>  self.vm.wait()
>
> +@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
> +'Test artifacts fetched from unreliable dl.armbian.com')
>  @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage
> limited')
>  @skipUnless(P7ZIP_AVAILABLE, '7z not installed')
>  def test_arm_orangepi_bionic(self):
> --
> 2.26.2
>
>

-- 
Niek Linnenbank


Re: [RFC PATCH 4/4] tests/acceptance: Test U-Boot/Linux from Armbian 20.08 on Orange Pi PC

2020-10-24 Thread Niek Linnenbank
 Philippe Mathieu-Daudé 
wrote:

> Test U-Boot and Linux on the recent Armbian release 20.08.
>
> Suggested-by: Cleber Rosa 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
>  tests/acceptance/boot_linux_console.py | 25 +
>  1 file changed, 25 insertions(+)
>
> diff --git a/tests/acceptance/boot_linux_console.py
> b/tests/acceptance/boot_linux_console.py
> index 803b4512a26..b604cfe7dab 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -829,6 +829,31 @@ def test_arm_orangepi_bionic_19_11(self):
>
>  self.do_test_arm_orangepi_uboot_armbian(image_path)
>
> +@skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
> +'Test artifacts fetched from unreliable apt.armbian.com')
> +@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage
> limited')
> +def test_arm_orangepi_bionic_20_08(self):
> +"""
> +:avocado: tags=arch:arm
> +:avocado: tags=machine:orangepi-pc
> +:avocado: tags=device:sd
> +"""
> +
> +# This test download a 275 MiB compressed image and expand it
> +# to 1036 MiB, but the underlying filesystem is 1552 MiB...
> +# As we expand it to 2 GiB we are safe.
> +
> +image_url = ('https://dl.armbian.com/orangepipc/archive/'
> +
>  'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
> +image_hash = ('b4d6775f5673486329e45a0586bf06b6'
> +  'dbe792199fd182ac6b9c7bb6c7d3e6dd')
> +image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
> + algorithm='sha256')
> +image_path = archive.extract(image_path_xz, self.workdir)
> +image_pow2ceil_expand(image_path)
> +
> +self.do_test_arm_orangepi_uboot_armbian(image_path)
> +
>  @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage
> limited')
>  def test_arm_orangepi_uboot_netbsd9(self):
>  """
> --
> 2.26.2
>
>

-- 
Niek Linnenbank


Re: [PULL 22/23] hw/sd: Fix incorrect populated function switch status data structure

2020-10-22 Thread Niek Linnenbank
Hi Bin, Philippe,

If im correct the acceptance tests for orange pi need to be run with a flag
ARMBIAN_ARTIFACTS_CACHED set that explicitly allows them to be run using
the armbian mirror. So if you pass that flag on the same command that
Philippe gave, the rests should run.

I have a follow up question and Im interested to hear your opinion on that
Philippe. Should we perhaps update the orange pi tests (and maybe others)
so they use a reliable mirror that we can control, for example a github
repo? I would be happy to create a repo for that, at least for the orange
pi tests. But maybe there is already something planned as a more general
solution for artifacts of other machines as well?

regards,
Niek

Op do 22 okt. 2020 16:47 schreef Bin Meng :

> Hi Philippe,
>
> On Wed, Oct 21, 2020 at 6:07 PM Philippe Mathieu-Daudé 
> wrote:
> >
> > On 10/21/20 11:57 AM, Bin Meng wrote:
> > > Hi Philippe,
> > >
> > > On Tue, Oct 20, 2020 at 11:18 PM Philippe Mathieu-Daudé <
> f4...@amsat.org> wrote:
> > >>
> > >> Hi Bin,
> > >>
> > >> On 8/21/20 7:29 PM, Philippe Mathieu-Daudé wrote:
> > >>> From: Bin Meng 
> > >>>
> > >>> At present the function switch status data structure bit [399:376]
> > >>> are wrongly pupulated. These 3 bytes encode function switch status
> > >>> for the 6 function groups, with 4 bits per group, starting from
> > >>> function group 6 at bit 399, then followed by function group 5 at
> > >>> bit 395, and so on.
> > >>>
> > >>> However the codes mistakenly fills in the function group 1 status
> > >>> at bit 399. This fixes the code logic.
> > >>>
> > >>> Fixes: a1bb27b1e9 ("SD card emulation (initial implementation)")
> > >>> Signed-off-by: Bin Meng 
> > >>> Reviewed-by: Philippe Mathieu-Daudé 
> > >>> Tested-by: Sai Pavan Boddu 
> > >>> Message-Id: <1598021136-49525-1-git-send-email-bmeng...@gmail.com>
> > >>> Signed-off-by: Philippe Mathieu-Daudé 
> > >>> ---
> > >>>hw/sd/sd.c | 3 ++-
> > >>>1 file changed, 2 insertions(+), 1 deletion(-)
> > >>>
> > >>> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> > >>> index 7c9d956f113..805e21fc883 100644
> > >>> --- a/hw/sd/sd.c
> > >>> +++ b/hw/sd/sd.c
> > >>> @@ -807,11 +807,12 @@ static void sd_function_switch(SDState *sd,
> uint32_t arg)
> > >>>sd->data[11] = 0x43;
> > >>>sd->data[12] = 0x80;/* Supported group 1 functions */
> > >>>sd->data[13] = 0x03;
> > >>> +
> > >>>for (i = 0; i < 6; i ++) {
> > >>>new_func = (arg >> (i * 4)) & 0x0f;
> > >>>if (mode && new_func != 0x0f)
> > >>>sd->function_group[i] = new_func;
> > >>> -sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4);
> > >>> +sd->data[16 - (i >> 1)] |= new_func << ((i % 2) * 4);
> > >>
> > >> This patch broke the orangepi machine, reproducible running
> > >> test_arm_orangepi_bionic:
> > >> https://www.mail-archive.com/qemu-devel@nongnu.org/msg739449.html
> > >>
> > >> Can you have a look?
> > >
> > > Yes, I can take a look. Could you please send more details on how to
> > > run "test_arm_orangepi_bionic"?
> >
> > Looking at the previous link, I think this should work:
> >
> > $ make check-venv qemu-system-arm
> > $ AVOCADO_ALLOW_LARGE_STORAGE=1 \
> >tests/venv/bin/python -m \
> >  avocado --show=app,console run \
> >run -t machine:orangepi-pc tests/acceptance
> >
>
> I tried the above command in my build tree, and got:
>
> avocado run: error: unrecognized arguments: tests/acceptance
> Perhaps a plugin is missing; run 'avocado plugins' to list the installed
> ones
>
> I switched to `make check-acceptance` which seems to work, however not
> for orangepi-pc related tests?
>
>  (09/32)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
> SKIP: Test artifacts fetched from unreliable apt.armbian.com
>  (10/32)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_initrd:
> SKIP: Test artifacts fetched from unreliable apt.armbian.com
>  (11/32)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_sd:
> SKIP: Test artifacts fetched from unreliable apt.armbian.com
>  (12/32)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_bionic:
> SKIP: storage limited
>  (13/32)
> tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi_uboot_netbsd9:
> SKIP: storage limited
>
> Any ideas?
>
> Regards,
> Bin
>


Re: [RFC PATCH] contrib/gitdm: Add more individual contributors

2020-10-04 Thread Niek Linnenbank
Acked-by: Niek Linnenbank 


Op zo 4 okt. 2020 20:25 schreef Philippe Mathieu-Daudé :

> These individual contributors have a number of contributions,
> add them to the 'individual' group map.
>
> Cc: Ahmed Karaman 
> Cc: Aleksandar Markovic 
> Cc: Alistair Francis 
> Cc: Artyom Tarasenko 
> Cc: David Carlier 
> Cc: Finn Thain 
> Cc: Guenter Roeck 
> Cc: Helge Deller 
> Cc: Hervé Poussineau 
> Cc: James Hogan 
> Cc: Jean-Christophe Dubois 
> Cc: Kővágó Zoltán 
> Cc: Laurent Vivier 
> Cc: Michael Rolnik 
> Cc: Niek Linnenbank 
> Cc: Paul Burton 
> Cc: Paul Zimmerman 
> Cc: Stefan Weil 
> Cc: Subbaraya Sundeep 
> Cc: Sven Schnelle 
> Cc: Thomas Huth 
> Cc: Volker Rümelin 
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> To the developers Cc'ed: If you agree with your entry, please
> reply with a Reviewed-by/Acked-by tag. If you disagree or doesn't
> care, please either reply with Nack-by or ignore this patch.
> I'll repost in 2 weeks as formal patch (not RFC) with only the
> entries acked by their author.
> ---
>  contrib/gitdm/group-map-individuals | 22 ++
>  contrib/gitdm/group-map-redhat  |  1 -
>  2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/gitdm/group-map-individuals
> b/contrib/gitdm/group-map-individuals
> index cf8a2ce367..b478fd4576 100644
> --- a/contrib/gitdm/group-map-individuals
> +++ b/contrib/gitdm/group-map-individuals
> @@ -16,3 +16,25 @@ aurel...@aurel32.net
>  bala...@eik.bme.hu
>  e.emanuelegiuse...@gmail.com
>  andrew.smir...@gmail.com
> +s...@weilnetz.de
> +h...@tuxfamily.org
> +laur...@vivier.eu
> +atar4q...@gmail.com
> +hpous...@reactos.org
> +del...@gmx.de
> +alist...@alistair23.me
> +fth...@telegraphics.com.au
> +sv...@stackframe.org
> +aleksandar.qemu.de...@gmail.com
> +jho...@kernel.org
> +paulbur...@kernel.org
> +vr_q...@t-online.de
> +nieklinnenb...@gmail.com
> +devne...@gmail.com
> +j...@tribudubois.net
> +dirty.ice...@gmail.com
> +mrol...@gmail.com
> +pauld...@gmail.com
> +li...@roeck-us.net
> +sundeep.l...@gmail.com
> +ahmedkhaledkara...@gmail.com
> diff --git a/contrib/gitdm/group-map-redhat
> b/contrib/gitdm/group-map-redhat
> index d15db2d35e..4a8ca84b36 100644
> --- a/contrib/gitdm/group-map-redhat
> +++ b/contrib/gitdm/group-map-redhat
> @@ -3,6 +3,5 @@
>  #
>
>  da...@gibson.dropbear.id.au
> -laur...@vivier.eu
>  p...@fedoraproject.org
>  arm...@pond.sub.org
> --
> 2.26.2
>
>


Re: [PATCH v2 05/58] allwinner-h3: Rename memmap enum constants

2020-08-21 Thread Niek Linnenbank
Op do 20 aug. 2020 02:12 schreef Eduardo Habkost :

> Some of the enum constant names conflict with the QOM type check
> macros (AW_H3_CCU, AW_H3_SYSCTRL).  This needs to be addressed to
> allow us to transform the QOM type check macros into functions
> generated by OBJECT_DECLARE_TYPE().
>
> Rename all the constants to AW_H3_DEV_*, to avoid conflicts.
>
> Reviewed-by: Daniel P. Berrangé 
>
Reviewed-by: Niek Linnenbank 

> Signed-off-by: Eduardo Habkost 
> ---
> Changes v1 -> v2:
> * Added more details to commit message
>
> ---
> Cc: Beniamino Galvani 
> Cc: Peter Maydell 
> Cc: Niek Linnenbank 
> Cc: qemu-...@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---
>  include/hw/arm/allwinner-h3.h |  62 -
>  hw/arm/allwinner-h3.c | 124 +-
>  hw/arm/orangepi.c |   6 +-
>  3 files changed, 96 insertions(+), 96 deletions(-)
>
> diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h
> index 82e4e59216..626139dcb3 100644
> --- a/include/hw/arm/allwinner-h3.h
> +++ b/include/hw/arm/allwinner-h3.h
> @@ -61,37 +61,37 @@
>   * @see AwH3State
>   */
>  enum {
> -AW_H3_SRAM_A1,
> -AW_H3_SRAM_A2,
> -AW_H3_SRAM_C,
> -AW_H3_SYSCTRL,
> -AW_H3_MMC0,
> -AW_H3_SID,
> -AW_H3_EHCI0,
> -AW_H3_OHCI0,
> -AW_H3_EHCI1,
> -AW_H3_OHCI1,
> -AW_H3_EHCI2,
> -AW_H3_OHCI2,
> -AW_H3_EHCI3,
> -AW_H3_OHCI3,
> -AW_H3_CCU,
> -AW_H3_PIT,
> -AW_H3_UART0,
> -AW_H3_UART1,
> -AW_H3_UART2,
> -AW_H3_UART3,
> -AW_H3_EMAC,
> -AW_H3_DRAMCOM,
> -AW_H3_DRAMCTL,
> -AW_H3_DRAMPHY,
> -AW_H3_GIC_DIST,
> -AW_H3_GIC_CPU,
> -AW_H3_GIC_HYP,
> -AW_H3_GIC_VCPU,
> -AW_H3_RTC,
> -AW_H3_CPUCFG,
> -AW_H3_SDRAM
> +AW_H3_DEV_SRAM_A1,
> +AW_H3_DEV_SRAM_A2,
> +AW_H3_DEV_SRAM_C,
> +AW_H3_DEV_SYSCTRL,
> +AW_H3_DEV_MMC0,
> +AW_H3_DEV_SID,
> +AW_H3_DEV_EHCI0,
> +AW_H3_DEV_OHCI0,
> +AW_H3_DEV_EHCI1,
> +AW_H3_DEV_OHCI1,
> +AW_H3_DEV_EHCI2,
> +AW_H3_DEV_OHCI2,
> +AW_H3_DEV_EHCI3,
> +AW_H3_DEV_OHCI3,
> +AW_H3_DEV_CCU,
> +AW_H3_DEV_PIT,
> +AW_H3_DEV_UART0,
> +AW_H3_DEV_UART1,
> +AW_H3_DEV_UART2,
> +AW_H3_DEV_UART3,
> +AW_H3_DEV_EMAC,
> +AW_H3_DEV_DRAMCOM,
> +AW_H3_DEV_DRAMCTL,
> +AW_H3_DEV_DRAMPHY,
> +AW_H3_DEV_GIC_DIST,
> +AW_H3_DEV_GIC_CPU,
> +AW_H3_DEV_GIC_HYP,
> +AW_H3_DEV_GIC_VCPU,
> +AW_H3_DEV_RTC,
> +AW_H3_DEV_CPUCFG,
> +AW_H3_DEV_SDRAM
>  };
>
>  /** Total number of CPU cores in the H3 SoC */
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index ff92ded82c..341abe6718 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -35,37 +35,37 @@
>
>  /* Memory map */
>  const hwaddr allwinner_h3_memmap[] = {
> -[AW_H3_SRAM_A1]= 0x,
> -[AW_H3_SRAM_A2]= 0x00044000,
> -[AW_H3_SRAM_C] = 0x0001,
> -[AW_H3_SYSCTRL]= 0x01c0,
> -[AW_H3_MMC0]   = 0x01c0f000,
> -[AW_H3_SID]= 0x01c14000,
> -[AW_H3_EHCI0]  = 0x01c1a000,
> -[AW_H3_OHCI0]  = 0x01c1a400,
> -[AW_H3_EHCI1]  = 0x01c1b000,
> -[AW_H3_OHCI1]  = 0x01c1b400,
> -[AW_H3_EHCI2]  = 0x01c1c000,
> -[AW_H3_OHCI2]  = 0x01c1c400,
> -[AW_H3_EHCI3]  = 0x01c1d000,
> -[AW_H3_OHCI3]  = 0x01c1d400,
> -[AW_H3_CCU]= 0x01c2,
> -[AW_H3_PIT]= 0x01c20c00,
> -[AW_H3_UART0]  = 0x01c28000,
> -[AW_H3_UART1]  = 0x01c28400,
> -[AW_H3_UART2]  = 0x01c28800,
> -[AW_H3_UART3]  = 0x01c28c00,
> -[AW_H3_EMAC]   = 0x01c3,
> -[AW_H3_DRAMCOM]= 0x01c62000,
> -[AW_H3_DRAMCTL]= 0x01c63000,
> -[AW_H3_DRAMPHY]= 0x01c65000,
> -[AW_H3_GIC_DIST]   = 0x01c81000,
> -[AW_H3_GIC_CPU]= 0x01c82000,
> -[AW_H3_GIC_HYP]= 0x01c84000,
> -[AW_H3_GIC_VCPU]   = 0x01c86000,
> -[AW_H3_RTC]= 0x01f0,
> -[AW_H3_CPUCFG] = 0x01f01c00,
> -[AW_H3_SDRAM]  = 0x4000
> +[AW_H3_DEV_SRAM_A1]= 0x,
> +[AW_H3_DEV_SRAM_A2]= 0x00044000,
> +[AW_H3_DEV_SRAM_C] = 0x0001,
> +[AW_H3_DEV_SYSCTRL]= 0x01c0,
> +[AW_H3_DEV_MMC0]   = 0x01c0f000,
> +[AW_H3_DEV_SID]= 0x01c14000,
> +[AW_H3_DEV_EHCI0]  = 0x01c1a000,
> +[AW_H3_DEV_OHCI0]  = 0x01c1a400,
> +[AW_H3_DEV_EHCI1]  = 0x01c1b000,
> +[AW_H3_DEV_OHCI1]  = 0x01c1b400,
> +[AW_H3_DEV_EHCI2]  = 

Re: [PATCH 06/41] allwinner-h3: Rename memmap enum constants

2020-08-17 Thread Niek Linnenbank
Hi,

Interesting suggestion Philippe. I modelled the initial code of the H3 SoC
mostly in-line with the aspeed SoC,
to let it use commonly applied code structures where possible. And it looks
like in this series, aspeed_soc.h is also
getting the same change. I'll see if I can find some time to make a small
patch to move the enum to the local allwinner-h3.c file like you
suggested.

For Eduardo's work, I'm OK with a rename for now to AW_H3_DEV_*. I see it
is also done like that in aspeed_soc.h and similar files.
I do have one follow-up question: which value(s) from the enum are actually
in conflict? Could you add that in the commit message perhaps, for clarity?

With that answered:
  Reviewed-by: Niek Linnenbank 

Regards,
Niek

On Fri, Aug 14, 2020 at 7:54 PM Philippe Mathieu-Daudé 
wrote:

> +Niek as maintainer.
>
> On 8/14/20 12:25 AM, Eduardo Habkost wrote:
> > Some of the enum constant names conflict with the QOM type check
> > macros.  This needs to be addressed to allow us to transform the
> > QOM type check macros into functions generated by
> > OBJECT_DECLARE_TYPE().
> >
> > Rename all the constants to AW_H3_DEV_*, to avoid conflicts.
> >
> > Signed-off-by: Eduardo Habkost 
> > ---
> >  include/hw/arm/allwinner-h3.h |  62 -
> >  hw/arm/allwinner-h3.c | 124 +-
> >  hw/arm/orangepi.c |   6 +-
> >  3 files changed, 96 insertions(+), 96 deletions(-)
> >
> > diff --git a/include/hw/arm/allwinner-h3.h
> b/include/hw/arm/allwinner-h3.h
> > index 82e4e59216..626139dcb3 100644
> > --- a/include/hw/arm/allwinner-h3.h
> > +++ b/include/hw/arm/allwinner-h3.h
> > @@ -61,37 +61,37 @@
> >   * @see AwH3State
> >   */
> >  enum {
> > -AW_H3_SRAM_A1,
> > -AW_H3_SRAM_A2,
> > -AW_H3_SRAM_C,
> > -AW_H3_SYSCTRL,
> > -AW_H3_MMC0,
> > -AW_H3_SID,
> > -AW_H3_EHCI0,
> > -AW_H3_OHCI0,
> > -AW_H3_EHCI1,
> > -AW_H3_OHCI1,
> > -AW_H3_EHCI2,
> > -AW_H3_OHCI2,
> > -AW_H3_EHCI3,
> > -AW_H3_OHCI3,
> > -AW_H3_CCU,
> > -AW_H3_PIT,
> > -AW_H3_UART0,
> > -AW_H3_UART1,
> > -AW_H3_UART2,
> > -AW_H3_UART3,
> > -AW_H3_EMAC,
> > -AW_H3_DRAMCOM,
> > -AW_H3_DRAMCTL,
> > -AW_H3_DRAMPHY,
> > -AW_H3_GIC_DIST,
> > -AW_H3_GIC_CPU,
> > -AW_H3_GIC_HYP,
> > -AW_H3_GIC_VCPU,
> > -AW_H3_RTC,
> > -AW_H3_CPUCFG,
> > -AW_H3_SDRAM
> > +AW_H3_DEV_SRAM_A1,
> > +AW_H3_DEV_SRAM_A2,
> > +AW_H3_DEV_SRAM_C,
> > +AW_H3_DEV_SYSCTRL,
>
> My 2 cents:
> These are not devices, but peripheral blocks or IP cores.
> Anyway, short change could be to name them E_AW_H3_xxx,
> but I don't understand why these are exposed. This enum
> should be locally declared in hw/arm/allwinner-h3.c,
> and the SoC might provide a get_sdram_base_address()
> method so the machine can access it.
>
> > +AW_H3_DEV_MMC0,
> > +AW_H3_DEV_SID,
> > +AW_H3_DEV_EHCI0,
> > +AW_H3_DEV_OHCI0,
> > +AW_H3_DEV_EHCI1,
> > +AW_H3_DEV_OHCI1,
> > +AW_H3_DEV_EHCI2,
> > +AW_H3_DEV_OHCI2,
> > +AW_H3_DEV_EHCI3,
> > +AW_H3_DEV_OHCI3,
> > +AW_H3_DEV_CCU,
> > +AW_H3_DEV_PIT,
> > +AW_H3_DEV_UART0,
> > +AW_H3_DEV_UART1,
> > +AW_H3_DEV_UART2,
> > +AW_H3_DEV_UART3,
> > +AW_H3_DEV_EMAC,
> > +AW_H3_DEV_DRAMCOM,
> > +AW_H3_DEV_DRAMCTL,
> > +AW_H3_DEV_DRAMPHY,
> > +AW_H3_DEV_GIC_DIST,
> > +AW_H3_DEV_GIC_CPU,
> > +AW_H3_DEV_GIC_HYP,
> > +AW_H3_DEV_GIC_VCPU,
> > +AW_H3_DEV_RTC,
> > +AW_H3_DEV_CPUCFG,
> > +AW_H3_DEV_SDRAM
> >  };
> >
> >  /** Total number of CPU cores in the H3 SoC */
> > diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> > index ff92ded82c..341abe6718 100644
> > --- a/hw/arm/allwinner-h3.c
> > +++ b/hw/arm/allwinner-h3.c
> > @@ -35,37 +35,37 @@
> >
> >  /* Memory map */
> >  const hwaddr allwinner_h3_memmap[] = {
> > -[AW_H3_SRAM_A1]= 0x,
> > -[AW_H3_SRAM_A2]= 0x00044000,
> > -[AW_H3_SRAM_C] = 0x0001,
> > -[AW_H3_SYSCTRL]= 0x01c0,
> > -[AW_H3_MMC0]   = 0x01c0f000,
> > -[AW_H3_SID]= 0x01c14000,
> > -[AW_H3_EHCI0]  = 0x01c1a000,
> > -[AW_H3_OHCI0]  = 0x01c1a400,
> > -[AW_H3_EHCI1]  = 0x01c1b000,
> > -[AW_H3_OHCI1]  = 0x01c1b400,
&

Re: [PATCH] hw/net/allwinner-sun8i-emac: Use AddressSpace for DMA transfers

2020-08-17 Thread Niek Linnenbank
Hi Philippe,

Same as the one for the SD device: I tested it with the avocado tests and
the official image OrangePi_pc_debian_stretch_server_linux5.3.5_v1.0.img
and networking is working good (ran some apt-get commands etc).

Reviewed-by: Niek Linnenbank 
Tested-by: Niek Linnenbank 

Regards,
Niek

On Fri, Aug 14, 2020 at 2:29 PM Philippe Mathieu-Daudé 
wrote:

> Allow the device to execute the DMA transfers in a different
> AddressSpace.
>
> The H3 SoC keeps using the system_memory address space,
> but via the proper dma_memory_access() API.
>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> Tested with:
>   AVOCADO_ALLOW_LARGE_STORAGE=1 avocado run -t machine:orangepi-pc
> tests/acceptance/
> ---
>  include/hw/net/allwinner-sun8i-emac.h |  6 
>  hw/arm/allwinner-h3.c |  2 ++
>  hw/net/allwinner-sun8i-emac.c | 46 +--
>  3 files changed, 38 insertions(+), 16 deletions(-)
>
> diff --git a/include/hw/net/allwinner-sun8i-emac.h
> b/include/hw/net/allwinner-sun8i-emac.h
> index eda034e96b..dd1d7b96cd 100644
> --- a/include/hw/net/allwinner-sun8i-emac.h
> +++ b/include/hw/net/allwinner-sun8i-emac.h
> @@ -49,6 +49,12 @@ typedef struct AwSun8iEmacState {
>  /** Interrupt output signal to notify CPU */
>  qemu_irq irq;
>
> +/** Memory region where DMA transfers are done */
> +MemoryRegion *dma_mr;
> +
> +/** Address space used internally for DMA transfers */
> +AddressSpace dma_as;
> +
>  /** Generic Network Interface Controller (NIC) for networking API */
>  NICState *nic;
>
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index ff92ded82c..21a5d759d1 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -363,6 +363,8 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>  qemu_check_nic_model(_table[0], TYPE_AW_SUN8I_EMAC);
>  qdev_set_nic_properties(DEVICE(>emac), _table[0]);
>  }
> +object_property_set_link(OBJECT(>emac), "dma-memory",
> + OBJECT(get_system_memory()), _fatal);
>  sysbus_realize(SYS_BUS_DEVICE(>emac), _fatal);
>  sysbus_mmio_map(SYS_BUS_DEVICE(>emac), 0, s->memmap[AW_H3_EMAC]);
>  sysbus_connect_irq(SYS_BUS_DEVICE(>emac), 0,
> diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
> index 28637ff4c1..38d328587e 100644
> --- a/hw/net/allwinner-sun8i-emac.c
> +++ b/hw/net/allwinner-sun8i-emac.c
> @@ -19,6 +19,7 @@
>
>  #include "qemu/osdep.h"
>  #include "qemu/units.h"
> +#include "qapi/error.h"
>  #include "hw/sysbus.h"
>  #include "migration/vmstate.h"
>  #include "net/net.h"
> @@ -29,6 +30,7 @@
>  #include "net/checksum.h"
>  #include "qemu/module.h"
>  #include "exec/cpu-common.h"
> +#include "sysemu/dma.h"
>  #include "hw/net/allwinner-sun8i-emac.h"
>
>  /* EMAC register offsets */
> @@ -337,12 +339,13 @@ static void
> allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
>  qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
>  }
>
> -static uint32_t allwinner_sun8i_emac_next_desc(FrameDescriptor *desc,
> +static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
> +   FrameDescriptor *desc,
> size_t min_size)
>  {
>  uint32_t paddr = desc->next;
>
> -cpu_physical_memory_read(paddr, desc, sizeof(*desc));
> +dma_memory_read(>dma_as, paddr, desc, sizeof(*desc));
>
>  if ((desc->status & DESC_STATUS_CTL) &&
>  (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
> @@ -352,7 +355,8 @@ static uint32_t
> allwinner_sun8i_emac_next_desc(FrameDescriptor *desc,
>  }
>  }
>
> -static uint32_t allwinner_sun8i_emac_get_desc(FrameDescriptor *desc,
> +static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
> +  FrameDescriptor *desc,
>uint32_t start_addr,
>size_t min_size)
>  {
> @@ -360,7 +364,7 @@ static uint32_t
> allwinner_sun8i_emac_get_desc(FrameDescriptor *desc,
>
>  /* Note that the list is a cycle. Last entry points back to the head.
> */
>  while (desc_addr != 0) {
> -cpu_physical_memory_read(desc_addr, desc, sizeof(*desc));
> +dma_memory_read(>dma_as, desc_addr, desc, sizeof(*desc));
>
>  if ((desc->status & DESC_STATUS_CTL) &&
&g

Re: [PATCH] hw/sd/allwinner-sdhost: Use AddressSpace for DMA transfers

2020-08-17 Thread Niek Linnenbank
Hi Philippe,

Nice improvement, I didnt know about this API. Makes sense to use it indeed.
The patch works fine. I tested your patches by applying the previous two
sets first, and then this one.
It ran well with the avocado tests and also with the official image
OrangePi_pc_debian_stretch_server_linux5.3.5_v1.0.img.

Tested-by: Niek Linnenbank 
Reviewed-by: Niek Linnenbank 

Regards,
Niek



On Fri, Aug 14, 2020 at 1:01 PM Philippe Mathieu-Daudé 
wrote:

> Allow the device to execute the DMA transfers in a different
> AddressSpace.
>
> The A10 and H3 SoC keep using the system_memory address space,
> but via the proper dma_memory_access() API.
>
> Signed-off-by: Philippe Mathieu-Daudé 
> ---
> Based-on: <20200814092346.21825-1-f4...@amsat.org>
> "hw/sd: Use sdbus_read_data/sdbus_write_data for multiple bytes access"
>
> Tested with:
>   AVOCADO_ALLOW_LARGE_STORAGE=1 avocado run -t machine:orangepi-pc -t
> machine:cubieboard tests/acceptance/
> ---
>  include/hw/sd/allwinner-sdhost.h |  6 ++
>  hw/arm/allwinner-a10.c   |  2 ++
>  hw/arm/allwinner-h3.c|  2 ++
>  hw/sd/allwinner-sdhost.c | 37 ++--
>  4 files changed, 41 insertions(+), 6 deletions(-)
>
> diff --git a/include/hw/sd/allwinner-sdhost.h
> b/include/hw/sd/allwinner-sdhost.h
> index d94606a853..839732ebf3 100644
> --- a/include/hw/sd/allwinner-sdhost.h
> +++ b/include/hw/sd/allwinner-sdhost.h
> @@ -71,6 +71,12 @@ typedef struct AwSdHostState {
>  /** Interrupt output signal to notify CPU */
>  qemu_irq irq;
>
> +/** Memory region where DMA transfers are done */
> +MemoryRegion *dma_mr;
> +
> +/** Address space used internally for DMA transfers */
> +AddressSpace dma_as;
> +
>  /** Number of bytes left in current DMA transfer */
>  uint32_t transfer_cnt;
>
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index e258463747..d404f31e02 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -155,6 +155,8 @@ static void aw_a10_realize(DeviceState *dev, Error
> **errp)
>  }
>
>  /* SD/MMC */
> +object_property_set_link(OBJECT(>mmc0), "dma-memory",
> + OBJECT(get_system_memory()), _fatal);
>  sysbus_realize(SYS_BUS_DEVICE(>mmc0), _fatal);
>  sysbus_mmio_map(SYS_BUS_DEVICE(>mmc0), 0, AW_A10_MMC0_BASE);
>  sysbus_connect_irq(SYS_BUS_DEVICE(>mmc0), 0, qdev_get_gpio_in(dev,
> 32));
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index ff92ded82c..43a8d3dc48 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -349,6 +349,8 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>  sysbus_mmio_map(SYS_BUS_DEVICE(>sid), 0, s->memmap[AW_H3_SID]);
>
>  /* SD/MMC */
> +object_property_set_link(OBJECT(>mmc0), "dma-memory",
> + OBJECT(get_system_memory()), _fatal);
>  sysbus_realize(SYS_BUS_DEVICE(>mmc0), _fatal);
>  sysbus_mmio_map(SYS_BUS_DEVICE(>mmc0), 0, s->memmap[AW_H3_MMC0]);
>  sysbus_connect_irq(SYS_BUS_DEVICE(>mmc0), 0,
> diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
> index f9eb92c09e..e82afb75eb 100644
> --- a/hw/sd/allwinner-sdhost.c
> +++ b/hw/sd/allwinner-sdhost.c
> @@ -21,7 +21,10 @@
>  #include "qemu/log.h"
>  #include "qemu/module.h"
>  #include "qemu/units.h"
> +#include "qapi/error.h"
>  #include "sysemu/blockdev.h"
> +#include "sysemu/dma.h"
> +#include "hw/qdev-properties.h"
>  #include "hw/irq.h"
>  #include "hw/sd/allwinner-sdhost.h"
>  #include "migration/vmstate.h"
> @@ -306,7 +309,7 @@ static uint32_t
> allwinner_sdhost_process_desc(AwSdHostState *s,
>  uint8_t buf[1024];
>
>  /* Read descriptor */
> -cpu_physical_memory_read(desc_addr, desc, sizeof(*desc));
> +dma_memory_read(>dma_as, desc_addr, desc, sizeof(*desc));
>  if (desc->size == 0) {
>  desc->size = klass->max_desc_size;
>  } else if (desc->size > klass->max_desc_size) {
> @@ -331,22 +334,24 @@ static uint32_t
> allwinner_sdhost_process_desc(AwSdHostState *s,
>
>  /* Write to SD bus */
>  if (is_write) {
> -cpu_physical_memory_read((desc->addr & DESC_SIZE_MASK) +
> num_done,
> -  buf, buf_bytes);
> +dma_memory_read(>dma_as,
> +(desc->addr & DESC_SIZE_MASK) + num_done,
> +buf, buf_bytes);
>  sdbus_write_d

Re: [PATCH for-5.1 2/2] hw: Mark nd_table[] misuse in realize methods FIXME

2020-07-15 Thread Niek Linnenbank
On Wed, Jul 15, 2020, 16:04 Markus Armbruster  wrote:

> nd_table[] contains NIC configuration for boards to pick up.  Device
> code has no business looking there.  Several devices do it anyway.
> Two of them already have a suitable FIXME comment: "allwinner-a10" and
> "msf2-soc".  Copy it to the others: "allwinner-h3", "xlnx-versal",
> "xlnx,zynqmp", "sparc32-ledma", "riscv.sifive.u.soc".
>
> Signed-off-by: Markus Armbruster 
>
Reviewed-by: Niek Linnenbank 

---
>  hw/arm/allwinner-h3.c | 1 +
>  hw/arm/xlnx-versal.c  | 1 +
>  hw/arm/xlnx-zynqmp.c  | 1 +
>  hw/dma/sparc32_dma.c  | 1 +
>  hw/riscv/sifive_u.c   | 1 +
>  5 files changed, 5 insertions(+)
>
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 8e09468e86..ff92ded82c 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -358,6 +358,7 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>"sd-bus");
>
>  /* EMAC */
> +/* FIXME use qdev NIC properties instead of nd_table[] */
>  if (nd_table[0].used) {
>  qemu_check_nic_model(_table[0], TYPE_AW_SUN8I_EMAC);
>  qdev_set_nic_properties(DEVICE(>emac), _table[0]);
> diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
> index ead038b971..e3aa4bd1e5 100644
> --- a/hw/arm/xlnx-versal.c
> +++ b/hw/arm/xlnx-versal.c
> @@ -160,6 +160,7 @@ static void versal_create_gems(Versal *s, qemu_irq
> *pic)
>  object_initialize_child(OBJECT(s), name, >lpd.iou.gem[i],
>  TYPE_CADENCE_GEM);
>  dev = DEVICE(>lpd.iou.gem[i]);
> +/* FIXME use qdev NIC properties instead of nd_table[] */
>  if (nd->used) {
>  qemu_check_nic_model(nd, "cadence_gem");
>  qdev_set_nic_properties(dev, nd);
> diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
> index 772cfa3771..5855e5d5bf 100644
> --- a/hw/arm/xlnx-zynqmp.c
> +++ b/hw/arm/xlnx-zynqmp.c
> @@ -455,6 +455,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev,
> Error **errp)
>  for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) {
>  NICInfo *nd = _table[i];
>
> +/* FIXME use qdev NIC properties instead of nd_table[] */
>  if (nd->used) {
>  qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
>  qdev_set_nic_properties(DEVICE(>gem[i]), nd);
> diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c
> index 9459178866..bcd1626fbd 100644
> --- a/hw/dma/sparc32_dma.c
> +++ b/hw/dma/sparc32_dma.c
> @@ -341,6 +341,7 @@ static void sparc32_ledma_device_realize(DeviceState
> *dev, Error **errp)
>  DeviceState *d;
>  NICInfo *nd = _table[0];
>
> +/* FIXME use qdev NIC properties instead of nd_table[] */
>  qemu_check_nic_model(nd, TYPE_LANCE);
>
>  d = qdev_new(TYPE_LANCE);
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 19a976c9a6..e5682c38a9 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -714,6 +714,7 @@ static void sifive_u_soc_realize(DeviceState *dev,
> Error **errp)
>  }
>  sysbus_mmio_map(SYS_BUS_DEVICE(>otp), 0,
> memmap[SIFIVE_U_OTP].base);
>
> +/* FIXME use qdev NIC properties instead of nd_table[] */
>  if (nd->used) {
>  qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
>  qdev_set_nic_properties(DEVICE(>gem), nd);
> --
> 2.26.2
>
>


Re: [PATCH 1/2] tests/acceptance/boot_linux: Truncate SD card image to power of 2

2020-07-12 Thread Niek Linnenbank
  image_pow2ceil_truncate(image_path)
 image_drive_args = 'if=sd,format=raw,snapshot=on,file=' +
image_path
 archive.gzip_uncompress(image_path_gz, image_path)
+image_pow2ceil_truncate(image_path)

 # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8
conv=notrunc
 with open(uboot_path, 'rb') as f_in:
@@ -754,9 +754,9 @@ class BootLinuxConsole(LinuxKernelTest):

 # Extend image, to avoid that NetBSD thinks the partition
 # inside the image is larger than device size itself
-f_out.seek(0, 2)
-f_out.seek(64 * 1024 * 1024, 1)
-f_out.write(bytearray([0x00]))




-- 
Niek Linnenbank


[PATCH] docs/system/arm/orangepi: add instructions for resizing SD image to power of two

2020-07-12 Thread Niek Linnenbank
SD cards need to have a size of a power of two. This commit updates
the Orange Pi machine documentation to include instructions for
resizing downloaded images using the qemu-img command.

Signed-off-by: Niek Linnenbank 
---
 docs/system/arm/orangepi.rst | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
index c41adad488..6f23907fb6 100644
--- a/docs/system/arm/orangepi.rst
+++ b/docs/system/arm/orangepi.rst
@@ -127,6 +127,16 @@ can be downloaded from:
 Alternatively, you can also choose to build you own image with buildroot
 using the orangepi_pc_defconfig. Also see https://buildroot.org for more 
information.
 
+When using an image as an SD card, it must be resized to a power of two. This 
can be
+done with the qemu-img command. It is recommended to only increase the image 
size
+instead of shrinking it to a power of two, to avoid loss of data. For example,
+to prepare a downloaded Armbian image, first extract it and then increase
+its size to one gigabyte as follows:
+
+.. code-block:: bash
+
+  $ qemu-img resize Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img 1G
+
 You can choose to attach the selected image either as an SD card or as USB 
mass storage.
 For example, to boot using the Orange Pi PC Debian image on SD card, simply 
add the -sd
 argument and provide the proper root= kernel parameter:
@@ -213,12 +223,12 @@ Next, unzip the NetBSD image and write the U-Boot binary 
including SPL using:
   $ dd if=/path/to/u-boot-sunxi-with-spl.bin of=armv7.img bs=1024 seek=8 
conv=notrunc
 
 Finally, before starting the machine the SD image must be extended such
-that the NetBSD kernel will not conclude the NetBSD partition is larger than
-the emulated SD card:
+that the size of the SD image is a power of two and that the NetBSD kernel
+will not conclude the NetBSD partition is larger than the emulated SD card:
 
 .. code-block:: bash
 
-  $ dd if=/dev/zero bs=1M count=64 >> armv7.img
+  $ qemu-img resize armv7.img 2G
 
 Start the machine using the following command:
 
-- 
2.25.1




Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes

2020-07-09 Thread Niek Linnenbank
On Thu, Jul 9, 2020 at 4:15 PM Peter Maydell 
wrote:

> On Thu, 9 Jul 2020 at 14:56, Philippe Mathieu-Daudé 
> wrote:
> >
> > On 7/7/20 10:29 PM, Niek Linnenbank wrote:
> > > So I manually copy & pasted the change into hw/sd/sd.c to test it.
> > > It looks like the check works, but my concern is that with this change,
> > > we will be getting this error on 'off-the-shelf' images as well.
> > > For example, the latest Raspbian image size also isn't a power of two:
> > >
> > > $ ./arm-softmmu/qemu-system-arm -M raspi2 -sd
> > > ~/Downloads/2020-05-27-raspios-buster-lite-armhf.img -nographic
> > > WARNING: Image format was not specified for
> > > '/home/me/Downloads/2020-05-27-raspios-buster-lite-armhf.img' and
> > > probing guessed raw.
> > >  Automatically detecting the format is dangerous for raw
> images,
> > > write operations on block 0 will be restricted.
> > >  Specify the 'raw' format explicitly to remove the
> restrictions.
> > > qemu-system-arm: Invalid SD card size: 1.73 GiB (expecting at least 2
> GiB)
> > >
> > > If we do decide that the change is needed, I would like to propose that
> > > we also give the user some instructions
> > > on how to fix it, maybe some 'dd' command?
> >
> > On POSIX we can suggest to use 'truncate -s 2G' from coreutils.
> > This is not in the default Darwin packages.
> > On Windows I have no clue.
>
> dd/truncate etc won't work if the image file is not raw (eg if
> it's qcow2). The only chance you have of something that's actually
> generic would probably involve "qemu-img resize". But I'm a bit
> wary of having an error message that recommends that, because
> what if we got it wrong?
>

Yeah good point Peter, I see what you mean. As I wrote to Philippe,
i'll try to make a small patch with some instructions in the OrangePi board
documentation,
so then we'll at least have something there to help the user.

Regards,
Niek


>
> thanks
> -- PMM
>


-- 
Niek Linnenbank


Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes

2020-07-09 Thread Niek Linnenbank
On Thu, Jul 9, 2020 at 3:56 PM Philippe Mathieu-Daudé 
wrote:

> On 7/7/20 10:29 PM, Niek Linnenbank wrote:
> > Hi Philippe,
> >
> > Just tried out your patch on latest master, and I noticed I couldn't
> > apply it without getting this error:
> >
> > $ git am ~/Downloads/patches/\[PATCH\ 2_2\]\ hw_sd_sdcard\:\ Do\ not\
> > allow\ invalid\ SD\ card\ sizes\ -\ Philippe\ Mathieu-Daudé\
> > \mailto:f4...@amsat.org>\>\ -\ 2020-07-07\ 1521.eml
> > Applying: hw/sd/sdcard: Do not allow invalid SD card sizes
> > error: patch failed: hw/sd/sd.c:2130
> > error: hw/sd/sd.c: patch does not apply
> > Patch failed at 0001 hw/sd/sdcard: Do not allow invalid SD card sizes
> > Use 'git am --show-current-patch' to see the failed patch
> > When you have resolved this problem, run "git am --continue".
> > If you prefer to skip this patch, run "git am --skip" instead.
> > To restore the original branch and stop patching, run "git am --abort".
> >
> > The first patch did go OK. Maybe this one just needs to be rebased, or I
> > made a mistake.
>
> Sorry it was not clear on the cover:
>
>   Part 1 is already reviewed:
>   https://www.mail-archive.com/qemu-devel@nongnu.org/msg718150.html
>   Based-on: <20200630133912.9428-1-f4...@amsat.org>
>
> This series is based on the "Part 1".
>
> > So I manually copy & pasted the change into hw/sd/sd.c to test it.
> > It looks like the check works, but my concern is that with this change,
> > we will be getting this error on 'off-the-shelf' images as well.
> > For example, the latest Raspbian image size also isn't a power of two:
> >
> > $ ./arm-softmmu/qemu-system-arm -M raspi2 -sd
> > ~/Downloads/2020-05-27-raspios-buster-lite-armhf.img -nographic
> > WARNING: Image format was not specified for
> > '/home/me/Downloads/2020-05-27-raspios-buster-lite-armhf.img' and
> > probing guessed raw.
> >  Automatically detecting the format is dangerous for raw images,
> > write operations on block 0 will be restricted.
> >  Specify the 'raw' format explicitly to remove the restrictions.
> > qemu-system-arm: Invalid SD card size: 1.73 GiB (expecting at least 2
> GiB)
> >
> > If we do decide that the change is needed, I would like to propose that
> > we also give the user some instructions
> > on how to fix it, maybe some 'dd' command?
>
> On POSIX we can suggest to use 'truncate -s 2G' from coreutils.
> This is not in the default Darwin packages.
> On Windows I have no clue.
>
> > In my opinion that should
> > also go in some of the documentation file(s),
> > possibly also in the one for the OrangePi PC at
> > docs/system/arm/orangepi.rst (I can also provide a patch for that if you
> > wish).
>
> Good idea, if you can send that patch that would a precious help,
> and I'd include it with the other patches :)
>

OK Philipe. Then I'll prepare a patch and try send it to the list somewhere
this weekend.


>
> Note that this was your orangepi-pc acceptance test that catched
> this bug!
> See https://travis-ci.org/github/philmd/qemu/jobs/705653532#L5672:
>
>
Oh cool, that is great. Looks like it is working pretty well then. But lets
be fair, I think it was you that contributed that part ;-)


>  CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=50c5387d
>  OF: fdt: Machine model: Xunlong Orange Pi PC
>  Kernel command line: printk.time=0 console=ttyS0,115200
> root=/dev/mmcblk0 rootwait rw panic=-1 noreboot
>  sunxi-mmc 1c0f000.mmc: Linked as a consumer to regulator.2
>  sunxi-mmc 1c0f000.mmc: Got CD GPIO
>  sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
>  mmc0: host does not support reading read-only switch, assuming
> write-enable
>  mmc0: Problem switching card into high-speed mode!
>  mmc0: new SD card at address 4567
>  mmcblk0: mmc0:4567 QEMU! 60.0 MiB
>  EXT4-fs (mmcblk0): mounting ext2 file system using the ext4 subsystem
>  EXT4-fs (mmcblk0): mounted filesystem without journal. Opts: (null)
>  VFS: Mounted root (ext2 filesystem) on device 179:0.
>  EXT4-fs (mmcblk0): re-mounted. Opts: block_validity,barrier,user_xattr,acl
>  Populating /dev using udev: udevd[204]: starting version 3.2.7
>  udevadm settle failed
>  done
>  udevd[205]: worker [208]
> /devices/platform/soc/1c0f000.mmc/mmc_host/mmc0/mmc0:4567/block/mmcblk0
> is taking a long time
> Runner error occurred: Timeout reached
> Original status: ERROR
>
> (I'll add that in the commit description too).
>

OK thanks!

>
> Thanks for your testing/review!
>
> > Kind regards,
> >
> > Niek
> >
> >
> > On Tue, J

Re: [PATCH 2/2] hw/sd/sdcard: Do not allow invalid SD card sizes

2020-07-07 Thread Niek Linnenbank
isterfields.h"
> >>>  #include "sysemu/block-backend.h"
> >>> @@ -2130,11 +2131,26 @@ static void sd_realize(DeviceState *dev, Error
> **errp)
> >>>  }
> >>>
> >>>  if (sd->blk) {
> >>> +int64_t blk_size;
> >>> +
> >>>  if (blk_is_read_only(sd->blk)) {
> >>>      error_setg(errp, "Cannot use read-only drive as SD card");
> >>>  return;
> >>>  }
> >>>
> >>> +blk_size = blk_getlength(sd->blk);
> >>> +if (blk_size > 0 && !is_power_of_2(blk_size)) {
> >>> +int64_t blk_size_aligned = pow2ceil(blk_size);
> >>> +char *blk_size_str = size_to_str(blk_size);
> >>> +char *blk_size_aligned_str =
> size_to_str(blk_size_aligned);
> >>> +
> >>> +error_setg(errp, "Invalid SD card size: %s (expecting at
> least %s)",
> >>> +   blk_size_str, blk_size_aligned_str);
> >>
> >> Should we print that we expect a power of 2? This isn't always obvious
> >> from the message.
> >
> > Mmm, I was thinking that. Perhaps
> >  "expecting a power of 2, e.g. %s"
> > ?
>
> OK, thanks guys!
>
> >
> > thanks
> > -- PMM
> >
>


-- 
Niek Linnenbank


Re: [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions

2020-07-05 Thread Niek Linnenbank
On Sat, Jul 4, 2020, 16:50 Philippe Mathieu-Daudé  wrote:

> Various machine/board/soc models create OHCI device instances
> with the generic QDEV API, and don't need to access USB internals.
>
> Simplify header inclusions by moving the QOM type names into a
> simple header, with no need to include other "hw/usb" headers.
>
> Suggested-by: BALATON Zoltan 
> Signed-off-by: Philippe Mathieu-Daudé 
>
Reviewed-by: Niek Linnenbank 

---
>  hw/usb/hcd-ohci.h|  2 +-
>  include/hw/usb/usb-hcd.h | 16 
>  hw/arm/allwinner-a10.c   |  2 +-
>  hw/arm/allwinner-h3.c|  9 +
>  hw/arm/pxa2xx.c  |  3 ++-
>  hw/arm/realview.c|  3 ++-
>  hw/arm/versatilepb.c |  3 ++-
>  hw/display/sm501.c   |  3 ++-
>  hw/ppc/mac_newworld.c|  3 ++-
>  hw/ppc/mac_oldworld.c|  3 ++-
>  hw/ppc/sam460ex.c|  3 ++-
>  hw/ppc/spapr.c   |  3 ++-
>  hw/usb/hcd-ohci-pci.c|  2 +-
>  13 files changed, 40 insertions(+), 15 deletions(-)
>  create mode 100644 include/hw/usb/usb-hcd.h
>
> diff --git a/hw/usb/hcd-ohci.h b/hw/usb/hcd-ohci.h
> index 771927ea17..6949cf0dab 100644
> --- a/hw/usb/hcd-ohci.h
> +++ b/hw/usb/hcd-ohci.h
> @@ -21,6 +21,7 @@
>  #ifndef HCD_OHCI_H
>  #define HCD_OHCI_H
>
> +#include "hw/usb/usb-hcd.h"
>  #include "sysemu/dma.h"
>  #include "usb-internal.h"
>
> @@ -91,7 +92,6 @@ typedef struct OHCIState {
>  void (*ohci_die)(struct OHCIState *ohci);
>  } OHCIState;
>
> -#define TYPE_SYSBUS_OHCI "sysbus-ohci"
>  #define SYSBUS_OHCI(obj) OBJECT_CHECK(OHCISysBusState, (obj),
> TYPE_SYSBUS_OHCI)
>
>  typedef struct {
> diff --git a/include/hw/usb/usb-hcd.h b/include/hw/usb/usb-hcd.h
> new file mode 100644
> index 00..21fdfaf22d
> --- /dev/null
> +++ b/include/hw/usb/usb-hcd.h
> @@ -0,0 +1,16 @@
> +/*
> + * QEMU USB HCD types
> + *
> + * Copyright (c) 2020  Philippe Mathieu-Daudé 
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef HW_USB_HCD_TYPES_H
> +#define HW_USB_HCD_TYPES_H
> +
> +/* OHCI */
> +#define TYPE_SYSBUS_OHCI"sysbus-ohci"
> +#define TYPE_PCI_OHCI   "pci-ohci"
> +
> +#endif
> diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
> index 52e0d83760..53c24ff602 100644
> --- a/hw/arm/allwinner-a10.c
> +++ b/hw/arm/allwinner-a10.c
> @@ -25,7 +25,7 @@
>  #include "hw/misc/unimp.h"
>  #include "sysemu/sysemu.h"
>  #include "hw/boards.h"
> -#include "hw/usb/hcd-ohci.h"
> +#include "hw/usb/usb-hcd.h"
>
>  #define AW_A10_MMC0_BASE0x01c0f000
>  #define AW_A10_PIC_REG_BASE 0x01c20400
> diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> index 8e09468e86..d1d90ffa79 100644
> --- a/hw/arm/allwinner-h3.c
> +++ b/hw/arm/allwinner-h3.c
> @@ -28,6 +28,7 @@
>  #include "hw/sysbus.h"
>  #include "hw/char/serial.h"
>  #include "hw/misc/unimp.h"
> +#include "hw/usb/usb-hcd.h"
>  #include "hw/usb/hcd-ehci.h"
>  #include "hw/loader.h"
>  #include "sysemu/sysemu.h"
> @@ -381,16 +382,16 @@ static void allwinner_h3_realize(DeviceState *dev,
> Error **errp)
>   qdev_get_gpio_in(DEVICE(>gic),
>AW_H3_GIC_SPI_EHCI3));
>
> -sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI0],
> +sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI0],
>   qdev_get_gpio_in(DEVICE(>gic),
>AW_H3_GIC_SPI_OHCI0));
> -sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI1],
> +sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI1],
>   qdev_get_gpio_in(DEVICE(>gic),
>AW_H3_GIC_SPI_OHCI1));
> -sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI2],
> +sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI2],
>   qdev_get_gpio_in(DEVICE(>gic),
>AW_H3_GIC_SPI_OHCI2));
> -sysbus_create_simple("sysbus-ohci", s->memmap[AW_H3_OHCI3],
> +sysbus_create_simple(TYPE_SYSBUS_OHCI, s->memmap[AW_H3_OHCI3],
>   qdev_get_gpio_in(DEVICE(>gic),
>AW_H3_GIC_SPI_OHCI3));
>
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index f104a33463..27196170f5 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @

  1   2   3   4   >