POWER8 Coherent Accelerator device driver
Subsystems (5)
cover POWER8 Coherent Accelerator device driver
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-2: Split some of the old Cell co-processor code out so it can be
reused.
Patches 3-9: Add infrastructure to arch/powerpc needed by cxl. Patches 10: Add call backs needed for invalidating cxl mm contexts. Patch 11: Add cxl specific support that needs to be built in to the
kernel (can't be a module).
Patches 12-15: Add the majority of the device driver and API header.
Patch 15: 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
Please consider for inclusion. Feedback welcome!
Regards,
Mikey
Documentation/ABI/testing/sysfs-class-cxl | 125 ++++ Documentation/ioctl/ioctl-number.txt | 1 + Documentation/powerpc/00-INDEX | 2 + Documentation/powerpc/cxl.txt | 310 ++++++++ MAINTAINERS | 7 + arch/powerpc/include/asm/copro.h | 18 + arch/powerpc/include/asm/mmu-hash64.h | 3 + arch/powerpc/include/asm/opal.h | 2 + arch/powerpc/include/asm/pnv-pci.h | 27 + arch/powerpc/include/asm/spu.h | 5 +- arch/powerpc/mm/Makefile | 2 + arch/powerpc/mm/copro_fault.c | 140 ++++ arch/powerpc/mm/hash_native_64.c | 6 +- arch/powerpc/mm/hash_utils_64.c | 25 +- arch/powerpc/mm/slb.c | 3 - arch/powerpc/mm/slice.c | 3 + arch/powerpc/platforms/cell/Makefile | 2 +- arch/powerpc/platforms/cell/spu_base.c | 41 +- arch/powerpc/platforms/cell/spu_fault.c | 94 --- arch/powerpc/platforms/cell/spufs/fault.c | 4 +- arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + arch/powerpc/platforms/powernv/pci-ioda.c | 229 +++++- arch/powerpc/sysdev/msi_bitmap.c | 18 +- drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/cxl/Kconfig | 25 + drivers/misc/cxl/Makefile | 4 + drivers/misc/cxl/base.c | 102 +++ drivers/misc/cxl/context.c | 169 +++++ drivers/misc/cxl/cxl-pci.c | 977 +++++++++++++++++++++++++ drivers/misc/cxl/cxl.h | 605 +++++++++++++++ drivers/misc/cxl/debugfs.c | 116 +++ drivers/misc/cxl/fault.c | 298 ++++++++ drivers/misc/cxl/file.c | 503 +++++++++++++ drivers/misc/cxl/irq.c | 405 ++++++++++ drivers/misc/cxl/main.c | 238 ++++++ drivers/misc/cxl/native.c | 649 ++++++++++++++++ drivers/misc/cxl/sysfs.c | 348 +++++++++ include/misc/cxl.h | 34 + include/uapi/Kbuild | 1 + include/uapi/misc/Kbuild | 2 + include/uapi/misc/cxl.h | 88 +++ 42 files changed, 5463 insertions(+), 171 deletions(-)
PATCH 1/15 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/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/Makefile | 2 +-
arch/powerpc/platforms/cell/spufs/fault.c | 4 ++--
6 files changed, 30 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/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_SPU_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/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 01/15] powerpc/cell: Move spu_handle_mm_fault() out of cell platform
Hi Mikey & Ian,
Quoted 6 lines
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/mmso that others may use it.
Makes sense.
Quoted 5 lines
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/platforms/cell/spu_fault.c +0
-1@@ -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 ;
arch/powerpc/mm/copro_fault.c int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea, · line 67
Quoted 10 lines
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/platforms/cell/spu_fault.c +2
-1+ 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;
Consistent DSISR encodings? woot! :)
Cheers,
Jeremy
Re: [PATCH 01/15] powerpc/cell: Move spu_handle_mm_fault() out of cell platform
Quoted 1 line
Review int spu_handle_mm_fault(struct mm_struct *mm, unsig=
Quoted 1 line
(quoted diff) +0
-0@@ -58,12 +56,12 @@ int spu_handle_mm_fault(struct mm_struct *mm, unsig=
ned long ea,
Quoted 8 lines
Quoted 8 lines
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/platforms/cell/spu_fault.c +0
-0goto out_unlock; }=20
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/platforms/cell/spu_fault.c +1
-1- is_write =3D dsisr & MFC_DSISR_ACCESS_PUT; + is_write =3D dsisr & DSISR_ISSTORE;if (is_write) {if (!(vma->vm_flags &VM_WRITE )) goto out_unlock;
Quoted 8 lines
arch/powerpc/mm/copro_fault.c int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea, · line 67
Quoted 6 lines
arch/powerpc/mm/copro_fault.c renamed from arch/powerpc/platforms/cell/spu_fault.c +1
-1}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;=20
Consistent DSISR encodings? woot! :)
Yep!
arch/powerpc/include/asm/spu.h:605:#define MFC_DSISR_ACCESS_PUT (1 =
<< 25)
arch/powerpc/include/asm/reg.h:255:#define DSISR_ISSTORE 0x0=
2000000 /* access was a store */
and=20
arch/powerpc/include/asm/spu.h:603:#define MFC_DSISR_ACCESS_DENIED =
(1 << 27)
arch/powerpc/include/asm/reg.h:254:#define DSISR_PROTFAULT 0x08000000 =
/* protection fault */Mikey
Re: [PATCH 01/15] powerpc/cell: Move spu_handle_mm_fault() out of cell platform
In reply to Michael NeulingQuoted 4 lines
From: Ian Munsie <[email protected]>
Currently
spu_handle_mm_fault()is in the cell platform.
Quoted 8 lines
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/mmso that others may use it.Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>
Anton
PATCH 2/15 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.
--- arch/powerpc/include/asm/mmu-hash64.h | 2 ++ arch/powerpc/mm/copro_fault.c | 48 ++++++++++++++++++++++++++++++++++ arch/powerpc/mm/slb.c | 3 --- arch/powerpc/platforms/cell/spu_base.c | 41 +++-------------------------- 4 files changed, 54 insertions(+), 40 deletions(-)
arch/powerpc/include/asm/mmu-hash64.h +2 -0
@@ -180,6 +180,8 @@ static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize)* we work in all cases including 4k page size. */ #define VPN_SHIFT 12 +#define slb_vsid_shift (ssize) \ + ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T)/* * HPTE Large Page (LP) details
arch/powerpc/mm/copro_fault.c +48 -0
51 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 +4 -37
49 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform
Hi Mikey & Ian,
Quoted 5 lines
__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.
OK, nice.
Quoted 34 lines
arch/powerpc/mm/copro_fault.c +34
-0+ +int copro_data_segment (struct mm_struct *mm,u64 ea,u64 *esid,u64 *vsid) +{ +int psize, ssize; + + *esid = (ea &ESID_MASK ) |SLB_ESID_V ; + +switch (REGION_ID (ea)) { +case USER_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- USER_REGION_ID\n" , ea); +#ifdef CONFIG_PPC_MM_SLICES + psize =get_slice_psize (mm, ea); +#else + psize = mm->context.user_psize; +#endif + ssize =user_segment_size (ea); + *vsid = (get_vsid (mm->context.id, ea, ssize) + <<slb_vsid_shift (ssize)) |SLB_VSID_USER + | (ssize ==MMU_SEGSIZE_1T ?SLB_VSID_B_1T :0 ); +break ; +case VMALLOC_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- VMALLOC_REGION_ID\n" , ea); +if (ea <VMALLOC_END ) + psize = mmu_vmalloc_psize; +else + psize = mmu_io_psize; + *vsid = (get_kernel_vsid (ea, mmu_kernel_ssize) + <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL + | (mmu_kernel_ssize ==MMU_SEGSIZE_1T ?SLB_VSID_B_1T :0 ); +break ; +case KERNEL_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- KERNEL_REGION_ID\n" , ea); + psize = mmu_linear_psize; + *vsid = (get_kernel_vsid(ea, mmu_kernel_ssize)
arch/powerpc/mm/copro_fault.c out_unlock: · line 136
Quoted 10 lines
arch/powerpc/mm/copro_fault.c +10
-0+ << SLB_VSID_SHIFT) | SLB_VSID_KERNEL + | (mmu_kernel_ssize ==MMU_SEGSIZE_1T ?SLB_VSID_B_1T :0 ); +break ; +default : +/* Future: support kernel segments so that drivers can use the +* CoProcessors */ +pr_debug ("invalid region access at %016llx\n" , ea); +return 1 ; + } + *vsid |= mmu_psize_defs[psize].sllp;
A bit of a nitpick, but how about you remove the repeated:
| (<size> == MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0)
then set ssize in each of the switch cases (like we do with psize), and or-in the VSID_B_1T bit at the end:
*vsid |= mmu_psize_defs[psize].sllp | (ssize == MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0);
Otherwise, looks good to me.
Cheers,
Jeremy
Re: [PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +int copro_data_segment(struct mm_struct *mm, u64 ea, u64 *esid, u64 *v=
sid)
Quoted 45 lines
Quoted 32 lines
(quoted diff) +32
-0+{ + int psize, ssize; + + *esid =3D (ea & ESID_MASK) | SLB_ESID_V; + + switch (REGION_ID(ea)) { + case USER_REGION_ID: + pr_devel("copro_data_segment: 0x%llx -- USER_REGION_ID\n", ea); +#ifdef CONFIG_PPC_MM_SLICES + psize =3D get_slice_psize(mm, ea); +#else + psize =3D mm->context.user_psize; +#endif + ssize =3D user_segment_size(ea); + *vsid =3D (get_vsid(mm->context.id, ea, ssize) + << slb_vsid_shift(ssize)) | SLB_VSID_USER + | (ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0); + break; + case VMALLOC_REGION_ID: + pr_devel("copro_data_segment: 0x%llx -- VMALLOC_REGION_ID\n", ea); + if (ea < VMALLOC_END) + psize =3D mmu_vmalloc_psize; + else + psize =3D mmu_io_psize; + *vsid =3D (get_kernel_vsid(ea, mmu_kernel_ssize) + << SLB_VSID_SHIFT) | SLB_VSID_KERNEL + | (mmu_kernel_ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0); + break; + case KERNEL_REGION_ID: + pr_devel("copro_data_segment: 0x%llx -- KERNEL_REGION_ID\n", ea); + psize =3D mmu_linear_psize; + *vsid =3D (get_kernel_vsid(ea, mmu_kernel_ssize)Review
Quoted 10 lines
(quoted diff) +10
-0+ << SLB_VSID_SHIFT) | SLB_VSID_KERNEL + | (mmu_kernel_ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0); + break; + default: + /* Future: support kernel segments so that drivers can use the + * CoProcessors */ + pr_debug("invalid region access at %016llx\n", ea); + return 1; + } + *vsid |=3D mmu_psize_defs[psize].sllp;=20
A bit of a nitpick, but how about you remove the repeated:
=20
Quoted 7 lines
| (<size> =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0)=20
then set ssize in each of the switch cases (like we do with psize), and or-in theVSID_B_1Tbit at the end:
=09*vsid |=3D mmu_psize_defs[psize].sllp | (ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0);
Nice. I think below is what you mean.
I'll fold this into the existing patch and repost in a few days.
Thanks,
Mikey
arch/powerpc/mm/copro_fault.c +0 -0
@@ -107,8 +107,7 @@ int copro_data_segment(struct mm_struct *mm, u64 ea, u6=
4 *esid, u64 *vsid)
#endif
ssize =3D user_segment_size(ea);
*vsid =3D (get_vsid(mm->context.id, ea, ssize)
- << slb_vsid_shift(ssize)) | SLB_VSID_USER
- | (ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0);
+ << slb_vsid_shift(ssize)) | SLB_VSID_USER;
break;
case VMALLOC_REGION_ID:
pr_devel("copro_data_segment: 0x%llx -- VMALLOC_REGION_ID\n", ea);
@@ -116,16 +115,16 @@ int copro_data_segment(struct mm_struct *mm, u64 ea, = u64 *esid, u64 *vsid)
psize =3D mmu_vmalloc_psize;
else
psize =3D mmu_io_psize;
+ ssize =3D mmu_kernel_ssize;
*vsid =3D (get_kernel_vsid(ea, mmu_kernel_ssize)
- << SLB_VSID_SHIFT) | SLB_VSID_KERNEL
- | (mmu_kernel_ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0);
+ << SLB_VSID_SHIFT) | SLB_VSID_KERNEL;
break;
case KERNEL_REGION_ID:
pr_devel("copro_data_segment: 0x%llx -- KERNEL_REGION_ID\n", ea); psize =3D mmu_linear_psize;
+ ssize =3D mmu_kernel_ssize;
*vsid =3D (get_kernel_vsid(ea, mmu_kernel_ssize)
- << SLB_VSID_SHIFT) | SLB_VSID_KERNEL
- | (mmu_kernel_ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0);
+ << SLB_VSID_SHIFT) | SLB_VSID_KERNEL;
break;
default:
/* Future: support kernel segments so that drivers can use the
@@ -133,7 +132,8 @@ int copro_data_segment(struct mm_struct *mm, u64 ea, u6= 4 *esid, u64 *vsid)
pr_debug("invalid region access at %016llx\n", ea); return 1;
}
- *vsid |=3D mmu_psize_defs[psize].sllp;
+ *vsid |=3D mmu_psize_defs[psize].sllp |
+ (ssize =3D=3D MMU_SEGSIZE_1T) ? SLB_VSID_B_1T : 0;
=20
return 0;
}
Re: [PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform
In reply to Michael NeulingQuoted 8 lines
From: 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.
Could we also mention:
and adds 1TB segment support.
Quoted 2 lines
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>
Anton
Re: [PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform
Quoted 11 lines · Anton Blanchard
Quoted 7 lines
From: Ian Munsie <[email protected]>
=20__spu_trap_data_seg()currently contains code to determine the VSID and ESID required for a particular EA and mm struct.
=20
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.=20
Could we also mention:
=20
and adds 1TB segment support.
Good point. I'll add.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>=20
Reviewed-by Anton Blanchard <[email protected]>
Thanks,
Mikey
Re: [PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform
In reply to Michael NeulingQuoted 22 lines · Michael Neuling
From: 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.
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/include/asm/mmu-hash64.h | 2 ++ arch/powerpc/mm/copro_fault.c | 48 ++++++++++++++++++++++++++++++++++ arch/powerpc/mm/slb.c | 3 --- arch/powerpc/platforms/cell/spu_base.c | 41 +++-------------------------- 4 files changed, 54 insertions(+), 40 deletions(-)arch/powerpc/include/asm/mmu-hash64.h +0
-0
arch/powerpc/include/asm/mmu-hash64.h static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize) · line 184
Quoted 5 lines
arch/powerpc/include/asm/mmu-hash64.h +2
-0@@ -180,6 +180,8 @@ static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize)* we work in all cases including 4k page size. */ #define VPN_SHIFT 12 +#define slb_vsid_shift (ssize) \ + ((ssize) == MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T)
can it be static inline similar to segment_shift() ?
Quoted 16 lines
arch/powerpc/include/asm/mmu-hash64.h +0
-0/* * HPTE Large Page (LP) details arch/powerpc/mm/copro_fault.c +5
-0@@ -90,3 +90,51 @@ out_unlock:return ret; }EXPORT_SYMBOL_GPL (copro_handle_mm_fault); + +int copro_data_segment (struct mm_struct *mm,u64 ea,u64 *esid,u64 *vsid) +{ +int psize, ssize; +
arch/powerpc/mm/copro_fault.c out_unlock: · line 107
Quoted 10 lines
arch/powerpc/mm/copro_fault.c +10
-0+ *esid = (ea &ESID_MASK ) |SLB_ESID_V ; + +switch (REGION_ID (ea)) { +case USER_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- USER_REGION_ID\n" , ea); +#ifdef CONFIG_PPC_MM_SLICES + psize =get_slice_psize (mm, ea); +#else + psize = mm->context.user_psize; +#endif
We don't need that.
#ifdef CONFIG_PPC_STD_MMU_64
#define get_slice_psize(mm, addr) ((mm)->context.user_psize)
Quoted 22 lines
arch/powerpc/mm/copro_fault.c +22
-0+ ssize =user_segment_size (ea); + *vsid = (get_vsid (mm->context.id, ea, ssize) + <<slb_vsid_shift (ssize)) |SLB_VSID_USER + | (ssize ==MMU_SEGSIZE_1T ?SLB_VSID_B_1T :0 ); +break ; +case VMALLOC_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- VMALLOC_REGION_ID\n" , ea); +if (ea <VMALLOC_END ) + psize = mmu_vmalloc_psize; +else + psize = mmu_io_psize; + *vsid = (get_kernel_vsid (ea, mmu_kernel_ssize) + <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL + | (mmu_kernel_ssize ==MMU_SEGSIZE_1T ?SLB_VSID_B_1T :0 ); +break ; +case KERNEL_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- KERNEL_REGION_ID\n" , ea); + psize = mmu_linear_psize; + *vsid = (get_kernel_vsid (ea, mmu_kernel_ssize) + <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL + | (mmu_kernel_ssize ==MMU_SEGSIZE_1T ?SLB_VSID_B_1T :0 ); +break ;
arch/powerpc/mm/copro_fault.c out_unlock: · line 139
Quoted 10 lines
arch/powerpc/mm/copro_fault.c +10
-0+default : +/* Future: support kernel segments so that drivers can use the +* CoProcessors */ +pr_debug ("invalid region access at %016llx\n" , ea); +return 1 ; + } + *vsid |= mmu_psize_defs[psize].sllp; + +return 0 ; +}
large part of this is same as what we do in hash_page. And we are not really updating vsid here, it is vsid slb encoding. So why not abstract the vsid part and use that in hash_page also ? That would have also taken care of the above #ifdef.
Quoted 59 lines
arch/powerpc/mm/copro_fault.c +1
-0+EXPORT_SYMBOL_GPL (copro_data_segment);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 +1
-33@@ -167,45 +167,12 @@ static inline void spu_load_slb(struct spu *spu, int slbe, struct spu_slb *slb)static int __spu_trap_data_seg (struct spu *spu,unsigned long ea) { -struct mm_struct *mm = spu->mm;struct spu_slb slb; -int psize; - -pr_debug ("%s\n" , __func__); - - slb.esid = (ea &ESID_MASK ) |SLB_ESID_V ; +int ret; -switch (REGION_ID (ea)) { -case USER_REGION_ID : -#ifdef CONFIG_PPC_MM_SLICES - psize =get_slice_psize (mm, ea); -#else - psize = mm->context.user_psize; -#endif - slb.vsid = (get_vsid (mm->context.id, ea,MMU_SEGSIZE_256M ) - <<SLB_VSID_SHIFT ) |SLB_VSID_USER ; -break ; -case VMALLOC_REGION_ID : -if (ea <VMALLOC_END ) - psize = mmu_vmalloc_psize; -else - psize = mmu_io_psize; - slb.vsid = (get_kernel_vsid (ea,MMU_SEGSIZE_256M ) - <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL ; -break ; -case KERNEL_REGION_ID : - psize = mmu_linear_psize; - slb.vsid = (get_kernel_vsid (ea,MMU_SEGSIZE_256M ) - <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL ; -break ; -default : -/* Future: support kernel segments so that drivers -* can use SPUs. -*/
arch/powerpc/platforms/cell/spu_base.c static inline void spu_load_slb(struct spu *spu, int slbe, struct spu_slb *slb) · line 178
Quoted 10 lines
arch/powerpc/platforms/cell/spu_base.c +3
-4-pr_debug ("invalid region access at %016lx\n" , ea); -return 1 ; - } - slb.vsid |= mmu_psize_defs[psize].sllp; + ret =copro_data_segment (spu->mm, ea, &slb.esid, &slb.vsid); +if (ret) +return ret;spu_load_slb (spu, spu->slb_replace, &slb);
-aneesh
Re: [PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform
Quoted 5 lines · Aneesh Kumar K.V
Michael Neuling <[email protected]> writes:
=20Quoted 3 lines
From: Ian Munsie <[email protected]>
__spu_trap_data_seg()currently contains code to determine the VSID and=
ESID
Quoted 3 lines
Quoted 3 lines
required for a particular EA and mm struct.
This code is generically useful for other co-processors. This moves th=
e code
Quoted 7 lines
Quoted 7 lines
of the cell platform so it can be used by other powerpc code.
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/include/asm/mmu-hash64.h | 2 ++
arch/powerpc/mm/copro_fault.c| 48 ++++++++++++++++++++++++++=
++++++++
Quoted 2 lines
Quoted 2 lines
arch/powerpc/mm/slb.c | 3 ---
arch/powerpc/platforms/cell/spu_base.c| 41 +++-----------------------=
---
Quoted 3 lines
arch/powerpc/inclu=
Quoted 3 lines
4 files changed, 54 insertions(+), 40 deletions(-)arch/powerpc/inclu= renamed from arch/powerpc/include/asm/mmu-hash64.h +0
-0
de/asm/mmu-hash64.h
Quoted 4 lines
arch/powerpc/include/asm/mmu-hash64.h static inline unsigned int mmu_psize_to_shift(unsig=
Quoted 4 lines
index d765144..fd19a53 100644
arch/powerpc/include/asm/mmu-hash64.h +0
-0@@ -180,6 +180,8 @@ static inline unsigned int mmu_psize_to_shift(unsig=
ned int mmu_psize)
Quoted 5 lines
arch/powerpc/include/asm/mmu-hash64.h static inline unsigned int mmu_psize_to_shift(unsigned int mmu_psize)
Quoted 5 lines
arch/powerpc/include/asm/mmu-hash64.h +2
-0* we work in all cases including 4k page size. */ #define VPN_SHIFT 12 +#define slb_vsid_shift (ssize) \ + ((ssize) =3D=3D MMU_SEGSIZE_256M ? SLB_VSID_SHIFT : SLB_VSID_SHIFT_1T=
)
Quoted 2 lines
=20
can it be static inline similar tosegment_shift()?
Yep.
Quoted 5 lines
=20
arch/powerpc/mm/copro_faul=
Quoted 4 lines
=20
/*
* HPTE Large Page (LP) detailsarch/powerpc/mm/copro_faul= renamed from arch/powerpc/mm/copro_fault.c +0
-0
t.c
Quoted 9 lines
arch/powerpc/mm/copro_fault.c out_unlock: · line 94
Quoted 9 lines
index ba7df14..4105a63 100644
arch/powerpc/mm/copro_fault.c +2
-0@@ -90,3 +90,51 @@ out_unlock:return ret; }EXPORT_SYMBOL_GPL (copro_handle_mm_fault); + +int copro_data_segment(struct mm_struct *mm, u64 ea, u64 *esid, u64 *v=
sid)
Quoted 10 lines
Quoted 10 lines
arch/powerpc/mm/copro_fault.c +10
-0+{ +int psize, ssize; + + *esid =3D (ea &ESID_MASK ) |SLB_ESID_V ; + +switch (REGION_ID (ea)) { +case USER_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- USER_REGION_ID\n" , ea); +#ifdef CONFIG_PPC_MM_SLICES + psize =3D get_slice_psize(mm, ea);
Quoted 8 lines
arch/powerpc/mm/copro_fault.c out_unlock: · line 107
Quoted 3 lines
arch/powerpc/mm/copro_fault.c +3
-0+#else + psize =3D mm->context.user_psize; +#endif =20
We don't need that.
=20
#ifdefCONFIG_PPC_STD_MMU_64
#defineget_slice_psize(mm, addr)((mm)->context.user_psize)
OK
Quoted 31 lines
=20
=20Quoted 29 lines
arch/powerpc/mm/copro_fault.c +29
-0+ ssize =3D user_segment_size(ea); + *vsid =3D (get_vsid (mm->context.id, ea, ssize) + <<slb_vsid_shift (ssize)) |SLB_VSID_USER + | (ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0); +break ; +case VMALLOC_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- VMALLOC_REGION_ID\n" , ea); +if (ea <VMALLOC_END ) + psize =3D mmu_vmalloc_psize; +else + psize =3D mmu_io_psize; + *vsid =3D (get_kernel_vsid (ea, mmu_kernel_ssize) + <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL + | (mmu_kernel_ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0); +break ; +case KERNEL_REGION_ID : +pr_devel ("copro_data_segment: 0x%llx -- KERNEL_REGION_ID\n" , ea); + psize =3D mmu_linear_psize; + *vsid =3D (get_kernel_vsid (ea, mmu_kernel_ssize) + <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL + | (mmu_kernel_ssize =3D=3D MMU_SEGSIZE_1T ? SLB_VSID_B_1T : 0); +break ; +default : +/* Future: support kernel segments so that drivers can use the +* CoProcessors */ +pr_debug ("invalid region access at %016llx\n" , ea); +return 1 ; + } + *vsid |=3D mmu_psize_defs[psize].sllp;
Quoted 8 lines
arch/powerpc/mm/copro_fault.c out_unlock: · line 139
Quoted 3 lines
arch/powerpc/mm/copro_fault.c +3
-0+ +return 0 ; +}=20
large part of this is same as what we do inhash_page. And we are not really updating vsid here, it is vsid slb encoding. So why not abstract the vsid part and use that inhash_pagealso ? That would have also taken care of the above #ifdef.
Ok, I've merge these two variants.
Going to repost this whole series again soon. I'll be in there.
Thanks for the comments.
Mikey
Quoted 7 lines
=20
arch/powerpc/mm/slb.c static inline unsigned long mk_esid_data(unsigned lon=
Quoted 6 lines
arch/powerpc/mm/copro_fault.c +1
-0+EXPORT_SYMBOL_GPL (copro_data_segment);arch/powerpc/mm/slb.c +0
-0@@ -46,9 +46,6 @@ static inline unsigned long mk_esid_data(unsigned lon=
g ea, int ssize,
Quoted 10 lines
arch/powerpc/plat=
Quoted 10 lines
arch/powerpc/mm/slb.c +0
-0return (ea &slb_esid_mask (ssize)) |SLB_ESID_V | slot; }=20
arch/powerpc/mm/slb.c +0
-3-#define slb_vsid_shift (ssize) \ - ((ssize) =3D=3D 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/plat= renamed from arch/powerpc/platforms/cell/spu_base.c +0
-0
forms/cell/spu_base.c
Quoted 4 lines
arch/powerpc/platforms/cell/spu_base.c static inline void spu_load_slb(struct spu *spu, =
Quoted 4 lines
index 2930d1e..fe004b1 100644
arch/powerpc/platforms/cell/spu_base.c +0
-0@@ -167,45 +167,12 @@ static inline void spu_load_slb(struct spu *spu, =
int slbe, struct spu_slb *slb)
Quoted 52 lines
Quoted 46 lines
=20
static int__spu_trap_data_seg(struct spu *spu, unsigned long ea){arch/powerpc/platforms/cell/spu_base.c +1
-6- struct mm_struct *mm =3D spu->mm;struct spu_slb slb; -int psize; - -pr_debug ("%s\n" , __func__); - - slb.esid =3D (ea &ESID_MASK ) |SLB_ESID_V ; +int ret;=20
arch/powerpc/platforms/cell/spu_base.c +3
-31-switch (REGION_ID (ea)) { -case USER_REGION_ID : -#ifdef CONFIG_PPC_MM_SLICES - psize =3D get_slice_psize(mm, ea); -#else - psize =3D mm->context.user_psize; -#endif - slb.vsid =3D (get_vsid (mm->context.id, ea,MMU_SEGSIZE_256M ) - <<SLB_VSID_SHIFT ) |SLB_VSID_USER ; -break ; -case VMALLOC_REGION_ID : -if (ea <VMALLOC_END ) - psize =3D mmu_vmalloc_psize; -else - psize =3D mmu_io_psize; - slb.vsid =3D (get_kernel_vsid (ea,MMU_SEGSIZE_256M ) - <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL ; -break ; -case KERNEL_REGION_ID : - psize =3D mmu_linear_psize; - slb.vsid =3D (get_kernel_vsid (ea,MMU_SEGSIZE_256M ) - <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL ; -break ; -default : -/* Future: support kernel segments so that drivers -* can use SPUs. -*/ -pr_debug ("invalid region access at %016lx\n" , ea); -return 1 ; - } - slb.vsid |=3D mmu_psize_defs[psize].sllp; + ret =3D copro_data_segment(spu->mm, ea, &slb.esid, &slb.vsid); +if (ret) +return ret;Quoted 3 lines
=20
spu_load_slb(spu, spu->slb_replace, &slb);
=20=20
-aneesh
=20
PATCH 3/15 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 can require multiple IRQs for every contexts that is attached to the accelerator. For AFU directed accelerators, 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.
--- arch/powerpc/sysdev/msi_bitmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
arch/powerpc/sysdev/msi_bitmap.c +13 -5
@@ -24,28 +24,36 @@ int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp, int num)* 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);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) {
Signature · 1 line
1.9.1
Re: [PATCH 03/15] powerpc/msi: Improve IRQ bitmap allocator
Quoted 11 lines · Michael Neuling
From: 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 can require multiple IRQs for every contexts that is attached to the accelerator. For AFU directed accelerators, there may be 1000s of contexts attached, hence we can easily run out of IRQs, especially if we are needlessly wasting them.
Quoted 8 lines
This changes the
msi_bitmap_alloc_hwirqs()to allocate only the required number of IRQs, hence avoiding this wastage.Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/sysdev/msi_bitmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
This conflicts with (and partially duplicates)
http://patchwork.ozlabs.org/patch/381892/
which I have in my tree. How should we handle it?
Laurentiu, from looking at the overlap between patches I see a problem with your existing patch, regarding the out-of-irqs path and msi_bitmap_free_hwirqs(), so one way or another that needs to get fixed soon.
-Scott
Quoted 46 lines
arch/powerpc/sysdev/msi_bitmap.c +13
-5@@ -24,28 +24,36 @@ int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp, int num)* 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);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) {
Re: [PATCH 03/15] powerpc/msi: Improve IRQ bitmap allocator
Quoted 21 lines · Scott Wood
Quoted 11 lines · Michael Neuling
From: 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 can require multiple IRQs for every contexts that is attached to the accelerator. For AFU directed accelerators, there may be 1000s of contexts attached, hence we can easily run out of IRQs, especially if we are needlessly wasting them.
Quoted 8 lines
This changes the
msi_bitmap_alloc_hwirqs()to allocate only the required number of IRQs, hence avoiding this wastage.Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/sysdev/msi_bitmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
Quoted 8 lines
This conflicts with (and partially duplicates)
http://patchwork.ozlabs.org/patch/381892/
which I have in my tree. How should we handle it?Laurentiu, from looking at the overlap between patches I see a problem with your existing patch, regarding the out-of-irqs path and
msi_bitmap_free_hwirqs(), so one way or another that needs to get fixed soon.
Given the problems with Laurentiu's patch, perhaps it'd be best for me to just revert that patch in my tree, and respin it after this patchset has been merged.
-Scott
Re: [PATCH 03/15] powerpc/msi: Improve IRQ bitmap allocator
Quoted 26 lines · Scott Wood
Quoted 25 lines · Scott Wood
Quoted 11 lines · Michael Neuling
From: 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 can require multiple IRQs for every contexts that is attached to the accelerator. For AFU directed accelerators, there may be 1000s of contexts attached, hence we can easily run out of IRQs, especially if we are needlessly wasting them.
Quoted 8 lines
This changes the
msi_bitmap_alloc_hwirqs()to allocate only the required number of IRQs, hence avoiding this wastage.Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/sysdev/msi_bitmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)This conflicts with (and partially duplicates)
http://patchwork.ozlabs.org/patch/381892/
which I have in my tree. How should we handle it?
Quoted 8 lines
Quoted 4 lines
Laurentiu, from looking at the overlap between patches I see a problem with your existing patch, regarding the out-of-irqs path and
msi_bitmap_free_hwirqs(), so one way or another that needs to get fixed soon.Given the problems with Laurentiu's patch, perhaps it'd be best for me to just revert that patch in my tree, and respin it after this patchset has been merged.
Let me know if you want me to rebase my stuff on top of Michael's patch.
---
Best Regards, Laurentiu
Re: [PATCH 03/15] powerpc/msi: Improve IRQ bitmap allocator
Quoted 32 lines · Laurentiu Tudor
Quoted 31 lines · Scott Wood
Quoted 29 lines · Scott Wood
Quoted 11 lines · Michael Neuling
From: 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 can require multiple IRQs for every contexts that is attached to the accelerator. For AFU directed accelerators, there may be 1000s of contexts attached, hence we can easily run out of IRQs, especially if we are needlessly wasting them.
Quoted 8 lines
This changes the
msi_bitmap_alloc_hwirqs()to allocate only the required number of IRQs, hence avoiding this wastage.Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/sysdev/msi_bitmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)This conflicts with (and partially duplicates)
http://patchwork.ozlabs.org/patch/381892/
which I have in my tree. How should we handle it?Laurentiu, from looking at the overlap between patches I see a problem with your existing patch, regarding the out-of-irqs path and
msi_bitmap_free_hwirqs(), so one way or another that needs to get fixed soon.
Quoted 5 lines
Quoted 3 lines
Given the problems with Laurentiu's patch, perhaps it'd be best for me to just revert that patch in my tree, and respin it after this patchset has been merged.
Let me know if you want me to rebase my stuff on top of Michael's patch.
Yes, please resend it once Michael's patch gets merged.
-Scott
Re: [PATCH 03/15] powerpc/msi: Improve IRQ bitmap allocator
In reply to Scott WoodQuoted 21 lines · Scott Wood
Quoted 11 lines · Michael Neuling
From: 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 can require multiple IRQs for every contexts that is attached to the accelerator. For AFU directed accelerators, there may be 1000s of contexts attached, hence we can easily run out of IRQs, especially if we are needlessly wasting them.
Quoted 8 lines
This changes the
msi_bitmap_alloc_hwirqs()to allocate only the required number of IRQs, hence avoiding this wastage.Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/sysdev/msi_bitmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
Quoted 9 lines
This conflicts with (and partially duplicates)
http://patchwork.ozlabs.org/patch/381892/
which I have in my tree. How should we handle it?Laurentiu, from looking at the overlap between patches I see a problem with your existing patch, regarding the out-of-irqs path and
msi_bitmap_free_hwirqs(), so one way or another that needs to get fixed soon.
Agree. My patch lacks error checking so Michael's patch is better.
---
Best Regards, Laurentiu
Quoted 49 lines
Quoted 47 lines
arch/powerpc/sysdev/msi_bitmap.c +13
-5@@ -24,28 +24,36 @@ int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp, int num)* 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);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) {
Re: [PATCH 03/15] powerpc/msi: Improve IRQ bitmap allocator
In reply to Michael NeulingHi Michael,
Minor comment inline.
Quoted 25 lines · Michael Neuling
From: 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 can require multiple IRQs for every contexts that is attached to the accelerator. For AFU directed accelerators, 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.Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/sysdev/msi_bitmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)arch/powerpc/sysdev/msi_bitmap.c +0
-0
arch/powerpc/sysdev/msi_bitmap.c int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp, int num) · line 26
Quoted 3 lines
arch/powerpc/sysdev/msi_bitmap.c +0
-0@@ -24,28 +24,36 @@ int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp, int num)* This is fast, but stricter than we need. We might want to add * a fallback routine which does a linear search with no alignment. */
Is this comment still relevant (especially the part mentioning "fast")?
---
Best Regards, Laurentiu
Re: [PATCH 03/15] powerpc/msi: Improve IRQ bitmap allocator
Quoted 1 line
arch/powerpc/sysdev/msi=
Quoted 1 line
arch/powerpc/sysdev/msi= renamed from arch/powerpc/sysdev/msi_bitmap.c +0
-0
_bitmap.c
Quoted 4 lines
arch/powerpc/sysdev/msi_bitmap.c int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp,=
Quoted 4 lines
index 2ff6302..e001559 100644
arch/powerpc/sysdev/msi_bitmap.c +0
-0@@ -24,28 +24,36 @@ int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp,=
int num)
Quoted 5 lines
arch/powerpc/sysdev/msi_bitmap.c int msi_bitmap_alloc_hwirqs(struct msi_bitmap *bmp, int num) · line 26
Quoted 3 lines
arch/powerpc/sysdev/msi_bitmap.c +0
-0* This is fast, but stricter than we need. We might want to add * a fallback routine which does a linear search with no alignment. */ =20
Is this comment still relevant (especially the part mentioning "fast")?
You're right, it's not really relevant any more. I'll remove.
Thanks
Mikey
PATCH 4/15 powerpc/mm: Export mmu_kernel_ssize and mmu_linear_psize
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
--- 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 5/15 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 | 43 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +25 -18
@@ -1306,14 +1306,36 @@ 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; + +/* +* 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); + } +} +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 +1387,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
Re: [PATCH 05/15] powerpc/powernv: Split out set MSI IRQ chip code
Quoted 35 lines · Michael Neuling
From: 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.
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>---
arch/powerpc/platforms/powernv/pci-ioda.c| 43 ++++++++++++++++++-------------1 file changed, 25 insertions(+), 18 deletions(-)arch/powerpc/platforms/powernv/pci-ioda.c +14
-0@@ -1306,14 +1306,36 @@ 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; + +/* +* 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);
arch/powerpc/platforms/powernv/pci-ioda.c static void pnv_ioda2_msi_eoi(struct irq_data *d) · line 1332
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10
-0+ 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); + } +} +
Nitpick: to check PHB type and bail early could avoid nested code :)
if (phb->type != PNV_PHB_IODA2) return;
Quoted 25 lines
arch/powerpc/platforms/powernv/pci-ioda.c +0
-12static 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 +1387,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 ;
arch/powerpc/platforms/powernv/pci-ioda.c static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev, · line 1393
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +1
-6- 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",
Thanks,
Gavin
Re: [PATCH 05/15] powerpc/powernv: Split out set MSI IRQ chip code
Quoted 26 lines
Quoted 13 lines
arch/powerpc/platforms/powernv/pci-ioda.c +13
-0+static void set_msi_irq_chip (struct pnv_phb *phb,unsigned int virq) +{ +struct irq_data *idata; +struct irq_chip *ichip; + +/* +* Change the IRQ chip for the MSI interrupts on PHB3. +* The corresponding IRQ chip should be populated for +* the first time. +*/ + if (phb->type =3D=3D PNV_PHB_IODA2) { +if (!phb->ioda.irq_chip_init) { + idata =3D irq_get_irq_data(virq);arch/powerpc/platforms/powernv/pci-ioda.c static void pnv_ioda2_msi_eoi(struct irq_data *d) · line 1332
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10
-0+ ichip =3D irq_data_get_irq_chip(idata); + phb->ioda.irq_chip_init =3D 1; + phb->ioda.irq_chip =3D *ichip; + phb->ioda.irq_chip.irq_eoi =3D pnv_ioda2_msi_eoi; + } + +irq_set_chip (virq, &phb->ioda.irq_chip); + } +} +=20
Nitpick: to check PHB type and bail early could avoid nested code :) =20
Quoted 2 lines
if (phb->type !=3D PNV_PHB_IODA2) return;
OK, will do in repost.
Thanks,
Mikey
PATCH 6/15 cxl: Add new header for call backs and structs
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
This new header add defines for callbacks and structs needed by the rest of the kernel to hook into the cxl infrastructure.
Empty functions are provided when CONFIG CXL_BASE is not enabled.
--- include/misc/cxl.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 include/misc/cxl.h
include/misc/cxl.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* 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_ASM_CXL_H +#define _MISC_ASM_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 + +void cxl_slbia (struct mm_struct *mm); +void cxl_ctx_get (void ); +void cxl_ctx_put (void ); +bool cxl_ctx_in_use (void ); + +#else /* CONFIG_CXL_BASE */ + +#define cxl_slbia (...) do { } while (0) +#define cxl_ctx_in_use (...) false + +#endif /* CONFIG_CXL_BASE */ + +#endif
Signature · 1 line
1.9.1
PATCH 7/15 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 | 186 ++++++++++++++++++++++++++++++ 2 files changed, 213 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 +186 -0
204 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH 07/15] powerpc/powerpc: Add new PCIe functions for allocating cxl interrupts
Quoted 75 lines · Michael Neuling
From: Ian Munsie <[email protected]>
This adds a number of functions for allocating IRQs under powernv PCIe for cxl.
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>---
arch/powerpc/include/asm/pnv-pci.h| 27 +++++arch/powerpc/platforms/powernv/pci-ioda.c| 186 ++++++++++++++++++++++++++++++2 files changed, 213 insertions(+)create mode 100644
arch/powerpc/include/asm/pnv-pci.harch/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 +15
-0@@ -38,6 +38,8 @@#include <asm/debug.h> #include <asm/firmware.h> +#include <misc/cxl.h> +#include "powernv.h" #include "pci.h" @@ -503,6 +505,163 @@ static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev)return NULL ;return &phb->ioda.pe_array[pdn->pe_number]; } + +struct device_node *pnv_pci_to_phb_node (struct pci_dev *dev) +{ +struct device_node *np; +struct property *prop =NULL ; + + np =of_node_get (pci_device_to_OF_node (dev)); + +/* Scan up the tree looking for the PHB node */ +while (np) { +if ((prop =of_find_property (np,"ibm,opal-phbid" ,NULL ))) +break ; + np =of_get_next_parent (np);
arch/powerpc/platforms/powernv/pci-ioda.c static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev) · line 530
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10
-0+ } + +if (!prop) { +of_node_put (np); +return NULL ; + } + +return np; +} +EXPORT_SYMBOL (pnv_pci_to_phb_node);
Nitpick: I'm not sure it's better way. "struct pci_controller::dn" should always have valid "ibm,opal-phbid", so I guess the code could be like this way:
struct pci_controller *hose = pci_bus_to_host(dev->bus); return hose->dn;
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10
-0+ +#ifdef CONFIG_CXL_BASE +int pnv_phb_to_cxl (struct pci_dev *dev) +{ +struct device_node *np; +struct pnv_ioda_pe *pe; +const u64 *prop64; +u64 phb_id; +int rc; +
arch/powerpc/platforms/powernv/pci-ioda.c static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev) · line 550
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10
-0+dev_info (&dev->dev,"switch PHB to CXL\n" ); + +if (!(np =pnv_pci_to_phb_node (dev))) +return -ENODEV ; + + prop64 =of_get_property (np,"ibm,opal-phbid" ,NULL ); + + phb_id =be64_to_cpup (prop64); +dev_info (&dev->dev,"PHB-ID : 0x%016llx\n" , phb_id); +
The PHB ID would have been there: struct pnv_phb::opal_id. So I guess we needn't grab it from device-tree again :)
arch/powerpc/platforms/powernv/pci-ioda.c static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev) · line 555
Quoted 5 lines
arch/powerpc/platforms/powernv/pci-ioda.c +5
-0+if (!(pe =pnv_ioda_get_pe (dev))) { + rc = -ENODEV ; + goto out; + } +dev_info (&dev->dev," pe : %i\n" , pe->pe_number);
Perhaps you can reuse pe_info() here.
Quoted 126 lines
arch/powerpc/platforms/powernv/pci-ioda.c +119
-0+ +if ((rc =opal_pci_set_phb_cxl_mode (phb_id,1 , pe->pe_number))) +dev_err (&dev->dev,"opal_pci_set_phb_cxl_mode failed: %i\n" , rc); + +out: +of_node_put (np); +return rc; +} +EXPORT_SYMBOL (pnv_phb_to_cxl); + +int pnv_cxl_alloc_hwirqs (struct pci_dev *dev,int num) +{ +struct pci_controller *hose =pci_bus_to_host (dev->bus); +struct pnv_phb *phb = hose->private_data; +int hwirq =msi_bitmap_alloc_hwirqs (&phb->msi_bmp, num); + +if (hwirq <0 ) { +dev_warn (&dev->dev,"Failed to find a free MSI\n" ); +return -ENOSPC ; + } + +return phb->msi_base + hwirq; +} +EXPORT_SYMBOL (pnv_cxl_alloc_hwirqs); + +void pnv_cxl_release_hwirqs (struct pci_dev *dev,int hwirq,int num) +{ +struct pci_controller *hose =pci_bus_to_host (dev->bus); +struct pnv_phb *phb = hose->private_data; + +msi_bitmap_free_hwirqs (&phb->msi_bmp, hwirq - phb->msi_base, num); +} +EXPORT_SYMBOL (pnv_cxl_release_hwirqs); + + +int pnv_cxl_alloc_hwirq_ranges (struct cxl_irq_ranges *irqs, +struct pci_dev *dev,int num) +{ +struct pci_controller *hose =pci_bus_to_host (dev->bus); +struct pnv_phb *phb = hose->private_data; +int range =0 ; +int hwirq; +int try; + +memset (irqs,0 ,sizeof (struct cxl_irq_ranges )); + +for (range =1 ; range <CXL_IRQ_RANGES && num; range++) { + try = num; +while (try) { + hwirq =msi_bitmap_alloc_hwirqs (&phb->msi_bmp, try); +if (hwirq >=0 ) +break ; + try /=2 ; + } +if (!try) + goto fail; + + irqs->offset[range] = phb->msi_base + hwirq; + irqs->range[range] = try; +pr_devel ("cxl alloc irq range 0x%x: offset: 0x%lx limit: %li\n" , + range, irqs->offset[range], irqs->range[range]); + num -= try; + } +if (num) + goto fail; + +return 0 ; +fail: +for (range--; range >=0 ; range--) { + hwirq = irqs->offset[range] - phb->msi_base; +msi_bitmap_free_hwirqs (&phb->msi_bmp, hwirq, + irqs->range[range]); + irqs->range[range] =0 ; + } +return -ENOSPC ; +} +EXPORT_SYMBOL (pnv_cxl_alloc_hwirq_ranges); + +void pnv_cxl_release_hwirq_ranges (struct cxl_irq_ranges *irqs, +struct pci_dev *dev) +{ +struct pci_controller *hose =pci_bus_to_host (dev->bus); +struct pnv_phb *phb = hose->private_data; +int range =0 ; +int hwirq; + +for (range =0 ; range <4 ; range++) { + hwirq = irqs->offset[range] - phb->msi_base; +if (irqs->range[range]) { +pr_devel ("cxl release irq range 0x%x: offset: 0x%lx limit: %ld\n" , + range, irqs->offset[range], + irqs->range[range]); +msi_bitmap_free_hwirqs (&phb->msi_bmp, hwirq, + irqs->range[range]); + } + } +} +EXPORT_SYMBOL (pnv_cxl_release_hwirq_ranges); + +int pnv_cxl_get_irq_count (struct pci_dev *dev) +{ +struct pci_controller *hose =pci_bus_to_host (dev->bus); +struct pnv_phb *phb = hose->private_data; + +return phb->msi_bmp.irq_count; +} +EXPORT_SYMBOL (pnv_cxl_get_irq_count); + +#endif /* CONFIG_CXL_BASE */ #endif /* CONFIG_PCI_MSI */ static int pnv_ioda_configure_pe (struct pnv_phb *phb,struct pnv_ioda_pe *pe)@@ -1330,6 +1489,33 @@ static void set_msi_irq_chip(struct pnv_phb *phb, unsigned int virq) } } +#ifdef CONFIG_CXL_BASE +int pnv_cxl_ioda_msi_setup (struct pci_dev *dev,unsigned int hwirq, +unsigned int virq) +{ +struct pci_controller *hose =pci_bus_to_host (dev->bus); +struct pnv_phb *phb = hose->private_data; +unsigned int xive_num = hwirq - phb->msi_base; +struct pnv_ioda_pe *pe; +int rc; +
arch/powerpc/platforms/powernv/pci-ioda.c static void set_msi_irq_chip(struct pnv_phb *phb, unsigned int virq) · line 1511
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10
-0+if (!(pe =pnv_ioda_get_pe (dev))) +return -ENODEV ; + +/* Assign XIVE to PE */ + rc =opal_pci_set_xive_pe (phb->opal_id, pe->pe_number, xive_num); +if (rc) { +pr_warn ("%s: OPAL error %d setting msi_base 0x%x hwirq 0x%x XIVE 0x%x PE\n" , +pci_name (dev), rc, phb->msi_base, hwirq, xive_num); +return -EIO ; + }
It seems current firmware doesn't support the OPAL API for PHB3.
arch/powerpc/platforms/powernv/pci-ioda.c static void set_msi_irq_chip(struct pnv_phb *phb, unsigned int virq) · line 1521
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +7
-0+set_msi_irq_chip (phb, virq); + + return 0; +} +EXPORT_SYMBOL (pnv_cxl_ioda_msi_setup); +#endif +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)
Thanks,
Gavin
Quoted 7 lines
Signature · 6 lines
1.9.1 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 07/15] powerpc/powerpc: Add new PCIe functions for allocating cxl interrupts
<snip>
Quoted 17 lines
Quoted 17 lines
arch/powerpc/platforms/powernv/pci-ioda.c +17
-0+struct device_node *pnv_pci_to_phb_node (struct pci_dev *dev) +{ +struct device_node *np; + struct property *prop =3D NULL; + + np =3D of_node_get(pci_device_to_OF_node(dev)); + +/* Scan up the tree looking for the PHB node */ +while (np) { + if ((prop =3D of_find_property(np, "ibm,opal-phbid", NULL))) +break ; + np =3D of_get_next_parent(np); + } + +if (!prop) { +of_node_put (np); +return NULL ;
Quoted 8 lines
arch/powerpc/platforms/powernv/pci-ioda.c static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev) · line 530
Quoted 5 lines
arch/powerpc/platforms/powernv/pci-ioda.c +5
-0+ } + +return np; +} +EXPORT_SYMBOL (pnv_pci_to_phb_node);=20
Nitpick: I'm not sure it's better way. "structpci_controller::dn" should always have valid "ibm,opal-phbid", so I guess the code could be like thi=
s
Quoted 5 lines
way:
=20struct pci_controller *hose =3D pci_bus_to_host(dev->bus); =20 return hose->dn;
Nice.. that makes it much simpler. I'll update.
<snip>
Quoted 15 lines
Quoted 15 lines
arch/powerpc/platforms/powernv/pci-ioda.c +15
-0+ +#ifdef CONFIG_CXL_BASE +int pnv_phb_to_cxl (struct pci_dev *dev) +{ +struct device_node *np; +struct pnv_ioda_pe *pe; +const u64 *prop64; +u64 phb_id; +int rc; + +dev_info (&dev->dev,"switch PHB to CXL\n" ); + + if (!(np =3D pnv_pci_to_phb_node(dev))) +return -ENODEV ; +
Quoted 8 lines
arch/powerpc/platforms/powernv/pci-ioda.c static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev) · line 550
Quoted 5 lines
arch/powerpc/platforms/powernv/pci-ioda.c +5
-0+ prop64 =3D of_get_property(np, "ibm,opal-phbid", NULL); + + phb_id =3D be64_to_cpup(prop64); +dev_info (&dev->dev,"PHB-ID : 0x%016llx\n" , phb_id); +=20
The PHB ID would have been there: structpnv_phb::opal_id. So I guess we needn't grab it from device-tree again :)
Nice, I'll update.
Quoted 7 lines
arch/powerpc/platforms/powernv/pci-ioda.c static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev) · line 555
Quoted 5 lines
arch/powerpc/platforms/powernv/pci-ioda.c +5
-0+ if (!(pe =3D pnv_ioda_get_pe(dev))) { + rc =3D -ENODEV ; + goto out; + } +dev_info (&dev->dev," pe : %i\n" , pe->pe_number);=20
Perhaps you can reusepe_info()here.
Yep, will do.
<snip>
Quoted 9 lines
Quoted 9 lines
arch/powerpc/platforms/powernv/pci-ioda.c +9
-0+#ifdef CONFIG_CXL_BASE +int pnv_cxl_ioda_msi_setup (struct pci_dev *dev,unsigned int hwirq, +unsigned int virq) +{ + struct pci_controller *hose =3D pci_bus_to_host(dev->bus); + struct pnv_phb *phb =3D hose->private_data; + unsigned int xive_num =3D hwirq - phb->msi_base; +struct pnv_ioda_pe *pe; +int rc;
Quoted 8 lines
arch/powerpc/platforms/powernv/pci-ioda.c static void set_msi_irq_chip(struct pnv_phb *phb, unsigned int virq)
Quoted 8 lines
arch/powerpc/platforms/powernv/pci-ioda.c +8
-0+ + if (!(pe =3D pnv_ioda_get_pe(dev))) +return -ENODEV ; + +/* Assign XIVE to PE */ + rc =3D opal_pci_set_xive_pe(phb->opal_id, pe->pe_number, xive_num); +if (rc) { + pr_warn("%s: OPAL error %d setting msi_base 0x%x hwirq 0x%x XIVE 0x%x=
PE\n",
Quoted 5 lines
arch/powerpc/platforms/powernv/pci-ioda.c static void set_msi_irq_chip(struct pnv_phb *phb, unsigned int virq) · line 1511
Quoted 3 lines
arch/powerpc/platforms/powernv/pci-ioda.c +3
-0+ pci_name(dev), rc, phb->msi_base, hwirq, xive_num); +return -EIO ; + }=20
It seems current firmware doesn't support the OPAL API for PHB3.
The current public version of skiboot seems to be doing something here in hw/phb3.c in phb3_set_ive_pe():
https://github.com/open-power/skiboot/blob/c34c4ef8c660e3e439365c8f5c06143f=
f00bc6bc/hw/phb3.c#L1096
I think we still need this.
Thanks again!
Mikey
PATCH 8/15 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 | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/mmu-hash64.h +1 -0
@@ -319,6 +319,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 +13 -7
@@ -991,26 +991,24 @@ 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;int rc, user_region =0 , local =0 ;int psize, ssize; -DBG_LOW ("hash_page(ea=%016lx, access=%lx, trap=%lx\n" , - ea, access, trap); +DBG_LOW ("%s(ea=%016lx, access=%lx, trap=%lx\n" , + __func__, ea, access, trap);/* Get region & vsid */ 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 ;
@@ -1106,7 +1104,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; }
@@ -1149,7 +1148,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
@@ -1184,6 +1184,12 @@ 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) +{ +return hash_page_mm (current->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
Re: [PATCH 08/15] powerpc/mm: Add new hash_page_mm()
Quoted 9 lines · Michael Neuling
From: Ian Munsie <[email protected]>
This adds a new function
hash_page_mm()based on the existinghash_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.
Can you also explain calling semantics. ie, why would we want to call this with anything other than current ? Should we flush slb now or should it be skipped ? so what would happen if the new hash page can result in segment demotion ? You don't put that under if (mm == current->mm). is that ok ?
if ((pte_val(*ptep) & _PAGE_4K_PFN) && psize == MMU_PAGE_64K) {
demote_segment_4k(mm, ea);
psize = MMU_PAGE_4K;
}We also update paca context there
if (get_paca_psize(addr) != MMU_PAGE_4K) {
get_paca()->context = mm->context;
slb_flush_and_rebolt();
}You also added code to handle KERNEL_REGION_ID in
[PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform. do we need to handle that here ?
Quoted 95 lines
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/include/asm/mmu-hash64.h | 1 + arch/powerpc/mm/hash_utils_64.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-)arch/powerpc/include/asm/mmu-hash64.h +1
-0@@ -319,6 +319,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 +13
-7@@ -991,26 +991,24 @@ 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;int rc, user_region =0 , local =0 ;int psize, ssize; -DBG_LOW ("hash_page(ea=%016lx, access=%lx, trap=%lx\n" , - ea, access, trap); +DBG_LOW ("%s(ea=%016lx, access=%lx, trap=%lx\n" , + __func__, ea, access, trap);/* Get region & vsid */ 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 ;@@ -1106,7 +1104,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; }@@ -1149,7 +1148,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 @@ -1184,6 +1184,12 @@ 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) +{ +return hash_page_mm (current->mm, ea, access, trap); +}EXPORT_SYMBOL_GPL (hash_page); void hash_preload(struct mm_struct *mm, unsigned long ea,Signature · 7 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 08/15] powerpc/mm: Add new hash_page_mm()
Quoted 4 lines
Quoted 4 lines
You also added code to handle
KERNEL_REGION_IDin
[PATCH 02/15] powerpc/cell: Move data segment faulting code out of cell platform. do we need to handle that here ?
=20
(Sorry missed this on my other reply...)
I've refactored that code now so it should be handled in the vsid calculation. It's not my strong area so you might wanna check on repost.
Thanks again.
Mikey
PATCH 9/15 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
Re: [PATCH 09/15] powerpc/opal: Add PHB to cxl mode call
Quoted 6 lines
From: Ian Munsie <[email protected]>
This adds the OPAL call to change a PHB into cxl mode.
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>
PATCH 10/15 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/hash_native_64.c | 6 +++++- arch/powerpc/mm/hash_utils_64.c | 3 +++ arch/powerpc/mm/slice.c | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-)
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)
arch/powerpc/mm/hash_utils_64.c +3 -0
@@ -34,6 +34,7 @@#include <linux/signal.h> #include <linux/memblock.h> #include <linux/context_tracking.h> +#include <misc/cxl.h> #include <asm/processor.h> #include <asm/pgtable.h>
@@ -906,6 +907,7 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr)#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm);if (get_paca_psize (addr) !=MMU_PAGE_4K ) {get_paca ()->context = mm->context;slb_flush_and_rebolt ();
@@ -1145,6 +1147,7 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea, unsigned long access, u#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm); } }
arch/powerpc/mm/slice.c +3 -0
@@ -30,6 +30,7 @@#include <linux/err.h> #include <linux/spinlock.h> #include <linux/export.h> +#include <misc/cxl.h> #include <asm/mman.h> #include <asm/mmu.h> #include <asm/spu.h>
@@ -235,6 +236,7 @@ static void slice_convert(struct mm_struct *mm, struct slice_mask mask, int psiz#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm); }/*
@@ -674,6 +676,7 @@ void slice_set_psize(struct mm_struct *mm, unsigned long address,#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm); } void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
Signature · 1 line
1.9.1
Re: [PATCH 10/15] powerpc/mm: Add hooks for cxl
Quoted 17 lines
From: 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.
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>
arch/powerpc/mm/hash_native_64.c static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize) · line 157
Quoted 1 line
arch/powerpc/mm/hash_native_64.c +1
-0+ use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL ) && !cxl_ctx_in_use ();
Seems reasonable until we can get the MMIO based optimisation in.
Will all CAPI cached translations be invalidated before we finish using a CAPI context? And conversely, could CAPI cache any translations when a context isn't active? I'm mostly concerned that we can't have a situation where badly behaving userspace could result in a stale translation.
Quoted 5 lines
(quoted diff) +1
-0spu_flush_all_slbs(mm); #endif + cxl_slbia(mm); spu_flush_all_slbs(mm);
Review
Quoted 10 lines
(quoted diff) +3
-0#endif + cxl_slbia(mm); spu_flush_all_slbs(mm); #endif + cxl_slbia(mm); spu_flush_all_slbs(mm); #endif + cxl_slbia(mm);
Should we combine the SPU vs CXL callouts into something common - perhaps copro_flush_all_slbs()?
Anton
Re: [PATCH 10/15] powerpc/mm: Add hooks for cxl
Quoted 16 lines · Anton Blanchard
Quoted 14 lines
From: Ian Munsie <[email protected]>
=20
This add a hook intotlbie()so that we use global invalidations when there are cxl contexts active.
=20
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 maketlbie()local mode smarter so that it invalidates cxl contexts explicitly when it needs to.
=20
This also adds a hooks for when SLBs are invalidated to ensure any corresponding SLBs in cxl are also invalidated at the same time. =20Quoted 2 lines
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>
Quoted 2 lines
=20
Review
Quoted 1 line
(quoted diff) +1
-0+ use_local =3D local && mmu_has_feature(MMU_FTR_TLBIEL) && !cxl_ctx_in=
_use();
Quoted 5 lines
=20
Seems reasonable until we can get the MMIO based optimisation in. =20
Will all CAPI cached translations be invalidated before we finish using a CAPI context?=20
I'm not sure I understand. Can you elaborate?
Quoted 2 lines
And conversely, could CAPI cache any translations when a context isn't active?=20
The kernel invalidates all translations when the file descriptor is closed. So no, unless the PSL was badly behaving and ignoring the invalidations.... but if we can't trust the PSL we're screwed.
Quoted 3 lines
I'm mostly concerned that we can't have a
situation where badly behaving userspace could result in a stale translation.
We only map what a user processes maps and we tear it down when the process is teared down (on the file descriptor release). So I think we are ok. =20
Unless there's some lazy teardown you're alluding to that I'm missing?
Quoted 13 lines
=20
arch/powerpc/mm/hash_utils_64.c void demote_segment_4k(struct mm_struct *mm, unsigned long addr) · line 910
Quoted 3 lines
arch/powerpc/mm/hash_utils_64.c +1
-0spu_flush_all_slbs (mm);#endif +cxl_slbia (mm);=20
arch/powerpc/mm/hash_utils_64.c void demote_segment_4k(struct mm_struct *mm, unsigned long addr) · line 910
Quoted 3 lines
arch/powerpc/mm/hash_utils_64.c +1
-0spu_flush_all_slbs (mm);#endif +cxl_slbia (mm);=20
arch/powerpc/mm/hash_utils_64.c void demote_segment_4k(struct mm_struct *mm, unsigned long addr) · line 910
Quoted 3 lines
arch/powerpc/mm/hash_utils_64.c +1
-0spu_flush_all_slbs (mm);#endif +cxl_slbia (mm);=20
Quoted 6 lines
arch/powerpc/mm/hash_utils_64.c void demote_segment_4k(struct mm_struct *mm, unsigned long addr) · line 910
Quoted 3 lines
arch/powerpc/mm/hash_utils_64.c +1
-0spu_flush_all_slbs (mm);#endif +cxl_slbia (mm);=20
Should we combine the SPU vs CXL callouts into something common - perhapscopro_flush_all_slbs()?
Sounds good. I'll update.
Mikey
Re: [PATCH 10/15] powerpc/mm: Add hooks for cxl
Hi Mikey,
Quoted 5 lines
We only map what a user processes maps and we tear it down when the process is teared down (on the file descriptor release). So I think we are ok.
Unless there's some lazy teardown you're alluding to that I'm missing?
I was trying to make sure things like the TLB batching code won't allow a tlbie to be postponed until after a CAPI mapping is destroyed. It's been ages since I looked at that part of the mm code.
Anton
Re: [PATCH 10/15] powerpc/mm: Add hooks for cxl
In reply to Michael NeulingQuoted 5 lines · Michael Neuling
From: Ian Munsie <[email protected]>
This add a hook into
tlbie()so that we use global invalidations when there are cxl contexts active.
Quoted 7 lines
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.
We are not really invalidating cx1 SLB's when we are doing slb_flush_and_rebolt(). May be add some code documentation around to explain when we are invalidating cx1 slb here. ?
Quoted 99 lines
Signed-off-by Ian Munsie <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/mm/hash_native_64.c | 6 +++++- arch/powerpc/mm/hash_utils_64.c | 3 +++ arch/powerpc/mm/slice.c | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-)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)arch/powerpc/mm/hash_utils_64.c +3
-0@@ -34,6 +34,7 @@#include <linux/signal.h> #include <linux/memblock.h> #include <linux/context_tracking.h> +#include <misc/cxl.h> #include <asm/processor.h> #include <asm/pgtable.h> @@ -906,6 +907,7 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr)#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm);if (get_paca_psize (addr) !=MMU_PAGE_4K ) {get_paca ()->context = mm->context;slb_flush_and_rebolt ();@@ -1145,6 +1147,7 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea, unsigned long access, u#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm); } }arch/powerpc/mm/slice.c +3
-0@@ -30,6 +30,7 @@#include <linux/err.h> #include <linux/spinlock.h> #include <linux/export.h> +#include <misc/cxl.h> #include <asm/mman.h> #include <asm/mmu.h> #include <asm/spu.h> @@ -235,6 +236,7 @@ static void slice_convert(struct mm_struct *mm, struct slice_mask mask, int psiz#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm); }/* @@ -674,6 +676,7 @@ void slice_set_psize(struct mm_struct *mm, unsigned long address,#ifdef CONFIG_SPU_BASE spu_flush_all_slbs (mm);#endif +cxl_slbia (mm); } void slice_set_range_psize(struct mm_struct *mm, unsigned long start,Signature · 7 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
PATCH 11/15 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.
--- arch/powerpc/mm/Makefile | 1 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/cxl/Kconfig | 7 ++++ drivers/misc/cxl/Makefile | 1 + drivers/misc/cxl/base.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 drivers/misc/cxl/Kconfig create mode 100644 drivers/misc/cxl/Makefile create mode 100644 drivers/misc/cxl/base.c
arch/powerpc/mm/Makefile +1 -0
@@ -35,3 +35,4 @@ obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage-prot.o obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_SPU_BASE) += copro_fault.o +obj-$(CONFIG_CXL_BASE) += copro_fault.o
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 +7 -0
@@ -0,0 +1,7 @@ +# +# IBM Coherent Accelerator (CXL) compatible devices +# + +config CXL_BASE + bool + default n
drivers/misc/cxl/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_CXL_BASE) += base.o
drivers/misc/cxl/base.c new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 12/15 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 (no guest support). It allows access to cxl accelerators by userspace using /dev/cxl/afu0.0 char device.
The kernel driver has no knowledge of the acceleration function. It only provides services to userspace via the /dev/cxl/afu0.0 device.
This will compile to two modules. cxl.ko provides the core cxl functionality and userspace API. cxl-pci.ko provides the PCI driver driver functionality the powernv environment.
Documentation of the cxl hardware architecture and userspace API is provided in subsequent patches.
--- drivers/misc/cxl/context.c | 169 ++++++++ drivers/misc/cxl/cxl-pci.c | 977 +++++++++++++++++++++++++++++++++++++++++++++ drivers/misc/cxl/cxl.h | 605 ++++++++++++++++++++++++++++ drivers/misc/cxl/debugfs.c | 116 ++++++ drivers/misc/cxl/fault.c | 298 ++++++++++++++ drivers/misc/cxl/file.c | 503 +++++++++++++++++++++++ drivers/misc/cxl/irq.c | 405 +++++++++++++++++++ drivers/misc/cxl/main.c | 238 +++++++++++ drivers/misc/cxl/native.c | 649 ++++++++++++++++++++++++++++++ drivers/misc/cxl/sysfs.c | 348 ++++++++++++++++ 10 files changed, 4308 insertions(+) create mode 100644 drivers/misc/cxl/context.c create mode 100644 drivers/misc/cxl/cxl-pci.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/sysfs.c
drivers/misc/cxl/context.c new file +169 -0
@@ -0,0 +1,169 @@ +/* +* 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_t *cxl_context_alloc (void ) +{ +return kzalloc (sizeof (struct cxl_context_t ),GFP_KERNEL ); +} + +/* +* Initialises a CXL context. +*/ +int cxl_context_init (struct cxl_context_t *ctx,struct cxl_afu_t *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; + + 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->ph = 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_t *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->ph , 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_t *ctx) +{ +unsigned long flags; +enum cxl_context_status status; + +spin_lock_irqsave (&ctx->sst_lock, flags); + status = ctx->status; + ctx->status =CLOSED ; +spin_unlock_irqrestore (&ctx->sst_lock, flags); +if (status !=STARTED ) +return ; + +WARN_ON (cxl_ops->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_t *ctx) +{ +__detach_context (ctx); +} + +/* +* Detach all contexts on the given AFU. +*/ +void cxl_context_detach_all (struct cxl_afu_t *afu) +{ +struct cxl_context_t *ctx; +int tmp; + +rcu_read_lock (); +idr_for_each_entry (&afu->contexts_idr, ctx, tmp) +__detach_context (ctx); +rcu_read_unlock (); +} +EXPORT_SYMBOL (cxl_context_detach_all); + +void cxl_context_free (struct cxl_context_t *ctx) +{ +unsigned long flags; + +idr_remove (&ctx->afu->contexts_idr, ctx->ph); +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-pci.c new file +977 -0
977 lines not on this page · raw message
drivers/misc/cxl/cxl.h new file +605 -0
605 lines not on this page · raw message
drivers/misc/cxl/debugfs.c new file +116 -0
116 lines not on this page · raw message
drivers/misc/cxl/fault.c new file +298 -0
298 lines not on this page · raw message
drivers/misc/cxl/file.c new file +503 -0
503 lines not on this page · raw message
drivers/misc/cxl/irq.c new file +405 -0
332 lines not on this page · raw message
drivers/misc/cxl/main.c new file +238 -0
238 lines not on this page · raw message
drivers/misc/cxl/native.c new file +649 -0
649 lines not on this page · raw message
drivers/misc/cxl/sysfs.c new file +348 -0
348 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 13/15 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 | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 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 +88 -0
88 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 14/15 cxl: Add driver to Kbuild and Makefiles
In reply to Michael NeulingFrom: Ian Munsie <[email protected]>
--- drivers/misc/cxl/Kconfig | 18 ++++++++++++++++++ drivers/misc/cxl/Makefile | 3 +++ 2 files changed, 21 insertions(+)
drivers/misc/cxl/Kconfig +18 -0
@@ -5,3 +5,21 @@ config CXL_BASE bool default n + +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). + +config CXL_PCI + tristate "Support for CXL devices via PCI" + depends on CXL && PPC_POWERNV + default y + help + Select this option to support CXL devices detected via PCI, e.g. + when running under powernv/OPAL.
drivers/misc/cxl/Makefile +3 -0
@@ -1 +1,4 @@ +cxl-y += main.o file.o irq.o fault.o native.o context.o sysfs.o debugfs.o +obj-$(CONFIG_CXL) += cxl.o +obj-$(CONFIG_CXL_PCI) += cxl-pci.o obj-$(CONFIG_CXL_BASE) += base.o
Signature · 1 line
1.9.1
PATCH 15/15 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 | 125 ++++++++++++ Documentation/ioctl/ioctl-number.txt | 1 + Documentation/powerpc/00-INDEX | 2 + Documentation/powerpc/cxl.txt | 310 ++++++++++++++++++++++++++++++ MAINTAINERS | 7 + 5 files changed, 445 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 +125 -0
@@ -0,0 +1,125 @@ +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/write + 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 request -1 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 but + no user contexts can be attached at this point. + + +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: Just prefault in the wed + 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. + + +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>/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/afu0.0) + +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 +310 -0
310 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