All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ndctl: have daxdev-errors discover the ndbus
@ 2017-04-05 19:40 Dave Jiang
  2017-04-05 21:46 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Jiang @ 2017-04-05 19:40 UTC (permalink / raw)
  To: dan.j.williams; +Cc: linux-nvdimm

Implementation had static config and made assumption that the region in
nfit_test will be ndbus0. Adding code to discover the proper bus and also
pass onto daxdev-errors.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 test/daxdev-errors.c  |    9 +++++----
 test/daxdev-errors.sh |   11 ++++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/test/daxdev-errors.c b/test/daxdev-errors.c
index 687e593..d8d5324 100644
--- a/test/daxdev-errors.c
+++ b/test/daxdev-errors.c
@@ -234,7 +234,7 @@ static struct ndctl_dax * get_dax_region(struct ndctl_region *region)
 	return NULL;
 }
 
-static int test_daxdev_clear_error(void)
+static int test_daxdev_clear_error(const char *busname)
 {
 	int rc = 0, i;
 	struct ndctl_ctx *ctx;
@@ -277,8 +277,9 @@ static int test_daxdev_clear_error(void)
 
 	/* get badblocks */
 	if (snprintf(path, 256,
-			"/sys/devices/platform/%s/ndbus0/%s/badblocks",
+			"/sys/devices/platform/%s/%s/%s/badblocks",
 			NFIT_PROVIDER0,
+			busname,
 			ndctl_region_get_devname(region)) >= 256) {
 		fprintf(stderr, "%s: buffer too small!\n",
 				ndctl_region_get_devname(region));
@@ -343,7 +344,7 @@ int main(int argc, char *argv[])
 	int rc;
 	struct sigaction act;
 
-	if (argc < 1)
+	if (argc < 1 || argc > 3)
 		return -EINVAL;
 
 	memset(&act, 0, sizeof(act));
@@ -355,7 +356,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-	rc = test_daxdev_clear_error();
+	rc = test_daxdev_clear_error(argv[1]);
 
 	return rc;
 }
diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
index 1777210..ee07f81 100755
--- a/test/daxdev-errors.sh
+++ b/test/daxdev-errors.sh
@@ -5,6 +5,7 @@ NDCTL="../ndctl/ndctl"
 DAXCTL="../daxctl/daxctl"
 BUS="-b nfit_test.0"
 BUS1="-b nfit_test.1"
+json2var="s/[{}\",]//g; s/:/=/g"
 rc=77
 
 err() {
@@ -52,15 +53,19 @@ chardev=$(echo $json | jq ". | select(.mode == \"dax\") | .daxregion.devices[0].
 #    ]
 #  }
 
-read sector len < /sys/bus/platform/devices/nfit_test.0/ndbus0/region5/badblocks
+json1=$($NDCTL list $BUS)
+eval $(echo $json1 | sed -e "$json2var")
+
+echo "read /sys/bus/platform/devices/nfit_test.0/$dev/region5/badblocks"
+read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/region5/badblocks
 echo "sector: $sector len: $len"
 
 # run the daxdev-errors test
 test -x ./daxdev-errors
-./daxdev-errors
+./daxdev-errors $dev
 
 # check badblocks, should be empty
-if read sector len < /sys/bus/platform/devices/nfit_test.0/ndbus0/region5/badblocks; then
+if read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/region5/badblocks; then
 	echo "badblocks empty, expected"
 fi
 [ -n "$sector" ] && echo "fail: $LINENO" && exit 1

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ndctl: have daxdev-errors discover the ndbus
  2017-04-05 19:40 [PATCH] ndctl: have daxdev-errors discover the ndbus Dave Jiang
@ 2017-04-05 21:46 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2017-04-05 21:46 UTC (permalink / raw)
  To: Dave Jiang; +Cc: linux-nvdimm

On Wed, Apr 5, 2017 at 12:40 PM, Dave Jiang <dave.jiang@intel.com> wrote:
> Implementation had static config and made assumption that the region in
> nfit_test will be ndbus0. Adding code to discover the proper bus and also
> pass onto daxdev-errors.
>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  test/daxdev-errors.c  |    9 +++++----
>  test/daxdev-errors.sh |   11 ++++++++---
>  2 files changed, 13 insertions(+), 7 deletions(-)
>
[..]
> diff --git a/test/daxdev-errors.sh b/test/daxdev-errors.sh
> index 1777210..ee07f81 100755
> --- a/test/daxdev-errors.sh
> +++ b/test/daxdev-errors.sh
> @@ -5,6 +5,7 @@ NDCTL="../ndctl/ndctl"
>  DAXCTL="../daxctl/daxctl"
>  BUS="-b nfit_test.0"
>  BUS1="-b nfit_test.1"
> +json2var="s/[{}\",]//g; s/:/=/g"
>  rc=77
>
>  err() {
> @@ -52,15 +53,19 @@ chardev=$(echo $json | jq ". | select(.mode == \"dax\") | .daxregion.devices[0].
>  #    ]
>  #  }
>
> -read sector len < /sys/bus/platform/devices/nfit_test.0/ndbus0/region5/badblocks
> +json1=$($NDCTL list $BUS)
> +eval $(echo $json1 | sed -e "$json2var")
> +
> +echo "read /sys/bus/platform/devices/nfit_test.0/$dev/region5/badblocks"
> +read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/region5/badblocks
>  echo "sector: $sector len: $len"
>
>  # run the daxdev-errors test
>  test -x ./daxdev-errors
> -./daxdev-errors
> +./daxdev-errors $dev
>
>  # check badblocks, should be empty
> -if read sector len < /sys/bus/platform/devices/nfit_test.0/ndbus0/region5/badblocks; then
> +if read sector len < /sys/bus/platform/devices/nfit_test.0/$dev/region5/badblocks; then

The region numbers are dynamic, so region5 might not be what you
expect depending on the system configuration and what buses get loaded
first. You can use ndctl list to find the expected region explicitly.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-05 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-05 19:40 [PATCH] ndctl: have daxdev-errors discover the ndbus Dave Jiang
2017-04-05 21:46 ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.