Re: [RFC PATCH] ARM: exynos_defconfig: Enable Samsung media platform drivers as modules

2016-03-23 Thread Krzysztof Kozlowski
On 23.03.2016 23:58, Javier Martinez Canillas wrote:
> There are a bunch of media platform drivers under drivers/media/platform/
> that are for Samsung SoCs but are not being built with exynos_defconfig.
> 
> This patch enables them as a module to improve build coverage for these
> drivers and also to allow people use them with proper hardware if modules
> are installed. The S5P MFC driver wasn't enabled since it fails to probe.
> 
> Only the boolean Kconfig symbols are enabled as built-in, since drivers
> are not critical and also to keep the kernel binary image size as small
> as possible.
> 
> Signed-off-by: Javier Martinez Canillas 
> 
> ---
> Hello Kukjin and Krzysztof,
> 
> I'm posting this as a RFC because I don't know if it will add too much bloat
> to a kernel built with exynos_defconfig.
> 
> I think it doesn't since the image size only increased 15 KiB which seems to
> be a small price for having these built, but you may have another opinion.

I like enabling as modules whatever look necessary or useful. I don't
see problems if it requires turning other things to built-in. Please go
ahead with the patch (and follow up after Tobias comments).

Best regards,
Krzysztof


Re: [RFC PATCH] ARM: exynos_defconfig: Enable Samsung media platform drivers as modules

2016-03-23 Thread Krzysztof Kozlowski
On 23.03.2016 23:58, Javier Martinez Canillas wrote:
> There are a bunch of media platform drivers under drivers/media/platform/
> that are for Samsung SoCs but are not being built with exynos_defconfig.
> 
> This patch enables them as a module to improve build coverage for these
> drivers and also to allow people use them with proper hardware if modules
> are installed. The S5P MFC driver wasn't enabled since it fails to probe.
> 
> Only the boolean Kconfig symbols are enabled as built-in, since drivers
> are not critical and also to keep the kernel binary image size as small
> as possible.
> 
> Signed-off-by: Javier Martinez Canillas 
> 
> ---
> Hello Kukjin and Krzysztof,
> 
> I'm posting this as a RFC because I don't know if it will add too much bloat
> to a kernel built with exynos_defconfig.
> 
> I think it doesn't since the image size only increased 15 KiB which seems to
> be a small price for having these built, but you may have another opinion.

I like enabling as modules whatever look necessary or useful. I don't
see problems if it requires turning other things to built-in. Please go
ahead with the patch (and follow up after Tobias comments).

Best regards,
Krzysztof


[PATCH 1/2] compiler.h: add support for malloc attribute

2016-03-23 Thread Rasmus Villemoes
gcc as far back as at least 3.04 documents the function attribute
__malloc__. Add a shorthand for attaching that to a function
declaration. This was also suggested by Andi Kleen way back in 2002
[1], but didn't get applied, perhaps because gcc at that time
generated the exact same code with and without this attribute.

This attribute tells the compiler that the return value (if non-NULL)
can be assumed not to alias any other valid pointers at the time of
the call.

Please note that the documentation for a range of gcc versions
(starting from around 4.7) contained a somewhat confusing and
self-contradicting text:

  The malloc attribute is used to tell the compiler that a function
  may be treated as if any non-NULL pointer it returns cannot alias
  any other pointer valid when the function returns and *that the
  memory has undefined content*. [...] Standard functions with this
  property include malloc and *calloc*.

(emphasis mine). The intended meaning has later been clarified [2]:

  This tells the compiler that a function is malloc-like, i.e., that
  the pointer P returned by the function cannot alias any other
  pointer valid when the function returns, and moreover no pointers to
  valid objects occur in any storage addressed by P.

What this means is that we can apply the attribute to kmalloc and
friends, and it is ok for the returned memory to have well-defined
contents (__GFP_ZERO). But it is not ok to apply it to kmemdup(), nor
to other functions which both allocate and possibly initialize the
memory with existing pointers. So unless someone is doing something
pretty perverted kstrdup() should also be a fine candidate.

[1] http://thread.gmane.org/gmane.linux.kernel/57172
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955

Signed-off-by: Rasmus Villemoes 
---
 include/linux/compiler-gcc.h | 1 +
 include/linux/compiler.h | 4 
 2 files changed, 5 insertions(+)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 22ab246feed3..9004f153c5ab 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -142,6 +142,7 @@
 
 #if GCC_VERSION >= 30400
 #define __must_check   __attribute__((warn_unused_result))
+#define __malloc   __attribute__((__malloc__))
 #endif
 
 #if GCC_VERSION >= 4
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index b5ff9881bef8..793c0829e3a3 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -357,6 +357,10 @@ static __always_inline void __write_once_size(volatile 
void *p, void *res, int s
 #define __deprecated_for_modules
 #endif
 
+#ifndef __malloc
+#define __malloc
+#endif
+
 /*
  * Allow us to avoid 'defined but not used' warnings on functions and data,
  * as well as force them to be emitted to the assembly file.
-- 
2.1.4



[PATCH 2/2] include/linux: apply __malloc attribute

2016-03-23 Thread Rasmus Villemoes
Attach the malloc attribute to a few allocation functions. This helps
gcc generate better code by telling it that the return value doesn't
alias any existing pointers (which is even more valuable given the
pessimizations implied by -fno-strict-aliasing).

A simple example of what this allows gcc to do can be seen by looking
at the last part of drm_atomic_helper_plane_reset:

plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);

if (plane->state) {
plane->state->plane = plane;
plane->state->rotation = BIT(DRM_ROTATE_0);
}

which compiles to

e8 99 bf d6 ff  callq  8116d540 
48 85 c0test   %rax,%rax
48 89 83 40 02 00 00mov%rax,0x240(%rbx)
74 11   je 814015c4 

48 89 18mov%rbx,(%rax)
48 8b 83 40 02 00 00mov0x240(%rbx),%rax [*]
c7 40 40 01 00 00 00movl   $0x1,0x40(%rax)

With this patch applied, the instruction at [*] is elided, since the
store to plane->state->plane is known to not alter the value of
plane->state.

Signed-off-by: Rasmus Villemoes 
---
 include/linux/bootmem.h | 16 
 include/linux/device.h  | 12 ++--
 include/linux/kernel.h  |  4 ++--
 include/linux/mempool.h |  3 ++-
 include/linux/slab.h| 16 
 include/linux/string.h  |  2 +-
 6 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 35b22f94d2d2..f9be32691718 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -83,34 +83,34 @@ extern void *__alloc_bootmem(unsigned long size,
 unsigned long goal);
 extern void *__alloc_bootmem_nopanic(unsigned long size,
 unsigned long align,
-unsigned long goal);
+unsigned long goal) __malloc;
 extern void *__alloc_bootmem_node(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 void *__alloc_bootmem_node_high(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
  unsigned long goal,
- unsigned long limit);
+ unsigned long limit) __malloc;
 extern void *__alloc_bootmem_low(unsigned long size,
 unsigned long align,
-unsigned long goal);
+unsigned long goal) __malloc;
 void *__alloc_bootmem_low_nopanic(unsigned long size,
 unsigned long align,
-unsigned long goal);
+unsigned long goal) __malloc;
 extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 
 #ifdef CONFIG_NO_BOOTMEM
 /* We are using top down, so it is safe to use 0 here */
diff --git a/include/linux/device.h b/include/linux/device.h
index 002c59728dbe..dd03e76fc375 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -609,14 +609,14 @@ typedef int (*dr_match_t)(struct device *dev, void *res, 
void *match_data);
 
 #ifdef CONFIG_DEBUG_DEVRES
 extern void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
-int nid, const char *name);
+int nid, const char *name) __malloc;
 #define devres_alloc(release, size, gfp) \
__devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
 #define devres_alloc_node(release, size, gfp, nid) \
__devres_alloc_node(release, size, gfp, nid, #release)
 #else
 extern void *devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
-  int nid);
+  int nid) __malloc;
 static inline void 

[PATCH 1/2] compiler.h: add support for malloc attribute

2016-03-23 Thread Rasmus Villemoes
gcc as far back as at least 3.04 documents the function attribute
__malloc__. Add a shorthand for attaching that to a function
declaration. This was also suggested by Andi Kleen way back in 2002
[1], but didn't get applied, perhaps because gcc at that time
generated the exact same code with and without this attribute.

This attribute tells the compiler that the return value (if non-NULL)
can be assumed not to alias any other valid pointers at the time of
the call.

Please note that the documentation for a range of gcc versions
(starting from around 4.7) contained a somewhat confusing and
self-contradicting text:

  The malloc attribute is used to tell the compiler that a function
  may be treated as if any non-NULL pointer it returns cannot alias
  any other pointer valid when the function returns and *that the
  memory has undefined content*. [...] Standard functions with this
  property include malloc and *calloc*.

(emphasis mine). The intended meaning has later been clarified [2]:

  This tells the compiler that a function is malloc-like, i.e., that
  the pointer P returned by the function cannot alias any other
  pointer valid when the function returns, and moreover no pointers to
  valid objects occur in any storage addressed by P.

What this means is that we can apply the attribute to kmalloc and
friends, and it is ok for the returned memory to have well-defined
contents (__GFP_ZERO). But it is not ok to apply it to kmemdup(), nor
to other functions which both allocate and possibly initialize the
memory with existing pointers. So unless someone is doing something
pretty perverted kstrdup() should also be a fine candidate.

[1] http://thread.gmane.org/gmane.linux.kernel/57172
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955

Signed-off-by: Rasmus Villemoes 
---
 include/linux/compiler-gcc.h | 1 +
 include/linux/compiler.h | 4 
 2 files changed, 5 insertions(+)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 22ab246feed3..9004f153c5ab 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -142,6 +142,7 @@
 
 #if GCC_VERSION >= 30400
 #define __must_check   __attribute__((warn_unused_result))
+#define __malloc   __attribute__((__malloc__))
 #endif
 
 #if GCC_VERSION >= 4
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index b5ff9881bef8..793c0829e3a3 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -357,6 +357,10 @@ static __always_inline void __write_once_size(volatile 
void *p, void *res, int s
 #define __deprecated_for_modules
 #endif
 
+#ifndef __malloc
+#define __malloc
+#endif
+
 /*
  * Allow us to avoid 'defined but not used' warnings on functions and data,
  * as well as force them to be emitted to the assembly file.
-- 
2.1.4



[PATCH 2/2] include/linux: apply __malloc attribute

2016-03-23 Thread Rasmus Villemoes
Attach the malloc attribute to a few allocation functions. This helps
gcc generate better code by telling it that the return value doesn't
alias any existing pointers (which is even more valuable given the
pessimizations implied by -fno-strict-aliasing).

A simple example of what this allows gcc to do can be seen by looking
at the last part of drm_atomic_helper_plane_reset:

plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);

if (plane->state) {
plane->state->plane = plane;
plane->state->rotation = BIT(DRM_ROTATE_0);
}

which compiles to

e8 99 bf d6 ff  callq  8116d540 
48 85 c0test   %rax,%rax
48 89 83 40 02 00 00mov%rax,0x240(%rbx)
74 11   je 814015c4 

48 89 18mov%rbx,(%rax)
48 8b 83 40 02 00 00mov0x240(%rbx),%rax [*]
c7 40 40 01 00 00 00movl   $0x1,0x40(%rax)

With this patch applied, the instruction at [*] is elided, since the
store to plane->state->plane is known to not alter the value of
plane->state.

Signed-off-by: Rasmus Villemoes 
---
 include/linux/bootmem.h | 16 
 include/linux/device.h  | 12 ++--
 include/linux/kernel.h  |  4 ++--
 include/linux/mempool.h |  3 ++-
 include/linux/slab.h| 16 
 include/linux/string.h  |  2 +-
 6 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 35b22f94d2d2..f9be32691718 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -83,34 +83,34 @@ extern void *__alloc_bootmem(unsigned long size,
 unsigned long goal);
 extern void *__alloc_bootmem_nopanic(unsigned long size,
 unsigned long align,
-unsigned long goal);
+unsigned long goal) __malloc;
 extern void *__alloc_bootmem_node(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 void *__alloc_bootmem_node_high(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 extern void *__alloc_bootmem_node_nopanic(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 void *___alloc_bootmem_node_nopanic(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
  unsigned long goal,
- unsigned long limit);
+ unsigned long limit) __malloc;
 extern void *__alloc_bootmem_low(unsigned long size,
 unsigned long align,
-unsigned long goal);
+unsigned long goal) __malloc;
 void *__alloc_bootmem_low_nopanic(unsigned long size,
 unsigned long align,
-unsigned long goal);
+unsigned long goal) __malloc;
 extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
  unsigned long size,
  unsigned long align,
- unsigned long goal);
+ unsigned long goal) __malloc;
 
 #ifdef CONFIG_NO_BOOTMEM
 /* We are using top down, so it is safe to use 0 here */
diff --git a/include/linux/device.h b/include/linux/device.h
index 002c59728dbe..dd03e76fc375 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -609,14 +609,14 @@ typedef int (*dr_match_t)(struct device *dev, void *res, 
void *match_data);
 
 #ifdef CONFIG_DEBUG_DEVRES
 extern void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
-int nid, const char *name);
+int nid, const char *name) __malloc;
 #define devres_alloc(release, size, gfp) \
__devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
 #define devres_alloc_node(release, size, gfp, nid) \
__devres_alloc_node(release, size, gfp, nid, #release)
 #else
 extern void *devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
-  int nid);
+  int nid) __malloc;
 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
 {

Re: [PATCH 1/3] sched/fair: Fix asym packing to select correct cpu

2016-03-23 Thread Michael Neuling
On Wed, 2016-03-23 at 17:04 +0530, Srikar Dronamraju wrote:
> If asymmetric packing is used when target cpu is busy,
> update_sd_pick_busiest(), can select a lightly loaded cpu.
> find_busiest_group() has checks to ensure asym packing is only used
> when target cpu is not busy.  However it may not be able to avoid a
> lightly loaded cpu selected by update_sd_pick_busiest from being
> selected as source cpu for eventual load balancing.
> 
> Also when using asymmetric scheduling, always select higher cpu as
> source cpu for load balancing.
> 
> While doing this change, move the check to see if target cpu is busy
> into check_asym_packing().
> 
> 1. Record per second ebizzy (32 threads) on a 64 cpu power 7 box. (5 
> iterations)
> 4.5.0-master/ebizzy_32.out
> N   Min   MaxMedian   AvgStddev
> x   5   5205896  17260530  12141204  10759008   4765419
> 
> 4.5.0-master-asym-changes/ebizzy_32.out
> N   Min   MaxMedian   AvgStddev
> x   5   7044349  19112876  17440718  14947658   5263970
> 
> 2. Record per second ebizzy (32 threads) on a 64 cpu power 7 box. (5 
> iterations)
> 4.5.0-master/ebizzy_64.out
> N   Min   MaxMedian   AvgStddev
> x   5   5400083  14091418   8673907 8872662.4 3389746.8
> 
> 4.5.0-master-asym-changes/ebizzy_64.out
> N   Min   MaxMedian   AvgStddev
> x   5   7533907  17232623  15083583  13364894 3776877.9
> 
> 3. Record per second ebizzy (32 threads) on a 64 cpu power 7 box. (5 
> iterations)
> 4.5.0-master/ebizzy_128.out
> N   Min   MaxMedian   AvgStddev
> x   5  35328039  41642699  37564951  38378409   2671280
> 
> 4.5.0-master-asym-changes/ebizzy_128.out
> N   Min   MaxMedian   AvgStddev
> x   5  37102220  42736809  38442478  39529626 2298389.4

I'm not sure how to interpret these.  Any chance you can give a summary of
what these results mean?

> Signed-off-by: Srikar Dronamraju 

FWIW, this still passes my scheduler tests on POWER7, but they weren't 
failing before anyway.

Mikey

> ---
>  kernel/sched/fair.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 56b7d4b..9abfb16 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6517,6 +6517,8 @@ static bool update_sd_pick_busiest(struct lb_env *env,
>   if (!(env->sd->flags & SD_ASYM_PACKING))
>   return true;
>  
> + if (env->idle == CPU_NOT_IDLE)
> + return true;
>   /*
>* ASYM_PACKING needs to move all the work to the lowest
>* numbered CPUs in the group, therefore mark all groups
> @@ -6526,7 +6528,7 @@ static bool update_sd_pick_busiest(struct lb_env *env,
>   if (!sds->busiest)
>   return true;
>  
> - if (group_first_cpu(sds->busiest) > group_first_cpu(sg))
> + if (group_first_cpu(sds->busiest) < group_first_cpu(sg))
>   return true;
>   }
>  
> @@ -6672,6 +6674,9 @@ static int check_asym_packing(struct lb_env *env, 
> struct sd_lb_stats *sds)
>   if (!(env->sd->flags & SD_ASYM_PACKING))
>   return 0;
>  
> + if (env->idle == CPU_NOT_IDLE)
> + return 0;
> +
>   if (!sds->busiest)
>   return 0;
>  
> @@ -6864,8 +6869,7 @@ static struct sched_group *find_busiest_group(struct 
> lb_env *env)
>   busiest = _stat;
>  
>   /* ASYM feature bypasses nice load balance check */
> - if ((env->idle == CPU_IDLE || env->idle == CPU_NEWLY_IDLE) &&
> - check_asym_packing(env, ))
> + if (check_asym_packing(env, ))
>   return sds.busiest;
>  
>   /* There is no busy sibling group to pull tasks from */


Re: [PATCH 1/3] sched/fair: Fix asym packing to select correct cpu

2016-03-23 Thread Michael Neuling
On Wed, 2016-03-23 at 17:04 +0530, Srikar Dronamraju wrote:
> If asymmetric packing is used when target cpu is busy,
> update_sd_pick_busiest(), can select a lightly loaded cpu.
> find_busiest_group() has checks to ensure asym packing is only used
> when target cpu is not busy.  However it may not be able to avoid a
> lightly loaded cpu selected by update_sd_pick_busiest from being
> selected as source cpu for eventual load balancing.
> 
> Also when using asymmetric scheduling, always select higher cpu as
> source cpu for load balancing.
> 
> While doing this change, move the check to see if target cpu is busy
> into check_asym_packing().
> 
> 1. Record per second ebizzy (32 threads) on a 64 cpu power 7 box. (5 
> iterations)
> 4.5.0-master/ebizzy_32.out
> N   Min   MaxMedian   AvgStddev
> x   5   5205896  17260530  12141204  10759008   4765419
> 
> 4.5.0-master-asym-changes/ebizzy_32.out
> N   Min   MaxMedian   AvgStddev
> x   5   7044349  19112876  17440718  14947658   5263970
> 
> 2. Record per second ebizzy (32 threads) on a 64 cpu power 7 box. (5 
> iterations)
> 4.5.0-master/ebizzy_64.out
> N   Min   MaxMedian   AvgStddev
> x   5   5400083  14091418   8673907 8872662.4 3389746.8
> 
> 4.5.0-master-asym-changes/ebizzy_64.out
> N   Min   MaxMedian   AvgStddev
> x   5   7533907  17232623  15083583  13364894 3776877.9
> 
> 3. Record per second ebizzy (32 threads) on a 64 cpu power 7 box. (5 
> iterations)
> 4.5.0-master/ebizzy_128.out
> N   Min   MaxMedian   AvgStddev
> x   5  35328039  41642699  37564951  38378409   2671280
> 
> 4.5.0-master-asym-changes/ebizzy_128.out
> N   Min   MaxMedian   AvgStddev
> x   5  37102220  42736809  38442478  39529626 2298389.4

I'm not sure how to interpret these.  Any chance you can give a summary of
what these results mean?

> Signed-off-by: Srikar Dronamraju 

FWIW, this still passes my scheduler tests on POWER7, but they weren't 
failing before anyway.

Mikey

> ---
>  kernel/sched/fair.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 56b7d4b..9abfb16 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6517,6 +6517,8 @@ static bool update_sd_pick_busiest(struct lb_env *env,
>   if (!(env->sd->flags & SD_ASYM_PACKING))
>   return true;
>  
> + if (env->idle == CPU_NOT_IDLE)
> + return true;
>   /*
>* ASYM_PACKING needs to move all the work to the lowest
>* numbered CPUs in the group, therefore mark all groups
> @@ -6526,7 +6528,7 @@ static bool update_sd_pick_busiest(struct lb_env *env,
>   if (!sds->busiest)
>   return true;
>  
> - if (group_first_cpu(sds->busiest) > group_first_cpu(sg))
> + if (group_first_cpu(sds->busiest) < group_first_cpu(sg))
>   return true;
>   }
>  
> @@ -6672,6 +6674,9 @@ static int check_asym_packing(struct lb_env *env, 
> struct sd_lb_stats *sds)
>   if (!(env->sd->flags & SD_ASYM_PACKING))
>   return 0;
>  
> + if (env->idle == CPU_NOT_IDLE)
> + return 0;
> +
>   if (!sds->busiest)
>   return 0;
>  
> @@ -6864,8 +6869,7 @@ static struct sched_group *find_busiest_group(struct 
> lb_env *env)
>   busiest = _stat;
>  
>   /* ASYM feature bypasses nice load balance check */
> - if ((env->idle == CPU_IDLE || env->idle == CPU_NEWLY_IDLE) &&
> - check_asym_packing(env, ))
> + if (check_asym_packing(env, ))
>   return sds.busiest;
>  
>   /* There is no busy sibling group to pull tasks from */


Dear Truly God Chosen

2016-03-23 Thread Mrs. Nicole Benoite Marois
(Dear Truly God Chosen)

Please excuse this humble email if it offends your sensibilities, but
I have no other means to contact you. I cannot talk on the telephone,
so I did a search for your email address, which I found on the
international directorate email data search. I am Mrs. Nicole Benoite
Marois, A Christian widow who is dying of esophageal cancers.

Recently, My Doctor told me that I would not last more than Three
Months due to cancer problem, But I have been touched by God to donate
an amount of money Inherited from my late husband Mr. White Marois to
you for the good work of God on Charity" People in the Street and
Helping the Orphanage. My husband derived this money from his vast
Estates and Investment in capital market, I decided to WILL/donate the
sum of USD$7.2 Million United states dollars to you and 30 Percent of
the total money is for your personal use, While 70% of the money will
go to charity" people in the street and helping the orphanage.

I will give you the contact of Bank Manager for the releasing of the
specific amount, my personal Reference Number Law/WILL/ 7983452026. I
will appreciate your utmost honest in this matter until the task is
accomplished as I don't want anything that will jeopardize this
charity project and my last wish.

With Regards,
Mrs. Nicole Benoite Marois.


Dear Truly God Chosen

2016-03-23 Thread Mrs. Nicole Benoite Marois
(Dear Truly God Chosen)

Please excuse this humble email if it offends your sensibilities, but
I have no other means to contact you. I cannot talk on the telephone,
so I did a search for your email address, which I found on the
international directorate email data search. I am Mrs. Nicole Benoite
Marois, A Christian widow who is dying of esophageal cancers.

Recently, My Doctor told me that I would not last more than Three
Months due to cancer problem, But I have been touched by God to donate
an amount of money Inherited from my late husband Mr. White Marois to
you for the good work of God on Charity" People in the Street and
Helping the Orphanage. My husband derived this money from his vast
Estates and Investment in capital market, I decided to WILL/donate the
sum of USD$7.2 Million United states dollars to you and 30 Percent of
the total money is for your personal use, While 70% of the money will
go to charity" people in the street and helping the orphanage.

I will give you the contact of Bank Manager for the releasing of the
specific amount, my personal Reference Number Law/WILL/ 7983452026. I
will appreciate your utmost honest in this matter until the task is
accomplished as I don't want anything that will jeopardize this
charity project and my last wish.

With Regards,
Mrs. Nicole Benoite Marois.


Re: linux-next: manual merge of the rdma tree with the net-next tree

2016-03-23 Thread Linus Torvalds
On Wed, Mar 23, 2016 at 4:04 PM, Or Gerlitz  wrote:
>
> I know there's history here, and in the 4.5 cycle things were much
> worse, but I still wanted to put things in their more precise place,
> if you don't mind.

We'll see how things shape up in the future. Once bitten, twice shy,
as they say.

Please make sure that Mellanox will not be a pain going forward, and
everything will be forgiven/forgotten.

Linus


Re: linux-next: manual merge of the rdma tree with the net-next tree

2016-03-23 Thread Linus Torvalds
On Wed, Mar 23, 2016 at 4:04 PM, Or Gerlitz  wrote:
>
> I know there's history here, and in the 4.5 cycle things were much
> worse, but I still wanted to put things in their more precise place,
> if you don't mind.

We'll see how things shape up in the future. Once bitten, twice shy,
as they say.

Please make sure that Mellanox will not be a pain going forward, and
everything will be forgiven/forgotten.

Linus


[PATCH 7/7] Drivers: hv: vmbus: Implement APIs to support "in place" consumption of vmbus packets

2016-03-23 Thread K. Y. Srinivasan
Implement APIs for in-place consumption of vmbus packets. Currently, each
packet is copied and processed one at a time and as part of processing
each packet we potentially may signal the host (if it is waiting for
room to produce a packet).

These APIs help batched in-place processing of vmbus packets.
We also optimize host signaling by having a separate API to signal
the end of in-place consumption. With netvsc using these APIs,
on an iperf run on average I see about 20X reduction in checks to
signal the host.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |1 +
 include/linux/hyperv.h   |   86 ++
 2 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 253311b..a2a38ab 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -132,6 +132,7 @@ hv_set_next_read_location(struct hv_ring_buffer_info 
*ring_info,
u32 next_read_location)
 {
ring_info->ring_buffer->read_index = next_read_location;
+   ring_info->priv_read_index = next_read_location;
 }
 
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 8fc9b09..3fadbaf 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -126,6 +126,8 @@ struct hv_ring_buffer_info {
 
u32 ring_datasize;  /* < ring_size */
u32 ring_data_startoffset;
+   u32 priv_write_index;
+   u32 priv_read_index;
 };
 
 /*
@@ -1408,4 +1410,88 @@ static inline  bool hv_need_to_signal_on_read(struct 
hv_ring_buffer_info *rbi)
return false;
 }
 
+/*
+ * An API to support in-place processing of incoming VMBUS packets.
+ */
+#define VMBUS_PKT_TRAILER  8
+
+static inline struct vmpacket_descriptor *
+get_next_pkt_raw(struct vmbus_channel *channel)
+{
+   struct hv_ring_buffer_info *ring_info = >inbound;
+   u32 read_loc = ring_info->priv_read_index;
+   void *ring_buffer = hv_get_ring_buffer(ring_info);
+   struct vmpacket_descriptor *cur_desc;
+   u32 packetlen;
+   u32 dsize = ring_info->ring_datasize;
+   u32 delta = read_loc - ring_info->ring_buffer->read_index;
+   u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);
+
+   if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
+   return NULL;
+
+   if ((read_loc + sizeof(*cur_desc)) > dsize)
+   return NULL;
+
+   cur_desc = ring_buffer + read_loc;
+   packetlen = cur_desc->len8 << 3;
+
+   /*
+* If the packet under consideration is wrapping around,
+* return failure.
+*/
+   if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
+   return NULL;
+
+   return cur_desc;
+}
+
+/*
+ * A helper function to step through packets "in-place"
+ * This API is to be called after each successful call
+ * get_next_pkt_raw().
+ */
+static inline void put_pkt_raw(struct vmbus_channel *channel,
+   struct vmpacket_descriptor *desc)
+{
+   struct hv_ring_buffer_info *ring_info = >inbound;
+   u32 read_loc = ring_info->priv_read_index;
+   u32 packetlen = desc->len8 << 3;
+   u32 dsize = ring_info->ring_datasize;
+
+   if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize)
+   BUG();
+   /*
+* Include the packet trailer.
+*/
+   ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
+}
+
+/*
+ * This call commits the read index and potentially signals the host.
+ * Here is the pattern for using the "in-place" consumption APIs:
+ *
+ * while (get_next_pkt_raw() {
+ * process the packet "in-place";
+ * put_pkt_raw();
+ * }
+ * if (packets processed in place)
+ * commit_rd_index();
+ */
+static inline void commit_rd_index(struct vmbus_channel *channel)
+{
+   struct hv_ring_buffer_info *ring_info = >inbound;
+   /*
+* Make sure all reads are done before we update the read index since
+* the writer may start writing to the read area once the read index
+* is updated.
+*/
+   virt_rmb();
+   ring_info->ring_buffer->read_index = ring_info->priv_read_index;
+
+   if (hv_need_to_signal_on_read(ring_info))
+   vmbus_set_event(channel);
+}
+
+
 #endif /* _HYPERV_H */
-- 
1.7.4.1



[PATCH 2/7] Drivers: hv: vmbus: Use READ_ONCE() to read variables that are volatile

2016-03-23 Thread K. Y. Srinivasan
Use the READ_ONCE macro to access variabes that can change asynchronously.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 902375b..2919395 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -69,7 +69,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi)
 {
mb();
-   if (rbi->ring_buffer->interrupt_mask)
+   if (READ_ONCE(rbi->ring_buffer->interrupt_mask))
return false;
 
/* check interrupt_mask before read_index */
@@ -78,7 +78,7 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
 * This is the only case we need to signal when the
 * ring transitions from being empty to non-empty.
 */
-   if (old_write == rbi->ring_buffer->read_index)
+   if (old_write == READ_ONCE(rbi->ring_buffer->read_index))
return true;
 
return false;
@@ -102,8 +102,9 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
 static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
 {
u32 cur_write_sz;
-   u32 pending_sz = rbi->ring_buffer->pending_send_sz;
+   u32 pending_sz;
 
+   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
return false;
-- 
1.7.4.1



[PATCH 7/7] Drivers: hv: vmbus: Implement APIs to support "in place" consumption of vmbus packets

2016-03-23 Thread K. Y. Srinivasan
Implement APIs for in-place consumption of vmbus packets. Currently, each
packet is copied and processed one at a time and as part of processing
each packet we potentially may signal the host (if it is waiting for
room to produce a packet).

These APIs help batched in-place processing of vmbus packets.
We also optimize host signaling by having a separate API to signal
the end of in-place consumption. With netvsc using these APIs,
on an iperf run on average I see about 20X reduction in checks to
signal the host.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |1 +
 include/linux/hyperv.h   |   86 ++
 2 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 253311b..a2a38ab 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -132,6 +132,7 @@ hv_set_next_read_location(struct hv_ring_buffer_info 
*ring_info,
u32 next_read_location)
 {
ring_info->ring_buffer->read_index = next_read_location;
+   ring_info->priv_read_index = next_read_location;
 }
 
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 8fc9b09..3fadbaf 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -126,6 +126,8 @@ struct hv_ring_buffer_info {
 
u32 ring_datasize;  /* < ring_size */
u32 ring_data_startoffset;
+   u32 priv_write_index;
+   u32 priv_read_index;
 };
 
 /*
@@ -1408,4 +1410,88 @@ static inline  bool hv_need_to_signal_on_read(struct 
hv_ring_buffer_info *rbi)
return false;
 }
 
+/*
+ * An API to support in-place processing of incoming VMBUS packets.
+ */
+#define VMBUS_PKT_TRAILER  8
+
+static inline struct vmpacket_descriptor *
+get_next_pkt_raw(struct vmbus_channel *channel)
+{
+   struct hv_ring_buffer_info *ring_info = >inbound;
+   u32 read_loc = ring_info->priv_read_index;
+   void *ring_buffer = hv_get_ring_buffer(ring_info);
+   struct vmpacket_descriptor *cur_desc;
+   u32 packetlen;
+   u32 dsize = ring_info->ring_datasize;
+   u32 delta = read_loc - ring_info->ring_buffer->read_index;
+   u32 bytes_avail_toread = (hv_get_bytes_to_read(ring_info) - delta);
+
+   if (bytes_avail_toread < sizeof(struct vmpacket_descriptor))
+   return NULL;
+
+   if ((read_loc + sizeof(*cur_desc)) > dsize)
+   return NULL;
+
+   cur_desc = ring_buffer + read_loc;
+   packetlen = cur_desc->len8 << 3;
+
+   /*
+* If the packet under consideration is wrapping around,
+* return failure.
+*/
+   if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > (dsize - 1))
+   return NULL;
+
+   return cur_desc;
+}
+
+/*
+ * A helper function to step through packets "in-place"
+ * This API is to be called after each successful call
+ * get_next_pkt_raw().
+ */
+static inline void put_pkt_raw(struct vmbus_channel *channel,
+   struct vmpacket_descriptor *desc)
+{
+   struct hv_ring_buffer_info *ring_info = >inbound;
+   u32 read_loc = ring_info->priv_read_index;
+   u32 packetlen = desc->len8 << 3;
+   u32 dsize = ring_info->ring_datasize;
+
+   if ((read_loc + packetlen + VMBUS_PKT_TRAILER) > dsize)
+   BUG();
+   /*
+* Include the packet trailer.
+*/
+   ring_info->priv_read_index += packetlen + VMBUS_PKT_TRAILER;
+}
+
+/*
+ * This call commits the read index and potentially signals the host.
+ * Here is the pattern for using the "in-place" consumption APIs:
+ *
+ * while (get_next_pkt_raw() {
+ * process the packet "in-place";
+ * put_pkt_raw();
+ * }
+ * if (packets processed in place)
+ * commit_rd_index();
+ */
+static inline void commit_rd_index(struct vmbus_channel *channel)
+{
+   struct hv_ring_buffer_info *ring_info = >inbound;
+   /*
+* Make sure all reads are done before we update the read index since
+* the writer may start writing to the read area once the read index
+* is updated.
+*/
+   virt_rmb();
+   ring_info->ring_buffer->read_index = ring_info->priv_read_index;
+
+   if (hv_need_to_signal_on_read(ring_info))
+   vmbus_set_event(channel);
+}
+
+
 #endif /* _HYPERV_H */
-- 
1.7.4.1



[PATCH 2/7] Drivers: hv: vmbus: Use READ_ONCE() to read variables that are volatile

2016-03-23 Thread K. Y. Srinivasan
Use the READ_ONCE macro to access variabes that can change asynchronously.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |7 ---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 902375b..2919395 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -69,7 +69,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi)
 {
mb();
-   if (rbi->ring_buffer->interrupt_mask)
+   if (READ_ONCE(rbi->ring_buffer->interrupt_mask))
return false;
 
/* check interrupt_mask before read_index */
@@ -78,7 +78,7 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
 * This is the only case we need to signal when the
 * ring transitions from being empty to non-empty.
 */
-   if (old_write == rbi->ring_buffer->read_index)
+   if (old_write == READ_ONCE(rbi->ring_buffer->read_index))
return true;
 
return false;
@@ -102,8 +102,9 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
 static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
 {
u32 cur_write_sz;
-   u32 pending_sz = rbi->ring_buffer->pending_send_sz;
+   u32 pending_sz;
 
+   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
return false;
-- 
1.7.4.1



[PATCH 3/7] Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read()

2016-03-23 Thread K. Y. Srinivasan
We need to issue a full memory barrier prior making a signalling decision.

Signed-off-by: K. Y. Srinivasan 
Cc: sta...@vger.kernel.org
---
 drivers/hv/ring_buffer.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 2919395..67dc245 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -104,6 +104,7 @@ static bool hv_need_to_signal_on_read(struct 
hv_ring_buffer_info *rbi)
u32 cur_write_sz;
u32 pending_sz;
 
+   mb();
pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
-- 
1.7.4.1



[PATCH 6/7] Drivers: hv: vmbus: Move some ring buffer functions to hyperv.h

2016-03-23 Thread K. Y. Srinivasan
In preparation for implementing APIs for in-place consumption of VMBUS
packets, movve some ring buffer functionality into hyperv.h

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   42 --
 include/linux/hyperv.h   |   42 ++
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index c2c2b2e..253311b 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -84,40 +84,6 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
return false;
 }
 
-/*
- * To optimize the flow management on the send-side,
- * when the sender is blocked because of lack of
- * sufficient space in the ring buffer, potential the
- * consumer of the ring buffer can signal the producer.
- * This is controlled by the following parameters:
- *
- * 1. pending_send_sz: This is the size in bytes that the
- *producer is trying to send.
- * 2. The feature bit feat_pending_send_sz set to indicate if
- *the consumer of the ring will signal when the ring
- *state transitions from being full to a state where
- *there is room for the producer to send the pending packet.
- */
-
-static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
-{
-   u32 cur_write_sz;
-   u32 pending_sz;
-
-   virt_mb();
-   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
-   /* If the other end is not blocked on write don't bother. */
-   if (pending_sz == 0)
-   return false;
-
-   cur_write_sz = hv_get_bytes_to_write(rbi);
-
-   if (cur_write_sz >= pending_sz)
-   return true;
-
-   return false;
-}
-
 /* Get the next write location for the specified ring buffer. */
 static inline u32
 hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
@@ -169,14 +135,6 @@ hv_set_next_read_location(struct hv_ring_buffer_info 
*ring_info,
 }
 
 
-/* Get the start of the ring buffer. */
-static inline void *
-hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
-{
-   return (void *)ring_info->ring_buffer->buffer;
-}
-
-
 /* Get the size of the ring buffer. */
 static inline u32
 hv_get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 4adeb6e..8fc9b09 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1366,4 +1366,46 @@ extern __u32 vmbus_proto_version;
 int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
  const uuid_le *shv_host_servie_id);
 void vmbus_set_event(struct vmbus_channel *channel);
