1 | Target-arm queue... | 1 | Arm queue; bugfixes only. |
---|---|---|---|
2 | 2 | ||
3 | thanks | 3 | thanks |
4 | -- PMM | 4 | -- PMM |
5 | 5 | ||
6 | The following changes since commit 735286a4f88255e1463d42ce28d8d14181fd32d4: | 6 | The following changes since commit 48aa8f0ac536db3550a35c295ff7de94e4c33739: |
7 | 7 | ||
8 | Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20170613' into staging (2017-06-13 13:51:29 +0100) | 8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-11-16' into staging (2020-11-17 11:07:00 +0000) |
9 | 9 | ||
10 | are available in the git repository at: | 10 | are available in the Git repository at: |
11 | 11 | ||
12 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170613 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201117 |
13 | 13 | ||
14 | for you to fetch changes up to 252a7a6a968c279a4636a86b0559ba3a930a90b5: | 14 | for you to fetch changes up to ab135622cf478585bdfcb68b85e4a817d74a0c42: |
15 | 15 | ||
16 | hw/intc/arm_gicv3_its: Allow save/restore (2017-06-13 14:57:01 +0100) | 16 | tmp105: Correct handling of temperature limit checks (2020-11-17 12:56:33 +0000) |
17 | 17 | ||
18 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
19 | target-arm queue: | 19 | target-arm queue: |
20 | * vITS: Support save/restore | 20 | * hw/arm/virt: ARM_VIRT must select ARM_GIC |
21 | * timer/aspeed: Fix timer enablement when reload is not set | 21 | * exynos: Fix bad printf format specifiers |
22 | * aspped: add temperature sensor device | 22 | * hw/input/ps2.c: Remove remnants of printf debug |
23 | * timer.h: Provide better monotonic time on ARM hosts | 23 | * target/openrisc: Remove dead code attempting to check "is timer disabled" |
24 | * exynos4210: various cleanups | 24 | * register: Remove unnecessary NULL check |
25 | * exynos4210: support system poweroff | 25 | * util/cutils: Fix Coverity array overrun in freq_to_str() |
26 | * configure: Make "does libgio work" test pull in some actual functions | ||
27 | * tmp105: reset the T_low and T_High registers | ||
28 | * tmp105: Correct handling of temperature limit checks | ||
26 | 29 | ||
27 | ---------------------------------------------------------------- | 30 | ---------------------------------------------------------------- |
28 | Cédric Le Goater (3): | 31 | Alex Chen (1): |
29 | hw/misc: add a TMP42{1, 2, 3} device model | 32 | exynos: Fix bad printf format specifiers |
30 | aspeed: add a temp sensor device on I2C bus 3 | ||
31 | timer/aspeed: fix timer enablement when a reload is not set | ||
32 | 33 | ||
33 | Eric Auger (4): | 34 | Alistair Francis (1): |
34 | kvm-all: Pass an error object to kvm_device_access | 35 | register: Remove unnecessary NULL check |
35 | hw/intc/arm_gicv3_its: Implement state save/restore | ||
36 | hw/intc/arm_gicv3_kvm: Implement pending table save | ||
37 | hw/intc/arm_gicv3_its: Allow save/restore | ||
38 | 36 | ||
39 | Krzysztof Kozlowski (9): | 37 | Andrew Jones (1): |
40 | hw/intc/exynos4210_gic: Use more meaningful name for local variable | 38 | hw/arm/virt: ARM_VIRT must select ARM_GIC |
41 | hw/timer/exynos4210_mct: Fix checkpatch style errors | ||
42 | hw/timer/exynos4210_mct: Cleanup indentation and empty new lines | ||
43 | hw/timer/exynos4210_mct: Remove unused defines | ||
44 | hw/arm/exynos: Move DRAM initialization next boards | ||
45 | hw/arm/exynos: Declare local variables in some order | ||
46 | hw/arm/exynos: Use type define instead of hard-coded a9mpcore_priv string | ||
47 | hw/intc/exynos4210_gic: Constify array of combiner interrupts | ||
48 | hw/misc/exynos4210_pmu: Add support for system poweroff | ||
49 | 39 | ||
50 | Pranith Kumar (1): | 40 | Peter Maydell (5): |
51 | timer.h: Provide better monotonic time | 41 | hw/input/ps2.c: Remove remnants of printf debug |
42 | target/openrisc: Remove dead code attempting to check "is timer disabled" | ||
43 | configure: Make "does libgio work" test pull in some actual functions | ||
44 | hw/misc/tmp105: reset the T_low and T_High registers | ||
45 | tmp105: Correct handling of temperature limit checks | ||
52 | 46 | ||
53 | hw/misc/Makefile.objs | 1 + | 47 | Philippe Mathieu-Daudé (1): |
54 | include/hw/arm/exynos4210.h | 5 +- | 48 | util/cutils: Fix Coverity array overrun in freq_to_str() |
55 | include/hw/intc/arm_gicv3_its_common.h | 8 + | ||
56 | include/migration/vmstate.h | 2 + | ||
57 | include/qemu/timer.h | 5 +- | ||
58 | include/sysemu/kvm.h | 11 +- | ||
59 | hw/arm/aspeed.c | 9 + | ||
60 | hw/arm/exynos4210.c | 27 +-- | ||
61 | hw/arm/exynos4_boards.c | 50 +++- | ||
62 | hw/intc/arm_gic_kvm.c | 9 +- | ||
63 | hw/intc/arm_gicv3_common.c | 1 + | ||
64 | hw/intc/arm_gicv3_its_common.c | 12 +- | ||
65 | hw/intc/arm_gicv3_its_kvm.c | 131 +++++++++-- | ||
66 | hw/intc/arm_gicv3_kvm.c | 48 +++- | ||
67 | hw/intc/exynos4210_gic.c | 14 +- | ||
68 | hw/misc/exynos4210_pmu.c | 20 +- | ||
69 | hw/misc/tmp421.c | 402 +++++++++++++++++++++++++++++++++ | ||
70 | hw/timer/aspeed_timer.c | 37 ++- | ||
71 | hw/timer/exynos4210_mct.c | 50 ++-- | ||
72 | kvm-all.c | 14 +- | ||
73 | default-configs/arm-softmmu.mak | 1 + | ||
74 | 21 files changed, 741 insertions(+), 116 deletions(-) | ||
75 | create mode 100644 hw/misc/tmp421.c | ||
76 | 49 | ||
50 | configure | 11 +++++-- | ||
51 | hw/misc/tmp105.h | 7 +++++ | ||
52 | hw/core/register.c | 4 --- | ||
53 | hw/input/ps2.c | 9 ------ | ||
54 | hw/misc/tmp105.c | 73 ++++++++++++++++++++++++++++++++++++++------ | ||
55 | hw/timer/exynos4210_mct.c | 4 +-- | ||
56 | hw/timer/exynos4210_pwm.c | 8 ++--- | ||
57 | target/openrisc/sys_helper.c | 3 -- | ||
58 | util/cutils.c | 3 +- | ||
59 | hw/arm/Kconfig | 1 + | ||
60 | 10 files changed, 89 insertions(+), 34 deletions(-) | ||
61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | There are to SysBusDevice variables in exynos4210_gic_realize() | ||
4 | function: one for the device itself and second for arm_gic device. Add | ||
5 | a prefix "gic" to the second one so it will be easier to understand the | ||
6 | code. | ||
7 | |||
8 | While at it, put local uninitialized 'i' variable at the end, next to | ||
9 | other uninitialized ones. | ||
10 | |||
11 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/intc/exynos4210_gic.c | 12 ++++++------ | ||
17 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
18 | |||
19 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/intc/exynos4210_gic.c | ||
22 | +++ b/hw/intc/exynos4210_gic.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_init(Object *obj) | ||
24 | DeviceState *dev = DEVICE(obj); | ||
25 | Exynos4210GicState *s = EXYNOS4210_GIC(obj); | ||
26 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
27 | - uint32_t i; | ||
28 | const char cpu_prefix[] = "exynos4210-gic-alias_cpu"; | ||
29 | const char dist_prefix[] = "exynos4210-gic-alias_dist"; | ||
30 | char cpu_alias_name[sizeof(cpu_prefix) + 3]; | ||
31 | char dist_alias_name[sizeof(cpu_prefix) + 3]; | ||
32 | - SysBusDevice *busdev; | ||
33 | + SysBusDevice *gicbusdev; | ||
34 | + uint32_t i; | ||
35 | |||
36 | s->gic = qdev_create(NULL, "arm_gic"); | ||
37 | qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu); | ||
38 | qdev_prop_set_uint32(s->gic, "num-irq", EXYNOS4210_GIC_NIRQ); | ||
39 | qdev_init_nofail(s->gic); | ||
40 | - busdev = SYS_BUS_DEVICE(s->gic); | ||
41 | + gicbusdev = SYS_BUS_DEVICE(s->gic); | ||
42 | |||
43 | /* Pass through outbound IRQ lines from the GIC */ | ||
44 | - sysbus_pass_irq(sbd, busdev); | ||
45 | + sysbus_pass_irq(sbd, gicbusdev); | ||
46 | |||
47 | /* Pass through inbound GPIO lines to the GIC */ | ||
48 | qdev_init_gpio_in(dev, exynos4210_gic_set_irq, | ||
49 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_init(Object *obj) | ||
50 | sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); | ||
51 | memory_region_init_alias(&s->cpu_alias[i], obj, | ||
52 | cpu_alias_name, | ||
53 | - sysbus_mmio_get_region(busdev, 1), | ||
54 | + sysbus_mmio_get_region(gicbusdev, 1), | ||
55 | 0, | ||
56 | EXYNOS4210_GIC_CPU_REGION_SIZE); | ||
57 | memory_region_add_subregion(&s->cpu_container, | ||
58 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_init(Object *obj) | ||
59 | sprintf(dist_alias_name, "%s%x", dist_prefix, i); | ||
60 | memory_region_init_alias(&s->dist_alias[i], obj, | ||
61 | dist_alias_name, | ||
62 | - sysbus_mmio_get_region(busdev, 0), | ||
63 | + sysbus_mmio_get_region(gicbusdev, 0), | ||
64 | 0, | ||
65 | EXYNOS4210_GIC_DIST_REGION_SIZE); | ||
66 | memory_region_add_subregion(&s->dist_container, | ||
67 | -- | ||
68 | 2.7.4 | ||
69 | |||
70 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Andrew Jones <drjones@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | We change the restoration priority of both the GICv3 and ITS. The | 3 | The removal of the selection of A15MPCORE from ARM_VIRT also |
4 | GICv3 must be restored before the ITS and the ITS needs to be restored | 4 | removed what A15MPCORE selects, ARM_GIC. We still need ARM_GIC. |
5 | before PCIe devices since it translates their MSI transactions. | ||
6 | 5 | ||
7 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 6 | Fixes: bec3c97e0cf9 ("hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals") |
8 | Reviewed-by: Juan Quintela <quintela@redhat.com> | 7 | Reported-by: Miroslav Rezanina <mrezanin@redhat.com> |
9 | Message-id: 1497023553-18411-5-git-send-email-eric.auger@redhat.com | 8 | Signed-off-by: Andrew Jones <drjones@redhat.com> |
9 | Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20201111143440.112763-1-drjones@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | include/migration/vmstate.h | 2 ++ | 14 | hw/arm/Kconfig | 1 + |
13 | hw/intc/arm_gicv3_common.c | 1 + | 15 | 1 file changed, 1 insertion(+) |
14 | hw/intc/arm_gicv3_its_common.c | 2 +- | ||
15 | hw/intc/arm_gicv3_its_kvm.c | 24 ++++++++++++------------ | ||
16 | 4 files changed, 16 insertions(+), 13 deletions(-) | ||
17 | 16 | ||
18 | diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h | 17 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/migration/vmstate.h | 19 | --- a/hw/arm/Kconfig |
21 | +++ b/include/migration/vmstate.h | 20 | +++ b/hw/arm/Kconfig |
22 | @@ -XXX,XX +XXX,XX @@ enum VMStateFlags { | 21 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT |
23 | typedef enum { | 22 | imply VFIO_PLATFORM |
24 | MIG_PRI_DEFAULT = 0, | 23 | imply VFIO_XGMAC |
25 | MIG_PRI_IOMMU, /* Must happen before PCI devices */ | 24 | imply TPM_TIS_SYSBUS |
26 | + MIG_PRI_GICV3_ITS, /* Must happen before PCI devices */ | 25 | + select ARM_GIC |
27 | + MIG_PRI_GICV3, /* Must happen before the ITS */ | 26 | select ACPI |
28 | MIG_PRI_MAX, | 27 | select ARM_SMMUV3 |
29 | } MigrationPriority; | 28 | select GPIO_KEY |
30 | |||
31 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/intc/arm_gicv3_common.c | ||
34 | +++ b/hw/intc/arm_gicv3_common.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = { | ||
36 | .minimum_version_id = 1, | ||
37 | .pre_save = gicv3_pre_save, | ||
38 | .post_load = gicv3_post_load, | ||
39 | + .priority = MIG_PRI_GICV3, | ||
40 | .fields = (VMStateField[]) { | ||
41 | VMSTATE_UINT32(gicd_ctlr, GICv3State), | ||
42 | VMSTATE_UINT32_ARRAY(gicd_statusr, GICv3State, 2), | ||
43 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/intc/arm_gicv3_its_common.c | ||
46 | +++ b/hw/intc/arm_gicv3_its_common.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_its = { | ||
48 | .name = "arm_gicv3_its", | ||
49 | .pre_save = gicv3_its_pre_save, | ||
50 | .post_load = gicv3_its_post_load, | ||
51 | - .unmigratable = true, | ||
52 | + .priority = MIG_PRI_GICV3_ITS, | ||
53 | .fields = (VMStateField[]) { | ||
54 | VMSTATE_UINT32(ctlr, GICv3ITSState), | ||
55 | VMSTATE_UINT32(iidr, GICv3ITSState), | ||
56 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
59 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
61 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | ||
62 | Error *local_err = NULL; | ||
63 | |||
64 | - /* | ||
65 | - * Block migration of a KVM GICv3 ITS device: the API for saving and | ||
66 | - * restoring the state in the kernel is not yet available | ||
67 | - */ | ||
68 | - error_setg(&s->migration_blocker, "vITS migration is not implemented"); | ||
69 | - migrate_add_blocker(s->migration_blocker, &local_err); | ||
70 | - if (local_err) { | ||
71 | - error_propagate(errp, local_err); | ||
72 | - error_free(s->migration_blocker); | ||
73 | - return; | ||
74 | - } | ||
75 | - | ||
76 | s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_ITS, false); | ||
77 | if (s->dev_fd < 0) { | ||
78 | error_setg_errno(errp, -s->dev_fd, "error creating in-kernel ITS"); | ||
79 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
80 | |||
81 | gicv3_its_init_mmio(s, NULL); | ||
82 | |||
83 | + if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
84 | + GITS_CTLR)) { | ||
85 | + error_setg(&s->migration_blocker, "This operating system kernel " | ||
86 | + "does not support vITS migration"); | ||
87 | + migrate_add_blocker(s->migration_blocker, &local_err); | ||
88 | + if (local_err) { | ||
89 | + error_propagate(errp, local_err); | ||
90 | + error_free(s->migration_blocker); | ||
91 | + return; | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | kvm_msi_use_devid = true; | ||
96 | kvm_gsi_direct_mapping = false; | ||
97 | kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled(); | ||
98 | -- | 29 | -- |
99 | 2.7.4 | 30 | 2.20.1 |
100 | 31 | ||
101 | 32 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Fix checkpatch errors: | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | 1. ERROR: spaces required around that '+' (ctx:VxV) | 4 | argument of type "unsigned int". |
5 | 2. ERROR: spaces required around that '&' (ctx:VxV) | ||
6 | 5 | ||
7 | No functional changes. | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
8 | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> | |
9 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 8 | Message-id: 20201111073651.72804-1-alex.chen@huawei.com |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | hw/timer/exynos4210_mct.c | 4 ++-- | 12 | hw/timer/exynos4210_mct.c | 4 ++-- |
15 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | hw/timer/exynos4210_pwm.c | 8 ++++---- |
14 | 2 files changed, 6 insertions(+), 6 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | 16 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/timer/exynos4210_mct.c | 18 | --- a/hw/timer/exynos4210_mct.c |
20 | +++ b/hw/timer/exynos4210_mct.c | 19 | +++ b/hw/timer/exynos4210_mct.c |
20 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gcomp_raise_irq(void *opaque, uint32_t id) | ||
21 | /* If CSTAT is pending and IRQ is enabled */ | ||
22 | if ((s->reg.int_cstat & G_INT_CSTAT_COMP(id)) && | ||
23 | (s->reg.int_enb & G_INT_ENABLE(id))) { | ||
24 | - DPRINTF("gcmp timer[%d] IRQ\n", id); | ||
25 | + DPRINTF("gcmp timer[%u] IRQ\n", id); | ||
26 | qemu_irq_raise(s->irq[id]); | ||
27 | } | ||
28 | } | ||
21 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s) | 29 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s) |
22 | { | ||
23 | uint32_t freq = s->freq; | ||
24 | s->freq = 24000000 / | ||
25 | - ((MCT_CFG_GET_PRESCALER(s->reg_mct_cfg)+1) * | ||
26 | + ((MCT_CFG_GET_PRESCALER(s->reg_mct_cfg) + 1) * | ||
27 | MCT_CFG_GET_DIVIDER(s->reg_mct_cfg)); | 30 | MCT_CFG_GET_DIVIDER(s->reg_mct_cfg)); |
28 | 31 | ||
29 | if (freq != s->freq) { | 32 | if (freq != s->freq) { |
30 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | 33 | - DPRINTF("freq=%dHz\n", s->freq); |
31 | 34 | + DPRINTF("freq=%uHz\n", s->freq); | |
32 | DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift); | 35 | |
33 | 36 | /* global timer */ | |
34 | - if (offset&0x4) { | 37 | tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq); |
35 | + if (offset & 0x4) { | 38 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c |
36 | s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index); | 39 | index XXXXXXX..XXXXXXX 100644 |
37 | } else { | 40 | --- a/hw/timer/exynos4210_pwm.c |
38 | s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); | 41 | +++ b/hw/timer/exynos4210_pwm.c |
42 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_update_freq(Exynos4210PWMState *s, uint32_t id) | ||
43 | |||
44 | if (freq != s->timer[id].freq) { | ||
45 | ptimer_set_freq(s->timer[id].ptimer, s->timer[id].freq); | ||
46 | - DPRINTF("freq=%dHz\n", s->timer[id].freq); | ||
47 | + DPRINTF("freq=%uHz\n", s->timer[id].freq); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque) | ||
52 | uint32_t id = s->id; | ||
53 | bool cmp; | ||
54 | |||
55 | - DPRINTF("timer %d tick\n", id); | ||
56 | + DPRINTF("timer %u tick\n", id); | ||
57 | |||
58 | /* set irq status */ | ||
59 | p->reg_tint_cstat |= TINT_CSTAT_STATUS(id); | ||
60 | |||
61 | /* raise IRQ */ | ||
62 | if (p->reg_tint_cstat & TINT_CSTAT_ENABLE(id)) { | ||
63 | - DPRINTF("timer %d IRQ\n", id); | ||
64 | + DPRINTF("timer %u IRQ\n", id); | ||
65 | qemu_irq_raise(p->timer[id].irq); | ||
66 | } | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque) | ||
69 | } | ||
70 | |||
71 | if (cmp) { | ||
72 | - DPRINTF("auto reload timer %d count to %x\n", id, | ||
73 | + DPRINTF("auto reload timer %u count to %x\n", id, | ||
74 | p->timer[id].reg_tcntb); | ||
75 | ptimer_set_count(p->timer[id].ptimer, p->timer[id].reg_tcntb); | ||
76 | ptimer_run(p->timer[id].ptimer, 1); | ||
39 | -- | 77 | -- |
40 | 2.7.4 | 78 | 2.20.1 |
41 | 79 | ||
42 | 80 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | Statements under 'case' were in some places wrongly indented bringing | ||
4 | confusion and making the code less readable. Remove also few unneeded | ||
5 | blank lines. No functional changes. | ||
6 | |||
7 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/timer/exynos4210_mct.c | 45 ++++++++++++++++++++------------------------- | ||
13 | 1 file changed, 20 insertions(+), 25 deletions(-) | ||
14 | |||
15 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/timer/exynos4210_mct.c | ||
18 | +++ b/hw/timer/exynos4210_mct.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_mct_read(void *opaque, hwaddr offset, | ||
20 | |||
21 | case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3): | ||
22 | case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3): | ||
23 | - index = GET_G_COMP_IDX(offset); | ||
24 | - shift = 8 * (offset & 0x4); | ||
25 | - value = UINT32_MAX & (s->g_timer.reg.comp[index] >> shift); | ||
26 | + index = GET_G_COMP_IDX(offset); | ||
27 | + shift = 8 * (offset & 0x4); | ||
28 | + value = UINT32_MAX & (s->g_timer.reg.comp[index] >> shift); | ||
29 | break; | ||
30 | |||
31 | case G_TCON: | ||
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_mct_read(void *opaque, hwaddr offset, | ||
33 | lt_i = GET_L_TIMER_IDX(offset); | ||
34 | |||
35 | value = exynos4210_lfrc_get_count(&s->l_timer[lt_i]); | ||
36 | - | ||
37 | break; | ||
38 | |||
39 | case L0_TCON: case L1_TCON: | ||
40 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
41 | |||
42 | case G_COMP_L(0): case G_COMP_L(1): case G_COMP_L(2): case G_COMP_L(3): | ||
43 | case G_COMP_U(0): case G_COMP_U(1): case G_COMP_U(2): case G_COMP_U(3): | ||
44 | - index = GET_G_COMP_IDX(offset); | ||
45 | - shift = 8 * (offset & 0x4); | ||
46 | - s->g_timer.reg.comp[index] = | ||
47 | - (s->g_timer.reg.comp[index] & | ||
48 | - (((uint64_t)UINT32_MAX << 32) >> shift)) + | ||
49 | - (value << shift); | ||
50 | + index = GET_G_COMP_IDX(offset); | ||
51 | + shift = 8 * (offset & 0x4); | ||
52 | + s->g_timer.reg.comp[index] = | ||
53 | + (s->g_timer.reg.comp[index] & | ||
54 | + (((uint64_t)UINT32_MAX << 32) >> shift)) + | ||
55 | + (value << shift); | ||
56 | |||
57 | - DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift); | ||
58 | + DPRINTF("comparator %d write 0x%llx val << %d\n", index, value, shift); | ||
59 | |||
60 | - if (offset & 0x4) { | ||
61 | - s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index); | ||
62 | - } else { | ||
63 | - s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); | ||
64 | - } | ||
65 | + if (offset & 0x4) { | ||
66 | + s->g_timer.reg.wstat |= G_WSTAT_COMP_U(index); | ||
67 | + } else { | ||
68 | + s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); | ||
69 | + } | ||
70 | |||
71 | - exynos4210_gfrc_restart(s); | ||
72 | - break; | ||
73 | + exynos4210_gfrc_restart(s); | ||
74 | + break; | ||
75 | |||
76 | case G_TCON: | ||
77 | old_val = s->g_timer.reg.tcon; | ||
78 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
79 | break; | ||
80 | |||
81 | case G_INT_ENB: | ||
82 | - | ||
83 | /* Raise IRQ if transition from disabled to enabled and CSTAT pending */ | ||
84 | for (i = 0; i < MCT_GT_CMP_NUM; i++) { | ||
85 | if ((value & G_INT_ENABLE(i)) > (s->g_timer.reg.tcon & | ||
86 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
87 | break; | ||
88 | |||
89 | case L0_TCNTB: case L1_TCNTB: | ||
90 | - | ||
91 | lt_i = GET_L_TIMER_IDX(offset); | ||
92 | index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); | ||
93 | |||
94 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
95 | break; | ||
96 | |||
97 | case L0_ICNTB: case L1_ICNTB: | ||
98 | - | ||
99 | lt_i = GET_L_TIMER_IDX(offset); | ||
100 | index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, | ||
103 | if (icntb_max[lt_i] < value) { | ||
104 | icntb_max[lt_i] = value; | ||
105 | } | ||
106 | -DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n", | ||
107 | - lt_i, value, icntb_max[lt_i], icntb_min[lt_i]); | ||
108 | + DPRINTF("local timer[%d] ICNTB write %llx; max=%x, min=%x\n\n", | ||
109 | + lt_i, value, icntb_max[lt_i], icntb_min[lt_i]); | ||
110 | #endif | ||
111 | -break; | ||
112 | + break; | ||
113 | |||
114 | case L0_FRCNTB: case L1_FRCNTB: | ||
115 | - | ||
116 | lt_i = GET_L_TIMER_IDX(offset); | ||
117 | index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i); | ||
118 | |||
119 | -- | ||
120 | 2.7.4 | ||
121 | |||
122 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | In commit 5edab03d4040 we added tracepoints to the ps2 keyboard |
---|---|---|---|
2 | and mouse emulation. However we didn't remove all the debug-by-printf | ||
3 | support. In fact there is only one printf() remaining, and it is | ||
4 | redundant with the trace_ps2_write_mouse() event next to it. | ||
5 | Remove the printf() and the now-unused DEBUG* macros. | ||
2 | 6 | ||
3 | On all Exynos-based boards, the system powers down itself by driving | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | PS_HOLD signal low - eight bit in PS_HOLD_CONTROL register of PMU. | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | Handle writing to respective PMU register to fix power off failure: | 9 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> |
10 | Message-id: 20201101133258.4240-1-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/input/ps2.c | 9 --------- | ||
13 | 1 file changed, 9 deletions(-) | ||
6 | 14 | ||
7 | reboot: Power down | 15 | diff --git a/hw/input/ps2.c b/hw/input/ps2.c |
8 | Unable to poweroff system | ||
9 | shutdown: 31 output lines suppressed due to ratelimiting | ||
10 | Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000 | ||
11 | |||
12 | CPU: 0 PID: 1 Comm: shutdown Not tainted 4.11.0-rc8 #846 | ||
13 | Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) | ||
14 | [<c031050c>] (unwind_backtrace) from [<c030ba6c>] (show_stack+0x10/0x14) | ||
15 | [<c030ba6c>] (show_stack) from [<c05b2800>] (dump_stack+0x88/0x9c) | ||
16 | [<c05b2800>] (dump_stack) from [<c03d3140>] (panic+0xdc/0x268) | ||
17 | [<c03d3140>] (panic) from [<c0343614>] (do_exit+0xa90/0xab4) | ||
18 | [<c0343614>] (do_exit) from [<c035f2dc>] (SyS_reboot+0x164/0x1d0) | ||
19 | [<c035f2dc>] (SyS_reboot) from [<c0307c80>] (ret_fast_syscall+0x0/0x3c) | ||
20 | |||
21 | Additionally the initial value of PS_HOLD has to be changed because | ||
22 | recent Linux kernel (v4.12-rc1) uses regmap cache for this access. | ||
23 | When the register is kept at reset value, the kernel will not issue a | ||
24 | write to it. Usually the bootloader sets the eight bit of PS_HOLD high | ||
25 | so mimic its existence here. | ||
26 | |||
27 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
28 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
29 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
31 | --- | ||
32 | hw/misc/exynos4210_pmu.c | 20 +++++++++++++++++++- | ||
33 | 1 file changed, 19 insertions(+), 1 deletion(-) | ||
34 | |||
35 | diff --git a/hw/misc/exynos4210_pmu.c b/hw/misc/exynos4210_pmu.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/misc/exynos4210_pmu.c | 17 | --- a/hw/input/ps2.c |
38 | +++ b/hw/misc/exynos4210_pmu.c | 18 | +++ b/hw/input/ps2.c |
39 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
40 | 20 | ||
41 | #include "qemu/osdep.h" | 21 | #include "trace.h" |
42 | #include "hw/sysbus.h" | 22 | |
43 | +#include "sysemu/sysemu.h" | 23 | -/* debug PC keyboard */ |
44 | 24 | -//#define DEBUG_KBD | |
45 | #ifndef DEBUG_PMU | 25 | - |
46 | #define DEBUG_PMU 0 | 26 | -/* debug PC keyboard : only mouse */ |
47 | @@ -XXX,XX +XXX,XX @@ static const Exynos4210PmuReg exynos4210_pmu_regs[] = { | 27 | -//#define DEBUG_MOUSE |
48 | {"PAD_RETENTION_MMCB_OPTION", PAD_RETENTION_MMCB_OPTION, 0x00000000}, | 28 | - |
49 | {"PAD_RETENTION_EBIA_OPTION", PAD_RETENTION_EBIA_OPTION, 0x00000000}, | 29 | /* Keyboard Commands */ |
50 | {"PAD_RETENTION_EBIB_OPTION", PAD_RETENTION_EBIB_OPTION, 0x00000000}, | 30 | #define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */ |
51 | - {"PS_HOLD_CONTROL", PS_HOLD_CONTROL, 0x00005200}, | 31 | #define KBD_CMD_ECHO 0xEE |
52 | + /* | 32 | @@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(void *opaque, int val) |
53 | + * PS_HOLD_CONTROL: reset value and manually toggle high the DATA bit. | 33 | PS2MouseState *s = (PS2MouseState *)opaque; |
54 | + * DATA bit high, set usually by bootloader, keeps system on. | 34 | |
55 | + */ | 35 | trace_ps2_write_mouse(opaque, val); |
56 | + {"PS_HOLD_CONTROL", PS_HOLD_CONTROL, 0x00005200 | BIT(8)}, | 36 | -#ifdef DEBUG_MOUSE |
57 | {"XUSBXTI_CONFIGURATION", XUSBXTI_CONFIGURATION, 0x00000001}, | 37 | - printf("kbd: write mouse 0x%02x\n", val); |
58 | {"XUSBXTI_STATUS", XUSBXTI_STATUS, 0x00000001}, | 38 | -#endif |
59 | {"XUSBXTI_DURATION", XUSBXTI_DURATION, 0xFFF00000}, | 39 | switch(s->common.write_cmd) { |
60 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210PmuState { | 40 | default: |
61 | uint32_t reg[PMU_NUM_OF_REGISTERS]; | 41 | case -1: |
62 | } Exynos4210PmuState; | ||
63 | |||
64 | +static void exynos4210_pmu_poweroff(void) | ||
65 | +{ | ||
66 | + PRINT_DEBUG("QEMU PMU: PS_HOLD bit down, powering off\n"); | ||
67 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | ||
68 | +} | ||
69 | + | ||
70 | static uint64_t exynos4210_pmu_read(void *opaque, hwaddr offset, | ||
71 | unsigned size) | ||
72 | { | ||
73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pmu_write(void *opaque, hwaddr offset, | ||
74 | PRINT_DEBUG_EXTEND("%s <0x%04x> <- 0x%04x\n", reg_p->name, | ||
75 | (uint32_t)offset, (uint32_t)val); | ||
76 | s->reg[i] = val; | ||
77 | + if ((offset == PS_HOLD_CONTROL) && ((val & BIT(8)) == 0)) { | ||
78 | + /* | ||
79 | + * We are interested only in setting data bit | ||
80 | + * of PS_HOLD_CONTROL register to indicate power off request. | ||
81 | + */ | ||
82 | + exynos4210_pmu_poweroff(); | ||
83 | + } | ||
84 | return; | ||
85 | } | ||
86 | reg_p++; | ||
87 | -- | 42 | -- |
88 | 2.7.4 | 43 | 2.20.1 |
89 | 44 | ||
90 | 45 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | In the mtspr helper we attempt to check for "is the timer disabled" |
---|---|---|---|
2 | with "if (env->ttmr & TIMER_NONE)". This is wrong because TIMER_NONE | ||
3 | is zero and the condition is always false (Coverity complains about | ||
4 | the dead code.) | ||
2 | 5 | ||
3 | Remove defines not used anywhere. | 6 | The correct check would be to test whether the TTMR_M field in the |
7 | register is equal to TIMER_NONE instead. However, the | ||
8 | cpu_openrisc_timer_update() function checks whether the timer is | ||
9 | enabled (it looks at cpu->env.is_counting, which is set to 0 via | ||
10 | cpu_openrisc_count_stop() when the TTMR_M field is set to | ||
11 | TIMER_NONE), so there's no need to check for "timer disabled" in the | ||
12 | target/openrisc code. Instead, simply remove the dead code. | ||
4 | 13 | ||
5 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 14 | Fixes: Coverity CID 1005812 |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Acked-by: Stafford Horne <shorne@gmail.com> | ||
17 | Message-id: 20201103114654.18540-1-peter.maydell@linaro.org | ||
8 | --- | 18 | --- |
9 | hw/timer/exynos4210_mct.c | 3 --- | 19 | target/openrisc/sys_helper.c | 3 --- |
10 | 1 file changed, 3 deletions(-) | 20 | 1 file changed, 3 deletions(-) |
11 | 21 | ||
12 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | 22 | diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/timer/exynos4210_mct.c | 24 | --- a/target/openrisc/sys_helper.c |
15 | +++ b/hw/timer/exynos4210_mct.c | 25 | +++ b/target/openrisc/sys_helper.c |
16 | @@ -XXX,XX +XXX,XX @@ enum LocalTimerRegCntIndexes { | 26 | @@ -XXX,XX +XXX,XX @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) |
17 | L_REG_CNT_AMOUNT | 27 | |
18 | }; | 28 | case TO_SPR(10, 1): /* TTCR */ |
19 | 29 | cpu_openrisc_count_set(cpu, rb); | |
20 | -#define MCT_NIRQ 6 | 30 | - if (env->ttmr & TIMER_NONE) { |
21 | #define MCT_SFR_SIZE 0x444 | 31 | - return; |
22 | 32 | - } | |
23 | #define MCT_GT_CMP_NUM 4 | 33 | cpu_openrisc_timer_update(cpu); |
24 | 34 | break; | |
25 | -#define MCT_GT_MAX_VAL UINT64_MAX | 35 | #endif |
26 | - | ||
27 | #define MCT_GT_COUNTER_STEP 0x100000000ULL | ||
28 | #define MCT_LT_COUNTER_STEP 0x100000000ULL | ||
29 | #define MCT_LT_CNT_LOW_LIMIT 0x100 | ||
30 | -- | 36 | -- |
31 | 2.7.4 | 37 | 2.20.1 |
32 | 38 | ||
33 | 39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | Before QOM-ifying the Exynos4 SoC model, move the DRAM initialization | ||
4 | from exynos4210.c to exynos4_boards.c because DRAM is board specific, | ||
5 | not SoC. | ||
6 | |||
7 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/exynos4210.h | 5 +---- | ||
12 | hw/arm/exynos4210.c | 20 +----------------- | ||
13 | hw/arm/exynos4_boards.c | 50 ++++++++++++++++++++++++++++++++++++++------- | ||
14 | 3 files changed, 45 insertions(+), 30 deletions(-) | ||
15 | |||
16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/exynos4210.h | ||
19 | +++ b/include/hw/arm/exynos4210.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210State { | ||
21 | MemoryRegion iram_mem; | ||
22 | MemoryRegion irom_mem; | ||
23 | MemoryRegion irom_alias_mem; | ||
24 | - MemoryRegion dram0_mem; | ||
25 | - MemoryRegion dram1_mem; | ||
26 | MemoryRegion boot_secondary; | ||
27 | MemoryRegion bootreg_mem; | ||
28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210State { | ||
30 | void exynos4210_write_secondary(ARMCPU *cpu, | ||
31 | const struct arm_boot_info *info); | ||
32 | |||
33 | -Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||
34 | - unsigned long ram_size); | ||
35 | +Exynos4210State *exynos4210_init(MemoryRegion *system_mem); | ||
36 | |||
37 | /* Initialize exynos4210 IRQ subsystem stub */ | ||
38 | qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); | ||
39 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/arm/exynos4210.c | ||
42 | +++ b/hw/arm/exynos4210.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_calc_affinity(int cpu) | ||
44 | return mp_affinity; | ||
45 | } | ||
46 | |||
47 | -Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||
48 | - unsigned long ram_size) | ||
49 | +Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | ||
50 | { | ||
51 | int i, n; | ||
52 | Exynos4210State *s = g_new(Exynos4210State, 1); | ||
53 | qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
54 | - unsigned long mem_size; | ||
55 | DeviceState *dev; | ||
56 | SysBusDevice *busdev; | ||
57 | ObjectClass *cpu_oc; | ||
58 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem, | ||
59 | memory_region_add_subregion(system_mem, EXYNOS4210_IRAM_BASE_ADDR, | ||
60 | &s->iram_mem); | ||
61 | |||
62 | - /* DRAM */ | ||
63 | - mem_size = ram_size; | ||
64 | - if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) { | ||
65 | - memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1", | ||
66 | - mem_size - EXYNOS4210_DRAM_MAX_SIZE, &error_fatal); | ||
67 | - vmstate_register_ram_global(&s->dram1_mem); | ||
68 | - memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR, | ||
69 | - &s->dram1_mem); | ||
70 | - mem_size = EXYNOS4210_DRAM_MAX_SIZE; | ||
71 | - } | ||
72 | - memory_region_init_ram(&s->dram0_mem, NULL, "exynos4210.dram0", mem_size, | ||
73 | - &error_fatal); | ||
74 | - vmstate_register_ram_global(&s->dram0_mem); | ||
75 | - memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR, | ||
76 | - &s->dram0_mem); | ||
77 | - | ||
78 | /* PMU. | ||
79 | * The only reason of existence at the moment is that secondary CPU boot | ||
80 | * loader uses PMU INFORM5 register as a holding pen. | ||
81 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/arm/exynos4_boards.c | ||
84 | +++ b/hw/arm/exynos4_boards.c | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | */ | ||
87 | |||
88 | #include "qemu/osdep.h" | ||
89 | +#include "qapi/error.h" | ||
90 | #include "qemu/error-report.h" | ||
91 | #include "qemu-common.h" | ||
92 | #include "cpu.h" | ||
93 | @@ -XXX,XX +XXX,XX @@ typedef enum Exynos4BoardType { | ||
94 | EXYNOS4_NUM_OF_BOARDS | ||
95 | } Exynos4BoardType; | ||
96 | |||
97 | +typedef struct Exynos4BoardState { | ||
98 | + Exynos4210State *soc; | ||
99 | + MemoryRegion dram0_mem; | ||
100 | + MemoryRegion dram1_mem; | ||
101 | +} Exynos4BoardState; | ||
102 | + | ||
103 | static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = { | ||
104 | [EXYNOS4_BOARD_NURI] = 0xD33, | ||
105 | [EXYNOS4_BOARD_SMDKC210] = 0xB16, | ||
106 | @@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq) | ||
107 | } | ||
108 | } | ||
109 | |||
110 | -static Exynos4210State *exynos4_boards_init_common(MachineState *machine, | ||
111 | - Exynos4BoardType board_type) | ||
112 | +static void exynos4_boards_init_ram(Exynos4BoardState *s, | ||
113 | + MemoryRegion *system_mem, | ||
114 | + unsigned long ram_size) | ||
115 | +{ | ||
116 | + unsigned long mem_size = ram_size; | ||
117 | + | ||
118 | + if (mem_size > EXYNOS4210_DRAM_MAX_SIZE) { | ||
119 | + memory_region_init_ram(&s->dram1_mem, NULL, "exynos4210.dram1", | ||
120 | + mem_size - EXYNOS4210_DRAM_MAX_SIZE, | ||
121 | + &error_fatal); | ||
122 | + vmstate_register_ram_global(&s->dram1_mem); | ||
123 | + memory_region_add_subregion(system_mem, EXYNOS4210_DRAM1_BASE_ADDR, | ||
124 | + &s->dram1_mem); | ||
125 | + mem_size = EXYNOS4210_DRAM_MAX_SIZE; | ||
126 | + } | ||
127 | + | ||
128 | + memory_region_init_ram(&s->dram0_mem, NULL, "exynos4210.dram0", mem_size, | ||
129 | + &error_fatal); | ||
130 | + vmstate_register_ram_global(&s->dram0_mem); | ||
131 | + memory_region_add_subregion(system_mem, EXYNOS4210_DRAM0_BASE_ADDR, | ||
132 | + &s->dram0_mem); | ||
133 | +} | ||
134 | + | ||
135 | +static Exynos4BoardState * | ||
136 | +exynos4_boards_init_common(MachineState *machine, | ||
137 | + Exynos4BoardType board_type) | ||
138 | { | ||
139 | + Exynos4BoardState *s = g_new(Exynos4BoardState, 1); | ||
140 | MachineClass *mc = MACHINE_GET_CLASS(machine); | ||
141 | |||
142 | if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) { | ||
143 | @@ -XXX,XX +XXX,XX @@ static Exynos4210State *exynos4_boards_init_common(MachineState *machine, | ||
144 | machine->kernel_cmdline, | ||
145 | machine->initrd_filename); | ||
146 | |||
147 | - return exynos4210_init(get_system_memory(), | ||
148 | - exynos4_board_ram_size[board_type]); | ||
149 | + exynos4_boards_init_ram(s, get_system_memory(), | ||
150 | + exynos4_board_ram_size[board_type]); | ||
151 | + | ||
152 | + s->soc = exynos4210_init(get_system_memory()); | ||
153 | + | ||
154 | + return s; | ||
155 | } | ||
156 | |||
157 | static void nuri_init(MachineState *machine) | ||
158 | @@ -XXX,XX +XXX,XX @@ static void nuri_init(MachineState *machine) | ||
159 | |||
160 | static void smdkc210_init(MachineState *machine) | ||
161 | { | ||
162 | - Exynos4210State *s = exynos4_boards_init_common(machine, | ||
163 | - EXYNOS4_BOARD_SMDKC210); | ||
164 | + Exynos4BoardState *s = exynos4_boards_init_common(machine, | ||
165 | + EXYNOS4_BOARD_SMDKC210); | ||
166 | |||
167 | lan9215_init(SMDK_LAN9118_BASE_ADDR, | ||
168 | - qemu_irq_invert(s->irq_table[exynos4210_get_irq(37, 1)])); | ||
169 | + qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)])); | ||
170 | arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo); | ||
171 | } | ||
172 | |||
173 | -- | ||
174 | 2.7.4 | ||
175 | |||
176 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | Bring some more readability by declaring local function variables: first | ||
4 | initialized ones and then the rest (with reversed-christmas-tree order). | ||
5 | |||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/exynos4210.c | 4 ++-- | ||
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/exynos4210.c | ||
16 | +++ b/hw/arm/exynos4210.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_calc_affinity(int cpu) | ||
18 | |||
19 | Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | ||
20 | { | ||
21 | - int i, n; | ||
22 | Exynos4210State *s = g_new(Exynos4210State, 1); | ||
23 | qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
24 | - DeviceState *dev; | ||
25 | SysBusDevice *busdev; | ||
26 | ObjectClass *cpu_oc; | ||
27 | + DeviceState *dev; | ||
28 | + int i, n; | ||
29 | |||
30 | cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, "cortex-a9"); | ||
31 | assert(cpu_oc); | ||
32 | -- | ||
33 | 2.7.4 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Alistair Francis <alistair.francis@wdc.com> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds the flush of the LPI pending bits into the | 3 | This patch fixes CID 1432800 by removing an unnecessary check. |
4 | redistributor pending tables. This happens on VM stop. | ||
5 | 4 | ||
6 | There is no explicit restore as the tables are implicitly sync'ed | 5 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
7 | on ITS table restore and on LPI enable at redistributor level. | ||
8 | |||
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Message-id: 1497023553-18411-4-git-send-email-eric.auger@redhat.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 8 | --- |
14 | hw/intc/arm_gicv3_kvm.c | 34 ++++++++++++++++++++++++++++++++++ | 9 | hw/core/register.c | 4 ---- |
15 | 1 file changed, 34 insertions(+) | 10 | 1 file changed, 4 deletions(-) |
16 | 11 | ||
17 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 12 | diff --git a/hw/core/register.c b/hw/core/register.c |
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/intc/arm_gicv3_kvm.c | 14 | --- a/hw/core/register.c |
20 | +++ b/hw/intc/arm_gicv3_kvm.c | 15 | +++ b/hw/core/register.c |
21 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ static RegisterInfoArray *register_init_block(DeviceState *owner, |
22 | #include "hw/sysbus.h" | 17 | int index = rae[i].addr / data_size; |
23 | #include "qemu/error-report.h" | 18 | RegisterInfo *r = &ri[index]; |
24 | #include "sysemu/kvm.h" | 19 | |
25 | +#include "sysemu/sysemu.h" | 20 | - if (data + data_size * index == 0 || !&rae[i]) { |
26 | #include "kvm_arm.h" | 21 | - continue; |
27 | #include "gicv3_internal.h" | 22 | - } |
28 | #include "vgic_common.h" | 23 | - |
29 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = { | 24 | /* Init the register, this will zero it. */ |
30 | REGINFO_SENTINEL | 25 | object_initialize((void *)r, sizeof(*r), TYPE_REGISTER); |
31 | }; | 26 | |
32 | |||
33 | +/** | ||
34 | + * vm_change_state_handler - VM change state callback aiming at flushing | ||
35 | + * RDIST pending tables into guest RAM | ||
36 | + * | ||
37 | + * The tables get flushed to guest RAM whenever the VM gets stopped. | ||
38 | + */ | ||
39 | +static void vm_change_state_handler(void *opaque, int running, | ||
40 | + RunState state) | ||
41 | +{ | ||
42 | + GICv3State *s = (GICv3State *)opaque; | ||
43 | + Error *err = NULL; | ||
44 | + int ret; | ||
45 | + | ||
46 | + if (running) { | ||
47 | + return; | ||
48 | + } | ||
49 | + | ||
50 | + ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
51 | + KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES, | ||
52 | + NULL, true, &err); | ||
53 | + if (err) { | ||
54 | + error_report_err(err); | ||
55 | + } | ||
56 | + if (ret < 0 && ret != -EFAULT) { | ||
57 | + abort(); | ||
58 | + } | ||
59 | +} | ||
60 | + | ||
61 | + | ||
62 | static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
63 | { | ||
64 | GICv3State *s = KVM_ARM_GICV3(dev); | ||
65 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
66 | return; | ||
67 | } | ||
68 | } | ||
69 | + if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
70 | + KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES)) { | ||
71 | + qemu_add_vm_change_state_handler(vm_change_state_handler, s); | ||
72 | + } | ||
73 | } | ||
74 | |||
75 | static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data) | ||
76 | -- | 27 | -- |
77 | 2.7.4 | 28 | 2.20.1 |
78 | 29 | ||
79 | 30 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Use a define for a9mpcore_priv device type name instead of hard-coded | 3 | Fix Coverity CID 1435957: Memory - illegal accesses (OVERRUN): |
4 | string. | ||
5 | 4 | ||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 5 | >>> Overrunning array "suffixes" of 7 8-byte elements at element |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | index 7 (byte offset 63) using index "idx" (which evaluates to 7). |
7 | |||
8 | Note, the biggest input value freq_to_str() can accept is UINT64_MAX, | ||
9 | which is ~18.446 EHz, less than 1000 EHz. | ||
10 | |||
11 | Reported-by: Eduardo Habkost <ehabkost@redhat.com> | ||
12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> | ||
15 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
16 | Message-id: 20201101215755.2021421-1-f4bug@amsat.org | ||
17 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 20 | --- |
10 | hw/arm/exynos4210.c | 3 ++- | 21 | util/cutils.c | 3 ++- |
11 | 1 file changed, 2 insertions(+), 1 deletion(-) | 22 | 1 file changed, 2 insertions(+), 1 deletion(-) |
12 | 23 | ||
13 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 24 | diff --git a/util/cutils.c b/util/cutils.c |
14 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/exynos4210.c | 26 | --- a/util/cutils.c |
16 | +++ b/hw/arm/exynos4210.c | 27 | +++ b/util/cutils.c |
17 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ char *freq_to_str(uint64_t freq_hz) |
18 | #include "qemu-common.h" | 29 | double freq = freq_hz; |
19 | #include "qemu/log.h" | 30 | size_t idx = 0; |
20 | #include "cpu.h" | 31 | |
21 | +#include "hw/cpu/a9mpcore.h" | 32 | - while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) { |
22 | #include "hw/boards.h" | 33 | + while (freq >= 1000.0) { |
23 | #include "sysemu/sysemu.h" | 34 | freq /= 1000.0; |
24 | #include "hw/sysbus.h" | 35 | idx++; |
25 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | ||
26 | } | 36 | } |
27 | 37 | + assert(idx < ARRAY_SIZE(suffixes)); | |
28 | /* Private memory region and Internal GIC */ | 38 | |
29 | - dev = qdev_create(NULL, "a9mpcore_priv"); | 39 | return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]); |
30 | + dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV); | 40 | } |
31 | qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | ||
32 | qdev_init_nofail(dev); | ||
33 | busdev = SYS_BUS_DEVICE(dev); | ||
34 | -- | 41 | -- |
35 | 2.7.4 | 42 | 2.20.1 |
36 | 43 | ||
37 | 44 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | ||
2 | 1 | ||
3 | The static array of interrupt combiner mappings is not modified so it | ||
4 | can be made const for code safeness. | ||
5 | |||
6 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/intc/exynos4210_gic.c | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/intc/exynos4210_gic.c | ||
16 | +++ b/hw/intc/exynos4210_gic.c | ||
17 | @@ -XXX,XX +XXX,XX @@ enum ExtInt { | ||
18 | * which is INTG16 in Internal Interrupt Combiner. | ||
19 | */ | ||
20 | |||
21 | -static uint32_t | ||
22 | +static const uint32_t | ||
23 | combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
24 | /* int combiner groups 16-19 */ | ||
25 | { }, { }, { }, { }, | ||
26 | -- | ||
27 | 2.7.4 | ||
28 | |||
29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Pranith Kumar <bobby.prani@gmail.com> | ||
2 | 1 | ||
3 | Tested and confirmed that the stretch i386 debian qcow2 image on a | ||
4 | raspberry pi 2 works. | ||
5 | |||
6 | Fixes: LP#: 893208 <https://bugs.launchpad.net/qemu/+bug/893208/> | ||
7 | Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> | ||
8 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | ||
9 | Message-id: 20170418191817.10430-1-bobby.prani@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/qemu/timer.h | 5 ++--- | ||
13 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/include/qemu/timer.h b/include/qemu/timer.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/qemu/timer.h | ||
18 | +++ b/include/qemu/timer.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline int64_t cpu_get_host_ticks(void) | ||
20 | /* The host CPU doesn't have an easily accessible cycle counter. | ||
21 | Just return a monotonically increasing value. This will be | ||
22 | totally wrong, but hopefully better than nothing. */ | ||
23 | -static inline int64_t cpu_get_host_ticks (void) | ||
24 | +static inline int64_t cpu_get_host_ticks(void) | ||
25 | { | ||
26 | - static int64_t ticks = 0; | ||
27 | - return ticks++; | ||
28 | + return get_clock(); | ||
29 | } | ||
30 | #endif | ||
31 | |||
32 | -- | ||
33 | 2.7.4 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | In commit 76346b6264a9b01979 we tried to add a configure check that |
---|---|---|---|
2 | the libgio pkg-config data was correct, which builds an executable | ||
3 | linked against it. Unfortunately this doesn't catch the problem | ||
4 | (missing static library dependency info), because a "do nothing" test | ||
5 | source file doesn't have any symbol references that cause the linker | ||
6 | to pull in .o files from libgio.a, and so we don't see the "missing | ||
7 | symbols from libmount" error that a full QEMU link triggers. | ||
2 | 8 | ||
3 | We need to handle both registers and ITS tables. While | 9 | (The ineffective test went unnoticed because of a typo that |
4 | register handling is standard, ITS table handling is more | 10 | effectively disabled libgio unconditionally, but after commit |
5 | challenging since the kernel API is devised so that the | 11 | 3569a5dfc11f2 fixed that, a static link of the system emulator on |
6 | tables are flushed into guest RAM and not in vmstate buffers. | 12 | Ubuntu stopped working again.) |
7 | 13 | ||
8 | Flushing the ITS tables on device pre_save() is too late | 14 | Improve the gio test by having the test source fragment reference a |
9 | since the guest RAM is already saved at this point. | 15 | g_dbus function (which is what is indirectly causing us to end up |
16 | wanting functions from libmount). | ||
10 | 17 | ||
11 | Table flushing needs to happen when we are sure the vcpus | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | are stopped and before the last dirty page saving. The | 19 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> |
13 | right point is RUN_STATE_FINISH_MIGRATE but sometimes the | 20 | Message-id: 20201116104617.18333-1-peter.maydell@linaro.org |
14 | VM gets stopped before migration launch so let's simply | 21 | --- |
15 | flush the tables each time the VM gets stopped. | 22 | configure | 11 +++++++++-- |
23 | 1 file changed, 9 insertions(+), 2 deletions(-) | ||
16 | 24 | ||
17 | For regular ITS registers we just can use vmstate pre_save() | 25 | diff --git a/configure b/configure |
18 | and post_load() callbacks. | 26 | index XXXXXXX..XXXXXXX 100755 |
19 | 27 | --- a/configure | |
20 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 28 | +++ b/configure |
21 | Message-id: 1497023553-18411-3-git-send-email-eric.auger@redhat.com | 29 | @@ -XXX,XX +XXX,XX @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then |
22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 30 | # Check that the libraries actually work -- Ubuntu 18.04 ships |
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | # with pkg-config --static --libs data for gio-2.0 that is missing |
24 | --- | 32 | # -lblkid and will give a link error. |
25 | include/hw/intc/arm_gicv3_its_common.h | 8 +++ | 33 | - write_c_skeleton |
26 | hw/intc/arm_gicv3_its_common.c | 10 ++++ | 34 | - if compile_prog "" "$gio_libs" ; then |
27 | hw/intc/arm_gicv3_its_kvm.c | 105 +++++++++++++++++++++++++++++++++ | 35 | + cat > $TMPC <<EOF |
28 | 3 files changed, 123 insertions(+) | 36 | +#include <gio/gio.h> |
29 | 37 | +int main(void) | |
30 | diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_gicv3_its_common.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/include/hw/intc/arm_gicv3_its_common.h | ||
33 | +++ b/include/hw/intc/arm_gicv3_its_common.h | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | #define ITS_TRANS_SIZE 0x10000 | ||
36 | #define ITS_SIZE (ITS_CONTROL_SIZE + ITS_TRANS_SIZE) | ||
37 | |||
38 | +#define GITS_CTLR 0x0 | ||
39 | +#define GITS_IIDR 0x4 | ||
40 | +#define GITS_CBASER 0x80 | ||
41 | +#define GITS_CWRITER 0x88 | ||
42 | +#define GITS_CREADR 0x90 | ||
43 | +#define GITS_BASER 0x100 | ||
44 | + | ||
45 | struct GICv3ITSState { | ||
46 | SysBusDevice parent_obj; | ||
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ struct GICv3ITSState { | ||
49 | |||
50 | /* Registers */ | ||
51 | uint32_t ctlr; | ||
52 | + uint32_t iidr; | ||
53 | uint64_t cbaser; | ||
54 | uint64_t cwriter; | ||
55 | uint64_t creadr; | ||
56 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/intc/arm_gicv3_its_common.c | ||
59 | +++ b/hw/intc/arm_gicv3_its_common.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_its = { | ||
61 | .pre_save = gicv3_its_pre_save, | ||
62 | .post_load = gicv3_its_post_load, | ||
63 | .unmigratable = true, | ||
64 | + .fields = (VMStateField[]) { | ||
65 | + VMSTATE_UINT32(ctlr, GICv3ITSState), | ||
66 | + VMSTATE_UINT32(iidr, GICv3ITSState), | ||
67 | + VMSTATE_UINT64(cbaser, GICv3ITSState), | ||
68 | + VMSTATE_UINT64(cwriter, GICv3ITSState), | ||
69 | + VMSTATE_UINT64(creadr, GICv3ITSState), | ||
70 | + VMSTATE_UINT64_ARRAY(baser, GICv3ITSState, 8), | ||
71 | + VMSTATE_END_OF_LIST() | ||
72 | + }, | ||
73 | }; | ||
74 | |||
75 | static MemTxResult gicv3_its_trans_read(void *opaque, hwaddr offset, | ||
76 | @@ -XXX,XX +XXX,XX @@ static void gicv3_its_common_reset(DeviceState *dev) | ||
77 | s->cbaser = 0; | ||
78 | s->cwriter = 0; | ||
79 | s->creadr = 0; | ||
80 | + s->iidr = 0; | ||
81 | memset(&s->baser, 0, sizeof(s->baser)); | ||
82 | |||
83 | gicv3_its_post_load(s, 0); | ||
84 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
87 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static int kvm_its_send_msi(GICv3ITSState *s, uint32_t value, uint16_t devid) | ||
89 | return kvm_vm_ioctl(kvm_state, KVM_SIGNAL_MSI, &msi); | ||
90 | } | ||
91 | |||
92 | +/** | ||
93 | + * vm_change_state_handler - VM change state callback aiming at flushing | ||
94 | + * ITS tables into guest RAM | ||
95 | + * | ||
96 | + * The tables get flushed to guest RAM whenever the VM gets stopped. | ||
97 | + */ | ||
98 | +static void vm_change_state_handler(void *opaque, int running, | ||
99 | + RunState state) | ||
100 | +{ | 38 | +{ |
101 | + GICv3ITSState *s = (GICv3ITSState *)opaque; | 39 | + g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); |
102 | + Error *err = NULL; | 40 | + return 0; |
103 | + int ret; | ||
104 | + | ||
105 | + if (running) { | ||
106 | + return; | ||
107 | + } | ||
108 | + | ||
109 | + ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
110 | + KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err); | ||
111 | + if (err) { | ||
112 | + error_report_err(err); | ||
113 | + } | ||
114 | + if (ret < 0 && ret != -EFAULT) { | ||
115 | + abort(); | ||
116 | + } | ||
117 | +} | 41 | +} |
118 | + | 42 | +EOF |
119 | static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | 43 | + if compile_prog "$gio_cflags" "$gio_libs" ; then |
120 | { | 44 | gio=yes |
121 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | 45 | else |
122 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | 46 | gio=no |
123 | kvm_msi_use_devid = true; | ||
124 | kvm_gsi_direct_mapping = false; | ||
125 | kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled(); | ||
126 | + | ||
127 | + qemu_add_vm_change_state_handler(vm_change_state_handler, s); | ||
128 | } | ||
129 | |||
130 | static void kvm_arm_its_init(Object *obj) | ||
131 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_init(Object *obj) | ||
132 | &error_abort); | ||
133 | } | ||
134 | |||
135 | +/** | ||
136 | + * kvm_arm_its_pre_save - handles the saving of ITS registers. | ||
137 | + * ITS tables are flushed into guest RAM separately and earlier, | ||
138 | + * through the VM change state handler, since at the moment pre_save() | ||
139 | + * is called, the guest RAM has already been saved. | ||
140 | + */ | ||
141 | +static void kvm_arm_its_pre_save(GICv3ITSState *s) | ||
142 | +{ | ||
143 | + int i; | ||
144 | + | ||
145 | + for (i = 0; i < 8; i++) { | ||
146 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
147 | + GITS_BASER + i * 8, &s->baser[i], false, | ||
148 | + &error_abort); | ||
149 | + } | ||
150 | + | ||
151 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
152 | + GITS_CTLR, &s->ctlr, false, &error_abort); | ||
153 | + | ||
154 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
155 | + GITS_CBASER, &s->cbaser, false, &error_abort); | ||
156 | + | ||
157 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
158 | + GITS_CREADR, &s->creadr, false, &error_abort); | ||
159 | + | ||
160 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
161 | + GITS_CWRITER, &s->cwriter, false, &error_abort); | ||
162 | + | ||
163 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
164 | + GITS_IIDR, &s->iidr, false, &error_abort); | ||
165 | +} | ||
166 | + | ||
167 | +/** | ||
168 | + * kvm_arm_its_post_load - Restore both the ITS registers and tables | ||
169 | + */ | ||
170 | +static void kvm_arm_its_post_load(GICv3ITSState *s) | ||
171 | +{ | ||
172 | + int i; | ||
173 | + | ||
174 | + if (!s->iidr) { | ||
175 | + return; | ||
176 | + } | ||
177 | + | ||
178 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
179 | + GITS_IIDR, &s->iidr, true, &error_abort); | ||
180 | + | ||
181 | + /* | ||
182 | + * must be written before GITS_CREADR since GITS_CBASER write | ||
183 | + * access resets GITS_CREADR. | ||
184 | + */ | ||
185 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
186 | + GITS_CBASER, &s->cbaser, true, &error_abort); | ||
187 | + | ||
188 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
189 | + GITS_CREADR, &s->creadr, true, &error_abort); | ||
190 | + | ||
191 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
192 | + GITS_CWRITER, &s->cwriter, true, &error_abort); | ||
193 | + | ||
194 | + | ||
195 | + for (i = 0; i < 8; i++) { | ||
196 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
197 | + GITS_BASER + i * 8, &s->baser[i], true, | ||
198 | + &error_abort); | ||
199 | + } | ||
200 | + | ||
201 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
202 | + KVM_DEV_ARM_ITS_RESTORE_TABLES, NULL, true, | ||
203 | + &error_abort); | ||
204 | + | ||
205 | + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, | ||
206 | + GITS_CTLR, &s->ctlr, true, &error_abort); | ||
207 | +} | ||
208 | + | ||
209 | static void kvm_arm_its_class_init(ObjectClass *klass, void *data) | ||
210 | { | ||
211 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
212 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_class_init(ObjectClass *klass, void *data) | ||
213 | |||
214 | dc->realize = kvm_arm_its_realize; | ||
215 | icc->send_msi = kvm_its_send_msi; | ||
216 | + icc->pre_save = kvm_arm_its_pre_save; | ||
217 | + icc->post_load = kvm_arm_its_post_load; | ||
218 | } | ||
219 | |||
220 | static const TypeInfo kvm_arm_its_info = { | ||
221 | -- | 47 | -- |
222 | 2.7.4 | 48 | 2.20.1 |
223 | 49 | ||
224 | 50 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | The TMP105 datasheet (https://www.ti.com/lit/gpn/tmp105) says that the |
---|---|---|---|
2 | power-up reset values for the T_low and T_high registers are 80 degrees C | ||
3 | and 75 degrees C, which are 0x500 and 0x4B0 hex according to table 5. These | ||
4 | values are then shifted right by four bits to give the register reset | ||
5 | values, since both registers store the 12 bits of temperature data in bits | ||
6 | [15..4] of a 16 bit register. | ||
2 | 7 | ||
3 | In some circumstances, we don't want to abort if the | 8 | We were resetting these registers to zero, which is problematic for Linux |
4 | kvm_device_access fails. This will be the case during ITS | 9 | guests which enable the alert interrupt and then immediately take an |
5 | migration, in case the ITS table save/restore fails because | 10 | unexpected overtemperature alert because the current temperature is above |
6 | the guest did not program the vITS correctly. So let's pass an | 11 | freezing... |
7 | error object to the function and return the ioctl value. New | ||
8 | callers will be able to make a decision upon this returned | ||
9 | value. | ||
10 | 12 | ||
11 | Existing callers pass &error_abort which will cause the | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | function to abort on failure. | 14 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
15 | Message-id: 20201110150023.25533-2-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/misc/tmp105.c | 3 +++ | ||
18 | 1 file changed, 3 insertions(+) | ||
13 | 19 | ||
14 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 20 | diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c |
15 | Reviewed-by: Juan Quintela <quintela@redhat.com> | ||
16 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
17 | Message-id: 1497023553-18411-2-git-send-email-eric.auger@redhat.com | ||
18 | [PMM: wrapped long line] | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | include/sysemu/kvm.h | 11 +++++++---- | ||
22 | hw/intc/arm_gic_kvm.c | 9 +++++---- | ||
23 | hw/intc/arm_gicv3_its_kvm.c | 2 +- | ||
24 | hw/intc/arm_gicv3_kvm.c | 14 +++++++------- | ||
25 | kvm-all.c | 14 ++++++++------ | ||
26 | 5 files changed, 28 insertions(+), 22 deletions(-) | ||
27 | |||
28 | diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/include/sysemu/kvm.h | 22 | --- a/hw/misc/tmp105.c |
31 | +++ b/include/sysemu/kvm.h | 23 | +++ b/hw/misc/tmp105.c |
32 | @@ -XXX,XX +XXX,XX @@ int kvm_device_check_attr(int fd, uint32_t group, uint64_t attr); | 24 | @@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c) |
33 | * @attr: the attribute of that group to set or get | 25 | s->faults = tmp105_faultq[(s->config >> 3) & 3]; |
34 | * @val: pointer to a storage area for the value | 26 | s->alarm = 0; |
35 | * @write: true for set and false for get operation | 27 | |
36 | + * @errp: error object handle | 28 | + s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */ |
37 | * | 29 | + s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */ |
38 | - * This function is not allowed to fail. Use kvm_device_check_attr() | 30 | + |
39 | - * in order to check for the availability of optional attributes. | 31 | tmp105_interrupt_update(s); |
40 | + * Returns: 0 on success | ||
41 | + * < 0 on error | ||
42 | + * Use kvm_device_check_attr() in order to check for the availability | ||
43 | + * of optional attributes. | ||
44 | */ | ||
45 | -void kvm_device_access(int fd, int group, uint64_t attr, | ||
46 | - void *val, bool write); | ||
47 | +int kvm_device_access(int fd, int group, uint64_t attr, | ||
48 | + void *val, bool write, Error **errp); | ||
49 | |||
50 | /** | ||
51 | * kvm_create_device - create a KVM device for the device control API | ||
52 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/intc/arm_gic_kvm.c | ||
55 | +++ b/hw/intc/arm_gic_kvm.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void kvm_gicd_access(GICState *s, int offset, int cpu, | ||
57 | uint32_t *val, bool write) | ||
58 | { | ||
59 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS, | ||
60 | - KVM_VGIC_ATTR(offset, cpu), val, write); | ||
61 | + KVM_VGIC_ATTR(offset, cpu), val, write, &error_abort); | ||
62 | } | 32 | } |
63 | 33 | ||
64 | static void kvm_gicc_access(GICState *s, int offset, int cpu, | ||
65 | uint32_t *val, bool write) | ||
66 | { | ||
67 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_REGS, | ||
68 | - KVM_VGIC_ATTR(offset, cpu), val, write); | ||
69 | + KVM_VGIC_ATTR(offset, cpu), val, write, &error_abort); | ||
70 | } | ||
71 | |||
72 | #define for_each_irq_reg(_ctr, _max_irq, _field_width) \ | ||
73 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | ||
74 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0)) { | ||
75 | uint32_t numirqs = s->num_irq; | ||
76 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, | ||
77 | - &numirqs, true); | ||
78 | + &numirqs, true, &error_abort); | ||
79 | } | ||
80 | /* Tell the kernel to complete VGIC initialization now */ | ||
81 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
82 | KVM_DEV_ARM_VGIC_CTRL_INIT)) { | ||
83 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
84 | - KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); | ||
85 | + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, | ||
86 | + &error_abort); | ||
87 | } | ||
88 | } else if (ret != -ENODEV && ret != -ENOTSUP) { | ||
89 | error_setg_errno(errp, -ret, "error creating in-kernel VGIC"); | ||
90 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
93 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) | ||
95 | |||
96 | /* explicit init of the ITS */ | ||
97 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
98 | - KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); | ||
99 | + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort); | ||
100 | |||
101 | /* register the base address */ | ||
102 | kvm_arm_register_device(&s->iomem_its_cntrl, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, | ||
103 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/hw/intc/arm_gicv3_kvm.c | ||
106 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gicd_access(GICv3State *s, int offset, | ||
108 | { | ||
109 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_DIST_REGS, | ||
110 | KVM_VGIC_ATTR(offset, 0), | ||
111 | - val, write); | ||
112 | + val, write, &error_abort); | ||
113 | } | ||
114 | |||
115 | static inline void kvm_gicr_access(GICv3State *s, int offset, int cpu, | ||
116 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gicr_access(GICv3State *s, int offset, int cpu, | ||
117 | { | ||
118 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_REDIST_REGS, | ||
119 | KVM_VGIC_ATTR(offset, s->cpu[cpu].gicr_typer), | ||
120 | - val, write); | ||
121 | + val, write, &error_abort); | ||
122 | } | ||
123 | |||
124 | static inline void kvm_gicc_access(GICv3State *s, uint64_t reg, int cpu, | ||
125 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gicc_access(GICv3State *s, uint64_t reg, int cpu, | ||
126 | { | ||
127 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS, | ||
128 | KVM_VGIC_ATTR(reg, s->cpu[cpu].gicr_typer), | ||
129 | - val, write); | ||
130 | + val, write, &error_abort); | ||
131 | } | ||
132 | |||
133 | static inline void kvm_gic_line_level_access(GICv3State *s, int irq, int cpu, | ||
134 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_gic_line_level_access(GICv3State *s, int irq, int cpu, | ||
135 | KVM_VGIC_ATTR(irq, s->cpu[cpu].gicr_typer) | | ||
136 | (VGIC_LEVEL_INFO_LINE_LEVEL << | ||
137 | KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT), | ||
138 | - val, write); | ||
139 | + val, write, &error_abort); | ||
140 | } | ||
141 | |||
142 | /* Loop through each distributor IRQ related register; since bits | ||
143 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | ||
144 | /* Initialize to actual HW supported configuration */ | ||
145 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS, | ||
146 | KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity), | ||
147 | - &c->icc_ctlr_el1[GICV3_NS], false); | ||
148 | + &c->icc_ctlr_el1[GICV3_NS], false, &error_abort); | ||
149 | |||
150 | c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS]; | ||
151 | } | ||
152 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
153 | } | ||
154 | |||
155 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_NR_IRQS, | ||
156 | - 0, &s->num_irq, true); | ||
157 | + 0, &s->num_irq, true, &error_abort); | ||
158 | |||
159 | /* Tell the kernel to complete VGIC initialization now */ | ||
160 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
161 | - KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); | ||
162 | + KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true, &error_abort); | ||
163 | |||
164 | kvm_arm_register_device(&s->iomem_dist, -1, KVM_DEV_ARM_VGIC_GRP_ADDR, | ||
165 | KVM_VGIC_V3_ADDR_TYPE_DIST, s->dev_fd); | ||
166 | diff --git a/kvm-all.c b/kvm-all.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/kvm-all.c | ||
169 | +++ b/kvm-all.c | ||
170 | @@ -XXX,XX +XXX,XX @@ | ||
171 | #include "qemu/option.h" | ||
172 | #include "qemu/config-file.h" | ||
173 | #include "qemu/error-report.h" | ||
174 | +#include "qapi/error.h" | ||
175 | #include "hw/hw.h" | ||
176 | #include "hw/pci/msi.h" | ||
177 | #include "hw/pci/msix.h" | ||
178 | @@ -XXX,XX +XXX,XX @@ int kvm_device_check_attr(int dev_fd, uint32_t group, uint64_t attr) | ||
179 | return kvm_device_ioctl(dev_fd, KVM_HAS_DEVICE_ATTR, &attribute) ? 0 : 1; | ||
180 | } | ||
181 | |||
182 | -void kvm_device_access(int fd, int group, uint64_t attr, | ||
183 | - void *val, bool write) | ||
184 | +int kvm_device_access(int fd, int group, uint64_t attr, | ||
185 | + void *val, bool write, Error **errp) | ||
186 | { | ||
187 | struct kvm_device_attr kvmattr; | ||
188 | int err; | ||
189 | @@ -XXX,XX +XXX,XX @@ void kvm_device_access(int fd, int group, uint64_t attr, | ||
190 | write ? KVM_SET_DEVICE_ATTR : KVM_GET_DEVICE_ATTR, | ||
191 | &kvmattr); | ||
192 | if (err < 0) { | ||
193 | - error_report("KVM_%s_DEVICE_ATTR failed: %s", | ||
194 | - write ? "SET" : "GET", strerror(-err)); | ||
195 | - error_printf("Group %d attr 0x%016" PRIx64 "\n", group, attr); | ||
196 | - abort(); | ||
197 | + error_setg_errno(errp, -err, | ||
198 | + "KVM_%s_DEVICE_ATTR failed: Group %d " | ||
199 | + "attr 0x%016" PRIx64, | ||
200 | + write ? "SET" : "GET", group, attr); | ||
201 | } | ||
202 | + return err; | ||
203 | } | ||
204 | |||
205 | /* Return 1 on success, 0 on failure */ | ||
206 | -- | 34 | -- |
207 | 2.7.4 | 35 | 2.20.1 |
208 | 36 | ||
209 | 37 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device |
---|---|---|---|
2 | signals an alert when the temperature equals or exceeds the T_high value and | ||
3 | then remains high until a device register is read or the device responds to | ||
4 | the SMBUS Alert Response address, or the device is put into Shutdown Mode. | ||
5 | Thereafter the Alert pin will only be re-signalled when temperature falls | ||
6 | below T_low; alert can then be cleared in the same set of ways, and the | ||
7 | device returns to its initial "alert when temperature goes above T_high" | ||
8 | mode. (If this textual description is confusing, see figure 3 in the | ||
9 | TI datasheet at https://www.ti.com/lit/gpn/tmp105 .) | ||
2 | 10 | ||
3 | Largely inspired by the TMP105 temperature sensor, here is a model for | 11 | We were misimplementing this as a simple "always alert if temperature is |
4 | the TMP42{1,2,3} temperature sensors. | 12 | above T_high or below T_low" condition, which gives a spurious alert on |
13 | startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset | ||
14 | limit values. | ||
5 | 15 | ||
6 | Specs can be found here : | 16 | Implement the correct (hysteresis) behaviour by tracking whether we |
17 | are currently looking for the temperature to rise over T_high or | ||
18 | for it to fall below T_low. Our implementation of the comparator | ||
19 | mode (TM==0) wasn't wrong, but rephrase it to match the way that | ||
20 | interrupt mode is now handled for clarity. | ||
7 | 21 | ||
8 | http://www.ti.com/lit/gpn/tmp421 | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
24 | Message-id: 20201110150023.25533-3-peter.maydell@linaro.org | ||
25 | --- | ||
26 | hw/misc/tmp105.h | 7 +++++ | ||
27 | hw/misc/tmp105.c | 70 +++++++++++++++++++++++++++++++++++++++++------- | ||
28 | 2 files changed, 68 insertions(+), 9 deletions(-) | ||
9 | 29 | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 30 | diff --git a/hw/misc/tmp105.h b/hw/misc/tmp105.h |
11 | Message-id: 1496739230-32109-2-git-send-email-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/misc/Makefile.objs | 1 + | ||
16 | hw/misc/tmp421.c | 402 ++++++++++++++++++++++++++++++++++++++++ | ||
17 | default-configs/arm-softmmu.mak | 1 + | ||
18 | 3 files changed, 404 insertions(+) | ||
19 | create mode 100644 hw/misc/tmp421.c | ||
20 | |||
21 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | ||
22 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/misc/Makefile.objs | 32 | --- a/hw/misc/tmp105.h |
24 | +++ b/hw/misc/Makefile.objs | 33 | +++ b/hw/misc/tmp105.h |
25 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ struct TMP105State { |
26 | common-obj-$(CONFIG_APPLESMC) += applesmc.o | 35 | int16_t limit[2]; |
27 | common-obj-$(CONFIG_MAX111X) += max111x.o | 36 | int faults; |
28 | common-obj-$(CONFIG_TMP105) += tmp105.o | 37 | uint8_t alarm; |
29 | +common-obj-$(CONFIG_TMP421) += tmp421.o | 38 | + /* |
30 | common-obj-$(CONFIG_ISA_DEBUG) += debugexit.o | 39 | + * The TMP105 initially looks for a temperature rising above T_high; |
31 | common-obj-$(CONFIG_SGA) += sga.o | 40 | + * once this is detected, the condition it looks for next is the |
32 | common-obj-$(CONFIG_ISA_TESTDEV) += pc-testdev.o | 41 | + * temperature falling below T_low. This flag is false when initially |
33 | diff --git a/hw/misc/tmp421.c b/hw/misc/tmp421.c | 42 | + * looking for T_high, true when looking for T_low. |
34 | new file mode 100644 | 43 | + */ |
35 | index XXXXXXX..XXXXXXX | 44 | + bool detect_falling; |
36 | --- /dev/null | 45 | }; |
37 | +++ b/hw/misc/tmp421.c | 46 | |
38 | @@ -XXX,XX +XXX,XX @@ | 47 | #endif |
39 | +/* | 48 | diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c |
40 | + * Texas Instruments TMP421 temperature sensor. | 49 | index XXXXXXX..XXXXXXX 100644 |
41 | + * | 50 | --- a/hw/misc/tmp105.c |
42 | + * Copyright (c) 2016 IBM Corporation. | 51 | +++ b/hw/misc/tmp105.c |
43 | + * | 52 | @@ -XXX,XX +XXX,XX @@ static void tmp105_alarm_update(TMP105State *s) |
44 | + * Largely inspired by : | 53 | return; |
45 | + * | 54 | } |
46 | + * Texas Instruments TMP105 temperature sensor. | 55 | |
47 | + * | 56 | - if ((s->config >> 1) & 1) { /* TM */ |
48 | + * Copyright (C) 2008 Nokia Corporation | 57 | - if (s->temperature >= s->limit[1]) |
49 | + * Written by Andrzej Zaborowski <andrew@openedhand.com> | 58 | - s->alarm = 1; |
50 | + * | 59 | - else if (s->temperature < s->limit[0]) |
51 | + * This program is free software; you can redistribute it and/or | 60 | - s->alarm = 1; |
52 | + * modify it under the terms of the GNU General Public License as | 61 | + if (s->config >> 1 & 1) { |
53 | + * published by the Free Software Foundation; either version 2 or | 62 | + /* |
54 | + * (at your option) version 3 of the License. | 63 | + * TM == 1 : Interrupt mode. We signal Alert when the |
55 | + * | 64 | + * temperature rises above T_high, and expect the guest to clear |
56 | + * This program is distributed in the hope that it will be useful, | 65 | + * it (eg by reading a device register). |
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 66 | + */ |
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 67 | + if (s->detect_falling) { |
59 | + * GNU General Public License for more details. | 68 | + if (s->temperature < s->limit[0]) { |
60 | + * | 69 | + s->alarm = 1; |
61 | + * You should have received a copy of the GNU General Public License along | 70 | + s->detect_falling = false; |
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | 71 | + } |
63 | + */ | 72 | + } else { |
73 | + if (s->temperature >= s->limit[1]) { | ||
74 | + s->alarm = 1; | ||
75 | + s->detect_falling = true; | ||
76 | + } | ||
77 | + } | ||
78 | } else { | ||
79 | - if (s->temperature >= s->limit[1]) | ||
80 | - s->alarm = 1; | ||
81 | - else if (s->temperature < s->limit[0]) | ||
82 | - s->alarm = 0; | ||
83 | + /* | ||
84 | + * TM == 0 : Comparator mode. We signal Alert when the temperature | ||
85 | + * rises above T_high, and stop signalling it when the temperature | ||
86 | + * falls below T_low. | ||
87 | + */ | ||
88 | + if (s->detect_falling) { | ||
89 | + if (s->temperature < s->limit[0]) { | ||
90 | + s->alarm = 0; | ||
91 | + s->detect_falling = false; | ||
92 | + } | ||
93 | + } else { | ||
94 | + if (s->temperature >= s->limit[1]) { | ||
95 | + s->alarm = 1; | ||
96 | + s->detect_falling = true; | ||
97 | + } | ||
98 | + } | ||
99 | } | ||
100 | |||
101 | tmp105_interrupt_update(s); | ||
102 | @@ -XXX,XX +XXX,XX @@ static int tmp105_post_load(void *opaque, int version_id) | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | +static bool detect_falling_needed(void *opaque) | ||
107 | +{ | ||
108 | + TMP105State *s = opaque; | ||
64 | + | 109 | + |
65 | +#include "qemu/osdep.h" | 110 | + /* |
66 | +#include "hw/hw.h" | 111 | + * We only need to migrate the detect_falling bool if it's set; |
67 | +#include "hw/i2c/i2c.h" | 112 | + * for migration from older machines we assume that it is false |
68 | +#include "qapi/error.h" | 113 | + * (ie temperature is not out of range). |
69 | +#include "qapi/visitor.h" | 114 | + */ |
70 | + | 115 | + return s->detect_falling; |
71 | +/* Manufacturer / Device ID's */ | ||
72 | +#define TMP421_MANUFACTURER_ID 0x55 | ||
73 | +#define TMP421_DEVICE_ID 0x21 | ||
74 | +#define TMP422_DEVICE_ID 0x22 | ||
75 | +#define TMP423_DEVICE_ID 0x23 | ||
76 | + | ||
77 | +typedef struct DeviceInfo { | ||
78 | + int model; | ||
79 | + const char *name; | ||
80 | +} DeviceInfo; | ||
81 | + | ||
82 | +static const DeviceInfo devices[] = { | ||
83 | + { TMP421_DEVICE_ID, "tmp421" }, | ||
84 | + { TMP422_DEVICE_ID, "tmp422" }, | ||
85 | + { TMP423_DEVICE_ID, "tmp423" }, | ||
86 | +}; | ||
87 | + | ||
88 | +typedef struct TMP421State { | ||
89 | + /*< private >*/ | ||
90 | + I2CSlave i2c; | ||
91 | + /*< public >*/ | ||
92 | + | ||
93 | + int16_t temperature[4]; | ||
94 | + | ||
95 | + uint8_t status; | ||
96 | + uint8_t config[2]; | ||
97 | + uint8_t rate; | ||
98 | + | ||
99 | + uint8_t len; | ||
100 | + uint8_t buf[2]; | ||
101 | + uint8_t pointer; | ||
102 | + | ||
103 | +} TMP421State; | ||
104 | + | ||
105 | +typedef struct TMP421Class { | ||
106 | + I2CSlaveClass parent_class; | ||
107 | + DeviceInfo *dev; | ||
108 | +} TMP421Class; | ||
109 | + | ||
110 | +#define TYPE_TMP421 "tmp421-generic" | ||
111 | +#define TMP421(obj) OBJECT_CHECK(TMP421State, (obj), TYPE_TMP421) | ||
112 | + | ||
113 | +#define TMP421_CLASS(klass) \ | ||
114 | + OBJECT_CLASS_CHECK(TMP421Class, (klass), TYPE_TMP421) | ||
115 | +#define TMP421_GET_CLASS(obj) \ | ||
116 | + OBJECT_GET_CLASS(TMP421Class, (obj), TYPE_TMP421) | ||
117 | + | ||
118 | +/* the TMP421 registers */ | ||
119 | +#define TMP421_STATUS_REG 0x08 | ||
120 | +#define TMP421_STATUS_BUSY (1 << 7) | ||
121 | +#define TMP421_CONFIG_REG_1 0x09 | ||
122 | +#define TMP421_CONFIG_RANGE (1 << 2) | ||
123 | +#define TMP421_CONFIG_SHUTDOWN (1 << 6) | ||
124 | +#define TMP421_CONFIG_REG_2 0x0A | ||
125 | +#define TMP421_CONFIG_RC (1 << 2) | ||
126 | +#define TMP421_CONFIG_LEN (1 << 3) | ||
127 | +#define TMP421_CONFIG_REN (1 << 4) | ||
128 | +#define TMP421_CONFIG_REN2 (1 << 5) | ||
129 | +#define TMP421_CONFIG_REN3 (1 << 6) | ||
130 | + | ||
131 | +#define TMP421_CONVERSION_RATE_REG 0x0B | ||
132 | +#define TMP421_ONE_SHOT 0x0F | ||
133 | + | ||
134 | +#define TMP421_RESET 0xFC | ||
135 | +#define TMP421_MANUFACTURER_ID_REG 0xFE | ||
136 | +#define TMP421_DEVICE_ID_REG 0xFF | ||
137 | + | ||
138 | +#define TMP421_TEMP_MSB0 0x00 | ||
139 | +#define TMP421_TEMP_MSB1 0x01 | ||
140 | +#define TMP421_TEMP_MSB2 0x02 | ||
141 | +#define TMP421_TEMP_MSB3 0x03 | ||
142 | +#define TMP421_TEMP_LSB0 0x10 | ||
143 | +#define TMP421_TEMP_LSB1 0x11 | ||
144 | +#define TMP421_TEMP_LSB2 0x12 | ||
145 | +#define TMP421_TEMP_LSB3 0x13 | ||
146 | + | ||
147 | +static const int32_t mins[2] = { -40000, -55000 }; | ||
148 | +static const int32_t maxs[2] = { 127000, 150000 }; | ||
149 | + | ||
150 | +static void tmp421_get_temperature(Object *obj, Visitor *v, const char *name, | ||
151 | + void *opaque, Error **errp) | ||
152 | +{ | ||
153 | + TMP421State *s = TMP421(obj); | ||
154 | + bool ext_range = (s->config[0] & TMP421_CONFIG_RANGE); | ||
155 | + int offset = ext_range * 64 * 256; | ||
156 | + int64_t value; | ||
157 | + int tempid; | ||
158 | + | ||
159 | + if (sscanf(name, "temperature%d", &tempid) != 1) { | ||
160 | + error_setg(errp, "error reading %s: %m", name); | ||
161 | + return; | ||
162 | + } | ||
163 | + | ||
164 | + if (tempid >= 4 || tempid < 0) { | ||
165 | + error_setg(errp, "error reading %s", name); | ||
166 | + return; | ||
167 | + } | ||
168 | + | ||
169 | + value = ((s->temperature[tempid] - offset) * 1000 + 128) / 256; | ||
170 | + | ||
171 | + visit_type_int(v, name, &value, errp); | ||
172 | +} | 116 | +} |
173 | + | 117 | + |
174 | +/* Units are 0.001 centigrades relative to 0 C. s->temperature is 8.8 | 118 | +static const VMStateDescription vmstate_tmp105_detect_falling = { |
175 | + * fixed point, so units are 1/256 centigrades. A simple ratio will do. | 119 | + .name = "TMP105/detect-falling", |
176 | + */ | 120 | + .version_id = 1, |
177 | +static void tmp421_set_temperature(Object *obj, Visitor *v, const char *name, | 121 | + .minimum_version_id = 1, |
178 | + void *opaque, Error **errp) | 122 | + .needed = detect_falling_needed, |
179 | +{ | ||
180 | + TMP421State *s = TMP421(obj); | ||
181 | + Error *local_err = NULL; | ||
182 | + int64_t temp; | ||
183 | + bool ext_range = (s->config[0] & TMP421_CONFIG_RANGE); | ||
184 | + int offset = ext_range * 64 * 256; | ||
185 | + int tempid; | ||
186 | + | ||
187 | + visit_type_int(v, name, &temp, &local_err); | ||
188 | + if (local_err) { | ||
189 | + error_propagate(errp, local_err); | ||
190 | + return; | ||
191 | + } | ||
192 | + | ||
193 | + if (temp >= maxs[ext_range] || temp < mins[ext_range]) { | ||
194 | + error_setg(errp, "value %" PRId64 ".%03" PRIu64 " °C is out of range", | ||
195 | + temp / 1000, temp % 1000); | ||
196 | + return; | ||
197 | + } | ||
198 | + | ||
199 | + if (sscanf(name, "temperature%d", &tempid) != 1) { | ||
200 | + error_setg(errp, "error reading %s: %m", name); | ||
201 | + return; | ||
202 | + } | ||
203 | + | ||
204 | + if (tempid >= 4 || tempid < 0) { | ||
205 | + error_setg(errp, "error reading %s", name); | ||
206 | + return; | ||
207 | + } | ||
208 | + | ||
209 | + s->temperature[tempid] = (int16_t) ((temp * 256 - 128) / 1000) + offset; | ||
210 | +} | ||
211 | + | ||
212 | +static void tmp421_read(TMP421State *s) | ||
213 | +{ | ||
214 | + TMP421Class *sc = TMP421_GET_CLASS(s); | ||
215 | + | ||
216 | + s->len = 0; | ||
217 | + | ||
218 | + switch (s->pointer) { | ||
219 | + case TMP421_MANUFACTURER_ID_REG: | ||
220 | + s->buf[s->len++] = TMP421_MANUFACTURER_ID; | ||
221 | + break; | ||
222 | + case TMP421_DEVICE_ID_REG: | ||
223 | + s->buf[s->len++] = sc->dev->model; | ||
224 | + break; | ||
225 | + case TMP421_CONFIG_REG_1: | ||
226 | + s->buf[s->len++] = s->config[0]; | ||
227 | + break; | ||
228 | + case TMP421_CONFIG_REG_2: | ||
229 | + s->buf[s->len++] = s->config[1]; | ||
230 | + break; | ||
231 | + case TMP421_CONVERSION_RATE_REG: | ||
232 | + s->buf[s->len++] = s->rate; | ||
233 | + break; | ||
234 | + case TMP421_STATUS_REG: | ||
235 | + s->buf[s->len++] = s->status; | ||
236 | + break; | ||
237 | + | ||
238 | + /* FIXME: check for channel enablement in config registers */ | ||
239 | + case TMP421_TEMP_MSB0: | ||
240 | + s->buf[s->len++] = (((uint16_t) s->temperature[0]) >> 8); | ||
241 | + s->buf[s->len++] = (((uint16_t) s->temperature[0]) >> 0) & 0xf0; | ||
242 | + break; | ||
243 | + case TMP421_TEMP_MSB1: | ||
244 | + s->buf[s->len++] = (((uint16_t) s->temperature[1]) >> 8); | ||
245 | + s->buf[s->len++] = (((uint16_t) s->temperature[1]) >> 0) & 0xf0; | ||
246 | + break; | ||
247 | + case TMP421_TEMP_MSB2: | ||
248 | + s->buf[s->len++] = (((uint16_t) s->temperature[2]) >> 8); | ||
249 | + s->buf[s->len++] = (((uint16_t) s->temperature[2]) >> 0) & 0xf0; | ||
250 | + break; | ||
251 | + case TMP421_TEMP_MSB3: | ||
252 | + s->buf[s->len++] = (((uint16_t) s->temperature[3]) >> 8); | ||
253 | + s->buf[s->len++] = (((uint16_t) s->temperature[3]) >> 0) & 0xf0; | ||
254 | + break; | ||
255 | + case TMP421_TEMP_LSB0: | ||
256 | + s->buf[s->len++] = (((uint16_t) s->temperature[0]) >> 0) & 0xf0; | ||
257 | + break; | ||
258 | + case TMP421_TEMP_LSB1: | ||
259 | + s->buf[s->len++] = (((uint16_t) s->temperature[1]) >> 0) & 0xf0; | ||
260 | + break; | ||
261 | + case TMP421_TEMP_LSB2: | ||
262 | + s->buf[s->len++] = (((uint16_t) s->temperature[2]) >> 0) & 0xf0; | ||
263 | + break; | ||
264 | + case TMP421_TEMP_LSB3: | ||
265 | + s->buf[s->len++] = (((uint16_t) s->temperature[3]) >> 0) & 0xf0; | ||
266 | + break; | ||
267 | + } | ||
268 | +} | ||
269 | + | ||
270 | +static void tmp421_reset(I2CSlave *i2c); | ||
271 | + | ||
272 | +static void tmp421_write(TMP421State *s) | ||
273 | +{ | ||
274 | + switch (s->pointer) { | ||
275 | + case TMP421_CONVERSION_RATE_REG: | ||
276 | + s->rate = s->buf[0]; | ||
277 | + break; | ||
278 | + case TMP421_CONFIG_REG_1: | ||
279 | + s->config[0] = s->buf[0]; | ||
280 | + break; | ||
281 | + case TMP421_CONFIG_REG_2: | ||
282 | + s->config[1] = s->buf[0]; | ||
283 | + break; | ||
284 | + case TMP421_RESET: | ||
285 | + tmp421_reset(I2C_SLAVE(s)); | ||
286 | + break; | ||
287 | + } | ||
288 | +} | ||
289 | + | ||
290 | +static int tmp421_rx(I2CSlave *i2c) | ||
291 | +{ | ||
292 | + TMP421State *s = TMP421(i2c); | ||
293 | + | ||
294 | + if (s->len < 2) { | ||
295 | + return s->buf[s->len++]; | ||
296 | + } else { | ||
297 | + return 0xff; | ||
298 | + } | ||
299 | +} | ||
300 | + | ||
301 | +static int tmp421_tx(I2CSlave *i2c, uint8_t data) | ||
302 | +{ | ||
303 | + TMP421State *s = TMP421(i2c); | ||
304 | + | ||
305 | + if (s->len == 0) { | ||
306 | + /* first byte is the register pointer for a read or write | ||
307 | + * operation */ | ||
308 | + s->pointer = data; | ||
309 | + s->len++; | ||
310 | + } else if (s->len == 1) { | ||
311 | + /* second byte is the data to write. The device only supports | ||
312 | + * one byte writes */ | ||
313 | + s->buf[0] = data; | ||
314 | + tmp421_write(s); | ||
315 | + } | ||
316 | + | ||
317 | + return 0; | ||
318 | +} | ||
319 | + | ||
320 | +static int tmp421_event(I2CSlave *i2c, enum i2c_event event) | ||
321 | +{ | ||
322 | + TMP421State *s = TMP421(i2c); | ||
323 | + | ||
324 | + if (event == I2C_START_RECV) { | ||
325 | + tmp421_read(s); | ||
326 | + } | ||
327 | + | ||
328 | + s->len = 0; | ||
329 | + return 0; | ||
330 | +} | ||
331 | + | ||
332 | +static const VMStateDescription vmstate_tmp421 = { | ||
333 | + .name = "TMP421", | ||
334 | + .version_id = 0, | ||
335 | + .minimum_version_id = 0, | ||
336 | + .fields = (VMStateField[]) { | 123 | + .fields = (VMStateField[]) { |
337 | + VMSTATE_UINT8(len, TMP421State), | 124 | + VMSTATE_BOOL(detect_falling, TMP105State), |
338 | + VMSTATE_UINT8_ARRAY(buf, TMP421State, 2), | ||
339 | + VMSTATE_UINT8(pointer, TMP421State), | ||
340 | + VMSTATE_UINT8_ARRAY(config, TMP421State, 2), | ||
341 | + VMSTATE_UINT8(status, TMP421State), | ||
342 | + VMSTATE_UINT8(rate, TMP421State), | ||
343 | + VMSTATE_INT16_ARRAY(temperature, TMP421State, 4), | ||
344 | + VMSTATE_I2C_SLAVE(i2c, TMP421State), | ||
345 | + VMSTATE_END_OF_LIST() | 125 | + VMSTATE_END_OF_LIST() |
346 | + } | 126 | + } |
347 | +}; | 127 | +}; |
348 | + | 128 | + |
349 | +static void tmp421_reset(I2CSlave *i2c) | 129 | static const VMStateDescription vmstate_tmp105 = { |
350 | +{ | 130 | .name = "TMP105", |
351 | + TMP421State *s = TMP421(i2c); | 131 | .version_id = 0, |
352 | + TMP421Class *sc = TMP421_GET_CLASS(s); | 132 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_tmp105 = { |
353 | + | 133 | VMSTATE_UINT8(alarm, TMP105State), |
354 | + memset(s->temperature, 0, sizeof(s->temperature)); | 134 | VMSTATE_I2C_SLAVE(i2c, TMP105State), |
355 | + s->pointer = 0; | 135 | VMSTATE_END_OF_LIST() |
356 | + | 136 | + }, |
357 | + s->config[0] = 0; /* TMP421_CONFIG_RANGE */ | 137 | + .subsections = (const VMStateDescription*[]) { |
358 | + | 138 | + &vmstate_tmp105_detect_falling, |
359 | + /* resistance correction and channel enablement */ | 139 | + NULL |
360 | + switch (sc->dev->model) { | 140 | } |
361 | + case TMP421_DEVICE_ID: | 141 | }; |
362 | + s->config[1] = 0x1c; | 142 | |
363 | + break; | 143 | @@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c) |
364 | + case TMP422_DEVICE_ID: | 144 | s->config = 0; |
365 | + s->config[1] = 0x3c; | 145 | s->faults = tmp105_faultq[(s->config >> 3) & 3]; |
366 | + break; | 146 | s->alarm = 0; |
367 | + case TMP423_DEVICE_ID: | 147 | + s->detect_falling = false; |
368 | + s->config[1] = 0x7c; | 148 | |
369 | + break; | 149 | s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */ |
370 | + } | 150 | s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */ |
371 | + | ||
372 | + s->rate = 0x7; /* 8Hz */ | ||
373 | + s->status = 0; | ||
374 | +} | ||
375 | + | ||
376 | +static int tmp421_init(I2CSlave *i2c) | ||
377 | +{ | ||
378 | + TMP421State *s = TMP421(i2c); | ||
379 | + | ||
380 | + tmp421_reset(&s->i2c); | ||
381 | + | ||
382 | + return 0; | ||
383 | +} | ||
384 | + | ||
385 | +static void tmp421_initfn(Object *obj) | ||
386 | +{ | ||
387 | + object_property_add(obj, "temperature0", "int", | ||
388 | + tmp421_get_temperature, | ||
389 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
390 | + object_property_add(obj, "temperature1", "int", | ||
391 | + tmp421_get_temperature, | ||
392 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
393 | + object_property_add(obj, "temperature2", "int", | ||
394 | + tmp421_get_temperature, | ||
395 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
396 | + object_property_add(obj, "temperature3", "int", | ||
397 | + tmp421_get_temperature, | ||
398 | + tmp421_set_temperature, NULL, NULL, NULL); | ||
399 | +} | ||
400 | + | ||
401 | +static void tmp421_class_init(ObjectClass *klass, void *data) | ||
402 | +{ | ||
403 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
404 | + I2CSlaveClass *k = I2C_SLAVE_CLASS(klass); | ||
405 | + TMP421Class *sc = TMP421_CLASS(klass); | ||
406 | + | ||
407 | + k->init = tmp421_init; | ||
408 | + k->event = tmp421_event; | ||
409 | + k->recv = tmp421_rx; | ||
410 | + k->send = tmp421_tx; | ||
411 | + dc->vmsd = &vmstate_tmp421; | ||
412 | + sc->dev = (DeviceInfo *) data; | ||
413 | +} | ||
414 | + | ||
415 | +static const TypeInfo tmp421_info = { | ||
416 | + .name = TYPE_TMP421, | ||
417 | + .parent = TYPE_I2C_SLAVE, | ||
418 | + .instance_size = sizeof(TMP421State), | ||
419 | + .class_size = sizeof(TMP421Class), | ||
420 | + .instance_init = tmp421_initfn, | ||
421 | + .abstract = true, | ||
422 | +}; | ||
423 | + | ||
424 | +static void tmp421_register_types(void) | ||
425 | +{ | ||
426 | + int i; | ||
427 | + | ||
428 | + type_register_static(&tmp421_info); | ||
429 | + for (i = 0; i < ARRAY_SIZE(devices); ++i) { | ||
430 | + TypeInfo ti = { | ||
431 | + .name = devices[i].name, | ||
432 | + .parent = TYPE_TMP421, | ||
433 | + .class_init = tmp421_class_init, | ||
434 | + .class_data = (void *) &devices[i], | ||
435 | + }; | ||
436 | + type_register(&ti); | ||
437 | + } | ||
438 | +} | ||
439 | + | ||
440 | +type_init(tmp421_register_types) | ||
441 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | ||
442 | index XXXXXXX..XXXXXXX 100644 | ||
443 | --- a/default-configs/arm-softmmu.mak | ||
444 | +++ b/default-configs/arm-softmmu.mak | ||
445 | @@ -XXX,XX +XXX,XX @@ CONFIG_TWL92230=y | ||
446 | CONFIG_TSC2005=y | ||
447 | CONFIG_LM832X=y | ||
448 | CONFIG_TMP105=y | ||
449 | +CONFIG_TMP421=y | ||
450 | CONFIG_STELLARIS=y | ||
451 | CONFIG_STELLARIS_INPUT=y | ||
452 | CONFIG_STELLARIS_ENET=y | ||
453 | -- | 151 | -- |
454 | 2.7.4 | 152 | 2.20.1 |
455 | 153 | ||
456 | 154 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Temperatures can be changed from the monitor with : | ||
4 | |||
5 | (qemu) qom-set /machine/unattached/device[2] temperature0 12000 | ||
6 | |||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 1496739230-32109-3-git-send-email-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/aspeed.c | 9 +++++++++ | ||
13 | 1 file changed, 9 insertions(+) | ||
14 | |||
15 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/aspeed.c | ||
18 | +++ b/hw/arm/aspeed.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
20 | static void palmetto_bmc_i2c_init(AspeedBoardState *bmc) | ||
21 | { | ||
22 | AspeedSoCState *soc = &bmc->soc; | ||
23 | + DeviceState *dev; | ||
24 | |||
25 | /* The palmetto platform expects a ds3231 RTC but a ds1338 is | ||
26 | * enough to provide basic RTC features. Alarms will be missing */ | ||
27 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68); | ||
28 | + | ||
29 | + /* add a TMP423 temperature sensor */ | ||
30 | + dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2), | ||
31 | + "tmp423", 0x4c); | ||
32 | + object_property_set_int(OBJECT(dev), 31000, "temperature0", &error_abort); | ||
33 | + object_property_set_int(OBJECT(dev), 28000, "temperature1", &error_abort); | ||
34 | + object_property_set_int(OBJECT(dev), 20000, "temperature2", &error_abort); | ||
35 | + object_property_set_int(OBJECT(dev), 110000, "temperature3", &error_abort); | ||
36 | } | ||
37 | |||
38 | static void palmetto_bmc_init(MachineState *machine) | ||
39 | -- | ||
40 | 2.7.4 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | When a timer is enabled before a reload value is set, the controller | ||
4 | waits for a reload value to be set before starting decrementing. This | ||
5 | fix tries to cover that case by changing the timer expiry only when | ||
6 | a reload value is valid. | ||
7 | |||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
10 | Message-id: 1496739312-32304-1-git-send-email-clg@kaod.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/timer/aspeed_timer.c | 37 +++++++++++++++++++++++++++++-------- | ||
14 | 1 file changed, 29 insertions(+), 8 deletions(-) | ||
15 | |||
16 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/timer/aspeed_timer.c | ||
19 | +++ b/hw/timer/aspeed_timer.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | ||
21 | next = seq[1]; | ||
22 | } else if (now < seq[2]) { | ||
23 | next = seq[2]; | ||
24 | - } else { | ||
25 | + } else if (t->reload) { | ||
26 | reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate); | ||
27 | t->start = now - ((now - t->start) % reload_ns); | ||
28 | + } else { | ||
29 | + /* no reload value, return 0 */ | ||
30 | + break; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | return next; | ||
35 | } | ||
36 | |||
37 | +static void aspeed_timer_mod(AspeedTimer *t) | ||
38 | +{ | ||
39 | + uint64_t next = calculate_next(t); | ||
40 | + if (next) { | ||
41 | + timer_mod(&t->timer, next); | ||
42 | + } | ||
43 | +} | ||
44 | + | ||
45 | static void aspeed_timer_expire(void *opaque) | ||
46 | { | ||
47 | AspeedTimer *t = opaque; | ||
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_expire(void *opaque) | ||
49 | qemu_set_irq(t->irq, t->level); | ||
50 | } | ||
51 | |||
52 | - timer_mod(&t->timer, calculate_next(t)); | ||
53 | + aspeed_timer_mod(t); | ||
54 | } | ||
55 | |||
56 | static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg) | ||
57 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, | ||
58 | uint32_t value) | ||
59 | { | ||
60 | AspeedTimer *t; | ||
61 | + uint32_t old_reload; | ||
62 | |||
63 | trace_aspeed_timer_set_value(timer, reg, value); | ||
64 | t = &s->timers[timer]; | ||
65 | switch (reg) { | ||
66 | + case TIMER_REG_RELOAD: | ||
67 | + old_reload = t->reload; | ||
68 | + t->reload = value; | ||
69 | + | ||
70 | + /* If the reload value was not previously set, or zero, and | ||
71 | + * the current value is valid, try to start the timer if it is | ||
72 | + * enabled. | ||
73 | + */ | ||
74 | + if (old_reload || !t->reload) { | ||
75 | + break; | ||
76 | + } | ||
77 | + | ||
78 | case TIMER_REG_STATUS: | ||
79 | if (timer_enabled(t)) { | ||
80 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, | ||
82 | uint32_t rate = calculate_rate(t); | ||
83 | |||
84 | t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); | ||
85 | - timer_mod(&t->timer, calculate_next(t)); | ||
86 | + aspeed_timer_mod(t); | ||
87 | } | ||
88 | break; | ||
89 | - case TIMER_REG_RELOAD: | ||
90 | - t->reload = value; | ||
91 | - break; | ||
92 | case TIMER_REG_MATCH_FIRST: | ||
93 | case TIMER_REG_MATCH_SECOND: | ||
94 | t->match[reg - 2] = value; | ||
95 | if (timer_enabled(t)) { | ||
96 | - timer_mod(&t->timer, calculate_next(t)); | ||
97 | + aspeed_timer_mod(t); | ||
98 | } | ||
99 | break; | ||
100 | default: | ||
101 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_ctrl_enable(AspeedTimer *t, bool enable) | ||
102 | trace_aspeed_timer_ctrl_enable(t->id, enable); | ||
103 | if (enable) { | ||
104 | t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
105 | - timer_mod(&t->timer, calculate_next(t)); | ||
106 | + aspeed_timer_mod(t); | ||
107 | } else { | ||
108 | timer_del(&t->timer); | ||
109 | } | ||
110 | -- | ||
111 | 2.7.4 | ||
112 | |||
113 | diff view generated by jsdifflib |