Re: [PATCH] cxl: Fix error handling

2016-10-30 Thread Andrew Donnellan

On 31/10/16 08:40, Christophe JAILLET wrote:

'cxl_dev_context_init()' returns an error pointer in case of error, not
NULL. So test it with IS_ERR.

Signed-off-by: Christophe JAILLET 


Reviewed-by: Andrew Donnellan 


---
un-compiled because I don't have the required  cross build environment.


Builds for me.


--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



Re: [PATCH] cxl: Fix error handling

2016-10-30 Thread Andrew Donnellan

On 31/10/16 08:34, Christophe JAILLET wrote:

'cxl_dev_context_init()' returns an error pointer in case of error, not
NULL. So test it with IS_ERR.

Signed-off-by: Christophe JAILLET 


Reviewed-by: Andrew Donnellan 


---
un-compiled because I don't have the required  cross build environment.


Builds fine here.

In future, you might want to bundle all 3 of your patches either into 1 
patch (while they are changes which can be done separately, it's all 
fixes to one type of problem in relation to one function, so personally 
I'm okay with that) or send it as a series, so that it's clear to 
everyone that they're all related fixes.


Additionally, having the same patch subject line for two patches sent in 
short succession is a bit confusing - in future, try and avoid that.



Andrew

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



Re: [PATCH] cxl: Fix memory allocation failure test

2016-10-30 Thread Andrew Donnellan

On 31/10/16 06:35, Christophe JAILLET wrote:

'cxl_context_alloc()' does not return an error pointer. It is just a
shortcut for a call to 'kzalloc' with 'sizeof(struct cxl_context)' as the
size parameter.

So its return value should be compared with NULL.
While fixing it, simplify a bit the code.

Signed-off-by: Christophe JAILLET 


Reviewed-by: Andrew Donnellan 


---
un-compiled because I don't have the required  cross build environment.


Compiles on my system!

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



Re: [PATCH 08/15] powerpc/iommu: use permission-specific DEVICE_ATTR variants

2016-10-30 Thread Michael Ellerman
Julia Lawall  writes:

> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index 5f202a5..32f18b5 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -127,8 +127,7 @@ static ssize_t fail_iommu_store(struct device *dev,
>   return count;
>  }
>  
> -static DEVICE_ATTR(fail_iommu, S_IRUGO|S_IWUSR, fail_iommu_show,
> -fail_iommu_store);
> +static DEVICE_ATTR_RW(fail_iommu);

Acked-by: Michael Ellerman  (powerpc)


cheers


Re: [PATCH V2 2/2] powerpc/kvm: Update kvmppc_set_arch_compat() for ISA v3.00

2016-10-30 Thread Paul Mackerras
On Mon, Oct 31, 2016 at 11:28:23AM +1100, Suraj Jitindar Singh wrote:
> The function kvmppc_set_arch_compat() is used to determine the value of the
> processor compatibility register (PCR) for a guest running in a given
> compatibility mode. There is currently no support for v3.00 of the ISA.
> 
> Add support for v3.00 of the ISA which adds an ISA v2.07 compatilibity mode
> to the PCR.
> 
> We also add a check to ensure the processor we are running on is capable of
> emulating the chosen processor (for example a POWER7 cannot emulate a
> POWER8, similarly with a POWER8 and a POWER9).
> 
> Signed-off-by: Suraj Jitindar Singh 
> ---
>  arch/powerpc/kvm/book3s_hv.c | 32 +++-
>  1 file changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 3686471..24681e7 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -311,24 +311,38 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu 
> *vcpu, u32 arch_compat)
>* If an arch bit is set in PCR, all the defined
>* higher-order arch bits also have to be set.
>*/
> - pcr = PCR_ARCH_206 | PCR_ARCH_205;
> + if (cpu_has_feature(CPU_FTR_ARCH_206))
> + pcr |= PCR_ARCH_205;
> + if (cpu_has_feature(CPU_FTR_ARCH_207S))
> + pcr |= PCR_ARCH_206;
> + if (cpu_has_feature(CPU_FTR_ARCH_300))
> + pcr |= PCR_ARCH_207;
>   break;
>   case PVR_ARCH_206:
>   case PVR_ARCH_206p:
> - pcr = PCR_ARCH_206;
> + /* Must be at least v2.06 to (emulate) it */
> + if (!cpu_has_feature(CPU_FTR_ARCH_206))
> + return -EINVAL;
> + if (cpu_has_feature(CPU_FTR_ARCH_207S))
> + pcr |= PCR_ARCH_206;
> + if (cpu_has_feature(CPU_FTR_ARCH_300))
> + pcr |= PCR_ARCH_207;
>   break;
>   case PVR_ARCH_207:
> + /* Must be at least v2.07 to (emulate) it */
> + if (!cpu_has_feature(CPU_FTR_ARCH_207S))
> + return -EINVAL;
> + if (cpu_has_feature(CPU_FTR_ARCH_300))
> + pcr |= PCR_ARCH_207;
> + break;
> + case PVR_ARCH_300:
> + /* Must be at least v3.00 to (emulate) it */
> + if (!cpu_has_feature(CPU_FTR_ARCH_300))
> + return -EINVAL;
>   break;

I can't help thinking that the repetitive structure of the lines
you're adding must imply a regularity that could be expressed more
concisely.  If you defined a dummy PCR_ARCH_300 bit as 0x10, perhaps
you could do something like this:

if (cpu_has_feature(CPU_FTR_ARCH_300))
host_pcr_bit = PCR_ARCH_300;
else if (cpu_has_feature(CPU_FTR_ARCH_207S))
host_pcr_bit = PCR_ARCH_207;
else
host_pcr_bit = PCR_ARCH_206;

switch (arch_compat) {
case PVR_ARCH_205:
guest_pcr_bit = PCR_ARCH_205;
break;
case PVR_ARCH_206:
guest_pcr_bit = PCR_ARCH_206;
break;
case PVR_ARCH_207:
case PVR_ARCH_207S:
guest_pcr_bit = PCR_ARCH_207;
break;
case PVR_ARCH_300:
guest_pcr_bit = PCR_ARCH_300;
break;
default:
return -EINVAL;
}

if (guest_pcr_bit > host_pcr_bit)
return -EINVAL;

pcr = host_pcr_bit - guest_pcr_bit;

The translation from arch_compat to guest_pcr_bit might look neater as
a table lookup on the low bits of arch_compat, after a bounds check.

Paul.


Re: [PATCH] cxl: Fix error handling

2016-10-30 Thread Michael Ellerman
Christophe JAILLET  writes:

> 'cxl_dev_context_init()' returns an error pointer in case of error, not
> NULL. So test it with IS_ERR.
>
> Signed-off-by: Christophe JAILLET 
> ---
> un-compiled because I don't have the required  cross build environment.

Do you run Ubuntu or Fedora? If so it's just a dnf/apt-get away:

$ sudo dnf install gcc-c++-powerpc64-linux-gnu binutils-powerpc64-linux-gnu 
gcc-powerpc64-linux-gnu
or
$ sudo apt-get install gcc-powerpc64le-linux-gnu gcc-powerpc-linux-gnu 
libc-dev-powerpc-cross libc-dev-ppc64el-cross

More here:

https://github.com/linuxppc/linux/wiki/Building-powerpc-kernels


cheers


Re: [PATCH] console: use first console if stdout-path device doesn't appear

2016-10-30 Thread Michael Ellerman
Andreas Schwab  writes:

> Any news?

We discovered it also breaks VGA on qemu, which presumably is not the
type of news you were hoping for.


To reproduce you just need to build a ppc64le kernel:

$ apt-get install gcc-powerpc64le-linux-gnu
$ make ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- pseries_le_defconfig
$ make ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu-

And then run qemu:

$ qemu-system-ppc64 -M pseries -m 1G  -kernel vmlinux


Which will display the Tux logo but then nothing else and then reboot
after 10 seconds or so.

If you revert 05fd007e4629 on top of rc3 it boots fine.


