[PATCH 4.4 36/37] sparc64: Delete now unused user copy assembler helpers.

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: "David S. Miller" 


[ Upstream commit 614da3d9685b67917cab48c8452fd8bf93de0867 ]

All of __ret{,l}_mone{_asi,_fp,_asi_fpu} are now unused.

Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/kernel/head_64.S |   30 --
 1 file changed, 30 deletions(-)

--- a/arch/sparc/kernel/head_64.S
+++ b/arch/sparc/kernel/head_64.S
@@ -927,36 +927,6 @@ ENTRY(__retl_efault)
 mov-EFAULT, %o0
 ENDPROC(__retl_efault)
 
-ENTRY(__retl_mone)
-   retl
-mov-1, %o0
-ENDPROC(__retl_mone)
-
-ENTRY(__retl_mone_fp)
-   VISExitHalf
-   retl
-mov1, %o0
-ENDPROC(__retl_mone_fp)
-
-ENTRY(__ret_mone_asi)
-   wr  %g0, ASI_AIUS, %asi
-   ret
-restore %g0, 1, %o0
-ENDPROC(__ret_mone_asi)
-
-ENTRY(__retl_mone_asi)
-   wr  %g0, ASI_AIUS, %asi
-   retl
-mov1, %o0
-ENDPROC(__retl_mone_asi)
-
-ENTRY(__retl_mone_asi_fp)
-   wr  %g0, ASI_AIUS, %asi
-   VISExitHalf
-   retl
-mov1, %o0
-ENDPROC(__retl_mone_asi_fp)
-
 ENTRY(__retl_o1)
retl
 mov%o1, %o0




[PATCH 4.4 37/37] sparc64: Delete now unused user copy fixup functions.

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: "David S. Miller" 


[ Upstream commit 0fd0ff01d4c3c01e7fe69b762ee1a13236639acc ]

Now that all of the user copy routines are converted to return
accurate residual lengths when an exception occurs, we no longer need
the broken fixup routines.

Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/include/asm/uaccess_64.h |   34 +
 arch/sparc/lib/Makefile |2 -
 arch/sparc/lib/user_fixup.c |   71 
 3 files changed, 4 insertions(+), 103 deletions(-)
 delete mode 100644 arch/sparc/lib/user_fixup.c

--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -204,58 +204,30 @@ int __get_user_bad(void);
 unsigned long __must_check ___copy_from_user(void *to,
 const void __user *from,
 unsigned long size);
-unsigned long copy_from_user_fixup(void *to, const void __user *from,
-  unsigned long size);
 static inline unsigned long __must_check
 copy_from_user(void *to, const void __user *from, unsigned long size)
 {
-   unsigned long ret = ___copy_from_user(to, from, size);
-
-   if (unlikely(ret)) {
-   if ((long)ret < 0)
-   ret = copy_from_user_fixup(to, from, size);
-   return ret;
-   }
-
-   return ret;
+   return ___copy_from_user(to, from, size);
 }
 #define __copy_from_user copy_from_user
 
 unsigned long __must_check ___copy_to_user(void __user *to,
   const void *from,
   unsigned long size);
-unsigned long copy_to_user_fixup(void __user *to, const void *from,
-unsigned long size);
 static inline unsigned long __must_check
 copy_to_user(void __user *to, const void *from, unsigned long size)
 {
-   unsigned long ret = ___copy_to_user(to, from, size);
-
-   if (unlikely(ret)) {
-   if ((long)ret < 0)
-   ret = copy_to_user_fixup(to, from, size);
-   return ret;
-   }
-   return ret;
+   return ___copy_to_user(to, from, size);
 }
 #define __copy_to_user copy_to_user
 
 unsigned long __must_check ___copy_in_user(void __user *to,
   const void __user *from,
   unsigned long size);
-unsigned long copy_in_user_fixup(void __user *to, void __user *from,
-unsigned long size);
 static inline unsigned long __must_check
 copy_in_user(void __user *to, void __user *from, unsigned long size)
 {
-   unsigned long ret = ___copy_in_user(to, from, size);
-
-   if (unlikely(ret)) {
-   if ((long)ret < 0)
-   ret = copy_in_user_fixup(to, from, size);
-   return ret;
-   }
-   return ret;
+   return ___copy_in_user(to, from, size);
 }
 #define __copy_in_user copy_in_user
 
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -38,7 +38,7 @@ lib-$(CONFIG_SPARC64) +=  NG4patch.o NG4
 lib-$(CONFIG_SPARC64) += GENmemcpy.o GENcopy_from_user.o GENcopy_to_user.o
 lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o
 
-lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o
+lib-$(CONFIG_SPARC64) += copy_in_user.o memmove.o
 lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
 
 obj-$(CONFIG_SPARC64) += iomap.o
--- a/arch/sparc/lib/user_fixup.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* user_fixup.c: Fix up user copy faults.
- *
- * Copyright (C) 2004 David S. Miller 
- */
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-
-/* Calculating the exact fault address when using
- * block loads and stores can be very complicated.
- *
- * Instead of trying to be clever and handling all
- * of the cases, just fix things up simply here.
- */
-
-static unsigned long compute_size(unsigned long start, unsigned long size, 
unsigned long *offset)
-{
-   unsigned long fault_addr = current_thread_info()->fault_address;
-   unsigned long end = start + size;
-
-   if (fault_addr < start || fault_addr >= end) {
-   *offset = 0;
-   } else {
-   *offset = fault_addr - start;
-   size = end - fault_addr;
-   }
-   return size;
-}
-
-unsigned long copy_from_user_fixup(void *to, const void __user *from, unsigned 
long size)
-{
-   unsigned long offset;
-
-   size = compute_size((unsigned long) from, size, );
-   if (likely(size))
-   memset(to + offset, 0, size);
-
-   return size;
-}
-EXPORT_SYMBOL(copy_from_user_fixup);
-
-unsigned long copy_to_user_fixup(void __user *to, const 

[PATCH 4.4 26/37] sparc64: Handle extremely large kernel TLB range flushes more gracefully.

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: "David S. Miller" 


[ Upstream commit a74ad5e660a9ee1d071665e7e8ad822784a2dc7f ]

When the vmalloc area gets fragmented, and because the firmware
mapping area sits between where modules live and the vmalloc area, we
can sometimes receive requests for enormous kernel TLB range flushes.

When this happens the cpu just spins flushing billions of pages and
this triggers the NMI watchdog and other problems.

We took care of this on the TSB side by doing a linear scan of the
table once we pass a certain threshold.

Do something similar for the TLB flush, however we are limited by
the TLB flush facilities provided by the different chip variants.

First of all we use an (mostly arbitrary) cut-off of 256K which is
about 32 pages.  This can be tuned in the future.

The huge range code path for each chip works as follows:

1) On spitfire we flush all non-locked TLB entries using diagnostic
   acceses.

2) On cheetah we use the "flush all" TLB flush.

3) On sun4v/hypervisor we do a TLB context flush on context 0, which
   unlike previous chips does not remove "permanent" or locked
   entries.

We could probably do something better on spitfire, such as limiting
the flush to kernel TLB entries or even doing range comparisons.
However that probably isn't worth it since those chips are old and
the TLB only had 64 entries.

Reported-by: James Clarke 
Tested-by: James Clarke 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/mm/ultra.S |  283 --
 1 file changed, 228 insertions(+), 55 deletions(-)

--- a/arch/sparc/mm/ultra.S
+++ b/arch/sparc/mm/ultra.S
@@ -113,12 +113,14 @@ __flush_tlb_pending:  /* 27 insns */
 
.align  32
.globl  __flush_tlb_kernel_range
-__flush_tlb_kernel_range:  /* 19 insns */
+__flush_tlb_kernel_range:  /* 31 insns */
/* %o0=start, %o1=end */
cmp %o0, %o1
be,pn   %xcc, 2f
+sub%o1, %o0, %o3
+   srlx%o3, 18, %o4
+   brnz,pn %o4, __spitfire_flush_tlb_kernel_range_slow
 sethi  %hi(PAGE_SIZE), %o4
-   sub %o1, %o0, %o3
sub %o3, %o4, %o3
or  %o0, 0x20, %o0  ! Nucleus
 1: stxa%g0, [%o0 + %o3] ASI_DMMU_DEMAP
@@ -134,6 +136,38 @@ __flush_tlb_kernel_range:  /* 19 insns */
nop
nop
nop
+   nop
+   nop
+   nop
+   nop
+   nop
+   nop
+   nop
+   nop
+   nop
+   nop
+
+__spitfire_flush_tlb_kernel_range_slow:
+   mov 63 * 8, %o4
+1: ldxa[%o4] ASI_ITLB_DATA_ACCESS, %o3
+   andcc   %o3, 0x40, %g0  /* _PAGE_L_4U */
+   bne,pn  %xcc, 2f
+movTLB_TAG_ACCESS, %o3
+   stxa%g0, [%o3] ASI_IMMU
+   stxa%g0, [%o4] ASI_ITLB_DATA_ACCESS
+   membar  #Sync
+2: ldxa[%o4] ASI_DTLB_DATA_ACCESS, %o3
+   andcc   %o3, 0x40, %g0
+   bne,pn  %xcc, 2f
+movTLB_TAG_ACCESS, %o3
+   stxa%g0, [%o3] ASI_DMMU
+   stxa%g0, [%o4] ASI_DTLB_DATA_ACCESS
+   membar  #Sync
+2: sub %o4, 8, %o4
+   brgez,pt%o4, 1b
+nop
+   retl
+nop
 
 __spitfire_flush_tlb_mm_slow:
rdpr%pstate, %g1
@@ -288,6 +322,40 @@ __cheetah_flush_tlb_pending:   /* 27 insns
retl
 wrpr   %g7, 0x0, %pstate
 
+__cheetah_flush_tlb_kernel_range:  /* 31 insns */
+   /* %o0=start, %o1=end */
+   cmp %o0, %o1
+   be,pn   %xcc, 2f
+sub%o1, %o0, %o3
+   srlx%o3, 18, %o4
+   brnz,pn %o4, 3f
+sethi  %hi(PAGE_SIZE), %o4
+   sub %o3, %o4, %o3
+   or  %o0, 0x20, %o0  ! Nucleus
+1: stxa%g0, [%o0 + %o3] ASI_DMMU_DEMAP
+   stxa%g0, [%o0 + %o3] ASI_IMMU_DEMAP
+   membar  #Sync
+   brnz,pt %o3, 1b
+sub%o3, %o4, %o3
+2: sethi   %hi(KERNBASE), %o3
+   flush   %o3
+   retl
+nop
+3: mov 0x80, %o4
+   stxa%g0, [%o4] ASI_DMMU_DEMAP
+   membar  #Sync
+   stxa%g0, [%o4] ASI_IMMU_DEMAP
+   membar  #Sync
+   retl
+nop
+   nop
+   nop
+   nop
+   nop
+   nop
+   nop
+   nop
+
 #ifdef DCACHE_ALIASING_POSSIBLE
 __cheetah_flush_dcache_page: /* 11 insns */
sethi   %hi(PAGE_OFFSET), %g1
@@ -388,13 +456,15 @@ __hypervisor_flush_tlb_pending: 

[PATCH 4.4 29/37] sparc64: Convert copy_in_user to accurate exception reporting.

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: "David S. Miller" 


[ Upstream commit 0096ac9f47b1a2e851b3165d44065d18e5f13d58 ]

Report the exact number of bytes which have not been successfully
copied when an exception occurs, using the running remaining length.

Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/lib/copy_in_user.S |   35 +--
 1 file changed, 25 insertions(+), 10 deletions(-)

--- a/arch/sparc/lib/copy_in_user.S
+++ b/arch/sparc/lib/copy_in_user.S
@@ -8,18 +8,33 @@
 
 #define XCC xcc
 
-#define EX(x,y)\
+#define EX(x,y,z)  \
 98:x,y;\
.section __ex_table,"a";\
.align 4;   \
-   .word 98b, __retl_mone; \
+   .word 98b, z;   \
.text;  \
.align 4;
 
+#define EX_O4(x,y) EX(x,y,__retl_o4_plus_8)
+#define EX_O2_4(x,y) EX(x,y,__retl_o2_plus_4)
+#define EX_O2_1(x,y) EX(x,y,__retl_o2_plus_1)
+
.register   %g2,#scratch
.register   %g3,#scratch
 
.text
+__retl_o4_plus_8:
+   add %o4, %o2, %o4
+   retl
+add%o4, 8, %o0
+__retl_o2_plus_4:
+   retl
+add%o2, 4, %o0
+__retl_o2_plus_1:
+   retl
+add%o2, 1, %o0
+
.align  32
 
/* Don't try to get too fancy here, just nice and
@@ -44,8 +59,8 @@ ENTRY(___copy_in_user)/* %o0=dst, %o1=s
andn%o2, 0x7, %o4
and %o2, 0x7, %o2
 1: subcc   %o4, 0x8, %o4
-   EX(ldxa [%o1] %asi, %o5)
-   EX(stxa %o5, [%o0] %asi)
+   EX_O4(ldxa [%o1] %asi, %o5)
+   EX_O4(stxa %o5, [%o0] %asi)
add %o1, 0x8, %o1
bgu,pt  %XCC, 1b
 add%o0, 0x8, %o0
@@ -53,8 +68,8 @@ ENTRY(___copy_in_user)/* %o0=dst, %o1=s
be,pt   %XCC, 1f
 nop
sub %o2, 0x4, %o2
-   EX(lduwa [%o1] %asi, %o5)
-   EX(stwa %o5, [%o0] %asi)
+   EX_O2_4(lduwa [%o1] %asi, %o5)
+   EX_O2_4(stwa %o5, [%o0] %asi)
add %o1, 0x4, %o1
add %o0, 0x4, %o0
 1: cmp %o2, 0
@@ -70,8 +85,8 @@ ENTRY(___copy_in_user)/* %o0=dst, %o1=s
 
 82:
subcc   %o2, 4, %o2
-   EX(lduwa [%o1] %asi, %g1)
-   EX(stwa %g1, [%o0] %asi)
+   EX_O2_4(lduwa [%o1] %asi, %g1)
+   EX_O2_4(stwa %g1, [%o0] %asi)
add %o1, 4, %o1
bgu,pt  %XCC, 82b
 add%o0, 4, %o0
@@ -82,8 +97,8 @@ ENTRY(___copy_in_user)/* %o0=dst, %o1=s
.align  32
 90:
subcc   %o2, 1, %o2
-   EX(lduba [%o1] %asi, %g1)
-   EX(stba %g1, [%o0] %asi)
+   EX_O2_1(lduba [%o1] %asi, %g1)
+   EX_O2_1(stba %g1, [%o0] %asi)
add %o1, 1, %o1
bgu,pt  %XCC, 90b
 add%o0, 1, %o0




[PATCH 4.4 34/37] sparc64: Convert NG2copy_{from,to}_user to accurate exception reporting.

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: "David S. Miller" 


[ Upstream commit e93704e4464fdc191f73fce35129c18de2ebf95d ]

Report the exact number of bytes which have not been successfully
copied when an exception occurs, using the running remaining length.

Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/lib/NG2copy_from_user.S |8 -
 arch/sparc/lib/NG2copy_to_user.S   |8 -
 arch/sparc/lib/NG2memcpy.S |  228 +++--
 3 files changed, 153 insertions(+), 91 deletions(-)

--- a/arch/sparc/lib/NG2copy_from_user.S
+++ b/arch/sparc/lib/NG2copy_from_user.S
@@ -3,19 +3,19 @@
  * Copyright (C) 2007 David S. Miller (da...@davemloft.net)
  */
 
-#define EX_LD(x)   \
+#define EX_LD(x,y) \
 98:x;  \
.section __ex_table,"a";\
.align 4;   \
-   .word 98b, __retl_mone_asi;\
+   .word 98b, y;   \
.text;  \
.align 4;
 
-#define EX_LD_FP(x)\
+#define EX_LD_FP(x,y)  \
 98:x;  \
.section __ex_table,"a";\
.align 4;   \
-   .word 98b, __retl_mone_asi_fp;\
+   .word 98b, y##_fp;  \
.text;  \
.align 4;
 
--- a/arch/sparc/lib/NG2copy_to_user.S
+++ b/arch/sparc/lib/NG2copy_to_user.S
@@ -3,19 +3,19 @@
  * Copyright (C) 2007 David S. Miller (da...@davemloft.net)
  */
 
-#define EX_ST(x)   \
+#define EX_ST(x,y) \
 98:x;  \
.section __ex_table,"a";\
.align 4;   \
-   .word 98b, __retl_mone_asi;\
+   .word 98b, y;   \
.text;  \
.align 4;
 
-#define EX_ST_FP(x)\
+#define EX_ST_FP(x,y)  \
 98:x;  \
.section __ex_table,"a";\
.align 4;   \
-   .word 98b, __retl_mone_asi_fp;\
+   .word 98b, y##_fp;  \
.text;  \
.align 4;
 
--- a/arch/sparc/lib/NG2memcpy.S
+++ b/arch/sparc/lib/NG2memcpy.S
@@ -4,6 +4,7 @@
  */
 
 #ifdef __KERNEL__
+#include 
 #include 
 #include 
 #define GLOBAL_SPARE   %g7
@@ -32,21 +33,17 @@
 #endif
 
 #ifndef EX_LD
-#define EX_LD(x)   x
+#define EX_LD(x,y) x
 #endif
 #ifndef EX_LD_FP
-#define EX_LD_FP(x)x
+#define EX_LD_FP(x,y)  x
 #endif
 
 #ifndef EX_ST
-#define EX_ST(x)   x
+#define EX_ST(x,y) x
 #endif
 #ifndef EX_ST_FP
-#define EX_ST_FP(x)x
-#endif
-
-#ifndef EX_RETVAL
-#define EX_RETVAL(x)   x
+#define EX_ST_FP(x,y)  x
 #endif
 
 #ifndef LOAD
@@ -140,45 +137,110 @@
fsrc2   %x6, %f12; \
fsrc2   %x7, %f14;
 #define FREG_LOAD_1(base, x0) \
-   EX_LD_FP(LOAD(ldd, base + 0x00, %x0))
+   EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1)
 #define FREG_LOAD_2(base, x0, x1) \
-   EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
-   EX_LD_FP(LOAD(ldd, base + 0x08, %x1));
+   EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1);
 #define FREG_LOAD_3(base, x0, x1, x2) \
-   EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
-   EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
-   EX_LD_FP(LOAD(ldd, base + 0x10, %x2));
+   EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1);
 #define FREG_LOAD_4(base, x0, x1, x2, x3) \
-   EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
-   EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
-   EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \
-   EX_LD_FP(LOAD(ldd, base + 0x18, %x3));
+   EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1);
 #define FREG_LOAD_5(base, x0, x1, x2, x3, x4) \
-   EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
-   EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \
-   EX_LD_FP(LOAD(ldd, base + 0x10, %x2)); \
-   EX_LD_FP(LOAD(ldd, base + 0x18, %x3)); \
-   EX_LD_FP(LOAD(ldd, base + 0x20, %x4));
+   EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
+   EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1);
 #define FREG_LOAD_6(base, x0, x1, x2, x3, x4, x5) \
-   EX_LD_FP(LOAD(ldd, base + 0x00, %x0)); \
-   EX_LD_FP(LOAD(ldd, base + 0x08, %x1)); \

[PATCH 4.4 04/37] bgmac: stop clearing DMA receive control register right after it is set

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Andy Gospodarek 


[ Upstream commit fcdefccac976ee51dd6071832b842d8fb41c479c ]

Current bgmac code initializes some DMA settings in the receive control
register for some hardware and then immediately clears those settings.
Not clearing those settings results in ~420Mbps *improvement* in
throughput; this system can now receive frames at line-rate on Broadcom
5871x hardware compared to ~520Mbps today.  I also tested a few other
values but found there to be no discernible difference in CPU
utilization even if burst size and prefetching values are different.

On the hardware tested there was no need to keep the code that cleared
all but bits 16-17, but since there is a wide variety of hardware that
used this driver (I did not look at all hardware docs for hardware using
this IP block), I find it wise to move this call up and clear bits just
after reading the default value from the hardware rather than completely
removing it.

This is a good candidate for -stable >=3.14 since that is when the code
that was supposed to improve performance (but did not) was introduced.

