Re: [PATCH 3/4 RFC] fsl/msi: Add MSI bank allocation for kernel owned devices

2015-03-13 Thread Scott Wood
On Thu, 2015-03-12 at 10:46 -0500, Bhushan Bharat-R65777 wrote: > > > > -Original Message- > > From: Wood Scott-B07421 > > Sent: Thursday, March 12, 2015 4:53 AM > > To: Bhushan Bharat-R65777 > > Cc: linuxppc-...@ozlabs.org > > Subject: Re: [PATCH 3/4 RFC] fsl/msi: Add MSI bank allocation

[PATCH 23/32] powerpc: copy_thread(): rename 'arg' argument to 'kthread_arg'

2015-03-13 Thread Alex Dowad
The 'arg' argument to copy_thread() is only ever used when forking a new kernel thread. Hence, rename it to 'kthread_arg' for clarity (and consistency with do_fork() and other arch-specific implementations of copy_thread()). Signed-off-by: Alex Dowad --- arch/powerpc/kernel/process.c | 9 +++

Re: [PATCHv2] powerpc: comvert relocs_check to a shell script using grep

2015-03-13 Thread Stephen Rothwell
Hi David, On Fri, 13 Mar 2015 14:18:10 + David Laight wrote: > > From: Stephen Rothwell > > This runs a bit faster and removes another use of perl from > > the kernel build. > ... > > diff --git a/arch/powerpc/relocs_check.sh b/arch/powerpc/relocs_check.sh > > new file mode 100755 > > index 0

Re: [PATCH 2/2] drivers/vfio: Support EEH error injection

2015-03-13 Thread Alex Williamson
On Wed, 2015-03-11 at 17:34 +1100, Gavin Shan wrote: > The patch adds one more EEH sub-command (VFIO_EEH_PE_INJECT_ERR) > to inject the specified EEH error, which is represented by > (struct vfio_eeh_pe_err), to the indicated PE for testing purpose. > > Signed-off-by: Gavin Shan > --- > Document

Re: [PATCH 1/2] powerpc/eeh: Introduce eeh_pe_inject_err()

2015-03-13 Thread Alex Williamson
On Wed, 2015-03-11 at 17:34 +1100, Gavin Shan wrote: > The patch defines PCI error types and functions in eeh.h and > exports function eeh_pe_inject_err(), which will be called by > VFIO driver to inject the specified PCI error to the indicated > PE for testing purpose. > > Signed-off-by: Gavin Sh

Re: [PATCH 2/2] drivers/vfio: Support EEH error injection