Paul I tried your "console: use first console if stdout-path device
doesn't appear" patch, but it didn't help. I'll try and work out why,
but it's a bit hard with no output :)


If we can't come up with a fix soon I'm inclined to ask for a revert.

cheers


Re: [PATCH kernel v4 4/4] powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown

2016-10-30 Thread David Gibson
On Mon, Oct 31, 2016 at 03:13:21PM +1100, Alexey Kardashevskiy wrote:
> On 31/10/16 14:13, David Gibson wrote:
> > On Tue, Oct 25, 2016 at 03:55:56PM +1100, Alexey Kardashevskiy wrote:
> >> On 25/10/16 15:44, David Gibson wrote:
> >>> On Mon, Oct 24, 2016 at 05:53:10PM +1100, Alexey Kardashevskiy wrote:
>  At the moment the userspace tool is expected to request pinning of
>  the entire guest RAM when VFIO IOMMU SPAPR v2 driver is present.
>  When the userspace process finishes, all the pinned pages need to
>  be put; this is done as a part of the userspace memory context (MM)
>  destruction which happens on the very last mmdrop().
> 
>  This approach has a problem that a MM of the userspace process
>  may live longer than the userspace process itself as kernel threads
>  use userspace process MMs which was runnning on a CPU where
>  the kernel thread was scheduled to. If this happened, the MM remains
>  referenced until this exact kernel thread wakes up again
>  and releases the very last reference to the MM, on an idle system this
>  can take even hours.
> 
>  This moves preregistered regions tracking from MM to VFIO; insteads of
>  using mm_iommu_table_group_mem_t::used, tce_container::prereg_list is
>  added so each container releases regions which it has pre-registered.
> 
>  This changes the userspace interface to return EBUSY if a memory
>  region is already registered in a container. However it should not
>  have any practical effect as the only userspace tool available now
>  does register memory region once per container anyway.
> 
>  As tce_iommu_register_pages/tce_iommu_unregister_pages are called
>  under container->lock, this does not need additional locking.
> 
>  Signed-off-by: Alexey Kardashevskiy 
>  Reviewed-by: Nicholas Piggin 
> >>>
> >>> On the grounds that this leaves things in a better state than before:
> >>>
> >>> Reviewed-by: David Gibson 
> >>>
> >>> On the other hand the implementation is kind of clunky, with the way
> >>> it keeps the mm-level and vfio-level lists of regions in parallel.
> >>> With this change, does the mm-level list actually serve any purpose at
> >>> all, or could it all be moved into the vfio-level list?
> >>
> >>
> >> The mm-level list allows not having gup() called for each container (minor
> >> thing, I suppose) and it also tracks a number of active mappings which will
> >> become useful when we add in-kernel real-mode TCE acceleration as
> >> vfio-level code cannot run in realmode.
> > 
> > Hm, ok.  So, if two different containers pre-register the same region
> > of memory, IIUC in the proposed code, the region will get one entry in
> > the mm level list, and that entry will be referenced in the lists for
> > both containers.  Yes?
> 
> Yes.
> 
> 
> > What happens if two different containers try to pre-register
> > different, but overlapping, mm regions?
> 
> The second container will fail to preregister memory - mm_iommu_get() will
> return -EINVAL.

Um.. yeah.. that's not really ok.  Prohibiting overlapping
registrations on the same container is reasonable enough.  Having a
container not be able to register memory because some completely
different container has registered something overlapping is getting
very ugly.

