[PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM)

Huacai Chen posted 4 patches 3 years, 10 months ago
Test FreeBSD passed
Test docker-quick@centos7 passed
Test checkpatch failed
Test docker-mingw@fedora passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1592914438-30317-1-git-send-email-chenhc@lemote.com
Maintainers: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Aurelien Jarno <aurelien@aurel32.net>
There is a newer version of this series
MAINTAINERS                          |   6 +
default-configs/mips64el-softmmu.mak |   1 +
hw/intc/Kconfig                      |   3 +
hw/intc/Makefile.objs                |   1 +
hw/intc/loongson_liointc.c           | 246 +++++++++
hw/mips/Kconfig                      |  11 +
hw/mips/Makefile.objs                |   1 +
hw/mips/loongson3_virt.c             | 969 +++++++++++++++++++++++++++++++++++
target/mips/kvm.c                    |  20 +
target/mips/kvm_mips.h               |  11 +
10 files changed, 1269 insertions(+)
create mode 100644 hw/intc/loongson_liointc.c
create mode 100644 hw/mips/loongson3_virt.c
[PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM)
Posted by Huacai Chen 3 years, 10 months ago
Loongson-3 CPU family include Loongson-3A R1/R2/R3/R4 and Loongson-3B
R1/R2. Loongson-3A R1 is the oldest and its ISA is the smallest, while
Loongson-3A R4 is the newest and its ISA is almost the superset of all
others. To reduce complexity, in QEMU we just define two CPU types:

1, "Loongson-3A1000" CPU which is corresponding to Loongson-3A R1. It is
   suitable for TCG because Loongson-3A R1 has fewest ASE.
2, "Loongson-3A4000" CPU which is corresponding to Loongson-3A R4. It is
   suitable for KVM because Loongson-3A R4 has the VZ ASE.

Loongson-3 lacks English documents. I've tried to translated them with
translate.google.com, and the machine translated documents (together
with their original Chinese versions) are available here.

