Skip to contentSkip to conversation

selftests/powerpc: Add NX-GZIP engine testcase

PATCH Superseded Raphael Moreira Zinsly 2 participants 8 messages Apr 13, 2020 – Apr 17, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover selftests/powerpc: Add NX-GZIP engine testcase

This patch series are intended to test the POWER9 Nest Accelerator (NX) GZIP engine that is being introduced by
https://lists.ozlabs.org/pipermail/linuxppc-dev/2020-March/205659.html
More information about how to access the NX can be found in that patch, also a complete userspace library and more documentation can be found at:
https://github.com/libnxz/power-gzip

Changes in V3:
- Defined a macro and increased the number of retries for page faults to work in system with less memory, mentioning the issue on README.
- Returned to use volatile on the touch pages routine and a few structs on inc/nxu.h as they are handled by hardware and some compilers could optmize it wrongly.
- Moved common functions to gzip_vas.c.

#1 lore raw

PATCH v3 1/5 selftests/powerpc: Add header files for GZIP engine test

Add files to access the powerpc NX-GZIP engine in user space.

---
 .../selftests/powerpc/nx-gzip/inc/crb.h       | 159 ++++++++++++++++++
 .../selftests/powerpc/nx-gzip/inc/nx-gzip.h   |  27 +++
 .../powerpc/nx-gzip/inc/nx-helpers.h          |  54 ++++++
 .../selftests/powerpc/nx-gzip/inc/nx.h        |  38 +++++
 4 files changed, 278 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/crb.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nx.h