> I am wondering what happens to the series now.
> 
> Alex, could you please have a look and comment? Thanks.
> 
> 
> 
> > 
> >>
> >>
> >>
> >>>
>  ---
>  Changes:
>  v4:
>  * changed tce_iommu_register_pages() to call mm_iommu_find() first and
>  avoid calling mm_iommu_put() if memory is preregistered already
> 
>  v3:
>  * moved tce_iommu_prereg_free() call out of list_for_each_entry()
> 
>  v2:
>  * updated commit log
>  ---
>   arch/powerpc/mm/mmu_context_book3s64.c |  4 ---
>   arch/powerpc/mm/mmu_context_iommu.c| 11 ---
>   drivers/vfio/vfio_iommu_spapr_tce.c| 58 
>  +-
>   3 files changed, 57 insertions(+), 16 deletions(-)
> 
>  diff --git a/arch/powerpc/mm/mmu_context_book3s64.c 
>  b/arch/powerpc/mm/mmu_context_book3s64.c
>  index ad82735..1a07969 100644
>  --- a/arch/powerpc/mm/mmu_context_book3s64.c
>  +++ b/arch/powerpc/mm/mmu_context_book3s64.c
>  @@ -159,10 +159,6 @@ static inline void destroy_pagetable_page(struct 
>  mm_struct *mm)
>   
>   void destroy_context(struct mm_struct *mm)
>   {
>  -#ifdef CONFIG_SPAPR_TCE_IOMMU
>  -mm_iommu_cleanup(mm);
>  -#endif
>  -
>   #ifdef CONFIG_PPC_ICSWX
>   drop_cop(mm->context.acop, mm);
>   kfree(mm->context.cop_lockp);
>  diff --git a/arch/powerpc/mm/mmu_context_iommu.c 
>  b/arch/powerpc/mm/mmu_context_iommu.c
>  index 4c6db09..104bad0 100644
>  --- a/arch/powerpc/mm/mmu_context_iommu.c
>  +++ b/arch/powerpc/mm/mmu_context_iommu.c
>  @@ -365,14 +

Re: [PATCH kernel v4 4/4] powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown

2016-10-30 Thread Alexey Kardashevskiy
On 31/10/16 14:13, David Gibson wrote:
> On Tue, Oct 25, 2016 at 03:55:56PM +1100, Alexey Kardashevskiy wrote:
>> On 25/10/16 15:44, David Gibson wrote:
>>> On Mon, Oct 24, 2016 at 05:53:10PM +1100, Alexey Kardashevskiy wrote:
 At the moment the userspace tool is expected to request pinning of
 the entire guest RAM when VFIO IOMMU SPAPR v2 driver is present.
 When the userspace process finishes, all the pinned pages need to
 be put; this is done as a part of the userspace memory context (MM)
 destruction which happens on the very last mmdrop().

 This approach has a problem that a MM of the userspace process
 may live longer than the userspace process itself as kernel threads
 use userspace process MMs which was runnning on a CPU where
 the kernel thread was scheduled to. If this happened, the MM remains
 referenced until this exact kernel thread wakes up again
 and releases the very last reference to the MM, on an idle system this
 can take even hours.

 This moves preregistered regions tracking from MM to VFIO; insteads of
 using mm_iommu_table_group_mem_t::used, tce_container::prereg_list is
 added so each container releases regions which it has pre-registered.

 This changes the userspace interface to return EBUSY if a memory
 region is already registered in a container. However it should not
 have any practical effect as the only userspace tool available now
 does register memory region once per container anyway.

 As tce_iommu_register_pages/tce_iommu_unregister_pages are called
 under container->lock, this does not need additional locking.

 Signed-off-by: Alexey Kardashevskiy 
 Reviewed-by: Nicholas Piggin 
>>>
>>> On the grounds that this leaves things in a better state than before:
>>>
>>> Reviewed-by: David Gibson 
>>>
>>> On the other hand the implementation is kind of clunky, with the way
>>> it keeps the mm-level and vfio-level lists of regions in parallel.
>>> With this change, does the mm-level list actually serve any purpose at
>>> all, or could it all be moved into the vfio-level list?
>>
>>
>> The mm-level list allows not having gup() called for each container (minor
>> thing, I suppose) and it also tracks a number of active mappings which will
>> become useful when we add in-kernel real-mode TCE acceleration as
>> vfio-level code cannot run in realmode.
> 
> Hm, ok.  So, if two different containers pre-register the same region
> of memory, IIUC in the proposed code, the region will get one entry in
> the mm level list, and that entry will be referenced in the lists for
> both containers.  Yes?

Yes.


> What happens if two different containers try to pre-register
> different, but overlapping, mm regions?

The second container will fail to preregister memory - mm_iommu_get() will
return -EINVAL.


I am wondering what happens to the series now.

Alex, could you please have a look and comment? Thanks.



> 
>>
>>
>>
>>>
 ---
 Changes:
 v4:
 * changed tce_iommu_register_pages() to call mm_iommu_find() first and
 avoid calling mm_iommu_put() if memory is preregistered already

 v3:
 * moved tce_iommu_prereg_free() call out of list_for_each_entry()

 v2:
 * updated commit log
 ---
  arch/powerpc/mm/mmu_context_book3s64.c |  4 ---
  arch/powerpc/mm/mmu_context_iommu.c| 11 ---
  drivers/vfio/vfio_iommu_spapr_tce.c| 58 
 +-
  3 files changed, 57 insertions(+), 16 deletions(-)

 diff --git a/arch/powerpc/mm/mmu_context_book3s64.c 
 b/arch/powerpc/mm/mmu_context_book3s64.c
 index ad82735..1a07969 100644
 --- a/arch/powerpc/mm/mmu_context_book3s64.c
 +++ b/arch/powerpc/mm/mmu_context_book3s64.c
 @@ -159,10 +159,6 @@ static inline void destroy_pagetable_page(struct 
 mm_struct *mm)
  
  void destroy_context(struct mm_struct *mm)
  {
 -#ifdef CONFIG_SPAPR_TCE_IOMMU
 -  mm_iommu_cleanup(mm);
 -#endif
 -
  #ifdef CONFIG_PPC_ICSWX
drop_cop(mm->context.acop, mm);
kfree(mm->context.cop_lockp);
 diff --git a/arch/powerpc/mm/mmu_context_iommu.c 
 b/arch/powerpc/mm/mmu_context_iommu.c
 index 4c6db09..104bad0 100644
 --- a/arch/powerpc/mm/mmu_context_iommu.c
 +++ b/arch/powerpc/mm/mmu_context_iommu.c
 @@ -365,14 +365,3 @@ void mm_iommu_init(struct mm_struct *mm)
  {
INIT_LIST_HEAD_RCU(&mm->context.iommu_group_mem_list);
  }
 -
 -void mm_iommu_cleanup(struct mm_struct *mm)
 -{
 -  struct mm_iommu_table_group_mem_t *mem, *tmp;
 -
 -  list_for_each_entry_safe(mem, tmp, &mm->context.iommu_group_mem_list,
 -  next) {
 -  list_del_rcu(&mem->next);
 -  mm_iommu_do_free(mem);
 -  }
 -}
 diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
 b/drivers/vfio/vfio_iommu_spapr_tce.c
 index 81ab93f..001

Re: Linux 4.9: Reported regressions as of Sunday, 2016-10-30

2016-10-30 Thread Benjamin Herrenschmidt
On Sun, 2016-10-30 at 14:20 +0100, Thorsten Leemhuis wrote:
> 
> Desc: PPC32: fails to boot on my PowerBook G4 Aluminum; bisected to
> commit 05fd007e4629
> Repo: 2016-10-20 https://www.mail-archive.com/linux-kernel@vger.kerne
> l.org/msg1253391.html
> Stat: 2016-10-22 https://www.mail-archive.com/linux-kernel@vger.kerne
> l.org/msg1255516.html https://www.linux-mips.org/archives/linux-mips/
> 2016-10/msg00176.html https://lkml.org/lkml/2016/10/18/142
> Note: Larry made a hack that works for him.

This breaks framebuffer console on ppc64 I've been told as well, I
heard...

I'm at KS now, hard to get you more details, but there's something
fishy here either with the commit or with something we do on ppc with
fbdev that this commit breaks.

Cheers,
Ben.



Re: [PATCH kernel v4 4/4] powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown

2016-10-30 Thread David Gibson
On Tue, Oct 25, 2016 at 03:55:56PM +1100, Alexey Kardashevskiy wrote:
> On 25/10/16 15:44, David Gibson wrote:
> > On Mon, Oct 24, 2016 at 05:53:10PM +1100, Alexey Kardashevskiy wrote:
> >> At the moment the userspace tool is expected to request pinning of
> >> the entire guest RAM when VFIO IOMMU SPAPR v2 driver is present.
> >> When the userspace process finishes, all the pinned pages need to
> >> be put; this is done as a part of the userspace memory context (MM)
> >> destruction which happens on the very last mmdrop().
> >>
> >> This approach has a problem that a MM of the userspace process
> >> may live longer than the userspace process itself as kernel threads
> >> use userspace process MMs which was runnning on a CPU where
> >> the kernel thread was scheduled to. If this happened, the MM remains
> >> referenced until this exact kernel thread wakes up again
> >> and releases the very last reference to the MM, on an idle system this
> >> can take even hours.
> >>
> >> This moves preregistered regions tracking from MM to VFIO; insteads of
> >> using mm_iommu_table_group_mem_t::used, tce_container::prereg_list is
> >> added so each container releases regions which it has pre-registered.
> >>
> >> This changes the userspace interface to return EBUSY if a memory
> >> region is already registered in a container. However it should not
> >> have any practical effect as the only userspace tool available now
> >> does register memory region once per container anyway.
> >>
> >> As tce_iommu_register_pages/tce_iommu_unregister_pages are called
> >> under container->lock, this does not need additional locking.
> >>
> >> Signed-off-by: Alexey Kardashevskiy 
> >> Reviewed-by: Nicholas Piggin 
> > 
> > On the grounds that this leaves things in a better state than before:
> > 
> > Reviewed-by: David Gibson 
> > 
> > On the other hand the implementation is kind of clunky, with the way
> > it keeps the mm-level and vfio-level lists of regions in parallel.
> > With this change, does the mm-level list actually serve any purpose at
> > all, or could it all be moved into the vfio-level list?
> 
> 
> The mm-level list allows not having gup() called for each container (minor
> thing, I suppose) and it also tracks a number of active mappings which will
> become useful when we add in-kernel real-mode TCE acceleration as
> vfio-level code cannot run in realmode.

Hm, ok.  So, if two different containers pre-register the same region
of memory, IIUC in the proposed code, the region will get one entry in
the mm level list, and that entry will be referenced in the lists for
both containers.  Yes?

What happens if two different containers try to pre-register
different, but overlapping, mm regions?

> 
> 
> 
> > 
> >> ---
> >> Changes:
> >> v4:
> >> * changed tce_iommu_register_pages() to call mm_iommu_find() first and
> >> avoid calling mm_iommu_put() if memory is preregistered already
> >>
> >> v3:
> >> * moved tce_iommu_prereg_free() call out of list_for_each_entry()
> >>
> >> v2:
> >> * updated commit log
> >> ---
> >>  arch/powerpc/mm/mmu_context_book3s64.c |  4 ---
> >>  arch/powerpc/mm/mmu_context_iommu.c| 11 ---
> >>  drivers/vfio/vfio_iommu_spapr_tce.c| 58 
> >> +-
> >>  3 files changed, 57 insertions(+), 16 deletions(-)
> >>
> >> diff --git a/arch/powerpc/mm/mmu_context_book3s64.c 
> >> b/arch/powerpc/mm/mmu_context_book3s64.c
> >> index ad82735..1a07969 100644
> >> --- a/arch/powerpc/mm/mmu_context_book3s64.c
> >> +++ b/arch/powerpc/mm/mmu_context_book3s64.c
> >> @@ -159,10 +159,6 @@ static inline void destroy_pagetable_page(struct 
> >> mm_struct *mm)
> >>  
> >>  void destroy_context(struct mm_struct *mm)
> >>  {
> >> -#ifdef CONFIG_SPAPR_TCE_IOMMU
> >> -  mm_iommu_cleanup(mm);
> >> -#endif
> >> -
> >>  #ifdef CONFIG_PPC_ICSWX
> >>drop_cop(mm->context.acop, mm);
> >>kfree(mm->context.cop_lockp);
> >> diff --git a/arch/powerpc/mm/mmu_context_iommu.c 
> >> b/arch/powerpc/mm/mmu_context_iommu.c
> >> index 4c6db09..104bad0 100644
> >> --- a/arch/powerpc/mm/mmu_context_iommu.c
> >> +++ b/arch/powerpc/mm/mmu_context_iommu.c
> >> @@ -365,14 +365,3 @@ void mm_iommu_init(struct mm_struct *mm)
> >>  {
> >>INIT_LIST_HEAD_RCU(&mm->context.iommu_group_mem_list);
> >>  }
> >> -
> >> -void mm_iommu_cleanup(struct mm_struct *mm)
> >> -{
> >> -  struct mm_iommu_table_group_mem_t *mem, *tmp;
> >> -
> >> -  list_for_each_entry_safe(mem, tmp, &mm->context.iommu_group_mem_list,
> >> -  next) {
> >> -  list_del_rcu(&mem->next);
> >> -  mm_iommu_do_free(mem);
> >> -  }
> >> -}
> >> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c 
> >> b/drivers/vfio/vfio_iommu_spapr_tce.c
> >> index 81ab93f..001a488 100644
> >> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> >> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> >> @@ -86,6 +86,15 @@ struct tce_iommu_group {
> >>  };
> >>  
> >>  /*
> >> + * A container needs to remember which preregistered region  it has
> >> + * ref

[PATCH 2/2] Revert "powerpc: Load Monitor Register Support"

2016-10-30 Thread Michael Neuling
Load monitored is no longer supported on POWER9 so let's remove the
code.

This reverts commit bd3ea317fddfd0f2044f94bed294b90c4bc8e69e.

Signed-off-by: Michael Neuling 
---
 arch/powerpc/include/asm/processor.h |  2 --
 arch/powerpc/include/asm/reg.h   |  5 -
 arch/powerpc/kernel/process.c| 18 --
 arch/powerpc/kernel/traps.c  |  9 -
 4 files changed, 34 deletions(-)

diff --git a/arch/powerpc/include/asm/processor.h 
b/arch/powerpc/include/asm/processor.h
index c07c31b0e8..5c0a665af1 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -312,8 +312,6 @@ struct thread_struct {
unsigned long   mmcr2;
unsignedmmcr0;
unsignedused_ebb;
-   unsigned long   lmrr;
-   unsigned long   lmser;
 #endif
 };
 
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index cff79885c2..86ccd0ec43 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -292,8 +292,6 @@
 #define SPRN_HRMOR 0x139   /* Real mode offset register */
 #define SPRN_HSRR0 0x13A   /* Hypervisor Save/Restore 0 */
 #define SPRN_HSRR1 0x13B   /* Hypervisor Save/Restore 1 */
-#define SPRN_LMRR  0x32D   /* Load Monitor Region Register */
-#define SPRN_LMSER 0x32E   /* Load Monitor Section Enable Register */
 #define SPRN_IC0x350   /* Virtual Instruction Count */
 #define SPRN_VTB   0x351   /* Virtual Time Base */
 #define SPRN_LDBAR 0x352   /* LD Base Address Register */
@@ -304,7 +302,6 @@
 #define SPRN_PMCR  0x374   /* Power Management Control Register */
 
 /* HFSCR and FSCR bit numbers are the same */
-#define FSCR_LM_LG 11  /* Enable Load Monitor Registers */
 #define FSCR_TAR_LG8   /* Enable Target Address Register */
 #define FSCR_EBB_LG7   /* Enable Event Based Branching */
 #define FSCR_TM_LG 5   /* Enable Transactional Memory */
@@ -314,12 +311,10 @@
 #define FSCR_VECVSX_LG 1   /* Enable VMX/VSX  */
 #define FSCR_FP_LG 0   /* Enable Floating Point */
 #define SPRN_FSCR  0x099   /* Facility Status & Control Register */
-#define   FSCR_LM  __MASK(FSCR_LM_LG)
 #define   FSCR_TAR __MASK(FSCR_TAR_LG)
 #define   FSCR_EBB __MASK(FSCR_EBB_LG)
 #define   FSCR_DSCR__MASK(FSCR_DSCR_LG)
 #define SPRN_HFSCR 0xbe/* HV=1 Facility Status & Control Register */
-#define   HFSCR_LM __MASK(FSCR_LM_LG)
 #define   HFSCR_TAR__MASK(FSCR_TAR_LG)
 #define   HFSCR_EBB__MASK(FSCR_EBB_LG)
 #define   HFSCR_TM __MASK(FSCR_TM_LG)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9e7c10fe20..345d7b4687 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1051,14 +1051,6 @@ static inline void save_sprs(struct thread_struct *t)
 */
t->tar = mfspr(SPRN_TAR);
}
-
-   if (cpu_has_feature(CPU_FTR_ARCH_300)) {
-   /* Conditionally save Load Monitor registers, if enabled */
-   if (t->fscr & FSCR_LM) {
-   t->lmrr = mfspr(SPRN_LMRR);
-   t->lmser = mfspr(SPRN_LMSER);
-   }
-   }
 #endif
 }
 
@@ -1094,16 +1086,6 @@ static inline void restore_sprs(struct thread_struct 
*old_thread,
if (old_thread->tar != new_thread->tar)
mtspr(SPRN_TAR, new_thread->tar);
}
-
-   if (cpu_has_feature(CPU_FTR_ARCH_300)) {
-   /* Conditionally restore Load Monitor registers, if enabled */
-   if (new_thread->fscr & FSCR_LM) {
-   if (old_thread->lmrr != new_thread->lmrr)
-   mtspr(SPRN_LMRR, new_thread->lmrr);
-   if (old_thread->lmser != new_thread->lmser)
-   mtspr(SPRN_LMSER, new_thread->lmser);
-   }
-   }
 #endif
 }
 
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 023a462725..dbb4d23c37 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1430,7 +1430,6 @@ void facility_unavailable_exception(struct pt_regs *regs)
[FSCR_TM_LG] = "TM",
[FSCR_EBB_LG] = "EBB",
[FSCR_TAR_LG] = "TAR",
-   [FSCR_LM_LG] = "LM",
};
char *facility = "unknown";
u64 value;
@@ -1488,14 +1487,6 @@ void facility_unavailable_exception(struct pt_regs *regs)
emulate_single_step(regs);
}
return;
-   } else if ((status == FSCR_LM_LG) && cpu_has_feature(CPU_FTR_ARCH_300)) 
{
-   /*
-* This process has touched LM, so turn it on forever
-* for this process
-*/
-   current->thread.fscr |= FSCR_LM;
-   mtspr(SPRN_FSCR, current->thread.fscr);
-   return;
}
 