Signed-off-by: Andy Gospodarek 
Fixes: 56ceecde1f29 ("bgmac: initialize the DMA controller of core...")
Cc: Hauke Mehrtens 
Acked-by: Hauke Mehrtens 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/broadcom/bgmac.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -314,6 +314,10 @@ static void bgmac_dma_rx_enable(struct b
u32 ctl;
 
ctl = bgmac_read(bgmac, ring->mmio_base + BGMAC_DMA_RX_CTL);
+
+   /* preserve ONLY bits 16-17 from current hardware value */
+   ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
+
if (bgmac->core->id.rev >= 4) {
ctl &= ~BGMAC_DMA_RX_BL_MASK;
ctl |= BGMAC_DMA_RX_BL_128 << BGMAC_DMA_RX_BL_SHIFT;
@@ -324,7 +328,6 @@ static void bgmac_dma_rx_enable(struct b
ctl &= ~BGMAC_DMA_RX_PT_MASK;
ctl |= BGMAC_DMA_RX_PT_1 << BGMAC_DMA_RX_PT_SHIFT;
}
-   ctl &= BGMAC_DMA_RX_ADDREXT_MASK;
ctl |= BGMAC_DMA_RX_ENABLE;
ctl |= BGMAC_DMA_RX_PARITY_DISABLE;
ctl |= BGMAC_DMA_RX_OVERFLOW_CONT;




[PATCH 4.4 08/37] dccp: fix out of bound access in dccp_v4_err()

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Eric Dumazet 


[ Upstream commit 6706a97fec963d6cb3f7fc2978ec1427b4651214 ]

dccp_v4_err() does not use pskb_may_pull() and might access garbage.

We only need 4 bytes at the beginning of the DCCP header, like TCP,
so the 8 bytes pulled in icmp_socket_deliver() are more than enough.

This patch might allow to process more ICMP messages, as some routers
are still limiting the size of reflected bytes to 28 (RFC 792), instead
of extended lengths (RFC 1812 4.3.2.3)

Signed-off-by: Eric Dumazet 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/dccp/ipv4.c |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -235,7 +235,7 @@ static void dccp_v4_err(struct sk_buff *
 {
const struct iphdr *iph = (struct iphdr *)skb->data;
const u8 offset = iph->ihl << 2;
-   const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
+   const struct dccp_hdr *dh;
struct dccp_sock *dp;
struct inet_sock *inet;
const int type = icmp_hdr(skb)->type;
@@ -245,11 +245,13 @@ static void dccp_v4_err(struct sk_buff *
int err;
struct net *net = dev_net(skb->dev);
 
-   if (skb->len < offset + sizeof(*dh) ||
-   skb->len < offset + __dccp_basic_hdr_len(dh)) {
-   ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS);
-   return;
-   }
+   /* Only need dccph_dport & dccph_sport which are the first
+* 4 bytes in dccp header.
+* Our caller (icmp_socket_deliver()) already pulled 8 bytes for us.
+*/
+   BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_sport) > 8);
+   BUILD_BUG_ON(offsetofend(struct dccp_hdr, dccph_dport) > 8);
+   dh = (struct dccp_hdr *)(skb->data + offset);
 
sk = __inet_lookup_established(net, _hashinfo,
   iph->daddr, dh->dccph_dport,




[PATCH 4.4 01/37] dctcp: avoid bogus doubling of cwnd after loss

2016-11-19 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Florian Westphal 


[ Upstream commit ce6dd23329b1ee6a794acf5f7e40f8e89b8317ee ]

If a congestion control module doesn't provide .undo_cwnd function,
tcp_undo_cwnd_reduction() will set cwnd to

   tp->snd_cwnd = max(tp->snd_cwnd, tp->snd_ssthresh << 1);

... which makes sense for reno (it sets ssthresh to half the current cwnd),
but it makes no sense for dctcp, which sets ssthresh based on the current
congestion estimate.

This can cause severe growth of cwnd (eventually overflowing u32).

Fix this by saving last cwnd on loss and restore cwnd based on that,
similar to cubic and other algorithms.

Fixes: e3118e8359bb7c ("net: tcp: add DCTCP congestion control algorithm")
Cc: Lawrence Brakmo 
Cc: Andrew Shewmaker 
Cc: Glenn Judd 
Acked-by: Daniel Borkmann 
Signed-off-by: Florian Westphal 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 
---
 net/ipv4/tcp_dctcp.c |   13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

--- a/net/ipv4/tcp_dctcp.c
+++ b/net/ipv4/tcp_dctcp.c
@@ -56,6 +56,7 @@ struct dctcp {
u32 next_seq;
u32 ce_state;
u32 delayed_ack_reserved;
+   u32 loss_cwnd;
 };
 
 static unsigned int dctcp_shift_g __read_mostly = 4; /* g = 1/2^4 */
@@ -96,6 +97,7 @@ static void dctcp_init(struct sock *sk)
ca->dctcp_alpha = min(dctcp_alpha_on_init, DCTCP_MAX_ALPHA);
 
ca->delayed_ack_reserved = 0;
+   ca->loss_cwnd = 0;
ca->ce_state = 0;
 
dctcp_reset(tp, ca);
@@ -111,9 +113,10 @@ static void dctcp_init(struct sock *sk)
 
 static u32 dctcp_ssthresh(struct sock *sk)
 {
-   const struct dctcp *ca = inet_csk_ca(sk);
+   struct dctcp *ca = inet_csk_ca(sk);
struct tcp_sock *tp = tcp_sk(sk);
 
+   ca->loss_cwnd = tp->snd_cwnd;
return max(tp->snd_cwnd - ((tp->snd_cwnd * ca->dctcp_alpha) >> 11U), 
2U);
 }
 
@@ -308,12 +311,20 @@ static size_t dctcp_get_info(struct sock
return 0;
 }
 
+static u32 dctcp_cwnd_undo(struct sock *sk)
+{
+   const struct dctcp *ca = inet_csk_ca(sk);
+
+   return max(tcp_sk(sk)->snd_cwnd, ca->loss_cwnd);
+}
+
 static struct tcp_congestion_ops dctcp __read_mostly = {
.init   = dctcp_init,
.in_ack_event   = dctcp_update_alpha,
.cwnd_event = dctcp_cwnd_event,
.ssthresh   = dctcp_ssthresh,
.cong_avoid = tcp_reno_cong_avoid,
+   .undo_cwnd  = dctcp_cwnd_undo,
.set_state  = dctcp_state,
.get_info   = dctcp_get_info,
.flags  = TCP_CONG_NEEDS_ECN,




[PATCH] staging: iio: ad9832:

2016-11-19 Thread Christophe JAILLET
Commit a98461d79ba5 ("staging: iio: ad9832: add DVDD regulator") and
commit 43a07e48af44 ("staging: iio: ad9832: clean-up regulator 'reg'") add
some dereference of 'st' which is an un-initialized pointer at this point.

Re-order code and tweak error handling in order to allocate memory and have
'st' be a valid pointer before using it.

Fixes: a98461d79ba5 ("staging: iio: ad9832: add DVDD regulator")
Fixes: 43a07e48af44 ("staging: iio: ad9832: clean-up regulator 'reg'")

Signed-off-by: Christophe JAILLET 
---
Compile tested only
---
 drivers/staging/iio/frequency/ad9832.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/iio/frequency/ad9832.c 
b/drivers/staging/iio/frequency/ad9832.c
index 639047fade30..16894836f982 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -211,6 +211,15 @@ static int ad9832_probe(struct spi_device *spi)
return -ENODEV;
}
 
+   indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
+   if (!indio_dev)
+   return -ENOMEM;
+
+   spi_set_drvdata(spi, indio_dev);
+   st = iio_priv(indio_dev);
+   st->mclk = pdata->mclk;
+   st->spi = spi;
+
st->avdd = devm_regulator_get(>dev, "avdd");
if (IS_ERR(st->avdd))
return PTR_ERR(st->avdd);
@@ -233,16 +242,6 @@ static int ad9832_probe(struct spi_device *spi)
goto error_disable_avdd;
}
 
-   indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
-   if (!indio_dev) {
-   ret = -ENOMEM;
-   goto error_disable_dvdd;
-   }
-   spi_set_drvdata(spi, indio_dev);
-   st = iio_priv(indio_dev);
-   st->mclk = pdata->mclk;
-   st->spi = spi;
-
indio_dev->dev.parent = >dev;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->info = _info;
-- 
2.9.3



Re: [PATCH v5 7/7] iommu/exynos: Use device dependency links to control runtime pm

2016-11-19 Thread Lukas Wunner
On Tue, Nov 08, 2016 at 08:27:12AM +0100, Marek Szyprowski wrote:
> On 2016-11-07 22:47, Luis R. Rodriguez wrote:
> > If so
> > why? If this issue is present also on systems that only use ACPI is
> > this possibly due to an ACPI firmware bug  or the lack of some semantics
> > in ACPI to express ordering in a better way? If the issue is device
> > tree related only is this due to the lack of semantics in device tree
> > to express some more complex dependency ?
> 
> The main feature of device links that is used in this patch is enabling
> runtime pm dependency between Exynos SYSMMU controller (called it client
> device) and the device, for which it implements DMA address translation
> (called master device). The assumptions are following:
> 1. master device driver is completely unaware of the Exynos SYSMMU presence,
>IOMMU is transparently hooked up and managed by DMA-mapping framework
> 2. SYSMMU belongs to the same power domain as it's master device
> 3. SYSMMU is optional, master device can fully operate without it, with
>simple DMA address translation (DMA address == physical address)
> 4. Master device implements runtime pm, what in turn causes respective
>power domain to be turned on/off
> 5. DMA-mapping and IOMMU frameworks provides no calls to notify SYSMMU
>when its master device is performing DMA operations, so SYSMMU has
>to be runtime active
> 6. Currently SYSMMU always sets its runtime pm status to active after
>attaching to its master device to ensure proper hardware state. This
>prevents power domain to be turned off, even when master device sets
>its runtime pm status to suspended.
> 7. Exynos SYSMMU has to be runtime active at the same time when its
>master device is runtime active to it to perform DMA operations and
>allow the power domain to be turned off, when master device is
>runtime suspended.
> 8. The terms of device links, Exynos SYSMMU is a 'consumer' and master
>device is a 'supplier'.

You seem to have mixed up the consumer and supplier in point 8 above.
Your code is such that the SYSMMU is the supplier and the master device
is the consumer:

device_link_add(dev, data->sysmmu, DL_FLAG_PM_RUNTIME);

Prototype of device_link_add:

struct device_link *device_link_add(struct device *consumer,
struct device *supplier,
u32 flags);

Your code is correct, only point 8 above is wrong.

Best regards,

Lukas


Re: [PATCH v3 1/6] Documentation: dt-bindings: Document STM32 ADC DT bindings

2016-11-19 Thread Jonathan Cameron
On 16/11/16 15:15, Rob Herring wrote:
> On Tue, Nov 15, 2016 at 04:30:56PM +0100, Fabrice Gasnier wrote:
>> This patch adds documentation of device tree bindings for the STM32 ADC.
>>
>> Signed-off-by: Fabrice Gasnier 
>> ---
>>  .../devicetree/bindings/iio/adc/st,stm32-adc.txt   | 83 
>> ++
>>  1 file changed, 83 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt
> 
> Acked-by: Rob Herring 
Applied to the togreg branch of iio.git.

Thanks,

Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



Re: [RFC][PATCH 7/7] kref: Implement using refcount_t

2016-11-19 Thread Peter Zijlstra
On Sat, Nov 19, 2016 at 07:14:08AM +, Reshetova, Elena wrote:
> > Well, if you get to tools (cocci script or whatever) to reliably work
> > fork atomic_t, then converting the few atomic_long_t's later should be
> > trivial.
> 
> I am using coccinelle to find all occurrences, but I do the changes
> only in semi-automated fashion.

If you can get the detection solid, that's good enough.

> Each change needs a proper manual review anyway and often one variable
> usage is spread between different headers/source files, so I prefer
> not to go to full automation and then not being sure what I have done.

Sure, every patch needs review, regardless of how it came to be.


Re: [HMM v13 16/18] mm/hmm/migrate: new memory migration helper for use with device memory

2016-11-19 Thread Aneesh Kumar K.V
Jérôme Glisse  writes:

> This patch add a new memory migration helpers, which migrate memory
> backing a range of virtual address of a process to different memory
> (which can be allocated through special allocator). It differs from
> numa migration by working on a range of virtual address and thus by
> doing migration in chunk that can be large enough to use DMA engine
> or special copy offloading engine.
>
> Expected users are any one with heterogeneous memory where different
> memory have different characteristics (latency, bandwidth, ...). As
> an example IBM platform with CAPI bus can make use of this feature
> to migrate between regular memory and CAPI device memory. New CPU
> architecture with a pool of high performance memory not manage as
> cache but presented as regular memory (while being faster and with
> lower latency than DDR) will also be prime user of this patch.
>
> Migration to private device memory will be usefull for device that
> have large pool of such like GPU, NVidia plans to use HMM for that.
>
> Signed-off-by: Jérôme Glisse 
> Signed-off-by: Jatin Kumar 
> Signed-off-by: John Hubbard 
> Signed-off-by: Mark Hairgrove 
> Signed-off-by: Sherry Cheung 
> Signed-off-by: Subhash Gutti 
> ---
>  include/linux/hmm.h |  54 -
>  mm/migrate.c| 584 
> 
>  2 files changed, 635 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/hmm.h b/include/linux/hmm.h
> index c79abfc..9777309 100644
> --- a/include/linux/hmm.h
> +++ b/include/linux/hmm.h
> @@ -101,10 +101,13 @@ struct hmm;
>   * HMM_PFN_EMPTY: corresponding CPU page table entry is none (pte_none() 
> true)
>   * HMM_PFN_FAULT: use by hmm_vma_fault() to signify which address need 
> faulting
>   * HMM_PFN_DEVICE: this is device memory (ie a ZONE_DEVICE page)
> + * HMM_PFN_LOCKED: underlying struct page is lock
>   * HMM_PFN_SPECIAL: corresponding CPU page table entry is special ie result 
> of
>   *  vm_insert_pfn() or vm_insert_page() and thus should not be mirror by 
> a
>   *  device (the entry will never have HMM_PFN_VALID set and the pfn value
>   *  is undefine)
> + * HMM_PFN_MIGRATE: use by hmm_vma_migrate() to signify which address can be
> + *  migrated
>   * HMM_PFN_UNADDRESSABLE: unaddressable device memory (ZONE_DEVICE)
>   */
>  typedef unsigned long hmm_pfn_t;
> @@ -116,9 +119,11 @@ typedef unsigned long hmm_pfn_t;
>  #define HMM_PFN_EMPTY (1 << 4)
>  #define HMM_PFN_FAULT (1 << 5)
>  #define HMM_PFN_DEVICE (1 << 6)
> -#define HMM_PFN_SPECIAL (1 << 7)
> -#define HMM_PFN_UNADDRESSABLE (1 << 8)
> -#define HMM_PFN_SHIFT 9
> +#define HMM_PFN_LOCKED (1 << 7)
> +#define HMM_PFN_SPECIAL (1 << 8)
> +#define HMM_PFN_MIGRATE (1 << 9)
> +#define HMM_PFN_UNADDRESSABLE (1 << 10)
> +#define HMM_PFN_SHIFT 11
>  
>  static inline struct page *hmm_pfn_to_page(hmm_pfn_t pfn)
>  {
> @@ -323,6 +328,49 @@ bool hmm_vma_fault(struct vm_area_struct *vma,
>  hmm_pfn_t *pfns);
>  
>  
> +/*
> + * struct hmm_migrate_ops - migrate operation callback
> + *
> + * @alloc_and_copy: alloc destination memoiry and copy source to it
> + * @finalize_and_map: allow caller to inspect successfull migrated page
> + *
> + * The new HMM migrate helper hmm_vma_migrate() allow memory migration to use
> + * device DMA engine to perform copy from source to destination memory it 
> also
> + * allow caller to use its own memory allocator for destination memory.
> + *
> + * Note that in alloc_and_copy device driver can decide not to migrate some 
> of
> + * the entry, for those it must clear the HMM_PFN_MIGRATE flag. The 
> destination
> + * page must lock and the corresponding hmm_pfn_t value in the array updated
> + * with the HMM_PFN_MIGRATE and HMM_PFN_LOCKED flag set (and of course be a
> + * valid entry). It is expected that the page allocated will have an elevated
> + * refcount and that a put_page() will free the page. Device driver might 
> want
> + * to allocate with an extra-refcount if they want to control deallocation of
> + * failed migration inside the finalize_and_map() callback.
> + *
> + * Inside finalize_and_map() device driver must use the HMM_PFN_MIGRATE flag 
> to
> + * determine which page have been successfully migrated.
> + */
> +struct hmm_migrate_ops {
> + void (*alloc_and_copy)(struct vm_area_struct *vma,
> +unsigned long start,
> +unsigned long end,
> +hmm_pfn_t *pfns,
> +void *private);
> + void (*finalize_and_map)(struct vm_area_struct *vma,
> +  unsigned long start,
> +  unsigned long end,
> +  hmm_pfn_t *pfns,
> +  void *private);
> +};
> +
> +int hmm_vma_migrate(const 

[PATCH 0/6] ASoC: samsung: Minor cleanup for old machines

2016-11-19 Thread Krzysztof Kozlowski
Hi,

Few patches removing dead code (machines not supported).

The third patch ([RFT 3/6] ASoC: samsung: smdk_wm8580: Remove machine
specific quirks) requires testing. I hope I understood the code
correctly.

The last ARM patch is independent. I will take it through samsung-soc
tree. I put it here for reference.

Best regards,
Krzysztof

Krzysztof Kozlowski (6):
  ASoC: samsung: Remove non-existing MACH dependencies
  ASoC: samsung: smdk_wm8580: Remove old platforms and drop mach-types
usage
  ASoC: samsung: smdk_wm8580: Remove machine specific quirks
  ASoC: samsung: Enable COMPILE_TEST for SmartQ and WM8580
  ASoC: samsung: Enable COMPILE_TEST for entire Samsung ASoc
  ARM: s5pv210_defconfig: Remove old MACHs

 arch/arm/configs/s5pv210_defconfig |  4 
 sound/soc/samsung/Kconfig  |  8 +---
 sound/soc/samsung/smdk_wm8580.c| 17 ++---
 3 files changed, 7 insertions(+), 22 deletions(-)

-- 
2.7.4



[PATCH 2/6] ASoC: samsung: smdk_wm8580: Remove old platforms and drop mach-types usage

2016-11-19 Thread Krzysztof Kozlowski
MACH_SMDKC100, MACH_SMDKV210 and MACH_SMDKC110 are no longer supported
so drop the dead code.

Signed-off-by: Krzysztof Kozlowski 
---
 sound/soc/samsung/smdk_wm8580.c | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/sound/soc/samsung/smdk_wm8580.c b/sound/soc/samsung/smdk_wm8580.c
index 548bfd993788..59fd3b8fd414 100644
--- a/sound/soc/samsung/smdk_wm8580.c
+++ b/sound/soc/samsung/smdk_wm8580.c
@@ -14,8 +14,6 @@
 #include 
 #include 
 
-#include 
-
 #include "../codecs/wm8580.h"
 #include "i2s.h"
 
@@ -206,15 +204,10 @@ static int __init smdk_audio_init(void)
int ret;
char *str;
 
-   if (machine_is_smdkc100()
-   || machine_is_smdkv210() || machine_is_smdkc110()) {
-   smdk.num_links = 3;
-   } else if (machine_is_smdk6410()) {
-   str = (char *)smdk_dai[PRI_PLAYBACK].cpu_dai_name;
-   str[strlen(str) - 1] = '2';
-   str = (char *)smdk_dai[PRI_CAPTURE].cpu_dai_name;
-   str[strlen(str) - 1] = '2';
-   }
+   str = (char *)smdk_dai[PRI_PLAYBACK].cpu_dai_name;
+   str[strlen(str) - 1] = '2';
+   str = (char *)smdk_dai[PRI_CAPTURE].cpu_dai_name;
+   str[strlen(str) - 1] = '2';
 
smdk_snd_device = platform_device_alloc("soc-audio", -1);
if (!smdk_snd_device)
-- 
2.7.4



[PATCH 1/6] ASoC: samsung: Remove non-existing MACH dependencies

2016-11-19 Thread Krzysztof Kozlowski
MACH_SMDKC100 was removed in commit b8529ec1c1b0 ("ARM: S5PC100: no more
support S5PC100 SoC"). MACH_SMDKV210 and MACH_SMDKC110 in commit
28c8331d386 ("ARM: S5PV210: Remove support for board files").

Signed-off-by: Krzysztof Kozlowski 
---
 sound/soc/samsung/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 79ae6a7c93ff..ea0fa9971a0c 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -49,7 +49,7 @@ config SND_SOC_SAMSUNG_JIVE_WM8750
 
 config SND_SOC_SAMSUNG_SMDK_WM8580
tristate "SoC I2S Audio support for WM8580 on SMDK"
-   depends on MACH_SMDK6410 || MACH_SMDKC100 || MACH_SMDKV210 || 
MACH_SMDKC110
+   depends on MACH_SMDK6410
depends on I2C
select SND_SOC_WM8580
select SND_SAMSUNG_I2S
-- 
2.7.4



[RFT 3/6] ASoC: samsung: smdk_wm8580: Remove machine specific quirks

2016-11-19 Thread Krzysztof Kozlowski
The driver no longer differentiates between machines (S3C24xx machines
are not supported by it) so there is no need to override I2S device id
in cpu_dai_name.

Signed-off-by: Krzysztof Kozlowski 

---

Not tested. The driver did not override .platform_name which looks
suspicious to me. However I did not want to add changes which could have
some visible impact on output code.
---
 sound/soc/samsung/smdk_wm8580.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/sound/soc/samsung/smdk_wm8580.c b/sound/soc/samsung/smdk_wm8580.c
index 59fd3b8fd414..3bf33387dfeb 100644
--- a/sound/soc/samsung/smdk_wm8580.c
+++ b/sound/soc/samsung/smdk_wm8580.c
@@ -155,7 +155,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
[PRI_PLAYBACK] = { /* Primary Playback i/f */
.name = "WM8580 PAIF RX",
.stream_name = "Playback",
-   .cpu_dai_name = "samsung-i2s.0",
+   .cpu_dai_name = "samsung-i2s.2",
.codec_dai_name = "wm8580-hifi-playback",
.platform_name = "samsung-i2s.0",
.codec_name = "wm8580.0-001b",
@@ -165,7 +165,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
[PRI_CAPTURE] = { /* Primary Capture i/f */
.name = "WM8580 PAIF TX",
.stream_name = "Capture",
-   .cpu_dai_name = "samsung-i2s.0",
+   .cpu_dai_name = "samsung-i2s.2",
.codec_dai_name = "wm8580-hifi-capture",
.platform_name = "samsung-i2s.0",
.codec_name = "wm8580.0-001b",
@@ -202,12 +202,6 @@ static struct platform_device *smdk_snd_device;
 static int __init smdk_audio_init(void)
 {
int ret;
-   char *str;
-
-   str = (char *)smdk_dai[PRI_PLAYBACK].cpu_dai_name;
-   str[strlen(str) - 1] = '2';
-   str = (char *)smdk_dai[PRI_CAPTURE].cpu_dai_name;
-   str[strlen(str) - 1] = '2';
 
smdk_snd_device = platform_device_alloc("soc-audio", -1);
if (!smdk_snd_device)
-- 
2.7.4



[PATCH 5/6] ASoC: samsung: Enable COMPILE_TEST for entire Samsung ASoc

2016-11-19 Thread Krzysztof Kozlowski
Instead of build time, Samsung ASoC drivers have rather runtime
dependency on Exynos or other Samsung platforms.  For building they
require Common Clock Framework.  If it is provided they could be compile
tested to increase build coverage.

Signed-off-by: Krzysztof Kozlowski 
---
 sound/soc/samsung/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 426ef1c7b265..a6cc6ca93fa7 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -1,6 +1,7 @@
 menuconfig SND_SOC_SAMSUNG
tristate "ASoC support for Samsung"
-   depends on (PLAT_SAMSUNG || ARCH_EXYNOS)
+   depends on PLAT_SAMSUNG || ARCH_EXYNOS || COMPILE_TEST
+   depends on COMMON_CLK
select SND_SOC_GENERIC_DMAENGINE_PCM
---help---
  Say Y or M if you want to add support for codecs attached to
-- 
2.7.4



[PATCH 6/6] ARM: s5pv210_defconfig: Remove old MACHs

2016-11-19 Thread Krzysztof Kozlowski
Remove non-existing MACH symbols from S5PV210 defconfig.

Signed-off-by: Krzysztof Kozlowski 
---
 arch/arm/configs/s5pv210_defconfig | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index fa989902236d..c51f0f02012b 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -9,10 +9,6 @@ CONFIG_ARCH_S5PV210=y
 CONFIG_S3C_LOWLEVEL_UART_PORT=1
 CONFIG_S3C_DEV_FB=y
 CONFIG_S5PV210_SETUP_FB_24BPP=y
-CONFIG_MACH_AQUILA=y
-CONFIG_MACH_GONI=y
-CONFIG_MACH_SMDKC110=y
-CONFIG_MACH_SMDKV210=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_VMSPLIT_2G=y
-- 
2.7.4



[PATCH 4/6] ASoC: samsung: Enable COMPILE_TEST for SmartQ and WM8580

2016-11-19 Thread Krzysztof Kozlowski
The I2S sound drivers for SmartQ board and WM8580 codec can be compile
tested to increase build coverage.

Signed-off-by: Krzysztof Kozlowski 
---
 sound/soc/samsung/Kconfig | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index ea0fa9971a0c..426ef1c7b265 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -49,7 +49,7 @@ config SND_SOC_SAMSUNG_JIVE_WM8750
 
 config SND_SOC_SAMSUNG_SMDK_WM8580
tristate "SoC I2S Audio support for WM8580 on SMDK"
-   depends on MACH_SMDK6410
+   depends on MACH_SMDK6410 || COMPILE_TEST
depends on I2C
select SND_SOC_WM8580
select SND_SAMSUNG_I2S
@@ -109,7 +109,8 @@ config SND_SOC_SAMSUNG_RX1950_UDA1380
 
 config SND_SOC_SMARTQ
tristate "SoC I2S Audio support for SmartQ board"
-   depends on MACH_SMARTQ && I2C
+   depends on MACH_SMARTQ || COMPILE_TEST
+   depends on I2C
select SND_SAMSUNG_I2S
select SND_SOC_WM8750
 
-- 
2.7.4



Re: [HMM v13 00/18] HMM (Heterogeneous Memory Management) v13

2016-11-19 Thread Aneesh Kumar K.V
John Hubbard  writes:

> On Fri, 18 Nov 2016, Jérôme Glisse wrote:
>
>> Cliff note: HMM offers 2 things (each standing on its own). First
>> it allows to use device memory transparently inside any process
>> without any modifications to process program code. Second it allows
>> to mirror process address space on a device.
>> 
>> Change since v12 is the use of struct page for device memory even if
>> the device memory is not accessible by the CPU (because of limitation
>> impose by the bus between the CPU and the device).
>> 
>> Using struct page means that their are minimal changes to core mm
>> code. HMM build on top of ZONE_DEVICE to provide struct page, it
>> adds new features to ZONE_DEVICE. The first 7 patches implement
>> those changes.
>> 
>> Rest of patchset is divided into 3 features that can each be use
>> independently from one another. First is the process address space
>> mirroring (patch 9 to 13), this allow to snapshot CPU page table
>> and to keep the device page table synchronize with the CPU one.
>> 
>> Second is a new memory migration helper which allow migration of
>> a range of virtual address of a process. This memory migration
>> also allow device to use their own DMA engine to perform the copy
>> between the source memory and destination memory. This can be
>> usefull even outside HMM context in many usecase.
>> 
>> Third part of the patchset (patch 17-18) is a set of helper to
>> register a ZONE_DEVICE node and manage it. It is meant as a
>> convenient helper so that device drivers do not each have to
>> reimplement over and over the same boiler plate code.
>> 
>> 
>> I am hoping that this can now be consider for inclusion upstream.
>> Bottom line is that without HMM we can not support some of the new
>> hardware features on x86 PCIE. I do believe we need some solution
>> to support those features or we won't be able to use such hardware
>> in standard like C++17, OpenCL 3.0 and others.
>> 
>> I have been working with NVidia to bring up this feature on their
>> Pascal GPU. There are real hardware that you can buy today that
>> could benefit from HMM. We also intend to leverage this inside the
>> open source nouveau driver.
>> 
>
> Hi,
>
> We (NVIDIA engineering) have been working closely with Jerome on this for 
> several years now, and I wanted to mention that NVIDIA is committed to 
> using HMM. We've done initial testing of this patchset on Pascal GPUs (a 
> bit more detail below) and it is looking good.
>   

This can also be used on IBM platforms like Minsky (
http://www.tomshardware.com/news/ibm-power8-nvidia-tesla-p100-minsky,32661.html
)

There is also discussion around using this for device accelerated page
migration. That can help with coherent device memory node work.
(https://lkml.kernel.org/r/1477283517-2504-1-git-send-email-khand...@linux.vnet.ibm.com)

-aneesh



[PATCH RFC] user-namespaced file capabilities - now with even more magic

2016-11-19 Thread Serge E. Hallyn
Root in a user ns cannot be trusted to write a traditional
security.capability xattr.  If it were allowed to do so, then any
unprivileged user on the host could map his own uid to root in a
namespace, write the xattr, and execute the file with privilege on the
host.

This patch introduces v3 of the security.capability xattr.  It builds a
vfs_ns_cap_data struct by appending a uid_t rootid to struct
vfs_cap_data.  This is the absolute uid_t (i.e. the uid_t in
init_user_ns) of the root id (uid 0 in a namespace) in whose namespaces
the file capabilities may take effect.

When a task in a user ns (which is privileged with CAP_SETFCAP toward
that user_ns) asks to write v2 security.capability, the kernel will
transparently rewrite the xattr as a v3 with the appropriate rootid.
Subsequently, any task executing the file which has the noted kuid as
its root uid, or which is in a descendent user_ns of such a user_ns,
will run the file with capabilities.

If a task writes a v3 security.capability, then it can provide a
uid (valid within its own user namespace, over which it has CAP_SETFCAP)
for the xattr.  The kernel will translate that to the absolute uid, and
write that to disk.  After this, a task in the writer's namespace will
not be able to use those capabilities, but a task in a namespace where
the given uid is root will.

Only a single security.capability xattr may be written.  A task may
overwrite the existing one so long as it was written by a user mapped
into his own user_ns over which he has CAP_SETFCAP.

This allows a simple setxattr to work, allows tar/untar to work, and
allows us to tar in one namespace and untar in another while preserving
the capability, without risking leaking privilege into a parent
namespace.

Changelog:
   Nov 02 2016: fix invalid check at refuse_fcap_overwrite()
   Nov 07 2016: convert rootid from and to fs user_ns
---
 fs/xattr.c  |  27 +++-
 include/linux/capability.h  |   5 +-
 include/linux/security.h|   2 +
 include/uapi/linux/capability.h |  22 ++-
 security/commoncap.c| 335 ++--
 5 files changed, 366 insertions(+), 25 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index 2d13b4e..e9e70f1 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -171,11 +171,27 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const 
char *name,
 {
struct inode *inode = dentry->d_inode;
int error = -EAGAIN;
+   void *wvalue = NULL;
+   size_t wsize = 0;
int issec = !strncmp(name, XATTR_SECURITY_PREFIX,
   XATTR_SECURITY_PREFIX_LEN);
 
-   if (issec)
+   if (issec) {
inode->i_flags &= ~S_NOSEC;
+
+   /* if root in a non-init user_ns tries to set
+* security.capability, write the virtualized
+* xattr in its place */
+   if (!strcmp(name, "security.capability") &&
+   current_user_ns() != _user_ns) {
+   cap_setxattr_make_nscap(dentry, value, size, , 
);
+   if (!wvalue)
+   return -EPERM;
+   value = wvalue;
+   size = wsize;
+   }
+   }
+
if (inode->i_opflags & IOP_XATTR) {
error = __vfs_setxattr(dentry, inode, name, value, size, flags);
if (!error) {
@@ -184,8 +200,10 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const 
char *name,
 size, flags);
}
} else {
-   if (unlikely(is_bad_inode(inode)))
-   return -EIO;
+   if (unlikely(is_bad_inode(inode))) {
+   error = -EIO;
+   goto out;
+   }
}
if (error == -EAGAIN) {
error = -EOPNOTSUPP;
@@ -200,10 +218,11 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const 
char *name,
}
}
 
+out:
+   kfree(wvalue);
return error;
 }
 
-
 int
 vfs_setxattr(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags)
diff --git a/include/linux/capability.h b/include/linux/capability.h
index dbc21c7..edd5be1 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -13,7 +13,7 @@
 #define _LINUX_CAPABILITY_H
 
 #include 
-
+#include 
 
 #define _KERNEL_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_3
 #define _KERNEL_CAPABILITY_U32S_LINUX_CAPABILITY_U32S_3
@@ -246,4 +246,7 @@ extern bool file_ns_capable(const struct file *file, struct 
user_namespace *ns,
 /* audit system wants to get cap info from files as well */
 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct 
cpu_vfs_cap_data *cpu_caps);
 
+extern void cap_setxattr_make_nscap(struct dentry *dentry, const void *value,
+   size_t size, void **wvalue, size_t *wsize);
+
 

Re: [RFC PATCH v2 1/7] dt-bindings: document devicetree bindings for mux-gpio

2016-11-19 Thread Jonathan Cameron
On 18/11/16 16:59, Peter Rosin wrote:
> On 2016-11-18 16:35, Rob Herring wrote:
>> On Thu, Nov 17, 2016 at 10:48:03PM +0100, Peter Rosin wrote:
>>> ---
>>>  .../devicetree/bindings/misc/mux-gpio.txt  | 79 
>>> ++
>>>  1 file changed, 79 insertions(+)
>>>  create mode 100644 Documentation/devicetree/bindings/misc/mux-gpio.txt
>>>
>>> diff --git a/Documentation/devicetree/bindings/misc/mux-gpio.txt 
>>> b/Documentation/devicetree/bindings/misc/mux-gpio.txt
>>> new file mode 100644
>>> index ..73699a37824f
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/misc/mux-gpio.txt
>>> @@ -0,0 +1,79 @@
>>> +GPIO-based multiplexer controller bindings
>>> +
>>> +Define what GPIO pins are used to control a multiplexer. Or several
>>> +multiplexers, if the same pins control more than one multiplexer.
>>
>> I think this makes sense in your case, but I think it is too complicated 
>> for a non-shared case. Perhaps mux-gpios should be used directly (i.e. 
>> in the adc-mux node) and control-muxes only used for the shared case.
>>
>> Part of me feels like you are working around in DT the GPIO subsystem 
>> limitation that it can't share GPIO lines. Either this could be fixed 
>> in some way in the GPIO subsystem, or the mux subsys could deal with it. 
>> You just have to look up if you already have a mux registered for the 
>> same GPIOs. Of course, that may make the mux subsys pretty much GPIO 
>> only, but I'm having a hard time thinking how you would have shared 
>> muxes that are not GPIO controlled. Any other control would be 
>> integrated into the mux itself.
> 
> But if someone wants to mux an adc line with a mux that is some kind of
> integrated i2c device, you'd have to add extra code to the iio muxer
> driver to handle that case. Or fork it. Or build something like the
> i2c muxer infrastructure and separate out the mux control in small
> drivers and handle the generic iio muxing centrally. But then someone
> else uses that i2c device to instead mux an i2c bus, and you'd end up
> with code duplication when that same muxer control code is added under
> drivers/i2c/muxes.
> 
> With the proposed solution, this is unified.
> 
> I'd just hate to see drivers for muxers added under drivers/i2c/muxes
> that do little more that control a mux that happens to be used to mux
> an i2c bus, but are generic muxers that could equally well mux something
> else. Even if the control is integrated into the mux, what the mux is
> actually used for should perhaps not determine where its driver should
> live.
> 
> Anyway, I don't know what to make with your suggestion, I just don't
> see the path forward (not enough experience with the kernel and/or gpio
> code). And it would be a limited solution (GPIO only,a s you say) so it
> doesn't feel right.
Also worth pointing out here the possibility of multi pole muxes...
Relays are ultimately muxes as well (be it slow ones ;)

A quick google fed me:
TI SN74LS153 for example.  This one is digital only though...

Analog option (in both senses) is:
http://www.analog.com/media/en/technical-documentation/data-sheets/ADG888.pdf

So these 'look' the same as two single muxes wired to the same GPIOs.

> 
> Is there perhaps some way to keep the complicated shared case work as
> is (or equivalently, the exact details are not important), and also
> provide a simpler in-node thingy to glue a mux control to a consumer
> w/o pointing to it with a phandle, but still have the same mux driver
> handle both cases? No, I'm not a devicetree guru, so I don't see a
> solution for that either, but maybe someone else does?
> 
> Perhaps the consumer could look for the mux control in first the
> phandle, as in my proposal. If not found, it could also look for
> a mux provider bound to child node.
> 
>   adc-mux {
>   compatible = "iio-mux";
>   io-channels = < 0>;
>   io-channel-names = "parent";
> 
>   mux-control {
>   compatible = "mux-gpio";
>   mux-gpios = < 0 GPIO_ACTIVE_HIGH>,
>   < 1 GPIO_ACTIVE_HIGH>;
>   };
> 
>   #address-cells = <1>;
>   #size-cells = <0>;
> 
>   sync-1@0 {
>   reg = <0>;
>   };
>   /* ... */
>   };
> 
> Or perhaps look in a parent node:
> 
>   mux-control {
>   compatible = "mux-gpio";
>   mux-gpios = < 0 GPIO_ACTIVE_HIGH>,
>   < 1 GPIO_ACTIVE_HIGH>;
> 
>   adc-mux {
>   compatible = "iio-mux";
>   io-channels = < 0>;
>   io-channel-names = "parent";
> 
>   #address-cells = <1>;
>   #size-cells = <0>;
> 
>   sync-1@0 {
>   reg = <0>;
>   };
>   /* ... */
>   };
>  

Re: [PATCH] net: macb: add check for dma mapping error in start_xmit()

2016-11-19 Thread David Miller
From: Alexey Khoroshilov 
Date: Sat, 19 Nov 2016 01:40:10 +0300

> at91ether_start_xmit() does not check for dma mapping errors.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov 

Applied, thanks.


Re: [RFC PATCH v2 2/7] misc: minimal mux subsystem and gpio-based mux controller

2016-11-19 Thread Jonathan Cameron
On 17/11/16 21:48, Peter Rosin wrote:
> When both the iio subsystem and the i2c subsystem wants to update
> the same mux, there needs to be some coordination. Invent a new
> minimal "mux" subsystem that handles this.
I'd probably put something more general in the description. Lots of things
may need the same infrastructure.  This is just an example.

Few bits inline.

Also, I suspect you will fairly rapidly have a need for a strobe signal
as well.  A lot of mux chips that are more than 2 way seem to have them to
allow multiple chips to be synchronized.
> 
> Add a single backend driver for this new subsystem that can
> control gpio based multiplexers.
> ---
>  drivers/misc/Kconfig|   6 +
>  drivers/misc/Makefile   |   2 +
>  drivers/misc/mux-core.c | 299 
> 
>  drivers/misc/mux-gpio.c | 115 +++
>  include/linux/mux.h |  53 +
>  5 files changed, 475 insertions(+)
>  create mode 100644 drivers/misc/mux-core.c
>  create mode 100644 drivers/misc/mux-gpio.c
>  create mode 100644 include/linux/mux.h
> 
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 64971baf11fa..9e119bb78d82 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -766,6 +766,12 @@ config PANEL_BOOT_MESSAGE
> An empty message will only clear the display at driver init time. Any 
> other
> printf()-formatted message is valid with newline and escape codes.
>  
> +config MUX_GPIO
> + tristate "GPIO-controlled MUX controller"
> + depends on OF
> + help
> +   GPIO-controlled MUX controller
> +
>  source "drivers/misc/c2port/Kconfig"
>  source "drivers/misc/eeprom/Kconfig"
>  source "drivers/misc/cb710/Kconfig"
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 31983366090a..92b547bcbac1 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -53,6 +53,8 @@ obj-$(CONFIG_ECHO)  += echo/
>  obj-$(CONFIG_VEXPRESS_SYSCFG)+= vexpress-syscfg.o
>  obj-$(CONFIG_CXL_BASE)   += cxl/
>  obj-$(CONFIG_PANEL) += panel.o
> +obj-$(CONFIG_MUX_GPIO)  += mux-core.o
> +obj-$(CONFIG_MUX_GPIO)  += mux-gpio.o
>  
>  lkdtm-$(CONFIG_LKDTM)+= lkdtm_core.o
>  lkdtm-$(CONFIG_LKDTM)+= lkdtm_bugs.o
> diff --git a/drivers/misc/mux-core.c b/drivers/misc/mux-core.c
> new file mode 100644
> index ..7a8bf003a92c
> --- /dev/null
> +++ b/drivers/misc/mux-core.c
> @@ -0,0 +1,299 @@
> +/*
> + * Multiplexer subsystem
> + *
> + * Copyright (C) 2016 Axentia Technologies AB
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#define pr_fmt(fmt) "mux-core: " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static struct bus_type mux_bus_type = {
> + .name = "mux",
> +};
> +
> +static int __init mux_init(void)
> +{
> + return bus_register(_bus_type);
> +}
> +
> +static void __exit mux_exit(void)
> +{
> + bus_unregister(_bus_type);
> +}
> +
> +static DEFINE_IDA(mux_ida);
> +
> +static void mux_control_release(struct device *dev)
> +{
> + struct mux_control *mux = to_mux_control(dev);
> +
> + ida_simple_remove(_ida, mux->id);
> + kfree(mux);
> +}
> +
> +static struct device_type mux_control_type = {
> + .name = "mux-control",
> + .release = mux_control_release,
> +};
> +
> +/*
> + * Allocate a mux-control, plus an extra memory area for private use
> + * by the caller.
> + */
> +struct mux_control *mux_control_alloc(size_t sizeof_priv)
> +{
> + struct mux_control *mux;
> +
Worth planning ahead for spi controlled muxes and others that need their
structures to be carefully aligned to avoid dma cacheline fun?
Easy enough to add later I guess.
> + mux = kzalloc(sizeof(*mux) + sizeof_priv, GFP_KERNEL);
> + if (!mux)
> + return NULL;
> +
> + mux->dev.bus = _bus_type;
> + mux->dev.type = _control_type;
> + device_initialize(>dev);
> + dev_set_drvdata(>dev, mux);
> +
> + init_rwsem(>lock);
> + mux->priv = mux + 1;
Needed?  Or just do it with a bit of pointer math where the access is needed?
> +
> + mux->id = ida_simple_get(_ida, 0, 0, GFP_KERNEL);
> + if (mux->id < 0) {
> + pr_err("mux-controlX failed to get device id\n");
> + kfree(mux);
> + return NULL;
> + }
> + dev_set_name(>dev, "mux:control%d", mux->id);
> +
> + mux->cached_state = -1;
> + mux->idle_state = -1;
> +
> + return mux;
> +}
> +EXPORT_SYMBOL_GPL(mux_control_alloc);
> +
> +/*
> + * Register the mux-control, thus readying it for use.
Either single line comment style - or perhaps kernel doc the lot...
> + */
> +int mux_control_register(struct mux_control *mux)
> +{
> + /* If the calling driver did not 

Re: [RFC PATCH v2 3/7] iio: inkern: api for manipulating ext_info of iio channels

2016-11-19 Thread Jonathan Cameron
On 17/11/16 21:48, Peter Rosin wrote:
> Extend the inkern api with functions for reading and writing ext_info
> of iio channels.
I'd like Lars' feedback on this one.

Superficially looks fine to me but I am not as familiar with this interface
as Lars is ;) (he wrote it IIRC:)
> ---
>  drivers/iio/inkern.c | 55 
> 
>  include/linux/iio/consumer.h |  6 +
>  2 files changed, 61 insertions(+)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index cfca17ba2535..a8099b164222 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -850,3 +850,58 @@ int iio_write_channel_raw(struct iio_channel *chan, int 
> val)
>   return ret;
>  }
>  EXPORT_SYMBOL_GPL(iio_write_channel_raw);
> +
> +int iio_get_channel_ext_info_count(struct iio_channel *chan)
> +{
> + const struct iio_chan_spec_ext_info *ext_info;
> + unsigned int i = 0;
> +
> + if (!chan->channel->ext_info)
> + return i;
> +
> + for (ext_info = chan->channel->ext_info; ext_info->name; ext_info++)
> + ++i;
> +
> + return i;
> +}
> +EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
> +
> +ssize_t iio_read_channel_ext_info(struct iio_channel *chan,
> +   const char *attr, char *buf)
> +{
> + const struct iio_chan_spec_ext_info *ext_info;
> +
> + if (!chan->channel->ext_info)
> + return -EINVAL;
> +
> + for (ext_info = chan->channel->ext_info; ext_info->name; ++ext_info) {
> + if (strcmp(attr, ext_info->name))
> + continue;
> +
> + return ext_info->read(chan->indio_dev, ext_info->private,
> +   chan->channel, buf);
> + }
> +
> + return -EINVAL;
> +}
> +EXPORT_SYMBOL_GPL(iio_read_channel_ext_info);
> +
> +ssize_t iio_write_channel_ext_info(struct iio_channel *chan, const char 
> *attr,
> +const char *buf, size_t len)
> +{
> + const struct iio_chan_spec_ext_info *ext_info;
> +
> + if (!chan->channel->ext_info)
> + return -EINVAL;
> +
> + for (ext_info = chan->channel->ext_info; ext_info->name; ++ext_info) {
> + if (strcmp(attr, ext_info->name))
> + continue;
> +
> + return ext_info->write(chan->indio_dev, ext_info->private,
> +chan->channel, buf, len);
> + }
> +
> + return -EINVAL;
> +}
> +EXPORT_SYMBOL_GPL(iio_write_channel_ext_info);
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index 9a4f336d8b4a..471dece8729a 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -299,4 +299,10 @@ int iio_read_channel_scale(struct iio_channel *chan, int 
> *val,
>  int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
>   int *processed, unsigned int scale);
>  
> +int iio_get_channel_ext_info_count(struct iio_channel *chan);
> +ssize_t iio_read_channel_ext_info(struct iio_channel *chan,
> +   const char *attr, char *buf);
> +ssize_t iio_write_channel_ext_info(struct iio_channel *chan, const char 
> *attr,
> +const char *buf, size_t len);
> +
>  #endif
> 



Re: [PATCH v3 0/2] Ajust lockdep static allocations for sparc

2016-11-19 Thread Peter Zijlstra
On Fri, Nov 18, 2016 at 02:34:07PM -0500, David Miller wrote:
> From: Babu Moger 
> Date: Tue, 27 Sep 2016 12:33:26 -0700
> 
> > These patches limit the static allocations for lockdep data structures
> > used for debugging locking correctness. For sparc, all the kernel's code,
> > data, and bss, must have locked translations in the TLB so that we don't
> > get TLB misses on kernel code and data. Current sparc chips have 8 TLB
> > entries available that may be locked down, and with a 4mb page size,
> > this gives a maximum of 32MB. With PROVE_LOCKING we could go over this
> > limit and cause system boot-up problems. These patches limit the static
> > allocations so that everything fits in current required size limit.
> > 
> > patch 1 : Adds new config parameter CONFIG_PROVE_LOCKING_SMALL
> > Patch 2 : Adjusts the sizes based on the new config parameter
> > 
> > v2-> v3:
> >Some more comments from Sam Ravnborg and Peter Zijlstra.
> >Defined PROVE_LOCKING_SMALL as invisible and moved the selection to
> >arch/sparc/Kconfig. 
> > 
> > v1-> v2:
> >As suggested by Peter Zijlstra, keeping the default as is.
> >Introduced new config variable CONFIG_PROVE_LOCKING_SMALL
> >to handle sparc specific case.
> > 
> > v0:
> >Initial revision.
> 
> Series applied, thanks.

Heh, I was only waiting for an ACK from you, but this works too :-)


Re: [PATCH v3 2/6] iio: adc: Add support for STM32 ADC core

2016-11-19 Thread Jonathan Cameron
On 15/11/16 15:30, Fabrice Gasnier wrote:
> Add core driver for STMicroelectronics STM32 ADC (Analog to Digital
> Converter). STM32 ADC can be composed of up to 3 ADCs with shared
> resources like clock prescaler, common interrupt line and analog
> reference voltage.
> This core driver basically manages shared resources.
> 
> Signed-off-by: Fabrice Gasnier 

There is nothing in here that demands selecting a fixed regulator.
I've also switched the select regulator over to depends on inline with
other drivers in IIO that have a hard dependency on regulators.
Other than that which showed up during build tests, looks good to me.
Shout if I've broken anything with this change.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/Kconfig  |  13 ++
>  drivers/iio/adc/Makefile |   1 +
>  drivers/iio/adc/stm32-adc-core.c | 303 
> +++
>  drivers/iio/adc/stm32-adc-core.h |  52 +++
>  4 files changed, 369 insertions(+)
>  create mode 100644 drivers/iio/adc/stm32-adc-core.c
>  create mode 100644 drivers/iio/adc/stm32-adc-core.h
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 7edcf32..ff30239 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -419,6 +419,19 @@ config ROCKCHIP_SARADC
> To compile this driver as a module, choose M here: the
> module will be called rockchip_saradc.
>  
> +config STM32_ADC_CORE
> + tristate "STMicroelectronics STM32 adc core"
> + depends on ARCH_STM32 || COMPILE_TEST
> + depends on OF
> + select REGULATOR
> + select REGULATOR_FIXED_VOLTAGE
> + help
> +   Select this option to enable the core driver for STMicroelectronics
> +   STM32 analog-to-digital converter (ADC).
> +
> +   This driver can also be built as a module.  If so, the module
> +   will be called stm32-adc-core.
> +
>  config STX104
>   tristate "Apex Embedded Systems STX104 driver"
>   depends on X86 && ISA_BUS_API
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index 7a40c04..a1e8f44 100644
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -41,6 +41,7 @@ obj-$(CONFIG_QCOM_SPMI_IADC) += qcom-spmi-iadc.o
>  obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o
>  obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o
>  obj-$(CONFIG_STX104) += stx104.o
> +obj-$(CONFIG_STM32_ADC_CORE) += stm32-adc-core.o
>  obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o
>  obj-$(CONFIG_TI_ADC0832) += ti-adc0832.o
>  obj-$(CONFIG_TI_ADC12138) += ti-adc12138.o
> diff --git a/drivers/iio/adc/stm32-adc-core.c 
> b/drivers/iio/adc/stm32-adc-core.c
> new file mode 100644
> index 000..4214b0c
> --- /dev/null
> +++ b/drivers/iio/adc/stm32-adc-core.c
> @@ -0,0 +1,303 @@
> +/*
> + * This file is part of STM32 ADC driver
> + *
> + * Copyright (C) 2016, STMicroelectronics - All Rights Reserved
> + * Author: Fabrice Gasnier .
> + *
> + * Inspired from: fsl-imx25-tsadc
> + *
> + * License type: GPLv2
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published 
> by
> + * the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> + * or FITNESS FOR A PARTICULAR PURPOSE.
> + * See the GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program. If not, see .
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "stm32-adc-core.h"
> +
> +/* STM32F4 - common registers for all ADC instances: 1, 2 & 3 */
> +#define STM32F4_ADC_CSR  (STM32_ADCX_COMN_OFFSET + 0x00)
> +#define STM32F4_ADC_CCR  (STM32_ADCX_COMN_OFFSET + 0x04)
> +
> +/* STM32F4_ADC_CSR - bit fields */
> +#define STM32F4_EOC3 BIT(17)
> +#define STM32F4_EOC2 BIT(9)
> +#define STM32F4_EOC1 BIT(1)
> +
> +/* STM32F4_ADC_CCR - bit fields */
> +#define STM32F4_ADC_ADCPRE_SHIFT 16
> +#define STM32F4_ADC_ADCPRE_MASK  GENMASK(17, 16)
> +
> +/* STM32 F4 maximum analog clock rate (from datasheet) */
> +#define STM32F4_ADC_MAX_CLK_RATE 3600
> +
> +/**
> + * struct stm32_adc_priv - stm32 ADC core private data
> + * @irq: irq for ADC block
> + * @domain:  irq domain reference
> + * @aclk:clock reference for the analog circuitry
> + * @vref:regulator reference
> + * @common:  common data for all ADC instances
> + */
> +struct stm32_adc_priv {
> + int

Re: [char-misc-next 4/4 V2] mei: bus: enable non-blocking RX

2016-11-19 Thread Greg Kroah-Hartman
On Sat, Nov 19, 2016 at 02:16:11PM +0200, Tomas Winkler wrote:
> From: Alexander Usyskin 
> 
> Enable non-blocking receive for drivers on mei bus, this allows checking
> for data availability by mei client drivers. This is most effective for
> fixed address clients, that lacks flow control.
> 
> This function adds new API function mei_cldev_recv_nonblock(), it
> retuns -EGAIN if function will block.
> 
> Signed-off-by: Alexander Usyskin 
> Signed-off-by: Tomas Winkler 
> ---
> V2: use _nonblock() function suffix instead of NONBLOCK flag
> 
>  drivers/misc/mei/bus-fixup.c |  4 ++--
>  drivers/misc/mei/bus.c   | 31 +--
>  drivers/misc/mei/mei_dev.h   |  7 ++-
>  include/linux/mei_cl_bus.h   |  6 --
>  4 files changed, 41 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
> index 7f2cef9011ae..18e05ca7584f 100644
> --- a/drivers/misc/mei/bus-fixup.c
> +++ b/drivers/misc/mei/bus-fixup.c
> @@ -141,7 +141,7 @@ static int mei_osver(struct mei_cl_device *cldev)
>   if (ret < 0)
>   return ret;
>  
> - ret = __mei_cl_recv(cldev->cl, buf, length);
> + ret = __mei_cl_recv(cldev->cl, buf, length, 0);

What is 0 here?  Again, mode...


Re: [PATCH v3 4/6] ARM: configs: stm32: enable ADC driver

2016-11-19 Thread Jonathan Cameron
On 15/11/16 15:30, Fabrice Gasnier wrote:
> Signed-off-by: Fabrice Gasnier 
The driver is now on it's way in.  I'm assuming this and the two device tree 
patches
will go via the relevant route to arm-soc.

Thanks,

Jonathan
> ---
>  arch/arm/configs/stm32_defconfig | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm/configs/stm32_defconfig 
> b/arch/arm/configs/stm32_defconfig
> index 1e5ec2a..5d241e0 100644
> --- a/arch/arm/configs/stm32_defconfig
> +++ b/arch/arm/configs/stm32_defconfig
> @@ -57,6 +57,9 @@ CONFIG_LEDS_TRIGGERS=y
>  CONFIG_LEDS_TRIGGER_HEARTBEAT=y
>  CONFIG_DMADEVICES=y
>  CONFIG_STM32_DMA=y
> +CONFIG_IIO=y
> +CONFIG_STM32_ADC_CORE=y
> +CONFIG_STM32_ADC=y
>  # CONFIG_FILE_LOCKING is not set
>  # CONFIG_DNOTIFY is not set
>  # CONFIG_INOTIFY_USER is not set
> 



Re: [PATCH v4] staging: slicoss: fix different address space warnings

2016-11-19 Thread Greg KH
On Fri, Nov 18, 2016 at 06:57:18PM +0100, Sergio Paracuellos wrote:
> Remove incorrect __iomem annotation.
> 
> This patch fix the following sparse warnings in slicoss driver:
> warning: incorrect type in assignment (different address spaces)
> 
> Signed-off-by: Sergio Paracuellos 
> ---
>  drivers/staging/slicoss/slic.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
> index 420546d..14d7555 100644
> --- a/drivers/staging/slicoss/slic.h
> +++ b/drivers/staging/slicoss/slic.h
> @@ -380,7 +380,7 @@ struct slic_shmemory {
>   dma_addr_t isr_phaddr;
>   dma_addr_t lnkstatus_phaddr;
>   dma_addr_t stats_phaddr;
> - struct slic_shmem_data __iomem *shmem_data;
> + struct slic_shmem_data *shmem_data;

But, is this the correct fix?  It looks like shmem_data is being treated
like a pointer to io memory, so we need to use the correct accessors for
that memory, and not just a "raw" pointer, right?  Removing this marking
seems to be moving backwards...

thanks,

greg k-h


[patch 5/8] x86/tsc: Sync test only for the first cpu in a package

2016-11-19 Thread Thomas Gleixner
If the TSC_ADJUST MSR is available all CPUs in a package are forced to the
same value. So TSCs cannot be out of sync when the first CPU in the package
was in sync.

That allows to skip the sync test for all CPUs except the first starting
CPU in a package.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/tsc.h |4 ++--
 arch/x86/kernel/tsc_sync.c |   37 -
 2 files changed, 30 insertions(+), 11 deletions(-)

--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -49,10 +49,10 @@ extern void check_tsc_sync_source(int cp
 extern void check_tsc_sync_target(void);
 
 #ifdef CONFIG_X86_TSC
-extern void tsc_store_and_check_tsc_adjust(void);
+extern bool tsc_store_and_check_tsc_adjust(void);
 extern void tsc_verify_tsc_adjust(void);
 #else
-static inline void tsc_store_and_check_tsc_adjust(void) { }
+static inline bool tsc_store_and_check_tsc_adjust(void) { }
 static inline void tsc_verify_tsc_adjust(void) { }
 #endif
 
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -47,18 +47,19 @@ void tsc_verify_tsc_adjust(void)
 }
 
 #ifndef CONFIG_SMP
-void __init tsc_store_and_check_tsc_adjust(void)
+bool __init tsc_store_and_check_tsc_adjust(void)
 {
struct tsc_adjust *ref, *cur = this_cpu_ptr(_adjust);
s64 bootval;
 
if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
-   return;
+   return false;
 
rdmsrl(MSR_IA32_TSC_ADJUST, bootval);
cur->bootval = bootval;
cur->adjusted = bootval;
pr_info("TSC ADJUST: Boot CPU%u: %lld\n", cpu,  bootval);
+   return false;
 }
 
 #else /* !CONFIG_SMP */
@@ -66,14 +67,14 @@ void __init tsc_store_and_check_tsc_adju
 /*
  * Store and check the TSC ADJUST MSR if available
  */
-void tsc_store_and_check_tsc_adjust(void)
+bool tsc_store_and_check_tsc_adjust(void)
 {
struct tsc_adjust *ref, *cur = this_cpu_ptr(_adjust);
unsigned int refcpu, cpu = smp_processor_id();
s64 bootval;
 
if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
-   return;
+   return false;
 
rdmsrl(MSR_IA32_TSC_ADJUST, bootval);
cur->bootval = bootval;
@@ -95,7 +96,7 @@ void tsc_store_and_check_tsc_adjust(void
 */
cur->adjusted = bootval;
pr_info_once("TSC ADJUST: Boot CPU%u: %lld\n", cpu,  bootval);
-   return;
+   return false;
}
 
ref = per_cpu_ptr(_adjust, refcpu);
@@ -119,6 +120,11 @@ void tsc_store_and_check_tsc_adjust(void
cur->adjusted = ref->adjusted;
wrmsrl(MSR_IA32_TSC_ADJUST, ref->adjusted);
}
+   /*
+* We have the TSCs forced to be in sync on this package. Skip sync
+* test:
+*/
+   return true;
 }
 
 /*
@@ -127,6 +133,7 @@ void tsc_store_and_check_tsc_adjust(void
  */
 static atomic_t start_count;
 static atomic_t stop_count;
+static atomic_t skip_test;
 
 /*
  * We use a raw spinlock in this exceptional case, because
@@ -250,10 +257,16 @@ void check_tsc_sync_source(int cpu)
atomic_set(_count, 0);
 
/*
-* Wait for the target to arrive:
+* Wait for the target to start or to skip the test:
 */
-   while (atomic_read(_count) != cpus-1)
+   while (atomic_read(_count) != cpus - 1) {
+   if (atomic_read(_test) > 0) {
+   atomic_set(_test, 0);
+   return;
+   }
cpu_relax();
+   }
+
/*
 * Trigger the target to continue into the measurement too:
 */
@@ -303,8 +316,14 @@ void check_tsc_sync_target(void)
if (unsynchronized_tsc() || tsc_clocksource_reliable)
return;
 
-   /* Store and check the TSC ADJUST MSR */
-   tsc_store_and_check_tsc_adjust();
+   /*
+* Store, verify and sanitize the TSC adjust register. If
+* successful skip the test.
+*/
+   if (tsc_store_and_check_tsc_adjust()) {
+   atomic_inc(_test);
+   return;
+   }
 
/*
 * Register this CPU's participation and wait for the




[patch 3/8] x86/tsc: Store and check TSC ADJUST MSR

2016-11-19 Thread Thomas Gleixner
The TSC_ADJUST MSR shows whether the TSC has been modified. This is helpful
in a two aspects:

1) It allows to detect BIOS wreckage, where SMM code tries to 'hide' the
   cycles spent by storing the TSC value at SMM entry and restoring it at
   SMM exit. On affected machines the TSCs run slowly out of sync up to the
   point where the clocksource watchdog (if available) detects it.

   The TSC_ADJUST MSR allows to detect the TSC modification before that and
   eventually restore it. This is also important for SoCs which have no
   watchdog clocksource and therefore TSC wreckage cannot be detected and
   acted upon.

2) All threads in a package are required to have the same TSC_ADJUST
   value. Broken BIOSes break that and as a result the TSC synchronization
   check fails.

   The TSC_ADJUST MSR allows to detect the deviation when a CPU comes
   online. If detected set it to the value of an already online CPU in the
   same package. This also allows to reduce the number of sync tests
   because with that in place the test is only required for the first CPU
   in a package.

   In principle all CPUs in a system should have the same TSC_ADJUST value
   even across packages, but with physical CPU hotplug this assumption is
   not true because the TSC starts with power on, so physical hotplug has
   to do some trickery to bring the TSC into sync with already running
   packages, which requires to use an TSC_ADJUST value different from CPUs
   which got powered earlier.

   A final enhancement is the opportunity to compensate for unsynced TSCs
   accross nodes at boot time and make the TSC usable that way. It won't
   help for TSCs which run apart due to frequency skew between packages,
   but this gets detected by the clocksource watchdog later.

The first step toward this is to store the TSC_ADJUST value of a starting
CPU and compare it with the value of an already online CPU in the same
package. If they differ, emit a warning and adjust it to the reference
value. The !SMP version just stores the boot value for later verification.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/tsc.h |6 +++
 arch/x86/kernel/Makefile   |2 -
 arch/x86/kernel/tsc.c  |2 +
 arch/x86/kernel/tsc_sync.c |   88 +
 4 files changed, 97 insertions(+), 1 deletion(-)

--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -48,6 +48,12 @@ extern int tsc_clocksource_reliable;
 extern void check_tsc_sync_source(int cpu);
 extern void check_tsc_sync_target(void);
 
+#ifdef CONFIG_X86_TSC
+extern void tsc_store_and_check_tsc_adjust(void);
+#else
+static inline void tsc_store_and_check_tsc_adjust(void) { }
+#endif
+
 extern int notsc_setup(char *);
 extern void tsc_save_sched_clock_state(void);
 extern void tsc_restore_sched_clock_state(void);
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -75,7 +75,7 @@ apm-y := apm_32.o
 obj-$(CONFIG_APM)  += apm.o
 obj-$(CONFIG_SMP)  += smp.o
 obj-$(CONFIG_SMP)  += smpboot.o
-obj-$(CONFIG_SMP)  += tsc_sync.o
+obj-$(CONFIG_X86_TSC)  += tsc_sync.o
 obj-$(CONFIG_SMP)  += setup_percpu.o
 obj-$(CONFIG_X86_MPPARSE)  += mpparse.o
 obj-y  += apic/
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1365,6 +1365,8 @@ void __init tsc_init(void)
 
if (unsynchronized_tsc())
mark_tsc_unstable("TSCs unsynchronized");
+   else
+   tsc_store_and_check_tsc_adjust();
 
check_system_tsc_reliable();
 
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -14,12 +14,95 @@
  * ( The serial nature of the boot logic and the CPU hotplug lock
  *   protects against more than 2 CPUs entering this code. )
  */
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
+struct tsc_adjust {
+   s64 bootval;
+   s64 adjusted;
+};
+
+static DEFINE_PER_CPU(struct tsc_adjust, tsc_adjust);
+
+#ifndef CONFIG_SMP
+void __init tsc_store_and_check_tsc_adjust(void)
+{
+   struct tsc_adjust *ref, *cur = this_cpu_ptr(_adjust);
+   s64 bootval;
+
+   if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
+   return;
+
+   rdmsrl(MSR_IA32_TSC_ADJUST, bootval);
+   cur->bootval = bootval;
+   cur->adjusted = bootval;
+   pr_info("TSC ADJUST: Boot CPU%u: %lld\n",cpu,  bootval);
+}
+
+#else /* !CONFIG_SMP */
+
+/*
+ * Store and check the TSC ADJUST MSR if available
+ */
+void tsc_store_and_check_tsc_adjust(void)
+{
+   struct tsc_adjust *ref, *cur = this_cpu_ptr(_adjust);
+   unsigned int refcpu, cpu = smp_processor_id();
+   s64 bootval;
+
+   if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
+   return;
+
+   rdmsrl(MSR_IA32_TSC_ADJUST, bootval);
+   cur->bootval = bootval;
+
+   /*
+* Check whether this CPU is the first in a package to come up. In
+   

[patch 7/8] x86/tsc: Prepare warp test for TSC adjustment

2016-11-19 Thread Thomas Gleixner
To allow TSC compensation cross nodes its necessary to know in which
direction the TSC warp was observed. Return the maximum observed value on
the calling CPU so the caller can determine the direction later.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/tsc_sync.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -151,9 +151,9 @@ static int random_warps;
  * TSC-warp measurement loop running on both CPUs.  This is not called
  * if there is no TSC.
  */
-static void check_tsc_warp(unsigned int timeout)
+static cycles_t check_tsc_warp(unsigned int timeout)
 {
-   cycles_t start, now, prev, end;
+   cycles_t start, now, prev, end, cur_max_warp = 0;
int i, cur_warps = 0;
 
start = rdtsc_ordered();
@@ -194,6 +194,7 @@ static void check_tsc_warp(unsigned int
if (unlikely(prev > now)) {
arch_spin_lock(_lock);
max_warp = max(max_warp, prev - now);
+   cur_max_warp = max_warp;
/*
 * Check whether this bounces back and forth. Only
 * one CPU should observe time going backwards.
@@ -208,6 +209,7 @@ static void check_tsc_warp(unsigned int
WARN(!(now-start),
"Warning: zero tsc calibration delta: %Ld [max: %Ld]\n",
now-start, end-start);
+   return cur_max_warp;
 }
 
 /*




[patch 8/8] x86/tsc: Try to adjust TSC if sync test fails

2016-11-19 Thread Thomas Gleixner
If the first CPU of a package comes online, it is necessary to test whether
the TSC is in sync with a CPU on some other package. When a deviation is
observed (time going backward between the two CPUs) the TSC is marked
unstable, which is a problem on large machines as they have to fall back to
the HPET clocksource, which is insanely slow.

It has been attempted to compensate the TSC by adding the offset to the TSC
and writing it back earlier, but it got dropped because it did not turn out
to be stable, especially not on older systems.

Modern systems have become more stable in that regard and the TSC_ADJUST
MSR allows us to compensate for the time deviation in a sane way. If it's
available allow up to three synchronization runs and if a time warp is
detected the starting CPU can compensate the time warp via the TSC_ADJUST
MSR and retry. If the third run still shows a deviation or when random time
warps are detected the test terminally fails.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/tsc_sync.c |   83 ++---
 1 file changed, 78 insertions(+), 5 deletions(-)

--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -134,6 +134,7 @@ bool tsc_store_and_check_tsc_adjust(void
 static atomic_t start_count;
 static atomic_t stop_count;
 static atomic_t skip_test;
+static atomic_t test_runs;
 
 /*
  * We use a raw spinlock in this exceptional case, because
@@ -254,6 +255,16 @@ void check_tsc_sync_source(int cpu)
}
 
/*
+* Set the maximum number of test runs to
+*  1 if the CPU does not provide the TSC_ADJUST MSR
+*  3 if the MSR is available, so the target can try to adjust
+*/
+   if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
+   atomic_set(_runs, 1);
+   else
+   atomic_set(_runs, 3);
+retry:
+   /*
 * Wait for the target to start or to skip the test:
 */
while (atomic_read(_count) != cpus - 1) {
@@ -274,7 +285,21 @@ void check_tsc_sync_source(int cpu)
while (atomic_read(_count) != cpus-1)
cpu_relax();
 
-   if (nr_warps) {
+   /*
+* If the test was successful set the number of runs to zero and
+* stop. If not, decrement the number of runs an check if we can
+* retry. In case of random warps no retry is attempted.
+*/
+   if (!nr_warps) {
+   atomic_set(_runs, 0);
+
+   pr_debug("TSC synchronization [CPU#%d -> CPU#%d]: passed\n",
+   smp_processor_id(), cpu);
+
+   } else if (atomic_dec_and_test(_runs) || random_warps) {
+   /* Force it to 0 if random warps brought us here */
+   atomic_set(_runs, 0);
+
pr_warning("TSC synchronization [CPU#%d -> CPU#%d]:\n",
smp_processor_id(), cpu);
pr_warning("Measured %Ld cycles TSC warp between CPUs, "
@@ -282,9 +307,6 @@ void check_tsc_sync_source(int cpu)
if (random_warps)
pr_warning("TSC warped randomly between CPUs\n");
mark_tsc_unstable("check_tsc_sync_source failed");
-   } else {
-   pr_debug("TSC synchronization [CPU#%d -> CPU#%d]: passed\n",
-   smp_processor_id(), cpu);
}
 
/*
@@ -300,6 +322,12 @@ void check_tsc_sync_source(int cpu)
 * Let the target continue with the bootup:
 */
atomic_inc(_count);
+
+   /*
+* Retry, if there is a chance to do so.
+*/
+   if (atomic_read(_runs) > 0)
+   goto retry;
 }
 
 /*
@@ -307,6 +335,9 @@ void check_tsc_sync_source(int cpu)
  */
 void check_tsc_sync_target(void)
 {
+   struct tsc_adjust *cur = this_cpu_ptr(_adjust);
+   unsigned int cpu = smp_processor_id();
+   cycles_t cur_max_warp, gbl_max_warp;
int cpus = 2;
 
/* Also aborts if there is no TSC. */
@@ -322,6 +353,7 @@ void check_tsc_sync_target(void)
return;
}
 
+retry:
/*
 * Register this CPU's participation and wait for the
 * source CPU to start the measurement:
@@ -330,7 +362,12 @@ void check_tsc_sync_target(void)
while (atomic_read(_count) != cpus)
cpu_relax();
 
-   check_tsc_warp(loop_timeout(smp_processor_id()));
+   cur_max_warp = check_tsc_warp(loop_timeout(cpu));
+
+   /*
+* Store the maximum observed warp value for a potential retry:
+*/
+   gbl_max_warp = max_warp;
 
/*
 * Ok, we are done:
@@ -347,6 +384,42 @@ void check_tsc_sync_target(void)
 * Reset it for the next sync test:
 */
atomic_set(_count, 0);
+
+   /*
+* Check the number of remaining test runs. If not zero, the test
+* failed and a retry with adjusted TSC is possible. If zero the
+* test was either successful or failed terminally.
+*/
+   if 

Re: Synopsys Ethernet QoS Driver

2016-11-19 Thread Rabin Vincent
On Fri, Nov 18, 2016 at 02:20:27PM +, Joao Pinto wrote:
> For now we are interesting in improving the synopsys QoS driver under
> /nect/ethernet/synopsys. For now the driver structure consists of a single 
> file
> called dwc_eth_qos.c, containing synopsys ethernet qos common ops and platform
> related stuff.
> 
> Our strategy would be:
> 
> a) Implement a platform glue driver (dwc_eth_qos_pltfm.c)
> b) Implement a pci glue driver (dwc_eth_qos_pci.c)
> c) Implement a "core driver" (dwc_eth_qos.c) that would only have Ethernet QoS
> related stuff to be reused by the platform / pci drivers
> d) Add a set of features to the "core driver" that we have available 
> internally

Note that there are actually two drivers in mainline for this hardware:

 drivers/net/ethernet/synopsis/
 drivers/net/ethernet/stmicro/stmmac/

(See http://lists.openwall.net/netdev/2016/02/29/127)

The former only supports 4.x of the hardware.

The later supports 4.x and 3.x and already has a platform glue driver
with support for several platforms, a PCI glue driver, and a core driver
with several features not present in the former (for example: TX/RX
interrupt coalescing, EEE, PTP).

Have you evaluated both drivers?  Why have you decided to work on the
former rather than the latter?


Re: [PATCH] staging: iio: ad9832:

2016-11-19 Thread Eva Rachel Retuya
On Sat, Nov 19, 2016 at 12:08:34PM +0100, Christophe JAILLET wrote:
> Commit a98461d79ba5 ("staging: iio: ad9832: add DVDD regulator") and
> commit 43a07e48af44 ("staging: iio: ad9832: clean-up regulator 'reg'") add
> some dereference of 'st' which is an un-initialized pointer at this point.
> 
> Re-order code and tweak error handling in order to allocate memory and have
> 'st' be a valid pointer before using it.

Hello,

Thanks for the patch but this fix was already submitted and applied:
https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/commit/?h=testing=6826fdbd2e207f8107e65c5a372ac616e7af11b4

Eva

> 
> Fixes: a98461d79ba5 ("staging: iio: ad9832: add DVDD regulator")
> Fixes: 43a07e48af44 ("staging: iio: ad9832: clean-up regulator 'reg'")
> 
> Signed-off-by: Christophe JAILLET 
> ---
> Compile tested only
> ---
>  drivers/staging/iio/frequency/ad9832.c | 19 +--
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/iio/frequency/ad9832.c 
> b/drivers/staging/iio/frequency/ad9832.c
> index 639047fade30..16894836f982 100644
> --- a/drivers/staging/iio/frequency/ad9832.c
> +++ b/drivers/staging/iio/frequency/ad9832.c
> @@ -211,6 +211,15 @@ static int ad9832_probe(struct spi_device *spi)
>   return -ENODEV;
>   }
>  
> + indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + spi_set_drvdata(spi, indio_dev);
> + st = iio_priv(indio_dev);
> + st->mclk = pdata->mclk;
> + st->spi = spi;
> +
>   st->avdd = devm_regulator_get(>dev, "avdd");
>   if (IS_ERR(st->avdd))
>   return PTR_ERR(st->avdd);
> @@ -233,16 +242,6 @@ static int ad9832_probe(struct spi_device *spi)
>   goto error_disable_avdd;
>   }
>  
> - indio_dev = devm_iio_device_alloc(>dev, sizeof(*st));
> - if (!indio_dev) {
> - ret = -ENOMEM;
> - goto error_disable_dvdd;
> - }
> - spi_set_drvdata(spi, indio_dev);
> - st = iio_priv(indio_dev);
> - st->mclk = pdata->mclk;
> - st->spi = spi;
> -
>   indio_dev->dev.parent = >dev;
>   indio_dev->name = spi_get_device_id(spi)->name;
>   indio_dev->info = _info;
> -- 
> 2.9.3
> 


Re: [PATCH v3 3/6] iio: adc: Add support for STM32 ADC

2016-11-19 Thread Jonathan Cameron
On 15/11/16 15:30, Fabrice Gasnier wrote:
> This patch adds support for STMicroelectronics STM32 MCU's analog to
> digital converter.
> 
> Signed-off-by: Fabrice Gasnier 
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Very nice driver!

Thanks,

Jonathan
> ---
>  drivers/iio/adc/Kconfig |  10 +
>  drivers/iio/adc/Makefile|   1 +
>  drivers/iio/adc/stm32-adc.c | 518 
> 
>  3 files changed, 529 insertions(+)
>  create mode 100644 drivers/iio/adc/stm32-adc.c
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index ff30239..f93b990 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -432,6 +432,16 @@ config STM32_ADC_CORE
> This driver can also be built as a module.  If so, the module
> will be called stm32-adc-core.
>  
> +config STM32_ADC
> + tristate "STMicroelectronics STM32 adc"
> + depends on STM32_ADC_CORE
> + help
> +   Say yes here to build support for STMicroelectronics stm32 Analog
> +   to Digital Converter (ADC).
> +
> +   This driver can also be built as a module.  If so, the module
> +   will be called stm32-adc.
> +
>  config STX104
>   tristate "Apex Embedded Systems STX104 driver"
>   depends on X86 && ISA_BUS_API
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index a1e8f44..8e02a94 100644
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -42,6 +42,7 @@ obj-$(CONFIG_QCOM_SPMI_VADC) += qcom-spmi-vadc.o
>  obj-$(CONFIG_ROCKCHIP_SARADC) += rockchip_saradc.o
>  obj-$(CONFIG_STX104) += stx104.o
>  obj-$(CONFIG_STM32_ADC_CORE) += stm32-adc-core.o
> +obj-$(CONFIG_STM32_ADC) += stm32-adc.o
>  obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o
>  obj-$(CONFIG_TI_ADC0832) += ti-adc0832.o
>  obj-$(CONFIG_TI_ADC12138) += ti-adc12138.o
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> new file mode 100644
> index 000..5715e79
> --- /dev/null
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -0,0 +1,518 @@
> +/*
> + * This file is part of STM32 ADC driver
> + *
> + * Copyright (C) 2016, STMicroelectronics - All Rights Reserved
> + * Author: Fabrice Gasnier .
> + *
> + * License type: GPLv2
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published 
> by
> + * the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> + * or FITNESS FOR A PARTICULAR PURPOSE.
> + * See the GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program. If not, see .
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "stm32-adc-core.h"
> +
> +/* STM32F4 - Registers for each ADC instance */
> +#define STM32F4_ADC_SR   0x00
> +#define STM32F4_ADC_CR1  0x04
> +#define STM32F4_ADC_CR2  0x08
> +#define STM32F4_ADC_SMPR10x0C
> +#define STM32F4_ADC_SMPR20x10
> +#define STM32F4_ADC_HTR  0x24
> +#define STM32F4_ADC_LTR  0x28
> +#define STM32F4_ADC_SQR1 0x2C
> +#define STM32F4_ADC_SQR2 0x30
> +#define STM32F4_ADC_SQR3 0x34
> +#define STM32F4_ADC_JSQR 0x38
> +#define STM32F4_ADC_JDR1 0x3C
> +#define STM32F4_ADC_JDR2 0x40
> +#define STM32F4_ADC_JDR3 0x44
> +#define STM32F4_ADC_JDR4 0x48
> +#define STM32F4_ADC_DR   0x4C
> +
> +/* STM32F4_ADC_SR - bit fields */
> +#define STM32F4_STRT BIT(4)
> +#define STM32F4_EOC  BIT(1)
> +
> +/* STM32F4_ADC_CR1 - bit fields */
> +#define STM32F4_SCAN BIT(8)
> +#define STM32F4_EOCIEBIT(5)
> +
> +/* STM32F4_ADC_CR2 - bit fields */
> +#define STM32F4_SWSTART  BIT(30)
> +#define STM32F4_EXTEN_MASK   GENMASK(29, 28)
> +#define STM32F4_EOCS BIT(10)
> +#define STM32F4_ADON BIT(0)
> +
> +/* STM32F4_ADC_SQR1 - bit fields */
> +#define STM32F4_L_SHIFT  20
> +#define STM32F4_L_MASK   GENMASK(23, 20)
> +
> +/* STM32F4_ADC_SQR3 - bit fields */
> +#define STM32F4_SQ1_SHIFT0
> +#define STM32F4_SQ1_MASK GENMASK(4, 0)
> +
> +#define STM32_ADC_TIMEOUT_US 10
> +#define STM32_ADC_TIMEOUT(msecs_to_jiffies(STM32_ADC_TIMEOUT_US / 1000))
> +
> +/**
> + * struct stm32_adc - private data of each ADC IIO instance
> + * @common:  reference to ADC 

Re: [PATCH 1/2] staging: iio: ad7606: replace range/range_available with corresponding scale

2016-11-19 Thread Jonathan Cameron
On 14/11/16 23:12, Linus Walleij wrote:
> On Mon, Nov 14, 2016 at 7:53 PM, Lars-Peter Clausen  wrote:
> 
>> It's about figuring out the setting of a "GPIO" that can't be changed from
>> software.
>>
>> Devices sometimes, instead of a configuration bus like I2C or SPI, use
>> simple input pins, that can either be set to high or low, to allow software
>> the state of the device. The GPIO API is typically used to configure these 
>> pins.
>>
>> This works fine as long as the pin is connected to a GPIO. But sometimes the
>> system designer decides that a settings does not need to be configurable, in
>> this case the pin will be tied to logic low or high directly on the PCB
>> without any GPIO controller being involved.
>>
>> Sometimes a driver wants to know how the pin is wired up so it can report to
>> userspace this part runs in the following mode and the mode can't be
>> changed. In a sense it is like a reverse GPIO hog.
>>
>> Considering that this is a common usecase the question was how this can be
>> implemented in a driver independent way to avoid code duplication and
>> slightly different variations of what is effectively the same DT/ACPI 
>> binding.
>>
>> E.g. lets say for a configurable pin you use
>>
>> range-gpio = < ...>;
>>
>> and for a static pin
>>
>> range-gpio-fixed = <1>;
>>
>> Or something similar.
> 
> Aha I understand.
> 
> Usually I feel we need not shoehorn stuff into GPIO because it is convenient,
> it might be best to leave the GPIO optional and if it is not there, look for
> a custom attribute that represents the "hogging" to 0/1. I think trying
> to extend GPIO bindings to cover it is overgeneralization, instead go
> for a local binding for this kind of devices.
> 
> But mainly it is a question to the DT bindings maintainers.
That's a reasonable approach, but I'd certainly like to see a generic binding
to describe it.  It's a pretty common situation.

Seems more likely we'll get a device tree maintainer response if we cc them ;)

So Mark, Rob and thoughts on this?

Thanks,

Jonathan
> 
> Yours,
> Linus Walleij
> 



Hopefully

2016-11-19 Thread Rita Micheal
Hi friend I am a banker in ADB BANK. I want to transfer an abandoned
$25.5Million to your Bank account. 40/percent will be your share.
No risks involved but keep it as secret. Contact me for more details
And also acknowledge receipt of this message in acceptance of my
mutual business Endeavour by furnishing me with the following:
1. Your Full Names and Address.
2. Direct Telephone and Fax numbers
Please reply in my private email address (michealrit...@yahoo.fr) for
security and confidential reasons.
Yours
Miss Rita Micheal


Re: [PATCH v2] iio: magnetometer: separate the values of attributes based on their usage type for HID compass sensor

2016-11-19 Thread Jonathan Cameron
On 16/11/16 09:43, Ooi, Joyce wrote:
> There are 2 usage types (Magnetic Flux and Heading data field) for HID
> compass sensor, thus the values of offset, scale, and sensitivity should
> be separated according to their respective usage type. The changes made
> are as below:
> 1. Hysteresis: A struct hid_sensor_common rot_attributes is created in
> struct magn_3d_state to contain the sensitivity for IIO_ROT.
> 2. Scale: scale_pre_decml and scale_post_decml are separated for IIO_MAGN
> and IIO_ROT.
> 3. Offset: Same as scale, value_offset is separated for IIO_MAGN and
> IIO_ROT.
> 
> For sensitivity, HID_USAGE_SENSOR_ORIENT_MAGN_FLUX and
> HID_USAGE_SENSOR_ORIENT_MAGN_HEADING are used for sensivitity fields based
> on the HID Sensor Usages specifications. Hence, these changes are added on
> the sensitivity field.
> 
> Signed-off-by: Ooi, Joyce 
I think I follow this one and it looks fine to me.  However, I would like
an Ack or review from Srinivas on this one.

Thanks,

Jonathan
> ---
>  changelog v2:
>  * rename struct hid_sensor_common common_attributes to struct
>hid_sensor_common magn_flux_attributes.
>  * create a common_attributes struct which stores scale_pre_decml,
>scale_post_decml, scale_precision, and value_offset.
>  * create struct hid_sensor_common magn_flux_attributes and rot_attributes
>for IIO_MAGN and IIO_ROT respectively.
> 
>  drivers/iio/magnetometer/hid-sensor-magn-3d.c | 147 
> --
>  1 file changed, 112 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c 
> b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> index d8a0c8d..0e791b0 100644
> --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
> @@ -42,9 +42,17 @@ enum magn_3d_channel {
>   MAGN_3D_CHANNEL_MAX,
>  };
>  
> +struct common_attributes {
> + int scale_pre_decml;
> + int scale_post_decml;
> + int scale_precision;
> + int value_offset;
> +};
> +
>  struct magn_3d_state {
>   struct hid_sensor_hub_callbacks callbacks;
> - struct hid_sensor_common common_attributes;
> + struct hid_sensor_common magn_flux_attributes;
> + struct hid_sensor_common rot_attributes;
>   struct hid_sensor_hub_attribute_info magn[MAGN_3D_CHANNEL_MAX];
>  
>   /* dynamically sized array to hold sensor values */
> @@ -52,10 +60,8 @@ struct magn_3d_state {
>   /* array of pointers to sensor value */
>   u32 *magn_val_addr[MAGN_3D_CHANNEL_MAX];
>  
> - int scale_pre_decml;
> - int scale_post_decml;
> - int scale_precision;
> - int value_offset;
> + struct common_attributes magn_flux_attr;
> + struct common_attributes rot_attr;
>  };
>  
>  static const u32 magn_3d_addresses[MAGN_3D_CHANNEL_MAX] = {
> @@ -162,41 +168,74 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev,
>   *val2 = 0;
>   switch (mask) {
>   case 0:
> - hid_sensor_power_state(_state->common_attributes, true);
> + hid_sensor_power_state(_state->magn_flux_attributes, true);
>   report_id =
>   magn_state->magn[chan->address].report_id;
>   address = magn_3d_addresses[chan->address];
>   if (report_id >= 0)
>   *val = sensor_hub_input_attr_get_raw_value(
> - magn_state->common_attributes.hsdev,
> + magn_state->magn_flux_attributes.hsdev,
>   HID_USAGE_SENSOR_COMPASS_3D, address,
>   report_id,
>   SENSOR_HUB_SYNC);
>   else {
>   *val = 0;
> - hid_sensor_power_state(_state->common_attributes,
> - false);
> + hid_sensor_power_state(
> + _state->magn_flux_attributes,
> + false);
>   return -EINVAL;
>   }
> - hid_sensor_power_state(_state->common_attributes, false);
> + hid_sensor_power_state(_state->magn_flux_attributes,
> + false);
>   ret_type = IIO_VAL_INT;
>   break;
>   case IIO_CHAN_INFO_SCALE:
> - *val = magn_state->scale_pre_decml;
> - *val2 = magn_state->scale_post_decml;
> - ret_type = magn_state->scale_precision;
> + switch (chan->type) {
> + case IIO_MAGN:
> + *val = magn_state->magn_flux_attr.scale_pre_decml;
> + *val2 = magn_state->magn_flux_attr.scale_post_decml;
> + ret_type = magn_state->magn_flux_attr.scale_precision;
> + break;
> + case IIO_ROT:
> + *val = magn_state->rot_attr.scale_pre_decml;
> + *val2 = 

[PATCH 1/2] rtc: imxdi: (trivial) fix a typo

2016-11-19 Thread Martin Kaiser
Signed-off-by: Martin Kaiser 
---
 drivers/rtc/rtc-imxdi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 8d8049bd..67b56b8 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -67,7 +67,7 @@
 #define DSR_ETAD  (1 << 21)  /* External tamper A detected */
 #define DSR_EBD   (1 << 20)  /* External boot detected */
 #define DSR_SAD   (1 << 19)  /* SCC alarm detected */
-#define DSR_TTD   (1 << 18)  /* Temperatur tamper detected */
+#define DSR_TTD   (1 << 18)  /* Temperature tamper detected */
 #define DSR_CTD   (1 << 17)  /* Clock tamper detected */
 #define DSR_VTD   (1 << 16)  /* Voltage tamper detected */
 #define DSR_WBF   (1 << 10)  /* Write Busy Flag (synchronous) */
-- 
1.7.10.4



[PATCH 2/2] rtc: imxdi: use the security violation interrupt

2016-11-19 Thread Martin Kaiser
The DryIce chipset has a dedicated security violation interrupt that is
triggered for security violations (if configured to do so). According to
the publicly available imx258 reference manual, irq 56 is used for this
interrupt.

Install a handler for the security violation interrupt. Move the code
for handling security violations from the "normal" interrupt handler
into the security violation interrupt handler.

Signed-off-by: Martin Kaiser 
---
 .../devicetree/bindings/rtc/imxdi-rtc.txt  |4 +-
 arch/arm/boot/dts/imx25.dtsi   |2 +-
 drivers/rtc/rtc-imxdi.c|   64 ++--
 3 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt 
b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
index c9d80d7..c53c7d8 100644
--- a/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
@@ -6,12 +6,12 @@ Required properties:
 - compatible: should be: "fsl,imx25-rtc"
 - reg: physical base address of the controller and length of memory mapped
   region.
-- interrupts: rtc alarm interrupt
+- interrupts: rtc alarm interrupt, dryice security violation interrupt
 
 Example:
 
 rtc@80056000 {
compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
reg = <0x80056000 2000>;
-   interrupts = <29>;
+   interrupts = <29>, <56>;
 };
diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
index 831d09a..3b754e3 100644
--- a/arch/arm/boot/dts/imx25.dtsi
+++ b/arch/arm/boot/dts/imx25.dtsi
@@ -560,7 +560,7 @@
reg = <0x53ffc000 0x4000>;
clocks = < 81>;
clock-names = "ipg";
-   interrupts = <25>;
+   interrupts = <25>, <56>;
};
};
 
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 67b56b8..9e1cf49 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -109,6 +109,7 @@
  * @rtc: pointer to rtc struct
  * @ioaddr: IO registers pointer
  * @irq: dryice normal interrupt
+ * @sec_irq: dryice security violation interrupt
  * @clk: input reference clock
  * @dsr: copy of the DSR register
  * @irq_lock: interrupt enable register (DIER) lock
@@ -121,6 +122,7 @@ struct imxdi_dev {
struct rtc_device *rtc;
void __iomem *ioaddr;
int irq;
+   int sec_irq;
struct clk *clk;
u32 dsr;
spinlock_t irq_lock;
@@ -688,24 +690,6 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id)
dier = readl(imxdi->ioaddr + DIER);
dsr = readl(imxdi->ioaddr + DSR);
 
-   /* handle the security violation event */
-   if (dier & DIER_SVIE) {
-   if (dsr & DSR_SVF) {
-   /*
-* Disable the interrupt when this kind of event has
-* happened.
-* There cannot be more than one event of this type,
-* because it needs a complex state change
-* including a main power cycle to get again out of
-* this state.
-*/
-   di_int_disable(imxdi, DIER_SVIE);
-   /* report the violation */
-   di_report_tamper_info(imxdi, dsr);
-   rc = IRQ_HANDLED;
-   }
-   }
-
/* handle write complete and write error cases */
if (dier & DIER_WCIE) {
/*If the write wait queue is empty then there is no pending
@@ -743,6 +727,40 @@ static irqreturn_t dryice_norm_irq(int irq, void *dev_id)
 }
 
 /*
+ * dryice security violation interrupt handler
+ */
+static irqreturn_t dryice_sec_irq(int irq, void *dev_id)
+{
+   struct imxdi_dev *imxdi = dev_id;
+   u32 dsr, dier;
+   irqreturn_t rc = IRQ_NONE;
+
+   dier = readl(imxdi->ioaddr + DIER);
+   dsr = readl(imxdi->ioaddr + DSR);
+
+   /* handle the security violation event */
+   if (dier & DIER_SVIE) {
+   if (dsr & DSR_SVF) {
+   /*
+* Disable the interrupt when this kind of event has
+* happened.
+* There cannot be more than one event of this type,
+* because it needs a complex state change
+* including a main power cycle to get again out of
+* this state.
+*/
+   di_int_disable(imxdi, DIER_SVIE);
+   /* report the violation */
+   di_report_tamper_info(imxdi, dsr);
+   rc = IRQ_HANDLED;
+   }
+   }
+
+   return rc;
+}
+
+
+/*
  * post the alarm event from user context so it can sleep
 

[PATCH] fs: xfs: xfs_icreate_item: constify xfs_item_ops structure

2016-11-19 Thread Bhumika Goyal
Declare the structure xfs_item_ops as const as it is only passed as an
argument to the function xfs_log_item_init. As this argument is of type
const struct xfs_item_ops *, so xfs_item_ops structures having this
property can be declared as const.
Done using Coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct xfs_item_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
expression e1,e2,e3;
@@
xfs_log_item_init(e1,e2,e3,@p)

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct xfs_item_ops i={...};

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct xfs_item_ops i;

File size before:
   textdata bss dec hex filename
737  64   8 809 329 fs/xfs/xfs_icreate_item.o

File size after:
   textdata bss dec hex filename
801   0   8 809 329 fs/xfs/xfs_icreate_item.o

Signed-off-by: Bhumika Goyal 
---
 fs/xfs/xfs_icreate_item.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index d45ca72..865ad13 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -133,7 +133,7 @@ static inline struct xfs_icreate_item *ICR_ITEM(struct 
xfs_log_item *lip)
 /*
  * This is the ops vector shared by all buf log items.
  */
-static struct xfs_item_ops xfs_icreate_item_ops = {
+static const struct xfs_item_ops xfs_icreate_item_ops = {
.iop_size   = xfs_icreate_item_size,
.iop_format = xfs_icreate_item_format,
.iop_pin= xfs_icreate_item_pin,
-- 
1.9.1



[PATCH] i2c: i2c-mux-pca954x: fix deselect enabling for device-tree

2016-11-19 Thread Peter Rosin
From: Alex Hemme 

Deselect functionality can be ignored for device-trees with
"i2c-mux-idle-disconnect" entries if no platform_data is available.
By enabling the deselect functionality outside the platform_data
block the logic works as it did in previous kernels.

Fixes: 7fcac9807175 ("i2c: i2c-mux-pca954x: convert to use an explicit i2c mux 
core")
Cc:  # v4.7+
Signed-off-by: Alex Hemme 
Signed-off-by: Ziyang Wu 
[touched up a few minor issues /peda]
Signed-off-by: Peter Rosin 
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Hi!

I got this regression report and patch off-list, and am now
feeding it on to the appropriate places.

I would like to thank Alex (and team?) for finding the bug and
providing a fix for the bug that I introduced.

Cheers,
Peter

diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c 
b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 1091346f2480..8bc3d36d2837 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -268,9 +268,9 @@ static int pca954x_probe(struct i2c_client *client,
/* discard unconfigured channels */
break;
idle_disconnect_pd = pdata->modes[num].deselect_on_exit;
-   data->deselect |= (idle_disconnect_pd
-  || idle_disconnect_dt) << num;
}
+   data->deselect |= (idle_disconnect_pd ||
+  idle_disconnect_dt) << num;
 
ret = i2c_mux_add_adapter(muxc, force, num, class);
 
-- 
2.1.4



[patch 1/8] x86/tsc: Use X86_FEATURE_TSC_ADJUST in detect_art()

2016-11-19 Thread Thomas Gleixner
The art detection uses rdmsrl_safe() to detect the availablity of the
TSC_ADJUST MSR.

That's pointless because we have a feature bit for this. Use it.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/tsc.c |   14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1043,18 +1043,20 @@ static void detect_art(void)
if (boot_cpu_data.cpuid_level < ART_CPUID_LEAF)
return;
 
-   cpuid(ART_CPUID_LEAF, _to_tsc_denominator,
- _to_tsc_numerator, unused, unused+1);
-
-   /* Don't enable ART in a VM, non-stop TSC required */
+   /* Don't enable ART in a VM, non-stop TSC and TSC_ADJUST required */
if (boot_cpu_has(X86_FEATURE_HYPERVISOR) ||
!boot_cpu_has(X86_FEATURE_NONSTOP_TSC) ||
-   art_to_tsc_denominator < ART_MIN_DENOMINATOR)
+   !boot_cpu_has(X86_FEATURE_TSC_ADJUST))
return;
 
-   if (rdmsrl_safe(MSR_IA32_TSC_ADJUST, _to_tsc_offset))
+   cpuid(ART_CPUID_LEAF, _to_tsc_denominator,
+ _to_tsc_numerator, unused, unused+1);
+
+   if (art_to_tsc_denominator < ART_MIN_DENOMINATOR)
return;
 
+   rdmsrl(MSR_IA32_TSC_ADJUST, art_to_tsc_offset);
+
/* Make this sticky over multiple CPU init calls */
setup_force_cpu_cap(X86_FEATURE_ART);
 }




[patch 4/8] x86/tsc: Verify TSC_ADJUST from idle

2016-11-19 Thread Thomas Gleixner
When entering idle, it's a good oportunity to verify that the TSC_ADJUST
MSR has not been tampered with (BIOS hiding SMM cycles). If tampering is
detected, emit a warning and restore it to the previous value.

This is especially important for machines, which mark the TSC reliable
because there is no watchdog clocksource available (SoCs).

This is not sufficient for HPC (NOHZ_FULL) situations where a CPU never
goes idle, but adding a timer to do the check periodically is not an option
either. On a machine, which has this issue, the check triggeres right
during boot, so there is a decent chance that the sysadmin will notice.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/include/asm/tsc.h |2 ++
 arch/x86/kernel/process.c  |1 +
 arch/x86/kernel/tsc_sync.c |   20 +++-
 3 files changed, 22 insertions(+), 1 deletion(-)

--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -50,8 +50,10 @@ extern void check_tsc_sync_target(void);
 
 #ifdef CONFIG_X86_TSC
 extern void tsc_store_and_check_tsc_adjust(void);
+extern void tsc_verify_tsc_adjust(void);
 #else
 static inline void tsc_store_and_check_tsc_adjust(void) { }
+static inline void tsc_verify_tsc_adjust(void) { }
 #endif
 
 extern int notsc_setup(char *);
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -277,6 +277,7 @@ void exit_idle(void)
 
 void arch_cpu_idle_enter(void)
 {
+   tsc_verify_tsc_adjust();
local_touch_nmi();
enter_idle();
 }
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -28,6 +28,24 @@ struct tsc_adjust {
 
 static DEFINE_PER_CPU(struct tsc_adjust, tsc_adjust);
 
+void tsc_verify_tsc_adjust(void)
+{
+   struct tsc_adjust *adj = this_cpu_ptr(_adjust);
+   s64 curval;
+
+   if (!boot_cpu_has(X86_FEATURE_TSC_ADJUST))
+   return;
+
+   rdmsrl(MSR_IA32_TSC_ADJUST, curval);
+   if (adj->adjusted == curval)
+   return;
+
+   pr_warn(FW_BUG "TSC ADJUST differs: CPU%u %lld --> %lld. Restoring\n",
+   smp_processor_id(), adj->adjusted, curval);
+
+   wrmsrl(MSR_IA32_TSC_ADJUST, adj->adjusted);
+}
+
 #ifndef CONFIG_SMP
 void __init tsc_store_and_check_tsc_adjust(void)
 {
@@ -40,7 +58,7 @@ void __init tsc_store_and_check_tsc_adju
rdmsrl(MSR_IA32_TSC_ADJUST, bootval);
cur->bootval = bootval;
cur->adjusted = bootval;
-   pr_info("TSC ADJUST: Boot CPU%u: %lld\n",cpu,  bootval);
+   pr_info("TSC ADJUST: Boot CPU%u: %lld\n", cpu,  bootval);
 }
 
 #else /* !CONFIG_SMP */




[patch 6/8] x86/tsc: Move sync cleanup to a safe place

2016-11-19 Thread Thomas Gleixner
Cleaning up the stop marker on the control CPU is wrong when we want to add
retry support. Move the cleanup to the starting CPU.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/tsc_sync.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -252,11 +252,6 @@ void check_tsc_sync_source(int cpu)
}
 
/*
-* Reset it - in case this is a second bootup:
-*/
-   atomic_set(_count, 0);
-
-   /*
 * Wait for the target to start or to skip the test:
 */
while (atomic_read(_count) != cpus - 1) {
@@ -345,6 +340,11 @@ void check_tsc_sync_target(void)
 */
while (atomic_read(_count) != cpus)
cpu_relax();
+
+   /*
+* Reset it for the next sync test:
+*/
+   atomic_set(_count, 0);
 }
 
 #endif /* CONFIG_SMP */




[patch 0/8] x86/tsc: Utilize TSC_ADJUST MSR

2016-11-19 Thread Thomas Gleixner
The TSC_ADJUST MSR shows whether the TSC has been modified. This is helpful
in two aspects:

1) It allows to detect BIOS wreckage, where SMM code tries to 'hide' the
   cycles spent by storing the TSC value at SMM entry and restoring it at
   SMM exit. On affected machines the TSCs run slowly out of sync up to the
   point where the clocksource watchdog (if available) detects it.

   The TSC_ADJUST MSR allows to detect the TSC modification before that and
   eventually restore it. This is also important for SoCs which have no
   watchdog clocksource and therefore TSC wreckage cannot be detected and
   acted upon.

2) All threads in a package are required to have the same TSC_ADJUST
   value. Broken BIOSes break that and as a result the TSC synchronization
   check fails.

   The TSC_ADJUST MSR allows to detect the deviation when a CPU comes
   online. If detected set it to the value of an already online CPU in the
   same package. This also allows to reduce the number of sync tests
   because with that in place the test is only required for the first CPU
   in a package.

   In principle all CPUs in a system should have the same TSC_ADJUST value
   even across packages, but with physical CPU hotplug this assumption is
   not true because the TSC starts with power on, so physical hotplug has
   to do some trickery to bring the TSC into sync with already running
   packages, which requires to use an TSC_ADJUST value different from CPUs
   which got powered earlier.

   A final enhancement is the opportunity to compensate for unsynced TSCs
   accross nodes at boot time and make the TSC usable that way. It won't
   help for TSCs which run apart due to frequency skew between packages,
   but this gets detected by the clocksource watchdog later.

This patch series implements all of the avove.

Thanks,

tglx

---
 include/asm/tsc.h |8 +
 kernel/Makefile   |2 
 kernel/process.c  |1 
 kernel/tsc.c  |   16 ++-
 kernel/tsc_sync.c |  237 +++---
 5 files changed, 244 insertions(+), 20 deletions(-)





[patch 2/8] x86/tsc: Detect random warps

2016-11-19 Thread Thomas Gleixner
If time warps can be observed then they should only ever be observed on one
CPU. If they are observed on both CPUs then the system is completely hosed.

Add a check for this condition and notify if it happens.

Signed-off-by: Thomas Gleixner 
---
 arch/x86/kernel/tsc_sync.c |   13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -37,6 +37,7 @@ static arch_spinlock_t sync_lock = __ARC
 static cycles_t last_tsc;
 static cycles_t max_warp;
 static int nr_warps;
+static int random_warps;
 
 /*
  * TSC-warp measurement loop running on both CPUs.  This is not called
@@ -45,7 +46,7 @@ static int nr_warps;
 static void check_tsc_warp(unsigned int timeout)
 {
cycles_t start, now, prev, end;
-   int i;
+   int i, cur_warps = 0;
 
start = rdtsc_ordered();
/*
@@ -85,7 +86,14 @@ static void check_tsc_warp(unsigned int
if (unlikely(prev > now)) {
arch_spin_lock(_lock);
max_warp = max(max_warp, prev - now);
+   /*
+* Check whether this bounces back and forth. Only
+* one CPU should observe time going backwards.
+*/
+   if (cur_warps != nr_warps)
+   random_warps++;
nr_warps++;
+   cur_warps = nr_warps;
arch_spin_unlock(_lock);
}
}
@@ -160,6 +168,8 @@ void check_tsc_sync_source(int cpu)
smp_processor_id(), cpu);
pr_warning("Measured %Ld cycles TSC warp between CPUs, "
   "turning off TSC clock.\n", max_warp);
+   if (random_warps)
+   pr_warning("TSC warped randomly between CPUs\n");
mark_tsc_unstable("check_tsc_sync_source failed");
} else {
pr_debug("TSC synchronization [CPU#%d -> CPU#%d]: passed\n",
@@ -170,6 +180,7 @@ void check_tsc_sync_source(int cpu)
 * Reset it - just in case we boot another CPU later:
 */
atomic_set(_count, 0);
+   random_warps = 0;
nr_warps = 0;
max_warp = 0;
last_tsc = 0;




Re: [HMM v13 16/18] mm/hmm/migrate: new memory migration helper for use with device memory

2016-11-19 Thread Jerome Glisse
On Sat, Nov 19, 2016 at 08:02:26PM +0530, Aneesh Kumar K.V wrote:
> Jérôme Glisse  writes:
> 
> > This patch add a new memory migration helpers, which migrate memory
> > backing a range of virtual address of a process to different memory
> > (which can be allocated through special allocator). It differs from
> > numa migration by working on a range of virtual address and thus by
> > doing migration in chunk that can be large enough to use DMA engine
> > or special copy offloading engine.
> >
> > Expected users are any one with heterogeneous memory where different
> > memory have different characteristics (latency, bandwidth, ...). As
> > an example IBM platform with CAPI bus can make use of this feature
> > to migrate between regular memory and CAPI device memory. New CPU
> > architecture with a pool of high performance memory not manage as
> > cache but presented as regular memory (while being faster and with
> > lower latency than DDR) will also be prime user of this patch.
> >
> > Migration to private device memory will be usefull for device that
> > have large pool of such like GPU, NVidia plans to use HMM for that.
> >
> > Signed-off-by: Jérôme Glisse 
> > Signed-off-by: Jatin Kumar 
> > Signed-off-by: John Hubbard 
> > Signed-off-by: Mark Hairgrove 
> > Signed-off-by: Sherry Cheung 
> > Signed-off-by: Subhash Gutti 
> > ---
> >  include/linux/hmm.h |  54 -
> >  mm/migrate.c| 584 
> > 
> >  2 files changed, 635 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/linux/hmm.h b/include/linux/hmm.h
> > index c79abfc..9777309 100644
> > --- a/include/linux/hmm.h
> > +++ b/include/linux/hmm.h
> > @@ -101,10 +101,13 @@ struct hmm;
> >   * HMM_PFN_EMPTY: corresponding CPU page table entry is none (pte_none() 
> > true)
> >   * HMM_PFN_FAULT: use by hmm_vma_fault() to signify which address need 
> > faulting
> >   * HMM_PFN_DEVICE: this is device memory (ie a ZONE_DEVICE page)
> > + * HMM_PFN_LOCKED: underlying struct page is lock
> >   * HMM_PFN_SPECIAL: corresponding CPU page table entry is special ie 
> > result of
> >   *  vm_insert_pfn() or vm_insert_page() and thus should not be mirror 
> > by a
> >   *  device (the entry will never have HMM_PFN_VALID set and the pfn 
> > value
> >   *  is undefine)
> > + * HMM_PFN_MIGRATE: use by hmm_vma_migrate() to signify which address can 
> > be
> > + *  migrated
> >   * HMM_PFN_UNADDRESSABLE: unaddressable device memory (ZONE_DEVICE)
> >   */
> >  typedef unsigned long hmm_pfn_t;
> > @@ -116,9 +119,11 @@ typedef unsigned long hmm_pfn_t;
> >  #define HMM_PFN_EMPTY (1 << 4)
> >  #define HMM_PFN_FAULT (1 << 5)
> >  #define HMM_PFN_DEVICE (1 << 6)
> > -#define HMM_PFN_SPECIAL (1 << 7)
> > -#define HMM_PFN_UNADDRESSABLE (1 << 8)
> > -#define HMM_PFN_SHIFT 9
> > +#define HMM_PFN_LOCKED (1 << 7)
> > +#define HMM_PFN_SPECIAL (1 << 8)
> > +#define HMM_PFN_MIGRATE (1 << 9)
> > +#define HMM_PFN_UNADDRESSABLE (1 << 10)
> > +#define HMM_PFN_SHIFT 11
> >  
> >  static inline struct page *hmm_pfn_to_page(hmm_pfn_t pfn)
> >  {
> > @@ -323,6 +328,49 @@ bool hmm_vma_fault(struct vm_area_struct *vma,
> >hmm_pfn_t *pfns);
> >  
> >  
> > +/*
> > + * struct hmm_migrate_ops - migrate operation callback
> > + *
> > + * @alloc_and_copy: alloc destination memoiry and copy source to it
> > + * @finalize_and_map: allow caller to inspect successfull migrated page
> > + *
> > + * The new HMM migrate helper hmm_vma_migrate() allow memory migration to 
> > use
> > + * device DMA engine to perform copy from source to destination memory it 
> > also
> > + * allow caller to use its own memory allocator for destination memory.
> > + *
> > + * Note that in alloc_and_copy device driver can decide not to migrate 
> > some of
> > + * the entry, for those it must clear the HMM_PFN_MIGRATE flag. The 
> > destination
> > + * page must lock and the corresponding hmm_pfn_t value in the array 
> > updated
> > + * with the HMM_PFN_MIGRATE and HMM_PFN_LOCKED flag set (and of course be a
> > + * valid entry). It is expected that the page allocated will have an 
> > elevated
> > + * refcount and that a put_page() will free the page. Device driver might 
> > want
> > + * to allocate with an extra-refcount if they want to control deallocation 
> > of
> > + * failed migration inside the finalize_and_map() callback.
> > + *
> > + * Inside finalize_and_map() device driver must use the HMM_PFN_MIGRATE 
> > flag to
> > + * determine which page have been successfully migrated.
> > + */
> > +struct hmm_migrate_ops {
> > +   void (*alloc_and_copy)(struct vm_area_struct *vma,
> > +  unsigned long start,
> > +  unsigned long end,
> > +  hmm_pfn_t *pfns,
> > +  void *private);
> > +   

Re: [RFC,2/2] hwmon: adt7411: add min, max and alarm attributes

2016-11-19 Thread Guenter Roeck
Hi Michael,

On Fri, Oct 14, 2016 at 11:43:35AM +0200, Michael Walle wrote:
> This patch adds support for the min, max and alarm attributes of the
> voltage and temperature channels. Additionally, the temp2_fault attribute
> is supported which indicates a fault of the external temperature diode.
> 
> Signed-off-by: Michael Walle 

Sorry for the late reply. Mostly looks ok.
Couple of comments below.

Guenter

> ---
>  drivers/hwmon/adt7411.c | 306 
> ++--
>  1 file changed, 271 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c
> index 2f44cdc..c6351b8 100644
> --- a/drivers/hwmon/adt7411.c
> +++ b/drivers/hwmon/adt7411.c
> @@ -21,6 +21,21 @@
>  #include 
>  #include 
>  
> +#define ADT7411_REG_STAT_1   0x00
> +#define ADT7411_STAT_1_INT_TEMP_HIGH (1 << 0)
> +#define ADT7411_STAT_1_INT_TEMP_LOW  (1 << 1)
> +#define ADT7411_STAT_1_EXT_TEMP_HIGH_AIN1(1 << 2)
> +#define ADT7411_STAT_1_EXT_TEMP_LOW  (1 << 3)
> +#define ADT7411_STAT_1_EXT_TEMP_FAULT(1 << 4)
> +#define ADT7411_STAT_1_AIN2  (1 << 5)
> +#define ADT7411_STAT_1_AIN3  (1 << 6)
> +#define ADT7411_STAT_1_AIN4  (1 << 7)
> +#define ADT7411_REG_STAT_2   0x01
> +#define ADT7411_STAT_2_AIN5  (1 << 0)
> +#define ADT7411_STAT_2_AIN6  (1 << 1)
> +#define ADT7411_STAT_2_AIN7  (1 << 2)
> +#define ADT7411_STAT_2_AIN8  (1 << 3)
> +#define ADT7411_STAT_2_VDD   (1 << 4)

Please use BIT().

>  #define ADT7411_REG_INT_TEMP_VDD_LSB 0x03
>  #define ADT7411_REG_EXT_TEMP_AIN14_LSB   0x04
>  #define ADT7411_REG_VDD_MSB  0x06
> @@ -43,6 +58,17 @@
>  #define ADT7411_CFG3_RESERVED_BIT3   (1 << 3)
>  #define ADT7411_CFG3_REF_VDD (1 << 4)
>  
> +#define ADT7411_REG_VDD_HIGH 0x23
> +#define ADT7411_REG_VDD_LOW  0x24
> +#define ADT7411_REG_TEMP_HIGH(nr)(0x25 + 2 * (nr))
> +#define ADT7411_REG_TEMP_LOW(nr) (0x26 + 2 * (nr))
> +#define ADT7411_REG_IN_HIGH(nr)  ((nr) > 1 \
> +   ? 0x2b + 2 * ((nr)-2) \
> +   : 0x27)
> +#define ADT7411_REG_IN_LOW(nr)   ((nr) > 1 \
> +   ? 0x2c + 2 * ((nr)-2) \
> +   : 0x28)
> +
>  #define ADT7411_REG_DEVICE_ID0x4d
>  #define ADT7411_REG_MANUFACTURER_ID  0x4e
>  
> @@ -51,6 +77,30 @@
>  
>  static const unsigned short normal_i2c[] = { 0x48, 0x4a, 0x4b, 
> I2C_CLIENT_END };
>  
> +static const u8 adt7411_in_alarm_reg[] = {
> + ADT7411_REG_STAT_2,
> + ADT7411_REG_STAT_1,
> + ADT7411_REG_STAT_1,
> + ADT7411_REG_STAT_1,
> + ADT7411_REG_STAT_1,
> + ADT7411_REG_STAT_2,
> + ADT7411_REG_STAT_2,
> + ADT7411_REG_STAT_2,
> + ADT7411_REG_STAT_2,
> +};
> +
> +static const u8 adt7411_in_alarm_bits[] = {
> + ADT7411_STAT_2_VDD,
> + ADT7411_STAT_1_EXT_TEMP_HIGH_AIN1,
> + ADT7411_STAT_1_AIN2,
> + ADT7411_STAT_1_AIN3,
> + ADT7411_STAT_1_AIN4,
> + ADT7411_STAT_2_AIN5,
> + ADT7411_STAT_2_AIN6,
> + ADT7411_STAT_2_AIN7,
> + ADT7411_STAT_2_AIN8,
> +};
> +
>  struct adt7411_data {
>   struct mutex device_lock;   /* for "atomic" device accesses */
>   struct mutex update_lock;
> @@ -165,6 +215,19 @@ static struct attribute *adt7411_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(adt7411);
>  
> +static int adt7411_read_in_alarm(struct device *dev, int channel, long *val)
> +{
> + struct adt7411_data *data = dev_get_drvdata(dev);
> + struct i2c_client *client = data->client;
> + int ret;
> +
> + ret = i2c_smbus_read_byte_data(client, adt7411_in_alarm_reg[channel]);
> + if (ret < 0)
> + return ret;
> + *val = !!(ret & adt7411_in_alarm_bits[channel]);
> + return 0;
> +}
> +
>  static int adt7411_read_in_vdd(struct device *dev, u32 attr, long *val)
>  {
>   struct adt7411_data *data = dev_get_drvdata(dev);
> @@ -179,32 +242,40 @@ static int adt7411_read_in_vdd(struct device *dev, u32 
> attr, long *val)
>   return ret;
>   *val = ret * 7000 / 1024;
>   return 0;
> + case hwmon_in_min:
> + ret = i2c_smbus_read_byte_data(client, ADT7411_REG_VDD_LOW);
> + if (ret < 0)
> + return ret;
> + *val = ret * 7000 / 256;
> + return 0;
> + case hwmon_in_max:
> + ret = i2c_smbus_read_byte_data(client, ADT7411_REG_VDD_HIGH);
> + if (ret < 0)
> + return ret;
> + *val = ret * 7000 / 256;
> + case hwmon_in_alarm:
> + return 

Re: [RFC PATCH v3 12/20] x86: Decrypt trampoline area if memory encryption is active

2016-11-19 Thread Tom Lendacky
On 11/17/2016 12:09 PM, Borislav Petkov wrote:
> On Wed, Nov 09, 2016 at 06:37:08PM -0600, Tom Lendacky wrote:
>> When Secure Memory Encryption is enabled, the trampoline area must not
>> be encrypted. A CPU running in real mode will not be able to decrypt
>> memory that has been encrypted because it will not be able to use addresses
>> with the memory encryption mask.
>>
>> Signed-off-by: Tom Lendacky 
>> ---
>>  arch/x86/realmode/init.c |9 +
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
>> index 5db706f1..44ed32a 100644
>> --- a/arch/x86/realmode/init.c
>> +++ b/arch/x86/realmode/init.c
>> @@ -6,6 +6,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  struct real_mode_header *real_mode_header;
>>  u32 *trampoline_cr4_features;
>> @@ -130,6 +131,14 @@ static void __init set_real_mode_permissions(void)
>>  unsigned long text_start =
>>  (unsigned long) __va(real_mode_header->text_start);
>>  
>> +/*
>> + * If memory encryption is active, the trampoline area will need to
>> + * be in un-encrypted memory in order to bring up other processors
>> + * successfully.
>> + */
>> +sme_early_mem_dec(__pa(base), size);
>> +sme_set_mem_unenc(base, size);
> 
> We're still unsure about the non-encrypted state: dec vs unenc. Please
> unify those for ease of use, code reading, etc etc.
> 
>   sme_early_decrypt(__pa(base), size);
>   sme_mark_decrypted(base, size);
> 
> or similar looks much more readable and understandable to me.

Yeah, I'll go through and change everything so that the implication
or action is expressed better.

Thanks,
Tom

> 


[PULL REQUEST] i2c for 4.9

2016-11-19 Thread Wolfram Sang
Linus,

here are some I2C driver bugfixes (and one documentation fix) for you.
Please pull. Note that I currently need to use a different email address
until the problems with my main mail provider are settled.

Thanks,

   Wolfram


The following changes since commit bc33b0ca11e3df46a4fa7639ba488c9d4911:

  Linux 4.9-rc4 (2016-11-05 16:23:36 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-current

for you to fetch changes up to ad092de60f865c1ad94221bd06d381ecea446cc8:

  i2c: i2c-mux-pca954x: fix deselect enabling for device-tree (2016-11-19 
21:49:29 +0100)


Alex Hemme (1):
  i2c: i2c-mux-pca954x: fix deselect enabling for device-tree

Linus Walleij (1):
  i2c: mux: fix up dependencies

Peter Rosin (1):
  i2c: Documentation: i2c-topology: fix minor whitespace nit

Wei Yongjun (1):
  i2c: digicolor: use clk_disable_unprepare instead of clk_unprepare

Wolfram Sang (1):
  i2c: mux: demux-pinctrl: make drivers with no pinctrl work again

 Documentation/i2c/i2c-topology|  4 ++--
 drivers/i2c/Kconfig   |  1 -
 drivers/i2c/busses/i2c-digicolor.c|  2 +-
 drivers/i2c/muxes/Kconfig |  1 +
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 22 --
 drivers/i2c/muxes/i2c-mux-pca954x.c   |  4 ++--
 6 files changed, 26 insertions(+), 8 deletions(-)


signature.asc
Description: PGP signature


Re: [05/20] hwmon/via-cputemp: Remove pointless CPU check on each CPU

2016-11-19 Thread Sebastian Andrzej Siewior
On 2016-11-19 09:23:31 [-0800], Guenter Roeck wrote:
> Applied to -next.

Thanks. Since you took that one, could you also please consider to apply
|[PATCH 06/20 v2] hwmon/via-cputemp: Convert to hotplug state machine
? It depends on the 5th patch from the series which applied.

> Thanks,
> Guenter

Sebastian


[PATCH] x86/boot: Fail the boot if !M486 and CPUID is missing

2016-11-19 Thread Andy Lutomirski
Linux will have all kinds of sporadic problems on systems that don't
have the CPUID instruction unless CONFIG_M486=y.  In particular,
sync_core() will explode.

I believe that these kernels had a better chance of working before
commit 05fb3c199bb0 ("x86/boot: Initialize FPU and X86_FEATURE_ALWAYS
even if we don't have CPUID").  That commit inadvertently fixed a
serious bug: we used to fail to detect the FPU if CPUID wasn't
present.  Because we also used to forget to set X86_FEATURE_ALWAYS, we
end up with no cpu feature bits set at all.  This meant that
alternative patching didn't do anything and, if paravirt was disabled,
we could plausibly finish the entire boot process without calling
sync_core().

Rather than trying to work around these issues, just have the kernel
fail loudly if it's running on a CPUID-less 486, doesn't have CPUID,
and doesn't have CONFIG_M486 set.

Reported-by: Matthew Whitehead 
Signed-off-by: Andy Lutomirski 
---
 arch/x86/boot/cpu.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/boot/cpu.c b/arch/x86/boot/cpu.c
index 26240dde081e..4224ede43b4e 100644
--- a/arch/x86/boot/cpu.c
+++ b/arch/x86/boot/cpu.c
@@ -87,6 +87,12 @@ int validate_cpu(void)
return -1;
}
 
+   if (CONFIG_X86_MINIMUM_CPU_FAMILY <= 4 && !IS_ENABLED(CONFIG_M486) &&
+   !has_eflag(X86_EFLAGS_ID)) {
+   printf("This kernel requires a CPU with the CPUID instruction.  
Build with CONFIG_M486=y to run on this CPU.\n");
+   return -1;
+   }
+
if (err_flags) {
puts("This kernel requires the following features "
 "not present on the CPU:\n");
-- 
2.7.4



Re: [RFC,1/2] hwmon: adt7411: update to new hwmon registration API

2016-11-19 Thread Guenter Roeck
On Fri, Oct 14, 2016 at 11:43:34AM +0200, Michael Walle wrote:
> This is also a preparation for to support more properties like min, max and
> alarm.
> 
> Signed-off-by: Michael Walle 

Passed my unit test. Applied to -next.

Thanks,
Guenter


Re: [PATCH] doc: Document the new inline struct member kernel-doc style

2016-11-19 Thread Jonathan Corbet
On Thu, 17 Nov 2016 11:19:43 +0100
Daniel Vetter  wrote:

> We don't just need better doc toolchains, we also need better docs for
> our doc toolchain!

Indeed.  Applied, thanks.

jon


[PATCH] [SCSI] dpt_i2o: Add a missing call to kfree

2016-11-19 Thread Quentin Lambert
Most error branches following the call to kzalloc contain
a call to kfree. This patch add these calls where they are
missing.

This issue was found with Hector.

Signed-off-by: Quentin Lambert 

---
 drivers/scsi/dpt_i2o.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1754,8 +1754,10 @@ static int adpt_i2o_passthru(adpt_hba* p
sg_offset = (msg[0]>>4)&0xf;
msg[2] = 0x4000; // IOCTL context
msg[3] = adpt_ioctl_to_context(pHba, reply);
-   if (msg[3] == (u32)-1)
+   if (msg[3] == (u32)-1) {
+   kfree(reply);
return -EBUSY;
+   }
 
memset(sg_list,0, sizeof(sg_list[0])*pHba->sg_tablesize);
if(sg_offset) {


[PATCH] coresight: perf: Add a missing call to etm_free_aux

2016-11-19 Thread Quentin Lambert
Most error branches following the call to alloc_event_data contain a call to
etm_free_aux. This patch add a call to etm_free_aux to an error branch
that does not call it.

This issue was found with Hector.

Signed-off-by: Quentin Lambert 
---
 drivers/hwtracing/coresight/coresight-etm-perf.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -215,7 +215,7 @@ static void *etm_setup_aux(int event_cpu
 */
sink = coresight_get_enabled_sink(true);
if (!sink)
-   return NULL;
+   goto err;
 
INIT_WORK(_data->work, free_event_data);
 


Re: [PATCH v6 4/8] drivers:input:tsc2007: add iio interface to read external ADC input and temperature

2016-11-19 Thread Dmitry Torokhov
Hi Nikolaus,

On Thu, Oct 27, 2016 at 10:44:17AM +0200, H. Nikolaus Schaller wrote:
> The tsc2007 chip not only has a resistive touch screen controller but
> also an external AUX adc imput which can be used for an ambient
> light sensor, battery voltage monitoring or any general purpose.
> 
> Additionally it can measure the chip temperature.
> 
> This extension provides an iio interface for these adc channels.
> 
> Since it is not wasting much resources and is very straightforward,
> we simply provide all other adc channels as optional iio interfaces
> as weel. This can be used for debugging or special applications.
> 
> This patch also splits the tsc2007 driver in several source files:
> tsc2007.h -- constants, structs and stubs
> tsc2007_core.c -- functional parts of the original driver
> tsc2007_iio.c -- the optional iio stuff
> 
> Makefile magic allows to conditionally link the iio
> stuff if CONFIG_IIO=y in a way that it works with
> CONFIG_TOUCHSCREEN_TSC2007=m.

What about CONFIG_TOUCHSCREEN_TSC2007=y and CONFIG_IIO=m?

> 
> Signed-off-by: H. Nikolaus Schaller 
> ---
>  drivers/input/touchscreen/Makefile |   2 +
>  drivers/input/touchscreen/tsc2007.h| 129 ++
>  .../touchscreen/{tsc2007.c => tsc2007_core.c}  | 127 ++---
>  drivers/input/touchscreen/tsc2007_iio.c| 151 
> +
>  4 files changed, 320 insertions(+), 89 deletions(-)
>  create mode 100644 drivers/input/touchscreen/tsc2007.h
>  rename drivers/input/touchscreen/{tsc2007.c => tsc2007_core.c} (84%)
>  create mode 100644 drivers/input/touchscreen/tsc2007_iio.c
> 
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 81b8645..d932e2d 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -80,6 +80,8 @@ obj-$(CONFIG_TOUCHSCREEN_TSC_SERIO) += tsc40.o
>  obj-$(CONFIG_TOUCHSCREEN_TSC200X_CORE)   += tsc200x-core.o
>  obj-$(CONFIG_TOUCHSCREEN_TSC2004)+= tsc2004.o
>  obj-$(CONFIG_TOUCHSCREEN_TSC2005)+= tsc2005.o
> +tsc2007-y:= tsc2007_core.o
> +tsc2007-$(CONFIG_IIO)+= tsc2007_iio.o
>  obj-$(CONFIG_TOUCHSCREEN_TSC2007)+= tsc2007.o
>  obj-$(CONFIG_TOUCHSCREEN_UCB1400)+= ucb1400_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001)+= wacom_w8001.o
> diff --git a/drivers/input/touchscreen/tsc2007.h 
> b/drivers/input/touchscreen/tsc2007.h
> new file mode 100644
> index 000..87d5ce5
> --- /dev/null
> +++ b/drivers/input/touchscreen/tsc2007.h
> @@ -0,0 +1,129 @@
> +/*
> + * drivers/input/touchscreen/tsc2007.h

No file names in comments please.

> + *
> + * Copyright (c) 2008 MtekVision Co., Ltd.
> + *   Kwangwoo Lee 
> + *
> + * Using code from:
> + *  - ads7846.c
> + *   Copyright (c) 2005 David Brownell
> + *   Copyright (c) 2006 Nokia Corporation
> + *  - corgi_ts.c
> + *   Copyright (C) 2004-2005 Richard Purdie
> + *  - omap_ts.[hc], ads7846.h, ts_osk.c
> + *   Copyright (C) 2002 MontaVista Software
> + *   Copyright (C) 2004 Texas Instruments
> + *   Copyright (C) 2005 Dirk Behme
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define TSC2007_MEASURE_TEMP0(0x0 << 4)
> +#define TSC2007_MEASURE_AUX  (0x2 << 4)
> +#define TSC2007_MEASURE_TEMP1(0x4 << 4)
> +#define TSC2007_ACTIVATE_XN  (0x8 << 4)
> +#define TSC2007_ACTIVATE_YN  (0x9 << 4)
> +#define TSC2007_ACTIVATE_YP_XN   (0xa << 4)
> +#define TSC2007_SETUP(0xb << 4)
> +#define TSC2007_MEASURE_X(0xc << 4)
> +#define TSC2007_MEASURE_Y(0xd << 4)
> +#define TSC2007_MEASURE_Z1   (0xe << 4)
> +#define TSC2007_MEASURE_Z2   (0xf << 4)
> +
> +#define TSC2007_POWER_OFF_IRQ_EN (0x0 << 2)
> +#define TSC2007_ADC_ON_IRQ_DIS0  (0x1 << 2)
> +#define TSC2007_ADC_OFF_IRQ_EN   (0x2 << 2)
> +#define TSC2007_ADC_ON_IRQ_DIS1  (0x3 << 2)
> +
> +#define TSC2007_12BIT(0x0 << 1)
> +#define TSC2007_8BIT (0x1 << 1)
> +
> +#define  MAX_12BIT   ((1 << 12) - 1)
> +
> +#define ADC_ON_12BIT (TSC2007_12BIT | TSC2007_ADC_ON_IRQ_DIS0)
> +
> +#define READ_Y   (ADC_ON_12BIT | TSC2007_MEASURE_Y)
> +#define READ_Z1  (ADC_ON_12BIT | TSC2007_MEASURE_Z1)
> +#define READ_Z2  (ADC_ON_12BIT | TSC2007_MEASURE_Z2)
> +#define READ_X   (ADC_ON_12BIT | TSC2007_MEASURE_X)
> +#define PWRDOWN  (TSC2007_12BIT | TSC2007_POWER_OFF_IRQ_EN)
> +
> +struct ts_event {
> + u16   

Re: [PATCH v2] mtd: nand: nandsim: fix error check

2016-11-19 Thread Boris Brezillon
On Wed, 16 Nov 2016 08:02:55 +
Sudip Mukherjee  wrote:

> debugfs_create_dir() and debugfs_create_file() returns NULL on error or
> a pointer on success. They do not return the error value with ERR_PTR.
> So we should not check the return with IS_ERR_OR_NULL, instead we
> should just check for NULL.
> 
> Signed-off-by: Sudip Mukherjee 

Applied.

Thanks,

Boris

> ---
> 
> v2: nuked err
> 
>  drivers/mtd/nand/nandsim.c | 15 +--
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
> index c76287a..c847426 100644
> --- a/drivers/mtd/nand/nandsim.c
> +++ b/drivers/mtd/nand/nandsim.c
> @@ -525,24 +525,20 @@ static int nandsim_debugfs_create(struct nandsim *dev)
>  {
>   struct nandsim_debug_info *dbg = >dbg;
>   struct dentry *dent;
> - int err;
>  
>   if (!IS_ENABLED(CONFIG_DEBUG_FS))
>   return 0;
>  
>   dent = debugfs_create_dir("nandsim", NULL);
> - if (IS_ERR_OR_NULL(dent)) {
> - int err = dent ? -ENODEV : PTR_ERR(dent);
> -
> - NS_ERR("cannot create \"nandsim\" debugfs directory, err %d\n",
> - err);
> - return err;
> + if (!dent) {
> + NS_ERR("cannot create \"nandsim\" debugfs directory\n");
> + return -ENODEV;
>   }
>   dbg->dfs_root = dent;
>  
>   dent = debugfs_create_file("wear_report", S_IRUSR,
>  dbg->dfs_root, dev, _fops);
> - if (IS_ERR_OR_NULL(dent))
> + if (!dent)
>   goto out_remove;
>   dbg->dfs_wear_report = dent;
>  
> @@ -550,8 +546,7 @@ static int nandsim_debugfs_create(struct nandsim *dev)
>  
>  out_remove:
>   debugfs_remove_recursive(dbg->dfs_root);
> - err = dent ? PTR_ERR(dent) : -ENODEV;
> - return err;
> + return -ENODEV;
>  }
>  
>  /**



Re: [PATCH] [v9]Input: evdev: fix bug of dropping valid packet after syn_dropped event

2016-11-19 Thread Dmitry Torokhov
Hi Anoroop,

On Wed, Oct 05, 2016 at 12:42:56AM +0530, Aniroop Mathur wrote:
> If last event dropped in the old queue was EV_SYN/SYN_REPORT, then lets
> generate EV_SYN/SYN_REPORT immediately after queing EV_SYN/SYN_DROPPED
> so that clients would not ignore next valid full packet events.
> 
> Signed-off-by: Aniroop Mathur 
> 
> Difference from v8:
> Added check for handling EVIOCG[type] ioctl for queue empty case
> ---
>  drivers/input/evdev.c | 52 
> ++-
>  1 file changed, 39 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
> index e9ae3d5..69407ff 100644
> --- a/drivers/input/evdev.c
> +++ b/drivers/input/evdev.c
> @@ -156,7 +156,12 @@ static void __evdev_flush_queue(struct evdev_client 
> *client, unsigned int type)
>  static void __evdev_queue_syn_dropped(struct evdev_client *client)
>  {
>   struct input_event ev;
> + struct input_event *last_ev;
>   ktime_t time;
> + unsigned int mask = client->bufsize - 1;
> +
> + /* capture last event stored in the buffer */
> + last_ev = >buffer[(client->head - 1) & mask];

I am uneasy with this "looking back" into the queue. How can we be sure
that we are looking at the right event? As far as I can tell we do not
know if that event has been consumed or not.

>  
>   time = client->clk_type == EV_CLK_REAL ?
>   ktime_get_real() :
> @@ -170,13 +175,28 @@ static void __evdev_queue_syn_dropped(struct 
> evdev_client *client)
>   ev.value = 0;
>  
>   client->buffer[client->head++] = ev;
> - client->head &= client->bufsize - 1;
> + client->head &= mask;
>  
>   if (unlikely(client->head == client->tail)) {
>   /* drop queue but keep our SYN_DROPPED event */
> - client->tail = (client->head - 1) & (client->bufsize - 1);
> + client->tail = (client->head - 1) & mask;
>   client->packet_head = client->tail;
>   }
> +
> + /*
> +  * If last packet was completely stored, then queue SYN_REPORT
> +  * so that clients would not ignore next valid full packet
> +  */
> + if (last_ev->type == EV_SYN && last_ev->code == SYN_REPORT) {
> + last_ev->time = ev.time;
> + client->buffer[client->head++] = *last_ev;
> + client->head &= mask;
> + client->packet_head = client->head;
> +
> + /* drop queue but keep our SYN_DROPPED & SYN_REPORT event */
> + if (unlikely(client->head == client->tail))
> + client->tail = (client->head - 2) & mask;
> + }
>  }
>  
>  static void evdev_queue_syn_dropped(struct evdev_client *client)
> @@ -218,7 +238,7 @@ static int evdev_set_clk_type(struct evdev_client 
> *client, unsigned int clkid)
>   spin_lock_irqsave(>buffer_lock, flags);
>  
>   if (client->head != client->tail) {
> - client->packet_head = client->head = client->tail;
> + client->packet_head = client->tail = client->head;
>   __evdev_queue_syn_dropped(client);
>   }
>  
> @@ -231,22 +251,24 @@ static int evdev_set_clk_type(struct evdev_client 
> *client, unsigned int clkid)
>  static void __pass_event(struct evdev_client *client,
>const struct input_event *event)
>  {
> + unsigned int mask = client->bufsize - 1;
> +
>   client->buffer[client->head++] = *event;
> - client->head &= client->bufsize - 1;
> + client->head &= mask;
>  
>   if (unlikely(client->head == client->tail)) {
>   /*
>* This effectively "drops" all unconsumed events, leaving
> -  * EV_SYN/SYN_DROPPED plus the newest event in the queue.
> +  * EV_SYN/SYN_DROPPED, EV_SYN/SYN_REPORT (if required) and
> +  * newest event in the queue.
>*/
> - client->tail = (client->head - 2) & (client->bufsize - 1);
> -
> - client->buffer[client->tail].time = event->time;
> - client->buffer[client->tail].type = EV_SYN;
> - client->buffer[client->tail].code = SYN_DROPPED;
> - client->buffer[client->tail].value = 0;
> + client->head = (client->head - 1) & mask;
> + client->packet_head = client->tail = client->head;
> + __evdev_queue_syn_dropped(client);
>  
> - client->packet_head = client->tail;
> + client->buffer[client->head++] = *event;
> + client->head &= mask;
> + /* No need to check for buffer overflow as it just occurred */
>   }
>  
>   if (event->type == EV_SYN && event->code == SYN_REPORT) {
> @@ -920,6 +942,7 @@ static int evdev_handle_get_val(struct evdev_client 
> *client,
>   int ret;
>   unsigned long *mem;
>   size_t len;
> + bool is_queue_empty;
>  
>   len = BITS_TO_LONGS(maxbit) * 

[PATCH v2 1/5] staging: speakup: synth.c Spaces around operators

2016-11-19 Thread Walt Feasel
Make suggested checkpatch modification for
CHECK: spaces preferred around that '+,|,-,/'

Signed-off-by: Walt Feasel 
---
v2 makes changes to correct for email format patch submission

 drivers/staging/speakup/synth.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 54b2f39..9c73a33 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -1,4 +1,4 @@
-#include 
+w#include 
 #include/* for isdigit() and friends */
 #include 
 #include   /* for verify_area */
@@ -303,11 +303,11 @@ void spk_get_index_count(int *linecount, int *sentcount)
sentence_count = ind % 10;
 
if ((ind / 10) <= synth->indexing.currindex)
-   index_count = synth->indexing.currindex-(ind/10);
+   index_count = synth->indexing.currindex - (ind / 10);
else
index_count = synth->indexing.currindex
-   -synth->indexing.lowindex
-   + synth->indexing.highindex-(ind/10)+1;
+   - synth->indexing.lowindex
+   + synth->indexing.highindex - (ind / 10) + 1;
 
}
*sentcount = sentence_count;
@@ -476,10 +476,10 @@ void synth_remove(struct spk_synth *in_synth)
break;
}
for ( ; synths[i] != NULL; i++) /* compress table */
-   synths[i] = synths[i+1];
+   synths[i] = synths[i + 1];
module_status = 0;
mutex_unlock(_mutex);
 }
 EXPORT_SYMBOL_GPL(synth_remove);
 
-short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM };
+short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM };
-- 
2.1.4



[PATCH v2 0/5] staging: speakup: synth.c checkpatch modifications

2016-11-19 Thread Walt Feasel
Make Linux kernel coding style modifications for XGI_main_26.c to include:

Spaces around operators
Blank lines before }
Logical continuation
Comment modifications
Align on parenthesis

Walt Feasel (5):
  staging: speakup: synth.c Spaces around operators
  staging: speakup: synth.c Blank line before }
  staging: speakup: synth.c Logical continuation
  staging: speakup: synth.c Comment modifications
  staging: speakup: synth.c Align parenthesis

 drivers/staging/speakup/synth.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

--
v2 makes changes to correct for email format patch submission 
2.1.4



[PATCH v2 2/5] staging: speakup: synth.c Blank line before }

2016-11-19 Thread Walt Feasel
Make suggested checkpatch modification for
CHECK: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Walt Feasel 
---
v2 makes changes to correct for email format patch submission

 drivers/staging/speakup/synth.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 9c73a33..9191a6d 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -308,7 +308,6 @@ void spk_get_index_count(int *linecount, int *sentcount)
index_count = synth->indexing.currindex
- synth->indexing.lowindex
+ synth->indexing.highindex - (ind / 10) + 1;
-
}
*sentcount = sentence_count;
*linecount = index_count;
-- 
2.1.4



[PATCH v2 3/5] staging: speakup: synth.c Logical continuation

2016-11-19 Thread Walt Feasel
Make suggested checkpatch modification for
CHECK: Logical continuations should be on the
previous line

Signed-off-by: Walt Feasel 
---
v2 makes changes to correct for email format patch submission

 drivers/staging/speakup/synth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 9191a6d..99d5cba 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -405,8 +405,8 @@ static int do_synth_init(struct spk_synth *in_synth)
speakup_register_var(var);
if (!spk_quiet_boot)
synth_printf("%s found\n", synth->long_name);
-   if (synth->attributes.name
-   && sysfs_create_group(speakup_kobj, >attributes) < 0)
+   if (synth->attributes.name && sysfs_create_group(speakup_kobj,
+>attributes) < 
0)
return -ENOMEM;
synth_flags = synth->flags;
wake_up_interruptible_all(_event);
-- 
2.1.4



[PATCH v2 5/5] staging: speakup: synth.c Align parenthesis

2016-11-19 Thread Walt Feasel
Make suggested checkpatch modification for
CHECK: Alignment should match open parenthesis

Signed-off-by: Walt Feasel 
---
v2 makes changes to correct for email format patch submission

 drivers/staging/speakup/synth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 779b918..2821a2b2 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -67,7 +67,7 @@ int spk_serial_synth_probe(struct spk_synth *synth)
return -ENODEV;
}
pr_info("%s: ttyS%i, Driver Version %s\n",
-   synth->long_name, synth->ser, synth->version);
+   synth->long_name, synth->ser, synth->version);
synth->alive = 1;
return 0;
 }
-- 
2.1.4



[PATCH v2 4/5] staging: speakup: synth.c Comment modifications

2016-11-19 Thread Walt Feasel
Make modifications to comment style

Signed-off-by: Walt Feasel 
---
v2 makes changes to correct for email format patch submission

 drivers/staging/speakup/synth.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 99d5cba..779b918 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -8,7 +8,7 @@ w#include 
 #include/* for loops_per_sec */
 #include 
 #include 
-#include  /* for copy_from_user */
+#include  /* for copy_from_user */
 #include 
 #include 
 #include 
@@ -73,7 +73,8 @@ int spk_serial_synth_probe(struct spk_synth *synth)
 }
 EXPORT_SYMBOL_GPL(spk_serial_synth_probe);
 
-/* Main loop of the progression thread: keep eating from the buffer
+/*
+ * Main loop of the progression thread: keep eating from the buffer
  * and push to the serial port, waiting as needed
  *
  * For devices that have a "full" notification mechanism, the driver can
-- 
2.1.4



Re: [Ksummit-discuss] Including images on Sphinx documents

2016-11-19 Thread Bart Van Assche
On 11/19/16 09:15, Jonathan Corbet wrote:
> Might there be a tool or an extension out there that would allow us
 > to express these diagrams in a text-friendly, editable form?

How about using the graphviz languages for generating diagrams that can 
be described easily in one of the graphviz languages? The graphviz 
programming languages are well suited for version control. And the 
graphviz software includes a tool for converting diagrams described in a 
graphviz language into many formats, including png, svg and pdf. 
Examples of diagrams generated with graphviz are available at 
http://www.graphviz.org/Gallery.php.

Bart.



Re: [RFC PATCH v3 09/20] x86: Insure that boot memory areas are mapped properly

2016-11-19 Thread Tom Lendacky
On 11/17/2016 6:20 AM, Borislav Petkov wrote:
> On Wed, Nov 09, 2016 at 06:36:20PM -0600, Tom Lendacky wrote:
>> The boot data and command line data are present in memory in an
>> un-encrypted state and are copied early in the boot process.  The early
>> page fault support will map these areas as encrypted, so before attempting
>> to copy them, add unencrypted mappings so the data is accessed properly
>> when copied.
>>
>> For the initrd, encrypt this data in place. Since the future mapping of the
>> initrd area will be mapped as encrypted the data will be accessed properly.
>>
>> Signed-off-by: Tom Lendacky 
>> ---
>>  arch/x86/include/asm/mem_encrypt.h |   13 
>>  arch/x86/kernel/head64.c   |   21 --
>>  arch/x86/kernel/setup.c|9 ++
>>  arch/x86/mm/mem_encrypt.c  |   56 
>> 
>>  4 files changed, 96 insertions(+), 3 deletions(-)
> 
> ...
> 
>> @@ -122,6 +131,12 @@ static void __init copy_bootdata(char *real_mode_data)
>>  char * command_line;
>>  unsigned long cmd_line_ptr;
>>  
>> +/*
>> + * If SME is active, this will create un-encrypted mappings of the
>> + * boot data in advance of the copy operations
> ^
> |
>   Fullstop--+
> 
>> + */
>> +sme_map_bootdata(real_mode_data);
>> +
>>  memcpy(_params, real_mode_data, sizeof boot_params);
>>  sanitize_boot_params(_params);
>>  cmd_line_ptr = get_cmd_line_ptr();
> 
> ...
> 
>> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c
>> index 06235b4..411210d 100644
>> --- a/arch/x86/mm/mem_encrypt.c
>> +++ b/arch/x86/mm/mem_encrypt.c
>> @@ -16,8 +16,11 @@
>>  
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>>  
>>  extern pmdval_t early_pmd_flags;
>> +int __init __early_make_pgtable(unsigned long, pmdval_t);
>>  
>>  /*
>>   * Since sme_me_mask is set early in the boot process it must reside in
>> @@ -126,6 +129,59 @@ void __init sme_early_mem_dec(resource_size_t paddr, 
>> unsigned long size)
>>  }
>>  }
>>  
>> +static void __init *sme_bootdata_mapping(void *vaddr, unsigned long size)
> 
> So this could be called __sme_map_bootdata(). "sme_bootdata_mapping"
> doesn't tell me what the function does as there's no verb in the name.
> 

Ok, makes sense.

>> +{
>> +unsigned long paddr = (unsigned long)vaddr - __PAGE_OFFSET;
>> +pmdval_t pmd_flags, pmd;
>> +void *ret = vaddr;
> 
> That *ret --->
> 
>> +
>> +/* Use early_pmd_flags but remove the encryption mask */
>> +pmd_flags = early_pmd_flags & ~sme_me_mask;
>> +
>> +do {
>> +pmd = (paddr & PMD_MASK) + pmd_flags;
>> +__early_make_pgtable((unsigned long)vaddr, pmd);
>> +
>> +vaddr += PMD_SIZE;
>> +paddr += PMD_SIZE;
>> +size = (size < PMD_SIZE) ? 0 : size - PMD_SIZE;
> 
>   size <= PMD_SIZE
> 
>   looks more obvious to me...

Ok, will do.

> 
>> +} while (size);
>> +
>> +return ret;
> 
> ---> is simply passing vaddr out. So the function can be just as well be
> void and you can do below:
> 
>   __sme_map_bootdata(real_mode_data, sizeof(boot_params));
> 
>   boot_data = (struct boot_params *)real_mode_data;
> 
>   ...

Ok, that simplifies the function too.

> 
>> +void __init sme_map_bootdata(char *real_mode_data)
>> +{
>> +struct boot_params *boot_data;
>> +unsigned long cmdline_paddr;
>> +
>> +if (!sme_me_mask)
>> +return;
>> +
>> +/*
>> + * The bootdata will not be encrypted, so it needs to be mapped
>> + * as unencrypted data so it can be copied properly.
>> + */
>> +boot_data = sme_bootdata_mapping(real_mode_data, sizeof(boot_params));
>> +
>> +/*
>> + * Determine the command line address only after having established
>> + * the unencrypted mapping.
>> + */
>> +cmdline_paddr = boot_data->hdr.cmd_line_ptr |
>> +((u64)boot_data->ext_cmd_line_ptr << 32);
> 
> < newline here.
> 
>> +if (cmdline_paddr)
>> +sme_bootdata_mapping(__va(cmdline_paddr), COMMAND_LINE_SIZE);
>> +}
>> +
>> +void __init sme_encrypt_ramdisk(resource_size_t paddr, unsigned long size)
>> +{
>> +if (!sme_me_mask)
>> +return;
>> +
>> +sme_early_mem_enc(paddr, size);
>> +}
> 
> So this one could simply be called sme_encrypt_area() and be used for
> other things. There's nothing special about encrypting a ramdisk, by the
> looks of it.

The sme_early_mem_enc() function is already exposed so I'll use that. I
originally had it that way but tried to hide any logic associated with
it by just calling this function.  Any changes in logic in the future
would be handled within the SME function.  But that can be done in the
future if needed.

Thanks,
Tom

> 


Re: [PATCH v6 2/8] drivers:input:tsc2007: send pendown and penup only once like ads7846(+tsc2046) driver does

2016-11-19 Thread Dmitry Torokhov
On Thu, Oct 27, 2016 at 10:44:15AM +0200, H. Nikolaus Schaller wrote:
> this should reduce unnecessary input events.

The duplicates will be filtered out by the input core anyway. I like to
keep the drivers simple.

Thanks.

> 
> Signed-off-by: H. Nikolaus Schaller 
> ---
>  drivers/input/touchscreen/tsc2007.c | 17 +
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/tsc2007.c 
> b/drivers/input/touchscreen/tsc2007.c
> index c1d9593..e9d5086 100644
> --- a/drivers/input/touchscreen/tsc2007.c
> +++ b/drivers/input/touchscreen/tsc2007.c
> @@ -94,6 +94,7 @@ struct tsc2007 {
>  
>   wait_queue_head_t   wait;
>   boolstopped;
> + boolpendown;
>  
>   int (*get_pendown_state)(struct device *);
>   void(*clear_penirq)(void);
> @@ -227,7 +228,11 @@ static irqreturn_t tsc2007_soft_irq(int irq, void 
> *handle)
>   sx, sy, rt);
>  
>   /* report event */
> - input_report_key(input, BTN_TOUCH, 1);
> + if (!ts->pendown) {
> + input_report_key(input, BTN_TOUCH, 1);
> + ts->pendown = true;
> + }
> +
>   touchscreen_report_pos(ts->input, >prop,
>   (unsigned int) sx,
>   (unsigned int) sy,
> @@ -250,9 +255,13 @@ static irqreturn_t tsc2007_soft_irq(int irq, void 
> *handle)
>  
>   dev_dbg(>client->dev, "UP\n");
>  
> - input_report_key(input, BTN_TOUCH, 0);
> - input_report_abs(input, ABS_PRESSURE, 0);
> - input_sync(input);
> + if (ts->pendown) {
> + input_report_key(input, BTN_TOUCH, 0);
> + input_report_abs(input, ABS_PRESSURE, 0);
> + input_sync(input);
> +
> + ts->pendown = false;
> + }
>  
>   if (ts->clear_penirq)
>   ts->clear_penirq();
> -- 
> 2.7.3
> 

-- 
Dmitry


[PATCH 0/3] usb: xhci: Add broken port disable quirk

2016-11-19 Thread Roger Quadros
Hi,

Some XHCI controllers e.g. dwc3 based have a broken Port disable [1].

If the attached high-speed device is misbehaving, the USB stack typically
disables the port using the PED bit in PORTSC. For the controllers that
have broken port disable, the port fails to detect further attach/detach
events and so high-speed devices can no longer be enumerated on the
port. The workaround is to prevent port disable using PED on such
controllers.

We add a new BROKEN_PED quirk flag and 'quirk-broken-port-ped' device
property and prevent port disable using PED if we encounter the quirk flag.

[1] - AM572x Silicon Errata http://www.ti.com/lit/er/sprz429j/sprz429j.pdf
Section i896— USB xHCI Port Disable Feature Does Not Work

cheers,
-roger

Felipe Balbi (3):
  usb: xhci: add quirk flag for broken PED bits
  usb: host: xhci-plat: enable BROKEN_PED quirk if platform requested
  usb: dwc3: host: pass quirk-broken-port-ped property for known broken
revisions

 Documentation/devicetree/bindings/usb/usb-xhci.txt |  1 +
 drivers/usb/dwc3/host.c| 21 ++---
 drivers/usb/host/xhci-hub.c|  6 ++
 drivers/usb/host/xhci-plat.c   |  3 +++
 drivers/usb/host/xhci.h|  3 +++
 5 files changed, 31 insertions(+), 3 deletions(-)

-- 
2.7.4



Re: [PATCH v6 7/8] drivers:input:ads7846(+tsc2046): fix spi module table

2016-11-19 Thread Dmitry Torokhov
On Thu, Oct 27, 2016 at 10:44:20AM +0200, H. Nikolaus Schaller wrote:
> Fix module table so that the driver is loaded if compiled
> as module and requested by DT.

We really need to fix it between spi/i23c core and module utils instead
of keeping adding duplicate IDs all over drivers. We already have OF
module device table containing the same data, we should be able to use
it.

Thanks.

> 
> Signed-off-by: H. Nikolaus Schaller 
> ---
>  drivers/input/touchscreen/ads7846.c | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/ads7846.c 
> b/drivers/input/touchscreen/ads7846.c
> index 400e421..50c85d2 100644
> --- a/drivers/input/touchscreen/ads7846.c
> +++ b/drivers/input/touchscreen/ads7846.c
> @@ -1532,6 +1532,16 @@ static int ads7846_remove(struct spi_device *spi)
>   return 0;
>  }
>  
> +static const struct spi_device_id ads7846_idtable[] = {
> + { "tsc2046", 0 },
> + { "ads7843", 0 },
> + { "ads7845", 0 },
> + { "ads7846", 0 },
> + { "ads7873", 0 },
> + { }
> +};
> +MODULE_DEVICE_TABLE(spi, ads7846_idtable);
> +
>  static struct spi_driver ads7846_driver = {
>   .driver = {
>   .name   = "ads7846",
> @@ -1546,4 +1556,3 @@ module_spi_driver(ads7846_driver);
>  
>  MODULE_DESCRIPTION("ADS7846 TouchScreen Driver");
>  MODULE_LICENSE("GPL");
> -MODULE_ALIAS("spi:ads7846");
> -- 
> 2.7.3
> 

-- 
Dmitry


Re: [PATCH v7 4/9] drivers:input:tsc2007: add iio interface to read external ADC input and temperature

2016-11-19 Thread Dmitry Torokhov
On Sat, Nov 12, 2016 at 02:19:30PM +, Jonathan Cameron wrote:
> On 12/11/16 14:04, Jonathan Cameron wrote:
> > On 11/11/16 19:02, H. Nikolaus Schaller wrote:
> >> The tsc2007 chip not only has a resistive touch screen controller but
> >> also an external AUX adc imput which can be used for an ambient
> >> light sensor, battery voltage monitoring or any general purpose.
> >>
> >> Additionally it can measure the chip temperature.
> >>
> >> This extension provides an iio interface for these adc channels.
> >>
> >> Since it is not wasting much resources and is very straightforward,
> >> we simply provide all other adc channels as optional iio interfaces
> >> as weel. This can be used for debugging or special applications.
> >>
> >> This patch also splits the tsc2007 driver in several source files:
> >> tsc2007.h -- constants, structs and stubs
> >> tsc2007_core.c -- functional parts of the original driver
> >> tsc2007_iio.c -- the optional iio stuff
> >>
> >> Makefile magic allows to conditionally link the iio
> >> stuff if CONFIG_IIO=y in a way that it works with
> >> CONFIG_TOUCHSCREEN_TSC2007=m.
> >>
> > 
> > I ran a quick build test and it blows up in a number of ways related to
> > the #ifdef CONFIG_IIO.
> > 
> > I'm not entirely sure why but
> > #if IS_ENABLED(CONFIG_IIO) works fine.
> Ah, I'm being sleepy today.  It's because I'm building IIO as a module
> and the symbol defined would therefore be CONFIG_IIO_MODULE.
> 
> The IS_ENABLED macro takes care of both cases.

No it doesn't. Have you tried building the driver into the kernel with
IIO as a module?

> > 
> > Otherwise looks good to me
> >> Signed-off-by: H. Nikolaus Schaller 
> > Reviewed-by: Jonathan Cameron 
> >> ---
> >>  drivers/input/touchscreen/Makefile |   2 +
> >>  drivers/input/touchscreen/tsc2007.h| 118 
> >>  .../touchscreen/{tsc2007.c => tsc2007_core.c}  | 119 ++--
> >>  drivers/input/touchscreen/tsc2007_iio.c| 152 
> >> +
> >>  4 files changed, 310 insertions(+), 81 deletions(-)
> >>  create mode 100644 drivers/input/touchscreen/tsc2007.h
> >>  rename drivers/input/touchscreen/{tsc2007.c => tsc2007_core.c} (85%)
> >>  create mode 100644 drivers/input/touchscreen/tsc2007_iio.c
> >>
> >> diff --git a/drivers/input/touchscreen/Makefile 
> >> b/drivers/input/touchscreen/Makefile
> >> index 81b8645..d932e2d 100644
> >> --- a/drivers/input/touchscreen/Makefile
> >> +++ b/drivers/input/touchscreen/Makefile
> >> @@ -80,6 +80,8 @@ obj-$(CONFIG_TOUCHSCREEN_TSC_SERIO)  += tsc40.o
> >>  obj-$(CONFIG_TOUCHSCREEN_TSC200X_CORE)+= tsc200x-core.o
> >>  obj-$(CONFIG_TOUCHSCREEN_TSC2004) += tsc2004.o
> >>  obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o
> >> +tsc2007-y := tsc2007_core.o
> >> +tsc2007-$(CONFIG_IIO) += tsc2007_iio.o
> >>  obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o
> >>  obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o
> >>  obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o
> >> diff --git a/drivers/input/touchscreen/tsc2007.h 
> >> b/drivers/input/touchscreen/tsc2007.h
> >> new file mode 100644
> >> index 000..5049bf8
> >> --- /dev/null
> >> +++ b/drivers/input/touchscreen/tsc2007.h
> >> @@ -0,0 +1,118 @@
> >> +/*
> >> + * drivers/input/touchscreen/tsc2007.h
> >> + *
> >> + * Copyright (c) 2008 MtekVision Co., Ltd.
> >> + *Kwangwoo Lee 
> >> + *
> >> + * Using code from:
> >> + *  - ads7846.c
> >> + *Copyright (c) 2005 David Brownell
> >> + *Copyright (c) 2006 Nokia Corporation
> >> + *  - corgi_ts.c
> >> + *Copyright (C) 2004-2005 Richard Purdie
> >> + *  - omap_ts.[hc], ads7846.h, ts_osk.c
> >> + *Copyright (C) 2002 MontaVista Software
> >> + *Copyright (C) 2004 Texas Instruments
> >> + *Copyright (C) 2005 Dirk Behme
> >> + *
> >> + *  This program is free software; you can redistribute it and/or modify
> >> + *  it under the terms of the GNU General Public License version 2 as
> >> + *  published by the Free Software Foundation.
> >> + */
> >> +
> >> +#include 
> >> +
> >> +#define TSC2007_MEASURE_TEMP0 (0x0 << 4)
> >> +#define TSC2007_MEASURE_AUX   (0x2 << 4)
> >> +#define TSC2007_MEASURE_TEMP1 (0x4 << 4)
> >> +#define TSC2007_ACTIVATE_XN   (0x8 << 4)
> >> +#define TSC2007_ACTIVATE_YN   (0x9 << 4)
> >> +#define TSC2007_ACTIVATE_YP_XN(0xa << 4)
> >> +#define TSC2007_SETUP (0xb << 4)
> >> +#define TSC2007_MEASURE_X (0xc << 4)
> >> +#define TSC2007_MEASURE_Y (0xd << 4)
> >> +#define TSC2007_MEASURE_Z1(0xe << 4)
> >> +#define TSC2007_MEASURE_Z2(0xf << 4)
> >> +
> >> +#define TSC2007_POWER_OFF_IRQ_EN  (0x0 << 2)
> >> +#define TSC2007_ADC_ON_IRQ_DIS0   (0x1 << 2)
> >> +#define TSC2007_ADC_OFF_IRQ_EN(0x2 

Re: [REVIEW][PATCH 0/3] Fixing ptrace vs exec vs userns interactions

2016-11-19 Thread Eric W. Biederman
ebied...@xmission.com (Eric W. Biederman) writes:

> Willy Tarreau  writes:
>
>> Hi Eric,
>>
>> On Thu, Nov 17, 2016 at 11:02:47AM -0600, Eric W. Biederman wrote:
>>> 
>>> With everyone heading to Kernel Summit and Plumbers I put this set of
>>> patches down temporarily.   Now is the time to take it back up and to
>>> make certain I am not missing something stupid in this set of patches.
>>
>> I couldn't get your patch set to apply to any of the kernels I tried,
>> I manually adjusted some parts but the second one has too many rejects.
>> What kernel should I apply this to ? Or maybe some preliminary patches
>> are needed ?
>
> It is against my for-next branch, and there is one patch in there
> that is significant.
>
> The entire patchset should be at:
> git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git 
> for-next

Grr. I typed too fast, the branch above is the base:
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git 
for-testing

should be the entire thing.

Eric


Re: [PATCH] coresight: perf: Add a missing call to etm_free_aux

2016-11-19 Thread Quentin Lambert



On 11/19/2016 07:22 PM, Quentin Lambert wrote:


On 11/19/2016 06:41 PM, Quentin Lambert wrote:
Most error branches following the call to alloc_event_data contain a 
call to

etm_free_aux. This patch add a call to etm_free_aux to an error branch
that does not call it.

This issue was found with Hector.

Signed-off-by: Quentin Lambert 
---
  drivers/hwtracing/coresight/coresight-etm-perf.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -215,7 +215,7 @@ static void *etm_setup_aux(int event_cpu
   */
  sink = coresight_get_enabled_sink(true);
  if (!sink)
-return NULL;
+goto err;
INIT_WORK(_data->work, free_event_data);

I realized that I hadn't try to compile after having sent this patch and
I wasn't able to compile it.
Therefore, please ignore it for now.

I have just confirmed that it compiles.

Quentin


Re: [REVIEW][PATCH 0/3] Fixing ptrace vs exec vs userns interactions

2016-11-19 Thread Eric W. Biederman
Willy Tarreau  writes:

> On Sat, Nov 19, 2016 at 08:17:00AM +0100, Willy Tarreau wrote:
>> Hi Eric,
>> 
>> On Thu, Nov 17, 2016 at 11:02:47AM -0600, Eric W. Biederman wrote:
>> > 
>> > With everyone heading to Kernel Summit and Plumbers I put this set of
>> > patches down temporarily.   Now is the time to take it back up and to
>> > make certain I am not missing something stupid in this set of patches.
>> 
>> I couldn't get your patch set to apply to any of the kernels I tried,
>> I manually adjusted some parts but the second one has too many rejects.
>> What kernel should I apply this to ? Or maybe some preliminary patches
>> are needed ?
>
> OK I finally managed to get it to work on top of 4.8.9 (required less changes
> than master). I also had to drop the user_ns changes since there's no such
> user_ns in mm_struct there.
>
> I could run a test on it, that looks reasonable :
>
> FS:
>
> admin@vm:~$ strace -e trace=fstat,uname,ioctl,open uname
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7f3f9a1663e3, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open(0x7ffd01bbeeb0, O_RDONLY|O_CLOEXEC) = 3
> fstat(3, {...}) = 0
> open(0x7ffd01bbee80, O_RDONLY|O_CLOEXEC) = 3
> fstat(3, {...}) = 0
> uname({...})= 0
> fstat(1, {...}) = 0
> ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7ffd01bbf400) = 0
>
> admin@vm:~$ sudo strace -e trace=fstat,uname,ioctl,open uname
> open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or 
> directory)
> open("/lib64/tls/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No 
> such file or directory)
> open("/lib64/tls/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such 
> file or directory)
> open("/lib64/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No 
> such file or directory)
> open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
> fstat(3, {st_mode=S_IFREG|0555, st_size=101312, ...}) = 0
> open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
> fstat(3, {st_mode=S_IFREG|0555, st_size=1479016, ...}) = 0
> uname({sys="Linux", node="vm", ...})= 0
> fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(4, 64), ...}) = 0
> ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 opost isig icanon echo ...}) = > 0
>
> Network:
>
> admin@vm:~$ strace -e trace=socket,setsockopt,connect /tmp/nc 198.18.3 22
> socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
> connect(3, {...}, 110)  = -1 ENOENT (No such file or 
> directory)
> socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
> connect(3, {...}, 110)  = -1 ENOENT (No such file or 
> directory)
> socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
> setsockopt(3, SOL_SOCKET, SO_REUSEADDR, 0x7ffd2c26bdbc, 4) = 0
> connect(3, {...}, 16)   = 0
>
> admin@vm:~$ sudo strace -e trace=socket,setsockopt,connect /tmp/nc 198.18.3 22
> socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
> connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT 
> (No such file or directory)
> socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
> connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT 
> (No such file or directory)
> socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
> setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> connect(3, {sa_family=AF_INET, sin_port=htons(22), 
> sin_addr=inet_addr("198.18.0.3")}, 16) = 0
>
> So in short now we can at least see what syscall fails eventhough we can't
> know why. I think it can be an acceptable trade-off.

Thanks for testing, and thanks for you acceptance even if I didn't make
it easy for you.


Eric



[PATCH] dmaengine: qcom_hidma: autoload while probing ACPI

2016-11-19 Thread Sinan Kaya
MODULE_DEVICE_TABLE is used by the kernel to determine which device driver
should be loaded for which platform device. MODULE_DEVICE_TABLE has been
only defined for the device-tree based platforms in the current code.
Defining it also for ACPI based platforms.

Signed-off-by: Sinan Kaya 
---
 drivers/dma/qcom/hidma.c  | 1 +
 drivers/dma/qcom/hidma_mgmt.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
index 248e74b..3c982c9 100644
--- a/drivers/dma/qcom/hidma.c
+++ b/drivers/dma/qcom/hidma.c
@@ -895,6 +895,7 @@ static int hidma_remove(struct platform_device *pdev)
{"QCOM8062"},
{},
 };
+MODULE_DEVICE_TABLE(acpi, hidma_acpi_ids);
 #endif
 
 static const struct of_device_id hidma_match[] = {
diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c
index 985f5ac..f847d32 100644
--- a/drivers/dma/qcom/hidma_mgmt.c
+++ b/drivers/dma/qcom/hidma_mgmt.c
@@ -282,6 +282,7 @@ static int hidma_mgmt_probe(struct platform_device *pdev)
{"QCOM8060"},
{},
 };
+MODULE_DEVICE_TABLE(acpi, hidma_mgmt_acpi_ids);
 #endif
 
 static const struct of_device_id hidma_mgmt_match[] = {
-- 
1.9.1



Re: [PULL REQUEST] Please pull rdma.git

2016-11-19 Thread Or Gerlitz
On Fri, Nov 18, 2016 at 4:01 AM, Doug Ledford  wrote:
> On 11/17/2016 5:24 PM, Or Gerlitz wrote:

[...]

> I agree with you.  It doesn't fix your patch.  The commit message can
> still be fixed up.

>> Please do not send it to Linus and wait for them to respond. I
>> disagree that it fixes my commit b/c my commit was prior to when
>> route-able RoCE  was introduced and on that time TOS had no relation.

> I agree.  A better fix tag would be the commit that added RoCEv2 support.

But this is the smaller part of the problem. The bigger part is that I
have asked for clarifications on the patch and they didn't provide
anything. So if you are picking patches where a reviewer comments are
ignored, what lesson are you teaching the submitter, that he can just
continue with this practice? why you letting this go that way?

>> does a tiny enhancement for a 10y old commit of Roland, why you think
>> we need it in 4.9-rc6 or 7??

> I don't, it's in the mlx-next branch which means I'll queue it up for
> the 4.10 merge window.  I have no plan on sending that branch for 4.9-rc.

Are you going to comment on that to the submitter? if not, they are
going to continue with this practice.

How are we supposed to realize from patchworks + your github branches
that patches that were submitted for 4.9-rc are picked for 4.10? this
is very confusing and error prone too.

Please comment also on the bunch of patches I pointed you where the
copy you have picked into your tree (pulled it from somewhere?) isn't
what was submitted.

Or.


[PATCH] drivers/usb: use READ_ONCE instead of deprecated ACCESS_ONCE

2016-11-19 Thread Davidlohr Bueso
With the new standardized functions, we can replace all ACCESS_ONCE()
calls across relevant drivers/usb/.

ACCESS_ONCE() does not work reliably on non-scalar types. For example
gcc 4.6 and 4.7 might remove the volatile tag for such accesses during
the SRA (scalar replacement of aggregates) step:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Update the new calls regardless of if it is a scalar type, this is
cleaner than having three alternatives.

Signed-off-by: Davidlohr Bueso 
---
 drivers/usb/class/cdc-wdm.c | 2 +-
 drivers/usb/core/devio.c| 2 +-
 drivers/usb/core/sysfs.c| 4 ++--
 drivers/usb/gadget/udc/gr_udc.c | 4 ++--
 drivers/usb/host/ohci-hcd.c | 2 +-
 drivers/usb/host/uhci-hcd.h | 4 ++--
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 0a6369510f2d..d31ae7d1c2ac 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -515,7 +515,7 @@ static ssize_t wdm_read
if (rv < 0)
return -ERESTARTSYS;
 
-   cntr = ACCESS_ONCE(desc->length);
+   cntr = READ_ONCE(desc->length);
if (cntr == 0) {
desc->read = 0;
 retry:
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 4016dae7433b..ffd4389fb2e2 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -153,7 +153,7 @@ static int usbfs_increase_memory_usage(unsigned amount)
 * Convert usbfs_memory_mb to bytes, avoiding overflows.
 * 0 means use the hard limit (effectively unlimited).
 */
-   lim = ACCESS_ONCE(usbfs_memory_mb);
+   lim = READ_ONCE(usbfs_memory_mb);
if (lim == 0 || lim > (USBFS_XFER_MAX >> 20))
lim = USBFS_XFER_MAX;
else
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index c953a0f1c695..048eece1884f 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -956,7 +956,7 @@ static ssize_t interface_show(struct device *dev, struct 
device_attribute *attr,
char *string;
 
intf = to_usb_interface(dev);
-   string = ACCESS_ONCE(intf->cur_altsetting->string);
+   string = READ_ONCE(intf->cur_altsetting->string);
if (!string)
return 0;
return sprintf(buf, "%s\n", string);
@@ -972,7 +972,7 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 
intf = to_usb_interface(dev);
udev = interface_to_usbdev(intf);
-   alt = ACCESS_ONCE(intf->cur_altsetting);
+   alt = READ_ONCE(intf->cur_altsetting);
 
return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X"
"ic%02Xisc%02Xip%02Xin%02X\n",
diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
index 39b7136d31d9..2af6e8a98224 100644
--- a/drivers/usb/gadget/udc/gr_udc.c
+++ b/drivers/usb/gadget/udc/gr_udc.c
@@ -1261,7 +1261,7 @@ static int gr_handle_in_ep(struct gr_ep *ep)
if (!req->last_desc)
return 0;
 
-   if (ACCESS_ONCE(req->last_desc->ctrl) & GR_DESC_IN_CTRL_EN)
+   if (READ_ONCE(req->last_desc->ctrl) & GR_DESC_IN_CTRL_EN)
return 0; /* Not put in hardware buffers yet */
 
if (gr_read32(>regs->epstat) & (GR_EPSTAT_B1 | GR_EPSTAT_B0))
@@ -1290,7 +1290,7 @@ static int gr_handle_out_ep(struct gr_ep *ep)
if (!req->curr_desc)
return 0;
 
-   ctrl = ACCESS_ONCE(req->curr_desc->ctrl);
+   ctrl = READ_ONCE(req->curr_desc->ctrl);
if (ctrl & GR_DESC_OUT_CTRL_EN)
return 0; /* Not received yet */
 
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 86612ac3fda2..cf9ac6e3d157 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -784,7 +784,7 @@ static void io_watchdog_func(unsigned long _ohci)
}
 
/* find the last TD processed by the controller. */
-   head = hc32_to_cpu(ohci, ACCESS_ONCE(ed->hwHeadP)) & TD_MASK;
+   head = hc32_to_cpu(ohci, READ_ONCE(ed->hwHeadP)) & TD_MASK;
td_start = td;
td_next = list_prepare_entry(td, >td_list, td_list);
list_for_each_entry_continue(td_next, >td_list, td_list) {
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index 6f986d82472d..033a2b46a46e 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -184,7 +184,7 @@ struct uhci_qh {
  * We need a special accessor for the element pointer because it is
  * subject to asynchronous updates by the controller.
  */
-#define qh_element(qh) ACCESS_ONCE((qh)->element)
+#define qh_element(qh) READ_ONCE((qh)->element)
 
 #define LINK_TO_QH(uhci, qh)   (UHCI_PTR_QH((uhci)) | \
cpu_to_hc32((uhci), (qh)->dma_handle))
@@ -272,7 +272,7 @@ struct uhci_td {
  * subject to asynchronous updates by the 

[PATCH] drivers/base: use READ_ONCE instead of deprecated ACCESS_ONCE

2016-11-19 Thread Davidlohr Bueso
With the new standardized functions, we can replace all ACCESS_ONCE()
calls across relevant drivers/base/.

ACCESS_ONCE() does not work reliably on non-scalar types. For example
gcc 4.6 and 4.7 might remove the volatile tag for such accesses during
the SRA (scalar replacement of aggregates) step:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

Update the new calls regardless of if it is a scalar type, this is
cleaner than having three alternatives.

Signed-off-by: Davidlohr Bueso 
---
 drivers/base/core.c  | 2 +-
 drivers/base/power/runtime.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index ce057a568673..c0b3a2a03d72 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -101,7 +101,7 @@ const char *dev_driver_string(const struct device *dev)
 * so be careful about accessing it.  dev->bus and dev->class should
 * never change once they are set, so they don't need special care.
 */
-   drv = ACCESS_ONCE(dev->driver);
+   drv = READ_ONCE(dev->driver);
return drv ? drv->name :
(dev->bus ? dev->bus->name :
(dev->class ? dev->class->name : ""));
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 60ebb04d8140..747c19286250 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -132,11 +132,11 @@ unsigned long pm_runtime_autosuspend_expiration(struct 
device *dev)
if (!dev->power.use_autosuspend)
goto out;
 
-   autosuspend_delay = ACCESS_ONCE(dev->power.autosuspend_delay);
+   autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay);
if (autosuspend_delay < 0)
goto out;
 
-   last_busy = ACCESS_ONCE(dev->power.last_busy);
+   last_busy = READ_ONCE(dev->power.last_busy);
elapsed = jiffies - last_busy;
if (elapsed < 0)
goto out;   /* jiffies has wrapped around. */
-- 
2.6.6



Re: [PATCH] ufs: qcom: Properly clear hba priv on failure

2016-11-19 Thread Subhash Jadavani

On 2016-11-18 12:55, Bjorn Andersson wrote:

In the case where we fail to acquire the phy the hba priv will be set
already, so during cleanup ufs_qcom_setup_clocks() will dereference the
now free, but still "valid looking" pointer "host".


host (ufs_qcom_host) was allocated with devm_kzalloc() so i am not sure 
why it would be freed up before probe() returns failure.



Signed-off-by: Bjorn Andersson 
---
 drivers/scsi/ufs/ufs-qcom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index d345434b084f..7bd88ffee47a 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1197,7 +1197,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
if (IS_ERR(host->generic_phy)) {
err = PTR_ERR(host->generic_phy);
dev_err(dev, "%s: PHY get failed %d\n", __func__, err);
-   goto out;
+   goto out_host_free;
}

err = ufs_qcom_bus_register(host);


--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project


Re: [PATCH] i2c: i2c-mux-pca954x: fix deselect enabling for device-tree

2016-11-19 Thread Wolfram Sang
On Sat, Nov 19, 2016 at 10:48:38AM +0100, Peter Rosin wrote:
> From: Alex Hemme 
> 
> Deselect functionality can be ignored for device-trees with
> "i2c-mux-idle-disconnect" entries if no platform_data is available.
> By enabling the deselect functionality outside the platform_data
> block the logic works as it did in previous kernels.
> 
> Fixes: 7fcac9807175 ("i2c: i2c-mux-pca954x: convert to use an explicit i2c 
> mux core")
> Cc:  # v4.7+
> Signed-off-by: Alex Hemme 
> Signed-off-by: Ziyang Wu 
> [touched up a few minor issues /peda]
> Signed-off-by: Peter Rosin 

Applied to for-current, thanks!



signature.asc
Description: PGP signature


Re: [PULL REQUEST] Please pull rdma.git

2016-11-19 Thread Doug Ledford
On 11/19/2016 2:46 PM, Or Gerlitz wrote:
> On Fri, Nov 18, 2016 at 4:01 AM, Doug Ledford  wrote:
>> On 11/17/2016 5:24 PM, Or Gerlitz wrote:
> 
> [...]
> 
>> I agree with you.  It doesn't fix your patch.  The commit message can
>> still be fixed up.
> 
>>> Please do not send it to Linus and wait for them to respond. I
>>> disagree that it fixes my commit b/c my commit was prior to when
>>> route-able RoCE  was introduced and on that time TOS had no relation.
> 
>> I agree.  A better fix tag would be the commit that added RoCEv2 support.
> 
> But this is the smaller part of the problem. The bigger part is that I
> have asked for clarifications on the patch and they didn't provide
> anything.

You asked for clarification on the commit message, I didn't hear any
objections to the content of the patch itself.

> So if you are picking patches where a reviewer comments are
> ignored, what lesson are you teaching the submitter, that he can just
> continue with this practice? why you letting this go that way?

Because I can fix up the log message at any time prior to pulling it
into my official -next branch.  Since that's all you objected to, I can
take the patch and wait for the final version of the comments.  It's not
a big deal Or.

>>> does a tiny enhancement for a 10y old commit of Roland, why you think
>>> we need it in 4.9-rc6 or 7??
> 
>> I don't, it's in the mlx-next branch which means I'll queue it up for
>> the 4.10 merge window.  I have no plan on sending that branch for 4.9-rc.
> 
> Are you going to comment on that to the submitter? if not, they are
> going to continue with this practice.

Comment on what to the submitter?  That the patch might not have been
-rc material?  I would have been OK with it around rc1 or rc2, just not
this late in the rc cycle.  In the end, I don't, nor can I, rely on
submitters to determine what's RC material and what isn't, that's what
I'm supposed to be doing.  I will always apply my own judgment on that
issue and submitters will learn over time when their patches get skipped
on any sort of a regular basis.

> How are we supposed to realize from patchworks + your github branches
> that patches that were submitted for 4.9-rc are picked for 4.10? this
> is very confusing and error prone too.

I emailed the submitters off list about it and provided them a list of
what patches went where and why.

> Please comment also on the bunch of patches I pointed you where the
> copy you have picked into your tree (pulled it from somewhere?) isn't
> what was submitted.

I'm sorry, but you'll have to refresh my memory on this issue.


-- 
Doug Ledford 
GPG Key ID: 0E572FDD



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v4] media: Driver for Toshiba et8ek8 5MP sensor

2016-11-19 Thread Sakari Ailus
Hi Pavel,

Just a few more comments...

Please check my other review as well. I believe you may have missed the
comments in between in that one.

On Sun, Oct 23, 2016 at 10:03:55PM +0200, Pavel Machek wrote:
> 
> Add driver for et8ek8 sensor, found in Nokia N900 main camera. Can be
> used for taking photos in 2.5MP resolution with fcam-dev.
> 
> Signed-off-by: Ivaylo Dimitrov 
> Signed-off-by: Pavel Machek 
> 
> ---
> From v4 I did cleanups to coding style and removed various oddities.
> 
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 2669b4b..6d01e15 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -667,6 +667,7 @@ config VIDEO_S5K5BAF
> camera sensor with an embedded SoC image signal processor.
>  
>  source "drivers/media/i2c/smiapp/Kconfig"
> +source "drivers/media/i2c/et8ek8/Kconfig"
>  
>  config VIDEO_S5C73M3
>   tristate "Samsung S5C73M3 sensor support"
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index 92773b2..5bc7bbe 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -2,6 +2,7 @@ msp3400-objs  :=  msp3400-driver.o msp3400-kthreads.o
>  obj-$(CONFIG_VIDEO_MSP3400) += msp3400.o
>  
>  obj-$(CONFIG_VIDEO_SMIAPP)   += smiapp/
> +obj-$(CONFIG_VIDEO_ET8EK8)   += et8ek8/
>  obj-$(CONFIG_VIDEO_CX25840) += cx25840/
>  obj-$(CONFIG_VIDEO_M5MOLS)   += m5mols/
>  obj-y+= soc_camera/
> diff --git a/drivers/media/i2c/et8ek8/Kconfig 
> b/drivers/media/i2c/et8ek8/Kconfig
> new file mode 100644
> index 000..1439936
> --- /dev/null
> +++ b/drivers/media/i2c/et8ek8/Kconfig
> @@ -0,0 +1,6 @@
> +config VIDEO_ET8EK8
> + tristate "ET8EK8 camera sensor support"
> + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
> + ---help---
> +   This is a driver for the Toshiba ET8EK8 5 MP camera sensor.
> +   It is used for example in Nokia N900 (RX-51).
> diff --git a/drivers/media/i2c/et8ek8/Makefile 
> b/drivers/media/i2c/et8ek8/Makefile
> new file mode 100644
> index 000..66d1b7d
> --- /dev/null
> +++ b/drivers/media/i2c/et8ek8/Makefile
> @@ -0,0 +1,2 @@
> +et8ek8-objs  += et8ek8_mode.o et8ek8_driver.o
> +obj-$(CONFIG_VIDEO_ET8EK8)   += et8ek8.o
> diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c 
> b/drivers/media/i2c/et8ek8/et8ek8_driver.c
> new file mode 100644
> index 000..0301e81
> --- /dev/null
> +++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
> @@ -0,0 +1,1588 @@
> +/*
> + * et8ek8_driver.c
> + *
> + * Copyright (C) 2008 Nokia Corporation
> + *
> + * Contact: Sakari Ailus 
> + *  Tuukka Toivonen 
> + *
> + * Based on code from Toni Leinonen .
> + *
> + * This driver is based on the Micron MT9T012 camera imager driver
> + * (C) Texas Instruments.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "et8ek8_reg.h"
> +
> +#define ET8EK8_NAME  "et8ek8"
> +#define ET8EK8_PRIV_MEM_SIZE 128
> +#define ET8EK8_MAX_MSG   48
> +
> +struct et8ek8_sensor {
> + struct v4l2_subdev subdev;
> + struct media_pad pad;
> + struct v4l2_mbus_framefmt format;
> + struct gpio_desc *reset;
> + struct regulator *vana;
> + struct clk *ext_clk;
> + u32 xclk_freq;
> +
> + u16 version;
> +
> + struct v4l2_ctrl_handler ctrl_handler;
> + struct v4l2_ctrl *exposure;
> + struct v4l2_ctrl *pixel_rate;
> + struct et8ek8_reglist *current_reglist;
> +
> + u8 priv_mem[ET8EK8_PRIV_MEM_SIZE];
> +
> + struct mutex power_lock;
> + int power_count;
> +};
> +
> +#define to_et8ek8_sensor(sd) container_of(sd, struct et8ek8_sensor, subdev)
> +
> +enum et8ek8_versions {
> + ET8EK8_REV_1 = 0x0001,
> + ET8EK8_REV_2,
> +};
> +
> +/*
> + * This table describes what should be written to the sensor register
> + * for each gain value. The gain(index in the table) is in terms of
> + * 0.1EV, i.e. 10 indexes in the table give 2 time more gain [0] in
> + * the *analog gain, [1] in the digital gain
> + *
> + * Analog gain [dB] = 20*log10(regvalue/32); 0x20..0x100
> + */
> +static struct et8ek8_gain {
> + u16 analog;
> + u16 digital;
> +} const et8ek8_gain_table[] = {
> + { 32,0},  /* x1 */
> + { 34,0},
> 

Re: [05/20] hwmon/via-cputemp: Remove pointless CPU check on each CPU

2016-11-19 Thread Guenter Roeck
On Thu, Nov 17, 2016 at 07:35:26PM +0100, Sebastian Andrzej Siewior wrote:
> From: Thomas Gleixner 
> 
> The check loop for the cpu type is pointless as we already have a cpu model
> match before that. The only thing which is not covered by that check would
> be a smp system with two different cores. Not likely to happen.
> 
> Cc: Jean Delvare 
> Cc: Guenter Roeck 
> Cc: linux-hw...@vger.kernel.org
> Signed-off-by: Thomas Gleixner 
> Signed-off-by: Sebastian Andrzej Siewior 

Applied to -next.

Thanks,
Guenter


Re: [Ksummit-discuss] Including images on Sphinx documents

2016-11-19 Thread Andrew Lunn
> Rather than beating our heads against the wall trying to convert between
> various image formats, maybe we need to take a step back.  We're trying
> to build better documentation, and there is certainly a place for
> diagrams and such in that documentation.  Johannes was asking about it
> for the 802.11 docs, and I know Paul has run into these issues with the
> RCU docs as well.  Might there be a tool or an extension out there that
> would allow us to express these diagrams in a text-friendly, editable
> form?

Hi Jonathan

A lot depends on what the diagram is supposed to show. I've used
graphviz dot in documents which get processes with Sphinx. That works
well for state machine, linked lists, etc. It uses a mainline Sphinx
extension.

It does however increase the size of your documents toolchain, you
need graphviz. But i doubt there is a distribution which does not have
it.

If you are worried about getting all these needed tools installed, i
think tools/perf might be a useful guide. When you compile it, it
gives helpful hints:

No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158
No sys/sdt.h found, no SDT events are defined, please install 
systemtap-sdt-devel or systemtap-sdt-dev

 Andrew


Re: [PATCH] Change the document about iowait

2016-11-19 Thread Jonathan Corbet
On Mon, 14 Nov 2016 11:42:41 +0800
Chao Fan  wrote:

> >Sorry for the delay on this.  Life has been...challenging...
> >  
> >> Signed-off-by: Cao Jin 
> >> Signed-off-by: Chao Fan   
> >
> >What does this signoff chain mean?
> 
> Hi jon,
> 
> I made this patch. He is my colleague who helped me a lot on
> investigating why this value decrease, so I added his s-o-b.
> I didn't know how to put the position, but both of us are
> responsible for this patch. Should I change and resend it?

The meaning of Signed-off-by is defined in the DOC, as seen in
Documentation/submitting-patches.rst.  In this case, the better approach
would have been to credit Cao Jin in the changelog, since he didn't write
the patch.

For a little documentation tweak like this it's not that big a deal,
though, so I simply gone ahead and applied it.

Thanks,

jon


Re: [PATCH v6 0/9] tpm: cleanup/fixes in existing event log support

2016-11-19 Thread Jason Gunthorpe
On Tue, Nov 15, 2016 at 10:54:53AM -0800, Jarkko Sakkinen wrote:
> On Tue, Nov 15, 2016 at 11:06:10AM -0700, Jason Gunthorpe wrote:
> > On Tue, Nov 15, 2016 at 09:40:12AM -0800, Jarkko Sakkinen wrote:
> > 
> > > I applied fix from Colin. I for OF specific patches in this patch set
> > > I do not have means to test the code paths that exercise OF specific
> > > functionality. This is what worries me a bit. If I had tested-by from
> > > someone running a system that can exercise those code paths, I would
> > > be less worried.
> > 
> > I can probably check it next week on my OF systems that do not use event log
> 
> Thanks Jason. I'll apppend your Tested-by's to the commits when you're
> done. Probably doing pull request in the latter part of next week.

What are we testing? Your master now? It will need the patch I just
sent or it will fail for me.

Jason


Re: [REVIEW][PATCH 0/3] Fixing ptrace vs exec vs userns interactions

2016-11-19 Thread Eric W. Biederman
Willy Tarreau  writes:

> Hi Eric,
>
> On Thu, Nov 17, 2016 at 11:02:47AM -0600, Eric W. Biederman wrote:
>> 
>> With everyone heading to Kernel Summit and Plumbers I put this set of
>> patches down temporarily.   Now is the time to take it back up and to
>> make certain I am not missing something stupid in this set of patches.
>
> I couldn't get your patch set to apply to any of the kernels I tried,
> I manually adjusted some parts but the second one has too many rejects.
> What kernel should I apply this to ? Or maybe some preliminary patches
> are needed ?

It is against my for-next branch, and there is one patch in there
that is significant.

The entire patchset should be at:
git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git 
for-next

Eric


Re: [tip:locking/core] locking/mutex, drm: Introduce mutex_trylock_recursive()

2016-11-19 Thread Rob Clark
On Wed, Nov 16, 2016 at 3:37 AM, tip-bot for Peter Zijlstra
 wrote:
> Commit-ID:  0f5225b024d4bffd682aab008c35862e8fdc1865
> Gitweb: http://git.kernel.org/tip/0f5225b024d4bffd682aab008c35862e8fdc1865
> Author: Peter Zijlstra 
> AuthorDate: Fri, 7 Oct 2016 17:43:51 +0200
> Committer:  Ingo Molnar 
> CommitDate: Tue, 15 Nov 2016 14:19:55 +0100
>
> locking/mutex, drm: Introduce mutex_trylock_recursive()
>
> By popular DRM demand, introduce mutex_trylock_recursive() to fix up the
> two GEM users.
>
> Without this it is very easy for these drivers to get stuck in
> low-memory situations and trigger OOM. Work is in progress to remove the
> need for this in at least i915.

btw, for the drm/msm part,

Acked-by: Rob Clark 

(and also for the following patch removing the deprecated warnings)

I would also like to rework the locking in drm/msm to be more fine
grained and not require this (as i915 plans).. I'm also just one
person with a lot else on my plate so I'm not sure I'll get around to
that quite as quickly as i915.. (otoh I'll be watching how i915
handles this, since I guess I should be able to follow the same
approach)

BR,
-R

> Signed-off-by: Peter Zijlstra (Intel) 
> Cc: Chris Wilson 
> Cc: Daniel Vetter 
> Cc: David Airlie 
> Cc: Davidlohr Bueso 
> Cc: Ding Tianhong 
> Cc: Imre Deak 
> Cc: Jason Low 
> Cc: Linus Torvalds 
> Cc: Paul E. McKenney 
> Cc: Peter Zijlstra 
> Cc: Rob Clark 
> Cc: Terry Rudd 
> Cc: Thomas Gleixner 
> Cc: Tim Chen 
> Cc: Will Deacon 
> Cc: dri-de...@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Ingo Molnar 
> ---
>  drivers/gpu/drm/i915/i915_gem_shrinker.c | 15 ---
>  drivers/gpu/drm/msm/msm_gem_shrinker.c   | 16 
>  include/linux/mutex.h| 31 +++
>  scripts/checkpatch.pl|  6 ++
>  4 files changed, 61 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c 
> b/drivers/gpu/drm/i915/i915_gem_shrinker.c
> index e9bd2a8..c450076 100644
> --- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
> @@ -227,11 +227,20 @@ unsigned long i915_gem_shrink_all(struct 
> drm_i915_private *dev_priv)
>
>  static bool i915_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
>  {
> -   if (!mutex_trylock(>struct_mutex))
> +   switch (mutex_trylock_recursive(>struct_mutex)) {
> +   case MUTEX_TRYLOCK_FAILED:
> return false;
>
> -   *unlock = true;
> -   return true;
> +   case MUTEX_TRYLOCK_SUCCESS:
> +   *unlock = true;
> +   return true;
> +
> +   case MUTEX_TRYLOCK_RECURSIVE:
> +   *unlock = false;
> +   return true;
> +   }
> +
> +   BUG();
>  }
>
>  static unsigned long
> diff --git a/drivers/gpu/drm/msm/msm_gem_shrinker.c 
> b/drivers/gpu/drm/msm/msm_gem_shrinker.c
> index 6d2e885..b77bca7 100644
> --- a/drivers/gpu/drm/msm/msm_gem_shrinker.c
> +++ b/drivers/gpu/drm/msm/msm_gem_shrinker.c
> @@ -20,13 +20,21 @@
>
>  static bool msm_gem_shrinker_lock(struct drm_device *dev, bool *unlock)
>  {
> -   if (!mutex_trylock(>struct_mutex))
> +   switch (mutex_trylock_recursive(>struct_mutex)) {
> +   case MUTEX_TRYLOCK_FAILED:
> return false;
>
> -   *unlock = true;
> -   return true;
> -}
> +   case MUTEX_TRYLOCK_SUCCESS:
> +   *unlock = true;
> +   return true;
> +
> +   case MUTEX_TRYLOCK_RECURSIVE:
> +   *unlock = false;
> +   return true;
> +   }
>
> +   BUG();
> +}
>
>  static unsigned long
>  msm_gem_shrinker_count(struct shrinker *shrinker, struct shrink_control *sc)
> diff --git a/include/linux/mutex.h b/include/linux/mutex.h
> index 4d3bcca..6a902f0 100644
> --- a/include/linux/mutex.h
> +++ b/include/linux/mutex.h
> @@ -189,4 +189,35 @@ extern void mutex_unlock(struct mutex *lock);
>
>  extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);
>
> +/*
> + * These values are chosen such that FAIL and SUCCESS match the
> + * values of the regular mutex_trylock().
> + */
> +enum mutex_trylock_recursive_enum {
> +   MUTEX_TRYLOCK_FAILED= 0,
> +   MUTEX_TRYLOCK_SUCCESS   = 1,
> +   MUTEX_TRYLOCK_RECURSIVE,
> +};
> +
> +/**
> + * mutex_trylock_recursive - trylock variant that allows recursive locking
> + * @lock: mutex to be locked
> + *
> + * This function should not be used, _ever_. It is purely for hysterical GEM
> 

Re: [PATCH] kvm: kvmclock: let KVM_GET_CLOCK return whether the master clock is in use

2016-11-19 Thread Radim Krčmář
2016-11-09 17:48+0100, Paolo Bonzini:
> Userspace can read the exact value of kvmclock by reading the TSC
> and fetching the timekeeping parameters out of guest memory.  This
> however is brittle and not necessary anymore with KVM 4.11.  Provide
> a mechanism that lets userspace know if the new KVM_GET_CLOCK
> semantics are in effect, and---since we are at it---if the clock
> is stable across all VCPUs.
> 
> Cc: Radim Krčmář 
> Cc: Marcelo Tosatti 
> Signed-off-by: Paolo Bonzini 
> ---

Applied to kvm/master, thanks.


[PATCH v3 1/5] staging: speakup: synth.c Spaces around operators

2016-11-19 Thread Walt Feasel
Make suggested checkpatch modification for
CHECK: spaces preferred around that '|,+,-,/'

Signed-off-by: Walt Feasel 
---
v3 fixes erroneous w added in v2
 drivers/staging/speakup/synth.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 54b2f39..17aa440 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -303,11 +303,11 @@ void spk_get_index_count(int *linecount, int *sentcount)
sentence_count = ind % 10;
 
if ((ind / 10) <= synth->indexing.currindex)
-   index_count = synth->indexing.currindex-(ind/10);
+   index_count = synth->indexing.currindex - (ind / 10);
else
index_count = synth->indexing.currindex
-   -synth->indexing.lowindex
-   + synth->indexing.highindex-(ind/10)+1;
+   - synth->indexing.lowindex
+   + synth->indexing.highindex - (ind / 10) + 1;
 
}
*sentcount = sentence_count;
@@ -476,10 +476,10 @@ void synth_remove(struct spk_synth *in_synth)
break;
}
for ( ; synths[i] != NULL; i++) /* compress table */
-   synths[i] = synths[i+1];
+   synths[i] = synths[i + 1];
module_status = 0;
mutex_unlock(_mutex);
 }
 EXPORT_SYMBOL_GPL(synth_remove);
 
-short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM };
+short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM };
-- 
2.1.4



Re: [PATCH] x86/dumpstack: make stack name tags more comprehensible

2016-11-19 Thread Josh Poimboeuf
On Fri, Nov 18, 2016 at 11:46:23AM -0600, Josh Poimboeuf wrote:
> NMI stack dumps are bracked by the following tags:

s/bracked/bracketed/

-- 
Josh


Re: [RFC,2/2] hwmon: adt7411: add min, max and alarm attributes

2016-11-19 Thread Guenter Roeck
On Fri, Oct 14, 2016 at 11:43:35AM +0200, Michael Walle wrote:
> This patch adds support for the min, max and alarm attributes of the
> voltage and temperature channels. Additionally, the temp2_fault attribute
> is supported which indicates a fault of the external temperature diode.
> 
> Signed-off-by: Michael Walle 
> ---
>  drivers/hwmon/adt7411.c | 306 
> ++--
>  1 file changed, 271 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c
> index 2f44cdc..c6351b8 100644
> --- a/drivers/hwmon/adt7411.c
> +++ b/drivers/hwmon/adt7411.c
[ ... ]
>  static int adt7411_read_in_vdd(struct device *dev, u32 attr, long *val)
>  {
>   struct adt7411_data *data = dev_get_drvdata(dev);
> @@ -179,32 +242,40 @@ static int adt7411_read_in_vdd(struct device *dev, u32 
> attr, long *val)
>   return ret;
>   *val = ret * 7000 / 1024;
>   return 0;
> + case hwmon_in_min:
> + ret = i2c_smbus_read_byte_data(client, ADT7411_REG_VDD_LOW);
> + if (ret < 0)
> + return ret;
> + *val = ret * 7000 / 256;
> + return 0;
> + case hwmon_in_max:
> + ret = i2c_smbus_read_byte_data(client, ADT7411_REG_VDD_HIGH);
> + if (ret < 0)
> + return ret;
> + *val = ret * 7000 / 256;

return 0;

> + case hwmon_in_alarm:
> + return adt7411_read_in_alarm(dev, 0, val);
>   default:
>   return -EOPNOTSUPP;
>   }
>  }