+
+/* Get the start of the ring buffer. */
+static inline void *
+hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
+{
+   return (void *)ring_info->ring_buffer->buffer;
+}
+
+/*
+ * To optimize the flow management on the send-side,
+ * when the sender is blocked because of lack of
+ * sufficient space in the ring buffer, potential the
+ * consumer of the ring buffer can signal the producer.
+ * This is controlled by the following parameters:
+ *
+ * 1. pending_send_sz: This is the size in bytes that the
+ *producer is trying to send.
+ * 2. The feature bit feat_pending_send_sz set to indicate if
+ *the consumer of the ring will signal when the ring
+ *state transitions from being full to a state where
+ *there is room for the producer to send the pending packet.
+ */
+
+static inline  bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
+{
+   u32 cur_write_sz;
+   u32 pending_sz;
+
+   virt_mb();
+   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
+   /* If the other end is not blocked on write don't bother. */
+   if (pending_sz == 0)
+   return false;
+
+   cur_write_sz = hv_get_bytes_to_write(rbi);
+
+   if (cur_write_sz >= pending_sz)
+   return true;
+
+   return false;
+}
+
 #endif /* _HYPERV_H */
-- 
1.7.4.1



[PATCH 3/7] Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read()

2016-03-23 Thread K. Y. Srinivasan
We need to issue a full memory barrier prior making a signalling decision.

Signed-off-by: K. Y. Srinivasan 
Cc: sta...@vger.kernel.org
---
 drivers/hv/ring_buffer.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 2919395..67dc245 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -104,6 +104,7 @@ static bool hv_need_to_signal_on_read(struct 
hv_ring_buffer_info *rbi)
u32 cur_write_sz;
u32 pending_sz;
 
+   mb();
pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
-- 
1.7.4.1



[PATCH 6/7] Drivers: hv: vmbus: Move some ring buffer functions to hyperv.h

2016-03-23 Thread K. Y. Srinivasan
In preparation for implementing APIs for in-place consumption of VMBUS
packets, movve some ring buffer functionality into hyperv.h

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   42 --
 include/linux/hyperv.h   |   42 ++
 2 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index c2c2b2e..253311b 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -84,40 +84,6 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
return false;
 }
 
-/*
- * To optimize the flow management on the send-side,
- * when the sender is blocked because of lack of
- * sufficient space in the ring buffer, potential the
- * consumer of the ring buffer can signal the producer.
- * This is controlled by the following parameters:
- *
- * 1. pending_send_sz: This is the size in bytes that the
- *producer is trying to send.
- * 2. The feature bit feat_pending_send_sz set to indicate if
- *the consumer of the ring will signal when the ring
- *state transitions from being full to a state where
- *there is room for the producer to send the pending packet.
- */
-
-static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
-{
-   u32 cur_write_sz;
-   u32 pending_sz;
-
-   virt_mb();
-   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
-   /* If the other end is not blocked on write don't bother. */
-   if (pending_sz == 0)
-   return false;
-
-   cur_write_sz = hv_get_bytes_to_write(rbi);
-
-   if (cur_write_sz >= pending_sz)
-   return true;
-
-   return false;
-}
-
 /* Get the next write location for the specified ring buffer. */
 static inline u32
 hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
@@ -169,14 +135,6 @@ hv_set_next_read_location(struct hv_ring_buffer_info 
*ring_info,
 }
 
 
-/* Get the start of the ring buffer. */
-static inline void *
-hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
-{
-   return (void *)ring_info->ring_buffer->buffer;
-}
-
-
 /* Get the size of the ring buffer. */
 static inline u32
 hv_get_ring_buffersize(struct hv_ring_buffer_info *ring_info)
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 4adeb6e..8fc9b09 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1366,4 +1366,46 @@ extern __u32 vmbus_proto_version;
 int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
  const uuid_le *shv_host_servie_id);
 void vmbus_set_event(struct vmbus_channel *channel);
+
+/* Get the start of the ring buffer. */
+static inline void *
+hv_get_ring_buffer(struct hv_ring_buffer_info *ring_info)
+{
+   return (void *)ring_info->ring_buffer->buffer;
+}
+
+/*
+ * To optimize the flow management on the send-side,
+ * when the sender is blocked because of lack of
+ * sufficient space in the ring buffer, potential the
+ * consumer of the ring buffer can signal the producer.
+ * This is controlled by the following parameters:
+ *
+ * 1. pending_send_sz: This is the size in bytes that the
+ *producer is trying to send.
+ * 2. The feature bit feat_pending_send_sz set to indicate if
+ *the consumer of the ring will signal when the ring
+ *state transitions from being full to a state where
+ *there is room for the producer to send the pending packet.
+ */
+
+static inline  bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
+{
+   u32 cur_write_sz;
+   u32 pending_sz;
+
+   virt_mb();
+   pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
+   /* If the other end is not blocked on write don't bother. */
+   if (pending_sz == 0)
+   return false;
+
+   cur_write_sz = hv_get_bytes_to_write(rbi);
+
+   if (cur_write_sz >= pending_sz)
+   return true;
+
+   return false;
+}
+
 #endif /* _HYPERV_H */
-- 
1.7.4.1



[PATCH 5/7] Drivers: hv: vmbus: Export the vmbus_set_event() API

2016-03-23 Thread K. Y. Srinivasan
In preparation for moving some ring buffer functionality out of the
vmbus driver, export the API for signaling the host.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/connection.c   |1 +
 drivers/hv/hyperv_vmbus.h |2 --
 include/linux/hyperv.h|1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index d02f137..fcf8a02 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -495,3 +495,4 @@ void vmbus_set_event(struct vmbus_channel *channel)
 
hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
 }
+EXPORT_SYMBOL_GPL(vmbus_set_event);
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 28e9df9..8cbd630 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -678,8 +678,6 @@ void vmbus_disconnect(void);
 
 int vmbus_post_msg(void *buffer, size_t buflen);
 
-void vmbus_set_event(struct vmbus_channel *channel);
-
 void vmbus_on_event(unsigned long data);
 void vmbus_on_msg_dpc(unsigned long data);
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index a6b053c..4adeb6e 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1365,4 +1365,5 @@ extern __u32 vmbus_proto_version;
 
 int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
  const uuid_le *shv_host_servie_id);
+void vmbus_set_event(struct vmbus_channel *channel);
 #endif /* _HYPERV_H */
-- 
1.7.4.1



[PATCH 1/7] Drivers: hv: vmbus: Introduce functions for estimating room in the ring buffer

2016-03-23 Thread K. Y. Srinivasan
Introduce separate functions for estimating how much can be read from
and written to the ring buffer.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   24 
 include/linux/hyperv.h   |   27 +++
 2 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 085003a..902375b 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -38,8 +38,6 @@ void hv_begin_read(struct hv_ring_buffer_info *rbi)
 
 u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 {
-   u32 read;
-   u32 write;
 
rbi->ring_buffer->interrupt_mask = 0;
mb();
@@ -49,9 +47,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 * If it is not, we raced and we need to process new
 * incoming messages.
 */
-   hv_get_ringbuffer_availbytes(rbi, , );
-
-   return read;
+   return hv_get_bytes_to_read(rbi);
 }
 
 /*
@@ -106,18 +102,13 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
 static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
 {
u32 cur_write_sz;
-   u32 r_size;
-   u32 write_loc = rbi->ring_buffer->write_index;
-   u32 read_loc = rbi->ring_buffer->read_index;
u32 pending_sz = rbi->ring_buffer->pending_send_sz;
 
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
return false;
 
-   r_size = rbi->ring_datasize;
-   cur_write_sz = write_loc >= read_loc ? r_size - (write_loc - read_loc) :
-   read_loc - write_loc;
+   cur_write_sz = hv_get_bytes_to_write(rbi);
 
if (cur_write_sz >= pending_sz)
return true;
@@ -317,7 +308,6 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info 
*outring_info,
 {
int i = 0;
u32 bytes_avail_towrite;
-   u32 bytes_avail_toread;
u32 totalbytes_towrite = 0;
 
u32 next_write_location;
@@ -333,9 +323,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info 
*outring_info,
if (lock)
spin_lock_irqsave(_info->ring_lock, flags);
 
-   hv_get_ringbuffer_availbytes(outring_info,
-   _avail_toread,
-   _avail_towrite);
+   bytes_avail_towrite = hv_get_bytes_to_write(outring_info);
 
/*
 * If there is only room for the packet, assume it is full.
@@ -386,7 +374,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info 
*inring_info,
   void *buffer, u32 buflen, u32 *buffer_actual_len,
   u64 *requestid, bool *signal, bool raw)
 {
-   u32 bytes_avail_towrite;
u32 bytes_avail_toread;
u32 next_read_location = 0;
u64 prev_indices = 0;
@@ -402,10 +389,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info 
*inring_info,
*buffer_actual_len = 0;
*requestid = 0;
 
-   hv_get_ringbuffer_availbytes(inring_info,
-   _avail_toread,
-   _avail_towrite);
-
+   bytes_avail_toread = hv_get_bytes_to_read(inring_info);
/* Make sure there is something to read */
if (bytes_avail_toread < sizeof(desc)) {
/*
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index ecd81c3..a6b053c 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -151,6 +151,33 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info 
*rbi,
*read = dsize - *write;
 }
 
+static inline u32 hv_get_bytes_to_read(struct hv_ring_buffer_info *rbi)
+{
+   u32 read_loc, write_loc, dsize, read;
+
+   dsize = rbi->ring_datasize;
+   read_loc = rbi->ring_buffer->read_index;
+   write_loc = READ_ONCE(rbi->ring_buffer->write_index);
+
+   read = write_loc >= read_loc ? (write_loc - read_loc) :
+   (dsize - read_loc) + write_loc;
+
+   return read;
+}
+
+static inline u32 hv_get_bytes_to_write(struct hv_ring_buffer_info *rbi)
+{
+   u32 read_loc, write_loc, dsize, write;
+
+   dsize = rbi->ring_datasize;
+   read_loc = READ_ONCE(rbi->ring_buffer->read_index);
+   write_loc = rbi->ring_buffer->write_index;
+
+   write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
+   read_loc - write_loc;
+   return write;
+}
+
 /*
  * VMBUS version is 32 bit entity broken up into
  * two 16 bit quantities: major_number. minor_number.
-- 
1.7.4.1



[PATCH 4/7] Drivers: hv: vmbus: Use the new virt_xx barrier code

2016-03-23 Thread K. Y. Srinivasan
Use the virt_xx barriers that have been defined for use in virtual machines.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 67dc245..c2c2b2e 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -33,14 +33,14 @@
 void hv_begin_read(struct hv_ring_buffer_info *rbi)
 {
rbi->ring_buffer->interrupt_mask = 1;
-   mb();
+   virt_mb();
 }
 
 u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 {
 
rbi->ring_buffer->interrupt_mask = 0;
-   mb();
+   virt_mb();
 
/*
 * Now check to see if the ring buffer is still empty.
@@ -68,12 +68,12 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 
 static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi)
 {
-   mb();
+   virt_mb();
if (READ_ONCE(rbi->ring_buffer->interrupt_mask))
return false;
 
/* check interrupt_mask before read_index */
-   rmb();
+   virt_rmb();
/*
 * This is the only case we need to signal when the
 * ring transitions from being empty to non-empty.
@@ -104,7 +104,7 @@ static bool hv_need_to_signal_on_read(struct 
hv_ring_buffer_info *rbi)
u32 cur_write_sz;
u32 pending_sz;
 
-   mb();
+   virt_mb();
pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
@@ -359,7 +359,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info 
*outring_info,
 sizeof(u64));
 
/* Issue a full memory barrier before updating the write index */
-   mb();
+   virt_mb();
 
/* Now, update the write location */
hv_set_next_write_location(outring_info, next_write_location);
@@ -435,7 +435,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info 
*inring_info,
 * the writer may start writing to the read area once the read index
 * is updated.
 */
-   mb();
+   virt_mb();
 
/* Update the read index */
hv_set_next_read_location(inring_info, next_read_location);
-- 
1.7.4.1



[PATCH 5/7] Drivers: hv: vmbus: Export the vmbus_set_event() API

2016-03-23 Thread K. Y. Srinivasan
In preparation for moving some ring buffer functionality out of the
vmbus driver, export the API for signaling the host.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/connection.c   |1 +
 drivers/hv/hyperv_vmbus.h |2 --
 include/linux/hyperv.h|1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index d02f137..fcf8a02 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -495,3 +495,4 @@ void vmbus_set_event(struct vmbus_channel *channel)
 
hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event, NULL);
 }
+EXPORT_SYMBOL_GPL(vmbus_set_event);
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index 28e9df9..8cbd630 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -678,8 +678,6 @@ void vmbus_disconnect(void);
 
 int vmbus_post_msg(void *buffer, size_t buflen);
 
-void vmbus_set_event(struct vmbus_channel *channel);
-
 void vmbus_on_event(unsigned long data);
 void vmbus_on_msg_dpc(unsigned long data);
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index a6b053c..4adeb6e 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1365,4 +1365,5 @@ extern __u32 vmbus_proto_version;
 
 int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id,
  const uuid_le *shv_host_servie_id);
+void vmbus_set_event(struct vmbus_channel *channel);
 #endif /* _HYPERV_H */
-- 
1.7.4.1



[PATCH 1/7] Drivers: hv: vmbus: Introduce functions for estimating room in the ring buffer

