Skip to contentSkip to conversation

support NFIT platform capabilities

PATCH Superseded Ross Zwisler 3 participants 12 messages May 17, 2018 – May 21, 2018 libnvdimm: non-volatile memory device

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover support NFIT platform capabilities

The first 2 patches in this series clean up some things I noticed while coding.

Patch 3 adds support for the new Platform Capabilities Structure, which was added to the NFIT in ACPI 6.2 Errata A. We add a machine command line option "nvdimm-cap":

-machine pc,accel=kvm,nvdimm,nvdimm-cap=2

which allows the user to pass in a value for this structure. When such a value is passed in we will generate the new NFIT subtable.

Patch 4 adds code to the "make check" self test infrastructure so that we generate the new Platform Capabilities Structure, and adds it to the expected NFIT output so that we test for it.

Thanks to Igor Mammedov for his feedback on v1 of this set.

Ross Zwisler (4):
nvdimm: fix typo in label-size definition tests/.gitignore: add entry for generated file nvdimm, acpi: support NFIT platform capabilities ACPI testing: test NFIT platform capabilities

 docs/nvdimm.txt                       |  18 ++++++++++++++
 hw/acpi/nvdimm.c                      |  44 ++++++++++++++++++++++++++++++----
 hw/i386/pc.c                          |  31 ++++++++++++++++++++++++
 hw/mem/nvdimm.c                       |   2 +-
 include/hw/i386/pc.h                  |   1 +
 include/hw/mem/nvdimm.h               |   7 +++++-
 tests/.gitignore                      |   1 +
 tests/acpi-test-data/pc/NFIT.dimmpxm  | Bin 224 -> 240 bytes
 tests/acpi-test-data/q35/NFIT.dimmpxm | Bin 224 -> 240 bytes
 tests/bios-tables-test.c              |   2 +-
 10 files changed, 99 insertions(+), 7 deletions(-)
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw

PATCH v2 1/4 nvdimm: fix typo in label-size definition

Fixes commit da6789c27c2e ("nvdimm: add a macro for property "label-size"")
Cc Haozhong Zhang <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
---
 hw/mem/nvdimm.c         | 2 +-
 include/hw/mem/nvdimm.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/mem/nvdimm.c +1 -1