tools/testing/selftests/powerpc/nx-gzip/inc/crb.h new file +159 -0
new file mode 100644
index 000000000000..9056e3dc1831
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __CRB_H
+#define __CRB_H
+#include <linux/types.h>
+#include "nx.h"
+
+typedef unsigned char u8;
+typedef unsigned int u32;
+typedef unsigned long long u64;
+
+/* CCW 842 CI/FC masks
+ * NX P8 workbook, section 4.3.1, figure 4-6
+ * "CI/FC Boundary by NX CT type"
+ */
+#define CCW_CI_842              (0x00003ff8)
+#define CCW_FC_842              (0x00000007)
+
+/* Chapter 6.5.8 Coprocessor-Completion Block (CCB) */
+
+#define CCB_VALUE		(0x3fffffffffffffff)
+#define CCB_ADDRESS		(0xfffffffffffffff8)
+#define CCB_CM			(0x0000000000000007)
+#define CCB_CM0			(0x0000000000000004)
+#define CCB_CM12		(0x0000000000000003)
+
+#define CCB_CM0_ALL_COMPLETIONS	(0x0)
+#define CCB_CM0_LAST_IN_CHAIN	(0x4)
+#define CCB_CM12_STORE		(0x0)
+#define CCB_CM12_INTERRUPT	(0x1)
+
+#define CCB_SIZE		(0x10)
+#define CCB_ALIGN		CCB_SIZE
+
+struct coprocessor_completion_block {
+	__be64 value;
+	__be64 address;
+} __aligned(CCB_ALIGN);
+
+
+/* Chapter 6.5.7 Coprocessor-Status Block (CSB) */
+
+#define CSB_V			(0x80)
+#define CSB_F			(0x04)
+#define CSB_CH			(0x03)
+#define CSB_CE_INCOMPLETE	(0x80)
+#define CSB_CE_TERMINATION	(0x40)
+#define CSB_CE_TPBC		(0x20)
+
+#define CSB_CC_SUCCESS		(0)
+#define CSB_CC_INVALID_ALIGN	(1)
+#define CSB_CC_OPERAND_OVERLAP	(2)
+#define CSB_CC_DATA_LENGTH	(3)
+#define CSB_CC_TRANSLATION	(5)
+#define CSB_CC_PROTECTION	(6)
+#define CSB_CC_RD_EXTERNAL	(7)
+#define CSB_CC_INVALID_OPERAND	(8)
+#define CSB_CC_PRIVILEGE	(9)
+#define CSB_CC_INTERNAL		(10)
+#define CSB_CC_WR_EXTERNAL	(12)
+#define CSB_CC_NOSPC		(13)
+#define CSB_CC_EXCESSIVE_DDE	(14)
+#define CSB_CC_WR_TRANSLATION	(15)
+#define CSB_CC_WR_PROTECTION	(16)
+#define CSB_CC_UNKNOWN_CODE	(17)
+#define CSB_CC_ABORT		(18)
+#define CSB_CC_TRANSPORT	(20)
+#define CSB_CC_SEGMENTED_DDL	(31)
+#define CSB_CC_PROGRESS_POINT	(32)
+#define CSB_CC_DDE_OVERFLOW	(33)
+#define CSB_CC_SESSION		(34)
+#define CSB_CC_PROVISION	(36)
+#define CSB_CC_CHAIN		(37)
+#define CSB_CC_SEQUENCE		(38)
+#define CSB_CC_HW		(39)
+
+#define CSB_SIZE		(0x10)
+#define CSB_ALIGN		CSB_SIZE
+
+struct coprocessor_status_block {
+	u8 flags;
+	u8 cs;
+	u8 cc;
+	u8 ce;
+	__be32 count;
+	__be64 address;
+} __aligned(CSB_ALIGN);
+
+
+/* Chapter 6.5.10 Data-Descriptor List (DDL)
+ * each list contains one or more Data-Descriptor Entries (DDE)
+ */
+
+#define DDE_P			(0x8000)
+
+#define DDE_SIZE		(0x10)
+#define DDE_ALIGN		DDE_SIZE
+
+struct data_descriptor_entry {
+	__be16 flags;
+	u8 count;
+	u8 index;
+	__be32 length;
+	__be64 address;
+} __aligned(DDE_ALIGN);
+
+
+/* Chapter 6.5.2 Coprocessor-Request Block (CRB) */
+
+#define CRB_SIZE		(0x80)
+#define CRB_ALIGN		(0x100) /* Errata: requires 256 alignment */
+
+
+/* Coprocessor Status Block field
+ *   ADDRESS	address of CSB
+ *   C		CCB is valid
+ *   AT		0 = addrs are virtual, 1 = addrs are phys
+ *   M		enable perf monitor
+ */
+#define CRB_CSB_ADDRESS		(0xfffffffffffffff0)
+#define CRB_CSB_C		(0x0000000000000008)
+#define CRB_CSB_AT		(0x0000000000000002)
+#define CRB_CSB_M		(0x0000000000000001)
+
+struct coprocessor_request_block {
+	__be32 ccw;
+	__be32 flags;
+	__be64 csb_addr;
+
+	struct data_descriptor_entry source;
+	struct data_descriptor_entry target;
+
+	struct coprocessor_completion_block ccb;
+
+	u8 reserved[48];
+
+	struct coprocessor_status_block csb;
+} __aligned(CRB_ALIGN);
+
+#define crb_csb_addr(c)         __be64_to_cpu(c->csb_addr)
+#define crb_nx_fault_addr(c)    __be64_to_cpu(c->stamp.nx.fault_storage_addr)
+#define crb_nx_flags(c)         c->stamp.nx.flags
+#define crb_nx_fault_status(c)  c->stamp.nx.fault_status
+#define crb_nx_pswid(c)		c->stamp.nx.pswid
+
+
+/* RFC02167 Initiate Coprocessor Instructions document
+ * Chapter 8.2.1.1.1 RS
+ * Chapter 8.2.3 Coprocessor Directive
+ * Chapter 8.2.4 Execution
+ *
+ * The CCW must be converted to BE before passing to icswx()
+ */
+
+#define CCW_PS                  (0xff000000)
+#define CCW_CT                  (0x00ff0000)
+#define CCW_CD                  (0x0000ffff)
+#define CCW_CL                  (0x0000c000)
+
+#endif
tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h new file +27 -0
new file mode 100644
index 000000000000..75482c45574d
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Copyright 2020 IBM Corp.
+ *
+ */
+
+#ifndef _UAPI_MISC_VAS_H
+#define _UAPI_MISC_VAS_H
+
+#include <asm/ioctl.h>
+
+#define VAS_FLAGS_PIN_WINDOW	0x1
+#define VAS_FLAGS_HIGH_PRI	0x2
+
+#define VAS_FTW_SETUP		_IOW('v', 1, struct vas_gzip_setup_attr)
+#define VAS_842_TX_WIN_OPEN	_IOW('v', 2, struct vas_gzip_setup_attr)
+#define VAS_GZIP_TX_WIN_OPEN	_IOW('v', 0x20, struct vas_gzip_setup_attr)
+
+struct vas_gzip_setup_attr {
+	int32_t		version;
+	int16_t		vas_id;
+	int16_t		reserved1;
+	int64_t		flags;
+	int64_t		reserved2[6];
+};
+
+#endif /* _UAPI_MISC_VAS_H */
tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h new file +54 -0