2016-03-23 Thread K. Y. Srinivasan
Introduce separate functions for estimating how much can be read from
and written to the ring buffer.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   24 
 include/linux/hyperv.h   |   27 +++
 2 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 085003a..902375b 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -38,8 +38,6 @@ void hv_begin_read(struct hv_ring_buffer_info *rbi)
 
 u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 {
-   u32 read;
-   u32 write;
 
rbi->ring_buffer->interrupt_mask = 0;
mb();
@@ -49,9 +47,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 * If it is not, we raced and we need to process new
 * incoming messages.
 */
-   hv_get_ringbuffer_availbytes(rbi, , );
-
-   return read;
+   return hv_get_bytes_to_read(rbi);
 }
 
 /*
@@ -106,18 +102,13 @@ static bool hv_need_to_signal(u32 old_write, struct 
hv_ring_buffer_info *rbi)
 static bool hv_need_to_signal_on_read(struct hv_ring_buffer_info *rbi)
 {
u32 cur_write_sz;
-   u32 r_size;
-   u32 write_loc = rbi->ring_buffer->write_index;
-   u32 read_loc = rbi->ring_buffer->read_index;
u32 pending_sz = rbi->ring_buffer->pending_send_sz;
 
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
return false;
 
-   r_size = rbi->ring_datasize;
-   cur_write_sz = write_loc >= read_loc ? r_size - (write_loc - read_loc) :
-   read_loc - write_loc;
+   cur_write_sz = hv_get_bytes_to_write(rbi);
 
if (cur_write_sz >= pending_sz)
return true;
@@ -317,7 +308,6 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info 
*outring_info,
 {
int i = 0;
u32 bytes_avail_towrite;
-   u32 bytes_avail_toread;
u32 totalbytes_towrite = 0;
 
u32 next_write_location;
@@ -333,9 +323,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info 
*outring_info,
if (lock)
spin_lock_irqsave(_info->ring_lock, flags);
 
-   hv_get_ringbuffer_availbytes(outring_info,
-   _avail_toread,
-   _avail_towrite);
+   bytes_avail_towrite = hv_get_bytes_to_write(outring_info);
 
/*
 * If there is only room for the packet, assume it is full.
@@ -386,7 +374,6 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info 
*inring_info,
   void *buffer, u32 buflen, u32 *buffer_actual_len,
   u64 *requestid, bool *signal, bool raw)
 {
-   u32 bytes_avail_towrite;
u32 bytes_avail_toread;
u32 next_read_location = 0;
u64 prev_indices = 0;
@@ -402,10 +389,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info 
*inring_info,
*buffer_actual_len = 0;
*requestid = 0;
 
-   hv_get_ringbuffer_availbytes(inring_info,
-   _avail_toread,
-   _avail_towrite);
-
+   bytes_avail_toread = hv_get_bytes_to_read(inring_info);
/* Make sure there is something to read */
if (bytes_avail_toread < sizeof(desc)) {
/*
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index ecd81c3..a6b053c 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -151,6 +151,33 @@ hv_get_ringbuffer_availbytes(struct hv_ring_buffer_info 
*rbi,
*read = dsize - *write;
 }
 
+static inline u32 hv_get_bytes_to_read(struct hv_ring_buffer_info *rbi)
+{
+   u32 read_loc, write_loc, dsize, read;
+
+   dsize = rbi->ring_datasize;
+   read_loc = rbi->ring_buffer->read_index;
+   write_loc = READ_ONCE(rbi->ring_buffer->write_index);
+
+   read = write_loc >= read_loc ? (write_loc - read_loc) :
+   (dsize - read_loc) + write_loc;
+
+   return read;
+}
+
+static inline u32 hv_get_bytes_to_write(struct hv_ring_buffer_info *rbi)
+{
+   u32 read_loc, write_loc, dsize, write;
+
+   dsize = rbi->ring_datasize;
+   read_loc = READ_ONCE(rbi->ring_buffer->read_index);
+   write_loc = rbi->ring_buffer->write_index;
+
+   write = write_loc >= read_loc ? dsize - (write_loc - read_loc) :
+   read_loc - write_loc;
+   return write;
+}
+
 /*
  * VMBUS version is 32 bit entity broken up into
  * two 16 bit quantities: major_number. minor_number.
-- 
1.7.4.1



[PATCH 4/7] Drivers: hv: vmbus: Use the new virt_xx barrier code

2016-03-23 Thread K. Y. Srinivasan
Use the virt_xx barriers that have been defined for use in virtual machines.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/hv/ring_buffer.c |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 67dc245..c2c2b2e 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -33,14 +33,14 @@
 void hv_begin_read(struct hv_ring_buffer_info *rbi)
 {
rbi->ring_buffer->interrupt_mask = 1;
-   mb();
+   virt_mb();
 }
 
 u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 {
 
rbi->ring_buffer->interrupt_mask = 0;
-   mb();
+   virt_mb();
 
/*
 * Now check to see if the ring buffer is still empty.
@@ -68,12 +68,12 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
 
 static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi)
 {
-   mb();
+   virt_mb();
if (READ_ONCE(rbi->ring_buffer->interrupt_mask))
return false;
 
/* check interrupt_mask before read_index */
-   rmb();
+   virt_rmb();
/*
 * This is the only case we need to signal when the
 * ring transitions from being empty to non-empty.
@@ -104,7 +104,7 @@ static bool hv_need_to_signal_on_read(struct 
hv_ring_buffer_info *rbi)
u32 cur_write_sz;
u32 pending_sz;
 
-   mb();
+   virt_mb();
pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
/* If the other end is not blocked on write don't bother. */
if (pending_sz == 0)
@@ -359,7 +359,7 @@ int hv_ringbuffer_write(struct hv_ring_buffer_info 
*outring_info,
 sizeof(u64));
 
/* Issue a full memory barrier before updating the write index */
-   mb();
+   virt_mb();
 
/* Now, update the write location */
hv_set_next_write_location(outring_info, next_write_location);
@@ -435,7 +435,7 @@ int hv_ringbuffer_read(struct hv_ring_buffer_info 
*inring_info,
 * the writer may start writing to the read area once the read index
 * is updated.
 */
-   mb();
+   virt_mb();
 
/* Update the read index */
hv_set_next_read_location(inring_info, next_read_location);
-- 
1.7.4.1



[PATCH 0/7] Drivers: hv: vmbus: Cleanup the ring buffer code

2016-03-23 Thread K. Y. Srinivasan
Cleanup and fix a bug in the ring buffer code. Also implement
APIs for in place consumption of received packets.

K. Y. Srinivasan (7):
  Drivers: hv: vmbus: Introduce functions for estimating room in the
ring buffer
  Drivers: hv: vmbus: Use READ_ONCE() to read variables that are
volatile
  Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read()
  Drivers: hv: vmbus: Use the new virt_xx barrier code
  Drivers: hv: vmbus: Export the vmbus_set_event() API
  Drivers: hv: vmbus: Move some ring buffer functions to hyperv.h
  Drivers: hv: vmbus: Implement APIs to support "in place" consumption
of vmbus packets

 drivers/hv/connection.c   |1 +
 drivers/hv/hyperv_vmbus.h |2 -
 drivers/hv/ring_buffer.c  |   79 ---
 include/linux/hyperv.h|  156 +
 4 files changed, 169 insertions(+), 69 deletions(-)

-- 
1.7.4.1



[PATCH 0/7] Drivers: hv: vmbus: Cleanup the ring buffer code

2016-03-23 Thread K. Y. Srinivasan
Cleanup and fix a bug in the ring buffer code. Also implement
APIs for in place consumption of received packets.

K. Y. Srinivasan (7):
  Drivers: hv: vmbus: Introduce functions for estimating room in the
ring buffer
  Drivers: hv: vmbus: Use READ_ONCE() to read variables that are
volatile
  Drivers: hv: vmbus: Fix a bug in hv_need_to_signal_on_read()
  Drivers: hv: vmbus: Use the new virt_xx barrier code
  Drivers: hv: vmbus: Export the vmbus_set_event() API
  Drivers: hv: vmbus: Move some ring buffer functions to hyperv.h
  Drivers: hv: vmbus: Implement APIs to support "in place" consumption
of vmbus packets

 drivers/hv/connection.c   |1 +
 drivers/hv/hyperv_vmbus.h |2 -
 drivers/hv/ring_buffer.c  |   79 ---
 include/linux/hyperv.h|  156 +
 4 files changed, 169 insertions(+), 69 deletions(-)

-- 
1.7.4.1



Re: [Patch V2 2/2] iommu: remove sysfs_link to device in iommu_group/devices when failed

2016-03-23 Thread Alex Williamson
On Wed, 23 Mar 2016 22:25:11 +
Wei Yang  wrote:

> The original code forgets to remove the sysfs_link to a device in
> iommu_group/devices directory, when the creation fails or conflicts on the
> name.
> 
> This patch tries to remove the sysfs_link on the failure.
> 
> Signed-off-by: Wei Yang 
> ---
>  drivers/iommu/iommu.c |1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 2696a38..8f480ba 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -403,6 +403,7 @@ rename:
>   ret = sysfs_create_link_nowarn(group->devices_kobj,
>  >kobj, device->name);
>   if (ret) {
> + sysfs_remove_link(group->devices_kobj, device->name);
>   kfree(device->name);
>   if (ret == -EEXIST && i >= 0) {
>   /*

If we failed to create a link, potentially due to a conflicting link
already present, then aren't we arbitrarily removing that conflicting
link with this change?  If sysfs_create_link_nowarn() fails then we
haven't created a link of our own to remove.  This looks wrong.  Thanks,

Alex


Re: [Patch V2 2/2] iommu: remove sysfs_link to device in iommu_group/devices when failed

2016-03-23 Thread Alex Williamson
On Wed, 23 Mar 2016 22:25:11 +
Wei Yang  wrote:

> The original code forgets to remove the sysfs_link to a device in
> iommu_group/devices directory, when the creation fails or conflicts on the
> name.
> 
> This patch tries to remove the sysfs_link on the failure.
> 
> Signed-off-by: Wei Yang 
> ---
>  drivers/iommu/iommu.c |1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 2696a38..8f480ba 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -403,6 +403,7 @@ rename:
>   ret = sysfs_create_link_nowarn(group->devices_kobj,
>  >kobj, device->name);
>   if (ret) {
> + sysfs_remove_link(group->devices_kobj, device->name);
>   kfree(device->name);
>   if (ret == -EEXIST && i >= 0) {
>   /*

If we failed to create a link, potentially due to a conflicting link
already present, then aren't we arbitrarily removing that conflicting
link with this change?  If sysfs_create_link_nowarn() fails then we
haven't created a link of our own to remove.  This looks wrong.  Thanks,

Alex


Re: linux-next: manual merge of the rdma tree with the net-next tree

2016-03-23 Thread Or Gerlitz
On Wed, Mar 16, 2016 at 7:44 PM, Linus Torvalds
 wrote:
> On Wed, Mar 16, 2016 at 10:35 AM, Doug Ledford  wrote:
>> On 3/16/2016 1:18 PM, Linus Torvalds wrote:
>>> On Tue, Mar 15, 2016 at 5:58 PM, Stephen Rothwell  
>>> wrote:

 I fixed it up (see below) and can carry the fix as necessary (no action
 is required).

>>> Side note: can you change this wording for your manual merge script?
>>> Last merge window (or was it the one before it?) we had confusion with
>>> people who thought that "no action is required" means "you can just
>>> ignore this entirely".

>> I certainly didn't take it that way regardless of the wording.

> It was Or Gerlitz. You were cc'd, since it was the whole rdma Mellanox
> mess. I quote from that thread:
>
>  "> However, the fact that it got resolved in linux-next is purely
>   > informational. It doesn't "fix" the conflict - it just means that both
>   > sides should have gotten informed about it. That doesn't mean that the
>   > conflict goes away or becomes better.
>
>   That's news to me. When such things happen and caught by Stephen, we
>   are getting an email saying something like
>
>   "Today's linux-next merge of the infiniband tree got a conflict
>   between commit X from net-next tree and commit Y from the infiniband
>   tree. I fixed it up (see below) and can carry the fix as necessary (no
>   action is required)."
>
>   Also asked around a bit and got to learn on Stephen using git rerere,
>   so all (no action needed note + seeing git rerere in action...) that
>   leaded me to think that indeed no action is required from our side,
>   but after reading your email (twice, so far), I realized that this was
>   wrong conclusion."

> So that whole "no action is required" wording very much has caused
> confusion before in the rdma camp.

> Let's fix the wording. I'm indeed hopeful that the rdma camp is now
> keenly aware of the issues, but that doesn't change the fact that the
> wording has been problematic.

>> "[...] The Mellanox people are on my xxit-list until they show that they can
>> actually act like responsible people [...]"

Linus,

As I wrote you in that other thread you were quoting from there,
following to the happenings mentioned there, we took responsibility
and made bunch of corrective actions within Mellanox which got us to a
point where there was only one rdma/netdev-next conflict for the 4.6
merge window.

I know there's history here, and in the 4.5 cycle things were much
worse, but I still wanted to put things in their more precise place,
if you don't mind.

Or.


Re: linux-next: manual merge of the rdma tree with the net-next tree

2016-03-23 Thread Or Gerlitz
On Wed, Mar 16, 2016 at 7:44 PM, Linus Torvalds
 wrote:
> On Wed, Mar 16, 2016 at 10:35 AM, Doug Ledford  wrote:
>> On 3/16/2016 1:18 PM, Linus Torvalds wrote:
>>> On Tue, Mar 15, 2016 at 5:58 PM, Stephen Rothwell  
>>> wrote:

 I fixed it up (see below) and can carry the fix as necessary (no action
 is required).

>>> Side note: can you change this wording for your manual merge script?
>>> Last merge window (or was it the one before it?) we had confusion with
>>> people who thought that "no action is required" means "you can just
>>> ignore this entirely".

>> I certainly didn't take it that way regardless of the wording.

> It was Or Gerlitz. You were cc'd, since it was the whole rdma Mellanox
> mess. I quote from that thread:
>
>  "> However, the fact that it got resolved in linux-next is purely
>   > informational. It doesn't "fix" the conflict - it just means that both
>   > sides should have gotten informed about it. That doesn't mean that the
>   > conflict goes away or becomes better.
>
>   That's news to me. When such things happen and caught by Stephen, we
>   are getting an email saying something like
>
>   "Today's linux-next merge of the infiniband tree got a conflict
>   between commit X from net-next tree and commit Y from the infiniband
>   tree. I fixed it up (see below) and can carry the fix as necessary (no
>   action is required)."
>
>   Also asked around a bit and got to learn on Stephen using git rerere,
>   so all (no action needed note + seeing git rerere in action...) that
>   leaded me to think that indeed no action is required from our side,
>   but after reading your email (twice, so far), I realized that this was
>   wrong conclusion."

> So that whole "no action is required" wording very much has caused
> confusion before in the rdma camp.

> Let's fix the wording. I'm indeed hopeful that the rdma camp is now
> keenly aware of the issues, but that doesn't change the fact that the
> wording has been problematic.

>> "[...] The Mellanox people are on my xxit-list until they show that they can
>> actually act like responsible people [...]"

Linus,

As I wrote you in that other thread you were quoting from there,
following to the happenings mentioned there, we took responsibility
and made bunch of corrective actions within Mellanox which got us to a
point where there was only one rdma/netdev-next conflict for the 4.6
merge window.

I know there's history here, and in the 4.5 cycle things were much
worse, but I still wanted to put things in their more precise place,
if you don't mind.

Or.


[PATCH] staging: xgifb: remove extra braces from if stmt (single branch)

2016-03-23 Thread Nicholas Sim
Remove braces from one branch of if statement where both branches only
have a single line of code, as suggested in Documentation/CodingStyle

Signed-off-by: Nicholas Sim 
---
 drivers/staging/xgifb/vb_setmode.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index 14230c2..40939c8 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -3840,9 +3840,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
if (pVBInfo->VGAVDE == 525) {
if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
| VB_SIS301LV | VB_SIS302LV
-   | VB_XGI301C)) {
+   | VB_XGI301C))
temp = 0xC6;
-   } else
+   else
temp = 0xC4;
 
xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
@@ -3852,9 +3852,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
if (pVBInfo->VGAVDE == 420) {
if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
| VB_SIS301LV | VB_SIS302LV
-   | VB_XGI301C)) {
+   | VB_XGI301C))
temp = 0x4F;
-   } else
+   else
temp = 0x4E;
xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
}
-- 
2.4.3



[PATCH] staging: xgifb: remove extra braces from if stmt (single branch)

2016-03-23 Thread Nicholas Sim
Remove braces from one branch of if statement where both branches only
have a single line of code, as suggested in Documentation/CodingStyle

Signed-off-by: Nicholas Sim 
---
 drivers/staging/xgifb/vb_setmode.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index 14230c2..40939c8 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -3840,9 +3840,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
if (pVBInfo->VGAVDE == 525) {
if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
| VB_SIS301LV | VB_SIS302LV
-   | VB_XGI301C)) {
+   | VB_XGI301C))
temp = 0xC6;
-   } else
+   else
temp = 0xC4;
 
xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
@@ -3852,9 +3852,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
if (pVBInfo->VGAVDE == 420) {
if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
| VB_SIS301LV | VB_SIS302LV
-   | VB_XGI301C)) {
+   | VB_XGI301C))
temp = 0x4F;
-   } else
+   else
temp = 0x4E;
xgifb_reg_set(pVBInfo->Part2Port, 0x2f, temp);
}
-- 
2.4.3



[PATCH] staging: xgifb: ensure braces on all arms of if stmt

2016-03-23 Thread Nicholas Sim
Added braces on else arm of if statement where if arm already has braces
as suggested for clarity in Documentation/CodingStyle

Signed-off-by: Nicholas Sim 
---
 drivers/staging/xgifb/vb_setmode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index f97c77d..14230c2 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -3450,8 +3450,9 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned 
short ModeIdIndex,
if (!(pVBInfo->TVInfo &
(TVSetYPbPr525p | TVSetYPbPr750p)))
tempbx >>= 1;
-   } else
+   } else {
tempbx >>= 1;
+   }
}
 
tempbx -= 2;
-- 
2.4.3



[PATCH] staging: xgifb: ensure braces on all arms of if stmt

2016-03-23 Thread Nicholas Sim
Added braces on else arm of if statement where if arm already has braces
as suggested for clarity in Documentation/CodingStyle

Signed-off-by: Nicholas Sim 
---
 drivers/staging/xgifb/vb_setmode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c 
b/drivers/staging/xgifb/vb_setmode.c
index f97c77d..14230c2 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -3450,8 +3450,9 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned 
short ModeIdIndex,
if (!(pVBInfo->TVInfo &
(TVSetYPbPr525p | TVSetYPbPr750p)))
tempbx >>= 1;
-   } else
+   } else {
tempbx >>= 1;
+   }
}
 
tempbx -= 2;
-- 
2.4.3



[PATCH] gpio / ACPI: ignore GpioInt() GPIOs when requesting GPIO_OUT_*

2016-03-23 Thread Dmitry Torokhov
From: Dmitry Torokhov 

When firmware does not use _DSD properties that allow properly name GPIO
resources, the kernel falls back on parsing _CRS resources, and will
return entries described as GpioInt() as general purpose GPIOs even
though they are meant to be used simply as interrupt sources for the
device:

Device (ETSA)
{
Name (_HID, "ELAN0001")
...

Method(_CRS, 0x0, NotSerialized)
{
Name(BUF0,ResourceTemplate ()
{
I2CSerialBus(
0x10, /* SlaveAddress */
ControllerInitiated,  /* SlaveMode */
40,   /* ConnectionSpeed */
AddressingMode7Bit,   /* AddressingMode */
"\\_SB.I2C1", /* ResourceSource */
)
GpioInt (Edge, ActiveLow, ExclusiveAndWake, PullNone,,
 "\\_SB.GPSW") { BOARD_TOUCH_GPIO_INDEX }
} )
Return (BUF0)
}
...
}

This gives troubles with drivers such as Elan Touchscreen driver
(elants_i2c) that uses devm_gpio_get to look up "reset" GPIO line and
decide whether the driver is responsible for powering up and resetting
the device or firmware is. In the above case the lookup succeeds, we map
GPIO as output and later fail to request client->irq interrupt that is
mapped to the same GPIO.

Let's ignore resources described as GpioInt() when requesting output
GPIO (but allow them when requesting GPIOD_ASIS or GPIOD_IN as some
drivers - i2c-hid - do request GPIO as input and then map it to
interrupt with gpiod_to_irq).

BUG=chrome-os-partner:51154
TEST=Boot Cyan, verify touchscreen work

Change-Id: Id20c730b937dce8a4135d2b64c8d798372d20e82
Signed-off-by: Dmitry Torokhov 
---
 drivers/gpio/gpiolib.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 7206553..4a0e66b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2231,9 +2231,11 @@ static struct gpio_desc *of_find_gpio(struct device 
*dev, const char *con_id,
return desc;
 }
 
-static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
+static struct gpio_desc *acpi_find_gpio(struct device *dev,
+   const char *con_id,
unsigned int idx,
-   enum gpio_lookup_flags *flags)
+   enum gpiod_flags flags,
+   enum gpio_lookup_flags *lookupflags)
 {
struct acpi_device *adev = ACPI_COMPANION(dev);
struct acpi_gpio_info info;
@@ -2264,10 +2266,16 @@ static struct gpio_desc *acpi_find_gpio(struct device 
*dev, const char *con_id,
desc = acpi_get_gpiod_by_index(adev, NULL, idx, );
if (IS_ERR(desc))
return desc;
+
+   if ((flags == GPIOD_OUT_LOW || flags == GPIOD_OUT_HIGH) &&
+   info.gpioint) {
+   dev_dbg(dev, "refusing GpioInt() entry when doing 
GPIOD_OUT_* lookup\n");
+   return ERR_PTR(-ENOENT);
+   }
}
 
if (info.polarity == GPIO_ACTIVE_LOW)
-   *flags |= GPIO_ACTIVE_LOW;
+   *lookupflags |= GPIO_ACTIVE_LOW;
 
return desc;
 }
@@ -2530,7 +2538,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct 
device *dev,
desc = of_find_gpio(dev, con_id, idx, );
} else if (ACPI_COMPANION(dev)) {
dev_dbg(dev, "using ACPI for GPIO lookup\n");
-   desc = acpi_find_gpio(dev, con_id, idx, );
+   desc = acpi_find_gpio(dev, con_id, idx, flags, 
);
}
}
 
-- 
2.8.0.rc3.226.g39d4020


-- 
Dmitry


[PATCH] gpio / ACPI: ignore GpioInt() GPIOs when requesting GPIO_OUT_*

2016-03-23 Thread Dmitry Torokhov
From: Dmitry Torokhov 

When firmware does not use _DSD properties that allow properly name GPIO
resources, the kernel falls back on parsing _CRS resources, and will
return entries described as GpioInt() as general purpose GPIOs even
though they are meant to be used simply as interrupt sources for the
device:

Device (ETSA)
{
Name (_HID, "ELAN0001")
...

Method(_CRS, 0x0, NotSerialized)
{
Name(BUF0,ResourceTemplate ()
{
I2CSerialBus(
0x10, /* SlaveAddress */
ControllerInitiated,  /* SlaveMode */
40,   /* ConnectionSpeed */
AddressingMode7Bit,   /* AddressingMode */
"\\_SB.I2C1", /* ResourceSource */
)
GpioInt (Edge, ActiveLow, ExclusiveAndWake, PullNone,,
 "\\_SB.GPSW") { BOARD_TOUCH_GPIO_INDEX }
} )
Return (BUF0)
}
...
}

This gives troubles with drivers such as Elan Touchscreen driver
(elants_i2c) that uses devm_gpio_get to look up "reset" GPIO line and
decide whether the driver is responsible for powering up and resetting
the device or firmware is. In the above case the lookup succeeds, we map
GPIO as output and later fail to request client->irq interrupt that is
mapped to the same GPIO.

Let's ignore resources described as GpioInt() when requesting output
GPIO (but allow them when requesting GPIOD_ASIS or GPIOD_IN as some
drivers - i2c-hid - do request GPIO as input and then map it to
interrupt with gpiod_to_irq).

BUG=chrome-os-partner:51154
TEST=Boot Cyan, verify touchscreen work

Change-Id: Id20c730b937dce8a4135d2b64c8d798372d20e82
Signed-off-by: Dmitry Torokhov 
---
 drivers/gpio/gpiolib.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 7206553..4a0e66b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2231,9 +2231,11 @@ static struct gpio_desc *of_find_gpio(struct device 
*dev, const char *con_id,
return desc;
 }
 
-static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
+static struct gpio_desc *acpi_find_gpio(struct device *dev,
+   const char *con_id,
unsigned int idx,
-   enum gpio_lookup_flags *flags)
+   enum gpiod_flags flags,
+   enum gpio_lookup_flags *lookupflags)
 {
struct acpi_device *adev = ACPI_COMPANION(dev);
struct acpi_gpio_info info;
@@ -2264,10 +2266,16 @@ static struct gpio_desc *acpi_find_gpio(struct device 
*dev, const char *con_id,
desc = acpi_get_gpiod_by_index(adev, NULL, idx, );
if (IS_ERR(desc))
return desc;
+
+   if ((flags == GPIOD_OUT_LOW || flags == GPIOD_OUT_HIGH) &&
+   info.gpioint) {
+   dev_dbg(dev, "refusing GpioInt() entry when doing 
GPIOD_OUT_* lookup\n");
+   return ERR_PTR(-ENOENT);
+   }
}
 
if (info.polarity == GPIO_ACTIVE_LOW)
-   *flags |= GPIO_ACTIVE_LOW;
+   *lookupflags |= GPIO_ACTIVE_LOW;
 
return desc;
 }
@@ -2530,7 +2538,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct 
device *dev,
desc = of_find_gpio(dev, con_id, idx, );
} else if (ACPI_COMPANION(dev)) {
dev_dbg(dev, "using ACPI for GPIO lookup\n");
-   desc = acpi_find_gpio(dev, con_id, idx, );
+   desc = acpi_find_gpio(dev, con_id, idx, flags, 
);
}
}
 
-- 
2.8.0.rc3.226.g39d4020


-- 
Dmitry


Proposal for Anti-Keystroke Fingerprinting at the Input Driver Level

2016-03-23 Thread bancfc

== Attack Description ==

Keystroke fingerprinting works by measuring how long keys are pressed 
and the time between presses. Its very high accuracy poses a serious 
threat to anonymous users.[1]