2015-03-13 Thread Alex Williamson
On Thu, 2015-03-12 at 15:21 +1100, David Gibson wrote: > On Thu, Mar 12, 2015 at 02:16:42PM +1100, Gavin Shan wrote: > > On Thu, Mar 12, 2015 at 11:57:21AM +1100, David Gibson wrote: > > >On Wed, Mar 11, 2015 at 05:34:11PM +1100, Gavin Shan wrote: > > >> The patch adds one more EEH sub-command (VFI

Re: [PATCH 1/2] powerpc: Add a proper syscall for switching endianness

2015-03-13 Thread Scott Wood
On Fri, 2015-03-13 at 17:38 +1100, Michael Ellerman wrote: > On Fri, 2015-03-13 at 15:39 +1100, Michael Ellerman wrote: > > We currently have a "special" syscall for switching endianness. This is > > syscall number 0x1ebe, which is handled explicitly in the 64-bit syscall > > exception entry. > >

RE: [PATCHv2] powerpc: comvert relocs_check to a shell script using grep

2015-03-13 Thread David Laight
From: Stephen Rothwell > This runs a bit faster and removes another use of perl from > the kernel build. ... > diff --git a/arch/powerpc/relocs_check.sh b/arch/powerpc/relocs_check.sh > new file mode 100755 > index ..182eae9cc40d > --- /dev/null > +++ b/arch/powerpc/relocs_check.sh > @@

Re: [PATCH 0/2] crypto: talitos: Add AES-XTS mode

2015-03-13 Thread Martin Hicks
Hi Horia, On Wed, Mar 11, 2015 at 11:48 AM, Horia Geantă wrote: > > While here: note that xts-talitos supports only two key lengths - 256 > and 512 bits. There are tcrypt speed tests that check also for 384-bit > keys (which is out-of-spec, but still...), leading to a "Key Size Error" > - see bel

Re: Re: [PATCHv2 2/8] perf probe: Improve detection of file/function name in the probe pattern

2015-03-13 Thread Masami Hiramatsu
(2015/03/13 5:24), Arnaldo Carvalho de Melo wrote: > Em Mon, Dec 15, 2014 at 08:20:32PM +0530, Naveen N. Rao escreveu: >> Currently, perf probe considers patterns including a '.' to be a file. >> However, this causes problems on powerpc ABIv1 where all functions have >> a leading '.': >> >> $ per

Re: [PATCH v2 1/5] of/fdt: split off FDT self reservation from memreserve processing

2015-03-13 Thread Ard Biesheuvel
On 12 March 2015 at 22:54, Rob Herring wrote: > On Wed, Mar 11, 2015 at 11:00 AM, Ard Biesheuvel > wrote: >> This splits off the reservation of the memory occupied by the FDT >> binary itself from the processing of the memory reservations it >> contains. This is necessary because the physical add

Re: [PATCH slof v2] virtio: Fix vring allocation

2015-03-13 Thread Thomas Huth
On Fri, 13 Mar 2015 20:42:03 +1100 Alexey Kardashevskiy wrote: > The value returned by virtio_vring_size() is used to allocate memory > for vring. The used descriptor list (array of vring_used_elem) is > counted by the header - vring_used struct - is not. > > This fixes virtio_vring_size() to re

Re: [PATCH slof v2] virtio: Fix vring allocation

2015-03-13 Thread Nikunj A Dadhania
Alexey Kardashevskiy writes: > The value returned by virtio_vring_size() is used to allocate memory > for vring. The used descriptor list (array of vring_used_elem) is > counted by the header - vring_used struct - is not. > > This fixes virtio_vring_size() to return the correct size. > At the mom

Re: [RFC V2 04/12] i2c: opal: make use of the new infrastructure for quirks

2015-03-13 Thread Neelesh Gupta
Hi Wolfram, Based on your patch: "[RFC V2 04/12] i2c: opal: make use of the new infrastructure for quirks" From: Neelesh Gupta Subject: [PATCH] i2c: opal: Update quirk flags to do write-then-anything Support write-then-anything in the case of 2 i2c messages for i2c transfer. Signed-off-by: N

[PATCH slof v2] virtio: Fix vring allocation

2015-03-13 Thread Alexey Kardashevskiy
The value returned by virtio_vring_size() is used to allocate memory for vring. The used descriptor list (array of vring_used_elem) is counted by the header - vring_used struct - is not. This fixes virtio_vring_size() to return the correct size. At the moment rings are quite small (256) and alloca

Re: [PATCH slof] virtio: Fix vring allocation

2015-03-13 Thread Nikunj A Dadhania
Alexey Kardashevskiy writes: > The value returned by virtio_vring_size() is used to allocate memory > for vring. The used descriptor list (array of vring_used_elem) is > counted by the header - vring_used struct - is not. > > This fixes virtio_vring_size() to return the correct size. > At the mom

Re: [PATCH slof] helpers: Fix SLOF_alloc_mem_aligned to meet callers expectation

2015-03-13 Thread Nikunj A Dadhania
Alexey Kardashevskiy writes: > Every caller of SLOF_alloc_mem_aligned() assumes the size is the first > argument while it is not. > > This switches align and size and fixes random memory corruptions. > > This is grep for SLOF_alloc_mem_aligned with this patch applied: > > include/helpers.h|27| ex

[PATCH slof] virtio: Fix vring allocation

2015-03-13 Thread Alexey Kardashevskiy
The value returned by virtio_vring_size() is used to allocate memory for vring. The used descriptor list (array of vring_used_elem) is counted by the header - vring_used struct - is not. This fixes virtio_vring_size() to return the correct size. At the moment rings are quite small (256) and alloca

[PATCH slof] helpers: Fix SLOF_alloc_mem_aligned to meet callers expectation

2015-03-13 Thread Alexey Kardashevskiy
Every caller of SLOF_alloc_mem_aligned() assumes the size is the first argument while it is not. This switches align and size and fixes random memory corruptions. This is grep for SLOF_alloc_mem_aligned with this patch applied: include/helpers.h|27| extern void *SLOF_alloc_mem_aligned(long size,

[PATCH kernel v6 28/29] vfio: powerpc/spapr: Support multiple groups in one container if possible

2015-03-13 Thread Alexey Kardashevskiy
At the moment only one group per container is supported. POWER8 CPUs have more flexible design and allows naving 2 TCE tables per IOMMU group so we can relax this limitation and support multiple groups per container. This adds TCE table descriptors to a container and uses iommu_table_group_ops to

[PATCH kernel v6 17/29] powerpc/powernv/ioda/ioda2: Rework tce_build()/tce_free()

2015-03-13 Thread Alexey Kardashevskiy
The pnv_pci_ioda_tce_invalidate() helper invalidates TCE cache. It is supposed to be called on IODA1/2 and not called on p5ioc2. It receives start and end host addresses of TCE table. This approach makes it possible to get pnv_pci_ioda_tce_invalidate() unintentionally called on p5ioc2. Another issu

[PATCH kernel v6 21/29] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_set_window

2015-03-13 Thread Alexey Kardashevskiy
This is a part of moving DMA window programming to an iommu_ops callback. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 85 --- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/arch/powe

[PATCH kernel v6 23/29] powerpc/powernv: Implement multilevel TCE tables

2015-03-13 Thread Alexey Kardashevskiy
TCE tables might get too big in case of 4K IOMMU pages and DDW enabled on huge guests (hundreds of GB of RAM) so the kernel might be unable to allocate contiguous chunk of physical memory to store the TCE table. To address this, POWER8 CPU (actually, IODA2) supports multi-level TCE tables, up to 5

[PATCH kernel v6 26/29] vfio: powerpc/spapr: Define v2 IOMMU

2015-03-13 Thread Alexey Kardashevskiy
The existing IOMMU requires VFIO_IOMMU_ENABLE call to enable actual use of the container (i.e. call DMA map/unmap) and this is where we check the rlimit for locked pages. It assumes that only as much memory as a default DMA window can be mapped. Every DMA map/unmap request will do pinning/unpinning

[PATCH kernel v6 24/29] powerpc/powernv: Change prototypes to receive iommu

2015-03-13 Thread Alexey Kardashevskiy
This changes few functions to receive a iommu_table_group pointer rather than PE as they are going to be a part of upcoming iommu_table_group_ops callback set. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 13 - 1 file changed, 8 insertions(+), 5

[PATCH kernel v6 14/29] vfio: powerpc/spapr: powerpc/iommu: Rework IOMMU ownership control

2015-03-13 Thread Alexey Kardashevskiy
This replaces iommu_take_ownership()/iommu_release_ownership() calls with the callback calls and it is up to the platform code to call iommu_take_ownership()/iommu_release_ownership() if needed. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 4 +-- arch/powerpc/ke

[PATCH kernel v6 11/29] powerpc/iommu: Move tce_xxx callbacks from ppc_md to iommu_table

2015-03-13 Thread Alexey Kardashevskiy
This adds a iommu_table_ops struct and puts pointer to it into the iommu_table struct. This moves tce_build/tce_free/tce_get/tce_flush callbacks from ppc_md to the new struct where they really belong to. This adds the requirement for @it_ops to be initialized before calling iommu_init_table() to m

[PATCH kernel v6 09/29] vfio: powerpc/spapr: Rework attach/detach

2015-03-13 Thread Alexey Kardashevskiy
This is to make extended ownership and multiple groups support patches simpler for review. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 38 ++--- 1 file changed, 23 insertions(+), 15 deletions(-) diff

[PATCH kernel v6 19/29] powerpc/powernv/ioda2: Rework iommu_table creation

2015-03-13 Thread Alexey Kardashevskiy
This moves iommu_table creation to the beginning. This is a mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-

[PATCH kernel v6 06/29] vfio: powerpc/spapr: Disable DMA mappings on disabled container

2015-03-13 Thread Alexey Kardashevskiy
At the moment DMA map/unmap requests are handled irrespective to the container's state. This allows the user space to pin memory which it might not be allowed to pin. This adds checks to MAP/UNMAP that the container is enabled, otherwise -EPERM is returned. Signed-off-by: Alexey Kardashevskiy --

[PATCH kernel v6 29/29] vfio: powerpc/spapr: Support Dynamic DMA windows

2015-03-13 Thread Alexey Kardashevskiy
This adds create/remove window ioctls to create and remove DMA windows. sPAPR defines a Dynamic DMA windows capability which allows para-virtualized guests to create additional DMA windows on a PCI bus. The existing linux kernels use this new window to map the entire guest memory and switch to the

[PATCH kernel v6 25/29] powerpc/powernv/ioda: Define and implement DMA table/window management callbacks

2015-03-13 Thread Alexey Kardashevskiy
This extends iommu_table_group_ops by a set of callbacks to support dynamic DMA windows management. query() returns IOMMU capabilities such as default DMA window address and supported number of DMA windows and TCE table levels. create_table() creates a TCE table with specific parameters. it recei

[PATCH kernel v6 13/29] powerpc/spapr: vfio: Switch from iommu_table to new iommu_table_group

2015-03-13 Thread Alexey Kardashevskiy
Modern IBM POWERPC systems support multiple (currently two) TCE tables per IOMMU group (a.k.a. PE). This adds a iommu_table_group container for TCE tables. Right now just one table is supported. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 18 +++-- arch

[PATCH kernel v6 12/29] powerpc/iommu: Introduce iommu_table_alloc() helper

2015-03-13 Thread Alexey Kardashevskiy
This replaces multiple calls of kzalloc_node() with a new iommu_table_alloc() helper. Right now it calls kzalloc_node() but later it will be modified to allocate a iommu_table_group struct with a single iommu_table in it. Later the helper will allocate a iommu_table_group struct which embeds the i

[PATCH kernel v6 05/29] vfio: powerpc/spapr: Move locked_vm accounting to helpers

2015-03-13 Thread Alexey Kardashevskiy
There moves locked pages accounting to helpers. Later they will be reused for Dynamic DMA windows (DDW). This reworks debug messages to show the current value and the limit. This stores the locked pages number in the container so when unlocking the iommu table pointer won't be needed. This does n

[PATCH kernel v6 10/29] powerpc/powernv: Do not set "read" flag if direction==DMA_NONE

2015-03-13 Thread Alexey Kardashevskiy
Normally a bitmap from the iommu_table is used to track what TCE entry is in use. Since we are going to use iommu_table without its locks and do xchg() instead, it becomes essential not to put bits which are not implied in the direction flag. This adds iommu_direction_to_tce_perm() (its counterpar

[PATCH kernel v6 15/29] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework IOMMU ownership control

2015-03-13 Thread Alexey Kardashevskiy
At the moment the iommu_table struct has a set_bypass() which enables/ disables DMA bypass on IODA2 PHB. This is exposed to POWERPC IOMMU code which calls this callback when external IOMMU users such as VFIO are about to get over a PHB. The set_bypass() callback is not really an iommu_table functi

[PATCH kernel v6 07/29] vfio: powerpc/spapr: Moving pinning/unpinning to helpers

2015-03-13 Thread Alexey Kardashevskiy
This is a pretty mechanical patch to make next patches simpler. New tce_iommu_unuse_page() helper does put_page() now but it might skip that after the memory registering patch applied. As we are here, this removes unnecessary checks for a value returned by pfn_to_page() as it cannot possibly retu

[PATCH kernel v6 20/29] powerpc/powernv/ioda2: Introduce pnv_pci_ioda2_create_table/pnc_pci_free_table

2015-03-13 Thread Alexey Kardashevskiy
This is a part of moving TCE table allocation into an iommu_ops callback to support multiple IOMMU groups per one VFIO container. This enforce window size to be a power of two. This is a pretty mechanical patch. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c

[PATCH kernel v6 27/29] vfio: powerpc/spapr: powerpc/powernv/ioda2: Rework ownership

2015-03-13 Thread Alexey Kardashevskiy
Before the IOMMU user (VFIO) would take control over the IOMMU table belonging to a specific IOMMU group. This approach did not allow sharing tables between IOMMU groups attached to the same container. This introduces a new IOMMU ownership flavour when the user can not just control the existing IO

[PATCH kernel v6 08/29] vfio: powerpc/spapr: Register memory

2015-03-13 Thread Alexey Kardashevskiy
The existing implementation accounts the whole DMA window in the locked_vm counter which is going to be even worse with multiple containers and huge DMA windows. This introduces 2 ioctls to register/unregister DMA memory which receive user space address and size of a memory region which needs to b

[PATCH kernel v6 18/29] powerpc/iommu/powernv: Release replaced TCE

2015-03-13 Thread Alexey Kardashevskiy
At the moment writing new TCE value to the IOMMU table fails with EBUSY if there is a valid entry already. However PAPR specification allows the guest to write new TCE value without clearing it first. Another problem this patch is addressing is the use of pool locks for external IOMMU users such a

[PATCH kernel v6 22/29] powerpc/iommu: Split iommu_free_table into 2 helpers

2015-03-13 Thread Alexey Kardashevskiy
The iommu_free_table helper release memory it is using (the TCE table and @it_map) and release the iommu_table struct as well. We might not want the very last step as we store iommu_table in parent structures. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 1 + arch/

[PATCH kernel v6 16/29] powerpc/iommu: Fix IOMMU ownership control functions

2015-03-13 Thread Alexey Kardashevskiy
This adds missing locks in iommu_take_ownership()/ iommu_release_ownership(). This marks all pages busy in iommu_table::it_map in order to catch errors if there is an attempt to use this table while ownership over it is taken. This only clears TCE content if there is no page marked busy in it_map

[PATCH kernel v6 03/29] vfio: powerpc/spapr: Check that TCE page size is equal to it_page_size

2015-03-13 Thread Alexey Kardashevskiy
This checks that the TCE table page size is not bigger that the size of a page we just pinned and going to put its physical address to the table. Otherwise the hardware gets unwanted access to physical memory between the end of the actual page and the end of the aligned up TCE page. Since compoun

[PATCH kernel v6 01/29] vfio: powerpc/spapr: Move page pinning from arch code to VFIO IOMMU driver

2015-03-13 Thread Alexey Kardashevskiy
This moves page pinning (get_user_pages_fast()/put_page()) code out of the platform IOMMU code and puts it to VFIO IOMMU driver where it belongs to as the platform code does not deal with page pinning. This makes iommu_take_ownership()/iommu_release_ownership() deal with the IOMMU table bitmap onl

[PATCH kernel v6 02/29] vfio: powerpc/spapr: Do cleanup when releasing the group

2015-03-13 Thread Alexey Kardashevskiy
This clears the TCE table when a container is being closed as this is a good thing to leave the table clean before passing the ownership back to the host kernel. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 14 +++--- 1 file changed, 11 insertions(+), 3 d

[PATCH kernel v6 04/29] vfio: powerpc/spapr: Use it_page_size

2015-03-13 Thread Alexey Kardashevskiy
This makes use of the it_page_size from the iommu_table struct as page size can differ. This replaces missing IOMMU_PAGE_SHIFT macro in commented debug code as recently introduced IOMMU_PAGE_XXX macros do not include IOMMU_PAGE_SHIFT. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson

[PATCH kernel v6 00/29] powerpc/iommu/vfio: Enable Dynamic DMA windows

2015-03-13 Thread Alexey Kardashevskiy
This enables sPAPR defined feature called Dynamic DMA windows (DDW). Each Partitionable Endpoint (IOMMU group) has an address range on a PCI bus where devices are allowed to do DMA. These ranges are called DMA windows. By default, there is a single DMA window, 1 or 2GB big, mapped at zero on a PCI

Re: [PATCH 2/2] selftests/powerpc: Add a test of the switch_endian() syscall

2015-03-13 Thread Michael Ellerman
On Fri, 2015-03-13 at 00:10 -0700, Ram Pai wrote: > On Fri, Mar 13, 2015 at 03:39:24PM +1100, Michael Ellerman wrote: > > This adds a test of the switch_endian() syscall we added in the previous > > commit. > > > > We test it by calling the endian switch syscall, and then executing some > > code i

Re: [RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR

2015-03-13 Thread Benjamin Herrenschmidt
On Fri, 2015-03-13 at 18:09 +1100, Michael Ellerman wrote: > On Thu, 2015-03-12 at 22:13 +1100, Benjamin Herrenschmidt wrote: > > On Thu, 2015-03-12 at 18:55 +0800, Kevin Hao wrote: > > > I know Torsten Duwe has tried to add the ticket spinlock for powerpc > > > one year ago [1]. But it make no pro

Re: [PATCH 2/2] selftests/powerpc: Add a test of the switch_endian() syscall

2015-03-13 Thread Ram Pai
On Fri, Mar 13, 2015 at 03:39:24PM +1100, Michael Ellerman wrote: > This adds a test of the switch_endian() syscall we added in the previous > commit. > > We test it by calling the endian switch syscall, and then executing some > code in the other endian to check everything went as expected. That

Re: [RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR

2015-03-13 Thread Michael Ellerman
On Thu, 2015-03-12 at 22:13 +1100, Benjamin Herrenschmidt wrote: > On Thu, 2015-03-12 at 18:55 +0800, Kevin Hao wrote: > > I know Torsten Duwe has tried to add the ticket spinlock for powerpc > > one year ago [1]. But it make no progress due to the conflict between > > PPC_SPLPAR and lockref. We st

Re: [RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR

2015-03-13 Thread Benjamin Herrenschmidt
On Fri, 2015-03-13 at 14:09 +0800, Kevin Hao wrote: > On Thu, Mar 12, 2015 at 04:24:10PM +0100, Torsten Duwe wrote: > > But generally, which platforms would benefit most from this change? > > In theory, the more cpus the platform has, the more serious the thundering > herd problem is. So the lates