thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-isa-Clean-up-use-of-cannot_instantiate_with_device_a.patch

218e99
From 7e9beb48fd9438354ea6d6747cbbefdc3b553590 Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Wed, 6 Nov 2013 14:41:20 +0100
218e99
Subject: [PATCH 44/81] isa: Clean up use of cannot_instantiate_with_device_add_yet
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1383748882-22831-16-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 55541
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 15/17] isa: Clean up use of cannot_instantiate_with_device_add_yet
218e99
Bugzilla: 1001216
218e99
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
218e99
From: Markus Armbruster <armbru@redhat.com>
218e99
218e99
Drop it when there's no obvious reason why device_add could not work.
218e99
Else keep and document why.
218e99
218e99
* isa-fdc: drop
218e99
218e99
* i8042: drop, even though its I/O base is hardcoded (because you
218e99
  could conceivably still add one to a board that has none), and even
218e99
  though PC board code wires up the A20 line (because that wiring is
218e99
  optional)
218e99
218e99
* port92: keep because it needs additional wiring by port92_init()
218e99
218e99
* mc146818rtc: keep because it needs to be wired up by rtc_init()
218e99
218e99
* m48t59_isa: keep because needs to be wired up by m48t59_init_isa()
218e99
218e99
* isa-pit, kvm-pit: keep (in their abstract base pic-common) because
218e99
  the PIT needs additional wiring by board code, depending on HPET
218e99
  presence
218e99
218e99
* pcspk: keep because of pointer property pit, and because realize
218e99
  sets global pcspk_state
218e99
218e99
* vmmouse: keep because of pointer property ps2_mouse
218e99
218e99
* vmport: keep because realize sets global port_state
218e99
218e99
* isa-i8259, kvm-i8259: keep (in their abstract base pic-common),
218e99
  because the PICs' IRQ input lines are set up by board code, and the
218e99
  wiring of the slave to the master is hard-coded in device model code
218e99
(cherry picked from pending upstream submission)
218e99
218e99
Conflicts:
218e99
	hw/i386/pc.c
218e99
	hw/input/pckbd.c
218e99
	hw/input/vmmouse.c
218e99
	hw/intc/i8259_common.c
218e99
	hw/misc/vmport.c
218e99
	hw/timer/m48t59.c
218e99
	hw/timer/mc146818rtc.c
218e99
218e99
Conflicts because we don't have commit db895a1 "isa: Use realizefn
218e99
for ISADevice".  Resolution is straightforward.
218e99
218e99
We got one more ISA device to cover than upstream:
218e99
218e99
* pvpanic : keep, so the future backport of commit a5d3f64 "hw/misc:
218e99
  make pvpanic known to user" can drop it, just like it dropped
218e99
  no_user upstream.  Artifact of backporting out-of-order.
218e99
218e99
Signed-off-by: Markus Armbruster <armbru@redhat.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
 hw/audio/pcspk.c        | 3 ++-
218e99
 hw/block/fdc.c          | 1 -
218e99
 hw/i386/pc.c            | 7 ++++++-
218e99
 hw/input/pckbd.c        | 1 -
218e99
 hw/input/vmmouse.c      | 3 ++-
218e99
 hw/intc/i8259_common.c  | 8 +++++++-
218e99
 hw/misc/pvpanic.c       | 6 +++++-
218e99
 hw/misc/vmport.c        | 3 ++-
218e99
 hw/timer/i8254_common.c | 7 ++++++-
218e99
 hw/timer/m48t59.c       | 3 ++-
218e99
 hw/timer/mc146818rtc.c  | 3 ++-
218e99
 11 files changed, 34 insertions(+), 11 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 hw/audio/pcspk.c        |    3 ++-
218e99
 hw/block/fdc.c          |    1 -
218e99
 hw/i386/pc.c            |    7 ++++++-
218e99
 hw/input/pckbd.c        |    1 -
218e99
 hw/input/vmmouse.c      |    3 ++-
218e99
 hw/intc/i8259_common.c  |    8 +++++++-
218e99
 hw/misc/pvpanic.c       |    6 +++++-
218e99
 hw/misc/vmport.c        |    3 ++-
218e99
 hw/timer/i8254_common.c |    7 ++++++-
218e99
 hw/timer/m48t59.c       |    3 ++-
218e99
 hw/timer/mc146818rtc.c  |    3 ++-
218e99
 11 files changed, 34 insertions(+), 11 deletions(-)
218e99
218e99
diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
218e99
index 9186304..c54b78d 100644
218e99
--- a/hw/audio/pcspk.c
218e99
+++ b/hw/audio/pcspk.c
218e99
@@ -188,8 +188,9 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
218e99
 
218e99
     ic->init = pcspk_initfn;