This tracking technology has been deployed by major advertisers (Google, 
Facebook), banks and massive online courses. Its also happening at a 
massive scale because just using a JS application (or SSH in interactive 
mode) in presence of a network adversary that records all traffic allows 
them to construct biometric models for virtually everyone (think Google 
suggestions) even if the website does not record these biometric stats 
itself.[2] They have this data from everyone's clearnet browsing and by 
comparing this to data exiting the Tor network they will unmask users.



== Current Measures and Threat Model ==

While the Tor Browser team is aware of the problem and working on a 
solution, current measures [6] are not enough. [4][5]


It's very useful to have it fixed on the OS level so even compromised 
VMs could not perform keystroke fingerprinting. Another reason is, that 
other applications (chat clients come to mind) and others that implement 
javascript one or another way, may be leaking this also. So having this 
fixed in Tor Browser is nice but non-ideal.


This is valid for systems running in VMs or on bare metal such as the 
TAILS Anonymous distro.



== Existing Work on Countermeasures ==

As a countermeasure security researcher Paul Moore created a prototype 
Chrome plugin known as KeyboardPrivacy. It works by caching keystrokes 
and introducing a random delay before passing them on to a webpage.[3] 
Unfortunately there is no source code available for the add-on and the 
planned Firefox version has not surfaced so far. There are hints that 
the author wants to create a closed hardware USB device that implements 
this which does not help our cause.


GenodeOS a security centric microkernel OS has already implemented a 
solution: https://github.com/genodelabs/genode-world/issues/12


QubesOS a security centric OS based on Xen will add a fix to deal with 
it.


A widely deployed Linux version only makes sense and would have the 
greatest impact for security of most free/open systems out there.



== Proposal for a System-wide Solution ==

A very much needed project would be to write a program that mimics the 
functionality of the this add-on but on the kernel level. Implementing 
it in the kernel ensures absolutely everything consuming input events on 
a workstation is protected.



[1] 
http://arstechnica.com/security/2015/07/how-the-way-you-type-can-shatter-anonymity-even-on-tor/


[2] http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=7358795

[3] https://archive.is/vCvWb

[4] 
https://www.lightbluetouchpaper.org/2015/07/30/double-bill-password-hashing-competition-keyboardprivacy/#comment-1288166


[5] https://trac.torproject.org/projects/tor/ticket/16110

[6] https://trac.torproject.org/projects/tor/ticket/1517




Proposal for Anti-Keystroke Fingerprinting at the Input Driver Level

2016-03-23 Thread bancfc

== Attack Description ==

Keystroke fingerprinting works by measuring how long keys are pressed 
and the time between presses. Its very high accuracy poses a serious 
threat to anonymous users.[1]


This tracking technology has been deployed by major advertisers (Google, 
Facebook), banks and massive online courses. Its also happening at a 
massive scale because just using a JS application (or SSH in interactive 
mode) in presence of a network adversary that records all traffic allows 
them to construct biometric models for virtually everyone (think Google 
suggestions) even if the website does not record these biometric stats 
itself.[2] They have this data from everyone's clearnet browsing and by 
comparing this to data exiting the Tor network they will unmask users.



== Current Measures and Threat Model ==

While the Tor Browser team is aware of the problem and working on a 
solution, current measures [6] are not enough. [4][5]


It's very useful to have it fixed on the OS level so even compromised 
VMs could not perform keystroke fingerprinting. Another reason is, that 
other applications (chat clients come to mind) and others that implement 
javascript one or another way, may be leaking this also. So having this 
fixed in Tor Browser is nice but non-ideal.


This is valid for systems running in VMs or on bare metal such as the 
TAILS Anonymous distro.



== Existing Work on Countermeasures ==

As a countermeasure security researcher Paul Moore created a prototype 
Chrome plugin known as KeyboardPrivacy. It works by caching keystrokes 
and introducing a random delay before passing them on to a webpage.[3] 
Unfortunately there is no source code available for the add-on and the 
planned Firefox version has not surfaced so far. There are hints that 
the author wants to create a closed hardware USB device that implements 
this which does not help our cause.


GenodeOS a security centric microkernel OS has already implemented a 
solution: https://github.com/genodelabs/genode-world/issues/12


QubesOS a security centric OS based on Xen will add a fix to deal with 
it.


A widely deployed Linux version only makes sense and would have the 
greatest impact for security of most free/open systems out there.



== Proposal for a System-wide Solution ==

A very much needed project would be to write a program that mimics the 
functionality of the this add-on but on the kernel level. Implementing 
it in the kernel ensures absolutely everything consuming input events on 
a workstation is protected.



[1] 
http://arstechnica.com/security/2015/07/how-the-way-you-type-can-shatter-anonymity-even-on-tor/


[2] http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=7358795

[3] https://archive.is/vCvWb

[4] 
https://www.lightbluetouchpaper.org/2015/07/30/double-bill-password-hashing-competition-keyboardprivacy/#comment-1288166


[5] https://trac.torproject.org/projects/tor/ticket/16110

[6] https://trac.torproject.org/projects/tor/ticket/1517




Re: [tip:perf/urgent] perf/x86/cqm: Fix CQM handling of grouping events into a cache_group

2016-03-23 Thread Vikas Shivappa



On Wed, 23 Mar 2016, Matt Fleming wrote:


On Mon, 21 Mar, at 11:14:37AM, Vikas Shivappa wrote:



Before MBM , the below condition was never hit because we had only one event ?

-   if (a->hw.target == b->hw.target)
+   if (a->hw.target == b->hw.target) {
+   b->hw.is_group_event = true;

We are trying to address this for cases where different MBM(local or total)
and cqm events are grouped into one RMID.


I can't test these changes, so I'm only working from memory, but I
seem to recall that this condition is hit if monitoring simultaneously
from two invocations of perf. It's also possible to have pid/tid
groups overlapping, and that needs to be handled.


Each task in a multithreaded process has an event. So it gets a different RMID. 
If two perf instances invoke 
the same pid then both of the instances expect to see the counters so its 
reported to both of them.





Which is the case which led to duplicate values ?


Good question. Try monitoring a multithread process with these changes
and see if you get duplicate values reported.


perf starts an event for each thread even when you give -p   a 
process which has multiple threads).
So it sends the pid of each thread to monitor and they get all seperate RMIDs. 
This should apply to the groups overlapping as well as this is dealing with only 
the perf task events..






Re: [tip:perf/urgent] perf/x86/cqm: Fix CQM handling of grouping events into a cache_group

2016-03-23 Thread Vikas Shivappa



On Wed, 23 Mar 2016, Matt Fleming wrote:


On Mon, 21 Mar, at 11:14:37AM, Vikas Shivappa wrote:



Before MBM , the below condition was never hit because we had only one event ?

-   if (a->hw.target == b->hw.target)
+   if (a->hw.target == b->hw.target) {
+   b->hw.is_group_event = true;

We are trying to address this for cases where different MBM(local or total)
and cqm events are grouped into one RMID.


I can't test these changes, so I'm only working from memory, but I
seem to recall that this condition is hit if monitoring simultaneously
from two invocations of perf. It's also possible to have pid/tid
groups overlapping, and that needs to be handled.


Each task in a multithreaded process has an event. So it gets a different RMID. 
If two perf instances invoke 
the same pid then both of the instances expect to see the counters so its 
reported to both of them.





Which is the case which led to duplicate values ?


Good question. Try monitoring a multithread process with these changes
and see if you get duplicate values reported.


perf starts an event for each thread even when you give -p   a 
process which has multiple threads).
So it sends the pid of each thread to monitor and they get all seperate RMIDs. 
This should apply to the groups overlapping as well as this is dealing with only 
the perf task events..






Re: [PATCH 08/17] watchdog: qcom: configure BARK time in addition to BITE time

2016-03-23 Thread Stephen Boyd
On 03/23, Matthew McClintock wrote:
> For certain parts and some versions of TZ, TZ will reset the chip
> when a BARK is triggered even though it was not configured here. So
> by default let's configure this BARK time as well.
> 

Why isn't TZ configuring the bark time to what it wants? I'm lost
why we have to do this for them.

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


Re: [PATCH 08/17] watchdog: qcom: configure BARK time in addition to BITE time

2016-03-23 Thread Stephen Boyd
On 03/23, Matthew McClintock wrote:
> For certain parts and some versions of TZ, TZ will reset the chip
> when a BARK is triggered even though it was not configured here. So
> by default let's configure this BARK time as well.
> 

Why isn't TZ configuring the bark time to what it wants? I'm lost
why we have to do this for them.

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


Re: [PATCH v4 00/20] x86, boot: kaslr cleanup and 64bit kaslr support

2016-03-23 Thread Kees Cook
On Tue, Mar 22, 2016 at 1:25 PM, Kees Cook  wrote:
> On Tue, Mar 22, 2016 at 12:31 AM, Baoquan He  wrote:
>> ***Background:
>> Previously a bug is reported that kdump didn't work when kaslr is enabled. 
>> During
>> discussing that bug fix, we found current kaslr has a limilation that it can
>> only randomize in 1GB region.
>>
>> This is because in curent kaslr implementaion only physical address of kernel
>> loading is randomized. Then calculate the delta of physical address where
>> vmlinux was linked to load and where it is finally loaded. If delta is not
>> equal to 0, namely there's a new physical address where kernel is actually
>> decompressed, relocation handling need be done. Then delta is added to offset
>> of kernel symbol relocation, this makes the address of kernel text mapping 
>> move
>> delta long. Though in principle kernel can be randomized to any physical 
>> address,
>> kernel text mapping address space is limited and only 1G, namely as follows 
>> on
>> x86_64:
>> [0x8000, 0xc000)
>>
>> In one word, kernel text physical address and virtual address randomization 
>> is
>> coupled. This causes the limitation.
>>
>> Then hpa and Vivek suggested we should change this. To decouple the physical
>> address and virtual address randomization of kernel text and let them work
>> separately. Then kernel text physical address can be randomized in region
>> [16M, 64T), and kernel text virtual address can be randomized in region
>> [0x8000, 0xc000).
>>
>> ***Problems we need solved:
>>   - For kernel boot from startup_32 case, only 0~4G identity mapping is 
>> built.
>> If kernel will be randomly put anywhere from 16M to 64T at most, the 
>> price
>> to build all region of identity mapping is too high. We need build the
>> identity mapping on demand, not covering all physical address space.
>>
>>   - Decouple the physical address and virtual address randomization of kernel
>> text and let them work separately.
>>
>> ***Parts:
>>- The 1st part is Yinghai's identity mapping building on demand patches.
>>  This is used to solve the first problem mentioned above.
>>  (Patch 09-10/19)
>>- The 2nd part is decoupling the physical address and virtual address
>>  randomization of kernel text and letting them work separately patches
>>  based on Yinghai's ident mapping patches.
>>  (Patch 12-19/19)
>>- The 3rd part is some clean up patches which Yinghai found when he 
>> reviewed
>>  my patches and the related code around.
>>  (Patch 01-08/19)
>>
>> ***Patch status:
>> This patchset went through several rounds of review.
>>
>> v1:
>> - The first round can be found here:
>> https://lwn.net/Articles/637115/
>>
>> v1->v2:
>> - In 2nd round Yinghai made a big patchset including this kaslr fix and 
>> another
>>   setup_data related fix. The link is here:
>>
>> http://lists-archives.com/linux-kernel/28346903-x86-updated-patches-for-kaslr-and-setup_data-etc-for-v4-3.html
>>   You can get the code from Yinghai's git branch:
>>   
>> git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git 
>> for-x86-v4.3-next
>>
>> v2->v3:
>> - It only takes care of the kaslr related patches.
>>   For reviewers it's better to discuss only one issue in one thread.
>> * I take off one patch as follows from Yinghai's because I think 
>> it's unnecessay.
>>- Patch 05/19 x86, kaslr: rename output_size to output_run_size
>>  output_size is enough to represen the value:
>> output_len > run_size ? output_len : run_size
>>
>> * I add Patch 04/19, it's a comment update patch. For other patches, 
>> I just
>>   adjust patch log and do several places of change comparing with 
>> 2nd round.
>>   Please check the change log under patch log of each patch for 
>> details.
>>
>> * Adjust sequence of several patches to make review easier. It 
>> doesn't
>>   affect codes.
>>
>> v3->v4:
>> - Made changes according to Kees's comments.
>>   Add one patch 20/20 as Kees suggested to use KERNEL_IMAGE_SIZE as 
>> offset
>>   max of virtual random, meanwhile clean up useless 
>> CONFIG_RANDOM_OFFSET_MAX
>>
>> x86, kaslr: Use KERNEL_IMAGE_SIZE as the offset max for kernel 
>> virtual randomization
>
> This series is looking good to me. I'm running tests under qemu now,
> and things appear to work as advertised. :) I'll report back once I've
> booted a few hundred times.

My qemu isn't implementing rdrand, so my entropy source is poor, but I
had 7322 successful boots, with 6356 unique physical memory positions
and 487 unique virtual memory positions.

With 48G of physical memory, I'd expect to see more physical positions
(i.e. for a 24M kernel (using 12 slots), avoiding the first 512M (256
slots), I'd expect to see closer to 24308 

Re: [PATCH v4 00/20] x86, boot: kaslr cleanup and 64bit kaslr support

2016-03-23 Thread Kees Cook
On Tue, Mar 22, 2016 at 1:25 PM, Kees Cook  wrote:
> On Tue, Mar 22, 2016 at 12:31 AM, Baoquan He  wrote:
>> ***Background:
>> Previously a bug is reported that kdump didn't work when kaslr is enabled. 
>> During
>> discussing that bug fix, we found current kaslr has a limilation that it can
>> only randomize in 1GB region.
>>
>> This is because in curent kaslr implementaion only physical address of kernel
>> loading is randomized. Then calculate the delta of physical address where
>> vmlinux was linked to load and where it is finally loaded. If delta is not
>> equal to 0, namely there's a new physical address where kernel is actually
>> decompressed, relocation handling need be done. Then delta is added to offset
>> of kernel symbol relocation, this makes the address of kernel text mapping 
>> move
>> delta long. Though in principle kernel can be randomized to any physical 
>> address,
>> kernel text mapping address space is limited and only 1G, namely as follows 
>> on
>> x86_64:
>> [0x8000, 0xc000)
>>
>> In one word, kernel text physical address and virtual address randomization 
>> is
>> coupled. This causes the limitation.
>>
>> Then hpa and Vivek suggested we should change this. To decouple the physical
>> address and virtual address randomization of kernel text and let them work
>> separately. Then kernel text physical address can be randomized in region
>> [16M, 64T), and kernel text virtual address can be randomized in region
>> [0x8000, 0xc000).
>>
>> ***Problems we need solved:
>>   - For kernel boot from startup_32 case, only 0~4G identity mapping is 
>> built.
>> If kernel will be randomly put anywhere from 16M to 64T at most, the 
>> price
>> to build all region of identity mapping is too high. We need build the
>> identity mapping on demand, not covering all physical address space.
>>
>>   - Decouple the physical address and virtual address randomization of kernel
>> text and let them work separately.
>>
>> ***Parts:
>>- The 1st part is Yinghai's identity mapping building on demand patches.
>>  This is used to solve the first problem mentioned above.
>>  (Patch 09-10/19)
>>- The 2nd part is decoupling the physical address and virtual address
>>  randomization of kernel text and letting them work separately patches
>>  based on Yinghai's ident mapping patches.
>>  (Patch 12-19/19)
>>- The 3rd part is some clean up patches which Yinghai found when he 
>> reviewed
>>  my patches and the related code around.
>>  (Patch 01-08/19)
>>
>> ***Patch status:
>> This patchset went through several rounds of review.
>>
>> v1:
>> - The first round can be found here:
>> https://lwn.net/Articles/637115/
>>
>> v1->v2:
>> - In 2nd round Yinghai made a big patchset including this kaslr fix and 
>> another
>>   setup_data related fix. The link is here:
>>
>> http://lists-archives.com/linux-kernel/28346903-x86-updated-patches-for-kaslr-and-setup_data-etc-for-v4-3.html
>>   You can get the code from Yinghai's git branch:
>>   
>> git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git 
>> for-x86-v4.3-next
>>
>> v2->v3:
>> - It only takes care of the kaslr related patches.
>>   For reviewers it's better to discuss only one issue in one thread.
>> * I take off one patch as follows from Yinghai's because I think 
>> it's unnecessay.
>>- Patch 05/19 x86, kaslr: rename output_size to output_run_size
>>  output_size is enough to represen the value:
>> output_len > run_size ? output_len : run_size
>>
>> * I add Patch 04/19, it's a comment update patch. For other patches, 
>> I just
>>   adjust patch log and do several places of change comparing with 
>> 2nd round.
>>   Please check the change log under patch log of each patch for 
>> details.
>>
>> * Adjust sequence of several patches to make review easier. It 
>> doesn't
>>   affect codes.
>>
>> v3->v4:
>> - Made changes according to Kees's comments.
>>   Add one patch 20/20 as Kees suggested to use KERNEL_IMAGE_SIZE as 
>> offset
>>   max of virtual random, meanwhile clean up useless 
>> CONFIG_RANDOM_OFFSET_MAX
>>
>> x86, kaslr: Use KERNEL_IMAGE_SIZE as the offset max for kernel 
>> virtual randomization
>
> This series is looking good to me. I'm running tests under qemu now,
> and things appear to work as advertised. :) I'll report back once I've
> booted a few hundred times.

My qemu isn't implementing rdrand, so my entropy source is poor, but I
had 7322 successful boots, with 6356 unique physical memory positions
and 487 unique virtual memory positions.

With 48G of physical memory, I'd expect to see more physical positions
(i.e. for a 24M kernel (using 12 slots), avoiding the first 512M (256
slots), I'd expect to see closer to 24308 positions (48G / 2M - 12 -
256)). The 

Re: [PATCH 07/17] watchdog: qcom: add option for standalone watchdog not in timer block

2016-03-23 Thread Stephen Boyd
On 03/23, Matthew McClintock wrote:
> @@ -202,13 +238,6 @@ static int qcom_wdt_remove(struct platform_device *pdev)
>   return 0;
>  }
>  
> -static const struct of_device_id qcom_wdt_of_table[] = {
> - { .compatible = "qcom,kpss-timer" },
> - { .compatible = "qcom,scss-timer" },
> - { },
> -};
> -MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);
> -

Leave this here and use of_device_get_match_data() in probe
instead.

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


Re: [PATCH 07/17] watchdog: qcom: add option for standalone watchdog not in timer block

2016-03-23 Thread Stephen Boyd
On 03/23, Matthew McClintock wrote:
> @@ -202,13 +238,6 @@ static int qcom_wdt_remove(struct platform_device *pdev)
>   return 0;
>  }
>  
> -static const struct of_device_id qcom_wdt_of_table[] = {
> - { .compatible = "qcom,kpss-timer" },
> - { .compatible = "qcom,scss-timer" },
> - { },
> -};
> -MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);
> -

Leave this here and use of_device_get_match_data() in probe
instead.

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


[PATCH v3] sparc/PCI: Fix for panic while enabling SR-IOV

2016-03-23 Thread Babu Moger
We noticed this panic while enabling SR-IOV in sparc.

