Enable VAS
v3 cover 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 "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.
In the initial OPAL and PowerNV kernel patchsets, the "senders" can only be kernel subsystems (eg NX-842 driver). A follow-on patch set will allow senders to be user-space processes.
This kernel patch set configures the VAS subsystems and provides kernel interfaces to drivers like NX-842 to open receive and send windows in VAS and to submit requests to the NX engine.
This patch set that has been tested in a Simics Power9 environment using a modified NX-842 kernel driver and a compression self-test module from Power8. The corresponding OPAL patchset for VAS support was posted to skiboot mailing list:
https://lists.ozlabs.org/pipermail/skiboot/2017-January/006193.html
OPAL and kernel patchsets for NX-842 driver will be posted separately. All four patchsets are needed to effectively use VAS/NX in Power9.
Thanks to input from Ben Herrenschmidt, Michael Neuling, Michael Ellerman and Haren Myneni.
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 (10):
VAS: Define macros, register fields and structures Move GET_FIELD/SET_FIELD to vas.h
VAS: Define vas_init() and vas_exit()
VAS: Define helpers for access MMIO regions
VAS: Define helpers to init window context
VAS: Define helpers to alloc/free windows
VAS: Define vas_rx_win_open() interface
VAS: Define vas_win_close() interface
VAS: Define vas_tx_win_open()
VAS: Define copy/paste interfaces
MAINTAINERS | 14 +- arch/powerpc/include/asm/reg.h | 1 + arch/powerpc/include/asm/vas.h | 157 ++++++ drivers/crypto/nx/nx-842-powernv.c | 7 +- drivers/crypto/nx/nx-842.h | 5 - drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/vas/Kconfig | 21 + drivers/misc/vas/Makefile | 3 + drivers/misc/vas/copy-paste.h | 74 +++ drivers/misc/vas/vas-internal.h | 473 ++++++++++++++++ drivers/misc/vas/vas-window.c | 1076 ++++++++++++++++++++++++++++++++++++ drivers/misc/vas/vas.c | 155 ++++++ 13 files changed, 1978 insertions(+), 10 deletions(-) create mode 100644 arch/powerpc/include/asm/vas.h create mode 100644 drivers/misc/vas/Kconfig create mode 100644 drivers/misc/vas/Makefile create mode 100644 drivers/misc/vas/copy-paste.h create mode 100644 drivers/misc/vas/vas-internal.h create mode 100644 drivers/misc/vas/vas-window.c create mode 100644 drivers/misc/vas/vas.c
Signature · 1 line
2.7.4
PATCH v3 2/10 Move GET_FIELD/SET_FIELD to vas.h
Move 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/asm/vas.h | 8 +++++++- drivers/crypto/nx/nx-842-powernv.c | 7 ++++--- drivers/crypto/nx/nx-842.h | 5 ----- 3 files changed, 11 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/vas.h +7 -1
@@ -37,7 +37,13 @@ enum vas_cop_type { VAS_COP_TYPE_MAX, }; +/* +* 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 /* __KERNEL__ */ -#endif
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 v3 3/10 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.
---
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.
--- MAINTAINERS | 8 ++- arch/powerpc/include/asm/reg.h | 1 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/vas/Kconfig | 21 ++++++ drivers/misc/vas/Makefile | 3 + drivers/misc/vas/vas-internal.h | 3 + drivers/misc/vas/vas-window.c | 19 +++++ drivers/misc/vas/vas.c | 155 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 drivers/misc/vas/Kconfig create mode 100644 drivers/misc/vas/Makefile create mode 100644 drivers/misc/vas/vas-window.c create mode 100644 drivers/misc/vas/vas.c
MAINTAINERS +6 -2
@@ -3673,8 +3673,6 @@ F: arch/powerpc/platforms/powernv/pci-cxl.c F: drivers/misc/cxl/ F: include/misc/cxl* F: include/uapi/misc/cxl.h -F: Documentation/powerpc/cxl.txt -F: Documentation/ABI/testing/sysfs-class-cxl CXLFLASH (IBM Coherent Accelerator Processor Interface CAPI Flash) SCSI DRIVER M: Manoj N. Kumar <[email protected]>
@@ -3686,6 +3684,12 @@ F: drivers/scsi/cxlflash/ F: include/uapi/scsi/cxlflash_ioctls.h F: Documentation/powerpc/cxlflash.txt +VAS (IBM Virtual Accelerator Switch) DRIVER +M: Sukadev Bhattiprolu <[email protected]> +L: [email protected] +S: Supported +F: drivers/misc/vas/ + STMMAC ETHERNET DRIVER M: Giuseppe Cavallaro <[email protected]> M: Alexandre Torgue <[email protected]>
arch/powerpc/include/asm/reg.h +1 -0
@@ -1225,6 +1225,7 @@#define PVR_POWER8E 0x004B#define PVR_POWER8NVL 0x004C#define PVR_POWER8 0x004D +#define PVR_POWER9 0x004E#define PVR_BE 0x0070#define PVR_PA6T 0x0090
drivers/misc/Kconfig +1 -0
@@ -783,4 +783,5 @@ source "drivers/misc/mic/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" source "drivers/misc/cxl/Kconfig" +source "drivers/misc/vas/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o obj-$(CONFIG_CXL_BASE) += cxl/ +obj-$(CONFIG_VAS) += vas/ obj-$(CONFIG_PANEL) += panel.o lkdtm-$(CONFIG_LKDTM) += lkdtm_core.o
drivers/misc/vas/Kconfig new file +21 -0
@@ -0,0 +1,21 @@ +# +# IBM Virtual Accelarator Switchboard (VAS) compatible devices +#depends on PPC_POWERNV && PCI_MSI && EEH +# + +config VAS + tristate "Support for IBM Virtual Accelerator Switchboard (VAS)" + depends on PPC_POWERNV + default n + help + Select this option to enable driver support for IBM Virtual + Accelerator Switchboard (VAS). + + VAS allows accelerators in co processors like NX-842 to be + directly available to a user process. This driver enables + userspace programs to access these accelerators via device + nodes like /dev/crypto/nx-gzip. + + VAS adapters are found in POWER9 based systems. + + If unsure, say N.
drivers/misc/vas/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +ccflags-y := $(call cc-disable-warning, unused-const-variable) +ccflags-$(CONFIG_PPC_WERROR) += -Werror +obj-$(CONFIG_VAS) += vas.o vas-window.o
drivers/misc/vas/vas-internal.h +3 -0
@@ -389,4 +389,7 @@ struct vas_winctx { enum vas_notify_after_count notify_after_count; }; +extern int vas_initialized; +extern int vas_window_reset (struct vas_instance *vinst,int winid); +extern struct vas_instance *find_vas_instance (int vasid);#endif
drivers/misc/vas/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 <asm/vas.h> +#include "vas-internal.h" + +/* stub for now */ +int vas_window_reset (struct vas_instance *vinst,int winid) +{ +return 0 ; +}
drivers/misc/vas/vas.c new file +155 -0
155 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 4/10 VAS: Define helpers for access MMIO regions
In reply to Sukadev BhattiproluDefine some helper functions to access the MMIO regions. We use these in a follow-on patches to read/write VAS hardware registers. These helpers are also used to later issue 'paste' instructions to submit requests to the NX hardware engines.
---
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.
--- drivers/misc/vas/vas-window.c | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+)
drivers/misc/vas/vas-window.c +126 -0
@@ -9,9 +9,135 @@#include <linux/types.h> #include <linux/mutex.h> +#include <linux/slab.h> +#include <linux/io.h> #include <asm/vas.h> #include "vas-internal.h" +/* +* Compute the paste address region for the window @window using the +* ->win_base_addr and ->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->win_base_addr; + shift = window->vinst->win_id_shift; + winid = window->winid; + + *addr = base + (winid << shift); + *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 ; +} + +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,pgprot_val (pgprot_cached (__pgprot (0 )))); +if (!map) { +pr_devel ("%s(): ioremap(0x%llx, %d) failed\n" , __func__, start, + len); +return NULL ; + } + +return map; +} + +/* +* Unmap the MMIO regions for a window. +*/ +static void unmap_wc_paste_kaddr (struct vas_window *window) +{ +int len; +uint64_t busaddr_start; + +if (window->paste_kaddr) { +iounmap (window->paste_kaddr); +compute_paste_address (window, &busaddr_start, &len); +release_mem_region ((phys_addr_t )busaddr_start, len); + window->paste_kaddr =NULL ; + } + +} + +static void unmap_wc_mmio_bars (struct vas_window *window) +{ +int len; +uint64_t busaddr_start; + +unmap_wc_paste_kaddr (window); + +if (window->hvwc_map) { +iounmap (window->hvwc_map); +get_hvwc_mmio_bar (window, &busaddr_start, &len); +release_mem_region ((phys_addr_t )busaddr_start, len); + window->hvwc_map =NULL ; + } + +if (window->uwc_map) { +iounmap (window->uwc_map); +get_uwc_mmio_bar (window, &busaddr_start, &len); +release_mem_region ((phys_addr_t )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_wc_mmio_bars (struct vas_window *window) +{ +int len; +uint64_t start; + + window->paste_kaddr = window->hvwc_map = window->uwc_map =NULL ; + +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_wc_mmio_bars (window); +return -1 ; + } + +return 0 ; +} +/* stub for now */ int vas_window_reset (struct vas_instance *vinst,int winid) {
Signature · 1 line
2.7.4
PATCH v3 1/10 VAS: Define macros, register fields and structures
In reply to Sukadev BhattiproluDefine macros for the VAS hardware registers and bit-fields as well as couple of data structures needed by the VAS driver.
---
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.
--- MAINTAINERS | 6 + arch/powerpc/include/asm/vas.h | 43 +++++ drivers/misc/vas/vas-internal.h | 392 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 441 insertions(+) create mode 100644 arch/powerpc/include/asm/vas.h create mode 100644 drivers/misc/vas/vas-internal.h
MAINTAINERS +6 -0
@@ -13213,6 +13213,12 @@ S: Maintained F: Documentation/fb/uvesafb.txt F: drivers/video/fbdev/uvesafb.* +VAS (IBM Virtual Accelerator Switchboard) DRIVER +M: Sukadev Bhattiprolu <[email protected]> +L: [email protected] +S: Supported +F: drivers/misc/vas/* + VF610 NAND DRIVER M: Stefan Agner <[email protected]> L: [email protected]
arch/powerpc/include/asm/vas.h new file +43 -0
43 lines not on this page · raw message
drivers/misc/vas/vas-internal.h new file +392 -0
392 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 5/10 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[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
--- drivers/misc/vas/vas-internal.h | 59 ++++++- drivers/misc/vas/vas-window.c | 334 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 390 insertions(+), 3 deletions(-)
drivers/misc/vas/vas-internal.h +56 -3
@@ -11,6 +11,7 @@#define VAS_INTERNAL_H #include <linux/atomic.h> #include <linux/idr.h> +#include <linux/io.h> #include <asm/vas.h> #ifdef CONFIG_PPC_4K_PAGES
@@ -336,9 +337,6 @@ struct vas_window {/* Feilds applicable only to receive windows */ enum vas_cop_type cop;atomic_t num_txwins; - -int32_t hwirq; -uint64_t irq_port; };/*
@@ -392,4 +390,59 @@ struct vas_winctx {extern int vas_initialized;extern int vas_window_reset (struct vas_instance *vinst,int winid);extern struct vas_instance *find_vas_instance (int vasid); + +/* +* VREG(x): +* Expand a register's short name (eg: LPID) into two parameters: +* - the register's short name in string form ("LPID"), and +* - the name of the macro (eg: VAS_LPID_OFFSET), defining the +* register's offset in the window context +*/ +#define VREG_SFX (n, s) __stringify(n), VAS_##n##s +#define VREG (r) VREG_SFX(r, _OFFSET) + +#ifndef vas_debug +static inline void vas_log_write (struct vas_window *win,char *name, +void *regptr,uint64_t val) +{ +if (val) +pr_err ("%swin #%d: %s reg %p, val 0x%llx\n" , + win->tx_win ?"Tx" :"Rx" , win->winid, name, + regptr, val); +} + +#else /* vas_debug */ + +#define vas_log_write (win, name, reg, val) + +#endif /* vas_debug */ + +static inline void write_uwc_reg (struct vas_window *win,char *name, +int32_t reg,uint64_t val) +{ +void *regptr; + + regptr = win->uwc_map + reg; +vas_log_write (win, name, regptr, val); + +out_be64 (regptr, val); +} + +static inline void write_hvwc_reg (struct vas_window *win,char *name, +int32_t reg,uint64_t val) +{ +void *regptr; + + regptr = win->hvwc_map + reg; +vas_log_write (win, name, regptr, val); + +out_be64 (regptr, val); +} + +static inline uint64_t read_hvwc_reg (struct vas_window *win, +char *name__maybe_unused ,int32_t reg) +{ +return in_be64 (win->hvwc_map+reg); +} +#endif
drivers/misc/vas/vas-window.c +334 -0
346 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 6/10 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.
--- drivers/misc/vas/vas-window.c | 74 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-)
drivers/misc/vas/vas-window.c +72 -2
@@ -119,7 +119,7 @@ static void unmap_wc_mmio_bars(struct vas_window *window)* 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_wc_mmio_bars (struct vas_window *window) +static int map_wc_mmio_bars (struct vas_window *window) {int len;uint64_t start;
@@ -472,8 +472,78 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)return 0 ; } -/* stub for now */ +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_MAX_WINDOWS_PER_CHIP ) { +pr_err ("VAS: Too many (%d) open windows\n" , winid); +vas_release_window_id (ida, winid); +return -EAGAIN ; + } + +return winid; +} + +static void vas_window_free (struct vas_window *window) +{ +unmap_wc_mmio_bars (window); +kfree (window->paste_addr_name); +kfree (window); +} + +static struct vas_window *vas_window_alloc (struct vas_instance *vinst,int id) +{ +struct vas_window *window; + + window =kzalloc (sizeof (*window),GFP_KERNEL ); +if (!window) +return NULL ; + + window->vinst = vinst; + window->winid = id; + +if (map_wc_mmio_bars (window)) + goto out_free; + +return window; + +out_free: +kfree (window); +return NULL ; +} +int vas_window_reset (struct vas_instance *vinst,int winid) { +struct vas_window *window; + + window =vas_window_alloc (vinst, winid); +if (!window) +return -ENOMEM ; + +reset_window_regs (window); + +vas_window_free (window); +return 0 ; }
Signature · 1 line
2.7.4
PATCH v3 10/10 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[v3]
- Map raw CR value from paste instruction into an error code.
--- arch/powerpc/include/asm/vas.h | 13 ++++++++ drivers/misc/vas/copy-paste.h | 74 +++++++++++++++++++++++++++++++++++++++++ drivers/misc/vas/vas-internal.h | 14 ++++++++ drivers/misc/vas/vas-window.c | 50 ++++++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 drivers/misc/vas/copy-paste.h
arch/powerpc/include/asm/vas.h +13 -0
@@ -132,6 +132,19 @@ 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); + +/* * Get/Set bit fields */ #define GET_FIELD (m, v) (((v) & (m)) >> MASK_LSH(m))
drivers/misc/vas/copy-paste.h new file +74 -0
74 lines not on this page · raw message
drivers/misc/vas/vas-internal.h +14 -0
@@ -456,4 +456,18 @@ static inline uint64_t read_hvwc_reg(struct vas_window *win, return in_be64(win->hvwc_map+reg); } +#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
drivers/misc/vas/vas-window.c +50 -0
62 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 7/10 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[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 | 46 +++++++++ drivers/misc/vas/vas-internal.h | 11 +++ drivers/misc/vas/vas-window.c | 200 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 257 insertions(+)
arch/powerpc/include/asm/vas.h +46 -0
@@ -38,6 +38,51 @@ 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 notify_disable; +bool intr_disable; +bool notify_early; + +int lnotify_lpid; +int lnotify_pid; +int lnotify_tid; +int pswid; + +int tc_mode; +}; + +/* +* 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); + +/* * Get/Set bit fields */ #define GET_FIELD (m, v) (((v) & (m)) >> MASK_LSH(m))
@@ -46,4 +91,5 @@ enum vas_cop_type { (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_LSH(m)) & (m)))#endif /* __KERNEL__ */ +#endif
drivers/misc/vas/vas-internal.h +11 -0
@@ -402,6 +402,16 @@ extern struct vas_instance *find_vas_instance(int vasid);#define VREG (r) VREG_SFX(r, _OFFSET)#ifndef 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) {
@@ -414,6 +424,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 */
drivers/misc/vas/vas-window.c +200 -0
203 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 8/10 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[v3]:
- Fix order of parameters in GET_FIELD().
- Update references and sequence for closing/quiescing a window.
--- arch/powerpc/include/asm/vas.h | 7 +++ drivers/misc/vas/vas-window.c | 120 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+)
arch/powerpc/include/asm/vas.h +7 -0
@@ -83,6 +83,13 @@ 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); + +/* * Get/Set bit fields */ #define GET_FIELD (m, v) (((v) & (m)) >> MASK_LSH(m))
drivers/misc/vas/vas-window.c +120 -0
129 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 9/10 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 [node, chip, cop] parameters, must already be open in VAS (i.e connected to an NX engine).
---
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 +++++++++++ drivers/misc/vas/vas-window.c | 157 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+)
arch/powerpc/include/asm/vas.h +42 -0
@@ -67,6 +67,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; +}; + +/* * Helper to initialize receive window attributes to defaults for an * NX window. */
@@ -83,6 +106,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.
drivers/misc/vas/vas-window.c +157 -0
163 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v3 02/10] Move GET_FIELD/SET_FIELD to vas.h
In reply to Sukadev BhattiproluQuoted 8 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]>
also, can you change the MAINTAINERS file owner of the IBM Power 842 accelerator to yourself, or someone else at IBM? I no longer have access to any of the ppc hardware, so it hardly makes sense for me to remain the maintainer of it.
Quoted 73 lines
---
Changelog[v3]
- Fix order of parameters in nx-842 driver.--- arch/powerpc/include/asm/vas.h | 8 +++++++- drivers/crypto/nx/nx-842-powernv.c | 7 ++++--- drivers/crypto/nx/nx-842.h | 5 ----- 3 files changed, 11 insertions(+), 9 deletions(-)arch/powerpc/include/asm/vas.h +7
-1@@ -37,7 +37,13 @@ enum vas_cop_type { VAS_COP_TYPE_MAX, }; +/* +* 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 /* __KERNEL__ */ -#endif 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
-6@@ -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: -- 2.7.4
Re: [PATCH v3 03/10] VAS: Define vas_init() and vas_exit()
In reply to Sukadev BhattiproluMAINTAINERS F:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0a=
Quoted 3 lines · Sukadev Bhattiprolu
MAINTAINERS +0
-0@@ -3673,8 +3673,6 @@ F:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0a=
rch/powerpc/platforms/powernv/pci-cxl.c
MAINTAINERS
Quoted 5 lines
=C2=A0F:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0drivers/misc/cxl/ =C2=A0F:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0include/misc/cxl* =C2=A0F:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0include/uapi/misc/cxl.h
MAINTAINERS +0
-2-F:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Documentation/powerpc/cxl.txt -F:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0Documentation/ABI/testing/sysfs-class-cx=
l
Quoted 1 line
=20
This shouldn't be deleted.
Mikey
Re: [PATCH v3 01/10] VAS: Define macros, register fields and structures
In reply to Sukadev BhattiproluQuoted 4 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. =20
Quoted 1 line
Signed-off-by Sukadev Bhattiprolu <[email protected]>
Quoted 16 lines
---
Changelog[v3]
- Renamewinctx->pidtowinctx->pidrto reflect that its a value =C2=A0=C2=A0from 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 =C2=A0=C2=A0the threshold-control modes.
- Add a pid field to structvas_window- needed for user space =C2=A0=C2=A0send windows.
=20
Changelog[v2]
- Add an overview of VAS invas-internal.h
- Get window context parameters from device tree and drop =C2=A0=C2=A0unnecessary macros.
---
=C2=A0MAINTAINERS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|= =C2=A0=C2=A0=C2=A06 +
Quoted 2 lines
=C2=A0arch/powerpc/include/asm/vas.h=C2=A0=C2=A0|=C2=A0=C2=A043 +++++ =C2=A0drivers/misc/vas/vas-internal.h | 392 +++++++++++++++++++++++++++++=
+++++++++++
This is going to have to go through gregkh/lkml if it's drivers/misc. you'= ll at
least need gregkh's ack/ok before mpe will take them (which is what we did = for
CAPI).
We might want to keep this in arch/powerpc but I'm not sure.
Quoted 4 lines
=C2=A03 files changed, 441 insertions(+) =C2=A0create mode 100644
arch/powerpc/include/asm/vas.h=C2=A0create mode 100644drivers/misc/vas/vas-internal.h=20
<snip>
drivers/misc/vas/vas-internal.h
Quoted 7 lines
drivers/misc/vas/vas-internal.h new file +7
-0+ +/* +* Overview of Virtual Accelerator Switchboard (VAS). +* +* VAS is a hardware "switchboard" that allows senders and receivers to +* exchange messages with _minimal_ kernel involvment. The receivers are +* typically NX coprocessor engines that perform compression or encrypti=
on
Quoted 4 lines
+ * in hardware, but receivers can also be other software threads.
+ *
+ * Senders are user/kernel threads that submit compression/encryption or
+ * other requests to the receivers. Senders must format their messages a=
s
Quoted 1 line
+ * Coprocessor Request Blocks (CRB)s and submit them using the instructi=
ons
Quoted 4 lines
+ * "copy" and "paste" which were introduced in Power9.
+ *
+ * A Power node can have (upto?) 8 Power chips. There is one instance of
+ * VAS in each Power9 chip. Each instance of VAS has 64K windows or port=
s,
Quoted 1 line
+ * Senders and receivers must each connect to a separate window before t=
hey
Quoted 9 lines
+ * can exchange messages through the switchboard.
+ *
+ * Each window is described by two types of window contexts:
+ *Quoted 1 line
+ * Hypervisor Window Context (HVWC) of size
VAS_HVWC_SIZEbytes+ *
Quoted 1 line
+ * OS/User Window Context (UWC) of size
VAS_UWC_SIZEbytes.+ *
+ * A window context can be viewed as a set of 64-bit registers. The sett=
ings
Quoted 1 line
+ * in these registers configure/control/determine the behavior of the VA=
S
Quoted 1 line
+ * hardware when messages are sent/received through the window. The regi=
sters
Quoted 1 line
+ * in the HVWC are configured by the kernel while the registers in the U=
WC can
Quoted 1 line
+ * be configured by the kernel or by the user space application that is =
using
Quoted 3 lines
+ * the window.
+ *
+ * The HVWCs for all windows on a specific instance of VAS are in a cont=
iguous
Quoted 1 line
+ * range of hardware addresses or Base address region (BAR) referred to =
as the
Quoted 1 line
+ * HVWC BAR for the instance. Similarly the UWCs for all windows on an i=
nstance
Quoted 1 line
+ * are referred to as the UWC BAR for the instance. The two BARs for eac=
h
Quoted 1 line
+ * instance are defined Power9 MMIO Ranges spreadsheet and available to =
the
Quoted 6 lines
+ * kernel the device tree as follows:
+ *Quoted 3 lines
+ *
/proc/device-tree/xscom@.../vas@.../hvwc-bar-start
+ */proc/device-tree/xscom@.../vas@.../hvwc-bar-size
+ */proc/device-tree/xscom@.../vas@.../uwc-bar-start+ *
/proc/device-tree/xscom@.../vas@.../uwc-bar-size
should these just be reg properties?
Quoted 2 lines
+ *
+ * The kernel maps these two hardware address regions into the kernel ad=
dress
Quoted 1 line
+ * space (
hvwc_mapanduwc_map) and accesses the window contexts of a sp=
ecific
Quoted 10 lines
+ * window using:
+ *Quoted 2 lines
+ * =C2=A0hvwc =3D
hvwc_map+ winid *VAS_HVWC_SIZE.
+ * =C2=A0uwc =3Duwc_map+ winid *VAS_UWC_SIZE.+ *
+ * where winid is the window index (0..64K).
+ *
+ * Note that the window contexts are used to "configure" the windows. In
+ * addition to this configuration address, each _send_ window also has a
+ * unique hardware address, referred to as the "paste-address" to which =
the
Quoted 1 line
+ * sender must "paste" the message (CRB) they wish to submit. This hardw=
are
Quoted 1 line
+ * paste address for window can be computed from the following nodes in =
the
Quoted 4 lines
+ * device tree:
+ *Quoted 1 line
+ *
/proc/device-tree/xscom@.../vas@.../window-base+ *
/proc/device-tree/xscom@.../vas@.../window-shift
Same here with reg properties.
<snip>=20
Quoted 1 line
+struct
vas_winctx{
<snip>
drivers/misc/vas/vas-internal.h line 375
Quoted 2 lines
Quoted 1 line
drivers/misc/vas/vas-internal.h new file +1
-0+int lpid;drivers/misc/vas/vas-internal.h new file +1
-0+int pidr;/* value from SPRN_PID, not linux pid */
I'm surprised we have a copy of these here. They should be accessed from t= he
context we are attaching to, rather than copied here... but I've not looked=
at
the rest of the code yet...
Re: [PATCH v3 03/10] VAS: Define vas_init() and vas_exit()
In reply to Michael NeulingQuoted 4 lines · Michael Neuling [[email protected]] wrote:
MAINTAINERS F:=A0=A0=A0=A0=A0=A0=A0=A0arch/powerpc/platforms/=
Quoted 3 lines · Sukadev Bhattiprolu
MAINTAINERS +0
-0@@ -3673,8 +3673,6 @@ F:=A0=A0=A0=A0=A0=A0=A0=A0arch/powerpc/platforms/=
powernv/pci-cxl.c
Quoted 8 lines
Quoted 6 lines
=A0F:=A0=A0=A0=A0=A0drivers/misc/cxl/
=A0F:=A0=A0=A0=A0=A0include/misc/cxl*
=A0F:=A0=A0=A0=A0=A0include/uapi/misc/cxl.hMAINTAINERS +0
-2-F:=A0=A0=A0=A0=A0Documentation/powerpc/cxl.txt -F:=A0=A0=A0=A0=A0Documentation/ABI/testing/sysfs-class-cxl=20
=20
This shouldn't be deleted.
Yes, I will fix it.
Thanks
Sukadev
Quoted 2 lines
=20
Mikey
Re: [PATCH v3 03/10] VAS: Define vas_init() and vas_exit()
In reply to Sukadev BhattiproluQuoted 5 lines · Sukadev Bhattiprolu
Implement
vas_init()andvas_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. =20Signed-off-by Sukadev Bhattiprolu <[email protected]>
Quoted 8 lines
---
Changelog[v3]:
- Zerovas_instancesmemory on allocation
- [Haren Myneni] Fix description inKconfig
Changelog[v2]:
- Get HVWC, UWC and window address parameters from device tree.
---
=C2=A0MAINTAINERS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0|= =C2=A0=C2=A0=C2=A08 ++-
Quoted 2 lines
=C2=A0arch/powerpc/include/asm/reg.h=C2=A0=C2=A0|=C2=A0=C2=A0=C2=A01 + =C2=A0drivers/misc/Kconfig=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0|=C2=A0=C2=A0=C2=A01 +
Quoted 1 line
=C2=A0drivers/misc/Makefile=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0|=C2=A0=C2=A0=C2=A01 +
Quoted 1 line
=C2=A0drivers/misc/vas/Kconfig=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0|=C2=A0=C2=A021 ++++++
Quoted 1 line
=C2=A0drivers/misc/vas/Makefile=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
|=C2=A0=C2=A0=C2=A03 +
Quoted 2 lines
=C2=A0drivers/misc/vas/vas-internal.h |=C2=A0=C2=A0=C2=A03 + =C2=A0drivers/misc/vas/vas-window.c=C2=A0=C2=A0=C2=A0|=C2=A0=C2=A019 ++++=
+
Quoted 1 line
=C2=A0drivers/misc/vas/vas.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0| 155
Quoted 15 lines
++++++++++++++++++++++++++++++++++++++++
=C2=A09 files changed, 210 insertions(+), 2 deletions(-) =C2=A0create mode 100644drivers/misc/vas/Kconfig=C2=A0create mode 100644drivers/misc/vas/Makefile=C2=A0create mode 100644drivers/misc/vas/vas-window.c=C2=A0create mode 100644drivers/misc/vas/vas.c=20MAINTAINERS +0
-0@@ -3673,8 +3673,6 @@ F: arch/powerpc/platforms/powernv/pci-cxl.c=C2=A0F:
drivers/misc/cxl/
=C2=A0F:include/misc/cxl*
=C2=A0F:include/uapi/misc/cxl.h
MAINTAINERS F: arch/powerpc/platforms/powernv/pci-cxl.c · line 3677
Quoted 2 lines
MAINTAINERS +0
-2-F: Documentation/powerpc/cxl.txt -F: Documentation/ABI/testing/sysfs-class-cxl
err?
Quoted 1 line
=C2=A0CXLFLASH (IBM Coherent Accelerator Processor Interface CAPI Flash) =
SCSI
MAINTAINERS F: drivers/scsi/cxlflash/ · line 3692
Quoted 12 lines
DRIVER
=C2=A0M: Manoj N. Kumar <[email protected]>MAINTAINERS +0
-0@@ -3686,6 +3684,12 @@ F: drivers/scsi/cxlflash/=C2=A0F:
include/uapi/scsi/cxlflash_ioctls.h
=C2=A0F:Documentation/powerpc/cxlflash.txt
=C2=A0MAINTAINERS +6
-0+VAS (IBM Virtual Accelerator Switch) DRIVER +M: Sukadev Bhattiprolu <[email protected]> +L: [email protected] +S: Supported +F: drivers/misc/vas/ +
This was already added in patch 1.
arch/powerpc/include/asm/re=
Quoted 4 lines
=C2=A0STMMAC ETHERNET DRIVER
=C2=A0M: Giuseppe Cavallaro <[email protected]>
=C2=A0M: Alexandre Torgue <[email protected]>arch/powerpc/include/asm/re= renamed from arch/powerpc/include/asm/reg.h +0
-0
g.h
Quoted 8 lines
index fc879fd..7a45ff7 100644
arch/powerpc/include/asm/reg.h +0
-0@@ -1225,6 +1225,7 @@=C2=A0#define
PVR_POWER8E0x004B
=C2=A0#definePVR_POWER8NVL0x004C
=C2=A0#definePVR_POWER80x004D
+#definePVR_POWER90x004E
Can you send this up separately? =20
Quoted 18 lines
=C2=A0#define
PVR_BE0x0070
=C2=A0#definePVR_PA6T0x0090
=C2=A0drivers/misc/Kconfig +0
-0@@ -783,4 +783,5 @@ source "drivers/misc/mic/Kconfig"=C2=A0source "
drivers/misc/genwqe/Kconfig"
=C2=A0source "drivers/misc/echo/Kconfig"
=C2=A0source "drivers/misc/cxl/Kconfig"
+source "drivers/misc/vas/Kconfig"
=C2=A0endmenudrivers/misc/Makefile +0
-0@@ -53,6 +53,7 @@ obj-$(CONFIG_GENWQE) +=3D genwqe/
Quoted 5 lines
=C2=A0obj-$(CONFIG_ECHO) +=3D echo/
=C2=A0obj-$(CONFIG_VEXPRESS_SYSCFG) +=3D vexpress-syscfg.o
=C2=A0obj-$(CONFIG_CXL_BASE) +=3D cxl/
+obj-$(CONFIG_VAS) +=3D vas/
=C2=A0obj-$(CONFIG_PANEL)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0+=3D panel.o
Quoted 15 lines
=C2=A0
=C2=A0lkdtm-$(CONFIG_LKDTM) +=3D lkdtm_core.odrivers/misc/vas/Kconfig new file +7
-0@@ -0,0 +1,21 @@ +# +# IBM Virtual Accelarator Switchboard (VAS) compatible devices +#depends on PPC_POWERNV && PCI_MSI && EEH +# + +config VAS + tristate "Support for IBM Virtual Accelerator Switchboard (VAS)"
drivers/misc/vas/Kconfig line 17
Quoted 10 lines
drivers/misc/vas/Kconfig new file +10
-0+ depends on PPC_POWERNV + default n + help + =C2=A0=C2=A0Select this option to enable driver support for IBM Virtual + =C2=A0=C2=A0Accelerator Switchboard (VAS). + + =C2=A0=C2=A0VAS allows accelerators in co processors like NX-842 to be + =C2=A0=C2=A0directly available to a user process. This driver enables + =C2=A0=C2=A0userspace programs to access these accelerators via device + =C2=A0=C2=A0nodes like /dev/crypto/nx-gzip.
I though this was kernel only users for now?
drivers/misc/vas/vas-inter=
Quoted 15 lines
drivers/misc/vas/Kconfig new file +4
-0+ + =C2=A0=C2=A0VAS adapters are found in POWER9 based systems. + + =C2=A0=C2=A0If unsure, say N.drivers/misc/vas/Makefile new file +1
-0@@ -0,0 +1,3 @@ +ccflags-y :=3D $(call cc-disable-warning, unused-const-variable)
drivers/misc/vas/Makefile new file +2
-0+ccflags-$(CONFIG_PPC_WERROR) +=3D -Werror +obj-$(CONFIG_VAS) +=3D vas.o vas-window.odrivers/misc/vas/vas-inter= renamed from drivers/misc/vas/vas-internal.h +0
-0
nal.h
drivers/misc/vas/vas-internal.h
Quoted 3 lines
index ce48f14..15b62e0 100644
drivers/misc/vas/vas-internal.h +0
-0
Just call this file vas.h.=20
Internal one is here. Kernel api one lives in include/misc. User API live= s in./include/uapi/misc. =C2=A0
eg. CXL does this:
% find . -name cxl.h./include/uapi/misc/cxl.h./include/misc/cxl.h./drivers/misc/cxl/cxl.h
Quoted 5 lines
drivers/misc/vas/vas-internal.h +0
-0@@ -389,4 +389,7 @@ struct vas_winctx { =C2=A0 enum vas_notify_after_count notify_after_count; =C2=A0};=C2=A0
+extern intvas_initialized;
I would probably make this a function.
drivers/misc/vas/vas-window.=
Quoted 4 lines
drivers/misc/vas/vas-internal.h +2
-0+extern int vas_window_reset (struct vas_instance *vinst,int winid); +extern struct vas_instance *find_vas_instance (int vasid);=C2=A0#endif
drivers/misc/vas/vas-window.= renamed from drivers/misc/vas/vas-window.c +0
-0
c
Quoted 13 lines
new file mode 100644
index 0000000..468f3bfdrivers/misc/vas/vas-window.c new file +8
-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. +*/
drivers/misc/vas/vas-window.c line 18
Quoted 10 lines
drivers/misc/vas/vas-window.c new file +10
-0+ +#include <linux/types.h> +#include <linux/mutex.h> +#include <asm/vas.h> +#include "vas-internal.h" + +/* stub for now */ +int vas_window_reset (struct vas_instance *vinst,int winid) +{ +return 0 ;
No biggy, but best to return an error if it's just a stub in case sometime = tries
to use it.
Quoted 166 lines
drivers/misc/vas/vas-window.c new file +1
-0+}drivers/misc/vas/vas.c new file +48
-0@@ -0,0 +1,155 @@ +/* +* 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/module.h> +#include <linux/kernel.h> +#include <linux/export.h> +#include <linux/types.h> +#include <linux/slab.h> +#include <linux/of.h> +#include <asm/vas.h> +#include "vas-internal.h" + +int vas_initialized; +int vas_num_instances; +struct vas_instance *vas_instances; + +static void init_vas_chip (struct vas_instance *vinst) +{ +int i; + + for (i =3D 0; i < VAS_MAX_WINDOWS_PER_CHIP; i++) +vas_window_reset (vinst, i); +} + +static int init_vas_instance (struct device_node *dn, +struct vas_instance *vinst) +{ +int rc; +const __be32 *p; + +ida_init (&vinst->ida); +mutex_init (&vinst->mutex); + + p =3D of_get_property(dn, "vas-id", NULL); +if (!p) { +pr_err ("VAS: NULL vas-id? %p\n" , p); +return -ENODEV ; + } + + vinst->vas_id =3D of_read_number(p, 1); + + rc =3D of_property_read_u64(dn, "hvwc-bar-start", &vinst-Quoted 1 line
hvwc_bar_start);drivers/misc/vas/vas.c new file +8
-0+if (rc) +return rc; + + rc =3D of_property_read_u64(dn, "hvwc-bar-size", &vinst->hvwc_bar_len); +if (rc) +return rc; + + rc =3D of_property_read_u64(dn, "uwc-bar-start", &vinst-Quoted 1 line
uwc_bar_start);drivers/misc/vas/vas.c new file +57
-0+if (rc) +return rc; + + rc =3D of_property_read_u64(dn, "uwc-bar-size", &vinst->uwc_bar_len); +if (rc) +return rc; + + rc =3D of_property_read_u64(dn, "window-base", &vinst->win_base_addr); +if (rc) +return rc; + + rc =3D of_property_read_u64(dn, "window-shift", &vinst->win_id_shift); +if (rc) +return rc; + +init_vas_chip (vinst); + +return 0 ; +} + +/* +* Although this is read/used multiple times, it is written to only +* during initialization. +*/ +struct vas_instance *find_vas_instance (int vasid) +{ +int i; +struct vas_instance *vinst; + + for (i =3D 0; i < vas_num_instances; i++) { + vinst =3D &vas_instances[i]; + if (vinst->vas_id =3D=3D vasid) +return vinst; + } +pr_err ("VAS instance for vas-id %d not found\n" , vasid); +WARN_ON_ONCE (1 ); +return NULL ; +} + + +int vas_init (void ) +{ +int rc; +struct device_node *dn; +struct vas_instance *vinst; + +if (!pvr_version_is (PVR_POWER9 )) +return -ENODEV ; + + vas_num_instances =3D 0; +for_each_node_by_name (dn,"vas" ) + vas_num_instances++; + +if (!vas_num_instances) +return -ENODEV ; + + vas_instances =3D kcalloc(vas_num_instances, sizeof(*vinst),
GFP_KERNEL);drivers/misc/vas/vas.c new file +8
-0+if (!vas_instances) +return -ENOMEM ; + + vinst =3D &vas_instances[0 ]; +for_each_node_by_name (dn,"vas" ) { + rc =3D init_vas_instance(dn, vinst); +if (rc) { + pr_err("Error %d initializing VAS instance %ld\n",rc,
drivers/misc/vas/vas.c new file +34
-0+ (vinst-&vas_instances[0])); + goto cleanup; + } + vinst++; + } + + rc =3D -ENODEV ; + if (vinst =3D=3D &vas_instances[0]) { +/* Should not happen as we saw some above. */ +pr_err ("VAS: Did not find any VAS DT nodes now!\n" ); + goto cleanup; + } + +pr_devel ("VAS: Initialized %d instances\n" , vas_num_instances); + vas_initialized =3D 1; + +return 0 ; + +cleanup: +kfree (vas_instances); +return rc; +} + +void vas_exit (void ) +{ + vas_initialized =3D 0; +kfree (vas_instances); +} + +module_init (vas_init); +module_exit (vas_exit); +MODULE_DESCRIPTION ("IBM Virtual Accelerator Switchboard" ); +MODULE_AUTHOR ("Sukadev Bhattiprolu <[email protected]>" ); +MODULE_LICENSE ("GPL" );
Re: [PATCH v3 04/10] VAS: Define helpers for access MMIO regions
In reply to Sukadev Bhattiproludrivers/misc/vas/vas-window.=
Quoted 19 lines · Sukadev Bhattiprolu
Define some helper functions to access the MMIO regions. We use these in a follow-on patches to read/write VAS hardware registers. These helpers are also used to later issue 'paste' instructions to submit requests to the NX hardware engines.
=20Signed-off-by Sukadev Bhattiprolu <[email protected]>---
Changelog [v3]:
- Minor reorg/cleanup of map/unmap functions
=20
Changelog [v2]:
- Get HVWC, UWC and paste addresses fromwindow->vinst(i.e DT) =C2=A0=C2=A0rather than kernel macros.
---
=C2=A0drivers/misc/vas/vas-window.c | 126
++++++++++++++++++++++++++++++++++++++++++
=C2=A01 file changed, 126 insertions(+)
=20drivers/misc/vas/vas-window.= renamed from drivers/misc/vas/vas-window.c +0
-0
c
Quoted 12 lines
index 468f3bf..32dd1d0 100644
drivers/misc/vas/vas-window.c +0
-0@@ -9,9 +9,135 @@=C2=A0
=C2=A0#include <linux/types.h>
=C2=A0#include <linux/mutex.h>drivers/misc/vas/vas-window.c +2
-0+#include <linux/slab.h> +#include <linux/io.h> =C2=A0#include <
asm/vas.h>
=C2=A0#include "vas-internal.h"
=C2=A0
drivers/misc/vas/vas-window.c
Quoted 5 lines
drivers/misc/vas/vas-window.c +5
-0+/* +* Compute the paste address region for the window @window using the +* ->win_base_addr and ->win_id_shift we got from device tree. +*/ +void compute_paste_address(struct vas_window *window, uint64_t *addr, in=
t
Quoted 23 lines
*len)
drivers/misc/vas/vas-window.c +22
-0+{ +uint64_t base, shift; +int winid; + + base =3D window->vinst->win_base_addr; + shift =3D window->vinst->win_id_shift; + winid =3D window->winid; + + *addr=C2=A0=C2=A0=3D base + (winid << shift); + *len =3D 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 =3D window->vinst->hvwc_bar_start; + *start =3D pbaddr + window->winid * VAS_HVWC_SIZE; + *len =3D VAS_HVWC_SIZE;
drivers/misc/vas/vas-window.c
Quoted 10 lines
drivers/misc/vas/vas-window.c +10
-0+} + +static inline void get_uwc_mmio_bar (struct vas_window *window, +uint64_t *start,int *len) +{ +uint64_t pbaddr; + + pbaddr =3D window->vinst->uwc_bar_start; + *start =3D pbaddr + window->winid * VAS_UWC_SIZE; + *len =3D VAS_UWC_SIZE;
I'm not sure this works for 4K pages since VAS_UWC_SIZE =3D PAGE_SIZE but i= n
reality I think it's always 64K. Right?
Seem like we are mixing pages sizes and hardware sizes here.
(I realise 4K isn't supported yet, but....)
Quoted 54 lines
drivers/misc/vas/vas-window.c +15
-0+} + +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 =3D __ioremap(start, len, pgprot_val(pgprot_cached(__pgprot(0)))); +if (!map) { + pr_devel("%s(): ioremap(0x%llx, %d) failed\n", __func__,start,
drivers/misc/vas/vas-window.c +38
-0+ len); +return NULL ; + } + +return map; +} + +/* +* Unmap the MMIO regions for a window. +*/ +static void unmap_wc_paste_kaddr (struct vas_window *window) +{ +int len; +uint64_t busaddr_start; + +if (window->paste_kaddr) { +iounmap (window->paste_kaddr); +compute_paste_address (window, &busaddr_start, &len); +release_mem_region ((phys_addr_t )busaddr_start, len); + window->paste_kaddr =3D NULL; + } + +} + +static void unmap_wc_mmio_bars (struct vas_window *window) +{ +int len; +uint64_t busaddr_start; + +unmap_wc_paste_kaddr (window); + +if (window->hvwc_map) { +iounmap (window->hvwc_map); +get_hvwc_mmio_bar (window, &busaddr_start, &len); +release_mem_region ((phys_addr_t )busaddr_start, len); + window->hvwc_map =3D NULL; + } +
drivers/misc/vas/vas-window.c
Quoted 10 lines
drivers/misc/vas/vas-window.c +10
-0+if (window->uwc_map) { +iounmap (window->uwc_map); +get_uwc_mmio_bar (window, &busaddr_start, &len); +release_mem_region ((phys_addr_t )busaddr_start, len); + window->uwc_map =3D NULL; + } +} + +/* +* Find the Hypervisor Window Context (HVWC) MMIO Base Address Region an=
d the
Quoted 3 lines
+ * OS/User Window Context (UWC) MMIO Base Address Region for the given window.
+ * Map these bus addresses and save the mapped kernel addresses in @wind=
ow.
Quoted 25 lines
+ */
drivers/misc/vas/vas-window.c +21
-0+int map_wc_mmio_bars (struct vas_window *window) +{ +int len; +uint64_t start; + + window->paste_kaddr =3D window->hvwc_map =3D window->uwc_map =3D NULL; + +get_hvwc_mmio_bar (window, &start, &len); + window->hvwc_map =3D map_mmio_region("HVWCM_Window", start, len); + +get_uwc_mmio_bar (window, &start, &len); + window->uwc_map =3D map_mmio_region("UWCM_Window", start, len); + +if (!window->hvwc_map || !window->uwc_map) { +unmap_wc_mmio_bars (window); +return -1 ; + } + +return 0 ; +} +=C2=A0/* stub for now */
=C2=A0intvas_window_reset(struct vas_instance *vinst, int winid)=C2=A0{
Re: [PATCH v3 05/10] VAS: Define helpers to init window context
In reply to Sukadev Bhattiproludrivers/misc/vas/vas-inter=
Quoted 21 lines · Sukadev Bhattiprolu
Define helpers to initialize window context registers of the VAS hardware. These will be used in follow-on patches when opening/closing VAS windows.
=20Signed-off-by Sukadev Bhattiprolu <[email protected]>---
Changelog[v3]
- Have caller, rather thaninit_xlate_regs()reset window regs =C2=A0=C2=A0so we don't reset any settings caller may already have set.
- Translation mode should be0x3(0b11) not0x11.
- Skip initilaizing read-only registersNX_UTILandNX_UTIL_SE
- Skip initializing adder registers from UWC - they are already =C2=A0=C2=A0initialized from the HVWC.
- Checkwinctx->user_winwhen setting translation registers
---
=C2=A0drivers/misc/vas/vas-internal.h |=C2=A0=C2=A059 ++++++- =C2=A0drivers/misc/vas/vas-window.c=C2=A0=C2=A0=C2=A0| 334
++++++++++++++++++++++++++++++++++++++++
=C2=A02 files changed, 390 insertions(+), 3 deletions(-)
=20drivers/misc/vas/vas-inter= renamed from drivers/misc/vas/vas-internal.h +0
-0
nal.h
Quoted 15 lines
index 15b62e0..8e721df 100644
drivers/misc/vas/vas-internal.h +0
-0@@ -11,6 +11,7 @@=C2=A0#define
VAS_INTERNAL_H
=C2=A0#include <linux/atomic.h>
=C2=A0#include <linux/idr.h>
+#include <linux/io.h>
=C2=A0#include <asm/vas.h>
=C2=A0
=C2=A0#ifdefCONFIG_PPC_4K_PAGESdrivers/misc/vas/vas-internal.h +0
-0@@ -336,9 +337,6 @@ struct vas_window {=C2=A0 /* Feilds applicable only to receive windows */
=C2=A0 enumvas_cop_typecop;
=C2=A0atomic_tnum_txwins;
drivers/misc/vas/vas-internal.h struct vas_window { · line 341
Quoted 3 lines
drivers/misc/vas/vas-internal.h +0
-3- -int32_t hwirq; -uint64_t irq_port;
We are removing things already? :-)
drivers/misc/vas/vas-window.=
Quoted 64 lines
=C2=A0};
=C2=A0
=C2=A0/*drivers/misc/vas/vas-internal.h +55
-0@@ -392,4 +390,59 @@ struct vas_winctx { =C2=A0extern int vas_initialized; =C2=A0extern int vas_window_reset(struct vas_instance *vinst, int winid); =C2=A0extern struct vas_instance *find_vas_instance(int vasid); + +/* +* VREG(x): +* Expand a register's short name (eg: LPID) into two parameters: +* - the register's short name in string form ("LPID"), and +* - the name of the macro (eg: VAS_LPID_OFFSET), defining the +* =C2=A0=C2=A0register's offset in the window context +*/ +#define VREG_SFX (n, s) __stringify(n), VAS_##n##s +#define VREG (r) VREG_SFX(r, _OFFSET) + +#ifndef vas_debug +static inline void vas_log_write (struct vas_window *win,char *name, +void *regptr,uint64_t val) +{ +if (val) +pr_err ("%swin #%d: %s reg %p, val 0x%llx\n" , + win->tx_win ?"Tx" :"Rx" , win->winid, name, + regptr, val); +} + +#else /* vas_debug */ + +#define vas_log_write (win, name, reg, val) + +#endif /* vas_debug */ + +static inline void write_uwc_reg (struct vas_window *win,char *name, +int32_t reg,uint64_t val) +{ +void *regptr; + + regptr =3D win->uwc_map + reg; +vas_log_write (win, name, regptr, val); + +out_be64 (regptr, val); +} + +static inline void write_hvwc_reg (struct vas_window *win,char *name, +int32_t reg,uint64_t val) +{ +void *regptr; + + regptr =3D win->hvwc_map + reg; +vas_log_write (win, name, regptr, val); + +out_be64 (regptr, val); +} + +static inline uint64_t read_hvwc_reg (struct vas_window *win, +char *name__maybe_unused ,int32_t reg) +{ +return in_be64 (win->hvwc_map+reg); +} +=C2=A0#endif
drivers/misc/vas/vas-window.= renamed from drivers/misc/vas/vas-window.c +0
-0
c
Quoted 11 lines
index 32dd1d0..edf5c9f 100644
drivers/misc/vas/vas-window.c +0
-0@@ -14,6 +14,8 @@=C2=A0#include <
asm/vas.h>
=C2=A0#include "vas-internal.h"
=C2=A0drivers/misc/vas/vas-window.c +2
-0+static int fault_winid; +=C2=A0/*
=C2=A0 * Compute the paste address region for the window @window using th=
e
Quoted 10 lines
=C2=A0 * ->win_base_addr and ->win_id_shift we got from device tree.
drivers/misc/vas/vas-window.c +0
-0@@ -138,6 +140,338 @@ int map_wc_mmio_bars(struct vas_window *window) =C2=A0 return 0; =C2=A0}=C2=A0
+/*
+ * 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 al=
l
Quoted 62 lines
+ * =C2=A0offsets in a window context are valid registers and the valid
+ * =C2=A0registers are not sequential. And, we can only write to offsets
+ * =C2=A0with valid registers (or is that only in Simics?).
+ */drivers/misc/vas/vas-window.c +58
-0+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 */ + +/* +=C2=A0* The send and receive window credit adder registers are also +=C2=A0* accessible from HVWC and have been initialized above. We don't +=C2=A0* need to initialize from the OS/User Window Context, so skip +=C2=A0* following calls: +=C2=A0* +=C2=A0* write_uwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); +=C2=A0* write_uwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); +=C2=A0*/ +} + +/* +* Initialize window context registers related to Address Translation. +* These registers are common to send/receive windows although they
drivers/misc/vas/vas-window.c int map_wc_mmio_bars(struct vas_window *window) · line 219
Quoted 10 lines
drivers/misc/vas/vas-window.c +10
-0+* 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, msr, val; + + msr =3D mfmsr(); +WARN_ON_ONCE (!(msr &MSR_SF ));
We don't support 32 bit userspace? I would return an error rather than thi= s.
drivers/misc/vas/vas-window.c
Quoted 12 lines
drivers/misc/vas/vas-window.c +12
-0+ + val =3D 0ULL; +if (user_win) { + val =3D SET_FIELD(VAS_XLATE_MSR_DR, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_TA, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_PR, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_US, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_HV, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_SF, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_UV, val, false); + }else { + val =3D SET_FIELD(VAS_XLATE_MSR_DR, val, false);
kernel contexts don't go through the nestmmu?
drivers/misc/vas/vas-window.c
Quoted 2 lines
drivers/misc/vas/vas-window.c +2
-0+ val =3D SET_FIELD(VAS_XLATE_MSR_TA, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_PR, val, msr & MSR_PR);
I don't understand this. It should just be 0 for the kernel.
drivers/misc/vas/vas-window.c
Quoted 12 lines
drivers/misc/vas/vas-window.c +12
-0+ val =3D SET_FIELD(VAS_XLATE_MSR_US, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_HV, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_SF, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_UV, val, false); + } +write_hvwc_reg (window,VREG (XLATE_MSR ), val); + + lpcr =3D mfspr(SPRN_LPCR); + val =3D 0ULL; +/* +=C2=A0* NOTE: From Section 5.7.6.1 Segment Lookaside Buffer of the +=C2=A0* =C2=A0Power ISA, v2.07, Page size encoding is 0 =3D 4KB, 5 =3D =
64KB.
Quoted 16 lines
drivers/misc/vas/vas-window.c +16
-0+=C2=A0* +=C2=A0* NOTE: From Section 1.3.1, Address Translation Context of the +=C2=A0* =C2=A0Nest MMU Workbook, LPCR_SC should be 0 for Power9. +=C2=A0*/ + val =3D SET_FIELD(VAS_XLATE_LPCR_PAGE_SIZE, val, 5); + val =3D SET_FIELD(VAS_XLATE_LPCR_ISL, val, lpcr & LPCR_ISL); + val =3D SET_FIELD(VAS_XLATE_LPCR_TC, val, lpcr & LPCR_TC); + val =3D SET_FIELD(VAS_XLATE_LPCR_SC, val, 0); +write_hvwc_reg (window,VREG (XLATE_LPCR ), val); + +/* +=C2=A0* Section 1.3.1 (Address translation Context) of NMMU workbook. +=C2=A0* 0b00 Hashed Page Table mode +=C2=A0* 0b01 Reserved +=C2=A0* 0b10 Radix on HPT - not supported in P9 +=C2=A0* 0b11 Radix on Radix (only mode supported in Linux on
Quoted 1 line
P9).
Linux supports hash on P9.
Does VAS only support radix? If so you should error out if we are booted h= ash.
drivers/misc/vas/vas-window.c
Quoted 3 lines
drivers/misc/vas/vas-window.c +3
-0+=C2=A0*/ + val =3D 0ULL; + val =3D SET_FIELD(VAS_XLATE_MODE, val, 0x3);
You can use radix_enabled() to set this for hash vs radix.
drivers/misc/vas/vas-window.c int map_wc_mmio_bars(struct vas_window *window)
Quoted 11 lines
drivers/misc/vas/vas-window.c +11
-0+write_hvwc_reg (window,VREG (XLATE_CTL ), val); + +/* +=C2=A0* TODO: Can we mfspr(AMR) even for user windows? +=C2=A0*/ + val =3D 0ULL; + val =3D SET_FIELD(VAS_AMR, val, mfspr(SPRN_AMR)); +write_hvwc_reg (window,VREG (AMR ), val); + +/* +=C2=A0* TODO: Assuming Secure Executable ID Register (SEIDR) is only us=
ed
drivers/misc/vas/vas-window.c int map_wc_mmio_bars(struct vas_window *window)
Quoted 12 lines
drivers/misc/vas/vas-window.c +1
-0+ =C2=A0* =C2=A0in the ultravisor mode. Since MSR(UV) is 0 for now, setSEIDR
drivers/misc/vas/vas-window.c +1
-0+ =C2=A0* =C2=A0to 0 as well, although we should 'mfspr(SEIDR)' at somepoint.
drivers/misc/vas/vas-window.c +8
-0+=C2=A0*/ + val =3D 0ULL; + val =3D SET_FIELD(VAS_SEIDR, val, 0); +write_hvwc_reg (window,VREG (SEIDR ), val); +} + +/* +* Initialize Reserved Send Buffer Count for the send window. It involve=
s
Quoted 8 lines
+ * 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.
+ */
drivers/misc/vas/vas-window.c int map_wc_mmio_bars(struct vas_window *window)
Quoted 8 lines
drivers/misc/vas/vas-window.c +8
-0+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 ); +} + +/* +* Compute the log2() of the FIFO size expressed as kilobytes. It is int=
ended
Quoted 1 line
+ * to be used to initialize the Local FIFO Size Register defined in Sect=
ion
Quoted 1 line
+ * 3.14.25 of the VAS Workbook.
There is a ilog2() function..
Quoted 19 lines
+ */
drivers/misc/vas/vas-window.c +18
-0+static int map_fifo_size_to_reg (int fifo_size) +{ +int kb; +int map; + + kb =3D fifo_size / 1024; +if (!kb) + kb =3D 1; + + map =3D -1 ; +while (kb) { + kb >>=3D 1; + map++; + } + +return map; +} +
Re: [PATCH v3 06/10] VAS: Define helpers to alloc/free windows
In reply to Sukadev BhattiproluQuoted 6 lines · Sukadev Bhattiprolu
Define helpers to allocate/free VAS window objects. These will be used in follow-on patches when opening/closing windows. =20
Signed-off-by Sukadev Bhattiprolu <[email protected]>---
=C2=A0drivers/misc/vas/vas-window.c | 74 ++++++++++++++++++++++++++++++++=
+++++++++-
drivers/misc/vas/vas-window.=
Quoted 4 lines
-
=C2=A01 file changed, 72 insertions(+), 2 deletions(-) =20drivers/misc/vas/vas-window.= renamed from drivers/misc/vas/vas-window.c +0
-0
c
drivers/misc/vas/vas-window.c static void unmap_wc_mmio_bars(struct vas_window *win=
Quoted 4 lines
index edf5c9f..9233bf5 100644
drivers/misc/vas/vas-window.c +0
-0@@ -119,7 +119,7 @@ static void unmap_wc_mmio_bars(struct vas_window *win=
dow)
Quoted 1 line
=C2=A0 * OS/User Window Context (UWC) MMIO Base Address Region for the gi=
ven
Quoted 2 lines
window.
=C2=A0 * Map these bus addresses and save the mapped kernel addresses in =
@window.
drivers/misc/vas/vas-window.c int init_winctx_regs(struct vas_window *window, stru=
Quoted 7 lines
=C2=A0 */
drivers/misc/vas/vas-window.c +1
-1-int map_wc_mmio_bars (struct vas_window *window) +static int map_wc_mmio_bars (struct vas_window *window)=C2=A0{
=C2=A0 int len;
=C2=A0uint64_tstart;drivers/misc/vas/vas-window.c +0
-0@@ -472,8 +472,78 @@ int init_winctx_regs(struct vas_window *window, stru=
ct
Quoted 36 lines
drivers/misc/vas/vas-window.c +0
-0vas_winctx *winctx) =C2=A0 return 0; =C2=A0}=C2=A0
drivers/misc/vas/vas-window.c +31
-1-/* stub for now */ +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 =3D ida_pre_get(ida, GFP_KERNEL); +if (!rc) +return -EAGAIN ; + +spin_lock (&vas_ida_lock); + rc =3D ida_get_new_above(ida, 0, &winid); +spin_unlock (&vas_ida_lock); + +if (rc) +return rc; + +if (winid >VAS_MAX_WINDOWS_PER_CHIP ) { +pr_err ("VAS: Too many (%d) open windows\n" , winid); +vas_release_window_id (ida, winid); +return -EAGAIN ; + } + +return winid;
drivers/misc/vas/vas-window.c int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)
Quoted 10 lines
drivers/misc/vas/vas-window.c +10
-0+} + +static void vas_window_free (struct vas_window *window) +{ +unmap_wc_mmio_bars (window); +kfree (window->paste_addr_name); +kfree (window); +} + +static struct vas_window *vas_window_alloc(struct vas_instance *vinst, i=
nt
Quoted 21 lines
id)
drivers/misc/vas/vas-window.c +20
-0+{ +struct vas_window *window; + + window =3D kzalloc(sizeof(*window), GFP_KERNEL); +if (!window) +return NULL ; + + window->vinst =3D vinst; + window->winid =3D id; + +if (map_wc_mmio_bars (window)) + goto out_free; + +return window; + +out_free: +kfree (window); +return NULL ; +} +
Quoted 2 lines
=C2=A0int
vas_window_reset(struct vas_instance *vinst, int winid)=20
This interface seems a little weird to me. Needing an alloc in a hardware r= eset
path seems a bit strange.
Maybe the data structures are the issue. A window is a hardware construct.= =20
Something that uses it should probably be called something else like a cont= ext.=20
Something that references a window should just be the vas_instance + winid.= =20
You should be able to reset this hardware window by referencing structures already allocated. Something associated with the struct vas_instance.
Mikey
Quoted 13 lines
=C2=A0{
drivers/misc/vas/vas-window.c +10
-0+struct vas_window *window; + + window =3D vas_window_alloc(vinst, winid); +if (!window) +return -ENOMEM ; + +reset_window_regs (window); + +vas_window_free (window); +=C2=A0 return 0;
=C2=A0}
Re: [PATCH v3 04/10] VAS: Define helpers for access MMIO regions
In reply to Michael NeulingQuoted 11 lines · Michael Neuling [[email protected]] wrote:
drivers/misc/vas/vas-window.c line 53
Quoted 8 lines
drivers/misc/vas/vas-window.c +8
-0+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 ;I'm not sure this works for 4K pages since
VAS_UWC_SIZE=PAGE_SIZEbut in reality I think it's always 64K. Right?
I believe the idea is that each user process will have its OS/User Window context on a separate page - to provide proper protection of the window context between processes. So, the OS/User Window context size _is_ dependent on page size.
The page size is set to 64K in init_north_ctl() in skiboot but can be set to 4K as well. The amount of memory allocated for the OS/User Window Context MMIO BAR (init_uwcm() in skiboot) also depends on the page size 256MB for 4K or 4GB for 64K.
Quoted 4 lines
Seem like we are mixing pages sizes and hardware sizes here.
(I realise 4K isn't supported yet, but....)
Yes, only 64K page-size for now.
Thanks,
Sukadev
Re: [PATCH v3 03/10] VAS: Define vas_init() and vas_exit()
In reply to Michael NeulingQuoted 14 lines · Michael Neuling [[email protected]] wrote:
Quoted 5 lines · Sukadev Bhattiprolu
Implement
vas_init()andvas_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. =20Signed-off-by Sukadev Bhattiprolu <[email protected]>Quoted 8 lines
---
Changelog[v3]:
- Zerovas_instancesmemory on allocation
- [Haren Myneni] Fix description inKconfig
Changelog[v2]:
- Get HVWC, UWC and window address parameters from device tree.
---
=A0MAINTAINERS=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0|=A0=A0=A08 ++-
Quoted 19 lines
Quoted 19 lines
=A0arch/powerpc/include/asm/reg.h=A0=A0|=A0=A0=A01 + =A0drivers/misc/Kconfig=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0|=A0=A0=A01 + =A0drivers/misc/Makefile=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0|=A0=A0=A01 + =A0drivers/misc/vas/Kconfig=A0=A0=A0=A0=A0=A0=A0=A0|=A0=A021 ++++++ =A0drivers/misc/vas/Makefile=A0=A0=A0=A0=A0=A0=A0|=A0=A0=A03 + =A0drivers/misc/vas/vas-internal.h |=A0=A0=A03 + =A0drivers/misc/vas/vas-window.c=A0=A0=A0|=A0=A019 +++++ =A0drivers/misc/vas/vas.c=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0| 155
++++++++++++++++++++++++++++++++++++++++
=A09 files changed, 210 insertions(+), 2 deletions(-) =A0create mode 100644drivers/misc/vas/Kconfig
=A0create mode 100644drivers/misc/vas/Makefile
=A0create mode 100644drivers/misc/vas/vas-window.c=A0create mode 100644drivers/misc/vas/vas.c
=20MAINTAINERS +0
-0
Quoted 8 lines
MAINTAINERS F: arch/powerpc/platforms/powernv/pci-cxl.c · line 3677
Quoted 6 lines
MAINTAINERS +0
-0@@ -3673,8 +3673,6 @@ F: arch/powerpc/platforms/powernv/pci-cxl.c=A0F:
drivers/misc/cxl/
=A0F:include/misc/cxl*
=A0F:include/uapi/misc/cxl.hMAINTAINERS +0
-2-F: Documentation/powerpc/cxl.txt -F: Documentation/ABI/testing/sysfs-class-cxl=20
err?
Yeah, something got messed up here and
Quoted 2 lines
=20
Quoted 1 line
=A0CXLFLASH (IBM Coherent Accelerator Processor Interface CAPI Flash) S=
CSI
Quoted 6 lines
Quoted 6 lines
DRIVER
=A0M: Manoj N. Kumar <[email protected]>MAINTAINERS +0
-0@@ -3686,6 +3684,12 @@ F: drivers/scsi/cxlflash/=A0F:
include/uapi/scsi/cxlflash_ioctls.h
=A0F:Documentation/powerpc/cxlflash.txt
=A0
Quoted 8 lines
MAINTAINERS F: drivers/scsi/cxlflash/ · line 3692
Quoted 6 lines
MAINTAINERS +6
-0+VAS (IBM Virtual Accelerator Switch) DRIVER +M: Sukadev Bhattiprolu <[email protected]> +L: [email protected] +S: Supported +F: drivers/misc/vas/ +=20
This was already added in patch 1.
here. Will fix
Quoted 5 lines
=20
arch/powerpc/include/asm/=
Quoted 4 lines
=A0STMMAC ETHERNET DRIVER
=A0M: Giuseppe Cavallaro <[email protected]>
=A0M: Alexandre Torgue <[email protected]>arch/powerpc/include/asm/= renamed from arch/powerpc/include/asm/reg.h +0
-0
reg.h
Quoted 10 lines
Quoted 8 lines
index fc879fd..7a45ff7 100644
arch/powerpc/include/asm/reg.h +0
-0@@ -1225,6 +1225,7 @@=A0#define
PVR_POWER8E0x004B
=A0#definePVR_POWER8NVL0x004C
=A0#definePVR_POWER80x004D
+#definePVR_POWER90x004E=20
Can you send this up separately? =20
Sure.
Quoted 16 lines
=20
Quoted 15 lines
=A0#define
PVR_BE0x0070
=A0#definePVR_PA6T0x0090
=A0drivers/misc/Kconfig +0
-0@@ -783,4 +783,5 @@ source "drivers/misc/mic/Kconfig"=A0source "
drivers/misc/genwqe/Kconfig"
=A0source "drivers/misc/echo/Kconfig"
=A0source "drivers/misc/cxl/Kconfig"
+source "drivers/misc/vas/Kconfig"
=A0endmenudrivers/misc/Makefile +0
-0
Quoted 8 lines
Quoted 8 lines
drivers/misc/Makefile +0
-0@@ -53,6 +53,7 @@ obj-$(CONFIG_GENWQE) +=3D genwqe/=A0obj-$(CONFIG_ECHO) +=3D echo/
=A0obj-$(CONFIG_VEXPRESS_SYSCFG) +=3D vexpress-syscfg.o
=A0obj-$(CONFIG_CXL_BASE) +=3D cxl/
+obj-$(CONFIG_VAS) +=3D vas/
=A0obj-$(CONFIG_PANEL)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0+=3D panel=
=2Eo
Quoted 19 lines
Quoted 19 lines
=A0
=A0lkdtm-$(CONFIG_LKDTM) +=3D lkdtm_core.odrivers/misc/vas/Kconfig new file +11
-0@@ -0,0 +1,21 @@ +# +# IBM Virtual Accelarator Switchboard (VAS) compatible devices +#depends on PPC_POWERNV && PCI_MSI && EEH +# + +config VAS + tristate "Support for IBM Virtual Accelerator Switchboard (VAS)" + depends on PPC_POWERNV + default n + help + =A0=A0Select this option to enable driver support for IBM Virtual
Quoted 8 lines
drivers/misc/vas/Kconfig line 17
Quoted 6 lines
drivers/misc/vas/Kconfig new file +6
-0+ =A0=A0Accelerator Switchboard (VAS). + + =A0=A0VAS allows accelerators in co processors like NX-842 to be + =A0=A0directly available to a user process. This driver enables + =A0=A0userspace programs to access these accelerators via device + =A0=A0nodes like /dev/crypto/nx-gzip.=20
I though this was kernel only users for now?
Yes, its only kernel for now. Will drop the last sentence.
Quoted 16 lines
=20
drivers/misc/vas/vas-int=
Quoted 15 lines
drivers/misc/vas/Kconfig new file +4
-0+ + =A0=A0VAS adapters are found in POWER9 based systems. + + =A0=A0If unsure, say N.drivers/misc/vas/Makefile new file +1
-0@@ -0,0 +1,3 @@ +ccflags-y :=3D $(call cc-disable-warning, unused-const-variable)
drivers/misc/vas/Makefile new file +2
-0+ccflags-$(CONFIG_PPC_WERROR) +=3D -Werror +obj-$(CONFIG_VAS) +=3D vas.o vas-window.odrivers/misc/vas/vas-int= renamed from drivers/misc/vas/vas-internal.h +0
-0
ernal.h
Quoted 7 lines
drivers/misc/vas/vas-internal.h
Quoted 3 lines
index ce48f14..15b62e0 100644
drivers/misc/vas/vas-internal.h +0
-0=20
Just call this file vas.h.=20
=20
Internal one is here. Kernel api one lives ininclude/misc. User API li=
ves in
Quoted 8 lines
./include/uapi/misc. =A0
=20
eg. CXL does this:
=20
% find . -namecxl.h./include/uapi/misc/cxl.h./include/misc/cxl.h./drivers/misc/cxl/cxl.h
Sure, makes sense.
Quoted 9 lines
=20
=20Quoted 5 lines
drivers/misc/vas/vas-internal.h +0
-0@@ -389,4 +389,7 @@ struct vas_winctx { =A0 enum vas_notify_after_count notify_after_count; =A0};=A0
+extern intvas_initialized;=20
I would probably make this a function.
Ok.
Quoted 5 lines
=20
drivers/misc/vas/vas-windo=
Quoted 4 lines
drivers/misc/vas/vas-internal.h +2
-0+extern int vas_window_reset (struct vas_instance *vinst,int winid); +extern struct vas_instance *find_vas_instance (int vasid);=A0#endif
drivers/misc/vas/vas-windo= renamed from drivers/misc/vas/vas-window.c +0
-0
w.c
Quoted 17 lines
Quoted 17 lines
new file mode 100644
index 0000000..468f3bfdrivers/misc/vas/vas-window.c new file +12
-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 <asm/vas.h>
Quoted 8 lines
drivers/misc/vas/vas-window.c line 18
Quoted 6 lines
drivers/misc/vas/vas-window.c new file +6
-0+#include "vas-internal.h" + +/* stub for now */ +int vas_window_reset (struct vas_instance *vinst,int winid) +{ +return 0 ;=20
No biggy, but best to return an error if it's just a stub in case sometim=
e tries
Quoted 1 line
to use it.
Sure.
Thanks
Sukadev
Re: [PATCH v3 01/10] VAS: Define macros, register fields and structures
In reply to Michael NeulingQuoted 5 lines · Michael Neuling [[email protected]] wrote:
Quoted 4 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. =20
Quoted 1 line
Signed-off-by Sukadev Bhattiprolu <[email protected]>
Quoted 16 lines
Quoted 8 lines
---
Changelog[v3]
- Renamewinctx->pidtowinctx->pidrto reflect that its a value =A0=A0from 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 =A0=A0the threshold-control modes.
- Add a pid field to structvas_window- needed for user spaceQuoted 8 lines
=A0=A0send windows.
=20
Changelog[v2]
- Add an overview of VAS invas-internal.h
- Get window context parameters from device tree and drop =A0=A0unnecessary macros.
---
=A0MAINTAINERS=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0|=A0=A0=A06 +
Quoted 2 lines
Quoted 2 lines
=A0arch/powerpc/include/asm/vas.h=A0=A0|=A0=A043 +++++ =A0drivers/misc/vas/vas-internal.h | 392 ++++++++++++++++++++++++++++++=
++++++++++
Quoted 2 lines
=20
This is going to have to go through gregkh/lkml if it'sdrivers/misc. yo=
u'll at
Quoted 1 line
least need gregkh's ack/ok before mpe will take them (which is what we di=
d for
Quoted 4 lines
CAPI).
=20
We might want to keep this inarch/powerpcbut I'm not sure. =20
We will have device nodes accessible to user space so put it here and can copy Gregkh next time. But let me know if we should move to arch/powerpc.
Quoted 11 lines
Quoted 4 lines
=A03 files changed, 441 insertions(+) =A0create mode 100644
arch/powerpc/include/asm/vas.h=A0create mode 100644drivers/misc/vas/vas-internal.h=20<snip>
drivers/misc/vas/vas-internal.h
Quoted 6 lines
drivers/misc/vas/vas-internal.h new file +6
-0+ +/* +* Overview of Virtual Accelerator Switchboard (VAS). +* +* VAS is a hardware "switchboard" that allows senders and receivers to +* exchange messages with _minimal_ kernel involvment. The receivers a=
re
Quoted 1 line
Quoted 1 line
+ * typically NX coprocessor engines that perform compression or encryp=
tion
Quoted 3 lines
Quoted 3 lines
+ * in hardware, but receivers can also be other software threads.
+ *
+ * Senders are user/kernel threads that submit compression/encryption =
or
Quoted 1 line
Quoted 1 line
+ * other requests to the receivers. Senders must format their messages=
as
Quoted 1 line
Quoted 1 line
+ * Coprocessor Request Blocks (CRB)s and submit them using the instruc=
tions
Quoted 3 lines
Quoted 3 lines
+ * "copy" and "paste" which were introduced in Power9.
+ *
+ * A Power node can have (upto?) 8 Power chips. There is one instance =
of
Quoted 1 line
Quoted 1 line
+ * VAS in each Power9 chip. Each instance of VAS has 64K windows or po=
rts,
Quoted 1 line
Quoted 1 line
+ * Senders and receivers must each connect to a separate window before=
they
Quoted 9 lines
Quoted 9 lines
+ * can exchange messages through the switchboard.
+ *
+ * Each window is described by two types of window contexts:
+ *Quoted 1 line
+ * Hypervisor Window Context (HVWC) of size
VAS_HVWC_SIZEbytes+ *
Quoted 1 line
+ * OS/User Window Context (UWC) of size
VAS_UWC_SIZEbytes.+ *
+ * A window context can be viewed as a set of 64-bit registers. The se=
ttings
Quoted 1 line
Quoted 1 line
+ * in these registers configure/control/determine the behavior of the =
VAS
Quoted 1 line
Quoted 1 line
+ * hardware when messages are sent/received through the window. The re=
gisters
Quoted 1 line
Quoted 1 line
+ * in the HVWC are configured by the kernel while the registers in the=
UWC can
Quoted 1 line
Quoted 1 line
+ * be configured by the kernel or by the user space application that i=
s using
Quoted 3 lines
Quoted 3 lines
+ * the window.
+ *
+ * The HVWCs for all windows on a specific instance of VAS are in a co=
ntiguous
Quoted 1 line
Quoted 1 line
+ * range of hardware addresses or Base address region (BAR) referred t=
o as the
Quoted 1 line
Quoted 1 line
+ * HVWC BAR for the instance. Similarly the UWCs for all windows on an=
instance
Quoted 1 line
Quoted 1 line
+ * are referred to as the UWC BAR for the instance. The two BARs for e=
ach
Quoted 1 line
Quoted 1 line
+ * instance are defined Power9 MMIO Ranges spreadsheet and available t=
o the
Quoted 8 lines
Quoted 6 lines
+ * kernel the device tree as follows:
+ *Quoted 3 lines
+ *
/proc/device-tree/xscom@.../vas@.../hvwc-bar-start
+ */proc/device-tree/xscom@.../vas@.../hvwc-bar-size
+ */proc/device-tree/xscom@.../vas@.../uwc-bar-start+ *
/proc/device-tree/xscom@.../vas@.../uwc-bar-size=20
should these just be reg properties?
I guess they could. Will try that
Quoted 3 lines
=20
Quoted 2 lines
+ *
+ * The kernel maps these two hardware address regions into the kernel =
address
Quoted 1 line
Quoted 1 line
+ * space (
hvwc_mapanduwc_map) and accesses the window contexts of a =
specific
Quoted 8 lines
Quoted 8 lines
+ * window using:
+ *Quoted 2 lines
+ * =A0hvwc =3D
hvwc_map+ winid *VAS_HVWC_SIZE.
+ * =A0uwc =3Duwc_map+ winid *VAS_UWC_SIZE.+ *
+ * where winid is the window index (0..64K).
+ *
+ * Note that the window contexts are used to "configure" the windows. =
In
Quoted 1 line
Quoted 1 line
+ * addition to this configuration address, each _send_ window also has=
a
Quoted 1 line
Quoted 1 line
+ * unique hardware address, referred to as the "paste-address" to whic=
h the
Quoted 1 line
Quoted 1 line
+ * sender must "paste" the message (CRB) they wish to submit. This har=
dware
Quoted 1 line
Quoted 1 line
+ * paste address for window can be computed from the following nodes i=
n the
Quoted 6 lines
Quoted 4 lines
+ * device tree:
+ *Quoted 1 line
+ *
/proc/device-tree/xscom@.../vas@.../window-base+ *
/proc/device-tree/xscom@.../vas@.../window-shift=20
Same here with reg properties.
ok
Quoted 8 lines
=20
<snip>=20Quoted 1 line
+struct
vas_winctx{<snip>
drivers/misc/vas/vas-internal.h line 375
Quoted 2 lines
Quoted 1 line
drivers/misc/vas/vas-internal.h new file +1
-0+int lpid;drivers/misc/vas/vas-internal.h new file +1
-0+int pidr;/* value from SPRN_PID, not linux pid */ =20
I'm surprised we have a copy of these here. They should be accessed from=
the
Quoted 1 line
context we are attaching to, rather than copied here... but I've not look=
ed at
Quoted 1 line
the rest of the code yet...
struct vas_winctx is just a convenient container for the window context. It gets initialized based on type/use of window (user/kernel send/receive). The lpid/pid are set by callers of VAS kernel interfaces.
Sukadev
Re: [PATCH v3 05/10] VAS: Define helpers to init window context
In reply to Michael NeulingQuoted 11 lines · Michael Neuling [[email protected]] wrote:
drivers/misc/vas/vas-internal.h struct vas_window { · line 341
Quoted 8 lines · Sukadev Bhattiprolu
=A0#ifdef
CONFIG_PPC_4K_PAGES(quoted diff) +0
-0@@ -336,9 +337,6 @@ struct vas_window {=A0 /* Feilds applicable only to receive windows */
=A0 enumvas_cop_typecop;
=A0atomic_tnum_txwins;drivers/misc/vas/vas-internal.h +0
-3- -int32_t hwirq; -uint64_t irq_port;=20
We are removing things already? :-)
:-) They are needed when we add support for user windows will remove them in the earlier patch.=20
Quoted 57 lines
=20
Quoted 56 lines
=A0};
=A0
=A0/*drivers/misc/vas/vas-internal.h +49
-0@@ -392,4 +390,59 @@ struct vas_winctx { =A0extern int vas_initialized; =A0extern int vas_window_reset(struct vas_instance *vinst, int winid); =A0extern struct vas_instance *find_vas_instance(int vasid); + +/* +* VREG(x): +* Expand a register's short name (eg: LPID) into two parameters: +* - the register's short name in string form ("LPID"), and +* - the name of the macro (eg: VAS_LPID_OFFSET), defining the +* =A0=A0register's offset in the window context +*/ +#define VREG_SFX (n, s) __stringify(n), VAS_##n##s +#define VREG (r) VREG_SFX(r, _OFFSET) + +#ifndef vas_debug +static inline void vas_log_write (struct vas_window *win,char *name, +void *regptr,uint64_t val) +{ +if (val) +pr_err ("%swin #%d: %s reg %p, val 0x%llx\n" , + win->tx_win ?"Tx" :"Rx" , win->winid, name, + regptr, val); +} + +#else /* vas_debug */ + +#define vas_log_write (win, name, reg, val) + +#endif /* vas_debug */ + +static inline void write_uwc_reg (struct vas_window *win,char *name, +int32_t reg,uint64_t val) +{ +void *regptr; + + regptr =3D win->uwc_map + reg; +vas_log_write (win, name, regptr, val); + +out_be64 (regptr, val); +} + +static inline void write_hvwc_reg (struct vas_window *win,char *name, +int32_t reg,uint64_t val) +{ +void *regptr; + + regptr =3D win->hvwc_map + reg; +vas_log_write (win, name, regptr, val); + +out_be64 (regptr, val); +} +
Quoted 8 lines
drivers/misc/vas/vas-windo=
Quoted 8 lines
drivers/misc/vas/vas-internal.h +6
-0+static inline uint64_t read_hvwc_reg (struct vas_window *win, +char *name__maybe_unused ,int32_t reg) +{ +return in_be64 (win->hvwc_map+reg); +} +=A0#endif
drivers/misc/vas/vas-windo= renamed from drivers/misc/vas/vas-window.c +0
-0
w.c
Quoted 13 lines
Quoted 13 lines
index 32dd1d0..edf5c9f 100644
drivers/misc/vas/vas-window.c +0
-0@@ -14,6 +14,8 @@=A0#include <
asm/vas.h>
=A0#include "vas-internal.h"
=A0drivers/misc/vas/vas-window.c +2
-0+static int fault_winid; +=A0/*
=A0 * Compute the paste address region for the window @window using the =A0 * ->win_base_addr and ->win_id_shift we got from device tree.drivers/misc/vas/vas-window.c +0
-0@@ -138,6 +140,338 @@ int map_wc_mmio_bars(struct vas_window *window)
Quoted 8 lines
Quoted 8 lines
drivers/misc/vas/vas-window.c +0
-0=A0 return 0; =A0}=A0
+/*
+ * 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
Quoted 66 lines
Quoted 66 lines
+ * =A0offsets in a window context are valid registers and the valid
+ * =A0registers are not sequential. And, we can only write to offsets
+ * =A0with valid registers (or is that only in Simics?).
+ */drivers/misc/vas/vas-window.c +62
-0+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 */ + +/* +=A0* The send and receive window credit adder registers are also +=A0* accessible from HVWC and have been initialized above. We don't +=A0* need to initialize from the OS/User Window Context, so skip +=A0* following calls: +=A0* +=A0* write_uwc_reg(window, VREG(TX_WCRED_ADDER), 0ULL); +=A0* write_uwc_reg(window, VREG(LRX_WCRED_ADDER), 0ULL); +=A0*/ +} + +/* +* 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(). +*/
Quoted 8 lines
drivers/misc/vas/vas-window.c int map_wc_mmio_bars(struct vas_window *window) · line 219
Quoted 6 lines
drivers/misc/vas/vas-window.c +6
-0+static void init_xlate_regs (struct vas_window *window,bool user_win) +{ +uint64_t lpcr, msr, val; + + msr =3D mfmsr(); +WARN_ON_ONCE (!(msr &MSR_SF ));=20
We don't support 32 bit userspace? I would return an error rather than t=
his.
I will return an error and add a TODO for 32-bit.
Quoted 15 lines
=20
drivers/misc/vas/vas-window.c
Quoted 12 lines
drivers/misc/vas/vas-window.c +12
-0+ + val =3D 0ULL; +if (user_win) { + val =3D SET_FIELD(VAS_XLATE_MSR_DR, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_TA, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_PR, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_US, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_HV, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_SF, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_UV, val, false); + }else { + val =3D SET_FIELD(VAS_XLATE_MSR_DR, val, false);=20
kernel contexts don't go through the nestmmu?
I think so, but will check with Alistair/Ben.
Quoted 5 lines
=20
drivers/misc/vas/vas-window.c
Quoted 2 lines
drivers/misc/vas/vas-window.c +2
-0+ val =3D SET_FIELD(VAS_XLATE_MSR_TA, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_PR, val, msr & MSR_PR);=20
I don't understand this. It should just be 0 for the kernel.
Ok.
Quoted 24 lines
=20
Quoted 23 lines
drivers/misc/vas/vas-window.c +23
-0+ val =3D SET_FIELD(VAS_XLATE_MSR_US, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_HV, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_SF, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_UV, val, false); + } +write_hvwc_reg (window,VREG (XLATE_MSR ), val); + + lpcr =3D mfspr(SPRN_LPCR); + val =3D 0ULL; +/* +=A0* NOTE: From Section 5.7.6.1 Segment Lookaside Buffer of the +=A0* =A0Power ISA, v2.07, Page size encoding is 0 =3D 4KB, 5 =3D 64KB. +=A0* +=A0* NOTE: From Section 1.3.1, Address Translation Context of the +=A0* =A0Nest MMU Workbook, LPCR_SC should be 0 for Power9. +=A0*/ + val =3D SET_FIELD(VAS_XLATE_LPCR_PAGE_SIZE, val, 5); + val =3D SET_FIELD(VAS_XLATE_LPCR_ISL, val, lpcr & LPCR_ISL); + val =3D SET_FIELD(VAS_XLATE_LPCR_TC, val, lpcr & LPCR_TC); + val =3D SET_FIELD(VAS_XLATE_LPCR_SC, val, 0); +write_hvwc_reg (window,VREG (XLATE_LPCR ), val); + +/*
Quoted 8 lines
Quoted 6 lines
drivers/misc/vas/vas-window.c +5
-0+ =A0* Section 1.3.1 (Address translation Context) of NMMU workbook. + =A0* 0b00 Hashed Page Table mode + =A0* 0b01 Reserved + =A0* 0b10 Radix on HPT - not supported in P9 + =A0* 0b11 Radix on Radix (only mode supported in Linux onP9).
=20
Linux supports hash on P9.
Ok. I was quoting from the Nest MMU spec. Will remove the text in ()s.
Quoted 2 lines
=20
Does VAS only support radix? If so you should error out if we are booted=
hash.
I think VAS just offloads the translation to NestMMU and doesn't really depend on radix/HPT. I was going by the comment in the spec.
Quoted 6 lines
=20
drivers/misc/vas/vas-window.c
Quoted 3 lines
drivers/misc/vas/vas-window.c +3
-0+=A0*/ + val =3D 0ULL; + val =3D SET_FIELD(VAS_XLATE_MODE, val, 0x3);=20
You can useradix_enabled()to set this for hash vs radix.
Ok.
Quoted 16 lines
=20
Quoted 15 lines
drivers/misc/vas/vas-window.c +12
-0+write_hvwc_reg (window,VREG (XLATE_CTL ), val); + +/* +=A0* TODO: Can we mfspr(AMR) even for user windows? +=A0*/ + val =3D 0ULL; + val =3D SET_FIELD(VAS_AMR, val, mfspr(SPRN_AMR)); +write_hvwc_reg (window,VREG (AMR ), val); + +/* +=A0* TODO: Assuming Secure Executable ID Register (SEIDR) is only used +=A0* =A0in the ultravisor mode. Since MSR(UV) is 0 for now, set SEIDR
drivers/misc/vas/vas-window.c +1
-0+ =A0* =A0to 0 as well, although we should 'mfspr(SEIDR)' at somepoint.
Quoted 8 lines
drivers/misc/vas/vas-window.c int map_wc_mmio_bars(struct vas_window *window)
Quoted 8 lines
drivers/misc/vas/vas-window.c +8
-0+=A0*/ + val =3D 0ULL; + val =3D SET_FIELD(VAS_SEIDR, val, 0); +write_hvwc_reg (window,VREG (SEIDR ), val); +} + +/* +* Initialize Reserved Send Buffer Count for the send window. It invol=
ves
Quoted 1 line
Quoted 1 line
+ * writing to the register, reading it back to confirm that the hardwa=
re
Quoted 1 line
Quoted 1 line
+ * has enough buffers to reserve. See section 1.3.1.2.1 of VAS workboo=
k.
Quoted 6 lines
Quoted 6 lines
+ *
+ * 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.
+ */
Quoted 8 lines
drivers/misc/vas/vas-window.c int map_wc_mmio_bars(struct vas_window *window)
Quoted 8 lines
drivers/misc/vas/vas-window.c +8
-0+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 ); +} + +/* +* Compute the log2() of the FIFO size expressed as kilobytes. It is i=
ntended
Quoted 1 line
Quoted 1 line
+ * to be used to initialize the Local FIFO Size Register defined in Se=
ction
Quoted 3 lines
Quoted 1 line
+ * 3.14.25 of the VAS Workbook.
=20
There is ailog2()function..
Ok, will use that.
Thanks,
Suka
Re: [PATCH v3 06/10] VAS: Define helpers to alloc/free windows
In reply to Michael NeulingQuoted 7 lines · Michael Neuling [[email protected]] wrote:
Quoted 6 lines · Sukadev Bhattiprolu
Define helpers to allocate/free VAS window objects. These will be used in follow-on patches when opening/closing windows. =20
Signed-off-by Sukadev Bhattiprolu <[email protected]>---
=A0drivers/misc/vas/vas-window.c | 74 +++++++++++++++++++++++++++++++++=
++++++++-
Quoted 4 lines
drivers/misc/vas/vas-windo=
Quoted 4 lines
-
=A01 file changed, 72 insertions(+), 2 deletions(-) =20drivers/misc/vas/vas-windo= renamed from drivers/misc/vas/vas-window.c +0
-0
w.c
Quoted 4 lines
drivers/misc/vas/vas-window.c static void unmap_wc_mmio_bars(struct vas_window *w=
Quoted 4 lines
index edf5c9f..9233bf5 100644
drivers/misc/vas/vas-window.c +0
-0@@ -119,7 +119,7 @@ static void unmap_wc_mmio_bars(struct vas_window *w=
indow)
Quoted 1 line
Quoted 1 line
=A0 * OS/User Window Context (UWC) MMIO Base Address Region for the giv=
en
Quoted 2 lines
Quoted 2 lines
window.
=A0 * Map these bus addresses and save the mapped kernel addresses in @=
window.
Quoted 7 lines
drivers/misc/vas/vas-window.c int init_winctx_regs(struct vas_window *window, st=
Quoted 7 lines
=A0 */
drivers/misc/vas/vas-window.c +1
-1-int map_wc_mmio_bars (struct vas_window *window) +static int map_wc_mmio_bars (struct vas_window *window)=A0{
=A0 int len;
=A0uint64_tstart;drivers/misc/vas/vas-window.c +0
-0@@ -472,8 +472,78 @@ int init_winctx_regs(struct vas_window *window, st=
ruct
Quoted 38 lines
Quoted 38 lines
drivers/misc/vas/vas-window.c +0
-0vas_winctx *winctx) =A0 return 0; =A0}=A0
drivers/misc/vas/vas-window.c +33
-1-/* stub for now */ +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 =3D ida_pre_get(ida, GFP_KERNEL); +if (!rc) +return -EAGAIN ; + +spin_lock (&vas_ida_lock); + rc =3D ida_get_new_above(ida, 0, &winid); +spin_unlock (&vas_ida_lock); + +if (rc) +return rc; + +if (winid >VAS_MAX_WINDOWS_PER_CHIP ) { +pr_err ("VAS: Too many (%d) open windows\n" , winid); +vas_release_window_id (ida, winid); +return -EAGAIN ; + } + +return winid; +} +
Quoted 8 lines
drivers/misc/vas/vas-window.c int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx)
Quoted 8 lines
drivers/misc/vas/vas-window.c +8
-0+static void vas_window_free (struct vas_window *window) +{ +unmap_wc_mmio_bars (window); +kfree (window->paste_addr_name); +kfree (window); +} + +static struct vas_window *vas_window_alloc(struct vas_instance *vinst,=
int
Quoted 17 lines
Quoted 17 lines
id)
drivers/misc/vas/vas-window.c +16
-0+{ +struct vas_window *window; + + window =3D kzalloc(sizeof(*window), GFP_KERNEL); +if (!window) +return NULL ; + + window->vinst =3D vinst; + window->winid =3D id; + +if (map_wc_mmio_bars (window)) + goto out_free; + +return window; + +out_free:
Quoted 8 lines
Quoted 6 lines
drivers/misc/vas/vas-window.c +4
-0+kfree (window); +return NULL ; +} +=A0int
vas_window_reset(struct vas_instance *vinst, int winid)=20=20
This interface seems a little weird to me. Needing an alloc in a hardware=
reset
Quoted 1 line
path seems a bit strange.
Yeah, the name alloc in this interface is awkward.
I probably can drop this interface. Its used only during start up to clear the window contexts. But since we must and do clear each window context before using, we don't to do this during start up.
Quoted 2 lines
=20
Maybe the data structures are the issue. A window is a hardware construc=
t.=20
Quoted 1 line
Something that uses it should probably be called something else like a co=
ntext.=20
Quoted 1 line
Something that references a window should just be the
vas_instance+ wini=
d.=20
Quoted 4 lines
=20
You should be able to reset this hardware window by referencing structures already allocated. Something associated with the structvas_instance. =20
'struct vas_winctx' is the window context (register fields associated with the window) 'struct vas_window' is a container for the kernel state associated with a window.
Quoted 1 line
Mikey
Thanks for the review.
Sukadev
Re: [PATCH v3 05/10] VAS: Define helpers to init window context
In reply to Sukadev BhattiproluQuoted 14 lines
Quoted 14 lines
Review
Quoted 12 lines
(quoted diff) +11
-0+ val =3D 0ULL; + if (user_win) { + val =3D SET_FIELD(VAS_XLATE_MSR_DR, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_TA, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_PR, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_US, val, false); + val =3D SET_FIELD(VAS_XLATE_MSR_HV, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_SF, val, true); + val =3D SET_FIELD(VAS_XLATE_MSR_UV, val, false); + } else { + val =3D SET_FIELD(VAS_XLATE_MSR_DR, val, false);=20
kernel contexts don't go through the nestmmu?
Quoted 2 lines
=20
I think so, but will check with Alistair/Ben.
Well it's kinda up to you. Do you want to use the kernel mapping or not? = I
probably would unless there are issues.
Mikey
Re: [PATCH v3 01/10] VAS: Define macros, register fields and structures
In reply to Sukadev BhattiproluQuoted 6 lines · Sukadev Bhattiprolu [[email protected]] wrote:
Quoted 5 lines · Michael Neuling [[email protected]] wrote:
Quoted 4 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. =20
Quoted 1 line
Signed-off-by Sukadev Bhattiprolu <[email protected]>
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
---
Changelog[v3]
- Renamewinctx->pidtowinctx->pidrto reflect that its a value =A0=A0from 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 =A0=A0the threshold-control modes.
- Add a pid field to structvas_window- needed for user spaceQuoted 8 lines
Quoted 8 lines
=A0=A0send windows.=20
Changelog[v2]
- Add an overview of VAS invas-internal.h
- Get window context parameters from device tree and drop =A0=A0unnecessary macros.
---
=A0MAINTAINERS=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0|=A0=A0=A06 +
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
=A0arch/powerpc/include/asm/vas.h=A0=A0|=A0=A043 +++++ =A0drivers/misc/vas/vas-internal.h | 392 ++++++++++++++++++++++++++++=
++++++++++++
Quoted 2 lines
Quoted 2 lines
=20
This is going to have to go through gregkh/lkml if it'sdrivers/misc. =
you'll at
Quoted 1 line
Quoted 1 line
least need gregkh's ack/ok before mpe will take them (which is what we =
did for
Quoted 8 lines
Quoted 4 lines
CAPI).
=20
We might want to keep this inarch/powerpcbut I'm not sure. =20=20
We will have device nodes accessible to user space so put it here and can copy Gregkh next time. But let me know if we should move toarch/powerpc. =20
Thinking about this some more, the VAS module itself does not provide the device nodes. Rather, the drivers that use VAS, like NX-GZIP, will provide them. So, I am moving the VAS code into arch/powerpc/kernel.
Please let me know of any comments/concerns.
Thanks
Suka