Loongson-3A R1 (Loongson-3A1000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A1000_p1.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P1.pdf (Chinese Version)
User Manual Part 2:
http://ftp.godson.ac.cn/lemote/3A1000_p2.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A1000_processor_user_manual_P2.pdf (Chinese Version)

Loongson-3A R2 (Loongson-3A2000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A2000_p1.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A2000_user1.pdf (Chinese Version)
User Manual Part 2:
http://ftp.godson.ac.cn/lemote/3A2000_p2.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A2000_user2.pdf (Chinese Version)

Loongson-3A R3 (Loongson-3A3000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A3000_p1.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual1.pdf (Chinese Version)
User Manual Part 2:
http://ftp.godson.ac.cn/lemote/3A3000_p2.pdf
http://ftp.godson.ac.cn/lemote/Loongson3A3000_3B3000usermanual2.pdf (Chinese Version)

Loongson-3A R4 (Loongson-3A4000)
User Manual Part 1:
http://ftp.godson.ac.cn/lemote/3A4000_p1.pdf
http://ftp.godson.ac.cn/lemote/3A4000user.pdf (Chinese Version)
User Manual Part 2:
I'm sorry that it is unavailable now.

We are preparing to add QEMU's Loongson-3 support. MIPS VZ extension is
fully supported in Loongson-3A R4+, so we at first add QEMU/KVM support
in this series. And the next series will add QEMU/TCG support (it will
emulate Loongson-3A R1).

We already have a full functional Linux kernel (based on Linux-5.4.x LTS
but not upstream yet) here:

https://github.com/chenhuacai/linux

How to use QEMU/Loongson-3?
1, Download kernel source from the above URL;
2, Build a kernel with arch/mips/configs/loongson3_{def,hpc}config;
3, Boot a Loongson-3A4000 host with this kernel;
4, Build QEMU-5.0.0 with this patchset;
5, modprobe kvm;
6, Use QEMU with TCG (available in future):
       qemu-system-mips64el -M loongson3-virt,accel=tcg -cpu Loongson-3A1000 -kernel <path_to_kernel> -append ...
   Use QEMU with KVM (available at present):
       qemu-system-mips64el -M loongson3-virt,accel=kvm -cpu Loongson-3A4000 -kernel <path_to_kernel> -append ...

   The "-cpu" parameter is optional here and QEMU will use the correct type for TCG/KVM automatically.

V1 -> V2:
1, Add a cover letter;
2, Improve CPU definitions;
3, Remove LS7A-related things (Use GPEX instead);
4, Add a description of how to run QEMU/Loongson-3.

V2 -> V3:
1, Fix all possible checkpatch.pl errors and warnings.

V3 -> V4:
1, Sync code with upstream;
2, Remove merged patches;
3, Fix build failure without CONFIG_KVM;
4, Add Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>.

V4 -> V5:
1, Improve coding style;
2, Remove merged patches;
3, Rename machine name from "loongson3" to "loongson3-virt";
4, Rework the "loongson3-virt" machine to drop any ISA things;
5, Rework "hw/mips: Implement the kvm_type() hook in MachineClass";
6, Add Jiaxun Yang as a reviewer of Loongson-3.

Huacai Chen(4):
 hw/mips: Implement the kvm_type() hook in MachineClass
 hw/intc: Add Loongson liointc support
 hw/mips: Add Loongson-3 machine support (with KVM)
 MAINTAINERS: Add Loongson-3 maintainer and reviewer

Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 MAINTAINERS                          |   6 +
 default-configs/mips64el-softmmu.mak |   1 +
 hw/intc/Kconfig                      |   3 +
 hw/intc/Makefile.objs                |   1 +
 hw/intc/loongson_liointc.c           | 246 +++++++++
 hw/mips/Kconfig                      |  11 +
 hw/mips/Makefile.objs                |   1 +
 hw/mips/loongson3_virt.c             | 969 +++++++++++++++++++++++++++++++++++
 target/mips/kvm.c                    |  20 +
 target/mips/kvm_mips.h               |  11 +
 10 files changed, 1269 insertions(+)
 create mode 100644 hw/intc/loongson_liointc.c
 create mode 100644 hw/mips/loongson3_virt.c
--
2.7.0

Re: [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM)
Posted by no-reply@patchew.org 3 years, 10 months ago
Patchew URL: https://patchew.org/QEMU/1592914438-30317-1-git-send-email-chenhc@lemote.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM)
Type: series
Message-id: 1592914438-30317-1-git-send-email-chenhc@lemote.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
 * [new tag]         patchew/1592914438-30317-1-git-send-email-chenhc@lemote.com -> patchew/1592914438-30317-1-git-send-email-chenhc@lemote.com
Switched to a new branch 'test'
63e13a2 MAINTAINERS: Add Loongson-3 maintainer and reviewer
727fa14 hw/mips: Add Loongson-3 machine support (with KVM)
5fd21a0 hw/intc: Add Loongson liointc support
6996d49 hw/mips: Implement the kvm_type() hook in MachineClass

=== OUTPUT BEGIN ===
1/4 Checking commit 6996d492ec71 (hw/mips: Implement the kvm_type() hook in MachineClass)
2/4 Checking commit 5fd21a0bcd83 (hw/intc: Add Loongson liointc support)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#36: 
new file mode 100644

ERROR: line over 90 characters
#90: FILE: hw/intc/loongson_liointc.c:50:
+#define LOONGSON_LIOINTC(obj) OBJECT_CHECK(struct loongson_liointc, (obj), TYPE_LOONGSON_LIOINTC)

ERROR: open brace '{' following struct go on the same line
#93: FILE: hw/intc/loongson_liointc.c:53:
+struct loongson_liointc
+{

ERROR: code indent should never use tabs
#148: FILE: hw/intc/loongson_liointc.c:108:
+^I    if (p->parent_state[parent] !=$

total: 3 errors, 1 warnings, 256 lines checked

Patch 2/4 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

3/4 Checking commit 727fa142abed (hw/mips: Add Loongson-3 machine support (with KVM))
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#84: 
new file mode 100644

WARNING: line over 80 characters
#404: FILE: hw/mips/loongson3_virt.c:316:
+static void loongson3_pm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)

WARNING: line over 80 characters
#704: FILE: hw/mips/loongson3_virt.c:616:
+    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)current_machine->smp.max_cpus);

WARNING: line over 80 characters
#840: FILE: hw/mips/loongson3_virt.c:752:
+static inline void loongson3_virt_devices_init(MachineState *machine, DeviceState *pic)

WARNING: line over 80 characters
#871: FILE: hw/mips/loongson3_virt.c:783:
+                             get_system_io(), 0, virt_memmap[VIRT_PCIE_PIO].size);

WARNING: line over 80 characters
#977: FILE: hw/mips/loongson3_virt.c:889:
+    /* Allocate RAM/BIOS, 0x00000000~0x10000000 is alias of 0x80000000~0x90000000 */

total: 0 errors, 6 warnings, 999 lines checked

Patch 3/4 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
4/4 Checking commit 63e13a297290 (MAINTAINERS: Add Loongson-3 maintainer and reviewer)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/1592914438-30317-1-git-send-email-chenhc@lemote.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM)
Posted by Aleksandar Markovic 3 years, 10 months ago
уторак, 23. јун 2020., <no-reply@patchew.org> је написао/ла:

> Patchew URL: https://patchew.org/QEMU/1592914438-30317-1-git-send-
> email-chenhc@lemote.com/
>
>
>
> Hi,
>
> This series seems to have some coding style problems. See output below for
> more information:
>
>
Hi, Huacai.