mlx4_core: Mellanox ConnectX core driver v2.2-1 (Jan  1 2015)
mlx4_core: Initializing 0007:01:00.0
mlx4_core 0007:01:00.0: Enabling SR-IOV with 5 VFs
mlx4_core: Initializing 0007:01:00.1
Unable to handle kernel NULL pointer dereference
insmod(10010): Oops [#1]
CPU: 391 PID: 10010 Comm: insmod Not tainted
4.1.12-32.el6uek.kdump2.sparc64 #1
TPC: 
I7: <__mlx4_init_one+0x324/0x500 [mlx4_core]>
Call Trace:
 [104c5ea4] __mlx4_init_one+0x324/0x500 [mlx4_core]
 [104c613c] mlx4_init_one+0xbc/0x120 [mlx4_core]
 [00725f14] local_pci_probe+0x34/0xa0
 [00726028] pci_call_probe+0xa8/0xe0
 [00726310] pci_device_probe+0x50/0x80
 [0079f700] really_probe+0x140/0x420
 [0079fa24] driver_probe_device+0x44/0xa0
 [0079fb5c] __device_attach+0x3c/0x60
 [0079d85c] bus_for_each_drv+0x5c/0xa0
 [0079f588] device_attach+0x88/0xc0
 [0071acd0] pci_bus_add_device+0x30/0x80
 [00736090] virtfn_add.clone.1+0x210/0x360
 [007364a4] sriov_enable+0x2c4/0x520
 [0073672c] pci_enable_sriov+0x2c/0x40
 [104c2d58] mlx4_enable_sriov+0xf8/0x180 [mlx4_core]
 [104c49ac] mlx4_load_one+0x42c/0xd40 [mlx4_core]
Disabling lock debugging due to kernel taint
Caller[104c5ea4]: __mlx4_init_one+0x324/0x500 [mlx4_core]
Caller[104c613c]: mlx4_init_one+0xbc/0x120 [mlx4_core]
Caller[00725f14]: local_pci_probe+0x34/0xa0
Caller[00726028]: pci_call_probe+0xa8/0xe0
Caller[00726310]: pci_device_probe+0x50/0x80
Caller[0079f700]: really_probe+0x140/0x420
Caller[0079fa24]: driver_probe_device+0x44/0xa0
Caller[0079fb5c]: __device_attach+0x3c/0x60
Caller[0079d85c]: bus_for_each_drv+0x5c/0xa0
Caller[0079f588]: device_attach+0x88/0xc0
Caller[0071acd0]: pci_bus_add_device+0x30/0x80
Caller[00736090]: virtfn_add.clone.1+0x210/0x360
Caller[007364a4]: sriov_enable+0x2c4/0x520
Caller[0073672c]: pci_enable_sriov+0x2c/0x40
Caller[104c2d58]: mlx4_enable_sriov+0xf8/0x180 [mlx4_core]
Caller[104c49ac]: mlx4_load_one+0x42c/0xd40 [mlx4_core]
Caller[104c5f90]: __mlx4_init_one+0x410/0x500 [mlx4_core]
Caller[104c613c]: mlx4_init_one+0xbc/0x120 [mlx4_core]
Caller[00725f14]: local_pci_probe+0x34/0xa0
Caller[00726028]: pci_call_probe+0xa8/0xe0
Caller[00726310]: pci_device_probe+0x50/0x80
Caller[0079f700]: really_probe+0x140/0x420
Caller[0079fa24]: driver_probe_device+0x44/0xa0
Caller[0079fb08]: __driver_attach+0x88/0xa0
Caller[0079d90c]: bus_for_each_dev+0x6c/0xa0
Caller[0079f29c]: driver_attach+0x1c/0x40
Caller[0079e35c]: bus_add_driver+0x17c/0x220
Caller[007a02d4]: driver_register+0x74/0x120
Caller[007263fc]: __pci_register_driver+0x3c/0x60
Caller[104f62bc]: mlx4_init+0x60/0xcc [mlx4_core]
Kernel panic - not syncing: Fatal exception
Press Stop-A (L1-A) to return to the boot prom
---[ end Kernel panic - not syncing: Fatal exception

Details:
Here is the call sequence
virtfn_add->__mlx4_init_one->dma_set_mask->dma_supported

The panic happened at line 760(file arch/sparc/kernel/iommu.c)

758 int dma_supported(struct device *dev, u64 device_mask)
759 {
760 struct iommu *iommu = dev->archdata.iommu;
761 u64 dma_addr_mask = iommu->dma_addr_mask;
762
763 if (device_mask >= (1UL << 32UL))
764 return 0;
765
766 if ((device_mask & dma_addr_mask) == dma_addr_mask)
767 return 1;
768
769 #ifdef CONFIG_PCI
770 if (dev_is_pci(dev))
771 return pci64_dma_supported(to_pci_dev(dev), device_mask);
772 #endif
773
774 return 0;
775 }
776 EXPORT_SYMBOL(dma_supported);

Same panic happened with Intel ixgbe driver also.

SR-IOV code looks for arch specific data while enabling
VFs. When VF device is added, driver probe function makes set
of calls to initialize the pci device. Because the VF device is
added different way than the normal PF device(which happens via
of_create_pci_dev for sparc), some of the arch specific initialization
does not happen for VF device.  That causes panic when archdata is
accessed.

To fix this, I have used already defined weak function
pcibios_setup_device to copy archdata from PF to VF.
Also verified the fix.

Signed-off-by: Babu Moger 
Signed-off-by: Sowmini Varadhan 
Reviewed-by: Ethan Zhao 
---
v2:
 Removed RFC.
 Made changes per comments from Ethan Zhao.
 Now the changes are only in Sparc specific code.
 Removed the changes from driver/pci.
 Implemented already defined weak function pcibios_add_device
 in arch/sparc/kernel/pci.c to initialize sriov archdata. 

v3:
 Fixed the compile error reported in kbuild test robot.

 arch/sparc/kernel/pci.c |   17 +
 

[PATCH v3] sparc/PCI: Fix for panic while enabling SR-IOV

2016-03-23 Thread Babu Moger
We noticed this panic while enabling SR-IOV in sparc.

mlx4_core: Mellanox ConnectX core driver v2.2-1 (Jan  1 2015)
mlx4_core: Initializing 0007:01:00.0
mlx4_core 0007:01:00.0: Enabling SR-IOV with 5 VFs
mlx4_core: Initializing 0007:01:00.1
Unable to handle kernel NULL pointer dereference
insmod(10010): Oops [#1]
CPU: 391 PID: 10010 Comm: insmod Not tainted
4.1.12-32.el6uek.kdump2.sparc64 #1
TPC: 
I7: <__mlx4_init_one+0x324/0x500 [mlx4_core]>
Call Trace:
 [104c5ea4] __mlx4_init_one+0x324/0x500 [mlx4_core]
 [104c613c] mlx4_init_one+0xbc/0x120 [mlx4_core]
 [00725f14] local_pci_probe+0x34/0xa0
 [00726028] pci_call_probe+0xa8/0xe0
 [00726310] pci_device_probe+0x50/0x80
 [0079f700] really_probe+0x140/0x420
 [0079fa24] driver_probe_device+0x44/0xa0
 [0079fb5c] __device_attach+0x3c/0x60
 [0079d85c] bus_for_each_drv+0x5c/0xa0
 [0079f588] device_attach+0x88/0xc0
 [0071acd0] pci_bus_add_device+0x30/0x80
 [00736090] virtfn_add.clone.1+0x210/0x360
 [007364a4] sriov_enable+0x2c4/0x520
 [0073672c] pci_enable_sriov+0x2c/0x40
 [104c2d58] mlx4_enable_sriov+0xf8/0x180 [mlx4_core]
 [104c49ac] mlx4_load_one+0x42c/0xd40 [mlx4_core]
Disabling lock debugging due to kernel taint
Caller[104c5ea4]: __mlx4_init_one+0x324/0x500 [mlx4_core]
Caller[104c613c]: mlx4_init_one+0xbc/0x120 [mlx4_core]
Caller[00725f14]: local_pci_probe+0x34/0xa0
Caller[00726028]: pci_call_probe+0xa8/0xe0
Caller[00726310]: pci_device_probe+0x50/0x80
Caller[0079f700]: really_probe+0x140/0x420
Caller[0079fa24]: driver_probe_device+0x44/0xa0
Caller[0079fb5c]: __device_attach+0x3c/0x60
Caller[0079d85c]: bus_for_each_drv+0x5c/0xa0
Caller[0079f588]: device_attach+0x88/0xc0
Caller[0071acd0]: pci_bus_add_device+0x30/0x80
Caller[00736090]: virtfn_add.clone.1+0x210/0x360
Caller[007364a4]: sriov_enable+0x2c4/0x520
Caller[0073672c]: pci_enable_sriov+0x2c/0x40
Caller[104c2d58]: mlx4_enable_sriov+0xf8/0x180 [mlx4_core]
Caller[104c49ac]: mlx4_load_one+0x42c/0xd40 [mlx4_core]
Caller[104c5f90]: __mlx4_init_one+0x410/0x500 [mlx4_core]
Caller[104c613c]: mlx4_init_one+0xbc/0x120 [mlx4_core]
Caller[00725f14]: local_pci_probe+0x34/0xa0
Caller[00726028]: pci_call_probe+0xa8/0xe0
Caller[00726310]: pci_device_probe+0x50/0x80
Caller[0079f700]: really_probe+0x140/0x420
Caller[0079fa24]: driver_probe_device+0x44/0xa0
Caller[0079fb08]: __driver_attach+0x88/0xa0
Caller[0079d90c]: bus_for_each_dev+0x6c/0xa0
Caller[0079f29c]: driver_attach+0x1c/0x40
Caller[0079e35c]: bus_add_driver+0x17c/0x220
Caller[007a02d4]: driver_register+0x74/0x120
Caller[007263fc]: __pci_register_driver+0x3c/0x60
Caller[104f62bc]: mlx4_init+0x60/0xcc [mlx4_core]
Kernel panic - not syncing: Fatal exception
Press Stop-A (L1-A) to return to the boot prom
---[ end Kernel panic - not syncing: Fatal exception

Details:
Here is the call sequence
virtfn_add->__mlx4_init_one->dma_set_mask->dma_supported

The panic happened at line 760(file arch/sparc/kernel/iommu.c)

758 int dma_supported(struct device *dev, u64 device_mask)
759 {
760 struct iommu *iommu = dev->archdata.iommu;
761 u64 dma_addr_mask = iommu->dma_addr_mask;
762
763 if (device_mask >= (1UL << 32UL))
764 return 0;
765
766 if ((device_mask & dma_addr_mask) == dma_addr_mask)
767 return 1;
768
769 #ifdef CONFIG_PCI
770 if (dev_is_pci(dev))
771 return pci64_dma_supported(to_pci_dev(dev), device_mask);
772 #endif
773
774 return 0;
775 }
776 EXPORT_SYMBOL(dma_supported);

Same panic happened with Intel ixgbe driver also.

SR-IOV code looks for arch specific data while enabling
VFs. When VF device is added, driver probe function makes set
of calls to initialize the pci device. Because the VF device is
added different way than the normal PF device(which happens via
of_create_pci_dev for sparc), some of the arch specific initialization
does not happen for VF device.  That causes panic when archdata is
accessed.

To fix this, I have used already defined weak function
pcibios_setup_device to copy archdata from PF to VF.
Also verified the fix.

Signed-off-by: Babu Moger 
Signed-off-by: Sowmini Varadhan 
Reviewed-by: Ethan Zhao 
---
v2:
 Removed RFC.
 Made changes per comments from Ethan Zhao.
 Now the changes are only in Sparc specific code.
 Removed the changes from driver/pci.
 Implemented already defined weak function pcibios_add_device
 in arch/sparc/kernel/pci.c to initialize sriov archdata. 

v3:
 Fixed the compile error reported in kbuild test robot.

 arch/sparc/kernel/pci.c |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/arch/sparc/kernel/pci.c 

[PATCH] staging: rtl8188eu: remove return at end of void function call

2016-03-23 Thread Nicholas Sim
Remove unnecessary return statements from last lines of void function call
(several)

Signed-off-by: Nicholas Sim 
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 439c035..7f32b39 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -601,8 +601,6 @@ static void issue_probersp(struct adapter *padapter, 
unsigned char *da)
pattrib->last_txcmdsz = pattrib->pktlen;
 
dump_mgntframe(padapter, pmgntframe);
-
-   return;
 }
 
 static int issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid 
*pssid, u8 *da, bool wait_ack)
@@ -883,8 +881,6 @@ static void issue_auth(struct adapter *padapter, struct 
sta_info *psta,
rtw_wep_encrypt(padapter, (u8 *)pmgntframe);
DBG_88E("%s\n", __func__);
dump_mgntframe(padapter, pmgntframe);
-
-   return;
 }
 
 
@@ -1207,8 +1203,6 @@ exit:
rtw_buf_update(>assoc_req, 
>assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen);
else
rtw_buf_free(>assoc_req, >assoc_req_len);
-
-   return;
 }
 
 /* when wait_ack is true, this function should be called at process context */
@@ -4326,8 +4320,6 @@ void report_survey_event(struct adapter *padapter,
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
 
pmlmeext->sitesurvey_res.bss_cnt++;
-
-   return;
 }
 
 void report_surveydone_event(struct adapter *padapter)
@@ -4371,8 +4363,6 @@ void report_surveydone_event(struct adapter *padapter)
DBG_88E("survey done event(%x)\n", psurveydone_evt->bss_cnt);
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 void report_join_res(struct adapter *padapter, int res)
@@ -4423,8 +4413,6 @@ void report_join_res(struct adapter *padapter, int res)
 
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, 
unsigned short reason)
@@ -4480,8 +4468,6 @@ void report_del_sta_event(struct adapter *padapter, 
unsigned char *MacAddr, unsi
DBG_88E("report_del_sta_event: delete STA, mac_id =%d\n", mac_id);
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, 
int cam_idx)
@@ -4526,8 +4512,6 @@ void report_add_sta_event(struct adapter *padapter, 
unsigned char *MacAddr, int
DBG_88E("report_add_sta_event: add STA\n");
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 
@@ -4963,7 +4947,6 @@ void link_timer_hdl(unsigned long data)
issue_assocreq(padapter);
set_link_timer(pmlmeext, REASSOC_TO);
}
-   return;
 }
 
 void addba_timer_hdl(unsigned long data)
-- 
2.4.3



[PATCH] staging: rtl8188eu: remove return at end of void function call

2016-03-23 Thread Nicholas Sim
Remove unnecessary return statements from last lines of void function call
(several)

Signed-off-by: Nicholas Sim 
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 439c035..7f32b39 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -601,8 +601,6 @@ static void issue_probersp(struct adapter *padapter, 
unsigned char *da)
pattrib->last_txcmdsz = pattrib->pktlen;
 
dump_mgntframe(padapter, pmgntframe);
-
-   return;
 }
 
 static int issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid 
*pssid, u8 *da, bool wait_ack)
@@ -883,8 +881,6 @@ static void issue_auth(struct adapter *padapter, struct 
sta_info *psta,
rtw_wep_encrypt(padapter, (u8 *)pmgntframe);
DBG_88E("%s\n", __func__);
dump_mgntframe(padapter, pmgntframe);
-
-   return;
 }
 
 
@@ -1207,8 +1203,6 @@ exit:
rtw_buf_update(>assoc_req, 
>assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen);
else
rtw_buf_free(>assoc_req, >assoc_req_len);
-
-   return;
 }
 
 /* when wait_ack is true, this function should be called at process context */
@@ -4326,8 +4320,6 @@ void report_survey_event(struct adapter *padapter,
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
 
pmlmeext->sitesurvey_res.bss_cnt++;
-
-   return;
 }
 
 void report_surveydone_event(struct adapter *padapter)
@@ -4371,8 +4363,6 @@ void report_surveydone_event(struct adapter *padapter)
DBG_88E("survey done event(%x)\n", psurveydone_evt->bss_cnt);
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 void report_join_res(struct adapter *padapter, int res)
@@ -4423,8 +4413,6 @@ void report_join_res(struct adapter *padapter, int res)
 
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, 
unsigned short reason)
@@ -4480,8 +4468,6 @@ void report_del_sta_event(struct adapter *padapter, 
unsigned char *MacAddr, unsi
DBG_88E("report_del_sta_event: delete STA, mac_id =%d\n", mac_id);
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, 
int cam_idx)
@@ -4526,8 +4512,6 @@ void report_add_sta_event(struct adapter *padapter, 
unsigned char *MacAddr, int
DBG_88E("report_add_sta_event: add STA\n");
 
rtw_enqueue_cmd(pcmdpriv, pcmd_obj);
-
-   return;
 }
 
 
@@ -4963,7 +4947,6 @@ void link_timer_hdl(unsigned long data)
issue_assocreq(padapter);
set_link_timer(pmlmeext, REASSOC_TO);
}
-   return;
 }
 
 void addba_timer_hdl(unsigned long data)
-- 
2.4.3



Re: [PATCH 15/17] qcom: ipq4019: add cpu operating points for cpufreq support

2016-03-23 Thread Stephen Boyd
On 03/23/2016 03:05 PM, Matthew McClintock wrote:
> This adds some operating points for cpu frequeny scaling
>
> Signed-off-by: Matthew McClintock 
> ---

Can you use the v2 OPP bindings instead? I imagine uV could be left out
then because there isn't any regulator control?

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



Re: [PATCH 15/17] qcom: ipq4019: add cpu operating points for cpufreq support

2016-03-23 Thread Stephen Boyd
On 03/23/2016 03:05 PM, Matthew McClintock wrote:
> This adds some operating points for cpu frequeny scaling
>
> Signed-off-by: Matthew McClintock 
> ---

Can you use the v2 OPP bindings instead? I imagine uV could be left out
then because there isn't any regulator control?

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



Re: [RFT PATCH] [media] exynos4-is: Fix fimc_is_parse_sensor_config() nodes handling

2016-03-23 Thread Andreas Färber
Hi Javier,