Re: [Ksummit-discuss] Including images on Sphinx documents

2016-11-19 Thread Mauro Carvalho Chehab
Em Sat, 19 Nov 2016 10:15:43 -0700
Jonathan Corbet  escreveu:

> On Thu, 17 Nov 2016 08:02:50 -0800
> Linus Torvalds  wrote:
> 
> > We have makefiles, but more importantly, few enough people actually
> > *generate* the documentation, that I think if it's an option to just
> > fix sphinx, we should do that instead. If it means that you have to
> > have some development version of sphinx, so be it. Most people read
> > the documentation either directly in the unprocessed text-files
> > ("source code") or on the web (by searching for pre-formatted docs)
> > that I really don't think we need to worry too much about the
> > toolchain.
> > 
> > But what we *should* worry about is having the kernel source tree
> > contain source.  
> 
> I would be happy to take a shot at fixing sphinx; we clearly need to
> engage more with sphinx upstream in general.  But I guess I still haven't
> figured out what "fixing sphinx" means in this case.
> 
> I don't know what the ultimate source of these images is (Mauro, perhaps
> you could shed some light there?).  Perhaps its SVG for some of the
> diagrams, but for the raster images, probably not; it's probably some
> weird-ass diagram-editor format.  We could put those in the tree, but
> they are likely to be harder to convert to a useful format and will raise
> all of the same obnoxious binary patch issues.