Please fix all checkpatch warnings in the next version (except thise that
complain about the need for updating MAONTAINERS)

Also, you dont need " for-5.1" in subject prefixes.

Please fix these and other small things that I commented about, and send v6
soon (tomorrow, if possible?), so that we remove these small obstacles and
focus on the core functionality of tge series.

Thanks, Aleksandar





> Subject: [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with
> KVM)
> Type: series
> Message-id: 1592914438-30317-1-git-send-email-chenhc@lemote.com
>
> === TEST SCRIPT BEGIN ===
> #!/bin/bash
> git rev-parse base > /dev/null || exit 0
> git config --local diff.renamelimit 0
> git config --local diff.renames True
> git config --local diff.algorithm histogram
> ./scripts/checkpatch.pl --mailback base..
> === TEST SCRIPT END ===
>
> From https://github.com/patchew-project/qemu
>  * [new tag]         patchew/1592914438-30317-1-
> git-send-email-chenhc@lemote.com -> patchew/1592914438-30317-1-
> git-send-email-chenhc@lemote.com
> Switched to a new branch 'test'
> 63e13a2 MAINTAINERS: Add Loongson-3 maintainer and reviewer
> 727fa14 hw/mips: Add Loongson-3 machine support (with KVM)
> 5fd21a0 hw/intc: Add Loongson liointc support
> 6996d49 hw/mips: Implement the kvm_type() hook in MachineClass
>
> === OUTPUT BEGIN ===
> 1/4 Checking commit 6996d492ec71 (hw/mips: Implement the kvm_type() hook
> in MachineClass)
> 2/4 Checking commit 5fd21a0bcd83 (hw/intc: Add Loongson liointc support)
> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
> #36:
> new file mode 100644
>
> ERROR: line over 90 characters
> #90: FILE: hw/intc/loongson_liointc.c:50:
> +#define LOONGSON_LIOINTC(obj) OBJECT_CHECK(struct loongson_liointc,
> (obj), TYPE_LOONGSON_LIOINTC)
>
> ERROR: open brace '{' following struct go on the same line
> #93: FILE: hw/intc/loongson_liointc.c:53:
> +struct loongson_liointc
> +{
>
> ERROR: code indent should never use tabs
> #148: FILE: hw/intc/loongson_liointc.c:108:
> +^I    if (p->parent_state[parent] !=$
>
> total: 3 errors, 1 warnings, 256 lines checked
>
> Patch 2/4 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
>
> 3/4 Checking commit 727fa142abed (hw/mips: Add Loongson-3 machine support
> (with KVM))
> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
> #84:
> new file mode 100644
>
> WARNING: line over 80 characters
> #404: FILE: hw/mips/loongson3_virt.c:316:
> +static void loongson3_pm_write(void *opaque, hwaddr addr, uint64_t val,
> unsigned size)
>
> WARNING: line over 80 characters
> #704: FILE: hw/mips/loongson3_virt.c:616:
> +    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)current_machine->
> smp.max_cpus);
>
> WARNING: line over 80 characters
> #840: FILE: hw/mips/loongson3_virt.c:752:
> +static inline void loongson3_virt_devices_init(MachineState *machine,
> DeviceState *pic)
>
> WARNING: line over 80 characters
> #871: FILE: hw/mips/loongson3_virt.c:783:
> +                             get_system_io(), 0,
> virt_memmap[VIRT_PCIE_PIO].size);
>
> WARNING: line over 80 characters
> #977: FILE: hw/mips/loongson3_virt.c:889:
> +    /* Allocate RAM/BIOS, 0x00000000~0x10000000 is alias of
> 0x80000000~0x90000000 */
>
> total: 0 errors, 6 warnings, 999 lines checked
>
> Patch 3/4 has style problems, please review.  If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
> 4/4 Checking commit 63e13a297290 (MAINTAINERS: Add Loongson-3 maintainer
> and reviewer)
> === OUTPUT END ===
>
> Test command exited with code: 1
>
>
> The full log is available at
> http://patchew.org/logs/1592914438-30317-1-git-send-
> email-chenhc@lemote.com/testing.checkpatch/?type=message.
> ---
> Email generated automatically by Patchew [https://patchew.org/].
> Please send your feedback to patchew-devel@redhat.com
Re: [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM)
Posted by Huacai Chen 3 years, 9 months ago
Hi, Aleksandar,

On Tue, Jun 23, 2020 at 9:58 PM Aleksandar Markovic
<aleksandar.qemu.devel@gmail.com> wrote:
>
>
>
> уторак, 23. јун 2020., <no-reply@patchew.org> је написао/ла:
>>
>> Patchew URL: https://patchew.org/QEMU/1592914438-30317-1-git-send-email-chenhc@lemote.com/
>>
>>
>>
>> Hi,
>>
>> This series seems to have some coding style problems. See output below for
>> more information:
>>
>
> Hi, Huacai.
>
> Please fix all checkpatch warnings in the next version (except thise that complain about the need for updating MAONTAINERS)
>
> Also, you dont need " for-5.1" in subject prefixes.
>
> Please fix these and other small things that I commented about, and send v6 soon (tomorrow, if possible?), so that we remove these small obstacles and focus on the core functionality of tge series.
>
> Thanks, Aleksandar
>
>
>
>
>>
>> Subject: [PATCH for-5.1 V5 0/4] mips: Add Loongson-3 machine support (with KVM)
>> Type: series
>> Message-id: 1592914438-30317-1-git-send-email-chenhc@lemote.com
>>
>> === TEST SCRIPT BEGIN ===
>> #!/bin/bash
>> git rev-parse base > /dev/null || exit 0
>> git config --local diff.renamelimit 0
>> git config --local diff.renames True
>> git config --local diff.algorithm histogram
>> ./scripts/checkpatch.pl --mailback base..
>> === TEST SCRIPT END ===
>>
>> From https://github.com/patchew-project/qemu
>>  * [new tag]         patchew/1592914438-30317-1-git-send-email-chenhc@lemote.com -> patchew/1592914438-30317-1-git-send-email-chenhc@lemote.com
>> Switched to a new branch 'test'
>> 63e13a2 MAINTAINERS: Add Loongson-3 maintainer and reviewer
>> 727fa14 hw/mips: Add Loongson-3 machine support (with KVM)
>> 5fd21a0 hw/intc: Add Loongson liointc support
>> 6996d49 hw/mips: Implement the kvm_type() hook in MachineClass
>>
>> === OUTPUT BEGIN ===
>> 1/4 Checking commit 6996d492ec71 (hw/mips: Implement the kvm_type() hook in MachineClass)
>> 2/4 Checking commit 5fd21a0bcd83 (hw/intc: Add Loongson liointc support)
>> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
>> #36:
>> new file mode 100644
>>
>> ERROR: line over 90 characters
>> #90: FILE: hw/intc/loongson_liointc.c:50:
>> +#define LOONGSON_LIOINTC(obj) OBJECT_CHECK(struct loongson_liointc, (obj), TYPE_LOONGSON_LIOINTC)
>>
>> ERROR: open brace '{' following struct go on the same line
>> #93: FILE: hw/intc/loongson_liointc.c:53:
>> +struct loongson_liointc
>> +{
>>
>> ERROR: code indent should never use tabs
>> #148: FILE: hw/intc/loongson_liointc.c:108:
>> +^I    if (p->parent_state[parent] !=$
>>
>> total: 3 errors, 1 warnings, 256 lines checked
>>
>> Patch 2/4 has style problems, please review.  If any of these errors
>> are false positives report them to the maintainer, see
>> CHECKPATCH in MAINTAINERS.
>>
>> 3/4 Checking commit 727fa142abed (hw/mips: Add Loongson-3 machine support (with KVM))
>> WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
>> #84:
>> new file mode 100644
>>
>> WARNING: line over 80 characters
>> #404: FILE: hw/mips/loongson3_virt.c:316:
>> +static void loongson3_pm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
>>
>> WARNING: line over 80 characters
>> #704: FILE: hw/mips/loongson3_virt.c:616:
>> +    fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)current_machine->smp.max_cpus);
>>
>> WARNING: line over 80 characters
>> #840: FILE: hw/mips/loongson3_virt.c:752:
>> +static inline void loongson3_virt_devices_init(MachineState *machine, DeviceState *pic)
>>
>> WARNING: line over 80 characters
>> #871: FILE: hw/mips/loongson3_virt.c:783:
>> +                             get_system_io(), 0, virt_memmap[VIRT_PCIE_PIO].size);
>>
>> WARNING: line over 80 characters
>> #977: FILE: hw/mips/loongson3_virt.c:889:
>> +    /* Allocate RAM/BIOS, 0x00000000~0x10000000 is alias of 0x80000000~0x90000000 */
>>
>> total: 0 errors, 6 warnings, 999 lines checked
>>
>> Patch 3/4 has style problems, please review.  If any of these errors
>> are false positives report them to the maintainer, see
>> CHECKPATCH in MAINTAINERS.
>> 4/4 Checking commit 63e13a297290 (MAINTAINERS: Add Loongson-3 maintainer and reviewer)
>> === OUTPUT END ===
>>
>> Test command exited with code: 1
>>
>>
>> The full log is available at
>> http://patchew.org/logs/1592914438-30317-1-git-send-email-chenhc@lemote.com/testing.checkpatch/?type=message.
OK, all errors will be fixed.

>> ---
>> Email generated automatically by Patchew [https://patchew.org/].
>> Please send your feedback to patchew-devel@redhat.com