Commit eb9d77a9 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

test/nvme: allocate aligned memory in unit tests



Match the expected alignment for nvme_alloc_request() and nvme_malloc()
to allow optimized memory copy code to work even in the unit tests.

Change-Id: I546692a6df9615a12a8209618fb6159a9c9e426b
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 88669436
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -47,7 +47,10 @@ struct spdk_pci_device;
static inline void *
nvme_malloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
{
	void *buf = calloc(1, size);
	void *buf = NULL;
	if (posix_memalign(&buf, align, size)) {
		return NULL;
	}
	*phys_addr = (uint64_t)buf;
	return buf;
}
@@ -74,7 +77,9 @@ uint64_t nvme_vtophys(void *buf);
#define nvme_alloc_request(bufp)	\
do					\
	{				\
		*bufp = malloc(sizeof(struct nvme_request));	\
		if (posix_memalign((void **)(bufp), 64, sizeof(struct nvme_request))) {	\
			*(bufp) = NULL;	\
		}			\
	}				\
	while (0)