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

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