All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset
@ 2022-11-09 16:14 Peter Maydell
  2022-11-09 16:14 ` [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU " Peter Maydell
                   ` (8 more replies)
  0 siblings, 9 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

This patchset converts some Arm devices to 3-phase reset.  The
rationale here is that it would be nice to get rid of the
device_class_set_parent_reset() function, which is used by
legacy-reset subclasses which want to chain to their parent's reset
function. There aren't very many of these devices in total, and
if we convert them and their parent classes to 3-phase reset they
can use the 3-phase-reset equivalent function
resettable_class_set_parent_phases().

Eventually this will then let us simplify the transitional
code for handling old-style device reset.

Note that it's necessary to convert the parent class before
the subclass -- the resettable transitional logic will
handle the situation where the subclass is still using
legacy reset and chaining to what it thinks is the parent's
legacy reset function (by doing a 3-phase reset on the parent),
but if the subclass is 3-phase then the parent must be too.

I plan to do the other uses of device_class_set_parent_reset()
too, but since the conversion patchsets don't depend on each
other I'm going to send them out piecemeal so they can be
cc'd to the relevant maintainers, rather than having a
single massive patchset with a billion people on cc.

thanks
-- PMM

Peter Maydell (9):
  hw/arm: Convert TYPE_ARM_SMMU to 3-phase reset
  hw/arm: Convert TYPE_ARM_SMMUV3 to 3-phase reset
  hw/intc: Convert TYPE_ARM_GIC_COMMON to 3-phase reset
  hw/intc: Convert TYPE_ARM_GIC_KVM to 3-phase reset
  hw/intc: Convert TYPE_ARM_GICV3_COMMON to 3-phase reset
  hw/intc: Convert TYPE_KVM_ARM_GICV3 to 3-phase reset
  hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON to 3-phase reset
  hw/intc: Convert TYPE_ARM_GICV3_ITS to 3-phase reset
  hw/intc: Convert TYPE_KVM_ARM_ITS to 3-phase reset

 include/hw/arm/smmuv3.h        |  2 +-
 hw/arm/smmu-common.c           |  7 ++++---
 hw/arm/smmuv3.c                | 12 ++++++++----
 hw/intc/arm_gic_common.c       |  7 ++++---
 hw/intc/arm_gic_kvm.c          | 14 +++++++++-----
 hw/intc/arm_gicv3_common.c     |  7 ++++---
 hw/intc/arm_gicv3_its.c        | 14 +++++++++-----
 hw/intc/arm_gicv3_its_common.c |  7 ++++---
 hw/intc/arm_gicv3_its_kvm.c    | 14 +++++++++-----
 hw/intc/arm_gicv3_kvm.c        | 14 +++++++++-----
 10 files changed, 61 insertions(+), 37 deletions(-)

-- 
2.25.1



^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-09 22:37   ` Philippe Mathieu-Daudé
                     ` (2 more replies)
  2022-11-09 16:14 ` [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 " Peter Maydell
                   ` (7 subsequent siblings)
  8 siblings, 3 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_ARM_SMMU device to 3-phase reset.  The legacy method
doesn't do anything that's invalid in the hold phase, so the
conversion is simple and not a behaviour change.

Note that we must convert this base class before we can convert the
TYPE_ARM_SMMUV3 subclass -- transitional support in Resettable
handles "chain to parent class reset" when the base class is 3-phase
and the subclass is still using legacy reset, but not the other way
around.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/smmu-common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index e09b9c13b74..220838525d4 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -526,9 +526,9 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
     }
 }
 