Am 23.03.2016 um 17:15 schrieb Javier Martinez Canillas:
> The same struct device_node * is used for looking up the I2C sensor, OF
> graph endpoint and port. So the reference count is incremented but not
> decremented for the endpoint and port nodes.
> 
> Fix this by having separate pointers for each node looked up.
> 
> Signed-off-by: Javier Martinez Canillas 
[...]
> diff --git a/drivers/media/platform/exynos4-is/fimc-is.c 
> b/drivers/media/platform/exynos4-is/fimc-is.c
> index 979c388ebf60..0b04a5d25187 100644
> --- a/drivers/media/platform/exynos4-is/fimc-is.c
> +++ b/drivers/media/platform/exynos4-is/fimc-is.c
> @@ -165,6 +165,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is 
> *is, unsigned int index,
>   struct device_node *node)
>  {
>   struct fimc_is_sensor *sensor = >sensor[index];
> + struct device_node *ep, *port;
>   u32 tmp = 0;
>   int ret;
>  
> @@ -175,16 +176,18 @@ static int fimc_is_parse_sensor_config(struct fimc_is 
> *is, unsigned int index,
>   return -EINVAL;
>   }
>  
> - node = of_graph_get_next_endpoint(node, NULL);
> - if (!node)
> + ep = of_graph_get_next_endpoint(node, NULL);
> + if (!ep)
>   return -ENXIO;
>  
> - node = of_graph_get_remote_port(node);
> - if (!node)
> + port = of_graph_get_remote_port(ep);
> + of_node_put(ep);
> + if (!port)
>   return -ENXIO;
>  
>   /* Use MIPI-CSIS channel id to determine the ISP I2C bus index. */
> - ret = of_property_read_u32(node, "reg", );
> + ret = of_property_read_u32(port, "reg", );
> + of_node_put(port);
>   if (ret < 0) {
>   dev_err(>pdev->dev, "reg property not found at: %s\n",
>node->full_name);

port->full_name. You'll need to defer the of_node_put(port) then.

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)


Re: [RFT PATCH] [media] exynos4-is: Fix fimc_is_parse_sensor_config() nodes handling

2016-03-23 Thread Andreas Färber
Hi Javier,

Am 23.03.2016 um 17:15 schrieb Javier Martinez Canillas:
> The same struct device_node * is used for looking up the I2C sensor, OF
> graph endpoint and port. So the reference count is incremented but not
> decremented for the endpoint and port nodes.
> 
> Fix this by having separate pointers for each node looked up.
> 
> Signed-off-by: Javier Martinez Canillas 
[...]
> diff --git a/drivers/media/platform/exynos4-is/fimc-is.c 
> b/drivers/media/platform/exynos4-is/fimc-is.c
> index 979c388ebf60..0b04a5d25187 100644
> --- a/drivers/media/platform/exynos4-is/fimc-is.c
> +++ b/drivers/media/platform/exynos4-is/fimc-is.c
> @@ -165,6 +165,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is 
> *is, unsigned int index,
>   struct device_node *node)
>  {
>   struct fimc_is_sensor *sensor = >sensor[index];
> + struct device_node *ep, *port;
>   u32 tmp = 0;
>   int ret;
>  
> @@ -175,16 +176,18 @@ static int fimc_is_parse_sensor_config(struct fimc_is 
> *is, unsigned int index,
>   return -EINVAL;
>   }
>  
> - node = of_graph_get_next_endpoint(node, NULL);
> - if (!node)
> + ep = of_graph_get_next_endpoint(node, NULL);
> + if (!ep)
>   return -ENXIO;
>  
> - node = of_graph_get_remote_port(node);
> - if (!node)
> + port = of_graph_get_remote_port(ep);
> + of_node_put(ep);
> + if (!port)
>   return -ENXIO;
>  
>   /* Use MIPI-CSIS channel id to determine the ISP I2C bus index. */
> - ret = of_property_read_u32(node, "reg", );
> + ret = of_property_read_u32(port, "reg", );
> + of_node_put(port);
>   if (ret < 0) {
>   dev_err(>pdev->dev, "reg property not found at: %s\n",
>node->full_name);

port->full_name. You'll need to defer the of_node_put(port) then.

Regards,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)


Re: [PATCH 06/17] watchdog: qcom: update device tree bindings

2016-03-23 Thread Stephen Boyd
On 03/23/2016 03:05 PM, Matthew McClintock wrote:
> Update the compatible string to align with driver
>
> CC: linux-watch...@vger.kernel.org
> Signed-off-by: Matthew McClintock 

I had a patch similar to this before
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-February/325235.html


> ---
>  Documentation/devicetree/bindings/watchdog/qcom-wdt.txt | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt 
> b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
> index 4726924..60bb2f98 100644
> --- a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
> +++ b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
> @@ -4,9 +4,8 @@ Qualcomm Krait Processor Sub-system (KPSS) Watchdog
>  Required properties :
>  - compatible : shall contain only one of the following:
>  
> - "qcom,kpss-wdt-msm8960"
> - "qcom,kpss-wdt-apq8064"
> - "qcom,kpss-wdt-ipq8064"
> + "qcom,kpss-timer"
> + "qcom,scss-timer"
>  
>  - reg : shall contain base register location and length
>  - clocks : shall contain the input clock

No example update?

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



Re: [PATCH 06/17] watchdog: qcom: update device tree bindings

2016-03-23 Thread Stephen Boyd
On 03/23/2016 03:05 PM, Matthew McClintock wrote:
> Update the compatible string to align with driver
>
> CC: linux-watch...@vger.kernel.org
> Signed-off-by: Matthew McClintock 

I had a patch similar to this before
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-February/325235.html


> ---
>  Documentation/devicetree/bindings/watchdog/qcom-wdt.txt | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt 
> b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
> index 4726924..60bb2f98 100644
> --- a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
> +++ b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
> @@ -4,9 +4,8 @@ Qualcomm Krait Processor Sub-system (KPSS) Watchdog
>  Required properties :
>  - compatible : shall contain only one of the following:
>  
> - "qcom,kpss-wdt-msm8960"
> - "qcom,kpss-wdt-apq8064"
> - "qcom,kpss-wdt-ipq8064"
> + "qcom,kpss-timer"
> + "qcom,scss-timer"
>  
>  - reg : shall contain base register location and length
>  - clocks : shall contain the input clock

No example update?

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



Re: [PATCH] iommu: remove the iommu_callback_data

2016-03-23 Thread Wei Yang
Obsolete this one, V2 is sent.

On Sun, Mar 20, 2016 at 01:57:52AM +, Wei Yang wrote:
>According to the code path, iommu_callback_data is passed in
>iommu_bus_init() and  just used in {add/remove}_iommu_group, by when the
>bus->iommu_ops is already set up properly.
>
>This patch removes the iommu_callback_data by retrieving iommu_ops from
>bus->iommu_ops directly.
>
>Signed-off-by: Wei Yang 
>---
> drivers/iommu/iommu.c | 21 ++---
> 1 file changed, 6 insertions(+), 15 deletions(-)
>
>diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>index 0e3b009..2696a38 100644
>--- a/drivers/iommu/iommu.c
>+++ b/drivers/iommu/iommu.c
>@@ -37,10 +37,6 @@ static struct kset *iommu_group_kset;
> static struct ida iommu_group_ida;
> static struct mutex iommu_group_mutex;
> 
>-struct iommu_callback_data {
>-  const struct iommu_ops *ops;
>-};
>-
> struct iommu_group {
>   struct kobject kobj;
>   struct kobject *devices_kobj;
>@@ -867,8 +863,7 @@ struct iommu_domain *iommu_group_default_domain(struct 
>iommu_group *group)
> 
> static int add_iommu_group(struct device *dev, void *data)
> {
>-  struct iommu_callback_data *cb = data;
>-  const struct iommu_ops *ops = cb->ops;
>+  const struct iommu_ops *ops = dev->bus->iommu_ops;
>   int ret;
> 
>   if (!ops->add_device)
>@@ -891,8 +886,7 @@ static int add_iommu_group(struct device *dev, void *data)
> 
> static int remove_iommu_group(struct device *dev, void *data)
> {
>-  struct iommu_callback_data *cb = data;
>-  const struct iommu_ops *ops = cb->ops;
>+  const struct iommu_ops *ops = dev->bus->iommu_ops;
> 
>   if (ops->remove_device && dev->iommu_group)
>   ops->remove_device(dev);
>@@ -953,13 +947,10 @@ static int iommu_bus_notifier(struct notifier_block *nb,
>   return 0;
> }
> 
>-static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
>+static int iommu_bus_init(struct bus_type *bus)
> {
>   int err;
>   struct notifier_block *nb;
>-  struct iommu_callback_data cb = {
>-  .ops = ops,
>-  };
> 
>   nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
>   if (!nb)
>@@ -971,7 +962,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
>struct iommu_ops *ops)
>   if (err)
>   goto out_free;
> 
>-  err = bus_for_each_dev(bus, NULL, , add_iommu_group);
>+  err = bus_for_each_dev(bus, NULL, NULL, add_iommu_group);
>   if (err)
>   goto out_err;
> 
>@@ -980,7 +971,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
>struct iommu_ops *ops)
> 
> out_err:
>   /* Clean up */
>-  bus_for_each_dev(bus, NULL, , remove_iommu_group);
>+  bus_for_each_dev(bus, NULL, NULL, remove_iommu_group);
>   bus_unregister_notifier(bus, nb);
> 
> out_free:
>@@ -1012,7 +1003,7 @@ int bus_set_iommu(struct bus_type *bus, const struct 
>iommu_ops *ops)
>   bus->iommu_ops = ops;
> 
>   /* Do IOMMU specific setup for this bus-type */
>-  err = iommu_bus_init(bus, ops);
>+  err = iommu_bus_init(bus);
>   if (err)
>   bus->iommu_ops = NULL;
> 
>-- 
>2.5.0

-- 
Wei Yang
Help you, Help me


Re: [PATCH] iommu: remove the iommu_callback_data

2016-03-23 Thread Wei Yang
Obsolete this one, V2 is sent.

On Sun, Mar 20, 2016 at 01:57:52AM +, Wei Yang wrote:
>According to the code path, iommu_callback_data is passed in
>iommu_bus_init() and  just used in {add/remove}_iommu_group, by when the
>bus->iommu_ops is already set up properly.
>
>This patch removes the iommu_callback_data by retrieving iommu_ops from
>bus->iommu_ops directly.
>
>Signed-off-by: Wei Yang 
>---
> drivers/iommu/iommu.c | 21 ++---
> 1 file changed, 6 insertions(+), 15 deletions(-)
>
>diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>index 0e3b009..2696a38 100644
>--- a/drivers/iommu/iommu.c
>+++ b/drivers/iommu/iommu.c
>@@ -37,10 +37,6 @@ static struct kset *iommu_group_kset;
> static struct ida iommu_group_ida;
> static struct mutex iommu_group_mutex;
> 
>-struct iommu_callback_data {
>-  const struct iommu_ops *ops;
>-};
>-
> struct iommu_group {
>   struct kobject kobj;
>   struct kobject *devices_kobj;
>@@ -867,8 +863,7 @@ struct iommu_domain *iommu_group_default_domain(struct 
>iommu_group *group)
> 
> static int add_iommu_group(struct device *dev, void *data)
> {
>-  struct iommu_callback_data *cb = data;
>-  const struct iommu_ops *ops = cb->ops;
>+  const struct iommu_ops *ops = dev->bus->iommu_ops;
>   int ret;
> 
>   if (!ops->add_device)
>@@ -891,8 +886,7 @@ static int add_iommu_group(struct device *dev, void *data)
> 
> static int remove_iommu_group(struct device *dev, void *data)
> {
>-  struct iommu_callback_data *cb = data;
>-  const struct iommu_ops *ops = cb->ops;
>+  const struct iommu_ops *ops = dev->bus->iommu_ops;
> 
>   if (ops->remove_device && dev->iommu_group)
>   ops->remove_device(dev);
>@@ -953,13 +947,10 @@ static int iommu_bus_notifier(struct notifier_block *nb,
>   return 0;
> }
> 
>-static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
>+static int iommu_bus_init(struct bus_type *bus)
> {
>   int err;
>   struct notifier_block *nb;
>-  struct iommu_callback_data cb = {
>-  .ops = ops,
>-  };
> 
>   nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
>   if (!nb)
>@@ -971,7 +962,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
>struct iommu_ops *ops)
>   if (err)
>   goto out_free;
> 
>-  err = bus_for_each_dev(bus, NULL, , add_iommu_group);
>+  err = bus_for_each_dev(bus, NULL, NULL, add_iommu_group);
>   if (err)
>   goto out_err;
> 
>@@ -980,7 +971,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
>struct iommu_ops *ops)
> 
> out_err:
>   /* Clean up */
>-  bus_for_each_dev(bus, NULL, , remove_iommu_group);
>+  bus_for_each_dev(bus, NULL, NULL, remove_iommu_group);
>   bus_unregister_notifier(bus, nb);
> 
> out_free:
>@@ -1012,7 +1003,7 @@ int bus_set_iommu(struct bus_type *bus, const struct 
>iommu_ops *ops)
>   bus->iommu_ops = ops;
> 
>   /* Do IOMMU specific setup for this bus-type */
>-  err = iommu_bus_init(bus, ops);
>+  err = iommu_bus_init(bus);
>   if (err)
>   bus->iommu_ops = NULL;
> 
>-- 
>2.5.0

-- 
Wei Yang
Help you, Help me


[Patch V2 2/2] iommu: remove sysfs_link to device in iommu_group/devices when failed

2016-03-23 Thread Wei Yang
The original code forgets to remove the sysfs_link to a device in
iommu_group/devices directory, when the creation fails or conflicts on the
name.

This patch tries to remove the sysfs_link on the failure.

Signed-off-by: Wei Yang 
---
 drivers/iommu/iommu.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 2696a38..8f480ba 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -403,6 +403,7 @@ rename:
ret = sysfs_create_link_nowarn(group->devices_kobj,
   >kobj, device->name);
if (ret) {
+   sysfs_remove_link(group->devices_kobj, device->name);
kfree(device->name);
if (ret == -EEXIST && i >= 0) {
/*
-- 
1.7.9.5



[Patch V2 0/2] Cleanup on IOMMU

2016-03-23 Thread Wei Yang
This two patches tries to do some cleanup in iommu.

V2:
  * add patch 2

Wei Yang (2):
  iommu: remove the iommu_callback_data
  iommu: remove sysfs_link to device in iommu_group/devices when failed

 drivers/iommu/iommu.c |   22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

-- 
1.7.9.5



[Patch V2 2/2] iommu: remove sysfs_link to device in iommu_group/devices when failed

2016-03-23 Thread Wei Yang
The original code forgets to remove the sysfs_link to a device in
iommu_group/devices directory, when the creation fails or conflicts on the
name.

This patch tries to remove the sysfs_link on the failure.

Signed-off-by: Wei Yang 
---
 drivers/iommu/iommu.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 2696a38..8f480ba 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -403,6 +403,7 @@ rename:
ret = sysfs_create_link_nowarn(group->devices_kobj,
   >kobj, device->name);
if (ret) {
+   sysfs_remove_link(group->devices_kobj, device->name);
kfree(device->name);
if (ret == -EEXIST && i >= 0) {
/*
-- 
1.7.9.5



[Patch V2 0/2] Cleanup on IOMMU

2016-03-23 Thread Wei Yang
This two patches tries to do some cleanup in iommu.

V2:
  * add patch 2

Wei Yang (2):
  iommu: remove the iommu_callback_data
  iommu: remove sysfs_link to device in iommu_group/devices when failed

 drivers/iommu/iommu.c |   22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

-- 
1.7.9.5



[Patch V2 1/2] iommu: remove the iommu_callback_data

2016-03-23 Thread Wei Yang
According to the code path, iommu_callback_data is passed in
iommu_bus_init() and  just used in {add/remove}_iommu_group, by when the
bus->iommu_ops is already set up properly.

This patch removes the iommu_callback_data by retrieving iommu_ops from
bus->iommu_ops directly.

Signed-off-by: Wei Yang 
---
 drivers/iommu/iommu.c |   21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 0e3b009..2696a38 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -37,10 +37,6 @@ static struct kset *iommu_group_kset;
 static struct ida iommu_group_ida;
 static struct mutex iommu_group_mutex;
 
-struct iommu_callback_data {
-   const struct iommu_ops *ops;
-};
-
 struct iommu_group {
struct kobject kobj;
struct kobject *devices_kobj;
@@ -867,8 +863,7 @@ struct iommu_domain *iommu_group_default_domain(struct 
iommu_group *group)
 
 static int add_iommu_group(struct device *dev, void *data)
 {
-   struct iommu_callback_data *cb = data;
-   const struct iommu_ops *ops = cb->ops;
+   const struct iommu_ops *ops = dev->bus->iommu_ops;
int ret;
 
if (!ops->add_device)
@@ -891,8 +886,7 @@ static int add_iommu_group(struct device *dev, void *data)
 
 static int remove_iommu_group(struct device *dev, void *data)
 {
-   struct iommu_callback_data *cb = data;
-   const struct iommu_ops *ops = cb->ops;
+   const struct iommu_ops *ops = dev->bus->iommu_ops;
 
if (ops->remove_device && dev->iommu_group)
ops->remove_device(dev);
@@ -953,13 +947,10 @@ static int iommu_bus_notifier(struct notifier_block *nb,
return 0;
 }
 
-static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
+static int iommu_bus_init(struct bus_type *bus)
 {
int err;
struct notifier_block *nb;
-   struct iommu_callback_data cb = {
-   .ops = ops,
-   };
 
nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
if (!nb)
@@ -971,7 +962,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
struct iommu_ops *ops)
if (err)
goto out_free;
 
-   err = bus_for_each_dev(bus, NULL, , add_iommu_group);
+   err = bus_for_each_dev(bus, NULL, NULL, add_iommu_group);
if (err)
goto out_err;
 
@@ -980,7 +971,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
struct iommu_ops *ops)
 
 out_err:
/* Clean up */
-   bus_for_each_dev(bus, NULL, , remove_iommu_group);
+   bus_for_each_dev(bus, NULL, NULL, remove_iommu_group);
bus_unregister_notifier(bus, nb);
 
 out_free:
@@ -1012,7 +1003,7 @@ int bus_set_iommu(struct bus_type *bus, const struct 
iommu_ops *ops)
bus->iommu_ops = ops;
 
/* Do IOMMU specific setup for this bus-type */
-   err = iommu_bus_init(bus, ops);
+   err = iommu_bus_init(bus);
if (err)
bus->iommu_ops = NULL;
 
-- 
1.7.9.5



[Patch V2 1/2] iommu: remove the iommu_callback_data

2016-03-23 Thread Wei Yang
According to the code path, iommu_callback_data is passed in
iommu_bus_init() and  just used in {add/remove}_iommu_group, by when the
bus->iommu_ops is already set up properly.

This patch removes the iommu_callback_data by retrieving iommu_ops from
bus->iommu_ops directly.

Signed-off-by: Wei Yang 
---
 drivers/iommu/iommu.c |   21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 0e3b009..2696a38 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -37,10 +37,6 @@ static struct kset *iommu_group_kset;
 static struct ida iommu_group_ida;
 static struct mutex iommu_group_mutex;
 
-struct iommu_callback_data {
-   const struct iommu_ops *ops;
-};
-
 struct iommu_group {
struct kobject kobj;
struct kobject *devices_kobj;
@@ -867,8 +863,7 @@ struct iommu_domain *iommu_group_default_domain(struct 
iommu_group *group)
 
 static int add_iommu_group(struct device *dev, void *data)
 {
-   struct iommu_callback_data *cb = data;
-   const struct iommu_ops *ops = cb->ops;
+   const struct iommu_ops *ops = dev->bus->iommu_ops;
int ret;
 
if (!ops->add_device)
@@ -891,8 +886,7 @@ static int add_iommu_group(struct device *dev, void *data)
 
 static int remove_iommu_group(struct device *dev, void *data)
 {
-   struct iommu_callback_data *cb = data;
-   const struct iommu_ops *ops = cb->ops;
+   const struct iommu_ops *ops = dev->bus->iommu_ops;
 
if (ops->remove_device && dev->iommu_group)
ops->remove_device(dev);
@@ -953,13 +947,10 @@ static int iommu_bus_notifier(struct notifier_block *nb,
return 0;
 }
 
-static int iommu_bus_init(struct bus_type *bus, const struct iommu_ops *ops)
+static int iommu_bus_init(struct bus_type *bus)
 {
int err;
struct notifier_block *nb;
-   struct iommu_callback_data cb = {
-   .ops = ops,
-   };
 
nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
if (!nb)
@@ -971,7 +962,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
struct iommu_ops *ops)
if (err)
goto out_free;
 
-   err = bus_for_each_dev(bus, NULL, , add_iommu_group);
+   err = bus_for_each_dev(bus, NULL, NULL, add_iommu_group);
if (err)
goto out_err;
 
@@ -980,7 +971,7 @@ static int iommu_bus_init(struct bus_type *bus, const 
struct iommu_ops *ops)
 
 out_err:
/* Clean up */
-   bus_for_each_dev(bus, NULL, , remove_iommu_group);
+   bus_for_each_dev(bus, NULL, NULL, remove_iommu_group);
bus_unregister_notifier(bus, nb);
 
 out_free:
@@ -1012,7 +1003,7 @@ int bus_set_iommu(struct bus_type *bus, const struct 
iommu_ops *ops)
bus->iommu_ops = ops;
 
/* Do IOMMU specific setup for this bus-type */
-   err = iommu_bus_init(bus, ops);
+   err = iommu_bus_init(bus);
if (err)
bus->iommu_ops = NULL;
 
-- 
1.7.9.5



[PATCH 4/4] arm64: dts: marvell: Rename armada-ap806 XOR nodes

2016-03-23 Thread Andreas Färber
Node names should not contain an instance number, the unit address
serves to distinguish nodes of the same name. So rename the XOR nodes
to just xor@address, using xorX as label instead.

Fixes: ec7e5a569bce ("arm64: dts: marvell: add Device Tree files for Armada 
7K/8K")
Cc: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
Signed-off-by: Andreas Färber <afaer...@suse.de>
---
 "marvell,mv-xor-v2" is not yet referenced from any driver in next-20160323.
 
 arch/arm64/boot/dts/marvell/armada-ap806.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
index 3ecf9b1798fa..dd6e48a952ac 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
@@ -135,7 +135,7 @@
marvell,spi-base = <128>, <136>, <144>, <152>;
};
 
-   xor0@40 {
+   xor0: xor@40 {
compatible = "marvell,mv-xor-v2";
reg = <0x40 0x1000>,
  <0x41 0x1000>;
@@ -143,7 +143,7 @@
dma-coherent;
};
 
-   xor1@42 {
+   xor1: xor@42 {
compatible = "marvell,mv-xor-v2";
reg = <0x42 0x1000>,
  <0x43 0x1000>;
@@ -151,7 +151,7 @@
dma-coherent;
};
 
-   xor2@44 {
+   xor2: xor@44 {
compatible = "marvell,mv-xor-v2";
reg = <0x44 0x1000>,
  <0x45 0x1000>;
@@ -159,7 +159,7 @@
dma-coherent;
};
 
-   xor3@46 {
+   xor3: xor@46 {
compatible = "marvell,mv-xor-v2";
reg = <0x46 0x1000>,
  <0x47 0x1000>;
-- 
2.6.2



[PATCH 1/4] arm64: dts: marvell: Clean up armada-3720-db

2016-03-23 Thread Andreas Färber
Instead of duplicating the SoC's node hierarchy, including a bus node
named "internal-regs", reference the actually desired nodes by label,
like Berlin already does. Add labels where necessary.

Drop an inconsistent white line while at it.

Fixes: adbc3695d9e4 ("arm64: dts: add the Marvell Armada 3700 family and a 
development board")
Cc: Gregory CLEMENT 
Signed-off-by: Andreas Färber 
---
 arch/arm64/boot/dts/marvell/armada-3720-db.dts | 35 +++---
 arch/arm64/boot/dts/marvell/armada-372x.dtsi   |  1 -
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi   |  4 +--
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-3720-db.dts 
b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
index 359050154511..48f97d14b057 100644
--- a/arch/arm64/boot/dts/marvell/armada-3720-db.dts
+++ b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
@@ -60,27 +60,22 @@
device_type = "memory";
reg = <0x 0x 0x 0x2000>;
};
+};
 
-   soc {
-   internal-regs {
-   /*
-   * Exported on the micro USB connector CON32
-   * through an FTDI
-   */
-   uart0: serial@12000 {
-   status = "okay";
-   };
-
-   /* CON31 */
-   usb3@58000 {
-   status = "okay";
-   };
+/* CON3 */
+ {
+   status = "okay";
+};
 
-   /* CON3 */
-   sata@e {
-  status = "okay";
-   };
-   };
-   };
+/*
+ * Exported on the micro USB connector CON32
+ * through an FTDI
+ */
+ {
+   status = "okay";
 };
 
+/* CON31 */
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/marvell/armada-372x.dtsi 
b/arch/arm64/boot/dts/marvell/armada-372x.dtsi
index f292a00ce97c..5120296596c2 100644
--- a/arch/arm64/boot/dts/marvell/armada-372x.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-372x.dtsi
@@ -59,5 +59,4 @@
enable-method = "psci";
};
};
-
 };
diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi 
b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
index ba9df7ff2a72..4328c2408a8a 100644
--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
@@ -105,14 +105,14 @@
status = "disabled";
};
 
-   usb3@58000 {
+   usb3: usb3@58000 {
compatible = "generic-xhci";
reg = <0x58000 0x4000>;
interrupts = ;
status = "disabled";
};
 
-   sata@e {
+   sata: sata@e {
compatible = "marvell,armada-3700-ahci";
reg = <0xe 0x2000>;
interrupts = ;
-- 
2.6.2



[PATCH 2/4] arm64: dts: marvell: Rename armada-37xx USB node

2016-03-23 Thread Andreas Färber
No need to reflect the USB version in the node name.

Fixes: adbc3695d9e4 ("arm64: dts: add the Marvell Armada 3700 family and a 
development board")
Cc: Gregory CLEMENT 
Signed-off-by: Andreas Färber 
---
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi 
b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
index 4328c2408a8a..55a861d60fae 100644
--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
@@ -105,7 +105,7 @@
status = "disabled";
};
 
-   usb3: usb3@58000 {
+   usb3: usb@58000 {
compatible = "generic-xhci";
reg = <0x58000 0x4000>;
interrupts = ;
-- 
2.6.2



[PATCH 4/4] arm64: dts: marvell: Rename armada-ap806 XOR nodes

2016-03-23 Thread Andreas Färber
Node names should not contain an instance number, the unit address
serves to distinguish nodes of the same name. So rename the XOR nodes
to just xor@address, using xorX as label instead.

Fixes: ec7e5a569bce ("arm64: dts: marvell: add Device Tree files for Armada 
7K/8K")
Cc: Thomas Petazzoni 
Signed-off-by: Andreas Färber 
---
 "marvell,mv-xor-v2" is not yet referenced from any driver in next-20160323.
 
 arch/arm64/boot/dts/marvell/armada-ap806.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
index 3ecf9b1798fa..dd6e48a952ac 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
@@ -135,7 +135,7 @@
marvell,spi-base = <128>, <136>, <144>, <152>;
};
 
-   xor0@40 {
+   xor0: xor@40 {
compatible = "marvell,mv-xor-v2";
reg = <0x40 0x1000>,
  <0x41 0x1000>;
@@ -143,7 +143,7 @@
dma-coherent;
};
 
-   xor1@42 {
+   xor1: xor@42 {
compatible = "marvell,mv-xor-v2";
reg = <0x42 0x1000>,
  <0x43 0x1000>;
@@ -151,7 +151,7 @@
dma-coherent;
};
 
-   xor2@44 {
+   xor2: xor@44 {
compatible = "marvell,mv-xor-v2";
reg = <0x44 0x1000>,
  <0x45 0x1000>;
@@ -159,7 +159,7 @@
dma-coherent;
};
 
-   xor3@46 {
+   xor3: xor@46 {
compatible = "marvell,mv-xor-v2";
reg = <0x46 0x1000>,
  <0x47 0x1000>;
-- 
2.6.2



[PATCH 1/4] arm64: dts: marvell: Clean up armada-3720-db

2016-03-23 Thread Andreas Färber
Instead of duplicating the SoC's node hierarchy, including a bus node
named "internal-regs", reference the actually desired nodes by label,
like Berlin already does. Add labels where necessary.

Drop an inconsistent white line while at it.

Fixes: adbc3695d9e4 ("arm64: dts: add the Marvell Armada 3700 family and a 
development board")
Cc: Gregory CLEMENT 
Signed-off-by: Andreas Färber 
---
 arch/arm64/boot/dts/marvell/armada-3720-db.dts | 35 +++---
 arch/arm64/boot/dts/marvell/armada-372x.dtsi   |  1 -
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi   |  4 +--
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-3720-db.dts 
b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
index 359050154511..48f97d14b057 100644
--- a/arch/arm64/boot/dts/marvell/armada-3720-db.dts
+++ b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
@@ -60,27 +60,22 @@
device_type = "memory";
reg = <0x 0x 0x 0x2000>;
};
+};
 
-   soc {
-   internal-regs {
-   /*
-   * Exported on the micro USB connector CON32
-   * through an FTDI
-   */
-   uart0: serial@12000 {
-   status = "okay";
-   };
-
-   /* CON31 */
-   usb3@58000 {
-   status = "okay";
-   };
+/* CON3 */
+ {
+   status = "okay";
+};
 
-   /* CON3 */
-   sata@e {
-  status = "okay";
-   };
-   };
-   };
+/*
+ * Exported on the micro USB connector CON32
+ * through an FTDI
+ */
+ {
+   status = "okay";
 };
 
+/* CON31 */
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/marvell/armada-372x.dtsi 
b/arch/arm64/boot/dts/marvell/armada-372x.dtsi
index f292a00ce97c..5120296596c2 100644
--- a/arch/arm64/boot/dts/marvell/armada-372x.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-372x.dtsi
@@ -59,5 +59,4 @@
enable-method = "psci";
};
};
-
 };
diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi 
b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
index ba9df7ff2a72..4328c2408a8a 100644
--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
@@ -105,14 +105,14 @@
status = "disabled";
};
 
-   usb3@58000 {
+   usb3: usb3@58000 {
compatible = "generic-xhci";
reg = <0x58000 0x4000>;
interrupts = ;
status = "disabled";
};
 
-   sata@e {
+   sata: sata@e {
compatible = "marvell,armada-3700-ahci";
reg = <0xe 0x2000>;
interrupts = ;
-- 
2.6.2



[PATCH 2/4] arm64: dts: marvell: Rename armada-37xx USB node

2016-03-23 Thread Andreas Färber
No need to reflect the USB version in the node name.

Fixes: adbc3695d9e4 ("arm64: dts: add the Marvell Armada 3700 family and a 
development board")
Cc: Gregory CLEMENT 
Signed-off-by: Andreas Färber 
---
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi 
b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
index 4328c2408a8a..55a861d60fae 100644
--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
@@ -105,7 +105,7 @@
status = "disabled";
};
 
-   usb3: usb3@58000 {
+   usb3: usb@58000 {
compatible = "generic-xhci";
reg = <0x58000 0x4000>;
interrupts = ;
-- 
2.6.2



[PATCH 3/4] arm64: dts: marvell: Clean up armada-7040-db

2016-03-23 Thread Andreas Färber
Instead of duplicating the node hierarchy, reference the nodes by label,
adding labels where necessary.

Drop some trailing or inconsistent white lines while at it.

Fixes: ec7e5a569bce ("arm64: dts: marvell: add Device Tree files for Armada 
7K/8K")
Cc: Thomas Petazzoni 
Signed-off-by: Andreas Färber 
---
 Is it intentional that there are no aliases for the two serial nodes and no 
/chosen/stdout-path?
 
 arch/arm64/boot/dts/marvell/armada-7040-db.dts | 52 ++
 arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi |  1 -
 arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi |  2 -
 arch/arm64/boot/dts/marvell/armada-ap806.dtsi  |  7 +--
 4 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-7040-db.dts 
b/arch/arm64/boot/dts/marvell/armada-7040-db.dts
index 064a251346dd..ee5778395bea 100644
--- a/arch/arm64/boot/dts/marvell/armada-7040-db.dts
+++ b/arch/arm64/boot/dts/marvell/armada-7040-db.dts
@@ -55,38 +55,34 @@
device_type = "memory";
reg = <0x0 0x0 0x0 0x8000>;
};
+};
 
-   ap806 {
-   config-space {
-   spi@510600 {
-   status = "okay";
-
-   spi-flash@0 {
-   #address-cells = <1>;
-   #size-cells = <1>;
-   compatible = "n25q128a13";
-   reg = <0>; /* Chip select 0 */
-   spi-max-frequency = <1000>;
+ {
+   status = "okay";
+   clock-frequency = <10>;
+};
 
-   partition@0 {
-   label = "U-Boot";
-   reg = <0 0x20>;
-   };
-   partition@40 {
-   label = "Filesystem";
-   reg = <0x20 0xce>;
-   };
-   };
-   };
+ {
+   status = "okay";
 
-   i2c@511000 {
-   status = "okay";
-   clock-frequency = <10>;
-   };
+   spi-flash@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "n25q128a13";
+   reg = <0>; /* Chip select 0 */
+   spi-max-frequency = <1000>;
 
-   serial@512000 {
-   status = "okay";
-   };
+   partition@0 {
+   label = "U-Boot";
+   reg = <0 0x20>;
+   };
+   partition@40 {
+   label = "Filesystem";
+   reg = <0x20 0xce>;
};
};
 };
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi
index f25c5c17fad7..95a1ff60f6c1 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi
@@ -68,4 +68,3 @@
};
};
 };
-
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi
index baa7d9a516b3..ba43a4357b89 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi
@@ -79,6 +79,4 @@
enable-method = "psci";
};
};
-
 };
-
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
index 556a92bcc2f6..3ecf9b1798fa 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
@@ -59,7 +59,6 @@
method = "smc";
};
 
-
ap806 {
#address-cells = <2>;
#size-cells = <2>;
@@ -190,7 +189,7 @@
status = "disabled";
};
 
-   serial@512000 {
+   uart0: serial@512000 {
compatible = "snps,dw-apb-uart";
reg = <0x512000 0x100>;
reg-shift = <2>;
@@ -200,7 +199,7 @@
status = "disabled";
};
 
-   serial@512100 {
+   uart1: serial@512100 {
compatible = "snps,dw-apb-uart";
reg = <0x512100 0x100>;
reg-shift = <2>;

[PATCH 3/4] arm64: dts: marvell: Clean up armada-7040-db

2016-03-23 Thread Andreas Färber
Instead of duplicating the node hierarchy, reference the nodes by label,
adding labels where necessary.

Drop some trailing or inconsistent white lines while at it.

Fixes: ec7e5a569bce ("arm64: dts: marvell: add Device Tree files for Armada 
7K/8K")
Cc: Thomas Petazzoni 
Signed-off-by: Andreas Färber 
---
 Is it intentional that there are no aliases for the two serial nodes and no 
/chosen/stdout-path?
 
 arch/arm64/boot/dts/marvell/armada-7040-db.dts | 52 ++
 arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi |  1 -
 arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi |  2 -
 arch/arm64/boot/dts/marvell/armada-ap806.dtsi  |  7 +--
 4 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-7040-db.dts 
b/arch/arm64/boot/dts/marvell/armada-7040-db.dts
index 064a251346dd..ee5778395bea 100644
--- a/arch/arm64/boot/dts/marvell/armada-7040-db.dts
+++ b/arch/arm64/boot/dts/marvell/armada-7040-db.dts
@@ -55,38 +55,34 @@
device_type = "memory";
reg = <0x0 0x0 0x0 0x8000>;
};
+};
 
-   ap806 {
-   config-space {
-   spi@510600 {
-   status = "okay";
-
-   spi-flash@0 {
-   #address-cells = <1>;
-   #size-cells = <1>;
-   compatible = "n25q128a13";
-   reg = <0>; /* Chip select 0 */
-   spi-max-frequency = <1000>;
+ {
+   status = "okay";
+   clock-frequency = <10>;
+};
 
-   partition@0 {
-   label = "U-Boot";
-   reg = <0 0x20>;
-   };
-   partition@40 {
-   label = "Filesystem";
-   reg = <0x20 0xce>;
-   };
-   };
-   };
+ {
+   status = "okay";
 
-   i2c@511000 {
-   status = "okay";
-   clock-frequency = <10>;
-   };
+   spi-flash@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "n25q128a13";
+   reg = <0>; /* Chip select 0 */
+   spi-max-frequency = <1000>;
 
-   serial@512000 {
-   status = "okay";
-   };
+   partition@0 {
+   label = "U-Boot";
+   reg = <0 0x20>;
+   };
+   partition@40 {
+   label = "Filesystem";
+   reg = <0x20 0xce>;
};
};
 };
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi
index f25c5c17fad7..95a1ff60f6c1 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806-dual.dtsi
@@ -68,4 +68,3 @@
};
};
 };
-
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi
index baa7d9a516b3..ba43a4357b89 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806-quad.dtsi
@@ -79,6 +79,4 @@
enable-method = "psci";
};
};
-
 };
-
diff --git a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi 
b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
index 556a92bcc2f6..3ecf9b1798fa 100644
--- a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi
@@ -59,7 +59,6 @@
method = "smc";
};
 
-
ap806 {
#address-cells = <2>;
#size-cells = <2>;
@@ -190,7 +189,7 @@
status = "disabled";
};
 
-   serial@512000 {
+   uart0: serial@512000 {
compatible = "snps,dw-apb-uart";
reg = <0x512000 0x100>;
reg-shift = <2>;
@@ -200,7 +199,7 @@
status = "disabled";
};
 
-   serial@512100 {
+   uart1: serial@512100 {
compatible = "snps,dw-apb-uart";
reg = <0x512100 0x100>;
reg-shift = <2>;
@@ -232,6 +231,4 @@
};
  

[PATCH 04/17] clk: qcom: ipq4019: switch remaining defines to enums

2016-03-23 Thread Matthew McClintock
When this was added not all the remaining defines were switched over to
use enums, so let's complete that process here

Reported-by: Stephen Boyd 
Signed-off-by: Matthew McClintock 
---
 drivers/clk/qcom/gcc-ipq4019.c | 60 ++
 1 file changed, 25 insertions(+), 35 deletions(-)

diff --git a/drivers/clk/qcom/gcc-ipq4019.c b/drivers/clk/qcom/gcc-ipq4019.c
index 21def7f..38ada8d 100644
--- a/drivers/clk/qcom/gcc-ipq4019.c
+++ b/drivers/clk/qcom/gcc-ipq4019.c
@@ -129,20 +129,10 @@ static const char * const gcc_xo_ddr_500_200[] = {
 };
 
 #define F(f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }
-#define P_XO 0
-#define FE_PLL_200 1
-#define FE_PLL_500 2
-#define DDRC_PLL_666  3
-
-#define DDRC_PLL_666_SDCC  1
-#define FE_PLL_125_DLY 1
-
-#define FE_PLL_WCSS2G 1
-#define FE_PLL_WCSS5G 1
 
 static const struct freq_tbl ftbl_gcc_audio_pwm_clk[] = {
F(4800, P_XO, 1, 0, 0),
-   F(2, FE_PLL_200, 1, 0, 0),
+   F(2, P_FEPLL200, 1, 0, 0),
{ }
 };
 
@@ -334,15 +324,15 @@ static struct clk_branch gcc_blsp1_qup2_spi_apps_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_blsp1_uart1_2_apps_clk[] = {
-   F(1843200, FE_PLL_200, 1, 144, 15625),
-   F(3686400, FE_PLL_200, 1, 288, 15625),
-   F(7372800, FE_PLL_200, 1, 576, 15625),
-   F(14745600, FE_PLL_200, 1, 1152, 15625),
-   F(1600, FE_PLL_200, 1, 2, 25),
+   F(1843200, P_FEPLL200, 1, 144, 15625),
+   F(3686400, P_FEPLL200, 1, 288, 15625),
+   F(7372800, P_FEPLL200, 1, 576, 15625),
+   F(14745600, P_FEPLL200, 1, 1152, 15625),
+   F(1600, P_FEPLL200, 1, 2, 25),
F(2400, P_XO, 1, 1, 2),
-   F(3200, FE_PLL_200, 1, 4, 25),
-   F(4000, FE_PLL_200, 1, 1, 5),
-   F(4640, FE_PLL_200, 1, 29, 125),
+   F(3200, P_FEPLL200, 1, 4, 25),
+   F(4000, P_FEPLL200, 1, 1, 5),
+   F(4640, P_FEPLL200, 1, 29, 125),
F(4800, P_XO, 1, 0, 0),
{ }
 };
@@ -410,9 +400,9 @@ static struct clk_branch gcc_blsp1_uart2_apps_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_gp_clk[] = {
-   F(125,  FE_PLL_200, 1, 16, 0),
-   F(250,  FE_PLL_200, 1,  8, 0),
-   F(500,  FE_PLL_200, 1,  4, 0),
+   F(125,  P_FEPLL200, 1, 16, 0),
+   F(250,  P_FEPLL200, 1,  8, 0),
+   F(500,  P_FEPLL200, 1,  4, 0),
{ }
 };
 
@@ -512,11 +502,11 @@ static struct clk_branch gcc_gp3_clk = {
 static const struct freq_tbl ftbl_gcc_sdcc1_apps_clk[] = {
F(144000,P_XO,  1,  3, 240),
F(40,P_XO,  1,  1, 0),
-   F(2000,  FE_PLL_500,1,  1, 25),
-   F(2500,  FE_PLL_500,1,  1, 20),
-   F(5000,  FE_PLL_500,1,  1, 10),
-   F(1, FE_PLL_500,1,  1, 5),
-   F(19300, DDRC_PLL_666_SDCC, 1,  0, 0),
+   F(2000,  P_FEPLL500,1,  1, 25),
+   F(2500,  P_FEPLL500,1,  1, 20),
+   F(5000,  P_FEPLL500,1,  1, 10),
+   F(1, P_FEPLL500,1,  1, 5),
+   F(19300, P_DDRPLL,  1,  0, 0),
{ }
 };
 
@@ -536,9 +526,9 @@ static struct clk_rcg2  sdcc1_apps_clk_src = {
 
 static const struct freq_tbl ftbl_gcc_apps_clk[] = {
F(4800, P_XO,  1, 0, 0),
-   F(2, FE_PLL_200,   1, 0, 0),
-   F(5, FE_PLL_500,   1, 0, 0),
-   F(62600, DDRC_PLL_666, 1, 0, 0),
+   F(2, P_FEPLL200,   1, 0, 0),
+   F(5, P_FEPLL500,   1, 0, 0),
+   F(62600, P_DDRPLLAPSS, 1, 0, 0),
{ }
 };
 
@@ -557,7 +547,7 @@ static struct clk_rcg2 apps_clk_src = {
 
 static const struct freq_tbl ftbl_gcc_apps_ahb_clk[] = {
F(4800, P_XO,  1, 0, 0),
-   F(1, FE_PLL_200,   2, 0, 0),
+   F(1, P_FEPLL200,   2, 0, 0),
{ }
 };
 
@@ -941,7 +931,7 @@ static struct clk_branch gcc_usb2_mock_utmi_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_usb30_mock_utmi_clk[] = {
-   F(200, FE_PLL_200, 10, 0, 0),
+   F(200, P_FEPLL200, 10, 0, 0),
{ }
 };
 
@@ -1008,7 +998,7 @@ static struct clk_branch gcc_usb3_mock_utmi_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_fephy_dly_clk[] = {
-   F(12500, FE_PLL_125_DLY, 1, 0, 0),
+   F(12500, P_FEPLL125DLY, 1, 0, 0),
{ }
 };
 
@@ -1028,7 +1018,7 @@ static struct clk_rcg2 fephy_125m_dly_clk_src = {
 
 static const struct freq_tbl ftbl_gcc_wcss2g_clk[] = {
F(4800, P_XO, 1, 0, 0),
-   F(25000, FE_PLL_WCSS2G, 1, 0, 0),
+   F(25000, P_FEPLLWCSS2G, 1, 0, 0),
{ }
 };
 
@@ -1098,7 +1088,7 @@ static struct clk_branch gcc_wcss2g_rtc_clk = {
 
 static const struct freq_tbl ftbl_gcc_wcss5g_clk[] = {
F(4800, P_XO, 1, 0, 0),
-   F(25000, 

[PATCH 04/17] clk: qcom: ipq4019: switch remaining defines to enums

2016-03-23 Thread Matthew McClintock
When this was added not all the remaining defines were switched over to
use enums, so let's complete that process here

Reported-by: Stephen Boyd 
Signed-off-by: Matthew McClintock 
---
 drivers/clk/qcom/gcc-ipq4019.c | 60 ++
 1 file changed, 25 insertions(+), 35 deletions(-)

diff --git a/drivers/clk/qcom/gcc-ipq4019.c b/drivers/clk/qcom/gcc-ipq4019.c
index 21def7f..38ada8d 100644
--- a/drivers/clk/qcom/gcc-ipq4019.c
+++ b/drivers/clk/qcom/gcc-ipq4019.c
@@ -129,20 +129,10 @@ static const char * const gcc_xo_ddr_500_200[] = {
 };
 
 #define F(f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }
-#define P_XO 0
-#define FE_PLL_200 1
-#define FE_PLL_500 2
-#define DDRC_PLL_666  3
-
-#define DDRC_PLL_666_SDCC  1
-#define FE_PLL_125_DLY 1
-
-#define FE_PLL_WCSS2G 1
-#define FE_PLL_WCSS5G 1
 
 static const struct freq_tbl ftbl_gcc_audio_pwm_clk[] = {
F(4800, P_XO, 1, 0, 0),
-   F(2, FE_PLL_200, 1, 0, 0),
+   F(2, P_FEPLL200, 1, 0, 0),
{ }
 };
 
@@ -334,15 +324,15 @@ static struct clk_branch gcc_blsp1_qup2_spi_apps_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_blsp1_uart1_2_apps_clk[] = {
-   F(1843200, FE_PLL_200, 1, 144, 15625),
-   F(3686400, FE_PLL_200, 1, 288, 15625),
-   F(7372800, FE_PLL_200, 1, 576, 15625),
-   F(14745600, FE_PLL_200, 1, 1152, 15625),
-   F(1600, FE_PLL_200, 1, 2, 25),
+   F(1843200, P_FEPLL200, 1, 144, 15625),
+   F(3686400, P_FEPLL200, 1, 288, 15625),
+   F(7372800, P_FEPLL200, 1, 576, 15625),
+   F(14745600, P_FEPLL200, 1, 1152, 15625),
+   F(1600, P_FEPLL200, 1, 2, 25),
F(2400, P_XO, 1, 1, 2),
-   F(3200, FE_PLL_200, 1, 4, 25),
-   F(4000, FE_PLL_200, 1, 1, 5),
-   F(4640, FE_PLL_200, 1, 29, 125),
+   F(3200, P_FEPLL200, 1, 4, 25),
+   F(4000, P_FEPLL200, 1, 1, 5),
+   F(4640, P_FEPLL200, 1, 29, 125),
F(4800, P_XO, 1, 0, 0),
{ }
 };
@@ -410,9 +400,9 @@ static struct clk_branch gcc_blsp1_uart2_apps_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_gp_clk[] = {
-   F(125,  FE_PLL_200, 1, 16, 0),
-   F(250,  FE_PLL_200, 1,  8, 0),
-   F(500,  FE_PLL_200, 1,  4, 0),
+   F(125,  P_FEPLL200, 1, 16, 0),
+   F(250,  P_FEPLL200, 1,  8, 0),
+   F(500,  P_FEPLL200, 1,  4, 0),
{ }
 };
 
@@ -512,11 +502,11 @@ static struct clk_branch gcc_gp3_clk = {
 static const struct freq_tbl ftbl_gcc_sdcc1_apps_clk[] = {
F(144000,P_XO,  1,  3, 240),
F(40,P_XO,  1,  1, 0),
-   F(2000,  FE_PLL_500,1,  1, 25),
-   F(2500,  FE_PLL_500,1,  1, 20),
-   F(5000,  FE_PLL_500,1,  1, 10),
-   F(1, FE_PLL_500,1,  1, 5),
-   F(19300, DDRC_PLL_666_SDCC, 1,  0, 0),
+   F(2000,  P_FEPLL500,1,  1, 25),
+   F(2500,  P_FEPLL500,1,  1, 20),
+   F(5000,  P_FEPLL500,1,  1, 10),
+   F(1, P_FEPLL500,1,  1, 5),
+   F(19300, P_DDRPLL,  1,  0, 0),
{ }
 };
 
@@ -536,9 +526,9 @@ static struct clk_rcg2  sdcc1_apps_clk_src = {
 
 static const struct freq_tbl ftbl_gcc_apps_clk[] = {
F(4800, P_XO,  1, 0, 0),
-   F(2, FE_PLL_200,   1, 0, 0),
-   F(5, FE_PLL_500,   1, 0, 0),
-   F(62600, DDRC_PLL_666, 1, 0, 0),
+   F(2, P_FEPLL200,   1, 0, 0),
+   F(5, P_FEPLL500,   1, 0, 0),
+   F(62600, P_DDRPLLAPSS, 1, 0, 0),
{ }
 };
 
@@ -557,7 +547,7 @@ static struct clk_rcg2 apps_clk_src = {
 
 static const struct freq_tbl ftbl_gcc_apps_ahb_clk[] = {
F(4800, P_XO,  1, 0, 0),
-   F(1, FE_PLL_200,   2, 0, 0),
+   F(1, P_FEPLL200,   2, 0, 0),
{ }
 };
 
@@ -941,7 +931,7 @@ static struct clk_branch gcc_usb2_mock_utmi_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_usb30_mock_utmi_clk[] = {
-   F(200, FE_PLL_200, 10, 0, 0),
+   F(200, P_FEPLL200, 10, 0, 0),
{ }
 };
 
@@ -1008,7 +998,7 @@ static struct clk_branch gcc_usb3_mock_utmi_clk = {
 };
 
 static const struct freq_tbl ftbl_gcc_fephy_dly_clk[] = {
-   F(12500, FE_PLL_125_DLY, 1, 0, 0),
+   F(12500, P_FEPLL125DLY, 1, 0, 0),
{ }
 };
 
@@ -1028,7 +1018,7 @@ static struct clk_rcg2 fephy_125m_dly_clk_src = {
 
 static const struct freq_tbl ftbl_gcc_wcss2g_clk[] = {
F(4800, P_XO, 1, 0, 0),
-   F(25000, FE_PLL_WCSS2G, 1, 0, 0),
+   F(25000, P_FEPLLWCSS2G, 1, 0, 0),
{ }
 };
 
@@ -1098,7 +1088,7 @@ static struct clk_branch gcc_wcss2g_rtc_clk = {
 
 static const struct freq_tbl ftbl_gcc_wcss5g_clk[] = {
F(4800, P_XO, 1, 0, 0),
-   F(25000, FE_PLL_WCSS5G, 1, 0, 0),
+   F(25000, 

[PATCH 11/17] qcom: ipq4019: add support for reset via qcom,ps-hold

2016-03-23 Thread Matthew McClintock
This will allow these types of boards to be rebooted.

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index 00a5e9e..acb851d 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -179,5 +179,10 @@
timeout-sec = <10>;
status = "disabled";
};
+
+   restart@4ab000 {
+   compatible = "qcom,pshold";
+   reg = <0x4ab000 0x4>;
+   };
};
 };
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 11/17] qcom: ipq4019: add support for reset via qcom,ps-hold

2016-03-23 Thread Matthew McClintock
This will allow these types of boards to be rebooted.

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index 00a5e9e..acb851d 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -179,5 +179,10 @@
timeout-sec = <10>;
status = "disabled";
};
+
+   restart@4ab000 {
+   compatible = "qcom,pshold";
+   reg = <0x4ab000 0x4>;
+   };
};
 };
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 09/17] watchdog: qcom: add kpss-standalone to device tree binding

2016-03-23 Thread Matthew McClintock
Update the compatible string to add new device tree binding

CC: linux-watch...@vger.kernel.org
Signed-off-by: Matthew McClintock 
---
 Documentation/devicetree/bindings/watchdog/qcom-wdt.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
index 60bb2f98..45b37cf 100644
--- a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
@@ -6,6 +6,7 @@ Required properties :
 
"qcom,kpss-timer"
"qcom,scss-timer"
+   "qcom,kpss-standalone"
 
 - reg : shall contain base register location and length
 - clocks : shall contain the input clock
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 06/17] watchdog: qcom: update device tree bindings

2016-03-23 Thread Matthew McClintock
Update the compatible string to align with driver

CC: linux-watch...@vger.kernel.org
Signed-off-by: Matthew McClintock 
---
 Documentation/devicetree/bindings/watchdog/qcom-wdt.txt | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
index 4726924..60bb2f98 100644
--- a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
@@ -4,9 +4,8 @@ Qualcomm Krait Processor Sub-system (KPSS) Watchdog
 Required properties :
 - compatible : shall contain only one of the following:
 
-   "qcom,kpss-wdt-msm8960"
-   "qcom,kpss-wdt-apq8064"
-   "qcom,kpss-wdt-ipq8064"
+   "qcom,kpss-timer"
+   "qcom,scss-timer"
 
 - reg : shall contain base register location and length
 - clocks : shall contain the input clock
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 09/17] watchdog: qcom: add kpss-standalone to device tree binding

2016-03-23 Thread Matthew McClintock
Update the compatible string to add new device tree binding

CC: linux-watch...@vger.kernel.org
Signed-off-by: Matthew McClintock 
---
 Documentation/devicetree/bindings/watchdog/qcom-wdt.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
index 60bb2f98..45b37cf 100644
--- a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
@@ -6,6 +6,7 @@ Required properties :
 
"qcom,kpss-timer"
"qcom,scss-timer"
+   "qcom,kpss-standalone"
 
 - reg : shall contain base register location and length
 - clocks : shall contain the input clock
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 06/17] watchdog: qcom: update device tree bindings

2016-03-23 Thread Matthew McClintock
Update the compatible string to align with driver

CC: linux-watch...@vger.kernel.org
Signed-off-by: Matthew McClintock 
---
 Documentation/devicetree/bindings/watchdog/qcom-wdt.txt | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
index 4726924..60bb2f98 100644
--- a/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/qcom-wdt.txt
@@ -4,9 +4,8 @@ Qualcomm Krait Processor Sub-system (KPSS) Watchdog
 Required properties :
 - compatible : shall contain only one of the following:
 
-   "qcom,kpss-wdt-msm8960"
-   "qcom,kpss-wdt-apq8064"
-   "qcom,kpss-wdt-ipq8064"
+   "qcom,kpss-timer"
+   "qcom,scss-timer"
 
 - reg : shall contain base register location and length
 - clocks : shall contain the input clock
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 07/17] watchdog: qcom: add option for standalone watchdog not in timer block

2016-03-23 Thread Matthew McClintock
Commit 0dfd582e026a ("watchdog: qcom: use timer devicetree binding") moved
to use the watchdog as a subset timer register block. Some devices have the
watchdog completely standalone with slightly different register offsets as
well so let's account for the differences here.

Signed-off-by: Matthew McClintock 
---
 drivers/watchdog/qcom-wdt.c | 69 -
 1 file changed, 49 insertions(+), 20 deletions(-)

diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index 20563cc..e46f18d 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -19,17 +19,37 @@
 #include 
 #include 
 
-#define WDT_RST0x38
-#define WDT_EN 0x40
-#define WDT_BITE_TIME  0x5C
+enum wdt_reg {
+   WDT_RST,
+   WDT_EN,
+   WDT_BITE_TIME,
+};
+
+static const u32 reg_offset_data_apcs_tmr[] = {
+   [WDT_RST] = 0x38,
+   [WDT_EN] = 0x40,
+   [WDT_BITE_TIME] = 0x5C,
+};
+
+static const u32 reg_offset_data_kpss[] = {
+   [WDT_RST] = 0x4,
+   [WDT_EN] = 0x8,
+   [WDT_BITE_TIME] = 0x14,
+};
 
 struct qcom_wdt {
struct watchdog_device  wdd;
struct clk  *clk;
unsigned long   rate;
void __iomem*base;
+   const u32   *layout;
 };
 
+static void __iomem *wdt_addr(struct qcom_wdt *wdt, enum wdt_reg reg)
+{
+   return wdt->base + wdt->layout[reg];
+}
+
 static inline
 struct qcom_wdt *to_qcom_wdt(struct watchdog_device *wdd)
 {
@@ -40,10 +60,10 @@ static int qcom_wdt_start(struct watchdog_device *wdd)
 {
struct qcom_wdt *wdt = to_qcom_wdt(wdd);
 
-   writel(0, wdt->base + WDT_EN);
-   writel(1, wdt->base + WDT_RST);
-   writel(wdd->timeout * wdt->rate, wdt->base + WDT_BITE_TIME);
-   writel(1, wdt->base + WDT_EN);
+   writel(0, wdt_addr(wdt, WDT_EN));
+   writel(1, wdt_addr(wdt, WDT_RST));
+   writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BITE_TIME));
+   writel(1, wdt_addr(wdt, WDT_EN));
return 0;
 }
 
@@ -51,7 +71,7 @@ static int qcom_wdt_stop(struct watchdog_device *wdd)
 {
struct qcom_wdt *wdt = to_qcom_wdt(wdd);
 
-   writel(0, wdt->base + WDT_EN);
+   writel(0, wdt_addr(wdt, WDT_EN));
return 0;
 }
 
@@ -59,7 +79,7 @@ static int qcom_wdt_ping(struct watchdog_device *wdd)
 {
struct qcom_wdt *wdt = to_qcom_wdt(wdd);
 
-   writel(1, wdt->base + WDT_RST);
+   writel(1, wdt_addr(wdt, WDT_RST));
return 0;
 }
 
@@ -82,10 +102,10 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, 
unsigned long action,
 */
timeout = 128 * wdt->rate / 1000;
 
-   writel(0, wdt->base + WDT_EN);
-   writel(1, wdt->base + WDT_RST);
-   writel(timeout, wdt->base + WDT_BITE_TIME);
-   writel(1, wdt->base + WDT_EN);
+   writel(0, wdt_addr(wdt, WDT_EN));
+   writel(1, wdt_addr(wdt, WDT_RST));
+   writel(timeout, wdt_addr(wdt, WDT_BITE_TIME));
+   writel(1, wdt_addr(wdt, WDT_EN));
 
/*
 * Actually make sure the above sequence hits hardware before sleeping.
@@ -112,14 +132,29 @@ static const struct watchdog_info qcom_wdt_info = {
.identity   = KBUILD_MODNAME,
 };
 
+static const struct of_device_id qcom_wdt_of_table[] = {
+   { .compatible = "qcom,kpss-timer", .data = reg_offset_data_apcs_tmr },
+   { .compatible = "qcom,scss-timer", .data = reg_offset_data_apcs_tmr },
+   { .compatible = "qcom,kpss-standalone", .data = _offset_data_kpss},
+   { },
+};
+MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);
+
 static int qcom_wdt_probe(struct platform_device *pdev)
 {
struct qcom_wdt *wdt;
struct resource *res;
struct device_node *np = pdev->dev.of_node;
+   const struct of_device_id *match;
u32 percpu_offset;
int ret;
 
+   match = of_match_node(qcom_wdt_of_table, np);
+   if (!match) {
+   dev_err(>dev, "Unsupported QCOM WDT module\n");
+   return -ENODEV;
+   }
+
wdt = devm_kzalloc(>dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt)
return -ENOMEM;
@@ -170,6 +205,7 @@ static int qcom_wdt_probe(struct platform_device *pdev)
wdt->wdd.min_timeout = 1;
wdt->wdd.max_timeout = 0x1000U / wdt->rate;
wdt->wdd.parent = >dev;
+   wdt->layout = match->data;
 
/*
 * If 'timeout-sec' unspecified in devicetree, assume a 30 second
@@ -202,13 +238,6 @@ static int qcom_wdt_remove(struct platform_device *pdev)
return 0;
 }
 
-static const struct of_device_id qcom_wdt_of_table[] = {
-   { .compatible = "qcom,kpss-timer" },
-   { .compatible = "qcom,scss-timer" },
-   { },
-};
-MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);
-
 static struct platform_driver qcom_watchdog_driver = {
.probe  = qcom_wdt_probe,
.remove = qcom_wdt_remove,
-- 
The Qualcomm Innovation Center, Inc. is a member of the 

[PATCH 13/17] qcom: ipq4019: add i2c node to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This will allow boards to enable the I2C bus

CC: Sricharan R 
Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019.dtsi | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index 99e64f4..1937edf 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -25,6 +25,7 @@
 
aliases {
spi0 = _0;
+   i2c0 = _0;
};
 
cpus {
@@ -126,6 +127,18 @@
status = "disabled";
};
 
+   i2c_0: i2c@78b7000 {
+   compatible = "qcom,i2c-qup-v2.2.1";
+   reg = <0x78b7000 0x6000>;
+   interrupts = ;
+   clocks = < GCC_BLSP1_AHB_CLK>,
+< GCC_BLSP1_QUP2_I2C_APPS_CLK>;
+   clock-names = "iface", "core";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
 acc0: clock-controller@b088000 {
 compatible = "qcom,kpss-acc-v1";
 reg = <0x0b088000 0x1000>, <0xb008000 0x1000>;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 07/17] watchdog: qcom: add option for standalone watchdog not in timer block

2016-03-23 Thread Matthew McClintock
Commit 0dfd582e026a ("watchdog: qcom: use timer devicetree binding") moved
to use the watchdog as a subset timer register block. Some devices have the
watchdog completely standalone with slightly different register offsets as
well so let's account for the differences here.

Signed-off-by: Matthew McClintock 
---
 drivers/watchdog/qcom-wdt.c | 69 -
 1 file changed, 49 insertions(+), 20 deletions(-)

diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index 20563cc..e46f18d 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -19,17 +19,37 @@
 #include 
 #include 
 
-#define WDT_RST0x38
-#define WDT_EN 0x40
-#define WDT_BITE_TIME  0x5C
+enum wdt_reg {
+   WDT_RST,
+   WDT_EN,
+   WDT_BITE_TIME,
+};
+
+static const u32 reg_offset_data_apcs_tmr[] = {
+   [WDT_RST] = 0x38,
+   [WDT_EN] = 0x40,
+   [WDT_BITE_TIME] = 0x5C,
+};
+
+static const u32 reg_offset_data_kpss[] = {
+   [WDT_RST] = 0x4,
+   [WDT_EN] = 0x8,
+   [WDT_BITE_TIME] = 0x14,
+};
 
 struct qcom_wdt {
struct watchdog_device  wdd;
struct clk  *clk;
unsigned long   rate;
void __iomem*base;
+   const u32   *layout;
 };
 
+static void __iomem *wdt_addr(struct qcom_wdt *wdt, enum wdt_reg reg)
+{
+   return wdt->base + wdt->layout[reg];
+}
+
 static inline
 struct qcom_wdt *to_qcom_wdt(struct watchdog_device *wdd)
 {
@@ -40,10 +60,10 @@ static int qcom_wdt_start(struct watchdog_device *wdd)
 {
struct qcom_wdt *wdt = to_qcom_wdt(wdd);
 
-   writel(0, wdt->base + WDT_EN);
-   writel(1, wdt->base + WDT_RST);
-   writel(wdd->timeout * wdt->rate, wdt->base + WDT_BITE_TIME);
-   writel(1, wdt->base + WDT_EN);
+   writel(0, wdt_addr(wdt, WDT_EN));
+   writel(1, wdt_addr(wdt, WDT_RST));
+   writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BITE_TIME));
+   writel(1, wdt_addr(wdt, WDT_EN));
return 0;
 }
 
@@ -51,7 +71,7 @@ static int qcom_wdt_stop(struct watchdog_device *wdd)
 {
struct qcom_wdt *wdt = to_qcom_wdt(wdd);
 
-   writel(0, wdt->base + WDT_EN);
+   writel(0, wdt_addr(wdt, WDT_EN));
return 0;
 }
 
@@ -59,7 +79,7 @@ static int qcom_wdt_ping(struct watchdog_device *wdd)
 {
struct qcom_wdt *wdt = to_qcom_wdt(wdd);
 
-   writel(1, wdt->base + WDT_RST);
+   writel(1, wdt_addr(wdt, WDT_RST));
return 0;
 }
 
@@ -82,10 +102,10 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, 
unsigned long action,
 */
timeout = 128 * wdt->rate / 1000;
 
-   writel(0, wdt->base + WDT_EN);
-   writel(1, wdt->base + WDT_RST);
-   writel(timeout, wdt->base + WDT_BITE_TIME);
-   writel(1, wdt->base + WDT_EN);
+   writel(0, wdt_addr(wdt, WDT_EN));
+   writel(1, wdt_addr(wdt, WDT_RST));
+   writel(timeout, wdt_addr(wdt, WDT_BITE_TIME));
+   writel(1, wdt_addr(wdt, WDT_EN));
 
/*
 * Actually make sure the above sequence hits hardware before sleeping.
@@ -112,14 +132,29 @@ static const struct watchdog_info qcom_wdt_info = {
.identity   = KBUILD_MODNAME,
 };
 
+static const struct of_device_id qcom_wdt_of_table[] = {
+   { .compatible = "qcom,kpss-timer", .data = reg_offset_data_apcs_tmr },
+   { .compatible = "qcom,scss-timer", .data = reg_offset_data_apcs_tmr },
+   { .compatible = "qcom,kpss-standalone", .data = _offset_data_kpss},
+   { },
+};
+MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);
+
 static int qcom_wdt_probe(struct platform_device *pdev)
 {
struct qcom_wdt *wdt;
struct resource *res;
struct device_node *np = pdev->dev.of_node;
+   const struct of_device_id *match;
u32 percpu_offset;
int ret;
 
+   match = of_match_node(qcom_wdt_of_table, np);
+   if (!match) {
+   dev_err(>dev, "Unsupported QCOM WDT module\n");
+   return -ENODEV;
+   }
+
wdt = devm_kzalloc(>dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt)
return -ENOMEM;
@@ -170,6 +205,7 @@ static int qcom_wdt_probe(struct platform_device *pdev)
wdt->wdd.min_timeout = 1;
wdt->wdd.max_timeout = 0x1000U / wdt->rate;
wdt->wdd.parent = >dev;
+   wdt->layout = match->data;
 
/*
 * If 'timeout-sec' unspecified in devicetree, assume a 30 second
@@ -202,13 +238,6 @@ static int qcom_wdt_remove(struct platform_device *pdev)
return 0;
 }
 
-static const struct of_device_id qcom_wdt_of_table[] = {
-   { .compatible = "qcom,kpss-timer" },
-   { .compatible = "qcom,scss-timer" },
-   { },
-};
-MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);
-
 static struct platform_driver qcom_watchdog_driver = {
.probe  = qcom_wdt_probe,
.remove = qcom_wdt_remove,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a 

[PATCH 13/17] qcom: ipq4019: add i2c node to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This will allow boards to enable the I2C bus

CC: Sricharan R 
Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019.dtsi | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index 99e64f4..1937edf 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -25,6 +25,7 @@
 
aliases {
spi0 = _0;
+   i2c0 = _0;
};
 
cpus {
@@ -126,6 +127,18 @@
status = "disabled";
};
 
+   i2c_0: i2c@78b7000 {
+   compatible = "qcom,i2c-qup-v2.2.1";
+   reg = <0x78b7000 0x6000>;
+   interrupts = ;
+   clocks = < GCC_BLSP1_AHB_CLK>,
+< GCC_BLSP1_QUP2_I2C_APPS_CLK>;
+   clock-names = "iface", "core";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
 acc0: clock-controller@b088000 {
 compatible = "qcom,kpss-acc-v1";
 reg = <0x0b088000 0x1000>, <0xb008000 0x1000>;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 10/17] qcom: ipq4019: add watchdog node to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This will allow boards to enable watchdog support

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi | 4 
 arch/arm/boot/dts/qcom-ipq4019.dtsi   | 8 
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
index fe78f3f..223da1a 100644
--- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
@@ -55,5 +55,9 @@
pinctrl-names = "default";
status = "ok";
};
+
+   watchdog@b017000 {
+   status = "ok";
+   };
};
 };
diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index e44f5b6..00a5e9e 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -171,5 +171,13 @@
< GCC_BLSP1_AHB_CLK>;
clock-names = "core", "iface";
};
+
+   watchdog@b017000 {
+   compatible = "qcom,kpss-standalone";
+   reg = <0xb017000 0x40>;
+   clocks = <_clk>;
+   timeout-sec = <10>;
+   status = "disabled";
+   };
};
 };
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 12/17] qcom: ipq4019: add spi node to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This will allow boards to enable the SPI bus

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi | 37 +++
 arch/arm/boot/dts/qcom-ipq4019.dtsi   | 18 +
 2 files changed, 55 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
index 223da1a..21032a8 100644
--- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
@@ -48,6 +48,43 @@
bias-disable;
};
};
+
+   spi_0_pins: spi_0_pinmux {
+   pinmux {
+   function = "blsp_spi0";
+   pins = "gpio55", "gpio56", "gpio57";
+   };
+   pinmux_cs {
+   function = "gpio";
+   pins = "gpio54";
+   };
+   pinconf {
+   pins = "gpio55", "gpio56", "gpio57";
+   drive-strength = <12>;
+   bias-disable;
+   };
+   pinconf_cs {
+   pins = "gpio54";
+   drive-strength = <2>;
+   bias-disable;
+   output-high;
+   };
+   };
+   };
+
+   spi_0: spi@78b5000 {
+   pinctrl-0 = <_0_pins>;
+   pinctrl-names = "default";
+   status = "ok";
+   cs-gpios = < 54 0>;
+
+   mx25l25635e@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0>;
+   compatible = "mx25l25635e";
+   spi-max-frequency = <2400>;
+   };
};
 
serial@78af000 {
diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index acb851d..99e64f4 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -15,12 +15,18 @@
 
 #include "skeleton.dtsi"
 #include 
+#include 
+#include 
 
 / {
model = "Qualcomm Technologies, Inc. IPQ4019";
compatible = "qcom,ipq4019";
interrupt-parent = <>;
 
+   aliases {
+   spi0 = _0;
+   };
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -108,6 +114,18 @@
interrupts = <0 208 0>;
};
 
+   spi_0: spi@78b5000 {
+   compatible = "qcom,spi-qup-v2.2.1";
+   reg = <0x78b5000 0x600>;
+   interrupts = ;
+   clocks = < GCC_BLSP1_QUP1_SPI_APPS_CLK>,
+< GCC_BLSP1_AHB_CLK>;
+   clock-names = "core", "iface";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
 acc0: clock-controller@b088000 {
 compatible = "qcom,kpss-acc-v1";
 reg = <0x0b088000 0x1000>, <0xb008000 0x1000>;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 10/17] qcom: ipq4019: add watchdog node to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This will allow boards to enable watchdog support

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi | 4 
 arch/arm/boot/dts/qcom-ipq4019.dtsi   | 8 
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
index fe78f3f..223da1a 100644
--- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
@@ -55,5 +55,9 @@
pinctrl-names = "default";
status = "ok";
};
+
+   watchdog@b017000 {
+   status = "ok";
+   };
};
 };
diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index e44f5b6..00a5e9e 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -171,5 +171,13 @@
< GCC_BLSP1_AHB_CLK>;
clock-names = "core", "iface";
};
+
+   watchdog@b017000 {
+   compatible = "qcom,kpss-standalone";
+   reg = <0xb017000 0x40>;
+   clocks = <_clk>;
+   timeout-sec = <10>;
+   status = "disabled";
+   };
};
 };
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 12/17] qcom: ipq4019: add spi node to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This will allow boards to enable the SPI bus

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi | 37 +++
 arch/arm/boot/dts/qcom-ipq4019.dtsi   | 18 +
 2 files changed, 55 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
index 223da1a..21032a8 100644
--- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
@@ -48,6 +48,43 @@
bias-disable;
};
};
+
+   spi_0_pins: spi_0_pinmux {
+   pinmux {
+   function = "blsp_spi0";
+   pins = "gpio55", "gpio56", "gpio57";
+   };
+   pinmux_cs {
+   function = "gpio";
+   pins = "gpio54";
+   };
+   pinconf {
+   pins = "gpio55", "gpio56", "gpio57";
+   drive-strength = <12>;
+   bias-disable;
+   };
+   pinconf_cs {
+   pins = "gpio54";
+   drive-strength = <2>;
+   bias-disable;
+   output-high;
+   };
+   };
+   };
+
+   spi_0: spi@78b5000 {
+   pinctrl-0 = <_0_pins>;
+   pinctrl-names = "default";
+   status = "ok";
+   cs-gpios = < 54 0>;
+
+   mx25l25635e@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0>;
+   compatible = "mx25l25635e";
+   spi-max-frequency = <2400>;
+   };
};
 
serial@78af000 {
diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index acb851d..99e64f4 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -15,12 +15,18 @@
 
 #include "skeleton.dtsi"
 #include 
+#include 
+#include 
 
 / {
model = "Qualcomm Technologies, Inc. IPQ4019";
compatible = "qcom,ipq4019";
interrupt-parent = <>;
 
+   aliases {
+   spi0 = _0;
+   };
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -108,6 +114,18 @@
interrupts = <0 208 0>;
};
 
+   spi_0: spi@78b5000 {
+   compatible = "qcom,spi-qup-v2.2.1";
+   reg = <0x78b5000 0x600>;
+   interrupts = ;
+   clocks = < GCC_BLSP1_QUP1_SPI_APPS_CLK>,
+< GCC_BLSP1_AHB_CLK>;
+   clock-names = "core", "iface";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
 acc0: clock-controller@b088000 {
 compatible = "qcom,kpss-acc-v1";
 reg = <0x0b088000 0x1000>, <0xb008000 0x1000>;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 16/17] qcom: ipq4019: add crypto nodes to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This adds the crypto nodes to the ipq4019 device tree, it also adds the
BAM node used by crypto as well which the driver currently requires to
operate properly

The crypto driver itself depends on some other patches to qcom_bam_dma
to function properly:

https://lkml.org/lkml/2015/12/1/113

CC: Stanimir Varbanov 
Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi |  8 
 arch/arm/boot/dts/qcom-ipq4019.dtsi   | 25 +
 2 files changed, 33 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
index 21032a8..2c347ad 100644
--- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
@@ -93,6 +93,14 @@
status = "ok";
};
 
+   cryptobam: dma@8e04000 {
+   status = "ok";
+   };
+
+   crypto@8e3a000 {
+   status = "ok";
+   };
+
watchdog@b017000 {
status = "ok";
};
diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index db48fd3..3cd42c0 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -147,6 +147,31 @@
status = "disabled";
};
 
+
+   cryptobam: dma@8e04000 {
+   compatible = "qcom,bam-v1.7.0";
+   reg = <0x08e04000 0x2>;
+   interrupts = ;
+   clocks = < GCC_CRYPTO_AHB_CLK>;
+   clock-names = "bam_clk";
+   #dma-cells = <1>;
+   qcom,ee = <1>;
+   qcom,controlled-remotely;
+   status = "disabled";
+   };
+
+   crypto@8e3a000 {
+   compatible = "qcom,crypto-v5.1";
+   reg = <0x08e3a000 0x6000>;
+   clocks = < GCC_CRYPTO_AHB_CLK>,
+< GCC_CRYPTO_AXI_CLK>,
+< GCC_CRYPTO_CLK>;
+   clock-names = "iface", "bus", "core";
+   dmas = < 2>, < 3>;
+   dma-names = "rx", "tx";
+   status = "disabled";
+   };
+
 acc0: clock-controller@b088000 {
 compatible = "qcom,kpss-acc-v1";
 reg = <0x0b088000 0x1000>, <0xb008000 0x1000>;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 15/17] qcom: ipq4019: add cpu operating points for cpufreq support

2016-03-23 Thread Matthew McClintock
This adds some operating points for cpu frequeny scaling

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index 1937edf..db48fd3 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -40,6 +40,14 @@
reg = <0x0>;
clocks = < GCC_APPS_CLK_SRC>;
clock-frequency = <0>;
+   operating-points = <
+   /* kHz  uV (fixed) */
+   48000   110
+   20  110
+   50  110
+   666000  110
+   >;
+   clock-latency = <256000>;
};
 
cpu@1 {
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 15/17] qcom: ipq4019: add cpu operating points for cpufreq support

2016-03-23 Thread Matthew McClintock
This adds some operating points for cpu frequeny scaling

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index 1937edf..db48fd3 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -40,6 +40,14 @@
reg = <0x0>;
clocks = < GCC_APPS_CLK_SRC>;
clock-frequency = <0>;
+   operating-points = <
+   /* kHz  uV (fixed) */
+   48000   110
+   20  110
+   50  110
+   666000  110
+   >;
+   clock-latency = <256000>;
};
 
cpu@1 {
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 16/17] qcom: ipq4019: add crypto nodes to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This adds the crypto nodes to the ipq4019 device tree, it also adds the
BAM node used by crypto as well which the driver currently requires to
operate properly

The crypto driver itself depends on some other patches to qcom_bam_dma
to function properly:

https://lkml.org/lkml/2015/12/1/113

CC: Stanimir Varbanov 
Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi |  8 
 arch/arm/boot/dts/qcom-ipq4019.dtsi   | 25 +
 2 files changed, 33 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
index 21032a8..2c347ad 100644
--- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
@@ -93,6 +93,14 @@
status = "ok";
};
 
+   cryptobam: dma@8e04000 {
+   status = "ok";
+   };
+
+   crypto@8e3a000 {
+   status = "ok";
+   };
+
watchdog@b017000 {
status = "ok";
};
diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index db48fd3..3cd42c0 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -147,6 +147,31 @@
status = "disabled";
};
 
+
+   cryptobam: dma@8e04000 {
+   compatible = "qcom,bam-v1.7.0";
+   reg = <0x08e04000 0x2>;
+   interrupts = ;
+   clocks = < GCC_CRYPTO_AHB_CLK>;
+   clock-names = "bam_clk";
+   #dma-cells = <1>;
+   qcom,ee = <1>;
+   qcom,controlled-remotely;
+   status = "disabled";
+   };
+
+   crypto@8e3a000 {
+   compatible = "qcom,crypto-v5.1";
+   reg = <0x08e3a000 0x6000>;
+   clocks = < GCC_CRYPTO_AHB_CLK>,
+< GCC_CRYPTO_AXI_CLK>,
+< GCC_CRYPTO_CLK>;
+   clock-names = "iface", "bus", "core";
+   dmas = < 2>, < 3>;
+   dma-names = "rx", "tx";
+   status = "disabled";
+   };
+
 acc0: clock-controller@b088000 {
 compatible = "qcom,kpss-acc-v1";
 reg = <0x0b088000 0x1000>, <0xb008000 0x1000>;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 14/17] cpufreq: ipq4019: add cpufreq driver

2016-03-23 Thread Matthew McClintock
Add cpufreq driver for ipq4019 SoC. This driver simply instantiates
cpufreq-dt.

Signed-off-by: Matthew McClintock 
---
 drivers/cpufreq/Kconfig.arm   |  9 +
 drivers/cpufreq/Makefile  |  1 +
 drivers/cpufreq/ipq4019-cpufreq.c | 35 +++
 3 files changed, 45 insertions(+)
 create mode 100644 drivers/cpufreq/ipq4019-cpufreq.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 14b1f93..187803d 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -69,6 +69,15 @@ config ARM_IMX6Q_CPUFREQ
 
  If in doubt, say N.
 
+config ARM_IPQ4019_CPUFREQ
+tristate "Qualcomm IPQ4019 cpufreq support"
+   depends on ARCH_QCOM && CPUFREQ_DT
+select PM_OPP
+help
+ This adds cpufreq driver support for Qualcomm IPQ4019 series SoCs.
+
+  If in doubt, say N.
+
 config ARM_INTEGRATOR
tristate "CPUfreq driver for ARM Integrator CPUs"
depends on ARCH_INTEGRATOR
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 9e63fb1..8ed4cdb 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)  += exynos5440-cpufreq.o
 obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o
 obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ)+= hisi-acpu-cpufreq.o
 obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)+= imx6q-cpufreq.o
+obj-$(CONFIG_ARM_IPQ4019_CPUFREQ)  += ipq4019-cpufreq.o
 obj-$(CONFIG_ARM_INTEGRATOR)   += integrator-cpufreq.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o
 obj-$(CONFIG_ARM_MT8173_CPUFREQ)   += mt8173-cpufreq.o
diff --git a/drivers/cpufreq/ipq4019-cpufreq.c 
b/drivers/cpufreq/ipq4019-cpufreq.c
new file mode 100644
index 000..6f7bba3
--- /dev/null
+++ b/drivers/cpufreq/ipq4019-cpufreq.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 
+
+static int __init ipq4019_cpufreq_driver_init(void)
+{
+   struct platform_device *pdev;
+
+   if (!of_machine_is_compatible("qcom,ipq4019"))
+   return -ENODEV;
+
+   pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
+   return PTR_ERR_OR_ZERO(pdev);
+}
+module_init(ipq4019_cpufreq_driver_init);
+
+MODULE_AUTHOR("Matthew McClintock ");
+MODULE_DESCRIPTION("ipq4019 cpufreq driver");
+MODULE_LICENSE("GPL");
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 08/17] watchdog: qcom: configure BARK time in addition to BITE time

2016-03-23 Thread Matthew McClintock
For certain parts and some versions of TZ, TZ will reset the chip
when a BARK is triggered even though it was not configured here. So
by default let's configure this BARK time as well.

Signed-off-by: Matthew McClintock 
---
 drivers/watchdog/qcom-wdt.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index e46f18d..53f57c3 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -22,18 +22,21 @@
 enum wdt_reg {
WDT_RST,
WDT_EN,
+   WDT_BARK_TIME,
WDT_BITE_TIME,
 };
 
 static const u32 reg_offset_data_apcs_tmr[] = {
[WDT_RST] = 0x38,
[WDT_EN] = 0x40,
+   [WDT_BARK_TIME] = 0x4C,
[WDT_BITE_TIME] = 0x5C,
 };
 
 static const u32 reg_offset_data_kpss[] = {
[WDT_RST] = 0x4,
[WDT_EN] = 0x8,
+   [WDT_BARK_TIME] = 0x10,
[WDT_BITE_TIME] = 0x14,
 };
 
@@ -62,6 +65,7 @@ static int qcom_wdt_start(struct watchdog_device *wdd)
 
writel(0, wdt_addr(wdt, WDT_EN));
writel(1, wdt_addr(wdt, WDT_RST));
+   writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BARK_TIME));
writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BITE_TIME));
writel(1, wdt_addr(wdt, WDT_EN));
return 0;
@@ -104,6 +108,7 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, 
unsigned long action,
 
