libnvdimm for 4.13-rc2
* Fix handling of media errors that span a sector * Fix support of multiple namespaces in a libnvdimm region being in device-dax mode * Clean up the machine check notifier properly when the nfit driver fails to register * Address a static analysis (smatch) report in device-dax -----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJZcL/cAAoJEB7SkWpmfYgCJCMQAKwvhvauCQJnVgYjdd9/nANv r3jz+xgBhRVY4RzostkkQ1MQWx50G5KXhHhSjIz3GAztZb64THCi9k0XNW9oBwcv Go8/j0/th5iUEKmBs2WzIXOjbBvzC4IsT4hUHS0c66iLeEFggiYj78/CzqrJiH5f 85DsCXhgxxGJ70RtTa080Pocst9IY9Ut0OrLo8WMiDUGnDd4FCV4JJDgQ3aUlG12 nn8xwokPk0d+pgQy0iWghxKJ/zIpmE/rrPQFFVxaBR9IrOHEFwFWav2v6IwOuUEF ZK+ERiI+I07WPTZ9n8RBfu/aYlN/TKD33jDoZwkaNvJJptGdrpU/Y4aitQbXVxev M+tTQ0ggDMUHQ4Da8axu76zDlECqcou+/MgOwU2rYwW2DAOluGHlhje8rIdmQiOL nvzIa35xRD7eKVe6viEsKaNhCpsc8O/b4LIMXlKX+QmoSbvQCoOz0EDzcqT9oufe ItE5CFGx1IqQ4bQCgWiRop+Ly2vp4kTfLK2FNV0Zq+imaIdrVJxgUJP5GWH6yy/Z lQsaxzx8AZTN44Mns4SRxgJJp11fDBsqwPXG4hdY4GMUZG2hyscPt8rBNlHDOANf 2rhVPZbefAlv12WWehQ8JXk+/l0sNqxQJfz0kfG72i0Ll6Ua6Isqy7Zs0fFZXT0C CFrXq4FMB0D4pvFi6b5i =s1pb -----END PGP SIGNATURE----- Merge tag 'libnvdimm-fixes-4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm Pull libnvdimm fixes from Dan Williams: "A handful of small fixes for 4.13-rc2. Three of these fixes are tagged for -stable. They have all appeared in at least one -next release with no reported issues - Fix handling of media errors that span a sector - Fix support of multiple namespaces in a libnvdimm region being in device-dax mode - Clean up the machine check notifier properly when the nfit driver fails to register - Address a static analysis (smatch) report in device-dax" * tag 'libnvdimm-fixes-4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: device-dax: fix sysfs duplicate warnings MAINTAINERS: list drivers/acpi/nfit/ files for libnvdimm sub-system acpi/nfit: Fix memory corruption/Unregister mce decoder on failure device-dax: fix 'passing zero to ERR_PTR()' warning libnvdimm: fix badblock range handling of ARS range
This commit is contained in:
commit
ae1c908517
|
@ -7730,6 +7730,7 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/
|
|||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git
|
||||
S: Supported
|
||||
F: drivers/nvdimm/*
|
||||
F: drivers/acpi/nfit/*
|
||||
F: include/linux/nd.h
|
||||
F: include/linux/libnvdimm.h
|
||||
F: include/uapi/linux/ndctl.h
|
||||
|
@ -7741,7 +7742,6 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/
|
|||
S: Supported
|
||||
F: drivers/nvdimm/blk.c
|
||||
F: drivers/nvdimm/region_devs.c
|
||||
F: drivers/acpi/nfit*
|
||||
|
||||
LIBNVDIMM BTT: BLOCK TRANSLATION TABLE
|
||||
M: Vishal Verma <vishal.l.verma@intel.com>
|
||||
|
|
|
@ -3160,6 +3160,8 @@ static struct acpi_driver acpi_nfit_driver = {
|
|||
|
||||
static __init int nfit_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40);
|
||||
BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 56);
|
||||
BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48);
|
||||
|
@ -3187,8 +3189,14 @@ static __init int nfit_init(void)
|
|||
return -ENOMEM;
|
||||
|
||||
nfit_mce_register();
|
||||
ret = acpi_bus_register_driver(&acpi_nfit_driver);
|
||||
if (ret) {
|
||||
nfit_mce_unregister();
|
||||
destroy_workqueue(nfit_wq);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
return acpi_bus_register_driver(&acpi_nfit_driver);
|
||||
}
|
||||
|
||||
static __exit void nfit_exit(void)
|
||||
|
|
|
@ -21,5 +21,5 @@ struct dax_region *alloc_dax_region(struct device *parent,
|
|||
int region_id, struct resource *res, unsigned int align,
|
||||
void *addr, unsigned long flags);
|
||||
struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
||||
struct resource *res, int count);
|
||||
int id, struct resource *res, int count);
|
||||
#endif /* __DEVICE_DAX_H__ */
|
||||
|
|
|
@ -529,6 +529,7 @@ static void dev_dax_release(struct device *dev)
|
|||
struct dax_region *dax_region = dev_dax->region;
|
||||
struct dax_device *dax_dev = dev_dax->dax_dev;
|
||||
|
||||
if (dev_dax->id >= 0)
|
||||
ida_simple_remove(&dax_region->ida, dev_dax->id);
|
||||
dax_region_put(dax_region);
|
||||
put_dax(dax_dev);
|
||||
|
@ -559,7 +560,7 @@ static void unregister_dev_dax(void *dev)
|
|||
}
|
||||
|
||||
struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
||||
struct resource *res, int count)
|
||||
int id, struct resource *res, int count)
|
||||
{
|
||||
struct device *parent = dax_region->dev;
|
||||
struct dax_device *dax_dev;
|
||||
|
@ -567,7 +568,10 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
|||
struct inode *inode;
|
||||
struct device *dev;
|
||||
struct cdev *cdev;
|
||||
int rc = 0, i;
|
||||
int rc, i;
|
||||
|
||||
if (!count)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
dev_dax = kzalloc(sizeof(*dev_dax) + sizeof(*res) * count, GFP_KERNEL);
|
||||
if (!dev_dax)
|
||||
|
@ -587,19 +591,27 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
|||
if (i < count)
|
||||
goto err_id;
|
||||
|
||||
dev_dax->id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL);
|
||||
if (dev_dax->id < 0) {
|
||||
rc = dev_dax->id;
|
||||
if (id < 0) {
|
||||
id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL);
|
||||
dev_dax->id = id;
|
||||
if (id < 0) {
|
||||
rc = id;
|
||||
goto err_id;
|
||||
}
|
||||
} else {
|
||||
/* region provider owns @id lifetime */
|
||||
dev_dax->id = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* No 'host' or dax_operations since there is no access to this
|
||||
* device outside of mmap of the resulting character device.
|
||||
*/
|
||||
dax_dev = alloc_dax(dev_dax, NULL, NULL);
|
||||
if (!dax_dev)
|
||||
if (!dax_dev) {
|
||||
rc = -ENOMEM;
|
||||
goto err_dax;
|
||||
}
|
||||
|
||||
/* from here on we're committed to teardown via dax_dev_release() */
|
||||
dev = &dev_dax->dev;
|
||||
|
@ -620,7 +632,7 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
|||
dev->parent = parent;
|
||||
dev->groups = dax_attribute_groups;
|
||||
dev->release = dev_dax_release;
|
||||
dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id);
|
||||
dev_set_name(dev, "dax%d.%d", dax_region->id, id);
|
||||
|
||||
rc = cdev_device_add(cdev, dev);
|
||||
if (rc) {
|
||||
|
@ -636,6 +648,7 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region,
|
|||
return dev_dax;
|
||||
|
||||
err_dax:
|
||||
if (dev_dax->id >= 0)
|
||||
ida_simple_remove(&dax_region->ida, dev_dax->id);
|
||||
err_id:
|
||||
kfree(dev_dax);
|
||||
|
|
|
@ -58,13 +58,12 @@ static void dax_pmem_percpu_kill(void *data)
|
|||
|
||||
static int dax_pmem_probe(struct device *dev)
|
||||
{
|
||||
int rc;
|
||||
void *addr;
|
||||
struct resource res;
|
||||
int rc, id, region_id;
|
||||
struct nd_pfn_sb *pfn_sb;
|
||||
struct dev_dax *dev_dax;
|
||||
struct dax_pmem *dax_pmem;
|
||||
struct nd_region *nd_region;
|
||||
struct nd_namespace_io *nsio;
|
||||
struct dax_region *dax_region;
|
||||
struct nd_namespace_common *ndns;
|
||||
|
@ -123,14 +122,17 @@ static int dax_pmem_probe(struct device *dev)
|
|||
/* adjust the dax_region resource to the start of data */
|
||||
res.start += le64_to_cpu(pfn_sb->dataoff);
|
||||
|
||||
nd_region = to_nd_region(dev->parent);
|
||||
dax_region = alloc_dax_region(dev, nd_region->id, &res,
|
||||
rc = sscanf(dev_name(&ndns->dev), "namespace%d.%d", ®ion_id, &id);
|
||||
if (rc != 2)
|
||||
return -EINVAL;
|
||||
|
||||
dax_region = alloc_dax_region(dev, region_id, &res,
|
||||
le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP);
|
||||
if (!dax_region)
|
||||
return -ENOMEM;
|
||||
|
||||
/* TODO: support for subdividing a dax region... */
|
||||
dev_dax = devm_create_dev_dax(dax_region, &res, 1);
|
||||
dev_dax = devm_create_dev_dax(dax_region, id, &res, 1);
|
||||
|
||||
/* child dev_dax instances now own the lifetime of the dax_region */
|
||||
dax_region_put(dax_region);
|
||||
|
|
|
@ -421,14 +421,15 @@ static void set_badblock(struct badblocks *bb, sector_t s, int num)
|
|||
static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len)
|
||||
{
|
||||
const unsigned int sector_size = 512;
|
||||
sector_t start_sector;
|
||||
sector_t start_sector, end_sector;
|
||||
u64 num_sectors;
|
||||
u32 rem;
|
||||
|
||||
start_sector = div_u64(ns_offset, sector_size);
|
||||
num_sectors = div_u64_rem(len, sector_size, &rem);
|
||||
end_sector = div_u64_rem(ns_offset + len, sector_size, &rem);
|
||||
if (rem)
|
||||
num_sectors++;
|
||||
end_sector++;
|
||||
num_sectors = end_sector - start_sector;
|
||||
|
||||
if (unlikely(num_sectors > (u64)INT_MAX)) {
|
||||
u64 remaining = num_sectors;
|
||||
|
|
Loading…
Reference in New Issue