218e99
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->props = pcspk_properties;
218e99
+    /* Reason: pointer property "pit", realize sets global pcspk_state */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo pcspk_info = {
218e99
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
218e99
index 1524e09..f3b5bec 100644
218e99
--- a/hw/block/fdc.c
218e99
+++ b/hw/block/fdc.c
218e99
@@ -2206,7 +2206,6 @@ static void isabus_fdc_class_init(ObjectClass *klass, void *data)
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
     ic->init = isabus_fdc_init1;
218e99
     dc->fw_name = "fdc";
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->reset = fdctrl_external_reset_isa;
218e99
     dc->vmsd = &vmstate_isa_fdc;
218e99
     dc->props = isa_fdc_properties;
218e99
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
218e99
index 0a8840a..9e5a082 100644
218e99
--- a/hw/i386/pc.c
218e99
+++ b/hw/i386/pc.c
218e99
@@ -538,9 +538,14 @@ static void port92_class_initfn(ObjectClass *klass, void *data)
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
     ic->init = port92_initfn;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->reset = port92_reset;
218e99
     dc->vmsd = &vmstate_port92_isa;
218e99
+    /*
218e99
+     * Reason: unlike ordinary ISA devices, this one needs additional
218e99
+     * wiring: its A20 output line needs to be wired up by
218e99
+     * port92_init().
218e99
+     */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo port92_info = {
218e99
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
218e99
index 98b8b15..ed396bf 100644
218e99
--- a/hw/input/pckbd.c
218e99
+++ b/hw/input/pckbd.c
218e99
@@ -514,7 +514,6 @@ static void i8042_class_initfn(ObjectClass *klass, void *data)
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
     ic->init = i8042_initfn;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->vmsd = &vmstate_kbd_isa;
218e99
 }
218e99
 
218e99
diff --git a/hw/input/vmmouse.c b/hw/input/vmmouse.c
218e99
index c9d5131..c6059a4 100644
218e99
--- a/hw/input/vmmouse.c
218e99
+++ b/hw/input/vmmouse.c
218e99
@@ -284,10 +284,11 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data)
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
     ic->init = vmmouse_initfn;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->reset = vmmouse_reset;
218e99
     dc->vmsd = &vmstate_vmmouse;
218e99
     dc->props = vmmouse_properties;
218e99
+    /* Reason: pointer property "ps2_mouse" */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo vmmouse_info = {
218e99
diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c
218e99
index 70868a5..3358341 100644
218e99
--- a/hw/intc/i8259_common.c
218e99
+++ b/hw/intc/i8259_common.c
218e99
@@ -139,9 +139,15 @@ static void pic_common_class_init(ObjectClass *klass, void *data)
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
 
218e99
     dc->vmsd = &vmstate_pic_common;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->props = pic_properties_common;
218e99
     ic->init = pic_init_common;
218e99
+    /*
218e99
+     * Reason: unlike ordinary ISA devices, the PICs need additional
218e99
+     * wiring: its IRQ input lines are set up by board code, and the
218e99
+     * wiring of the slave to the master is hard-coded in device model
218e99
+     * code.
218e99
+     */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo pic_common_type = {
218e99
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
218e99
index af4a8b2..439d636 100644
218e99
--- a/hw/misc/pvpanic.c
218e99
+++ b/hw/misc/pvpanic.c
218e99
@@ -125,8 +125,12 @@ static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
 
218e99
     ic->init = pvpanic_isa_initfn;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->props = pvpanic_isa_properties;
218e99
+    /*
218e99
+     * To be dropped in future backport of commit a5d3f64 "hw/misc:
218e99
+     * make pvpanic known to user":
218e99
+     */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static TypeInfo pvpanic_isa_info = {
218e99
diff --git a/hw/misc/vmport.c b/hw/misc/vmport.c
218e99
index ab7adf1..d7e1182 100644
218e99
--- a/hw/misc/vmport.c
218e99
+++ b/hw/misc/vmport.c
218e99
@@ -156,7 +156,8 @@ static void vmport_class_initfn(ObjectClass *klass, void *data)
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
     ic->init = vmport_initfn;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
+    /* Reason: realize sets global port_state */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo vmport_info = {
218e99
diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c
218e99
index 8f01313..d0737fa 100644
218e99
--- a/hw/timer/i8254_common.c
218e99
+++ b/hw/timer/i8254_common.c
218e99
@@ -291,7 +291,12 @@ static void pit_common_class_init(ObjectClass *klass, void *data)
218e99
 
218e99
     ic->init = pit_init_common;
218e99
     dc->vmsd = &vmstate_pit_common;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
+    /*
218e99
+     * Reason: unlike ordinary ISA devices, the PIT may need to be
218e99
+     * wired to the HPET, and because of that, some wiring is always
218e99
+     * done by board code.
218e99
+     */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo pit_common_type = {
218e99
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
218e99
index e536bb9..d8a13fb 100644
218e99
--- a/hw/timer/m48t59.c
218e99
+++ b/hw/timer/m48t59.c
218e99
@@ -740,9 +740,10 @@ static void m48t59_isa_class_init(ObjectClass *klass, void *data)
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
     ic->init = m48t59_init_isa1;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->reset = m48t59_reset_isa;
218e99
     dc->props = m48t59_isa_properties;
218e99
+    /* Reason: needs to be wired up by m48t59_init_isa() */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo m48t59_isa_info = {
218e99
diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
218e99
index 7a70556..432b16c 100644
218e99
--- a/hw/timer/mc146818rtc.c
218e99
+++ b/hw/timer/mc146818rtc.c
218e99
@@ -904,9 +904,10 @@ static void rtc_class_initfn(ObjectClass *klass, void *data)
218e99
     DeviceClass *dc = DEVICE_CLASS(klass);
218e99
     ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
218e99
     ic->init = rtc_initfn;
218e99
-    dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */
218e99
     dc->vmsd = &vmstate_rtc;
218e99
     dc->props = mc146818rtc_properties;
218e99
+    /* Reason: needs to be wired up by rtc_init() */
218e99
+    dc->cannot_instantiate_with_device_add_yet = true;
218e99
 }
218e99
 
218e99
 static const TypeInfo mc146818rtc_info = {
218e99
-- 
218e99
1.7.1
218e99