From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: linux-nvdimm@lists.01.org
Subject: Re: [PATCH v2 1/4] acpi: nfit: Add support for detect platform CPU cache flush on power loss
Date: Tue, 30 Jan 2018 15:31:54 -0700 [thread overview]
Message-ID: <20180130223154.GA23836@linux.intel.com> (raw)
In-Reply-To: <151276680927.31888.15096916678580860198.stgit@djiang5-desk3.ch.intel.com>
On Fri, Dec 08, 2017 at 02:00:09PM -0700, Dave Jiang wrote:
> In ACPI 6.2a the platform capability structure has been added to the NFIT
> tables. That provides software the ability to determine whether a system
> supports the auto flushing of CPU caches on power loss. If the capability
> is supported, we do not need to do dax_write_cache(). Plumbing the path
dax_flush() ?
dax_write_cache() just sets or clears DAXDEV_WRITE_CACHE. dax_flush() is the
place where we check DAXDEV_WRITE_CACHE and avoid calling arch_wb_cache_pmem()
if the platform supports a flush-on-fail CPU cache.
> to set the property on per region from the NFTI tables.
NFIT
>
> This patch depends on the ACPI NFIT 6.2a platform capabilities support code
> in include/acpi/actbl1.h.
>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/acpi/nfit/core.c | 20 ++++++++++++++++++++
> drivers/acpi/nfit/nfit.h | 1 +
> drivers/nvdimm/pmem.c | 4 +++-
> drivers/nvdimm/region_devs.c | 1 +
> include/linux/libnvdimm.h | 5 +++++
> 5 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index ff2580e7611d..c08b3da61b93 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -838,6 +838,18 @@ static bool add_flush(struct acpi_nfit_desc *acpi_desc,
> return true;
> }
>
> +static bool add_platform_cap(struct acpi_nfit_desc *acpi_desc,
> + struct acpi_nfit_capabilities *pcap)
> +{
> + struct device *dev = acpi_desc->dev;
> + u8 mask;
'mask' cannot be a u8, else you'll lose all the upper bits when you compute
it. It needs to be a u32.
> +
> + mask = pcap->highest_capability - 1 + pcap->highest_capability;
This calculation is broken. Take the simplest case, highest_capability = 0.
This should translate into a mask of 0x1, so you only look at bit 0, but:
0 - 1 + 0 == -1
giving you a mask that includes all the bits. I think the mask you're looking
for is:
mask = (1 << (pcap->highest_capability + 1)) - 1;
> + acpi_desc->platform_cap = pcap->capabilities & (u32)mask;
> + dev_dbg(dev, "%s: cap: %#x\n", __func__, acpi_desc->platform_cap);
> + return true;
> +}
> +
> static void *add_table(struct acpi_nfit_desc *acpi_desc,
> struct nfit_table_prev *prev, void *table, const void *end)
> {
<>
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index 7fbc5c5dc8e1..13f2ed80899e 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -35,6 +35,7 @@
> #include "pmem.h"
> #include "pfn.h"
> #include "nd.h"
> +#include "nd-core.h"
>
> static struct device *to_dev(struct pmem_device *pmem)
> {
> @@ -334,7 +335,8 @@ static int pmem_attach_disk(struct device *dev,
> dev_warn(dev, "unable to guarantee persistence of writes\n");
> fua = 0;
> }
> - wbc = nvdimm_has_cache(nd_region);
> + wbc = nvdimm_has_cache(nd_region) &
I'm guessing you meant: &&
> + !test_bit(ND_REGION_PERSIST_CACHE, &nd_region->flags);
>
> if (!devm_request_mem_region(dev, res->start, resource_size(res),
> dev_name(&ndns->dev))) {
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index abaf38c61220..87e8cd10de05 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -994,6 +994,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
> dev->groups = ndr_desc->attr_groups;
> nd_region->ndr_size = resource_size(ndr_desc->res);
> nd_region->ndr_start = ndr_desc->res->start;
> +
Unrelated whitespace change.
> nd_device_register(dev);
>
> return nd_region;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2018-01-30 22:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-08 21:00 [PATCH v2 0/4] add support for platform persistence capabilities Dave Jiang
2017-12-08 21:00 ` [PATCH v2 1/4] acpi: nfit: Add support for detect platform CPU cache flush on power loss Dave Jiang
2018-01-30 22:31 ` Ross Zwisler [this message]
2017-12-08 21:00 ` [PATCH v2 2/4] acpi: nfit: add persistent memory control flag for nd_region Dave Jiang
2018-01-30 22:52 ` Ross Zwisler
2017-12-08 21:00 ` [PATCH v2 3/4] libnvdimm: expose platform persistence attribute " Dave Jiang
2018-01-30 22:52 ` Ross Zwisler
2017-12-08 21:00 ` [PATCH v2 4/4] nfit-test: Add platform cap support from ACPI 6.2a to test Dave Jiang
2018-01-30 22:52 ` Ross Zwisler
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=20180130223154.GA23836@linux.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-nvdimm@lists.01.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.