diff mbox series

[daxctl,v2,4/5] daxctl: add align support in create-device

Message ID 20201216224833.6229-5-joao.m.martins@oracle.com (mailing list archive)
State New, archived
Headers show
Series daxctl: device align support | expand

Commit Message

Joao Martins Dec. 16, 2020, 10:48 p.m. UTC
Allow changing devices alignment when creating
a new child device.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
 Documentation/daxctl/daxctl-create-device.txt | 8 ++++++++
 daxctl/device.c                               | 8 ++++++++
 2 files changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/daxctl/daxctl-create-device.txt b/Documentation/daxctl/daxctl-create-device.txt
index 648d2541f833..adc7b395125e 100644
--- a/Documentation/daxctl/daxctl-create-device.txt
+++ b/Documentation/daxctl/daxctl-create-device.txt
@@ -87,6 +87,14 @@  OPTIONS
 
 	The size must be a multiple of the region alignment.
 
+-a::
+--align::
+	Applications that want to establish dax memory mappings with
+	page table entries greater than system base page size (4K on
+	x86) need a device that is sufficiently aligned. This defaults
+	to 2M. Note that "devdax" mode enforces all mappings to be
+	aligned to this value, i.e. it fails unaligned mapping attempts.
+
 -u::
 --human::
 	By default the command will output machine-friendly raw-integer
diff --git a/daxctl/device.c b/daxctl/device.c
index a5394577908d..3c2d4e3d8b48 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -216,6 +216,8 @@  static const char *parse_device_options(int argc, const char **argv,
 	case ACTION_CREATE:
 		if (param.size)
 			size = __parse_size64(param.size, &units);
+		if (param.align)
+			align = __parse_size64(param.align, &units);
 		/* fall through */
 	case ACTION_ONLINE:
 		if (param.no_movable)
@@ -538,6 +540,12 @@  static int do_create(struct daxctl_region *region, long long val,
 	if (val <= 0)
 		return -ENOSPC;
 
+	if (align > 0) {
+		rc = daxctl_dev_set_align(dev, align);
+		if (rc < 0)
+			return rc;
+	}
+
 	rc = daxctl_dev_set_size(dev, val);
 	if (rc < 0)
 		return rc;