54 lines not on this page · raw message

tools/testing/selftests/powerpc/nx-gzip/inc/nx.h new file +38 -0
new file mode 100644
index 000000000000..1ae8348b59d6
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Copyright 2020 IBM Corp.
+ *
+ */
+#ifndef _NX_H
+#define _NX_H
+
+#include <stdbool.h>
+
+#define	NX_FUNC_COMP_842	1
+#define NX_FUNC_COMP_GZIP	2
+
+#ifndef __aligned
+#define __aligned(x)	__attribute__((aligned(x)))
+#endif
+
+struct nx842_func_args {
+	bool use_crc;
+	bool decompress;		/* true decompress; false compress */
+	bool move_data;
+	int timeout;			/* seconds */
+};
+
+struct nxbuf_t {
+	int len;
+	char *buf;
+};
+
+/* @function should be EFT (aka 842), GZIP etc */
+extern void *nx_function_begin(int function, int pri);
+
+extern int nx_function(void *handle, struct nxbuf_t *in, struct nxbuf_t *out,
+			void *arg);
+
+extern int nx_function_end(void *handle);
+
+#endif	/* _NX_H */
Signature · 1 line
2.21.0
#2 lore raw

Re: [PATCH V3 1/5] selftests/powerpc: Add header files for GZIP engine test

Hi Raphael,

Some comments below ...

Quoted 4 lines · Raphael Moreira Zinsly

Add files to access the powerpc NX-GZIP engine in user space.

Quoted 10 lines
---
 .../selftests/powerpc/nx-gzip/inc/crb.h       | 159 ++++++++++++++++++
 .../selftests/powerpc/nx-gzip/inc/nx-gzip.h   |  27 +++
 .../powerpc/nx-gzip/inc/nx-helpers.h          |  54 ++++++
 .../selftests/powerpc/nx-gzip/inc/nx.h        |  38 +++++
 4 files changed, 278 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/crb.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nx.h

It's standard to call the directory "include", can you rename it please?

Quoted 6 lines
tools/testing/selftests/powerpc/nx-gzip/inc/crb.h new file +0 -0
new file mode 100644
index 000000000000..9056e3dc1831

tools/testing/selftests/powerpc/nx-gzip/inc/crb.h line 9

Quoted 9 lines
tools/testing/selftests/powerpc/nx-gzip/inc/crb.h new file +9 -0
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __CRB_H
+#define __CRB_H
+#include <linux/types.h>
+#include "nx.h"
+
+typedef unsigned char u8;
+typedef unsigned int u32;
+typedef unsigned long long u64;

The vast bulk of the code uses the stdint.h types, so it would be preferable to either use those throughout or use the kernel types throughout, eg. __u8, __u32, __u64, rather than defining your own here.

