1 | target-arm queue. This has the "plumb txattrs through various | 1 | First arm pullreq for 7.1. The bulk of this is the qemu_split_irq |
---|---|---|---|
2 | bits of exec.c" patches, and a collection of bug fixes from | 2 | removal. |
3 | various people. | 3 | |
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. | ||
4 | 6 | ||
5 | thanks | 7 | thanks |
6 | -- PMM | 8 | -- PMM |
7 | 9 | ||
10 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: | ||
8 | 11 | ||
9 | 12 | Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700) | |
10 | The following changes since commit a3ac12fba028df90f7b3dbec924995c126c41022: | ||
11 | |||
12 | Merge remote-tracking branch 'remotes/ehabkost/tags/numa-next-pull-request' into staging (2018-05-31 11:12:36 +0100) | ||
13 | 13 | ||
14 | are available in the Git repository at: | 14 | are available in the Git repository at: |
15 | 15 | ||
16 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180531 | 16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220421 |
17 | 17 | ||
18 | for you to fetch changes up to 49d1dca0520ea71bc21867fab6647f474fcf857b: | 18 | for you to fetch changes up to 5b415dd61bdbf61fb4be0e9f1a7172b8bce682c6: |
19 | 19 | ||
20 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice (2018-05-31 14:52:53 +0100) | 20 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs (2022-04-21 11:37:05 +0100) |
21 | 21 | ||
22 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
23 | target-arm queue: | 23 | target-arm queue: |
24 | * target/arm: Honour FPCR.FZ in FRECPX | 24 | * hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF |
25 | * MAINTAINERS: Add entries for newer MPS2 boards and devices | 25 | * versal: Add the Cortex-R5s in the Real-Time Processing Unit (RPU) subsystem |
26 | * hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 26 | * versal: model enough of the Clock/Reset Low-power domain (CRL) to allow control of the Cortex-R5s |
27 | * arm_gicv3_kvm: fix bug in writing zero bits back to the in-kernel | 27 | * xlnx-zynqmp: Connect 4 TTC timers |
28 | GIC state | 28 | * exynos4210: Refactor GIC/combiner code to stop using qemu_split_irq |
29 | * tcg: Fix helper function vs host abi for float16 | 29 | * realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
30 | * arm: fix qemu crash on startup with -bios option | 30 | * stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
31 | * arm: fix malloc type mismatch | 31 | * hw/core/irq: remove unused 'qemu_irq_split' function |
32 | * xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | 32 | * npcm7xx: use symbolic constants for PWRON STRAP bit fields |
33 | * Correct CPACR reset value for v7 cores | 33 | * virt: document impact of gic-version on max CPUs |
34 | * memory.h: Improve IOMMU related documentation | ||
35 | * exec: Plumb transaction attributes through various functions in | ||
36 | preparation for allowing IOMMUs to see them | ||
37 | * vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | ||
38 | * ARM: ACPI: Fix use-after-free due to memory realloc | ||
39 | * KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | ||
40 | 34 | ||
41 | ---------------------------------------------------------------- | 35 | ---------------------------------------------------------------- |
42 | Francisco Iglesias (1): | 36 | Edgar E. Iglesias (6): |
43 | xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | 37 | timer: cadence_ttc: Break out header file to allow embedding |
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 | ||
44 | 43 | ||
45 | Igor Mammedov (1): | 44 | Hao Wu (2): |
46 | arm: fix qemu crash on startup with -bios option | 45 | hw/misc: Add PWRON STRAP bit fields in GCR module |
46 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs | ||
47 | 47 | ||
48 | Jan Kiszka (1): | 48 | Heinrich Schuchardt (1): |
49 | hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 49 | hw/arm/virt: impact of gic-version on max CPUs |
50 | 50 | ||
51 | Paolo Bonzini (1): | 51 | Peter Maydell (19): |
52 | arm: fix malloc type mismatch | 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 | ||
53 | 71 | ||
54 | Peter Maydell (17): | 72 | Zongyuan Li (3): |
55 | target/arm: Honour FPCR.FZ in FRECPX | 73 | hw/arm/realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
56 | MAINTAINERS: Add entries for newer MPS2 boards and devices | 74 | hw/arm/stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
57 | Correct CPACR reset value for v7 cores | 75 | hw/core/irq: remove unused 'qemu_irq_split' function |
58 | memory.h: Improve IOMMU related documentation | ||
59 | Make tb_invalidate_phys_addr() take a MemTxAttrs argument | ||
60 | Make address_space_translate{, _cached}() take a MemTxAttrs argument | ||
61 | Make address_space_map() take a MemTxAttrs argument | ||
62 | Make address_space_access_valid() take a MemTxAttrs argument | ||
63 | Make flatview_extend_translation() take a MemTxAttrs argument | ||
64 | Make memory_region_access_valid() take a MemTxAttrs argument | ||
65 | Make MemoryRegion valid.accepts callback take a MemTxAttrs argument | ||
66 | Make flatview_access_valid() take a MemTxAttrs argument | ||
67 | Make flatview_translate() take a MemTxAttrs argument | ||
68 | Make address_space_get_iotlb_entry() take a MemTxAttrs argument | ||
69 | Make flatview_do_translate() take a MemTxAttrs argument | ||
70 | Make address_space_translate_iommu take a MemTxAttrs argument | ||
71 | vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | ||
72 | 76 | ||
73 | Richard Henderson (1): | 77 | docs/system/arm/virt.rst | 4 +- |
74 | tcg: Fix helper function vs host abi for float16 | 78 | include/hw/arm/exynos4210.h | 50 ++-- |
75 | 79 | include/hw/arm/xlnx-versal.h | 16 ++ | |
76 | Shannon Zhao (3): | 80 | include/hw/arm/xlnx-zynqmp.h | 4 + |
77 | arm_gicv3_kvm: increase clroffset accordingly | 81 | include/hw/intc/exynos4210_combiner.h | 57 +++++ |
78 | ARM: ACPI: Fix use-after-free due to memory realloc | 82 | include/hw/intc/exynos4210_gic.h | 43 ++++ |
79 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | 83 | include/hw/irq.h | 5 - |
80 | 84 | include/hw/misc/npcm7xx_gcr.h | 30 +++ | |
81 | include/exec/exec-all.h | 5 +- | 85 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++++ |
82 | include/exec/helper-head.h | 2 +- | 86 | include/hw/timer/cadence_ttc.h | 54 +++++ |
83 | include/exec/memory-internal.h | 3 +- | 87 | hw/arm/exynos4210.c | 430 ++++++++++++++++++++++++++++++---- |
84 | include/exec/memory.h | 128 +++++++++++++++++++++++++++++++++++------ | 88 | hw/arm/npcm7xx_boards.c | 24 +- |
85 | include/migration/vmstate.h | 3 + | 89 | hw/arm/realview.c | 33 ++- |
86 | include/sysemu/dma.h | 6 +- | 90 | hw/arm/stellaris.c | 15 +- |
87 | accel/tcg/translate-all.c | 4 +- | 91 | hw/arm/virt.c | 7 + |
88 | exec.c | 95 ++++++++++++++++++------------ | 92 | hw/arm/xlnx-versal-virt.c | 6 +- |
89 | hw/arm/boot.c | 18 +++--- | 93 | hw/arm/xlnx-versal.c | 99 +++++++- |
90 | hw/arm/virt-acpi-build.c | 20 +++++-- | 94 | hw/arm/xlnx-zynqmp.c | 22 ++ |
91 | hw/dma/xlnx-zdma.c | 10 +++- | 95 | hw/core/irq.c | 15 -- |
92 | hw/hppa/dino.c | 3 +- | 96 | hw/intc/exynos4210_combiner.c | 108 +-------- |
93 | hw/intc/arm_gic_kvm.c | 1 - | 97 | hw/intc/exynos4210_gic.c | 344 +-------------------------- |
94 | hw/intc/arm_gicv3_cpuif.c | 12 ++-- | 98 | hw/misc/xlnx-versal-crl.c | 421 +++++++++++++++++++++++++++++++++ |
95 | hw/intc/arm_gicv3_kvm.c | 2 +- | 99 | hw/timer/cadence_ttc.c | 32 +-- |
96 | hw/nvram/fw_cfg.c | 12 ++-- | 100 | MAINTAINERS | 2 +- |
97 | hw/s390x/s390-pci-inst.c | 3 +- | 101 | hw/misc/meson.build | 1 + |
98 | hw/scsi/esp.c | 3 +- | 102 | 25 files changed, 1457 insertions(+), 600 deletions(-) |
99 | hw/vfio/common.c | 3 +- | 103 | create mode 100644 include/hw/intc/exynos4210_combiner.h |
100 | hw/virtio/vhost.c | 3 +- | 104 | create mode 100644 include/hw/intc/exynos4210_gic.h |
101 | hw/xen/xen_pt_msi.c | 3 +- | 105 | create mode 100644 include/hw/misc/xlnx-versal-crl.h |
102 | memory.c | 12 ++-- | 106 | create mode 100644 include/hw/timer/cadence_ttc.h |
103 | memory_ldst.inc.c | 18 +++--- | 107 | create mode 100644 hw/misc/xlnx-versal-crl.c |
104 | target/arm/gdbstub.c | 3 +- | ||
105 | target/arm/helper-a64.c | 41 +++++++------ | ||
106 | target/arm/helper.c | 90 ++++++++++++++++------------- | ||
107 | target/ppc/mmu-hash64.c | 3 +- | ||
108 | target/riscv/helper.c | 2 +- | ||
109 | target/s390x/diag.c | 6 +- | ||
110 | target/s390x/excp_helper.c | 3 +- | ||
111 | target/s390x/mmu_helper.c | 3 +- | ||
112 | target/s390x/sigp.c | 3 +- | ||
113 | target/xtensa/op_helper.c | 3 +- | ||
114 | MAINTAINERS | 9 ++- | ||
115 | 34 files changed, 353 insertions(+), 182 deletions(-) | ||
116 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
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: | ||
1 | 6 | ||
7 | $ qemu-system-aarch64 -enable-kvm -machine virt,secure=on -cpu host -display none | ||
8 | Unexpected error in object_property_find_err() at ../../qom/object.c:1304: | ||
9 | qemu-system-aarch64: Property 'host-arm-cpu.secure-memory' not found | ||
10 | Aborted | ||
11 | |||
12 | Check for this combination of options and report an error, in the | ||
13 | same way we already do for attempts to give a KVM or HVF guest the | ||
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 | ||
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 | ||
22 | --- | ||
23 | hw/arm/virt.c | 7 +++++++ | ||
24 | 1 file changed, 7 insertions(+) | ||
25 | |||
26 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/arm/virt.c | ||
29 | +++ b/hw/arm/virt.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
31 | exit(1); | ||
32 | } | ||
33 | |||
34 | + if (vms->secure && (kvm_enabled() || hvf_enabled())) { | ||
35 | + error_report("mach-virt: %s does not support providing " | ||
36 | + "Security extensions (TrustZone) to the guest CPU", | ||
37 | + kvm_enabled() ? "KVM" : "HVF"); | ||
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", | ||
44 | -- | ||
45 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
1 | 2 | ||
3 | Break out header file to allow embedding of the the TTC. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
9 | Message-id: 20220331222017.2914409-2-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/timer/cadence_ttc.h | 54 ++++++++++++++++++++++++++++++++++ | ||
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 | ||
16 | |||
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 | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/timer/cadence_ttc.c | ||
80 | +++ b/hw/timer/cadence_ttc.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qemu/timer.h" | ||
83 | #include "qom/object.h" | ||
84 | |||
85 | +#include "hw/timer/cadence_ttc.h" | ||
86 | + | ||
87 | #ifdef CADENCE_TTC_ERR_DEBUG | ||
88 | #define DB_PRINT(...) do { \ | ||
89 | fprintf(stderr, ": %s: ", __func__); \ | ||
90 | @@ -XXX,XX +XXX,XX @@ | ||
91 | #define CLOCK_CTRL_PS_EN 0x00000001 | ||
92 | #define CLOCK_CTRL_PS_V 0x0000001e | ||
93 | |||
94 | -typedef struct { | ||
95 | - QEMUTimer *timer; | ||
96 | - int freq; | ||
97 | - | ||
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)); | ||
127 | -- | ||
128 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
1 | 2 | ||
3 | Connect the 4 TTC timers on the ZynqMP. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
9 | Message-id: 20220331222017.2914409-3-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/arm/xlnx-zynqmp.h | 4 ++++ | ||
13 | hw/arm/xlnx-zynqmp.c | 22 ++++++++++++++++++++++ | ||
14 | 2 files changed, 26 insertions(+) | ||
15 | |||
16 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/xlnx-zynqmp.h | ||
19 | +++ b/include/hw/arm/xlnx-zynqmp.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "hw/or-irq.h" | ||
22 | #include "hw/misc/xlnx-zynqmp-apu-ctrl.h" | ||
23 | #include "hw/misc/xlnx-zynqmp-crf.h" | ||
24 | +#include "hw/timer/cadence_ttc.h" | ||
25 | |||
26 | #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp" | ||
27 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | ||
28 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | ||
29 | #define XLNX_ZYNQMP_MAX_RAM_SIZE (XLNX_ZYNQMP_MAX_LOW_RAM_SIZE + \ | ||
30 | XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE) | ||
31 | |||
32 | +#define XLNX_ZYNQMP_NUM_TTC 4 | ||
33 | + | ||
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]); | ||
61 | } | ||
62 | |||
63 | +static void xlnx_zynqmp_create_ttc(XlnxZynqMPState *s, qemu_irq *gic) | ||
64 | +{ | ||
65 | + SysBusDevice *sbd; | ||
66 | + int i, irq; | ||
67 | + | ||
68 | + for (i = 0; i < XLNX_ZYNQMP_NUM_TTC; i++) { | ||
69 | + object_initialize_child(OBJECT(s), "ttc[*]", &s->ttc[i], | ||
70 | + TYPE_CADENCE_TTC); | ||
71 | + sbd = SYS_BUS_DEVICE(&s->ttc[i]); | ||
72 | + | ||
73 | + sysbus_realize(sbd, &error_fatal); | ||
74 | + sysbus_mmio_map(sbd, 0, TTC0_ADDR + i * 0x10000); | ||
75 | + for (irq = 0; irq < 3; irq++) { | ||
76 | + sysbus_connect_irq(sbd, irq, gic[TTC0_IRQ + i * 3 + irq]); | ||
77 | + } | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s) | ||
82 | { | ||
83 | static const struct UnimpInfo { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
85 | xlnx_zynqmp_create_efuse(s, gic_spi); | ||
86 | xlnx_zynqmp_create_apu_ctrl(s, gic_spi); | ||
87 | xlnx_zynqmp_create_crf(s, gic_spi); | ||
88 | + xlnx_zynqmp_create_ttc(s, gic_spi); | ||
89 | xlnx_zynqmp_create_unimp_mmio(s); | ||
90 | |||
91 | for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) { | ||
92 | -- | ||
93 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
1 | 2 | ||
3 | Create an APU CPU Cluster. This is in preparation to add the RPU. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
7 | Message-id: 20220406174303.2022038-2-edgar.iglesias@xilinx.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | include/hw/arm/xlnx-versal.h | 2 ++ | ||
11 | hw/arm/xlnx-versal.c | 9 ++++++++- | ||
12 | 2 files changed, 10 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/arm/xlnx-versal.h | ||
17 | +++ b/include/hw/arm/xlnx-versal.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
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) | ||
39 | { | ||
40 | int i; | ||
41 | |||
42 | + object_initialize_child(OBJECT(s), "apu-cluster", &s->fpd.apu.cluster, | ||
43 | + TYPE_CPU_CLUSTER); | ||
44 | + qdev_prop_set_uint32(DEVICE(&s->fpd.apu.cluster), "cluster-id", 0); | ||
45 | + | ||
46 | for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { | ||
47 | Object *obj; | ||
48 | |||
49 | - object_initialize_child(OBJECT(s), "apu-cpu[*]", &s->fpd.apu.cpu[i], | ||
50 | + object_initialize_child(OBJECT(&s->fpd.apu.cluster), | ||
51 | + "apu-cpu[*]", &s->fpd.apu.cpu[i], | ||
52 | XLNX_VERSAL_ACPU_TYPE); | ||
53 | obj = OBJECT(&s->fpd.apu.cpu[i]); | ||
54 | if (i) { | ||
55 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | ||
56 | &error_abort); | ||
57 | qdev_realize(DEVICE(obj), NULL, &error_fatal); | ||
58 | } | ||
59 | + | ||
60 | + qdev_realize(DEVICE(&s->fpd.apu.cluster), NULL, &error_fatal); | ||
61 | } | ||
62 | |||
63 | static void versal_create_apu_gic(Versal *s, qemu_irq *pic) | ||
64 | -- | ||
65 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Depending on the host abi, float16, aka uint16_t, values are | 3 | Add the Cortex-R5Fs of the Versal RPU (Real-time Processing Unit) |
4 | passed and returned either zero-extended in the host register | 4 | subsystem. |
5 | or with garbage at the top of the host register. | ||
6 | 5 | ||
7 | The tcg code generator has so far been assuming garbage, as that | 6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
8 | matches the x86 abi, but this is incorrect for other host abis. | 7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> |
9 | Further, target/arm has so far been assuming zero-extended results, | 8 | Message-id: 20220406174303.2022038-3-edgar.iglesias@xilinx.com |
10 | so that it may store the 16-bit value into a 32-bit slot with the | ||
11 | high 16-bits already clear. | ||
12 | |||
13 | Rectify both problems by mapping "f16" in the helper definition | ||
14 | to uint32_t instead of (a typedef for) uint16_t. This forces | ||
15 | the host compiler to assume garbage in the upper 16 bits on input | ||
16 | and to zero-extend the result on output. | ||
17 | |||
18 | Cc: qemu-stable@nongnu.org | ||
19 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
22 | Message-id: 20180522175629.24932-1-richard.henderson@linaro.org | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | --- | 10 | --- |
26 | include/exec/helper-head.h | 2 +- | 11 | include/hw/arm/xlnx-versal.h | 10 ++++++++++ |
27 | target/arm/helper-a64.c | 35 +++++++++-------- | 12 | hw/arm/xlnx-versal-virt.c | 6 +++--- |
28 | target/arm/helper.c | 80 +++++++++++++++++++------------------- | 13 | hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++++++++++ |
29 | 3 files changed, 59 insertions(+), 58 deletions(-) | 14 | 3 files changed, 49 insertions(+), 3 deletions(-) |
30 | 15 | ||
31 | diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h | 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/include/exec/helper-head.h | 18 | --- a/include/hw/arm/xlnx-versal.h |
34 | +++ b/include/exec/helper-head.h | 19 | +++ b/include/hw/arm/xlnx-versal.h |
35 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
36 | #define dh_ctype_int int | 21 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) |
37 | #define dh_ctype_i64 uint64_t | 22 | |
38 | #define dh_ctype_s64 int64_t | 23 | #define XLNX_VERSAL_NR_ACPUS 2 |
39 | -#define dh_ctype_f16 float16 | 24 | +#define XLNX_VERSAL_NR_RCPUS 2 |
40 | +#define dh_ctype_f16 uint32_t | 25 | #define XLNX_VERSAL_NR_UARTS 2 |
41 | #define dh_ctype_f32 float32 | 26 | #define XLNX_VERSAL_NR_GEMS 2 |
42 | #define dh_ctype_f64 float64 | 27 | #define XLNX_VERSAL_NR_ADMAS 8 |
43 | #define dh_ctype_ptr void * | 28 | @@ -XXX,XX +XXX,XX @@ struct Versal { |
44 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 29 | VersalUsb2 usb; |
30 | } iou; | ||
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 | ||
45 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/helper-a64.c | 46 | --- a/hw/arm/xlnx-versal-virt.c |
47 | +++ b/target/arm/helper-a64.c | 47 | +++ b/hw/arm/xlnx-versal-virt.c |
48 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res) | 48 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data) |
49 | return flags; | 49 | |
50 | mc->desc = "Xilinx Versal Virtual development board"; | ||
51 | mc->init = versal_virt_init; | ||
52 | - mc->min_cpus = XLNX_VERSAL_NR_ACPUS; | ||
53 | - mc->max_cpus = XLNX_VERSAL_NR_ACPUS; | ||
54 | - mc->default_cpus = XLNX_VERSAL_NR_ACPUS; | ||
55 | + mc->min_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
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"; | ||
50 | } | 60 | } |
51 | 61 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | |
52 | -uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) | ||
53 | +uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status) | ||
54 | { | ||
55 | return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); | ||
56 | } | ||
57 | |||
58 | -uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) | ||
59 | +uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status) | ||
60 | { | ||
61 | return float_rel_to_flags(float16_compare(x, y, fp_status)); | ||
62 | } | ||
63 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) | ||
64 | #define float64_three make_float64(0x4008000000000000ULL) | ||
65 | #define float64_one_point_five make_float64(0x3FF8000000000000ULL) | ||
66 | |||
67 | -float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp) | ||
68 | +uint32_t HELPER(recpsf_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
69 | { | ||
70 | float_status *fpst = fpstp; | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp) | ||
73 | return float64_muladd(a, b, float64_two, 0, fpst); | ||
74 | } | ||
75 | |||
76 | -float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp) | ||
77 | +uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
78 | { | ||
79 | float_status *fpst = fpstp; | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a) | ||
82 | } | ||
83 | |||
84 | /* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */ | ||
85 | -float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | ||
86 | +uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) | ||
87 | { | ||
88 | float_status *fpst = fpstp; | ||
89 | uint16_t val16, sbit; | ||
90 | @@ -XXX,XX +XXX,XX @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, | ||
91 | #define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix)) | ||
92 | |||
93 | #define ADVSIMD_HALFOP(name) \ | ||
94 | -float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \ | ||
95 | +uint32_t ADVSIMD_HELPER(name, h)(uint32_t a, uint32_t b, void *fpstp) \ | ||
96 | { \ | ||
97 | float_status *fpst = fpstp; \ | ||
98 | return float16_ ## name(a, b, fpst); \ | ||
99 | @@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(mulx) | ||
100 | ADVSIMD_TWOHALFOP(mulx) | ||
101 | |||
102 | /* fused multiply-accumulate */ | ||
103 | -float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) | ||
104 | +uint32_t HELPER(advsimd_muladdh)(uint32_t a, uint32_t b, uint32_t c, | ||
105 | + void *fpstp) | ||
106 | { | ||
107 | float_status *fpst = fpstp; | ||
108 | return float16_muladd(a, b, c, 0, fpst); | ||
109 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b, | ||
110 | |||
111 | #define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0 | ||
112 | |||
113 | -uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp) | ||
114 | +uint32_t HELPER(advsimd_ceq_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
115 | { | ||
116 | float_status *fpst = fpstp; | ||
117 | int compare = float16_compare_quiet(a, b, fpst); | ||
118 | return ADVSIMD_CMPRES(compare == float_relation_equal); | ||
119 | } | ||
120 | |||
121 | -uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | ||
122 | +uint32_t HELPER(advsimd_cge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
123 | { | ||
124 | float_status *fpst = fpstp; | ||
125 | int compare = float16_compare(a, b, fpst); | ||
126 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | ||
127 | compare == float_relation_equal); | ||
128 | } | ||
129 | |||
130 | -uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp) | ||
131 | +uint32_t HELPER(advsimd_cgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
132 | { | ||
133 | float_status *fpst = fpstp; | ||
134 | int compare = float16_compare(a, b, fpst); | ||
135 | return ADVSIMD_CMPRES(compare == float_relation_greater); | ||
136 | } | ||
137 | |||
138 | -uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | ||
139 | +uint32_t HELPER(advsimd_acge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
140 | { | ||
141 | float_status *fpst = fpstp; | ||
142 | float16 f0 = float16_abs(a); | ||
143 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | ||
144 | compare == float_relation_equal); | ||
145 | } | ||
146 | |||
147 | -uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | ||
148 | +uint32_t HELPER(advsimd_acgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
149 | { | ||
150 | float_status *fpst = fpstp; | ||
151 | float16 f0 = float16_abs(a); | ||
152 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | ||
153 | } | ||
154 | |||
155 | /* round to integral */ | ||
156 | -float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status) | ||
157 | +uint32_t HELPER(advsimd_rinth_exact)(uint32_t x, void *fp_status) | ||
158 | { | ||
159 | return float16_round_to_int(x, fp_status); | ||
160 | } | ||
161 | |||
162 | -float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
163 | +uint32_t HELPER(advsimd_rinth)(uint32_t x, void *fp_status) | ||
164 | { | ||
165 | int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
166 | float16 ret; | ||
167 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
168 | * setting the mode appropriately before calling the helper. | ||
169 | */ | ||
170 | |||
171 | -uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
172 | +uint32_t HELPER(advsimd_f16tosinth)(uint32_t a, void *fpstp) | ||
173 | { | ||
174 | float_status *fpst = fpstp; | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
177 | return float16_to_int16(a, fpst); | ||
178 | } | ||
179 | |||
180 | -uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
181 | +uint32_t HELPER(advsimd_f16touinth)(uint32_t a, void *fpstp) | ||
182 | { | ||
183 | float_status *fpst = fpstp; | ||
184 | |||
185 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
186 | * Square Root and Reciprocal square root | ||
187 | */ | ||
188 | |||
189 | -float16 HELPER(sqrt_f16)(float16 a, void *fpstp) | ||
190 | +uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp) | ||
191 | { | ||
192 | float_status *s = fpstp; | ||
193 | |||
194 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
195 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
196 | --- a/target/arm/helper.c | 63 | --- a/hw/arm/xlnx-versal.c |
197 | +++ b/target/arm/helper.c | 64 | +++ b/hw/arm/xlnx-versal.c |
198 | @@ -XXX,XX +XXX,XX @@ DO_VFP_cmp(d, float64) | 65 | @@ -XXX,XX +XXX,XX @@ |
199 | 66 | #include "hw/sysbus.h" | |
200 | /* Integer to float and float to integer conversions */ | 67 | |
201 | 68 | #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72") | |
202 | -#define CONV_ITOF(name, fsz, sign) \ | 69 | +#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f") |
203 | - float##fsz HELPER(name)(uint32_t x, void *fpstp) \ | 70 | #define GEM_REVISION 0x40070106 |
204 | -{ \ | 71 | |
205 | - float_status *fpst = fpstp; \ | 72 | #define VERSAL_NUM_PMC_APB_IRQS 3 |
206 | - return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | 73 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) |
207 | +#define CONV_ITOF(name, ftype, fsz, sign) \ | ||
208 | +ftype HELPER(name)(uint32_t x, void *fpstp) \ | ||
209 | +{ \ | ||
210 | + float_status *fpst = fpstp; \ | ||
211 | + return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
212 | } | ||
213 | |||
214 | -#define CONV_FTOI(name, fsz, sign, round) \ | ||
215 | -uint32_t HELPER(name)(float##fsz x, void *fpstp) \ | ||
216 | -{ \ | ||
217 | - float_status *fpst = fpstp; \ | ||
218 | - if (float##fsz##_is_any_nan(x)) { \ | ||
219 | - float_raise(float_flag_invalid, fpst); \ | ||
220 | - return 0; \ | ||
221 | - } \ | ||
222 | - return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
223 | +#define CONV_FTOI(name, ftype, fsz, sign, round) \ | ||
224 | +uint32_t HELPER(name)(ftype x, void *fpstp) \ | ||
225 | +{ \ | ||
226 | + float_status *fpst = fpstp; \ | ||
227 | + if (float##fsz##_is_any_nan(x)) { \ | ||
228 | + float_raise(float_flag_invalid, fpst); \ | ||
229 | + return 0; \ | ||
230 | + } \ | ||
231 | + return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
232 | } | ||
233 | |||
234 | -#define FLOAT_CONVS(name, p, fsz, sign) \ | ||
235 | -CONV_ITOF(vfp_##name##to##p, fsz, sign) \ | ||
236 | -CONV_FTOI(vfp_to##name##p, fsz, sign, ) \ | ||
237 | -CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero) | ||
238 | +#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ | ||
239 | + CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ | ||
240 | + CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ | ||
241 | + CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) | ||
242 | |||
243 | -FLOAT_CONVS(si, h, 16, ) | ||
244 | -FLOAT_CONVS(si, s, 32, ) | ||
245 | -FLOAT_CONVS(si, d, 64, ) | ||
246 | -FLOAT_CONVS(ui, h, 16, u) | ||
247 | -FLOAT_CONVS(ui, s, 32, u) | ||
248 | -FLOAT_CONVS(ui, d, 64, u) | ||
249 | +FLOAT_CONVS(si, h, uint32_t, 16, ) | ||
250 | +FLOAT_CONVS(si, s, float32, 32, ) | ||
251 | +FLOAT_CONVS(si, d, float64, 64, ) | ||
252 | +FLOAT_CONVS(ui, h, uint32_t, 16, u) | ||
253 | +FLOAT_CONVS(ui, s, float32, 32, u) | ||
254 | +FLOAT_CONVS(ui, d, float64, 64, u) | ||
255 | |||
256 | #undef CONV_ITOF | ||
257 | #undef CONV_FTOI | ||
258 | @@ -XXX,XX +XXX,XX @@ static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) | ||
259 | return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst); | ||
260 | } | ||
261 | |||
262 | -float16 HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
263 | +uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
264 | { | ||
265 | return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst); | ||
266 | } | ||
267 | |||
268 | -float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
269 | +uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
270 | { | ||
271 | return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); | ||
272 | } | ||
273 | |||
274 | -float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
275 | +uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
276 | { | ||
277 | return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); | ||
278 | } | ||
279 | |||
280 | -float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
281 | +uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
282 | { | ||
283 | return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); | ||
284 | } | ||
285 | @@ -XXX,XX +XXX,XX @@ static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) | ||
286 | } | 74 | } |
287 | } | 75 | } |
288 | 76 | ||
289 | -uint32_t HELPER(vfp_toshh)(float16 x, uint32_t shift, void *fpst) | 77 | +static void versal_create_rpu_cpus(Versal *s) |
290 | +uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) | 78 | +{ |
79 | + int i; | ||
80 | + | ||
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); | ||
101 | + } | ||
102 | + | ||
103 | + qdev_realize(DEVICE(&s->lpd.rpu.cluster), NULL, &error_fatal); | ||
104 | +} | ||
105 | + | ||
106 | static void versal_create_uarts(Versal *s, qemu_irq *pic) | ||
291 | { | 107 | { |
292 | return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst); | 108 | int i; |
109 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
110 | |||
111 | versal_create_apu_cpus(s); | ||
112 | versal_create_apu_gic(s, pic); | ||
113 | + versal_create_rpu_cpus(s); | ||
114 | versal_create_uarts(s, pic); | ||
115 | versal_create_usbs(s, pic); | ||
116 | versal_create_gems(s, pic); | ||
117 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
118 | |||
119 | memory_region_add_subregion_overlap(&s->mr_ps, MM_OCM, &s->lpd.mr_ocm, 0); | ||
120 | memory_region_add_subregion_overlap(&s->fpd.apu.mr, 0, &s->mr_ps, 0); | ||
121 | + memory_region_add_subregion_overlap(&s->lpd.rpu.mr, 0, | ||
122 | + &s->lpd.rpu.mr_ps_alias, 0); | ||
293 | } | 123 | } |
294 | 124 | ||
295 | -uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) | 125 | static void versal_init(Object *obj) |
296 | +uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) | 126 | @@ -XXX,XX +XXX,XX @@ static void versal_init(Object *obj) |
297 | { | 127 | Versal *s = XLNX_VERSAL(obj); |
298 | return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); | 128 | |
129 | memory_region_init(&s->fpd.apu.mr, obj, "mr-apu", UINT64_MAX); | ||
130 | + memory_region_init(&s->lpd.rpu.mr, obj, "mr-rpu", UINT64_MAX); | ||
131 | memory_region_init(&s->mr_ps, obj, "mr-ps-switch", UINT64_MAX); | ||
132 | + memory_region_init_alias(&s->lpd.rpu.mr_ps_alias, OBJECT(s), | ||
133 | + "mr-rpu-ps-alias", &s->mr_ps, 0, UINT64_MAX); | ||
299 | } | 134 | } |
300 | 135 | ||
301 | -uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) | 136 | static Property versal_properties[] = { |
302 | +uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) | ||
303 | { | ||
304 | return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); | ||
305 | } | ||
306 | |||
307 | -uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) | ||
308 | +uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) | ||
309 | { | ||
310 | return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); | ||
311 | } | ||
312 | |||
313 | -uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) | ||
314 | +uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) | ||
315 | { | ||
316 | return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); | ||
317 | } | ||
318 | |||
319 | -uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) | ||
320 | +uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) | ||
321 | { | ||
322 | return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); | ||
323 | } | ||
324 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) | ||
325 | } | ||
326 | |||
327 | /* Half precision conversions. */ | ||
328 | -float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
329 | +float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
330 | { | ||
331 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
332 | * it would affect flushing input denormals. | ||
333 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
334 | return r; | ||
335 | } | ||
336 | |||
337 | -float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
338 | +uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
339 | { | ||
340 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
341 | * it would affect flushing output denormals. | ||
342 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
343 | return r; | ||
344 | } | ||
345 | |||
346 | -float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
347 | +float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
348 | { | ||
349 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
350 | * it would affect flushing input denormals. | ||
351 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
352 | return r; | ||
353 | } | ||
354 | |||
355 | -float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
356 | +uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
357 | { | ||
358 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
359 | * it would affect flushing output denormals. | ||
360 | @@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit) | ||
361 | g_assert_not_reached(); | ||
362 | } | ||
363 | |||
364 | -float16 HELPER(recpe_f16)(float16 input, void *fpstp) | ||
365 | +uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
366 | { | ||
367 | float_status *fpst = fpstp; | ||
368 | float16 f16 = float16_squash_input_denormal(input, fpst); | ||
369 | @@ -XXX,XX +XXX,XX @@ static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) | ||
370 | return extract64(estimate, 0, 8) << 44; | ||
371 | } | ||
372 | |||
373 | -float16 HELPER(rsqrte_f16)(float16 input, void *fpstp) | ||
374 | +uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
375 | { | ||
376 | float_status *s = fpstp; | ||
377 | float16 f16 = float16_squash_input_denormal(input, s); | ||
378 | -- | 137 | -- |
379 | 2.17.1 | 138 | 2.25.1 |
380 | |||
381 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
1 | 2 | ||
3 | Add a model of the Xilinx Versal CRL. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> | ||
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
8 | Message-id: 20220406174303.2022038-4-edgar.iglesias@xilinx.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++ | ||
12 | hw/misc/xlnx-versal-crl.c | 421 ++++++++++++++++++++++++++++++ | ||
13 | hw/misc/meson.build | 1 + | ||
14 | 3 files changed, 657 insertions(+) | ||
15 | create mode 100644 include/hw/misc/xlnx-versal-crl.h | ||
16 | create mode 100644 hw/misc/xlnx-versal-crl.c | ||
17 | |||
18 | diff --git a/include/hw/misc/xlnx-versal-crl.h b/include/hw/misc/xlnx-versal-crl.h | ||
19 | new file mode 100644 | ||
20 | index XXXXXXX..XXXXXXX | ||
21 | --- /dev/null | ||
22 | +++ b/include/hw/misc/xlnx-versal-crl.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | +/* | ||
25 | + * QEMU model of the Clock-Reset-LPD (CRL). | ||
26 | + * | ||
27 | + * Copyright (c) 2022 Xilinx Inc. | ||
28 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
29 | + * | ||
30 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
31 | + */ | ||
32 | +#ifndef HW_MISC_XLNX_VERSAL_CRL_H | ||
33 | +#define HW_MISC_XLNX_VERSAL_CRL_H | ||
34 | + | ||
35 | +#include "hw/sysbus.h" | ||
36 | +#include "hw/register.h" | ||
37 | +#include "target/arm/cpu.h" | ||
38 | + | ||
39 | +#define TYPE_XLNX_VERSAL_CRL "xlnx,versal-crl" | ||
40 | +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCRL, XLNX_VERSAL_CRL) | ||
41 | + | ||
42 | +REG32(ERR_CTRL, 0x0) | ||
43 | + FIELD(ERR_CTRL, SLVERR_ENABLE, 0, 1) | ||
44 | +REG32(IR_STATUS, 0x4) | ||
45 | + FIELD(IR_STATUS, ADDR_DECODE_ERR, 0, 1) | ||
46 | +REG32(IR_MASK, 0x8) | ||
47 | + FIELD(IR_MASK, ADDR_DECODE_ERR, 0, 1) | ||
48 | +REG32(IR_ENABLE, 0xc) | ||
49 | + FIELD(IR_ENABLE, ADDR_DECODE_ERR, 0, 1) | ||
50 | +REG32(IR_DISABLE, 0x10) | ||
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; | ||
244 | + qemu_irq irq; | ||
245 | + | ||
246 | + struct { | ||
247 | + ARMCPU *cpu_r5[RPU_MAX_CPU]; | ||
248 | + DeviceState *adma[8]; | ||
249 | + DeviceState *uart[2]; | ||
250 | + DeviceState *gem[2]; | ||
251 | + DeviceState *usb; | ||
252 | + } cfg; | ||
253 | + | ||
254 | + RegisterInfoArray *reg_array; | ||
255 | + uint32_t regs[CRL_R_MAX]; | ||
256 | + RegisterInfo regs_info[CRL_R_MAX]; | ||
257 | +}; | ||
258 | +#endif | ||
259 | diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c | ||
260 | new file mode 100644 | ||
261 | index XXXXXXX..XXXXXXX | ||
262 | --- /dev/null | ||
263 | +++ b/hw/misc/xlnx-versal-crl.c | ||
264 | @@ -XXX,XX +XXX,XX @@ | ||
265 | +/* | ||
266 | + * QEMU model of the Clock-Reset-LPD (CRL). | ||
267 | + * | ||
268 | + * Copyright (c) 2022 Advanced Micro Devices, Inc. | ||
269 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
270 | + * | ||
271 | + * Written by Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
272 | + */ | ||
273 | + | ||
274 | +#include "qemu/osdep.h" | ||
275 | +#include "qapi/error.h" | ||
276 | +#include "qemu/log.h" | ||
277 | +#include "qemu/bitops.h" | ||
278 | +#include "migration/vmstate.h" | ||
279 | +#include "hw/qdev-properties.h" | ||
280 | +#include "hw/sysbus.h" | ||
281 | +#include "hw/irq.h" | ||
282 | +#include "hw/register.h" | ||
283 | +#include "hw/resettable.h" | ||
284 | + | ||
285 | +#include "target/arm/arm-powerctl.h" | ||
286 | +#include "hw/misc/xlnx-versal-crl.h" | ||
287 | + | ||
288 | +#ifndef XLNX_VERSAL_CRL_ERR_DEBUG | ||
289 | +#define XLNX_VERSAL_CRL_ERR_DEBUG 0 | ||
290 | +#endif | ||
291 | + | ||
292 | +static void crl_update_irq(XlnxVersalCRL *s) | ||
293 | +{ | ||
294 | + bool pending = s->regs[R_IR_STATUS] & ~s->regs[R_IR_MASK]; | ||
295 | + qemu_set_irq(s->irq, pending); | ||
296 | +} | ||
297 | + | ||
298 | +static void crl_status_postw(RegisterInfo *reg, uint64_t val64) | ||
299 | +{ | ||
300 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
301 | + crl_update_irq(s); | ||
302 | +} | ||
303 | + | ||
304 | +static uint64_t crl_enable_prew(RegisterInfo *reg, uint64_t val64) | ||
305 | +{ | ||
306 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
307 | + uint32_t val = val64; | ||
308 | + | ||
309 | + s->regs[R_IR_MASK] &= ~val; | ||
310 | + crl_update_irq(s); | ||
311 | + return 0; | ||
312 | +} | ||
313 | + | ||
314 | +static uint64_t crl_disable_prew(RegisterInfo *reg, uint64_t val64) | ||
315 | +{ | ||
316 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
317 | + uint32_t val = val64; | ||
318 | + | ||
319 | + s->regs[R_IR_MASK] |= val; | ||
320 | + crl_update_irq(s); | ||
321 | + return 0; | ||
322 | +} | ||
323 | + | ||
324 | +static void crl_reset_dev(XlnxVersalCRL *s, DeviceState *dev, | ||
325 | + bool rst_old, bool rst_new) | ||
326 | +{ | ||
327 | + device_cold_reset(dev); | ||
328 | +} | ||
329 | + | ||
330 | +static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcpu, | ||
331 | + bool rst_old, bool rst_new) | ||
332 | +{ | ||
333 | + if (rst_new) { | ||
334 | + arm_set_cpu_off(armcpu->mp_affinity); | ||
335 | + } else { | ||
336 | + arm_set_cpu_on_and_reset(armcpu->mp_affinity); | ||
337 | + } | ||
338 | +} | ||
339 | + | ||
340 | +#define REGFIELD_RESET(type, s, reg, f, new_val, dev) { \ | ||
341 | + bool old_f = ARRAY_FIELD_EX32((s)->regs, reg, f); \ | ||
342 | + bool new_f = FIELD_EX32(new_val, reg, f); \ | ||
343 | + \ | ||
344 | + /* Detect edges. */ \ | ||
345 | + if (dev && old_f != new_f) { \ | ||
346 | + crl_reset_ ## type(s, dev, old_f, new_f); \ | ||
347 | + } \ | ||
348 | +} | ||
349 | + | ||
350 | +static uint64_t crl_rst_r5_prew(RegisterInfo *reg, uint64_t val64) | ||
351 | +{ | ||
352 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
353 | + | ||
354 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU0, val64, s->cfg.cpu_r5[0]); | ||
355 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU1, val64, s->cfg.cpu_r5[1]); | ||
356 | + return val64; | ||
357 | +} | ||
358 | + | ||
359 | +static uint64_t crl_rst_adma_prew(RegisterInfo *reg, uint64_t val64) | ||
360 | +{ | ||
361 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
362 | + int i; | ||
363 | + | ||
364 | + /* A single register fans out to all ADMA reset inputs. */ | ||
365 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); i++) { | ||
366 | + REGFIELD_RESET(dev, s, RST_ADMA, RESET, val64, s->cfg.adma[i]); | ||
367 | + } | ||
368 | + return val64; | ||
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 | + } | ||
565 | +}; | ||
566 | + | ||
567 | +static void crl_reset_enter(Object *obj, ResetType type) | ||
568 | +{ | ||
569 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
570 | + unsigned int i; | ||
571 | + | ||
572 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
573 | + register_reset(&s->regs_info[i]); | ||
574 | + } | ||
575 | +} | ||
576 | + | ||
577 | +static void crl_reset_hold(Object *obj) | ||
578 | +{ | ||
579 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
580 | + | ||
581 | + crl_update_irq(s); | ||
582 | +} | ||
583 | + | ||
584 | +static const MemoryRegionOps crl_ops = { | ||
585 | + .read = register_read_memory, | ||
586 | + .write = register_write_memory, | ||
587 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
588 | + .valid = { | ||
589 | + .min_access_size = 4, | ||
590 | + .max_access_size = 4, | ||
591 | + }, | ||
592 | +}; | ||
593 | + | ||
594 | +static void crl_init(Object *obj) | ||
595 | +{ | ||
596 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
597 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
598 | + int i; | ||
599 | + | ||
600 | + s->reg_array = | ||
601 | + register_init_block32(DEVICE(obj), crl_regs_info, | ||
602 | + ARRAY_SIZE(crl_regs_info), | ||
603 | + s->regs_info, s->regs, | ||
604 | + &crl_ops, | ||
605 | + XLNX_VERSAL_CRL_ERR_DEBUG, | ||
606 | + CRL_R_MAX * 4); | ||
607 | + sysbus_init_mmio(sbd, &s->reg_array->mem); | ||
608 | + sysbus_init_irq(sbd, &s->irq); | ||
609 | + | ||
610 | + for (i = 0; i < ARRAY_SIZE(s->cfg.cpu_r5); ++i) { | ||
611 | + object_property_add_link(obj, "cpu_r5[*]", TYPE_ARM_CPU, | ||
612 | + (Object **)&s->cfg.cpu_r5[i], | ||
613 | + qdev_prop_allow_set_link_before_realize, | ||
614 | + OBJ_PROP_LINK_STRONG); | ||
615 | + } | ||
616 | + | ||
617 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); ++i) { | ||
618 | + object_property_add_link(obj, "adma[*]", TYPE_DEVICE, | ||
619 | + (Object **)&s->cfg.adma[i], | ||
620 | + qdev_prop_allow_set_link_before_realize, | ||
621 | + OBJ_PROP_LINK_STRONG); | ||
622 | + } | ||
623 | + | ||
624 | + for (i = 0; i < ARRAY_SIZE(s->cfg.uart); ++i) { | ||
625 | + object_property_add_link(obj, "uart[*]", TYPE_DEVICE, | ||
626 | + (Object **)&s->cfg.uart[i], | ||
627 | + qdev_prop_allow_set_link_before_realize, | ||
628 | + OBJ_PROP_LINK_STRONG); | ||
629 | + } | ||
630 | + | ||
631 | + for (i = 0; i < ARRAY_SIZE(s->cfg.gem); ++i) { | ||
632 | + object_property_add_link(obj, "gem[*]", TYPE_DEVICE, | ||
633 | + (Object **)&s->cfg.gem[i], | ||
634 | + qdev_prop_allow_set_link_before_realize, | ||
635 | + OBJ_PROP_LINK_STRONG); | ||
636 | + } | ||
637 | + | ||
638 | + object_property_add_link(obj, "usb", TYPE_DEVICE, | ||
639 | + (Object **)&s->cfg.gem[i], | ||
640 | + qdev_prop_allow_set_link_before_realize, | ||
641 | + OBJ_PROP_LINK_STRONG); | ||
642 | +} | ||
643 | + | ||
644 | +static void crl_finalize(Object *obj) | ||
645 | +{ | ||
646 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
647 | + register_finalize_block(s->reg_array); | ||
648 | +} | ||
649 | + | ||
650 | +static const VMStateDescription vmstate_crl = { | ||
651 | + .name = TYPE_XLNX_VERSAL_CRL, | ||
652 | + .version_id = 1, | ||
653 | + .minimum_version_id = 1, | ||
654 | + .fields = (VMStateField[]) { | ||
655 | + VMSTATE_UINT32_ARRAY(regs, XlnxVersalCRL, CRL_R_MAX), | ||
656 | + VMSTATE_END_OF_LIST(), | ||
657 | + } | ||
658 | +}; | ||
659 | + | ||
660 | +static void crl_class_init(ObjectClass *klass, void *data) | ||
661 | +{ | ||
662 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
663 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
664 | + | ||
665 | + dc->vmsd = &vmstate_crl; | ||
666 | + | ||
667 | + rc->phases.enter = crl_reset_enter; | ||
668 | + rc->phases.hold = crl_reset_hold; | ||
669 | +} | ||
670 | + | ||
671 | +static const TypeInfo crl_info = { | ||
672 | + .name = TYPE_XLNX_VERSAL_CRL, | ||
673 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
674 | + .instance_size = sizeof(XlnxVersalCRL), | ||
675 | + .class_init = crl_class_init, | ||
676 | + .instance_init = crl_init, | ||
677 | + .instance_finalize = crl_finalize, | ||
678 | +}; | ||
679 | + | ||
680 | +static void crl_register_types(void) | ||
681 | +{ | ||
682 | + type_register_static(&crl_info); | ||
683 | +} | ||
684 | + | ||
685 | +type_init(crl_register_types) | ||
686 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
687 | index XXXXXXX..XXXXXXX 100644 | ||
688 | --- a/hw/misc/meson.build | ||
689 | +++ b/hw/misc/meson.build | ||
690 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | ||
691 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) | ||
692 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c')) | ||
693 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c')) | ||
694 | +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-crl.c')) | ||
695 | softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( | ||
696 | 'xlnx-versal-xramc.c', | ||
697 | 'xlnx-versal-pmc-iou-slcr.c', | ||
698 | -- | ||
699 | 2.25.1 | diff view generated by jsdifflib |
1 | In commit f0aff255700 we made cpacr_write() enforce that some CPACR | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately | ||
3 | we forgot to also update the register's reset value. The effect | ||
4 | was that (a) a guest that read CPACR on reset would not see ones in | ||
5 | the RAO bits, and (b) if you did a migration before the guest did | ||
6 | a write to the CPACR then the migration would fail because the | ||
7 | destination would enforce the RAO bits and then complain that they | ||
8 | didn't match the zero value from the source. | ||
9 | 2 | ||
10 | Implement reset for the CPACR using a custom reset function | 3 | Connect the CRL (Clock Reset LPD) to the Versal SoC. |
11 | that just calls cpacr_write(), to avoid having to duplicate | ||
12 | the logic for which bits are RAO. | ||
13 | 4 | ||
14 | This bug would affect migration for TCG CPUs which are ARMv7 | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
15 | with VFP but without one of Neon or VFPv3. | 6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
8 | Message-id: 20220406174303.2022038-5-edgar.iglesias@xilinx.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/xlnx-versal.h | 4 +++ | ||
12 | hw/arm/xlnx-versal.c | 54 ++++++++++++++++++++++++++++++++++-- | ||
13 | 2 files changed, 56 insertions(+), 2 deletions(-) | ||
16 | 14 | ||
17 | Reported-by: Cédric Le Goater <clg@kaod.org> | 15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
20 | Message-id: 20180522173713.26282-1-peter.maydell@linaro.org | ||
21 | --- | ||
22 | target/arm/helper.c | 10 +++++++++- | ||
23 | 1 file changed, 9 insertions(+), 1 deletion(-) | ||
24 | |||
25 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.c | 17 | --- a/include/hw/arm/xlnx-versal.h |
28 | +++ b/target/arm/helper.c | 18 | +++ b/include/hw/arm/xlnx-versal.h |
29 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 19 | @@ -XXX,XX +XXX,XX @@ |
30 | env->cp15.cpacr_el1 = value; | 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]); | ||
31 | } | 50 | } |
32 | 51 | ||
33 | +static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 52 | +static void versal_create_crl(Versal *s, qemu_irq *pic) |
34 | +{ | 53 | +{ |
35 | + /* Call cpacr_write() so that we reset with the correct RAO bits set | 54 | + SysBusDevice *sbd; |
36 | + * for our CPU features. | 55 | + int i; |
37 | + */ | 56 | + |
38 | + cpacr_write(env, ri, 0); | 57 | + object_initialize_child(OBJECT(s), "crl", &s->lpd.crl, |
58 | + TYPE_XLNX_VERSAL_CRL); | ||
59 | + sbd = SYS_BUS_DEVICE(&s->lpd.crl); | ||
60 | + | ||
61 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { | ||
62 | + g_autofree gchar *name = g_strdup_printf("cpu_r5[%d]", i); | ||
63 | + | ||
64 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
65 | + name, OBJECT(&s->lpd.rpu.cpu[i]), | ||
66 | + &error_abort); | ||
67 | + } | ||
68 | + | ||
69 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.gem); i++) { | ||
70 | + g_autofree gchar *name = g_strdup_printf("gem[%d]", i); | ||
71 | + | ||
72 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
73 | + name, OBJECT(&s->lpd.iou.gem[i]), | ||
74 | + &error_abort); | ||
75 | + } | ||
76 | + | ||
77 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.adma); i++) { | ||
78 | + g_autofree gchar *name = g_strdup_printf("adma[%d]", i); | ||
79 | + | ||
80 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
81 | + name, OBJECT(&s->lpd.iou.adma[i]), | ||
82 | + &error_abort); | ||
83 | + } | ||
84 | + | ||
85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.uart); i++) { | ||
86 | + g_autofree gchar *name = g_strdup_printf("uart[%d]", i); | ||
87 | + | ||
88 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
89 | + name, OBJECT(&s->lpd.iou.uart[i]), | ||
90 | + &error_abort); | ||
91 | + } | ||
92 | + | ||
93 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
94 | + "usb", OBJECT(&s->lpd.iou.usb), | ||
95 | + &error_abort); | ||
96 | + | ||
97 | + sysbus_realize(sbd, &error_fatal); | ||
98 | + memory_region_add_subregion(&s->mr_ps, MM_CRL, | ||
99 | + sysbus_mmio_get_region(sbd, 0)); | ||
100 | + sysbus_connect_irq(sbd, 0, pic[VERSAL_CRL_IRQ]); | ||
39 | +} | 101 | +} |
40 | + | 102 | + |
41 | static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | 103 | /* This takes the board allocated linear DDR memory and creates aliases |
42 | bool isread) | 104 | * for each split DDR range/aperture on the Versal address map. |
43 | { | 105 | */ |
44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | 106 | @@ -XXX,XX +XXX,XX @@ static void versal_unimp(Versal *s) |
45 | { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, | 107 | |
46 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | 108 | versal_unimp_area(s, "psm", &s->mr_ps, |
47 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | 109 | MM_PSM_START, MM_PSM_END - MM_PSM_START); |
48 | - .resetvalue = 0, .writefn = cpacr_write }, | 110 | - versal_unimp_area(s, "crl", &s->mr_ps, |
49 | + .resetfn = cpacr_reset, .writefn = cpacr_write }, | 111 | - MM_CRL, MM_CRL_SIZE); |
50 | REGINFO_SENTINEL | 112 | versal_unimp_area(s, "crf", &s->mr_ps, |
51 | }; | 113 | MM_FPD_CRF, MM_FPD_CRF_SIZE); |
114 | versal_unimp_area(s, "apu", &s->mr_ps, | ||
115 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
116 | versal_create_efuse(s, pic); | ||
117 | versal_create_pmc_iou_slcr(s, pic); | ||
118 | versal_create_ospi(s, pic); | ||
119 | + versal_create_crl(s, pic); | ||
120 | versal_map_ddr(s); | ||
121 | versal_unimp(s); | ||
52 | 122 | ||
53 | -- | 123 | -- |
54 | 2.17.1 | 124 | 2.25.1 |
55 | |||
56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The Exynos4210 SoC device currently uses a custom device | ||
2 | "exynos4210.irq_gate" to model the OR gate that feeds each CPU's IRQ | ||
3 | line. We have a standard TYPE_OR_IRQ device for this now, so use | ||
4 | that instead. | ||
1 | 5 | ||
6 | (This is a migration compatibility break, but that is OK for this | ||
7 | machine type.) | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-2-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 + | ||
14 | hw/arm/exynos4210.c | 31 ++++++++++++++++--------------- | ||
15 | 2 files changed, 17 insertions(+), 15 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
22 | MemoryRegion bootreg_mem; | ||
23 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | ||
24 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | ||
25 | + qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
26 | }; | ||
27 | |||
28 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
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 | { | ||
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)); | ||
64 | } | ||
65 | |||
66 | /* Private memory region and Internal GIC */ | ||
67 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
68 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
69 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); | ||
70 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
71 | - sysbus_connect_irq(busdev, n, gate_irq[n][0]); | ||
72 | + sysbus_connect_irq(busdev, n, | ||
73 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
74 | } | ||
75 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | ||
76 | s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
77 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
78 | /* Map Distributer interface */ | ||
79 | sysbus_mmio_map(busdev, 1, EXYNOS4210_EXT_GIC_DIST_BASE_ADDR); | ||
80 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
81 | - sysbus_connect_irq(busdev, n, gate_irq[n][1]); | ||
82 | + sysbus_connect_irq(busdev, n, | ||
83 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
84 | } | ||
85 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
86 | s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
87 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
88 | object_initialize_child(obj, name, orgate, TYPE_OR_IRQ); | ||
89 | g_free(name); | ||
90 | } | ||
91 | + | ||
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 | + } | ||
96 | } | ||
97 | |||
98 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
99 | -- | ||
100 | 2.25.1 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | Now we have removed the only use of TYPE_EXYNOS4210_IRQ_GATE we can |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_translate_iommu(). | 2 | delete the device entirely. |
3 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Message-id: 20220404154658.565020-3-peter.maydell@linaro.org |
7 | Message-id: 20180521140402.23318-14-peter.maydell@linaro.org | ||
8 | --- | 7 | --- |
9 | exec.c | 8 +++++--- | 8 | hw/intc/exynos4210_gic.c | 107 --------------------------------------- |
10 | 1 file changed, 5 insertions(+), 3 deletions(-) | 9 | 1 file changed, 107 deletions(-) |
11 | 10 | ||
12 | diff --git a/exec.c b/exec.c | 11 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c |
13 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 13 | --- a/hw/intc/exynos4210_gic.c |
15 | +++ b/exec.c | 14 | +++ b/hw/intc/exynos4210_gic.c |
16 | @@ -XXX,XX +XXX,XX @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x | 15 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_register_types(void) |
17 | * @is_write: whether the translation operation is for write | ||
18 | * @is_mmio: whether this can be MMIO, set true if it can | ||
19 | * @target_as: the address space targeted by the IOMMU | ||
20 | + * @attrs: transaction attributes | ||
21 | * | ||
22 | * This function is called from RCU critical section. It is the common | ||
23 | * part of flatview_do_translate and address_space_translate_cached. | ||
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iomm | ||
25 | hwaddr *page_mask_out, | ||
26 | bool is_write, | ||
27 | bool is_mmio, | ||
28 | - AddressSpace **target_as) | ||
29 | + AddressSpace **target_as, | ||
30 | + MemTxAttrs attrs) | ||
31 | { | ||
32 | MemoryRegionSection *section; | ||
33 | hwaddr page_mask = (hwaddr)-1; | ||
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | ||
35 | return address_space_translate_iommu(iommu_mr, xlat, | ||
36 | plen_out, page_mask_out, | ||
37 | is_write, is_mmio, | ||
38 | - target_as); | ||
39 | + target_as, attrs); | ||
40 | } | ||
41 | if (page_mask_out) { | ||
42 | /* Not behind an IOMMU, use default page size. */ | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate_cached( | ||
44 | |||
45 | section = address_space_translate_iommu(iommu_mr, xlat, plen, | ||
46 | NULL, is_write, true, | ||
47 | - &target_as); | ||
48 | + &target_as, attrs); | ||
49 | return section.mr; | ||
50 | } | 16 | } |
51 | 17 | ||
18 | type_init(exynos4210_gic_register_types) | ||
19 | - | ||
20 | -/* IRQ OR Gate struct. | ||
21 | - * | ||
22 | - * This device models an OR gate. There are n_in input qdev gpio lines and one | ||
23 | - * output sysbus IRQ line. The output IRQ level is formed as OR between all | ||
24 | - * gpio inputs. | ||
25 | - */ | ||
26 | - | ||
27 | -#define TYPE_EXYNOS4210_IRQ_GATE "exynos4210.irq_gate" | ||
28 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210IRQGateState, EXYNOS4210_IRQ_GATE) | ||
29 | - | ||
30 | -struct Exynos4210IRQGateState { | ||
31 | - SysBusDevice parent_obj; | ||
32 | - | ||
33 | - uint32_t n_in; /* inputs amount */ | ||
34 | - uint32_t *level; /* input levels */ | ||
35 | - qemu_irq out; /* output IRQ */ | ||
36 | -}; | ||
37 | - | ||
38 | -static Property exynos4210_irq_gate_properties[] = { | ||
39 | - DEFINE_PROP_UINT32("n_in", Exynos4210IRQGateState, n_in, 1), | ||
40 | - DEFINE_PROP_END_OF_LIST(), | ||
41 | -}; | ||
42 | - | ||
43 | -static const VMStateDescription vmstate_exynos4210_irq_gate = { | ||
44 | - .name = "exynos4210.irq_gate", | ||
45 | - .version_id = 2, | ||
46 | - .minimum_version_id = 2, | ||
47 | - .fields = (VMStateField[]) { | ||
48 | - VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, 1, NULL, n_in), | ||
49 | - VMSTATE_END_OF_LIST() | ||
50 | - } | ||
51 | -}; | ||
52 | - | ||
53 | -/* Process a change in IRQ input. */ | ||
54 | -static void exynos4210_irq_gate_handler(void *opaque, int irq, int level) | ||
55 | -{ | ||
56 | - Exynos4210IRQGateState *s = (Exynos4210IRQGateState *)opaque; | ||
57 | - uint32_t i; | ||
58 | - | ||
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) | ||
103 | -{ | ||
104 | - DeviceClass *dc = DEVICE_CLASS(klass); | ||
105 | - | ||
106 | - dc->reset = exynos4210_irq_gate_reset; | ||
107 | - dc->vmsd = &vmstate_exynos4210_irq_gate; | ||
108 | - device_class_set_props(dc, exynos4210_irq_gate_properties); | ||
109 | - dc->realize = exynos4210_irq_gate_realize; | ||
110 | -} | ||
111 | - | ||
112 | -static const TypeInfo exynos4210_irq_gate_info = { | ||
113 | - .name = TYPE_EXYNOS4210_IRQ_GATE, | ||
114 | - .parent = TYPE_SYS_BUS_DEVICE, | ||
115 | - .instance_size = sizeof(Exynos4210IRQGateState), | ||
116 | - .instance_init = exynos4210_irq_gate_init, | ||
117 | - .class_init = exynos4210_irq_gate_class_init, | ||
118 | -}; | ||
119 | - | ||
120 | -static void exynos4210_irq_gate_register_types(void) | ||
121 | -{ | ||
122 | - type_register_static(&exynos4210_irq_gate_info); | ||
123 | -} | ||
124 | - | ||
125 | -type_init(exynos4210_irq_gate_register_types) | ||
52 | -- | 126 | -- |
53 | 2.17.1 | 127 | 2.25.1 |
54 | |||
55 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | The exynos4210 SoC mostly creates its child devices as if it were |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_access_valid(). | 2 | board code. This includes the a9mpcore object. Switch that to a |
3 | Its callers now all have an attrs value to hand, so we can | 3 | new-style "embedded in the state struct" creation, because in the |
4 | correct our earlier temporary use of MEMTXATTRS_UNSPECIFIED. | 4 | next commit we're going to want to refer to the object again further |
5 | down in the exynos4210_realize() function. | ||
5 | 6 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | 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> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20180521140402.23318-10-peter.maydell@linaro.org | 9 | Message-id: 20220404154658.565020-4-peter.maydell@linaro.org |
10 | --- | 10 | --- |
11 | exec.c | 12 +++++------- | 11 | include/hw/arm/exynos4210.h | 2 ++ |
12 | 1 file changed, 5 insertions(+), 7 deletions(-) | 12 | hw/arm/exynos4210.c | 11 ++++++----- |
13 | 2 files changed, 8 insertions(+), 5 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/exec.c b/exec.c | 15 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 17 | --- a/include/hw/arm/exynos4210.h |
17 | +++ b/exec.c | 18 | +++ b/include/hw/arm/exynos4210.h |
18 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 20 | |
20 | const uint8_t *buf, int len); | 21 | #include "hw/or-irq.h" |
21 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 22 | #include "hw/sysbus.h" |
22 | - bool is_write); | 23 | +#include "hw/cpu/a9mpcore.h" |
23 | + bool is_write, MemTxAttrs attrs); | 24 | #include "target/arm/cpu-qom.h" |
24 | 25 | #include "qom/object.h" | |
25 | static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data, | 26 | |
26 | unsigned len, MemTxAttrs attrs) | 27 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { |
27 | @@ -XXX,XX +XXX,XX @@ static bool subpage_accepts(void *opaque, hwaddr addr, | 28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; |
28 | #endif | 29 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; |
29 | 30 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | |
30 | return flatview_access_valid(subpage->fv, addr + subpage->base, | 31 | + A9MPPrivState a9mpcore; |
31 | - len, is_write); | 32 | }; |
32 | + len, is_write, attrs); | 33 | |
34 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
35 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/arm/exynos4210.c | ||
38 | +++ b/hw/arm/exynos4210.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
40 | } | ||
41 | |||
42 | /* Private memory region and Internal GIC */ | ||
43 | - dev = qdev_new(TYPE_A9MPCORE_PRIV); | ||
44 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | ||
45 | - busdev = SYS_BUS_DEVICE(dev); | ||
46 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
47 | + qdev_prop_set_uint32(DEVICE(&s->a9mpcore), "num-cpu", EXYNOS4210_NCPUS); | ||
48 | + busdev = SYS_BUS_DEVICE(&s->a9mpcore); | ||
49 | + sysbus_realize(busdev, &error_fatal); | ||
50 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); | ||
51 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
52 | sysbus_connect_irq(busdev, n, | ||
53 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
54 | } | ||
55 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | ||
56 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
57 | + s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); | ||
58 | } | ||
59 | |||
60 | /* Cache controller */ | ||
61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
62 | g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i); | ||
63 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | ||
64 | } | ||
65 | + | ||
66 | + object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
33 | } | 67 | } |
34 | 68 | ||
35 | static const MemoryRegionOps subpage_ops = { | 69 | static void exynos4210_class_init(ObjectClass *klass, void *data) |
36 | @@ -XXX,XX +XXX,XX @@ static void cpu_notify_map_clients(void) | ||
37 | } | ||
38 | |||
39 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
40 | - bool is_write) | ||
41 | + bool is_write, MemTxAttrs attrs) | ||
42 | { | ||
43 | MemoryRegion *mr; | ||
44 | hwaddr l, xlat; | ||
45 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
46 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
47 | if (!memory_access_is_direct(mr, is_write)) { | ||
48 | l = memory_access_size(mr, l, addr); | ||
49 | - /* When our callers all have attrs we'll pass them through here */ | ||
50 | - if (!memory_region_access_valid(mr, xlat, l, is_write, | ||
51 | - MEMTXATTRS_UNSPECIFIED)) { | ||
52 | + if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | ||
57 | |||
58 | rcu_read_lock(); | ||
59 | fv = address_space_to_flatview(as); | ||
60 | - result = flatview_access_valid(fv, addr, len, is_write); | ||
61 | + result = flatview_access_valid(fv, addr, len, is_write, attrs); | ||
62 | rcu_read_unlock(); | ||
63 | return result; | ||
64 | } | ||
65 | -- | 70 | -- |
66 | 2.17.1 | 71 | 2.25.1 |
67 | |||
68 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | The only time we use the int_gic_irq[] array in the Exynos4210Irq |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_do_translate(). | 2 | struct is in the exynos4210_realize() function: we initialize it with |
3 | the GPIO inputs of the a9mpcore device, and then a bit later on we | ||
4 | connect those to the outputs of the internal combiner. Now that the | ||
5 | a9mpcore object is easily accessible as s->a9mpcore we can make the | ||
6 | connection directly from one device to the other without going via | ||
7 | this array. | ||
3 | 8 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180521140402.23318-13-peter.maydell@linaro.org | 11 | Message-id: 20220404154658.565020-5-peter.maydell@linaro.org |
8 | --- | 12 | --- |
9 | exec.c | 9 ++++++--- | 13 | include/hw/arm/exynos4210.h | 1 - |
10 | 1 file changed, 6 insertions(+), 3 deletions(-) | 14 | hw/arm/exynos4210.c | 6 ++---- |
15 | 2 files changed, 2 insertions(+), 5 deletions(-) | ||
11 | 16 | ||
12 | diff --git a/exec.c b/exec.c | 17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
13 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 19 | --- a/include/hw/arm/exynos4210.h |
15 | +++ b/exec.c | 20 | +++ b/include/hw/arm/exynos4210.h |
16 | @@ -XXX,XX +XXX,XX @@ unassigned: | 21 | @@ -XXX,XX +XXX,XX @@ |
17 | * @is_write: whether the translation operation is for write | 22 | typedef struct Exynos4210Irq { |
18 | * @is_mmio: whether this can be MMIO, set true if it can | 23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
19 | * @target_as: the address space targeted by the IOMMU | 24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; |
20 | + * @attrs: memory transaction attributes | 25 | - qemu_irq int_gic_irq[EXYNOS4210_INT_GIC_NIRQ]; |
21 | * | 26 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; |
22 | * This function is called from RCU critical section | 27 | qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
23 | */ | 28 | } Exynos4210Irq; |
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | 29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
25 | hwaddr *page_mask_out, | 30 | index XXXXXXX..XXXXXXX 100644 |
26 | bool is_write, | 31 | --- a/hw/arm/exynos4210.c |
27 | bool is_mmio, | 32 | +++ b/hw/arm/exynos4210.c |
28 | - AddressSpace **target_as) | 33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
29 | + AddressSpace **target_as, | 34 | sysbus_connect_irq(busdev, n, |
30 | + MemTxAttrs attrs) | 35 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); |
31 | { | 36 | } |
32 | MemoryRegionSection *section; | 37 | - for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { |
33 | IOMMUMemoryRegion *iommu_mr; | 38 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); |
34 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 39 | - } |
35 | * but page mask. | 40 | |
36 | */ | 41 | /* Cache controller */ |
37 | section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat, | 42 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); |
38 | - NULL, &page_mask, is_write, false, &as); | 43 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
39 | + NULL, &page_mask, is_write, false, &as, | 44 | busdev = SYS_BUS_DEVICE(dev); |
40 | + attrs); | 45 | sysbus_realize_and_unref(busdev, &error_fatal); |
41 | 46 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | |
42 | /* Illegal translation */ | 47 | - sysbus_connect_irq(busdev, n, s->irqs.int_gic_irq[n]); |
43 | if (section.mr == &io_mem_unassigned) { | 48 | + sysbus_connect_irq(busdev, n, |
44 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | 49 | + qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); |
45 | 50 | } | |
46 | /* This can be MMIO, so setup MMIO bit. */ | 51 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); |
47 | section = flatview_do_translate(fv, addr, xlat, plen, NULL, | 52 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); |
48 | - is_write, true, &as); | ||
49 | + is_write, true, &as, attrs); | ||
50 | mr = section.mr; | ||
51 | |||
52 | if (xen_enabled() && memory_access_is_direct(mr, is_write)) { | ||
53 | -- | 53 | -- |
54 | 2.17.1 | 54 | 2.25.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | The exynos4210 code currently has two very similar arrays of IRQs: |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_map(). | 2 | |
3 | Its callers either have an attrs value to hand, or don't care | 3 | * board_irqs is a field of the Exynos4210Irq struct which is filled |
4 | and can use MEMTXATTRS_UNSPECIFIED. | 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. | ||
5 | 14 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | 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> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20180521140402.23318-5-peter.maydell@linaro.org | 17 | Message-id: 20220404154658.565020-6-peter.maydell@linaro.org |
10 | --- | 18 | --- |
11 | include/exec/memory.h | 3 ++- | 19 | include/hw/arm/exynos4210.h | 8 ++------ |
12 | include/sysemu/dma.h | 3 ++- | 20 | hw/arm/exynos4210.c | 6 +----- |
13 | exec.c | 6 ++++-- | 21 | hw/intc/exynos4210_gic.c | 32 ++++++++------------------------ |
14 | target/ppc/mmu-hash64.c | 3 ++- | 22 | 3 files changed, 11 insertions(+), 35 deletions(-) |
15 | 4 files changed, 10 insertions(+), 5 deletions(-) | ||
16 | 23 | ||
17 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 24 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/memory.h | 26 | --- a/include/hw/arm/exynos4210.h |
20 | +++ b/include/exec/memory.h | 27 | +++ b/include/hw/arm/exynos4210.h |
21 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_ | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210Irq { |
22 | * @addr: address within that address space | 29 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
23 | * @plen: pointer to length of buffer; updated on return | 30 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; |
24 | * @is_write: indicates the transfer direction | 31 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; |
25 | + * @attrs: memory attributes | 32 | - qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
33 | } Exynos4210Irq; | ||
34 | |||
35 | struct Exynos4210State { | ||
36 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
37 | /*< public >*/ | ||
38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | ||
39 | Exynos4210Irq irqs; | ||
40 | - qemu_irq *irq_table; | ||
41 | + qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
42 | |||
43 | MemoryRegion chipid_mem; | ||
44 | MemoryRegion iram_mem; | ||
45 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | ||
46 | void exynos4210_write_secondary(ARMCPU *cpu, | ||
47 | const struct arm_boot_info *info); | ||
48 | |||
49 | -/* Initialize exynos4210 IRQ subsystem stub */ | ||
50 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); | ||
51 | - | ||
52 | /* Initialize board IRQs. | ||
53 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ | ||
54 | -void exynos4210_init_board_irqs(Exynos4210Irq *s); | ||
55 | +void exynos4210_init_board_irqs(Exynos4210State *s); | ||
56 | |||
57 | /* Get IRQ number from exynos4210 IRQ subsystem stub. | ||
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); | ||
65 | } | ||
66 | |||
67 | - /*** IRQs ***/ | ||
68 | - | ||
69 | - s->irq_table = exynos4210_init_irq(&s->irqs); | ||
70 | - | ||
71 | /* IRQ Gate */ | ||
72 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { | ||
73 | DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
75 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
76 | |||
77 | /* Initialize board IRQs. */ | ||
78 | - exynos4210_init_board_irqs(&s->irqs); | ||
79 | + exynos4210_init_board_irqs(s); | ||
80 | |||
81 | /*** Memory ***/ | ||
82 | |||
83 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/hw/intc/exynos4210_gic.c | ||
86 | +++ b/hw/intc/exynos4210_gic.c | ||
87 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
88 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
89 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
90 | |||
91 | -static void exynos4210_irq_handler(void *opaque, int irq, int level) | ||
92 | -{ | ||
93 | - Exynos4210Irq *s = (Exynos4210Irq *)opaque; | ||
94 | - | ||
95 | - /* Bypass */ | ||
96 | - qemu_set_irq(s->board_irqs[irq], level); | ||
97 | -} | ||
98 | - | ||
99 | -/* | ||
100 | - * Initialize exynos4210 IRQ subsystem stub. | ||
101 | - */ | ||
102 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *s) | ||
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. | ||
26 | */ | 111 | */ |
27 | void *address_space_map(AddressSpace *as, hwaddr addr, | 112 | -void exynos4210_init_board_irqs(Exynos4210Irq *s) |
28 | - hwaddr *plen, bool is_write); | 113 | +void exynos4210_init_board_irqs(Exynos4210State *s) |
29 | + hwaddr *plen, bool is_write, MemTxAttrs attrs); | 114 | { |
30 | 115 | uint32_t grp, bit, irq_id, n; | |
31 | /* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() | 116 | + Exynos4210Irq *is = &s->irqs; |
32 | * | 117 | |
33 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | 118 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { |
34 | index XXXXXXX..XXXXXXX 100644 | 119 | irq_id = 0; |
35 | --- a/include/sysemu/dma.h | 120 | @@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s) |
36 | +++ b/include/sysemu/dma.h | 121 | irq_id = EXT_GIC_ID_MCT_G1; |
37 | @@ -XXX,XX +XXX,XX @@ static inline void *dma_memory_map(AddressSpace *as, | 122 | } |
38 | hwaddr xlen = *len; | 123 | if (irq_id) { |
39 | void *p; | 124 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], |
40 | 125 | - s->ext_gic_irq[irq_id-32]); | |
41 | - p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE); | 126 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
42 | + p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE, | 127 | + is->ext_gic_irq[irq_id - 32]); |
43 | + MEMTXATTRS_UNSPECIFIED); | 128 | } else { |
44 | *len = xlen; | 129 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], |
45 | return p; | 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 | } | ||
46 | } | 146 | } |
47 | diff --git a/exec.c b/exec.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/exec.c | ||
50 | +++ b/exec.c | ||
51 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | ||
52 | void *address_space_map(AddressSpace *as, | ||
53 | hwaddr addr, | ||
54 | hwaddr *plen, | ||
55 | - bool is_write) | ||
56 | + bool is_write, | ||
57 | + MemTxAttrs attrs) | ||
58 | { | ||
59 | hwaddr len = *plen; | ||
60 | hwaddr l, xlat; | ||
61 | @@ -XXX,XX +XXX,XX @@ void *cpu_physical_memory_map(hwaddr addr, | ||
62 | hwaddr *plen, | ||
63 | int is_write) | ||
64 | { | ||
65 | - return address_space_map(&address_space_memory, addr, plen, is_write); | ||
66 | + return address_space_map(&address_space_memory, addr, plen, is_write, | ||
67 | + MEMTXATTRS_UNSPECIFIED); | ||
68 | } | ||
69 | |||
70 | void cpu_physical_memory_unmap(void *buffer, hwaddr len, | ||
71 | diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/ppc/mmu-hash64.c | ||
74 | +++ b/target/ppc/mmu-hash64.c | ||
75 | @@ -XXX,XX +XXX,XX @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu, | ||
76 | return NULL; | ||
77 | } | ||
78 | |||
79 | - hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false); | ||
80 | + hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false, | ||
81 | + MEMTXATTRS_UNSPECIFIED); | ||
82 | if (plen < (n * HASH_PTE_SIZE_64)) { | ||
83 | hw_error("%s: Unable to map all requested HPTEs\n", __func__); | ||
84 | } | ||
85 | -- | 147 | -- |
86 | 2.17.1 | 148 | 2.25.1 |
87 | |||
88 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | Fix a missing set of spaces around '-' in the definition of |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_get_iotlb_entry(). | 2 | combiner_grp_to_gic_id[]. We're about to move this code, so |
3 | fix the style issue first to keep checkpatch happy with the | ||
4 | code-motion patch. | ||
3 | 5 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180521140402.23318-12-peter.maydell@linaro.org | 8 | Message-id: 20220404154658.565020-7-peter.maydell@linaro.org |
8 | --- | 9 | --- |
9 | include/exec/memory.h | 2 +- | 10 | hw/intc/exynos4210_gic.c | 2 +- |
10 | exec.c | 2 +- | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | hw/virtio/vhost.c | 3 ++- | ||
12 | 3 files changed, 4 insertions(+), 3 deletions(-) | ||
13 | 12 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 13 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 15 | --- a/hw/intc/exynos4210_gic.c |
17 | +++ b/include/exec/memory.h | 16 | +++ b/hw/intc/exynos4210_gic.c |
18 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache); | 17 | @@ -XXX,XX +XXX,XX @@ enum ExtInt { |
19 | * entry. Should be called from an RCU critical section. | ||
20 | */ | 18 | */ |
21 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 19 | |
22 | - bool is_write); | 20 | static const uint32_t |
23 | + bool is_write, MemTxAttrs attrs); | 21 | -combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { |
24 | 22 | +combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | |
25 | /* address_space_translate: translate an address range into an address space | 23 | /* int combiner groups 16-19 */ |
26 | * into a MemoryRegion and an address range into that section. Should be | 24 | { }, { }, { }, { }, |
27 | diff --git a/exec.c b/exec.c | 25 | /* int combiner group 20 */ |
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/exec.c | ||
30 | +++ b/exec.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | ||
32 | |||
33 | /* Called from RCU critical section */ | ||
34 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | ||
35 | - bool is_write) | ||
36 | + bool is_write, MemTxAttrs attrs) | ||
37 | { | ||
38 | MemoryRegionSection section; | ||
39 | hwaddr xlat, page_mask; | ||
40 | diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/virtio/vhost.c | ||
43 | +++ b/hw/virtio/vhost.c | ||
44 | @@ -XXX,XX +XXX,XX @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write) | ||
45 | trace_vhost_iotlb_miss(dev, 1); | ||
46 | |||
47 | iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as, | ||
48 | - iova, write); | ||
49 | + iova, write, | ||
50 | + MEMTXATTRS_UNSPECIFIED); | ||
51 | if (iotlb.target_as != NULL) { | ||
52 | ret = vhost_memory_region_lookup(dev, iotlb.translated_addr, | ||
53 | &uaddr, &len); | ||
54 | -- | 26 | -- |
55 | 2.17.1 | 27 | 2.25.1 |
56 | |||
57 | diff view generated by jsdifflib |
1 | Provide a VMSTATE_BOOL_SUB_ARRAY to go with VMSTATE_UINT8_SUB_ARRAY | 1 | The function exynos4210_init_board_irqs() currently lives in |
---|---|---|---|
2 | and friends. | 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. | ||
3 | 8 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20180521140402.23318-23-peter.maydell@linaro.org | 11 | Message-id: 20220404154658.565020-8-peter.maydell@linaro.org |
7 | --- | 12 | --- |
8 | include/migration/vmstate.h | 3 +++ | 13 | include/hw/arm/exynos4210.h | 4 - |
9 | 1 file changed, 3 insertions(+) | 14 | hw/arm/exynos4210.c | 202 +++++++++++++++++++++++++++++++++++ |
15 | hw/intc/exynos4210_gic.c | 204 ------------------------------------ | ||
16 | 3 files changed, 202 insertions(+), 208 deletions(-) | ||
10 | 17 | ||
11 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
12 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/migration/vmstate.h | 20 | --- a/include/hw/arm/exynos4210.h |
14 | +++ b/include/migration/vmstate.h | 21 | +++ b/include/hw/arm/exynos4210.h |
15 | @@ -XXX,XX +XXX,XX @@ extern const VMStateInfo vmstate_info_qtailq; | 22 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) |
16 | #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ | 23 | void exynos4210_write_secondary(ARMCPU *cpu, |
17 | VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) | 24 | const struct arm_boot_info *info); |
18 | 25 | ||
19 | +#define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \ | 26 | -/* Initialize board IRQs. |
20 | + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool) | 27 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ |
21 | + | 28 | -void exynos4210_init_board_irqs(Exynos4210State *s); |
22 | #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ | 29 | - |
23 | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) | 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 | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | #define EXYNOS4210_PL330_BASE1_ADDR 0x12690000 | ||
39 | #define EXYNOS4210_PL330_BASE2_ADDR 0x12850000 | ||
40 | |||
41 | +enum ExtGicId { | ||
42 | + EXT_GIC_ID_MDMA_LCD0 = 66, | ||
43 | + EXT_GIC_ID_PDMA0, | ||
44 | + EXT_GIC_ID_PDMA1, | ||
45 | + EXT_GIC_ID_TIMER0, | ||
46 | + EXT_GIC_ID_TIMER1, | ||
47 | + EXT_GIC_ID_TIMER2, | ||
48 | + EXT_GIC_ID_TIMER3, | ||
49 | + EXT_GIC_ID_TIMER4, | ||
50 | + EXT_GIC_ID_MCT_L0, | ||
51 | + EXT_GIC_ID_WDT, | ||
52 | + EXT_GIC_ID_RTC_ALARM, | ||
53 | + EXT_GIC_ID_RTC_TIC, | ||
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) | ||
194 | +{ | ||
195 | + uint32_t grp, bit, irq_id, n; | ||
196 | + Exynos4210Irq *is = &s->irqs; | ||
197 | + | ||
198 | + for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
199 | + irq_id = 0; | ||
200 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
201 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
202 | + /* MCT_G0 is passed to External GIC */ | ||
203 | + irq_id = EXT_GIC_ID_MCT_G0; | ||
204 | + } | ||
205 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | ||
206 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | ||
207 | + /* MCT_G1 is passed to External and GIC */ | ||
208 | + irq_id = EXT_GIC_ID_MCT_G1; | ||
209 | + } | ||
210 | + if (irq_id) { | ||
211 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
212 | + is->ext_gic_irq[irq_id - 32]); | ||
213 | + } else { | ||
214 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
215 | + is->ext_combiner_irq[n]); | ||
216 | + } | ||
217 | + } | ||
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 | + } | ||
230 | +} | ||
231 | + | ||
232 | +/* | ||
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) | ||
239 | +{ | ||
240 | + return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
241 | +} | ||
242 | + | ||
243 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
244 | 0x09, 0x00, 0x00, 0x00 }; | ||
245 | |||
246 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
247 | index XXXXXXX..XXXXXXX 100644 | ||
248 | --- a/hw/intc/exynos4210_gic.c | ||
249 | +++ b/hw/intc/exynos4210_gic.c | ||
250 | @@ -XXX,XX +XXX,XX @@ | ||
251 | #include "hw/arm/exynos4210.h" | ||
252 | #include "qom/object.h" | ||
253 | |||
254 | -enum ExtGicId { | ||
255 | - EXT_GIC_ID_MDMA_LCD0 = 66, | ||
256 | - EXT_GIC_ID_PDMA0, | ||
257 | - EXT_GIC_ID_PDMA1, | ||
258 | - EXT_GIC_ID_TIMER0, | ||
259 | - EXT_GIC_ID_TIMER1, | ||
260 | - EXT_GIC_ID_TIMER2, | ||
261 | - EXT_GIC_ID_TIMER3, | ||
262 | - EXT_GIC_ID_TIMER4, | ||
263 | - EXT_GIC_ID_MCT_L0, | ||
264 | - EXT_GIC_ID_WDT, | ||
265 | - EXT_GIC_ID_RTC_ALARM, | ||
266 | - EXT_GIC_ID_RTC_TIC, | ||
267 | - EXT_GIC_ID_GPIO_XB, | ||
268 | - EXT_GIC_ID_GPIO_XA, | ||
269 | - EXT_GIC_ID_MCT_L1, | ||
270 | - EXT_GIC_ID_IEM_APC, | ||
271 | - EXT_GIC_ID_IEM_IEC, | ||
272 | - EXT_GIC_ID_NFC, | ||
273 | - EXT_GIC_ID_UART0, | ||
274 | - EXT_GIC_ID_UART1, | ||
275 | - EXT_GIC_ID_UART2, | ||
276 | - EXT_GIC_ID_UART3, | ||
277 | - EXT_GIC_ID_UART4, | ||
278 | - EXT_GIC_ID_MCT_G0, | ||
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) | ||
24 | 467 | ||
25 | -- | 468 | -- |
26 | 2.17.1 | 469 | 2.25.1 |
27 | |||
28 | diff view generated by jsdifflib |
1 | Add entries to MAINTAINERS to cover the newer MPS2 boards and | 1 | Switch the creation of the external GIC to the new-style "embedded in |
---|---|---|---|
2 | the new devices they use. | 2 | state struct" approach, so we can easily refer to the object |
3 | elsewhere during realize. | ||
3 | 4 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20180518153157.14899-1-peter.maydell@linaro.org | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20220404154658.565020-9-peter.maydell@linaro.org | ||
6 | --- | 8 | --- |
7 | MAINTAINERS | 9 +++++++-- | 9 | include/hw/arm/exynos4210.h | 2 ++ |
8 | 1 file changed, 7 insertions(+), 2 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 | ||
9 | 16 | ||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #include "hw/or-irq.h" | ||
23 | #include "hw/sysbus.h" | ||
24 | #include "hw/cpu/a9mpcore.h" | ||
25 | +#include "hw/intc/exynos4210_gic.h" | ||
26 | #include "target/arm/cpu-qom.h" | ||
27 | #include "qom/object.h" | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
30 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | ||
31 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
32 | A9MPPrivState a9mpcore; | ||
33 | + Exynos4210GicState ext_gic; | ||
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)); | ||
106 | } | ||
107 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
108 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
109 | + s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); | ||
110 | } | ||
111 | |||
112 | /* Internal Interrupt Combiner */ | ||
113 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
114 | } | ||
115 | |||
116 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
117 | + object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
118 | } | ||
119 | |||
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); | ||
10 | diff --git a/MAINTAINERS b/MAINTAINERS | 163 | diff --git a/MAINTAINERS b/MAINTAINERS |
11 | index XXXXXXX..XXXXXXX 100644 | 164 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/MAINTAINERS | 165 | --- a/MAINTAINERS |
13 | +++ b/MAINTAINERS | 166 | +++ b/MAINTAINERS |
14 | @@ -XXX,XX +XXX,XX @@ F: hw/timer/cmsdk-apb-timer.c | ||
15 | F: include/hw/timer/cmsdk-apb-timer.h | ||
16 | F: hw/char/cmsdk-apb-uart.c | ||
17 | F: include/hw/char/cmsdk-apb-uart.h | ||
18 | +F: hw/misc/tz-ppc.c | ||
19 | +F: include/hw/misc/tz-ppc.h | ||
20 | |||
21 | ARM cores | ||
22 | M: Peter Maydell <peter.maydell@linaro.org> | ||
23 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | 167 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> |
24 | L: qemu-arm@nongnu.org | 168 | L: qemu-arm@nongnu.org |
25 | S: Maintained | 169 | S: Odd Fixes |
26 | F: hw/arm/mps2.c | 170 | F: hw/*/exynos* |
27 | -F: hw/misc/mps2-scc.c | 171 | -F: include/hw/arm/exynos4210.h |
28 | -F: include/hw/misc/mps2-scc.h | 172 | +F: include/hw/*/exynos* |
29 | +F: hw/arm/mps2-tz.c | 173 | |
30 | +F: hw/misc/mps2-*.c | 174 | Calxeda Highbank |
31 | +F: include/hw/misc/mps2-*.h | 175 | M: Rob Herring <robh@kernel.org> |
32 | +F: hw/arm/iotkit.c | ||
33 | +F: include/hw/arm/iotkit.h | ||
34 | |||
35 | Musicpal | ||
36 | M: Jan Kiszka <jan.kiszka@web.de> | ||
37 | -- | 176 | -- |
38 | 2.17.1 | 177 | 2.25.1 |
39 | |||
40 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | The only time we use the ext_gic_irq[] array in the Exynos4210Irq |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_translate() | 2 | struct is during realize of the SoC -- we initialize it with the |
3 | and address_space_translate_cached(). Callers either have an | 3 | input IRQs of the external GIC device, and then connect those to |
4 | attrs value to hand, or don't care and can use MEMTXATTRS_UNSPECIFIED. | 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. | ||
5 | 8 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | 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> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20180521140402.23318-4-peter.maydell@linaro.org | 11 | Message-id: 20220404154658.565020-10-peter.maydell@linaro.org |
10 | --- | 12 | --- |
11 | include/exec/memory.h | 4 +++- | 13 | include/hw/arm/exynos4210.h | 1 - |
12 | accel/tcg/translate-all.c | 2 +- | 14 | hw/arm/exynos4210.c | 12 ++++++------ |
13 | exec.c | 14 +++++++++----- | 15 | 2 files changed, 6 insertions(+), 7 deletions(-) |
14 | hw/vfio/common.c | 3 ++- | ||
15 | memory_ldst.inc.c | 18 +++++++++--------- | ||
16 | target/riscv/helper.c | 2 +- | ||
17 | 6 files changed, 25 insertions(+), 18 deletions(-) | ||
18 | 16 | ||
19 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
20 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/exec/memory.h | 19 | --- a/include/hw/arm/exynos4210.h |
22 | +++ b/include/exec/memory.h | 20 | +++ b/include/hw/arm/exynos4210.h |
23 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 21 | @@ -XXX,XX +XXX,XX @@ |
24 | * #MemoryRegion. | 22 | typedef struct Exynos4210Irq { |
25 | * @len: pointer to length | 23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
26 | * @is_write: indicates the transfer direction | 24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; |
27 | + * @attrs: memory attributes | 25 | - qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; |
28 | */ | 26 | } Exynos4210Irq; |
29 | MemoryRegion *flatview_translate(FlatView *fv, | 27 | |
30 | hwaddr addr, hwaddr *xlat, | 28 | struct Exynos4210State { |
31 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, | 29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
32 | 30 | index XXXXXXX..XXXXXXX 100644 | |
33 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | 31 | --- a/hw/arm/exynos4210.c |
34 | hwaddr addr, hwaddr *xlat, | 32 | +++ b/hw/arm/exynos4210.c |
35 | - hwaddr *len, bool is_write) | 33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
36 | + hwaddr *len, bool is_write, | ||
37 | + MemTxAttrs attrs) | ||
38 | { | 34 | { |
39 | return flatview_translate(address_space_to_flatview(as), | 35 | uint32_t grp, bit, irq_id, n; |
40 | addr, xlat, len, is_write); | 36 | Exynos4210Irq *is = &s->irqs; |
41 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 37 | + DeviceState *extgicdev = DEVICE(&s->ext_gic); |
42 | index XXXXXXX..XXXXXXX 100644 | 38 | |
43 | --- a/accel/tcg/translate-all.c | 39 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { |
44 | +++ b/accel/tcg/translate-all.c | 40 | irq_id = 0; |
45 | @@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | 41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
46 | hwaddr l = 1; | 42 | } |
47 | 43 | if (irq_id) { | |
48 | rcu_read_lock(); | 44 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
49 | - mr = address_space_translate(as, addr, &addr, &l, false); | 45 | - is->ext_gic_irq[irq_id - 32]); |
50 | + mr = address_space_translate(as, addr, &addr, &l, false, attrs); | 46 | + qdev_get_gpio_in(extgicdev, |
51 | if (!(memory_region_is_ram(mr) | 47 | + irq_id - 32)); |
52 | || memory_region_is_romd(mr))) { | 48 | } else { |
53 | rcu_read_unlock(); | 49 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
54 | diff --git a/exec.c b/exec.c | 50 | is->ext_combiner_irq[n]); |
55 | index XXXXXXX..XXXXXXX 100644 | 51 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
56 | --- a/exec.c | 52 | |
57 | +++ b/exec.c | 53 | if (irq_id) { |
58 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, | 54 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
59 | rcu_read_lock(); | 55 | - is->ext_gic_irq[irq_id - 32]); |
60 | while (len > 0) { | 56 | + qdev_get_gpio_in(extgicdev, |
61 | l = len; | 57 | + irq_id - 32)); |
62 | - mr = address_space_translate(as, addr, &addr1, &l, true); | 58 | } |
63 | + mr = address_space_translate(as, addr, &addr1, &l, true, | 59 | } |
64 | + MEMTXATTRS_UNSPECIFIED); | 60 | } |
65 | 61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | |
66 | if (!(memory_region_is_ram(mr) || | 62 | sysbus_connect_irq(busdev, n, |
67 | memory_region_is_romd(mr))) { | 63 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); |
68 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache) | 64 | } |
69 | */ | 65 | - for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { |
70 | static inline MemoryRegion *address_space_translate_cached( | 66 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); |
71 | MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat, | 67 | - } |
72 | - hwaddr *plen, bool is_write) | 68 | |
73 | + hwaddr *plen, bool is_write, MemTxAttrs attrs) | 69 | /* Internal Interrupt Combiner */ |
74 | { | 70 | dev = qdev_new("exynos4210.combiner"); |
75 | MemoryRegionSection section; | 71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
76 | MemoryRegion *mr; | 72 | busdev = SYS_BUS_DEVICE(dev); |
77 | @@ -XXX,XX +XXX,XX @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, | 73 | sysbus_realize_and_unref(busdev, &error_fatal); |
78 | MemoryRegion *mr; | 74 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { |
79 | 75 | - sysbus_connect_irq(busdev, n, s->irqs.ext_gic_irq[n]); | |
80 | l = len; | 76 | + sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); |
81 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, false); | 77 | } |
82 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, false, | 78 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); |
83 | + MEMTXATTRS_UNSPECIFIED); | 79 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); |
84 | flatview_read_continue(cache->fv, | ||
85 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | ||
86 | addr1, l, mr); | ||
87 | @@ -XXX,XX +XXX,XX @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, | ||
88 | MemoryRegion *mr; | ||
89 | |||
90 | l = len; | ||
91 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, true); | ||
92 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, true, | ||
93 | + MEMTXATTRS_UNSPECIFIED); | ||
94 | flatview_write_continue(cache->fv, | ||
95 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | ||
96 | addr1, l, mr); | ||
97 | @@ -XXX,XX +XXX,XX @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) | ||
98 | |||
99 | rcu_read_lock(); | ||
100 | mr = address_space_translate(&address_space_memory, | ||
101 | - phys_addr, &phys_addr, &l, false); | ||
102 | + phys_addr, &phys_addr, &l, false, | ||
103 | + MEMTXATTRS_UNSPECIFIED); | ||
104 | |||
105 | res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr)); | ||
106 | rcu_read_unlock(); | ||
107 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/hw/vfio/common.c | ||
110 | +++ b/hw/vfio/common.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, | ||
112 | */ | ||
113 | mr = address_space_translate(&address_space_memory, | ||
114 | iotlb->translated_addr, | ||
115 | - &xlat, &len, writable); | ||
116 | + &xlat, &len, writable, | ||
117 | + MEMTXATTRS_UNSPECIFIED); | ||
118 | if (!memory_region_is_ram(mr)) { | ||
119 | error_report("iommu map to non memory area %"HWADDR_PRIx"", | ||
120 | xlat); | ||
121 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/memory_ldst.inc.c | ||
124 | +++ b/memory_ldst.inc.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | ||
126 | bool release_lock = false; | ||
127 | |||
128 | RCU_READ_LOCK(); | ||
129 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
130 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
131 | if (l < 4 || !IS_DIRECT(mr, false)) { | ||
132 | release_lock |= prepare_mmio_access(mr); | ||
133 | |||
134 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | ||
135 | bool release_lock = false; | ||
136 | |||
137 | RCU_READ_LOCK(); | ||
138 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
139 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
140 | if (l < 8 || !IS_DIRECT(mr, false)) { | ||
141 | release_lock |= prepare_mmio_access(mr); | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, | ||
144 | bool release_lock = false; | ||
145 | |||
146 | RCU_READ_LOCK(); | ||
147 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
148 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
149 | if (!IS_DIRECT(mr, false)) { | ||
150 | release_lock |= prepare_mmio_access(mr); | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | ||
153 | bool release_lock = false; | ||
154 | |||
155 | RCU_READ_LOCK(); | ||
156 | - mr = TRANSLATE(addr, &addr1, &l, false); | ||
157 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | ||
158 | if (l < 2 || !IS_DIRECT(mr, false)) { | ||
159 | release_lock |= prepare_mmio_access(mr); | ||
160 | |||
161 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL, | ||
162 | bool release_lock = false; | ||
163 | |||
164 | RCU_READ_LOCK(); | ||
165 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
166 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
167 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
168 | release_lock |= prepare_mmio_access(mr); | ||
169 | |||
170 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
171 | bool release_lock = false; | ||
172 | |||
173 | RCU_READ_LOCK(); | ||
174 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
175 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
176 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
177 | release_lock |= prepare_mmio_access(mr); | ||
178 | |||
179 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, | ||
180 | bool release_lock = false; | ||
181 | |||
182 | RCU_READ_LOCK(); | ||
183 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
184 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
185 | if (!IS_DIRECT(mr, true)) { | ||
186 | release_lock |= prepare_mmio_access(mr); | ||
187 | r = memory_region_dispatch_write(mr, addr1, val, 1, attrs); | ||
188 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
189 | bool release_lock = false; | ||
190 | |||
191 | RCU_READ_LOCK(); | ||
192 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
193 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
194 | if (l < 2 || !IS_DIRECT(mr, true)) { | ||
195 | release_lock |= prepare_mmio_access(mr); | ||
196 | |||
197 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
198 | bool release_lock = false; | ||
199 | |||
200 | RCU_READ_LOCK(); | ||
201 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
202 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
203 | if (l < 8 || !IS_DIRECT(mr, true)) { | ||
204 | release_lock |= prepare_mmio_access(mr); | ||
205 | |||
206 | diff --git a/target/riscv/helper.c b/target/riscv/helper.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/target/riscv/helper.c | ||
209 | +++ b/target/riscv/helper.c | ||
210 | @@ -XXX,XX +XXX,XX @@ restart: | ||
211 | MemoryRegion *mr; | ||
212 | hwaddr l = sizeof(target_ulong), addr1; | ||
213 | mr = address_space_translate(cs->as, pte_addr, | ||
214 | - &addr1, &l, false); | ||
215 | + &addr1, &l, false, MEMTXATTRS_UNSPECIFIED); | ||
216 | if (memory_access_is_direct(mr, true)) { | ||
217 | target_ulong *pte_pa = | ||
218 | qemu_map_ram_ptr(mr->ram_block, addr1); | ||
219 | -- | 80 | -- |
220 | 2.17.1 | 81 | 2.25.1 |
221 | |||
222 | diff view generated by jsdifflib |
1 | Add more detail to the documentation for memory_region_init_iommu() | 1 | The function exynos4210_combiner_get_gpioin() currently lives in |
---|---|---|---|
2 | and other IOMMU-related functions and data structures. | 2 | exynos4210_combiner.c, but it isn't really part of the combiner |
3 | device itself -- it is a function that implements the wiring up of | ||
4 | some interrupt sources to multiple combiner inputs. Move it to live | ||
5 | with the other SoC-level code in exynos4210.c, along with a few | ||
6 | macros previously defined in exynos4210.h which are now used only | ||
7 | in exynos4210.c. | ||
3 | 8 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 11 | Message-id: 20220404154658.565020-11-peter.maydell@linaro.org |
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20180521140402.23318-2-peter.maydell@linaro.org | ||
9 | --- | 12 | --- |
10 | include/exec/memory.h | 105 ++++++++++++++++++++++++++++++++++++++---- | 13 | include/hw/arm/exynos4210.h | 11 ----- |
11 | 1 file changed, 95 insertions(+), 10 deletions(-) | 14 | hw/arm/exynos4210.c | 82 +++++++++++++++++++++++++++++++++++ |
15 | hw/intc/exynos4210_combiner.c | 77 -------------------------------- | ||
16 | 3 files changed, 82 insertions(+), 88 deletions(-) | ||
12 | 17 | ||
13 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
14 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/exec/memory.h | 20 | --- a/include/hw/arm/exynos4210.h |
16 | +++ b/include/exec/memory.h | 21 | +++ b/include/hw/arm/exynos4210.h |
17 | @@ -XXX,XX +XXX,XX @@ enum IOMMUMemoryRegionAttr { | 22 | @@ -XXX,XX +XXX,XX @@ |
18 | IOMMU_ATTR_SPAPR_TCE_FD | 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 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
19 | }; | 53 | }; |
20 | 54 | ||
21 | +/** | 55 | +#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp) * 8 + (bit)) |
22 | + * IOMMUMemoryRegionClass: | 56 | +#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8) |
23 | + * | 57 | +#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ |
24 | + * All IOMMU implementations need to subclass TYPE_IOMMU_MEMORY_REGION | 58 | + ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) |
25 | + * and provide an implementation of at least the @translate method here | 59 | + |
26 | + * to handle requests to the memory region. Other methods are optional. | 60 | /* |
27 | + * | 61 | * Initialize board IRQs. |
28 | + * The IOMMU implementation must use the IOMMU notifier infrastructure | 62 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. |
29 | + * to report whenever mappings are changed, by calling | 63 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) |
30 | + * memory_region_notify_iommu() (or, if necessary, by calling | 64 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); |
31 | + * memory_region_notify_one() for each registered notifier). | 65 | } |
66 | |||
67 | +/* | ||
68 | + * Get Combiner input GPIO into irqs structure | ||
32 | + */ | 69 | + */ |
33 | typedef struct IOMMUMemoryRegionClass { | 70 | +static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, |
34 | /* private */ | 71 | + DeviceState *dev, int ext) |
35 | struct DeviceClass parent_class; | 72 | +{ |
36 | 73 | + int n; | |
37 | /* | 74 | + int bit; |
38 | - * Return a TLB entry that contains a given address. Flag should | 75 | + int max; |
39 | - * be the access permission of this translation operation. We can | 76 | + qemu_irq *irq; |
40 | - * set flag to IOMMU_NONE to mean that we don't need any | 77 | + |
41 | - * read/write permission checks, like, when for region replay. | 78 | + max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : |
42 | + * Return a TLB entry that contains a given address. | 79 | + EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; |
43 | + * | 80 | + irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; |
44 | + * The IOMMUAccessFlags indicated via @flag are optional and may | 81 | + |
45 | + * be specified as IOMMU_NONE to indicate that the caller needs | 82 | + /* |
46 | + * the full translation information for both reads and writes. If | 83 | + * Some IRQs of Int/External Combiner are going to two Combiners groups, |
47 | + * the access flags are specified then the IOMMU implementation | 84 | + * so let split them. |
48 | + * may use this as an optimization, to stop doing a page table | ||
49 | + * walk as soon as it knows that the requested permissions are not | ||
50 | + * allowed. If IOMMU_NONE is passed then the IOMMU must do the | ||
51 | + * full page table walk and report the permissions in the returned | ||
52 | + * IOMMUTLBEntry. (Note that this implies that an IOMMU may not | ||
53 | + * return different mappings for reads and writes.) | ||
54 | + * | ||
55 | + * The returned information remains valid while the caller is | ||
56 | + * holding the big QEMU lock or is inside an RCU critical section; | ||
57 | + * if the caller wishes to cache the mapping beyond that it must | ||
58 | + * register an IOMMU notifier so it can invalidate its cached | ||
59 | + * information when the IOMMU mapping changes. | ||
60 | + * | ||
61 | + * @iommu: the IOMMUMemoryRegion | ||
62 | + * @hwaddr: address to be translated within the memory region | ||
63 | + * @flag: requested access permissions | ||
64 | */ | ||
65 | IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr, | ||
66 | IOMMUAccessFlags flag); | ||
67 | - /* Returns minimum supported page size */ | ||
68 | + /* Returns minimum supported page size in bytes. | ||
69 | + * If this method is not provided then the minimum is assumed to | ||
70 | + * be TARGET_PAGE_SIZE. | ||
71 | + * | ||
72 | + * @iommu: the IOMMUMemoryRegion | ||
73 | + */ | 85 | + */ |
74 | uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu); | 86 | + for (n = 0; n < max; n++) { |
75 | - /* Called when IOMMU Notifier flag changed */ | 87 | + |
76 | + /* Called when IOMMU Notifier flag changes (ie when the set of | 88 | + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); |
77 | + * events which IOMMU users are requesting notification for changes). | 89 | + |
78 | + * Optional method -- need not be provided if the IOMMU does not | 90 | + switch (n) { |
79 | + * need to know exactly which events must be notified. | 91 | + /* MDNIE_LCD1 INTG1 */ |
80 | + * | 92 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... |
81 | + * @iommu: the IOMMUMemoryRegion | 93 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): |
82 | + * @old_flags: events which previously needed to be notified | 94 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
83 | + * @new_flags: events which now need to be notified | 95 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); |
84 | + */ | 96 | + continue; |
85 | void (*notify_flag_changed)(IOMMUMemoryRegion *iommu, | 97 | + |
86 | IOMMUNotifierFlag old_flags, | 98 | + /* TMU INTG3 */ |
87 | IOMMUNotifierFlag new_flags); | 99 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): |
88 | - /* Set this up to provide customized IOMMU replay function */ | 100 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
89 | + /* Called to handle memory_region_iommu_replay(). | 101 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); |
90 | + * | 102 | + continue; |
91 | + * The default implementation of memory_region_iommu_replay() is to | 103 | + |
92 | + * call the IOMMU translate method for every page in the address space | 104 | + /* LCD1 INTG12 */ |
93 | + * with flag == IOMMU_NONE and then call the notifier if translate | 105 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... |
94 | + * returns a valid mapping. If this method is implemented then it | 106 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): |
95 | + * overrides the default behaviour, and must provide the full semantics | 107 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
96 | + * of memory_region_iommu_replay(), by calling @notifier for every | 108 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); |
97 | + * translation present in the IOMMU. | 109 | + continue; |
98 | + * | 110 | + |
99 | + * Optional method -- an IOMMU only needs to provide this method | 111 | + /* Multi-Core Timer INTG12 */ |
100 | + * if the default is inefficient or produces undesirable side effects. | 112 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... |
101 | + * | 113 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): |
102 | + * Note: this is not related to record-and-replay functionality. | 114 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
103 | + */ | 115 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); |
104 | void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier); | 116 | + continue; |
105 | 117 | + | |
106 | - /* Get IOMMU misc attributes */ | 118 | + /* Multi-Core Timer INTG35 */ |
107 | - int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr, | 119 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... |
108 | + /* Get IOMMU misc attributes. This is an optional method that | 120 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): |
109 | + * can be used to allow users of the IOMMU to get implementation-specific | 121 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
110 | + * information. The IOMMU implements this method to handle calls | 122 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); |
111 | + * by IOMMU users to memory_region_iommu_get_attr() by filling in | 123 | + continue; |
112 | + * the arbitrary data pointer for any IOMMUMemoryRegionAttr values that | 124 | + |
113 | + * the IOMMU supports. If the method is unimplemented then | 125 | + /* Multi-Core Timer INTG51 */ |
114 | + * memory_region_iommu_get_attr() will always return -EINVAL. | 126 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... |
115 | + * | 127 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): |
116 | + * @iommu: the IOMMUMemoryRegion | 128 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
117 | + * @attr: attribute being queried | 129 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); |
118 | + * @data: memory to fill in with the attribute data | 130 | + continue; |
119 | + * | 131 | + |
120 | + * Returns 0 on success, or a negative errno; in particular | 132 | + /* Multi-Core Timer INTG53 */ |
121 | + * returns -EINVAL for unrecognized or unimplemented attribute types. | 133 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... |
122 | + */ | 134 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): |
123 | + int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr attr, | 135 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
124 | void *data); | 136 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); |
125 | } IOMMUMemoryRegionClass; | 137 | + continue; |
126 | 138 | + } | |
127 | @@ -XXX,XX +XXX,XX @@ static inline void memory_region_init_reservation(MemoryRegion *mr, | 139 | + |
128 | * An IOMMU region translates addresses and forwards accesses to a target | 140 | + irq[n] = qdev_get_gpio_in(dev, n); |
129 | * memory region. | 141 | + } |
130 | * | 142 | +} |
131 | + * The IOMMU implementation must define a subclass of TYPE_IOMMU_MEMORY_REGION. | 143 | + |
132 | + * @_iommu_mr should be a pointer to enough memory for an instance of | 144 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, |
133 | + * that subclass, @instance_size is the size of that subclass, and | 145 | 0x09, 0x00, 0x00, 0x00 }; |
134 | + * @mrtypename is its name. This function will initialize @_iommu_mr as an | 146 | |
135 | + * instance of the subclass, and its methods will then be called to handle | 147 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c |
136 | + * accesses to the memory region. See the documentation of | 148 | index XXXXXXX..XXXXXXX 100644 |
137 | + * #IOMMUMemoryRegionClass for further details. | 149 | --- a/hw/intc/exynos4210_combiner.c |
138 | + * | 150 | +++ b/hw/intc/exynos4210_combiner.c |
139 | * @_iommu_mr: the #IOMMUMemoryRegion to be initialized | 151 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_exynos4210_combiner = { |
140 | * @instance_size: the IOMMUMemoryRegion subclass instance size | 152 | } |
141 | * @mrtypename: the type name of the #IOMMUMemoryRegion | 153 | }; |
142 | @@ -XXX,XX +XXX,XX @@ void memory_region_register_iommu_notifier(MemoryRegion *mr, | 154 | |
143 | * a notifier with the minimum page granularity returned by | 155 | -/* |
144 | * mr->iommu_ops->get_page_size(). | 156 | - * Get Combiner input GPIO into irqs structure |
145 | * | 157 | - */ |
146 | + * Note: this is not related to record-and-replay functionality. | 158 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, |
147 | + * | 159 | - int ext) |
148 | * @iommu_mr: the memory region to observe | 160 | -{ |
149 | * @n: the notifier to which to replay iommu mappings | 161 | - int n; |
150 | */ | 162 | - int bit; |
151 | @@ -XXX,XX +XXX,XX @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n); | 163 | - int max; |
152 | * memory_region_iommu_replay_all: replay existing IOMMU translations | 164 | - qemu_irq *irq; |
153 | * to all the notifiers registered. | 165 | - |
154 | * | 166 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : |
155 | + * Note: this is not related to record-and-replay functionality. | 167 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; |
156 | + * | 168 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; |
157 | * @iommu_mr: the memory region to observe | 169 | - |
158 | */ | 170 | - /* |
159 | void memory_region_iommu_replay_all(IOMMUMemoryRegion *iommu_mr); | 171 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, |
160 | @@ -XXX,XX +XXX,XX @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, | 172 | - * so let split them. |
161 | * memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is | 173 | - */ |
162 | * defined on the IOMMU. | 174 | - for (n = 0; n < max; n++) { |
163 | * | 175 | - |
164 | - * Returns 0 if succeded, error code otherwise. | 176 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); |
165 | + * Returns 0 on success, or a negative errno otherwise. In particular, | 177 | - |
166 | + * -EINVAL indicates that the IOMMU does not support the requested | 178 | - switch (n) { |
167 | + * attribute. | 179 | - /* MDNIE_LCD1 INTG1 */ |
168 | * | 180 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... |
169 | * @iommu_mr: the memory region | 181 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): |
170 | * @attr: the requested attribute | 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; | ||
226 | - } | ||
227 | - | ||
228 | - irq[n] = qdev_get_gpio_in(dev, n); | ||
229 | - } | ||
230 | -} | ||
231 | - | ||
232 | static uint64_t | ||
233 | exynos4210_combiner_read(void *opaque, hwaddr offset, unsigned size) | ||
234 | { | ||
171 | -- | 235 | -- |
172 | 2.17.1 | 236 | 2.25.1 |
173 | |||
174 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | Delete a couple of #defines which are never used. |
---|---|---|---|
2 | add MemTxAttrs as an argument to memory_region_access_valid(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | |||
6 | The callsite in flatview_access_valid() is part of a recursive | ||
7 | loop flatview_access_valid() -> memory_region_access_valid() -> | ||
8 | subpage_accepts() -> flatview_access_valid(); we make it pass | ||
9 | MEMTXATTRS_UNSPECIFIED for now, until the next several commits | ||
10 | have plumbed an attrs parameter through the rest of the loop | ||
11 | and we can add an attrs parameter to flatview_access_valid(). | ||
12 | 2 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
16 | Message-id: 20180521140402.23318-8-peter.maydell@linaro.org | 5 | Message-id: 20220404154658.565020-12-peter.maydell@linaro.org |
17 | --- | 6 | --- |
18 | include/exec/memory-internal.h | 3 ++- | 7 | include/hw/arm/exynos4210.h | 4 ---- |
19 | exec.c | 4 +++- | 8 | 1 file changed, 4 deletions(-) |
20 | hw/s390x/s390-pci-inst.c | 3 ++- | ||
21 | memory.c | 7 ++++--- | ||
22 | 4 files changed, 11 insertions(+), 6 deletions(-) | ||
23 | 9 | ||
24 | diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h | 10 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
25 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory-internal.h | 12 | --- a/include/hw/arm/exynos4210.h |
27 | +++ b/include/exec/memory-internal.h | 13 | +++ b/include/hw/arm/exynos4210.h |
28 | @@ -XXX,XX +XXX,XX @@ void flatview_unref(FlatView *view); | 14 | @@ -XXX,XX +XXX,XX @@ |
29 | extern const MemoryRegionOps unassigned_mem_ops; | 15 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ |
30 | 16 | (EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8) | |
31 | bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr, | 17 | |
32 | - unsigned size, bool is_write); | 18 | -/* IRQs number for external and internal GIC */ |
33 | + unsigned size, bool is_write, | 19 | -#define EXYNOS4210_EXT_GIC_NIRQ (160-32) |
34 | + MemTxAttrs attrs); | 20 | -#define EXYNOS4210_INT_GIC_NIRQ 64 |
35 | 21 | - | |
36 | void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); | 22 | #define EXYNOS4210_I2C_NUMBER 9 |
37 | AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); | 23 | |
38 | diff --git a/exec.c b/exec.c | 24 | #define EXYNOS4210_NUM_DMA 3 |
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/exec.c | ||
41 | +++ b/exec.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
43 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
44 | if (!memory_access_is_direct(mr, is_write)) { | ||
45 | l = memory_access_size(mr, l, addr); | ||
46 | - if (!memory_region_access_valid(mr, xlat, l, is_write)) { | ||
47 | + /* When our callers all have attrs we'll pass them through here */ | ||
48 | + if (!memory_region_access_valid(mr, xlat, l, is_write, | ||
49 | + MEMTXATTRS_UNSPECIFIED)) { | ||
50 | return false; | ||
51 | } | ||
52 | } | ||
53 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/s390x/s390-pci-inst.c | ||
56 | +++ b/hw/s390x/s390-pci-inst.c | ||
57 | @@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, | ||
58 | mr = s390_get_subregion(mr, offset, len); | ||
59 | offset -= mr->addr; | ||
60 | |||
61 | - if (!memory_region_access_valid(mr, offset, len, true)) { | ||
62 | + if (!memory_region_access_valid(mr, offset, len, true, | ||
63 | + MEMTXATTRS_UNSPECIFIED)) { | ||
64 | s390_program_interrupt(env, PGM_OPERAND, 6, ra); | ||
65 | return 0; | ||
66 | } | ||
67 | diff --git a/memory.c b/memory.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/memory.c | ||
70 | +++ b/memory.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ram_device_mem_ops = { | ||
72 | bool memory_region_access_valid(MemoryRegion *mr, | ||
73 | hwaddr addr, | ||
74 | unsigned size, | ||
75 | - bool is_write) | ||
76 | + bool is_write, | ||
77 | + MemTxAttrs attrs) | ||
78 | { | ||
79 | int access_size_min, access_size_max; | ||
80 | int access_size, i; | ||
81 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | ||
82 | { | ||
83 | MemTxResult r; | ||
84 | |||
85 | - if (!memory_region_access_valid(mr, addr, size, false)) { | ||
86 | + if (!memory_region_access_valid(mr, addr, size, false, attrs)) { | ||
87 | *pval = unassigned_mem_read(mr, addr, size); | ||
88 | return MEMTX_DECODE_ERROR; | ||
89 | } | ||
90 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, | ||
91 | unsigned size, | ||
92 | MemTxAttrs attrs) | ||
93 | { | ||
94 | - if (!memory_region_access_valid(mr, addr, size, true)) { | ||
95 | + if (!memory_region_access_valid(mr, addr, size, true, attrs)) { | ||
96 | unassigned_mem_write(mr, addr, data, size); | ||
97 | return MEMTX_DECODE_ERROR; | ||
98 | } | ||
99 | -- | 25 | -- |
100 | 2.17.1 | 26 | 2.25.1 |
101 | |||
102 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | In exynos4210_init_board_irqs(), use the TYPE_SPLIT_IRQ device |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_translate(); all its | 2 | instead of qemu_irq_split(). |
3 | callers now have attrs available. | ||
4 | 3 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | 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> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20180521140402.23318-11-peter.maydell@linaro.org | 6 | Message-id: 20220404154658.565020-13-peter.maydell@linaro.org |
9 | --- | 7 | --- |
10 | include/exec/memory.h | 7 ++++--- | 8 | include/hw/arm/exynos4210.h | 9 ++++++++ |
11 | exec.c | 17 +++++++++-------- | 9 | hw/arm/exynos4210.c | 41 +++++++++++++++++++++++++++++-------- |
12 | 2 files changed, 13 insertions(+), 11 deletions(-) | 10 | 2 files changed, 42 insertions(+), 8 deletions(-) |
13 | 11 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 12 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 14 | --- a/include/hw/arm/exynos4210.h |
17 | +++ b/include/exec/memory.h | 15 | +++ b/include/hw/arm/exynos4210.h |
18 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 16 | @@ -XXX,XX +XXX,XX @@ |
19 | */ | 17 | #include "hw/sysbus.h" |
20 | MemoryRegion *flatview_translate(FlatView *fv, | 18 | #include "hw/cpu/a9mpcore.h" |
21 | hwaddr addr, hwaddr *xlat, | 19 | #include "hw/intc/exynos4210_gic.h" |
22 | - hwaddr *len, bool is_write); | 20 | +#include "hw/core/split-irq.h" |
23 | + hwaddr *len, bool is_write, | 21 | #include "target/arm/cpu-qom.h" |
24 | + MemTxAttrs attrs); | 22 | #include "qom/object.h" |
25 | 23 | ||
26 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | 24 | @@ -XXX,XX +XXX,XX @@ |
27 | hwaddr addr, hwaddr *xlat, | 25 | |
28 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | 26 | #define EXYNOS4210_NUM_DMA 3 |
29 | MemTxAttrs attrs) | 27 | |
30 | { | 28 | +/* |
31 | return flatview_translate(address_space_to_flatview(as), | 29 | + * We need one splitter for every external combiner input, plus |
32 | - addr, xlat, len, is_write); | 30 | + * one for every non-zero entry in combiner_grp_to_gic_id[]. |
33 | + addr, xlat, len, is_write, attrs); | 31 | + * We'll assert in exynos4210_init_board_irqs() if this is wrong. |
32 | + */ | ||
33 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) | ||
34 | + | ||
35 | typedef struct Exynos4210Irq { | ||
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]; | ||
43 | }; | ||
44 | |||
45 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/exynos4210.c | ||
49 | +++ b/hw/arm/exynos4210.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
51 | uint32_t grp, bit, irq_id, n; | ||
52 | Exynos4210Irq *is = &s->irqs; | ||
53 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
54 | + int splitcount = 0; | ||
55 | + DeviceState *splitter; | ||
56 | |||
57 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
58 | irq_id = 0; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
60 | /* MCT_G1 is passed to External and GIC */ | ||
61 | irq_id = EXT_GIC_ID_MCT_G1; | ||
62 | } | ||
63 | + | ||
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); | ||
34 | } | 108 | } |
35 | 109 | ||
36 | /* address_space_access_valid: check for validity of accessing an address | 110 | /* |
37 | @@ -XXX,XX +XXX,XX @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr, | 111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) |
38 | rcu_read_lock(); | 112 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); |
39 | fv = address_space_to_flatview(as); | ||
40 | l = len; | ||
41 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
42 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
43 | if (len == l && memory_access_is_direct(mr, false)) { | ||
44 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | ||
45 | memcpy(buf, ptr, len); | ||
46 | diff --git a/exec.c b/exec.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/exec.c | ||
49 | +++ b/exec.c | ||
50 | @@ -XXX,XX +XXX,XX @@ iotlb_fail: | ||
51 | |||
52 | /* Called from RCU critical section */ | ||
53 | MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | ||
54 | - hwaddr *plen, bool is_write) | ||
55 | + hwaddr *plen, bool is_write, | ||
56 | + MemTxAttrs attrs) | ||
57 | { | ||
58 | MemoryRegion *mr; | ||
59 | MemoryRegionSection section; | ||
60 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, | ||
61 | } | ||
62 | |||
63 | l = len; | ||
64 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | ||
65 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | ||
66 | } | 113 | } |
67 | 114 | ||
68 | return result; | 115 | + for (i = 0; i < ARRAY_SIZE(s->splitter); i++) { |
69 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 116 | + g_autofree char *name = g_strdup_printf("irq-splitter%d", i); |
70 | MemTxResult result = MEMTX_OK; | 117 | + object_initialize_child(obj, name, &s->splitter[i], TYPE_SPLIT_IRQ); |
71 | 118 | + } | |
72 | l = len; | 119 | + |
73 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | 120 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); |
74 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | 121 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); |
75 | result = flatview_write_continue(fv, addr, attrs, buf, len, | ||
76 | addr1, l, mr); | ||
77 | |||
78 | @@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, | ||
79 | } | ||
80 | |||
81 | l = len; | ||
82 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
83 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
84 | } | ||
85 | |||
86 | return result; | ||
87 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | ||
88 | MemoryRegion *mr; | ||
89 | |||
90 | l = len; | ||
91 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | ||
92 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | ||
93 | return flatview_read_continue(fv, addr, attrs, buf, len, | ||
94 | addr1, l, mr); | ||
95 | } | 122 | } |
96 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | ||
97 | |||
98 | while (len > 0) { | ||
99 | l = len; | ||
100 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
101 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | ||
102 | if (!memory_access_is_direct(mr, is_write)) { | ||
103 | l = memory_access_size(mr, l, addr); | ||
104 | if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | ||
105 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | ||
106 | |||
107 | len = target_len; | ||
108 | this_mr = flatview_translate(fv, addr, &xlat, | ||
109 | - &len, is_write); | ||
110 | + &len, is_write, attrs); | ||
111 | if (this_mr != mr || xlat != base + done) { | ||
112 | return done; | ||
113 | } | ||
114 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | ||
115 | l = len; | ||
116 | rcu_read_lock(); | ||
117 | fv = address_space_to_flatview(as); | ||
118 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
119 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | ||
120 | |||
121 | if (!memory_access_is_direct(mr, is_write)) { | ||
122 | if (atomic_xchg(&bounce.in_use, true)) { | ||
123 | -- | 123 | -- |
124 | 2.17.1 | 124 | 2.25.1 |
125 | |||
126 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | In exynos4210_init_board_irqs(), the loop that handles IRQ lines that |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_extend_translation(). | 2 | are in a range that applies to the internal combiner only creates a |
3 | Its callers either have an attrs value to hand, or don't care | 3 | splitter for those interrupts which go to both the internal combiner |
4 | and can use MEMTXATTRS_UNSPECIFIED. | 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 | Message-id: 20180521140402.23318-7-peter.maydell@linaro.org | 23 | Message-id: 20220404154658.565020-14-peter.maydell@linaro.org |
10 | --- | 24 | --- |
11 | exec.c | 15 ++++++++++----- | 25 | hw/arm/exynos4210.c | 2 ++ |
12 | 1 file changed, 10 insertions(+), 5 deletions(-) | 26 | 1 file changed, 2 insertions(+) |
13 | 27 | ||
14 | diff --git a/exec.c b/exec.c | 28 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
15 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 30 | --- a/hw/arm/exynos4210.c |
17 | +++ b/exec.c | 31 | +++ b/hw/arm/exynos4210.c |
18 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 32 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
19 | 33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | |
20 | static hwaddr | 34 | qdev_connect_gpio_out(splitter, 1, |
21 | flatview_extend_translation(FlatView *fv, hwaddr addr, | 35 | qdev_get_gpio_in(extgicdev, irq_id - 32)); |
22 | - hwaddr target_len, | 36 | + } else { |
23 | - MemoryRegion *mr, hwaddr base, hwaddr len, | 37 | + s->irq_table[n] = is->int_combiner_irq[n]; |
24 | - bool is_write) | 38 | } |
25 | + hwaddr target_len, | 39 | } |
26 | + MemoryRegion *mr, hwaddr base, hwaddr len, | 40 | /* |
27 | + bool is_write, MemTxAttrs attrs) | ||
28 | { | ||
29 | hwaddr done = 0; | ||
30 | hwaddr xlat; | ||
31 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | ||
32 | |||
33 | memory_region_ref(mr); | ||
34 | *plen = flatview_extend_translation(fv, addr, len, mr, xlat, | ||
35 | - l, is_write); | ||
36 | + l, is_write, attrs); | ||
37 | ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); | ||
38 | rcu_read_unlock(); | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ int64_t address_space_cache_init(MemoryRegionCache *cache, | ||
41 | mr = cache->mrs.mr; | ||
42 | memory_region_ref(mr); | ||
43 | if (memory_access_is_direct(mr, is_write)) { | ||
44 | + /* We don't care about the memory attributes here as we're only | ||
45 | + * doing this if we found actual RAM, which behaves the same | ||
46 | + * regardless of attributes; so UNSPECIFIED is fine. | ||
47 | + */ | ||
48 | l = flatview_extend_translation(cache->fv, addr, len, mr, | ||
49 | - cache->xlat, l, is_write); | ||
50 | + cache->xlat, l, is_write, | ||
51 | + MEMTXATTRS_UNSPECIFIED); | ||
52 | cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true); | ||
53 | } else { | ||
54 | cache->ptr = NULL; | ||
55 | -- | 41 | -- |
56 | 2.17.1 | 42 | 2.25.1 |
57 | |||
58 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | Currently for the interrupts MCT_G0 and MCT_G1 which are |
---|---|---|---|
2 | add MemTxAttrs as an argument to the MemoryRegion valid.accepts | 2 | the only ones in the input range of the external combiner |
3 | callback. We'll need this for subpage_accepts(). | 3 | and which are also wired to the external GIC, we connect |
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.) | ||
4 | 10 | ||
5 | We could take the approach we used with the read and write | 11 | Wire these interrupts up to both combiners, like the rest. |
6 | callbacks and add new a new _with_attrs version, but since there | ||
7 | are so few implementations of the accepts hook we just change | ||
8 | them all. | ||
9 | 12 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Message-id: 20180521140402.23318-9-peter.maydell@linaro.org | 15 | Message-id: 20220404154658.565020-15-peter.maydell@linaro.org |
14 | --- | 16 | --- |
15 | include/exec/memory.h | 3 ++- | 17 | hw/arm/exynos4210.c | 7 +++---- |
16 | exec.c | 9 ++++++--- | 18 | 1 file changed, 3 insertions(+), 4 deletions(-) |
17 | hw/hppa/dino.c | 3 ++- | ||
18 | hw/nvram/fw_cfg.c | 12 ++++++++---- | ||
19 | hw/scsi/esp.c | 3 ++- | ||
20 | hw/xen/xen_pt_msi.c | 3 ++- | ||
21 | memory.c | 5 +++-- | ||
22 | 7 files changed, 25 insertions(+), 13 deletions(-) | ||
23 | 19 | ||
24 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 20 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
25 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory.h | 22 | --- a/hw/arm/exynos4210.c |
27 | +++ b/include/exec/memory.h | 23 | +++ b/hw/arm/exynos4210.c |
28 | @@ -XXX,XX +XXX,XX @@ struct MemoryRegionOps { | 24 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) |
29 | * as a machine check exception). | 25 | |
30 | */ | 26 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); |
31 | bool (*accepts)(void *opaque, hwaddr addr, | 27 | splitter = DEVICE(&s->splitter[splitcount]); |
32 | - unsigned size, bool is_write); | 28 | - qdev_prop_set_uint16(splitter, "num-lines", 2); |
33 | + unsigned size, bool is_write, | 29 | + qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2); |
34 | + MemTxAttrs attrs); | 30 | qdev_realize(splitter, NULL, &error_abort); |
35 | } valid; | 31 | splitcount++; |
36 | /* Internal implementation constraints: */ | 32 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); |
37 | struct { | 33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); |
38 | diff --git a/exec.c b/exec.c | 34 | + qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); |
39 | index XXXXXXX..XXXXXXX 100644 | 35 | if (irq_id) { |
40 | --- a/exec.c | 36 | - qdev_connect_gpio_out(splitter, 1, |
41 | +++ b/exec.c | 37 | + qdev_connect_gpio_out(splitter, 2, |
42 | @@ -XXX,XX +XXX,XX @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr, | 38 | qdev_get_gpio_in(extgicdev, irq_id - 32)); |
43 | } | 39 | - } else { |
44 | 40 | - qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | |
45 | static bool notdirty_mem_accepts(void *opaque, hwaddr addr, | ||
46 | - unsigned size, bool is_write) | ||
47 | + unsigned size, bool is_write, | ||
48 | + MemTxAttrs attrs) | ||
49 | { | ||
50 | return is_write; | ||
51 | } | ||
52 | @@ -XXX,XX +XXX,XX @@ static MemTxResult subpage_write(void *opaque, hwaddr addr, | ||
53 | } | ||
54 | |||
55 | static bool subpage_accepts(void *opaque, hwaddr addr, | ||
56 | - unsigned len, bool is_write) | ||
57 | + unsigned len, bool is_write, | ||
58 | + MemTxAttrs attrs) | ||
59 | { | ||
60 | subpage_t *subpage = opaque; | ||
61 | #if defined(DEBUG_SUBPAGE) | ||
62 | @@ -XXX,XX +XXX,XX @@ static void readonly_mem_write(void *opaque, hwaddr addr, | ||
63 | } | ||
64 | |||
65 | static bool readonly_mem_accepts(void *opaque, hwaddr addr, | ||
66 | - unsigned size, bool is_write) | ||
67 | + unsigned size, bool is_write, | ||
68 | + MemTxAttrs attrs) | ||
69 | { | ||
70 | return is_write; | ||
71 | } | ||
72 | diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/hw/hppa/dino.c | ||
75 | +++ b/hw/hppa/dino.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static void gsc_to_pci_forwarding(DinoState *s) | ||
77 | } | ||
78 | |||
79 | static bool dino_chip_mem_valid(void *opaque, hwaddr addr, | ||
80 | - unsigned size, bool is_write) | ||
81 | + unsigned size, bool is_write, | ||
82 | + MemTxAttrs attrs) | ||
83 | { | ||
84 | switch (addr) { | ||
85 | case DINO_IAR0: | ||
86 | diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/nvram/fw_cfg.c | ||
89 | +++ b/hw/nvram/fw_cfg.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_dma_mem_write(void *opaque, hwaddr addr, | ||
91 | } | ||
92 | |||
93 | static bool fw_cfg_dma_mem_valid(void *opaque, hwaddr addr, | ||
94 | - unsigned size, bool is_write) | ||
95 | + unsigned size, bool is_write, | ||
96 | + MemTxAttrs attrs) | ||
97 | { | ||
98 | return !is_write || ((size == 4 && (addr == 0 || addr == 4)) || | ||
99 | (size == 8 && addr == 0)); | ||
100 | } | ||
101 | |||
102 | static bool fw_cfg_data_mem_valid(void *opaque, hwaddr addr, | ||
103 | - unsigned size, bool is_write) | ||
104 | + unsigned size, bool is_write, | ||
105 | + MemTxAttrs attrs) | ||
106 | { | ||
107 | return addr == 0; | ||
108 | } | ||
109 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr, | ||
110 | } | ||
111 | |||
112 | static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr, | ||
113 | - unsigned size, bool is_write) | ||
114 | + unsigned size, bool is_write, | ||
115 | + MemTxAttrs attrs) | ||
116 | { | ||
117 | return is_write && size == 2; | ||
118 | } | ||
119 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_comb_write(void *opaque, hwaddr addr, | ||
120 | } | ||
121 | |||
122 | static bool fw_cfg_comb_valid(void *opaque, hwaddr addr, | ||
123 | - unsigned size, bool is_write) | ||
124 | + unsigned size, bool is_write, | ||
125 | + MemTxAttrs attrs) | ||
126 | { | ||
127 | return (size == 1) || (is_write && size == 2); | ||
128 | } | ||
129 | diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/hw/scsi/esp.c | ||
132 | +++ b/hw/scsi/esp.c | ||
133 | @@ -XXX,XX +XXX,XX @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) | ||
134 | } | ||
135 | |||
136 | static bool esp_mem_accepts(void *opaque, hwaddr addr, | ||
137 | - unsigned size, bool is_write) | ||
138 | + unsigned size, bool is_write, | ||
139 | + MemTxAttrs attrs) | ||
140 | { | ||
141 | return (size == 1) || (is_write && size == 4); | ||
142 | } | ||
143 | diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c | ||
144 | index XXXXXXX..XXXXXXX 100644 | ||
145 | --- a/hw/xen/xen_pt_msi.c | ||
146 | +++ b/hw/xen/xen_pt_msi.c | ||
147 | @@ -XXX,XX +XXX,XX @@ static uint64_t pci_msix_read(void *opaque, hwaddr addr, | ||
148 | } | ||
149 | |||
150 | static bool pci_msix_accepts(void *opaque, hwaddr addr, | ||
151 | - unsigned size, bool is_write) | ||
152 | + unsigned size, bool is_write, | ||
153 | + MemTxAttrs attrs) | ||
154 | { | ||
155 | return !(addr & (size - 1)); | ||
156 | } | ||
157 | diff --git a/memory.c b/memory.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/memory.c | ||
160 | +++ b/memory.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static void unassigned_mem_write(void *opaque, hwaddr addr, | ||
162 | } | ||
163 | |||
164 | static bool unassigned_mem_accepts(void *opaque, hwaddr addr, | ||
165 | - unsigned size, bool is_write) | ||
166 | + unsigned size, bool is_write, | ||
167 | + MemTxAttrs attrs) | ||
168 | { | ||
169 | return false; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ bool memory_region_access_valid(MemoryRegion *mr, | ||
172 | access_size = MAX(MIN(size, access_size_max), access_size_min); | ||
173 | for (i = 0; i < size; i += access_size) { | ||
174 | if (!mr->ops->valid.accepts(mr->opaque, addr + i, access_size, | ||
175 | - is_write)) { | ||
176 | + is_write, attrs)) { | ||
177 | return false; | ||
178 | } | 41 | } |
179 | } | 42 | } |
43 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
180 | -- | 44 | -- |
181 | 2.17.1 | 45 | 2.25.1 |
182 | |||
183 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | The combiner_grp_to_gic_id[] array includes the EXT_GIC_ID_MCT_G0 |
---|---|---|---|
2 | and EXT_GIC_ID_MCT_G1 multiple times. This means that we will | ||
3 | connect multiple IRQs up to the same external GIC input, which | ||
4 | is not permitted. We do the same thing in the code in | ||
5 | exynos4210_init_board_irqs() because the conditionals selecting | ||
6 | an irq_id in the first loop match multiple interrupt IDs. | ||
2 | 7 | ||
3 | kvm_irqchip_create called by kvm_init will call kvm_init_irq_routing to | 8 | Overall we do this for interrupt IDs |
4 | initialize global capability variables. If we call kvm_init_irq_routing in | 9 | (1, 4), (12, 4), (35, 4), (51, 4), (53, 4) for EXT_GIC_ID_MCT_G0 |
5 | GIC realize function, previous allocated memory will leak. | 10 | and |
11 | (1, 5), (12, 5), (35, 5), (51, 5), (53, 5) for EXT_GIC_ID_MCT_G1 | ||
6 | 12 | ||
7 | Fix this by deleting the unnecessary call. | 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. | ||
8 | 20 | ||
9 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 21 | This bug didn't cause any visible effects, because we only connect |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 22 | up a device to the "primary" ID values (1, 4) and (1, 5), so the |
11 | Message-id: 1527750994-14360-1-git-send-email-zhaoshenglong@huawei.com | 23 | extra lines would never be set to a level. |
24 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
27 | Message-id: 20220404154658.565020-16-peter.maydell@linaro.org | ||
13 | --- | 28 | --- |
14 | hw/intc/arm_gic_kvm.c | 1 - | 29 | include/hw/arm/exynos4210.h | 2 +- |
15 | hw/intc/arm_gicv3_kvm.c | 1 - | 30 | hw/arm/exynos4210.c | 12 +++++------- |
16 | 2 files changed, 2 deletions(-) | 31 | 2 files changed, 6 insertions(+), 8 deletions(-) |
17 | 32 | ||
18 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.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_gic_kvm.c | 35 | --- a/include/hw/arm/exynos4210.h |
21 | +++ b/hw/intc/arm_gic_kvm.c | 36 | +++ b/include/hw/arm/exynos4210.h |
22 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | 37 | @@ -XXX,XX +XXX,XX @@ |
23 | 38 | * one for every non-zero entry in combiner_grp_to_gic_id[]. | |
24 | if (kvm_has_gsi_routing()) { | 39 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. |
25 | /* set up irq routing */ | 40 | */ |
26 | - kvm_init_irq_routing(kvm_state); | 41 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) |
27 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | 42 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) |
28 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | 43 | |
44 | typedef struct Exynos4210Irq { | ||
45 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/exynos4210.c | ||
49 | +++ b/hw/arm/exynos4210.c | ||
50 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
51 | /* int combiner group 34 */ | ||
52 | { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
53 | /* int combiner group 35 */ | ||
54 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
55 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1 }, | ||
56 | /* int combiner group 36 */ | ||
57 | { EXT_GIC_ID_MIXER }, | ||
58 | /* int combiner group 37 */ | ||
59 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
60 | /* groups 38-50 */ | ||
61 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
62 | /* int combiner group 51 */ | ||
63 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
64 | + { EXT_GIC_ID_MCT_L0 }, | ||
65 | /* group 52 */ | ||
66 | { }, | ||
67 | /* int combiner group 53 */ | ||
68 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
69 | + { EXT_GIC_ID_WDT }, | ||
70 | /* groups 54-63 */ | ||
71 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
72 | }; | ||
73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
74 | |||
75 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
76 | irq_id = 0; | ||
77 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
78 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
79 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4)) { | ||
80 | /* MCT_G0 is passed to External GIC */ | ||
81 | irq_id = EXT_GIC_ID_MCT_G0; | ||
29 | } | 82 | } |
30 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 83 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || |
31 | index XXXXXXX..XXXXXXX 100644 | 84 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { |
32 | --- a/hw/intc/arm_gicv3_kvm.c | 85 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5)) { |
33 | +++ b/hw/intc/arm_gicv3_kvm.c | 86 | /* MCT_G1 is passed to External and GIC */ |
34 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | 87 | irq_id = EXT_GIC_ID_MCT_G1; |
35 | |||
36 | if (kvm_has_gsi_routing()) { | ||
37 | /* set up irq routing */ | ||
38 | - kvm_init_irq_routing(kvm_state); | ||
39 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | ||
40 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | ||
41 | } | 88 | } |
42 | -- | 89 | -- |
43 | 2.17.1 | 90 | 2.25.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | At this point, the function exynos4210_init_board_irqs() splits input |
---|---|---|---|
2 | add MemTxAttrs as an argument to tb_invalidate_phys_addr(). | 2 | IRQ lines to connect them to the input combiner, output combiner and |
3 | Its callers either have an attrs value to hand, or don't care | 3 | external GIC. The function exynos4210_combiner_get_gpioin() splits |
4 | and can use MEMTXATTRS_UNSPECIFIED. | 4 | some of the combiner input lines further to connect them to multiple |
5 | different inputs on the combiner. | ||
6 | |||
7 | Because (unlike qemu_irq_split()) the TYPE_SPLIT_IRQ device has a | ||
8 | configurable number of outputs, we can do all this in one place, by | ||
9 | making exynos4210_init_board_irqs() add extra outputs to the splitter | ||
10 | device when it must be connected to more than one input on each | ||
11 | combiner. | ||
12 | |||
13 | We do this with a new data structure, the combinermap, which is an | ||
14 | array each of whose elements is a list of the interrupt IDs on the | ||
15 | combiner which must be tied together. As we loop through each | ||
16 | interrupt ID, if we find that it is the first one in one of these | ||
17 | lists, we configure the splitter device with eonugh extra outputs and | ||
18 | wire them up to the other interrupt IDs in the list. | ||
19 | |||
20 | Conveniently, for all the cases where this is necessary, the | ||
21 | lowest-numbered interrupt ID in each group is in the range of the | ||
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. | ||
5 | 38 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 39 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 40 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 41 | Message-id: 20220404154658.565020-17-peter.maydell@linaro.org |
9 | Message-id: 20180521140402.23318-3-peter.maydell@linaro.org | ||
10 | --- | 42 | --- |
11 | include/exec/exec-all.h | 5 +++-- | 43 | include/hw/arm/exynos4210.h | 6 +- |
12 | accel/tcg/translate-all.c | 2 +- | 44 | hw/arm/exynos4210.c | 178 +++++++++++++++++++++++------------- |
13 | exec.c | 2 +- | 45 | 2 files changed, 119 insertions(+), 65 deletions(-) |
14 | target/xtensa/op_helper.c | 3 ++- | 46 | |
15 | 4 files changed, 7 insertions(+), 5 deletions(-) | 47 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
16 | |||
17 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/exec-all.h | 49 | --- a/include/hw/arm/exynos4210.h |
20 | +++ b/include/exec/exec-all.h | 50 | +++ b/include/hw/arm/exynos4210.h |
21 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 51 | @@ -XXX,XX +XXX,XX @@ |
22 | void tlb_set_page(CPUState *cpu, target_ulong vaddr, | 52 | |
23 | hwaddr paddr, int prot, | 53 | /* |
24 | int mmu_idx, target_ulong size); | 54 | * We need one splitter for every external combiner input, plus |
25 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr); | 55 | - * one for every non-zero entry in combiner_grp_to_gic_id[]. |
26 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs); | 56 | + * one for every non-zero entry in combiner_grp_to_gic_id[], |
27 | void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 57 | + * minus one for every external combiner ID in second or later |
28 | uintptr_t retaddr); | 58 | + * places in a combinermap[] line. |
29 | #else | 59 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. |
30 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | 60 | */ |
31 | uint16_t idxmap) | 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)) | ||
73 | |||
74 | +/* | ||
75 | + * Some interrupt lines go to multiple combiner inputs. | ||
76 | + * This data structure defines those: each array element is | ||
77 | + * a list of combiner inputs which are connected together; | ||
78 | + * the one with the smallest interrupt ID value must be first. | ||
79 | + * As with combiner_grp_to_gic_id[], we rely on (0, 0) not being | ||
80 | + * wired to anything so we can use 0 as a terminator. | ||
81 | + */ | ||
82 | +#define IRQNO(G, B) EXYNOS4210_COMBINER_GET_IRQ_NUM(G, B) | ||
83 | +#define IRQNONE 0 | ||
84 | + | ||
85 | +#define COMBINERMAP_SIZE 16 | ||
86 | + | ||
87 | +static const int combinermap[COMBINERMAP_SIZE][6] = { | ||
88 | + /* MDNIE_LCD1 */ | ||
89 | + { IRQNO(0, 4), IRQNO(1, 0), IRQNONE }, | ||
90 | + { IRQNO(0, 5), IRQNO(1, 1), IRQNONE }, | ||
91 | + { IRQNO(0, 6), IRQNO(1, 2), IRQNONE }, | ||
92 | + { IRQNO(0, 7), IRQNO(1, 3), IRQNONE }, | ||
93 | + /* TMU */ | ||
94 | + { IRQNO(2, 4), IRQNO(3, 4), IRQNONE }, | ||
95 | + { IRQNO(2, 5), IRQNO(3, 5), IRQNONE }, | ||
96 | + { IRQNO(2, 6), IRQNO(3, 6), IRQNONE }, | ||
97 | + { IRQNO(2, 7), IRQNO(3, 7), IRQNONE }, | ||
98 | + /* LCD1 */ | ||
99 | + { IRQNO(11, 4), IRQNO(12, 0), IRQNONE }, | ||
100 | + { IRQNO(11, 5), IRQNO(12, 1), IRQNONE }, | ||
101 | + { IRQNO(11, 6), IRQNO(12, 2), IRQNONE }, | ||
102 | + { IRQNO(11, 7), IRQNO(12, 3), IRQNONE }, | ||
103 | + /* Multi-core timer */ | ||
104 | + { IRQNO(1, 4), IRQNO(12, 4), IRQNO(35, 4), IRQNO(51, 4), IRQNO(53, 4), IRQNONE }, | ||
105 | + { IRQNO(1, 5), IRQNO(12, 5), IRQNO(35, 5), IRQNO(51, 5), IRQNO(53, 5), IRQNONE }, | ||
106 | + { IRQNO(1, 6), IRQNO(12, 6), IRQNO(35, 6), IRQNO(51, 6), IRQNO(53, 6), IRQNONE }, | ||
107 | + { IRQNO(1, 7), IRQNO(12, 7), IRQNO(35, 7), IRQNO(51, 7), IRQNO(53, 7), IRQNONE }, | ||
108 | +}; | ||
109 | + | ||
110 | +#undef IRQNO | ||
111 | + | ||
112 | +static const int *combinermap_entry(int irq) | ||
113 | +{ | ||
114 | + /* | ||
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)); | ||
206 | } | ||
207 | } | ||
208 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
209 | irq_id = combiner_grp_to_gic_id[grp - | ||
210 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
211 | |||
212 | + if (s->irq_table[n]) { | ||
213 | + /* | ||
214 | + * This must be some non-first entry in a combinermap line, | ||
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) | ||
32 | { | 225 | { |
33 | } | 226 | int n; |
34 | -static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | 227 | - int bit; |
35 | +static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, | 228 | int max; |
36 | + MemTxAttrs attrs) | 229 | qemu_irq *irq; |
37 | { | 230 | |
38 | } | 231 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, |
39 | #endif | 232 | EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; |
40 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 233 | irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; |
41 | index XXXXXXX..XXXXXXX 100644 | 234 | |
42 | --- a/accel/tcg/translate-all.c | 235 | - /* |
43 | +++ b/accel/tcg/translate-all.c | 236 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, |
44 | @@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr) | 237 | - * so let split them. |
45 | } | 238 | - */ |
46 | 239 | for (n = 0; n < max; n++) { | |
47 | #if !defined(CONFIG_USER_ONLY) | 240 | - |
48 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | 241 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); |
49 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | 242 | - |
50 | { | 243 | - switch (n) { |
51 | ram_addr_t ram_addr; | 244 | - /* MDNIE_LCD1 INTG1 */ |
52 | MemoryRegion *mr; | 245 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... |
53 | diff --git a/exec.c b/exec.c | 246 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): |
54 | index XXXXXXX..XXXXXXX 100644 | 247 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
55 | --- a/exec.c | 248 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); |
56 | +++ b/exec.c | 249 | - continue; |
57 | @@ -XXX,XX +XXX,XX @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) | 250 | - |
58 | if (phys != -1) { | 251 | - /* TMU INTG3 */ |
59 | /* Locks grabbed by tb_invalidate_phys_addr */ | 252 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): |
60 | tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as, | 253 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), |
61 | - phys | (pc & ~TARGET_PAGE_MASK)); | 254 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); |
62 | + phys | (pc & ~TARGET_PAGE_MASK), attrs); | 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); | ||
63 | } | 294 | } |
64 | } | 295 | } |
65 | #endif | ||
66 | diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/xtensa/op_helper.c | ||
69 | +++ b/target/xtensa/op_helper.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr) | ||
71 | int ret = xtensa_get_physical_addr(env, false, vaddr, 2, 0, | ||
72 | &paddr, &page_size, &access); | ||
73 | if (ret == 0) { | ||
74 | - tb_invalidate_phys_addr(&address_space_memory, paddr); | ||
75 | + tb_invalidate_phys_addr(&address_space_memory, paddr, | ||
76 | + MEMTXATTRS_UNSPECIFIED); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | -- | 296 | -- |
81 | 2.17.1 | 297 | 2.25.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | The FRECPX instructions should (like most other floating point operations) | 1 | Switch the creation of the combiner devices to the new-style |
---|---|---|---|
2 | honour the FPCR.FZ bit which specifies whether input denormals should | 2 | "embedded in state struct" approach, so we can easily refer |
3 | be flushed to zero (or FZ16 for the half-precision version). | 3 | to the object elsewhere during realize. |
4 | We forgot to implement this, which doesn't affect the results (since | ||
5 | the calculation doesn't actually care about the mantissa bits) but did | ||
6 | mean we were failing to set the FPSR.IDC bit. | ||
7 | 4 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20180521172712.19930-1-peter.maydell@linaro.org | 7 | Message-id: 20220404154658.565020-18-peter.maydell@linaro.org |
11 | --- | 8 | --- |
12 | target/arm/helper-a64.c | 6 ++++++ | 9 | include/hw/arm/exynos4210.h | 3 ++ |
13 | 1 file changed, 6 insertions(+) | 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 | ||
14 | 15 | ||
15 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-a64.c | 18 | --- a/include/hw/arm/exynos4210.h |
18 | +++ b/target/arm/helper-a64.c | 19 | +++ b/include/hw/arm/exynos4210.h |
19 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | 20 | @@ -XXX,XX +XXX,XX @@ |
20 | return nan; | 21 | #include "hw/sysbus.h" |
22 | #include "hw/cpu/a9mpcore.h" | ||
23 | #include "hw/intc/exynos4210_gic.h" | ||
24 | +#include "hw/intc/exynos4210_combiner.h" | ||
25 | #include "hw/core/split-irq.h" | ||
26 | #include "target/arm/cpu-qom.h" | ||
27 | #include "qom/object.h" | ||
28 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
29 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
30 | A9MPPrivState a9mpcore; | ||
31 | Exynos4210GicState ext_gic; | ||
32 | + Exynos4210CombinerState int_combiner; | ||
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) | ||
21 | } | 105 | } |
22 | 106 | ||
23 | + a = float16_squash_input_denormal(a, fpst); | 107 | /* Internal Interrupt Combiner */ |
24 | + | 108 | - dev = qdev_new("exynos4210.combiner"); |
25 | val16 = float16_val(a); | 109 | - busdev = SYS_BUS_DEVICE(dev); |
26 | sbit = 0x8000 & val16; | 110 | - sysbus_realize_and_unref(busdev, &error_fatal); |
27 | exp = extract32(val16, 10, 5); | 111 | + busdev = SYS_BUS_DEVICE(&s->int_combiner); |
28 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) | 112 | + sysbus_realize(busdev, &error_fatal); |
29 | return nan; | 113 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { |
114 | sysbus_connect_irq(busdev, n, | ||
115 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
30 | } | 116 | } |
31 | 117 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); | |
32 | + a = float32_squash_input_denormal(a, fpst); | 118 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); |
33 | + | 119 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); |
34 | val32 = float32_val(a); | 120 | |
35 | sbit = 0x80000000ULL & val32; | 121 | /* External Interrupt Combiner */ |
36 | exp = extract32(val32, 23, 8); | 122 | - dev = qdev_new("exynos4210.combiner"); |
37 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) | 123 | - qdev_prop_set_uint32(dev, "external", 1); |
38 | return nan; | 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)); | ||
39 | } | 131 | } |
40 | 132 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); | |
41 | + a = float64_squash_input_denormal(a, fpst); | 133 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); |
42 | + | 134 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); |
43 | val64 = float64_val(a); | 135 | |
44 | sbit = 0x8000000000000000ULL & val64; | 136 | /* Initialize board IRQs. */ |
45 | exp = extract64(float64_val(a), 52, 11); | 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); | ||
145 | } | ||
146 | |||
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", | ||
46 | -- | 198 | -- |
47 | 2.17.1 | 199 | 2.25.1 |
48 | |||
49 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | The only time we use the int_combiner_irq[] and ext_combiner_irq[] |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_access_valid(). | 2 | arrays in the Exynos4210Irq struct is during realize of the SoC -- we |
3 | Its callers either have an attrs value to hand, or don't care | 3 | initialize them with the input IRQs of the combiner devices, and then |
4 | and can use MEMTXATTRS_UNSPECIFIED. | 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. | ||
9 | |||
10 | Since these are the only two remaining elements of Exynos4210Irq, | ||
11 | we can remove that struct entirely. | ||
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> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20180521140402.23318-6-peter.maydell@linaro.org | 15 | Message-id: 20220404154658.565020-19-peter.maydell@linaro.org |
10 | --- | 16 | --- |
11 | include/exec/memory.h | 4 +++- | 17 | include/hw/arm/exynos4210.h | 6 ------ |
12 | include/sysemu/dma.h | 3 ++- | 18 | hw/arm/exynos4210.c | 34 ++++++++-------------------------- |
13 | exec.c | 3 ++- | 19 | 2 files changed, 8 insertions(+), 32 deletions(-) |
14 | target/s390x/diag.c | 6 ++++-- | ||
15 | target/s390x/excp_helper.c | 3 ++- | ||
16 | target/s390x/mmu_helper.c | 3 ++- | ||
17 | target/s390x/sigp.c | 3 ++- | ||
18 | 7 files changed, 17 insertions(+), 8 deletions(-) | ||
19 | 20 | ||
20 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 21 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/memory.h | 23 | --- a/include/hw/arm/exynos4210.h |
23 | +++ b/include/exec/memory.h | 24 | +++ b/include/hw/arm/exynos4210.h |
24 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | 25 | @@ -XXX,XX +XXX,XX @@ |
25 | * @addr: address within that address space | ||
26 | * @len: length of the area to be checked | ||
27 | * @is_write: indicates the transfer direction | ||
28 | + * @attrs: memory attributes | ||
29 | */ | 26 | */ |
30 | -bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write); | 27 | #define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) |
31 | +bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, | 28 | |
32 | + bool is_write, MemTxAttrs attrs); | 29 | -typedef struct Exynos4210Irq { |
33 | 30 | - qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | |
34 | /* address_space_map: map a physical memory region into a host virtual address | 31 | - qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; |
35 | * | 32 | -} Exynos4210Irq; |
36 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | 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 | ||
37 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/include/sysemu/dma.h | 45 | --- a/hw/arm/exynos4210.c |
39 | +++ b/include/sysemu/dma.h | 46 | +++ b/hw/arm/exynos4210.c |
40 | @@ -XXX,XX +XXX,XX @@ static inline bool dma_memory_valid(AddressSpace *as, | 47 | @@ -XXX,XX +XXX,XX @@ static int mapline_size(const int *mapline) |
41 | DMADirection dir) | 48 | static void exynos4210_init_board_irqs(Exynos4210State *s) |
42 | { | 49 | { |
43 | return address_space_access_valid(as, addr, len, | 50 | uint32_t grp, bit, irq_id, n; |
44 | - dir == DMA_DIRECTION_FROM_DEVICE); | 51 | - Exynos4210Irq *is = &s->irqs; |
45 | + dir == DMA_DIRECTION_FROM_DEVICE, | 52 | DeviceState *extgicdev = DEVICE(&s->ext_gic); |
46 | + MEMTXATTRS_UNSPECIFIED); | 53 | + DeviceState *intcdev = DEVICE(&s->int_combiner); |
54 | + DeviceState *extcdev = DEVICE(&s->ext_combiner); | ||
55 | int splitcount = 0; | ||
56 | DeviceState *splitter; | ||
57 | const int *mapline; | ||
58 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
59 | splitin = 0; | ||
60 | for (;;) { | ||
61 | s->irq_table[in] = qdev_get_gpio_in(splitter, 0); | ||
62 | - qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]); | ||
63 | - qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]); | ||
64 | + qdev_connect_gpio_out(splitter, splitin, | ||
65 | + qdev_get_gpio_in(intcdev, in)); | ||
66 | + qdev_connect_gpio_out(splitter, splitin + 1, | ||
67 | + qdev_get_gpio_in(extcdev, in)); | ||
68 | splitin += 2; | ||
69 | if (!mapline) { | ||
70 | break; | ||
71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
72 | qdev_realize(splitter, NULL, &error_abort); | ||
73 | splitcount++; | ||
74 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
75 | - qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
76 | + qdev_connect_gpio_out(splitter, 0, qdev_get_gpio_in(intcdev, n)); | ||
77 | qdev_connect_gpio_out(splitter, 1, | ||
78 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
79 | } else { | ||
80 | - s->irq_table[n] = is->int_combiner_irq[n]; | ||
81 | + s->irq_table[n] = qdev_get_gpio_in(intcdev, n); | ||
82 | } | ||
83 | } | ||
84 | /* | ||
85 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
86 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
47 | } | 87 | } |
48 | 88 | ||
49 | static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, | 89 | -/* |
50 | diff --git a/exec.c b/exec.c | 90 | - * Get Combiner input GPIO into irqs structure |
51 | index XXXXXXX..XXXXXXX 100644 | 91 | - */ |
52 | --- a/exec.c | 92 | -static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, |
53 | +++ b/exec.c | 93 | - DeviceState *dev, int ext) |
54 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 94 | -{ |
55 | } | 95 | - int n; |
56 | 96 | - int max; | |
57 | bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 97 | - qemu_irq *irq; |
58 | - int len, bool is_write) | 98 | - |
59 | + int len, bool is_write, | 99 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : |
60 | + MemTxAttrs attrs) | 100 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; |
61 | { | 101 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; |
62 | FlatView *fv; | 102 | - |
63 | bool result; | 103 | - for (n = 0; n < max; n++) { |
64 | diff --git a/target/s390x/diag.c b/target/s390x/diag.c | 104 | - irq[n] = qdev_get_gpio_in(dev, n); |
65 | index XXXXXXX..XXXXXXX 100644 | 105 | - } |
66 | --- a/target/s390x/diag.c | 106 | -} |
67 | +++ b/target/s390x/diag.c | 107 | - |
68 | @@ -XXX,XX +XXX,XX @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) | 108 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, |
69 | return; | 109 | 0x09, 0x00, 0x00, 0x00 }; |
70 | } | 110 | |
71 | if (!address_space_access_valid(&address_space_memory, addr, | 111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
72 | - sizeof(IplParameterBlock), false)) { | 112 | sysbus_connect_irq(busdev, n, |
73 | + sizeof(IplParameterBlock), false, | 113 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); |
74 | + MEMTXATTRS_UNSPECIFIED)) { | ||
75 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
76 | return; | ||
77 | } | ||
78 | @@ -XXX,XX +XXX,XX @@ out: | ||
79 | return; | ||
80 | } | ||
81 | if (!address_space_access_valid(&address_space_memory, addr, | ||
82 | - sizeof(IplParameterBlock), true)) { | ||
83 | + sizeof(IplParameterBlock), true, | ||
84 | + MEMTXATTRS_UNSPECIFIED)) { | ||
85 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
86 | return; | ||
87 | } | ||
88 | diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/s390x/excp_helper.c | ||
91 | +++ b/target/s390x/excp_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size, | ||
93 | |||
94 | /* check out of RAM access */ | ||
95 | if (!address_space_access_valid(&address_space_memory, raddr, | ||
96 | - TARGET_PAGE_SIZE, rw)) { | ||
97 | + TARGET_PAGE_SIZE, rw, | ||
98 | + MEMTXATTRS_UNSPECIFIED)) { | ||
99 | DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__, | ||
100 | (uint64_t)raddr, (uint64_t)ram_size); | ||
101 | trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO); | ||
102 | diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/s390x/mmu_helper.c | ||
105 | +++ b/target/s390x/mmu_helper.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, | ||
107 | return ret; | ||
108 | } | ||
109 | if (!address_space_access_valid(&address_space_memory, pages[i], | ||
110 | - TARGET_PAGE_SIZE, is_write)) { | ||
111 | + TARGET_PAGE_SIZE, is_write, | ||
112 | + MEMTXATTRS_UNSPECIFIED)) { | ||
113 | trigger_access_exception(env, PGM_ADDRESSING, ILEN_AUTO, 0); | ||
114 | return -EFAULT; | ||
115 | } | ||
116 | diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/s390x/sigp.c | ||
119 | +++ b/target/s390x/sigp.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) | ||
121 | cpu_synchronize_state(cs); | ||
122 | |||
123 | if (!address_space_access_valid(&address_space_memory, addr, | ||
124 | - sizeof(struct LowCore), false)) { | ||
125 | + sizeof(struct LowCore), false, | ||
126 | + MEMTXATTRS_UNSPECIFIED)) { | ||
127 | set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); | ||
128 | return; | ||
129 | } | 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. */ | ||
130 | -- | 127 | -- |
131 | 2.17.1 | 128 | 2.25.1 |
132 | |||
133 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | acpi_data_push uses g_array_set_size to resize the memory size. If there | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | is no enough contiguous memory, the address will be changed. So previous | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | pointer could not be used any more. It must update the pointer and use | 5 | Message-id: 20220324181557.203805-2-zongyuan.li@smartx.com |
6 | the new one. | ||
7 | |||
8 | Also, previous codes wrongly use le32 conversion of iort->node_offset | ||
9 | for subsequent computations that will result incorrect value if host is | ||
10 | not litlle endian. So use the non-converted one instead. | ||
11 | |||
12 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | ||
13 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
14 | Message-id: 1527663951-14552-1-git-send-email-zhaoshenglong@huawei.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 7 | --- |
17 | hw/arm/virt-acpi-build.c | 20 +++++++++++++++----- | 8 | hw/arm/realview.c | 33 ++++++++++++++++++++++++--------- |
18 | 1 file changed, 15 insertions(+), 5 deletions(-) | 9 | 1 file changed, 24 insertions(+), 9 deletions(-) |
19 | 10 | ||
20 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 11 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c |
21 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/virt-acpi-build.c | 13 | --- a/hw/arm/realview.c |
23 | +++ b/hw/arm/virt-acpi-build.c | 14 | +++ b/hw/arm/realview.c |
24 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 15 | @@ -XXX,XX +XXX,XX @@ |
25 | AcpiIortItsGroup *its; | 16 | #include "hw/sysbus.h" |
26 | AcpiIortTable *iort; | 17 | #include "hw/arm/boot.h" |
27 | AcpiIortSmmu3 *smmu; | 18 | #include "hw/arm/primecell.h" |
28 | - size_t node_size, iort_length, smmu_offset = 0; | 19 | +#include "hw/core/split-irq.h" |
29 | + size_t node_size, iort_node_offset, iort_length, smmu_offset = 0; | 20 | #include "hw/net/lan9118.h" |
30 | AcpiIortRC *rc; | 21 | #include "hw/net/smc91c111.h" |
31 | 22 | #include "hw/pci/pci.h" | |
32 | iort = acpi_data_push(table_data, sizeof(*iort)); | 23 | +#include "hw/qdev-core.h" |
33 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 24 | #include "net/net.h" |
34 | 25 | #include "sysemu/sysemu.h" | |
35 | iort_length = sizeof(*iort); | 26 | #include "hw/boards.h" |
36 | iort->node_count = cpu_to_le32(nb_nodes); | 27 | @@ -XXX,XX +XXX,XX @@ static const int realview_board_id[] = { |
37 | - iort->node_offset = cpu_to_le32(sizeof(*iort)); | 28 | 0x76d |
38 | + /* | 29 | }; |
39 | + * Use a copy in case table_data->data moves during acpi_data_push | 30 | |
40 | + * operations. | 31 | +static void split_irq_from_named(DeviceState *src, const char* outname, |
41 | + */ | 32 | + qemu_irq out1, qemu_irq out2) { |
42 | + iort_node_offset = sizeof(*iort); | 33 | + DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ); |
43 | + iort->node_offset = cpu_to_le32(iort_node_offset); | 34 | + |
44 | 35 | + qdev_prop_set_uint32(splitter, "num-lines", 2); | |
45 | /* ITS group node */ | 36 | + |
46 | node_size = sizeof(*its) + sizeof(uint32_t); | 37 | + qdev_realize_and_unref(splitter, NULL, &error_fatal); |
47 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 38 | + |
48 | int irq = vms->irqmap[VIRT_SMMU]; | 39 | + qdev_connect_gpio_out(splitter, 0, out1); |
49 | 40 | + qdev_connect_gpio_out(splitter, 1, out2); | |
50 | /* SMMUv3 node */ | 41 | + qdev_connect_gpio_out_named(src, outname, 0, |
51 | - smmu_offset = iort->node_offset + node_size; | 42 | + qdev_get_gpio_in(splitter, 0)); |
52 | + smmu_offset = iort_node_offset + node_size; | 43 | +} |
53 | node_size = sizeof(*smmu) + sizeof(*idmap); | 44 | + |
54 | iort_length += node_size; | 45 | static void realview_init(MachineState *machine, |
55 | smmu = acpi_data_push(table_data, node_size); | 46 | enum realview_board_type board_type) |
56 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 47 | { |
57 | idmap->id_count = cpu_to_le32(0xFFFF); | 48 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, |
58 | idmap->output_base = 0; | 49 | DeviceState *dev, *sysctl, *gpio2, *pl041; |
59 | /* output IORT node is the ITS group node (the first node) */ | 50 | SysBusDevice *busdev; |
60 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | 51 | qemu_irq pic[64]; |
61 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | 52 | - qemu_irq mmc_irq[2]; |
62 | } | 53 | PCIBus *pci_bus = NULL; |
63 | 54 | NICInfo *nd; | |
64 | /* Root Complex Node */ | 55 | DriveInfo *dinfo; |
65 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 56 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, |
66 | idmap->output_reference = cpu_to_le32(smmu_offset); | 57 | * and the PL061 has them the other way about. Also the card |
67 | } else { | 58 | * detect line is inverted. |
68 | /* output IORT node is the ITS group node (the first node) */ | 59 | */ |
69 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | 60 | - mmc_irq[0] = qemu_irq_split( |
70 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | 61 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), |
71 | } | 62 | - qdev_get_gpio_in(gpio2, 1)); |
72 | 63 | - mmc_irq[1] = qemu_irq_split( | |
73 | + /* | 64 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), |
74 | + * Update the pointer address in case table_data->data moves during above | 65 | - qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); |
75 | + * acpi_data_push operations. | 66 | - qdev_connect_gpio_out_named(dev, "card-read-only", 0, mmc_irq[0]); |
76 | + */ | 67 | - qdev_connect_gpio_out_named(dev, "card-inserted", 0, mmc_irq[1]); |
77 | + iort = (AcpiIortTable *)(table_data->data + iort_start); | 68 | + split_irq_from_named(dev, "card-read-only", |
78 | iort->length = cpu_to_le32(iort_length); | 69 | + qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), |
79 | 70 | + qdev_get_gpio_in(gpio2, 1)); | |
80 | build_header(linker, table_data, (void *)(table_data->data + iort_start), | 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; | ||
81 | -- | 79 | -- |
82 | 2.17.1 | 80 | 2.25.1 |
83 | |||
84 | diff view generated by jsdifflib |
1 | From: Paolo Bonzini <pbonzini@redhat.com> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | cpregs_keys is an uint32_t* so the allocation should use uint32_t. | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | g_new is even better because it is type-safe. | ||
5 | |||
6 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Message-id: 20220324181557.203805-3-zongyuan.li@smartx.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 7 | --- |
11 | target/arm/gdbstub.c | 3 +-- | 8 | hw/arm/stellaris.c | 15 +++++++++++++-- |
12 | 1 file changed, 1 insertion(+), 2 deletions(-) | 9 | 1 file changed, 13 insertions(+), 2 deletions(-) |
13 | 10 | ||
14 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | 11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
15 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/gdbstub.c | 13 | --- a/hw/arm/stellaris.c |
17 | +++ b/target/arm/gdbstub.c | 14 | +++ b/hw/arm/stellaris.c |
18 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_xml(CPUState *cs) | 15 | @@ -XXX,XX +XXX,XX @@ |
19 | RegisterSysregXmlParam param = {cs, s}; | 16 | |
20 | 17 | #include "qemu/osdep.h" | |
21 | cpu->dyn_xml.num_cpregs = 0; | 18 | #include "qapi/error.h" |
22 | - cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) * | 19 | +#include "hw/core/split-irq.h" |
23 | - g_hash_table_size(cpu->cp_regs)); | 20 | #include "hw/sysbus.h" |
24 | + cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); | 21 | #include "hw/sd/sd.h" |
25 | g_string_printf(s, "<?xml version=\"1.0\"?>"); | 22 | #include "hw/ssi/ssi.h" |
26 | g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | 23 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
27 | g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">"); | 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), | ||
37 | + | ||
38 | + gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ); | ||
39 | + qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2); | ||
40 | + qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal); | ||
41 | + qdev_connect_gpio_out( | ||
42 | + gpio_d_splitter, 0, | ||
43 | + qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0)); | ||
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); | ||
48 | + | ||
49 | gpio_out[GPIO_C][7] = qdev_get_gpio_in(ssddev, 0); | ||
50 | |||
51 | /* Make sure the select pin is high. */ | ||
28 | -- | 52 | -- |
29 | 2.17.1 | 53 | 2.25.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | From: Igor Mammedov <imammedo@redhat.com> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | When QEMU is started with following CLI | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | -machine virt,gic-version=3,accel=kvm -cpu host -bios AAVMF_CODE.fd | ||
5 | it crashes with abort at | ||
6 | accel/kvm/kvm-all.c:2164: | ||
7 | KVM_SET_DEVICE_ATTR failed: Group 6 attr 0x000000000000c665: Invalid argument | ||
8 | |||
9 | Which is caused by implicit dependency of kvm_arm_gicv3_reset() on | ||
10 | arm_gicv3_icc_reset() where the later is called by CPU reset | ||
11 | reset callback. | ||
12 | |||
13 | However commit: | ||
14 | 3b77f6c arm/boot: split load_dtb() from arm_load_kernel() | ||
15 | broke CPU reset callback registration in case | ||
16 | |||
17 | arm_load_kernel() | ||
18 | ... | ||
19 | if (!info->kernel_filename || info->firmware_loaded) | ||
20 | |||
21 | branch is taken, i.e. it's sufficient to provide a firmware | ||
22 | or do not provide kernel on CLI to skip cpu reset callback | ||
23 | registration, where before offending commit the callback | ||
24 | has been registered unconditionally. | ||
25 | |||
26 | Fix it by registering the callback right at the beginning of | ||
27 | arm_load_kernel() unconditionally instead of doing it at the end. | ||
28 | |||
29 | NOTE: | ||
30 | we probably should eliminate that dependency anyways as well as | ||
31 | separate arch CPU reset parts from arm_load_kernel() into CPU | ||
32 | itself, but that refactoring that I probably would have to do | ||
33 | anyways later for CPU hotplug to work. | ||
34 | |||
35 | Reported-by: Auger Eric <eric.auger@redhat.com> | ||
36 | Signed-off-by: Igor Mammedov <imammedo@redhat.com> | ||
37 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
38 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
39 | Message-id: 1527070950-208350-1-git-send-email-imammedo@redhat.com | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20220324181557.203805-5-zongyuan.li@smartx.com | ||
6 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/811 | ||
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
42 | --- | 8 | --- |
43 | hw/arm/boot.c | 18 +++++++++--------- | 9 | include/hw/irq.h | 5 ----- |
44 | 1 file changed, 9 insertions(+), 9 deletions(-) | 10 | hw/core/irq.c | 15 --------------- |
11 | 2 files changed, 20 deletions(-) | ||
45 | 12 | ||
46 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 13 | diff --git a/include/hw/irq.h b/include/hw/irq.h |
47 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/arm/boot.c | 15 | --- a/include/hw/irq.h |
49 | +++ b/hw/arm/boot.c | 16 | +++ b/include/hw/irq.h |
50 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | 17 | @@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq); |
51 | static const ARMInsnFixup *primary_loader; | 18 | /* Returns a new IRQ with opposite polarity. */ |
52 | AddressSpace *as = arm_boot_address_space(cpu, info); | 19 | qemu_irq qemu_irq_invert(qemu_irq irq); |
53 | 20 | ||
54 | + /* CPU objects (unlike devices) are not automatically reset on system | 21 | -/* Returns a new IRQ which feeds into both the passed IRQs. |
55 | + * reset, so we must always register a handler to do so. If we're | 22 | - * It's probably better to use the TYPE_SPLIT_IRQ device instead. |
56 | + * actually loading a kernel, the handler is also responsible for | 23 | - */ |
57 | + * arranging that we start it correctly. | 24 | -qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); |
58 | + */ | ||
59 | + for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | ||
60 | + qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | ||
61 | + } | ||
62 | + | ||
63 | /* The board code is not supposed to set secure_board_setup unless | ||
64 | * running its code in secure mode is actually possible, and KVM | ||
65 | * doesn't support secure. | ||
66 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | ||
67 | ARM_CPU(cs)->env.boot_info = info; | ||
68 | } | ||
69 | |||
70 | - /* CPU objects (unlike devices) are not automatically reset on system | ||
71 | - * reset, so we must always register a handler to do so. If we're | ||
72 | - * actually loading a kernel, the handler is also responsible for | ||
73 | - * arranging that we start it correctly. | ||
74 | - */ | ||
75 | - for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | ||
76 | - qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | ||
77 | - } | ||
78 | - | 25 | - |
79 | if (!info->skip_dtb_autoload && have_dtb(info)) { | 26 | /* For internal use in qtest. Similar to qemu_irq_split, but operating |
80 | if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as) < 0) { | 27 | on an existing vector of qemu_irq. */ |
81 | exit(1); | 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 | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/core/irq.c | ||
32 | +++ b/hw/core/irq.c | ||
33 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_invert(qemu_irq irq) | ||
34 | return qemu_allocate_irq(qemu_notirq, irq, 0); | ||
35 | } | ||
36 | |||
37 | -static void qemu_splitirq(void *opaque, int line, int level) | ||
38 | -{ | ||
39 | - struct IRQState **irq = opaque; | ||
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) | ||
53 | { | ||
54 | int i; | ||
82 | -- | 55 | -- |
83 | 2.17.1 | 56 | 2.25.1 |
84 | |||
85 | diff view generated by jsdifflib |
1 | From: Francisco Iglesias <frasse.iglesias@gmail.com> | 1 | From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> |
---|---|---|---|
2 | 2 | ||
3 | Coverity found that the string return by 'object_get_canonical_path' was not | 3 | Describe that the gic-version influences the maximum number of CPUs. |
4 | being freed at two locations in the model (CID 1391294 and CID 1391293) and | ||
5 | also that a memset was being called with a value greater than the max of a byte | ||
6 | on the second argument (CID 1391286). This patch corrects this by adding the | ||
7 | freeing of the strings and also changing to memset to zero instead on | ||
8 | descriptor unaligned errors. | ||
9 | 4 | ||
10 | Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 5 | Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> |
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 6 | Message-id: 20220413231456.35811-1-heinrich.schuchardt@canonical.com |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | [PMM: minor punctuation tweaks] |
13 | Message-id: 20180528184859.3530-1-frasse.iglesias@gmail.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 10 | --- |
17 | hw/dma/xlnx-zdma.c | 10 +++++++--- | 11 | docs/system/arm/virt.rst | 4 ++-- |
18 | 1 file changed, 7 insertions(+), 3 deletions(-) | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
19 | 13 | ||
20 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c | 14 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/dma/xlnx-zdma.c | 16 | --- a/docs/system/arm/virt.rst |
23 | +++ b/hw/dma/xlnx-zdma.c | 17 | +++ b/docs/system/arm/virt.rst |
24 | @@ -XXX,XX +XXX,XX @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf) | 18 | @@ -XXX,XX +XXX,XX @@ gic-version |
25 | qemu_log_mask(LOG_GUEST_ERROR, | 19 | Valid values are: |
26 | "zdma: unaligned descriptor at %" PRIx64, | 20 | |
27 | addr); | 21 | ``2`` |
28 | - memset(buf, 0xdeadbeef, sizeof(XlnxZDMADescr)); | 22 | - GICv2 |
29 | + memset(buf, 0x0, sizeof(XlnxZDMADescr)); | 23 | + GICv2. Note that this limits the number of CPUs to 8. |
30 | s->error = true; | 24 | ``3`` |
31 | return false; | 25 | - GICv3 |
32 | } | 26 | + GICv3. This allows up to 512 CPUs. |
33 | @@ -XXX,XX +XXX,XX @@ static uint64_t zdma_read(void *opaque, hwaddr addr, unsigned size) | 27 | ``host`` |
34 | RegisterInfo *r = &s->regs_info[addr / 4]; | 28 | Use the same GIC version the host provides, when using KVM |
35 | 29 | ``max`` | |
36 | if (!r->data) { | ||
37 | + gchar *path = object_get_canonical_path(OBJECT(s)); | ||
38 | qemu_log("%s: Decode error: read from %" HWADDR_PRIx "\n", | ||
39 | - object_get_canonical_path(OBJECT(s)), | ||
40 | + path, | ||
41 | addr); | ||
42 | + g_free(path); | ||
43 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | ||
44 | zdma_ch_imr_update_irq(s); | ||
45 | return 0; | ||
46 | @@ -XXX,XX +XXX,XX @@ static void zdma_write(void *opaque, hwaddr addr, uint64_t value, | ||
47 | RegisterInfo *r = &s->regs_info[addr / 4]; | ||
48 | |||
49 | if (!r->data) { | ||
50 | + gchar *path = object_get_canonical_path(OBJECT(s)); | ||
51 | qemu_log("%s: Decode error: write to %" HWADDR_PRIx "=%" PRIx64 "\n", | ||
52 | - object_get_canonical_path(OBJECT(s)), | ||
53 | + path, | ||
54 | addr, value); | ||
55 | + g_free(path); | ||
56 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | ||
57 | zdma_ch_imr_update_irq(s); | ||
58 | return; | ||
59 | -- | 30 | -- |
60 | 2.17.1 | 31 | 2.25.1 |
61 | |||
62 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | It forgot to increase clroffset during the loop. So it only clear the | 3 | Similar to the Aspeed code in include/misc/aspeed_scu.h, we define |
4 | first 4 bytes. | 4 | the PWRON STRAP fields in their corresponding module for NPCM7XX. |
5 | 5 | ||
6 | Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920 | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
7 | Cc: qemu-stable@nongnu.org | 7 | Reviewed-by: Patrick Venture <venture@google.com> |
8 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 8 | Message-id: 20220411165842.3912945-2-wuhaotsh@google.com |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Message-id: 1527047633-12368-1-git-send-email-zhaoshenglong@huawei.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | hw/intc/arm_gicv3_kvm.c | 1 + | 12 | include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++ |
15 | 1 file changed, 1 insertion(+) | 13 | 1 file changed, 30 insertions(+) |
16 | 14 | ||
17 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 15 | diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_kvm.c | 17 | --- a/include/hw/misc/npcm7xx_gcr.h |
20 | +++ b/hw/intc/arm_gicv3_kvm.c | 18 | +++ b/include/hw/misc/npcm7xx_gcr.h |
21 | @@ -XXX,XX +XXX,XX @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset, | 19 | @@ -XXX,XX +XXX,XX @@ |
22 | if (clroffset != 0) { | 20 | #include "exec/memory.h" |
23 | reg = 0; | 21 | #include "hw/sysbus.h" |
24 | kvm_gicd_access(s, clroffset, ®, true); | 22 | |
25 | + clroffset += 4; | 23 | +/* |
26 | } | 24 | + * NPCM7XX PWRON STRAP bit fields |
27 | reg = *gic_bmp_ptr32(bmp, irq); | 25 | + * 12: SPI0 powered by VSBV3 at 1.8V |
28 | kvm_gicd_access(s, offset, ®, true); | 26 | + * 11: System flash attached to BMC |
27 | + * 10: BSP alternative pins. | ||
28 | + * 9:8: Flash UART command route enabled. | ||
29 | + * 7: Security enabled. | ||
30 | + * 6: HI-Z state control. | ||
31 | + * 5: ECC disabled. | ||
32 | + * 4: Reserved | ||
33 | + * 3: JTAG2 enabled. | ||
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. | ||
29 | -- | 56 | -- |
30 | 2.17.1 | 57 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | From: Jan Kiszka <jan.kiszka@siemens.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | There was a nasty flip in identifying which register group an access is | 3 | This patch uses the defined fields to describe PWRON STRAPs for |
4 | targeting. The issue caused spuriously raised priorities of the guest | 4 | better readability. |
5 | when handing CPUs over in the Jailhouse hypervisor. | ||
6 | 5 | ||
7 | Cc: qemu-stable@nongnu.org | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
8 | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> | 7 | Reviewed-by: Patrick Venture <venture@google.com> |
9 | Message-id: 28b927d3-da58-bce4-cc13-bfec7f9b1cb9@siemens.com | 8 | Message-id: 20220411165842.3912945-3-wuhaotsh@google.com |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/intc/arm_gicv3_cpuif.c | 12 ++++++------ | 12 | hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++----- |
14 | 1 file changed, 6 insertions(+), 6 deletions(-) | 13 | 1 file changed, 19 insertions(+), 5 deletions(-) |
15 | 14 | ||
16 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 15 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/arm_gicv3_cpuif.c | 17 | --- a/hw/arm/npcm7xx_boards.c |
19 | +++ b/hw/intc/arm_gicv3_cpuif.c | 18 | +++ b/hw/arm/npcm7xx_boards.c |
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 19 | @@ -XXX,XX +XXX,XX @@ |
21 | { | 20 | #include "sysemu/sysemu.h" |
22 | GICv3CPUState *cs = icc_cs_from_env(env); | 21 | #include "sysemu/block-backend.h" |
23 | int regno = ri->opc2 & 3; | 22 | |
24 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | 23 | -#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7 |
25 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | 24 | -#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff |
26 | uint64_t value = cs->ich_apr[grp][regno]; | 25 | -#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff |
27 | 26 | -#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff | |
28 | trace_gicv3_icv_ap_read(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | 27 | -#define MORI_BMC_POWER_ON_STRAPS 0x00001fff |
29 | @@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | 28 | +#define NPCM7XX_POWER_ON_STRAPS_DEFAULT ( \ |
30 | { | 29 | + NPCM7XX_PWRON_STRAP_SPI0F18 | \ |
31 | GICv3CPUState *cs = icc_cs_from_env(env); | 30 | + NPCM7XX_PWRON_STRAP_SFAB | \ |
32 | int regno = ri->opc2 & 3; | 31 | + NPCM7XX_PWRON_STRAP_BSPA | \ |
33 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | 32 | + NPCM7XX_PWRON_STRAP_FUP(FUP_NORM_UART2) | \ |
34 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | 33 | + NPCM7XX_PWRON_STRAP_SECEN | \ |
35 | 34 | + NPCM7XX_PWRON_STRAP_HIZ | \ | |
36 | trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | 35 | + NPCM7XX_PWRON_STRAP_ECC | \ |
37 | 36 | + NPCM7XX_PWRON_STRAP_RESERVE1 | \ | |
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 37 | + NPCM7XX_PWRON_STRAP_J2EN | \ |
39 | uint64_t value; | 38 | + NPCM7XX_PWRON_STRAP_CKFRQ(CKFRQ_DEFAULT)) |
40 | 39 | + | |
41 | int regno = ri->opc2 & 3; | 40 | +#define NPCM750_EVB_POWER_ON_STRAPS ( \ |
42 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | 41 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_J2EN) |
43 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | 42 | +#define QUANTA_GSJ_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT |
44 | 43 | +#define QUANTA_GBS_POWER_ON_STRAPS ( \ | |
45 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | 44 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB) |
46 | return icv_ap_read(env, ri); | 45 | +#define KUDO_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT |
47 | @@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | 46 | +#define MORI_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT |
48 | GICv3CPUState *cs = icc_cs_from_env(env); | 47 | |
49 | 48 | static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin"; | |
50 | int regno = ri->opc2 & 3; | ||
51 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | ||
52 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | ||
53 | |||
54 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | ||
55 | icv_ap_write(env, ri, value); | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
57 | { | ||
58 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
59 | int regno = ri->opc2 & 3; | ||
60 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
61 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
62 | uint64_t value; | ||
63 | |||
64 | value = cs->ich_apr[grp][regno]; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
66 | { | ||
67 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
68 | int regno = ri->opc2 & 3; | ||
69 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
70 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
71 | |||
72 | trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
73 | 49 | ||
74 | -- | 50 | -- |
75 | 2.17.1 | 51 | 2.25.1 |
76 | |||
77 | diff view generated by jsdifflib |