Skip to contentSkip to conversation

hw/dma: Convert DMA devices to Resettable interface

PATCH New Oscar Alejandro Sánchez Lucero 1 participant 11 messages Dec 1

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover hw/dma: Convert DMA devices to Resettable interface

Convert the remaining DMA devices in hw/dma/ away from the deprecated device_class_set_legacy_reset() wrapper to the ResettableClass interface (hold phase), moving towards removing the legacy_reset callback from DeviceClass once all callers are migrated (as noted in include/hw/core/qdev.h).

Note: hw/dma/xlnx_csu_dma.c is excluded from this series as it was already submitted separately.

---
Oscar Alejandro Sánchez Lucero (10):
hw/dma/sparc32_dma: Convert to Resettable interface hw/dma/xilinx_axidma: Convert to Resettable interface hw/dma/xlnx-zdma: Convert to Resettable interface hw/dma/xlnx-zynq-devcfg: Convert to Resettable interface hw/dma/xlnx_dpdma: Convert to Resettable interface hw/dma/bcm2835_dma: Convert to Resettable interface hw/dma/i8257: Convert to Resettable interface hw/dma/pl080: Convert to Resettable interface hw/dma/pl330: Convert to Resettable interface hw/dma/rc4030: Convert to Resettable interface

 hw/dma/bcm2835_dma.c      | 9 +++++----
 hw/dma/i8257.c            | 7 ++++---
 hw/dma/pl080.c            | 7 ++++---
 hw/dma/pl330.c            | 7 ++++---
 hw/dma/rc4030.c           | 7 ++++---
 hw/dma/sparc32_dma.c      | 7 ++++---
 hw/dma/xilinx_axidma.c    | 7 ++++---
 hw/dma/xlnx-zdma.c        | 7 ++++---
 hw/dma/xlnx-zynq-devcfg.c | 7 ++++---
 hw/dma/xlnx_dpdma.c       | 7 ++++---
 10 files changed, 41 insertions(+), 31 deletions(-)

---
base-commit: 9751c62358073580cbf330a4df22077a7c6a407c
change-id: 20261201-dma-resettable-d98e14bdbd78

Best regards,

Signature · 1 line
Oscar Alejandro Sánchez Lucero <[email protected]>
#1 lore raw

PATCH 1/10 hw/dma/sparc32_dma: Convert to Resettable interface

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in sparc32_dma_device_reset_hold().

---
 hw/dma/sparc32_dma.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/sparc32_dma.c +4 -3
index a5dc35e..f60dce2 100644
@@ -237,9 +237,9 @@ static const MemoryRegionOps dma_mem_ops = {
     },
 };
 
-static void sparc32_dma_device_reset(DeviceState *d)
+static void sparc32_dma_device_reset_hold(Object *obj, ResetType type)
 {
-    DMADeviceState *s = SPARC32_DMA_DEVICE(d);
+    DMADeviceState *s = SPARC32_DMA_DEVICE(obj);
 
     memset(s->dmaregs, 0, DMA_SIZE);
     s->dmaregs[0] = DMA_VER;
@@ -277,8 +277,9 @@ static void sparc32_dma_device_init(Object *obj)
 static void sparc32_dma_device_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, sparc32_dma_device_reset);
+    rc->phases.hold = sparc32_dma_device_reset_hold;
     dc->vmsd = &vmstate_sparc32_dma_device;
 }
 
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/10 hw/dma/xilinx_axidma: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in xilinx_axidma_reset_hold().

---
 hw/dma/xilinx_axidma.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/xilinx_axidma.c +4 -3
index 22dec8b..40f17e0 100644
@@ -403,10 +403,10 @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
     return pos;
 }
 