[PATCH 1/2] Revert "selftests/powerpc: Load Monitor Register Tests"

2016-10-30 Thread Michael Neuling
Load monitored won't be supported in POWER9, so PPC_FEATURE2_ARCH_3_00
(in HWCAP2) will no longer imply Load monitor support.

These Load monitored tests are enabled by PPC_FEATURE2_ARCH_3_00 so
they are now bogus and need to be removed.

This reverts commit 16c19a2e983346c547501795aadffde1977b058d.

Signed-off-by: Michael Neuling 
---
 tools/testing/selftests/powerpc/pmu/ebb/.gitignore |   2 -
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   |   2 +-
 tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr.c  | 143 -
 tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr.h  |  39 --
 .../selftests/powerpc/pmu/ebb/ebb_lmr_regs.c   |  37 --
 tools/testing/selftests/powerpc/reg.h  |   5 -
 6 files changed, 1 insertion(+), 227 deletions(-)
 delete mode 100644 tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr.c
 delete mode 100644 tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr.h
 delete mode 100644 tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr_regs.c

diff --git a/tools/testing/selftests/powerpc/pmu/ebb/.gitignore 
b/tools/testing/selftests/powerpc/pmu/ebb/.gitignore
index 44b7df14a9..42bddbed8b 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/.gitignore
+++ b/tools/testing/selftests/powerpc/pmu/ebb/.gitignore
@@ -20,5 +20,3 @@ back_to_back_ebbs_test
 lost_exception_test
 no_handler_test
 cycles_with_mmcr2_test
