All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL for-rc1 0/3] Ide patches
@ 2017-03-16  0:52 John Snow
  2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 1/3] ide: qdev: register ide bus unrealize function John Snow
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: John Snow @ 2017-03-16  0:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, jsnow

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(-)

-- 
2.9.3

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

* [Qemu-devel] [PULL for-rc1 1/3] ide: qdev: register ide bus unrealize function
  2017-03-16  0:52 [Qemu-devel] [PULL for-rc1 0/3] Ide patches John Snow
@ 2017-03-16  0:52 ` John Snow
  2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 2/3] ide: core: add cleanup function John Snow
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2017-03-16  0:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, jsnow, Li Qiang, Li Qiang

From: Li Qiang <liq3ea@gmail.com>

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.

Suggested-by: John Snow <jsnow@redhat.com>
Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1488449293-80280-2-git-send-email-liqiang6-s@360.cn
Signed-off-by: John Snow <jsnow@redhat.com>
---
 hw/ide/qdev.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 4383cd1..299e592 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -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;
 }
 
-- 
2.9.3

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

* [Qemu-devel] [PULL for-rc1 2/3] ide: core: add cleanup function
  2017-03-16  0:52 [Qemu-devel] [PULL for-rc1 0/3] Ide patches John Snow
  2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 1/3] ide: qdev: register ide bus unrealize function John Snow
@ 2017-03-16  0:52 ` John Snow
  2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci unit John Snow
  2017-03-16 11:05 ` [Qemu-devel] [PULL for-rc1 0/3] Ide patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2017-03-16  0:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, jsnow, Li Qiang, Li Qiang

From: Li Qiang <liq3ea@gmail.com>

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.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Message-id: 1488449293-80280-3-git-send-email-liqiang6-s@360.cn
Signed-off-by: John Snow <jsnow@redhat.com>
---
 hw/ide/core.c             | 8 ++++++++
 include/hw/ide/internal.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index db509b3..0b48b64 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -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 },
diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h
index 88dc118..482a951 100644
--- a/include/hw/ide/internal.h
+++ b/include/hw/ide/internal.h
@@ -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);
 
-- 
2.9.3

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

* [Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci unit
  2017-03-16  0:52 [Qemu-devel] [PULL for-rc1 0/3] Ide patches John Snow
  2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 1/3] ide: qdev: register ide bus unrealize function John Snow
  2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 2/3] ide: core: add cleanup function John Snow
@ 2017-03-16  0:52 ` John Snow
  2017-03-16 11:05 ` [Qemu-devel] [PULL for-rc1 0/3] Ide patches Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2017-03-16  0:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, jsnow, Li Qiang, Li Qiang

From: Li Qiang <liq3ea@gmail.com>

This can avoid memory leak when hotunplug the ahci device.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Message-id: 1488449293-80280-4-git-send-email-liqiang6-s@360.cn
Signed-off-by: John Snow <jsnow@redhat.com>
---
 hw/ide/ahci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 6a17acf..f60826d 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -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);
 }
 
-- 
2.9.3

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

* Re: [Qemu-devel] [PULL for-rc1 0/3] Ide patches
  2017-03-16  0:52 [Qemu-devel] [PULL for-rc1 0/3] Ide patches John Snow
                   ` (2 preceding siblings ...)
  2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci unit John Snow
@ 2017-03-16 11:05 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2017-03-16 11:05 UTC (permalink / raw)
  To: John Snow; +Cc: QEMU Developers

On 16 March 2017 at 00:52, John Snow <jsnow@redhat.com> wrote:
> 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)
>
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------
>

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2017-03-16 11:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16  0:52 [Qemu-devel] [PULL for-rc1 0/3] Ide patches John Snow
2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 1/3] ide: qdev: register ide bus unrealize function John Snow
2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 2/3] ide: core: add cleanup function John Snow
2017-03-16  0:52 ` [Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci unit John Snow
2017-03-16 11:05 ` [Qemu-devel] [PULL for-rc1 0/3] Ide patches Peter Maydell

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.