From: Santosh Sivaraj <santosh@fossix.org> To: Linux NVDIMM <linux-nvdimm@lists.01.org>, Vishal Verma <vishal.l.verma@intel.com>, "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>, Vaibhav Jain <vaibhav@linux.ibm.com>, Shivaprasad G Bhat <sbhat@linux.ibm.com>, Harish Sriram <harish@linux.ibm.com> Cc: Santosh Sivaraj <santosh@fossix.org> Subject: [ndctl RFC v4 2/3] Skip smart tests when non nfit devices present Date: Sun, 8 Nov 2020 17:50:15 +0530 Message-ID: <20201108122016.2090891-2-santosh@fossix.org> (raw) In-Reply-To: <20201108122016.2090891-1-santosh@fossix.org> Signed-off-by: Santosh Sivaraj <santosh@fossix.org> --- ndctl/lib/libndctl.c | 34 ++++++++++++++++++++++++++-------- test/libndctl.c | 3 ++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index d1f8e4e..26fc14c 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -815,8 +815,11 @@ static void parse_papr_flags(struct ndctl_dimm *dimm, char *flags) dimm->flags.f_restore = 1; else if (strcmp(start, "smart_notify") == 0) dimm->flags.f_smart = 1; + else if (strcmp(start, "save_fail") == 0) + dimm->flags.f_save = 1; start = end + 1; } + if (end != start) dbg(ctx, "%s: Flags:%s\n", ndctl_dimm_get_devname(dimm), flags); } @@ -1044,7 +1047,8 @@ NDCTL_EXPORT int ndctl_bus_is_papr_scm(struct ndctl_bus *bus) if (sysfs_read_attr(bus->ctx, bus->bus_buf, buf) < 0) return 0; - return (strcmp(buf, "ibm,pmemory") == 0); + return (strcmp(buf, "ibm,pmemory") == 0 || + strcmp(buf, "nvdimm_test") == 0); } /** @@ -1661,6 +1665,7 @@ static void populate_dimm_attributes(struct ndctl_dimm *dimm, char buf[SYSFS_ATTR_SIZE]; struct ndctl_ctx *ctx = dimm->bus->ctx; char *path = calloc(1, strlen(dimm_base) + 100); + int i; sprintf(path, "%s/phys_id", dimm_base); if (sysfs_read_attr(ctx, path, buf) < 0) @@ -1690,6 +1695,16 @@ static void populate_dimm_attributes(struct ndctl_dimm *dimm, dimm->manufacturing_location = b[2]; } } + + sprintf(path, "%s/format", dimm_base); + if (sysfs_read_attr(ctx, path, buf) == 0) + dimm->format[0] = strtoul(buf, NULL, 0); + for (i = 1; i < dimm->formats; i++) { + sprintf(path, "%s/format%d", dimm_base, i); + if (sysfs_read_attr(ctx, path, buf) == 0) + dimm->format[i] = strtoul(buf, NULL, 0); + } + sprintf(path, "%s/subsystem_vendor", dimm_base); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->subsystem_vendor_id = strtoul(buf, NULL, 0); @@ -1853,7 +1868,8 @@ static void *add_dimm(void *parent, int id, const char *dimm_base) if (!path) return NULL; - sprintf(path, "%s/nfit/formats", dimm_base); + sprintf(path, "%s%s/formats", dimm_base, + ndctl_bus_has_nfit(bus) ? "/nfit" : ""); if (sysfs_read_attr(ctx, path, buf) < 0) formats = 1; else @@ -1927,9 +1943,9 @@ static void *add_dimm(void *parent, int id, const char *dimm_base) else dimm->fwa_result = fwa_result_to_result(buf); + dimm->formats = formats; /* Check if the given dimm supports nfit */ if (ndctl_bus_has_nfit(bus)) { - dimm->formats = formats; rc = add_nfit_dimm(dimm, dimm_base); } else if (ndctl_bus_has_of_node(bus)) { rc = add_papr_dimm(dimm, dimm_base); @@ -2592,13 +2608,15 @@ static void *add_region(void *parent, int id, const char *region_base) goto err_read; region->num_mappings = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/range_index", region_base); - if (ndctl_bus_has_nfit(bus)) { - if (sysfs_read_attr(ctx, path, buf) < 0) + sprintf(path, "%s%s/range_index", region_base, + ndctl_bus_has_nfit(bus) ? "/nfit" : ""); + if (sysfs_read_attr(ctx, path, buf) < 0) { + if (ndctl_bus_has_nfit(bus)) goto err_read; - region->range_index = strtoul(buf, NULL, 0); + else + region->range_index = -1; } else - region->range_index = -1; + region->range_index = strtoul(buf, NULL, 0); sprintf(path, "%s/read_only", region_base); if (sysfs_read_attr(ctx, path, buf) < 0) diff --git a/test/libndctl.c b/test/libndctl.c index 994e0fa..b7e7b68 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2427,7 +2427,8 @@ static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm, * The kernel did not start emulating v1.2 namespace spec smart data * until 4.9. */ - if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 9, 0))) + if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 9, 0)) + || !ndctl_bus_has_nfit(bus)) dimm_commands &= ~((1 << ND_CMD_SMART) | (1 << ND_CMD_SMART_THRESHOLD)); -- 2.26.2 _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
next prev parent reply index Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-08 12:17 [RFC v4 0/1] PMEM device emulation without nfit depenency Santosh Sivaraj 2020-11-08 12:17 ` [RFC v4 1/1] testing/nvdimm: Add test module for non-nfit platforms Santosh Sivaraj 2020-11-08 12:20 ` [ndctl RFC v4 1/3] libndctl: test enablement for non-nfit devices Santosh Sivaraj 2020-11-08 12:20 ` Santosh Sivaraj [this message] 2020-12-07 23:24 ` [ndctl RFC v4 2/3] Skip smart tests when non nfit devices present Dan Williams 2020-11-08 12:20 ` [ndctl RFC v4 3/3] Use page size as alignment value Santosh Sivaraj 2020-12-07 23:26 ` Dan Williams 2020-12-07 23:07 ` [ndctl RFC v4 1/3] libndctl: test enablement for non-nfit devices Dan Williams 2020-12-09 2:09 ` Santosh Sivaraj 2020-11-20 18:42 ` [RFC v4 0/1] PMEM device emulation without nfit depenency Dan Williams
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20201108122016.2090891-2-santosh@fossix.org \ --to=santosh@fossix.org \ --cc=aneesh.kumar@linux.ibm.com \ --cc=harish@linux.ibm.com \ --cc=linux-nvdimm@lists.01.org \ --cc=sbhat@linux.ibm.com \ --cc=vaibhav@linux.ibm.com \ --cc=vishal.l.verma@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-NVDIMM Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-nvdimm/0 linux-nvdimm/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-nvdimm linux-nvdimm/ https://lore.kernel.org/linux-nvdimm \ linux-nvdimm@lists.01.org public-inbox-index linux-nvdimm Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.01.lists.linux-nvdimm AGPL code for this site: git clone https://public-inbox.org/public-inbox.git