-ebb_lmr
-ebb_lmr_regs
\ No newline at end of file
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile 
b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index 6b0453e60d..8d2279c4bb 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -14,7 +14,7 @@ TEST_PROGS := reg_access_test event_attributes_test 
cycles_test   \
 fork_cleanup_test ebb_on_child_test\
 ebb_on_willing_child_test back_to_back_ebbs_test   \
 lost_exception_test no_handler_test\
-cycles_with_mmcr2_test ebb_lmr ebb_lmr_regs
+cycles_with_mmcr2_test
 
 all: $(TEST_PROGS)
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr.c 
b/tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr.c
deleted file mode 100644
index c47ebd55ba..00
--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb_lmr.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2016, Jack Miller, IBM Corp.
- * Licensed under GPLv2.
- */
-
-#include 
-#include 
-
-#include "ebb.h"
-#include "ebb_lmr.h"
-
-#define SIZE   (32 * 1024 * 1024)  /* 32M */
-#define LM_SIZE0   /* Smallest encoding, 32M */
-
-#define SECTIONS   64  /* 1 per bit in LMSER */
-#define SECTION_SIZE   (SIZE / SECTIONS)
-#define SECTION_LONGS   (SECTION_SIZE / sizeof(long))
-
-static unsigned long *test_mem;
-
-static int lmr_count = 0;
-
-void ebb_lmr_handler(void)
-{
-   lmr_count++;
-}
-
-void ldmx_full_section(unsigned long *mem, int section)
-{
-   unsigned long *ptr;
-   int i;
-
-   for (i = 0; i < SECTION_LONGS; i++) {
-   ptr = &mem[(SECTION_LONGS * section) + i];
-   ldmx((unsigned long) &ptr);
-   ebb_lmr_reset();
-   }
-}
-
-unsigned long section_masks[] = {
-   0x8000,
-   0xFF00,
-   0x000F7000,
-   0x8001,
-   0xF0F0F0F0F0F0F0F0,
-   0x0F0F0F0F0F0F0F0F,
-   0x0
-};
-
-int ebb_lmr_section_test(unsigned long *mem)
-{
-   unsigned long *mask = section_masks;
-   int i;
-
-   for (; *mask; mask++) {
-   mtspr(SPRN_LMSER, *mask);
-   printf("Testing mask 0x%016lx\n", mfspr(SPRN_LMSER));
-
-   for (i = 0; i < 64; i++) {
-   lmr_count = 0;
-   ldmx_full_section(mem, i);
-   if (*mask & (1UL << (63 - i)))
-   FAIL_IF(lmr_count != SECTION_LONGS);
-   else
-   FAIL_IF(lmr_count);
-   }
-   }
-
-   return 0;
-}
-
-int ebb_lmr(void)
-{
-   int i;
-
-   SKIP_IF(!lmr_is_supported());
-
-   setup_ebb_handler(ebb_lmr_handler);
-
-   ebb_global_enable();
-
-   FAIL_IF(posix_memalign((void **)&test_mem, SIZE, SIZE) != 0);
-
-   mtspr(SPRN_LMSER, 0);
-
-   FAIL_IF(mfspr(SPRN_LMSER) != 0);
-
-   mtspr(SPRN_LMRR, ((unsigned long)test_mem | LM_SIZE));
-
-   FAIL_IF(mfspr(SPRN_LMRR) != ((unsigned long)test_mem | LM_SIZE));
-
-   /* Read every single byte to ensure we get no false positives */
-   for (i = 0; i < SECTIONS; i++)
-   ldmx_full_section(test_mem, i);
-
-   FAIL_IF(lmr_count != 0);
-
-   /* Turn on the first section */
-
-   mtspr(SPRN_LMSER, (1UL << 63));
-   FAIL_IF(mfspr(SPRN_LMSER) != (1UL << 63));
-
-   /* Enable LM (BESCR) */
-
-   mtspr(SPRN_BESCR, mfspr(SPRN_BESCR) | BESCR_LME);
-   FAIL_IF(!(mfspr(SPRN_BESCR) & BESCR_LME));
-
-   ldmx((unsigne

[PATCH] powerpc/powernv: de-deuplicate OPAL call wrappers

2016-10-30 Thread Oliver O'Halloran
Currently the code to perform an OPAL call is duplicated between the
normal path and path taken when tracepoints are enabled. There's no
real need for this and combining them makes opal_tracepoint_entry
considerably easier to understand.

Signed-off-by: Oliver O'Halloran 
---
 arch/powerpc/platforms/powernv/opal-wrappers.S | 44 ++
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 44d2d842cee7..3ebe0db7ffeb 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -50,18 +50,14 @@ END_FTR_SECTION(0, 1);  
\
 #define OPAL_BRANCH(LABEL)
 #endif
 
-/* TODO:
+/*
+ * DO_OPAL_CALL assumes:
  *
- * - Trace irqs in/off (needs saving/restoring all args, argh...)
- * - Get r11 feed up by Dave so I can have better register usage
+ * r0 = OPAL call token
+ * LR has been saved on the stack
  */
 
-#define OPAL_CALL(name, token) \
- _GLOBAL_TOC(name);\
-   mflrr0; \
-   std r0,PPC_LR_STKOFF(r1);   \
-   li  r0,token;   \
-   OPAL_BRANCH(opal_tracepoint_entry) \
+#define DO_OPAL_CALL() \
mfcrr12;\
stw r12,8(r1);  \
li  r11,0;  \
@@ -81,6 +77,14 @@ END_FTR_SECTION(0, 1);   
\
mtspr   SPRN_HSRR0,r12; \
hrfid
 
+#define OPAL_CALL(name, token) \
+ _GLOBAL_TOC(name);\
+   mflrr0; \
+   std r0,PPC_LR_STKOFF(r1);   \
+   li  r0,token;   \
+   OPAL_BRANCH(opal_tracepoint_entry) \
+   DO_OPAL_CALL()
+
 opal_return:
/*
 * Fixup endian on OPAL return... we should be able to simplify
@@ -122,26 +126,12 @@ opal_tracepoint_entry:
ld  r8,STK_REG(R29)(r1)
ld  r9,STK_REG(R30)(r1)
ld  r10,STK_REG(R31)(r1)
+
+   /* return from the opal call via tracepoint_return */
LOAD_REG_ADDR(r11,opal_tracepoint_return)
-   mfcrr12
std r11,16(r1)
-   stw r12,8(r1)
-   li  r11,0
-   mfmsr   r12
-   ori r11,r11,MSR_EE
-   std r12,PACASAVEDMSR(r13)
-   andcr12,r12,r11
-   mtmsrd  r12,1
-   LOAD_REG_ADDR(r11,opal_return)
-   mtlrr11
-   li  r11,MSR_DR|MSR_IR|MSR_LE
-   andcr12,r12,r11
-   mtspr   SPRN_HSRR1,r12
-   LOAD_REG_ADDR(r11,opal)
-   ld  r12,8(r11)
-   ld  r2,0(r11)
-   mtspr   SPRN_HSRR0,r12
-   hrfid
+
+   DO_OPAL_CALL()
 
 opal_tracepoint_return:
std r3,STK_REG(R31)(r1)
-- 
2.5.5



[PATCH V2 2/2] powerpc/kvm: Update kvmppc_set_arch_compat() for ISA v3.00

2016-10-30 Thread Suraj Jitindar Singh
The function kvmppc_set_arch_compat() is used to determine the value of the
processor compatibility register (PCR) for a guest running in a given
compatibility mode. There is currently no support for v3.00 of the ISA.

Add support for v3.00 of the ISA which adds an ISA v2.07 compatilibity mode
to the PCR.

We also add a check to ensure the processor we are running on is capable of
emulating the chosen processor (for example a POWER7 cannot emulate a
POWER8, similarly with a POWER8 and a POWER9).

Signed-off-by: Suraj Jitindar Singh 
---
 arch/powerpc/kvm/book3s_hv.c | 32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 3686471..24681e7 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -311,24 +311,38 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, 
u32 arch_compat)
 * If an arch bit is set in PCR, all the defined
 * higher-order arch bits also have to be set.
 */
-   pcr = PCR_ARCH_206 | PCR_ARCH_205;
+   if (cpu_has_feature(CPU_FTR_ARCH_206))
+   pcr |= PCR_ARCH_205;
+   if (cpu_has_feature(CPU_FTR_ARCH_207S))
+   pcr |= PCR_ARCH_206;
+   if (cpu_has_feature(CPU_FTR_ARCH_300))
+   pcr |= PCR_ARCH_207;
break;
case PVR_ARCH_206:
case PVR_ARCH_206p:
-   pcr = PCR_ARCH_206;
+   /* Must be at least v2.06 to (emulate) it */
+   if (!cpu_has_feature(CPU_FTR_ARCH_206))
+   return -EINVAL;
+   if (cpu_has_feature(CPU_FTR_ARCH_207S))
+   pcr |= PCR_ARCH_206;
+   if (cpu_has_feature(CPU_FTR_ARCH_300))
+   pcr |= PCR_ARCH_207;
break;
case PVR_ARCH_207:
+   /* Must be at least v2.07 to (emulate) it */
+   if (!cpu_has_feature(CPU_FTR_ARCH_207S))
+   return -EINVAL;
+   if (cpu_has_feature(CPU_FTR_ARCH_300))
+   pcr |= PCR_ARCH_207;
+   break;
+   case PVR_ARCH_300:
+   /* Must be at least v3.00 to (emulate) it */
+   if (!cpu_has_feature(CPU_FTR_ARCH_300))
+   return -EINVAL;
break;
default:
return -EINVAL;
}
-
-   if (!cpu_has_feature(CPU_FTR_ARCH_207S)) {
-   /* POWER7 can't emulate POWER8 */
-   if (!(pcr & PCR_ARCH_206))
-   return -EINVAL;
-   pcr &= ~PCR_ARCH_206;
-   }
}
 
