powerpc/vas: Enable VAS
Subsystems (5)
v6 cover powerpc/vas: Enable VAS
POWER9 introduces a hardware subsystem referred to as the Virtual Accelerator Switchboard (VAS). VAS allows kernel subsystems and user space processes to directly access the Nest Accelerator (NX) engines which implement compression and encryption algorithms in the hardware.
NX has been in Power processors since Power7+, but access to the NX engines was through the 'icswx' instruction which is only available to the kernel/hypervisor. Starting with POWER9, access to the NX engines is provided to both kernel and user space processes through VAS.
The switchboard (i.e VAS) multiplexes accesses between "receivers" and "senders", where the "receivers" are typically the NX engines and the "senders" are the kernel subsystems and user processors that wish to access the receivers (NX engines). Once a sender is "connected" to a receiver through the switchboard, the senders can submit compression/ encryption requests to the hardware using the new (PowerISA 3.0) "copy" and "paste" instructions.
Senders can also send "empty" messages to the receiver. If the receiver is executing a WAIT instruction, this empty message serves to have the receiver resume from the next instruction. (i.e acts as "wake up" message). This usage of VAS is referred to as "Fast thread-wakeup".
Provides:
This patch set:
- configures the VAS subsystems in the hardware
- provides kernel interfaces to drivers like NX-842 and NX-FTW (new) to open receive and send/receive windows and to submit copy/paste (i.e compression) requests to the NX engines.
- implements an NX-FTW driver for the fast thread-wake up mechanism. It provides the /dev/crypto/nx-ftw device node, and ioctls to allow users to use the FTW mechanism in VAS.
Follow-on patch set(s) will allow user space processes to submit requests to the NX-GZIP engine (and possibly other engines).
Requires:
This patch set needs corresponding VAS/NX skiboot patches which were merged into skiboot tree. i.e skiboot must include:
commit 3b3c596 (NX: Add P9 NX support for 842 compression engine)
Testing:
In-kernel compression requests were tested on DD1 POWER9 hardware using the following NX-842 patch set from Haren Myneni:
https://lists.ozlabs.org/pipermail/linuxppc-dev/2017-July/160620.html
The ability to setup user space send/receive windows for FTW was tested on DD1 hardware. The actual copy/paste of the empty messages is not yet supported in hardware and that functionality was tested on DD2 simics software.
Git Tree:
https://github.com/sukadev/linux/
Branch: vas-kern-v6
Thanks to input from Ben Herrenschmidt, Michael Neuling, Michael Ellerman, Robert Blackmore and Haren Myneni.
Changelog[v6]
- Add support for user space send/receive FTW windows
- Add a new, NX-FTW driver which provides the FTW user interface
Changelog[v5]
- [Ben Herrenschmidt] Make VAS a platform device in the device tree and use the core platform functions to parse the VAS properties. Map the VAS MMIO regions as non-cachable and paste regions as cachable. Use CONFIG_PPC_VAS rather than CONFIG_VAS; Don't assume VAS ids are sequential.
- Copy the FIFO address as is into LFIFO_BAR (don't shift it).
Changelog[v4]
Comments from Michael Neuling:
- Move VAS code from drivers/misc/vas to arch/powerpc/platforms/powernv since VAS only provides interfaces to other drivers like NX-842.
- Drop vas-internal.h and use vas.h in separate dirs for VAS internal, kernel API and user API
- Rather than create 6 separate device tree properties windows and window context, combine them into 6 "reg" properties.
- Drop vas_window_reset() since windows are reset/cleared before being assigned to kernel/users.
- Use ilog2() and radix_enabled() helpers
Changelog[v3]
- Rebase to v4.11-rc1
- Add interfaces to initialize send/receive window attributes to defaults that drivers can use (see arch/powerpc/include/asm/vas.h)
- Modify interface vas_paste() to return 0 or error code
- Fix a bug in setting Translation Control Mode (0b11 not 0x11)
- Enable send-window-credit checking
- Reorg code in vas_win_close()
- Minor reorgs and tweaks to register field settings to make it easier to add support for user space windows.
- Skip writing to read-only registers
- Start window indexing from 0 rather than 1
Changelog[v2]
- Use vas-id, HVWC, UWC and paste address, entries from device tree rather than defining/computing them in kernel and reorg code.
Sukadev Bhattiprolu (17):
powerpc/vas: Define macros, register fields and structures Move GET_FIELD/SET_FIELD to vas.h
powerpc/vas: Define vas_init() and vas_exit() powerpc/vas: Define helpers to access MMIO regions powerpc/vas: Define helpers to init window context powerpc/vas: Define helpers to alloc/free windows powerpc/vas: Define vas_win_paste_addr() powerpc/vas: Define vas_win_id()
powerpc/vas: Define vas_rx_win_open() interface powerpc/vas: Define vas_rx_win_open() interface powerpc/vas: Define vas_win_close() interface powerpc/vas: Define vas_tx_win_open() powerpc/vas: Define copy/paste interfaces
powerpc: Add support for setting SPRN_TIDR powerpc/vas: Define window open ioctls API powerpc/vas: Implement a simple FTW driver
VAS: Document FTW API/usage
.../devicetree/bindings/powerpc/ibm,vas.txt | 24 + Documentation/powerpc/ftw-api.txt | 373 ++++++ MAINTAINERS | 20 + arch/powerpc/include/asm/processor.h | 4 + arch/powerpc/include/asm/vas.h | 156 +++ arch/powerpc/include/uapi/asm/vas.h | 63 + arch/powerpc/kernel/process.c | 74 ++ arch/powerpc/platforms/powernv/Kconfig | 30 + arch/powerpc/platforms/powernv/Makefile | 2 + arch/powerpc/platforms/powernv/copy-paste.h | 74 ++ arch/powerpc/platforms/powernv/nx-ftw.c | 486 ++++++++ arch/powerpc/platforms/powernv/vas-window.c | 1233 ++++++++++++++++++++ arch/powerpc/platforms/powernv/vas.c | 183 +++ arch/powerpc/platforms/powernv/vas.h | 500 ++++++++ drivers/crypto/nx/nx-842-powernv.c | 7 +- drivers/crypto/nx/nx-842.h | 5 - 16 files changed, 3226 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/powerpc/ibm,vas.txt create mode 100644 Documentation/powerpc/ftw-api.txt create mode 100644 arch/powerpc/include/asm/vas.h create mode 100644 arch/powerpc/include/uapi/asm/vas.h create mode 100644 arch/powerpc/platforms/powernv/copy-paste.h create mode 100644 arch/powerpc/platforms/powernv/nx-ftw.c create mode 100644 arch/powerpc/platforms/powernv/vas-window.c create mode 100644 arch/powerpc/platforms/powernv/vas.c create mode 100644 arch/powerpc/platforms/powernv/vas.h
Signature · 1 line
2.7.4
PATCH v6 1/17 powerpc/vas: Define macros, register fields and structures
Define macros for the VAS hardware registers and bit-fields as well as couple of data structures needed by the VAS driver.
---
Changelog[v6]
- Add some fields for FTW windows
Changelog[v4]
- [Michael Neuling] Move VAS code to arch/powerpc; Reorg vas.h and vas-internal.h to kernel and uapi versions; rather than creating separate properties for window context/address entries in device tree, combine them into "reg" properties; drop ->hwirq and irq_port fields from vas_window as they are only needed with user space windows.
- Drop the error check for CONFIG_PPC_4K_PAGES. Instead in a follow-on patch add a "depends on CONFIG_PPC_64K_PAGES".
Changelog[v3]
- Rename winctx->pid to winctx->pidr to reflect that its a value from the PID register (SPRN_PID), not the linux process id.
- Make it easier to split header into kernel/user parts
- To keep user interface simple, use macros rather than enum for the threshold-control modes.
- Add a pid field to struct vas_window - needed for user space send windows.
Changelog[v2]
- Add an overview of VAS in vas-internal.h
- Get window context parameters from device tree and drop unnecessary macros.
--- arch/powerpc/include/asm/vas.h | 35 ++++ arch/powerpc/include/uapi/asm/vas.h | 25 +++ arch/powerpc/platforms/powernv/vas.h | 382 +++++++++++++++++++++++++++++++++++ 3 files changed, 442 insertions(+) create mode 100644 arch/powerpc/include/asm/vas.h create mode 100644 arch/powerpc/include/uapi/asm/vas.h create mode 100644 arch/powerpc/platforms/powernv/vas.h
arch/powerpc/include/asm/vas.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright 2016 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifndef _MISC_VAS_H +#define _MISC_VAS_H + +#include <uapi/asm/vas.h> + +/* +* Min and max FIFO sizes are based on Version 1.05 Section 3.1.4.25 +* (Local FIFO Size Register) of the VAS workbook. +*/ +#define VAS_RX_FIFO_SIZE_MIN (1 << 10)/* 1KB */ +#define VAS_RX_FIFO_SIZE_MAX (8 << 20)/* 8MB */ + +/* +* Co-processor Engine type. +*/ +enum vas_cop_type { +VAS_COP_TYPE_FAULT , +VAS_COP_TYPE_842 , +VAS_COP_TYPE_842_HIPRI , +VAS_COP_TYPE_GZIP , +VAS_COP_TYPE_GZIP_HIPRI , +VAS_COP_TYPE_FTW , +VAS_COP_TYPE_MAX , +}; + +#endif /* _MISC_VAS_H */
arch/powerpc/include/uapi/asm/vas.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright 2016 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifndef _UAPI_MISC_VAS_H +#define _UAPI_MISC_VAS_H + +/* +* Threshold Control Mode: Have paste operation fail if the number of +* requests in receive FIFO exceeds a threshold. +* +* NOTE: No special error code yet if paste is rejected because of these +* limits. So users can't distinguish between this and other errors. +*/ +#define VAS_THRESH_DISABLED 0 +#define VAS_THRESH_FIFO_GT_HALF_FULL 1 +#define VAS_THRESH_FIFO_GT_QTR_FULL 2 +#define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3 + +#endif /* _UAPI_MISC_VAS_H */
arch/powerpc/platforms/powernv/vas.h new file +382 -0
382 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 2/17 powerpc/vas: Move GET_FIELD/SET_FIELD to vas.h
In reply to Sukadev BhattiproluMove the GET_FIELD and SET_FIELD macros to vas.h as VAS and other users of VAS, including NX-842 can use those macros.
There is a lot of related code between the VAS/NX kernel drivers and skiboot. For consistency switch the order of parameters in SET_FIELD to match the order in skiboot.
---
Changelog[v3]
- Fix order of parameters in nx-842 driver.
--- arch/powerpc/include/uapi/asm/vas.h | 8 ++++++++ drivers/crypto/nx/nx-842-powernv.c | 7 ++++--- drivers/crypto/nx/nx-842.h | 5 ----- 3 files changed, 12 insertions(+), 8 deletions(-)
arch/powerpc/include/uapi/asm/vas.h +8 -0
@@ -22,4 +22,12 @@#define VAS_THRESH_FIFO_GT_QTR_FULL 2#define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3 +/* +* Get/Set bit fields +*/ +#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))) +#endif /* _UAPI_MISC_VAS_H */
drivers/crypto/nx/nx-842-powernv.c +4 -3
@@ -22,6 +22,7 @@#include <asm/prom.h> #include <asm/icswx.h> +#include <asm/vas.h> MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Dan Streetman <[email protected]>" );
@@ -424,9 +425,9 @@ static int nx842_powernv_function(const unsigned char *in, unsigned int inlen,/* set up CCW */ ccw =0 ; - ccw =SET_FIELD (ccw,CCW_CT , nx842_ct); - ccw =SET_FIELD (ccw,CCW_CI_842 ,0 );/* use 0 for hw auto-selection */ - ccw =SET_FIELD (ccw,CCW_FC_842 , fc); + ccw =SET_FIELD (CCW_CT , ccw, nx842_ct); + ccw =SET_FIELD (CCW_CI_842 , ccw,0 );/* use 0 for hw auto-selection */ + ccw =SET_FIELD (CCW_FC_842 , ccw, fc);/* set up CRB's CSB addr */ csb_addr =nx842_get_pa (csb) &CRB_CSB_ADDRESS ;
drivers/crypto/nx/nx-842.h +0 -5
@@ -100,11 +100,6 @@ static inline unsigned long nx842_get_pa(void *addr)return page_to_phys (vmalloc_to_page (addr)) +offset_in_page (addr); } -/* Get/Set bit fields */ -#define MASK_LSH (m) (__builtin_ffsl(m) - 1) -#define GET_FIELD (v, m) (((v) & (m)) >> MASK_LSH(m)) -#define SET_FIELD (v, m, val) (((v) & ~(m)) | (((val) << MASK_LSH(m)) & (m))) -/** * This provides the driver's constraints. Different nx842 implementations * may have varying requirements. The constraints are:
Signature · 1 line
2.7.4
PATCH v6 3/17 powerpc/vas: Define vas_init() and vas_exit()
In reply to Sukadev BhattiproluImplement vas_init() and vas_exit() functions for a new VAS module. This VAS module is essentially a library for other device drivers and kernel users of the NX coprocessors like NX-842 and NX-GZIP. In the future this will be extended to add support for user space to access the NX coprocessors.
VAS is currently only supported with 64K page size.
---
Changelog[v5]:
- [Ben Herrenschmidt]: Create and use platform device tree nodes, fix up the "reg" properties for the VAS DT node and use the platform device helpers to parse the reg properties; Use linked list of VAS instances (don't assume vasids are sequential); Use CONFIG_PPC_VAS instead of CONFIG_VAS.
Changelog[v4]:
- [Michael Neuling] Fix some accidental deletions; fix help text in Kconfig; change vas_initialized to a function; move from drivers/misc to arch/powerpc/kernel
- Drop the vas_window_reset() interface. It is not needed as window will be initialized before each use.
- Add a "depends on PPC_64K_PAGES"
Changelog[v3]:
- Zero vas_instances memory on allocation
- [Haren Myneni] Fix description in Kconfig
Changelog[v2]:
- Get HVWC, UWC and window address parameters from device tree.
--- .../devicetree/bindings/powerpc/ibm,vas.txt | 24 +++ MAINTAINERS | 18 ++ arch/powerpc/platforms/powernv/Kconfig | 14 ++ arch/powerpc/platforms/powernv/Makefile | 1 + arch/powerpc/platforms/powernv/vas-window.c | 19 +++ arch/powerpc/platforms/powernv/vas.c | 183 +++++++++++++++++++++ arch/powerpc/platforms/powernv/vas.h | 10 +- 7 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/powerpc/ibm,vas.txt create mode 100644 arch/powerpc/platforms/powernv/vas-window.c create mode 100644 arch/powerpc/platforms/powernv/vas.c
Documentation/devicetree/bindings/powerpc/ibm,vas.txt new file +24 -0
@@ -0,0 +1,24 @@ +* IBM Powerpc Virtual Accelerator Switchboard (VAS) + +VAS is a hardware mechanism that allows ekrnel subsystems and user processes +to directly submit compression and other requests to Nest accelerators (NX) +or other coprocessors functions. + +Required properties: +- compatible : should be "ibm,vas" or "ibm,power9-vas" +- ibm,vas-id : A unique identifier for each instance of VAS in the system +- reg : Should contain 4 pairs of 64-bit fields specifying the Hypervisor + window context start and length, OS/User window context start and length, + "Paste address" start and length, "Paste window id" start bit and number + of bits) +- name : "vas" + +Example: + + vas@6019100000000 { + compatible = "ibm,vas", "ibm,power9-vas"; + reg = <0x6019100000000 0x2000000 0x6019000000000 0x100000000 0x8000000000000 0x100000000 0x20 0x10>; + name = "vas"; + ibm,vas-id = <0x1>; + }; +
MAINTAINERS +18 -0
@@ -6425,6 +6425,24 @@ F: drivers/crypto/nx/nx.* F: drivers/crypto/nx/nx_csbcpb.h F: drivers/crypto/nx/nx_debugfs.h +IBM Power Virtual Accelerator Switchboard +M: Sukadev Bhattiprolu +L: [email protected] +S: Supported +F: arch/powerpc/platforms/powernv/vas* +F: arch/powerpc/include/asm/vas.h +F: arch/powerpc/include/uapi/asm/vas.h + +IBM Power 842 compression accelerator +M: Haren Myneni <[email protected]> +S: Supported +F: drivers/crypto/nx/Makefile +F: drivers/crypto/nx/Kconfig +F: drivers/crypto/nx/nx-842* +F: include/linux/sw842.h +F: crypto/842.c +F: lib/842/ + IBM Power Linux RAID adapter M: Brian King <[email protected]> S: Supported
arch/powerpc/platforms/powernv/Kconfig +14 -0
@@ -30,3 +30,17 @@ config OPAL_PRD help This enables the opal-prd driver, a facility to run processor recovery diagnostics on OpenPower machines + +config PPC_VAS + bool "IBM Virtual Accelerator Switchboard (VAS)" + depends on PPC_POWERNV && PPC_64K_PAGES + default n + help + This enables support for IBM Virtual Accelerator Switchboard (VAS). + + VAS allows accelerators in co-processors like NX-GZIP and NX-842 + to be accessible to kernel subsystems and user processes. + + VAS adapters are found in POWER9 based systems. + + If unsure, say N.
arch/powerpc/platforms/powernv/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_PPC_SCOM) += opal-xscom.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_TRACEPOINTS) += opal-tracepoints.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o +obj-$(CONFIG_PPC_VAS) += vas.o vas-window.o
arch/powerpc/platforms/powernv/vas-window.c new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Copyright 2016 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#include <linux/types.h> +#include <linux/mutex.h> + +#include "vas.h" + +/* stub for now */ +int vas_win_close (struct vas_window *window) +{ +return -1 ; +}
arch/powerpc/platforms/powernv/vas.c new file +183 -0
183 lines not on this page · raw message
arch/powerpc/platforms/powernv/vas.h +8 -2
@@ -291,14 +291,17 @@ enum vas_notify_after_count {*/ struct vas_instance {int vas_id; +bool ready;struct ida ida; +struct list_head node; +struct platform_device *pdev;u64 hvwc_bar_start;u64 hvwc_bar_len;u64 uwc_bar_start;u64 uwc_bar_len; -u64 win_base_addr; -u64 win_id_shift; +u64 paste_base_addr; +u64 paste_win_id_shift;struct mutex mutex;struct vas_window *rxwin[VAS_COP_TYPE_MAX ];
@@ -379,4 +382,7 @@ struct vas_winctx { enum vas_notify_after_count notify_after_count; }; +extern bool vas_initialized (void ); +extern struct vas_instance *find_vas_instance (int vasid); +#endif /* _VAS_H */
Signature · 1 line
2.7.4
PATCH v6 4/17 powerpc/vas: Define helpers to access MMIO regions
In reply to Sukadev BhattiproluDefine some helper functions to access the MMIO regions. We use these in follow-on patches to read/write VAS hardware registers. They are also used to later issue 'paste' instructions to submit requests to the NX hardware engines.
---
Changelog [v6]:
- Minor reorg to make setup/cleanup functions more symmetric
Changelog [v5]:
- [Ben Herrenschmidt]: Need cachable mapping for paste regions and non-cachable mapping for the MMIO regions. So, just use ioremap() for mapping the MMIO regions; use "winctx" instead of "wc" to avoid collision with "write combine".
Changelog [v3]:
- Minor reorg/cleanup of map/unmap functions
Changelog [v2]:
- Get HVWC, UWC and paste addresses from window->vinst (i.e DT) rather than kernel macros.
--- arch/powerpc/platforms/powernv/vas-window.c | 173 ++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+)
arch/powerpc/platforms/powernv/vas-window.c +173 -0
@@ -9,9 +9,182 @@#include <linux/types.h> #include <linux/mutex.h> +#include <linux/slab.h> +#include <linux/io.h> #include "vas.h" +/* +* Compute the paste address region for the window @window using the +* ->paste_base_addr and ->paste_win_id_shift we got from device tree. +*/ +void compute_paste_address (struct vas_window *window,uint64_t *addr,int *len) +{ +uint64_t base, shift; +int winid; + + base = window->vinst->paste_base_addr; + shift = window->vinst->paste_win_id_shift; + winid = window->winid; + + *addr = base + (winid << shift); +if (len) + *len =PAGE_SIZE ; + +pr_debug ("Txwin #%d: Paste addr 0x%llx\n" , winid, *addr); +} + +static inline void get_hvwc_mmio_bar (struct vas_window *window, +uint64_t *start,int *len) +{ +uint64_t pbaddr; + + pbaddr = window->vinst->hvwc_bar_start; + *start = pbaddr + window->winid *VAS_HVWC_SIZE ; + *len =VAS_HVWC_SIZE ; +} + +static inline void get_uwc_mmio_bar (struct vas_window *window, +uint64_t *start,int *len) +{ +uint64_t pbaddr; + + pbaddr = window->vinst->uwc_bar_start; + *start = pbaddr + window->winid *VAS_UWC_SIZE ; + *len =VAS_UWC_SIZE ; +} + +/* +* Map the paste bus address of the given send window into kernel address +* space. Unlike MMIO regions (map_mmio_region() below), paste region must +* be mapped cache-able and is only applicable to send windows. +*/ +void *map_paste_region (struct vas_window *txwin) +{ +int rc, len; +void *map; +char *name; +uint64_t start; + + rc = -ENOMEM ; + name =kasprintf (GFP_KERNEL ,"window-v%d-w%d" , txwin->vinst->vas_id, + txwin->winid); +if (!name) +return ERR_PTR (rc); + + txwin->paste_addr_name = name; +compute_paste_address (txwin, &start, &len); + +if (!request_mem_region (start, len, name)) { +pr_devel ("%s(): request_mem_region(0x%llx, %d) failed\n" , + __func__, start, len); + goto free_name; + } + + map =ioremap_cache (start, len); +if (!map) { +pr_devel ("%s(): ioremap_cache(0x%llx, %d) failed\n" , __func__, + start, len); + goto free_name; + } + +pr_devel ("VAS: mapped paste addr 0x%llx to kaddr 0x%p\n" , start, map); +return map; + +free_name: +kfree (name); +return ERR_PTR (rc); +} + + +static void *map_mmio_region (char *name,uint64_t start,int len) +{ +void *map; + +if (!request_mem_region (start, len, name)) { +pr_devel ("%s(): request_mem_region(0x%llx, %d) failed\n" , + __func__, start, len); +return NULL ; + } + + map =ioremap (start, len); +if (!map) { +pr_devel ("%s(): ioremap(0x%llx, %d) failed\n" , __func__, start, + len); +return NULL ; + } + +return map; +} + +static void unmap_region (void *addr,uint64_t start,int len) +{ +iounmap (addr); +release_mem_region ((phys_addr_t )start, len); +} + +/* +* Unmap the paste address region for a window. +*/ +void unmap_paste_region (struct vas_window *window) +{ +int len; +uint64_t busaddr_start; + +if (window->paste_kaddr) { +compute_paste_address (window, &busaddr_start, &len); +unmap_region (window->paste_kaddr, busaddr_start, len); + window->paste_kaddr =NULL ; +kfree (window->paste_addr_name); + window->paste_addr_name =NULL ; + } +} + +/* +* Unmap the MMIO regions for a window. +*/ +static void unmap_winctx_mmio_bars (struct vas_window *window) +{ +int len; +uint64_t busaddr_start; + +if (window->hvwc_map) { +get_hvwc_mmio_bar (window, &busaddr_start, &len); +unmap_region (window->hvwc_map, busaddr_start, len); + window->hvwc_map =NULL ; + } + +if (window->uwc_map) { +get_uwc_mmio_bar (window, &busaddr_start, &len); +unmap_region (window->uwc_map, busaddr_start, len); + window->uwc_map =NULL ; + } +} + +/* +* Find the Hypervisor Window Context (HVWC) MMIO Base Address Region and the +* OS/User Window Context (UWC) MMIO Base Address Region for the given window. +* Map these bus addresses and save the mapped kernel addresses in @window. +*/ +int map_winctx_mmio_bars (struct vas_window *window) +{ +int len; +uint64_t start; + +get_hvwc_mmio_bar (window, &start, &len); + window->hvwc_map =map_mmio_region ("HVWCM_Window" , start, len); + +get_uwc_mmio_bar (window, &start, &len); + window->uwc_map =map_mmio_region ("UWCM_Window" , start, len); + +if (!window->hvwc_map || !window->uwc_map) { +unmap_winctx_mmio_bars (window); +return -1 ; + } + +return 0 ; +} +/* stub for now */ int vas_win_close (struct vas_window *window) {
Signature · 1 line
2.7.4
PATCH v6 5/17 powerpc/vas: Define helpers to init window context
In reply to Sukadev BhattiproluDefine helpers to initialize window context registers of the VAS hardware. These will be used in follow-on patches when opening/closing VAS windows.
---
Changelog[v6]
- Add support for FTW windows and drop the fault window id code since it is not needed for FTW/kernel windows.
Changelog[v5]
- Fix: Copy the FIFO address into LFIFO_BAR register as is (don't shift address into bits 8:53).
Changelog[v4]
- Michael Neuling] Use ilog2(), radix_enabled() helpers; drop warning when 32-bit app uses VAS (a follow-on patch will check and return error). Set MSR_PR state to 0 for kernel (rather than reading from MSR).
Changelog[v3]
- Have caller, rather than init_xlate_regs() reset window regs so we don't reset any settings caller may already have set.
- Translation mode should be 0x3 (0b11) not 0x11.
- Skip initilaizing read-only registers NX_UTIL and NX_UTIL_SE
- Skip initializing adder registers from UWC - they are already initialized from the HVWC.
- Check winctx->user_win when setting translation registers
--- arch/powerpc/platforms/powernv/vas-window.c | 305 ++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/vas.h | 55 +++++ 2 files changed, 360 insertions(+)
arch/powerpc/platforms/powernv/vas-window.c +305 -0
@@ -11,6 +11,7 @@#include <linux/mutex.h> #include <linux/slab.h> #include <linux/io.h> +#include <linux/log2.h> #include "vas.h"
@@ -185,6 +186,310 @@ int map_winctx_mmio_bars(struct vas_window *window)return 0 ; } +/* +* Reset all valid registers in the HV and OS/User Window Contexts for +* the window identified by @window. +* +* NOTE: We cannot really use a for loop to reset window context. Not all +* offsets in a window context are valid registers and the valid +* registers are not sequential. And, we can only write to offsets +* with valid registers (or is that only in Simics?). +*/ +void reset_window_regs (struct vas_window *window) +{ +write_hvwc_reg (window,VREG (LPID ),0ULL ); +write_hvwc_reg (window,VREG (PID ),0ULL ); +write_hvwc_reg (window,VREG (XLATE_MSR ),0ULL ); +write_hvwc_reg (window,VREG (XLATE_LPCR ),0ULL ); +write_hvwc_reg (window,VREG (XLATE_CTL ),0ULL ); +write_hvwc_reg (window,VREG (AMR ),0ULL ); +write_hvwc_reg (window,VREG (SEIDR ),0ULL ); +write_hvwc_reg (window,VREG (FAULT_TX_WIN ),0ULL ); +write_hvwc_reg (window,VREG (OSU_INTR_SRC_RA ),0ULL ); +write_hvwc_reg (window,VREG (HV_INTR_SRC_RA ),0ULL ); +write_hvwc_reg (window,VREG (PSWID ),0ULL ); +write_hvwc_reg (window,VREG (SPARE1 ),0ULL ); +write_hvwc_reg (window,VREG (SPARE2 ),0ULL ); +write_hvwc_reg (window,VREG (SPARE3 ),0ULL ); +write_hvwc_reg (window,VREG (SPARE4 ),0ULL ); +write_hvwc_reg (window,VREG (SPARE5 ),0ULL ); +write_hvwc_reg (window,VREG (SPARE6 ),0ULL ); +write_hvwc_reg (window,VREG (LFIFO_BAR ),0ULL ); +write_hvwc_reg (window,VREG (LDATA_STAMP_CTL ),0ULL ); +write_hvwc_reg (window,VREG (LDMA_CACHE_CTL ),0ULL ); +write_hvwc_reg (window,VREG (LRFIFO_PUSH ),0ULL ); +write_hvwc_reg (window,VREG (CURR_MSG_COUNT ),0ULL ); +write_hvwc_reg (window,VREG (LNOTIFY_AFTER_COUNT ),0ULL ); +write_hvwc_reg (window,VREG (LRX_WCRED ),0ULL ); +write_hvwc_reg (window,VREG (LRX_WCRED_ADDER ),0ULL ); +write_hvwc_reg (window,VREG (TX_WCRED ),0ULL ); +write_hvwc_reg (window,VREG (TX_WCRED_ADDER ),0ULL ); +write_hvwc_reg (window,VREG (LFIFO_SIZE ),0ULL ); +write_hvwc_reg (window,VREG (WINCTL ),0ULL ); +write_hvwc_reg (window,VREG (WIN_STATUS ),0ULL ); +write_hvwc_reg (window,VREG (WIN_CTX_CACHING_CTL ),0ULL ); +write_hvwc_reg (window,VREG (TX_RSVD_BUF_COUNT ),0ULL ); +write_hvwc_reg (window,VREG (LRFIFO_WIN_PTR ),0ULL ); +write_hvwc_reg (window,VREG (LNOTIFY_CTL ),0ULL ); +write_hvwc_reg (window,VREG (LNOTIFY_PID ),0ULL ); +write_hvwc_reg (window,VREG (LNOTIFY_LPID ),0ULL ); +write_hvwc_reg (window,VREG (LNOTIFY_TID ),0ULL ); +write_hvwc_reg (window,VREG (LNOTIFY_SCOPE ),0ULL ); +write_hvwc_reg (window,VREG (NX_UTIL_ADDER ),0ULL ); + +/* Skip read-only registers: NX_UTIL and NX_UTIL_SE */ + +/* +* The send and receive window credit adder registers are also +* accessible from HVWC and have been initialized above. We don't +* need to initialize from the OS/User Window Context, so skip +* following calls: +* +* write_uwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); +* write_uwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); +*/ +} + +/* +* Initialize window context registers related to Address Translation. +* These registers are common to send/receive windows although they +* differ for user/kernel windows. As we resolve the TODOs we may +* want to add fields to vas_winctx and move the initialization to +* init_vas_winctx_regs(). +*/ +static void init_xlate_regs (struct vas_window *window,bool user_win) +{ +uint64_t lpcr, val; + +/* +* MSR_TA, MSR_US are false for both kernel and user. +* MSR_DR and MSR_PR are false for kernel. +*/ + val =0ULL ; + val =SET_FIELD (VAS_XLATE_MSR_HV , val, true); + val =SET_FIELD (VAS_XLATE_MSR_SF , val, true); +if (user_win) { + val =SET_FIELD (VAS_XLATE_MSR_DR , val, true); + val =SET_FIELD (VAS_XLATE_MSR_PR , val, true); + } +write_hvwc_reg (window,VREG (XLATE_MSR ), val); + + lpcr =mfspr (SPRN_LPCR ); + val =0ULL ; +/* +* NOTE: From Section 5.7.6.1 Segment Lookaside Buffer of the +* Power ISA, v2.07, Page size encoding is 0 = 4KB, 5 = 64KB. +* +* NOTE: From Section 1.3.1, Address Translation Context of the +* Nest MMU Workbook, LPCR_SC should be 0 for Power9. +*/ + val =SET_FIELD (VAS_XLATE_LPCR_PAGE_SIZE , val,5 ); + val =SET_FIELD (VAS_XLATE_LPCR_ISL , val, lpcr &LPCR_ISL ); + val =SET_FIELD (VAS_XLATE_LPCR_TC , val, lpcr &LPCR_TC ); + val =SET_FIELD (VAS_XLATE_LPCR_SC , val,0 ); +write_hvwc_reg (window,VREG (XLATE_LPCR ), val); + +/* +* Section 1.3.1 (Address translation Context) of NMMU workbook. +* 0b00 Hashed Page Table mode +* 0b01 Reserved +* 0b10 Radix on HPT +* 0b11 Radix on Radix +*/ + val =0ULL ; + val =SET_FIELD (VAS_XLATE_MODE , val,radix_enabled () ?3 :2 ); +write_hvwc_reg (window,VREG (XLATE_CTL ), val); + +/* +* TODO: Can we mfspr(AMR) even for user windows? +*/ + val =0ULL ; + val =SET_FIELD (VAS_AMR , val,mfspr (SPRN_AMR )); +write_hvwc_reg (window,VREG (AMR ), val); + + val =0ULL ; + val =SET_FIELD (VAS_SEIDR , val,0 ); +write_hvwc_reg (window,VREG (SEIDR ), val); +} + +/* +* Initialize Reserved Send Buffer Count for the send window. It involves +* writing to the register, reading it back to confirm that the hardware +* has enough buffers to reserve. See section 1.3.1.2.1 of VAS workbook. +* +* Since we can only make a best-effort attempt to fulfill the request, +* we don't return any errors if we cannot. +* +* TODO: Reserved (aka dedicated) send buffers are not supported yet. +*/ +static void init_rsvd_tx_buf_count (struct vas_window *txwin, +struct vas_winctx *winctx) +{ +write_hvwc_reg (txwin,VREG (TX_RSVD_BUF_COUNT ),0ULL ); +} + +/* +* init_winctx_regs() +* Initialize window context registers for a receive window. +* Except for caching control and marking window open, the registers +* are initialized in the order listed in Section 3.1.4 (Window Context +* Cache Register Details) of the VAS workbook although they don't need +* to be. +* +* Design note: For NX receive windows, NX allocates the FIFO buffer in OPAL +* (so that it can get a large contiguous area) and passes that buffer +* to kernel via device tree. We now write that buffer address to the +* FIFO BAR. Would it make sense to do this all in OPAL? i.e have OPAL +* write the per-chip RX FIFO addresses to the windows during boot-up +* as a one-time task? That could work for NX but what about other +* receivers? Let the receivers tell us the rx-fifo buffers for now. +*/ +int init_winctx_regs (struct vas_window *window,struct vas_winctx *winctx) +{ +uint64_t val; +int fifo_size; + +reset_window_regs (window); + + val =0ULL ; + val =SET_FIELD (VAS_LPID , val, winctx->lpid); +write_hvwc_reg (window,VREG (LPID ), val); + + val =0ULL ; + val =SET_FIELD (VAS_PID_ID , val, winctx->pidr); +write_hvwc_reg (window,VREG (PID ), val); + +init_xlate_regs (window, winctx->user_win); + + val =0ULL ; + val =SET_FIELD (VAS_FAULT_TX_WIN , val,0 ); +write_hvwc_reg (window,VREG (FAULT_TX_WIN ), val); + +/* In PowerNV, interrupts go to HV. */ +write_hvwc_reg (window,VREG (OSU_INTR_SRC_RA ),0ULL ); + + val =0ULL ; + val =SET_FIELD (VAS_HV_INTR_SRC_RA , val, winctx->irq_port); +write_hvwc_reg (window,VREG (HV_INTR_SRC_RA ), val); + + val =0ULL ; + val =SET_FIELD (VAS_PSWID_EA_HANDLE , val, winctx->pswid); +write_hvwc_reg (window,VREG (PSWID ), val); + +write_hvwc_reg (window,VREG (SPARE1 ),0ULL ); +write_hvwc_reg (window,VREG (SPARE2 ),0ULL ); +write_hvwc_reg (window,VREG (SPARE3 ),0ULL ); + +/* +* NOTE: VAS expects the FIFO address to be copied into the LFIFO_BAR +* register as is - do NOT shift the address into VAS_LFIFO_BAR +* bit fields! Ok to set the page migration select fields - +* VAS ignores the lower 10+ bits in the address anyway, because +* the minimum FIFO size is 1K? +* +* See also: Design note in function header. +*/ + val =__pa (winctx->rx_fifo); + val =SET_FIELD (VAS_PAGE_MIGRATION_SELECT , val,0 ); +write_hvwc_reg (window,VREG (LFIFO_BAR ), val); + + val =0ULL ; + val =SET_FIELD (VAS_LDATA_STAMP , val, winctx->data_stamp); +write_hvwc_reg (window,VREG (LDATA_STAMP_CTL ), val); + + val =0ULL ; + val =SET_FIELD (VAS_LDMA_TYPE , val, winctx->dma_type); + val =SET_FIELD (VAS_LDMA_FIFO_DISABLE , val, winctx->fifo_disable); +write_hvwc_reg (window,VREG (LDMA_CACHE_CTL ), val); + +write_hvwc_reg (window,VREG (LRFIFO_PUSH ),0ULL ); +write_hvwc_reg (window,VREG (CURR_MSG_COUNT ),0ULL ); +write_hvwc_reg (window,VREG (LNOTIFY_AFTER_COUNT ),0ULL ); + + val =0ULL ; + val =SET_FIELD (VAS_LRX_WCRED , val, winctx->wcreds_max); +write_hvwc_reg (window,VREG (LRX_WCRED ), val); + + val =0ULL ; + val =SET_FIELD (VAS_TX_WCRED , val, winctx->wcreds_max); +write_hvwc_reg (window,VREG (TX_WCRED ), val); + +write_hvwc_reg (window,VREG (LRX_WCRED_ADDER ),0ULL ); +write_hvwc_reg (window,VREG (TX_WCRED_ADDER ),0ULL ); + + fifo_size = winctx->rx_fifo_size /1024 ; + + val =0ULL ; + val =SET_FIELD (VAS_LFIFO_SIZE , val,ilog2 (fifo_size)); +write_hvwc_reg (window,VREG (LFIFO_SIZE ), val); + +/* Update window control and caching control registers last so +* we mark the window open only after fully initializing it and +* pushing context to cache. +*/ + +write_hvwc_reg (window,VREG (WIN_STATUS ),0ULL ); + +init_rsvd_tx_buf_count (window, winctx); + +/* for a send window, point to the matching receive window */ + val =0ULL ; + val =SET_FIELD (VAS_LRX_WIN_ID , val, winctx->rx_win_id); +write_hvwc_reg (window,VREG (LRFIFO_WIN_PTR ), val); + +write_hvwc_reg (window,VREG (SPARE4 ),0ULL ); + + val =0ULL ; + val =SET_FIELD (VAS_NOTIFY_DISABLE , val, winctx->notify_disable); + val =SET_FIELD (VAS_INTR_DISABLE , val, winctx->intr_disable); + val =SET_FIELD (VAS_NOTIFY_EARLY , val, winctx->notify_early); + val =SET_FIELD (VAS_NOTIFY_OSU_INTR , val, winctx->notify_os_intr_reg); +write_hvwc_reg (window,VREG (LNOTIFY_CTL ), val); + + val =0ULL ; + val =SET_FIELD (VAS_LNOTIFY_PID , val, winctx->lnotify_pid); +write_hvwc_reg (window,VREG (LNOTIFY_PID ), val); + + val =0ULL ; + val =SET_FIELD (VAS_LNOTIFY_LPID , val, winctx->lnotify_lpid); +write_hvwc_reg (window,VREG (LNOTIFY_LPID ), val); + + val =0ULL ; + val =SET_FIELD (VAS_LNOTIFY_TID , val, winctx->lnotify_tid); +write_hvwc_reg (window,VREG (LNOTIFY_TID ), val); + + val =0ULL ; + val =SET_FIELD (VAS_LNOTIFY_MIN_SCOPE , val, winctx->min_scope); + val =SET_FIELD (VAS_LNOTIFY_MAX_SCOPE , val, winctx->max_scope); +write_hvwc_reg (window,VREG (LNOTIFY_SCOPE ), val); + +/* Skip read-only registers NX_UTIL and NX_UTIL_SE */ + +write_hvwc_reg (window,VREG (SPARE5 ),0ULL ); +write_hvwc_reg (window,VREG (NX_UTIL_ADDER ),0ULL ); +write_hvwc_reg (window,VREG (SPARE6 ),0ULL ); + +/* Finally, push window context to memory and... */ + val =0ULL ; + val =SET_FIELD (VAS_PUSH_TO_MEM , val,1 ); +write_hvwc_reg (window,VREG (WIN_CTX_CACHING_CTL ), val); + +/* ... mark the window open for business */ + val =0ULL ; + val =SET_FIELD (VAS_WINCTL_REJ_NO_CREDIT , val, winctx->rej_no_credit); + val =SET_FIELD (VAS_WINCTL_PIN , val, winctx->pin_win); + val =SET_FIELD (VAS_WINCTL_TX_WCRED_MODE , val, winctx->tx_wcred_mode); + val =SET_FIELD (VAS_WINCTL_RX_WCRED_MODE , val, winctx->rx_wcred_mode); + val =SET_FIELD (VAS_WINCTL_TX_WORD_MODE , val, winctx->tx_word_mode); + val =SET_FIELD (VAS_WINCTL_RX_WORD_MODE , val, winctx->rx_word_mode); + val =SET_FIELD (VAS_WINCTL_FAULT_WIN , val, winctx->fault_win); + val =SET_FIELD (VAS_WINCTL_NX_WIN , val, winctx->nx_win); + val =SET_FIELD (VAS_WINCTL_OPEN , val,1 ); +write_hvwc_reg (window,VREG (WINCTL ), val); + +return 0 ; +} +/* stub for now */ int vas_win_close (struct vas_window *window) {
arch/powerpc/platforms/powernv/vas.h +55 -0
65 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 7/17 powerpc/vas: Define vas_win_paste_addr()
In reply to Sukadev BhattiproluDefine an interface that the NX drivers can use to find the physical paste address of a send window. This interface is expected to be used with the mmap() operation of the NX driver's device. i.e the user space process can use driver's mmap() operation to map the send window's paste address into their address space and then use copy and paste instructions to submit the CRBs to the NX engine.
Note that kernel drivers will use vas_paste_crb() directly and don't need this interface.
--- arch/powerpc/include/asm/vas.h | 7 +++++++ arch/powerpc/platforms/powernv/vas-window.c | 10 ++++++++++ 2 files changed, 17 insertions(+)
arch/powerpc/include/asm/vas.h +7 -0
@@ -12,6 +12,8 @@#include <uapi/asm/vas.h> +struct vas_window ; +/* * Min and max FIFO sizes are based on Version 1.05 Section 3.1.4.25 * (Local FIFO Size Register) of the VAS workbook.
@@ -32,4 +34,9 @@ enum vas_cop_type { VAS_COP_TYPE_MAX, }; +/* +* Return the power bus paste address associated with @win so the caller +* can map that address into their address space. +*/ +extern uint64_t vas_win_paste_addr (struct vas_window *win);#endif /* _MISC_VAS_H */
arch/powerpc/platforms/powernv/vas-window.c +10 -0
@@ -35,6 +35,16 @@ void compute_paste_address(struct vas_window *window, uint64_t *addr, int *len)pr_debug ("Txwin #%d: Paste addr 0x%llx\n" , winid, *addr); } +uint64_t vas_win_paste_addr (struct vas_window *win) +{ +uint64_t addr; + +compute_paste_address (win, &addr,NULL ); + +return addr; +} +EXPORT_SYMBOL (vas_win_paste_addr); +static inline void get_hvwc_mmio_bar (struct vas_window *window,uint64_t *start,int *len) {
Signature · 1 line
2.7.4
PATCH v6 6/17 powerpc/vas: Define helpers to alloc/free windows
In reply to Sukadev BhattiproluDefine helpers to allocate/free VAS window objects. These will be used in follow-on patches when opening/closing windows.
--- arch/powerpc/platforms/powernv/vas-window.c | 70 +++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
arch/powerpc/platforms/powernv/vas-window.c +70 -0
@@ -490,6 +490,76 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)return 0 ; } +DEFINE_SPINLOCK (vas_ida_lock); + +void vas_release_window_id (struct ida *ida,int winid) +{ +spin_lock (&vas_ida_lock); +ida_remove (ida, winid); +spin_unlock (&vas_ida_lock); +} + +int vas_assign_window_id (struct ida *ida) +{ +int rc, winid; + + rc =ida_pre_get (ida,GFP_KERNEL ); +if (!rc) +return -EAGAIN ; + +spin_lock (&vas_ida_lock); + rc =ida_get_new_above (ida,0 , &winid); +spin_unlock (&vas_ida_lock); + +if (rc) +return rc; + +if (winid >VAS_WINDOWS_PER_CHIP ) { +pr_err ("VAS: Too many (%d) open windows\n" , winid); +vas_release_window_id (ida, winid); +return -EAGAIN ; + } + +return winid; +} + +void vas_window_free (struct vas_window *window) +{ +int winid = window->winid; +struct vas_instance *vinst = window->vinst; + +unmap_winctx_mmio_bars (window); +kfree (window); + +vas_release_window_id (&vinst->ida, winid); +} + +struct vas_window *vas_window_alloc (struct vas_instance *vinst) +{ +int winid; +struct vas_window *window; + + winid =vas_assign_window_id (&vinst->ida); +if (winid <0 ) +return ERR_PTR (winid); + + window =kzalloc (sizeof (*window),GFP_KERNEL ); +if (!window) +return ERR_PTR (-ENOMEM ); + + window->vinst = vinst; + window->winid = winid; + +if (map_winctx_mmio_bars (window)) + goto out_free; + +return window; + +out_free: +kfree (window); +return ERR_PTR (-ENOMEM ); +} +/* stub for now */ int vas_win_close (struct vas_window *window) {
Signature · 1 line
2.7.4
PATCH v6 8/17 powerpc/vas: Define vas_win_id()
In reply to Sukadev BhattiproluDefine an interface to return a system-wide unique id for a given VAS window.
The vas_win_id() will be used in a follow-on patch to generate an unique handle for a user space receive window. Applications can use this handle to pair send and receive windows for fast thread-wakeup.
The hardware refers to this system-wide unique id as a Partition Send Window ID which is expected to be used during fault handling. Hence the "pswid" in the function names.
--- arch/powerpc/include/asm/vas.h | 5 +++++ arch/powerpc/platforms/powernv/vas-window.c | 9 +++++++++ arch/powerpc/platforms/powernv/vas.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+)
arch/powerpc/include/asm/vas.h +5 -0
@@ -35,6 +35,11 @@ enum vas_cop_type { };/* +* Return a system-wide unique id for the VAS window @win. +*/ +extern uint32_t vas_win_id (struct vas_window *win); + +/* * Return the power bus paste address associated with @win so the caller * can map that address into their address space. */
arch/powerpc/platforms/powernv/vas-window.c +9 -0
@@ -575,3 +575,12 @@ int vas_win_close(struct vas_window *window) {return -1 ; } + +/* +* Return a system-wide unique window id for the window @win. +*/ +uint32_t vas_win_id (struct vas_window *win) +{ +return encode_pswid (win->vinst->vas_id, win->winid); +} +EXPORT_SYMBOL_GPL (vas_win_id);
arch/powerpc/platforms/powernv/vas.h +28 -0
@@ -440,4 +440,32 @@ static inline uint64_t read_hvwc_reg(struct vas_window *win, return in_be64(win->hvwc_map+reg); } +/* +* Encode/decode the Partition Send Window ID (PSWID) for a window in +* a way that we can uniquely identify any window in the system. i.e. +* we should be able to locate the 'struct vas_window' given the PSWID. +* +* Bits Usage +* 0:7 VAS id (8 bits) +* 8:15 Unused, 0 (3 bits) +* 16:31 Window id (16 bits) +*/ +static inline u32 encode_pswid (int vasid,int winid) +{ +u32 pswid =0 ; + + pswid |= vasid << (31 -7 ); + pswid |= winid; + +return pswid; +} + +static inline void decode_pswid (u32 pswid,int *vasid,int *winid) +{ +if (vasid) + *vasid = pswid >> (31 -7 ) &0xFF ; + +if (winid) + *winid = pswid &0xFFFF ; +}#endif /* _VAS_H */
Signature · 1 line
2.7.4
PATCH v6 9/17 powerpc/vas: Define vas_rx_win_open() interface
In reply to Sukadev BhattiproluDefine the vas_rx_win_open() interface. This interface is intended to be used by the Nest Accelerator (NX) driver(s) to setup receive windows for one or more NX engines (which implement compression/encryption algorithms in the hardware).
Follow-on patches will provide an interface to close the window and to open a send window that kenrel subsystems can use to access the NX engines.
The interface to open a receive window is expected to be invoked for each instance of VAS in the system.
---
Changelog[v6]:
- Add support for FTW windows
Changelog[v4]:
- Export the symbols
Changelog[v3]:
- Fault receive windows must enable interrupts and disable notifications. NX Windows are opposite.
- Use macros rather than enum for threshold-control mode
- Ignore irq_ports for in-kernel windows. They are needed for user space windows and will be added later
--- arch/powerpc/include/asm/vas.h | 47 ++++ arch/powerpc/platforms/powernv/vas-window.c | 357 +++++++++++++++++++++++++++- arch/powerpc/platforms/powernv/vas.h | 14 ++ 3 files changed, 417 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/vas.h +47 -0
@@ -35,6 +35,36 @@ enum vas_cop_type { };/* +* Receive window attributes specified by the (in-kernel) owner of window. +*/ +struct vas_rx_win_attr { +void *rx_fifo; +int rx_fifo_size; +int wcreds_max; + +bool pin_win; +bool rej_no_credit; +bool tx_wcred_mode; +bool rx_wcred_mode; +bool tx_win_ord_mode; +bool rx_win_ord_mode; +bool data_stamp; +bool nx_win; +bool fault_win; +bool user_win; +bool notify_disable; +bool intr_disable; +bool notify_early; + +int lnotify_lpid; +int lnotify_pid; +int lnotify_tid; +uint32_t pswid; + +int tc_mode; +}; + +/* * Return a system-wide unique id for the VAS window @win. */ extern uint32_t vas_win_id (struct vas_window *win);
@@ -44,4 +74,21 @@ extern uint32_t vas_win_id(struct vas_window *win);* can map that address into their address space. */ extern uint64_t vas_win_paste_addr (struct vas_window *win); + +/* +* Helper to initialize receive window attributes to defaults for an +* NX window. +*/ +extern void vas_init_rx_win_attr (struct vas_rx_win_attr *rxattr, +enum vas_cop_type cop); + +/* +* Open a VAS receive window for the instance of VAS identified by @vasid +* Use @attr to initialize the attributes of the window. +* +* Return a handle to the window or ERR_PTR() on error. +*/ +extern struct vas_window *vas_rx_win_open (int vasid,enum vas_cop_type cop, +struct vas_rx_win_attr *attr); +#endif /* _MISC_VAS_H */
arch/powerpc/platforms/powernv/vas-window.c +356 -1
375 lines not on this page · raw message
arch/powerpc/platforms/powernv/vas.h +14 -0
@@ -289,6 +289,9 @@ enum vas_notify_after_count {/* * One per instance of VAS. Each instance will have a separate set of * receive windows, one per coprocessor type. +* +* See also function header of set_vinst_win() for details on ->windows[] +* and ->rxwin[] tables. */ struct vas_instance {int vas_id;
@@ -397,6 +400,16 @@ extern struct vas_instance *find_vas_instance(int vasid);#define VREG (r) VREG_SFX(r, _OFFSET)#ifdef vas_debug +static inline void dump_rx_win_attr (struct vas_rx_win_attr *attr) +{ +pr_err ("VAS: fault %d, notify %d, intr %d early %d\n" , + attr->fault_win, attr->notify_disable, + attr->intr_disable, attr->notify_early); + +pr_err ("VAS: rx_fifo_size %d, max value %d\n" , + attr->rx_fifo_size,VAS_RX_FIFO_SIZE_MAX ); +} +static inline void vas_log_write (struct vas_window *win,char *name,void *regptr,uint64_t val) {
@@ -409,6 +422,7 @@ static inline void vas_log_write(struct vas_window *win, char *name,#else /* vas_debug */ #define vas_log_write (win, name, reg, val) +#define dump_rx_win_attr (attr)#endif /* vas_debug */
Signature · 1 line
2.7.4
PATCH v6 10/17 powerpc/vas: Define vas_rx_win_open() interface
In reply to Sukadev BhattiproluDefine the vas_rx_win_open() interface. This interface is intended to be used by the Nest Accelerator (NX) driver(s) to setup receive windows for one or more NX engines (which implement compression/encryption algorithms in the hardware).
Follow-on patches will provide an interface to close the window and to open a send window that kenrel subsystems can use to access the NX engines.
The interface to open a receive window is expected to be invoked for each instance of VAS in the system.
---
Changelog[v6]:
- Add support for FTW windows
Changelog[v4]:
- Export the symbols
Changelog[v3]:
- Fault receive windows must enable interrupts and disable notifications. NX Windows are opposite.
- Use macros rather than enum for threshold-control mode
- Ignore irq_ports for in-kernel windows. They are needed for user space windows and will be added later
--- arch/powerpc/platforms/powernv/vas-window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/vas-window.c +1 -1
@@ -717,7 +717,7 @@ void clear_vinst_win(struct vas_window *window)mutex_lock (&vinst->mutex); -if (!window->tx_win) { +if (!window->user_win && !window->tx_win) {WARN_ON_ONCE (!vinst->rxwin[window->cop]); vinst->rxwin[window->cop] =NULL ; }
Signature · 1 line
2.7.4
PATCH v6 11/17 powerpc/vas: Define vas_win_close() interface
In reply to Sukadev BhattiproluDefine the vas_win_close() interface which should be used to close a send or receive windows.
While the hardware configurations required to open send and receive windows differ, the configuration to close a window is the same for both. So we use a single interface to close the window.
---
Changelog[v4]:
- Drop the poll for credits return (we can set the required credit, but cannot really find the available credit at a point in time)
- Export the symbol
Changelog[v3]:
- Fix order of parameters in GET_FIELD().
- Update references and sequence for closing/quiescing a window.
--- arch/powerpc/include/asm/vas.h | 7 ++ arch/powerpc/platforms/powernv/vas-window.c | 99 +++++++++++++++++++++++++++-- 2 files changed, 101 insertions(+), 5 deletions(-)
arch/powerpc/include/asm/vas.h +7 -0
@@ -91,4 +91,11 @@ extern void vas_init_rx_win_attr(struct vas_rx_win_attr *rxattr,extern struct vas_window *vas_rx_win_open (int vasid,enum vas_cop_type cop,struct vas_rx_win_attr *attr); +/* +* Close the send or receive window identified by @win. For receive windows +* return -EAGAIN if there are active send windows attached to this receive +* window. +*/ +int vas_win_close (struct vas_window *win); +#endif /* _MISC_VAS_H */
arch/powerpc/platforms/powernv/vas-window.c +94 -5
132 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 12/17 powerpc/vas: Define vas_tx_win_open()
In reply to Sukadev BhattiproluDefine an interface to open a VAS send window. This interface is intended to be used the Nest Accelerator (NX) driver(s) to open a send window and use it to submit compression/encryption requests to a VAS receive window.
The receive window, identified by the [vasid, cop] parameters, must already be open in VAS (i.e connected to an NX engine).
---
Changelog[v6]:
- Add support for FTW windows
Changelog[v4]:
- [Ben Herrenschmidt] MMIO regions must be mapped non-cached and paste regions must be mapped cached. Define/use map_paste_region().
Changelog [v3]:
- Distinguish between hardware PID (SPRN_PID) and Linux pid.
- Use macros rather than enum for threshold-control mode
- Set the pid of send window from attr (needed for user space send windows).
- Ignore irq port setting for now. They are needed for user space windows and will be added later
--- arch/powerpc/include/asm/vas.h | 42 ++++++++ arch/powerpc/platforms/powernv/vas-window.c | 157 +++++++++++++++++++++++++++- 2 files changed, 196 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/vas.h +42 -0
@@ -65,6 +65,29 @@ struct vas_rx_win_attr { };/* +* Window attributes specified by the in-kernel owner of a send window. +*/ +struct vas_tx_win_attr { +enum vas_cop_type cop; +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; + +bool user_win; +bool pin_win; +bool rej_no_credit; +bool rsvd_txbuf_enable; +bool tx_wcred_mode; +bool rx_wcred_mode; +bool tx_win_ord_mode; +bool rx_win_ord_mode; +}; + +/* * Return a system-wide unique id for the VAS window @win. */ extern uint32_t vas_win_id (struct vas_window *win);
@@ -92,6 +115,25 @@ extern struct vas_window *vas_rx_win_open(int vasid, enum vas_cop_type cop, struct vas_rx_win_attr *attr);/* +* Helper to initialize send window attributes to defaults for an NX window. +*/ +extern void vas_init_tx_win_attr (struct vas_tx_win_attr *txattr, +enum vas_cop_type cop); + +/* +* Open a VAS send window for the instance of VAS identified by @vasid +* and the co-processor type @cop. Use @attr to initialize attributes +* of the window. +* +* Note: The instance of VAS must already have an open receive window for +* the coprocessor type @cop. +* +* Return a handle to the send window or ERR_PTR() on error. +*/ +struct vas_window *vas_tx_win_open (int vasid,enum vas_cop_type cop, +struct vas_tx_win_attr *attr); + +/* * Close the send or receive window identified by @win. For receive windows * return -EAGAIN if there are active send windows attached to this receive * window.
arch/powerpc/platforms/powernv/vas-window.c +154 -3
181 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 13/17 powerpc/vas: Define copy/paste interfaces
In reply to Sukadev BhattiproluDefine interfaces (wrappers) to the 'copy' and 'paste' instructions (which are new in PowerISA 3.0). These are intended to be used to by NX driver(s) to submit Coprocessor Request Blocks (CRBs) to the NX hardware engines.
---
Changelog[v4]
- Export symbols
Changelog[v3]
- Map raw CR value from paste instruction into an error code.
--- MAINTAINERS | 1 + arch/powerpc/include/asm/vas.h | 13 +++++ arch/powerpc/platforms/powernv/copy-paste.h | 74 +++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/vas-window.c | 52 ++++++++++++++++++++ arch/powerpc/platforms/powernv/vas.h | 15 ++++++ 5 files changed, 155 insertions(+) create mode 100644 arch/powerpc/platforms/powernv/copy-paste.h
MAINTAINERS +1 -0
@@ -6430,6 +6430,7 @@ M: Sukadev Bhattiprolu L: [email protected] S: Supported F: arch/powerpc/platforms/powernv/vas* +F: arch/powerpc/platforms/powernv/copy-paste.h F: arch/powerpc/include/asm/vas.h F: arch/powerpc/include/uapi/asm/vas.h
arch/powerpc/include/asm/vas.h +13 -0
@@ -140,4 +140,17 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop,*/ int vas_win_close (struct vas_window *win); +/* +* Copy the co-processor request block (CRB) @crb into the local L2 cache. +* For now, @offset must be 0 and @first must be true. +*/ +extern int vas_copy_crb (void *crb,int offset,bool first); + +/* +* Paste a previously copied CRB (see vas_copy_crb()) from the L2 cache to +* the hardware address associated with the window @win. For now, @off must +* 0 and @last must be true. @re is expected/assumed to be true for NX windows. +*/ +extern int vas_paste_crb (struct vas_window *win,int off,bool last,bool re); +#endif /* _MISC_VAS_H */
arch/powerpc/platforms/powernv/copy-paste.h new file +74 -0
74 lines not on this page · raw message
arch/powerpc/platforms/powernv/vas-window.c +52 -0
64 lines not on this page · raw message
arch/powerpc/platforms/powernv/vas.h +15 -0
@@ -482,4 +482,19 @@ static inline void decode_pswid(u32 pswid, int *vasid, int *winid)if (winid) *winid = pswid & 0xFFFF; } + +#ifdef vas_debug + +static void print_fifo_msg_count (struct vas_window *txwin) +{ +uint64_t read_hvwc_reg (struct vas_window *w,char *n,uint64_t o); +pr_devel ("Winid %d, Msg count %llu\n" , txwin->winid, + (uint64_t )read_hvwc_reg (txwin,VREG (LRFIFO_PUSH ))); +} +#else /* vas_debug */ + +#define print_fifo_msg_count (window) + +#endif /* vas_debug */ +#endif /* _VAS_H */
Signature · 1 line
2.7.4
PATCH v6 14/17 powerpc: Add support for setting SPRN_TIDR
In reply to Sukadev BhattiproluWe need the SPRN_TIDR to bet set for use with fast thread-wakeup (core-to-core wakeup). Each thread in a process needs to have a unique id within the process but as explained below, for now, we assign globally unique thread ids to all threads in the system.
--- arch/powerpc/include/asm/processor.h | 4 ++ arch/powerpc/kernel/process.c | 74 ++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+)
arch/powerpc/include/asm/processor.h +4 -0
@@ -232,6 +232,10 @@ struct debug_reg {struct thread_struct {unsigned long ksp;/* Kernel stack pointer */ +#ifdef CONFIG_PPC_VAS +unsigned long tidr; +#endif +#ifdef CONFIG_PPC64 unsigned long ksp_vsid;#endif
arch/powerpc/kernel/process.c +74 -0
95 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 15/17 powerpc/vas: Define window open ioctls API
In reply to Sukadev BhattiproluDefine the VAS_TX_WIN_OPEN and VAS_RX_WIN_OPEN ioctl interface. Each user of VAS, like the NX-FTW driver in a follow-on patch, should implement these ioctls.
--- arch/powerpc/include/uapi/asm/vas.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
arch/powerpc/include/uapi/asm/vas.h +30 -0
@@ -10,6 +10,8 @@#ifndef _UAPI_MISC_VAS_H#define _UAPI_MISC_VAS_H +#include <asm/ioctl.h> +/* * Threshold Control Mode: Have paste operation fail if the number of * requests in receive FIFO exceeds a threshold.
@@ -22,6 +24,34 @@#define VAS_THRESH_FIFO_GT_QTR_FULL 2#define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3 +#define VAS_FLAGS_PIN_WINDOW 0x1 +#define VAS_FLAGS_HIGH_PRI 0x2 + +#define VAS_TX_WIN_OPEN _IOW('v', 1, struct vas_tx_win_open_attr) +#define VAS_RX_WIN_OPEN _IOW('v', 2, struct vas_rx_win_open_attr) + +struct vas_tx_win_open_attr { +int16_t version; +int16_t vas_id; +uint32_t rx_win_handle; + +int64_t reserved1; + +int64_t flags; +int64_t reserved2; + +int32_t tc_mode; +int32_t rsvd_txbuf; +int64_t reserved3[6 ]; +}; + +struct vas_rx_win_open_attr { +int16_t version; +int16_t vas_id; +uint32_t rx_win_handle;/* output field */ +int64_t reserved[8 ]; +}; +/* * Get/Set bit fields */
Signature · 1 line
2.7.4
PATCH v6 16/17 powerpc/vas: Implement a simple FTW driver
In reply to Sukadev BhattiproluThe Fast Thread Wake-up (FTW) driver provides user space applications an interface to the Core-to-Core functionality in POWER9. The driver provides the device node/ioctl API to applications and uses the external interfaces to the VAS driver to interact with the VAS hardware.
A follow-on patch provides detailed description of the API for the driver.
--- MAINTAINERS | 1 + arch/powerpc/platforms/powernv/Kconfig | 16 ++ arch/powerpc/platforms/powernv/Makefile | 1 + arch/powerpc/platforms/powernv/nx-ftw.c | 486 ++++++++++++++++++++++++++++++++ 4 files changed, 504 insertions(+) create mode 100644 arch/powerpc/platforms/powernv/nx-ftw.c
MAINTAINERS +1 -0
@@ -6431,6 +6431,7 @@ L: [email protected] S: Supported F: arch/powerpc/platforms/powernv/vas* F: arch/powerpc/platforms/powernv/copy-paste.h +F: arch/powerpc/platforms/powernv/nx-ftw* F: arch/powerpc/include/asm/vas.h F: arch/powerpc/include/uapi/asm/vas.h
arch/powerpc/platforms/powernv/Kconfig +16 -0
@@ -44,3 +44,19 @@ config PPC_VAS VAS adapters are found in POWER9 based systems. If unsure, say N. + +config PPC_FTW + bool "IBM Fast Thread-Wakeup (FTW)" + depends on PPC_VAS + default n + help + This enables support for IBM Fast Thread-Wakeup driver. + + The FTW driver allows applications to utilize a low overhead + core-to-core wake up mechansim in the IBM Virtual Accelerator + Switchboard (VAS) to improve performance. + + VAS adapters are found in POWER9 based systems and are required + for the FTW driver to be operational. + + If unsure, say N.
arch/powerpc/platforms/powernv/Makefile +1 -0
@@ -13,3 +13,4 @@ obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_TRACEPOINTS) += opal-tracepoints.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o obj-$(CONFIG_PPC_VAS) += vas.o vas-window.o +obj-$(CONFIG_PPC_FTW) += nx-ftw.o
arch/powerpc/platforms/powernv/nx-ftw.c new file +486 -0
486 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 17/17 powerpc/vas: Document FTW API/usage
In reply to Sukadev BhattiproluDocument the usage of the VAS Fast thread-wakeup API.
Thanks for input/comments from Benjamin Herrenschmidt, Michael Neuling, Michael Ellerman, Robert Blackmore, Ian Munsie, Haren Myneni, Paul Mackerras.
--- Documentation/powerpc/ftw-api.txt | 373 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 373 insertions(+) create mode 100644 Documentation/powerpc/ftw-api.txt
Documentation/powerpc/ftw-api.txt new file +373 -0
@@ -0,0 +1,373 @@ +Virtual Accelerator Switchboard and Fast Thread-Wakeup API + + Power9 processor supports a hardware subystem known as the Virtual + Accelerator Switchboard (VAS) which allows two entities in the Power9 + system to efficiently exchange messages. Messages must be formatted as + Coprocessor Reqeust Blocks (CRB) and be submitted using the COPY/PASTE + instructions (new in Power9). + + Usage of VAS depends on the entities exchanging the messages and + currently two usages have been identified. + + First usage of VAS, referred to as VAS/NX involves a software thread + submitting data compression requests to a co-processor (hardware/nest + accelerator) aka NX engine. The API for this usage is described in the + VAS/NX API document. + + Alternatively, VAS can be used by two software threads to efficiently + exchange messages. Initially, this mechanism is intended to wake up a + waiting thread quickly - i.e "fast thread wake-up (FTW)". This document + describes the user API for this VAS/FTW mechanism. + + Application access to the FTW mechanism is provided through the NX-FTW + device node (/dev/crypto/nx-ftw) implemented by the VAS/FTW device + driver. + + A software thread T1 that intends to wait for an event must first setup + a receive window, by opening the NX-FTW device and using the + VAS_RX_WIN_OPEN ioctl. Upon successful return from the VAS_RX_WIN_OPEN + ioctl, an rx_win_handle is returned. + + A software thread T2 that intends to wake up T1 at some point, must first + set up a "send window" using the VAS_TX_WIN_OPEN ioctl and specify the + rx_win_handle obtained by T1. After a successful VAS_TX_WIN_OPEN ioctl the + send window of T2 is considered paired with the receive window of T1. The + thread T2 must then use mmap() to obtain a "paste address" for the send + window. + + With this set up, thread T1 can wait for an event using the WAIT + instruction. + + Thread T2 can wake up T1 by using the "COPY/PASTE" instructions and + submitting an empty/NULL CRB to the send window's paste address. The + wait/wake up process can be repeated as long as the threads have the + send/receive windows open. + +1. NX-FTW Device Node + + There is one /dev/crypto/nx-ftw node in the system and it provides + access to the VAS/FTW functionality. + + The only valid operations on the NX-FTW node are: + + - open() the device for read and write. + + - issue either VAS_RX_WIN_OPEN or VAS_TX_WIN_OPEN ioctls to set up + receive or send (only one of them per open). + + - if the open is associated with send window (i.e VAS_TX_WIN_OPEN + ioctl was issued) mmap() the send window into the application's + virtual address space. (i.e get a 'paste_address' for the send + window). + + - close the device node. + + Other file operations on the NX-FTW node are undefined. + + Note tHAT the COPY and PASTE operations go directly to the hardware + and not go through the NX-FTW device. + + Although a system may have several instances of the VAS in the system + (typically, one per P9 chip) there is just one NX-FTW device node in + the system. + + When the NX-FTW device node is opened, the kernel assigns a suitable + instance of VAS to the process. Kernel will make a best-effort attempt + to assign an optimal instance of VAS for the process. In the initial + release, the kernel does not support migrating the VAS instance if the + process migrates from a processor on one chip to a processor on another + chip. + + Applications may chose a specific instance of the VAS using the 'vas_id' + field in the VAS_TX_WIN_OPEN and VAS_RX_WIN_OPEN ioctls as detailed below. + +2. Open NX-FTW node + + The device should be opened for read and write. No special privileges + are needed to open the device. The device may be opened multiple times. + + Each open() of the NX-FTW device may be associated with either a send + window or receive window but not both. + + See open(2) system call man pages for other details such as return + values, error codes and restrictions. + +3. Setup Receive window (VAS_RX_WIN_OPEN ioctl) + + A thread that expects to wait for events and be woken up using COPY/PASTE + must first set up a receive window by issuing the VAS_RX_WIN_OPEN ioctl. + + #include <asm/vas.h> + + struct vas_rx_win_open_attr rxattr; + + rc = ioctl(fd, VAS_RX_WIN_OPEN, &rxattr); + + The attributes of rxattr are as follows: + + struct vas_rx_win_open_attr { + int16_t version; + int16_t vas_id; + int32_t rx_win_handle; /* output field */ + int64_t reserved[8]; + }; + + The version field identifies the version of the API and must currently + be set to 1. + + The vas_id field identifies a specific instance of the VAS that the + application wishes to access. See section on VAS ID below. + + The reserved field must be set to all zeroes. + + Upon successful return from the ioctl, the rx_win_handle field contains + an identifier for the VAS window associated with this "sleeping" thread. + + This rx_win_handle field is used to "pair" this receive window with a + send window and must be specified when opening the corresponding send + window (see struct vas_tx_win_open_attr below). + + Return value: + + The VAS_RX_WIN_OPEN ioctl returns 0 on success. On error, it returns -1 + and sets the errno variable to indicate the error. + + Error codes: + + EINVAL version is invalid + + EINVAL vas_id is invalid + + EINVAL reserved field is not set to zeroes + + EINVAL fd is already associated with a send window + + +3. Set up a Send window (VAS_TX_WIN_OPEN ioctl) + + An application thread that expects to wake up a waiting thread using + copy/paste, must first set up a send window that is paired with the + receive window of the waiting thread. This is accomplished using the + VAS_TX_WIN_OPEN ioctl. + + #include <asm/vas.h> + + struct vas_tx_win_open_attr txattr; + + rc = ioctl(fd, VAS_TX_WIN_OPEN, &txattr); + + The attributes 'txattr' for the VAS_TX_WIN_OPEN ioctl are defined as + follows: + + struct vas_tx_win_open_attr { + int32_t version; + int16_t vas_id; + uint32_t rx_win_handle; + + int64_t reserved1; + + int64_t flags; + int64_t reserved2; + + int32_t tc_mode; + int32_t rsvd_txbuf; + int64_t reserved3[6]; + }; + + The version field must currently be set to 1. + + The vas_id field identifies a specific instance of the VAS that the + application wishes to access. See section on VAS ID below. + + The rx_win_handle field must be set to the rx_win_handle returned by + a prior successful call to VAS_RX_WIN_OPEN ioctl (see above). This + field is used to pair this send window with a receive window. The + process must have sufficient permissions to communicate with the + process owning the receive window identified by rx_win_handle. + + The tc_mode and rsvd_txbuf fields are currently unused and must be + set to 0 + + The flags field specifies additional attributes to the window. The + only valid bit in the flag are for FTW windows is: + + VAS_FLAGS_PIN_WINDOW if set, indicates the a window should be + pinned in cache. This flag is restricted + to privileged users. See Pinning windows + below. + + All the other bits in the flags field must be set to 0. + + The fields reserved1, reserved2 and reserved3 are for future extension + and must be set to 0. + + Return value: + + The VAS_TX_WIN_OPEN ioctl returns 0 on success. On error, it returns -1 + and sets the errno variable to indicate the error. + + Error conditions: + + EINVAL version, vas_id or rx_win_handle fields are invalid + + EINVAL fd does not refer to a valid VAS device. + + EINVAL fd is already associated with a receive window + + ENOSPC System has too many active windows (connections) open, + + EINVAL For FTW windows, rsvd_txbuf is not 0. + + EINVAL For FTW windows, tc_mode is not VAS_THRESH_DISABLED. + + EPERM VAS_FLAGS_PIN_WINDOW is set in 'flags' field and process + is not privileged. + + EPERM VAS_FLAGS_HIGH_PRI is set in 'flags' field and process + is not privileged. + + EINVAL an invalid flag is set in the 'flags' field. (For FTW + windows, VAS_FLAGS_HIGH_PRI is also invalid). + + EINVAL reserved fields are not set to 0. + + See the ioctl(2) man page for more details, error codes and restrictions. + +4. mmap() NX-FTW device fd + + The mmap() system call for a NX-FTW device fd returns a "paste address" + that the application can use to COPY/PASTE a CRB to the waiting thread. + + paste_addr = mmap(NULL, size, prot, flags, fd, offset); + + The mmap() operation is only valid on a file descriptor associated + with a send window. + + Only restrictions on mmap for a NX-FTW device fd are: + + - size parameter should be one page size + + - offset parameter should be 0ULL. + + Refer to mmap(2) man page for additional details/restrictions. + + In addition to the error conditions listed on the mmap(2) man page, + mmap() can also fail with one of following error codes: + + EINVAL fd is not associated with an open send window (i.e mmap() + does not follow a successful call to the VAS_TX_WIN_OPEN + ioctl). + + EINVAL offset field is not 0ULL. + + +5. VAS ID + + A system may have several instances of VAS in the hardware, typically + one per POWER 9 chip. The choice of a specific instance of VAS can have + significant impact on the performance, specially if the application + migrates from one CPU to another. Applications can specify a vas_id + using the VAS_TX_WIN_OPEN and VAS_RX_WIN_OPEN ioctls and should be + prudent in choosing an instance of VAS. + + The vas_id for each instance of VAS is listed as the device tree + property 'ibm,vas-id'. Determining the specific vas_id to use for + a specific application thread is beyond the scope of this API. + + If the application has no preference, the vas_id field may be set to + -1 and the kernel will choose a suitable instance of the VAS engine. + +6. COPY/PASTE operations: + + Applications should use the COPY and PASTE instructions defined in + the RFC to copy/paste the CRB. For VAS/FTW usage, the contents of + CRB if any, are ignored. CRB can be NULL. + +7. Interrupt completion and signal handling + + No VAS-specific signals will be generated to the application threads + with the VAS/FTW usage. + + +8. Example/Proposed usage of the VAS/FTW API + + In the following example we use two threads that use the VAS/FTW API. + Thread T1 uses the WAIT instruction to wait for an event. Thread T2 + uses copy/paste instructions to wake up T1. + + Common interfaces: + + static bool paste_done; + uint32_t rx_win_handle; + + #define WAIT .long (0x7C00003C) + + static inline int do_wait(void) + { + __asm__ __volatile(stringify_in_c(WAIT)";"); + } + + /* + * Check if paste_done is true + */ + static bool is_paste_done(void) + { + return __sync_bool_compare_and_swap(&paste_done, 1, 0); + + } + + /* + * Set paste_done to true + */ + static inline void set_paste_done(void) + { + __sync_bool_compare_and_swap(&paste_done, 0, 1); + } + + Thread T1: + + struct vas_rx_win_open_attr rxattr; + + fd = open("/dev/crypto/nx-ftw", O_RDWR); + + memset(&rxattr, 0, sizeof(rxattr)); + rxattr.version = 1; + + rc = ioctl(fd, VAS_RX_WIN_OPEN, &rxattr); + + rx_win_handle = rxattr.rx_win_handle; + + /* Tell T2 that Rx window is ready to be paired */ + pthread_cond_signal(&rx_win_ready); + + /* Rx set up done */ + + /* later, wait for an event to occur */ + + while(!is_paste_done()) + do_wait(); + + Thread T2: + + struct vas_tx_win_open_attr txattr; + + fd = open("/dev/crypto/nx-ftw", O_RDWR); + + /* Wait for Rx window to be set up first */ + pthread_cond_wait(&rx_win_ready); + + memset(&txattr, 0, sizeof(txattr)); + txattr.version = 1; + txattr.rx_win_handle = rx_win_handle; + + rc = ioctl(fd, VAS_TX_WIN_OPEN, &txattr); + + prot = PROT_READ|PROT_WRITE; + paste_addr = mmap(NULL, 4096, prot, MAP_SHARED, fd, 0ULL); + + /* Tx setup done */ + + /* later ... */ + + set_paste_done(); /* ... event occured */ + write_null_crb(paste_addr); /* wake up T1 */
Signature · 1 line
2.7.4
Michael Ellerman
reviewerRe: [PATCH v6 01/17] powerpc/vas: Define macros, register fields and structures
In reply to Sukadev BhattiproluQuoted 27 lines · Sukadev Bhattiprolu
Define macros for the VAS hardware registers and bit-fields as well as couple of data structures needed by the VAS driver.
Signed-off-by Sukadev Bhattiprolu <[email protected]>---
Changelog[v6]
- Add some fields for FTW windowsChangelog[v4]
- [Michael Neuling] Move VAS code toarch/powerpc; Reorgvas.handvas-internal.hto kernel and uapi versions; rather than creating separate properties for window context/address entries in device tree, combine them into "reg" properties; drop ->hwirq andirq_portfields fromvas_windowas they are only needed with user space windows.
- Drop the error check forCONFIG_PPC_4K_PAGES. Instead in a follow-on patch add a "depends onCONFIG_PPC_64K_PAGES".Changelog[v3]
- Renamewinctx->pidtowinctx->pidrto reflect that its a value from the PID register (SPRN_PID), not the linux process id.
- Make it easier to split header into kernel/user parts
- To keep user interface simple, use macros rather than enum for the threshold-control modes.
- Add a pid field to structvas_window- needed for user space send windows.
Quoted 7 lines
Changelog[v2]
- Add an overview of VAS invas-internal.h
- Get window context parameters from device tree and drop unnecessary macros.--- arch/powerpc/include/asm/vas.h | 35 ++++ arch/powerpc/include/uapi/asm/vas.h | 25 +++
I thought we weren't exposing VAS to userspace yet?
If we are then we need to get things straight WRT copy/paste abort.
cheers
Nicholas Piggin
reviewerRe: [PATCH v6 01/17] powerpc/vas: Define macros, register fields and structures
Quoted 8 lines · On Mon, 14 Aug 2017 15:21:48 +1000 Michael Ellerman <[email protected]> wrote:
Quoted 2 lines · Sukadev Bhattiprolu
arch/powerpc/include/asm/vas.h | 35 ++++ arch/powerpc/include/uapi/asm/vas.h | 25 +++I thought we weren't exposing VAS to userspace yet?
If we are then we need to get things straight WRT copy/paste abort.
No we should not be. This might be just a leftover hunk that should be moved to a future series.
At the moment (as far as I understand) it should be limited to preempt-disabled, process context, kernel users which avoids any concern for switch_to.
Thanks,
Nick
Michael Ellerman
reviewerRe: [PATCH v6 16/17] powerpc/vas: Implement a simple FTW driver
In reply to Sukadev BhattiproluHi Suka,
Some comments inline ...
Quoted 5 lines · Sukadev Bhattiprolu
The Fast Thread Wake-up (FTW) driver provides user space applications an interface to the Core-to-Core functionality in POWER9. The driver provides the device node/ioctl API to applications and uses the external interfaces to the VAS driver to interact with the VAS hardware.
Quoted 8 lines
A follow-on patch provides detailed description of the API for the driver.
Signed-off-by Sukadev Bhattiprolu <[email protected]>--- MAINTAINERS | 1 + arch/powerpc/platforms/powernv/Kconfig | 16 ++ arch/powerpc/platforms/powernv/Makefile | 1 + arch/powerpc/platforms/powernv/nx-ftw.c | 486 ++++++++++++++++++++++++++++++++
AFAICS this has nothing to do with NX, so why is it called nx-ftw ?
Also aren't we going to want to use this on pseries eventually? If so should it go in arch/powerpc/sysdev ?
arch/powerpc/platforms/powernv/nx-ftw.c
Quoted 15 lines
arch/powerpc/platforms/powernv/Makefile +1
-0@@ -13,3 +13,4 @@ obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_TRACEPOINTS) += opal-tracepoints.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o obj-$(CONFIG_PPC_VAS) += vas.o vas-window.o +obj-$(CONFIG_PPC_FTW) += nx-ftw.oarch/powerpc/platforms/powernv/nx-ftw.c new file +0
-0@@ -0,0 +1,486 @@
Missing license header.
Quoted 9 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +9
-0+#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/export.h> +#include <asm/cputable.h> +#include <linux/device.h> +#include <linux/debugfs.h> +#include <linux/cdev.h> +#include <linux/mutex.h> +#include <linux/fs.h>
arch/powerpc/platforms/powernv/nx-ftw.c line 19
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+#include <linux/mm.h> +#include <linux/slab.h> +#include <linux/sched.h> +#include <linux/uaccess.h> +#include <linux/bootmem.h> +#include <asm/opal-api.h> +#include <asm/opal.h> +#include <asm/page.h> +#include <asm/vas.h> +#include <asm/reg.h>
Please try and trim the list to what you need.
Quoted 15 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +15
-0+ +/* +* NX-FTW is a device driver used to provide user space access to the +* Core-to-Core aka Fast Thread Wakeup (FTW) functionality provided by +* the Virtual Accelerator Subsystem (VAS) in POWER9 systems. See also +* arch/powerpc/platforms/powernv/vas*. +* +* The driver creates the device node /dev/crypto/nx-ftw that can be +* used as follows: +* +* fd = open("/dev/crypto/nx-ftw", O_RDWR); +* rc = ioctl(fd, VAS_RX_WIN_OPEN, &rxattr); +* rc = ioctl(fd, VAS_TX_WIN_OPEN, &txattr); +* paste_addr = mmap(NULL, PAGE_SIZE, prot, MAP_SHARED, fd, 0ULL). +* vas_copy(&crb, 0, 1);
arch/powerpc/platforms/powernv/nx-ftw.c line 44
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+* vas_paste(paste_addr, 0, 1); +* +* where "vas_copy" and "vas_paste" are defined in copy-paste.h. +*/ + +static char *nxftw_dev_name ="nx-ftw" ; +static atomic_t nxftw_instid =ATOMIC_INIT (0 ); +static dev_t nxftw_devt; +static struct dentry *nxftw_debugfs; +static struct class *nxftw_dbgfs_class;
The class doesn't go in debugfs, which is what "dbgfs" says to me.
arch/powerpc/platforms/powernv/nx-ftw.c line 46
Quoted 2 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +2
-0+/* +* Wrapper object for the nx-ftw device node - there is just one
Just "device".
"device node" is ambiguous vs device tree.
arch/powerpc/platforms/powernv/nx-ftw.c line 48
Quoted 1 line
arch/powerpc/platforms/powernv/nx-ftw.c new file +1
-0+* instance of this node for the whole system.
So why not put the globals above in here also?
Quoted 11 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +11
-0+*/ +struct nxftw_dev { +struct cdev cdev; +struct device *device; +char *name; +atomic_t refcount; +} nxftw_device; + +/* +* One instance per open of a nx-ftw device. Each nxftw_instance is +* associated with a VAS window, after the caller issues VAS_RX_WIN_OPEN
arch/powerpc/platforms/powernv/nx-ftw.c line 69
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+* or VAS_TX_WIN_OPEN ioctl. +*/ +struct nxftw_instance { +int instance; +bool tx_win; +struct vas_window *window; +}; + +#define VAS_DEFAULT_VAS_ID 0 +#define POWERNV_LPID 0/* TODO: For VM/KVM guests? */
mfspr(SPRN_LPID)
would seem to do the trick?
arch/powerpc/platforms/powernv/nx-ftw.c line 73
Quoted 3 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +3
-0+static char *nxftw_devnode (struct device *dev,umode_t *mode) +{ +return kasprintf (GFP_KERNEL ,"crypto/%s" ,dev_name (dev));
This isn't a crypto device?
arch/powerpc/platforms/powernv/nx-ftw.c line 79
Quoted 6 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +6
-0+} + +static int nxftw_open (struct inode *inode,struct file *fp) +{ +int minor; +struct nxftw_instance *nxti;
instance would be a better name.
arch/powerpc/platforms/powernv/nx-ftw.c line 81
Quoted 1 line
arch/powerpc/platforms/powernv/nx-ftw.c new file +1
-0+ minor =MINOR (inode->i_rdev);
Not used?
arch/powerpc/platforms/powernv/nx-ftw.c line 87
Quoted 5 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +5
-0+ nxti =kzalloc (sizeof (*nxti),GFP_KERNEL ); +if (!nxti) +return -ENOMEM ; + + nxti->instance =atomic_inc_return (&nxftw_instid);
And this would read better if the variable was "id". eg.
instance->id = atomic_inc_return(&next_instance_id);
Quoted 13 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +13
-0+ nxti->window =NULL ; + + fp->private_data = nxti; +return 0 ; +} + +static int validate_txwin_user_attr (struct vas_tx_win_open_attr *uattr) +{ +int i; + +if (uattr->version !=1 ) +return -EINVAL ; +
arch/powerpc/platforms/powernv/nx-ftw.c line 110
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+if (uattr->flags & ~VAS_FLAGS_HIGH_PRI ) +return -EINVAL ; + +if (uattr->reserved1 || uattr->reserved2) +return -EINVAL ; + +for (i =0 ; i <sizeof (uattr->reserved3) /sizeof (uint64_t ); i++) { +if (uattr->reserved3[i]) +return -EINVAL ; + }
That struct is a mess and needs to be reworked.
Quoted 4 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +4
-0+return 0 ; +} + +static bool validate_rxwin_user_attr (struct vas_rx_win_open_attr *uattr)
arch/powerpc/platforms/powernv/nx-ftw.c line 125
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+{ +int i; + +if (uattr->version !=1 ) +return -EINVAL ; + +for (i =0 ; i <sizeof (uattr->reserved) /sizeof (uint64_t ); i++) { +if (uattr->reserved[i]) +return -EINVAL ; + }
Ditto.
arch/powerpc/platforms/powernv/nx-ftw.c line 130
Quoted 4 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +4
-0+return 0 ; +} + +#ifdef vas_debug
This is dead code, which makes it very easy for it to get out of sync with the vas_rx_win_attr for example.
Better to just make these pr_debug() in the only caller, that way they get type checked.
Quoted 18 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +18
-0+static inline void dump_rx_win_attr (struct vas_rx_win_attr *attr) +{ +pr_err ("NX-FTW: user %d, nx %d, fault %d, ntfy %d, intr %d early %d\n" , + attr->user_win ?1 :0 , + attr->nx_win ?1 :0 , + attr->fault_win ?1 :0 , + attr->notify_disable ?1 :0 , + attr->intr_disable ?1 :0 , + attr->notify_early ?1 :0 ); + +pr_err ("NX-FTW: rx_fifo %p, rx_fifo_size %d, max value 0x%x\n" , + attr->rx_fifo, attr->rx_fifo_size, +VAS_RX_FIFO_SIZE_MAX ); + +} +#else +static inline void dump_rx_win_attr (struct vas_rx_win_attr *attr) +{
arch/powerpc/platforms/powernv/nx-ftw.c line 158
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+} +#endif + +static int nxftw_ioc_open_rx_window (struct file *fp,unsigned long arg) +{ +int rc; +struct vas_rx_win_open_attr uattr; +struct vas_rx_win_attr rxattr; +struct nxftw_instance *nxti = fp->private_data; +struct vas_window *win;
struct vas_rx_win_open_attr uattr;
struct vas_rx_win_attr rxattr;
struct nxftw_instance *nxti;
struct vas_window *win;
int rc;
nxti = fp->private_data;Ah much better :)
Aka. reverse-christmas-tree.
arch/powerpc/platforms/powernv/nx-ftw.c line 154
Quoted 2 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +2
-0+ + rc =copy_from_user (&uattr, (void *)arg,sizeof (uattr));
Nicer would be:
void __user *uptr = (void *)arg; rc = copy_from_user(&uattr, uptr, sizeof(uattr));
Quoted 14 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +14
-0+if (rc) { +pr_devel ("%s(): copy_from_user() returns %d\n" , __func__, rc); +return -EFAULT ; + } + + rc =validate_rxwin_user_attr (&uattr); +if (rc) +return rc; + +memset (&rxattr,0 ,sizeof (rxattr)); + + rxattr.lnotify_lpid =POWERNV_LPID ; + +/*
arch/powerpc/platforms/powernv/nx-ftw.c line 184
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+* Only caller can own the window for now. Not sure if there is need +* for process P1 to make P2 the owner of a window. If so, we need to +* find P2, make sure we have permissions, get a reference etc. +*/ + rxattr.lnotify_pid =mfspr (SPRN_PID ); + rxattr.lnotify_tid =mfspr (SPRN_TIDR ); + rxattr.rx_fifo =NULL ; + rxattr.rx_fifo_size =0 ; + rxattr.intr_disable = true; + rxattr.user_win = true;
vas_init_rx_win_attr() ?
arch/powerpc/platforms/powernv/nx-ftw.c line 191
Quoted 7 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +7
-0+ +dump_rx_win_attr (&rxattr); + +/* +* TODO: Rather than the default vas id, choose an instance of VAS +* based on the chip the caller is running. +*/
Seems like that will be a common pattern so maybe the vas core should handle it for callers who want it.
Quoted 5 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +5
-0+ win =vas_rx_win_open (VAS_DEFAULT_VAS_ID ,VAS_COP_TYPE_FTW , &rxattr); +if (IS_ERR (win)) { +pr_devel ("%s() vas_rx_win_open() failed, %ld\n" , __func__, +PTR_ERR (win)); +return PTR_ERR (win);
arch/powerpc/platforms/powernv/nx-ftw.c line 206
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+ } + + nxti->window = win; + uattr.rx_win_handle =vas_win_id (win); + + rc =copy_to_user ((void *)arg, &uattr,sizeof (uattr)); +if (rc) { +pr_devel ("%s(): copy_to_user() failed, %d\n" , __func__, rc); +return -EFAULT ; + }
You defined the ioctl as:
#define VAS_RX_WIN_OPEN _IOW('v', 2, struct vas_rx_win_open_attr)But you're reading and writing from the user arg, so it should be _IOWR.
arch/powerpc/platforms/powernv/nx-ftw.c line 217
Quoted 11 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +11
-0+ +return 0 ; +} + +static int nxftw_ioc_open_tx_window (struct file *fp,unsigned long arg) +{ +int rc; +enum vas_cop_type cop; +struct vas_window *win; +struct vas_tx_win_open_attr uattr; +struct vas_tx_win_attr txattr;
Those two struct names are quite confusing.
arch/powerpc/platforms/powernv/nx-ftw.c line 224
Quoted 7 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +7
-0+struct nxftw_instance *nxti = fp->private_data; + + rc =copy_from_user (&uattr, (void *)arg,sizeof (uattr)); +if (rc) { +pr_devel ("%s(): copy_from_user() failed, %d\n" , __func__, rc); +return -EFAULT ; + }
All you use is rx_win_handle, so why does this ioctl take the whole struct?
Quoted 4 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +4
-0+ cop =VAS_COP_TYPE_FTW ; + + rc =validate_txwin_user_attr (&uattr); +if (rc)
arch/powerpc/platforms/powernv/nx-ftw.c line 239
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+return rc; + +pr_devel ("Pid %d: Opening txwin, cop %d, PIDR %ld\n" , +task_pid_nr (current), cop,mfspr (SPRN_PID )); + +vas_init_tx_win_attr (&txattr, cop); + + txattr.lpid =POWERNV_LPID ; + txattr.pidr =mfspr (SPRN_PID ); + txattr.pid =task_pid_nr (current);
Why is that in txattr?
The pid can be freed and given to another process so it's fishy to be saving the pid without also holding a reference on the task.
arch/powerpc/platforms/powernv/nx-ftw.c line 240
Quoted 1 line
arch/powerpc/platforms/powernv/nx-ftw.c new file +1
-0+ txattr.user_win = true;
Has been done for us.
arch/powerpc/platforms/powernv/nx-ftw.c line 250
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+ txattr.pswid = uattr.rx_win_handle; + + win =vas_tx_win_open (VAS_DEFAULT_VAS_ID , cop, &txattr); +if (IS_ERR (win)) { +pr_devel ("%s() vas_tx_win_open() failed, %ld\n" , __func__, +PTR_ERR (win)); +return PTR_ERR (win); + } + nxti->window = win; + nxti->tx_win = true;
is_tx would be clearer IMHO.
Quoted 4 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +4
-0+return 0 ; +} + +static int nxftw_release (struct inode *inode,struct file *fp)
arch/powerpc/platforms/powernv/nx-ftw.c line 265
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+{ +struct nxftw_instance *nxti; + + nxti = fp->private_data; + +vas_win_close (nxti->window); + nxti->window =NULL ; + +kfree (nxti); + fp->private_data =NULL ;
Flipping the order of those would be preferable though it's not actually a bug.
Quoted 6 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +6
-0+atomic_dec (&nxftw_instid); + +return 0 ; +} + +static ssize_t nxftw_write(struct file *fp, const char __user *buf,
arch/powerpc/platforms/powernv/nx-ftw.c line 281
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+ size_t len, loff_t *offsetp) +{ + return -ENOTSUPP; +} + +static ssize_t nxftw_read (struct file *fp,char __user *buf,size_t len, +loff_t *offsetp) +{ +return -ENOTSUPP ; +}
Do you need those?
Quoted 18 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +18
-0+static int nxftw_vma_fault (struct vm_fault *vmf) +{ +u64 offset; +unsigned long vaddr; +uint64_t pbaddr_start; +struct nxftw_instance *nxti; +struct vm_area_struct *vma = vmf->vma; + + nxti = vma->vm_private_data; + offset = vmf->pgoff <<PAGE_SHIFT ; + vaddr = (unsigned long )vmf->address; + + pbaddr_start =vas_win_paste_addr (nxti->window); + + pr_devel("%s() instance %d, pbaddr 0x%llx, vaddr 0x%lx," + "offset %llx, pgoff 0x%lx, vma-start 0x%zx," + "size %zd\n", __func__, nxti->instance, + pbaddr_start, vaddr, offset, vmf->pgoff,
arch/powerpc/platforms/powernv/nx-ftw.c line 310
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+ vma->vm_start, vma->vm_end-vma->vm_start); + +vm_insert_pfn (vma, vaddr, (pbaddr_start + offset) >>PAGE_SHIFT ); + +return VM_FAULT_NOPAGE ; +} + +const struct vm_operations_struct nxftw_vm_ops = { + .fault = nxftw_vma_fault, +};
Is there some particular reason you need to implement those, you appear to be just mapping a page into the address space. Can't you just use remap_pfn_range() in your mmap routine?
Quoted 12 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +12
-0+static int nxftw_mmap (struct file *fp,struct vm_area_struct *vma) +{ +struct nxftw_instance *nxti = fp->private_data; + +if ((vma->vm_end - vma->vm_start) >PAGE_SIZE ) { +pr_devel ("%s(): size 0x%zx, PAGE_SIZE 0x%zx\n" , __func__, + (vma->vm_end - vma->vm_start),PAGE_SIZE ); +return -EINVAL ; + } + +/* Ensure instance has an open send window */ +if (!nxti->window || !nxti->tx_win) {
arch/powerpc/platforms/powernv/nx-ftw.c line 333
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+pr_devel ("%s(): No send window open?\n" , __func__); +return -EINVAL ; + } + +/* flags, page_prot from cxl_mmap(), except we want cachable */ + vma->vm_flags |=VM_IO |VM_PFNMAP ; + vma->vm_page_prot =pgprot_cached (vma->vm_page_prot); + + vma->vm_ops = &nxftw_vm_ops; + vma->vm_private_data = nxti;
ie. here.
See eg. opal-prd.c for an example.
arch/powerpc/platforms/powernv/nx-ftw.c line 342
Quoted 8 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +8
-0+return 0 ; +} + +static long nxftw_ioctl (struct file *fp,unsigned int cmd,unsigned long arg) +{ +struct nxftw_instance *nxti; + + nxti = fp->private_data;
Not used.
arch/powerpc/platforms/powernv/nx-ftw.c line 345
Quoted 3 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +3
-0+ +pr_devel ("%s() cmd 0x%x, TX_WIN_OPEN 0x%lx\n" , __func__, cmd, +VAS_TX_WIN_OPEN );
Can we drop that?
Quoted 78 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +78
-0+switch (cmd) { + +case VAS_TX_WIN_OPEN : +return nxftw_ioc_open_tx_window (fp, arg); + +case VAS_RX_WIN_OPEN : +return nxftw_ioc_open_rx_window (fp, arg); + +default : +return -EINVAL ; + } +} + +const struct file_operations nxftw_fops = { + .owner =THIS_MODULE , + .open = nxftw_open, + .release = nxftw_release, + .read = nxftw_read, + .write = nxftw_write, + .mmap = nxftw_mmap, + .unlocked_ioctl = nxftw_ioctl, +}; + + +int nxftw_file_init (void ) +{ +int rc; +dev_t devno; + + rc =alloc_chrdev_region (&nxftw_devt,1 ,1 ,"nx-ftw" ); +if (rc) { +pr_err ("Unable to allocate nxftw major number: %i\n" , rc); +return rc; + } + +pr_devel ("NX-FTW device allocated, dev [%i,%i]\n" ,MAJOR (nxftw_devt), +MINOR (nxftw_devt)); + + nxftw_dbgfs_class =class_create (THIS_MODULE ,"nxftw" ); +if (IS_ERR (nxftw_dbgfs_class)) { +pr_err ("Unable to create NX-FTW class\n" ); + rc =PTR_ERR (nxftw_dbgfs_class); + goto err; + } + nxftw_dbgfs_class->devnode = nxftw_devnode; + +cdev_init (&nxftw_device.cdev, &nxftw_fops); + + devno =MKDEV (MAJOR (nxftw_devt),0 ); +if (cdev_add (&nxftw_device.cdev, devno,1 )) { +pr_err ("NX-FTW: cdev_add() failed\n" ); + goto err; + } + + nxftw_device.device =device_create (nxftw_dbgfs_class,NULL , + devno,NULL , nxftw_dev_name,MINOR (devno)); +if (IS_ERR (nxftw_device.device)) { +pr_err ("Unable to create nxftw-%d\n" ,MINOR (devno)); + goto err; + } + +pr_devel ("%s: Added dev [%d,%d]\n" , __func__,MAJOR (devno), +MINOR (devno)); +return 0 ; + +err: +unregister_chrdev_region (nxftw_devt,1 ); +return rc; +} + +void nxftw_file_exit (void ) +{ +dev_t devno; + +pr_devel ("NX-FTW: %s entered\n" , __func__); + +cdev_del (&nxftw_device.cdev); + devno =MKDEV (MAJOR (nxftw_devt),MINOR (nxftw_devt));
arch/powerpc/platforms/powernv/nx-ftw.c line 433
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+device_destroy (nxftw_dbgfs_class, devno); + +class_destroy (nxftw_dbgfs_class); +unregister_chrdev_region (nxftw_devt,1 ); +} + + +/* +* Create a debugfs entry. Not sure what for yet, though +*/
Please just drop it.
Quoted 22 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +22
-0+int __init nxftw_debugfs_init (void ) +{ +struct dentry *ent; + + ent =debugfs_create_dir ("nxftw" ,NULL ); +if (IS_ERR (ent)) { +pr_devel ("nxftw: %s(): error creating dbgfs dir\n" , __func__); +return PTR_ERR (ent); + } + nxftw_debugfs = ent; + +return 0 ; +} + +void nxftw_debugfs_exit (void ) +{ +debugfs_remove_recursive (nxftw_debugfs); +} + +int __init nxftw_init (void ) +{ +int rc;
arch/powerpc/platforms/powernv/nx-ftw.c line 465
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+ + rc =nxftw_file_init (); +if (rc) +return rc; + + rc =nxftw_debugfs_init (); +if (rc) + goto free_file; + +pr_err ("NX-FTW Device initialized\n" );
That's not an error.
Quoted 7 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +7
-0+ +return 0 ; + +free_file: +nxftw_file_exit (); +return rc; +}
arch/powerpc/platforms/powernv/nx-ftw.c line 482
Quoted 10 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +10
-0+ +void __init nxftw_exit (void ) +{ +pr_devel ("NX-FTW Device exiting\n" ); +nxftw_debugfs_exit (); +nxftw_file_exit (); +} + +module_init (nxftw_init); +module_exit (nxftw_exit);
This can't be a module, so you shouldn't be using these.
Or these:
arch/powerpc/platforms/powernv/nx-ftw.c line 486
Quoted 3 lines
arch/powerpc/platforms/powernv/nx-ftw.c new file +3
-0+MODULE_DESCRIPTION ("IBM NX Fast Thread Wakeup Device" ); +MODULE_AUTHOR ("Sukadev Bhattiprolu <[email protected]>" ); +MODULE_LICENSE ("GPL" );
cheers
Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
In reply to Sukadev BhattiproluQuoted 2 lines · Sukadev Bhattiprolu
We need the
SPRN_TIDRto bet set for use with fast thread-wakeup (core-to-core wakeup).=C2=A0=C2=A0Each thread in a process needs to have =
a
Quoted 7 lines
unique id within the process but as explained below, for now, we assign globally unique thread ids to all threads in the system. =20
Signed-off-by Sukadev Bhattiprolu <[email protected]>---
=C2=A0arch/powerpc/include/asm/processor.h |=C2=A0=C2=A04 ++ =C2=A0arch/powerpc/kernel/process.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0| 74
Quoted 10 lines
++++++++++++++++++++++++++++++++++++
=C2=A02 files changed, 78 insertions(+)
=20arch/powerpc/include/asm/processor.h +0
-0@@ -232,6 +232,10 @@ struct debug_reg { =C2=A0struct thread_struct {
Quoted 3 lines
=C2=A0 unsigned long ksp; /* Kernel stack pointer */
=C2=A0
+#ifdefCONFIG_PPC_VAS
I'm tempted to have this always, or a new feature CONFIG_PPC_TID that's PPC= _VAS
depends on.
arch/powerpc/kernel/process.=
Quoted 8 lines
arch/powerpc/include/asm/processor.h +3
-0+unsigned long tidr; +#endif +=C2=A0#ifdef
CONFIG_PPC64
=C2=A0 unsigned longksp_vsid;
=C2=A0#endifarch/powerpc/kernel/process.= renamed from arch/powerpc/kernel/process.c +0
-0
c
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1217
Quoted 10 lines
index 9f3e2c9..6123859 100644
arch/powerpc/kernel/process.c +0
-0@@ -1213,6 +1213,16 @@ struct task_struct *__switch_to(struct task_struct *prev, =C2=A0 hard_irq_disable(); =C2=A0 }=C2=A0
arch/powerpc/kernel/process.c +2
-0+#ifdef CONFIG_PPC_VAS +mtspr (SPRN_TIDR , new->thread.tidr);
how much does this hurt our context_switch benchmark in tools/testing/selftests/powerpc/benchmarks/context_switch.c ?
Also you need an CPU_FTR_ARCH_300 test here (and elsewhere)
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1225
Quoted 8 lines
arch/powerpc/kernel/process.c +8
-0+#endif +/* +=C2=A0* We can't take a PMU exception inside _switch() since there is a +=C2=A0* window where the kernel stack SLB and the kernel stack are out +=C2=A0* of sync. Hard disable here. +=C2=A0*/ +hard_irq_disable (); +
What is this?
Quoted 2 lines
=C2=A0 /*
=C2=A0 =C2=A0* Callrestore_sprs()before calling_switch(). If we move i=
t after
Quoted 1 line
=C2=A0 =C2=A0*
_switch()then we miss out on calling it for new tasks. Th=
e reason
arch/powerpc/kernel/process.c void flush_thread(void) · line 1464
Quoted 7 lines
arch/powerpc/kernel/process.c +0
-0@@ -1449,9 +1459,70 @@ void flush_thread(void)=C2=A0#endif /*
CONFIG_HAVE_HW_BREAKPOINT*/
=C2=A0}
=C2=A0arch/powerpc/kernel/process.c +3
-0+#ifdef CONFIG_PPC_VAS +static DEFINE_SPINLOCK (vas_thread_id_lock); +static DEFINE_IDA (vas_thread_ida);
This IDA be per process, not global.
arch/powerpc/kernel/process.c void flush_thread(void)
Quoted 3 lines
arch/powerpc/kernel/process.c +3
-0+ +/* +* We need to assign an unique thread id to each thread in a process. Th=
is
Quoted 1 line
+ * thread id is intended to be used with the Fast Thread-wakeup (aka Cor=
e-
Quoted 1 line
+ * to-core wakeup) mechanism being implemented on top of Virtual Acceler=
ator
Quoted 3 lines
+ * Switchboard (VAS).
+ *
+ * To get a unique thread-id per process we could simply use task_pid_nr=
()
Quoted 1 line
+ * but the problem is that
task_pid_nr()is not yet available for the th=
read
Quoted 5 lines
+ * when
copy_thread()is called. Fixing that would require changing more
+ * intrusive arch-neutral code in code path incopy_process()?.
+ *
+ * Further, to assign unique thread ids within each process, we need an
+ * atomic field (or an IDR) intask_struct, which again intrudes into th=
e
Quoted 1 line
+ * arch-neutral code.
Really?
Quoted 1 line
+ * So try to assign globally unique thraed ids for now.
Yuck!
arch/powerpc/kernel/process.c void flush_thread(void)
Quoted 12 lines
+ */
arch/powerpc/kernel/process.c +11
-0+static int assign_thread_id (void ) +{ +int index; +int err; + +again: +if (!ida_pre_get (&vas_thread_ida,GFP_KERNEL )) +return -ENOMEM ; + +spin_lock (&vas_thread_id_lock); + err =3D ida_get_new_above(&vas_thread_ida, 1, &index);
We can't use 0 or 1?
Quoted 29 lines
arch/powerpc/kernel/process.c +26
-0+spin_unlock (&vas_thread_id_lock); + + if (err =3D=3D -EAGAIN) + goto again; +else if (err) +return err; + +if (index >MAX_USER_CONTEXT ) { +spin_lock (&vas_thread_id_lock); +ida_remove (&vas_thread_ida, index); +spin_unlock (&vas_thread_id_lock); +return -ENOMEM ; + } + + return index; +} + +static void free_thread_id (int id) +{ +spin_lock (&vas_thread_id_lock); +ida_remove (&vas_thread_ida, id); +spin_unlock (&vas_thread_id_lock); +} +#endif /* CONFIG_PPC_VAS */ + +=C2=A0void
=C2=A0release_thread(structtask_struct*t)
=C2=A0{
arch/powerpc/kernel/process.c void flush_thread(void) · line 1525
Quoted 3 lines
arch/powerpc/kernel/process.c +3
-0+#ifdef CONFIG_PPC_VAS +free_thread_id (t->thread.tidr); +#endif
Can you restructure this to avoid the #ifdef ugliness
arch/powerpc/kernel/process.c int copy_thread(unsigned long clone_flags, unsigned=
Quoted 4 lines
=C2=A0}
=C2=A0
=C2=A0/*arch/powerpc/kernel/process.c +0
-0@@ -1587,6 +1658,9 @@ int copy_thread(unsigned long clone_flags, unsigned=
long
arch/powerpc/kernel/process.c
Quoted 7 lines
arch/powerpc/kernel/process.c +0
-0usp,=C2=A0#endif
=C2=A0
=C2=A0setup_ksp_vsid(p, sp);arch/powerpc/kernel/process.c +3
-0+#ifdef CONFIG_PPC_VAS + p->thread.tidr =3D assign_thread_id(); +#endif
Same here...=20
Quoted 3 lines
=C2=A0
=C2=A0#ifdefCONFIG_PPC64=C2=A0
=C2=A0 if (cpu_has_feature(CPU_FTR_DSCR)) {
Michael Ellerman
reviewerRe: [PATCH v6 02/17] powerpc/vas: Move GET_FIELD/SET_FIELD to vas.h
In reply to Sukadev BhattiproluQuoted 15 lines · Sukadev Bhattiprolu
Move the
GET_FIELDandSET_FIELDmacros tovas.has VAS and other users of VAS, including NX-842 can use those macros.There is a lot of related code between the VAS/NX kernel drivers and skiboot. For consistency switch the order of parameters in
SET_FIELDto match the order in skiboot.Signed-off-by Sukadev Bhattiprolu <[email protected]>Reviewed-by Dan Streetman <[email protected]>arch/powerpc/include/uapi/asm/vas.h +0
-0
arch/powerpc/include/uapi/asm/vas.h line 31
Quoted 10 lines
arch/powerpc/include/uapi/asm/vas.h +7
-0@@ -22,4 +22,12 @@#define VAS_THRESH_FIFO_GT_QTR_FULL 2#define VAS_THRESH_FIFO_GT_EIGHTH_FULL 3 +/* +* Get/Set bit fields +*/ +#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)))
This has no business being in a uapi header for VAS.
Put it in asm/vas.h if you must.
Personally I really dislike these sort of macros because they completely obscure what the final value should end up being, and it's the final value you'll see when you're debugging it.
arch/powerpc/include/uapi/asm/vas.h
Quoted 3 lines
arch/powerpc/include/uapi/asm/vas.h +3
-0+ ccw =SET_FIELD (CCW_CT , ccw, nx842_ct); + ccw =SET_FIELD (CCW_CI_842 , ccw,0 );/* use 0 for hw auto-selection */ + ccw =SET_FIELD (CCW_FC_842 , ccw, fc);
eg. that could also be written:
ccw = (nx842_ct << 16) | (fc & 7);
cheers
Re: [PATCH v6 17/17] powerpc/vas: Document FTW API/usage
In reply to Sukadev BhattiproluT24gVHVlLCAyMDE3LTA4LTA4IGF0IDE2OjA3IC0wNzAwLCBTdWthZGV2IEJoYXR0aXByb2x1IHdy b3RlOgo+IERvY3VtZW50IHRoZSB1c2FnZSBvZiB0aGUgVkFTIEZhc3QgdGhyZWFkLXdha2V1cCBB UEkuCj4gCj4gVGhhbmtzIGZvciBpbnB1dC9jb21tZW50cyBmcm9tIEJlbmphbWluIEhlcnJlbnNj aG1pZHQsIE1pY2hhZWwgTmV1bGluZywKPiBNaWNoYWVsIEVsbGVybWFuLCBSb2JlcnQgQmxhY2tt b3JlLCBJYW4gTXVuc2llLCBIYXJlbiBNeW5lbmksIFBhdWwgTWFja2VycmFzLgo+IAo+IENjOklh biBNdW5zaWUgPGltdW5zaWVAYXUxLmlibS5jb20+Cj4gQ2M6UGF1bCBNYWN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UgPSB0cnVlOwoJc21wX21iKCk7IC8qIG5lZWRlZCBmb3IgbWVtb3J5IC0+IHBhc3RlICov CsKgwqDCoMKgwqDCoMKgwqB3cml0ZV9jcmIocGFzdGVfYWRkcik7Cn0KCmludCBtYWluKCkKewoJ cHRocmVhZF90IHRocmVhZDsKCWludCBkZXZmZDsKCsKgwqDCoMKgwqDCoMKgwqBkZXZmZCA9IG9w ZW4oIi9kZXYvdmFzLWZ0dyIsIE9fUkRXUik7CgoJLyogY3JlYXRlIGEgbmV3IHJ4IGZpbGUgZGVz Y3JpcHRvciBhc3NvY2lhdGVkIHdpdGggdGhpcyBMUElEL1BJRC9USUQgKi8KwqDCoMKgwqDCoMKg wqDCoHJ4ZmQgPSBpb2N0bChkZXZmZCwgVkFTX1JYX0NSRUFURSk7CgoJcHRocmVhZF9jcmVhdGUo JnRocmVhZCwgTlVMTCwgc2VuZGVyLCBOVUxMKTsKCgkvKiBSZWNpZXZlciBtdXN0ICpub3QqIGJl IGEgbmV3IHRocmVhZCBzaW5jZSBWQVNfUlhfQ1JFQVRFCgnCoMKgwqBpb2N0bCBpcyBhc3NvY2lh dGVkIHdpdGggdGhpcyBMUElEL1BJRC9USUTCoAoJKi8KCXJlY2lldmVyKCk7Cn0KCl==
Michael Ellerman
reviewerRe: [PATCH v6 01/17] powerpc/vas: Define macros, register fields and structures
In reply to Nicholas PigginQuoted 10 lines · Nicholas Piggin
Quoted 7 lines · On Mon, 14 Aug 2017 15:21:48 +1000 Michael Ellerman <[email protected]> wrote:
Quoted 2 lines · Sukadev Bhattiprolu
arch/powerpc/include/asm/vas.h | 35 ++++ arch/powerpc/include/uapi/asm/vas.h | 25 +++I thought we weren't exposing VAS to userspace yet?
Quoted 8 lines
Quoted 1 line
If we are then we need to get things straight WRT copy/paste abort.
No we should not be. This might be just a leftover hunk that should be moved to a future series.
At the moment (as far as I understand) it should be limited to preempt-disabled, process context, kernel users which avoids any concern for
switch_to.
I think that comment applied to a previous version, see patch 16.
cheers
Michael Ellerman
reviewerRe: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
In reply to Sukadev BhattiproluQuoted 4 lines · Sukadev Bhattiprolu
We need the
SPRN_TIDRto bet set for use with fast thread-wakeup (core-to-core wakeup). Each thread in a process needs to have a unique id within the process but as explained below, for now, we assign globally unique thread ids to all threads in the system.
Each thread in a process already has a unique id, ie. its pid (in the init PID namespace), accessible in the kernel as task_pid_nr(task).
So if that's all we need, we don't need a new allocator, and we don't need to store it in the thread_struct.
Also 99.99% of processes aren't going to care about the TIDR, so we should avoid setting it in the common case. ie. it should start out zero and only be initialised in the FTW code, or a helper that it calls.
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1218
Quoted 11 lines
arch/powerpc/kernel/process.c +3
-0@@ -1213,6 +1213,16 @@ struct task_struct *__switch_to(struct task_struct *prev,hard_irq_disable (); } +#ifdef CONFIG_PPC_VAS +mtspr (SPRN_TIDR , new->thread.tidr); +#endif
That should be in restore_sprs().
It should also check that the TIDR is initialised, and only switch it when necessary.
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1224
Quoted 6 lines
arch/powerpc/kernel/process.c +6
-0+/* +* We can't take a PMU exception inside _switch() since there is a +* window where the kernel stack SLB and the kernel stack are out +* of sync. Hard disable here. +*/ +hard_irq_disable ();
We removed that in June in:
e4c0fc5f72bc ("powerpc/64s: Leave interrupts hard enabled in context switch for radix")
You've obviously picked it up somewhere along the line during a rebase, please be more careful!
cheers
Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
In reply to Michael NeulingQuoted 15 lines · Michael Neuling
Quoted 6 lines
+/*
+ * We need to assign an unique thread id to each thread in a process. This
+ * thread id is intended to be used with the Fast Thread-wakeup (aka Core-
+ * to-core wakeup) mechanism being implemented on top of Virtual Accelerator
+ * Switchboard (VAS).
+ *Quoted 8 lines
+ * To get a unique thread-id per process we could simply use
task_pid_nr()
+ * but the problem is thattask_pid_nr()is not yet available for the thread
+ * whencopy_thread()is called. Fixing that would require changing more
+ * intrusive arch-neutral code in code path incopy_process()?.
+ *
+ * Further, to assign unique thread ids within each process, we need an
+ * atomic field (or an IDR) intask_struct, which again intrudes into the
+ * arch-neutral code.
Quoted 5 lines
Really?
Quoted 1 line
+ * So try to assign globally unique thraed ids for now.
Yuck!
Also CAPI has size limits for the TIDR afaik
Ben.
Re: [PATCH v6 01/17] powerpc/vas: Define macros, register fields and structures
In reply to Nicholas PigginQuoted 8 lines · Nicholas Piggin [[email protected]] wrote:
Quoted 5 lines · On Mon, 14 Aug 2017 15:21:48 +1000 Michael Ellerman <[email protected]> wrote:
Quoted 2 lines · Sukadev Bhattiprolu
arch/powerpc/include/asm/vas.h | 35 ++++ arch/powerpc/include/uapi/asm/vas.h | 25 +++
Quoted 7 lines
Quoted 3 lines
I thought we weren't exposing VAS to userspace yet?
If we are then we need to get things straight WRT copy/paste abort.
No we should not be. This might be just a leftover hunk that should be moved to a future series.
Yes, I should have posted patches 14..17 separately as an RFC that goes on top of the VAS kernel patches 1..13.
Quoted 5 lines
At the moment (as far as I understand) it should be limited to preempt-disabled, process context, kernel users which avoids any concern for
switch_to.
In the FTW case, there is no data transfer from user space to the hardware. i.e the copy/paste submit a NULL CRB and hardware will be configured (see ->fifo_disable setting in winctx) to ignore any data they specify in the CRB.
Would we be able to allow copy/paste from user space in that case?
Sukadev
Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
In reply to Benjamin HerrenschmidtQuoted 16 lines · Benjamin Herrenschmidt [[email protected]] wrote:
Quoted 15 lines · Michael Neuling
Quoted 14 lines
+/*
+ * We need to assign an unique thread id to each thread in a process. This
+ * thread id is intended to be used with the Fast Thread-wakeup (aka Core-
+ * to-core wakeup) mechanism being implemented on top of Virtual Accelerator
+ * Switchboard (VAS).
+ *
+ * To get a unique thread-id per process we could simply usetask_pid_nr()
+ * but the problem is thattask_pid_nr()is not yet available for the thread
+ * whencopy_thread()is called. Fixing that would require changing more
+ * intrusive arch-neutral code in code path incopy_process()?.
+ *
+ * Further, to assign unique thread ids within each process, we need an
+ * atomic field (or an IDR) intask_struct, which again intrudes into the
+ * arch-neutral code.
Quoted 5 lines
Quoted 5 lines
Really?
Quoted 1 line
+ * So try to assign globally unique thraed ids for now.
Yuck!
I know :-) copy_process() has:
retval = copy_thread_tls(clone_flags, stack_start, stack_size, p, tls);
if (retval)
goto bad_fork_cleanup_io;
if (pid != &init_struct_pid) {
pid = alloc_pid(p->nsproxy->pid_ns_for_children);
if (IS_ERR(pid)) {so copy_thread() is called before a pid_nr is assigned to the task.
But see also response to Michael Ellerman.
Quoted 2 lines
Also CAPI has size limits for the TIDR afaik
Ok.
Quoted 2 lines
Ben.
Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
In reply to Michael EllermanQuoted 10 lines · Michael Ellerman [[email protected]] wrote:
Quoted 4 lines · Sukadev Bhattiprolu
We need the
SPRN_TIDRto bet set for use with fast thread-wakeup (core-to-core wakeup). Each thread in a process needs to have a unique id within the process but as explained below, for now, we assign globally unique thread ids to all threads in the system.Each thread in a process already has a unique id, ie. its pid (in the init PID namespace), accessible in the kernel as
task_pid_nr(task).
Quoted 6 lines
So if that's all we need, we don't need a new allocator, and we don't need to store it in the
thread_struct.Also 99.99% of processes aren't going to care about the TIDR, so we should avoid setting it in the common case. ie. it should start out zero and only be initialised in the FTW code, or a helper that it calls.
Good point. So, should we just set when the RX_WIN_OPEN ioctl is called rather than at the time of clone()?
_switch_to() (restore_sprs() could check for non-zero and save/restore the value.
As Ben pointed out, we are going to be have limit the number of TIDs (to be within the size limits), so we won't be able to use task_pid_nr()? But if we assign the TIDs in the RX_WIN_OPEN ioctl, then only the FTW processes will need the TIDR value.
Can we then assign new, globally-unique TID values for now and have the ioctl fail with -EAGAIN if all TIDs are in use? We can extend to per-process TID values, later?
Quoted 9 lines
Quoted 9 lines
arch/powerpc/kernel/process.c +0
-0@@ -1213,6 +1213,16 @@ struct task_struct *__switch_to(struct task_struct *prev,hard_irq_disable (); }
Quoted 5 lines
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1218
Quoted 3 lines
arch/powerpc/kernel/process.c +3
-0+#ifdef CONFIG_PPC_VAS +mtspr (SPRN_TIDR , new->thread.tidr); +#endif That should be in
restore_sprs().
ok.
Quoted 13 lines
It should also check that the TIDR is initialised, and only switch it when necessary.
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1224
Quoted 6 lines
arch/powerpc/kernel/process.c +6
-0+/* +* We can't take a PMU exception inside _switch() since there is a +* window where the kernel stack SLB and the kernel stack are out +* of sync. Hard disable here. +*/ +hard_irq_disable ();We removed that in June in:
Quoted 4 lines
e4c0fc5f72bc("powerpc/64s: Leave interrupts hard enabled in context switch for radix")You've obviously picked it up somewhere along the line during a rebase, please be more careful!
Yeah, That was stupid. I picked it up on a recent rebase. Will be careful.
Quoted 2 lines
cheers
Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
In reply to Michael EllermanQuoted 7 lines · Michael Ellerman
Quoted 4 lines · Sukadev Bhattiprolu
We need the
SPRN_TIDRto bet set for use with fast thread-wakeup (core-to-core wakeup). Each thread in a process needs to have a unique id within the process but as explained below, for now, we assign globally unique thread ids to all threads in the system.
Quoted 5 lines
Each thread in a process already has a unique id, ie. its pid (in the init PID namespace), accessible in the kernel as
task_pid_nr(task).So if that's all we need, we don't need a new allocator, and we don't need to store it in the
thread_struct.
We need an allocator, I think, due to size restriction on the HW TID.
Quoted 37 lines
Also 99.99% of processes aren't going to care about the TIDR, so we should avoid setting it in the common case. ie. it should start out zero and only be initialised in the FTW code, or a helper that it calls.
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1218
Quoted 11 lines
arch/powerpc/kernel/process.c +3
-0@@ -1213,6 +1213,16 @@ struct task_struct *__switch_to(struct task_struct *prev,hard_irq_disable (); } +#ifdef CONFIG_PPC_VAS +mtspr (SPRN_TIDR , new->thread.tidr); +#endif That should be in
restore_sprs().It should also check that the TIDR is initialised, and only switch it when necessary.
arch/powerpc/kernel/process.c struct task_struct *__switch_to(struct task_struct *prev, · line 1224
Quoted 6 lines
arch/powerpc/kernel/process.c +6
-0+/* +* We can't take a PMU exception inside _switch() since there is a +* window where the kernel stack SLB and the kernel stack are out +* of sync. Hard disable here. +*/ +hard_irq_disable ();We removed that in June in:
e4c0fc5f72bc("powerpc/64s: Leave interrupts hard enabled in context switch for radix")You've obviously picked it up somewhere along the line during a rebase, please be more careful!
cheers
Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
In reply to Sukadev BhattiproluQuoted 4 lines · Sukadev Bhattiprolu
As Ben pointed out, we are going to be have limit the number of TIDs (to be within the size limits), so we won't be able to use
task_pid_nr()? But if we assign the TIDs in theRX_WIN_OPENioctl, then only the FTW processes will need the TIDR value.
But you'll have to assign it for all present and future threads of that process which is somewhat hard to do without races.
Quoted 3 lines
Can we then assign new, globally-unique TID values for now and have the ioctl fail with
-EAGAINif all TIDs are in use? We can extend to per-process TID values, later?
Why would you want to do that ?
Ben.
Michael Ellerman
reviewerRe: [PATCH v6 01/17] powerpc/vas: Define macros, register fields and structures
In reply to Sukadev BhattiproluQuoted 12 lines · Sukadev Bhattiprolu
Quoted 11 lines · Nicholas Piggin [[email protected]] wrote:
Quoted 8 lines · On Mon, 14 Aug 2017 15:21:48 +1000 Michael Ellerman <[email protected]> wrote:
Quoted 2 lines · Sukadev Bhattiprolu
arch/powerpc/include/asm/vas.h | 35 ++++ arch/powerpc/include/uapi/asm/vas.h | 25 +++I thought we weren't exposing VAS to userspace yet?
If we are then we need to get things straight WRT copy/paste abort.
...
Quoted 4 lines
In the FTW case, there is no data transfer from user space to the hardware. i.e the copy/paste submit a NULL CRB and hardware will be configured (see ->fifo_disable setting in winctx) to ignore any data they specify in the CRB.
I thought the copy did copy a cacheline, but then the paste to the VAS window just ignores the contents, and doesn't allow userspace to get the content in any way?
Which means we have two thirds of a covert channel, ie. something can be copied into the copy buffer by one process, and then a second process can paste it, but because it can only paste to foreign memory, and the only foreign memory it can get is a VAS FTW window, it can't actually see the content of the copy buffer.
Quoted 1 line
Would we be able to allow copy/paste from user space in that case?
Yeah I think so, but it is all a bit fragile.
cheers
Re: [PATCH v6 01/17] powerpc/vas: Define macros, register fields and structures
Quoted 11 lines · Michael Ellerman [[email protected]] wrote:
Quoted 9 lines · Sukadev Bhattiprolu
Quoted 8 lines · Nicholas Piggin [[email protected]] wrote:
Quoted 5 lines · On Mon, 14 Aug 2017 15:21:48 +1000 Michael Ellerman <[email protected]> wrote:
Quoted 2 lines · Sukadev Bhattiprolu
arch/powerpc/include/asm/vas.h | 35 ++++ arch/powerpc/include/uapi/asm/vas.h | 25 +++
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I thought we weren't exposing VAS to userspace yet?
If we are then we need to get things straight WRT copy/paste abort.
...
Quoted 2 lines
In the FTW case, there is no data transfer from user space to the hardware.
Sorry, that was focussed on the paste side.
Quoted 6 lines
Quoted 2 lines
i.e the copy/paste submit a NULL CRB and hardware will be configured (see ->fifo_disable setting in winctx) to ignore any data they specify in the CRB.
I thought the copy did copy a cacheline, but then the paste to the VAS window just ignores the contents, and doesn't allow userspace to get the content in any way?
Yes, you are right. The copy instruction does read the CRB into its copy- buffer but for the FTW, VAS ignores the copy-buffer contents on paste. So, the CRB may be zeroed, but must be a valid buffer.
Quoted 12 lines
Which means we have two thirds of a covert channel, ie. something can be copied into the copy buffer by one process, and then a second process can paste it, but because it can only paste to foreign memory, and the only foreign memory it can get is a VAS FTW window, it can't actually see the content of the copy buffer.
Quoted 1 line
Would we be able to allow copy/paste from user space in that case?
Yeah I think so, but it is all a bit fragile.
cheers