Re: [PATCH 0/3] Resolve -Wattribute-alias warnings from SYSCALL_DEFINEx()

2018-06-18 Thread Christophe LEROY




Le 16/06/2018 à 02:53, Paul Burton a écrit :

This series introduces infrastructure allowing compiler diagnostics to
be disabled or their severity modified for specific pieces of code, with
suitable abstractions to prevent that code from becoming tied to a
specific compiler.

This infrastructure is then used to disable the -Wattribute-alias
warning around syscall definitions, which rely on type mismatches to
sanitize arguments.

Finally PowerPC-specific #pragma's are removed now that the generic code
is handling this.

The series takes Arnd's RFC patches & addresses the review comments they
received. The most notable effect of this series to to avoid warnings &
build failures caused by -Wattribute-alias when compiling the kernel
with GCC 8.

Applies cleanly atop master as of 9215310cf13b ("Merge
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net").

Thanks,
 Paul

Arnd Bergmann (2):
   kbuild: add macro for controlling warnings to linux/compiler.h
   disable -Wattribute-alias warning for SYSCALL_DEFINEx()

Paul Burton (1):
   Revert "powerpc: fix build failure by disabling attribute-alias
 warning in pci_32"

  arch/powerpc/kernel/pci_32.c   |  4 ---
  include/linux/compat.h |  8 -
  include/linux/compiler-gcc.h   | 66 ++
  include/linux/compiler_types.h | 18 ++
  include/linux/syscalls.h   |  4 +++
  5 files changed, 95 insertions(+), 5 deletions(-)



Works well, thanks.

You can then also revert2479bfc9bc600dcce7f932d52dcfa8d677c41f93
("powerpc: Fix build by disabling attribute-alias warning for 
SYSCALL_DEFINEx")


Christophe


Re: [PATCH 1/3] kbuild: add macro for controlling warnings to linux/compiler.h

2018-06-18 Thread Christophe LEROY




Le 16/06/2018 à 02:53, Paul Burton a écrit :

From: Arnd Bergmann 

I have occasionally run into a situation where it would make sense to
control a compiler warning from a source file rather than doing so from
a Makefile using the $(cc-disable-warning, ...) or $(cc-option, ...)
helpers.

The approach here is similar to what glibc uses, using __diag() and
related macros to encapsulate a _Pragma("GCC diagnostic ...") statement
that gets turned into the respective "#pragma GCC diagnostic ..." by
the preprocessor when the macro gets expanded.

Like glibc, I also have an argument to pass the affected compiler
version, but decided to actually evaluate that one. For now, this
supports GCC_4_6, GCC_4_7, GCC_4_8, GCC_4_9, GCC_5, GCC_6, GCC_7,
GCC_8 and GCC_9. Adding support for CLANG_5 and other interesting
versions is straightforward here. GNU compilers starting with gcc-4.2
could support it in principle, but "#pragma GCC diagnostic push"
was only added in gcc-4.6, so it seems simpler to not deal with those
at all. The same versions show a large number of warnings already,
so it seems easier to just leave it at that and not do a more
fine-grained control for them.

The use cases I found so far include:

- turning off the gcc-8 -Wattribute-alias warning inside of the
   SYSCALL_DEFINEx() macro without having to do it globally.

- Reducing the build time for a simple re-make after a change,
   once we move the warnings from ./Makefile and
   ./scripts/Makefile.extrawarn into linux/compiler.h

- More control over the warnings based on other configurations,
   using preprocessor syntax instead of Makefile syntax. This should make
   it easier for the average developer to understand and change things.

- Adding an easy way to turn the W=1 option on unconditionally
   for a subdirectory or a specific file. This has been requested
   by several developers in the past that want to have their subsystems
   W=1 clean.

- Integrating clang better into the build systems. Clang supports
   more warnings than GCC, and we probably want to classify them
   as default, W=1, W=2 etc, but there are cases in which the
   warnings should be classified differently due to excessive false
   positives from one or the other compiler.

- Adding a way to turn the default warnings into errors (e.g. using
   a new "make E=0" tag) while not also turning the W=1 warnings into
   errors.

This patch for now just adds the minimal infrastructure in order to
do the first of the list above. As the #pragma GCC diagnostic
takes precedence over command line options, the next step would be
to convert a lot of the individual Makefiles that set nonstandard
options to use __diag() instead.

[paul.bur...@mips.com:
   - Rebase atop current master.
   - Add __diag_GCC, or more generally __diag_, abstraction to
 avoid code outside of linux/compiler-gcc.h needing to duplicate
 knowledge about different GCC versions.
   - Add a comment argument to __diag_{ignore,warn,error} which isn't
 used in the expansion of the macros but serves to push people to
 document the reason for using them - per feedback from Kees Cook.]

Signed-off-by: Arnd Bergmann 
Signed-off-by: Paul Burton 
Cc: Michal Marek 
Cc: Masahiro Yamada 
Cc: Douglas Anderson 
Cc: Al Viro 
Cc: Heiko Carstens 
Cc: Mauro Carvalho Chehab 
Cc: Matthew Wilcox 
Cc: Matthias Kaehlcke 
Cc: Arnd Bergmann 
Cc: Ingo Molnar 
Cc: Josh Poimboeuf 
Cc: Kees Cook 
Cc: Andrew Morton 
Cc: Thomas Gleixner 
Cc: Gideon Israel Dsouza 
Cc: Christophe Leroy 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Stafford Horne 
Cc: Khem Raj 
Cc: He Zhe 
Cc: linux-kbu...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linuxppc-dev@lists.ozlabs.org


Tested-by: Christophe Leroy 


---

  include/linux/compiler-gcc.h   | 66 ++
  include/linux/compiler_types.h | 18 ++
  2 files changed, 84 insertions(+)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index f1a7492a5cc8..aba64a2912d8 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -347,3 +347,69 @@
  #if GCC_VERSION >= 50100
  #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
  #endif
+
+/*
+ * turn individual warnings and errors on and off locally, depending
+ * on version.
+ */
+#define __diag_GCC(version, s) __diag_GCC_ ## version(s)
+
+#if GCC_VERSION >= 40600
+#define __diag_str1(s) #s
+#define __diag_str(s) __diag_str1(s)
+#define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
+
+/* compilers before gcc-4.6 do not understand "#pragma GCC diagnostic push" */
+#define __diag_GCC_4_6(s) __diag(s)
+#else
+#define __diag(s)
+#define __diag_GCC_4_6(s)
+#endif
+
+#if GCC_VERSION >= 40700
+#define __diag_GCC_4_7(s) __diag(s)
+#else
+#define __diag_GCC_4_7(s)
+#endif
+
+#if GCC_VERSION >= 40800
+#define __diag_GCC_4_8(s) __diag(s)
+#else
+#define __diag_GCC_4_8(s)
+#endif
+
+#if GCC_VERSION >= 40900
+#define __diag_GCC

Re: [PATCH 2/3] disable -Wattribute-alias warning for SYSCALL_DEFINEx()

2018-06-18 Thread Christophe LEROY




Le 16/06/2018 à 02:53, Paul Burton a écrit :

From: Arnd Bergmann 

gcc-8 warns for every single definition of a system call entry
point, e.g.:

include/linux/compat.h:56:18: error: 'compat_sys_rt_sigprocmask' alias between functions of 
incompatible types 'long int(int,  compat_sigset_t *, compat_sigset_t *, compat_size_t)' 
{aka 'long int(int,  struct  *, struct  *, unsigned 
int)'} and 'long int(long int,  long int,  long int,  long int)' [-Werror=attribute-alias]
   asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\
   ^~
include/linux/compat.h:45:2: note: in expansion of macro 
'COMPAT_SYSCALL_DEFINEx'
   COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
   ^~
kernel/signal.c:2601:1: note: in expansion of macro 'COMPAT_SYSCALL_DEFINE4'
  COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, 
nset,
  ^~
include/linux/compat.h:60:18: note: aliased declaration here
   asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
   ^~

The new warning seems reasonable in principle, but it doesn't
help us here, since we rely on the type mismatch to sanitize the
system call arguments. After I reported this as GCC PR82435, a new
-Wno-attribute-alias option was added that could be used to turn the
warning off globally on the command line, but I'd prefer to do it a
little more fine-grained.

Interestingly, turning a warning off and on again inside of
a single macro doesn't always work, in this case I had to add
an extra statement inbetween and decided to copy the __SC_TEST
one from the native syscall to the compat syscall macro.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83256 for more details
about this.

[paul.bur...@mips.com:
   - Rebase atop current master.
   - Split GCC & version arguments to __diag_ignore() in order to match
 changes to the preceding patch.
   - Add the comment argument to match the preceding patch.]

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82435
Signed-off-by: Arnd Bergmann 
Signed-off-by: Paul Burton 
Cc: Michal Marek 
Cc: Masahiro Yamada 
Cc: Douglas Anderson 
Cc: Al Viro 
Cc: Heiko Carstens 
Cc: Mauro Carvalho Chehab 
Cc: Matthew Wilcox 
Cc: Matthias Kaehlcke 
Cc: Arnd Bergmann 
Cc: Ingo Molnar 
Cc: Josh Poimboeuf 
Cc: Kees Cook 
Cc: Andrew Morton 
Cc: Thomas Gleixner 
Cc: Gideon Israel Dsouza 
Cc: Christophe Leroy 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Stafford Horne 
Cc: Khem Raj 
Cc: He Zhe 
Cc: linux-kbu...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linuxppc-dev@lists.ozlabs.org


Tested-by: Christophe Leroy 



---

  include/linux/compat.h   | 8 +++-
  include/linux/syscalls.h | 4 
  2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index b1a5562b3215..c68acc47da57 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -72,6 +72,9 @@
   */
  #ifndef COMPAT_SYSCALL_DEFINEx
  #define COMPAT_SYSCALL_DEFINEx(x, name, ...)  
\
+   __diag_push();  
\
+   __diag_ignore(GCC, 8, "-Wattribute-alias",\
+ "Type aliasing is used to sanitize syscall arguments");\
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));   
\
asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
\
__attribute__((alias(__stringify(__se_compat_sys##name; 
\
@@ -80,8 +83,11 @@
asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__));  
\
asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))   
\
{   
\
-   return 
__do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
+   long ret = 
__do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
+   __MAP(x,__SC_TEST,__VA_ARGS__); 
\
+   return ret; 
\
}   
\
+   __diag_pop();   
\
static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
  #endif /* COMPAT_SYSCALL_DEFINEx */
  
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h

index 73810808cdf2..a368a68cb667 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -231,6 +231,9 @@ static inline int is_syscall_trace_event(struct 
trace_event_call *tp_event)
   */
  #ifndef __SYSCALL_DEFINEx
  #define __SYSCALL_DEFINEx(x, name, ...)   
\
+   __diag_push();  \
+   __diag_

Re: [PATCH 3/3] Revert "powerpc: fix build failure by disabling attribute-alias warning in pci_32"

2018-06-18 Thread Christophe LEROY




Le 16/06/2018 à 02:53, Paul Burton a écrit :

With SYSCALL_DEFINEx() disabling -Wattribute-alias generically, there's
no need to duplicate that for PowerPC's pciconfig_iobase syscall.

