qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 15/74] acpi: support serialized method


From: Shannon Zhao
Subject: Re: [Qemu-devel] [PATCH 15/74] acpi: support serialized method
Date: Fri, 11 Dec 2015 10:58:26 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0


On 2015/12/10 7:41, Igor Mammedov wrote:
> From: Xiao Guangrong <address@hidden>
> 
> Add serialized method support so that explicit Mutex can be
> avoided
> 
> Signed-off-by: Xiao Guangrong <address@hidden>
> Signed-off-by: Igor Mammedov <address@hidden>

Reviewed-by: Shannon Zhao <address@hidden>

> ---
>  hw/acpi/aml-build.c         | 17 +++++++++++++++--
>  hw/arm/virt-acpi-build.c    | 10 +++++-----
>  hw/i386/acpi-build.c        | 41 +++++++++++++++++++++--------------------
>  include/hw/acpi/aml-build.h |  8 +++++++-
>  4 files changed, 48 insertions(+), 28 deletions(-)
> 
> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
> index e36b546..5094826 100644
> --- a/hw/acpi/aml-build.c
> +++ b/hw/acpi/aml-build.c
> @@ -741,11 +741,24 @@ Aml *aml_while(Aml *predicate)
>  }
>  
>  /* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMethod */
> -Aml *aml_method(const char *name, int arg_count)
> +Aml *aml_method(const char *name, int arg_count, AmlSerializeFlag sflag)
>  {
>      Aml *var = aml_bundle(0x14 /* MethodOp */, AML_PACKAGE);
> +    int methodflags;
> +
> +    /*
> +     * MethodFlags:
> +     *   bit 0-2: ArgCount (0-7)
> +     *   bit 3: SerializeFlag
> +     *     0: NotSerialized
> +     *     1: Serialized
> +     *   bit 4-7: reserved (must be 0)
> +     */
> +    assert(arg_count < 8);
> +    methodflags = arg_count | (sflag << 3);
> +
>      build_append_namestring(var->buf, "%s", name);
> -    build_append_byte(var->buf, arg_count); /* MethodFlags: ArgCount */
> +    build_append_byte(var->buf, methodflags); /* MethodFlags: ArgCount */
>      return var;
>  }
>  
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 3c2c5d6..38ab844 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -212,16 +212,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const 
> MemMapEntry *memmap, int irq,
>                     aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
>                                   AML_EXCLUSIVE, irq + i));
>          aml_append(dev_gsi, aml_name_decl("_CRS", crs));
> -        method = aml_method("_SRS", 1);
> +        method = aml_method("_SRS", 1, AML_NOTSERIALIZED);
>          aml_append(dev_gsi, method);
>          aml_append(dev, dev_gsi);
>      }
>  
> -    method = aml_method("_CBA", 0);
> +    method = aml_method("_CBA", 0, AML_NOTSERIALIZED);
>      aml_append(method, aml_return(aml_int(base_ecam)));
>      aml_append(dev, method);
>  
> -    method = aml_method("_CRS", 0);
> +    method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
>      Aml *rbuf = aml_resource_template();
>      aml_append(rbuf,
>          aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
> @@ -254,7 +254,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const 
> MemMapEntry *memmap, int irq,
>      /* Declare an _OSC (OS Control Handoff) method */
>      aml_append(dev, aml_name_decl("SUPP", aml_int(0)));
>      aml_append(dev, aml_name_decl("CTRL", aml_int(0)));
> -    method = aml_method("_OSC", 4);
> +    method = aml_method("_OSC", 4, AML_NOTSERIALIZED);
>      aml_append(method,
>          aml_create_dword_field(aml_arg(3), aml_int(0), "CDW1"));
>  
> @@ -296,7 +296,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const 
> MemMapEntry *memmap, int irq,
>      aml_append(method, elsectx);
>      aml_append(dev, method);
>  
> -    method = aml_method("_DSM", 4);
> +    method = aml_method("_DSM", 4, AML_NOTSERIALIZED);
>  
>      /* PCI Firmware Specification 3.0
>       * 4.6.1. _DSM for PCI Express Slot Information
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 8f7b95a..62afe5a 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -487,7 +487,7 @@ static void build_append_pci_bus_devices(Aml 
> *parent_scope, PCIBus *bus,
>          int64_t bsel_val = qint_get_int(qobject_to_qint(bsel));
>  
>          aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
> -        notify_method = aml_method("DVNT", 2);
> +        notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
>      }
>  
>      for (i = 0; i < ARRAY_SIZE(bus->devices); i += PCI_FUNC_MAX) {
> @@ -503,7 +503,7 @@ static void build_append_pci_bus_devices(Aml 
> *parent_scope, PCIBus *bus,
>                  dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
>                  aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
>                  aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
> -                method = aml_method("_EJ0", 1);
> +                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>                  aml_append(method,
>                      aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
>                  );
> @@ -546,22 +546,22 @@ static void build_append_pci_bus_devices(Aml 
> *parent_scope, PCIBus *bus,
>                  s3d = 0;
>              }
>  
> -            method = aml_method("_S1D", 0);
> +            method = aml_method("_S1D", 0, AML_NOTSERIALIZED);
>              aml_append(method, aml_return(aml_int(0)));
>              aml_append(dev, method);
>  
> -            method = aml_method("_S2D", 0);
> +            method = aml_method("_S2D", 0, AML_NOTSERIALIZED);
>              aml_append(method, aml_return(aml_int(0)));
>              aml_append(dev, method);
>  
> -            method = aml_method("_S3D", 0);
> +            method = aml_method("_S3D", 0, AML_NOTSERIALIZED);
>              aml_append(method, aml_return(aml_int(s3d)));
>              aml_append(dev, method);
>          } else if (hotplug_enabled_dev) {
>              /* add _SUN/_EJ0 to make slot hotpluggable  */
>              aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
>  
> -            method = aml_method("_EJ0", 1);
> +            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>              aml_append(method,
>                  aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
>              );
> @@ -590,7 +590,7 @@ static void build_append_pci_bus_devices(Aml 
> *parent_scope, PCIBus *bus,
>      /* Append PCNT method to notify about events on local and child buses.
>       * Add unconditionally for root since DSDT expects it.
>       */
> -    method = aml_method("PCNT", 0);
> +    method = aml_method("PCNT", 0, AML_NOTSERIALIZED);
>  
>      /* If bus supports hotplug select it and notify about local events */
>      if (bsel) {
> @@ -651,7 +651,7 @@ static Aml *build_prt(void)
>  {
>      Aml *method, *while_ctx, *pin, *res;
>  
> -    method = aml_method("_PRT", 0);
> +    method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
>      res = aml_local(0);
>      pin = aml_local(1);
>      aml_append(method, aml_store(aml_package(128), res));
> @@ -1112,12 +1112,12 @@ build_ssdt(GArray *table_data, GArray *linker,
>          /* device present, functioning, decoding, shown in UI */
>          aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
>  
> -        method = aml_method("RDPT", 0);
> +        method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
>          aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
>          aml_append(method, aml_return(aml_local(0)));
>          aml_append(dev, method);
>  
> -        method = aml_method("WRPT", 1);
> +        method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
>          aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
>          aml_append(dev, method);
>  
> @@ -1153,15 +1153,15 @@ build_ssdt(GArray *table_data, GArray *linker,
>          for (i = 0; i < acpi_cpus; i++) {
>              dev = aml_processor(i, 0, 0, "CP%.02X", i);
>  
> -            method = aml_method("_MAT", 0);
> +            method = aml_method("_MAT", 0, AML_NOTSERIALIZED);
>              aml_append(method, aml_return(aml_call1("CPMA", aml_int(i))));
>              aml_append(dev, method);
>  
> -            method = aml_method("_STA", 0);
> +            method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>              aml_append(method, aml_return(aml_call1("CPST", aml_int(i))));
>              aml_append(dev, method);
>  
> -            method = aml_method("_EJ0", 1);
> +            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>              aml_append(method,
>                  aml_return(aml_call2("CPEJ", aml_int(i), aml_arg(0)))
>              );
> @@ -1174,7 +1174,7 @@ build_ssdt(GArray *table_data, GArray *linker,
>           *   Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} 
> ...}
>           */
>          /* Arg0 = Processor ID = APIC ID */
> -        method = aml_method("NTFY", 2);
> +        method = aml_method("NTFY", 2, AML_NOTSERIALIZED);
>          for (i = 0; i < acpi_cpus; i++) {
>              ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
>              aml_append(ifctx,
> @@ -1269,29 +1269,29 @@ build_ssdt(GArray *table_data, GArray *linker,
>              aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
>              aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
>  
> -            method = aml_method("_CRS", 0);
> +            method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
>              s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
>              aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>              aml_append(dev, method);
>  
> -            method = aml_method("_STA", 0);
> +            method = aml_method("_STA", 0, AML_NOTSERIALIZED);
>              s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
>              aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>              aml_append(dev, method);
>  
> -            method = aml_method("_PXM", 0);
> +            method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
>              s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
>              aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>              aml_append(dev, method);
>  
> -            method = aml_method("_OST", 3);
> +            method = aml_method("_OST", 3, AML_NOTSERIALIZED);
>              s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
>              aml_append(method, aml_return(aml_call4(
>                  s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
>              )));
>              aml_append(dev, method);
>  
> -            method = aml_method("_EJ0", 1);
> +            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
>              s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
>              aml_append(method, aml_return(aml_call2(
>                         s, aml_name("_UID"), aml_arg(0))));
> @@ -1303,7 +1303,8 @@ build_ssdt(GArray *table_data, GArray *linker,
>          /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
>           *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
>           */
> -        method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
> +        method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2,
> +                            AML_NOTSERIALIZED);
>          for (i = 0; i < nr_mem; i++) {
>              ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
>              aml_append(ifctx,
> diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
> index 944b001..cd82065 100644
> --- a/include/hw/acpi/aml-build.h
> +++ b/include/hw/acpi/aml-build.h
> @@ -148,6 +148,12 @@ typedef enum {
>      AML_SHARED_AND_WAKE = 3,
>  } AmlShared;
>  
> +/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: MethodFlags */
> +typedef enum {
> +    AML_NOTSERIALIZED = 0,
> +    AML_SERIALIZED = 1,
> +} AmlSerializeFlag;
> +
>  typedef
>  struct AcpiBuildTables {
>      GArray *table_data;
> @@ -268,7 +274,7 @@ Aml *aml_sleep(uint64_t msec);
>  /* Block AML object primitives */
>  Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
>  Aml *aml_device(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
> -Aml *aml_method(const char *name, int arg_count);
> +Aml *aml_method(const char *name, int arg_count, AmlSerializeFlag sflag);
>  Aml *aml_if(Aml *predicate);
>  Aml *aml_else(void);
>  Aml *aml_while(Aml *predicate);
> 

-- 
Shannon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]