[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 09/15] hw/timer: convert mptimer access to attrs to derive cpu
From: |
Alex Bennée |
Subject: |
[PATCH v3 09/15] hw/timer: convert mptimer access to attrs to derive cpu index |
Date: |
Tue, 27 Sep 2022 15:14:58 +0100 |
This removes the hacks to deal with empty current_cpu.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
v2
- update for new fields
- bool asserts
---
hw/timer/arm_mptimer.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
index cdfca3000b..34693a2534 100644
--- a/hw/timer/arm_mptimer.c
+++ b/hw/timer/arm_mptimer.c
@@ -41,9 +41,10 @@
* which is used in both the ARM11MPCore and Cortex-A9MP.
*/
-static inline int get_current_cpu(ARMMPTimerState *s)
+static inline int get_current_cpu(ARMMPTimerState *s, MemTxAttrs attrs)
{
- int cpu_id = current_cpu ? current_cpu->cpu_index : 0;
+ int cpu_id = attrs.requester_id;
+ g_assert(attrs.requester_type == MTRT_CPU);
if (cpu_id >= s->num_cpu) {
hw_error("arm_mptimer: num-cpu %d but this cpu is %d!\n",
@@ -178,25 +179,27 @@ static void timerblock_write(void *opaque, hwaddr addr,
/* Wrapper functions to implement the "read timer/watchdog for
* the current CPU" memory regions.
*/
-static uint64_t arm_thistimer_read(void *opaque, hwaddr addr,
- unsigned size)
+static MemTxResult arm_thistimer_read(void *opaque, hwaddr addr, uint64_t
*data,
+ unsigned size, MemTxAttrs attrs)
{
ARMMPTimerState *s = (ARMMPTimerState *)opaque;
- int id = get_current_cpu(s);
- return timerblock_read(&s->timerblock[id], addr, size);
+ int id = get_current_cpu(s, attrs);
+ *data = timerblock_read(&s->timerblock[id], addr, size);
+ return MEMTX_OK;
}
-static void arm_thistimer_write(void *opaque, hwaddr addr,
- uint64_t value, unsigned size)
+static MemTxResult arm_thistimer_write(void *opaque, hwaddr addr,
+ uint64_t value, unsigned size, MemTxAttrs
attrs)
{
ARMMPTimerState *s = (ARMMPTimerState *)opaque;
- int id = get_current_cpu(s);
+ int id = get_current_cpu(s, attrs);
timerblock_write(&s->timerblock[id], addr, value, size);
+ return MEMTX_OK;
}
static const MemoryRegionOps arm_thistimer_ops = {
- .read = arm_thistimer_read,
- .write = arm_thistimer_write,
+ .read_with_attrs = arm_thistimer_read,
+ .write_with_attrs = arm_thistimer_write,
.valid = {
.min_access_size = 4,
.max_access_size = 4,
--
2.34.1
- [PATCH v3 00/15] gdbstub/next (MemTxAttrs, re-factoring), Alex Bennée, 2022/09/27
- [PATCH v3 01/15] hw: encode accessing CPU index in MemTxAttrs, Alex Bennée, 2022/09/27
- [PATCH v3 06/15] target/arm: ensure m-profile helpers set appropriate MemTxAttrs, Alex Bennée, 2022/09/27
- [PATCH v3 03/15] target/arm: ensure HVF traps set appropriate MemTxAttrs, Alex Bennée, 2022/09/27
- [PATCH v3 02/15] target/arm: ensure TCG IO accesses set appropriate MemTxAttrs, Alex Bennée, 2022/09/27
- [PATCH v3 09/15] hw/timer: convert mptimer access to attrs to derive cpu index,
Alex Bennée <=
- [PATCH v3 05/15] target/arm: ensure ptw accesses set appropriate MemTxAttrs, Alex Bennée, 2022/09/27
- [PATCH v3 04/15] target/arm: ensure KVM traps set appropriate MemTxAttrs, Alex Bennée, 2022/09/27
- [PATCH v3 11/15] gdbstub: move into its own sub directory, Alex Bennée, 2022/09/27
- [PATCH v3 07/15] qtest: make read/write operation appear to be from CPU, Alex Bennée, 2022/09/27
- [PATCH v3 14/15] gdbstub: move guest debug support check to ops, Alex Bennée, 2022/09/27
- [PATCH v3 08/15] hw/intc/gic: use MxTxAttrs to divine accessing CPU, Alex Bennée, 2022/09/27