-static void xilinx_axidma_reset(DeviceState *dev)
+static void xilinx_axidma_reset_hold(Object *obj, ResetType type)
 {
     int i;
-    XilinxAXIDMA *s = XILINX_AXI_DMA(dev);
+    XilinxAXIDMA *s = XILINX_AXI_DMA(obj);
 
     for (i = 0; i < 2; i++) {
         stream_reset(&s->streams[i]);
@@ -624,9 +624,10 @@ static const Property axidma_properties[] = {
 static void axidma_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = xilinx_axidma_realize;
-    device_class_set_legacy_reset(dc, xilinx_axidma_reset);
+    rc->phases.hold = xilinx_axidma_reset_hold;
     device_class_set_props(dc, axidma_properties);
 }
 
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/10 hw/dma/xlnx-zdma: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in zdma_reset_hold().

---
 hw/dma/xlnx-zdma.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/xlnx-zdma.c +4 -3
index 306c56c..ef46c76 100644
@@ -701,9 +701,9 @@ static RegisterAccessInfo zdma_regs_info[] = {
     }
 };
 
-static void zdma_reset(DeviceState *dev)
+static void zdma_reset_hold(Object *obj, ResetType type)
 {
-    XlnxZDMA *s = XLNX_ZDMA(dev);
+    XlnxZDMA *s = XLNX_ZDMA(obj);
     unsigned int i;
 
     for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
@@ -819,8 +819,9 @@ static const Property zdma_props[] = {
 static void zdma_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, zdma_reset);
+    rc->phases.hold = zdma_reset_hold;
     dc->realize = zdma_realize;
     device_class_set_props(dc, zdma_props);
     dc->vmsd = &vmstate_zdma;
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/10 hw/dma/xlnx-zynq-devcfg: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in xlnx_zynq_devcfg_reset_hold().

---
 hw/dma/xlnx-zynq-devcfg.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/xlnx-zynq-devcfg.c +4 -3
index 5608460..e344b4b 100644
@@ -140,9 +140,9 @@ static void xlnx_zynq_devcfg_update_ixr(XlnxZynqDevcfg *s)
     qemu_set_irq(s->irq, ~s->regs[R_INT_MASK] & s->regs[R_INT_STS]);
 }
 
-static void xlnx_zynq_devcfg_reset(DeviceState *dev)
+static void xlnx_zynq_devcfg_reset_hold(Object *obj, ResetType type)
 {
-    XlnxZynqDevcfg *s = XLNX_ZYNQ_DEVCFG(dev);
+    XlnxZynqDevcfg *s = XLNX_ZYNQ_DEVCFG(obj);
     int i;
 
     for (i = 0; i < XLNX_ZYNQ_DEVCFG_R_MAX; ++i) {
@@ -404,8 +404,9 @@ static void xlnx_zynq_devcfg_init(Object *obj)
 static void xlnx_zynq_devcfg_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, xlnx_zynq_devcfg_reset);
+    rc->phases.hold = xlnx_zynq_devcfg_reset_hold;
     dc->vmsd = &vmstate_xlnx_zynq_devcfg;
 }
 
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/10 hw/dma/xlnx_dpdma: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in xlnx_dpdma_reset_hold().

---
 hw/dma/xlnx_dpdma.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/xlnx_dpdma.c +4 -3
index 9d8e759..ee41c8d 100644
@@ -576,9 +576,9 @@ static void xlnx_dpdma_init(Object *obj)
     sysbus_init_irq(sbd, &s->irq);
 }
 
-static void xlnx_dpdma_reset(DeviceState *dev)
+static void xlnx_dpdma_reset_hold(Object *obj, ResetType type)
 {
-    XlnxDPDMAState *s = XLNX_DPDMA(dev);
+    XlnxDPDMAState *s = XLNX_DPDMA(obj);
     size_t i;
 
     memset(s->registers, 0, sizeof(s->registers));
@@ -597,9 +597,10 @@ static void xlnx_dpdma_reset(DeviceState *dev)
 static void xlnx_dpdma_class_init(ObjectClass *oc, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
+    ResettableClass *rc = RESETTABLE_CLASS(oc);
 
     dc->vmsd = &vmstate_xlnx_dpdma;
-    device_class_set_legacy_reset(dc, xlnx_dpdma_reset);
+    rc->phases.hold = xlnx_dpdma_reset_hold;
 }
 
 static const TypeInfo xlnx_dpdma_info = {
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/10 hw/dma/bcm2835_dma: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in bcm2835_dma_reset_hold(), and call device_cold_reset() in realize.

---
 hw/dma/bcm2835_dma.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
hw/dma/bcm2835_dma.c +5 -4
index b842aef..8a80f32 100644
@@ -378,9 +378,9 @@ static void bcm2835_dma_init(Object *obj)
     }
 }
 
-static void bcm2835_dma_reset(DeviceState *dev)
+static void bcm2835_dma_reset_hold(Object *obj, ResetType type)
 {
-    BCM2835DMAState *s = BCM2835_DMA(dev);
+    BCM2835DMAState *s = BCM2835_DMA(obj);
     int n;
 
     s->enable = 0xffff;
@@ -399,15 +399,16 @@ static void bcm2835_dma_realize(DeviceState *dev, Error **errp)
     s->dma_mr = MEMORY_REGION(obj);
     address_space_init(&s->dma_as, s->dma_mr, TYPE_BCM2835_DMA "-memory");
 
-    bcm2835_dma_reset(dev);
+    device_cold_reset(dev);
 }
 
 static void bcm2835_dma_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = bcm2835_dma_realize;
