Skip to contentSkip to conversation

Ide patches

GIT PULL Applied John Snow 2 participants 5 messages Mar 16, 2017

lore
Share & tools
lore

John Snow

author
#0 lore raw

The following changes since commit 1883ff34b540daacae948f493b0ba525edf5f642:

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2017-03-15 18:44:05 +0000)

are available in the git repository at:

https://github.com/jnsnow/qemu.git tags/ide-pull-request

for you to fetch changes up to d68f0f778e7f4fbd674627274267f269e40f0b04:

ide: ahci: call cleanup function in ahci unit (2017-03-15 20:50:14 -0400)

----------------------------------------------------------------

----------------------------------------------------------------

Li Qiang (3):
ide: qdev: register ide bus unrealize function
ide: core: add cleanup function
ide: ahci: call cleanup function in ahci unit

 hw/ide/ahci.c             | 12 ++++++++++++
 hw/ide/core.c             |  8 ++++++++
 hw/ide/qdev.c             | 12 ++++++------
 include/hw/ide/internal.h |  1 +
 4 files changed, 27 insertions(+), 6 deletions(-)
Signature · 1 line
2.9.3
author
#1 lore raw

[Qemu-devel] [PULL for-rc1 1/3] ide: qdev: register ide bus unrealize function

From: Li Qiang <[email protected]>

we have an idebus unrealize function, but it was being registered as the unrealize function for the IDE Device, so it was not getting invoked on device teardown because nothing is "unrealizing" the IDE devices themselves.

Message-id: [email protected]

---
 hw/ide/qdev.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
hw/ide/qdev.c +6 -6
index 4383cd1..299e592 100644
@@ -31,7 +31,7 @@
 /* --------------------------------- */
 
 static char *idebus_get_fw_dev_path(DeviceState *dev);
-static void idebus_unrealize(DeviceState *qdev, Error **errp);
+static void idebus_unrealize(BusState *qdev, Error **errp);
 
 static Property ide_props[] = {
     DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1),
@@ -43,14 +43,15 @@ static void ide_bus_class_init(ObjectClass *klass, void *data)
     BusClass *k = BUS_CLASS(klass);
 
     k->get_fw_dev_path = idebus_get_fw_dev_path;
+    k->unrealize = idebus_unrealize;
 }
 
-static void idebus_unrealize(DeviceState *qdev, Error **errp)
+static void idebus_unrealize(BusState *bus, Error **errp)
 {
-    IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus);
+    IDEBus *ibus = IDE_BUS(bus);
 
-    if (bus->vmstate) {
-        qemu_del_vm_change_state_handler(bus->vmstate);
+    if (ibus->vmstate) {
+        qemu_del_vm_change_state_handler(ibus->vmstate);
     }
 }
 
@@ -370,7 +371,6 @@ static void ide_device_class_init(ObjectClass *klass, void *data)
     k->init = ide_qdev_init;
     set_bit(DEVICE_CATEGORY_STORAGE, k->categories);
     k->bus_type = TYPE_IDE_BUS;
-    k->unrealize = idebus_unrealize;
     k->props = ide_props;
 }
 
Signature · 1 line
2.9.3
author
#2 lore raw

[Qemu-devel] [PULL for-rc1 2/3] ide: core: add cleanup function

In reply to John Snow

From: Li Qiang <[email protected]>

As the pci ahci can be hotplug and unplug, in the ahci unrealize function it should free all the resource once allocated in the realized function. This patch add ide_exit to free the resource.

Message-id: [email protected]

---
 hw/ide/core.c             | 8 ++++++++
 include/hw/ide/internal.h | 1 +
 2 files changed, 9 insertions(+)
hw/ide/core.c +8 -0
index db509b3..0b48b64 100644
@@ -2603,6 +2603,14 @@ void ide_init2(IDEBus *bus, qemu_irq irq)
     bus->dma = &ide_dma_nop;
 }
 
+void ide_exit(IDEState *s)
+{
+    timer_del(s->sector_write_timer);
+    timer_free(s->sector_write_timer);
+    qemu_vfree(s->smart_selftest_data);
+    qemu_vfree(s->io_buffer);
+}
+
 static const MemoryRegionPortio ide_portio_list[] = {
     { 0, 8, 1, .read = ide_ioport_read, .write = ide_ioport_write },
     { 0, 1, 2, .read = ide_data_readw, .write = ide_data_writew },
include/hw/ide/internal.h +1 -0
index 88dc118..482a951 100644
@@ -607,6 +607,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind,
                    uint32_t cylinders, uint32_t heads, uint32_t secs,
                    int chs_trans);
 void ide_init2(IDEBus *bus, qemu_irq irq);
+void ide_exit(IDEState *s);
 void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2);
 void ide_register_restart_cb(IDEBus *bus);
 
Signature · 1 line
2.9.3
author
#3 lore raw

[Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci unit

In reply to John Snow

From: Li Qiang <[email protected]>

This can avoid memory leak when hotunplug the ahci device.

Message-id: [email protected]

---
 hw/ide/ahci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/ide/ahci.c +12 -0
index 6a17acf..f60826d 100644
@@ -1485,6 +1485,18 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
 
 void ahci_uninit(AHCIState *s)
 {
+    int i, j;
+
+    for (i = 0; i < s->ports; i++) {
+        AHCIDevice *ad = &s->dev[i];
+
+        for (j = 0; j < 2; j++) {
+            IDEState *s = &ad->port.ifs[j];
+
+            ide_exit(s);
+        }
+    }
+
     g_free(s->dev);
 }
 
Signature · 1 line
2.9.3
#4 lore raw
In reply to John Snow
Quoted 8 lines · John Snow

The following changes since commit 1883ff34b540daacae948f493b0ba525edf5f642:

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2017-03-15 18:44:05 +0000)

are available in the git repository at:

https://github.com/jnsnow/qemu.git tags/ide-pull-request

Quoted 8 lines

for you to fetch changes up to d68f0f778e7f4fbd674627274267f269e40f0b04:

ide: ahci: call cleanup function in ahci unit (2017-03-15 20:50:14 -0400)

----------------------------------------------------------------

----------------------------------------------------------------

Applied, thanks.

-- PMM