...

Quoted 6 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h new file +0 -0
new file mode 100644
index 000000000000..75482c45574d

tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h line 8

Quoted 8 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h new file +8 -0
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Copyright 2020 IBM Corp.
+ *
+ */
+
+#ifndef _UAPI_MISC_VAS_H
+#define _UAPI_MISC_VAS_H

That's the wrong include guard.

Quoted 7 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h new file +7 -0
+
+#include <asm/ioctl.h>
+
+#define VAS_FLAGS_PIN_WINDOW	0x1
+#define VAS_FLAGS_HIGH_PRI	0x2
+
+#define VAS_FTW_SETUP		_IOW('v', 1, struct vas_gzip_setup_attr)

tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h line 25

Quoted 10 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h new file +10 -0
+#define VAS_842_TX_WIN_OPEN	_IOW('v', 2, struct vas_gzip_setup_attr)
+#define VAS_GZIP_TX_WIN_OPEN	_IOW('v', 0x20, struct vas_gzip_setup_attr)
+
+struct vas_gzip_setup_attr {
+	int32_t		version;
+	int16_t		vas_id;
+	int16_t		reserved1;
+	int64_t		flags;
+	int64_t		reserved2[6];
+};

This doesn't match the kernel header.

In fact you should just be able to symlink the uapi header.

Quoted 19 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-gzip.h new file +1 -0
+#endif /* _UAPI_MISC_VAS_H */
tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h new file +12 -0
new file mode 100644
index 000000000000..e0d68914c941
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <sys/time.h>
+#include <asm/byteorder.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include "crb.h"
+
+#define cpu_to_be32		__cpu_to_be32
+#define cpu_to_be64		__cpu_to_be64
+#define be32_to_cpu		__be32_to_cpu
+#define be64_to_cpu		__be64_to_cpu
+

tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h line 22

Quoted 10 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h new file +10 -0
+/*
+ * Several helpers/macros below were copied from the tree
+ * (kernel.h, nx-842.h, nx-ftw.h, asm-compat.h etc)
+ */
+
+/* from kernel.h */
+#define IS_ALIGNED(x, a)	(((x) & ((typeof(x))(a) - 1)) == 0)
+#define __round_mask(x, y)	((__typeof__(x))((y)-1))
+#define round_up(x, y)		((((x)-1) | __round_mask(x, y))+1)
+#define round_down(x, y)	((x) & ~__round_mask(x, y))

Unused?

tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h line 24

Quoted 1 line
tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h new file +1 -0
+#define min_t(t, x, y)	((x) < (y) ? (x) : (y))

Unused?

tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h line 31

Quoted 7 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h new file +7 -0
+/*
+ * Get/Set bit fields. (from nx-842.h)
+ */
+#define GET_FIELD(m, v)         (((v) & (m)) >> MASK_LSH(m))
+#define MASK_LSH(m)             (__builtin_ffsl(m) - 1)
+#define SET_FIELD(m, v, val)    \
+		(((v) & ~(m)) | ((((typeof(v))(val)) << MASK_LSH(m)) & (m)))

Unused?

tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h line 44

Quoted 13 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h new file +13 -0
+
+/* From asm-compat.h */
+#define __stringify_in_c(...)	#__VA_ARGS__
+#define stringify_in_c(...)	__stringify_in_c(__VA_ARGS__) " "
+
+#define	pr_debug
+#define	pr_debug_ratelimited	printf
+#define	pr_err			printf
+#define	pr_err_ratelimited	printf
+
+#define WARN_ON_ONCE(x)		do {if (x) \
+				printf("WARNING: %s:%d\n", __func__, __LINE__)\
+				} while (0)

Unused?

tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h line 54

Quoted 9 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx-helpers.h new file +8 -0
+extern void dump_buffer(char *msg, char *buf, int len);
+extern void *alloc_aligned_mem(int len, int align, char *msg);
+extern void get_payload(char *buf, int len);
+extern void time_add(struct timeval *in, int seconds, struct timeval *out);
 