index acb656b672..4087aca25e 100644
@@ -89,7 +89,7 @@ static void nvdimm_set_unarmed(Object *obj, bool value, Error **errp)
 
 static void nvdimm_init(Object *obj)
 {
-    object_property_add(obj, NVDIMM_LABLE_SIZE_PROP, "int",
+    object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int",
                         nvdimm_get_label_size, nvdimm_set_label_size, NULL,
                         NULL, NULL);
     object_property_add_bool(obj, NVDIMM_UNARMED_PROP,
include/hw/mem/nvdimm.h +1 -1
index 7fd87c4e1c..74c60332e1 100644
@@ -48,7 +48,7 @@
 #define NVDIMM_GET_CLASS(obj) OBJECT_GET_CLASS(NVDIMMClass, (obj), \
                                                TYPE_NVDIMM)
 
-#define NVDIMM_LABLE_SIZE_PROP "label-size"
+#define NVDIMM_LABEL_SIZE_PROP "label-size"
 #define NVDIMM_UNARMED_PROP    "unarmed"
 
 struct NVDIMMDevice {
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#2 lore raw

PATCH v2 2/4 tests/.gitignore: add entry for generated file

In reply to Ross Zwisler

After a "make check" we end up with the following:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Untracked files:
(use "git add <file>..." to include in what will be committed)

tests/test-block-backend

nothing added to commit but untracked files present (use "git add" to track)

Fixes commit ad0df3e0fdac ("block: test blk_aio_flush() with blk->root == NULL")
---
 tests/.gitignore | 1 +
 1 file changed, 1 insertion(+)
tests/.gitignore +1 -0
index fb62d2299b..2bc61a9a58 100644
@@ -21,6 +21,7 @@ test-base64
 test-bdrv-drain
 test-bitops
 test-bitcnt
+test-block-backend
 test-blockjob
 test-blockjob-txn
 test-bufferiszero
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#3 lore raw

PATCH v2 3/4 nvdimm, acpi: support NFIT platform capabilities

In reply to Ross Zwisler

Add a machine command line option to allow the user to control the Platform Capabilities Structure in the virtualized NFIT. This Platform Capabilities Structure was added in ACPI 6.2 Errata A.

---
 docs/nvdimm.txt         | 18 ++++++++++++++++++
 hw/acpi/nvdimm.c        | 44 ++++++++++++++++++++++++++++++++++++++++----
 hw/i386/pc.c            | 31 +++++++++++++++++++++++++++++++
 include/hw/i386/pc.h    |  1 +
 include/hw/mem/nvdimm.h |  5 +++++
 5 files changed, 95 insertions(+), 4 deletions(-)
docs/nvdimm.txt +18 -0
index e903d8bb09..3f18013880 100644
@@ -153,3 +153,21 @@ guest NVDIMM region mapping structure.  This unarmed flag indicates
 guest software that this vNVDIMM device contains a region that cannot
 accept persistent writes. In result, for example, the guest Linux
 NVDIMM driver, marks such vNVDIMM device as read-only.
+
+Platform Capabilities
+---------------------
+
+ACPI 6.2 Errata A added support for a new Platform Capabilities Structure
+which allows the platform to communicate what features it supports related to
+NVDIMM data durability.  Users can provide a capabilities value to a guest via
+the optional "nvdimm-cap" machine command line option:
+
+    -machine pc,accel=kvm,nvdimm,nvdimm-cap=2
+
+As of ACPI 6.2 Errata A, the following values are valid for the bottom two
+bits:
+
+2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable.
+3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.
+
+For a complete list of the flags available please consult the ACPI spec.
hw/acpi/nvdimm.c +40 -4

75 lines not on this page · raw message

hw/i386/pc.c +31 -0
index d768930d02..1b2684c549 100644
@@ -2182,6 +2182,33 @@ static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp)
     pcms->acpi_nvdimm_state.is_enabled = value;
 }
 
