1 | A grab-bag of minor stuff for the end of the year. My to-review | 1 | Nothing too exciting, but does include the last bits of v8.1M support work. |
---|---|---|---|
2 | queue is not empty, but it it at least in single figures... | ||
3 | 2 | ||
4 | -- PMM | 3 | -- PMM |
5 | 4 | ||
6 | The following changes since commit 5bfbd8170ce7acb98a1834ff49ed7340b0837144: | 5 | The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a: |
7 | 6 | ||
8 | Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-6.0-pull-request' into staging (2020-12-14 20:32:38 +0000) | 7 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210107' into staging (2021-01-07 20:34:05 +0000) |
9 | 8 | ||
10 | are available in the Git repository at: | 9 | are available in the Git repository at: |
11 | 10 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201215 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210108 |
13 | 12 | ||
14 | for you to fetch changes up to 23af268566069183285bebbdf95b1b37cb7c0942: | 13 | for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208: |
15 | 14 | ||
16 | hw/block/m25p80: Fix Numonyx fast read dummy cycle count (2020-12-15 13:39:30 +0000) | 15 | docs/system: arm: Add sabrelite board description (2021-01-08 15:13:39 +0000) |
17 | 16 | ||
18 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
19 | target-arm queue: | 18 | target-arm queue: |
20 | * gdbstub: Correct misparsing of vCont C/S requests | 19 | * intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs |
21 | * openrisc: Move pic_cpu code into CPU object proper | 20 | * target/arm: Fix MTE0_ACTIVE |
22 | * nios2: Move IIC code into CPU object proper | 21 | * target/arm: Implement v8.1M and Cortex-M55 model |
23 | * Improve reporting of ROM overlap errors | 22 | * hw/arm/highbank: Drop dead KVM support code |
24 | * xlnx-versal: Add USB support | 23 | * util/qemu-timer: Make timer_free() imply timer_del() |
25 | * hw/misc/zynq_slcr: Avoid #DIV/0! error | 24 | * various devices: Use ptimer_free() in finalize function |
26 | * Numonyx: Fix dummy cycles and check for SPI mode on cmds | 25 | * docs/system: arm: Add sabrelite board description |
26 | * sabrelite: Minor fixes to allow booting U-Boot | ||
27 | 27 | ||
28 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
29 | Joe Komlodi (4): | 29 | Andrew Jones (1): |
30 | hw/block/m25p80: Make Numonyx config field names more accurate | 30 | hw/arm/virt: Remove virt machine state 'smp_cpus' |
31 | hw/block/m25p80: Fix when VCFG XIP bit is set for Numonyx | ||
32 | hw/block/m25p80: Check SPI mode before running some Numonyx commands | ||
33 | hw/block/m25p80: Fix Numonyx fast read dummy cycle count | ||
34 | 31 | ||
35 | Peter Maydell (11): | 32 | Bin Meng (4): |
36 | gdbstub: Correct misparsing of vCont C/S requests | 33 | hw/misc: imx6_ccm: Update PMU_MISC0 reset value |
37 | hw/openrisc/openrisc_sim: Use IRQ splitter when connecting IRQ to multiple CPUs | 34 | hw/msic: imx6_ccm: Correct register value for silicon type |
38 | hw/openrisc/openrisc_sim: Abstract out "get IRQ x of CPU y" | 35 | hw/arm: sabrelite: Connect the Ethernet PHY at address 6 |
39 | target/openrisc: Move pic_cpu code into CPU object proper | 36 | docs/system: arm: Add sabrelite board description |
40 | target/nios2: Move IIC code into CPU object proper | ||
41 | target/nios2: Move nios2_check_interrupts() into target/nios2 | ||
42 | target/nios2: Use deposit32() to update ipending register | ||
43 | hw/core/loader.c: Track last-seen ROM in rom_check_and_register_reset() | ||
44 | hw/core/loader.c: Improve reporting of ROM overlap errors | ||
45 | elf_ops.h: Don't truncate name of the ROM blobs we create | ||
46 | elf_ops.h: Be more verbose with ROM blob names | ||
47 | 37 | ||
48 | Philippe Mathieu-Daudé (1): | 38 | Edgar E. Iglesias (1): |
49 | hw/misc/zynq_slcr: Avoid #DIV/0! error | 39 | intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs |
50 | 40 | ||
51 | Sai Pavan Boddu (2): | 41 | Gan Qixin (7): |
52 | usb: Add versal-usb2-ctrl-regs module | 42 | digic-timer: Use ptimer_free() in the finalize function to avoid memleaks |
53 | usb: xlnx-usb-subsystem: Add xilinx usb subsystem | 43 | allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks |
44 | exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks | ||
45 | exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks | ||
46 | mss-timer: Use ptimer_free() in the finalize function to avoid memleaks | ||
47 | musicpal: Use ptimer_free() in the finalize function to avoid memleaks | ||
48 | exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks | ||
54 | 49 | ||
55 | Vikram Garhwal (2): | 50 | Peter Maydell (9): |
56 | usb: Add DWC3 model | 51 | hw/intc/armv7m_nvic: Correct handling of CCR.BFHFNMIGN |
57 | arm: xlnx-versal: Connect usb to virt-versal | 52 | target/arm: Correct store of FPSCR value via FPCXT_S |
53 | target/arm: Implement FPCXT_NS fp system register | ||
54 | target/arm: Implement Cortex-M55 model | ||
55 | hw/arm/highbank: Drop dead KVM support code | ||
56 | util/qemu-timer: Make timer_free() imply timer_del() | ||
57 | scripts/coccinelle: New script to remove unnecessary timer_del() calls | ||
58 | Remove superfluous timer_del() calls | ||
59 | target/arm: Remove timer_del()/timer_deinit() before timer_free() | ||
58 | 60 | ||
59 | include/hw/arm/xlnx-versal.h | 9 + | 61 | Richard Henderson (1): |
60 | include/hw/elf_ops.h | 5 +- | 62 | target/arm: Fix MTE0_ACTIVE |
61 | include/hw/usb/hcd-dwc3.h | 55 +++ | ||
62 | include/hw/usb/xlnx-usb-subsystem.h | 45 ++ | ||
63 | include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 45 ++ | ||
64 | target/nios2/cpu.h | 3 - | ||
65 | target/openrisc/cpu.h | 1 - | ||
66 | gdbstub.c | 2 +- | ||
67 | hw/arm/xlnx-versal-virt.c | 55 +++ | ||
68 | hw/arm/xlnx-versal.c | 26 ++ | ||
69 | hw/block/m25p80.c | 158 +++++-- | ||
70 | hw/core/loader.c | 67 ++- | ||
71 | hw/intc/nios2_iic.c | 95 ---- | ||
72 | hw/misc/zynq_slcr.c | 5 + | ||
73 | hw/nios2/10m50_devboard.c | 13 +- | ||
74 | hw/nios2/cpu_pic.c | 67 --- | ||
75 | hw/openrisc/openrisc_sim.c | 46 +- | ||
76 | hw/openrisc/pic_cpu.c | 61 --- | ||
77 | hw/usb/hcd-dwc3.c | 689 ++++++++++++++++++++++++++++ | ||
78 | hw/usb/xlnx-usb-subsystem.c | 94 ++++ | ||
79 | hw/usb/xlnx-versal-usb2-ctrl-regs.c | 229 +++++++++ | ||
80 | softmmu/vl.c | 1 - | ||
81 | target/nios2/cpu.c | 29 ++ | ||
82 | target/nios2/op_helper.c | 9 + | ||
83 | target/openrisc/cpu.c | 32 ++ | ||
84 | MAINTAINERS | 1 - | ||
85 | hw/intc/meson.build | 1 - | ||
86 | hw/nios2/meson.build | 2 +- | ||
87 | hw/openrisc/Kconfig | 1 + | ||
88 | hw/openrisc/meson.build | 2 +- | ||
89 | hw/usb/Kconfig | 10 + | ||
90 | hw/usb/meson.build | 3 + | ||
91 | 32 files changed, 1557 insertions(+), 304 deletions(-) | ||
92 | create mode 100644 include/hw/usb/hcd-dwc3.h | ||
93 | create mode 100644 include/hw/usb/xlnx-usb-subsystem.h | ||
94 | create mode 100644 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | ||
95 | delete mode 100644 hw/intc/nios2_iic.c | ||
96 | delete mode 100644 hw/nios2/cpu_pic.c | ||
97 | delete mode 100644 hw/openrisc/pic_cpu.c | ||
98 | create mode 100644 hw/usb/hcd-dwc3.c | ||
99 | create mode 100644 hw/usb/xlnx-usb-subsystem.c | ||
100 | create mode 100644 hw/usb/xlnx-versal-usb2-ctrl-regs.c | ||
101 | 63 | ||
64 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++ | ||
65 | docs/system/target-arm.rst | 1 + | ||
66 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++ | ||
67 | include/hw/arm/virt.h | 3 +- | ||
68 | include/qemu/timer.h | 24 +++--- | ||
69 | block/iscsi.c | 2 - | ||
70 | block/nbd.c | 1 - | ||
71 | block/qcow2.c | 1 - | ||
72 | hw/arm/highbank.c | 14 +-- | ||
73 | hw/arm/musicpal.c | 12 +++ | ||
74 | hw/arm/sabrelite.c | 4 + | ||
75 | hw/arm/virt-acpi-build.c | 9 +- | ||
76 | hw/arm/virt.c | 21 +++-- | ||
77 | hw/block/nvme.c | 2 - | ||
78 | hw/char/serial.c | 2 - | ||
79 | hw/char/virtio-serial-bus.c | 2 - | ||
80 | hw/ide/core.c | 1 - | ||
81 | hw/input/hid.c | 1 - | ||
82 | hw/intc/apic.c | 1 - | ||
83 | hw/intc/arm_gic.c | 4 +- | ||
84 | hw/intc/armv7m_nvic.c | 15 ++++ | ||
85 | hw/intc/ioapic.c | 1 - | ||
86 | hw/ipmi/ipmi_bmc_extern.c | 1 - | ||
87 | hw/misc/imx6_ccm.c | 4 +- | ||
88 | hw/net/e1000.c | 3 - | ||
89 | hw/net/e1000e_core.c | 8 -- | ||
90 | hw/net/pcnet-pci.c | 1 - | ||
91 | hw/net/rtl8139.c | 1 - | ||
92 | hw/net/spapr_llan.c | 1 - | ||
93 | hw/net/virtio-net.c | 2 - | ||
94 | hw/rtc/exynos4210_rtc.c | 9 ++ | ||
95 | hw/s390x/s390-pci-inst.c | 1 - | ||
96 | hw/sd/sd.c | 1 - | ||
97 | hw/sd/sdhci.c | 2 - | ||
98 | hw/timer/allwinner-a10-pit.c | 11 +++ | ||
99 | hw/timer/digic-timer.c | 8 ++ | ||
100 | hw/timer/exynos4210_mct.c | 14 +++ | ||
101 | hw/timer/exynos4210_pwm.c | 11 +++ | ||
102 | hw/timer/mss-timer.c | 13 +++ | ||
103 | hw/usb/dev-hub.c | 1 - | ||
104 | hw/usb/hcd-ehci.c | 1 - | ||
105 | hw/usb/hcd-ohci-pci.c | 1 - | ||
106 | hw/usb/hcd-uhci.c | 1 - | ||
107 | hw/usb/hcd-xhci.c | 1 - | ||
108 | hw/usb/redirect.c | 1 - | ||
109 | hw/vfio/display.c | 1 - | ||
110 | hw/virtio/vhost-vsock-common.c | 1 - | ||
111 | hw/virtio/virtio-balloon.c | 1 - | ||
112 | hw/virtio/virtio-rng.c | 1 - | ||
113 | hw/watchdog/wdt_diag288.c | 1 - | ||
114 | hw/watchdog/wdt_i6300esb.c | 1 - | ||
115 | migration/colo.c | 1 - | ||
116 | monitor/hmp-cmds.c | 1 - | ||
117 | net/announce.c | 1 - | ||
118 | net/colo-compare.c | 1 - | ||
119 | net/slirp.c | 1 - | ||
120 | replay/replay-debugging.c | 1 - | ||
121 | target/arm/cpu.c | 2 - | ||
122 | target/arm/cpu_tcg.c | 42 +++++++++ | ||
123 | target/arm/helper.c | 2 +- | ||
124 | target/s390x/cpu.c | 2 - | ||
125 | ui/console.c | 1 - | ||
126 | ui/spice-core.c | 1 - | ||
127 | util/throttle.c | 1 - | ||
128 | target/arm/translate-vfp.c.inc | 114 ++++++++++++++++++++++-- | ||
129 | 65 files changed, 421 insertions(+), 111 deletions(-) | ||
130 | create mode 100644 docs/system/arm/sabrelite.rst | ||
131 | create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci | ||
132 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | ||
1 | 2 | ||
3 | Correct the indexing into s->cpu_ctlr for vCPUs. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
8 | Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/intc/arm_gic.c | 4 +++- | ||
12 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/intc/arm_gic.c | ||
17 | +++ b/hw/intc/arm_gic.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu, | ||
19 | static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, | ||
20 | int group_mask) | ||
21 | { | ||
22 | + int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu; | ||
23 | + | ||
24 | if (!virt && !(s->ctlr & group_mask)) { | ||
25 | return false; | ||
26 | } | ||
27 | @@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt, | ||
28 | return false; | ||
29 | } | ||
30 | |||
31 | - if (!(s->cpu_ctlr[cpu] & group_mask)) { | ||
32 | + if (!(s->cpu_ctlr[cpu_iface] & group_mask)) { | ||
33 | return false; | ||
34 | } | ||
35 | |||
36 | -- | ||
37 | 2.20.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Andrew Jones <drjones@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Malicious user can set the feedback divisor for the PLLs | 3 | virt machine's 'smp_cpus' and machine->smp.cpus must always have the |
4 | to zero, triggering a floating-point exception (SIGFPE). | 4 | same value. And, anywhere we have virt machine state we have machine |
5 | state. So let's remove the redundancy. Also, to make it easier to see | ||
6 | that machine->smp is the true source for "smp_cpus" and "max_cpus", | ||
7 | avoid passing them in function parameters, preferring instead to get | ||
8 | them from the state. | ||
5 | 9 | ||
6 | As the datasheet [*] is not clear how hardware behaves | 10 | No functional change intended. |
7 | when these bits are zeroes, use the maximum divisor | ||
8 | possible (128) to avoid the software FPE. | ||
9 | 11 | ||
10 | [*] Zynq-7000 TRM, UG585 (v1.12.2) | 12 | Signed-off-by: Andrew Jones <drjones@redhat.com> |
11 | B.28 System Level Control Registers (slcr) | 13 | Reviewed-by: David Edmondson <david.edmondson@oracle.com> |
12 | -> "Register (slcr) ARM_PLL_CTRL" | 14 | Reviewed-by: Ying Fang <fangying1@huawei.com> |
13 | 25.10.4 PLLs | 15 | Message-id: 20201215174815.51520-1-drjones@redhat.com |
14 | -> "Software-Controlled PLL Update" | 16 | [PMM: minor formatting tweak to smp_cpus variable declaration] |
15 | |||
16 | Fixes: 38867cb7ec9 ("hw/misc/zynq_slcr: add clock generation for uarts") | ||
17 | Reported-by: Gaoning Pan <pgn@zju.edu.cn> | ||
18 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
19 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
20 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
21 | Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> | ||
22 | Message-id: 20201210141610.884600-1-f4bug@amsat.org | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 18 | --- |
25 | hw/misc/zynq_slcr.c | 5 +++++ | 19 | include/hw/arm/virt.h | 3 +-- |
26 | 1 file changed, 5 insertions(+) | 20 | hw/arm/virt-acpi-build.c | 9 +++++---- |
21 | hw/arm/virt.c | 21 ++++++++++----------- | ||
22 | 3 files changed, 16 insertions(+), 17 deletions(-) | ||
27 | 23 | ||
28 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c | 24 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
29 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/misc/zynq_slcr.c | 26 | --- a/include/hw/arm/virt.h |
31 | +++ b/hw/misc/zynq_slcr.c | 27 | +++ b/include/hw/arm/virt.h |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t zynq_slcr_compute_pll(uint64_t input, uint32_t ctrl_reg) | 28 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { |
33 | return 0; | 29 | MemMapEntry *memmap; |
30 | char *pciehb_nodename; | ||
31 | const int *irqmap; | ||
32 | - int smp_cpus; | ||
33 | void *fdt; | ||
34 | int fdt_size; | ||
35 | uint32_t clock_phandle; | ||
36 | @@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) | ||
37 | |||
38 | assert(vms->gic_version == VIRT_GIC_VERSION_3); | ||
39 | |||
40 | - return vms->smp_cpus > redist0_capacity ? 2 : 1; | ||
41 | + return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1; | ||
42 | } | ||
43 | |||
44 | #endif /* QEMU_ARM_VIRT_H */ | ||
45 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/arm/virt-acpi-build.c | ||
48 | +++ b/hw/arm/virt-acpi-build.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | |||
51 | #define ACPI_BUILD_TABLE_SIZE 0x20000 | ||
52 | |||
53 | -static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) | ||
54 | +static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms) | ||
55 | { | ||
56 | + MachineState *ms = MACHINE(vms); | ||
57 | uint16_t i; | ||
58 | |||
59 | - for (i = 0; i < smp_cpus; i++) { | ||
60 | + for (i = 0; i < ms->smp.cpus; i++) { | ||
61 | Aml *dev = aml_device("C%.03X", i); | ||
62 | aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007"))); | ||
63 | aml_append(dev, aml_name_decl("_UID", aml_int(i))); | ||
64 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
65 | gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base); | ||
66 | gicd->version = vms->gic_version; | ||
67 | |||
68 | - for (i = 0; i < vms->smp_cpus; i++) { | ||
69 | + for (i = 0; i < MACHINE(vms)->smp.cpus; i++) { | ||
70 | AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data, | ||
71 | sizeof(*gicc)); | ||
72 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i)); | ||
73 | @@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
74 | * the RTC ACPI device at all when using UEFI. | ||
75 | */ | ||
76 | scope = aml_scope("\\_SB"); | ||
77 | - acpi_dsdt_add_cpus(scope, vms->smp_cpus); | ||
78 | + acpi_dsdt_add_cpus(scope, vms); | ||
79 | acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], | ||
80 | (irqmap[VIRT_UART] + ARM_SPI_BASE)); | ||
81 | if (vmc->acpi_expose_flash) { | ||
82 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/hw/arm/virt.c | ||
85 | +++ b/hw/arm/virt.c | ||
86 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) | ||
87 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
88 | irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, | ||
89 | GIC_FDT_IRQ_PPI_CPU_WIDTH, | ||
90 | - (1 << vms->smp_cpus) - 1); | ||
91 | + (1 << MACHINE(vms)->smp.cpus) - 1); | ||
34 | } | 92 | } |
35 | 93 | ||
36 | + /* Consider zero feedback as maximum divide ratio possible */ | 94 | qemu_fdt_add_subnode(vms->fdt, "/timer"); |
37 | + if (!mult) { | 95 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) |
38 | + mult = 1 << R_xxx_PLL_CTRL_PLL_FPDIV_LENGTH; | 96 | int cpu; |
39 | + } | 97 | int addr_cells = 1; |
40 | + | 98 | const MachineState *ms = MACHINE(vms); |
41 | /* frequency multiplier -> period division */ | 99 | + int smp_cpus = ms->smp.cpus; |
42 | return input / mult; | 100 | |
43 | } | 101 | /* |
102 | * From Documentation/devicetree/bindings/arm/cpus.txt | ||
103 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
104 | * The simplest way to go is to examine affinity IDs of all our CPUs. If | ||
105 | * at least one of them has Aff3 populated, we set #address-cells to 2. | ||
106 | */ | ||
107 | - for (cpu = 0; cpu < vms->smp_cpus; cpu++) { | ||
108 | + for (cpu = 0; cpu < smp_cpus; cpu++) { | ||
109 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | ||
110 | |||
111 | if (armcpu->mp_affinity & ARM_AFF3_MASK) { | ||
112 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
113 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells); | ||
114 | qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0); | ||
115 | |||
116 | - for (cpu = vms->smp_cpus - 1; cpu >= 0; cpu--) { | ||
117 | + for (cpu = smp_cpus - 1; cpu >= 0; cpu--) { | ||
118 | char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); | ||
119 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | ||
120 | CPUState *cs = CPU(armcpu); | ||
121 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
122 | qemu_fdt_setprop_string(vms->fdt, nodename, "compatible", | ||
123 | armcpu->dtb_compatible); | ||
124 | |||
125 | - if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED | ||
126 | - && vms->smp_cpus > 1) { | ||
127 | + if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED && smp_cpus > 1) { | ||
128 | qemu_fdt_setprop_string(vms->fdt, nodename, | ||
129 | "enable-method", "psci"); | ||
130 | } | ||
131 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) | ||
132 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
133 | irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, | ||
134 | GIC_FDT_IRQ_PPI_CPU_WIDTH, | ||
135 | - (1 << vms->smp_cpus) - 1); | ||
136 | + (1 << MACHINE(vms)->smp.cpus) - 1); | ||
137 | } | ||
138 | |||
139 | qemu_fdt_add_subnode(vms->fdt, "/pmu"); | ||
140 | @@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms) | ||
141 | * virt_cpu_post_init() must be called after the CPUs have | ||
142 | * been realized and the GIC has been created. | ||
143 | */ | ||
144 | -static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus, | ||
145 | - MemoryRegion *sysmem) | ||
146 | +static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem) | ||
147 | { | ||
148 | + int max_cpus = MACHINE(vms)->smp.max_cpus; | ||
149 | bool aarch64, pmu, steal_time; | ||
150 | CPUState *cpu; | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
153 | exit(1); | ||
154 | } | ||
155 | |||
156 | - vms->smp_cpus = smp_cpus; | ||
157 | - | ||
158 | if (vms->virt && kvm_enabled()) { | ||
159 | error_report("mach-virt: KVM does not support providing " | ||
160 | "Virtualization extensions to the guest CPU"); | ||
161 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
162 | create_fdt(vms); | ||
163 | |||
164 | possible_cpus = mc->possible_cpu_arch_ids(machine); | ||
165 | + assert(possible_cpus->len == max_cpus); | ||
166 | for (n = 0; n < possible_cpus->len; n++) { | ||
167 | Object *cpuobj; | ||
168 | CPUState *cs; | ||
169 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
170 | |||
171 | create_gic(vms); | ||
172 | |||
173 | - virt_cpu_post_init(vms, possible_cpus->len, sysmem); | ||
174 | + virt_cpu_post_init(vms, sysmem); | ||
175 | |||
176 | fdt_add_pmu_nodes(vms); | ||
177 | |||
44 | -- | 178 | -- |
45 | 2.20.1 | 179 | 2.20.1 |
46 | 180 | ||
47 | 181 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | In 50244cc76abc we updated mte_check_fail to match the ARM | ||
4 | pseudocode, using the correct EL to select the TCF field. | ||
5 | But we failed to update MTE0_ACTIVE the same way, which led | ||
6 | to g_assert_not_reached(). | ||
7 | |||
8 | Cc: qemu-stable@nongnu.org | ||
9 | Buglink: https://bugs.launchpad.net/bugs/1907137 | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20201221204426.88514-1-richard.henderson@linaro.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/helper.c | 2 +- | ||
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper.c | ||
21 | +++ b/target/arm/helper.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
23 | if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV) | ||
24 | && tbid | ||
25 | && !(env->pstate & PSTATE_TCO) | ||
26 | - && (sctlr & SCTLR_TCF0) | ||
27 | + && (sctlr & SCTLR_TCF) | ||
28 | && allocation_tag_access_enabled(env, 0, sctlr)) { | ||
29 | flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1); | ||
30 | } | ||
31 | -- | ||
32 | 2.20.1 | ||
33 | |||
34 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The CCR is a register most of whose bits are banked between security | ||
2 | states but where BFHFNMIGN is not, and we keep it in the non-secure | ||
3 | entry of the v7m.ccr[] array. The logic which tries to handle this | ||
4 | bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS | ||
5 | is zero" requirement; correct the omission. | ||
1 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20201210201433.26262-2-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/intc/armv7m_nvic.c | 15 +++++++++++++++ | ||
12 | 1 file changed, 15 insertions(+) | ||
13 | |||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/intc/armv7m_nvic.c | ||
17 | +++ b/hw/intc/armv7m_nvic.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
19 | */ | ||
20 | val = cpu->env.v7m.ccr[attrs.secure]; | ||
21 | val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | ||
22 | + /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */ | ||
23 | + if (!attrs.secure) { | ||
24 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
25 | + val &= ~R_V7M_CCR_BFHFNMIGN_MASK; | ||
26 | + } | ||
27 | + } | ||
28 | return val; | ||
29 | case 0xd24: /* System Handler Control and State (SHCSR) */ | ||
30 | if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) { | ||
31 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
32 | (cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK) | ||
33 | | (value & R_V7M_CCR_BFHFNMIGN_MASK); | ||
34 | value &= ~R_V7M_CCR_BFHFNMIGN_MASK; | ||
35 | + } else { | ||
36 | + /* | ||
37 | + * BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0, so | ||
38 | + * preserve the state currently in the NS element of the array | ||
39 | + */ | ||
40 | + if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
41 | + value &= ~R_V7M_CCR_BFHFNMIGN_MASK; | ||
42 | + value |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | ||
43 | + } | ||
44 | } | ||
45 | |||
46 | cpu->env.v7m.ccr[attrs.secure] = value; | ||
47 | -- | ||
48 | 2.20.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
1 | Instead of making the ROM blob name something like: | 1 | In commit 64f863baeedc8659 we implemented the v8.1M FPCXT_S register, |
---|---|---|---|
2 | phdr #0: /home/petmay01/linaro/qemu-misc-tests/ldmia-fault.axf | 2 | but we got the write behaviour wrong. On read, this register reads |
3 | make it a little more self-explanatory for people who don't know | 3 | bits [27:0] of FPSCR plus the CONTROL.SFPA bit. On write, it doesn't |
4 | ELF format details: | 4 | just write back those bits -- it writes a value to the whole FPSCR, |
5 | /home/petmay01/linaro/qemu-misc-tests/ldmia-fault.axf ELF program header segment 0 | 5 | whose upper 4 bits are zeroes. |
6 | |||
7 | We also incorrectly implemented the write-to-FPSCR as a simple store | ||
8 | to vfp.xregs; this skips the "update the softfloat flags" part of | ||
9 | the vfp_set_fpscr helper so the value would read back correctly but | ||
10 | not actually take effect. | ||
11 | |||
12 | Fix both of these things by doing a complete write to the FPSCR | ||
13 | using the helper function. | ||
6 | 14 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201129203923.10622-5-peter.maydell@linaro.org | 17 | Message-id: 20201210201433.26262-3-peter.maydell@linaro.org |
10 | --- | 18 | --- |
11 | include/hw/elf_ops.h | 3 ++- | 19 | target/arm/translate-vfp.c.inc | 12 ++++++------ |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 20 | 1 file changed, 6 insertions(+), 6 deletions(-) |
13 | 21 | ||
14 | diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h | 22 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/elf_ops.h | 24 | --- a/target/arm/translate-vfp.c.inc |
17 | +++ b/include/hw/elf_ops.h | 25 | +++ b/target/arm/translate-vfp.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ static int glue(load_elf, SZ)(const char *name, int fd, | 26 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
19 | if (mem_size != 0) { | 27 | } |
20 | if (load_rom) { | 28 | case ARM_VFP_FPCXT_S: |
21 | g_autofree char *label = | 29 | { |
22 | - g_strdup_printf("phdr #%d: %s", i, name); | 30 | - TCGv_i32 sfpa, control, fpscr; |
23 | + g_strdup_printf("%s ELF program header segment %d", | 31 | - /* Set FPSCR[27:0] and CONTROL.SFPA from value */ |
24 | + name, i); | 32 | + TCGv_i32 sfpa, control; |
25 | 33 | + /* | |
26 | /* | 34 | + * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes |
27 | * rom_add_elf_program() takes its own reference to | 35 | + * bits [27:0] from value and zeroes bits [31:28]. |
36 | + */ | ||
37 | tmp = loadfn(s, opaque); | ||
38 | sfpa = tcg_temp_new_i32(); | ||
39 | tcg_gen_shri_i32(sfpa, tmp, 31); | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
41 | tcg_gen_deposit_i32(control, control, sfpa, | ||
42 | R_V7M_CONTROL_SFPA_SHIFT, 1); | ||
43 | store_cpu_field(control, v7m.control[M_REG_S]); | ||
44 | - fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
45 | - tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK); | ||
46 | tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
47 | - tcg_gen_or_i32(fpscr, fpscr, tmp); | ||
48 | - store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | ||
49 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); | ||
50 | tcg_temp_free_i32(tmp); | ||
51 | tcg_temp_free_i32(sfpa); | ||
52 | break; | ||
28 | -- | 53 | -- |
29 | 2.20.1 | 54 | 2.20.1 |
30 | 55 | ||
31 | 56 | diff view generated by jsdifflib |
1 | We're about to refactor the OpenRISC pic_cpu code in a way that means | 1 | Implement the v8.1M FPCXT_NS floating-point system register. This is |
---|---|---|---|
2 | that just grabbing the whole qemu_irq[] array of inbound IRQs for a | 2 | a little more complicated than FPCXT_S, because it has specific |
3 | CPU won't be possible any more. Abstract out a function for "return | 3 | handling for "current FP state is inactive", and it only wants to do |
4 | the qemu_irq for IRQ x input of CPU y" so we can more easily replace | 4 | PreserveFPState(), not the full set of actions done by |
5 | the implementation. | 5 | ExecuteFPCheck() which vfp_access_check() implements. |
6 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Stafford Horne <shorne@gmail.com> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201127225127.14770-3-peter.maydell@linaro.org | 9 | Message-id: 20201210201433.26262-4-peter.maydell@linaro.org |
10 | --- | 10 | --- |
11 | hw/openrisc/openrisc_sim.c | 38 +++++++++++++++++++++----------------- | 11 | target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++- |
12 | 1 file changed, 21 insertions(+), 17 deletions(-) | 12 | 1 file changed, 99 insertions(+), 3 deletions(-) |
13 | 13 | ||
14 | diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c | 14 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/openrisc/openrisc_sim.c | 16 | --- a/target/arm/translate-vfp.c.inc |
17 | +++ b/hw/openrisc/openrisc_sim.c | 17 | +++ b/target/arm/translate-vfp.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ static void main_cpu_reset(void *opaque) | 18 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) |
19 | cpu_set_pc(cs, boot_info.bootstrap_pc); | 19 | } |
20 | break; | ||
21 | case ARM_VFP_FPCXT_S: | ||
22 | + case ARM_VFP_FPCXT_NS: | ||
23 | if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
24 | return false; | ||
25 | } | ||
26 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
27 | return FPSysRegCheckFailed; | ||
28 | } | ||
29 | |||
30 | - if (!vfp_access_check(s)) { | ||
31 | + /* | ||
32 | + * FPCXT_NS is a special case: it has specific handling for | ||
33 | + * "current FP state is inactive", and must do the PreserveFPState() | ||
34 | + * but not the usual full set of actions done by ExecuteFPCheck(). | ||
35 | + * So we don't call vfp_access_check() and the callers must handle this. | ||
36 | + */ | ||
37 | + if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) { | ||
38 | return FPSysRegCheckDone; | ||
39 | } | ||
40 | - | ||
41 | return FPSysRegCheckContinue; | ||
20 | } | 42 | } |
21 | 43 | ||
22 | +static qemu_irq get_cpu_irq(OpenRISCCPU *cpus[], int cpunum, int irq_pin) | 44 | +static void gen_branch_fpInactive(DisasContext *s, TCGCond cond, |
45 | + TCGLabel *label) | ||
23 | +{ | 46 | +{ |
24 | + return cpus[cpunum]->env.irq[irq_pin]; | 47 | + /* |
48 | + * FPCXT_NS is a special case: it has specific handling for | ||
49 | + * "current FP state is inactive", and must do the PreserveFPState() | ||
50 | + * but not the usual full set of actions done by ExecuteFPCheck(). | ||
51 | + * We don't have a TB flag that matches the fpInactive check, so we | ||
52 | + * do it at runtime as we don't expect FPCXT_NS accesses to be frequent. | ||
53 | + * | ||
54 | + * Emit code that checks fpInactive and does a conditional | ||
55 | + * branch to label based on it: | ||
56 | + * if cond is TCG_COND_NE then branch if fpInactive != 0 (ie if inactive) | ||
57 | + * if cond is TCG_COND_EQ then branch if fpInactive == 0 (ie if active) | ||
58 | + */ | ||
59 | + assert(cond == TCG_COND_EQ || cond == TCG_COND_NE); | ||
60 | + | ||
61 | + /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */ | ||
62 | + TCGv_i32 aspen, fpca; | ||
63 | + aspen = load_cpu_field(v7m.fpccr[M_REG_NS]); | ||
64 | + fpca = load_cpu_field(v7m.control[M_REG_S]); | ||
65 | + tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
66 | + tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
67 | + tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK); | ||
68 | + tcg_gen_or_i32(fpca, fpca, aspen); | ||
69 | + tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label); | ||
70 | + tcg_temp_free_i32(aspen); | ||
71 | + tcg_temp_free_i32(fpca); | ||
25 | +} | 72 | +} |
26 | + | 73 | + |
27 | static void openrisc_sim_net_init(hwaddr base, hwaddr descriptors, | 74 | static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
28 | - int num_cpus, qemu_irq **cpu_irqs, | 75 | |
29 | + int num_cpus, OpenRISCCPU *cpus[], | 76 | fp_sysreg_loadfn *loadfn, |
30 | int irq_pin, NICInfo *nd) | 77 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
31 | { | 78 | { |
32 | DeviceState *dev; | 79 | /* Do a write to an M-profile floating point system register */ |
33 | @@ -XXX,XX +XXX,XX @@ static void openrisc_sim_net_init(hwaddr base, hwaddr descriptors, | 80 | TCGv_i32 tmp; |
34 | qdev_prop_set_uint32(splitter, "num-lines", num_cpus); | 81 | + TCGLabel *lab_end = NULL; |
35 | qdev_realize_and_unref(splitter, NULL, &error_fatal); | 82 | |
36 | for (i = 0; i < num_cpus; i++) { | 83 | switch (fp_sysreg_checks(s, regno)) { |
37 | - qdev_connect_gpio_out(splitter, i, cpu_irqs[i][irq_pin]); | 84 | case FPSysRegCheckFailed: |
38 | + qdev_connect_gpio_out(splitter, i, get_cpu_irq(cpus, i, irq_pin)); | 85 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, |
39 | } | 86 | tcg_temp_free_i32(tmp); |
40 | sysbus_connect_irq(s, 0, qdev_get_gpio_in(splitter, 0)); | 87 | break; |
41 | } else { | ||
42 | - sysbus_connect_irq(s, 0, cpu_irqs[0][irq_pin]); | ||
43 | + sysbus_connect_irq(s, 0, get_cpu_irq(cpus, 0, irq_pin)); | ||
44 | } | 88 | } |
45 | sysbus_mmio_map(s, 0, base); | 89 | + case ARM_VFP_FPCXT_NS: |
46 | sysbus_mmio_map(s, 1, descriptors); | 90 | + lab_end = gen_new_label(); |
91 | + /* fpInactive case: write is a NOP, so branch to end */ | ||
92 | + gen_branch_fpInactive(s, TCG_COND_NE, lab_end); | ||
93 | + /* !fpInactive: PreserveFPState(), and reads same as FPCXT_S */ | ||
94 | + gen_preserve_fp_state(s); | ||
95 | + /* fall through */ | ||
96 | case ARM_VFP_FPCXT_S: | ||
97 | { | ||
98 | TCGv_i32 sfpa, control; | ||
99 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
100 | default: | ||
101 | g_assert_not_reached(); | ||
102 | } | ||
103 | + if (lab_end) { | ||
104 | + gen_set_label(lab_end); | ||
105 | + } | ||
106 | return true; | ||
47 | } | 107 | } |
48 | 108 | ||
49 | static void openrisc_sim_ompic_init(hwaddr base, int num_cpus, | 109 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, |
50 | - qemu_irq **cpu_irqs, int irq_pin) | ||
51 | + OpenRISCCPU *cpus[], int irq_pin) | ||
52 | { | 110 | { |
53 | DeviceState *dev; | 111 | /* Do a read from an M-profile floating point system register */ |
54 | SysBusDevice *s; | 112 | TCGv_i32 tmp; |
55 | @@ -XXX,XX +XXX,XX @@ static void openrisc_sim_ompic_init(hwaddr base, int num_cpus, | 113 | + TCGLabel *lab_end = NULL; |
56 | s = SYS_BUS_DEVICE(dev); | 114 | + bool lookup_tb = false; |
57 | sysbus_realize_and_unref(s, &error_fatal); | 115 | |
58 | for (i = 0; i < num_cpus; i++) { | 116 | switch (fp_sysreg_checks(s, regno)) { |
59 | - sysbus_connect_irq(s, i, cpu_irqs[i][irq_pin]); | 117 | case FPSysRegCheckFailed: |
60 | + sysbus_connect_irq(s, i, get_cpu_irq(cpus, i, irq_pin)); | 118 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, |
119 | fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
120 | gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
121 | tcg_temp_free_i32(fpscr); | ||
122 | - gen_lookup_tb(s); | ||
123 | + lookup_tb = true; | ||
124 | + break; | ||
125 | + } | ||
126 | + case ARM_VFP_FPCXT_NS: | ||
127 | + { | ||
128 | + TCGv_i32 control, sfpa, fpscr, fpdscr, zero; | ||
129 | + TCGLabel *lab_active = gen_new_label(); | ||
130 | + | ||
131 | + lookup_tb = true; | ||
132 | + | ||
133 | + gen_branch_fpInactive(s, TCG_COND_EQ, lab_active); | ||
134 | + /* fpInactive case: reads as FPDSCR_NS */ | ||
135 | + TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
136 | + storefn(s, opaque, tmp); | ||
137 | + lab_end = gen_new_label(); | ||
138 | + tcg_gen_br(lab_end); | ||
139 | + | ||
140 | + gen_set_label(lab_active); | ||
141 | + /* !fpInactive: Reads the same as FPCXT_S, but side effects differ */ | ||
142 | + gen_preserve_fp_state(s); | ||
143 | + tmp = tcg_temp_new_i32(); | ||
144 | + sfpa = tcg_temp_new_i32(); | ||
145 | + fpscr = tcg_temp_new_i32(); | ||
146 | + gen_helper_vfp_get_fpscr(fpscr, cpu_env); | ||
147 | + tcg_gen_andi_i32(tmp, fpscr, ~FPCR_NZCV_MASK); | ||
148 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
149 | + tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
150 | + tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
151 | + tcg_gen_or_i32(tmp, tmp, sfpa); | ||
152 | + tcg_temp_free_i32(control); | ||
153 | + /* Store result before updating FPSCR, in case it faults */ | ||
154 | + storefn(s, opaque, tmp); | ||
155 | + /* If SFPA is zero then set FPSCR from FPDSCR_NS */ | ||
156 | + fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
157 | + zero = tcg_const_i32(0); | ||
158 | + tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr); | ||
159 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
160 | + tcg_temp_free_i32(zero); | ||
161 | + tcg_temp_free_i32(sfpa); | ||
162 | + tcg_temp_free_i32(fpdscr); | ||
163 | + tcg_temp_free_i32(fpscr); | ||
164 | break; | ||
61 | } | 165 | } |
62 | sysbus_mmio_map(s, 0, base); | 166 | default: |
167 | g_assert_not_reached(); | ||
168 | } | ||
169 | + | ||
170 | + if (lab_end) { | ||
171 | + gen_set_label(lab_end); | ||
172 | + } | ||
173 | + if (lookup_tb) { | ||
174 | + gen_lookup_tb(s); | ||
175 | + } | ||
176 | return true; | ||
63 | } | 177 | } |
64 | @@ -XXX,XX +XXX,XX @@ static void openrisc_sim_init(MachineState *machine) | 178 | |
65 | { | ||
66 | ram_addr_t ram_size = machine->ram_size; | ||
67 | const char *kernel_filename = machine->kernel_filename; | ||
68 | - OpenRISCCPU *cpu = NULL; | ||
69 | + OpenRISCCPU *cpus[2] = {}; | ||
70 | MemoryRegion *ram; | ||
71 | - qemu_irq *cpu_irqs[2]; | ||
72 | qemu_irq serial_irq; | ||
73 | int n; | ||
74 | unsigned int smp_cpus = machine->smp.cpus; | ||
75 | |||
76 | assert(smp_cpus >= 1 && smp_cpus <= 2); | ||
77 | for (n = 0; n < smp_cpus; n++) { | ||
78 | - cpu = OPENRISC_CPU(cpu_create(machine->cpu_type)); | ||
79 | - if (cpu == NULL) { | ||
80 | + cpus[n] = OPENRISC_CPU(cpu_create(machine->cpu_type)); | ||
81 | + if (cpus[n] == NULL) { | ||
82 | fprintf(stderr, "Unable to find CPU definition!\n"); | ||
83 | exit(1); | ||
84 | } | ||
85 | - cpu_openrisc_pic_init(cpu); | ||
86 | - cpu_irqs[n] = (qemu_irq *) cpu->env.irq; | ||
87 | + cpu_openrisc_pic_init(cpus[n]); | ||
88 | |||
89 | - cpu_openrisc_clock_init(cpu); | ||
90 | + cpu_openrisc_clock_init(cpus[n]); | ||
91 | |||
92 | - qemu_register_reset(main_cpu_reset, cpu); | ||
93 | + qemu_register_reset(main_cpu_reset, cpus[n]); | ||
94 | } | ||
95 | |||
96 | ram = g_malloc(sizeof(*ram)); | ||
97 | @@ -XXX,XX +XXX,XX @@ static void openrisc_sim_init(MachineState *machine) | ||
98 | |||
99 | if (nd_table[0].used) { | ||
100 | openrisc_sim_net_init(0x92000000, 0x92000400, smp_cpus, | ||
101 | - cpu_irqs, 4, nd_table); | ||
102 | + cpus, 4, nd_table); | ||
103 | } | ||
104 | |||
105 | if (smp_cpus > 1) { | ||
106 | - openrisc_sim_ompic_init(0x98000000, smp_cpus, cpu_irqs, 1); | ||
107 | + openrisc_sim_ompic_init(0x98000000, smp_cpus, cpus, 1); | ||
108 | |||
109 | - serial_irq = qemu_irq_split(cpu_irqs[0][2], cpu_irqs[1][2]); | ||
110 | + serial_irq = qemu_irq_split(get_cpu_irq(cpus, 0, 2), | ||
111 | + get_cpu_irq(cpus, 1, 2)); | ||
112 | } else { | ||
113 | - serial_irq = cpu_irqs[0][2]; | ||
114 | + serial_irq = get_cpu_irq(cpus, 0, 2); | ||
115 | } | ||
116 | |||
117 | serial_mm_init(get_system_memory(), 0x90000000, 0, serial_irq, | ||
118 | -- | 179 | -- |
119 | 2.20.1 | 180 | 2.20.1 |
120 | 181 | ||
121 | 182 | diff view generated by jsdifflib |
1 | In rom_check_and_register_reset() we detect overlaps by looking at | 1 | Now that we have implemented all the features needed by the v8.1M |
---|---|---|---|
2 | whether the ROM blob we're currently examining is in the same address | 2 | architecture, we can add the model of the Cortex-M55. This is the |
3 | space and starts before the previous ROM blob ends. (This works | 3 | configuration without MVE support; we'll add MVE later. |
4 | because the ROM list is kept sorted in order by AddressSpace and then | ||
5 | by address.) | ||
6 | |||
7 | Instead of keeping the AddressSpace and last address of the previous ROM | ||
8 | blob in local variables, just keep a pointer to it. | ||
9 | |||
10 | This will allow us to print more useful information when we do detect | ||
11 | an overlap. | ||
12 | 4 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20201129203923.10622-2-peter.maydell@linaro.org | 7 | Message-id: 20201210201433.26262-5-peter.maydell@linaro.org |
16 | --- | 8 | --- |
17 | hw/core/loader.c | 23 +++++++++++++++-------- | 9 | target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++ |
18 | 1 file changed, 15 insertions(+), 8 deletions(-) | 10 | 1 file changed, 42 insertions(+) |
19 | 11 | ||
20 | diff --git a/hw/core/loader.c b/hw/core/loader.c | 12 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
21 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/core/loader.c | 14 | --- a/target/arm/cpu_tcg.c |
23 | +++ b/hw/core/loader.c | 15 | +++ b/target/arm/cpu_tcg.c |
24 | @@ -XXX,XX +XXX,XX @@ static void rom_reset(void *unused) | 16 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) |
25 | } | 17 | cpu->ctr = 0x8000c000; |
26 | } | 18 | } |
27 | 19 | ||
28 | +/* Return true if two consecutive ROMs in the ROM list overlap */ | 20 | +static void cortex_m55_initfn(Object *obj) |
29 | +static bool roms_overlap(Rom *last_rom, Rom *this_rom) | ||
30 | +{ | 21 | +{ |
31 | + if (!last_rom) { | 22 | + ARMCPU *cpu = ARM_CPU(obj); |
32 | + return false; | 23 | + |
33 | + } | 24 | + set_feature(&cpu->env, ARM_FEATURE_V8); |
34 | + return last_rom->as == this_rom->as && | 25 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); |
35 | + last_rom->addr + last_rom->romsize > this_rom->addr; | 26 | + set_feature(&cpu->env, ARM_FEATURE_M); |
27 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
28 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
29 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
30 | + cpu->midr = 0x410fd221; /* r0p1 */ | ||
31 | + cpu->revidr = 0; | ||
32 | + cpu->pmsav7_dregion = 16; | ||
33 | + cpu->sau_sregion = 8; | ||
34 | + /* | ||
35 | + * These are the MVFR* values for the FPU, no MVE configuration; | ||
36 | + * we will update them later when we implement MVE | ||
37 | + */ | ||
38 | + cpu->isar.mvfr0 = 0x10110221; | ||
39 | + cpu->isar.mvfr1 = 0x12100011; | ||
40 | + cpu->isar.mvfr2 = 0x00000040; | ||
41 | + cpu->isar.id_pfr0 = 0x20000030; | ||
42 | + cpu->isar.id_pfr1 = 0x00000230; | ||
43 | + cpu->isar.id_dfr0 = 0x10200000; | ||
44 | + cpu->id_afr0 = 0x00000000; | ||
45 | + cpu->isar.id_mmfr0 = 0x00111040; | ||
46 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
47 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
48 | + cpu->isar.id_mmfr3 = 0x00000011; | ||
49 | + cpu->isar.id_isar0 = 0x01103110; | ||
50 | + cpu->isar.id_isar1 = 0x02212000; | ||
51 | + cpu->isar.id_isar2 = 0x20232232; | ||
52 | + cpu->isar.id_isar3 = 0x01111131; | ||
53 | + cpu->isar.id_isar4 = 0x01310132; | ||
54 | + cpu->isar.id_isar5 = 0x00000000; | ||
55 | + cpu->isar.id_isar6 = 0x00000000; | ||
56 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
57 | + cpu->ctr = 0x8303c003; | ||
36 | +} | 58 | +} |
37 | + | 59 | + |
38 | int rom_check_and_register_reset(void) | 60 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { |
39 | { | 61 | /* Dummy the TCM region regs for the moment */ |
40 | - hwaddr addr = 0; | 62 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, |
41 | MemoryRegionSection section; | 63 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { |
42 | - Rom *rom; | 64 | .class_init = arm_v7m_class_init }, |
43 | - AddressSpace *as = NULL; | 65 | { .name = "cortex-m33", .initfn = cortex_m33_initfn, |
44 | + Rom *rom, *last_rom = NULL; | 66 | .class_init = arm_v7m_class_init }, |
45 | 67 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | |
46 | QTAILQ_FOREACH(rom, &roms, next) { | 68 | + .class_init = arm_v7m_class_init }, |
47 | if (rom->fw_file) { | 69 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, |
48 | continue; | 70 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, |
49 | } | 71 | { .name = "ti925t", .initfn = ti925t_initfn }, |
50 | if (!rom->mr) { | ||
51 | - if ((addr > rom->addr) && (as == rom->as)) { | ||
52 | + if (roms_overlap(last_rom, rom)) { | ||
53 | fprintf(stderr, "rom: requested regions overlap " | ||
54 | "(rom %s. free=0x" TARGET_FMT_plx | ||
55 | ", addr=0x" TARGET_FMT_plx ")\n", | ||
56 | - rom->name, addr, rom->addr); | ||
57 | + rom->name, last_rom->addr + last_rom->romsize, | ||
58 | + rom->addr); | ||
59 | return -1; | ||
60 | } | ||
61 | - addr = rom->addr; | ||
62 | - addr += rom->romsize; | ||
63 | - as = rom->as; | ||
64 | + last_rom = rom; | ||
65 | } | ||
66 | section = memory_region_find(rom->mr ? rom->mr : get_system_memory(), | ||
67 | rom->addr, 1); | ||
68 | -- | 72 | -- |
69 | 2.20.1 | 73 | 2.20.1 |
70 | 74 | ||
71 | 75 | diff view generated by jsdifflib |
1 | Currently the load_elf code assembles the ROM blob name into a | 1 | Support for running KVM on 32-bit Arm hosts was removed in commit |
---|---|---|---|
2 | local 128 byte fixed-size array. Use g_strdup_printf() instead so | 2 | 82bf7ae84ce739e. You can still run a 32-bit guest on a 64-bit Arm |
3 | that we don't truncate the pathname if it happens to be long. | 3 | host CPU, but because Arm KVM requires the host and guest CPU types |
4 | (This matters mostly for monitor 'info roms' output and for the | 4 | to match, it is not possible to run a guest that requires a Cortex-A9 |
5 | error messages if ROM blobs overlap.) | 5 | or Cortex-A15 CPU there. That means that the code in the |
6 | highbank/midway board models to support KVM is no longer used, and we | ||
7 | can delete it. | ||
6 | 8 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201129203923.10622-4-peter.maydell@linaro.org | 11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
12 | Message-id: 20201215144215.28482-1-peter.maydell@linaro.org | ||
10 | --- | 13 | --- |
11 | include/hw/elf_ops.h | 4 ++-- | 14 | hw/arm/highbank.c | 14 ++++---------- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 15 | 1 file changed, 4 insertions(+), 10 deletions(-) |
13 | 16 | ||
14 | diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h | 17 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/elf_ops.h | 19 | --- a/hw/arm/highbank.c |
17 | +++ b/include/hw/elf_ops.h | 20 | +++ b/hw/arm/highbank.c |
18 | @@ -XXX,XX +XXX,XX @@ static int glue(load_elf, SZ)(const char *name, int fd, | 21 | @@ -XXX,XX +XXX,XX @@ |
19 | uint64_t addr, low = (uint64_t)-1, high = 0; | 22 | #include "hw/arm/boot.h" |
20 | GMappedFile *mapped_file = NULL; | 23 | #include "hw/loader.h" |
21 | uint8_t *data = NULL; | 24 | #include "net/net.h" |
22 | - char label[128]; | 25 | -#include "sysemu/kvm.h" |
23 | int ret = ELF_LOAD_FAILED; | 26 | #include "sysemu/runstate.h" |
24 | 27 | #include "sysemu/sysemu.h" | |
25 | if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) | 28 | #include "hw/boards.h" |
26 | @@ -XXX,XX +XXX,XX @@ static int glue(load_elf, SZ)(const char *name, int fd, | 29 | @@ -XXX,XX +XXX,XX @@ |
27 | */ | 30 | #include "hw/cpu/a15mpcore.h" |
28 | if (mem_size != 0) { | 31 | #include "qemu/log.h" |
29 | if (load_rom) { | 32 | #include "qom/object.h" |
30 | - snprintf(label, sizeof(label), "phdr #%d: %s", i, name); | 33 | +#include "cpu.h" |
31 | + g_autofree char *label = | 34 | |
32 | + g_strdup_printf("phdr #%d: %s", i, name); | 35 | #define SMP_BOOT_ADDR 0x100 |
33 | 36 | #define SMP_BOOT_REG 0x40 | |
34 | /* | 37 | @@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) |
35 | * rom_add_elf_program() takes its own reference to | 38 | highbank_binfo.loader_start = 0; |
39 | highbank_binfo.write_secondary_boot = hb_write_secondary; | ||
40 | highbank_binfo.secondary_cpu_reset_hook = hb_reset_secondary; | ||
41 | - if (!kvm_enabled()) { | ||
42 | - highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; | ||
43 | - highbank_binfo.write_board_setup = hb_write_board_setup; | ||
44 | - highbank_binfo.secure_board_setup = true; | ||
45 | - } else { | ||
46 | - warn_report("cannot load built-in Monitor support " | ||
47 | - "if KVM is enabled. Some guests (such as Linux) " | ||
48 | - "may not boot."); | ||
49 | - } | ||
50 | + highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR; | ||
51 | + highbank_binfo.write_board_setup = hb_write_board_setup; | ||
52 | + highbank_binfo.secure_board_setup = true; | ||
53 | |||
54 | arm_load_kernel(ARM_CPU(first_cpu), machine, &highbank_binfo); | ||
55 | } | ||
36 | -- | 56 | -- |
37 | 2.20.1 | 57 | 2.20.1 |
38 | 58 | ||
39 | 59 | diff view generated by jsdifflib |
1 | In nios2_cpu_set_irq(), use deposit32() rather than raw shift-and-mask | 1 | Currently timer_free() is a simple wrapper for g_free(). This means |
---|---|---|---|
2 | operations to set the appropriate bit in the ipending register. | 2 | that the timer being freed must not be currently active, as otherwise |
3 | QEMU might crash later when the active list is processed and still | ||
4 | has a pointer to freed memory on it. As a result almost all calls to | ||
5 | timer_free() are preceded by a timer_del() call, as can be seen in | ||
6 | the output of | ||
7 | git grep -B1 '\<timer_free\>' | ||
8 | |||
9 | This is unfortunate API design as it makes it easy to accidentally | ||
10 | misuse (by forgetting the timer_del()), and the correct use is | ||
11 | annoyingly verbose. | ||
12 | |||
13 | Make timer_free() imply a timer_del(). | ||
3 | 14 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
6 | Message-id: 20201129174022.26530-4-peter.maydell@linaro.org | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-id: 20201215154107.3255-2-peter.maydell@linaro.org | ||
7 | --- | 19 | --- |
8 | target/nios2/cpu.c | 3 +-- | 20 | include/qemu/timer.h | 24 +++++++++++++----------- |
9 | 1 file changed, 1 insertion(+), 2 deletions(-) | 21 | 1 file changed, 13 insertions(+), 11 deletions(-) |
10 | 22 | ||
11 | diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c | 23 | diff --git a/include/qemu/timer.h b/include/qemu/timer.h |
12 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/nios2/cpu.c | 25 | --- a/include/qemu/timer.h |
14 | +++ b/target/nios2/cpu.c | 26 | +++ b/include/qemu/timer.h |
15 | @@ -XXX,XX +XXX,XX @@ static void nios2_cpu_set_irq(void *opaque, int irq, int level) | 27 | @@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb, |
16 | CPUNios2State *env = &cpu->env; | 28 | */ |
17 | CPUState *cs = CPU(cpu); | 29 | void timer_deinit(QEMUTimer *ts); |
18 | 30 | ||
19 | - env->regs[CR_IPENDING] &= ~(1 << irq); | 31 | -/** |
20 | - env->regs[CR_IPENDING] |= !!level << irq; | 32 | - * timer_free: |
21 | + env->regs[CR_IPENDING] = deposit32(env->regs[CR_IPENDING], irq, 1, !!level); | 33 | - * @ts: the timer |
22 | 34 | - * | |
23 | env->irq_pending = env->regs[CR_IPENDING] & env->regs[CR_IENABLE]; | 35 | - * Free a timer (it must not be on the active list) |
24 | 36 | - */ | |
37 | -static inline void timer_free(QEMUTimer *ts) | ||
38 | -{ | ||
39 | - g_free(ts); | ||
40 | -} | ||
41 | - | ||
42 | /** | ||
43 | * timer_del: | ||
44 | * @ts: the timer | ||
45 | @@ -XXX,XX +XXX,XX @@ static inline void timer_free(QEMUTimer *ts) | ||
46 | */ | ||
47 | void timer_del(QEMUTimer *ts); | ||
48 | |||
49 | +/** | ||
50 | + * timer_free: | ||
51 | + * @ts: the timer | ||
52 | + * | ||
53 | + * Free a timer. This will call timer_del() for you to remove | ||
54 | + * the timer from the active list if it was still active. | ||
55 | + */ | ||
56 | +static inline void timer_free(QEMUTimer *ts) | ||
57 | +{ | ||
58 | + timer_del(ts); | ||
59 | + g_free(ts); | ||
60 | +} | ||
61 | + | ||
62 | /** | ||
63 | * timer_mod_ns: | ||
64 | * @ts: the timer | ||
25 | -- | 65 | -- |
26 | 2.20.1 | 66 | 2.20.1 |
27 | 67 | ||
28 | 68 | diff view generated by jsdifflib |
1 | From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 1 | Now that timer_free() implicitly calls timer_del(), sequences |
---|---|---|---|
2 | timer_del(mytimer); | ||
3 | timer_free(mytimer); | ||
2 | 4 | ||
3 | This model is a top level integration wrapper for hcd-dwc3 and | 5 | can be simplified to just |
4 | versal-usb2-ctrl-regs modules, this is used by xilinx versal soc's and | 6 | timer_free(mytimer); |
5 | future xilinx usb subsystems would also be part of it. | ||
6 | 7 | ||
7 | Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 8 | Add a Coccinelle script to do this transformation. |
8 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 9 | |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 1607023357-5096-4-git-send-email-sai.pavan.boddu@xilinx.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20201215154107.3255-3-peter.maydell@linaro.org | ||
12 | --- | 15 | --- |
13 | include/hw/usb/xlnx-usb-subsystem.h | 45 ++++++++++++++ | 16 | scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++++++++++++++++ |
14 | hw/usb/xlnx-usb-subsystem.c | 94 +++++++++++++++++++++++++++++ | 17 | 1 file changed, 18 insertions(+) |
15 | hw/usb/Kconfig | 5 ++ | 18 | create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci |
16 | hw/usb/meson.build | 1 + | ||
17 | 4 files changed, 145 insertions(+) | ||
18 | create mode 100644 include/hw/usb/xlnx-usb-subsystem.h | ||
19 | create mode 100644 hw/usb/xlnx-usb-subsystem.c | ||
20 | 19 | ||
21 | diff --git a/include/hw/usb/xlnx-usb-subsystem.h b/include/hw/usb/xlnx-usb-subsystem.h | 20 | diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci |
22 | new file mode 100644 | 21 | new file mode 100644 |
23 | index XXXXXXX..XXXXXXX | 22 | index XXXXXXX..XXXXXXX |
24 | --- /dev/null | 23 | --- /dev/null |
25 | +++ b/include/hw/usb/xlnx-usb-subsystem.h | 24 | +++ b/scripts/coccinelle/timer-del-timer-free.cocci |
26 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ |
27 | +/* | 26 | +// Remove superfluous timer_del() calls |
28 | + * QEMU model of the Xilinx usb subsystem | 27 | +// |
29 | + * | 28 | +// Copyright Linaro Limited 2020 |
30 | + * Copyright (c) 2020 Xilinx Inc. Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 29 | +// This work is licensed under the terms of the GNU GPLv2 or later. |
31 | + * | 30 | +// |
32 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 31 | +// spatch --macro-file scripts/cocci-macro-file.h \ |
33 | + * of this software and associated documentation files (the "Software"), to deal | 32 | +// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \ |
34 | + * in the Software without restriction, including without limitation the rights | 33 | +// --in-place --dir . |
35 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 34 | +// |
36 | + * copies of the Software, and to permit persons to whom the Software is | 35 | +// The timer_free() function now implicitly calls timer_del() |
37 | + * furnished to do so, subject to the following conditions: | 36 | +// for you, so calls to timer_del() immediately before the |
38 | + * | 37 | +// timer_free() of the same timer can be deleted. |
39 | + * The above copyright notice and this permission notice shall be included in | ||
40 | + * all copies or substantial portions of the Software. | ||
41 | + * | ||
42 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
43 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
44 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
45 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
46 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
47 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
48 | + * THE SOFTWARE. | ||
49 | + */ | ||
50 | + | 38 | + |
51 | +#ifndef _XLNX_VERSAL_USB_SUBSYSTEM_H_ | 39 | +@@ |
52 | +#define _XLNX_VERSAL_USB_SUBSYSTEM_H_ | 40 | +expression T; |
53 | + | 41 | +@@ |
54 | +#include "hw/usb/xlnx-versal-usb2-ctrl-regs.h" | 42 | +-timer_del(T); |
55 | +#include "hw/usb/hcd-dwc3.h" | 43 | + timer_free(T); |
56 | + | ||
57 | +#define TYPE_XILINX_VERSAL_USB2 "xlnx.versal-usb2" | ||
58 | + | ||
59 | +#define VERSAL_USB2(obj) \ | ||
60 | + OBJECT_CHECK(VersalUsb2, (obj), TYPE_XILINX_VERSAL_USB2) | ||
61 | + | ||
62 | +typedef struct VersalUsb2 { | ||
63 | + SysBusDevice parent_obj; | ||
64 | + MemoryRegion dwc3_mr; | ||
65 | + MemoryRegion usb2Ctrl_mr; | ||
66 | + | ||
67 | + VersalUsb2CtrlRegs usb2Ctrl; | ||
68 | + USBDWC3 dwc3; | ||
69 | +} VersalUsb2; | ||
70 | + | ||
71 | +#endif | ||
72 | diff --git a/hw/usb/xlnx-usb-subsystem.c b/hw/usb/xlnx-usb-subsystem.c | ||
73 | new file mode 100644 | ||
74 | index XXXXXXX..XXXXXXX | ||
75 | --- /dev/null | ||
76 | +++ b/hw/usb/xlnx-usb-subsystem.c | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | +/* | ||
79 | + * QEMU model of the Xilinx usb subsystem | ||
80 | + * | ||
81 | + * Copyright (c) 2020 Xilinx Inc. Sai Pavan Boddu <sai.pava.boddu@xilinx.com> | ||
82 | + * | ||
83 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
84 | + * of this software and associated documentation files (the "Software"), to deal | ||
85 | + * in the Software without restriction, including without limitation the rights | ||
86 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
87 | + * copies of the Software, and to permit persons to whom the Software is | ||
88 | + * furnished to do so, subject to the following conditions: | ||
89 | + * | ||
90 | + * The above copyright notice and this permission notice shall be included in | ||
91 | + * all copies or substantial portions of the Software. | ||
92 | + * | ||
93 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
94 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
95 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
96 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
97 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
98 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
99 | + * THE SOFTWARE. | ||
100 | + */ | ||
101 | + | ||
102 | +#include "qemu/osdep.h" | ||
103 | +#include "hw/sysbus.h" | ||
104 | +#include "hw/irq.h" | ||
105 | +#include "hw/register.h" | ||
106 | +#include "qemu/bitops.h" | ||
107 | +#include "qemu/log.h" | ||
108 | +#include "qom/object.h" | ||
109 | +#include "qapi/error.h" | ||
110 | +#include "hw/qdev-properties.h" | ||
111 | +#include "hw/usb/xlnx-usb-subsystem.h" | ||
112 | + | ||
113 | +static void versal_usb2_realize(DeviceState *dev, Error **errp) | ||
114 | +{ | ||
115 | + VersalUsb2 *s = VERSAL_USB2(dev); | ||
116 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
117 | + Error *err = NULL; | ||
118 | + | ||
119 | + sysbus_realize(SYS_BUS_DEVICE(&s->dwc3), &err); | ||
120 | + if (err) { | ||
121 | + error_propagate(errp, err); | ||
122 | + return; | ||
123 | + } | ||
124 | + sysbus_realize(SYS_BUS_DEVICE(&s->usb2Ctrl), &err); | ||
125 | + if (err) { | ||
126 | + error_propagate(errp, err); | ||
127 | + return; | ||
128 | + } | ||
129 | + sysbus_init_mmio(sbd, &s->dwc3_mr); | ||
130 | + sysbus_init_mmio(sbd, &s->usb2Ctrl_mr); | ||
131 | + qdev_pass_gpios(DEVICE(&s->dwc3.sysbus_xhci), dev, SYSBUS_DEVICE_GPIO_IRQ); | ||
132 | +} | ||
133 | + | ||
134 | +static void versal_usb2_init(Object *obj) | ||
135 | +{ | ||
136 | + VersalUsb2 *s = VERSAL_USB2(obj); | ||
137 | + | ||
138 | + object_initialize_child(obj, "versal.dwc3", &s->dwc3, | ||
139 | + TYPE_USB_DWC3); | ||
140 | + object_initialize_child(obj, "versal.usb2-ctrl", &s->usb2Ctrl, | ||
141 | + TYPE_XILINX_VERSAL_USB2_CTRL_REGS); | ||
142 | + memory_region_init_alias(&s->dwc3_mr, obj, "versal.dwc3_alias", | ||
143 | + &s->dwc3.iomem, 0, DWC3_SIZE); | ||
144 | + memory_region_init_alias(&s->usb2Ctrl_mr, obj, "versal.usb2Ctrl_alias", | ||
145 | + &s->usb2Ctrl.iomem, 0, USB2_REGS_R_MAX * 4); | ||
146 | + qdev_alias_all_properties(DEVICE(&s->dwc3), obj); | ||
147 | + qdev_alias_all_properties(DEVICE(&s->dwc3.sysbus_xhci), obj); | ||
148 | + object_property_add_alias(obj, "dma", OBJECT(&s->dwc3.sysbus_xhci), "dma"); | ||
149 | +} | ||
150 | + | ||
151 | +static void versal_usb2_class_init(ObjectClass *klass, void *data) | ||
152 | +{ | ||
153 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
154 | + | ||
155 | + dc->realize = versal_usb2_realize; | ||
156 | +} | ||
157 | + | ||
158 | +static const TypeInfo versal_usb2_info = { | ||
159 | + .name = TYPE_XILINX_VERSAL_USB2, | ||
160 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
161 | + .instance_size = sizeof(VersalUsb2), | ||
162 | + .class_init = versal_usb2_class_init, | ||
163 | + .instance_init = versal_usb2_init, | ||
164 | +}; | ||
165 | + | ||
166 | +static void versal_usb_types(void) | ||
167 | +{ | ||
168 | + type_register_static(&versal_usb2_info); | ||
169 | +} | ||
170 | + | ||
171 | +type_init(versal_usb_types) | ||
172 | diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/hw/usb/Kconfig | ||
175 | +++ b/hw/usb/Kconfig | ||
176 | @@ -XXX,XX +XXX,XX @@ config USB_DWC3 | ||
177 | bool | ||
178 | select USB_XHCI_SYSBUS | ||
179 | select REGISTER | ||
180 | + | ||
181 | +config XLNX_USB_SUBSYS | ||
182 | + bool | ||
183 | + default y if XLNX_VERSAL | ||
184 | + select USB_DWC3 | ||
185 | diff --git a/hw/usb/meson.build b/hw/usb/meson.build | ||
186 | index XXXXXXX..XXXXXXX 100644 | ||
187 | --- a/hw/usb/meson.build | ||
188 | +++ b/hw/usb/meson.build | ||
189 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_TUSB6010', if_true: files('tusb6010.c')) | ||
190 | softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('chipidea.c')) | ||
191 | softmmu_ss.add(when: 'CONFIG_IMX_USBPHY', if_true: files('imx-usb-phy.c')) | ||
192 | specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-usb2-ctrl-regs.c')) | ||
193 | +specific_ss.add(when: 'CONFIG_XLNX_USB_SUBSYS', if_true: files('xlnx-usb-subsystem.c')) | ||
194 | |||
195 | # emulated usb devices | ||
196 | softmmu_ss.add(when: 'CONFIG_USB', if_true: files('dev-hub.c')) | ||
197 | -- | 44 | -- |
198 | 2.20.1 | 45 | 2.20.1 |
199 | 46 | ||
200 | 47 | diff view generated by jsdifflib |
1 | The Nios2 architecture supports two different interrupt controller | 1 | This commit is the result of running the timer-del-timer-free.cocci |
---|---|---|---|
2 | options: | 2 | script on the whole source tree. |
3 | 3 | ||
4 | * The IIC (Internal Interrupt Controller) is part of the CPU itself; | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | it has 32 IRQ input lines and no NMI support. Interrupt status is | 5 | Acked-by: Corey Minyard <cminyard@mvista.com> |
6 | queried and controlled via the CPU's ipending and istatus | 6 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> |
7 | registers. | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20201215154107.3255-4-peter.maydell@linaro.org | ||
10 | --- | ||
11 | block/iscsi.c | 2 -- | ||
12 | block/nbd.c | 1 - | ||
13 | block/qcow2.c | 1 - | ||
14 | hw/block/nvme.c | 2 -- | ||
15 | hw/char/serial.c | 2 -- | ||
16 | hw/char/virtio-serial-bus.c | 2 -- | ||
17 | hw/ide/core.c | 1 - | ||
18 | hw/input/hid.c | 1 - | ||
19 | hw/intc/apic.c | 1 - | ||
20 | hw/intc/ioapic.c | 1 - | ||
21 | hw/ipmi/ipmi_bmc_extern.c | 1 - | ||
22 | hw/net/e1000.c | 3 --- | ||
23 | hw/net/e1000e_core.c | 8 -------- | ||
24 | hw/net/pcnet-pci.c | 1 - | ||
25 | hw/net/rtl8139.c | 1 - | ||
26 | hw/net/spapr_llan.c | 1 - | ||
27 | hw/net/virtio-net.c | 2 -- | ||
28 | hw/s390x/s390-pci-inst.c | 1 - | ||
29 | hw/sd/sd.c | 1 - | ||
30 | hw/sd/sdhci.c | 2 -- | ||
31 | hw/usb/dev-hub.c | 1 - | ||
32 | hw/usb/hcd-ehci.c | 1 - | ||
33 | hw/usb/hcd-ohci-pci.c | 1 - | ||
34 | hw/usb/hcd-uhci.c | 1 - | ||
35 | hw/usb/hcd-xhci.c | 1 - | ||
36 | hw/usb/redirect.c | 1 - | ||
37 | hw/vfio/display.c | 1 - | ||
38 | hw/virtio/vhost-vsock-common.c | 1 - | ||
39 | hw/virtio/virtio-balloon.c | 1 - | ||
40 | hw/virtio/virtio-rng.c | 1 - | ||
41 | hw/watchdog/wdt_diag288.c | 1 - | ||
42 | hw/watchdog/wdt_i6300esb.c | 1 - | ||
43 | migration/colo.c | 1 - | ||
44 | monitor/hmp-cmds.c | 1 - | ||
45 | net/announce.c | 1 - | ||
46 | net/colo-compare.c | 1 - | ||
47 | net/slirp.c | 1 - | ||
48 | replay/replay-debugging.c | 1 - | ||
49 | target/s390x/cpu.c | 2 -- | ||
50 | ui/console.c | 1 - | ||
51 | ui/spice-core.c | 1 - | ||
52 | util/throttle.c | 1 - | ||
53 | 42 files changed, 58 deletions(-) | ||
8 | 54 | ||
9 | * The EIC (External Interrupt Controller) interface allows the CPU | 55 | diff --git a/block/iscsi.c b/block/iscsi.c |
10 | to connect to an external interrupt controller. The interface | 56 | index XXXXXXX..XXXXXXX 100644 |
11 | allows the interrupt controller to present a packet of information | 57 | --- a/block/iscsi.c |
12 | containing: | 58 | +++ b/block/iscsi.c |
13 | - handler address | 59 | @@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs) |
14 | - interrupt level | 60 | iscsilun->events = 0; |
15 | - register set | 61 | |
16 | - NMI mode | 62 | if (iscsilun->nop_timer) { |
17 | 63 | - timer_del(iscsilun->nop_timer); | |
18 | QEMU does not model an EIC currently. We do model the IIC, but its | 64 | timer_free(iscsilun->nop_timer); |
19 | implementation is split across code in hw/nios2/cpu_pic.c and | 65 | iscsilun->nop_timer = NULL; |
20 | hw/intc/nios2_iic.c. The code in those two files has no state of its | 66 | } |
21 | own -- the IIC state is in the Nios2CPU state struct. | 67 | if (iscsilun->event_timer) { |
22 | 68 | - timer_del(iscsilun->event_timer); | |
23 | Because CPU objects now inherit (indirectly) from TYPE_DEVICE, they | 69 | timer_free(iscsilun->event_timer); |
24 | can have GPIO input lines themselves, so we can implement the IIC | 70 | iscsilun->event_timer = NULL; |
25 | directly in the CPU object the same way that real hardware does. | 71 | } |
26 | 72 | diff --git a/block/nbd.c b/block/nbd.c | |
27 | Create named "IRQ" GPIO inputs to the Nios2 CPU object, and make the | 73 | index XXXXXXX..XXXXXXX 100644 |
28 | only user of the IIC wire up directly to those instead. | 74 | --- a/block/nbd.c |
29 | 75 | +++ b/block/nbd.c | |
30 | Note that the old code had an "NMI" concept which was entirely unused | 76 | @@ -XXX,XX +XXX,XX @@ static void nbd_recv_coroutines_wake_all(BDRVNBDState *s) |
31 | and also as far as I can see not architecturally correct, since only | 77 | static void reconnect_delay_timer_del(BDRVNBDState *s) |
32 | the EIC has a concept of an NMI. | 78 | { |
33 | 79 | if (s->reconnect_delay_timer) { | |
34 | This fixes a Coverity-reported trivial memory leak of the IRQ array | 80 | - timer_del(s->reconnect_delay_timer); |
35 | allocated in nios2_cpu_pic_init(). | 81 | timer_free(s->reconnect_delay_timer); |
36 | 82 | s->reconnect_delay_timer = NULL; | |
37 | Fixes: Coverity CID 1421916 | 83 | } |
38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 84 | diff --git a/block/qcow2.c b/block/qcow2.c |
39 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 85 | index XXXXXXX..XXXXXXX 100644 |
40 | Message-id: 20201129174022.26530-2-peter.maydell@linaro.org | 86 | --- a/block/qcow2.c |
41 | Reviewed-by: Wentong Wu <wentong.wu@intel.com> | 87 | +++ b/block/qcow2.c |
42 | Tested-by: Wentong Wu <wentong.wu@intel.com> | 88 | @@ -XXX,XX +XXX,XX @@ static void cache_clean_timer_del(BlockDriverState *bs) |
43 | --- | 89 | { |
44 | target/nios2/cpu.h | 1 - | 90 | BDRVQcow2State *s = bs->opaque; |
45 | hw/intc/nios2_iic.c | 95 --------------------------------------- | 91 | if (s->cache_clean_timer) { |
46 | hw/nios2/10m50_devboard.c | 13 +----- | 92 | - timer_del(s->cache_clean_timer); |
47 | hw/nios2/cpu_pic.c | 31 ------------- | 93 | timer_free(s->cache_clean_timer); |
48 | target/nios2/cpu.c | 30 +++++++++++++ | 94 | s->cache_clean_timer = NULL; |
49 | MAINTAINERS | 1 - | 95 | } |
50 | hw/intc/meson.build | 1 - | 96 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c |
51 | 7 files changed, 32 insertions(+), 140 deletions(-) | 97 | index XXXXXXX..XXXXXXX 100644 |
52 | delete mode 100644 hw/intc/nios2_iic.c | 98 | --- a/hw/block/nvme.c |
53 | 99 | +++ b/hw/block/nvme.c | |
54 | diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h | 100 | @@ -XXX,XX +XXX,XX @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req) |
55 | index XXXXXXX..XXXXXXX 100644 | 101 | static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n) |
56 | --- a/target/nios2/cpu.h | 102 | { |
57 | +++ b/target/nios2/cpu.h | 103 | n->sq[sq->sqid] = NULL; |
58 | @@ -XXX,XX +XXX,XX @@ void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, | 104 | - timer_del(sq->timer); |
59 | MMUAccessType access_type, | 105 | timer_free(sq->timer); |
60 | int mmu_idx, uintptr_t retaddr); | 106 | g_free(sq->io_req); |
61 | 107 | if (sq->sqid) { | |
62 | -qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu); | 108 | @@ -XXX,XX +XXX,XX @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req) |
63 | void nios2_check_interrupts(CPUNios2State *env); | 109 | static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n) |
64 | 110 | { | |
65 | void do_nios2_semihosting(CPUNios2State *env); | 111 | n->cq[cq->cqid] = NULL; |
66 | diff --git a/hw/intc/nios2_iic.c b/hw/intc/nios2_iic.c | 112 | - timer_del(cq->timer); |
67 | deleted file mode 100644 | 113 | timer_free(cq->timer); |
68 | index XXXXXXX..XXXXXXX | 114 | msix_vector_unuse(&n->parent_obj, cq->vector); |
69 | --- a/hw/intc/nios2_iic.c | 115 | if (cq->cqid) { |
70 | +++ /dev/null | 116 | diff --git a/hw/char/serial.c b/hw/char/serial.c |
71 | @@ -XXX,XX +XXX,XX @@ | 117 | index XXXXXXX..XXXXXXX 100644 |
72 | -/* | 118 | --- a/hw/char/serial.c |
73 | - * QEMU Altera Internal Interrupt Controller. | 119 | +++ b/hw/char/serial.c |
74 | - * | 120 | @@ -XXX,XX +XXX,XX @@ static void serial_unrealize(DeviceState *dev) |
75 | - * Copyright (c) 2012 Chris Wulff <crwulff@gmail.com> | 121 | |
76 | - * | 122 | qemu_chr_fe_deinit(&s->chr, false); |
77 | - * This library is free software; you can redistribute it and/or | 123 | |
78 | - * modify it under the terms of the GNU Lesser General Public | 124 | - timer_del(s->modem_status_poll); |
79 | - * License as published by the Free Software Foundation; either | 125 | timer_free(s->modem_status_poll); |
80 | - * version 2.1 of the License, or (at your option) any later version. | 126 | |
81 | - * | 127 | - timer_del(s->fifo_timeout_timer); |
82 | - * This library is distributed in the hope that it will be useful, | 128 | timer_free(s->fifo_timeout_timer); |
83 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | 129 | |
84 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 130 | fifo8_destroy(&s->recv_fifo); |
85 | - * Lesser General Public License for more details. | 131 | diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c |
86 | - * | 132 | index XXXXXXX..XXXXXXX 100644 |
87 | - * You should have received a copy of the GNU Lesser General Public | 133 | --- a/hw/char/virtio-serial-bus.c |
88 | - * License along with this library; if not, see | 134 | +++ b/hw/char/virtio-serial-bus.c |
89 | - * <http://www.gnu.org/licenses/lgpl-2.1.html> | 135 | @@ -XXX,XX +XXX,XX @@ static void virtio_serial_post_load_timer_cb(void *opaque) |
90 | - */ | 136 | } |
91 | - | 137 | } |
92 | -#include "qemu/osdep.h" | 138 | g_free(s->post_load->connected); |
93 | -#include "qemu/module.h" | 139 | - timer_del(s->post_load->timer); |
94 | -#include "qapi/error.h" | 140 | timer_free(s->post_load->timer); |
95 | - | 141 | g_free(s->post_load); |
96 | -#include "hw/irq.h" | 142 | s->post_load = NULL; |
97 | -#include "hw/sysbus.h" | 143 | @@ -XXX,XX +XXX,XX @@ static void virtio_serial_device_unrealize(DeviceState *dev) |
98 | -#include "cpu.h" | 144 | g_free(vser->ports_map); |
99 | -#include "qom/object.h" | 145 | if (vser->post_load) { |
100 | - | 146 | g_free(vser->post_load->connected); |
101 | -#define TYPE_ALTERA_IIC "altera,iic" | 147 | - timer_del(vser->post_load->timer); |
102 | -OBJECT_DECLARE_SIMPLE_TYPE(AlteraIIC, ALTERA_IIC) | 148 | timer_free(vser->post_load->timer); |
103 | - | 149 | g_free(vser->post_load); |
104 | -struct AlteraIIC { | 150 | } |
105 | - SysBusDevice parent_obj; | 151 | diff --git a/hw/ide/core.c b/hw/ide/core.c |
106 | - void *cpu; | 152 | index XXXXXXX..XXXXXXX 100644 |
107 | - qemu_irq parent_irq; | 153 | --- a/hw/ide/core.c |
108 | -}; | 154 | +++ b/hw/ide/core.c |
109 | - | 155 | @@ -XXX,XX +XXX,XX @@ void ide_init2(IDEBus *bus, qemu_irq irq) |
110 | -static void update_irq(AlteraIIC *pv) | 156 | |
111 | -{ | 157 | void ide_exit(IDEState *s) |
112 | - CPUNios2State *env = &((Nios2CPU *)(pv->cpu))->env; | 158 | { |
113 | - | 159 | - timer_del(s->sector_write_timer); |
114 | - qemu_set_irq(pv->parent_irq, | 160 | timer_free(s->sector_write_timer); |
115 | - env->regs[CR_IPENDING] & env->regs[CR_IENABLE]); | 161 | qemu_vfree(s->smart_selftest_data); |
116 | -} | 162 | qemu_vfree(s->io_buffer); |
117 | - | 163 | diff --git a/hw/input/hid.c b/hw/input/hid.c |
118 | -static void irq_handler(void *opaque, int irq, int level) | 164 | index XXXXXXX..XXXXXXX 100644 |
119 | -{ | 165 | --- a/hw/input/hid.c |
120 | - AlteraIIC *pv = opaque; | 166 | +++ b/hw/input/hid.c |
121 | - CPUNios2State *env = &((Nios2CPU *)(pv->cpu))->env; | 167 | @@ -XXX,XX +XXX,XX @@ static void hid_idle_timer(void *opaque) |
122 | - | 168 | static void hid_del_idle_timer(HIDState *hs) |
123 | - env->regs[CR_IPENDING] &= ~(1 << irq); | 169 | { |
124 | - env->regs[CR_IPENDING] |= !!level << irq; | 170 | if (hs->idle_timer) { |
125 | - | 171 | - timer_del(hs->idle_timer); |
126 | - update_irq(pv); | 172 | timer_free(hs->idle_timer); |
127 | -} | 173 | hs->idle_timer = NULL; |
128 | - | 174 | } |
129 | -static void altera_iic_init(Object *obj) | 175 | diff --git a/hw/intc/apic.c b/hw/intc/apic.c |
130 | -{ | 176 | index XXXXXXX..XXXXXXX 100644 |
131 | - AlteraIIC *pv = ALTERA_IIC(obj); | 177 | --- a/hw/intc/apic.c |
132 | - | 178 | +++ b/hw/intc/apic.c |
133 | - qdev_init_gpio_in(DEVICE(pv), irq_handler, 32); | 179 | @@ -XXX,XX +XXX,XX @@ static void apic_unrealize(DeviceState *dev) |
134 | - sysbus_init_irq(SYS_BUS_DEVICE(obj), &pv->parent_irq); | 180 | { |
135 | -} | 181 | APICCommonState *s = APIC(dev); |
136 | - | 182 | |
137 | -static void altera_iic_realize(DeviceState *dev, Error **errp) | 183 | - timer_del(s->timer); |
138 | -{ | 184 | timer_free(s->timer); |
139 | - struct AlteraIIC *pv = ALTERA_IIC(dev); | 185 | local_apics[s->id] = NULL; |
140 | - | 186 | } |
141 | - pv->cpu = object_property_get_link(OBJECT(dev), "cpu", &error_abort); | 187 | diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c |
142 | -} | 188 | index XXXXXXX..XXXXXXX 100644 |
143 | - | 189 | --- a/hw/intc/ioapic.c |
144 | -static void altera_iic_class_init(ObjectClass *klass, void *data) | 190 | +++ b/hw/intc/ioapic.c |
145 | -{ | 191 | @@ -XXX,XX +XXX,XX @@ static void ioapic_unrealize(DeviceState *dev) |
146 | - DeviceClass *dc = DEVICE_CLASS(klass); | 192 | { |
147 | - | 193 | IOAPICCommonState *s = IOAPIC_COMMON(dev); |
148 | - /* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */ | 194 | |
149 | - dc->user_creatable = false; | 195 | - timer_del(s->delayed_ioapic_service_timer); |
150 | - dc->realize = altera_iic_realize; | 196 | timer_free(s->delayed_ioapic_service_timer); |
151 | -} | 197 | } |
152 | - | 198 | |
153 | -static TypeInfo altera_iic_info = { | 199 | diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c |
154 | - .name = TYPE_ALTERA_IIC, | 200 | index XXXXXXX..XXXXXXX 100644 |
155 | - .parent = TYPE_SYS_BUS_DEVICE, | 201 | --- a/hw/ipmi/ipmi_bmc_extern.c |
156 | - .instance_size = sizeof(AlteraIIC), | 202 | +++ b/hw/ipmi/ipmi_bmc_extern.c |
157 | - .instance_init = altera_iic_init, | 203 | @@ -XXX,XX +XXX,XX @@ static void ipmi_bmc_extern_finalize(Object *obj) |
158 | - .class_init = altera_iic_class_init, | 204 | { |
159 | -}; | 205 | IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj); |
160 | - | 206 | |
161 | -static void altera_iic_register(void) | 207 | - timer_del(ibe->extern_timer); |
162 | -{ | 208 | timer_free(ibe->extern_timer); |
163 | - type_register_static(&altera_iic_info); | 209 | } |
164 | -} | 210 | |
165 | - | 211 | diff --git a/hw/net/e1000.c b/hw/net/e1000.c |
166 | -type_init(altera_iic_register) | 212 | index XXXXXXX..XXXXXXX 100644 |
167 | diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c | 213 | --- a/hw/net/e1000.c |
168 | index XXXXXXX..XXXXXXX 100644 | 214 | +++ b/hw/net/e1000.c |
169 | --- a/hw/nios2/10m50_devboard.c | 215 | @@ -XXX,XX +XXX,XX @@ pci_e1000_uninit(PCIDevice *dev) |
170 | +++ b/hw/nios2/10m50_devboard.c | 216 | { |
171 | @@ -XXX,XX +XXX,XX @@ static void nios2_10m50_ghrd_init(MachineState *machine) | 217 | E1000State *d = E1000(dev); |
172 | ram_addr_t tcm_size = 0x1000; /* 1 kiB, but QEMU limit is 4 kiB */ | 218 | |
173 | ram_addr_t ram_base = 0x08000000; | 219 | - timer_del(d->autoneg_timer); |
174 | ram_addr_t ram_size = 0x08000000; | 220 | timer_free(d->autoneg_timer); |
175 | - qemu_irq *cpu_irq, irq[32]; | 221 | - timer_del(d->mit_timer); |
176 | + qemu_irq irq[32]; | 222 | timer_free(d->mit_timer); |
223 | - timer_del(d->flush_queue_timer); | ||
224 | timer_free(d->flush_queue_timer); | ||
225 | qemu_del_nic(d->nic); | ||
226 | } | ||
227 | diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c | ||
228 | index XXXXXXX..XXXXXXX 100644 | ||
229 | --- a/hw/net/e1000e_core.c | ||
230 | +++ b/hw/net/e1000e_core.c | ||
231 | @@ -XXX,XX +XXX,XX @@ e1000e_intrmgr_pci_unint(E1000ECore *core) | ||
232 | { | ||
177 | int i; | 233 | int i; |
178 | 234 | ||
179 | /* Physical TCM (tb_ram_1k) with alias at 0xc0000000 */ | 235 | - timer_del(core->radv.timer); |
180 | @@ -XXX,XX +XXX,XX @@ static void nios2_10m50_ghrd_init(MachineState *machine) | 236 | timer_free(core->radv.timer); |
181 | 237 | - timer_del(core->rdtr.timer); | |
182 | /* Create CPU -- FIXME */ | 238 | timer_free(core->rdtr.timer); |
183 | cpu = NIOS2_CPU(cpu_create(TYPE_NIOS2_CPU)); | 239 | - timer_del(core->raid.timer); |
184 | - | 240 | timer_free(core->raid.timer); |
185 | - /* Register: CPU interrupt controller (PIC) */ | 241 | |
186 | - cpu_irq = nios2_cpu_pic_init(cpu); | 242 | - timer_del(core->tadv.timer); |
187 | - | 243 | timer_free(core->tadv.timer); |
188 | - /* Register: Internal Interrupt Controller (IIC) */ | 244 | - timer_del(core->tidv.timer); |
189 | - dev = qdev_new("altera,iic"); | 245 | timer_free(core->tidv.timer); |
190 | - object_property_add_const_link(OBJECT(dev), "cpu", OBJECT(cpu)); | 246 | |
191 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | 247 | - timer_del(core->itr.timer); |
192 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, cpu_irq[0]); | 248 | timer_free(core->itr.timer); |
193 | for (i = 0; i < 32; i++) { | 249 | |
194 | - irq[i] = qdev_get_gpio_in(dev, i); | 250 | for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) { |
195 | + irq[i] = qdev_get_gpio_in_named(DEVICE(cpu), "IRQ", i); | 251 | - timer_del(core->eitr[i].timer); |
196 | } | 252 | timer_free(core->eitr[i].timer); |
197 | 253 | } | |
198 | /* Register: Altera 16550 UART */ | 254 | } |
199 | diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c | 255 | @@ -XXX,XX +XXX,XX @@ e1000e_core_pci_uninit(E1000ECore *core) |
200 | index XXXXXXX..XXXXXXX 100644 | 256 | { |
201 | --- a/hw/nios2/cpu_pic.c | 257 | int i; |
202 | +++ b/hw/nios2/cpu_pic.c | 258 | |
203 | @@ -XXX,XX +XXX,XX @@ | 259 | - timer_del(core->autoneg_timer); |
204 | 260 | timer_free(core->autoneg_timer); | |
205 | #include "boot.h" | 261 | |
206 | 262 | e1000e_intrmgr_pci_unint(core); | |
207 | -static void nios2_pic_cpu_handler(void *opaque, int irq, int level) | 263 | diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c |
208 | -{ | 264 | index XXXXXXX..XXXXXXX 100644 |
209 | - Nios2CPU *cpu = opaque; | 265 | --- a/hw/net/pcnet-pci.c |
210 | - CPUNios2State *env = &cpu->env; | 266 | +++ b/hw/net/pcnet-pci.c |
211 | - CPUState *cs = CPU(cpu); | 267 | @@ -XXX,XX +XXX,XX @@ static void pci_pcnet_uninit(PCIDevice *dev) |
212 | - int type = irq ? CPU_INTERRUPT_NMI : CPU_INTERRUPT_HARD; | 268 | PCIPCNetState *d = PCI_PCNET(dev); |
213 | - | 269 | |
214 | - if (type == CPU_INTERRUPT_HARD) { | 270 | qemu_free_irq(d->state.irq); |
215 | - env->irq_pending = level; | 271 | - timer_del(d->state.poll_timer); |
216 | - | 272 | timer_free(d->state.poll_timer); |
217 | - if (level && (env->regs[CR_STATUS] & CR_STATUS_PIE)) { | 273 | qemu_del_nic(d->state.nic); |
218 | - env->irq_pending = 0; | 274 | } |
219 | - cpu_interrupt(cs, type); | 275 | diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c |
220 | - } else if (!level) { | 276 | index XXXXXXX..XXXXXXX 100644 |
221 | - env->irq_pending = 0; | 277 | --- a/hw/net/rtl8139.c |
222 | - cpu_reset_interrupt(cs, type); | 278 | +++ b/hw/net/rtl8139.c |
223 | - } | 279 | @@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_uninit(PCIDevice *dev) |
224 | - } else { | 280 | |
225 | - if (level) { | 281 | g_free(s->cplus_txbuffer); |
226 | - cpu_interrupt(cs, type); | 282 | s->cplus_txbuffer = NULL; |
227 | - } else { | 283 | - timer_del(s->timer); |
228 | - cpu_reset_interrupt(cs, type); | 284 | timer_free(s->timer); |
229 | - } | 285 | qemu_del_nic(s->nic); |
230 | - } | 286 | } |
231 | -} | 287 | diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c |
232 | - | 288 | index XXXXXXX..XXXXXXX 100644 |
233 | void nios2_check_interrupts(CPUNios2State *env) | 289 | --- a/hw/net/spapr_llan.c |
234 | { | 290 | +++ b/hw/net/spapr_llan.c |
235 | if (env->irq_pending && | 291 | @@ -XXX,XX +XXX,XX @@ static void spapr_vlan_instance_finalize(Object *obj) |
236 | @@ -XXX,XX +XXX,XX @@ void nios2_check_interrupts(CPUNios2State *env) | 292 | } |
237 | cpu_interrupt(env_cpu(env), CPU_INTERRUPT_HARD); | 293 | |
238 | } | 294 | if (dev->rxp_timer) { |
239 | } | 295 | - timer_del(dev->rxp_timer); |
240 | - | 296 | timer_free(dev->rxp_timer); |
241 | -qemu_irq *nios2_cpu_pic_init(Nios2CPU *cpu) | 297 | } |
242 | -{ | 298 | } |
243 | - return qemu_allocate_irqs(nios2_pic_cpu_handler, cpu, 2); | 299 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c |
244 | -} | 300 | index XXXXXXX..XXXXXXX 100644 |
245 | diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c | 301 | --- a/hw/net/virtio-net.c |
246 | index XXXXXXX..XXXXXXX 100644 | 302 | +++ b/hw/net/virtio-net.c |
247 | --- a/target/nios2/cpu.c | 303 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_rsc_cleanup(VirtIONet *n) |
248 | +++ b/target/nios2/cpu.c | 304 | g_free(seg); |
249 | @@ -XXX,XX +XXX,XX @@ static void nios2_cpu_reset(DeviceState *dev) | 305 | } |
250 | #endif | 306 | |
251 | } | 307 | - timer_del(chain->drain_timer); |
252 | 308 | timer_free(chain->drain_timer); | |
253 | +#ifndef CONFIG_USER_ONLY | 309 | QTAILQ_REMOVE(&n->rsc_chains, chain, next); |
254 | +static void nios2_cpu_set_irq(void *opaque, int irq, int level) | 310 | g_free(chain); |
255 | +{ | 311 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_del_queue(VirtIONet *n, int index) |
256 | + Nios2CPU *cpu = opaque; | 312 | |
257 | + CPUNios2State *env = &cpu->env; | 313 | virtio_del_queue(vdev, index * 2); |
258 | + CPUState *cs = CPU(cpu); | 314 | if (q->tx_timer) { |
259 | + | 315 | - timer_del(q->tx_timer); |
260 | + env->regs[CR_IPENDING] &= ~(1 << irq); | 316 | timer_free(q->tx_timer); |
261 | + env->regs[CR_IPENDING] |= !!level << irq; | 317 | q->tx_timer = NULL; |
262 | + | 318 | } else { |
263 | + env->irq_pending = env->regs[CR_IPENDING] & env->regs[CR_IENABLE]; | 319 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c |
264 | + | 320 | index XXXXXXX..XXXXXXX 100644 |
265 | + if (env->irq_pending && (env->regs[CR_STATUS] & CR_STATUS_PIE)) { | 321 | --- a/hw/s390x/s390-pci-inst.c |
266 | + env->irq_pending = 0; | 322 | +++ b/hw/s390x/s390-pci-inst.c |
267 | + cpu_interrupt(cs, CPU_INTERRUPT_HARD); | 323 | @@ -XXX,XX +XXX,XX @@ void pci_dereg_ioat(S390PCIIOMMU *iommu) |
268 | + } else if (!env->irq_pending) { | 324 | void fmb_timer_free(S390PCIBusDevice *pbdev) |
269 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); | 325 | { |
270 | + } | 326 | if (pbdev->fmb_timer) { |
271 | +} | 327 | - timer_del(pbdev->fmb_timer); |
272 | +#endif | 328 | timer_free(pbdev->fmb_timer); |
273 | + | 329 | pbdev->fmb_timer = NULL; |
274 | static void nios2_cpu_initfn(Object *obj) | 330 | } |
275 | { | 331 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
276 | Nios2CPU *cpu = NIOS2_CPU(obj); | 332 | index XXXXXXX..XXXXXXX 100644 |
277 | @@ -XXX,XX +XXX,XX @@ static void nios2_cpu_initfn(Object *obj) | 333 | --- a/hw/sd/sd.c |
278 | 334 | +++ b/hw/sd/sd.c | |
335 | @@ -XXX,XX +XXX,XX @@ static void sd_instance_finalize(Object *obj) | ||
336 | { | ||
337 | SDState *sd = SD_CARD(obj); | ||
338 | |||
339 | - timer_del(sd->ocr_power_timer); | ||
340 | timer_free(sd->ocr_power_timer); | ||
341 | } | ||
342 | |||
343 | diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c | ||
344 | index XXXXXXX..XXXXXXX 100644 | ||
345 | --- a/hw/sd/sdhci.c | ||
346 | +++ b/hw/sd/sdhci.c | ||
347 | @@ -XXX,XX +XXX,XX @@ void sdhci_initfn(SDHCIState *s) | ||
348 | |||
349 | void sdhci_uninitfn(SDHCIState *s) | ||
350 | { | ||
351 | - timer_del(s->insert_timer); | ||
352 | timer_free(s->insert_timer); | ||
353 | - timer_del(s->transfer_timer); | ||
354 | timer_free(s->transfer_timer); | ||
355 | |||
356 | g_free(s->fifo_buffer); | ||
357 | diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c | ||
358 | index XXXXXXX..XXXXXXX 100644 | ||
359 | --- a/hw/usb/dev-hub.c | ||
360 | +++ b/hw/usb/dev-hub.c | ||
361 | @@ -XXX,XX +XXX,XX @@ static void usb_hub_unrealize(USBDevice *dev) | ||
362 | &s->ports[i].port); | ||
363 | } | ||
364 | |||
365 | - timer_del(s->port_timer); | ||
366 | timer_free(s->port_timer); | ||
367 | } | ||
368 | |||
369 | diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c | ||
370 | index XXXXXXX..XXXXXXX 100644 | ||
371 | --- a/hw/usb/hcd-ehci.c | ||
372 | +++ b/hw/usb/hcd-ehci.c | ||
373 | @@ -XXX,XX +XXX,XX @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev) | ||
374 | trace_usb_ehci_unrealize(); | ||
375 | |||
376 | if (s->frame_timer) { | ||
377 | - timer_del(s->frame_timer); | ||
378 | timer_free(s->frame_timer); | ||
379 | s->frame_timer = NULL; | ||
380 | } | ||
381 | diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c | ||
382 | index XXXXXXX..XXXXXXX 100644 | ||
383 | --- a/hw/usb/hcd-ohci-pci.c | ||
384 | +++ b/hw/usb/hcd-ohci-pci.c | ||
385 | @@ -XXX,XX +XXX,XX @@ static void usb_ohci_exit(PCIDevice *dev) | ||
386 | usb_bus_release(&s->bus); | ||
387 | } | ||
388 | |||
389 | - timer_del(s->eof_timer); | ||
390 | timer_free(s->eof_timer); | ||
391 | } | ||
392 | |||
393 | diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c | ||
394 | index XXXXXXX..XXXXXXX 100644 | ||
395 | --- a/hw/usb/hcd-uhci.c | ||
396 | +++ b/hw/usb/hcd-uhci.c | ||
397 | @@ -XXX,XX +XXX,XX @@ static void usb_uhci_exit(PCIDevice *dev) | ||
398 | trace_usb_uhci_exit(); | ||
399 | |||
400 | if (s->frame_timer) { | ||
401 | - timer_del(s->frame_timer); | ||
402 | timer_free(s->frame_timer); | ||
403 | s->frame_timer = NULL; | ||
404 | } | ||
405 | diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c | ||
406 | index XXXXXXX..XXXXXXX 100644 | ||
407 | --- a/hw/usb/hcd-xhci.c | ||
408 | +++ b/hw/usb/hcd-xhci.c | ||
409 | @@ -XXX,XX +XXX,XX @@ static void usb_xhci_unrealize(DeviceState *dev) | ||
410 | } | ||
411 | |||
412 | if (xhci->mfwrap_timer) { | ||
413 | - timer_del(xhci->mfwrap_timer); | ||
414 | timer_free(xhci->mfwrap_timer); | ||
415 | xhci->mfwrap_timer = NULL; | ||
416 | } | ||
417 | diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c | ||
418 | index XXXXXXX..XXXXXXX 100644 | ||
419 | --- a/hw/usb/redirect.c | ||
420 | +++ b/hw/usb/redirect.c | ||
421 | @@ -XXX,XX +XXX,XX @@ static void usbredir_unrealize(USBDevice *udev) | ||
422 | qemu_bh_delete(dev->chardev_close_bh); | ||
423 | qemu_bh_delete(dev->device_reject_bh); | ||
424 | |||
425 | - timer_del(dev->attach_timer); | ||
426 | timer_free(dev->attach_timer); | ||
427 | |||
428 | usbredir_cleanup_device_queues(dev); | ||
429 | diff --git a/hw/vfio/display.c b/hw/vfio/display.c | ||
430 | index XXXXXXX..XXXXXXX 100644 | ||
431 | --- a/hw/vfio/display.c | ||
432 | +++ b/hw/vfio/display.c | ||
433 | @@ -XXX,XX +XXX,XX @@ static void vfio_display_edid_exit(VFIODisplay *dpy) | ||
434 | |||
435 | g_free(dpy->edid_regs); | ||
436 | g_free(dpy->edid_blob); | ||
437 | - timer_del(dpy->edid_link_timer); | ||
438 | timer_free(dpy->edid_link_timer); | ||
439 | } | ||
440 | |||
441 | diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c | ||
442 | index XXXXXXX..XXXXXXX 100644 | ||
443 | --- a/hw/virtio/vhost-vsock-common.c | ||
444 | +++ b/hw/virtio/vhost-vsock-common.c | ||
445 | @@ -XXX,XX +XXX,XX @@ static void vhost_vsock_common_post_load_timer_cleanup(VHostVSockCommon *vvc) | ||
446 | return; | ||
447 | } | ||
448 | |||
449 | - timer_del(vvc->post_load_timer); | ||
450 | timer_free(vvc->post_load_timer); | ||
451 | vvc->post_load_timer = NULL; | ||
452 | } | ||
453 | diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c | ||
454 | index XXXXXXX..XXXXXXX 100644 | ||
455 | --- a/hw/virtio/virtio-balloon.c | ||
456 | +++ b/hw/virtio/virtio-balloon.c | ||
457 | @@ -XXX,XX +XXX,XX @@ static bool balloon_stats_enabled(const VirtIOBalloon *s) | ||
458 | static void balloon_stats_destroy_timer(VirtIOBalloon *s) | ||
459 | { | ||
460 | if (balloon_stats_enabled(s)) { | ||
461 | - timer_del(s->stats_timer); | ||
462 | timer_free(s->stats_timer); | ||
463 | s->stats_timer = NULL; | ||
464 | s->stats_poll_interval = 0; | ||
465 | diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c | ||
466 | index XXXXXXX..XXXXXXX 100644 | ||
467 | --- a/hw/virtio/virtio-rng.c | ||
468 | +++ b/hw/virtio/virtio-rng.c | ||
469 | @@ -XXX,XX +XXX,XX @@ static void virtio_rng_device_unrealize(DeviceState *dev) | ||
470 | VirtIORNG *vrng = VIRTIO_RNG(dev); | ||
471 | |||
472 | qemu_del_vm_change_state_handler(vrng->vmstate); | ||
473 | - timer_del(vrng->rate_limit_timer); | ||
474 | timer_free(vrng->rate_limit_timer); | ||
475 | virtio_del_queue(vdev, 0); | ||
476 | virtio_cleanup(vdev); | ||
477 | diff --git a/hw/watchdog/wdt_diag288.c b/hw/watchdog/wdt_diag288.c | ||
478 | index XXXXXXX..XXXXXXX 100644 | ||
479 | --- a/hw/watchdog/wdt_diag288.c | ||
480 | +++ b/hw/watchdog/wdt_diag288.c | ||
481 | @@ -XXX,XX +XXX,XX @@ static void wdt_diag288_unrealize(DeviceState *dev) | ||
482 | { | ||
483 | DIAG288State *diag288 = DIAG288(dev); | ||
484 | |||
485 | - timer_del(diag288->timer); | ||
486 | timer_free(diag288->timer); | ||
487 | } | ||
488 | |||
489 | diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c | ||
490 | index XXXXXXX..XXXXXXX 100644 | ||
491 | --- a/hw/watchdog/wdt_i6300esb.c | ||
492 | +++ b/hw/watchdog/wdt_i6300esb.c | ||
493 | @@ -XXX,XX +XXX,XX @@ static void i6300esb_exit(PCIDevice *dev) | ||
494 | { | ||
495 | I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev); | ||
496 | |||
497 | - timer_del(d->timer); | ||
498 | timer_free(d->timer); | ||
499 | } | ||
500 | |||
501 | diff --git a/migration/colo.c b/migration/colo.c | ||
502 | index XXXXXXX..XXXXXXX 100644 | ||
503 | --- a/migration/colo.c | ||
504 | +++ b/migration/colo.c | ||
505 | @@ -XXX,XX +XXX,XX @@ out: | ||
506 | * error. | ||
507 | */ | ||
508 | colo_compare_unregister_notifier(&packets_compare_notifier); | ||
509 | - timer_del(s->colo_delay_timer); | ||
510 | timer_free(s->colo_delay_timer); | ||
511 | qemu_event_destroy(&s->colo_checkpoint_event); | ||
512 | |||
513 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c | ||
514 | index XXXXXXX..XXXXXXX 100644 | ||
515 | --- a/monitor/hmp-cmds.c | ||
516 | +++ b/monitor/hmp-cmds.c | ||
517 | @@ -XXX,XX +XXX,XX @@ static void hmp_migrate_status_cb(void *opaque) | ||
518 | error_report("%s", info->error_desc); | ||
519 | } | ||
520 | monitor_resume(status->mon); | ||
521 | - timer_del(status->timer); | ||
522 | timer_free(status->timer); | ||
523 | g_free(status); | ||
524 | } | ||
525 | diff --git a/net/announce.c b/net/announce.c | ||
526 | index XXXXXXX..XXXXXXX 100644 | ||
527 | --- a/net/announce.c | ||
528 | +++ b/net/announce.c | ||
529 | @@ -XXX,XX +XXX,XX @@ void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named) | ||
530 | { | ||
531 | bool free_timer = false; | ||
532 | if (timer->tm) { | ||
533 | - timer_del(timer->tm); | ||
534 | timer_free(timer->tm); | ||
535 | timer->tm = NULL; | ||
536 | } | ||
537 | diff --git a/net/colo-compare.c b/net/colo-compare.c | ||
538 | index XXXXXXX..XXXXXXX 100644 | ||
539 | --- a/net/colo-compare.c | ||
540 | +++ b/net/colo-compare.c | ||
541 | @@ -XXX,XX +XXX,XX @@ static void colo_compare_timer_init(CompareState *s) | ||
542 | static void colo_compare_timer_del(CompareState *s) | ||
543 | { | ||
544 | if (s->packet_check_timer) { | ||
545 | - timer_del(s->packet_check_timer); | ||
546 | timer_free(s->packet_check_timer); | ||
547 | s->packet_check_timer = NULL; | ||
548 | } | ||
549 | diff --git a/net/slirp.c b/net/slirp.c | ||
550 | index XXXXXXX..XXXXXXX 100644 | ||
551 | --- a/net/slirp.c | ||
552 | +++ b/net/slirp.c | ||
553 | @@ -XXX,XX +XXX,XX @@ static void *net_slirp_timer_new(SlirpTimerCb cb, | ||
554 | |||
555 | static void net_slirp_timer_free(void *timer, void *opaque) | ||
556 | { | ||
557 | - timer_del(timer); | ||
558 | timer_free(timer); | ||
559 | } | ||
560 | |||
561 | diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c | ||
562 | index XXXXXXX..XXXXXXX 100644 | ||
563 | --- a/replay/replay-debugging.c | ||
564 | +++ b/replay/replay-debugging.c | ||
565 | @@ -XXX,XX +XXX,XX @@ static void replay_delete_break(void) | ||
566 | assert(replay_mutex_locked()); | ||
567 | |||
568 | if (replay_break_timer) { | ||
569 | - timer_del(replay_break_timer); | ||
570 | timer_free(replay_break_timer); | ||
571 | replay_break_timer = NULL; | ||
572 | } | ||
573 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
574 | index XXXXXXX..XXXXXXX 100644 | ||
575 | --- a/target/s390x/cpu.c | ||
576 | +++ b/target/s390x/cpu.c | ||
577 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_finalize(Object *obj) | ||
279 | #if !defined(CONFIG_USER_ONLY) | 578 | #if !defined(CONFIG_USER_ONLY) |
280 | mmu_init(&cpu->env); | 579 | S390CPU *cpu = S390_CPU(obj); |
281 | + | 580 | |
282 | + /* | 581 | - timer_del(cpu->env.tod_timer); |
283 | + * These interrupt lines model the IIC (internal interrupt | 582 | timer_free(cpu->env.tod_timer); |
284 | + * controller). QEMU does not currently support the EIC | 583 | - timer_del(cpu->env.cpu_timer); |
285 | + * (external interrupt controller) -- if we did it would be | 584 | timer_free(cpu->env.cpu_timer); |
286 | + * a separate device in hw/intc with a custom interface to | 585 | |
287 | + * the CPU, and boards using it would not wire up these IRQ lines. | 586 | qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu); |
288 | + */ | 587 | diff --git a/ui/console.c b/ui/console.c |
289 | + qdev_init_gpio_in_named(DEVICE(cpu), nios2_cpu_set_irq, "IRQ", 32); | 588 | index XXXXXXX..XXXXXXX 100644 |
290 | #endif | 589 | --- a/ui/console.c |
291 | } | 590 | +++ b/ui/console.c |
292 | 591 | @@ -XXX,XX +XXX,XX @@ static void gui_setup_refresh(DisplayState *ds) | |
293 | diff --git a/MAINTAINERS b/MAINTAINERS | 592 | timer_mod(ds->gui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME)); |
294 | index XXXXXXX..XXXXXXX 100644 | 593 | } |
295 | --- a/MAINTAINERS | 594 | if (!need_timer && ds->gui_timer != NULL) { |
296 | +++ b/MAINTAINERS | 595 | - timer_del(ds->gui_timer); |
297 | @@ -XXX,XX +XXX,XX @@ M: Marek Vasut <marex@denx.de> | 596 | timer_free(ds->gui_timer); |
298 | S: Maintained | 597 | ds->gui_timer = NULL; |
299 | F: target/nios2/ | 598 | } |
300 | F: hw/nios2/ | 599 | diff --git a/ui/spice-core.c b/ui/spice-core.c |
301 | -F: hw/intc/nios2_iic.c | 600 | index XXXXXXX..XXXXXXX 100644 |
302 | F: disas/nios2.c | 601 | --- a/ui/spice-core.c |
303 | F: default-configs/nios2-softmmu.mak | 602 | +++ b/ui/spice-core.c |
304 | 603 | @@ -XXX,XX +XXX,XX @@ static void timer_cancel(SpiceTimer *timer) | |
305 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build | 604 | |
306 | index XXXXXXX..XXXXXXX 100644 | 605 | static void timer_remove(SpiceTimer *timer) |
307 | --- a/hw/intc/meson.build | 606 | { |
308 | +++ b/hw/intc/meson.build | 607 | - timer_del(timer->timer); |
309 | @@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_plic.c')) | 608 | timer_free(timer->timer); |
310 | specific_ss.add(when: 'CONFIG_IOAPIC', if_true: files('ioapic.c')) | 609 | g_free(timer); |
311 | specific_ss.add(when: 'CONFIG_LOONGSON_LIOINTC', if_true: files('loongson_liointc.c')) | 610 | } |
312 | specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_gic.c')) | 611 | diff --git a/util/throttle.c b/util/throttle.c |
313 | -specific_ss.add(when: 'CONFIG_NIOS2', if_true: files('nios2_iic.c')) | 612 | index XXXXXXX..XXXXXXX 100644 |
314 | specific_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_intc.c')) | 613 | --- a/util/throttle.c |
315 | specific_ss.add(when: 'CONFIG_OMPIC', if_true: files('ompic.c')) | 614 | +++ b/util/throttle.c |
316 | specific_ss.add(when: 'CONFIG_OPENPIC_KVM', if_true: files('openpic_kvm.c')) | 615 | @@ -XXX,XX +XXX,XX @@ static void throttle_timer_destroy(QEMUTimer **timer) |
616 | { | ||
617 | assert(*timer != NULL); | ||
618 | |||
619 | - timer_del(*timer); | ||
620 | timer_free(*timer); | ||
621 | *timer = NULL; | ||
622 | } | ||
317 | -- | 623 | -- |
318 | 2.20.1 | 624 | 2.20.1 |
319 | 625 | ||
320 | 626 | diff view generated by jsdifflib |
1 | openrisc_sim_net_init() attempts to connect the IRQ line from the | 1 | The Arm CPU finalize function uses a sequence of timer_del(), timer_deinit(), |
---|---|---|---|
2 | ethernet device to both CPUs in an SMP configuration by simply caling | 2 | timer_free() to free the timer. The timer_deinit() step in this was always |
3 | sysbus_connect_irq() for it twice. This doesn't work, because the | 3 | unnecessary, and now the timer_del() is implied by timer_free(), so we can |
4 | second connection simply overrides the first. | 4 | collapse this down to simply calling timer_free(). |
5 | |||
6 | Fix this by creating a TYPE_SPLIT_IRQ to split the IRQ in the SMP | ||
7 | case. | ||
8 | 5 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Stafford Horne <shorne@gmail.com> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
11 | Message-id: 20201127225127.14770-2-peter.maydell@linaro.org | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201215154107.3255-5-peter.maydell@linaro.org | ||
12 | --- | 10 | --- |
13 | hw/openrisc/openrisc_sim.c | 13 +++++++++++-- | 11 | target/arm/cpu.c | 2 -- |
14 | hw/openrisc/Kconfig | 1 + | 12 | 1 file changed, 2 deletions(-) |
15 | 2 files changed, 12 insertions(+), 2 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/openrisc/openrisc_sim.c | 16 | --- a/target/arm/cpu.c |
20 | +++ b/hw/openrisc/openrisc_sim.c | 17 | +++ b/target/arm/cpu.c |
21 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj) |
22 | #include "hw/sysbus.h" | ||
23 | #include "sysemu/qtest.h" | ||
24 | #include "sysemu/reset.h" | ||
25 | +#include "hw/core/split-irq.h" | ||
26 | |||
27 | #define KERNEL_LOAD_ADDR 0x100 | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ static void openrisc_sim_net_init(hwaddr base, hwaddr descriptors, | ||
30 | |||
31 | s = SYS_BUS_DEVICE(dev); | ||
32 | sysbus_realize_and_unref(s, &error_fatal); | ||
33 | - for (i = 0; i < num_cpus; i++) { | ||
34 | - sysbus_connect_irq(s, 0, cpu_irqs[i][irq_pin]); | ||
35 | + if (num_cpus > 1) { | ||
36 | + DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ); | ||
37 | + qdev_prop_set_uint32(splitter, "num-lines", num_cpus); | ||
38 | + qdev_realize_and_unref(splitter, NULL, &error_fatal); | ||
39 | + for (i = 0; i < num_cpus; i++) { | ||
40 | + qdev_connect_gpio_out(splitter, i, cpu_irqs[i][irq_pin]); | ||
41 | + } | ||
42 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in(splitter, 0)); | ||
43 | + } else { | ||
44 | + sysbus_connect_irq(s, 0, cpu_irqs[0][irq_pin]); | ||
45 | } | 19 | } |
46 | sysbus_mmio_map(s, 0, base); | 20 | #ifndef CONFIG_USER_ONLY |
47 | sysbus_mmio_map(s, 1, descriptors); | 21 | if (cpu->pmu_timer) { |
48 | diff --git a/hw/openrisc/Kconfig b/hw/openrisc/Kconfig | 22 | - timer_del(cpu->pmu_timer); |
49 | index XXXXXXX..XXXXXXX 100644 | 23 | - timer_deinit(cpu->pmu_timer); |
50 | --- a/hw/openrisc/Kconfig | 24 | timer_free(cpu->pmu_timer); |
51 | +++ b/hw/openrisc/Kconfig | 25 | } |
52 | @@ -XXX,XX +XXX,XX @@ config OR1K_SIM | 26 | #endif |
53 | select SERIAL | ||
54 | select OPENCORES_ETH | ||
55 | select OMPIC | ||
56 | + select SPLIT_IRQ | ||
57 | -- | 27 | -- |
58 | 2.20.1 | 28 | 2.20.1 |
59 | 29 | ||
60 | 30 | diff view generated by jsdifflib |
1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Connect VersalUsb2 subsystem to xlnx-versal SOC, its placed | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | in iou of lpd domain and configure it as dual port host controller. | 4 | digic_timer_init function, so use ptimer_free() in the finalize function to |
5 | Add the respective guest dts nodes for "xlnx-versal-virt" machine. | 5 | avoid it. |
6 | 6 | ||
7 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> | 7 | ASAN shows memory leak stack: |
8 | Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 8 | |
9 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 9 | Indirect leak of 288 byte(s) in 3 object(s) allocated from: |
10 | Message-id: 1607023357-5096-5-git-send-email-sai.pavan.boddu@xilinx.com | 10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf5b04084 in digic_timer_init /qemu/hw/timer/digic-timer.c:142 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
16 | #6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
17 | #7 0xaaabf5b40e84 in digic_init /qemu/hw/arm/digic.c:46 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
22 | #12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 28 | --- |
13 | include/hw/arm/xlnx-versal.h | 9 ++++++ | 29 | hw/timer/digic-timer.c | 8 ++++++++ |
14 | hw/arm/xlnx-versal-virt.c | 55 ++++++++++++++++++++++++++++++++++++ | 30 | 1 file changed, 8 insertions(+) |
15 | hw/arm/xlnx-versal.c | 26 +++++++++++++++++ | ||
16 | 3 files changed, 90 insertions(+) | ||
17 | 31 | ||
18 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 32 | diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c |
19 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/xlnx-versal.h | 34 | --- a/hw/timer/digic-timer.c |
21 | +++ b/include/hw/arm/xlnx-versal.h | 35 | +++ b/hw/timer/digic-timer.c |
22 | @@ -XXX,XX +XXX,XX @@ | 36 | @@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj) |
23 | #include "hw/net/cadence_gem.h" | 37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); |
24 | #include "hw/rtc/xlnx-zynqmp-rtc.h" | 38 | } |
25 | #include "qom/object.h" | 39 | |
26 | +#include "hw/usb/xlnx-usb-subsystem.h" | 40 | +static void digic_timer_finalize(Object *obj) |
27 | 41 | +{ | |
28 | #define TYPE_XLNX_VERSAL "xlnx-versal" | 42 | + DigicTimerState *s = DIGIC_TIMER(obj); |
29 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) | ||
30 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
31 | PL011State uart[XLNX_VERSAL_NR_UARTS]; | ||
32 | CadenceGEMState gem[XLNX_VERSAL_NR_GEMS]; | ||
33 | XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS]; | ||
34 | + VersalUsb2 usb; | ||
35 | } iou; | ||
36 | } lpd; | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
39 | |||
40 | #define VERSAL_UART0_IRQ_0 18 | ||
41 | #define VERSAL_UART1_IRQ_0 19 | ||
42 | +#define VERSAL_USB0_IRQ_0 22 | ||
43 | #define VERSAL_GEM0_IRQ_0 56 | ||
44 | #define VERSAL_GEM0_WAKE_IRQ_0 57 | ||
45 | #define VERSAL_GEM1_IRQ_0 58 | ||
46 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
47 | #define MM_OCM 0xfffc0000U | ||
48 | #define MM_OCM_SIZE 0x40000 | ||
49 | |||
50 | +#define MM_USB2_CTRL_REGS 0xFF9D0000 | ||
51 | +#define MM_USB2_CTRL_REGS_SIZE 0x10000 | ||
52 | + | 43 | + |
53 | +#define MM_USB_0 0xFE200000 | 44 | + ptimer_free(s->ptimer); |
54 | +#define MM_USB_0_SIZE 0x10000 | ||
55 | + | ||
56 | #define MM_TOP_DDR 0x0 | ||
57 | #define MM_TOP_DDR_SIZE 0x80000000U | ||
58 | #define MM_TOP_DDR_2 0x800000000ULL | ||
59 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/hw/arm/xlnx-versal-virt.c | ||
62 | +++ b/hw/arm/xlnx-versal-virt.c | ||
63 | @@ -XXX,XX +XXX,XX @@ struct VersalVirt { | ||
64 | uint32_t ethernet_phy[2]; | ||
65 | uint32_t clk_125Mhz; | ||
66 | uint32_t clk_25Mhz; | ||
67 | + uint32_t usb; | ||
68 | + uint32_t dwc; | ||
69 | } phandle; | ||
70 | struct arm_boot_info binfo; | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static void fdt_create(VersalVirt *s) | ||
73 | s->phandle.clk_25Mhz = qemu_fdt_alloc_phandle(s->fdt); | ||
74 | s->phandle.clk_125Mhz = qemu_fdt_alloc_phandle(s->fdt); | ||
75 | |||
76 | + s->phandle.usb = qemu_fdt_alloc_phandle(s->fdt); | ||
77 | + s->phandle.dwc = qemu_fdt_alloc_phandle(s->fdt); | ||
78 | /* Create /chosen node for load_dtb. */ | ||
79 | qemu_fdt_add_subnode(s->fdt, "/chosen"); | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(VersalVirt *s) | ||
82 | compat, sizeof(compat)); | ||
83 | } | ||
84 | |||
85 | +static void fdt_add_usb_xhci_nodes(VersalVirt *s) | ||
86 | +{ | ||
87 | + const char clocknames[] = "bus_clk\0ref_clk"; | ||
88 | + const char irq_name[] = "dwc_usb3"; | ||
89 | + const char compatVersalDWC3[] = "xlnx,versal-dwc3"; | ||
90 | + const char compatDWC3[] = "snps,dwc3"; | ||
91 | + char *name = g_strdup_printf("/usb@%" PRIx32, MM_USB2_CTRL_REGS); | ||
92 | + | ||
93 | + qemu_fdt_add_subnode(s->fdt, name); | ||
94 | + qemu_fdt_setprop(s->fdt, name, "compatible", | ||
95 | + compatVersalDWC3, sizeof(compatVersalDWC3)); | ||
96 | + qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", | ||
97 | + 2, MM_USB2_CTRL_REGS, | ||
98 | + 2, MM_USB2_CTRL_REGS_SIZE); | ||
99 | + qemu_fdt_setprop(s->fdt, name, "clock-names", | ||
100 | + clocknames, sizeof(clocknames)); | ||
101 | + qemu_fdt_setprop_cells(s->fdt, name, "clocks", | ||
102 | + s->phandle.clk_25Mhz, s->phandle.clk_125Mhz); | ||
103 | + qemu_fdt_setprop(s->fdt, name, "ranges", NULL, 0); | ||
104 | + qemu_fdt_setprop_cell(s->fdt, name, "#address-cells", 2); | ||
105 | + qemu_fdt_setprop_cell(s->fdt, name, "#size-cells", 2); | ||
106 | + qemu_fdt_setprop_cell(s->fdt, name, "phandle", s->phandle.usb); | ||
107 | + g_free(name); | ||
108 | + | ||
109 | + name = g_strdup_printf("/usb@%" PRIx32 "/dwc3@%" PRIx32, | ||
110 | + MM_USB2_CTRL_REGS, MM_USB_0); | ||
111 | + qemu_fdt_add_subnode(s->fdt, name); | ||
112 | + qemu_fdt_setprop(s->fdt, name, "compatible", | ||
113 | + compatDWC3, sizeof(compatDWC3)); | ||
114 | + qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", | ||
115 | + 2, MM_USB_0, 2, MM_USB_0_SIZE); | ||
116 | + qemu_fdt_setprop(s->fdt, name, "interrupt-names", | ||
117 | + irq_name, sizeof(irq_name)); | ||
118 | + qemu_fdt_setprop_cells(s->fdt, name, "interrupts", | ||
119 | + GIC_FDT_IRQ_TYPE_SPI, VERSAL_USB0_IRQ_0, | ||
120 | + GIC_FDT_IRQ_FLAGS_LEVEL_HI); | ||
121 | + qemu_fdt_setprop_cell(s->fdt, name, | ||
122 | + "snps,quirk-frame-length-adjustment", 0x20); | ||
123 | + qemu_fdt_setprop_cells(s->fdt, name, "#stream-id-cells", 1); | ||
124 | + qemu_fdt_setprop_string(s->fdt, name, "dr_mode", "host"); | ||
125 | + qemu_fdt_setprop_string(s->fdt, name, "phy-names", "usb3-phy"); | ||
126 | + qemu_fdt_setprop(s->fdt, name, "snps,dis_u2_susphy_quirk", NULL, 0); | ||
127 | + qemu_fdt_setprop(s->fdt, name, "snps,dis_u3_susphy_quirk", NULL, 0); | ||
128 | + qemu_fdt_setprop(s->fdt, name, "snps,refclk_fladj", NULL, 0); | ||
129 | + qemu_fdt_setprop(s->fdt, name, "snps,mask_phy_reset", NULL, 0); | ||
130 | + qemu_fdt_setprop_cell(s->fdt, name, "phandle", s->phandle.dwc); | ||
131 | + qemu_fdt_setprop_string(s->fdt, name, "maximum-speed", "high-speed"); | ||
132 | + g_free(name); | ||
133 | +} | 45 | +} |
134 | + | 46 | + |
135 | static void fdt_add_uart_nodes(VersalVirt *s) | 47 | static void digic_timer_class_init(ObjectClass *klass, void *class_data) |
136 | { | 48 | { |
137 | uint64_t addrs[] = { MM_UART1, MM_UART0 }; | 49 | DeviceClass *dc = DEVICE_CLASS(klass); |
138 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | 50 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo digic_timer_info = { |
139 | fdt_add_gic_nodes(s); | 51 | .parent = TYPE_SYS_BUS_DEVICE, |
140 | fdt_add_timer_nodes(s); | 52 | .instance_size = sizeof(DigicTimerState), |
141 | fdt_add_zdma_nodes(s); | 53 | .instance_init = digic_timer_init, |
142 | + fdt_add_usb_xhci_nodes(s); | 54 | + .instance_finalize = digic_timer_finalize, |
143 | fdt_add_sd_nodes(s); | 55 | .class_init = digic_timer_class_init, |
144 | fdt_add_rtc_node(s); | 56 | }; |
145 | fdt_add_cpu_nodes(s, psci_conduit); | 57 | |
146 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/hw/arm/xlnx-versal.c | ||
149 | +++ b/hw/arm/xlnx-versal.c | ||
150 | @@ -XXX,XX +XXX,XX @@ static void versal_create_uarts(Versal *s, qemu_irq *pic) | ||
151 | } | ||
152 | } | ||
153 | |||
154 | +static void versal_create_usbs(Versal *s, qemu_irq *pic) | ||
155 | +{ | ||
156 | + DeviceState *dev; | ||
157 | + MemoryRegion *mr; | ||
158 | + | ||
159 | + object_initialize_child(OBJECT(s), "usb2", &s->lpd.iou.usb, | ||
160 | + TYPE_XILINX_VERSAL_USB2); | ||
161 | + dev = DEVICE(&s->lpd.iou.usb); | ||
162 | + | ||
163 | + object_property_set_link(OBJECT(dev), "dma", OBJECT(&s->mr_ps), | ||
164 | + &error_abort); | ||
165 | + qdev_prop_set_uint32(dev, "intrs", 1); | ||
166 | + qdev_prop_set_uint32(dev, "slots", 2); | ||
167 | + | ||
168 | + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); | ||
169 | + | ||
170 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
171 | + memory_region_add_subregion(&s->mr_ps, MM_USB_0, mr); | ||
172 | + | ||
173 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[VERSAL_USB0_IRQ_0]); | ||
174 | + | ||
175 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); | ||
176 | + memory_region_add_subregion(&s->mr_ps, MM_USB2_CTRL_REGS, mr); | ||
177 | +} | ||
178 | + | ||
179 | static void versal_create_gems(Versal *s, qemu_irq *pic) | ||
180 | { | ||
181 | int i; | ||
182 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
183 | versal_create_apu_cpus(s); | ||
184 | versal_create_apu_gic(s, pic); | ||
185 | versal_create_uarts(s, pic); | ||
186 | + versal_create_usbs(s, pic); | ||
187 | versal_create_gems(s, pic); | ||
188 | versal_create_admas(s, pic); | ||
189 | versal_create_sds(s, pic); | ||
190 | -- | 58 | -- |
191 | 2.20.1 | 59 | 2.20.1 |
192 | 60 | ||
193 | 61 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Numonyx chips determine the number of cycles to wait based on bits 7:4 | 3 | When running device-introspect-test, a memory leak occurred in the a10_pit_init |
4 | in the volatile configuration register. | 4 | function, so use ptimer_free() in the finalize function to avoid it. |
5 | 5 | ||
6 | However, if these bits are 0x0 or 0xF, the number of dummy cycles to | 6 | ASAN shows memory leak stack: |
7 | wait is 10 for QIOR and QIOR4 commands or when in QIO mode, and otherwise 8 for | ||
8 | the currently supported fast read commands. [1] | ||
9 | 7 | ||
10 | [1] | 8 | Indirect leak of 288 byte(s) in 6 object(s) allocated from: |
11 | https://www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/mt25q/die-rev-b/mt25q_qlkt_u_02g_cbb_0.pdf?rev=9b167fbf2b3645efba6385949a72e453 | 9 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
10 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
11 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
12 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
13 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
14 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
15 | #6 0xaaabf57415e8 in a10_pit_init /qemu/hw/timer/allwinner-a10-pit.c:278 | ||
16 | #7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
17 | #8 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
18 | #9 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
19 | #10 0xaaabf5b94680 in aw_a10_init /qemu/hw/arm/allwinner-a10.c:49 | ||
20 | #11 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
21 | #12 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
12 | 22 | ||
13 | Signed-off-by: Joe Komlodi <komlodi@xilinx.com> | 23 | Reported-by: Euler Robot <euler.robot@huawei.com> |
14 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> | 24 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> |
15 | Message-id: 1605568264-26376-5-git-send-email-komlodi@xilinx.com | 25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 27 | --- |
18 | hw/block/m25p80.c | 30 +++++++++++++++++++++++++++--- | 28 | hw/timer/allwinner-a10-pit.c | 11 +++++++++++ |
19 | 1 file changed, 27 insertions(+), 3 deletions(-) | 29 | 1 file changed, 11 insertions(+) |
20 | 30 | ||
21 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 31 | diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c |
22 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/block/m25p80.c | 33 | --- a/hw/timer/allwinner-a10-pit.c |
24 | +++ b/hw/block/m25p80.c | 34 | +++ b/hw/timer/allwinner-a10-pit.c |
25 | @@ -XXX,XX +XXX,XX @@ static uint8_t numonyx_mode(Flash *s) | 35 | @@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj) |
26 | } | 36 | } |
27 | } | 37 | } |
28 | 38 | ||
29 | +static uint8_t numonyx_extract_cfg_num_dummies(Flash *s) | 39 | +static void a10_pit_finalize(Object *obj) |
30 | +{ | 40 | +{ |
31 | + uint8_t num_dummies; | 41 | + AwA10PITState *s = AW_A10_PIT(obj); |
32 | + uint8_t mode; | 42 | + int i; |
33 | + assert(get_man(s) == MAN_NUMONYX); | ||
34 | + | 43 | + |
35 | + mode = numonyx_mode(s); | 44 | + for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) { |
36 | + num_dummies = extract32(s->volatile_cfg, 4, 4); | 45 | + ptimer_free(s->timer[i]); |
37 | + | ||
38 | + if (num_dummies == 0x0 || num_dummies == 0xf) { | ||
39 | + switch (s->cmd_in_progress) { | ||
40 | + case QIOR: | ||
41 | + case QIOR4: | ||
42 | + num_dummies = 10; | ||
43 | + break; | ||
44 | + default: | ||
45 | + num_dummies = (mode == MODE_QIO) ? 10 : 8; | ||
46 | + break; | ||
47 | + } | ||
48 | + } | 46 | + } |
49 | + | ||
50 | + return num_dummies; | ||
51 | +} | 47 | +} |
52 | + | 48 | + |
53 | static void decode_fast_read_cmd(Flash *s) | 49 | static void a10_pit_class_init(ObjectClass *klass, void *data) |
54 | { | 50 | { |
55 | s->needed_bytes = get_addr_length(s); | 51 | DeviceClass *dc = DEVICE_CLASS(klass); |
56 | @@ -XXX,XX +XXX,XX @@ static void decode_fast_read_cmd(Flash *s) | 52 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo a10_pit_info = { |
57 | s->needed_bytes += 8; | 53 | .parent = TYPE_SYS_BUS_DEVICE, |
58 | break; | 54 | .instance_size = sizeof(AwA10PITState), |
59 | case MAN_NUMONYX: | 55 | .instance_init = a10_pit_init, |
60 | - s->needed_bytes += extract32(s->volatile_cfg, 4, 4); | 56 | + .instance_finalize = a10_pit_finalize, |
61 | + s->needed_bytes += numonyx_extract_cfg_num_dummies(s); | 57 | .class_init = a10_pit_class_init, |
62 | break; | 58 | }; |
63 | case MAN_MACRONIX: | 59 | |
64 | if (extract32(s->volatile_cfg, 6, 2) == 1) { | ||
65 | @@ -XXX,XX +XXX,XX @@ static void decode_dio_read_cmd(Flash *s) | ||
66 | ); | ||
67 | break; | ||
68 | case MAN_NUMONYX: | ||
69 | - s->needed_bytes += extract32(s->volatile_cfg, 4, 4); | ||
70 | + s->needed_bytes += numonyx_extract_cfg_num_dummies(s); | ||
71 | break; | ||
72 | case MAN_MACRONIX: | ||
73 | switch (extract32(s->volatile_cfg, 6, 2)) { | ||
74 | @@ -XXX,XX +XXX,XX @@ static void decode_qio_read_cmd(Flash *s) | ||
75 | ); | ||
76 | break; | ||
77 | case MAN_NUMONYX: | ||
78 | - s->needed_bytes += extract32(s->volatile_cfg, 4, 4); | ||
79 | + s->needed_bytes += numonyx_extract_cfg_num_dummies(s); | ||
80 | break; | ||
81 | case MAN_MACRONIX: | ||
82 | switch (extract32(s->volatile_cfg, 6, 2)) { | ||
83 | -- | 60 | -- |
84 | 2.20.1 | 61 | 2.20.1 |
85 | 62 | ||
86 | 63 | diff view generated by jsdifflib |
1 | In rom_check_and_register_reset() we report to the user if there is | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | a "ROM region overlap". This has a couple of problems: | ||
3 | * the reported information is not very easy to intepret | ||
4 | * the function just prints the overlap to stderr (and relies on | ||
5 | its single callsite in vl.c to do an error_report() and exit) | ||
6 | * only the first overlap encountered is diagnosed | ||
7 | 2 | ||
8 | Make this function use error_report() and error_printf() and | 3 | When running device-introspect-test, a memory leak occurred in the |
9 | report a more user-friendly report with all the overlaps | 4 | exynos4210_rtc_init function, so use ptimer_free() in the finalize function to |
10 | diagnosed. | 5 | avoid it. |
11 | 6 | ||
12 | Sample old output: | 7 | ASAN shows memory leak stack: |
13 | 8 | ||
14 | rom: requested regions overlap (rom dtb. free=0x0000000000008000, addr=0x0000000000000000) | 9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: |
15 | qemu-system-aarch64: rom check and register reset failed | 10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf57b3934 in exynos4210_rtc_init /qemu/hw/rtc/exynos4210_rtc.c:567 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
16 | #6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
17 | #7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
18 | #8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
19 | #9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
20 | #10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164 | ||
21 | #11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381 | ||
22 | #12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306 | ||
16 | 23 | ||
17 | Sample new output: | 24 | Reported-by: Euler Robot <euler.robot@huawei.com> |
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | --- | ||
29 | hw/rtc/exynos4210_rtc.c | 9 +++++++++ | ||
30 | 1 file changed, 9 insertions(+) | ||
18 | 31 | ||
19 | qemu-system-aarch64: Some ROM regions are overlapping | 32 | diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c |
20 | These ROM regions might have been loaded by direct user request or by default. | ||
21 | They could be BIOS/firmware images, a guest kernel, initrd or some other file loaded into guest memory. | ||
22 | Check whether you intended to load all this guest code, and whether it has been built to load to the correct addresses. | ||
23 | |||
24 | The following two regions overlap (in the cpu-memory-0 address space): | ||
25 | phdr #0: /home/petmay01/linaro/qemu-misc-tests/ldmia-fault.axf (addresses 0x0000000000000000 - 0x0000000000008000) | ||
26 | dtb (addresses 0x0000000000000000 - 0x0000000000100000) | ||
27 | |||
28 | The following two regions overlap (in the cpu-memory-0 address space): | ||
29 | phdr #1: /home/petmay01/linaro/qemu-misc-tests/bad-psci-call.axf (addresses 0x0000000040000000 - 0x0000000040000010) | ||
30 | phdr #0: /home/petmay01/linaro/qemu-misc-tests/bp-test.elf (addresses 0x0000000040000000 - 0x0000000040000020) | ||
31 | |||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
33 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
34 | Message-id: 20201129203923.10622-3-peter.maydell@linaro.org | ||
35 | --- | ||
36 | hw/core/loader.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ | ||
37 | softmmu/vl.c | 1 - | ||
38 | 2 files changed, 42 insertions(+), 7 deletions(-) | ||
39 | |||
40 | diff --git a/hw/core/loader.c b/hw/core/loader.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/hw/core/loader.c | 34 | --- a/hw/rtc/exynos4210_rtc.c |
43 | +++ b/hw/core/loader.c | 35 | +++ b/hw/rtc/exynos4210_rtc.c |
44 | @@ -XXX,XX +XXX,XX @@ static bool roms_overlap(Rom *last_rom, Rom *this_rom) | 36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj) |
45 | last_rom->addr + last_rom->romsize > this_rom->addr; | 37 | sysbus_init_mmio(dev, &s->iomem); |
46 | } | 38 | } |
47 | 39 | ||
48 | +static const char *rom_as_name(Rom *rom) | 40 | +static void exynos4210_rtc_finalize(Object *obj) |
49 | +{ | 41 | +{ |
50 | + const char *name = rom->as ? rom->as->name : NULL; | 42 | + Exynos4210RTCState *s = EXYNOS4210_RTC(obj); |
51 | + return name ?: "anonymous"; | 43 | + |
44 | + ptimer_free(s->ptimer); | ||
45 | + ptimer_free(s->ptimer_1Hz); | ||
52 | +} | 46 | +} |
53 | + | 47 | + |
54 | +static void rom_print_overlap_error_header(void) | 48 | static void exynos4210_rtc_class_init(ObjectClass *klass, void *data) |
55 | +{ | ||
56 | + error_report("Some ROM regions are overlapping"); | ||
57 | + error_printf( | ||
58 | + "These ROM regions might have been loaded by " | ||
59 | + "direct user request or by default.\n" | ||
60 | + "They could be BIOS/firmware images, a guest kernel, " | ||
61 | + "initrd or some other file loaded into guest memory.\n" | ||
62 | + "Check whether you intended to load all this guest code, and " | ||
63 | + "whether it has been built to load to the correct addresses.\n"); | ||
64 | +} | ||
65 | + | ||
66 | +static void rom_print_one_overlap_error(Rom *last_rom, Rom *rom) | ||
67 | +{ | ||
68 | + error_printf( | ||
69 | + "\nThe following two regions overlap (in the %s address space):\n", | ||
70 | + rom_as_name(rom)); | ||
71 | + error_printf( | ||
72 | + " %s (addresses 0x" TARGET_FMT_plx " - 0x" TARGET_FMT_plx ")\n", | ||
73 | + last_rom->name, last_rom->addr, last_rom->addr + last_rom->romsize); | ||
74 | + error_printf( | ||
75 | + " %s (addresses 0x" TARGET_FMT_plx " - 0x" TARGET_FMT_plx ")\n", | ||
76 | + rom->name, rom->addr, rom->addr + rom->romsize); | ||
77 | +} | ||
78 | + | ||
79 | int rom_check_and_register_reset(void) | ||
80 | { | 49 | { |
81 | MemoryRegionSection section; | 50 | DeviceClass *dc = DEVICE_CLASS(klass); |
82 | Rom *rom, *last_rom = NULL; | 51 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = { |
83 | + bool found_overlap = false; | 52 | .parent = TYPE_SYS_BUS_DEVICE, |
84 | 53 | .instance_size = sizeof(Exynos4210RTCState), | |
85 | QTAILQ_FOREACH(rom, &roms, next) { | 54 | .instance_init = exynos4210_rtc_init, |
86 | if (rom->fw_file) { | 55 | + .instance_finalize = exynos4210_rtc_finalize, |
87 | @@ -XXX,XX +XXX,XX @@ int rom_check_and_register_reset(void) | 56 | .class_init = exynos4210_rtc_class_init, |
88 | } | 57 | }; |
89 | if (!rom->mr) { | ||
90 | if (roms_overlap(last_rom, rom)) { | ||
91 | - fprintf(stderr, "rom: requested regions overlap " | ||
92 | - "(rom %s. free=0x" TARGET_FMT_plx | ||
93 | - ", addr=0x" TARGET_FMT_plx ")\n", | ||
94 | - rom->name, last_rom->addr + last_rom->romsize, | ||
95 | - rom->addr); | ||
96 | - return -1; | ||
97 | + if (!found_overlap) { | ||
98 | + found_overlap = true; | ||
99 | + rom_print_overlap_error_header(); | ||
100 | + } | ||
101 | + rom_print_one_overlap_error(last_rom, rom); | ||
102 | + /* Keep going through the list so we report all overlaps */ | ||
103 | } | ||
104 | last_rom = rom; | ||
105 | } | ||
106 | @@ -XXX,XX +XXX,XX @@ int rom_check_and_register_reset(void) | ||
107 | rom->isrom = int128_nz(section.size) && memory_region_is_rom(section.mr); | ||
108 | memory_region_unref(section.mr); | ||
109 | } | ||
110 | + if (found_overlap) { | ||
111 | + return -1; | ||
112 | + } | ||
113 | + | ||
114 | qemu_register_reset(rom_reset, NULL); | ||
115 | roms_loaded = 1; | ||
116 | return 0; | ||
117 | diff --git a/softmmu/vl.c b/softmmu/vl.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/softmmu/vl.c | ||
120 | +++ b/softmmu/vl.c | ||
121 | @@ -XXX,XX +XXX,XX @@ static void qemu_machine_creation_done(void) | ||
122 | qemu_run_machine_init_done_notifiers(); | ||
123 | |||
124 | if (rom_check_and_register_reset() != 0) { | ||
125 | - error_report("rom check and register reset failed"); | ||
126 | exit(1); | ||
127 | } | ||
128 | 58 | ||
129 | -- | 59 | -- |
130 | 2.20.1 | 60 | 2.20.1 |
131 | 61 | ||
132 | 62 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Some Numonyx flash commands cannot be executed in DIO and QIO mode, such as | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | trying to do DPP or DOR when in QIO mode. | 4 | exynos4210_pwm_init function, so use ptimer_free() in the finalize function to |
5 | avoid it. | ||
5 | 6 | ||
6 | Signed-off-by: Joe Komlodi <komlodi@xilinx.com> | 7 | ASAN shows memory leak stack: |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> | 8 | |
8 | Message-id: 1605568264-26376-4-git-send-email-komlodi@xilinx.com | 9 | Indirect leak of 240 byte(s) in 5 object(s) allocated from: |
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
13 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
14 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
15 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
16 | #6 0xaaabf56a36cc in exynos4210_pwm_init /qemu/hw/timer/exynos4210_pwm.c:401 | ||
17 | #7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
18 | #8 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
19 | #9 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
20 | #10 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
21 | #11 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
22 | #12 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 28 | --- |
11 | hw/block/m25p80.c | 114 ++++++++++++++++++++++++++++++++++++++-------- | 29 | hw/timer/exynos4210_pwm.c | 11 +++++++++++ |
12 | 1 file changed, 95 insertions(+), 19 deletions(-) | 30 | 1 file changed, 11 insertions(+) |
13 | 31 | ||
14 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 32 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c |
15 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/block/m25p80.c | 34 | --- a/hw/timer/exynos4210_pwm.c |
17 | +++ b/hw/block/m25p80.c | 35 | +++ b/hw/timer/exynos4210_pwm.c |
18 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj) |
19 | MAN_GENERIC, | 37 | sysbus_init_mmio(dev, &s->iomem); |
20 | } Manufacturer; | 38 | } |
21 | 39 | ||
22 | +typedef enum { | 40 | +static void exynos4210_pwm_finalize(Object *obj) |
23 | + MODE_STD = 0, | 41 | +{ |
24 | + MODE_DIO = 1, | 42 | + Exynos4210PWMState *s = EXYNOS4210_PWM(obj); |
25 | + MODE_QIO = 2 | 43 | + int i; |
26 | +} SPIMode; | ||
27 | + | 44 | + |
28 | #define M25P80_INTERNAL_DATA_BUFFER_SZ 16 | 45 | + for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) { |
29 | 46 | + ptimer_free(s->timer[i].ptimer); | |
30 | struct Flash { | ||
31 | @@ -XXX,XX +XXX,XX @@ static void reset_memory(Flash *s) | ||
32 | trace_m25p80_reset_done(s); | ||
33 | } | ||
34 | |||
35 | +static uint8_t numonyx_mode(Flash *s) | ||
36 | +{ | ||
37 | + if (!(s->enh_volatile_cfg & EVCFG_QUAD_IO_DISABLED)) { | ||
38 | + return MODE_QIO; | ||
39 | + } else if (!(s->enh_volatile_cfg & EVCFG_DUAL_IO_DISABLED)) { | ||
40 | + return MODE_DIO; | ||
41 | + } else { | ||
42 | + return MODE_STD; | ||
43 | + } | 47 | + } |
44 | +} | 48 | +} |
45 | + | 49 | + |
46 | static void decode_fast_read_cmd(Flash *s) | 50 | static void exynos4210_pwm_class_init(ObjectClass *klass, void *data) |
47 | { | 51 | { |
48 | s->needed_bytes = get_addr_length(s); | 52 | DeviceClass *dc = DEVICE_CLASS(klass); |
49 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | 53 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_pwm_info = { |
50 | case ERASE4_32K: | 54 | .parent = TYPE_SYS_BUS_DEVICE, |
51 | case ERASE_SECTOR: | 55 | .instance_size = sizeof(Exynos4210PWMState), |
52 | case ERASE4_SECTOR: | 56 | .instance_init = exynos4210_pwm_init, |
53 | - case READ: | 57 | + .instance_finalize = exynos4210_pwm_finalize, |
54 | - case READ4: | 58 | .class_init = exynos4210_pwm_class_init, |
55 | - case DPP: | 59 | }; |
56 | - case QPP: | 60 | |
57 | - case QPP_4: | ||
58 | case PP: | ||
59 | case PP4: | ||
60 | - case PP4_4: | ||
61 | case DIE_ERASE: | ||
62 | case RDID_90: | ||
63 | case RDID_AB: | ||
64 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
65 | s->len = 0; | ||
66 | s->state = STATE_COLLECTING_DATA; | ||
67 | break; | ||
68 | + case READ: | ||
69 | + case READ4: | ||
70 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) == MODE_STD) { | ||
71 | + s->needed_bytes = get_addr_length(s); | ||
72 | + s->pos = 0; | ||
73 | + s->len = 0; | ||
74 | + s->state = STATE_COLLECTING_DATA; | ||
75 | + } else { | ||
76 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in " | ||
77 | + "DIO or QIO mode\n", s->cmd_in_progress); | ||
78 | + } | ||
79 | + break; | ||
80 | + case DPP: | ||
81 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_QIO) { | ||
82 | + s->needed_bytes = get_addr_length(s); | ||
83 | + s->pos = 0; | ||
84 | + s->len = 0; | ||
85 | + s->state = STATE_COLLECTING_DATA; | ||
86 | + } else { | ||
87 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in " | ||
88 | + "QIO mode\n", s->cmd_in_progress); | ||
89 | + } | ||
90 | + break; | ||
91 | + case QPP: | ||
92 | + case QPP_4: | ||
93 | + case PP4_4: | ||
94 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_DIO) { | ||
95 | + s->needed_bytes = get_addr_length(s); | ||
96 | + s->pos = 0; | ||
97 | + s->len = 0; | ||
98 | + s->state = STATE_COLLECTING_DATA; | ||
99 | + } else { | ||
100 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in " | ||
101 | + "DIO mode\n", s->cmd_in_progress); | ||
102 | + } | ||
103 | + break; | ||
104 | |||
105 | case FAST_READ: | ||
106 | case FAST_READ4: | ||
107 | + decode_fast_read_cmd(s); | ||
108 | + break; | ||
109 | case DOR: | ||
110 | case DOR4: | ||
111 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_QIO) { | ||
112 | + decode_fast_read_cmd(s); | ||
113 | + } else { | ||
114 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in " | ||
115 | + "QIO mode\n", s->cmd_in_progress); | ||
116 | + } | ||
117 | + break; | ||
118 | case QOR: | ||
119 | case QOR4: | ||
120 | - decode_fast_read_cmd(s); | ||
121 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_DIO) { | ||
122 | + decode_fast_read_cmd(s); | ||
123 | + } else { | ||
124 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in " | ||
125 | + "DIO mode\n", s->cmd_in_progress); | ||
126 | + } | ||
127 | break; | ||
128 | |||
129 | case DIOR: | ||
130 | case DIOR4: | ||
131 | - decode_dio_read_cmd(s); | ||
132 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_QIO) { | ||
133 | + decode_dio_read_cmd(s); | ||
134 | + } else { | ||
135 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in " | ||
136 | + "QIO mode\n", s->cmd_in_progress); | ||
137 | + } | ||
138 | break; | ||
139 | |||
140 | case QIOR: | ||
141 | case QIOR4: | ||
142 | - decode_qio_read_cmd(s); | ||
143 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) != MODE_DIO) { | ||
144 | + decode_qio_read_cmd(s); | ||
145 | + } else { | ||
146 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute cmd %x in " | ||
147 | + "DIO mode\n", s->cmd_in_progress); | ||
148 | + } | ||
149 | break; | ||
150 | |||
151 | case WRSR: | ||
152 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
153 | break; | ||
154 | |||
155 | case JEDEC_READ: | ||
156 | - trace_m25p80_populated_jedec(s); | ||
157 | - for (i = 0; i < s->pi->id_len; i++) { | ||
158 | - s->data[i] = s->pi->id[i]; | ||
159 | - } | ||
160 | - for (; i < SPI_NOR_MAX_ID_LEN; i++) { | ||
161 | - s->data[i] = 0; | ||
162 | - } | ||
163 | + if (get_man(s) != MAN_NUMONYX || numonyx_mode(s) == MODE_STD) { | ||
164 | + trace_m25p80_populated_jedec(s); | ||
165 | + for (i = 0; i < s->pi->id_len; i++) { | ||
166 | + s->data[i] = s->pi->id[i]; | ||
167 | + } | ||
168 | + for (; i < SPI_NOR_MAX_ID_LEN; i++) { | ||
169 | + s->data[i] = 0; | ||
170 | + } | ||
171 | |||
172 | - s->len = SPI_NOR_MAX_ID_LEN; | ||
173 | - s->pos = 0; | ||
174 | - s->state = STATE_READING_DATA; | ||
175 | + s->len = SPI_NOR_MAX_ID_LEN; | ||
176 | + s->pos = 0; | ||
177 | + s->state = STATE_READING_DATA; | ||
178 | + } else { | ||
179 | + qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Cannot execute JEDEC read " | ||
180 | + "in DIO or QIO mode\n"); | ||
181 | + } | ||
182 | break; | ||
183 | |||
184 | case RDCR: | ||
185 | -- | 61 | -- |
186 | 2.20.1 | 62 | 2.20.1 |
187 | 63 | ||
188 | 64 | diff view generated by jsdifflib |
1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds skeleton model of dwc3 usb controller attached to | 3 | When running device-introspect-test, a memory leak occurred in the |
4 | xhci-sysbus device. It defines global register space of DWC3 controller, | 4 | mss_timer_init function, so use ptimer_free() in the finalize function to avoid |
5 | global registers control the AXI/AHB interfaces properties, external FIFO | 5 | it. |
6 | support and event count support. All of which are unimplemented at | ||
7 | present,we are only supporting core reset and read of ID register. | ||
8 | 6 | ||
9 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> | 7 | ASAN shows memory leak stack: |
10 | Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 8 | |
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 9 | Indirect leak of 192 byte(s) in 2 object(s) allocated from: |
12 | Message-id: 1607023357-5096-3-git-send-email-sai.pavan.boddu@xilinx.com | 10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf58a0010 in mss_timer_init /qemu/hw/timer/mss-timer.c:235 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564 | ||
16 | #6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547 | ||
17 | #7 0xaaabf5b8316c in m2sxxx_soc_initfn /qemu/hw/arm/msf2-soc.c:70 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
22 | #12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 28 | --- |
15 | include/hw/usb/hcd-dwc3.h | 55 +++ | 29 | hw/timer/mss-timer.c | 13 +++++++++++++ |
16 | hw/usb/hcd-dwc3.c | 689 ++++++++++++++++++++++++++++++++++++++ | 30 | 1 file changed, 13 insertions(+) |
17 | hw/usb/Kconfig | 5 + | ||
18 | hw/usb/meson.build | 1 + | ||
19 | 4 files changed, 750 insertions(+) | ||
20 | create mode 100644 include/hw/usb/hcd-dwc3.h | ||
21 | create mode 100644 hw/usb/hcd-dwc3.c | ||
22 | 31 | ||
23 | diff --git a/include/hw/usb/hcd-dwc3.h b/include/hw/usb/hcd-dwc3.h | 32 | diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c |
24 | new file mode 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
25 | index XXXXXXX..XXXXXXX | 34 | --- a/hw/timer/mss-timer.c |
26 | --- /dev/null | 35 | +++ b/hw/timer/mss-timer.c |
27 | +++ b/include/hw/usb/hcd-dwc3.h | 36 | @@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj) |
28 | @@ -XXX,XX +XXX,XX @@ | 37 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio); |
29 | +/* | 38 | } |
30 | + * QEMU model of the USB DWC3 host controller emulation. | 39 | |
31 | + * | 40 | +static void mss_timer_finalize(Object *obj) |
32 | + * Copyright (c) 2020 Xilinx Inc. | 41 | +{ |
33 | + * | 42 | + MSSTimerState *t = MSS_TIMER(obj); |
34 | + * Written by Vikram Garhwal<fnu.vikram@xilinx.com> | 43 | + int i; |
35 | + * | ||
36 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
37 | + * of this software and associated documentation files (the "Software"), to deal | ||
38 | + * in the Software without restriction, including without limitation the rights | ||
39 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
40 | + * copies of the Software, and to permit persons to whom the Software is | ||
41 | + * furnished to do so, subject to the following conditions: | ||
42 | + * | ||
43 | + * The above copyright notice and this permission notice shall be included in | ||
44 | + * all copies or substantial portions of the Software. | ||
45 | + * | ||
46 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
47 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
48 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
49 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
50 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
51 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
52 | + * THE SOFTWARE. | ||
53 | + */ | ||
54 | +#ifndef HCD_DWC3_H | ||
55 | +#define HCD_DWC3_H | ||
56 | + | 44 | + |
57 | +#include "hw/usb/hcd-xhci.h" | 45 | + for (i = 0; i < NUM_TIMERS; i++) { |
58 | +#include "hw/usb/hcd-xhci-sysbus.h" | 46 | + struct Msf2Timer *st = &t->timers[i]; |
59 | + | 47 | + |
60 | +#define TYPE_USB_DWC3 "usb_dwc3" | 48 | + ptimer_free(st->ptimer); |
61 | + | ||
62 | +#define USB_DWC3(obj) \ | ||
63 | + OBJECT_CHECK(USBDWC3, (obj), TYPE_USB_DWC3) | ||
64 | + | ||
65 | +#define USB_DWC3_R_MAX ((0x530 / 4) + 1) | ||
66 | +#define DWC3_SIZE 0x10000 | ||
67 | + | ||
68 | +typedef struct USBDWC3 { | ||
69 | + SysBusDevice parent_obj; | ||
70 | + MemoryRegion iomem; | ||
71 | + XHCISysbusState sysbus_xhci; | ||
72 | + | ||
73 | + uint32_t regs[USB_DWC3_R_MAX]; | ||
74 | + RegisterInfo regs_info[USB_DWC3_R_MAX]; | ||
75 | + | ||
76 | + struct { | ||
77 | + uint8_t mode; | ||
78 | + uint32_t dwc_usb3_user; | ||
79 | + } cfg; | ||
80 | + | ||
81 | +} USBDWC3; | ||
82 | + | ||
83 | +#endif | ||
84 | diff --git a/hw/usb/hcd-dwc3.c b/hw/usb/hcd-dwc3.c | ||
85 | new file mode 100644 | ||
86 | index XXXXXXX..XXXXXXX | ||
87 | --- /dev/null | ||
88 | +++ b/hw/usb/hcd-dwc3.c | ||
89 | @@ -XXX,XX +XXX,XX @@ | ||
90 | +/* | ||
91 | + * QEMU model of the USB DWC3 host controller emulation. | ||
92 | + * | ||
93 | + * This model defines global register space of DWC3 controller. Global | ||
94 | + * registers control the AXI/AHB interfaces properties, external FIFO support | ||
95 | + * and event count support. All of which are unimplemented at present. We are | ||
96 | + * only supporting core reset and read of ID register. | ||
97 | + * | ||
98 | + * Copyright (c) 2020 Xilinx Inc. Vikram Garhwal<fnu.vikram@xilinx.com> | ||
99 | + * | ||
100 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
101 | + * of this software and associated documentation files (the "Software"), to deal | ||
102 | + * in the Software without restriction, including without limitation the rights | ||
103 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
104 | + * copies of the Software, and to permit persons to whom the Software is | ||
105 | + * furnished to do so, subject to the following conditions: | ||
106 | + * | ||
107 | + * The above copyright notice and this permission notice shall be included in | ||
108 | + * all copies or substantial portions of the Software. | ||
109 | + * | ||
110 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
111 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
112 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
113 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
114 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
115 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
116 | + * THE SOFTWARE. | ||
117 | + */ | ||
118 | + | ||
119 | +#include "qemu/osdep.h" | ||
120 | +#include "hw/sysbus.h" | ||
121 | +#include "hw/register.h" | ||
122 | +#include "qemu/bitops.h" | ||
123 | +#include "qemu/log.h" | ||
124 | +#include "qom/object.h" | ||
125 | +#include "migration/vmstate.h" | ||
126 | +#include "hw/qdev-properties.h" | ||
127 | +#include "hw/usb/hcd-dwc3.h" | ||
128 | +#include "qapi/error.h" | ||
129 | + | ||
130 | +#ifndef USB_DWC3_ERR_DEBUG | ||
131 | +#define USB_DWC3_ERR_DEBUG 0 | ||
132 | +#endif | ||
133 | + | ||
134 | +#define HOST_MODE 1 | ||
135 | +#define FIFO_LEN 0x1000 | ||
136 | + | ||
137 | +REG32(GSBUSCFG0, 0x00) | ||
138 | + FIELD(GSBUSCFG0, DATRDREQINFO, 28, 4) | ||
139 | + FIELD(GSBUSCFG0, DESRDREQINFO, 24, 4) | ||
140 | + FIELD(GSBUSCFG0, DATWRREQINFO, 20, 4) | ||
141 | + FIELD(GSBUSCFG0, DESWRREQINFO, 16, 4) | ||
142 | + FIELD(GSBUSCFG0, RESERVED_15_12, 12, 4) | ||
143 | + FIELD(GSBUSCFG0, DATBIGEND, 11, 1) | ||
144 | + FIELD(GSBUSCFG0, DESBIGEND, 10, 1) | ||
145 | + FIELD(GSBUSCFG0, RESERVED_9_8, 8, 2) | ||
146 | + FIELD(GSBUSCFG0, INCR256BRSTENA, 7, 1) | ||
147 | + FIELD(GSBUSCFG0, INCR128BRSTENA, 6, 1) | ||
148 | + FIELD(GSBUSCFG0, INCR64BRSTENA, 5, 1) | ||
149 | + FIELD(GSBUSCFG0, INCR32BRSTENA, 4, 1) | ||
150 | + FIELD(GSBUSCFG0, INCR16BRSTENA, 3, 1) | ||
151 | + FIELD(GSBUSCFG0, INCR8BRSTENA, 2, 1) | ||
152 | + FIELD(GSBUSCFG0, INCR4BRSTENA, 1, 1) | ||
153 | + FIELD(GSBUSCFG0, INCRBRSTENA, 0, 1) | ||
154 | +REG32(GSBUSCFG1, 0x04) | ||
155 | + FIELD(GSBUSCFG1, RESERVED_31_13, 13, 19) | ||
156 | + FIELD(GSBUSCFG1, EN1KPAGE, 12, 1) | ||
157 | + FIELD(GSBUSCFG1, PIPETRANSLIMIT, 8, 4) | ||
158 | + FIELD(GSBUSCFG1, RESERVED_7_0, 0, 8) | ||
159 | +REG32(GTXTHRCFG, 0x08) | ||
160 | + FIELD(GTXTHRCFG, RESERVED_31, 31, 1) | ||
161 | + FIELD(GTXTHRCFG, RESERVED_30, 30, 1) | ||
162 | + FIELD(GTXTHRCFG, USBTXPKTCNTSEL, 29, 1) | ||
163 | + FIELD(GTXTHRCFG, RESERVED_28, 28, 1) | ||
164 | + FIELD(GTXTHRCFG, USBTXPKTCNT, 24, 4) | ||
165 | + FIELD(GTXTHRCFG, USBMAXTXBURSTSIZE, 16, 8) | ||
166 | + FIELD(GTXTHRCFG, RESERVED_15, 15, 1) | ||
167 | + FIELD(GTXTHRCFG, RESERVED_14, 14, 1) | ||
168 | + FIELD(GTXTHRCFG, RESERVED_13_11, 11, 3) | ||
169 | + FIELD(GTXTHRCFG, RESERVED_10_0, 0, 11) | ||
170 | +REG32(GRXTHRCFG, 0x0c) | ||
171 | + FIELD(GRXTHRCFG, RESERVED_31_30, 30, 2) | ||
172 | + FIELD(GRXTHRCFG, USBRXPKTCNTSEL, 29, 1) | ||
173 | + FIELD(GRXTHRCFG, RESERVED_28, 28, 1) | ||
174 | + FIELD(GRXTHRCFG, USBRXPKTCNT, 24, 4) | ||
175 | + FIELD(GRXTHRCFG, USBMAXRXBURSTSIZE, 19, 5) | ||
176 | + FIELD(GRXTHRCFG, RESERVED_18_16, 16, 3) | ||
177 | + FIELD(GRXTHRCFG, RESERVED_15, 15, 1) | ||
178 | + FIELD(GRXTHRCFG, RESERVED_14_13, 13, 2) | ||
179 | + FIELD(GRXTHRCFG, RESVISOCOUTSPC, 0, 13) | ||
180 | +REG32(GCTL, 0x10) | ||
181 | + FIELD(GCTL, PWRDNSCALE, 19, 13) | ||
182 | + FIELD(GCTL, MASTERFILTBYPASS, 18, 1) | ||
183 | + FIELD(GCTL, BYPSSETADDR, 17, 1) | ||
184 | + FIELD(GCTL, U2RSTECN, 16, 1) | ||
185 | + FIELD(GCTL, FRMSCLDWN, 14, 2) | ||
186 | + FIELD(GCTL, PRTCAPDIR, 12, 2) | ||
187 | + FIELD(GCTL, CORESOFTRESET, 11, 1) | ||
188 | + FIELD(GCTL, U1U2TIMERSCALE, 9, 1) | ||
189 | + FIELD(GCTL, DEBUGATTACH, 8, 1) | ||
190 | + FIELD(GCTL, RAMCLKSEL, 6, 2) | ||
191 | + FIELD(GCTL, SCALEDOWN, 4, 2) | ||
192 | + FIELD(GCTL, DISSCRAMBLE, 3, 1) | ||
193 | + FIELD(GCTL, U2EXIT_LFPS, 2, 1) | ||
194 | + FIELD(GCTL, GBLHIBERNATIONEN, 1, 1) | ||
195 | + FIELD(GCTL, DSBLCLKGTNG, 0, 1) | ||
196 | +REG32(GPMSTS, 0x14) | ||
197 | +REG32(GSTS, 0x18) | ||
198 | + FIELD(GSTS, CBELT, 20, 12) | ||
199 | + FIELD(GSTS, RESERVED_19_12, 12, 8) | ||
200 | + FIELD(GSTS, SSIC_IP, 11, 1) | ||
201 | + FIELD(GSTS, OTG_IP, 10, 1) | ||
202 | + FIELD(GSTS, BC_IP, 9, 1) | ||
203 | + FIELD(GSTS, ADP_IP, 8, 1) | ||
204 | + FIELD(GSTS, HOST_IP, 7, 1) | ||
205 | + FIELD(GSTS, DEVICE_IP, 6, 1) | ||
206 | + FIELD(GSTS, CSRTIMEOUT, 5, 1) | ||
207 | + FIELD(GSTS, BUSERRADDRVLD, 4, 1) | ||
208 | + FIELD(GSTS, RESERVED_3_2, 2, 2) | ||
209 | + FIELD(GSTS, CURMOD, 0, 2) | ||
210 | +REG32(GUCTL1, 0x1c) | ||
211 | + FIELD(GUCTL1, RESUME_OPMODE_HS_HOST, 10, 1) | ||
212 | +REG32(GSNPSID, 0x20) | ||
213 | +REG32(GGPIO, 0x24) | ||
214 | + FIELD(GGPIO, GPO, 16, 16) | ||
215 | + FIELD(GGPIO, GPI, 0, 16) | ||
216 | +REG32(GUID, 0x28) | ||
217 | +REG32(GUCTL, 0x2c) | ||
218 | + FIELD(GUCTL, REFCLKPER, 22, 10) | ||
219 | + FIELD(GUCTL, NOEXTRDL, 21, 1) | ||
220 | + FIELD(GUCTL, RESERVED_20_18, 18, 3) | ||
221 | + FIELD(GUCTL, SPRSCTRLTRANSEN, 17, 1) | ||
222 | + FIELD(GUCTL, RESBWHSEPS, 16, 1) | ||
223 | + FIELD(GUCTL, RESERVED_15, 15, 1) | ||
224 | + FIELD(GUCTL, USBHSTINAUTORETRYEN, 14, 1) | ||
225 | + FIELD(GUCTL, ENOVERLAPCHK, 13, 1) | ||
226 | + FIELD(GUCTL, EXTCAPSUPPTEN, 12, 1) | ||
227 | + FIELD(GUCTL, INSRTEXTRFSBODI, 11, 1) | ||
228 | + FIELD(GUCTL, DTCT, 9, 2) | ||
229 | + FIELD(GUCTL, DTFT, 0, 9) | ||
230 | +REG32(GBUSERRADDRLO, 0x30) | ||
231 | +REG32(GBUSERRADDRHI, 0x34) | ||
232 | +REG32(GHWPARAMS0, 0x40) | ||
233 | + FIELD(GHWPARAMS0, GHWPARAMS0_31_24, 24, 8) | ||
234 | + FIELD(GHWPARAMS0, GHWPARAMS0_23_16, 16, 8) | ||
235 | + FIELD(GHWPARAMS0, GHWPARAMS0_15_8, 8, 8) | ||
236 | + FIELD(GHWPARAMS0, GHWPARAMS0_7_6, 6, 2) | ||
237 | + FIELD(GHWPARAMS0, GHWPARAMS0_5_3, 3, 3) | ||
238 | + FIELD(GHWPARAMS0, GHWPARAMS0_2_0, 0, 3) | ||
239 | +REG32(GHWPARAMS1, 0x44) | ||
240 | + FIELD(GHWPARAMS1, GHWPARAMS1_31, 31, 1) | ||
241 | + FIELD(GHWPARAMS1, GHWPARAMS1_30, 30, 1) | ||
242 | + FIELD(GHWPARAMS1, GHWPARAMS1_29, 29, 1) | ||
243 | + FIELD(GHWPARAMS1, GHWPARAMS1_28, 28, 1) | ||
244 | + FIELD(GHWPARAMS1, GHWPARAMS1_27, 27, 1) | ||
245 | + FIELD(GHWPARAMS1, GHWPARAMS1_26, 26, 1) | ||
246 | + FIELD(GHWPARAMS1, GHWPARAMS1_25_24, 24, 2) | ||
247 | + FIELD(GHWPARAMS1, GHWPARAMS1_23, 23, 1) | ||
248 | + FIELD(GHWPARAMS1, GHWPARAMS1_22_21, 21, 2) | ||
249 | + FIELD(GHWPARAMS1, GHWPARAMS1_20_15, 15, 6) | ||
250 | + FIELD(GHWPARAMS1, GHWPARAMS1_14_12, 12, 3) | ||
251 | + FIELD(GHWPARAMS1, GHWPARAMS1_11_9, 9, 3) | ||
252 | + FIELD(GHWPARAMS1, GHWPARAMS1_8_6, 6, 3) | ||
253 | + FIELD(GHWPARAMS1, GHWPARAMS1_5_3, 3, 3) | ||
254 | + FIELD(GHWPARAMS1, GHWPARAMS1_2_0, 0, 3) | ||
255 | +REG32(GHWPARAMS2, 0x48) | ||
256 | +REG32(GHWPARAMS3, 0x4c) | ||
257 | + FIELD(GHWPARAMS3, GHWPARAMS3_31, 31, 1) | ||
258 | + FIELD(GHWPARAMS3, GHWPARAMS3_30_23, 23, 8) | ||
259 | + FIELD(GHWPARAMS3, GHWPARAMS3_22_18, 18, 5) | ||
260 | + FIELD(GHWPARAMS3, GHWPARAMS3_17_12, 12, 6) | ||
261 | + FIELD(GHWPARAMS3, GHWPARAMS3_11, 11, 1) | ||
262 | + FIELD(GHWPARAMS3, GHWPARAMS3_10, 10, 1) | ||
263 | + FIELD(GHWPARAMS3, GHWPARAMS3_9_8, 8, 2) | ||
264 | + FIELD(GHWPARAMS3, GHWPARAMS3_7_6, 6, 2) | ||
265 | + FIELD(GHWPARAMS3, GHWPARAMS3_5_4, 4, 2) | ||
266 | + FIELD(GHWPARAMS3, GHWPARAMS3_3_2, 2, 2) | ||
267 | + FIELD(GHWPARAMS3, GHWPARAMS3_1_0, 0, 2) | ||
268 | +REG32(GHWPARAMS4, 0x50) | ||
269 | + FIELD(GHWPARAMS4, GHWPARAMS4_31_28, 28, 4) | ||
270 | + FIELD(GHWPARAMS4, GHWPARAMS4_27_24, 24, 4) | ||
271 | + FIELD(GHWPARAMS4, GHWPARAMS4_23, 23, 1) | ||
272 | + FIELD(GHWPARAMS4, GHWPARAMS4_22, 22, 1) | ||
273 | + FIELD(GHWPARAMS4, GHWPARAMS4_21, 21, 1) | ||
274 | + FIELD(GHWPARAMS4, GHWPARAMS4_20_17, 17, 4) | ||
275 | + FIELD(GHWPARAMS4, GHWPARAMS4_16_13, 13, 4) | ||
276 | + FIELD(GHWPARAMS4, GHWPARAMS4_12, 12, 1) | ||
277 | + FIELD(GHWPARAMS4, GHWPARAMS4_11, 11, 1) | ||
278 | + FIELD(GHWPARAMS4, GHWPARAMS4_10_9, 9, 2) | ||
279 | + FIELD(GHWPARAMS4, GHWPARAMS4_8_7, 7, 2) | ||
280 | + FIELD(GHWPARAMS4, GHWPARAMS4_6, 6, 1) | ||
281 | + FIELD(GHWPARAMS4, GHWPARAMS4_5_0, 0, 6) | ||
282 | +REG32(GHWPARAMS5, 0x54) | ||
283 | + FIELD(GHWPARAMS5, GHWPARAMS5_31_28, 28, 4) | ||
284 | + FIELD(GHWPARAMS5, GHWPARAMS5_27_22, 22, 6) | ||
285 | + FIELD(GHWPARAMS5, GHWPARAMS5_21_16, 16, 6) | ||
286 | + FIELD(GHWPARAMS5, GHWPARAMS5_15_10, 10, 6) | ||
287 | + FIELD(GHWPARAMS5, GHWPARAMS5_9_4, 4, 6) | ||
288 | + FIELD(GHWPARAMS5, GHWPARAMS5_3_0, 0, 4) | ||
289 | +REG32(GHWPARAMS6, 0x58) | ||
290 | + FIELD(GHWPARAMS6, GHWPARAMS6_31_16, 16, 16) | ||
291 | + FIELD(GHWPARAMS6, BUSFLTRSSUPPORT, 15, 1) | ||
292 | + FIELD(GHWPARAMS6, BCSUPPORT, 14, 1) | ||
293 | + FIELD(GHWPARAMS6, OTG_SS_SUPPORT, 13, 1) | ||
294 | + FIELD(GHWPARAMS6, ADPSUPPORT, 12, 1) | ||
295 | + FIELD(GHWPARAMS6, HNPSUPPORT, 11, 1) | ||
296 | + FIELD(GHWPARAMS6, SRPSUPPORT, 10, 1) | ||
297 | + FIELD(GHWPARAMS6, GHWPARAMS6_9_8, 8, 2) | ||
298 | + FIELD(GHWPARAMS6, GHWPARAMS6_7, 7, 1) | ||
299 | + FIELD(GHWPARAMS6, GHWPARAMS6_6, 6, 1) | ||
300 | + FIELD(GHWPARAMS6, GHWPARAMS6_5_0, 0, 6) | ||
301 | +REG32(GHWPARAMS7, 0x5c) | ||
302 | + FIELD(GHWPARAMS7, GHWPARAMS7_31_16, 16, 16) | ||
303 | + FIELD(GHWPARAMS7, GHWPARAMS7_15_0, 0, 16) | ||
304 | +REG32(GDBGFIFOSPACE, 0x60) | ||
305 | + FIELD(GDBGFIFOSPACE, SPACE_AVAILABLE, 16, 16) | ||
306 | + FIELD(GDBGFIFOSPACE, RESERVED_15_9, 9, 7) | ||
307 | + FIELD(GDBGFIFOSPACE, FIFO_QUEUE_SELECT, 0, 9) | ||
308 | +REG32(GUCTL2, 0x9c) | ||
309 | + FIELD(GUCTL2, RESERVED_31_26, 26, 6) | ||
310 | + FIELD(GUCTL2, EN_HP_PM_TIMER, 19, 7) | ||
311 | + FIELD(GUCTL2, NOLOWPWRDUR, 15, 4) | ||
312 | + FIELD(GUCTL2, RST_ACTBITLATER, 14, 1) | ||
313 | + FIELD(GUCTL2, RESERVED_13, 13, 1) | ||
314 | + FIELD(GUCTL2, DISABLECFC, 11, 1) | ||
315 | +REG32(GUSB2PHYCFG, 0x100) | ||
316 | + FIELD(GUSB2PHYCFG, U2_FREECLK_EXISTS, 30, 1) | ||
317 | + FIELD(GUSB2PHYCFG, ULPI_LPM_WITH_OPMODE_CHK, 29, 1) | ||
318 | + FIELD(GUSB2PHYCFG, RESERVED_25, 25, 1) | ||
319 | + FIELD(GUSB2PHYCFG, LSTRD, 22, 3) | ||
320 | + FIELD(GUSB2PHYCFG, LSIPD, 19, 3) | ||
321 | + FIELD(GUSB2PHYCFG, ULPIEXTVBUSINDIACTOR, 18, 1) | ||
322 | + FIELD(GUSB2PHYCFG, ULPIEXTVBUSDRV, 17, 1) | ||
323 | + FIELD(GUSB2PHYCFG, RESERVED_16, 16, 1) | ||
324 | + FIELD(GUSB2PHYCFG, ULPIAUTORES, 15, 1) | ||
325 | + FIELD(GUSB2PHYCFG, RESERVED_14, 14, 1) | ||
326 | + FIELD(GUSB2PHYCFG, USBTRDTIM, 10, 4) | ||
327 | + FIELD(GUSB2PHYCFG, XCVRDLY, 9, 1) | ||
328 | + FIELD(GUSB2PHYCFG, ENBLSLPM, 8, 1) | ||
329 | + FIELD(GUSB2PHYCFG, PHYSEL, 7, 1) | ||
330 | + FIELD(GUSB2PHYCFG, SUSPENDUSB20, 6, 1) | ||
331 | + FIELD(GUSB2PHYCFG, FSINTF, 5, 1) | ||
332 | + FIELD(GUSB2PHYCFG, ULPI_UTMI_SEL, 4, 1) | ||
333 | + FIELD(GUSB2PHYCFG, PHYIF, 3, 1) | ||
334 | + FIELD(GUSB2PHYCFG, TOUTCAL, 0, 3) | ||
335 | +REG32(GUSB2I2CCTL, 0x140) | ||
336 | +REG32(GUSB2PHYACC_ULPI, 0x180) | ||
337 | + FIELD(GUSB2PHYACC_ULPI, RESERVED_31_27, 27, 5) | ||
338 | + FIELD(GUSB2PHYACC_ULPI, DISUIPIDRVR, 26, 1) | ||
339 | + FIELD(GUSB2PHYACC_ULPI, NEWREGREQ, 25, 1) | ||
340 | + FIELD(GUSB2PHYACC_ULPI, VSTSDONE, 24, 1) | ||
341 | + FIELD(GUSB2PHYACC_ULPI, VSTSBSY, 23, 1) | ||
342 | + FIELD(GUSB2PHYACC_ULPI, REGWR, 22, 1) | ||
343 | + FIELD(GUSB2PHYACC_ULPI, REGADDR, 16, 6) | ||
344 | + FIELD(GUSB2PHYACC_ULPI, EXTREGADDR, 8, 8) | ||
345 | + FIELD(GUSB2PHYACC_ULPI, REGDATA, 0, 8) | ||
346 | +REG32(GTXFIFOSIZ0, 0x200) | ||
347 | + FIELD(GTXFIFOSIZ0, TXFSTADDR_N, 16, 16) | ||
348 | + FIELD(GTXFIFOSIZ0, TXFDEP_N, 0, 16) | ||
349 | +REG32(GTXFIFOSIZ1, 0x204) | ||
350 | + FIELD(GTXFIFOSIZ1, TXFSTADDR_N, 16, 16) | ||
351 | + FIELD(GTXFIFOSIZ1, TXFDEP_N, 0, 16) | ||
352 | +REG32(GTXFIFOSIZ2, 0x208) | ||
353 | + FIELD(GTXFIFOSIZ2, TXFSTADDR_N, 16, 16) | ||
354 | + FIELD(GTXFIFOSIZ2, TXFDEP_N, 0, 16) | ||
355 | +REG32(GTXFIFOSIZ3, 0x20c) | ||
356 | + FIELD(GTXFIFOSIZ3, TXFSTADDR_N, 16, 16) | ||
357 | + FIELD(GTXFIFOSIZ3, TXFDEP_N, 0, 16) | ||
358 | +REG32(GTXFIFOSIZ4, 0x210) | ||
359 | + FIELD(GTXFIFOSIZ4, TXFSTADDR_N, 16, 16) | ||
360 | + FIELD(GTXFIFOSIZ4, TXFDEP_N, 0, 16) | ||
361 | +REG32(GTXFIFOSIZ5, 0x214) | ||
362 | + FIELD(GTXFIFOSIZ5, TXFSTADDR_N, 16, 16) | ||
363 | + FIELD(GTXFIFOSIZ5, TXFDEP_N, 0, 16) | ||
364 | +REG32(GRXFIFOSIZ0, 0x280) | ||
365 | + FIELD(GRXFIFOSIZ0, RXFSTADDR_N, 16, 16) | ||
366 | + FIELD(GRXFIFOSIZ0, RXFDEP_N, 0, 16) | ||
367 | +REG32(GRXFIFOSIZ1, 0x284) | ||
368 | + FIELD(GRXFIFOSIZ1, RXFSTADDR_N, 16, 16) | ||
369 | + FIELD(GRXFIFOSIZ1, RXFDEP_N, 0, 16) | ||
370 | +REG32(GRXFIFOSIZ2, 0x288) | ||
371 | + FIELD(GRXFIFOSIZ2, RXFSTADDR_N, 16, 16) | ||
372 | + FIELD(GRXFIFOSIZ2, RXFDEP_N, 0, 16) | ||
373 | +REG32(GEVNTADRLO_0, 0x300) | ||
374 | +REG32(GEVNTADRHI_0, 0x304) | ||
375 | +REG32(GEVNTSIZ_0, 0x308) | ||
376 | + FIELD(GEVNTSIZ_0, EVNTINTRPTMASK, 31, 1) | ||
377 | + FIELD(GEVNTSIZ_0, RESERVED_30_16, 16, 15) | ||
378 | + FIELD(GEVNTSIZ_0, EVENTSIZ, 0, 16) | ||
379 | +REG32(GEVNTCOUNT_0, 0x30c) | ||
380 | + FIELD(GEVNTCOUNT_0, EVNT_HANDLER_BUSY, 31, 1) | ||
381 | + FIELD(GEVNTCOUNT_0, RESERVED_30_16, 16, 15) | ||
382 | + FIELD(GEVNTCOUNT_0, EVNTCOUNT, 0, 16) | ||
383 | +REG32(GEVNTADRLO_1, 0x310) | ||
384 | +REG32(GEVNTADRHI_1, 0x314) | ||
385 | +REG32(GEVNTSIZ_1, 0x318) | ||
386 | + FIELD(GEVNTSIZ_1, EVNTINTRPTMASK, 31, 1) | ||
387 | + FIELD(GEVNTSIZ_1, RESERVED_30_16, 16, 15) | ||
388 | + FIELD(GEVNTSIZ_1, EVENTSIZ, 0, 16) | ||
389 | +REG32(GEVNTCOUNT_1, 0x31c) | ||
390 | + FIELD(GEVNTCOUNT_1, EVNT_HANDLER_BUSY, 31, 1) | ||
391 | + FIELD(GEVNTCOUNT_1, RESERVED_30_16, 16, 15) | ||
392 | + FIELD(GEVNTCOUNT_1, EVNTCOUNT, 0, 16) | ||
393 | +REG32(GEVNTADRLO_2, 0x320) | ||
394 | +REG32(GEVNTADRHI_2, 0x324) | ||
395 | +REG32(GEVNTSIZ_2, 0x328) | ||
396 | + FIELD(GEVNTSIZ_2, EVNTINTRPTMASK, 31, 1) | ||
397 | + FIELD(GEVNTSIZ_2, RESERVED_30_16, 16, 15) | ||
398 | + FIELD(GEVNTSIZ_2, EVENTSIZ, 0, 16) | ||
399 | +REG32(GEVNTCOUNT_2, 0x32c) | ||
400 | + FIELD(GEVNTCOUNT_2, EVNT_HANDLER_BUSY, 31, 1) | ||
401 | + FIELD(GEVNTCOUNT_2, RESERVED_30_16, 16, 15) | ||
402 | + FIELD(GEVNTCOUNT_2, EVNTCOUNT, 0, 16) | ||
403 | +REG32(GEVNTADRLO_3, 0x330) | ||
404 | +REG32(GEVNTADRHI_3, 0x334) | ||
405 | +REG32(GEVNTSIZ_3, 0x338) | ||
406 | + FIELD(GEVNTSIZ_3, EVNTINTRPTMASK, 31, 1) | ||
407 | + FIELD(GEVNTSIZ_3, RESERVED_30_16, 16, 15) | ||
408 | + FIELD(GEVNTSIZ_3, EVENTSIZ, 0, 16) | ||
409 | +REG32(GEVNTCOUNT_3, 0x33c) | ||
410 | + FIELD(GEVNTCOUNT_3, EVNT_HANDLER_BUSY, 31, 1) | ||
411 | + FIELD(GEVNTCOUNT_3, RESERVED_30_16, 16, 15) | ||
412 | + FIELD(GEVNTCOUNT_3, EVNTCOUNT, 0, 16) | ||
413 | +REG32(GHWPARAMS8, 0x500) | ||
414 | +REG32(GTXFIFOPRIDEV, 0x510) | ||
415 | + FIELD(GTXFIFOPRIDEV, RESERVED_31_N, 6, 26) | ||
416 | + FIELD(GTXFIFOPRIDEV, GTXFIFOPRIDEV, 0, 6) | ||
417 | +REG32(GTXFIFOPRIHST, 0x518) | ||
418 | + FIELD(GTXFIFOPRIHST, RESERVED_31_16, 3, 29) | ||
419 | + FIELD(GTXFIFOPRIHST, GTXFIFOPRIHST, 0, 3) | ||
420 | +REG32(GRXFIFOPRIHST, 0x51c) | ||
421 | + FIELD(GRXFIFOPRIHST, RESERVED_31_16, 3, 29) | ||
422 | + FIELD(GRXFIFOPRIHST, GRXFIFOPRIHST, 0, 3) | ||
423 | +REG32(GDMAHLRATIO, 0x524) | ||
424 | + FIELD(GDMAHLRATIO, RESERVED_31_13, 13, 19) | ||
425 | + FIELD(GDMAHLRATIO, HSTRXFIFO, 8, 5) | ||
426 | + FIELD(GDMAHLRATIO, RESERVED_7_5, 5, 3) | ||
427 | + FIELD(GDMAHLRATIO, HSTTXFIFO, 0, 5) | ||
428 | +REG32(GFLADJ, 0x530) | ||
429 | + FIELD(GFLADJ, GFLADJ_REFCLK_240MHZDECR_PLS1, 31, 1) | ||
430 | + FIELD(GFLADJ, GFLADJ_REFCLK_240MHZ_DECR, 24, 7) | ||
431 | + FIELD(GFLADJ, GFLADJ_REFCLK_LPM_SEL, 23, 1) | ||
432 | + FIELD(GFLADJ, RESERVED_22, 22, 1) | ||
433 | + FIELD(GFLADJ, GFLADJ_REFCLK_FLADJ, 8, 14) | ||
434 | + FIELD(GFLADJ, GFLADJ_30MHZ_SDBND_SEL, 7, 1) | ||
435 | + FIELD(GFLADJ, GFLADJ_30MHZ, 0, 6) | ||
436 | + | ||
437 | +#define DWC3_GLOBAL_OFFSET 0xC100 | ||
438 | +static void reset_csr(USBDWC3 * s) | ||
439 | +{ | ||
440 | + int i = 0; | ||
441 | + /* | ||
442 | + * We reset all CSR regs except GCTL, GUCTL, GSTS, GSNPSID, GGPIO, GUID, | ||
443 | + * GUSB2PHYCFGn registers and GUSB3PIPECTLn registers. We will skip PHY | ||
444 | + * register as we don't implement them. | ||
445 | + */ | ||
446 | + for (i = 0; i < USB_DWC3_R_MAX; i++) { | ||
447 | + switch (i) { | ||
448 | + case R_GCTL: | ||
449 | + break; | ||
450 | + case R_GSTS: | ||
451 | + break; | ||
452 | + case R_GSNPSID: | ||
453 | + break; | ||
454 | + case R_GGPIO: | ||
455 | + break; | ||
456 | + case R_GUID: | ||
457 | + break; | ||
458 | + case R_GUCTL: | ||
459 | + break; | ||
460 | + case R_GHWPARAMS0...R_GHWPARAMS7: | ||
461 | + break; | ||
462 | + case R_GHWPARAMS8: | ||
463 | + break; | ||
464 | + default: | ||
465 | + register_reset(&s->regs_info[i]); | ||
466 | + break; | ||
467 | + } | ||
468 | + } | ||
469 | + | ||
470 | + xhci_sysbus_reset(DEVICE(&s->sysbus_xhci)); | ||
471 | +} | ||
472 | + | ||
473 | +static void usb_dwc3_gctl_postw(RegisterInfo *reg, uint64_t val64) | ||
474 | +{ | ||
475 | + USBDWC3 *s = USB_DWC3(reg->opaque); | ||
476 | + | ||
477 | + if (ARRAY_FIELD_EX32(s->regs, GCTL, CORESOFTRESET)) { | ||
478 | + reset_csr(s); | ||
479 | + } | 49 | + } |
480 | +} | 50 | +} |
481 | + | 51 | + |
482 | +static void usb_dwc3_guid_postw(RegisterInfo *reg, uint64_t val64) | 52 | static const VMStateDescription vmstate_timers = { |
483 | +{ | 53 | .name = "mss-timer-block", |
484 | + USBDWC3 *s = USB_DWC3(reg->opaque); | 54 | .version_id = 1, |
485 | + | 55 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mss_timer_info = { |
486 | + s->regs[R_GUID] = s->cfg.dwc_usb3_user; | 56 | .parent = TYPE_SYS_BUS_DEVICE, |
487 | +} | 57 | .instance_size = sizeof(MSSTimerState), |
488 | + | 58 | .instance_init = mss_timer_init, |
489 | +static const RegisterAccessInfo usb_dwc3_regs_info[] = { | 59 | + .instance_finalize = mss_timer_finalize, |
490 | + { .name = "GSBUSCFG0", .addr = A_GSBUSCFG0, | 60 | .class_init = mss_timer_class_init, |
491 | + .ro = 0xf300, | 61 | }; |
492 | + .unimp = 0xffffffff, | 62 | |
493 | + },{ .name = "GSBUSCFG1", .addr = A_GSBUSCFG1, | ||
494 | + .reset = 0x300, | ||
495 | + .ro = 0xffffe0ff, | ||
496 | + .unimp = 0xffffffff, | ||
497 | + },{ .name = "GTXTHRCFG", .addr = A_GTXTHRCFG, | ||
498 | + .ro = 0xd000ffff, | ||
499 | + .unimp = 0xffffffff, | ||
500 | + },{ .name = "GRXTHRCFG", .addr = A_GRXTHRCFG, | ||
501 | + .ro = 0xd007e000, | ||
502 | + .unimp = 0xffffffff, | ||
503 | + },{ .name = "GCTL", .addr = A_GCTL, | ||
504 | + .reset = 0x30c13004, .post_write = usb_dwc3_gctl_postw, | ||
505 | + },{ .name = "GPMSTS", .addr = A_GPMSTS, | ||
506 | + .ro = 0xfffffff, | ||
507 | + .unimp = 0xffffffff, | ||
508 | + },{ .name = "GSTS", .addr = A_GSTS, | ||
509 | + .reset = 0x7e800000, | ||
510 | + .ro = 0xffffffcf, | ||
511 | + .w1c = 0x30, | ||
512 | + .unimp = 0xffffffff, | ||
513 | + },{ .name = "GUCTL1", .addr = A_GUCTL1, | ||
514 | + .reset = 0x198a, | ||
515 | + .ro = 0x7800, | ||
516 | + .unimp = 0xffffffff, | ||
517 | + },{ .name = "GSNPSID", .addr = A_GSNPSID, | ||
518 | + .reset = 0x5533330a, | ||
519 | + .ro = 0xffffffff, | ||
520 | + },{ .name = "GGPIO", .addr = A_GGPIO, | ||
521 | + .ro = 0xffff, | ||
522 | + .unimp = 0xffffffff, | ||
523 | + },{ .name = "GUID", .addr = A_GUID, | ||
524 | + .reset = 0x12345678, .post_write = usb_dwc3_guid_postw, | ||
525 | + },{ .name = "GUCTL", .addr = A_GUCTL, | ||
526 | + .reset = 0x0c808010, | ||
527 | + .ro = 0x1c8000, | ||
528 | + .unimp = 0xffffffff, | ||
529 | + },{ .name = "GBUSERRADDRLO", .addr = A_GBUSERRADDRLO, | ||
530 | + .ro = 0xffffffff, | ||
531 | + },{ .name = "GBUSERRADDRHI", .addr = A_GBUSERRADDRHI, | ||
532 | + .ro = 0xffffffff, | ||
533 | + },{ .name = "GHWPARAMS0", .addr = A_GHWPARAMS0, | ||
534 | + .ro = 0xffffffff, | ||
535 | + },{ .name = "GHWPARAMS1", .addr = A_GHWPARAMS1, | ||
536 | + .ro = 0xffffffff, | ||
537 | + },{ .name = "GHWPARAMS2", .addr = A_GHWPARAMS2, | ||
538 | + .ro = 0xffffffff, | ||
539 | + },{ .name = "GHWPARAMS3", .addr = A_GHWPARAMS3, | ||
540 | + .ro = 0xffffffff, | ||
541 | + },{ .name = "GHWPARAMS4", .addr = A_GHWPARAMS4, | ||
542 | + .ro = 0xffffffff, | ||
543 | + },{ .name = "GHWPARAMS5", .addr = A_GHWPARAMS5, | ||
544 | + .ro = 0xffffffff, | ||
545 | + },{ .name = "GHWPARAMS6", .addr = A_GHWPARAMS6, | ||
546 | + .ro = 0xffffffff, | ||
547 | + },{ .name = "GHWPARAMS7", .addr = A_GHWPARAMS7, | ||
548 | + .ro = 0xffffffff, | ||
549 | + },{ .name = "GDBGFIFOSPACE", .addr = A_GDBGFIFOSPACE, | ||
550 | + .reset = 0xa0000, | ||
551 | + .ro = 0xfffffe00, | ||
552 | + .unimp = 0xffffffff, | ||
553 | + },{ .name = "GUCTL2", .addr = A_GUCTL2, | ||
554 | + .reset = 0x40d, | ||
555 | + .ro = 0x2000, | ||
556 | + .unimp = 0xffffffff, | ||
557 | + },{ .name = "GUSB2PHYCFG", .addr = A_GUSB2PHYCFG, | ||
558 | + .reset = 0x40102410, | ||
559 | + .ro = 0x1e014030, | ||
560 | + .unimp = 0xffffffff, | ||
561 | + },{ .name = "GUSB2I2CCTL", .addr = A_GUSB2I2CCTL, | ||
562 | + .ro = 0xffffffff, | ||
563 | + .unimp = 0xffffffff, | ||
564 | + },{ .name = "GUSB2PHYACC_ULPI", .addr = A_GUSB2PHYACC_ULPI, | ||
565 | + .ro = 0xfd000000, | ||
566 | + .unimp = 0xffffffff, | ||
567 | + },{ .name = "GTXFIFOSIZ0", .addr = A_GTXFIFOSIZ0, | ||
568 | + .reset = 0x2c7000a, | ||
569 | + .unimp = 0xffffffff, | ||
570 | + },{ .name = "GTXFIFOSIZ1", .addr = A_GTXFIFOSIZ1, | ||
571 | + .reset = 0x2d10103, | ||
572 | + .unimp = 0xffffffff, | ||
573 | + },{ .name = "GTXFIFOSIZ2", .addr = A_GTXFIFOSIZ2, | ||
574 | + .reset = 0x3d40103, | ||
575 | + .unimp = 0xffffffff, | ||
576 | + },{ .name = "GTXFIFOSIZ3", .addr = A_GTXFIFOSIZ3, | ||
577 | + .reset = 0x4d70083, | ||
578 | + .unimp = 0xffffffff, | ||
579 | + },{ .name = "GTXFIFOSIZ4", .addr = A_GTXFIFOSIZ4, | ||
580 | + .reset = 0x55a0083, | ||
581 | + .unimp = 0xffffffff, | ||
582 | + },{ .name = "GTXFIFOSIZ5", .addr = A_GTXFIFOSIZ5, | ||
583 | + .reset = 0x5dd0083, | ||
584 | + .unimp = 0xffffffff, | ||
585 | + },{ .name = "GRXFIFOSIZ0", .addr = A_GRXFIFOSIZ0, | ||
586 | + .reset = 0x1c20105, | ||
587 | + .unimp = 0xffffffff, | ||
588 | + },{ .name = "GRXFIFOSIZ1", .addr = A_GRXFIFOSIZ1, | ||
589 | + .reset = 0x2c70000, | ||
590 | + .unimp = 0xffffffff, | ||
591 | + },{ .name = "GRXFIFOSIZ2", .addr = A_GRXFIFOSIZ2, | ||
592 | + .reset = 0x2c70000, | ||
593 | + .unimp = 0xffffffff, | ||
594 | + },{ .name = "GEVNTADRLO_0", .addr = A_GEVNTADRLO_0, | ||
595 | + .unimp = 0xffffffff, | ||
596 | + },{ .name = "GEVNTADRHI_0", .addr = A_GEVNTADRHI_0, | ||
597 | + .unimp = 0xffffffff, | ||
598 | + },{ .name = "GEVNTSIZ_0", .addr = A_GEVNTSIZ_0, | ||
599 | + .ro = 0x7fff0000, | ||
600 | + .unimp = 0xffffffff, | ||
601 | + },{ .name = "GEVNTCOUNT_0", .addr = A_GEVNTCOUNT_0, | ||
602 | + .ro = 0x7fff0000, | ||
603 | + .unimp = 0xffffffff, | ||
604 | + },{ .name = "GEVNTADRLO_1", .addr = A_GEVNTADRLO_1, | ||
605 | + .unimp = 0xffffffff, | ||
606 | + },{ .name = "GEVNTADRHI_1", .addr = A_GEVNTADRHI_1, | ||
607 | + .unimp = 0xffffffff, | ||
608 | + },{ .name = "GEVNTSIZ_1", .addr = A_GEVNTSIZ_1, | ||
609 | + .ro = 0x7fff0000, | ||
610 | + .unimp = 0xffffffff, | ||
611 | + },{ .name = "GEVNTCOUNT_1", .addr = A_GEVNTCOUNT_1, | ||
612 | + .ro = 0x7fff0000, | ||
613 | + .unimp = 0xffffffff, | ||
614 | + },{ .name = "GEVNTADRLO_2", .addr = A_GEVNTADRLO_2, | ||
615 | + .unimp = 0xffffffff, | ||
616 | + },{ .name = "GEVNTADRHI_2", .addr = A_GEVNTADRHI_2, | ||
617 | + .unimp = 0xffffffff, | ||
618 | + },{ .name = "GEVNTSIZ_2", .addr = A_GEVNTSIZ_2, | ||
619 | + .ro = 0x7fff0000, | ||
620 | + .unimp = 0xffffffff, | ||
621 | + },{ .name = "GEVNTCOUNT_2", .addr = A_GEVNTCOUNT_2, | ||
622 | + .ro = 0x7fff0000, | ||
623 | + .unimp = 0xffffffff, | ||
624 | + },{ .name = "GEVNTADRLO_3", .addr = A_GEVNTADRLO_3, | ||
625 | + .unimp = 0xffffffff, | ||
626 | + },{ .name = "GEVNTADRHI_3", .addr = A_GEVNTADRHI_3, | ||
627 | + .unimp = 0xffffffff, | ||
628 | + },{ .name = "GEVNTSIZ_3", .addr = A_GEVNTSIZ_3, | ||
629 | + .ro = 0x7fff0000, | ||
630 | + .unimp = 0xffffffff, | ||
631 | + },{ .name = "GEVNTCOUNT_3", .addr = A_GEVNTCOUNT_3, | ||
632 | + .ro = 0x7fff0000, | ||
633 | + .unimp = 0xffffffff, | ||
634 | + },{ .name = "GHWPARAMS8", .addr = A_GHWPARAMS8, | ||
635 | + .ro = 0xffffffff, | ||
636 | + },{ .name = "GTXFIFOPRIDEV", .addr = A_GTXFIFOPRIDEV, | ||
637 | + .ro = 0xffffffc0, | ||
638 | + .unimp = 0xffffffff, | ||
639 | + },{ .name = "GTXFIFOPRIHST", .addr = A_GTXFIFOPRIHST, | ||
640 | + .ro = 0xfffffff8, | ||
641 | + .unimp = 0xffffffff, | ||
642 | + },{ .name = "GRXFIFOPRIHST", .addr = A_GRXFIFOPRIHST, | ||
643 | + .ro = 0xfffffff8, | ||
644 | + .unimp = 0xffffffff, | ||
645 | + },{ .name = "GDMAHLRATIO", .addr = A_GDMAHLRATIO, | ||
646 | + .ro = 0xffffe0e0, | ||
647 | + .unimp = 0xffffffff, | ||
648 | + },{ .name = "GFLADJ", .addr = A_GFLADJ, | ||
649 | + .reset = 0xc83f020, | ||
650 | + .rsvd = 0x40, | ||
651 | + .ro = 0x400040, | ||
652 | + .unimp = 0xffffffff, | ||
653 | + } | ||
654 | +}; | ||
655 | + | ||
656 | +static void usb_dwc3_reset(DeviceState *dev) | ||
657 | +{ | ||
658 | + USBDWC3 *s = USB_DWC3(dev); | ||
659 | + unsigned int i; | ||
660 | + | ||
661 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
662 | + switch (i) { | ||
663 | + case R_GHWPARAMS0...R_GHWPARAMS7: | ||
664 | + break; | ||
665 | + case R_GHWPARAMS8: | ||
666 | + break; | ||
667 | + default: | ||
668 | + register_reset(&s->regs_info[i]); | ||
669 | + }; | ||
670 | + } | ||
671 | + | ||
672 | + xhci_sysbus_reset(DEVICE(&s->sysbus_xhci)); | ||
673 | +} | ||
674 | + | ||
675 | +static const MemoryRegionOps usb_dwc3_ops = { | ||
676 | + .read = register_read_memory, | ||
677 | + .write = register_write_memory, | ||
678 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
679 | + .valid = { | ||
680 | + .min_access_size = 4, | ||
681 | + .max_access_size = 4, | ||
682 | + }, | ||
683 | +}; | ||
684 | + | ||
685 | +static void usb_dwc3_realize(DeviceState *dev, Error **errp) | ||
686 | +{ | ||
687 | + USBDWC3 *s = USB_DWC3(dev); | ||
688 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
689 | + Error *err = NULL; | ||
690 | + | ||
691 | + sysbus_realize(SYS_BUS_DEVICE(&s->sysbus_xhci), &err); | ||
692 | + if (err) { | ||
693 | + error_propagate(errp, err); | ||
694 | + return; | ||
695 | + } | ||
696 | + | ||
697 | + memory_region_add_subregion(&s->iomem, 0, | ||
698 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->sysbus_xhci), 0)); | ||
699 | + sysbus_init_mmio(sbd, &s->iomem); | ||
700 | + | ||
701 | + /* | ||
702 | + * Device Configuration | ||
703 | + */ | ||
704 | + s->regs[R_GHWPARAMS0] = 0x40204048 | s->cfg.mode; | ||
705 | + s->regs[R_GHWPARAMS1] = 0x222493b; | ||
706 | + s->regs[R_GHWPARAMS2] = 0x12345678; | ||
707 | + s->regs[R_GHWPARAMS3] = 0x618c088; | ||
708 | + s->regs[R_GHWPARAMS4] = 0x47822004; | ||
709 | + s->regs[R_GHWPARAMS5] = 0x4202088; | ||
710 | + s->regs[R_GHWPARAMS6] = 0x7850c20; | ||
711 | + s->regs[R_GHWPARAMS7] = 0x0; | ||
712 | + s->regs[R_GHWPARAMS8] = 0x478; | ||
713 | +} | ||
714 | + | ||
715 | +static void usb_dwc3_init(Object *obj) | ||
716 | +{ | ||
717 | + USBDWC3 *s = USB_DWC3(obj); | ||
718 | + RegisterInfoArray *reg_array; | ||
719 | + | ||
720 | + memory_region_init(&s->iomem, obj, TYPE_USB_DWC3, DWC3_SIZE); | ||
721 | + reg_array = | ||
722 | + register_init_block32(DEVICE(obj), usb_dwc3_regs_info, | ||
723 | + ARRAY_SIZE(usb_dwc3_regs_info), | ||
724 | + s->regs_info, s->regs, | ||
725 | + &usb_dwc3_ops, | ||
726 | + USB_DWC3_ERR_DEBUG, | ||
727 | + USB_DWC3_R_MAX * 4); | ||
728 | + memory_region_add_subregion(&s->iomem, | ||
729 | + DWC3_GLOBAL_OFFSET, | ||
730 | + ®_array->mem); | ||
731 | + object_initialize_child(obj, "dwc3-xhci", &s->sysbus_xhci, | ||
732 | + TYPE_XHCI_SYSBUS); | ||
733 | + qdev_alias_all_properties(DEVICE(&s->sysbus_xhci), obj); | ||
734 | + | ||
735 | + s->cfg.mode = HOST_MODE; | ||
736 | +} | ||
737 | + | ||
738 | +static const VMStateDescription vmstate_usb_dwc3 = { | ||
739 | + .name = "usb-dwc3", | ||
740 | + .version_id = 1, | ||
741 | + .fields = (VMStateField[]) { | ||
742 | + VMSTATE_UINT32_ARRAY(regs, USBDWC3, USB_DWC3_R_MAX), | ||
743 | + VMSTATE_UINT8(cfg.mode, USBDWC3), | ||
744 | + VMSTATE_UINT32(cfg.dwc_usb3_user, USBDWC3), | ||
745 | + VMSTATE_END_OF_LIST() | ||
746 | + } | ||
747 | +}; | ||
748 | + | ||
749 | +static Property usb_dwc3_properties[] = { | ||
750 | + DEFINE_PROP_UINT32("DWC_USB3_USERID", USBDWC3, cfg.dwc_usb3_user, | ||
751 | + 0x12345678), | ||
752 | + DEFINE_PROP_END_OF_LIST(), | ||
753 | +}; | ||
754 | + | ||
755 | +static void usb_dwc3_class_init(ObjectClass *klass, void *data) | ||
756 | +{ | ||
757 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
758 | + | ||
759 | + dc->reset = usb_dwc3_reset; | ||
760 | + dc->realize = usb_dwc3_realize; | ||
761 | + dc->vmsd = &vmstate_usb_dwc3; | ||
762 | + device_class_set_props(dc, usb_dwc3_properties); | ||
763 | +} | ||
764 | + | ||
765 | +static const TypeInfo usb_dwc3_info = { | ||
766 | + .name = TYPE_USB_DWC3, | ||
767 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
768 | + .instance_size = sizeof(USBDWC3), | ||
769 | + .class_init = usb_dwc3_class_init, | ||
770 | + .instance_init = usb_dwc3_init, | ||
771 | +}; | ||
772 | + | ||
773 | +static void usb_dwc3_register_types(void) | ||
774 | +{ | ||
775 | + type_register_static(&usb_dwc3_info); | ||
776 | +} | ||
777 | + | ||
778 | +type_init(usb_dwc3_register_types) | ||
779 | diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig | ||
780 | index XXXXXXX..XXXXXXX 100644 | ||
781 | --- a/hw/usb/Kconfig | ||
782 | +++ b/hw/usb/Kconfig | ||
783 | @@ -XXX,XX +XXX,XX @@ config IMX_USBPHY | ||
784 | bool | ||
785 | default y | ||
786 | depends on USB | ||
787 | + | ||
788 | +config USB_DWC3 | ||
789 | + bool | ||
790 | + select USB_XHCI_SYSBUS | ||
791 | + select REGISTER | ||
792 | diff --git a/hw/usb/meson.build b/hw/usb/meson.build | ||
793 | index XXXXXXX..XXXXXXX 100644 | ||
794 | --- a/hw/usb/meson.build | ||
795 | +++ b/hw/usb/meson.build | ||
796 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_USB_XHCI_SYSBUS', if_true: files('hcd-xhci-sysbus.c | ||
797 | softmmu_ss.add(when: 'CONFIG_USB_XHCI_NEC', if_true: files('hcd-xhci-nec.c')) | ||
798 | softmmu_ss.add(when: 'CONFIG_USB_MUSB', if_true: files('hcd-musb.c')) | ||
799 | softmmu_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c')) | ||
800 | +softmmu_ss.add(when: 'CONFIG_USB_DWC3', if_true: files('hcd-dwc3.c')) | ||
801 | |||
802 | softmmu_ss.add(when: 'CONFIG_TUSB6010', if_true: files('tusb6010.c')) | ||
803 | softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('chipidea.c')) | ||
804 | -- | 63 | -- |
805 | 2.20.1 | 64 | 2.20.1 |
806 | 65 | ||
807 | 66 | diff view generated by jsdifflib |
1 | The openrisc code uses an old style of interrupt handling, where a | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | separate standalone set of qemu_irqs invoke a function | ||
3 | openrisc_pic_cpu_handler() which signals the interrupt to the CPU | ||
4 | proper by directly calling cpu_interrupt() and cpu_reset_interrupt(). | ||
5 | Because CPU objects now inherit (indirectly) from TYPE_DEVICE, they | ||
6 | can have GPIO input lines themselves, and the neater modern way to | ||
7 | implement this is to simply have the CPU object itself provide the | ||
8 | input IRQ lines. | ||
9 | 2 | ||
10 | Create GPIO inputs to the OpenRISC CPU object, and make the only user | 3 | When running device-introspect-test, a memory leak occurred in the |
11 | of cpu_openrisc_pic_init() wire up directly to those instead. | 4 | mv88w8618_pit_init function, so use ptimer_free() in the finalize function to |
5 | avoid it. | ||
12 | 6 | ||
13 | This allows us to delete the hw/openrisc/pic_cpu.c file entirely. | 7 | ASAN shows memory leak stack: |
14 | 8 | ||
15 | This fixes a trivial memory leak reported by Coverity of the IRQs | 9 | Indirect leak of 192 byte(s) in 4 object(s) allocated from: |
16 | allocated in cpu_openrisc_pic_init(). | 10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) |
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523 | ||
13 | #3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544 | ||
14 | #4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562 | ||
15 | #5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433 | ||
16 | #6 0xaaabf5bb2290 in mv88w8618_timer_init /qemu/hw/arm/musicpal.c:862 | ||
17 | #7 0xaaabf5bb2290 in mv88w8618_pit_init /qemu/hw/arm/musicpal.c:954 | ||
18 | #8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
19 | #9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
20 | #10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
21 | #11 0xaaabf5a95540 in qdev_device_help /qemu/softmmu/qdev-monitor.c:283 | ||
22 | #12 0xaaabf5a96940 in qmp_device_add /qemu/softmmu/qdev-monitor.c:801 | ||
17 | 23 | ||
18 | Fixes: Coverity CID 1421934 | 24 | Reported-by: Euler Robot <euler.robot@huawei.com> |
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Stafford Horne <shorne@gmail.com> | ||
21 | Message-id: 20201127225127.14770-4-peter.maydell@linaro.org | ||
22 | --- | 28 | --- |
23 | target/openrisc/cpu.h | 1 - | 29 | hw/arm/musicpal.c | 12 ++++++++++++ |
24 | hw/openrisc/openrisc_sim.c | 3 +- | 30 | 1 file changed, 12 insertions(+) |
25 | hw/openrisc/pic_cpu.c | 61 -------------------------------------- | ||
26 | target/openrisc/cpu.c | 32 ++++++++++++++++++++ | ||
27 | hw/openrisc/meson.build | 2 +- | ||
28 | 5 files changed, 34 insertions(+), 65 deletions(-) | ||
29 | delete mode 100644 hw/openrisc/pic_cpu.c | ||
30 | 31 | ||
31 | diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h | 32 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c |
32 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/openrisc/cpu.h | 34 | --- a/hw/arm/musicpal.c |
34 | +++ b/target/openrisc/cpu.h | 35 | +++ b/hw/arm/musicpal.c |
35 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUOpenRISCState { | 36 | @@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj) |
36 | uint32_t picmr; /* Interrupt mask register */ | 37 | sysbus_init_mmio(dev, &s->iomem); |
37 | uint32_t picsr; /* Interrupt contrl register*/ | ||
38 | #endif | ||
39 | - void *irq[32]; /* Interrupt irq input */ | ||
40 | } CPUOpenRISCState; | ||
41 | |||
42 | /** | ||
43 | diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/openrisc/openrisc_sim.c | ||
46 | +++ b/hw/openrisc/openrisc_sim.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static void main_cpu_reset(void *opaque) | ||
48 | |||
49 | static qemu_irq get_cpu_irq(OpenRISCCPU *cpus[], int cpunum, int irq_pin) | ||
50 | { | ||
51 | - return cpus[cpunum]->env.irq[irq_pin]; | ||
52 | + return qdev_get_gpio_in_named(DEVICE(cpus[cpunum]), "IRQ", irq_pin); | ||
53 | } | 38 | } |
54 | 39 | ||
55 | static void openrisc_sim_net_init(hwaddr base, hwaddr descriptors, | 40 | +static void mv88w8618_pit_finalize(Object *obj) |
56 | @@ -XXX,XX +XXX,XX @@ static void openrisc_sim_init(MachineState *machine) | ||
57 | fprintf(stderr, "Unable to find CPU definition!\n"); | ||
58 | exit(1); | ||
59 | } | ||
60 | - cpu_openrisc_pic_init(cpus[n]); | ||
61 | |||
62 | cpu_openrisc_clock_init(cpus[n]); | ||
63 | |||
64 | diff --git a/hw/openrisc/pic_cpu.c b/hw/openrisc/pic_cpu.c | ||
65 | deleted file mode 100644 | ||
66 | index XXXXXXX..XXXXXXX | ||
67 | --- a/hw/openrisc/pic_cpu.c | ||
68 | +++ /dev/null | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | -/* | ||
71 | - * OpenRISC Programmable Interrupt Controller support. | ||
72 | - * | ||
73 | - * Copyright (c) 2011-2012 Jia Liu <proljc@gmail.com> | ||
74 | - * Feng Gao <gf91597@gmail.com> | ||
75 | - * | ||
76 | - * This library is free software; you can redistribute it and/or | ||
77 | - * modify it under the terms of the GNU Lesser General Public | ||
78 | - * License as published by the Free Software Foundation; either | ||
79 | - * version 2.1 of the License, or (at your option) any later version. | ||
80 | - * | ||
81 | - * This library is distributed in the hope that it will be useful, | ||
82 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
83 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
84 | - * Lesser General Public License for more details. | ||
85 | - * | ||
86 | - * You should have received a copy of the GNU Lesser General Public | ||
87 | - * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
88 | - */ | ||
89 | - | ||
90 | -#include "qemu/osdep.h" | ||
91 | -#include "hw/irq.h" | ||
92 | -#include "cpu.h" | ||
93 | - | ||
94 | -/* OpenRISC pic handler */ | ||
95 | -static void openrisc_pic_cpu_handler(void *opaque, int irq, int level) | ||
96 | -{ | ||
97 | - OpenRISCCPU *cpu = (OpenRISCCPU *)opaque; | ||
98 | - CPUState *cs = CPU(cpu); | ||
99 | - uint32_t irq_bit; | ||
100 | - | ||
101 | - if (irq > 31 || irq < 0) { | ||
102 | - return; | ||
103 | - } | ||
104 | - | ||
105 | - irq_bit = 1U << irq; | ||
106 | - | ||
107 | - if (level) { | ||
108 | - cpu->env.picsr |= irq_bit; | ||
109 | - } else { | ||
110 | - cpu->env.picsr &= ~irq_bit; | ||
111 | - } | ||
112 | - | ||
113 | - if (cpu->env.picsr & cpu->env.picmr) { | ||
114 | - cpu_interrupt(cs, CPU_INTERRUPT_HARD); | ||
115 | - } else { | ||
116 | - cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); | ||
117 | - cpu->env.picsr = 0; | ||
118 | - } | ||
119 | -} | ||
120 | - | ||
121 | -void cpu_openrisc_pic_init(OpenRISCCPU *cpu) | ||
122 | -{ | ||
123 | - int i; | ||
124 | - qemu_irq *qi; | ||
125 | - qi = qemu_allocate_irqs(openrisc_pic_cpu_handler, cpu, NR_IRQS); | ||
126 | - | ||
127 | - for (i = 0; i < NR_IRQS; i++) { | ||
128 | - cpu->env.irq[i] = qi[i]; | ||
129 | - } | ||
130 | -} | ||
131 | diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/openrisc/cpu.c | ||
134 | +++ b/target/openrisc/cpu.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_reset(DeviceState *dev) | ||
136 | #endif | ||
137 | } | ||
138 | |||
139 | +#ifndef CONFIG_USER_ONLY | ||
140 | +static void openrisc_cpu_set_irq(void *opaque, int irq, int level) | ||
141 | +{ | 41 | +{ |
142 | + OpenRISCCPU *cpu = (OpenRISCCPU *)opaque; | 42 | + SysBusDevice *dev = SYS_BUS_DEVICE(obj); |
143 | + CPUState *cs = CPU(cpu); | 43 | + mv88w8618_pit_state *s = MV88W8618_PIT(dev); |
144 | + uint32_t irq_bit; | 44 | + int i; |
145 | + | 45 | + |
146 | + if (irq > 31 || irq < 0) { | 46 | + for (i = 0; i < 4; i++) { |
147 | + return; | 47 | + ptimer_free(s->timer[i].ptimer); |
148 | + } | ||
149 | + | ||
150 | + irq_bit = 1U << irq; | ||
151 | + | ||
152 | + if (level) { | ||
153 | + cpu->env.picsr |= irq_bit; | ||
154 | + } else { | ||
155 | + cpu->env.picsr &= ~irq_bit; | ||
156 | + } | ||
157 | + | ||
158 | + if (cpu->env.picsr & cpu->env.picmr) { | ||
159 | + cpu_interrupt(cs, CPU_INTERRUPT_HARD); | ||
160 | + } else { | ||
161 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); | ||
162 | + cpu->env.picsr = 0; | ||
163 | + } | 48 | + } |
164 | +} | 49 | +} |
165 | +#endif | ||
166 | + | 50 | + |
167 | static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp) | 51 | static const VMStateDescription mv88w8618_timer_vmsd = { |
168 | { | 52 | .name = "timer", |
169 | CPUState *cs = CPU(dev); | 53 | .version_id = 1, |
170 | @@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_initfn(Object *obj) | 54 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo mv88w8618_pit_info = { |
171 | OpenRISCCPU *cpu = OPENRISC_CPU(obj); | 55 | .parent = TYPE_SYS_BUS_DEVICE, |
172 | 56 | .instance_size = sizeof(mv88w8618_pit_state), | |
173 | cpu_set_cpustate_pointers(cpu); | 57 | .instance_init = mv88w8618_pit_init, |
174 | + | 58 | + .instance_finalize = mv88w8618_pit_finalize, |
175 | +#ifndef CONFIG_USER_ONLY | 59 | .class_init = mv88w8618_pit_class_init, |
176 | + qdev_init_gpio_in_named(DEVICE(cpu), openrisc_cpu_set_irq, "IRQ", NR_IRQS); | 60 | }; |
177 | +#endif | 61 | |
178 | } | ||
179 | |||
180 | /* CPU models */ | ||
181 | diff --git a/hw/openrisc/meson.build b/hw/openrisc/meson.build | ||
182 | index XXXXXXX..XXXXXXX 100644 | ||
183 | --- a/hw/openrisc/meson.build | ||
184 | +++ b/hw/openrisc/meson.build | ||
185 | @@ -XXX,XX +XXX,XX @@ | ||
186 | openrisc_ss = ss.source_set() | ||
187 | -openrisc_ss.add(files('pic_cpu.c', 'cputimer.c')) | ||
188 | +openrisc_ss.add(files('cputimer.c')) | ||
189 | openrisc_ss.add(when: 'CONFIG_OR1K_SIM', if_true: files('openrisc_sim.c')) | ||
190 | |||
191 | hw_arch += {'openrisc': openrisc_ss} | ||
192 | -- | 62 | -- |
193 | 2.20.1 | 63 | 2.20.1 |
194 | 64 | ||
195 | 65 | diff view generated by jsdifflib |
1 | The function nios2_check_interrupts)() looks only at CPU-internal | 1 | From: Gan Qixin <ganqixin@huawei.com> |
---|---|---|---|
2 | state; it belongs in target/nios2, not hw/nios2. Move it into the | ||
3 | same file as its only caller, so it can just be local to that file. | ||
4 | 2 | ||
5 | This removes the only remaining code from cpu_pic.c, so we can delete | 3 | When running device-introspect-test, a memory leak occurred in the |
6 | that file entirely. | 4 | exynos4210_mct_init function, so use ptimer_free() in the finalize function to |
5 | avoid it. | ||
7 | 6 | ||
7 | ASAN shows memory leak stack: | ||
8 | |||
9 | Indirect leak of 96 byte(s) in 1 object(s) allocated from: | ||
10 | #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) | ||
11 | #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) | ||
12 | #2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432 | ||
13 | #3 0xaaabf56b01a0 in exynos4210_mct_init /qemu/hw/timer/exynos4210_mct.c:1505 | ||
14 | #4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515 | ||
15 | #5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729 | ||
16 | #6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153 | ||
17 | #7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59 | ||
18 | #8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110 | ||
19 | #9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136 | ||
20 | #10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164 | ||
21 | #11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381 | ||
22 | #12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306 | ||
23 | |||
24 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
25 | Signed-off-by: Gan Qixin <ganqixin@huawei.com> | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20201129174022.26530-3-peter.maydell@linaro.org | ||
11 | Reviewed-by: Wentong Wu <wentong.wu@intel.com> | ||
12 | Tested-by: Wentong Wu <wentong.wu@intel.com> | ||
13 | --- | 28 | --- |
14 | target/nios2/cpu.h | 2 -- | 29 | hw/timer/exynos4210_mct.c | 14 ++++++++++++++ |
15 | hw/nios2/cpu_pic.c | 36 ------------------------------------ | 30 | 1 file changed, 14 insertions(+) |
16 | target/nios2/op_helper.c | 9 +++++++++ | ||
17 | hw/nios2/meson.build | 2 +- | ||
18 | 4 files changed, 10 insertions(+), 39 deletions(-) | ||
19 | delete mode 100644 hw/nios2/cpu_pic.c | ||
20 | 31 | ||
21 | diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h | 32 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c |
22 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/nios2/cpu.h | 34 | --- a/hw/timer/exynos4210_mct.c |
24 | +++ b/target/nios2/cpu.h | 35 | +++ b/hw/timer/exynos4210_mct.c |
25 | @@ -XXX,XX +XXX,XX @@ void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, | 36 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj) |
26 | MMUAccessType access_type, | 37 | sysbus_init_mmio(dev, &s->iomem); |
27 | int mmu_idx, uintptr_t retaddr); | ||
28 | |||
29 | -void nios2_check_interrupts(CPUNios2State *env); | ||
30 | - | ||
31 | void do_nios2_semihosting(CPUNios2State *env); | ||
32 | |||
33 | #define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU | ||
34 | diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c | ||
35 | deleted file mode 100644 | ||
36 | index XXXXXXX..XXXXXXX | ||
37 | --- a/hw/nios2/cpu_pic.c | ||
38 | +++ /dev/null | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | -/* | ||
41 | - * Altera Nios2 CPU PIC | ||
42 | - * | ||
43 | - * Copyright (c) 2016 Marek Vasut <marek.vasut@gmail.com> | ||
44 | - * | ||
45 | - * This library is free software; you can redistribute it and/or | ||
46 | - * modify it under the terms of the GNU Lesser General Public | ||
47 | - * License as published by the Free Software Foundation; either | ||
48 | - * version 2.1 of the License, or (at your option) any later version. | ||
49 | - * | ||
50 | - * This library is distributed in the hope that it will be useful, | ||
51 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
52 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
53 | - * Lesser General Public License for more details. | ||
54 | - * | ||
55 | - * You should have received a copy of the GNU Lesser General Public | ||
56 | - * License along with this library; if not, see | ||
57 | - * <http://www.gnu.org/licenses/lgpl-2.1.html> | ||
58 | - */ | ||
59 | - | ||
60 | -#include "qemu/osdep.h" | ||
61 | -#include "cpu.h" | ||
62 | -#include "hw/irq.h" | ||
63 | - | ||
64 | -#include "qemu/config-file.h" | ||
65 | - | ||
66 | -#include "boot.h" | ||
67 | - | ||
68 | -void nios2_check_interrupts(CPUNios2State *env) | ||
69 | -{ | ||
70 | - if (env->irq_pending && | ||
71 | - (env->regs[CR_STATUS] & CR_STATUS_PIE)) { | ||
72 | - env->irq_pending = 0; | ||
73 | - cpu_interrupt(env_cpu(env), CPU_INTERRUPT_HARD); | ||
74 | - } | ||
75 | -} | ||
76 | diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/nios2/op_helper.c | ||
79 | +++ b/target/nios2/op_helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ void helper_mmu_write(CPUNios2State *env, uint32_t rn, uint32_t v) | ||
81 | mmu_write(env, rn, v); | ||
82 | } | 38 | } |
83 | 39 | ||
84 | +static void nios2_check_interrupts(CPUNios2State *env) | 40 | +static void exynos4210_mct_finalize(Object *obj) |
85 | +{ | 41 | +{ |
86 | + if (env->irq_pending && | 42 | + int i; |
87 | + (env->regs[CR_STATUS] & CR_STATUS_PIE)) { | 43 | + Exynos4210MCTState *s = EXYNOS4210_MCT(obj); |
88 | + env->irq_pending = 0; | 44 | + |
89 | + cpu_interrupt(env_cpu(env), CPU_INTERRUPT_HARD); | 45 | + ptimer_free(s->g_timer.ptimer_frc); |
46 | + | ||
47 | + for (i = 0; i < 2; i++) { | ||
48 | + ptimer_free(s->l_timer[i].tick_timer.ptimer_tick); | ||
49 | + ptimer_free(s->l_timer[i].ptimer_frc); | ||
90 | + } | 50 | + } |
91 | +} | 51 | +} |
92 | + | 52 | + |
93 | void helper_check_interrupts(CPUNios2State *env) | 53 | static void exynos4210_mct_class_init(ObjectClass *klass, void *data) |
94 | { | 54 | { |
95 | qemu_mutex_lock_iothread(); | 55 | DeviceClass *dc = DEVICE_CLASS(klass); |
96 | diff --git a/hw/nios2/meson.build b/hw/nios2/meson.build | 56 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = { |
97 | index XXXXXXX..XXXXXXX 100644 | 57 | .parent = TYPE_SYS_BUS_DEVICE, |
98 | --- a/hw/nios2/meson.build | 58 | .instance_size = sizeof(Exynos4210MCTState), |
99 | +++ b/hw/nios2/meson.build | 59 | .instance_init = exynos4210_mct_init, |
100 | @@ -XXX,XX +XXX,XX @@ | 60 | + .instance_finalize = exynos4210_mct_finalize, |
101 | nios2_ss = ss.source_set() | 61 | .class_init = exynos4210_mct_class_init, |
102 | -nios2_ss.add(files('boot.c', 'cpu_pic.c')) | 62 | }; |
103 | +nios2_ss.add(files('boot.c')) | ||
104 | nios2_ss.add(when: 'CONFIG_NIOS2_10M50', if_true: files('10m50_devboard.c')) | ||
105 | nios2_ss.add(when: 'CONFIG_NIOS2_GENERIC_NOMMU', if_true: files('generic_nommu.c')) | ||
106 | 63 | ||
107 | -- | 64 | -- |
108 | 2.20.1 | 65 | 2.20.1 |
109 | 66 | ||
110 | 67 | diff view generated by jsdifflib |
1 | In the vCont packet, two of the command actions (C and S) take an | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | argument specifying the signal to be sent to the process/thread, which is | ||
3 | sent as an ASCII string of two hex digits which immediately follow the | ||
4 | 'C' or 'S' character. | ||
5 | 2 | ||
6 | Our code for parsing this packet accidentally skipped the first of the | 3 | U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap() |
7 | two bytes of the signal value, because it started parsing the hex string | 4 | in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the |
8 | at 'p + 1' when the preceding code had already moved past the 'C' or | 5 | bandgap has stabilized. |
9 | 'S' with "cur_action = *p++". | ||
10 | 6 | ||
11 | This meant that we would only do the right thing for signals below | 7 | With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6 |
12 | 10, and would misinterpret the rest. For instance, when the debugger | 8 | sabrelite board (mx6qsabrelite_defconfig), with a slight change made |
13 | wants to send the process a SIGPROF (27 on x86-64) we mangle this into | 9 | by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot |
14 | a SIGSEGV (11). | 10 | shell on QEMU with the following command: |
15 | 11 | ||
16 | Remove the accidental double increment. | 12 | $ qemu-system-arm -M sabrelite -smp 4 -m 1G -kernel u-boot \ |
13 | -display none -serial null -serial stdio | ||
17 | 14 | ||
18 | Fixes: https://bugs.launchpad.net/qemu/+bug/1773743 | 15 | Boot log below: |
16 | |||
17 | U-Boot 2021.01-rc3 (Dec 12 2020 - 17:40:02 +0800) | ||
18 | |||
19 | CPU: Freescale i.MX?? rev1.0 at 792 MHz | ||
20 | Reset cause: POR | ||
21 | Model: Freescale i.MX6 Quad SABRE Lite Board | ||
22 | Board: SABRE Lite | ||
23 | I2C: ready | ||
24 | DRAM: 1 GiB | ||
25 | force_idle_bus: sda=0 scl=0 sda.gp=0x5c scl.gp=0x55 | ||
26 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
27 | force_idle_bus: sda=0 scl=0 sda.gp=0x6d scl.gp=0x6c | ||
28 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
29 | force_idle_bus: sda=0 scl=0 sda.gp=0xcb scl.gp=0x5 | ||
30 | force_idle_bus: failed to clear bus, sda=0 scl=0 | ||
31 | MMC: FSL_SDHC: 0, FSL_SDHC: 1 | ||
32 | Loading Environment from MMC... *** Warning - No block device, using default environment | ||
33 | |||
34 | In: serial | ||
35 | Out: serial | ||
36 | Err: serial | ||
37 | Net: Board Net Initialization Failed | ||
38 | No ethernet found. | ||
39 | starting USB... | ||
40 | Bus usb@2184000: usb dr_mode not found | ||
41 | USB EHCI 1.00 | ||
42 | Bus usb@2184200: USB EHCI 1.00 | ||
43 | scanning bus usb@2184000 for devices... 1 USB Device(s) found | ||
44 | scanning bus usb@2184200 for devices... 1 USB Device(s) found | ||
45 | scanning usb for storage devices... 0 Storage Device(s) found | ||
46 | scanning usb for ethernet devices... 0 Ethernet Device(s) found | ||
47 | Hit any key to stop autoboot: 0 | ||
48 | => | ||
49 | |||
50 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
51 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
52 | Message-id: 20210106063504.10841-2-bmeng.cn@gmail.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 53 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
21 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
22 | Message-id: 20201121210342.10089-1-peter.maydell@linaro.org | ||
23 | --- | 54 | --- |
24 | gdbstub.c | 2 +- | 55 | hw/misc/imx6_ccm.c | 2 +- |
25 | 1 file changed, 1 insertion(+), 1 deletion(-) | 56 | 1 file changed, 1 insertion(+), 1 deletion(-) |
26 | 57 | ||
27 | diff --git a/gdbstub.c b/gdbstub.c | 58 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c |
28 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/gdbstub.c | 60 | --- a/hw/misc/imx6_ccm.c |
30 | +++ b/gdbstub.c | 61 | +++ b/hw/misc/imx6_ccm.c |
31 | @@ -XXX,XX +XXX,XX @@ static int gdb_handle_vcont(const char *p) | 62 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) |
32 | cur_action = *p++; | 63 | s->analog[PMU_REG_3P0] = 0x00000F74; |
33 | if (cur_action == 'C' || cur_action == 'S') { | 64 | s->analog[PMU_REG_2P5] = 0x00005071; |
34 | cur_action = qemu_tolower(cur_action); | 65 | s->analog[PMU_REG_CORE] = 0x00402010; |
35 | - res = qemu_strtoul(p + 1, &p, 16, &tmp); | 66 | - s->analog[PMU_MISC0] = 0x04000000; |
36 | + res = qemu_strtoul(p, &p, 16, &tmp); | 67 | + s->analog[PMU_MISC0] = 0x04000080; |
37 | if (res) { | 68 | s->analog[PMU_MISC1] = 0x00000000; |
38 | goto out; | 69 | s->analog[PMU_MISC2] = 0x00272727; |
39 | } | 70 | |
40 | -- | 71 | -- |
41 | 2.20.1 | 72 | 2.20.1 |
42 | 73 | ||
43 | 74 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | VCFG XIP is set (disabled) when the NVCFG XIP bits are all set (disabled). | 3 | Currently when U-Boot boots, it prints "??" for i.MX processor: |
4 | 4 | ||
5 | Signed-off-by: Joe Komlodi <komlodi@xilinx.com> | 5 | CPU: Freescale i.MX?? rev1.0 at 792 MHz |
6 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> | 6 | |
7 | Message-id: 1605568264-26376-3-git-send-email-komlodi@xilinx.com | 7 | The register that was used to determine the silicon type is |
8 | undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we | ||
9 | can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in | ||
10 | the U-Boot source codes that USB_ANALOG_DIGPROG is used. | ||
11 | |||
12 | Update its reset value to indicate i.MX6Q. | ||
13 | |||
14 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
15 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
16 | Message-id: 20210106063504.10841-3-bmeng.cn@gmail.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 18 | --- |
10 | hw/block/m25p80.c | 2 +- | 19 | hw/misc/imx6_ccm.c | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 20 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 21 | ||
13 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 22 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/block/m25p80.c | 24 | --- a/hw/misc/imx6_ccm.c |
16 | +++ b/hw/block/m25p80.c | 25 | +++ b/hw/misc/imx6_ccm.c |
17 | @@ -XXX,XX +XXX,XX @@ static void reset_memory(Flash *s) | 26 | @@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev) |
18 | s->volatile_cfg |= VCFG_DUMMY; | 27 | s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004; |
19 | s->volatile_cfg |= VCFG_WRAP_SEQUENTIAL; | 28 | s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000; |
20 | if ((s->nonvolatile_cfg & NVCFG_XIP_MODE_MASK) | 29 | s->analog[USB_ANALOG_USB2_MISC] = 0x00000002; |
21 | - != NVCFG_XIP_MODE_DISABLED) { | 30 | - s->analog[USB_ANALOG_DIGPROG] = 0x00000000; |
22 | + == NVCFG_XIP_MODE_DISABLED) { | 31 | + s->analog[USB_ANALOG_DIGPROG] = 0x00630000; |
23 | s->volatile_cfg |= VCFG_XIP_MODE_DISABLED; | 32 | |
24 | } | 33 | /* all PLLs need to be locked */ |
25 | s->volatile_cfg |= deposit32(s->volatile_cfg, | 34 | s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK; |
26 | -- | 35 | -- |
27 | 2.20.1 | 36 | 2.20.1 |
28 | 37 | ||
29 | 38 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | The previous naming of the configuration registers made it sound like that if | 3 | At present, when booting U-Boot on QEMU sabrelite, we see: |
4 | the bits were set the settings would be enabled, while the opposite is true. | ||
5 | 4 | ||
6 | Signed-off-by: Joe Komlodi <komlodi@xilinx.com> | 5 | Net: Board Net Initialization Failed |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> | 6 | No ethernet found. |
8 | Message-id: 1605568264-26376-2-git-send-email-komlodi@xilinx.com | 7 | |
8 | U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the | ||
9 | U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real | ||
10 | board, the Ethernet PHY is at address 6. Adjust this by updating the | ||
11 | "fec-phy-num" property of the fsl_imx6 SoC object. | ||
12 | |||
13 | With this change, U-Boot sees the PHY but complains MAC address: | ||
14 | |||
15 | Net: using phy at 6 | ||
16 | FEC [PRIME] | ||
17 | Error: FEC address not set. | ||
18 | |||
19 | This is due to U-Boot tries to read the MAC address from the fuse, | ||
20 | which QEMU does not have any valid content filled in. However this | ||
21 | does not prevent the Ethernet from working in QEMU. We just need to | ||
22 | set up the MAC address later in the U-Boot command shell, by: | ||
23 | |||
24 | => setenv ethaddr 00:11:22:33:44:55 | ||
25 | |||
26 | Signed-off-by: Bin Meng <bin.meng@windriver.com> | ||
27 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
28 | Message-id: 20210106063504.10841-4-bmeng.cn@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 30 | --- |
11 | hw/block/m25p80.c | 12 ++++++------ | 31 | hw/arm/sabrelite.c | 4 ++++ |
12 | 1 file changed, 6 insertions(+), 6 deletions(-) | 32 | 1 file changed, 4 insertions(+) |
13 | 33 | ||
14 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 34 | diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c |
15 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/block/m25p80.c | 36 | --- a/hw/arm/sabrelite.c |
17 | +++ b/hw/block/m25p80.c | 37 | +++ b/hw/arm/sabrelite.c |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct FlashPartInfo { | 38 | @@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine) |
19 | #define VCFG_WRAP_SEQUENTIAL 0x2 | 39 | |
20 | #define NVCFG_XIP_MODE_DISABLED (7 << 9) | 40 | s = FSL_IMX6(object_new(TYPE_FSL_IMX6)); |
21 | #define NVCFG_XIP_MODE_MASK (7 << 9) | 41 | object_property_add_child(OBJECT(machine), "soc", OBJECT(s)); |
22 | -#define VCFG_XIP_MODE_ENABLED (1 << 3) | 42 | + |
23 | +#define VCFG_XIP_MODE_DISABLED (1 << 3) | 43 | + /* Ethernet PHY address is 6 */ |
24 | #define CFG_DUMMY_CLK_LEN 4 | 44 | + object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal); |
25 | #define NVCFG_DUMMY_CLK_POS 12 | 45 | + |
26 | #define VCFG_DUMMY_CLK_POS 4 | 46 | qdev_realize(DEVICE(s), NULL, &error_fatal); |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct FlashPartInfo { | 47 | |
28 | #define EVCFG_VPP_ACCELERATOR (1 << 3) | 48 | memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR, |
29 | #define EVCFG_RESET_HOLD_ENABLED (1 << 4) | ||
30 | #define NVCFG_DUAL_IO_MASK (1 << 2) | ||
31 | -#define EVCFG_DUAL_IO_ENABLED (1 << 6) | ||
32 | +#define EVCFG_DUAL_IO_DISABLED (1 << 6) | ||
33 | #define NVCFG_QUAD_IO_MASK (1 << 3) | ||
34 | -#define EVCFG_QUAD_IO_ENABLED (1 << 7) | ||
35 | +#define EVCFG_QUAD_IO_DISABLED (1 << 7) | ||
36 | #define NVCFG_4BYTE_ADDR_MASK (1 << 0) | ||
37 | #define NVCFG_LOWER_SEGMENT_MASK (1 << 1) | ||
38 | |||
39 | @@ -XXX,XX +XXX,XX @@ static void reset_memory(Flash *s) | ||
40 | s->volatile_cfg |= VCFG_WRAP_SEQUENTIAL; | ||
41 | if ((s->nonvolatile_cfg & NVCFG_XIP_MODE_MASK) | ||
42 | != NVCFG_XIP_MODE_DISABLED) { | ||
43 | - s->volatile_cfg |= VCFG_XIP_MODE_ENABLED; | ||
44 | + s->volatile_cfg |= VCFG_XIP_MODE_DISABLED; | ||
45 | } | ||
46 | s->volatile_cfg |= deposit32(s->volatile_cfg, | ||
47 | VCFG_DUMMY_CLK_POS, | ||
48 | @@ -XXX,XX +XXX,XX @@ static void reset_memory(Flash *s) | ||
49 | s->enh_volatile_cfg |= EVCFG_VPP_ACCELERATOR; | ||
50 | s->enh_volatile_cfg |= EVCFG_RESET_HOLD_ENABLED; | ||
51 | if (s->nonvolatile_cfg & NVCFG_DUAL_IO_MASK) { | ||
52 | - s->enh_volatile_cfg |= EVCFG_DUAL_IO_ENABLED; | ||
53 | + s->enh_volatile_cfg |= EVCFG_DUAL_IO_DISABLED; | ||
54 | } | ||
55 | if (s->nonvolatile_cfg & NVCFG_QUAD_IO_MASK) { | ||
56 | - s->enh_volatile_cfg |= EVCFG_QUAD_IO_ENABLED; | ||
57 | + s->enh_volatile_cfg |= EVCFG_QUAD_IO_DISABLED; | ||
58 | } | ||
59 | if (!(s->nonvolatile_cfg & NVCFG_4BYTE_ADDR_MASK)) { | ||
60 | s->four_bytes_address_mode = true; | ||
61 | -- | 49 | -- |
62 | 2.20.1 | 50 | 2.20.1 |
63 | 51 | ||
64 | 52 | diff view generated by jsdifflib |
1 | From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 1 | From: Bin Meng <bin.meng@windriver.com> |
---|---|---|---|
2 | 2 | ||
3 | This module emulates control registers of versal usb2 controller, this is added | 3 | This adds the target guide for SABRE Lite board, and documents how |
4 | just to make guest happy. In general this module would control the phy-reset | 4 | to boot a Linux kernel and U-Boot bootloader. |
5 | signal from usb controller, data coherency of the transactions, signals | ||
6 | the host system errors received from controller. | ||
7 | 5 | ||
8 | Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | 6 | Signed-off-by: Bin Meng <bin.meng@windriver.com> |
9 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
10 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 1607023357-5096-2-git-send-email-sai.pavan.boddu@xilinx.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 45 ++++ | 11 | docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++ |
16 | hw/usb/xlnx-versal-usb2-ctrl-regs.c | 229 ++++++++++++++++++++ | 12 | docs/system/target-arm.rst | 1 + |
17 | hw/usb/meson.build | 1 + | 13 | 2 files changed, 120 insertions(+) |
18 | 3 files changed, 275 insertions(+) | 14 | create mode 100644 docs/system/arm/sabrelite.rst |
19 | create mode 100644 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | ||
20 | create mode 100644 hw/usb/xlnx-versal-usb2-ctrl-regs.c | ||
21 | 15 | ||
22 | diff --git a/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 16 | diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst |
23 | new file mode 100644 | 17 | new file mode 100644 |
24 | index XXXXXXX..XXXXXXX | 18 | index XXXXXXX..XXXXXXX |
25 | --- /dev/null | 19 | --- /dev/null |
26 | +++ b/include/hw/usb/xlnx-versal-usb2-ctrl-regs.h | 20 | +++ b/docs/system/arm/sabrelite.rst |
27 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
28 | +/* | 22 | +Boundary Devices SABRE Lite (``sabrelite``) |
29 | + * QEMU model of the VersalUsb2CtrlRegs Register control/Status block for | 23 | +=========================================== |
30 | + * USB2.0 controller | ||
31 | + * | ||
32 | + * Copyright (c) 2020 Xilinx Inc. Vikram Garhwal <fnu.vikram@xilinx.com> | ||
33 | + * | ||
34 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
35 | + * of this software and associated documentation files (the "Software"), to deal | ||
36 | + * in the Software without restriction, including without limitation the rights | ||
37 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
38 | + * copies of the Software, and to permit persons to whom the Software is | ||
39 | + * furnished to do so, subject to the following conditions: | ||
40 | + * | ||
41 | + * The above copyright notice and this permission notice shall be included in | ||
42 | + * all copies or substantial portions of the Software. | ||
43 | + * | ||
44 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
45 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
46 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
47 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
48 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
49 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
50 | + * THE SOFTWARE. | ||
51 | + */ | ||
52 | + | 24 | + |
53 | +#ifndef _XLNX_USB2_REGS_H_ | 25 | +Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development |
54 | +#define _XLNX_USB2_REGS_H_ | 26 | +platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad |
27 | +Applications Processor. | ||
55 | + | 28 | + |
56 | +#define TYPE_XILINX_VERSAL_USB2_CTRL_REGS "xlnx.versal-usb2-ctrl-regs" | 29 | +Supported devices |
30 | +----------------- | ||
57 | + | 31 | + |
58 | +#define XILINX_VERSAL_USB2_CTRL_REGS(obj) \ | 32 | +The SABRE Lite machine supports the following devices: |
59 | + OBJECT_CHECK(VersalUsb2CtrlRegs, (obj), TYPE_XILINX_VERSAL_USB2_CTRL_REGS) | ||
60 | + | 33 | + |
61 | +#define USB2_REGS_R_MAX ((0x78 / 4) + 1) | 34 | + * Up to 4 Cortex A9 cores |
35 | + * Generic Interrupt Controller | ||
36 | + * 1 Clock Controller Module | ||
37 | + * 1 System Reset Controller | ||
38 | + * 5 UARTs | ||
39 | + * 2 EPIC timers | ||
40 | + * 1 GPT timer | ||
41 | + * 2 Watchdog timers | ||
42 | + * 1 FEC Ethernet controller | ||
43 | + * 3 I2C controllers | ||
44 | + * 7 GPIO controllers | ||
45 | + * 4 SDHC storage controllers | ||
46 | + * 4 USB 2.0 host controllers | ||
47 | + * 5 ECSPI controllers | ||
48 | + * 1 SST 25VF016B flash | ||
62 | + | 49 | + |
63 | +typedef struct VersalUsb2CtrlRegs { | 50 | +Please note above list is a complete superset the QEMU SABRE Lite machine can |
64 | + SysBusDevice parent_obj; | 51 | +support. For a normal use case, a device tree blob that represents a real world |
65 | + MemoryRegion iomem; | 52 | +SABRE Lite board, only exposes a subset of devices to the guest software. |
66 | + qemu_irq irq_ir; | ||
67 | + | 53 | + |
68 | + uint32_t regs[USB2_REGS_R_MAX]; | 54 | +Boot options |
69 | + RegisterInfo regs_info[USB2_REGS_R_MAX]; | 55 | +------------ |
70 | +} VersalUsb2CtrlRegs; | ||
71 | + | 56 | + |
72 | +#endif | 57 | +The SABRE Lite machine can start using the standard -kernel functionality |
73 | diff --git a/hw/usb/xlnx-versal-usb2-ctrl-regs.c b/hw/usb/xlnx-versal-usb2-ctrl-regs.c | 58 | +for loading a Linux kernel, U-Boot bootloader or ELF executable. |
74 | new file mode 100644 | ||
75 | index XXXXXXX..XXXXXXX | ||
76 | --- /dev/null | ||
77 | +++ b/hw/usb/xlnx-versal-usb2-ctrl-regs.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | +/* | ||
80 | + * QEMU model of the VersalUsb2CtrlRegs Register control/Status block for | ||
81 | + * USB2.0 controller | ||
82 | + * | ||
83 | + * This module should control phy_reset, permanent device plugs, frame length | ||
84 | + * time adjust & setting of coherency paths. None of which are emulated in | ||
85 | + * present model. | ||
86 | + * | ||
87 | + * Copyright (c) 2020 Xilinx Inc. Vikram Garhwal <fnu.vikram@xilinx.com> | ||
88 | + * | ||
89 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
90 | + * of this software and associated documentation files (the "Software"), to deal | ||
91 | + * in the Software without restriction, including without limitation the rights | ||
92 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
93 | + * copies of the Software, and to permit persons to whom the Software is | ||
94 | + * furnished to do so, subject to the following conditions: | ||
95 | + * | ||
96 | + * The above copyright notice and this permission notice shall be included in | ||
97 | + * all copies or substantial portions of the Software. | ||
98 | + * | ||
99 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
100 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
101 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
102 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
103 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
104 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
105 | + * THE SOFTWARE. | ||
106 | + */ | ||
107 | + | 59 | + |
108 | +#include "qemu/osdep.h" | 60 | +Running Linux kernel |
109 | +#include "hw/sysbus.h" | 61 | +-------------------- |
110 | +#include "hw/irq.h" | ||
111 | +#include "hw/register.h" | ||
112 | +#include "qemu/bitops.h" | ||
113 | +#include "qemu/log.h" | ||
114 | +#include "qom/object.h" | ||
115 | +#include "migration/vmstate.h" | ||
116 | +#include "hw/usb/xlnx-versal-usb2-ctrl-regs.h" | ||
117 | + | 62 | + |
118 | +#ifndef XILINX_VERSAL_USB2_CTRL_REGS_ERR_DEBUG | 63 | +Linux mainline v5.10 release is tested at the time of writing. To build a Linux |
119 | +#define XILINX_VERSAL_USB2_CTRL_REGS_ERR_DEBUG 0 | 64 | +mainline kernel that can be booted by the SABRE Lite machine, simply configure |
120 | +#endif | 65 | +the kernel using the imx_v6_v7_defconfig configuration: |
121 | + | 66 | + |
122 | +REG32(BUS_FILTER, 0x30) | 67 | +.. code-block:: bash |
123 | + FIELD(BUS_FILTER, BYPASS, 0, 4) | ||
124 | +REG32(PORT, 0x34) | ||
125 | + FIELD(PORT, HOST_SMI_BAR_WR, 4, 1) | ||
126 | + FIELD(PORT, HOST_SMI_PCI_CMD_REG_WR, 3, 1) | ||
127 | + FIELD(PORT, HOST_MSI_ENABLE, 2, 1) | ||
128 | + FIELD(PORT, PWR_CTRL_PRSNT, 1, 1) | ||
129 | + FIELD(PORT, HUB_PERM_ATTACH, 0, 1) | ||
130 | +REG32(JITTER_ADJUST, 0x38) | ||
131 | + FIELD(JITTER_ADJUST, FLADJ, 0, 6) | ||
132 | +REG32(BIGENDIAN, 0x40) | ||
133 | + FIELD(BIGENDIAN, ENDIAN_GS, 0, 1) | ||
134 | +REG32(COHERENCY, 0x44) | ||
135 | + FIELD(COHERENCY, USB_COHERENCY, 0, 1) | ||
136 | +REG32(XHC_BME, 0x48) | ||
137 | + FIELD(XHC_BME, XHC_BME, 0, 1) | ||
138 | +REG32(REG_CTRL, 0x60) | ||
139 | + FIELD(REG_CTRL, SLVERR_ENABLE, 0, 1) | ||
140 | +REG32(IR_STATUS, 0x64) | ||
141 | + FIELD(IR_STATUS, HOST_SYS_ERR, 1, 1) | ||
142 | + FIELD(IR_STATUS, ADDR_DEC_ERR, 0, 1) | ||
143 | +REG32(IR_MASK, 0x68) | ||
144 | + FIELD(IR_MASK, HOST_SYS_ERR, 1, 1) | ||
145 | + FIELD(IR_MASK, ADDR_DEC_ERR, 0, 1) | ||
146 | +REG32(IR_ENABLE, 0x6c) | ||
147 | + FIELD(IR_ENABLE, HOST_SYS_ERR, 1, 1) | ||
148 | + FIELD(IR_ENABLE, ADDR_DEC_ERR, 0, 1) | ||
149 | +REG32(IR_DISABLE, 0x70) | ||
150 | + FIELD(IR_DISABLE, HOST_SYS_ERR, 1, 1) | ||
151 | + FIELD(IR_DISABLE, ADDR_DEC_ERR, 0, 1) | ||
152 | +REG32(USB3, 0x78) | ||
153 | + | 68 | + |
154 | +static void ir_update_irq(VersalUsb2CtrlRegs *s) | 69 | + $ export ARCH=arm |
155 | +{ | 70 | + $ export CROSS_COMPILE=arm-linux-gnueabihf- |
156 | + bool pending = s->regs[R_IR_STATUS] & ~s->regs[R_IR_MASK]; | 71 | + $ make imx_v6_v7_defconfig |
157 | + qemu_set_irq(s->irq_ir, pending); | 72 | + $ make |
158 | +} | ||
159 | + | 73 | + |
160 | +static void ir_status_postw(RegisterInfo *reg, uint64_t val64) | 74 | +To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use: |
161 | +{ | ||
162 | + VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(reg->opaque); | ||
163 | + /* | ||
164 | + * TODO: This should also clear USBSTS.HSE field in USB XHCI register. | ||
165 | + * May be combine both the modules. | ||
166 | + */ | ||
167 | + ir_update_irq(s); | ||
168 | +} | ||
169 | + | 75 | + |
170 | +static uint64_t ir_enable_prew(RegisterInfo *reg, uint64_t val64) | 76 | +.. code-block:: bash |
171 | +{ | ||
172 | + VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(reg->opaque); | ||
173 | + uint32_t val = val64; | ||
174 | + | 77 | + |
175 | + s->regs[R_IR_MASK] &= ~val; | 78 | + $ qemu-system-arm -M sabrelite -smp 4 -m 1G \ |
176 | + ir_update_irq(s); | 79 | + -display none -serial null -serial stdio \ |
177 | + return 0; | 80 | + -kernel arch/arm/boot/zImage \ |
178 | +} | 81 | + -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \ |
82 | + -initrd /path/to/rootfs.ext4 \ | ||
83 | + -append "root=/dev/ram" | ||
179 | + | 84 | + |
180 | +static uint64_t ir_disable_prew(RegisterInfo *reg, uint64_t val64) | 85 | +Running U-Boot |
181 | +{ | 86 | +-------------- |
182 | + VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(reg->opaque); | ||
183 | + uint32_t val = val64; | ||
184 | + | 87 | + |
185 | + s->regs[R_IR_MASK] |= val; | 88 | +U-Boot mainline v2020.10 release is tested at the time of writing. To build a |
186 | + ir_update_irq(s); | 89 | +U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use |
187 | + return 0; | 90 | +the mx6qsabrelite_defconfig with similar commands as described above for Linux: |
188 | +} | ||
189 | + | 91 | + |
190 | +static const RegisterAccessInfo usb2_ctrl_regs_regs_info[] = { | 92 | +.. code-block:: bash |
191 | + { .name = "BUS_FILTER", .addr = A_BUS_FILTER, | ||
192 | + .rsvd = 0xfffffff0, | ||
193 | + },{ .name = "PORT", .addr = A_PORT, | ||
194 | + .rsvd = 0xffffffe0, | ||
195 | + },{ .name = "JITTER_ADJUST", .addr = A_JITTER_ADJUST, | ||
196 | + .reset = 0x20, | ||
197 | + .rsvd = 0xffffffc0, | ||
198 | + },{ .name = "BIGENDIAN", .addr = A_BIGENDIAN, | ||
199 | + .rsvd = 0xfffffffe, | ||
200 | + },{ .name = "COHERENCY", .addr = A_COHERENCY, | ||
201 | + .rsvd = 0xfffffffe, | ||
202 | + },{ .name = "XHC_BME", .addr = A_XHC_BME, | ||
203 | + .reset = 0x1, | ||
204 | + .rsvd = 0xfffffffe, | ||
205 | + },{ .name = "REG_CTRL", .addr = A_REG_CTRL, | ||
206 | + .rsvd = 0xfffffffe, | ||
207 | + },{ .name = "IR_STATUS", .addr = A_IR_STATUS, | ||
208 | + .rsvd = 0xfffffffc, | ||
209 | + .w1c = 0x3, | ||
210 | + .post_write = ir_status_postw, | ||
211 | + },{ .name = "IR_MASK", .addr = A_IR_MASK, | ||
212 | + .reset = 0x3, | ||
213 | + .rsvd = 0xfffffffc, | ||
214 | + .ro = 0x3, | ||
215 | + },{ .name = "IR_ENABLE", .addr = A_IR_ENABLE, | ||
216 | + .rsvd = 0xfffffffc, | ||
217 | + .pre_write = ir_enable_prew, | ||
218 | + },{ .name = "IR_DISABLE", .addr = A_IR_DISABLE, | ||
219 | + .rsvd = 0xfffffffc, | ||
220 | + .pre_write = ir_disable_prew, | ||
221 | + },{ .name = "USB3", .addr = A_USB3, | ||
222 | + } | ||
223 | +}; | ||
224 | + | 93 | + |
225 | +static void usb2_ctrl_regs_reset_init(Object *obj, ResetType type) | 94 | + $ export CROSS_COMPILE=arm-linux-gnueabihf- |
226 | +{ | 95 | + $ make mx6qsabrelite_defconfig |
227 | + VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(obj); | ||
228 | + unsigned int i; | ||
229 | + | 96 | + |
230 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | 97 | +Note we need to adjust settings by: |
231 | + register_reset(&s->regs_info[i]); | ||
232 | + } | ||
233 | +} | ||
234 | + | 98 | + |
235 | +static void usb2_ctrl_regs_reset_hold(Object *obj) | 99 | +.. code-block:: bash |
236 | +{ | ||
237 | + VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(obj); | ||
238 | + | 100 | + |
239 | + ir_update_irq(s); | 101 | + $ make menuconfig |
240 | +} | ||
241 | + | 102 | + |
242 | +static const MemoryRegionOps usb2_ctrl_regs_ops = { | 103 | +then manually select the following configuration in U-Boot: |
243 | + .read = register_read_memory, | ||
244 | + .write = register_write_memory, | ||
245 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
246 | + .valid = { | ||
247 | + .min_access_size = 4, | ||
248 | + .max_access_size = 4, | ||
249 | + }, | ||
250 | +}; | ||
251 | + | 104 | + |
252 | +static void usb2_ctrl_regs_init(Object *obj) | 105 | + Device Tree Control > Provider of DTB for DT Control > Embedded DTB |
253 | +{ | ||
254 | + VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(obj); | ||
255 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
256 | + RegisterInfoArray *reg_array; | ||
257 | + | 106 | + |
258 | + memory_region_init(&s->iomem, obj, TYPE_XILINX_VERSAL_USB2_CTRL_REGS, | 107 | +To start U-Boot using the SABRE Lite machine, provide the u-boot binary to |
259 | + USB2_REGS_R_MAX * 4); | 108 | +the -kernel argument, along with an SD card image with rootfs: |
260 | + reg_array = | ||
261 | + register_init_block32(DEVICE(obj), usb2_ctrl_regs_regs_info, | ||
262 | + ARRAY_SIZE(usb2_ctrl_regs_regs_info), | ||
263 | + s->regs_info, s->regs, | ||
264 | + &usb2_ctrl_regs_ops, | ||
265 | + XILINX_VERSAL_USB2_CTRL_REGS_ERR_DEBUG, | ||
266 | + USB2_REGS_R_MAX * 4); | ||
267 | + memory_region_add_subregion(&s->iomem, | ||
268 | + 0x0, | ||
269 | + ®_array->mem); | ||
270 | + sysbus_init_mmio(sbd, &s->iomem); | ||
271 | + sysbus_init_irq(sbd, &s->irq_ir); | ||
272 | +} | ||
273 | + | 109 | + |
274 | +static const VMStateDescription vmstate_usb2_ctrl_regs = { | 110 | +.. code-block:: bash |
275 | + .name = TYPE_XILINX_VERSAL_USB2_CTRL_REGS, | ||
276 | + .version_id = 1, | ||
277 | + .minimum_version_id = 1, | ||
278 | + .fields = (VMStateField[]) { | ||
279 | + VMSTATE_UINT32_ARRAY(regs, VersalUsb2CtrlRegs, USB2_REGS_R_MAX), | ||
280 | + VMSTATE_END_OF_LIST(), | ||
281 | + } | ||
282 | +}; | ||
283 | + | 111 | + |
284 | +static void usb2_ctrl_regs_class_init(ObjectClass *klass, void *data) | 112 | + $ qemu-system-arm -M sabrelite -smp 4 -m 1G \ |
285 | +{ | 113 | + -display none -serial null -serial stdio \ |
286 | + DeviceClass *dc = DEVICE_CLASS(klass); | 114 | + -kernel u-boot |
287 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
288 | + | 115 | + |
289 | + rc->phases.enter = usb2_ctrl_regs_reset_init; | 116 | +The following example shows booting Linux kernel from dhcp, and uses the |
290 | + rc->phases.hold = usb2_ctrl_regs_reset_hold; | 117 | +rootfs on an SD card. This requires some additional command line parameters |
291 | + dc->vmsd = &vmstate_usb2_ctrl_regs; | 118 | +for QEMU: |
292 | +} | ||
293 | + | 119 | + |
294 | +static const TypeInfo usb2_ctrl_regs_info = { | 120 | +.. code-block:: none |
295 | + .name = TYPE_XILINX_VERSAL_USB2_CTRL_REGS, | ||
296 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
297 | + .instance_size = sizeof(VersalUsb2CtrlRegs), | ||
298 | + .class_init = usb2_ctrl_regs_class_init, | ||
299 | + .instance_init = usb2_ctrl_regs_init, | ||
300 | +}; | ||
301 | + | 121 | + |
302 | +static void usb2_ctrl_regs_register_types(void) | 122 | + -nic user,tftp=/path/to/kernel/zImage \ |
303 | +{ | 123 | + -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs |
304 | + type_register_static(&usb2_ctrl_regs_info); | ||
305 | +} | ||
306 | + | 124 | + |
307 | +type_init(usb2_ctrl_regs_register_types) | 125 | +The directory for the built-in TFTP server should also contain the device tree |
308 | diff --git a/hw/usb/meson.build b/hw/usb/meson.build | 126 | +blob of the SABRE Lite board. The sample SD card image was populated with the |
127 | +root file system with one single partition. You may adjust the kernel "root=" | ||
128 | +boot parameter accordingly. | ||
129 | + | ||
130 | +After U-Boot boots, type the following commands in the U-Boot command shell to | ||
131 | +boot the Linux kernel: | ||
132 | + | ||
133 | +.. code-block:: none | ||
134 | + | ||
135 | + => setenv ethaddr 00:11:22:33:44:55 | ||
136 | + => setenv bootfile zImage | ||
137 | + => dhcp | ||
138 | + => tftpboot 14000000 imx6q-sabrelite.dtb | ||
139 | + => setenv bootargs root=/dev/mmcblk3p1 | ||
140 | + => bootz 12000000 - 14000000 | ||
141 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
309 | index XXXXXXX..XXXXXXX 100644 | 142 | index XXXXXXX..XXXXXXX 100644 |
310 | --- a/hw/usb/meson.build | 143 | --- a/docs/system/target-arm.rst |
311 | +++ b/hw/usb/meson.build | 144 | +++ b/docs/system/target-arm.rst |
312 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_USB_DWC2', if_true: files('hcd-dwc2.c')) | 145 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running |
313 | softmmu_ss.add(when: 'CONFIG_TUSB6010', if_true: files('tusb6010.c')) | 146 | arm/versatile |
314 | softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('chipidea.c')) | 147 | arm/vexpress |
315 | softmmu_ss.add(when: 'CONFIG_IMX_USBPHY', if_true: files('imx-usb-phy.c')) | 148 | arm/aspeed |
316 | +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-usb2-ctrl-regs.c')) | 149 | + arm/sabrelite |
317 | 150 | arm/digic | |
318 | # emulated usb devices | 151 | arm/musicpal |
319 | softmmu_ss.add(when: 'CONFIG_USB', if_true: files('dev-hub.c')) | 152 | arm/gumstix |
320 | -- | 153 | -- |
321 | 2.20.1 | 154 | 2.20.1 |
322 | 155 | ||
323 | 156 | diff view generated by jsdifflib |