+extern bool time_after(struct timeval *a, struct timeval *b);
+extern long time_delta(struct timeval *a, struct timeval *b);
+extern void dump_dde(struct data_descriptor_entry *dde, char *msg);
+extern void copy_paste_crb_data(struct coprocessor_request_block *crb);

None of those externs appear to exist or be used.

Quoted 32 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx.h new file +26 -0
new file mode 100644
index 000000000000..1ae8348b59d6
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * Copyright 2020 IBM Corp.
+ *
+ */
+#ifndef _NX_H
+#define _NX_H
+
+#include <stdbool.h>
+
+#define	NX_FUNC_COMP_842	1
+#define NX_FUNC_COMP_GZIP	2
+
+#ifndef __aligned
+#define __aligned(x)	__attribute__((aligned(x)))
+#endif
+
+struct nx842_func_args {
+	bool use_crc;
+	bool decompress;		/* true decompress; false compress */
+	bool move_data;
+	int timeout;			/* seconds */
+};
+
+struct nxbuf_t {
+	int len;

tools/testing/selftests/powerpc/nx-gzip/inc/nx.h line 36

Quoted 10 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx.h new file +10 -0
+	char *buf;
+};
+
+/* @function should be EFT (aka 842), GZIP etc */
+extern void *nx_function_begin(int function, int pri);
+
+extern int nx_function(void *handle, struct nxbuf_t *in, struct nxbuf_t *out,
+			void *arg);
+
+extern int nx_function_end(void *handle);

You don't need extern on function declarations in headers.

Quoted 4 lines
tools/testing/selftests/powerpc/nx-gzip/inc/nx.h new file +2 -0
+
+#endif	/* _NX_H */
Signature · 1 line
2.21.0

cheers

#3 lore raw

PATCH v3 2/5 selftests/powerpc: Add header files for NX compresion/decompression

In reply to Raphael Moreira Zinsly

Add files to be able to compress and decompress files using the powerpc NX-GZIP engine.

---
 .../powerpc/nx-gzip/inc/copy-paste.h          |  54 ++
 .../selftests/powerpc/nx-gzip/inc/nx_dbg.h    |  95 +++
 .../selftests/powerpc/nx-gzip/inc/nxu.h       | 650 ++++++++++++++++++
 3 files changed, 799 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/copy-paste.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nx_dbg.h
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/inc/nxu.h
tools/testing/selftests/powerpc/nx-gzip/inc/copy-paste.h new file +54 -0
new file mode 100644
index 000000000000..107139b6c7df
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "nx-helpers.h"
+
+/*
+ * Macros taken from arch/powerpc/include/asm/ppc-opcode.h and other
+ * header files.
+ */
+#define ___PPC_RA(a)    (((a) & 0x1f) << 16)
+#define ___PPC_RB(b)    (((b) & 0x1f) << 11)
+
+#define PPC_INST_COPY                   0x7c20060c
+#define PPC_INST_PASTE                  0x7c20070d
+
+#define PPC_COPY(a, b)          stringify_in_c(.long PPC_INST_COPY | \
+						___PPC_RA(a) | ___PPC_RB(b))
+#define PPC_PASTE(a, b)         stringify_in_c(.long PPC_INST_PASTE | \
+						___PPC_RA(a) | ___PPC_RB(b))
+#define CR0_SHIFT	28
+#define CR0_MASK	0xF
+/*
+ * Copy/paste instructions:
+ *
+ *	copy RA,RB
+ *		Copy contents of address (RA) + effective_address(RB)
+ *		to internal copy-buffer.
+ *
+ *	paste RA,RB
+ *		Paste contents of internal copy-buffer to the address
+ *		(RA) + effective_address(RB)
+ */
+static inline int vas_copy(void *crb, int offset)
+{
+	asm volatile(PPC_COPY(%0, %1)";"
+		:
+		: "b" (offset), "b" (crb)
+		: "memory");
+
+	return 0;
+}
+
+static inline int vas_paste(void *paste_address, int offset)
+{
+	u32 cr;
+
+	cr = 0;
+	asm volatile(PPC_PASTE(%1, %2)";"
+		"mfocrf %0, 0x80;"
+		: "=r" (cr)
+		: "b" (offset), "b" (paste_address)
+		: "memory", "cr0");
+
+	return (cr >> CR0_SHIFT) & CR0_MASK;
+}
tools/testing/selftests/powerpc/nx-gzip/inc/nx_dbg.h new file +95 -0

