tools/testing/nvdimm: Add command debug messages
authorDan Williams <dan.j.williams@intel.com>
Mon, 20 Jul 2020 22:07:51 +0000 (15:07 -0700)
committerVishal Verma <vishal.l.verma@intel.com>
Sun, 26 Jul 2020 01:34:47 +0000 (19:34 -0600)
Arrange the for nfit_test_ctl() path to dump command payloads similarly
to the acpi_nfit_ctl() path. This is useful for comparing the
sequence of command events between an emulated ACPI-NFIT platform and a
real one.

Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
tools/testing/nvdimm/test/nfit.c

index ddf9b30..9c6f475 100644 (file)
@@ -1192,6 +1192,29 @@ static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
        return i;
 }
 
+static void nfit_ctl_dbg(struct acpi_nfit_desc *acpi_desc,
+               struct nvdimm *nvdimm, unsigned int cmd, void *buf,
+               unsigned int len)
+{
+       struct nfit_test *t = container_of(acpi_desc, typeof(*t), acpi_desc);
+       unsigned int func = cmd;
+       unsigned int family = 0;
+
+       if (cmd == ND_CMD_CALL) {
+               struct nd_cmd_pkg *pkg = buf;
+
+               len = pkg->nd_size_in;
+               family = pkg->nd_family;
+               buf = pkg->nd_payload;
+               func = pkg->nd_command;
+       }
+       dev_dbg(&t->pdev.dev, "%s family: %d cmd: %d: func: %d input length: %d\n",
+                       nvdimm ? nvdimm_name(nvdimm) : "bus", family, cmd, func,
+                       len);
+       print_hex_dump_debug("nvdimm in  ", DUMP_PREFIX_OFFSET, 16, 4,
+                       buf, min(len, 256u), true);
+}
+
 static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
                struct nvdimm *nvdimm, unsigned int cmd, void *buf,
                unsigned int buf_len, int *cmd_rc)
@@ -1205,6 +1228,8 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
                cmd_rc = &__cmd_rc;
        *cmd_rc = 0;
 
+       nfit_ctl_dbg(acpi_desc, nvdimm, cmd, buf, buf_len);
+
        if (nvdimm) {
                struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
                unsigned long cmd_mask = nvdimm_cmd_mask(nvdimm);