1 | target-arm queue. This has the "plumb txattrs through various | 1 | Last pullreq before 6.0 softfreeze: a few minor feature patches, |
---|---|---|---|
2 | bits of exec.c" patches, and a collection of bug fixes from | 2 | some bugfixes, some cleanups. |
3 | various people. | ||
4 | 3 | ||
5 | thanks | ||
6 | -- PMM | 4 | -- PMM |
7 | 5 | ||
6 | The following changes since commit 6f34661b6c97a37a5efc27d31c037ddeda4547e2: | ||
8 | 7 | ||
9 | 8 | Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-6.0-pull-request' into staging (2021-03-11 18:55:27 +0000) | |
10 | The following changes since commit a3ac12fba028df90f7b3dbec924995c126c41022: | ||
11 | |||
12 | Merge remote-tracking branch 'remotes/ehabkost/tags/numa-next-pull-request' into staging (2018-05-31 11:12:36 +0100) | ||
13 | 9 | ||
14 | are available in the Git repository at: | 10 | are available in the Git repository at: |
15 | 11 | ||
16 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180531 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210312-1 |
17 | 13 | ||
18 | for you to fetch changes up to 49d1dca0520ea71bc21867fab6647f474fcf857b: | 14 | for you to fetch changes up to 41f09f2e9f09e4dd386d84174a6dcb5136af17ca: |
19 | 15 | ||
20 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice (2018-05-31 14:52:53 +0100) | 16 | hw/display/pxa2xx: Inline template header (2021-03-12 13:26:08 +0000) |
21 | 17 | ||
22 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
23 | target-arm queue: | 19 | target-arm queue: |
24 | * target/arm: Honour FPCR.FZ in FRECPX | 20 | * versal: Support XRAMs and XRAM controller |
25 | * MAINTAINERS: Add entries for newer MPS2 boards and devices | 21 | * smmu: Various minor bug fixes |
26 | * hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 22 | * SVE emulation: fix bugs handling odd vector lengths |
27 | * arm_gicv3_kvm: fix bug in writing zero bits back to the in-kernel | 23 | * allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value |
28 | GIC state | 24 | * tests/acceptance: fix orangepi-pc acceptance tests |
29 | * tcg: Fix helper function vs host abi for float16 | 25 | * hw/timer/sse-timer: Propagate eventual error in sse_timer_realize() |
30 | * arm: fix qemu crash on startup with -bios option | 26 | * hw/arm/virt: KVM: The IPA lower bound is 32 |
31 | * arm: fix malloc type mismatch | 27 | * npcm7xx: support MFT module |
32 | * xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | 28 | * pl110, pxa2xx_lcd: tidy up template headers |
33 | * Correct CPACR reset value for v7 cores | ||
34 | * memory.h: Improve IOMMU related documentation | ||
35 | * exec: Plumb transaction attributes through various functions in | ||
36 | preparation for allowing IOMMUs to see them | ||
37 | * vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | ||
38 | * ARM: ACPI: Fix use-after-free due to memory realloc | ||
39 | * KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | ||
40 | 29 | ||
41 | ---------------------------------------------------------------- | 30 | ---------------------------------------------------------------- |
42 | Francisco Iglesias (1): | 31 | Andrew Jones (2): |
43 | xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors | 32 | accel: kvm: Fix kvm_type invocation |
33 | hw/arm/virt: KVM: The IPA lower bound is 32 | ||
44 | 34 | ||
45 | Igor Mammedov (1): | 35 | Edgar E. Iglesias (2): |
46 | arm: fix qemu crash on startup with -bios option | 36 | hw/misc: versal: Add a model of the XRAM controller |
37 | hw/arm: versal: Add support for the XRAMs | ||
47 | 38 | ||
48 | Jan Kiszka (1): | 39 | Eric Auger (7): |
49 | hw/intc/arm_gicv3: Fix APxR<n> register dispatching | 40 | intel_iommu: Fix mask may be uninitialized in vtd_context_device_invalidate |
41 | dma: Introduce dma_aligned_pow2_mask() | ||
42 | virtio-iommu: Handle non power of 2 range invalidations | ||
43 | hw/arm/smmu-common: Fix smmu_iotlb_inv_iova when asid is not set | ||
44 | hw/arm/smmuv3: Enforce invalidation on a power of two range | ||
45 | hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling | ||
46 | hw/arm/smmuv3: Uniformize sid traces | ||
50 | 47 | ||
51 | Paolo Bonzini (1): | 48 | Hao Wu (5): |
52 | arm: fix malloc type mismatch | 49 | hw/misc: Add GPIOs for duty in NPCM7xx PWM |
50 | hw/misc: Add NPCM7XX MFT Module | ||
51 | hw/arm: Add MFT device to NPCM7xx Soc | ||
52 | hw/arm: Connect PWM fans in NPCM7XX boards | ||
53 | tests/qtest: Test PWM fan RPM using MFT in PWM test | ||
53 | 54 | ||
54 | Peter Maydell (17): | 55 | Niek Linnenbank (5): |
55 | target/arm: Honour FPCR.FZ in FRECPX | 56 | hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value |
56 | MAINTAINERS: Add entries for newer MPS2 boards and devices | 57 | tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic test for orangepi-pc machine |
57 | Correct CPACR reset value for v7 cores | 58 | tests/acceptance/boot_linux_console: change URL for test_arm_orangepi_bionic_20_08 |
58 | memory.h: Improve IOMMU related documentation | 59 | tests/acceptance: update sunxi kernel from armbian to 5.10.16 |
59 | Make tb_invalidate_phys_addr() take a MemTxAttrs argument | 60 | tests/acceptance: drop ARMBIAN_ARTIFACTS_CACHED condition for orangepi-pc, cubieboard tests |
60 | Make address_space_translate{, _cached}() take a MemTxAttrs argument | ||
61 | Make address_space_map() take a MemTxAttrs argument | ||
62 | Make address_space_access_valid() take a MemTxAttrs argument | ||
63 | Make flatview_extend_translation() take a MemTxAttrs argument | ||
64 | Make memory_region_access_valid() take a MemTxAttrs argument | ||
65 | Make MemoryRegion valid.accepts callback take a MemTxAttrs argument | ||
66 | Make flatview_access_valid() take a MemTxAttrs argument | ||
67 | Make flatview_translate() take a MemTxAttrs argument | ||
68 | Make address_space_get_iotlb_entry() take a MemTxAttrs argument | ||
69 | Make flatview_do_translate() take a MemTxAttrs argument | ||
70 | Make address_space_translate_iommu take a MemTxAttrs argument | ||
71 | vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY | ||
72 | 61 | ||
73 | Richard Henderson (1): | 62 | Peter Maydell (9): |
74 | tcg: Fix helper function vs host abi for float16 | 63 | hw/display/pl110: Remove dead code for non-32-bpp surfaces |
64 | hw/display/pl110: Pull included-once parts of template header into pl110.c | ||
65 | hw/display/pl110: Remove use of BITS from pl110_template.h | ||
66 | hw/display/pxa2xx_lcd: Remove dead code for non-32-bpp surfaces | ||
67 | hw/display/pxa2xx_lcd: Remove dest_width state field | ||
68 | hw/display/pxa2xx: Remove use of BITS in pxa2xx_template.h | ||
69 | hw/display/pxa2xx: Apply brace-related coding style fixes to template header | ||
70 | hw/display/pxa2xx: Apply whitespace-only coding style fixes to template header | ||
71 | hw/display/pxa2xx: Inline template header | ||
75 | 72 | ||
76 | Shannon Zhao (3): | 73 | Philippe Mathieu-Daudé (1): |
77 | arm_gicv3_kvm: increase clroffset accordingly | 74 | hw/timer/sse-timer: Propagate eventual error in sse_timer_realize() |
78 | ARM: ACPI: Fix use-after-free due to memory realloc | ||
79 | KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice | ||
80 | 75 | ||
81 | include/exec/exec-all.h | 5 +- | 76 | Richard Henderson (8): |
82 | include/exec/helper-head.h | 2 +- | 77 | target/arm: Fix sve_uzp_p vs odd vector lengths |
83 | include/exec/memory-internal.h | 3 +- | 78 | target/arm: Fix sve_zip_p vs odd vector lengths |
84 | include/exec/memory.h | 128 +++++++++++++++++++++++++++++++++++------ | 79 | target/arm: Fix sve_punpk_p vs odd vector lengths |
85 | include/migration/vmstate.h | 3 + | 80 | target/arm: Update find_last_active for PREDDESC |
86 | include/sysemu/dma.h | 6 +- | 81 | target/arm: Update BRKA, BRKB, BRKN for PREDDESC |
87 | accel/tcg/translate-all.c | 4 +- | 82 | target/arm: Update CNTP for PREDDESC |
88 | exec.c | 95 ++++++++++++++++++------------ | 83 | target/arm: Update WHILE for PREDDESC |
89 | hw/arm/boot.c | 18 +++--- | 84 | target/arm: Update sve reduction vs simd_desc |
90 | hw/arm/virt-acpi-build.c | 20 +++++-- | ||
91 | hw/dma/xlnx-zdma.c | 10 +++- | ||
92 | hw/hppa/dino.c | 3 +- | ||
93 | hw/intc/arm_gic_kvm.c | 1 - | ||
94 | hw/intc/arm_gicv3_cpuif.c | 12 ++-- | ||
95 | hw/intc/arm_gicv3_kvm.c | 2 +- | ||
96 | hw/nvram/fw_cfg.c | 12 ++-- | ||
97 | hw/s390x/s390-pci-inst.c | 3 +- | ||
98 | hw/scsi/esp.c | 3 +- | ||
99 | hw/vfio/common.c | 3 +- | ||
100 | hw/virtio/vhost.c | 3 +- | ||
101 | hw/xen/xen_pt_msi.c | 3 +- | ||
102 | memory.c | 12 ++-- | ||
103 | memory_ldst.inc.c | 18 +++--- | ||
104 | target/arm/gdbstub.c | 3 +- | ||
105 | target/arm/helper-a64.c | 41 +++++++------ | ||
106 | target/arm/helper.c | 90 ++++++++++++++++------------- | ||
107 | target/ppc/mmu-hash64.c | 3 +- | ||
108 | target/riscv/helper.c | 2 +- | ||
109 | target/s390x/diag.c | 6 +- | ||
110 | target/s390x/excp_helper.c | 3 +- | ||
111 | target/s390x/mmu_helper.c | 3 +- | ||
112 | target/s390x/sigp.c | 3 +- | ||
113 | target/xtensa/op_helper.c | 3 +- | ||
114 | MAINTAINERS | 9 ++- | ||
115 | 34 files changed, 353 insertions(+), 182 deletions(-) | ||
116 | 85 | ||
86 | docs/system/arm/nuvoton.rst | 2 +- | ||
87 | docs/system/arm/xlnx-versal-virt.rst | 1 + | ||
88 | hw/arm/smmu-internal.h | 5 + | ||
89 | hw/display/pl110_template.h | 120 +------- | ||
90 | hw/display/pxa2xx_template.h | 447 --------------------------- | ||
91 | include/hw/arm/npcm7xx.h | 13 +- | ||
92 | include/hw/arm/xlnx-versal.h | 13 + | ||
93 | include/hw/boards.h | 1 + | ||
94 | include/hw/misc/npcm7xx_mft.h | 70 +++++ | ||
95 | include/hw/misc/npcm7xx_pwm.h | 4 +- | ||
96 | include/hw/misc/xlnx-versal-xramc.h | 97 ++++++ | ||
97 | include/sysemu/dma.h | 12 + | ||
98 | target/arm/kvm_arm.h | 6 +- | ||
99 | accel/kvm/kvm-all.c | 2 + | ||
100 | hw/arm/npcm7xx.c | 45 ++- | ||
101 | hw/arm/npcm7xx_boards.c | 99 ++++++ | ||
102 | hw/arm/smmu-common.c | 32 +- | ||
103 | hw/arm/smmuv3.c | 58 ++-- | ||
104 | hw/arm/virt.c | 23 +- | ||
105 | hw/arm/xlnx-versal.c | 36 +++ | ||
106 | hw/display/pl110.c | 123 +++++--- | ||
107 | hw/display/pxa2xx_lcd.c | 520 ++++++++++++++++++++++++++----- | ||
108 | hw/i386/intel_iommu.c | 32 +- | ||
109 | hw/misc/npcm7xx_mft.c | 540 +++++++++++++++++++++++++++++++++ | ||
110 | hw/misc/npcm7xx_pwm.c | 4 + | ||
111 | hw/misc/xlnx-versal-xramc.c | 253 +++++++++++++++ | ||
112 | hw/net/allwinner-sun8i-emac.c | 62 ++-- | ||
113 | hw/timer/sse-timer.c | 1 + | ||
114 | hw/virtio/virtio-iommu.c | 19 +- | ||
115 | softmmu/dma-helpers.c | 26 ++ | ||
116 | target/arm/kvm.c | 4 +- | ||
117 | target/arm/sve_helper.c | 107 ++++--- | ||
118 | target/arm/translate-sve.c | 26 +- | ||
119 | tests/qtest/npcm7xx_pwm-test.c | 205 ++++++++++++- | ||
120 | hw/arm/trace-events | 24 +- | ||
121 | hw/misc/meson.build | 2 + | ||
122 | hw/misc/trace-events | 8 + | ||
123 | tests/acceptance/boot_linux_console.py | 120 +++----- | ||
124 | tests/acceptance/replay_kernel.py | 10 +- | ||
125 | 39 files changed, 2235 insertions(+), 937 deletions(-) | ||
126 | delete mode 100644 hw/display/pxa2xx_template.h | ||
127 | create mode 100644 include/hw/misc/npcm7xx_mft.h | ||
128 | create mode 100644 include/hw/misc/xlnx-versal-xramc.h | ||
129 | create mode 100644 hw/misc/npcm7xx_mft.c | ||
130 | create mode 100644 hw/misc/xlnx-versal-xramc.c | ||
131 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | |
2 | |||
3 | Add a model of the Xilinx Versal Accelerator RAM (XRAM). | ||
4 | This is mainly a stub to make firmware happy. The size of | ||
5 | the RAMs can be probed. The interrupt mask logic is | ||
6 | modelled but none of the interrups will ever be raised | ||
7 | unless injected. | ||
8 | |||
9 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
10 | Message-id: 20210308224637.2949533-2-edgar.iglesias@gmail.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | include/hw/misc/xlnx-versal-xramc.h | 97 +++++++++++ | ||
15 | hw/misc/xlnx-versal-xramc.c | 253 ++++++++++++++++++++++++++++ | ||
16 | hw/misc/meson.build | 1 + | ||
17 | 3 files changed, 351 insertions(+) | ||
18 | create mode 100644 include/hw/misc/xlnx-versal-xramc.h | ||
19 | create mode 100644 hw/misc/xlnx-versal-xramc.c | ||
20 | |||
21 | diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h | ||
22 | new file mode 100644 | ||
23 | index XXXXXXX..XXXXXXX | ||
24 | --- /dev/null | ||
25 | +++ b/include/hw/misc/xlnx-versal-xramc.h | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | +/* | ||
28 | + * QEMU model of the Xilinx XRAM Controller. | ||
29 | + * | ||
30 | + * Copyright (c) 2021 Xilinx Inc. | ||
31 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
32 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
33 | + */ | ||
34 | + | ||
35 | +#ifndef XLNX_VERSAL_XRAMC_H | ||
36 | +#define XLNX_VERSAL_XRAMC_H | ||
37 | + | ||
38 | +#include "hw/sysbus.h" | ||
39 | +#include "hw/register.h" | ||
40 | + | ||
41 | +#define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc" | ||
42 | + | ||
43 | +#define XLNX_XRAM_CTRL(obj) \ | ||
44 | + OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL) | ||
45 | + | ||
46 | +REG32(XRAM_ERR_CTRL, 0x0) | ||
47 | + FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1) | ||
48 | + FIELD(XRAM_ERR_CTRL, PWR_ERR_RES, 2, 1) | ||
49 | + FIELD(XRAM_ERR_CTRL, PZ_ERR_RES, 1, 1) | ||
50 | + FIELD(XRAM_ERR_CTRL, APB_ERR_RES, 0, 1) | ||
51 | +REG32(XRAM_ISR, 0x4) | ||
52 | + FIELD(XRAM_ISR, INV_APB, 0, 1) | ||
53 | +REG32(XRAM_IMR, 0x8) | ||
54 | + FIELD(XRAM_IMR, INV_APB, 0, 1) | ||
55 | +REG32(XRAM_IEN, 0xc) | ||
56 | + FIELD(XRAM_IEN, INV_APB, 0, 1) | ||
57 | +REG32(XRAM_IDS, 0x10) | ||
58 | + FIELD(XRAM_IDS, INV_APB, 0, 1) | ||
59 | +REG32(XRAM_ECC_CNTL, 0x14) | ||
60 | + FIELD(XRAM_ECC_CNTL, FI_MODE, 2, 1) | ||
61 | + FIELD(XRAM_ECC_CNTL, DET_ONLY, 1, 1) | ||
62 | + FIELD(XRAM_ECC_CNTL, ECC_ON_OFF, 0, 1) | ||
63 | +REG32(XRAM_CLR_EXE, 0x18) | ||
64 | + FIELD(XRAM_CLR_EXE, MON_7, 7, 1) | ||
65 | + FIELD(XRAM_CLR_EXE, MON_6, 6, 1) | ||
66 | + FIELD(XRAM_CLR_EXE, MON_5, 5, 1) | ||
67 | + FIELD(XRAM_CLR_EXE, MON_4, 4, 1) | ||
68 | + FIELD(XRAM_CLR_EXE, MON_3, 3, 1) | ||
69 | + FIELD(XRAM_CLR_EXE, MON_2, 2, 1) | ||
70 | + FIELD(XRAM_CLR_EXE, MON_1, 1, 1) | ||
71 | + FIELD(XRAM_CLR_EXE, MON_0, 0, 1) | ||
72 | +REG32(XRAM_CE_FFA, 0x1c) | ||
73 | + FIELD(XRAM_CE_FFA, ADDR, 0, 20) | ||
74 | +REG32(XRAM_CE_FFD0, 0x20) | ||
75 | +REG32(XRAM_CE_FFD1, 0x24) | ||
76 | +REG32(XRAM_CE_FFD2, 0x28) | ||
77 | +REG32(XRAM_CE_FFD3, 0x2c) | ||
78 | +REG32(XRAM_CE_FFE, 0x30) | ||
79 | + FIELD(XRAM_CE_FFE, SYNDROME, 0, 16) | ||
80 | +REG32(XRAM_UE_FFA, 0x34) | ||
81 | + FIELD(XRAM_UE_FFA, ADDR, 0, 20) | ||
82 | +REG32(XRAM_UE_FFD0, 0x38) | ||
83 | +REG32(XRAM_UE_FFD1, 0x3c) | ||
84 | +REG32(XRAM_UE_FFD2, 0x40) | ||
85 | +REG32(XRAM_UE_FFD3, 0x44) | ||
86 | +REG32(XRAM_UE_FFE, 0x48) | ||
87 | + FIELD(XRAM_UE_FFE, SYNDROME, 0, 16) | ||
88 | +REG32(XRAM_FI_D0, 0x4c) | ||
89 | +REG32(XRAM_FI_D1, 0x50) | ||
90 | +REG32(XRAM_FI_D2, 0x54) | ||
91 | +REG32(XRAM_FI_D3, 0x58) | ||
92 | +REG32(XRAM_FI_SY, 0x5c) | ||
93 | + FIELD(XRAM_FI_SY, DATA, 0, 16) | ||
94 | +REG32(XRAM_RMW_UE_FFA, 0x70) | ||
95 | + FIELD(XRAM_RMW_UE_FFA, ADDR, 0, 20) | ||
96 | +REG32(XRAM_FI_CNTR, 0x74) | ||
97 | + FIELD(XRAM_FI_CNTR, COUNT, 0, 24) | ||
98 | +REG32(XRAM_IMP, 0x80) | ||
99 | + FIELD(XRAM_IMP, SIZE, 0, 4) | ||
100 | +REG32(XRAM_PRDY_DBG, 0x84) | ||
101 | + FIELD(XRAM_PRDY_DBG, ISLAND3, 12, 4) | ||
102 | + FIELD(XRAM_PRDY_DBG, ISLAND2, 8, 4) | ||
103 | + FIELD(XRAM_PRDY_DBG, ISLAND1, 4, 4) | ||
104 | + FIELD(XRAM_PRDY_DBG, ISLAND0, 0, 4) | ||
105 | +REG32(XRAM_SAFETY_CHK, 0xff8) | ||
106 | + | ||
107 | +#define XRAM_CTRL_R_MAX (R_XRAM_SAFETY_CHK + 1) | ||
108 | + | ||
109 | +typedef struct XlnxXramCtrl { | ||
110 | + SysBusDevice parent_obj; | ||
111 | + MemoryRegion ram; | ||
112 | + qemu_irq irq; | ||
113 | + | ||
114 | + struct { | ||
115 | + uint64_t size; | ||
116 | + unsigned int encoded_size; | ||
117 | + } cfg; | ||
118 | + | ||
119 | + RegisterInfoArray *reg_array; | ||
120 | + uint32_t regs[XRAM_CTRL_R_MAX]; | ||
121 | + RegisterInfo regs_info[XRAM_CTRL_R_MAX]; | ||
122 | +} XlnxXramCtrl; | ||
123 | +#endif | ||
124 | diff --git a/hw/misc/xlnx-versal-xramc.c b/hw/misc/xlnx-versal-xramc.c | ||
125 | new file mode 100644 | ||
126 | index XXXXXXX..XXXXXXX | ||
127 | --- /dev/null | ||
128 | +++ b/hw/misc/xlnx-versal-xramc.c | ||
129 | @@ -XXX,XX +XXX,XX @@ | ||
130 | +/* | ||
131 | + * QEMU model of the Xilinx XRAM Controller. | ||
132 | + * | ||
133 | + * Copyright (c) 2021 Xilinx Inc. | ||
134 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
135 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
136 | + */ | ||
137 | + | ||
138 | +#include "qemu/osdep.h" | ||
139 | +#include "qemu/units.h" | ||
140 | +#include "qapi/error.h" | ||
141 | +#include "migration/vmstate.h" | ||
142 | +#include "hw/sysbus.h" | ||
143 | +#include "hw/register.h" | ||
144 | +#include "hw/qdev-properties.h" | ||
145 | +#include "hw/irq.h" | ||
146 | +#include "hw/misc/xlnx-versal-xramc.h" | ||
147 | + | ||
148 | +#ifndef XLNX_XRAM_CTRL_ERR_DEBUG | ||
149 | +#define XLNX_XRAM_CTRL_ERR_DEBUG 0 | ||
150 | +#endif | ||
151 | + | ||
152 | +static void xram_update_irq(XlnxXramCtrl *s) | ||
153 | +{ | ||
154 | + bool pending = s->regs[R_XRAM_ISR] & ~s->regs[R_XRAM_IMR]; | ||
155 | + qemu_set_irq(s->irq, pending); | ||
156 | +} | ||
157 | + | ||
158 | +static void xram_isr_postw(RegisterInfo *reg, uint64_t val64) | ||
159 | +{ | ||
160 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque); | ||
161 | + xram_update_irq(s); | ||
162 | +} | ||
163 | + | ||
164 | +static uint64_t xram_ien_prew(RegisterInfo *reg, uint64_t val64) | ||
165 | +{ | ||
166 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque); | ||
167 | + uint32_t val = val64; | ||
168 | + | ||
169 | + s->regs[R_XRAM_IMR] &= ~val; | ||
170 | + xram_update_irq(s); | ||
171 | + return 0; | ||
172 | +} | ||
173 | + | ||
174 | +static uint64_t xram_ids_prew(RegisterInfo *reg, uint64_t val64) | ||
175 | +{ | ||
176 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque); | ||
177 | + uint32_t val = val64; | ||
178 | + | ||
179 | + s->regs[R_XRAM_IMR] |= val; | ||
180 | + xram_update_irq(s); | ||
181 | + return 0; | ||
182 | +} | ||
183 | + | ||
184 | +static const RegisterAccessInfo xram_ctrl_regs_info[] = { | ||
185 | + { .name = "XRAM_ERR_CTRL", .addr = A_XRAM_ERR_CTRL, | ||
186 | + .reset = 0xf, | ||
187 | + .rsvd = 0xfffffff0, | ||
188 | + },{ .name = "XRAM_ISR", .addr = A_XRAM_ISR, | ||
189 | + .rsvd = 0xfffff800, | ||
190 | + .w1c = 0x7ff, | ||
191 | + .post_write = xram_isr_postw, | ||
192 | + },{ .name = "XRAM_IMR", .addr = A_XRAM_IMR, | ||
193 | + .reset = 0x7ff, | ||
194 | + .rsvd = 0xfffff800, | ||
195 | + .ro = 0x7ff, | ||
196 | + },{ .name = "XRAM_IEN", .addr = A_XRAM_IEN, | ||
197 | + .rsvd = 0xfffff800, | ||
198 | + .pre_write = xram_ien_prew, | ||
199 | + },{ .name = "XRAM_IDS", .addr = A_XRAM_IDS, | ||
200 | + .rsvd = 0xfffff800, | ||
201 | + .pre_write = xram_ids_prew, | ||
202 | + },{ .name = "XRAM_ECC_CNTL", .addr = A_XRAM_ECC_CNTL, | ||
203 | + .rsvd = 0xfffffff8, | ||
204 | + },{ .name = "XRAM_CLR_EXE", .addr = A_XRAM_CLR_EXE, | ||
205 | + .rsvd = 0xffffff00, | ||
206 | + },{ .name = "XRAM_CE_FFA", .addr = A_XRAM_CE_FFA, | ||
207 | + .rsvd = 0xfff00000, | ||
208 | + .ro = 0xfffff, | ||
209 | + },{ .name = "XRAM_CE_FFD0", .addr = A_XRAM_CE_FFD0, | ||
210 | + .ro = 0xffffffff, | ||
211 | + },{ .name = "XRAM_CE_FFD1", .addr = A_XRAM_CE_FFD1, | ||
212 | + .ro = 0xffffffff, | ||
213 | + },{ .name = "XRAM_CE_FFD2", .addr = A_XRAM_CE_FFD2, | ||
214 | + .ro = 0xffffffff, | ||
215 | + },{ .name = "XRAM_CE_FFD3", .addr = A_XRAM_CE_FFD3, | ||
216 | + .ro = 0xffffffff, | ||
217 | + },{ .name = "XRAM_CE_FFE", .addr = A_XRAM_CE_FFE, | ||
218 | + .rsvd = 0xffff0000, | ||
219 | + .ro = 0xffff, | ||
220 | + },{ .name = "XRAM_UE_FFA", .addr = A_XRAM_UE_FFA, | ||
221 | + .rsvd = 0xfff00000, | ||
222 | + .ro = 0xfffff, | ||
223 | + },{ .name = "XRAM_UE_FFD0", .addr = A_XRAM_UE_FFD0, | ||
224 | + .ro = 0xffffffff, | ||
225 | + },{ .name = "XRAM_UE_FFD1", .addr = A_XRAM_UE_FFD1, | ||
226 | + .ro = 0xffffffff, | ||
227 | + },{ .name = "XRAM_UE_FFD2", .addr = A_XRAM_UE_FFD2, | ||
228 | + .ro = 0xffffffff, | ||
229 | + },{ .name = "XRAM_UE_FFD3", .addr = A_XRAM_UE_FFD3, | ||
230 | + .ro = 0xffffffff, | ||
231 | + },{ .name = "XRAM_UE_FFE", .addr = A_XRAM_UE_FFE, | ||
232 | + .rsvd = 0xffff0000, | ||
233 | + .ro = 0xffff, | ||
234 | + },{ .name = "XRAM_FI_D0", .addr = A_XRAM_FI_D0, | ||
235 | + },{ .name = "XRAM_FI_D1", .addr = A_XRAM_FI_D1, | ||
236 | + },{ .name = "XRAM_FI_D2", .addr = A_XRAM_FI_D2, | ||
237 | + },{ .name = "XRAM_FI_D3", .addr = A_XRAM_FI_D3, | ||
238 | + },{ .name = "XRAM_FI_SY", .addr = A_XRAM_FI_SY, | ||
239 | + .rsvd = 0xffff0000, | ||
240 | + },{ .name = "XRAM_RMW_UE_FFA", .addr = A_XRAM_RMW_UE_FFA, | ||
241 | + .rsvd = 0xfff00000, | ||
242 | + .ro = 0xfffff, | ||
243 | + },{ .name = "XRAM_FI_CNTR", .addr = A_XRAM_FI_CNTR, | ||
244 | + .rsvd = 0xff000000, | ||
245 | + },{ .name = "XRAM_IMP", .addr = A_XRAM_IMP, | ||
246 | + .reset = 0x4, | ||
247 | + .rsvd = 0xfffffff0, | ||
248 | + .ro = 0xf, | ||
249 | + },{ .name = "XRAM_PRDY_DBG", .addr = A_XRAM_PRDY_DBG, | ||
250 | + .reset = 0xffff, | ||
251 | + .rsvd = 0xffff0000, | ||
252 | + .ro = 0xffff, | ||
253 | + },{ .name = "XRAM_SAFETY_CHK", .addr = A_XRAM_SAFETY_CHK, | ||
254 | + } | ||
255 | +}; | ||
256 | + | ||
257 | +static void xram_ctrl_reset_enter(Object *obj, ResetType type) | ||
258 | +{ | ||
259 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | ||
260 | + unsigned int i; | ||
261 | + | ||
262 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
263 | + register_reset(&s->regs_info[i]); | ||
264 | + } | ||
265 | + | ||
266 | + ARRAY_FIELD_DP32(s->regs, XRAM_IMP, SIZE, s->cfg.encoded_size); | ||
267 | +} | ||
268 | + | ||
269 | +static void xram_ctrl_reset_hold(Object *obj) | ||
270 | +{ | ||
271 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | ||
272 | + | ||
273 | + xram_update_irq(s); | ||
274 | +} | ||
275 | + | ||
276 | +static const MemoryRegionOps xram_ctrl_ops = { | ||
277 | + .read = register_read_memory, | ||
278 | + .write = register_write_memory, | ||
279 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
280 | + .valid = { | ||
281 | + .min_access_size = 4, | ||
282 | + .max_access_size = 4, | ||
283 | + }, | ||
284 | +}; | ||
285 | + | ||
286 | +static void xram_ctrl_realize(DeviceState *dev, Error **errp) | ||
287 | +{ | ||
288 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
289 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(dev); | ||
290 | + | ||
291 | + switch (s->cfg.size) { | ||
292 | + case 64 * KiB: | ||
293 | + s->cfg.encoded_size = 0; | ||
294 | + break; | ||
295 | + case 128 * KiB: | ||
296 | + s->cfg.encoded_size = 1; | ||
297 | + break; | ||
298 | + case 256 * KiB: | ||
299 | + s->cfg.encoded_size = 2; | ||
300 | + break; | ||
301 | + case 512 * KiB: | ||
302 | + s->cfg.encoded_size = 3; | ||
303 | + break; | ||
304 | + case 1 * MiB: | ||
305 | + s->cfg.encoded_size = 4; | ||
306 | + break; | ||
307 | + default: | ||
308 | + error_setg(errp, "Unsupported XRAM size %" PRId64, s->cfg.size); | ||
309 | + return; | ||
310 | + } | ||
311 | + | ||
312 | + memory_region_init_ram(&s->ram, OBJECT(s), | ||
313 | + object_get_canonical_path_component(OBJECT(s)), | ||
314 | + s->cfg.size, &error_fatal); | ||
315 | + sysbus_init_mmio(sbd, &s->ram); | ||
316 | +} | ||
317 | + | ||
318 | +static void xram_ctrl_init(Object *obj) | ||
319 | +{ | ||
320 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | ||
321 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
322 | + | ||
323 | + s->reg_array = | ||
324 | + register_init_block32(DEVICE(obj), xram_ctrl_regs_info, | ||
325 | + ARRAY_SIZE(xram_ctrl_regs_info), | ||
326 | + s->regs_info, s->regs, | ||
327 | + &xram_ctrl_ops, | ||
328 | + XLNX_XRAM_CTRL_ERR_DEBUG, | ||
329 | + XRAM_CTRL_R_MAX * 4); | ||
330 | + sysbus_init_mmio(sbd, &s->reg_array->mem); | ||
331 | + sysbus_init_irq(sbd, &s->irq); | ||
332 | +} | ||
333 | + | ||
334 | +static void xram_ctrl_finalize(Object *obj) | ||
335 | +{ | ||
336 | + XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | ||
337 | + register_finalize_block(s->reg_array); | ||
338 | +} | ||
339 | + | ||
340 | +static const VMStateDescription vmstate_xram_ctrl = { | ||
341 | + .name = TYPE_XLNX_XRAM_CTRL, | ||
342 | + .version_id = 1, | ||
343 | + .minimum_version_id = 1, | ||
344 | + .fields = (VMStateField[]) { | ||
345 | + VMSTATE_UINT32_ARRAY(regs, XlnxXramCtrl, XRAM_CTRL_R_MAX), | ||
346 | + VMSTATE_END_OF_LIST(), | ||
347 | + } | ||
348 | +}; | ||
349 | + | ||
350 | +static Property xram_ctrl_properties[] = { | ||
351 | + DEFINE_PROP_UINT64("size", XlnxXramCtrl, cfg.size, 1 * MiB), | ||
352 | + DEFINE_PROP_END_OF_LIST(), | ||
353 | +}; | ||
354 | + | ||
355 | +static void xram_ctrl_class_init(ObjectClass *klass, void *data) | ||
356 | +{ | ||
357 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
358 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
359 | + | ||
360 | + dc->realize = xram_ctrl_realize; | ||
361 | + dc->vmsd = &vmstate_xram_ctrl; | ||
362 | + device_class_set_props(dc, xram_ctrl_properties); | ||
363 | + | ||
364 | + rc->phases.enter = xram_ctrl_reset_enter; | ||
365 | + rc->phases.hold = xram_ctrl_reset_hold; | ||
366 | +} | ||
367 | + | ||
368 | +static const TypeInfo xram_ctrl_info = { | ||
369 | + .name = TYPE_XLNX_XRAM_CTRL, | ||
370 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
371 | + .instance_size = sizeof(XlnxXramCtrl), | ||
372 | + .class_init = xram_ctrl_class_init, | ||
373 | + .instance_init = xram_ctrl_init, | ||
374 | + .instance_finalize = xram_ctrl_finalize, | ||
375 | +}; | ||
376 | + | ||
377 | +static void xram_ctrl_register_types(void) | ||
378 | +{ | ||
379 | + type_register_static(&xram_ctrl_info); | ||
380 | +} | ||
381 | + | ||
382 | +type_init(xram_ctrl_register_types) | ||
383 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
384 | index XXXXXXX..XXXXXXX 100644 | ||
385 | --- a/hw/misc/meson.build | ||
386 | +++ b/hw/misc/meson.build | ||
387 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
388 | )) | ||
389 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | ||
390 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c')) | ||
391 | +softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-xramc.c')) | ||
392 | softmmu_ss.add(when: 'CONFIG_STM32F2XX_SYSCFG', if_true: files('stm32f2xx_syscfg.c')) | ||
393 | softmmu_ss.add(when: 'CONFIG_STM32F4XX_SYSCFG', if_true: files('stm32f4xx_syscfg.c')) | ||
394 | softmmu_ss.add(when: 'CONFIG_STM32F4XX_EXTI', if_true: files('stm32f4xx_exti.c')) | ||
395 | -- | ||
396 | 2.20.1 | ||
397 | |||
398 | diff view generated by jsdifflib |
1 | In commit f0aff255700 we made cpacr_write() enforce that some CPACR | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately | ||
3 | we forgot to also update the register's reset value. The effect | ||
4 | was that (a) a guest that read CPACR on reset would not see ones in | ||
5 | the RAO bits, and (b) if you did a migration before the guest did | ||
6 | a write to the CPACR then the migration would fail because the | ||
7 | destination would enforce the RAO bits and then complain that they | ||
8 | didn't match the zero value from the source. | ||
9 | 2 | ||
10 | Implement reset for the CPACR using a custom reset function | 3 | Connect the support for the Versal Accelerator RAMs (XRAMs). |
11 | that just calls cpacr_write(), to avoid having to duplicate | ||
12 | the logic for which bits are RAO. | ||
13 | 4 | ||
14 | This bug would affect migration for TCG CPUs which are ARMv7 | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
15 | with VFP but without one of Neon or VFPv3. | 6 | Acked-by: Alistair Francis <alistair.francis@wdc.com> |
7 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
8 | Message-id: 20210308224637.2949533-3-edgar.iglesias@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | docs/system/arm/xlnx-versal-virt.rst | 1 + | ||
12 | include/hw/arm/xlnx-versal.h | 13 ++++++++++ | ||
13 | hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++ | ||
14 | 3 files changed, 50 insertions(+) | ||
16 | 15 | ||
17 | Reported-by: Cédric Le Goater <clg@kaod.org> | 16 | diff --git a/docs/system/arm/xlnx-versal-virt.rst b/docs/system/arm/xlnx-versal-virt.rst |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
20 | Message-id: 20180522173713.26282-1-peter.maydell@linaro.org | ||
21 | --- | ||
22 | target/arm/helper.c | 10 +++++++++- | ||
23 | 1 file changed, 9 insertions(+), 1 deletion(-) | ||
24 | |||
25 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.c | 18 | --- a/docs/system/arm/xlnx-versal-virt.rst |
28 | +++ b/target/arm/helper.c | 19 | +++ b/docs/system/arm/xlnx-versal-virt.rst |
29 | @@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 20 | @@ -XXX,XX +XXX,XX @@ Implemented devices: |
30 | env->cp15.cpacr_el1 = value; | 21 | - 8 ADMA (Xilinx zDMA) channels |
22 | - 2 SD Controllers | ||
23 | - OCM (256KB of On Chip Memory) | ||
24 | +- XRAM (4MB of on chip Accelerator RAM) | ||
25 | - DDR memory | ||
26 | |||
27 | QEMU does not yet model any other devices, including the PL and the AI Engine. | ||
28 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/include/hw/arm/xlnx-versal.h | ||
31 | +++ b/include/hw/arm/xlnx-versal.h | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | |||
34 | #include "hw/sysbus.h" | ||
35 | #include "hw/arm/boot.h" | ||
36 | +#include "hw/or-irq.h" | ||
37 | #include "hw/sd/sdhci.h" | ||
38 | #include "hw/intc/arm_gicv3.h" | ||
39 | #include "hw/char/pl011.h" | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | #include "hw/rtc/xlnx-zynqmp-rtc.h" | ||
42 | #include "qom/object.h" | ||
43 | #include "hw/usb/xlnx-usb-subsystem.h" | ||
44 | +#include "hw/misc/xlnx-versal-xramc.h" | ||
45 | |||
46 | #define TYPE_XLNX_VERSAL "xlnx-versal" | ||
47 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) | ||
48 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) | ||
49 | #define XLNX_VERSAL_NR_GEMS 2 | ||
50 | #define XLNX_VERSAL_NR_ADMAS 8 | ||
51 | #define XLNX_VERSAL_NR_SDS 2 | ||
52 | +#define XLNX_VERSAL_NR_XRAM 4 | ||
53 | #define XLNX_VERSAL_NR_IRQS 192 | ||
54 | |||
55 | struct Versal { | ||
56 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
57 | XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS]; | ||
58 | VersalUsb2 usb; | ||
59 | } iou; | ||
60 | + | ||
61 | + struct { | ||
62 | + qemu_or_irq irq_orgate; | ||
63 | + XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | ||
64 | + } xram; | ||
65 | } lpd; | ||
66 | |||
67 | /* The Platform Management Controller subsystem. */ | ||
68 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
69 | #define VERSAL_GEM1_IRQ_0 58 | ||
70 | #define VERSAL_GEM1_WAKE_IRQ_0 59 | ||
71 | #define VERSAL_ADMA_IRQ_0 60 | ||
72 | +#define VERSAL_XRAM_IRQ_0 79 | ||
73 | #define VERSAL_RTC_APB_ERR_IRQ 121 | ||
74 | #define VERSAL_SD0_IRQ_0 126 | ||
75 | #define VERSAL_RTC_ALARM_IRQ 142 | ||
76 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
77 | #define MM_OCM 0xfffc0000U | ||
78 | #define MM_OCM_SIZE 0x40000 | ||
79 | |||
80 | +#define MM_XRAM 0xfe800000 | ||
81 | +#define MM_XRAMC 0xff8e0000 | ||
82 | +#define MM_XRAMC_SIZE 0x10000 | ||
83 | + | ||
84 | #define MM_USB2_CTRL_REGS 0xFF9D0000 | ||
85 | #define MM_USB2_CTRL_REGS_SIZE 0x10000 | ||
86 | |||
87 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/arm/xlnx-versal.c | ||
90 | +++ b/hw/arm/xlnx-versal.c | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | */ | ||
93 | |||
94 | #include "qemu/osdep.h" | ||
95 | +#include "qemu/units.h" | ||
96 | #include "qapi/error.h" | ||
97 | #include "qemu/log.h" | ||
98 | #include "qemu/module.h" | ||
99 | @@ -XXX,XX +XXX,XX @@ static void versal_create_rtc(Versal *s, qemu_irq *pic) | ||
100 | sysbus_connect_irq(sbd, 1, pic[VERSAL_RTC_APB_ERR_IRQ]); | ||
31 | } | 101 | } |
32 | 102 | ||
33 | +static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 103 | +static void versal_create_xrams(Versal *s, qemu_irq *pic) |
34 | +{ | 104 | +{ |
35 | + /* Call cpacr_write() so that we reset with the correct RAO bits set | 105 | + int nr_xrams = ARRAY_SIZE(s->lpd.xram.ctrl); |
36 | + * for our CPU features. | 106 | + DeviceState *orgate; |
37 | + */ | 107 | + int i; |
38 | + cpacr_write(env, ri, 0); | 108 | + |
109 | + /* XRAM IRQs get ORed into a single line. */ | ||
110 | + object_initialize_child(OBJECT(s), "xram-irq-orgate", | ||
111 | + &s->lpd.xram.irq_orgate, TYPE_OR_IRQ); | ||
112 | + orgate = DEVICE(&s->lpd.xram.irq_orgate); | ||
113 | + object_property_set_int(OBJECT(orgate), | ||
114 | + "num-lines", nr_xrams, &error_fatal); | ||
115 | + qdev_realize(orgate, NULL, &error_fatal); | ||
116 | + qdev_connect_gpio_out(orgate, 0, pic[VERSAL_XRAM_IRQ_0]); | ||
117 | + | ||
118 | + for (i = 0; i < ARRAY_SIZE(s->lpd.xram.ctrl); i++) { | ||
119 | + SysBusDevice *sbd; | ||
120 | + MemoryRegion *mr; | ||
121 | + | ||
122 | + object_initialize_child(OBJECT(s), "xram[*]", &s->lpd.xram.ctrl[i], | ||
123 | + TYPE_XLNX_XRAM_CTRL); | ||
124 | + sbd = SYS_BUS_DEVICE(&s->lpd.xram.ctrl[i]); | ||
125 | + sysbus_realize(sbd, &error_fatal); | ||
126 | + | ||
127 | + mr = sysbus_mmio_get_region(sbd, 0); | ||
128 | + memory_region_add_subregion(&s->mr_ps, | ||
129 | + MM_XRAMC + i * MM_XRAMC_SIZE, mr); | ||
130 | + mr = sysbus_mmio_get_region(sbd, 1); | ||
131 | + memory_region_add_subregion(&s->mr_ps, MM_XRAM + i * MiB, mr); | ||
132 | + | ||
133 | + sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(orgate, i)); | ||
134 | + } | ||
39 | +} | 135 | +} |
40 | + | 136 | + |
41 | static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri, | 137 | /* This takes the board allocated linear DDR memory and creates aliases |
42 | bool isread) | 138 | * for each split DDR range/aperture on the Versal address map. |
43 | { | 139 | */ |
44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | 140 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) |
45 | { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, | 141 | versal_create_admas(s, pic); |
46 | .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, | 142 | versal_create_sds(s, pic); |
47 | .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1), | 143 | versal_create_rtc(s, pic); |
48 | - .resetvalue = 0, .writefn = cpacr_write }, | 144 | + versal_create_xrams(s, pic); |
49 | + .resetfn = cpacr_reset, .writefn = cpacr_write }, | 145 | versal_map_ddr(s); |
50 | REGINFO_SENTINEL | 146 | versal_unimp(s); |
51 | }; | ||
52 | 147 | ||
53 | -- | 148 | -- |
54 | 2.17.1 | 149 | 2.20.1 |
55 | 150 | ||
56 | 151 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
1 | 2 | ||
3 | With -Werror=maybe-uninitialized configuration we get | ||
4 | ../hw/i386/intel_iommu.c: In function ‘vtd_context_device_invalidate’: | ||
5 | ../hw/i386/intel_iommu.c:1888:10: error: ‘mask’ may be used | ||
6 | uninitialized in this function [-Werror=maybe-uninitialized] | ||
7 | 1888 | mask = ~mask; | ||
8 | | ~~~~~^~~~~~~ | ||
9 | |||
10 | Add a g_assert_not_reached() to avoid the error. | ||
11 | |||
12 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Message-id: 20210309102742.30442-2-eric.auger@redhat.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/i386/intel_iommu.c | 2 ++ | ||
19 | 1 file changed, 2 insertions(+) | ||
20 | |||
21 | diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/i386/intel_iommu.c | ||
24 | +++ b/hw/i386/intel_iommu.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void vtd_context_device_invalidate(IntelIOMMUState *s, | ||
26 | case 3: | ||
27 | mask = 7; /* Mask bit 2:0 in the SID field */ | ||
28 | break; | ||
29 | + default: | ||
30 | + g_assert_not_reached(); | ||
31 | } | ||
32 | mask = ~mask; | ||
33 | |||
34 | -- | ||
35 | 2.20.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Eric Auger <eric.auger@redhat.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_map(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Currently get_naturally_aligned_size() is used by the intel iommu | ||
4 | to compute the maximum invalidation range based on @size which is | ||
5 | a power of 2 while being aligned with the @start address and less | ||
6 | than the maximum range defined by @gaw. | ||
7 | |||
8 | This helper is also useful for other iommu devices (virtio-iommu, | ||
9 | SMMUv3) to make sure IOMMU UNMAP notifiers only are called with | ||
10 | power of 2 range sizes. | ||
11 | |||
12 | Let's move this latter into dma-helpers.c and rename it into | ||
13 | dma_aligned_pow2_mask(). Also rewrite the helper so that it | ||
14 | accomodates UINT64_MAX values for the size mask and max mask. | ||
15 | It now returns a mask instead of a size. Change the caller. | ||
16 | |||
17 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
19 | Message-id: 20210309102742.30442-3-eric.auger@redhat.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-5-peter.maydell@linaro.org | ||
10 | --- | 21 | --- |
11 | include/exec/memory.h | 3 ++- | 22 | include/sysemu/dma.h | 12 ++++++++++++ |
12 | include/sysemu/dma.h | 3 ++- | 23 | hw/i386/intel_iommu.c | 30 +++++++----------------------- |
13 | exec.c | 6 ++++-- | 24 | softmmu/dma-helpers.c | 26 ++++++++++++++++++++++++++ |
14 | target/ppc/mmu-hash64.c | 3 ++- | 25 | 3 files changed, 45 insertions(+), 23 deletions(-) |
15 | 4 files changed, 10 insertions(+), 5 deletions(-) | ||
16 | 26 | ||
17 | diff --git a/include/exec/memory.h b/include/exec/memory.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/exec/memory.h | ||
20 | +++ b/include/exec/memory.h | ||
21 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_ | ||
22 | * @addr: address within that address space | ||
23 | * @plen: pointer to length of buffer; updated on return | ||
24 | * @is_write: indicates the transfer direction | ||
25 | + * @attrs: memory attributes | ||
26 | */ | ||
27 | void *address_space_map(AddressSpace *as, hwaddr addr, | ||
28 | - hwaddr *plen, bool is_write); | ||
29 | + hwaddr *plen, bool is_write, MemTxAttrs attrs); | ||
30 | |||
31 | /* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() | ||
32 | * | ||
33 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | 27 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h |
34 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/include/sysemu/dma.h | 29 | --- a/include/sysemu/dma.h |
36 | +++ b/include/sysemu/dma.h | 30 | +++ b/include/sysemu/dma.h |
37 | @@ -XXX,XX +XXX,XX @@ static inline void *dma_memory_map(AddressSpace *as, | 31 | @@ -XXX,XX +XXX,XX @@ uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); |
38 | hwaddr xlen = *len; | 32 | void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, |
39 | void *p; | 33 | QEMUSGList *sg, enum BlockAcctType type); |
40 | 34 | ||
41 | - p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE); | 35 | +/** |
42 | + p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE, | 36 | + * dma_aligned_pow2_mask: Return the address bit mask of the largest |
43 | + MEMTXATTRS_UNSPECIFIED); | 37 | + * power of 2 size less or equal than @end - @start + 1, aligned with @start, |
44 | *len = xlen; | 38 | + * and bounded by 1 << @max_addr_bits bits. |
45 | return p; | 39 | + * |
40 | + * @start: range start address | ||
41 | + * @end: range end address (greater than @start) | ||
42 | + * @max_addr_bits: max address bits (<= 64) | ||
43 | + */ | ||
44 | +uint64_t dma_aligned_pow2_mask(uint64_t start, uint64_t end, | ||
45 | + int max_addr_bits); | ||
46 | + | ||
47 | #endif | ||
48 | diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/i386/intel_iommu.c | ||
51 | +++ b/hw/i386/intel_iommu.c | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | #include "hw/i386/x86-iommu.h" | ||
54 | #include "hw/pci-host/q35.h" | ||
55 | #include "sysemu/kvm.h" | ||
56 | +#include "sysemu/dma.h" | ||
57 | #include "sysemu/sysemu.h" | ||
58 | #include "hw/i386/apic_internal.h" | ||
59 | #include "kvm/kvm_i386.h" | ||
60 | @@ -XXX,XX +XXX,XX @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) | ||
61 | return vtd_dev_as; | ||
46 | } | 62 | } |
47 | diff --git a/exec.c b/exec.c | 63 | |
64 | -static uint64_t get_naturally_aligned_size(uint64_t start, | ||
65 | - uint64_t size, int gaw) | ||
66 | -{ | ||
67 | - uint64_t max_mask = 1ULL << gaw; | ||
68 | - uint64_t alignment = start ? start & -start : max_mask; | ||
69 | - | ||
70 | - alignment = MIN(alignment, max_mask); | ||
71 | - size = MIN(size, max_mask); | ||
72 | - | ||
73 | - if (alignment <= size) { | ||
74 | - /* Increase the alignment of start */ | ||
75 | - return alignment; | ||
76 | - } else { | ||
77 | - /* Find the largest page mask from size */ | ||
78 | - return 1ULL << (63 - clz64(size)); | ||
79 | - } | ||
80 | -} | ||
81 | - | ||
82 | /* Unmap the whole range in the notifier's scope. */ | ||
83 | static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) | ||
84 | { | ||
85 | @@ -XXX,XX +XXX,XX @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) | ||
86 | |||
87 | while (remain >= VTD_PAGE_SIZE) { | ||
88 | IOMMUTLBEvent event; | ||
89 | - uint64_t mask = get_naturally_aligned_size(start, remain, s->aw_bits); | ||
90 | + uint64_t mask = dma_aligned_pow2_mask(start, end, s->aw_bits); | ||
91 | + uint64_t size = mask + 1; | ||
92 | |||
93 | - assert(mask); | ||
94 | + assert(size); | ||
95 | |||
96 | event.type = IOMMU_NOTIFIER_UNMAP; | ||
97 | event.entry.iova = start; | ||
98 | - event.entry.addr_mask = mask - 1; | ||
99 | + event.entry.addr_mask = mask; | ||
100 | event.entry.target_as = &address_space_memory; | ||
101 | event.entry.perm = IOMMU_NONE; | ||
102 | /* This field is meaningless for unmap */ | ||
103 | @@ -XXX,XX +XXX,XX @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) | ||
104 | |||
105 | memory_region_notify_iommu_one(n, &event); | ||
106 | |||
107 | - start += mask; | ||
108 | - remain -= mask; | ||
109 | + start += size; | ||
110 | + remain -= size; | ||
111 | } | ||
112 | |||
113 | assert(!remain); | ||
114 | diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | 115 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/exec.c | 116 | --- a/softmmu/dma-helpers.c |
50 | +++ b/exec.c | 117 | +++ b/softmmu/dma-helpers.c |
51 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | 118 | @@ -XXX,XX +XXX,XX @@ void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, |
52 | void *address_space_map(AddressSpace *as, | ||
53 | hwaddr addr, | ||
54 | hwaddr *plen, | ||
55 | - bool is_write) | ||
56 | + bool is_write, | ||
57 | + MemTxAttrs attrs) | ||
58 | { | 119 | { |
59 | hwaddr len = *plen; | 120 | block_acct_start(blk_get_stats(blk), cookie, sg->size, type); |
60 | hwaddr l, xlat; | ||
61 | @@ -XXX,XX +XXX,XX @@ void *cpu_physical_memory_map(hwaddr addr, | ||
62 | hwaddr *plen, | ||
63 | int is_write) | ||
64 | { | ||
65 | - return address_space_map(&address_space_memory, addr, plen, is_write); | ||
66 | + return address_space_map(&address_space_memory, addr, plen, is_write, | ||
67 | + MEMTXATTRS_UNSPECIFIED); | ||
68 | } | 121 | } |
69 | 122 | + | |
70 | void cpu_physical_memory_unmap(void *buffer, hwaddr len, | 123 | +uint64_t dma_aligned_pow2_mask(uint64_t start, uint64_t end, int max_addr_bits) |
71 | diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c | 124 | +{ |
72 | index XXXXXXX..XXXXXXX 100644 | 125 | + uint64_t max_mask = UINT64_MAX, addr_mask = end - start; |
73 | --- a/target/ppc/mmu-hash64.c | 126 | + uint64_t alignment_mask, size_mask; |
74 | +++ b/target/ppc/mmu-hash64.c | 127 | + |
75 | @@ -XXX,XX +XXX,XX @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu, | 128 | + if (max_addr_bits != 64) { |
76 | return NULL; | 129 | + max_mask = (1ULL << max_addr_bits) - 1; |
77 | } | 130 | + } |
78 | 131 | + | |
79 | - hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false); | 132 | + alignment_mask = start ? (start & -start) - 1 : max_mask; |
80 | + hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false, | 133 | + alignment_mask = MIN(alignment_mask, max_mask); |
81 | + MEMTXATTRS_UNSPECIFIED); | 134 | + size_mask = MIN(addr_mask, max_mask); |
82 | if (plen < (n * HASH_PTE_SIZE_64)) { | 135 | + |
83 | hw_error("%s: Unable to map all requested HPTEs\n", __func__); | 136 | + if (alignment_mask <= size_mask) { |
84 | } | 137 | + /* Increase the alignment of start */ |
138 | + return alignment_mask; | ||
139 | + } else { | ||
140 | + /* Find the largest page mask from size */ | ||
141 | + if (addr_mask == UINT64_MAX) { | ||
142 | + return UINT64_MAX; | ||
143 | + } | ||
144 | + return (1ULL << (63 - clz64(addr_mask + 1))) - 1; | ||
145 | + } | ||
146 | +} | ||
147 | + | ||
85 | -- | 148 | -- |
86 | 2.17.1 | 149 | 2.20.1 |
87 | 150 | ||
88 | 151 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
1 | 2 | ||
3 | Unmap notifiers work with an address mask assuming an | ||
4 | invalidation range of a power of 2. Nothing mandates this | ||
5 | in the VIRTIO-IOMMU spec. | ||
6 | |||
7 | So in case the range is not a power of 2, split it into | ||
8 | several invalidations. | ||
9 | |||
10 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
12 | Message-id: 20210309102742.30442-4-eric.auger@redhat.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/virtio/virtio-iommu.c | 19 ++++++++++++++++--- | ||
16 | 1 file changed, 16 insertions(+), 3 deletions(-) | ||
17 | |||
18 | diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/virtio/virtio-iommu.c | ||
21 | +++ b/hw/virtio/virtio-iommu.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, | ||
23 | hwaddr virt_end) | ||
24 | { | ||
25 | IOMMUTLBEvent event; | ||
26 | + uint64_t delta = virt_end - virt_start; | ||
27 | |||
28 | if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) { | ||
29 | return; | ||
30 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, | ||
31 | |||
32 | event.type = IOMMU_NOTIFIER_UNMAP; | ||
33 | event.entry.target_as = &address_space_memory; | ||
34 | - event.entry.addr_mask = virt_end - virt_start; | ||
35 | - event.entry.iova = virt_start; | ||
36 | event.entry.perm = IOMMU_NONE; | ||
37 | event.entry.translated_addr = 0; | ||
38 | + event.entry.addr_mask = delta; | ||
39 | + event.entry.iova = virt_start; | ||
40 | |||
41 | - memory_region_notify_iommu(mr, 0, event); | ||
42 | + if (delta == UINT64_MAX) { | ||
43 | + memory_region_notify_iommu(mr, 0, event); | ||
44 | + } | ||
45 | + | ||
46 | + | ||
47 | + while (virt_start != virt_end + 1) { | ||
48 | + uint64_t mask = dma_aligned_pow2_mask(virt_start, virt_end, 64); | ||
49 | + | ||
50 | + event.entry.addr_mask = mask; | ||
51 | + event.entry.iova = virt_start; | ||
52 | + memory_region_notify_iommu(mr, 0, event); | ||
53 | + virt_start += mask + 1; | ||
54 | + } | ||
55 | } | ||
56 | |||
57 | static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value, | ||
58 | -- | ||
59 | 2.20.1 | ||
60 | |||
61 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
1 | 2 | ||
3 | If the asid is not set, do not attempt to locate the key directly | ||
4 | as all inserted keys have a valid asid. | ||
5 | |||
6 | Use g_hash_table_foreach_remove instead. | ||
7 | |||
8 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Message-id: 20210309102742.30442-5-eric.auger@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/arm/smmu-common.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/smmu-common.c | ||
19 | +++ b/hw/arm/smmu-common.c | ||
20 | @@ -XXX,XX +XXX,XX @@ inline void | ||
21 | smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
22 | uint8_t tg, uint64_t num_pages, uint8_t ttl) | ||
23 | { | ||
24 | - if (ttl && (num_pages == 1)) { | ||
25 | + if (ttl && (num_pages == 1) && (asid >= 0)) { | ||
26 | SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl); | ||
27 | |||
28 | g_hash_table_remove(s->iotlb, &key); | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
1 | 2 | ||
3 | As of today, the driver can invalidate a number of pages that is | ||
4 | not a power of 2. However IOTLB unmap notifications and internal | ||
5 | IOTLB invalidations work with masks leading to erroneous | ||
6 | invalidations. | ||
7 | |||
8 | In case the range is not a power of 2, split invalidations into | ||
9 | power of 2 invalidations. | ||
10 | |||
11 | When looking for a single page entry in the vSMMU internal IOTLB, | ||
12 | let's make sure that if the entry is not found using a | ||
13 | g_hash_table_remove() we iterate over all the entries to find a | ||
14 | potential range that overlaps it. | ||
15 | |||
16 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
17 | Message-id: 20210309102742.30442-6-eric.auger@redhat.com | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | hw/arm/smmu-common.c | 30 ++++++++++++++++++------------ | ||
22 | hw/arm/smmuv3.c | 24 ++++++++++++++++++++---- | ||
23 | 2 files changed, 38 insertions(+), 16 deletions(-) | ||
24 | |||
25 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/arm/smmu-common.c | ||
28 | +++ b/hw/arm/smmu-common.c | ||
29 | @@ -XXX,XX +XXX,XX @@ inline void | ||
30 | smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
31 | uint8_t tg, uint64_t num_pages, uint8_t ttl) | ||
32 | { | ||
33 | + /* if tg is not set we use 4KB range invalidation */ | ||
34 | + uint8_t granule = tg ? tg * 2 + 10 : 12; | ||
35 | + | ||
36 | if (ttl && (num_pages == 1) && (asid >= 0)) { | ||
37 | SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl); | ||
38 | |||
39 | - g_hash_table_remove(s->iotlb, &key); | ||
40 | - } else { | ||
41 | - /* if tg is not set we use 4KB range invalidation */ | ||
42 | - uint8_t granule = tg ? tg * 2 + 10 : 12; | ||
43 | - | ||
44 | - SMMUIOTLBPageInvInfo info = { | ||
45 | - .asid = asid, .iova = iova, | ||
46 | - .mask = (num_pages * 1 << granule) - 1}; | ||
47 | - | ||
48 | - g_hash_table_foreach_remove(s->iotlb, | ||
49 | - smmu_hash_remove_by_asid_iova, | ||
50 | - &info); | ||
51 | + if (g_hash_table_remove(s->iotlb, &key)) { | ||
52 | + return; | ||
53 | + } | ||
54 | + /* | ||
55 | + * if the entry is not found, let's see if it does not | ||
56 | + * belong to a larger IOTLB entry | ||
57 | + */ | ||
58 | } | ||
59 | + | ||
60 | + SMMUIOTLBPageInvInfo info = { | ||
61 | + .asid = asid, .iova = iova, | ||
62 | + .mask = (num_pages * 1 << granule) - 1}; | ||
63 | + | ||
64 | + g_hash_table_foreach_remove(s->iotlb, | ||
65 | + smmu_hash_remove_by_asid_iova, | ||
66 | + &info); | ||
67 | } | ||
68 | |||
69 | inline void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) | ||
70 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/hw/arm/smmuv3.c | ||
73 | +++ b/hw/arm/smmuv3.c | ||
74 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
75 | uint16_t vmid = CMD_VMID(cmd); | ||
76 | bool leaf = CMD_LEAF(cmd); | ||
77 | uint8_t tg = CMD_TG(cmd); | ||
78 | - hwaddr num_pages = 1; | ||
79 | + uint64_t first_page = 0, last_page; | ||
80 | + uint64_t num_pages = 1; | ||
81 | int asid = -1; | ||
82 | |||
83 | if (tg) { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
85 | if (type == SMMU_CMD_TLBI_NH_VA) { | ||
86 | asid = CMD_ASID(cmd); | ||
87 | } | ||
88 | - trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | ||
89 | - smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages); | ||
90 | - smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl); | ||
91 | + | ||
92 | + /* Split invalidations into ^2 range invalidations */ | ||
93 | + last_page = num_pages - 1; | ||
94 | + while (num_pages) { | ||
95 | + uint8_t granule = tg * 2 + 10; | ||
96 | + uint64_t mask, count; | ||
97 | + | ||
98 | + mask = dma_aligned_pow2_mask(first_page, last_page, 64 - granule); | ||
99 | + count = mask + 1; | ||
100 | + | ||
101 | + trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, count, ttl, leaf); | ||
102 | + smmuv3_inv_notifiers_iova(s, asid, addr, tg, count); | ||
103 | + smmu_iotlb_inv_iova(s, asid, addr, tg, count, ttl); | ||
104 | + | ||
105 | + num_pages -= count; | ||
106 | + first_page += count; | ||
107 | + addr += count * BIT_ULL(granule); | ||
108 | + } | ||
109 | } | ||
110 | |||
111 | static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
112 | -- | ||
113 | 2.20.1 | ||
114 | |||
115 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
1 | 2 | ||
3 | If the whole SID range (32b) is invalidated (SMMU_CMD_CFGI_ALL), | ||
4 | @end overflows and we fail to handle the command properly. | ||
5 | |||
6 | Once this gets fixed, the current code really is awkward in the | ||
7 | sense it loops over the whole range instead of removing the | ||
8 | currently cached configs through a hash table lookup. | ||
9 | |||
10 | Fix both the overflow and the lookup. | ||
11 | |||
12 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Message-id: 20210309102742.30442-7-eric.auger@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/arm/smmu-internal.h | 5 +++++ | ||
18 | hw/arm/smmuv3.c | 34 ++++++++++++++++++++-------------- | ||
19 | 2 files changed, 25 insertions(+), 14 deletions(-) | ||
20 | |||
21 | diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/arm/smmu-internal.h | ||
24 | +++ b/hw/arm/smmu-internal.h | ||
25 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUIOTLBPageInvInfo { | ||
26 | uint64_t mask; | ||
27 | } SMMUIOTLBPageInvInfo; | ||
28 | |||
29 | +typedef struct SMMUSIDRange { | ||
30 | + uint32_t start; | ||
31 | + uint32_t end; | ||
32 | +} SMMUSIDRange; | ||
33 | + | ||
34 | #endif | ||
35 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/arm/smmuv3.c | ||
38 | +++ b/hw/arm/smmuv3.c | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | |||
41 | #include "hw/arm/smmuv3.h" | ||
42 | #include "smmuv3-internal.h" | ||
43 | +#include "smmu-internal.h" | ||
44 | |||
45 | /** | ||
46 | * smmuv3_trigger_irq - pulse @irq if enabled and update | ||
47 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
48 | } | ||
49 | } | ||
50 | |||
51 | +static gboolean | ||
52 | +smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data) | ||
53 | +{ | ||
54 | + SMMUDevice *sdev = (SMMUDevice *)key; | ||
55 | + uint32_t sid = smmu_get_sid(sdev); | ||
56 | + SMMUSIDRange *sid_range = (SMMUSIDRange *)user_data; | ||
57 | + | ||
58 | + if (sid < sid_range->start || sid > sid_range->end) { | ||
59 | + return false; | ||
60 | + } | ||
61 | + trace_smmuv3_config_cache_inv(sid); | ||
62 | + return true; | ||
63 | +} | ||
64 | + | ||
65 | static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
66 | { | ||
67 | SMMUState *bs = ARM_SMMU(s); | ||
68 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
69 | } | ||
70 | case SMMU_CMD_CFGI_STE_RANGE: /* same as SMMU_CMD_CFGI_ALL */ | ||
71 | { | ||
72 | - uint32_t start = CMD_SID(&cmd), end, i; | ||
73 | + uint32_t start = CMD_SID(&cmd); | ||
74 | uint8_t range = CMD_STE_RANGE(&cmd); | ||
75 | + uint64_t end = start + (1ULL << (range + 1)) - 1; | ||
76 | + SMMUSIDRange sid_range = {start, end}; | ||
77 | |||
78 | if (CMD_SSEC(&cmd)) { | ||
79 | cmd_error = SMMU_CERROR_ILL; | ||
80 | break; | ||
81 | } | ||
82 | - | ||
83 | - end = start + (1 << (range + 1)) - 1; | ||
84 | trace_smmuv3_cmdq_cfgi_ste_range(start, end); | ||
85 | - | ||
86 | - for (i = start; i <= end; i++) { | ||
87 | - IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, i); | ||
88 | - SMMUDevice *sdev; | ||
89 | - | ||
90 | - if (!mr) { | ||
91 | - continue; | ||
92 | - } | ||
93 | - sdev = container_of(mr, SMMUDevice, iommu); | ||
94 | - smmuv3_flush_config(sdev); | ||
95 | - } | ||
96 | + g_hash_table_foreach_remove(bs->configs, smmuv3_invalidate_ste, | ||
97 | + &sid_range); | ||
98 | break; | ||
99 | } | ||
100 | case SMMU_CMD_CFGI_CD: | ||
101 | -- | ||
102 | 2.20.1 | ||
103 | |||
104 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
1 | 2 | ||
3 | Convert all sid printouts to sid=0x%x. | ||
4 | |||
5 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20210309102742.30442-8-eric.auger@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/trace-events | 24 ++++++++++++------------ | ||
11 | 1 file changed, 12 insertions(+), 12 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/trace-events | ||
16 | +++ b/hw/arm/trace-events | ||
17 | @@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_opcode(const char *opcode) "<--- %s" | ||
18 | smmuv3_cmdq_consume_out(uint32_t prod, uint32_t cons, uint8_t prod_wrap, uint8_t cons_wrap) "prod:%d, cons:%d, prod_wrap:%d, cons_wrap:%d " | ||
19 | smmuv3_cmdq_consume_error(const char *cmd_name, uint8_t cmd_error) "Error on %s command execution: %d" | ||
20 | smmuv3_write_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)" | ||
21 | -smmuv3_record_event(const char *type, uint32_t sid) "%s sid=%d" | ||
22 | -smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "SID:0x%x features:0x%x, sid_split:0x%x" | ||
23 | +smmuv3_record_event(const char *type, uint32_t sid) "%s sid=0x%x" | ||
24 | +smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "sid=0x%x features:0x%x, sid_split:0x%x" | ||
25 | smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d" | ||
26 | smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64 | ||
27 | -smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" | ||
28 | -smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d STE bypass iova:0x%"PRIx64" is_write=%d" | ||
29 | -smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d abort on iova:0x%"PRIx64" is_write=%d" | ||
30 | -smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" | ||
31 | +smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" | ||
32 | +smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x STE bypass iova:0x%"PRIx64" is_write=%d" | ||
33 | +smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x abort on iova:0x%"PRIx64" is_write=%d" | ||
34 | +smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=0x%x iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" | ||
35 | smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 | ||
36 | smmuv3_decode_cd(uint32_t oas) "oas=%d" | ||
37 | smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz, bool had) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d had:%d" | ||
38 | -smmuv3_cmdq_cfgi_ste(int streamid) "streamid =%d" | ||
39 | +smmuv3_cmdq_cfgi_ste(int streamid) "streamid= 0x%x" | ||
40 | smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%x - end=0x%x" | ||
41 | -smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d" | ||
42 | -smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
43 | -smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)" | ||
44 | -smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" | ||
45 | +smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x" | ||
46 | +smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" | ||
47 | +smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" | ||
48 | +smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" | ||
49 | smmuv3_cmdq_tlbi_nh(void) "" | ||
50 | smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" | ||
51 | -smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d" | ||
52 | +smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x" | ||
53 | smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s" | ||
54 | smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s" | ||
55 | smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64 | ||
56 | -- | ||
57 | 2.20.1 | ||
58 | |||
59 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Missed out on compressing the second half of a predicate | ||
4 | with length vl % 512 > 256. | ||
5 | |||
6 | Adjust all of the x + (y << s) to x | (y << s) as a | ||
7 | general style fix. Drop the extract64 because the input | ||
8 | uint64_t are known to be already zero-extended from the | ||
9 | current size of the predicate. | ||
10 | |||
11 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210309155305.11301-2-richard.henderson@linaro.org | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/sve_helper.c | 30 +++++++++++++++++++++--------- | ||
18 | 1 file changed, 21 insertions(+), 9 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/sve_helper.c | ||
23 | +++ b/target/arm/sve_helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | ||
25 | if (oprsz <= 8) { | ||
26 | l = compress_bits(n[0] >> odd, esz); | ||
27 | h = compress_bits(m[0] >> odd, esz); | ||
28 | - d[0] = extract64(l + (h << (4 * oprsz)), 0, 8 * oprsz); | ||
29 | + d[0] = l | (h << (4 * oprsz)); | ||
30 | } else { | ||
31 | ARMPredicateReg tmp_m; | ||
32 | intptr_t oprsz_16 = oprsz / 16; | ||
33 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | ||
34 | h = n[2 * i + 1]; | ||
35 | l = compress_bits(l >> odd, esz); | ||
36 | h = compress_bits(h >> odd, esz); | ||
37 | - d[i] = l + (h << 32); | ||
38 | + d[i] = l | (h << 32); | ||
39 | } | ||
40 | |||
41 | - /* For VL which is not a power of 2, the results from M do not | ||
42 | - align nicely with the uint64_t for D. Put the aligned results | ||
43 | - from M into TMP_M and then copy it into place afterward. */ | ||
44 | + /* | ||
45 | + * For VL which is not a multiple of 512, the results from M do not | ||
46 | + * align nicely with the uint64_t for D. Put the aligned results | ||
47 | + * from M into TMP_M and then copy it into place afterward. | ||
48 | + */ | ||
49 | if (oprsz & 15) { | ||
50 | - d[i] = compress_bits(n[2 * i] >> odd, esz); | ||
51 | + int final_shift = (oprsz & 15) * 2; | ||
52 | + | ||
53 | + l = n[2 * i + 0]; | ||
54 | + h = n[2 * i + 1]; | ||
55 | + l = compress_bits(l >> odd, esz); | ||
56 | + h = compress_bits(h >> odd, esz); | ||
57 | + d[i] = l | (h << final_shift); | ||
58 | |||
59 | for (i = 0; i < oprsz_16; i++) { | ||
60 | l = m[2 * i + 0]; | ||
61 | h = m[2 * i + 1]; | ||
62 | l = compress_bits(l >> odd, esz); | ||
63 | h = compress_bits(h >> odd, esz); | ||
64 | - tmp_m.p[i] = l + (h << 32); | ||
65 | + tmp_m.p[i] = l | (h << 32); | ||
66 | } | ||
67 | - tmp_m.p[i] = compress_bits(m[2 * i] >> odd, esz); | ||
68 | + l = m[2 * i + 0]; | ||
69 | + h = m[2 * i + 1]; | ||
70 | + l = compress_bits(l >> odd, esz); | ||
71 | + h = compress_bits(h >> odd, esz); | ||
72 | + tmp_m.p[i] = l | (h << final_shift); | ||
73 | |||
74 | swap_memmove(vd + oprsz / 2, &tmp_m, oprsz / 2); | ||
75 | } else { | ||
76 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | ||
77 | h = m[2 * i + 1]; | ||
78 | l = compress_bits(l >> odd, esz); | ||
79 | h = compress_bits(h >> odd, esz); | ||
80 | - d[oprsz_16 + i] = l + (h << 32); | ||
81 | + d[oprsz_16 + i] = l | (h << 32); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | -- | ||
86 | 2.20.1 | ||
87 | |||
88 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to memory_region_access_valid(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
6 | The callsite in flatview_access_valid() is part of a recursive | 3 | Wrote too much with low-half zip (zip1) with vl % 512 != 0. |
7 | loop flatview_access_valid() -> memory_region_access_valid() -> | ||
8 | subpage_accepts() -> flatview_access_valid(); we make it pass | ||
9 | MEMTXATTRS_UNSPECIFIED for now, until the next several commits | ||
10 | have plumbed an attrs parameter through the rest of the loop | ||
11 | and we can add an attrs parameter to flatview_access_valid(). | ||
12 | 4 | ||
5 | Adjust all of the x + (y << s) to x | (y << s) as a style fix. | ||
6 | |||
7 | We only ever have exact overlap between D, M, and N. Therefore | ||
8 | we only need a single temporary, and we do not need to check for | ||
9 | partial overlap. | ||
10 | |||
11 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210309155305.11301-3-richard.henderson@linaro.org | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20180521140402.23318-8-peter.maydell@linaro.org | ||
17 | --- | 16 | --- |
18 | include/exec/memory-internal.h | 3 ++- | 17 | target/arm/sve_helper.c | 25 ++++++++++++++----------- |
19 | exec.c | 4 +++- | 18 | 1 file changed, 14 insertions(+), 11 deletions(-) |
20 | hw/s390x/s390-pci-inst.c | 3 ++- | ||
21 | memory.c | 7 ++++--- | ||
22 | 4 files changed, 11 insertions(+), 6 deletions(-) | ||
23 | 19 | ||
24 | diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h | 20 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
25 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory-internal.h | 22 | --- a/target/arm/sve_helper.c |
27 | +++ b/include/exec/memory-internal.h | 23 | +++ b/target/arm/sve_helper.c |
28 | @@ -XXX,XX +XXX,XX @@ void flatview_unref(FlatView *view); | 24 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) |
29 | extern const MemoryRegionOps unassigned_mem_ops; | 25 | intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); |
30 | 26 | int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); | |
31 | bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr, | 27 | intptr_t high = FIELD_EX32(pred_desc, PREDDESC, DATA); |
32 | - unsigned size, bool is_write); | 28 | + int esize = 1 << esz; |
33 | + unsigned size, bool is_write, | 29 | uint64_t *d = vd; |
34 | + MemTxAttrs attrs); | 30 | intptr_t i; |
35 | 31 | ||
36 | void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); | 32 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) |
37 | AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); | 33 | mm = extract64(mm, high * half, half); |
38 | diff --git a/exec.c b/exec.c | 34 | nn = expand_bits(nn, esz); |
39 | index XXXXXXX..XXXXXXX 100644 | 35 | mm = expand_bits(mm, esz); |
40 | --- a/exec.c | 36 | - d[0] = nn + (mm << (1 << esz)); |
41 | +++ b/exec.c | 37 | + d[0] = nn | (mm << esize); |
42 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 38 | } else { |
43 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | 39 | - ARMPredicateReg tmp_n, tmp_m; |
44 | if (!memory_access_is_direct(mr, is_write)) { | 40 | + ARMPredicateReg tmp; |
45 | l = memory_access_size(mr, l, addr); | 41 | |
46 | - if (!memory_region_access_valid(mr, xlat, l, is_write)) { | 42 | /* We produce output faster than we consume input. |
47 | + /* When our callers all have attrs we'll pass them through here */ | 43 | Therefore we must be mindful of possible overlap. */ |
48 | + if (!memory_region_access_valid(mr, xlat, l, is_write, | 44 | - if ((vn - vd) < (uintptr_t)oprsz) { |
49 | + MEMTXATTRS_UNSPECIFIED)) { | 45 | - vn = memcpy(&tmp_n, vn, oprsz); |
50 | return false; | 46 | - } |
47 | - if ((vm - vd) < (uintptr_t)oprsz) { | ||
48 | - vm = memcpy(&tmp_m, vm, oprsz); | ||
49 | + if (vd == vn) { | ||
50 | + vn = memcpy(&tmp, vn, oprsz); | ||
51 | + if (vd == vm) { | ||
52 | + vm = vn; | ||
53 | + } | ||
54 | + } else if (vd == vm) { | ||
55 | + vm = memcpy(&tmp, vm, oprsz); | ||
56 | } | ||
57 | if (high) { | ||
58 | high = oprsz >> 1; | ||
59 | } | ||
60 | |||
61 | - if ((high & 3) == 0) { | ||
62 | + if ((oprsz & 7) == 0) { | ||
63 | uint32_t *n = vn, *m = vm; | ||
64 | high >>= 2; | ||
65 | |||
66 | - for (i = 0; i < DIV_ROUND_UP(oprsz, 8); i++) { | ||
67 | + for (i = 0; i < oprsz / 8; i++) { | ||
68 | uint64_t nn = n[H4(high + i)]; | ||
69 | uint64_t mm = m[H4(high + i)]; | ||
70 | |||
71 | nn = expand_bits(nn, esz); | ||
72 | mm = expand_bits(mm, esz); | ||
73 | - d[i] = nn + (mm << (1 << esz)); | ||
74 | + d[i] = nn | (mm << esize); | ||
75 | } | ||
76 | } else { | ||
77 | uint8_t *n = vn, *m = vm; | ||
78 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc) | ||
79 | |||
80 | nn = expand_bits(nn, esz); | ||
81 | mm = expand_bits(mm, esz); | ||
82 | - d16[H2(i)] = nn + (mm << (1 << esz)); | ||
83 | + d16[H2(i)] = nn | (mm << esize); | ||
51 | } | 84 | } |
52 | } | 85 | } |
53 | diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/s390x/s390-pci-inst.c | ||
56 | +++ b/hw/s390x/s390-pci-inst.c | ||
57 | @@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr, | ||
58 | mr = s390_get_subregion(mr, offset, len); | ||
59 | offset -= mr->addr; | ||
60 | |||
61 | - if (!memory_region_access_valid(mr, offset, len, true)) { | ||
62 | + if (!memory_region_access_valid(mr, offset, len, true, | ||
63 | + MEMTXATTRS_UNSPECIFIED)) { | ||
64 | s390_program_interrupt(env, PGM_OPERAND, 6, ra); | ||
65 | return 0; | ||
66 | } | ||
67 | diff --git a/memory.c b/memory.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/memory.c | ||
70 | +++ b/memory.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ram_device_mem_ops = { | ||
72 | bool memory_region_access_valid(MemoryRegion *mr, | ||
73 | hwaddr addr, | ||
74 | unsigned size, | ||
75 | - bool is_write) | ||
76 | + bool is_write, | ||
77 | + MemTxAttrs attrs) | ||
78 | { | ||
79 | int access_size_min, access_size_max; | ||
80 | int access_size, i; | ||
81 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr, | ||
82 | { | ||
83 | MemTxResult r; | ||
84 | |||
85 | - if (!memory_region_access_valid(mr, addr, size, false)) { | ||
86 | + if (!memory_region_access_valid(mr, addr, size, false, attrs)) { | ||
87 | *pval = unassigned_mem_read(mr, addr, size); | ||
88 | return MEMTX_DECODE_ERROR; | ||
89 | } | ||
90 | @@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, | ||
91 | unsigned size, | ||
92 | MemTxAttrs attrs) | ||
93 | { | ||
94 | - if (!memory_region_access_valid(mr, addr, size, true)) { | ||
95 | + if (!memory_region_access_valid(mr, addr, size, true, attrs)) { | ||
96 | unassigned_mem_write(mr, addr, data, size); | ||
97 | return MEMTX_DECODE_ERROR; | ||
98 | } | 86 | } |
99 | -- | 87 | -- |
100 | 2.17.1 | 88 | 2.20.1 |
101 | 89 | ||
102 | 90 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Wrote too much with punpk1 with vl % 512 != 0. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210309155305.11301-4-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/sve_helper.c | 4 ++-- | ||
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/sve_helper.c | ||
17 | +++ b/target/arm/sve_helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_punpk_p)(void *vd, void *vn, uint32_t pred_desc) | ||
19 | high = oprsz >> 1; | ||
20 | } | ||
21 | |||
22 | - if ((high & 3) == 0) { | ||
23 | + if ((oprsz & 7) == 0) { | ||
24 | uint32_t *n = vn; | ||
25 | high >>= 2; | ||
26 | |||
27 | - for (i = 0; i < DIV_ROUND_UP(oprsz, 8); i++) { | ||
28 | + for (i = 0; i < oprsz / 8; i++) { | ||
29 | uint64_t nn = n[H4(high + i)]; | ||
30 | d[i] = expand_bits(nn, 0); | ||
31 | } | ||
32 | -- | ||
33 | 2.20.1 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_translate_iommu(). | ||
3 | 2 | ||
3 | Since b64ee454a4a0, all predicate operations should be | ||
4 | using these field macros for predicates. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210309155305.11301-5-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-14-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | exec.c | 8 +++++--- | 11 | target/arm/sve_helper.c | 6 +++--- |
10 | 1 file changed, 5 insertions(+), 3 deletions(-) | 12 | target/arm/translate-sve.c | 7 +++---- |
13 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
11 | 14 | ||
12 | diff --git a/exec.c b/exec.c | 15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 17 | --- a/target/arm/sve_helper.c |
15 | +++ b/exec.c | 18 | +++ b/target/arm/sve_helper.c |
16 | @@ -XXX,XX +XXX,XX @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x | 19 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_compact_d)(void *vd, void *vn, void *vg, uint32_t desc) |
17 | * @is_write: whether the translation operation is for write | 20 | */ |
18 | * @is_mmio: whether this can be MMIO, set true if it can | 21 | int32_t HELPER(sve_last_active_element)(void *vg, uint32_t pred_desc) |
19 | * @target_as: the address space targeted by the IOMMU | ||
20 | + * @attrs: transaction attributes | ||
21 | * | ||
22 | * This function is called from RCU critical section. It is the common | ||
23 | * part of flatview_do_translate and address_space_translate_cached. | ||
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iomm | ||
25 | hwaddr *page_mask_out, | ||
26 | bool is_write, | ||
27 | bool is_mmio, | ||
28 | - AddressSpace **target_as) | ||
29 | + AddressSpace **target_as, | ||
30 | + MemTxAttrs attrs) | ||
31 | { | 22 | { |
32 | MemoryRegionSection *section; | 23 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; |
33 | hwaddr page_mask = (hwaddr)-1; | 24 | - intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2); |
34 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | 25 | + intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8); |
35 | return address_space_translate_iommu(iommu_mr, xlat, | 26 | + intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); |
36 | plen_out, page_mask_out, | 27 | |
37 | is_write, is_mmio, | 28 | - return last_active_element(vg, DIV_ROUND_UP(oprsz, 8), esz); |
38 | - target_as); | 29 | + return last_active_element(vg, words, esz); |
39 | + target_as, attrs); | ||
40 | } | ||
41 | if (page_mask_out) { | ||
42 | /* Not behind an IOMMU, use default page size. */ | ||
43 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate_cached( | ||
44 | |||
45 | section = address_space_translate_iommu(iommu_mr, xlat, plen, | ||
46 | NULL, is_write, true, | ||
47 | - &target_as); | ||
48 | + &target_as, attrs); | ||
49 | return section.mr; | ||
50 | } | 30 | } |
51 | 31 | ||
32 | void HELPER(sve_splice)(void *vd, void *vn, void *vm, void *vg, uint32_t desc) | ||
33 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/translate-sve.c | ||
36 | +++ b/target/arm/translate-sve.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static void find_last_active(DisasContext *s, TCGv_i32 ret, int esz, int pg) | ||
38 | */ | ||
39 | TCGv_ptr t_p = tcg_temp_new_ptr(); | ||
40 | TCGv_i32 t_desc; | ||
41 | - unsigned vsz = pred_full_reg_size(s); | ||
42 | - unsigned desc; | ||
43 | + unsigned desc = 0; | ||
44 | |||
45 | - desc = vsz - 2; | ||
46 | - desc = deposit32(desc, SIMD_DATA_SHIFT, 2, esz); | ||
47 | + desc = FIELD_DP32(desc, PREDDESC, OPRSZ, pred_full_reg_size(s)); | ||
48 | + desc = FIELD_DP32(desc, PREDDESC, ESZ, esz); | ||
49 | |||
50 | tcg_gen_addi_ptr(t_p, cpu_env, pred_full_reg_offset(s, pg)); | ||
51 | t_desc = tcg_const_i32(desc); | ||
52 | -- | 52 | -- |
53 | 2.17.1 | 53 | 2.20.1 |
54 | 54 | ||
55 | 55 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_access_valid(). | ||
3 | Its callers now all have an attrs value to hand, so we can | ||
4 | correct our earlier temporary use of MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | Since b64ee454a4a0, all predicate operations should be | ||
4 | using these field macros for predicates. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210309155305.11301-6-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-10-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | exec.c | 12 +++++------- | 11 | target/arm/sve_helper.c | 30 ++++++++++++++---------------- |
12 | 1 file changed, 5 insertions(+), 7 deletions(-) | 12 | target/arm/translate-sve.c | 4 ++-- |
13 | 2 files changed, 16 insertions(+), 18 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/exec.c b/exec.c | 15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 17 | --- a/target/arm/sve_helper.c |
17 | +++ b/exec.c | 18 | +++ b/target/arm/sve_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | 19 | @@ -XXX,XX +XXX,XX @@ static uint32_t do_zero(ARMPredicateReg *d, intptr_t oprsz) |
19 | static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 20 | void HELPER(sve_brkpa)(void *vd, void *vn, void *vm, void *vg, |
20 | const uint8_t *buf, int len); | 21 | uint32_t pred_desc) |
21 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 22 | { |
22 | - bool is_write); | 23 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; |
23 | + bool is_write, MemTxAttrs attrs); | 24 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); |
24 | 25 | if (last_active_pred(vn, vg, oprsz)) { | |
25 | static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data, | 26 | compute_brk_z(vd, vm, vg, oprsz, true); |
26 | unsigned len, MemTxAttrs attrs) | 27 | } else { |
27 | @@ -XXX,XX +XXX,XX @@ static bool subpage_accepts(void *opaque, hwaddr addr, | 28 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_brkpa)(void *vd, void *vn, void *vm, void *vg, |
28 | #endif | 29 | uint32_t HELPER(sve_brkpas)(void *vd, void *vn, void *vm, void *vg, |
29 | 30 | uint32_t pred_desc) | |
30 | return flatview_access_valid(subpage->fv, addr + subpage->base, | 31 | { |
31 | - len, is_write); | 32 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; |
32 | + len, is_write, attrs); | 33 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); |
34 | if (last_active_pred(vn, vg, oprsz)) { | ||
35 | return compute_brks_z(vd, vm, vg, oprsz, true); | ||
36 | } else { | ||
37 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkpas)(void *vd, void *vn, void *vm, void *vg, | ||
38 | void HELPER(sve_brkpb)(void *vd, void *vn, void *vm, void *vg, | ||
39 | uint32_t pred_desc) | ||
40 | { | ||
41 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
42 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
43 | if (last_active_pred(vn, vg, oprsz)) { | ||
44 | compute_brk_z(vd, vm, vg, oprsz, false); | ||
45 | } else { | ||
46 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve_brkpb)(void *vd, void *vn, void *vm, void *vg, | ||
47 | uint32_t HELPER(sve_brkpbs)(void *vd, void *vn, void *vm, void *vg, | ||
48 | uint32_t pred_desc) | ||
49 | { | ||
50 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
51 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
52 | if (last_active_pred(vn, vg, oprsz)) { | ||
53 | return compute_brks_z(vd, vm, vg, oprsz, false); | ||
54 | } else { | ||
55 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkpbs)(void *vd, void *vn, void *vm, void *vg, | ||
56 | |||
57 | void HELPER(sve_brka_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
58 | { | ||
59 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
60 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
61 | compute_brk_z(vd, vn, vg, oprsz, true); | ||
33 | } | 62 | } |
34 | 63 | ||
35 | static const MemoryRegionOps subpage_ops = { | 64 | uint32_t HELPER(sve_brkas_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) |
36 | @@ -XXX,XX +XXX,XX @@ static void cpu_notify_map_clients(void) | 65 | { |
66 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
67 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
68 | return compute_brks_z(vd, vn, vg, oprsz, true); | ||
37 | } | 69 | } |
38 | 70 | ||
39 | static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 71 | void HELPER(sve_brkb_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) |
40 | - bool is_write) | ||
41 | + bool is_write, MemTxAttrs attrs) | ||
42 | { | 72 | { |
43 | MemoryRegion *mr; | 73 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; |
44 | hwaddr l, xlat; | 74 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); |
45 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 75 | compute_brk_z(vd, vn, vg, oprsz, false); |
46 | mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
47 | if (!memory_access_is_direct(mr, is_write)) { | ||
48 | l = memory_access_size(mr, l, addr); | ||
49 | - /* When our callers all have attrs we'll pass them through here */ | ||
50 | - if (!memory_region_access_valid(mr, xlat, l, is_write, | ||
51 | - MEMTXATTRS_UNSPECIFIED)) { | ||
52 | + if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | ||
57 | |||
58 | rcu_read_lock(); | ||
59 | fv = address_space_to_flatview(as); | ||
60 | - result = flatview_access_valid(fv, addr, len, is_write); | ||
61 | + result = flatview_access_valid(fv, addr, len, is_write, attrs); | ||
62 | rcu_read_unlock(); | ||
63 | return result; | ||
64 | } | 76 | } |
77 | |||
78 | uint32_t HELPER(sve_brkbs_z)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
79 | { | ||
80 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
81 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
82 | return compute_brks_z(vd, vn, vg, oprsz, false); | ||
83 | } | ||
84 | |||
85 | void HELPER(sve_brka_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
86 | { | ||
87 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
88 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
89 | compute_brk_m(vd, vn, vg, oprsz, true); | ||
90 | } | ||
91 | |||
92 | uint32_t HELPER(sve_brkas_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
93 | { | ||
94 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
95 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
96 | return compute_brks_m(vd, vn, vg, oprsz, true); | ||
97 | } | ||
98 | |||
99 | void HELPER(sve_brkb_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
100 | { | ||
101 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
102 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
103 | compute_brk_m(vd, vn, vg, oprsz, false); | ||
104 | } | ||
105 | |||
106 | uint32_t HELPER(sve_brkbs_m)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
107 | { | ||
108 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
109 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
110 | return compute_brks_m(vd, vn, vg, oprsz, false); | ||
111 | } | ||
112 | |||
113 | void HELPER(sve_brkn)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
114 | { | ||
115 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
116 | - | ||
117 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
118 | if (!last_active_pred(vn, vg, oprsz)) { | ||
119 | do_zero(vd, oprsz); | ||
120 | } | ||
121 | @@ -XXX,XX +XXX,XX @@ static uint32_t predtest_ones(ARMPredicateReg *d, intptr_t oprsz, | ||
122 | |||
123 | uint32_t HELPER(sve_brkns)(void *vd, void *vn, void *vg, uint32_t pred_desc) | ||
124 | { | ||
125 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; | ||
126 | - | ||
127 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); | ||
128 | if (last_active_pred(vn, vg, oprsz)) { | ||
129 | return predtest_ones(vd, oprsz, -1); | ||
130 | } else { | ||
131 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate-sve.c | ||
134 | +++ b/target/arm/translate-sve.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static bool do_brk3(DisasContext *s, arg_rprr_s *a, | ||
136 | TCGv_ptr n = tcg_temp_new_ptr(); | ||
137 | TCGv_ptr m = tcg_temp_new_ptr(); | ||
138 | TCGv_ptr g = tcg_temp_new_ptr(); | ||
139 | - TCGv_i32 t = tcg_const_i32(vsz - 2); | ||
140 | + TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz)); | ||
141 | |||
142 | tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd)); | ||
143 | tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn)); | ||
144 | @@ -XXX,XX +XXX,XX @@ static bool do_brk2(DisasContext *s, arg_rpr_s *a, | ||
145 | TCGv_ptr d = tcg_temp_new_ptr(); | ||
146 | TCGv_ptr n = tcg_temp_new_ptr(); | ||
147 | TCGv_ptr g = tcg_temp_new_ptr(); | ||
148 | - TCGv_i32 t = tcg_const_i32(vsz - 2); | ||
149 | + TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz)); | ||
150 | |||
151 | tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd)); | ||
152 | tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn)); | ||
65 | -- | 153 | -- |
66 | 2.17.1 | 154 | 2.20.1 |
67 | 155 | ||
68 | 156 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | kvm_irqchip_create called by kvm_init will call kvm_init_irq_routing to | 3 | Since b64ee454a4a0, all predicate operations should be |
4 | initialize global capability variables. If we call kvm_init_irq_routing in | 4 | using these field macros for predicates. |
5 | GIC realize function, previous allocated memory will leak. | ||
6 | 5 | ||
7 | Fix this by deleting the unnecessary call. | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | 7 | Message-id: 20210309155305.11301-7-richard.henderson@linaro.org | |
9 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Message-id: 1527750994-14360-1-git-send-email-zhaoshenglong@huawei.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | hw/intc/arm_gic_kvm.c | 1 - | 11 | target/arm/sve_helper.c | 6 +++--- |
15 | hw/intc/arm_gicv3_kvm.c | 1 - | 12 | target/arm/translate-sve.c | 6 +++--- |
16 | 2 files changed, 2 deletions(-) | 13 | 2 files changed, 6 insertions(+), 6 deletions(-) |
17 | 14 | ||
18 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | 15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/intc/arm_gic_kvm.c | 17 | --- a/target/arm/sve_helper.c |
21 | +++ b/hw/intc/arm_gic_kvm.c | 18 | +++ b/target/arm/sve_helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | 19 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkns)(void *vd, void *vn, void *vg, uint32_t pred_desc) |
23 | 20 | ||
24 | if (kvm_has_gsi_routing()) { | 21 | uint64_t HELPER(sve_cntp)(void *vn, void *vg, uint32_t pred_desc) |
25 | /* set up irq routing */ | 22 | { |
26 | - kvm_init_irq_routing(kvm_state); | 23 | - intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; |
27 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | 24 | - intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2); |
28 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | 25 | + intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8); |
29 | } | 26 | + intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); |
30 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 27 | uint64_t *n = vn, *g = vg, sum = 0, mask = pred_esz_masks[esz]; |
28 | intptr_t i; | ||
29 | |||
30 | - for (i = 0; i < DIV_ROUND_UP(oprsz, 8); ++i) { | ||
31 | + for (i = 0; i < words; ++i) { | ||
32 | uint64_t t = n[i] & g[i] & mask; | ||
33 | sum += ctpop64(t); | ||
34 | } | ||
35 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/intc/arm_gicv3_kvm.c | 37 | --- a/target/arm/translate-sve.c |
33 | +++ b/hw/intc/arm_gicv3_kvm.c | 38 | +++ b/target/arm/translate-sve.c |
34 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | 39 | @@ -XXX,XX +XXX,XX @@ static void do_cntp(DisasContext *s, TCGv_i64 val, int esz, int pn, int pg) |
35 | 40 | } else { | |
36 | if (kvm_has_gsi_routing()) { | 41 | TCGv_ptr t_pn = tcg_temp_new_ptr(); |
37 | /* set up irq routing */ | 42 | TCGv_ptr t_pg = tcg_temp_new_ptr(); |
38 | - kvm_init_irq_routing(kvm_state); | 43 | - unsigned desc; |
39 | for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) { | 44 | + unsigned desc = 0; |
40 | kvm_irqchip_add_irq_route(kvm_state, i, 0, i); | 45 | TCGv_i32 t_desc; |
41 | } | 46 | |
47 | - desc = psz - 2; | ||
48 | - desc = deposit32(desc, SIMD_DATA_SHIFT, 2, esz); | ||
49 | + desc = FIELD_DP32(desc, PREDDESC, OPRSZ, psz); | ||
50 | + desc = FIELD_DP32(desc, PREDDESC, ESZ, esz); | ||
51 | |||
52 | tcg_gen_addi_ptr(t_pn, cpu_env, pred_full_reg_offset(s, pn)); | ||
53 | tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg)); | ||
42 | -- | 54 | -- |
43 | 2.17.1 | 55 | 2.20.1 |
44 | 56 | ||
45 | 57 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Depending on the host abi, float16, aka uint16_t, values are | 3 | Since b64ee454a4a0, all predicate operations should be |
4 | passed and returned either zero-extended in the host register | 4 | using these field macros for predicates. |
5 | or with garbage at the top of the host register. | ||
6 | 5 | ||
7 | The tcg code generator has so far been assuming garbage, as that | ||
8 | matches the x86 abi, but this is incorrect for other host abis. | ||
9 | Further, target/arm has so far been assuming zero-extended results, | ||
10 | so that it may store the 16-bit value into a 32-bit slot with the | ||
11 | high 16-bits already clear. | ||
12 | |||
13 | Rectify both problems by mapping "f16" in the helper definition | ||
14 | to uint32_t instead of (a typedef for) uint16_t. This forces | ||
15 | the host compiler to assume garbage in the upper 16 bits on input | ||
16 | and to zero-extend the result on output. | ||
17 | |||
18 | Cc: qemu-stable@nongnu.org | ||
19 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20210309155305.11301-8-richard.henderson@linaro.org |
21 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
22 | Message-id: 20180522175629.24932-1-richard.henderson@linaro.org | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | --- | 10 | --- |
26 | include/exec/helper-head.h | 2 +- | 11 | target/arm/sve_helper.c | 4 ++-- |
27 | target/arm/helper-a64.c | 35 +++++++++-------- | 12 | target/arm/translate-sve.c | 7 ++++--- |
28 | target/arm/helper.c | 80 +++++++++++++++++++------------------- | 13 | 2 files changed, 6 insertions(+), 5 deletions(-) |
29 | 3 files changed, 59 insertions(+), 58 deletions(-) | ||
30 | 14 | ||
31 | diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h | 15 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
32 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/exec/helper-head.h | 17 | --- a/target/arm/sve_helper.c |
34 | +++ b/include/exec/helper-head.h | 18 | +++ b/target/arm/sve_helper.c |
35 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(sve_cntp)(void *vn, void *vg, uint32_t pred_desc) |
36 | #define dh_ctype_int int | 20 | |
37 | #define dh_ctype_i64 uint64_t | 21 | uint32_t HELPER(sve_while)(void *vd, uint32_t count, uint32_t pred_desc) |
38 | #define dh_ctype_s64 int64_t | 22 | { |
39 | -#define dh_ctype_f16 float16 | 23 | - uintptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2; |
40 | +#define dh_ctype_f16 uint32_t | 24 | - intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2); |
41 | #define dh_ctype_f32 float32 | 25 | + intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ); |
42 | #define dh_ctype_f64 float64 | 26 | + intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ); |
43 | #define dh_ctype_ptr void * | 27 | uint64_t esz_mask = pred_esz_masks[esz]; |
44 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 28 | ARMPredicateReg *d = vd; |
29 | uint32_t flags; | ||
30 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/helper-a64.c | 32 | --- a/target/arm/translate-sve.c |
47 | +++ b/target/arm/helper-a64.c | 33 | +++ b/target/arm/translate-sve.c |
48 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res) | 34 | @@ -XXX,XX +XXX,XX @@ static bool trans_WHILE(DisasContext *s, arg_WHILE *a) |
49 | return flags; | 35 | TCGv_i64 op0, op1, t0, t1, tmax; |
50 | } | 36 | TCGv_i32 t2, t3; |
51 | 37 | TCGv_ptr ptr; | |
52 | -uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) | 38 | - unsigned desc, vsz = vec_full_reg_size(s); |
53 | +uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status) | 39 | + unsigned vsz = vec_full_reg_size(s); |
54 | { | 40 | + unsigned desc = 0; |
55 | return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); | 41 | TCGCond cond; |
56 | } | 42 | |
57 | 43 | if (!sve_access_check(s)) { | |
58 | -uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) | 44 | @@ -XXX,XX +XXX,XX @@ static bool trans_WHILE(DisasContext *s, arg_WHILE *a) |
59 | +uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status) | 45 | /* Scale elements to bits. */ |
60 | { | 46 | tcg_gen_shli_i32(t2, t2, a->esz); |
61 | return float_rel_to_flags(float16_compare(x, y, fp_status)); | 47 | |
62 | } | 48 | - desc = (vsz / 8) - 2; |
63 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp) | 49 | - desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz); |
64 | #define float64_three make_float64(0x4008000000000000ULL) | 50 | + desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz / 8); |
65 | #define float64_one_point_five make_float64(0x3FF8000000000000ULL) | 51 | + desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz); |
66 | 52 | t3 = tcg_const_i32(desc); | |
67 | -float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp) | 53 | |
68 | +uint32_t HELPER(recpsf_f16)(uint32_t a, uint32_t b, void *fpstp) | 54 | ptr = tcg_temp_new_ptr(); |
69 | { | ||
70 | float_status *fpst = fpstp; | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp) | ||
73 | return float64_muladd(a, b, float64_two, 0, fpst); | ||
74 | } | ||
75 | |||
76 | -float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp) | ||
77 | +uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
78 | { | ||
79 | float_status *fpst = fpstp; | ||
80 | |||
81 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a) | ||
82 | } | ||
83 | |||
84 | /* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */ | ||
85 | -float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | ||
86 | +uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) | ||
87 | { | ||
88 | float_status *fpst = fpstp; | ||
89 | uint16_t val16, sbit; | ||
90 | @@ -XXX,XX +XXX,XX @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr, | ||
91 | #define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix)) | ||
92 | |||
93 | #define ADVSIMD_HALFOP(name) \ | ||
94 | -float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \ | ||
95 | +uint32_t ADVSIMD_HELPER(name, h)(uint32_t a, uint32_t b, void *fpstp) \ | ||
96 | { \ | ||
97 | float_status *fpst = fpstp; \ | ||
98 | return float16_ ## name(a, b, fpst); \ | ||
99 | @@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(mulx) | ||
100 | ADVSIMD_TWOHALFOP(mulx) | ||
101 | |||
102 | /* fused multiply-accumulate */ | ||
103 | -float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp) | ||
104 | +uint32_t HELPER(advsimd_muladdh)(uint32_t a, uint32_t b, uint32_t c, | ||
105 | + void *fpstp) | ||
106 | { | ||
107 | float_status *fpst = fpstp; | ||
108 | return float16_muladd(a, b, c, 0, fpst); | ||
109 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b, | ||
110 | |||
111 | #define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0 | ||
112 | |||
113 | -uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp) | ||
114 | +uint32_t HELPER(advsimd_ceq_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
115 | { | ||
116 | float_status *fpst = fpstp; | ||
117 | int compare = float16_compare_quiet(a, b, fpst); | ||
118 | return ADVSIMD_CMPRES(compare == float_relation_equal); | ||
119 | } | ||
120 | |||
121 | -uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | ||
122 | +uint32_t HELPER(advsimd_cge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
123 | { | ||
124 | float_status *fpst = fpstp; | ||
125 | int compare = float16_compare(a, b, fpst); | ||
126 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp) | ||
127 | compare == float_relation_equal); | ||
128 | } | ||
129 | |||
130 | -uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp) | ||
131 | +uint32_t HELPER(advsimd_cgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
132 | { | ||
133 | float_status *fpst = fpstp; | ||
134 | int compare = float16_compare(a, b, fpst); | ||
135 | return ADVSIMD_CMPRES(compare == float_relation_greater); | ||
136 | } | ||
137 | |||
138 | -uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | ||
139 | +uint32_t HELPER(advsimd_acge_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
140 | { | ||
141 | float_status *fpst = fpstp; | ||
142 | float16 f0 = float16_abs(a); | ||
143 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp) | ||
144 | compare == float_relation_equal); | ||
145 | } | ||
146 | |||
147 | -uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | ||
148 | +uint32_t HELPER(advsimd_acgt_f16)(uint32_t a, uint32_t b, void *fpstp) | ||
149 | { | ||
150 | float_status *fpst = fpstp; | ||
151 | float16 f0 = float16_abs(a); | ||
152 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp) | ||
153 | } | ||
154 | |||
155 | /* round to integral */ | ||
156 | -float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status) | ||
157 | +uint32_t HELPER(advsimd_rinth_exact)(uint32_t x, void *fp_status) | ||
158 | { | ||
159 | return float16_round_to_int(x, fp_status); | ||
160 | } | ||
161 | |||
162 | -float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
163 | +uint32_t HELPER(advsimd_rinth)(uint32_t x, void *fp_status) | ||
164 | { | ||
165 | int old_flags = get_float_exception_flags(fp_status), new_flags; | ||
166 | float16 ret; | ||
167 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status) | ||
168 | * setting the mode appropriately before calling the helper. | ||
169 | */ | ||
170 | |||
171 | -uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
172 | +uint32_t HELPER(advsimd_f16tosinth)(uint32_t a, void *fpstp) | ||
173 | { | ||
174 | float_status *fpst = fpstp; | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp) | ||
177 | return float16_to_int16(a, fpst); | ||
178 | } | ||
179 | |||
180 | -uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
181 | +uint32_t HELPER(advsimd_f16touinth)(uint32_t a, void *fpstp) | ||
182 | { | ||
183 | float_status *fpst = fpstp; | ||
184 | |||
185 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp) | ||
186 | * Square Root and Reciprocal square root | ||
187 | */ | ||
188 | |||
189 | -float16 HELPER(sqrt_f16)(float16 a, void *fpstp) | ||
190 | +uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp) | ||
191 | { | ||
192 | float_status *s = fpstp; | ||
193 | |||
194 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/target/arm/helper.c | ||
197 | +++ b/target/arm/helper.c | ||
198 | @@ -XXX,XX +XXX,XX @@ DO_VFP_cmp(d, float64) | ||
199 | |||
200 | /* Integer to float and float to integer conversions */ | ||
201 | |||
202 | -#define CONV_ITOF(name, fsz, sign) \ | ||
203 | - float##fsz HELPER(name)(uint32_t x, void *fpstp) \ | ||
204 | -{ \ | ||
205 | - float_status *fpst = fpstp; \ | ||
206 | - return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
207 | +#define CONV_ITOF(name, ftype, fsz, sign) \ | ||
208 | +ftype HELPER(name)(uint32_t x, void *fpstp) \ | ||
209 | +{ \ | ||
210 | + float_status *fpst = fpstp; \ | ||
211 | + return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ | ||
212 | } | ||
213 | |||
214 | -#define CONV_FTOI(name, fsz, sign, round) \ | ||
215 | -uint32_t HELPER(name)(float##fsz x, void *fpstp) \ | ||
216 | -{ \ | ||
217 | - float_status *fpst = fpstp; \ | ||
218 | - if (float##fsz##_is_any_nan(x)) { \ | ||
219 | - float_raise(float_flag_invalid, fpst); \ | ||
220 | - return 0; \ | ||
221 | - } \ | ||
222 | - return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
223 | +#define CONV_FTOI(name, ftype, fsz, sign, round) \ | ||
224 | +uint32_t HELPER(name)(ftype x, void *fpstp) \ | ||
225 | +{ \ | ||
226 | + float_status *fpst = fpstp; \ | ||
227 | + if (float##fsz##_is_any_nan(x)) { \ | ||
228 | + float_raise(float_flag_invalid, fpst); \ | ||
229 | + return 0; \ | ||
230 | + } \ | ||
231 | + return float##fsz##_to_##sign##int32##round(x, fpst); \ | ||
232 | } | ||
233 | |||
234 | -#define FLOAT_CONVS(name, p, fsz, sign) \ | ||
235 | -CONV_ITOF(vfp_##name##to##p, fsz, sign) \ | ||
236 | -CONV_FTOI(vfp_to##name##p, fsz, sign, ) \ | ||
237 | -CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero) | ||
238 | +#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ | ||
239 | + CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ | ||
240 | + CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ | ||
241 | + CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) | ||
242 | |||
243 | -FLOAT_CONVS(si, h, 16, ) | ||
244 | -FLOAT_CONVS(si, s, 32, ) | ||
245 | -FLOAT_CONVS(si, d, 64, ) | ||
246 | -FLOAT_CONVS(ui, h, 16, u) | ||
247 | -FLOAT_CONVS(ui, s, 32, u) | ||
248 | -FLOAT_CONVS(ui, d, 64, u) | ||
249 | +FLOAT_CONVS(si, h, uint32_t, 16, ) | ||
250 | +FLOAT_CONVS(si, s, float32, 32, ) | ||
251 | +FLOAT_CONVS(si, d, float64, 64, ) | ||
252 | +FLOAT_CONVS(ui, h, uint32_t, 16, u) | ||
253 | +FLOAT_CONVS(ui, s, float32, 32, u) | ||
254 | +FLOAT_CONVS(ui, d, float64, 64, u) | ||
255 | |||
256 | #undef CONV_ITOF | ||
257 | #undef CONV_FTOI | ||
258 | @@ -XXX,XX +XXX,XX @@ static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) | ||
259 | return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst); | ||
260 | } | ||
261 | |||
262 | -float16 HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
263 | +uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) | ||
264 | { | ||
265 | return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst); | ||
266 | } | ||
267 | |||
268 | -float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
269 | +uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
270 | { | ||
271 | return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); | ||
272 | } | ||
273 | |||
274 | -float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
275 | +uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
276 | { | ||
277 | return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); | ||
278 | } | ||
279 | |||
280 | -float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
281 | +uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
282 | { | ||
283 | return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); | ||
284 | } | ||
285 | @@ -XXX,XX +XXX,XX @@ static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) | ||
286 | } | ||
287 | } | ||
288 | |||
289 | -uint32_t HELPER(vfp_toshh)(float16 x, uint32_t shift, void *fpst) | ||
290 | +uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) | ||
291 | { | ||
292 | return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst); | ||
293 | } | ||
294 | |||
295 | -uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) | ||
296 | +uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) | ||
297 | { | ||
298 | return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); | ||
299 | } | ||
300 | |||
301 | -uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) | ||
302 | +uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) | ||
303 | { | ||
304 | return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); | ||
305 | } | ||
306 | |||
307 | -uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) | ||
308 | +uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) | ||
309 | { | ||
310 | return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); | ||
311 | } | ||
312 | |||
313 | -uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) | ||
314 | +uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) | ||
315 | { | ||
316 | return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); | ||
317 | } | ||
318 | |||
319 | -uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) | ||
320 | +uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) | ||
321 | { | ||
322 | return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); | ||
323 | } | ||
324 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) | ||
325 | } | ||
326 | |||
327 | /* Half precision conversions. */ | ||
328 | -float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
329 | +float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
330 | { | ||
331 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
332 | * it would affect flushing input denormals. | ||
333 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
334 | return r; | ||
335 | } | ||
336 | |||
337 | -float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
338 | +uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
339 | { | ||
340 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
341 | * it would affect flushing output denormals. | ||
342 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) | ||
343 | return r; | ||
344 | } | ||
345 | |||
346 | -float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
347 | +float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) | ||
348 | { | ||
349 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
350 | * it would affect flushing input denormals. | ||
351 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode) | ||
352 | return r; | ||
353 | } | ||
354 | |||
355 | -float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
356 | +uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) | ||
357 | { | ||
358 | /* Squash FZ16 to 0 for the duration of conversion. In this case, | ||
359 | * it would affect flushing output denormals. | ||
360 | @@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit) | ||
361 | g_assert_not_reached(); | ||
362 | } | ||
363 | |||
364 | -float16 HELPER(recpe_f16)(float16 input, void *fpstp) | ||
365 | +uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) | ||
366 | { | ||
367 | float_status *fpst = fpstp; | ||
368 | float16 f16 = float16_squash_input_denormal(input, fpst); | ||
369 | @@ -XXX,XX +XXX,XX @@ static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) | ||
370 | return extract64(estimate, 0, 8) << 44; | ||
371 | } | ||
372 | |||
373 | -float16 HELPER(rsqrte_f16)(float16 input, void *fpstp) | ||
374 | +uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
375 | { | ||
376 | float_status *s = fpstp; | ||
377 | float16 f16 = float16_squash_input_denormal(input, s); | ||
378 | -- | 55 | -- |
379 | 2.17.1 | 56 | 2.20.1 |
380 | 57 | ||
381 | 58 | diff view generated by jsdifflib |
1 | From: Jan Kiszka <jan.kiszka@siemens.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There was a nasty flip in identifying which register group an access is | 3 | With the reduction operations, we intentionally increase maxsz to |
4 | targeting. The issue caused spuriously raised priorities of the guest | 4 | the next power of 2, so as to fill out the reduction tree correctly. |
5 | when handing CPUs over in the Jailhouse hypervisor. | 5 | Since e2e7168a214b, oprsz must equal maxsz, with exceptions for small |
6 | vectors, so this triggers an assertion for vector sizes > 32 that are | ||
7 | not themselves a power of 2. | ||
6 | 8 | ||
7 | Cc: qemu-stable@nongnu.org | 9 | Pass the power-of-two value in the simd_data field instead. |
8 | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> | 10 | |
9 | Message-id: 28b927d3-da58-bce4-cc13-bfec7f9b1cb9@siemens.com | 11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20210309155305.11301-9-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 15 | --- |
13 | hw/intc/arm_gicv3_cpuif.c | 12 ++++++------ | 16 | target/arm/sve_helper.c | 2 +- |
14 | 1 file changed, 6 insertions(+), 6 deletions(-) | 17 | target/arm/translate-sve.c | 2 +- |
18 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
15 | 19 | ||
16 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 20 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/arm_gicv3_cpuif.c | 22 | --- a/target/arm/sve_helper.c |
19 | +++ b/hw/intc/arm_gicv3_cpuif.c | 23 | +++ b/target/arm/sve_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 24 | @@ -XXX,XX +XXX,XX @@ static TYPE NAME##_reduce(TYPE *data, float_status *status, uintptr_t n) \ |
25 | } \ | ||
26 | uint64_t HELPER(NAME)(void *vn, void *vg, void *vs, uint32_t desc) \ | ||
27 | { \ | ||
28 | - uintptr_t i, oprsz = simd_oprsz(desc), maxsz = simd_maxsz(desc); \ | ||
29 | + uintptr_t i, oprsz = simd_oprsz(desc), maxsz = simd_data(desc); \ | ||
30 | TYPE data[sizeof(ARMVectorReg) / sizeof(TYPE)]; \ | ||
31 | for (i = 0; i < oprsz; ) { \ | ||
32 | uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); \ | ||
33 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/translate-sve.c | ||
36 | +++ b/target/arm/translate-sve.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static void do_reduce(DisasContext *s, arg_rpr_esz *a, | ||
21 | { | 38 | { |
22 | GICv3CPUState *cs = icc_cs_from_env(env); | 39 | unsigned vsz = vec_full_reg_size(s); |
23 | int regno = ri->opc2 & 3; | 40 | unsigned p2vsz = pow2ceil(vsz); |
24 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | 41 | - TCGv_i32 t_desc = tcg_const_i32(simd_desc(vsz, p2vsz, 0)); |
25 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | 42 | + TCGv_i32 t_desc = tcg_const_i32(simd_desc(vsz, vsz, p2vsz)); |
26 | uint64_t value = cs->ich_apr[grp][regno]; | 43 | TCGv_ptr t_zn, t_pg, status; |
27 | 44 | TCGv_i64 temp; | |
28 | trace_gicv3_icv_ap_read(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
30 | { | ||
31 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
32 | int regno = ri->opc2 & 3; | ||
33 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
34 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
35 | |||
36 | trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
39 | uint64_t value; | ||
40 | |||
41 | int regno = ri->opc2 & 3; | ||
42 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | ||
43 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | ||
44 | |||
45 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | ||
46 | return icv_ap_read(env, ri); | ||
47 | @@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
48 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
49 | |||
50 | int regno = ri->opc2 & 3; | ||
51 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; | ||
52 | + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; | ||
53 | |||
54 | if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { | ||
55 | icv_ap_write(env, ri, value); | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
57 | { | ||
58 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
59 | int regno = ri->opc2 & 3; | ||
60 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
61 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
62 | uint64_t value; | ||
63 | |||
64 | value = cs->ich_apr[grp][regno]; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
66 | { | ||
67 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
68 | int regno = ri->opc2 & 3; | ||
69 | - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; | ||
70 | + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; | ||
71 | |||
72 | trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
73 | 45 | ||
74 | -- | 46 | -- |
75 | 2.17.1 | 47 | 2.20.1 |
76 | 48 | ||
77 | 49 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to the MemoryRegion valid.accepts | ||
3 | callback. We'll need this for subpage_accepts(). | ||
4 | 2 | ||
5 | We could take the approach we used with the read and write | 3 | Currently the emulated EMAC for sun8i always traverses the transmit queue |
6 | callbacks and add new a new _with_attrs version, but since there | 4 | from the head when transferring packets. It searches for a list of consecutive |
7 | are so few implementations of the accepts hook we just change | 5 | descriptors whichs are flagged as ready for processing and transmits their payloads |
8 | them all. | 6 | accordingly. The controller stops processing once it finds a descriptor that is not |
7 | marked ready. | ||
9 | 8 | ||
9 | While the above behaviour works in most situations, it is not the same as the actual | ||
10 | EMAC in hardware. Actual hardware uses the TX_CUR_DESC register value to keep track | ||
11 | of the last position in the transmit queue and continues processing from that position | ||
12 | when software triggers the start of DMA processing. The currently emulated behaviour can | ||
13 | lead to packet loss on transmit when software fills the transmit queue with ready | ||
14 | descriptors that overlap the tail of the circular list. | ||
15 | |||
16 | This commit modifies the emulated EMAC for sun8i such that it processes | ||
17 | the transmit queue using the TX_CUR_DESC register in the same way as hardware. | ||
18 | |||
19 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Message-id: 20210310195820.21950-2-nieklinnenbank@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20180521140402.23318-9-peter.maydell@linaro.org | ||
14 | --- | 23 | --- |
15 | include/exec/memory.h | 3 ++- | 24 | hw/net/allwinner-sun8i-emac.c | 62 +++++++++++++++++++---------------- |
16 | exec.c | 9 ++++++--- | 25 | 1 file changed, 34 insertions(+), 28 deletions(-) |
17 | hw/hppa/dino.c | 3 ++- | ||
18 | hw/nvram/fw_cfg.c | 12 ++++++++---- | ||
19 | hw/scsi/esp.c | 3 ++- | ||
20 | hw/xen/xen_pt_msi.c | 3 ++- | ||
21 | memory.c | 5 +++-- | ||
22 | 7 files changed, 25 insertions(+), 13 deletions(-) | ||
23 | 26 | ||
24 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 27 | diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c |
25 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/exec/memory.h | 29 | --- a/hw/net/allwinner-sun8i-emac.c |
27 | +++ b/include/exec/memory.h | 30 | +++ b/hw/net/allwinner-sun8i-emac.c |
28 | @@ -XXX,XX +XXX,XX @@ struct MemoryRegionOps { | 31 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s) |
29 | * as a machine check exception). | 32 | qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0); |
30 | */ | ||
31 | bool (*accepts)(void *opaque, hwaddr addr, | ||
32 | - unsigned size, bool is_write); | ||
33 | + unsigned size, bool is_write, | ||
34 | + MemTxAttrs attrs); | ||
35 | } valid; | ||
36 | /* Internal implementation constraints: */ | ||
37 | struct { | ||
38 | diff --git a/exec.c b/exec.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/exec.c | ||
41 | +++ b/exec.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr, | ||
43 | } | 33 | } |
44 | 34 | ||
45 | static bool notdirty_mem_accepts(void *opaque, hwaddr addr, | 35 | -static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s, |
46 | - unsigned size, bool is_write) | 36 | - FrameDescriptor *desc, |
47 | + unsigned size, bool is_write, | 37 | - size_t min_size) |
48 | + MemTxAttrs attrs) | 38 | +static bool allwinner_sun8i_emac_desc_owned(FrameDescriptor *desc, |
39 | + size_t min_buf_size) | ||
49 | { | 40 | { |
50 | return is_write; | 41 | - uint32_t paddr = desc->next; |
42 | - | ||
43 | - dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc)); | ||
44 | - | ||
45 | - if ((desc->status & DESC_STATUS_CTL) && | ||
46 | - (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) { | ||
47 | - return paddr; | ||
48 | - } else { | ||
49 | - return 0; | ||
50 | - } | ||
51 | + return (desc->status & DESC_STATUS_CTL) && (min_buf_size == 0 || | ||
52 | + (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_buf_size); | ||
51 | } | 53 | } |
52 | @@ -XXX,XX +XXX,XX @@ static MemTxResult subpage_write(void *opaque, hwaddr addr, | 54 | |
55 | -static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s, | ||
56 | - FrameDescriptor *desc, | ||
57 | - uint32_t start_addr, | ||
58 | - size_t min_size) | ||
59 | +static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s, | ||
60 | + FrameDescriptor *desc, | ||
61 | + uint32_t phys_addr) | ||
62 | +{ | ||
63 | + dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc)); | ||
64 | +} | ||
65 | + | ||
66 | +static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s, | ||
67 | + FrameDescriptor *desc) | ||
68 | +{ | ||
69 | + const uint32_t nxt = desc->next; | ||
70 | + allwinner_sun8i_emac_get_desc(s, desc, nxt); | ||
71 | + return nxt; | ||
72 | +} | ||
73 | + | ||
74 | +static uint32_t allwinner_sun8i_emac_find_desc(AwSun8iEmacState *s, | ||
75 | + FrameDescriptor *desc, | ||
76 | + uint32_t start_addr, | ||
77 | + size_t min_size) | ||
78 | { | ||
79 | uint32_t desc_addr = start_addr; | ||
80 | |||
81 | /* Note that the list is a cycle. Last entry points back to the head. */ | ||
82 | while (desc_addr != 0) { | ||
83 | - dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc)); | ||
84 | + allwinner_sun8i_emac_get_desc(s, desc, desc_addr); | ||
85 | |||
86 | - if ((desc->status & DESC_STATUS_CTL) && | ||
87 | - (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) { | ||
88 | + if (allwinner_sun8i_emac_desc_owned(desc, min_size)) { | ||
89 | return desc_addr; | ||
90 | } else if (desc->next == start_addr) { | ||
91 | break; | ||
92 | @@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s, | ||
93 | FrameDescriptor *desc, | ||
94 | size_t min_size) | ||
95 | { | ||
96 | - return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size); | ||
97 | + return allwinner_sun8i_emac_find_desc(s, desc, s->rx_desc_curr, min_size); | ||
53 | } | 98 | } |
54 | 99 | ||
55 | static bool subpage_accepts(void *opaque, hwaddr addr, | 100 | static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s, |
56 | - unsigned len, bool is_write) | 101 | - FrameDescriptor *desc, |
57 | + unsigned len, bool is_write, | 102 | - size_t min_size) |
58 | + MemTxAttrs attrs) | 103 | + FrameDescriptor *desc) |
59 | { | 104 | { |
60 | subpage_t *subpage = opaque; | 105 | - return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size); |
61 | #if defined(DEBUG_SUBPAGE) | 106 | + allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_curr); |
62 | @@ -XXX,XX +XXX,XX @@ static void readonly_mem_write(void *opaque, hwaddr addr, | 107 | + return s->tx_desc_curr; |
63 | } | 108 | } |
64 | 109 | ||
65 | static bool readonly_mem_accepts(void *opaque, hwaddr addr, | 110 | static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s, |
66 | - unsigned size, bool is_write) | 111 | @@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc, |
67 | + unsigned size, bool is_write, | 112 | bytes_left -= desc_bytes; |
68 | + MemTxAttrs attrs) | 113 | |
69 | { | 114 | /* Move to the next descriptor */ |
70 | return is_write; | 115 | - s->rx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 64); |
71 | } | 116 | + s->rx_desc_curr = allwinner_sun8i_emac_find_desc(s, &desc, desc.next, |
72 | diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c | 117 | + AW_SUN8I_EMAC_MIN_PKT_SZ); |
73 | index XXXXXXX..XXXXXXX 100644 | 118 | if (!s->rx_desc_curr) { |
74 | --- a/hw/hppa/dino.c | 119 | /* Not enough buffer space available */ |
75 | +++ b/hw/hppa/dino.c | 120 | s->int_sta |= INT_STA_RX_BUF_UA; |
76 | @@ -XXX,XX +XXX,XX @@ static void gsc_to_pci_forwarding(DinoState *s) | 121 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s) |
77 | } | 122 | size_t transmitted = 0; |
78 | 123 | static uint8_t packet_buf[2048]; | |
79 | static bool dino_chip_mem_valid(void *opaque, hwaddr addr, | 124 | |
80 | - unsigned size, bool is_write) | 125 | - s->tx_desc_curr = allwinner_sun8i_emac_tx_desc(s, &desc, 0); |
81 | + unsigned size, bool is_write, | 126 | + s->tx_desc_curr = allwinner_sun8i_emac_tx_desc(s, &desc); |
82 | + MemTxAttrs attrs) | 127 | |
83 | { | 128 | /* Read all transmit descriptors */ |
84 | switch (addr) { | 129 | - while (s->tx_desc_curr != 0) { |
85 | case DINO_IAR0: | 130 | + while (allwinner_sun8i_emac_desc_owned(&desc, 0)) { |
86 | diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c | 131 | |
87 | index XXXXXXX..XXXXXXX 100644 | 132 | /* Read from physical memory into packet buffer */ |
88 | --- a/hw/nvram/fw_cfg.c | 133 | bytes = desc.status2 & DESC_STATUS2_BUF_SIZE_MASK; |
89 | +++ b/hw/nvram/fw_cfg.c | 134 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s) |
90 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_dma_mem_write(void *opaque, hwaddr addr, | 135 | packet_bytes = 0; |
91 | } | 136 | transmitted++; |
92 | |||
93 | static bool fw_cfg_dma_mem_valid(void *opaque, hwaddr addr, | ||
94 | - unsigned size, bool is_write) | ||
95 | + unsigned size, bool is_write, | ||
96 | + MemTxAttrs attrs) | ||
97 | { | ||
98 | return !is_write || ((size == 4 && (addr == 0 || addr == 4)) || | ||
99 | (size == 8 && addr == 0)); | ||
100 | } | ||
101 | |||
102 | static bool fw_cfg_data_mem_valid(void *opaque, hwaddr addr, | ||
103 | - unsigned size, bool is_write) | ||
104 | + unsigned size, bool is_write, | ||
105 | + MemTxAttrs attrs) | ||
106 | { | ||
107 | return addr == 0; | ||
108 | } | ||
109 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr, | ||
110 | } | ||
111 | |||
112 | static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr, | ||
113 | - unsigned size, bool is_write) | ||
114 | + unsigned size, bool is_write, | ||
115 | + MemTxAttrs attrs) | ||
116 | { | ||
117 | return is_write && size == 2; | ||
118 | } | ||
119 | @@ -XXX,XX +XXX,XX @@ static void fw_cfg_comb_write(void *opaque, hwaddr addr, | ||
120 | } | ||
121 | |||
122 | static bool fw_cfg_comb_valid(void *opaque, hwaddr addr, | ||
123 | - unsigned size, bool is_write) | ||
124 | + unsigned size, bool is_write, | ||
125 | + MemTxAttrs attrs) | ||
126 | { | ||
127 | return (size == 1) || (is_write && size == 2); | ||
128 | } | ||
129 | diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/hw/scsi/esp.c | ||
132 | +++ b/hw/scsi/esp.c | ||
133 | @@ -XXX,XX +XXX,XX @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) | ||
134 | } | ||
135 | |||
136 | static bool esp_mem_accepts(void *opaque, hwaddr addr, | ||
137 | - unsigned size, bool is_write) | ||
138 | + unsigned size, bool is_write, | ||
139 | + MemTxAttrs attrs) | ||
140 | { | ||
141 | return (size == 1) || (is_write && size == 4); | ||
142 | } | ||
143 | diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c | ||
144 | index XXXXXXX..XXXXXXX 100644 | ||
145 | --- a/hw/xen/xen_pt_msi.c | ||
146 | +++ b/hw/xen/xen_pt_msi.c | ||
147 | @@ -XXX,XX +XXX,XX @@ static uint64_t pci_msix_read(void *opaque, hwaddr addr, | ||
148 | } | ||
149 | |||
150 | static bool pci_msix_accepts(void *opaque, hwaddr addr, | ||
151 | - unsigned size, bool is_write) | ||
152 | + unsigned size, bool is_write, | ||
153 | + MemTxAttrs attrs) | ||
154 | { | ||
155 | return !(addr & (size - 1)); | ||
156 | } | ||
157 | diff --git a/memory.c b/memory.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/memory.c | ||
160 | +++ b/memory.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static void unassigned_mem_write(void *opaque, hwaddr addr, | ||
162 | } | ||
163 | |||
164 | static bool unassigned_mem_accepts(void *opaque, hwaddr addr, | ||
165 | - unsigned size, bool is_write) | ||
166 | + unsigned size, bool is_write, | ||
167 | + MemTxAttrs attrs) | ||
168 | { | ||
169 | return false; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ bool memory_region_access_valid(MemoryRegion *mr, | ||
172 | access_size = MAX(MIN(size, access_size_max), access_size_min); | ||
173 | for (i = 0; i < size; i += access_size) { | ||
174 | if (!mr->ops->valid.accepts(mr->opaque, addr + i, access_size, | ||
175 | - is_write)) { | ||
176 | + is_write, attrs)) { | ||
177 | return false; | ||
178 | } | 137 | } |
138 | - s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 0); | ||
139 | + s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc); | ||
179 | } | 140 | } |
141 | |||
142 | /* Raise transmit completed interrupt */ | ||
180 | -- | 143 | -- |
181 | 2.17.1 | 144 | 2.20.1 |
182 | 145 | ||
183 | 146 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_do_translate(). | ||
3 | 2 | ||
3 | The image for Armbian 19.11.3 bionic has been removed from the armbian server. | ||
4 | Without the image as input the test arm_orangepi_bionic_19_11 cannot run. | ||
5 | |||
6 | This commit removes the test completely and merges the code of the generic function | ||
7 | do_test_arm_orangepi_uboot_armbian back with the 20.08 test. | ||
8 | |||
9 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
10 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
11 | Message-id: 20210310195820.21950-3-nieklinnenbank@gmail.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-13-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | exec.c | 9 ++++++--- | 14 | tests/acceptance/boot_linux_console.py | 72 ++++++++------------------ |
10 | 1 file changed, 6 insertions(+), 3 deletions(-) | 15 | 1 file changed, 23 insertions(+), 49 deletions(-) |
11 | 16 | ||
12 | diff --git a/exec.c b/exec.c | 17 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
13 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/exec.c | 19 | --- a/tests/acceptance/boot_linux_console.py |
15 | +++ b/exec.c | 20 | +++ b/tests/acceptance/boot_linux_console.py |
16 | @@ -XXX,XX +XXX,XX @@ unassigned: | 21 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self): |
17 | * @is_write: whether the translation operation is for write | 22 | # Wait for VM to shut down gracefully |
18 | * @is_mmio: whether this can be MMIO, set true if it can | 23 | self.vm.wait() |
19 | * @target_as: the address space targeted by the IOMMU | 24 | |
20 | + * @attrs: memory transaction attributes | 25 | - def do_test_arm_orangepi_uboot_armbian(self, image_path): |
21 | * | 26 | + @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), |
22 | * This function is called from RCU critical section | 27 | + 'Test artifacts fetched from unreliable apt.armbian.com') |
23 | */ | 28 | + @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') |
24 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | 29 | + def test_arm_orangepi_bionic_20_08(self): |
25 | hwaddr *page_mask_out, | 30 | + """ |
26 | bool is_write, | 31 | + :avocado: tags=arch:arm |
27 | bool is_mmio, | 32 | + :avocado: tags=machine:orangepi-pc |
28 | - AddressSpace **target_as) | 33 | + :avocado: tags=device:sd |
29 | + AddressSpace **target_as, | 34 | + """ |
30 | + MemTxAttrs attrs) | 35 | + |
31 | { | 36 | + # This test download a 275 MiB compressed image and expand it |
32 | MemoryRegionSection *section; | 37 | + # to 1036 MiB, but the underlying filesystem is 1552 MiB... |
33 | IOMMUMemoryRegion *iommu_mr; | 38 | + # As we expand it to 2 GiB we are safe. |
34 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 39 | + |
35 | * but page mask. | 40 | + image_url = ('https://dl.armbian.com/orangepipc/archive/' |
36 | */ | 41 | + 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') |
37 | section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat, | 42 | + image_hash = ('b4d6775f5673486329e45a0586bf06b6' |
38 | - NULL, &page_mask, is_write, false, &as); | 43 | + 'dbe792199fd182ac6b9c7bb6c7d3e6dd') |
39 | + NULL, &page_mask, is_write, false, &as, | 44 | + image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, |
40 | + attrs); | 45 | + algorithm='sha256') |
41 | 46 | + image_path = archive.extract(image_path_xz, self.workdir) | |
42 | /* Illegal translation */ | 47 | + image_pow2ceil_expand(image_path) |
43 | if (section.mr == &io_mem_unassigned) { | 48 | + |
44 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | 49 | self.vm.set_console() |
45 | 50 | self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', | |
46 | /* This can be MMIO, so setup MMIO bit. */ | 51 | '-nic', 'user', |
47 | section = flatview_do_translate(fv, addr, xlat, plen, NULL, | 52 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_orangepi_uboot_armbian(self, image_path): |
48 | - is_write, true, &as); | 53 | 'to <orangepipc>') |
49 | + is_write, true, &as, attrs); | 54 | self.wait_for_console_pattern('Starting Load Kernel Modules...') |
50 | mr = section.mr; | 55 | |
51 | 56 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | |
52 | if (xen_enabled() && memory_access_is_direct(mr, is_write)) { | 57 | - 'Test artifacts fetched from unreliable apt.armbian.com') |
58 | - @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | ||
59 | - @skipUnless(P7ZIP_AVAILABLE, '7z not installed') | ||
60 | - def test_arm_orangepi_bionic_19_11(self): | ||
61 | - """ | ||
62 | - :avocado: tags=arch:arm | ||
63 | - :avocado: tags=machine:orangepi-pc | ||
64 | - :avocado: tags=device:sd | ||
65 | - """ | ||
66 | - | ||
67 | - # This test download a 196MB compressed image and expand it to 1GB | ||
68 | - image_url = ('https://dl.armbian.com/orangepipc/archive/' | ||
69 | - 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z') | ||
70 | - image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e' | ||
71 | - image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash) | ||
72 | - image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img' | ||
73 | - image_path = os.path.join(self.workdir, image_name) | ||
74 | - process.run("7z e -o%s %s" % (self.workdir, image_path_7z)) | ||
75 | - image_pow2ceil_expand(image_path) | ||
76 | - | ||
77 | - self.do_test_arm_orangepi_uboot_armbian(image_path) | ||
78 | - | ||
79 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
80 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
81 | - @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | ||
82 | - def test_arm_orangepi_bionic_20_08(self): | ||
83 | - """ | ||
84 | - :avocado: tags=arch:arm | ||
85 | - :avocado: tags=machine:orangepi-pc | ||
86 | - :avocado: tags=device:sd | ||
87 | - """ | ||
88 | - | ||
89 | - # This test download a 275 MiB compressed image and expand it | ||
90 | - # to 1036 MiB, but the underlying filesystem is 1552 MiB... | ||
91 | - # As we expand it to 2 GiB we are safe. | ||
92 | - | ||
93 | - image_url = ('https://dl.armbian.com/orangepipc/archive/' | ||
94 | - 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') | ||
95 | - image_hash = ('b4d6775f5673486329e45a0586bf06b6' | ||
96 | - 'dbe792199fd182ac6b9c7bb6c7d3e6dd') | ||
97 | - image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash, | ||
98 | - algorithm='sha256') | ||
99 | - image_path = archive.extract(image_path_xz, self.workdir) | ||
100 | - image_pow2ceil_expand(image_path) | ||
101 | - | ||
102 | - self.do_test_arm_orangepi_uboot_armbian(image_path) | ||
103 | - | ||
104 | @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | ||
105 | def test_arm_orangepi_uboot_netbsd9(self): | ||
106 | """ | ||
53 | -- | 107 | -- |
54 | 2.17.1 | 108 | 2.20.1 |
55 | 109 | ||
56 | 110 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_get_iotlb_entry(). | ||
3 | 2 | ||
3 | Update the download URL of the Armbian 20.08 Bionic image for | ||
4 | test_arm_orangepi_bionic_20_08 of the orangepi-pc machine. | ||
5 | |||
6 | The archive.armbian.com URL contains more images and should keep stable | ||
7 | for a longer period of time than dl.armbian.com. | ||
8 | |||
9 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
13 | Message-id: 20210310195820.21950-4-nieklinnenbank@gmail.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180521140402.23318-12-peter.maydell@linaro.org | ||
8 | --- | 15 | --- |
9 | include/exec/memory.h | 2 +- | 16 | tests/acceptance/boot_linux_console.py | 2 +- |
10 | exec.c | 2 +- | 17 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | hw/virtio/vhost.c | 3 ++- | ||
12 | 3 files changed, 4 insertions(+), 3 deletions(-) | ||
13 | 18 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 19 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 21 | --- a/tests/acceptance/boot_linux_console.py |
17 | +++ b/include/exec/memory.h | 22 | +++ b/tests/acceptance/boot_linux_console.py |
18 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache); | 23 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_bionic_20_08(self): |
19 | * entry. Should be called from an RCU critical section. | 24 | # to 1036 MiB, but the underlying filesystem is 1552 MiB... |
20 | */ | 25 | # As we expand it to 2 GiB we are safe. |
21 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 26 | |
22 | - bool is_write); | 27 | - image_url = ('https://dl.armbian.com/orangepipc/archive/' |
23 | + bool is_write, MemTxAttrs attrs); | 28 | + image_url = ('https://archive.armbian.com/orangepipc/archive/' |
24 | 29 | 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz') | |
25 | /* address_space_translate: translate an address range into an address space | 30 | image_hash = ('b4d6775f5673486329e45a0586bf06b6' |
26 | * into a MemoryRegion and an address range into that section. Should be | 31 | 'dbe792199fd182ac6b9c7bb6c7d3e6dd') |
27 | diff --git a/exec.c b/exec.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/exec.c | ||
30 | +++ b/exec.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv, | ||
32 | |||
33 | /* Called from RCU critical section */ | ||
34 | IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | ||
35 | - bool is_write) | ||
36 | + bool is_write, MemTxAttrs attrs) | ||
37 | { | ||
38 | MemoryRegionSection section; | ||
39 | hwaddr xlat, page_mask; | ||
40 | diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/virtio/vhost.c | ||
43 | +++ b/hw/virtio/vhost.c | ||
44 | @@ -XXX,XX +XXX,XX @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write) | ||
45 | trace_vhost_iotlb_miss(dev, 1); | ||
46 | |||
47 | iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as, | ||
48 | - iova, write); | ||
49 | + iova, write, | ||
50 | + MEMTXATTRS_UNSPECIFIED); | ||
51 | if (iotlb.target_as != NULL) { | ||
52 | ret = vhost_memory_region_lookup(dev, iotlb.translated_addr, | ||
53 | &uaddr, &len); | ||
54 | -- | 32 | -- |
55 | 2.17.1 | 33 | 2.20.1 |
56 | 34 | ||
57 | 35 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_extend_translation(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | The linux kernel 4.20.7 binary for sunxi has been removed from apt.armbian.com: | ||
4 | |||
5 | $ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado --show=app,console run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py | ||
6 | Fetching asset from tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi | ||
7 | ... | ||
8 | (1/6) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi: | ||
9 | CANCEL: Missing asset https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb (0.55 s) | ||
10 | |||
11 | This commit updates the sunxi kernel to 5.10.16 for the acceptance | ||
12 | tests of the orangepi-pc and cubieboard machines. | ||
13 | |||
14 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
15 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
16 | Message-id: 20210310195820.21950-5-nieklinnenbank@gmail.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-7-peter.maydell@linaro.org | ||
10 | --- | 18 | --- |
11 | exec.c | 15 ++++++++++----- | 19 | tests/acceptance/boot_linux_console.py | 40 +++++++++++++------------- |
12 | 1 file changed, 10 insertions(+), 5 deletions(-) | 20 | tests/acceptance/replay_kernel.py | 8 +++--- |
21 | 2 files changed, 24 insertions(+), 24 deletions(-) | ||
13 | 22 | ||
14 | diff --git a/exec.c b/exec.c | 23 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
15 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/exec.c | 25 | --- a/tests/acceptance/boot_linux_console.py |
17 | +++ b/exec.c | 26 | +++ b/tests/acceptance/boot_linux_console.py |
18 | @@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 27 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): |
19 | 28 | :avocado: tags=machine:cubieboard | |
20 | static hwaddr | 29 | """ |
21 | flatview_extend_translation(FlatView *fv, hwaddr addr, | 30 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
22 | - hwaddr target_len, | 31 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') |
23 | - MemoryRegion *mr, hwaddr base, hwaddr len, | 32 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' |
24 | - bool is_write) | 33 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') |
25 | + hwaddr target_len, | 34 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' |
26 | + MemoryRegion *mr, hwaddr base, hwaddr len, | 35 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
27 | + bool is_write, MemTxAttrs attrs) | 36 | kernel_path = self.extract_from_deb(deb_path, |
28 | { | 37 | - '/boot/vmlinuz-4.20.7-sunxi') |
29 | hwaddr done = 0; | 38 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' |
30 | hwaddr xlat; | 39 | + '/boot/vmlinuz-5.10.16-sunxi') |
31 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | 40 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' |
32 | 41 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | |
33 | memory_region_ref(mr); | 42 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
34 | *plen = flatview_extend_translation(fv, addr, len, mr, xlat, | 43 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
35 | - l, is_write); | 44 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self): |
36 | + l, is_write, attrs); | 45 | :avocado: tags=machine:cubieboard |
37 | ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); | 46 | """ |
38 | rcu_read_unlock(); | 47 | deb_url = ('https://apt.armbian.com/pool/main/l/' |
39 | 48 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | |
40 | @@ -XXX,XX +XXX,XX @@ int64_t address_space_cache_init(MemoryRegionCache *cache, | 49 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' |
41 | mr = cache->mrs.mr; | 50 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') |
42 | memory_region_ref(mr); | 51 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' |
43 | if (memory_access_is_direct(mr, is_write)) { | 52 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
44 | + /* We don't care about the memory attributes here as we're only | 53 | kernel_path = self.extract_from_deb(deb_path, |
45 | + * doing this if we found actual RAM, which behaves the same | 54 | - '/boot/vmlinuz-4.20.7-sunxi') |
46 | + * regardless of attributes; so UNSPECIFIED is fine. | 55 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' |
47 | + */ | 56 | + '/boot/vmlinuz-5.10.16-sunxi') |
48 | l = flatview_extend_translation(cache->fv, addr, len, mr, | 57 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' |
49 | - cache->xlat, l, is_write); | 58 | dtb_path = self.extract_from_deb(deb_path, dtb_path) |
50 | + cache->xlat, l, is_write, | 59 | rootfs_url = ('https://github.com/groeck/linux-build-test/raw/' |
51 | + MEMTXATTRS_UNSPECIFIED); | 60 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
52 | cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true); | 61 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi(self): |
53 | } else { | 62 | :avocado: tags=machine:orangepi-pc |
54 | cache->ptr = NULL; | 63 | """ |
64 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
65 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
66 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
67 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
68 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
69 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
70 | kernel_path = self.extract_from_deb(deb_path, | ||
71 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
72 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
73 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
74 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
75 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
76 | |||
77 | self.vm.set_console() | ||
78 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_initrd(self): | ||
79 | :avocado: tags=machine:orangepi-pc | ||
80 | """ | ||
81 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
82 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
83 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
84 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
85 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
86 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
87 | kernel_path = self.extract_from_deb(deb_path, | ||
88 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
89 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
90 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
91 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
92 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
93 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
94 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
95 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self): | ||
96 | :avocado: tags=device:sd | ||
97 | """ | ||
98 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
99 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
100 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
101 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
102 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
103 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
104 | kernel_path = self.extract_from_deb(deb_path, | ||
105 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
106 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
107 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
108 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb' | ||
109 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
110 | rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' | ||
111 | 'kci-2019.02/armel/base/rootfs.ext2.xz') | ||
112 | diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/tests/acceptance/replay_kernel.py | ||
115 | +++ b/tests/acceptance/replay_kernel.py | ||
116 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): | ||
117 | :avocado: tags=machine:cubieboard | ||
118 | """ | ||
119 | deb_url = ('https://apt.armbian.com/pool/main/l/' | ||
120 | - 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | ||
121 | - deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | ||
122 | + 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') | ||
123 | + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' | ||
124 | deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
125 | kernel_path = self.extract_from_deb(deb_path, | ||
126 | - '/boot/vmlinuz-4.20.7-sunxi') | ||
127 | - dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' | ||
128 | + '/boot/vmlinuz-5.10.16-sunxi') | ||
129 | + dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' | ||
130 | dtb_path = self.extract_from_deb(deb_path, dtb_path) | ||
131 | initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
132 | '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | ||
55 | -- | 133 | -- |
56 | 2.17.1 | 134 | 2.20.1 |
57 | 135 | ||
58 | 136 | diff view generated by jsdifflib |
1 | From: Paolo Bonzini <pbonzini@redhat.com> | 1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | cpregs_keys is an uint32_t* so the allocation should use uint32_t. | 3 | Previously the ARMBIAN_ARTIFACTS_CACHED pre-condition was added to allow running |
4 | g_new is even better because it is type-safe. | 4 | tests that have already existing armbian.com artifacts stored in the local avocado cache, |
5 | but do not have working URLs to download a fresh copy. | ||
5 | 6 | ||
6 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | 7 | At this time of writing the URLs for artifacts on the armbian.com server are updated and working. |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Any future broken URLs will result in a skipped acceptance test, for example: |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | |
10 | (1/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi: | ||
11 | CANCEL: Missing asset https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb (0.53 s) | ||
12 | |||
13 | This commits removes the ARMBIAN_ARTIFACTS_CACHED pre-condition such that | ||
14 | the acceptance tests for the orangepi-pc and cubieboard machines can run. | ||
15 | |||
16 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
17 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | ||
18 | Message-id: 20210310195820.21950-6-nieklinnenbank@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 20 | --- |
11 | target/arm/gdbstub.c | 3 +-- | 21 | tests/acceptance/boot_linux_console.py | 12 ------------ |
12 | 1 file changed, 1 insertion(+), 2 deletions(-) | 22 | tests/acceptance/replay_kernel.py | 2 -- |
23 | 2 files changed, 14 deletions(-) | ||
13 | 24 | ||
14 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | 25 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
15 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/gdbstub.c | 27 | --- a/tests/acceptance/boot_linux_console.py |
17 | +++ b/target/arm/gdbstub.c | 28 | +++ b/tests/acceptance/boot_linux_console.py |
18 | @@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_xml(CPUState *cs) | 29 | @@ -XXX,XX +XXX,XX @@ def test_arm_exynos4210_initrd(self): |
19 | RegisterSysregXmlParam param = {cs, s}; | 30 | self.wait_for_console_pattern('Boot successful.') |
20 | 31 | # TODO user command, for now the uart is stuck | |
21 | cpu->dyn_xml.num_cpregs = 0; | 32 | |
22 | - cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) * | 33 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), |
23 | - g_hash_table_size(cpu->cp_regs)); | 34 | - 'Test artifacts fetched from unreliable apt.armbian.com') |
24 | + cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs)); | 35 | def test_arm_cubieboard_initrd(self): |
25 | g_string_printf(s, "<?xml version=\"1.0\"?>"); | 36 | """ |
26 | g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); | 37 | :avocado: tags=arch:arm |
27 | g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">"); | 38 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self): |
39 | 'system-control@1c00000') | ||
40 | # cubieboard's reboot is not functioning; omit reboot test. | ||
41 | |||
42 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
43 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
44 | def test_arm_cubieboard_sata(self): | ||
45 | """ | ||
46 | :avocado: tags=arch:arm | ||
47 | @@ -XXX,XX +XXX,XX @@ def test_arm_quanta_gsj_initrd(self): | ||
48 | self.wait_for_console_pattern( | ||
49 | 'Give root password for system maintenance') | ||
50 | |||
51 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
52 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
53 | def test_arm_orangepi(self): | ||
54 | """ | ||
55 | :avocado: tags=arch:arm | ||
56 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi(self): | ||
57 | console_pattern = 'Kernel command line: %s' % kernel_command_line | ||
58 | self.wait_for_console_pattern(console_pattern) | ||
59 | |||
60 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
61 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
62 | def test_arm_orangepi_initrd(self): | ||
63 | """ | ||
64 | :avocado: tags=arch:arm | ||
65 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_initrd(self): | ||
66 | # Wait for VM to shut down gracefully | ||
67 | self.vm.wait() | ||
68 | |||
69 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
70 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
71 | def test_arm_orangepi_sd(self): | ||
72 | """ | ||
73 | :avocado: tags=arch:arm | ||
74 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self): | ||
75 | # Wait for VM to shut down gracefully | ||
76 | self.vm.wait() | ||
77 | |||
78 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
79 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
80 | @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') | ||
81 | def test_arm_orangepi_bionic_20_08(self): | ||
82 | """ | ||
83 | diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/tests/acceptance/replay_kernel.py | ||
86 | +++ b/tests/acceptance/replay_kernel.py | ||
87 | @@ -XXX,XX +XXX,XX @@ def test_arm_virt(self): | ||
88 | self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1) | ||
89 | |||
90 | @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | ||
91 | - @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'), | ||
92 | - 'Test artifacts fetched from unreliable apt.armbian.com') | ||
93 | def test_arm_cubieboard_initrd(self): | ||
94 | """ | ||
95 | :avocado: tags=arch:arm | ||
28 | -- | 96 | -- |
29 | 2.17.1 | 97 | 2.20.1 |
30 | 98 | ||
31 | 99 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | It forgot to increase clroffset during the loop. So it only clear the | 3 | If the SSECounter link is absent, we set an error message |
4 | first 4 bytes. | 4 | in sse_timer_realize() but forgot to propagate this error. |
5 | Add the missing 'return'. | ||
5 | 6 | ||
6 | Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920 | 7 | Fixes: CID 1450755 (Null pointer dereferences) |
7 | Cc: qemu-stable@nongnu.org | 8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | 9 | Message-id: 20210312001845.1562670-1-f4bug@amsat.org |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Message-id: 1527047633-12368-1-git-send-email-zhaoshenglong@huawei.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | hw/intc/arm_gicv3_kvm.c | 1 + | 13 | hw/timer/sse-timer.c | 1 + |
15 | 1 file changed, 1 insertion(+) | 14 | 1 file changed, 1 insertion(+) |
16 | 15 | ||
17 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 16 | diff --git a/hw/timer/sse-timer.c b/hw/timer/sse-timer.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_kvm.c | 18 | --- a/hw/timer/sse-timer.c |
20 | +++ b/hw/intc/arm_gicv3_kvm.c | 19 | +++ b/hw/timer/sse-timer.c |
21 | @@ -XXX,XX +XXX,XX @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset, | 20 | @@ -XXX,XX +XXX,XX @@ static void sse_timer_realize(DeviceState *dev, Error **errp) |
22 | if (clroffset != 0) { | 21 | |
23 | reg = 0; | 22 | if (!s->counter) { |
24 | kvm_gicd_access(s, clroffset, ®, true); | 23 | error_setg(errp, "counter property was not set"); |
25 | + clroffset += 4; | 24 | + return; |
26 | } | 25 | } |
27 | reg = *gic_bmp_ptr32(bmp, irq); | 26 | |
28 | kvm_gicd_access(s, offset, ®, true); | 27 | s->counter_notifier.notify = sse_timer_counter_callback; |
29 | -- | 28 | -- |
30 | 2.17.1 | 29 | 2.20.1 |
31 | 30 | ||
32 | 31 | diff view generated by jsdifflib |
1 | From: Shannon Zhao <zhaoshenglong@huawei.com> | 1 | From: Andrew Jones <drjones@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | acpi_data_push uses g_array_set_size to resize the memory size. If there | 3 | Prior to commit f2ce39b4f067 a MachineClass kvm_type method |
4 | is no enough contiguous memory, the address will be changed. So previous | 4 | only needed to be registered to ensure it would be executed. |
5 | pointer could not be used any more. It must update the pointer and use | 5 | With commit f2ce39b4f067 a kvm-type machine property must also |
6 | the new one. | 6 | be specified. hw/arm/virt relies on the kvm_type method to pass |
7 | its selected IPA limit to KVM, but this is not exposed as a | ||
8 | machine property. Restore the previous functionality of invoking | ||
9 | kvm_type when it's present. | ||
7 | 10 | ||
8 | Also, previous codes wrongly use le32 conversion of iort->node_offset | 11 | Fixes: f2ce39b4f067 ("vl: make qemu_get_machine_opts static") |
9 | for subsequent computations that will result incorrect value if host is | 12 | Signed-off-by: Andrew Jones <drjones@redhat.com> |
10 | not litlle endian. So use the non-converted one instead. | ||
11 | |||
12 | Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> | ||
13 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 13 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
14 | Message-id: 1527663951-14552-1-git-send-email-zhaoshenglong@huawei.com | 14 | Message-id: 20210310135218.255205-2-drjones@redhat.com |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 16 | --- |
17 | hw/arm/virt-acpi-build.c | 20 +++++++++++++++----- | 17 | include/hw/boards.h | 1 + |
18 | 1 file changed, 15 insertions(+), 5 deletions(-) | 18 | accel/kvm/kvm-all.c | 2 ++ |
19 | 2 files changed, 3 insertions(+) | ||
19 | 20 | ||
20 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 21 | diff --git a/include/hw/boards.h b/include/hw/boards.h |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/virt-acpi-build.c | 23 | --- a/include/hw/boards.h |
23 | +++ b/hw/arm/virt-acpi-build.c | 24 | +++ b/include/hw/boards.h |
24 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
25 | AcpiIortItsGroup *its; | 26 | * @kvm_type: |
26 | AcpiIortTable *iort; | 27 | * Return the type of KVM corresponding to the kvm-type string option or |
27 | AcpiIortSmmu3 *smmu; | 28 | * computed based on other criteria such as the host kernel capabilities. |
28 | - size_t node_size, iort_length, smmu_offset = 0; | 29 | + * kvm-type may be NULL if it is not needed. |
29 | + size_t node_size, iort_node_offset, iort_length, smmu_offset = 0; | 30 | * @numa_mem_supported: |
30 | AcpiIortRC *rc; | 31 | * true if '--numa node.mem' option is supported and false otherwise |
31 | 32 | * @smp_parse: | |
32 | iort = acpi_data_push(table_data, sizeof(*iort)); | 33 | diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c |
33 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 34 | index XXXXXXX..XXXXXXX 100644 |
34 | 35 | --- a/accel/kvm/kvm-all.c | |
35 | iort_length = sizeof(*iort); | 36 | +++ b/accel/kvm/kvm-all.c |
36 | iort->node_count = cpu_to_le32(nb_nodes); | 37 | @@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms) |
37 | - iort->node_offset = cpu_to_le32(sizeof(*iort)); | 38 | "kvm-type", |
38 | + /* | 39 | &error_abort); |
39 | + * Use a copy in case table_data->data moves during acpi_data_push | 40 | type = mc->kvm_type(ms, kvm_type); |
40 | + * operations. | 41 | + } else if (mc->kvm_type) { |
41 | + */ | 42 | + type = mc->kvm_type(ms, NULL); |
42 | + iort_node_offset = sizeof(*iort); | ||
43 | + iort->node_offset = cpu_to_le32(iort_node_offset); | ||
44 | |||
45 | /* ITS group node */ | ||
46 | node_size = sizeof(*its) + sizeof(uint32_t); | ||
47 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
48 | int irq = vms->irqmap[VIRT_SMMU]; | ||
49 | |||
50 | /* SMMUv3 node */ | ||
51 | - smmu_offset = iort->node_offset + node_size; | ||
52 | + smmu_offset = iort_node_offset + node_size; | ||
53 | node_size = sizeof(*smmu) + sizeof(*idmap); | ||
54 | iort_length += node_size; | ||
55 | smmu = acpi_data_push(table_data, node_size); | ||
56 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
57 | idmap->id_count = cpu_to_le32(0xFFFF); | ||
58 | idmap->output_base = 0; | ||
59 | /* output IORT node is the ITS group node (the first node) */ | ||
60 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | ||
61 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | ||
62 | } | 43 | } |
63 | 44 | ||
64 | /* Root Complex Node */ | 45 | do { |
65 | @@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
66 | idmap->output_reference = cpu_to_le32(smmu_offset); | ||
67 | } else { | ||
68 | /* output IORT node is the ITS group node (the first node) */ | ||
69 | - idmap->output_reference = cpu_to_le32(iort->node_offset); | ||
70 | + idmap->output_reference = cpu_to_le32(iort_node_offset); | ||
71 | } | ||
72 | |||
73 | + /* | ||
74 | + * Update the pointer address in case table_data->data moves during above | ||
75 | + * acpi_data_push operations. | ||
76 | + */ | ||
77 | + iort = (AcpiIortTable *)(table_data->data + iort_start); | ||
78 | iort->length = cpu_to_le32(iort_length); | ||
79 | |||
80 | build_header(linker, table_data, (void *)(table_data->data + iort_start), | ||
81 | -- | 46 | -- |
82 | 2.17.1 | 47 | 2.20.1 |
83 | 48 | ||
84 | 49 | diff view generated by jsdifflib |
1 | Provide a VMSTATE_BOOL_SUB_ARRAY to go with VMSTATE_UINT8_SUB_ARRAY | 1 | From: Andrew Jones <drjones@redhat.com> |
---|---|---|---|
2 | and friends. | ||
3 | 2 | ||
3 | The virt machine already checks KVM_CAP_ARM_VM_IPA_SIZE to get the | ||
4 | upper bound of the IPA size. If that bound is lower than the highest | ||
5 | possible GPA for the machine, then QEMU will error out. However, the | ||
6 | IPA is set to 40 when the highest GPA is less than or equal to 40, | ||
7 | even when KVM may support an IPA limit as low as 32. This means KVM | ||
8 | may fail the VM creation unnecessarily. Additionally, 40 is selected | ||
9 | with the value 0, which means use the default, and that gets around | ||
10 | a check in some versions of KVM, causing a difficult to debug fail. | ||
11 | Always use the IPA size that corresponds to the highest possible GPA, | ||
12 | unless it's lower than 32, in which case use 32. Also, we must still | ||
13 | use 0 when KVM only supports the legacy fixed 40 bit IPA. | ||
14 | |||
15 | Suggested-by: Marc Zyngier <maz@kernel.org> | ||
16 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
17 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
19 | Message-id: 20210310135218.255205-3-drjones@redhat.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Message-id: 20180521140402.23318-23-peter.maydell@linaro.org | ||
7 | --- | 21 | --- |
8 | include/migration/vmstate.h | 3 +++ | 22 | target/arm/kvm_arm.h | 6 ++++-- |
9 | 1 file changed, 3 insertions(+) | 23 | hw/arm/virt.c | 23 ++++++++++++++++------- |
24 | target/arm/kvm.c | 4 +++- | ||
25 | 3 files changed, 23 insertions(+), 10 deletions(-) | ||
10 | 26 | ||
11 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 27 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h |
12 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/include/migration/vmstate.h | 29 | --- a/target/arm/kvm_arm.h |
14 | +++ b/include/migration/vmstate.h | 30 | +++ b/target/arm/kvm_arm.h |
15 | @@ -XXX,XX +XXX,XX @@ extern const VMStateInfo vmstate_info_qtailq; | 31 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_sve_supported(void); |
16 | #define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ | 32 | /** |
17 | VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) | 33 | * kvm_arm_get_max_vm_ipa_size: |
18 | 34 | * @ms: Machine state handle | |
19 | +#define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \ | 35 | + * @fixed_ipa: True when the IPA limit is fixed at 40. This is the case |
20 | + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool) | 36 | + * for legacy KVM. |
37 | * | ||
38 | * Returns the number of bits in the IPA address space supported by KVM | ||
39 | */ | ||
40 | -int kvm_arm_get_max_vm_ipa_size(MachineState *ms); | ||
41 | +int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa); | ||
42 | |||
43 | /** | ||
44 | * kvm_arm_sync_mpstate_to_kvm: | ||
45 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_add_vcpu_properties(Object *obj) | ||
46 | g_assert_not_reached(); | ||
47 | } | ||
48 | |||
49 | -static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
50 | +static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa) | ||
51 | { | ||
52 | g_assert_not_reached(); | ||
53 | } | ||
54 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/arm/virt.c | ||
57 | +++ b/hw/arm/virt.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | ||
59 | static int virt_kvm_type(MachineState *ms, const char *type_str) | ||
60 | { | ||
61 | VirtMachineState *vms = VIRT_MACHINE(ms); | ||
62 | - int max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms); | ||
63 | - int requested_pa_size; | ||
64 | + int max_vm_pa_size, requested_pa_size; | ||
65 | + bool fixed_ipa; | ||
21 | + | 66 | + |
22 | #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ | 67 | + max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa); |
23 | VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) | 68 | |
69 | /* we freeze the memory map to compute the highest gpa */ | ||
70 | virt_set_memmap(vms); | ||
71 | |||
72 | requested_pa_size = 64 - clz64(vms->highest_gpa); | ||
73 | |||
74 | + /* | ||
75 | + * KVM requires the IPA size to be at least 32 bits. | ||
76 | + */ | ||
77 | + if (requested_pa_size < 32) { | ||
78 | + requested_pa_size = 32; | ||
79 | + } | ||
80 | + | ||
81 | if (requested_pa_size > max_vm_pa_size) { | ||
82 | error_report("-m and ,maxmem option values " | ||
83 | "require an IPA range (%d bits) larger than " | ||
84 | "the one supported by the host (%d bits)", | ||
85 | requested_pa_size, max_vm_pa_size); | ||
86 | - exit(1); | ||
87 | + exit(1); | ||
88 | } | ||
89 | /* | ||
90 | - * By default we return 0 which corresponds to an implicit legacy | ||
91 | - * 40b IPA setting. Otherwise we return the actual requested PA | ||
92 | - * logsize | ||
93 | + * We return the requested PA log size, unless KVM only supports | ||
94 | + * the implicit legacy 40b IPA setting, in which case the kvm_type | ||
95 | + * must be 0. | ||
96 | */ | ||
97 | - return requested_pa_size > 40 ? requested_pa_size : 0; | ||
98 | + return fixed_ipa ? 0 : requested_pa_size; | ||
99 | } | ||
100 | |||
101 | static void virt_machine_class_init(ObjectClass *oc, void *data) | ||
102 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/arm/kvm.c | ||
105 | +++ b/target/arm/kvm.c | ||
106 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(void) | ||
107 | return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3); | ||
108 | } | ||
109 | |||
110 | -int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
111 | +int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa) | ||
112 | { | ||
113 | KVMState *s = KVM_STATE(ms->accelerator); | ||
114 | int ret; | ||
115 | |||
116 | ret = kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE); | ||
117 | + *fixed_ipa = ret <= 0; | ||
118 | + | ||
119 | return ret > 0 ? ret : 40; | ||
120 | } | ||
24 | 121 | ||
25 | -- | 122 | -- |
26 | 2.17.1 | 123 | 2.20.1 |
27 | 124 | ||
28 | 125 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_access_valid(). | ||
3 | Its callers either have an attrs value to hand, or don't care | ||
4 | and can use MEMTXATTRS_UNSPECIFIED. | ||
5 | 2 | ||
3 | This patch adds GPIOs in NPCM7xx PWM module for its duty values. | ||
4 | The purpose of this is to connect it to the MFT module to provide | ||
5 | an input for measuring a PWM fan's RPM. Each PWM module has | ||
6 | NPCM7XX_PWM_PER_MODULE of GPIOs, each one corresponds to | ||
7 | one PWM instance and can connect to multiple fan instances in MFT. | ||
8 | |||
9 | Reviewed-by: Doug Evans <dje@google.com> | ||
10 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
11 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20210311180855.149764-2-wuhaotsh@google.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180521140402.23318-6-peter.maydell@linaro.org | ||
10 | --- | 15 | --- |
11 | include/exec/memory.h | 4 +++- | 16 | include/hw/misc/npcm7xx_pwm.h | 4 +++- |
12 | include/sysemu/dma.h | 3 ++- | 17 | hw/misc/npcm7xx_pwm.c | 4 ++++ |
13 | exec.c | 3 ++- | 18 | 2 files changed, 7 insertions(+), 1 deletion(-) |
14 | target/s390x/diag.c | 6 ++++-- | ||
15 | target/s390x/excp_helper.c | 3 ++- | ||
16 | target/s390x/mmu_helper.c | 3 ++- | ||
17 | target/s390x/sigp.c | 3 ++- | ||
18 | 7 files changed, 17 insertions(+), 8 deletions(-) | ||
19 | 19 | ||
20 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 20 | diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/memory.h | 22 | --- a/include/hw/misc/npcm7xx_pwm.h |
23 | +++ b/include/exec/memory.h | 23 | +++ b/include/hw/misc/npcm7xx_pwm.h |
24 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | 24 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxPWM { |
25 | * @addr: address within that address space | 25 | * @iomem: Memory region through which registers are accessed. |
26 | * @len: length of the area to be checked | 26 | * @clock: The PWM clock. |
27 | * @is_write: indicates the transfer direction | 27 | * @pwm: The PWM channels owned by this module. |
28 | + * @attrs: memory attributes | 28 | + * @duty_gpio_out: The duty cycle of each PWM channels as a output GPIO. |
29 | */ | 29 | * @ppr: The prescaler register. |
30 | -bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write); | 30 | * @csr: The clock selector register. |
31 | +bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, | 31 | * @pcr: The control register. |
32 | + bool is_write, MemTxAttrs attrs); | 32 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxPWMState { |
33 | 33 | MemoryRegion iomem; | |
34 | /* address_space_map: map a physical memory region into a host virtual address | 34 | |
35 | * | 35 | Clock *clock; |
36 | diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h | 36 | - NPCM7xxPWM pwm[NPCM7XX_PWM_PER_MODULE]; |
37 | + NPCM7xxPWM pwm[NPCM7XX_PWM_PER_MODULE]; | ||
38 | + qemu_irq duty_gpio_out[NPCM7XX_PWM_PER_MODULE]; | ||
39 | |||
40 | uint32_t ppr; | ||
41 | uint32_t csr; | ||
42 | diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/include/sysemu/dma.h | 44 | --- a/hw/misc/npcm7xx_pwm.c |
39 | +++ b/include/sysemu/dma.h | 45 | +++ b/hw/misc/npcm7xx_pwm.c |
40 | @@ -XXX,XX +XXX,XX @@ static inline bool dma_memory_valid(AddressSpace *as, | 46 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_update_duty(NPCM7xxPWM *p) |
41 | DMADirection dir) | 47 | trace_npcm7xx_pwm_update_duty(DEVICE(p->module)->canonical_path, |
42 | { | 48 | p->index, p->duty, duty); |
43 | return address_space_access_valid(as, addr, len, | 49 | p->duty = duty; |
44 | - dir == DMA_DIRECTION_FROM_DEVICE); | 50 | + qemu_set_irq(p->module->duty_gpio_out[p->index], p->duty); |
45 | + dir == DMA_DIRECTION_FROM_DEVICE, | 51 | } |
46 | + MEMTXATTRS_UNSPECIFIED); | ||
47 | } | 52 | } |
48 | 53 | ||
49 | static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, | 54 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_init(Object *obj) |
50 | diff --git a/exec.c b/exec.c | 55 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
51 | index XXXXXXX..XXXXXXX 100644 | 56 | int i; |
52 | --- a/exec.c | 57 | |
53 | +++ b/exec.c | 58 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->pwm) != NPCM7XX_PWM_PER_MODULE); |
54 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 59 | for (i = 0; i < NPCM7XX_PWM_PER_MODULE; i++) { |
60 | NPCM7xxPWM *p = &s->pwm[i]; | ||
61 | p->module = s; | ||
62 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_init(Object *obj) | ||
63 | object_property_add_uint32_ptr(obj, "duty[*]", | ||
64 | &s->pwm[i].duty, OBJ_PROP_FLAG_READ); | ||
65 | } | ||
66 | + qdev_init_gpio_out_named(DEVICE(s), s->duty_gpio_out, | ||
67 | + "duty-gpio-out", NPCM7XX_PWM_PER_MODULE); | ||
55 | } | 68 | } |
56 | 69 | ||
57 | bool address_space_access_valid(AddressSpace *as, hwaddr addr, | 70 | static const VMStateDescription vmstate_npcm7xx_pwm = { |
58 | - int len, bool is_write) | ||
59 | + int len, bool is_write, | ||
60 | + MemTxAttrs attrs) | ||
61 | { | ||
62 | FlatView *fv; | ||
63 | bool result; | ||
64 | diff --git a/target/s390x/diag.c b/target/s390x/diag.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/s390x/diag.c | ||
67 | +++ b/target/s390x/diag.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra) | ||
69 | return; | ||
70 | } | ||
71 | if (!address_space_access_valid(&address_space_memory, addr, | ||
72 | - sizeof(IplParameterBlock), false)) { | ||
73 | + sizeof(IplParameterBlock), false, | ||
74 | + MEMTXATTRS_UNSPECIFIED)) { | ||
75 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
76 | return; | ||
77 | } | ||
78 | @@ -XXX,XX +XXX,XX @@ out: | ||
79 | return; | ||
80 | } | ||
81 | if (!address_space_access_valid(&address_space_memory, addr, | ||
82 | - sizeof(IplParameterBlock), true)) { | ||
83 | + sizeof(IplParameterBlock), true, | ||
84 | + MEMTXATTRS_UNSPECIFIED)) { | ||
85 | s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra); | ||
86 | return; | ||
87 | } | ||
88 | diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/s390x/excp_helper.c | ||
91 | +++ b/target/s390x/excp_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size, | ||
93 | |||
94 | /* check out of RAM access */ | ||
95 | if (!address_space_access_valid(&address_space_memory, raddr, | ||
96 | - TARGET_PAGE_SIZE, rw)) { | ||
97 | + TARGET_PAGE_SIZE, rw, | ||
98 | + MEMTXATTRS_UNSPECIFIED)) { | ||
99 | DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__, | ||
100 | (uint64_t)raddr, (uint64_t)ram_size); | ||
101 | trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO); | ||
102 | diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/s390x/mmu_helper.c | ||
105 | +++ b/target/s390x/mmu_helper.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages, | ||
107 | return ret; | ||
108 | } | ||
109 | if (!address_space_access_valid(&address_space_memory, pages[i], | ||
110 | - TARGET_PAGE_SIZE, is_write)) { | ||
111 | + TARGET_PAGE_SIZE, is_write, | ||
112 | + MEMTXATTRS_UNSPECIFIED)) { | ||
113 | trigger_access_exception(env, PGM_ADDRESSING, ILEN_AUTO, 0); | ||
114 | return -EFAULT; | ||
115 | } | ||
116 | diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/s390x/sigp.c | ||
119 | +++ b/target/s390x/sigp.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) | ||
121 | cpu_synchronize_state(cs); | ||
122 | |||
123 | if (!address_space_access_valid(&address_space_memory, addr, | ||
124 | - sizeof(struct LowCore), false)) { | ||
125 | + sizeof(struct LowCore), false, | ||
126 | + MEMTXATTRS_UNSPECIFIED)) { | ||
127 | set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); | ||
128 | return; | ||
129 | } | ||
130 | -- | 71 | -- |
131 | 2.17.1 | 72 | 2.20.1 |
132 | 73 | ||
133 | 74 | diff view generated by jsdifflib |
1 | From: Francisco Iglesias <frasse.iglesias@gmail.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Coverity found that the string return by 'object_get_canonical_path' was not | 3 | This patch implements Multi Function Timer (MFT) module for NPCM7XX. |
4 | being freed at two locations in the model (CID 1391294 and CID 1391293) and | 4 | This module is mainly used to configure PWM fans. It has just enough |
5 | also that a memset was being called with a value greater than the max of a byte | 5 | functionality to make the PWM fan kernel module work. |
6 | on the second argument (CID 1391286). This patch corrects this by adding the | ||
7 | freeing of the strings and also changing to memset to zero instead on | ||
8 | descriptor unaligned errors. | ||
9 | 6 | ||
10 | Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 7 | The module takes two input, the max_rpm of a fan (modifiable via QMP) |
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | and duty cycle (a GPIO from the PWM module.) The actual measured RPM |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | is equal to max_rpm * duty_cycle / NPCM7XX_PWM_MAX_DUTY. The RPM is |
13 | Message-id: 20180528184859.3530-1-frasse.iglesias@gmail.com | 10 | measured as a counter compared to a prescaled input clock. The kernel |
11 | driver reads this counter and report to user space. | ||
12 | |||
13 | Refs: | ||
14 | https://github.com/torvalds/linux/blob/master/drivers/hwmon/npcm750-pwm-fan.c | ||
15 | |||
16 | Reviewed-by: Doug Evans <dje@google.com> | ||
17 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
18 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
19 | Message-id: 20210311180855.149764-3-wuhaotsh@google.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 22 | --- |
17 | hw/dma/xlnx-zdma.c | 10 +++++++--- | 23 | include/hw/misc/npcm7xx_mft.h | 70 +++++ |
18 | 1 file changed, 7 insertions(+), 3 deletions(-) | 24 | hw/misc/npcm7xx_mft.c | 540 ++++++++++++++++++++++++++++++++++ |
25 | hw/misc/meson.build | 1 + | ||
26 | hw/misc/trace-events | 8 + | ||
27 | 4 files changed, 619 insertions(+) | ||
28 | create mode 100644 include/hw/misc/npcm7xx_mft.h | ||
29 | create mode 100644 hw/misc/npcm7xx_mft.c | ||
19 | 30 | ||
20 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c | 31 | diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h |
32 | new file mode 100644 | ||
33 | index XXXXXXX..XXXXXXX | ||
34 | --- /dev/null | ||
35 | +++ b/include/hw/misc/npcm7xx_mft.h | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | +/* | ||
38 | + * Nuvoton NPCM7xx MFT Module | ||
39 | + * | ||
40 | + * Copyright 2021 Google LLC | ||
41 | + * | ||
42 | + * This program is free software; you can redistribute it and/or modify it | ||
43 | + * under the terms of the GNU General Public License as published by the | ||
44 | + * Free Software Foundation; either version 2 of the License, or | ||
45 | + * (at your option) any later version. | ||
46 | + * | ||
47 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
48 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
49 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
50 | + * for more details. | ||
51 | + */ | ||
52 | +#ifndef NPCM7XX_MFT_H | ||
53 | +#define NPCM7XX_MFT_H | ||
54 | + | ||
55 | +#include "exec/memory.h" | ||
56 | +#include "hw/clock.h" | ||
57 | +#include "hw/irq.h" | ||
58 | +#include "hw/sysbus.h" | ||
59 | +#include "qom/object.h" | ||
60 | + | ||
61 | +/* Max Fan input number. */ | ||
62 | +#define NPCM7XX_MFT_MAX_FAN_INPUT 19 | ||
63 | + | ||
64 | +/* | ||
65 | + * Number of registers in one MFT module. Don't change this without increasing | ||
66 | + * the version_id in vmstate. | ||
67 | + */ | ||
68 | +#define NPCM7XX_MFT_NR_REGS (0x20 / sizeof(uint16_t)) | ||
69 | + | ||
70 | +/* | ||
71 | + * The MFT can take up to 4 inputs: A0, B0, A1, B1. It can measure one A and one | ||
72 | + * B simultaneously. NPCM7XX_MFT_INASEL and NPCM7XX_MFT_INBSEL are used to | ||
73 | + * select which A or B input are used. | ||
74 | + */ | ||
75 | +#define NPCM7XX_MFT_FANIN_COUNT 4 | ||
76 | + | ||
77 | +/** | ||
78 | + * struct NPCM7xxMFTState - Multi Functional Tachometer device state. | ||
79 | + * @parent: System bus device. | ||
80 | + * @iomem: Memory region through which registers are accessed. | ||
81 | + * @clock_in: The input clock for MFT from CLK module. | ||
82 | + * @clock_{1,2}: The counter clocks for NPCM7XX_MFT_CNT{1,2} | ||
83 | + * @irq: The IRQ for this MFT state. | ||
84 | + * @regs: The MMIO registers. | ||
85 | + * @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1. | ||
86 | + * @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY. | ||
87 | + */ | ||
88 | +typedef struct NPCM7xxMFTState { | ||
89 | + SysBusDevice parent; | ||
90 | + | ||
91 | + MemoryRegion iomem; | ||
92 | + | ||
93 | + Clock *clock_in; | ||
94 | + Clock *clock_1, *clock_2; | ||
95 | + qemu_irq irq; | ||
96 | + uint16_t regs[NPCM7XX_MFT_NR_REGS]; | ||
97 | + | ||
98 | + uint32_t max_rpm[NPCM7XX_MFT_FANIN_COUNT]; | ||
99 | + uint32_t duty[NPCM7XX_MFT_FANIN_COUNT]; | ||
100 | +} NPCM7xxMFTState; | ||
101 | + | ||
102 | +#define TYPE_NPCM7XX_MFT "npcm7xx-mft" | ||
103 | +#define NPCM7XX_MFT(obj) \ | ||
104 | + OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT) | ||
105 | + | ||
106 | +#endif /* NPCM7XX_MFT_H */ | ||
107 | diff --git a/hw/misc/npcm7xx_mft.c b/hw/misc/npcm7xx_mft.c | ||
108 | new file mode 100644 | ||
109 | index XXXXXXX..XXXXXXX | ||
110 | --- /dev/null | ||
111 | +++ b/hw/misc/npcm7xx_mft.c | ||
112 | @@ -XXX,XX +XXX,XX @@ | ||
113 | +/* | ||
114 | + * Nuvoton NPCM7xx MFT Module | ||
115 | + * | ||
116 | + * Copyright 2021 Google LLC | ||
117 | + * | ||
118 | + * This program is free software; you can redistribute it and/or modify it | ||
119 | + * under the terms of the GNU General Public License as published by the | ||
120 | + * Free Software Foundation; either version 2 of the License, or | ||
121 | + * (at your option) any later version. | ||
122 | + * | ||
123 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
124 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
125 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
126 | + * for more details. | ||
127 | + */ | ||
128 | + | ||
129 | +#include "qemu/osdep.h" | ||
130 | +#include "hw/irq.h" | ||
131 | +#include "hw/qdev-clock.h" | ||
132 | +#include "hw/qdev-properties.h" | ||
133 | +#include "hw/misc/npcm7xx_mft.h" | ||
134 | +#include "hw/misc/npcm7xx_pwm.h" | ||
135 | +#include "hw/registerfields.h" | ||
136 | +#include "migration/vmstate.h" | ||
137 | +#include "qapi/error.h" | ||
138 | +#include "qapi/visitor.h" | ||
139 | +#include "qemu/bitops.h" | ||
140 | +#include "qemu/error-report.h" | ||
141 | +#include "qemu/log.h" | ||
142 | +#include "qemu/module.h" | ||
143 | +#include "qemu/timer.h" | ||
144 | +#include "qemu/units.h" | ||
145 | +#include "trace.h" | ||
146 | + | ||
147 | +/* | ||
148 | + * Some of the registers can only accessed via 16-bit ops and some can only | ||
149 | + * be accessed via 8-bit ops. However we mark all of them using REG16 to | ||
150 | + * simplify implementation. npcm7xx_mft_check_mem_op checks the access length | ||
151 | + * of memory operations. | ||
152 | + */ | ||
153 | +REG16(NPCM7XX_MFT_CNT1, 0x00); | ||
154 | +REG16(NPCM7XX_MFT_CRA, 0x02); | ||
155 | +REG16(NPCM7XX_MFT_CRB, 0x04); | ||
156 | +REG16(NPCM7XX_MFT_CNT2, 0x06); | ||
157 | +REG16(NPCM7XX_MFT_PRSC, 0x08); | ||
158 | +REG16(NPCM7XX_MFT_CKC, 0x0a); | ||
159 | +REG16(NPCM7XX_MFT_MCTRL, 0x0c); | ||
160 | +REG16(NPCM7XX_MFT_ICTRL, 0x0e); | ||
161 | +REG16(NPCM7XX_MFT_ICLR, 0x10); | ||
162 | +REG16(NPCM7XX_MFT_IEN, 0x12); | ||
163 | +REG16(NPCM7XX_MFT_CPA, 0x14); | ||
164 | +REG16(NPCM7XX_MFT_CPB, 0x16); | ||
165 | +REG16(NPCM7XX_MFT_CPCFG, 0x18); | ||
166 | +REG16(NPCM7XX_MFT_INASEL, 0x1a); | ||
167 | +REG16(NPCM7XX_MFT_INBSEL, 0x1c); | ||
168 | + | ||
169 | +/* Register Fields */ | ||
170 | +#define NPCM7XX_MFT_CKC_C2CSEL BIT(3) | ||
171 | +#define NPCM7XX_MFT_CKC_C1CSEL BIT(0) | ||
172 | + | ||
173 | +#define NPCM7XX_MFT_MCTRL_TBEN BIT(6) | ||
174 | +#define NPCM7XX_MFT_MCTRL_TAEN BIT(5) | ||
175 | +#define NPCM7XX_MFT_MCTRL_TBEDG BIT(4) | ||
176 | +#define NPCM7XX_MFT_MCTRL_TAEDG BIT(3) | ||
177 | +#define NPCM7XX_MFT_MCTRL_MODE5 BIT(2) | ||
178 | + | ||
179 | +#define NPCM7XX_MFT_ICTRL_TFPND BIT(5) | ||
180 | +#define NPCM7XX_MFT_ICTRL_TEPND BIT(4) | ||
181 | +#define NPCM7XX_MFT_ICTRL_TDPND BIT(3) | ||
182 | +#define NPCM7XX_MFT_ICTRL_TCPND BIT(2) | ||
183 | +#define NPCM7XX_MFT_ICTRL_TBPND BIT(1) | ||
184 | +#define NPCM7XX_MFT_ICTRL_TAPND BIT(0) | ||
185 | + | ||
186 | +#define NPCM7XX_MFT_ICLR_TFCLR BIT(5) | ||
187 | +#define NPCM7XX_MFT_ICLR_TECLR BIT(4) | ||
188 | +#define NPCM7XX_MFT_ICLR_TDCLR BIT(3) | ||
189 | +#define NPCM7XX_MFT_ICLR_TCCLR BIT(2) | ||
190 | +#define NPCM7XX_MFT_ICLR_TBCLR BIT(1) | ||
191 | +#define NPCM7XX_MFT_ICLR_TACLR BIT(0) | ||
192 | + | ||
193 | +#define NPCM7XX_MFT_IEN_TFIEN BIT(5) | ||
194 | +#define NPCM7XX_MFT_IEN_TEIEN BIT(4) | ||
195 | +#define NPCM7XX_MFT_IEN_TDIEN BIT(3) | ||
196 | +#define NPCM7XX_MFT_IEN_TCIEN BIT(2) | ||
197 | +#define NPCM7XX_MFT_IEN_TBIEN BIT(1) | ||
198 | +#define NPCM7XX_MFT_IEN_TAIEN BIT(0) | ||
199 | + | ||
200 | +#define NPCM7XX_MFT_CPCFG_GET_B(rv) extract8((rv), 4, 4) | ||
201 | +#define NPCM7XX_MFT_CPCFG_GET_A(rv) extract8((rv), 0, 4) | ||
202 | +#define NPCM7XX_MFT_CPCFG_HIEN BIT(3) | ||
203 | +#define NPCM7XX_MFT_CPCFG_EQEN BIT(2) | ||
204 | +#define NPCM7XX_MFT_CPCFG_LOEN BIT(1) | ||
205 | +#define NPCM7XX_MFT_CPCFG_CPSEL BIT(0) | ||
206 | + | ||
207 | +#define NPCM7XX_MFT_INASEL_SELA BIT(0) | ||
208 | +#define NPCM7XX_MFT_INBSEL_SELB BIT(0) | ||
209 | + | ||
210 | +/* Max CNT values of the module. The CNT value is a countdown from it. */ | ||
211 | +#define NPCM7XX_MFT_MAX_CNT 0xFFFF | ||
212 | + | ||
213 | +/* Each fan revolution should generated 2 pulses */ | ||
214 | +#define NPCM7XX_MFT_PULSE_PER_REVOLUTION 2 | ||
215 | + | ||
216 | +typedef enum NPCM7xxMFTCaptureState { | ||
217 | + /* capture succeeded with a valid CNT value. */ | ||
218 | + NPCM7XX_CAPTURE_SUCCEED, | ||
219 | + /* capture stopped prematurely due to reaching CPCFG condition. */ | ||
220 | + NPCM7XX_CAPTURE_COMPARE_HIT, | ||
221 | + /* capture fails since it reaches underflow condition for CNT. */ | ||
222 | + NPCM7XX_CAPTURE_UNDERFLOW, | ||
223 | +} NPCM7xxMFTCaptureState; | ||
224 | + | ||
225 | +static void npcm7xx_mft_reset(NPCM7xxMFTState *s) | ||
226 | +{ | ||
227 | + int i; | ||
228 | + | ||
229 | + /* Only registers PRSC ~ INBSEL need to be reset. */ | ||
230 | + for (i = R_NPCM7XX_MFT_PRSC; i <= R_NPCM7XX_MFT_INBSEL; ++i) { | ||
231 | + s->regs[i] = 0; | ||
232 | + } | ||
233 | +} | ||
234 | + | ||
235 | +static void npcm7xx_mft_clear_interrupt(NPCM7xxMFTState *s, uint8_t iclr) | ||
236 | +{ | ||
237 | + /* | ||
238 | + * Clear bits in ICTRL where corresponding bits in iclr is 1. | ||
239 | + * Both iclr and ictrl are 8-bit regs. (See npcm7xx_mft_check_mem_op) | ||
240 | + */ | ||
241 | + s->regs[R_NPCM7XX_MFT_ICTRL] &= ~iclr; | ||
242 | +} | ||
243 | + | ||
244 | +/* | ||
245 | + * If the CPCFG's condition should be triggered during count down from | ||
246 | + * NPCM7XX_MFT_MAX_CNT to src if compared to tgt, return the count when | ||
247 | + * the condition is triggered. | ||
248 | + * Otherwise return -1. | ||
249 | + * Since tgt is uint16_t it must always <= NPCM7XX_MFT_MAX_CNT. | ||
250 | + */ | ||
251 | +static int npcm7xx_mft_compare(int32_t src, uint16_t tgt, uint8_t cpcfg) | ||
252 | +{ | ||
253 | + if (cpcfg & NPCM7XX_MFT_CPCFG_HIEN) { | ||
254 | + return NPCM7XX_MFT_MAX_CNT; | ||
255 | + } | ||
256 | + if ((cpcfg & NPCM7XX_MFT_CPCFG_EQEN) && (src <= tgt)) { | ||
257 | + return tgt; | ||
258 | + } | ||
259 | + if ((cpcfg & NPCM7XX_MFT_CPCFG_LOEN) && (tgt > 0) && (src < tgt)) { | ||
260 | + return tgt - 1; | ||
261 | + } | ||
262 | + | ||
263 | + return -1; | ||
264 | +} | ||
265 | + | ||
266 | +/* Compute CNT according to corresponding fan's RPM. */ | ||
267 | +static NPCM7xxMFTCaptureState npcm7xx_mft_compute_cnt( | ||
268 | + Clock *clock, uint32_t max_rpm, uint32_t duty, uint16_t tgt, | ||
269 | + uint8_t cpcfg, uint16_t *cnt) | ||
270 | +{ | ||
271 | + uint32_t rpm = (uint64_t)max_rpm * (uint64_t)duty / NPCM7XX_PWM_MAX_DUTY; | ||
272 | + int32_t count; | ||
273 | + int stopped; | ||
274 | + NPCM7xxMFTCaptureState state; | ||
275 | + | ||
276 | + if (rpm == 0) { | ||
277 | + /* | ||
278 | + * If RPM = 0, capture won't happen. CNT will continue count down. | ||
279 | + * So it's effective equivalent to have a cnt > NPCM7XX_MFT_MAX_CNT | ||
280 | + */ | ||
281 | + count = NPCM7XX_MFT_MAX_CNT + 1; | ||
282 | + } else { | ||
283 | + /* | ||
284 | + * RPM = revolution/min. The time for one revlution (in ns) is | ||
285 | + * MINUTE_TO_NANOSECOND / RPM. | ||
286 | + */ | ||
287 | + count = clock_ns_to_ticks(clock, (60 * NANOSECONDS_PER_SECOND) / | ||
288 | + (rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION)); | ||
289 | + } | ||
290 | + | ||
291 | + if (count > NPCM7XX_MFT_MAX_CNT) { | ||
292 | + count = -1; | ||
293 | + } else { | ||
294 | + /* The CNT is a countdown value from NPCM7XX_MFT_MAX_CNT. */ | ||
295 | + count = NPCM7XX_MFT_MAX_CNT - count; | ||
296 | + } | ||
297 | + stopped = npcm7xx_mft_compare(count, tgt, cpcfg); | ||
298 | + if (stopped == -1) { | ||
299 | + if (count == -1) { | ||
300 | + /* Underflow */ | ||
301 | + state = NPCM7XX_CAPTURE_UNDERFLOW; | ||
302 | + } else { | ||
303 | + state = NPCM7XX_CAPTURE_SUCCEED; | ||
304 | + } | ||
305 | + } else { | ||
306 | + count = stopped; | ||
307 | + state = NPCM7XX_CAPTURE_COMPARE_HIT; | ||
308 | + } | ||
309 | + | ||
310 | + if (count != -1) { | ||
311 | + *cnt = count; | ||
312 | + } | ||
313 | + trace_npcm7xx_mft_rpm(clock->canonical_path, clock_get_hz(clock), | ||
314 | + state, count, rpm, duty); | ||
315 | + return state; | ||
316 | +} | ||
317 | + | ||
318 | +/* | ||
319 | + * Capture Fan RPM and update CNT and CR registers accordingly. | ||
320 | + * Raise IRQ if certain contidions are met in IEN. | ||
321 | + */ | ||
322 | +static void npcm7xx_mft_capture(NPCM7xxMFTState *s) | ||
323 | +{ | ||
324 | + int irq_level = 0; | ||
325 | + NPCM7xxMFTCaptureState state; | ||
326 | + int sel; | ||
327 | + uint8_t cpcfg; | ||
328 | + | ||
329 | + /* | ||
330 | + * If not mode 5, the behavior is undefined. We just do nothing in this | ||
331 | + * case. | ||
332 | + */ | ||
333 | + if (!(s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_MODE5)) { | ||
334 | + return; | ||
335 | + } | ||
336 | + | ||
337 | + /* Capture input A. */ | ||
338 | + if (s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_TAEN && | ||
339 | + s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C1CSEL) { | ||
340 | + sel = s->regs[R_NPCM7XX_MFT_INASEL] & NPCM7XX_MFT_INASEL_SELA; | ||
341 | + cpcfg = NPCM7XX_MFT_CPCFG_GET_A(s->regs[R_NPCM7XX_MFT_CPCFG]); | ||
342 | + state = npcm7xx_mft_compute_cnt(s->clock_1, | ||
343 | + sel ? s->max_rpm[2] : s->max_rpm[0], | ||
344 | + sel ? s->duty[2] : s->duty[0], | ||
345 | + s->regs[R_NPCM7XX_MFT_CPA], | ||
346 | + cpcfg, | ||
347 | + &s->regs[R_NPCM7XX_MFT_CNT1]); | ||
348 | + switch (state) { | ||
349 | + case NPCM7XX_CAPTURE_SUCCEED: | ||
350 | + /* Interrupt on input capture on TAn transition - TAPND */ | ||
351 | + s->regs[R_NPCM7XX_MFT_CRA] = s->regs[R_NPCM7XX_MFT_CNT1]; | ||
352 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TAPND; | ||
353 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TAIEN) { | ||
354 | + irq_level = 1; | ||
355 | + } | ||
356 | + break; | ||
357 | + | ||
358 | + case NPCM7XX_CAPTURE_COMPARE_HIT: | ||
359 | + /* Compare Hit - TEPND */ | ||
360 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TEPND; | ||
361 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TEIEN) { | ||
362 | + irq_level = 1; | ||
363 | + } | ||
364 | + break; | ||
365 | + | ||
366 | + case NPCM7XX_CAPTURE_UNDERFLOW: | ||
367 | + /* Underflow - TCPND */ | ||
368 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TCPND; | ||
369 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TCIEN) { | ||
370 | + irq_level = 1; | ||
371 | + } | ||
372 | + break; | ||
373 | + | ||
374 | + default: | ||
375 | + g_assert_not_reached(); | ||
376 | + } | ||
377 | + } | ||
378 | + | ||
379 | + /* Capture input B. */ | ||
380 | + if (s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_TBEN && | ||
381 | + s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C2CSEL) { | ||
382 | + sel = s->regs[R_NPCM7XX_MFT_INBSEL] & NPCM7XX_MFT_INBSEL_SELB; | ||
383 | + cpcfg = NPCM7XX_MFT_CPCFG_GET_B(s->regs[R_NPCM7XX_MFT_CPCFG]); | ||
384 | + state = npcm7xx_mft_compute_cnt(s->clock_2, | ||
385 | + sel ? s->max_rpm[3] : s->max_rpm[1], | ||
386 | + sel ? s->duty[3] : s->duty[1], | ||
387 | + s->regs[R_NPCM7XX_MFT_CPB], | ||
388 | + cpcfg, | ||
389 | + &s->regs[R_NPCM7XX_MFT_CNT2]); | ||
390 | + switch (state) { | ||
391 | + case NPCM7XX_CAPTURE_SUCCEED: | ||
392 | + /* Interrupt on input capture on TBn transition - TBPND */ | ||
393 | + s->regs[R_NPCM7XX_MFT_CRB] = s->regs[R_NPCM7XX_MFT_CNT2]; | ||
394 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TBPND; | ||
395 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TBIEN) { | ||
396 | + irq_level = 1; | ||
397 | + } | ||
398 | + break; | ||
399 | + | ||
400 | + case NPCM7XX_CAPTURE_COMPARE_HIT: | ||
401 | + /* Compare Hit - TFPND */ | ||
402 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TFPND; | ||
403 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TFIEN) { | ||
404 | + irq_level = 1; | ||
405 | + } | ||
406 | + break; | ||
407 | + | ||
408 | + case NPCM7XX_CAPTURE_UNDERFLOW: | ||
409 | + /* Underflow - TDPND */ | ||
410 | + s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TDPND; | ||
411 | + if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TDIEN) { | ||
412 | + irq_level = 1; | ||
413 | + } | ||
414 | + break; | ||
415 | + | ||
416 | + default: | ||
417 | + g_assert_not_reached(); | ||
418 | + } | ||
419 | + } | ||
420 | + | ||
421 | + trace_npcm7xx_mft_capture(DEVICE(s)->canonical_path, irq_level); | ||
422 | + qemu_set_irq(s->irq, irq_level); | ||
423 | +} | ||
424 | + | ||
425 | +/* Update clock for counters. */ | ||
426 | +static void npcm7xx_mft_update_clock(void *opaque, ClockEvent event) | ||
427 | +{ | ||
428 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
429 | + uint64_t prescaled_clock_period; | ||
430 | + | ||
431 | + prescaled_clock_period = clock_get(s->clock_in) * | ||
432 | + (s->regs[R_NPCM7XX_MFT_PRSC] + 1ULL); | ||
433 | + trace_npcm7xx_mft_update_clock(s->clock_in->canonical_path, | ||
434 | + s->regs[R_NPCM7XX_MFT_CKC], | ||
435 | + clock_get(s->clock_in), | ||
436 | + prescaled_clock_period); | ||
437 | + /* Update clock 1 */ | ||
438 | + if (s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C1CSEL) { | ||
439 | + /* Clock is prescaled. */ | ||
440 | + clock_update(s->clock_1, prescaled_clock_period); | ||
441 | + } else { | ||
442 | + /* Clock stopped. */ | ||
443 | + clock_update(s->clock_1, 0); | ||
444 | + } | ||
445 | + /* Update clock 2 */ | ||
446 | + if (s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C2CSEL) { | ||
447 | + /* Clock is prescaled. */ | ||
448 | + clock_update(s->clock_2, prescaled_clock_period); | ||
449 | + } else { | ||
450 | + /* Clock stopped. */ | ||
451 | + clock_update(s->clock_2, 0); | ||
452 | + } | ||
453 | + | ||
454 | + npcm7xx_mft_capture(s); | ||
455 | +} | ||
456 | + | ||
457 | +static uint64_t npcm7xx_mft_read(void *opaque, hwaddr offset, unsigned size) | ||
458 | +{ | ||
459 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
460 | + uint16_t value = 0; | ||
461 | + | ||
462 | + switch (offset) { | ||
463 | + case A_NPCM7XX_MFT_ICLR: | ||
464 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
465 | + "%s: register @ 0x%04" HWADDR_PRIx " is write-only\n", | ||
466 | + __func__, offset); | ||
467 | + break; | ||
468 | + | ||
469 | + default: | ||
470 | + value = s->regs[offset / 2]; | ||
471 | + } | ||
472 | + | ||
473 | + trace_npcm7xx_mft_read(DEVICE(s)->canonical_path, offset, value); | ||
474 | + return value; | ||
475 | +} | ||
476 | + | ||
477 | +static void npcm7xx_mft_write(void *opaque, hwaddr offset, | ||
478 | + uint64_t v, unsigned size) | ||
479 | +{ | ||
480 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
481 | + | ||
482 | + trace_npcm7xx_mft_write(DEVICE(s)->canonical_path, offset, v); | ||
483 | + switch (offset) { | ||
484 | + case A_NPCM7XX_MFT_ICLR: | ||
485 | + npcm7xx_mft_clear_interrupt(s, v); | ||
486 | + break; | ||
487 | + | ||
488 | + case A_NPCM7XX_MFT_CKC: | ||
489 | + case A_NPCM7XX_MFT_PRSC: | ||
490 | + s->regs[offset / 2] = v; | ||
491 | + npcm7xx_mft_update_clock(s, ClockUpdate); | ||
492 | + break; | ||
493 | + | ||
494 | + default: | ||
495 | + s->regs[offset / 2] = v; | ||
496 | + npcm7xx_mft_capture(s); | ||
497 | + break; | ||
498 | + } | ||
499 | +} | ||
500 | + | ||
501 | +static bool npcm7xx_mft_check_mem_op(void *opaque, hwaddr offset, | ||
502 | + unsigned size, bool is_write, | ||
503 | + MemTxAttrs attrs) | ||
504 | +{ | ||
505 | + switch (offset) { | ||
506 | + /* 16-bit registers. Must be accessed with 16-bit read/write.*/ | ||
507 | + case A_NPCM7XX_MFT_CNT1: | ||
508 | + case A_NPCM7XX_MFT_CRA: | ||
509 | + case A_NPCM7XX_MFT_CRB: | ||
510 | + case A_NPCM7XX_MFT_CNT2: | ||
511 | + case A_NPCM7XX_MFT_CPA: | ||
512 | + case A_NPCM7XX_MFT_CPB: | ||
513 | + return size == 2; | ||
514 | + | ||
515 | + /* 8-bit registers. Must be accessed with 8-bit read/write.*/ | ||
516 | + case A_NPCM7XX_MFT_PRSC: | ||
517 | + case A_NPCM7XX_MFT_CKC: | ||
518 | + case A_NPCM7XX_MFT_MCTRL: | ||
519 | + case A_NPCM7XX_MFT_ICTRL: | ||
520 | + case A_NPCM7XX_MFT_ICLR: | ||
521 | + case A_NPCM7XX_MFT_IEN: | ||
522 | + case A_NPCM7XX_MFT_CPCFG: | ||
523 | + case A_NPCM7XX_MFT_INASEL: | ||
524 | + case A_NPCM7XX_MFT_INBSEL: | ||
525 | + return size == 1; | ||
526 | + | ||
527 | + default: | ||
528 | + /* Invalid registers. */ | ||
529 | + return false; | ||
530 | + } | ||
531 | +} | ||
532 | + | ||
533 | +static void npcm7xx_mft_get_max_rpm(Object *obj, Visitor *v, const char *name, | ||
534 | + void *opaque, Error **errp) | ||
535 | +{ | ||
536 | + visit_type_uint32(v, name, (uint32_t *)opaque, errp); | ||
537 | +} | ||
538 | + | ||
539 | +static void npcm7xx_mft_set_max_rpm(Object *obj, Visitor *v, const char *name, | ||
540 | + void *opaque, Error **errp) | ||
541 | +{ | ||
542 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
543 | + uint32_t *max_rpm = opaque; | ||
544 | + uint32_t value; | ||
545 | + | ||
546 | + if (!visit_type_uint32(v, name, &value, errp)) { | ||
547 | + return; | ||
548 | + } | ||
549 | + | ||
550 | + *max_rpm = value; | ||
551 | + npcm7xx_mft_capture(s); | ||
552 | +} | ||
553 | + | ||
554 | +static void npcm7xx_mft_duty_handler(void *opaque, int n, int value) | ||
555 | +{ | ||
556 | + NPCM7xxMFTState *s = NPCM7XX_MFT(opaque); | ||
557 | + | ||
558 | + trace_npcm7xx_mft_set_duty(DEVICE(s)->canonical_path, n, value); | ||
559 | + s->duty[n] = value; | ||
560 | + npcm7xx_mft_capture(s); | ||
561 | +} | ||
562 | + | ||
563 | +static const struct MemoryRegionOps npcm7xx_mft_ops = { | ||
564 | + .read = npcm7xx_mft_read, | ||
565 | + .write = npcm7xx_mft_write, | ||
566 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
567 | + .valid = { | ||
568 | + .min_access_size = 1, | ||
569 | + .max_access_size = 2, | ||
570 | + .unaligned = false, | ||
571 | + .accepts = npcm7xx_mft_check_mem_op, | ||
572 | + }, | ||
573 | +}; | ||
574 | + | ||
575 | +static void npcm7xx_mft_enter_reset(Object *obj, ResetType type) | ||
576 | +{ | ||
577 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
578 | + | ||
579 | + npcm7xx_mft_reset(s); | ||
580 | +} | ||
581 | + | ||
582 | +static void npcm7xx_mft_hold_reset(Object *obj) | ||
583 | +{ | ||
584 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
585 | + | ||
586 | + qemu_irq_lower(s->irq); | ||
587 | +} | ||
588 | + | ||
589 | +static void npcm7xx_mft_init(Object *obj) | ||
590 | +{ | ||
591 | + NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
592 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
593 | + DeviceState *dev = DEVICE(obj); | ||
594 | + | ||
595 | + memory_region_init_io(&s->iomem, obj, &npcm7xx_mft_ops, s, | ||
596 | + TYPE_NPCM7XX_MFT, 4 * KiB); | ||
597 | + sysbus_init_mmio(sbd, &s->iomem); | ||
598 | + sysbus_init_irq(sbd, &s->irq); | ||
599 | + s->clock_in = qdev_init_clock_in(dev, "clock-in", npcm7xx_mft_update_clock, | ||
600 | + s, ClockUpdate); | ||
601 | + s->clock_1 = qdev_init_clock_out(dev, "clock1"); | ||
602 | + s->clock_2 = qdev_init_clock_out(dev, "clock2"); | ||
603 | + | ||
604 | + for (int i = 0; i < NPCM7XX_PWM_PER_MODULE; ++i) { | ||
605 | + object_property_add(obj, "max_rpm[*]", "uint32", | ||
606 | + npcm7xx_mft_get_max_rpm, | ||
607 | + npcm7xx_mft_set_max_rpm, | ||
608 | + NULL, &s->max_rpm[i]); | ||
609 | + } | ||
610 | + qdev_init_gpio_in_named(dev, npcm7xx_mft_duty_handler, "duty", | ||
611 | + NPCM7XX_MFT_FANIN_COUNT); | ||
612 | +} | ||
613 | + | ||
614 | +static const VMStateDescription vmstate_npcm7xx_mft = { | ||
615 | + .name = "npcm7xx-mft-module", | ||
616 | + .version_id = 0, | ||
617 | + .minimum_version_id = 0, | ||
618 | + .fields = (VMStateField[]) { | ||
619 | + VMSTATE_CLOCK(clock_in, NPCM7xxMFTState), | ||
620 | + VMSTATE_CLOCK(clock_1, NPCM7xxMFTState), | ||
621 | + VMSTATE_CLOCK(clock_2, NPCM7xxMFTState), | ||
622 | + VMSTATE_UINT16_ARRAY(regs, NPCM7xxMFTState, NPCM7XX_MFT_NR_REGS), | ||
623 | + VMSTATE_UINT32_ARRAY(max_rpm, NPCM7xxMFTState, NPCM7XX_MFT_FANIN_COUNT), | ||
624 | + VMSTATE_UINT32_ARRAY(duty, NPCM7xxMFTState, NPCM7XX_MFT_FANIN_COUNT), | ||
625 | + VMSTATE_END_OF_LIST(), | ||
626 | + }, | ||
627 | +}; | ||
628 | + | ||
629 | +static void npcm7xx_mft_class_init(ObjectClass *klass, void *data) | ||
630 | +{ | ||
631 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
632 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
633 | + | ||
634 | + dc->desc = "NPCM7xx MFT Controller"; | ||
635 | + dc->vmsd = &vmstate_npcm7xx_mft; | ||
636 | + rc->phases.enter = npcm7xx_mft_enter_reset; | ||
637 | + rc->phases.hold = npcm7xx_mft_hold_reset; | ||
638 | +} | ||
639 | + | ||
640 | +static const TypeInfo npcm7xx_mft_info = { | ||
641 | + .name = TYPE_NPCM7XX_MFT, | ||
642 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
643 | + .instance_size = sizeof(NPCM7xxMFTState), | ||
644 | + .class_init = npcm7xx_mft_class_init, | ||
645 | + .instance_init = npcm7xx_mft_init, | ||
646 | +}; | ||
647 | + | ||
648 | +static void npcm7xx_mft_register_type(void) | ||
649 | +{ | ||
650 | + type_register_static(&npcm7xx_mft_info); | ||
651 | +} | ||
652 | +type_init(npcm7xx_mft_register_type); | ||
653 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
21 | index XXXXXXX..XXXXXXX 100644 | 654 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/dma/xlnx-zdma.c | 655 | --- a/hw/misc/meson.build |
23 | +++ b/hw/dma/xlnx-zdma.c | 656 | +++ b/hw/misc/meson.build |
24 | @@ -XXX,XX +XXX,XX @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf) | 657 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mst_fpga.c')) |
25 | qemu_log_mask(LOG_GUEST_ERROR, | 658 | softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files( |
26 | "zdma: unaligned descriptor at %" PRIx64, | 659 | 'npcm7xx_clk.c', |
27 | addr); | 660 | 'npcm7xx_gcr.c', |
28 | - memset(buf, 0xdeadbeef, sizeof(XlnxZDMADescr)); | 661 | + 'npcm7xx_mft.c', |
29 | + memset(buf, 0x0, sizeof(XlnxZDMADescr)); | 662 | 'npcm7xx_pwm.c', |
30 | s->error = true; | 663 | 'npcm7xx_rng.c', |
31 | return false; | 664 | )) |
32 | } | 665 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events |
33 | @@ -XXX,XX +XXX,XX @@ static uint64_t zdma_read(void *opaque, hwaddr addr, unsigned size) | 666 | index XXXXXXX..XXXXXXX 100644 |
34 | RegisterInfo *r = &s->regs_info[addr / 4]; | 667 | --- a/hw/misc/trace-events |
35 | 668 | +++ b/hw/misc/trace-events | |
36 | if (!r->data) { | 669 | @@ -XXX,XX +XXX,XX @@ npcm7xx_clk_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " valu |
37 | + gchar *path = object_get_canonical_path(OBJECT(s)); | 670 | npcm7xx_gcr_read(uint64_t offset, uint32_t value) " offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 |
38 | qemu_log("%s: Decode error: read from %" HWADDR_PRIx "\n", | 671 | npcm7xx_gcr_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 |
39 | - object_get_canonical_path(OBJECT(s)), | 672 | |
40 | + path, | 673 | +# npcm7xx_mft.c |
41 | addr); | 674 | +npcm7xx_mft_read(const char *name, uint64_t offset, uint16_t value) "%s: offset: 0x%04" PRIx64 " value: 0x%04" PRIx16 |
42 | + g_free(path); | 675 | +npcm7xx_mft_write(const char *name, uint64_t offset, uint16_t value) "%s: offset: 0x%04" PRIx64 " value: 0x%04" PRIx16 |
43 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | 676 | +npcm7xx_mft_rpm(const char *clock, uint32_t clock_hz, int state, int32_t cnt, uint32_t rpm, uint32_t duty) " fan clk: %s clock_hz: %" PRIu32 ", state: %d, cnt: %" PRIi32 ", rpm: %" PRIu32 ", duty: %" PRIu32 |
44 | zdma_ch_imr_update_irq(s); | 677 | +npcm7xx_mft_capture(const char *name, int irq_level) "%s: level: %d" |
45 | return 0; | 678 | +npcm7xx_mft_update_clock(const char *name, uint16_t sel, uint64_t clock_period, uint64_t prescaled_clock_period) "%s: sel: 0x%02" PRIx16 ", period: %" PRIu64 ", prescaled: %" PRIu64 |
46 | @@ -XXX,XX +XXX,XX @@ static void zdma_write(void *opaque, hwaddr addr, uint64_t value, | 679 | +npcm7xx_mft_set_duty(const char *name, int n, int value) "%s[%d]: %d" |
47 | RegisterInfo *r = &s->regs_info[addr / 4]; | 680 | + |
48 | 681 | # npcm7xx_rng.c | |
49 | if (!r->data) { | 682 | npcm7xx_rng_read(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u" |
50 | + gchar *path = object_get_canonical_path(OBJECT(s)); | 683 | npcm7xx_rng_write(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u" |
51 | qemu_log("%s: Decode error: write to %" HWADDR_PRIx "=%" PRIx64 "\n", | ||
52 | - object_get_canonical_path(OBJECT(s)), | ||
53 | + path, | ||
54 | addr, value); | ||
55 | + g_free(path); | ||
56 | ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true); | ||
57 | zdma_ch_imr_update_irq(s); | ||
58 | return; | ||
59 | -- | 684 | -- |
60 | 2.17.1 | 685 | 2.20.1 |
61 | 686 | ||
62 | 687 | diff view generated by jsdifflib |
1 | From: Igor Mammedov <imammedo@redhat.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | When QEMU is started with following CLI | 3 | This patch adds the recently implemented MFT device to the NPCM7XX |
4 | -machine virt,gic-version=3,accel=kvm -cpu host -bios AAVMF_CODE.fd | 4 | SoC file. |
5 | it crashes with abort at | ||
6 | accel/kvm/kvm-all.c:2164: | ||
7 | KVM_SET_DEVICE_ATTR failed: Group 6 attr 0x000000000000c665: Invalid argument | ||
8 | 5 | ||
9 | Which is caused by implicit dependency of kvm_arm_gicv3_reset() on | 6 | Reviewed-by: Doug Evans <dje@google.com> |
10 | arm_gicv3_icc_reset() where the later is called by CPU reset | 7 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> |
11 | reset callback. | 8 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
12 | 9 | Message-id: 20210311180855.149764-4-wuhaotsh@google.com | |
13 | However commit: | ||
14 | 3b77f6c arm/boot: split load_dtb() from arm_load_kernel() | ||
15 | broke CPU reset callback registration in case | ||
16 | |||
17 | arm_load_kernel() | ||
18 | ... | ||
19 | if (!info->kernel_filename || info->firmware_loaded) | ||
20 | |||
21 | branch is taken, i.e. it's sufficient to provide a firmware | ||
22 | or do not provide kernel on CLI to skip cpu reset callback | ||
23 | registration, where before offending commit the callback | ||
24 | has been registered unconditionally. | ||
25 | |||
26 | Fix it by registering the callback right at the beginning of | ||
27 | arm_load_kernel() unconditionally instead of doing it at the end. | ||
28 | |||
29 | NOTE: | ||
30 | we probably should eliminate that dependency anyways as well as | ||
31 | separate arch CPU reset parts from arm_load_kernel() into CPU | ||
32 | itself, but that refactoring that I probably would have to do | ||
33 | anyways later for CPU hotplug to work. | ||
34 | |||
35 | Reported-by: Auger Eric <eric.auger@redhat.com> | ||
36 | Signed-off-by: Igor Mammedov <imammedo@redhat.com> | ||
37 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
38 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
39 | Message-id: 1527070950-208350-1-git-send-email-imammedo@redhat.com | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
42 | --- | 12 | --- |
43 | hw/arm/boot.c | 18 +++++++++--------- | 13 | docs/system/arm/nuvoton.rst | 2 +- |
44 | 1 file changed, 9 insertions(+), 9 deletions(-) | 14 | include/hw/arm/npcm7xx.h | 2 ++ |
15 | hw/arm/npcm7xx.c | 45 ++++++++++++++++++++++++++++++------- | ||
16 | 3 files changed, 40 insertions(+), 9 deletions(-) | ||
45 | 17 | ||
46 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 18 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
47 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/arm/boot.c | 20 | --- a/docs/system/arm/nuvoton.rst |
49 | +++ b/hw/arm/boot.c | 21 | +++ b/docs/system/arm/nuvoton.rst |
50 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | 22 | @@ -XXX,XX +XXX,XX @@ Supported devices |
51 | static const ARMInsnFixup *primary_loader; | 23 | * Pulse Width Modulation (PWM) |
52 | AddressSpace *as = arm_boot_address_space(cpu, info); | 24 | * SMBus controller (SMBF) |
53 | 25 | * Ethernet controller (EMC) | |
54 | + /* CPU objects (unlike devices) are not automatically reset on system | 26 | + * Tachometer |
55 | + * reset, so we must always register a handler to do so. If we're | 27 | |
56 | + * actually loading a kernel, the handler is also responsible for | 28 | Missing devices |
57 | + * arranging that we start it correctly. | 29 | --------------- |
58 | + */ | 30 | @@ -XXX,XX +XXX,XX @@ Missing devices |
59 | + for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | 31 | * Peripheral SPI controller (PSPI) |
60 | + qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | 32 | * SD/MMC host |
33 | * PECI interface | ||
34 | - * Tachometer | ||
35 | * PCI and PCIe root complex and bridges | ||
36 | * VDM and MCTP support | ||
37 | * Serial I/O expansion | ||
38 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/include/hw/arm/npcm7xx.h | ||
41 | +++ b/include/hw/arm/npcm7xx.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #include "hw/mem/npcm7xx_mc.h" | ||
44 | #include "hw/misc/npcm7xx_clk.h" | ||
45 | #include "hw/misc/npcm7xx_gcr.h" | ||
46 | +#include "hw/misc/npcm7xx_mft.h" | ||
47 | #include "hw/misc/npcm7xx_pwm.h" | ||
48 | #include "hw/misc/npcm7xx_rng.h" | ||
49 | #include "hw/net/npcm7xx_emc.h" | ||
50 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState { | ||
51 | NPCM7xxTimerCtrlState tim[3]; | ||
52 | NPCM7xxADCState adc; | ||
53 | NPCM7xxPWMState pwm[2]; | ||
54 | + NPCM7xxMFTState mft[8]; | ||
55 | NPCM7xxOTPState key_storage; | ||
56 | NPCM7xxOTPState fuse_array; | ||
57 | NPCM7xxMCState mc; | ||
58 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/hw/arm/npcm7xx.c | ||
61 | +++ b/hw/arm/npcm7xx.c | ||
62 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { | ||
63 | NPCM7XX_SMBUS15_IRQ, | ||
64 | NPCM7XX_PWM0_IRQ = 93, /* PWM module 0 */ | ||
65 | NPCM7XX_PWM1_IRQ, /* PWM module 1 */ | ||
66 | + NPCM7XX_MFT0_IRQ = 96, /* MFT module 0 */ | ||
67 | + NPCM7XX_MFT1_IRQ, /* MFT module 1 */ | ||
68 | + NPCM7XX_MFT2_IRQ, /* MFT module 2 */ | ||
69 | + NPCM7XX_MFT3_IRQ, /* MFT module 3 */ | ||
70 | + NPCM7XX_MFT4_IRQ, /* MFT module 4 */ | ||
71 | + NPCM7XX_MFT5_IRQ, /* MFT module 5 */ | ||
72 | + NPCM7XX_MFT6_IRQ, /* MFT module 6 */ | ||
73 | + NPCM7XX_MFT7_IRQ, /* MFT module 7 */ | ||
74 | NPCM7XX_EMC2RX_IRQ = 114, | ||
75 | NPCM7XX_EMC2TX_IRQ, | ||
76 | NPCM7XX_GPIO0_IRQ = 116, | ||
77 | @@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_pwm_addr[] = { | ||
78 | 0xf0104000, | ||
79 | }; | ||
80 | |||
81 | +/* Register base address for each MFT Module */ | ||
82 | +static const hwaddr npcm7xx_mft_addr[] = { | ||
83 | + 0xf0180000, | ||
84 | + 0xf0181000, | ||
85 | + 0xf0182000, | ||
86 | + 0xf0183000, | ||
87 | + 0xf0184000, | ||
88 | + 0xf0185000, | ||
89 | + 0xf0186000, | ||
90 | + 0xf0187000, | ||
91 | +}; | ||
92 | + | ||
93 | /* Direct memory-mapped access to each SMBus Module. */ | ||
94 | static const hwaddr npcm7xx_smbus_addr[] = { | ||
95 | 0xf0080000, | ||
96 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj) | ||
97 | object_initialize_child(obj, "pwm[*]", &s->pwm[i], TYPE_NPCM7XX_PWM); | ||
98 | } | ||
99 | |||
100 | + for (i = 0; i < ARRAY_SIZE(s->mft); i++) { | ||
101 | + object_initialize_child(obj, "mft[*]", &s->mft[i], TYPE_NPCM7XX_MFT); | ||
61 | + } | 102 | + } |
62 | + | 103 | + |
63 | /* The board code is not supposed to set secure_board_setup unless | 104 | for (i = 0; i < ARRAY_SIZE(s->emc); i++) { |
64 | * running its code in secure mode is actually possible, and KVM | 105 | object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC); |
65 | * doesn't support secure. | ||
66 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) | ||
67 | ARM_CPU(cs)->env.boot_info = info; | ||
68 | } | 106 | } |
69 | 107 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) | |
70 | - /* CPU objects (unlike devices) are not automatically reset on system | 108 | sysbus_connect_irq(sbd, i, npcm7xx_irq(s, NPCM7XX_PWM0_IRQ + i)); |
71 | - * reset, so we must always register a handler to do so. If we're | 109 | } |
72 | - * actually loading a kernel, the handler is also responsible for | 110 | |
73 | - * arranging that we start it correctly. | 111 | + /* MFT Modules. Cannot fail. */ |
74 | - */ | 112 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_mft_addr) != ARRAY_SIZE(s->mft)); |
75 | - for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | 113 | + for (i = 0; i < ARRAY_SIZE(s->mft); i++) { |
76 | - qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); | 114 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->mft[i]); |
77 | - } | 115 | + |
78 | - | 116 | + qdev_connect_clock_in(DEVICE(&s->mft[i]), "clock-in", |
79 | if (!info->skip_dtb_autoload && have_dtb(info)) { | 117 | + qdev_get_clock_out(DEVICE(&s->clk), |
80 | if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as) < 0) { | 118 | + "apb4-clock")); |
81 | exit(1); | 119 | + sysbus_realize(sbd, &error_abort); |
120 | + sysbus_mmio_map(sbd, 0, npcm7xx_mft_addr[i]); | ||
121 | + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, NPCM7XX_MFT0_IRQ + i)); | ||
122 | + } | ||
123 | + | ||
124 | /* | ||
125 | * EMC Modules. Cannot fail. | ||
126 | * The mapping of the device to its netdev backend works as follows: | ||
127 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) | ||
128 | create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB); | ||
129 | create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB); | ||
130 | create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB); | ||
131 | - create_unimplemented_device("npcm7xx.mft[0]", 0xf0180000, 4 * KiB); | ||
132 | - create_unimplemented_device("npcm7xx.mft[1]", 0xf0181000, 4 * KiB); | ||
133 | - create_unimplemented_device("npcm7xx.mft[2]", 0xf0182000, 4 * KiB); | ||
134 | - create_unimplemented_device("npcm7xx.mft[3]", 0xf0183000, 4 * KiB); | ||
135 | - create_unimplemented_device("npcm7xx.mft[4]", 0xf0184000, 4 * KiB); | ||
136 | - create_unimplemented_device("npcm7xx.mft[5]", 0xf0185000, 4 * KiB); | ||
137 | - create_unimplemented_device("npcm7xx.mft[6]", 0xf0186000, 4 * KiB); | ||
138 | - create_unimplemented_device("npcm7xx.mft[7]", 0xf0187000, 4 * KiB); | ||
139 | create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB); | ||
140 | create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB); | ||
141 | create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB); | ||
82 | -- | 142 | -- |
83 | 2.17.1 | 143 | 2.20.1 |
84 | 144 | ||
85 | 145 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Hao Wu <wuhaotsh@google.com> | |
2 | |||
3 | This patch adds fan_splitters (split IRQs) in NPCM7XX boards. Each fan | ||
4 | splitter corresponds to 1 PWM output and can connect to multiple fan | ||
5 | inputs (MFT devices). | ||
6 | In NPCM7XX boards(NPCM750 EVB and Quanta GSJ boards), we initializes | ||
7 | these splitters and connect them to their corresponding modules | ||
8 | according their specific device trees. | ||
9 | |||
10 | Reviewed-by: Doug Evans <dje@google.com> | ||
11 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
12 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Message-id: 20210311180855.149764-5-wuhaotsh@google.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | include/hw/arm/npcm7xx.h | 11 ++++- | ||
18 | hw/arm/npcm7xx_boards.c | 99 ++++++++++++++++++++++++++++++++++++++++ | ||
19 | 2 files changed, 109 insertions(+), 1 deletion(-) | ||
20 | |||
21 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/arm/npcm7xx.h | ||
24 | +++ b/include/hw/arm/npcm7xx.h | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | |||
27 | #include "hw/boards.h" | ||
28 | #include "hw/adc/npcm7xx_adc.h" | ||
29 | +#include "hw/core/split-irq.h" | ||
30 | #include "hw/cpu/a9mpcore.h" | ||
31 | #include "hw/gpio/npcm7xx_gpio.h" | ||
32 | #include "hw/i2c/npcm7xx_smbus.h" | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */ | ||
35 | #define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */ | ||
36 | |||
37 | +#define NPCM7XX_NR_PWM_MODULES 2 | ||
38 | + | ||
39 | typedef struct NPCM7xxMachine { | ||
40 | MachineState parent; | ||
41 | + /* | ||
42 | + * PWM fan splitter. each splitter connects to one PWM output and | ||
43 | + * multiple MFT inputs. | ||
44 | + */ | ||
45 | + SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES * | ||
46 | + NPCM7XX_PWM_PER_MODULE]; | ||
47 | } NPCM7xxMachine; | ||
48 | |||
49 | #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx") | ||
50 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState { | ||
51 | NPCM7xxCLKState clk; | ||
52 | NPCM7xxTimerCtrlState tim[3]; | ||
53 | NPCM7xxADCState adc; | ||
54 | - NPCM7xxPWMState pwm[2]; | ||
55 | + NPCM7xxPWMState pwm[NPCM7XX_NR_PWM_MODULES]; | ||
56 | NPCM7xxMFTState mft[8]; | ||
57 | NPCM7xxOTPState key_storage; | ||
58 | NPCM7xxOTPState fuse_array; | ||
59 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/hw/arm/npcm7xx_boards.c | ||
62 | +++ b/hw/arm/npcm7xx_boards.c | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | #include "hw/core/cpu.h" | ||
65 | #include "hw/i2c/smbus_eeprom.h" | ||
66 | #include "hw/loader.h" | ||
67 | +#include "hw/qdev-core.h" | ||
68 | #include "hw/qdev-properties.h" | ||
69 | #include "qapi/error.h" | ||
70 | #include "qemu-common.h" | ||
71 | @@ -XXX,XX +XXX,XX @@ static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr, | ||
72 | i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort); | ||
73 | } | ||
74 | |||
75 | +static void npcm7xx_init_pwm_splitter(NPCM7xxMachine *machine, | ||
76 | + NPCM7xxState *soc, const int *fan_counts) | ||
77 | +{ | ||
78 | + SplitIRQ *splitters = machine->fan_splitter; | ||
79 | + | ||
80 | + /* | ||
81 | + * PWM 0~3 belong to module 0 output 0~3. | ||
82 | + * PWM 4~7 belong to module 1 output 0~3. | ||
83 | + */ | ||
84 | + for (int i = 0; i < NPCM7XX_NR_PWM_MODULES; ++i) { | ||
85 | + for (int j = 0; j < NPCM7XX_PWM_PER_MODULE; ++j) { | ||
86 | + int splitter_no = i * NPCM7XX_PWM_PER_MODULE + j; | ||
87 | + DeviceState *splitter; | ||
88 | + | ||
89 | + if (fan_counts[splitter_no] < 1) { | ||
90 | + continue; | ||
91 | + } | ||
92 | + object_initialize_child(OBJECT(machine), "fan-splitter[*]", | ||
93 | + &splitters[splitter_no], TYPE_SPLIT_IRQ); | ||
94 | + splitter = DEVICE(&splitters[splitter_no]); | ||
95 | + qdev_prop_set_uint16(splitter, "num-lines", | ||
96 | + fan_counts[splitter_no]); | ||
97 | + qdev_realize(splitter, NULL, &error_abort); | ||
98 | + qdev_connect_gpio_out_named(DEVICE(&soc->pwm[i]), "duty-gpio-out", | ||
99 | + j, qdev_get_gpio_in(splitter, 0)); | ||
100 | + } | ||
101 | + } | ||
102 | +} | ||
103 | + | ||
104 | +static void npcm7xx_connect_pwm_fan(NPCM7xxState *soc, SplitIRQ *splitter, | ||
105 | + int fan_no, int output_no) | ||
106 | +{ | ||
107 | + DeviceState *fan; | ||
108 | + int fan_input; | ||
109 | + qemu_irq fan_duty_gpio; | ||
110 | + | ||
111 | + g_assert(fan_no >= 0 && fan_no <= NPCM7XX_MFT_MAX_FAN_INPUT); | ||
112 | + /* | ||
113 | + * Fan 0~1 belong to module 0 input 0~1. | ||
114 | + * Fan 2~3 belong to module 1 input 0~1. | ||
115 | + * ... | ||
116 | + * Fan 14~15 belong to module 7 input 0~1. | ||
117 | + * Fan 16~17 belong to module 0 input 2~3. | ||
118 | + * Fan 18~19 belong to module 1 input 2~3. | ||
119 | + */ | ||
120 | + if (fan_no < 16) { | ||
121 | + fan = DEVICE(&soc->mft[fan_no / 2]); | ||
122 | + fan_input = fan_no % 2; | ||
123 | + } else { | ||
124 | + fan = DEVICE(&soc->mft[(fan_no - 16) / 2]); | ||
125 | + fan_input = fan_no % 2 + 2; | ||
126 | + } | ||
127 | + | ||
128 | + /* Connect the Fan to PWM module */ | ||
129 | + fan_duty_gpio = qdev_get_gpio_in_named(fan, "duty", fan_input); | ||
130 | + qdev_connect_gpio_out(DEVICE(splitter), output_no, fan_duty_gpio); | ||
131 | +} | ||
132 | + | ||
133 | static void npcm750_evb_i2c_init(NPCM7xxState *soc) | ||
134 | { | ||
135 | /* lm75 temperature sensor on SVB, tmp105 is compatible */ | ||
136 | @@ -XXX,XX +XXX,XX @@ static void npcm750_evb_i2c_init(NPCM7xxState *soc) | ||
137 | i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48); | ||
138 | } | ||
139 | |||
140 | +static void npcm750_evb_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) | ||
141 | +{ | ||
142 | + SplitIRQ *splitter = machine->fan_splitter; | ||
143 | + static const int fan_counts[] = {2, 2, 2, 2, 2, 2, 2, 2}; | ||
144 | + | ||
145 | + npcm7xx_init_pwm_splitter(machine, soc, fan_counts); | ||
146 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x00, 0); | ||
147 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x01, 1); | ||
148 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x02, 0); | ||
149 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x03, 1); | ||
150 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x04, 0); | ||
151 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x05, 1); | ||
152 | + npcm7xx_connect_pwm_fan(soc, &splitter[3], 0x06, 0); | ||
153 | + npcm7xx_connect_pwm_fan(soc, &splitter[3], 0x07, 1); | ||
154 | + npcm7xx_connect_pwm_fan(soc, &splitter[4], 0x08, 0); | ||
155 | + npcm7xx_connect_pwm_fan(soc, &splitter[4], 0x09, 1); | ||
156 | + npcm7xx_connect_pwm_fan(soc, &splitter[5], 0x0a, 0); | ||
157 | + npcm7xx_connect_pwm_fan(soc, &splitter[5], 0x0b, 1); | ||
158 | + npcm7xx_connect_pwm_fan(soc, &splitter[6], 0x0c, 0); | ||
159 | + npcm7xx_connect_pwm_fan(soc, &splitter[6], 0x0d, 1); | ||
160 | + npcm7xx_connect_pwm_fan(soc, &splitter[7], 0x0e, 0); | ||
161 | + npcm7xx_connect_pwm_fan(soc, &splitter[7], 0x0f, 1); | ||
162 | +} | ||
163 | + | ||
164 | static void quanta_gsj_i2c_init(NPCM7xxState *soc) | ||
165 | { | ||
166 | /* GSJ machine have 4 max31725 temperature sensors, tmp105 is compatible. */ | ||
167 | @@ -XXX,XX +XXX,XX @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc) | ||
168 | /* TODO: Add additional i2c devices. */ | ||
169 | } | ||
170 | |||
171 | +static void quanta_gsj_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc) | ||
172 | +{ | ||
173 | + SplitIRQ *splitter = machine->fan_splitter; | ||
174 | + static const int fan_counts[] = {2, 2, 2, 0, 0, 0, 0, 0}; | ||
175 | + | ||
176 | + npcm7xx_init_pwm_splitter(machine, soc, fan_counts); | ||
177 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x00, 0); | ||
178 | + npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x01, 1); | ||
179 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x02, 0); | ||
180 | + npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x03, 1); | ||
181 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x04, 0); | ||
182 | + npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x05, 1); | ||
183 | +} | ||
184 | + | ||
185 | static void npcm750_evb_init(MachineState *machine) | ||
186 | { | ||
187 | NPCM7xxState *soc; | ||
188 | @@ -XXX,XX +XXX,XX @@ static void npcm750_evb_init(MachineState *machine) | ||
189 | npcm7xx_load_bootrom(machine, soc); | ||
190 | npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0)); | ||
191 | npcm750_evb_i2c_init(soc); | ||
192 | + npcm750_evb_fan_init(NPCM7XX_MACHINE(machine), soc); | ||
193 | npcm7xx_load_kernel(machine, soc); | ||
194 | } | ||
195 | |||
196 | @@ -XXX,XX +XXX,XX @@ static void quanta_gsj_init(MachineState *machine) | ||
197 | npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e", | ||
198 | drive_get(IF_MTD, 0, 0)); | ||
199 | quanta_gsj_i2c_init(soc); | ||
200 | + quanta_gsj_fan_init(NPCM7XX_MACHINE(machine), soc); | ||
201 | npcm7xx_load_kernel(machine, soc); | ||
202 | } | ||
203 | |||
204 | -- | ||
205 | 2.20.1 | ||
206 | |||
207 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Hao Wu <wuhaotsh@google.com> | |
2 | |||
3 | This patch adds testing of PWM fan RPMs in the existing npcm7xx pwm | ||
4 | test. It tests whether the MFT module can measure correct fan values | ||
5 | for a PWM fan in NPCM7XX boards. | ||
6 | |||
7 | Reviewed-by: Doug Evans <dje@google.com> | ||
8 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
9 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20210311180855.149764-6-wuhaotsh@google.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | tests/qtest/npcm7xx_pwm-test.c | 205 ++++++++++++++++++++++++++++++++- | ||
15 | 1 file changed, 199 insertions(+), 6 deletions(-) | ||
16 | |||
17 | diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/tests/qtest/npcm7xx_pwm-test.c | ||
20 | +++ b/tests/qtest/npcm7xx_pwm-test.c | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #define PLL_FBDV(rv) extract32((rv), 16, 12) | ||
23 | #define PLL_OTDV1(rv) extract32((rv), 8, 3) | ||
24 | #define PLL_OTDV2(rv) extract32((rv), 13, 3) | ||
25 | +#define APB4CKDIV(rv) extract32((rv), 30, 2) | ||
26 | #define APB3CKDIV(rv) extract32((rv), 28, 2) | ||
27 | #define CLK2CKDIV(rv) extract32((rv), 0, 1) | ||
28 | #define CLK4CKDIV(rv) extract32((rv), 26, 2) | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | |||
31 | #define MAX_DUTY 1000000 | ||
32 | |||
33 | +/* MFT (PWM fan) related */ | ||
34 | +#define MFT_BA(n) (0xf0180000 + ((n) * 0x1000)) | ||
35 | +#define MFT_IRQ(n) (96 + (n)) | ||
36 | +#define MFT_CNT1 0x00 | ||
37 | +#define MFT_CRA 0x02 | ||
38 | +#define MFT_CRB 0x04 | ||
39 | +#define MFT_CNT2 0x06 | ||
40 | +#define MFT_PRSC 0x08 | ||
41 | +#define MFT_CKC 0x0a | ||
42 | +#define MFT_MCTRL 0x0c | ||
43 | +#define MFT_ICTRL 0x0e | ||
44 | +#define MFT_ICLR 0x10 | ||
45 | +#define MFT_IEN 0x12 | ||
46 | +#define MFT_CPA 0x14 | ||
47 | +#define MFT_CPB 0x16 | ||
48 | +#define MFT_CPCFG 0x18 | ||
49 | +#define MFT_INASEL 0x1a | ||
50 | +#define MFT_INBSEL 0x1c | ||
51 | + | ||
52 | +#define MFT_MCTRL_ALL 0x64 | ||
53 | +#define MFT_ICLR_ALL 0x3f | ||
54 | +#define MFT_IEN_ALL 0x3f | ||
55 | +#define MFT_CPCFG_EQ_MODE 0x44 | ||
56 | + | ||
57 | +#define MFT_CKC_C2CSEL BIT(3) | ||
58 | +#define MFT_CKC_C1CSEL BIT(0) | ||
59 | + | ||
60 | +#define MFT_ICTRL_TFPND BIT(5) | ||
61 | +#define MFT_ICTRL_TEPND BIT(4) | ||
62 | +#define MFT_ICTRL_TDPND BIT(3) | ||
63 | +#define MFT_ICTRL_TCPND BIT(2) | ||
64 | +#define MFT_ICTRL_TBPND BIT(1) | ||
65 | +#define MFT_ICTRL_TAPND BIT(0) | ||
66 | + | ||
67 | +#define MFT_MAX_CNT 0xffff | ||
68 | +#define MFT_TIMEOUT 0x5000 | ||
69 | + | ||
70 | +#define DEFAULT_RPM 19800 | ||
71 | +#define DEFAULT_PRSC 255 | ||
72 | +#define MFT_PULSE_PER_REVOLUTION 2 | ||
73 | + | ||
74 | +#define MAX_ERROR 1 | ||
75 | + | ||
76 | typedef struct PWMModule { | ||
77 | int irq; | ||
78 | uint64_t base_addr; | ||
79 | @@ -XXX,XX +XXX,XX @@ static uint64_t pwm_get_duty(QTestState *qts, int module_index, int pwm_index) | ||
80 | return pwm_qom_get(qts, path, name); | ||
81 | } | ||
82 | |||
83 | +static void mft_qom_set(QTestState *qts, int index, const char *name, | ||
84 | + uint32_t value) | ||
85 | +{ | ||
86 | + QDict *response; | ||
87 | + char *path = g_strdup_printf("/machine/soc/mft[%d]", index); | ||
88 | + | ||
89 | + g_test_message("Setting properties %s of mft[%d] with value %u", | ||
90 | + name, index, value); | ||
91 | + response = qtest_qmp(qts, "{ 'execute': 'qom-set'," | ||
92 | + " 'arguments': { 'path': %s, " | ||
93 | + " 'property': %s, 'value': %u}}", | ||
94 | + path, name, value); | ||
95 | + /* The qom set message returns successfully. */ | ||
96 | + g_assert_true(qdict_haskey(response, "return")); | ||
97 | +} | ||
98 | + | ||
99 | static uint32_t get_pll(uint32_t con) | ||
100 | { | ||
101 | return REF_HZ * PLL_FBDV(con) / (PLL_INDV(con) * PLL_OTDV1(con) | ||
102 | * PLL_OTDV2(con)); | ||
103 | } | ||
104 | |||
105 | -static uint64_t read_pclk(QTestState *qts) | ||
106 | +static uint64_t read_pclk(QTestState *qts, bool mft) | ||
107 | { | ||
108 | uint64_t freq = REF_HZ; | ||
109 | uint32_t clksel = qtest_readl(qts, CLK_BA + CLKSEL); | ||
110 | uint32_t pllcon; | ||
111 | uint32_t clkdiv1 = qtest_readl(qts, CLK_BA + CLKDIV1); | ||
112 | uint32_t clkdiv2 = qtest_readl(qts, CLK_BA + CLKDIV2); | ||
113 | + uint32_t apbdiv = mft ? APB4CKDIV(clkdiv2) : APB3CKDIV(clkdiv2); | ||
114 | |||
115 | switch (CPUCKSEL(clksel)) { | ||
116 | case 0: | ||
117 | @@ -XXX,XX +XXX,XX @@ static uint64_t read_pclk(QTestState *qts) | ||
118 | g_assert_not_reached(); | ||
119 | } | ||
120 | |||
121 | - freq >>= (CLK2CKDIV(clkdiv1) + CLK4CKDIV(clkdiv1) + APB3CKDIV(clkdiv2)); | ||
122 | + freq >>= (CLK2CKDIV(clkdiv1) + CLK4CKDIV(clkdiv1) + apbdiv); | ||
123 | |||
124 | return freq; | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static uint32_t pwm_selector(uint32_t csr) | ||
127 | static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr, | ||
128 | uint32_t cnr) | ||
129 | { | ||
130 | - return read_pclk(qts) / ((ppr + 1) * pwm_selector(csr) * (cnr + 1)); | ||
131 | + return read_pclk(qts, false) / ((ppr + 1) * pwm_selector(csr) * (cnr + 1)); | ||
132 | } | ||
133 | |||
134 | static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted) | ||
135 | @@ -XXX,XX +XXX,XX @@ static void pwm_write(QTestState *qts, const TestData *td, unsigned offset, | ||
136 | qtest_writel(qts, td->module->base_addr + offset, value); | ||
137 | } | ||
138 | |||
139 | +static uint8_t mft_readb(QTestState *qts, int index, unsigned offset) | ||
140 | +{ | ||
141 | + return qtest_readb(qts, MFT_BA(index) + offset); | ||
142 | +} | ||
143 | + | ||
144 | +static uint16_t mft_readw(QTestState *qts, int index, unsigned offset) | ||
145 | +{ | ||
146 | + return qtest_readw(qts, MFT_BA(index) + offset); | ||
147 | +} | ||
148 | + | ||
149 | +static void mft_writeb(QTestState *qts, int index, unsigned offset, | ||
150 | + uint8_t value) | ||
151 | +{ | ||
152 | + qtest_writeb(qts, MFT_BA(index) + offset, value); | ||
153 | +} | ||
154 | + | ||
155 | +static void mft_writew(QTestState *qts, int index, unsigned offset, | ||
156 | + uint16_t value) | ||
157 | +{ | ||
158 | + return qtest_writew(qts, MFT_BA(index) + offset, value); | ||
159 | +} | ||
160 | + | ||
161 | static uint32_t pwm_read_ppr(QTestState *qts, const TestData *td) | ||
162 | { | ||
163 | return extract32(pwm_read(qts, td, PPR), ppr_base[pwm_index(td->pwm)], 8); | ||
164 | @@ -XXX,XX +XXX,XX @@ static void pwm_write_cmr(QTestState *qts, const TestData *td, uint32_t value) | ||
165 | pwm_write(qts, td, td->pwm->cmr_offset, value); | ||
166 | } | ||
167 | |||
168 | +static int mft_compute_index(const TestData *td) | ||
169 | +{ | ||
170 | + int index = pwm_module_index(td->module) * ARRAY_SIZE(pwm_list) + | ||
171 | + pwm_index(td->pwm); | ||
172 | + | ||
173 | + g_assert_cmpint(index, <, | ||
174 | + ARRAY_SIZE(pwm_module_list) * ARRAY_SIZE(pwm_list)); | ||
175 | + | ||
176 | + return index; | ||
177 | +} | ||
178 | + | ||
179 | +static void mft_reset_counters(QTestState *qts, int index) | ||
180 | +{ | ||
181 | + mft_writew(qts, index, MFT_CNT1, MFT_MAX_CNT); | ||
182 | + mft_writew(qts, index, MFT_CNT2, MFT_MAX_CNT); | ||
183 | + mft_writew(qts, index, MFT_CRA, MFT_MAX_CNT); | ||
184 | + mft_writew(qts, index, MFT_CRB, MFT_MAX_CNT); | ||
185 | + mft_writew(qts, index, MFT_CPA, MFT_MAX_CNT - MFT_TIMEOUT); | ||
186 | + mft_writew(qts, index, MFT_CPB, MFT_MAX_CNT - MFT_TIMEOUT); | ||
187 | +} | ||
188 | + | ||
189 | +static void mft_init(QTestState *qts, const TestData *td) | ||
190 | +{ | ||
191 | + int index = mft_compute_index(td); | ||
192 | + | ||
193 | + /* Enable everything */ | ||
194 | + mft_writeb(qts, index, MFT_CKC, 0); | ||
195 | + mft_writeb(qts, index, MFT_ICLR, MFT_ICLR_ALL); | ||
196 | + mft_writeb(qts, index, MFT_MCTRL, MFT_MCTRL_ALL); | ||
197 | + mft_writeb(qts, index, MFT_IEN, MFT_IEN_ALL); | ||
198 | + mft_writeb(qts, index, MFT_INASEL, 0); | ||
199 | + mft_writeb(qts, index, MFT_INBSEL, 0); | ||
200 | + | ||
201 | + /* Set cpcfg to use EQ mode, same as kernel driver */ | ||
202 | + mft_writeb(qts, index, MFT_CPCFG, MFT_CPCFG_EQ_MODE); | ||
203 | + | ||
204 | + /* Write default counters, timeout and prescaler */ | ||
205 | + mft_reset_counters(qts, index); | ||
206 | + mft_writeb(qts, index, MFT_PRSC, DEFAULT_PRSC); | ||
207 | + | ||
208 | + /* Write default max rpm via QMP */ | ||
209 | + mft_qom_set(qts, index, "max_rpm[0]", DEFAULT_RPM); | ||
210 | + mft_qom_set(qts, index, "max_rpm[1]", DEFAULT_RPM); | ||
211 | +} | ||
212 | + | ||
213 | +static int32_t mft_compute_cnt(uint32_t rpm, uint64_t clk) | ||
214 | +{ | ||
215 | + uint64_t cnt; | ||
216 | + | ||
217 | + if (rpm == 0) { | ||
218 | + return -1; | ||
219 | + } | ||
220 | + | ||
221 | + cnt = clk * 60 / ((DEFAULT_PRSC + 1) * rpm * MFT_PULSE_PER_REVOLUTION); | ||
222 | + if (cnt >= MFT_TIMEOUT) { | ||
223 | + return -1; | ||
224 | + } | ||
225 | + return MFT_MAX_CNT - cnt; | ||
226 | +} | ||
227 | + | ||
228 | +static void mft_verify_rpm(QTestState *qts, const TestData *td, uint64_t duty) | ||
229 | +{ | ||
230 | + int index = mft_compute_index(td); | ||
231 | + uint16_t cnt, cr; | ||
232 | + uint32_t rpm = DEFAULT_RPM * duty / MAX_DUTY; | ||
233 | + uint64_t clk = read_pclk(qts, true); | ||
234 | + int32_t expected_cnt = mft_compute_cnt(rpm, clk); | ||
235 | + | ||
236 | + qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); | ||
237 | + g_test_message( | ||
238 | + "verifying rpm for mft[%d]: clk: %lu, duty: %lu, rpm: %u, cnt: %d", | ||
239 | + index, clk, duty, rpm, expected_cnt); | ||
240 | + | ||
241 | + /* Verify rpm for fan A */ | ||
242 | + /* Stop capture */ | ||
243 | + mft_writeb(qts, index, MFT_CKC, 0); | ||
244 | + mft_writeb(qts, index, MFT_ICLR, MFT_ICLR_ALL); | ||
245 | + mft_reset_counters(qts, index); | ||
246 | + g_assert_cmphex(mft_readw(qts, index, MFT_CNT1), ==, MFT_MAX_CNT); | ||
247 | + g_assert_cmphex(mft_readw(qts, index, MFT_CRA), ==, MFT_MAX_CNT); | ||
248 | + g_assert_cmphex(mft_readw(qts, index, MFT_CPA), ==, | ||
249 | + MFT_MAX_CNT - MFT_TIMEOUT); | ||
250 | + /* Start capture */ | ||
251 | + mft_writeb(qts, index, MFT_CKC, MFT_CKC_C1CSEL); | ||
252 | + g_assert_true(qtest_get_irq(qts, MFT_IRQ(index))); | ||
253 | + if (expected_cnt == -1) { | ||
254 | + g_assert_cmphex(mft_readb(qts, index, MFT_ICTRL), ==, MFT_ICTRL_TEPND); | ||
255 | + } else { | ||
256 | + g_assert_cmphex(mft_readb(qts, index, MFT_ICTRL), ==, MFT_ICTRL_TAPND); | ||
257 | + cnt = mft_readw(qts, index, MFT_CNT1); | ||
258 | + /* | ||
259 | + * Due to error in clock measurement and rounding, we might have a small | ||
260 | + * error in measuring RPM. | ||
261 | + */ | ||
262 | + g_assert_cmphex(cnt + MAX_ERROR, >=, expected_cnt); | ||
263 | + g_assert_cmphex(cnt, <=, expected_cnt + MAX_ERROR); | ||
264 | + cr = mft_readw(qts, index, MFT_CRA); | ||
265 | + g_assert_cmphex(cnt, ==, cr); | ||
266 | + } | ||
267 | + | ||
268 | + /* Verify rpm for fan B */ | ||
269 | + | ||
270 | + qtest_irq_intercept_out(qts, "/machine/soc/a9mpcore/gic"); | ||
271 | +} | ||
272 | + | ||
273 | /* Check pwm registers can be reset to default value */ | ||
274 | static void test_init(gconstpointer test_data) | ||
275 | { | ||
276 | const TestData *td = test_data; | ||
277 | - QTestState *qts = qtest_init("-machine quanta-gsj"); | ||
278 | + QTestState *qts = qtest_init("-machine npcm750-evb"); | ||
279 | int module = pwm_module_index(td->module); | ||
280 | int pwm = pwm_index(td->pwm); | ||
281 | |||
282 | @@ -XXX,XX +XXX,XX @@ static void test_init(gconstpointer test_data) | ||
283 | static void test_oneshot(gconstpointer test_data) | ||
284 | { | ||
285 | const TestData *td = test_data; | ||
286 | - QTestState *qts = qtest_init("-machine quanta-gsj"); | ||
287 | + QTestState *qts = qtest_init("-machine npcm750-evb"); | ||
288 | int module = pwm_module_index(td->module); | ||
289 | int pwm = pwm_index(td->pwm); | ||
290 | uint32_t ppr, csr, pcr; | ||
291 | @@ -XXX,XX +XXX,XX @@ static void test_oneshot(gconstpointer test_data) | ||
292 | static void test_toggle(gconstpointer test_data) | ||
293 | { | ||
294 | const TestData *td = test_data; | ||
295 | - QTestState *qts = qtest_init("-machine quanta-gsj"); | ||
296 | + QTestState *qts = qtest_init("-machine npcm750-evb"); | ||
297 | int module = pwm_module_index(td->module); | ||
298 | int pwm = pwm_index(td->pwm); | ||
299 | uint32_t ppr, csr, pcr, cnr, cmr; | ||
300 | int i, j, k, l; | ||
301 | uint64_t expected_freq, expected_duty; | ||
302 | |||
303 | + mft_init(qts, td); | ||
304 | + | ||
305 | pcr = CH_EN | CH_MOD; | ||
306 | for (i = 0; i < ARRAY_SIZE(ppr_list); ++i) { | ||
307 | ppr = ppr_list[i]; | ||
308 | @@ -XXX,XX +XXX,XX @@ static void test_toggle(gconstpointer test_data) | ||
309 | ==, expected_freq); | ||
310 | } | ||
311 | |||
312 | + /* Test MFT's RPM is correct. */ | ||
313 | + mft_verify_rpm(qts, td, expected_duty); | ||
314 | + | ||
315 | /* Test inverted mode */ | ||
316 | expected_duty = pwm_compute_duty(cnr, cmr, true); | ||
317 | pwm_write_pcr(qts, td, pcr | CH_INV); | ||
318 | -- | ||
319 | 2.20.1 | ||
320 | |||
321 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | For a long time now the UI layer has guaranteed that the console |
---|---|---|---|
2 | add MemTxAttrs as an argument to flatview_translate(); all its | 2 | surface is always 32 bits per pixel. Remove the legacy dead |
3 | callers now have attrs available. | 3 | code from the pl110 display device which was handling the |
4 | possibility that the console surface was some other format. | ||
4 | 5 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 7 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20210211141515.8755-2-peter.maydell@linaro.org |
8 | Message-id: 20180521140402.23318-11-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | include/exec/memory.h | 7 ++++--- | 10 | hw/display/pl110.c | 53 +++++++--------------------------------------- |
11 | exec.c | 17 +++++++++-------- | 11 | 1 file changed, 8 insertions(+), 45 deletions(-) |
12 | 2 files changed, 13 insertions(+), 11 deletions(-) | ||
13 | 12 | ||
14 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 13 | diff --git a/hw/display/pl110.c b/hw/display/pl110.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/exec/memory.h | 15 | --- a/hw/display/pl110.c |
17 | +++ b/include/exec/memory.h | 16 | +++ b/hw/display/pl110.c |
18 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 17 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { |
19 | */ | 18 | pl111_id |
20 | MemoryRegion *flatview_translate(FlatView *fv, | 19 | }; |
21 | hwaddr addr, hwaddr *xlat, | 20 | |
22 | - hwaddr *len, bool is_write); | 21 | -#define BITS 8 |
23 | + hwaddr *len, bool is_write, | 22 | -#include "pl110_template.h" |
24 | + MemTxAttrs attrs); | 23 | -#define BITS 15 |
25 | 24 | -#include "pl110_template.h" | |
26 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | 25 | -#define BITS 16 |
27 | hwaddr addr, hwaddr *xlat, | 26 | -#include "pl110_template.h" |
28 | @@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as, | 27 | -#define BITS 24 |
29 | MemTxAttrs attrs) | 28 | -#include "pl110_template.h" |
30 | { | 29 | #define BITS 32 |
31 | return flatview_translate(address_space_to_flatview(as), | 30 | #include "pl110_template.h" |
32 | - addr, xlat, len, is_write); | 31 | |
33 | + addr, xlat, len, is_write, attrs); | 32 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) |
34 | } | 33 | PL110State *s = (PL110State *)opaque; |
35 | 34 | SysBusDevice *sbd; | |
36 | /* address_space_access_valid: check for validity of accessing an address | 35 | DisplaySurface *surface = qemu_console_surface(s->con); |
37 | @@ -XXX,XX +XXX,XX @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr, | 36 | - drawfn* fntable; |
38 | rcu_read_lock(); | 37 | drawfn fn; |
39 | fv = address_space_to_flatview(as); | 38 | - int dest_width; |
40 | l = len; | 39 | int src_width; |
41 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | 40 | int bpp_offset; |
42 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | 41 | int first; |
43 | if (len == l && memory_access_is_direct(mr, false)) { | 42 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) |
44 | ptr = qemu_map_ram_ptr(mr->ram_block, addr1); | 43 | |
45 | memcpy(buf, ptr, len); | 44 | sbd = SYS_BUS_DEVICE(s); |
46 | diff --git a/exec.c b/exec.c | 45 | |
47 | index XXXXXXX..XXXXXXX 100644 | 46 | - switch (surface_bits_per_pixel(surface)) { |
48 | --- a/exec.c | 47 | - case 0: |
49 | +++ b/exec.c | 48 | - return; |
50 | @@ -XXX,XX +XXX,XX @@ iotlb_fail: | 49 | - case 8: |
51 | 50 | - fntable = pl110_draw_fn_8; | |
52 | /* Called from RCU critical section */ | 51 | - dest_width = 1; |
53 | MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, | 52 | - break; |
54 | - hwaddr *plen, bool is_write) | 53 | - case 15: |
55 | + hwaddr *plen, bool is_write, | 54 | - fntable = pl110_draw_fn_15; |
56 | + MemTxAttrs attrs) | 55 | - dest_width = 2; |
57 | { | 56 | - break; |
58 | MemoryRegion *mr; | 57 | - case 16: |
59 | MemoryRegionSection section; | 58 | - fntable = pl110_draw_fn_16; |
60 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, | 59 | - dest_width = 2; |
60 | - break; | ||
61 | - case 24: | ||
62 | - fntable = pl110_draw_fn_24; | ||
63 | - dest_width = 3; | ||
64 | - break; | ||
65 | - case 32: | ||
66 | - fntable = pl110_draw_fn_32; | ||
67 | - dest_width = 4; | ||
68 | - break; | ||
69 | - default: | ||
70 | - fprintf(stderr, "pl110: Bad color depth\n"); | ||
71 | - exit(1); | ||
72 | - } | ||
73 | if (s->cr & PL110_CR_BGR) | ||
74 | bpp_offset = 0; | ||
75 | else | ||
76 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | ||
61 | } | 77 | } |
62 | |||
63 | l = len; | ||
64 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | ||
65 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | ||
66 | } | 78 | } |
67 | 79 | ||
68 | return result; | 80 | - if (s->cr & PL110_CR_BEBO) |
69 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, | 81 | - fn = fntable[s->bpp + 8 + bpp_offset]; |
70 | MemTxResult result = MEMTX_OK; | 82 | - else if (s->cr & PL110_CR_BEPO) |
71 | 83 | - fn = fntable[s->bpp + 16 + bpp_offset]; | |
72 | l = len; | 84 | - else |
73 | - mr = flatview_translate(fv, addr, &addr1, &l, true); | 85 | - fn = fntable[s->bpp + bpp_offset]; |
74 | + mr = flatview_translate(fv, addr, &addr1, &l, true, attrs); | 86 | + if (s->cr & PL110_CR_BEBO) { |
75 | result = flatview_write_continue(fv, addr, attrs, buf, len, | 87 | + fn = pl110_draw_fn_32[s->bpp + 8 + bpp_offset]; |
76 | addr1, l, mr); | 88 | + } else if (s->cr & PL110_CR_BEPO) { |
77 | 89 | + fn = pl110_draw_fn_32[s->bpp + 16 + bpp_offset]; | |
78 | @@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, | 90 | + } else { |
79 | } | 91 | + fn = pl110_draw_fn_32[s->bpp + bpp_offset]; |
80 | 92 | + } | |
81 | l = len; | 93 | |
82 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | 94 | src_width = s->cols; |
83 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | 95 | switch (s->bpp) { |
96 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | ||
97 | src_width <<= 2; | ||
98 | break; | ||
84 | } | 99 | } |
85 | 100 | - dest_width *= s->cols; | |
86 | return result; | 101 | first = 0; |
87 | @@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, | 102 | if (s->invalidate) { |
88 | MemoryRegion *mr; | 103 | framebuffer_update_memory_section(&s->fbsection, |
89 | 104 | @@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque) | |
90 | l = len; | 105 | |
91 | - mr = flatview_translate(fv, addr, &addr1, &l, false); | 106 | framebuffer_update_display(surface, &s->fbsection, |
92 | + mr = flatview_translate(fv, addr, &addr1, &l, false, attrs); | 107 | s->cols, s->rows, |
93 | return flatview_read_continue(fv, addr, attrs, buf, len, | 108 | - src_width, dest_width, 0, |
94 | addr1, l, mr); | 109 | + src_width, s->cols * 4, 0, |
95 | } | 110 | s->invalidate, |
96 | @@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, | 111 | fn, s->palette, |
97 | 112 | &first, &last); | |
98 | while (len > 0) { | ||
99 | l = len; | ||
100 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
101 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | ||
102 | if (!memory_access_is_direct(mr, is_write)) { | ||
103 | l = memory_access_size(mr, l, addr); | ||
104 | if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) { | ||
105 | @@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr, | ||
106 | |||
107 | len = target_len; | ||
108 | this_mr = flatview_translate(fv, addr, &xlat, | ||
109 | - &len, is_write); | ||
110 | + &len, is_write, attrs); | ||
111 | if (this_mr != mr || xlat != base + done) { | ||
112 | return done; | ||
113 | } | ||
114 | @@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as, | ||
115 | l = len; | ||
116 | rcu_read_lock(); | ||
117 | fv = address_space_to_flatview(as); | ||
118 | - mr = flatview_translate(fv, addr, &xlat, &l, is_write); | ||
119 | + mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs); | ||
120 | |||
121 | if (!memory_access_is_direct(mr, is_write)) { | ||
122 | if (atomic_xchg(&bounce.in_use, true)) { | ||
123 | -- | 113 | -- |
124 | 2.17.1 | 114 | 2.20.1 |
125 | 115 | ||
126 | 116 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | The pl110_template.h header has a doubly-nested multiple-include pattern: | |
2 | * pl110.c includes it once for each host bit depth (now always 32) | ||
3 | * every time it is included, it includes itself 6 times, to account | ||
4 | for multiple guest device pixel and byte orders | ||
5 | |||
6 | Now we only have to deal with 32-bit host bit depths, we can move the | ||
7 | code corresponding to the outer layer of this double-nesting to be | ||
8 | directly in pl110.c and reduce the template header to a single layer | ||
9 | of nesting. | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
13 | Message-id: 20210211141515.8755-3-peter.maydell@linaro.org | ||
14 | --- | ||
15 | hw/display/pl110_template.h | 100 +----------------------------------- | ||
16 | hw/display/pl110.c | 79 ++++++++++++++++++++++++++++ | ||
17 | 2 files changed, 80 insertions(+), 99 deletions(-) | ||
18 | |||
19 | diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/display/pl110_template.h | ||
22 | +++ b/hw/display/pl110_template.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | */ | ||
25 | |||
26 | #ifndef ORDER | ||
27 | - | ||
28 | -#if BITS == 8 | ||
29 | -#define COPY_PIXEL(to, from) *(to++) = from | ||
30 | -#elif BITS == 15 || BITS == 16 | ||
31 | -#define COPY_PIXEL(to, from) do { *(uint16_t *)to = from; to += 2; } while (0) | ||
32 | -#elif BITS == 24 | ||
33 | -#define COPY_PIXEL(to, from) \ | ||
34 | - do { \ | ||
35 | - *(to++) = from; \ | ||
36 | - *(to++) = (from) >> 8; \ | ||
37 | - *(to++) = (from) >> 16; \ | ||
38 | - } while (0) | ||
39 | -#elif BITS == 32 | ||
40 | -#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0) | ||
41 | -#else | ||
42 | -#error unknown bit depth | ||
43 | +#error "pl110_template.h is only for inclusion by pl110.c" | ||
44 | #endif | ||
45 | |||
46 | -#undef RGB | ||
47 | -#define BORDER bgr | ||
48 | -#define ORDER 0 | ||
49 | -#include "pl110_template.h" | ||
50 | -#define ORDER 1 | ||
51 | -#include "pl110_template.h" | ||
52 | -#define ORDER 2 | ||
53 | -#include "pl110_template.h" | ||
54 | -#undef BORDER | ||
55 | -#define RGB | ||
56 | -#define BORDER rgb | ||
57 | -#define ORDER 0 | ||
58 | -#include "pl110_template.h" | ||
59 | -#define ORDER 1 | ||
60 | -#include "pl110_template.h" | ||
61 | -#define ORDER 2 | ||
62 | -#include "pl110_template.h" | ||
63 | -#undef BORDER | ||
64 | - | ||
65 | -static drawfn glue(pl110_draw_fn_,BITS)[48] = | ||
66 | -{ | ||
67 | - glue(pl110_draw_line1_lblp_bgr,BITS), | ||
68 | - glue(pl110_draw_line2_lblp_bgr,BITS), | ||
69 | - glue(pl110_draw_line4_lblp_bgr,BITS), | ||
70 | - glue(pl110_draw_line8_lblp_bgr,BITS), | ||
71 | - glue(pl110_draw_line16_555_lblp_bgr,BITS), | ||
72 | - glue(pl110_draw_line32_lblp_bgr,BITS), | ||
73 | - glue(pl110_draw_line16_lblp_bgr,BITS), | ||
74 | - glue(pl110_draw_line12_lblp_bgr,BITS), | ||
75 | - | ||
76 | - glue(pl110_draw_line1_bbbp_bgr,BITS), | ||
77 | - glue(pl110_draw_line2_bbbp_bgr,BITS), | ||
78 | - glue(pl110_draw_line4_bbbp_bgr,BITS), | ||
79 | - glue(pl110_draw_line8_bbbp_bgr,BITS), | ||
80 | - glue(pl110_draw_line16_555_bbbp_bgr,BITS), | ||
81 | - glue(pl110_draw_line32_bbbp_bgr,BITS), | ||
82 | - glue(pl110_draw_line16_bbbp_bgr,BITS), | ||
83 | - glue(pl110_draw_line12_bbbp_bgr,BITS), | ||
84 | - | ||
85 | - glue(pl110_draw_line1_lbbp_bgr,BITS), | ||
86 | - glue(pl110_draw_line2_lbbp_bgr,BITS), | ||
87 | - glue(pl110_draw_line4_lbbp_bgr,BITS), | ||
88 | - glue(pl110_draw_line8_lbbp_bgr,BITS), | ||
89 | - glue(pl110_draw_line16_555_lbbp_bgr,BITS), | ||
90 | - glue(pl110_draw_line32_lbbp_bgr,BITS), | ||
91 | - glue(pl110_draw_line16_lbbp_bgr,BITS), | ||
92 | - glue(pl110_draw_line12_lbbp_bgr,BITS), | ||
93 | - | ||
94 | - glue(pl110_draw_line1_lblp_rgb,BITS), | ||
95 | - glue(pl110_draw_line2_lblp_rgb,BITS), | ||
96 | - glue(pl110_draw_line4_lblp_rgb,BITS), | ||
97 | - glue(pl110_draw_line8_lblp_rgb,BITS), | ||
98 | - glue(pl110_draw_line16_555_lblp_rgb,BITS), | ||
99 | - glue(pl110_draw_line32_lblp_rgb,BITS), | ||
100 | - glue(pl110_draw_line16_lblp_rgb,BITS), | ||
101 | - glue(pl110_draw_line12_lblp_rgb,BITS), | ||
102 | - | ||
103 | - glue(pl110_draw_line1_bbbp_rgb,BITS), | ||
104 | - glue(pl110_draw_line2_bbbp_rgb,BITS), | ||
105 | - glue(pl110_draw_line4_bbbp_rgb,BITS), | ||
106 | - glue(pl110_draw_line8_bbbp_rgb,BITS), | ||
107 | - glue(pl110_draw_line16_555_bbbp_rgb,BITS), | ||
108 | - glue(pl110_draw_line32_bbbp_rgb,BITS), | ||
109 | - glue(pl110_draw_line16_bbbp_rgb,BITS), | ||
110 | - glue(pl110_draw_line12_bbbp_rgb,BITS), | ||
111 | - | ||
112 | - glue(pl110_draw_line1_lbbp_rgb,BITS), | ||
113 | - glue(pl110_draw_line2_lbbp_rgb,BITS), | ||
114 | - glue(pl110_draw_line4_lbbp_rgb,BITS), | ||
115 | - glue(pl110_draw_line8_lbbp_rgb,BITS), | ||
116 | - glue(pl110_draw_line16_555_lbbp_rgb,BITS), | ||
117 | - glue(pl110_draw_line32_lbbp_rgb,BITS), | ||
118 | - glue(pl110_draw_line16_lbbp_rgb,BITS), | ||
119 | - glue(pl110_draw_line12_lbbp_rgb,BITS), | ||
120 | -}; | ||
121 | - | ||
122 | -#undef BITS | ||
123 | -#undef COPY_PIXEL | ||
124 | - | ||
125 | -#else | ||
126 | - | ||
127 | #if ORDER == 0 | ||
128 | #define NAME glue(glue(lblp_, BORDER), BITS) | ||
129 | #ifdef HOST_WORDS_BIGENDIAN | ||
130 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line12_,NAME)(void *opaque, uint8_t *d, const uint8_ | ||
131 | #undef NAME | ||
132 | #undef SWAP_WORDS | ||
133 | #undef ORDER | ||
134 | - | ||
135 | -#endif | ||
136 | diff --git a/hw/display/pl110.c b/hw/display/pl110.c | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/hw/display/pl110.c | ||
139 | +++ b/hw/display/pl110.c | ||
140 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { | ||
141 | }; | ||
142 | |||
143 | #define BITS 32 | ||
144 | +#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0) | ||
145 | + | ||
146 | +#undef RGB | ||
147 | +#define BORDER bgr | ||
148 | +#define ORDER 0 | ||
149 | #include "pl110_template.h" | ||
150 | +#define ORDER 1 | ||
151 | +#include "pl110_template.h" | ||
152 | +#define ORDER 2 | ||
153 | +#include "pl110_template.h" | ||
154 | +#undef BORDER | ||
155 | +#define RGB | ||
156 | +#define BORDER rgb | ||
157 | +#define ORDER 0 | ||
158 | +#include "pl110_template.h" | ||
159 | +#define ORDER 1 | ||
160 | +#include "pl110_template.h" | ||
161 | +#define ORDER 2 | ||
162 | +#include "pl110_template.h" | ||
163 | +#undef BORDER | ||
164 | + | ||
165 | +static drawfn pl110_draw_fn_32[48] = { | ||
166 | + pl110_draw_line1_lblp_bgr32, | ||
167 | + pl110_draw_line2_lblp_bgr32, | ||
168 | + pl110_draw_line4_lblp_bgr32, | ||
169 | + pl110_draw_line8_lblp_bgr32, | ||
170 | + pl110_draw_line16_555_lblp_bgr32, | ||
171 | + pl110_draw_line32_lblp_bgr32, | ||
172 | + pl110_draw_line16_lblp_bgr32, | ||
173 | + pl110_draw_line12_lblp_bgr32, | ||
174 | + | ||
175 | + pl110_draw_line1_bbbp_bgr32, | ||
176 | + pl110_draw_line2_bbbp_bgr32, | ||
177 | + pl110_draw_line4_bbbp_bgr32, | ||
178 | + pl110_draw_line8_bbbp_bgr32, | ||
179 | + pl110_draw_line16_555_bbbp_bgr32, | ||
180 | + pl110_draw_line32_bbbp_bgr32, | ||
181 | + pl110_draw_line16_bbbp_bgr32, | ||
182 | + pl110_draw_line12_bbbp_bgr32, | ||
183 | + | ||
184 | + pl110_draw_line1_lbbp_bgr32, | ||
185 | + pl110_draw_line2_lbbp_bgr32, | ||
186 | + pl110_draw_line4_lbbp_bgr32, | ||
187 | + pl110_draw_line8_lbbp_bgr32, | ||
188 | + pl110_draw_line16_555_lbbp_bgr32, | ||
189 | + pl110_draw_line32_lbbp_bgr32, | ||
190 | + pl110_draw_line16_lbbp_bgr32, | ||
191 | + pl110_draw_line12_lbbp_bgr32, | ||
192 | + | ||
193 | + pl110_draw_line1_lblp_rgb32, | ||
194 | + pl110_draw_line2_lblp_rgb32, | ||
195 | + pl110_draw_line4_lblp_rgb32, | ||
196 | + pl110_draw_line8_lblp_rgb32, | ||
197 | + pl110_draw_line16_555_lblp_rgb32, | ||
198 | + pl110_draw_line32_lblp_rgb32, | ||
199 | + pl110_draw_line16_lblp_rgb32, | ||
200 | + pl110_draw_line12_lblp_rgb32, | ||
201 | + | ||
202 | + pl110_draw_line1_bbbp_rgb32, | ||
203 | + pl110_draw_line2_bbbp_rgb32, | ||
204 | + pl110_draw_line4_bbbp_rgb32, | ||
205 | + pl110_draw_line8_bbbp_rgb32, | ||
206 | + pl110_draw_line16_555_bbbp_rgb32, | ||
207 | + pl110_draw_line32_bbbp_rgb32, | ||
208 | + pl110_draw_line16_bbbp_rgb32, | ||
209 | + pl110_draw_line12_bbbp_rgb32, | ||
210 | + | ||
211 | + pl110_draw_line1_lbbp_rgb32, | ||
212 | + pl110_draw_line2_lbbp_rgb32, | ||
213 | + pl110_draw_line4_lbbp_rgb32, | ||
214 | + pl110_draw_line8_lbbp_rgb32, | ||
215 | + pl110_draw_line16_555_lbbp_rgb32, | ||
216 | + pl110_draw_line32_lbbp_rgb32, | ||
217 | + pl110_draw_line16_lbbp_rgb32, | ||
218 | + pl110_draw_line12_lbbp_rgb32, | ||
219 | +}; | ||
220 | + | ||
221 | +#undef BITS | ||
222 | +#undef COPY_PIXEL | ||
223 | + | ||
224 | |||
225 | static int pl110_enabled(PL110State *s) | ||
226 | { | ||
227 | -- | ||
228 | 2.20.1 | ||
229 | |||
230 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | BITS is always 32, so remove all uses of it from the template header, | |
2 | by dropping the trailing '32' from the draw function names and | ||
3 | not constructing the name of rgb_to_pixel32() via the glue() macro. | ||
4 | |||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
7 | Message-id: 20210211141515.8755-4-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/display/pl110_template.h | 20 +++---- | ||
10 | hw/display/pl110.c | 113 ++++++++++++++++++------------------ | ||
11 | 2 files changed, 65 insertions(+), 68 deletions(-) | ||
12 | |||
13 | diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/display/pl110_template.h | ||
16 | +++ b/hw/display/pl110_template.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | #endif | ||
19 | |||
20 | #if ORDER == 0 | ||
21 | -#define NAME glue(glue(lblp_, BORDER), BITS) | ||
22 | +#define NAME glue(lblp_, BORDER) | ||
23 | #ifdef HOST_WORDS_BIGENDIAN | ||
24 | #define SWAP_WORDS 1 | ||
25 | #endif | ||
26 | #elif ORDER == 1 | ||
27 | -#define NAME glue(glue(bbbp_, BORDER), BITS) | ||
28 | +#define NAME glue(bbbp_, BORDER) | ||
29 | #ifndef HOST_WORDS_BIGENDIAN | ||
30 | #define SWAP_WORDS 1 | ||
31 | #endif | ||
32 | #else | ||
33 | #define SWAP_PIXELS 1 | ||
34 | -#define NAME glue(glue(lbbp_, BORDER), BITS) | ||
35 | +#define NAME glue(lbbp_, BORDER) | ||
36 | #ifdef HOST_WORDS_BIGENDIAN | ||
37 | #define SWAP_WORDS 1 | ||
38 | #endif | ||
39 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line16_,NAME)(void *opaque, uint8_t *d, const uint8_ | ||
40 | MSB = (data & 0x1f) << 3; | ||
41 | data >>= 5; | ||
42 | #endif | ||
43 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
44 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
45 | LSB = (data & 0x1f) << 3; | ||
46 | data >>= 5; | ||
47 | g = (data & 0x3f) << 2; | ||
48 | data >>= 6; | ||
49 | MSB = (data & 0x1f) << 3; | ||
50 | data >>= 5; | ||
51 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
52 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
53 | #undef MSB | ||
54 | #undef LSB | ||
55 | width -= 2; | ||
56 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line32_,NAME)(void *opaque, uint8_t *d, const uint8_ | ||
57 | g = (data >> 16) & 0xff; | ||
58 | MSB = (data >> 8) & 0xff; | ||
59 | #endif | ||
60 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
61 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
62 | #undef MSB | ||
63 | #undef LSB | ||
64 | width--; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line16_555_,NAME)(void *opaque, uint8_t *d, const ui | ||
66 | data >>= 5; | ||
67 | MSB = (data & 0x1f) << 3; | ||
68 | data >>= 5; | ||
69 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
70 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
71 | LSB = (data & 0x1f) << 3; | ||
72 | data >>= 5; | ||
73 | g = (data & 0x1f) << 3; | ||
74 | data >>= 5; | ||
75 | MSB = (data & 0x1f) << 3; | ||
76 | data >>= 6; | ||
77 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
78 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
79 | #undef MSB | ||
80 | #undef LSB | ||
81 | width -= 2; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line12_,NAME)(void *opaque, uint8_t *d, const uint8_ | ||
83 | data >>= 4; | ||
84 | MSB = (data & 0xf) << 4; | ||
85 | data >>= 8; | ||
86 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
87 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
88 | LSB = (data & 0xf) << 4; | ||
89 | data >>= 4; | ||
90 | g = (data & 0xf) << 4; | ||
91 | data >>= 4; | ||
92 | MSB = (data & 0xf) << 4; | ||
93 | data >>= 8; | ||
94 | - COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); | ||
95 | + COPY_PIXEL(d, rgb_to_pixel32(r, g, b)); | ||
96 | #undef MSB | ||
97 | #undef LSB | ||
98 | width -= 2; | ||
99 | diff --git a/hw/display/pl110.c b/hw/display/pl110.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/hw/display/pl110.c | ||
102 | +++ b/hw/display/pl110.c | ||
103 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { | ||
104 | pl111_id | ||
105 | }; | ||
106 | |||
107 | -#define BITS 32 | ||
108 | #define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0) | ||
109 | |||
110 | #undef RGB | ||
111 | @@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = { | ||
112 | #include "pl110_template.h" | ||
113 | #undef BORDER | ||
114 | |||
115 | -static drawfn pl110_draw_fn_32[48] = { | ||
116 | - pl110_draw_line1_lblp_bgr32, | ||
117 | - pl110_draw_line2_lblp_bgr32, | ||
118 | - pl110_draw_line4_lblp_bgr32, | ||
119 | - pl110_draw_line8_lblp_bgr32, | ||
120 | - pl110_draw_line16_555_lblp_bgr32, | ||
121 | - pl110_draw_line32_lblp_bgr32, | ||
122 | - pl110_draw_line16_lblp_bgr32, | ||
123 | - pl110_draw_line12_lblp_bgr32, | ||
124 | - | ||
125 | - pl110_draw_line1_bbbp_bgr32, | ||
126 | - pl110_draw_line2_bbbp_bgr32, | ||
127 | - pl110_draw_line4_bbbp_bgr32, | ||
128 | - pl110_draw_line8_bbbp_bgr32, | ||
129 | - pl110_draw_line16_555_bbbp_bgr32, | ||
130 | - pl110_draw_line32_bbbp_bgr32, | ||
131 | - pl110_draw_line16_bbbp_bgr32, | ||
132 | - pl110_draw_line12_bbbp_bgr32, | ||
133 | - | ||
134 | - pl110_draw_line1_lbbp_bgr32, | ||
135 | - pl110_draw_line2_lbbp_bgr32, | ||
136 | - pl110_draw_line4_lbbp_bgr32, | ||
137 | - pl110_draw_line8_lbbp_bgr32, | ||
138 | - pl110_draw_line16_555_lbbp_bgr32, | ||
139 | - pl110_draw_line32_lbbp_bgr32, | ||
140 | - pl110_draw_line16_lbbp_bgr32, | ||
141 | - pl110_draw_line12_lbbp_bgr32, | ||
142 | - | ||
143 | - pl110_draw_line1_lblp_rgb32, | ||
144 | - pl110_draw_line2_lblp_rgb32, | ||
145 | - pl110_draw_line4_lblp_rgb32, | ||
146 | - pl110_draw_line8_lblp_rgb32, | ||
147 | - pl110_draw_line16_555_lblp_rgb32, | ||
148 | - pl110_draw_line32_lblp_rgb32, | ||
149 | - pl110_draw_line16_lblp_rgb32, | ||
150 | - pl110_draw_line12_lblp_rgb32, | ||
151 | - | ||
152 | - pl110_draw_line1_bbbp_rgb32, | ||
153 | - pl110_draw_line2_bbbp_rgb32, | ||
154 | - pl110_draw_line4_bbbp_rgb32, | ||
155 | - pl110_draw_line8_bbbp_rgb32, | ||
156 | - pl110_draw_line16_555_bbbp_rgb32, | ||
157 | - pl110_draw_line32_bbbp_rgb32, | ||
158 | - pl110_draw_line16_bbbp_rgb32, | ||
159 | - pl110_draw_line12_bbbp_rgb32, | ||
160 | - | ||
161 | - pl110_draw_line1_lbbp_rgb32, | ||
162 | - pl110_draw_line2_lbbp_rgb32, | ||
163 | - pl110_draw_line4_lbbp_rgb32, | ||
164 | - pl110_draw_line8_lbbp_rgb32, | ||
165 | - pl110_draw_line16_555_lbbp_rgb32, | ||
166 | - pl110_draw_line32_lbbp_rgb32, | ||
167 | - pl110_draw_line16_lbbp_rgb32, | ||
168 | - pl110_draw_line12_lbbp_rgb32, | ||
169 | -}; | ||
170 | - | ||
171 | -#undef BITS | ||
172 | #undef COPY_PIXEL | ||
173 | |||
174 | +static drawfn pl110_draw_fn_32[48] = { | ||
175 | + pl110_draw_line1_lblp_bgr, | ||
176 | + pl110_draw_line2_lblp_bgr, | ||
177 | + pl110_draw_line4_lblp_bgr, | ||
178 | + pl110_draw_line8_lblp_bgr, | ||
179 | + pl110_draw_line16_555_lblp_bgr, | ||
180 | + pl110_draw_line32_lblp_bgr, | ||
181 | + pl110_draw_line16_lblp_bgr, | ||
182 | + pl110_draw_line12_lblp_bgr, | ||
183 | + | ||
184 | + pl110_draw_line1_bbbp_bgr, | ||
185 | + pl110_draw_line2_bbbp_bgr, | ||
186 | + pl110_draw_line4_bbbp_bgr, | ||
187 | + pl110_draw_line8_bbbp_bgr, | ||
188 | + pl110_draw_line16_555_bbbp_bgr, | ||
189 | + pl110_draw_line32_bbbp_bgr, | ||
190 | + pl110_draw_line16_bbbp_bgr, | ||
191 | + pl110_draw_line12_bbbp_bgr, | ||
192 | + | ||
193 | + pl110_draw_line1_lbbp_bgr, | ||
194 | + pl110_draw_line2_lbbp_bgr, | ||
195 | + pl110_draw_line4_lbbp_bgr, | ||
196 | + pl110_draw_line8_lbbp_bgr, | ||
197 | + pl110_draw_line16_555_lbbp_bgr, | ||
198 | + pl110_draw_line32_lbbp_bgr, | ||
199 | + pl110_draw_line16_lbbp_bgr, | ||
200 | + pl110_draw_line12_lbbp_bgr, | ||
201 | + | ||
202 | + pl110_draw_line1_lblp_rgb, | ||
203 | + pl110_draw_line2_lblp_rgb, | ||
204 | + pl110_draw_line4_lblp_rgb, | ||
205 | + pl110_draw_line8_lblp_rgb, | ||
206 | + pl110_draw_line16_555_lblp_rgb, | ||
207 | + pl110_draw_line32_lblp_rgb, | ||
208 | + pl110_draw_line16_lblp_rgb, | ||
209 | + pl110_draw_line12_lblp_rgb, | ||
210 | + | ||
211 | + pl110_draw_line1_bbbp_rgb, | ||
212 | + pl110_draw_line2_bbbp_rgb, | ||
213 | + pl110_draw_line4_bbbp_rgb, | ||
214 | + pl110_draw_line8_bbbp_rgb, | ||
215 | + pl110_draw_line16_555_bbbp_rgb, | ||
216 | + pl110_draw_line32_bbbp_rgb, | ||
217 | + pl110_draw_line16_bbbp_rgb, | ||
218 | + pl110_draw_line12_bbbp_rgb, | ||
219 | + | ||
220 | + pl110_draw_line1_lbbp_rgb, | ||
221 | + pl110_draw_line2_lbbp_rgb, | ||
222 | + pl110_draw_line4_lbbp_rgb, | ||
223 | + pl110_draw_line8_lbbp_rgb, | ||
224 | + pl110_draw_line16_555_lbbp_rgb, | ||
225 | + pl110_draw_line32_lbbp_rgb, | ||
226 | + pl110_draw_line16_lbbp_rgb, | ||
227 | + pl110_draw_line12_lbbp_rgb, | ||
228 | +}; | ||
229 | |||
230 | static int pl110_enabled(PL110State *s) | ||
231 | { | ||
232 | -- | ||
233 | 2.20.1 | ||
234 | |||
235 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | For a long time now the UI layer has guaranteed that the console |
---|---|---|---|
2 | add MemTxAttrs as an argument to tb_invalidate_phys_addr(). | 2 | surface is always 32 bits per pixel. Remove the legacy dead code |
3 | Its callers either have an attrs value to hand, or don't care | 3 | from the pxa2xx_lcd display device which was handling the possibility |
4 | and can use MEMTXATTRS_UNSPECIFIED. | 4 | that the console surface was some other format. |
5 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> |
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Message-id: 20210211141515.8755-5-peter.maydell@linaro.org |
9 | Message-id: 20180521140402.23318-3-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | include/exec/exec-all.h | 5 +++-- | 10 | hw/display/pxa2xx_lcd.c | 79 +++++++++-------------------------------- |
12 | accel/tcg/translate-all.c | 2 +- | 11 | 1 file changed, 17 insertions(+), 62 deletions(-) |
13 | exec.c | 2 +- | ||
14 | target/xtensa/op_helper.c | 3 ++- | ||
15 | 4 files changed, 7 insertions(+), 5 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | 13 | diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/exec/exec-all.h | 15 | --- a/hw/display/pxa2xx_lcd.c |
20 | +++ b/include/exec/exec-all.h | 16 | +++ b/hw/display/pxa2xx_lcd.c |
21 | @@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, | 17 | @@ -XXX,XX +XXX,XX @@ struct PXA2xxLCDState { |
22 | void tlb_set_page(CPUState *cpu, target_ulong vaddr, | 18 | |
23 | hwaddr paddr, int prot, | 19 | int invalidated; |
24 | int mmu_idx, target_ulong size); | 20 | QemuConsole *con; |
25 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr); | 21 | - drawfn *line_fn[2]; |
26 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs); | 22 | int dest_width; |
27 | void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, | 23 | int xres, yres; |
28 | uintptr_t retaddr); | 24 | int pal_for; |
29 | #else | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED { |
30 | @@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, | 26 | #define LDCMD_SOFINT (1 << 22) |
31 | uint16_t idxmap) | 27 | #define LDCMD_PAL (1 << 26) |
28 | |||
29 | +#define BITS 32 | ||
30 | +#include "pxa2xx_template.h" | ||
31 | + | ||
32 | /* Route internal interrupt lines to the global IC */ | ||
33 | static void pxa2xx_lcdc_int_update(PXA2xxLCDState *s) | ||
32 | { | 34 | { |
33 | } | 35 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) |
34 | -static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | ||
35 | +static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, | ||
36 | + MemTxAttrs attrs) | ||
37 | { | ||
38 | } | ||
39 | #endif | ||
40 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/accel/tcg/translate-all.c | ||
43 | +++ b/accel/tcg/translate-all.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr) | ||
45 | } | ||
46 | |||
47 | #if !defined(CONFIG_USER_ONLY) | ||
48 | -void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr) | ||
49 | +void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | ||
50 | { | ||
51 | ram_addr_t ram_addr; | ||
52 | MemoryRegion *mr; | ||
53 | diff --git a/exec.c b/exec.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/exec.c | ||
56 | +++ b/exec.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc) | ||
58 | if (phys != -1) { | ||
59 | /* Locks grabbed by tb_invalidate_phys_addr */ | ||
60 | tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as, | ||
61 | - phys | (pc & ~TARGET_PAGE_MASK)); | ||
62 | + phys | (pc & ~TARGET_PAGE_MASK), attrs); | ||
63 | } | 36 | } |
64 | } | 37 | } |
65 | #endif | 38 | |
66 | diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c | 39 | +static inline drawfn pxa2xx_drawfn(PXA2xxLCDState *s) |
67 | index XXXXXXX..XXXXXXX 100644 | 40 | +{ |
68 | --- a/target/xtensa/op_helper.c | 41 | + if (s->transp) { |
69 | +++ b/target/xtensa/op_helper.c | 42 | + return pxa2xx_draw_fn_32t[s->bpp]; |
70 | @@ -XXX,XX +XXX,XX @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr) | 43 | + } else { |
71 | int ret = xtensa_get_physical_addr(env, false, vaddr, 2, 0, | 44 | + return pxa2xx_draw_fn_32[s->bpp]; |
72 | &paddr, &page_size, &access); | 45 | + } |
73 | if (ret == 0) { | 46 | +} |
74 | - tb_invalidate_phys_addr(&address_space_memory, paddr); | 47 | + |
75 | + tb_invalidate_phys_addr(&address_space_memory, paddr, | 48 | static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s, |
76 | + MEMTXATTRS_UNSPECIFIED); | 49 | hwaddr addr, int *miny, int *maxy) |
50 | { | ||
51 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
52 | int src_width, dest_width; | ||
53 | - drawfn fn = NULL; | ||
54 | - if (s->dest_width) | ||
55 | - fn = s->line_fn[s->transp][s->bpp]; | ||
56 | + drawfn fn = pxa2xx_drawfn(s); | ||
57 | if (!fn) | ||
58 | return; | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s, | ||
61 | { | ||
62 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
63 | int src_width, dest_width; | ||
64 | - drawfn fn = NULL; | ||
65 | - if (s->dest_width) | ||
66 | - fn = s->line_fn[s->transp][s->bpp]; | ||
67 | + drawfn fn = pxa2xx_drawfn(s); | ||
68 | if (!fn) | ||
69 | return; | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s, | ||
72 | { | ||
73 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
74 | int src_width, dest_width; | ||
75 | - drawfn fn = NULL; | ||
76 | - if (s->dest_width) { | ||
77 | - fn = s->line_fn[s->transp][s->bpp]; | ||
78 | - } | ||
79 | + drawfn fn = pxa2xx_drawfn(s); | ||
80 | if (!fn) { | ||
81 | return; | ||
77 | } | 82 | } |
78 | } | 83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s, |
84 | { | ||
85 | DisplaySurface *surface = qemu_console_surface(s->con); | ||
86 | int src_width, dest_width; | ||
87 | - drawfn fn = NULL; | ||
88 | - if (s->dest_width) { | ||
89 | - fn = s->line_fn[s->transp][s->bpp]; | ||
90 | - } | ||
91 | + drawfn fn = pxa2xx_drawfn(s); | ||
92 | if (!fn) { | ||
93 | return; | ||
94 | } | ||
95 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pxa2xx_lcdc = { | ||
96 | } | ||
97 | }; | ||
98 | |||
99 | -#define BITS 8 | ||
100 | -#include "pxa2xx_template.h" | ||
101 | -#define BITS 15 | ||
102 | -#include "pxa2xx_template.h" | ||
103 | -#define BITS 16 | ||
104 | -#include "pxa2xx_template.h" | ||
105 | -#define BITS 24 | ||
106 | -#include "pxa2xx_template.h" | ||
107 | -#define BITS 32 | ||
108 | -#include "pxa2xx_template.h" | ||
109 | - | ||
110 | static const GraphicHwOps pxa2xx_ops = { | ||
111 | .invalidate = pxa2xx_invalidate_display, | ||
112 | .gfx_update = pxa2xx_update_display, | ||
113 | @@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, | ||
114 | hwaddr base, qemu_irq irq) | ||
115 | { | ||
116 | PXA2xxLCDState *s; | ||
117 | - DisplaySurface *surface; | ||
118 | |||
119 | s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState)); | ||
120 | s->invalidated = 1; | ||
121 | @@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, | ||
122 | memory_region_add_subregion(sysmem, base, &s->iomem); | ||
123 | |||
124 | s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s); | ||
125 | - surface = qemu_console_surface(s->con); | ||
126 | - | ||
127 | - switch (surface_bits_per_pixel(surface)) { | ||
128 | - case 0: | ||
129 | - s->dest_width = 0; | ||
130 | - break; | ||
131 | - case 8: | ||
132 | - s->line_fn[0] = pxa2xx_draw_fn_8; | ||
133 | - s->line_fn[1] = pxa2xx_draw_fn_8t; | ||
134 | - s->dest_width = 1; | ||
135 | - break; | ||
136 | - case 15: | ||
137 | - s->line_fn[0] = pxa2xx_draw_fn_15; | ||
138 | - s->line_fn[1] = pxa2xx_draw_fn_15t; | ||
139 | - s->dest_width = 2; | ||
140 | - break; | ||
141 | - case 16: | ||
142 | - s->line_fn[0] = pxa2xx_draw_fn_16; | ||
143 | - s->line_fn[1] = pxa2xx_draw_fn_16t; | ||
144 | - s->dest_width = 2; | ||
145 | - break; | ||
146 | - case 24: | ||
147 | - s->line_fn[0] = pxa2xx_draw_fn_24; | ||
148 | - s->line_fn[1] = pxa2xx_draw_fn_24t; | ||
149 | - s->dest_width = 3; | ||
150 | - break; | ||
151 | - case 32: | ||
152 | - s->line_fn[0] = pxa2xx_draw_fn_32; | ||
153 | - s->line_fn[1] = pxa2xx_draw_fn_32t; | ||
154 | - s->dest_width = 4; | ||
155 | - break; | ||
156 | - default: | ||
157 | - fprintf(stderr, "%s: Bad color depth\n", __func__); | ||
158 | - exit(1); | ||
159 | - } | ||
160 | + s->dest_width = 4; | ||
161 | |||
162 | vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s); | ||
79 | 163 | ||
80 | -- | 164 | -- |
81 | 2.17.1 | 165 | 2.20.1 |
82 | 166 | ||
83 | 167 | diff view generated by jsdifflib |
1 | The FRECPX instructions should (like most other floating point operations) | 1 | Since the dest_width is now always 4 because the output surface is |
---|---|---|---|
2 | honour the FPCR.FZ bit which specifies whether input denormals should | 2 | 32bpp, we can replace the dest_width state field with a constant. |
3 | be flushed to zero (or FZ16 for the half-precision version). | ||
4 | We forgot to implement this, which doesn't affect the results (since | ||
5 | the calculation doesn't actually care about the mantissa bits) but did | ||
6 | mean we were failing to set the FPSR.IDC bit. | ||
7 | 3 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> |
10 | Message-id: 20180521172712.19930-1-peter.maydell@linaro.org | 6 | Message-id: 20210211141515.8755-6-peter.maydell@linaro.org |
11 | --- | 7 | --- |
12 | target/arm/helper-a64.c | 6 ++++++ | 8 | hw/display/pxa2xx_lcd.c | 20 +++++++++++--------- |
13 | 1 file changed, 6 insertions(+) | 9 | 1 file changed, 11 insertions(+), 9 deletions(-) |
14 | 10 | ||
15 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 11 | diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-a64.c | 13 | --- a/hw/display/pxa2xx_lcd.c |
18 | +++ b/target/arm/helper-a64.c | 14 | +++ b/hw/display/pxa2xx_lcd.c |
19 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp) | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED { |
20 | return nan; | 16 | #define LDCMD_SOFINT (1 << 22) |
17 | #define LDCMD_PAL (1 << 26) | ||
18 | |||
19 | +/* Size of a pixel in the QEMU UI output surface, in bytes */ | ||
20 | +#define DEST_PIXEL_WIDTH 4 | ||
21 | + | ||
22 | #define BITS 32 | ||
23 | #include "pxa2xx_template.h" | ||
24 | |||
25 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s, | ||
26 | else if (s->bpp > pxa_lcdc_8bpp) | ||
27 | src_width *= 2; | ||
28 | |||
29 | - dest_width = s->xres * s->dest_width; | ||
30 | + dest_width = s->xres * DEST_PIXEL_WIDTH; | ||
31 | *miny = 0; | ||
32 | if (s->invalidated) { | ||
33 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, | ||
34 | addr, s->yres, src_width); | ||
21 | } | 35 | } |
22 | 36 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | |
23 | + a = float16_squash_input_denormal(a, fpst); | 37 | - src_width, dest_width, s->dest_width, |
24 | + | 38 | + src_width, dest_width, DEST_PIXEL_WIDTH, |
25 | val16 = float16_val(a); | 39 | s->invalidated, |
26 | sbit = 0x8000 & val16; | 40 | fn, s->dma_ch[0].palette, miny, maxy); |
27 | exp = extract32(val16, 10, 5); | 41 | } |
28 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) | 42 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s, |
29 | return nan; | 43 | else if (s->bpp > pxa_lcdc_8bpp) |
44 | src_width *= 2; | ||
45 | |||
46 | - dest_width = s->yres * s->dest_width; | ||
47 | + dest_width = s->yres * DEST_PIXEL_WIDTH; | ||
48 | *miny = 0; | ||
49 | if (s->invalidated) { | ||
50 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, | ||
51 | addr, s->yres, src_width); | ||
30 | } | 52 | } |
31 | 53 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | |
32 | + a = float32_squash_input_denormal(a, fpst); | 54 | - src_width, s->dest_width, -dest_width, |
33 | + | 55 | + src_width, DEST_PIXEL_WIDTH, -dest_width, |
34 | val32 = float32_val(a); | 56 | s->invalidated, |
35 | sbit = 0x80000000ULL & val32; | 57 | fn, s->dma_ch[0].palette, |
36 | exp = extract32(val32, 23, 8); | 58 | miny, maxy); |
37 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) | 59 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s, |
38 | return nan; | 60 | src_width *= 2; |
39 | } | 61 | } |
40 | 62 | ||
41 | + a = float64_squash_input_denormal(a, fpst); | 63 | - dest_width = s->xres * s->dest_width; |
42 | + | 64 | + dest_width = s->xres * DEST_PIXEL_WIDTH; |
43 | val64 = float64_val(a); | 65 | *miny = 0; |
44 | sbit = 0x8000000000000000ULL & val64; | 66 | if (s->invalidated) { |
45 | exp = extract64(float64_val(a), 52, 11); | 67 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, |
68 | addr, s->yres, src_width); | ||
69 | } | ||
70 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | ||
71 | - src_width, -dest_width, -s->dest_width, | ||
72 | + src_width, -dest_width, -DEST_PIXEL_WIDTH, | ||
73 | s->invalidated, | ||
74 | fn, s->dma_ch[0].palette, miny, maxy); | ||
75 | } | ||
76 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s, | ||
77 | src_width *= 2; | ||
78 | } | ||
79 | |||
80 | - dest_width = s->yres * s->dest_width; | ||
81 | + dest_width = s->yres * DEST_PIXEL_WIDTH; | ||
82 | *miny = 0; | ||
83 | if (s->invalidated) { | ||
84 | framebuffer_update_memory_section(&s->fbsection, s->sysmem, | ||
85 | addr, s->yres, src_width); | ||
86 | } | ||
87 | framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres, | ||
88 | - src_width, -s->dest_width, dest_width, | ||
89 | + src_width, -DEST_PIXEL_WIDTH, dest_width, | ||
90 | s->invalidated, | ||
91 | fn, s->dma_ch[0].palette, | ||
92 | miny, maxy); | ||
93 | @@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem, | ||
94 | memory_region_add_subregion(sysmem, base, &s->iomem); | ||
95 | |||
96 | s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s); | ||
97 | - s->dest_width = 4; | ||
98 | |||
99 | vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s); | ||
100 | |||
46 | -- | 101 | -- |
47 | 2.17.1 | 102 | 2.20.1 |
48 | 103 | ||
49 | 104 | diff view generated by jsdifflib |
1 | Add more detail to the documentation for memory_region_init_iommu() | 1 | Now that BITS is always 32, expand out all its uses in the template |
---|---|---|---|
2 | and other IOMMU-related functions and data structures. | 2 | header, including removing now-useless uses of the glue() macro. |
3 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Message-id: 20210211141515.8755-7-peter.maydell@linaro.org |
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20180521140402.23318-2-peter.maydell@linaro.org | ||
9 | --- | 7 | --- |
10 | include/exec/memory.h | 105 ++++++++++++++++++++++++++++++++++++++---- | 8 | hw/display/pxa2xx_template.h | 110 ++++++++++++++--------------------- |
11 | 1 file changed, 95 insertions(+), 10 deletions(-) | 9 | 1 file changed, 45 insertions(+), 65 deletions(-) |
12 | 10 | ||
13 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 11 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h |
14 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/exec/memory.h | 13 | --- a/hw/display/pxa2xx_template.h |
16 | +++ b/include/exec/memory.h | 14 | +++ b/hw/display/pxa2xx_template.h |
17 | @@ -XXX,XX +XXX,XX @@ enum IOMMUMemoryRegionAttr { | 15 | @@ -XXX,XX +XXX,XX @@ |
18 | IOMMU_ATTR_SPAPR_TCE_FD | 16 | */ |
17 | |||
18 | # define SKIP_PIXEL(to) to += deststep | ||
19 | -#if BITS == 8 | ||
20 | -# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0) | ||
21 | -#elif BITS == 15 || BITS == 16 | ||
22 | -# define COPY_PIXEL(to, from) \ | ||
23 | - do { \ | ||
24 | - *(uint16_t *) to = from; \ | ||
25 | - SKIP_PIXEL(to); \ | ||
26 | - } while (0) | ||
27 | -#elif BITS == 24 | ||
28 | -# define COPY_PIXEL(to, from) \ | ||
29 | - do { \ | ||
30 | - *(uint16_t *) to = from; \ | ||
31 | - *(to + 2) = (from) >> 16; \ | ||
32 | - SKIP_PIXEL(to); \ | ||
33 | - } while (0) | ||
34 | -#elif BITS == 32 | ||
35 | # define COPY_PIXEL(to, from) \ | ||
36 | do { \ | ||
37 | *(uint32_t *) to = from; \ | ||
38 | SKIP_PIXEL(to); \ | ||
39 | } while (0) | ||
40 | -#else | ||
41 | -# error unknown bit depth | ||
42 | -#endif | ||
43 | |||
44 | #ifdef HOST_WORDS_BIGENDIAN | ||
45 | # define SWAP_WORDS 1 | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #define FN_2(x) FN(x + 1) FN(x) | ||
48 | #define FN_4(x) FN_2(x + 2) FN_2(x) | ||
49 | |||
50 | -static void glue(pxa2xx_draw_line2_, BITS)(void *opaque, | ||
51 | +static void pxa2xx_draw_line2(void *opaque, | ||
52 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
53 | { | ||
54 | uint32_t *palette = opaque; | ||
55 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line2_, BITS)(void *opaque, | ||
56 | } | ||
57 | } | ||
58 | |||
59 | -static void glue(pxa2xx_draw_line4_, BITS)(void *opaque, | ||
60 | +static void pxa2xx_draw_line4(void *opaque, | ||
61 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
62 | { | ||
63 | uint32_t *palette = opaque; | ||
64 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line4_, BITS)(void *opaque, | ||
65 | } | ||
66 | } | ||
67 | |||
68 | -static void glue(pxa2xx_draw_line8_, BITS)(void *opaque, | ||
69 | +static void pxa2xx_draw_line8(void *opaque, | ||
70 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
71 | { | ||
72 | uint32_t *palette = opaque; | ||
73 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line8_, BITS)(void *opaque, | ||
74 | } | ||
75 | } | ||
76 | |||
77 | -static void glue(pxa2xx_draw_line16_, BITS)(void *opaque, | ||
78 | +static void pxa2xx_draw_line16(void *opaque, | ||
79 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
80 | { | ||
81 | uint32_t data; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16_, BITS)(void *opaque, | ||
83 | data >>= 6; | ||
84 | r = (data & 0x1f) << 3; | ||
85 | data >>= 5; | ||
86 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
87 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
88 | b = (data & 0x1f) << 3; | ||
89 | data >>= 5; | ||
90 | g = (data & 0x3f) << 2; | ||
91 | data >>= 6; | ||
92 | r = (data & 0x1f) << 3; | ||
93 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
94 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
95 | width -= 2; | ||
96 | src += 4; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | -static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque, | ||
101 | +static void pxa2xx_draw_line16t(void *opaque, | ||
102 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
103 | { | ||
104 | uint32_t data; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque, | ||
106 | if (data & 1) | ||
107 | SKIP_PIXEL(dest); | ||
108 | else | ||
109 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
110 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
111 | data >>= 1; | ||
112 | b = (data & 0x1f) << 3; | ||
113 | data >>= 5; | ||
114 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque, | ||
115 | if (data & 1) | ||
116 | SKIP_PIXEL(dest); | ||
117 | else | ||
118 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
119 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
120 | width -= 2; | ||
121 | src += 4; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | -static void glue(pxa2xx_draw_line18_, BITS)(void *opaque, | ||
126 | +static void pxa2xx_draw_line18(void *opaque, | ||
127 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
128 | { | ||
129 | uint32_t data; | ||
130 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line18_, BITS)(void *opaque, | ||
131 | g = (data & 0x3f) << 2; | ||
132 | data >>= 6; | ||
133 | r = (data & 0x3f) << 2; | ||
134 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
135 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
136 | width -= 1; | ||
137 | src += 4; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | /* The wicked packed format */ | ||
142 | -static void glue(pxa2xx_draw_line18p_, BITS)(void *opaque, | ||
143 | +static void pxa2xx_draw_line18p(void *opaque, | ||
144 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
145 | { | ||
146 | uint32_t data[3]; | ||
147 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line18p_, BITS)(void *opaque, | ||
148 | data[0] >>= 6; | ||
149 | r = (data[0] & 0x3f) << 2; | ||
150 | data[0] >>= 12; | ||
151 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
152 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
153 | b = (data[0] & 0x3f) << 2; | ||
154 | data[0] >>= 6; | ||
155 | g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
156 | data[1] >>= 4; | ||
157 | r = (data[1] & 0x3f) << 2; | ||
158 | data[1] >>= 12; | ||
159 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
160 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
161 | b = (data[1] & 0x3f) << 2; | ||
162 | data[1] >>= 6; | ||
163 | g = (data[1] & 0x3f) << 2; | ||
164 | data[1] >>= 6; | ||
165 | r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
166 | data[2] >>= 8; | ||
167 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
168 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
169 | b = (data[2] & 0x3f) << 2; | ||
170 | data[2] >>= 6; | ||
171 | g = (data[2] & 0x3f) << 2; | ||
172 | data[2] >>= 6; | ||
173 | r = data[2] << 2; | ||
174 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
175 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
176 | width -= 4; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | -static void glue(pxa2xx_draw_line19_, BITS)(void *opaque, | ||
181 | +static void pxa2xx_draw_line19(void *opaque, | ||
182 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
183 | { | ||
184 | uint32_t data; | ||
185 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19_, BITS)(void *opaque, | ||
186 | if (data & 1) | ||
187 | SKIP_PIXEL(dest); | ||
188 | else | ||
189 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
190 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
191 | width -= 1; | ||
192 | src += 4; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | /* The wicked packed format */ | ||
197 | -static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
198 | +static void pxa2xx_draw_line19p(void *opaque, | ||
199 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
200 | { | ||
201 | uint32_t data[3]; | ||
202 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
203 | if (data[0] & 1) | ||
204 | SKIP_PIXEL(dest); | ||
205 | else | ||
206 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
207 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
208 | data[0] >>= 6; | ||
209 | b = (data[0] & 0x3f) << 2; | ||
210 | data[0] >>= 6; | ||
211 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
212 | if (data[1] & 1) | ||
213 | SKIP_PIXEL(dest); | ||
214 | else | ||
215 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
216 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
217 | data[1] >>= 6; | ||
218 | b = (data[1] & 0x3f) << 2; | ||
219 | data[1] >>= 6; | ||
220 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
221 | if (data[2] & 1) | ||
222 | SKIP_PIXEL(dest); | ||
223 | else | ||
224 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
225 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
226 | data[2] >>= 6; | ||
227 | b = (data[2] & 0x3f) << 2; | ||
228 | data[2] >>= 6; | ||
229 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque, | ||
230 | if (data[2] & 1) | ||
231 | SKIP_PIXEL(dest); | ||
232 | else | ||
233 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
234 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
235 | width -= 4; | ||
236 | } | ||
237 | } | ||
238 | |||
239 | -static void glue(pxa2xx_draw_line24_, BITS)(void *opaque, | ||
240 | +static void pxa2xx_draw_line24(void *opaque, | ||
241 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
242 | { | ||
243 | uint32_t data; | ||
244 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line24_, BITS)(void *opaque, | ||
245 | g = data & 0xff; | ||
246 | data >>= 8; | ||
247 | r = data & 0xff; | ||
248 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
249 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
250 | width -= 1; | ||
251 | src += 4; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | -static void glue(pxa2xx_draw_line24t_, BITS)(void *opaque, | ||
256 | +static void pxa2xx_draw_line24t(void *opaque, | ||
257 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
258 | { | ||
259 | uint32_t data; | ||
260 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line24t_, BITS)(void *opaque, | ||
261 | if (data & 1) | ||
262 | SKIP_PIXEL(dest); | ||
263 | else | ||
264 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
265 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
266 | width -= 1; | ||
267 | src += 4; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | -static void glue(pxa2xx_draw_line25_, BITS)(void *opaque, | ||
272 | +static void pxa2xx_draw_line25(void *opaque, | ||
273 | uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
274 | { | ||
275 | uint32_t data; | ||
276 | @@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line25_, BITS)(void *opaque, | ||
277 | if (data & 1) | ||
278 | SKIP_PIXEL(dest); | ||
279 | else | ||
280 | - COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); | ||
281 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
282 | width -= 1; | ||
283 | src += 4; | ||
284 | } | ||
285 | } | ||
286 | |||
287 | /* Overlay planes disabled, no transparency */ | ||
288 | -static drawfn glue(pxa2xx_draw_fn_, BITS)[16] = | ||
289 | +static drawfn pxa2xx_draw_fn_32[16] = | ||
290 | { | ||
291 | [0 ... 0xf] = NULL, | ||
292 | - [pxa_lcdc_2bpp] = glue(pxa2xx_draw_line2_, BITS), | ||
293 | - [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS), | ||
294 | - [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS), | ||
295 | - [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16_, BITS), | ||
296 | - [pxa_lcdc_18bpp] = glue(pxa2xx_draw_line18_, BITS), | ||
297 | - [pxa_lcdc_18pbpp] = glue(pxa2xx_draw_line18p_, BITS), | ||
298 | - [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24_, BITS), | ||
299 | + [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
300 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
301 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
302 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16, | ||
303 | + [pxa_lcdc_18bpp] = pxa2xx_draw_line18, | ||
304 | + [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p, | ||
305 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24, | ||
19 | }; | 306 | }; |
20 | 307 | ||
21 | +/** | 308 | /* Overlay planes enabled, transparency used */ |
22 | + * IOMMUMemoryRegionClass: | 309 | -static drawfn glue(glue(pxa2xx_draw_fn_, BITS), t)[16] = |
23 | + * | 310 | +static drawfn pxa2xx_draw_fn_32t[16] = |
24 | + * All IOMMU implementations need to subclass TYPE_IOMMU_MEMORY_REGION | 311 | { |
25 | + * and provide an implementation of at least the @translate method here | 312 | [0 ... 0xf] = NULL, |
26 | + * to handle requests to the memory region. Other methods are optional. | 313 | - [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS), |
27 | + * | 314 | - [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS), |
28 | + * The IOMMU implementation must use the IOMMU notifier infrastructure | 315 | - [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16t_, BITS), |
29 | + * to report whenever mappings are changed, by calling | 316 | - [pxa_lcdc_19bpp] = glue(pxa2xx_draw_line19_, BITS), |
30 | + * memory_region_notify_iommu() (or, if necessary, by calling | 317 | - [pxa_lcdc_19pbpp] = glue(pxa2xx_draw_line19p_, BITS), |
31 | + * memory_region_notify_one() for each registered notifier). | 318 | - [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24t_, BITS), |
32 | + */ | 319 | - [pxa_lcdc_25bpp] = glue(pxa2xx_draw_line25_, BITS), |
33 | typedef struct IOMMUMemoryRegionClass { | 320 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, |
34 | /* private */ | 321 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, |
35 | struct DeviceClass parent_class; | 322 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16t, |
36 | 323 | + [pxa_lcdc_19bpp] = pxa2xx_draw_line19, | |
37 | /* | 324 | + [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p, |
38 | - * Return a TLB entry that contains a given address. Flag should | 325 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24t, |
39 | - * be the access permission of this translation operation. We can | 326 | + [pxa_lcdc_25bpp] = pxa2xx_draw_line25, |
40 | - * set flag to IOMMU_NONE to mean that we don't need any | 327 | }; |
41 | - * read/write permission checks, like, when for region replay. | 328 | |
42 | + * Return a TLB entry that contains a given address. | 329 | -#undef BITS |
43 | + * | 330 | #undef COPY_PIXEL |
44 | + * The IOMMUAccessFlags indicated via @flag are optional and may | 331 | #undef SKIP_PIXEL |
45 | + * be specified as IOMMU_NONE to indicate that the caller needs | 332 | |
46 | + * the full translation information for both reads and writes. If | ||
47 | + * the access flags are specified then the IOMMU implementation | ||
48 | + * may use this as an optimization, to stop doing a page table | ||
49 | + * walk as soon as it knows that the requested permissions are not | ||
50 | + * allowed. If IOMMU_NONE is passed then the IOMMU must do the | ||
51 | + * full page table walk and report the permissions in the returned | ||
52 | + * IOMMUTLBEntry. (Note that this implies that an IOMMU may not | ||
53 | + * return different mappings for reads and writes.) | ||
54 | + * | ||
55 | + * The returned information remains valid while the caller is | ||
56 | + * holding the big QEMU lock or is inside an RCU critical section; | ||
57 | + * if the caller wishes to cache the mapping beyond that it must | ||
58 | + * register an IOMMU notifier so it can invalidate its cached | ||
59 | + * information when the IOMMU mapping changes. | ||
60 | + * | ||
61 | + * @iommu: the IOMMUMemoryRegion | ||
62 | + * @hwaddr: address to be translated within the memory region | ||
63 | + * @flag: requested access permissions | ||
64 | */ | ||
65 | IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr, | ||
66 | IOMMUAccessFlags flag); | ||
67 | - /* Returns minimum supported page size */ | ||
68 | + /* Returns minimum supported page size in bytes. | ||
69 | + * If this method is not provided then the minimum is assumed to | ||
70 | + * be TARGET_PAGE_SIZE. | ||
71 | + * | ||
72 | + * @iommu: the IOMMUMemoryRegion | ||
73 | + */ | ||
74 | uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu); | ||
75 | - /* Called when IOMMU Notifier flag changed */ | ||
76 | + /* Called when IOMMU Notifier flag changes (ie when the set of | ||
77 | + * events which IOMMU users are requesting notification for changes). | ||
78 | + * Optional method -- need not be provided if the IOMMU does not | ||
79 | + * need to know exactly which events must be notified. | ||
80 | + * | ||
81 | + * @iommu: the IOMMUMemoryRegion | ||
82 | + * @old_flags: events which previously needed to be notified | ||
83 | + * @new_flags: events which now need to be notified | ||
84 | + */ | ||
85 | void (*notify_flag_changed)(IOMMUMemoryRegion *iommu, | ||
86 | IOMMUNotifierFlag old_flags, | ||
87 | IOMMUNotifierFlag new_flags); | ||
88 | - /* Set this up to provide customized IOMMU replay function */ | ||
89 | + /* Called to handle memory_region_iommu_replay(). | ||
90 | + * | ||
91 | + * The default implementation of memory_region_iommu_replay() is to | ||
92 | + * call the IOMMU translate method for every page in the address space | ||
93 | + * with flag == IOMMU_NONE and then call the notifier if translate | ||
94 | + * returns a valid mapping. If this method is implemented then it | ||
95 | + * overrides the default behaviour, and must provide the full semantics | ||
96 | + * of memory_region_iommu_replay(), by calling @notifier for every | ||
97 | + * translation present in the IOMMU. | ||
98 | + * | ||
99 | + * Optional method -- an IOMMU only needs to provide this method | ||
100 | + * if the default is inefficient or produces undesirable side effects. | ||
101 | + * | ||
102 | + * Note: this is not related to record-and-replay functionality. | ||
103 | + */ | ||
104 | void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier); | ||
105 | |||
106 | - /* Get IOMMU misc attributes */ | ||
107 | - int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr, | ||
108 | + /* Get IOMMU misc attributes. This is an optional method that | ||
109 | + * can be used to allow users of the IOMMU to get implementation-specific | ||
110 | + * information. The IOMMU implements this method to handle calls | ||
111 | + * by IOMMU users to memory_region_iommu_get_attr() by filling in | ||
112 | + * the arbitrary data pointer for any IOMMUMemoryRegionAttr values that | ||
113 | + * the IOMMU supports. If the method is unimplemented then | ||
114 | + * memory_region_iommu_get_attr() will always return -EINVAL. | ||
115 | + * | ||
116 | + * @iommu: the IOMMUMemoryRegion | ||
117 | + * @attr: attribute being queried | ||
118 | + * @data: memory to fill in with the attribute data | ||
119 | + * | ||
120 | + * Returns 0 on success, or a negative errno; in particular | ||
121 | + * returns -EINVAL for unrecognized or unimplemented attribute types. | ||
122 | + */ | ||
123 | + int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr attr, | ||
124 | void *data); | ||
125 | } IOMMUMemoryRegionClass; | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static inline void memory_region_init_reservation(MemoryRegion *mr, | ||
128 | * An IOMMU region translates addresses and forwards accesses to a target | ||
129 | * memory region. | ||
130 | * | ||
131 | + * The IOMMU implementation must define a subclass of TYPE_IOMMU_MEMORY_REGION. | ||
132 | + * @_iommu_mr should be a pointer to enough memory for an instance of | ||
133 | + * that subclass, @instance_size is the size of that subclass, and | ||
134 | + * @mrtypename is its name. This function will initialize @_iommu_mr as an | ||
135 | + * instance of the subclass, and its methods will then be called to handle | ||
136 | + * accesses to the memory region. See the documentation of | ||
137 | + * #IOMMUMemoryRegionClass for further details. | ||
138 | + * | ||
139 | * @_iommu_mr: the #IOMMUMemoryRegion to be initialized | ||
140 | * @instance_size: the IOMMUMemoryRegion subclass instance size | ||
141 | * @mrtypename: the type name of the #IOMMUMemoryRegion | ||
142 | @@ -XXX,XX +XXX,XX @@ void memory_region_register_iommu_notifier(MemoryRegion *mr, | ||
143 | * a notifier with the minimum page granularity returned by | ||
144 | * mr->iommu_ops->get_page_size(). | ||
145 | * | ||
146 | + * Note: this is not related to record-and-replay functionality. | ||
147 | + * | ||
148 | * @iommu_mr: the memory region to observe | ||
149 | * @n: the notifier to which to replay iommu mappings | ||
150 | */ | ||
151 | @@ -XXX,XX +XXX,XX @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n); | ||
152 | * memory_region_iommu_replay_all: replay existing IOMMU translations | ||
153 | * to all the notifiers registered. | ||
154 | * | ||
155 | + * Note: this is not related to record-and-replay functionality. | ||
156 | + * | ||
157 | * @iommu_mr: the memory region to observe | ||
158 | */ | ||
159 | void memory_region_iommu_replay_all(IOMMUMemoryRegion *iommu_mr); | ||
160 | @@ -XXX,XX +XXX,XX @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, | ||
161 | * memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is | ||
162 | * defined on the IOMMU. | ||
163 | * | ||
164 | - * Returns 0 if succeded, error code otherwise. | ||
165 | + * Returns 0 on success, or a negative errno otherwise. In particular, | ||
166 | + * -EINVAL indicates that the IOMMU does not support the requested | ||
167 | + * attribute. | ||
168 | * | ||
169 | * @iommu_mr: the memory region | ||
170 | * @attr: the requested attribute | ||
171 | -- | 333 | -- |
172 | 2.17.1 | 334 | 2.20.1 |
173 | 335 | ||
174 | 336 | diff view generated by jsdifflib |
1 | As part of plumbing MemTxAttrs down to the IOMMU translate method, | 1 | We're about to move code from the template header into pxa2xx_lcd.c. |
---|---|---|---|
2 | add MemTxAttrs as an argument to address_space_translate() | 2 | Before doing that, make coding style fixes so checkpatch doesn't |
3 | and address_space_translate_cached(). Callers either have an | 3 | complain about the patch which moves the code. This commit fixes |
4 | attrs value to hand, or don't care and can use MEMTXATTRS_UNSPECIFIED. | 4 | missing braces in the SKIP_PIXEL() macro definition and in if() |
5 | statements. | ||
5 | 6 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20210211141515.8755-8-peter.maydell@linaro.org |
9 | Message-id: 20180521140402.23318-4-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | include/exec/memory.h | 4 +++- | 11 | hw/display/pxa2xx_template.h | 47 +++++++++++++++++++++--------------- |
12 | accel/tcg/translate-all.c | 2 +- | 12 | 1 file changed, 28 insertions(+), 19 deletions(-) |
13 | exec.c | 14 +++++++++----- | ||
14 | hw/vfio/common.c | 3 ++- | ||
15 | memory_ldst.inc.c | 18 +++++++++--------- | ||
16 | target/riscv/helper.c | 2 +- | ||
17 | 6 files changed, 25 insertions(+), 18 deletions(-) | ||
18 | 13 | ||
19 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 14 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h |
20 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/exec/memory.h | 16 | --- a/hw/display/pxa2xx_template.h |
22 | +++ b/include/exec/memory.h | 17 | +++ b/hw/display/pxa2xx_template.h |
23 | @@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, | 18 | @@ -XXX,XX +XXX,XX @@ |
24 | * #MemoryRegion. | 19 | * Framebuffer format conversion routines. |
25 | * @len: pointer to length | ||
26 | * @is_write: indicates the transfer direction | ||
27 | + * @attrs: memory attributes | ||
28 | */ | 20 | */ |
29 | MemoryRegion *flatview_translate(FlatView *fv, | 21 | |
30 | hwaddr addr, hwaddr *xlat, | 22 | -# define SKIP_PIXEL(to) to += deststep |
31 | @@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, | 23 | +# define SKIP_PIXEL(to) do { to += deststep; } while (0) |
32 | 24 | # define COPY_PIXEL(to, from) \ | |
33 | static inline MemoryRegion *address_space_translate(AddressSpace *as, | 25 | do { \ |
34 | hwaddr addr, hwaddr *xlat, | 26 | *(uint32_t *) to = from; \ |
35 | - hwaddr *len, bool is_write) | 27 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque, |
36 | + hwaddr *len, bool is_write, | 28 | data >>= 5; |
37 | + MemTxAttrs attrs) | 29 | r = (data & 0x1f) << 3; |
38 | { | 30 | data >>= 5; |
39 | return flatview_translate(address_space_to_flatview(as), | 31 | - if (data & 1) |
40 | addr, xlat, len, is_write); | 32 | + if (data & 1) { |
41 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | 33 | SKIP_PIXEL(dest); |
42 | index XXXXXXX..XXXXXXX 100644 | 34 | - else |
43 | --- a/accel/tcg/translate-all.c | 35 | + } else { |
44 | +++ b/accel/tcg/translate-all.c | 36 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
45 | @@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs) | 37 | + } |
46 | hwaddr l = 1; | 38 | data >>= 1; |
47 | 39 | b = (data & 0x1f) << 3; | |
48 | rcu_read_lock(); | 40 | data >>= 5; |
49 | - mr = address_space_translate(as, addr, &addr, &l, false); | 41 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque, |
50 | + mr = address_space_translate(as, addr, &addr, &l, false, attrs); | 42 | data >>= 5; |
51 | if (!(memory_region_is_ram(mr) | 43 | r = (data & 0x1f) << 3; |
52 | || memory_region_is_romd(mr))) { | 44 | data >>= 5; |
53 | rcu_read_unlock(); | 45 | - if (data & 1) |
54 | diff --git a/exec.c b/exec.c | 46 | + if (data & 1) { |
55 | index XXXXXXX..XXXXXXX 100644 | 47 | SKIP_PIXEL(dest); |
56 | --- a/exec.c | 48 | - else |
57 | +++ b/exec.c | 49 | + } else { |
58 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, | 50 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
59 | rcu_read_lock(); | 51 | + } |
60 | while (len > 0) { | 52 | width -= 2; |
61 | l = len; | 53 | src += 4; |
62 | - mr = address_space_translate(as, addr, &addr1, &l, true); | 54 | } |
63 | + mr = address_space_translate(as, addr, &addr1, &l, true, | 55 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19(void *opaque, |
64 | + MEMTXATTRS_UNSPECIFIED); | 56 | data >>= 6; |
65 | 57 | r = (data & 0x3f) << 2; | |
66 | if (!(memory_region_is_ram(mr) || | 58 | data >>= 6; |
67 | memory_region_is_romd(mr))) { | 59 | - if (data & 1) |
68 | @@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache) | 60 | + if (data & 1) { |
69 | */ | 61 | SKIP_PIXEL(dest); |
70 | static inline MemoryRegion *address_space_translate_cached( | 62 | - else |
71 | MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat, | 63 | + } else { |
72 | - hwaddr *plen, bool is_write) | 64 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
73 | + hwaddr *plen, bool is_write, MemTxAttrs attrs) | 65 | + } |
74 | { | 66 | width -= 1; |
75 | MemoryRegionSection section; | 67 | src += 4; |
76 | MemoryRegion *mr; | 68 | } |
77 | @@ -XXX,XX +XXX,XX @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, | 69 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, |
78 | MemoryRegion *mr; | 70 | data[0] >>= 6; |
79 | 71 | r = (data[0] & 0x3f) << 2; | |
80 | l = len; | 72 | data[0] >>= 6; |
81 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, false); | 73 | - if (data[0] & 1) |
82 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, false, | 74 | + if (data[0] & 1) { |
83 | + MEMTXATTRS_UNSPECIFIED); | 75 | SKIP_PIXEL(dest); |
84 | flatview_read_continue(cache->fv, | 76 | - else |
85 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | 77 | + } else { |
86 | addr1, l, mr); | 78 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
87 | @@ -XXX,XX +XXX,XX @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, | 79 | + } |
88 | MemoryRegion *mr; | 80 | data[0] >>= 6; |
89 | 81 | b = (data[0] & 0x3f) << 2; | |
90 | l = len; | 82 | data[0] >>= 6; |
91 | - mr = address_space_translate_cached(cache, addr, &addr1, &l, true); | 83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, |
92 | + mr = address_space_translate_cached(cache, addr, &addr1, &l, true, | 84 | data[1] >>= 4; |
93 | + MEMTXATTRS_UNSPECIFIED); | 85 | r = (data[1] & 0x3f) << 2; |
94 | flatview_write_continue(cache->fv, | 86 | data[1] >>= 6; |
95 | addr, MEMTXATTRS_UNSPECIFIED, buf, len, | 87 | - if (data[1] & 1) |
96 | addr1, l, mr); | 88 | + if (data[1] & 1) { |
97 | @@ -XXX,XX +XXX,XX @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) | 89 | SKIP_PIXEL(dest); |
98 | 90 | - else | |
99 | rcu_read_lock(); | 91 | + } else { |
100 | mr = address_space_translate(&address_space_memory, | 92 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
101 | - phys_addr, &phys_addr, &l, false); | 93 | + } |
102 | + phys_addr, &phys_addr, &l, false, | 94 | data[1] >>= 6; |
103 | + MEMTXATTRS_UNSPECIFIED); | 95 | b = (data[1] & 0x3f) << 2; |
104 | 96 | data[1] >>= 6; | |
105 | res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr)); | 97 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, |
106 | rcu_read_unlock(); | 98 | data[1] >>= 6; |
107 | diff --git a/hw/vfio/common.c b/hw/vfio/common.c | 99 | r = ((data[2] & 0x3) << 6) | (data[1] << 2); |
108 | index XXXXXXX..XXXXXXX 100644 | 100 | data[2] >>= 2; |
109 | --- a/hw/vfio/common.c | 101 | - if (data[2] & 1) |
110 | +++ b/hw/vfio/common.c | 102 | + if (data[2] & 1) { |
111 | @@ -XXX,XX +XXX,XX @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr, | 103 | SKIP_PIXEL(dest); |
112 | */ | 104 | - else |
113 | mr = address_space_translate(&address_space_memory, | 105 | + } else { |
114 | iotlb->translated_addr, | 106 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
115 | - &xlat, &len, writable); | 107 | + } |
116 | + &xlat, &len, writable, | 108 | data[2] >>= 6; |
117 | + MEMTXATTRS_UNSPECIFIED); | 109 | b = (data[2] & 0x3f) << 2; |
118 | if (!memory_region_is_ram(mr)) { | 110 | data[2] >>= 6; |
119 | error_report("iommu map to non memory area %"HWADDR_PRIx"", | 111 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, |
120 | xlat); | 112 | data[2] >>= 6; |
121 | diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c | 113 | r = data[2] << 2; |
122 | index XXXXXXX..XXXXXXX 100644 | 114 | data[2] >>= 6; |
123 | --- a/memory_ldst.inc.c | 115 | - if (data[2] & 1) |
124 | +++ b/memory_ldst.inc.c | 116 | + if (data[2] & 1) { |
125 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL, | 117 | SKIP_PIXEL(dest); |
126 | bool release_lock = false; | 118 | - else |
127 | 119 | + } else { | |
128 | RCU_READ_LOCK(); | 120 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
129 | - mr = TRANSLATE(addr, &addr1, &l, false); | 121 | + } |
130 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | 122 | width -= 4; |
131 | if (l < 4 || !IS_DIRECT(mr, false)) { | 123 | } |
132 | release_lock |= prepare_mmio_access(mr); | 124 | } |
133 | 125 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24t(void *opaque, | |
134 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL, | 126 | data >>= 8; |
135 | bool release_lock = false; | 127 | r = data & 0xff; |
136 | 128 | data >>= 8; | |
137 | RCU_READ_LOCK(); | 129 | - if (data & 1) |
138 | - mr = TRANSLATE(addr, &addr1, &l, false); | 130 | + if (data & 1) { |
139 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | 131 | SKIP_PIXEL(dest); |
140 | if (l < 8 || !IS_DIRECT(mr, false)) { | 132 | - else |
141 | release_lock |= prepare_mmio_access(mr); | 133 | + } else { |
142 | 134 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | |
143 | @@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL, | 135 | + } |
144 | bool release_lock = false; | 136 | width -= 1; |
145 | 137 | src += 4; | |
146 | RCU_READ_LOCK(); | 138 | } |
147 | - mr = TRANSLATE(addr, &addr1, &l, false); | 139 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line25(void *opaque, |
148 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | 140 | data >>= 8; |
149 | if (!IS_DIRECT(mr, false)) { | 141 | r = data & 0xff; |
150 | release_lock |= prepare_mmio_access(mr); | 142 | data >>= 8; |
151 | 143 | - if (data & 1) | |
152 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL, | 144 | + if (data & 1) { |
153 | bool release_lock = false; | 145 | SKIP_PIXEL(dest); |
154 | 146 | - else | |
155 | RCU_READ_LOCK(); | 147 | + } else { |
156 | - mr = TRANSLATE(addr, &addr1, &l, false); | 148 | COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); |
157 | + mr = TRANSLATE(addr, &addr1, &l, false, attrs); | 149 | + } |
158 | if (l < 2 || !IS_DIRECT(mr, false)) { | 150 | width -= 1; |
159 | release_lock |= prepare_mmio_access(mr); | 151 | src += 4; |
160 | 152 | } | |
161 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL, | ||
162 | bool release_lock = false; | ||
163 | |||
164 | RCU_READ_LOCK(); | ||
165 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
166 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
167 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
168 | release_lock |= prepare_mmio_access(mr); | ||
169 | |||
170 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL, | ||
171 | bool release_lock = false; | ||
172 | |||
173 | RCU_READ_LOCK(); | ||
174 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
175 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
176 | if (l < 4 || !IS_DIRECT(mr, true)) { | ||
177 | release_lock |= prepare_mmio_access(mr); | ||
178 | |||
179 | @@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL, | ||
180 | bool release_lock = false; | ||
181 | |||
182 | RCU_READ_LOCK(); | ||
183 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
184 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
185 | if (!IS_DIRECT(mr, true)) { | ||
186 | release_lock |= prepare_mmio_access(mr); | ||
187 | r = memory_region_dispatch_write(mr, addr1, val, 1, attrs); | ||
188 | @@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL, | ||
189 | bool release_lock = false; | ||
190 | |||
191 | RCU_READ_LOCK(); | ||
192 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
193 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
194 | if (l < 2 || !IS_DIRECT(mr, true)) { | ||
195 | release_lock |= prepare_mmio_access(mr); | ||
196 | |||
197 | @@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL, | ||
198 | bool release_lock = false; | ||
199 | |||
200 | RCU_READ_LOCK(); | ||
201 | - mr = TRANSLATE(addr, &addr1, &l, true); | ||
202 | + mr = TRANSLATE(addr, &addr1, &l, true, attrs); | ||
203 | if (l < 8 || !IS_DIRECT(mr, true)) { | ||
204 | release_lock |= prepare_mmio_access(mr); | ||
205 | |||
206 | diff --git a/target/riscv/helper.c b/target/riscv/helper.c | ||
207 | index XXXXXXX..XXXXXXX 100644 | ||
208 | --- a/target/riscv/helper.c | ||
209 | +++ b/target/riscv/helper.c | ||
210 | @@ -XXX,XX +XXX,XX @@ restart: | ||
211 | MemoryRegion *mr; | ||
212 | hwaddr l = sizeof(target_ulong), addr1; | ||
213 | mr = address_space_translate(cs->as, pte_addr, | ||
214 | - &addr1, &l, false); | ||
215 | + &addr1, &l, false, MEMTXATTRS_UNSPECIFIED); | ||
216 | if (memory_access_is_direct(mr, true)) { | ||
217 | target_ulong *pte_pa = | ||
218 | qemu_map_ram_ptr(mr->ram_block, addr1); | ||
219 | -- | 153 | -- |
220 | 2.17.1 | 154 | 2.20.1 |
221 | 155 | ||
222 | 156 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | We're about to move code from the template header into pxa2xx_lcd.c. | |
2 | Before doing that, make coding style fixes so checkpatch doesn't | ||
3 | complain about the patch which moves the code. This commit is | ||
4 | whitespace changes only: | ||
5 | * avoid hard-coded tabs | ||
6 | * fix ident on function prototypes | ||
7 | * no newline before open brace on array definitions | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> | ||
11 | Message-id: 20210211141515.8755-9-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/display/pxa2xx_template.h | 66 +++++++++++++++++------------------- | ||
14 | 1 file changed, 32 insertions(+), 34 deletions(-) | ||
15 | |||
16 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/display/pxa2xx_template.h | ||
19 | +++ b/hw/display/pxa2xx_template.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | } while (0) | ||
22 | |||
23 | #ifdef HOST_WORDS_BIGENDIAN | ||
24 | -# define SWAP_WORDS 1 | ||
25 | +# define SWAP_WORDS 1 | ||
26 | #endif | ||
27 | |||
28 | -#define FN_2(x) FN(x + 1) FN(x) | ||
29 | -#define FN_4(x) FN_2(x + 2) FN_2(x) | ||
30 | +#define FN_2(x) FN(x + 1) FN(x) | ||
31 | +#define FN_4(x) FN_2(x + 2) FN_2(x) | ||
32 | |||
33 | -static void pxa2xx_draw_line2(void *opaque, | ||
34 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
35 | +static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src, | ||
36 | + int width, int deststep) | ||
37 | { | ||
38 | uint32_t *palette = opaque; | ||
39 | uint32_t data; | ||
40 | while (width > 0) { | ||
41 | data = *(uint32_t *) src; | ||
42 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
43 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
44 | #ifdef SWAP_WORDS | ||
45 | FN_4(12) | ||
46 | FN_4(8) | ||
47 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line2(void *opaque, | ||
48 | } | ||
49 | } | ||
50 | |||
51 | -static void pxa2xx_draw_line4(void *opaque, | ||
52 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
53 | +static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src, | ||
54 | + int width, int deststep) | ||
55 | { | ||
56 | uint32_t *palette = opaque; | ||
57 | uint32_t data; | ||
58 | while (width > 0) { | ||
59 | data = *(uint32_t *) src; | ||
60 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | ||
61 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | ||
62 | #ifdef SWAP_WORDS | ||
63 | FN_2(6) | ||
64 | FN_2(4) | ||
65 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line4(void *opaque, | ||
66 | } | ||
67 | } | ||
68 | |||
69 | -static void pxa2xx_draw_line8(void *opaque, | ||
70 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
71 | +static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src, | ||
72 | + int width, int deststep) | ||
73 | { | ||
74 | uint32_t *palette = opaque; | ||
75 | uint32_t data; | ||
76 | while (width > 0) { | ||
77 | data = *(uint32_t *) src; | ||
78 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
79 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
80 | #ifdef SWAP_WORDS | ||
81 | FN(24) | ||
82 | FN(16) | ||
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line8(void *opaque, | ||
84 | } | ||
85 | } | ||
86 | |||
87 | -static void pxa2xx_draw_line16(void *opaque, | ||
88 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
89 | +static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src, | ||
90 | + int width, int deststep) | ||
91 | { | ||
92 | uint32_t data; | ||
93 | unsigned int r, g, b; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16(void *opaque, | ||
95 | } | ||
96 | } | ||
97 | |||
98 | -static void pxa2xx_draw_line16t(void *opaque, | ||
99 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
100 | +static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
101 | + int width, int deststep) | ||
102 | { | ||
103 | uint32_t data; | ||
104 | unsigned int r, g, b; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque, | ||
106 | } | ||
107 | } | ||
108 | |||
109 | -static void pxa2xx_draw_line18(void *opaque, | ||
110 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
111 | +static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src, | ||
112 | + int width, int deststep) | ||
113 | { | ||
114 | uint32_t data; | ||
115 | unsigned int r, g, b; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line18(void *opaque, | ||
117 | } | ||
118 | |||
119 | /* The wicked packed format */ | ||
120 | -static void pxa2xx_draw_line18p(void *opaque, | ||
121 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
122 | +static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
123 | + int width, int deststep) | ||
124 | { | ||
125 | uint32_t data[3]; | ||
126 | unsigned int r, g, b; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line18p(void *opaque, | ||
128 | } | ||
129 | } | ||
130 | |||
131 | -static void pxa2xx_draw_line19(void *opaque, | ||
132 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
133 | +static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src, | ||
134 | + int width, int deststep) | ||
135 | { | ||
136 | uint32_t data; | ||
137 | unsigned int r, g, b; | ||
138 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19(void *opaque, | ||
139 | } | ||
140 | |||
141 | /* The wicked packed format */ | ||
142 | -static void pxa2xx_draw_line19p(void *opaque, | ||
143 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
144 | +static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
145 | + int width, int deststep) | ||
146 | { | ||
147 | uint32_t data[3]; | ||
148 | unsigned int r, g, b; | ||
149 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque, | ||
150 | } | ||
151 | } | ||
152 | |||
153 | -static void pxa2xx_draw_line24(void *opaque, | ||
154 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
155 | +static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src, | ||
156 | + int width, int deststep) | ||
157 | { | ||
158 | uint32_t data; | ||
159 | unsigned int r, g, b; | ||
160 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24(void *opaque, | ||
161 | } | ||
162 | } | ||
163 | |||
164 | -static void pxa2xx_draw_line24t(void *opaque, | ||
165 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
166 | +static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
167 | + int width, int deststep) | ||
168 | { | ||
169 | uint32_t data; | ||
170 | unsigned int r, g, b; | ||
171 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24t(void *opaque, | ||
172 | } | ||
173 | } | ||
174 | |||
175 | -static void pxa2xx_draw_line25(void *opaque, | ||
176 | - uint8_t *dest, const uint8_t *src, int width, int deststep) | ||
177 | +static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src, | ||
178 | + int width, int deststep) | ||
179 | { | ||
180 | uint32_t data; | ||
181 | unsigned int r, g, b; | ||
182 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line25(void *opaque, | ||
183 | } | ||
184 | |||
185 | /* Overlay planes disabled, no transparency */ | ||
186 | -static drawfn pxa2xx_draw_fn_32[16] = | ||
187 | -{ | ||
188 | +static drawfn pxa2xx_draw_fn_32[16] = { | ||
189 | [0 ... 0xf] = NULL, | ||
190 | [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
191 | [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
192 | @@ -XXX,XX +XXX,XX @@ static drawfn pxa2xx_draw_fn_32[16] = | ||
193 | }; | ||
194 | |||
195 | /* Overlay planes enabled, transparency used */ | ||
196 | -static drawfn pxa2xx_draw_fn_32t[16] = | ||
197 | -{ | ||
198 | +static drawfn pxa2xx_draw_fn_32t[16] = { | ||
199 | [0 ... 0xf] = NULL, | ||
200 | [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
201 | [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
202 | -- | ||
203 | 2.20.1 | ||
204 | |||
205 | diff view generated by jsdifflib |
1 | Add entries to MAINTAINERS to cover the newer MPS2 boards and | 1 | The template header is now included only once; just inline its contents |
---|---|---|---|
2 | the new devices they use. | 2 | in hw/display/pxa2xx_lcd.c. |
3 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20180518153157.14899-1-peter.maydell@linaro.org | 5 | Acked-by: Gerd Hoffmann <kraxel@redhat.com> |
6 | Message-id: 20210211141515.8755-10-peter.maydell@linaro.org | ||
6 | --- | 7 | --- |
7 | MAINTAINERS | 9 +++++++-- | 8 | hw/display/pxa2xx_template.h | 434 ----------------------------------- |
8 | 1 file changed, 7 insertions(+), 2 deletions(-) | 9 | hw/display/pxa2xx_lcd.c | 427 +++++++++++++++++++++++++++++++++- |
10 | 2 files changed, 425 insertions(+), 436 deletions(-) | ||
11 | delete mode 100644 hw/display/pxa2xx_template.h | ||
9 | 12 | ||
10 | diff --git a/MAINTAINERS b/MAINTAINERS | 13 | diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h |
14 | deleted file mode 100644 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- a/hw/display/pxa2xx_template.h | ||
17 | +++ /dev/null | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | -/* | ||
20 | - * Intel XScale PXA255/270 LCDC emulation. | ||
21 | - * | ||
22 | - * Copyright (c) 2006 Openedhand Ltd. | ||
23 | - * Written by Andrzej Zaborowski <balrog@zabor.org> | ||
24 | - * | ||
25 | - * This code is licensed under the GPLv2. | ||
26 | - * | ||
27 | - * Framebuffer format conversion routines. | ||
28 | - */ | ||
29 | - | ||
30 | -# define SKIP_PIXEL(to) do { to += deststep; } while (0) | ||
31 | -# define COPY_PIXEL(to, from) \ | ||
32 | - do { \ | ||
33 | - *(uint32_t *) to = from; \ | ||
34 | - SKIP_PIXEL(to); \ | ||
35 | - } while (0) | ||
36 | - | ||
37 | -#ifdef HOST_WORDS_BIGENDIAN | ||
38 | -# define SWAP_WORDS 1 | ||
39 | -#endif | ||
40 | - | ||
41 | -#define FN_2(x) FN(x + 1) FN(x) | ||
42 | -#define FN_4(x) FN_2(x + 2) FN_2(x) | ||
43 | - | ||
44 | -static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src, | ||
45 | - int width, int deststep) | ||
46 | -{ | ||
47 | - uint32_t *palette = opaque; | ||
48 | - uint32_t data; | ||
49 | - while (width > 0) { | ||
50 | - data = *(uint32_t *) src; | ||
51 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
52 | -#ifdef SWAP_WORDS | ||
53 | - FN_4(12) | ||
54 | - FN_4(8) | ||
55 | - FN_4(4) | ||
56 | - FN_4(0) | ||
57 | -#else | ||
58 | - FN_4(0) | ||
59 | - FN_4(4) | ||
60 | - FN_4(8) | ||
61 | - FN_4(12) | ||
62 | -#endif | ||
63 | -#undef FN | ||
64 | - width -= 16; | ||
65 | - src += 4; | ||
66 | - } | ||
67 | -} | ||
68 | - | ||
69 | -static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src, | ||
70 | - int width, int deststep) | ||
71 | -{ | ||
72 | - uint32_t *palette = opaque; | ||
73 | - uint32_t data; | ||
74 | - while (width > 0) { | ||
75 | - data = *(uint32_t *) src; | ||
76 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | ||
77 | -#ifdef SWAP_WORDS | ||
78 | - FN_2(6) | ||
79 | - FN_2(4) | ||
80 | - FN_2(2) | ||
81 | - FN_2(0) | ||
82 | -#else | ||
83 | - FN_2(0) | ||
84 | - FN_2(2) | ||
85 | - FN_2(4) | ||
86 | - FN_2(6) | ||
87 | -#endif | ||
88 | -#undef FN | ||
89 | - width -= 8; | ||
90 | - src += 4; | ||
91 | - } | ||
92 | -} | ||
93 | - | ||
94 | -static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src, | ||
95 | - int width, int deststep) | ||
96 | -{ | ||
97 | - uint32_t *palette = opaque; | ||
98 | - uint32_t data; | ||
99 | - while (width > 0) { | ||
100 | - data = *(uint32_t *) src; | ||
101 | -#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
102 | -#ifdef SWAP_WORDS | ||
103 | - FN(24) | ||
104 | - FN(16) | ||
105 | - FN(8) | ||
106 | - FN(0) | ||
107 | -#else | ||
108 | - FN(0) | ||
109 | - FN(8) | ||
110 | - FN(16) | ||
111 | - FN(24) | ||
112 | -#endif | ||
113 | -#undef FN | ||
114 | - width -= 4; | ||
115 | - src += 4; | ||
116 | - } | ||
117 | -} | ||
118 | - | ||
119 | -static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src, | ||
120 | - int width, int deststep) | ||
121 | -{ | ||
122 | - uint32_t data; | ||
123 | - unsigned int r, g, b; | ||
124 | - while (width > 0) { | ||
125 | - data = *(uint32_t *) src; | ||
126 | -#ifdef SWAP_WORDS | ||
127 | - data = bswap32(data); | ||
128 | -#endif | ||
129 | - b = (data & 0x1f) << 3; | ||
130 | - data >>= 5; | ||
131 | - g = (data & 0x3f) << 2; | ||
132 | - data >>= 6; | ||
133 | - r = (data & 0x1f) << 3; | ||
134 | - data >>= 5; | ||
135 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
136 | - b = (data & 0x1f) << 3; | ||
137 | - data >>= 5; | ||
138 | - g = (data & 0x3f) << 2; | ||
139 | - data >>= 6; | ||
140 | - r = (data & 0x1f) << 3; | ||
141 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
142 | - width -= 2; | ||
143 | - src += 4; | ||
144 | - } | ||
145 | -} | ||
146 | - | ||
147 | -static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
148 | - int width, int deststep) | ||
149 | -{ | ||
150 | - uint32_t data; | ||
151 | - unsigned int r, g, b; | ||
152 | - while (width > 0) { | ||
153 | - data = *(uint32_t *) src; | ||
154 | -#ifdef SWAP_WORDS | ||
155 | - data = bswap32(data); | ||
156 | -#endif | ||
157 | - b = (data & 0x1f) << 3; | ||
158 | - data >>= 5; | ||
159 | - g = (data & 0x1f) << 3; | ||
160 | - data >>= 5; | ||
161 | - r = (data & 0x1f) << 3; | ||
162 | - data >>= 5; | ||
163 | - if (data & 1) { | ||
164 | - SKIP_PIXEL(dest); | ||
165 | - } else { | ||
166 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
167 | - } | ||
168 | - data >>= 1; | ||
169 | - b = (data & 0x1f) << 3; | ||
170 | - data >>= 5; | ||
171 | - g = (data & 0x1f) << 3; | ||
172 | - data >>= 5; | ||
173 | - r = (data & 0x1f) << 3; | ||
174 | - data >>= 5; | ||
175 | - if (data & 1) { | ||
176 | - SKIP_PIXEL(dest); | ||
177 | - } else { | ||
178 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
179 | - } | ||
180 | - width -= 2; | ||
181 | - src += 4; | ||
182 | - } | ||
183 | -} | ||
184 | - | ||
185 | -static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src, | ||
186 | - int width, int deststep) | ||
187 | -{ | ||
188 | - uint32_t data; | ||
189 | - unsigned int r, g, b; | ||
190 | - while (width > 0) { | ||
191 | - data = *(uint32_t *) src; | ||
192 | -#ifdef SWAP_WORDS | ||
193 | - data = bswap32(data); | ||
194 | -#endif | ||
195 | - b = (data & 0x3f) << 2; | ||
196 | - data >>= 6; | ||
197 | - g = (data & 0x3f) << 2; | ||
198 | - data >>= 6; | ||
199 | - r = (data & 0x3f) << 2; | ||
200 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
201 | - width -= 1; | ||
202 | - src += 4; | ||
203 | - } | ||
204 | -} | ||
205 | - | ||
206 | -/* The wicked packed format */ | ||
207 | -static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
208 | - int width, int deststep) | ||
209 | -{ | ||
210 | - uint32_t data[3]; | ||
211 | - unsigned int r, g, b; | ||
212 | - while (width > 0) { | ||
213 | - data[0] = *(uint32_t *) src; | ||
214 | - src += 4; | ||
215 | - data[1] = *(uint32_t *) src; | ||
216 | - src += 4; | ||
217 | - data[2] = *(uint32_t *) src; | ||
218 | - src += 4; | ||
219 | -#ifdef SWAP_WORDS | ||
220 | - data[0] = bswap32(data[0]); | ||
221 | - data[1] = bswap32(data[1]); | ||
222 | - data[2] = bswap32(data[2]); | ||
223 | -#endif | ||
224 | - b = (data[0] & 0x3f) << 2; | ||
225 | - data[0] >>= 6; | ||
226 | - g = (data[0] & 0x3f) << 2; | ||
227 | - data[0] >>= 6; | ||
228 | - r = (data[0] & 0x3f) << 2; | ||
229 | - data[0] >>= 12; | ||
230 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
231 | - b = (data[0] & 0x3f) << 2; | ||
232 | - data[0] >>= 6; | ||
233 | - g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
234 | - data[1] >>= 4; | ||
235 | - r = (data[1] & 0x3f) << 2; | ||
236 | - data[1] >>= 12; | ||
237 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
238 | - b = (data[1] & 0x3f) << 2; | ||
239 | - data[1] >>= 6; | ||
240 | - g = (data[1] & 0x3f) << 2; | ||
241 | - data[1] >>= 6; | ||
242 | - r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
243 | - data[2] >>= 8; | ||
244 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
245 | - b = (data[2] & 0x3f) << 2; | ||
246 | - data[2] >>= 6; | ||
247 | - g = (data[2] & 0x3f) << 2; | ||
248 | - data[2] >>= 6; | ||
249 | - r = data[2] << 2; | ||
250 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
251 | - width -= 4; | ||
252 | - } | ||
253 | -} | ||
254 | - | ||
255 | -static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src, | ||
256 | - int width, int deststep) | ||
257 | -{ | ||
258 | - uint32_t data; | ||
259 | - unsigned int r, g, b; | ||
260 | - while (width > 0) { | ||
261 | - data = *(uint32_t *) src; | ||
262 | -#ifdef SWAP_WORDS | ||
263 | - data = bswap32(data); | ||
264 | -#endif | ||
265 | - b = (data & 0x3f) << 2; | ||
266 | - data >>= 6; | ||
267 | - g = (data & 0x3f) << 2; | ||
268 | - data >>= 6; | ||
269 | - r = (data & 0x3f) << 2; | ||
270 | - data >>= 6; | ||
271 | - if (data & 1) { | ||
272 | - SKIP_PIXEL(dest); | ||
273 | - } else { | ||
274 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
275 | - } | ||
276 | - width -= 1; | ||
277 | - src += 4; | ||
278 | - } | ||
279 | -} | ||
280 | - | ||
281 | -/* The wicked packed format */ | ||
282 | -static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
283 | - int width, int deststep) | ||
284 | -{ | ||
285 | - uint32_t data[3]; | ||
286 | - unsigned int r, g, b; | ||
287 | - while (width > 0) { | ||
288 | - data[0] = *(uint32_t *) src; | ||
289 | - src += 4; | ||
290 | - data[1] = *(uint32_t *) src; | ||
291 | - src += 4; | ||
292 | - data[2] = *(uint32_t *) src; | ||
293 | - src += 4; | ||
294 | -# ifdef SWAP_WORDS | ||
295 | - data[0] = bswap32(data[0]); | ||
296 | - data[1] = bswap32(data[1]); | ||
297 | - data[2] = bswap32(data[2]); | ||
298 | -# endif | ||
299 | - b = (data[0] & 0x3f) << 2; | ||
300 | - data[0] >>= 6; | ||
301 | - g = (data[0] & 0x3f) << 2; | ||
302 | - data[0] >>= 6; | ||
303 | - r = (data[0] & 0x3f) << 2; | ||
304 | - data[0] >>= 6; | ||
305 | - if (data[0] & 1) { | ||
306 | - SKIP_PIXEL(dest); | ||
307 | - } else { | ||
308 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
309 | - } | ||
310 | - data[0] >>= 6; | ||
311 | - b = (data[0] & 0x3f) << 2; | ||
312 | - data[0] >>= 6; | ||
313 | - g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
314 | - data[1] >>= 4; | ||
315 | - r = (data[1] & 0x3f) << 2; | ||
316 | - data[1] >>= 6; | ||
317 | - if (data[1] & 1) { | ||
318 | - SKIP_PIXEL(dest); | ||
319 | - } else { | ||
320 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
321 | - } | ||
322 | - data[1] >>= 6; | ||
323 | - b = (data[1] & 0x3f) << 2; | ||
324 | - data[1] >>= 6; | ||
325 | - g = (data[1] & 0x3f) << 2; | ||
326 | - data[1] >>= 6; | ||
327 | - r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
328 | - data[2] >>= 2; | ||
329 | - if (data[2] & 1) { | ||
330 | - SKIP_PIXEL(dest); | ||
331 | - } else { | ||
332 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
333 | - } | ||
334 | - data[2] >>= 6; | ||
335 | - b = (data[2] & 0x3f) << 2; | ||
336 | - data[2] >>= 6; | ||
337 | - g = (data[2] & 0x3f) << 2; | ||
338 | - data[2] >>= 6; | ||
339 | - r = data[2] << 2; | ||
340 | - data[2] >>= 6; | ||
341 | - if (data[2] & 1) { | ||
342 | - SKIP_PIXEL(dest); | ||
343 | - } else { | ||
344 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
345 | - } | ||
346 | - width -= 4; | ||
347 | - } | ||
348 | -} | ||
349 | - | ||
350 | -static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src, | ||
351 | - int width, int deststep) | ||
352 | -{ | ||
353 | - uint32_t data; | ||
354 | - unsigned int r, g, b; | ||
355 | - while (width > 0) { | ||
356 | - data = *(uint32_t *) src; | ||
357 | -#ifdef SWAP_WORDS | ||
358 | - data = bswap32(data); | ||
359 | -#endif | ||
360 | - b = data & 0xff; | ||
361 | - data >>= 8; | ||
362 | - g = data & 0xff; | ||
363 | - data >>= 8; | ||
364 | - r = data & 0xff; | ||
365 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
366 | - width -= 1; | ||
367 | - src += 4; | ||
368 | - } | ||
369 | -} | ||
370 | - | ||
371 | -static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
372 | - int width, int deststep) | ||
373 | -{ | ||
374 | - uint32_t data; | ||
375 | - unsigned int r, g, b; | ||
376 | - while (width > 0) { | ||
377 | - data = *(uint32_t *) src; | ||
378 | -#ifdef SWAP_WORDS | ||
379 | - data = bswap32(data); | ||
380 | -#endif | ||
381 | - b = (data & 0x7f) << 1; | ||
382 | - data >>= 7; | ||
383 | - g = data & 0xff; | ||
384 | - data >>= 8; | ||
385 | - r = data & 0xff; | ||
386 | - data >>= 8; | ||
387 | - if (data & 1) { | ||
388 | - SKIP_PIXEL(dest); | ||
389 | - } else { | ||
390 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
391 | - } | ||
392 | - width -= 1; | ||
393 | - src += 4; | ||
394 | - } | ||
395 | -} | ||
396 | - | ||
397 | -static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src, | ||
398 | - int width, int deststep) | ||
399 | -{ | ||
400 | - uint32_t data; | ||
401 | - unsigned int r, g, b; | ||
402 | - while (width > 0) { | ||
403 | - data = *(uint32_t *) src; | ||
404 | -#ifdef SWAP_WORDS | ||
405 | - data = bswap32(data); | ||
406 | -#endif | ||
407 | - b = data & 0xff; | ||
408 | - data >>= 8; | ||
409 | - g = data & 0xff; | ||
410 | - data >>= 8; | ||
411 | - r = data & 0xff; | ||
412 | - data >>= 8; | ||
413 | - if (data & 1) { | ||
414 | - SKIP_PIXEL(dest); | ||
415 | - } else { | ||
416 | - COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
417 | - } | ||
418 | - width -= 1; | ||
419 | - src += 4; | ||
420 | - } | ||
421 | -} | ||
422 | - | ||
423 | -/* Overlay planes disabled, no transparency */ | ||
424 | -static drawfn pxa2xx_draw_fn_32[16] = { | ||
425 | - [0 ... 0xf] = NULL, | ||
426 | - [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
427 | - [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
428 | - [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
429 | - [pxa_lcdc_16bpp] = pxa2xx_draw_line16, | ||
430 | - [pxa_lcdc_18bpp] = pxa2xx_draw_line18, | ||
431 | - [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p, | ||
432 | - [pxa_lcdc_24bpp] = pxa2xx_draw_line24, | ||
433 | -}; | ||
434 | - | ||
435 | -/* Overlay planes enabled, transparency used */ | ||
436 | -static drawfn pxa2xx_draw_fn_32t[16] = { | ||
437 | - [0 ... 0xf] = NULL, | ||
438 | - [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
439 | - [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
440 | - [pxa_lcdc_16bpp] = pxa2xx_draw_line16t, | ||
441 | - [pxa_lcdc_19bpp] = pxa2xx_draw_line19, | ||
442 | - [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p, | ||
443 | - [pxa_lcdc_24bpp] = pxa2xx_draw_line24t, | ||
444 | - [pxa_lcdc_25bpp] = pxa2xx_draw_line25, | ||
445 | -}; | ||
446 | - | ||
447 | -#undef COPY_PIXEL | ||
448 | -#undef SKIP_PIXEL | ||
449 | - | ||
450 | -#ifdef SWAP_WORDS | ||
451 | -# undef SWAP_WORDS | ||
452 | -#endif | ||
453 | diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | 454 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/MAINTAINERS | 455 | --- a/hw/display/pxa2xx_lcd.c |
13 | +++ b/MAINTAINERS | 456 | +++ b/hw/display/pxa2xx_lcd.c |
14 | @@ -XXX,XX +XXX,XX @@ F: hw/timer/cmsdk-apb-timer.c | 457 | @@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED { |
15 | F: include/hw/timer/cmsdk-apb-timer.h | 458 | /* Size of a pixel in the QEMU UI output surface, in bytes */ |
16 | F: hw/char/cmsdk-apb-uart.c | 459 | #define DEST_PIXEL_WIDTH 4 |
17 | F: include/hw/char/cmsdk-apb-uart.h | 460 | |
18 | +F: hw/misc/tz-ppc.c | 461 | -#define BITS 32 |
19 | +F: include/hw/misc/tz-ppc.h | 462 | -#include "pxa2xx_template.h" |
20 | 463 | +/* Line drawing code to handle the various possible guest pixel formats */ | |
21 | ARM cores | 464 | + |
22 | M: Peter Maydell <peter.maydell@linaro.org> | 465 | +# define SKIP_PIXEL(to) do { to += deststep; } while (0) |
23 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | 466 | +# define COPY_PIXEL(to, from) \ |
24 | L: qemu-arm@nongnu.org | 467 | + do { \ |
25 | S: Maintained | 468 | + *(uint32_t *) to = from; \ |
26 | F: hw/arm/mps2.c | 469 | + SKIP_PIXEL(to); \ |
27 | -F: hw/misc/mps2-scc.c | 470 | + } while (0) |
28 | -F: include/hw/misc/mps2-scc.h | 471 | + |
29 | +F: hw/arm/mps2-tz.c | 472 | +#ifdef HOST_WORDS_BIGENDIAN |
30 | +F: hw/misc/mps2-*.c | 473 | +# define SWAP_WORDS 1 |
31 | +F: include/hw/misc/mps2-*.h | 474 | +#endif |
32 | +F: hw/arm/iotkit.c | 475 | + |
33 | +F: include/hw/arm/iotkit.h | 476 | +#define FN_2(x) FN(x + 1) FN(x) |
34 | 477 | +#define FN_4(x) FN_2(x + 2) FN_2(x) | |
35 | Musicpal | 478 | + |
36 | M: Jan Kiszka <jan.kiszka@web.de> | 479 | +static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src, |
480 | + int width, int deststep) | ||
481 | +{ | ||
482 | + uint32_t *palette = opaque; | ||
483 | + uint32_t data; | ||
484 | + while (width > 0) { | ||
485 | + data = *(uint32_t *) src; | ||
486 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); | ||
487 | +#ifdef SWAP_WORDS | ||
488 | + FN_4(12) | ||
489 | + FN_4(8) | ||
490 | + FN_4(4) | ||
491 | + FN_4(0) | ||
492 | +#else | ||
493 | + FN_4(0) | ||
494 | + FN_4(4) | ||
495 | + FN_4(8) | ||
496 | + FN_4(12) | ||
497 | +#endif | ||
498 | +#undef FN | ||
499 | + width -= 16; | ||
500 | + src += 4; | ||
501 | + } | ||
502 | +} | ||
503 | + | ||
504 | +static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src, | ||
505 | + int width, int deststep) | ||
506 | +{ | ||
507 | + uint32_t *palette = opaque; | ||
508 | + uint32_t data; | ||
509 | + while (width > 0) { | ||
510 | + data = *(uint32_t *) src; | ||
511 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); | ||
512 | +#ifdef SWAP_WORDS | ||
513 | + FN_2(6) | ||
514 | + FN_2(4) | ||
515 | + FN_2(2) | ||
516 | + FN_2(0) | ||
517 | +#else | ||
518 | + FN_2(0) | ||
519 | + FN_2(2) | ||
520 | + FN_2(4) | ||
521 | + FN_2(6) | ||
522 | +#endif | ||
523 | +#undef FN | ||
524 | + width -= 8; | ||
525 | + src += 4; | ||
526 | + } | ||
527 | +} | ||
528 | + | ||
529 | +static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src, | ||
530 | + int width, int deststep) | ||
531 | +{ | ||
532 | + uint32_t *palette = opaque; | ||
533 | + uint32_t data; | ||
534 | + while (width > 0) { | ||
535 | + data = *(uint32_t *) src; | ||
536 | +#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); | ||
537 | +#ifdef SWAP_WORDS | ||
538 | + FN(24) | ||
539 | + FN(16) | ||
540 | + FN(8) | ||
541 | + FN(0) | ||
542 | +#else | ||
543 | + FN(0) | ||
544 | + FN(8) | ||
545 | + FN(16) | ||
546 | + FN(24) | ||
547 | +#endif | ||
548 | +#undef FN | ||
549 | + width -= 4; | ||
550 | + src += 4; | ||
551 | + } | ||
552 | +} | ||
553 | + | ||
554 | +static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src, | ||
555 | + int width, int deststep) | ||
556 | +{ | ||
557 | + uint32_t data; | ||
558 | + unsigned int r, g, b; | ||
559 | + while (width > 0) { | ||
560 | + data = *(uint32_t *) src; | ||
561 | +#ifdef SWAP_WORDS | ||
562 | + data = bswap32(data); | ||
563 | +#endif | ||
564 | + b = (data & 0x1f) << 3; | ||
565 | + data >>= 5; | ||
566 | + g = (data & 0x3f) << 2; | ||
567 | + data >>= 6; | ||
568 | + r = (data & 0x1f) << 3; | ||
569 | + data >>= 5; | ||
570 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
571 | + b = (data & 0x1f) << 3; | ||
572 | + data >>= 5; | ||
573 | + g = (data & 0x3f) << 2; | ||
574 | + data >>= 6; | ||
575 | + r = (data & 0x1f) << 3; | ||
576 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
577 | + width -= 2; | ||
578 | + src += 4; | ||
579 | + } | ||
580 | +} | ||
581 | + | ||
582 | +static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
583 | + int width, int deststep) | ||
584 | +{ | ||
585 | + uint32_t data; | ||
586 | + unsigned int r, g, b; | ||
587 | + while (width > 0) { | ||
588 | + data = *(uint32_t *) src; | ||
589 | +#ifdef SWAP_WORDS | ||
590 | + data = bswap32(data); | ||
591 | +#endif | ||
592 | + b = (data & 0x1f) << 3; | ||
593 | + data >>= 5; | ||
594 | + g = (data & 0x1f) << 3; | ||
595 | + data >>= 5; | ||
596 | + r = (data & 0x1f) << 3; | ||
597 | + data >>= 5; | ||
598 | + if (data & 1) { | ||
599 | + SKIP_PIXEL(dest); | ||
600 | + } else { | ||
601 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
602 | + } | ||
603 | + data >>= 1; | ||
604 | + b = (data & 0x1f) << 3; | ||
605 | + data >>= 5; | ||
606 | + g = (data & 0x1f) << 3; | ||
607 | + data >>= 5; | ||
608 | + r = (data & 0x1f) << 3; | ||
609 | + data >>= 5; | ||
610 | + if (data & 1) { | ||
611 | + SKIP_PIXEL(dest); | ||
612 | + } else { | ||
613 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
614 | + } | ||
615 | + width -= 2; | ||
616 | + src += 4; | ||
617 | + } | ||
618 | +} | ||
619 | + | ||
620 | +static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src, | ||
621 | + int width, int deststep) | ||
622 | +{ | ||
623 | + uint32_t data; | ||
624 | + unsigned int r, g, b; | ||
625 | + while (width > 0) { | ||
626 | + data = *(uint32_t *) src; | ||
627 | +#ifdef SWAP_WORDS | ||
628 | + data = bswap32(data); | ||
629 | +#endif | ||
630 | + b = (data & 0x3f) << 2; | ||
631 | + data >>= 6; | ||
632 | + g = (data & 0x3f) << 2; | ||
633 | + data >>= 6; | ||
634 | + r = (data & 0x3f) << 2; | ||
635 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
636 | + width -= 1; | ||
637 | + src += 4; | ||
638 | + } | ||
639 | +} | ||
640 | + | ||
641 | +/* The wicked packed format */ | ||
642 | +static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
643 | + int width, int deststep) | ||
644 | +{ | ||
645 | + uint32_t data[3]; | ||
646 | + unsigned int r, g, b; | ||
647 | + while (width > 0) { | ||
648 | + data[0] = *(uint32_t *) src; | ||
649 | + src += 4; | ||
650 | + data[1] = *(uint32_t *) src; | ||
651 | + src += 4; | ||
652 | + data[2] = *(uint32_t *) src; | ||
653 | + src += 4; | ||
654 | +#ifdef SWAP_WORDS | ||
655 | + data[0] = bswap32(data[0]); | ||
656 | + data[1] = bswap32(data[1]); | ||
657 | + data[2] = bswap32(data[2]); | ||
658 | +#endif | ||
659 | + b = (data[0] & 0x3f) << 2; | ||
660 | + data[0] >>= 6; | ||
661 | + g = (data[0] & 0x3f) << 2; | ||
662 | + data[0] >>= 6; | ||
663 | + r = (data[0] & 0x3f) << 2; | ||
664 | + data[0] >>= 12; | ||
665 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
666 | + b = (data[0] & 0x3f) << 2; | ||
667 | + data[0] >>= 6; | ||
668 | + g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
669 | + data[1] >>= 4; | ||
670 | + r = (data[1] & 0x3f) << 2; | ||
671 | + data[1] >>= 12; | ||
672 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
673 | + b = (data[1] & 0x3f) << 2; | ||
674 | + data[1] >>= 6; | ||
675 | + g = (data[1] & 0x3f) << 2; | ||
676 | + data[1] >>= 6; | ||
677 | + r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
678 | + data[2] >>= 8; | ||
679 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
680 | + b = (data[2] & 0x3f) << 2; | ||
681 | + data[2] >>= 6; | ||
682 | + g = (data[2] & 0x3f) << 2; | ||
683 | + data[2] >>= 6; | ||
684 | + r = data[2] << 2; | ||
685 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
686 | + width -= 4; | ||
687 | + } | ||
688 | +} | ||
689 | + | ||
690 | +static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src, | ||
691 | + int width, int deststep) | ||
692 | +{ | ||
693 | + uint32_t data; | ||
694 | + unsigned int r, g, b; | ||
695 | + while (width > 0) { | ||
696 | + data = *(uint32_t *) src; | ||
697 | +#ifdef SWAP_WORDS | ||
698 | + data = bswap32(data); | ||
699 | +#endif | ||
700 | + b = (data & 0x3f) << 2; | ||
701 | + data >>= 6; | ||
702 | + g = (data & 0x3f) << 2; | ||
703 | + data >>= 6; | ||
704 | + r = (data & 0x3f) << 2; | ||
705 | + data >>= 6; | ||
706 | + if (data & 1) { | ||
707 | + SKIP_PIXEL(dest); | ||
708 | + } else { | ||
709 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
710 | + } | ||
711 | + width -= 1; | ||
712 | + src += 4; | ||
713 | + } | ||
714 | +} | ||
715 | + | ||
716 | +/* The wicked packed format */ | ||
717 | +static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src, | ||
718 | + int width, int deststep) | ||
719 | +{ | ||
720 | + uint32_t data[3]; | ||
721 | + unsigned int r, g, b; | ||
722 | + while (width > 0) { | ||
723 | + data[0] = *(uint32_t *) src; | ||
724 | + src += 4; | ||
725 | + data[1] = *(uint32_t *) src; | ||
726 | + src += 4; | ||
727 | + data[2] = *(uint32_t *) src; | ||
728 | + src += 4; | ||
729 | +# ifdef SWAP_WORDS | ||
730 | + data[0] = bswap32(data[0]); | ||
731 | + data[1] = bswap32(data[1]); | ||
732 | + data[2] = bswap32(data[2]); | ||
733 | +# endif | ||
734 | + b = (data[0] & 0x3f) << 2; | ||
735 | + data[0] >>= 6; | ||
736 | + g = (data[0] & 0x3f) << 2; | ||
737 | + data[0] >>= 6; | ||
738 | + r = (data[0] & 0x3f) << 2; | ||
739 | + data[0] >>= 6; | ||
740 | + if (data[0] & 1) { | ||
741 | + SKIP_PIXEL(dest); | ||
742 | + } else { | ||
743 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
744 | + } | ||
745 | + data[0] >>= 6; | ||
746 | + b = (data[0] & 0x3f) << 2; | ||
747 | + data[0] >>= 6; | ||
748 | + g = ((data[1] & 0xf) << 4) | (data[0] << 2); | ||
749 | + data[1] >>= 4; | ||
750 | + r = (data[1] & 0x3f) << 2; | ||
751 | + data[1] >>= 6; | ||
752 | + if (data[1] & 1) { | ||
753 | + SKIP_PIXEL(dest); | ||
754 | + } else { | ||
755 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
756 | + } | ||
757 | + data[1] >>= 6; | ||
758 | + b = (data[1] & 0x3f) << 2; | ||
759 | + data[1] >>= 6; | ||
760 | + g = (data[1] & 0x3f) << 2; | ||
761 | + data[1] >>= 6; | ||
762 | + r = ((data[2] & 0x3) << 6) | (data[1] << 2); | ||
763 | + data[2] >>= 2; | ||
764 | + if (data[2] & 1) { | ||
765 | + SKIP_PIXEL(dest); | ||
766 | + } else { | ||
767 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
768 | + } | ||
769 | + data[2] >>= 6; | ||
770 | + b = (data[2] & 0x3f) << 2; | ||
771 | + data[2] >>= 6; | ||
772 | + g = (data[2] & 0x3f) << 2; | ||
773 | + data[2] >>= 6; | ||
774 | + r = data[2] << 2; | ||
775 | + data[2] >>= 6; | ||
776 | + if (data[2] & 1) { | ||
777 | + SKIP_PIXEL(dest); | ||
778 | + } else { | ||
779 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
780 | + } | ||
781 | + width -= 4; | ||
782 | + } | ||
783 | +} | ||
784 | + | ||
785 | +static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src, | ||
786 | + int width, int deststep) | ||
787 | +{ | ||
788 | + uint32_t data; | ||
789 | + unsigned int r, g, b; | ||
790 | + while (width > 0) { | ||
791 | + data = *(uint32_t *) src; | ||
792 | +#ifdef SWAP_WORDS | ||
793 | + data = bswap32(data); | ||
794 | +#endif | ||
795 | + b = data & 0xff; | ||
796 | + data >>= 8; | ||
797 | + g = data & 0xff; | ||
798 | + data >>= 8; | ||
799 | + r = data & 0xff; | ||
800 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
801 | + width -= 1; | ||
802 | + src += 4; | ||
803 | + } | ||
804 | +} | ||
805 | + | ||
806 | +static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src, | ||
807 | + int width, int deststep) | ||
808 | +{ | ||
809 | + uint32_t data; | ||
810 | + unsigned int r, g, b; | ||
811 | + while (width > 0) { | ||
812 | + data = *(uint32_t *) src; | ||
813 | +#ifdef SWAP_WORDS | ||
814 | + data = bswap32(data); | ||
815 | +#endif | ||
816 | + b = (data & 0x7f) << 1; | ||
817 | + data >>= 7; | ||
818 | + g = data & 0xff; | ||
819 | + data >>= 8; | ||
820 | + r = data & 0xff; | ||
821 | + data >>= 8; | ||
822 | + if (data & 1) { | ||
823 | + SKIP_PIXEL(dest); | ||
824 | + } else { | ||
825 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
826 | + } | ||
827 | + width -= 1; | ||
828 | + src += 4; | ||
829 | + } | ||
830 | +} | ||
831 | + | ||
832 | +static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src, | ||
833 | + int width, int deststep) | ||
834 | +{ | ||
835 | + uint32_t data; | ||
836 | + unsigned int r, g, b; | ||
837 | + while (width > 0) { | ||
838 | + data = *(uint32_t *) src; | ||
839 | +#ifdef SWAP_WORDS | ||
840 | + data = bswap32(data); | ||
841 | +#endif | ||
842 | + b = data & 0xff; | ||
843 | + data >>= 8; | ||
844 | + g = data & 0xff; | ||
845 | + data >>= 8; | ||
846 | + r = data & 0xff; | ||
847 | + data >>= 8; | ||
848 | + if (data & 1) { | ||
849 | + SKIP_PIXEL(dest); | ||
850 | + } else { | ||
851 | + COPY_PIXEL(dest, rgb_to_pixel32(r, g, b)); | ||
852 | + } | ||
853 | + width -= 1; | ||
854 | + src += 4; | ||
855 | + } | ||
856 | +} | ||
857 | + | ||
858 | +/* Overlay planes disabled, no transparency */ | ||
859 | +static drawfn pxa2xx_draw_fn_32[16] = { | ||
860 | + [0 ... 0xf] = NULL, | ||
861 | + [pxa_lcdc_2bpp] = pxa2xx_draw_line2, | ||
862 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
863 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
864 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16, | ||
865 | + [pxa_lcdc_18bpp] = pxa2xx_draw_line18, | ||
866 | + [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p, | ||
867 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24, | ||
868 | +}; | ||
869 | + | ||
870 | +/* Overlay planes enabled, transparency used */ | ||
871 | +static drawfn pxa2xx_draw_fn_32t[16] = { | ||
872 | + [0 ... 0xf] = NULL, | ||
873 | + [pxa_lcdc_4bpp] = pxa2xx_draw_line4, | ||
874 | + [pxa_lcdc_8bpp] = pxa2xx_draw_line8, | ||
875 | + [pxa_lcdc_16bpp] = pxa2xx_draw_line16t, | ||
876 | + [pxa_lcdc_19bpp] = pxa2xx_draw_line19, | ||
877 | + [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p, | ||
878 | + [pxa_lcdc_24bpp] = pxa2xx_draw_line24t, | ||
879 | + [pxa_lcdc_25bpp] = pxa2xx_draw_line25, | ||
880 | +}; | ||
881 | + | ||
882 | +#undef COPY_PIXEL | ||
883 | +#undef SKIP_PIXEL | ||
884 | + | ||
885 | +#ifdef SWAP_WORDS | ||
886 | +# undef SWAP_WORDS | ||
887 | +#endif | ||
888 | |||
889 | /* Route internal interrupt lines to the global IC */ | ||
890 | static void pxa2xx_lcdc_int_update(PXA2xxLCDState *s) | ||
37 | -- | 891 | -- |
38 | 2.17.1 | 892 | 2.20.1 |
39 | 893 | ||
40 | 894 | diff view generated by jsdifflib |