I did some research on Friday trying to identify where those images
came. It turns that, for the oldest images (before I took the media
maintainership), PDF were actually their "source", as far as I could track,
in the sense that the *.gif images were produced from the PDF.

The images seem to be generated using some LaTeX tool. Their original
format were probably EPS. I was able to convert those to SVG from their
pdf "source":


https://git.linuxtv.org/mchehab/experimental.git/commit/?h=svg-images=9baca9431d333af086c1ccd499668b5b76d35a64

I didn't check yet where the newer images came from, but I guess
that at least some of them were generated using some bitmap editor
like gimp.

> Rather than beating our heads against the wall trying to convert between
> various image formats, maybe we need to take a step back.  We're trying
> to build better documentation, and there is certainly a place for
> diagrams and such in that documentation.  Johannes was asking about it
> for the 802.11 docs, and I know Paul has run into these issues with the
> RCU docs as well.  Might there be a tool or an extension out there that
> would allow us to express these diagrams in a text-friendly, editable
> form?

I guess that a Sphinx extension for graphviz is something that we'll
need sooner or later. One of our images were clearly generated using
graphviz:
Documentation/media/uapi/v4l/pipeline.png

> With some effort, I bet we could get rid of a number of the images, and
> perhaps end up with something that makes sense when read in the .rst
> source files as an extra benefit.  But I'm not convinced that we can,
> say, sensibly express the differences between different video interlacing
> schemes that way.

