Skip to contentSkip to conversation

hw/arm/acpi: simplify AML bit and/or statement

PATCH Superseded Heyi Guo 2 participants 7 messages Mar 5, 2019 – Mar 7, 2019

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Heyi Guo

author
#0 lore raw

PATCH v3 1/2 hw/arm/acpi: simplify AML bit and/or statement

The last argument of AML bit and/or statement is the target variable, so we don't need to use a NULL target and then an additional store operation; a single bit and/or statement is enough.

Cc Shannon Zhao <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
---
 hw/arm/virt-acpi-build.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/arm/virt-acpi-build.c +4 -4
index 04b62c7..1c84e87 100644
@@ -265,16 +265,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
         aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));
     aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP")));
     aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL")));
-    aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL),
+    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                                 aml_name("CTRL")));
 
     ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x08), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),
                                  aml_name("CDW1")));
     aml_append(ifctx, ifctx1);
 
     ifctx1 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), aml_name("CTRL"))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x10), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x10),
                                  aml_name("CDW1")));
     aml_append(ifctx, ifctx1);
 
@@ -283,7 +283,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
     aml_append(method, ifctx);
 
     elsectx = aml_else();
-    aml_append(elsectx, aml_store(aml_or(aml_name("CDW1"), aml_int(4), NULL),
+    aml_append(elsectx, aml_or(aml_name("CDW1"), aml_int(4),
                                   aml_name("CDW1")));
     aml_append(elsectx, aml_return(aml_arg(3)));
     aml_append(method, elsectx);
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH v3 2/2 hw/arm/acpi: enable SHPC native hot plug

After the introduction of generic PCIe root port and PCIe-PCI bridge, we will also have SHPC controller on ARM, so just enalbe SHPC native hot plug.

Cc Shannon Zhao <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
---
 hw/arm/virt-acpi-build.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +6 -1
index 1c84e87..e8e00fe 100644
@@ -265,7 +265,12 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
         aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));
     aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP")));
     aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL")));
-    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
+
+    /*
+     * Allow OS control for all 5 features:
+     * PCIeHotplug SHPCHotplug PME AER PCIeCapability.
+     */
+    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1F),
                                 aml_name("CTRL")));
 
     ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH v3 2/2] hw/arm/acpi: enable SHPC native hot plug

Quoted 20 lines · On Wed, 6 Mar 2019 06:03:49 +0800 Heyi Guo <[email protected]> wrote:

After the introduction of generic PCIe root port and PCIe-PCI bridge, we will also have SHPC controller on ARM, so just enalbe SHPC native hot plug.

Cc Shannon Zhao <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
---
 hw/arm/virt-acpi-build.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +0 -0
index 1c84e87..e8e00fe 100644
@@ -265,7 +265,12 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
         aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 274

Quoted 10 lines
hw/arm/virt-acpi-build.c +6 -1
     aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP")));
     aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL")));
-    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
+
+    /*
+     * Allow OS control for all 5 features:
+     * PCIeHotplug SHPCHotplug PME AER PCIeCapability.
+     */
+    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1F),
                                 aml_name("CTRL")));

ditto: fix indent

Quoted 2 lines
hw/arm/virt-acpi-build.c +0 -0
     ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
#3 lore raw
In reply to Heyi Guo
Quoted 19 lines · On Wed, 6 Mar 2019 06:03:48 +0800 Heyi Guo <[email protected]> wrote:

The last argument of AML bit and/or statement is the target variable, so we don't need to use a NULL target and then an additional store operation; a single bit and/or statement is enough.

Cc Shannon Zhao <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
---
 hw/arm/virt-acpi-build.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/arm/virt-acpi-build.c +0 -0
index 04b62c7..1c84e87 100644

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 269

Quoted 6 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -265,16 +265,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
         aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));
     aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP")));
     aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL")));
-    aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL),
+    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                                 aml_name("CTRL")));

pls fix indent in all such cases. I'd align it like this:
aml_append(ifctx,

              aml_and(aml_name("CTRL"), aml_int(0x1D), aml_name("CTRL")));

or
aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),

                             aml_name("CTRL")));

PS:
When making multi-patch series use --cover-letter git option

Quoted 22 lines
hw/arm/virt-acpi-build.c +3 -3
     ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x08), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),
                                  aml_name("CDW1")));
     aml_append(ifctx, ifctx1);
 
     ifctx1 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), aml_name("CTRL"))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x10), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x10),
                                  aml_name("CDW1")));
     aml_append(ifctx, ifctx1);
 
@@ -283,7 +283,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
     aml_append(method, ifctx);
 
     elsectx = aml_else();
-    aml_append(elsectx, aml_store(aml_or(aml_name("CDW1"), aml_int(4), NULL),
+    aml_append(elsectx, aml_or(aml_name("CDW1"), aml_int(4),
                                   aml_name("CDW1")));
     aml_append(elsectx, aml_return(aml_arg(3)));
     aml_append(method, elsectx);
author
#4 lore raw

Sorry, I didn't know the indention policy of qemu code. So we need to indent the 2nd line just after the parentheses it belongs to?

Will change that and send next version.

Thanks,

Heyi

Quoted 65 lines · Igor Mammedov
Quoted 19 lines · On Wed, 6 Mar 2019 06:03:48 +0800 Heyi Guo <[email protected]> wrote:

The last argument of AML bit and/or statement is the target variable, so we don't need to use a NULL target and then an additional store operation; a single bit and/or statement is enough.

Cc Shannon Zhao <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
---
  hw/arm/virt-acpi-build.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
hw/arm/virt-acpi-build.c +0 -0
index 04b62c7..1c84e87 100644

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 269

Quoted 6 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -265,16 +265,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
          aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));
      aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP")));
      aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL")));
-    aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL),
+    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                                  aml_name("CTRL")));

pls fix indent in all such cases. I'd align it like this:

    aml_append(ifctx,
               aml_and(aml_name("CTRL"), aml_int(0x1D), aml_name("CTRL")));

or

    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                              aml_name("CTRL")));

PS:
When making multi-patch series use --cover-letter git option

Quoted 14 lines
hw/arm/virt-acpi-build.c +2 -2
      ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x08), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),
                                   aml_name("CDW1")));
      aml_append(ifctx, ifctx1);
 
      ifctx1 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), aml_name("CTRL"))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x10), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x10),
                                   aml_name("CDW1")));
      aml_append(ifctx, ifctx1);
 

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 289

Quoted 8 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -283,7 +283,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
      aml_append(method, ifctx);
 
      elsectx = aml_else();
-    aml_append(elsectx, aml_store(aml_or(aml_name("CDW1"), aml_int(4), NULL),
+    aml_append(elsectx, aml_or(aml_name("CDW1"), aml_int(4),
                                    aml_name("CDW1")));
      aml_append(elsectx, aml_return(aml_arg(3)));
      aml_append(method, elsectx);

.

#5 lore raw
Quoted 1 line · On Wed, 6 Mar 2019 21:09:11 +0800 Heyi Guo <[email protected]> wrote:

Sorry, I didn't know the indention policy of qemu code. So we need to indent the 2nd line just after the parentheses it belongs to?

See "[PATCH v6 0/2] CODING_STYLE: trivial update" for clarification

Quoted 77 lines

Will change that and send next version.

Thanks,

Heyi

Quoted 65 lines · Igor Mammedov
Quoted 19 lines · On Wed, 6 Mar 2019 06:03:48 +0800 Heyi Guo <[email protected]> wrote:

The last argument of AML bit and/or statement is the target variable, so we don't need to use a NULL target and then an additional store operation; a single bit and/or statement is enough.

Cc Shannon Zhao <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
---
  hw/arm/virt-acpi-build.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
hw/arm/virt-acpi-build.c +0 -0
index 04b62c7..1c84e87 100644

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 269

Quoted 6 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -265,16 +265,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
          aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));
      aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP")));
      aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL")));
-    aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL),
+    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                                  aml_name("CTRL")));

pls fix indent in all such cases. I'd align it like this:

    aml_append(ifctx,
               aml_and(aml_name("CTRL"), aml_int(0x1D), aml_name("CTRL")));

or

    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                              aml_name("CTRL")));

PS:
When making multi-patch series use --cover-letter git option

Quoted 14 lines
hw/arm/virt-acpi-build.c +2 -2
      ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x08), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),
                                   aml_name("CDW1")));
      aml_append(ifctx, ifctx1);
 
      ifctx1 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), aml_name("CTRL"))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x10), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x10),
                                   aml_name("CDW1")));
      aml_append(ifctx, ifctx1);
 

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 289

Quoted 8 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -283,7 +283,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
      aml_append(method, ifctx);
 
      elsectx = aml_else();
-    aml_append(elsectx, aml_store(aml_or(aml_name("CDW1"), aml_int(4), NULL),
+    aml_append(elsectx, aml_or(aml_name("CDW1"), aml_int(4),
                                    aml_name("CDW1")));
      aml_append(elsectx, aml_return(aml_arg(3)));
      aml_append(method, elsectx);

.

author
#6 lore raw

Got it; thanks.

Heyi

Quoted 83 lines · Igor Mammedov
Quoted 1 line · On Wed, 6 Mar 2019 21:09:11 +0800 Heyi Guo <[email protected]> wrote:

Sorry, I didn't know the indention policy of qemu code. So we need to indent the 2nd line just after the parentheses it belongs to?

See "[PATCH v6 0/2] CODING_STYLE: trivial update" for clarification

Quoted 74 lines

Will change that and send next version.

Thanks,

Heyi

Quoted 64 lines · Igor Mammedov
Quoted 19 lines · On Wed, 6 Mar 2019 06:03:48 +0800 Heyi Guo <[email protected]> wrote:

The last argument of AML bit and/or statement is the target variable, so we don't need to use a NULL target and then an additional store operation; a single bit and/or statement is enough.

Cc Shannon Zhao <[email protected]>
Cc Peter Maydell <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Igor Mammedov <[email protected]>
---
   hw/arm/virt-acpi-build.c | 8 ++++----
   1 file changed, 4 insertions(+), 4 deletions(-)
hw/arm/virt-acpi-build.c +0 -0
index 04b62c7..1c84e87 100644

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 269

Quoted 6 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -265,16 +265,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
           aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3"));
       aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP")));
       aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL")));
-    aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL),
+    aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                                   aml_name("CTRL")));

pls fix indent in all such cases. I'd align it like this:

     aml_append(ifctx,
                aml_and(aml_name("CTRL"), aml_int(0x1D), aml_name("CTRL")));

or

     aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D),
                               aml_name("CTRL")));

PS:
When making multi-patch series use --cover-letter git option

Quoted 14 lines
hw/arm/virt-acpi-build.c +2 -2
       ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x08), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),
                                    aml_name("CDW1")));
       aml_append(ifctx, ifctx1);
 
       ifctx1 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), aml_name("CTRL"))));
-    aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x10), NULL),
+    aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x10),
                                    aml_name("CDW1")));
       aml_append(ifctx, ifctx1);
 

hw/arm/virt-acpi-build.c static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, · line 289

Quoted 8 lines
hw/arm/virt-acpi-build.c +1 -1
@@ -283,7 +283,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
       aml_append(method, ifctx);
 
       elsectx = aml_else();
-    aml_append(elsectx, aml_store(aml_or(aml_name("CDW1"), aml_int(4), NULL),
+    aml_append(elsectx, aml_or(aml_name("CDW1"), aml_int(4),
                                     aml_name("CDW1")));
       aml_append(elsectx, aml_return(aml_arg(3)));
       aml_append(method, elsectx);

.

.