spin_lock(&vc->lock);
-- 
2.5.5



[PATCH V2 1/2] powerpc: Define new ISA v3.00 logical PVR value and PCR register value

2016-10-30 Thread Suraj Jitindar Singh
ISA 3.00 adds the logical PVR value 0x0f05, so add a definition for
this.

Define PCR_ARCH_207 to reflect ISA 2.07 compatibility mode in the processor
compatibility register (PCR).

Signed-off-by: Suraj Jitindar Singh 
---
 arch/powerpc/include/asm/reg.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 9cd4e8c..74c8079 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -377,6 +377,7 @@
 #define   PCR_VEC_DIS  (1ul << (63-0)) /* Vec. disable (bit NA since POWER8) */
 #define   PCR_VSX_DIS  (1ul << (63-1)) /* VSX disable (bit NA since POWER8) */
 #define   PCR_TM_DIS   (1ul << (63-2)) /* Trans. memory disable (POWER8) */
+#define   PCR_ARCH_207 0x8 /* Architecture 2.07 */
 #define   PCR_ARCH_206 0x4 /* Architecture 2.06 */
 #define   PCR_ARCH_205 0x2 /* Architecture 2.05 */
 #defineSPRN_HEIR   0x153   /* Hypervisor Emulated Instruction 
Register */
@@ -1218,6 +1219,7 @@
 #define PVR_ARCH_206   0x0f03
 #define PVR_ARCH_206p  0x0f13
 #define PVR_ARCH_207   0x0f04
+#define PVR_ARCH_300   0x0f05
 
 /* Macros for setting and retrieving special purpose registers */
 #ifndef __ASSEMBLY__
-- 
2.5.5



[PATCH V2 0/2] powerpc: add support for ISA v2.07 compat level

2016-10-30 Thread Suraj Jitindar Singh
Version v3.00 of the ISA added a new compat level to the processor
compatibility register (PCR), an ISA v2.07 compatibility mode.

Upstream QEMU already supports this so it may as well go into the kernel
now.

Change Log:

V1 -> V2:
- Reworked logic to set and mask the PCR, no functional change

Suraj Jitindar Singh (2):
  powerpc: Define new ISA v3.00 logical PVR value and PCR register value
  powerpc/kvm: Update kvmppc_set_arch_compat() for ISA v3.00

 arch/powerpc/include/asm/reg.h |  2 ++
 arch/powerpc/kvm/book3s_hv.c   | 32 +++-
 2 files changed, 25 insertions(+), 9 deletions(-)

-- 
2.5.5



Re: [PATCH 1/3] ABI: fix some syntax issues at the ABI database

2016-10-30 Thread Jonathan Cameron
On 28/10/16 13:19, Mauro Carvalho Chehab wrote:
> On those three files, the ABI representation described at
> README are violated.
> 
> - at sysfs-bus-iio-proximity-as3935:
>   a ':' character is missing after "What"
> 
> - at sysfs-class-devfreq:
>   there's a typo at Description
> 
> - at sysfs-class-cxl, it is using the ":" character at a
>   file preamble, causing it to be misinterpreted as a
>   tag.
> 
> - On the other files, instead of "What", they use "Where".
> 
> Signed-off-by: Mauro Carvalho Chehab 
Acked-by: Jonathan Cameron  for the iio one.

As an aside, I think that hm6352 is probably the docs fo the hmc6352 driver in 
misc.
Hence wrong filename perhaps?

Thanks,
Jonathan

> ---
>  Documentation/ABI/testing/pstore   |  2 +-
>  .../testing/sysfs-bus-event_source-devices-format  |  2 +-
>  .../ABI/testing/sysfs-bus-i2c-devices-hm6352   |  6 +++---
>  .../ABI/testing/sysfs-bus-iio-proximity-as3935 |  4 ++--
>  .../ABI/testing/sysfs-bus-pci-devices-cciss| 22 
> +++---
>  .../ABI/testing/sysfs-bus-usb-devices-usbsevseg| 12 ++--
>  Documentation/ABI/testing/sysfs-class-cxl  |  6 +++---
>  Documentation/ABI/testing/sysfs-class-devfreq  |  2 +-
>  8 files changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/pstore 
> b/Documentation/ABI/testing/pstore
> index 5fca9f5e10a3..8d6e48f4e8ef 100644
> --- a/Documentation/ABI/testing/pstore
> +++ b/Documentation/ABI/testing/pstore
> @@ -1,4 +1,4 @@
> -Where:   /sys/fs/pstore/... (or /dev/pstore/...)
> +What:/sys/fs/pstore/... (or /dev/pstore/...)
>  Date:March 2011
>  Kernel Version: 2.6.39
>  Contact: tony.l...@intel.com
> diff --git a/Documentation/ABI/testing/sysfs-bus-event_source-devices-format 
> b/Documentation/ABI/testing/sysfs-bus-event_source-devices-format
> index 77f47ff5ee02..b6f8748e0200 100644
> --- a/Documentation/ABI/testing/sysfs-bus-event_source-devices-format
> +++ b/Documentation/ABI/testing/sysfs-bus-event_source-devices-format
> @@ -1,4 +1,4 @@
> -Where:   /sys/bus/event_source/devices//format
> +What:/sys/bus/event_source/devices//format
>  Date:January 2012
>  Kernel Version: 3.3
>  Contact: Jiri Olsa 
> diff --git a/Documentation/ABI/testing/sysfs-bus-i2c-devices-hm6352 
> b/Documentation/ABI/testing/sysfs-bus-i2c-devices-hm6352
> index feb2e4a87075..29bd447e50a0 100644
> --- a/Documentation/ABI/testing/sysfs-bus-i2c-devices-hm6352
> +++ b/Documentation/ABI/testing/sysfs-bus-i2c-devices-hm6352
> @@ -1,18 +1,18 @@
> -Where:   /sys/bus/i2c/devices/.../heading0_input
> +What:/sys/bus/i2c/devices/.../heading0_input
>  Date:April 2010
>  Kernel Version: 2.6.36?
>  Contact: alan@intel.com
>  Description: Reports the current heading from the compass as a floating
>   point value in degrees.
>  
> -Where:   /sys/bus/i2c/devices/.../power_state
> +What:/sys/bus/i2c/devices/.../power_state
>  Date:April 2010
>  Kernel Version: 2.6.36?
>  Contact: alan@intel.com
>  Description: Sets the power state of the device. 0 sets the device into
>   sleep mode, 1 wakes it up.
>  
> -Where:   /sys/bus/i2c/devices/.../calibration
> +What:/sys/bus/i2c/devices/.../calibration
>  Date:April 2010
>  Kernel Version: 2.6.36?
>  Contact: alan@intel.com
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 
> b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
> index 33e96f740639..61a3c9fed07d 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
> +++ b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
> @@ -1,4 +1,4 @@
> -What /sys/bus/iio/devices/iio:deviceX/in_proximity_input
> +What:/sys/bus/iio/devices/iio:deviceX/in_proximity_input
>  Date:March 2014
>  KernelVersion:   3.15
>  Contact: Matt Ranostay 
> @@ -6,7 +6,7 @@ Description:
>   Get the current distance in meters of storm (1km steps)
>   1000-4 = distance in meters
>  
> -What /sys/bus/iio/devices/iio:deviceX/sensor_sensitivity
> +What:/sys/bus/iio/devices/iio:deviceX/sensor_sensitivity
>  Date:March 2014
>  KernelVersion:   3.15
>  Contact: Matt Ranostay 
> diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss 
> b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss
> index 53d99edd1d75..eb449169c30b 100644
> --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss
> +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss
> @@ -1,66 +1,66 @@
> -Where:   /sys/bus/pci/devices//ccissX/cXdY/model
> +What:/sys/bus/pci/devices//ccissX/cXdY/model
>  Date:March 2009
>  Kernel Ve