+static void pc_machine_get_nvdimm_capabilities(Object *obj, Visitor *v,
+                                               const char *name, void *opaque,
+                                               Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+    uint32_t value = pcms->acpi_nvdimm_state.capabilities;
+
+    visit_type_uint32(v, name, &value, errp);
+}
+
+static void pc_machine_set_nvdimm_capabilities(Object *obj, Visitor *v,
+                                               const char *name, void *opaque,
+                                               Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+    Error *error = NULL;
+    uint32_t value;
+
+    visit_type_uint32(v, name, &value, &error);
+    if (error) {
+        error_propagate(errp, error);
+        return;
+    }
+
+    pcms->acpi_nvdimm_state.capabilities = value;
+}
+
 static bool pc_machine_get_smbus(Object *obj, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -2395,6 +2422,10 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     object_class_property_add_bool(oc, PC_MACHINE_NVDIMM,
         pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort);
 
+    object_class_property_add(oc, PC_MACHINE_NVDIMM_CAP, "uint32",
+        pc_machine_get_nvdimm_capabilities,
+        pc_machine_set_nvdimm_capabilities, NULL, NULL, &error_abort);
+
     object_class_property_add_bool(oc, PC_MACHINE_SMBUS,
         pc_machine_get_smbus, pc_machine_set_smbus, &error_abort);
 
include/hw/i386/pc.h +1 -0
index 2a98e3ad68..e9b22f929c 100644
@@ -76,6 +76,7 @@ struct PCMachineState {
 #define PC_MACHINE_VMPORT           "vmport"
 #define PC_MACHINE_SMM              "smm"
 #define PC_MACHINE_NVDIMM           "nvdimm"
+#define PC_MACHINE_NVDIMM_CAP       "nvdimm-cap"
 #define PC_MACHINE_SMBUS            "smbus"
 #define PC_MACHINE_SATA             "sata"
 #define PC_MACHINE_PIT              "pit"
include/hw/mem/nvdimm.h +5 -0
index 74c60332e1..3c82751bab 100644
@@ -134,6 +134,11 @@ struct AcpiNVDIMMState {
 
     /* the IO region used by OSPM to transfer control to QEMU. */
     MemoryRegion io_mr;
+
+    /*
+     * Platform capabilities, section 5.2.25.9 of ACPI 6.2 Errata A
+     */
+    int32_t capabilities;
 };
 typedef struct AcpiNVDIMMState AcpiNVDIMMState;
 
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#4 lore raw

RE: [qemu PATCH v2 3/4] nvdimm, acpi: support NFIT platform capabilities

Quoted 15 lines

-----Original Message-----
From: Linux-nvdimm [mailto:[email protected]] On Behalf Of Ross Zwisler
Sent: Thursday, May 17, 2018 12:00 AM
Subject: [qemu PATCH v2 3/4] nvdimm, acpi: support NFIT platform capabilities

Add a machine command line option to allow the user to control the Platform
Capabilities Structure in the virtualized NFIT. This Platform Capabilities
Structure was added in ACPI 6.2 Errata A.

...

Quoted 14 lines
docs/nvdimm.txt +5 -0
+Platform Capabilities
+---------------------
+
+ACPI 6.2 Errata A added support for a new Platform Capabilities Structure
+which allows the platform to communicate what features it supports

related to
+NVDIMM data durability. Users can provide a capabilities value to a guest via

docs/nvdimm.txt +5 -0
+the optional "nvdimm-cap" machine command line option:
+
+    -machine pc,accel=kvm,nvdimm,nvdimm-cap=2
+
+As of ACPI 6.2 Errata A, the following values are valid for the bottom

two

docs/nvdimm.txt guest NVDIMM region mapping structure. This unarmed flag indicates · line 171

Quoted 4 lines
docs/nvdimm.txt +4 -0
+bits:
+
+2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable.
+3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.

It's a bit unclear that those are decimal values for the field, not bit numbers.

...

Quoted 5 lines
hw/acpi/nvdimm.c +4 -1
-static GArray *nvdimm_build_device_structure(void)
+/*
+ * ACPI 6.2 Errata A: 5.2.25.9 NVDIMM Platform Capabilities Structure
+ */
+static void

hw/acpi/nvdimm.c static void nvdimm_build_structure_dcr(GArray *structures, DeviceState *dev) · line 382

Quoted 10 lines
hw/acpi/nvdimm.c +10 -0
+nvdimm_build_structure_caps(GArray *structures, uint32_t capabilities)
+{
+    NvdimmNfitPlatformCaps *nfit_caps;
+
+    nfit_caps = acpi_data_push(structures, sizeof(*nfit_caps));
+
+    nfit_caps->type = cpu_to_le16(7 /* NVDIMM Platform Capabilities */);
+    nfit_caps->length = cpu_to_le16(sizeof(*nfit_caps));
+    nfit_caps->highest_cap = 2;
+    nfit_caps->capabilities = cpu_to_le32(capabilities);

highest_cap needs to be set to a value that at least covers the highest bit set to 1 used in capabilities.

As capabilities bits are added, there are three different meanings:
* 1: bit within highest_cap range, platform is claiming the 1 meaning
* 0: bit within highest_cap range, platform is claiming the 0 meaning
* not reported: bit not within highest_cap range, so the platform's implementation of this feature is unknown. Not necessarily the same as the 0 meaning.

So, there should be a way to specify a highest_cap value to convey that some of the upper capabilities bits are valid and contain 0.

---
Robert Elliott, HPE Persistent Memory

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#5 lore raw

Re: [qemu PATCH v2 3/4] nvdimm, acpi: support NFIT platform capabilities

Quoted 29 lines · Robert (Persistent Memory)
Quoted 15 lines

-----Original Message-----
From: Linux-nvdimm [mailto:[email protected]] On Behalf Of Ross Zwisler
Sent: Thursday, May 17, 2018 12:00 AM
Subject: [qemu PATCH v2 3/4] nvdimm, acpi: support NFIT platform capabilities

Add a machine command line option to allow the user to control the Platform
Capabilities Structure in the virtualized NFIT. This Platform Capabilities
Structure was added in ACPI 6.2 Errata A.

...

Quoted 13 lines
docs/nvdimm.txt +5 -0
+Platform Capabilities
+---------------------
+
+ACPI 6.2 Errata A added support for a new Platform Capabilities Structure
+which allows the platform to communicate what features it supports

related to
+NVDIMM data durability. Users can provide a capabilities value to a guest via

docs/nvdimm.txt +5 -0
+the optional "nvdimm-cap" machine command line option:
+
+    -machine pc,accel=kvm,nvdimm,nvdimm-cap=2
+
+As of ACPI 6.2 Errata A, the following values are valid for the bottom
Quoted 8 lines

docs/nvdimm.txt guest NVDIMM region mapping structure. This unarmed flag indicates · line 171

Quoted 5 lines

two

docs/nvdimm.txt +4 -0
+bits:
+
+2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable.
+3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.

It's a bit unclear that those are decimal values for the field, not bit numbers.

Hmm..I was trying to be clear by saying "the following values are valid for the bottom two bits", and having 2 and 3 as the possible values.

Would it help to show them in hex?

As of ACPI 6.2 Errata A, the following values are valid for the bottom two bits:

0x2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable. 0x3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.

More clearly showing that they are values created by combining bitfields?

Quoted 26 lines
Quoted 5 lines
hw/acpi/nvdimm.c +4 -1
-static GArray *nvdimm_build_device_structure(void)
+/*
+ * ACPI 6.2 Errata A: 5.2.25.9 NVDIMM Platform Capabilities Structure
+ */
+static void

hw/acpi/nvdimm.c static void nvdimm_build_structure_dcr(GArray *structures, DeviceState *dev) · line 382

Quoted 10 lines
hw/acpi/nvdimm.c +10 -0
+nvdimm_build_structure_caps(GArray *structures, uint32_t capabilities)
+{
+    NvdimmNfitPlatformCaps *nfit_caps;
+
+    nfit_caps = acpi_data_push(structures, sizeof(*nfit_caps));
+
+    nfit_caps->type = cpu_to_le16(7 /* NVDIMM Platform Capabilities */);
+    nfit_caps->length = cpu_to_le16(sizeof(*nfit_caps));
+    nfit_caps->highest_cap = 2;
+    nfit_caps->capabilities = cpu_to_le32(capabilities);

highest_cap needs to be set to a value that at least covers the highest bit set to 1 used in capabilities.

As capabilities bits are added, there are three different meanings:
* 1: bit within highest_cap range, platform is claiming the 1 meaning
* 0: bit within highest_cap range, platform is claiming the 0 meaning
* not reported: bit not within highest_cap range, so the platform's implementation of this feature is unknown. Not necessarily the same as the 0 meaning.

Quoted 2 lines

So, there should be a way to specify a highest_cap value to convey that some of the upper capabilities bits are valid and contain 0.

Right, I'll make this dynamic based on the capabilities value passed in by the user. That's a much better solution, thanks. This should cover all the same cases as you have outlined above, without burdening the user with yet another input value.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#6 lore raw

RE: [qemu PATCH v2 3/4] nvdimm, acpi: support NFIT platform capabilities

...

Quoted 7 lines

Would it help to show them in hex?

As of ACPI 6.2 Errata A, the following values are valid for the bottom two bits:

0x2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable. 0x3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.

Yes, that helps (unless the parser for that command-line does not accept hex values).

It would also help to make the text be:
"CPU Cache and Memory Controller Flush"

...

Quoted 7 lines
Quoted 2 lines

So, there should be a way to specify a highest_cap value to convey that some of the upper capabilities bits are valid and contain 0.

Right, I'll make this dynamic based on the capabilities value passed in by the user. That's a much better solution, thanks. This should cover all the same cases as you have outlined above, without burdening the user with yet another input value.

Automatically determining the highest bit that the user wants to set to 1 should be easy, and will probably be the most common case.

It's harder to let the user set some upper bits to 0 but also have them within the highest_cap range. Since this will be less common, the syntax could be more convoluted, like an optional highest_cap argument to override the automatically generated value.

For example, to report bits 7, 1 and 0 are all set to 1:

	-machine pc,accel=kvm,nvdimm,nvdimm-cap=0x83

would automatically set highest_cap to 7.

To report bit 7 set to 0 while bits 1 and 0 are set to 1:

	-machine pc,accel=kvm,nvdimm,nvdimm-cap=0x3,nvdimm-highest-cap=7

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#7 lore raw

Re: [qemu PATCH v2 3/4] nvdimm, acpi: support NFIT platform capabilities

Quoted 8 lines · Robert (Persistent Memory)

...

Quoted 5 lines

Would it help to show them in hex?

As of ACPI 6.2 Errata A, the following values are valid for the bottom two bits:

Quoted 8 lines
Quoted 2 lines

0x2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable. 0x3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.

Yes, that helps (unless the parser for that command-line does not accept hex values).

It would also help to make the text be:
"CPU Cache and Memory Controller Flush"

Yea, let me check on that. I'll update the wording regardless to try and make it more clear.

Quoted 17 lines

...

Quoted 7 lines
Quoted 2 lines

So, there should be a way to specify a highest_cap value to convey that some of the upper capabilities bits are valid and contain 0.

Right, I'll make this dynamic based on the capabilities value passed in by the user. That's a much better solution, thanks. This should cover all the same cases as you have outlined above, without burdening the user with yet another input value.

Automatically determining the highest bit that the user wants to set to 1 should be easy, and will probably be the most common case.

It's harder to let the user set some upper bits to 0 but also have them within the highest_cap range. Since this will be less common, the syntax could be more convoluted, like an optional highest_cap argument to override the automatically generated value.

Quoted 6 lines

For example, to report bits 7, 1 and 0 are all set to 1:

	-machine pc,accel=kvm,nvdimm,nvdimm-cap=0x83

would automatically set highest_cap to 7.

To report bit 7 set to 0 while bits 1 and 0 are set to 1:

	-machine pc,accel=kvm,nvdimm,nvdimm-cap=0x3,nvdimm-highest-cap=7

Yea, I agree that this is how we could do it, but I don't think this is necessary right now. We currently only have 3 bits in the Capabilities field, and right now there is never a case where there is a difference between "I don't know about this bit" and "I know about this bit, and it's value is 0".

So, really for now we could essentially just say the highest_cap = 31 and be fine.

Let's put off the nvdimm-highest-cap argument complexity until we actually have a use case where it adds value.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#8 lore raw

Re: [qemu PATCH v2 3/4] nvdimm, acpi: support NFIT platform capabilities

In reply to Elliott, Robert (Persistent Memory)
Quoted 5 lines · Robert (Persistent Memory)

...

Quoted 2 lines

Would it help to show them in hex?

Quoted 8 lines
Quoted 5 lines

As of ACPI 6.2 Errata A, the following values are valid for the bottom two bits:

0x2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable. 0x3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.

Yes, that helps (unless the parser for that command-line does not accept hex values).

Yep, the command-line parser does accept hex values. I ended up just trying to make the text clearer, though.

Quoted 2 lines

It would also help to make the text be:
"CPU Cache and Memory Controller Flush"

My descriptions for the bits are coming straight out of ACPI. :) I'd prefer to stay consistent with what's written in the spec.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#9 lore raw

PATCH v2 4/4 ACPI testing: test NFIT platform capabilities

In reply to Ross Zwisler

Add testing for the newly added NFIT Platform Capabilities Structure.

---
 tests/acpi-test-data/pc/NFIT.dimmpxm  | Bin 224 -> 240 bytes
 tests/acpi-test-data/q35/NFIT.dimmpxm | Bin 224 -> 240 bytes
 tests/bios-tables-test.c              |   2 +-
 3 files changed, 1 insertion(+), 1 deletion(-)
tests/acpi-test-data/pc/NFIT.dimmpxm binary +0 -0
index 2bfc6c51f31c25a052803c494c933d4948fc0106..b5f18b1e570f2058442c34799a2bde7ff50449f2 100644
GIT binary patch
tests/acpi-test-data/q35/NFIT.dimmpxm binary +0 -0
index 2bfc6c51f31c25a052803c494c933d4948fc0106..b5f18b1e570f2058442c34799a2bde7ff50449f2 100644
GIT binary patch
tests/bios-tables-test.c +1 -1
index bf3e193ae9..256d463cb8 100644
@@ -830,7 +830,7 @@ static void test_acpi_tcg_dimm_pxm(const char *machine)
     memset(&data, 0, sizeof(data));
     data.machine = machine;
     data.variant = ".dimmpxm";
-    test_acpi_one(" -machine nvdimm=on"
+    test_acpi_one(" -machine nvdimm=on,nvdimm-cap=3"
                   " -smp 4,sockets=4"
                   " -m 128M,slots=3,maxmem=1G"
                   " -numa node,mem=32M,nodeid=0"
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#10 lore raw
In reply to Ross Zwisler
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [qemu PATCH v2 0/4] support NFIT platform capabilities

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384

Quoted 1 line

From https://github.com/patchew-project/qemu

t [tag update] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
3a8b0e98fa ACPI testing: test NFIT platform capabilities 5732e8be9b nvdimm, acpi: support NFIT platform capabilities 3808b5f1bc tests/.gitignore: add entry for generated file fa07ae77c6 nvdimm: fix typo in label-size definition

=== OUTPUT BEGIN ===
Checking PATCH 1/4: nvdimm: fix typo in label-size definition... Checking PATCH 2/4: tests/.gitignore: add entry for generated file... Checking PATCH 3/4: nvdimm, acpi: support NFIT platform capabilities...
ERROR: braces {} are necessary for all arms of this statement #94: FILE: hw/acpi/nvdimm.c:407:
+ if (state->capabilities)
[...]

total: 1 errors, 0 warnings, 157 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 4/4: ACPI testing: test NFIT platform capabilities... === OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#11 lore raw

PATCH v3 3/4 nvdimm, acpi: support NFIT platform capabilities

Add a machine command line option to allow the user to control the Platform Capabilities Structure in the virtualized NFIT. This Platform Capabilities Structure was added in ACPI 6.2 Errata A.

---

v3: Added brackets around single statement "if" conditional to comply
with qemu coding style.

---
 docs/nvdimm.txt         | 18 ++++++++++++++++++
 hw/acpi/nvdimm.c        | 45 +++++++++++++++++++++++++++++++++++++++++----
 hw/i386/pc.c            | 31 +++++++++++++++++++++++++++++++
 include/hw/i386/pc.h    |  1 +
 include/hw/mem/nvdimm.h |  5 +++++
 5 files changed, 96 insertions(+), 4 deletions(-)
docs/nvdimm.txt +18 -0
index e903d8bb09..3f18013880 100644
@@ -153,3 +153,21 @@ guest NVDIMM region mapping structure.  This unarmed flag indicates
 guest software that this vNVDIMM device contains a region that cannot
 accept persistent writes. In result, for example, the guest Linux
 NVDIMM driver, marks such vNVDIMM device as read-only.
+
+Platform Capabilities
+---------------------
+
+ACPI 6.2 Errata A added support for a new Platform Capabilities Structure
+which allows the platform to communicate what features it supports related to
+NVDIMM data durability.  Users can provide a capabilities value to a guest via
+the optional "nvdimm-cap" machine command line option:
+
+    -machine pc,accel=kvm,nvdimm,nvdimm-cap=2
+
+As of ACPI 6.2 Errata A, the following values are valid for the bottom two
+bits:
+
+2 - Memory Controller Flush to NVDIMM Durability on Power Loss Capable.
+3 - CPU Cache Flush to NVDIMM Durability on Power Loss Capable.
+
+For a complete list of the flags available please consult the ACPI spec.
hw/acpi/nvdimm.c +41 -4

76 lines not on this page · raw message

hw/i386/pc.c +31 -0
index d768930d02..1b2684c549 100644
@@ -2182,6 +2182,33 @@ static void pc_machine_set_nvdimm(Object *obj, bool value, Error **errp)
     pcms->acpi_nvdimm_state.is_enabled = value;
 }
 
+static void pc_machine_get_nvdimm_capabilities(Object *obj, Visitor *v,
+                                               const char *name, void *opaque,
+                                               Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+    uint32_t value = pcms->acpi_nvdimm_state.capabilities;
+
+    visit_type_uint32(v, name, &value, errp);
+}
+
+static void pc_machine_set_nvdimm_capabilities(Object *obj, Visitor *v,
+                                               const char *name, void *opaque,
+                                               Error **errp)
+{
+    PCMachineState *pcms = PC_MACHINE(obj);
+    Error *error = NULL;
+    uint32_t value;
+
+    visit_type_uint32(v, name, &value, &error);
+    if (error) {
+        error_propagate(errp, error);
+        return;
+    }
+
+    pcms->acpi_nvdimm_state.capabilities = value;
+}
+
 static bool pc_machine_get_smbus(Object *obj, Error **errp)
 {
     PCMachineState *pcms = PC_MACHINE(obj);
@@ -2395,6 +2422,10 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     object_class_property_add_bool(oc, PC_MACHINE_NVDIMM,
         pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort);
 
+    object_class_property_add(oc, PC_MACHINE_NVDIMM_CAP, "uint32",
+        pc_machine_get_nvdimm_capabilities,
+        pc_machine_set_nvdimm_capabilities, NULL, NULL, &error_abort);
+
     object_class_property_add_bool(oc, PC_MACHINE_SMBUS,
         pc_machine_get_smbus, pc_machine_set_smbus, &error_abort);
 
include/hw/i386/pc.h +1 -0
index 2a98e3ad68..e9b22f929c 100644
@@ -76,6 +76,7 @@ struct PCMachineState {
 #define PC_MACHINE_VMPORT           "vmport"
 #define PC_MACHINE_SMM              "smm"
 #define PC_MACHINE_NVDIMM           "nvdimm"
+#define PC_MACHINE_NVDIMM_CAP       "nvdimm-cap"
 #define PC_MACHINE_SMBUS            "smbus"
 #define PC_MACHINE_SATA             "sata"
 #define PC_MACHINE_PIT              "pit"
include/hw/mem/nvdimm.h +5 -0
index 74c60332e1..3c82751bab 100644
@@ -134,6 +134,11 @@ struct AcpiNVDIMMState {
 
     /* the IO region used by OSPM to transfer control to QEMU. */
     MemoryRegion io_mr;
+
+    /*
+     * Platform capabilities, section 5.2.25.9 of ACPI 6.2 Errata A
+     */
+    int32_t capabilities;
 };
 typedef struct AcpiNVDIMMState AcpiNVDIMMState;
 
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm