diff mbox

[v2,4/4] nfit-test: Add platform cap support from ACPI 6.2a to test

Message ID 151276682564.31888.9763911491092344231.stgit@djiang5-desk3.ch.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dave Jiang Dec. 8, 2017, 9 p.m. UTC
Adding NFIT platform capabilities sub table in nfit_test simulated ACPI
NFIT table. Only the first NFIT table is added with the capability
sub-table.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 tools/testing/nvdimm/test/nfit.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Ross Zwisler Jan. 30, 2018, 10:52 p.m. UTC | #1
On Fri, Dec 08, 2017 at 02:00:25PM -0700, Dave Jiang wrote:
> Adding NFIT platform capabilities sub table in nfit_test simulated ACPI
> NFIT table. Only the first NFIT table is added with the capability
> sub-table.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  tools/testing/nvdimm/test/nfit.c |   11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
> index 7217b2b953b5..8a16f90a9573 100644
> --- a/tools/testing/nvdimm/test/nfit.c
> +++ b/tools/testing/nvdimm/test/nfit.c
> @@ -993,6 +993,7 @@ static void nfit_test0_setup(struct nfit_test *t)
>  	struct acpi_nfit_control_region *dcr;
>  	struct acpi_nfit_data_region *bdw;
>  	struct acpi_nfit_flush_address *flush;
> +	struct acpi_nfit_capabilities *pcap;
>  	unsigned int offset, i;
>  
>  	/*
> @@ -1500,8 +1501,16 @@ static void nfit_test0_setup(struct nfit_test *t)
>  	for (i = 0; i < NUM_HINTS; i++)
>  		flush->hint_address[i] = t->flush_dma[3] + i * sizeof(u64);
>  
> +	/* platform capabilities */
> +	pcap = nfit_buf + offset + flush_hint_size * 4;
> +	pcap->header.type = ACPI_NFIT_TYPE_CAPABILITIES;
> +	pcap->header.length = sizeof(*pcap);
> +	pcap->highest_capability = BIT(2);
> +	pcap->capabilities = ACPI_NFIT_CAPABILITY_CACHE_FLUSH |
> +		ACPI_NFIT_CAPABILITY_MEM_FLUSH;
> +
>  	if (t->setup_hotplug) {
> -		offset = offset + flush_hint_size * 4;
> +		offset = offset + sizeof(*pcap);

You still need to increase the offset by flush_hint_size*4, in addition to
sizeof(*pcap):

	offset = offset + flush_hint_size * 4 + sizeof(*pcap);

Also, you need to increase the size of the memory allocation for t->nfit_buf
in nfit_test_alloc() by adding in a sizeof(struct acpi_nfit_capabilities) to
the calculation of nfit_size.  Otherwise you'll increment offset off the end
of nfit_buf in nfit_test0_setup().

>  		/* dcr-descriptor4: blk */
>  		dcr = nfit_buf + offset;
>  		dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
> 
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
diff mbox

Patch

diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 7217b2b953b5..8a16f90a9573 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -993,6 +993,7 @@  static void nfit_test0_setup(struct nfit_test *t)
 	struct acpi_nfit_control_region *dcr;
 	struct acpi_nfit_data_region *bdw;
 	struct acpi_nfit_flush_address *flush;
+	struct acpi_nfit_capabilities *pcap;
 	unsigned int offset, i;
 
 	/*
@@ -1500,8 +1501,16 @@  static void nfit_test0_setup(struct nfit_test *t)
 	for (i = 0; i < NUM_HINTS; i++)
 		flush->hint_address[i] = t->flush_dma[3] + i * sizeof(u64);
 
+	/* platform capabilities */
+	pcap = nfit_buf + offset + flush_hint_size * 4;
+	pcap->header.type = ACPI_NFIT_TYPE_CAPABILITIES;
+	pcap->header.length = sizeof(*pcap);
+	pcap->highest_capability = BIT(2);
+	pcap->capabilities = ACPI_NFIT_CAPABILITY_CACHE_FLUSH |
+		ACPI_NFIT_CAPABILITY_MEM_FLUSH;
+
 	if (t->setup_hotplug) {
-		offset = offset + flush_hint_size * 4;
+		offset = offset + sizeof(*pcap);
 		/* dcr-descriptor4: blk */
 		dcr = nfit_buf + offset;
 		dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;