writel(0, wdt_addr(wdt, WDT_EN));
writel(1, wdt_addr(wdt, WDT_RST));
+   writel(timeout, wdt_addr(wdt, WDT_BARK_TIME));
writel(timeout, wdt_addr(wdt, WDT_BITE_TIME));
writel(1, wdt_addr(wdt, WDT_EN));
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 14/17] cpufreq: ipq4019: add cpufreq driver

2016-03-23 Thread Matthew McClintock
Add cpufreq driver for ipq4019 SoC. This driver simply instantiates
cpufreq-dt.

Signed-off-by: Matthew McClintock 
---
 drivers/cpufreq/Kconfig.arm   |  9 +
 drivers/cpufreq/Makefile  |  1 +
 drivers/cpufreq/ipq4019-cpufreq.c | 35 +++
 3 files changed, 45 insertions(+)
 create mode 100644 drivers/cpufreq/ipq4019-cpufreq.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 14b1f93..187803d 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -69,6 +69,15 @@ config ARM_IMX6Q_CPUFREQ
 
  If in doubt, say N.
 
+config ARM_IPQ4019_CPUFREQ
+tristate "Qualcomm IPQ4019 cpufreq support"
+   depends on ARCH_QCOM && CPUFREQ_DT
+select PM_OPP
+help
+ This adds cpufreq driver support for Qualcomm IPQ4019 series SoCs.
+
+  If in doubt, say N.
+
 config ARM_INTEGRATOR