[PATCH] cxl: Fix error handling

2016-10-30 Thread Christophe JAILLET
'cxl_dev_context_init()' returns an error pointer in case of error, not
NULL. So test it with IS_ERR.

Signed-off-by: Christophe JAILLET 
---
un-compiled because I don't have the required  cross build environment.
---
 drivers/misc/cxl/pci.c | 2 +-
 drivers/misc/cxl/phb.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index e96be9ca4e60..80a87ab25b83 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1921,7 +1921,7 @@ static pci_ers_result_t cxl_pci_slot_reset(struct pci_dev 
*pdev)
goto err;
 
ctx = cxl_dev_context_init(afu_dev);
-   if (!ctx)
+   if (IS_ERR(ctx))
goto err;
 
afu_dev->dev.archdata.cxl_ctx = ctx;
diff --git a/drivers/misc/cxl/phb.c b/drivers/misc/cxl/phb.c
index 0935d44c1770..6ec69ada19f4 100644
--- a/drivers/misc/cxl/phb.c
+++ b/drivers/misc/cxl/phb.c
@@ -20,7 +20,7 @@ bool _cxl_pci_associate_default_context(struct pci_dev *dev, 
struct cxl_afu *afu
 * in the virtual phb, we'll need a default context to attach them to.
 */
ctx = cxl_dev_context_init(dev);
-   if (!ctx)
+   if (IS_ERR(ctx))
return false;
dev->dev.archdata.cxl_ctx = ctx;
 
-- 
2.9.3



[PATCH] cxl: Fix error handling

2016-10-30 Thread Christophe JAILLET
'cxl_dev_context_init()' returns an error pointer in case of error, not
NULL. So test it with IS_ERR.

Signed-off-by: Christophe JAILLET 
---
un-compiled because I don't have the required  cross build environment.
---
 drivers/misc/cxl/api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index 2b88ad8a2a89..e2efc6489c6e 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -538,7 +538,7 @@ int _cxl_cx4_setup_msi_irqs(struct pci_dev *pdev, int nvec, 
int type)
 
if (remaining > 0) {
new_ctx = cxl_dev_context_init(pdev);
-   if (!new_ctx) {
+   if (IS_ERR(new_ctx)) {
pr_warn("%s: Failed to allocate enough contexts 
for MSIs\n", pci_name(pdev));
return -ENOSPC;
}
-- 
2.9.3



Re: [PATCH] cxl: Fix memory allocation failure test

2016-10-30 Thread walter harms


Am 30.10.2016 20:35, schrieb Christophe JAILLET:
> 'cxl_context_alloc()' does not return an error pointer. It is just a
> shortcut for a call to 'kzalloc' with 'sizeof(struct cxl_context)' as the
> size parameter.
> 
> So its return value should be compared with NULL.
> While fixing it, simplify a bit the code.
> 
> Signed-off-by: Christophe JAILLET 
> ---
> un-compiled because I don't have the required  cross build environment.
> ---
>  drivers/misc/cxl/api.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
> index 2e5233b60971..2b88ad8a2a89 100644
> --- a/drivers/misc/cxl/api.c
> +++ b/drivers/misc/cxl/api.c
> @@ -30,10 +30,8 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev 
> *dev)
>   return ERR_CAST(afu);
>  
>   ctx = cxl_context_alloc();
> - if (IS_ERR(ctx)) {
> - rc = PTR_ERR(ctx);
> - goto err_dev;
> - }
> + if (!ctx)
> + return ERR_PTR(-ENOMEM);
>  

So far i see it is only used 2 times,
To avoid such problems it should be replaced with
kzalloc(sizeof(struct cxl_context), GFP_KERNEL); (from context.c)

or even better:
ctx = kzalloc(*ctx, GFP_KERNEL);

This way the error had been spotted much more early.

just my 2 cents,
re,
 wh

>   ctx->kernelapi = true;
>  
> @@ -61,7 +59,6 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev 
> *dev)
>   kfree(mapping);
>  err_ctx:
>   kfree(ctx);
> -err_dev:
>   return ERR_PTR(rc);
>  }
>  EXPORT_SYMBOL_GPL(cxl_dev_context_init);


[PATCH] cxl: Fix memory allocation failure test

2016-10-30 Thread Christophe JAILLET
'cxl_context_alloc()' does not return an error pointer. It is just a
shortcut for a call to 'kzalloc' with 'sizeof(struct cxl_context)' as the
size parameter.

So its return value should be compared with NULL.
While fixing it, simplify a bit the code.

Signed-off-by: Christophe JAILLET 
---
un-compiled because I don't have the required  cross build environment.
---
 drivers/misc/cxl/api.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index 2e5233b60971..2b88ad8a2a89 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -30,10 +30,8 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev)
return ERR_CAST(afu);
 
ctx = cxl_context_alloc();
-   if (IS_ERR(ctx)) {
-   rc = PTR_ERR(ctx);
-   goto err_dev;
-   }
+   if (!ctx)
+   return ERR_PTR(-ENOMEM);
 
ctx->kernelapi = true;
 
@@ -61,7 +59,6 @@ struct cxl_context *cxl_dev_context_init(struct pci_dev *dev)
kfree(mapping);
 err_ctx:
kfree(ctx);
-err_dev:
return ERR_PTR(rc);
 }
 EXPORT_SYMBOL_GPL(cxl_dev_context_init);
-- 
2.9.3



Re: [PATCH v2 02/16] scsi: don't use fc_bsg_job::request and fc_bsg_job::reply directly

2016-10-30 Thread Johannes Thumshirn
On Fri, Oct 28, 2016 at 11:53:46AM +0200, Steffen Maier wrote:

[...]