95 lines not on this page · raw message

tools/testing/selftests/powerpc/nx-gzip/inc/nxu.h new file +650 -0

650 lines not on this page · raw message

Signature · 1 line
2.21.0
#4 lore raw

PATCH v3 3/5 selftests/powerpc: Add NX-GZIP engine compress testcase

In reply to Raphael Moreira Zinsly

Add a compression testcase for the powerpc NX-GZIP engine.

---
 .../selftests/powerpc/nx-gzip/Makefile        |  21 +
 .../selftests/powerpc/nx-gzip/gzfht_test.c    | 432 ++++++++++++++++++
 .../selftests/powerpc/nx-gzip/gzip_vas.c      | 316 +++++++++++++
 3 files changed, 769 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/Makefile
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/gzip_vas.c
tools/testing/selftests/powerpc/nx-gzip/Makefile new file +21 -0
new file mode 100644
index 000000000000..ab903f63bbbd
@@ -0,0 +1,21 @@
+CC = gcc
+CFLAGS = -O3
+INC = ./inc
+SRC = gzfht_test.c
+OBJ = $(SRC:.c=.o)
+TESTS = gzfht_test
+EXTRA_SOURCES = gzip_vas.c
+
+all:	$(TESTS)
+
+$(OBJ): %.o: %.c
+	$(CC) $(CFLAGS) -I$(INC) -c $<
+
+$(TESTS): $(OBJ)
+	$(CC) $(CFLAGS) -I$(INC) -o $@ [email protected] $(EXTRA_SOURCES)
+
+run_tests: $(TESTS)
+	./gzfht_test gzip_vas.c
+
+clean:
+	rm -f $(TESTS) *.o *~ *.gz
tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c new file +432 -0

432 lines not on this page · raw message

tools/testing/selftests/powerpc/nx-gzip/gzip_vas.c new file +316 -0

316 lines not on this page · raw message

Signature · 1 line
2.21.0
#5 lore raw

Re: [PATCH V3 3/5] selftests/powerpc: Add NX-GZIP engine compress testcase

Hi Raphael,

Some comments below ...

Quoted 4 lines · Raphael Moreira Zinsly

Add a compression testcase for the powerpc NX-GZIP engine.

Quoted 8 lines
---
 .../selftests/powerpc/nx-gzip/Makefile        |  21 +
 .../selftests/powerpc/nx-gzip/gzfht_test.c    | 432 ++++++++++++++++++
 .../selftests/powerpc/nx-gzip/gzip_vas.c      | 316 +++++++++++++
 3 files changed, 769 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/Makefile
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/gzip_vas.c

You haven't added this to tools/testing/selftests/powerpc/Makefile, which means it's not actually built as part of the selftests build. Which makes it not really a selftest.

We need:

tools/testing/selftests/powerpc/Makefile +1 -0
index 644770c3b754..0830e63818c1 100644
@@ -19,6 +19,7 @@ SUB_DIRS = alignment		\
 	   copyloops		\
 	   dscr			\
 	   mm			\
+	   nx-gzip		\
 	   pmu			\
 	   signal		\
 	   primitives		\