This reverts commit 415520373975 ("powerpc: fix build failure by
disabling attribute-alias warning in pci_32").

Signed-off-by: Paul Burton 
Cc: Michal Marek 
Cc: Masahiro Yamada 
Cc: Douglas Anderson 
Cc: Al Viro 
Cc: Heiko Carstens 
Cc: Mauro Carvalho Chehab 
Cc: Matthew Wilcox 
Cc: Matthias Kaehlcke 
Cc: Arnd Bergmann 
Cc: Ingo Molnar 
Cc: Josh Poimboeuf 
Cc: Kees Cook 
Cc: Andrew Morton 
Cc: Thomas Gleixner 
Cc: Gideon Israel Dsouza 
Cc: Christophe Leroy 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Stafford Horne 
Cc: Khem Raj 
Cc: He Zhe 
Cc: linux-kbu...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Cc: linux-m...@linux-mips.org
Cc: linuxppc-dev@lists.ozlabs.org


Acked-by: Christophe Leroy 



---

  arch/powerpc/kernel/pci_32.c | 4 
  1 file changed, 4 deletions(-)

diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 4f861055a852..d63b488d34d7 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -285,9 +285,6 @@ pci_bus_to_hose(int bus)
   * Note that the returned IO or memory base is a physical address
   */
  
-#pragma GCC diagnostic push

-#pragma GCC diagnostic ignored "-Wpragmas"
-#pragma GCC diagnostic ignored "-Wattribute-alias"
  SYSCALL_DEFINE3(pciconfig_iobase, long, which,
unsigned long, bus, unsigned long, devfn)
  {
@@ -313,4 +310,3 @@ SYSCALL_DEFINE3(pciconfig_iobase, long, which,
  
  	return result;

  }
-#pragma GCC diagnostic pop



Re: [PATCH] powerpc/eeh: Avoid misleading message "EEH: no capable adapters found"

2018-06-18 Thread Venkat Rao B




On Friday 27 April 2018 06:04 AM, Russell Currey wrote:

On Thu, 2018-03-22 at 23:10 -0300, Mauro S. M. Rodrigues wrote:

Due to recent refactoring in EEH in:
commit b9fde58db7e5 ("powerpc/powernv: Rework EEH initialization on
powernv")
a misleading message was seen in the kernel message buffer:

[0.108431] EEH: PowerNV platform initialized
[0.589979] EEH: No capable adapters found

This happened due to the removal of the initialization delay for
powernv
platform.

Even though the EEH infrastructure for the devices is eventually
initialized and still works just fine the eeh device probe step is
postponed in order to assure the PEs are created. Later
pnv_eeh_post_init does the probe devices job but at that point the
message was already shown right after eeh_init flow.

This patch introduces a new flag EEH_POSTPONED_PROBE to represent
that
temporary state and avoid the message mentioned above and showing the
follow one instead:

[0.107724] EEH: PowerNV platform initialized
[4.844825] EEH: PCI Enhanced I/O Error Handling Enabled

Signed-off-by: Mauro S. M. Rodrigues 


Good idea, thanks for the patch.

Acked-by: Russell Currey 




Hi Mauro,

I got a chance to test your patch, I applied your patch on top of 
mainline kernel commit:8efcf34a263965e471e304f94d1f6799d42a and 
booted and I don't see the message "No capable adapters found" instead I 
see "EEH: PCI Enhanced I/O Error Handling Enabled" as desired. But I 
have not injected any EEH.Hope this should qualify your patch.


Tested-by:Venkat Rao B 

Regards,
Venkat.



Re: [PATCH kernel 2/2] powerpc/powernv: Define PHB4 type and enable sketchy bypass on POWER9

2018-06-18 Thread Alexey Kardashevskiy
On Mon, 18 Jun 2018 14:44:56 +1000
Benjamin Herrenschmidt  wrote:

> On Mon, 2018-06-18 at 12:13 +1000, Alexey Kardashevskiy wrote:
> > On Sat, 16 Jun 2018 11:05:19 +1000
> > Benjamin Herrenschmidt  wrote:
> >   
> > > On Fri, 2018-06-01 at 18:10 +1000, Alexey Kardashevskiy wrote:  
> > > > These are found in POWER9 chips. Right now these PHBs have unknown type
> > > > so changing it to PHB4 won't make much of a difference except enabling
> > > > sketchy bypass for POWER9 as this does below.
> > > 
> > > And that will break on multi-chip systems since P9 doesn't have the
> > > memory contiguous (it has the chip ID in the top bits).  
> > 
> > 
> > This did not break mine and it is hard to see why it would break at all
> > if we use 1G pages and the maximum we need to cover is 48 bits (this
> > is what we are trying to support here - all these gpus, right?), or is
> > it more now? If so, I have posted v2 of tce multilevel dynamic
> > allocation which helps with enormous tce tables.  
> 
> The whole point of sketchy bypass is to deal with devices with small
> amount of DMA bits... most Radeon's have 40 for example. So that won't
> work terribly well.


40 with 1GB pages needs 40-30=10 bits i.e. (1<<10)*8 = 8KB for the
entire TCE table. I am definitely missing something here, what is it?



> 
> Cheers,
> Ben.
> 
> > 
> >   
> > > 
> > > Russell is working on a different implementation that should be much
> > > more imune to the system physical memory layout.
> > >   
> > > > Signed-off-by: Alexey Kardashevskiy 
> > > > ---
> > > >  arch/powerpc/platforms/powernv/pci.h  | 1 +
> > > >  arch/powerpc/platforms/powernv/pci-ioda.c | 5 -
> > > >  2 files changed, 5 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/arch/powerpc/platforms/powernv/pci.h 
> > > > b/arch/powerpc/platforms/powernv/pci.h
> > > > index eada4b6..1408247 100644
> > > > --- a/arch/powerpc/platforms/powernv/pci.h
> > > > +++ b/arch/powerpc/platforms/powernv/pci.h
> > > > @@ -23,6 +23,7 @@ enum pnv_phb_model {
> > > > PNV_PHB_MODEL_UNKNOWN,
> > > > PNV_PHB_MODEL_P7IOC,
> > > > PNV_PHB_MODEL_PHB3,
> > > > +   PNV_PHB_MODEL_PHB4,
> > > > PNV_PHB_MODEL_NPU,
> > > > PNV_PHB_MODEL_NPU2,
> > > >  };
> > > > diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
> > > > b/arch/powerpc/platforms/powernv/pci-ioda.c
> > > > index 9239142..66c2804 100644
> > > > --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> > > > +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> > > > @@ -1882,7 +1882,8 @@ static int pnv_pci_ioda_dma_set_mask(struct 
> > > > pci_dev *pdev, u64 dma_mask)
> > > > if (dma_mask >> 32 &&
> > > > dma_mask > (memory_hotplug_max() + (1ULL << 32)) &&
> > > > pnv_pci_ioda_pe_single_vendor(pe) &&
> > > > -   phb->model == PNV_PHB_MODEL_PHB3) {
> > > > +   (phb->model == PNV_PHB_MODEL_PHB3 ||
> > > > +phb->model == PNV_PHB_MODEL_PHB4)) {
> > > > /* Configure the bypass mode */
> > > > rc = pnv_pci_ioda_dma_64bit_bypass(pe);
> > > > if (rc)
> > > > @@ -3930,6 +3931,8 @@ static void __init pnv_pci_init_ioda_phb(struct 
> > > > device_node *np,
> > > > phb->model = PNV_PHB_MODEL_P7IOC;
> > > > else if (of_device_is_compatible(np, "ibm,power8-pciex"))
> > > > phb->model = PNV_PHB_MODEL_PHB3;
> > > > +   else if (of_device_is_compatible(np, "ibm,power9-pciex"))
> > > > +   phb->model = PNV_PHB_MODEL_PHB4;
> > > > else if (of_device_is_compatible(np, "ibm,power8-npu-pciex"))
> > > > phb->model = PNV_PHB_MODEL_NPU;
> > > > else if (of_device_is_compatible(np, "ibm,power9-npu-pciex"))   
> > > >  
> > 
> > 
> > 
> > --
> > Alexey  



--
Alexey


Re: [PATCH v2] powerpc/cell: fix build failure by disabling attribute-alias warning

2018-06-18 Thread Christophe LEROY




Le 29/05/2018 à 18:06, Christophe Leroy a écrit :

Latest GCC version emit the following warnings

As arch/powerpc code is built with -Werror, this breaks build with
GCC 8.1

This patch inhibits those warnings

   CC  arch/powerpc/platforms/cell/spu_syscalls.o
In file included from arch/powerpc/platforms/cell/spu_syscalls.c:26:
./include/linux/syscalls.h:233:18: error: 'sys_spu_create' alias between 
functions of incompatible types 'long int(const char *, unsigned int,  umode_t, 
 int)' {aka 'long int(const char *, unsigned int,  short unsigned int,  int)'} 
and 'long int(long int,  long int,  long int,  long int)' 
[-Werror=attribute-alias]
   asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
   ^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:214:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/platforms/cell/spu_syscalls.c:70:1: note: in expansion of macro 
'SYSCALL_DEFINE4'
  SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags,
  ^~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
   asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
   ^~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:214:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/platforms/cell/spu_syscalls.c:70:1: note: in expansion of macro 
'SYSCALL_DEFINE4'
  SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags,
  ^~~
./include/linux/syscalls.h:233:18: error: 'sys_spu_run' alias between functions 
of incompatible types 'long int(int,  __u32 *, __u32 *)' {aka 'long int(int,  
unsigned int *, unsigned int *)'} and 'long int(long int,  long int,  long 
int)' [-Werror=attribute-alias]
   asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
   ^~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:213:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/platforms/cell/spu_syscalls.c:94:1: note: in expansion of macro 
'SYSCALL_DEFINE3'
  SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, 
ustatus)
  ^~~
./include/linux/syscalls.h:238:18: note: aliased declaration here
   asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
   ^~~~
./include/linux/syscalls.h:222:2: note: in expansion of macro 
'__SYSCALL_DEFINEx'
   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
   ^
./include/linux/syscalls.h:213:36: note: in expansion of macro 'SYSCALL_DEFINEx'
  #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
 ^~~
arch/powerpc/platforms/cell/spu_syscalls.c:94:1: note: in expansion of macro 
'SYSCALL_DEFINE3'
  SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, 
ustatus)
  ^~~

Signed-off-by: Christophe Leroy 


If the serie from Paul Burton 
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=50442 
goes in, this patch won't be necessary.


Christophe


---
v2: added '#pragma GCC diagnostic ignored "-Wpragmas"' to avoid build failure 
on old GCC

  arch/powerpc/platforms/cell/spu_syscalls.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c 
b/arch/powerpc/platforms/cell/spu_syscalls.c
index 263413a34823..7862279a82e4 100644
--- a/arch/powerpc/platforms/cell/spu_syscalls.c
+++ b/arch/powerpc/platforms/cell/spu_syscalls.c
@@ -67,6 +67,9 @@ static inline void spufs_calls_put(struct spufs_calls *calls) 
{ }
  
  #endif /* CONFIG_SPU_FS_MODULE */
  
+#pragma GCC diagnostic push

+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wattribute-alias"
  SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags,
umode_t, mode, int, neighbor_fd)
  {
@@ -111,6 +114,7 @@ SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, 
__u32 __user *, ustatus)
spufs_calls_put(calls);
return ret;
  }
+#pragma GCC diagnostic pop
  
  #ifdef CONFIG_COREDUMP

  int elf_coredump_extra_notes_size(void)



Constant ata messages on console with commit 28361c403683 ("libata: add extra internal command") (was Re: [GIT PULL 2/2] libata changes for v4.18-rc1)

2018-06-18 Thread Michael Ellerman
Tejun Heo  writes:
...
> Jens Axboe (10):
>   libata: introduce notion of separate hardware tags
>   libata: convert core and drivers to ->hw_tag usage
>   libata: bump ->qc_active to a 64-bit type
>   libata: use ata_tag_internal() consistently
>   libata: remove assumption that ATA_MAX_QUEUE - 1 is the max
>   sata_nv: set host can_queue count appropriately
>   libata: add extra internal command

Replying here because I can't find the original mail.

The above commit is causing one of my machines to constantly spew ata
messages on the console, according to bisect:

# first bad commit: [28361c403683c2b00d4f5e76045f3ccd299bf99d] libata: add 
extra internal command

To get it to boot I have to also apply:

  88e10092f6a6 ("sata_fsl: use the right type for tag bitshift")


The system boots OK and seems fine, except that it's just printing
multiple of these per second:

  ata2: Signature Update detected @ 0 msecs
  ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
  ata2.00: configured for UDMA/100
  ata2: Signature Update detected @ 0 msecs
  ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
  ata2.00: configured for UDMA/100
  ata2: Signature Update detected @ 0 msecs
  ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
  ata2.00: configured for UDMA/100
  ata2: Signature Update detected @ 0 msecs
  ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
  ata2.00: configured for UDMA/100
  ata2: Signature Update detected @ 0 msecs

And it never seems to stop.

The machine is a Freescale/NXP P5020ds, using the sata_fsl driver
presumably. Any ideas?

cheers


Re: Build regressions/improvements in v4.18-rc1

2018-06-18 Thread Geert Uytterhoeven
On Mon, Jun 18, 2018 at 11:18 AM Geert Uytterhoeven
 wrote:
> Below is the list of build error/warning regressions/improvements in
> v4.18-rc1[1] compared to v4.17[2].
>
> Summarized:
>   - build errors: +11/-1

> [1] 
> http://kisskb.ellerman.id.au/kisskb/head/ce397d215ccd07b8ae3f71db689aedb85d56ab40/
>  (233 out of 244 configs)
> [2] 
> http://kisskb.ellerman.id.au/kisskb/head/29dcea88779c856c7dc92040a0c01233263101d4/
>  (all 244 configs)

> 11 error regressions:
>   + /kisskb/src/drivers/ata/pata_ali.c: error: implicit declaration of 
> function 'pci_domain_nr' [-Werror=implicit-function-declaration]:  => 469:38

sparc64/sparc-allmodconfig

>   + /kisskb/src/mm/memblock.c: error: redefinition of 
> 'memblock_virt_alloc_try_nid':  => 1413:15
>   + /kisskb/src/mm/memblock.c: error: redefinition of 
> 'memblock_virt_alloc_try_nid_nopanic':  => 1377:15
>   + /kisskb/src/mm/memblock.c: error: redefinition of 
> 'memblock_virt_alloc_try_nid_raw':  => 1340:15

ia64/ia64-defconfig
mips/bigsur_defconfig
mips/cavium_octeon_defconfig
mips/ip22_defconfig
mips/ip27_defconfig
mips/ip32_defconfig
mips/malta_defconfig
mips/mips-allmodconfig
mips/mips-allnoconfig
mips/mips-defconfig
mipsel/mips-allmodconfig
mipsel/mips-allnoconfig
mipsel/mips-defconfig

>   + error: ".radix__flush_pwc_lpid" [arch/powerpc/kvm/kvm-hv.ko] undefined!:  
> => N/A
>   + error: ".radix__flush_tlb_lpid_page" [arch/powerpc/kvm/kvm-hv.ko] 
> undefined!:  => N/A
>   + error: ".radix__local_flush_tlb_lpid_guest" [arch/powerpc/kvm/kvm-hv.ko] 
> undefined!:  => N/A
>   + error: "radix__flush_pwc_lpid" [arch/powerpc/kvm/kvm-hv.ko] undefined!:  
> => N/A
>   + error: "radix__flush_tlb_lpid_page" [arch/powerpc/kvm/kvm-hv.ko] 
> undefined!:  => N/A
>   + error: "radix__local_flush_tlb_lpid_guest" [arch/powerpc/kvm/kvm-hv.ko] 
> undefined!:  => N/A

