qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Ani Sinha <ani@anisinha.ca>, qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH V2] Introduce a new flag for piix to disable root bus PCI hotplug
Date: Tue, 18 Aug 2020 12:16:10 +0200	[thread overview]
Message-ID: <ffc51bbc-3aa1-ced3-60f2-033291fd1cdc@redhat.com> (raw)
In-Reply-To: <CAARzgwxZNpiTLn8aome=tVxHe-ut=Pkbte=McUbr=B2xx6kRfQ@mail.gmail.com>

Hi,

On 8/18/20 11:54 AM, Ani Sinha wrote:
> Igor etc, I just tested this patch using a Windows 2012 R2 image and
> it seems to be working. Any feedbacks on this patch?
> 
> On Tue, Aug 11, 2020 at 6:42 PM Ani Sinha <ani@anisinha.ca> wrote:
>>
>> We introduce a new global flag for PIIX with which we can turn on or off PCI
>> device hotplug on the root bus. This flag can be used to prevent all PCI
>> devices from getting hotplugged or unplugged from the root PCI bus.
>>
>> Signed-off-by: Ani Sinha <ani@anisinha.ca>
>> ---
>>  hw/acpi/piix4.c      |  3 +++
>>  hw/i386/acpi-build.c | 20 ++++++++++++++++----
>>  2 files changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
>> index 26bac4f..94ec35a 100644
>> --- a/hw/acpi/piix4.c
>> +++ b/hw/acpi/piix4.c
>> @@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
>>
>>      AcpiPciHpState acpi_pci_hotplug;
>>      bool use_acpi_hotplug_bridge;
>> +    bool use_acpi_root_pci_hotplug;
>>
>>      uint8_t disable_s3;
>>      uint8_t disable_s4;
>> @@ -635,6 +636,8 @@ static Property piix4_pm_properties[] = {
>>      DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
>>      DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
>>                       use_acpi_hotplug_bridge, true),
>> +    DEFINE_PROP_BOOL("acpi-root-pci-hotplug", PIIX4PMState,
>> +                     use_acpi_root_pci_hotplug, true),

From what I understood here, this file is already pretty twisted
and Igor doesn't want more workarounds:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg690564.html

¯\_(ツ)_/¯

>>      DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
>>                       acpi_memory_hotplug.is_enabled, true),
>>      DEFINE_PROP_END_OF_LIST(),
>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>> index b7bcbbb..a82e5c1 100644
>> --- a/hw/i386/acpi-build.c
>> +++ b/hw/i386/acpi-build.c
>> @@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {
>>      bool s3_disabled;
>>      bool s4_disabled;
>>      bool pcihp_bridge_en;
>> +    bool pcihp_root_en;
>>      uint8_t s4_val;
>>      AcpiFadtData fadt;
>>      uint16_t cpu_hp_io_base;
>> @@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
>>      pm->pcihp_bridge_en =
>>          object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
>>                                   NULL);
>> +    pm->pcihp_root_en =
>> +        object_property_get_bool(obj, "acpi-root-pci-hotplug", NULL);
>> +
>>  }
>>
>>  static void acpi_get_misc_info(AcpiMiscInfo *info)
>> @@ -337,12 +341,15 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
>>  }
>>
>>  static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
>> -                                         bool pcihp_bridge_en)
>> +                                         bool pcihp_bridge_en,
>> +                                         bool pcihp_root_en)
>>  {
>>      Aml *dev, *notify_method = NULL, *method;
>>      QObject *bsel;
>>      PCIBus *sec;
>>      int i;
>> +    bool root_bus = pci_bus_is_root(bus);
>> +    bool root_pcihp_disabled = (root_bus && !pcihp_root_en);
>>
>>      bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
>>      if (bsel) {
>> @@ -361,6 +368,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
>>          bool bridge_in_acpi;
>>
>>          if (!pdev) {
>> +            /* skip if pci hotplug for the root bus is disabled */
>> +            if (root_pcihp_disabled)
>> +                continue;
>>              if (bsel) { /* add hotplug slots for non present devices */
>>                  dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
>>                  aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
>> @@ -419,7 +429,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
>>              method = aml_method("_S3D", 0, AML_NOTSERIALIZED);
>>              aml_append(method, aml_return(aml_int(s3d)));
>>              aml_append(dev, method);
>> -        } else if (hotplug_enabled_dev) {
>> +        } else if (hotplug_enabled_dev && !root_pcihp_disabled) {
>>              /* add _SUN/_EJ0 to make slot hotpluggable  */
>>              aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
>>
>> @@ -439,7 +449,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
>>               */
>>              PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
>>
>> -            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
>> +            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
>> +                                         pcihp_root_en);
>>          }
>>          /* slot descriptor has been composed, add it into parent context */
>>          aml_append(parent_scope, dev);
>> @@ -1818,7 +1829,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>>          if (bus) {
>>              Aml *scope = aml_scope("PCI0");
>>              /* Scan all PCI buses. Generate tables to support hotplug. */
>> -            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
>> +            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
>> +                                         pm->pcihp_root_en);
>>
>>              if (TPM_IS_TIS_ISA(tpm)) {
>>                  if (misc->tpm_version == TPM_VERSION_2_0) {
>> --
>> 2.7.4
>>
> 



  reply	other threads:[~2020-08-18 10:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11 13:12 [PATCH V2] Introduce a new flag for piix to disable root bus PCI hotplug Ani Sinha
2020-08-18  9:54 ` Ani Sinha
2020-08-18 10:16   ` Philippe Mathieu-Daudé [this message]
2020-08-18 10:19     ` Ani Sinha
2020-08-18 10:46       ` Ani Sinha
2020-08-19 10:00 ` Igor Mammedov
2020-08-19 10:36   ` Ani Sinha

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=ffc51bbc-3aa1-ced3-60f2-033291fd1cdc@redhat.com \
    --to=philmd@redhat.com \
    --cc=aleksandar.qemu.devel@gmail.com \
    --cc=ani@anisinha.ca \
    --cc=aurelien@aurel32.net \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).