diff mbox

[RFC,8/9] pcihp: expose PCI hotplug MMIO base/length as properties of piix4pm

Message ID 1391777496-3882-9-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov Feb. 7, 2014, 12:51 p.m. UTC
with introduction of PCIHP, MMIO range becomes changable
at runtime so it's not possible to statically punch hole
PCI bus _CRS.

Making IO base/length available as readonly properties
allow acpi builder to get values and reserve PCI hotplug
IO range at runtime later.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/pcihp.c         |   28 ++++++++++++++++++++++++++++
 hw/acpi/piix4.c         |    1 +
 include/hw/acpi/pcihp.h |    4 ++++
 3 files changed, 33 insertions(+), 0 deletions(-)

Comments

Michael S. Tsirkin Feb. 16, 2014, 3:45 p.m. UTC | #1
On Fri, Feb 07, 2014 at 01:51:35PM +0100, Igor Mammedov wrote:
> with introduction of PCIHP, MMIO range becomes changable
> at runtime so it's not possible to statically punch hole
> PCI bus _CRS.
> 
> Making IO base/length available as readonly properties
> allow acpi builder to get values and reserve PCI hotplug
> IO range at runtime later.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

No objection but I wonder: isn't it already possible to enumerate
memory regions?

> ---
>  hw/acpi/pcihp.c         |   28 ++++++++++++++++++++++++++++
>  hw/acpi/piix4.c         |    1 +
>  include/hw/acpi/pcihp.h |    4 ++++
>  3 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 1ce6fc2..629d364 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -37,6 +37,7 @@
>  #include "hw/pci/pci_bus.h"
>  #include "qom/qom-qobject.h"
>  #include "qapi/qmp/qint.h"
> +#include "qapi/visitor.h"
>  
>  //#define DEBUG
>  
> @@ -309,3 +310,30 @@ const VMStateDescription vmstate_acpi_pcihp_pci_status = {
>          VMSTATE_END_OF_LIST()
>      }
>  };
> +
> +static void acpi_pcihp_get_io_addr(Object *obj, Visitor *v, void *opaque,
> +                                     const char *name, Error **errp)
> +{
> +    AcpiPciHpState *s = opaque;
> +    MemoryRegionSection mr_info = memory_region_find(&s->io, 0, 1);
> +    uint16_t value = mr_info.offset_within_address_space;
> +
> +    visit_type_uint16(v, &value, name, errp);
> +}
> +
> +static void acpi_pcihp_get_io_len(Object *obj, Visitor *v, void *opaque,
> +                                     const char *name, Error **errp)
> +{
> +    AcpiPciHpState *s = opaque;
> +    uint16_t value = memory_region_size(&s->io);
> +
> +    visit_type_uint16(v, &value, name, errp);
> +}
> +
> +void acpi_pcihp_add_mmio_properties(Object *obj, AcpiPciHpState *s)
> +{
> +    object_property_add(obj, ACPI_PCIHP_IO_ADDR, "uint16",
> +                        acpi_pcihp_get_io_addr, NULL, NULL, s, NULL);
> +    object_property_add(obj, ACPI_PCIHP_IO_LEN, "uint16",
> +                        acpi_pcihp_get_io_len, NULL, NULL, s, NULL);
> +}
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index 7a0efcb..034c5cd 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -558,6 +558,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
>                            "acpi-gpe0", GPE_LEN);
>      memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
>  
> +    acpi_pcihp_add_mmio_properties(OBJECT(s), &s->acpi_pci_hotplug);
>      acpi_pcihp_init(&s->acpi_pci_hotplug, bus, parent,
>                      s->use_acpi_pci_hotplug);
>  
> diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
> index 0a90e4a..0eb4e1c 100644
> --- a/include/hw/acpi/pcihp.h
> +++ b/include/hw/acpi/pcihp.h
> @@ -70,4 +70,8 @@ extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
>                                    vmstate_acpi_pcihp_pci_status, \
>                                    AcpiPciHpPciStatus)
>  
> +#define ACPI_PCIHP_IO_ADDR "pcihp-io-addr"
> +#define ACPI_PCIHP_IO_LEN  "pcihp-io-len"
> +
> +void acpi_pcihp_add_mmio_properties(Object *obj, AcpiPciHpState *s);
>  #endif
> -- 
> 1.7.1
diff mbox

Patch

diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 1ce6fc2..629d364 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -37,6 +37,7 @@ 
 #include "hw/pci/pci_bus.h"
 #include "qom/qom-qobject.h"
 #include "qapi/qmp/qint.h"
+#include "qapi/visitor.h"
 
 //#define DEBUG
 
@@ -309,3 +310,30 @@  const VMStateDescription vmstate_acpi_pcihp_pci_status = {
         VMSTATE_END_OF_LIST()
     }
 };
+
+static void acpi_pcihp_get_io_addr(Object *obj, Visitor *v, void *opaque,
+                                     const char *name, Error **errp)
+{
+    AcpiPciHpState *s = opaque;
+    MemoryRegionSection mr_info = memory_region_find(&s->io, 0, 1);
+    uint16_t value = mr_info.offset_within_address_space;
+
+    visit_type_uint16(v, &value, name, errp);
+}
+
+static void acpi_pcihp_get_io_len(Object *obj, Visitor *v, void *opaque,
+                                     const char *name, Error **errp)
+{
+    AcpiPciHpState *s = opaque;
+    uint16_t value = memory_region_size(&s->io);
+
+    visit_type_uint16(v, &value, name, errp);
+}
+
+void acpi_pcihp_add_mmio_properties(Object *obj, AcpiPciHpState *s)
+{
+    object_property_add(obj, ACPI_PCIHP_IO_ADDR, "uint16",
+                        acpi_pcihp_get_io_addr, NULL, NULL, s, NULL);
+    object_property_add(obj, ACPI_PCIHP_IO_LEN, "uint16",
+                        acpi_pcihp_get_io_len, NULL, NULL, s, NULL);
+}
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 7a0efcb..034c5cd 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -558,6 +558,7 @@  static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
                           "acpi-gpe0", GPE_LEN);
     memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
 
+    acpi_pcihp_add_mmio_properties(OBJECT(s), &s->acpi_pci_hotplug);
     acpi_pcihp_init(&s->acpi_pci_hotplug, bus, parent,
                     s->use_acpi_pci_hotplug);
 
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 0a90e4a..0eb4e1c 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -70,4 +70,8 @@  extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
                                   vmstate_acpi_pcihp_pci_status, \
                                   AcpiPciHpPciStatus)
 
+#define ACPI_PCIHP_IO_ADDR "pcihp-io-addr"
+#define ACPI_PCIHP_IO_LEN  "pcihp-io-len"
+
+void acpi_pcihp_add_mmio_properties(Object *obj, AcpiPciHpState *s);
 #endif