-static void smmu_base_reset(DeviceState *dev)
+static void smmu_base_reset_hold(Object *obj)
 {
-    SMMUState *s = ARM_SMMU(dev);
+    SMMUState *s = ARM_SMMU(obj);
 
     g_hash_table_remove_all(s->configs);
     g_hash_table_remove_all(s->iotlb);
@@ -543,12 +543,13 @@ static Property smmu_dev_properties[] = {
 static void smmu_base_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     SMMUBaseClass *sbc = ARM_SMMU_CLASS(klass);
 
     device_class_set_props(dc, smmu_dev_properties);
     device_class_set_parent_realize(dc, smmu_base_realize,
                                     &sbc->parent_realize);
-    dc->reset = smmu_base_reset;
+    rc->phases.hold = smmu_base_reset_hold;
 }
 
 static const TypeInfo smmu_base_info = {
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
  2022-11-09 16:14 ` [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-10  5:41   ` Richard Henderson
                     ` (2 more replies)
  2022-11-09 16:14 ` [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON " Peter Maydell
                   ` (6 subsequent siblings)
  8 siblings, 3 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_ARM_SMMUV3 device to 3-phase reset.  The legacy
reset method doesn't do anything that's invalid in the hold phase, so
the conversion only requires changing it to a hold phase method, and
using the 3-phase versions of the "save the parent reset method and
chain to it" code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/hw/arm/smmuv3.h |  2 +-
 hw/arm/smmuv3.c         | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
index c641e60735e..f1921fdf9e7 100644
--- a/include/hw/arm/smmuv3.h
+++ b/include/hw/arm/smmuv3.h
@@ -77,7 +77,7 @@ struct SMMUv3Class {
     /*< public >*/
 
     DeviceRealize parent_realize;
-    DeviceReset   parent_reset;
+    ResettablePhases parent_phases;
 };
 
 #define TYPE_ARM_SMMUV3   "arm-smmuv3"
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index daa80e9c7b6..955b89c8d59 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -1431,12 +1431,14 @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev)
     }
 }
 
-static void smmu_reset(DeviceState *dev)
+static void smmu_reset_hold(Object *obj)
 {
-    SMMUv3State *s = ARM_SMMUV3(dev);
+    SMMUv3State *s = ARM_SMMUV3(obj);
     SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
 
-    c->parent_reset(dev);
+    if (c->parent_phases.hold) {
+        c->parent_phases.hold(obj);
+    }
 
     smmuv3_init_regs(s);
 }
@@ -1520,10 +1522,12 @@ static void smmuv3_instance_init(Object *obj)
 static void smmuv3_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     SMMUv3Class *c = ARM_SMMUV3_CLASS(klass);
 
     dc->vmsd = &vmstate_smmuv3;
-    device_class_set_parent_reset(dc, smmu_reset, &c->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, smmu_reset_hold, NULL,
+                                       &c->parent_phases);
     c->parent_realize = dc->realize;
     dc->realize = smmu_realize;
 }
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
  2022-11-09 16:14 ` [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU " Peter Maydell
  2022-11-09 16:14 ` [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-09 22:37   ` Philippe Mathieu-Daudé
  2022-11-10  5:41   ` Richard Henderson
  2022-11-09 16:14 ` [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM " Peter Maydell
                   ` (5 subsequent siblings)
  8 siblings, 2 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_ARM_GIC_COMMON device to 3-phase reset.  This is a
simple no-behaviour-change conversion.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/intc/arm_gic_common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c
index 7b44d5625b6..a379cea3959 100644
--- a/hw/intc/arm_gic_common.c
+++ b/hw/intc/arm_gic_common.c
@@ -261,9 +261,9 @@ static inline void arm_gic_common_reset_irq_state(GICState *s, int first_cpu,
     }
 }
 
-static void arm_gic_common_reset(DeviceState *dev)
+static void arm_gic_common_reset_hold(Object *obj)
 {
-    GICState *s = ARM_GIC_COMMON(dev);
+    GICState *s = ARM_GIC_COMMON(obj);
     int i, j;
     int resetprio;
 
@@ -364,9 +364,10 @@ static Property arm_gic_common_properties[] = {
 static void arm_gic_common_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     ARMLinuxBootIfClass *albifc = ARM_LINUX_BOOT_IF_CLASS(klass);
 
-    dc->reset = arm_gic_common_reset;
+    rc->phases.hold = arm_gic_common_reset_hold;
     dc->realize = arm_gic_common_realize;
     device_class_set_props(dc, arm_gic_common_properties);
     dc->vmsd = &vmstate_gic;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
                   ` (2 preceding siblings ...)
  2022-11-09 16:14 ` [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-10  5:42   ` Richard Henderson
  2022-11-30 10:29   ` Philippe Mathieu-Daudé
  2022-11-09 16:14 ` [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON " Peter Maydell
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Now we have converted TYPE_ARM_GIC_COMMON, we can convert the
TYPE_ARM_GIC_KVM subclass to 3-phase reset.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/intc/arm_gic_kvm.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
index 7d2a13273a4..1d588946bce 100644
--- a/hw/intc/arm_gic_kvm.c
+++ b/hw/intc/arm_gic_kvm.c
@@ -38,7 +38,7 @@ DECLARE_OBJ_CHECKERS(GICState, KVMARMGICClass,
 struct KVMARMGICClass {
     ARMGICCommonClass parent_class;
     DeviceRealize parent_realize;
-    void (*parent_reset)(DeviceState *dev);
+    ResettablePhases parent_phases;
 };
 
 void kvm_arm_gic_set_irq(uint32_t num_irq, int irq, int level)
@@ -473,12 +473,14 @@ static void kvm_arm_gic_get(GICState *s)
     }
 }
 
-static void kvm_arm_gic_reset(DeviceState *dev)
+static void kvm_arm_gic_reset_hold(Object *obj)
 {
-    GICState *s = ARM_GIC_COMMON(dev);
+    GICState *s = ARM_GIC_COMMON(obj);
     KVMARMGICClass *kgc = KVM_ARM_GIC_GET_CLASS(s);
 
-    kgc->parent_reset(dev);
+    if (kgc->parent_phases.hold) {
+        kgc->parent_phases.hold(obj);
+    }
 
     if (kvm_arm_gic_can_save_restore(s)) {
         kvm_arm_gic_put(s);
@@ -593,6 +595,7 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
 static void kvm_arm_gic_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     ARMGICCommonClass *agcc = ARM_GIC_COMMON_CLASS(klass);
     KVMARMGICClass *kgc = KVM_ARM_GIC_CLASS(klass);
 
@@ -600,7 +603,8 @@ static void kvm_arm_gic_class_init(ObjectClass *klass, void *data)
     agcc->post_load = kvm_arm_gic_put;
     device_class_set_parent_realize(dc, kvm_arm_gic_realize,
                                     &kgc->parent_realize);
-    device_class_set_parent_reset(dc, kvm_arm_gic_reset, &kgc->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, kvm_arm_gic_reset_hold, NULL,
+                                       &kgc->parent_phases);
 }
 
 static const TypeInfo kvm_arm_gic_info = {
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
                   ` (3 preceding siblings ...)
  2022-11-09 16:14 ` [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-10  5:42   ` Richard Henderson
  2022-11-30 10:30   ` Philippe Mathieu-Daudé
  2022-11-09 16:14 ` [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 " Peter Maydell
                   ` (3 subsequent siblings)
  8 siblings, 2 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_ARM_GICV3_COMMON parent class to 3-phase reset.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/intc/arm_gicv3_common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
index 351843db4aa..642a8243ed4 100644
--- a/hw/intc/arm_gicv3_common.c
+++ b/hw/intc/arm_gicv3_common.c
@@ -450,9 +450,9 @@ static void arm_gicv3_finalize(Object *obj)
     g_free(s->redist_region_count);
 }
 
-static void arm_gicv3_common_reset(DeviceState *dev)
+static void arm_gicv3_common_reset_hold(Object *obj)
 {
-    GICv3State *s = ARM_GICV3_COMMON(dev);
+    GICv3State *s = ARM_GICV3_COMMON(obj);
     int i;
 
     for (i = 0; i < s->num_cpu; i++) {
@@ -578,9 +578,10 @@ static Property arm_gicv3_common_properties[] = {
 static void arm_gicv3_common_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     ARMLinuxBootIfClass *albifc = ARM_LINUX_BOOT_IF_CLASS(klass);
 
-    dc->reset = arm_gicv3_common_reset;
+    rc->phases.hold = arm_gicv3_common_reset_hold;
     dc->realize = arm_gicv3_common_realize;
     device_class_set_props(dc, arm_gicv3_common_properties);
     dc->vmsd = &vmstate_gicv3;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
                   ` (4 preceding siblings ...)
  2022-11-09 16:14 ` [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-10  5:43   ` Richard Henderson
  2022-11-30 10:32   ` Philippe Mathieu-Daudé
  2022-11-09 16:14 ` [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON " Peter Maydell
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_KVM_ARM_GICV3 device to 3-phase reset.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/intc/arm_gicv3_kvm.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
index 3ca643ecba4..72ad916d3db 100644
--- a/hw/intc/arm_gicv3_kvm.c
+++ b/hw/intc/arm_gicv3_kvm.c
@@ -77,7 +77,7 @@ DECLARE_OBJ_CHECKERS(GICv3State, KVMARMGICv3Class,
 struct KVMARMGICv3Class {
     ARMGICv3CommonClass parent_class;
     DeviceRealize parent_realize;
-    void (*parent_reset)(DeviceState *dev);
+    ResettablePhases parent_phases;
 };
 
 static void kvm_arm_gicv3_set_irq(void *opaque, int irq, int level)
@@ -703,14 +703,16 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
 }
 
-static void kvm_arm_gicv3_reset(DeviceState *dev)
+static void kvm_arm_gicv3_reset_hold(Object *obj)
 {
-    GICv3State *s = ARM_GICV3_COMMON(dev);
+    GICv3State *s = ARM_GICV3_COMMON(obj);
     KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);
 
     DPRINTF("Reset\n");
 
-    kgc->parent_reset(dev);
+    if (kgc->parent_phases.hold) {
+        kgc->parent_phases.hold(obj);
+    }
 
     if (s->migration_blocker) {
         DPRINTF("Cannot put kernel gic state, no kernel interface\n");
@@ -890,6 +892,7 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
 static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     ARMGICv3CommonClass *agcc = ARM_GICV3_COMMON_CLASS(klass);
     KVMARMGICv3Class *kgc = KVM_ARM_GICV3_CLASS(klass);
 
@@ -897,7 +900,8 @@ static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data)
     agcc->post_load = kvm_arm_gicv3_put;
     device_class_set_parent_realize(dc, kvm_arm_gicv3_realize,
                                     &kgc->parent_realize);
-    device_class_set_parent_reset(dc, kvm_arm_gicv3_reset, &kgc->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, kvm_arm_gicv3_reset_hold, NULL,
+                                       &kgc->parent_phases);
 }
 
 static const TypeInfo kvm_arm_gicv3_info = {
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
                   ` (5 preceding siblings ...)
  2022-11-09 16:14 ` [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-09 22:38   ` Philippe Mathieu-Daudé
  2022-11-10  5:43   ` Richard Henderson
  2022-11-09 16:14 ` [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS " Peter Maydell
  2022-11-09 16:14 ` [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS " Peter Maydell
  8 siblings, 2 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_ARM_GICV3_ITS_COMMON parent class to 3-phase reset.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/intc/arm_gicv3_its_common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c
index 90b85f1e25c..d7532a7a899 100644
--- a/hw/intc/arm_gicv3_its_common.c
+++ b/hw/intc/arm_gicv3_its_common.c
@@ -122,9 +122,9 @@ void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops,
     msi_nonbroken = true;
 }
 
-static void gicv3_its_common_reset(DeviceState *dev)
+static void gicv3_its_common_reset_hold(Object *obj)
 {
-    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
+    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
 
     s->ctlr = 0;
     s->cbaser = 0;
@@ -137,8 +137,9 @@ static void gicv3_its_common_reset(DeviceState *dev)
 static void gicv3_its_common_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    dc->reset = gicv3_its_common_reset;
+    rc->phases.hold = gicv3_its_common_reset_hold;
     dc->vmsd = &vmstate_its;
 }
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
                   ` (6 preceding siblings ...)
  2022-11-09 16:14 ` [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-10  5:44   ` Richard Henderson
  2022-11-30 10:33   ` Philippe Mathieu-Daudé
  2022-11-09 16:14 ` [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS " Peter Maydell
  8 siblings, 2 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_ARM_GICV3_ITS device to 3-phase reset.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/intc/arm_gicv3_its.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
index 2ff21ed6bbe..57c79da5c55 100644
--- a/hw/intc/arm_gicv3_its.c
+++ b/hw/intc/arm_gicv3_its.c
@@ -27,7 +27,7 @@ DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSClass,
 
 struct GICv3ITSClass {
     GICv3ITSCommonClass parent_class;
-    void (*parent_reset)(DeviceState *dev);
+    ResettablePhases parent_phases;
 };
 
 /*
@@ -1953,12 +1953,14 @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp)
     }
 }
 
-static void gicv3_its_reset(DeviceState *dev)
+static void gicv3_its_reset_hold(Object *obj)
 {
-    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
+    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
     GICv3ITSClass *c = ARM_GICV3_ITS_GET_CLASS(s);
 
-    c->parent_reset(dev);
+    if (c->parent_phases.hold) {
+        c->parent_phases.hold(obj);
+    }
 
     /* Quiescent bit reset to 1 */
     s->ctlr = FIELD_DP32(s->ctlr, GITS_CTLR, QUIESCENT, 1);
@@ -2012,12 +2014,14 @@ static Property gicv3_its_props[] = {
 static void gicv3_its_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     GICv3ITSClass *ic = ARM_GICV3_ITS_CLASS(klass);
     GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass);
 
     dc->realize = gicv3_arm_its_realize;
     device_class_set_props(dc, gicv3_its_props);
-    device_class_set_parent_reset(dc, gicv3_its_reset, &ic->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, gicv3_its_reset_hold, NULL,
+                                       &ic->parent_phases);
     icc->post_load = gicv3_its_post_load;
 }
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS to 3-phase reset
  2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
                   ` (7 preceding siblings ...)
  2022-11-09 16:14 ` [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS " Peter Maydell
@ 2022-11-09 16:14 ` Peter Maydell
  2022-11-10  5:44   ` Richard Henderson
  2022-11-30 10:34   ` Philippe Mathieu-Daudé
  8 siblings, 2 replies; 30+ messages in thread
From: Peter Maydell @ 2022-11-09 16:14 UTC (permalink / raw)
  To: qemu-arm, qemu-devel

Convert the TYPE_KVM_ARM_ITS device to 3-phase reset.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/intc/arm_gicv3_its_kvm.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
index 529c7bd4946..7eda9fb86ea 100644
--- a/hw/intc/arm_gicv3_its_kvm.c
+++ b/hw/intc/arm_gicv3_its_kvm.c
@@ -37,7 +37,7 @@ DECLARE_OBJ_CHECKERS(GICv3ITSState, KVMARMITSClass,
 
 struct KVMARMITSClass {
     GICv3ITSCommonClass parent_class;
-    void (*parent_reset)(DeviceState *dev);
+    ResettablePhases parent_phases;
 };
 
 
@@ -197,13 +197,15 @@ static void kvm_arm_its_post_load(GICv3ITSState *s)
                       GITS_CTLR, &s->ctlr, true, &error_abort);
 }
 
-static void kvm_arm_its_reset(DeviceState *dev)
+static void kvm_arm_its_reset_hold(Object *obj)
 {
-    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
+    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
     KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s);
     int i;
 
-    c->parent_reset(dev);
+    if (c->parent_phases.hold) {
+        c->parent_phases.hold(obj);
+    }
 
     if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
                                KVM_DEV_ARM_ITS_CTRL_RESET)) {
@@ -241,12 +243,14 @@ static Property kvm_arm_its_props[] = {
 static void kvm_arm_its_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
     GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass);
     KVMARMITSClass *ic = KVM_ARM_ITS_CLASS(klass);
 
     dc->realize = kvm_arm_its_realize;
     device_class_set_props(dc, kvm_arm_its_props);
-    device_class_set_parent_reset(dc, kvm_arm_its_reset, &ic->parent_reset);
+    resettable_class_set_parent_phases(rc, NULL, kvm_arm_its_reset_hold, NULL,
+                                       &ic->parent_phases);
     icc->send_msi = kvm_its_send_msi;
     icc->pre_save = kvm_arm_its_pre_save;
     icc->post_load = kvm_arm_its_post_load;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON " Peter Maydell
@ 2022-11-09 22:37   ` Philippe Mathieu-Daudé
  2022-11-10  5:41   ` Richard Henderson
  1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-09 22:37 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GIC_COMMON device to 3-phase reset.  This is a
> simple no-behaviour-change conversion.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gic_common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU " Peter Maydell
@ 2022-11-09 22:37   ` Philippe Mathieu-Daudé
  2022-11-10  5:40   ` Richard Henderson
  2022-11-28 18:20   ` Eric Auger
  2 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-09 22:37 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_SMMU device to 3-phase reset.  The legacy method
> doesn't do anything that's invalid in the hold phase, so the
> conversion is simple and not a behaviour change.
> 
> Note that we must convert this base class before we can convert the
> TYPE_ARM_SMMUV3 subclass -- transitional support in Resettable
> handles "chain to parent class reset" when the base class is 3-phase
> and the subclass is still using legacy reset, but not the other way
> around.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/smmu-common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON " Peter Maydell
@ 2022-11-09 22:38   ` Philippe Mathieu-Daudé
  2022-11-10  5:43   ` Richard Henderson
  1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-09 22:38 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GICV3_ITS_COMMON parent class to 3-phase reset.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_its_common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU " Peter Maydell
  2022-11-09 22:37   ` Philippe Mathieu-Daudé
@ 2022-11-10  5:40   ` Richard Henderson
  2022-11-28 18:20   ` Eric Auger
  2 siblings, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:40 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_ARM_SMMU device to 3-phase reset.  The legacy method
> doesn't do anything that's invalid in the hold phase, so the
> conversion is simple and not a behaviour change.
> 
> Note that we must convert this base class before we can convert the
> TYPE_ARM_SMMUV3 subclass -- transitional support in Resettable
> handles "chain to parent class reset" when the base class is 3-phase
> and the subclass is still using legacy reset, but not the other way
> around.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/arm/smmu-common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 " Peter Maydell
@ 2022-11-10  5:41   ` Richard Henderson
  2022-11-28 18:19   ` Eric Auger
  2022-11-30 10:28   ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:41 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_ARM_SMMUV3 device to 3-phase reset.  The legacy
> reset method doesn't do anything that's invalid in the hold phase, so
> the conversion only requires changing it to a hold phase method, and
> using the 3-phase versions of the "save the parent reset method and
> chain to it" code.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   include/hw/arm/smmuv3.h |  2 +-
>   hw/arm/smmuv3.c         | 12 ++++++++----
>   2 files changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON " Peter Maydell
  2022-11-09 22:37   ` Philippe Mathieu-Daudé
@ 2022-11-10  5:41   ` Richard Henderson
  1 sibling, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:41 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GIC_COMMON device to 3-phase reset.  This is a
> simple no-behaviour-change conversion.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gic_common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM " Peter Maydell
@ 2022-11-10  5:42   ` Richard Henderson
  2022-11-30 10:29   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:42 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Now we have converted TYPE_ARM_GIC_COMMON, we can convert the
> TYPE_ARM_GIC_KVM subclass to 3-phase reset.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gic_kvm.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON " Peter Maydell
@ 2022-11-10  5:42   ` Richard Henderson
  2022-11-30 10:30   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:42 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GICV3_COMMON parent class to 3-phase reset.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 " Peter Maydell
@ 2022-11-10  5:43   ` Richard Henderson
  2022-11-30 10:32   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:43 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_KVM_ARM_GICV3 device to 3-phase reset.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_kvm.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON " Peter Maydell
  2022-11-09 22:38   ` Philippe Mathieu-Daudé
@ 2022-11-10  5:43   ` Richard Henderson
  1 sibling, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:43 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GICV3_ITS_COMMON parent class to 3-phase reset.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_its_common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS " Peter Maydell
@ 2022-11-10  5:44   ` Richard Henderson
  2022-11-30 10:33   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:44 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GICV3_ITS device to 3-phase reset.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_its.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS " Peter Maydell
@ 2022-11-10  5:44   ` Richard Henderson
  2022-11-30 10:34   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Richard Henderson @ 2022-11-10  5:44 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 11/10/22 03:14, Peter Maydell wrote:
> Convert the TYPE_KVM_ARM_ITS device to 3-phase reset.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_its_kvm.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 " Peter Maydell
  2022-11-10  5:41   ` Richard Henderson
@ 2022-11-28 18:19   ` Eric Auger
  2022-11-30 10:28   ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2022-11-28 18:19 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

Hi Peter,

On 11/9/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_SMMUV3 device to 3-phase reset.  The legacy
> reset method doesn't do anything that's invalid in the hold phase, so
> the conversion only requires changing it to a hold phase method, and
> using the 3-phase versions of the "save the parent reset method and
> chain to it" code.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Eric

> ---
>  include/hw/arm/smmuv3.h |  2 +-
>  hw/arm/smmuv3.c         | 12 ++++++++----
>  2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
> index c641e60735e..f1921fdf9e7 100644
> --- a/include/hw/arm/smmuv3.h
> +++ b/include/hw/arm/smmuv3.h
> @@ -77,7 +77,7 @@ struct SMMUv3Class {
>      /*< public >*/
>  
>      DeviceRealize parent_realize;
> -    DeviceReset   parent_reset;
> +    ResettablePhases parent_phases;
>  };
>  
>  #define TYPE_ARM_SMMUV3   "arm-smmuv3"
> diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
> index daa80e9c7b6..955b89c8d59 100644
> --- a/hw/arm/smmuv3.c
> +++ b/hw/arm/smmuv3.c
> @@ -1431,12 +1431,14 @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev)
>      }
>  }
>  
> -static void smmu_reset(DeviceState *dev)
> +static void smmu_reset_hold(Object *obj)
>  {
> -    SMMUv3State *s = ARM_SMMUV3(dev);
> +    SMMUv3State *s = ARM_SMMUV3(obj);
>      SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
>  
> -    c->parent_reset(dev);
> +    if (c->parent_phases.hold) {
> +        c->parent_phases.hold(obj);
> +    }
>  
>      smmuv3_init_regs(s);
>  }
> @@ -1520,10 +1522,12 @@ static void smmuv3_instance_init(Object *obj)
>  static void smmuv3_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> +    ResettableClass *rc = RESETTABLE_CLASS(klass);
>      SMMUv3Class *c = ARM_SMMUV3_CLASS(klass);
>  
>      dc->vmsd = &vmstate_smmuv3;
> -    device_class_set_parent_reset(dc, smmu_reset, &c->parent_reset);
> +    resettable_class_set_parent_phases(rc, NULL, smmu_reset_hold, NULL,
> +                                       &c->parent_phases);
>      c->parent_realize = dc->realize;
>      dc->realize = smmu_realize;
>  }



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU " Peter Maydell
  2022-11-09 22:37   ` Philippe Mathieu-Daudé
  2022-11-10  5:40   ` Richard Henderson
@ 2022-11-28 18:20   ` Eric Auger
  2 siblings, 0 replies; 30+ messages in thread
From: Eric Auger @ 2022-11-28 18:20 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

Hi Peter,

On 11/9/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_SMMU device to 3-phase reset.  The legacy method
> doesn't do anything that's invalid in the hold phase, so the
> conversion is simple and not a behaviour change.
> 
> Note that we must convert this base class before we can convert the
> TYPE_ARM_SMMUV3 subclass -- transitional support in Resettable
> handles "chain to parent class reset" when the base class is 3-phase
> and the subclass is still using legacy reset, but not the other way
> around.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  hw/arm/smmu-common.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
> index e09b9c13b74..220838525d4 100644
> --- a/hw/arm/smmu-common.c
> +++ b/hw/arm/smmu-common.c
> @@ -526,9 +526,9 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
>      }
>  }
>  
> -static void smmu_base_reset(DeviceState *dev)
> +static void smmu_base_reset_hold(Object *obj)
>  {
> -    SMMUState *s = ARM_SMMU(dev);
> +    SMMUState *s = ARM_SMMU(obj);
>  
>      g_hash_table_remove_all(s->configs);
>      g_hash_table_remove_all(s->iotlb);
> @@ -543,12 +543,13 @@ static Property smmu_dev_properties[] = {
>  static void smmu_base_class_init(ObjectClass *klass, void *data)
>  {
>      DeviceClass *dc = DEVICE_CLASS(klass);
> +    ResettableClass *rc = RESETTABLE_CLASS(klass);
>      SMMUBaseClass *sbc = ARM_SMMU_CLASS(klass);
>  
>      device_class_set_props(dc, smmu_dev_properties);
>      device_class_set_parent_realize(dc, smmu_base_realize,
>                                      &sbc->parent_realize);
> -    dc->reset = smmu_base_reset;
> +    rc->phases.hold = smmu_base_reset_hold;
>  }
>  
>  static const TypeInfo smmu_base_info = {



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 " Peter Maydell
  2022-11-10  5:41   ` Richard Henderson
  2022-11-28 18:19   ` Eric Auger
@ 2022-11-30 10:28   ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:28 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_SMMUV3 device to 3-phase reset.  The legacy
> reset method doesn't do anything that's invalid in the hold phase, so
> the conversion only requires changing it to a hold phase method, and
> using the 3-phase versions of the "save the parent reset method and
> chain to it" code.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/hw/arm/smmuv3.h |  2 +-
>   hw/arm/smmuv3.c         | 12 ++++++++----
>   2 files changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM " Peter Maydell
  2022-11-10  5:42   ` Richard Henderson
@ 2022-11-30 10:29   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:29 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Now we have converted TYPE_ARM_GIC_COMMON, we can convert the
> TYPE_ARM_GIC_KVM subclass to 3-phase reset.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gic_kvm.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON " Peter Maydell
  2022-11-10  5:42   ` Richard Henderson
@ 2022-11-30 10:30   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:30 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GICV3_COMMON parent class to 3-phase reset.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_common.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 " Peter Maydell
  2022-11-10  5:43   ` Richard Henderson
@ 2022-11-30 10:32   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:32 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_KVM_ARM_GICV3 device to 3-phase reset.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_kvm.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS " Peter Maydell
  2022-11-10  5:44   ` Richard Henderson
@ 2022-11-30 10:33   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:33 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_ARM_GICV3_ITS device to 3-phase reset.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_its.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS to 3-phase reset
  2022-11-09 16:14 ` [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS " Peter Maydell
  2022-11-10  5:44   ` Richard Henderson
@ 2022-11-30 10:34   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2022-11-30 10:34 UTC (permalink / raw)
  To: Peter Maydell, qemu-arm, qemu-devel

On 9/11/22 17:14, Peter Maydell wrote:
> Convert the TYPE_KVM_ARM_ITS device to 3-phase reset.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/intc/arm_gicv3_its_kvm.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2022-11-30 10:35 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 16:14 [PATCH for-8.0 0/9] arm: Convert Arm GIC, ITS, SMMU devices to 3-phase reset Peter Maydell
2022-11-09 16:14 ` [PATCH for-8.0 1/9] hw/arm: Convert TYPE_ARM_SMMU " Peter Maydell
2022-11-09 22:37   ` Philippe Mathieu-Daudé
2022-11-10  5:40   ` Richard Henderson
2022-11-28 18:20   ` Eric Auger
2022-11-09 16:14 ` [PATCH for-8.0 2/9] hw/arm: Convert TYPE_ARM_SMMUV3 " Peter Maydell
2022-11-10  5:41   ` Richard Henderson
2022-11-28 18:19   ` Eric Auger
2022-11-30 10:28   ` Philippe Mathieu-Daudé
2022-11-09 16:14 ` [PATCH for-8.0 3/9] hw/intc: Convert TYPE_ARM_GIC_COMMON " Peter Maydell
2022-11-09 22:37   ` Philippe Mathieu-Daudé
2022-11-10  5:41   ` Richard Henderson
2022-11-09 16:14 ` [PATCH for-8.0 4/9] hw/intc: Convert TYPE_ARM_GIC_KVM " Peter Maydell
2022-11-10  5:42   ` Richard Henderson
2022-11-30 10:29   ` Philippe Mathieu-Daudé
2022-11-09 16:14 ` [PATCH for-8.0 5/9] hw/intc: Convert TYPE_ARM_GICV3_COMMON " Peter Maydell
2022-11-10  5:42   ` Richard Henderson
2022-11-30 10:30   ` Philippe Mathieu-Daudé
2022-11-09 16:14 ` [PATCH for-8.0 6/9] hw/intc: Convert TYPE_KVM_ARM_GICV3 " Peter Maydell
2022-11-10  5:43   ` Richard Henderson
2022-11-30 10:32   ` Philippe Mathieu-Daudé
2022-11-09 16:14 ` [PATCH for-8.0 7/9] hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON " Peter Maydell
2022-11-09 22:38   ` Philippe Mathieu-Daudé
2022-11-10  5:43   ` Richard Henderson
2022-11-09 16:14 ` [PATCH for-8.0 8/9] hw/intc: Convert TYPE_ARM_GICV3_ITS " Peter Maydell
2022-11-10  5:44   ` Richard Henderson
2022-11-30 10:33   ` Philippe Mathieu-Daudé
2022-11-09 16:14 ` [PATCH for-8.0 9/9] hw/intc: Convert TYPE_KVM_ARM_ITS " Peter Maydell
2022-11-10  5:44   ` Richard Henderson
2022-11-30 10:34   ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.