Quoted 17 lines
tools/testing/selftests/powerpc/nx-gzip/Makefile new file +11 -0
new file mode 100644
index 000000000000..ab903f63bbbd
@@ -0,0 +1,21 @@
+CC = gcc
+CFLAGS = -O3
+INC = ./inc
+SRC = gzfht_test.c
+OBJ = $(SRC:.c=.o)
+TESTS = gzfht_test
+EXTRA_SOURCES = gzip_vas.c
+
+all:	$(TESTS)
+
+$(OBJ): %.o: %.c

tools/testing/selftests/powerpc/nx-gzip/Makefile line 21

Quoted 10 lines
tools/testing/selftests/powerpc/nx-gzip/Makefile new file +10 -0
+	$(CC) $(CFLAGS) -I$(INC) -c $<
+
+$(TESTS): $(OBJ)
+	$(CC) $(CFLAGS) -I$(INC) -o $@ [email protected] $(EXTRA_SOURCES)
+
+run_tests: $(TESTS)
+	./gzfht_test gzip_vas.c
+
+clean:
+	rm -f $(TESTS) *.o *~ *.gz

We have an existing system for Makefiles for selftests.

Also the test programs need to be able to just run standalone with no arguments in order for the selftest machinery to run them correctly.

The patch below should integrate the tests properly and add a wrapper script to run the tests.

However I'm still getting some warnings from the build:

gunz_test.c: In function ‘decompress_file’:
gunz_test.c:914:12: error: ‘total_out’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

    914 |  total_out = total_out + tpbc;
        |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
  gunz_test.c:287:11: error: ‘last_comp_ratio’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    287 |  uint64_t last_comp_ratio; /* 1000 max */
        |           ^~~~~~~~~~~~~~~
  gunz_test.c:519:8: error: ‘outf’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    519 |    n = fwrite(fifo_out, 1, write_sz, outf);
        |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  gunz_test.c:68:20: error: ‘inpf’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     68 | #define GETINPC(X) fgetc(X)
        |                    ^~~~~
  gunz_test.c:274:8: note: ‘inpf’ was declared here
    274 |  FILE *inpf;
        |        ^~~~

cc1: all warnings being treated as errors
make[2]: *** [../../lib.mk:142: /home/michael/build/adhoc/kselftest/powerpc/nx-gzip/gunz_test] Error 1

Please send a fix for those. If you just need to initialise them to 0 or NULL at the beginning of the function that's fine by me.

cheers

tools/testing/selftests/powerpc/nx-gzip/Makefile +5 -19
index 82abc19a49a0..387ad3857c9d 100644
@@ -1,22 +1,8 @@
-CC = gcc
-CFLAGS = -O3
-INC = ./inc
-SRC = gzfht_test.c gunz_test.c
-OBJ = $(SRC:.c=.o)
-TESTS = gzfht_test gunz_test
-EXTRA_SOURCES = gzip_vas.c
+CFLAGS += -O3 -m64 -I./inc
 
-all:   $(TESTS)
+TEST_GEN_FILES := gzfht_test gunz_test
+TEST_PROGS := nx-gzip-test.sh
 
-$(OBJ): %.o: %.c
-       $(CC) $(CFLAGS) -I$(INC) -c $<
+include ../../lib.mk
 
-$(TESTS): $(OBJ)
-       $(CC) $(CFLAGS) -I$(INC) -o $@ [email protected] $(EXTRA_SOURCES)
-
-run_tests: $(TESTS)
-       ./gzfht_test gzip_vas.c
-       ./gunz_test gzip_vas.c.nx.gz
-
-clean:
-       rm -f $(TESTS) *.o *~ *.gz *.gunzip
+$(TEST_GEN_FILES): gzip_vas.c
tools/testing/selftests/powerpc/nx-gzip/gunz_test.c +3 -1
index 94cb79616225..8196cf56df7a 100644
@@ -36,6 +36,9 @@
  * vas:      virtual accelerator switch; the user mode interface
  */
 
