@@ -88,3 +88,8 @@ to /etc/depmod.d with the following contents:
`override nd_btt * extra`
`override nd_e820 * extra`
`override nd_pmem * extra`
+
+The nfit_test module emulates pmem with memory allocated via vmalloc().
+One of the side effects is that this breaks 'physically contiguous'
+assumptions in the driver. Use the '--align=4K option to 'ndctl
+create-namespace' to avoid these corner case scenarios.
@@ -563,6 +563,19 @@ static int validate_namespace_options(struct ndctl_region *region,
return -ENXIO;
}
+ /*
+ * Fallback to a 4K default alignment if the region is
+ * not 2MB (typical default) aligned. This mainly helps
+ * the nfit_test use case where it is backed by vmalloc
+ * memory.
+ */
+ if (param.align_default && (ndctl_region_get_resource(region)
+ & (SZ_2M - 1))) {
+ debug("%s: falling back to a 4K alignment\n",
+ region_name);
+ p->align = SZ_4K;
+ }
+
switch (p->align) {
case SZ_4K:
case SZ_2M:
Vishal reports: (after ndctl create-namepsace -t pmem --bus=nfit_test.0) I'm seeing that it is created as a memory mode namespace, but after cycling it, it comes up as raw and dmesg has: pfn7.0: bad offset: 0x2af000 dax disabled align: 0x200000 This arises from the hacks that nfit_test uses to emulate pmem with vmalloc(). Setting the alignment to 4K avoids these problems. For casual testing try to detect the nfit_test case and adjust the default alignment accordingly. Reported-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- README.md | 5 +++++ ndctl/namespace.c | 13 +++++++++++++ 2 files changed, 18 insertions(+)