Explaining visual concepts without images is really hard. Several
images that we use are there to explain things like interlacing,
point (x, y) positions of R, G and B pixels (or YUV), and even
wavelengths to show where the VBI frames are taken. There's not
much we can to do get rid of those images.

We can try to convert those to vector graphics, or encapsulate the bitmaps
inside a SVG file, but still we'll need images on documents.

Thanks,
Mauro


Re: [PATCH v2 3/3] staging: speakup: TODO Correct email

2016-11-19 Thread Chris Brannon
Walt Feasel  writes:

> Make email correction for k...@reisers.ca
>
> Signed-off-by: Walt Feasel 

Acked-by: Chris Brannon 

> ---
> v2 makes changes to correct for email format patch submission
>
>  drivers/staging/speakup/TODO | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/speakup/TODO b/drivers/staging/speakup/TODO
> index 3094799..993410c 100644
> --- a/drivers/staging/speakup/TODO
> +++ b/drivers/staging/speakup/TODO
> @@ -42,6 +42,6 @@ We prefer that you contact us on the mailing list; however, 
> if you do
>  not want to subscribe to a mailing list, send your email to all of the
>  following:
>  
> -w.d.hu...@gmail.com, ch...@the-brannons.com, k...@braille.uwo.ca and
> +w.d.hu...@gmail.com, ch...@the-brannons.com, k...@reisers.ca and
>  samuel.thiba...@ens-lyon.org.


