POWER8 Coherent Accelerator device driver
Subsystems (5)
v3 cover POWER8 Coherent Accelerator device driver
This is the latest version of the cxl driver. Change log below:
v3:
- Updates based on comments from mpe, benh, aneesh and offline reviews.
- Fixed bug freeing AFU IRQs that also freed the multiplexed PSL IRQ
- Change copro_flush_all_slbs to a static inline as suggested by mpe
- Implement sanitisation routines to clear out more registers and do full adapter wide tlbia and slbia when initialising hardware
- Add self testcase to msi_bitmap to test allocations are aligned to a power of 2 and cleanup comment as suggested by mpe
- Clean up cxl_use_count
- Split out detach_process_native into two logical functions
- Improve comment in set_msi_irq_chip as requested by mpe
- Move cxl functions in pci-ioda.c to be under just one #ifdef CONFIG_CXL_BASE
- Cleanup hash_page and hash_page_mm from mpes and Aneesh' reviews
- Remove dead code in cxl_alloc_sst
- Add timeout in afu_slbia_native
- Remove cxl backend and driver ops abstractions
- Removed separate cxl-pci module
- Merged cxl pci module init calls into main driver init
- Refactor afu_read() to be a bit simpler and more closely follow exising patterns in the kernel
- Userspace API updates from reviews:
- Added ioctl to get the process element number, and removed it as a return from the start work ioctl
- Alter cxl_event to have one common header struct
- Dropped check error ioctl
- Added current and binary compatible API version numbers to sysfs
- read() now takes a 4K (or greater) buffer
- Pack event structs to reduce unecessary reserved fields
- Event sizes can now differ
- All event sizes are 64bit multiples to allow future event coalescing
- Add flags fields to indicate which fields contain valid data
- Add BUILD_BUG_ONs to protect against inadvertantly changing API without bumping version number and/or flags
- Update documentation
- Skip CXL SLBIA codepath if CXL is not in use
- Split cxl_slbia_core into two functions to be easier to read
- Refactor copro_data_segment (renamed to copro_calc_slb) since we are no longer merging with hash_page and cleaned up parameters.
- Some renames:
- struct cxl_t -> struct cxl
- struct cxl_afu_t -> struct cxl_afu
- struct cxl_context_t -> struct cxl_context
- copro_data_segment -> copro_calc_slb
- ctx->ph -> ctx->pe
- Added ctx->status mutex lock around for start and release context
v2:
- Updates based on comments from, Anton, Gavin, Aneesh, jk and offline reviews
- Simplified copro_data_segment() and merged code with hash_page_mm()
(New patch 10/17)
- PCIe code simplifications based on Gavin's review
- Removed redundant comment in msi_bitmap_alloc_hwirqs()
- Fix for locking in idr_remove in core driver
- Ensure PSL is enabled when PHB is flipped to CXL mode
- Added CONFIG_PPC_COPRO_BASE to compile copro_fault.c
- Merged SPU and cxl slb flushing calls into copro_flush_all_slbs()
(New patch 03/17) - Moved slb_vsid_shift() to static inline from #define
- Don't write paca->context when demoting segments and mm != current
- Fix minor typos in documentation
v1:
- Initial post
This add support for the Coherent Accelerator (cxl) attached to POWER8 processors. This coherent accelerator interface is designed to allow the coherent connection of FPGA based accelerators (and other devices) to a POWER systems.
IBM refers to this as the Coherent Accelerator Processor Interface or CAPI. In this driver it's referred to by the name cxl to avoid confusion with the ISDN CAPI subsystem.
An overview of the patches:
Patches 1-3: Split some of the old Cell co-processor code out so it can be
reused.
Patches 4-10: Add infrastructure to arch/powerpc needed by cxl. Patches 11: Add call backs needed for invalidating cxl mm contexts. Patch 12: Add cxl specific support that needs to be built in to the
kernel (can't be a module).
Patches 13-15: Add the majority of the device driver and API header.
Patch 16: Documentation.
The documentation in this last patch gives an overview of the hardware architecture as well as the userspace API.
The cxl driver has a user-space interface described in include/uapi/misc/cxl.h and Documentation/powerpc/cxl.txt. There are two ioctls which can be used to talk to the driver once the new /dev/cxl/afu0.0 device is opened. This device can also be read and mmaped.
There's also sysfs entries used to communicate information about the cxl configuration to userspace. These are documented in Documentation/ABI/testing/sysfs-class-cxl.
Many contributed to this device driver but Ian Munsie is the principal author.
Driver can also be found here (based on 3.17-rc5):
git://github.com/mikey/linux.git cxl
https://github.com/mikey/linux/commits/cxl
(Series rebases on recent linux-next with one trivial include file conflict)
Please consider for inclusion. Feedback welcome!
Regards,
Mikey
PATCH v3 1/16 powerpc/cell: Move spu_handle_mm_fault() out of cell platform
From: Ian Munsie <[email protected]>
Currently spu_handle_mm_fault() is in the cell platform.
This code is generically useful for other non-cell co-processors on powerpc.
This patch moves this function out of the cell platform into arch/powerpc/mm so that others may use it.
---
arch/powerpc/Kconfig | 4 ++++
arch/powerpc/include/asm/copro.h | 18 ++++++++++++++++++
arch/powerpc/include/asm/spu.h | 5 ++---
arch/powerpc/mm/Makefile | 1 +
.../{platforms/cell/spu_fault.c => mm/copro_fault.c} | 14 ++++++--------
arch/powerpc/platforms/cell/Kconfig | 1 +
arch/powerpc/platforms/cell/Makefile | 2 +-
arch/powerpc/platforms/cell/spufs/fault.c | 4 ++--
8 files changed, 35 insertions(+), 14 deletions(-)
create mode 100644 arch/powerpc/include/asm/copro.h
rename arch/powerpc/{platforms/cell/spu_fault.c => mm/copro_fault.c} (89%)arch/powerpc/Kconfig +4 -0
@@ -603,6 +603,10 @@ config PPC_SUBPAGE_PROT to set access permissions (read/write, readonly, or no access) on the 4k subpages of each 64k page. +config PPC_COPRO_BASE + bool + default n + config SCHED_SMT bool "SMT (Hyperthreading) scheduler support" depends on PPC64 && SMP
arch/powerpc/include/asm/copro.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright 2014 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifndef _ASM_POWERPC_COPRO_H +#define _ASM_POWERPC_COPRO_H + +int copro_handle_mm_fault (struct mm_struct *mm,unsigned long ea, +unsigned long dsisr,unsigned *flt); + +int copro_data_segment (struct mm_struct *mm,u64 ea,u64 *esid,u64 *vsid); + +#endif /* _ASM_POWERPC_COPRO_H */
arch/powerpc/include/asm/spu.h +2 -3
@@ -27,6 +27,8 @@#include <linux/workqueue.h> #include <linux/device.h> #include <linux/mutex.h> +#include <asm/reg.h> +#include <asm/copro.h> #define LS_SIZE (256 * 1024)#define LS_ADDR_MASK (LS_SIZE - 1)
@@ -277,9 +279,6 @@ void spu_remove_dev_attr(struct device_attribute *attr);int spu_add_dev_attr_group (struct attribute_group *attrs);void spu_remove_dev_attr_group (struct attribute_group *attrs); -int spu_handle_mm_fault (struct mm_struct *mm,unsigned long ea, -unsigned long dsisr,unsigned *flt); -/* * Notifier blocks: *
arch/powerpc/mm/Makefile +1 -0
@@ -34,3 +34,4 @@ obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hugepage-hash64.o obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage-prot.o obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o obj-$(CONFIG_HIGHMEM) += highmem.o +obj-$(CONFIG_PPC_COPRO_BASE) += copro_fault.o
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/platforms/cell/spu_fault.c +6 -8
@@ -1,5 +1,5 @@/* -* SPU mm fault handler +* CoProcessor (SPU/AFU) mm fault handler * * (C) Copyright IBM Deutschland Entwicklung GmbH 2007 *
@@ -23,16 +23,14 @@#include <linux/sched.h> #include <linux/mm.h> #include <linux/export.h> - -#include <asm/spu.h> -#include <asm/spu_csa.h> +#include <asm/reg.h> /* * This ought to be kept in sync with the powerpc specific do_page_fault * function. Currently, there are a few corner cases that we haven't had * to handle fortunately. */ -int spu_handle_mm_fault (struct mm_struct *mm,unsigned long ea, +int copro_handle_mm_fault (struct mm_struct *mm,unsigned long ea,unsigned long dsisr,unsigned *flt) {struct vm_area_struct *vma;
@@ -58,12 +56,12 @@ int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea, goto out_unlock; } - is_write = dsisr &MFC_DSISR_ACCESS_PUT ; + is_write = dsisr &DSISR_ISSTORE ;if (is_write) {if (!(vma->vm_flags &VM_WRITE )) goto out_unlock; }else { -if (dsisr &MFC_DSISR_ACCESS_DENIED ) +if (dsisr &DSISR_PROTFAULT ) goto out_unlock;if (!(vma->vm_flags & (VM_READ |VM_EXEC ))) goto out_unlock;
@@ -91,4 +89,4 @@ out_unlock:up_read (&mm->mmap_sem);return ret; } -EXPORT_SYMBOL_GPL (spu_handle_mm_fault); +EXPORT_SYMBOL_GPL (copro_handle_mm_fault);
arch/powerpc/platforms/cell/Kconfig +1 -0
@@ -86,6 +86,7 @@ config SPU_FS_64K_LS config SPU_BASE bool default n + select PPC_COPRO_BASE config CBE_RAS bool "RAS features for bare metal Cell BE"
arch/powerpc/platforms/cell/Makefile +1 -1
@@ -20,7 +20,7 @@ spu-manage-$(CONFIG_PPC_CELL_COMMON) += spu_manage.o obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \ spu_notify.o \ - spu_syscalls.o spu_fault.o \ + spu_syscalls.o \ $(spu-priv1-y) \ $(spu-manage-y) \ spufs/
arch/powerpc/platforms/cell/spufs/fault.c +2 -2
@@ -138,7 +138,7 @@ int spufs_handle_class1(struct spu_context *ctx)if (ctx->state ==SPU_STATE_RUNNABLE ) ctx->spu->stats.hash_flt++; -/* we must not hold the lock when entering spu_handle_mm_fault */ +/* we must not hold the lock when entering copro_handle_mm_fault */ spu_release (ctx); access = (_PAGE_PRESENT | _PAGE_USER);
@@ -149,7 +149,7 @@ int spufs_handle_class1(struct spu_context *ctx)/* hashing failed, so try the actual fault handler */ if (ret) - ret =spu_handle_mm_fault (current->mm, ea, dsisr, &flt); + ret =copro_handle_mm_fault (current->mm, ea, dsisr, &flt);/* * This is nasty: we need the state_mutex for all the bookkeeping even
Signature · 1 line
1.9.1
Re: [PATCH v3 01/16] powerpc/cell: Move spu_handle_mm_fault() out of cell platform
Hi Mikey,
Quoted 13 lines · On Tue, 7 Oct 2014 21:48:07 +1100 Michael Neuling <[email protected]> wrote:
arch/powerpc/include/asm/copro.h new file +6
-0@@ -0,0 +1,18 @@ +/* +* Copyright 2014 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
arch/powerpc/include/asm/copro.h line 16
Quoted 10 lines
arch/powerpc/include/asm/copro.h new file +10
-0+* 2 of the License, or (at your option) any later version. +*/ + +#ifndef _ASM_POWERPC_COPRO_H +#define _ASM_POWERPC_COPRO_H + +int copro_handle_mm_fault (struct mm_struct *mm,unsigned long ea, +unsigned long dsisr,unsigned *flt); + +int copro_data_segment (struct mm_struct *mm,u64 ea,u64 *esid,u64 *vsid);
This function is otherwise not included in this patch, so it should probably be removed (as the next patch removes it anyway).
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
Re: [PATCH v3 01/16] powerpc/cell: Move spu_handle_mm_fault() out of cell platform
Quoted 2 lines
Quoted 2 lines
+int copro_data_segment(struct
mm_struct*mm, u64 ea, u64 *esid, u64 *v=
sid);
Quoted 3 lines
=20
This function is otherwise not included in this patch, so it should probably be removed (as the next patch removes it anyway).
Yeah, looks like I screwed it up slightly in the packing of these patches.
Thanks.
Mikey
PATCH v3 2/16 powerpc/cell: Move data segment faulting code out of cell platform
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
__spu_trap_data_seg() currently contains code to determine the VSID and ESID required for a particular EA and mm struct.
This code is generically useful for other co-processors. This moves the code of the cell platform so it can be used by other powerpc code. It also adds 1TB segment handling which Cell didn't have.
This also moves the internal struct spu_slb to a generic struct copro_slb which is now used in the spu and copro code. We use this new struct instead of the us passing around esid and vsid parameters.
--- arch/powerpc/include/asm/copro.h | 7 ++++- arch/powerpc/include/asm/mmu-hash64.h | 7 ++++- arch/powerpc/mm/copro_fault.c | 46 ++++++++++++++++++++++++++++ arch/powerpc/mm/slb.c | 3 -- arch/powerpc/platforms/cell/spu_base.c | 55 ++++++---------------------------- 5 files changed, 67 insertions(+), 51 deletions(-)
arch/powerpc/include/asm/copro.h +6 -1
@@ -10,9 +10,14 @@#ifndef _ASM_POWERPC_COPRO_H#define _ASM_POWERPC_COPRO_H +struct copro_slb +{ +u64 esid, vsid; +}; +int copro_handle_mm_fault (struct mm_struct *mm,unsigned long ea,unsigned long dsisr,unsigned *flt); -int copro_data_segment (struct mm_struct *mm,u64 ea,u64 *esid,u64 *vsid); +int copro_calc_slb (struct mm_struct *mm,u64 ea,struct copro_slb *slb);#endif /* _ASM_POWERPC_COPRO_H */
arch/powerpc/include/asm/mmu-hash64.h +6 -1
@@ -189,7 +189,12 @@ static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize)#define LP_MASK (i) ((0xFF >> (i)) << LP_SHIFT)#ifndef __ASSEMBLY__ - +static inline int slb_vsid_shift (int ssize) +{ +if (ssize ==MMU_SEGSIZE_256M ) +return SLB_VSID_SHIFT ; +return SLB_VSID_SHIFT_1T ; +}static inline int segment_shift (int ssize) {if (ssize ==MMU_SEGSIZE_256M )
arch/powerpc/mm/copro_fault.c +46 -0
55 lines not on this page · raw message
arch/powerpc/mm/slb.c +0 -3
@@ -46,9 +46,6 @@ static inline unsigned long mk_esid_data(unsigned long ea, int ssize,return (ea &slb_esid_mask (ssize)) |SLB_ESID_V | slot; } -#define slb_vsid_shift (ssize) \ - ((ssize) == MMU_SEGSIZE_256M? SLB_VSID_SHIFT: SLB_VSID_SHIFT_1T) -static inline unsigned long mk_vsid_data (unsigned long ea,int ssize,unsigned long flags) {
arch/powerpc/platforms/cell/spu_base.c +9 -46
92 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 3/16 powerpc/cell: Make spu_flush_all_slbs() generic
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This moves spu_flush_all_slbs() into a generic call copro_flush_all_slbs().
This will be useful when we add cxl which also needs a similar SLB flush call.
--- arch/powerpc/include/asm/copro.h | 6 ++++++ arch/powerpc/mm/copro_fault.c | 9 +++++++++ arch/powerpc/mm/hash_utils_64.c | 10 +++------- arch/powerpc/mm/slice.c | 10 +++------- 4 files changed, 21 insertions(+), 14 deletions(-)
arch/powerpc/include/asm/copro.h +6 -0
@@ -20,4 +20,10 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,int copro_calc_slb (struct mm_struct *mm,u64 ea,struct copro_slb *slb); + +#ifdef CONFIG_PPC_COPRO_BASE +void copro_flush_all_slbs (struct mm_struct *mm); +#else +static inline void copro_flush_all_slbs (struct mm_struct *mm) {} +#endif #endif /* _ASM_POWERPC_COPRO_H */
arch/powerpc/mm/copro_fault.c +9 -0
@@ -25,6 +25,7 @@#include <linux/export.h> #include <asm/reg.h> #include <asm/copro.h> +#include <asm/spu.h> /* * This ought to be kept in sync with the powerpc specific do_page_fault
@@ -136,3 +137,11 @@ int copro_calc_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)return 0 ; }EXPORT_SYMBOL_GPL (copro_calc_slb); + +void copro_flush_all_slbs (struct mm_struct *mm) +{ +#ifdef CONFIG_SPU_BASE +spu_flush_all_slbs (mm); +#endif +} +EXPORT_SYMBOL_GPL (copro_flush_all_slbs);
arch/powerpc/mm/hash_utils_64.c +3 -7
@@ -51,7 +51,7 @@#include <asm/cacheflush.h> #include <asm/cputable.h> #include <asm/sections.h> -#include <asm/spu.h> +#include <asm/copro.h> #include <asm/udbg.h> #include <asm/code-patching.h> #include <asm/fadump.h>
@@ -901,9 +901,7 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr)if (get_slice_psize (mm, addr) ==MMU_PAGE_4K )return ;slice_set_range_psize (mm, addr,1 ,MMU_PAGE_4K ); -#ifdef CONFIG_SPU_BASE -spu_flush_all_slbs (mm); -#endif +copro_flush_all_slbs (mm);if (get_paca_psize (addr) !=MMU_PAGE_4K ) {get_paca ()->context = mm->context;slb_flush_and_rebolt ();
@@ -1141,9 +1139,7 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)"to 4kB pages because of " "non-cacheable mapping\n"); psize = mmu_vmalloc_psize =MMU_PAGE_4K ; -#ifdef CONFIG_SPU_BASE -spu_flush_all_slbs (mm); -#endif +copro_flush_all_slbs (mm); } }
arch/powerpc/mm/slice.c +3 -7
@@ -32,7 +32,7 @@#include <linux/export.h> #include <asm/mman.h> #include <asm/mmu.h> -#include <asm/spu.h> +#include <asm/copro.h> /* some sanity checks */ #if (PGTABLE_RANGE >>43 ) >SLICE_MASK_SIZE
@@ -232,9 +232,7 @@ static void slice_convert(struct mm_struct *mm, struct slice_mask mask, int psizspin_unlock_irqrestore (&slice_convert_lock, flags); -#ifdef CONFIG_SPU_BASE -spu_flush_all_slbs (mm); -#endif +copro_flush_all_slbs (mm); }/*
@@ -671,9 +669,7 @@ void slice_set_psize(struct mm_struct *mm, unsigned long address,spin_unlock_irqrestore (&slice_convert_lock, flags); -#ifdef CONFIG_SPU_BASE -spu_flush_all_slbs (mm); -#endif +copro_flush_all_slbs (mm); } void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
Signature · 1 line
1.9.1
PATCH v3 4/16 powerpc/msi: Improve IRQ bitmap allocator
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
Currently msi_bitmap_alloc_hwirqs() will round up any IRQ allocation requests to the nearest power of 2. eg. ask for 5 IRQs and you'll get 8. This wastes a lot of IRQs which can be a scarce resource.
For cxl we may require multiple IRQs for every context that is attached to the accelerator. There may be 1000s of contexts attached, hence we can easily run out of IRQs, especially if we are needlessly wasting them.
This changes the msi_bitmap_alloc_hwirqs() to allocate only the required number of IRQs, hence avoiding this wastage. It keeps the natural alignment requirement though.
--- arch/powerpc/sysdev/msi_bitmap.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-)
arch/powerpc/sysdev/msi_bitmap.c +22 -11
@@ -20,32 +20,37 @@ int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp, int num)int offset, order =get_count_order (num);spin_lock_irqsave (&bmp->lock, flags); -/* -* This is fast, but stricter than we need. We might want to add -* a fallback routine which does a linear search with no alignment. -*/ - offset =bitmap_find_free_region (bmp->bitmap, bmp->irq_count, order); + + offset =bitmap_find_next_zero_area (bmp->bitmap, bmp->irq_count,0 , + num, (1 << order) -1 ); +if (offset > bmp->irq_count) + goto err; + +bitmap_set (bmp->bitmap, offset, num);spin_unlock_irqrestore (&bmp->lock, flags); -pr_debug ("msi_bitmap: allocated 0x%x (2^%d) at offset 0x%x\n" , - num, order, offset); +pr_debug ("msi_bitmap: allocated 0x%x at offset 0x%x\n" , num, offset);return offset; +err: +spin_unlock_irqrestore (&bmp->lock, flags); +return -ENOMEM ; } +EXPORT_SYMBOL (msi_bitmap_alloc_hwirqs);void msi_bitmap_free_hwirqs (struct msi_bitmap *bmp,unsigned int offset,unsigned int num) {unsigned long flags; -int order =get_count_order (num); -pr_debug ("msi_bitmap: freeing 0x%x (2^%d) at offset 0x%x\n" , - num, order, offset); +pr_debug ("msi_bitmap: freeing 0x%x at offset 0x%x\n" , + num, offset);spin_lock_irqsave (&bmp->lock, flags); -bitmap_release_region (bmp->bitmap, offset, order); +bitmap_clear (bmp->bitmap, offset, num);spin_unlock_irqrestore (&bmp->lock, flags); } +EXPORT_SYMBOL (msi_bitmap_free_hwirqs);void msi_bitmap_reserve_hwirq (struct msi_bitmap *bmp,unsigned int hwirq) {
@@ -180,6 +185,12 @@ void __init test_basics(void)msi_bitmap_free_hwirqs (&bmp, size /2 ,1 );check (msi_bitmap_alloc_hwirqs (&bmp,1 ) == size /2 ); +/* Check we get a naturally aligned offset */ +check (msi_bitmap_alloc_hwirqs (&bmp,2 ) %2 ==0 ); +check (msi_bitmap_alloc_hwirqs (&bmp,4 ) %4 ==0 ); +check (msi_bitmap_alloc_hwirqs (&bmp,8 ) %8 ==0 ); +check (msi_bitmap_alloc_hwirqs (&bmp,9 ) %16 ==0 ); +msi_bitmap_free (&bmp);/* Clients may check bitmap == NULL for "not-allocated" */
Signature · 1 line
1.9.1
PATCH v3 5/16 powerpc/mm: Export mmu_kernel_ssize and mmu_linear_psize
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
Export mmu_kernel_ssize and mmu_linear_psize. These are needed by the cxl driver which has it's own MMU. To setup the MMU cxl need access to these.
--- arch/powerpc/mm/hash_utils_64.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/mm/hash_utils_64.c +2 -0
@@ -98,6 +98,7 @@ unsigned long htab_size_bytes;unsigned long htab_hash_mask;EXPORT_SYMBOL_GPL (htab_hash_mask);int mmu_linear_psize =MMU_PAGE_4K ; +EXPORT_SYMBOL_GPL (mmu_linear_psize);int mmu_virtual_psize =MMU_PAGE_4K ;int mmu_vmalloc_psize =MMU_PAGE_4K ;#ifdef CONFIG_SPARSEMEM_VMEMMAP
@@ -105,6 +106,7 @@ int mmu_vmemmap_psize = MMU_PAGE_4K;#endif int mmu_io_psize =MMU_PAGE_4K ;int mmu_kernel_ssize =MMU_SEGSIZE_256M ; +EXPORT_SYMBOL_GPL (mmu_kernel_ssize);int mmu_highuser_ssize =MMU_SEGSIZE_256M ;u16 mmu_slb_size =64 ;EXPORT_SYMBOL_GPL (mmu_slb_size);
Signature · 1 line
1.9.1
PATCH v3 6/16 powerpc/powernv: Split out set MSI IRQ chip code
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
Some of the MSI IRQ code in pnv_pci_ioda_msi_setup() is generically useful so split it out.
This will be used by some of the cxl PCIe code later.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 42 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 18 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +24 -18
@@ -1306,14 +1306,35 @@ static void pnv_ioda2_msi_eoi(struct irq_data *d)icp_native_eoi (d); } + +static void set_msi_irq_chip (struct pnv_phb *phb,unsigned int virq) +{ +struct irq_data *idata; +struct irq_chip *ichip; + +if (phb->type !=PNV_PHB_IODA2 ) +return ; + +if (!phb->ioda.irq_chip_init) { +/* +* First time we setup an MSI IRQ, we need to setup the +* corresponding IRQ chip to route correctly. +*/ + idata =irq_get_irq_data (virq); + ichip =irq_data_get_irq_chip (idata); + phb->ioda.irq_chip_init =1 ; + phb->ioda.irq_chip = *ichip; + phb->ioda.irq_chip.irq_eoi = pnv_ioda2_msi_eoi; + } +irq_set_chip (virq, &phb->ioda.irq_chip); +} +static int pnv_pci_ioda_msi_setup (struct pnv_phb *phb,struct pci_dev *dev,unsigned int hwirq,unsigned int virq,unsigned int is_64,struct msi_msg *msg) {struct pnv_ioda_pe *pe =pnv_ioda_get_pe (dev);struct pci_dn *pdn =pci_get_pdn (dev); -struct irq_data *idata; -struct irq_chip *ichip;unsigned int xive_num = hwirq - phb->msi_base;__be32 data;int rc;
@@ -1365,22 +1386,7 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev, } msg->data =be32_to_cpu (data); -/* -* Change the IRQ chip for the MSI interrupts on PHB3. -* The corresponding IRQ chip should be populated for -* the first time. -*/ -if (phb->type ==PNV_PHB_IODA2 ) { -if (!phb->ioda.irq_chip_init) { - idata =irq_get_irq_data (virq); - ichip =irq_data_get_irq_chip (idata); - phb->ioda.irq_chip_init =1 ; - phb->ioda.irq_chip = *ichip; - phb->ioda.irq_chip.irq_eoi = pnv_ioda2_msi_eoi; - } - -irq_set_chip (virq, &phb->ioda.irq_chip); - } +set_msi_irq_chip (phb, virq); pr_devel("%s: %s-bit MSI on hwirq %x (xive #%d)," " address=%x_%08x data=%x PE# %d\n",
Signature · 1 line
1.9.1
PATCH v3 7/16 cxl: Add new header for call backs and structs
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This new header adds callbacks and structs needed by the rest of the kernel to hook into the cxl infrastructure.
cxl_ctx_get/put/in_use are static inlined here as they are called in tlbie which we want to be fast (mpe's suggestion).
Empty functions are provided when CONFIG_CXL_BASE is not enabled.
--- include/misc/cxl.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/misc/cxl.h
include/misc/cxl.h new file +48 -0
@@ -0,0 +1,48 @@ +/* +* Copyright 2014 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifndef _MISC_CXL_H +#define _MISC_CXL_H + +#define CXL_IRQ_RANGES 4 + +struct cxl_irq_ranges { +irq_hw_number_t offset[CXL_IRQ_RANGES ]; +irq_hw_number_t range[CXL_IRQ_RANGES ]; +}; + +#ifdef CONFIG_CXL_BASE + +extern atomic_t cxl_use_count; + +static inline bool cxl_ctx_in_use (void ) +{ +return (atomic_read (&cxl_use_count) !=0 ); +} + +static inline void cxl_ctx_get (void ) +{ +atomic_inc (&cxl_use_count); +} + +static inline void cxl_ctx_put (void ) +{ +atomic_dec (&cxl_use_count); +} + +void cxl_slbia (struct mm_struct *mm); + +#else /* CONFIG_CXL_BASE */ + +static inline bool cxl_ctx_in_use (void ) {return false; } +static inline void cxl_slbia (struct mm_struct *mm) {} + +#endif /* CONFIG_CXL_BASE */ + +#endif
Signature · 1 line
1.9.1
PATCH v3 8/16 powerpc/powerpc: Add new PCIe functions for allocating cxl interrupts
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This adds a number of functions for allocating IRQs under powernv PCIe for cxl.
--- arch/powerpc/include/asm/pnv-pci.h | 27 ++++++ arch/powerpc/platforms/powernv/pci-ioda.c | 153 ++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 arch/powerpc/include/asm/pnv-pci.h
arch/powerpc/include/asm/pnv-pci.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright 2014 IBM Corp. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version +* 2 of the License, or (at your option) any later version. +*/ + +#ifndef _ASM_PNV_PCI_H +#define _ASM_PNV_PCI_H + +#include <linux/pci.h> +#include <misc/cxl.h> + +int pnv_phb_to_cxl (struct pci_dev *dev); +int pnv_cxl_ioda_msi_setup (struct pci_dev *dev,unsigned int hwirq, +unsigned int virq); +int pnv_cxl_alloc_hwirqs (struct pci_dev *dev,int num); +void pnv_cxl_release_hwirqs (struct pci_dev *dev,int hwirq,int num); +int pnv_cxl_alloc_hwirq_ranges (struct cxl_irq_ranges *irqs, +struct pci_dev *dev,int num); +void pnv_cxl_release_hwirq_ranges (struct cxl_irq_ranges *irqs, +struct pci_dev *dev); +int pnv_cxl_get_irq_count (struct pci_dev *dev); + +#endif
arch/powerpc/platforms/powernv/pci-ioda.c +153 -0
165 lines not on this page · raw message
Signature · 1 line
1.9.1
Michael Ellerman
reviewerRe: [v3, 08/16] powerpc/powerpc: Add new PCIe functions for allocating cxl interrupts
arch/powerpc/platforms/powernv/pci-ioda.c line 41
Quoted 13 lines · Michael Neuling
From: Ian Munsie <[email protected]>
This adds a number of functions for allocating IRQs under powernv PCIe for cxl.
arch/powerpc/platforms/powernv/pci-ioda.c +1
-0@@ -38,6 +38,8 @@#include <asm/debug.h> #include <asm/firmware.h> +#include <misc/cxl.h>
You should be including pnv-pci.h here.
Otherwise the header and the implementation could get out of sync, it will also fix these:
arch/powerpc/platforms/powernv/pci-ioda.c:1365:5: warning: symbol 'pnv_phb_to_cxl' was not declared. Should it be static? arch/powerpc/platforms/powernv/pci-ioda.c:1389:5: warning: symbol 'pnv_cxl_alloc_hwirqs' was not declared. Should it be static? arch/powerpc/platforms/powernv/pci-ioda.c:1404:6: warning: symbol 'pnv_cxl_release_hwirqs' was not declared. Should it be static? arch/powerpc/platforms/powernv/pci-ioda.c:1413:6: warning: symbol 'pnv_cxl_release_hwirq_ranges' was not declared. Should it be static? arch/powerpc/platforms/powernv/pci-ioda.c:1433:5: warning: symbol 'pnv_cxl_alloc_hwirq_ranges' was not declared. Should it be static? arch/powerpc/platforms/powernv/pci-ioda.c:1470:5: warning: symbol 'pnv_cxl_get_irq_count' was not declared. Should it be static? arch/powerpc/platforms/powernv/pci-ioda.c:1479:5: warning: symbol 'pnv_cxl_ioda_msi_setup' was not declared. Should it be static?
cheers
Re: [v3, 08/16] powerpc/powerpc: Add new PCIe functions for allocating cxl interrupts
Quoted 4 lines · Michael Ellerman
Quoted 3 lines · Michael Neuling
From: Ian Munsie <[email protected]>
=20
This adds a number of functions for allocating IRQs under powernv PCIe =
for cxl.
Quoted 2 lines
arch/powerpc/p=
Quoted 2 lines
=20
arch/powerpc/p= renamed from arch/powerpc/platforms/powernv/pci-ioda.c +0
-0
latforms/powernv/pci-ioda.c
Quoted 4 lines
Quoted 4 lines
index baf3de6..3b67010b 100644
arch/powerpc/platforms/powernv/pci-ioda.c +0
-0@@ -38,6 +38,8 @@
Quoted 8 lines
Quoted 4 lines
arch/powerpc/platforms/powernv/pci-ioda.c +0
-0#include <asm/debug.h> #include <asm/firmware.h> =20
+#include <misc/cxl.h>=20
You should be includingpnv-pci.hhere.
=20
Otherwise the header and the implementation could get out of sync, it wil=
l also
Quoted 3 lines
fix these:
=20
arch/powerpc/platforms/powernv/pci-ioda.c:1365:5: warning: symbol 'pnv_=
phb_to_cxl' was not declared. Should it be static?
Quoted 1 line
arch/powerpc/platforms/powernv/pci-ioda.c:1389:5: warning: symbol 'pnv_=
cxl_alloc_hwirqs' was not declared. Should it be static?
Quoted 1 line
arch/powerpc/platforms/powernv/pci-ioda.c:1404:6: warning: symbol 'pnv_=
cxl_release_hwirqs' was not declared. Should it be static?
Quoted 1 line
arch/powerpc/platforms/powernv/pci-ioda.c:1413:6: warning: symbol 'pnv_=
cxl_release_hwirq_ranges' was not declared. Should it be static?
Quoted 1 line
arch/powerpc/platforms/powernv/pci-ioda.c:1433:5: warning: symbol 'pnv_=
cxl_alloc_hwirq_ranges' was not declared. Should it be static?
Quoted 1 line
arch/powerpc/platforms/powernv/pci-ioda.c:1470:5: warning: symbol 'pnv_=
cxl_get_irq_count' was not declared. Should it be static?
Quoted 1 line
arch/powerpc/platforms/powernv/pci-ioda.c:1479:5: warning: symbol 'pnv_=
cxl_ioda_msi_setup' was not declared. Should it be static?
Ok... will fix.
Mikey
PATCH v3 9/16 powerpc/mm: Add new hash_page_mm()
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This adds a new function hash_page_mm() based on the existing hash_page(). This version allows any struct mm to be passed in, rather than assuming current. This is useful for servicing co-processor faults which are not in the context of the current running process.
We need to be careful here as the current hash_page() assumes current in a few places.
--- arch/powerpc/include/asm/mmu-hash64.h | 1 + arch/powerpc/mm/hash_utils_64.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/mmu-hash64.h +1 -0
@@ -322,6 +322,7 @@ extern int __hash_page_64K(unsigned long ea, unsigned long access, unsigned int local, int ssize);struct mm_struct ;unsigned int hash_page_do_lazy_icache (unsigned int pp,pte_t pte,int trap); +extern int hash_page_mm (struct mm_struct *mm,unsigned long ea,unsigned long access,unsigned long trap);extern int hash_page (unsigned long ea,unsigned long access,unsigned long trap); int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, pte_t *ptep, unsigned long trap, int local, int ssize,
arch/powerpc/mm/hash_utils_64.c +17 -7
@@ -904,7 +904,7 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr)return ;slice_set_range_psize (mm, addr,1 ,MMU_PAGE_4K );copro_flush_all_slbs (mm); -if (get_paca_psize (addr) !=MMU_PAGE_4K ) { +if ((get_paca_psize (addr) !=MMU_PAGE_4K ) && (current->mm == mm)) {get_paca ()->context = mm->context;slb_flush_and_rebolt (); }
@@ -989,12 +989,11 @@ static void check_paca_psize(unsigned long ea, struct mm_struct *mm,* -1 - critical hash insertion error * -2 - access not permitted by subpage protection mechanism */ -int hash_page (unsigned long ea,unsigned long access,unsigned long trap) +int hash_page_mm (struct mm_struct *mm,unsigned long ea,unsigned long access,unsigned long trap) {enum ctx_state prev_state =exception_enter ();pgd_t *pgdir;unsigned long vsid; -struct mm_struct *mm;pte_t *ptep;unsigned hugeshift;const struct cpumask *tmp;
@@ -1008,7 +1007,6 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)switch (REGION_ID (ea)) {case USER_REGION_ID : user_region =1 ; - mm = current->mm;if (! mm) {DBG_LOW (" user region with no mm !\n" ); rc =1 ;
@@ -1019,7 +1017,6 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap) vsid =get_vsid (mm->context.id, ea, ssize);break ;case VMALLOC_REGION_ID : - mm = &init_mm; vsid =get_kernel_vsid (ea, mmu_kernel_ssize);if (ea <VMALLOC_END ) psize = mmu_vmalloc_psize;
@@ -1104,7 +1101,8 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap) WARN_ON(1); }#endif -check_paca_psize (ea, mm, psize, user_region); +if (current->mm == mm) +check_paca_psize (ea, mm, psize, user_region); goto bail; }
@@ -1145,7 +1143,8 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap) } } -check_paca_psize (ea, mm, psize, user_region); +if (current->mm == mm) +check_paca_psize (ea, mm, psize, user_region);#endif /* CONFIG_PPC_64K_PAGES */ #ifdef CONFIG_PPC_HAS_HASH_64K
@@ -1180,6 +1179,17 @@ bail:exception_exit (prev_state);return rc; } +EXPORT_SYMBOL_GPL (hash_page_mm); + +int hash_page (unsigned long ea,unsigned long access,unsigned long trap) +{ +struct mm_struct *mm = current->mm; + +if (REGION_ID (ea) ==VMALLOC_REGION_ID ) + mm = &init_mm; + +return hash_page_mm (mm, ea, access, trap); +}EXPORT_SYMBOL_GPL (hash_page); void hash_preload(struct mm_struct *mm, unsigned long ea,
Signature · 1 line
1.9.1
PATCH v3 10/16 powerpc/opal: Add PHB to cxl mode call
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This adds the OPAL call to change a PHB into cxl mode.
--- arch/powerpc/include/asm/opal.h | 2 ++ arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + 2 files changed, 3 insertions(+)
arch/powerpc/include/asm/opal.h +2 -0
@@ -146,6 +146,7 @@ struct opal_sg_list {#define OPAL_GET_PARAM 89#define OPAL_SET_PARAM 90#define OPAL_DUMP_RESEND 91 +#define OPAL_PCI_SET_PHB_CXL_MODE 93#define OPAL_DUMP_INFO2 94#define OPAL_PCI_EEH_FREEZE_SET 97#define OPAL_HANDLE_HMI 98
@@ -924,6 +925,7 @@ int64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data);int64_t opal_handle_hmi (void );int64_t opal_register_dump_region (uint32_t id,uint64_t start,uint64_t end);int64_t opal_unregister_dump_region (uint32_t id); +int64_t opal_pci_set_phb_cxl_mode (uint64_t phb_id,uint64_t mode,uint64_t pe_number);/* Internal functions */ extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
arch/powerpc/platforms/powernv/opal-wrappers.S +1 -0
@@ -247,3 +247,4 @@ OPAL_CALL(opal_set_param, OPAL_SET_PARAM); OPAL_CALL(opal_handle_hmi, OPAL_HANDLE_HMI); OPAL_CALL(opal_register_dump_region, OPAL_REGISTER_DUMP_REGION); OPAL_CALL(opal_unregister_dump_region, OPAL_UNREGISTER_DUMP_REGION); +OPAL_CALL(opal_pci_set_phb_cxl_mode, OPAL_PCI_SET_PHB_CXL_MODE);
Signature · 1 line
1.9.1
PATCH v3 11/16 powerpc/mm: Add hooks for cxl
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This add a hook into tlbie() so that we use global invalidations when there are cxl contexts active.
Normally cxl snoops broadcast tlbie. cxl can have TLB entries invalidated via MMIO, but we aren't doing that yet. So for now we are just disabling local tlbies when cxl contexts are active. In future we can make tlbie() local mode smarter so that it invalidates cxl contexts explicitly when it needs to.
This also adds a hooks for when SLBs are invalidated to ensure any corresponding SLBs in cxl are also invalidated at the same time.
--- arch/powerpc/mm/copro_fault.c | 2 ++ arch/powerpc/mm/hash_native_64.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/mm/copro_fault.c +2 -0
@@ -26,6 +26,7 @@#include <asm/reg.h> #include <asm/copro.h> #include <asm/spu.h> +#include <misc/cxl.h> /* * This ought to be kept in sync with the powerpc specific do_page_fault
@@ -143,5 +144,6 @@ void copro_flush_all_slbs(struct mm_struct *mm)#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm); }EXPORT_SYMBOL_GPL (copro_flush_all_slbs);
arch/powerpc/mm/hash_native_64.c +5 -1
@@ -29,6 +29,8 @@#include <asm/kexec.h> #include <asm/ppc-opcode.h> +#include <misc/cxl.h> +#ifdef DEBUG_LOW #define DBG_LOW(fmt...) udbg_printf(fmt)#else
@@ -149,9 +151,11 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)static inline void tlbie (unsigned long vpn,int psize,int apsize,int ssize,int local) { -unsigned int use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL ); +unsigned int use_local;int lock_tlbie = !mmu_has_feature (MMU_FTR_LOCKLESS_TLBIE ); + use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL ) && !cxl_ctx_in_use (); +if (use_local) use_local = mmu_psize_defs[psize].tlbiel;if (lock_tlbie && !use_local)
Signature · 1 line
1.9.1
PATCH v3 12/16 cxl: Add base builtin support
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This adds the base cxl support that needs to be build into the kernel to use cxl as a module. This is needed so that the cxl call backs from the core powerpc mm code always exist irrespective of if the cxl module is loaded or not. This is similar to how cell works with CONFIG_SPU_BASE.
This adds a cxl_slbia() call (similar to spu_flush_all_slbs()) which checks for the cxl module being loaded. If the modules is not loaded we return, otherwise we call into the cxl SLB invalidation code.
This also adds the cxl_ctx_in_use() function for use in the mm code to see if any cxl contexts are currently in use. This is used by the tlbie() to determine if it can do local TLB invalidations or not. This also adds get/put calls for the cxl driver module to refcount the active cxl contexts.
--- drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/cxl/Kconfig | 8 +++++ drivers/misc/cxl/Makefile | 1 + drivers/misc/cxl/base.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+) create mode 100644 drivers/misc/cxl/Kconfig create mode 100644 drivers/misc/cxl/Makefile create mode 100644 drivers/misc/cxl/base.c
drivers/misc/Kconfig +1 -0
@@ -527,4 +527,5 @@ source "drivers/misc/vmw_vmci/Kconfig" source "drivers/misc/mic/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" +source "drivers/misc/cxl/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -55,3 +55,4 @@ obj-y += mic/ obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o +obj-$(CONFIG_CXL_BASE) += cxl/
drivers/misc/cxl/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +# +# IBM Coherent Accelerator (CXL) compatible devices +# + +config CXL_BASE + bool + default n + select PPC_COPRO_BASE
drivers/misc/cxl/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_CXL_BASE) += base.o
drivers/misc/cxl/base.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
1.9.1
Michael Ellerman
reviewerRe: [v3,12/16] cxl: Add base builtin support
Quoted 7 lines · Michael Neuling
From: Ian Munsie <[email protected]>
This adds the base cxl support that needs to be build into the kernel to use cxl as a module. This is needed so that the cxl call backs from the core powerpc mm code always exist irrespective of if the cxl module is loaded or not. This is similar to how cell works with
CONFIG_SPU_BASE.
Quoted 8 lines
This adds a
cxl_slbia()call (similar tospu_flush_all_slbs()) which checks for the cxl module being loaded. If the modules is not loaded we return, otherwise we call into the cxl SLB invalidation code.This also adds the
cxl_ctx_in_use()function for use in the mm code to see if any cxl contexts are currently in use. This is used by thetlbie()to determine if it can do local TLB invalidations or not. This also adds get/put calls for the cxl driver module to refcount the active cxl contexts.
This last paragraph is no longer true.
cheers
Re: [v3,12/16] cxl: Add base builtin support
Quoted 4 lines · Michael Ellerman
Quoted 3 lines · Michael Neuling
From: Ian Munsie <[email protected]>
=20
This adds the base cxl support that needs to be build into the kernel t=
o use
Quoted 1 line
Quoted 1 line
cxl as a module. This is needed so that the cxl call backs from the cor=
e
Quoted 1 line
Quoted 1 line
powerpc mm code always exist irrespective of if the cxl module is loade=
d or
Quoted 3 lines
Quoted 3 lines
not. This is similar to how cell works with
CONFIG_SPU_BASE. =20
This adds acxl_slbia()call (similar tospu_flush_all_slbs()) which ch=
ecks for
Quoted 1 line
Quoted 1 line
the cxl module being loaded. If the modules is not loaded we return, ot=
herwise
Quoted 3 lines
Quoted 3 lines
we call into the cxl SLB invalidation code.
=20
This also adds thecxl_ctx_in_use()function for use in the mm code to =
see if
Quoted 2 lines
Quoted 2 lines
any cxl contexts are currently in use. This is used by the
tlbie()to determine if it can do local TLB invalidations or not. This also adds g=
et/put
Quoted 3 lines
Quoted 1 line
calls for the cxl driver module to refcount the active cxl contexts.
=20
This last paragraph is no longer true.
Yep, thanks. I'll move it to patch 7 where it does apply.
Mikey
PATCH v3 13/16 cxl: Driver code for powernv PCIe based cards for userspace access
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This is the core of the cxl driver.
It adds support for using cxl cards in the powernv environment only (ie POWER8 bare metal). It allows access to cxl accelerators by userspace using the /dev/cxl/afuM.N char devices.
The kernel driver has no knowledge of the function implemented by the accelerator. It provides services to userspace via the /dev/cxl/afuM.N devices. When a program opens this device and runs the start work IOCTL, the accelerator will have coherent access to that processes memory using the same virtual addresses. That process may mmap the device to access any MMIO space the accelerator provides. Also, reads on the device will allow interrupts to be received. These services are further documented in a later patch in Documentation/powerpc/cxl.txt.
Documentation of the cxl hardware architecture and userspace API is provided in subsequent patches.
--- drivers/misc/cxl/context.c | 173 ++++++++ drivers/misc/cxl/cxl.h | 622 ++++++++++++++++++++++++++++ drivers/misc/cxl/debugfs.c | 112 +++++ drivers/misc/cxl/fault.c | 299 ++++++++++++++ drivers/misc/cxl/file.c | 493 ++++++++++++++++++++++ drivers/misc/cxl/irq.c | 398 ++++++++++++++++++ drivers/misc/cxl/main.c | 234 +++++++++++ drivers/misc/cxl/native.c | 683 +++++++++++++++++++++++++++++++ drivers/misc/cxl/pci.c | 994 +++++++++++++++++++++++++++++++++++++++++++++ drivers/misc/cxl/sysfs.c | 360 ++++++++++++++++ 10 files changed, 4368 insertions(+) create mode 100644 drivers/misc/cxl/context.c create mode 100644 drivers/misc/cxl/cxl.h create mode 100644 drivers/misc/cxl/debugfs.c create mode 100644 drivers/misc/cxl/fault.c create mode 100644 drivers/misc/cxl/file.c create mode 100644 drivers/misc/cxl/irq.c create mode 100644 drivers/misc/cxl/main.c create mode 100644 drivers/misc/cxl/native.c create mode 100644 drivers/misc/cxl/pci.c create mode 100644 drivers/misc/cxl/sysfs.c
drivers/misc/cxl/context.c new file +173 -0
@@ -0,0 +1,173 @@ +/* +* Copyright 2014 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. +*/ + +#undef DEBUG + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/bitmap.h> +#include <linux/sched.h> +#include <linux/pid.h> +#include <linux/fs.h> +#include <linux/mm.h> +#include <linux/debugfs.h> +#include <linux/slab.h> +#include <linux/idr.h> +#include <asm/cputable.h> +#include <asm/current.h> +#include <asm/copro.h> + +#include "cxl.h" + +/* +* Allocates space for a CXL context. +*/ +struct cxl_context *cxl_context_alloc (void ) +{ +return kzalloc (sizeof (struct cxl_context ),GFP_KERNEL ); +} + +/* +* Initialises a CXL context. +*/ +int cxl_context_init (struct cxl_context *ctx,struct cxl_afu *afu,bool master) +{ +int i; + +spin_lock_init (&ctx->sst_lock); + ctx->sstp =NULL ; + ctx->afu = afu; + ctx->master = master; + ctx->pid =get_pid (get_task_pid (current,PIDTYPE_PID )); + +INIT_WORK (&ctx->fault_work, cxl_handle_fault); + +init_waitqueue_head (&ctx->wq); +spin_lock_init (&ctx->lock); + + ctx->irq_bitmap =NULL ; + ctx->pending_irq = false; + ctx->pending_fault = false; + ctx->pending_afu_err = false; + +mutex_init (&ctx->status_mutex); + +/* Don't need to lock just writing this */ + ctx->status =OPENED ; + +idr_preload (GFP_KERNEL ); +spin_lock (&afu->contexts_lock); + i =idr_alloc (&ctx->afu->contexts_idr, ctx,0 , + ctx->afu->num_procs,GFP_NOWAIT ); +spin_unlock (&afu->contexts_lock); +idr_preload_end (); +if (i <0 ) +return i; + + ctx->pe = i; + ctx->elem = &ctx->afu->spa[i]; + ctx->pe_inserted = false; +return 0 ; +} + +/* +* Map a per-context mmio space into the given vma. +*/ +int cxl_context_iomap (struct cxl_context *ctx,struct vm_area_struct *vma) +{ +u64 len = vma->vm_end - vma->vm_start; + len =min (len, ctx->psn_size); + +if (ctx->afu->current_model ==CXL_MODEL_DEDICATED ) { + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); +return vm_iomap_memory (vma, ctx->afu->psn_phys, ctx->afu->adapter->ps_size); + } + +/* make sure there is a valid per process space for this AFU */ +if ((ctx->master && !ctx->afu->psa) || (!ctx->afu->pp_psa)) { +pr_devel ("AFU doesn't support mmio space\n" ); +return -EINVAL ; + } + +/* Can't mmap until the AFU is enabled */ +if (!ctx->afu->enabled) +return -EBUSY ; + +pr_devel ("%s: mmio physical: %llx pe: %i master:%i\n" , __func__, + ctx->psn_phys, ctx->pe , ctx->master); + + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); +return vm_iomap_memory (vma, ctx->psn_phys, len); +} + +/* +* Detach a context from the hardware. This disables interrupts and doesn't +* return until all outstanding interrupts for this context have completed. The +* hardware should no longer access *ctx after this has returned. +*/ +static void __detach_context (struct cxl_context *ctx) +{ +unsigned long flags; +enum cxl_context_status status; + +mutex_lock (&ctx->status_mutex); + status = ctx->status; + ctx->status =CLOSED ; +mutex_unlock (&ctx->status_mutex); +if (status !=STARTED ) +return ; + +WARN_ON (cxl_detach_process (ctx)); +afu_release_irqs (ctx); +flush_work (&ctx->fault_work);/* Only needed for dedicated process */ +wake_up_all (&ctx->wq); +} + +/* +* Detach the given context from the AFU. This doesn't actually +* free the context but it should stop the context running in hardware +* (ie. prevent this context from generating any further interrupts +* so that it can be freed). +*/ +void cxl_context_detach (struct cxl_context *ctx) +{ +__detach_context (ctx); +} + +/* +* Detach all contexts on the given AFU. +*/ +void cxl_context_detach_all (struct cxl_afu *afu) +{ +struct cxl_context *ctx; +int tmp; + +rcu_read_lock (); +idr_for_each_entry (&afu->contexts_idr, ctx, tmp) +__detach_context (ctx); +rcu_read_unlock (); +} + +void cxl_context_free (struct cxl_context *ctx) +{ +unsigned long flags; + +spin_lock (&ctx->afu->contexts_lock); +idr_remove (&ctx->afu->contexts_idr, ctx->pe); +spin_unlock (&ctx->afu->contexts_lock); +synchronize_rcu (); + +spin_lock_irqsave (&ctx->sst_lock, flags); +free_page ((u64 )ctx->sstp); + ctx->sstp =NULL ; +spin_unlock_irqrestore (&ctx->sst_lock, flags); + +put_pid (ctx->pid); +kfree (ctx); +}
drivers/misc/cxl/cxl.h new file +622 -0
622 lines not on this page · raw message
drivers/misc/cxl/debugfs.c new file +112 -0
112 lines not on this page · raw message
drivers/misc/cxl/fault.c new file +299 -0
299 lines not on this page · raw message
drivers/misc/cxl/file.c new file +493 -0
493 lines not on this page · raw message
drivers/misc/cxl/irq.c new file +398 -0
398 lines not on this page · raw message
drivers/misc/cxl/main.c new file +234 -0
234 lines not on this page · raw message
drivers/misc/cxl/native.c new file +683 -0
669 lines not on this page · raw message
drivers/misc/cxl/pci.c new file +994 -0
994 lines not on this page · raw message
drivers/misc/cxl/sysfs.c new file +360 -0
360 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.9.1
Part of the diff is not shown here. View the raw message.
PATCH v3 14/16 cxl: Userspace header file.
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This defines structs and magic numbers required for userspace to interact with the kernel cxl driver via /dev/cxl/afu0.0.
It adds this header file Kbuild so it's exported when doing make headers_installs.
--- include/uapi/Kbuild | 1 + include/uapi/misc/Kbuild | 2 ++ include/uapi/misc/cxl.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 include/uapi/misc/Kbuild create mode 100644 include/uapi/misc/cxl.h
include/uapi/Kbuild +1 -0
@@ -12,3 +12,4 @@ header-y += video/ header-y += drm/ header-y += xen/ header-y += scsi/ +header-y += misc/
include/uapi/misc/Kbuild new file +2 -0
@@ -0,0 +1,2 @@ +# misc Header export list +header-y += cxl.h
include/uapi/misc/cxl.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 15/16 cxl: Add driver to Kbuild and Makefiles
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
--- drivers/misc/cxl/Kconfig | 10 ++++++++++ drivers/misc/cxl/Makefile | 2 ++ 2 files changed, 12 insertions(+)
drivers/misc/cxl/Kconfig +10 -0
@@ -6,3 +6,13 @@ config CXL_BASE bool default n select PPC_COPRO_BASE + +config CXL + tristate "Support for IBM Coherent Accelerators (CXL)" + depends on PPC_POWERNV && PCI_MSI + select CXL_BASE + default m + help + Select this option to enable userspace driver support for IBM + Coherent Accelerators (CXL). CXL is otherwise known as Coherent + Accelerator Processor Interface (CAPI).
drivers/misc/cxl/Makefile +2 -0
@@ -1 +1,3 @@ +cxl-y += main.o file.o irq.o fault.o native.o context.o sysfs.o debugfs.o pci.o +obj-$(CONFIG_CXL) += cxl.o obj-$(CONFIG_CXL_BASE) += base.o
Signature · 1 line
1.9.1
PATCH v3 16/16 cxl: Add documentation for userspace APIs
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This documentation gives an overview of the hardware architecture, userspace APIs via /dev/cxl/afu0.0 and the syfs files. It also adds a MAINTAINERS file entry for cxl.
--- Documentation/ABI/testing/sysfs-class-cxl | 142 ++++++++++++ Documentation/ioctl/ioctl-number.txt | 1 + Documentation/powerpc/00-INDEX | 2 + Documentation/powerpc/cxl.txt | 346 ++++++++++++++++++++++++++++++ MAINTAINERS | 7 + 5 files changed, 498 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-cxl create mode 100644 Documentation/powerpc/cxl.txt
Documentation/ABI/testing/sysfs-class-cxl new file +142 -0
@@ -0,0 +1,142 @@ +Slave contexts (eg. /sys/class/cxl/afu0.0): + +What: /sys/class/cxl/<afu>/irqs_max +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Maximum number of interrupts that can be requested by userspace. + The default on probe is the maximum that hardware can support + (eg. 2037). Write values will limit userspace applications to + that many userspace interrupts. Must be >= irqs_min. + +What: /sys/class/cxl/<afu>/irqs_min +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + The minimum number of interrupts that userspace must request + on a CXL_START_WORK ioctl. Userspace may omit the + num_interrupts field in the START_WORK IOCTL to get this + minimum automatically. + +What: /sys/class/cxl/<afu>/mmio_size +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Size of the MMIO space that may be mmaped by userspace. + + +What: /sys/class/cxl/<afu>/models_supported +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + List of the models this AFU supports. + Valid entries are: "dedicated_process" and "afu_directed" + +What: /sys/class/cxl/<afu>/model +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read/write + The current model the AFU is using. Will be one of the models + given in models_supported. Writing will change the model + provided that no user contexts are attached. + + +What: /sys/class/cxl/<afu>/prefault_mode +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read/write + Set the mode for prefaulting in segments into the segment table + when performing the START_WORK ioctl. Possible values: + none: No prefaulting (default) + wed: Treat the wed as an effective address and prefault it + all: all segments this process currently maps + +What: /sys/class/cxl/<afu>/reset +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: write only + Reset the AFU. + +What: /sys/class/cxl/<afu>/api_version +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + List the current version of the kernel/user API. + +What: /sys/class/cxl/<afu>/api_version_com +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + List the lowest version the kernel/user API this + kernel is compatible with. + + + +Master contexts (eg. /sys/class/cxl/afu0.0m) + +What: /sys/class/cxl/<afu>m/mmio_size +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Size of the MMIO space that may be mmaped by userspace. This + includes all slave contexts space also. + +What: /sys/class/cxl/<afu>m/pp_mmio_len +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Per Process MMIO space length. + +What: /sys/class/cxl/<afu>m/pp_mmio_off +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Per Process MMIO space offset. + + +Card info (eg. /sys/class/cxl/card0) + +What: /sys/class/cxl/<card>/caia_version +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Identifies the CAIA Version the card implements. + +What: /sys/class/cxl/<card>/psl_version +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Identifies the revision level of the PSL. + +What: /sys/class/cxl/<card>/base_image +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Identifies the revision level of the base image for devices + that support load-able PSLs. For FPGAs this field identifies + the image contained in the on-adapter flash which is loaded + during the initial program load + +What: /sys/class/cxl/<card>/image_loaded +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Will return "user" or "factory" depending on the image loaded + onto the card +
Documentation/ioctl/ioctl-number.txt +1 -0
@@ -313,6 +313,7 @@ Code Seq#(hex) Include File Comments 0xB1 00-1F PPPoX <mailto:[email protected]> 0xB3 00 linux/mmc/ioctl.h 0xC0 00-0F linux/usb/iowarrior.h +0xCA 00-0F uapi/misc/cxl.h 0xCB 00-1F CBM serial IEC bus in development: <mailto:[email protected]> 0xCD 01 linux/reiserfs_fs.h
Documentation/powerpc/00-INDEX +2 -0
@@ -28,3 +28,5 @@ ptrace.txt - Information on the ptrace interfaces for hardware debug registers. transactional_memory.txt - Overview of the Power8 transactional memory support. +cxl.txt + - Overview of the CXL driver.
Documentation/powerpc/cxl.txt new file +346 -0
346 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -2711,6 +2711,13 @@ W: http://www.chelsio.com S: Supported F: drivers/net/ethernet/chelsio/cxgb4vf/ +CXL (IBM Coherent Accelerator Processor Interface CAPI) DRIVER +M: Ian Munsie <[email protected]> +M: Michael Neuling <[email protected]> +L: [email protected] +S: Supported +F: drivers/misc/cxl/ + STMMAC ETHERNET DRIVER M: Giuseppe Cavallaro <[email protected]> L: [email protected]
Signature · 1 line
1.9.1
Michael Ellerman
reviewerRe: [v3,16/16] cxl: Add documentation for userspace APIs
Quoted 4 lines · Michael Neuling
From: Ian Munsie <[email protected]>
This documentation gives an overview of the hardware architecture, userspace APIs via
/dev/cxl/afu0.0and the syfs files. It also adds aMAINTAINERSfile
Elsewhere you talk about /dev/cxl/afuM.N, please be consistent.
Documentation/ABI/testing/sysfs-class-cxl line 1
Quoted 7 lines
Documentation/ABI/testing/sysfs-class-cxl new file +1
-0@@ -0,0 +1,142 @@ +Slave contexts (eg. /sys/class/cxl/afu0.0):
Don't slave contexts end with 's' ?
Documentation/ABI/testing/sysfs-class-cxl line 6
Quoted 5 lines
Documentation/ABI/testing/sysfs-class-cxl new file +5
-0+ +What: /sys/class/cxl/<afu>/irqs_max +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]>
We just had to fix up a bunch of these for someone who left IBM. Would it be better if they just pointed to linuxppc-dev ?
Documentation/ABI/testing/sysfs-class-cxl line 10
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-cxl new file +4
-0+Description: read only + Maximum number of interrupts that can be requested by userspace. + The default on probe is the maximum that hardware can support + (eg. 2037). Write values will limit userspace applications to
I thought it was read only?
Documentation/ABI/testing/sysfs-class-cxl line 11
Quoted 1 line
Documentation/ABI/testing/sysfs-class-cxl new file +1
-0+ that many userspace interrupts. Must be >= irqs_min.
Decimal, hex?
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-cxl new file +6
-0+What: /sys/class/cxl/<afu>/irqs_min +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + The minimum number of interrupts that userspace must request
Documentation/ABI/testing/sysfs-class-cxl line 28
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-cxl new file +10
-0+ on a CXL_START_WORK ioctl. Userspace may omit the + num_interrupts field in the START_WORK IOCTL to get this + minimum automatically. + +What: /sys/class/cxl/<afu>/mmio_size +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Size of the MMIO space that may be mmaped by userspace.
Decimal, hex? Bytes, KB ?
Documentation/ABI/testing/sysfs-class-cxl line 36
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-cxl new file +6
-0+What: /sys/class/cxl/<afu>/models_supported +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + List of the models this AFU supports.
So there can be more than one? How are multiple values separated?
Quoted 12 lines
Documentation/ABI/testing/sysfs-class-cxl new file +12
-0+ Valid entries are: "dedicated_process" and "afu_directed" + +What: /sys/class/cxl/<afu>/model +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read/write + The current model the AFU is using. Will be one of the models + given in models_supported. Writing will change the model + provided that no user contexts are attached. + +
Documentation/ABI/testing/sysfs-class-cxl line 58
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-cxl new file +10
-0+What: /sys/class/cxl/<afu>/prefault_mode +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read/write + Set the mode for prefaulting in segments into the segment table + when performing the START_WORK ioctl. Possible values: + none: No prefaulting (default) + wed: Treat the wed as an effective address and prefault it + all: all segments this process currently maps
"this" process is not entirely clear. You mean "the process that calls START_WORK" ?
Documentation/ABI/testing/sysfs-class-cxl line 65
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-cxl new file +6
-0+What: /sys/class/cxl/<afu>/reset +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: write only + Reset the AFU.
How does this interact with the chardev API? Do my contexts go away or stop working or anything?
Documentation/ABI/testing/sysfs-class-cxl line 72
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-cxl new file +6
-0+What: /sys/class/cxl/<afu>/api_version +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + List the current version of the kernel/user API.
Show not List. Decimal, hex?
Documentation/ABI/testing/sysfs-class-cxl line 80
Quoted 7 lines
Documentation/ABI/testing/sysfs-class-cxl new file +7
-0+What: /sys/class/cxl/<afu>/api_version_com +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + List the lowest version the kernel/user API this + kernel is compatible with.
Show not List. Decimal, hex?
And needs to be clearer:
"The lowest version of the userspace API that this kernel supports."
Documentation/ABI/testing/sysfs-class-cxl line 92
Quoted 9 lines
Documentation/ABI/testing/sysfs-class-cxl new file +9
-0+Master contexts (eg. /sys/class/cxl/afu0.0m) + +What: /sys/class/cxl/<afu>m/mmio_size +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Size of the MMIO space that may be mmaped by userspace. This + includes all slave contexts space also.
Units.
Documentation/ABI/testing/sysfs-class-cxl line 99
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-cxl new file +6
-0+What: /sys/class/cxl/<afu>m/pp_mmio_len +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Per Process MMIO space length.
Units.
Documentation/ABI/testing/sysfs-class-cxl line 106
Quoted 6 lines
Documentation/ABI/testing/sysfs-class-cxl new file +6
-0+What: /sys/class/cxl/<afu>m/pp_mmio_off +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Per Process MMIO space offset.
Units.
Quoted 13 lines
Documentation/ABI/testing/sysfs-class-cxl new file +13
-0+Card info (eg. /sys/class/cxl/card0) + +What: /sys/class/cxl/<card>/caia_version +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Identifies the CAIA Version the card implements. + +What: /sys/class/cxl/<card>/psl_version +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]>
Documentation/ABI/testing/sysfs-class-cxl line 131
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-cxl new file +10
-0+Description: read only + Identifies the revision level of the PSL. + +What: /sys/class/cxl/<card>/base_image +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Identifies the revision level of the base image for devices + that support load-able PSLs. For FPGAs this field identifies
loadable is one word.
Documentation/ABI/testing/sysfs-class-cxl line 133
Quoted 2 lines
Documentation/ABI/testing/sysfs-class-cxl new file +2
-0+ the image contained in the on-adapter flash which is loaded + during the initial program load
Full stop missing.
Documentation/ABI/testing/sysfs-class-cxl line 141
Quoted 7 lines
Documentation/ABI/testing/sysfs-class-cxl new file +7
-0+What: /sys/class/cxl/<card>/image_loaded +Date: September 2014 +Contact: Ian Munsie <[email protected]>, + Michael Neuling <[email protected]> +Description: read only + Will return "user" or "factory" depending on the image loaded + onto the card
Full stop missing.
Documentation/powerpc/00-INDEX ptrace.txt · line 32
Quoted 10 lines
Documentation/powerpc/00-INDEX +2
-0@@ -28,3 +28,5 @@ ptrace.txt - Information on the ptrace interfaces for hardware debug registers. transactional_memory.txt - Overview of the Power8 transactional memory support. +cxl.txt + - Overview of the CXL driver.
This file is not entirely in alphabetical order, but don't make it worse :)
Quoted 6 lines
Documentation/powerpc/cxl.txt new file +0
-0
Documentation/powerpc/cxl.txt line 8
Quoted 8 lines
Documentation/powerpc/cxl.txt new file +8
-0@@ -0,0 +1,346 @@ +Coherent Accelerator Interface (CXL) +==================================== + +Introduction +============ + + The coherent accelerator interface is designed to allow the + coherent connection of FPGA based accelerators (and other devices)
Or "connection of accelerators (FPGAs and other devices)" ?
Below you use FPGA a few times, should they also be "accelerator" or something more generic?
Also you use "64bit" a bunch, it's "64-bit" :)
Documentation/powerpc/cxl.txt line 10
Quoted 2 lines
Documentation/powerpc/cxl.txt new file +2
-0+ to a POWER system. These devices need to adhere to the Coherent + Accelerator Interface Architecture (CAIA).
It would be good to briefly describe what "coherent" means in this context, you use it a lot.
Quoted 14 lines
Documentation/powerpc/cxl.txt new file +14
-0+ IBM refers to this as the Coherent Accelerator Processor Interface + or CAPI. In the kernel it's referred to by the name CXL to avoid + confusion with the ISDN CAPI subsystem. + +Hardware overview +================= + + POWER8 FPGA + +----------+ +---------+ + | | | | + | CPU | | AFU | + | | | | + | | | | + | | | |
Documentation/powerpc/cxl.txt line 35
Quoted 10 lines
Documentation/powerpc/cxl.txt new file +10
-0+ +----------+ +---------+ + | | | | + | CAPP +--------+ PSL | + | | PCIe | | + +----------+ +---------+ + + The POWER8 chip has a Coherently Attached Processor Proxy (CAPP) + unit which is part of the PCIe Host Bridge (PHB). This is managed + by Linux by calls into OPAL. Linux doesn't directly program the + CAPP.
But that's not what your diagram shows, how about:
POWER8 FPGA
+----------+ +---------+
| | | |
| CPU | | AFU |
| | | |
| | | |
| | | |
+----------+ +---------+
| PHB | | |
| +------+ | PSL |
| | CAPP |<------>| |
+---+------+ PCIE +---------+
Documentation/powerpc/cxl.txt line 39
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ The FPGA (or coherently attached device) consists of two parts. + The POWER Service Layer (PSL) and the Accelerator Function Unit + (AFU). AFU is used to implement specific functionality behind
The AFU
Quoted 14 lines
Documentation/powerpc/cxl.txt new file +14
-0+ the PSL. The PSL, among other things, provides memory address + translation services to allow each AFU direct access to userspace + memory. + + The AFU is the core part of the accelerator (eg. the compression, + crypto etc function). The kernel has no knowledge of the function + of the AFU. Only userspace interacts directly with the AFU. + + The PSL provides the translation and interrupt services that the + AFU needs. This is what the kernel interacts with. For example, + if the AFU needs to read a particular virtual address, it sends + that address to the PSL, the PSL then translates it, fetches the + data from memory and returns it to the AFU. If the PSL has a + translation miss, it interrupts the kernel and the kernel services
Documentation/powerpc/cxl.txt line 63
Quoted 10 lines
Documentation/powerpc/cxl.txt new file +10
-0+ the fault. The context to which this fault is serviced is based + on who owns that acceleration function. + +AFU Models +========== + + There are two programming models supported by the AFU. Dedicated + and AFU directed. AFU may support one or both models. + + In dedicated model only one MMU context is supported. In this
"In dedicated model" is a bit strange.
"When using the dedicated model .." ?
Or "dedicated mode" ?
Documentation/powerpc/cxl.txt line 69
Quoted 6 lines
Documentation/powerpc/cxl.txt new file +6
-0+ model, only one userspace process can use the accelerator at time. + + In AFU directed model, up to 16K simultaneous contexts can be + supported. This means up to 16K simultaneous userspace + applications may use the accelerator (although specific AFUs may + support less). In this mode, the AFU sends a 16 bit context ID
fewer not less :)
Documentation/powerpc/cxl.txt line 71
Quoted 2 lines
Documentation/powerpc/cxl.txt new file +2
-0+ with each of its requests. This tells the PSL which context is + associated with this operation. If the PSL can't translate a
with each operation, or with an operation
Documentation/powerpc/cxl.txt line 74
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ request, the ID can also be accessed by the kernel so it can + determine the associated userspace context to service this + translation with.
You were talking about operations but now it's translations?
Maybe "the ID can also be accessed by the kernel so it can determine the userspace context associated with an operation".
Documentation/powerpc/cxl.txt line 83
Quoted 8 lines
Documentation/powerpc/cxl.txt new file +8
-0+MMIO space +========== + + A portion of the FPGA MMIO space can be directly mapped from the + AFU to userspace. Either the whole space can be mapped (master + context), or just a per context portion (slave context). The + hardware is self describing, hence the kernel can determine the + offset and size of the per context portion.
That's the first mention of master and slave and it's not very clear.
Documentation/powerpc/cxl.txt line 90
Quoted 7 lines
Documentation/powerpc/cxl.txt new file +7
-0+ +Interrupts +========== + + AFUs may generate interrupts that are destined for userspace. These + are received by the kernel as hardware interrupts and passed onto + userspace.
How? (via read on the context ..)
Documentation/powerpc/cxl.txt line 101
Quoted 10 lines
Documentation/powerpc/cxl.txt new file +10
-0+ Data storage faults and error interrupts are handled by the kernel + driver. + +Work Element Descriptor (WED) +============================= + + The WED is a 64bit parameter passed to the AFU when a context is + started. Its format is up to the AFU hence the kernel has no + knowledge of what it represents. Typically it will be a virtual + address pointer to a work queue where the AFU and userspace can
Effective address no?
Documentation/powerpc/cxl.txt line 102
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ share control and status information or work queues.
"point to a work queue .. or work queues" doesn't read that well.
Maybe:
"Typically it will be the effective address of a work queue or status block where the AFU and userspace can share control and status information."
Documentation/powerpc/cxl.txt line 117
Quoted 11 lines
Documentation/powerpc/cxl.txt new file +11
-0+User API +======== + + For AFUs operating in the AFU directed model, the driver will + create two character devices per AFU under /dev/cxl. One for + master and one for slave contexts. + + The master context (eg. /dev/cxl/afu0.0m), has access to all of + the MMIO space that an AFU provides. The slave context + (eg. /dev/cxl/afu0.0) has access to only the per process MMIO + space an AFU provides (AFU directed only).
There's only one slave context ?
Documentation/powerpc/cxl.txt line 130
Quoted 12 lines
Documentation/powerpc/cxl.txt new file +12
-0+ For AFUs operating in the dedicated process model, the driver will + only create a single character device per AFU (e.g. + /dev/cxl/afu0.0), which has access to the entire MMIO space that + the AFU provides. + + The following file operations are supported on both slave and + master devices: + + open + + Opens the device and allocates a file descriptor to be used + with the rest of the API.
This would be better done as a subsection I think, eg:
open
----
Opens the device and allocates a file descriptor to be used with the rest of the API.
...
Otherwise you end up very indented further down.
Documentation/powerpc/cxl.txt line 133
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ + A dedicated model AFU only has one context and hence only + allows this device to be opened once.
Where do we enforce that?
Documentation/powerpc/cxl.txt line 136
Quoted 2 lines
Documentation/powerpc/cxl.txt new file +2
-0+ An AFU directed model AFU can have many contexts and hence + this device can be opened by as many contexts as available.
What happens when all the contexts are opened?
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ Note: IRQs also need to be allocated per context, which may + also limit the number of contexts that can be allocated, + and hence how many times the device may be opened. The + POWER8 CAPP supports 2040 IRQs and 3 are used by the
Documentation/powerpc/cxl.txt line 151
Quoted 10 lines
Documentation/powerpc/cxl.txt new file +10
-0+ kernel, so 2037 are left. If 1 IRQ is needed per + context, then only 2037 contexts can be allocated. If 4 + IRQs are needed per context, then only 2037/4 = 509 + contexts can be allocated. + + ioctl + + CXL_IOCTL_START_WORK: + Starts the AFU context and associates it with the process + memory. Once this ioctl is successfully executed, all
"the current process"
Quoted 14 lines
Documentation/powerpc/cxl.txt new file +14
-0+ memory mapped into this process is accessible to this AFU + context using the same virtual addresses. No additional + calls are required to map/unmap memory. The AFU memory + context will be updated as userspace allocates and frees + memory. This ioctl returns once the AFU context is + started. + + Takes a pointer to a struct cxl_ioctl_start_work + struct cxl_ioctl_start_work { + __u64 flags; + __u64 wed; + __u64 amr; + __s16 num_interrupts; + __s16 reserved1;
Documentation/powerpc/cxl.txt line 175
Quoted 10 lines
Documentation/powerpc/cxl.txt new file +10
-0+ __s32 reserved2; + __u64 reserved3; + __u64 reserved4; + __u64 reserved5; + __u64 reserved6; + }; + + flags: + Indicates which optional fields (e.g. amr, + num_interrupts) in the structure are valid.
Don't mention the optional fields here, you'll just end up with a stale list when you add more optional fields in future.
Documentation/powerpc/cxl.txt line 185
Quoted 9 lines
Documentation/powerpc/cxl.txt new file +9
-0+ wed: + The Work Element Descriptor (WED) is a 64bit + argument defined by the AFU. Typically this is an + virtual address pointing to an AFU specific + structure describing what work to perform. + + amr: + Authority Mask Register (AMR), same as the powerpc + AMR.
Is it optional? How?
Documentation/powerpc/cxl.txt line 187
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ num_interrupt:
plural.
Documentation/powerpc/cxl.txt line 191
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ Number of userspace interrupts to request. If not + specified the minimum number required will be + automatically allocated. The min and max number + can be obtained from sysfs.
Not specified how?
Documentation/powerpc/cxl.txt line 198
Quoted 6 lines
Documentation/powerpc/cxl.txt new file +6
-0+ reserved fields: + For ABI padding and future extensions + + CXL_IOCTL_GET_PROCESS_ELEMENT: + Get info on current context id. This info is returned + from the kernel as an int.
It's not "info on the current context id", it *is* the id, isn't it ?
Any good reason it's an int and not a __u32 ?
Documentation/powerpc/cxl.txt line 202
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ Written by the kernel with the context id (AKA process + element) it has allocated. Slave contexts may want to + communicate this to a master process.
I don't know what the implied noun for "Written" is. You could probably just drop that sentence, you've said most of it already.
Documentation/powerpc/cxl.txt line 206
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ + mmap + + An AFU may have a MMIO space to facilitate communication with
an MMIO
Documentation/powerpc/cxl.txt line 207
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ the AFU and mmap allows access to this. The size and contents
the AFU. If it does, the MMIO space can be accessed via mmap.
Documentation/powerpc/cxl.txt line 209
Quoted 2 lines
Documentation/powerpc/cxl.txt new file +2
-0+ of this area are specific to the particular AFU. The size can + be discovered via sysfs.
What if there's none? Size of zero?
Documentation/powerpc/cxl.txt line 211
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ In the AFU directed model, master contexts will get all of the
"get" is a bit vague. You mean master contexts will be allowed to map all of the MMIO space?
Documentation/powerpc/cxl.txt line 216
Quoted 5 lines
Documentation/powerpc/cxl.txt new file +5
-0+ MMIO space and slave contexts will get only the per process + space associated with its context. In the dedicated process + model the entire MMIO space is always mapped. + + This mmap call must be done after the IOCTL is started.
Which ioctl?
Documentation/powerpc/cxl.txt line 220
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ Care should be taken when accessing MMIO space. Only 32 and + 64bit accesses are supported by POWER8. Also, the AFU will be + designed with a specific endian, so all MMIO access should
endian*ness* ?
Documentation/powerpc/cxl.txt line 227
Quoted 7 lines
Documentation/powerpc/cxl.txt new file +7
-0+ consider endian (recommend endian(3) variants like: le64toh(), + be64toh() etc). These endian issues equally apply to shared + memory queues the WED may describe. + + read + + Reads an event from the AFU. Will return -EINVAL if the user
One or more events?
Documentation/powerpc/cxl.txt line 211
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ supplied buffer to read into is less than 4096 bytes.
You say that later so drop this one.
Documentation/powerpc/cxl.txt line 231
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ Blocks + if no events are pending (unless O_NONBLOCK is supplied). Will + return -EIO in the case of an unrecoverable error or if the + card is removed.
"Will return" -> "Returns"
Documentation/powerpc/cxl.txt
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ A read may return multiple events. A read will return the + length of the buffer written and it will be a integral number + of events up to the buffer size.
That's a bit confusing, you're starting to rewrite the read(2) manpage, but from the point of view of the kernel.
The actual text is "On success, the number of bytes read is returned".
I think you should just leave that as implied, because it's read(2). What you do need to say is that the kernel will return an integral number of events.
Documentation/powerpc/cxl.txt line 219
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ Users must supply a buffer size of at least 4K bytes.
"The buffer passed to read() must be at least 4K bytes".
Documentation/powerpc/cxl.txt line 239
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ + All events will be return a struct cxl_event which varies in + size.
"The result of the read will be a buffer of one or more events, each event is of type struct cxl_event, of varying size."
Documentation/powerpc/cxl.txt line 250
Quoted 10 lines
Documentation/powerpc/cxl.txt new file +10
-0+ struct cxl_event { + struct cxl_event_header header; + union { + struct cxl_event_afu_interrupt irq; + struct cxl_event_data_storage fault; + struct cxl_event_afu_error afu_err; + }; + }; + + A struct cxl_event_header at the start gives:
"The struct cxl_event_header is defined as:"
Documentation/powerpc/cxl.txt line 259
Quoted 9 lines
Documentation/powerpc/cxl.txt new file +9
-0+ struct cxl_event_header { + __u16 type; + __u16 size; + __u16 process_element; + __u16 reserved1; + }; + + type: + This gives the type of event. The type determines how
s/gives/defines/
Documentation/powerpc/cxl.txt line 260
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ the rest of the event will be structured. These types
s/will be/is/
Documentation/powerpc/cxl.txt line 261
Quoted 1 line
Documentation/powerpc/cxl.txt new file +1
-0+ are shown below.
You don't mention cxl_event_type (the enum). You should.
Documentation/powerpc/cxl.txt line 265
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ + size: + This is the size of the event in bytes including the + header. The start of the next event can be found at
s/header/struct cxl_event_header/
Documentation/powerpc/cxl.txt line 273
Quoted 10 lines
Documentation/powerpc/cxl.txt new file +4
-0+ this offset from the start of the current event. + + process_element: + Context ID of the event.Currently this will always
Documentation/powerpc/cxl.txt new file +4
-0+ be the current context. Future work may allow + interrupts from one context to be routed to another + (eg. a master contexts handling error interrupts on + behalf of a slave).
Drop all of that.
Documentation/powerpc/cxl.txt line 278
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ reserved field: + For future extensions and padding. + + If an AFU interrupt event is received, the full structure received is:
"If the event type is CXL_EVENT_AFU_INTERRUPT then the event structure is defined as"
Documentation/powerpc/cxl.txt line 287
Quoted 9 lines
Documentation/powerpc/cxl.txt new file +9
-0+ struct cxl_event_afu_interrupt { + __u16 flags; + __u16 irq; /* Raised AFU interrupt number */ + __u32 reserved1; + }; + + flags: + These flags indicate which optional fields are present + in this struct. Currently all fields are Mandatory.
mandatory
Documentation/powerpc/cxl.txt line 295
Quoted 7 lines
Documentation/powerpc/cxl.txt new file +7
-0+ irq: + The IRQ number sent by the AFU. + + reserved field: + For future extensions and padding. + + If a data storage event is received, the full structure received is:
As for cxl_event_afu_interrupt.
Documentation/powerpc/cxl.txt line 307
Quoted 12 lines
Documentation/powerpc/cxl.txt new file +12
-0+ struct cxl_event_data_storage { + __u16 flags; + __u16 reserved1; + __u32 reserved2; + __u64 addr; + __u64 dsisr; + __u64 reserved3; + }; + + flags: + These flags indicate which optional fields are present + in this struct. Currently all fields are Mandatory.
mandatory
Quoted 1 line
+ address: Mandatory
Drop the Mandatory.
Quoted 1 line
+ Address of the data storage trying to be accessed by
"The address that the AFU unsucessfully attempted to access"
Quoted 1 line
+ the AFU. Valid accesses will handled transparently by
will be handled
Quoted 1 line
+ the kernel but invalid access will generate this
invalid accesses
Documentation/powerpc/cxl.txt line 315
Quoted 3 lines
Documentation/powerpc/cxl.txt new file +3
-0+ event. + + dsisr: Manditory
Drop Manditory.
Quoted 1 line
+ These fields give information on the type of
This field
Documentation/powerpc/cxl.txt line 318
Quoted 2 lines
Documentation/powerpc/cxl.txt new file +2
-0+ fault. Copy of the DSISR from PSL hardware when + address fault occured.
Defined in CAIA ?
Documentation/powerpc/cxl.txt line 323
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ reserved fields: + For future extensions + + If an AFU error event is received, the full structure received is:
As above.
Documentation/powerpc/cxl.txt line 331
Quoted 8 lines
Documentation/powerpc/cxl.txt new file +8
-0+ struct cxl_event_afu_error { + __u16 flags; + __u16 reserved1; + __u32 reserved2; + __u64 err; + }; + + flags: Mandatory
Drop Mandatory.
Documentation/powerpc/cxl.txt line 335
Quoted 4 lines
Documentation/powerpc/cxl.txt new file +4
-0+ These flags indicate which optional fields are present + in this struct. Currently all fields are Mandatory. + + err:
Can we just call it error ?
Quoted 1 line
+ Error status from the AFU. AFU defined.
"Defined by the AFU".
Quoted 14 lines
Documentation/powerpc/cxl.txt new file +9
-0+ reserved fields: + For future extensions and padding + +Sysfs Class +=========== + + A cxl sysfs class is added under /sys/class/cxl to facilitate + enumeration and tuning of the accelerators. Its layout is + described in Documentation/ABI/testing/sysfs-class-cxlMAINTAINERS +0
-0
MAINTAINERS W: http://www.chelsio.com · line 2719
Quoted 9 lines
MAINTAINERS +6
-0@@ -2711,6 +2711,13 @@ W: http://www.chelsio.com S: Supported F: drivers/net/ethernet/chelsio/cxgb4vf/ +CXL (IBM Coherent Accelerator Processor Interface CAPI) DRIVER +M: Ian Munsie <[email protected]> +M: Michael Neuling <[email protected]> +L: [email protected] +S: Supported +F: drivers/misc/cxl/
F: include/misc/cxl.h
F: include/uapi/misc/cxl.h
F: Documentation/powerpc/cxl.txt
F: Documentation/powerpc/cxl.txt
F: Documentation/ABI/testing/sysfs-class-cxl
cheers