1 | The following changes since commit b10d00d8811fa4eed4862963273d7353ce310c82: | 1 | First arm pullreq for 7.1. The bulk of this is the qemu_split_irq |
---|---|---|---|
2 | removal. | ||
2 | 3 | ||
3 | Merge remote-tracking branch 'remotes/kraxel/tags/seabios-20220118-pull-request' into staging (2022-01-19 18:46:28 +0000) | 4 | I have enough stuff in my to-review queue that I expect to do another |
5 | pullreq early next week, but 31 patches is enough to not hang on to. | ||
6 | |||
7 | thanks | ||
8 | -- PMM | ||
9 | |||
10 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: | ||
11 | |||
12 | Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700) | ||
4 | 13 | ||
5 | are available in the Git repository at: | 14 | are available in the Git repository at: |
6 | 15 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220120 | 16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220421 |
8 | 17 | ||
9 | for you to fetch changes up to 9705e3c1dcff96b0b3c7e594b6cd68d27d6c4ced: | 18 | for you to fetch changes up to 5b415dd61bdbf61fb4be0e9f1a7172b8bce682c6: |
10 | 19 | ||
11 | hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR (2022-01-20 11:47:54 +0000) | 20 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs (2022-04-21 11:37:05 +0100) |
12 | 21 | ||
13 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
14 | target-arm: | 23 | target-arm queue: |
15 | * hw/intc/arm_gicv3_its: Fix various minor bugs | 24 | * hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF |
16 | * hw/arm/aspeed: Add the i3c device to the AST2600 SoC | 25 | * versal: Add the Cortex-R5s in the Real-Time Processing Unit (RPU) subsystem |
17 | * hw/arm: kudo: add lm75s behind bus 1 switch at 75 | 26 | * versal: model enough of the Clock/Reset Low-power domain (CRL) to allow control of the Cortex-R5s |
18 | * hw/arm/virt: Fix support for running guests on hosts | 27 | * xlnx-zynqmp: Connect 4 TTC timers |
19 | with restricted IPA ranges | 28 | * exynos4210: Refactor GIC/combiner code to stop using qemu_split_irq |
20 | * hw/intc/arm_gic: Allow reset of the running priority | 29 | * realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
21 | * hw/intc/arm_gic: Implement read of GICC_IIDR | 30 | * stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
22 | * hw/arm/virt: Support for virtio-mem-pci | 31 | * hw/core/irq: remove unused 'qemu_irq_split' function |
23 | * hw/arm/virt: Support CPU cluster on ARM virt machine | 32 | * npcm7xx: use symbolic constants for PWRON STRAP bit fields |
24 | * docs/can: convert to restructuredText | 33 | * virt: document impact of gic-version on max CPUs |
25 | * hw/net: Move MV88W8618 network device out of hw/arm/ directory | ||
26 | * hw/arm/virt: KVM: Enable PAuth when supported by the host | ||
27 | 34 | ||
28 | ---------------------------------------------------------------- | 35 | ---------------------------------------------------------------- |
29 | Gavin Shan (2): | 36 | Edgar E. Iglesias (6): |
30 | virtio-mem: Correct default THP size for ARM64 | 37 | timer: cadence_ttc: Break out header file to allow embedding |
31 | hw/arm/virt: Support for virtio-mem-pci | 38 | hw/arm/xlnx-zynqmp: Connect 4 TTC timers |
39 | hw/arm: versal: Create an APU CPU Cluster | ||
40 | hw/arm: versal: Add the Cortex-R5Fs | ||
41 | hw/misc: Add a model of the Xilinx Versal CRL | ||
42 | hw/arm: versal: Connect the CRL | ||
32 | 43 | ||
33 | Lucas Ramage (1): | 44 | Hao Wu (2): |
34 | docs/can: convert to restructuredText | 45 | hw/misc: Add PWRON STRAP bit fields in GCR module |
46 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs | ||
35 | 47 | ||
36 | Marc Zyngier (7): | 48 | Heinrich Schuchardt (1): |
37 | hw/arm/virt: KVM: Enable PAuth when supported by the host | 49 | hw/arm/virt: impact of gic-version on max CPUs |
38 | hw/arm/virt: Add a control for the the highmem PCIe MMIO | ||
39 | hw/arm/virt: Add a control for the the highmem redistributors | ||
40 | hw/arm/virt: Honor highmem setting when computing the memory map | ||
41 | hw/arm/virt: Use the PA range to compute the memory map | ||
42 | hw/arm/virt: Disable highmem devices that don't fit in the PA range | ||
43 | hw/arm/virt: Drop superfluous checks against highmem | ||
44 | 50 | ||
45 | Patrick Venture (1): | 51 | Peter Maydell (19): |
46 | hw/arm: kudo add lm75s behind bus 1 switch at 75 | 52 | hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF |
53 | hw/arm/exynos4210: Use TYPE_OR_IRQ instead of custom OR-gate device | ||
54 | hw/intc/exynos4210_gic: Remove unused TYPE_EXYNOS4210_IRQ_GATE | ||
55 | hw/arm/exynos4210: Put a9mpcore device into state struct | ||
56 | hw/arm/exynos4210: Drop int_gic_irq[] from Exynos4210Irq struct | ||
57 | hw/arm/exynos4210: Coalesce board_irqs and irq_table | ||
58 | hw/arm/exynos4210: Fix code style nit in combiner_grp_to_gic_id[] | ||
59 | hw/arm/exynos4210: Move exynos4210_init_board_irqs() into exynos4210.c | ||
60 | hw/arm/exynos4210: Put external GIC into state struct | ||
61 | hw/arm/exynos4210: Drop ext_gic_irq[] from Exynos4210Irq struct | ||
62 | hw/arm/exynos4210: Move exynos4210_combiner_get_gpioin() into exynos4210.c | ||
63 | hw/arm/exynos4210: Delete unused macro definitions | ||
64 | hw/arm/exynos4210: Use TYPE_SPLIT_IRQ in exynos4210_init_board_irqs() | ||
65 | hw/arm/exynos4210: Fill in irq_table[] for internal-combiner-only IRQ lines | ||
66 | hw/arm/exynos4210: Connect MCT_G0 and MCT_G1 to both combiners | ||
67 | hw/arm/exynos4210: Don't connect multiple lines to external GIC inputs | ||
68 | hw/arm/exynos4210: Fold combiner splits into exynos4210_init_board_irqs() | ||
69 | hw/arm/exynos4210: Put combiners into state struct | ||
70 | hw/arm/exynos4210: Drop Exynos4210Irq struct | ||
47 | 71 | ||
48 | Peter Maydell (13): | 72 | Zongyuan Li (3): |
49 | hw/intc/arm_gicv3_its: Fix event ID bounds checks | 73 | hw/arm/realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
50 | hw/intc/arm_gicv3_its: Convert int ID check to num_intids convention | 74 | hw/arm/stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
51 | hw/intc/arm_gicv3_its: Fix handling of process_its_cmd() return value | 75 | hw/core/irq: remove unused 'qemu_irq_split' function |
52 | hw/intc/arm_gicv3_its: Don't use data if reading command failed | ||
53 | hw/intc/arm_gicv3_its: Use enum for return value of process_* functions | ||
54 | hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd() | ||
55 | hw/intc/arm_gicv3_its: Refactor process_its_cmd() to reduce nesting | ||
56 | hw/intc/arm_gicv3_its: Fix return codes in process_mapti() | ||
57 | hw/intc/arm_gicv3_its: Fix return codes in process_mapc() | ||
58 | hw/intc/arm_gicv3_its: Fix return codes in process_mapd() | ||
59 | hw/intc/arm_gicv3_its: Factor out "find address of table entry" code | ||
60 | hw/intc/arm_gicv3_its: Check indexes before use, not after | ||
61 | hw/intc/arm_gicv3_its: Range-check ICID before indexing into collection table | ||
62 | 76 | ||
63 | Petr Pavlu (2): | 77 | docs/system/arm/virt.rst | 4 +- |
64 | hw/intc/arm_gic: Implement read of GICC_IIDR | 78 | include/hw/arm/exynos4210.h | 50 ++-- |
65 | hw/intc/arm_gic: Allow reset of the running priority | 79 | include/hw/arm/xlnx-versal.h | 16 ++ |
66 | 80 | include/hw/arm/xlnx-zynqmp.h | 4 + | |
67 | Philippe Mathieu-Daudé (4): | 81 | include/hw/intc/exynos4210_combiner.h | 57 +++++ |
68 | hw: Move MARVELL_88W8618 Kconfig from audio/ to arm/ | 82 | include/hw/intc/exynos4210_gic.h | 43 ++++ |
69 | hw/arm/musicpal: Fix coding style of code related to MV88W8618 device | 83 | include/hw/irq.h | 5 - |
70 | hw/net: Move MV88W8618 network device out of hw/arm/ directory | 84 | include/hw/misc/npcm7xx_gcr.h | 30 +++ |
71 | hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR | 85 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++++ |
72 | 86 | include/hw/timer/cadence_ttc.h | 54 +++++ | |
73 | Troy Lee (2): | 87 | hw/arm/exynos4210.c | 430 ++++++++++++++++++++++++++++++---- |
74 | hw/misc/aspeed_i3c.c: Introduce a dummy AST2600 I3C model. | 88 | hw/arm/npcm7xx_boards.c | 24 +- |
75 | hw/arm/aspeed: Add the i3c device to the AST2600 SoC | 89 | hw/arm/realview.c | 33 ++- |
76 | 90 | hw/arm/stellaris.c | 15 +- | |
77 | Yanan Wang (6): | 91 | hw/arm/virt.c | 7 + |
78 | hw/arm/virt: Support CPU cluster on ARM virt machine | 92 | hw/arm/xlnx-versal-virt.c | 6 +- |
79 | hw/arm/virt: Support cluster level in DT cpu-map | 93 | hw/arm/xlnx-versal.c | 99 +++++++- |
80 | hw/acpi/aml-build: Improve scalability of PPTT generation | 94 | hw/arm/xlnx-zynqmp.c | 22 ++ |
81 | tests/acpi/bios-tables-test: Allow changes to virt/PPTT file | 95 | hw/core/irq.c | 15 -- |
82 | hw/acpi/aml-build: Support cluster level in PPTT generation | 96 | hw/intc/exynos4210_combiner.c | 108 +-------- |
83 | tests/acpi/bios-table-test: Update expected virt/PPTT file | 97 | hw/intc/exynos4210_gic.c | 344 +-------------------------- |
84 | 98 | hw/misc/xlnx-versal-crl.c | 421 +++++++++++++++++++++++++++++++++ | |
85 | docs/system/arm/cpu-features.rst | 4 - | 99 | hw/timer/cadence_ttc.c | 32 +-- |
86 | docs/system/device-emulation.rst | 1 + | 100 | MAINTAINERS | 2 +- |
87 | docs/{can.txt => system/devices/can.rst} | 90 +++--- | 101 | hw/misc/meson.build | 1 + |
88 | include/hw/arm/aspeed_soc.h | 3 + | 102 | 25 files changed, 1457 insertions(+), 600 deletions(-) |
89 | include/hw/arm/virt.h | 5 +- | 103 | create mode 100644 include/hw/intc/exynos4210_combiner.h |
90 | include/hw/misc/aspeed_i3c.h | 48 +++ | 104 | create mode 100644 include/hw/intc/exynos4210_gic.h |
91 | include/hw/net/mv88w8618_eth.h | 12 + | 105 | create mode 100644 include/hw/misc/xlnx-versal-crl.h |
92 | target/arm/cpu.h | 1 + | 106 | create mode 100644 include/hw/timer/cadence_ttc.h |
93 | hw/acpi/aml-build.c | 68 +++-- | 107 | create mode 100644 hw/misc/xlnx-versal-crl.c |
94 | hw/arm/aspeed_ast2600.c | 16 + | ||
95 | hw/arm/musicpal.c | 381 +----------------------- | ||
96 | hw/arm/npcm7xx_boards.c | 10 +- | ||
97 | hw/arm/virt-acpi-build.c | 10 +- | ||
98 | hw/arm/virt.c | 184 ++++++++++-- | ||
99 | hw/intc/arm_gic.c | 11 + | ||
100 | hw/intc/arm_gicv3_its.c | 492 ++++++++++++++----------------- | ||
101 | hw/intc/arm_gicv3_redist.c | 4 +- | ||
102 | hw/misc/aspeed_i3c.c | 381 ++++++++++++++++++++++++ | ||
103 | hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++ | ||
104 | hw/virtio/virtio-mem.c | 36 ++- | ||
105 | target/arm/cpu.c | 16 +- | ||
106 | target/arm/cpu64.c | 31 +- | ||
107 | target/arm/kvm64.c | 21 ++ | ||
108 | MAINTAINERS | 2 + | ||
109 | hw/arm/Kconfig | 4 + | ||
110 | hw/audio/Kconfig | 3 - | ||
111 | hw/misc/meson.build | 1 + | ||
112 | hw/misc/trace-events | 6 + | ||
113 | hw/net/meson.build | 1 + | ||
114 | qemu-options.hx | 10 + | ||
115 | tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes | ||
116 | 31 files changed, 1473 insertions(+), 782 deletions(-) | ||
117 | rename docs/{can.txt => system/devices/can.rst} (68%) | ||
118 | create mode 100644 include/hw/misc/aspeed_i3c.h | ||
119 | create mode 100644 include/hw/net/mv88w8618_eth.h | ||
120 | create mode 100644 hw/misc/aspeed_i3c.c | ||
121 | create mode 100644 hw/net/mv88w8618_eth.c | ||
122 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | It's not possible to provide the guest with the Security extensions |
---|---|---|---|
2 | (TrustZone) when using KVM or HVF, because the hardware | ||
3 | virtualization extensions don't permit running EL3 guest code. | ||
4 | However, we weren't checking for this combination, with the result | ||
5 | that QEMU would assert if you tried it: | ||
2 | 6 | ||
3 | Now that the devices present in the extended memory map are checked | 7 | $ qemu-system-aarch64 -enable-kvm -machine virt,secure=on -cpu host -display none |
4 | against the available PA space and disabled when they don't fit, | 8 | Unexpected error in object_property_find_err() at ../../qom/object.c:1304: |
5 | there is no need to keep the same checks against highmem, as | 9 | qemu-system-aarch64: Property 'host-arm-cpu.secure-memory' not found |
6 | highmem really is a shortcut for the PA space being 32bit. | 10 | Aborted |
7 | 11 | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 12 | Check for this combination of options and report an error, in the |
9 | Signed-off-by: Marc Zyngier <maz@kernel.org> | 13 | same way we already do for attempts to give a KVM or HVF guest the |
10 | Message-id: 20220114140741.1358263-7-maz@kernel.org | 14 | Virtualization or MTE extensions. Now we will report: |
15 | |||
16 | qemu-system-aarch64: mach-virt: KVM does not support providing Security extensions (TrustZone) to the guest CPU | ||
17 | |||
18 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/961 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20220404155301.566542-1-peter.maydell@linaro.org | ||
12 | --- | 22 | --- |
13 | hw/arm/virt-acpi-build.c | 2 -- | 23 | hw/arm/virt.c | 7 +++++++ |
14 | hw/arm/virt.c | 5 +---- | 24 | 1 file changed, 7 insertions(+) |
15 | 2 files changed, 1 insertion(+), 6 deletions(-) | ||
16 | 25 | ||
17 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/virt-acpi-build.c | ||
20 | +++ b/hw/arm/virt-acpi-build.c | ||
21 | @@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) | ||
22 | acpi_add_table(table_offsets, tables_blob); | ||
23 | build_fadt_rev5(tables_blob, tables->linker, vms, dsdt); | ||
24 | |||
25 | - vms->highmem_redists &= vms->highmem; | ||
26 | - | ||
27 | acpi_add_table(table_offsets, tables_blob); | ||
28 | build_madt(tables_blob, tables->linker, vms); | ||
29 | |||
30 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 26 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
31 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/arm/virt.c | 28 | --- a/hw/arm/virt.c |
33 | +++ b/hw/arm/virt.c | 29 | +++ b/hw/arm/virt.c |
34 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 30 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
35 | 31 | exit(1); | |
36 | virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); | ||
37 | |||
38 | - vms->highmem_mmio &= vms->highmem; | ||
39 | - vms->highmem_redists &= vms->highmem; | ||
40 | - | ||
41 | create_gic(vms, sysmem); | ||
42 | |||
43 | virt_cpu_post_init(vms, sysmem); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
45 | machine->ram_size, "mach-virt.tag"); | ||
46 | } | 32 | } |
47 | 33 | ||
48 | - vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64); | 34 | + if (vms->secure && (kvm_enabled() || hvf_enabled())) { |
49 | + vms->highmem_ecam &= (!firmware_loaded || aarch64); | 35 | + error_report("mach-virt: %s does not support providing " |
50 | 36 | + "Security extensions (TrustZone) to the guest CPU", | |
51 | create_rtc(vms); | 37 | + kvm_enabled() ? "KVM" : "HVF"); |
52 | 38 | + exit(1); | |
39 | + } | ||
40 | + | ||
41 | if (vms->virt && (kvm_enabled() || hvf_enabled())) { | ||
42 | error_report("mach-virt: %s does not support providing " | ||
43 | "Virtualization extensions to the guest CPU", | ||
53 | -- | 44 | -- |
54 | 2.25.1 | 45 | 2.25.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Quoting Peter Maydell: | 3 | Break out header file to allow embedding of the the TTC. |
4 | 4 | ||
5 | "These MEMTX_* aren't from the memory transaction | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
6 | API functions; they're just being used by gicd_readl() and | 6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
7 | friends as a way to indicate a success/failure so that the | 7 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
8 | actual MemoryRegionOps read/write fns like gicv3_dist_read() | 8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
9 | can log a guest error." | 9 | Message-id: 20220331222017.2914409-2-edgar.iglesias@gmail.com |
10 | |||
11 | We are going to introduce more MemTxResult bits, so it is | ||
12 | safer to check for !MEMTX_OK rather than MEMTX_ERROR. | ||
13 | |||
14 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
15 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
18 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 11 | --- |
21 | hw/intc/arm_gicv3_redist.c | 4 ++-- | 12 | include/hw/timer/cadence_ttc.h | 54 ++++++++++++++++++++++++++++++++++ |
22 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | hw/timer/cadence_ttc.c | 32 ++------------------ |
14 | 2 files changed, 56 insertions(+), 30 deletions(-) | ||
15 | create mode 100644 include/hw/timer/cadence_ttc.h | ||
23 | 16 | ||
24 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | 17 | diff --git a/include/hw/timer/cadence_ttc.h b/include/hw/timer/cadence_ttc.h |
18 | new file mode 100644 | ||
19 | index XXXXXXX..XXXXXXX | ||
20 | --- /dev/null | ||
21 | +++ b/include/hw/timer/cadence_ttc.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | +/* | ||
24 | + * Xilinx Zynq cadence TTC model | ||
25 | + * | ||
26 | + * Copyright (c) 2011 Xilinx Inc. | ||
27 | + * Copyright (c) 2012 Peter A.G. Crosthwaite (peter.crosthwaite@petalogix.com) | ||
28 | + * Copyright (c) 2012 PetaLogix Pty Ltd. | ||
29 | + * Written By Haibing Ma | ||
30 | + * M. Habib | ||
31 | + * | ||
32 | + * This program is free software; you can redistribute it and/or | ||
33 | + * modify it under the terms of the GNU General Public License | ||
34 | + * as published by the Free Software Foundation; either version | ||
35 | + * 2 of the License, or (at your option) any later version. | ||
36 | + * | ||
37 | + * You should have received a copy of the GNU General Public License along | ||
38 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
39 | + */ | ||
40 | +#ifndef HW_TIMER_CADENCE_TTC_H | ||
41 | +#define HW_TIMER_CADENCE_TTC_H | ||
42 | + | ||
43 | +#include "hw/sysbus.h" | ||
44 | +#include "qemu/timer.h" | ||
45 | + | ||
46 | +typedef struct { | ||
47 | + QEMUTimer *timer; | ||
48 | + int freq; | ||
49 | + | ||
50 | + uint32_t reg_clock; | ||
51 | + uint32_t reg_count; | ||
52 | + uint32_t reg_value; | ||
53 | + uint16_t reg_interval; | ||
54 | + uint16_t reg_match[3]; | ||
55 | + uint32_t reg_intr; | ||
56 | + uint32_t reg_intr_en; | ||
57 | + uint32_t reg_event_ctrl; | ||
58 | + uint32_t reg_event; | ||
59 | + | ||
60 | + uint64_t cpu_time; | ||
61 | + unsigned int cpu_time_valid; | ||
62 | + | ||
63 | + qemu_irq irq; | ||
64 | +} CadenceTimerState; | ||
65 | + | ||
66 | +#define TYPE_CADENCE_TTC "cadence_ttc" | ||
67 | +OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) | ||
68 | + | ||
69 | +struct CadenceTTCState { | ||
70 | + SysBusDevice parent_obj; | ||
71 | + | ||
72 | + MemoryRegion iomem; | ||
73 | + CadenceTimerState timer[3]; | ||
74 | +}; | ||
75 | + | ||
76 | +#endif | ||
77 | diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 78 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/intc/arm_gicv3_redist.c | 79 | --- a/hw/timer/cadence_ttc.c |
27 | +++ b/hw/intc/arm_gicv3_redist.c | 80 | +++ b/hw/timer/cadence_ttc.c |
28 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data, | 81 | @@ -XXX,XX +XXX,XX @@ |
29 | break; | 82 | #include "qemu/timer.h" |
30 | } | 83 | #include "qom/object.h" |
31 | 84 | ||
32 | - if (r == MEMTX_ERROR) { | 85 | +#include "hw/timer/cadence_ttc.h" |
33 | + if (r != MEMTX_OK) { | 86 | + |
34 | qemu_log_mask(LOG_GUEST_ERROR, | 87 | #ifdef CADENCE_TTC_ERR_DEBUG |
35 | "%s: invalid guest read at offset " TARGET_FMT_plx | 88 | #define DB_PRINT(...) do { \ |
36 | " size %u\n", __func__, offset, size); | 89 | fprintf(stderr, ": %s: ", __func__); \ |
37 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data, | 90 | @@ -XXX,XX +XXX,XX @@ |
38 | break; | 91 | #define CLOCK_CTRL_PS_EN 0x00000001 |
39 | } | 92 | #define CLOCK_CTRL_PS_V 0x0000001e |
40 | 93 | ||
41 | - if (r == MEMTX_ERROR) { | 94 | -typedef struct { |
42 | + if (r != MEMTX_OK) { | 95 | - QEMUTimer *timer; |
43 | qemu_log_mask(LOG_GUEST_ERROR, | 96 | - int freq; |
44 | "%s: invalid guest write at offset " TARGET_FMT_plx | 97 | - |
45 | " size %u\n", __func__, offset, size); | 98 | - uint32_t reg_clock; |
99 | - uint32_t reg_count; | ||
100 | - uint32_t reg_value; | ||
101 | - uint16_t reg_interval; | ||
102 | - uint16_t reg_match[3]; | ||
103 | - uint32_t reg_intr; | ||
104 | - uint32_t reg_intr_en; | ||
105 | - uint32_t reg_event_ctrl; | ||
106 | - uint32_t reg_event; | ||
107 | - | ||
108 | - uint64_t cpu_time; | ||
109 | - unsigned int cpu_time_valid; | ||
110 | - | ||
111 | - qemu_irq irq; | ||
112 | -} CadenceTimerState; | ||
113 | - | ||
114 | -#define TYPE_CADENCE_TTC "cadence_ttc" | ||
115 | -OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) | ||
116 | - | ||
117 | -struct CadenceTTCState { | ||
118 | - SysBusDevice parent_obj; | ||
119 | - | ||
120 | - MemoryRegion iomem; | ||
121 | - CadenceTimerState timer[3]; | ||
122 | -}; | ||
123 | - | ||
124 | static void cadence_timer_update(CadenceTimerState *s) | ||
125 | { | ||
126 | qemu_set_irq(s->irq, !!(s->reg_intr & s->reg_intr_en)); | ||
46 | -- | 127 | -- |
47 | 2.25.1 | 128 | 2.25.1 |
48 | |||
49 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Just like we can control the enablement of the highmem PCIe region | 3 | Connect the 4 TTC timers on the ZynqMP. |
4 | using highmem_ecam, let's add a control for the highmem GICv3 | ||
5 | redistributor region. | ||
6 | 4 | ||
7 | Similarily to highmem_ecam, these redistributors are disabled when | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
8 | highmem is off. | 6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
9 | 7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | |
10 | Reviewed-by: Andrew Jones <drjones@redhat.com> | 8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
11 | Signed-off-by: Marc Zyngier <maz@kernel.org> | 9 | Message-id: 20220331222017.2914409-3-edgar.iglesias@gmail.com |
12 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Message-id: 20220114140741.1358263-3-maz@kernel.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 11 | --- |
16 | include/hw/arm/virt.h | 4 +++- | 12 | include/hw/arm/xlnx-zynqmp.h | 4 ++++ |
17 | hw/arm/virt-acpi-build.c | 2 ++ | 13 | hw/arm/xlnx-zynqmp.c | 22 ++++++++++++++++++++++ |
18 | hw/arm/virt.c | 2 ++ | 14 | 2 files changed, 26 insertions(+) |
19 | 3 files changed, 7 insertions(+), 1 deletion(-) | ||
20 | 15 | ||
21 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 16 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h |
22 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/virt.h | 18 | --- a/include/hw/arm/xlnx-zynqmp.h |
24 | +++ b/include/hw/arm/virt.h | 19 | +++ b/include/hw/arm/xlnx-zynqmp.h |
25 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { | 20 | @@ -XXX,XX +XXX,XX @@ |
26 | bool highmem; | 21 | #include "hw/or-irq.h" |
27 | bool highmem_ecam; | 22 | #include "hw/misc/xlnx-zynqmp-apu-ctrl.h" |
28 | bool highmem_mmio; | 23 | #include "hw/misc/xlnx-zynqmp-crf.h" |
29 | + bool highmem_redists; | 24 | +#include "hw/timer/cadence_ttc.h" |
30 | bool its; | 25 | |
31 | bool tcg_its; | 26 | #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp" |
32 | bool virt; | 27 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) |
33 | @@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | 28 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) |
34 | 29 | #define XLNX_ZYNQMP_MAX_RAM_SIZE (XLNX_ZYNQMP_MAX_LOW_RAM_SIZE + \ | |
35 | assert(vms->gic_version == VIRT_GIC_VERSION_3); | 30 | XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE) |
36 | 31 | ||
37 | - return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1; | 32 | +#define XLNX_ZYNQMP_NUM_TTC 4 |
38 | + return (MACHINE(vms)->smp.cpus > redist0_capacity && | 33 | + |
39 | + vms->highmem_redists) ? 2 : 1; | 34 | /* |
35 | * Unimplemented mmio regions needed to boot some images. | ||
36 | */ | ||
37 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | ||
38 | qemu_or_irq qspi_irq_orgate; | ||
39 | XlnxZynqMPAPUCtrl apu_ctrl; | ||
40 | XlnxZynqMPCRF crf; | ||
41 | + CadenceTTCState ttc[XLNX_ZYNQMP_NUM_TTC]; | ||
42 | |||
43 | char *boot_cpu; | ||
44 | ARMCPU *boot_cpu_ptr; | ||
45 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/arm/xlnx-zynqmp.c | ||
48 | +++ b/hw/arm/xlnx-zynqmp.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | #define APU_ADDR 0xfd5c0000 | ||
51 | #define APU_IRQ 153 | ||
52 | |||
53 | +#define TTC0_ADDR 0xFF110000 | ||
54 | +#define TTC0_IRQ 36 | ||
55 | + | ||
56 | #define IPI_ADDR 0xFF300000 | ||
57 | #define IPI_IRQ 64 | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_crf(XlnxZynqMPState *s, qemu_irq *gic) | ||
60 | sysbus_connect_irq(sbd, 0, gic[CRF_IRQ]); | ||
40 | } | 61 | } |
41 | 62 | ||
42 | #endif /* QEMU_ARM_VIRT_H */ | 63 | +static void xlnx_zynqmp_create_ttc(XlnxZynqMPState *s, qemu_irq *gic) |
43 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 64 | +{ |
44 | index XXXXXXX..XXXXXXX 100644 | 65 | + SysBusDevice *sbd; |
45 | --- a/hw/arm/virt-acpi-build.c | 66 | + int i, irq; |
46 | +++ b/hw/arm/virt-acpi-build.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) | ||
48 | acpi_add_table(table_offsets, tables_blob); | ||
49 | build_fadt_rev5(tables_blob, tables->linker, vms, dsdt); | ||
50 | |||
51 | + vms->highmem_redists &= vms->highmem; | ||
52 | + | 67 | + |
53 | acpi_add_table(table_offsets, tables_blob); | 68 | + for (i = 0; i < XLNX_ZYNQMP_NUM_TTC; i++) { |
54 | build_madt(tables_blob, tables->linker, vms); | 69 | + object_initialize_child(OBJECT(s), "ttc[*]", &s->ttc[i], |
55 | 70 | + TYPE_CADENCE_TTC); | |
56 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 71 | + sbd = SYS_BUS_DEVICE(&s->ttc[i]); |
57 | index XXXXXXX..XXXXXXX 100644 | 72 | + |
58 | --- a/hw/arm/virt.c | 73 | + sysbus_realize(sbd, &error_fatal); |
59 | +++ b/hw/arm/virt.c | 74 | + sysbus_mmio_map(sbd, 0, TTC0_ADDR + i * 0x10000); |
60 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 75 | + for (irq = 0; irq < 3; irq++) { |
61 | virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); | 76 | + sysbus_connect_irq(sbd, irq, gic[TTC0_IRQ + i * 3 + irq]); |
62 | 77 | + } | |
63 | vms->highmem_mmio &= vms->highmem; | 78 | + } |
64 | + vms->highmem_redists &= vms->highmem; | 79 | +} |
65 | 80 | + | |
66 | create_gic(vms, sysmem); | 81 | static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s) |
67 | 82 | { | |
68 | @@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj) | 83 | static const struct UnimpInfo { |
69 | 84 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | |
70 | vms->highmem_ecam = !vmc->no_highmem_ecam; | 85 | xlnx_zynqmp_create_efuse(s, gic_spi); |
71 | vms->highmem_mmio = true; | 86 | xlnx_zynqmp_create_apu_ctrl(s, gic_spi); |
72 | + vms->highmem_redists = true; | 87 | xlnx_zynqmp_create_crf(s, gic_spi); |
73 | 88 | + xlnx_zynqmp_create_ttc(s, gic_spi); | |
74 | if (vmc->no_its) { | 89 | xlnx_zynqmp_create_unimp_mmio(s); |
75 | vms->its = false; | 90 | |
91 | for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) { | ||
76 | -- | 92 | -- |
77 | 2.25.1 | 93 | 2.25.1 |
78 | |||
79 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Even when the VM is configured with highmem=off, the highest_gpa | 3 | Create an APU CPU Cluster. This is in preparation to add the RPU. |
4 | field includes devices that are above the 4GiB limit. | ||
5 | Similarily, nothing seem to check that the memory is within | ||
6 | the limit set by the highmem=off option. | ||
7 | 4 | ||
8 | This leads to failures in virt_kvm_type() on systems that have | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
9 | a crippled IPA range, as the reported IPA space is larger than | 6 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> |
10 | what it should be. | 7 | Message-id: 20220406174303.2022038-2-edgar.iglesias@xilinx.com |
11 | |||
12 | Instead, honor the user-specified limit to only use the devices | ||
13 | at the lowest end of the spectrum, and fail if we have memory | ||
14 | crossing the 4GiB limit. | ||
15 | |||
16 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
17 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
19 | Message-id: 20220114140741.1358263-4-maz@kernel.org | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 9 | --- |
22 | hw/arm/virt.c | 10 +++++++--- | 10 | include/hw/arm/xlnx-versal.h | 2 ++ |
23 | 1 file changed, 7 insertions(+), 3 deletions(-) | 11 | hw/arm/xlnx-versal.c | 9 ++++++++- |
12 | 2 files changed, 10 insertions(+), 1 deletion(-) | ||
24 | 13 | ||
25 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 14 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h |
26 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/virt.c | 16 | --- a/include/hw/arm/xlnx-versal.h |
28 | +++ b/hw/arm/virt.c | 17 | +++ b/include/hw/arm/xlnx-versal.h |
29 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | 18 | @@ -XXX,XX +XXX,XX @@ |
30 | static void virt_set_memmap(VirtMachineState *vms) | 19 | |
20 | #include "hw/sysbus.h" | ||
21 | #include "hw/arm/boot.h" | ||
22 | +#include "hw/cpu/cluster.h" | ||
23 | #include "hw/or-irq.h" | ||
24 | #include "hw/sd/sdhci.h" | ||
25 | #include "hw/intc/arm_gicv3.h" | ||
26 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
27 | struct { | ||
28 | struct { | ||
29 | MemoryRegion mr; | ||
30 | + CPUClusterState cluster; | ||
31 | ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; | ||
32 | GICv3State gic; | ||
33 | } apu; | ||
34 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/arm/xlnx-versal.c | ||
37 | +++ b/hw/arm/xlnx-versal.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | ||
31 | { | 39 | { |
32 | MachineState *ms = MACHINE(vms); | ||
33 | - hwaddr base, device_memory_base, device_memory_size; | ||
34 | + hwaddr base, device_memory_base, device_memory_size, memtop; | ||
35 | int i; | 40 | int i; |
36 | 41 | ||
37 | vms->memmap = extended_memmap; | 42 | + object_initialize_child(OBJECT(s), "apu-cluster", &s->fpd.apu.cluster, |
38 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms) | 43 | + TYPE_CPU_CLUSTER); |
39 | device_memory_size = ms->maxram_size - ms->ram_size + ms->ram_slots * GiB; | 44 | + qdev_prop_set_uint32(DEVICE(&s->fpd.apu.cluster), "cluster-id", 0); |
40 | 45 | + | |
41 | /* Base address of the high IO region */ | 46 | for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { |
42 | - base = device_memory_base + ROUND_UP(device_memory_size, GiB); | 47 | Object *obj; |
43 | + memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB); | 48 | |
44 | + if (!vms->highmem && memtop > 4 * GiB) { | 49 | - object_initialize_child(OBJECT(s), "apu-cpu[*]", &s->fpd.apu.cpu[i], |
45 | + error_report("highmem=off, but memory crosses the 4GiB limit\n"); | 50 | + object_initialize_child(OBJECT(&s->fpd.apu.cluster), |
46 | + exit(EXIT_FAILURE); | 51 | + "apu-cpu[*]", &s->fpd.apu.cpu[i], |
47 | + } | 52 | XLNX_VERSAL_ACPU_TYPE); |
48 | if (base < device_memory_base) { | 53 | obj = OBJECT(&s->fpd.apu.cpu[i]); |
49 | error_report("maxmem/slots too huge"); | 54 | if (i) { |
50 | exit(EXIT_FAILURE); | 55 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) |
51 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms) | 56 | &error_abort); |
52 | vms->memmap[i].size = size; | 57 | qdev_realize(DEVICE(obj), NULL, &error_fatal); |
53 | base += size; | ||
54 | } | 58 | } |
55 | - vms->highest_gpa = base - 1; | 59 | + |
56 | + vms->highest_gpa = (vms->highmem ? base : memtop) - 1; | 60 | + qdev_realize(DEVICE(&s->fpd.apu.cluster), NULL, &error_fatal); |
57 | if (device_memory_size > 0) { | 61 | } |
58 | ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); | 62 | |
59 | ms->device_memory->base = device_memory_base; | 63 | static void versal_create_apu_gic(Versal *s, qemu_irq *pic) |
60 | -- | 64 | -- |
61 | 2.25.1 | 65 | 2.25.1 |
62 | |||
63 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Add basic support for Pointer Authentication when running a KVM | 3 | Add the Cortex-R5Fs of the Versal RPU (Real-time Processing Unit) |
4 | guest and that the host supports it, loosely based on the SVE | 4 | subsystem. |
5 | support. | ||
6 | 5 | ||
7 | Although the feature is enabled by default when the host advertises | 6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
8 | it, it is possible to disable it by setting the 'pauth=off' CPU | 7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> |
9 | property. The 'pauth' comment is removed from cpu-features.rst, | 8 | Message-id: 20220406174303.2022038-3-edgar.iglesias@xilinx.com |
10 | as it is now common to both TCG and KVM. | ||
11 | |||
12 | Tested on an Apple M1 running 5.16-rc6. | ||
13 | |||
14 | Cc: Eric Auger <eric.auger@redhat.com> | ||
15 | Cc: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
18 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Message-id: 20220107150154.2490308-1-maz@kernel.org | ||
21 | [PMM: fixed indentation] | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | --- | 10 | --- |
24 | docs/system/arm/cpu-features.rst | 4 ---- | 11 | include/hw/arm/xlnx-versal.h | 10 ++++++++++ |
25 | target/arm/cpu.h | 1 + | 12 | hw/arm/xlnx-versal-virt.c | 6 +++--- |
26 | target/arm/cpu.c | 16 +++++----------- | 13 | hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++++++++++ |
27 | target/arm/cpu64.c | 31 +++++++++++++++++++++++++++---- | 14 | 3 files changed, 49 insertions(+), 3 deletions(-) |
28 | target/arm/kvm64.c | 21 +++++++++++++++++++++ | ||
29 | 5 files changed, 54 insertions(+), 19 deletions(-) | ||
30 | 15 | ||
31 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst | 16 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h |
32 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/docs/system/arm/cpu-features.rst | 18 | --- a/include/hw/arm/xlnx-versal.h |
34 | +++ b/docs/system/arm/cpu-features.rst | 19 | +++ b/include/hw/arm/xlnx-versal.h |
35 | @@ -XXX,XX +XXX,XX @@ TCG VCPU Features | 20 | @@ -XXX,XX +XXX,XX @@ |
36 | TCG VCPU features are CPU features that are specific to TCG. | 21 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) |
37 | Below is the list of TCG VCPU features and their descriptions. | 22 | |
38 | 23 | #define XLNX_VERSAL_NR_ACPUS 2 | |
39 | - pauth Enable or disable ``FEAT_Pauth``, pointer | 24 | +#define XLNX_VERSAL_NR_RCPUS 2 |
40 | - authentication. By default, the feature is | 25 | #define XLNX_VERSAL_NR_UARTS 2 |
41 | - enabled with ``-cpu max``. | 26 | #define XLNX_VERSAL_NR_GEMS 2 |
42 | - | 27 | #define XLNX_VERSAL_NR_ADMAS 8 |
43 | pauth-impdef When ``FEAT_Pauth`` is enabled, either the | 28 | @@ -XXX,XX +XXX,XX @@ struct Versal { |
44 | *impdef* (Implementation Defined) algorithm | 29 | VersalUsb2 usb; |
45 | is enabled or the *architected* QARMA algorithm | 30 | } iou; |
46 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 31 | |
32 | + /* Real-time Processing Unit. */ | ||
33 | + struct { | ||
34 | + MemoryRegion mr; | ||
35 | + MemoryRegion mr_ps_alias; | ||
36 | + | ||
37 | + CPUClusterState cluster; | ||
38 | + ARMCPU cpu[XLNX_VERSAL_NR_RCPUS]; | ||
39 | + } rpu; | ||
40 | + | ||
41 | struct { | ||
42 | qemu_or_irq irq_orgate; | ||
43 | XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | ||
44 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/cpu.h | 46 | --- a/hw/arm/xlnx-versal-virt.c |
49 | +++ b/target/arm/cpu.h | 47 | +++ b/hw/arm/xlnx-versal-virt.c |
50 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); | 48 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data) |
51 | void aarch64_sve_change_el(CPUARMState *env, int old_el, | 49 | |
52 | int new_el, bool el0_a64); | 50 | mc->desc = "Xilinx Versal Virtual development board"; |
53 | void aarch64_add_sve_properties(Object *obj); | 51 | mc->init = versal_virt_init; |
54 | +void aarch64_add_pauth_properties(Object *obj); | 52 | - mc->min_cpus = XLNX_VERSAL_NR_ACPUS; |
55 | 53 | - mc->max_cpus = XLNX_VERSAL_NR_ACPUS; | |
56 | /* | 54 | - mc->default_cpus = XLNX_VERSAL_NR_ACPUS; |
57 | * SVE registers are encoded in KVM's memory in an endianness-invariant format. | 55 | + mc->min_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; |
58 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 56 | + mc->max_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; |
57 | + mc->default_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
58 | mc->no_cdrom = true; | ||
59 | mc->default_ram_id = "ddr"; | ||
60 | } | ||
61 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/cpu.c | 63 | --- a/hw/arm/xlnx-versal.c |
61 | +++ b/target/arm/cpu.c | 64 | +++ b/hw/arm/xlnx-versal.c |
62 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | 65 | @@ -XXX,XX +XXX,XX @@ |
63 | return; | 66 | #include "hw/sysbus.h" |
64 | } | 67 | |
65 | 68 | #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72") | |
66 | - /* | 69 | +#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f") |
67 | - * KVM does not support modifications to this feature. | 70 | #define GEM_REVISION 0x40070106 |
68 | - * We have not registered the cpu properties when KVM | 71 | |
69 | - * is in use, so the user will not be able to set them. | 72 | #define VERSAL_NUM_PMC_APB_IRQS 3 |
70 | - */ | 73 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) |
71 | - if (!kvm_enabled()) { | ||
72 | - arm_cpu_pauth_finalize(cpu, &local_err); | ||
73 | - if (local_err != NULL) { | ||
74 | - error_propagate(errp, local_err); | ||
75 | - return; | ||
76 | - } | ||
77 | + arm_cpu_pauth_finalize(cpu, &local_err); | ||
78 | + if (local_err != NULL) { | ||
79 | + error_propagate(errp, local_err); | ||
80 | + return; | ||
81 | } | ||
82 | } | 74 | } |
83 | 75 | } | |
84 | @@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj) | 76 | |
85 | kvm_arm_set_cpu_features_from_host(cpu); | 77 | +static void versal_create_rpu_cpus(Versal *s) |
86 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | 78 | +{ |
87 | aarch64_add_sve_properties(obj); | 79 | + int i; |
88 | + aarch64_add_pauth_properties(obj); | ||
89 | } | ||
90 | #else | ||
91 | hvf_arm_set_cpu_features_from_host(cpu); | ||
92 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/cpu64.c | ||
95 | +++ b/target/arm/cpu64.c | ||
96 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) | ||
97 | int arch_val = 0, impdef_val = 0; | ||
98 | uint64_t t; | ||
99 | |||
100 | + /* Exit early if PAuth is enabled, and fall through to disable it */ | ||
101 | + if (kvm_enabled() && cpu->prop_pauth) { | ||
102 | + if (!cpu_isar_feature(aa64_pauth, cpu)) { | ||
103 | + error_setg(errp, "'pauth' feature not supported by KVM on this host"); | ||
104 | + } | ||
105 | + | 80 | + |
106 | + return; | 81 | + object_initialize_child(OBJECT(s), "rpu-cluster", &s->lpd.rpu.cluster, |
82 | + TYPE_CPU_CLUSTER); | ||
83 | + qdev_prop_set_uint32(DEVICE(&s->lpd.rpu.cluster), "cluster-id", 1); | ||
84 | + | ||
85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { | ||
86 | + Object *obj; | ||
87 | + | ||
88 | + object_initialize_child(OBJECT(&s->lpd.rpu.cluster), | ||
89 | + "rpu-cpu[*]", &s->lpd.rpu.cpu[i], | ||
90 | + XLNX_VERSAL_RCPU_TYPE); | ||
91 | + obj = OBJECT(&s->lpd.rpu.cpu[i]); | ||
92 | + object_property_set_bool(obj, "start-powered-off", true, | ||
93 | + &error_abort); | ||
94 | + | ||
95 | + object_property_set_int(obj, "mp-affinity", 0x100 | i, &error_abort); | ||
96 | + object_property_set_int(obj, "core-count", ARRAY_SIZE(s->lpd.rpu.cpu), | ||
97 | + &error_abort); | ||
98 | + object_property_set_link(obj, "memory", OBJECT(&s->lpd.rpu.mr), | ||
99 | + &error_abort); | ||
100 | + qdev_realize(DEVICE(obj), NULL, &error_fatal); | ||
107 | + } | 101 | + } |
108 | + | 102 | + |
109 | /* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */ | 103 | + qdev_realize(DEVICE(&s->lpd.rpu.cluster), NULL, &error_fatal); |
110 | if (cpu->prop_pauth) { | ||
111 | if (cpu->prop_pauth_impdef) { | ||
112 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pauth_property = | ||
113 | static Property arm_cpu_pauth_impdef_property = | ||
114 | DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); | ||
115 | |||
116 | +void aarch64_add_pauth_properties(Object *obj) | ||
117 | +{ | ||
118 | + ARMCPU *cpu = ARM_CPU(obj); | ||
119 | + | ||
120 | + /* Default to PAUTH on, with the architected algorithm on TCG. */ | ||
121 | + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property); | ||
122 | + if (kvm_enabled()) { | ||
123 | + /* | ||
124 | + * Mirror PAuth support from the probed sysregs back into the | ||
125 | + * property for KVM. Is it just a bit backward? Yes it is! | ||
126 | + */ | ||
127 | + cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu); | ||
128 | + } else { | ||
129 | + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property); | ||
130 | + } | ||
131 | +} | 104 | +} |
132 | + | 105 | + |
133 | /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); | 106 | static void versal_create_uarts(Versal *s, qemu_irq *pic) |
134 | * otherwise, a CPU with as many features enabled as our emulation supports. | 107 | { |
135 | * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; | 108 | int i; |
136 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 109 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) |
137 | cpu->dcz_blocksize = 7; /* 512 bytes */ | 110 | |
138 | #endif | 111 | versal_create_apu_cpus(s); |
139 | 112 | versal_create_apu_gic(s, pic); | |
140 | - /* Default to PAUTH on, with the architected algorithm. */ | 113 | + versal_create_rpu_cpus(s); |
141 | - qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property); | 114 | versal_create_uarts(s, pic); |
142 | - qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property); | 115 | versal_create_usbs(s, pic); |
143 | - | 116 | versal_create_gems(s, pic); |
144 | bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ); | 117 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) |
145 | } | 118 | |
146 | 119 | memory_region_add_subregion_overlap(&s->mr_ps, MM_OCM, &s->lpd.mr_ocm, 0); | |
147 | + aarch64_add_pauth_properties(obj); | 120 | memory_region_add_subregion_overlap(&s->fpd.apu.mr, 0, &s->mr_ps, 0); |
148 | aarch64_add_sve_properties(obj); | 121 | + memory_region_add_subregion_overlap(&s->lpd.rpu.mr, 0, |
149 | object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | 122 | + &s->lpd.rpu.mr_ps_alias, 0); |
150 | cpu_max_set_sve_max_vq, NULL, NULL); | ||
151 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/target/arm/kvm64.c | ||
154 | +++ b/target/arm/kvm64.c | ||
155 | @@ -XXX,XX +XXX,XX @@ static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id) | ||
156 | return ioctl(fd, KVM_GET_ONE_REG, &idreg); | ||
157 | } | 123 | } |
158 | 124 | ||
159 | +static bool kvm_arm_pauth_supported(void) | 125 | static void versal_init(Object *obj) |
160 | +{ | 126 | @@ -XXX,XX +XXX,XX @@ static void versal_init(Object *obj) |
161 | + return (kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_ADDRESS) && | 127 | Versal *s = XLNX_VERSAL(obj); |
162 | + kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC)); | 128 | |
163 | +} | 129 | memory_region_init(&s->fpd.apu.mr, obj, "mr-apu", UINT64_MAX); |
164 | + | 130 | + memory_region_init(&s->lpd.rpu.mr, obj, "mr-rpu", UINT64_MAX); |
165 | bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | 131 | memory_region_init(&s->mr_ps, obj, "mr-ps-switch", UINT64_MAX); |
166 | { | 132 | + memory_region_init_alias(&s->lpd.rpu.mr_ps_alias, OBJECT(s), |
167 | /* Identify the feature bits corresponding to the host CPU, and | 133 | + "mr-rpu-ps-alias", &s->mr_ps, 0, UINT64_MAX); |
168 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | 134 | } |
169 | */ | 135 | |
170 | struct kvm_vcpu_init init = { .target = -1, }; | 136 | static Property versal_properties[] = { |
171 | |||
172 | + /* | ||
173 | + * Ask for Pointer Authentication if supported. We can't play the | ||
174 | + * SVE trick of synthesising the ID reg as KVM won't tell us | ||
175 | + * whether we have the architected or IMPDEF version of PAuth, so | ||
176 | + * we have to use the actual ID regs. | ||
177 | + */ | ||
178 | + if (kvm_arm_pauth_supported()) { | ||
179 | + init.features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | | ||
180 | + 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); | ||
181 | + } | ||
182 | + | ||
183 | if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { | ||
184 | return false; | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs) | ||
187 | assert(kvm_arm_sve_supported()); | ||
188 | cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE; | ||
189 | } | ||
190 | + if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
191 | + cpu->kvm_init_features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | | ||
192 | + 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); | ||
193 | + } | ||
194 | |||
195 | /* Do KVM_ARM_VCPU_INIT ioctl */ | ||
196 | ret = kvm_arm_vcpu_init(cs); | ||
197 | -- | 137 | -- |
198 | 2.25.1 | 138 | 2.25.1 |
199 | |||
200 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
2 | 1 | ||
3 | The Marvell 88W8618 is a system-on-chip with an ARM core. | ||
4 | We implement its audio codecs and network interface. | ||
5 | Homogeneous SoC Kconfig are usually defined in the hw/$ARCH | ||
6 | directory. Move it there. | ||
7 | |||
8 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20220107184429.423572-2-f4bug@amsat.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/Kconfig | 3 +++ | ||
15 | hw/audio/Kconfig | 3 --- | ||
16 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/arm/Kconfig | ||
21 | +++ b/hw/arm/Kconfig | ||
22 | @@ -XXX,XX +XXX,XX @@ config MUSCA | ||
23 | select SPLIT_IRQ | ||
24 | select UNIMP | ||
25 | |||
26 | +config MARVELL_88W8618 | ||
27 | + bool | ||
28 | + | ||
29 | config MUSICPAL | ||
30 | bool | ||
31 | select OR_IRQ | ||
32 | diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/audio/Kconfig | ||
35 | +++ b/hw/audio/Kconfig | ||
36 | @@ -XXX,XX +XXX,XX @@ config PL041 | ||
37 | |||
38 | config CS4231 | ||
39 | bool | ||
40 | - | ||
41 | -config MARVELL_88W8618 | ||
42 | - bool | ||
43 | -- | ||
44 | 2.25.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
1 | From: Troy Lee <troy_lee@aspeedtech.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Aspeed 2600 SDK enables I3C support by default. The I3C driver will try | 3 | Add a model of the Xilinx Versal CRL. |
4 | to reset the device controller and set it up through device address table | ||
5 | register. This dummy model responds to these registers with default values | ||
6 | as listed in the ast2600v10 datasheet chapter 54.2. | ||
7 | 4 | ||
8 | This avoids a guest machine kernel panic due to referencing an | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
9 | invalid kernel address if the device address table register isn't | 6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> |
10 | set correctly. | 7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> |
11 | 8 | Message-id: 20220406174303.2022038-4-edgar.iglesias@xilinx.com | |
12 | Signed-off-by: Troy Lee <troy_lee@aspeedtech.com> | ||
13 | Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com> | ||
14 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Tested-by: Graeme Gregory <quic_ggregory@quicinc.com> | ||
16 | Message-id: 20220111084546.4145785-2-troy_lee@aspeedtech.com | ||
17 | [PMM: tidied commit message] | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 10 | --- |
20 | include/hw/misc/aspeed_i3c.h | 48 +++++ | 11 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++ |
21 | hw/misc/aspeed_i3c.c | 381 +++++++++++++++++++++++++++++++++++ | 12 | hw/misc/xlnx-versal-crl.c | 421 ++++++++++++++++++++++++++++++ |
22 | hw/misc/meson.build | 1 + | 13 | hw/misc/meson.build | 1 + |
23 | hw/misc/trace-events | 6 + | 14 | 3 files changed, 657 insertions(+) |
24 | 4 files changed, 436 insertions(+) | 15 | create mode 100644 include/hw/misc/xlnx-versal-crl.h |
25 | create mode 100644 include/hw/misc/aspeed_i3c.h | 16 | create mode 100644 hw/misc/xlnx-versal-crl.c |
26 | create mode 100644 hw/misc/aspeed_i3c.c | ||
27 | 17 | ||
28 | diff --git a/include/hw/misc/aspeed_i3c.h b/include/hw/misc/aspeed_i3c.h | 18 | diff --git a/include/hw/misc/xlnx-versal-crl.h b/include/hw/misc/xlnx-versal-crl.h |
29 | new file mode 100644 | 19 | new file mode 100644 |
30 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
31 | --- /dev/null | 21 | --- /dev/null |
32 | +++ b/include/hw/misc/aspeed_i3c.h | 22 | +++ b/include/hw/misc/xlnx-versal-crl.h |
33 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
34 | +/* | 24 | +/* |
35 | + * ASPEED I3C Controller | 25 | + * QEMU model of the Clock-Reset-LPD (CRL). |
36 | + * | 26 | + * |
37 | + * Copyright (C) 2021 ASPEED Technology Inc. | 27 | + * Copyright (c) 2022 Xilinx Inc. |
28 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
38 | + * | 29 | + * |
39 | + * This code is licensed under the GPL version 2 or later. See | 30 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
40 | + * the COPYING file in the top-level directory. | ||
41 | + */ | 31 | + */ |
42 | + | 32 | +#ifndef HW_MISC_XLNX_VERSAL_CRL_H |
43 | +#ifndef ASPEED_I3C_H | 33 | +#define HW_MISC_XLNX_VERSAL_CRL_H |
44 | +#define ASPEED_I3C_H | ||
45 | + | 34 | + |
46 | +#include "hw/sysbus.h" | 35 | +#include "hw/sysbus.h" |
47 | + | 36 | +#include "hw/register.h" |
48 | +#define TYPE_ASPEED_I3C "aspeed.i3c" | 37 | +#include "target/arm/cpu.h" |
49 | +#define TYPE_ASPEED_I3C_DEVICE "aspeed.i3c.device" | 38 | + |
50 | +OBJECT_DECLARE_TYPE(AspeedI3CState, AspeedI3CClass, ASPEED_I3C) | 39 | +#define TYPE_XLNX_VERSAL_CRL "xlnx,versal-crl" |
51 | + | 40 | +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCRL, XLNX_VERSAL_CRL) |
52 | +#define ASPEED_I3C_NR_REGS (0x70 >> 2) | 41 | + |
53 | +#define ASPEED_I3C_DEVICE_NR_REGS (0x300 >> 2) | 42 | +REG32(ERR_CTRL, 0x0) |
54 | +#define ASPEED_I3C_NR_DEVICES 6 | 43 | + FIELD(ERR_CTRL, SLVERR_ENABLE, 0, 1) |
55 | + | 44 | +REG32(IR_STATUS, 0x4) |
56 | +OBJECT_DECLARE_SIMPLE_TYPE(AspeedI3CDevice, ASPEED_I3C_DEVICE) | 45 | + FIELD(IR_STATUS, ADDR_DECODE_ERR, 0, 1) |
57 | +typedef struct AspeedI3CDevice { | 46 | +REG32(IR_MASK, 0x8) |
58 | + /* <private> */ | 47 | + FIELD(IR_MASK, ADDR_DECODE_ERR, 0, 1) |
59 | + SysBusDevice parent; | 48 | +REG32(IR_ENABLE, 0xc) |
60 | + | 49 | + FIELD(IR_ENABLE, ADDR_DECODE_ERR, 0, 1) |
61 | + /* <public> */ | 50 | +REG32(IR_DISABLE, 0x10) |
62 | + MemoryRegion mr; | 51 | + FIELD(IR_DISABLE, ADDR_DECODE_ERR, 0, 1) |
52 | +REG32(WPROT, 0x1c) | ||
53 | + FIELD(WPROT, ACTIVE, 0, 1) | ||
54 | +REG32(PLL_CLK_OTHER_DMN, 0x20) | ||
55 | + FIELD(PLL_CLK_OTHER_DMN, APLL_BYPASS, 0, 1) | ||
56 | +REG32(RPLL_CTRL, 0x40) | ||
57 | + FIELD(RPLL_CTRL, POST_SRC, 24, 3) | ||
58 | + FIELD(RPLL_CTRL, PRE_SRC, 20, 3) | ||
59 | + FIELD(RPLL_CTRL, CLKOUTDIV, 16, 2) | ||
60 | + FIELD(RPLL_CTRL, FBDIV, 8, 8) | ||
61 | + FIELD(RPLL_CTRL, BYPASS, 3, 1) | ||
62 | + FIELD(RPLL_CTRL, RESET, 0, 1) | ||
63 | +REG32(RPLL_CFG, 0x44) | ||
64 | + FIELD(RPLL_CFG, LOCK_DLY, 25, 7) | ||
65 | + FIELD(RPLL_CFG, LOCK_CNT, 13, 10) | ||
66 | + FIELD(RPLL_CFG, LFHF, 10, 2) | ||
67 | + FIELD(RPLL_CFG, CP, 5, 4) | ||
68 | + FIELD(RPLL_CFG, RES, 0, 4) | ||
69 | +REG32(RPLL_FRAC_CFG, 0x48) | ||
70 | + FIELD(RPLL_FRAC_CFG, ENABLED, 31, 1) | ||
71 | + FIELD(RPLL_FRAC_CFG, SEED, 22, 3) | ||
72 | + FIELD(RPLL_FRAC_CFG, ALGRTHM, 19, 1) | ||
73 | + FIELD(RPLL_FRAC_CFG, ORDER, 18, 1) | ||
74 | + FIELD(RPLL_FRAC_CFG, DATA, 0, 16) | ||
75 | +REG32(PLL_STATUS, 0x50) | ||
76 | + FIELD(PLL_STATUS, RPLL_STABLE, 2, 1) | ||
77 | + FIELD(PLL_STATUS, RPLL_LOCK, 0, 1) | ||
78 | +REG32(RPLL_TO_XPD_CTRL, 0x100) | ||
79 | + FIELD(RPLL_TO_XPD_CTRL, CLKACT, 25, 1) | ||
80 | + FIELD(RPLL_TO_XPD_CTRL, DIVISOR0, 8, 10) | ||
81 | +REG32(LPD_TOP_SWITCH_CTRL, 0x104) | ||
82 | + FIELD(LPD_TOP_SWITCH_CTRL, CLKACT_ADMA, 26, 1) | ||
83 | + FIELD(LPD_TOP_SWITCH_CTRL, CLKACT, 25, 1) | ||
84 | + FIELD(LPD_TOP_SWITCH_CTRL, DIVISOR0, 8, 10) | ||
85 | + FIELD(LPD_TOP_SWITCH_CTRL, SRCSEL, 0, 3) | ||
86 | +REG32(LPD_LSBUS_CTRL, 0x108) | ||
87 | + FIELD(LPD_LSBUS_CTRL, CLKACT, 25, 1) | ||
88 | + FIELD(LPD_LSBUS_CTRL, DIVISOR0, 8, 10) | ||
89 | + FIELD(LPD_LSBUS_CTRL, SRCSEL, 0, 3) | ||
90 | +REG32(CPU_R5_CTRL, 0x10c) | ||
91 | + FIELD(CPU_R5_CTRL, CLKACT_OCM2, 28, 1) | ||
92 | + FIELD(CPU_R5_CTRL, CLKACT_OCM, 27, 1) | ||
93 | + FIELD(CPU_R5_CTRL, CLKACT_CORE, 26, 1) | ||
94 | + FIELD(CPU_R5_CTRL, CLKACT, 25, 1) | ||
95 | + FIELD(CPU_R5_CTRL, DIVISOR0, 8, 10) | ||
96 | + FIELD(CPU_R5_CTRL, SRCSEL, 0, 3) | ||
97 | +REG32(IOU_SWITCH_CTRL, 0x114) | ||
98 | + FIELD(IOU_SWITCH_CTRL, CLKACT, 25, 1) | ||
99 | + FIELD(IOU_SWITCH_CTRL, DIVISOR0, 8, 10) | ||
100 | + FIELD(IOU_SWITCH_CTRL, SRCSEL, 0, 3) | ||
101 | +REG32(GEM0_REF_CTRL, 0x118) | ||
102 | + FIELD(GEM0_REF_CTRL, CLKACT_RX, 27, 1) | ||
103 | + FIELD(GEM0_REF_CTRL, CLKACT_TX, 26, 1) | ||
104 | + FIELD(GEM0_REF_CTRL, CLKACT, 25, 1) | ||
105 | + FIELD(GEM0_REF_CTRL, DIVISOR0, 8, 10) | ||
106 | + FIELD(GEM0_REF_CTRL, SRCSEL, 0, 3) | ||
107 | +REG32(GEM1_REF_CTRL, 0x11c) | ||
108 | + FIELD(GEM1_REF_CTRL, CLKACT_RX, 27, 1) | ||
109 | + FIELD(GEM1_REF_CTRL, CLKACT_TX, 26, 1) | ||
110 | + FIELD(GEM1_REF_CTRL, CLKACT, 25, 1) | ||
111 | + FIELD(GEM1_REF_CTRL, DIVISOR0, 8, 10) | ||
112 | + FIELD(GEM1_REF_CTRL, SRCSEL, 0, 3) | ||
113 | +REG32(GEM_TSU_REF_CTRL, 0x120) | ||
114 | + FIELD(GEM_TSU_REF_CTRL, CLKACT, 25, 1) | ||
115 | + FIELD(GEM_TSU_REF_CTRL, DIVISOR0, 8, 10) | ||
116 | + FIELD(GEM_TSU_REF_CTRL, SRCSEL, 0, 3) | ||
117 | +REG32(USB0_BUS_REF_CTRL, 0x124) | ||
118 | + FIELD(USB0_BUS_REF_CTRL, CLKACT, 25, 1) | ||
119 | + FIELD(USB0_BUS_REF_CTRL, DIVISOR0, 8, 10) | ||
120 | + FIELD(USB0_BUS_REF_CTRL, SRCSEL, 0, 3) | ||
121 | +REG32(UART0_REF_CTRL, 0x128) | ||
122 | + FIELD(UART0_REF_CTRL, CLKACT, 25, 1) | ||
123 | + FIELD(UART0_REF_CTRL, DIVISOR0, 8, 10) | ||
124 | + FIELD(UART0_REF_CTRL, SRCSEL, 0, 3) | ||
125 | +REG32(UART1_REF_CTRL, 0x12c) | ||
126 | + FIELD(UART1_REF_CTRL, CLKACT, 25, 1) | ||
127 | + FIELD(UART1_REF_CTRL, DIVISOR0, 8, 10) | ||
128 | + FIELD(UART1_REF_CTRL, SRCSEL, 0, 3) | ||
129 | +REG32(SPI0_REF_CTRL, 0x130) | ||
130 | + FIELD(SPI0_REF_CTRL, CLKACT, 25, 1) | ||
131 | + FIELD(SPI0_REF_CTRL, DIVISOR0, 8, 10) | ||
132 | + FIELD(SPI0_REF_CTRL, SRCSEL, 0, 3) | ||
133 | +REG32(SPI1_REF_CTRL, 0x134) | ||
134 | + FIELD(SPI1_REF_CTRL, CLKACT, 25, 1) | ||
135 | + FIELD(SPI1_REF_CTRL, DIVISOR0, 8, 10) | ||
136 | + FIELD(SPI1_REF_CTRL, SRCSEL, 0, 3) | ||
137 | +REG32(CAN0_REF_CTRL, 0x138) | ||
138 | + FIELD(CAN0_REF_CTRL, CLKACT, 25, 1) | ||
139 | + FIELD(CAN0_REF_CTRL, DIVISOR0, 8, 10) | ||
140 | + FIELD(CAN0_REF_CTRL, SRCSEL, 0, 3) | ||
141 | +REG32(CAN1_REF_CTRL, 0x13c) | ||
142 | + FIELD(CAN1_REF_CTRL, CLKACT, 25, 1) | ||
143 | + FIELD(CAN1_REF_CTRL, DIVISOR0, 8, 10) | ||
144 | + FIELD(CAN1_REF_CTRL, SRCSEL, 0, 3) | ||
145 | +REG32(I2C0_REF_CTRL, 0x140) | ||
146 | + FIELD(I2C0_REF_CTRL, CLKACT, 25, 1) | ||
147 | + FIELD(I2C0_REF_CTRL, DIVISOR0, 8, 10) | ||
148 | + FIELD(I2C0_REF_CTRL, SRCSEL, 0, 3) | ||
149 | +REG32(I2C1_REF_CTRL, 0x144) | ||
150 | + FIELD(I2C1_REF_CTRL, CLKACT, 25, 1) | ||
151 | + FIELD(I2C1_REF_CTRL, DIVISOR0, 8, 10) | ||
152 | + FIELD(I2C1_REF_CTRL, SRCSEL, 0, 3) | ||
153 | +REG32(DBG_LPD_CTRL, 0x148) | ||
154 | + FIELD(DBG_LPD_CTRL, CLKACT, 25, 1) | ||
155 | + FIELD(DBG_LPD_CTRL, DIVISOR0, 8, 10) | ||
156 | + FIELD(DBG_LPD_CTRL, SRCSEL, 0, 3) | ||
157 | +REG32(TIMESTAMP_REF_CTRL, 0x14c) | ||
158 | + FIELD(TIMESTAMP_REF_CTRL, CLKACT, 25, 1) | ||
159 | + FIELD(TIMESTAMP_REF_CTRL, DIVISOR0, 8, 10) | ||
160 | + FIELD(TIMESTAMP_REF_CTRL, SRCSEL, 0, 3) | ||
161 | +REG32(CRL_SAFETY_CHK, 0x150) | ||
162 | +REG32(PSM_REF_CTRL, 0x154) | ||
163 | + FIELD(PSM_REF_CTRL, DIVISOR0, 8, 10) | ||
164 | + FIELD(PSM_REF_CTRL, SRCSEL, 0, 3) | ||
165 | +REG32(DBG_TSTMP_CTRL, 0x158) | ||
166 | + FIELD(DBG_TSTMP_CTRL, CLKACT, 25, 1) | ||
167 | + FIELD(DBG_TSTMP_CTRL, DIVISOR0, 8, 10) | ||
168 | + FIELD(DBG_TSTMP_CTRL, SRCSEL, 0, 3) | ||
169 | +REG32(CPM_TOPSW_REF_CTRL, 0x15c) | ||
170 | + FIELD(CPM_TOPSW_REF_CTRL, CLKACT, 25, 1) | ||
171 | + FIELD(CPM_TOPSW_REF_CTRL, DIVISOR0, 8, 10) | ||
172 | + FIELD(CPM_TOPSW_REF_CTRL, SRCSEL, 0, 3) | ||
173 | +REG32(USB3_DUAL_REF_CTRL, 0x160) | ||
174 | + FIELD(USB3_DUAL_REF_CTRL, CLKACT, 25, 1) | ||
175 | + FIELD(USB3_DUAL_REF_CTRL, DIVISOR0, 8, 10) | ||
176 | + FIELD(USB3_DUAL_REF_CTRL, SRCSEL, 0, 3) | ||
177 | +REG32(RST_CPU_R5, 0x300) | ||
178 | + FIELD(RST_CPU_R5, RESET_PGE, 4, 1) | ||
179 | + FIELD(RST_CPU_R5, RESET_AMBA, 2, 1) | ||
180 | + FIELD(RST_CPU_R5, RESET_CPU1, 1, 1) | ||
181 | + FIELD(RST_CPU_R5, RESET_CPU0, 0, 1) | ||
182 | +REG32(RST_ADMA, 0x304) | ||
183 | + FIELD(RST_ADMA, RESET, 0, 1) | ||
184 | +REG32(RST_GEM0, 0x308) | ||
185 | + FIELD(RST_GEM0, RESET, 0, 1) | ||
186 | +REG32(RST_GEM1, 0x30c) | ||
187 | + FIELD(RST_GEM1, RESET, 0, 1) | ||
188 | +REG32(RST_SPARE, 0x310) | ||
189 | + FIELD(RST_SPARE, RESET, 0, 1) | ||
190 | +REG32(RST_USB0, 0x314) | ||
191 | + FIELD(RST_USB0, RESET, 0, 1) | ||
192 | +REG32(RST_UART0, 0x318) | ||
193 | + FIELD(RST_UART0, RESET, 0, 1) | ||
194 | +REG32(RST_UART1, 0x31c) | ||
195 | + FIELD(RST_UART1, RESET, 0, 1) | ||
196 | +REG32(RST_SPI0, 0x320) | ||
197 | + FIELD(RST_SPI0, RESET, 0, 1) | ||
198 | +REG32(RST_SPI1, 0x324) | ||
199 | + FIELD(RST_SPI1, RESET, 0, 1) | ||
200 | +REG32(RST_CAN0, 0x328) | ||
201 | + FIELD(RST_CAN0, RESET, 0, 1) | ||
202 | +REG32(RST_CAN1, 0x32c) | ||
203 | + FIELD(RST_CAN1, RESET, 0, 1) | ||
204 | +REG32(RST_I2C0, 0x330) | ||
205 | + FIELD(RST_I2C0, RESET, 0, 1) | ||
206 | +REG32(RST_I2C1, 0x334) | ||
207 | + FIELD(RST_I2C1, RESET, 0, 1) | ||
208 | +REG32(RST_DBG_LPD, 0x338) | ||
209 | + FIELD(RST_DBG_LPD, RPU_DBG1_RESET, 5, 1) | ||
210 | + FIELD(RST_DBG_LPD, RPU_DBG0_RESET, 4, 1) | ||
211 | + FIELD(RST_DBG_LPD, RESET_HSDP, 1, 1) | ||
212 | + FIELD(RST_DBG_LPD, RESET, 0, 1) | ||
213 | +REG32(RST_GPIO, 0x33c) | ||
214 | + FIELD(RST_GPIO, RESET, 0, 1) | ||
215 | +REG32(RST_TTC, 0x344) | ||
216 | + FIELD(RST_TTC, TTC3_RESET, 3, 1) | ||
217 | + FIELD(RST_TTC, TTC2_RESET, 2, 1) | ||
218 | + FIELD(RST_TTC, TTC1_RESET, 1, 1) | ||
219 | + FIELD(RST_TTC, TTC0_RESET, 0, 1) | ||
220 | +REG32(RST_TIMESTAMP, 0x348) | ||
221 | + FIELD(RST_TIMESTAMP, RESET, 0, 1) | ||
222 | +REG32(RST_SWDT, 0x34c) | ||
223 | + FIELD(RST_SWDT, RESET, 0, 1) | ||
224 | +REG32(RST_OCM, 0x350) | ||
225 | + FIELD(RST_OCM, RESET, 0, 1) | ||
226 | +REG32(RST_IPI, 0x354) | ||
227 | + FIELD(RST_IPI, RESET, 0, 1) | ||
228 | +REG32(RST_SYSMON, 0x358) | ||
229 | + FIELD(RST_SYSMON, SEQ_RST, 1, 1) | ||
230 | + FIELD(RST_SYSMON, CFG_RST, 0, 1) | ||
231 | +REG32(RST_FPD, 0x360) | ||
232 | + FIELD(RST_FPD, SRST, 1, 1) | ||
233 | + FIELD(RST_FPD, POR, 0, 1) | ||
234 | +REG32(PSM_RST_MODE, 0x370) | ||
235 | + FIELD(PSM_RST_MODE, WAKEUP, 2, 1) | ||
236 | + FIELD(PSM_RST_MODE, RST_MODE, 0, 2) | ||
237 | + | ||
238 | +#define CRL_R_MAX (R_PSM_RST_MODE + 1) | ||
239 | + | ||
240 | +#define RPU_MAX_CPU 2 | ||
241 | + | ||
242 | +struct XlnxVersalCRL { | ||
243 | + SysBusDevice parent_obj; | ||
63 | + qemu_irq irq; | 244 | + qemu_irq irq; |
64 | + | 245 | + |
65 | + uint8_t id; | 246 | + struct { |
66 | + uint32_t regs[ASPEED_I3C_DEVICE_NR_REGS]; | 247 | + ARMCPU *cpu_r5[RPU_MAX_CPU]; |
67 | +} AspeedI3CDevice; | 248 | + DeviceState *adma[8]; |
68 | + | 249 | + DeviceState *uart[2]; |
69 | +typedef struct AspeedI3CState { | 250 | + DeviceState *gem[2]; |
70 | + /* <private> */ | 251 | + DeviceState *usb; |
71 | + SysBusDevice parent; | 252 | + } cfg; |
72 | + | 253 | + |
73 | + /* <public> */ | 254 | + RegisterInfoArray *reg_array; |
74 | + MemoryRegion iomem; | 255 | + uint32_t regs[CRL_R_MAX]; |
75 | + MemoryRegion iomem_container; | 256 | + RegisterInfo regs_info[CRL_R_MAX]; |
76 | + qemu_irq irq; | 257 | +}; |
77 | + | 258 | +#endif |
78 | + uint32_t regs[ASPEED_I3C_NR_REGS]; | 259 | diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c |
79 | + AspeedI3CDevice devices[ASPEED_I3C_NR_DEVICES]; | ||
80 | +} AspeedI3CState; | ||
81 | +#endif /* ASPEED_I3C_H */ | ||
82 | diff --git a/hw/misc/aspeed_i3c.c b/hw/misc/aspeed_i3c.c | ||
83 | new file mode 100644 | 260 | new file mode 100644 |
84 | index XXXXXXX..XXXXXXX | 261 | index XXXXXXX..XXXXXXX |
85 | --- /dev/null | 262 | --- /dev/null |
86 | +++ b/hw/misc/aspeed_i3c.c | 263 | +++ b/hw/misc/xlnx-versal-crl.c |
87 | @@ -XXX,XX +XXX,XX @@ | 264 | @@ -XXX,XX +XXX,XX @@ |
88 | +/* | 265 | +/* |
89 | + * ASPEED I3C Controller | 266 | + * QEMU model of the Clock-Reset-LPD (CRL). |
90 | + * | 267 | + * |
91 | + * Copyright (C) 2021 ASPEED Technology Inc. | 268 | + * Copyright (c) 2022 Advanced Micro Devices, Inc. |
269 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
92 | + * | 270 | + * |
93 | + * This code is licensed under the GPL version 2 or later. See | 271 | + * Written by Edgar E. Iglesias <edgar.iglesias@amd.com> |
94 | + * the COPYING file in the top-level directory. | ||
95 | + */ | 272 | + */ |
96 | + | 273 | + |
97 | +#include "qemu/osdep.h" | 274 | +#include "qemu/osdep.h" |
275 | +#include "qapi/error.h" | ||
98 | +#include "qemu/log.h" | 276 | +#include "qemu/log.h" |
99 | +#include "qemu/error-report.h" | 277 | +#include "qemu/bitops.h" |
100 | +#include "hw/misc/aspeed_i3c.h" | 278 | +#include "migration/vmstate.h" |
101 | +#include "hw/registerfields.h" | ||
102 | +#include "hw/qdev-properties.h" | 279 | +#include "hw/qdev-properties.h" |
103 | +#include "qapi/error.h" | 280 | +#include "hw/sysbus.h" |
104 | +#include "migration/vmstate.h" | 281 | +#include "hw/irq.h" |
105 | +#include "trace.h" | 282 | +#include "hw/register.h" |
106 | + | 283 | +#include "hw/resettable.h" |
107 | +/* I3C Controller Registers */ | 284 | + |
108 | +REG32(I3C1_REG0, 0x10) | 285 | +#include "target/arm/arm-powerctl.h" |
109 | +REG32(I3C1_REG1, 0x14) | 286 | +#include "hw/misc/xlnx-versal-crl.h" |
110 | + FIELD(I3C1_REG1, I2C_MODE, 0, 1) | 287 | + |
111 | + FIELD(I3C1_REG1, SA_EN, 15, 1) | 288 | +#ifndef XLNX_VERSAL_CRL_ERR_DEBUG |
112 | +REG32(I3C2_REG0, 0x20) | 289 | +#define XLNX_VERSAL_CRL_ERR_DEBUG 0 |
113 | +REG32(I3C2_REG1, 0x24) | 290 | +#endif |
114 | + FIELD(I3C2_REG1, I2C_MODE, 0, 1) | 291 | + |
115 | + FIELD(I3C2_REG1, SA_EN, 15, 1) | 292 | +static void crl_update_irq(XlnxVersalCRL *s) |
116 | +REG32(I3C3_REG0, 0x30) | 293 | +{ |
117 | +REG32(I3C3_REG1, 0x34) | 294 | + bool pending = s->regs[R_IR_STATUS] & ~s->regs[R_IR_MASK]; |
118 | + FIELD(I3C3_REG1, I2C_MODE, 0, 1) | 295 | + qemu_set_irq(s->irq, pending); |
119 | + FIELD(I3C3_REG1, SA_EN, 15, 1) | 296 | +} |
120 | +REG32(I3C4_REG0, 0x40) | 297 | + |
121 | +REG32(I3C4_REG1, 0x44) | 298 | +static void crl_status_postw(RegisterInfo *reg, uint64_t val64) |
122 | + FIELD(I3C4_REG1, I2C_MODE, 0, 1) | 299 | +{ |
123 | + FIELD(I3C4_REG1, SA_EN, 15, 1) | 300 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
124 | +REG32(I3C5_REG0, 0x50) | 301 | + crl_update_irq(s); |
125 | +REG32(I3C5_REG1, 0x54) | 302 | +} |
126 | + FIELD(I3C5_REG1, I2C_MODE, 0, 1) | 303 | + |
127 | + FIELD(I3C5_REG1, SA_EN, 15, 1) | 304 | +static uint64_t crl_enable_prew(RegisterInfo *reg, uint64_t val64) |
128 | +REG32(I3C6_REG0, 0x60) | 305 | +{ |
129 | +REG32(I3C6_REG1, 0x64) | 306 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
130 | + FIELD(I3C6_REG1, I2C_MODE, 0, 1) | 307 | + uint32_t val = val64; |
131 | + FIELD(I3C6_REG1, SA_EN, 15, 1) | 308 | + |
132 | + | 309 | + s->regs[R_IR_MASK] &= ~val; |
133 | +/* I3C Device Registers */ | 310 | + crl_update_irq(s); |
134 | +REG32(DEVICE_CTRL, 0x00) | 311 | + return 0; |
135 | +REG32(DEVICE_ADDR, 0x04) | 312 | +} |
136 | +REG32(HW_CAPABILITY, 0x08) | 313 | + |
137 | +REG32(COMMAND_QUEUE_PORT, 0x0c) | 314 | +static uint64_t crl_disable_prew(RegisterInfo *reg, uint64_t val64) |
138 | +REG32(RESPONSE_QUEUE_PORT, 0x10) | 315 | +{ |
139 | +REG32(RX_TX_DATA_PORT, 0x14) | 316 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
140 | +REG32(IBI_QUEUE_STATUS, 0x18) | 317 | + uint32_t val = val64; |
141 | +REG32(IBI_QUEUE_DATA, 0x18) | 318 | + |
142 | +REG32(QUEUE_THLD_CTRL, 0x1c) | 319 | + s->regs[R_IR_MASK] |= val; |
143 | +REG32(DATA_BUFFER_THLD_CTRL, 0x20) | 320 | + crl_update_irq(s); |
144 | +REG32(IBI_QUEUE_CTRL, 0x24) | 321 | + return 0; |
145 | +REG32(IBI_MR_REQ_REJECT, 0x2c) | 322 | +} |
146 | +REG32(IBI_SIR_REQ_REJECT, 0x30) | 323 | + |
147 | +REG32(RESET_CTRL, 0x34) | 324 | +static void crl_reset_dev(XlnxVersalCRL *s, DeviceState *dev, |
148 | +REG32(SLV_EVENT_CTRL, 0x38) | 325 | + bool rst_old, bool rst_new) |
149 | +REG32(INTR_STATUS, 0x3c) | 326 | +{ |
150 | +REG32(INTR_STATUS_EN, 0x40) | 327 | + device_cold_reset(dev); |
151 | +REG32(INTR_SIGNAL_EN, 0x44) | 328 | +} |
152 | +REG32(INTR_FORCE, 0x48) | 329 | + |
153 | +REG32(QUEUE_STATUS_LEVEL, 0x4c) | 330 | +static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcpu, |
154 | +REG32(DATA_BUFFER_STATUS_LEVEL, 0x50) | 331 | + bool rst_old, bool rst_new) |
155 | +REG32(PRESENT_STATE, 0x54) | 332 | +{ |
156 | +REG32(CCC_DEVICE_STATUS, 0x58) | 333 | + if (rst_new) { |
157 | +REG32(DEVICE_ADDR_TABLE_POINTER, 0x5c) | 334 | + arm_set_cpu_off(armcpu->mp_affinity); |
158 | + FIELD(DEVICE_ADDR_TABLE_POINTER, DEPTH, 16, 16) | 335 | + } else { |
159 | + FIELD(DEVICE_ADDR_TABLE_POINTER, ADDR, 0, 16) | 336 | + arm_set_cpu_on_and_reset(armcpu->mp_affinity); |
160 | +REG32(DEV_CHAR_TABLE_POINTER, 0x60) | 337 | + } |
161 | +REG32(VENDOR_SPECIFIC_REG_POINTER, 0x6c) | 338 | +} |
162 | +REG32(SLV_MIPI_PID_VALUE, 0x70) | 339 | + |
163 | +REG32(SLV_PID_VALUE, 0x74) | 340 | +#define REGFIELD_RESET(type, s, reg, f, new_val, dev) { \ |
164 | +REG32(SLV_CHAR_CTRL, 0x78) | 341 | + bool old_f = ARRAY_FIELD_EX32((s)->regs, reg, f); \ |
165 | +REG32(SLV_MAX_LEN, 0x7c) | 342 | + bool new_f = FIELD_EX32(new_val, reg, f); \ |
166 | +REG32(MAX_READ_TURNAROUND, 0x80) | 343 | + \ |
167 | +REG32(MAX_DATA_SPEED, 0x84) | 344 | + /* Detect edges. */ \ |
168 | +REG32(SLV_DEBUG_STATUS, 0x88) | 345 | + if (dev && old_f != new_f) { \ |
169 | +REG32(SLV_INTR_REQ, 0x8c) | 346 | + crl_reset_ ## type(s, dev, old_f, new_f); \ |
170 | +REG32(DEVICE_CTRL_EXTENDED, 0xb0) | 347 | + } \ |
171 | +REG32(SCL_I3C_OD_TIMING, 0xb4) | 348 | +} |
172 | +REG32(SCL_I3C_PP_TIMING, 0xb8) | 349 | + |
173 | +REG32(SCL_I2C_FM_TIMING, 0xbc) | 350 | +static uint64_t crl_rst_r5_prew(RegisterInfo *reg, uint64_t val64) |
174 | +REG32(SCL_I2C_FMP_TIMING, 0xc0) | 351 | +{ |
175 | +REG32(SCL_EXT_LCNT_TIMING, 0xc8) | 352 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
176 | +REG32(SCL_EXT_TERMN_LCNT_TIMING, 0xcc) | 353 | + |
177 | +REG32(BUS_FREE_TIMING, 0xd4) | 354 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU0, val64, s->cfg.cpu_r5[0]); |
178 | +REG32(BUS_IDLE_TIMING, 0xd8) | 355 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU1, val64, s->cfg.cpu_r5[1]); |
179 | +REG32(I3C_VER_ID, 0xe0) | 356 | + return val64; |
180 | +REG32(I3C_VER_TYPE, 0xe4) | 357 | +} |
181 | +REG32(EXTENDED_CAPABILITY, 0xe8) | 358 | + |
182 | +REG32(SLAVE_CONFIG, 0xec) | 359 | +static uint64_t crl_rst_adma_prew(RegisterInfo *reg, uint64_t val64) |
183 | + | 360 | +{ |
184 | +static const uint32_t ast2600_i3c_device_resets[ASPEED_I3C_DEVICE_NR_REGS] = { | 361 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
185 | + [R_HW_CAPABILITY] = 0x000e00bf, | 362 | + int i; |
186 | + [R_QUEUE_THLD_CTRL] = 0x01000101, | 363 | + |
187 | + [R_I3C_VER_ID] = 0x3130302a, | 364 | + /* A single register fans out to all ADMA reset inputs. */ |
188 | + [R_I3C_VER_TYPE] = 0x6c633033, | 365 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); i++) { |
189 | + [R_DEVICE_ADDR_TABLE_POINTER] = 0x00080280, | 366 | + REGFIELD_RESET(dev, s, RST_ADMA, RESET, val64, s->cfg.adma[i]); |
190 | + [R_DEV_CHAR_TABLE_POINTER] = 0x00020200, | 367 | + } |
191 | + [A_VENDOR_SPECIFIC_REG_POINTER] = 0x000000b0, | 368 | + return val64; |
192 | + [R_SLV_MAX_LEN] = 0x00ff00ff, | 369 | +} |
370 | + | ||
371 | +static uint64_t crl_rst_uart0_prew(RegisterInfo *reg, uint64_t val64) | ||
372 | +{ | ||
373 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
374 | + | ||
375 | + REGFIELD_RESET(dev, s, RST_UART0, RESET, val64, s->cfg.uart[0]); | ||
376 | + return val64; | ||
377 | +} | ||
378 | + | ||
379 | +static uint64_t crl_rst_uart1_prew(RegisterInfo *reg, uint64_t val64) | ||
380 | +{ | ||
381 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
382 | + | ||
383 | + REGFIELD_RESET(dev, s, RST_UART1, RESET, val64, s->cfg.uart[1]); | ||
384 | + return val64; | ||
385 | +} | ||
386 | + | ||
387 | +static uint64_t crl_rst_gem0_prew(RegisterInfo *reg, uint64_t val64) | ||
388 | +{ | ||
389 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
390 | + | ||
391 | + REGFIELD_RESET(dev, s, RST_GEM0, RESET, val64, s->cfg.gem[0]); | ||
392 | + return val64; | ||
393 | +} | ||
394 | + | ||
395 | +static uint64_t crl_rst_gem1_prew(RegisterInfo *reg, uint64_t val64) | ||
396 | +{ | ||
397 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
398 | + | ||
399 | + REGFIELD_RESET(dev, s, RST_GEM1, RESET, val64, s->cfg.gem[1]); | ||
400 | + return val64; | ||
401 | +} | ||
402 | + | ||
403 | +static uint64_t crl_rst_usb_prew(RegisterInfo *reg, uint64_t val64) | ||
404 | +{ | ||
405 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
406 | + | ||
407 | + REGFIELD_RESET(dev, s, RST_USB0, RESET, val64, s->cfg.usb); | ||
408 | + return val64; | ||
409 | +} | ||
410 | + | ||
411 | +static const RegisterAccessInfo crl_regs_info[] = { | ||
412 | + { .name = "ERR_CTRL", .addr = A_ERR_CTRL, | ||
413 | + },{ .name = "IR_STATUS", .addr = A_IR_STATUS, | ||
414 | + .w1c = 0x1, | ||
415 | + .post_write = crl_status_postw, | ||
416 | + },{ .name = "IR_MASK", .addr = A_IR_MASK, | ||
417 | + .reset = 0x1, | ||
418 | + .ro = 0x1, | ||
419 | + },{ .name = "IR_ENABLE", .addr = A_IR_ENABLE, | ||
420 | + .pre_write = crl_enable_prew, | ||
421 | + },{ .name = "IR_DISABLE", .addr = A_IR_DISABLE, | ||
422 | + .pre_write = crl_disable_prew, | ||
423 | + },{ .name = "WPROT", .addr = A_WPROT, | ||
424 | + },{ .name = "PLL_CLK_OTHER_DMN", .addr = A_PLL_CLK_OTHER_DMN, | ||
425 | + .reset = 0x1, | ||
426 | + .rsvd = 0xe, | ||
427 | + },{ .name = "RPLL_CTRL", .addr = A_RPLL_CTRL, | ||
428 | + .reset = 0x24809, | ||
429 | + .rsvd = 0xf88c00f6, | ||
430 | + },{ .name = "RPLL_CFG", .addr = A_RPLL_CFG, | ||
431 | + .reset = 0x2000000, | ||
432 | + .rsvd = 0x1801210, | ||
433 | + },{ .name = "RPLL_FRAC_CFG", .addr = A_RPLL_FRAC_CFG, | ||
434 | + .rsvd = 0x7e330000, | ||
435 | + },{ .name = "PLL_STATUS", .addr = A_PLL_STATUS, | ||
436 | + .reset = R_PLL_STATUS_RPLL_STABLE_MASK | | ||
437 | + R_PLL_STATUS_RPLL_LOCK_MASK, | ||
438 | + .rsvd = 0xfa, | ||
439 | + .ro = 0x5, | ||
440 | + },{ .name = "RPLL_TO_XPD_CTRL", .addr = A_RPLL_TO_XPD_CTRL, | ||
441 | + .reset = 0x2000100, | ||
442 | + .rsvd = 0xfdfc00ff, | ||
443 | + },{ .name = "LPD_TOP_SWITCH_CTRL", .addr = A_LPD_TOP_SWITCH_CTRL, | ||
444 | + .reset = 0x6000300, | ||
445 | + .rsvd = 0xf9fc00f8, | ||
446 | + },{ .name = "LPD_LSBUS_CTRL", .addr = A_LPD_LSBUS_CTRL, | ||
447 | + .reset = 0x2000800, | ||
448 | + .rsvd = 0xfdfc00f8, | ||
449 | + },{ .name = "CPU_R5_CTRL", .addr = A_CPU_R5_CTRL, | ||
450 | + .reset = 0xe000300, | ||
451 | + .rsvd = 0xe1fc00f8, | ||
452 | + },{ .name = "IOU_SWITCH_CTRL", .addr = A_IOU_SWITCH_CTRL, | ||
453 | + .reset = 0x2000500, | ||
454 | + .rsvd = 0xfdfc00f8, | ||
455 | + },{ .name = "GEM0_REF_CTRL", .addr = A_GEM0_REF_CTRL, | ||
456 | + .reset = 0xe000a00, | ||
457 | + .rsvd = 0xf1fc00f8, | ||
458 | + },{ .name = "GEM1_REF_CTRL", .addr = A_GEM1_REF_CTRL, | ||
459 | + .reset = 0xe000a00, | ||
460 | + .rsvd = 0xf1fc00f8, | ||
461 | + },{ .name = "GEM_TSU_REF_CTRL", .addr = A_GEM_TSU_REF_CTRL, | ||
462 | + .reset = 0x300, | ||
463 | + .rsvd = 0xfdfc00f8, | ||
464 | + },{ .name = "USB0_BUS_REF_CTRL", .addr = A_USB0_BUS_REF_CTRL, | ||
465 | + .reset = 0x2001900, | ||
466 | + .rsvd = 0xfdfc00f8, | ||
467 | + },{ .name = "UART0_REF_CTRL", .addr = A_UART0_REF_CTRL, | ||
468 | + .reset = 0xc00, | ||
469 | + .rsvd = 0xfdfc00f8, | ||
470 | + },{ .name = "UART1_REF_CTRL", .addr = A_UART1_REF_CTRL, | ||
471 | + .reset = 0xc00, | ||
472 | + .rsvd = 0xfdfc00f8, | ||
473 | + },{ .name = "SPI0_REF_CTRL", .addr = A_SPI0_REF_CTRL, | ||
474 | + .reset = 0x600, | ||
475 | + .rsvd = 0xfdfc00f8, | ||
476 | + },{ .name = "SPI1_REF_CTRL", .addr = A_SPI1_REF_CTRL, | ||
477 | + .reset = 0x600, | ||
478 | + .rsvd = 0xfdfc00f8, | ||
479 | + },{ .name = "CAN0_REF_CTRL", .addr = A_CAN0_REF_CTRL, | ||
480 | + .reset = 0xc00, | ||
481 | + .rsvd = 0xfdfc00f8, | ||
482 | + },{ .name = "CAN1_REF_CTRL", .addr = A_CAN1_REF_CTRL, | ||
483 | + .reset = 0xc00, | ||
484 | + .rsvd = 0xfdfc00f8, | ||
485 | + },{ .name = "I2C0_REF_CTRL", .addr = A_I2C0_REF_CTRL, | ||
486 | + .reset = 0xc00, | ||
487 | + .rsvd = 0xfdfc00f8, | ||
488 | + },{ .name = "I2C1_REF_CTRL", .addr = A_I2C1_REF_CTRL, | ||
489 | + .reset = 0xc00, | ||
490 | + .rsvd = 0xfdfc00f8, | ||
491 | + },{ .name = "DBG_LPD_CTRL", .addr = A_DBG_LPD_CTRL, | ||
492 | + .reset = 0x300, | ||
493 | + .rsvd = 0xfdfc00f8, | ||
494 | + },{ .name = "TIMESTAMP_REF_CTRL", .addr = A_TIMESTAMP_REF_CTRL, | ||
495 | + .reset = 0x2000c00, | ||
496 | + .rsvd = 0xfdfc00f8, | ||
497 | + },{ .name = "CRL_SAFETY_CHK", .addr = A_CRL_SAFETY_CHK, | ||
498 | + },{ .name = "PSM_REF_CTRL", .addr = A_PSM_REF_CTRL, | ||
499 | + .reset = 0xf04, | ||
500 | + .rsvd = 0xfffc00f8, | ||
501 | + },{ .name = "DBG_TSTMP_CTRL", .addr = A_DBG_TSTMP_CTRL, | ||
502 | + .reset = 0x300, | ||
503 | + .rsvd = 0xfdfc00f8, | ||
504 | + },{ .name = "CPM_TOPSW_REF_CTRL", .addr = A_CPM_TOPSW_REF_CTRL, | ||
505 | + .reset = 0x300, | ||
506 | + .rsvd = 0xfdfc00f8, | ||
507 | + },{ .name = "USB3_DUAL_REF_CTRL", .addr = A_USB3_DUAL_REF_CTRL, | ||
508 | + .reset = 0x3c00, | ||
509 | + .rsvd = 0xfdfc00f8, | ||
510 | + },{ .name = "RST_CPU_R5", .addr = A_RST_CPU_R5, | ||
511 | + .reset = 0x17, | ||
512 | + .rsvd = 0x8, | ||
513 | + .pre_write = crl_rst_r5_prew, | ||
514 | + },{ .name = "RST_ADMA", .addr = A_RST_ADMA, | ||
515 | + .reset = 0x1, | ||
516 | + .pre_write = crl_rst_adma_prew, | ||
517 | + },{ .name = "RST_GEM0", .addr = A_RST_GEM0, | ||
518 | + .reset = 0x1, | ||
519 | + .pre_write = crl_rst_gem0_prew, | ||
520 | + },{ .name = "RST_GEM1", .addr = A_RST_GEM1, | ||
521 | + .reset = 0x1, | ||
522 | + .pre_write = crl_rst_gem1_prew, | ||
523 | + },{ .name = "RST_SPARE", .addr = A_RST_SPARE, | ||
524 | + .reset = 0x1, | ||
525 | + },{ .name = "RST_USB0", .addr = A_RST_USB0, | ||
526 | + .reset = 0x1, | ||
527 | + .pre_write = crl_rst_usb_prew, | ||
528 | + },{ .name = "RST_UART0", .addr = A_RST_UART0, | ||
529 | + .reset = 0x1, | ||
530 | + .pre_write = crl_rst_uart0_prew, | ||
531 | + },{ .name = "RST_UART1", .addr = A_RST_UART1, | ||
532 | + .reset = 0x1, | ||
533 | + .pre_write = crl_rst_uart1_prew, | ||
534 | + },{ .name = "RST_SPI0", .addr = A_RST_SPI0, | ||
535 | + .reset = 0x1, | ||
536 | + },{ .name = "RST_SPI1", .addr = A_RST_SPI1, | ||
537 | + .reset = 0x1, | ||
538 | + },{ .name = "RST_CAN0", .addr = A_RST_CAN0, | ||
539 | + .reset = 0x1, | ||
540 | + },{ .name = "RST_CAN1", .addr = A_RST_CAN1, | ||
541 | + .reset = 0x1, | ||
542 | + },{ .name = "RST_I2C0", .addr = A_RST_I2C0, | ||
543 | + .reset = 0x1, | ||
544 | + },{ .name = "RST_I2C1", .addr = A_RST_I2C1, | ||
545 | + .reset = 0x1, | ||
546 | + },{ .name = "RST_DBG_LPD", .addr = A_RST_DBG_LPD, | ||
547 | + .reset = 0x33, | ||
548 | + .rsvd = 0xcc, | ||
549 | + },{ .name = "RST_GPIO", .addr = A_RST_GPIO, | ||
550 | + .reset = 0x1, | ||
551 | + },{ .name = "RST_TTC", .addr = A_RST_TTC, | ||
552 | + .reset = 0xf, | ||
553 | + },{ .name = "RST_TIMESTAMP", .addr = A_RST_TIMESTAMP, | ||
554 | + .reset = 0x1, | ||
555 | + },{ .name = "RST_SWDT", .addr = A_RST_SWDT, | ||
556 | + .reset = 0x1, | ||
557 | + },{ .name = "RST_OCM", .addr = A_RST_OCM, | ||
558 | + },{ .name = "RST_IPI", .addr = A_RST_IPI, | ||
559 | + },{ .name = "RST_FPD", .addr = A_RST_FPD, | ||
560 | + .reset = 0x3, | ||
561 | + },{ .name = "PSM_RST_MODE", .addr = A_PSM_RST_MODE, | ||
562 | + .reset = 0x1, | ||
563 | + .rsvd = 0xf8, | ||
564 | + } | ||
193 | +}; | 565 | +}; |
194 | + | 566 | + |
195 | +static uint64_t aspeed_i3c_device_read(void *opaque, hwaddr offset, | 567 | +static void crl_reset_enter(Object *obj, ResetType type) |
196 | + unsigned size) | 568 | +{ |
197 | +{ | 569 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); |
198 | + AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque); | 570 | + unsigned int i; |
199 | + uint32_t addr = offset >> 2; | 571 | + |
200 | + uint64_t value; | 572 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { |
201 | + | 573 | + register_reset(&s->regs_info[i]); |
202 | + switch (addr) { | 574 | + } |
203 | + case R_COMMAND_QUEUE_PORT: | 575 | +} |
204 | + value = 0; | 576 | + |
205 | + break; | 577 | +static void crl_reset_hold(Object *obj) |
206 | + default: | 578 | +{ |
207 | + value = s->regs[addr]; | 579 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); |
208 | + break; | 580 | + |
209 | + } | 581 | + crl_update_irq(s); |
210 | + | 582 | +} |
211 | + trace_aspeed_i3c_device_read(s->id, offset, value); | 583 | + |
212 | + | 584 | +static const MemoryRegionOps crl_ops = { |
213 | + return value; | 585 | + .read = register_read_memory, |
214 | +} | 586 | + .write = register_write_memory, |
215 | + | ||
216 | +static void aspeed_i3c_device_write(void *opaque, hwaddr offset, | ||
217 | + uint64_t value, unsigned size) | ||
218 | +{ | ||
219 | + AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque); | ||
220 | + uint32_t addr = offset >> 2; | ||
221 | + | ||
222 | + trace_aspeed_i3c_device_write(s->id, offset, value); | ||
223 | + | ||
224 | + switch (addr) { | ||
225 | + case R_HW_CAPABILITY: | ||
226 | + case R_RESPONSE_QUEUE_PORT: | ||
227 | + case R_IBI_QUEUE_DATA: | ||
228 | + case R_QUEUE_STATUS_LEVEL: | ||
229 | + case R_PRESENT_STATE: | ||
230 | + case R_CCC_DEVICE_STATUS: | ||
231 | + case R_DEVICE_ADDR_TABLE_POINTER: | ||
232 | + case R_VENDOR_SPECIFIC_REG_POINTER: | ||
233 | + case R_SLV_CHAR_CTRL: | ||
234 | + case R_SLV_MAX_LEN: | ||
235 | + case R_MAX_READ_TURNAROUND: | ||
236 | + case R_I3C_VER_ID: | ||
237 | + case R_I3C_VER_TYPE: | ||
238 | + case R_EXTENDED_CAPABILITY: | ||
239 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
240 | + "%s: write to readonly register[%02lx] = %08lx\n", | ||
241 | + __func__, offset, value); | ||
242 | + break; | ||
243 | + case R_RX_TX_DATA_PORT: | ||
244 | + break; | ||
245 | + case R_RESET_CTRL: | ||
246 | + break; | ||
247 | + default: | ||
248 | + s->regs[addr] = value; | ||
249 | + break; | ||
250 | + } | ||
251 | +} | ||
252 | + | ||
253 | +static const VMStateDescription aspeed_i3c_device_vmstate = { | ||
254 | + .name = TYPE_ASPEED_I3C, | ||
255 | + .version_id = 1, | ||
256 | + .minimum_version_id = 1, | ||
257 | + .fields = (VMStateField[]){ | ||
258 | + VMSTATE_UINT32_ARRAY(regs, AspeedI3CDevice, ASPEED_I3C_DEVICE_NR_REGS), | ||
259 | + VMSTATE_END_OF_LIST(), | ||
260 | + } | ||
261 | +}; | ||
262 | + | ||
263 | +static const MemoryRegionOps aspeed_i3c_device_ops = { | ||
264 | + .read = aspeed_i3c_device_read, | ||
265 | + .write = aspeed_i3c_device_write, | ||
266 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
267 | +}; | ||
268 | + | ||
269 | +static void aspeed_i3c_device_reset(DeviceState *dev) | ||
270 | +{ | ||
271 | + AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev); | ||
272 | + | ||
273 | + memcpy(s->regs, ast2600_i3c_device_resets, sizeof(s->regs)); | ||
274 | +} | ||
275 | + | ||
276 | +static void aspeed_i3c_device_realize(DeviceState *dev, Error **errp) | ||
277 | +{ | ||
278 | + AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev); | ||
279 | + g_autofree char *name = g_strdup_printf(TYPE_ASPEED_I3C_DEVICE ".%d", | ||
280 | + s->id); | ||
281 | + | ||
282 | + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); | ||
283 | + | ||
284 | + memory_region_init_io(&s->mr, OBJECT(s), &aspeed_i3c_device_ops, | ||
285 | + s, name, ASPEED_I3C_DEVICE_NR_REGS << 2); | ||
286 | +} | ||
287 | + | ||
288 | +static uint64_t aspeed_i3c_read(void *opaque, hwaddr addr, unsigned int size) | ||
289 | +{ | ||
290 | + AspeedI3CState *s = ASPEED_I3C(opaque); | ||
291 | + uint64_t val = 0; | ||
292 | + | ||
293 | + val = s->regs[addr >> 2]; | ||
294 | + | ||
295 | + trace_aspeed_i3c_read(addr, val); | ||
296 | + | ||
297 | + return val; | ||
298 | +} | ||
299 | + | ||
300 | +static void aspeed_i3c_write(void *opaque, | ||
301 | + hwaddr addr, | ||
302 | + uint64_t data, | ||
303 | + unsigned int size) | ||
304 | +{ | ||
305 | + AspeedI3CState *s = ASPEED_I3C(opaque); | ||
306 | + | ||
307 | + trace_aspeed_i3c_write(addr, data); | ||
308 | + | ||
309 | + addr >>= 2; | ||
310 | + | ||
311 | + /* I3C controller register */ | ||
312 | + switch (addr) { | ||
313 | + case R_I3C1_REG1: | ||
314 | + case R_I3C2_REG1: | ||
315 | + case R_I3C3_REG1: | ||
316 | + case R_I3C4_REG1: | ||
317 | + case R_I3C5_REG1: | ||
318 | + case R_I3C6_REG1: | ||
319 | + if (data & R_I3C1_REG1_I2C_MODE_MASK) { | ||
320 | + qemu_log_mask(LOG_UNIMP, | ||
321 | + "%s: Not support I2C mode [%08lx]=%08lx", | ||
322 | + __func__, addr << 2, data); | ||
323 | + break; | ||
324 | + } | ||
325 | + if (data & R_I3C1_REG1_SA_EN_MASK) { | ||
326 | + qemu_log_mask(LOG_UNIMP, | ||
327 | + "%s: Not support slave mode [%08lx]=%08lx", | ||
328 | + __func__, addr << 2, data); | ||
329 | + break; | ||
330 | + } | ||
331 | + s->regs[addr] = data; | ||
332 | + break; | ||
333 | + default: | ||
334 | + s->regs[addr] = data; | ||
335 | + break; | ||
336 | + } | ||
337 | +} | ||
338 | + | ||
339 | +static const MemoryRegionOps aspeed_i3c_ops = { | ||
340 | + .read = aspeed_i3c_read, | ||
341 | + .write = aspeed_i3c_write, | ||
342 | + .endianness = DEVICE_LITTLE_ENDIAN, | 587 | + .endianness = DEVICE_LITTLE_ENDIAN, |
343 | + .valid = { | 588 | + .valid = { |
344 | + .min_access_size = 1, | 589 | + .min_access_size = 4, |
345 | + .max_access_size = 4, | 590 | + .max_access_size = 4, |
346 | + } | 591 | + }, |
347 | +}; | 592 | +}; |
348 | + | 593 | + |
349 | +static void aspeed_i3c_reset(DeviceState *dev) | 594 | +static void crl_init(Object *obj) |
350 | +{ | 595 | +{ |
351 | + AspeedI3CState *s = ASPEED_I3C(dev); | 596 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); |
352 | + memset(s->regs, 0, sizeof(s->regs)); | 597 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
353 | +} | ||
354 | + | ||
355 | +static void aspeed_i3c_instance_init(Object *obj) | ||
356 | +{ | ||
357 | + AspeedI3CState *s = ASPEED_I3C(obj); | ||
358 | + int i; | 598 | + int i; |
359 | + | 599 | + |
360 | + for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) { | 600 | + s->reg_array = |
361 | + object_initialize_child(obj, "device[*]", &s->devices[i], | 601 | + register_init_block32(DEVICE(obj), crl_regs_info, |
362 | + TYPE_ASPEED_I3C_DEVICE); | 602 | + ARRAY_SIZE(crl_regs_info), |
363 | + } | 603 | + s->regs_info, s->regs, |
364 | +} | 604 | + &crl_ops, |
365 | + | 605 | + XLNX_VERSAL_CRL_ERR_DEBUG, |
366 | +static void aspeed_i3c_realize(DeviceState *dev, Error **errp) | 606 | + CRL_R_MAX * 4); |
367 | +{ | 607 | + sysbus_init_mmio(sbd, &s->reg_array->mem); |
368 | + int i; | 608 | + sysbus_init_irq(sbd, &s->irq); |
369 | + AspeedI3CState *s = ASPEED_I3C(dev); | 609 | + |
370 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 610 | + for (i = 0; i < ARRAY_SIZE(s->cfg.cpu_r5); ++i) { |
371 | + | 611 | + object_property_add_link(obj, "cpu_r5[*]", TYPE_ARM_CPU, |
372 | + memory_region_init(&s->iomem_container, OBJECT(s), | 612 | + (Object **)&s->cfg.cpu_r5[i], |
373 | + TYPE_ASPEED_I3C ".container", 0x8000); | 613 | + qdev_prop_allow_set_link_before_realize, |
374 | + | 614 | + OBJ_PROP_LINK_STRONG); |
375 | + sysbus_init_mmio(sbd, &s->iomem_container); | 615 | + } |
376 | + | 616 | + |
377 | + memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_i3c_ops, s, | 617 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); ++i) { |
378 | + TYPE_ASPEED_I3C ".regs", ASPEED_I3C_NR_REGS << 2); | 618 | + object_property_add_link(obj, "adma[*]", TYPE_DEVICE, |
379 | + | 619 | + (Object **)&s->cfg.adma[i], |
380 | + memory_region_add_subregion(&s->iomem_container, 0x0, &s->iomem); | 620 | + qdev_prop_allow_set_link_before_realize, |
381 | + | 621 | + OBJ_PROP_LINK_STRONG); |
382 | + for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) { | 622 | + } |
383 | + Object *dev = OBJECT(&s->devices[i]); | 623 | + |
384 | + | 624 | + for (i = 0; i < ARRAY_SIZE(s->cfg.uart); ++i) { |
385 | + if (!object_property_set_uint(dev, "device-id", i, errp)) { | 625 | + object_property_add_link(obj, "uart[*]", TYPE_DEVICE, |
386 | + return; | 626 | + (Object **)&s->cfg.uart[i], |
387 | + } | 627 | + qdev_prop_allow_set_link_before_realize, |
388 | + | 628 | + OBJ_PROP_LINK_STRONG); |
389 | + if (!sysbus_realize(SYS_BUS_DEVICE(dev), errp)) { | 629 | + } |
390 | + return; | 630 | + |
391 | + } | 631 | + for (i = 0; i < ARRAY_SIZE(s->cfg.gem); ++i) { |
392 | + | 632 | + object_property_add_link(obj, "gem[*]", TYPE_DEVICE, |
393 | + /* | 633 | + (Object **)&s->cfg.gem[i], |
394 | + * Register Address of I3CX Device = | 634 | + qdev_prop_allow_set_link_before_realize, |
395 | + * (Base Address of Global Register) + (Offset of I3CX) + Offset | 635 | + OBJ_PROP_LINK_STRONG); |
396 | + * X = 0, 1, 2, 3, 4, 5 | 636 | + } |
397 | + * Offset of I3C0 = 0x2000 | 637 | + |
398 | + * Offset of I3C1 = 0x3000 | 638 | + object_property_add_link(obj, "usb", TYPE_DEVICE, |
399 | + * Offset of I3C2 = 0x4000 | 639 | + (Object **)&s->cfg.gem[i], |
400 | + * Offset of I3C3 = 0x5000 | 640 | + qdev_prop_allow_set_link_before_realize, |
401 | + * Offset of I3C4 = 0x6000 | 641 | + OBJ_PROP_LINK_STRONG); |
402 | + * Offset of I3C5 = 0x7000 | 642 | +} |
403 | + */ | 643 | + |
404 | + memory_region_add_subregion(&s->iomem_container, | 644 | +static void crl_finalize(Object *obj) |
405 | + 0x2000 + i * 0x1000, &s->devices[i].mr); | 645 | +{ |
406 | + } | 646 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); |
407 | + | 647 | + register_finalize_block(s->reg_array); |
408 | +} | 648 | +} |
409 | + | 649 | + |
410 | +static Property aspeed_i3c_device_properties[] = { | 650 | +static const VMStateDescription vmstate_crl = { |
411 | + DEFINE_PROP_UINT8("device-id", AspeedI3CDevice, id, 0), | 651 | + .name = TYPE_XLNX_VERSAL_CRL, |
412 | + DEFINE_PROP_END_OF_LIST(), | ||
413 | +}; | ||
414 | + | ||
415 | +static void aspeed_i3c_device_class_init(ObjectClass *klass, void *data) | ||
416 | +{ | ||
417 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
418 | + | ||
419 | + dc->desc = "Aspeed I3C Device"; | ||
420 | + dc->realize = aspeed_i3c_device_realize; | ||
421 | + dc->reset = aspeed_i3c_device_reset; | ||
422 | + device_class_set_props(dc, aspeed_i3c_device_properties); | ||
423 | +} | ||
424 | + | ||
425 | +static const TypeInfo aspeed_i3c_device_info = { | ||
426 | + .name = TYPE_ASPEED_I3C_DEVICE, | ||
427 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
428 | + .instance_size = sizeof(AspeedI3CDevice), | ||
429 | + .class_init = aspeed_i3c_device_class_init, | ||
430 | +}; | ||
431 | + | ||
432 | +static const VMStateDescription vmstate_aspeed_i3c = { | ||
433 | + .name = TYPE_ASPEED_I3C, | ||
434 | + .version_id = 1, | 652 | + .version_id = 1, |
435 | + .minimum_version_id = 1, | 653 | + .minimum_version_id = 1, |
436 | + .fields = (VMStateField[]) { | 654 | + .fields = (VMStateField[]) { |
437 | + VMSTATE_UINT32_ARRAY(regs, AspeedI3CState, ASPEED_I3C_NR_REGS), | 655 | + VMSTATE_UINT32_ARRAY(regs, XlnxVersalCRL, CRL_R_MAX), |
438 | + VMSTATE_STRUCT_ARRAY(devices, AspeedI3CState, ASPEED_I3C_NR_DEVICES, 1, | ||
439 | + aspeed_i3c_device_vmstate, AspeedI3CDevice), | ||
440 | + VMSTATE_END_OF_LIST(), | 656 | + VMSTATE_END_OF_LIST(), |
441 | + } | 657 | + } |
442 | +}; | 658 | +}; |
443 | + | 659 | + |
444 | +static void aspeed_i3c_class_init(ObjectClass *klass, void *data) | 660 | +static void crl_class_init(ObjectClass *klass, void *data) |
445 | +{ | 661 | +{ |
662 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
446 | + DeviceClass *dc = DEVICE_CLASS(klass); | 663 | + DeviceClass *dc = DEVICE_CLASS(klass); |
447 | + | 664 | + |
448 | + dc->realize = aspeed_i3c_realize; | 665 | + dc->vmsd = &vmstate_crl; |
449 | + dc->reset = aspeed_i3c_reset; | 666 | + |
450 | + dc->desc = "Aspeed I3C Controller"; | 667 | + rc->phases.enter = crl_reset_enter; |
451 | + dc->vmsd = &vmstate_aspeed_i3c; | 668 | + rc->phases.hold = crl_reset_hold; |
452 | +} | 669 | +} |
453 | + | 670 | + |
454 | +static const TypeInfo aspeed_i3c_info = { | 671 | +static const TypeInfo crl_info = { |
455 | + .name = TYPE_ASPEED_I3C, | 672 | + .name = TYPE_XLNX_VERSAL_CRL, |
456 | + .parent = TYPE_SYS_BUS_DEVICE, | 673 | + .parent = TYPE_SYS_BUS_DEVICE, |
457 | + .instance_init = aspeed_i3c_instance_init, | 674 | + .instance_size = sizeof(XlnxVersalCRL), |
458 | + .instance_size = sizeof(AspeedI3CState), | 675 | + .class_init = crl_class_init, |
459 | + .class_init = aspeed_i3c_class_init, | 676 | + .instance_init = crl_init, |
677 | + .instance_finalize = crl_finalize, | ||
460 | +}; | 678 | +}; |
461 | + | 679 | + |
462 | +static void aspeed_i3c_register_types(void) | 680 | +static void crl_register_types(void) |
463 | +{ | 681 | +{ |
464 | + type_register_static(&aspeed_i3c_device_info); | 682 | + type_register_static(&crl_info); |
465 | + type_register_static(&aspeed_i3c_info); | 683 | +} |
466 | +} | 684 | + |
467 | + | 685 | +type_init(crl_register_types) |
468 | +type_init(aspeed_i3c_register_types); | ||
469 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | 686 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build |
470 | index XXXXXXX..XXXXXXX 100644 | 687 | index XXXXXXX..XXXXXXX 100644 |
471 | --- a/hw/misc/meson.build | 688 | --- a/hw/misc/meson.build |
472 | +++ b/hw/misc/meson.build | 689 | +++ b/hw/misc/meson.build |
473 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) | 690 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) |
474 | softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) | 691 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) |
475 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( | 692 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c')) |
476 | 'aspeed_hace.c', | 693 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c')) |
477 | + 'aspeed_i3c.c', | 694 | +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-crl.c')) |
478 | 'aspeed_lpc.c', | 695 | softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( |
479 | 'aspeed_scu.c', | 696 | 'xlnx-versal-xramc.c', |
480 | 'aspeed_sdmc.c', | 697 | 'xlnx-versal-pmc-iou-slcr.c', |
481 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
482 | index XXXXXXX..XXXXXXX 100644 | ||
483 | --- a/hw/misc/trace-events | ||
484 | +++ b/hw/misc/trace-events | ||
485 | @@ -XXX,XX +XXX,XX @@ armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU wri | ||
486 | # aspeed_xdma.c | ||
487 | aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64 | ||
488 | |||
489 | +# aspeed_i3c.c | ||
490 | +aspeed_i3c_read(uint64_t offset, uint64_t data) "I3C read: offset 0x%" PRIx64 " data 0x%" PRIx64 | ||
491 | +aspeed_i3c_write(uint64_t offset, uint64_t data) "I3C write: offset 0x%" PRIx64 " data 0x%" PRIx64 | ||
492 | +aspeed_i3c_device_read(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] read: offset 0x%" PRIx64 " data 0x%" PRIx64 | ||
493 | +aspeed_i3c_device_write(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] write: offset 0x%" PRIx64 " data 0x%" PRIx64 | ||
494 | + | ||
495 | # bcm2835_property.c | ||
496 | bcm2835_mbox_property(uint32_t tag, uint32_t bufsize, size_t resplen) "mbox property tag:0x%08x in_sz:%u out_sz:%zu" | ||
497 | |||
498 | -- | 698 | -- |
499 | 2.25.1 | 699 | 2.25.1 |
500 | |||
501 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | The highmem attribute is nothing but another way to express the | 3 | Connect the CRL (Clock Reset LPD) to the Versal SoC. |
4 | PA range of a VM. To support HW that has a smaller PA range then | ||
5 | what QEMU assumes, pass this PA range to the virt_set_memmap() | ||
6 | function, allowing it to correctly exclude highmem devices | ||
7 | if they are outside of the PA range. | ||
8 | 4 | ||
9 | Signed-off-by: Marc Zyngier <maz@kernel.org> | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> |
11 | Message-id: 20220114140741.1358263-5-maz@kernel.org | 7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> |
8 | Message-id: 20220406174303.2022038-5-edgar.iglesias@xilinx.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | hw/arm/virt.c | 64 +++++++++++++++++++++++++++++++++++++++++---------- | 11 | include/hw/arm/xlnx-versal.h | 4 +++ |
15 | 1 file changed, 52 insertions(+), 12 deletions(-) | 12 | hw/arm/xlnx-versal.c | 54 ++++++++++++++++++++++++++++++++++-- |
13 | 2 files changed, 56 insertions(+), 2 deletions(-) | ||
16 | 14 | ||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 17 | --- a/include/hw/arm/xlnx-versal.h |
20 | +++ b/hw/arm/virt.c | 18 | +++ b/include/hw/arm/xlnx-versal.h |
21 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | 19 | @@ -XXX,XX +XXX,XX @@ |
22 | return arm_cpu_mp_affinity(idx, clustersz); | 20 | #include "hw/nvram/xlnx-versal-efuse.h" |
21 | #include "hw/ssi/xlnx-versal-ospi.h" | ||
22 | #include "hw/dma/xlnx_csu_dma.h" | ||
23 | +#include "hw/misc/xlnx-versal-crl.h" | ||
24 | #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" | ||
25 | |||
26 | #define TYPE_XLNX_VERSAL "xlnx-versal" | ||
27 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
28 | qemu_or_irq irq_orgate; | ||
29 | XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | ||
30 | } xram; | ||
31 | + | ||
32 | + XlnxVersalCRL crl; | ||
33 | } lpd; | ||
34 | |||
35 | /* The Platform Management Controller subsystem. */ | ||
36 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
37 | #define VERSAL_TIMER_NS_EL1_IRQ 14 | ||
38 | #define VERSAL_TIMER_NS_EL2_IRQ 10 | ||
39 | |||
40 | +#define VERSAL_CRL_IRQ 10 | ||
41 | #define VERSAL_UART0_IRQ_0 18 | ||
42 | #define VERSAL_UART1_IRQ_0 19 | ||
43 | #define VERSAL_USB0_IRQ_0 22 | ||
44 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/xlnx-versal.c | ||
47 | +++ b/hw/arm/xlnx-versal.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void versal_create_ospi(Versal *s, qemu_irq *pic) | ||
49 | qdev_connect_gpio_out(orgate, 0, pic[VERSAL_OSPI_IRQ]); | ||
23 | } | 50 | } |
24 | 51 | ||
25 | -static void virt_set_memmap(VirtMachineState *vms) | 52 | +static void versal_create_crl(Versal *s, qemu_irq *pic) |
26 | +static void virt_set_memmap(VirtMachineState *vms, int pa_bits) | 53 | +{ |
27 | { | 54 | + SysBusDevice *sbd; |
28 | MachineState *ms = MACHINE(vms); | 55 | + int i; |
29 | hwaddr base, device_memory_base, device_memory_size, memtop; | 56 | + |
30 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms) | 57 | + object_initialize_child(OBJECT(s), "crl", &s->lpd.crl, |
31 | exit(EXIT_FAILURE); | 58 | + TYPE_XLNX_VERSAL_CRL); |
32 | } | 59 | + sbd = SYS_BUS_DEVICE(&s->lpd.crl); |
33 | 60 | + | |
34 | + /* | 61 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { |
35 | + * !highmem is exactly the same as limiting the PA space to 32bit, | 62 | + g_autofree gchar *name = g_strdup_printf("cpu_r5[%d]", i); |
36 | + * irrespective of the underlying capabilities of the HW. | 63 | + |
37 | + */ | 64 | + object_property_set_link(OBJECT(&s->lpd.crl), |
38 | + if (!vms->highmem) { | 65 | + name, OBJECT(&s->lpd.rpu.cpu[i]), |
39 | + pa_bits = 32; | 66 | + &error_abort); |
40 | + } | 67 | + } |
41 | + | 68 | + |
42 | /* | 69 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.gem); i++) { |
43 | * We compute the base of the high IO region depending on the | 70 | + g_autofree gchar *name = g_strdup_printf("gem[%d]", i); |
44 | * amount of initial and device memory. The device memory start/size | ||
45 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms) | ||
46 | |||
47 | /* Base address of the high IO region */ | ||
48 | memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB); | ||
49 | - if (!vms->highmem && memtop > 4 * GiB) { | ||
50 | - error_report("highmem=off, but memory crosses the 4GiB limit\n"); | ||
51 | + if (memtop > BIT_ULL(pa_bits)) { | ||
52 | + error_report("Addressing limited to %d bits, but memory exceeds it by %llu bytes\n", | ||
53 | + pa_bits, memtop - BIT_ULL(pa_bits)); | ||
54 | exit(EXIT_FAILURE); | ||
55 | } | ||
56 | if (base < device_memory_base) { | ||
57 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms) | ||
58 | vms->memmap[i].size = size; | ||
59 | base += size; | ||
60 | } | ||
61 | - vms->highest_gpa = (vms->highmem ? base : memtop) - 1; | ||
62 | + | 71 | + |
63 | + /* | 72 | + object_property_set_link(OBJECT(&s->lpd.crl), |
64 | + * If base fits within pa_bits, all good. If it doesn't, limit it | 73 | + name, OBJECT(&s->lpd.iou.gem[i]), |
65 | + * to the end of RAM, which is guaranteed to fit within pa_bits. | 74 | + &error_abort); |
66 | + */ | ||
67 | + vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1; | ||
68 | + | ||
69 | if (device_memory_size > 0) { | ||
70 | ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); | ||
71 | ms->device_memory->base = device_memory_base; | ||
72 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
73 | unsigned int smp_cpus = machine->smp.cpus; | ||
74 | unsigned int max_cpus = machine->smp.max_cpus; | ||
75 | |||
76 | + if (!cpu_type_valid(machine->cpu_type)) { | ||
77 | + error_report("mach-virt: CPU type %s not supported", machine->cpu_type); | ||
78 | + exit(1); | ||
79 | + } | 75 | + } |
80 | + | 76 | + |
81 | + possible_cpus = mc->possible_cpu_arch_ids(machine); | 77 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.adma); i++) { |
78 | + g_autofree gchar *name = g_strdup_printf("adma[%d]", i); | ||
82 | + | 79 | + |
83 | /* | 80 | + object_property_set_link(OBJECT(&s->lpd.crl), |
84 | * In accelerated mode, the memory map is computed earlier in kvm_type() | 81 | + name, OBJECT(&s->lpd.iou.adma[i]), |
85 | * to create a VM with the right number of IPA bits. | 82 | + &error_abort); |
86 | */ | 83 | + } |
87 | if (!vms->memmap) { | ||
88 | - virt_set_memmap(vms); | ||
89 | + Object *cpuobj; | ||
90 | + ARMCPU *armcpu; | ||
91 | + int pa_bits; | ||
92 | + | 84 | + |
93 | + /* | 85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.uart); i++) { |
94 | + * Instanciate a temporary CPU object to find out about what | 86 | + g_autofree gchar *name = g_strdup_printf("uart[%d]", i); |
95 | + * we are about to deal with. Once this is done, get rid of | ||
96 | + * the object. | ||
97 | + */ | ||
98 | + cpuobj = object_new(possible_cpus->cpus[0].type); | ||
99 | + armcpu = ARM_CPU(cpuobj); | ||
100 | + | 87 | + |
101 | + if (object_property_get_bool(cpuobj, "aarch64", NULL)) { | 88 | + object_property_set_link(OBJECT(&s->lpd.crl), |
102 | + pa_bits = arm_pamax(armcpu); | 89 | + name, OBJECT(&s->lpd.iou.uart[i]), |
103 | + } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) { | 90 | + &error_abort); |
104 | + /* v7 with LPAE */ | 91 | + } |
105 | + pa_bits = 40; | ||
106 | + } else { | ||
107 | + /* Anything else */ | ||
108 | + pa_bits = 32; | ||
109 | + } | ||
110 | + | 92 | + |
111 | + object_unref(cpuobj); | 93 | + object_property_set_link(OBJECT(&s->lpd.crl), |
94 | + "usb", OBJECT(&s->lpd.iou.usb), | ||
95 | + &error_abort); | ||
112 | + | 96 | + |
113 | + virt_set_memmap(vms, pa_bits); | 97 | + sysbus_realize(sbd, &error_fatal); |
114 | } | 98 | + memory_region_add_subregion(&s->mr_ps, MM_CRL, |
115 | 99 | + sysbus_mmio_get_region(sbd, 0)); | |
116 | /* We can probe only here because during property set | 100 | + sysbus_connect_irq(sbd, 0, pic[VERSAL_CRL_IRQ]); |
117 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 101 | +} |
118 | */ | 102 | + |
119 | finalize_gic_version(vms); | 103 | /* This takes the board allocated linear DDR memory and creates aliases |
120 | 104 | * for each split DDR range/aperture on the Versal address map. | |
121 | - if (!cpu_type_valid(machine->cpu_type)) { | 105 | */ |
122 | - error_report("mach-virt: CPU type %s not supported", machine->cpu_type); | 106 | @@ -XXX,XX +XXX,XX @@ static void versal_unimp(Versal *s) |
123 | - exit(1); | 107 | |
124 | - } | 108 | versal_unimp_area(s, "psm", &s->mr_ps, |
125 | - | 109 | MM_PSM_START, MM_PSM_END - MM_PSM_START); |
126 | if (vms->secure) { | 110 | - versal_unimp_area(s, "crl", &s->mr_ps, |
127 | /* | 111 | - MM_CRL, MM_CRL_SIZE); |
128 | * The Secure view of the world is the same as the NonSecure, | 112 | versal_unimp_area(s, "crf", &s->mr_ps, |
129 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 113 | MM_FPD_CRF, MM_FPD_CRF_SIZE); |
130 | 114 | versal_unimp_area(s, "apu", &s->mr_ps, | |
131 | create_fdt(vms); | 115 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) |
132 | 116 | versal_create_efuse(s, pic); | |
133 | - possible_cpus = mc->possible_cpu_arch_ids(machine); | 117 | versal_create_pmc_iou_slcr(s, pic); |
134 | assert(possible_cpus->len == max_cpus); | 118 | versal_create_ospi(s, pic); |
135 | for (n = 0; n < possible_cpus->len; n++) { | 119 | + versal_create_crl(s, pic); |
136 | Object *cpuobj; | 120 | versal_map_ddr(s); |
137 | @@ -XXX,XX +XXX,XX @@ static int virt_kvm_type(MachineState *ms, const char *type_str) | 121 | versal_unimp(s); |
138 | max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa); | ||
139 | |||
140 | /* we freeze the memory map to compute the highest gpa */ | ||
141 | - virt_set_memmap(vms); | ||
142 | + virt_set_memmap(vms, max_vm_pa_size); | ||
143 | |||
144 | requested_pa_size = 64 - clz64(vms->highest_gpa); | ||
145 | 122 | ||
146 | -- | 123 | -- |
147 | 2.25.1 | 124 | 2.25.1 |
148 | |||
149 | diff view generated by jsdifflib |
1 | Fix process_mapti() to consistently return CMD_STALL for memory | 1 | The Exynos4210 SoC device currently uses a custom device |
---|---|---|---|
2 | errors and CMD_CONTINUE for parameter errors, as we claim in the | 2 | "exynos4210.irq_gate" to model the OR gate that feeds each CPU's IRQ |
3 | comments that we do. | 3 | line. We have a standard TYPE_OR_IRQ device for this now, so use |
4 | that instead. | ||
5 | |||
6 | (This is a migration compatibility break, but that is OK for this | ||
7 | machine type.) | ||
4 | 8 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220111171048.3545974-9-peter.maydell@linaro.org | 11 | Message-id: 20220404154658.565020-2-peter.maydell@linaro.org |
9 | --- | 12 | --- |
10 | hw/intc/arm_gicv3_its.c | 28 +++++++++++++--------------- | 13 | include/hw/arm/exynos4210.h | 1 + |
11 | 1 file changed, 13 insertions(+), 15 deletions(-) | 14 | hw/arm/exynos4210.c | 31 ++++++++++++++++--------------- |
15 | 2 files changed, 17 insertions(+), 15 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/arm_gicv3_its.c | 19 | --- a/include/hw/arm/exynos4210.h |
16 | +++ b/hw/intc/arm_gicv3_its.c | 20 | +++ b/include/hw/arm/exynos4210.h |
17 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 21 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { |
18 | MemTxResult res = MEMTX_OK; | 22 | MemoryRegion bootreg_mem; |
19 | uint16_t icid = 0; | 23 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; |
20 | uint64_t dte = 0; | 24 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; |
21 | - ItsCmdResult result = CMD_STALL; | 25 | + qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; |
22 | + IteEntry ite = {}; | 26 | }; |
23 | 27 | ||
24 | devid = ((value & DEVID_MASK) >> DEVID_SHIFT); | 28 | #define TYPE_EXYNOS4210_SOC "exynos4210" |
25 | offset += NUM_BYTES_IN_DW; | 29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
26 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 30 | index XXXXXXX..XXXXXXX 100644 |
27 | MEMTXATTRS_UNSPECIFIED, &res); | 31 | --- a/hw/arm/exynos4210.c |
28 | 32 | +++ b/hw/arm/exynos4210.c | |
29 | if (res != MEMTX_OK) { | 33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
30 | - return result; | 34 | { |
31 | + return CMD_STALL; | 35 | Exynos4210State *s = EXYNOS4210_SOC(socdev); |
36 | MemoryRegion *system_mem = get_system_memory(); | ||
37 | - qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
38 | SysBusDevice *busdev; | ||
39 | DeviceState *dev, *uart[4], *pl330[3]; | ||
40 | int i, n; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
42 | |||
43 | /* IRQ Gate */ | ||
44 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { | ||
45 | - dev = qdev_new("exynos4210.irq_gate"); | ||
46 | - qdev_prop_set_uint32(dev, "n_in", EXYNOS4210_IRQ_GATE_NINPUTS); | ||
47 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
48 | - /* Get IRQ Gate input in gate_irq */ | ||
49 | - for (n = 0; n < EXYNOS4210_IRQ_GATE_NINPUTS; n++) { | ||
50 | - gate_irq[i][n] = qdev_get_gpio_in(dev, n); | ||
51 | - } | ||
52 | - busdev = SYS_BUS_DEVICE(dev); | ||
53 | - | ||
54 | - /* Connect IRQ Gate output to CPU's IRQ line */ | ||
55 | - sysbus_connect_irq(busdev, 0, | ||
56 | - qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ)); | ||
57 | + DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); | ||
58 | + object_property_set_int(OBJECT(orgate), "num-lines", | ||
59 | + EXYNOS4210_IRQ_GATE_NINPUTS, | ||
60 | + &error_abort); | ||
61 | + qdev_realize(orgate, NULL, &error_abort); | ||
62 | + qdev_connect_gpio_out(orgate, 0, | ||
63 | + qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ)); | ||
32 | } | 64 | } |
33 | 65 | ||
34 | eventid = (value & EVENTID_MASK); | 66 | /* Private memory region and Internal GIC */ |
35 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 67 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
36 | MEMTXATTRS_UNSPECIFIED, &res); | 68 | sysbus_realize_and_unref(busdev, &error_fatal); |
37 | 69 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); | |
38 | if (res != MEMTX_OK) { | 70 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { |
39 | - return result; | 71 | - sysbus_connect_irq(busdev, n, gate_irq[n][0]); |
40 | + return CMD_STALL; | 72 | + sysbus_connect_irq(busdev, n, |
73 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
41 | } | 74 | } |
42 | 75 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | |
43 | icid = value & ICID_MASK; | 76 | s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); |
44 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 77 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
45 | dte = get_dte(s, devid, &res); | 78 | /* Map Distributer interface */ |
46 | 79 | sysbus_mmio_map(busdev, 1, EXYNOS4210_EXT_GIC_DIST_BASE_ADDR); | |
47 | if (res != MEMTX_OK) { | 80 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { |
48 | - return result; | 81 | - sysbus_connect_irq(busdev, n, gate_irq[n][1]); |
49 | + return CMD_STALL; | 82 | + sysbus_connect_irq(busdev, n, |
83 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
50 | } | 84 | } |
51 | dte_valid = FIELD_EX64(dte, DTE, VALID); | 85 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { |
52 | num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 86 | s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); |
53 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 87 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) |
54 | * we ignore this command and move onto the next | 88 | object_initialize_child(obj, name, orgate, TYPE_OR_IRQ); |
55 | * command in the queue | 89 | g_free(name); |
56 | */ | ||
57 | - } else { | ||
58 | - /* add ite entry to interrupt translation table */ | ||
59 | - IteEntry ite = {}; | ||
60 | - ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid); | ||
61 | - ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL); | ||
62 | - ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid); | ||
63 | - ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS); | ||
64 | - ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid); | ||
65 | - | ||
66 | - result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | ||
67 | + return CMD_CONTINUE; | ||
68 | } | 90 | } |
69 | |||
70 | - return result; | ||
71 | + /* add ite entry to interrupt translation table */ | ||
72 | + ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid); | ||
73 | + ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL); | ||
74 | + ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid); | ||
75 | + ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS); | ||
76 | + ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid); | ||
77 | + | 91 | + |
78 | + return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | 92 | + for (i = 0; i < ARRAY_SIZE(s->cpu_irq_orgate); i++) { |
93 | + g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i); | ||
94 | + object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | ||
95 | + } | ||
79 | } | 96 | } |
80 | 97 | ||
81 | static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid, | 98 | static void exynos4210_class_init(ObjectClass *klass, void *data) |
82 | -- | 99 | -- |
83 | 2.25.1 | 100 | 2.25.1 |
84 | |||
85 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Now we have removed the only use of TYPE_EXYNOS4210_IRQ_GATE we can |
---|---|---|---|
2 | delete the device entirely. | ||
2 | 3 | ||
3 | The Marvell 88W8618 network device is hidden in the Musicpal | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | machine. Move it into a new unit file under the hw/net/ directory. | 5 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
6 | Message-id: 20220404154658.565020-3-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/intc/exynos4210_gic.c | 107 --------------------------------------- | ||
9 | 1 file changed, 107 deletions(-) | ||
5 | 10 | ||
6 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | 11 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c |
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20220107184429.423572-4-f4bug@amsat.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/net/mv88w8618_eth.h | 12 + | ||
13 | hw/arm/musicpal.c | 381 +------------------------------ | ||
14 | hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++++++++++ | ||
15 | MAINTAINERS | 2 + | ||
16 | hw/net/meson.build | 1 + | ||
17 | 5 files changed, 419 insertions(+), 380 deletions(-) | ||
18 | create mode 100644 include/hw/net/mv88w8618_eth.h | ||
19 | create mode 100644 hw/net/mv88w8618_eth.c | ||
20 | |||
21 | diff --git a/include/hw/net/mv88w8618_eth.h b/include/hw/net/mv88w8618_eth.h | ||
22 | new file mode 100644 | ||
23 | index XXXXXXX..XXXXXXX | ||
24 | --- /dev/null | ||
25 | +++ b/include/hw/net/mv88w8618_eth.h | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
28 | +/* | ||
29 | + * Marvell MV88W8618 / Freecom MusicPal emulation. | ||
30 | + * | ||
31 | + * Copyright (c) 2008-2021 QEMU contributors | ||
32 | + */ | ||
33 | +#ifndef HW_NET_MV88W8618_H | ||
34 | +#define HW_NET_MV88W8618_H | ||
35 | + | ||
36 | +#define TYPE_MV88W8618_ETH "mv88w8618_eth" | ||
37 | + | ||
38 | +#endif | ||
39 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/hw/arm/musicpal.c | 13 | --- a/hw/intc/exynos4210_gic.c |
42 | +++ b/hw/arm/musicpal.c | 14 | +++ b/hw/intc/exynos4210_gic.c |
43 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_register_types(void) |
44 | #include "ui/pixel_ops.h" | 16 | } |
45 | #include "qemu/cutils.h" | 17 | |
46 | #include "qom/object.h" | 18 | type_init(exynos4210_gic_register_types) |
47 | +#include "hw/net/mv88w8618_eth.h" | ||
48 | |||
49 | #define MP_MISC_BASE 0x80002000 | ||
50 | #define MP_MISC_SIZE 0x00001000 | ||
51 | |||
52 | #define MP_ETH_BASE 0x80008000 | ||
53 | -#define MP_ETH_SIZE 0x00001000 | ||
54 | |||
55 | #define MP_WLAN_BASE 0x8000C000 | ||
56 | #define MP_WLAN_SIZE 0x00000800 | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | /* Wolfson 8750 I2C address */ | ||
59 | #define MP_WM_ADDR 0x1A | ||
60 | |||
61 | -/* Ethernet register offsets */ | ||
62 | -#define MP_ETH_SMIR 0x010 | ||
63 | -#define MP_ETH_PCXR 0x408 | ||
64 | -#define MP_ETH_SDCMR 0x448 | ||
65 | -#define MP_ETH_ICR 0x450 | ||
66 | -#define MP_ETH_IMR 0x458 | ||
67 | -#define MP_ETH_FRDP0 0x480 | ||
68 | -#define MP_ETH_FRDP1 0x484 | ||
69 | -#define MP_ETH_FRDP2 0x488 | ||
70 | -#define MP_ETH_FRDP3 0x48C | ||
71 | -#define MP_ETH_CRDP0 0x4A0 | ||
72 | -#define MP_ETH_CRDP1 0x4A4 | ||
73 | -#define MP_ETH_CRDP2 0x4A8 | ||
74 | -#define MP_ETH_CRDP3 0x4AC | ||
75 | -#define MP_ETH_CTDP0 0x4E0 | ||
76 | -#define MP_ETH_CTDP1 0x4E4 | ||
77 | - | 19 | - |
78 | -/* MII PHY access */ | 20 | -/* IRQ OR Gate struct. |
79 | -#define MP_ETH_SMIR_DATA 0x0000FFFF | 21 | - * |
80 | -#define MP_ETH_SMIR_ADDR 0x03FF0000 | 22 | - * This device models an OR gate. There are n_in input qdev gpio lines and one |
81 | -#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */ | 23 | - * output sysbus IRQ line. The output IRQ level is formed as OR between all |
82 | -#define MP_ETH_SMIR_RDVALID (1 << 27) | 24 | - * gpio inputs. |
25 | - */ | ||
83 | - | 26 | - |
84 | -/* PHY registers */ | 27 | -#define TYPE_EXYNOS4210_IRQ_GATE "exynos4210.irq_gate" |
85 | -#define MP_ETH_PHY1_BMSR 0x00210000 | 28 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210IRQGateState, EXYNOS4210_IRQ_GATE) |
86 | -#define MP_ETH_PHY1_PHYSID1 0x00410000 | ||
87 | -#define MP_ETH_PHY1_PHYSID2 0x00610000 | ||
88 | - | 29 | - |
89 | -#define MP_PHY_BMSR_LINK 0x0004 | 30 | -struct Exynos4210IRQGateState { |
90 | -#define MP_PHY_BMSR_AUTONEG 0x0008 | 31 | - SysBusDevice parent_obj; |
91 | - | 32 | - |
92 | -#define MP_PHY_88E3015 0x01410E20 | 33 | - uint32_t n_in; /* inputs amount */ |
93 | - | 34 | - uint32_t *level; /* input levels */ |
94 | -/* TX descriptor status */ | 35 | - qemu_irq out; /* output IRQ */ |
95 | -#define MP_ETH_TX_OWN (1U << 31) | ||
96 | - | ||
97 | -/* RX descriptor status */ | ||
98 | -#define MP_ETH_RX_OWN (1U << 31) | ||
99 | - | ||
100 | -/* Interrupt cause/mask bits */ | ||
101 | -#define MP_ETH_IRQ_RX_BIT 0 | ||
102 | -#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT) | ||
103 | -#define MP_ETH_IRQ_TXHI_BIT 2 | ||
104 | -#define MP_ETH_IRQ_TXLO_BIT 3 | ||
105 | - | ||
106 | -/* Port config bits */ | ||
107 | -#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */ | ||
108 | - | ||
109 | -/* SDMA command bits */ | ||
110 | -#define MP_ETH_CMD_TXHI (1 << 23) | ||
111 | -#define MP_ETH_CMD_TXLO (1 << 22) | ||
112 | - | ||
113 | -typedef struct mv88w8618_tx_desc { | ||
114 | - uint32_t cmdstat; | ||
115 | - uint16_t res; | ||
116 | - uint16_t bytes; | ||
117 | - uint32_t buffer; | ||
118 | - uint32_t next; | ||
119 | -} mv88w8618_tx_desc; | ||
120 | - | ||
121 | -typedef struct mv88w8618_rx_desc { | ||
122 | - uint32_t cmdstat; | ||
123 | - uint16_t bytes; | ||
124 | - uint16_t buffer_size; | ||
125 | - uint32_t buffer; | ||
126 | - uint32_t next; | ||
127 | -} mv88w8618_rx_desc; | ||
128 | - | ||
129 | -#define TYPE_MV88W8618_ETH "mv88w8618_eth" | ||
130 | -OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH) | ||
131 | - | ||
132 | -struct mv88w8618_eth_state { | ||
133 | - /*< private >*/ | ||
134 | - SysBusDevice parent_obj; | ||
135 | - /*< public >*/ | ||
136 | - | ||
137 | - MemoryRegion iomem; | ||
138 | - qemu_irq irq; | ||
139 | - MemoryRegion *dma_mr; | ||
140 | - AddressSpace dma_as; | ||
141 | - uint32_t smir; | ||
142 | - uint32_t icr; | ||
143 | - uint32_t imr; | ||
144 | - int mmio_index; | ||
145 | - uint32_t vlan_header; | ||
146 | - uint32_t tx_queue[2]; | ||
147 | - uint32_t rx_queue[4]; | ||
148 | - uint32_t frx_queue[4]; | ||
149 | - uint32_t cur_rx[4]; | ||
150 | - NICState *nic; | ||
151 | - NICConf conf; | ||
152 | -}; | 36 | -}; |
153 | - | 37 | - |
154 | -static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr, | 38 | -static Property exynos4210_irq_gate_properties[] = { |
155 | - mv88w8618_rx_desc *desc) | 39 | - DEFINE_PROP_UINT32("n_in", Exynos4210IRQGateState, n_in, 1), |
156 | -{ | 40 | - DEFINE_PROP_END_OF_LIST(), |
157 | - cpu_to_le32s(&desc->cmdstat); | ||
158 | - cpu_to_le16s(&desc->bytes); | ||
159 | - cpu_to_le16s(&desc->buffer_size); | ||
160 | - cpu_to_le32s(&desc->buffer); | ||
161 | - cpu_to_le32s(&desc->next); | ||
162 | - dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
163 | -} | ||
164 | - | ||
165 | -static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr, | ||
166 | - mv88w8618_rx_desc *desc) | ||
167 | -{ | ||
168 | - dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
169 | - le32_to_cpus(&desc->cmdstat); | ||
170 | - le16_to_cpus(&desc->bytes); | ||
171 | - le16_to_cpus(&desc->buffer_size); | ||
172 | - le32_to_cpus(&desc->buffer); | ||
173 | - le32_to_cpus(&desc->next); | ||
174 | -} | ||
175 | - | ||
176 | -static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
177 | -{ | ||
178 | - mv88w8618_eth_state *s = qemu_get_nic_opaque(nc); | ||
179 | - uint32_t desc_addr; | ||
180 | - mv88w8618_rx_desc desc; | ||
181 | - int i; | ||
182 | - | ||
183 | - for (i = 0; i < 4; i++) { | ||
184 | - desc_addr = s->cur_rx[i]; | ||
185 | - if (!desc_addr) { | ||
186 | - continue; | ||
187 | - } | ||
188 | - do { | ||
189 | - eth_rx_desc_get(&s->dma_as, desc_addr, &desc); | ||
190 | - if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) { | ||
191 | - dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header, | ||
192 | - buf, size, MEMTXATTRS_UNSPECIFIED); | ||
193 | - desc.bytes = size + s->vlan_header; | ||
194 | - desc.cmdstat &= ~MP_ETH_RX_OWN; | ||
195 | - s->cur_rx[i] = desc.next; | ||
196 | - | ||
197 | - s->icr |= MP_ETH_IRQ_RX; | ||
198 | - if (s->icr & s->imr) { | ||
199 | - qemu_irq_raise(s->irq); | ||
200 | - } | ||
201 | - eth_rx_desc_put(&s->dma_as, desc_addr, &desc); | ||
202 | - return size; | ||
203 | - } | ||
204 | - desc_addr = desc.next; | ||
205 | - } while (desc_addr != s->rx_queue[i]); | ||
206 | - } | ||
207 | - return size; | ||
208 | -} | ||
209 | - | ||
210 | -static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr, | ||
211 | - mv88w8618_tx_desc *desc) | ||
212 | -{ | ||
213 | - cpu_to_le32s(&desc->cmdstat); | ||
214 | - cpu_to_le16s(&desc->res); | ||
215 | - cpu_to_le16s(&desc->bytes); | ||
216 | - cpu_to_le32s(&desc->buffer); | ||
217 | - cpu_to_le32s(&desc->next); | ||
218 | - dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
219 | -} | ||
220 | - | ||
221 | -static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr, | ||
222 | - mv88w8618_tx_desc *desc) | ||
223 | -{ | ||
224 | - dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
225 | - le32_to_cpus(&desc->cmdstat); | ||
226 | - le16_to_cpus(&desc->res); | ||
227 | - le16_to_cpus(&desc->bytes); | ||
228 | - le32_to_cpus(&desc->buffer); | ||
229 | - le32_to_cpus(&desc->next); | ||
230 | -} | ||
231 | - | ||
232 | -static void eth_send(mv88w8618_eth_state *s, int queue_index) | ||
233 | -{ | ||
234 | - uint32_t desc_addr = s->tx_queue[queue_index]; | ||
235 | - mv88w8618_tx_desc desc; | ||
236 | - uint32_t next_desc; | ||
237 | - uint8_t buf[2048]; | ||
238 | - int len; | ||
239 | - | ||
240 | - do { | ||
241 | - eth_tx_desc_get(&s->dma_as, desc_addr, &desc); | ||
242 | - next_desc = desc.next; | ||
243 | - if (desc.cmdstat & MP_ETH_TX_OWN) { | ||
244 | - len = desc.bytes; | ||
245 | - if (len < 2048) { | ||
246 | - dma_memory_read(&s->dma_as, desc.buffer, buf, len, | ||
247 | - MEMTXATTRS_UNSPECIFIED); | ||
248 | - qemu_send_packet(qemu_get_queue(s->nic), buf, len); | ||
249 | - } | ||
250 | - desc.cmdstat &= ~MP_ETH_TX_OWN; | ||
251 | - s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index); | ||
252 | - eth_tx_desc_put(&s->dma_as, desc_addr, &desc); | ||
253 | - } | ||
254 | - desc_addr = next_desc; | ||
255 | - } while (desc_addr != s->tx_queue[queue_index]); | ||
256 | -} | ||
257 | - | ||
258 | -static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset, | ||
259 | - unsigned size) | ||
260 | -{ | ||
261 | - mv88w8618_eth_state *s = opaque; | ||
262 | - | ||
263 | - switch (offset) { | ||
264 | - case MP_ETH_SMIR: | ||
265 | - if (s->smir & MP_ETH_SMIR_OPCODE) { | ||
266 | - switch (s->smir & MP_ETH_SMIR_ADDR) { | ||
267 | - case MP_ETH_PHY1_BMSR: | ||
268 | - return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG | | ||
269 | - MP_ETH_SMIR_RDVALID; | ||
270 | - case MP_ETH_PHY1_PHYSID1: | ||
271 | - return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID; | ||
272 | - case MP_ETH_PHY1_PHYSID2: | ||
273 | - return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID; | ||
274 | - default: | ||
275 | - return MP_ETH_SMIR_RDVALID; | ||
276 | - } | ||
277 | - } | ||
278 | - return 0; | ||
279 | - | ||
280 | - case MP_ETH_ICR: | ||
281 | - return s->icr; | ||
282 | - | ||
283 | - case MP_ETH_IMR: | ||
284 | - return s->imr; | ||
285 | - | ||
286 | - case MP_ETH_FRDP0 ... MP_ETH_FRDP3: | ||
287 | - return s->frx_queue[(offset - MP_ETH_FRDP0) / 4]; | ||
288 | - | ||
289 | - case MP_ETH_CRDP0 ... MP_ETH_CRDP3: | ||
290 | - return s->rx_queue[(offset - MP_ETH_CRDP0) / 4]; | ||
291 | - | ||
292 | - case MP_ETH_CTDP0 ... MP_ETH_CTDP1: | ||
293 | - return s->tx_queue[(offset - MP_ETH_CTDP0) / 4]; | ||
294 | - | ||
295 | - default: | ||
296 | - return 0; | ||
297 | - } | ||
298 | -} | ||
299 | - | ||
300 | -static void mv88w8618_eth_write(void *opaque, hwaddr offset, | ||
301 | - uint64_t value, unsigned size) | ||
302 | -{ | ||
303 | - mv88w8618_eth_state *s = opaque; | ||
304 | - | ||
305 | - switch (offset) { | ||
306 | - case MP_ETH_SMIR: | ||
307 | - s->smir = value; | ||
308 | - break; | ||
309 | - | ||
310 | - case MP_ETH_PCXR: | ||
311 | - s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2; | ||
312 | - break; | ||
313 | - | ||
314 | - case MP_ETH_SDCMR: | ||
315 | - if (value & MP_ETH_CMD_TXHI) { | ||
316 | - eth_send(s, 1); | ||
317 | - } | ||
318 | - if (value & MP_ETH_CMD_TXLO) { | ||
319 | - eth_send(s, 0); | ||
320 | - } | ||
321 | - if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) { | ||
322 | - qemu_irq_raise(s->irq); | ||
323 | - } | ||
324 | - break; | ||
325 | - | ||
326 | - case MP_ETH_ICR: | ||
327 | - s->icr &= value; | ||
328 | - break; | ||
329 | - | ||
330 | - case MP_ETH_IMR: | ||
331 | - s->imr = value; | ||
332 | - if (s->icr & s->imr) { | ||
333 | - qemu_irq_raise(s->irq); | ||
334 | - } | ||
335 | - break; | ||
336 | - | ||
337 | - case MP_ETH_FRDP0 ... MP_ETH_FRDP3: | ||
338 | - s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value; | ||
339 | - break; | ||
340 | - | ||
341 | - case MP_ETH_CRDP0 ... MP_ETH_CRDP3: | ||
342 | - s->rx_queue[(offset - MP_ETH_CRDP0) / 4] = | ||
343 | - s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value; | ||
344 | - break; | ||
345 | - | ||
346 | - case MP_ETH_CTDP0 ... MP_ETH_CTDP1: | ||
347 | - s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value; | ||
348 | - break; | ||
349 | - } | ||
350 | -} | ||
351 | - | ||
352 | -static const MemoryRegionOps mv88w8618_eth_ops = { | ||
353 | - .read = mv88w8618_eth_read, | ||
354 | - .write = mv88w8618_eth_write, | ||
355 | - .endianness = DEVICE_NATIVE_ENDIAN, | ||
356 | -}; | 41 | -}; |
357 | - | 42 | - |
358 | -static void eth_cleanup(NetClientState *nc) | 43 | -static const VMStateDescription vmstate_exynos4210_irq_gate = { |
359 | -{ | 44 | - .name = "exynos4210.irq_gate", |
360 | - mv88w8618_eth_state *s = qemu_get_nic_opaque(nc); | 45 | - .version_id = 2, |
361 | - | 46 | - .minimum_version_id = 2, |
362 | - s->nic = NULL; | ||
363 | -} | ||
364 | - | ||
365 | -static NetClientInfo net_mv88w8618_info = { | ||
366 | - .type = NET_CLIENT_DRIVER_NIC, | ||
367 | - .size = sizeof(NICState), | ||
368 | - .receive = eth_receive, | ||
369 | - .cleanup = eth_cleanup, | ||
370 | -}; | ||
371 | - | ||
372 | -static void mv88w8618_eth_init(Object *obj) | ||
373 | -{ | ||
374 | - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
375 | - DeviceState *dev = DEVICE(sbd); | ||
376 | - mv88w8618_eth_state *s = MV88W8618_ETH(dev); | ||
377 | - | ||
378 | - sysbus_init_irq(sbd, &s->irq); | ||
379 | - memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s, | ||
380 | - "mv88w8618-eth", MP_ETH_SIZE); | ||
381 | - sysbus_init_mmio(sbd, &s->iomem); | ||
382 | -} | ||
383 | - | ||
384 | -static void mv88w8618_eth_realize(DeviceState *dev, Error **errp) | ||
385 | -{ | ||
386 | - mv88w8618_eth_state *s = MV88W8618_ETH(dev); | ||
387 | - | ||
388 | - if (!s->dma_mr) { | ||
389 | - error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set"); | ||
390 | - return; | ||
391 | - } | ||
392 | - | ||
393 | - address_space_init(&s->dma_as, s->dma_mr, "emac-dma"); | ||
394 | - s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf, | ||
395 | - object_get_typename(OBJECT(dev)), dev->id, s); | ||
396 | -} | ||
397 | - | ||
398 | -static const VMStateDescription mv88w8618_eth_vmsd = { | ||
399 | - .name = "mv88w8618_eth", | ||
400 | - .version_id = 1, | ||
401 | - .minimum_version_id = 1, | ||
402 | - .fields = (VMStateField[]) { | 47 | - .fields = (VMStateField[]) { |
403 | - VMSTATE_UINT32(smir, mv88w8618_eth_state), | 48 | - VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, 1, NULL, n_in), |
404 | - VMSTATE_UINT32(icr, mv88w8618_eth_state), | ||
405 | - VMSTATE_UINT32(imr, mv88w8618_eth_state), | ||
406 | - VMSTATE_UINT32(vlan_header, mv88w8618_eth_state), | ||
407 | - VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2), | ||
408 | - VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4), | ||
409 | - VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4), | ||
410 | - VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4), | ||
411 | - VMSTATE_END_OF_LIST() | 49 | - VMSTATE_END_OF_LIST() |
412 | - } | 50 | - } |
413 | -}; | 51 | -}; |
414 | - | 52 | - |
415 | -static Property mv88w8618_eth_properties[] = { | 53 | -/* Process a change in IRQ input. */ |
416 | - DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf), | 54 | -static void exynos4210_irq_gate_handler(void *opaque, int irq, int level) |
417 | - DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr, | 55 | -{ |
418 | - TYPE_MEMORY_REGION, MemoryRegion *), | 56 | - Exynos4210IRQGateState *s = (Exynos4210IRQGateState *)opaque; |
419 | - DEFINE_PROP_END_OF_LIST(), | 57 | - uint32_t i; |
420 | -}; | ||
421 | - | 58 | - |
422 | -static void mv88w8618_eth_class_init(ObjectClass *klass, void *data) | 59 | - assert(irq < s->n_in); |
60 | - | ||
61 | - s->level[irq] = level; | ||
62 | - | ||
63 | - for (i = 0; i < s->n_in; i++) { | ||
64 | - if (s->level[i] >= 1) { | ||
65 | - qemu_irq_raise(s->out); | ||
66 | - return; | ||
67 | - } | ||
68 | - } | ||
69 | - | ||
70 | - qemu_irq_lower(s->out); | ||
71 | -} | ||
72 | - | ||
73 | -static void exynos4210_irq_gate_reset(DeviceState *d) | ||
74 | -{ | ||
75 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(d); | ||
76 | - | ||
77 | - memset(s->level, 0, s->n_in * sizeof(*s->level)); | ||
78 | -} | ||
79 | - | ||
80 | -/* | ||
81 | - * IRQ Gate initialization. | ||
82 | - */ | ||
83 | -static void exynos4210_irq_gate_init(Object *obj) | ||
84 | -{ | ||
85 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(obj); | ||
86 | - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
87 | - | ||
88 | - sysbus_init_irq(sbd, &s->out); | ||
89 | -} | ||
90 | - | ||
91 | -static void exynos4210_irq_gate_realize(DeviceState *dev, Error **errp) | ||
92 | -{ | ||
93 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(dev); | ||
94 | - | ||
95 | - /* Allocate general purpose input signals and connect a handler to each of | ||
96 | - * them */ | ||
97 | - qdev_init_gpio_in(dev, exynos4210_irq_gate_handler, s->n_in); | ||
98 | - | ||
99 | - s->level = g_malloc0(s->n_in * sizeof(*s->level)); | ||
100 | -} | ||
101 | - | ||
102 | -static void exynos4210_irq_gate_class_init(ObjectClass *klass, void *data) | ||
423 | -{ | 103 | -{ |
424 | - DeviceClass *dc = DEVICE_CLASS(klass); | 104 | - DeviceClass *dc = DEVICE_CLASS(klass); |
425 | - | 105 | - |
426 | - dc->vmsd = &mv88w8618_eth_vmsd; | 106 | - dc->reset = exynos4210_irq_gate_reset; |
427 | - device_class_set_props(dc, mv88w8618_eth_properties); | 107 | - dc->vmsd = &vmstate_exynos4210_irq_gate; |
428 | - dc->realize = mv88w8618_eth_realize; | 108 | - device_class_set_props(dc, exynos4210_irq_gate_properties); |
109 | - dc->realize = exynos4210_irq_gate_realize; | ||
429 | -} | 110 | -} |
430 | - | 111 | - |
431 | -static const TypeInfo mv88w8618_eth_info = { | 112 | -static const TypeInfo exynos4210_irq_gate_info = { |
432 | - .name = TYPE_MV88W8618_ETH, | 113 | - .name = TYPE_EXYNOS4210_IRQ_GATE, |
433 | - .parent = TYPE_SYS_BUS_DEVICE, | 114 | - .parent = TYPE_SYS_BUS_DEVICE, |
434 | - .instance_size = sizeof(mv88w8618_eth_state), | 115 | - .instance_size = sizeof(Exynos4210IRQGateState), |
435 | - .instance_init = mv88w8618_eth_init, | 116 | - .instance_init = exynos4210_irq_gate_init, |
436 | - .class_init = mv88w8618_eth_class_init, | 117 | - .class_init = exynos4210_irq_gate_class_init, |
437 | -}; | 118 | -}; |
438 | - | 119 | - |
439 | /* LCD register offsets */ | 120 | -static void exynos4210_irq_gate_register_types(void) |
440 | #define MP_LCD_IRQCTRL 0x180 | 121 | -{ |
441 | #define MP_LCD_IRQSTAT 0x184 | 122 | - type_register_static(&exynos4210_irq_gate_info); |
442 | @@ -XXX,XX +XXX,XX @@ static void musicpal_register_types(void) | 123 | -} |
443 | type_register_static(&mv88w8618_pic_info); | 124 | - |
444 | type_register_static(&mv88w8618_pit_info); | 125 | -type_init(exynos4210_irq_gate_register_types) |
445 | type_register_static(&mv88w8618_flashcfg_info); | ||
446 | - type_register_static(&mv88w8618_eth_info); | ||
447 | type_register_static(&mv88w8618_wlan_info); | ||
448 | type_register_static(&musicpal_lcd_info); | ||
449 | type_register_static(&musicpal_gpio_info); | ||
450 | diff --git a/hw/net/mv88w8618_eth.c b/hw/net/mv88w8618_eth.c | ||
451 | new file mode 100644 | ||
452 | index XXXXXXX..XXXXXXX | ||
453 | --- /dev/null | ||
454 | +++ b/hw/net/mv88w8618_eth.c | ||
455 | @@ -XXX,XX +XXX,XX @@ | ||
456 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
457 | +/* | ||
458 | + * Marvell MV88W8618 / Freecom MusicPal emulation. | ||
459 | + * | ||
460 | + * Copyright (c) 2008 Jan Kiszka | ||
461 | + */ | ||
462 | + | ||
463 | +#include "qemu/osdep.h" | ||
464 | +#include "qapi/error.h" | ||
465 | +#include "hw/qdev-properties.h" | ||
466 | +#include "hw/sysbus.h" | ||
467 | +#include "hw/irq.h" | ||
468 | +#include "hw/net/mv88w8618_eth.h" | ||
469 | +#include "migration/vmstate.h" | ||
470 | +#include "sysemu/dma.h" | ||
471 | +#include "net/net.h" | ||
472 | + | ||
473 | +#define MP_ETH_SIZE 0x00001000 | ||
474 | + | ||
475 | +/* Ethernet register offsets */ | ||
476 | +#define MP_ETH_SMIR 0x010 | ||
477 | +#define MP_ETH_PCXR 0x408 | ||
478 | +#define MP_ETH_SDCMR 0x448 | ||
479 | +#define MP_ETH_ICR 0x450 | ||
480 | +#define MP_ETH_IMR 0x458 | ||
481 | +#define MP_ETH_FRDP0 0x480 | ||
482 | +#define MP_ETH_FRDP1 0x484 | ||
483 | +#define MP_ETH_FRDP2 0x488 | ||
484 | +#define MP_ETH_FRDP3 0x48C | ||
485 | +#define MP_ETH_CRDP0 0x4A0 | ||
486 | +#define MP_ETH_CRDP1 0x4A4 | ||
487 | +#define MP_ETH_CRDP2 0x4A8 | ||
488 | +#define MP_ETH_CRDP3 0x4AC | ||
489 | +#define MP_ETH_CTDP0 0x4E0 | ||
490 | +#define MP_ETH_CTDP1 0x4E4 | ||
491 | + | ||
492 | +/* MII PHY access */ | ||
493 | +#define MP_ETH_SMIR_DATA 0x0000FFFF | ||
494 | +#define MP_ETH_SMIR_ADDR 0x03FF0000 | ||
495 | +#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */ | ||
496 | +#define MP_ETH_SMIR_RDVALID (1 << 27) | ||
497 | + | ||
498 | +/* PHY registers */ | ||
499 | +#define MP_ETH_PHY1_BMSR 0x00210000 | ||
500 | +#define MP_ETH_PHY1_PHYSID1 0x00410000 | ||
501 | +#define MP_ETH_PHY1_PHYSID2 0x00610000 | ||
502 | + | ||
503 | +#define MP_PHY_BMSR_LINK 0x0004 | ||
504 | +#define MP_PHY_BMSR_AUTONEG 0x0008 | ||
505 | + | ||
506 | +#define MP_PHY_88E3015 0x01410E20 | ||
507 | + | ||
508 | +/* TX descriptor status */ | ||
509 | +#define MP_ETH_TX_OWN (1U << 31) | ||
510 | + | ||
511 | +/* RX descriptor status */ | ||
512 | +#define MP_ETH_RX_OWN (1U << 31) | ||
513 | + | ||
514 | +/* Interrupt cause/mask bits */ | ||
515 | +#define MP_ETH_IRQ_RX_BIT 0 | ||
516 | +#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT) | ||
517 | +#define MP_ETH_IRQ_TXHI_BIT 2 | ||
518 | +#define MP_ETH_IRQ_TXLO_BIT 3 | ||
519 | + | ||
520 | +/* Port config bits */ | ||
521 | +#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */ | ||
522 | + | ||
523 | +/* SDMA command bits */ | ||
524 | +#define MP_ETH_CMD_TXHI (1 << 23) | ||
525 | +#define MP_ETH_CMD_TXLO (1 << 22) | ||
526 | + | ||
527 | +typedef struct mv88w8618_tx_desc { | ||
528 | + uint32_t cmdstat; | ||
529 | + uint16_t res; | ||
530 | + uint16_t bytes; | ||
531 | + uint32_t buffer; | ||
532 | + uint32_t next; | ||
533 | +} mv88w8618_tx_desc; | ||
534 | + | ||
535 | +typedef struct mv88w8618_rx_desc { | ||
536 | + uint32_t cmdstat; | ||
537 | + uint16_t bytes; | ||
538 | + uint16_t buffer_size; | ||
539 | + uint32_t buffer; | ||
540 | + uint32_t next; | ||
541 | +} mv88w8618_rx_desc; | ||
542 | + | ||
543 | +OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH) | ||
544 | + | ||
545 | +struct mv88w8618_eth_state { | ||
546 | + /*< private >*/ | ||
547 | + SysBusDevice parent_obj; | ||
548 | + /*< public >*/ | ||
549 | + | ||
550 | + MemoryRegion iomem; | ||
551 | + qemu_irq irq; | ||
552 | + MemoryRegion *dma_mr; | ||
553 | + AddressSpace dma_as; | ||
554 | + uint32_t smir; | ||
555 | + uint32_t icr; | ||
556 | + uint32_t imr; | ||
557 | + int mmio_index; | ||
558 | + uint32_t vlan_header; | ||
559 | + uint32_t tx_queue[2]; | ||
560 | + uint32_t rx_queue[4]; | ||
561 | + uint32_t frx_queue[4]; | ||
562 | + uint32_t cur_rx[4]; | ||
563 | + NICState *nic; | ||
564 | + NICConf conf; | ||
565 | +}; | ||
566 | + | ||
567 | +static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr, | ||
568 | + mv88w8618_rx_desc *desc) | ||
569 | +{ | ||
570 | + cpu_to_le32s(&desc->cmdstat); | ||
571 | + cpu_to_le16s(&desc->bytes); | ||
572 | + cpu_to_le16s(&desc->buffer_size); | ||
573 | + cpu_to_le32s(&desc->buffer); | ||
574 | + cpu_to_le32s(&desc->next); | ||
575 | + dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
576 | +} | ||
577 | + | ||
578 | +static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr, | ||
579 | + mv88w8618_rx_desc *desc) | ||
580 | +{ | ||
581 | + dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
582 | + le32_to_cpus(&desc->cmdstat); | ||
583 | + le16_to_cpus(&desc->bytes); | ||
584 | + le16_to_cpus(&desc->buffer_size); | ||
585 | + le32_to_cpus(&desc->buffer); | ||
586 | + le32_to_cpus(&desc->next); | ||
587 | +} | ||
588 | + | ||
589 | +static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size) | ||
590 | +{ | ||
591 | + mv88w8618_eth_state *s = qemu_get_nic_opaque(nc); | ||
592 | + uint32_t desc_addr; | ||
593 | + mv88w8618_rx_desc desc; | ||
594 | + int i; | ||
595 | + | ||
596 | + for (i = 0; i < 4; i++) { | ||
597 | + desc_addr = s->cur_rx[i]; | ||
598 | + if (!desc_addr) { | ||
599 | + continue; | ||
600 | + } | ||
601 | + do { | ||
602 | + eth_rx_desc_get(&s->dma_as, desc_addr, &desc); | ||
603 | + if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) { | ||
604 | + dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header, | ||
605 | + buf, size, MEMTXATTRS_UNSPECIFIED); | ||
606 | + desc.bytes = size + s->vlan_header; | ||
607 | + desc.cmdstat &= ~MP_ETH_RX_OWN; | ||
608 | + s->cur_rx[i] = desc.next; | ||
609 | + | ||
610 | + s->icr |= MP_ETH_IRQ_RX; | ||
611 | + if (s->icr & s->imr) { | ||
612 | + qemu_irq_raise(s->irq); | ||
613 | + } | ||
614 | + eth_rx_desc_put(&s->dma_as, desc_addr, &desc); | ||
615 | + return size; | ||
616 | + } | ||
617 | + desc_addr = desc.next; | ||
618 | + } while (desc_addr != s->rx_queue[i]); | ||
619 | + } | ||
620 | + return size; | ||
621 | +} | ||
622 | + | ||
623 | +static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr, | ||
624 | + mv88w8618_tx_desc *desc) | ||
625 | +{ | ||
626 | + cpu_to_le32s(&desc->cmdstat); | ||
627 | + cpu_to_le16s(&desc->res); | ||
628 | + cpu_to_le16s(&desc->bytes); | ||
629 | + cpu_to_le32s(&desc->buffer); | ||
630 | + cpu_to_le32s(&desc->next); | ||
631 | + dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
632 | +} | ||
633 | + | ||
634 | +static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr, | ||
635 | + mv88w8618_tx_desc *desc) | ||
636 | +{ | ||
637 | + dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED); | ||
638 | + le32_to_cpus(&desc->cmdstat); | ||
639 | + le16_to_cpus(&desc->res); | ||
640 | + le16_to_cpus(&desc->bytes); | ||
641 | + le32_to_cpus(&desc->buffer); | ||
642 | + le32_to_cpus(&desc->next); | ||
643 | +} | ||
644 | + | ||
645 | +static void eth_send(mv88w8618_eth_state *s, int queue_index) | ||
646 | +{ | ||
647 | + uint32_t desc_addr = s->tx_queue[queue_index]; | ||
648 | + mv88w8618_tx_desc desc; | ||
649 | + uint32_t next_desc; | ||
650 | + uint8_t buf[2048]; | ||
651 | + int len; | ||
652 | + | ||
653 | + do { | ||
654 | + eth_tx_desc_get(&s->dma_as, desc_addr, &desc); | ||
655 | + next_desc = desc.next; | ||
656 | + if (desc.cmdstat & MP_ETH_TX_OWN) { | ||
657 | + len = desc.bytes; | ||
658 | + if (len < 2048) { | ||
659 | + dma_memory_read(&s->dma_as, desc.buffer, buf, len, | ||
660 | + MEMTXATTRS_UNSPECIFIED); | ||
661 | + qemu_send_packet(qemu_get_queue(s->nic), buf, len); | ||
662 | + } | ||
663 | + desc.cmdstat &= ~MP_ETH_TX_OWN; | ||
664 | + s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index); | ||
665 | + eth_tx_desc_put(&s->dma_as, desc_addr, &desc); | ||
666 | + } | ||
667 | + desc_addr = next_desc; | ||
668 | + } while (desc_addr != s->tx_queue[queue_index]); | ||
669 | +} | ||
670 | + | ||
671 | +static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset, | ||
672 | + unsigned size) | ||
673 | +{ | ||
674 | + mv88w8618_eth_state *s = opaque; | ||
675 | + | ||
676 | + switch (offset) { | ||
677 | + case MP_ETH_SMIR: | ||
678 | + if (s->smir & MP_ETH_SMIR_OPCODE) { | ||
679 | + switch (s->smir & MP_ETH_SMIR_ADDR) { | ||
680 | + case MP_ETH_PHY1_BMSR: | ||
681 | + return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG | | ||
682 | + MP_ETH_SMIR_RDVALID; | ||
683 | + case MP_ETH_PHY1_PHYSID1: | ||
684 | + return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID; | ||
685 | + case MP_ETH_PHY1_PHYSID2: | ||
686 | + return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID; | ||
687 | + default: | ||
688 | + return MP_ETH_SMIR_RDVALID; | ||
689 | + } | ||
690 | + } | ||
691 | + return 0; | ||
692 | + | ||
693 | + case MP_ETH_ICR: | ||
694 | + return s->icr; | ||
695 | + | ||
696 | + case MP_ETH_IMR: | ||
697 | + return s->imr; | ||
698 | + | ||
699 | + case MP_ETH_FRDP0 ... MP_ETH_FRDP3: | ||
700 | + return s->frx_queue[(offset - MP_ETH_FRDP0) / 4]; | ||
701 | + | ||
702 | + case MP_ETH_CRDP0 ... MP_ETH_CRDP3: | ||
703 | + return s->rx_queue[(offset - MP_ETH_CRDP0) / 4]; | ||
704 | + | ||
705 | + case MP_ETH_CTDP0 ... MP_ETH_CTDP1: | ||
706 | + return s->tx_queue[(offset - MP_ETH_CTDP0) / 4]; | ||
707 | + | ||
708 | + default: | ||
709 | + return 0; | ||
710 | + } | ||
711 | +} | ||
712 | + | ||
713 | +static void mv88w8618_eth_write(void *opaque, hwaddr offset, | ||
714 | + uint64_t value, unsigned size) | ||
715 | +{ | ||
716 | + mv88w8618_eth_state *s = opaque; | ||
717 | + | ||
718 | + switch (offset) { | ||
719 | + case MP_ETH_SMIR: | ||
720 | + s->smir = value; | ||
721 | + break; | ||
722 | + | ||
723 | + case MP_ETH_PCXR: | ||
724 | + s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2; | ||
725 | + break; | ||
726 | + | ||
727 | + case MP_ETH_SDCMR: | ||
728 | + if (value & MP_ETH_CMD_TXHI) { | ||
729 | + eth_send(s, 1); | ||
730 | + } | ||
731 | + if (value & MP_ETH_CMD_TXLO) { | ||
732 | + eth_send(s, 0); | ||
733 | + } | ||
734 | + if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) { | ||
735 | + qemu_irq_raise(s->irq); | ||
736 | + } | ||
737 | + break; | ||
738 | + | ||
739 | + case MP_ETH_ICR: | ||
740 | + s->icr &= value; | ||
741 | + break; | ||
742 | + | ||
743 | + case MP_ETH_IMR: | ||
744 | + s->imr = value; | ||
745 | + if (s->icr & s->imr) { | ||
746 | + qemu_irq_raise(s->irq); | ||
747 | + } | ||
748 | + break; | ||
749 | + | ||
750 | + case MP_ETH_FRDP0 ... MP_ETH_FRDP3: | ||
751 | + s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value; | ||
752 | + break; | ||
753 | + | ||
754 | + case MP_ETH_CRDP0 ... MP_ETH_CRDP3: | ||
755 | + s->rx_queue[(offset - MP_ETH_CRDP0) / 4] = | ||
756 | + s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value; | ||
757 | + break; | ||
758 | + | ||
759 | + case MP_ETH_CTDP0 ... MP_ETH_CTDP1: | ||
760 | + s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value; | ||
761 | + break; | ||
762 | + } | ||
763 | +} | ||
764 | + | ||
765 | +static const MemoryRegionOps mv88w8618_eth_ops = { | ||
766 | + .read = mv88w8618_eth_read, | ||
767 | + .write = mv88w8618_eth_write, | ||
768 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
769 | +}; | ||
770 | + | ||
771 | +static void eth_cleanup(NetClientState *nc) | ||
772 | +{ | ||
773 | + mv88w8618_eth_state *s = qemu_get_nic_opaque(nc); | ||
774 | + | ||
775 | + s->nic = NULL; | ||
776 | +} | ||
777 | + | ||
778 | +static NetClientInfo net_mv88w8618_info = { | ||
779 | + .type = NET_CLIENT_DRIVER_NIC, | ||
780 | + .size = sizeof(NICState), | ||
781 | + .receive = eth_receive, | ||
782 | + .cleanup = eth_cleanup, | ||
783 | +}; | ||
784 | + | ||
785 | +static void mv88w8618_eth_init(Object *obj) | ||
786 | +{ | ||
787 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
788 | + DeviceState *dev = DEVICE(sbd); | ||
789 | + mv88w8618_eth_state *s = MV88W8618_ETH(dev); | ||
790 | + | ||
791 | + sysbus_init_irq(sbd, &s->irq); | ||
792 | + memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s, | ||
793 | + "mv88w8618-eth", MP_ETH_SIZE); | ||
794 | + sysbus_init_mmio(sbd, &s->iomem); | ||
795 | +} | ||
796 | + | ||
797 | +static void mv88w8618_eth_realize(DeviceState *dev, Error **errp) | ||
798 | +{ | ||
799 | + mv88w8618_eth_state *s = MV88W8618_ETH(dev); | ||
800 | + | ||
801 | + if (!s->dma_mr) { | ||
802 | + error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set"); | ||
803 | + return; | ||
804 | + } | ||
805 | + | ||
806 | + address_space_init(&s->dma_as, s->dma_mr, "emac-dma"); | ||
807 | + s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf, | ||
808 | + object_get_typename(OBJECT(dev)), dev->id, s); | ||
809 | +} | ||
810 | + | ||
811 | +static const VMStateDescription mv88w8618_eth_vmsd = { | ||
812 | + .name = "mv88w8618_eth", | ||
813 | + .version_id = 1, | ||
814 | + .minimum_version_id = 1, | ||
815 | + .fields = (VMStateField[]) { | ||
816 | + VMSTATE_UINT32(smir, mv88w8618_eth_state), | ||
817 | + VMSTATE_UINT32(icr, mv88w8618_eth_state), | ||
818 | + VMSTATE_UINT32(imr, mv88w8618_eth_state), | ||
819 | + VMSTATE_UINT32(vlan_header, mv88w8618_eth_state), | ||
820 | + VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2), | ||
821 | + VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4), | ||
822 | + VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4), | ||
823 | + VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4), | ||
824 | + VMSTATE_END_OF_LIST() | ||
825 | + } | ||
826 | +}; | ||
827 | + | ||
828 | +static Property mv88w8618_eth_properties[] = { | ||
829 | + DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf), | ||
830 | + DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr, | ||
831 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
832 | + DEFINE_PROP_END_OF_LIST(), | ||
833 | +}; | ||
834 | + | ||
835 | +static void mv88w8618_eth_class_init(ObjectClass *klass, void *data) | ||
836 | +{ | ||
837 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
838 | + | ||
839 | + dc->vmsd = &mv88w8618_eth_vmsd; | ||
840 | + device_class_set_props(dc, mv88w8618_eth_properties); | ||
841 | + dc->realize = mv88w8618_eth_realize; | ||
842 | +} | ||
843 | + | ||
844 | +static const TypeInfo mv88w8618_eth_info = { | ||
845 | + .name = TYPE_MV88W8618_ETH, | ||
846 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
847 | + .instance_size = sizeof(mv88w8618_eth_state), | ||
848 | + .instance_init = mv88w8618_eth_init, | ||
849 | + .class_init = mv88w8618_eth_class_init, | ||
850 | +}; | ||
851 | + | ||
852 | +static void musicpal_register_types(void) | ||
853 | +{ | ||
854 | + type_register_static(&mv88w8618_eth_info); | ||
855 | +} | ||
856 | + | ||
857 | +type_init(musicpal_register_types) | ||
858 | + | ||
859 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
860 | index XXXXXXX..XXXXXXX 100644 | ||
861 | --- a/MAINTAINERS | ||
862 | +++ b/MAINTAINERS | ||
863 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
864 | L: qemu-arm@nongnu.org | ||
865 | S: Odd Fixes | ||
866 | F: hw/arm/musicpal.c | ||
867 | +F: hw/net/mv88w8618_eth.c | ||
868 | +F: include/hw/net/mv88w8618_eth.h | ||
869 | F: docs/system/arm/musicpal.rst | ||
870 | |||
871 | Nuvoton NPCM7xx | ||
872 | diff --git a/hw/net/meson.build b/hw/net/meson.build | ||
873 | index XXXXXXX..XXXXXXX 100644 | ||
874 | --- a/hw/net/meson.build | ||
875 | +++ b/hw/net/meson.build | ||
876 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ALLWINNER_EMAC', if_true: files('allwinner_emac.c') | ||
877 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_SUN8I_EMAC', if_true: files('allwinner-sun8i-emac.c')) | ||
878 | softmmu_ss.add(when: 'CONFIG_IMX_FEC', if_true: files('imx_fec.c')) | ||
879 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-emac.c')) | ||
880 | +softmmu_ss.add(when: 'CONFIG_MARVELL_88W8618', if_true: files('mv88w8618_eth.c')) | ||
881 | |||
882 | softmmu_ss.add(when: 'CONFIG_CADENCE', if_true: files('cadence_gem.c')) | ||
883 | softmmu_ss.add(when: 'CONFIG_STELLARIS_ENET', if_true: files('stellaris_enet.c')) | ||
884 | -- | 126 | -- |
885 | 2.25.1 | 127 | 2.25.1 |
886 | |||
887 | diff view generated by jsdifflib |
1 | The ITS has several tables which all share a similar format, | 1 | The exynos4210 SoC mostly creates its child devices as if it were |
---|---|---|---|
2 | described by the TableDesc struct: the guest may configure them | 2 | board code. This includes the a9mpcore object. Switch that to a |
3 | to be a single-level table or a two-level table. Currently we | 3 | new-style "embedded in the state struct" creation, because in the |
4 | open-code the process of finding the table entry in all the | 4 | next commit we're going to want to refer to the object again further |
5 | functions which read or write the device table or the collection | 5 | down in the exynos4210_realize() function. |
6 | table. Factor out the "get the address of the table entry" | ||
7 | logic into a new function, so that the code which needs to | ||
8 | read or write a table entry only needs to call table_entry_addr() | ||
9 | and then perform a suitable load or store to that address. | ||
10 | |||
11 | Note that the error handling is slightly complicated because | ||
12 | we want to handle two cases differently: | ||
13 | * failure to read the L1 table entry should end up causing | ||
14 | a command stall, like other kinds of DMA error | ||
15 | * an L1 table entry that says there is no L2 table for this | ||
16 | index (ie whose valid bit is 0) must result in us treating | ||
17 | the table entry as not-valid on read, and discarding | ||
18 | writes (this is mandated by the spec) | ||
19 | 6 | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
22 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Message-id: 20220404154658.565020-4-peter.maydell@linaro.org |
23 | Message-id: 20220111171048.3545974-12-peter.maydell@linaro.org | ||
24 | --- | 10 | --- |
25 | hw/intc/arm_gicv3_its.c | 212 +++++++++++++--------------------------- | 11 | include/hw/arm/exynos4210.h | 2 ++ |
26 | 1 file changed, 70 insertions(+), 142 deletions(-) | 12 | hw/arm/exynos4210.c | 11 ++++++----- |
13 | 2 files changed, 8 insertions(+), 5 deletions(-) | ||
27 | 14 | ||
28 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 15 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
29 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/intc/arm_gicv3_its.c | 17 | --- a/include/hw/arm/exynos4210.h |
31 | +++ b/hw/intc/arm_gicv3_its.c | 18 | +++ b/include/hw/arm/exynos4210.h |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) | 19 | @@ -XXX,XX +XXX,XX @@ |
33 | return result; | 20 | |
34 | } | 21 | #include "hw/or-irq.h" |
35 | 22 | #include "hw/sysbus.h" | |
36 | +static uint64_t table_entry_addr(GICv3ITSState *s, TableDesc *td, | 23 | +#include "hw/cpu/a9mpcore.h" |
37 | + uint32_t idx, MemTxResult *res) | 24 | #include "target/arm/cpu-qom.h" |
38 | +{ | 25 | #include "qom/object.h" |
39 | + /* | 26 | |
40 | + * Given a TableDesc describing one of the ITS in-guest-memory | 27 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { |
41 | + * tables and an index into it, return the guest address | 28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; |
42 | + * corresponding to that table entry. | 29 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; |
43 | + * If there was a memory error reading the L1 table of an | 30 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; |
44 | + * indirect table, *res is set accordingly, and we return -1. | 31 | + A9MPPrivState a9mpcore; |
45 | + * If the L1 table entry is marked not valid, we return -1 with | 32 | }; |
46 | + * *res set to MEMTX_OK. | 33 | |
47 | + * | 34 | #define TYPE_EXYNOS4210_SOC "exynos4210" |
48 | + * The specification defines the format of level 1 entries of a | 35 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
49 | + * 2-level table, but the format of level 2 entries and the format | 36 | index XXXXXXX..XXXXXXX 100644 |
50 | + * of flat-mapped tables is IMPDEF. | 37 | --- a/hw/arm/exynos4210.c |
51 | + */ | 38 | +++ b/hw/arm/exynos4210.c |
52 | + AddressSpace *as = &s->gicv3->dma_as; | 39 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
53 | + uint32_t l2idx; | ||
54 | + uint64_t l2; | ||
55 | + uint32_t num_l2_entries; | ||
56 | + | ||
57 | + *res = MEMTX_OK; | ||
58 | + | ||
59 | + if (!td->indirect) { | ||
60 | + /* Single level table */ | ||
61 | + return td->base_addr + idx * td->entry_sz; | ||
62 | + } | ||
63 | + | ||
64 | + /* Two level table */ | ||
65 | + l2idx = idx / (td->page_sz / L1TABLE_ENTRY_SIZE); | ||
66 | + | ||
67 | + l2 = address_space_ldq_le(as, | ||
68 | + td->base_addr + (l2idx * L1TABLE_ENTRY_SIZE), | ||
69 | + MEMTXATTRS_UNSPECIFIED, res); | ||
70 | + if (*res != MEMTX_OK) { | ||
71 | + return -1; | ||
72 | + } | ||
73 | + if (!(l2 & L2_TABLE_VALID_MASK)) { | ||
74 | + return -1; | ||
75 | + } | ||
76 | + | ||
77 | + num_l2_entries = td->page_sz / td->entry_sz; | ||
78 | + return (l2 & ((1ULL << 51) - 1)) + (idx % num_l2_entries) * td->entry_sz; | ||
79 | +} | ||
80 | + | ||
81 | static bool get_cte(GICv3ITSState *s, uint16_t icid, uint64_t *cte, | ||
82 | MemTxResult *res) | ||
83 | { | ||
84 | AddressSpace *as = &s->gicv3->dma_as; | ||
85 | - uint64_t l2t_addr; | ||
86 | - uint64_t value; | ||
87 | - bool valid_l2t; | ||
88 | - uint32_t l2t_id; | ||
89 | - uint32_t num_l2_entries; | ||
90 | + uint64_t entry_addr = table_entry_addr(s, &s->ct, icid, res); | ||
91 | |||
92 | - if (s->ct.indirect) { | ||
93 | - l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE); | ||
94 | - | ||
95 | - value = address_space_ldq_le(as, | ||
96 | - s->ct.base_addr + | ||
97 | - (l2t_id * L1TABLE_ENTRY_SIZE), | ||
98 | - MEMTXATTRS_UNSPECIFIED, res); | ||
99 | - | ||
100 | - if (*res == MEMTX_OK) { | ||
101 | - valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
102 | - | ||
103 | - if (valid_l2t) { | ||
104 | - num_l2_entries = s->ct.page_sz / s->ct.entry_sz; | ||
105 | - | ||
106 | - l2t_addr = value & ((1ULL << 51) - 1); | ||
107 | - | ||
108 | - *cte = address_space_ldq_le(as, l2t_addr + | ||
109 | - ((icid % num_l2_entries) * GITS_CTE_SIZE), | ||
110 | - MEMTXATTRS_UNSPECIFIED, res); | ||
111 | - } | ||
112 | - } | ||
113 | - } else { | ||
114 | - /* Flat level table */ | ||
115 | - *cte = address_space_ldq_le(as, s->ct.base_addr + | ||
116 | - (icid * GITS_CTE_SIZE), | ||
117 | - MEMTXATTRS_UNSPECIFIED, res); | ||
118 | + if (entry_addr == -1) { | ||
119 | + return false; /* not valid */ | ||
120 | } | 40 | } |
121 | 41 | ||
122 | + *cte = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res); | 42 | /* Private memory region and Internal GIC */ |
123 | return FIELD_EX64(*cte, CTE, VALID); | 43 | - dev = qdev_new(TYPE_A9MPCORE_PRIV); |
124 | } | 44 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); |
125 | 45 | - busdev = SYS_BUS_DEVICE(dev); | |
126 | @@ -XXX,XX +XXX,XX @@ static bool get_ite(GICv3ITSState *s, uint32_t eventid, uint64_t dte, | 46 | - sysbus_realize_and_unref(busdev, &error_fatal); |
127 | static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res) | 47 | + qdev_prop_set_uint32(DEVICE(&s->a9mpcore), "num-cpu", EXYNOS4210_NCPUS); |
128 | { | 48 | + busdev = SYS_BUS_DEVICE(&s->a9mpcore); |
129 | AddressSpace *as = &s->gicv3->dma_as; | 49 | + sysbus_realize(busdev, &error_fatal); |
130 | - uint64_t l2t_addr; | 50 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); |
131 | - uint64_t value; | 51 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { |
132 | - bool valid_l2t; | 52 | sysbus_connect_irq(busdev, n, |
133 | - uint32_t l2t_id; | 53 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); |
134 | - uint32_t num_l2_entries; | ||
135 | + uint64_t entry_addr = table_entry_addr(s, &s->dt, devid, res); | ||
136 | |||
137 | - if (s->dt.indirect) { | ||
138 | - l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE); | ||
139 | - | ||
140 | - value = address_space_ldq_le(as, | ||
141 | - s->dt.base_addr + | ||
142 | - (l2t_id * L1TABLE_ENTRY_SIZE), | ||
143 | - MEMTXATTRS_UNSPECIFIED, res); | ||
144 | - | ||
145 | - if (*res == MEMTX_OK) { | ||
146 | - valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
147 | - | ||
148 | - if (valid_l2t) { | ||
149 | - num_l2_entries = s->dt.page_sz / s->dt.entry_sz; | ||
150 | - | ||
151 | - l2t_addr = value & ((1ULL << 51) - 1); | ||
152 | - | ||
153 | - value = address_space_ldq_le(as, l2t_addr + | ||
154 | - ((devid % num_l2_entries) * GITS_DTE_SIZE), | ||
155 | - MEMTXATTRS_UNSPECIFIED, res); | ||
156 | - } | ||
157 | - } | ||
158 | - } else { | ||
159 | - /* Flat level table */ | ||
160 | - value = address_space_ldq_le(as, s->dt.base_addr + | ||
161 | - (devid * GITS_DTE_SIZE), | ||
162 | - MEMTXATTRS_UNSPECIFIED, res); | ||
163 | + if (entry_addr == -1) { | ||
164 | + return 0; /* a DTE entry with the Valid bit clear */ | ||
165 | } | 54 | } |
166 | - | 55 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { |
167 | - return value; | 56 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); |
168 | + return address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res); | 57 | + s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); |
169 | } | ||
170 | |||
171 | /* | ||
172 | @@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid, | ||
173 | uint64_t rdbase) | ||
174 | { | ||
175 | AddressSpace *as = &s->gicv3->dma_as; | ||
176 | - uint64_t value; | ||
177 | - uint64_t l2t_addr; | ||
178 | - bool valid_l2t; | ||
179 | - uint32_t l2t_id; | ||
180 | - uint32_t num_l2_entries; | ||
181 | + uint64_t entry_addr; | ||
182 | uint64_t cte = 0; | ||
183 | MemTxResult res = MEMTX_OK; | ||
184 | |||
185 | @@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid, | ||
186 | cte = FIELD_DP64(cte, CTE, RDBASE, rdbase); | ||
187 | } | 58 | } |
188 | 59 | ||
189 | - /* | 60 | /* Cache controller */ |
190 | - * The specification defines the format of level 1 entries of a | 61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) |
191 | - * 2-level table, but the format of level 2 entries and the format | 62 | g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i); |
192 | - * of flat-mapped tables is IMPDEF. | 63 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); |
193 | - */ | ||
194 | - if (s->ct.indirect) { | ||
195 | - l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE); | ||
196 | - | ||
197 | - value = address_space_ldq_le(as, | ||
198 | - s->ct.base_addr + | ||
199 | - (l2t_id * L1TABLE_ENTRY_SIZE), | ||
200 | - MEMTXATTRS_UNSPECIFIED, &res); | ||
201 | - | ||
202 | - if (res != MEMTX_OK) { | ||
203 | - return false; | ||
204 | - } | ||
205 | - | ||
206 | - valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
207 | - | ||
208 | - if (valid_l2t) { | ||
209 | - num_l2_entries = s->ct.page_sz / s->ct.entry_sz; | ||
210 | - | ||
211 | - l2t_addr = value & ((1ULL << 51) - 1); | ||
212 | - | ||
213 | - address_space_stq_le(as, l2t_addr + | ||
214 | - ((icid % num_l2_entries) * GITS_CTE_SIZE), | ||
215 | - cte, MEMTXATTRS_UNSPECIFIED, &res); | ||
216 | - } | ||
217 | - } else { | ||
218 | - /* Flat level table */ | ||
219 | - address_space_stq_le(as, s->ct.base_addr + (icid * GITS_CTE_SIZE), | ||
220 | - cte, MEMTXATTRS_UNSPECIFIED, &res); | ||
221 | - } | ||
222 | + entry_addr = table_entry_addr(s, &s->ct, icid, &res); | ||
223 | if (res != MEMTX_OK) { | ||
224 | + /* memory access error: stall */ | ||
225 | return false; | ||
226 | - } else { | ||
227 | + } | ||
228 | + if (entry_addr == -1) { | ||
229 | + /* No L2 table for this index: discard write and continue */ | ||
230 | return true; | ||
231 | } | 64 | } |
232 | + | 65 | + |
233 | + address_space_stq_le(as, entry_addr, cte, MEMTXATTRS_UNSPECIFIED, &res); | 66 | + object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); |
234 | + return res == MEMTX_OK; | ||
235 | } | 67 | } |
236 | 68 | ||
237 | static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset) | 69 | static void exynos4210_class_init(ObjectClass *klass, void *data) |
238 | @@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid, | ||
239 | uint8_t size, uint64_t itt_addr) | ||
240 | { | ||
241 | AddressSpace *as = &s->gicv3->dma_as; | ||
242 | - uint64_t value; | ||
243 | - uint64_t l2t_addr; | ||
244 | - bool valid_l2t; | ||
245 | - uint32_t l2t_id; | ||
246 | - uint32_t num_l2_entries; | ||
247 | + uint64_t entry_addr; | ||
248 | uint64_t dte = 0; | ||
249 | MemTxResult res = MEMTX_OK; | ||
250 | |||
251 | @@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid, | ||
252 | return true; | ||
253 | } | ||
254 | |||
255 | - /* | ||
256 | - * The specification defines the format of level 1 entries of a | ||
257 | - * 2-level table, but the format of level 2 entries and the format | ||
258 | - * of flat-mapped tables is IMPDEF. | ||
259 | - */ | ||
260 | - if (s->dt.indirect) { | ||
261 | - l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE); | ||
262 | - | ||
263 | - value = address_space_ldq_le(as, | ||
264 | - s->dt.base_addr + | ||
265 | - (l2t_id * L1TABLE_ENTRY_SIZE), | ||
266 | - MEMTXATTRS_UNSPECIFIED, &res); | ||
267 | - | ||
268 | - if (res != MEMTX_OK) { | ||
269 | - return false; | ||
270 | - } | ||
271 | - | ||
272 | - valid_l2t = (value & L2_TABLE_VALID_MASK) != 0; | ||
273 | - | ||
274 | - if (valid_l2t) { | ||
275 | - num_l2_entries = s->dt.page_sz / s->dt.entry_sz; | ||
276 | - | ||
277 | - l2t_addr = value & ((1ULL << 51) - 1); | ||
278 | - | ||
279 | - address_space_stq_le(as, l2t_addr + | ||
280 | - ((devid % num_l2_entries) * GITS_DTE_SIZE), | ||
281 | - dte, MEMTXATTRS_UNSPECIFIED, &res); | ||
282 | - } | ||
283 | - } else { | ||
284 | - /* Flat level table */ | ||
285 | - address_space_stq_le(as, s->dt.base_addr + (devid * GITS_DTE_SIZE), | ||
286 | - dte, MEMTXATTRS_UNSPECIFIED, &res); | ||
287 | - } | ||
288 | + entry_addr = table_entry_addr(s, &s->dt, devid, &res); | ||
289 | if (res != MEMTX_OK) { | ||
290 | + /* memory access error: stall */ | ||
291 | return false; | ||
292 | - } else { | ||
293 | + } | ||
294 | + if (entry_addr == -1) { | ||
295 | + /* No L2 table for this index: discard write and continue */ | ||
296 | return true; | ||
297 | } | ||
298 | + address_space_stq_le(as, entry_addr, dte, MEMTXATTRS_UNSPECIFIED, &res); | ||
299 | + return res == MEMTX_OK; | ||
300 | } | ||
301 | |||
302 | static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value, | ||
303 | -- | 70 | -- |
304 | 2.25.1 | 71 | 2.25.1 |
305 | |||
306 | diff view generated by jsdifflib |
1 | In process_its_cmd(), we read an ICID out of the interrupt table | 1 | The only time we use the int_gic_irq[] array in the Exynos4210Irq |
---|---|---|---|
2 | entry, and then use it as an index into the collection table. Add a | 2 | struct is in the exynos4210_realize() function: we initialize it with |
3 | check that it is within range for the collection table first. | 3 | the GPIO inputs of the a9mpcore device, and then a bit later on we |
4 | 4 | connect those to the outputs of the internal combiner. Now that the | |
5 | This check is not strictly necessary, because: | 5 | a9mpcore object is easily accessible as s->a9mpcore we can make the |
6 | * we range check the ICID from the guest before writing it into | 6 | connection directly from one device to the other without going via |
7 | the interrupt table entry, so the the only way to get an | 7 | this array. |
8 | out of range ICID in process_its_cmd() is if a badly-behaved | ||
9 | guest is writing directly to the interrupt table memory | ||
10 | * the collection table is in guest memory, so QEMU won't fall | ||
11 | over if we read off the end of it | ||
12 | |||
13 | However, it seems clearer to include the check. | ||
14 | 8 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20220111171048.3545974-14-peter.maydell@linaro.org | 11 | Message-id: 20220404154658.565020-5-peter.maydell@linaro.org |
18 | --- | 12 | --- |
19 | hw/intc/arm_gicv3_its.c | 7 +++++++ | 13 | include/hw/arm/exynos4210.h | 1 - |
20 | 1 file changed, 7 insertions(+) | 14 | hw/arm/exynos4210.c | 6 ++---- |
15 | 2 files changed, 2 insertions(+), 5 deletions(-) | ||
21 | 16 | ||
22 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
23 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/intc/arm_gicv3_its.c | 19 | --- a/include/hw/arm/exynos4210.h |
25 | +++ b/hw/intc/arm_gicv3_its.c | 20 | +++ b/include/hw/arm/exynos4210.h |
26 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 21 | @@ -XXX,XX +XXX,XX @@ |
27 | return CMD_CONTINUE; | 22 | typedef struct Exynos4210Irq { |
23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
25 | - qemu_irq int_gic_irq[EXYNOS4210_INT_GIC_NIRQ]; | ||
26 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | ||
27 | qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
28 | } Exynos4210Irq; | ||
29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/exynos4210.c | ||
32 | +++ b/hw/arm/exynos4210.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
34 | sysbus_connect_irq(busdev, n, | ||
35 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
28 | } | 36 | } |
29 | 37 | - for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | |
30 | + if (icid >= s->ct.num_ids) { | 38 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); |
31 | + qemu_log_mask(LOG_GUEST_ERROR, | 39 | - } |
32 | + "%s: invalid ICID 0x%x in ITE (table corrupted?)\n", | 40 | |
33 | + __func__, icid); | 41 | /* Cache controller */ |
34 | + return CMD_CONTINUE; | 42 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); |
35 | + } | 43 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
36 | + | 44 | busdev = SYS_BUS_DEVICE(dev); |
37 | cte_valid = get_cte(s, icid, &cte, &res); | 45 | sysbus_realize_and_unref(busdev, &error_fatal); |
38 | if (res != MEMTX_OK) { | 46 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { |
39 | return CMD_STALL; | 47 | - sysbus_connect_irq(busdev, n, s->irqs.int_gic_irq[n]); |
48 | + sysbus_connect_irq(busdev, n, | ||
49 | + qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
50 | } | ||
51 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); | ||
52 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
40 | -- | 53 | -- |
41 | 2.25.1 | 54 | 2.25.1 |
42 | |||
43 | diff view generated by jsdifflib |
1 | In a few places in the ITS command handling functions, we were | 1 | The exynos4210 code currently has two very similar arrays of IRQs: |
---|---|---|---|
2 | doing the range-check of an event ID or device ID only after using | ||
3 | it as a table index; move the checks to before the uses. | ||
4 | 2 | ||
5 | This misordering wouldn't have very bad effects because the | 3 | * board_irqs is a field of the Exynos4210Irq struct which is filled |
6 | tables are in guest memory anyway. | 4 | in by exynos4210_init_board_irqs() with the appropriate qemu_irqs |
5 | for each IRQ the board/SoC can assert | ||
6 | * irq_table is a set of qemu_irqs pointed to from the | ||
7 | Exynos4210State struct. It's allocated in exynos4210_init_irq, | ||
8 | and the only behaviour these irqs have is that they pass on the | ||
9 | level to the equivalent board_irqs[] irq | ||
10 | |||
11 | The extra indirection through irq_table is unnecessary, so coalesce | ||
12 | these into a single irq_table[] array as a direct field in | ||
13 | Exynos4210State which exynos4210_init_board_irqs() fills in. | ||
7 | 14 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20220111171048.3545974-13-peter.maydell@linaro.org | 17 | Message-id: 20220404154658.565020-6-peter.maydell@linaro.org |
11 | --- | 18 | --- |
12 | hw/intc/arm_gicv3_its.c | 42 ++++++++++++++++++++++++----------------- | 19 | include/hw/arm/exynos4210.h | 8 ++------ |
13 | 1 file changed, 25 insertions(+), 17 deletions(-) | 20 | hw/arm/exynos4210.c | 6 +----- |
21 | hw/intc/exynos4210_gic.c | 32 ++++++++------------------------ | ||
22 | 3 files changed, 11 insertions(+), 35 deletions(-) | ||
14 | 23 | ||
15 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 24 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
16 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/intc/arm_gicv3_its.c | 26 | --- a/include/hw/arm/exynos4210.h |
18 | +++ b/hw/intc/arm_gicv3_its.c | 27 | +++ b/include/hw/arm/exynos4210.h |
19 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210Irq { |
20 | 29 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | |
21 | eventid = (value & EVENTID_MASK); | 30 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; |
22 | 31 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | |
23 | + if (devid >= s->dt.num_ids) { | 32 | - qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
24 | + qemu_log_mask(LOG_GUEST_ERROR, | 33 | } Exynos4210Irq; |
25 | + "%s: invalid command attributes: devid %d>=%d", | 34 | |
26 | + __func__, devid, s->dt.num_ids); | 35 | struct Exynos4210State { |
27 | + return CMD_CONTINUE; | 36 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { |
28 | + } | 37 | /*< public >*/ |
29 | + | 38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; |
30 | dte = get_dte(s, devid, &res); | 39 | Exynos4210Irq irqs; |
31 | 40 | - qemu_irq *irq_table; | |
32 | if (res != MEMTX_OK) { | 41 | + qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
33 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 42 | |
34 | 43 | MemoryRegion chipid_mem; | |
35 | num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 44 | MemoryRegion iram_mem; |
36 | 45 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | |
37 | + if (eventid >= num_eventids) { | 46 | void exynos4210_write_secondary(ARMCPU *cpu, |
38 | + qemu_log_mask(LOG_GUEST_ERROR, | 47 | const struct arm_boot_info *info); |
39 | + "%s: invalid command attributes: eventid %d >= %" | 48 | |
40 | + PRId64 "\n", | 49 | -/* Initialize exynos4210 IRQ subsystem stub */ |
41 | + __func__, eventid, num_eventids); | 50 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); |
42 | + return CMD_CONTINUE; | 51 | - |
43 | + } | 52 | /* Initialize board IRQs. |
44 | + | 53 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ |
45 | ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res); | 54 | -void exynos4210_init_board_irqs(Exynos4210Irq *s); |
46 | if (res != MEMTX_OK) { | 55 | +void exynos4210_init_board_irqs(Exynos4210State *s); |
47 | return CMD_STALL; | 56 | |
48 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 57 | /* Get IRQ number from exynos4210 IRQ subsystem stub. |
49 | return CMD_CONTINUE; | 58 | * To identify IRQ source use internal combiner group and bit number |
59 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/hw/arm/exynos4210.c | ||
62 | +++ b/hw/arm/exynos4210.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
64 | qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); | ||
50 | } | 65 | } |
51 | 66 | ||
52 | - if (devid >= s->dt.num_ids) { | 67 | - /*** IRQs ***/ |
53 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
54 | - "%s: invalid command attributes: devid %d>=%d", | ||
55 | - __func__, devid, s->dt.num_ids); | ||
56 | - return CMD_CONTINUE; | ||
57 | - } | ||
58 | - if (eventid >= num_eventids) { | ||
59 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
60 | - "%s: invalid command attributes: eventid %d >= %" | ||
61 | - PRId64 "\n", | ||
62 | - __func__, eventid, num_eventids); | ||
63 | - return CMD_CONTINUE; | ||
64 | - } | ||
65 | - | 68 | - |
66 | /* | 69 | - s->irq_table = exynos4210_init_irq(&s->irqs); |
67 | * Current implementation only supports rdbase == procnum | 70 | - |
68 | * Hence rdbase physical address is ignored | 71 | /* IRQ Gate */ |
69 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 72 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { |
70 | 73 | DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); | |
71 | icid = value & ICID_MASK; | 74 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
72 | 75 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | |
73 | + if (devid >= s->dt.num_ids) { | 76 | |
74 | + qemu_log_mask(LOG_GUEST_ERROR, | 77 | /* Initialize board IRQs. */ |
75 | + "%s: invalid command attributes: devid %d>=%d", | 78 | - exynos4210_init_board_irqs(&s->irqs); |
76 | + __func__, devid, s->dt.num_ids); | 79 | + exynos4210_init_board_irqs(s); |
77 | + return CMD_CONTINUE; | 80 | |
78 | + } | 81 | /*** Memory ***/ |
79 | + | 82 | |
80 | dte = get_dte(s, devid, &res); | 83 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c |
81 | 84 | index XXXXXXX..XXXXXXX 100644 | |
82 | if (res != MEMTX_OK) { | 85 | --- a/hw/intc/exynos4210_gic.c |
83 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 86 | +++ b/hw/intc/exynos4210_gic.c |
84 | num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 87 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { |
85 | num_intids = 1ULL << (GICD_TYPER_IDBITS + 1); | 88 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 |
86 | 89 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | |
87 | - if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids) | 90 | |
88 | + if ((icid >= s->ct.num_ids) | 91 | -static void exynos4210_irq_handler(void *opaque, int irq, int level) |
89 | || !dte_valid || (eventid >= num_eventids) || | 92 | -{ |
90 | (((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) && | 93 | - Exynos4210Irq *s = (Exynos4210Irq *)opaque; |
91 | (pIntid != INTID_SPURIOUS))) { | 94 | - |
92 | qemu_log_mask(LOG_GUEST_ERROR, | 95 | - /* Bypass */ |
93 | "%s: invalid command attributes " | 96 | - qemu_set_irq(s->board_irqs[irq], level); |
94 | - "devid %d or icid %d or eventid %d or pIntid %d or" | 97 | -} |
95 | - "unmapped dte %d\n", __func__, devid, icid, eventid, | 98 | - |
96 | + "icid %d or eventid %d or pIntid %d or" | 99 | -/* |
97 | + "unmapped dte %d\n", __func__, icid, eventid, | 100 | - * Initialize exynos4210 IRQ subsystem stub. |
98 | pIntid, dte_valid); | 101 | - */ |
99 | /* | 102 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *s) |
100 | * in this implementation, in case of error | 103 | -{ |
104 | - return qemu_allocate_irqs(exynos4210_irq_handler, s, | ||
105 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ); | ||
106 | -} | ||
107 | - | ||
108 | /* | ||
109 | * Initialize board IRQs. | ||
110 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
111 | */ | ||
112 | -void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
113 | +void exynos4210_init_board_irqs(Exynos4210State *s) | ||
114 | { | ||
115 | uint32_t grp, bit, irq_id, n; | ||
116 | + Exynos4210Irq *is = &s->irqs; | ||
117 | |||
118 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
119 | irq_id = 0; | ||
120 | @@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
121 | irq_id = EXT_GIC_ID_MCT_G1; | ||
122 | } | ||
123 | if (irq_id) { | ||
124 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
125 | - s->ext_gic_irq[irq_id-32]); | ||
126 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
127 | + is->ext_gic_irq[irq_id - 32]); | ||
128 | } else { | ||
129 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
130 | - s->ext_combiner_irq[n]); | ||
131 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
132 | + is->ext_combiner_irq[n]); | ||
133 | } | ||
134 | } | ||
135 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
136 | @@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
137 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
138 | |||
139 | if (irq_id) { | ||
140 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
141 | - s->ext_gic_irq[irq_id-32]); | ||
142 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
143 | + is->ext_gic_irq[irq_id - 32]); | ||
144 | } | ||
145 | } | ||
146 | } | ||
101 | -- | 147 | -- |
102 | 2.25.1 | 148 | 2.25.1 |
103 | |||
104 | diff view generated by jsdifflib |
1 | Fix process_its_cmd() to consistently return CMD_STALL for | 1 | Fix a missing set of spaces around '-' in the definition of |
---|---|---|---|
2 | memory errors and CMD_CONTINUE for parameter errors, as | 2 | combiner_grp_to_gic_id[]. We're about to move this code, so |
3 | we claim in the comments that we do. | 3 | fix the style issue first to keep checkpatch happy with the |
4 | code-motion patch. | ||
4 | 5 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220111171048.3545974-7-peter.maydell@linaro.org | 8 | Message-id: 20220404154658.565020-7-peter.maydell@linaro.org |
9 | --- | 9 | --- |
10 | hw/intc/arm_gicv3_its.c | 22 +++++++++++----------- | 10 | hw/intc/exynos4210_gic.c | 2 +- |
11 | 1 file changed, 11 insertions(+), 11 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 12 | ||
13 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 13 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/arm_gicv3_its.c | 15 | --- a/hw/intc/exynos4210_gic.c |
16 | +++ b/hw/intc/arm_gicv3_its.c | 16 | +++ b/hw/intc/exynos4210_gic.c |
17 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 17 | @@ -XXX,XX +XXX,XX @@ enum ExtInt { |
18 | bool ite_valid = false; | 18 | */ |
19 | uint64_t cte = 0; | 19 | |
20 | bool cte_valid = false; | 20 | static const uint32_t |
21 | - ItsCmdResult result = CMD_STALL; | 21 | -combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { |
22 | uint64_t rdbase; | 22 | +combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { |
23 | 23 | /* int combiner groups 16-19 */ | |
24 | if (cmd == NONE) { | 24 | { }, { }, { }, { }, |
25 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 25 | /* int combiner group 20 */ |
26 | } | ||
27 | |||
28 | if (res != MEMTX_OK) { | ||
29 | - return result; | ||
30 | + return CMD_STALL; | ||
31 | } | ||
32 | |||
33 | eventid = (value & EVENTID_MASK); | ||
34 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | ||
35 | dte = get_dte(s, devid, &res); | ||
36 | |||
37 | if (res != MEMTX_OK) { | ||
38 | - return result; | ||
39 | + return CMD_STALL; | ||
40 | } | ||
41 | dte_valid = FIELD_EX64(dte, DTE, VALID); | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | ||
44 | ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res); | ||
45 | |||
46 | if (res != MEMTX_OK) { | ||
47 | - return result; | ||
48 | + return CMD_STALL; | ||
49 | } | ||
50 | |||
51 | if (ite_valid) { | ||
52 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | ||
53 | } | ||
54 | |||
55 | if (res != MEMTX_OK) { | ||
56 | - return result; | ||
57 | + return CMD_STALL; | ||
58 | } | ||
59 | } else { | ||
60 | qemu_log_mask(LOG_GUEST_ERROR, | ||
61 | "%s: invalid command attributes: " | ||
62 | "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n", | ||
63 | __func__, dte, devid, res); | ||
64 | - return result; | ||
65 | + return CMD_CONTINUE; | ||
66 | } | ||
67 | |||
68 | |||
69 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | ||
70 | qemu_log_mask(LOG_GUEST_ERROR, | ||
71 | "%s: invalid command attributes: devid %d>=%d", | ||
72 | __func__, devid, s->dt.num_ids); | ||
73 | - | ||
74 | + return CMD_CONTINUE; | ||
75 | } else if (!dte_valid || !ite_valid || !cte_valid) { | ||
76 | qemu_log_mask(LOG_GUEST_ERROR, | ||
77 | "%s: invalid command attributes: " | ||
78 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | ||
79 | dte_valid ? "valid" : "invalid", | ||
80 | ite_valid ? "valid" : "invalid", | ||
81 | cte_valid ? "valid" : "invalid"); | ||
82 | + return CMD_CONTINUE; | ||
83 | } else if (eventid >= num_eventids) { | ||
84 | qemu_log_mask(LOG_GUEST_ERROR, | ||
85 | "%s: invalid command attributes: eventid %d >= %" | ||
86 | PRId64 "\n", | ||
87 | __func__, eventid, num_eventids); | ||
88 | + return CMD_CONTINUE; | ||
89 | } else { | ||
90 | /* | ||
91 | * Current implementation only supports rdbase == procnum | ||
92 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | ||
93 | rdbase = FIELD_EX64(cte, CTE, RDBASE); | ||
94 | |||
95 | if (rdbase >= s->gicv3->num_cpu) { | ||
96 | - return result; | ||
97 | + return CMD_CONTINUE; | ||
98 | } | ||
99 | |||
100 | if ((cmd == CLEAR) || (cmd == DISCARD)) { | ||
101 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | ||
102 | if (cmd == DISCARD) { | ||
103 | IteEntry ite = {}; | ||
104 | /* remove mapping from interrupt translation table */ | ||
105 | - result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | ||
106 | + return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | ||
107 | } | ||
108 | + return CMD_CONTINUE; | ||
109 | } | ||
110 | - | ||
111 | - return result; | ||
112 | } | ||
113 | |||
114 | static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | ||
115 | -- | 26 | -- |
116 | 2.25.1 | 27 | 2.25.1 |
117 | |||
118 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | The function exynos4210_init_board_irqs() currently lives in |
---|---|---|---|
2 | exynos4210_gic.c, but it isn't really part of the exynos4210.gic | ||
3 | device -- it is a function that implements (some of) the wiring up of | ||
4 | interrupts between the SoC's GIC and combiner components. This means | ||
5 | it fits better in exynos4210.c, which is the SoC-level code. Move it | ||
6 | there. Similarly, exynos4210_git_irq() is used almost only in the | ||
7 | SoC-level code, so move it too. | ||
2 | 8 | ||
3 | This supports virtio-mem-pci device on "virt" platform, by simply | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | following the implementation on x86. | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20220404154658.565020-8-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 4 - | ||
14 | hw/arm/exynos4210.c | 202 +++++++++++++++++++++++++++++++++++ | ||
15 | hw/intc/exynos4210_gic.c | 204 ------------------------------------ | ||
16 | 3 files changed, 202 insertions(+), 208 deletions(-) | ||
5 | 17 | ||
6 | * This implements the hotplug handlers to support virtio-mem-pci | 18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
7 | device hot-add, while the hot-remove isn't supported as we have | ||
8 | on x86. | ||
9 | |||
10 | * The block size is 512MB on ARM64 instead of 128MB on x86. | ||
11 | |||
12 | * It has been passing the tests with various combinations like 64KB | ||
13 | and 4KB page sizes on host and guest, different memory device | ||
14 | backends like normal, transparent huge page and HugeTLB, plus | ||
15 | migration. | ||
16 | |||
17 | Co-developed-by: David Hildenbrand <david@redhat.com> | ||
18 | Co-developed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> | ||
19 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
20 | Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com> | ||
21 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
22 | Message-id: 20220111063329.74447-3-gshan@redhat.com | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | --- | ||
25 | hw/arm/virt.c | 70 ++++++++++++++++++++++++++++++++++++++++++ | ||
26 | hw/virtio/virtio-mem.c | 4 ++- | ||
27 | hw/arm/Kconfig | 1 + | ||
28 | 3 files changed, 74 insertions(+), 1 deletion(-) | ||
29 | |||
30 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/arm/virt.c | 20 | --- a/include/hw/arm/exynos4210.h |
33 | +++ b/hw/arm/virt.c | 21 | +++ b/include/hw/arm/exynos4210.h |
22 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | ||
23 | void exynos4210_write_secondary(ARMCPU *cpu, | ||
24 | const struct arm_boot_info *info); | ||
25 | |||
26 | -/* Initialize board IRQs. | ||
27 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ | ||
28 | -void exynos4210_init_board_irqs(Exynos4210State *s); | ||
29 | - | ||
30 | /* Get IRQ number from exynos4210 IRQ subsystem stub. | ||
31 | * To identify IRQ source use internal combiner group and bit number | ||
32 | * grp - group number | ||
33 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/hw/arm/exynos4210.c | ||
36 | +++ b/hw/arm/exynos4210.c | ||
34 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ |
35 | #include "hw/arm/smmuv3.h" | 38 | #define EXYNOS4210_PL330_BASE1_ADDR 0x12690000 |
36 | #include "hw/acpi/acpi.h" | 39 | #define EXYNOS4210_PL330_BASE2_ADDR 0x12850000 |
37 | #include "target/arm/internals.h" | 40 | |
38 | +#include "hw/mem/memory-device.h" | 41 | +enum ExtGicId { |
39 | #include "hw/mem/pc-dimm.h" | 42 | + EXT_GIC_ID_MDMA_LCD0 = 66, |
40 | #include "hw/mem/nvdimm.h" | 43 | + EXT_GIC_ID_PDMA0, |
41 | #include "hw/acpi/generic_event_device.h" | 44 | + EXT_GIC_ID_PDMA1, |
42 | +#include "hw/virtio/virtio-mem-pci.h" | 45 | + EXT_GIC_ID_TIMER0, |
43 | #include "hw/virtio/virtio-iommu.h" | 46 | + EXT_GIC_ID_TIMER1, |
44 | #include "hw/char/pl011.h" | 47 | + EXT_GIC_ID_TIMER2, |
45 | #include "qemu/guest-random.h" | 48 | + EXT_GIC_ID_TIMER3, |
46 | @@ -XXX,XX +XXX,XX @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, | 49 | + EXT_GIC_ID_TIMER4, |
47 | dev, &error_abort); | 50 | + EXT_GIC_ID_MCT_L0, |
48 | } | 51 | + EXT_GIC_ID_WDT, |
49 | 52 | + EXT_GIC_ID_RTC_ALARM, | |
50 | +static void virt_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev, | 53 | + EXT_GIC_ID_RTC_TIC, |
51 | + DeviceState *dev, Error **errp) | 54 | + EXT_GIC_ID_GPIO_XB, |
55 | + EXT_GIC_ID_GPIO_XA, | ||
56 | + EXT_GIC_ID_MCT_L1, | ||
57 | + EXT_GIC_ID_IEM_APC, | ||
58 | + EXT_GIC_ID_IEM_IEC, | ||
59 | + EXT_GIC_ID_NFC, | ||
60 | + EXT_GIC_ID_UART0, | ||
61 | + EXT_GIC_ID_UART1, | ||
62 | + EXT_GIC_ID_UART2, | ||
63 | + EXT_GIC_ID_UART3, | ||
64 | + EXT_GIC_ID_UART4, | ||
65 | + EXT_GIC_ID_MCT_G0, | ||
66 | + EXT_GIC_ID_I2C0, | ||
67 | + EXT_GIC_ID_I2C1, | ||
68 | + EXT_GIC_ID_I2C2, | ||
69 | + EXT_GIC_ID_I2C3, | ||
70 | + EXT_GIC_ID_I2C4, | ||
71 | + EXT_GIC_ID_I2C5, | ||
72 | + EXT_GIC_ID_I2C6, | ||
73 | + EXT_GIC_ID_I2C7, | ||
74 | + EXT_GIC_ID_SPI0, | ||
75 | + EXT_GIC_ID_SPI1, | ||
76 | + EXT_GIC_ID_SPI2, | ||
77 | + EXT_GIC_ID_MCT_G1, | ||
78 | + EXT_GIC_ID_USB_HOST, | ||
79 | + EXT_GIC_ID_USB_DEVICE, | ||
80 | + EXT_GIC_ID_MODEMIF, | ||
81 | + EXT_GIC_ID_HSMMC0, | ||
82 | + EXT_GIC_ID_HSMMC1, | ||
83 | + EXT_GIC_ID_HSMMC2, | ||
84 | + EXT_GIC_ID_HSMMC3, | ||
85 | + EXT_GIC_ID_SDMMC, | ||
86 | + EXT_GIC_ID_MIPI_CSI_4LANE, | ||
87 | + EXT_GIC_ID_MIPI_DSI_4LANE, | ||
88 | + EXT_GIC_ID_MIPI_CSI_2LANE, | ||
89 | + EXT_GIC_ID_MIPI_DSI_2LANE, | ||
90 | + EXT_GIC_ID_ONENAND_AUDI, | ||
91 | + EXT_GIC_ID_ROTATOR, | ||
92 | + EXT_GIC_ID_FIMC0, | ||
93 | + EXT_GIC_ID_FIMC1, | ||
94 | + EXT_GIC_ID_FIMC2, | ||
95 | + EXT_GIC_ID_FIMC3, | ||
96 | + EXT_GIC_ID_JPEG, | ||
97 | + EXT_GIC_ID_2D, | ||
98 | + EXT_GIC_ID_PCIe, | ||
99 | + EXT_GIC_ID_MIXER, | ||
100 | + EXT_GIC_ID_HDMI, | ||
101 | + EXT_GIC_ID_HDMI_I2C, | ||
102 | + EXT_GIC_ID_MFC, | ||
103 | + EXT_GIC_ID_TVENC, | ||
104 | +}; | ||
105 | + | ||
106 | +enum ExtInt { | ||
107 | + EXT_GIC_ID_EXTINT0 = 48, | ||
108 | + EXT_GIC_ID_EXTINT1, | ||
109 | + EXT_GIC_ID_EXTINT2, | ||
110 | + EXT_GIC_ID_EXTINT3, | ||
111 | + EXT_GIC_ID_EXTINT4, | ||
112 | + EXT_GIC_ID_EXTINT5, | ||
113 | + EXT_GIC_ID_EXTINT6, | ||
114 | + EXT_GIC_ID_EXTINT7, | ||
115 | + EXT_GIC_ID_EXTINT8, | ||
116 | + EXT_GIC_ID_EXTINT9, | ||
117 | + EXT_GIC_ID_EXTINT10, | ||
118 | + EXT_GIC_ID_EXTINT11, | ||
119 | + EXT_GIC_ID_EXTINT12, | ||
120 | + EXT_GIC_ID_EXTINT13, | ||
121 | + EXT_GIC_ID_EXTINT14, | ||
122 | + EXT_GIC_ID_EXTINT15 | ||
123 | +}; | ||
124 | + | ||
125 | +/* | ||
126 | + * External GIC sources which are not from External Interrupt Combiner or | ||
127 | + * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ, | ||
128 | + * which is INTG16 in Internal Interrupt Combiner. | ||
129 | + */ | ||
130 | + | ||
131 | +static const uint32_t | ||
132 | +combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
133 | + /* int combiner groups 16-19 */ | ||
134 | + { }, { }, { }, { }, | ||
135 | + /* int combiner group 20 */ | ||
136 | + { 0, EXT_GIC_ID_MDMA_LCD0 }, | ||
137 | + /* int combiner group 21 */ | ||
138 | + { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 }, | ||
139 | + /* int combiner group 22 */ | ||
140 | + { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2, | ||
141 | + EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 }, | ||
142 | + /* int combiner group 23 */ | ||
143 | + { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC }, | ||
144 | + /* int combiner group 24 */ | ||
145 | + { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA }, | ||
146 | + /* int combiner group 25 */ | ||
147 | + { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC }, | ||
148 | + /* int combiner group 26 */ | ||
149 | + { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3, | ||
150 | + EXT_GIC_ID_UART4 }, | ||
151 | + /* int combiner group 27 */ | ||
152 | + { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3, | ||
153 | + EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6, | ||
154 | + EXT_GIC_ID_I2C7 }, | ||
155 | + /* int combiner group 28 */ | ||
156 | + { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST}, | ||
157 | + /* int combiner group 29 */ | ||
158 | + { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2, | ||
159 | + EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC }, | ||
160 | + /* int combiner group 30 */ | ||
161 | + { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE }, | ||
162 | + /* int combiner group 31 */ | ||
163 | + { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE }, | ||
164 | + /* int combiner group 32 */ | ||
165 | + { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 }, | ||
166 | + /* int combiner group 33 */ | ||
167 | + { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 }, | ||
168 | + /* int combiner group 34 */ | ||
169 | + { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
170 | + /* int combiner group 35 */ | ||
171 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
172 | + /* int combiner group 36 */ | ||
173 | + { EXT_GIC_ID_MIXER }, | ||
174 | + /* int combiner group 37 */ | ||
175 | + { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6, | ||
176 | + EXT_GIC_ID_EXTINT7 }, | ||
177 | + /* groups 38-50 */ | ||
178 | + { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
179 | + /* int combiner group 51 */ | ||
180 | + { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
181 | + /* group 52 */ | ||
182 | + { }, | ||
183 | + /* int combiner group 53 */ | ||
184 | + { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
185 | + /* groups 54-63 */ | ||
186 | + { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
187 | +}; | ||
188 | + | ||
189 | +/* | ||
190 | + * Initialize board IRQs. | ||
191 | + * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
192 | + */ | ||
193 | +static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
52 | +{ | 194 | +{ |
53 | + HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev); | 195 | + uint32_t grp, bit, irq_id, n; |
54 | + Error *local_err = NULL; | 196 | + Exynos4210Irq *is = &s->irqs; |
55 | + | 197 | + |
56 | + if (!hotplug_dev2 && dev->hotplugged) { | 198 | + for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { |
57 | + /* | 199 | + irq_id = 0; |
58 | + * Without a bus hotplug handler, we cannot control the plug/unplug | 200 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || |
59 | + * order. We should never reach this point when hotplugging on ARM. | 201 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { |
60 | + * However, it's nice to add a safety net, similar to what we have | 202 | + /* MCT_G0 is passed to External GIC */ |
61 | + * on x86. | 203 | + irq_id = EXT_GIC_ID_MCT_G0; |
62 | + */ | 204 | + } |
63 | + error_setg(errp, "hotplug of virtio based memory devices not supported" | 205 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || |
64 | + " on this bus."); | 206 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { |
65 | + return; | 207 | + /* MCT_G1 is passed to External and GIC */ |
66 | + } | 208 | + irq_id = EXT_GIC_ID_MCT_G1; |
67 | + /* | 209 | + } |
68 | + * First, see if we can plug this memory device at all. If that | 210 | + if (irq_id) { |
69 | + * succeeds, branch of to the actual hotplug handler. | 211 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
70 | + */ | 212 | + is->ext_gic_irq[irq_id - 32]); |
71 | + memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL, | 213 | + } else { |
72 | + &local_err); | 214 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
73 | + if (!local_err && hotplug_dev2) { | 215 | + is->ext_combiner_irq[n]); |
74 | + hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err); | ||
75 | + } | ||
76 | + error_propagate(errp, local_err); | ||
77 | +} | ||
78 | + | ||
79 | +static void virt_virtio_md_pci_plug(HotplugHandler *hotplug_dev, | ||
80 | + DeviceState *dev, Error **errp) | ||
81 | +{ | ||
82 | + HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev); | ||
83 | + Error *local_err = NULL; | ||
84 | + | ||
85 | + /* | ||
86 | + * Plug the memory device first and then branch off to the actual | ||
87 | + * hotplug handler. If that one fails, we can easily undo the memory | ||
88 | + * device bits. | ||
89 | + */ | ||
90 | + memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); | ||
91 | + if (hotplug_dev2) { | ||
92 | + hotplug_handler_plug(hotplug_dev2, dev, &local_err); | ||
93 | + if (local_err) { | ||
94 | + memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev)); | ||
95 | + } | 216 | + } |
96 | + } | 217 | + } |
97 | + error_propagate(errp, local_err); | 218 | + for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { |
219 | + /* these IDs are passed to Internal Combiner and External GIC */ | ||
220 | + grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); | ||
221 | + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
222 | + irq_id = combiner_grp_to_gic_id[grp - | ||
223 | + EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
224 | + | ||
225 | + if (irq_id) { | ||
226 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
227 | + is->ext_gic_irq[irq_id - 32]); | ||
228 | + } | ||
229 | + } | ||
98 | +} | 230 | +} |
99 | + | 231 | + |
100 | +static void virt_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev, | 232 | +/* |
101 | + DeviceState *dev, Error **errp) | 233 | + * Get IRQ number from exynos4210 IRQ subsystem stub. |
234 | + * To identify IRQ source use internal combiner group and bit number | ||
235 | + * grp - group number | ||
236 | + * bit - bit number inside group | ||
237 | + */ | ||
238 | +uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
102 | +{ | 239 | +{ |
103 | + /* We don't support hot unplug of virtio based memory devices */ | 240 | + return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); |
104 | + error_setg(errp, "virtio based memory devices cannot be unplugged."); | ||
105 | +} | 241 | +} |
106 | + | 242 | + |
107 | + | 243 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, |
108 | static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, | 244 | 0x09, 0x00, 0x00, 0x00 }; |
109 | DeviceState *dev, Error **errp) | 245 | |
110 | { | 246 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c |
111 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, | ||
112 | |||
113 | if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { | ||
114 | virt_memory_pre_plug(hotplug_dev, dev, errp); | ||
115 | + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { | ||
116 | + virt_virtio_md_pci_pre_plug(hotplug_dev, dev, errp); | ||
117 | } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { | ||
118 | hwaddr db_start = 0, db_end = 0; | ||
119 | char *resv_prop_str; | ||
120 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, | ||
121 | if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { | ||
122 | virt_memory_plug(hotplug_dev, dev, errp); | ||
123 | } | ||
124 | + | ||
125 | + if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { | ||
126 | + virt_virtio_md_pci_plug(hotplug_dev, dev, errp); | ||
127 | + } | ||
128 | + | ||
129 | if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { | ||
130 | PCIDevice *pdev = PCI_DEVICE(dev); | ||
131 | |||
132 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, | ||
133 | { | ||
134 | if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { | ||
135 | virt_dimm_unplug_request(hotplug_dev, dev, errp); | ||
136 | + } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) { | ||
137 | + virt_virtio_md_pci_unplug_request(hotplug_dev, dev, errp); | ||
138 | } else { | ||
139 | error_setg(errp, "device unplug request for unsupported device" | ||
140 | " type: %s", object_get_typename(OBJECT(dev))); | ||
141 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | ||
142 | |||
143 | if (device_is_dynamic_sysbus(mc, dev) || | ||
144 | object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || | ||
145 | + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) || | ||
146 | object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { | ||
147 | return HOTPLUG_HANDLER(machine); | ||
148 | } | ||
149 | diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | 247 | index XXXXXXX..XXXXXXX 100644 |
151 | --- a/hw/virtio/virtio-mem.c | 248 | --- a/hw/intc/exynos4210_gic.c |
152 | +++ b/hw/virtio/virtio-mem.c | 249 | +++ b/hw/intc/exynos4210_gic.c |
153 | @@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) | 250 | @@ -XXX,XX +XXX,XX @@ |
154 | * The memory block size corresponds mostly to the section size. | 251 | #include "hw/arm/exynos4210.h" |
155 | * | 252 | #include "qom/object.h" |
156 | * This allows e.g., to add 20MB with a section size of 128MB on x86_64, and | 253 | |
157 | - * a section size of 1GB on arm64 (as long as the start address is properly | 254 | -enum ExtGicId { |
158 | + * a section size of 512MB on arm64 (as long as the start address is properly | 255 | - EXT_GIC_ID_MDMA_LCD0 = 66, |
159 | * aligned, similar to ordinary DIMMs). | 256 | - EXT_GIC_ID_PDMA0, |
160 | * | 257 | - EXT_GIC_ID_PDMA1, |
161 | * We can change this at any time and maybe even make it configurable if | 258 | - EXT_GIC_ID_TIMER0, |
162 | @@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb) | 259 | - EXT_GIC_ID_TIMER1, |
163 | */ | 260 | - EXT_GIC_ID_TIMER2, |
164 | #if defined(TARGET_X86_64) || defined(TARGET_I386) | 261 | - EXT_GIC_ID_TIMER3, |
165 | #define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB)) | 262 | - EXT_GIC_ID_TIMER4, |
166 | +#elif defined(TARGET_ARM) | 263 | - EXT_GIC_ID_MCT_L0, |
167 | +#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB)) | 264 | - EXT_GIC_ID_WDT, |
168 | #else | 265 | - EXT_GIC_ID_RTC_ALARM, |
169 | #error VIRTIO_MEM_USABLE_EXTENT not defined | 266 | - EXT_GIC_ID_RTC_TIC, |
170 | #endif | 267 | - EXT_GIC_ID_GPIO_XB, |
171 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 268 | - EXT_GIC_ID_GPIO_XA, |
172 | index XXXXXXX..XXXXXXX 100644 | 269 | - EXT_GIC_ID_MCT_L1, |
173 | --- a/hw/arm/Kconfig | 270 | - EXT_GIC_ID_IEM_APC, |
174 | +++ b/hw/arm/Kconfig | 271 | - EXT_GIC_ID_IEM_IEC, |
175 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT | 272 | - EXT_GIC_ID_NFC, |
176 | select ACPI_HW_REDUCED | 273 | - EXT_GIC_ID_UART0, |
177 | select ACPI_APEI | 274 | - EXT_GIC_ID_UART1, |
178 | select ACPI_VIOT | 275 | - EXT_GIC_ID_UART2, |
179 | + select VIRTIO_MEM_SUPPORTED | 276 | - EXT_GIC_ID_UART3, |
180 | 277 | - EXT_GIC_ID_UART4, | |
181 | config CHEETAH | 278 | - EXT_GIC_ID_MCT_G0, |
182 | bool | 279 | - EXT_GIC_ID_I2C0, |
280 | - EXT_GIC_ID_I2C1, | ||
281 | - EXT_GIC_ID_I2C2, | ||
282 | - EXT_GIC_ID_I2C3, | ||
283 | - EXT_GIC_ID_I2C4, | ||
284 | - EXT_GIC_ID_I2C5, | ||
285 | - EXT_GIC_ID_I2C6, | ||
286 | - EXT_GIC_ID_I2C7, | ||
287 | - EXT_GIC_ID_SPI0, | ||
288 | - EXT_GIC_ID_SPI1, | ||
289 | - EXT_GIC_ID_SPI2, | ||
290 | - EXT_GIC_ID_MCT_G1, | ||
291 | - EXT_GIC_ID_USB_HOST, | ||
292 | - EXT_GIC_ID_USB_DEVICE, | ||
293 | - EXT_GIC_ID_MODEMIF, | ||
294 | - EXT_GIC_ID_HSMMC0, | ||
295 | - EXT_GIC_ID_HSMMC1, | ||
296 | - EXT_GIC_ID_HSMMC2, | ||
297 | - EXT_GIC_ID_HSMMC3, | ||
298 | - EXT_GIC_ID_SDMMC, | ||
299 | - EXT_GIC_ID_MIPI_CSI_4LANE, | ||
300 | - EXT_GIC_ID_MIPI_DSI_4LANE, | ||
301 | - EXT_GIC_ID_MIPI_CSI_2LANE, | ||
302 | - EXT_GIC_ID_MIPI_DSI_2LANE, | ||
303 | - EXT_GIC_ID_ONENAND_AUDI, | ||
304 | - EXT_GIC_ID_ROTATOR, | ||
305 | - EXT_GIC_ID_FIMC0, | ||
306 | - EXT_GIC_ID_FIMC1, | ||
307 | - EXT_GIC_ID_FIMC2, | ||
308 | - EXT_GIC_ID_FIMC3, | ||
309 | - EXT_GIC_ID_JPEG, | ||
310 | - EXT_GIC_ID_2D, | ||
311 | - EXT_GIC_ID_PCIe, | ||
312 | - EXT_GIC_ID_MIXER, | ||
313 | - EXT_GIC_ID_HDMI, | ||
314 | - EXT_GIC_ID_HDMI_I2C, | ||
315 | - EXT_GIC_ID_MFC, | ||
316 | - EXT_GIC_ID_TVENC, | ||
317 | -}; | ||
318 | - | ||
319 | -enum ExtInt { | ||
320 | - EXT_GIC_ID_EXTINT0 = 48, | ||
321 | - EXT_GIC_ID_EXTINT1, | ||
322 | - EXT_GIC_ID_EXTINT2, | ||
323 | - EXT_GIC_ID_EXTINT3, | ||
324 | - EXT_GIC_ID_EXTINT4, | ||
325 | - EXT_GIC_ID_EXTINT5, | ||
326 | - EXT_GIC_ID_EXTINT6, | ||
327 | - EXT_GIC_ID_EXTINT7, | ||
328 | - EXT_GIC_ID_EXTINT8, | ||
329 | - EXT_GIC_ID_EXTINT9, | ||
330 | - EXT_GIC_ID_EXTINT10, | ||
331 | - EXT_GIC_ID_EXTINT11, | ||
332 | - EXT_GIC_ID_EXTINT12, | ||
333 | - EXT_GIC_ID_EXTINT13, | ||
334 | - EXT_GIC_ID_EXTINT14, | ||
335 | - EXT_GIC_ID_EXTINT15 | ||
336 | -}; | ||
337 | - | ||
338 | -/* | ||
339 | - * External GIC sources which are not from External Interrupt Combiner or | ||
340 | - * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ, | ||
341 | - * which is INTG16 in Internal Interrupt Combiner. | ||
342 | - */ | ||
343 | - | ||
344 | -static const uint32_t | ||
345 | -combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
346 | - /* int combiner groups 16-19 */ | ||
347 | - { }, { }, { }, { }, | ||
348 | - /* int combiner group 20 */ | ||
349 | - { 0, EXT_GIC_ID_MDMA_LCD0 }, | ||
350 | - /* int combiner group 21 */ | ||
351 | - { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 }, | ||
352 | - /* int combiner group 22 */ | ||
353 | - { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2, | ||
354 | - EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 }, | ||
355 | - /* int combiner group 23 */ | ||
356 | - { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC }, | ||
357 | - /* int combiner group 24 */ | ||
358 | - { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA }, | ||
359 | - /* int combiner group 25 */ | ||
360 | - { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC }, | ||
361 | - /* int combiner group 26 */ | ||
362 | - { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3, | ||
363 | - EXT_GIC_ID_UART4 }, | ||
364 | - /* int combiner group 27 */ | ||
365 | - { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3, | ||
366 | - EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6, | ||
367 | - EXT_GIC_ID_I2C7 }, | ||
368 | - /* int combiner group 28 */ | ||
369 | - { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST}, | ||
370 | - /* int combiner group 29 */ | ||
371 | - { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2, | ||
372 | - EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC }, | ||
373 | - /* int combiner group 30 */ | ||
374 | - { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE }, | ||
375 | - /* int combiner group 31 */ | ||
376 | - { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE }, | ||
377 | - /* int combiner group 32 */ | ||
378 | - { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 }, | ||
379 | - /* int combiner group 33 */ | ||
380 | - { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 }, | ||
381 | - /* int combiner group 34 */ | ||
382 | - { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
383 | - /* int combiner group 35 */ | ||
384 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
385 | - /* int combiner group 36 */ | ||
386 | - { EXT_GIC_ID_MIXER }, | ||
387 | - /* int combiner group 37 */ | ||
388 | - { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6, | ||
389 | - EXT_GIC_ID_EXTINT7 }, | ||
390 | - /* groups 38-50 */ | ||
391 | - { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
392 | - /* int combiner group 51 */ | ||
393 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
394 | - /* group 52 */ | ||
395 | - { }, | ||
396 | - /* int combiner group 53 */ | ||
397 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
398 | - /* groups 54-63 */ | ||
399 | - { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
400 | -}; | ||
401 | - | ||
402 | #define EXYNOS4210_GIC_NIRQ 160 | ||
403 | |||
404 | #define EXYNOS4210_EXT_GIC_CPU_REGION_SIZE 0x10000 | ||
405 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
406 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
407 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
408 | |||
409 | -/* | ||
410 | - * Initialize board IRQs. | ||
411 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
412 | - */ | ||
413 | -void exynos4210_init_board_irqs(Exynos4210State *s) | ||
414 | -{ | ||
415 | - uint32_t grp, bit, irq_id, n; | ||
416 | - Exynos4210Irq *is = &s->irqs; | ||
417 | - | ||
418 | - for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
419 | - irq_id = 0; | ||
420 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
421 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
422 | - /* MCT_G0 is passed to External GIC */ | ||
423 | - irq_id = EXT_GIC_ID_MCT_G0; | ||
424 | - } | ||
425 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | ||
426 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | ||
427 | - /* MCT_G1 is passed to External and GIC */ | ||
428 | - irq_id = EXT_GIC_ID_MCT_G1; | ||
429 | - } | ||
430 | - if (irq_id) { | ||
431 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
432 | - is->ext_gic_irq[irq_id - 32]); | ||
433 | - } else { | ||
434 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
435 | - is->ext_combiner_irq[n]); | ||
436 | - } | ||
437 | - } | ||
438 | - for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
439 | - /* these IDs are passed to Internal Combiner and External GIC */ | ||
440 | - grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); | ||
441 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
442 | - irq_id = combiner_grp_to_gic_id[grp - | ||
443 | - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
444 | - | ||
445 | - if (irq_id) { | ||
446 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
447 | - is->ext_gic_irq[irq_id - 32]); | ||
448 | - } | ||
449 | - } | ||
450 | -} | ||
451 | - | ||
452 | -/* | ||
453 | - * Get IRQ number from exynos4210 IRQ subsystem stub. | ||
454 | - * To identify IRQ source use internal combiner group and bit number | ||
455 | - * grp - group number | ||
456 | - * bit - bit number inside group | ||
457 | - */ | ||
458 | -uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
459 | -{ | ||
460 | - return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
461 | -} | ||
462 | - | ||
463 | -/********* GIC part *********/ | ||
464 | - | ||
465 | #define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
466 | OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
467 | |||
183 | -- | 468 | -- |
184 | 2.25.1 | 469 | 2.25.1 |
185 | |||
186 | diff view generated by jsdifflib |
1 | Fix process_mapd() to consistently return CMD_STALL for memory | 1 | Switch the creation of the external GIC to the new-style "embedded in |
---|---|---|---|
2 | errors and CMD_CONTINUE for parameter errors, as we claim in the | 2 | state struct" approach, so we can easily refer to the object |
3 | comments that we do. | 3 | elsewhere during realize. |
4 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220111171048.3545974-11-peter.maydell@linaro.org | 7 | Message-id: 20220404154658.565020-9-peter.maydell@linaro.org |
9 | --- | 8 | --- |
10 | hw/intc/arm_gicv3_its.c | 10 ++++------ | 9 | include/hw/arm/exynos4210.h | 2 ++ |
11 | 1 file changed, 4 insertions(+), 6 deletions(-) | 10 | include/hw/intc/exynos4210_gic.h | 43 ++++++++++++++++++++++++++++++++ |
11 | hw/arm/exynos4210.c | 10 ++++---- | ||
12 | hw/intc/exynos4210_gic.c | 17 ++----------- | ||
13 | MAINTAINERS | 2 +- | ||
14 | 5 files changed, 53 insertions(+), 21 deletions(-) | ||
15 | create mode 100644 include/hw/intc/exynos4210_gic.h | ||
12 | 16 | ||
13 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/arm_gicv3_its.c | 19 | --- a/include/hw/arm/exynos4210.h |
16 | +++ b/hw/intc/arm_gicv3_its.c | 20 | +++ b/include/hw/arm/exynos4210.h |
17 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value, | 21 | @@ -XXX,XX +XXX,XX @@ |
18 | uint64_t itt_addr; | 22 | #include "hw/or-irq.h" |
19 | bool valid; | 23 | #include "hw/sysbus.h" |
20 | MemTxResult res = MEMTX_OK; | 24 | #include "hw/cpu/a9mpcore.h" |
21 | - ItsCmdResult result = CMD_STALL; | 25 | +#include "hw/intc/exynos4210_gic.h" |
22 | 26 | #include "target/arm/cpu-qom.h" | |
23 | devid = ((value & DEVID_MASK) >> DEVID_SHIFT); | 27 | #include "qom/object.h" |
24 | 28 | ||
25 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value, | 29 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { |
26 | MEMTXATTRS_UNSPECIFIED, &res); | 30 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; |
27 | 31 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | |
28 | if (res != MEMTX_OK) { | 32 | A9MPPrivState a9mpcore; |
29 | - return result; | 33 | + Exynos4210GicState ext_gic; |
30 | + return CMD_STALL; | 34 | }; |
35 | |||
36 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
37 | diff --git a/include/hw/intc/exynos4210_gic.h b/include/hw/intc/exynos4210_gic.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/intc/exynos4210_gic.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | +/* | ||
44 | + * Samsung exynos4210 GIC implementation. Based on hw/arm_gic.c | ||
45 | + * | ||
46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. | ||
47 | + * All rights reserved. | ||
48 | + * | ||
49 | + * Evgeny Voevodin <e.voevodin@samsung.com> | ||
50 | + * | ||
51 | + * This program is free software; you can redistribute it and/or modify it | ||
52 | + * under the terms of the GNU General Public License as published by the | ||
53 | + * Free Software Foundation; either version 2 of the License, or (at your | ||
54 | + * option) any later version. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, | ||
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
59 | + * See the GNU General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License along | ||
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
63 | + */ | ||
64 | +#ifndef HW_INTC_EXYNOS4210_GIC_H | ||
65 | +#define HW_INTC_EXYNOS4210_GIC_H | ||
66 | + | ||
67 | +#include "hw/sysbus.h" | ||
68 | + | ||
69 | +#define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
70 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
71 | + | ||
72 | +#define EXYNOS4210_GIC_NCPUS 2 | ||
73 | + | ||
74 | +struct Exynos4210GicState { | ||
75 | + SysBusDevice parent_obj; | ||
76 | + | ||
77 | + MemoryRegion cpu_container; | ||
78 | + MemoryRegion dist_container; | ||
79 | + MemoryRegion cpu_alias[EXYNOS4210_GIC_NCPUS]; | ||
80 | + MemoryRegion dist_alias[EXYNOS4210_GIC_NCPUS]; | ||
81 | + uint32_t num_cpu; | ||
82 | + DeviceState *gic; | ||
83 | +}; | ||
84 | + | ||
85 | +#endif | ||
86 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/arm/exynos4210.c | ||
89 | +++ b/hw/arm/exynos4210.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
91 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); | ||
92 | |||
93 | /* External GIC */ | ||
94 | - dev = qdev_new("exynos4210.gic"); | ||
95 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | ||
96 | - busdev = SYS_BUS_DEVICE(dev); | ||
97 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
98 | + qdev_prop_set_uint32(DEVICE(&s->ext_gic), "num-cpu", EXYNOS4210_NCPUS); | ||
99 | + busdev = SYS_BUS_DEVICE(&s->ext_gic); | ||
100 | + sysbus_realize(busdev, &error_fatal); | ||
101 | /* Map CPU interface */ | ||
102 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_GIC_CPU_BASE_ADDR); | ||
103 | /* Map Distributer interface */ | ||
104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
105 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
31 | } | 106 | } |
32 | 107 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | |
33 | size = (value & SIZE_MASK); | 108 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); |
34 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value, | 109 | + s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); |
35 | MEMTXATTRS_UNSPECIFIED, &res); | ||
36 | |||
37 | if (res != MEMTX_OK) { | ||
38 | - return result; | ||
39 | + return CMD_STALL; | ||
40 | } | 110 | } |
41 | 111 | ||
42 | itt_addr = (value & ITTADDR_MASK) >> ITTADDR_SHIFT; | 112 | /* Internal Interrupt Combiner */ |
43 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value, | 113 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) |
44 | * we ignore this command and move onto the next | ||
45 | * command in the queue | ||
46 | */ | ||
47 | - } else { | ||
48 | - result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL; | ||
49 | + return CMD_CONTINUE; | ||
50 | } | 114 | } |
51 | 115 | ||
52 | - return result; | 116 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); |
53 | + return update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL; | 117 | + object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); |
54 | } | 118 | } |
55 | 119 | ||
56 | /* | 120 | static void exynos4210_class_init(ObjectClass *klass, void *data) |
121 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/hw/intc/exynos4210_gic.c | ||
124 | +++ b/hw/intc/exynos4210_gic.c | ||
125 | @@ -XXX,XX +XXX,XX @@ | ||
126 | #include "qemu/module.h" | ||
127 | #include "hw/irq.h" | ||
128 | #include "hw/qdev-properties.h" | ||
129 | +#include "hw/intc/exynos4210_gic.h" | ||
130 | #include "hw/arm/exynos4210.h" | ||
131 | #include "qom/object.h" | ||
132 | |||
133 | @@ -XXX,XX +XXX,XX @@ | ||
134 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
135 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
136 | |||
137 | -#define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
138 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
139 | - | ||
140 | -struct Exynos4210GicState { | ||
141 | - SysBusDevice parent_obj; | ||
142 | - | ||
143 | - MemoryRegion cpu_container; | ||
144 | - MemoryRegion dist_container; | ||
145 | - MemoryRegion cpu_alias[EXYNOS4210_NCPUS]; | ||
146 | - MemoryRegion dist_alias[EXYNOS4210_NCPUS]; | ||
147 | - uint32_t num_cpu; | ||
148 | - DeviceState *gic; | ||
149 | -}; | ||
150 | - | ||
151 | static void exynos4210_gic_set_irq(void *opaque, int irq, int level) | ||
152 | { | ||
153 | Exynos4210GicState *s = (Exynos4210GicState *)opaque; | ||
154 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) | ||
155 | * enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86 | ||
156 | * doesn't figure this out, otherwise and gives spurious warnings. | ||
157 | */ | ||
158 | - assert(n <= EXYNOS4210_NCPUS); | ||
159 | + assert(n <= EXYNOS4210_GIC_NCPUS); | ||
160 | for (i = 0; i < n; i++) { | ||
161 | /* Map CPU interface per SMP Core */ | ||
162 | sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); | ||
163 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/MAINTAINERS | ||
166 | +++ b/MAINTAINERS | ||
167 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
168 | L: qemu-arm@nongnu.org | ||
169 | S: Odd Fixes | ||
170 | F: hw/*/exynos* | ||
171 | -F: include/hw/arm/exynos4210.h | ||
172 | +F: include/hw/*/exynos* | ||
173 | |||
174 | Calxeda Highbank | ||
175 | M: Rob Herring <robh@kernel.org> | ||
57 | -- | 176 | -- |
58 | 2.25.1 | 177 | 2.25.1 |
59 | |||
60 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | The only time we use the ext_gic_irq[] array in the Exynos4210Irq |
---|---|---|---|
2 | struct is during realize of the SoC -- we initialize it with the | ||
3 | input IRQs of the external GIC device, and then connect those to | ||
4 | outputs of other devices further on in realize (including in the | ||
5 | exynos4210_init_board_irqs() function). Now that the ext_gic object | ||
6 | is easily accessible as s->ext_gic we can make the connections | ||
7 | directly from one device to the other without going via this array. | ||
2 | 8 | ||
3 | We are going to move this code, so fix its style first to avoid: | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-10-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 - | ||
14 | hw/arm/exynos4210.c | 12 ++++++------ | ||
15 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
4 | 16 | ||
5 | ERROR: spaces required around that '/' (ctx:VxV) | 17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
6 | |||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 20220107184429.423572-3-f4bug@amsat.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/musicpal.c | 14 +++++++------- | ||
13 | 1 file changed, 7 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/musicpal.c | 19 | --- a/include/hw/arm/exynos4210.h |
18 | +++ b/hw/arm/musicpal.c | 20 | +++ b/include/hw/arm/exynos4210.h |
19 | @@ -XXX,XX +XXX,XX @@ static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset, | 21 | @@ -XXX,XX +XXX,XX @@ |
20 | return s->imr; | 22 | typedef struct Exynos4210Irq { |
21 | 23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | |
22 | case MP_ETH_FRDP0 ... MP_ETH_FRDP3: | 24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; |
23 | - return s->frx_queue[(offset - MP_ETH_FRDP0)/4]; | 25 | - qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; |
24 | + return s->frx_queue[(offset - MP_ETH_FRDP0) / 4]; | 26 | } Exynos4210Irq; |
25 | 27 | ||
26 | case MP_ETH_CRDP0 ... MP_ETH_CRDP3: | 28 | struct Exynos4210State { |
27 | - return s->rx_queue[(offset - MP_ETH_CRDP0)/4]; | 29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
28 | + return s->rx_queue[(offset - MP_ETH_CRDP0) / 4]; | 30 | index XXXXXXX..XXXXXXX 100644 |
29 | 31 | --- a/hw/arm/exynos4210.c | |
30 | case MP_ETH_CTDP0 ... MP_ETH_CTDP1: | 32 | +++ b/hw/arm/exynos4210.c |
31 | - return s->tx_queue[(offset - MP_ETH_CTDP0)/4]; | 33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
32 | + return s->tx_queue[(offset - MP_ETH_CTDP0) / 4]; | 34 | { |
33 | 35 | uint32_t grp, bit, irq_id, n; | |
34 | default: | 36 | Exynos4210Irq *is = &s->irqs; |
35 | return 0; | 37 | + DeviceState *extgicdev = DEVICE(&s->ext_gic); |
36 | @@ -XXX,XX +XXX,XX @@ static void mv88w8618_eth_write(void *opaque, hwaddr offset, | 38 | |
37 | break; | 39 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { |
38 | 40 | irq_id = 0; | |
39 | case MP_ETH_FRDP0 ... MP_ETH_FRDP3: | 41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
40 | - s->frx_queue[(offset - MP_ETH_FRDP0)/4] = value; | 42 | } |
41 | + s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value; | 43 | if (irq_id) { |
42 | break; | 44 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
43 | 45 | - is->ext_gic_irq[irq_id - 32]); | |
44 | case MP_ETH_CRDP0 ... MP_ETH_CRDP3: | 46 | + qdev_get_gpio_in(extgicdev, |
45 | - s->rx_queue[(offset - MP_ETH_CRDP0)/4] = | 47 | + irq_id - 32)); |
46 | - s->cur_rx[(offset - MP_ETH_CRDP0)/4] = value; | 48 | } else { |
47 | + s->rx_queue[(offset - MP_ETH_CRDP0) / 4] = | 49 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
48 | + s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value; | 50 | is->ext_combiner_irq[n]); |
49 | break; | 51 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
50 | 52 | ||
51 | case MP_ETH_CTDP0 ... MP_ETH_CTDP1: | 53 | if (irq_id) { |
52 | - s->tx_queue[(offset - MP_ETH_CTDP0)/4] = value; | 54 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
53 | + s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value; | 55 | - is->ext_gic_irq[irq_id - 32]); |
54 | break; | 56 | + qdev_get_gpio_in(extgicdev, |
57 | + irq_id - 32)); | ||
58 | } | ||
55 | } | 59 | } |
56 | } | 60 | } |
61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
62 | sysbus_connect_irq(busdev, n, | ||
63 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
64 | } | ||
65 | - for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
66 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); | ||
67 | - } | ||
68 | |||
69 | /* Internal Interrupt Combiner */ | ||
70 | dev = qdev_new("exynos4210.combiner"); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
72 | busdev = SYS_BUS_DEVICE(dev); | ||
73 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
74 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
75 | - sysbus_connect_irq(busdev, n, s->irqs.ext_gic_irq[n]); | ||
76 | + sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
77 | } | ||
78 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); | ||
79 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
57 | -- | 80 | -- |
58 | 2.25.1 | 81 | 2.25.1 |
59 | |||
60 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Yanan Wang <wangyanan55@huawei.com> | ||
2 | 1 | ||
3 | ARM64 machines like Kunpeng Family Server Chips have a level | ||
4 | of hardware topology in which a group of CPU cores share L3 | ||
5 | cache tag or L2 cache. For example, Kunpeng 920 typically | ||
6 | has 6 or 8 clusters in each NUMA node (also represent range | ||
7 | of CPU die), and each cluster has 4 CPU cores. All clusters | ||
8 | share L3 cache data, but CPU cores in each cluster share a | ||
9 | local L3 tag. | ||
10 | |||
11 | Running a guest kernel with Cluster-Aware Scheduling on the | ||
12 | Hosts which have physical clusters, if we can design a vCPU | ||
13 | topology with cluster level for guest kernel and then have | ||
14 | a dedicated vCPU pinning, the guest will gain scheduling | ||
15 | performance improvement from cache affinity of CPU cluster. | ||
16 | |||
17 | So let's enable the support for this new parameter on ARM | ||
18 | virt machines. After this patch, we can define a 4-level | ||
19 | CPU hierarchy like: cpus=*,maxcpus=*,sockets=*,clusters=*, | ||
20 | cores=*,threads=*. | ||
21 | |||
22 | Signed-off-by: Yanan Wang <wangyanan55@huawei.com> | ||
23 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
24 | Message-id: 20220107083232.16256-2-wangyanan55@huawei.com | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | --- | ||
27 | hw/arm/virt.c | 1 + | ||
28 | qemu-options.hx | 10 ++++++++++ | ||
29 | 2 files changed, 11 insertions(+) | ||
30 | |||
31 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/arm/virt.c | ||
34 | +++ b/hw/arm/virt.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) | ||
36 | hc->unplug_request = virt_machine_device_unplug_request_cb; | ||
37 | hc->unplug = virt_machine_device_unplug_cb; | ||
38 | mc->nvdimm_supported = true; | ||
39 | + mc->smp_props.clusters_supported = true; | ||
40 | mc->auto_enable_numa_with_memhp = true; | ||
41 | mc->auto_enable_numa_with_memdev = true; | ||
42 | mc->default_ram_id = "mach-virt.ram"; | ||
43 | diff --git a/qemu-options.hx b/qemu-options.hx | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/qemu-options.hx | ||
46 | +++ b/qemu-options.hx | ||
47 | @@ -XXX,XX +XXX,XX @@ SRST | ||
48 | |||
49 | -smp 16,sockets=2,dies=2,cores=2,threads=2,maxcpus=16 | ||
50 | |||
51 | + The following sub-option defines a CPU topology hierarchy (2 sockets | ||
52 | + totally on the machine, 2 clusters per socket, 2 cores per cluster, | ||
53 | + 2 threads per core) for ARM virt machines which support sockets/clusters | ||
54 | + /cores/threads. Some members of the option can be omitted but their values | ||
55 | + will be automatically computed: | ||
56 | + | ||
57 | + :: | ||
58 | + | ||
59 | + -smp 16,sockets=2,clusters=2,cores=2,threads=2,maxcpus=16 | ||
60 | + | ||
61 | Historically preference was given to the coarsest topology parameters | ||
62 | when computing missing values (ie sockets preferred over cores, which | ||
63 | were preferred over threads), however, this behaviour is considered | ||
64 | -- | ||
65 | 2.25.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Yanan Wang <wangyanan55@huawei.com> | ||
2 | 1 | ||
3 | Support one cluster level between core and physical package in the | ||
4 | cpu-map of Arm/virt devicetree. This is also consistent with Linux | ||
5 | Doc "Documentation/devicetree/bindings/cpu/cpu-topology.txt". | ||
6 | |||
7 | Signed-off-by: Yanan Wang <wangyanan55@huawei.com> | ||
8 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
9 | Message-id: 20220107083232.16256-3-wangyanan55@huawei.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/virt.c | 15 ++++++++------- | ||
13 | 1 file changed, 8 insertions(+), 7 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/virt.c | ||
18 | +++ b/hw/arm/virt.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
20 | * can contain several layers of clustering within a single physical | ||
21 | * package and cluster nodes can be contained in parent cluster nodes. | ||
22 | * | ||
23 | - * Given that cluster is not yet supported in the vCPU topology, | ||
24 | - * we currently generate one cluster node within each socket node | ||
25 | - * by default. | ||
26 | + * Note: currently we only support one layer of clustering within | ||
27 | + * each physical package. | ||
28 | */ | ||
29 | qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map"); | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
32 | |||
33 | if (ms->smp.threads > 1) { | ||
34 | map_path = g_strdup_printf( | ||
35 | - "/cpus/cpu-map/socket%d/cluster0/core%d/thread%d", | ||
36 | - cpu / (ms->smp.cores * ms->smp.threads), | ||
37 | + "/cpus/cpu-map/socket%d/cluster%d/core%d/thread%d", | ||
38 | + cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.threads), | ||
39 | + (cpu / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters, | ||
40 | (cpu / ms->smp.threads) % ms->smp.cores, | ||
41 | cpu % ms->smp.threads); | ||
42 | } else { | ||
43 | map_path = g_strdup_printf( | ||
44 | - "/cpus/cpu-map/socket%d/cluster0/core%d", | ||
45 | - cpu / ms->smp.cores, | ||
46 | + "/cpus/cpu-map/socket%d/cluster%d/core%d", | ||
47 | + cpu / (ms->smp.clusters * ms->smp.cores), | ||
48 | + (cpu / ms->smp.cores) % ms->smp.clusters, | ||
49 | cpu % ms->smp.cores); | ||
50 | } | ||
51 | qemu_fdt_add_path(ms->fdt, map_path); | ||
52 | -- | ||
53 | 2.25.1 | ||
54 | |||
55 | diff view generated by jsdifflib |
1 | Refactor process_its_cmd() so that it consistently uses | 1 | The function exynos4210_combiner_get_gpioin() currently lives in |
---|---|---|---|
2 | the structure | 2 | exynos4210_combiner.c, but it isn't really part of the combiner |
3 | do thing; | 3 | device itself -- it is a function that implements the wiring up of |
4 | if (error condition) { | 4 | some interrupt sources to multiple combiner inputs. Move it to live |
5 | return early; | 5 | with the other SoC-level code in exynos4210.c, along with a few |
6 | } | 6 | macros previously defined in exynos4210.h which are now used only |
7 | do next thing; | 7 | in exynos4210.c. |
8 | |||
9 | rather than doing some of the work nested inside if (not error) | ||
10 | code blocks. | ||
11 | 8 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20220111171048.3545974-8-peter.maydell@linaro.org | 11 | Message-id: 20220404154658.565020-11-peter.maydell@linaro.org |
16 | --- | 12 | --- |
17 | hw/intc/arm_gicv3_its.c | 103 +++++++++++++++++++--------------------- | 13 | include/hw/arm/exynos4210.h | 11 ----- |
18 | 1 file changed, 50 insertions(+), 53 deletions(-) | 14 | hw/arm/exynos4210.c | 82 +++++++++++++++++++++++++++++++++++ |
15 | hw/intc/exynos4210_combiner.c | 77 -------------------------------- | ||
16 | 3 files changed, 82 insertions(+), 88 deletions(-) | ||
19 | 17 | ||
20 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
21 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/intc/arm_gicv3_its.c | 20 | --- a/include/hw/arm/exynos4210.h |
23 | +++ b/hw/intc/arm_gicv3_its.c | 21 | +++ b/include/hw/arm/exynos4210.h |
24 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 22 | @@ -XXX,XX +XXX,XX @@ |
23 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ | ||
24 | (EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8) | ||
25 | |||
26 | -#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp)*8 + (bit)) | ||
27 | -#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8) | ||
28 | -#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
29 | - ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
30 | - | ||
31 | /* IRQs number for external and internal GIC */ | ||
32 | #define EXYNOS4210_EXT_GIC_NIRQ (160-32) | ||
33 | #define EXYNOS4210_INT_GIC_NIRQ 64 | ||
34 | @@ -XXX,XX +XXX,XX @@ void exynos4210_write_secondary(ARMCPU *cpu, | ||
35 | * bit - bit number inside group */ | ||
36 | uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit); | ||
37 | |||
38 | -/* | ||
39 | - * Get Combiner input GPIO into irqs structure | ||
40 | - */ | ||
41 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, | ||
42 | - int ext); | ||
43 | - | ||
44 | /* | ||
45 | * exynos4210 UART | ||
46 | */ | ||
47 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/exynos4210.c | ||
50 | +++ b/hw/arm/exynos4210.c | ||
51 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
52 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
53 | }; | ||
54 | |||
55 | +#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp) * 8 + (bit)) | ||
56 | +#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8) | ||
57 | +#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
58 | + ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
59 | + | ||
60 | /* | ||
61 | * Initialize board IRQs. | ||
62 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
63 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
64 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
65 | } | ||
66 | |||
67 | +/* | ||
68 | + * Get Combiner input GPIO into irqs structure | ||
69 | + */ | ||
70 | +static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
71 | + DeviceState *dev, int ext) | ||
72 | +{ | ||
73 | + int n; | ||
74 | + int bit; | ||
75 | + int max; | ||
76 | + qemu_irq *irq; | ||
77 | + | ||
78 | + max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
79 | + EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
80 | + irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
81 | + | ||
82 | + /* | ||
83 | + * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
84 | + * so let split them. | ||
85 | + */ | ||
86 | + for (n = 0; n < max; n++) { | ||
87 | + | ||
88 | + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
89 | + | ||
90 | + switch (n) { | ||
91 | + /* MDNIE_LCD1 INTG1 */ | ||
92 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
93 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
94 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
95 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
96 | + continue; | ||
97 | + | ||
98 | + /* TMU INTG3 */ | ||
99 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
100 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
101 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
102 | + continue; | ||
103 | + | ||
104 | + /* LCD1 INTG12 */ | ||
105 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
106 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
107 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
108 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
109 | + continue; | ||
110 | + | ||
111 | + /* Multi-Core Timer INTG12 */ | ||
112 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
113 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
114 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
115 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
116 | + continue; | ||
117 | + | ||
118 | + /* Multi-Core Timer INTG35 */ | ||
119 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
120 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
121 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
122 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
123 | + continue; | ||
124 | + | ||
125 | + /* Multi-Core Timer INTG51 */ | ||
126 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
127 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
128 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
129 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
130 | + continue; | ||
131 | + | ||
132 | + /* Multi-Core Timer INTG53 */ | ||
133 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
134 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
135 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
136 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
137 | + continue; | ||
138 | + } | ||
139 | + | ||
140 | + irq[n] = qdev_get_gpio_in(dev, n); | ||
141 | + } | ||
142 | +} | ||
143 | + | ||
144 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
145 | 0x09, 0x00, 0x00, 0x00 }; | ||
146 | |||
147 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c | ||
148 | index XXXXXXX..XXXXXXX 100644 | ||
149 | --- a/hw/intc/exynos4210_combiner.c | ||
150 | +++ b/hw/intc/exynos4210_combiner.c | ||
151 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_exynos4210_combiner = { | ||
25 | } | 152 | } |
26 | dte_valid = FIELD_EX64(dte, DTE, VALID); | 153 | }; |
27 | 154 | ||
28 | - if (dte_valid) { | 155 | -/* |
29 | - num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 156 | - * Get Combiner input GPIO into irqs structure |
30 | - | 157 | - */ |
31 | - ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res); | 158 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, |
32 | - | 159 | - int ext) |
33 | - if (res != MEMTX_OK) { | 160 | -{ |
34 | - return CMD_STALL; | 161 | - int n; |
162 | - int bit; | ||
163 | - int max; | ||
164 | - qemu_irq *irq; | ||
165 | - | ||
166 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
167 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
168 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
169 | - | ||
170 | - /* | ||
171 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
172 | - * so let split them. | ||
173 | - */ | ||
174 | - for (n = 0; n < max; n++) { | ||
175 | - | ||
176 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
177 | - | ||
178 | - switch (n) { | ||
179 | - /* MDNIE_LCD1 INTG1 */ | ||
180 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
181 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
182 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
183 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
184 | - continue; | ||
185 | - | ||
186 | - /* TMU INTG3 */ | ||
187 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
188 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
189 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
190 | - continue; | ||
191 | - | ||
192 | - /* LCD1 INTG12 */ | ||
193 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
194 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
195 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
196 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
197 | - continue; | ||
198 | - | ||
199 | - /* Multi-Core Timer INTG12 */ | ||
200 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
201 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
202 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
203 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
204 | - continue; | ||
205 | - | ||
206 | - /* Multi-Core Timer INTG35 */ | ||
207 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
208 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
209 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
210 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
211 | - continue; | ||
212 | - | ||
213 | - /* Multi-Core Timer INTG51 */ | ||
214 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
215 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
216 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
217 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
218 | - continue; | ||
219 | - | ||
220 | - /* Multi-Core Timer INTG53 */ | ||
221 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
222 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
223 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
224 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
225 | - continue; | ||
35 | - } | 226 | - } |
36 | - | 227 | - |
37 | - if (ite_valid) { | 228 | - irq[n] = qdev_get_gpio_in(dev, n); |
38 | - cte_valid = get_cte(s, icid, &cte, &res); | 229 | - } |
39 | - } | 230 | -} |
40 | - | 231 | - |
41 | - if (res != MEMTX_OK) { | 232 | static uint64_t |
42 | - return CMD_STALL; | 233 | exynos4210_combiner_read(void *opaque, hwaddr offset, unsigned size) |
43 | - } | 234 | { |
44 | - } else { | ||
45 | + if (!dte_valid) { | ||
46 | qemu_log_mask(LOG_GUEST_ERROR, | ||
47 | "%s: invalid command attributes: " | ||
48 | - "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n", | ||
49 | - __func__, dte, devid, res); | ||
50 | + "invalid dte: %"PRIx64" for %d\n", | ||
51 | + __func__, dte, devid); | ||
52 | return CMD_CONTINUE; | ||
53 | } | ||
54 | |||
55 | + num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | ||
56 | + | ||
57 | + ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res); | ||
58 | + if (res != MEMTX_OK) { | ||
59 | + return CMD_STALL; | ||
60 | + } | ||
61 | + | ||
62 | + if (!ite_valid) { | ||
63 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
64 | + "%s: invalid command attributes: invalid ITE\n", | ||
65 | + __func__); | ||
66 | + return CMD_CONTINUE; | ||
67 | + } | ||
68 | + | ||
69 | + cte_valid = get_cte(s, icid, &cte, &res); | ||
70 | + if (res != MEMTX_OK) { | ||
71 | + return CMD_STALL; | ||
72 | + } | ||
73 | + if (!cte_valid) { | ||
74 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
75 | + "%s: invalid command attributes: " | ||
76 | + "invalid cte: %"PRIx64"\n", | ||
77 | + __func__, cte); | ||
78 | + return CMD_CONTINUE; | ||
79 | + } | ||
80 | |||
81 | - /* | ||
82 | - * In this implementation, in case of guest errors we ignore the | ||
83 | - * command and move onto the next command in the queue. | ||
84 | - */ | ||
85 | if (devid >= s->dt.num_ids) { | ||
86 | qemu_log_mask(LOG_GUEST_ERROR, | ||
87 | "%s: invalid command attributes: devid %d>=%d", | ||
88 | __func__, devid, s->dt.num_ids); | ||
89 | return CMD_CONTINUE; | ||
90 | - } else if (!dte_valid || !ite_valid || !cte_valid) { | ||
91 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
92 | - "%s: invalid command attributes: " | ||
93 | - "dte: %s, ite: %s, cte: %s\n", | ||
94 | - __func__, | ||
95 | - dte_valid ? "valid" : "invalid", | ||
96 | - ite_valid ? "valid" : "invalid", | ||
97 | - cte_valid ? "valid" : "invalid"); | ||
98 | - return CMD_CONTINUE; | ||
99 | - } else if (eventid >= num_eventids) { | ||
100 | + } | ||
101 | + if (eventid >= num_eventids) { | ||
102 | qemu_log_mask(LOG_GUEST_ERROR, | ||
103 | "%s: invalid command attributes: eventid %d >= %" | ||
104 | PRId64 "\n", | ||
105 | __func__, eventid, num_eventids); | ||
106 | return CMD_CONTINUE; | ||
107 | - } else { | ||
108 | - /* | ||
109 | - * Current implementation only supports rdbase == procnum | ||
110 | - * Hence rdbase physical address is ignored | ||
111 | - */ | ||
112 | - rdbase = FIELD_EX64(cte, CTE, RDBASE); | ||
113 | + } | ||
114 | |||
115 | - if (rdbase >= s->gicv3->num_cpu) { | ||
116 | - return CMD_CONTINUE; | ||
117 | - } | ||
118 | + /* | ||
119 | + * Current implementation only supports rdbase == procnum | ||
120 | + * Hence rdbase physical address is ignored | ||
121 | + */ | ||
122 | + rdbase = FIELD_EX64(cte, CTE, RDBASE); | ||
123 | |||
124 | - if ((cmd == CLEAR) || (cmd == DISCARD)) { | ||
125 | - gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0); | ||
126 | - } else { | ||
127 | - gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1); | ||
128 | - } | ||
129 | - | ||
130 | - if (cmd == DISCARD) { | ||
131 | - IteEntry ite = {}; | ||
132 | - /* remove mapping from interrupt translation table */ | ||
133 | - return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | ||
134 | - } | ||
135 | + if (rdbase >= s->gicv3->num_cpu) { | ||
136 | return CMD_CONTINUE; | ||
137 | } | ||
138 | + | ||
139 | + if ((cmd == CLEAR) || (cmd == DISCARD)) { | ||
140 | + gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0); | ||
141 | + } else { | ||
142 | + gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1); | ||
143 | + } | ||
144 | + | ||
145 | + if (cmd == DISCARD) { | ||
146 | + IteEntry ite = {}; | ||
147 | + /* remove mapping from interrupt translation table */ | ||
148 | + return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | ||
149 | + } | ||
150 | + return CMD_CONTINUE; | ||
151 | } | ||
152 | |||
153 | static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | ||
154 | -- | 235 | -- |
155 | 2.25.1 | 236 | 2.25.1 |
156 | |||
157 | diff view generated by jsdifflib |
1 | In process_cmdq(), we read 64 bits of the command packet, which | 1 | Delete a couple of #defines which are never used. |
---|---|---|---|
2 | contain the command identifier, which we then switch() on to dispatch | ||
3 | to an appropriate sub-function. However, if address_space_ldq_le() | ||
4 | reports a memory transaction failure, we still read the command | ||
5 | identifier out of the data and switch() on it. Restructure the code | ||
6 | so that we stop immediately (stalling the command queue) in this | ||
7 | case. | ||
8 | 2 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20220111171048.3545974-5-peter.maydell@linaro.org | 5 | Message-id: 20220404154658.565020-12-peter.maydell@linaro.org |
13 | --- | 6 | --- |
14 | hw/intc/arm_gicv3_its.c | 7 ++++++- | 7 | include/hw/arm/exynos4210.h | 4 ---- |
15 | 1 file changed, 6 insertions(+), 1 deletion(-) | 8 | 1 file changed, 4 deletions(-) |
16 | 9 | ||
17 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 10 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
18 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_its.c | 12 | --- a/include/hw/arm/exynos4210.h |
20 | +++ b/hw/intc/arm_gicv3_its.c | 13 | +++ b/include/hw/arm/exynos4210.h |
21 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | 14 | @@ -XXX,XX +XXX,XX @@ |
22 | data = address_space_ldq_le(as, s->cq.base_addr + cq_offset, | 15 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ |
23 | MEMTXATTRS_UNSPECIFIED, &res); | 16 | (EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8) |
24 | if (res != MEMTX_OK) { | 17 | |
25 | - result = false; | 18 | -/* IRQs number for external and internal GIC */ |
26 | + s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1); | 19 | -#define EXYNOS4210_EXT_GIC_NIRQ (160-32) |
27 | + qemu_log_mask(LOG_GUEST_ERROR, | 20 | -#define EXYNOS4210_INT_GIC_NIRQ 64 |
28 | + "%s: could not read command at 0x%" PRIx64 "\n", | 21 | - |
29 | + __func__, s->cq.base_addr + cq_offset); | 22 | #define EXYNOS4210_I2C_NUMBER 9 |
30 | + break; | 23 | |
31 | } | 24 | #define EXYNOS4210_NUM_DMA 3 |
32 | + | ||
33 | cmd = (data & CMD_MASK); | ||
34 | |||
35 | switch (cmd) { | ||
36 | -- | 25 | -- |
37 | 2.25.1 | 26 | 2.25.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Troy Lee <troy_lee@aspeedtech.com> | 1 | In exynos4210_init_board_irqs(), use the TYPE_SPLIT_IRQ device |
---|---|---|---|
2 | instead of qemu_irq_split(). | ||
2 | 3 | ||
3 | Add the new i3c device to the AST2600 SoC. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20220404154658.565020-13-peter.maydell@linaro.org | ||
7 | --- | ||
8 | include/hw/arm/exynos4210.h | 9 ++++++++ | ||
9 | hw/arm/exynos4210.c | 41 +++++++++++++++++++++++++++++-------- | ||
10 | 2 files changed, 42 insertions(+), 8 deletions(-) | ||
4 | 11 | ||
5 | Signed-off-by: Troy Lee <troy_lee@aspeedtech.com> | 12 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
6 | Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com> | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Tested-by: Graeme Gregory <quic_ggregory@quicinc.com> | ||
9 | Message-id: 20220111084546.4145785-3-troy_lee@aspeedtech.com | ||
10 | [PMM: tidied commit message] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/arm/aspeed_soc.h | 3 +++ | ||
14 | hw/arm/aspeed_ast2600.c | 16 ++++++++++++++++ | ||
15 | 2 files changed, 19 insertions(+) | ||
16 | |||
17 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/aspeed_soc.h | 14 | --- a/include/hw/arm/exynos4210.h |
20 | +++ b/include/hw/arm/aspeed_soc.h | 15 | +++ b/include/hw/arm/exynos4210.h |
21 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
22 | #include "hw/timer/aspeed_timer.h" | 17 | #include "hw/sysbus.h" |
23 | #include "hw/rtc/aspeed_rtc.h" | 18 | #include "hw/cpu/a9mpcore.h" |
24 | #include "hw/i2c/aspeed_i2c.h" | 19 | #include "hw/intc/exynos4210_gic.h" |
25 | +#include "hw/misc/aspeed_i3c.h" | 20 | +#include "hw/core/split-irq.h" |
26 | #include "hw/ssi/aspeed_smc.h" | 21 | #include "target/arm/cpu-qom.h" |
27 | #include "hw/misc/aspeed_hace.h" | 22 | #include "qom/object.h" |
28 | #include "hw/watchdog/wdt_aspeed.h" | 23 | |
29 | @@ -XXX,XX +XXX,XX @@ struct AspeedSoCState { | 24 | @@ -XXX,XX +XXX,XX @@ |
30 | AspeedRtcState rtc; | 25 | |
31 | AspeedTimerCtrlState timerctrl; | 26 | #define EXYNOS4210_NUM_DMA 3 |
32 | AspeedI2CState i2c; | 27 | |
33 | + AspeedI3CState i3c; | 28 | +/* |
34 | AspeedSCUState scu; | 29 | + * We need one splitter for every external combiner input, plus |
35 | AspeedHACEState hace; | 30 | + * one for every non-zero entry in combiner_grp_to_gic_id[]. |
36 | AspeedXDMAState xdma; | 31 | + * We'll assert in exynos4210_init_board_irqs() if this is wrong. |
37 | @@ -XXX,XX +XXX,XX @@ enum { | 32 | + */ |
38 | ASPEED_DEV_HACE, | 33 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) |
39 | ASPEED_DEV_DPMCU, | 34 | + |
40 | ASPEED_DEV_DP, | 35 | typedef struct Exynos4210Irq { |
41 | + ASPEED_DEV_I3C, | 36 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
37 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
38 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
39 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
40 | A9MPPrivState a9mpcore; | ||
41 | Exynos4210GicState ext_gic; | ||
42 | + SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS]; | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | #endif /* ASPEED_SOC_H */ | 45 | #define TYPE_EXYNOS4210_SOC "exynos4210" |
45 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | 46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
46 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/hw/arm/aspeed_ast2600.c | 48 | --- a/hw/arm/exynos4210.c |
48 | +++ b/hw/arm/aspeed_ast2600.c | 49 | +++ b/hw/arm/exynos4210.c |
49 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { | 50 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
50 | [ASPEED_DEV_UART1] = 0x1E783000, | 51 | uint32_t grp, bit, irq_id, n; |
51 | [ASPEED_DEV_UART5] = 0x1E784000, | 52 | Exynos4210Irq *is = &s->irqs; |
52 | [ASPEED_DEV_VUART] = 0x1E787000, | 53 | DeviceState *extgicdev = DEVICE(&s->ext_gic); |
53 | + [ASPEED_DEV_I3C] = 0x1E7A0000, | 54 | + int splitcount = 0; |
54 | [ASPEED_DEV_SDRAM] = 0x80000000, | 55 | + DeviceState *splitter; |
55 | }; | 56 | |
56 | 57 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | |
57 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = { | 58 | irq_id = 0; |
58 | [ASPEED_DEV_ETH4] = 33, | 59 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
59 | [ASPEED_DEV_KCS] = 138, /* 138 -> 142 */ | 60 | /* MCT_G1 is passed to External and GIC */ |
60 | [ASPEED_DEV_DP] = 62, | 61 | irq_id = EXT_GIC_ID_MCT_G1; |
61 | + [ASPEED_DEV_I3C] = 102, /* 102 -> 107 */ | 62 | } |
62 | }; | ||
63 | |||
64 | static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl) | ||
65 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
66 | |||
67 | snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname); | ||
68 | object_initialize_child(obj, "hace", &s->hace, typename); | ||
69 | + | 63 | + |
70 | + object_initialize_child(obj, "i3c", &s->i3c, TYPE_ASPEED_I3C); | 64 | + assert(splitcount < EXYNOS4210_NUM_SPLITTERS); |
65 | + splitter = DEVICE(&s->splitter[splitcount]); | ||
66 | + qdev_prop_set_uint16(splitter, "num-lines", 2); | ||
67 | + qdev_realize(splitter, NULL, &error_abort); | ||
68 | + splitcount++; | ||
69 | + s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
70 | + qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
71 | if (irq_id) { | ||
72 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
73 | - qdev_get_gpio_in(extgicdev, | ||
74 | - irq_id - 32)); | ||
75 | + qdev_connect_gpio_out(splitter, 1, | ||
76 | + qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
77 | } else { | ||
78 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
79 | - is->ext_combiner_irq[n]); | ||
80 | + qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
81 | } | ||
82 | } | ||
83 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
85 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
86 | |||
87 | if (irq_id) { | ||
88 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
89 | - qdev_get_gpio_in(extgicdev, | ||
90 | - irq_id - 32)); | ||
91 | + assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
92 | + splitter = DEVICE(&s->splitter[splitcount]); | ||
93 | + qdev_prop_set_uint16(splitter, "num-lines", 2); | ||
94 | + qdev_realize(splitter, NULL, &error_abort); | ||
95 | + splitcount++; | ||
96 | + s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
97 | + qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
98 | + qdev_connect_gpio_out(splitter, 1, | ||
99 | + qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
100 | } | ||
101 | } | ||
102 | + /* | ||
103 | + * We check this here to avoid a more obscure assert later when | ||
104 | + * qdev_assert_realized_properly() checks that we realized every | ||
105 | + * child object we initialized. | ||
106 | + */ | ||
107 | + assert(splitcount == EXYNOS4210_NUM_SPLITTERS); | ||
71 | } | 108 | } |
72 | 109 | ||
73 | /* | 110 | /* |
74 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | 111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) |
75 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]); | 112 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); |
76 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, | 113 | } |
77 | aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); | 114 | |
115 | + for (i = 0; i < ARRAY_SIZE(s->splitter); i++) { | ||
116 | + g_autofree char *name = g_strdup_printf("irq-splitter%d", i); | ||
117 | + object_initialize_child(obj, name, &s->splitter[i], TYPE_SPLIT_IRQ); | ||
118 | + } | ||
78 | + | 119 | + |
79 | + /* I3C */ | 120 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); |
80 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp)) { | 121 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); |
81 | + return; | ||
82 | + } | ||
83 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]); | ||
84 | + for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) { | ||
85 | + qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
86 | + sc->irqmap[ASPEED_DEV_I3C] + i); | ||
87 | + /* The AST2600 I3C controller has one IRQ per bus. */ | ||
88 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq); | ||
89 | + } | ||
90 | } | 122 | } |
91 | |||
92 | static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) | ||
93 | -- | 123 | -- |
94 | 2.25.1 | 124 | 2.25.1 |
95 | |||
96 | diff view generated by jsdifflib |
1 | process_its_cmd() returns a bool, like all the other process_ functions. | 1 | In exynos4210_init_board_irqs(), the loop that handles IRQ lines that |
---|---|---|---|
2 | However we were putting its return value into 'res', not 'result', | 2 | are in a range that applies to the internal combiner only creates a |
3 | which meant we would ignore it when deciding whether to continue | 3 | splitter for those interrupts which go to both the internal combiner |
4 | or stall the command queue. Fix the typo. | 4 | and to the external GIC, but it does nothing at all for the |
5 | interrupts which don't go to the external GIC, leaving the | ||
6 | irq_table[] array element empty for those. (This will result in | ||
7 | those interrupts simply being lost, not in a QEMU crash.) | ||
8 | |||
9 | I don't have a reliable datasheet for this SoC, but since we do wire | ||
10 | up one interrupt line in this category (the HDMI I2C device on | ||
11 | interrupt 16,1), this seems like it must be a bug in the existing | ||
12 | QEMU code. Fill in the irq_table[] entries where we're not splitting | ||
13 | the IRQ to both the internal combiner and the external GIC with the | ||
14 | IRQ line of the internal combiner. (That is, these IRQ lines go to | ||
15 | just one device, not multiple.) | ||
16 | |||
17 | This bug didn't have any visible guest effects because the only | ||
18 | implemented device that was affected was the HDMI I2C controller, | ||
19 | and we never connect any I2C devices to that bus. | ||
5 | 20 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 23 | Message-id: 20220404154658.565020-14-peter.maydell@linaro.org |
10 | Message-id: 20220111171048.3545974-4-peter.maydell@linaro.org | ||
11 | --- | 24 | --- |
12 | hw/intc/arm_gicv3_its.c | 4 ++-- | 25 | hw/arm/exynos4210.c | 2 ++ |
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | 26 | 1 file changed, 2 insertions(+) |
14 | 27 | ||
15 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 28 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
16 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/intc/arm_gicv3_its.c | 30 | --- a/hw/arm/exynos4210.c |
18 | +++ b/hw/intc/arm_gicv3_its.c | 31 | +++ b/hw/arm/exynos4210.c |
19 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | 32 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
20 | 33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | |
21 | switch (cmd) { | 34 | qdev_connect_gpio_out(splitter, 1, |
22 | case GITS_CMD_INT: | 35 | qdev_get_gpio_in(extgicdev, irq_id - 32)); |
23 | - res = process_its_cmd(s, data, cq_offset, INTERRUPT); | 36 | + } else { |
24 | + result = process_its_cmd(s, data, cq_offset, INTERRUPT); | 37 | + s->irq_table[n] = is->int_combiner_irq[n]; |
25 | break; | 38 | } |
26 | case GITS_CMD_CLEAR: | 39 | } |
27 | - res = process_its_cmd(s, data, cq_offset, CLEAR); | 40 | /* |
28 | + result = process_its_cmd(s, data, cq_offset, CLEAR); | ||
29 | break; | ||
30 | case GITS_CMD_SYNC: | ||
31 | /* | ||
32 | -- | 41 | -- |
33 | 2.25.1 | 42 | 2.25.1 |
34 | |||
35 | diff view generated by jsdifflib |
1 | The bounds check on the number of interrupt IDs is correct, but | 1 | Currently for the interrupts MCT_G0 and MCT_G1 which are |
---|---|---|---|
2 | doesn't match our convention; change the variable name, initialize it | 2 | the only ones in the input range of the external combiner |
3 | to the 2^n value rather than (2^n)-1, and use >= instead of > in the | 3 | and which are also wired to the external GIC, we connect |
4 | comparison. | 4 | them only to the internal combiner and the external GIC. |
5 | This seems likely to be a bug, as all other interrupts | ||
6 | which are in the input range of both combiners are | ||
7 | connected to both combiners. (The fact that the code in | ||
8 | exynos4210_combiner_get_gpioin() is also trying to wire | ||
9 | up these inputs on both combiners also suggests this.) | ||
10 | |||
11 | Wire these interrupts up to both combiners, like the rest. | ||
5 | 12 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220111171048.3545974-3-peter.maydell@linaro.org | 15 | Message-id: 20220404154658.565020-15-peter.maydell@linaro.org |
9 | --- | 16 | --- |
10 | hw/intc/arm_gicv3_its.c | 6 +++--- | 17 | hw/arm/exynos4210.c | 7 +++---- |
11 | 1 file changed, 3 insertions(+), 3 deletions(-) | 18 | 1 file changed, 3 insertions(+), 4 deletions(-) |
12 | 19 | ||
13 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 20 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
14 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/arm_gicv3_its.c | 22 | --- a/hw/arm/exynos4210.c |
16 | +++ b/hw/intc/arm_gicv3_its.c | 23 | +++ b/hw/arm/exynos4210.c |
17 | @@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | 24 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
18 | uint32_t devid, eventid; | 25 | |
19 | uint32_t pIntid = 0; | 26 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); |
20 | uint64_t num_eventids; | 27 | splitter = DEVICE(&s->splitter[splitcount]); |
21 | - uint32_t max_Intid; | 28 | - qdev_prop_set_uint16(splitter, "num-lines", 2); |
22 | + uint32_t num_intids; | 29 | + qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2); |
23 | bool dte_valid; | 30 | qdev_realize(splitter, NULL, &error_abort); |
24 | MemTxResult res = MEMTX_OK; | 31 | splitcount++; |
25 | uint16_t icid = 0; | 32 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); |
26 | @@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | 33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); |
34 | + qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
35 | if (irq_id) { | ||
36 | - qdev_connect_gpio_out(splitter, 1, | ||
37 | + qdev_connect_gpio_out(splitter, 2, | ||
38 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
39 | - } else { | ||
40 | - qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
41 | } | ||
27 | } | 42 | } |
28 | dte_valid = FIELD_EX64(dte, DTE, VALID); | 43 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { |
29 | num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | ||
30 | - max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1; | ||
31 | + num_intids = 1ULL << (GICD_TYPER_IDBITS + 1); | ||
32 | |||
33 | if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids) | ||
34 | || !dte_valid || (eventid >= num_eventids) || | ||
35 | - (((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) && | ||
36 | + (((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) && | ||
37 | (pIntid != INTID_SPURIOUS))) { | ||
38 | qemu_log_mask(LOG_GUEST_ERROR, | ||
39 | "%s: invalid command attributes " | ||
40 | -- | 44 | -- |
41 | 2.25.1 | 45 | 2.25.1 |
42 | |||
43 | diff view generated by jsdifflib |
1 | In process_its_cmd() and process_mapti() we must check the | 1 | The combiner_grp_to_gic_id[] array includes the EXT_GIC_ID_MCT_G0 |
---|---|---|---|
2 | event ID against a limit defined by the size field in the DTE, | 2 | and EXT_GIC_ID_MCT_G1 multiple times. This means that we will |
3 | which specifies the number of ID bits minus one. Convert | 3 | connect multiple IRQs up to the same external GIC input, which |
4 | this code to our num_foo convention: | 4 | is not permitted. We do the same thing in the code in |
5 | * change the variable names | 5 | exynos4210_init_board_irqs() because the conditionals selecting |
6 | * use uint64_t and 1ULL when calculating the number | 6 | an irq_id in the first loop match multiple interrupt IDs. |
7 | of valid event IDs, because DTE.SIZE is 5 bits and | 7 | |
8 | so num_eventids may be up to 2^32 | 8 | Overall we do this for interrupt IDs |
9 | * fix the off-by-one error in the comparison | 9 | (1, 4), (12, 4), (35, 4), (51, 4), (53, 4) for EXT_GIC_ID_MCT_G0 |
10 | and | ||
11 | (1, 5), (12, 5), (35, 5), (51, 5), (53, 5) for EXT_GIC_ID_MCT_G1 | ||
12 | |||
13 | These correspond to the cases for the multi-core timer that we are | ||
14 | wiring up to multiple inputs on the combiner in | ||
15 | exynos4210_combiner_get_gpioin(). That code already deals with all | ||
16 | these interrupt IDs being the same input source, so we don't need to | ||
17 | connect the external GIC interrupt for any of them except the first | ||
18 | (1, 4) and (1, 5). Remove the array entries and conditionals which | ||
19 | were incorrectly causing us to wire up extra lines. | ||
20 | |||
21 | This bug didn't cause any visible effects, because we only connect | ||
22 | up a device to the "primary" ID values (1, 4) and (1, 5), so the | ||
23 | extra lines would never be set to a level. | ||
10 | 24 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Message-id: 20220111171048.3545974-2-peter.maydell@linaro.org | 27 | Message-id: 20220404154658.565020-16-peter.maydell@linaro.org |
14 | --- | 28 | --- |
15 | hw/intc/arm_gicv3_its.c | 18 ++++++++++-------- | 29 | include/hw/arm/exynos4210.h | 2 +- |
16 | 1 file changed, 10 insertions(+), 8 deletions(-) | 30 | hw/arm/exynos4210.c | 12 +++++------- |
31 | 2 files changed, 6 insertions(+), 8 deletions(-) | ||
17 | 32 | ||
18 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 33 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
19 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/intc/arm_gicv3_its.c | 35 | --- a/include/hw/arm/exynos4210.h |
21 | +++ b/hw/intc/arm_gicv3_its.c | 36 | +++ b/include/hw/arm/exynos4210.h |
22 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 37 | @@ -XXX,XX +XXX,XX @@ |
23 | MemTxResult res = MEMTX_OK; | 38 | * one for every non-zero entry in combiner_grp_to_gic_id[]. |
24 | bool dte_valid; | 39 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. |
25 | uint64_t dte = 0; | 40 | */ |
26 | - uint32_t max_eventid; | 41 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) |
27 | + uint64_t num_eventids; | 42 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) |
28 | uint16_t icid = 0; | 43 | |
29 | uint32_t pIntid = 0; | 44 | typedef struct Exynos4210Irq { |
30 | bool ite_valid = false; | 45 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
31 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
32 | dte_valid = FIELD_EX64(dte, DTE, VALID); | 47 | index XXXXXXX..XXXXXXX 100644 |
33 | 48 | --- a/hw/arm/exynos4210.c | |
34 | if (dte_valid) { | 49 | +++ b/hw/arm/exynos4210.c |
35 | - max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 50 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { |
36 | + num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 51 | /* int combiner group 34 */ |
37 | 52 | { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | |
38 | ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res); | 53 | /* int combiner group 35 */ |
39 | 54 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | |
40 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 55 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1 }, |
41 | dte_valid ? "valid" : "invalid", | 56 | /* int combiner group 36 */ |
42 | ite_valid ? "valid" : "invalid", | 57 | { EXT_GIC_ID_MIXER }, |
43 | cte_valid ? "valid" : "invalid"); | 58 | /* int combiner group 37 */ |
44 | - } else if (eventid > max_eventid) { | 59 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { |
45 | + } else if (eventid >= num_eventids) { | 60 | /* groups 38-50 */ |
46 | qemu_log_mask(LOG_GUEST_ERROR, | 61 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, |
47 | - "%s: invalid command attributes: eventid %d > %d\n", | 62 | /* int combiner group 51 */ |
48 | - __func__, eventid, max_eventid); | 63 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, |
49 | + "%s: invalid command attributes: eventid %d >= %" | 64 | + { EXT_GIC_ID_MCT_L0 }, |
50 | + PRId64 "\n", | 65 | /* group 52 */ |
51 | + __func__, eventid, num_eventids); | 66 | { }, |
52 | } else { | 67 | /* int combiner group 53 */ |
53 | /* | 68 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, |
54 | * Current implementation only supports rdbase == procnum | 69 | + { EXT_GIC_ID_WDT }, |
55 | @@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | 70 | /* groups 54-63 */ |
56 | AddressSpace *as = &s->gicv3->dma_as; | 71 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } |
57 | uint32_t devid, eventid; | 72 | }; |
58 | uint32_t pIntid = 0; | 73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
59 | - uint32_t max_eventid, max_Intid; | 74 | |
60 | + uint64_t num_eventids; | 75 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { |
61 | + uint32_t max_Intid; | 76 | irq_id = 0; |
62 | bool dte_valid; | 77 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || |
63 | MemTxResult res = MEMTX_OK; | 78 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { |
64 | uint16_t icid = 0; | 79 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4)) { |
65 | @@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | 80 | /* MCT_G0 is passed to External GIC */ |
66 | return result; | 81 | irq_id = EXT_GIC_ID_MCT_G0; |
67 | } | 82 | } |
68 | dte_valid = FIELD_EX64(dte, DTE, VALID); | 83 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || |
69 | - max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 84 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { |
70 | + num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1); | 85 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5)) { |
71 | max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1; | 86 | /* MCT_G1 is passed to External and GIC */ |
72 | 87 | irq_id = EXT_GIC_ID_MCT_G1; | |
73 | if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids) | 88 | } |
74 | - || !dte_valid || (eventid > max_eventid) || | ||
75 | + || !dte_valid || (eventid >= num_eventids) || | ||
76 | (((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) && | ||
77 | (pIntid != INTID_SPURIOUS))) { | ||
78 | qemu_log_mask(LOG_GUEST_ERROR, | ||
79 | -- | 89 | -- |
80 | 2.25.1 | 90 | 2.25.1 |
81 | |||
82 | diff view generated by jsdifflib |
1 | When an ITS detects an error in a command, it has an | 1 | At this point, the function exynos4210_init_board_irqs() splits input |
---|---|---|---|
2 | implementation-defined (CONSTRAINED UNPREDICTABLE) choice of whether | 2 | IRQ lines to connect them to the input combiner, output combiner and |
3 | to ignore the command, proceeding to the next one in the queue, or to | 3 | external GIC. The function exynos4210_combiner_get_gpioin() splits |
4 | stall the ITS command queue, processing nothing further. The | 4 | some of the combiner input lines further to connect them to multiple |
5 | behaviour required when the read of the command packet from memory | 5 | different inputs on the combiner. |
6 | fails is less clearly documented, but the same set of choices as for | 6 | |
7 | command errors seem reasonable. | 7 | Because (unlike qemu_irq_split()) the TYPE_SPLIT_IRQ device has a |
8 | 8 | configurable number of outputs, we can do all this in one place, by | |
9 | The intention of the QEMU implementation, as documented in the | 9 | making exynos4210_init_board_irqs() add extra outputs to the splitter |
10 | comments, is that if we encounter a memory error reading the command | 10 | device when it must be connected to more than one input on each |
11 | packet or one of the various data tables then we should stall, but | 11 | combiner. |
12 | for command parameter errors we should ignore the queue and continue. | 12 | |
13 | However, we don't actually do this. To get the desired behaviour, | 13 | We do this with a new data structure, the combinermap, which is an |
14 | the various process_* functions need to return true to cause | 14 | array each of whose elements is a list of the interrupt IDs on the |
15 | process_cmdq() to advance to the next command and keep processing, | 15 | combiner which must be tied together. As we loop through each |
16 | and false to stall command processing. What they mostly do is return | 16 | interrupt ID, if we find that it is the first one in one of these |
17 | false for any kind of error. | 17 | lists, we configure the splitter device with eonugh extra outputs and |
18 | 18 | wire them up to the other interrupt IDs in the list. | |
19 | To make the code clearer, replace the 'bool' return from the process_ | 19 | |
20 | functions with an enum which may be either CMD_STALL or CMD_CONTINUE. | 20 | Conveniently, for all the cases where this is necessary, the |
21 | In this commit no behaviour changes; in subsequent commits we will | 21 | lowest-numbered interrupt ID in each group is in the range of the |
22 | adjust the error-return paths for the process_ functions one by one. | 22 | external combiner, so we only need to code for this in the first of |
23 | the two loops in exynos4210_init_board_irqs(). | ||
24 | |||
25 | The old code in exynos4210_combiner_get_gpioin() which is being | ||
26 | deleted here had several problems which don't exist in the new code | ||
27 | in its handling of the multi-core timer interrupts: | ||
28 | (1) the case labels specified bits 4 ... 8, but bit '8' doesn't | ||
29 | exist; these should have been 4 ... 7 | ||
30 | (2) it used the input irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)] | ||
31 | multiple times as the input of several different splitters, | ||
32 | which isn't allowed | ||
33 | (3) in an apparent cut-and-paste error, the cases for all the | ||
34 | multi-core timer inputs used "bit + 4" even though the | ||
35 | bit range for the case was (intended to be) 4 ... 7, which | ||
36 | meant it was looking at non-existent bits 8 ... 11. | ||
37 | None of these exist in the new code. | ||
23 | 38 | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 39 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 40 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
27 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 41 | Message-id: 20220404154658.565020-17-peter.maydell@linaro.org |
28 | Message-id: 20220111171048.3545974-6-peter.maydell@linaro.org | ||
29 | --- | 42 | --- |
30 | hw/intc/arm_gicv3_its.c | 59 ++++++++++++++++++++++++++--------------- | 43 | include/hw/arm/exynos4210.h | 6 +- |
31 | 1 file changed, 38 insertions(+), 21 deletions(-) | 44 | hw/arm/exynos4210.c | 178 +++++++++++++++++++++++------------- |
32 | 45 | 2 files changed, 119 insertions(+), 65 deletions(-) | |
33 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 46 | |
47 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/hw/intc/arm_gicv3_its.c | 49 | --- a/include/hw/arm/exynos4210.h |
36 | +++ b/hw/intc/arm_gicv3_its.c | 50 | +++ b/include/hw/arm/exynos4210.h |
37 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 51 | @@ -XXX,XX +XXX,XX @@ |
38 | uint64_t itel; | 52 | |
39 | } IteEntry; | 53 | /* |
54 | * We need one splitter for every external combiner input, plus | ||
55 | - * one for every non-zero entry in combiner_grp_to_gic_id[]. | ||
56 | + * one for every non-zero entry in combiner_grp_to_gic_id[], | ||
57 | + * minus one for every external combiner ID in second or later | ||
58 | + * places in a combinermap[] line. | ||
59 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. | ||
60 | */ | ||
61 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) | ||
62 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) | ||
63 | |||
64 | typedef struct Exynos4210Irq { | ||
65 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
66 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/arm/exynos4210.c | ||
69 | +++ b/hw/arm/exynos4210.c | ||
70 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
71 | #define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
72 | ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
40 | 73 | ||
41 | +/* | 74 | +/* |
42 | + * The ITS spec permits a range of CONSTRAINED UNPREDICTABLE options | 75 | + * Some interrupt lines go to multiple combiner inputs. |
43 | + * if a command parameter is not correct. These include both "stall | 76 | + * This data structure defines those: each array element is |
44 | + * processing of the command queue" and "ignore this command, and | 77 | + * a list of combiner inputs which are connected together; |
45 | + * keep processing the queue". In our implementation we choose that | 78 | + * the one with the smallest interrupt ID value must be first. |
46 | + * memory transaction errors reading the command packet provoke a | 79 | + * As with combiner_grp_to_gic_id[], we rely on (0, 0) not being |
47 | + * stall, but errors in parameters cause us to ignore the command | 80 | + * wired to anything so we can use 0 as a terminator. |
48 | + * and continue processing. | ||
49 | + * The process_* functions which handle individual ITS commands all | ||
50 | + * return an ItsCmdResult which tells process_cmdq() whether it should | ||
51 | + * stall or keep going. | ||
52 | + */ | 81 | + */ |
53 | +typedef enum ItsCmdResult { | 82 | +#define IRQNO(G, B) EXYNOS4210_COMBINER_GET_IRQ_NUM(G, B) |
54 | + CMD_STALL = 0, | 83 | +#define IRQNONE 0 |
55 | + CMD_CONTINUE = 1, | 84 | + |
56 | +} ItsCmdResult; | 85 | +#define COMBINERMAP_SIZE 16 |
57 | + | 86 | + |
58 | static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz) | 87 | +static const int combinermap[COMBINERMAP_SIZE][6] = { |
59 | { | 88 | + /* MDNIE_LCD1 */ |
60 | uint64_t result = 0; | 89 | + { IRQNO(0, 4), IRQNO(1, 0), IRQNONE }, |
61 | @@ -XXX,XX +XXX,XX @@ static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res) | 90 | + { IRQNO(0, 5), IRQNO(1, 1), IRQNONE }, |
62 | * 3. handling of ITS CLEAR command | 91 | + { IRQNO(0, 6), IRQNO(1, 2), IRQNONE }, |
63 | * 4. handling of ITS DISCARD command | 92 | + { IRQNO(0, 7), IRQNO(1, 3), IRQNONE }, |
64 | */ | 93 | + /* TMU */ |
65 | -static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 94 | + { IRQNO(2, 4), IRQNO(3, 4), IRQNONE }, |
66 | - ItsCmdType cmd) | 95 | + { IRQNO(2, 5), IRQNO(3, 5), IRQNONE }, |
67 | +static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value, | 96 | + { IRQNO(2, 6), IRQNO(3, 6), IRQNONE }, |
68 | + uint32_t offset, ItsCmdType cmd) | 97 | + { IRQNO(2, 7), IRQNO(3, 7), IRQNONE }, |
69 | { | 98 | + /* LCD1 */ |
70 | AddressSpace *as = &s->gicv3->dma_as; | 99 | + { IRQNO(11, 4), IRQNO(12, 0), IRQNONE }, |
71 | uint32_t devid, eventid; | 100 | + { IRQNO(11, 5), IRQNO(12, 1), IRQNONE }, |
72 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 101 | + { IRQNO(11, 6), IRQNO(12, 2), IRQNONE }, |
73 | bool ite_valid = false; | 102 | + { IRQNO(11, 7), IRQNO(12, 3), IRQNONE }, |
74 | uint64_t cte = 0; | 103 | + /* Multi-core timer */ |
75 | bool cte_valid = false; | 104 | + { IRQNO(1, 4), IRQNO(12, 4), IRQNO(35, 4), IRQNO(51, 4), IRQNO(53, 4), IRQNONE }, |
76 | - bool result = false; | 105 | + { IRQNO(1, 5), IRQNO(12, 5), IRQNO(35, 5), IRQNO(51, 5), IRQNO(53, 5), IRQNONE }, |
77 | + ItsCmdResult result = CMD_STALL; | 106 | + { IRQNO(1, 6), IRQNO(12, 6), IRQNO(35, 6), IRQNO(51, 6), IRQNO(53, 6), IRQNONE }, |
78 | uint64_t rdbase; | 107 | + { IRQNO(1, 7), IRQNO(12, 7), IRQNO(35, 7), IRQNO(51, 7), IRQNO(53, 7), IRQNONE }, |
79 | 108 | +}; | |
80 | if (cmd == NONE) { | 109 | + |
81 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 110 | +#undef IRQNO |
82 | if (cmd == DISCARD) { | 111 | + |
83 | IteEntry ite = {}; | 112 | +static const int *combinermap_entry(int irq) |
84 | /* remove mapping from interrupt translation table */ | 113 | +{ |
85 | - result = update_ite(s, eventid, dte, ite); | 114 | + /* |
86 | + result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | 115 | + * If the interrupt number passed in is the first entry in some |
116 | + * line of the combinermap, return a pointer to that line; | ||
117 | + * otherwise return NULL. | ||
118 | + */ | ||
119 | + int i; | ||
120 | + for (i = 0; i < COMBINERMAP_SIZE; i++) { | ||
121 | + if (combinermap[i][0] == irq) { | ||
122 | + return combinermap[i]; | ||
123 | + } | ||
124 | + } | ||
125 | + return NULL; | ||
126 | +} | ||
127 | + | ||
128 | +static int mapline_size(const int *mapline) | ||
129 | +{ | ||
130 | + /* Return number of entries in this mapline in total */ | ||
131 | + int i = 0; | ||
132 | + | ||
133 | + if (!mapline) { | ||
134 | + /* Not in the map? IRQ goes to exactly one combiner input */ | ||
135 | + return 1; | ||
136 | + } | ||
137 | + while (*mapline != IRQNONE) { | ||
138 | + mapline++; | ||
139 | + i++; | ||
140 | + } | ||
141 | + return i; | ||
142 | +} | ||
143 | + | ||
144 | /* | ||
145 | * Initialize board IRQs. | ||
146 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
147 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
148 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
149 | int splitcount = 0; | ||
150 | DeviceState *splitter; | ||
151 | + const int *mapline; | ||
152 | + int numlines, splitin, in; | ||
153 | |||
154 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
155 | irq_id = 0; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
157 | irq_id = EXT_GIC_ID_MCT_G1; | ||
158 | } | ||
159 | |||
160 | + if (s->irq_table[n]) { | ||
161 | + /* | ||
162 | + * This must be some non-first entry in a combinermap line, | ||
163 | + * and we've already filled it in. | ||
164 | + */ | ||
165 | + continue; | ||
166 | + } | ||
167 | + mapline = combinermap_entry(n); | ||
168 | + /* | ||
169 | + * We need to connect the IRQ to multiple inputs on both combiners | ||
170 | + * and possibly also to the external GIC. | ||
171 | + */ | ||
172 | + numlines = 2 * mapline_size(mapline); | ||
173 | + if (irq_id) { | ||
174 | + numlines++; | ||
175 | + } | ||
176 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
177 | splitter = DEVICE(&s->splitter[splitcount]); | ||
178 | - qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2); | ||
179 | + qdev_prop_set_uint16(splitter, "num-lines", numlines); | ||
180 | qdev_realize(splitter, NULL, &error_abort); | ||
181 | splitcount++; | ||
182 | - s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
183 | - qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
184 | - qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
185 | + | ||
186 | + in = n; | ||
187 | + splitin = 0; | ||
188 | + for (;;) { | ||
189 | + s->irq_table[in] = qdev_get_gpio_in(splitter, 0); | ||
190 | + qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]); | ||
191 | + qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]); | ||
192 | + splitin += 2; | ||
193 | + if (!mapline) { | ||
194 | + break; | ||
195 | + } | ||
196 | + mapline++; | ||
197 | + in = *mapline; | ||
198 | + if (in == IRQNONE) { | ||
199 | + break; | ||
200 | + } | ||
201 | + } | ||
202 | if (irq_id) { | ||
203 | - qdev_connect_gpio_out(splitter, 2, | ||
204 | + qdev_connect_gpio_out(splitter, splitin, | ||
205 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
87 | } | 206 | } |
88 | } | 207 | } |
89 | 208 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | |
90 | return result; | 209 | irq_id = combiner_grp_to_gic_id[grp - |
91 | } | 210 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; |
92 | 211 | ||
93 | -static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | 212 | + if (s->irq_table[n]) { |
94 | - bool ignore_pInt) | 213 | + /* |
95 | +static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value, | 214 | + * This must be some non-first entry in a combinermap line, |
96 | + uint32_t offset, bool ignore_pInt) | 215 | + * and we've already filled it in. |
216 | + */ | ||
217 | + continue; | ||
218 | + } | ||
219 | + | ||
220 | if (irq_id) { | ||
221 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
222 | splitter = DEVICE(&s->splitter[splitcount]); | ||
223 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
224 | DeviceState *dev, int ext) | ||
97 | { | 225 | { |
98 | AddressSpace *as = &s->gicv3->dma_as; | 226 | int n; |
99 | uint32_t devid, eventid; | 227 | - int bit; |
100 | @@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | 228 | int max; |
101 | MemTxResult res = MEMTX_OK; | 229 | qemu_irq *irq; |
102 | uint16_t icid = 0; | 230 | |
103 | uint64_t dte = 0; | 231 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, |
104 | - bool result = false; | 232 | EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; |
105 | + ItsCmdResult result = CMD_STALL; | 233 | irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; |
106 | 234 | ||
107 | devid = ((value & DEVID_MASK) >> DEVID_SHIFT); | 235 | - /* |
108 | offset += NUM_BYTES_IN_DW; | 236 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, |
109 | @@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset, | 237 | - * so let split them. |
110 | ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS); | 238 | - */ |
111 | ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid); | 239 | for (n = 0; n < max; n++) { |
112 | 240 | - | |
113 | - result = update_ite(s, eventid, dte, ite); | 241 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); |
114 | + result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL; | 242 | - |
115 | } | 243 | - switch (n) { |
116 | 244 | - /* MDNIE_LCD1 INTG1 */ | |
117 | return result; | 245 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... |
118 | @@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid, | 246 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): |
247 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
248 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
249 | - continue; | ||
250 | - | ||
251 | - /* TMU INTG3 */ | ||
252 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
253 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
254 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
255 | - continue; | ||
256 | - | ||
257 | - /* LCD1 INTG12 */ | ||
258 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
259 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
260 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
261 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
262 | - continue; | ||
263 | - | ||
264 | - /* Multi-Core Timer INTG12 */ | ||
265 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
266 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
267 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
268 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
269 | - continue; | ||
270 | - | ||
271 | - /* Multi-Core Timer INTG35 */ | ||
272 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
273 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
274 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
275 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
276 | - continue; | ||
277 | - | ||
278 | - /* Multi-Core Timer INTG51 */ | ||
279 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
280 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
281 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
282 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
283 | - continue; | ||
284 | - | ||
285 | - /* Multi-Core Timer INTG53 */ | ||
286 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
287 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
288 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
289 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
290 | - continue; | ||
291 | - } | ||
292 | - | ||
293 | irq[n] = qdev_get_gpio_in(dev, n); | ||
119 | } | 294 | } |
120 | } | 295 | } |
121 | |||
122 | -static bool process_mapc(GICv3ITSState *s, uint32_t offset) | ||
123 | +static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset) | ||
124 | { | ||
125 | AddressSpace *as = &s->gicv3->dma_as; | ||
126 | uint16_t icid; | ||
127 | uint64_t rdbase; | ||
128 | bool valid; | ||
129 | MemTxResult res = MEMTX_OK; | ||
130 | - bool result = false; | ||
131 | + ItsCmdResult result = CMD_STALL; | ||
132 | uint64_t value; | ||
133 | |||
134 | offset += NUM_BYTES_IN_DW; | ||
135 | @@ -XXX,XX +XXX,XX @@ static bool process_mapc(GICv3ITSState *s, uint32_t offset) | ||
136 | * command in the queue | ||
137 | */ | ||
138 | } else { | ||
139 | - result = update_cte(s, icid, valid, rdbase); | ||
140 | + result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL; | ||
141 | } | ||
142 | |||
143 | return result; | ||
144 | @@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid, | ||
145 | } | ||
146 | } | ||
147 | |||
148 | -static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset) | ||
149 | +static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value, | ||
150 | + uint32_t offset) | ||
151 | { | ||
152 | AddressSpace *as = &s->gicv3->dma_as; | ||
153 | uint32_t devid; | ||
154 | @@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset) | ||
155 | uint64_t itt_addr; | ||
156 | bool valid; | ||
157 | MemTxResult res = MEMTX_OK; | ||
158 | - bool result = false; | ||
159 | + ItsCmdResult result = CMD_STALL; | ||
160 | |||
161 | devid = ((value & DEVID_MASK) >> DEVID_SHIFT); | ||
162 | |||
163 | @@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset) | ||
164 | * command in the queue | ||
165 | */ | ||
166 | } else { | ||
167 | - result = update_dte(s, devid, valid, size, itt_addr); | ||
168 | + result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL; | ||
169 | } | ||
170 | |||
171 | return result; | ||
172 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
173 | uint64_t data; | ||
174 | AddressSpace *as = &s->gicv3->dma_as; | ||
175 | MemTxResult res = MEMTX_OK; | ||
176 | - bool result = true; | ||
177 | uint8_t cmd; | ||
178 | int i; | ||
179 | |||
180 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
181 | } | ||
182 | |||
183 | while (wr_offset != rd_offset) { | ||
184 | + ItsCmdResult result = CMD_CONTINUE; | ||
185 | + | ||
186 | cq_offset = (rd_offset * GITS_CMDQ_ENTRY_SIZE); | ||
187 | data = address_space_ldq_le(as, s->cq.base_addr + cq_offset, | ||
188 | MEMTXATTRS_UNSPECIFIED, &res); | ||
189 | @@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s) | ||
190 | default: | ||
191 | break; | ||
192 | } | ||
193 | - if (result) { | ||
194 | + if (result == CMD_CONTINUE) { | ||
195 | rd_offset++; | ||
196 | rd_offset %= s->cq.num_entries; | ||
197 | s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, OFFSET, rd_offset); | ||
198 | } else { | ||
199 | - /* | ||
200 | - * in this implementation, in case of dma read/write error | ||
201 | - * we stall the command processing | ||
202 | - */ | ||
203 | + /* CMD_STALL */ | ||
204 | s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1); | ||
205 | qemu_log_mask(LOG_GUEST_ERROR, | ||
206 | - "%s: %x cmd processing failed\n", __func__, cmd); | ||
207 | + "%s: 0x%x cmd processing failed, stalling\n", | ||
208 | + __func__, cmd); | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | -- | 296 | -- |
213 | 2.25.1 | 297 | 2.25.1 |
214 | |||
215 | diff view generated by jsdifflib |
1 | Fix process_mapc() to consistently return CMD_STALL for memory | 1 | Switch the creation of the combiner devices to the new-style |
---|---|---|---|
2 | errors and CMD_CONTINUE for parameter errors, as we claim in the | 2 | "embedded in state struct" approach, so we can easily refer |
3 | comments that we do. | 3 | to the object elsewhere during realize. |
4 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20220111171048.3545974-10-peter.maydell@linaro.org | 7 | Message-id: 20220404154658.565020-18-peter.maydell@linaro.org |
9 | --- | 8 | --- |
10 | hw/intc/arm_gicv3_its.c | 8 +++----- | 9 | include/hw/arm/exynos4210.h | 3 ++ |
11 | 1 file changed, 3 insertions(+), 5 deletions(-) | 10 | include/hw/intc/exynos4210_combiner.h | 57 +++++++++++++++++++++++++++ |
11 | hw/arm/exynos4210.c | 20 +++++----- | ||
12 | hw/intc/exynos4210_combiner.c | 31 +-------------- | ||
13 | 4 files changed, 72 insertions(+), 39 deletions(-) | ||
14 | create mode 100644 include/hw/intc/exynos4210_combiner.h | ||
12 | 15 | ||
13 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/arm_gicv3_its.c | 18 | --- a/include/hw/arm/exynos4210.h |
16 | +++ b/hw/intc/arm_gicv3_its.c | 19 | +++ b/include/hw/arm/exynos4210.h |
17 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset) | 20 | @@ -XXX,XX +XXX,XX @@ |
18 | uint64_t rdbase; | 21 | #include "hw/sysbus.h" |
19 | bool valid; | 22 | #include "hw/cpu/a9mpcore.h" |
20 | MemTxResult res = MEMTX_OK; | 23 | #include "hw/intc/exynos4210_gic.h" |
21 | - ItsCmdResult result = CMD_STALL; | 24 | +#include "hw/intc/exynos4210_combiner.h" |
22 | uint64_t value; | 25 | #include "hw/core/split-irq.h" |
23 | 26 | #include "target/arm/cpu-qom.h" | |
24 | offset += NUM_BYTES_IN_DW; | 27 | #include "qom/object.h" |
25 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset) | 28 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { |
26 | MEMTXATTRS_UNSPECIFIED, &res); | 29 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; |
27 | 30 | A9MPPrivState a9mpcore; | |
28 | if (res != MEMTX_OK) { | 31 | Exynos4210GicState ext_gic; |
29 | - return result; | 32 | + Exynos4210CombinerState int_combiner; |
30 | + return CMD_STALL; | 33 | + Exynos4210CombinerState ext_combiner; |
34 | SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS]; | ||
35 | }; | ||
36 | |||
37 | diff --git a/include/hw/intc/exynos4210_combiner.h b/include/hw/intc/exynos4210_combiner.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/intc/exynos4210_combiner.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | +/* | ||
44 | + * Samsung exynos4210 Interrupt Combiner | ||
45 | + * | ||
46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. | ||
47 | + * All rights reserved. | ||
48 | + * | ||
49 | + * Evgeny Voevodin <e.voevodin@samsung.com> | ||
50 | + * | ||
51 | + * This program is free software; you can redistribute it and/or modify it | ||
52 | + * under the terms of the GNU General Public License as published by the | ||
53 | + * Free Software Foundation; either version 2 of the License, or (at your | ||
54 | + * option) any later version. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, | ||
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
59 | + * See the GNU General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License along | ||
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
63 | + */ | ||
64 | + | ||
65 | +#ifndef HW_INTC_EXYNOS4210_COMBINER | ||
66 | +#define HW_INTC_EXYNOS4210_COMBINER | ||
67 | + | ||
68 | +#include "hw/sysbus.h" | ||
69 | + | ||
70 | +/* | ||
71 | + * State for each output signal of internal combiner | ||
72 | + */ | ||
73 | +typedef struct CombinerGroupState { | ||
74 | + uint8_t src_mask; /* 1 - source enabled, 0 - disabled */ | ||
75 | + uint8_t src_pending; /* Pending source interrupts before masking */ | ||
76 | +} CombinerGroupState; | ||
77 | + | ||
78 | +#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner" | ||
79 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER) | ||
80 | + | ||
81 | +/* Number of groups and total number of interrupts for the internal combiner */ | ||
82 | +#define IIC_NGRP 64 | ||
83 | +#define IIC_NIRQ (IIC_NGRP * 8) | ||
84 | +#define IIC_REGSET_SIZE 0x41 | ||
85 | + | ||
86 | +struct Exynos4210CombinerState { | ||
87 | + SysBusDevice parent_obj; | ||
88 | + | ||
89 | + MemoryRegion iomem; | ||
90 | + | ||
91 | + struct CombinerGroupState group[IIC_NGRP]; | ||
92 | + uint32_t reg_set[IIC_REGSET_SIZE]; | ||
93 | + uint32_t icipsr[2]; | ||
94 | + uint32_t external; /* 1 means that this combiner is external */ | ||
95 | + | ||
96 | + qemu_irq output_irq[IIC_NGRP]; | ||
97 | +}; | ||
98 | + | ||
99 | +#endif | ||
100 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/hw/arm/exynos4210.c | ||
103 | +++ b/hw/arm/exynos4210.c | ||
104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
31 | } | 105 | } |
32 | 106 | ||
33 | icid = value & ICID_MASK; | 107 | /* Internal Interrupt Combiner */ |
34 | @@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset) | 108 | - dev = qdev_new("exynos4210.combiner"); |
35 | * we ignore this command and move onto the next | 109 | - busdev = SYS_BUS_DEVICE(dev); |
36 | * command in the queue | 110 | - sysbus_realize_and_unref(busdev, &error_fatal); |
37 | */ | 111 | + busdev = SYS_BUS_DEVICE(&s->int_combiner); |
38 | - } else { | 112 | + sysbus_realize(busdev, &error_fatal); |
39 | - result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL; | 113 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { |
40 | + return CMD_CONTINUE; | 114 | sysbus_connect_irq(busdev, n, |
115 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
41 | } | 116 | } |
42 | 117 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); | |
43 | - return result; | 118 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); |
44 | + return update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL; | 119 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); |
120 | |||
121 | /* External Interrupt Combiner */ | ||
122 | - dev = qdev_new("exynos4210.combiner"); | ||
123 | - qdev_prop_set_uint32(dev, "external", 1); | ||
124 | - busdev = SYS_BUS_DEVICE(dev); | ||
125 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
126 | + qdev_prop_set_uint32(DEVICE(&s->ext_combiner), "external", 1); | ||
127 | + busdev = SYS_BUS_DEVICE(&s->ext_combiner); | ||
128 | + sysbus_realize(busdev, &error_fatal); | ||
129 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
130 | sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
131 | } | ||
132 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); | ||
133 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); | ||
134 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
135 | |||
136 | /* Initialize board IRQs. */ | ||
137 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
138 | |||
139 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
140 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
141 | + object_initialize_child(obj, "int-combiner", &s->int_combiner, | ||
142 | + TYPE_EXYNOS4210_COMBINER); | ||
143 | + object_initialize_child(obj, "ext-combiner", &s->ext_combiner, | ||
144 | + TYPE_EXYNOS4210_COMBINER); | ||
45 | } | 145 | } |
46 | 146 | ||
47 | static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid, | 147 | static void exynos4210_class_init(ObjectClass *klass, void *data) |
148 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/hw/intc/exynos4210_combiner.c | ||
151 | +++ b/hw/intc/exynos4210_combiner.c | ||
152 | @@ -XXX,XX +XXX,XX @@ | ||
153 | #include "hw/sysbus.h" | ||
154 | #include "migration/vmstate.h" | ||
155 | #include "qemu/module.h" | ||
156 | - | ||
157 | +#include "hw/intc/exynos4210_combiner.h" | ||
158 | #include "hw/arm/exynos4210.h" | ||
159 | #include "hw/hw.h" | ||
160 | #include "hw/irq.h" | ||
161 | @@ -XXX,XX +XXX,XX @@ | ||
162 | #define DPRINTF(fmt, ...) do {} while (0) | ||
163 | #endif | ||
164 | |||
165 | -#define IIC_NGRP 64 /* Internal Interrupt Combiner | ||
166 | - Groups number */ | ||
167 | -#define IIC_NIRQ (IIC_NGRP * 8)/* Internal Interrupt Combiner | ||
168 | - Interrupts number */ | ||
169 | #define IIC_REGION_SIZE 0x108 /* Size of memory mapped region */ | ||
170 | -#define IIC_REGSET_SIZE 0x41 | ||
171 | - | ||
172 | -/* | ||
173 | - * State for each output signal of internal combiner | ||
174 | - */ | ||
175 | -typedef struct CombinerGroupState { | ||
176 | - uint8_t src_mask; /* 1 - source enabled, 0 - disabled */ | ||
177 | - uint8_t src_pending; /* Pending source interrupts before masking */ | ||
178 | -} CombinerGroupState; | ||
179 | - | ||
180 | -#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner" | ||
181 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER) | ||
182 | - | ||
183 | -struct Exynos4210CombinerState { | ||
184 | - SysBusDevice parent_obj; | ||
185 | - | ||
186 | - MemoryRegion iomem; | ||
187 | - | ||
188 | - struct CombinerGroupState group[IIC_NGRP]; | ||
189 | - uint32_t reg_set[IIC_REGSET_SIZE]; | ||
190 | - uint32_t icipsr[2]; | ||
191 | - uint32_t external; /* 1 means that this combiner is external */ | ||
192 | - | ||
193 | - qemu_irq output_irq[IIC_NGRP]; | ||
194 | -}; | ||
195 | |||
196 | static const VMStateDescription vmstate_exynos4210_combiner_group_state = { | ||
197 | .name = "exynos4210.combiner.groupstate", | ||
48 | -- | 198 | -- |
49 | 2.25.1 | 199 | 2.25.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Yanan Wang <wangyanan55@huawei.com> | 1 | The only time we use the int_combiner_irq[] and ext_combiner_irq[] |
---|---|---|---|
2 | arrays in the Exynos4210Irq struct is during realize of the SoC -- we | ||
3 | initialize them with the input IRQs of the combiner devices, and then | ||
4 | connect those to outputs of other devices in | ||
5 | exynos4210_init_board_irqs(). Now that the combiner objects are | ||
6 | easily accessible as s->int_combiner and s->ext_combiner we can make | ||
7 | the connections directly from one device to the other without going | ||
8 | via these arrays. | ||
2 | 9 | ||
3 | Use g_queue APIs to reduce the nested loops and code indentation | 10 | Since these are the only two remaining elements of Exynos4210Irq, |
4 | with the processor hierarchy levels increasing. Consenquently, | 11 | we can remove that struct entirely. |
5 | it's more scalable to add new topology level to build_pptt. | ||
6 | 12 | ||
7 | No functional change intended. | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20220404154658.565020-19-peter.maydell@linaro.org | ||
16 | --- | ||
17 | include/hw/arm/exynos4210.h | 6 ------ | ||
18 | hw/arm/exynos4210.c | 34 ++++++++-------------------------- | ||
19 | 2 files changed, 8 insertions(+), 32 deletions(-) | ||
8 | 20 | ||
9 | Signed-off-by: Yanan Wang <wangyanan55@huawei.com> | 21 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
10 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
11 | Message-id: 20220107083232.16256-4-wangyanan55@huawei.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/acpi/aml-build.c | 50 +++++++++++++++++++++++++++++---------------- | ||
15 | 1 file changed, 32 insertions(+), 18 deletions(-) | ||
16 | |||
17 | diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/acpi/aml-build.c | 23 | --- a/include/hw/arm/exynos4210.h |
20 | +++ b/hw/acpi/aml-build.c | 24 | +++ b/include/hw/arm/exynos4210.h |
21 | @@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags, | 25 | @@ -XXX,XX +XXX,XX @@ |
22 | void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, | 26 | */ |
23 | const char *oem_id, const char *oem_table_id) | 27 | #define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) |
28 | |||
29 | -typedef struct Exynos4210Irq { | ||
30 | - qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
31 | - qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
32 | -} Exynos4210Irq; | ||
33 | - | ||
34 | struct Exynos4210State { | ||
35 | /*< private >*/ | ||
36 | SysBusDevice parent_obj; | ||
37 | /*< public >*/ | ||
38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | ||
39 | - Exynos4210Irq irqs; | ||
40 | qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
41 | |||
42 | MemoryRegion chipid_mem; | ||
43 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/arm/exynos4210.c | ||
46 | +++ b/hw/arm/exynos4210.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static int mapline_size(const int *mapline) | ||
48 | static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
24 | { | 49 | { |
25 | - int pptt_start = table_data->len; | 50 | uint32_t grp, bit, irq_id, n; |
26 | + GQueue *list = g_queue_new(); | 51 | - Exynos4210Irq *is = &s->irqs; |
27 | + guint pptt_start = table_data->len; | 52 | DeviceState *extgicdev = DEVICE(&s->ext_gic); |
28 | + guint parent_offset; | 53 | + DeviceState *intcdev = DEVICE(&s->int_combiner); |
29 | + guint length, i; | 54 | + DeviceState *extcdev = DEVICE(&s->ext_combiner); |
30 | int uid = 0; | 55 | int splitcount = 0; |
31 | int socket; | 56 | DeviceState *splitter; |
32 | AcpiTable table = { .sig = "PPTT", .rev = 2, | 57 | const int *mapline; |
33 | @@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, | 58 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
34 | acpi_table_begin(&table, table_data); | 59 | splitin = 0; |
35 | 60 | for (;;) { | |
36 | for (socket = 0; socket < ms->smp.sockets; socket++) { | 61 | s->irq_table[in] = qdev_get_gpio_in(splitter, 0); |
37 | - uint32_t socket_offset = table_data->len - pptt_start; | 62 | - qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]); |
38 | - int core; | 63 | - qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]); |
39 | - | 64 | + qdev_connect_gpio_out(splitter, splitin, |
40 | + g_queue_push_tail(list, | 65 | + qdev_get_gpio_in(intcdev, in)); |
41 | + GUINT_TO_POINTER(table_data->len - pptt_start)); | 66 | + qdev_connect_gpio_out(splitter, splitin + 1, |
42 | build_processor_hierarchy_node( | 67 | + qdev_get_gpio_in(extcdev, in)); |
43 | table_data, | 68 | splitin += 2; |
44 | /* | 69 | if (!mapline) { |
45 | @@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, | 70 | break; |
46 | */ | 71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
47 | (1 << 0), | 72 | qdev_realize(splitter, NULL, &error_abort); |
48 | 0, socket, NULL, 0); | 73 | splitcount++; |
49 | + } | 74 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); |
50 | 75 | - qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | |
51 | + length = g_queue_get_length(list); | 76 | + qdev_connect_gpio_out(splitter, 0, qdev_get_gpio_in(intcdev, n)); |
52 | + for (i = 0; i < length; i++) { | 77 | qdev_connect_gpio_out(splitter, 1, |
53 | + int core; | 78 | qdev_get_gpio_in(extgicdev, irq_id - 32)); |
54 | + | 79 | } else { |
55 | + parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | 80 | - s->irq_table[n] = is->int_combiner_irq[n]; |
56 | for (core = 0; core < ms->smp.cores; core++) { | 81 | + s->irq_table[n] = qdev_get_gpio_in(intcdev, n); |
57 | - uint32_t core_offset = table_data->len - pptt_start; | ||
58 | - int thread; | ||
59 | - | ||
60 | if (ms->smp.threads > 1) { | ||
61 | + g_queue_push_tail(list, | ||
62 | + GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
63 | build_processor_hierarchy_node( | ||
64 | table_data, | ||
65 | (0 << 0), /* not a physical package */ | ||
66 | - socket_offset, core, NULL, 0); | ||
67 | - | ||
68 | - for (thread = 0; thread < ms->smp.threads; thread++) { | ||
69 | - build_processor_hierarchy_node( | ||
70 | - table_data, | ||
71 | - (1 << 1) | /* ACPI Processor ID valid */ | ||
72 | - (1 << 2) | /* Processor is a Thread */ | ||
73 | - (1 << 3), /* Node is a Leaf */ | ||
74 | - core_offset, uid++, NULL, 0); | ||
75 | - } | ||
76 | + parent_offset, core, NULL, 0); | ||
77 | } else { | ||
78 | build_processor_hierarchy_node( | ||
79 | table_data, | ||
80 | (1 << 1) | /* ACPI Processor ID valid */ | ||
81 | (1 << 3), /* Node is a Leaf */ | ||
82 | - socket_offset, uid++, NULL, 0); | ||
83 | + parent_offset, uid++, NULL, 0); | ||
84 | } | ||
85 | } | 82 | } |
86 | } | 83 | } |
87 | 84 | /* | |
88 | + length = g_queue_get_length(list); | 85 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) |
89 | + for (i = 0; i < length; i++) { | 86 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); |
90 | + int thread; | ||
91 | + | ||
92 | + parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
93 | + for (thread = 0; thread < ms->smp.threads; thread++) { | ||
94 | + build_processor_hierarchy_node( | ||
95 | + table_data, | ||
96 | + (1 << 1) | /* ACPI Processor ID valid */ | ||
97 | + (1 << 2) | /* Processor is a Thread */ | ||
98 | + (1 << 3), /* Node is a Leaf */ | ||
99 | + parent_offset, uid++, NULL, 0); | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + g_queue_free(list); | ||
104 | acpi_table_end(linker, &table); | ||
105 | } | 87 | } |
106 | 88 | ||
89 | -/* | ||
90 | - * Get Combiner input GPIO into irqs structure | ||
91 | - */ | ||
92 | -static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
93 | - DeviceState *dev, int ext) | ||
94 | -{ | ||
95 | - int n; | ||
96 | - int max; | ||
97 | - qemu_irq *irq; | ||
98 | - | ||
99 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
100 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
101 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
102 | - | ||
103 | - for (n = 0; n < max; n++) { | ||
104 | - irq[n] = qdev_get_gpio_in(dev, n); | ||
105 | - } | ||
106 | -} | ||
107 | - | ||
108 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
109 | 0x09, 0x00, 0x00, 0x00 }; | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
112 | sysbus_connect_irq(busdev, n, | ||
113 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
114 | } | ||
115 | - exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); | ||
116 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
117 | |||
118 | /* External Interrupt Combiner */ | ||
119 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
120 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
121 | sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
122 | } | ||
123 | - exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); | ||
124 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
125 | |||
126 | /* Initialize board IRQs. */ | ||
107 | -- | 127 | -- |
108 | 2.25.1 | 128 | 2.25.1 |
109 | |||
110 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Yanan Wang <wangyanan55@huawei.com> | ||
2 | 1 | ||
3 | List test/data/acpi/virt/PPTT as the expected files allowed to | ||
4 | be changed in tests/qtest/bios-tables-test-allowed-diff.h | ||
5 | |||
6 | Signed-off-by: Yanan Wang <wangyanan55@huawei.com> | ||
7 | Acked-by: Ani Sinha <ani@anisinha.ca> | ||
8 | Message-id: 20220107083232.16256-5-wangyanan55@huawei.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | tests/qtest/bios-tables-test-allowed-diff.h | 1 + | ||
12 | 1 file changed, 1 insertion(+) | ||
13 | |||
14 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | ||
17 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | ||
18 | @@ -1 +1,2 @@ | ||
19 | /* List of comma-separated changed AML files to ignore */ | ||
20 | +"tests/data/acpi/virt/PPTT", | ||
21 | -- | ||
22 | 2.25.1 | ||
23 | |||
24 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Yanan Wang <wangyanan55@huawei.com> | ||
2 | 1 | ||
3 | Support CPU cluster topology level in generation of ACPI | ||
4 | Processor Properties Topology Table (PPTT). | ||
5 | |||
6 | Signed-off-by: Yanan Wang <wangyanan55@huawei.com> | ||
7 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
8 | Message-id: 20220107083232.16256-6-wangyanan55@huawei.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/acpi/aml-build.c | 18 ++++++++++++++++++ | ||
12 | 1 file changed, 18 insertions(+) | ||
13 | |||
14 | diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/acpi/aml-build.c | ||
17 | +++ b/hw/acpi/aml-build.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags, | ||
19 | void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, | ||
20 | const char *oem_id, const char *oem_table_id) | ||
21 | { | ||
22 | + MachineClass *mc = MACHINE_GET_CLASS(ms); | ||
23 | GQueue *list = g_queue_new(); | ||
24 | guint pptt_start = table_data->len; | ||
25 | guint parent_offset; | ||
26 | @@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, | ||
27 | 0, socket, NULL, 0); | ||
28 | } | ||
29 | |||
30 | + if (mc->smp_props.clusters_supported) { | ||
31 | + length = g_queue_get_length(list); | ||
32 | + for (i = 0; i < length; i++) { | ||
33 | + int cluster; | ||
34 | + | ||
35 | + parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
36 | + for (cluster = 0; cluster < ms->smp.clusters; cluster++) { | ||
37 | + g_queue_push_tail(list, | ||
38 | + GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
39 | + build_processor_hierarchy_node( | ||
40 | + table_data, | ||
41 | + (0 << 0), /* not a physical package */ | ||
42 | + parent_offset, cluster, NULL, 0); | ||
43 | + } | ||
44 | + } | ||
45 | + } | ||
46 | + | ||
47 | length = g_queue_get_length(list); | ||
48 | for (i = 0; i < length; i++) { | ||
49 | int core; | ||
50 | -- | ||
51 | 2.25.1 | ||
52 | |||
53 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Yanan Wang <wangyanan55@huawei.com> | ||
2 | 1 | ||
3 | Run ./tests/data/acpi/rebuild-expected-aml.sh from build directory | ||
4 | to update PPTT binary. Also empty bios-tables-test-allowed-diff.h. | ||
5 | |||
6 | The disassembled differences between actual and expected PPTT: | ||
7 | |||
8 | /* | ||
9 | * Intel ACPI Component Architecture | ||
10 | * AML/ASL+ Disassembler version 20200528 (64-bit version) | ||
11 | * Copyright (c) 2000 - 2020 Intel Corporation | ||
12 | * | ||
13 | - * Disassembly of tests/data/acpi/virt/PPTT, Tue Jan 4 12:51:11 2022 | ||
14 | + * Disassembly of /tmp/aml-2ZGOF1, Tue Jan 4 12:51:11 2022 | ||
15 | * | ||
16 | * ACPI Data Table [PPTT] | ||
17 | * | ||
18 | * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue | ||
19 | */ | ||
20 | |||
21 | [000h 0000 4] Signature : "PPTT" [Processor Properties Topology Table] | ||
22 | -[004h 0004 4] Table Length : 0000004C | ||
23 | +[004h 0004 4] Table Length : 00000060 | ||
24 | [008h 0008 1] Revision : 02 | ||
25 | -[009h 0009 1] Checksum : A8 | ||
26 | +[009h 0009 1] Checksum : 48 | ||
27 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
28 | [010h 0016 8] Oem Table ID : "BXPC " | ||
29 | [018h 0024 4] Oem Revision : 00000001 | ||
30 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
31 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
32 | |||
33 | [024h 0036 1] Subtable Type : 00 [Processor Hierarchy Node] | ||
34 | [025h 0037 1] Length : 14 | ||
35 | [026h 0038 2] Reserved : 0000 | ||
36 | [028h 0040 4] Flags (decoded below) : 00000001 | ||
37 | Physical package : 1 | ||
38 | ACPI Processor ID valid : 0 | ||
39 | Processor is a thread : 0 | ||
40 | Node is a leaf : 0 | ||
41 | Identical Implementation : 0 | ||
42 | [02Ch 0044 4] Parent : 00000000 | ||
43 | [030h 0048 4] ACPI Processor ID : 00000000 | ||
44 | [034h 0052 4] Private Resource Number : 00000000 | ||
45 | |||
46 | [038h 0056 1] Subtable Type : 00 [Processor Hierarchy Node] | ||
47 | [039h 0057 1] Length : 14 | ||
48 | [03Ah 0058 2] Reserved : 0000 | ||
49 | -[03Ch 0060 4] Flags (decoded below) : 0000000A | ||
50 | +[03Ch 0060 4] Flags (decoded below) : 00000000 | ||
51 | Physical package : 0 | ||
52 | - ACPI Processor ID valid : 1 | ||
53 | + ACPI Processor ID valid : 0 | ||
54 | Processor is a thread : 0 | ||
55 | - Node is a leaf : 1 | ||
56 | + Node is a leaf : 0 | ||
57 | Identical Implementation : 0 | ||
58 | [040h 0064 4] Parent : 00000024 | ||
59 | [044h 0068 4] ACPI Processor ID : 00000000 | ||
60 | [048h 0072 4] Private Resource Number : 00000000 | ||
61 | |||
62 | -Raw Table Data: Length 76 (0x4C) | ||
63 | +[04Ch 0076 1] Subtable Type : 00 [Processor Hierarchy Node] | ||
64 | +[04Dh 0077 1] Length : 14 | ||
65 | +[04Eh 0078 2] Reserved : 0000 | ||
66 | +[050h 0080 4] Flags (decoded below) : 0000000A | ||
67 | + Physical package : 0 | ||
68 | + ACPI Processor ID valid : 1 | ||
69 | + Processor is a thread : 0 | ||
70 | + Node is a leaf : 1 | ||
71 | + Identical Implementation : 0 | ||
72 | +[054h 0084 4] Parent : 00000038 | ||
73 | +[058h 0088 4] ACPI Processor ID : 00000000 | ||
74 | +[05Ch 0092 4] Private Resource Number : 00000000 | ||
75 | + | ||
76 | +Raw Table Data: Length 96 (0x60) | ||
77 | |||
78 | - 0000: 50 50 54 54 4C 00 00 00 02 A8 42 4F 43 48 53 20 // PPTTL.....BOCHS | ||
79 | + 0000: 50 50 54 54 60 00 00 00 02 48 42 4F 43 48 53 20 // PPTT`....HBOCHS | ||
80 | 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC | ||
81 | 0020: 01 00 00 00 00 14 00 00 01 00 00 00 00 00 00 00 // ................ | ||
82 | - 0030: 00 00 00 00 00 00 00 00 00 14 00 00 0A 00 00 00 // ................ | ||
83 | - 0040: 24 00 00 00 00 00 00 00 00 00 00 00 // $........... | ||
84 | + 0030: 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 // ................ | ||
85 | + 0040: 24 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 // $............... | ||
86 | + 0050: 0A 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 // ....8........... | ||
87 | |||
88 | Signed-off-by: Yanan Wang <wangyanan55@huawei.com> | ||
89 | Reviewed-by: Ani Sinha <ani@anisinha.ca> | ||
90 | Message-id: 20220107083232.16256-7-wangyanan55@huawei.com | ||
91 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
92 | --- | ||
93 | tests/qtest/bios-tables-test-allowed-diff.h | 1 - | ||
94 | tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes | ||
95 | 2 files changed, 1 deletion(-) | ||
96 | |||
97 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
98 | index XXXXXXX..XXXXXXX 100644 | ||
99 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | ||
100 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | ||
101 | @@ -1,2 +1 @@ | ||
102 | /* List of comma-separated changed AML files to ignore */ | ||
103 | -"tests/data/acpi/virt/PPTT", | ||
104 | diff --git a/tests/data/acpi/virt/PPTT b/tests/data/acpi/virt/PPTT | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | GIT binary patch | ||
107 | delta 53 | ||
108 | pcmeZC;0g!`2}xjJU|{l?$YrDgWH5jU5Ca567#O&Klm(arApowi1QY-O | ||
109 | |||
110 | delta 32 | ||
111 | fcmYfB;R*-{3GrcIU|?D?k;`ae01J-_kOKn%ZFdCM | ||
112 | |||
113 | -- | ||
114 | 2.25.1 | ||
115 | |||
116 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Lucas Ramage <lucas.ramage@infinite-omicron.com> | ||
2 | 1 | ||
3 | Buglink: https://gitlab.com/qemu-project/qemu/-/issues/527 | ||
4 | Signed-off-by: Lucas Ramage <lucas.ramage@infinite-omicron.com> | ||
5 | Message-id: 20220105205628.5491-1-oxr463@gmx.us | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | [PMM: Move to docs/system/devices/ rather than top-level; | ||
8 | fix a pre-existing typo in passing] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | docs/system/device-emulation.rst | 1 + | ||
12 | docs/{can.txt => system/devices/can.rst} | 90 +++++++++++------------- | ||
13 | 2 files changed, 41 insertions(+), 50 deletions(-) | ||
14 | rename docs/{can.txt => system/devices/can.rst} (68%) | ||
15 | |||
16 | diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/docs/system/device-emulation.rst | ||
19 | +++ b/docs/system/device-emulation.rst | ||
20 | @@ -XXX,XX +XXX,XX @@ Emulated Devices | ||
21 | .. toctree:: | ||
22 | :maxdepth: 1 | ||
23 | |||
24 | + devices/can.rst | ||
25 | devices/ivshmem.rst | ||
26 | devices/net.rst | ||
27 | devices/nvme.rst | ||
28 | diff --git a/docs/can.txt b/docs/system/devices/can.rst | ||
29 | similarity index 68% | ||
30 | rename from docs/can.txt | ||
31 | rename to docs/system/devices/can.rst | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/docs/can.txt | ||
34 | +++ b/docs/system/devices/can.rst | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | -QEMU CAN bus emulation support | ||
37 | -============================== | ||
38 | - | ||
39 | +CAN Bus Emulation Support | ||
40 | +========================= | ||
41 | The CAN bus emulation provides mechanism to connect multiple | ||
42 | emulated CAN controller chips together by one or multiple CAN busses | ||
43 | (the controller device "canbus" parameter). The individual busses | ||
44 | @@ -XXX,XX +XXX,XX @@ emulated environment for testing and RTEMS GSoC slot has been donated | ||
45 | to work on CAN hardware emulation on QEMU. | ||
46 | |||
47 | Examples how to use CAN emulation for SJA1000 based boards | ||
48 | -========================================================== | ||
49 | - | ||
50 | +---------------------------------------------------------- | ||
51 | When QEMU with CAN PCI support is compiled then one of the next | ||
52 | CAN boards can be selected | ||
53 | |||
54 | - (1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) boad. QEMU startup options | ||
55 | +(1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) board. QEMU startup options:: | ||
56 | + | ||
57 | -object can-bus,id=canbus0 | ||
58 | -device kvaser_pci,canbus=canbus0 | ||
59 | - Add "can-host-socketcan" object to connect device to host system CAN bus | ||
60 | + | ||
61 | +Add "can-host-socketcan" object to connect device to host system CAN bus:: | ||
62 | + | ||
63 | -object can-host-socketcan,id=canhost0,if=can0,canbus=canbus0 | ||
64 | |||
65 | - (2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation | ||
66 | +(2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation:: | ||
67 | + | ||
68 | -object can-bus,id=canbus0 | ||
69 | -device pcm3680_pci,canbus0=canbus0,canbus1=canbus0 | ||
70 | |||
71 | - another example: | ||
72 | +Another example:: | ||
73 | + | ||
74 | -object can-bus,id=canbus0 | ||
75 | -object can-bus,id=canbus1 | ||
76 | -device pcm3680_pci,canbus0=canbus0,canbus1=canbus1 | ||
77 | |||
78 | - (3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation | ||
79 | +(3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation:: | ||
80 | + | ||
81 | -device mioe3680_pci,canbus0=canbus0 | ||
82 | |||
83 | - | ||
84 | The ''kvaser_pci'' board/device model is compatible with and has been tested with | ||
85 | -''kvaser_pci'' driver included in mainline Linux kernel. | ||
86 | +the ''kvaser_pci'' driver included in mainline Linux kernel. | ||
87 | The tested setup was Linux 4.9 kernel on the host and guest side. | ||
88 | -Example for qemu-system-x86_64: | ||
89 | + | ||
90 | +Example for qemu-system-x86_64:: | ||
91 | |||
92 | qemu-system-x86_64 -accel kvm -kernel /boot/vmlinuz-4.9.0-4-amd64 \ | ||
93 | -initrd ramdisk.cpio \ | ||
94 | @@ -XXX,XX +XXX,XX @@ Example for qemu-system-x86_64: | ||
95 | -device kvaser_pci,canbus=canbus0 \ | ||
96 | -nographic -append "console=ttyS0" | ||
97 | |||
98 | -Example for qemu-system-arm: | ||
99 | +Example for qemu-system-arm:: | ||
100 | |||
101 | qemu-system-arm -cpu arm1176 -m 256 -M versatilepb \ | ||
102 | -kernel kernel-qemu-arm1176-versatilepb \ | ||
103 | @@ -XXX,XX +XXX,XX @@ Example for qemu-system-arm: | ||
104 | The CAN interface of the host system has to be configured for proper | ||
105 | bitrate and set up. Configuration is not propagated from emulated | ||
106 | devices through bus to the physical host device. Example configuration | ||
107 | -for 1 Mbit/s | ||
108 | +for 1 Mbit/s:: | ||
109 | |||
110 | ip link set can0 type can bitrate 1000000 | ||
111 | ip link set can0 up | ||
112 | |||
113 | Virtual (host local only) can interface can be used on the host | ||
114 | -side instead of physical interface | ||
115 | +side instead of physical interface:: | ||
116 | |||
117 | ip link add dev can0 type vcan | ||
118 | |||
119 | The CAN interface on the host side can be used to analyze CAN | ||
120 | -traffic with "candump" command which is included in "can-utils". | ||
121 | +traffic with "candump" command which is included in "can-utils":: | ||
122 | |||
123 | candump can0 | ||
124 | |||
125 | CTU CAN FD support examples | ||
126 | -=========================== | ||
127 | - | ||
128 | +--------------------------- | ||
129 | This open-source core provides CAN FD support. CAN FD drames are | ||
130 | delivered even to the host systems when SocketCAN interface is found | ||
131 | CAN FD capable. | ||
132 | @@ -XXX,XX +XXX,XX @@ on the board. | ||
133 | Example how to connect the canbus0-bus (virtual wire) to the host | ||
134 | Linux system (SocketCAN used) and to both CTU CAN FD cores emulated | ||
135 | on the corresponding PCI card expects that host system CAN bus | ||
136 | -is setup according to the previous SJA1000 section. | ||
137 | +is setup according to the previous SJA1000 section:: | ||
138 | |||
139 | qemu-system-x86_64 -enable-kvm -kernel /boot/vmlinuz-4.19.52+ \ | ||
140 | -initrd ramdisk.cpio \ | ||
141 | @@ -XXX,XX +XXX,XX @@ is setup according to the previous SJA1000 section. | ||
142 | -device ctucan_pci,canbus0=canbus0-bus,canbus1=canbus0-bus \ | ||
143 | -nographic | ||
144 | |||
145 | -Setup of CTU CAN FD controller in a guest Linux system | ||
146 | +Setup of CTU CAN FD controller in a guest Linux system:: | ||
147 | |||
148 | insmod ctucanfd.ko || modprobe ctucanfd | ||
149 | insmod ctucanfd_pci.ko || modprobe ctucanfd_pci | ||
150 | @@ -XXX,XX +XXX,XX @@ Setup of CTU CAN FD controller in a guest Linux system | ||
151 | /bin/ip link set $ifc up | ||
152 | done | ||
153 | |||
154 | -The test can run for example | ||
155 | +The test can run for example:: | ||
156 | |||
157 | candump can1 | ||
158 | |||
159 | -in the guest system and next commands in the host system for basic CAN | ||
160 | +in the guest system and next commands in the host system for basic CAN:: | ||
161 | |||
162 | cangen can0 | ||
163 | |||
164 | -for CAN FD without bitrate switch | ||
165 | +for CAN FD without bitrate switch:: | ||
166 | |||
167 | cangen can0 -f | ||
168 | |||
169 | -and with bitrate switch | ||
170 | +and with bitrate switch:: | ||
171 | |||
172 | cangen can0 -b | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ The test can be run viceversa, generate messages in the guest system and capture | ||
175 | in the host one and much more combinations. | ||
176 | |||
177 | Links to other resources | ||
178 | -======================== | ||
179 | +------------------------ | ||
180 | |||
181 | - (1) CAN related projects at Czech Technical University, Faculty of Electrical Engineering | ||
182 | - http://canbus.pages.fel.cvut.cz/ | ||
183 | - (2) Repository with development can-pci branch at Czech Technical University | ||
184 | - https://gitlab.fel.cvut.cz/canbus/qemu-canbus | ||
185 | - (3) RTEMS page describing project | ||
186 | - https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation | ||
187 | - (4) RTLWS 2015 article about the project and its use with CANopen emulation | ||
188 | - http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf | ||
189 | - (5) GNU/Linux, CAN and CANopen in Real-time Control Applications | ||
190 | - Slides from LinuxDays 2017 (include updated RTLWS 2015 content) | ||
191 | - https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf | ||
192 | - (6) Linux SocketCAN utilities | ||
193 | - https://github.com/linux-can/can-utils/ | ||
194 | - (7) CTU CAN FD project including core VHDL design, Linux driver, | ||
195 | - test utilities etc. | ||
196 | - https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core | ||
197 | - (8) CTU CAN FD Core Datasheet Documentation | ||
198 | - http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf | ||
199 | - (9) CTU CAN FD Core System Architecture Documentation | ||
200 | - http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf | ||
201 | - (10) CTU CAN FD Driver Documentation | ||
202 | - http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html | ||
203 | - (11) Integration with PCIe interfacing for Intel/Altera Cyclone IV based board | ||
204 | - https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd | ||
205 | + (1) `CAN related projects at Czech Technical University, Faculty of Electrical Engineering <http://canbus.pages.fel.cvut.cz>`_ | ||
206 | + (2) `Repository with development can-pci branch at Czech Technical University <https://gitlab.fel.cvut.cz/canbus/qemu-canbus>`_ | ||
207 | + (3) `RTEMS page describing project <https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation>`_ | ||
208 | + (4) `RTLWS 2015 article about the project and its use with CANopen emulation <http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf>`_ | ||
209 | + (5) `GNU/Linux, CAN and CANopen in Real-time Control Applications Slides from LinuxDays 2017 (include updated RTLWS 2015 content) <https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf>`_ | ||
210 | + (6) `Linux SocketCAN utilities <https://github.com/linux-can/can-utils>`_ | ||
211 | + (7) `CTU CAN FD project including core VHDL design, Linux driver, test utilities etc. <https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core>`_ | ||
212 | + (8) `CTU CAN FD Core Datasheet Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf>`_ | ||
213 | + (9) `CTU CAN FD Core System Architecture Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf>`_ | ||
214 | + (10) `CTU CAN FD Driver Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html>`_ | ||
215 | + (11) `Integration with PCIe interfacing for Intel/Altera Cyclone IV based board <https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd>`_ | ||
216 | -- | ||
217 | 2.25.1 | ||
218 | |||
219 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | The default block size is same as to the THP size, which is either | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | retrieved from "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | or hardcoded to 2MB. There are flaws in both mechanisms and this | 5 | Message-id: 20220324181557.203805-2-zongyuan.li@smartx.com |
6 | intends to fix them up. | ||
7 | |||
8 | * When "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" is | ||
9 | used to getting the THP size, 32MB and 512MB are valid values | ||
10 | when we have 16KB and 64KB page size on ARM64. | ||
11 | |||
12 | * When the hardcoded THP size is used, 2MB, 32MB and 512MB are | ||
13 | valid values when we have 4KB, 16KB and 64KB page sizes on | ||
14 | ARM64. | ||
15 | |||
16 | Co-developed-by: David Hildenbrand <david@redhat.com> | ||
17 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
18 | Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com> | ||
19 | Reviewed-by: David Hildenbrand <david@redhat.com> | ||
20 | Message-id: 20220111063329.74447-2-gshan@redhat.com | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 7 | --- |
23 | hw/virtio/virtio-mem.c | 32 ++++++++++++++++++++------------ | 8 | hw/arm/realview.c | 33 ++++++++++++++++++++++++--------- |
24 | 1 file changed, 20 insertions(+), 12 deletions(-) | 9 | 1 file changed, 24 insertions(+), 9 deletions(-) |
25 | 10 | ||
26 | diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c | 11 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c |
27 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/virtio/virtio-mem.c | 13 | --- a/hw/arm/realview.c |
29 | +++ b/hw/virtio/virtio-mem.c | 14 | +++ b/hw/arm/realview.c |
30 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ |
31 | */ | 16 | #include "hw/sysbus.h" |
32 | #define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)(1 * MiB)) | 17 | #include "hw/arm/boot.h" |
33 | 18 | #include "hw/arm/primecell.h" | |
34 | -#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \ | 19 | +#include "hw/core/split-irq.h" |
35 | - defined(__powerpc64__) | 20 | #include "hw/net/lan9118.h" |
36 | -#define VIRTIO_MEM_DEFAULT_THP_SIZE ((uint32_t)(2 * MiB)) | 21 | #include "hw/net/smc91c111.h" |
37 | -#else | 22 | #include "hw/pci/pci.h" |
38 | - /* fallback to 1 MiB (e.g., the THP size on s390x) */ | 23 | +#include "hw/qdev-core.h" |
39 | -#define VIRTIO_MEM_DEFAULT_THP_SIZE VIRTIO_MEM_MIN_BLOCK_SIZE | 24 | #include "net/net.h" |
40 | +static uint32_t virtio_mem_default_thp_size(void) | 25 | #include "sysemu/sysemu.h" |
41 | +{ | 26 | #include "hw/boards.h" |
42 | + uint32_t default_thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE; | 27 | @@ -XXX,XX +XXX,XX @@ static const int realview_board_id[] = { |
28 | 0x76d | ||
29 | }; | ||
30 | |||
31 | +static void split_irq_from_named(DeviceState *src, const char* outname, | ||
32 | + qemu_irq out1, qemu_irq out2) { | ||
33 | + DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ); | ||
43 | + | 34 | + |
44 | +#if defined(__x86_64__) || defined(__arm__) || defined(__powerpc64__) | 35 | + qdev_prop_set_uint32(splitter, "num-lines", 2); |
45 | + default_thp_size = 2 * MiB; | 36 | + |
46 | +#elif defined(__aarch64__) | 37 | + qdev_realize_and_unref(splitter, NULL, &error_fatal); |
47 | + if (qemu_real_host_page_size == 4 * KiB) { | 38 | + |
48 | + default_thp_size = 2 * MiB; | 39 | + qdev_connect_gpio_out(splitter, 0, out1); |
49 | + } else if (qemu_real_host_page_size == 16 * KiB) { | 40 | + qdev_connect_gpio_out(splitter, 1, out2); |
50 | + default_thp_size = 32 * MiB; | 41 | + qdev_connect_gpio_out_named(src, outname, 0, |
51 | + } else if (qemu_real_host_page_size == 64 * KiB) { | 42 | + qdev_get_gpio_in(splitter, 0)); |
52 | + default_thp_size = 512 * MiB; | ||
53 | + } | ||
54 | #endif | ||
55 | |||
56 | + return default_thp_size; | ||
57 | +} | 43 | +} |
58 | + | 44 | + |
59 | /* | 45 | static void realview_init(MachineState *machine, |
60 | * We want to have a reasonable default block size such that | 46 | enum realview_board_type board_type) |
61 | * 1. We avoid splitting THPs when unplugging memory, which degrades | 47 | { |
62 | @@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void) | 48 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, |
63 | if (g_file_get_contents(HPAGE_PMD_SIZE_PATH, &content, NULL, NULL) && | 49 | DeviceState *dev, *sysctl, *gpio2, *pl041; |
64 | !qemu_strtou64(content, &endptr, 0, &tmp) && | 50 | SysBusDevice *busdev; |
65 | (!endptr || *endptr == '\n')) { | 51 | qemu_irq pic[64]; |
66 | - /* | 52 | - qemu_irq mmc_irq[2]; |
67 | - * Sanity-check the value, if it's too big (e.g., aarch64 with 64k base | 53 | PCIBus *pci_bus = NULL; |
68 | - * pages) or weird, fallback to something smaller. | 54 | NICInfo *nd; |
69 | - */ | 55 | DriveInfo *dinfo; |
70 | - if (!tmp || !is_power_of_2(tmp) || tmp > 16 * MiB) { | 56 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, |
71 | + /* Sanity-check the value and fallback to something reasonable. */ | 57 | * and the PL061 has them the other way about. Also the card |
72 | + if (!tmp || !is_power_of_2(tmp)) { | 58 | * detect line is inverted. |
73 | warn_report("Read unsupported THP size: %" PRIx64, tmp); | 59 | */ |
74 | } else { | 60 | - mmc_irq[0] = qemu_irq_split( |
75 | thp_size = tmp; | 61 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), |
76 | @@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void) | 62 | - qdev_get_gpio_in(gpio2, 1)); |
77 | } | 63 | - mmc_irq[1] = qemu_irq_split( |
78 | 64 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), | |
79 | if (!thp_size) { | 65 | - qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); |
80 | - thp_size = VIRTIO_MEM_DEFAULT_THP_SIZE; | 66 | - qdev_connect_gpio_out_named(dev, "card-read-only", 0, mmc_irq[0]); |
81 | + thp_size = virtio_mem_default_thp_size(); | 67 | - qdev_connect_gpio_out_named(dev, "card-inserted", 0, mmc_irq[1]); |
82 | warn_report("Could not detect THP size, falling back to %" PRIx64 | 68 | + split_irq_from_named(dev, "card-read-only", |
83 | " MiB.", thp_size / MiB); | 69 | + qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), |
84 | } | 70 | + qdev_get_gpio_in(gpio2, 1)); |
71 | + | ||
72 | + split_irq_from_named(dev, "card-inserted", | ||
73 | + qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), | ||
74 | + qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); | ||
75 | + | ||
76 | dinfo = drive_get(IF_SD, 0, 0); | ||
77 | if (dinfo) { | ||
78 | DeviceState *card; | ||
85 | -- | 79 | -- |
86 | 2.25.1 | 80 | 2.25.1 |
87 | |||
88 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | In order to only keep the highmem devices that actually fit in | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | the PA range, check their location against the range and update | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | highest_gpa if they fit. If they don't, mark them as disabled. | 5 | Message-id: 20220324181557.203805-3-zongyuan.li@smartx.com |
6 | |||
7 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Message-id: 20220114140741.1358263-6-maz@kernel.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 7 | --- |
12 | hw/arm/virt.c | 34 ++++++++++++++++++++++++++++------ | 8 | hw/arm/stellaris.c | 15 +++++++++++++-- |
13 | 1 file changed, 28 insertions(+), 6 deletions(-) | 9 | 1 file changed, 13 insertions(+), 2 deletions(-) |
14 | 10 | ||
15 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/virt.c | 13 | --- a/hw/arm/stellaris.c |
18 | +++ b/hw/arm/virt.c | 14 | +++ b/hw/arm/stellaris.c |
19 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits) | 15 | @@ -XXX,XX +XXX,XX @@ |
20 | base = vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES; | 16 | |
21 | } | 17 | #include "qemu/osdep.h" |
22 | 18 | #include "qapi/error.h" | |
23 | + /* We know for sure that at least the memory fits in the PA space */ | 19 | +#include "hw/core/split-irq.h" |
24 | + vms->highest_gpa = memtop - 1; | 20 | #include "hw/sysbus.h" |
21 | #include "hw/sd/sd.h" | ||
22 | #include "hw/ssi/ssi.h" | ||
23 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
24 | DeviceState *ssddev; | ||
25 | DriveInfo *dinfo; | ||
26 | DeviceState *carddev; | ||
27 | + DeviceState *gpio_d_splitter; | ||
28 | BlockBackend *blk; | ||
29 | |||
30 | /* | ||
31 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
32 | &error_fatal); | ||
33 | |||
34 | ssddev = ssi_create_peripheral(bus, "ssd0323"); | ||
35 | - gpio_out[GPIO_D][0] = qemu_irq_split( | ||
36 | - qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0), | ||
25 | + | 37 | + |
26 | for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | 38 | + gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ); |
27 | hwaddr size = extended_memmap[i].size; | 39 | + qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2); |
28 | + bool fits; | 40 | + qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal); |
29 | 41 | + qdev_connect_gpio_out( | |
30 | base = ROUND_UP(base, size); | 42 | + gpio_d_splitter, 0, |
31 | vms->memmap[i].base = base; | 43 | + qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0)); |
32 | vms->memmap[i].size = size; | 44 | + qdev_connect_gpio_out( |
45 | + gpio_d_splitter, 1, | ||
46 | qdev_get_gpio_in_named(ssddev, SSI_GPIO_CS, 0)); | ||
47 | + gpio_out[GPIO_D][0] = qdev_get_gpio_in(gpio_d_splitter, 0); | ||
33 | + | 48 | + |
34 | + /* | 49 | gpio_out[GPIO_C][7] = qdev_get_gpio_in(ssddev, 0); |
35 | + * Check each device to see if they fit in the PA space, | 50 | |
36 | + * moving highest_gpa as we go. | 51 | /* Make sure the select pin is high. */ |
37 | + * | ||
38 | + * For each device that doesn't fit, disable it. | ||
39 | + */ | ||
40 | + fits = (base + size) <= BIT_ULL(pa_bits); | ||
41 | + if (fits) { | ||
42 | + vms->highest_gpa = base + size - 1; | ||
43 | + } | ||
44 | + | ||
45 | + switch (i) { | ||
46 | + case VIRT_HIGH_GIC_REDIST2: | ||
47 | + vms->highmem_redists &= fits; | ||
48 | + break; | ||
49 | + case VIRT_HIGH_PCIE_ECAM: | ||
50 | + vms->highmem_ecam &= fits; | ||
51 | + break; | ||
52 | + case VIRT_HIGH_PCIE_MMIO: | ||
53 | + vms->highmem_mmio &= fits; | ||
54 | + break; | ||
55 | + } | ||
56 | + | ||
57 | base += size; | ||
58 | } | ||
59 | |||
60 | - /* | ||
61 | - * If base fits within pa_bits, all good. If it doesn't, limit it | ||
62 | - * to the end of RAM, which is guaranteed to fit within pa_bits. | ||
63 | - */ | ||
64 | - vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1; | ||
65 | - | ||
66 | if (device_memory_size > 0) { | ||
67 | ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); | ||
68 | ms->device_memory->base = device_memory_base; | ||
69 | -- | 52 | -- |
70 | 2.25.1 | 53 | 2.25.1 |
71 | |||
72 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | Just like we can control the enablement of the highmem PCIe ECAM | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | region using highmem_ecam, let's add a control for the highmem | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | PCIe MMIO region. | 5 | Message-id: 20220324181557.203805-5-zongyuan.li@smartx.com |
6 | 6 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/811 | |
7 | Similarily to highmem_ecam, this region is disabled when highmem | ||
8 | is off. | ||
9 | |||
10 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Message-id: 20220114140741.1358263-2-maz@kernel.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 8 | --- |
15 | include/hw/arm/virt.h | 1 + | 9 | include/hw/irq.h | 5 ----- |
16 | hw/arm/virt-acpi-build.c | 10 ++++------ | 10 | hw/core/irq.c | 15 --------------- |
17 | hw/arm/virt.c | 7 +++++-- | 11 | 2 files changed, 20 deletions(-) |
18 | 3 files changed, 10 insertions(+), 8 deletions(-) | ||
19 | 12 | ||
20 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 13 | diff --git a/include/hw/irq.h b/include/hw/irq.h |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/virt.h | 15 | --- a/include/hw/irq.h |
23 | +++ b/include/hw/arm/virt.h | 16 | +++ b/include/hw/irq.h |
24 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { | 17 | @@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq); |
25 | bool secure; | 18 | /* Returns a new IRQ with opposite polarity. */ |
26 | bool highmem; | 19 | qemu_irq qemu_irq_invert(qemu_irq irq); |
27 | bool highmem_ecam; | 20 | |
28 | + bool highmem_mmio; | 21 | -/* Returns a new IRQ which feeds into both the passed IRQs. |
29 | bool its; | 22 | - * It's probably better to use the TYPE_SPLIT_IRQ device instead. |
30 | bool tcg_its; | 23 | - */ |
31 | bool virt; | 24 | -qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); |
32 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 25 | - |
26 | /* For internal use in qtest. Similar to qemu_irq_split, but operating | ||
27 | on an existing vector of qemu_irq. */ | ||
28 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); | ||
29 | diff --git a/hw/core/irq.c b/hw/core/irq.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/virt-acpi-build.c | 31 | --- a/hw/core/irq.c |
35 | +++ b/hw/arm/virt-acpi-build.c | 32 | +++ b/hw/core/irq.c |
36 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_virtio(Aml *scope, | 33 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_invert(qemu_irq irq) |
34 | return qemu_allocate_irq(qemu_notirq, irq, 0); | ||
37 | } | 35 | } |
38 | 36 | ||
39 | static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | 37 | -static void qemu_splitirq(void *opaque, int line, int level) |
40 | - uint32_t irq, bool use_highmem, bool highmem_ecam, | 38 | -{ |
41 | - VirtMachineState *vms) | 39 | - struct IRQState **irq = opaque; |
42 | + uint32_t irq, VirtMachineState *vms) | 40 | - irq[0]->handler(irq[0]->opaque, irq[0]->n, level); |
41 | - irq[1]->handler(irq[1]->opaque, irq[1]->n, level); | ||
42 | -} | ||
43 | - | ||
44 | -qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2) | ||
45 | -{ | ||
46 | - qemu_irq *s = g_new0(qemu_irq, 2); | ||
47 | - s[0] = irq1; | ||
48 | - s[1] = irq2; | ||
49 | - return qemu_allocate_irq(qemu_splitirq, s, 0); | ||
50 | -} | ||
51 | - | ||
52 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n) | ||
43 | { | 53 | { |
44 | - int ecam_id = VIRT_ECAM_ID(highmem_ecam); | 54 | int i; |
45 | + int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam); | ||
46 | struct GPEXConfig cfg = { | ||
47 | .mmio32 = memmap[VIRT_PCIE_MMIO], | ||
48 | .pio = memmap[VIRT_PCIE_PIO], | ||
49 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
50 | .bus = vms->bus, | ||
51 | }; | ||
52 | |||
53 | - if (use_highmem) { | ||
54 | + if (vms->highmem_mmio) { | ||
55 | cfg.mmio64 = memmap[VIRT_HIGH_PCIE_MMIO]; | ||
56 | } | ||
57 | |||
58 | @@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
59 | acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]); | ||
60 | acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO], | ||
61 | (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS); | ||
62 | - acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE), | ||
63 | - vms->highmem, vms->highmem_ecam, vms); | ||
64 | + acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms); | ||
65 | if (vms->acpi_dev) { | ||
66 | build_ged_aml(scope, "\\_SB."GED_DEVICE, | ||
67 | HOTPLUG_HANDLER(vms->acpi_dev), | ||
68 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/virt.c | ||
71 | +++ b/hw/arm/virt.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms) | ||
73 | mmio_reg, base_mmio, size_mmio); | ||
74 | memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias); | ||
75 | |||
76 | - if (vms->highmem) { | ||
77 | + if (vms->highmem_mmio) { | ||
78 | /* Map high MMIO space */ | ||
79 | MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1); | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms) | ||
82 | qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg", | ||
83 | 2, base_ecam, 2, size_ecam); | ||
84 | |||
85 | - if (vms->highmem) { | ||
86 | + if (vms->highmem_mmio) { | ||
87 | qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "ranges", | ||
88 | 1, FDT_PCI_RANGE_IOPORT, 2, 0, | ||
89 | 2, base_pio, 2, size_pio, | ||
90 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
91 | |||
92 | virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); | ||
93 | |||
94 | + vms->highmem_mmio &= vms->highmem; | ||
95 | + | ||
96 | create_gic(vms, sysmem); | ||
97 | |||
98 | virt_cpu_post_init(vms, sysmem); | ||
99 | @@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj) | ||
100 | vms->gic_version = VIRT_GIC_VERSION_NOSEL; | ||
101 | |||
102 | vms->highmem_ecam = !vmc->no_highmem_ecam; | ||
103 | + vms->highmem_mmio = true; | ||
104 | |||
105 | if (vmc->no_its) { | ||
106 | vms->its = false; | ||
107 | -- | 55 | -- |
108 | 2.25.1 | 56 | 2.25.1 |
109 | |||
110 | diff view generated by jsdifflib |
1 | From: Petr Pavlu <petr.pavlu@suse.com> | 1 | From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> |
---|---|---|---|
2 | 2 | ||
3 | When running Linux on a machine with GICv2, the kernel can crash while | 3 | Describe that the gic-version influences the maximum number of CPUs. |
4 | processing an interrupt and can subsequently start a kdump kernel from | ||
5 | the active interrupt handler. In such a case, the crashed kernel might | ||
6 | not gracefully signal the end of interrupt to the GICv2 hardware. The | ||
7 | kdump kernel will however try to reset the GIC state on startup to get | ||
8 | the controller into a sane state, in particular the kernel writes ones | ||
9 | to GICD_ICACTIVERn and wipes out GICC_APRn to make sure that no | ||
10 | interrupt is active. | ||
11 | 4 | ||
12 | The patch adds a logic to recalculate the running priority when | 5 | Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> |
13 | GICC_APRn/GICC_NSAPRn is written which makes sure that the mentioned | 6 | Message-id: 20220413231456.35811-1-heinrich.schuchardt@canonical.com |
14 | reset works with the GICv2 emulation in QEMU too and the kdump kernel | 7 | [PMM: minor punctuation tweaks] |
15 | starts receiving interrupts. | ||
16 | |||
17 | The described scenario can be reproduced on an AArch64 QEMU virt machine | ||
18 | with a kdump-enabled Linux system by using the softdog module. The kdump | ||
19 | kernel will hang at some point because QEMU still thinks the running | ||
20 | priority is that of the timer interrupt and asserts no new interrupts to | ||
21 | the system: | ||
22 | $ modprobe softdog soft_margin=10 soft_panic=1 | ||
23 | $ cat > /dev/watchdog | ||
24 | [Press Enter to start the watchdog, wait for its timeout and observe | ||
25 | that the kdump kernel hangs on startup.] | ||
26 | |||
27 | Signed-off-by: Petr Pavlu <petr.pavlu@suse.com> | ||
28 | Message-id: 20220113151916.17978-3-ppavlu@suse.cz | ||
29 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 10 | --- |
32 | hw/intc/arm_gic.c | 2 ++ | 11 | docs/system/arm/virt.rst | 4 ++-- |
33 | 1 file changed, 2 insertions(+) | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
34 | 13 | ||
35 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | 14 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
36 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/intc/arm_gic.c | 16 | --- a/docs/system/arm/virt.rst |
38 | +++ b/hw/intc/arm_gic.c | 17 | +++ b/docs/system/arm/virt.rst |
39 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset, | 18 | @@ -XXX,XX +XXX,XX @@ gic-version |
40 | } else { | 19 | Valid values are: |
41 | s->apr[regno][cpu] = value; | 20 | |
42 | } | 21 | ``2`` |
43 | + s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu); | 22 | - GICv2 |
44 | break; | 23 | + GICv2. Note that this limits the number of CPUs to 8. |
45 | } | 24 | ``3`` |
46 | case 0xe0: case 0xe4: case 0xe8: case 0xec: | 25 | - GICv3 |
47 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset, | 26 | + GICv3. This allows up to 512 CPUs. |
48 | return MEMTX_OK; | 27 | ``host`` |
49 | } | 28 | Use the same GIC version the host provides, when using KVM |
50 | s->nsapr[regno][cpu] = value; | 29 | ``max`` |
51 | + s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu); | ||
52 | break; | ||
53 | } | ||
54 | case 0x1000: | ||
55 | -- | 30 | -- |
56 | 2.25.1 | 31 | 2.25.1 |
57 | |||
58 | diff view generated by jsdifflib |
1 | From: Petr Pavlu <petr.pavlu@suse.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Implement support for reading GICC_IIDR. This register is used by the | 3 | Similar to the Aspeed code in include/misc/aspeed_scu.h, we define |
4 | Linux kernel to recognize that GICv2 with GICC_APRn is present. | 4 | the PWRON STRAP fields in their corresponding module for NPCM7XX. |
5 | 5 | ||
6 | Signed-off-by: Petr Pavlu <petr.pavlu@suse.com> | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
7 | Message-id: 20220113151916.17978-2-ppavlu@suse.cz | 7 | Reviewed-by: Patrick Venture <venture@google.com> |
8 | Message-id: 20220411165842.3912945-2-wuhaotsh@google.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/intc/arm_gic.c | 9 +++++++++ | 12 | include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++ |
12 | 1 file changed, 9 insertions(+) | 13 | 1 file changed, 30 insertions(+) |
13 | 14 | ||
14 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | 15 | diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/arm_gic.c | 17 | --- a/include/hw/misc/npcm7xx_gcr.h |
17 | +++ b/hw/intc/arm_gic.c | 18 | +++ b/include/hw/misc/npcm7xx_gcr.h |
18 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset, | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | } | 20 | #include "exec/memory.h" |
20 | break; | 21 | #include "hw/sysbus.h" |
21 | } | 22 | |
22 | + case 0xfc: | 23 | +/* |
23 | + if (s->revision == REV_11MPCORE) { | 24 | + * NPCM7XX PWRON STRAP bit fields |
24 | + /* Reserved on 11MPCore */ | 25 | + * 12: SPI0 powered by VSBV3 at 1.8V |
25 | + *data = 0; | 26 | + * 11: System flash attached to BMC |
26 | + } else { | 27 | + * 10: BSP alternative pins. |
27 | + /* GICv1 or v2; Arm implementation */ | 28 | + * 9:8: Flash UART command route enabled. |
28 | + *data = (s->revision << 16) | 0x43b; | 29 | + * 7: Security enabled. |
29 | + } | 30 | + * 6: HI-Z state control. |
30 | + break; | 31 | + * 5: ECC disabled. |
31 | default: | 32 | + * 4: Reserved |
32 | qemu_log_mask(LOG_GUEST_ERROR, | 33 | + * 3: JTAG2 enabled. |
33 | "gic_cpu_read: Bad offset %x\n", (int)offset); | 34 | + * 2:0: CPU and DRAM clock frequency. |
35 | + */ | ||
36 | +#define NPCM7XX_PWRON_STRAP_SPI0F18 BIT(12) | ||
37 | +#define NPCM7XX_PWRON_STRAP_SFAB BIT(11) | ||
38 | +#define NPCM7XX_PWRON_STRAP_BSPA BIT(10) | ||
39 | +#define NPCM7XX_PWRON_STRAP_FUP(x) ((x) << 8) | ||
40 | +#define FUP_NORM_UART2 3 | ||
41 | +#define FUP_PROG_UART3 2 | ||
42 | +#define FUP_PROG_UART2 1 | ||
43 | +#define FUP_NORM_UART3 0 | ||
44 | +#define NPCM7XX_PWRON_STRAP_SECEN BIT(7) | ||
45 | +#define NPCM7XX_PWRON_STRAP_HIZ BIT(6) | ||
46 | +#define NPCM7XX_PWRON_STRAP_ECC BIT(5) | ||
47 | +#define NPCM7XX_PWRON_STRAP_RESERVE1 BIT(4) | ||
48 | +#define NPCM7XX_PWRON_STRAP_J2EN BIT(3) | ||
49 | +#define NPCM7XX_PWRON_STRAP_CKFRQ(x) (x) | ||
50 | +#define CKFRQ_SKIPINIT 0x000 | ||
51 | +#define CKFRQ_DEFAULT 0x111 | ||
52 | + | ||
53 | /* | ||
54 | * Number of registers in our device state structure. Don't change this without | ||
55 | * incrementing the version_id in the vmstate. | ||
34 | -- | 56 | -- |
35 | 2.25.1 | 57 | 2.25.1 |
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Patrick Venture <venture@google.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Hao Wu <wuhaotsh@google.com> | 3 | This patch uses the defined fields to describe PWRON STRAPs for |
4 | Signed-off-by: Patrick Venture <venture@google.com> | 4 | better readability. |
5 | Message-id: 20220111172338.1525587-1-venture@google.com | 5 | |
6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
7 | Reviewed-by: Patrick Venture <venture@google.com> | ||
8 | Message-id: 20220411165842.3912945-3-wuhaotsh@google.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 11 | --- |
9 | hw/arm/npcm7xx_boards.c | 10 +++++++++- | 12 | hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++----- |
10 | 1 file changed, 9 insertions(+), 1 deletion(-) | 13 | 1 file changed, 19 insertions(+), 5 deletions(-) |
11 | 14 | ||
12 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | 15 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/npcm7xx_boards.c | 17 | --- a/hw/arm/npcm7xx_boards.c |
15 | +++ b/hw/arm/npcm7xx_boards.c | 18 | +++ b/hw/arm/npcm7xx_boards.c |
16 | @@ -XXX,XX +XXX,XX @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc) | 19 | @@ -XXX,XX +XXX,XX @@ |
17 | { | 20 | #include "sysemu/sysemu.h" |
18 | I2CSlave *i2c_mux; | 21 | #include "sysemu/block-backend.h" |
19 | 22 | ||
20 | - i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x75); | 23 | -#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7 |
21 | + i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), | 24 | -#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff |
22 | + TYPE_PCA9548, 0x75); | 25 | -#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff |
26 | -#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff | ||
27 | -#define MORI_BMC_POWER_ON_STRAPS 0x00001fff | ||
28 | +#define NPCM7XX_POWER_ON_STRAPS_DEFAULT ( \ | ||
29 | + NPCM7XX_PWRON_STRAP_SPI0F18 | \ | ||
30 | + NPCM7XX_PWRON_STRAP_SFAB | \ | ||
31 | + NPCM7XX_PWRON_STRAP_BSPA | \ | ||
32 | + NPCM7XX_PWRON_STRAP_FUP(FUP_NORM_UART2) | \ | ||
33 | + NPCM7XX_PWRON_STRAP_SECEN | \ | ||
34 | + NPCM7XX_PWRON_STRAP_HIZ | \ | ||
35 | + NPCM7XX_PWRON_STRAP_ECC | \ | ||
36 | + NPCM7XX_PWRON_STRAP_RESERVE1 | \ | ||
37 | + NPCM7XX_PWRON_STRAP_J2EN | \ | ||
38 | + NPCM7XX_PWRON_STRAP_CKFRQ(CKFRQ_DEFAULT)) | ||
23 | + | 39 | + |
24 | + /* tmp105 is compatible with the lm75 */ | 40 | +#define NPCM750_EVB_POWER_ON_STRAPS ( \ |
25 | + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x5c); | 41 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_J2EN) |
26 | + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x5c); | 42 | +#define QUANTA_GSJ_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT |
27 | + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 6), "tmp105", 0x5c); | 43 | +#define QUANTA_GBS_POWER_ON_STRAPS ( \ |
28 | + i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 7), "tmp105", 0x5c); | 44 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB) |
29 | + | 45 | +#define KUDO_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT |
30 | i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x77); | 46 | +#define MORI_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT |
31 | 47 | ||
32 | i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77); | 48 | static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin"; |
49 | |||
33 | -- | 50 | -- |
34 | 2.25.1 | 51 | 2.25.1 |
35 | |||
36 | diff view generated by jsdifflib |