[PATCH v2 0/2] staging: speakup: thread.c checkpatch modifications

2016-11-19 Thread Walt Feasel
Make Linux kernel style modifications for speakup to include

comment style modifications
align parenthesis

Walt Feasel (2):
  staging: speakup: thread.c Comment modifications
  staging: speakup: thread.c align on parenthesis

 drivers/staging/speakup/thread.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
v2 makes changes to correct for email format patch submission
2.1.4



[PATCH v2 1/2] staging: speakup: thread.c Comment modifications

2016-11-19 Thread Walt Feasel
Make comment style modifications

Signed-off-by: Walt Feasel 
---
v2 makes changes to correct for email format patch submission

 drivers/staging/speakup/thread.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/thread.c b/drivers/staging/speakup/thread.c
index 90c383e..e4de7dc 100644
--- a/drivers/staging/speakup/thread.c
+++ b/drivers/staging/speakup/thread.c
@@ -47,7 +47,8 @@ int speakup_thread(void *data)
if (our_sound.active)
kd_mksound(our_sound.freq, our_sound.jiffies);
if (synth && synth->catch_up && synth->alive) {
-   /* It is up to the callee to take the lock, so that it
+   /*
+* It is up to the callee to take the lock, so that it
 * can sleep whenever it likes
 */
synth->catch_up(synth);
-- 
2.1.4



<    1   2   3   4   5   6   7   >