[PATCH] acpi, nfit: check for the correct event code in notifications
by Vishal Verma
Commit 209851649dc4 "acpi: nfit: Add support for hot-add" added
support for _FIT notifications, but it neglected to verify the
notification event code matches the one in the ACPI spec for
"NFIT Update". Currently there is only one code in the spec, but
once additional codes are added, older kernels (without this fix)
will misbehave by assuming all event notifications are for an
NFIT Update.
Fixes: 209851649dc4 ("acpi: nfit: Add support for hot-add")
Cc: <stable(a)vger.kernel.org>
Cc: <linux-acpi(a)vger.kernel.org>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Reported-by: Linda Knippers <linda.knippers(a)hpe.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
drivers/acpi/nfit/core.c | 3 +++
drivers/acpi/nfit/nfit.h | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 80cc7c0..4a363be 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -2681,6 +2681,9 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event)
dev_dbg(dev, "%s: event: %d\n", __func__, event);
+ if (event != NFIT_NOTIFY_UPDATE)
+ return;
+
device_lock(dev);
if (!dev->driver) {
/* dev->driver may be null if we're being removed */
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h
index e894ded..51d23f1 100644
--- a/drivers/acpi/nfit/nfit.h
+++ b/drivers/acpi/nfit/nfit.h
@@ -78,6 +78,10 @@ enum {
NFIT_ARS_TIMEOUT = 90,
};
+enum nfit_root_notifiers {
+ NFIT_NOTIFY_UPDATE = 0x80,
+};
+
struct nfit_spa {
struct list_head list;
struct nd_region *nd_region;
--
2.7.4
4 years, 4 months
[PATCH 1/2] x86: Set up resources correctly on Hyper-V Generation 2
by Matthew Wilcox
From: Matthew Wilcox <mawilcox(a)microsoft.com>
The Generation 2 Hyper-V virtual machine does not emulate PCI.
This check causes the call to pcibios_resource_survey() to be skipped,
and pcibios_resource_survey() calls e820_reserve_resources_late(), which
is where PMEM resources are added to the resource tree. With this patch,
the PMEM devices now show up.
Signed-off-by: Matthew Wilcox <mawilcox(a)microsoft.com>
---
arch/x86/pci/common.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 7b6a9d1..d39e799 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -516,11 +516,6 @@ void __init pcibios_set_cache_line_size(void)
int __init pcibios_init(void)
{
- if (!raw_pci_ops && !raw_pci_ext_ops) {
- printk(KERN_WARNING "PCI: System does not support PCI\n");
- return 0;
- }
-
pcibios_set_cache_line_size();
pcibios_resource_survey();
--
2.8.1
4 years, 5 months
[PATCH v2] libnvdimm: Fix nvdimm_probe error on NVDIMM-N
by Toshi Kani
'ndctl list --buses --dimms' does not list any NVDIMM-Ns since
they are considered as idle. ndctl checks if any driver is
attached to nmem device. nvdimm_probe() always fails in
nvdimm_init_nsarea() since NVDIMM-Ns do not implement optinal
ND_CMD_GET_CONFIG_DATA command.
Change nvdimm_probe() to accept the case that the CONFIG_DATA
command is not implemented for NVDIMM-Ns. The driver attaches
without ndd, which keeps it no-op to the device.
Reported-by: Brian Boylston <brian.boylston(a)hpe.com>
Signed-off-by: Toshi Kani <toshi.kani(a)hpe.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
---
v2:
- Fix failures in ndctl unit test suite. (Dan Williams)
- Change ENOENT to ENOTTY, and remove gotos. (Dan Williams)
---
drivers/nvdimm/dimm.c | 11 +++++++++++
drivers/nvdimm/dimm_devs.c | 28 +++++++++++++++-------------
drivers/nvdimm/nd.h | 1 +
3 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/drivers/nvdimm/dimm.c b/drivers/nvdimm/dimm.c
index 71d12bb..619834e 100644
--- a/drivers/nvdimm/dimm.c
+++ b/drivers/nvdimm/dimm.c
@@ -26,6 +26,14 @@ static int nvdimm_probe(struct device *dev)
struct nvdimm_drvdata *ndd;
int rc;
+ rc = nvdimm_check_config_data(dev);
+ if (rc) {
+ /* not required for non-aliased nvdimm, ex. NVDIMM-N */
+ if (rc == -ENOTTY)
+ rc = 0;
+ return rc;
+ }
+
ndd = kzalloc(sizeof(*ndd), GFP_KERNEL);
if (!ndd)
return -ENOMEM;
@@ -72,6 +80,9 @@ static int nvdimm_remove(struct device *dev)
{
struct nvdimm_drvdata *ndd = dev_get_drvdata(dev);
+ if (!ndd)
+ return 0;
+
nvdimm_bus_lock(dev);
dev_set_drvdata(dev, NULL);
nvdimm_bus_unlock(dev);
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index d9bba5e..c22244a 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -28,28 +28,30 @@ static DEFINE_IDA(dimm_ida);
* Retrieve bus and dimm handle and return if this bus supports
* get_config_data commands
*/
-static int __validate_dimm(struct nvdimm_drvdata *ndd)
+int nvdimm_check_config_data(struct device *dev)
{
- struct nvdimm *nvdimm;
-
- if (!ndd)
- return -EINVAL;
-
- nvdimm = to_nvdimm(ndd->dev);
+ struct nvdimm *nvdimm = to_nvdimm(dev);
- if (!nvdimm->cmd_mask)
- return -ENXIO;
- if (!test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask))
- return -ENXIO;
+ if (!nvdimm->cmd_mask ||
+ !test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask)) {
+ if (nvdimm->flags & NDD_ALIASING)
+ return -ENXIO;
+ else
+ return -ENOTTY;
+ }
return 0;
}
static int validate_dimm(struct nvdimm_drvdata *ndd)
{
- int rc = __validate_dimm(ndd);
+ int rc;
+
+ if (!ndd)
+ return -EINVAL;
- if (rc && ndd)
+ rc = nvdimm_check_config_data(ndd->dev);
+ if (rc)
dev_dbg(ndd->dev, "%pf: %s error: %d\n",
__builtin_return_address(0), __func__, rc);
return rc;
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 8024a0e..38d6f03 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -191,6 +191,7 @@ void nvdimm_exit(void);
void nd_region_exit(void);
struct nvdimm;
struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping);
+int nvdimm_check_config_data(struct device *dev);
int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd);
int nvdimm_init_config_data(struct nvdimm_drvdata *ndd);
int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
4 years, 5 months
[PATCH] acpi, nfit: fix acpi event notifications for nfit
by Vishal Verma
The nfit driver had an acpi event notification handler, but it never
would've worked because we weren't setting the
ACPI_DRIVER_ALL_NOTIFY_EVENTS flag in acpi_driver.
Cc: <stable(a)vger.kernel.org>
Cc: <linux-acpi(a)vger.kernel.org>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Xiao Guangrong <guangrong.xiao(a)linux.intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
drivers/acpi/nfit/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 80cc7c0..5d33d81 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -2731,6 +2731,7 @@ MODULE_DEVICE_TABLE(acpi, acpi_nfit_ids);
static struct acpi_driver acpi_nfit_driver = {
.name = KBUILD_MODNAME,
.ids = acpi_nfit_ids,
+ .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
.ops = {
.add = acpi_nfit_add,
.remove = acpi_nfit_remove,
--
2.7.4
4 years, 5 months
[PATCH 0/7] re-enable DAX PMD support
by Ross Zwisler
DAX PMDs have been disabled since Jan Kara introduced DAX radix tree based
locking. This series allows DAX PMDs to participate in the DAX radix tree
based locking scheme so that they can be re-enabled.
This series restores DAX PMD functionality back to what it was before it
was disabled. There is still a known issue between DAX PMDs and hole
punch, which I am currently working on and which I plan to address with a
separate series.
Ross Zwisler (7):
ext2: tell DAX the size of allocation holes
ext4: tell DAX the size of allocation holes
dax: remove buffer_size_valid()
dax: rename 'ret' to 'entry' in grab_mapping_entry
dax: lock based on slot instead of [mapping, index]
dax: re-enable DAX PMD support
dax: remove "depends on BROKEN" from FS_DAX_PMD
fs/Kconfig | 1 -
fs/dax.c | 301 ++++++++++++++++++++++++++--------------------------
fs/ext2/inode.c | 6 ++
fs/ext4/inode.c | 3 +
include/linux/dax.h | 30 +++++-
mm/filemap.c | 7 +-
6 files changed, 191 insertions(+), 157 deletions(-)
--
2.9.0
4 years, 5 months
[PATCH] ext4: allow DAX writeback for hole punch
by Ross Zwisler
Currently when doing a DAX hole punch with ext4 we fail to do a writeback.
This is because the logic around filemap_write_and_wait_range() in
ext4_punch_hole() only looks for dirty page cache pages in the radix tree,
not for dirty DAX exceptional entries.
Signed-off-by: Ross Zwisler <ross.zwisler(a)linux.intel.com>
---
I found this while testing my PMD patches
(https://lkml.org/lkml/2016/8/15/613), but this fix applies equally to the
4k-only case. I'm sending this separately from that series because I think
that this should probably be merged for v4.8 as it corrects an existing bug
and should have very low risk.
Regarding the other two supported DAX filesystems, XFS already properly
does this writeback and ext2 doesn't support hole punch so it doesn't have
to worry about this issue.
---
fs/ext4/inode.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3131747..8550416 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3890,7 +3890,7 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
}
/*
- * ext4_punch_hole: punches a hole in a file by releaseing the blocks
+ * ext4_punch_hole: punches a hole in a file by releasing the blocks
* associated with the given offset and length
*
* @inode: File inode
@@ -3919,7 +3919,9 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
* Write out all dirty pages to avoid race conditions
* Then release them.
*/
- if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
+ if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
+ ((!dax_mapping(mapping) && mapping->nrpages) ||
+ (dax_mapping(mapping) && mapping->nrexceptional))) {
ret = filemap_write_and_wait_range(mapping, offset,
offset + length - 1);
if (ret)
--
2.9.0
4 years, 5 months
[ndctl PATCH 0/8] ndctl: device-dax tests
by Dan Williams
- enable tests of the ndctl built-in commands to be authored in C rather
than Shell
- add apis for retrieving the region-seed and available size
- test the creation and destruction of device-dax instances, and that
destruction (region unbind) triggers unmap of current mappings.
---
Dan Williams (8):
ndctl: centralize libndctl context init across commands
libdaxctl: add daxctl_region_get_available_size()
libdaxctl: add daxctl_region_get_seed()
test: teach test/libndctl about device-dax seeds
test: refactor / export ndctl_get_test_dev()
test, create-namespace: reset global data
test: convert device-dax test from shell to C
test, device-dax: check mappings invalidated on namespace reconfiguration
daxctl/lib/libdaxctl-private.h | 3 +
daxctl/lib/libdaxctl.c | 77 ++++++++++++++++--
daxctl/lib/libdaxctl.sym | 7 ++
daxctl/libdaxctl.h | 4 +
ndctl/builtin-bat.c | 6 +
ndctl/builtin-create-nfit.c | 3 -
ndctl/builtin-help.c | 2
ndctl/builtin-list.c | 9 --
ndctl/builtin-read-labels.c | 9 --
ndctl/builtin-test.c | 8 +-
ndctl/builtin-xable-region.c | 17 +---
ndctl/builtin-xaction-namespace.c | 46 ++++++-----
ndctl/builtin-zero-labels.c | 9 --
ndctl/builtin.h | 29 +++----
ndctl/ndctl.c | 17 +++-
test.h | 17 ++--
test/Makefile.am | 13 +++
test/blk_namespaces.c | 24 +++---
test/dax-dev.c | 42 ++++++----
test/device-dax.c | 159 +++++++++++++++++++++++++++++++++----
test/device-dax.sh | 40 ---------
test/dpa-alloc.c | 19 ++--
test/libndctl.c | 33 ++++----
test/parent-uuid.c | 19 ++--
test/pmem_namespaces.c | 22 +++--
25 files changed, 406 insertions(+), 228 deletions(-)
delete mode 100755 test/device-dax.sh
4 years, 5 months
[PATCH 0/4] device-dax prepare for dynamic resize / allocate
by Dan Williams
In preparation for dynamic resize / allocation support:
- convert device-dax instances to reserve memory ranges from their
parent region
- produce a 'seed' device instance to accept new allocation requests
---
Dan Williams (4):
dax: check resource alignment at dax region/device create
dax: add region-available-size attribute
dax: convert devm_create_dax_dev to PTR_ERR
dax: register seed device
drivers/dax/dax.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++++----
drivers/dax/dax.h | 5 +
drivers/dax/pmem.c | 5 +
3 files changed, 196 insertions(+), 22 deletions(-)
4 years, 5 months
[PATCH] libnvdimm: Fix nvdimm_probe error on NVDIMM-N
by Toshi Kani
'ndctl list --buses --dimms' does not list any NVDIMM-Ns since
they are considered as idle. ndctl checks if any driver is
attached to nmem device. nvdimm_probe() always fails in
nvdimm_init_nsarea() since NVDIMM-Ns do not implement optinal
ND_CMD_GET_CONFIG_DATA command.
Change nvdimm_probe() to accept the case that the CONFIG_DATA
command is not implemented for NVDIMM-Ns. The driver attaches
without ndd, which keeps it no-op to the device.
Reported-by: Brian Boylston <brian.boylston(a)hpe.com>
Signed-off-by: Toshi Kani <toshi.kani(a)hpe.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
---
drivers/nvdimm/dimm.c | 10 ++++++++++
drivers/nvdimm/dimm_devs.c | 27 ++++++++++++++++-----------
drivers/nvdimm/nd.h | 1 +
3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/drivers/nvdimm/dimm.c b/drivers/nvdimm/dimm.c
index 71d12bb..07e09c2 100644
--- a/drivers/nvdimm/dimm.c
+++ b/drivers/nvdimm/dimm.c
@@ -26,6 +26,13 @@ static int nvdimm_probe(struct device *dev)
struct nvdimm_drvdata *ndd;
int rc;
+ rc = nvdimm_check_config_data(dev);
+ if (rc == -ENOENT)
+ /* not required for non-aliased nvdimm, ex. NVDIMM-N */
+ return 0;
+ else
+ return rc;
+
ndd = kzalloc(sizeof(*ndd), GFP_KERNEL);
if (!ndd)
return -ENOMEM;
@@ -72,6 +79,9 @@ static int nvdimm_remove(struct device *dev)
{
struct nvdimm_drvdata *ndd = dev_get_drvdata(dev);
+ if (!ndd)
+ return 0;
+
nvdimm_bus_lock(dev);
dev_set_drvdata(dev, NULL);
nvdimm_bus_unlock(dev);
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index d9bba5e..fee82d3 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -28,28 +28,33 @@ static DEFINE_IDA(dimm_ida);
* Retrieve bus and dimm handle and return if this bus supports
* get_config_data commands
*/
-static int __validate_dimm(struct nvdimm_drvdata *ndd)
+int nvdimm_check_config_data(struct device *dev)
{
- struct nvdimm *nvdimm;
-
- if (!ndd)
- return -EINVAL;
-
- nvdimm = to_nvdimm(ndd->dev);
+ struct nvdimm *nvdimm = to_nvdimm(dev);
if (!nvdimm->cmd_mask)
- return -ENXIO;
+ goto err;
if (!test_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm->cmd_mask))
- return -ENXIO;
+ goto err;
return 0;
+
+ err:
+ if (nvdimm->flags & NDD_ALIASING)
+ return -ENXIO;
+ else
+ return -ENOENT;
}
static int validate_dimm(struct nvdimm_drvdata *ndd)
{
- int rc = __validate_dimm(ndd);
+ int rc;
- if (rc && ndd)
+ if (!ndd)
+ return -EINVAL;
+
+ rc = nvdimm_check_config_data(ndd->dev);
+ if (rc)
dev_dbg(ndd->dev, "%pf: %s error: %d\n",
__builtin_return_address(0), __func__, rc);
return rc;
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 8024a0e..38d6f03 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -191,6 +191,7 @@ void nvdimm_exit(void);
void nd_region_exit(void);
struct nvdimm;
struct nvdimm_drvdata *to_ndd(struct nd_mapping *nd_mapping);
+int nvdimm_check_config_data(struct device *dev);
int nvdimm_init_nsarea(struct nvdimm_drvdata *ndd);
int nvdimm_init_config_data(struct nvdimm_drvdata *ndd);
int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset,
4 years, 5 months