tristate "CPUfreq driver for ARM Integrator CPUs"
depends on ARCH_INTEGRATOR
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 9e63fb1..8ed4cdb 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)  += exynos5440-cpufreq.o
 obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o
 obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ)+= hisi-acpu-cpufreq.o
 obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)+= imx6q-cpufreq.o
+obj-$(CONFIG_ARM_IPQ4019_CPUFREQ)  += ipq4019-cpufreq.o
 obj-$(CONFIG_ARM_INTEGRATOR)   += integrator-cpufreq.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o
 obj-$(CONFIG_ARM_MT8173_CPUFREQ)   += mt8173-cpufreq.o
diff --git a/drivers/cpufreq/ipq4019-cpufreq.c 
b/drivers/cpufreq/ipq4019-cpufreq.c
new file mode 100644
index 000..6f7bba3
--- /dev/null
+++ b/drivers/cpufreq/ipq4019-cpufreq.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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 
+
+static int __init ipq4019_cpufreq_driver_init(void)
+{
+   struct platform_device *pdev;
+
+   if (!of_machine_is_compatible("qcom,ipq4019"))
+   return -ENODEV;
+
+   pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
+   return PTR_ERR_OR_ZERO(pdev);
+}
+module_init(ipq4019_cpufreq_driver_init);
+
+MODULE_AUTHOR("Matthew McClintock ");
+MODULE_DESCRIPTION("ipq4019 cpufreq driver");
+MODULE_LICENSE("GPL");
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 08/17] watchdog: qcom: configure BARK time in addition to BITE time

2016-03-23 Thread Matthew McClintock
For certain parts and some versions of TZ, TZ will reset the chip
when a BARK is triggered even though it was not configured here. So
by default let's configure this BARK time as well.

Signed-off-by: Matthew McClintock 
---
 drivers/watchdog/qcom-wdt.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index e46f18d..53f57c3 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -22,18 +22,21 @@
 enum wdt_reg {
WDT_RST,
WDT_EN,
+   WDT_BARK_TIME,
WDT_BITE_TIME,
 };
 
 static const u32 reg_offset_data_apcs_tmr[] = {
[WDT_RST] = 0x38,
[WDT_EN] = 0x40,
+   [WDT_BARK_TIME] = 0x4C,
[WDT_BITE_TIME] = 0x5C,
 };
 
 static const u32 reg_offset_data_kpss[] = {
[WDT_RST] = 0x4,
[WDT_EN] = 0x8,
+   [WDT_BARK_TIME] = 0x10,
[WDT_BITE_TIME] = 0x14,
 };
 
@@ -62,6 +65,7 @@ static int qcom_wdt_start(struct watchdog_device *wdd)
 
writel(0, wdt_addr(wdt, WDT_EN));
writel(1, wdt_addr(wdt, WDT_RST));
+   writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BARK_TIME));
writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BITE_TIME));
writel(1, wdt_addr(wdt, WDT_EN));
return 0;
@@ -104,6 +108,7 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, 
unsigned long action,
 
writel(0, wdt_addr(wdt, WDT_EN));
writel(1, wdt_addr(wdt, WDT_RST));
+   writel(timeout, wdt_addr(wdt, WDT_BARK_TIME));
writel(timeout, wdt_addr(wdt, WDT_BITE_TIME));
writel(1, wdt_addr(wdt, WDT_EN));
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 05/17] clk: qcom: ipq4019: add some fixed clocks for ddrppl and fepll

2016-03-23 Thread Matthew McClintock
Drivers for these don't exist yet so we will add them as fixed clocks
so we don't BUG() if we change clocks that reference these clocks.

Signed-off-by: Matthew McClintock 
---
 drivers/clk/qcom/gcc-ipq4019.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/qcom/gcc-ipq4019.c b/drivers/clk/qcom/gcc-ipq4019.c
index 38ada8d..f0b0a5a 100644
--- a/drivers/clk/qcom/gcc-ipq4019.c
+++ b/drivers/clk/qcom/gcc-ipq4019.c
@@ -1316,6 +1316,16 @@ MODULE_DEVICE_TABLE(of, gcc_ipq4019_match_table);
 
 static int gcc_ipq4019_probe(struct platform_device *pdev)
 {
+   struct device *dev = >dev;
+
+   clk_register_fixed_rate(dev, "fepll125", "xo", 0, 2);
+   clk_register_fixed_rate(dev, "fepll125dly", "xo", 0, 2);
+   clk_register_fixed_rate(dev, "fepllwcss2g", "xo", 0, 2);
+   clk_register_fixed_rate(dev, "fepllwcss5g", "xo", 0, 2);
+   clk_register_fixed_rate(dev, "fepll200", "xo", 0, 2);
+   clk_register_fixed_rate(dev, "fepll500", "xo", 0, 2);
+   clk_register_fixed_rate(dev, "ddrpllapss", "xo", 0, 66600);
+
return qcom_cc_probe(pdev, _ipq4019_desc);
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH 17/17] qcom: ipq4019: add DMA nodes to ipq4019 SoC and DK01 device tree

2016-03-23 Thread Matthew McClintock
This adds the blsp_dma node to the device tree and the required
properties for using DMA with serial

Signed-off-by: Matthew McClintock 
---
 arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi |  4 
 arch/arm/boot/dts/qcom-ipq4019.dtsi   | 15 +++
 2 files changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
index 2c347ad..b9457dd2 100644
--- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
@@ -72,6 +72,10 @@
};
};
 
+   blsp_dma: dma@7884000 {
+   status = "ok";
+   };
+
spi_0: spi@78b5000 {
pinctrl-0 = <_0_pins>;
pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi 
b/arch/arm/boot/dts/qcom-ipq4019.dtsi
index 3cd42c0..5c08d19 100644
--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
+++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
@@ -123,6 +123,17 @@
interrupts = <0 208 0>;
};
 
+   blsp_dma: dma@7884000 {
+   compatible = "qcom,bam-v1.7.0";
+   reg = <0x07884000 0x23000>;
+   interrupts = ;
+   clocks = < GCC_BLSP1_AHB_CLK>;
+   clock-names = "bam_clk";
+   #dma-cells = <1>;
+   qcom,ee = <0>;
+   status = "disabled";
+   };
+
spi_0: spi@78b5000 {
compatible = "qcom,spi-qup-v2.2.1";
reg = <0x78b5000 0x600>;
@@ -224,6 +235,8 @@
clocks = < GCC_BLSP1_UART1_APPS_CLK>,
< GCC_BLSP1_AHB_CLK>;
clock-names = "core", "iface";
+   dmas = <_dma 1>, <_dma 0>;
+   dma-names = "rx", "tx";
};
 
serial@78b {
@@ -234,6 +247,8 @@
clocks = < GCC_BLSP1_UART2_APPS_CLK>,
< GCC_BLSP1_AHB_CLK>;
clock-names = "core", "iface";
+   dmas = <_dma 3>, <_dma 2>;
+   dma-names = "rx", "tx";
};
 
watchdog@b017000 {
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



<    1   2   3   4   5   6   7   8   9   10   >