From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org,
Stefano Stabellini <sstabellini@kernel.org>,
Bruce Rogers <brogers@suse.com>,
Igor Mammedov <imammedo@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-2.10 v3 2/3] hw/acpi: Move acpi_set_pci_info to pcihp
Date: Fri, 18 Aug 2017 04:40:02 +0300 [thread overview]
Message-ID: <20170818043655-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170817162347.1590-3-anthony.perard@citrix.com>
On Thu, Aug 17, 2017 at 05:23:46PM +0100, Anthony PERARD wrote:
> This means that the function will be call and the property
> acpi-pcihp-bsel will be set even if ACPI build is disable.
>
> To do PCI passthrough with Xen, the property acpi-pcihp-bsel needs to be
> set, but this was done only when ACPI tables are built which is not
> needed for a Xen guest. The need for the property starts with commit
> "pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice"
> (f0c9d64a68b776374ec4732424a3e27753ce37b6).
>
> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
>
> ---
> Changes in V3:
> - move acpi_set_pci_info to pcihp instead
>
> Changes in V2:
> - check for acpi_enabled before calling acpi_set_pci_info.
> - set the property on the root bus only.
>
> This patch would be a canditade to backport to 2.9, along with
> "hw/acpi: Limit hotplug to root bus on legacy mode"
>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Bruce Rogers <brogers@suse.com>
> ---
> hw/acpi/pcihp.c | 31 +++++++++++++++++++++++++++++++
> hw/i386/acpi-build.c | 32 --------------------------------
> 2 files changed, 31 insertions(+), 32 deletions(-)
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 9db3c2eaf2..44e8842db8 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -75,6 +75,36 @@ static int acpi_pcihp_get_bsel(PCIBus *bus)
> }
> }
>
> +/* Assign BSEL property to all buses. In the future, this can be changed
> + * to only assign to buses that support hotplug.
> + */
> +static void *acpi_set_bsel(PCIBus *bus, void *opaque)
> +{
> + unsigned *bsel_alloc = opaque;
> + unsigned *bus_bsel;
> +
> + if (qbus_is_hotpluggable(BUS(bus))) {
> + bus_bsel = g_malloc(sizeof *bus_bsel);
> +
> + *bus_bsel = (*bsel_alloc)++;
> + object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> + bus_bsel, &error_abort);
> + }
> +
> + return bsel_alloc;
> +}
> +
> +static void acpi_set_pci_info(void)
> +{
> + PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
> + unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT;
> +
> + if (bus) {
> + /* Scan all PCI buses. Set property to enable acpi based hotplug. */
> + pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc);
> + }
> +}
> +
> static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque)
> {
> AcpiPciHpFind *find = opaque;
> @@ -177,6 +207,7 @@ static void acpi_pcihp_update(AcpiPciHpState *s)
>
> void acpi_pcihp_reset(AcpiPciHpState *s)
> {
> + acpi_set_pci_info();
> acpi_pcihp_update(s);
> }
IIUC doing this on reset will add property over and over again leaking
memory.
I think that we need to do it on machine done.
Igor, I think reordering acpi-build like earlier version did
is less intrusive and more appropriate for 2.10.
For 2.10 I would like to see ideally some changes that
are all if (xen) making it obvious non xen is not
affected. I can then ack it and it will be merged in xen tree.
Clean it up after 2.10.
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 98dd424678..4d19d91e1b 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -493,36 +493,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms)
> table_data->len - madt_start, 1, NULL, NULL);
> }
>
> -/* Assign BSEL property to all buses. In the future, this can be changed
> - * to only assign to buses that support hotplug.
> - */
> -static void *acpi_set_bsel(PCIBus *bus, void *opaque)
> -{
> - unsigned *bsel_alloc = opaque;
> - unsigned *bus_bsel;
> -
> - if (qbus_is_hotpluggable(BUS(bus))) {
> - bus_bsel = g_malloc(sizeof *bus_bsel);
> -
> - *bus_bsel = (*bsel_alloc)++;
> - object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> - bus_bsel, &error_abort);
> - }
> -
> - return bsel_alloc;
> -}
> -
> -static void acpi_set_pci_info(void)
> -{
> - PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
> - unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT;
> -
> - if (bus) {
> - /* Scan all PCI buses. Set property to enable acpi based hotplug. */
> - pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc);
> - }
> -}
> -
> static void build_append_pcihp_notify_entry(Aml *method, int slot)
> {
> Aml *if_ctx;
> @@ -2888,8 +2858,6 @@ void acpi_setup(void)
>
> build_state = g_malloc0(sizeof *build_state);
>
> - acpi_set_pci_info();
> -
> acpi_build_tables_init(&tables);
> acpi_build(&tables, MACHINE(pcms));
>
> --
> Anthony PERARD
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Eduardo Habkost <ehabkost@redhat.com>,
qemu-devel@nongnu.org, Bruce Rogers <brogers@suse.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
xen-devel@lists.xenproject.org,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH for-2.10 v3 2/3] hw/acpi: Move acpi_set_pci_info to pcihp
Date: Fri, 18 Aug 2017 04:40:02 +0300 [thread overview]
Message-ID: <20170818043655-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170817162347.1590-3-anthony.perard@citrix.com>
On Thu, Aug 17, 2017 at 05:23:46PM +0100, Anthony PERARD wrote:
> This means that the function will be call and the property
> acpi-pcihp-bsel will be set even if ACPI build is disable.
>
> To do PCI passthrough with Xen, the property acpi-pcihp-bsel needs to be
> set, but this was done only when ACPI tables are built which is not
> needed for a Xen guest. The need for the property starts with commit
> "pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice"
> (f0c9d64a68b776374ec4732424a3e27753ce37b6).
>
> Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
>
> ---
> Changes in V3:
> - move acpi_set_pci_info to pcihp instead
>
> Changes in V2:
> - check for acpi_enabled before calling acpi_set_pci_info.
> - set the property on the root bus only.
>
> This patch would be a canditade to backport to 2.9, along with
> "hw/acpi: Limit hotplug to root bus on legacy mode"
>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Bruce Rogers <brogers@suse.com>
> ---
> hw/acpi/pcihp.c | 31 +++++++++++++++++++++++++++++++
> hw/i386/acpi-build.c | 32 --------------------------------
> 2 files changed, 31 insertions(+), 32 deletions(-)
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 9db3c2eaf2..44e8842db8 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -75,6 +75,36 @@ static int acpi_pcihp_get_bsel(PCIBus *bus)
> }
> }
>
> +/* Assign BSEL property to all buses. In the future, this can be changed
> + * to only assign to buses that support hotplug.
> + */
> +static void *acpi_set_bsel(PCIBus *bus, void *opaque)
> +{
> + unsigned *bsel_alloc = opaque;
> + unsigned *bus_bsel;
> +
> + if (qbus_is_hotpluggable(BUS(bus))) {
> + bus_bsel = g_malloc(sizeof *bus_bsel);
> +
> + *bus_bsel = (*bsel_alloc)++;
> + object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> + bus_bsel, &error_abort);
> + }
> +
> + return bsel_alloc;
> +}
> +
> +static void acpi_set_pci_info(void)
> +{
> + PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
> + unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT;
> +
> + if (bus) {
> + /* Scan all PCI buses. Set property to enable acpi based hotplug. */
> + pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc);
> + }
> +}
> +
> static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque)
> {
> AcpiPciHpFind *find = opaque;
> @@ -177,6 +207,7 @@ static void acpi_pcihp_update(AcpiPciHpState *s)
>
> void acpi_pcihp_reset(AcpiPciHpState *s)
> {
> + acpi_set_pci_info();
> acpi_pcihp_update(s);
> }
IIUC doing this on reset will add property over and over again leaking
memory.
I think that we need to do it on machine done.
Igor, I think reordering acpi-build like earlier version did
is less intrusive and more appropriate for 2.10.
For 2.10 I would like to see ideally some changes that
are all if (xen) making it obvious non xen is not
affected. I can then ack it and it will be merged in xen tree.
Clean it up after 2.10.
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 98dd424678..4d19d91e1b 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -493,36 +493,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms)
> table_data->len - madt_start, 1, NULL, NULL);
> }
>
> -/* Assign BSEL property to all buses. In the future, this can be changed
> - * to only assign to buses that support hotplug.
> - */
> -static void *acpi_set_bsel(PCIBus *bus, void *opaque)
> -{
> - unsigned *bsel_alloc = opaque;
> - unsigned *bus_bsel;
> -
> - if (qbus_is_hotpluggable(BUS(bus))) {
> - bus_bsel = g_malloc(sizeof *bus_bsel);
> -
> - *bus_bsel = (*bsel_alloc)++;
> - object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> - bus_bsel, &error_abort);
> - }
> -
> - return bsel_alloc;
> -}
> -
> -static void acpi_set_pci_info(void)
> -{
> - PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
> - unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT;
> -
> - if (bus) {
> - /* Scan all PCI buses. Set property to enable acpi based hotplug. */
> - pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc);
> - }
> -}
> -
> static void build_append_pcihp_notify_entry(Aml *method, int slot)
> {
> Aml *if_ctx;
> @@ -2888,8 +2858,6 @@ void acpi_setup(void)
>
> build_state = g_malloc0(sizeof *build_state);
>
> - acpi_set_pci_info();
> -
> acpi_build_tables_init(&tables);
> acpi_build(&tables, MACHINE(pcms));
>
> --
> Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-08-18 1:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 16:23 [Qemu-devel] [PATCH for-2.10 v3 0/3] Fix hotplug of PCI passthrought device on Xen Anthony PERARD
2017-08-17 16:23 ` Anthony PERARD
2017-08-17 16:23 ` [Qemu-devel] [PATCH for-2.10 v3 1/3] hw/acpi: Limit hotplug to root bus on legacy mode Anthony PERARD
2017-08-17 16:23 ` Anthony PERARD
2017-08-17 16:23 ` [Qemu-devel] [PATCH for-2.10 v3 2/3] hw/acpi: Move acpi_set_pci_info to pcihp Anthony PERARD
2017-08-17 16:23 ` Anthony PERARD
2017-08-18 1:40 ` Michael S. Tsirkin [this message]
2017-08-18 1:40 ` Michael S. Tsirkin
2017-08-18 9:37 ` [Qemu-devel] " Igor Mammedov
2017-08-18 9:37 ` Igor Mammedov
2017-08-18 13:31 ` [Qemu-devel] " Anthony PERARD
2017-08-18 13:31 ` Anthony PERARD
2017-08-18 14:19 ` [Qemu-devel] " Igor Mammedov
2017-08-18 14:19 ` Igor Mammedov
2017-08-18 16:00 ` [Qemu-devel] " Anthony PERARD
2017-08-18 16:00 ` Anthony PERARD
2017-08-18 18:32 ` [Qemu-devel] " Michael S. Tsirkin
2017-08-18 18:32 ` Michael S. Tsirkin
2017-08-18 18:30 ` [Qemu-devel] " Michael S. Tsirkin
2017-08-18 18:30 ` Michael S. Tsirkin
2017-08-18 9:47 ` [Qemu-devel] " Igor Mammedov
2017-08-18 9:47 ` Igor Mammedov
2017-08-17 16:23 ` [Qemu-devel] [PATCH for-2.10 v3 3/3] Revert "ACPI: don't call acpi_pcihp_device_plug_cb on xen" Anthony PERARD
2017-08-17 16:23 ` Anthony PERARD
2017-08-17 16:57 ` [Qemu-devel] [PATCH for-2.10 v3 0/3] Fix hotplug of PCI passthrought device on Xen no-reply
2017-08-17 16:57 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170818043655-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=anthony.perard@citrix.com \
--cc=brogers@suse.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.