> > > 
> > > > @@ -3937,6 +3944,7 @@ fc_bsg_request_handler(struct request_queue *q, 
> > > > struct Scsi_Host *shost,
> > > > struct request *req;
> > > > struct fc_bsg_job *job;
> > > > enum fc_dispatch_result ret;
> > > > +   struct fc_bsg_reply *bsg_reply;
> > > > 
> > > > if (!get_device(dev))
> > > > return;
> > > > @@ -3973,8 +3981,9 @@ fc_bsg_request_handler(struct request_queue *q, 
> > > > struct Scsi_Host *shost,
> > > > /* check if we have the msgcode value at least */
> > > > if (job->request_len < sizeof(uint32_t)) {
> > > > BUG_ON(job->reply_len < sizeof(uint32_t));
> > > > -   job->reply->reply_payload_rcv_len = 0;
> > > > -   job->reply->result = -ENOMSG;
> > > > +   bsg_reply = job->reply;
> > > > +   bsg_reply->reply_payload_rcv_len = 0;
> > > > +   bsg_reply->result = -ENOMSG;
> 
> Compiler optimization re-ordered above two lines and the first pointer
> derefence is bsg_reply->result [field offset 0] where bsg_reply is NULL.
> The assignment tries to write to memory at address NULL causing the kernel
> page fault.
> 
> Does your suggested change for [PATCH v3 02/16], shuffling the
> job->request_len checks, address above kernel page fault?

This is what I hope at least. I'm sorry but I don't have any experience with 
s390
and zfcp at all. I still need to get a test environment set up, but all the
people knowing how to do are rather busy at the moment. All my tests on x86_64
with FCoE and lpfc haven't had a problem so far.

Thanks,
Johannes
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH v6 02/11] locking/osq: Drop the overload of osq_lock()

2016-10-30 Thread Pan Xinhui



在 2016/10/30 00:52, Davidlohr Bueso 写道:

On Fri, 28 Oct 2016, Pan Xinhui wrote:

/*
 * If we need to reschedule bail... so we can block.
+ * Use vcpu_is_preempted to detech lock holder preemption issue

   ^^ detect

ok. thanks for poingting it out.

+ * and break.


Could you please remove the rest of this comment? Its just noise to point out
that vcpu_is_preempted is a macro defined by arch/false. This is standard 
protocol
in the kernel.


fair enough.


Same goes for all locks you change with this.

Thanks,
Davidlohr


   * vcpu_is_preempted is a macro defined by false if
+ * arch does not support vcpu preempted check,
 */
-if (need_resched())
+if (need_resched() || vcpu_is_preempted(node_cpu(node->prev)))
goto unqueue;

cpu_relax_lowlatency();
--
2.4.11







Linux 4.9: Reported regressions as of Sunday, 2016-10-30

2016-10-30 Thread Thorsten Leemhuis
Hi! Here is my second regression report for Linux 4.9. It lists 14
regressions I'm aware of. 4 of them are new; 3 got fixed since last weeks 
report.

As always: Are you aware of any other regressions? Then please let me
know (simply CC regressi...@leemhuis.info). And please tell me if there
is anything in the report that shouldn't be there.

Ciao, Thorsten

== Current regressions ==

Desc: tpm0: TPM self test failed
Repo: 2016-10-28 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1259943.html
Stat: 2016-10-28 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1260452.html 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1256705.html 
Note: Fix hopefully soon heading upstream

Desc: Radeon Oops on shutdown
Repo: 2016-10-19 https://bugzilla.kernel.org/show_bug.cgi?id=178421
Stat: 2016-10-30 https://bugzilla.kernel.org/show_bug.cgi?id=178421#c6
Note: WIP

Desc: module loadling broken due to kbuild changes
Repo: 2016-10-15 http://www.gossamer-threads.com/lists/linux/kernel/2544734
Stat: 2016-10-27 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1259418.html
Note: Fix available, waiting for Michal to get back from vacation; wondering if 
those will fix https://bugzilla.kernel.org/show_bug.cgi?id=185581 and 
https://lkml.org/lkml/2016/10/27/471 and 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1250105.html as 
well

Desc: pci: artpec-6: imprecise external abort
Repo: 2016-10-14 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1249646.html
Stat: 2016-10-14 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1249922.html
Note: Patch available

Desc: PPC32: fails to boot on my PowerBook G4 Aluminum; bisected to commit 
05fd007e4629
Repo: 2016-10-20 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1253391.html
Stat: 2016-10-22 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1255516.html 
https://www.linux-mips.org/archives/linux-mips/2016-10/msg00176.html 
https://lkml.org/lkml/2016/10/18/142
Note: Larry made a hack that works for him.

Desc: "Nokia N900 (omap3-n900) with ""VDD1: ramp_delay not set"" string in 
printk frequently"
Repo: 2016-10-19 https://bugzilla.kernel.org/show_bug.cgi?id=178371
Stat: n/a https://lkml.org/lkml/2016/10/27/527
Note: discussion on lkml ongoing

Desc: radeon performance drop from 4.8 to 4.9-rc1 in Shadow of Mordor
Repo: 2016-10-14 https://bugzilla.kernel.org/show_bug.cgi?id=178221 
https://lists.freedesktop.org/archives/dri-devel/2016-October/120693.html
Stat: 2016-10-20 
https://lists.freedesktop.org/archives/dri-devel/2016-October/121427.html
Note: Stuck? Poked bugzilla

Desc: unable to handle kernel NULL pointer dereference at fuse_setattr
Repo: 2016-10-17 https://bugzilla.kernel.org/show_bug.cgi?id=177801
Stat: 2016-10-18 https://bugzilla.kernel.org/show_bug.cgi?id=177801#c5
Note: Fix heading upstream

Desc: Skylake gen6 suspend/resume video regression
Repo: 2016-10-16 https://bugzilla.kernel.org/show_bug.cgi?id=177731
Stat: 2016-10-25 https://bugzilla.kernel.org/show_bug.cgi?id=177731#c3
Note: WIP

Desc: warning in intel_dp_aux_transfer: CPU: 0 PID: 4 at 
drivers/gpu/drm/i915/intel_dp.c:1062 intel_dp_aux_transfer+0x1ed/0x230#
Repo: 2016-10-16 https://bugzilla.kernel.org/show_bug.cgi?id=177701
Stat: 2016-10-27 https://bugs.freedesktop.org/show_bug.cgi?id=97344
Note: Poked Janni to give a statement

Desc: """Failed to find cpu0 device node"" in dmesg"
Repo: 2016-10-16 https://bugzilla.kernel.org/show_bug.cgi?id=177681 
https://bugzilla.kernel.org/show_bug.cgi?id=180031
Stat: 2016-10-28 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1260133.html
Note: Patches afaics in the work

Desc: boot failure of Intel Mobile Internet Devices due to a change in the PCI 
subsystem that appeared in v4.9-rc1.
Repo: 2016-10-23 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1255643.html
Stat: 2016-10-26 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1258579.html
Note: Fix proposed

Desc: 4.9-rc1 boot regression, ambiguous bisect result
Repo: 2016-10-19 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1253369.html
Stat: 2016-10-21 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1255296.html
Note: Poked list, as this looks stuck or was is discussed (or even fixed) 
somewhere else


== Stalled, waiting for feedback from reporter ==

Desc: can't boot with root fs on md raid 0; mdadm: no devices listed in conf 
file were found. 
Repo: 2016-10-17 https://bugzilla.kernel.org/show_bug.cgi?id=178211
Stat: 2016-10-18 https://bugzilla.kernel.org/show_bug.cgi?id=178211#c1
Note: Root cause unknown; might be a controller driver issue


== Going to be removed from the list ==

Desc: some gpio drivers broken by commit 762c2e46
Repo: 2016-10-18 https://www.spinics.net/lists/linux-gpio/msg17283.html
Stat: 2016-10-21 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1253906.html
Note: Not a 4.9 regression


== Fixed sinc

Re: [PATCH] console: use first console if stdout-path device doesn't appear

2016-10-30 Thread Andreas Schwab
Any news?

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."