powerpc/ppc64_defconfig+NO_RADIX
ppc64le/powernv_defconfig+NO_RADIX (what's in a name ;-)

>   + {standard input}: Error: offset to unaligned destination:  => 2268, 2316, 
> 1691, 1362, 1455, 1598, 2502, 1645, 1988, 1927, 1409, 2615, 1548, 2409, 1268, 
> 2363, 1314, 1208, 1785, 2034, , 2661, 1880, 2552, 1161, 2082, 1833, 2455, 
> 2176, 2129, 1501, 1738

sh4/sh-randconfig (doesn't seem to be a new issue, seen before on v4.12-rc3)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH] powerpc: xmon: use ktime_get_coarse_boottime64

2018-06-18 Thread Arnd Bergmann
get_monotonic_boottime() is deprecated, and may not be safe to call in
every context, as it has to read a hardware clocksource.

This changes xmon to print the time using ktime_get_coarse_boottime64()
instead, which avoids the old timespec type and the HW access.

Signed-off-by: Arnd Bergmann 
---
 arch/powerpc/xmon/xmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 47166ad2a669..45e3d0ec1246 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -918,13 +918,13 @@ static void remove_cpu_bpts(void)
 static void
 show_uptime(void)
 {
-   struct timespec uptime;
+   struct timespec64 uptime;
 
if (setjmp(bus_error_jmp) == 0) {
catch_memory_errors = 1;
sync();
 
-   get_monotonic_boottime(&uptime);
+   ktime_get_coarse_boottime_ts64(&uptime);
printf("Uptime: %lu.%.2lu seconds\n", (unsigned 
long)uptime.tv_sec,
((unsigned long)uptime.tv_nsec / (NSEC_PER_SEC/100)));
 
-- 
2.9.0



[PATCH] ocxl: Fix page fault handler in case of fault on dying process

2018-06-18 Thread Frederic Barrat
If a process exits without doing proper cleanup, there's a window
where an opencapi device can try to access the memory of the dying
process and may trigger a page fault. That's an expected scenario and
the ocxl driver holds a reference on the mm_struct of the process
until the opencapi device is notified of the process exiting.
However, if mm_users is already at 0, i.e. the address space of the
process has already been destroyed, the driver shouldn't try resolving
the page fault, as it will fail, but it can also try accessing already
freed data.

It is fixed by only calling the bottom half of the page fault handler
if mm_users is greater than 0 and get a reference on mm_users instead
of mm_count. Otherwise, we can safely return a translation fault to
the device, as its associated memory context is being removed. The
opencapi device will be properly cleaned up shortly after when closing
the file descriptors.

Fixes: 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")
Cc: sta...@vger.kernel.org # v4.16+
Signed-off-by: Frederic Barrat 
---
 drivers/misc/ocxl/link.c | 24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
index f30790582dc0..2aeaf34e7eda 100644
--- a/drivers/misc/ocxl/link.c
+++ b/drivers/misc/ocxl/link.c
@@ -136,7 +136,7 @@ static void xsl_fault_handler_bh(struct work_struct 
*fault_work)
int rc;
 
/*
-* We need to release a reference on the mm whenever exiting this
+* We must release a reference on mm_users whenever exiting this
 * function (taken in the memory fault interrupt handler)
 */
rc = copro_handle_mm_fault(fault->pe_data.mm, fault->dar, fault->dsisr,
@@ -172,7 +172,7 @@ static void xsl_fault_handler_bh(struct work_struct 
*fault_work)
}
r = RESTART;
 ack:
-   mmdrop(fault->pe_data.mm);
+   mmput(fault->pe_data.mm);
ack_irq(spa, r);
 }
 
@@ -184,6 +184,7 @@ static irqreturn_t xsl_fault_handler(int irq, void *data)
struct pe_data *pe_data;
struct ocxl_process_element *pe;
int lpid, pid, tid;
+   bool schedule = false;
 
read_irq(spa, &dsisr, &dar, &pe_handle);
trace_ocxl_fault(spa->spa_mem, pe_handle, dsisr, dar, -1);
@@ -226,14 +227,19 @@ static irqreturn_t xsl_fault_handler(int irq, void *data)
}
WARN_ON(pe_data->mm->context.id != pid);
 
-   spa->xsl_fault.pe = pe_handle;
-   spa->xsl_fault.dar = dar;
-   spa->xsl_fault.dsisr = dsisr;
-   spa->xsl_fault.pe_data = *pe_data;
-   mmgrab(pe_data->mm); /* mm count is released by bottom half */
-
+   if (mmget_not_zero(pe_data->mm)) {
+   spa->xsl_fault.pe = pe_handle;
+   spa->xsl_fault.dar = dar;
+   spa->xsl_fault.dsisr = dsisr;
+   spa->xsl_fault.pe_data = *pe_data;
+   schedule = true;
+   /* mm_users count released by bottom half */
+   }
rcu_read_unlock();
-   schedule_work(&spa->xsl_fault.fault_work);
+   if (schedule)
+   schedule_work(&spa->xsl_fault.fault_work);
+   else
+   ack_irq(spa, ADDRESS_ERROR);
return IRQ_HANDLED;
 }
 
-- 
2.17.1



[PATCH] powerpc/fsl: Sanitize the syscall table for NXP PowerPC 32 bit platforms

2018-06-18 Thread Diana Craciun
Used barrier_nospec to sanitize the syscall table.

Signed-off-by: Diana Craciun 
---
 arch/powerpc/kernel/entry_32.S | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index eb8d01b..e3ff9ace 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * MSR_KERNEL is > 0x1 on 4xx/Book-E since it include MSR_CE.
@@ -358,6 +359,15 @@ syscall_dotrace_cont:
ori r10,r10,sys_call_table@l
slwir0,r0,2
bge-66f
+
+   barrier_nospec_asm
+   /*
+* Prevent the load of the handler below (based on the user-passed
+* system call number) being speculatively executed until the test
+* against NR_syscalls and branch to .66f above has
+* committed.
+*/
+
lwzxr10,r10,r0  /* Fetch system call handler [ptr] */
mtlrr10
addir9,r1,STACK_FRAME_OVERHEAD
-- 
2.5.5



Re: [PATCH 0/3] Resolve -Wattribute-alias warnings from SYSCALL_DEFINEx()

2018-06-18 Thread Arnd Bergmann
On Sat, Jun 16, 2018 at 2:53 AM, Paul Burton  wrote:
> This series introduces infrastructure allowing compiler diagnostics to
> be disabled or their severity modified for specific pieces of code, with
> suitable abstractions to prevent that code from becoming tied to a
> specific compiler.
>
> This infrastructure is then used to disable the -Wattribute-alias
> warning around syscall definitions, which rely on type mismatches to
> sanitize arguments.
>
> Finally PowerPC-specific #pragma's are removed now that the generic code
> is handling this.
>
> The series takes Arnd's RFC patches & addresses the review comments they
> received. The most notable effect of this series to to avoid warnings &
> build failures caused by -Wattribute-alias when compiling the kernel
> with GCC 8.
>
> Applies cleanly atop master as of 9215310cf13b ("Merge
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net").
>

Sorry I dropped the ball on this earlier, and thanks a lot for picking
it up again! From what I can tell, your version addresses all issues
I was aware of, so we should merge that.

  Arnd


Re: powerpc: use time64_t in read_persistent_clock

2018-06-18 Thread Arnd Bergmann
On Thu, Jun 14, 2018 at 9:03 PM, Mathieu Malaterre  wrote:
> On Thu, Jun 14, 2018 at 1:46 PM Arnd Bergmann  wrote:
>> On Wed, Jun 13, 2018 at 10:24 PM, Mathieu Malaterre  wrote:
>
>> Can you confirm that this patch addresses your problem?
>
> Yes !
>
> Before:
> [5.986710] rtc-generic rtc-generic: hctosys: unable to read the
> hardware clock
>
> After:
> [5.579611] rtc-generic rtc-generic: setting system clock to
> 2018-06-14 18:57:00 UTC (1529002620)
>
> So for the above:
>
> Tested-by: Mathieu Malaterre 

Thanks a lot!

>> --- a/arch/powerpc/platforms/powermac/time.c
>> +++ b/arch/powerpc/platforms/powermac/time.c
>> @@ -88,7 +88,7 @@ long __init pmac_time_init(void)
>>  static time64_t cuda_get_time(void)
>>  {
>> struct adb_request req;
>> -   time64_t now;
>> +   u32 now;
>>
>> if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0)
>> return 0;
>> @@ -132,7 +132,7 @@ static int cuda_set_rtc_time(struct rtc_time *tm)
>>  static time64_t pmu_get_time(void)
>>  {
>> struct adb_request req;
>> -   time64_t now;
>> +   u32 now;
>>
>> if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0)
>> return 0;
>>
>> On the upside, this would possibly extend the life of some machines
>> by another 66 years, on the downside it might cause issues when
>> an empty RTC battery causes the initial system time to be
>> above the 32-bit TIME_T_MAX (instead of going back to 1904).
>
> I would submit the first patch and add the above as comment. I doubt
> anyone would still have a running system by then.

I was about to send a similar patch to the first one for m68k macs, which have
basically the same code. My patch had the same bug, so I'm glad I had
not sent it yet, but I also noticed that I made the opposite decision on m68k
as that code had already been using 'unsigned long' in the conversion (but
then of course would wrap it during the conversion to 'time_t). I've picked
the same approach for both now, using the 1904..2040 range.

   Arnd


[PATCH 2/3] m68k: mac: use time64_t in RTC handling

2018-06-18 Thread Arnd Bergmann
The real-time clock on m68k (and powerpc) mac systems uses an unsigned
32-bit value starting in 1904, which overflows in 2040, about two years
later than everyone else, but this gets wrapped around in the Linux
code in 2038 already because of the deprecated usage of time_t and/or
long in the conversion.

Getting rid of the deprecated interfaces makes it work until 2040 as
documented, and it could be easily extended by reinterpreting
the resulting time64_t as a positive number. For the moment, I'm
adding a WARN_ON() that triggers if we encounter a time before 1970
or after 2040 (the two are indistinguishable).

This brings it in line with the corresponding code that we have on
powerpc macintosh.

Signed-off-by: Arnd Bergmann 
---
 arch/m68k/mac/misc.c | 58 +---
 1 file changed, 37 insertions(+), 21 deletions(-)

diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c
index c68054361615..b399a0809e18 100644
--- a/arch/m68k/mac/misc.c
+++ b/arch/m68k/mac/misc.c
@@ -26,33 +26,40 @@
 
 #include 
 
-/* Offset between Unix time (1970-based) and Mac time (1904-based) */
+/* Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and 
PMU
+ * times wrap in 2040. If we need to handle later times, the read_time 
functions
+ * need to be changed to interpret wrapped times as post-2040. */
 
 #define RTC_OFFSET 2082844800
 
 static void (*rom_reset)(void);
 
 #ifdef CONFIG_ADB_CUDA
-static long cuda_read_time(void)
+static time64_t cuda_read_time(void)
 {
struct adb_request req;
-   long time;
+   time64_t time;
 
if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0)
return 0;
while (!req.complete)
cuda_poll();
 
-   time = (req.reply[3] << 24) | (req.reply[4] << 16) |
-  (req.reply[5] << 8) | req.reply[6];
+   time = (u32)((req.reply[3] << 24( | (req.reply[4] << 16) |
+(req.reply[5] << 8) | req.reply[6]);
+
+   /* it's either after year 2040, or the RTC has gone backwards */
+   WARN_ON(time < RTC_OFFSET);
+
return time - RTC_OFFSET;
 }
 
-static void cuda_write_time(long data)
+static void cuda_write_time(time64_t data)
 {
struct adb_request req;
 
data += RTC_OFFSET;
+   data &= 0x;
if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
 (data >> 24) & 0xFF, (data >> 16) & 0xFF,
 (data >> 8) & 0xFF, data & 0xFF) < 0)
@@ -86,26 +93,29 @@ static void cuda_write_pram(int offset, __u8 data)
 #endif /* CONFIG_ADB_CUDA */
 
 #ifdef CONFIG_ADB_PMU68K
-static long pmu_read_time(void)
+static time64_t pmu_read_time(void)
 {
struct adb_request req;
-   long time;
+   time64_t time;
 
if (pmu_request(&req, NULL, 1, PMU_READ_RTC) < 0)
return 0;
while (!req.complete)
pmu_poll();
 
-   time = (req.reply[1] << 24) | (req.reply[2] << 16) |
-  (req.reply[3] << 8) | req.reply[4];
+   /* it's either after year 2040, or the RTC has gone backwards */
+   time = (u32)((req.reply[1] << 24) | (req.reply[2] << 16) |
+(req.reply[3] << 8) | req.reply[4]);
+
return time - RTC_OFFSET;
 }
 
-static void pmu_write_time(long data)
+static void pmu_write_time(time64_t data)
 {
struct adb_request req;
 
data += RTC_OFFSET;
+   data &= 0x;
if (pmu_request(&req, NULL, 5, PMU_SET_RTC,
(data >> 24) & 0xFF, (data >> 16) & 0xFF,
(data >> 8) & 0xFF, data & 0xFF) < 0)
@@ -269,8 +279,12 @@ static long via_read_time(void)
via_pram_command(0x89, &result.cdata[1]);
via_pram_command(0x8D, &result.cdata[0]);
 
-   if (result.idata == last_result.idata)
+   if (result.idata == last_result.idata) {
+   if (result.idata < RTC_OFFSET)
+   result.idata += 0x1ull;
+
return result.idata - RTC_OFFSET;
+   }
 
if (++count > 10)
break;
@@ -291,11 +305,11 @@ static long via_read_time(void)
  * is basically any machine with Mac II-style ADB.
  */
 
-static void via_write_time(long time)
+static void via_write_time(time64_t time)
 {
union {
__u8 cdata[4];
-   long idata;
+   __u32 idata;
} data;
__u8 temp;
 
@@ -585,12 +599,15 @@ void mac_reset(void)
  * This function translates seconds since 1970 into a proper date.
  *
  * Algorithm cribbed from glibc2.1, __offtime().
+ *
+ * This is roughly same as rtc_time64_to_tm(), which we should probably
+ * use here, but it's only available when CONFIG_RTC_LIB is enabled.
  */
 #define SECS_PER_MINUTE (60)
 #define SECS_PER_HOUR  (SECS_PER_MINUTE * 60)
 #define SECS_PER_DAY   (SECS_PER_HOUR * 24)
 
-static void u

[PATCH 3/3] m68k: remove unused set_clock_mmss() helpers

2018-06-18 Thread Arnd Bergmann
Commit 397ac99c6cef ("m68k: remove dead timer code") removed set_rtc_mmss()
because it was unused in 2012. However, this was itself the only user of the
mach_set_clock_mmss() callback and the many implementations of that callback,
which are equally unused.

This removes all of those as well.

Signed-off-by: Arnd Bergmann 
---
 arch/m68k/apollo/config.c   |  8 --
 arch/m68k/atari/config.c|  5 
 arch/m68k/atari/time.c  | 63 -
 arch/m68k/bvme6000/config.c | 45 -
 arch/m68k/include/asm/machdep.h |  1 -
 arch/m68k/kernel/setup_mm.c |  1 -
 arch/m68k/kernel/setup_no.c |  1 -
 arch/m68k/mac/config.c  |  2 --
 arch/m68k/mac/misc.c| 16 ---
 arch/m68k/mvme147/config.c  |  7 -
 arch/m68k/mvme16x/config.c  |  8 --
 arch/m68k/q40/config.c  | 30 
 12 files changed, 187 deletions(-)

diff --git a/arch/m68k/apollo/config.c b/arch/m68k/apollo/config.c
index b2a6bc63f8cd..aef8d42e078d 100644
--- a/arch/m68k/apollo/config.c
+++ b/arch/m68k/apollo/config.c
@@ -31,7 +31,6 @@ extern void dn_sched_init(irq_handler_t handler);
 extern void dn_init_IRQ(void);
 extern u32 dn_gettimeoffset(void);
 extern int dn_dummy_hwclk(int, struct rtc_time *);
-extern int dn_dummy_set_clock_mmss(unsigned long);
 extern void dn_dummy_reset(void);
 #ifdef CONFIG_HEARTBEAT
 static void dn_heartbeat(int on);
@@ -156,7 +155,6 @@ void __init config_apollo(void)
arch_gettimeoffset   = dn_gettimeoffset;
mach_max_dma_address = 0x;
mach_hwclk   = dn_dummy_hwclk; /* */
-   mach_set_clock_mmss  = dn_dummy_set_clock_mmss; /* */
mach_reset   = dn_dummy_reset;  /* */
 #ifdef CONFIG_HEARTBEAT
mach_heartbeat = dn_heartbeat;
@@ -240,12 +238,6 @@ int dn_dummy_hwclk(int op, struct rtc_time *t) {
 
 }
 
-int dn_dummy_set_clock_mmss(unsigned long nowtime)
-{
-   pr_info("set_clock_mmss\n");
-   return 0;
-}
-
 void dn_dummy_reset(void) {
 
   dn_serial_print("The end !\n");
diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index 565c6f06ab0b..bd96702a1ad0 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -81,9 +81,6 @@ extern void atari_sched_init(irq_handler_t);
 extern u32 atari_gettimeoffset(void);
 extern int atari_mste_hwclk (int, struct rtc_time *);
 extern int atari_tt_hwclk (int, struct rtc_time *);
-extern int atari_mste_set_clock_mmss (unsigned long);
-extern int atari_tt_set_clock_mmss (unsigned long);
-
 
 /* ++roman: This is a more elaborate test for an SCC chip, since the plain
  * Medusa board generates DTACK at the SCC's standard addresses, but a SCC
@@ -362,13 +359,11 @@ void __init config_atari(void)
ATARIHW_SET(TT_CLK);
pr_cont(" TT_CLK");
mach_hwclk = atari_tt_hwclk;
-   mach_set_clock_mmss = atari_tt_set_clock_mmss;
}
if (hwreg_present(&mste_rtc.sec_ones)) {
ATARIHW_SET(MSTE_CLK);
pr_cont(" MSTE_CLK");
mach_hwclk = atari_mste_hwclk;
-   mach_set_clock_mmss = atari_mste_set_clock_mmss;
}
if (!MACH_IS_MEDUSA && hwreg_present(&dma_wd.fdc_speed) &&
hwreg_write(&dma_wd.fdc_speed, 0)) {
diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c
index c549b48174ec..9cca64286464 100644
--- a/arch/m68k/atari/time.c
+++ b/arch/m68k/atari/time.c
@@ -285,69 +285,6 @@ int atari_tt_hwclk( int op, struct rtc_time *t )
 return( 0 );
 }
 
-
-int atari_mste_set_clock_mmss (unsigned long nowtime)
-{
-short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
-struct MSTE_RTC val;
-unsigned char rtc_minutes;
-
-mste_read(&val);
-rtc_minutes= val.min_ones + val.min_tens * 10;
-if ((rtc_minutes < real_minutes
- ? real_minutes - rtc_minutes
- : rtc_minutes - real_minutes) < 30)
-{
-val.sec_ones = real_seconds % 10;
-val.sec_tens = real_seconds / 10;
-val.min_ones = real_minutes % 10;
-val.min_tens = real_minutes / 10;
-mste_write(&val);
-}
-else
-return -1;
-return 0;
-}
-
-int atari_tt_set_clock_mmss (unsigned long nowtime)
-{
-int retval = 0;
-short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
-unsigned char save_control, save_freq_select, rtc_minutes;
-
-save_control = RTC_READ (RTC_CONTROL); /* tell the clock it's being set */
-RTC_WRITE (RTC_CONTROL, save_control | RTC_SET);
-
-save_freq_select = RTC_READ (RTC_FREQ_SELECT); /* stop and reset prescaler 
*/
-RTC_WRITE (RTC_FREQ_SELECT, save_freq_select | RTC_DIV_RESET2);
-
-rtc_minutes = RTC_READ (RTC_MINUTES);
-if (!(save_control & RTC_DM_BINARY))
-   rtc_minutes = bcd2bin(rtc_minutes);
-
-/* Since we're only adjusting minutes and seconds, don't interfere
-   with hour overflow.  

[PATCH 1/3] powerpc: mac: fix rtc read functions

2018-06-18 Thread Arnd Bergmann
As Mathieu pointed out, my conversion to time64_t was incorrect and resulted
in negative times to be read from the RTC. The problem is that during the
conversion from a byte array to a time64_t, the 'unsigned char' variable
holding the top byte gets turned into a negative signed 32-bit integer
before being assigned to the 64-bit variable for any times after 1972.

This changes the logic to cast to an unsigned 32-bit number first for
the Macintosh time and then convert that to the Unix time, which then gives
us a time in the documented 1904..2040 year range. I decided not to use
the longer 1970..2106 range that other drivers use, for consistency with
the literal interpretation of the register, but that could be easily
changed if we decide we want to support any Mac after 2040.

Just to be on the safe side, I'm also adding a WARN_ON that will trigger
if either the year 2040 has come and is observed by this driver, or we
run into an RTC that got set back to a pre-1970 date for some reason
(the two are indistinguishable).

The same code exists in arch/m68k/ and is patched in an identical way now
in a separate patch.

Fixes: 5bfd643583b2 ("powerpc: use time64_t in read_persistent_clock")
Reported-by: Mathieu Malaterre 
Signed-off-by: Arnd Bergmann 
---
 arch/powerpc/platforms/powermac/time.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/time.c 
b/arch/powerpc/platforms/powermac/time.c
index 7c968e46736f..173a80630169 100644
--- a/arch/powerpc/platforms/powermac/time.c
+++ b/arch/powerpc/platforms/powermac/time.c
@@ -42,7 +42,11 @@
 #define DBG(x...)
 #endif
 
-/* Apparently the RTC stores seconds since 1 Jan 1904 */
+/*
+ * Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and 
PMU
+ * times wrap in 2040. If we need to handle later times, the read_time 
functions
+ * need to be changed to interpret wrapped times as post-2040.
+ */
 #define RTC_OFFSET 2082844800
 
 /*
@@ -97,8 +101,11 @@ static time64_t cuda_get_time(void)
if (req.reply_len != 7)
printk(KERN_ERR "cuda_get_time: got %d byte reply\n",
   req.reply_len);
-   now = (req.reply[3] << 24) + (req.reply[4] << 16)
-   + (req.reply[5] << 8) + req.reply[6];
+   now = (u32)((req.reply[3] << 24) + (req.reply[4] << 16) +
+   (req.reply[5] << 8) + req.reply[6]);
+   /* it's either after year 2040, or the RTC has gone backwards */
+   WARN_ON(now < RTC_OFFSET);
+
return now - RTC_OFFSET;
 }
 
@@ -140,8 +147,12 @@ static time64_t pmu_get_time(void)
if (req.reply_len != 4)
printk(KERN_ERR "pmu_get_time: got %d byte reply from PMU\n",
   req.reply_len);
-   now = (req.reply[0] << 24) + (req.reply[1] << 16)
-   + (req.reply[2] << 8) + req.reply[3];
+   now = (u32)((req.reply[0] << 24) + (req.reply[1] << 16) +
+   (req.reply[2] << 8) + req.reply[3]);
+
+   /* it's either after year 2040, or the RTC has gone backwards */
+   WARN_ON(now < RTC_OFFSET);
+
return now - RTC_OFFSET;
 }
 
-- 
2.9.0



[PATCH] powerpc/numa: Handle unitialized timer reset

2018-06-18 Thread Michael Bringmann
Some of the code in 'numa.c' may be reused when updating kernel
state after an LPAR migration event.  One such common function
is 'reset_topology_timer' which was being invoked by the
'.notifier_call' function within the NUMA module by
'of_property_notify'.  If this occurs after a previous call to
'stop_topology_update' or on a system without VPHN enabled, the
code runs into an unitialized timer structure and crashes.  This
patch adds a safety check along this path toward the problem code.

Note: This crash was observed on every LPM in the 4.17-rc7 kernel
of a system with dedicated CPUs enabled.  An example crash log
without the patch is as follows.

  [ 2571.437467] ibmvscsi 3081: Re-enabling adapter!
[ 2571.673850] [ cut here ]
[ 2571.673863] kernel BUG at kernel/time/timer.c:958!
[ 2571.673875] Oops: Exception in kernel mode, sig: 5 [#1]
[ 2571.673877] LE SMP NR_CPUS=2048 NUMA pSeries
[ 2571.673886] Modules linked in: nfsv3 nfs_acl nfs tcp_diag udp_diag inet_diag 
lockd unix_diag af_packet_diag netlink_diag grace fscache sunrpc xts vmx_crypto 
pseries_rng sg binfmt_misc ip_tables xfs libcrc32c sd_mod ibmvscsi ibmveth 
scsi_transport_srp dm_mirror dm_region_hash dm_log dm_mod
[ 2571.673969] CPU: 11 PID: 3067 Comm: drmgr Not tainted 4.17.0+ #179
[ 2571.673972] NIP:  c0198a2c LR: c0075990 CTR: 
[ 2571.673975] REGS: c003f9407560 TRAP: 0700   Not tainted  (4.17.0+)
[ 2571.673977] MSR:  80010282b033   
CR: 44482824  XER: 
[ 2571.673990] CFAR: c007598c SOFTE: 0 
[ 2571.673990] GPR00: c0075990 c003f94077e0 c113a900 
c12e5968 
[ 2571.673990] GPR04: 00010003776b c003ffa05180 0020 
c003f9407850 
[ 2571.673990] GPR08:  0001  
0220 
[ 2571.673990] GPR12: c0076560 c0001ec90200 4000 
0018 
[ 2571.673990] GPR16:  000d c003e9ea5015 
0010 
[ 2571.673990] GPR20: 000b 0050 c003e9ea4068 
0001 
[ 2571.673990] GPR24: 001c c0033ab0  
c003f9407990 
[ 2571.673990] GPR28: 0005 c0033ab0 00010003776b 
c12e5968 
[ 2571.674042] NIP [c0198a2c] mod_timer+0x4c/0x400
[ 2571.674051] LR [c0075990] reset_topology_timer+0x40/0x60
[ 2571.674053] Call Trace:
[ 2571.674056] [c003f94077e0] [c003f9407830] 0xc003f9407830 
(unreliable)
[ 2571.674060] [c003f9407860] [c0075990] 
reset_topology_timer+0x40/0x60
[ 2571.674063] [c003f9407880] [c0076660] 
dt_update_callback+0x100/0x120
[ 2571.674072] [c003f94078d0] [c012ada0] 
notifier_call_chain+0x90/0x100
[ 2571.674077] [c003f9407920] [c012b270] 
__blocking_notifier_call_chain+0x60/0x90
[ 2571.674092] [c003f9407970] [c07b9a60] 
of_property_notify+0x90/0xd0
[ 2571.674096] [c003f94079d0] [c07b4644] 
of_update_property+0x104/0x150
[ 2571.674103] [c003f9407a30] [c00c0ddc] 
update_dt_property+0xdc/0x1f0
[ 2571.674106] [c003f9407a90] [c00c11c0] 
pseries_devicetree_update+0x2d0/0x510
[ 2571.674110] [c003f9407bc0] [c00c147c] 
post_mobility_fixup+0x7c/0xf0
[ 2571.674113] [c003f9407c30] [c00c1594] migration_store+0xa4/0xc0
[ 2571.674123] [c003f9407c70] [c0989940] kobj_attr_store+0x30/0x60
[ 2571.674133] [c003f9407c90] [c040b294] sysfs_kf_write+0x64/0xa0
[ 2571.674136] [c003f9407cb0] [c040a02c] 
kernfs_fop_write+0x16c/0x240
[ 2571.674146] [c003f9407d00] [c034eeb0] __vfs_write+0x40/0x200
[ 2571.674149] [c003f9407d90] [c034f288] vfs_write+0xc8/0x240
[ 2571.674152] [c003f9407de0] [c034f5bc] ksys_write+0x5c/0x100
[ 2571.674158] [c003f9407e30] [c000b284] system_call+0x58/0x6c
[ 2571.674161] Instruction dump:
[ 2571.674163] fb01ffc0 7c7f1b78 fb21ffc8 fb41ffd0 fb61ffd8 fb81ffe0 fba1ffe8 
f8010010 
[ 2571.674168] f821ff81 e9230018 7d290074 7929d182 <0b09> e9230008 2fa9 
419e0278 
[ 2571.674176] ---[ end trace 0c7939657d5522df ]---

Signed-off-by: Michael Bringmann 
---
 arch/powerpc/mm/numa.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 57a5029..8802e7d 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1457,7 +1457,8 @@ static void topology_timer_fn(struct timer_list *unused)
 
 static void reset_topology_timer(void)
 {
-   mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ);
+   if (vphn_enabled)
+   mod_timer(&topology_timer, jiffies + topology_timer_secs * HZ);
 }
 
 #ifdef CONFIG_SMP



Re: Constant ata messages on console with commit 28361c403683 ("libata: add extra internal command") (was Re: [GIT PULL 2/2] libata changes for v4.18-rc1)

2018-06-18 Thread Jens Axboe
On 6/18/18 1:33 AM, Michael Ellerman wrote:
> Tejun Heo  writes:
> ...
>> Jens Axboe (10):
>>   libata: introduce notion of separate hardware tags
>>   libata: convert core and drivers to ->hw_tag usage
>>   libata: bump ->qc_active to a 64-bit type
>>   libata: use ata_tag_internal() consistently
>>   libata: remove assumption that ATA_MAX_QUEUE - 1 is the max
>>   sata_nv: set host can_queue count appropriately
>>   libata: add extra internal command
> 
> Replying here because I can't find the original mail.
> 
> The above commit is causing one of my machines to constantly spew ata
> messages on the console, according to bisect:
> 
> # first bad commit: [28361c403683c2b00d4f5e76045f3ccd299bf99d] libata: add 
> extra internal command
> 
> To get it to boot I have to also apply:
> 
>   88e10092f6a6 ("sata_fsl: use the right type for tag bitshift")
> 
> 
> The system boots OK and seems fine, except that it's just printing
> multiple of these per second:
> 
>   ata2: Signature Update detected @ 0 msecs
>   ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>   ata2.00: configured for UDMA/100
>   ata2: Signature Update detected @ 0 msecs
>   ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>   ata2.00: configured for UDMA/100
>   ata2: Signature Update detected @ 0 msecs
>   ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>   ata2.00: configured for UDMA/100
>   ata2: Signature Update detected @ 0 msecs
>   ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
>   ata2.00: configured for UDMA/100
>   ata2: Signature Update detected @ 0 msecs
> 
> And it never seems to stop.
> 
> The machine is a Freescale/NXP P5020ds, using the sata_fsl driver
> presumably. Any ideas?

Hmm that's odd. Can you include the boot log from a working boot as
well? Would be nice to see what devices are on the sata adapter.
The above just looks like a hardreset loop.

-- 
Jens Axboe



Re: [PATCH 2/3] m68k: mac: use time64_t in RTC handling

2018-06-18 Thread kbuild test robot
Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.18-rc1 next-20180618]
[cannot apply to m68k/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Arnd-Bergmann/powerpc-mac-fix-rtc-read-functions/20180618-222412
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: m68k-multi_defconfig (attached as .config)
compiler: m68k-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   arch/m68k/mac/misc.c: In function 'cuda_read_time':
>> arch/m68k/mac/misc.c:48:36: error: expected expression before '|' token
 time = (u32)((req.reply[3] << 24( | (req.reply[4] << 16) |
   ^
>> arch/m68k/mac/misc.c:48:32: error: called object is not a function or 
>> function pointer
 time = (u32)((req.reply[3] << 24( | (req.reply[4] << 16) |
   ^~
>> arch/m68k/mac/misc.c:49:43: error: expected ')' before ';' token
   (req.reply[5] << 8) | req.reply[6]);
  ^
   arch/m68k/mac/misc.c:55:1: error: expected ')' before '}' token
}
^
>> arch/m68k/mac/misc.c:55:1: error: expected ';' before '}' token
   arch/m68k/mac/misc.c:55:1: warning: control reaches end of non-void function 
[-Wreturn-type]
}
^

vim +48 arch/m68k/mac/misc.c

36  
37  #ifdef CONFIG_ADB_CUDA
38  static time64_t cuda_read_time(void)
39  {
40  struct adb_request req;
41  time64_t time;
42  
43  if (cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_GET_TIME) < 0)
44  return 0;
45  while (!req.complete)
46  cuda_poll();
47  
  > 48  time = (u32)((req.reply[3] << 24( | (req.reply[4] << 16) |
  > 49   (req.reply[5] << 8) | req.reply[6]);
50  
51  /* it's either after year 2040, or the RTC has gone backwards */
52  WARN_ON(time < RTC_OFFSET);
53  
54  return time - RTC_OFFSET;
  > 55  }
56  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH] arch: powerpc: pci-common: fix wrong return value check on phd_id

2018-06-18 Thread Daniel Walker
Cisco has a couple platforms which depend on the domain values getting
set a certain way. We discovered our machines not detecting the pci
devices, and traced it back to this commit,

63a7228 powerpc/pci: Assign fixed PHB number based on device-tree
properties

It seems that the code is expecting the return value of of_property_read_u64()
to be the opposite of what it actually is.. It returns zero on success, and a
negative return value on error. So if you only check when it's non-zero your
going to set Opal for all platforms but Opal, which I assume is not what was
expected.

Fix is just to negate the ret value.

Cc: xe-ker...@external.cisco.com
Cc: Guilherme G. Piccoli 
Cc: Gavin Shan 
Cc: Ian Munsie 
Cc: Michael Ellerman 
Fixes: 63a72284b159 ("powerpc/pci: Assign fixed PHB number based on device-tree 
properties")
Signed-off-by: Daniel Walker 
---
 arch/powerpc/kernel/pci-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fe9733f..0a1bcbe 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -89,7 +89,7 @@ static int get_phb_number(struct device_node *dn)
 * reading "ibm,opal-phbid", only present in OPAL environment.
 */
ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop);
-   if (ret) {
+   if (!ret) {
ret = of_property_read_u32_index(dn, "reg", 1, &prop_32);
prop = prop_32;
}
-- 
2.10.3.dirty



Re: [PATCH] Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"

2018-06-18 Thread Andreas Schwab
On Jun 17 2018, Eric Dumazet  wrote:

> Oh this is silly, please try :
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 
> c642304f178ce0a4e1358d59e45032a39f76fb3f..54dd9c18ecad817812898d6f335e1794a07dabbe
>  100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -1845,10 +1845,9 @@ EXPORT_SYMBOL(___pskb_trim);
>  int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
>  {
> if (skb->ip_summed == CHECKSUM_COMPLETE) {
> -   int delta = skb->len - len;
> +   __wsum csumdiff = skb_checksum(skb, len, skb->len - len, 0);
>  
> -   skb->csum = csum_sub(skb->csum,
> -skb_checksum(skb, len, delta, 0));
> +   skb->csum = csum_block_sub(skb->csum, csumdiff, len);
> }
> return __pskb_trim(skb, len);
>  }

That doesn't help either.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH] Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"

2018-06-18 Thread Eric Dumazet



On 06/18/2018 10:54 AM, Andreas Schwab wrote:
> On Jun 17 2018, Eric Dumazet  wrote:
> 
>> Oh this is silly, please try :
>>
>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
>> index 
>> c642304f178ce0a4e1358d59e45032a39f76fb3f..54dd9c18ecad817812898d6f335e1794a07dabbe
>>  100644
>> --- a/net/core/skbuff.c
>> +++ b/net/core/skbuff.c
>> @@ -1845,10 +1845,9 @@ EXPORT_SYMBOL(___pskb_trim);
>>  int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
>>  {
>> if (skb->ip_summed == CHECKSUM_COMPLETE) {
>> -   int delta = skb->len - len;
>> +   __wsum csumdiff = skb_checksum(skb, len, skb->len - len, 0);
>>  
>> -   skb->csum = csum_sub(skb->csum,
>> -skb_checksum(skb, len, delta, 0));
>> +   skb->csum = csum_block_sub(skb->csum, csumdiff, len);
>> }
>> return __pskb_trim(skb, len);
>>  }
> 
> That doesn't help either.
> 
> Andreas.
> 

Then maybe NIC provided csum is not correct.

It does not compute a checksum on all the frame, but part of it.

You could use this patch to double check.

diff --git a/drivers/net/ethernet/sun/sungem.c 
b/drivers/net/ethernet/sun/sungem.c
index 
7a16d40a72d13cf1d522e8a3a396c826fe76f9b9..277859ea73e35271a10b02011120fca248ec8e71
 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -857,6 +857,11 @@ static int gem_rx(struct gem *gp, int work_to_do)
 
csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 
0x);
skb->csum = csum_unfold(csum);
+   {
+   __wsum rsum = csum_partial(skb->data + ETH_HLEN, len - 
ETH_HLEN, 0);
+   if (csum != csum_fold(rsum))
+   pr_err_ratelimited("sungem wrong csum : %x/%x, len %u 
bytes\n", csum, csum_fold(rsum), len);
+   }
skb->ip_summed = CHECKSUM_COMPLETE;
skb->protocol = eth_type_trans(skb, gp->dev);
 






Re: [PATCH] Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"

2018-06-18 Thread Mathieu Malaterre
On Mon, Jun 18, 2018 at 7:54 PM Andreas Schwab  wrote:
>
> On Jun 17 2018, Eric Dumazet  wrote:
>
> > Oh this is silly, please try :
> >
> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> > index 
> > c642304f178ce0a4e1358d59e45032a39f76fb3f..54dd9c18ecad817812898d6f335e1794a07dabbe
> >  100644
> > --- a/net/core/skbuff.c
> > +++ b/net/core/skbuff.c
> > @@ -1845,10 +1845,9 @@ EXPORT_SYMBOL(___pskb_trim);
> >  int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
> >  {
> > if (skb->ip_summed == CHECKSUM_COMPLETE) {
> > -   int delta = skb->len - len;
> > +   __wsum csumdiff = skb_checksum(skb, len, skb->len - len, 0);
> >
> > -   skb->csum = csum_sub(skb->csum,
> > -skb_checksum(skb, len, delta, 0));
> > +   skb->csum = csum_block_sub(skb->csum, csumdiff, len);
> > }
> > return __pskb_trim(skb, len);
> >  }
>
> That doesn't help either.

seconded (setup g4+sungem):

[  100.272676] eth0: hw csum failure
[  100.272710] CPU: 0 PID: 0 Comm: swapper Not tainted 4.17.0+ #6
[  100.272716] Call Trace:
[  100.272733] [dffedbd0] [c069ddb8]
__skb_checksum_complete+0xf0/0x108 (unreliable)
[  100.272752] [dffedbf0] [c078ea28] __udp4_lib_rcv+0x238/0xf98
[  100.272767] [dffedc70] [c0731630] ip_local_deliver_finish+0xa8/0x3c4
[  100.272777] [dffedcb0] [c073243c] ip_local_deliver+0xf0/0x154
[  100.272786] [dffedcf0] [c07328e8] ip_rcv+0x448/0x774
[  100.272800] [dffedd50] [c06aeaec] __netif_receive_skb_core+0x5e8/0x1184
[  100.272811] [dffedde0] [c06bba2c] napi_gro_receive+0x160/0x22c
[  100.272828] [dffede10] [e1571590] gem_poll+0x7fc/0x1ac0 [sungem]
[  100.272837] [dffedee0] [c06bacfc] net_rx_action+0x34c/0x618
[  100.272849] [dffedf60] [c07fd28c] __do_softirq+0x16c/0x5f0
[  100.272863] [dffedfd0] [c0064c7c] irq_exit+0x110/0x1a8
[  100.272877] [dffedff0] [c0016170] call_do_irq+0x24/0x3c
[  100.272890] [c0cf7e80] [c0009a84] do_IRQ+0x98/0x1a0
[  100.272900] [c0cf7eb0] [c001b474] ret_from_except+0x0/0x14
[  100.272911] --- interrupt: 501 at arch_cpu_idle+0x30/0x78
   LR = arch_cpu_idle+0x30/0x78
[  100.272920] [c0cf7f70] [c0cf6000] 0xc0cf6000 (unreliable)
[  100.272935] [c0cf7f80] [c00a3868] do_idle+0xc4/0x158
[  100.272944] [c0cf7fb0] [c00a3ab4] cpu_startup_entry+0x24/0x28
[  100.272955] [c0cf7fc0] [c0998820] start_kernel+0x47c/0x490
[  100.272963] [c0cf7ff0] [3444] 0x3444


> Andreas.
>
> --
> Andreas Schwab, sch...@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."


Re: [PATCH] Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"

2018-06-18 Thread Mathieu Malaterre
On Mon, Jun 18, 2018 at 8:18 PM Eric Dumazet  wrote:
>
>
>
> On 06/18/2018 10:54 AM, Andreas Schwab wrote:
> > On Jun 17 2018, Eric Dumazet  wrote:
> >
> >> Oh this is silly, please try :
> >>
> >> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> >> index 
> >> c642304f178ce0a4e1358d59e45032a39f76fb3f..54dd9c18ecad817812898d6f335e1794a07dabbe
> >>  100644
> >> --- a/net/core/skbuff.c
> >> +++ b/net/core/skbuff.c
> >> @@ -1845,10 +1845,9 @@ EXPORT_SYMBOL(___pskb_trim);
> >>  int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
> >>  {
> >> if (skb->ip_summed == CHECKSUM_COMPLETE) {
> >> -   int delta = skb->len - len;
> >> +   __wsum csumdiff = skb_checksum(skb, len, skb->len - len, 
> >> 0);
> >>
> >> -   skb->csum = csum_sub(skb->csum,
> >> -skb_checksum(skb, len, delta, 0));
> >> +   skb->csum = csum_block_sub(skb->csum, csumdiff, len);
> >> }
> >> return __pskb_trim(skb, len);
> >>  }
> >
> > That doesn't help either.
> >
> > Andreas.
> >
>
> Then maybe NIC provided csum is not correct.
>
> It does not compute a checksum on all the frame, but part of it.
>
> You could use this patch to double check.
>
> diff --git a/drivers/net/ethernet/sun/sungem.c 
> b/drivers/net/ethernet/sun/sungem.c
> index 
> 7a16d40a72d13cf1d522e8a3a396c826fe76f9b9..277859ea73e35271a10b02011120fca248ec8e71
>  100644
> --- a/drivers/net/ethernet/sun/sungem.c
> +++ b/drivers/net/ethernet/sun/sungem.c
> @@ -857,6 +857,11 @@ static int gem_rx(struct gem *gp, int work_to_do)
>
> csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 
> 0x);
> skb->csum = csum_unfold(csum);
> +   {
> +   __wsum rsum = csum_partial(skb->data + ETH_HLEN, len - 
> ETH_HLEN, 0);
> +   if (csum != csum_fold(rsum))
> +   pr_err_ratelimited("sungem wrong csum : %x/%x, len %u 
> bytes\n", csum, csum_fold(rsum), len);
> +   }
> skb->ip_summed = CHECKSUM_COMPLETE;
> skb->protocol = eth_type_trans(skb, gp->dev);
>
>

Here is what I get on my side

[   53.628847] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
[   53.667063] sungem: sungem wrong csum : eea8/6eec, len 149 bytes
[   58.648952] sungem: sungem wrong csum : 2095/3d06, len 64 bytes
[   58.669414] sungem: sungem wrong csum : 5245/b50, len 149 bytes
[   63.674451] sungem: sungem wrong csum : 2d8/5abd, len 149 bytes
[   68.678233] sungem: sungem wrong csum : b8fc/a498, len 149 bytes
[   73.685771] sungem: sungem wrong csum : 374/5a21, len 149 bytes
[   78.689089] sungem: sungem wrong csum : d81/5014, len 149 bytes
[   83.683261] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
[   83.690193] sungem: sungem wrong csum : c2f7/9a9d, len 149 bytes
[   88.692511] sungem: sungem wrong csum : f4d8/68bc, len 149 bytes
[   93.699915] sungem: sungem wrong csum : 1370/4a25, len 149 bytes
[   98.703136] sungem: sungem wrong csum : e1b5/7bdf, len 149 bytes
[  103.704230] sungem: sungem wrong csum : 5321/a74, len 149 bytes
[  108.688912] sungem: sungem wrong csum : 2095/3d06, len 64 bytes
[  108.706559] sungem: sungem wrong csum : ddbc/7fd8, len 149 bytes
[  113.713189] sungem: sungem wrong csum : 5a65/330, len 149 bytes
[  113.891697] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
[  118.717151] sungem: sungem wrong csum : f7c8/65cc, len 149 bytes
[  123.722680] sungem: sungem wrong csum : 3d7a/201b, len 149 bytes
[  128.726524] sungem: sungem wrong csum : c8fd/9497, len 149 bytes
[  133.732045] sungem: sungem wrong csum : de0d/7f87, len 149 bytes
[  135.529163] sungem: sungem wrong csum : 3089/b6dd, len 96 bytes
[  135.529208] eth0: hw csum failure
[  135.529220] CPU: 0 PID: 0 Comm: swapper Not tainted 4.17.0+ #7
[  135.529226] Call Trace:
[  135.529243] [dffedbe0] [c069ddac]
__skb_checksum_complete+0xf0/0x108 (unreliable)


>
>
>


Re: [PATCH 1/3] powerpc: mac: fix rtc read functions

2018-06-18 Thread Mathieu Malaterre
On Mon, Jun 18, 2018 at 4:07 PM Arnd Bergmann  wrote:
>
> As Mathieu pointed out, my conversion to time64_t was incorrect and resulted
> in negative times to be read from the RTC. The problem is that during the
> conversion from a byte array to a time64_t, the 'unsigned char' variable
> holding the top byte gets turned into a negative signed 32-bit integer
> before being assigned to the 64-bit variable for any times after 1972.
>
> This changes the logic to cast to an unsigned 32-bit number first for
> the Macintosh time and then convert that to the Unix time, which then gives
> us a time in the documented 1904..2040 year range. I decided not to use
> the longer 1970..2106 range that other drivers use, for consistency with
> the literal interpretation of the register, but that could be easily
> changed if we decide we want to support any Mac after 2040.
>
> Just to be on the safe side, I'm also adding a WARN_ON that will trigger
> if either the year 2040 has come and is observed by this driver, or we
> run into an RTC that got set back to a pre-1970 date for some reason
> (the two are indistinguishable).
>
> The same code exists in arch/m68k/ and is patched in an identical way now
> in a separate patch.
>
> Fixes: 5bfd643583b2 ("powerpc: use time64_t in read_persistent_clock")
> Reported-by: Mathieu Malaterre 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/powerpc/platforms/powermac/time.c | 21 -
>  1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powermac/time.c 
> b/arch/powerpc/platforms/powermac/time.c
> index 7c968e46736f..173a80630169 100644
> --- a/arch/powerpc/platforms/powermac/time.c
> +++ b/arch/powerpc/platforms/powermac/time.c
> @@ -42,7 +42,11 @@
>  #define DBG(x...)
>  #endif
>
> -/* Apparently the RTC stores seconds since 1 Jan 1904 */
> +/*
> + * Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and 
> PMU
> + * times wrap in 2040. If we need to handle later times, the read_time 
> functions
> + * need to be changed to interpret wrapped times as post-2040.
> + */
>  #define RTC_OFFSET 2082844800
>
>  /*
> @@ -97,8 +101,11 @@ static time64_t cuda_get_time(void)
> if (req.reply_len != 7)
> printk(KERN_ERR "cuda_get_time: got %d byte reply\n",
>req.reply_len);
> -   now = (req.reply[3] << 24) + (req.reply[4] << 16)
> -   + (req.reply[5] << 8) + req.reply[6];
> +   now = (u32)((req.reply[3] << 24) + (req.reply[4] << 16) +
> +   (req.reply[5] << 8) + req.reply[6]);
> +   /* it's either after year 2040, or the RTC has gone backwards */
> +   WARN_ON(now < RTC_OFFSET);
> +
> return now - RTC_OFFSET;
>  }
>
> @@ -140,8 +147,12 @@ static time64_t pmu_get_time(void)
> if (req.reply_len != 4)
> printk(KERN_ERR "pmu_get_time: got %d byte reply from PMU\n",
>req.reply_len);
> -   now = (req.reply[0] << 24) + (req.reply[1] << 16)
> -   + (req.reply[2] << 8) + req.reply[3];
> +   now = (u32)((req.reply[0] << 24) + (req.reply[1] << 16) +
> +   (req.reply[2] << 8) + req.reply[3]);
> +
> +   /* it's either after year 2040, or the RTC has gone backwards */
> +   WARN_ON(now < RTC_OFFSET);
> +
> return now - RTC_OFFSET;
>  }

Sadly, trying again today does not work anymore. Adding some printk
just before WARN_ON:

+printk(KERN_ERR " rtc DBG pmu_get_time1: %lld %d %lld \n", now,
RTC_OFFSET, now - RTC_OFFSET );
+printk(KERN_ERR " rtc DBG pmu_get_time2: %x %x %x %x %d \n",
req.reply[0], req.reply[1], req.reply[2], req.reply[3] ,
req.reply_len);

leads to:

[0.00]  rtc DBG pmu_get_time1: 14096662 2082844800 -2068748138
[0.00]  rtc DBG pmu_get_time2: 0 d7 19 16 4
[0.00] WARNING: CPU: 0 PID: 0 at
../arch/powerpc/platforms/powermac/time.c:158 pmu_get_time+0x11c/0x16c
[0.00] Modules linked in:
[0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 4.17.0+ #8
[0.00] NIP:  c0035658 LR: c0035640 CTR: c00d4a5c
[0.00] REGS: c0cf7da0 TRAP: 0700   Not tainted  (4.17.0+)
[0.00] MSR:  00021032   CR: 84000848  XER: 
[0.00]
   GPR00: c0035640 c0cf7e50 c0a41bd0 0025 0001
0051 c0d56430 
   GPR08: 0051 0001 c0aa4b38 0004 24000842
 ffbbf4c0 0013da1c
   GPR16: 0013da18 0013da20   00b81044
01696028 01697e02 4014
   GPR24:  00d71000 c09debec dfff1120 01a4
00d71916  84b16896
[0.00] NIP [c0035658] pmu_get_time+0x11c/0x16c
[0.00] LR [c0035640] pmu_get_time+0x104/0x16c
[0.00] Call Trace:
[0.00] [c0cf7e50] [c0035640] pmu_get_time+0x104/0x16c (unreliable)
[0.00] [c0cf7ed0] [c00113fc] read_persistent_clock64+0x78/0x1ac
[0.00] [c0cf7f30] [c09ad470] timekeeping_init+0x24/0x2f4
[0.00] [c0cf7fc0] [c09986f0] start_ker

Re: [PATCH 1/3] powerpc: mac: fix rtc read functions

2018-06-18 Thread Andreas Schwab
On Jun 18 2018, Mathieu Malaterre  wrote:

> Sadly, trying again today does not work anymore. Adding some printk
> just before WARN_ON:
>
> +printk(KERN_ERR " rtc DBG pmu_get_time1: %lld %d %lld \n", now,
> RTC_OFFSET, now - RTC_OFFSET );
> +printk(KERN_ERR " rtc DBG pmu_get_time2: %x %x %x %x %d \n",
> req.reply[0], req.reply[1], req.reply[2], req.reply[3] ,
> req.reply_len);
>
> leads to:
>
> [0.00]  rtc DBG pmu_get_time1: 14096662 2082844800 -2068748138
> [0.00]  rtc DBG pmu_get_time2: 0 d7 19 16 4

A good value would have 0xd7 in the first byte.  The problem is that
pmu_set_rtc_time is also broken, and leads to an invalid time value
stored in the RTC.  Since pmu_request is a varargs function passing
values of type time64_t without casting won't work.

You need to reset your RTC before you can continue.

I think the right fix is to change nowtime in pmu_set_rtc_time and
cuda_set_rtc_time back to unsigned int (or to u32).

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


[PATCH] powerpc/pci: Remove legacy debug code

2018-06-18 Thread Breno Leitao
Commit 59f47eff03a0 ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")
removed the 'oirq' variable, but kept memsetting it when the DEBUG macro is
defined.

When setting DEBUG macro for debugging purpose, the kernel fails to build since
'oirq' is not defined anymore.

This patch simply remove the debug block, since it does not seem to sense
now.

Fixes: 59f47eff03a08c ("powerpc/pci: Use of_irq_parse_and_map_pci() helper")

Signed-off-by: Breno Leitao 
---
 arch/powerpc/kernel/pci-common.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fe9733aa..f9352167e619 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -366,9 +366,6 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
 
pr_debug("PCI: Try to map irq for %s...\n", pci_name(pci_dev));
 
-#ifdef DEBUG
-   memset(&oirq, 0xff, sizeof(oirq));
-#endif
/* Try to get a mapping from the device-tree */
virq = of_irq_parse_and_map_pci(pci_dev, 0, 0);
if (virq <= 0) {
-- 
2.16.3



[PATCH v2 1/4] powerpc/tm: Remove msr_tm_active()

2018-06-18 Thread Breno Leitao
Currently msr_tm_active() is a wrapper around MSR_TM_ACTIVE() if
CONFIG_PPC_TRANSACTIONAL_MEM is set, or it is just a function that
returns false if CONFIG_PPC_TRANSACTIONAL_MEM is not set.

This function is not necessary, since MSR_TM_ACTIVE() just do the same,
checking for the TS bits and does not require any TM facility.

This patchset remove every instance of msr_tm_active() and replaced it
by MSR_TM_ACTIVE().

Signed-off-by: Breno Leitao 
---
 arch/powerpc/kernel/process.c | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index d26a150766ef..661e4ed5f628 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -102,24 +102,18 @@ static void check_if_tm_restore_required(struct 
task_struct *tsk)
}
 }
 
-static inline bool msr_tm_active(unsigned long msr)
-{
-   return MSR_TM_ACTIVE(msr);
-}
-
 static bool tm_active_with_fp(struct task_struct *tsk)
 {
-   return msr_tm_active(tsk->thread.regs->msr) &&
+   return MSR_TM_ACTIVE(tsk->thread.regs->msr) &&
(tsk->thread.ckpt_regs.msr & MSR_FP);
 }
 
 static bool tm_active_with_altivec(struct task_struct *tsk)
 {
-   return msr_tm_active(tsk->thread.regs->msr) &&
+   return MSR_TM_ACTIVE(tsk->thread.regs->msr) &&
(tsk->thread.ckpt_regs.msr & MSR_VEC);
 }
 #else
-static inline bool msr_tm_active(unsigned long msr) { return false; }
 static inline void check_if_tm_restore_required(struct task_struct *tsk) { }
 static inline bool tm_active_with_fp(struct task_struct *tsk) { return false; }
 static inline bool tm_active_with_altivec(struct task_struct *tsk) { return 
false; }
@@ -239,6 +233,7 @@ void enable_kernel_fp(void)
cpumsr = msr_check_and_set(MSR_FP);
 
if (current->thread.regs && (current->thread.regs->msr & MSR_FP)) {
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
check_if_tm_restore_required(current);
/*
 * If a thread has already been reclaimed then the
@@ -247,8 +242,10 @@ void enable_kernel_fp(void)
 * giveup as this would save  to the 'live' structure not the
 * checkpointed structure.
 */
-   if(!msr_tm_active(cpumsr) && 
msr_tm_active(current->thread.regs->msr))
+   if (!MSR_TM_ACTIVE(cpumsr) &&
+MSR_TM_ACTIVE(current->thread.regs->msr))
return;
+#endif
__giveup_fpu(current);
}
 }
@@ -303,6 +300,7 @@ void enable_kernel_altivec(void)
cpumsr = msr_check_and_set(MSR_VEC);
 
if (current->thread.regs && (current->thread.regs->msr & MSR_VEC)) {
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
check_if_tm_restore_required(current);
/*
 * If a thread has already been reclaimed then the
@@ -311,8 +309,10 @@ void enable_kernel_altivec(void)
 * giveup as this would save  to the 'live' structure not the
 * checkpointed structure.
 */
-   if(!msr_tm_active(cpumsr) && 
msr_tm_active(current->thread.regs->msr))
+   if (!MSR_TM_ACTIVE(cpumsr) &&
+MSR_TM_ACTIVE(current->thread.regs->msr))
return;
+#endif
__giveup_altivec(current);
}
 }
@@ -389,6 +389,7 @@ void enable_kernel_vsx(void)
 
if (current->thread.regs &&
(current->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP))) {
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
check_if_tm_restore_required(current);
/*
 * If a thread has already been reclaimed then the
@@ -397,8 +398,10 @@ void enable_kernel_vsx(void)
 * giveup as this would save  to the 'live' structure not the
 * checkpointed structure.
 */
-   if(!msr_tm_active(cpumsr) && 
msr_tm_active(current->thread.regs->msr))
+   if (!MSR_TM_ACTIVE(cpumsr) &&
+MSR_TM_ACTIVE(current->thread.regs->msr))
return;
+#endif
__giveup_vsx(current);
}
 }
@@ -530,9 +533,14 @@ void restore_math(struct pt_regs *regs)
 {
unsigned long msr;
 
-   if (!msr_tm_active(regs->msr) &&
-   !current->thread.load_fp && !loadvec(current->thread))
+   if (!current->thread.load_fp && !loadvec(current->thread)) {
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+   if (!MSR_TM_ACTIVE(regs->msr))
+   return;
+#else
return;
+#endif
+   }
 
msr = regs->msr;
msr_check_and_set(msr_all_available);
-- 
2.16.3



[PATCH v2 2/4] powerpc/tm: Fix HTM documentation

2018-06-18 Thread Breno Leitao
This patch simply fix part of the documentation on the HTM code.

This fixes reference to old fields that were renamed in commit
000ec280e3dd ("powerpc: tm: Rename transct_(*) to ck(\1)_state")

It also documents better the flow after commit eb5c3f1c8647 ("powerpc:
Always save/restore checkpointed regs during treclaim/trecheckpoint"),
where tm_recheckpoint can recheckpoint what is in ck{fp,vr}_state blindly.

Signed-off-by: Breno Leitao 
---
 arch/powerpc/kernel/tm.S| 10 +-
 arch/powerpc/kernel/traps.c | 15 +--
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
index ff12f47a96b6..019d73053cd3 100644
--- a/arch/powerpc/kernel/tm.S
+++ b/arch/powerpc/kernel/tm.S
@@ -95,9 +95,9 @@ EXPORT_SYMBOL_GPL(tm_abort);
  *uint8_t cause)
  *
  * - Performs a full reclaim.  This destroys outstanding
- *   transactions and updates thread->regs.tm_ckpt_* with the
- *   original checkpointed state.  Note that thread->regs is
- *   unchanged.
+ *   transactions and updates thread.ckpt_regs, thread.ckfp_state and
+ *   thread.ckvr_state with the original checkpointed state.  Note that
+ *   thread->regs is unchanged.
  *
  * Purpose is to both abort transactions of, and preserve the state of,
  * a transactions at a context switch. We preserve/restore both sets of process
@@ -260,7 +260,7 @@ _GLOBAL(tm_reclaim)
 
/* Altivec (VEC/VMX/VR)*/
addir7, r3, THREAD_CKVRSTATE
-   SAVE_32VRS(0, r6, r7)   /* r6 scratch, r7 transact vr state */
+   SAVE_32VRS(0, r6, r7)   /* r6 scratch, r7 ckvr_state */
mfvscr  v0
li  r6, VRSTATE_VSCR
stvxv0, r7, r6
@@ -271,7 +271,7 @@ _GLOBAL(tm_reclaim)
 
/* Floating Point (FP) */
addir7, r3, THREAD_CKFPSTATE
-   SAVE_32FPRS_VSRS(0, R6, R7) /* r6 scratch, r7 transact fp state */
+   SAVE_32FPRS_VSRS(0, R6, R7) /* r6 scratch, r7 ckfp_state */
mffsfr0
stfdfr0,FPSTATE_FPSCR(r7)
 
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 0e17dcb48720..6742b6b3eb37 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1719,16 +1719,19 @@ void fp_unavailable_tm(struct pt_regs *regs)
  * checkpointed FP registers need to be loaded.
 */
tm_reclaim_current(TM_CAUSE_FAC_UNAV);
-   /* Reclaim didn't save out any FPRs to transact_fprs. */
+
+   /* Reclaim initially saved out bogus (lazy) FPRs to ckfp_state, and
+* then it was overwrite by the thr->fp_state by tm_reclaim_thread().
+*
+* At this point, ck{fp,vr}_state contains the exact values we want to
+* recheckpoint.
+*/
 
/* Enable FP for the task: */
current->thread.load_fp = 1;
 
-   /* This loads and recheckpoints the FP registers from
-* thread.fpr[].  They will remain in registers after the
-* checkpoint so we don't need to reload them after.
-* If VMX is in use, the VRs now hold checkpointed values,
-* so we don't want to load the VRs from the thread_struct.
+   /*
+* Recheckpoint all the checkpointed ckpt, ck{fp, vr}_state registers.
 */
tm_recheckpoint(¤t->thread);
 }
-- 
2.16.3



[PATCH v2 3/4] powerpc/tm: Adjust tm_reclaim_thread() parameters

2018-06-18 Thread Breno Leitao
From: Cyril Bur 

tm_reclaim_thread() doesn't use the parameter anymore, both callers have
to bother getting it as they have no need for a struct thread_info
either.

It was previously used but became unused in commit
dc3106690b20 ("powerpc: tm: Always use fp_state and vr_state to store live
registers")

Just remove it and adjust the callers.

Signed-off-by: Cyril Bur 
Signed-off-by: Breno Leitao 
---
 arch/powerpc/kernel/process.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9ef4aea9fffe..f8beee03f00a 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -866,8 +866,7 @@ static inline bool tm_enabled(struct task_struct *tsk)
return tsk && tsk->thread.regs && (tsk->thread.regs->msr & MSR_TM);
 }
 
-static void tm_reclaim_thread(struct thread_struct *thr,
- struct thread_info *ti, uint8_t cause)
+static void tm_reclaim_thread(struct thread_struct *thr, uint8_t cause)
 {
/*
 * Use the current MSR TM suspended bit to track if we have
@@ -914,7 +913,7 @@ static void tm_reclaim_thread(struct thread_struct *thr,
 void tm_reclaim_current(uint8_t cause)
 {
tm_enable();
-   tm_reclaim_thread(¤t->thread, current_thread_info(), cause);
+   tm_reclaim_thread(¤t->thread, cause);
 }
 
 static inline void tm_reclaim_task(struct task_struct *tsk)
@@ -945,7 +944,7 @@ static inline void tm_reclaim_task(struct task_struct *tsk)
 thr->regs->ccr, thr->regs->msr,
 thr->regs->trap);
 
-   tm_reclaim_thread(thr, task_thread_info(tsk), TM_CAUSE_RESCHED);
+   tm_reclaim_thread(thr, TM_CAUSE_RESCHED);
 
TM_DEBUG("--- tm_reclaim on pid %d complete\n",
 tsk->pid);
-- 
2.16.3



[PATCH v2 4/4] powerpc/tm: Do not recheckpoint non-tm task

2018-06-18 Thread Breno Leitao
If __switch_to() tries to context switch from task A to task B, and task A
 had task->thread->regs->msr[TM] enabled, then __switch_to_tm() will call
tm_recheckpoint_new_task(), which will call trecheckpoint, for task B, which
 is clearly wrong since task B might not be an active TM user.

This does not cause a lot of damage because tm_recheckpoint() will abort
the call since it realize that the current task does not have msr[TM] bit
set.

Signed-off-by: Breno Leitao 
---
 arch/powerpc/kernel/process.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index f8beee03f00a..d26a150766ef 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1036,7 +1036,8 @@ static inline void __switch_to_tm(struct task_struct 
*prev,
prev->thread.regs->msr &= ~MSR_TM;
}
 
-   tm_recheckpoint_new_task(new);
+   if (tm_enabled(new))
+   tm_recheckpoint_new_task(new);
}
 }
 
-- 
2.16.3



Re: [PATCH] Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"

2018-06-18 Thread Eric Dumazet



On 06/18/2018 11:45 AM, Mathieu Malaterre wrote:

> 
> Here is what I get on my side
> 
> [   53.628847] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
> [   53.667063] sungem: sungem wrong csum : eea8/6eec, len 149 bytes
> [   58.648952] sungem: sungem wrong csum : 2095/3d06, len 64 bytes
> [   58.669414] sungem: sungem wrong csum : 5245/b50, len 149 bytes
> [   63.674451] sungem: sungem wrong csum : 2d8/5abd, len 149 bytes
> [   68.678233] sungem: sungem wrong csum : b8fc/a498, len 149 bytes
> [   73.685771] sungem: sungem wrong csum : 374/5a21, len 149 bytes
> [   78.689089] sungem: sungem wrong csum : d81/5014, len 149 bytes
> [   83.683261] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
> [   83.690193] sungem: sungem wrong csum : c2f7/9a9d, len 149 bytes
> [   88.692511] sungem: sungem wrong csum : f4d8/68bc, len 149 bytes
> [   93.699915] sungem: sungem wrong csum : 1370/4a25, len 149 bytes
> [   98.703136] sungem: sungem wrong csum : e1b5/7bdf, len 149 bytes
> [  103.704230] sungem: sungem wrong csum : 5321/a74, len 149 bytes
> [  108.688912] sungem: sungem wrong csum : 2095/3d06, len 64 bytes
> [  108.706559] sungem: sungem wrong csum : ddbc/7fd8, len 149 bytes
> [  113.713189] sungem: sungem wrong csum : 5a65/330, len 149 bytes
> [  113.891697] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
> [  118.717151] sungem: sungem wrong csum : f7c8/65cc, len 149 bytes
> [  123.722680] sungem: sungem wrong csum : 3d7a/201b, len 149 bytes
> [  128.726524] sungem: sungem wrong csum : c8fd/9497, len 149 bytes
> [  133.732045] sungem: sungem wrong csum : de0d/7f87, len 149 bytes
> [  135.529163] sungem: sungem wrong csum : 3089/b6dd, len 96 bytes
> [  135.529208] eth0: hw csum failure
> [  135.529220] CPU: 0 PID: 0 Comm: swapper Not tainted 4.17.0+ #7
> [  135.529226] Call Trace:
> [  135.529243] [dffedbe0] [c069ddac]
> __skb_checksum_complete+0xf0/0x108 (unreliable)

Thanks, then I guess next step would be to dump the content of the frames
having a wrong checksum, hoping we find an easy way to discard the 
CHECKSUM_COMPLETE
in a selective way.

Otherwise, we will need to remove CHECKSUM_COMPLETE setting in this driver.

diff --git a/drivers/net/ethernet/sun/sungem.c 
b/drivers/net/ethernet/sun/sungem.c
index 
7a16d40a72d13cf1d522e8a3a396c826fe76f9b9..77a761f95be788bb86c8d917f613c9084818f826
 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -857,6 +857,14 @@ static int gem_rx(struct gem *gp, int work_to_do)
 
csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 
0x);
skb->csum = csum_unfold(csum);
+   {
+   __wsum rsum = csum_partial(skb->data + ETH_HLEN, len - 
ETH_HLEN, 0);
+   if (csum != csum_fold(rsum) && net_ratelimit())
+   pr_err("sungem wrong csum : %04x/%04x, len %u bytes\n",
+   csum, csum_fold(rsum), len);
+   print_hex_dump(KERN_ERR, "raw data: ", 
DUMP_PREFIX_OFFSET,
+   16, 1, skb->data, len, true);
+   }
skb->ip_summed = CHECKSUM_COMPLETE;
skb->protocol = eth_type_trans(skb, gp->dev);
 



Re: [PATCH] Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"

2018-06-18 Thread Eric Dumazet



On 06/18/2018 04:29 PM, Eric Dumazet wrote:
> 
> 
> On 06/18/2018 11:45 AM, Mathieu Malaterre wrote:
> 
>>
>> Here is what I get on my side
>>
>> [   53.628847] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
>> [   53.667063] sungem: sungem wrong csum : eea8/6eec, len 149 bytes
>> [   58.648952] sungem: sungem wrong csum : 2095/3d06, len 64 bytes
>> [   58.669414] sungem: sungem wrong csum : 5245/b50, len 149 bytes
>> [   63.674451] sungem: sungem wrong csum : 2d8/5abd, len 149 bytes
>> [   68.678233] sungem: sungem wrong csum : b8fc/a498, len 149 bytes
>> [   73.685771] sungem: sungem wrong csum : 374/5a21, len 149 bytes
>> [   78.689089] sungem: sungem wrong csum : d81/5014, len 149 bytes
>> [   83.683261] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
>> [   83.690193] sungem: sungem wrong csum : c2f7/9a9d, len 149 bytes
>> [   88.692511] sungem: sungem wrong csum : f4d8/68bc, len 149 bytes
>> [   93.699915] sungem: sungem wrong csum : 1370/4a25, len 149 bytes
>> [   98.703136] sungem: sungem wrong csum : e1b5/7bdf, len 149 bytes
>> [  103.704230] sungem: sungem wrong csum : 5321/a74, len 149 bytes
>> [  108.688912] sungem: sungem wrong csum : 2095/3d06, len 64 bytes
>> [  108.706559] sungem: sungem wrong csum : ddbc/7fd8, len 149 bytes
>> [  113.713189] sungem: sungem wrong csum : 5a65/330, len 149 bytes
>> [  113.891697] sungem: sungem wrong csum : 4e04/f97, len 64 bytes
>> [  118.717151] sungem: sungem wrong csum : f7c8/65cc, len 149 bytes
>> [  123.722680] sungem: sungem wrong csum : 3d7a/201b, len 149 bytes
>> [  128.726524] sungem: sungem wrong csum : c8fd/9497, len 149 bytes
>> [  133.732045] sungem: sungem wrong csum : de0d/7f87, len 149 bytes
>> [  135.529163] sungem: sungem wrong csum : 3089/b6dd, len 96 bytes
>> [  135.529208] eth0: hw csum failure
>> [  135.529220] CPU: 0 PID: 0 Comm: swapper Not tainted 4.17.0+ #7
>> [  135.529226] Call Trace:
>> [  135.529243] [dffedbe0] [c069ddac]
>> __skb_checksum_complete+0xf0/0x108 (unreliable)
> 
> Thanks, then I guess next step would be to dump the content of the frames
> having a wrong checksum, hoping we find an easy way to discard the 
> CHECKSUM_COMPLETE
> in a selective way.
> 
> Otherwise, we will need to remove CHECKSUM_COMPLETE setting in this driver.
> 
> diff --git a/drivers/net/ethernet/sun/sungem.c 
> b/drivers/net/ethernet/sun/sungem.c
> index 
> 7a16d40a72d13cf1d522e8a3a396c826fe76f9b9..77a761f95be788bb86c8d917f613c9084818f826
>  100644
> --- a/drivers/net/ethernet/sun/sungem.c
> +++ b/drivers/net/ethernet/sun/sungem.c
> @@ -857,6 +857,14 @@ static int gem_rx(struct gem *gp, int work_to_do)
>  
> csum = (__force __sum16)htons((status & RXDCTRL_TCPCSUM) ^ 
> 0x);
> skb->csum = csum_unfold(csum);
> +   {
> +   __wsum rsum = csum_partial(skb->data + ETH_HLEN, len - 
> ETH_HLEN, 0);
> +   if (csum != csum_fold(rsum) && net_ratelimit())
> +   pr_err("sungem wrong csum : %04x/%04x, len %u 
> bytes\n",
> +   csum, csum_fold(rsum), len);
> +   print_hex_dump(KERN_ERR, "raw data: ", 
> DUMP_PREFIX_OFFSET,


DUMP_PREFIX_ADDRESS might give us more information (say alignment problem, or 
crossing page boundaries)

> +   16, 1, skb->data, len, true);
> +   }
> skb->ip_summed = CHECKSUM_COMPLETE;
> skb->protocol = eth_type_trans(skb, gp->dev);
>  
> 


Re: [PATCH] powerpc: xmon: use ktime_get_coarse_boottime64

2018-06-18 Thread Balbir Singh
On Mon, Jun 18, 2018 at 7:56 PM, Arnd Bergmann  wrote:
> get_monotonic_boottime() is deprecated, and may not be safe to call in
> every context, as it has to read a hardware clocksource.
>
> This changes xmon to print the time using ktime_get_coarse_boottime64()
> instead, which avoids the old timespec type and the HW access.
>
> Signed-off-by: Arnd Bergmann 
> ---

Looks good to me!

Acked-by: Balbir Singh 

Balbir Singh


[PATCH 0/3] powernv/cpuidle Device-tree parsing cleanup

2018-06-18 Thread Akshay Adiga
Device-tree parsed multiple time in powernv cpuidle and powernv
hotplug code. 

First to identify supported flags, secondly, to identify deepest_state
and first deep state, Thirdly , during cpudidle init to find the available
idle states. Any change in device-tree format will lead to make changes in
these 3 places.

This series adds code to parse device tree once and save in global structure.

Akshay Adiga (3):
  powernv/cpuidle: Parse dt idle properties into global structure
  cpuidle/powernv: Change platform init to avoid reparsing dt
  powernv/cpuidle: Use parsed device tree values for cpuidle_init

 arch/powerpc/include/asm/cpuidle.h|  16 +++
 arch/powerpc/platforms/powernv/idle.c | 214 +-
 drivers/cpuidle/cpuidle-powernv.c |  49 +---
 3 files changed, 182 insertions(+), 97 deletions(-)

-- 
2.5.5



[PATCH 1/3] powernv/cpuidle: Parse dt idle properties into global structure

2018-06-18 Thread Akshay Adiga
Device-tree parsing happens in twice, once while deciding idle state to
be used for hotplug and once during cpuidle init. Hence, parsing the
device tree and caching it will reduce code duplication. Parsing code
has been moved to pnv_parse_cpuidle_dt() from pnv_probe_idle_states().

Setting up things so that number of available idle states can be
accessible to cpuidle-powernv driver. Hence adding nr_pnv_idle_states to
track number of idle states.

Signed-off-by: Akshay Adiga 
---
 arch/powerpc/include/asm/cpuidle.h|  14 +++
 arch/powerpc/platforms/powernv/idle.c | 197 --
 2 files changed, 152 insertions(+), 59 deletions(-)

diff --git a/arch/powerpc/include/asm/cpuidle.h 
b/arch/powerpc/include/asm/cpuidle.h
index e210a83..55ee7e3 100644
--- a/arch/powerpc/include/asm/cpuidle.h
+++ b/arch/powerpc/include/asm/cpuidle.h
@@ -79,6 +79,20 @@ struct stop_sprs {
u64 mmcra;
 };
 
+#define PNV_IDLE_NAME_LEN16
+struct pnv_idle_states_t {
+   char name[PNV_IDLE_NAME_LEN];
+   u32 latency_ns;
+   u32 residency_ns;
+   /*
+* Register value/mask used to select different idle states.
+* PMICR in POWER8 and PSSCR in POWER9
+*/
+   u64 pm_ctrl_reg_val;
+   u64 pm_ctrl_reg_mask;
+   u32 flags;
+};
+
 extern u32 pnv_fastsleep_workaround_at_entry[];
 extern u32 pnv_fastsleep_workaround_at_exit[];
 
diff --git a/arch/powerpc/platforms/powernv/idle.c 
b/arch/powerpc/platforms/powernv/idle.c
index 1c5d067..07be984 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -36,6 +36,8 @@
 #define P9_STOP_SPR_PSSCR  855
 
 static u32 supported_cpuidle_states;
+struct pnv_idle_states_t *pnv_idle_states;
+int nr_pnv_idle_states;
 
 /*
  * The default stop state that will be used by ppc_md.power_save
@@ -625,45 +627,8 @@ int validate_psscr_val_mask(u64 *psscr_val, u64 
*psscr_mask, u32 flags)
 static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
int dt_idle_states)
 {
-   u64 *psscr_val = NULL;
-   u64 *psscr_mask = NULL;
-   u32 *residency_ns = NULL;
u64 max_residency_ns = 0;
-   int rc = 0, i;
-
-   psscr_val = kcalloc(dt_idle_states, sizeof(*psscr_val), GFP_KERNEL);
-   psscr_mask = kcalloc(dt_idle_states, sizeof(*psscr_mask), GFP_KERNEL);
-   residency_ns = kcalloc(dt_idle_states, sizeof(*residency_ns),
-  GFP_KERNEL);
-
-   if (!psscr_val || !psscr_mask || !residency_ns) {
-   rc = -1;
-   goto out;
-   }
-
-   if (of_property_read_u64_array(np,
-   "ibm,cpu-idle-state-psscr",
-   psscr_val, dt_idle_states)) {
-   pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr in 
DT\n");
-   rc = -1;
-   goto out;
-   }
-
-   if (of_property_read_u64_array(np,
-  "ibm,cpu-idle-state-psscr-mask",
-  psscr_mask, dt_idle_states)) {
-   pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr-mask 
in DT\n");
-   rc = -1;
-   goto out;
-   }
-
-   if (of_property_read_u32_array(np,
-  "ibm,cpu-idle-state-residency-ns",
-   residency_ns, dt_idle_states)) {
-   pr_warn("cpuidle-powernv: missing 
ibm,cpu-idle-state-residency-ns in DT\n");
-   rc = -1;
-   goto out;
-   }
+   int i;
 
/*
 * Set pnv_first_deep_stop_state, pnv_deepest_stop_psscr_{val,mask},
@@ -681,31 +646,33 @@ static int __init pnv_power9_idle_init(struct device_node 
*np, u32 *flags,
pnv_first_deep_stop_state = MAX_STOP_STATE;
for (i = 0; i < dt_idle_states; i++) {
int err;
-   u64 psscr_rl = psscr_val[i] & PSSCR_RL_MASK;
+   struct pnv_idle_states_t *state = &pnv_idle_states[i];
+   u64 psscr_rl = state->pm_ctrl_reg_val & PSSCR_RL_MASK;
 
-   if ((flags[i] & OPAL_PM_LOSE_FULL_CONTEXT) &&
-(pnv_first_deep_stop_state > psscr_rl))
+   if ((state->flags & OPAL_PM_LOSE_FULL_CONTEXT) &&
+   (pnv_first_deep_stop_state > psscr_rl))
pnv_first_deep_stop_state = psscr_rl;
 
-   err = validate_psscr_val_mask(&psscr_val[i], &psscr_mask[i],
- flags[i]);
+   err = validate_psscr_val_mask(&state->pm_ctrl_reg_val,
+ &state->pm_ctrl_reg_mask,
+ state->flags);
if (err) {
-   report_invalid_psscr_val(psscr_val[i], err);
+   report_invalid_psscr_val(state->pm_ctrl_reg_val, err);
continue;
 

[PATCH 2/3] cpuidle/powernv: Change platform init to avoid reparsing dt

2018-06-18 Thread Akshay Adiga
The required data is accessible from cpuidle_states structure and
nr_cpu_idle_states. This patch makes changes to avoid reparsing and use
data from these structures.

Signed-off-by: Akshay Adiga 
---
 arch/powerpc/platforms/powernv/idle.c | 37 ---
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/idle.c 
b/arch/powerpc/platforms/powernv/idle.c
index 07be984..0a62611 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -624,8 +624,7 @@ int validate_psscr_val_mask(u64 *psscr_val, u64 
*psscr_mask, u32 flags)
  * @dt_idle_states: Number of idle state entries
  * Returns 0 on success
  */
-static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
-   int dt_idle_states)
+static int __init pnv_power9_idle_init(void)
 {
u64 max_residency_ns = 0;
int i;
@@ -644,7 +643,7 @@ static int __init pnv_power9_idle_init(struct device_node 
*np, u32 *flags,
 * the shallowest (OPAL_PM_STOP_INST_FAST) loss-less stop state.
 */
pnv_first_deep_stop_state = MAX_STOP_STATE;
-   for (i = 0; i < dt_idle_states; i++) {
+   for (i = 0; i < nr_pnv_idle_states; i++) {
int err;
struct pnv_idle_states_t *state = &pnv_idle_states[i];
u64 psscr_rl = state->pm_ctrl_reg_val & PSSCR_RL_MASK;
@@ -704,41 +703,21 @@ static int __init pnv_power9_idle_init(struct device_node 
*np, u32 *flags,
  */
 static void __init pnv_probe_idle_states(void)
 {
-   struct device_node *np;
-   int dt_idle_states;
-   u32 *flags = NULL;
int i;
 
-   np = of_find_node_by_path("/ibm,opal/power-mgt");
-   if (!np) {
-   pr_warn("opal: PowerMgmt Node not found\n");
-   goto out;
-   }
-   dt_idle_states = of_property_count_u32_elems(np,
-   "ibm,cpu-idle-state-flags");
-   if (dt_idle_states < 0) {
+   if (nr_pnv_idle_states < 0) {
pr_warn("cpuidle-powernv: no idle states found in the DT\n");
-   goto out;
-   }
-
-   flags = kcalloc(dt_idle_states, sizeof(*flags),  GFP_KERNEL);
-
-   if (of_property_read_u32_array(np,
-   "ibm,cpu-idle-state-flags", flags, dt_idle_states)) {
-   pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-flags in 
DT\n");
-   goto out;
+   return;
}
 
if (cpu_has_feature(CPU_FTR_ARCH_300)) {
-   if (pnv_power9_idle_init(np, flags, dt_idle_states))
-   goto out;
+   if (pnv_power9_idle_init())
+   return;
}
 
-   for (i = 0; i < dt_idle_states; i++)
-   supported_cpuidle_states |= flags[i];
+   for (i = 0; i < nr_pnv_idle_states; i++)
+   supported_cpuidle_states |= pnv_idle_states[i].flags;
 
-out:
-   kfree(flags);
 }
 
 /*
-- 
2.5.5



[PATCH 3/3] powernv/cpuidle: Use parsed device tree values for cpuidle_init

2018-06-18 Thread Akshay Adiga
Export pnv_idle_states and nr_pnv_idle_states so that its accessible to
cpuidle driver. Use properties from pnv_idle_states structure for powernv
cpuidle_init.

Signed-off-by: Akshay Adiga 
---
 arch/powerpc/include/asm/cpuidle.h |  2 ++
 drivers/cpuidle/cpuidle-powernv.c  | 49 +++---
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/include/asm/cpuidle.h 
b/arch/powerpc/include/asm/cpuidle.h
index 55ee7e3..1446747 100644
--- a/arch/powerpc/include/asm/cpuidle.h
+++ b/arch/powerpc/include/asm/cpuidle.h
@@ -93,6 +93,8 @@ struct pnv_idle_states_t {
u32 flags;
 };
 
+extern struct pnv_idle_states_t *pnv_idle_states;
+extern int nr_pnv_idle_states;
 extern u32 pnv_fastsleep_workaround_at_entry[];
 extern u32 pnv_fastsleep_workaround_at_exit[];
 
diff --git a/drivers/cpuidle/cpuidle-powernv.c 
b/drivers/cpuidle/cpuidle-powernv.c
index d29e4f0..de8ba26 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -285,6 +285,11 @@ static int powernv_add_idle_states(void)
goto out;
}
 
+   if (nr_pnv_idle_states <= 0) {
+   pr_warn("opal: No idle states found\n");
+   goto out;
+   }
+
/* Read values of any property to determine the num of idle states */
dt_idle_states = of_property_count_u32_elems(power_mgt, 
"ibm,cpu-idle-state-flags");
if (dt_idle_states < 0) {
@@ -338,7 +343,7 @@ static int powernv_add_idle_states(void)
 * If the idle states use stop instruction, probe for psscr values
 * and psscr mask which are necessary to specify required stop level.
 */
-   has_stop_states = (flags[0] &
+   has_stop_states = (pnv_idle_states[0].flags &
   (OPAL_PM_STOP_INST_FAST | OPAL_PM_STOP_INST_DEEP));
if (has_stop_states) {
count = of_property_count_u64_elems(power_mgt,
@@ -387,51 +392,55 @@ static int powernv_add_idle_states(void)
residency_ns, dt_idle_states);
}
 
-   for (i = 0; i < dt_idle_states; i++) {
+   for (i = 0; i < nr_pnv_idle_states; i++) {
unsigned int exit_latency, target_residency;
bool stops_timebase = false;
+   struct pnv_idle_states_t *state = &pnv_idle_states[i];
 
/*
 * Skip the platform idle state whose flag isn't in
-* the supported_cpuidle_states flag mask.
+* the supported_pnv_idle_states flag mask.
 */
-   if ((flags[i] & supported_flags) != flags[i])
+   if ((state->flags & supported_flags) !=
+   state->flags)
continue;
/*
 * If an idle state has exit latency beyond
 * POWERNV_THRESHOLD_LATENCY_NS then don't use it
 * in cpu-idle.
 */
-   if (latency_ns[i] > POWERNV_THRESHOLD_LATENCY_NS)
+   if (state->latency_ns > POWERNV_THRESHOLD_LATENCY_NS)
continue;
/*
 * Firmware passes residency and latency values in ns.
 * cpuidle expects it in us.
 */
-   exit_latency = DIV_ROUND_UP(latency_ns[i], 1000);
+   exit_latency = DIV_ROUND_UP(state->latency_ns, 1000);
if (!rc)
-   target_residency = DIV_ROUND_UP(residency_ns[i], 1000);
+   target_residency = DIV_ROUND_UP(state->residency_ns, 
1000);
else
target_residency = 0;
 
if (has_stop_states) {
-   int err = validate_psscr_val_mask(&psscr_val[i],
- &psscr_mask[i],
- flags[i]);
+   int err;
+   err = validate_psscr_val_mask(&state->pm_ctrl_reg_val,
+ &state->pm_ctrl_reg_mask,
+ state->flags);
if (err) {
-   report_invalid_psscr_val(psscr_val[i], err);
+   report_invalid_psscr_val(state->pm_ctrl_reg_val,
+err);
continue;
}
}
 
-   if (flags[i] & OPAL_PM_TIMEBASE_STOP)
+   if (state->flags & OPAL_PM_TIMEBASE_STOP)
stops_timebase = true;
 
/*
 * For nap and fastsleep, use default target_residency
 * values if f/w does not expose it.
 */
-   if (flags[i] & OPAL_PM_NAP_ENABLED) {
+   if (state->flags & OPAL_PM_

Re: [PATCH] misc: ocxl: Change return type for fault handler

2018-06-18 Thread Souptick Joarder
On Thu, Jun 14, 2018 at 9:36 PM, Frederic Barrat  wrote:
>
>
> Le 11/06/2018 à 22:29, Souptick Joarder a écrit :
>>
>> Use new return type vm_fault_t for fault handler. For
>> now, this is just documenting that the function returns
>> a VM_FAULT value rather than an errno. Once all instances
>> are converted, vm_fault_t will become a distinct type.
>>
>> Ref-> commit 1c8f422059ae ("mm: change return type to vm_fault_t")
>>
>> There is an existing bug when vm_insert_pfn() can return
>> ENOMEM which was ignored and VM_FAULT_NOPAGE returned as
>> default. The new inline vmf_insert_pfn() has removed
>> this inefficiency by returning correct vm_fault_ type.
>>
>> Signed-off-by: Souptick Joarder 
>> ---
>
>
> Thanks!
>
> Tested and
> Acked-by: Frederic Barrat 
>
>

Frederic, is this patch queued for 4.19 ?


Re: [PATCH 1/3] powerpc: mac: fix rtc read functions

2018-06-18 Thread Mathieu Malaterre
On Mon, Jun 18, 2018 at 10:04 PM Andreas Schwab  wrote:
>
> On Jun 18 2018, Mathieu Malaterre  wrote:
>
> > Sadly, trying again today does not work anymore. Adding some printk
> > just before WARN_ON:
> >
> > +printk(KERN_ERR " rtc DBG pmu_get_time1: %lld %d %lld \n", now,
> > RTC_OFFSET, now - RTC_OFFSET );
> > +printk(KERN_ERR " rtc DBG pmu_get_time2: %x %x %x %x %d \n",
> > req.reply[0], req.reply[1], req.reply[2], req.reply[3] ,
> > req.reply_len);
> >
> > leads to:
> >
> > [0.00]  rtc DBG pmu_get_time1: 14096662 2082844800 -2068748138
> > [0.00]  rtc DBG pmu_get_time2: 0 d7 19 16 4
>
> A good value would have 0xd7 in the first byte.  The problem is that
> pmu_set_rtc_time is also broken, and leads to an invalid time value
> stored in the RTC.  Since pmu_request is a varargs function passing
> values of type time64_t without casting won't work.
>
> You need to reset your RTC before you can continue.

Indeed that was silly, I was not paying attention. I'll try again tonight.

> I think the right fix is to change nowtime in pmu_set_rtc_time and
> cuda_set_rtc_time back to unsigned int (or to u32).
>
> Andreas.
>
> --
> Andreas Schwab, sch...@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."


Re: Build regressions/improvements in v4.18-rc1

2018-06-18 Thread Michael Ellerman
Geert Uytterhoeven  writes:
> On Mon, Jun 18, 2018 at 11:18 AM Geert Uytterhoeven
>  wrote:
>> Below is the list of build error/warning regressions/improvements in
>> v4.18-rc1[1] compared to v4.17[2].
>>
>> Summarized:
>>   - build errors: +11/-1
>
>> [1] 
>> http://kisskb.ellerman.id.au/kisskb/head/ce397d215ccd07b8ae3f71db689aedb85d56ab40/
>>  (233 out of 244 configs)
>> [2] 
>> http://kisskb.ellerman.id.au/kisskb/head/29dcea88779c856c7dc92040a0c01233263101d4/
>>  (all 244 configs)
>
>> 11 error regressions:
>>   + /kisskb/src/drivers/ata/pata_ali.c: error: implicit declaration of 
>> function 'pci_domain_nr' [-Werror=implicit-function-declaration]:  => 469:38
>
> sparc64/sparc-allmodconfig
>
>>   + /kisskb/src/mm/memblock.c: error: redefinition of 
>> 'memblock_virt_alloc_try_nid':  => 1413:15
>>   + /kisskb/src/mm/memblock.c: error: redefinition of 
>> 'memblock_virt_alloc_try_nid_nopanic':  => 1377:15
>>   + /kisskb/src/mm/memblock.c: error: redefinition of 
>> 'memblock_virt_alloc_try_nid_raw':  => 1340:15
>
> ia64/ia64-defconfig
> mips/bigsur_defconfig
> mips/cavium_octeon_defconfig
> mips/ip22_defconfig
> mips/ip27_defconfig
> mips/ip32_defconfig
> mips/malta_defconfig
> mips/mips-allmodconfig
> mips/mips-allnoconfig
> mips/mips-defconfig
> mipsel/mips-allmodconfig
> mipsel/mips-allnoconfig
> mipsel/mips-defconfig

These are now fixed in Linus' tree by:

  6cc22dc08a24 ("revert "mm/memblock: add missing include "")


>>   + error: ".radix__flush_pwc_lpid" [arch/powerpc/kvm/kvm-hv.ko] undefined!: 
>>  => N/A
>>   + error: ".radix__flush_tlb_lpid_page" [arch/powerpc/kvm/kvm-hv.ko] 
>> undefined!:  => N/A
>>   + error: ".radix__local_flush_tlb_lpid_guest" [arch/powerpc/kvm/kvm-hv.ko] 
>> undefined!:  => N/A
>>   + error: "radix__flush_pwc_lpid" [arch/powerpc/kvm/kvm-hv.ko] undefined!:  
>> => N/A
>>   + error: "radix__flush_tlb_lpid_page" [arch/powerpc/kvm/kvm-hv.ko] 
>> undefined!:  => N/A
>>   + error: "radix__local_flush_tlb_lpid_guest" [arch/powerpc/kvm/kvm-hv.ko] 
>> undefined!:  => N/A
>
> powerpc/ppc64_defconfig+NO_RADIX
> ppc64le/powernv_defconfig+NO_RADIX (what's in a name ;-)

Can you tell we don't test that combination very often :/


>>   + {standard input}: Error: offset to unaligned destination:  => 2268, 
>> 2316, 1691, 1362, 1455, 1598, 2502, 1645, 1988, 1927, 1409, 2615, 1548, 
>> 2409, 1268, 2363, 1314, 1208, 1785, 2034, , 2661, 1880, 2552, 1161, 
>> 2082, 1833, 2455, 2176, 2129, 1501, 1738
>
> sh4/sh-randconfig (doesn't seem to be a new issue, seen before on v4.12-rc3)

I think I'll disable that one, it's been broken more often that not and
I doubt anyone is that motivated to fix sh4 randconfig breakages?

  http://kisskb.ellerman.id.au/kisskb/target/1826/


Relatedly I might move all the randconfig targets from Linus' tree into
a separate "linus-rand" tree, so that they don't pollute the results, as
I've done for linux-next.

cheers


Re: Build regressions/improvements in v4.18-rc1

2018-06-18 Thread Geert Uytterhoeven
Hi Michael,

On Tue, Jun 19, 2018 at 8:35 AM Michael Ellerman  wrote:
> Geert Uytterhoeven  writes:
> > On Mon, Jun 18, 2018 at 11:18 AM Geert Uytterhoeven
> >  wrote:
> >> Below is the list of build error/warning regressions/improvements in
> >> v4.18-rc1[1] compared to v4.17[2].

> >>   + /kisskb/src/mm/memblock.c: error: redefinition of 
> >> 'memblock_virt_alloc_try_nid':  => 1413:15
> >>   + /kisskb/src/mm/memblock.c: error: redefinition of 
> >> 'memblock_virt_alloc_try_nid_nopanic':  => 1377:15
> >>   + /kisskb/src/mm/memblock.c: error: redefinition of 
> >> 'memblock_virt_alloc_try_nid_raw':  => 1340:15
> >
> > ia64/ia64-defconfig
> > mips/bigsur_defconfig
> > mips/cavium_octeon_defconfig
> > mips/ip22_defconfig
> > mips/ip27_defconfig
> > mips/ip32_defconfig
> > mips/malta_defconfig
> > mips/mips-allmodconfig
> > mips/mips-allnoconfig
> > mips/mips-defconfig
> > mipsel/mips-allmodconfig
> > mipsel/mips-allnoconfig
> > mipsel/mips-defconfig
>
> These are now fixed in Linus' tree by:
>
>   6cc22dc08a24 ("revert "mm/memblock: add missing include "")

Good.

> >>   + error: ".radix__flush_pwc_lpid" [arch/powerpc/kvm/kvm-hv.ko] 
> >> undefined!:  => N/A
> >>   + error: ".radix__flush_tlb_lpid_page" [arch/powerpc/kvm/kvm-hv.ko] 
> >> undefined!:  => N/A
> >>   + error: ".radix__local_flush_tlb_lpid_guest" 
> >> [arch/powerpc/kvm/kvm-hv.ko] undefined!:  => N/A
> >>   + error: "radix__flush_pwc_lpid" [arch/powerpc/kvm/kvm-hv.ko] 
> >> undefined!:  => N/A
> >>   + error: "radix__flush_tlb_lpid_page" [arch/powerpc/kvm/kvm-hv.ko] 
> >> undefined!:  => N/A
> >>   + error: "radix__local_flush_tlb_lpid_guest" 
> >> [arch/powerpc/kvm/kvm-hv.ko] undefined!:  => N/A
> >
> > powerpc/ppc64_defconfig+NO_RADIX
> > ppc64le/powernv_defconfig+NO_RADIX (what's in a name ;-)
>
> Can you tell we don't test that combination very often :/

That's why you have a special config for it? ;-)

> >>   + {standard input}: Error: offset to unaligned destination:  => 2268, 
> >> 2316, 1691, 1362, 1455, 1598, 2502, 1645, 1988, 1927, 1409, 2615, 1548, 
> >> 2409, 1268, 2363, 1314, 1208, 1785, 2034, , 2661, 1880, 2552, 1161, 
> >> 2082, 1833, 2455, 2176, 2129, 1501, 1738
> >
> > sh4/sh-randconfig (doesn't seem to be a new issue, seen before on v4.12-rc3)
>
> I think I'll disable that one, it's been broken more often that not and
> I doubt anyone is that motivated to fix sh4 randconfig breakages?

Probably not. Usually I ignore the commonly seen issues.
This one was more uncommon, so I kept it.

> Relatedly I might move all the randconfig targets from Linus' tree into
> a separate "linus-rand" tree, so that they don't pollute the results, as
> I've done for linux-next.

Sounds look a good thing.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds