[PATCH] device-dax: remove redundant __func__ in dev_dbg
by Dan Williams
Dynamic debug can be instructed to add the function name to the debug
output using the +f switch, so there is no need for the dax modules to
do it again. If a user decides to add the +f switch for the dax modules'
dynamic debug this results in double prints of the function name.
Reported-by: Johannes Thumshirn <jthumshirn(a)suse.de>
Reported-by: Ross Zwisler <ross.zwisler(a)linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
drivers/dax/device.c | 38 +++++++++++++++++---------------------
drivers/dax/pmem.c | 6 +++---
2 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/drivers/dax/device.c b/drivers/dax/device.c
index 2137dbc29877..37be5a306c8f 100644
--- a/drivers/dax/device.c
+++ b/drivers/dax/device.c
@@ -257,8 +257,8 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
dax_region = dev_dax->region;
if (dax_region->align > PAGE_SIZE) {
- dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n",
- __func__, dax_region->align, fault_size);
+ dev_dbg(dev, "alignment (%#x) > fault size (%#x)\n",
+ dax_region->align, fault_size);
return VM_FAULT_SIGBUS;
}
@@ -267,8 +267,7 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
phys = dax_pgoff_to_phys(dev_dax, vmf->pgoff, PAGE_SIZE);
if (phys == -1) {
- dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__,
- vmf->pgoff);
+ dev_dbg(dev, "pgoff_to_phys(%#lx) failed\n", vmf->pgoff);
return VM_FAULT_SIGBUS;
}
@@ -299,14 +298,14 @@ static int __dev_dax_pmd_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
dax_region = dev_dax->region;
if (dax_region->align > PMD_SIZE) {
- dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n",
- __func__, dax_region->align, fault_size);
+ dev_dbg(dev, "alignment (%#x) > fault size (%#x)\n",
+ dax_region->align, fault_size);
return VM_FAULT_SIGBUS;
}
/* dax pmd mappings require pfn_t_devmap() */
if ((dax_region->pfn_flags & (PFN_DEV|PFN_MAP)) != (PFN_DEV|PFN_MAP)) {
- dev_dbg(dev, "%s: region lacks devmap flags\n", __func__);
+ dev_dbg(dev, "region lacks devmap flags\n");
return VM_FAULT_SIGBUS;
}
@@ -323,8 +322,7 @@ static int __dev_dax_pmd_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
pgoff = linear_page_index(vmf->vma, pmd_addr);
phys = dax_pgoff_to_phys(dev_dax, pgoff, PMD_SIZE);
if (phys == -1) {
- dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__,
- pgoff);
+ dev_dbg(dev, "pgoff_to_phys(%#lx) failed\n", pgoff);
return VM_FAULT_SIGBUS;
}
@@ -351,14 +349,14 @@ static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
dax_region = dev_dax->region;
if (dax_region->align > PUD_SIZE) {
- dev_dbg(dev, "%s: alignment (%#x) > fault size (%#x)\n",
- __func__, dax_region->align, fault_size);
+ dev_dbg(dev, "alignment (%#x) > fault size (%#x)\n",
+ dax_region->align, fault_size);
return VM_FAULT_SIGBUS;
}
/* dax pud mappings require pfn_t_devmap() */
if ((dax_region->pfn_flags & (PFN_DEV|PFN_MAP)) != (PFN_DEV|PFN_MAP)) {
- dev_dbg(dev, "%s: region lacks devmap flags\n", __func__);
+ dev_dbg(dev, "region lacks devmap flags\n");
return VM_FAULT_SIGBUS;
}
@@ -375,8 +373,7 @@ static int __dev_dax_pud_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
pgoff = linear_page_index(vmf->vma, pud_addr);
phys = dax_pgoff_to_phys(dev_dax, pgoff, PUD_SIZE);
if (phys == -1) {
- dev_dbg(dev, "%s: pgoff_to_phys(%#lx) failed\n", __func__,
- pgoff);
+ dev_dbg(dev, "pgoff_to_phys(%#lx) failed\n", pgoff);
return VM_FAULT_SIGBUS;
}
@@ -399,9 +396,8 @@ static int dev_dax_huge_fault(struct vm_fault *vmf,
struct file *filp = vmf->vma->vm_file;
struct dev_dax *dev_dax = filp->private_data;
- dev_dbg(&dev_dax->dev, "%s: %s: %s (%#lx - %#lx) size = %d\n", __func__,
- current->comm, (vmf->flags & FAULT_FLAG_WRITE)
- ? "write" : "read",
+ dev_dbg(&dev_dax->dev, "%s: %s (%#lx - %#lx) size = %d\n", current->comm,
+ (vmf->flags & FAULT_FLAG_WRITE) ? "write" : "read",
vmf->vma->vm_start, vmf->vma->vm_end, pe_size);
id = dax_read_lock();
@@ -450,7 +446,7 @@ static int dax_mmap(struct file *filp, struct vm_area_struct *vma)
struct dev_dax *dev_dax = filp->private_data;
int rc, id;
- dev_dbg(&dev_dax->dev, "%s\n", __func__);
+ dev_dbg(&dev_dax->dev, "trace\n");
/*
* We lock to check dax_dev liveness and will re-check at
@@ -508,7 +504,7 @@ static int dax_open(struct inode *inode, struct file *filp)
struct inode *__dax_inode = dax_inode(dax_dev);
struct dev_dax *dev_dax = dax_get_private(dax_dev);
- dev_dbg(&dev_dax->dev, "%s\n", __func__);
+ dev_dbg(&dev_dax->dev, "trace\n");
inode->i_mapping = __dax_inode->i_mapping;
inode->i_mapping->host = __dax_inode;
filp->f_mapping = inode->i_mapping;
@@ -523,7 +519,7 @@ static int dax_release(struct inode *inode, struct file *filp)
{
struct dev_dax *dev_dax = filp->private_data;
- dev_dbg(&dev_dax->dev, "%s\n", __func__);
+ dev_dbg(&dev_dax->dev, "trace\n");
return 0;
}
@@ -565,7 +561,7 @@ static void unregister_dev_dax(void *dev)
struct inode *inode = dax_inode(dax_dev);
struct cdev *cdev = inode->i_cdev;
- dev_dbg(dev, "%s\n", __func__);
+ dev_dbg(dev, "trace\n");
kill_dev_dax(dev_dax);
cdev_device_del(cdev, dev);
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c
index 31b6ecce4c64..f7c0137e9325 100644
--- a/drivers/dax/pmem.c
+++ b/drivers/dax/pmem.c
@@ -34,7 +34,7 @@ static void dax_pmem_percpu_release(struct percpu_ref *ref)
{
struct dax_pmem *dax_pmem = to_dax_pmem(ref);
- dev_dbg(dax_pmem->dev, "%s\n", __func__);
+ dev_dbg(dax_pmem->dev, "trace\n");
complete(&dax_pmem->cmp);
}
@@ -43,7 +43,7 @@ static void dax_pmem_percpu_exit(void *data)
struct percpu_ref *ref = data;
struct dax_pmem *dax_pmem = to_dax_pmem(ref);
- dev_dbg(dax_pmem->dev, "%s\n", __func__);
+ dev_dbg(dax_pmem->dev, "trace\n");
wait_for_completion(&dax_pmem->cmp);
percpu_ref_exit(ref);
}
@@ -53,7 +53,7 @@ static void dax_pmem_percpu_kill(void *data)
struct percpu_ref *ref = data;
struct dax_pmem *dax_pmem = to_dax_pmem(ref);
- dev_dbg(dax_pmem->dev, "%s\n", __func__);
+ dev_dbg(dax_pmem->dev, "trace\n");
percpu_ref_kill(ref);
}
4 years, 3 months
[PATCH] acpi, nfit: remove redundant __func__ in dev_dbg
by Johannes Thumshirn
Dynamic debug can be instructed to add the function name to the debug
output using the +f switch, so there is no need for the nfit module to
do it again. If a user decides to add the +f switch for nfit's dynamic
debug this results in double prints of the function name like the
following:
[ 2391.935383] acpi_nfit_ctl: nfit ACPI0012:00: acpi_nfit_ctl:nmem8 cmd: 10: func: 1 input length: 0
Thus remove the stray __func__ printing.
Signed-off-by: Johannes Thumshirn <jthumshirn(a)suse.de>
---
drivers/acpi/nfit/core.c | 75 +++++++++++++++++++++++-------------------------
1 file changed, 36 insertions(+), 39 deletions(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index bbe48ad20886..39ad06143e78 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -476,8 +476,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
in_buf.buffer.length = call_pkg->nd_size_in;
}
- dev_dbg(dev, "%s:%s cmd: %d: func: %d input length: %d\n",
- __func__, dimm_name, cmd, func, in_buf.buffer.length);
+ dev_dbg(dev, "%s cmd: %d: func: %d input length: %d\n",
+ dimm_name, cmd, func, in_buf.buffer.length);
print_hex_dump_debug("nvdimm in ", DUMP_PREFIX_OFFSET, 4, 4,
in_buf.buffer.pointer,
min_t(u32, 256, in_buf.buffer.length), true);
@@ -506,8 +506,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
}
if (!out_obj) {
- dev_dbg(dev, "%s:%s _DSM failed cmd: %s\n", __func__, dimm_name,
- cmd_name);
+ dev_dbg(dev, "%s _DSM failed cmd: %s\n", dimm_name, cmd_name);
return -EINVAL;
}
@@ -528,13 +527,13 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
}
if (out_obj->package.type != ACPI_TYPE_BUFFER) {
- dev_dbg(dev, "%s:%s unexpected output object type cmd: %s type: %d\n",
- __func__, dimm_name, cmd_name, out_obj->type);
+ dev_dbg(dev, "%s unexpected output object type cmd: %s type: %d\n",
+ dimm_name, cmd_name, out_obj->type);
rc = -EINVAL;
goto out;
}
- dev_dbg(dev, "%s:%s cmd: %s output length: %d\n", __func__, dimm_name,
+ dev_dbg(dev, "%s cmd: %s output length: %d\n", dimm_name,
cmd_name, out_obj->buffer.length);
print_hex_dump_debug(cmd_name, DUMP_PREFIX_OFFSET, 4, 4,
out_obj->buffer.pointer,
@@ -546,14 +545,14 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
out_obj->buffer.length - offset);
if (offset + out_size > out_obj->buffer.length) {
- dev_dbg(dev, "%s:%s output object underflow cmd: %s field: %d\n",
- __func__, dimm_name, cmd_name, i);
+ dev_dbg(dev, "%s output object underflow cmd: %s field: %d\n",
+ dimm_name, cmd_name, i);
break;
}
if (in_buf.buffer.length + offset + out_size > buf_len) {
- dev_dbg(dev, "%s:%s output overrun cmd: %s field: %d\n",
- __func__, dimm_name, cmd_name, i);
+ dev_dbg(dev, "%s output overrun cmd: %s field: %d\n",
+ dimm_name, cmd_name, i);
rc = -ENXIO;
goto out;
}
@@ -655,7 +654,7 @@ static bool add_spa(struct acpi_nfit_desc *acpi_desc,
INIT_LIST_HEAD(&nfit_spa->list);
memcpy(nfit_spa->spa, spa, sizeof(*spa));
list_add_tail(&nfit_spa->list, &acpi_desc->spas);
- dev_dbg(dev, "%s: spa index: %d type: %s\n", __func__,
+ dev_dbg(dev, "spa index: %d type: %s\n",
spa->range_index,
spa_type_name(nfit_spa_type(spa)));
return true;
@@ -684,8 +683,8 @@ static bool add_memdev(struct acpi_nfit_desc *acpi_desc,
INIT_LIST_HEAD(&nfit_memdev->list);
memcpy(nfit_memdev->memdev, memdev, sizeof(*memdev));
list_add_tail(&nfit_memdev->list, &acpi_desc->memdevs);
- dev_dbg(dev, "%s: memdev handle: %#x spa: %d dcr: %d flags: %#x\n",
- __func__, memdev->device_handle, memdev->range_index,
+ dev_dbg(dev, "memdev handle: %#x spa: %d dcr: %d flags: %#x\n",
+ memdev->device_handle, memdev->range_index,
memdev->region_index, memdev->flags);
return true;
}
@@ -727,7 +726,7 @@ static bool add_dcr(struct acpi_nfit_desc *acpi_desc,
INIT_LIST_HEAD(&nfit_dcr->list);
memcpy(nfit_dcr->dcr, dcr, sizeof_dcr(dcr));
list_add_tail(&nfit_dcr->list, &acpi_desc->dcrs);
- dev_dbg(dev, "%s: dcr index: %d windows: %d\n", __func__,
+ dev_dbg(dev, "dcr index: %d windows: %d\n",
dcr->region_index, dcr->windows);
return true;
}
@@ -754,7 +753,7 @@ static bool add_bdw(struct acpi_nfit_desc *acpi_desc,
INIT_LIST_HEAD(&nfit_bdw->list);
memcpy(nfit_bdw->bdw, bdw, sizeof(*bdw));
list_add_tail(&nfit_bdw->list, &acpi_desc->bdws);
- dev_dbg(dev, "%s: bdw dcr: %d windows: %d\n", __func__,
+ dev_dbg(dev, "bdw dcr: %d windows: %d\n",
bdw->region_index, bdw->windows);
return true;
}
@@ -793,7 +792,7 @@ static bool add_idt(struct acpi_nfit_desc *acpi_desc,
INIT_LIST_HEAD(&nfit_idt->list);
memcpy(nfit_idt->idt, idt, sizeof_idt(idt));
list_add_tail(&nfit_idt->list, &acpi_desc->idts);
- dev_dbg(dev, "%s: idt index: %d num_lines: %d\n", __func__,
+ dev_dbg(dev, "idt index: %d num_lines: %d\n",
idt->interleave_index, idt->line_count);
return true;
}
@@ -833,7 +832,7 @@ static bool add_flush(struct acpi_nfit_desc *acpi_desc,
INIT_LIST_HEAD(&nfit_flush->list);
memcpy(nfit_flush->flush, flush, sizeof_flush(flush));
list_add_tail(&nfit_flush->list, &acpi_desc->flushes);
- dev_dbg(dev, "%s: nfit_flush handle: %d hint_count: %d\n", __func__,
+ dev_dbg(dev, "nfit_flush handle: %d hint_count: %d\n",
flush->device_handle, flush->hint_count);
return true;
}
@@ -846,7 +845,7 @@ static bool add_platform_cap(struct acpi_nfit_desc *acpi_desc,
mask = (1 << (pcap->highest_capability + 1)) - 1;
acpi_desc->platform_cap = pcap->capabilities & mask;
- dev_dbg(dev, "%s: cap: %#x\n", __func__, acpi_desc->platform_cap);
+ dev_dbg(dev, "cap: %#x\n", acpi_desc->platform_cap);
return true;
}
@@ -893,7 +892,7 @@ static void *add_table(struct acpi_nfit_desc *acpi_desc,
return err;
break;
case ACPI_NFIT_TYPE_SMBIOS:
- dev_dbg(dev, "%s: smbios\n", __func__);
+ dev_dbg(dev, "smbios\n");
break;
case ACPI_NFIT_TYPE_CAPABILITIES:
if (!add_platform_cap(acpi_desc, table))
@@ -1621,7 +1620,7 @@ void __acpi_nvdimm_notify(struct device *dev, u32 event)
struct nfit_mem *nfit_mem;
struct acpi_nfit_desc *acpi_desc;
- dev_dbg(dev->parent, "%s: %s: event: %d\n", dev_name(dev), __func__,
+ dev_dbg(dev->parent, "%s: event: %d\n", dev_name(dev),
event);
if (event != NFIT_NOTIFY_DIMM_HEALTH) {
@@ -2338,7 +2337,7 @@ static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus,
nvdimm = nd_blk_region_to_dimm(ndbr);
nfit_mem = nvdimm_provider_data(nvdimm);
if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) {
- dev_dbg(dev, "%s: missing%s%s%s\n", __func__,
+ dev_dbg(dev, "missing%s%s%s\n",
nfit_mem ? "" : " nfit_mem",
(nfit_mem && nfit_mem->dcr) ? "" : " dcr",
(nfit_mem && nfit_mem->bdw) ? "" : " bdw");
@@ -2357,7 +2356,7 @@ static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus,
mmio->addr.base = devm_nvdimm_memremap(dev, nfit_mem->spa_bdw->address,
nfit_mem->spa_bdw->length, nd_blk_memremap_flags(ndbr));
if (!mmio->addr.base) {
- dev_dbg(dev, "%s: %s failed to map bdw\n", __func__,
+ dev_dbg(dev, "%s failed to map bdw\n",
nvdimm_name(nvdimm));
return -ENOMEM;
}
@@ -2368,8 +2367,8 @@ static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus,
rc = nfit_blk_init_interleave(mmio, nfit_mem->idt_bdw,
nfit_mem->memdev_bdw->interleave_ways);
if (rc) {
- dev_dbg(dev, "%s: %s failed to init bdw interleave\n",
- __func__, nvdimm_name(nvdimm));
+ dev_dbg(dev, "%s failed to init bdw interleave\n",
+ nvdimm_name(nvdimm));
return rc;
}
@@ -2380,7 +2379,7 @@ static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus,
mmio->addr.base = devm_nvdimm_ioremap(dev, nfit_mem->spa_dcr->address,
nfit_mem->spa_dcr->length);
if (!mmio->addr.base) {
- dev_dbg(dev, "%s: %s failed to map dcr\n", __func__,
+ dev_dbg(dev, "%s failed to map dcr\n",
nvdimm_name(nvdimm));
return -ENOMEM;
}
@@ -2391,15 +2390,15 @@ static int acpi_nfit_blk_region_enable(struct nvdimm_bus *nvdimm_bus,
rc = nfit_blk_init_interleave(mmio, nfit_mem->idt_dcr,
nfit_mem->memdev_dcr->interleave_ways);
if (rc) {
- dev_dbg(dev, "%s: %s failed to init dcr interleave\n",
- __func__, nvdimm_name(nvdimm));
+ dev_dbg(dev, "%s failed to init dcr interleave\n",
+ nvdimm_name(nvdimm));
return rc;
}
rc = acpi_nfit_blk_get_flags(nd_desc, nvdimm, nfit_blk);
if (rc < 0) {
- dev_dbg(dev, "%s: %s failed get DIMM flags\n",
- __func__, nvdimm_name(nvdimm));
+ dev_dbg(dev, "%s failed get DIMM flags\n",
+ nvdimm_name(nvdimm));
return rc;
}
@@ -2655,8 +2654,7 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
return 0;
if (spa->range_index == 0 && !nfit_spa_is_virtual(spa)) {
- dev_dbg(acpi_desc->dev, "%s: detected invalid spa index\n",
- __func__);
+ dev_dbg(acpi_desc->dev, "detected invalid spa index\n");
return 0;
}
@@ -3142,8 +3140,7 @@ int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, void *data, acpi_size sz)
data = add_table(acpi_desc, &prev, data, end);
if (IS_ERR(data)) {
- dev_dbg(dev, "%s: nfit table parsing error: %ld\n", __func__,
- PTR_ERR(data));
+ dev_dbg(dev, "nfit table parsing error: %ld\n", PTR_ERR(data));
rc = PTR_ERR(data);
goto out_unlock;
}
@@ -3259,7 +3256,7 @@ int acpi_nfit_ars_rescan(struct acpi_nfit_desc *acpi_desc, u8 flags)
}
acpi_desc->ars_start_flags = flags;
queue_work(nfit_wq, &acpi_desc->work);
- dev_dbg(dev, "%s: ars_scan triggered\n", __func__);
+ dev_dbg(dev, "ars_scan triggered\n");
mutex_unlock(&acpi_desc->init_mutex);
return 0;
@@ -3366,8 +3363,8 @@ static int acpi_nfit_add(struct acpi_device *adev)
rc = acpi_nfit_init(acpi_desc, obj->buffer.pointer,
obj->buffer.length);
else
- dev_dbg(dev, "%s invalid type %d, ignoring _FIT\n",
- __func__, (int) obj->type);
+ dev_dbg(dev, "invalid type %d, ignoring _FIT\n",
+ (int) obj->type);
kfree(buf.pointer);
} else
/* skip over the lead-in header table */
@@ -3396,7 +3393,7 @@ static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle)
if (!dev->driver) {
/* dev->driver may be null if we're being removed */
- dev_dbg(dev, "%s: no driver found for dev\n", __func__);
+ dev_dbg(dev, "no driver found for dev\n");
return;
}
@@ -3442,7 +3439,7 @@ static void acpi_nfit_uc_error_notify(struct device *dev, acpi_handle handle)
void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event)
{
- dev_dbg(dev, "%s: event: 0x%x\n", __func__, event);
+ dev_dbg(dev, "event: 0x%x\n", event);
switch (event) {
case NFIT_NOTIFY_UPDATE:
--
2.13.6
4 years, 3 months
[PATCH v3 1/2] ndctl: add check for update firmware supported
by Dave Jiang
Adding generic and intel support function to allow check if update firmware
is supported by the kernel.
Signed-off-by: Dave Jiang <dave.jiang(a)intel.com>
Reviewed-by: Dan Williams <dan.j.williams(a)intel.com>
---
ndctl/lib/firmware.c | 11 +++++++++++
ndctl/lib/intel.c | 24 ++++++++++++++++++++++++
ndctl/lib/libndctl.sym | 1 +
ndctl/lib/private.h | 1 +
ndctl/libndctl.h | 1 +
ndctl/update.c | 13 +++++++++++++
6 files changed, 51 insertions(+)
diff --git a/ndctl/lib/firmware.c b/ndctl/lib/firmware.c
index f6deec5d..277b5399 100644
--- a/ndctl/lib/firmware.c
+++ b/ndctl/lib/firmware.c
@@ -107,3 +107,14 @@ ndctl_cmd_fw_xlat_firmware_status(struct ndctl_cmd *cmd)
else
return FW_EUNKNOWN;
}
+
+NDCTL_EXPORT int
+ndctl_dimm_fw_update_supported(struct ndctl_dimm *dimm)
+{
+ struct ndctl_dimm_ops *ops = dimm->ops;
+
+ if (ops && ops->fw_update_supported)
+ return ops->fw_update_supported(dimm);
+ else
+ return -ENOTTY;
+}
diff --git a/ndctl/lib/intel.c b/ndctl/lib/intel.c
index cee5204c..a4f0af26 100644
--- a/ndctl/lib/intel.c
+++ b/ndctl/lib/intel.c
@@ -650,6 +650,29 @@ intel_dimm_cmd_new_lss(struct ndctl_dimm *dimm)
return cmd;
}
+static int intel_dimm_fw_update_supported(struct ndctl_dimm *dimm)
+{
+ struct ndctl_ctx *ctx = ndctl_dimm_get_ctx(dimm);
+
+ if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_CALL)) {
+ dbg(ctx, "unsupported cmd: %d\n", ND_CMD_CALL);
+ return -EOPNOTSUPP;
+ }
+
+ /*
+ * We only need to check FW_GET_INFO. If that isn't supported then
+ * the others aren't either.
+ */
+ if (test_dimm_dsm(dimm, ND_INTEL_FW_GET_INFO)
+ == DIMM_DSM_UNSUPPORTED) {
+ dbg(ctx, "unsupported function: %d\n",
+ ND_INTEL_FW_GET_INFO);
+ return -EIO;
+ }
+
+ return 0;
+}
+
struct ndctl_dimm_ops * const intel_dimm_ops = &(struct ndctl_dimm_ops) {
.cmd_desc = intel_cmd_desc,
.new_smart = intel_dimm_cmd_new_smart,
@@ -703,4 +726,5 @@ struct ndctl_dimm_ops * const intel_dimm_ops = &(struct ndctl_dimm_ops) {
.fw_fquery_get_fw_rev = intel_cmd_fw_fquery_get_fw_rev,
.fw_xlat_firmware_status = intel_cmd_fw_xlat_firmware_status,
.new_ack_shutdown_count = intel_dimm_cmd_new_lss,
+ .fw_update_supported = intel_dimm_fw_update_supported,
};
diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym
index af9b7d54..cc580f9c 100644
--- a/ndctl/lib/libndctl.sym
+++ b/ndctl/lib/libndctl.sym
@@ -344,4 +344,5 @@ global:
ndctl_cmd_fw_fquery_get_fw_rev;
ndctl_cmd_fw_xlat_firmware_status;
ndctl_dimm_cmd_new_ack_shutdown_count;
+ ndctl_dimm_fw_update_supported;
} LIBNDCTL_13;
diff --git a/ndctl/lib/private.h b/ndctl/lib/private.h
index 015eeb2d..1cad06b7 100644
--- a/ndctl/lib/private.h
+++ b/ndctl/lib/private.h
@@ -325,6 +325,7 @@ struct ndctl_dimm_ops {
unsigned long long (*fw_fquery_get_fw_rev)(struct ndctl_cmd *);
enum ND_FW_STATUS (*fw_xlat_firmware_status)(struct ndctl_cmd *);
struct ndctl_cmd *(*new_ack_shutdown_count)(struct ndctl_dimm *);
+ int (*fw_update_supported)(struct ndctl_dimm *);
};
struct ndctl_dimm_ops * const intel_dimm_ops;
diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h
index 9db775ba..d223ea81 100644
--- a/ndctl/libndctl.h
+++ b/ndctl/libndctl.h
@@ -625,6 +625,7 @@ unsigned int ndctl_cmd_fw_start_get_context(struct ndctl_cmd *cmd);
unsigned long long ndctl_cmd_fw_fquery_get_fw_rev(struct ndctl_cmd *cmd);
enum ND_FW_STATUS ndctl_cmd_fw_xlat_firmware_status(struct ndctl_cmd *cmd);
struct ndctl_cmd *ndctl_dimm_cmd_new_ack_shutdown_count(struct ndctl_dimm *dimm);
+int ndctl_dimm_fw_update_supported(struct ndctl_dimm *dimm);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/ndctl/update.c b/ndctl/update.c
index 0f0f0d81..b4ae1ddb 100644
--- a/ndctl/update.c
+++ b/ndctl/update.c
@@ -449,11 +449,24 @@ static int get_ndctl_dimm(struct update_context *uctx, void *ctx)
{
struct ndctl_dimm *dimm;
struct ndctl_bus *bus;
+ int rc;
ndctl_bus_foreach(ctx, bus)
ndctl_dimm_foreach(bus, dimm) {
if (!util_dimm_filter(dimm, uctx->dimm_id))
continue;
+ rc = ndctl_dimm_fw_update_supported(dimm);
+ switch (rc) {
+ case -ENOTTY:
+ error("DIMM firmware update not supported by ndctl.");
+ return rc;
+ case -EOPNOTSUPP:
+ error("DIMM firmware update not supported by the kernel");
+ return rc;
+ case -EIO:
+ error("DIMM firmware update not supported by platform firmware.");
+ return rc;
+ }
uctx->dimm = dimm;
return 0;
}
4 years, 3 months
[ndctl PATCH] ndctl, test: add a unit test for partition rescanning
by Vishal Verma
pre-4.16 kernels had a bug where BTT partitions wouldn't come up on
driver probe because we were adding a zero-sized disk. Add a unit test
that creates partitions, and cycles the namespace to ensure the
partitions are automatically brought up. This performs the test for raw,
memory, and sector modes.
Reported-by: Dariusz Dokupil <dariusz.dokupil(a)intel.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
test/Makefile.am | 3 +-
test/rescan-partitions.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+), 1 deletion(-)
create mode 100755 test/rescan-partitions.sh
diff --git a/test/Makefile.am b/test/Makefile.am
index 749055c..496a663 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -20,7 +20,8 @@ TESTS =\
hugetlb \
btt-pad-compat.sh \
firmware-update.sh \
- ack-shutdown-count-set
+ ack-shutdown-count-set \
+ rescan-partitions.sh
check_PROGRAMS =\
libndctl \
diff --git a/test/rescan-partitions.sh b/test/rescan-partitions.sh
new file mode 100755
index 0000000..6dd289b
--- /dev/null
+++ b/test/rescan-partitions.sh
@@ -0,0 +1,106 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018 Intel Corporation. All rights reserved.
+
+[ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ] && ndctl="../ndctl/ndctl"
+[ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ] && ndctl="./ndctl/ndctl"
+[ -z "$ndctl" ] && echo "Couldn't find an ndctl binary" && exit 1
+bus="nfit_test.0"
+json2var="s/[{}\",]//g; s/:/=/g"
+dev=""
+size=""
+blockdev=""
+rc=77
+
+trap 'err $LINENO' ERR
+
+# sample json:
+#{
+# "dev":"namespace5.0",
+# "mode":"sector",
+# "size":"60.00 MiB (62.92 MB)",
+# "uuid":"f1baa71a-d165-4da4-bb6a-083a2b0e6469",
+# "blockdev":"pmem5s",
+#}
+
+# $1: Line number
+# $2: exit code
+err()
+{
+ [ -n "$2" ] && rc="$2"
+ echo "test/rescan-partitions.sh: failed at line $1"
+ exit "$rc"
+}
+
+check_min_kver()
+{
+ local ver="$1"
+ : "${KVER:=$(uname -r)}"
+
+ [ -n "$ver" ] || return 1
+ [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
+}
+check_min_kver "4.16" || { echo "kernel $KVER may not contain fixes for partition rescanning"; exit "$rc"; }
+
+check_prereq()
+{
+ if ! command -v "$1" >/dev/null; then
+ echo "missing '$1', skipping.."
+ exit "$rc"
+ fi
+}
+check_prereq "parted"
+check_prereq "blockdev"
+
+reset()
+{
+ $ndctl disable-region -b "$bus" all
+ $ndctl zero-labels -b "$bus" all
+ $ndctl enable-region -b "$bus" all
+}
+
+test_mode()
+{
+ local mode="$1"
+
+ # create namespace
+ json=$($ndctl create-namespace -b "$bus" -t pmem -m "$mode")
+ eval "$(echo "$json" | sed -e "$json2var")"
+ [ -n "$dev" ] || err "$LINENO" 2
+ [ -n "$size" ] || err "$LINENO" 2
+ [ -n "$blockdev" ] || err "$LINENO" 2
+ [ $size -gt 0 ] || err "$LINENO" 2
+
+ # create partition
+ parted --script /dev/$blockdev mklabel gpt mkpart primary 1MiB 10MiB
+
+ # verify it is created
+ sleep 1
+ blockdev --rereadpt /dev/$blockdev
+ sleep 1
+ partdev="$(grep -Eo "${blockdev}.+" /proc/partitions)"
+ test -b /dev/$partdev
+
+ # cycle the namespace, and verify the partition is read
+ # without needing to do a blockdev --rereadpt
+ $ndctl disable-namespace $dev
+ $ndctl enable-namespace $dev
+ if [ -b /dev/$partdev ]; then
+ echo "mode: $mode - partition read successful"
+ else
+ echo "mode: $mode - partition read failed"
+ err "$LINENO" 1
+ fi
+
+ $ndctl disable-namespace $dev
+ $ndctl destroy-namespace $dev
+}
+
+rc=1
+reset
+test_mode "raw"
+test_mode "memory"
+test_mode "sector"
+reset
+
+exit 0
--
2.14.3
4 years, 3 months
[PATCH v2 0/2] ndctl: move firmware update to dimm action
by Dave Jiang
The following series moves firmware update to dimm.c in order to take
advantage of the command line parsing that already exists and remove
duplications.
v2:
- Add distinct return errors for lack of support in ndctl, kernel, or
platform.
- Moved the firmware update defines and structs to its own header.
---
Dave Jiang (2):
ndctl: add check for update firmware supported
ndctl: merge firmware-update to dimm.c as one of the dimm ops
ndctl/Makefile.am | 1
ndctl/dimm.c | 466 ++++++++++++++++++++++++++++++++++++++++
ndctl/firmware-update.h | 45 ++++
ndctl/lib/firmware.c | 11 +
ndctl/lib/intel.c | 24 ++
ndctl/lib/libndctl.sym | 1
ndctl/lib/private.h | 1
ndctl/libndctl.h | 1
ndctl/update.c | 545 -----------------------------------------------
9 files changed, 547 insertions(+), 548 deletions(-)
create mode 100644 ndctl/firmware-update.h
delete mode 100644 ndctl/update.c
--
4 years, 3 months
[PATCH] libnvdimm, {btt, blk}: do integrity setup before add_disk()
by Vishal Verma
Prior to 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk")
we needed to temporarily add a zero-capacity disk before registering for
blk-integrity. But adding a zero-capacity disk caused the partition
table scanning to bail early, and this resulted in partitions not coming
up after a probe of the BTT or blk namespaces.
We can now register for integrity before the disk has been added, and
this fixes the rescan problems.
Fixes: 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk")
Reported-by: Dariusz Dokupil <dariusz.dokupil(a)intel.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: stable(a)vger.kernel.org
Signed-off-by: Vishal Verma <vishal.l.verma(a)intel.com>
---
drivers/nvdimm/blk.c | 3 +--
drivers/nvdimm/btt.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c
index 345acca576b3..1bd7b3734751 100644
--- a/drivers/nvdimm/blk.c
+++ b/drivers/nvdimm/blk.c
@@ -278,8 +278,6 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
disk->queue = q;
disk->flags = GENHD_FL_EXT_DEVT;
nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name);
- set_capacity(disk, 0);
- device_add_disk(dev, disk);
if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk))
return -ENOMEM;
@@ -292,6 +290,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
}
set_capacity(disk, available_disk_size >> SECTOR_SHIFT);
+ device_add_disk(dev, disk);
revalidate_disk(disk);
return 0;
}
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 2ef544f10ec8..4b95ac513de2 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1545,8 +1545,6 @@ static int btt_blk_init(struct btt *btt)
queue_flag_set_unlocked(QUEUE_FLAG_NONROT, btt->btt_queue);
btt->btt_queue->queuedata = btt;
- set_capacity(btt->btt_disk, 0);
- device_add_disk(&btt->nd_btt->dev, btt->btt_disk);
if (btt_meta_size(btt)) {
int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
@@ -1558,6 +1556,7 @@ static int btt_blk_init(struct btt *btt)
}
}
set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
+ device_add_disk(&btt->nd_btt->dev, btt->btt_disk);
btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
revalidate_disk(btt->btt_disk);
--
2.14.3
4 years, 3 months
[PATCH 1/3] nfit_test: improve structure offset handling
by Ross Zwisler
In nfit_test0_setup() and nfit_test1_setup() we keep an 'offset' value
which we use to calculate where in our 'nfit_buf' we will place our next
structure. The handling of 'offset' and the calculation of the placement
of the next structure is a bit inconsistent, though. We don't update
'offset' after we insert each structure, sometimes causing us to update it
for multiple structures' sizes at once. When calculating the position of
the next structure we aren't always able to just use 'offset', but
sometimes have to add in other structure sizes as well.
Fix this by updating 'offset' after each structure insertion in a
consistent way, allowing us to always calculate the position of the next
structure to be inserted by just using 'nfit_buf + offset'.
Signed-off-by: Ross Zwisler <ross.zwisler(a)linux.intel.com>
---
tools/testing/nvdimm/test/nfit.c | 183 +++++++++++++++++++++++----------------
1 file changed, 109 insertions(+), 74 deletions(-)
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 620fa78b3b1b..1376fc95c33a 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -1366,7 +1366,7 @@ static void nfit_test0_setup(struct nfit_test *t)
struct acpi_nfit_data_region *bdw;
struct acpi_nfit_flush_address *flush;
struct acpi_nfit_capabilities *pcap;
- unsigned int offset, i;
+ unsigned int offset = 0, i;
/*
* spa0 (interleave first half of dimm0 and dimm1, note storage
@@ -1380,93 +1380,102 @@ static void nfit_test0_setup(struct nfit_test *t)
spa->range_index = 0+1;
spa->address = t->spa_set_dma[0];
spa->length = SPA0_SIZE;
+ offset += spa->header.length;
/*
* spa1 (interleave last half of the 4 DIMMS, note storage
* does not actually alias the related block-data-window
* regions)
*/
- spa = nfit_buf + sizeof(*spa);
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_PM), 16);
spa->range_index = 1+1;
spa->address = t->spa_set_dma[1];
spa->length = SPA1_SIZE;
+ offset += spa->header.length;
/* spa2 (dcr0) dimm0 */
- spa = nfit_buf + sizeof(*spa) * 2;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_DCR), 16);
spa->range_index = 2+1;
spa->address = t->dcr_dma[0];
spa->length = DCR_SIZE;
+ offset += spa->header.length;
/* spa3 (dcr1) dimm1 */
- spa = nfit_buf + sizeof(*spa) * 3;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_DCR), 16);
spa->range_index = 3+1;
spa->address = t->dcr_dma[1];
spa->length = DCR_SIZE;
+ offset += spa->header.length;
/* spa4 (dcr2) dimm2 */
- spa = nfit_buf + sizeof(*spa) * 4;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_DCR), 16);
spa->range_index = 4+1;
spa->address = t->dcr_dma[2];
spa->length = DCR_SIZE;
+ offset += spa->header.length;
/* spa5 (dcr3) dimm3 */
- spa = nfit_buf + sizeof(*spa) * 5;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_DCR), 16);
spa->range_index = 5+1;
spa->address = t->dcr_dma[3];
spa->length = DCR_SIZE;
+ offset += spa->header.length;
/* spa6 (bdw for dcr0) dimm0 */
- spa = nfit_buf + sizeof(*spa) * 6;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_BDW), 16);
spa->range_index = 6+1;
spa->address = t->dimm_dma[0];
spa->length = DIMM_SIZE;
+ offset += spa->header.length;
/* spa7 (bdw for dcr1) dimm1 */
- spa = nfit_buf + sizeof(*spa) * 7;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_BDW), 16);
spa->range_index = 7+1;
spa->address = t->dimm_dma[1];
spa->length = DIMM_SIZE;
+ offset += spa->header.length;
/* spa8 (bdw for dcr2) dimm2 */
- spa = nfit_buf + sizeof(*spa) * 8;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_BDW), 16);
spa->range_index = 8+1;
spa->address = t->dimm_dma[2];
spa->length = DIMM_SIZE;
+ offset += spa->header.length;
/* spa9 (bdw for dcr3) dimm3 */
- spa = nfit_buf + sizeof(*spa) * 9;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_BDW), 16);
spa->range_index = 9+1;
spa->address = t->dimm_dma[3];
spa->length = DIMM_SIZE;
+ offset += spa->header.length;
- offset = sizeof(*spa) * 10;
/* mem-region0 (spa0, dimm0) */
memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
@@ -1481,9 +1490,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 2;
+ offset += memdev->header.length;
/* mem-region1 (spa0, dimm1) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map);
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[1];
@@ -1497,9 +1507,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->interleave_index = 0;
memdev->interleave_ways = 2;
memdev->flags = ACPI_NFIT_MEM_HEALTH_ENABLED;
+ offset += memdev->header.length;
/* mem-region2 (spa1, dimm0) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 2;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[0];
@@ -1513,9 +1524,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->interleave_index = 0;
memdev->interleave_ways = 4;
memdev->flags = ACPI_NFIT_MEM_HEALTH_ENABLED;
+ offset += memdev->header.length;
/* mem-region3 (spa1, dimm1) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 3;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[1];
@@ -1528,9 +1540,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = SPA0_SIZE/2;
memdev->interleave_index = 0;
memdev->interleave_ways = 4;
+ offset += memdev->header.length;
/* mem-region4 (spa1, dimm2) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 4;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[2];
@@ -1544,9 +1557,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->interleave_index = 0;
memdev->interleave_ways = 4;
memdev->flags = ACPI_NFIT_MEM_HEALTH_ENABLED;
+ offset += memdev->header.length;
/* mem-region5 (spa1, dimm3) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 5;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[3];
@@ -1559,9 +1573,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = SPA0_SIZE/2;
memdev->interleave_index = 0;
memdev->interleave_ways = 4;
+ offset += memdev->header.length;
/* mem-region6 (spa/dcr0, dimm0) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 6;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[0];
@@ -1574,9 +1589,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
/* mem-region7 (spa/dcr1, dimm1) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 7;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[1];
@@ -1589,9 +1605,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
/* mem-region8 (spa/dcr2, dimm2) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 8;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[2];
@@ -1604,9 +1621,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
/* mem-region9 (spa/dcr3, dimm3) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 9;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[3];
@@ -1619,9 +1637,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
/* mem-region10 (spa/bdw0, dimm0) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 10;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[0];
@@ -1634,9 +1653,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
/* mem-region11 (spa/bdw1, dimm1) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 11;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[1];
@@ -1649,9 +1669,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
/* mem-region12 (spa/bdw2, dimm2) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 12;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[2];
@@ -1664,9 +1685,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
/* mem-region13 (spa/dcr3, dimm3) */
- memdev = nfit_buf + offset + sizeof(struct acpi_nfit_memory_map) * 13;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[3];
@@ -1680,12 +1702,12 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
memdev->flags = ACPI_NFIT_MEM_HEALTH_ENABLED;
+ offset += memdev->header.length;
- offset = offset + sizeof(struct acpi_nfit_memory_map) * 14;
/* dcr-descriptor0: blk */
dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
- dcr->header.length = sizeof(struct acpi_nfit_control_region);
+ dcr->header.length = sizeof(*dcr);
dcr->region_index = 0+1;
dcr_common_init(dcr);
dcr->serial_number = ~handle[0];
@@ -1696,11 +1718,12 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->command_size = 8;
dcr->status_offset = 8;
dcr->status_size = 4;
+ offset += dcr->header.length;
/* dcr-descriptor1: blk */
- dcr = nfit_buf + offset + sizeof(struct acpi_nfit_control_region);
+ dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
- dcr->header.length = sizeof(struct acpi_nfit_control_region);
+ dcr->header.length = sizeof(*dcr);
dcr->region_index = 1+1;
dcr_common_init(dcr);
dcr->serial_number = ~handle[1];
@@ -1711,11 +1734,12 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->command_size = 8;
dcr->status_offset = 8;
dcr->status_size = 4;
+ offset += dcr->header.length;
/* dcr-descriptor2: blk */
- dcr = nfit_buf + offset + sizeof(struct acpi_nfit_control_region) * 2;
+ dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
- dcr->header.length = sizeof(struct acpi_nfit_control_region);
+ dcr->header.length = sizeof(*dcr);
dcr->region_index = 2+1;
dcr_common_init(dcr);
dcr->serial_number = ~handle[2];
@@ -1726,11 +1750,12 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->command_size = 8;
dcr->status_offset = 8;
dcr->status_size = 4;
+ offset += dcr->header.length;
/* dcr-descriptor3: blk */
- dcr = nfit_buf + offset + sizeof(struct acpi_nfit_control_region) * 3;
+ dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
- dcr->header.length = sizeof(struct acpi_nfit_control_region);
+ dcr->header.length = sizeof(*dcr);
dcr->region_index = 3+1;
dcr_common_init(dcr);
dcr->serial_number = ~handle[3];
@@ -1741,8 +1766,8 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->command_size = 8;
dcr->status_offset = 8;
dcr->status_size = 4;
+ offset += dcr->header.length;
- offset = offset + sizeof(struct acpi_nfit_control_region) * 4;
/* dcr-descriptor0: pmem */
dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
@@ -1753,10 +1778,10 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->serial_number = ~handle[0];
dcr->code = NFIT_FIC_BYTEN;
dcr->windows = 0;
+ offset += dcr->header.length;
/* dcr-descriptor1: pmem */
- dcr = nfit_buf + offset + offsetof(struct acpi_nfit_control_region,
- window_size);
+ dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
dcr->header.length = offsetof(struct acpi_nfit_control_region,
window_size);
@@ -1765,10 +1790,10 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->serial_number = ~handle[1];
dcr->code = NFIT_FIC_BYTEN;
dcr->windows = 0;
+ offset += dcr->header.length;
/* dcr-descriptor2: pmem */
- dcr = nfit_buf + offset + offsetof(struct acpi_nfit_control_region,
- window_size) * 2;
+ dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
dcr->header.length = offsetof(struct acpi_nfit_control_region,
window_size);
@@ -1777,10 +1802,10 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->serial_number = ~handle[2];
dcr->code = NFIT_FIC_BYTEN;
dcr->windows = 0;
+ offset += dcr->header.length;
/* dcr-descriptor3: pmem */
- dcr = nfit_buf + offset + offsetof(struct acpi_nfit_control_region,
- window_size) * 3;
+ dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
dcr->header.length = offsetof(struct acpi_nfit_control_region,
window_size);
@@ -1789,54 +1814,56 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->serial_number = ~handle[3];
dcr->code = NFIT_FIC_BYTEN;
dcr->windows = 0;
+ offset += dcr->header.length;
- offset = offset + offsetof(struct acpi_nfit_control_region,
- window_size) * 4;
/* bdw0 (spa/dcr0, dimm0) */
bdw = nfit_buf + offset;
bdw->header.type = ACPI_NFIT_TYPE_DATA_REGION;
- bdw->header.length = sizeof(struct acpi_nfit_data_region);
+ bdw->header.length = sizeof(*bdw);
bdw->region_index = 0+1;
bdw->windows = 1;
bdw->offset = 0;
bdw->size = BDW_SIZE;
bdw->capacity = DIMM_SIZE;
bdw->start_address = 0;
+ offset += bdw->header.length;
/* bdw1 (spa/dcr1, dimm1) */
- bdw = nfit_buf + offset + sizeof(struct acpi_nfit_data_region);
+ bdw = nfit_buf + offset;
bdw->header.type = ACPI_NFIT_TYPE_DATA_REGION;
- bdw->header.length = sizeof(struct acpi_nfit_data_region);
+ bdw->header.length = sizeof(*bdw);
bdw->region_index = 1+1;
bdw->windows = 1;
bdw->offset = 0;
bdw->size = BDW_SIZE;
bdw->capacity = DIMM_SIZE;
bdw->start_address = 0;
+ offset += bdw->header.length;
/* bdw2 (spa/dcr2, dimm2) */
- bdw = nfit_buf + offset + sizeof(struct acpi_nfit_data_region) * 2;
+ bdw = nfit_buf + offset;
bdw->header.type = ACPI_NFIT_TYPE_DATA_REGION;
- bdw->header.length = sizeof(struct acpi_nfit_data_region);
+ bdw->header.length = sizeof(*bdw);
bdw->region_index = 2+1;
bdw->windows = 1;
bdw->offset = 0;
bdw->size = BDW_SIZE;
bdw->capacity = DIMM_SIZE;
bdw->start_address = 0;
+ offset += bdw->header.length;
/* bdw3 (spa/dcr3, dimm3) */
- bdw = nfit_buf + offset + sizeof(struct acpi_nfit_data_region) * 3;
+ bdw = nfit_buf + offset;
bdw->header.type = ACPI_NFIT_TYPE_DATA_REGION;
- bdw->header.length = sizeof(struct acpi_nfit_data_region);
+ bdw->header.length = sizeof(*bdw);
bdw->region_index = 3+1;
bdw->windows = 1;
bdw->offset = 0;
bdw->size = BDW_SIZE;
bdw->capacity = DIMM_SIZE;
bdw->start_address = 0;
+ offset += bdw->header.length;
- offset = offset + sizeof(struct acpi_nfit_data_region) * 4;
/* flush0 (dimm0) */
flush = nfit_buf + offset;
flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
@@ -1845,48 +1872,52 @@ static void nfit_test0_setup(struct nfit_test *t)
flush->hint_count = NUM_HINTS;
for (i = 0; i < NUM_HINTS; i++)
flush->hint_address[i] = t->flush_dma[0] + i * sizeof(u64);
+ offset += flush->header.length;
/* flush1 (dimm1) */
- flush = nfit_buf + offset + flush_hint_size * 1;
+ flush = nfit_buf + offset;
flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
flush->header.length = flush_hint_size;
flush->device_handle = handle[1];
flush->hint_count = NUM_HINTS;
for (i = 0; i < NUM_HINTS; i++)
flush->hint_address[i] = t->flush_dma[1] + i * sizeof(u64);
+ offset += flush->header.length;
/* flush2 (dimm2) */
- flush = nfit_buf + offset + flush_hint_size * 2;
+ flush = nfit_buf + offset;
flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
flush->header.length = flush_hint_size;
flush->device_handle = handle[2];
flush->hint_count = NUM_HINTS;
for (i = 0; i < NUM_HINTS; i++)
flush->hint_address[i] = t->flush_dma[2] + i * sizeof(u64);
+ offset += flush->header.length;
/* flush3 (dimm3) */
- flush = nfit_buf + offset + flush_hint_size * 3;
+ flush = nfit_buf + offset;
flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
flush->header.length = flush_hint_size;
flush->device_handle = handle[3];
flush->hint_count = NUM_HINTS;
for (i = 0; i < NUM_HINTS; i++)
flush->hint_address[i] = t->flush_dma[3] + i * sizeof(u64);
+ offset += flush->header.length;
/* platform capabilities */
- pcap = nfit_buf + offset + flush_hint_size * 4;
+ pcap = nfit_buf + offset;
pcap->header.type = ACPI_NFIT_TYPE_CAPABILITIES;
pcap->header.length = sizeof(*pcap);
pcap->highest_capability = 1;
pcap->capabilities = ACPI_NFIT_CAPABILITY_CACHE_FLUSH |
ACPI_NFIT_CAPABILITY_MEM_FLUSH;
+ offset += pcap->header.length;
if (t->setup_hotplug) {
- offset = offset + flush_hint_size * 4 + sizeof(*pcap);
/* dcr-descriptor4: blk */
dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
- dcr->header.length = sizeof(struct acpi_nfit_control_region);
+ dcr->header.length = sizeof(*dcr);
dcr->region_index = 8+1;
dcr_common_init(dcr);
dcr->serial_number = ~handle[4];
@@ -1897,8 +1928,8 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->command_size = 8;
dcr->status_offset = 8;
dcr->status_size = 4;
+ offset += dcr->header.length;
- offset = offset + sizeof(struct acpi_nfit_control_region);
/* dcr-descriptor4: pmem */
dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
@@ -1909,21 +1940,20 @@ static void nfit_test0_setup(struct nfit_test *t)
dcr->serial_number = ~handle[4];
dcr->code = NFIT_FIC_BYTEN;
dcr->windows = 0;
+ offset += dcr->header.length;
- offset = offset + offsetof(struct acpi_nfit_control_region,
- window_size);
/* bdw4 (spa/dcr4, dimm4) */
bdw = nfit_buf + offset;
bdw->header.type = ACPI_NFIT_TYPE_DATA_REGION;
- bdw->header.length = sizeof(struct acpi_nfit_data_region);
+ bdw->header.length = sizeof(*bdw);
bdw->region_index = 8+1;
bdw->windows = 1;
bdw->offset = 0;
bdw->size = BDW_SIZE;
bdw->capacity = DIMM_SIZE;
bdw->start_address = 0;
+ offset += bdw->header.length;
- offset = offset + sizeof(struct acpi_nfit_data_region);
/* spa10 (dcr4) dimm4 */
spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
@@ -1932,30 +1962,32 @@ static void nfit_test0_setup(struct nfit_test *t)
spa->range_index = 10+1;
spa->address = t->dcr_dma[4];
spa->length = DCR_SIZE;
+ offset += spa->header.length;
/*
* spa11 (single-dimm interleave for hotplug, note storage
* does not actually alias the related block-data-window
* regions)
*/
- spa = nfit_buf + offset + sizeof(*spa);
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_PM), 16);
spa->range_index = 11+1;
spa->address = t->spa_set_dma[2];
spa->length = SPA0_SIZE;
+ offset += spa->header.length;
/* spa12 (bdw for dcr4) dimm4 */
- spa = nfit_buf + offset + sizeof(*spa) * 2;
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_BDW), 16);
spa->range_index = 12+1;
spa->address = t->dimm_dma[4];
spa->length = DIMM_SIZE;
+ offset += spa->header.length;
- offset = offset + sizeof(*spa) * 3;
/* mem-region14 (spa/dcr4, dimm4) */
memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
@@ -1970,10 +2002,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
- /* mem-region15 (spa0, dimm4) */
- memdev = nfit_buf + offset +
- sizeof(struct acpi_nfit_memory_map);
+ /* mem-region15 (spa11, dimm4) */
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[4];
@@ -1987,10 +2019,10 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
memdev->flags = ACPI_NFIT_MEM_HEALTH_ENABLED;
+ offset += memdev->header.length;
/* mem-region16 (spa/bdw4, dimm4) */
- memdev = nfit_buf + offset +
- sizeof(struct acpi_nfit_memory_map) * 2;
+ memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
memdev->device_handle = handle[4];
@@ -2003,8 +2035,8 @@ static void nfit_test0_setup(struct nfit_test *t)
memdev->address = 0;
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
+ offset += memdev->header.length;
- offset = offset + sizeof(struct acpi_nfit_memory_map) * 3;
/* flush3 (dimm4) */
flush = nfit_buf + offset;
flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
@@ -2014,6 +2046,7 @@ static void nfit_test0_setup(struct nfit_test *t)
for (i = 0; i < NUM_HINTS; i++)
flush->hint_address[i] = t->flush_dma[4]
+ i * sizeof(u64);
+ offset += flush->header.length;
}
post_ars_status(&t->ars_state, &t->badrange, t->spa_set_dma[0],
@@ -2061,17 +2094,18 @@ static void nfit_test1_setup(struct nfit_test *t)
spa->range_index = 0+1;
spa->address = t->spa_set_dma[0];
spa->length = SPA2_SIZE;
+ offset += spa->header.length;
/* virtual cd region */
- spa = nfit_buf + sizeof(*spa);
+ spa = nfit_buf + offset;
spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
spa->header.length = sizeof(*spa);
memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_VCD), 16);
spa->range_index = 0;
spa->address = t->spa_set_dma[1];
spa->length = SPA_VCD_SIZE;
+ offset += spa->header.length;
- offset += sizeof(*spa) * 2;
/* mem-region0 (spa0, dimm0) */
memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
@@ -2089,8 +2123,8 @@ static void nfit_test1_setup(struct nfit_test *t)
memdev->flags = ACPI_NFIT_MEM_SAVE_FAILED | ACPI_NFIT_MEM_RESTORE_FAILED
| ACPI_NFIT_MEM_FLUSH_FAILED | ACPI_NFIT_MEM_HEALTH_OBSERVED
| ACPI_NFIT_MEM_NOT_ARMED;
+ offset += memdev->header.length;
- offset += sizeof(*memdev);
/* dcr-descriptor0 */
dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
@@ -2101,8 +2135,8 @@ static void nfit_test1_setup(struct nfit_test *t)
dcr->serial_number = ~handle[5];
dcr->code = NFIT_FIC_BYTE;
dcr->windows = 0;
-
offset += dcr->header.length;
+
memdev = nfit_buf + offset;
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
memdev->header.length = sizeof(*memdev);
@@ -2117,9 +2151,9 @@ static void nfit_test1_setup(struct nfit_test *t)
memdev->interleave_index = 0;
memdev->interleave_ways = 1;
memdev->flags = ACPI_NFIT_MEM_MAP_FAILED;
+ offset += memdev->header.length;
/* dcr-descriptor1 */
- offset += sizeof(*memdev);
dcr = nfit_buf + offset;
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
dcr->header.length = offsetof(struct acpi_nfit_control_region,
@@ -2129,6 +2163,7 @@ static void nfit_test1_setup(struct nfit_test *t)
dcr->serial_number = ~handle[6];
dcr->code = NFIT_FIC_BYTE;
dcr->windows = 0;
+ offset += dcr->header.length;
post_ars_status(&t->ars_state, &t->badrange, t->spa_set_dma[0],
SPA2_SIZE);
--
2.14.3
4 years, 3 months
[PATCH] kernel/memremap: Remove stale devres_free() call
by Oliver O'Halloran
devm_memremap_pages() was re-worked in e8d513483300 to take a caller
allocated struct dev_pagemap as a function parameter. A call to
devres_free() was left in the error cleanup path which results in
a kernel panic if the remap fails for some reason. Remove it
to fix the panic and let devm_memremap_pages() fail gracefully.
Fixes: e8d513483300 ("memremap: change devm_memremap_pages interface to use struct dev_pagemap")
Cc: Logan Gunthorpe <logang(a)deltatee.com>
Cc: Christoph Hellwig <hch(a)lst.de>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Signed-off-by: Oliver O'Halloran <oohall(a)gmail.com>
---
Both in-tree users of devm_memremap_pages() embed dev_pagemap into other
structures so this shouldn't cause any leaks. Logan's p2p series does
add one usage that assumes pgmap will be freed on error so that'll
need fixing.
---
kernel/memremap.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/memremap.c b/kernel/memremap.c
index 4dd4274cabe2..895e6b76b25e 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -427,7 +427,6 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
err_pfn_remap:
err_radix:
pgmap_radix_release(res, pgoff);
- devres_free(pgmap);
return ERR_PTR(error);
}
EXPORT_SYMBOL(devm_memremap_pages);
--
2.9.5
4 years, 3 months
[PATCH] ndctl: removing daxctl io
by Dave Jiang
With PMDK implementing daxio, we no longer need daxctl io. Removing and free
up dependency on libpmem.
Signed-off-by: Dave Jiang <dave.jiang(a)intel.com>
---
Documentation/daxctl/Makefile.am | 3
Documentation/daxctl/daxctl-io.txt | 72 ----
configure.ac | 11 -
daxctl/Makefile.am | 8
daxctl/io.c | 586 ------------------------------------
5 files changed, 1 insertion(+), 679 deletions(-)
delete mode 100644 Documentation/daxctl/daxctl-io.txt
delete mode 100644 daxctl/io.c
diff --git a/Documentation/daxctl/Makefile.am b/Documentation/daxctl/Makefile.am
index 032d48cb..5913c94c 100644
--- a/Documentation/daxctl/Makefile.am
+++ b/Documentation/daxctl/Makefile.am
@@ -16,8 +16,7 @@ asciidoc.conf: ../asciidoc.conf.in
man1_MANS = \
daxctl.1 \
- daxctl-list.1 \
- daxctl-io.1
+ daxctl-list.1
CLEANFILES = $(man1_MANS)
diff --git a/Documentation/daxctl/daxctl-io.txt b/Documentation/daxctl/daxctl-io.txt
deleted file mode 100644
index c4ad9ef0..00000000
--- a/Documentation/daxctl/daxctl-io.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-daxctl-io(1)
-===========
-
-NAME
-----
-daxctl-io - Perform I/O on Device-DAX devices or zero a Device-DAX device.
-
-SYNOPSIS
---------
-[verse]
-'daxctl io' [<options>]
-
-There must be a Device-DAX device involved whether as the input or the output
-device. Read from a Device-DAX device and write to a file descriptor, or
-another Device-DAX device. Write to a Device-DAX device from a file descriptor
-or another Device-DAX device.
-
-No length specified will default to input file/device length. If input is
-a special char file then length will be the output file/device length.
-
-No input will default to stdin. No output will default to stdout.
-
-For a Device-DAX device, attempts to clear badblocks within range of writes
-will be performed.
-
-EXAMPLE
--------
-[verse]
-# daxctl io --zero /dev/dax1.0
-
-# daxctl io --input=/dev/dax1.0 --output=/home/myfile --len=2M --seek=4096
-
-# cat /dev/zero | daxctl io --output=/dev/dax1.0
-
-# daxctl io --input=/dev/zero --output=/dev/dax1.0 --skip=4096
-
-OPTIONS
--------
--i::
---input=::
- Input device or file to read from.
-
--o::
---output=::
- Output device or file to write to.
-
--z::
---zero::
- Zero the output device for 'len' size. Or the entire device if no
- length was provided. The output device must be a Device DAX device.
-
--l::
---len::
- The length in bytes to perform the I/O. The following suffixes are
- supported to make passing in size easier for kibi, mebi, gibi, and
- tebi bytes: k/K,m/M,g/G,t/T. i.e. 20m - 20 Mebibytes
-
--s::
---seek::
- The number of bytes to skip over on the output before performing a
- write.
-
--k::
---skip::
- The number of bytes to skip over on the input before performing a read.
-
-COPYRIGHT
----------
-Copyright (c) 2017, Intel Corporation. License GPLv2: GNU GPL
-version 2 <http://gnu.org/licenses/gpl.html>. This is free software:
-you are free to change and redistribute it. There is NO WARRANTY, to
-the extent permitted by law.
diff --git a/configure.ac b/configure.ac
index 9067b419..3eaac32f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,17 +94,6 @@ PKG_CHECK_MODULES([UDEV], [libudev])
PKG_CHECK_MODULES([UUID], [uuid])
PKG_CHECK_MODULES([JSON], [json-c])
-AC_ARG_WITH([libpmem],
- AS_HELP_STRING([--with-libpmem],
- [Install with libpmem support. @<:@default=no@:>@]),
- [],
- [with_libpmem=no])
-if test "x$with_libpmem" = "xyes"; then
- PKG_CHECK_MODULES([PMEM], [libpmem])
- AC_DEFINE(ENABLE_DAXIO, 1, [Enable daxctl io])
-fi
-AM_CONDITIONAL([ENABLE_DAXIO], [test "x$with_libpmem" = "xyes"])
-
AC_ARG_WITH([bash-completion-dir],
AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
[Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
diff --git a/daxctl/Makefile.am b/daxctl/Makefile.am
index 81d405e7..e256afd5 100644
--- a/daxctl/Makefile.am
+++ b/daxctl/Makefile.am
@@ -7,17 +7,9 @@ daxctl_SOURCES =\
list.c \
../util/json.c
-if ENABLE_DAXIO
-daxctl_SOURCES += io.c
-endif
-
daxctl_LDADD =\
lib/libdaxctl.la \
../ndctl/lib/libndctl.la \
../libutil.a \
$(UUID_LIBS) \
$(JSON_LIBS)
-
-if ENABLE_DAXIO
-daxctl_LDADD += $(PMEM_LIBS)
-endif
diff --git a/daxctl/io.c b/daxctl/io.c
deleted file mode 100644
index 551e8319..00000000
--- a/daxctl/io.c
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- */
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <limits.h>
-#include <libgen.h>
-#include <libpmem.h>
-#include <util/json.h>
-#include <util/filter.h>
-#include <util/size.h>
-#include <json-c/json.h>
-#include <daxctl/libdaxctl.h>
-#include <ccan/short_types/short_types.h>
-#include <util/parse-options.h>
-#include <ccan/array_size/array_size.h>
-#include <ndctl/ndctl.h>
-
-enum io_direction {
- IO_READ = 0,
- IO_WRITE,
-};
-
-struct io_dev {
- int fd;
- int major;
- int minor;
- void *mmap;
- const char *parm_path;
- char *real_path;
- uint64_t offset;
- uint64_t offset_diff;
- enum io_direction direction;
- bool is_dax;
- bool is_char;
- bool is_new;
- bool need_trunc;
- struct ndctl_ctx *ndctl_ctx;
- struct ndctl_region *region;
- struct ndctl_dax *dax;
- uint64_t size;
- uint64_t mmap_size;
-};
-
-static struct {
- struct io_dev dev[2];
- bool zero;
- uint64_t len;
- struct ndctl_cmd *ars_cap;
- struct ndctl_cmd *clear_err;
-} io = {
- .dev[0].fd = -1,
- .dev[1].fd = -1,
-};
-
-#define fail(fmt, ...) \
-do { \
- fprintf(stderr, "daxctl-%s:%s:%d: " fmt, \
- VERSION, __func__, __LINE__, ##__VA_ARGS__); \
-} while (0)
-
-static bool is_stdinout(struct io_dev *io_dev)
-{
- return (io_dev->fd == STDIN_FILENO ||
- io_dev->fd == STDOUT_FILENO) ? true : false;
-}
-
-static int setup_device(struct io_dev *io_dev, size_t size)
-{
- int flags, rc;
- uint64_t align, offset;
-
- if (is_stdinout(io_dev))
- return 0;
-
- if (io_dev->is_new)
- flags = O_CREAT|O_WRONLY|O_TRUNC;
- else if (io_dev->need_trunc)
- flags = O_RDWR | O_TRUNC;
- else
- flags = O_RDWR;
-
- io_dev->fd = open(io_dev->parm_path, flags, S_IRUSR|S_IWUSR);
- if (io_dev->fd == -1) {
- rc = -errno;
- perror("open");
- return rc;
- }
-
- if (!io_dev->is_dax)
- return 0;
-
- align = ndctl_dax_get_align(io_dev->dax);
- if (align == ULONG_MAX)
- return -ERANGE;
-
- io_dev->mmap_size = ALIGN(size, align);
- flags = (io_dev->direction == IO_READ) ? PROT_READ : PROT_WRITE;
- offset = ALIGN_DOWN(io_dev->offset, align);
- io_dev->offset_diff = io_dev->offset - offset;
-
- io_dev->mmap = mmap(NULL, io_dev->mmap_size, flags,
- MAP_SHARED, io_dev->fd, offset);
- if (io_dev->mmap == MAP_FAILED) {
- rc = -errno;
- perror("mmap");
- return rc;
- }
-
- return 0;
-}
-
-static int match_device(struct io_dev *io_dev, struct daxctl_region *dregion)
-{
- struct daxctl_dev *dev;
-
- daxctl_dev_foreach(dregion, dev) {
- if (io_dev->major == daxctl_dev_get_major(dev) &&
- io_dev->minor == daxctl_dev_get_minor(dev)) {
- io_dev->is_dax = true;
- io_dev->size = daxctl_dev_get_size(dev);
- return 1;
- }
- }
-
- return 0;
-}
-
-struct ndctl_dax *find_ndctl_dax(struct ndctl_ctx *ndctl_ctx,
- struct io_dev *io_dev)
-{
- struct ndctl_bus *bus;
- struct ndctl_region *region;
- struct ndctl_dax *dax;
- struct daxctl_region *dregion;
-
- ndctl_bus_foreach(ndctl_ctx, bus)
- ndctl_region_foreach(bus, region)
- ndctl_dax_foreach(region, dax) {
- dregion = ndctl_dax_get_daxctl_region(dax);
- if (match_device(io_dev, dregion))
- return dax;
- }
-
- return NULL;
-}
-
-static int find_dax_device(struct io_dev *io_dev,
- struct daxctl_ctx *daxctl_ctx, struct ndctl_ctx *ndctl_ctx,
- enum io_direction dir)
-{
- struct daxctl_region *dregion;
- struct stat st;
- int rc;
-
- if (is_stdinout(io_dev)) {
- io_dev->size = ULONG_MAX;
- return 0;
- }
-
- rc = stat(io_dev->parm_path, &st);
- if (rc == -1) {
- rc = -errno;
- if (rc == -ENOENT && dir == IO_WRITE) {
- io_dev->is_new = true;
- io_dev->size = ULONG_MAX;
- return 0;
- }
- perror("stat");
- return rc;
- }
-
- if (S_ISREG(st.st_mode)) {
- if (dir == IO_WRITE) {
- io_dev->need_trunc = true;
- io_dev->size = ULONG_MAX;
- } else
- io_dev->size = st.st_size;
- return 0;
- } else if (S_ISBLK(st.st_mode)) {
- io_dev->size = st.st_size;
- return 0;
- } else if (S_ISCHR(st.st_mode)) {
- io_dev->size = ULONG_MAX;
- io_dev->is_char = true;
- io_dev->major = major(st.st_rdev);
- io_dev->minor = minor(st.st_rdev);
- } else
- return -ENODEV;
-
- /* grab the ndctl matches if they exist */
- io_dev->dax = find_ndctl_dax(ndctl_ctx, io_dev);
- if (io_dev->dax) {
- io_dev->region = ndctl_dax_get_region(io_dev->dax);
- return 1;
- }
-
- daxctl_region_foreach(daxctl_ctx, dregion)
- if (match_device(io_dev, dregion))
- return 1;
-
- return 0;
-}
-
-static int send_clear_error(struct ndctl_bus *bus, uint64_t start, uint64_t size)
-{
- uint64_t cleared;
- int rc;
-
- io.clear_err = ndctl_bus_cmd_new_clear_error(start, size, io.ars_cap);
- if (!io.clear_err) {
- fail("bus: %s failed to create cmd\n",
- ndctl_bus_get_provider(bus));
- return -ENXIO;
- }
-
- rc = ndctl_cmd_submit(io.clear_err);
- if (rc) {
- fail("bus: %s failed to submit cmd: %d\n",
- ndctl_bus_get_provider(bus), rc);
- ndctl_cmd_unref(io.clear_err);
- return rc;
- }
-
- cleared = ndctl_cmd_clear_error_get_cleared(io.clear_err);
- if (cleared != size) {
- fail("bus: %s expected to clear: %ld actual: %ld\n",
- ndctl_bus_get_provider(bus),
- size, cleared);
- return -ENXIO;
- }
-
- return 0;
-}
-
-static int get_ars_cap(struct ndctl_bus *bus, uint64_t start, uint64_t size)
-{
- int rc;
-
- io.ars_cap = ndctl_bus_cmd_new_ars_cap(bus, start, size);
- if (!io.ars_cap) {
- fail("bus: %s failed to create cmd\n",
- ndctl_bus_get_provider(bus));
- return -ENOTTY;
- }
-
- rc = ndctl_cmd_submit(io.ars_cap);
- if (rc) {
- fail("bus: %s failed to submit cmd: %d\n",
- ndctl_bus_get_provider(bus), rc);
- ndctl_cmd_unref(io.ars_cap);
- return rc;
- }
-
- if (ndctl_cmd_ars_cap_get_size(io.ars_cap) <
- sizeof(struct nd_cmd_ars_status)) {
- fail("bus: %s expected size >= %zd got: %d\n",
- ndctl_bus_get_provider(bus),
- sizeof(struct nd_cmd_ars_status),
- ndctl_cmd_ars_cap_get_size(io.ars_cap));
- ndctl_cmd_unref(io.ars_cap);
- return -ENXIO;
- }
-
- return 0;
-}
-
-int clear_errors(struct ndctl_bus *bus, uint64_t start, uint64_t len)
-{
- int rc;
-
- rc = get_ars_cap(bus, start, len);
- if (rc) {
- fail("get_ars_cap failed\n");
- return rc;
- }
-
- rc = send_clear_error(bus, start, len);
- if (rc) {
- fail("send_clear_error failed\n");
- return rc;
- }
-
- return 0;
-}
-
-static int clear_badblocks(struct io_dev *dev, uint64_t len)
-{
- unsigned long long dax_begin, dax_size, dax_end;
- unsigned long long region_begin, offset;
- unsigned long long size, io_begin, io_end, io_len;
- struct badblock *bb;
- int rc;
-
- dax_begin = ndctl_dax_get_resource(dev->dax);
- if (dax_begin == ULLONG_MAX)
- return -ERANGE;
-
- dax_size = ndctl_dax_get_size(dev->dax);
- if (dax_size == ULLONG_MAX)
- return -ERANGE;
-
- dax_end = dax_begin + dax_size - 1;
-
- region_begin = ndctl_region_get_resource(dev->region);
- if (region_begin == ULLONG_MAX)
- return -ERANGE;
-
- ndctl_region_badblock_foreach(dev->region, bb) {
- unsigned long long bb_begin, bb_end, begin, end;
-
- bb_begin = region_begin + (bb->offset << 9);
- bb_end = bb_begin + (bb->len << 9) - 1;
-
- if (bb_end <= dax_begin || bb_begin >= dax_end)
- continue;
-
- if (bb_begin < dax_begin)
- begin = dax_begin;
- else
- begin = bb_begin;
-
- if (bb_end > dax_end)
- end = dax_end;
- else
- end = bb_end;
-
- offset = begin - dax_begin;
- size = end - begin + 1;
-
- /*
- * If end of I/O is before badblock or the offset of the
- * I/O is greater than the actual size of badblock range
- */
- if (dev->offset + len - 1 < offset || dev->offset > size)
- continue;
-
- io_begin = (dev->offset < offset) ? offset : dev->offset;
- if ((dev->offset + len) < (offset + size))
- io_end = offset + len;
- else
- io_end = offset + size;
-
- io_len = io_end - io_begin;
- io_begin += dax_begin;
- rc = clear_errors(ndctl_region_get_bus(dev->region),
- io_begin, io_len);
- if (rc < 0)
- return rc;
- }
-
- return 0;
-}
-
-static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev,
- uint64_t len, bool zero)
-{
- void *src, *dst;
- ssize_t rc, count = 0;
-
- if (zero && dst_dev->is_dax) {
- dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff;
- memset(dst, 0, len);
- pmem_persist(dst, len);
- rc = len;
- } else if (dst_dev->is_dax && src_dev->is_dax) {
- src = (uint8_t *)src_dev->mmap + src_dev->offset_diff;
- dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff;
- pmem_memcpy_persist(dst, src, len);
- rc = len;
- } else if (src_dev->is_dax) {
- src = (uint8_t *)src_dev->mmap + src_dev->offset_diff;
- if (dst_dev->offset) {
- rc = lseek(dst_dev->fd, dst_dev->offset, SEEK_SET);
- if (rc < 0) {
- rc = -errno;
- perror("lseek");
- return rc;
- }
- }
-
- do {
- rc = write(dst_dev->fd, (uint8_t *)src + count,
- len - count);
- if (rc == -1) {
- rc = -errno;
- perror("write");
- return rc;
- }
- count += rc;
- } while (count != (ssize_t)len);
- rc = count;
- if (rc != (ssize_t)len)
- printf("Requested size %lu larger than source.\n",
- len);
- } else if (dst_dev->is_dax) {
- dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff;
- if (src_dev->offset) {
- rc = lseek(src_dev->fd, src_dev->offset, SEEK_SET);
- if (rc < 0) {
- rc = -errno;
- perror("lseek");
- return rc;
- }
- }
-
- do {
- rc = read(src_dev->fd, (uint8_t *)dst + count,
- len - count);
- if (rc == -1) {
- rc = -errno;
- perror("pread");
- return rc;
- }
- /* end of file */
- if (rc == 0)
- break;
- count += rc;
- } while (count != (ssize_t)len);
- pmem_persist(dst, count);
- rc = count;
- if (rc != (ssize_t)len)
- printf("Requested size %lu larger than destination.\n", len);
- } else
- return -EINVAL;
-
- return rc;
-}
-
-static int do_io(struct daxctl_ctx *daxctl_ctx, struct ndctl_ctx *ndctl_ctx)
-{
- int i, dax_devs = 0;
- ssize_t rc;
-
- /* if we are zeroing the device, we just need output */
- i = io.zero ? 1 : 0;
- for (; i < 2; i++) {
- if (!io.dev[i].parm_path)
- continue;
- rc = find_dax_device(&io.dev[i], daxctl_ctx, ndctl_ctx, i);
- if (rc < 0)
- return rc;
-
- if (rc == 1)
- dax_devs++;
- }
-
- if (dax_devs == 0) {
- fail("No DAX devices for input or output, fail\n");
- return -ENODEV;
- }
-
- if (io.len == 0) {
- if (is_stdinout(&io.dev[0]))
- io.len = io.dev[1].size;
- else
- io.len = io.dev[0].size;
- }
-
- io.dev[1].direction = IO_WRITE;
- i = io.zero ? 1 : 0;
- for (; i < 2; i++) {
- if (!io.dev[i].parm_path)
- continue;
- rc = setup_device(&io.dev[i], io.len);
- if (rc < 0)
- return rc;
- }
-
- /* make sure we are DAX and we have ndctl related bits */
- if (io.dev[1].is_dax && io.dev[1].dax) {
- rc = clear_badblocks(&io.dev[1], io.len);
- if (rc < 0) {
- fail("Failed to clear badblocks on %s\n",
- io.dev[1].parm_path);
- return rc;
- }
- }
-
- rc = __do_io(&io.dev[1], &io.dev[0], io.len, io.zero);
- if (rc < 0) {
- fail("Failed to perform I/O: %ld\n", rc);
- return rc;
- }
-
- printf("Data copied %lu bytes to device %s\n",
- rc, io.dev[1].parm_path);
-
- return 0;
-}
-
-static void cleanup(void)
-{
- int i;
-
- for (i = 0; i < 2; i++) {
- if (is_stdinout(&io.dev[i]))
- continue;
- if (io.dev[i].mmap_size)
- munmap(io.dev[i].mmap, io.dev[i].mmap_size);
- close(io.dev[i].fd);
- }
-}
-
-int cmd_io(int argc, const char **argv, void *daxctl_ctx)
-{
- const char *len_str;
- const struct option options[] = {
- OPT_STRING('i', "input", &io.dev[0].parm_path, "in device",
- "input device/file"),
- OPT_STRING('o', "output", &io.dev[1].parm_path, "out device",
- "output device/file"),
- OPT_BOOLEAN('z', "zero", &io.zero, "zeroing the device"),
- OPT_STRING('l', "len", &len_str, "I/O length", "total length to perform the I/O"),
- OPT_U64('s', "seek", &io.dev[1].offset, "seek offset for output"),
- OPT_U64('k', "skip", &io.dev[0].offset, "skip offset for input"),
- };
- const char * const u[] = {
- "daxctl io [<options>]",
- NULL
- };
- int i, rc;
- struct ndctl_ctx *ndctl_ctx;
-
- argc = parse_options(argc, argv, options, u, 0);
- for (i = 0; i < argc; i++)
- fail("Unknown parameter \"%s\"\n", argv[i]);
-
- if (argc)
- usage_with_options(u, options);
-
- if (!io.dev[0].parm_path && !io.dev[1].parm_path) {
- usage_with_options(u, options);
- return 0;
- }
-
- if (len_str) {
- io.len = parse_size64(len_str);
- if (io.len == ULLONG_MAX) {
- fail("Incorrect len param entered: %s\n", len_str);
- return -EINVAL;
- }
- } else
- io.len = 0;
-
- if (!io.dev[0].parm_path) {
- io.dev[0].fd = STDIN_FILENO;
- io.dev[0].offset = 0;
- }
-
- if (!io.dev[1].parm_path) {
- io.dev[1].fd = STDOUT_FILENO;
- io.dev[1].offset = 0;
- }
-
- rc = ndctl_new(&ndctl_ctx);
- if (rc)
- return -ENOMEM;
-
- rc = do_io(daxctl_ctx, ndctl_ctx);
- if (rc < 0)
- goto out;
-
- rc = 0;
-out:
- cleanup();
- ndctl_unref(ndctl_ctx);
- return rc;
-}
4 years, 3 months
转发:/ 如何进行产品测试需求分析,有效控制测试输入?
by 方琳芸
linux-nvdimm//讨论主题
1. 如何进行测试需求分析,有效控制测试输入?
2. 如何根据公司不同的发展阶段确定相应的测试组织结构?确定测试投入?
3. 如何设计高质量的测试用例,确保测试的完备性?
4. 如何对测试缺陷进行深入分析,明确问题根源,减少测试重复?
5. 如何确保测试人员有效参与到产品开发前期,加深对产品的了解?
6. 如何规划测试人员的职业发展,提升测试人员的成就感?
详细 内容 请 阅 读 附 件
2018-3-6
4 years, 3 months