-    device_class_set_legacy_reset(dc, bcm2835_dma_reset);
+    rc->phases.hold = bcm2835_dma_reset_hold;
     dc->vmsd = &vmstate_bcm2835_dma;
 }
 
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/10 hw/dma/i8257: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in i8257_reset_hold().

---
 hw/dma/i8257.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/i8257.c +4 -3
index 8ff4cbf..89a3648 100644
@@ -487,9 +487,9 @@ static void i8257_dma_schedule(IsaDma *obj)
     }
 }
 
-static void i8257_reset(DeviceState *dev)
+static void i8257_reset_hold(Object *obj, ResetType type)
 {
-    I8257State *d = I8257(dev);
+    I8257State *d = I8257(obj);
     i8257_write_cont(d, (0x05 << d->dshift), 0, 1);
 }
 
@@ -618,9 +618,10 @@ static void i8257_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     IsaDmaClass *idc = ISADMA_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = i8257_realize;
-    device_class_set_legacy_reset(dc, i8257_reset);
+    rc->phases.hold = i8257_reset_hold;
     dc->vmsd = &vmstate_i8257;
     device_class_set_props(dc, i8257_properties);
 
Signature · 1 line
2.53.0
#8 lore raw

PATCH 8/10 hw/dma/pl080: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in pl080_reset_hold().

---
 hw/dma/pl080.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/pl080.c +4 -3
index f9f1e3e..4692e08 100644
@@ -375,9 +375,9 @@ static const MemoryRegionOps pl080_ops = {
     .endianness = DEVICE_NATIVE_ENDIAN,
 };
 
-static void pl080_reset(DeviceState *dev)
+static void pl080_reset_hold(Object *obj, ResetType type)
 {
-    PL080State *s = PL080(dev);
+    PL080State *s = PL080(obj);
     int i;
 
     s->tc_int = 0;
@@ -439,11 +439,12 @@ static const Property pl080_properties[] = {
 static void pl080_class_init(ObjectClass *oc, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(oc);
+    ResettableClass *rc = RESETTABLE_CLASS(oc);
 
     dc->vmsd = &vmstate_pl080;
     dc->realize = pl080_realize;
     device_class_set_props(dc, pl080_properties);
-    device_class_set_legacy_reset(dc, pl080_reset);
+    rc->phases.hold = pl080_reset_hold;
 }
 
 static const TypeInfo pl080_info = {
Signature · 1 line
2.53.0
#9 lore raw

PATCH 9/10 hw/dma/pl330: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in pl330_reset_hold().

---
 hw/dma/pl330.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/pl330.c +4 -3
index 5a8df39..ea5ef0b 100644
@@ -1524,10 +1524,10 @@ static void pl330_chan_reset(PL330Chan *ch)
     ch->fault_type = 0;
 }
 
-static void pl330_reset(DeviceState *d)
+static void pl330_reset_hold(Object *obj, ResetType type)
 {
     int i;
-    PL330State *s = PL330(d);
+    PL330State *s = PL330(obj);
 
     s->inten = 0;
     s->int_status = 0;
@@ -1672,9 +1672,10 @@ static const Property pl330_properties[] = {
 static void pl330_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = pl330_realize;
-    device_class_set_legacy_reset(dc, pl330_reset);
+    rc->phases.hold = pl330_reset_hold;
     device_class_set_props(dc, pl330_properties);
     dc->vmsd = &vmstate_pl330;
 }
Signature · 1 line
2.53.0
#10 lore raw

PATCH 10/10 hw/dma/rc4030: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in rc4030_reset_hold().

---
 hw/dma/rc4030.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/dma/rc4030.c +4 -3
index 546ff67..9676b6f 100644
@@ -526,9 +526,9 @@ static IOMMUTLBEntry rc4030_dma_translate(IOMMUMemoryRegion *iommu, hwaddr addr,
     return ret;
 }
 
-static void rc4030_reset(DeviceState *dev)
+static void rc4030_reset_hold(Object *obj, ResetType type)
 {
-    rc4030State *s = RC4030(dev);
+    rc4030State *s = RC4030(obj);
     int i;
 
     s->config = 0x410; /* some boards seem to accept 0x104 too */
@@ -706,10 +706,11 @@ static void rc4030_unrealize(DeviceState *dev)
 static void rc4030_class_init(ObjectClass *klass, const void *class_data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = rc4030_realize;
     dc->unrealize = rc4030_unrealize;
-    device_class_set_legacy_reset(dc, rc4030_reset);
+    rc->phases.hold = rc4030_reset_hold;
     dc->vmsd = &vmstate_rc4030;
 }
 
Signature · 1 line
2.53.0