+#define _ISOC11_SOURCE // For aligned_alloc()
+#define _DEFAULT_SOURCE        // For endian.h
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -242,7 +245,6 @@ static int nx_touch_pages_dde(struct nx_dde_t *ddep, long buf_sz, long page_sz,
 static int nx_submit_job(struct nx_dde_t *src, struct nx_dde_t *dst,
                         struct nx_gzip_crb_cpb_t *cmdp, void *handle)
 {
-       int cc;
        uint64_t csbaddr;
 
        memset((void *)&cmdp->crb.csb, 0, sizeof(cmdp->crb.csb));
tools/testing/selftests/powerpc/nx-gzip/gzfht_test.c +2 -1
index e60f743e2c6b..a3d90b2b1591 100644
@@ -41,6 +41,8 @@
  * vas:      virtual accelerator switch; the user mode interface
  */
 
+#define _ISOC11_SOURCE // For aligned_alloc()
+#define _DEFAULT_SOURCE        // For endian.h
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -75,7 +77,6 @@ static int compress_fht_sample(char *src, uint32_t srclen, char *dst,
                                uint32_t dstlen, int with_count,
                                struct nx_gzip_crb_cpb_t *cmdp, void *handle)
 {
-       int cc;
        uint32_t fc;
 
        assert(!!cmdp);
tools/testing/selftests/powerpc/nx-gzip/nx-gzip-test.sh new file +45 -0

45 lines not on this page · raw message

#6 lore raw

PATCH v3 4/5 selftests/powerpc: Add NX-GZIP engine decompress testcase

In reply to Raphael Moreira Zinsly

Include a decompression testcase for the powerpc NX-GZIP engine.

---
 .../selftests/powerpc/nx-gzip/Makefile        |    7 +-
 .../selftests/powerpc/nx-gzip/gunz_test.c     | 1026 +++++++++++++++++
 2 files changed, 1030 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/gunz_test.c
tools/testing/selftests/powerpc/nx-gzip/Makefile +4 -3
index ab903f63bbbd..82abc19a49a0 100644
@@ -1,9 +1,9 @@
 CC = gcc
 CFLAGS = -O3
 INC = ./inc
-SRC = gzfht_test.c
+SRC = gzfht_test.c gunz_test.c
 OBJ = $(SRC:.c=.o)
-TESTS = gzfht_test
+TESTS = gzfht_test gunz_test
 EXTRA_SOURCES = gzip_vas.c
 
 all:	$(TESTS)
@@ -16,6 +16,7 @@ $(TESTS): $(OBJ)
 
 run_tests: $(TESTS)
 	./gzfht_test gzip_vas.c
+	./gunz_test gzip_vas.c.nx.gz
 
 clean:
-	rm -f $(TESTS) *.o *~ *.gz
+	rm -f $(TESTS) *.o *~ *.gz *.gunzip
tools/testing/selftests/powerpc/nx-gzip/gunz_test.c new file +1026 -0

1,026 lines not on this page · raw message

Signature · 1 line
2.21.0
#7 lore raw

PATCH v3 5/5 selftests/powerpc: Add README for GZIP engine tests

In reply to Raphael Moreira Zinsly

Include a README file with the instructions to use the testcases at selftests/powerpc/nx-gzip.

---
 .../powerpc/nx-gzip/99-nx-gzip.rules          |  1 +
 .../testing/selftests/powerpc/nx-gzip/README  | 46 +++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/99-nx-gzip.rules
 create mode 100644 tools/testing/selftests/powerpc/nx-gzip/README
tools/testing/selftests/powerpc/nx-gzip/99-nx-gzip.rules new file +1 -0
new file mode 100644
index 000000000000..5a7118495cb3
@@ -0,0 +1 @@
+SUBSYSTEM=="nxgzip", KERNEL=="nx-gzip", MODE="0666"
tools/testing/selftests/powerpc/nx-gzip/README new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.21.0