crypto/nx: Enable GZIP engine and provide userpace API
Subsystems (5)
v2 cover crypto/nx: Enable GZIP engine and provide userpace API
Power9 processor supports Virtual Accelerator Switchboard (VAS) which allows kernel and userspace to send compression requests to Nest Accelerator (NX) directly. The NX unit comprises of 2 842 compression engines and 1 GZIP engine. Linux kernel already has 842 compression support on kernel. This patch series adds GZIP compression support from user space. The GZIP Compression engine implements the ZLIB and GZIP compression algorithms. No plans of adding NX-GZIP compression support in kernel right now.
Applications can send requests to NX directly with COPY/PASTE instructions. But kernel has to establish channel / window on NX-GZIP device for the userspace. So userspace access to the GZIP engine is provided through /dev/crypto/nx-gzip device with several operations.
An application must open the this device to obtain a file descriptor (fd). Using the fd, application should issue the VAS_TX_WIN_OPEN ioctl to establish a connection to the engine. Once window is opened, should use mmap() system call to map the hardware address of engine's request queue into the application's virtual address space. Then user space forms the request as co-processor Request Block (CRB) and paste this CRB on the mapped HW address using COPY/PASTE instructions. Application can poll on status flags (part of CRB) with timeout for request completion.
For VAS_TX_WIN_OPEN ioctl, if user space passes vas_id = -1 (struct vas_tx_win_open_attr), kernel determins the VAS instance on the corresponding chip based on the CPU on which the process is executing. Otherwise, the specified VAS instance is used if application passes the proper VAS instance (vas_id listed in /proc/device-tree/vas@*/ibm,vas_id).
Process can open multiple windows with different FDs or can send several requests to NX on the same window at the same time.
A userspace library libnxz is available:
https://github.com/abalib/power-gzip
Applications that use inflate/deflate calls can link with libNXz and use NX GZIP compression without any modification.
Tested the available 842 compression on power8 and power9 system to make sure no regression and tested GZIP compression on power9 with tests available in the above link.
Thanks to Bulent Abali for nxz library and tests development.
Changelog:
V2:
- Move user space API code to powerpc as suggested. Also this API can be extended to any other coprocessor type that VAS can support in future. Example: Fast thread wakeup feature from VAS
- Rebased to 5.6-rc3
Haren Myneni (9):
powerpc/vas: Initialize window attributes for GZIP coprocessor type powerpc/vas: Define VAS_TX_WIN_OPEN ioctl API powerpc/vas: Add VAS user space API
crypto/nx: Initialize coproc entry with kzalloc crypto/nx: Rename nx-842-powernv file name to nx-common-powernv crypto/NX: Make enable code generic to add new GZIP compression type crypto/nx: Enable and setup GZIP compresstion type crypto/nx: Remove 'pid' in vas_tx_win_attr struct Documentation/powerpc: VAS API
Documentation/powerpc/index.rst | 1 + Documentation/powerpc/vas-api.rst | 246 +++++ Documentation/userspace-api/ioctl/ioctl-number.rst | 1 + arch/powerpc/include/asm/vas.h | 12 +- arch/powerpc/include/uapi/asm/vas-api.h | 22 + arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/vas-api.c | 290 +++++ arch/powerpc/platforms/powernv/vas-window.c | 23 +- arch/powerpc/platforms/powernv/vas.h | 2 + drivers/crypto/nx/Makefile | 2 +- drivers/crypto/nx/nx-842-powernv.c | 1062 ------------------ drivers/crypto/nx/nx-common-powernv.c | 1133 ++++++++++++++++++++ 12 files changed, 1723 insertions(+), 1073 deletions(-) create mode 100644 Documentation/powerpc/vas-api.rst create mode 100644 arch/powerpc/include/uapi/asm/vas-api.h create mode 100644 arch/powerpc/platforms/powernv/vas-api.c delete mode 100644 drivers/crypto/nx/nx-842-powernv.c create mode 100644 drivers/crypto/nx/nx-common-powernv.c
Signature · 1 line
1.8.3.1
PATCH v2 1/9 powerpc/vas: Initialize window attributes for GZIP coprocessor type
Initialize send and receive window attributes for GZIP high and normal priority types.
--- arch/powerpc/platforms/powernv/vas-window.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/powerpc/platforms/powernv/vas-window.c +12 -5
@@ -817,7 +817,8 @@ void vas_init_rx_win_attr(struct vas_rx_win_attr *rxattr, enum vas_cop_type cop) {memset (rxattr,0 ,sizeof (*rxattr)); -if (cop ==VAS_COP_TYPE_842 || cop ==VAS_COP_TYPE_842_HIPRI ) { +if (cop ==VAS_COP_TYPE_842 || cop ==VAS_COP_TYPE_842_HIPRI || + cop ==VAS_COP_TYPE_GZIP || cop ==VAS_COP_TYPE_GZIP_HIPRI ) { rxattr->pin_win = true; rxattr->nx_win = true; rxattr->fault_win = false;
@@ -892,7 +893,8 @@ void vas_init_tx_win_attr(struct vas_tx_win_attr *txattr, enum vas_cop_type cop) {memset (txattr,0 ,sizeof (*txattr)); -if (cop ==VAS_COP_TYPE_842 || cop ==VAS_COP_TYPE_842_HIPRI ) { +if (cop ==VAS_COP_TYPE_842 || cop ==VAS_COP_TYPE_842_HIPRI || + cop ==VAS_COP_TYPE_GZIP || cop ==VAS_COP_TYPE_GZIP_HIPRI ) { txattr->rej_no_credit = false; txattr->rx_wcred_mode = true; txattr->tx_wcred_mode = true;
@@ -976,9 +978,14 @@ static bool tx_win_args_valid(enum vas_cop_type cop,if (attr->wcreds_max >VAS_TX_WCREDS_MAX )return false; -if (attr->user_win && - (cop !=VAS_COP_TYPE_FTW || attr->rsvd_txbuf_count)) -return false; +if (attr->user_win) { +if (attr->rsvd_txbuf_count) +return false; + +if (cop !=VAS_COP_TYPE_FTW && cop !=VAS_COP_TYPE_GZIP && + cop !=VAS_COP_TYPE_GZIP_HIPRI ) +return false; + }return true; }
Signature · 1 line
1.8.3.1
PATCH v2 2/9 powerpc/vas: Define VAS_TX_WIN_OPEN ioctl API
In reply to Haren MyneniDefine the VAS_TX_WIN_OPEN ioctl interface for NX GZIP access from user space. This interface is used to open GZIP send window and mmap region which can be used by userspace to send requests to NX directly with copy/paste instructions.
--- Documentation/userspace-api/ioctl/ioctl-number.rst | 1 + arch/powerpc/include/uapi/asm/vas-api.h | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/vas-api.h
Documentation/userspace-api/ioctl/ioctl-number.rst +1 -0
@@ -287,6 +287,7 @@ Code Seq# Include File Comments 'v' 00-1F linux/fs.h conflict! 'v' 00-0F linux/sonypi.h conflict! 'v' 00-0F media/v4l2-subdev.h conflict! +'v' 20-27 arch/powerpc/include/uapi/asm/vas-api.h VAS API 'v' C0-FF linux/meye.h conflict! 'w' all CERN SCI driver 'y' 00-1F packet based user level communications
arch/powerpc/include/uapi/asm/vas-api.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* +* Copyright 2019 IBM Corp. +*/ + +#ifndef _UAPI_MISC_VAS_H +#define _UAPI_MISC_VAS_H + +#include <asm/ioctl.h> + +#define VAS_MAGIC 'v' +#define VAS_TX_WIN_OPEN _IOW(VAS_MAGIC, 0x20, struct vas_tx_win_open_attr) + +struct vas_tx_win_open_attr { +__u32 version; +__s16 vas_id;/* specific instance of vas or -1 for default */ +__u16 reserved1; +__u64 flags;/* Future use */ +__u64 reserved2[6 ]; +}; + +#endif /* _UAPI_MISC_VAS_H */
Signature · 1 line
1.8.3.1
PATCH v3 3/9 powerpc/vas: Add VAS user space API
In reply to Haren MyneniOn power9, userspace can send GZIP compression requests directly to NX once kernel establishes NX channel / window with VAS. This patch provides user space API which allows user space to establish channel using open VAS_TX_WIN_OPEN ioctl, mmap and close operations.
Each window corresponds to file descriptor and application can open multiple windows. After the window is opened, VAS_TX_WIN_OPEN icoctl to open a window on specific VAS instance, mmap() system call to map the hardware address of engine's request queue into the application's virtual address space.
Then the application can then submit one or more requests to the the engine by using the copy/paste instructions and pasting the CRBs to the virtual address (aka paste_address) returned by mmap().
Only NX GZIP coprocessor type is supported right now and allow GZIP engine access via /dev/crypto/nx-gzip device node.
--- arch/powerpc/include/asm/vas.h | 11 ++ arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/vas-api.c | 290 ++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/vas-window.c | 6 +- arch/powerpc/platforms/powernv/vas.h | 2 + 5 files changed, 307 insertions(+), 4 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/vas-api.c
arch/powerpc/include/asm/vas.h +11 -0
@@ -163,4 +163,15 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,*/ int vas_paste_crb (struct vas_window *win,int offset,bool re); +/* +* Register / unregister coprocessor type to VAS API which will be exported +* to user space. Applications can use this API to open / close window +* which can be used to send / receive requests directly to cooprcessor. +* +* Only NX GZIP coprocessor type is supported now, but this API can be +* used for others in future. +*/ +int vas_register_coproc_api (struct module *mod); +void vas_unregister_coproc_api (void ); +#endif /* __ASM_POWERPC_VAS_H */
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -17,7 +17,7 @@ obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o obj-$(CONFIG_PERF_EVENTS) += opal-imc.o obj-$(CONFIG_PPC_MEMTRACE) += memtrace.o -obj-$(CONFIG_PPC_VAS) += vas.o vas-window.o vas-debug.o vas-fault.o +obj-$(CONFIG_PPC_VAS) += vas.o vas-window.o vas-debug.o vas-fault.o vas-api.o obj-$(CONFIG_OCXL_BASE) += ocxl.o obj-$(CONFIG_SCOM_DEBUGFS) += opal-xscom.o obj-$(CONFIG_PPC_SECURE_BOOT) += opal-secvar.o
arch/powerpc/platforms/powernv/vas-api.c new file +290 -0
290 lines not on this page · raw message
arch/powerpc/platforms/powernv/vas-window.c +3 -3
@@ -26,7 +26,7 @@* Compute the paste address region for the window @window using the * ->paste_base_addr and ->paste_win_id_shift we got from device tree. */ -static void compute_paste_address (struct vas_window *window,u64 *addr,int *len) +void vas_win_paste_addr (struct vas_window *window,u64 *addr,int *len) {int winid;u64 base, shift;
@@ -80,7 +80,7 @@ static void *map_paste_region(struct vas_window *txwin) goto free_name; txwin->paste_addr_name = name; -compute_paste_address (txwin, &start, &len); +vas_win_paste_addr (txwin, &start, &len);if (!request_mem_region (start, len, name)) { pr_devel("%s(): request_mem_region(0x%llx, %d) failed\n",
@@ -138,7 +138,7 @@ static void unmap_paste_region(struct vas_window *window)u64 busaddr_start;if (window->paste_kaddr) { -compute_paste_address (window, &busaddr_start, &len); +vas_win_paste_addr (window, &busaddr_start, &len);unmap_region (window->paste_kaddr, busaddr_start, len); window->paste_kaddr =NULL ;kfree (window->paste_addr_name);
arch/powerpc/platforms/powernv/vas.h +2 -0
@@ -418,6 +418,8 @@ struct vas_winctx {extern void vas_return_credit (struct vas_window *window,bool tx);extern struct vas_window *vas_pswid_to_window (struct vas_instance *vinst,uint32_t pswid); +extern void vas_win_paste_addr (struct vas_window *window,u64 *addr, +int *len);static inline int vas_window_pid (struct vas_window *window) {
Signature · 1 line
1.8.3.1
PATCH v2 4/9 crypto/nx: Initialize coproc entry with kzalloc
In reply to Haren Mynenicoproc entry is initialized during NX probe on power9, but not on P8. nx842_delete_coprocs() is used for both and frees receive window if it is allocated. Getting crash for rmmod on P8 since coproc->vas.rxwin is not initialized.
This patch replaces kmalloc with kzalloc in nx842_powernv_probe()
--- drivers/crypto/nx/nx-842-powernv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/nx/nx-842-powernv.c +1 -1
@@ -922,7 +922,7 @@ static int __init nx842_powernv_probe(struct device_node *dn)return -EINVAL ; } - coproc =kmalloc (sizeof (*coproc),GFP_KERNEL ); + coproc =kzalloc (sizeof (*coproc),GFP_KERNEL );if (!coproc)return -ENOMEM ;
Signature · 1 line
1.8.3.1
PATCH v2 5/9 crypto/nx: Rename nx-842-powernv file name to nx-common-powernv
In reply to Haren MyneniRename nx-842-powernv.c to nx-common-powernv.c to add code for setup and enable new GZIP compression type. The actual functionality is not changed in this patch.
--- drivers/crypto/nx/Makefile | 2 +- drivers/crypto/nx/nx-842-powernv.c | 1062 --------------------------------- drivers/crypto/nx/nx-common-powernv.c | 1062 +++++++++++++++++++++++++++++++++ 3 files changed, 1063 insertions(+), 1063 deletions(-) delete mode 100644 drivers/crypto/nx/nx-842-powernv.c create mode 100644 drivers/crypto/nx/nx-common-powernv.c
drivers/crypto/nx/Makefile +1 -1
@@ -15,4 +15,4 @@ obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS_PSERIES) += nx-compress-pseries.o nx-compres obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS_POWERNV) += nx-compress-powernv.o nx-compress.o nx-compress-objs := nx-842.o nx-compress-pseries-objs := nx-842-pseries.o -nx-compress-powernv-objs := nx-842-powernv.o +nx-compress-powernv-objs := nx-common-powernv.o
drivers/crypto/nx/nx-842-powernv.c deleted +0 -1062
1,062 lines not on this page · raw message
drivers/crypto/nx/nx-common-powernv.c new file +1062 -0
1,062 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 6/9 crypto/nx: Make enable code generic to add new GZIP compression type
In reply to Haren MyneniMake setup and enable code generic to support new GZIP compression type. Changed nx842 reference to nx and moved some code to new functions. The actual functionality is not changed.
--- drivers/crypto/nx/nx-common-powernv.c | 159 +++++++++++++++++++++------------- 1 file changed, 100 insertions(+), 59 deletions(-)
drivers/crypto/nx/nx-common-powernv.c +100 -59
@@ -40,9 +40,9 @@ struct nx842_workmem {char padding[WORKMEM_ALIGN ];/* unused, to allow alignment */ } __packed__aligned(WORKMEM_ALIGN) ; -struct nx842_coproc { +struct nx_coproc {unsigned int chip_id; -unsigned int ct; +unsigned int ct;/* Can be 842 or GZIP high/normal*/ unsigned int ci;/* Coprocessor instance, used with icswx */ struct {struct vas_window *rxwin;
@@ -58,9 +58,15 @@ struct nx842_coproc { static DEFINE_PER_CPU(struct vas_window *, cpu_txwin);/* no cpu hotplug on powernv, so this list never changes after init */ -static LIST_HEAD (nx842_coprocs); +static LIST_HEAD (nx_coprocs);static unsigned int nx842_ct;/* used in icswx function */ +/* +* Using same values as in skiboot or coprocessor type representing +* in NX workbook. +*/ +#define NX_CT_842 (3) +static int (*nx842_powernv_exec)(const unsigned char *in,unsigned int inlen,unsigned char *out,unsigned int *outlenp,void *workmem,int fc);
@@ -666,15 +672,15 @@ static int nx842_powernv_decompress(const unsigned char *in, unsigned int inlen, wmem, CCW_FC_842_DECOMP_CRC); } -static inline void nx842_add_coprocs_list (struct nx842_coproc *coproc, +static inline void nx_add_coprocs_list (struct nx_coproc *coproc,int chipid) { coproc->chip_id = chipid;INIT_LIST_HEAD (&coproc->list); -list_add (&coproc->list, &nx842_coprocs); +list_add (&coproc->list, &nx_coprocs); } -static struct vas_window *nx842_alloc_txwin (struct nx842_coproc *coproc) +static struct vas_window *nx_alloc_txwin (struct nx_coproc *coproc) {struct vas_window *txwin =NULL ;struct vas_tx_win_attr txattr;
@@ -704,9 +710,9 @@ static struct vas_window *nx842_alloc_txwin(struct nx842_coproc *coproc)* cpu_txwin is used in copy/paste operation for each compression / * decompression request. */ -static int nx842_open_percpu_txwins (void ) +static int nx_open_percpu_txwins (void ) { -struct nx842_coproc *coproc, *n; +struct nx_coproc *coproc, *n;unsigned int i, chip_id;for_each_possible_cpu (i) {
@@ -714,17 +720,18 @@ static int nx842_open_percpu_txwins(void) chip_id =cpu_to_chip_id (i); -list_for_each_entry_safe (coproc, n, &nx842_coprocs, list) { +list_for_each_entry_safe (coproc, n, &nx_coprocs, list) {/* * Kernel requests use only high priority FIFOs. So * open send windows for these FIFOs. +* GZIP is not supported in kernel right now. */ if (coproc->ct !=VAS_COP_TYPE_842_HIPRI )continue ;if (coproc->chip_id == chip_id) { - txwin =nx842_alloc_txwin (coproc); + txwin =nx_alloc_txwin (coproc);if (IS_ERR (txwin))return PTR_ERR (txwin);
@@ -743,13 +750,28 @@ static int nx842_open_percpu_txwins(void)return 0 ; } +static int __init nx_set_ct (struct nx_coproc *coproc,const char *priority, +int high,int normal) +{ +if (!strcmp (priority,"High" )) + coproc->ct = high; +else if (!strcmp (priority,"Normal" )) + coproc->ct = normal; +else { +pr_err ("Invalid RxFIFO priority value\n" ); +return -EINVAL ; + } + +return 0 ; +} +static int __init vas_cfg_coproc_info (struct device_node *dn,int chip_id, -int vasid,int *ct) +int vasid,int type,int *ct) {struct vas_window *rxwin =NULL ;struct vas_rx_win_attr rxattr; -struct nx842_coproc *coproc;u32 lpid, pid, tid, fifo_size; +struct nx_coproc *coproc;u64 rx_fifo;const char *priority;int ret;
@@ -794,15 +816,12 @@ static int __init vas_cfg_coproc_info(struct device_node *dn, int chip_id,if (!coproc)return -ENOMEM ; -if (!strcmp (priority,"High" )) - coproc->ct =VAS_COP_TYPE_842_HIPRI ; -else if (!strcmp (priority,"Normal" )) - coproc->ct =VAS_COP_TYPE_842 ; -else { -pr_err ("Invalid RxFIFO priority value\n" ); - ret = -EINVAL ; +if (type ==NX_CT_842 ) + ret =nx_set_ct (coproc, priority,VAS_COP_TYPE_842_HIPRI , +VAS_COP_TYPE_842 ); + +if (ret) goto err_out; - }vas_init_rx_win_attr (&rxattr, coproc->ct); rxattr.rx_fifo = (void *)rx_fifo;
@@ -830,7 +849,7 @@ static int __init vas_cfg_coproc_info(struct device_node *dn, int chip_id, coproc->vas.rxwin = rxwin; coproc->vas.id = vasid; -nx842_add_coprocs_list (coproc, chip_id); +nx_add_coprocs_list (coproc, chip_id);/* * (lpid, pid, tid) combination has to be unique for each
@@ -848,13 +867,43 @@ static int __init vas_cfg_coproc_info(struct device_node *dn, int chip_id,return ret; } +static int __init nx_coproc_init (int chip_id,int ct_842) +{ +int ret =0 ; -static int __init nx842_powernv_probe_vas (struct device_node *pn) +if (opal_check_token (OPAL_NX_COPROC_INIT )) { + ret =opal_nx_coproc_init (chip_id, ct_842); +if (ret) { + ret =opal_error_code (ret); +pr_err ("Failed to initialize NX for chip(%d): %d\n" , + chip_id, ret); + } + }else +pr_warn ("Firmware doesn't support NX initialization\n" ); + +return ret; +} + +static int __init find_nx_device_tree (struct device_node *dn,int chip_id, +int vasid,int type,char *devname, +int *ct) +{ +int ret =0 ; + +if (of_device_is_compatible (dn, devname)) { + ret =vas_cfg_coproc_info (dn, chip_id, vasid, type, ct); +if (ret) +of_node_put (dn); + } + +return ret; +} + +static int __init nx_powernv_probe_vas (struct device_node *pn) { -struct device_node *dn;int chip_id, vasid, ret =0 ; -int nx_fifo_found =0 ; -int uninitialized_var (ct ); +struct device_node *dn; +int ct_842 =0 ; chip_id =of_get_ibm_chip_id (pn);if (chip_id <0 ) {
@@ -869,17 +918,13 @@ static int __init nx842_powernv_probe_vas(struct device_node *pn) }for_each_child_of_node (pn, dn) { -if (of_device_is_compatible (dn,"ibm,p9-nx-842" )) { - ret =vas_cfg_coproc_info (dn, chip_id, vasid, &ct); -if (ret) { -of_node_put (dn); -return ret; - } - nx_fifo_found++; - } + ret =find_nx_device_tree (dn, chip_id, vasid,NX_CT_842 , +"ibm,p9-nx-842" , &ct_842); +if (ret) +return ret; } -if (!nx_fifo_found) { +if (!ct_842) {pr_err ("NX842 FIFO nodes are missing\n" );return -EINVAL ; }
@@ -887,22 +932,14 @@ static int __init nx842_powernv_probe_vas(struct device_node *pn)/* * Initialize NX instance for both high and normal priority FIFOs. */ -if (opal_check_token (OPAL_NX_COPROC_INIT )) { - ret =opal_nx_coproc_init (chip_id, ct); -if (ret) { -pr_err ("Failed to initialize NX for chip(%d): %d\n" , - chip_id, ret); - ret =opal_error_code (ret); - } - }else -pr_warn ("Firmware doesn't support NX initialization\n" ); + ret =nx_coproc_init (chip_id, ct_842);return ret; }static int __init nx842_powernv_probe (struct device_node *dn) { -struct nx842_coproc *coproc; +struct nx_coproc *coproc;unsigned int ct, ci;int chip_id;
@@ -928,7 +965,7 @@ static int __init nx842_powernv_probe(struct device_node *dn) coproc->ct = ct; coproc->ci = ci; -nx842_add_coprocs_list (coproc, chip_id); +nx_add_coprocs_list (coproc, chip_id);pr_info ("coprocessor found on chip %d, CT %d CI %d\n" , chip_id, ct, ci);
@@ -941,9 +978,9 @@ static int __init nx842_powernv_probe(struct device_node *dn)return 0 ; } -static void nx842_delete_coprocs (void ) +static void nx_delete_coprocs (void ) { -struct nx842_coproc *coproc, *n; +struct nx_coproc *coproc, *n;struct vas_window *txwin;int i;
@@ -958,7 +995,7 @@ static void nx842_delete_coprocs(void)per_cpu (cpu_txwin, i) =0 ; } -list_for_each_entry_safe (coproc, n, &nx842_coprocs, list) { +list_for_each_entry_safe (coproc, n, &nx_coprocs, list) {if (coproc->vas.rxwin)vas_win_close (coproc->vas.rxwin);
@@ -1002,7 +1039,7 @@ static int nx842_powernv_crypto_init(struct crypto_tfm *tfm) .coa_decompress = nx842_crypto_decompress } } }; -static __init int nx842_powernv_init (void ) +static __init int nx_compress_powernv_init (void ) {struct device_node *dn;int ret;
@@ -1017,15 +1054,15 @@ static __init int nx842_powernv_init(void)BUILD_BUG_ON (DDE_BUFFER_SIZE_MULT %DDE_BUFFER_LAST_MULT );for_each_compatible_node (dn,NULL ,"ibm,power9-nx" ) { - ret =nx842_powernv_probe_vas (dn); + ret =nx_powernv_probe_vas (dn);if (ret) { -nx842_delete_coprocs (); +nx_delete_coprocs ();of_node_put (dn);return ret; } } -if (list_empty (&nx842_coprocs)) { +if (list_empty (&nx_coprocs)) {for_each_compatible_node (dn,NULL ,"ibm,power-nx" )nx842_powernv_probe (dn);
@@ -1034,9 +1071,13 @@ static __init int nx842_powernv_init(void) nx842_powernv_exec = nx842_exec_icswx; }else { - ret =nx842_open_percpu_txwins (); +/* +* GZIP is not supported in kernel right now. +* So open tx windows only for 842. +*/ + ret =nx_open_percpu_txwins ();if (ret) { -nx842_delete_coprocs (); +nx_delete_coprocs ();return ret; }
@@ -1045,18 +1086,18 @@ static __init int nx842_powernv_init(void) ret =crypto_register_alg (&nx842_powernv_alg);if (ret) { -nx842_delete_coprocs (); +nx_delete_coprocs ();return ret; }return 0 ; } -module_init (nx842_powernv_init); +module_init (nx_compress_powernv_init); -static void __exit nx842_powernv_exit(void) +static void __exit nx_compress_powernv_exit(void) {crypto_unregister_alg (&nx842_powernv_alg); -nx842_delete_coprocs (); +nx_delete_coprocs (); } -module_exit (nx842_powernv_exit); +module_exit (nx_compress_powernv_exit);
Signature · 1 line
1.8.3.1
PATCH v2 7/9 crypto/nx: Enable and setup GZIP compression type
In reply to Haren MyneniChanges to probe GZIP device-tree nodes, open RX windows and setup GZIP compression type. No plans to provide GZIP usage in kernel right now, but this patch enables GZIP for user space usage.
--- drivers/crypto/nx/nx-common-powernv.c | 43 ++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-)
drivers/crypto/nx/nx-common-powernv.c +37 -6
@@ -65,6 +65,7 @@ struct nx_coproc {* Using same values as in skiboot or coprocessor type representing * in NX workbook. */ +#define NX_CT_GZIP (2)/* on P9 and later */ #define NX_CT_842 (3) static int (*nx842_powernv_exec)(const unsigned char *in,
@@ -819,6 +820,9 @@ static int __init vas_cfg_coproc_info(struct device_node *dn, int chip_id,if (type ==NX_CT_842 ) ret =nx_set_ct (coproc, priority,VAS_COP_TYPE_842_HIPRI ,VAS_COP_TYPE_842 ); +else if (type ==NX_CT_GZIP ) + ret =nx_set_ct (coproc, priority,VAS_COP_TYPE_GZIP_HIPRI , +VAS_COP_TYPE_GZIP );if (ret) goto err_out;
@@ -867,12 +871,16 @@ static int __init vas_cfg_coproc_info(struct device_node *dn, int chip_id,return ret; } -static int __init nx_coproc_init (int chip_id,int ct_842) +static int __init nx_coproc_init (int chip_id,int ct_842,int ct_gzip) {int ret =0 ;if (opal_check_token (OPAL_NX_COPROC_INIT )) { ret =opal_nx_coproc_init (chip_id, ct_842); + +if (!ret) + ret =opal_nx_coproc_init (chip_id, ct_gzip); +if (ret) { ret =opal_error_code (ret); pr_err("Failed to initialize NX for chip(%d): %d\n",
@@ -902,8 +910,8 @@ static int __init find_nx_device_tree(struct device_node *dn, int chip_id,static int __init nx_powernv_probe_vas (struct device_node *pn) {int chip_id, vasid, ret =0 ; +int ct_842 =0 , ct_gzip =0 ;struct device_node *dn; -int ct_842 =0 ; chip_id =of_get_ibm_chip_id (pn);if (chip_id <0 ) {
@@ -920,19 +928,24 @@ static int __init nx_powernv_probe_vas(struct device_node *pn)for_each_child_of_node (pn, dn) { ret =find_nx_device_tree (dn, chip_id, vasid,NX_CT_842 ,"ibm,p9-nx-842" , &ct_842); + +if (!ret) + ret =find_nx_device_tree (dn, chip_id, vasid, +NX_CT_GZIP ,"ibm,p9-nx-gzip" , &ct_gzip); +if (ret)return ret; } -if (!ct_842) { -pr_err ("NX842 FIFO nodes are missing\n" ); +if (!ct_842 || !ct_gzip) { +pr_err ("NX FIFO nodes are missing\n" );return -EINVAL ; }/* * Initialize NX instance for both high and normal priority FIFOs. */ - ret =nx_coproc_init (chip_id, ct_842); + ret =nx_coproc_init (chip_id, ct_842, ct_gzip);return ret; }
@@ -1072,10 +1085,19 @@ static __init int nx_compress_powernv_init(void) nx842_powernv_exec = nx842_exec_icswx; }else {/* +* Register VAS user space API for NX GZIP so +* that user space can use GZIP engine. +* 842 compression is supported only in kernel. +*/ + ret =vas_register_coproc_api (THIS_MODULE ); + +/* * GZIP is not supported in kernel right now. * So open tx windows only for 842. */ - ret =nx_open_percpu_txwins (); +if (!ret) + ret =nx_open_percpu_txwins (); +if (ret) {nx_delete_coprocs ();return ret;
@@ -1096,6 +1118,15 @@ static __init int nx_compress_powernv_init(void) static void __exit nx_compress_powernv_exit(void) { +/* +* GZIP engine is supported only in power9 or later and nx842_ct +* is used on power8 (icswx). +* VAS API for NX GZIP is registered during init for user space +* use. So delete this API use for GZIP engine. +*/ +if (!nx842_ct) +vas_unregister_coproc_api (); +crypto_unregister_alg (&nx842_powernv_alg);nx_delete_coprocs ();
Signature · 1 line
1.8.3.1
PATCH v2 8/9 crypto/nx: Remove 'pid' in vas_tx_win_attr struct
In reply to Haren MyneniWhen window is opened, pid reference is taken for user space windows. Not needed for kernel windows. So remove 'pid' in vas_tx_win_attr struct.
--- arch/powerpc/include/asm/vas.h | 1 - drivers/crypto/nx/nx-common-powernv.c | 1 - 2 files changed, 2 deletions(-)
arch/powerpc/include/asm/vas.h +0 -1
@@ -86,7 +86,6 @@ struct vas_tx_win_attr {int wcreds_max;int lpid;int pidr;/* hardware PID (from SPRN_PID) */ -int pid;/* linux process id */ int pswid;int rsvd_txbuf_count;int tc_mode;
drivers/crypto/nx/nx-common-powernv.c +0 -1
@@ -692,7 +692,6 @@ static struct vas_window *nx_alloc_txwin(struct nx_coproc *coproc)*/ vas_init_tx_win_attr (&txattr, coproc->ct); txattr.lpid =0 ;/* lpid is 0 for kernel requests */ - txattr.pid =0 ;/* pid is 0 for kernel requests */ /* * Open a VAS send window which is used to send request to NX.
Signature · 1 line
1.8.3.1
PATCH v2 9/9 Documentation/powerpc: VAS API
In reply to Haren MyneniPower9 introduced Virtual Accelerator Switchboard (VAS) which allows userspace to communicate with Nest Accelerator (NX) directly. But kernel has to establish channel to NX for userspace. This document describes user space API that application can use to establish communication channel.
--- Documentation/powerpc/index.rst | 1 + Documentation/powerpc/vas-api.rst | 246 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 Documentation/powerpc/vas-api.rst
Documentation/powerpc/index.rst +1 -0
@@ -30,6 +30,7 @@ powerpc syscall64-abi transactional_memory ultravisor + vas-api .. only:: subproject and html
Documentation/powerpc/vas-api.rst new file +246 -0
246 lines not on this page · raw message
Signature · 1 line
1.8.3.1