[tip:perf/core] perf bpf: Rename bpf config to program config

2015-11-28 Thread tip-bot for Wang Nan
Commit-ID:  0bb93490170477224f8bd4cc9ce8920517461643
Gitweb: http://git.kernel.org/tip/0bb93490170477224f8bd4cc9ce8920517461643
Author: Wang Nan 
AuthorDate: Fri, 27 Nov 2015 08:47:37 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 22:00:46 -0300

perf bpf: Rename bpf config to program config

Following patches are going to introduce BPF object level configuration
to enable setting values into BPF maps. To avoid confusion, this patch
renames existing 'config' in bpf-loader.c to 'program config'. Following
patches would introduce 'object config'.

Signed-off-by: Wang Nan 
Cc: Alexei Starovoitov 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1448614067-197576-4-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/bpf-loader.c | 65 ++--
 tools/perf/util/bpf-loader.h |  2 +-
 2 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 36544e5..540a7ef 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -120,7 +120,7 @@ bpf_prog_priv__clear(struct bpf_program *prog 
__maybe_unused,
 }
 
 static int
-config__exec(const char *value, struct perf_probe_event *pev)
+prog_config__exec(const char *value, struct perf_probe_event *pev)
 {
pev->uprobes = true;
pev->target = strdup(value);
@@ -130,7 +130,7 @@ config__exec(const char *value, struct perf_probe_event 
*pev)
 }
 
 static int
-config__module(const char *value, struct perf_probe_event *pev)
+prog_config__module(const char *value, struct perf_probe_event *pev)
 {
pev->uprobes = false;
pev->target = strdup(value);
@@ -140,8 +140,7 @@ config__module(const char *value, struct perf_probe_event 
*pev)
 }
 
 static int
-config__bool(const char *value,
-bool *pbool, bool invert)
+prog_config__bool(const char *value, bool *pbool, bool invert)
 {
int err;
bool bool_value;
@@ -158,17 +157,17 @@ config__bool(const char *value,
 }
 
 static int
-config__inlines(const char *value,
-   struct perf_probe_event *pev __maybe_unused)
+prog_config__inlines(const char *value,
+struct perf_probe_event *pev __maybe_unused)
 {
-   return config__bool(value, _conf.no_inlines, true);
+   return prog_config__bool(value, _conf.no_inlines, true);
 }
 
 static int
-config__force(const char *value,
- struct perf_probe_event *pev __maybe_unused)
+prog_config__force(const char *value,
+  struct perf_probe_event *pev __maybe_unused)
 {
-   return config__bool(value, _conf.force_add, false);
+   return prog_config__bool(value, _conf.force_add, false);
 }
 
 static struct {
@@ -176,58 +175,58 @@ static struct {
const char *usage;
const char *desc;
int (*func)(const char *, struct perf_probe_event *);
-} bpf_config_terms[] = {
+} bpf_prog_config_terms[] = {
{
.key= "exec",
.usage  = "exec=",
.desc   = "Set uprobe target",
-   .func   = config__exec,
+   .func   = prog_config__exec,
},
{
.key= "module",
.usage  = "module=",
.desc   = "Set kprobe module",
-   .func   = config__module,
+   .func   = prog_config__module,
},
{
.key= "inlines",
.usage  = "inlines=[yes|no]",
.desc   = "Probe at inline symbol",
-   .func   = config__inlines,
+   .func   = prog_config__inlines,
},
{
.key= "force",
.usage  = "force=[yes|no]  ",
.desc   = "Forcibly add events with existing name",
-   .func   = config__force,
+   .func   = prog_config__force,
},
 };
 
 static int
-do_config(const char *key, const char *value,
- struct perf_probe_event *pev)
+do_prog_config(const char *key, const char *value,
+  struct perf_probe_event *pev)
 {
unsigned int i;
 
pr_debug("config bpf program: %s=%s\n", key, value);
-   for (i = 0; i < ARRAY_SIZE(bpf_config_terms); i++)
-   if (strcmp(key, bpf_config_terms[i].key) == 0)
-   return bpf_config_terms[i].func(value, pev);
+   for (i = 0; i < ARRAY_SIZE(bpf_prog_config_terms); i++)
+   if (strcmp(key, bpf_prog_config_terms[i].key) == 0)
+   return bpf_prog_config_terms[i].func(value, pev);
 
-   pr_debug("BPF: ERROR: invalid config option in object: %s=%s\n",
+   pr_debug("BPF: ERROR: invalid program config option: %s=%s\n",
 key, value);
 
-   pr_debug("\nHint: Currently valid options are:\n");
-   for (i = 0; i < 

[tip:perf/core] tools lib bpf: Extract and collect map names from BPF object file

2015-11-28 Thread tip-bot for Wang Nan
Commit-ID:  561bbccac72d08babafaa33fd7fa9100ec4c9fb6
Gitweb: http://git.kernel.org/tip/561bbccac72d08babafaa33fd7fa9100ec4c9fb6
Author: Wang Nan 
AuthorDate: Fri, 27 Nov 2015 08:47:36 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 21:59:53 -0300

tools lib bpf: Extract and collect map names from BPF object file

This patch collects name of maps in BPF object files and saves them into
'maps' field in 'struct bpf_object'. 'bpf_object__get_map_by_name' is
introduced to retrive fd and definitions of a map through its name.

Signed-off-by: He Kuang 
Cc: Alexei Starovoitov 
Cc: He Kuang 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1448614067-197576-3-git-send-email-wangn...@huawei.com
Signed-off-by: Wang Nan 
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/bpf/libbpf.c | 65 +++---
 tools/lib/bpf/libbpf.h |  3 +++
 2 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index f509825..a298614 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -165,6 +165,7 @@ struct bpf_program {
 
 struct bpf_map {
int fd;
+   char *name;
struct bpf_map_def def;
void *priv;
bpf_map_clear_priv_t clear_priv;
@@ -526,12 +527,46 @@ bpf_object__init_maps(struct bpf_object *obj, void *data,
return 0;
 }
 
+static void
+bpf_object__init_maps_name(struct bpf_object *obj, int maps_shndx)
+{
+   int i;
+   Elf_Data *symbols = obj->efile.symbols;
+
+   if (!symbols || maps_shndx < 0)
+   return;
+
+   for (i = 0; i < symbols->d_size / sizeof(GElf_Sym); i++) {
+   GElf_Sym sym;
+   size_t map_idx;
+   const char *map_name;
+
+   if (!gelf_getsym(symbols, i, ))
+   continue;
+   if (sym.st_shndx != maps_shndx)
+   continue;
+
+   map_name = elf_strptr(obj->efile.elf,
+ obj->efile.ehdr.e_shstrndx,
+ sym.st_name);
+   map_idx = sym.st_value / sizeof(struct bpf_map_def);
+   if (map_idx >= obj->nr_maps) {
+   pr_warning("index of map \"%s\" is buggy: %zu > %zu\n",
+  map_name, map_idx, obj->nr_maps);
+   continue;
+   }
+   obj->maps[map_idx].name = strdup(map_name);
+   pr_debug("map %zu is \"%s\"\n", map_idx,
+obj->maps[map_idx].name);
+   }
+}
+
 static int bpf_object__elf_collect(struct bpf_object *obj)
 {
Elf *elf = obj->efile.elf;
GElf_Ehdr *ep = >efile.ehdr;
Elf_Scn *scn = NULL;
-   int idx = 0, err = 0;
+   int idx = 0, err = 0, maps_shndx = -1;
 
/* Elf is corrupted/truncated, avoid calling elf_strptr. */
if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL)) {
@@ -581,10 +616,11 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
err = bpf_object__init_kversion(obj,
data->d_buf,
data->d_size);
-   else if (strcmp(name, "maps") == 0)
+   else if (strcmp(name, "maps") == 0) {
err = bpf_object__init_maps(obj, data->d_buf,
data->d_size);
-   else if (sh.sh_type == SHT_SYMTAB) {
+   maps_shndx = idx;
+   } else if (sh.sh_type == SHT_SYMTAB) {
if (obj->efile.symbols) {
pr_warning("bpf: multiple SYMTAB in %s\n",
   obj->path);
@@ -625,6 +661,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
if (err)
goto out;
}
+
+   if (maps_shndx >= 0)
+   bpf_object__init_maps_name(obj, maps_shndx);
 out:
return err;
 }
@@ -1086,6 +1125,7 @@ void bpf_object__close(struct bpf_object *obj)
bpf_object__unload(obj);
 
for (i = 0; i < obj->nr_maps; i++) {
+   zfree(>maps[i].name);
if (obj->maps[i].clear_priv)
obj->maps[i].clear_priv(>maps[i],
obj->maps[i].priv);
@@ -1266,6 +1306,13 @@ int bpf_map__get_def(struct bpf_map *map, struct 
bpf_map_def *pdef)
return 0;
 }
 
+const char *bpf_map__get_name(struct bpf_map *map)
+{
+   if (!map)
+   return NULL;
+   return map->name;
+}
+
 int bpf_map__set_private(struct bpf_map *map, void *priv,
 bpf_map_clear_priv_t clear_priv)
 {
@@ -1318,3 +1365,15 @@ bpf_map__next(struct bpf_map *prev, struct bpf_object 
*obj)
   

[tip:perf/core] tools lib bpf: Collect map definition in bpf_object

2015-11-28 Thread tip-bot for Wang Nan
Commit-ID:  9d759a9b4ac2690077d8b21258e6e95c3e34bfa9
Gitweb: http://git.kernel.org/tip/9d759a9b4ac2690077d8b21258e6e95c3e34bfa9
Author: Wang Nan 
AuthorDate: Fri, 27 Nov 2015 08:47:35 +
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 21:57:09 -0300

tools lib bpf: Collect map definition in bpf_object

This patch collects more information from maps sections in BPF object
files into 'struct bpf_object', enables later patches access those
information (such as the type and size of the map).

In this patch, a new handler 'struct bpf_map' is extracted in parallel
with bpf_object and bpf_program. Its iterator and accessor is also
created.

Signed-off-by: Wang Nan 
Cc: Alexei Starovoitov 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Cc: Zefan Li 
Cc: pi3or...@163.com
Link: 
http://lkml.kernel.org/r/1448614067-197576-2-git-send-email-wangn...@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/bpf/libbpf.c | 187 +
 tools/lib/bpf/libbpf.h |  21 ++
 2 files changed, 148 insertions(+), 60 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index e3f4c33..f509825 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -163,22 +163,24 @@ struct bpf_program {
bpf_program_clear_priv_t clear_priv;
 };
 
+struct bpf_map {
+   int fd;
+   struct bpf_map_def def;
+   void *priv;
+   bpf_map_clear_priv_t clear_priv;
+};
+
 static LIST_HEAD(bpf_objects_list);
 
 struct bpf_object {
char license[64];
u32 kern_version;
-   void *maps_buf;
-   size_t maps_buf_sz;
 
struct bpf_program *programs;
size_t nr_programs;
-   int *map_fds;
-   /*
-* This field is required because maps_buf will be freed and
-* maps_buf_sz will be set to 0 after loaded.
-*/
-   size_t nr_map_fds;
+   struct bpf_map *maps;
+   size_t nr_maps;
+
bool loaded;
 
/*
@@ -489,21 +491,38 @@ static int
 bpf_object__init_maps(struct bpf_object *obj, void *data,
  size_t size)
 {
-   if (size == 0) {
+   size_t nr_maps;
+   int i;
+
+   nr_maps = size / sizeof(struct bpf_map_def);
+   if (!data || !nr_maps) {
pr_debug("%s doesn't need map definition\n",
 obj->path);
return 0;
}
 
-   obj->maps_buf = malloc(size);
-   if (!obj->maps_buf) {
-   pr_warning("malloc maps failed: %s\n", obj->path);
+   pr_debug("maps in %s: %zd bytes\n", obj->path, size);
+
+   obj->maps = calloc(nr_maps, sizeof(obj->maps[0]));
+   if (!obj->maps) {
+   pr_warning("alloc maps for object failed\n");
return -ENOMEM;
}
+   obj->nr_maps = nr_maps;
+
+   for (i = 0; i < nr_maps; i++) {
+   struct bpf_map_def *def = >maps[i].def;
 
-   obj->maps_buf_sz = size;
-   memcpy(obj->maps_buf, data, size);
-   pr_debug("maps in %s: %ld bytes\n", obj->path, (long)size);
+   /*
+* fill all fd with -1 so won't close incorrect
+* fd (fd=0 is stdin) when failure (zclose won't close
+* negative fd)).
+*/
+   obj->maps[i].fd = -1;
+
+   /* Save map definition into obj->maps */
+   *def = ((struct bpf_map_def *)data)[i];
+   }
return 0;
 }
 
@@ -688,37 +707,15 @@ static int
 bpf_object__create_maps(struct bpf_object *obj)
 {
unsigned int i;
-   size_t nr_maps;
-   int *pfd;
-
-   nr_maps = obj->maps_buf_sz / sizeof(struct bpf_map_def);
-   if (!obj->maps_buf || !nr_maps) {
-   pr_debug("don't need create maps for %s\n",
-obj->path);
-   return 0;
-   }
 
-   obj->map_fds = malloc(sizeof(int) * nr_maps);
-   if (!obj->map_fds) {
-   pr_warning("realloc perf_bpf_map_fds failed\n");
-   return -ENOMEM;
-   }
-   obj->nr_map_fds = nr_maps;
-
-   /* fill all fd with -1 */
-   memset(obj->map_fds, -1, sizeof(int) * nr_maps);
+   for (i = 0; i < obj->nr_maps; i++) {
+   struct bpf_map_def *def = >maps[i].def;
+   int *pfd = >maps[i].fd;
 
-   pfd = obj->map_fds;
-   for (i = 0; i < nr_maps; i++) {
-   struct bpf_map_def def;
-
-   def = *(struct bpf_map_def *)(obj->maps_buf +
-   i * sizeof(struct bpf_map_def));
-
-   *pfd = bpf_create_map(def.type,
- def.key_size,
- def.value_size,
- def.max_entries);
+   *pfd = bpf_create_map(def->type,
+ def->key_size,
+ def->value_size,
+ def->max_entries);

[tip:perf/core] perf list: Robustify event printing routine

2015-11-28 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  e37df6c76cb19971f1228bfaff504d8a3ea6f748
Gitweb: http://git.kernel.org/tip/e37df6c76cb19971f1228bfaff504d8a3ea6f748
Author: Arnaldo Carvalho de Melo 
AuthorDate: Fri, 27 Nov 2015 16:04:58 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 16:04:58 -0300

perf list: Robustify event printing routine

When a43eec304259 ("bpf: introduce bpf_perf_event_output() helper") added
PERF_COUNT_SW_BPF_OUTPUT we ended up with a new entry in the event_symbols_sw
array that wasn't initialized, thus set to NULL, fix print_symbol_events()
to check for that case so that we don't crash if this happens again.

  (gdb) bt
  #0  __match_glob (ignore_space=false, pat=, str=) at util/string.c:198
  #1  strglobmatch (str=, pat=pat@entry=0x7fffe61d "stall") 
at util/string.c:252
  #2  0x004993a5 in print_symbol_events (type=1, syms=0x872880 
, max=11, name_only=false, event_glob=0x7fffe61d 
"stall")
  at util/parse-events.c:1615
  #3  print_events (event_glob=event_glob@entry=0x7fffe61d "stall", 
name_only=false) at util/parse-events.c:1675
  #4  0x0042c79e in cmd_list (argc=1, argv=0x7fffe390, 
prefix=) at builtin-list.c:68
  #5  0x004788a5 in run_builtin (p=p@entry=0x871758 , 
argc=argc@entry=2, argv=argv@entry=0x7fffe390) at perf.c:370
  #6  0x00420ab0 in handle_internal_command (argv=0x7fffe390, 
argc=2) at perf.c:429
  #7  run_argv (argv=0x7fffe110, argcp=0x7fffe11c) at perf.c:473
  #8  main (argc=2, argv=0x7fffe390) at perf.c:588
  (gdb) p event_symbols_sw[PERF_COUNT_SW_BPF_OUTPUT]
  $4 = {symbol = 0x0, alias = 0x0}
  (gdb)

A patch to robustify perf to not segfault when the next counter gets added in
the kernel will follow this one.

Reported-by: Ingo Molnar 
Cc: Adrian Hunter 
Cc: Alexei Starovoitov 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-57wysblcjfrseb0zg5u7e...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/parse-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 40ae92a..6fc8cd7 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1883,7 +1883,7 @@ restart:
 
for (i = 0; i < max; i++, syms++) {
 
-   if (event_glob != NULL &&
+   if (event_glob != NULL && syms->symbol != NULL &&
!(strglobmatch(syms->symbol, event_glob) ||
  (syms->alias && strglobmatch(syms->alias, event_glob
continue;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf hists: Do not skip elided fields when processing samples

2015-11-28 Thread tip-bot for Namhyung Kim
Commit-ID:  e72655d97d24fff559b4ab59de791c3741a74c8c
Gitweb: http://git.kernel.org/tip/e72655d97d24fff559b4ab59de791c3741a74c8c
Author: Namhyung Kim 
AuthorDate: Sat, 28 Nov 2015 02:32:38 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 21:42:13 -0300

perf hists: Do not skip elided fields when processing samples

If user gives a filter, perf marks the corresponding column elided and
omits the output.  But it should process and aggregates samples using
the field, otherwise samples will be aggregated as if the column was not
there resulted in incorrect output.

For example, I'd like to set a filter on native_write_msr_safe.  The
original overhead of the function is negligible.

  $ perf report | grep native_write_msr_safe
  0.00%  swapper  [kernel.vmlinux]  native_write_msr_safe
  0.00%  perf [kernel.vmlinux]  native_write_msr_safe

However adding -S option gives different output.

  $ perf report -S native_write_msr_safe --percentage absolute | \
  > grep -e swapper -e perf
 51.47%  swapper  [kernel.vmlinux]
  4.14%  perf [kernel.vmlinux]

Since it aggregated samples using comm and dso only.  In fact, the above
values are same when it sorts with -s comm,dso.

  $ perf report -s comm,dso | grep -e swapper -e perf
 51.47%  swapper  [kernel.vmlinux]
  4.14%  perf [kernel.vmlinux]

This resulted in TUI failure with -ERANGE since it tries to increase
sample hit count for annotation with wrong symbols due to incorrect
aggregation.

This patch fixes it not to skip elided fields when comparing samples in
order to insert them to the hists.

Commiter note:

After the patch, with a different workloads:

  # perf report --show-total-period -S native_write_msr_safe --stdio
  #
  # symbol: native_write_msr_safe
  #
  # Samples: 455  of event 'cycles:pp'
  # Event count (approx.): 134787489
  #
  # Overhead Period Command Shared Object
  #  .. ... 
  #
   0.22% 293081 qemu-system-x86 [vmlinux]
   0.19% 255914 swapper [vmlinux]
   0.00%   2054 Timer   [vmlinux]
   0.00%   1021 firefox [vmlinux]
   0.00%  2 perf[vmlinux]

  # perf report --show-total-period | grep native_write_msr_safe
  Failed to open /tmp/perf-14838.map, continuing without symbols
   0.22% 293081 qemu-system-x86 [vmlinux]  [k] native_write_msr_safe
   0.19% 255914 swapper [vmlinux]  [k] native_write_msr_safe
   0.00%   2054 Timer   [vmlinux]  [k] native_write_msr_safe
   0.00%   1021 firefox [vmlinux]  [k] native_write_msr_safe
   0.00%  2 perf[vmlinux]  [k] native_write_msr_safe
  #

Reported-by: Ingo Molnar 
Signed-off-by: Namhyung Kim 
Tested-by: Arnaldo Carvalho de Melo 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1448645559-31167-2-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/hist.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 4fd37d6..6e8e0ee 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -924,9 +924,6 @@ hist_entry__cmp(struct hist_entry *left, struct hist_entry 
*right)
int64_t cmp = 0;
 
perf_hpp__for_each_sort_list(fmt) {
-   if (perf_hpp__should_skip(fmt))
-   continue;
-
cmp = fmt->cmp(fmt, left, right);
if (cmp)
break;
@@ -942,9 +939,6 @@ hist_entry__collapse(struct hist_entry *left, struct 
hist_entry *right)
int64_t cmp = 0;
 
perf_hpp__for_each_sort_list(fmt) {
-   if (perf_hpp__should_skip(fmt))
-   continue;
-
cmp = fmt->collapse(fmt, left, right);
if (cmp)
break;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf hists browser: Update nr entries regardless of min percent

2015-11-28 Thread tip-bot for Namhyung Kim
Commit-ID:  039050482573e168690d365b8ea1d4f599ebbbd8
Gitweb: http://git.kernel.org/tip/039050482573e168690d365b8ea1d4f599ebbbd8
Author: Namhyung Kim 
AuthorDate: Sat, 28 Nov 2015 02:32:39 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 21:53:33 -0300

perf hists browser: Update nr entries regardless of min percent

When perf report on TUI was called with -S symbol filter, it should
update nr entries even if min_pcnt is 0.  IIRC the reason was to update
nr entries after applying minimum percent threshold.  But if symbol
filter was given on command line (with -S option), it should use
hists->nr_non_filtered_entries instead of hists->nr_entries.

So this patch fixes a bug of navigating hists browser that the cursor
goes beyond the number of entries when -S (or similar) option is used.

Signed-off-by: Namhyung Kim 
Tested-by: Arnaldo Carvalho de Melo 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1448645559-31167-3-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/ui/browsers/hists.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a211b7b..dcdcbaf 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2055,10 +2055,9 @@ static int perf_evsel__hists_browse(struct perf_evsel 
*evsel, int nr_events,
SLang_reset_tty();
SLang_init_tty(0, 0, 0);
 
-   if (min_pcnt) {
+   if (min_pcnt)
browser->min_pcnt = min_pcnt;
-   hist_browser__update_nr_entries(browser);
-   }
+   hist_browser__update_nr_entries(browser);
 
browser->pstack = pstack__new(3);
if (browser->pstack == NULL)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf report: Show error message when processing sample fails

2015-11-28 Thread tip-bot for Namhyung Kim
Commit-ID:  25b1606be1a910a63a23c3d1006581c9aad4e6e3
Gitweb: http://git.kernel.org/tip/25b1606be1a910a63a23c3d1006581c9aad4e6e3
Author: Namhyung Kim 
AuthorDate: Sat, 28 Nov 2015 02:32:37 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 16:56:32 -0300

perf report: Show error message when processing sample fails

Currently when perf fails to process samples for some reason, it doesn't
show any message about the failure.  This is very inconvenient for users
especially on TUI as screen is reset after the failure.

Reported-by: Ingo Molnar 
Signed-off-by: Namhyung Kim 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/1448645559-31167-1-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-report.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 8a9c690..af5db88 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -513,20 +513,26 @@ static int __cmd_report(struct report *rep)
if (rep->cpu_list) {
ret = perf_session__cpu_bitmap(session, rep->cpu_list,
   rep->cpu_bitmap);
-   if (ret)
+   if (ret) {
+   ui__error("failed to set cpu bitmap\n");
return ret;
+   }
}
 
if (rep->show_threads)
perf_read_values_init(>show_threads_values);
 
ret = report__setup_sample_type(rep);
-   if (ret)
+   if (ret) {
+   /* report__setup_sample_type() already showed error message */
return ret;
+   }
 
ret = perf_session__process_events(session);
-   if (ret)
+   if (ret) {
+   ui__error("failed to process sample\n");
return ret;
+   }
 
report__warn_kptr_restrict(rep);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf test: 'unwind' test should create kernel maps

2015-11-28 Thread tip-bot for Jiri Olsa
Commit-ID:  9bdcede563a831f139b5fc872f028ef844a7462e
Gitweb: http://git.kernel.org/tip/9bdcede563a831f139b5fc872f028ef844a7462e
Author: Jiri Olsa 
AuthorDate: Fri, 27 Nov 2015 09:21:21 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 13:14:26 -0300

perf test: 'unwind' test should create kernel maps

The 'perf test unwind' is failing because it forgot to create the kernel
maps, fix it.

After the patch:

  # perf test unwind
  40: Test dwarf unwind : Ok

Reported-and-Tested-by: Arnaldo Carvalho de Melo 
Signed-off-by: Jiri Olsa 
Cc: David Ahern 
Cc: Masami Hiramatsu 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/r/20151127082121.ga24...@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/dwarf-unwind.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index b2357e8..3cce13b1 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -173,6 +173,11 @@ int test__dwarf_unwind(int subtest __maybe_unused)
return -1;
}
 
+   if (machine__create_kernel_maps(machine)) {
+   pr_err("Failed to create kernel maps\n");
+   return -1;
+   }
+
callchain_param.record_mode = CALLCHAIN_DWARF;
 
if (init_live_machine(machine)) {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[tip:perf/core] perf list: Add support for PERF_COUNT_SW_BPF_OUT

2015-11-28 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  bae9cc41105b9edd74d68a9636be2ba240e74b9e
Gitweb: http://git.kernel.org/tip/bae9cc41105b9edd74d68a9636be2ba240e74b9e
Author: Arnaldo Carvalho de Melo 
AuthorDate: Fri, 27 Nov 2015 15:54:33 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Fri, 27 Nov 2015 16:03:46 -0300

perf list: Add support for PERF_COUNT_SW_BPF_OUT

When PERF_COUNT_SW_BPF_OUTPUT was added to the kernel we should've
added it to tools/perf, where it is used just to list events.

This ended up causing a segfault in commands like "perf list stall".

Fix it by adding that new software counter.

A patch to robustify perf to not segfault when the next counter gets
added in the kernel will follow this one.

Reported-by: Ingo Molnar 
Cc: Adrian Hunter 
Cc: Alexei Starovoitov 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-uya354upi3eprsey6mi59...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/parse-events.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index e48d9da..40ae92a 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -124,6 +124,10 @@ struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = {
.symbol = "dummy",
.alias  = "",
},
+   [PERF_COUNT_SW_BPF_OUTPUT] = {
+   .symbol = "bpf-output",
+   .alias  = "",
+   },
 };
 
 #define __PERF_EVENT_FIELD(config, name) \
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] regulator: lm363x: Staticise ldo_cont_enable_time

2015-11-28 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/lm363x-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/lm363x-regulator.c 
b/drivers/regulator/lm363x-regulator.c
index 3858735..f53e633 100644
--- a/drivers/regulator/lm363x-regulator.c
+++ b/drivers/regulator/lm363x-regulator.c
@@ -41,7 +41,7 @@
 #define LM363X_STEP_50mV   5
 #define LM363X_STEP_500mV  50
 
-const int ldo_cont_enable_time[] = {
+static const int ldo_cont_enable_time[] = {
0, 2000, 5000, 1, 2, 5, 10, 20,
 };
 
-- 
2.1.4



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] regulator: lm363x: Remove struct lm363x_regulator which is not necessary

2015-11-28 Thread Axel Lin
Signed-off-by: Axel Lin 
---
 drivers/regulator/lm363x-regulator.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/regulator/lm363x-regulator.c 
b/drivers/regulator/lm363x-regulator.c
index e1b683e..3858735 100644
--- a/drivers/regulator/lm363x-regulator.c
+++ b/drivers/regulator/lm363x-regulator.c
@@ -41,18 +41,12 @@
 #define LM363X_STEP_50mV   5
 #define LM363X_STEP_500mV  50
 
-struct lm363x_regulator {
-   struct regmap *regmap;
-   struct regulator_dev *regulator;
-};
-
 const int ldo_cont_enable_time[] = {
0, 2000, 5000, 1, 2, 5, 10, 20,
 };
 
 static int lm363x_regulator_enable_time(struct regulator_dev *rdev)
 {
-   struct lm363x_regulator *lm363x_regulator = rdev_get_drvdata(rdev);
enum lm363x_regulator_id id = rdev_get_id(rdev);
u8 val, addr, mask;
 
@@ -77,7 +71,7 @@ static int lm363x_regulator_enable_time(struct regulator_dev 
*rdev)
return 0;
}
 
-   if (regmap_read(lm363x_regulator->regmap, addr, (unsigned int *)))
+   if (regmap_read(rdev->regmap, addr, (unsigned int *)))
return -EINVAL;
 
val = (val & mask) >> LM3631_ENTIME_SHIFT;
@@ -244,7 +238,6 @@ static int lm363x_regulator_of_get_enable_gpio(struct 
device_node *np, int id)
 static int lm363x_regulator_probe(struct platform_device *pdev)
 {
struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent);
-   struct lm363x_regulator *lm363x_regulator;
struct regmap *regmap = lmu->regmap;
struct regulator_config cfg = { };
struct regulator_dev *rdev;
@@ -252,15 +245,7 @@ static int lm363x_regulator_probe(struct platform_device 
*pdev)
int id = pdev->id;
int ret, ena_gpio;
 
-   lm363x_regulator = devm_kzalloc(dev, sizeof(*lm363x_regulator),
-   GFP_KERNEL);
-   if (!lm363x_regulator)
-   return -ENOMEM;
-
-   lm363x_regulator->regmap = regmap;
-
cfg.dev = dev;
-   cfg.driver_data = lm363x_regulator;
cfg.regmap = regmap;
 
/*
@@ -288,9 +273,6 @@ static int lm363x_regulator_probe(struct platform_device 
*pdev)
return ret;
}
 
-   lm363x_regulator->regulator = rdev;
-   platform_set_drvdata(pdev, lm363x_regulator);
-
return 0;
 }
 
-- 
2.1.4



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: RCU stall and the system boot hang

2015-11-28 Thread Paul E. McKenney
On Sun, Nov 29, 2015 at 12:46:10PM +0800, fupan li wrote:
> 2015-11-28 22:53 GMT+08:00 Paul E. McKenney :
> 
> > On Sat, Nov 28, 2015 at 01:05:52PM +0800, fupan li wrote:
> > > 2015-11-28 0:28 GMT+08:00 Paul E. McKenney :
> > >
> > > > On Fri, Nov 27, 2015 at 08:23:24PM +0800, fupan li wrote:
> > > > > Hi, Paul
> > > > >
> > > > > On my Wildcat_Pass (Haswell) board, the system boot will hang as
> > below.
> > > > > The kernel is preempt-rt kernel.
> > > > > But it was not reproduced every time, about 1 time per 5-10 boots.
> > > >
> > > > CCing LMKL and linux-rt-users in case anyone else is seeing this.
> > > >
> > > > OK, let's take a look at the stall warning...
> > > >
> > > > [ . . . ]
> > > >
> > > > > Btrfs loaded
> > > > > console [netcon0] enabled
> > > > > netconsole: network logging started
> > > > > rtc_cmos 00:00: setting system clock to 2015-11-11 18:18:03 UTC
> > > > (1447265883)
> > > > > usb 1-9: new full-speed USB device number 3 using xhci_hcd
> > > > > IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
> > > > > IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
> > > > > usb 1-9: ep 0x81 - rounding interval to 64 microframes, ep desc says
> > 80
> > > > > microframes
> > > > > input: American Megatrends Inc. Virtual Keyboard and Mouse as
> > > > >
> > > >
> > /devices/pci:00/:00:14.0/usb1/1-9/1-9:1.0/0003:046B:FF10.0002/input/input3
> > > > > hid-generic 0003:046B:FF10.0002: input: USB HID v1.10 Keyboard
> > [American
> > > > > Megatrends Inc. Virtual Keyboard and Mouse] on
> > usb-:00:14.0-9/input0
> > > > > input: American Megatrends Inc. Virtual Keyboard and Mouse as
> > > > >
> > > >
> > /devices/pci:00/:00:14.0/usb1/1-9/1-9:1.1/0003:046B:FF10.0003/input/input4
> > > > > hid-generic 0003:046B:FF10.0003: input: USB HID v1.10 Mouse [American
> > > > > Megatrends Inc. Virtual Keyboard and Mouse] on
> > usb-:00:14.0-9/input1
> > > > > ixgbe :02:00.0: registered PHC device on eth2
> > > > > IPv6: ADDRCONF(NETDEV_UP): eth2: link is not ready
> > > > > ixgbe :02:00.1: registered PHC device on eth3
> > > > > IPv6: ADDRCONF(NETDEV_UP): eth3: link is not ready
> > > > > igb :04:00.0 eth0: igb: eth0 NIC Link is Up 100 Mbps Full Duplex,
> > > > Flow
> > > > > Control: RX/TX
> > > > > IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> > > > > cfg80211: Calling CRDA to update world regulatory domain
> > > > > Sending DHCP requests ., OK
> > > > > random: nonblocking pool is initialized
> > > > > cfg80211: Calling CRDA to update world regulatory domain
> > > > > cfg80211: Calling CRDA to update world regulatory domain
> > > > > cfg80211: Calling CRDA to update world regulatory domain
> > > > > cfg80211: Calling CRDA to update world regulatory domain
> > > > > cfg80211: Calling CRDA to update world regulatory domain
> > > > > cfg80211: Calling CRDA to update world regulatory domain
> > > > > INFO: rcu_preempt detected stalls on CPUs/tasks:
> > > > > 12: (0 ticks this GP) idle=f48/0/0 softirq=0/0 fqs=0
> > > > > 17: (59 GPs behind) idle=55a/0/0 softirq=0/0 fqs=0
> > > >
> > > > So CPUs 12 and 17 are stalling the grace period.
> > > >
> > > > > (detected by 5, t=21002 jiffies, g=-237, c=-238, q=136)
> > > > > Task dump for CPU 12:
> > > > > swapper/12  R  running task0 0  1 0x0020
> > > > >  8140f1f7 880859037eb8 810b7ff5 880859037ea8
> > > > >  810759ef 82140220 000c 82140220
> > > > >  880859034000 880859037ea8 8140f1f7 880859037ec8
> > > > > Call Trace:
> > > > >  [] ? debug_smp_processor_id+0x17/0x20
> > > > >  [] ? rcu_eqs_enter_common+0x85/0x240
> > > > >  [] ? __atomic_notifier_call_chain+0x4f/0x70
> > > > >  [] ? debug_smp_processor_id+0x17/0x20
> > > > >  [] ? mwait_idle+0x42/0x1d0
> > > > >  [] ? arch_cpu_idle+0xf/0x20
> > > > >  [] ? cpu_startup_entry+0xae/0x300
> > > > >  [] ? start_secondary+0x12c/0x140
> > > >
> > > > But CPU 12 seems to be idle (as is in fact indicated by the
> > "idle=55a/0/0"
> > > > above), so the grace-period kthread should have reported a quiescent
> > > > state on its behalf.
> > > >
> > > > > Task dump for CPU 17:
> > > > > swapper/17  R  running task0 0  1 0x0020
> > > > >  8140f1f7 880859063eb8 810b7ff5 880859063ea8
> > > > >  810759ef 82140220 0011 82140220
> > > > >  88085906 880859063ea8 8140f1f7 880859063ec8
> > > > > Call Trace:
> > > > >  [] ? debug_smp_processor_id+0x17/0x20
> > > > >  [] ? rcu_eqs_enter_common+0x85/0x240
> > > > >  [] ? __atomic_notifier_call_chain+0x4f/0x70
> > > > >  [] ? debug_smp_processor_id+0x17/0x20
> > > > >  [] ? mwait_idle+0x42/0x1d0
> > > > >  [] ? arch_cpu_idle+0xf/0x20
> > > > >  [] ? cpu_startup_entry+0xae/0x300
> > > > >  [] ? start_secondary+0x12c/0x140
> > > >
> > > > And the same for CPU 17.
> > > >
> > > > > rcu_preempt kthread starved for 21002 jiffies!
> > > >
> > 

[GIT PULL] target fixes for v4.4-rc3

2015-11-28 Thread Nicholas A. Bellinger
Hi Linus,

Here are outstanding target-pending fixes queued for v4.4-rc3 code.

Please go ahead and pull from:

   git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master

This includes:

  - Fix tcm-user backend driver expired cmd time processing (agrover)
  - Elimination of kref_put_spinlock_irqsave() for I/O completion (bart)
  - Fix iscsi login kthread failure case hung task regression (nab)
  - Fix COMPARE_AND_WRITE completion use-after-free race (nab)
  - Fix COMPARE_AND_WRITE with SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC
non zero SGL offset data corruption.  (Jan + Doug)
  - Fix >= v4.4-rc1 regression for tcm_qla2xxx enable configfs attribute
(Himanshu + HCH)

Thank you,

--nab

Andy Grover (2):
  target/user: Fix time calc in expired cmd processing
  target/user: Do not set unused fields in tcmu_ops

Bart Van Assche (2):
  target: Invoke release_cmd() callback without holding a spinlock
  kref: Remove kref_put_spinlock_irqsave()

David Disseldorp (1):
  target/stat: print full t10_wwn.model buffer

Himanshu Madhani (1):
  qla2xxx: Fix regression introduced by target configFS changes

Jan Engelhardt (1):
  target: fix COMPARE_AND_WRITE non zero SGL offset data corruption

Luis de Bethencourt (1):
  iscsi-target: return -ENOMEM instead of -1 in case of failed kmalloc()

Nicholas Bellinger (2):
  iscsi-target: Fix rx_login_comp hang after login failure
  target: Fix race for SCF_COMPARE_AND_WRITE_POST checking

 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  2 +-
 drivers/target/iscsi/iscsi_target.c| 13 +-
 drivers/target/iscsi/iscsi_target_nego.c   |  1 +
 drivers/target/iscsi/iscsi_target_parameters.c | 10 
 drivers/target/target_core_sbc.c   | 17 -
 drivers/target/target_core_stat.c  |  2 +-
 drivers/target/target_core_tmr.c   |  7 +-
 drivers/target/target_core_transport.c | 26 ++--
 drivers/target/target_core_user.c  |  4 +---
 include/linux/kref.h   | 33 --
 include/target/target_core_base.h  |  2 +-
 11 files changed, 53 insertions(+), 64 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

2015-11-28 Thread Brent Taylor
Signed-off-by: Brent Taylor 

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree

ath6kl: fix kmalloc build error
---
Changes v2 -> v3:
   - fix kmalloc build error

Changes v1 -> v2:
   - simplify memory allocation
   - use kvfree

 drivers/net/wireless/ath/ath6kl/core.c | 2 +-
 drivers/net/wireless/ath/ath6kl/init.c | 7 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.c 
b/drivers/net/wireless/ath/ath6kl/core.c
index 4ec02ce..052e58b 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -343,7 +343,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)
 
kfree(ar->fw_board);
kfree(ar->fw_otp);
-   vfree(ar->fw);
+   kvfree(ar->fw);
kfree(ar->fw_patch);
kfree(ar->fw_testscript);
 
diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa..19535dc 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
*filename,
return ret;
 
*fw_len = fw_entry->size;
-   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
+   if (>fw == fw)
+   *fw = vmalloc(fw_entry->size);
+   else
+   *fw = kmalloc(fw_entry->size, GFP_KERNEL);
 
if (*fw == NULL)
ret = -ENOMEM;
+   else
+   memcpy(*fw, fw_entry->data, fw_entry->size);
 
release_firmware(fw_entry);
 
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

2015-11-28 Thread kbuild test robot
Hi Brent,

[auto build test ERROR on: net-next/master]
[also build test ERROR on: v4.4-rc2 next-20151127]

url:
https://github.com/0day-ci/linux/commits/Brent-Taylor/ath6kl-Use-vmalloc-for-loading-firmware-using-api1-method-and-use-kvfree/20151129-132013
config: x86_64-randconfig-x012-201548 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/net/wireless/ath/ath6kl/init.c: In function 'ath6kl_get_fw':
>> drivers/net/wireless/ath/ath6kl/init.c:679:9: error: too few arguments to 
>> function 'kmalloc'
  *fw = kmalloc(fw_entry->size);
^
   In file included from include/linux/textsearch.h:8:0,
from include/linux/skbuff.h:30,
from include/linux/if_ether.h:23,
from include/linux/etherdevice.h:25,
from drivers/net/wireless/ath/ath6kl/core.h:21,
from drivers/net/wireless/ath/ath6kl/init.c:28:
   include/linux/slab.h:428:30: note: declared here
static __always_inline void *kmalloc(size_t size, gfp_t flags)
 ^

vim +/kmalloc +679 drivers/net/wireless/ath/ath6kl/init.c

   673  return ret;
   674  
   675  *fw_len = fw_entry->size;
   676  if (>fw == fw)
   677  *fw = vmalloc(fw_entry->size);
   678  else
 > 679  *fw = kmalloc(fw_entry->size);
   680  
   681  if (*fw == NULL)
   682  ret = -ENOMEM;

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


.config.gz
Description: Binary data


[PATCH 3/6] Input: psmouse - rearrange Focaltech init code

2015-11-28 Thread Dmitry Torokhov
The fact that we were calling focaltech_init() even when Focaltech support
is disabled was confusing. Rearrange the code so that if support is
disabled we continue to fall through the rest of protocol probing code
until we get to full reset that Focaltech devices need to work properly.

Also, replace focaltech_init() with a stub now that it is only called when
protocol is enabled.

Signed-off-by: Dmitry Torokhov 
---

I know I originally requested doing reset in focaltech_init() even when
focaltech support is disabled, but as I was working with the code I found
it confusing.

 drivers/input/mouse/focaltech.c| 22 ++
 drivers/input/mouse/focaltech.h|  8 
 drivers/input/mouse/psmouse-base.c | 23 ---
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/drivers/input/mouse/focaltech.c b/drivers/input/mouse/focaltech.c
index 4d5576d..c8c6a8c 100644
--- a/drivers/input/mouse/focaltech.c
+++ b/drivers/input/mouse/focaltech.c
@@ -49,12 +49,6 @@ int focaltech_detect(struct psmouse *psmouse, bool 
set_properties)
return 0;
 }
 
-static void focaltech_reset(struct psmouse *psmouse)
-{
-   ps2_command(>ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
-   psmouse_reset(psmouse);
-}
-
 #ifdef CONFIG_MOUSE_PS2_FOCALTECH
 
 /*
@@ -300,6 +294,12 @@ static int focaltech_switch_protocol(struct psmouse 
*psmouse)
return 0;
 }
 
+static void focaltech_reset(struct psmouse *psmouse)
+{
+   ps2_command(>ps2dev, NULL, PSMOUSE_CMD_RESET_DIS);
+   psmouse_reset(psmouse);
+}
+
 static void focaltech_disconnect(struct psmouse *psmouse)
 {
focaltech_reset(psmouse);
@@ -456,14 +456,4 @@ fail:
kfree(priv);
return error;
 }
-
-#else /* CONFIG_MOUSE_PS2_FOCALTECH */
-
-int focaltech_init(struct psmouse *psmouse)
-{
-   focaltech_reset(psmouse);
-
-   return 0;
-}
-
 #endif /* CONFIG_MOUSE_PS2_FOCALTECH */
diff --git a/drivers/input/mouse/focaltech.h b/drivers/input/mouse/focaltech.h
index ca61ebf..783b28e 100644
--- a/drivers/input/mouse/focaltech.h
+++ b/drivers/input/mouse/focaltech.h
@@ -18,6 +18,14 @@
 #define _FOCALTECH_H
 
 int focaltech_detect(struct psmouse *psmouse, bool set_properties);
+
+#ifdef CONFIG_MOUSE_PS2_FOCALTECH
 int focaltech_init(struct psmouse *psmouse);
+#else
+static inline int focaltech_init(struct psmouse *psmouse)
+{
+   return -ENOSYS;
+}
+#endif
 
 #endif
diff --git a/drivers/input/mouse/psmouse-base.c 
b/drivers/input/mouse/psmouse-base.c
index 525de2e..c2bd866 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -750,19 +750,20 @@ static int psmouse_extensions(struct psmouse *psmouse,
 */
if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
if (max_proto > PSMOUSE_IMEX) {
-   if (!set_properties || focaltech_init(psmouse) == 0) {
-   if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH))
-   return PSMOUSE_FOCALTECH;
-   /*
-* Note that we need to also restrict
-* psmouse_max_proto so that 
psmouse_initialize()
-* does not try to reset rate and resolution,
-* because even that upsets the device.
-*/
-   psmouse_max_proto = PSMOUSE_PS2;
-   return PSMOUSE_PS2;
+   if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH) &&
+   (!set_properties || focaltech_init(psmouse) == 0)) {
+   return PSMOUSE_FOCALTECH;
}
}
+   /*
+* Restrict psmouse_max_proto so that psmouse_initialize()
+* does not try to reset rate and resolution, because even
+* that upsets the device.
+* This also causes us to basically fall through to basic
+* protocol detection, where we fully reset the mouse,
+* and set it up as bare PS/2 protocol device.
+*/
+   psmouse_max_proto = max_proto = PSMOUSE_PS2;
}
 
/*
-- 
2.6.0.rc2.230.g3dd15c0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] Input: psmouse - limit protocols that we try on passthrough ports

2015-11-28 Thread Dmitry Torokhov
PS/2 protocol is slow, and using it with pass-through port (where we
encapsulate PS/2 into PS/2) is slower yet so it takes quite a bit of time
to do full protocol discovery for device attached to a pass-through port.
However, so far we have not see anything but trackpoints or basic PS/2
mice on pass-through ports, so let's limit protocols that we probe there
to Trackpoint, IntelliMouse Explorer, IntelliMouse, and bare PS/2 protocol,
and avoid other extended protocols, such as Synaptics, ALPS, etc.

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/mouse/psmouse-base.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/input/mouse/psmouse-base.c 
b/drivers/input/mouse/psmouse-base.c
index ee59b0e..e909c6e 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -119,6 +119,7 @@ struct psmouse_protocol {
enum psmouse_type type;
bool maxproto;
bool ignore_parity; /* Protocol should ignore parity errors from KBC */
+   bool try_passthru; /* Try protocol also on passthrough ports */
const char *name;
const char *alias;
int (*detect)(struct psmouse *, bool);
@@ -691,6 +692,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
.maxproto   = true,
.ignore_parity  = true,
.detect = ps2bare_detect,
+   .try_passthru   = true,
},
 #ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
{
@@ -728,6 +730,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
.maxproto   = true,
.ignore_parity  = true,
.detect = intellimouse_detect,
+   .try_passthru   = true,
},
{
.type   = PSMOUSE_IMEX,
@@ -736,6 +739,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
.maxproto   = true,
.ignore_parity  = true,
.detect = im_explorer_detect,
+   .try_passthru   = true,
},
 #ifdef CONFIG_MOUSE_PS2_SYNAPTICS
{
@@ -777,6 +781,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
.name   = "TPPS/2",
.alias  = "trackpoint",
.detect = trackpoint_detect,
+   .try_passthru   = true,
},
 #endif
 #ifdef CONFIG_MOUSE_PS2_TOUCHKIT
@@ -933,6 +938,11 @@ static bool psmouse_try_protocol(struct psmouse *psmouse,
if (!proto)
return false;
 
+   if (psmouse->ps2dev.serio->id.type == SERIO_PS_PSTHRU &&
+   !proto->try_passthru) {
+   return false;
+   }
+
if (set_properties)
psmouse_apply_defaults(psmouse);
 
-- 
2.6.0.rc2.230.g3dd15c0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] Input: psmouse - factor out common protocol probing code

2015-11-28 Thread Dmitry Torokhov
In preparation of limiting protocols that we try on pass-through ports,
let's rework initialization code and factor common code into
psmouse_try_protocol() that accepts protocol type (instead of detec()
function pointer) and can, for most protocols, perform both detection and
initialization.

Note that this removes option of forcing Lifebook protocol on devices that
are not recognized by lifebook_detect() as having the hardware, but I do
not recall anyone using this option.

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/mouse/psmouse-base.c | 159 +++--
 1 file changed, 82 insertions(+), 77 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c 
b/drivers/input/mouse/psmouse-base.c
index b92c1bd..ee59b0e 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -767,6 +767,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
.type   = PSMOUSE_LIFEBOOK,
.name   = "LBPS/2",
.alias  = "lifebook",
+   .detect = lifebook_detect,
.init   = lifebook_init,
},
 #endif
@@ -844,7 +845,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
},
 };
 
-static const struct psmouse_protocol *psmouse_protocol_by_type(enum 
psmouse_type type)
+static const struct psmouse_protocol *__psmouse_protocol_by_type(enum 
psmouse_type type)
 {
int i;
 
@@ -852,6 +853,17 @@ static const struct psmouse_protocol 
*psmouse_protocol_by_type(enum psmouse_type
if (psmouse_protocols[i].type == type)
return _protocols[i];
 
+   return NULL;
+}
+
+static const struct psmouse_protocol *psmouse_protocol_by_type(enum 
psmouse_type type)
+{
+   const struct psmouse_protocol *proto;
+
+   proto = __psmouse_protocol_by_type(type);
+   if (proto)
+   return proto;
+
WARN_ON(1);
return _protocols[0];
 }
@@ -910,18 +922,37 @@ static void psmouse_apply_defaults(struct psmouse 
*psmouse)
psmouse->pt_deactivate = NULL;
 }
 
-/*
- * Apply default settings to the psmouse structure and call specified
- * protocol detection or initialization routine.
- */
-static int psmouse_do_detect(int (*detect)(struct psmouse *psmouse,
-  bool set_properties),
-struct psmouse *psmouse, bool set_properties)
+static bool psmouse_try_protocol(struct psmouse *psmouse,
+enum psmouse_type type,
+unsigned int *max_proto,
+bool set_properties, bool do_init)
 {
+   const struct psmouse_protocol *proto;
+
+   proto = __psmouse_protocol_by_type(type);
+   if (!proto)
+   return false;
+
if (set_properties)
psmouse_apply_defaults(psmouse);
 
-   return detect(psmouse, set_properties);
+   if (proto->detect(psmouse, set_properties) != 0)
+   return false;
+
+   if (set_properties && do_init && proto->init) {
+   if (proto->init(psmouse) != 0) {
+   /*
+* We detected device, but init failed. Adjust
+* max_proto so we only try standard protocols.
+*/
+   if (*max_proto > PSMOUSE_IMEX)
+   *max_proto = PSMOUSE_IMEX;
+
+   return false;
+   }
+   }
+
+   return true;
 }
 
 /*
@@ -937,7 +968,8 @@ static int psmouse_extensions(struct psmouse *psmouse,
 * Always check for focaltech, this is safe as it uses pnp-id
 * matching.
 */
-   if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
+   if (psmouse_try_protocol(psmouse, PSMOUSE_FOCALTECH,
+_proto, set_properties, false)) {
if (max_proto > PSMOUSE_IMEX) {
if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH) &&
(!set_properties || focaltech_init(psmouse) == 0)) {
@@ -959,26 +991,21 @@ static int psmouse_extensions(struct psmouse *psmouse,
 * We always check for LifeBook because it does not disturb mouse
 * (it only checks DMI information).
 */
-   if (psmouse_do_detect(lifebook_detect, psmouse, set_properties) == 0) {
-   if (max_proto > PSMOUSE_IMEX) {
-   if (!set_properties || lifebook_init(psmouse) == 0)
-   return PSMOUSE_LIFEBOOK;
-   }
-   }
+   if (psmouse_try_protocol(psmouse, PSMOUSE_LIFEBOOK, _proto,
+set_properties, max_proto > PSMOUSE_IMEX))
+   return PSMOUSE_LIFEBOOK;
 
-   if (psmouse_do_detect(vmmouse_detect, psmouse, set_properties) == 0) {
-   if (max_proto > 

[PATCH v2] ath6kl: Use vmalloc for loading firmware using api1 method and use kvfree

2015-11-28 Thread Brent Taylor
Signed-off-by: Brent Taylor 

ath6kl: Use vmalloc for loading firmware using api1 method and free using kvfree
---
Changes v1 -> v2:
   - simplify memory allocation
   - use kvfree

 drivers/net/wireless/ath/ath6kl/core.c | 2 +-
 drivers/net/wireless/ath/ath6kl/init.c | 7 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.c 
b/drivers/net/wireless/ath/ath6kl/core.c
index 4ec02ce..052e58b 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -343,7 +343,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)
 
kfree(ar->fw_board);
kfree(ar->fw_otp);
-   vfree(ar->fw);
+   kvfree(ar->fw);
kfree(ar->fw_patch);
kfree(ar->fw_testscript);
 
diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa..836afea2 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -673,10 +673,15 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
*filename,
return ret;
 
*fw_len = fw_entry->size;
-   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
+   if (>fw == fw)
+   *fw = vmalloc(fw_entry->size);
+   else
+   *fw = kmalloc(fw_entry->size);
 
if (*fw == NULL)
ret = -ENOMEM;
+   else
+   memcpy(*fw, fw_entry->data, fw_entry->size);
 
release_firmware(fw_entry);
 
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] Input: psmouse - move protocol descriptions around

2015-11-28 Thread Dmitry Torokhov
We move protocol descriptions and psmouse_find_by_type() and
pmouse_find_by_name() so that we can use them without forward declarations
in the subsequent patches.

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/mouse/psmouse-base.c | 379 ++---
 1 file changed, 189 insertions(+), 190 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c 
b/drivers/input/mouse/psmouse-base.c
index c2bd866..b92c1bd 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -683,6 +683,195 @@ static int cortron_detect(struct psmouse *psmouse, bool 
set_properties)
return 0;
 }
 
+static const struct psmouse_protocol psmouse_protocols[] = {
+   {
+   .type   = PSMOUSE_PS2,
+   .name   = "PS/2",
+   .alias  = "bare",
+   .maxproto   = true,
+   .ignore_parity  = true,
+   .detect = ps2bare_detect,
+   },
+#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
+   {
+   .type   = PSMOUSE_PS2PP,
+   .name   = "PS2++",
+   .alias  = "logitech",
+   .detect = ps2pp_init,
+   },
+#endif
+   {
+   .type   = PSMOUSE_THINKPS,
+   .name   = "ThinkPS/2",
+   .alias  = "thinkps",
+   .detect = thinking_detect,
+   },
+#ifdef CONFIG_MOUSE_PS2_CYPRESS
+   {
+   .type   = PSMOUSE_CYPRESS,
+   .name   = "CyPS/2",
+   .alias  = "cypress",
+   .detect = cypress_detect,
+   .init   = cypress_init,
+   },
+#endif
+   {
+   .type   = PSMOUSE_GENPS,
+   .name   = "GenPS/2",
+   .alias  = "genius",
+   .detect = genius_detect,
+   },
+   {
+   .type   = PSMOUSE_IMPS,
+   .name   = "ImPS/2",
+   .alias  = "imps",
+   .maxproto   = true,
+   .ignore_parity  = true,
+   .detect = intellimouse_detect,
+   },
+   {
+   .type   = PSMOUSE_IMEX,
+   .name   = "ImExPS/2",
+   .alias  = "exps",
+   .maxproto   = true,
+   .ignore_parity  = true,
+   .detect = im_explorer_detect,
+   },
+#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
+   {
+   .type   = PSMOUSE_SYNAPTICS,
+   .name   = "SynPS/2",
+   .alias  = "synaptics",
+   .detect = synaptics_detect,
+   .init   = synaptics_init,
+   },
+   {
+   .type   = PSMOUSE_SYNAPTICS_RELATIVE,
+   .name   = "SynRelPS/2",
+   .alias  = "synaptics-relative",
+   .detect = synaptics_detect,
+   .init   = synaptics_init_relative,
+   },
+#endif
+#ifdef CONFIG_MOUSE_PS2_ALPS
+   {
+   .type   = PSMOUSE_ALPS,
+   .name   = "AlpsPS/2",
+   .alias  = "alps",
+   .detect = alps_detect,
+   .init   = alps_init,
+   },
+#endif
+#ifdef CONFIG_MOUSE_PS2_LIFEBOOK
+   {
+   .type   = PSMOUSE_LIFEBOOK,
+   .name   = "LBPS/2",
+   .alias  = "lifebook",
+   .init   = lifebook_init,
+   },
+#endif
+#ifdef CONFIG_MOUSE_PS2_TRACKPOINT
+   {
+   .type   = PSMOUSE_TRACKPOINT,
+   .name   = "TPPS/2",
+   .alias  = "trackpoint",
+   .detect = trackpoint_detect,
+   },
+#endif
+#ifdef CONFIG_MOUSE_PS2_TOUCHKIT
+   {
+   .type   = PSMOUSE_TOUCHKIT_PS2,
+   .name   = "touchkitPS/2",
+   .alias  = "touchkit",
+   .detect = touchkit_ps2_detect,
+   },
+#endif
+#ifdef CONFIG_MOUSE_PS2_OLPC
+   {
+   .type   = PSMOUSE_HGPK,
+   .name   = "OLPC HGPK",
+   .alias  = "hgpk",
+   .detect = hgpk_detect,
+   },
+#endif
+#ifdef CONFIG_MOUSE_PS2_ELANTECH
+   {
+   .type   = PSMOUSE_ELANTECH,
+   .name   = "ETPS/2",
+   .alias  = "elantech",
+   .detect = elantech_detect,
+   .init   = elantech_init,
+   },
+#endif
+#ifdef CONFIG_MOUSE_PS2_SENTELIC
+   {
+   .type   = PSMOUSE_FSP,
+   .name   = "FSPPS/2",
+   .alias  = "fsp",
+   .detect = 

[PATCH 2/6] Input: psmouse - fix comment style

2015-11-28 Thread Dmitry Torokhov
The module was using non-standard comment style with comment blocks often
starting at the very beginning of a line instead of being aligned with the
code. Let's switch to standard formatting.

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/mouse/psmouse-base.c | 279 +
 1 file changed, 124 insertions(+), 155 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c 
b/drivers/input/mouse/psmouse-base.c
index 4e43e7e..525de2e 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -129,7 +129,6 @@ struct psmouse_protocol {
  * psmouse_process_byte() analyzes the PS/2 data stream and reports
  * relevant events to the input module once full packet has arrived.
  */
-
 psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
 {
struct input_dev *dev = psmouse->dev;
@@ -219,7 +218,6 @@ void psmouse_queue_work(struct psmouse *psmouse, struct 
delayed_work *work,
 /*
  * __psmouse_set_state() sets new psmouse state and resets all flags.
  */
-
 static inline void __psmouse_set_state(struct psmouse *psmouse, enum 
psmouse_state new_state)
 {
psmouse->state = new_state;
@@ -228,13 +226,11 @@ static inline void __psmouse_set_state(struct psmouse 
*psmouse, enum psmouse_sta
psmouse->last = jiffies;
 }
 
-
 /*
  * psmouse_set_state() sets new psmouse state and resets all flags and
  * counters while holding serio lock so fighting with interrupt handler
  * is not a concern.
  */
-
 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state)
 {
serio_pause_rx(psmouse->ps2dev.serio);
@@ -246,7 +242,6 @@ void psmouse_set_state(struct psmouse *psmouse, enum 
psmouse_state new_state)
  * psmouse_handle_byte() processes one byte of the input data stream
  * by calling corresponding protocol handler.
  */
-
 static int psmouse_handle_byte(struct psmouse *psmouse)
 {
psmouse_ret_t rc = psmouse->protocol_handler(psmouse);
@@ -289,7 +284,6 @@ static int psmouse_handle_byte(struct psmouse *psmouse)
  * psmouse_interrupt() handles incoming characters, either passing them
  * for normal processing or gathering them as command response.
  */
-
 static irqreturn_t psmouse_interrupt(struct serio *serio,
unsigned char data, unsigned int flags)
 {
@@ -332,9 +326,8 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
}
 
psmouse->packet[psmouse->pktcnt++] = data;
-/*
- * Check if this is a new device announcement (0xAA 0x00)
- */
+
+   /* Check if this is a new device announcement (0xAA 0x00) */
if (unlikely(psmouse->packet[0] == PSMOUSE_RET_BAT && psmouse->pktcnt 
<= 2)) {
if (psmouse->pktcnt == 1) {
psmouse->last = jiffies;
@@ -348,9 +341,8 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
serio_reconnect(serio);
goto out;
}
-/*
- * Not a new device, try processing first byte normally
- */
+
+   /* Not a new device, try processing first byte normally */
psmouse->pktcnt = 1;
if (psmouse_handle_byte(psmouse))
goto out;
@@ -358,9 +350,10 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
psmouse->packet[psmouse->pktcnt++] = data;
}
 
-/*
- * See if we need to force resync because mouse was idle for too long
- */
+   /*
+* See if we need to force resync because mouse was idle for
+* too long.
+*/
if (psmouse->state == PSMOUSE_ACTIVATED &&
psmouse->pktcnt == 1 && psmouse->resync_time &&
time_after(jiffies, psmouse->last + psmouse->resync_time * HZ)) {
@@ -377,7 +370,6 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
return IRQ_HANDLED;
 }
 
-
 /*
  * psmouse_sliced_command() sends an extended PS/2 command to the mouse
  * using sliced syntax, understood by advanced devices, such as Logitech
@@ -401,7 +393,6 @@ int psmouse_sliced_command(struct psmouse *psmouse, 
unsigned char command)
return 0;
 }
 
-
 /*
  * psmouse_reset() resets the mouse into power-on state.
  */
@@ -421,7 +412,6 @@ int psmouse_reset(struct psmouse *psmouse)
 /*
  * Here we set the mouse resolution.
  */
-
 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution)
 {
static const unsigned char params[] = { 0, 1, 2, 2, 3 };
@@ -438,7 +428,6 @@ void psmouse_set_resolution(struct psmouse *psmouse, 
unsigned int resolution)
 /*
  * Here we set the mouse report rate.
  */
-
 static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate)
 {
static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 
};
@@ -454,7 +443,6 @@ static void psmouse_set_rate(struct psmouse *psmouse, 
unsigned int rate)
 /*
  * Here we set the mouse scaling.
  */
-
 static void psmouse_set_scale(struct psmouse *psmouse, enum psmouse_scale 
scale)
 {
 

[PATCH 1/6] Input: psmouse - use switch statement in psmouse_process_byte()

2015-11-28 Thread Dmitry Torokhov
Instead of a series mostly exclusive "if" statements testing protocol type
of the mouse let's use "switch" statement.

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/mouse/psmouse-base.c | 65 ++
 1 file changed, 31 insertions(+), 34 deletions(-)

diff --git a/drivers/input/mouse/psmouse-base.c 
b/drivers/input/mouse/psmouse-base.c
index ad18dab..4e43e7e 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -138,22 +138,16 @@ psmouse_ret_t psmouse_process_byte(struct psmouse 
*psmouse)
if (psmouse->pktcnt < psmouse->pktsize)
return PSMOUSE_GOOD_DATA;
 
-/*
- * Full packet accumulated, process it
- */
-
-/*
- * Scroll wheel on IntelliMice, scroll buttons on NetMice
- */
+   /* Full packet accumulated, process it */
 
-   if (psmouse->type == PSMOUSE_IMPS || psmouse->type == PSMOUSE_GENPS)
+   switch (psmouse->type) {
+   case PSMOUSE_IMPS:
+   /* IntelliMouse has scroll wheel */
input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);
+   break;
 
-/*
- * Scroll wheel and buttons on IntelliMouse Explorer
- */
-
-   if (psmouse->type == PSMOUSE_IMEX) {
+   case PSMOUSE_IMEX:
+   /* Scroll wheel and buttons on IntelliMouse Explorer */
switch (packet[3] & 0xC0) {
case 0x80: /* vertical scroll on IntelliMouse Explorer 4.0 */
input_report_rel(dev, REL_WHEEL, (int) (packet[3] & 32) 
- (int) (packet[3] & 31));
@@ -168,39 +162,42 @@ psmouse_ret_t psmouse_process_byte(struct psmouse 
*psmouse)
input_report_key(dev, BTN_EXTRA, (packet[3] >> 5) & 1);
break;
}
-   }
+   break;
 
-/*
- * Extra buttons on Genius NewNet 3D
- */
+   case PSMOUSE_GENPS:
+   /* Report scroll buttons on NetMice */
+   input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);
 
-   if (psmouse->type == PSMOUSE_GENPS) {
+   /* Extra buttons on Genius NewNet 3D */
input_report_key(dev, BTN_SIDE, (packet[0] >> 6) & 1);
input_report_key(dev, BTN_EXTRA, (packet[0] >> 7) & 1);
-   }
+   break;
 
-/*
- * Extra button on ThinkingMouse
- */
-   if (psmouse->type == PSMOUSE_THINKPS) {
+   case PSMOUSE_THINKPS:
+   /* Extra button on ThinkingMouse */
input_report_key(dev, BTN_EXTRA, (packet[0] >> 3) & 1);
-   /* Without this bit of weirdness moving up gives wildly high Y 
changes. */
+
+   /*
+* Without this bit of weirdness moving up gives wildly
+* high Y changes.
+*/
packet[1] |= (packet[0] & 0x40) << 1;
-   }
+   break;
 
-/*
- * Cortron PS2 Trackball reports SIDE button on the 4th bit of the first
- * byte.
- */
-   if (psmouse->type == PSMOUSE_CORTRON) {
+   case PSMOUSE_CORTRON:
+   /*
+* Cortron PS2 Trackball reports SIDE button in the
+* 4th bit of the first byte.
+*/
input_report_key(dev, BTN_SIDE, (packet[0] >> 3) & 1);
packet[0] |= 0x08;
-   }
+   break;
 
-/*
- * Generic PS/2 Mouse
- */
+   default:
+   break;
+   }
 
+   /* Generic PS/2 Mouse */
input_report_key(dev, BTN_LEFT,packet[0]   & 1);
input_report_key(dev, BTN_MIDDLE, (packet[0] >> 2) & 1);
input_report_key(dev, BTN_RIGHT,  (packet[0] >> 1) & 1);
-- 
2.6.0.rc2.230.g3dd15c0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] Only probe select protocols on pass through PS/2 prots

2015-11-28 Thread Dmitry Torokhov
This series limits protocols that we probe on pass-through PS/2 ports to
IBM Trackpoint, Intellimouse, Intellimouse Explorer and basic PS/2, since
we have not seen anything else and probing all possible protocols takes too
long.

  Input: psmouse - use switch statement in psmouse_process_byte()
  Input: psmouse - fix comment style
  Input: psmouse - rearrange Focaltech init code
  Input: psmouse - move protocol descriptions around
  Input: psmouse - factor out common protocol probing code
  Input: psmouse - limit protocols that we try on passthrough ports

 drivers/input/mouse/focaltech.c|  22 +-
 drivers/input/mouse/focaltech.h|   8 +
 drivers/input/mouse/psmouse-base.c | 769 ++---
 3 files changed, 389 insertions(+), 410 deletions(-)

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 5/5] ARM: dts: sun9i: Add TODO comments for the main and low power clocks

2015-11-28 Thread Chen-Yu Tsai
The main (24MHz) clock on the A80 is configurable via the PRCM address
space. The low power/speed (32kHz) clock is from an external chip, the
AC100.

Signed-off-by: Chen-Yu Tsai 
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index a4ce348c0831..eb69a62f6bc4 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -128,6 +128,17 @@
 */
ranges = <0 0 0 0x2000>;
 
+   /*
+* This clock is actually configurable from the PRCM address
+* space. The external 24M oscillator can be turned off, and
+* the clock switched to an internal 16M RC oscillator. Under
+* normal operation there's no reason to do this, and the
+* default is to use the external good one, so just model this
+* as a fixed clock. Also it is not entirely clear if the
+* osc24M mux in the PRCM affects the entire clock tree, which
+* would also throw all the PLL clock rates off, or just the
+* downstream clocks in the PRCM.
+*/
osc24M: osc24M_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
@@ -135,6 +146,13 @@
clock-output-names = "osc24M";
};
 
+   /*
+* The 32k clock is from an external source, normally the
+* AC100 codec/RTC chip. This clock is by default enabled
+* and clocked at 32768 Hz, from the oscillator connected
+* to the AC100. It is configurable, but no such driver or
+* bindings exist yet.
+*/
osc32k: osc32k_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support

2015-11-28 Thread Chen-Yu Tsai
Hi everyone,

(resent with mailing lists CC-ed)

This is v4 of the Allwinner A80 PRCM support series. Since v4, the
series moved away from the mfd approach, and just lists the various
controls directly under the "clocks" and "soc" nodes.

Changes since v3:

- Only build new clock drivers for CONFIG_MACH_SUN9I

- Refactor sun8i-a23-apb0-clk driver to share common clock
  registering code

Changes since v2:

- Move away from mfd approach and directly list the clock and
  reset controls as first class devices.

- Use the new clk-simple-gates driver for the apbs clock gates.

- Update clk code to use struct clk_request.

- Add 1wire clk node.

- Use GENMASK and always use shifted bitmasks in cpus clk driver.

Changes since v1:

- Added missing clock gates based on updated documents

- Added new cpus clock driver based on updated documents

- Added pll3 clock placeholder

- Added comments about 24M & 32k oscillators

The series adds support for the Power Reset and Clock Management
module on Allwinner's A80 SoC. The PRCM manages clocks and resets
for the "special" block of peripherals, or the R/RTC block in
earlier SoCs, as well as power domain and resets for various parts
of the SoC, such as the 2 processor clusters, the GPU and others.

The special peripherals include a standby processor core, a timer
block, a watchdog, pin controller, 1 wire interface, PS/2 interface,
a UART, the RSB controller, a DMA controller, a consumer IR receiver
block, 2 I2C controllers, and 2 I2S controllers. We do not have
documents for all the peripherals. Support will be added where
possible.

Patch 1 adds CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver.
This driver was used with the mfd approach for the A23/A33 PRCM. As
such it is a platform device driver.

Patch 2 adds a new compatible string for the apbs gates to the
clk-simple-gates driver.

Patch 3 adds a new driver for the cpus clock.

Patch 4 adds the various supported clock and reset control device nodes
to the A80 dtsi.

Patch 5 adds some TODO comments regarding the 2 system oscillators.

Regards
ChenYu

Chen-Yu Tsai (5):
  clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver
  clk: sunxi: Add sun9i A80 apbs gates support
  clk: sunxi: Add sun9i A80 cpus (cpu special) clock support
  ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes
  ARM: dts: sun9i: Add TODO comments for the main and low power clocks

 Documentation/devicetree/bindings/clock/sunxi.txt |   2 +
 arch/arm/boot/dts/sun9i-a80.dtsi  |  97 -
 drivers/clk/sunxi/Makefile|   6 +-
 drivers/clk/sunxi/clk-simple-gates.c  |   2 +
 drivers/clk/sunxi/clk-sun8i-apb0.c|  71 +--
 drivers/clk/sunxi/clk-sun9i-cpus.c| 240 ++
 6 files changed, 403 insertions(+), 15 deletions(-)
 create mode 100644 drivers/clk/sunxi/clk-sun9i-cpus.c

-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support

2015-11-28 Thread Chen-Yu Tsai
The "cpus" clock is the clock for the embedded processor in the A80.
It is also part of the PRCM clock tree. This clock includes a pre-
divider on one of its inputs. For now we are using a custom clock
driver for it. In the future we may want to develop a generalized
driver for these types of clocks, which also includes the AHB clock
driver on sun[5678]i.

Signed-off-by: Chen-Yu Tsai 
---
 Documentation/devicetree/bindings/clock/sunxi.txt |   1 +
 drivers/clk/sunxi/Makefile|   1 +
 drivers/clk/sunxi/clk-sun9i-cpus.c| 240 ++
 3 files changed, 242 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk-sun9i-cpus.c

diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt 
b/Documentation/devicetree/bindings/clock/sunxi.txt
index b6859ed6913f..153ac72869e8 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -27,6 +27,7 @@ Required properties:
"allwinner,sun5i-a10s-ahb-gates-clk" - for the AHB gates on A10s
"allwinner,sun7i-a20-ahb-gates-clk" - for the AHB gates on A20
"allwinner,sun6i-a31-ar100-clk" - for the AR100 on A31
+   "allwinner,sun9i-a80-cpus-clk" - for the CPUS on A80
"allwinner,sun6i-a31-ahb1-clk" - for the AHB1 clock on A31
"allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
"allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index c55d5cd1c0e5..f7d439fa9980 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -16,6 +16,7 @@ obj-y += clk-sun9i-mmc.o
 obj-y += clk-usb.o
 
 obj-$(CONFIG_MACH_SUN9I) += clk-sun8i-apb0.o
+obj-$(CONFIG_MACH_SUN9I) += clk-sun9i-cpus.o
 
 obj-$(CONFIG_MFD_SUN6I_PRCM) += \
clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o
diff --git a/drivers/clk/sunxi/clk-sun9i-cpus.c 
b/drivers/clk/sunxi/clk-sun9i-cpus.c
new file mode 100644
index ..7626d2194b96
--- /dev/null
+++ b/drivers/clk/sunxi/clk-sun9i-cpus.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2015 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai 
+ *
+ * Allwinner A80 CPUS clock driver
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static DEFINE_SPINLOCK(sun9i_a80_cpus_lock);
+
+/**
+ * sun9i_a80_cpus_clk_setup() - Setup function for a80 cpus composite clk
+ */
+
+#define SUN9I_CPUS_MAX_PARENTS 4
+#define SUN9I_CPUS_MUX_PARENT_PLL4 3
+#define SUN9I_CPUS_MUX_SHIFT   16
+#define SUN9I_CPUS_MUX_MASKGENMASK(17, 16)
+#define SUN9I_CPUS_MUX_GET_PARENT(reg) ((reg & SUN9I_CPUS_MUX_MASK) >> \
+   SUN9I_CPUS_MUX_SHIFT)
+
+#define SUN9I_CPUS_DIV_SHIFT   4
+#define SUN9I_CPUS_DIV_MASKGENMASK(5, 4)
+#define SUN9I_CPUS_DIV_GET(reg)((reg & SUN9I_CPUS_DIV_MASK) >> 
\
+   SUN9I_CPUS_DIV_SHIFT)
+#define SUN9I_CPUS_DIV_SET(reg, div)   ((reg & ~SUN9I_CPUS_DIV_MASK) | \
+   (div << SUN9I_CPUS_DIV_SHIFT))
+#define SUN9I_CPUS_PLL4_DIV_SHIFT  8
+#define SUN9I_CPUS_PLL4_DIV_MASK   GENMASK(12, 8)
+#define SUN9I_CPUS_PLL4_DIV_GET(reg)   ((reg & SUN9I_CPUS_PLL4_DIV_MASK) >> \
+   SUN9I_CPUS_PLL4_DIV_SHIFT)
+#define SUN9I_CPUS_PLL4_DIV_SET(reg, div) ((reg & ~SUN9I_CPUS_PLL4_DIV_MASK) | 
\
+   (div << 
SUN9I_CPUS_PLL4_DIV_SHIFT))
+
+struct sun9i_a80_cpus_clk {
+   struct clk_hw hw;
+   void __iomem *reg;
+};
+
+#define to_sun9i_a80_cpus_clk(_hw) container_of(_hw, struct 
sun9i_a80_cpus_clk, hw)
+
+static unsigned long sun9i_a80_cpus_clk_recalc_rate(struct clk_hw *hw,
+   unsigned long parent_rate)
+{
+   struct sun9i_a80_cpus_clk *cpus = to_sun9i_a80_cpus_clk(hw);
+   unsigned long rate;
+   u32 reg;
+
+   /* Fetch the register value */
+   reg = readl(cpus->reg);
+
+   /* apply pre-divider first if parent is pll4 */
+   if (SUN9I_CPUS_MUX_GET_PARENT(reg) == SUN9I_CPUS_MUX_PARENT_PLL4)
+   parent_rate /= SUN9I_CPUS_PLL4_DIV_GET(reg) + 1;
+
+   /* clk divider */
+   rate = parent_rate / (SUN9I_CPUS_DIV_GET(reg) + 1);
+
+   return rate;
+}
+
+static long sun9i_a80_cpus_clk_round(unsigned long rate, u8 *divp, u8 
*pre_divp,
+u8 parent, unsigned long parent_rate)
+{
+   u8 div, pre_div = 1;
+
+   /*
+* clock can only divide, so we will never be able to achieve
+* frequencies higher than the parent frequency
+*/
+   if (parent_rate && rate > parent_rate)
+   rate = parent_rate;
+
+   div = DIV_ROUND_UP(parent_rate, rate);
+
+   /* calculate pre-divider if parent is pll4 */
+   if (parent == SUN9I_CPUS_MUX_PARENT_PLL4 && 

[PATCH v4 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver

2015-11-28 Thread Chen-Yu Tsai
The APBS clock on sun9i is the same as the APB0 clock on sun8i. With
sun9i we are supporting the PRCM clocks by using CLK_OF_DECLARE,
instead of through a PRCM mfd device and subdevices for each clock
and reset control. As such we need a CLK_OF_DECLARE version of
the sun8i-a23-apb0-clk driver.

Also, build it for sun9i/A80, and not just for configurations with
MFD_SUN6I_PRCM enabled.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/clk/sunxi/Makefile |  5 +--
 drivers/clk/sunxi/clk-sun8i-apb0.c | 71 +++---
 2 files changed, 62 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index cb4c299214ce..c55d5cd1c0e5 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -15,6 +15,7 @@ obj-y += clk-sun9i-core.o
 obj-y += clk-sun9i-mmc.o
 obj-y += clk-usb.o
 
+obj-$(CONFIG_MACH_SUN9I) += clk-sun8i-apb0.o
+
 obj-$(CONFIG_MFD_SUN6I_PRCM) += \
-   clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
-   clk-sun8i-apb0.o
+   clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o
diff --git a/drivers/clk/sunxi/clk-sun8i-apb0.c 
b/drivers/clk/sunxi/clk-sun8i-apb0.c
index 7ae5d2c2cde1..c1e2ac8f4b0d 100644
--- a/drivers/clk/sunxi/clk-sun8i-apb0.c
+++ b/drivers/clk/sunxi/clk-sun8i-apb0.c
@@ -17,13 +17,68 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
+static struct clk *sun8i_a23_apb0_register(struct device_node *node,
+  void __iomem *reg)
+{
+   const char *clk_name = node->name;
+   const char *clk_parent;
+   struct clk *clk;
+   int ret;
+
+   clk_parent = of_clk_get_parent_name(node, 0);
+   if (!clk_parent)
+   return ERR_PTR(-EINVAL);
+
+   of_property_read_string(node, "clock-output-names", _name);
+
+   /* The A23 APB0 clock is a standard 2 bit wide divider clock */
+   clk = clk_register_divider(NULL, clk_name, clk_parent, 0, reg,
+  0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
+   if (IS_ERR(clk))
+   return clk;
+
+   ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+   if (ret)
+   goto err_unregister;
+
+   return clk;
+
+err_unregister:
+   clk_unregister_divider(clk);
+
+   return ERR_PTR(ret);
+}
+
+static void sun8i_a23_apb0_setup(struct device_node *node)
+{
+   void __iomem *reg;
+   struct resource res;
+   struct clk *clk;
+
+   reg = of_io_request_and_map(node, 0, of_node_full_name(node));
+   if (IS_ERR(reg))
+   return;
+
+   clk = sun8i_a23_apb0_register(node, reg);
+   if (IS_ERR(clk))
+   goto err_unmap;
+
+   return;
+
+err_unmap:
+   iounmap(reg);
+   of_address_to_resource(node, 0, );
+   release_mem_region(res.start, resource_size());
+}
+CLK_OF_DECLARE(sun8i_a23_apb0, "allwinner,sun8i-a23-apb0-clk",
+  sun8i_a23_apb0_setup);
+
 static int sun8i_a23_apb0_clk_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev->dev.of_node;
-   const char *clk_name = np->name;
-   const char *clk_parent;
struct resource *r;
void __iomem *reg;
struct clk *clk;
@@ -33,19 +88,11 @@ static int sun8i_a23_apb0_clk_probe(struct platform_device 
*pdev)
if (IS_ERR(reg))
return PTR_ERR(reg);
 
-   clk_parent = of_clk_get_parent_name(np, 0);
-   if (!clk_parent)
-   return -EINVAL;
-
-   of_property_read_string(np, "clock-output-names", _name);
-
-   /* The A23 APB0 clock is a standard 2 bit wide divider clock */
-   clk = clk_register_divider(>dev, clk_name, clk_parent, 0, reg,
-  0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
+   clk = sun8i_a23_apb0_register(np, reg);
if (IS_ERR(clk))
return PTR_ERR(clk);
 
-   return of_clk_add_provider(np, of_clk_src_simple_get, clk);
+   return 0;
 }
 
 static const struct of_device_id sun8i_a23_apb0_clk_dt_ids[] = {
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes

2015-11-28 Thread Chen-Yu Tsai
This adds the supported PRCM clocks and reset controls to the A80 dtsi.
The DAUDIO module clocks are not supported yet.

Also update clock and reset phandles for r_uart.

Signed-off-by: Chen-Yu Tsai 
---
 arch/arm/boot/dts/sun9i-a80.dtsi | 79 +++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index 1118bf5cc4fb..a4ce348c0831 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -164,6 +164,14 @@
 "usb_phy2", "usb_hsic_12M";
};
 
+   pll3: clk@0608 {
+   /* placeholder until implemented */
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-rate = <0>;
+   clock-output-names = "pll3";
+   };
+
pll4: clk@060c {
#clock-cells = <0>;
compatible = "allwinner,sun9i-a80-pll4-clk";
@@ -350,6 +358,68 @@
"apb1_uart2", "apb1_uart3",
"apb1_uart4", "apb1_uart5";
};
+
+   cpus_clk: clk@08001410 {
+   compatible = "allwinner,sun9i-a80-cpus-clk";
+   reg = <0x08001410 0x4>;
+   #clock-cells = <0>;
+   clocks = <>, <>, <>, <>;
+   clock-output-names = "cpus";
+   };
+
+   ahbs: ahbs_clk {
+   compatible = "fixed-factor-clock";
+   #clock-cells = <0>;
+   clock-div = <1>;
+   clock-mult = <1>;
+   clocks = <_clk>;
+   clock-output-names = "ahbs";
+   };
+
+   apbs: clk@0800141c {
+   compatible = "allwinner,sun8i-a23-apb0-clk";
+   reg = <0x0800141c 0x4>;
+   #clock-cells = <0>;
+   clocks = <>;
+   clock-output-names = "apbs";
+   };
+
+   apbs_gates: clk@08001428 {
+   compatible = "allwinner,sun9i-a80-apbs-gates-clk";
+   reg = <0x08001428 0x4>;
+   #clock-cells = <1>;
+   clocks = <>;
+   clock-indices = <0>, <1>,
+   <2>, <3>,
+   <4>, <5>,
+   <6>, <7>,
+   <12>, <13>,
+   <16>, <17>,
+   <18>, <20>;
+   clock-output-names = "apbs_pio", "apbs_ir",
+   "apbs_timer", "apbs_rsb",
+   "apbs_uart", "apbs_1wire",
+   "apbs_i2c0", "apbs_i2c1",
+   "apbs_ps2_0", "apbs_ps2_1",
+   "apbs_dma", "apbs_i2s0",
+   "apbs_i2s1", "apbs_twd";
+   };
+
+   r_1wire_clk: clk@08001450 {
+   reg = <0x08001450 0x4>;
+   #clock-cells = <0>;
+   compatible = "allwinner,sun4i-a10-mod0-clk";
+   clocks = <>, <>;
+   clock-output-names = "r_1wire";
+   };
+
+   r_ir_clk: clk@08001454 {
+   reg = <0x08001454 0x4>;
+   #clock-cells = <0>;
+   compatible = "allwinner,sun4i-a10-mod0-clk";
+   clocks = <>, <>;
+   clock-output-names = "r_ir";
+   };
};
 
soc {
@@ -764,13 +834,20 @@
interrupts = ;
};
 
+   apbs_rst: reset@080014b0 {
+   reg = <0x080014b0 0x4>;
+   compatible = "allwinner,sun6i-a31-clock-reset";
+   #reset-cells = <1>;
+   };
+
r_uart: serial@08002800 {
compatible = "snps,dw-apb-uart";
reg = <0x08002800 0x400>;
interrupts = ;
reg-shift = <2>;
reg-io-width = <4>;
-   clocks = <>;
+   clocks = <_gates 4>;
+   resets = <_rst 4>;
status = "disabled";
};
};
-- 
2.6.2

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

[PATCH v4 2/5] clk: sunxi: Add sun9i A80 apbs gates support

2015-11-28 Thread Chen-Yu Tsai
This patch adds support for the PRCM apbs clock gates found on the
Allwinner A80 SoC.

Signed-off-by: Chen-Yu Tsai 
---
 Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
 drivers/clk/sunxi/clk-simple-gates.c  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt 
b/Documentation/devicetree/bindings/clock/sunxi.txt
index a94bb56a0e9e..b6859ed6913f 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -55,6 +55,7 @@ Required properties:
"allwinner,sun9i-a80-apb1-gates-clk" - for the APB1 gates on A80
"allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31
"allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
+   "allwinner,sun9i-a80-apbs-gates-clk" - for the APBS gates on A80
"allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13
"allwinner,sun4i-a10-mmc-clk" - for the MMC clock
"allwinner,sun9i-a80-mmc-clk" - for mmc module clocks on A80
diff --git a/drivers/clk/sunxi/clk-simple-gates.c 
b/drivers/clk/sunxi/clk-simple-gates.c
index 0214c6548afd..c8acc0612c15 100644
--- a/drivers/clk/sunxi/clk-simple-gates.c
+++ b/drivers/clk/sunxi/clk-simple-gates.c
@@ -140,6 +140,8 @@ CLK_OF_DECLARE(sun9i_a80_apb0, 
"allwinner,sun9i-a80-apb0-gates-clk",
   sunxi_simple_gates_init);
 CLK_OF_DECLARE(sun9i_a80_apb1, "allwinner,sun9i-a80-apb1-gates-clk",
   sunxi_simple_gates_init);
+CLK_OF_DECLARE(sun9i_a80_apbs, "allwinner,sun9i-a80-apbs-gates-clk",
+  sunxi_simple_gates_init);
 
 static const int sun4i_a10_ahb_critical_clocks[] __initconst = {
14, /* ahb_sdram */
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ath6kl: Use vmalloc for loading firmware using api1 method

2015-11-28 Thread Tetsuo Handa
Andy Shevchenko wrote:
> On Sat, Nov 28, 2015 at 8:58 PM, Brent Taylor  wrote:
> > Whats the status on this patch?  I don't see it on patchwork anymore
> > nor is it in any of the git trees I checked.
> >
> 
> You forget to use kvfree() instead of kfree() in core.c.
> 

In addition to that, I think you can do like below.

if (>fw == fw)
*fw = vmalloc(fw_entry->size);
else
*fw = kmalloc(fw_entry->size, GFP_KERNEL);
if (*fw == NULL)
ret = -ENOMEM;
else
memcpy(*fw, fw_entry->data, fw_entry->size);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sched: fix outdated comment on task_prio() return value

2015-11-28 Thread Antoine Busque
The comment describing the possible return values of the task_prio()
function, having not been updated in many years, was misleading. It
indicated an offset of -200 for RT tasks, and normal tasks having 32
possible priority values centered around 0. This is no longer the
case, as the values it returns will be in the range [-100..39]. The
new comment reflects the current behaviour.

Signed-off-by: Antoine Busque 
---
 kernel/sched/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bbe9577..b9e5f4a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3106,8 +3106,8 @@ SYSCALL_DEFINE1(nice, int, increment)
  * @p: the task in question.
  *
  * Return: The priority value as seen by users in /proc.
- * RT tasks are offset by -200. Normal tasks are centered
- * around 0, value goes from -16 to +15.
+ * Values range from -100 to to -2 for RT tasks, and from
+ * 0 to 39 for normal tasks.
  */
 int task_prio(const struct task_struct *p)
 {
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 01/12] Ext4: Fix extended timestamp encoding and decoding

2015-11-28 Thread Theodore Ts'o
On Tue, Nov 24, 2015 at 09:10:53PM +0100, Arnd Bergmann wrote:
> On Tuesday 24 November 2015 14:36:46 Theodore Ts'o wrote:
> > This is the patch I would prefer to use (and in fact which I have
> > added to the ext4 tree):
> > 
> > There are issues with 32-bit vs 64-bit encoding of times before
> > January 1, 1970, which are handled with this patch which is not
> > handled with what you have in your patch series.  So I'd prefer if you
> > drop this patch, and I'll get this sent to Linus as a bug fix for 4.4.
> 
> I'm happy with either one. Apparently both Davids have arrived with
> almost the same algorithm and implementation, with the exception of
> the pre-1970 handling you mention there.

I was doing some testing on x86, which leads me to ask --- what's the
current thinking about post y2038 on 32-bit platforms such as x86?  I
see that there was some talk about using struct timespec64, but we
haven't made the transition in the VFS interfaces yet, despite a
comment in an LWN article from 2014 stating that "the first steps have
been taken; hopefully the rest will follow before too long".

Cheers,

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: The console log is doubled if earlycon is enabled

2015-11-28 Thread Andy Shevchenko
On Fri, Nov 27, 2015 at 12:21 PM, Masahiro Yamada
 wrote:
> Hi,
>
>
> If I add "earlycon" to the kernel parameter, the log message
> on the earlycon is also displayed to the regular console.
> In other words, the same log messages are displayed twice.
>
> I noticed this problem on v4.4-rc1.
> It has not been fixed in the mainline yet, I think.
>
> Anybody who has a clue?
> (I have not done git-bisect yet.)

Does adding the following line in
drivers/tty/serial/8250/8250_early.c:: early_serial8250_setup() fix
the issue?

device->con->flags &= ~CON_PRINTBUFFER;

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] Thermal Management fixes for v4.4-rc3

2015-11-28 Thread Zhang Rui
Hi, Linus,

Please pull from
  git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git next

to receive the latest Thermal Management updates for 4.4-rc3 with
top-most commit a2291badc355d58ead5c19ae0609468947416040:

  imx: thermal: use CPU temperature grade info for thresholds
(2015-11-23 16:38:40 -0800)

on top of commit 5d50ac70fe98518dbf620bfba8184254663125eb:

  Merge tag 'xfs-for-linus-4.4' of
git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs (2015-11-11
20:18:48 -0800)


Specifics:

- Several fixes and cleanups on Rockchip thermal drivers.
- Add the missing support of RK3368 SoCs in Rockchip driver.
- Small fixes on of-thermal, power_allocator, rcar driver, IMX, and QCOM
drivers, and also compilation fixes, on thermal.h, when thermal is not
selected.

thanks,
rui


Arnd Bergmann (2):
  Revert "thermal: qcom_spmi: allow compile test"
  thermal: fix thermal_zone_bind_cooling_device prototype

Caesar Wang (7):
  dt-bindings: rockchip-thermal: Support the RK3368 SoCs compatible
  thermal: rockchip: better to compatible the driver for different
SoCs
  thermal: rockchip: trivial: fix typo in commit
  thermal: rockchip: improve the conversion function
  thermal: rockchip: Add the sort mode for adc value increment or
decrement
  thermal: rockchip: consistently use int for temperatures
  thermal: rockchip: Support the RK3368 SoCs in thermal driver

Jiada Wang (1):
  thermal: of-thermal: Reduce log level for message when can't fine
thermal zone

Kapileshwar Singh (1):
  thermal: power_allocator: Use temperature reading from tz

Kuninori Morimoto (1):
  thermal: rcar_thermal: remove redundant operation

Tim Harvey (1):
  imx: thermal: use CPU temperature grade info for thresholds

 .../bindings/thermal/rockchip-thermal.txt  |   4 +-
 drivers/thermal/Kconfig|   2 +-
 drivers/thermal/imx_thermal.c  |  56 +++-
 drivers/thermal/of-thermal.c   |   2 +-
 drivers/thermal/power_allocator.c  |  24 +-
 drivers/thermal/rcar_thermal.c |  49 ++-
 drivers/thermal/rockchip_thermal.c | 328
+++--
 include/linux/thermal.h|   3 +-
 8 files changed, 316 insertions(+), 152 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] spi: dw-mid: constify dw_spi_dma_ops structure

2015-11-28 Thread Andy Shevchenko
On Sat, Nov 28, 2015 at 4:09 PM, Julia Lawall  wrote:
> The dw_spi_dma_ops structure is never modified, so declare it as const.
>
> Done with the help of Coccinelle.
>
> Signed-off-by: Julia Lawall 
>

Acked-by: Andy Shevchenko 

> ---
>  drivers/spi/spi-dw-mid.c |2 +-
>  drivers/spi/spi-dw.h |2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
> index bb1052e..9185f6c 100644
> --- a/drivers/spi/spi-dw-mid.c
> +++ b/drivers/spi/spi-dw-mid.c
> @@ -283,7 +283,7 @@ static void mid_spi_dma_stop(struct dw_spi *dws)
> }
>  }
>
> -static struct dw_spi_dma_ops mid_dma_ops = {
> +static const struct dw_spi_dma_ops mid_dma_ops = {
> .dma_init   = mid_spi_dma_init,
> .dma_exit   = mid_spi_dma_exit,
> .dma_setup  = mid_spi_dma_setup,
> diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
> index 35589a2..61bc3cb 100644
> --- a/drivers/spi/spi-dw.h
> +++ b/drivers/spi/spi-dw.h
> @@ -130,7 +130,7 @@ struct dw_spi {
> struct dma_chan *rxchan;
> unsigned long   dma_chan_busy;
> dma_addr_t  dma_addr; /* phy address of the Data register 
> */
> -   struct dw_spi_dma_ops   *dma_ops;
> +   const struct dw_spi_dma_ops *dma_ops;
> void*dma_tx;
> void*dma_rx;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-spi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ath6kl: Use vmalloc for loading firmware using api1 method

2015-11-28 Thread Andy Shevchenko
On Sat, Nov 28, 2015 at 8:58 PM, Brent Taylor  wrote:
> Sorry, the first e-mail was sent via gmail and I forgot about sending
> it in plain text mode.
>
> Whats the status on this patch?  I don't see it on patchwork anymore
> nor is it in any of the git trees I checked.
>

You forget to use kvfree() instead of kfree() in core.c.

> Thanks,
> Brent
>
> On Fri, Oct 16, 2015 at 12:10 AM, Brent Taylor  wrote:
>> Signed-off-by: Brent Taylor 
>> ---
>>  drivers/net/wireless/ath/ath6kl/init.c | 15 +++
>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
>> b/drivers/net/wireless/ath/ath6kl/init.c
>> index 6e473fa..2155739 100644
>> --- a/drivers/net/wireless/ath/ath6kl/init.c
>> +++ b/drivers/net/wireless/ath/ath6kl/init.c
>> @@ -673,10 +673,17 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
>> *filename,
>> return ret;
>>
>> *fw_len = fw_entry->size;
>> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
>> -
>> -   if (*fw == NULL)
>> -   ret = -ENOMEM;
>> +   if (>fw == fw) {
>> +   *fw = vmalloc(fw_entry->size);
>> +   if (*fw == NULL)
>> +   ret = -ENOMEM;
>> +   else
>> +   memcpy(*fw, fw_entry->data, fw_entry->size);
>> +   } else {
>> +   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
>> +   if (*fw == NULL)
>> +   ret = -ENOMEM;
>> +   }
>>
>> release_firmware(fw_entry);
>>
>> --
>> 2.6.1
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 22/71] ncr5380: Eliminate selecting state

2015-11-28 Thread Finn Thain

On Sun, 29 Nov 2015, Ondrej Zary wrote:

> > [...] I think that this should solve the problem:
> 
> Yes, it does!
> 
> [   48.119367] scsi host2: Generic NCR5380/NCR53C400 SCSI, io_port 0x0, 
> n_io_port 0, base 0xd8000, irq 0, can_queue 16, cmd_per_lun 2, sg_tablesize 
> 128, this_id 7, flags { NO_DMA_FIXUP }, options { AUTOPROBE_IRQ PSEUDO_DMA }
> [   49.715388] scsi 2:0:1:0: Direct-Access QUANTUM  LP240S GM240S01X 4.6  
> PQ: 0 ANSI: 2 CCS

That still takes about 1.6 seconds to scan a vacant bus ID. It should be 
more like 0.25 seconds. Did you have the entire patch series applied?

The code presently in mainline spins for 500 iterations in the relevant 
busy-wait loop, with the comment, "8uS a cycle for the cpu access". That 
doesn't help me much. Does that refer to an ISA bus cycle? Or one 
iteration of the loop? Electrical conductance?

If we knew how many loops_per_jiffy your machine gets, and your CONFIG_HZ 
value, we could figure out how long a chip register access takes (which 
might be 8 us).

I'll try to figure out a similar timing for my Domex PCI card to see if 
there is some sort of compromise to be found.

-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 0/3] Add PWM clock support for bcm2835

2015-11-28 Thread Remi Pommarel
Hi Stefan,

On Sat, Nov 28, 2015 at 09:52:07PM +0100, Stefan Wahren wrote:
> i applied the series including the devicetree modification, but it
> doesn't work for me.
> 
> First of all i get an ugly division by zero warning from the pwm
> driver. The pwm driver still assume a fixed clock and doesn't handle
> the error cases of clk_get_rate(). I attached a patch at the end.

Yes the devicetree patch from patchset version one does not work with
this version. I haven't sent the modified devicetree because Eric said
it is better to send it in a separate patchset. If you want to test it I
attached the working devicetree patch at the end.

But, yes, that would be nice if pwm driver was protected from this
division by zero.

> 
> The reason in my case why clk_get_rate() returns zero is that the
> pwm clock is orphan ( pwm is listed under
> /sys/kernel/debug/clk_orphan_summary ).
> 
> My suspicion is it has something to do with the clock manager driver.
> The bcm2835_clock_per_parents contains only 8 entries. But according to
> BCM2835-ARM-Peripherals.pdf [1] CM_GP0CTL SRC page 107 has 16
> entries. The upper 8 entries are all mapped to GND. It looks to me
> that the driver doesn't take care of this and so the pwm clock isn't
> able to determine it's parent.
> 

In fact, default parent for pwm after boot up is GND (CM_GP0CTL SRC ==
0). Which means that the default pwm clock rate is 0. The clock appears
to be orphan because in the bcm2835 clock driver, the GND clock is not
registered.

So, IMHO, we have to set the default pwm rate from the devicetree, using
assigned-clock-rates. That what does the following dts patch.

This patch also set the gpio pin 18 to proper alternate function in order
to be able to get pwm output from this gpio.

Thanks

-- 
Remi

-->8--
diff --git a/arch/arm/boot/dts/bcm2835-rpi-b.dts 
b/arch/arm/boot/dts/bcm2835-rpi-b.dts
index ff6b2d1..478aa79 100644
--- a/arch/arm/boot/dts/bcm2835-rpi-b.dts
+++ b/arch/arm/boot/dts/bcm2835-rpi-b.dts
@@ -13,5 +13,10 @@
 };
 
  {
-   pinctrl-0 = <  >;
+   pinctrl-0 = <   >;
+
+   gpiopwm: pwm {
+   brcm,pins = <18>;
+   brcm,function = ;
+   };
 };
diff --git a/arch/arm/boot/dts/bcm2835-rpi.dtsi 
b/arch/arm/boot/dts/bcm2835-rpi.dtsi
index 3572f03..55801e0 100644
--- a/arch/arm/boot/dts/bcm2835-rpi.dtsi
+++ b/arch/arm/boot/dts/bcm2835-rpi.dtsi
@@ -60,3 +60,7 @@
status = "okay";
bus-width = <4>;
 };
+
+ {
+   status = "okay";
+};
diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi
index aef64de..567bd35 100644
--- a/arch/arm/boot/dts/bcm2835.dtsi
+++ b/arch/arm/boot/dts/bcm2835.dtsi
@@ -149,6 +149,15 @@
status = "disabled";
};
 
+   pwm: pwm@7e20c000 {
+   compatible = "brcm,bcm2835-pwm";
+   reg = <0x7e20c000 0x28>;
+   clocks = < BCM2835_CLOCK_PWM>;
+   assigned-clocks = < BCM2835_CLOCK_PWM>;
+   assigned-clock-rates = <960>;
+   status = "disabled";
+   };
+
sdhci: sdhci@7e30 {
compatible = "brcm,bcm2835-sdhci";
reg = <0x7e30 0x100>;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] um: Set secure access mode for temporary file

2015-11-28 Thread Mickaël Salaün


On 28/11/2015 23:55, Richard Weinberger wrote:
> Am 28.11.2015 um 23:52 schrieb Mickaël Salaün:
>>
>> On 28/11/2015 22:40, Richard Weinberger wrote:
>>> Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
 Replace the default insecure mode 0777 with 0700 for temporary file.

 Prohibit other users to change the executable mapped code.
>>>
>>> Hmm, isn't the tmp file already unlinked at this stage?
>>>
>>
>> Yes, but if someone could open it before the unlink e.g. because of the 
>> umask (which does not seems to be the case thanks to mkstemp, but remains 
>> unspecified [1]), this user should then be able to have write access to the 
>> file descriptor/description.
> 
> Yes, someone can open it before the unlink. But you change the file mode 
> after that.
> How does it improve the situation? The attacker has already the file handle.

The attacker could have the file handle only in a read-only mode, which is a 
bit different than being able to write and execute arbitrary code thanks to a 
file descriptor mapped RWX :)

 Mickaël



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-28 Thread kbuild test robot
Hi Robert,

[auto build test ERROR on: gpio/for-next]
[also build test ERROR on: v4.4-rc2 next-20151127]

url:
https://github.com/0day-ci/linux/commits/Robert-Jarzmik/gpio-pxa-integrate-with-pincontrol/20151129-054738
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
for-next
config: arm-pxa910_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/gpio/gpio-pxa.c: In function 'pxa_gpio_probe':
>> drivers/gpio/gpio-pxa.c:625:12: error: 'pxa_irq_domain_ops' undeclared 
>> (first use in this function)
   0, _irq_domain_ops, pchip);
   ^
   drivers/gpio/gpio-pxa.c:625:12: note: each undeclared identifier is reported 
only once for each function it appears in
   drivers/gpio/gpio-pxa.c: At top level:
   drivers/gpio/gpio-pxa.c:500:24: warning: 'pxa_muxed_gpio_chip' defined but 
not used [-Wunused-variable]
static struct irq_chip pxa_muxed_gpio_chip = {
   ^

vim +/pxa_irq_domain_ops +625 drivers/gpio/gpio-pxa.c

   619  
   620  if (!pxa_last_gpio)
   621  return -EINVAL;
   622  
   623  pchip->irqdomain = irq_domain_add_legacy(pdev->dev.of_node,
   624   pxa_last_gpio + 1, 
irq_base,
 > 625   0, 
 > _irq_domain_ops, pchip);
   626  if (IS_ERR(pchip->irqdomain))
   627  return PTR_ERR(pchip->irqdomain);
   628  

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


.config.gz
Description: Binary data


Re: [PATCH 2/2] um: Use race-free temporary file creation

2015-11-28 Thread Mickaël Salaün

On 28/11/2015 23:07, Richard Weinberger wrote:
> Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
>> Open the memory mapped file with the O_TMPFILE flag when available.
>>
>> Signed-off-by: Mickaël Salaün 
>> ---
>>  arch/um/os-Linux/mem.c | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
>> index 798aeb4..fe52e2d 100644
>> --- a/arch/um/os-Linux/mem.c
>> +++ b/arch/um/os-Linux/mem.c
>> @@ -106,6 +106,18 @@ static int __init make_tempfile(const char *template)
>>  }
>>  }
>>  
>> +#ifdef O_TMPFILE
>> +fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700);
>> +/*
>> + * If the running system does not support O_TMPFILE flag then retry
>> + * without it.
>> + */
>> +if (fd != -1 || (errno != EINVAL && errno != EISDIR &&
> 
> Why are you handling EISDIR?

I follow the man page for open [1], I think it was a workaround needed for some 
kernel versions just after the O_TMPFILE was added but before the support for 
EOPNOTSUPP.
We may need to add the EACCES too for some version of glibc [2, 3]?

1. http://man7.org/linux/man-pages/man2/openat.2.html#BUGS
2. Commit 69a91c237ab0ebe4e9fdeaf6d0090c85275594ec and 
https://sourceware.org/bugzilla/show_bug.cgi?id=17523
3. https://bugs.gentoo.org/529044

> 
>> +errno != EOPNOTSUPP))
>> +return fd;
>> +errno = 0;
> 
> Why are you resetting errno?

It's to ignore/reset the error code from open, but it may not be needed because 
of the next call to malloc?

 Mickaël



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 22/71] ncr5380: Eliminate selecting state

2015-11-28 Thread Ondrej Zary
On Thursday 26 November 2015 23:32:46 Finn Thain wrote:
> 
> On Thu, 26 Nov 2015, Ondrej Zary wrote:
> 
> > 
> > [  156.014234] scsi host2: Generic NCR5380/NCR53C400 SCSI, io_port 0x0, 
> > n_io_port 0, base 0xd8000, irq 0, can_queue 16, cmd_per_lun 2, sg_tablesize 
> > 128, this_id 7, flags { NO_DMA_FIXUP }, options { AUTOPROBE_IRQ PSEUDO_DMA }
> > [  156.020369] scsi host2: scsi_scan_host_selected: 
> > <4294967295:4294967295:18446744073709551615>
> > [  156.020777] scsi 2:0:0:0: scsi scan: INQUIRY pass 1 length 36
> > [  156.022046] scsi host2: main: dequeued de045600
> > [  156.022109] STATUS_REG: 00
> > BASR: 00
> > ICR: 00
> > MODE: 00
> > [  156.022451] scsi host2: starting arbitration, id = 7
> > [  156.022740] scsi host2: won arbitration
> > [  156.022806] scsi host2: selecting target 0
> > [  171.097450] scsi host2: target did not respond within 250ms
> > [  171.097508] scsi host2: main: select complete
> > [  171.099554] scsi 2:0:0:0: scsi scan: INQUIRY failed with code 0x4
> 
> This is very helpful, thanks.
> 
> The problem has to be this:
> 
> err = NCR5380_poll_politely(instance, STATUS_REG, SR_BSY, SR_BSY,
> msecs_to_jiffies(250));
> 
> which would suggest a problem with the busy wait loop. It seems that 5380 
> register accesses are much more expensive on PC than the platforms I've 
> tested.
> 
> > [  171.103200] scsi 2:0:1:0: scsi scan: INQUIRY pass 1 length 36
> > [  171.105246] scsi host2: main: dequeued df6b9f00
> > [  171.105350] STATUS_REG: 00
> > BASR: 08
> > ICR: 00
> > MODE: 00
> > [  171.105664] scsi host2: starting arbitration, id = 7
> > [  171.105752] scsi host2: won arbitration
> > [  171.105822] scsi host2: selecting target 1
> > [  171.105977] scsi host2: target 1 selected, going into MESSAGE OUT phase.
> > [  171.106042] scsi host2: nexus established.
> > [  171.106093] scsi host2: main: select complete
> > [  171.106145] scsi host2: main: performing information transfer
> > [  171.108531] scsi 2:0:1:0: scsi scan: INQUIRY successful with code 0x0
> > [  171.108639] scsi 2:0:1:0: scsi scan: INQUIRY pass 2 length 130
> > [  171.109401] scsi host2: main: dequeued df6b9f00
> > [  171.109485] STATUS_REG: 00
> > BASR: 08
> > ICR: 00
> > MODE: 00
> > [  171.109779] scsi host2: starting arbitration, id = 7
> > [  171.109878] scsi host2: won arbitration
> > [  171.109954] scsi host2: selecting target 1
> > [  171.110112] scsi host2: target 1 selected, going into MESSAGE OUT phase.
> > [  171.110181] scsi host2: nexus established.
> > [  171.110236] scsi host2: main: select complete
> > [  171.110286] scsi host2: main: performing information transfer
> > [  171.114811] scsi 2:0:1:0: scsi scan: INQUIRY successful with code 0x0
> > [  171.114928] scsi 2:0:1:0: Direct-Access QUANTUM  LP240S GM240S01X 
> > 4.6  PQ: 0 ANSI: 2 CCS
> > [  171.115011] scsi target2:0:1: scsi scan: Sequential scan
> > [  171.115856] scsi 2:0:1:1: scsi scan: INQUIRY pass 1 length 36
> > [  171.116008] scsi host2: main: dequeued df6b9800
> > [  171.116039] STATUS_REG: 00
> > BASR: 08
> > ICR: 00
> > MODE: 00
> > [  171.116736] scsi host2: starting arbitration, id = 7
> > [  171.116843] scsi host2: won arbitration
> > [  171.116898] scsi host2: selecting target 1
> > [  171.117117] scsi host2: target 1 selected, going into MESSAGE OUT phase.
> > [  171.117182] scsi host2: nexus established.
> > [  171.117234] scsi host2: main: select complete
> > [  171.117287] scsi host2: main: performing information transfer
> > [  171.119674] scsi 2:0:1:1: scsi scan: INQUIRY successful with code 0x0
> > [  171.119781] scsi 2:0:1:1: scsi scan: INQUIRY pass 2 length 130
> > [  171.119898] scsi host2: main: dequeued df6b9800
> > [  171.119962] STATUS_REG: 00
> > BASR: 08
> > ICR: 00
> > MODE: 00
> > [  171.121426] scsi host2: starting arbitration, id = 7
> > [  171.121537] scsi host2: won arbitration
> > [  171.121592] scsi host2: selecting target 1
> > [  171.121766] scsi host2: target 1 selected, going into MESSAGE OUT phase.
> > [  171.121834] scsi host2: nexus established.
> > [  171.121889] scsi host2: main: select complete
> > [  171.121940] scsi host2: main: performing information transfer
> > [  171.126361] scsi 2:0:1:1: scsi scan: INQUIRY successful with code 0x0
> > [  171.126470] scsi 2:0:1:1: scsi scan: peripheral qualifier of 3, device 
> > not added
> > [  171.127735] scsi 2:0:2:0: scsi scan: INQUIRY pass 1 length 36
> > [  171.127920] scsi host2: main: dequeued df6b9800
> > [  171.127982] STATUS_REG: 00
> > BASR: 08
> > ICR: 00
> > MODE: 00
> > [  171.128648] scsi host2: starting arbitration, id = 7
> > [  171.128754] scsi host2: won arbitration
> > [  171.128811] scsi host2: selecting target 2
> > [  186.203734] scsi host2: target did not respond within 250ms
> > [  186.203794] scsi host2: main: select complete
> > [  186.205355] scsi 2:0:2:0: scsi scan: INQUIRY failed with code 0x4
> > [  186.208989] scsi 2:0:3:0: scsi scan: INQUIRY pass 1 length 36
> > [  

Re: [PATCH 1/2] um: Set secure access mode for temporary file

2015-11-28 Thread Richard Weinberger
Am 29.11.2015 um 00:00 schrieb Mickaël Salaün:
> 
> 
> On 28/11/2015 23:55, Richard Weinberger wrote:
>> Am 28.11.2015 um 23:52 schrieb Mickaël Salaün:
>>>
>>> On 28/11/2015 22:40, Richard Weinberger wrote:
 Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
> Replace the default insecure mode 0777 with 0700 for temporary file.
>
> Prohibit other users to change the executable mapped code.

 Hmm, isn't the tmp file already unlinked at this stage?

>>>
>>> Yes, but if someone could open it before the unlink e.g. because of the 
>>> umask (which does not seems to be the case thanks to mkstemp, but remains 
>>> unspecified [1]), this user should then be able to have write access to the 
>>> file descriptor/description.
>>
>> Yes, someone can open it before the unlink. But you change the file mode 
>> after that.
>> How does it improve the situation? The attacker has already the file handle.
> 
> The attacker could have the file handle only in a read-only mode, which is a 
> bit different than being able to write and execute arbitrary code thanks to a 
> file descriptor mapped RWX :)

Fair point. Please describe this in detail in the patch changelog. :-)

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] um: Use race-free temporary file creation

2015-11-28 Thread Mickaël Salaün

 +  errno != EOPNOTSUPP))
 +  return fd;
 +  errno = 0;
>>>
>>> Why are you resetting errno?
>>
>> It's to ignore/reset the error code from open, but it may not be needed 
>> because of the next call to malloc?
> 
> But then you'd have to reset errno after every syscall. :-)

OK, I will remove it then :)

 Mickaël



signature.asc
Description: OpenPGP digital signature


gpio-mxc: gpiod_get_value returns INT_MIN when the GPIO is off

2015-11-28 Thread Clemens Gruber
Hi,

I am writing a module which reads several GPIO input states from a
Freescale i.MX6Q. I can control the input states through hardware
buttons attached to my development board. They are all connected exactly
the same, with external pull up resistors.
I am using the current torvalds/linux master branch.

The list in my DT looks like this:
my-gpios = < 7 GPIO_ACTIVE_LOW>,
< 8 GPIO_ACTIVE_LOW>,
/*  */
< 31 GPIO_ACTIVE_LOW>,
< 11 GPIO_ACTIVE_LOW>;

In my platform driver module, I first call gpiod_get_array(dev, "my",
GPIOD_IN);

Then I can successfully read in the input states of my GPIOs and get
"correct" values for all but one of them: GPIO6_31
Meaning: When no button is pressed, every call to
gpiod_get_value(my_gpios->desc[i]) returns 0 and if one of the buttons
is pressed, it returns 1.
Except for gpio6 31: It returns -2^31 (INT_MIN) when no button is
pressed and 1 if a button is pressed.

I double checked the pinmuxing and the hardware, the input state should
be off / 0 and not -2^31. The internal pull up is also enabled.
Muxing: fsl,pins = ;

I read through the source of gpio-generic.c and came across
bgpio_get_set. If I interpret the code correctly, it is set as the get
function of the gpio chip. (because BGPIOF_READ_OUTPUT_REG_SET is passed
as flags argument when bgpio_init is called from gpio-mxc.c)
In the case of gpio6_31, the pin2mask function would return 1 << 31 as
unsigned long, meaning 2^31 and then the unsigned long return value of
read_reg is bitmasked with 2^31 which would result in 2^31 if it is on
and 0 if it is off.
But because gpiod_get_value returns an int, the 2^31 unsigned long is
casted to a signed int, which means it returns -2^31 if it is active.
But in this case, it returns -2^31 if it is inactive and 1 if it is
active...

I can workaround by checking gpiod_get_value(desc) == 1 but I'd really
like to know what's causing this (odd?) behavior.

Am I doing something wrong here?

Thanks,
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: epoll and multiple processes - eliminate unneeded process wake-ups

2015-11-28 Thread Madars Vitolins

Hi Jason,

I did recently tests with multiprocessing and epoll() on Posix Queues.
You were right about "EP_MAX_NESTS", it is not related with how many 
processes are waken up when multiple process epoll_waits are waiting on 
one event source.


At doing epoll every process is added to wait queue for every monitored 
event source. Thus when message is sent to some queue (for example), all 
processes polling on it are activated during mq_timedsend() -> 
__do_notify () -> wake_up(>wait_q) kernel processing.


So to get one message to be processed only by one process of 
epoll_wait(), it requires that process in event source's  wait queue is 
added with exclusive flag set.


I could create a kernel patch, by adding new EPOLLEXCL flag which could 
result in following functionality:


- fs/eventpoll.c

/*
 * This is the callback that is used to add our wait queue to the
 * target file wakeup lists.
 */
static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t 
*whead,

 poll_table *pt)
{
struct epitem *epi = ep_item_from_epqueue(pt);
struct eppoll_entry *pwq;

if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, 
GFP_KERNEL))) {

init_waitqueue_func_entry(>wait, ep_poll_callback);
pwq->whead = whead;
pwq->base = epi;

if (epi->event.events & EPOLLEXCL) {  New 
functionality here!!!

add_wait_queue_exclusive(whead, >wait);
} else {
add_wait_queue(whead, >wait);
}
list_add_tail(>llink, >pwqlist);
epi->nwait++;
} else {
/* We have to signal that an error occurred */
epi->nwait = -1;
}
}


After doing test with EPOLLEXCL set in my multiprocessing application 
framework (now it is open source: http://www.endurox.org/ :) ), results 
were good, there were no extra wakeups. Thus more efficient processing.


Jason, how do you think would mainline accept such patch with new flag? 
Or are there any concerns about this? Also this will mean that new flag 
will be need to add to GNU C Library (/usr/include/sys/epoll.h).


Or maybe somebody else who is familiar with kernel epoll functionality 
can comment this?


Regarding the flag's bitmask, seems like (1<<28) needs to be taken for 
EPOLLEXCL as flags type for epoll_event.events is int32 and last bit 
1<<31 is used by EPOLLET (in include/uapi/linux/eventpoll.h).


Thanks a lot in advance,
Madars


Jason Baron @ 2015-08-05 15:32 rakstīja:

On 08/05/2015 07:06 AM, Madars Vitolins wrote:

Jason Baron @ 2015-08-04 18:02 rakstīja:

On 08/03/2015 07:48 PM, Eric Wong wrote:

Madars Vitolins  wrote:

Hi Folks,

I am developing kind of open systems application, which uses
multiple processes/executables where each of them monitors some set
of resources (in this case POSIX Queues) via epoll interface. For
example when 10 processes on same queue are in state of 
epoll_wait()

and one message arrives, all 10 processes gets woken up and all of
them tries to read the message from Q. One succeeds, the others 
gets

EAGAIN error. The problem is with those others, which generates
extra context switches - useless CPU usage. With more processes
inefficiency gets higher.

I tried to use EPOLLONESHOT, but no help. Seems this is suitable 
for

multi-threaded application and not for multi-process application.


Correct.  Most FDs are not shared across processes.


Ideal mechanism for this would be:
1. If multiple epoll sets in kernel matches same event and one or
more processes are in state of epoll_wait() - then send event only
to one waiter.
2. If none of processes are in wait state, then send the event to
all epoll sets (as it is currently). Then the first free process
will grab the event.


Jason Baron was working on this (search LKML archives for
EPOLLEXCLUSIVE, EPOLLROUNDROBIN, EPOLL_ROTATE)

However, I was unconvinced about modifying epoll.

Perhaps I may be more easily convinced about your mqueue case than 
his

case for listen sockets, though[*]



Yeah, so I implemented an 'EPOLL_ROTATE' mode, where you could have
multiple epoll fds (or epoll sets) attached to the same wakeup 
source,

and have the wakeups 'rotate' among the epoll sets. The wakeup
essentially walks the list of waiters, wakes up the first thread
that is actively in epoll_wait(), stops and moves the woken up
epoll set to the end of the list. So it attempts to balance
the wakeups among the epoll sets, I think in the way that you
were describing.

Here is the patchset:

https://lkml.org/lkml/2015/2/24/667

The test program shows how to use the API. Essentially, you
have to create a 'dummy' epoll fd with the 'EPOLL_ROTATE' flag,
which you then attach to you're shared wakeup 

Re: [PATCH 2/2] um: Use race-free temporary file creation

2015-11-28 Thread Richard Weinberger
Am 28.11.2015 um 23:56 schrieb Mickaël Salaün:
> 
> On 28/11/2015 23:07, Richard Weinberger wrote:
>> Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
>>> Open the memory mapped file with the O_TMPFILE flag when available.
>>>
>>> Signed-off-by: Mickaël Salaün 
>>> ---
>>>  arch/um/os-Linux/mem.c | 12 
>>>  1 file changed, 12 insertions(+)
>>>
>>> diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
>>> index 798aeb4..fe52e2d 100644
>>> --- a/arch/um/os-Linux/mem.c
>>> +++ b/arch/um/os-Linux/mem.c
>>> @@ -106,6 +106,18 @@ static int __init make_tempfile(const char *template)
>>> }
>>> }
>>>  
>>> +#ifdef O_TMPFILE
>>> +   fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700);
>>> +   /*
>>> +* If the running system does not support O_TMPFILE flag then retry
>>> +* without it.
>>> +*/
>>> +   if (fd != -1 || (errno != EINVAL && errno != EISDIR &&
>>
>> Why are you handling EISDIR?
> 
> I follow the man page for open [1], I think it was a workaround needed for 
> some kernel versions just after the O_TMPFILE was added but before the 
> support for EOPNOTSUPP.
> We may need to add the EACCES too for some version of glibc [2, 3]?

Makes sense! :)

> 1. http://man7.org/linux/man-pages/man2/openat.2.html#BUGS
> 2. Commit 69a91c237ab0ebe4e9fdeaf6d0090c85275594ec and 
> https://sourceware.org/bugzilla/show_bug.cgi?id=17523
> 3. https://bugs.gentoo.org/529044
> 
>>
>>> +   errno != EOPNOTSUPP))
>>> +   return fd;
>>> +   errno = 0;
>>
>> Why are you resetting errno?
> 
> It's to ignore/reset the error code from open, but it may not be needed 
> because of the next call to malloc?

But then you'd have to reset errno after every syscall. :-)

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] um: Set secure access mode for temporary file

2015-11-28 Thread Richard Weinberger
Am 28.11.2015 um 23:52 schrieb Mickaël Salaün:
> 
> On 28/11/2015 22:40, Richard Weinberger wrote:
>> Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
>>> Replace the default insecure mode 0777 with 0700 for temporary file.
>>>
>>> Prohibit other users to change the executable mapped code.
>>
>> Hmm, isn't the tmp file already unlinked at this stage?
>>
> 
> Yes, but if someone could open it before the unlink e.g. because of the umask 
> (which does not seems to be the case thanks to mkstemp, but remains 
> unspecified [1]), this user should then be able to have write access to the 
> file descriptor/description.

Yes, someone can open it before the unlink. But you change the file mode after 
that.
How does it improve the situation? The attacker has already the file handle.

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] um: Set secure access mode for temporary file

2015-11-28 Thread Mickaël Salaün

On 28/11/2015 22:40, Richard Weinberger wrote:
> Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
>> Replace the default insecure mode 0777 with 0700 for temporary file.
>>
>> Prohibit other users to change the executable mapped code.
> 
> Hmm, isn't the tmp file already unlinked at this stage?
> 

Yes, but if someone could open it before the unlink e.g. because of the umask 
(which does not seems to be the case thanks to mkstemp, but remains unspecified 
[1]), this user should then be able to have write access to the file 
descriptor/description.

 Mickaël

1. http://man7.org/linux/man-pages/man3/mkstemp.3.html#NOTES




signature.asc
Description: OpenPGP digital signature


Re: [tpmdd-devel] [PATCH] base/platform: fix panic when probe function is NULL

2015-11-28 Thread Jason Gunthorpe
On Sat, Nov 28, 2015 at 06:40:03PM +0200, Jarkko Sakkinen wrote:
> > I have some patches to do this that are part of my OF enablement
> > series, but I can make something simpler that would deal with this
> > fairly quickly if you can test.
> 
> Does the patch set that you sent include the fix or not? I haven't yet
> reviewed them properly.

No fixing probe is another task. I can send some patches for that when
we are done with the IRQ stuff. That is something we should fix no
matter what..

BTW, please test my IRQ series, I forgot to mention I was unable to
test it properly here...

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] um: Set secure access mode for temporary file

2015-11-28 Thread Mickaël Salaün
Replace the default insecure mode 0777 with 0700 for temporary file.

Prohibit other users to change the executable mapped code.

Signed-off-by: Mickaël Salaün 
---
 arch/um/os-Linux/mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 897e9ad..798aeb4 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -142,7 +142,7 @@ static int __init create_tmp_file(unsigned long long len)
if (fd < 0)
exit(1);
 
-   err = fchmod(fd, 0777);
+   err = fchmod(fd, 0700);
if (err < 0) {
perror("fchmod");
exit(1);
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


awk: scripts/ld-version.sh: line 4: regular expression compile failed (missing '(')

2015-11-28 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   8003a573560ae96540bce2a698347c6d502e2997
commit: ebb5e78cc63417a35254a791de66e1cc84f963cc MIPS: Initial implementation 
of a VDSO
date:   3 weeks ago
config: mips-allnoconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout ebb5e78cc63417a35254a791de66e1cc84f963cc
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> awk: scripts/ld-version.sh: line 4: regular expression compile failed 
>> (missing '(')
   .*)
--
>> awk: scripts/ld-version.sh: line 4: regular expression compile failed 
>> (missing '(')
   .*)
   /bin/sh: line 0: [: -gt: unary operator expected
   arch/mips/vdso/Makefile:30: MIPS VDSO requires binutils > 2.24

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


.config.gz
Description: Binary data


[PATCH 2/2] um: Use race-free temporary file creation

2015-11-28 Thread Mickaël Salaün
Open the memory mapped file with the O_TMPFILE flag when available.

Signed-off-by: Mickaël Salaün 
---
 arch/um/os-Linux/mem.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 798aeb4..fe52e2d 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -106,6 +106,18 @@ static int __init make_tempfile(const char *template)
}
}
 
+#ifdef O_TMPFILE
+   fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700);
+   /*
+* If the running system does not support O_TMPFILE flag then retry
+* without it.
+*/
+   if (fd != -1 || (errno != EINVAL && errno != EISDIR &&
+   errno != EOPNOTSUPP))
+   return fd;
+   errno = 0;
+#endif
+
tempname = malloc(strlen(tempdir) + strlen(template) + 1);
if (tempname == NULL)
return -1;
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] um: Use race-free temporary file creation

2015-11-28 Thread Richard Weinberger
Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
> Open the memory mapped file with the O_TMPFILE flag when available.
> 
> Signed-off-by: Mickaël Salaün 
> ---
>  arch/um/os-Linux/mem.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
> index 798aeb4..fe52e2d 100644
> --- a/arch/um/os-Linux/mem.c
> +++ b/arch/um/os-Linux/mem.c
> @@ -106,6 +106,18 @@ static int __init make_tempfile(const char *template)
>   }
>   }
>  
> +#ifdef O_TMPFILE
> + fd = open(tempdir, O_CLOEXEC | O_RDWR | O_EXCL | O_TMPFILE, 0700);
> + /*
> +  * If the running system does not support O_TMPFILE flag then retry
> +  * without it.
> +  */
> + if (fd != -1 || (errno != EINVAL && errno != EISDIR &&

Why are you handling EISDIR?

> + errno != EOPNOTSUPP))
> + return fd;
> + errno = 0;

Why are you resetting errno?

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] um: Protect memory mapped file

2015-11-28 Thread Mickaël Salaün
These patches protect the memory mapped file.

Mickaël Salaün (2):
  um: Set secure access mode for temporary file
  um: Use race-free temporary file creation

 arch/um/os-Linux/mem.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] gpio: pxa: change the interrupt management

2015-11-28 Thread Robert Jarzmik
The interrupt management is changed by this patch to rely on chip data
instead of chained interrupts.

The main goal is to loosen the dependency on the global pxa chip
structure in favor of the passed chip data. The secondary goal is to
better show in /proc/interrupts the difference between interrupts for
gpio0 and gpio1 (directly wired to interrupt controller), and the other
gpios (wired onto a third line in the interrupt controller).

The last advantage of this patch is that the interrupt is actually
requested, so that another driver cannot steal this line, or overwrite
the handler.

Signed-off-by: Robert Jarzmik 
---
 drivers/gpio/gpio-pxa.c | 145 +++-
 1 file changed, 82 insertions(+), 63 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 8558abf98204..7e02157c5b92 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -64,11 +64,6 @@
 int pxa_last_gpio;
 static int irq_base;
 
-#ifdef CONFIG_OF
-static struct irq_domain *domain;
-static struct device_node *pxa_gpio_of_node;
-#endif
-
 struct pxa_gpio_bank {
void __iomem*regbase;
unsigned long   irq_mask;
@@ -87,6 +82,7 @@ struct pxa_gpio_chip {
struct device *dev;
struct gpio_chip chip;
struct pxa_gpio_bank *banks;
+   struct irq_domain *irqdomain;
 
int irq0;
int irq1;
@@ -231,14 +227,23 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip 
*pchip, unsigned gpio)
return ret;
 }
 
-static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+int pxa_irq_to_gpio(int irq)
 {
-   return offset + irq_base;
+   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
+   int irq_gpio0;
+
+   irq_gpio0 = irq_find_mapping(pchip->irqdomain, 0);
+   if (irq_gpio0 > 0)
+   return irq - irq_gpio0;
+
+   return irq_gpio0;
 }
 
-int pxa_irq_to_gpio(int irq)
+static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
-   return irq - irq_base;
+   struct pxa_gpio_chip *pchip = chip_to_pxachip(chip);
+
+   return irq_find_mapping(pchip->irqdomain, offset);
 }
 
 static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -314,7 +319,7 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 #endif
 
 static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
- void __iomem *regbase)
+ struct device_node *np, void __iomem *regbase)
 {
int i, gpio, nbanks = DIV_ROUND_UP(ngpio, 32);
struct pxa_gpio_bank *bank;
@@ -332,7 +337,7 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, 
int ngpio,
pchip->chip.to_irq = pxa_gpio_to_irq;
pchip->chip.ngpio = ngpio;
 #ifdef CONFIG_OF_GPIO
-   pchip->chip.of_node = pxa_gpio_of_node;
+   pchip->chip.of_node = np;
pchip->chip.of_xlate = pxa_gpio_of_xlate;
pchip->chip.of_gpio_n_cells = 2;
 #endif
@@ -362,8 +367,8 @@ static inline void update_edge_detect(struct pxa_gpio_bank 
*c)
 
 static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type)
 {
-   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
-   int gpio = pxa_irq_to_gpio(d->irq);
+   struct pxa_gpio_chip *pchip = irq_data_get_irq_chip_data(d);
+   unsigned int gpio = irqd_to_hwirq(d);
struct pxa_gpio_bank *c = gpio_to_pxabank(>chip, gpio);
unsigned long gpdr, mask = GPIO_bit(gpio);
 
@@ -405,16 +410,13 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned 
int type)
return 0;
 }
 
-static void pxa_gpio_demux_handler(struct irq_desc *desc)
+static irqreturn_t pxa_gpio_demux_handler(int in_irq, void *d)
 {
int loop, gpio, n, handled = 0;
unsigned long gedr;
-   struct irq_chip *chip = irq_desc_get_chip(desc);
-   struct pxa_gpio_chip *pchip = pxa_gpio_chip;
+   struct pxa_gpio_chip *pchip = d;
struct pxa_gpio_bank *c;
 
-   chained_irq_enter(chip, desc);
-
do {
loop = 0;
for_each_gpio_bank(gpio, c, pchip) {
@@ -428,15 +430,31 @@ static void pxa_gpio_demux_handler(struct irq_desc *desc)
generic_handle_irq(gpio_to_irq(gpio + n));
}
}
+   handled += loop;
} while (loop);
 
-   chained_irq_exit(chip, desc);
+   return handled ? IRQ_HANDLED : IRQ_NONE;
+}
+
+static irqreturn_t pxa_gpio_direct_handler(int in_irq, void *d)
+{
+   struct pxa_gpio_chip *pchip = d;
+
+   if (in_irq == pchip->irq0) {
+   generic_handle_irq(gpio_to_irq(0));
+   } else if (in_irq == pchip->irq1) {
+   generic_handle_irq(gpio_to_irq(1));
+   } else {
+   pr_err("%s() unknown irq %d\n", __func__, in_irq);
+   return IRQ_NONE;
+   }
+   return IRQ_HANDLED;
 }
 
 static void pxa_ack_muxed_gpio(struct irq_data *d)
 {
-   struct pxa_gpio_chip 

[PATCH 4/4] gpio: pxa: add pin control gpio direction and request

2015-11-28 Thread Robert Jarzmik
If a pin control driver is available, use it to change the gpio
direction. If not fallback to directly manipulating the gpio direction
register.

The reason to use the pin control driver first is that pin control in
pxa2xx architecture implies changing the gpio direction, even for non
gpio functions. In order to do it atomically, only one driver should
control the gpio direction, and if a pin controller is available, it has
to be him.

Signed-off-by: Robert Jarzmik 
---
 drivers/gpio/gpio-pxa.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 7e02157c5b92..01d507502d56 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -251,6 +252,11 @@ static int pxa_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
void __iomem *base = gpio_bank_base(chip, offset);
uint32_t value, mask = GPIO_bit(offset);
unsigned long flags;
+   int ret;
+
+   ret = pinctrl_gpio_direction_input(chip->base + offset);
+   if (!ret)
+   return 0;
 
spin_lock_irqsave(_lock, flags);
 
@@ -271,9 +277,14 @@ static int pxa_gpio_direction_output(struct gpio_chip 
*chip,
void __iomem *base = gpio_bank_base(chip, offset);
uint32_t tmp, mask = GPIO_bit(offset);
unsigned long flags;
+   int ret;
 
writel_relaxed(mask, base + (value ? GPSR_OFFSET : GPCR_OFFSET));
 
+   ret = pinctrl_gpio_direction_output(chip->base + offset);
+   if (!ret)
+   return 0;
+
spin_lock_irqsave(_lock, flags);
 
tmp = readl_relaxed(base + GPDR_OFFSET);
@@ -318,6 +329,16 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 }
 #endif
 
+static int pxa_gpio_request(struct gpio_chip *chip, unsigned int offset)
+{
+   return pinctrl_request_gpio(chip->base + offset);
+}
+
+static void pxa_gpio_free(struct gpio_chip *chip, unsigned int offset)
+{
+   pinctrl_free_gpio(chip->base + offset);
+}
+
 static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, int ngpio,
  struct device_node *np, void __iomem *regbase)
 {
@@ -336,6 +357,8 @@ static int pxa_init_gpio_chip(struct pxa_gpio_chip *pchip, 
int ngpio,
pchip->chip.set = pxa_gpio_set;
pchip->chip.to_irq = pxa_gpio_to_irq;
pchip->chip.ngpio = ngpio;
+   pchip->chip.request = pxa_gpio_request;
+   pchip->chip.free = pxa_gpio_free;
 #ifdef CONFIG_OF_GPIO
pchip->chip.of_node = np;
pchip->chip.of_xlate = pxa_gpio_of_xlate;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] gpio: pxa: convert to one gpiochip

2015-11-28 Thread Robert Jarzmik
The pxa gpio IP is provided by one chip, which holds multiple banks.

Another reason the driver should register only one gpiochip instead of
multiple gpiochips (ie. 1 per each bank) is that for pincontrol and
devicetree integration (think gpio-ranges), it's impossible to have the
contiguous pin range 0..127 mapped to gpios 0..127.

This patch, amongst other thinks, paves the path to loosen the bond with
the global structure variable pxa_gpio_chip.

Signed-off-by: Robert Jarzmik 
---
 drivers/gpio/gpio-pxa.c | 221 ++--
 1 file changed, 120 insertions(+), 101 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index df2ce550f309..de2cfbeccaa1 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -69,15 +69,11 @@ static struct irq_domain *domain;
 static struct device_node *pxa_gpio_of_node;
 #endif
 
-struct pxa_gpio_chip {
-   struct gpio_chip chip;
+struct pxa_gpio_bank {
void __iomem*regbase;
-   char label[10];
-
unsigned long   irq_mask;
unsigned long   irq_edge_rise;
unsigned long   irq_edge_fall;
-   int (*set_wake)(unsigned int gpio, unsigned int on);
 
 #ifdef CONFIG_PM
unsigned long   saved_gplr;
@@ -87,6 +83,16 @@ struct pxa_gpio_chip {
 #endif
 };
 
+struct pxa_gpio_chip {
+   struct device *dev;
+   struct gpio_chip chip;
+   struct pxa_gpio_bank *banks;
+
+   int irq0;
+   int irq1;
+   int (*set_wake)(unsigned int gpio, unsigned int on);
+};
+
 enum pxa_gpio_type {
PXA25X_GPIO = 0,
PXA26X_GPIO,
@@ -104,9 +110,8 @@ struct pxa_gpio_id {
 };
 
 static DEFINE_SPINLOCK(gpio_lock);
-static struct pxa_gpio_chip *pxa_gpio_chips;
+static struct pxa_gpio_chip *pxa_gpio_chip;
 static enum pxa_gpio_type gpio_type;
-static void __iomem *gpio_reg_base;
 
 static struct pxa_gpio_id pxa25x_id = {
.type   = PXA25X_GPIO,
@@ -148,17 +153,27 @@ static struct pxa_gpio_id pxa1928_id = {
.gpio_nums  = 224,
 };
 
-#define for_each_gpio_chip(i, c)   \
-   for (i = 0, c = _gpio_chips[0]; i <= pxa_last_gpio; i += 32, c++)
+#define for_each_gpio_bank(i, b, pc)   \
+   for (i = 0, b = pc->banks; i <= pxa_last_gpio; i += 32, b++)
 
-static inline void __iomem *gpio_chip_base(struct gpio_chip *c)
+static inline struct pxa_gpio_chip *chip_to_pxachip(struct gpio_chip *c)
 {
-   return container_of(c, struct pxa_gpio_chip, chip)->regbase;
+   struct pxa_gpio_chip *pxa_chip =
+   container_of(c, struct pxa_gpio_chip, chip);
+
+   return pxa_chip;
 }
+static inline void __iomem *gpio_bank_base(struct gpio_chip *c, int gpio)
+{
+   struct pxa_gpio_bank *bank = chip_to_pxachip(c)->banks + (gpio / 32);
 
-static inline struct pxa_gpio_chip *gpio_to_pxachip(unsigned gpio)
+   return bank->regbase;
+}
+
+static inline struct pxa_gpio_bank *gpio_to_pxabank(struct gpio_chip *c,
+   unsigned gpio)
 {
-   return _gpio_chips[gpio_to_bank(gpio)];
+   return chip_to_pxachip(c)->banks + gpio / 32;
 }
 
 static inline int gpio_is_pxa_type(int type)
@@ -187,15 +202,13 @@ static inline int __gpio_is_inverted(int gpio)
  * is attributed as "occupied" here (I know this terminology isn't
  * accurate, you are welcome to propose a better one :-)
  */
-static inline int __gpio_is_occupied(unsigned gpio)
+static inline int __gpio_is_occupied(struct pxa_gpio_chip *pchip, unsigned 
gpio)
 {
-   struct pxa_gpio_chip *pxachip;
void __iomem *base;
unsigned long gafr = 0, gpdr = 0;
int ret, af = 0, dir = 0;
 
-   pxachip = gpio_to_pxachip(gpio);
-   base = gpio_chip_base(>chip);
+   base = gpio_bank_base(>chip, gpio);
gpdr = readl_relaxed(base + GPDR_OFFSET);
 
switch (gpio_type) {
@@ -220,7 +233,7 @@ static inline int __gpio_is_occupied(unsigned gpio)
 
 static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
-   return chip->base + offset + irq_base;
+   return offset + irq_base;
 }
 
 int pxa_irq_to_gpio(int irq)
@@ -230,8 +243,8 @@ int pxa_irq_to_gpio(int irq)
 
 static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 {
-   void __iomem *base = gpio_chip_base(chip);
-   uint32_t value, mask = 1 << offset;
+   void __iomem *base = gpio_bank_base(chip, offset);
+   uint32_t value, mask = GPIO_bit(offset);
unsigned long flags;
 
spin_lock_irqsave(_lock, flags);
@@ -250,8 +263,8 @@ static int pxa_gpio_direction_input(struct gpio_chip *chip, 
unsigned offset)
 static int pxa_gpio_direction_output(struct gpio_chip *chip,
 unsigned offset, int value)
 {
-   void __iomem *base = gpio_chip_base(chip);
-   uint32_t tmp, mask = 1 << offset;
+   void __iomem *base = gpio_bank_base(chip, offset);
+   uint32_t tmp, mask = 

[PATCH 2/4] gpio: pxa: convert to devm_ioremap

2015-11-28 Thread Robert Jarzmik
Use the device managed ioremap to simplify the probe function.

Signed-off-by: Robert Jarzmik 
---
 drivers/gpio/gpio-pxa.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index de2cfbeccaa1..8558abf98204 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -614,9 +614,8 @@ static int pxa_gpio_probe(struct platform_device *pdev)
|| (irq_mux <= 0))
return -EINVAL;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res)
-   return -EINVAL;
-   gpio_reg_base = ioremap(res->start, resource_size(res));
+   gpio_reg_base = devm_ioremap(>dev, res->start,
+resource_size(res));
if (!gpio_reg_base)
return -EINVAL;
 
@@ -627,13 +626,11 @@ static int pxa_gpio_probe(struct platform_device *pdev)
if (IS_ERR(clk)) {
dev_err(>dev, "Error %ld to get gpio clock\n",
PTR_ERR(clk));
-   iounmap(gpio_reg_base);
return PTR_ERR(clk);
}
ret = clk_prepare_enable(clk);
if (ret) {
clk_put(clk);
-   iounmap(gpio_reg_base);
return ret;
}
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/4] gpio: pxa: integrate with pincontrol

2015-11-28 Thread Robert Jarzmik
Hi Linus, Alexandre and Haojian,

This serie aims at several cleanups and improvements in the pxa gpio driver, to
support integration with pin control.

Amongst the changes, the main points are :
 - removal of as many global variables as possible
 - use of devm_*() function when applicable
 - use of irqdomain
 - use of pinctrl functions when available

Haojian, I've tested that on pxa27x, in both platform_data and devicetree
builds. Nevertheless I'd feel better if others architectures were tested,
especially mmp ones and pxa1928, which I don't have home.

Happy review.

Robert Jarzmik (4):
  gpio: pxa: convert to one gpiochip
  gpio: pxa: convert to devm_ioremap
  gpio: pxa: change the interrupt management
  gpio: pxa: add pin control gpio direction and request

 drivers/gpio/gpio-pxa.c | 370 
 1 file changed, 214 insertions(+), 156 deletions(-)

-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] um: Set secure access mode for temporary file

2015-11-28 Thread Richard Weinberger
Am 28.11.2015 um 22:32 schrieb Mickaël Salaün:
> Replace the default insecure mode 0777 with 0700 for temporary file.
> 
> Prohibit other users to change the executable mapped code.

Hmm, isn't the tmp file already unlinked at this stage?

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] spi: tools: move spidev_test metadata

2015-11-28 Thread Joshua Clayton
Now that spidev_test and spidev_fdx have been moved, remove them
from the Documentation index and move their .gitignore file.

Signed-off-by: Joshua Clayton 
---
 Documentation/spi/.gitignore | 2 --
 Documentation/spi/00-INDEX   | 4 
 tools/spi/.gitignore | 2 ++
 3 files changed, 2 insertions(+), 6 deletions(-)
 delete mode 100644 Documentation/spi/.gitignore
 create mode 100644 tools/spi/.gitignore

diff --git a/Documentation/spi/.gitignore b/Documentation/spi/.gitignore
deleted file mode 100644
index 4280576..000
--- a/Documentation/spi/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-spidev_fdx
-spidev_test
diff --git a/Documentation/spi/00-INDEX b/Documentation/spi/00-INDEX
index a128fa8..4644bf0 100644
--- a/Documentation/spi/00-INDEX
+++ b/Documentation/spi/00-INDEX
@@ -10,13 +10,9 @@ pxa2xx
- PXA2xx SPI master controller build by spi_message fifo wq
 spidev
- Intro to the userspace API for spi devices
-spidev_fdx.c
-   - spidev example file
 spi-lm70llp
- Connecting an LM70-LLP sensor to the kernel via the SPI subsys.
 spi-sc18is602
- NXP SC18IS602/603 I2C-bus to SPI bridge
 spi-summary
- (Linux) SPI overview. If unsure about SPI or SPI in Linux, start here.
-spidev_test.c
-   - SPI testing utility.
diff --git a/tools/spi/.gitignore b/tools/spi/.gitignore
new file mode 100644
index 000..4280576
--- /dev/null
+++ b/tools/spi/.gitignore
@@ -0,0 +1,2 @@
+spidev_fdx
+spidev_test
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] regulator: fixed: Add support for regmap

2015-11-28 Thread Simon Arlott
Use the device tree properties for regmap:
* Lookup the regmap phandle
* Use the enable offset and enable mask
* Reuse enable-active-high value

Use an alternative set of regulator_ops when the regmap is set,
specifying the regmap helper functions.

As syscon_regmap_lookup_by_phandle() can only return -ENODEV or -ENOSYS
as errors and -EPROBE_DEFER doesn't make sense for a register, the
specific error is never propagated.

This is required for Broadcom BCM63xx SoCs that enable power to
individual peripherals by clearing a bit in the miscIddqCtrl register.

Signed-off-by: Simon Arlott 
---
 drivers/regulator/fixed.c   | 30 +-
 include/linux/regulator/fixed.h |  9 -
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index ff62d69..5a3fa44 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct fixed_voltage_data {
struct regulator_desc desc;
@@ -92,6 +93,19 @@ of_get_fixed_voltage_config(struct device *dev,
if ((config->gpio == -ENODEV) || (config->gpio == -EPROBE_DEFER))
return ERR_PTR(-EPROBE_DEFER);
 
+   config->regmap = syscon_regmap_lookup_by_phandle(np, "regmap");
+   if (!IS_ERR(config->regmap)) {
+   u32 val;
+
+   if (of_property_read_u32(np, "regmap-offset", ))
+   return ERR_PTR(-EINVAL);
+   config->enable_reg = val;
+
+   if (of_property_read_u32(np, "regmap-mask", ))
+   return ERR_PTR(-EINVAL);
+   config->enable_mask = val;
+   }
+
of_property_read_u32(np, "startup-delay-us", >startup_delay);
 
config->enable_high = of_property_read_bool(np, "enable-active-high");
@@ -107,6 +121,12 @@ of_get_fixed_voltage_config(struct device *dev,
 static struct regulator_ops fixed_voltage_ops = {
 };
 
+static struct regulator_ops fixed_voltage_regmap_ops = {
+   .enable = regulator_enable_regmap,
+   .disable = regulator_disable_regmap,
+   .is_enabled = regulator_is_enabled_regmap,
+};
+
 static int reg_fixed_voltage_probe(struct platform_device *pdev)
 {
struct fixed_voltage_config *config;
@@ -140,7 +160,15 @@ static int reg_fixed_voltage_probe(struct platform_device 
*pdev)
}
drvdata->desc.type = REGULATOR_VOLTAGE;
drvdata->desc.owner = THIS_MODULE;
-   drvdata->desc.ops = _voltage_ops;
+   if (!IS_ERR_OR_NULL(config->regmap)) {
+   drvdata->desc.ops = _voltage_regmap_ops;
+   cfg.regmap = config->regmap;
+   drvdata->desc.enable_reg = config->enable_reg;
+   drvdata->desc.enable_mask = config->enable_mask;
+   drvdata->desc.enable_is_inverted = !config->enable_high;
+   } else {
+   drvdata->desc.ops = _voltage_ops;
+   }
 
drvdata->desc.enable_time = config->startup_delay;
 
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h
index 48918be..7cec0d1 100644
--- a/include/linux/regulator/fixed.h
+++ b/include/linux/regulator/fixed.h
@@ -26,6 +26,10 @@ struct regulator_init_data;
  * @microvolts:Output voltage of regulator
  * @gpio:  GPIO to use for enable control
  * set to -EINVAL if not used
+ * @regmap:Regmap to use for enable control
+ * set to -ENODEV if not used
+ * @enable_reg:Register for control when using regmap
+ * @enable_mask:   Mask for control when using regmap
  * @startup_delay: Start-up time in microseconds
  * @gpio_is_open_drain: Gpio pin is open drain or normal type.
  * If it is open drain type then HIGH will be set
@@ -33,7 +37,7 @@ struct regulator_init_data;
  * and low will be set as gpio-output with driven
  * to low. For non-open-drain case, the gpio will
  * will be in output and drive to low/high accordingly.
- * @enable_high:   Polarity of enable GPIO
+ * @enable_high:   Polarity of enable GPIO/regmap
  * 1 = Active high, 0 = Active low
  * @enabled_at_boot:   Whether regulator has been enabled at
  * boot or not. 1 = Yes, 0 = No
@@ -50,6 +54,9 @@ struct fixed_voltage_config {
const char *input_supply;
int microvolts;
int gpio;
+   struct regmap *regmap;
+   unsigned int enable_reg;
+   unsigned int enable_mask;
unsigned startup_delay;
unsigned gpio_is_open_drain:1;
unsigned enable_high:1;
-- 
2.1.4

-- 
Simon Arlott
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] regulator: Add regmap support to regulator-fixed device tree binding

2015-11-28 Thread Simon Arlott
Add properties for regmap to the regulator-fixed device tree binding:
* Reference the regmap phandle
* Specify the enable offset and enable mask
* Reuse enable-active-high for regmap

This is required for Broadcom BCM63xx SoCs that enable power to
individual peripherals by clearing a bit in the miscIddqCtrl register.

Signed-off-by: Simon Arlott 
---
 .../bindings/regulator/fixed-regulator.txt  | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt 
b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
index 4fae41d..b499a65 100644
--- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
@@ -5,13 +5,18 @@ Required properties:
 
 Optional properties:
 - gpio: gpio to use for enable control
+- regmap: regmap phandle to use for enable control
+- regmap-offset: register offset when using regmap for enable control
+- regmap-mask: register enable mask when using regmap for enable control
 - startup-delay-us: startup time in microseconds
-- enable-active-high: Polarity of GPIO is Active high
+- enable-active-high: Polarity of GPIO/regmap is Active high
 If this property is missing, the default assumed is Active low.
 - gpio-open-drain: GPIO is open drain type.
   If this property is missing then default assumption is false.
 -vin-supply: Input supply name.
 
+Only one of gpio/regmap should be specified.
+
 Any property defined as part of the core regulator
 binding, defined in regulator.txt, can also be used.
 However a fixed voltage regulator is expected to have the
@@ -32,3 +37,17 @@ Example:
gpio-open-drain;
vin-supply = <_reg>;
};
+
+   xyz: fixedregulator@1 {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-supply";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regmap = <>;
+   regmap-offset = <0x4>;
+   regmap-mask = <0x200>;
+   startup-delay-us = <7>;
+   enable-active-high;
+   regulator-boot-on;
+   vin-supply = <_reg>;
+   };
-- 
2.1.4

-- 
Simon Arlott
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] ARM: dt: mvebu: ix4-300d: remove whole flash partition

2015-11-28 Thread Andrew Lunn
>On Sat, Nov 28, 2015 at 12:14:05PM +0100, Sebastian Hesselbarth wrote:
> Current NAND node has an additional flash partition for the whole
> flash overlapping with real partitions. Remove this partition as
> the whole flash is already represented by the NAND device itself.
> 
> Signed-off-by: Sebastian Hesselbarth 

Given Benoit comment

Acked-by: Andrew Lunn 

  Andrew
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/5] arm: boot: store ATAGs structure into DT "/chosen/linux,atags" entry

2015-11-28 Thread Frank Rowand
On 11/28/2015 9:34 AM, Nicolas Pitre wrote:
> On Sat, 28 Nov 2015, Russell King - ARM Linux wrote:
> 
>> On Fri, Nov 27, 2015 at 06:28:50PM -0500, Nicolas Pitre wrote:
>>> On Fri, 27 Nov 2015, Arnd Bergmann wrote:
>>>
 I don't mind creating the /proc/atags compatibility hack from the kernel
 for a DT based N700 kernel, as long as we limit it as much as we can
 to the machines that need it. Leaving a board file for the N700 in place
 that contains the procfs code (and not much more) seems reasonable
 here, as we are talking about a board specific hack and the whole point
 appears to be running unmodified user space.

 Regarding how to get the data into the kernel in the first place, my
 preferred choice would still be to have an intermediate bootloader
 such as pxa-impedance-matcher, but I won't complain if others are
 happy enough about putting it into the ATAGS compat code we already
 have, as long as it's limited to the boards we know need it.
>>>
>>> Assuming you have a N700 board file for special procfs code, then why 
>>> not getting at the atags in memory where the bootloader has put them 
>>> directly from that same board file? This way it'll really be limited to 
>>> the board we know needs it and the special exception will be contained 
>>> to that one file.  Amongst the machine specific hooks, there is one that 
>>> gets invoked early during boot before those atags are overwritten.
>>
>> I've already suggested that.
> 
> Good. And Arnd likes the idea too. So we might be converging at last 
> which is a good thing.

It makes me happy too.

-Frank

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[radeon agp] add blacklist for thinkpad T40p

2015-11-28 Thread Pavel Machek

Thinkpad T40p needs agpmode 1.

Signed-off-by: Pavel Machek 

diff --git a/drivers/gpu/drm/radeon/radeon_agp.c 
b/drivers/gpu/drm/radeon/radeon_agp.c
index fe994aa..c77d349 100644
--- a/drivers/gpu/drm/radeon/radeon_agp.c
+++ b/drivers/gpu/drm/radeon/radeon_agp.c
@@ -54,6 +54,9 @@ static struct radeon_agpmode_quirk 
radeon_agpmode_quirk_list[] = {
/* Intel 82855PM host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 
(lp #195051) */
{ PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4e50,
PCI_VENDOR_ID_IBM, 0x0550, 1},
+   /* Intel 82855PM host bridge / RV250/M9 GL [Mobility FireGL 9000/Radeon 
9000] needs AGPMode 1 (Thinkpad T40p) */
+   { PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4c66,
+   PCI_VENDOR_ID_IBM, 0x054d, 1},
/* Intel 82855PM host bridge / Mobility M7 needs AGPMode 1 */
{ PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4c57,
PCI_VENDOR_ID_IBM, 0x0530, 1},

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[radeon r100] when ring test fails, provide users with option to test

2015-11-28 Thread Pavel Machek

Ring test failure is often caused by too high agpmode. Tell the user
what to try.

Signed-off-by: Pavel Machek 

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 238b13f..32b1917 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -3665,7 +3665,7 @@ int r100_ring_test(struct radeon_device *rdev, struct 
radeon_ring *ring)
if (i < rdev->usec_timeout) {
DRM_INFO("ring test succeeded in %d usecs\n", i);
} else {
-   DRM_ERROR("radeon: ring test failed (scratch(0x%04X)=0x%08X)\n",
+   DRM_ERROR("radeon: ring test failed (scratch(0x%04X)=0x%08X), 
try radeon.agpmode=1?\n",
  scratch, tmp);
r = -EINVAL;
}

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


strange s2ram problems with the XFX Radeon R7 240 graphics card

2015-11-28 Thread Elmar Stellnberger
After an upgrade of my graphics card s2ram does no more work (newest 
test so far: 4.2.5-1-ARCH):

old card: XFX Radeon R5 230 (s2ram working)
new card: XFX Radeon R7 240 (s2ram not working)
(computer: Fujitsu Esprimo E5730, Core 2 Quad)

kernel parameters where s2ram does not use to work:
radeon.modeset=0 radeon.blacklist=1 no_console_suspend

However on a single test it was working including all the suggested 
steps as freezer/devices/platform/processor/core >/sys/power/pm_test


See for the details at: 
https://bugzilla.kernel.org/show_bug.cgi?id=108541 (logs say sth. about 
WakeOnLAN and system wakeup disabled by acpi; just have a look.)

I`d suggest to direct further discussion at the report.

Have Thanks,
Elmar

p.s.: the R7 card is 2GB, passively cooled, low/normal profile an works 
well in 3840x2160/UHD.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 0/3] Add PWM clock support for bcm2835

2015-11-28 Thread Stefan Wahren

Hi Remi,
hi Eric,

Am 11.11.2015 um 15:22 schrieb Remi Pommarel:

Hi,

This patchset adds support for pwm clock. At boot, this clock does not have a
default parent nor a default rate set. Thus we should be able to change its
parent to get this clock working. The current clock implementation is using a
mux to select the parent, but these clocks need to add a password (0x5a) in
higher register bits when changing parent. So a generic mux cannot be used
here.

The two first patches fix the clock parent selection, while the second one is
actually adding the pwm clock registration.

Changes since v1:
- determine_rate now based its parent selection upon divided rate
  instead of the parent one
- bcm2835_clock_choose_div has been modified to produce an avarage rate
  lower or equal to the requested one
- devicetree modifications have removed to be send in another patch



i applied the series including the devicetree modification, but it 
doesn't work for me.


First of all i get an ugly division by zero warning from the pwm driver. 
The pwm driver still assume a fixed clock and doesn't handle the error 
cases of clk_get_rate(). I attached a patch at the end.


The reason in my case why clk_get_rate() returns zero is that the pwm 
clock is orphan ( pwm is listed under 
/sys/kernel/debug/clk_orphan_summary ).


My suspicion is it has something to do with the clock manager driver.
The bcm2835_clock_per_parents contains only 8 entries. But according to
BCM2835-ARM-Peripherals.pdf [1] CM_GP0CTL SRC page 107 has 16 entries. 
The upper 8 entries are all mapped to GND. It looks to me that the 
driver doesn't take care of this and so the pwm clock isn't able to 
determine it's parent.


Best regards
Stefan

[1] - 
https://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf


-->8--
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index b4c7f95..49e28df 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -29,7 +29,6 @@
 struct bcm2835_pwm {
struct pwm_chip chip;
struct device *dev;
-   unsigned long scaler;
void __iomem *base;
struct clk *clk;
 };
@@ -66,6 +65,15 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, 
struct pwm_device *pwm,

  int duty_ns, int period_ns)
 {
struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
+   unsigned long rate = clk_get_rate(pc->clk);
+   unsigned long scaler;
+
+   if (rate <= 0) {
+   dev_err(pc->dev, "Invalid clock rate: %ld\n", rate);
+   return -EINVAL;
+   }
+
+   scaler = NSEC_PER_SEC / rate;

if (period_ns <= MIN_PERIOD) {
dev_err(pc->dev, "period %d not supported, minimum %d\n",
@@ -73,8 +81,8 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, 
struct pwm_device *pwm,

return -EINVAL;
}

-   writel(duty_ns / pc->scaler, pc->base + DUTY(pwm->hwpwm));
-   writel(period_ns / pc->scaler, pc->base + PERIOD(pwm->hwpwm));
+   writel(duty_ns / scaler, pc->base + DUTY(pwm->hwpwm));
+   writel(period_ns / scaler, pc->base + PERIOD(pwm->hwpwm));

return 0;
 }
@@ -156,8 +164,6 @@ static int bcm2835_pwm_probe(struct platform_device 
*pdev)

if (ret)
return ret;

-   pc->scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
-
pc->chip.dev = >dev;
pc->chip.ops = _pwm_ops;
pc->chip.npwm = 2;



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/4] ARM: dt: mvebu: ix4-300d: remove whole flash partition

2015-11-28 Thread Benoit Masson
>From mobile

> Le 28 nov. 2015 à 18:38, Sebastian Hesselbarth 
>  a écrit :
>
>> On 28.11.2015 17:52, Andrew Lunn wrote:
>>> On Sat, Nov 28, 2015 at 12:14:05PM +0100, Sebastian Hesselbarth wrote:
>>> Current NAND node has an additional flash partition for the whole
>>> flash overlapping with real partitions. Remove this partition as
>>> the whole flash is already represented by the NAND device itself.
>>
>> If i remember correctly, we discussed this when the contribution was
>> made. I think the stock firmware might use this for applying updates.
>> Maybe Benoit can comment?
>
> Yes, please.
>From my memory since I'm not running the stock firmware it uses the
MTD device directly. This is safe to remove. I was not very contort
able with this flash dts part it was copied over from a netgear mevbu
device ...

>
>> If so, removing this will break compatibility with stock firmware. Do
>> we want to do that? There are a few other mvebu dts files with a
>> partition spanning the whole flash. Should we remove them as well?
>
> Well, there is already a mtd device that spans the whole flash so
> what is the purpose of another "partition" that isn't a part but
> all of the device? Actually, I doubt that a FW update will wipe
> the flash as a whole, i.e. including boot loader, boot env, user
> config.
>
> Anyway, let's see if Benoit can shed some light on this.
>
> FWIW, neither single partitions nor a combined partitions node
> should be a direct sub-node of the _controller_ but a NAND
> _device_ node instead. Luckily, multi-device systems are not that
> common, so I guess we wait with it until such a system pops up for
> testing.
>
> Sebastian
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/10] Input: synaptics-rmi4: Add device tree support for 2d sensors and F11

2015-11-28 Thread Andrew Duggan

Hi Rob,

Thanks for reviewing! I will incorporate your feedback into the next 
version.


Andrew

On 11/27/2015 01:10 PM, Rob Herring wrote:

On Wed, Nov 25, 2015 at 04:09:13PM -0800, Andrew Duggan wrote:

2D sensors have several parameter which can be set in the platform data.
This patch adds support for getting those values from devicetree.

Signed-off-by: Andrew Duggan 
---
  .../bindings/input/rmi4/rmi_2d_sensor.txt  |  54 +++
  drivers/input/rmi4/rmi_2d_sensor.c | 103 +
  drivers/input/rmi4/rmi_2d_sensor.h |   3 +
  drivers/input/rmi4/rmi_f11.c   |   7 +-
  4 files changed, 166 insertions(+), 1 deletion(-)
  create mode 100644 
Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt

diff --git a/Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt 
b/Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt
new file mode 100644
index 000..bbff31b
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt
@@ -0,0 +1,54 @@
+Synaptics RMI4 2D Sensor Device Binding
+
+The Synaptics RMI4 core is able to support RMI4 devices using differnet

s/differnet/different/


+transports and differnet functions. This file describes the device tree

ditto.


+bindings for devices which contain 2D sensors using Function 11 or
+Function 12. Complete documentation for transports and other functions
+can be found in:
+Documentation/devicetree/bindings/input/rmi4.
+
+RMI4 Function 11 and Function 12 are for 2D touch position sensing.
+Additional documentation for F11 can be found at:
+http://www.synaptics.com/sites/default/files/511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf
+
+Optional Properties:
+- syna,swap-axes: Swap X and Y positions when reporting (boolean).
+- syna,flip-x: Reverse the direction of X (boolean).
+- syna,flip-y: Reverse the direction of Y (boolean).

We already have similar, generic properties for these.


+- syna,clip-x-low: Sets a minimum value for X.
+- syna,clip-y-low: Sets a minimum value for Y.
+- syna,clip-x-high: Sets a maximum value for X.
+- syna,clip-y-high: Sets a maximum value for Y.
+- syna,offset-x: Add an offset to X.
+- syna,offset_y: Add an offset to Y.

Don't use "_".


+- syna,delta-x-threshold: Set the minimum distance on the X axis required
+   to generate an interrupt in reduced reporting
+   mode.
+- syna,delta-y-threshold: Set the minimum distance on the Y axis required
+   to generate an interrupt in reduced reporting
+   mode.
+- syna,type-a: Report type A multitouch events.
+- syna,sensor-type: Set the sensor type. 1 for touchscreen 2 for touchpad.
+- syna,x-mm: The length in millimeters of the X axis.
+- syna,y-mm: The length in millimeters of the Y axis.

I think some of these have common properties defined too. If not, we
should add them.


+- syna,disable-report-mask: Mask for disabling posiiton reporting. Used to
+   disable reporing absolute position data.
+- syna,rezero-wait: Time in miliseconds to wait after issuing a rezero
+   command.

Add -msec suffix.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 00/10] Input: synaptics-rmi4: Synaptics RMI4 Driver rebased on 4.3

2015-11-28 Thread Andrew Duggan



On 11/26/2015 02:41 AM, Benjamin Tissoires wrote:

Hi Andrew,

On Nov 25 2015 or thereabouts, Andrew Duggan wrote:

This is a new patch series which squashes all of the development
history of the RMI4 driver into patches based on functionality. The
first patch adds the core RMI4 functionality needed by all RMI4 devices
and then the additional patches add transport and function drivers for
supporting various devices.

Thanks for this hard work. I did not do a full review of the series yet,
but caught some general design questions that I am writing here.


Touchpads which are currently using hid-rmi should have the same
functionality, but now knowledge of RMI is handled in the core instead

I tried applying the series on top of a 4.4-rc2, and git am failed. I
think it's good to keep this one in the series, but we might want to
postpone its application when rmi4 hits Linus' tree so Jiri will be able
to take it without conflicting with Dmitry's tree. Well, Jiri and Dmitry
can sort this out :)


I forgot there were in changes to hid-rmi in 4.4. I can fix it up to 
work with whatever version the core ends up being applied to.



of in hid-rmi. These patches also provide basic finger reporting for a
wide range of RMI4 touchscreens connected to I2C and SPI busses.
However, additional work may need to be done to implement product specific
features.

I tried to include all of the feedback I received from the previous
patches I posted. However, I did not come up with a satisfactory solution
for allowing function drivers to be built as modules. I think it is fine
to allow function drivers to be enabled or disabled in the core at build

I agree. I do not like the implementation however (I know, I contributed
a lot to it). How about we keep a static array of struct
rmi_function_handler? If we add a .registered file in struct
rmi_function_handler, we could simplify the registering/unregistering of
the functions more easily by looping through the array.


Sounds like a good idea. Right you it takes several lines in multiple 
files to register and unregister function drivers and its really easy to 
forget something.



time. However, if supporting function drivers as modules is a must have
for upstreaming I can continue to try to find a solution. Also, I went
ahead and removed support for polling.

Thanks for removing polling.

I have 2 other general concerns for rmi_bus:
- interrupts:
the current implementation has 2 type of interrupt handling depending on
the transport driver: either generic irqs or specific ones that are
triggered by the transport driver.

I think it would make sense to remove the generic irq handling in rmi4_bus
and let the transport driver handle it. This way, it will be easier for
the transport driver to decide whether or not forwarding the interrupts to
the bus.

This is what is done with the HID bus for the record. The transport
driver calls hid_input_report() when an irq has been processed.


The driver was handling the IRQs originally to avoid duplicating a lot 
of code in each of the transport devices. But, now that the custom GPIO 
code has been removed the reasoning for handling it in rmi_driver is 
less compelling. Plus, now we have SMBus and HID transports which don't 
handle the IRQs directly. It might also be better to enable and disable 
IRQs in the transport drivers pm callbacks.



- suspend/resume:
with the smbus implementation, we have quite some troubles with the
suspend/resume part. The reason is that both the rmi_bus and the serio
bus are registering to the pm subsystem and this leads to races between
them. Our current solution is to disable the pm registering in rmi_bus
and let the transport driver handle it at his level (which is in fine
triggered by the serio pm resume actually, not its own pm registration).


The interaction between the SMBus and the PS/2 interface does complicate 
things. I have not noticed any similar issues with PS/2 + HID/I2C. 
Probably, because PS/2 + HID/I2C was designed to work without any driver 
interaction.



I wonder if having the pm functions directly in the bus is a good idea
and if we should not let the transport driver handle those. We should
still keep the rmi specific functions in rmi_core/bus, I am just talking
about the registration of the bus to the subsystem.


I guess we could just call rmi_driver_suspend/resume() from the 
transports and have it loop through all of the function drivers and call 
their suspend/resume functions. So far it has just made sense to use the 
pm subsystem instead of doing things manually. But, none of the other 
transports have dependencies on devices in separate driver stacks.



[just thinking out loud: maybe we encounter problems of ordering due to
the fact that the bus is registered to the pm subsystem. Maybe if the
device itself in the transport driver registers, there will be guarantee
that the serio resume is called before the rmi_smbus one, which would
solve our problems].


Well if rmi_smbus can 

[GIT PULL] PCI fixes for v4.4

2015-11-28 Thread Bjorn Helgaas
Hi Linus,

Here are a few fixes I'd like to have in v4.4: a generic one for sysfs and
three for HiSilicon and DesignWare host controllers.

Bjorn


The following changes since commit 1ec218373b8ebda821aec00bb156a9c94fad9cd4:

  Linux 4.4-rc2 (2015-11-22 16:45:59 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git 
tags/pci-v4.4-fixes-1

for you to fetch changes up to 7c7a0e945349a3d0d497d7f32db6ed33d4031110:

  ARM/PCI: Move align_resource function pointer to pci_host_bridge structure 
(2015-11-25 13:23:38 -0600)


PCI updates for v4.4:

  NUMA
Prevent out of bounds access in numa_node override (Mathias Krause)

  HiSilicon host bridge driver
Fix deferred probing (Arnd Bergmann)

  Synopsys DesignWare host bridge driver
Remove incorrect io_base assignment (Stanimir Varbanov)
Move align_resource function pointer to pci_host_bridge structure (Gabriele 
Paoloni)


Arnd Bergmann (1):
  PCI: hisi: Fix deferred probing

Gabriele Paoloni (1):
  ARM/PCI: Move align_resource function pointer to pci_host_bridge structure

Mathias Krause (1):
  PCI: Prevent out of bounds access in numa_node override

Stanimir Varbanov (1):
  PCI: designware: Remove incorrect io_base assignment

 arch/arm/kernel/bios32.c   | 19 +++
 drivers/pci/host/pcie-designware.c |  1 -
 drivers/pci/host/pcie-hisi.c   |  4 ++--
 drivers/pci/pci-sysfs.c|  5 -
 drivers/pci/pci.h  |  2 --
 include/linux/pci.h|  9 +
 6 files changed, 26 insertions(+), 14 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mtd: brcmnand: Workaround false ECC uncorrectable errors

2015-11-28 Thread Simon Arlott
Workaround false ECC uncorrectable errors by checking if the data
has been erased and the OOB data indicates that the data has been
erased. The v4.0 controller on the BCM63168 incorrectly handles
these as uncorrectable errors.

I don't know which version of the controller handles this scenario
correctly. I'm only able to test this in Hamming mode, so the BCH
version needs to be checked.

This code is quite complicated because the fact that either the data
buffer or the OOB data may not have been read from the controller, and
both of them are required to determine if the error is incorrect.

Signed-off-by: Simon Arlott 
---
 drivers/mtd/nand/brcmnand/brcmnand.c | 107 ++-
 1 file changed, 106 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c 
b/drivers/mtd/nand/brcmnand/brcmnand.c
index 5f26b8a..0857af7 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -1387,6 +1387,102 @@ static int brcmnand_dma_trans(struct brcmnand_host 
*host, u64 addr, u32 *buf,
 }
 
 /*
+ * Workaround false ECC uncorrectable errors by checking if the data
+ * has been erased and the OOB data indicates that the data has been
+ * erased. The controller incorrectly handles these as uncorrectable
+ * errors.
+ */
+static void brcmnand_read_ecc_unc_err(struct mtd_info *mtd,
+   struct nand_chip *chip,
+   int idx, unsigned int trans,
+   u32 *buf, u8 *oob_begin, u8 *oob_end,
+   u64 *err_addr)
+{
+   struct brcmnand_host *host = chip->priv;
+   struct brcmnand_controller *ctrl = host->ctrl;
+   u32 *buf_tmp = NULL;
+   u8 *oob_tmp = NULL;
+   bool buf_erased = false;
+   bool oob_erased = false;
+   int j;
+
+   /* Assume this is fixed in v5.0+ */
+   if (ctrl->nand_version >= 0x0500)
+   return;
+
+   /* Read OOB data if not already read */
+   if (!oob_begin) {
+   oob_tmp = kmalloc(ctrl->max_oob, GFP_KERNEL);
+   if (!oob_tmp)
+   goto out_free;
+
+   oob_begin = oob_tmp;
+   oob_end = oob_tmp;
+
+   oob_end += read_oob_from_regs(ctrl, idx, oob_tmp,
+   mtd->oobsize / trans,
+   host->hwcfg.sector_size_1k);
+   }
+
+   if (is_hamming_ecc(>hwcfg)) {
+   u8 *oob_offset = oob_begin + 6;
+
+   if (oob_offset + 3 < oob_end)
+   /* Erased if ECC bytes are all 0xFF, or the data bytes
+* are all 0xFF which should have Hamming codes of 0x00
+*/
+   oob_erased = memchr_inv(oob_offset, 0xFF, 3) == NULL ||
+   memchr_inv(oob_offset, 0x00, 3) == NULL;
+   } else { /* BCH */
+   u8 *oob_offset = oob_end - ctrl->max_oob;
+
+   if (oob_offset >= oob_begin)
+   /* Erased if ECC bytes are all 0xFF */
+   oob_erased = memchr_inv(oob_offset, 0xFF,
+   oob_end - oob_offset) == NULL;
+   }
+
+   if (!oob_erased)
+   goto out_free;
+
+   /* Read data buffer if not already read */
+   if (!buf) {
+   buf_tmp = kmalloc_array(FC_WORDS, sizeof(*buf_tmp), GFP_KERNEL);
+   if (!buf_tmp)
+   goto out_free;
+
+   buf = buf_tmp;
+
+   brcmnand_soc_data_bus_prepare(ctrl->soc);
+
+   for (j = 0; j < FC_WORDS; j++, buf++)
+   *buf = brcmnand_read_fc(ctrl, j);
+
+   brcmnand_soc_data_bus_unprepare(ctrl->soc);
+   }
+
+   /* Go to start of buffer */
+   buf -= FC_WORDS;
+
+   /* Erased if all data bytes are 0xFF */
+   buf_erased = memchr_inv(buf, 0xFF, FC_WORDS) == NULL;
+
+   if (!buf_erased)
+   goto out_free;
+
+   /* Clear error addresses */
+   brcmnand_write_reg(ctrl, BRCMNAND_UNCORR_ADDR, 0);
+   brcmnand_write_reg(ctrl, BRCMNAND_CORR_ADDR, 0);
+   brcmnand_write_reg(ctrl, BRCMNAND_UNCORR_EXT_ADDR, 0);
+   brcmnand_write_reg(ctrl, BRCMNAND_CORR_EXT_ADDR, 0);
+   *err_addr = 0;
+
+out_free:
+   kfree(buf_tmp);
+   kfree(oob_tmp);
+}
+
+/*
  * Assumes proper CS is already set
  */
 static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip,
@@ -1396,6 +1492,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, 
struct nand_chip *chip,
struct brcmnand_host *host = chip->priv;
struct brcmnand_controller *ctrl = host->ctrl;
int i, j, ret = 0;
+   u8 *prev_oob = NULL;
 
/* Clear error addresses */
brcmnand_write_reg(ctrl, BRCMNAND_UNCORR_ADDR, 0);
@@ -1424,10 +1521,12 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, 
struct nand_chip 

Re: [PATCH v5 1/5] Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.

2015-11-28 Thread Andy Shevchenko
On Sat, Nov 28, 2015 at 7:41 PM, Dave Penkler  wrote:
> On Sat, Nov 28, 2015 at 04:57:47PM +0200, Andy Shevchenko wrote:
>> On Sat, Nov 28, 2015 at 1:55 PM, Dave Penkler  wrote:
>> > On Wed, Nov 25, 2015 at 10:38:39PM +0200, Andy Shevchenko wrote:
>> >> On Wed, Nov 25, 2015 at 11:18 AM, Dave Penkler  wrote:
>> >> > On Sun, Nov 22, 2015 at 12:32:41PM +0200, Andy Shevchenko wrote:
>> >> >> On Sun, Nov 22, 2015 at 11:19 AM, Dave Penkler  
>> >> >> wrote:
>> >> >> > On Wed, Nov 18, 2015 at 11:55:27AM +0200, Andy Shevchenko wrote:
>> >> >> >> On Wed, Nov 18, 2015 at 10:37 AM, Dave Penkler  
>> >> >> >> wrote:
>>
>> Thank you for an update!
>>
>> >> >> >> > +   switch (status) {
>> >> >> >> > +   case 0: /* SUCCESS */
>> >> >> >> > +   if (data->iin_buffer[0] & 0x80) {
>> >> >> >> > +   /* check for valid STB notification */
>> >> >> >> > +   if ((data->iin_buffer[0] & 0x7f) > 1) {
>>
>> How can I miss that there are two conditionals in a sequence and
>> moreover for the same data?!
>
> Sorry, my fault, it is the combination of patch 1 and 2
>
>> That might explain the optimization done by compiler.
>>
>> So, could it be transformed to simple one condition
>>if (data->iin_buffer[0] > 0x81 /* 129 */) {
>> ?
>
> OK so now for patch 1 and 2 we have:
>
> switch (status) {
> case 0: /* SUCCESS */
> /* PATCH 1 check for valid STB notification */
> if (data->iin_buffer[0] > 0x81) {
> data->bNotify1 = data->iin_buffer[0];
> data->bNotify2 = data->iin_buffer[1];
> atomic_set(>iin_data_valid, 1);
> wake_up_interruptible(>waitq);
> goto exit;
> }
> /* PATCH 2 check for SRQ notification */
> if (data->iin_buffer[0] == 0x81) {
> if (data->fasync)
> kill_fasync(>fasync,
> SIGIO, POLL_IN);
>
> atomic_set(>srq_asserted, 1);
> wake_up_interruptible(>waitq);
> goto exit;
> }
>
>
> I'll push a new set if you are OK with this.

Yes, fine by me, thanks for patience.

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 05/17] hv_netvsc: Eliminatte the data field from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminatte the data field from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   |5 ++---
 drivers/net/hyperv/netvsc.c   |5 +++--
 drivers/net/hyperv/netvsc_drv.c   |3 ++-
 drivers/net/hyperv/rndis_filter.c |   11 +++
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 7fa4f43..506d552 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -148,9 +148,6 @@ struct hv_netvsc_packet {
u64 send_completion_tid;
void *send_completion_ctx;
void (*send_completion)(void *context);
-
-   /* Points to the send/receive buffer where the ethernet frame is */
-   void *data;
struct hv_page_buffer *page_buf;
 };
 
@@ -196,6 +193,7 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 void netvsc_xmit_completion(void *context);
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
+   void **data,
struct ndis_tcp_ip_checksum_info *csum_info,
struct vmbus_channel *channel);
 void netvsc_channel_cb(void *context);
@@ -206,6 +204,7 @@ int rndis_filter_device_add(struct hv_device *dev,
 void rndis_filter_device_remove(struct hv_device *dev);
 int rndis_filter_receive(struct hv_device *dev,
struct hv_netvsc_packet *pkt,
+   void **data,
struct vmbus_channel *channel);
 
 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 2de9e7f..8fbf816 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1008,6 +1008,7 @@ static void netvsc_receive(struct netvsc_device 
*net_device,
int i;
int count = 0;
struct net_device *ndev;
+   void *data;
 
ndev = net_device->ndev;
 
@@ -1047,13 +1048,13 @@ static void netvsc_receive(struct netvsc_device 
*net_device,
for (i = 0; i < count; i++) {
/* Initialize the netvsc packet */
netvsc_packet->status = NVSP_STAT_SUCCESS;
-   netvsc_packet->data = (void *)((unsigned long)net_device->
+   data = (void *)((unsigned long)net_device->
recv_buf + vmxferpage_packet->ranges[i].byte_offset);
netvsc_packet->total_data_buflen =
vmxferpage_packet->ranges[i].byte_count;
 
/* Pass it to the upper layer */
-   rndis_filter_receive(device, netvsc_packet, channel);
+   rndis_filter_receive(device, netvsc_packet, , channel);
 
if (netvsc_packet->status != NVSP_STAT_SUCCESS)
status = NVSP_STAT_FAIL;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 77c0849..c73afb1 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -685,6 +685,7 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
  */
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
+   void **data,
struct ndis_tcp_ip_checksum_info *csum_info,
struct vmbus_channel *channel)
 {
@@ -713,7 +714,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 * Copy to skb. This copy is needed here since the memory pointed by
 * hv_netvsc_packet cannot be deallocated
 */
-   memcpy(skb_put(skb, packet->total_data_buflen), packet->data,
+   memcpy(skb_put(skb, packet->total_data_buflen), *data,
packet->total_data_buflen);
 
skb->protocol = eth_type_trans(skb, net);
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 63584e7..be0fa9c 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -351,6 +351,7 @@ static inline void *rndis_get_ppi(struct rndis_packet 
*rpkt, u32 type)
 static void rndis_filter_receive_data(struct rndis_device *dev,
   struct rndis_message *msg,
   struct hv_netvsc_packet *pkt,
+  void **data,
   struct vmbus_channel *channel)
 {
struct rndis_packet *rndis_pkt;
@@ -383,7 +384,7 @@ static void rndis_filter_receive_data(struct rndis_device 
*dev,
 * the data packet to the stack, without the rndis trailer padding
 */
pkt->total_data_buflen = rndis_pkt->data_len;
-   pkt->data = (void *)((unsigned long)pkt->data + data_offset);
+   *data = (void *)((unsigned long)(*data) + data_offset);

[PATCH net-next V2 09/17] hv_netvsc: move subchannel existence check to netvsc_select_queue()

2015-11-28 Thread K. Y. Srinivasan
From: Vitaly Kuznetsov 

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h |   15 ---
 drivers/net/hyperv/netvsc.c |5 ++---
 drivers/net/hyperv/netvsc_drv.c |3 +++
 3 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index e15dc2c..a9d2bdc5 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -1260,19 +1260,4 @@ struct rndis_message {
 #define TRANSPORT_INFO_IPV6_TCP ((INFO_IPV6 << 16) | INFO_TCP)
 #define TRANSPORT_INFO_IPV6_UDP ((INFO_IPV6 << 16) | INFO_UDP)
 
-static inline struct vmbus_channel *get_channel(struct hv_netvsc_packet 
*packet,
-   struct netvsc_device *net_device)
-
-{
-   struct vmbus_channel *out_channel;
-
-   out_channel = net_device->chn_table[packet->q_idx];
-   if (!out_channel) {
-   out_channel = net_device->dev->channel;
-   packet->q_idx = 0;
-   }
-   return out_channel;
-}
-
-
 #endif /* _HYPERV_NET_H */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 0e0b723..419b055 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -749,8 +749,8 @@ static inline int netvsc_send_pkt(
struct netvsc_device *net_device)
 {
struct nvsp_message nvmsg;
-   struct vmbus_channel *out_channel = get_channel(packet, net_device);
u16 q_idx = packet->q_idx;
+   struct vmbus_channel *out_channel = net_device->chn_table[q_idx];
struct net_device *ndev = net_device->ndev;
u64 req_id;
int ret;
@@ -859,8 +859,7 @@ int netvsc_send(struct hv_device *device,
if (!net_device)
return -ENODEV;
 
-   out_channel = get_channel(packet, net_device);
-   q_idx = packet->q_idx;
+   out_channel = net_device->chn_table[q_idx];
 
packet->send_buf_index = NETVSC_INVALID_INDEX;
packet->cp_partial = false;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 90cc8d9..da3a224 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -272,6 +272,9 @@ static u16 netvsc_select_queue(struct net_device *ndev, 
struct sk_buff *skb,
skb_set_hash(skb, hash, PKT_HASH_TYPE_L3);
}
 
+   if (!nvsc_dev->chn_table[q_idx])
+   q_idx = 0;
+
return q_idx;
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ath6kl: Use vmalloc for loading firmware using api1 method

2015-11-28 Thread Brent Taylor
Sorry, the first e-mail was sent via gmail and I forgot about sending
it in plain text mode.

Whats the status on this patch?  I don't see it on patchwork anymore
nor is it in any of the git trees I checked.

Thanks,
Brent

On Fri, Oct 16, 2015 at 12:10 AM, Brent Taylor  wrote:
> Signed-off-by: Brent Taylor 
> ---
>  drivers/net/wireless/ath/ath6kl/init.c | 15 +++
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
> b/drivers/net/wireless/ath/ath6kl/init.c
> index 6e473fa..2155739 100644
> --- a/drivers/net/wireless/ath/ath6kl/init.c
> +++ b/drivers/net/wireless/ath/ath6kl/init.c
> @@ -673,10 +673,17 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char 
> *filename,
> return ret;
>
> *fw_len = fw_entry->size;
> -   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
> -
> -   if (*fw == NULL)
> -   ret = -ENOMEM;
> +   if (>fw == fw) {
> +   *fw = vmalloc(fw_entry->size);
> +   if (*fw == NULL)
> +   ret = -ENOMEM;
> +   else
> +   memcpy(*fw, fw_entry->data, fw_entry->size);
> +   } else {
> +   *fw = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
> +   if (*fw == NULL)
> +   ret = -ENOMEM;
> +   }
>
> release_firmware(fw_entry);
>
> --
> 2.6.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 01/17] hv_netvsc: Resize some of the variables in hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
As part of reducing the size of the hv_netvsc_packet, resize some of the
variables based on their usage.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 5fa98f5..972e562 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -127,11 +127,11 @@ struct ndis_tcp_ip_checksum_info;
  */
 struct hv_netvsc_packet {
/* Bookkeeping stuff */
-   u32 status;
+   u8 status;
 
-   bool is_data_pkt;
-   bool xmit_more; /* from skb */
-   bool cp_partial; /* partial copy into send buffer */
+   u8 is_data_pkt;
+   u8 xmit_more; /* from skb */
+   u8 cp_partial; /* partial copy into send buffer */
 
u16 vlan_tci;
 
@@ -147,13 +147,13 @@ struct hv_netvsc_packet {
/* This points to the memory after page_buf */
struct rndis_message *rndis_msg;
 
-   u32 rmsg_size; /* RNDIS header and PPI size */
-   u32 rmsg_pgcnt; /* page count of RNDIS header and PPI */
+   u8 rmsg_size; /* RNDIS header and PPI size */
+   u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
 
u32 total_data_buflen;
/* Points to the send/receive buffer where the ethernet frame is */
void *data;
-   u32 page_buf_cnt;
+   u8 page_buf_cnt;
struct hv_page_buffer *page_buf;
 };
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 03/17] hv_netvsc: Eliminate the channel field in hv_netvsc_packet structure

2015-11-28 Thread K. Y. Srinivasan
Eliminate the channel field in hv_netvsc_packet structure.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   |   22 ++
 drivers/net/hyperv/netvsc.c   |   19 ---
 drivers/net/hyperv/netvsc_drv.c   |5 +++--
 drivers/net/hyperv/rndis_filter.c |   10 ++
 4 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 7435673..ac24091 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -144,7 +144,6 @@ struct hv_netvsc_packet {
u32 total_data_buflen;
u32 pad1;
 
-   struct vmbus_channel *channel;
 
u64 send_completion_tid;
void *send_completion_ctx;
@@ -199,7 +198,8 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
 void netvsc_xmit_completion(void *context);
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
-   struct ndis_tcp_ip_checksum_info *csum_info);
+   struct ndis_tcp_ip_checksum_info *csum_info,
+   struct vmbus_channel *channel);
 void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
@@ -207,12 +207,12 @@ int rndis_filter_device_add(struct hv_device *dev,
void *additional_info);
 void rndis_filter_device_remove(struct hv_device *dev);
 int rndis_filter_receive(struct hv_device *dev,
-   struct hv_netvsc_packet *pkt);
+   struct hv_netvsc_packet *pkt,
+   struct vmbus_channel *channel);
 
 int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
 int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
 
-
 #define NVSP_INVALID_PROTOCOL_VERSION  ((u32)0x)
 
 #define NVSP_PROTOCOL_VERSION_12
@@ -1262,5 +1262,19 @@ struct rndis_message {
 #define TRANSPORT_INFO_IPV6_TCP ((INFO_IPV6 << 16) | INFO_TCP)
 #define TRANSPORT_INFO_IPV6_UDP ((INFO_IPV6 << 16) | INFO_UDP)
 
+static inline struct vmbus_channel *get_channel(struct hv_netvsc_packet 
*packet,
+   struct netvsc_device *net_device)
+
+{
+   struct vmbus_channel *out_channel;
+
+   out_channel = net_device->chn_table[packet->q_idx];
+   if (!out_channel) {
+   out_channel = net_device->dev->channel;
+   packet->q_idx = 0;
+   }
+   return out_channel;
+}
+
 
 #endif /* _HYPERV_NET_H */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 51e4c0f..52533ed 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -610,6 +610,7 @@ static inline void netvsc_free_send_slot(struct 
netvsc_device *net_device,
 }
 
 static void netvsc_send_completion(struct netvsc_device *net_device,
+  struct vmbus_channel *incoming_channel,
   struct hv_device *device,
   struct vmpacket_descriptor *packet)
 {
@@ -651,7 +652,7 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
if (send_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, send_index);
q_idx = nvsc_packet->q_idx;
-   channel = nvsc_packet->channel;
+   channel = incoming_channel;
nvsc_packet->send_completion(nvsc_packet->
 send_completion_ctx);
}
@@ -748,7 +749,7 @@ static inline int netvsc_send_pkt(
struct netvsc_device *net_device)
 {
struct nvsp_message nvmsg;
-   struct vmbus_channel *out_channel = packet->channel;
+   struct vmbus_channel *out_channel = get_channel(packet, net_device);
u16 q_idx = packet->q_idx;
struct net_device *ndev = net_device->ndev;
u64 req_id;
@@ -857,13 +858,9 @@ int netvsc_send(struct hv_device *device,
if (!net_device)
return -ENODEV;
 
-   out_channel = net_device->chn_table[q_idx];
-   if (!out_channel) {
-   out_channel = device->channel;
-   q_idx = 0;
-   packet->q_idx = 0;
-   }
-   packet->channel = out_channel;
+   out_channel = get_channel(packet, net_device);
+   q_idx = packet->q_idx;
+
packet->send_buf_index = NETVSC_INVALID_INDEX;
packet->cp_partial = false;
 
@@ -1043,7 +1040,6 @@ static void netvsc_receive(struct netvsc_device 
*net_device,
}
 
count = vmxferpage_packet->range_cnt;
-   netvsc_packet->channel = channel;
 
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
for (i = 0; i < count; i++) {
@@ -1055,7 

[PATCH net-next V2 04/17] hv_netvsc: Eliminate rndis_msg pointer from hv_netvsc_packet structure

2015-11-28 Thread K. Y. Srinivasan
Eliminate rndis_msg pointer from hv_netvsc_packet structure.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   |8 +++-
 drivers/net/hyperv/netvsc.c   |   10 ++
 drivers/net/hyperv/netvsc_drv.c   |7 +++
 drivers/net/hyperv/rndis_filter.c |2 +-
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index ac24091..7fa4f43 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -149,10 +149,6 @@ struct hv_netvsc_packet {
void *send_completion_ctx;
void (*send_completion)(void *context);
 
-
-   /* This points to the memory after page_buf */
-   struct rndis_message *rndis_msg;
-
/* Points to the send/receive buffer where the ethernet frame is */
void *data;
struct hv_page_buffer *page_buf;
@@ -189,10 +185,12 @@ struct rndis_device {
 
 
 /* Interface */
+struct rndis_message;
 int netvsc_device_add(struct hv_device *device, void *additional_info);
 int netvsc_device_remove(struct hv_device *device);
 int netvsc_send(struct hv_device *device,
-   struct hv_netvsc_packet *packet);
+   struct hv_netvsc_packet *packet,
+   struct rndis_message *rndis_msg);
 void netvsc_linkstatus_callback(struct hv_device *device_obj,
struct rndis_message *resp);
 void netvsc_xmit_completion(void *context);
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 52533ed..2de9e7f 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -706,7 +706,8 @@ static u32 netvsc_get_next_send_section(struct 
netvsc_device *net_device)
 static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
   unsigned int section_index,
   u32 pend_size,
-  struct hv_netvsc_packet *packet)
+  struct hv_netvsc_packet *packet,
+  struct rndis_message *rndis_msg)
 {
char *start = net_device->send_buf;
char *dest = start + (section_index * net_device->send_section_size)
@@ -722,7 +723,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
if (packet->is_data_pkt && packet->xmit_more && remain &&
!packet->cp_partial) {
padding = net_device->pkt_align - remain;
-   packet->rndis_msg->msg_len += padding;
+   rndis_msg->msg_len += padding;
packet->total_data_buflen += padding;
}
 
@@ -841,7 +842,8 @@ static inline int netvsc_send_pkt(
 }
 
 int netvsc_send(struct hv_device *device,
-   struct hv_netvsc_packet *packet)
+   struct hv_netvsc_packet *packet,
+   struct rndis_message *rndis_msg)
 {
struct netvsc_device *net_device;
int ret = 0, m_ret = 0;
@@ -897,7 +899,7 @@ int netvsc_send(struct hv_device *device,
if (section_index != NETVSC_INVALID_INDEX) {
netvsc_copy_to_send_buf(net_device,
section_index, msd_len,
-   packet);
+   packet, rndis_msg);
 
packet->send_buf_index = section_index;
 
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index e5f4eec..77c0849 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -482,10 +482,10 @@ check_size:
packet->is_data_pkt = true;
packet->total_data_buflen = skb->len;
 
-   packet->rndis_msg = (struct rndis_message *)((unsigned long)packet +
+   rndis_msg = (struct rndis_message *)((unsigned long)packet +
sizeof(struct hv_netvsc_packet));
 
-   memset(packet->rndis_msg, 0, RNDIS_AND_PPI_SIZE);
+   memset(rndis_msg, 0, RNDIS_AND_PPI_SIZE);
 
/* Set the completion routine */
packet->send_completion = netvsc_xmit_completion;
@@ -495,7 +495,6 @@ check_size:
isvlan = packet->vlan_tci & VLAN_TAG_PRESENT;
 
/* Add the rndis header */
-   rndis_msg = packet->rndis_msg;
rndis_msg->ndis_msg_type = RNDIS_MSG_PACKET;
rndis_msg->msg_len = packet->total_data_buflen;
rndis_pkt = _msg->msg.pkt;
@@ -619,7 +618,7 @@ do_send:
packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size,
   skb, packet);
 
-   ret = netvsc_send(net_device_ctx->device_ctx, packet);
+   ret = netvsc_send(net_device_ctx->device_ctx, packet, rndis_msg);
 
 drop:
if (ret == 0) {
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 1b04d78..63584e7 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -240,7 

[PATCH net-next V2 17/17] hv_netvsc: Eliminate vlan_tci from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate vlan_tci from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h   |4 ++--
 drivers/net/hyperv/netvsc_drv.c   |   14 +++---
 drivers/net/hyperv/rndis_filter.c |7 +++
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 128b296..0c04362 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -136,7 +136,6 @@ struct hv_netvsc_packet {
u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
u8 page_buf_cnt;
 
-   u16 vlan_tci;
u16 q_idx;
u32 send_buf_index;
 
@@ -188,7 +187,8 @@ int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
void **data,
struct ndis_tcp_ip_checksum_info *csum_info,
-   struct vmbus_channel *channel);
+   struct vmbus_channel *channel,
+   u16 vlan_tci);
 void netvsc_channel_cb(void *context);
 int rndis_filter_open(struct hv_device *dev);
 int rndis_filter_close(struct hv_device *dev);
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 490672e..ba21272 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -470,7 +470,6 @@ check_size:
FIELD_SIZEOF(struct sk_buff, cb));
packet = (struct hv_netvsc_packet *)skb->cb;
 
-   packet->vlan_tci = skb->vlan_tci;
 
packet->q_idx = skb_get_queue_mapping(skb);
 
@@ -480,7 +479,7 @@ check_size:
 
memset(rndis_msg, 0, RNDIS_AND_PPI_SIZE);
 
-   isvlan = packet->vlan_tci & VLAN_TAG_PRESENT;
+   isvlan = skb->vlan_tci & VLAN_TAG_PRESENT;
 
/* Add the rndis header */
rndis_msg->ndis_msg_type = RNDIS_MSG_PACKET;
@@ -508,8 +507,8 @@ check_size:
IEEE_8021Q_INFO);
vlan = (struct ndis_pkt_8021q_info *)((void *)ppi +
ppi->ppi_offset);
-   vlan->vlanid = packet->vlan_tci & VLAN_VID_MASK;
-   vlan->pri = (packet->vlan_tci & VLAN_PRIO_MASK) >>
+   vlan->vlanid = skb->vlan_tci & VLAN_VID_MASK;
+   vlan->pri = (skb->vlan_tci & VLAN_PRIO_MASK) >>
VLAN_PRIO_SHIFT;
}
 
@@ -676,7 +675,8 @@ int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
void **data,
struct ndis_tcp_ip_checksum_info *csum_info,
-   struct vmbus_channel *channel)
+   struct vmbus_channel *channel,
+   u16 vlan_tci)
 {
struct net_device *net;
struct net_device_context *net_device_ctx;
@@ -716,9 +716,9 @@ int netvsc_recv_callback(struct hv_device *device_obj,
skb->ip_summed = CHECKSUM_NONE;
}
 
-   if (packet->vlan_tci & VLAN_TAG_PRESENT)
+   if (vlan_tci & VLAN_TAG_PRESENT)
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
-  packet->vlan_tci);
+  vlan_tci);
 
skb_record_rx_queue(skb, channel->
offermsg.offer.sub_channel_index);
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 28adf6a..a37bbda 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -354,6 +354,7 @@ static int rndis_filter_receive_data(struct rndis_device 
*dev,
u32 data_offset;
struct ndis_pkt_8021q_info *vlan;
struct ndis_tcp_ip_checksum_info *csum_info;
+   u16 vlan_tci = 0;
 
rndis_pkt = >msg.pkt;
 
@@ -384,15 +385,13 @@ static int rndis_filter_receive_data(struct rndis_device 
*dev,
 
vlan = rndis_get_ppi(rndis_pkt, IEEE_8021Q_INFO);
if (vlan) {
-   pkt->vlan_tci = VLAN_TAG_PRESENT | vlan->vlanid |
+   vlan_tci = VLAN_TAG_PRESENT | vlan->vlanid |
(vlan->pri << VLAN_PRIO_SHIFT);
-   } else {
-   pkt->vlan_tci = 0;
}
 
csum_info = rndis_get_ppi(rndis_pkt, TCPIP_CHKSUM_PKTINFO);
return netvsc_recv_callback(dev->net_dev->dev, pkt, data,
-   csum_info, channel);
+   csum_info, channel, vlan_tci);
 }
 
 int rndis_filter_receive(struct hv_device *dev,
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 11/17] hv_netvsc: Eliminate page_buf from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate page_buf from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   |4 ++--
 drivers/net/hyperv/netvsc.c   |   25 ++---
 drivers/net/hyperv/netvsc_drv.c   |   11 ++-
 drivers/net/hyperv/rndis_filter.c |   26 +-
 4 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index f5b2145..b541455 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -149,7 +149,6 @@ struct hv_netvsc_packet {
 
 
u64 send_completion_tid;
-   struct hv_page_buffer *page_buf;
 };
 
 struct netvsc_device_info {
@@ -188,7 +187,8 @@ int netvsc_device_add(struct hv_device *device, void 
*additional_info);
 int netvsc_device_remove(struct hv_device *device);
 int netvsc_send(struct hv_device *device,
struct hv_netvsc_packet *packet,
-   struct rndis_message *rndis_msg);
+   struct rndis_message *rndis_msg,
+   struct hv_page_buffer **page_buffer);
 void netvsc_linkstatus_callback(struct hv_device *device_obj,
struct rndis_message *resp);
 void netvsc_xmit_completion(void *context);
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 081f14f..18058a59 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -702,7 +702,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
   unsigned int section_index,
   u32 pend_size,
   struct hv_netvsc_packet *packet,
-  struct rndis_message *rndis_msg)
+  struct rndis_message *rndis_msg,
+  struct hv_page_buffer **pb)
 {
char *start = net_device->send_buf;
char *dest = start + (section_index * net_device->send_section_size)
@@ -723,9 +724,9 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
}
 
for (i = 0; i < page_count; i++) {
-   char *src = phys_to_virt(packet->page_buf[i].pfn << PAGE_SHIFT);
-   u32 offset = packet->page_buf[i].offset;
-   u32 len = packet->page_buf[i].len;
+   char *src = phys_to_virt((*pb)[i].pfn << PAGE_SHIFT);
+   u32 offset = (*pb)[i].offset;
+   u32 len = (*pb)[i].len;
 
memcpy(dest, (src + offset), len);
msg_size += len;
@@ -742,7 +743,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
 
 static inline int netvsc_send_pkt(
struct hv_netvsc_packet *packet,
-   struct netvsc_device *net_device)
+   struct netvsc_device *net_device,
+   struct hv_page_buffer **pb)
 {
struct nvsp_message nvmsg;
u16 q_idx = packet->q_idx;
@@ -789,8 +791,8 @@ static inline int netvsc_send_pkt(
packet->xmit_more = false;
 
if (packet->page_buf_cnt) {
-   pgbuf = packet->cp_partial ? packet->page_buf +
-   packet->rmsg_pgcnt : packet->page_buf;
+   pgbuf = packet->cp_partial ? (*pb) +
+   packet->rmsg_pgcnt : (*pb);
ret = vmbus_sendpacket_pagebuffer_ctl(out_channel,
  pgbuf,
  packet->page_buf_cnt,
@@ -838,7 +840,8 @@ static inline int netvsc_send_pkt(
 
 int netvsc_send(struct hv_device *device,
struct hv_netvsc_packet *packet,
-   struct rndis_message *rndis_msg)
+   struct rndis_message *rndis_msg,
+   struct hv_page_buffer **pb)
 {
struct netvsc_device *net_device;
int ret = 0, m_ret = 0;
@@ -891,7 +894,7 @@ int netvsc_send(struct hv_device *device,
if (section_index != NETVSC_INVALID_INDEX) {
netvsc_copy_to_send_buf(net_device,
section_index, msd_len,
-   packet, rndis_msg);
+   packet, rndis_msg, pb);
 
packet->send_buf_index = section_index;
 
@@ -922,7 +925,7 @@ int netvsc_send(struct hv_device *device,
}
 
if (msd_send) {
-   m_ret = netvsc_send_pkt(msd_send, net_device);
+   m_ret = netvsc_send_pkt(msd_send, net_device, pb);
 
if (m_ret != 0) {
netvsc_free_send_slot(net_device,
@@ -932,7 +935,7 @@ int netvsc_send(struct hv_device *device,
}
 
if (cur_send)
-   ret = netvsc_send_pkt(cur_send, net_device);
+   ret = netvsc_send_pkt(cur_send, net_device, pb);
 
if (ret != 0 && section_index != NETVSC_INVALID_INDEX)

[PATCH net-next V2 14/17] hv_netvsc: Eliminate completion_func from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate completion_func from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h   |1 -
 drivers/net/hyperv/netvsc_drv.c   |3 ---
 drivers/net/hyperv/rndis_filter.c |1 -
 3 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 65e340e..ddf51a0 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -137,7 +137,6 @@ struct hv_netvsc_packet {
u8 rmsg_size; /* RNDIS header and PPI size */
u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
u8 page_buf_cnt;
-   u8 completion_func;
 
u16 vlan_tci;
u16 q_idx;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index eb0c6fa..bc4be1d 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -483,9 +483,6 @@ check_size:
 
memset(rndis_msg, 0, RNDIS_AND_PPI_SIZE);
 
-   /* Set the completion routine */
-   packet->completion_func = 1;
-
isvlan = packet->vlan_tci & VLAN_TAG_PRESENT;
 
/* Add the rndis header */
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 0b98674..6ba5adf 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -236,7 +236,6 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
pb[0].len;
}
 
-   packet->completion_func = 0;
packet->xmit_more = false;
 
ret = netvsc_send(dev->net_dev->dev, packet, NULL, , NULL);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 13/17] hv_netvsc: Eliminate is_data_pkt from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate is_data_pkt from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h   |1 -
 drivers/net/hyperv/netvsc.c   |   14 --
 drivers/net/hyperv/netvsc_drv.c   |1 -
 drivers/net/hyperv/rndis_filter.c |1 -
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index baa40b1..65e340e 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -131,7 +131,6 @@ struct ndis_tcp_ip_checksum_info;
 struct hv_netvsc_packet {
/* Bookkeeping stuff */
u8 status;
-   u8 is_data_pkt;
u8 xmit_more; /* from skb */
u8 cp_partial; /* partial copy into send buffer */
 
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index d18e10c..11b009e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -704,12 +704,14 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
   u32 pend_size,
   struct hv_netvsc_packet *packet,
   struct rndis_message *rndis_msg,
-  struct hv_page_buffer **pb)
+  struct hv_page_buffer **pb,
+  struct sk_buff *skb)
 {
char *start = net_device->send_buf;
char *dest = start + (section_index * net_device->send_section_size)
 + pend_size;
int i;
+   bool is_data_pkt = (skb != NULL) ? true : false;
u32 msg_size = 0;
u32 padding = 0;
u32 remain = packet->total_data_buflen % net_device->pkt_align;
@@ -717,7 +719,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
packet->page_buf_cnt;
 
/* Add padding */
-   if (packet->is_data_pkt && packet->xmit_more && remain &&
+   if (is_data_pkt && packet->xmit_more && remain &&
!packet->cp_partial) {
padding = net_device->pkt_align - remain;
rndis_msg->msg_len += padding;
@@ -758,7 +760,7 @@ static inline int netvsc_send_pkt(
u32 ring_avail = hv_ringbuf_avail_percent(_channel->outbound);
 
nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
-   if (packet->is_data_pkt) {
+   if (skb != NULL) {
/* 0 is RMC_DATA; */
nvmsg.msg.v1_msg.send_rndis_pkt.channel_type = 0;
} else {
@@ -868,7 +870,7 @@ int netvsc_send(struct hv_device *device,
if (msdp->pkt)
msd_len = msdp->pkt->total_data_buflen;
 
-   try_batch = packet->is_data_pkt && msd_len > 0 && msdp->count <
+   try_batch = (skb != NULL) && msd_len > 0 && msdp->count <
net_device->max_pkt;
 
if (try_batch && msd_len + pktlen + net_device->pkt_align <
@@ -880,7 +882,7 @@ int netvsc_send(struct hv_device *device,
section_index = msdp->pkt->send_buf_index;
packet->cp_partial = true;
 
-   } else if (packet->is_data_pkt && pktlen + net_device->pkt_align <
+   } else if ((skb != NULL) && pktlen + net_device->pkt_align <
   net_device->send_section_size) {
section_index = netvsc_get_next_send_section(net_device);
if (section_index != NETVSC_INVALID_INDEX) {
@@ -894,7 +896,7 @@ int netvsc_send(struct hv_device *device,
if (section_index != NETVSC_INVALID_INDEX) {
netvsc_copy_to_send_buf(net_device,
section_index, msd_len,
-   packet, rndis_msg, pb);
+   packet, rndis_msg, pb, skb);
 
packet->send_buf_index = section_index;
 
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 1532ae4..eb0c6fa 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -477,7 +477,6 @@ check_size:
 
packet->q_idx = skb_get_queue_mapping(skb);
 
-   packet->is_data_pkt = true;
packet->total_data_buflen = skb->len;
 
rndis_msg = (struct rndis_message *)skb->head;
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 53139f7..0b98674 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -215,7 +215,6 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
/* Setup the packet to send it */
packet = >pkt;
 
-   packet->is_data_pkt = false;
packet->total_data_buflen = req->request_msg.msg_len;
packet->page_buf_cnt = 1;
 
-- 
1.7.4.1

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

[PATCH net-next V2 16/17] hv_netvsc: Eliminate status from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate status from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h   |1 -
 drivers/net/hyperv/netvsc.c   |6 ++
 drivers/net/hyperv/netvsc_drv.c   |8 ++--
 drivers/net/hyperv/rndis_filter.c |   20 +---
 4 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 96d34e2..128b296 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -130,7 +130,6 @@ struct ndis_tcp_ip_checksum_info;
  */
 struct hv_netvsc_packet {
/* Bookkeeping stuff */
-   u8 status;
u8 cp_partial; /* partial copy into send buffer */
 
u8 rmsg_size; /* RNDIS header and PPI size */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index cd5b65e..02bab9a 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1045,17 +1045,15 @@ static void netvsc_receive(struct netvsc_device 
*net_device,
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
for (i = 0; i < count; i++) {
/* Initialize the netvsc packet */
-   netvsc_packet->status = NVSP_STAT_SUCCESS;
data = (void *)((unsigned long)net_device->
recv_buf + vmxferpage_packet->ranges[i].byte_offset);
netvsc_packet->total_data_buflen =
vmxferpage_packet->ranges[i].byte_count;
 
/* Pass it to the upper layer */
-   rndis_filter_receive(device, netvsc_packet, , channel);
+   status = rndis_filter_receive(device, netvsc_packet, ,
+ channel);
 
-   if (netvsc_packet->status != NVSP_STAT_SUCCESS)
-   status = NVSP_STAT_FAIL;
}
 
netvsc_send_recv_completion(device, channel, net_device,
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 7520c52..490672e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -470,8 +470,6 @@ check_size:
FIELD_SIZEOF(struct sk_buff, cb));
packet = (struct hv_netvsc_packet *)skb->cb;
 
-   packet->status = 0;
-
packet->vlan_tci = skb->vlan_tci;
 
packet->q_idx = skb_get_queue_mapping(skb);
@@ -687,8 +685,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
 
net = ((struct netvsc_device *)hv_get_drvdata(device_obj))->ndev;
if (!net || net->reg_state != NETREG_REGISTERED) {
-   packet->status = NVSP_STAT_FAIL;
-   return 0;
+   return NVSP_STAT_FAIL;
}
net_device_ctx = netdev_priv(net);
rx_stats = this_cpu_ptr(net_device_ctx->rx_stats);
@@ -697,8 +694,7 @@ int netvsc_recv_callback(struct hv_device *device_obj,
skb = netdev_alloc_skb_ip_align(net, packet->total_data_buflen);
if (unlikely(!skb)) {
++net->stats.rx_dropped;
-   packet->status = NVSP_STAT_FAIL;
-   return 0;
+   return NVSP_STAT_FAIL;
}
 
/*
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 3c06aa7..28adf6a 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -344,7 +344,7 @@ static inline void *rndis_get_ppi(struct rndis_packet 
*rpkt, u32 type)
return NULL;
 }
 
-static void rndis_filter_receive_data(struct rndis_device *dev,
+static int rndis_filter_receive_data(struct rndis_device *dev,
   struct rndis_message *msg,
   struct hv_netvsc_packet *pkt,
   void **data,
@@ -371,7 +371,7 @@ static void rndis_filter_receive_data(struct rndis_device 
*dev,
   "overflow detected (got %u, min %u)"
   "...dropping this message!\n",
   pkt->total_data_buflen, rndis_pkt->data_len);
-   return;
+   return NVSP_STAT_FAIL;
}
 
/*
@@ -391,7 +391,8 @@ static void rndis_filter_receive_data(struct rndis_device 
*dev,
}
 
csum_info = rndis_get_ppi(rndis_pkt, TCPIP_CHKSUM_PKTINFO);
-   netvsc_recv_callback(dev->net_dev->dev, pkt, data, csum_info, channel);
+   return netvsc_recv_callback(dev->net_dev->dev, pkt, data,
+   csum_info, channel);
 }
 
 int rndis_filter_receive(struct hv_device *dev,
@@ -406,7 +407,7 @@ int rndis_filter_receive(struct hv_device *dev,
int ret = 0;
 
if (!net_dev) {
-   ret = -EINVAL;
+   ret = NVSP_STAT_FAIL;
goto exit;
}
 
@@ -416,7 +417,7 @@ int rndis_filter_receive(struct hv_device *dev,
if (!net_dev->extension) {
netdev_err(ndev, "got rndis 

[PATCH net-next V2 15/17] hv_netvsc: Eliminate xmit_more from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate xmit_more from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h   |1 -
 drivers/net/hyperv/netvsc.c   |   13 -
 drivers/net/hyperv/netvsc_drv.c   |1 -
 drivers/net/hyperv/rndis_filter.c |2 --
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index ddf51a0..96d34e2 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -131,7 +131,6 @@ struct ndis_tcp_ip_checksum_info;
 struct hv_netvsc_packet {
/* Bookkeeping stuff */
u8 status;
-   u8 xmit_more; /* from skb */
u8 cp_partial; /* partial copy into send buffer */
 
u8 rmsg_size; /* RNDIS header and PPI size */
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 11b009e..cd5b65e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -712,6 +712,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
 + pend_size;
int i;
bool is_data_pkt = (skb != NULL) ? true : false;
+   bool xmit_more = (skb != NULL) ? skb->xmit_more : false;
u32 msg_size = 0;
u32 padding = 0;
u32 remain = packet->total_data_buflen % net_device->pkt_align;
@@ -719,7 +720,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
packet->page_buf_cnt;
 
/* Add padding */
-   if (is_data_pkt && packet->xmit_more && remain &&
+   if (is_data_pkt && xmit_more && remain &&
!packet->cp_partial) {
padding = net_device->pkt_align - remain;
rndis_msg->msg_len += padding;
@@ -758,6 +759,7 @@ static inline int netvsc_send_pkt(
int ret;
struct hv_page_buffer *pgbuf;
u32 ring_avail = hv_ringbuf_avail_percent(_channel->outbound);
+   bool xmit_more = (skb != NULL) ? skb->xmit_more : false;
 
nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
if (skb != NULL) {
@@ -789,7 +791,7 @@ static inline int netvsc_send_pkt(
 * unnecessarily.
 */
if (ring_avail < (RING_AVAIL_PERCENT_LOWATER + 1))
-   packet->xmit_more = false;
+   xmit_more = false;
 
if (packet->page_buf_cnt) {
pgbuf = packet->cp_partial ? (*pb) +
@@ -801,14 +803,14 @@ static inline int netvsc_send_pkt(
  sizeof(struct 
nvsp_message),
  req_id,
  
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED,
- !packet->xmit_more);
+ !xmit_more);
} else {
ret = vmbus_sendpacket_ctl(out_channel, ,
   sizeof(struct nvsp_message),
   req_id,
   VM_PKT_DATA_INBAND,
   
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED,
-  !packet->xmit_more);
+  !xmit_more);
}
 
if (ret == 0) {
@@ -854,6 +856,7 @@ int netvsc_send(struct hv_device *device,
struct multi_send_data *msdp;
struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL;
bool try_batch;
+   bool xmit_more = (skb != NULL) ? skb->xmit_more : false;
 
net_device = get_outbound_net_device(device);
if (!net_device)
@@ -911,7 +914,7 @@ int netvsc_send(struct hv_device *device,
if (msdp->pkt)
dev_kfree_skb_any(skb);
 
-   if (packet->xmit_more && !packet->cp_partial) {
+   if (xmit_more && !packet->cp_partial) {
msdp->pkt = packet;
msdp->count++;
} else {
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index bc4be1d..7520c52 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -471,7 +471,6 @@ check_size:
packet = (struct hv_netvsc_packet *)skb->cb;
 
packet->status = 0;
-   packet->xmit_more = skb->xmit_more;
 
packet->vlan_tci = skb->vlan_tci;
 
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 6ba5adf..3c06aa7 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -236,8 +236,6 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
pb[0].len;
}
 
-   packet->xmit_more = false;
-
ret = netvsc_send(dev->net_dev->dev, packet, NULL, , NULL);
return ret;
 }
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe 

[PATCH net-next V2 08/17] hv_netvsc: Don't ask for additional head room in the skb

2015-11-28 Thread K. Y. Srinivasan
The rndis header is 116 bytes big and can be placed in the default
head room that will be available in the skb. Since the netvsc packet
is less than 48 bytes, we can use the skb control buffer
for the netvsc packet. With these changes we don't need to
ask for additional head room.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
v2: When HYPERV_NET is configured, set LL_MAX_HEADER to 128 - Vitaly 
Kuznetsov  
V2: Add a build time check on the skb control buffer - Florian Westphal 

 drivers/net/hyperv/hyperv_net.h |3 +++
 drivers/net/hyperv/netvsc_drv.c |   30 +++---
 include/linux/netdevice.h   |4 +++-
 3 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 9504ca9..e15dc2c 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -124,6 +124,9 @@ struct ndis_tcp_ip_checksum_info;
 /*
  * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
  * within the RNDIS
+ *
+ * The size of this structure is less than 48 bytes and we can now
+ * place this structure in the skb->cb field.
  */
 struct hv_netvsc_packet {
/* Bookkeeping stuff */
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 947b778..90cc8d9 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -432,7 +432,6 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct 
net_device *net)
u32 net_trans_info;
u32 hash;
u32 skb_length;
-   u32 pkt_sz;
struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
struct netvsc_stats *tx_stats = this_cpu_ptr(net_device_ctx->tx_stats);
 
@@ -460,16 +459,21 @@ check_size:
goto check_size;
}
 
-   pkt_sz = sizeof(struct hv_netvsc_packet) + RNDIS_AND_PPI_SIZE;
-
-   ret = skb_cow_head(skb, pkt_sz);
+   /*
+* Place the rndis header in the skb head room and
+* the skb->cb will be used for hv_netvsc_packet
+* structure.
+*/
+   ret = skb_cow_head(skb, RNDIS_AND_PPI_SIZE);
if (ret) {
netdev_err(net, "unable to alloc hv_netvsc_packet\n");
ret = -ENOMEM;
goto drop;
}
-   /* Use the headroom for building up the packet */
-   packet = (struct hv_netvsc_packet *)skb->head;
+   /* Use the skb control buffer for building up the packet */
+   BUILD_BUG_ON(sizeof(struct hv_netvsc_packet) >
+   FIELD_SIZEOF(struct sk_buff, cb));
+   packet = (struct hv_netvsc_packet *)skb->cb;
 
packet->status = 0;
packet->xmit_more = skb->xmit_more;
@@ -482,8 +486,7 @@ check_size:
packet->is_data_pkt = true;
packet->total_data_buflen = skb->len;
 
-   rndis_msg = (struct rndis_message *)((unsigned long)packet +
-   sizeof(struct hv_netvsc_packet));
+   rndis_msg = (struct rndis_message *)skb->head;
 
memset(rndis_msg, 0, RNDIS_AND_PPI_SIZE);
 
@@ -1071,16 +1074,12 @@ static int netvsc_probe(struct hv_device *dev,
struct netvsc_device_info device_info;
struct netvsc_device *nvdev;
int ret;
-   u32 max_needed_headroom;
 
net = alloc_etherdev_mq(sizeof(struct net_device_context),
num_online_cpus());
if (!net)
return -ENOMEM;
 
-   max_needed_headroom = sizeof(struct hv_netvsc_packet) +
- RNDIS_AND_PPI_SIZE;
-
netif_carrier_off(net);
 
net_device_ctx = netdev_priv(net);
@@ -1116,13 +1115,6 @@ static int netvsc_probe(struct hv_device *dev,
net->ethtool_ops = _ops;
SET_NETDEV_DEV(net, >device);
 
-   /*
-* Request additional head room in the skb.
-* We will use this space to build the rndis
-* heaser and other state we need to maintain.
-*/
-   net->needed_headroom = max_needed_headroom;
-
/* Notify the netvsc driver of the new device */
memset(_info, 0, sizeof(device_info));
device_info.ring_size = ring_size;
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d208914..2e8d703 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -132,7 +132,9 @@ static inline bool dev_xmit_complete(int rc)
  * used.
  */
 
-#if defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25)
+#if defined(CONFIG_HYPERV_NET)
+# define LL_MAX_HEADER 128
+#elseif defined(CONFIG_WLAN) || IS_ENABLED(CONFIG_AX25)
 # if defined(CONFIG_MAC80211_MESH)
 #  define LL_MAX_HEADER 128
 # else
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 10/17] hv_netvsc: remove locking in netvsc_send()

2015-11-28 Thread K. Y. Srinivasan
From: Vitaly Kuznetsov 

Packet scheduler guarantees there won't be multiple senders for the same
queue and as we use q_idx for multi_send_data the spinlock is redundant.

Signed-off-by: Vitaly Kuznetsov 
Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h |1 -
 drivers/net/hyperv/netvsc.c |8 
 2 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index a9d2bdc5..f5b2145 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -633,7 +633,6 @@ struct nvsp_message {
 #define RNDIS_PKT_ALIGN_DEFAULT 8
 
 struct multi_send_data {
-   spinlock_t lock; /* protect struct multi_send_data */
struct hv_netvsc_packet *pkt; /* netvsc pkt pending */
u32 count; /* counter of batched packets */
 };
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 419b055..081f14f 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -38,7 +38,6 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
 {
struct netvsc_device *net_device;
struct net_device *ndev = hv_get_drvdata(device);
-   int i;
 
net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
if (!net_device)
@@ -58,9 +57,6 @@ static struct netvsc_device *alloc_net_device(struct 
hv_device *device)
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
 
-   for (i = 0; i < num_online_cpus(); i++)
-   spin_lock_init(_device->msd[i].lock);
-
hv_set_drvdata(device, net_device);
return net_device;
 }
@@ -850,7 +846,6 @@ int netvsc_send(struct hv_device *device,
u16 q_idx = packet->q_idx;
u32 pktlen = packet->total_data_buflen, msd_len = 0;
unsigned int section_index = NETVSC_INVALID_INDEX;
-   unsigned long flag;
struct multi_send_data *msdp;
struct hv_netvsc_packet *msd_send = NULL, *cur_send = NULL;
bool try_batch;
@@ -867,7 +862,6 @@ int netvsc_send(struct hv_device *device,
msdp = _device->msd[q_idx];
 
/* batch packets in send buffer if possible */
-   spin_lock_irqsave(>lock, flag);
if (msdp->pkt)
msd_len = msdp->pkt->total_data_buflen;
 
@@ -927,8 +921,6 @@ int netvsc_send(struct hv_device *device,
cur_send = packet;
}
 
-   spin_unlock_irqrestore(>lock, flag);
-
if (msd_send) {
m_ret = netvsc_send_pkt(msd_send, net_device);
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 12/17] hv_netvsc: Eliminate send_completion_tid from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate send_completion_tid from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/hyperv_net.h   |8 ++--
 drivers/net/hyperv/netvsc.c   |   28 ++--
 drivers/net/hyperv/netvsc_drv.c   |   14 ++
 drivers/net/hyperv/rndis_filter.c |2 +-
 4 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index b541455..baa40b1 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -145,10 +145,6 @@ struct hv_netvsc_packet {
u32 send_buf_index;
 
u32 total_data_buflen;
-   u32 pad1;
-
-
-   u64 send_completion_tid;
 };
 
 struct netvsc_device_info {
@@ -188,10 +184,10 @@ int netvsc_device_remove(struct hv_device *device);
 int netvsc_send(struct hv_device *device,
struct hv_netvsc_packet *packet,
struct rndis_message *rndis_msg,
-   struct hv_page_buffer **page_buffer);
+   struct hv_page_buffer **page_buffer,
+   struct sk_buff *skb);
 void netvsc_linkstatus_callback(struct hv_device *device_obj,
struct rndis_message *resp);
-void netvsc_xmit_completion(void *context);
 int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet,
void **data,
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 18058a59..d18e10c 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -614,6 +614,7 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
struct hv_netvsc_packet *nvsc_packet;
struct net_device *ndev;
u32 send_index;
+   struct sk_buff *skb;
 
ndev = net_device->ndev;
 
@@ -639,17 +640,17 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
int queue_sends;
 
/* Get the send context */
-   nvsc_packet = (struct hv_netvsc_packet *)(unsigned long)
-   packet->trans_id;
+   skb = (struct sk_buff *)(unsigned long)packet->trans_id;
 
/* Notify the layer above us */
-   if (nvsc_packet) {
+   if (skb) {
+   nvsc_packet = (struct hv_netvsc_packet *) skb->cb;
send_index = nvsc_packet->send_buf_index;
if (send_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, send_index);
q_idx = nvsc_packet->q_idx;
channel = incoming_channel;
-   netvsc_xmit_completion(nvsc_packet);
+   dev_kfree_skb_any(skb);
}
 
num_outstanding_sends =
@@ -744,7 +745,8 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device 
*net_device,
 static inline int netvsc_send_pkt(
struct hv_netvsc_packet *packet,
struct netvsc_device *net_device,
-   struct hv_page_buffer **pb)
+   struct hv_page_buffer **pb,
+   struct sk_buff *skb)
 {
struct nvsp_message nvmsg;
u16 q_idx = packet->q_idx;
@@ -772,10 +774,7 @@ static inline int netvsc_send_pkt(
nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_size =
packet->total_data_buflen;
 
-   if (packet->completion_func)
-   req_id = (ulong)packet;
-   else
-   req_id = 0;
+   req_id = (ulong)skb;
 
if (out_channel->rescind)
return -ENODEV;
@@ -841,7 +840,8 @@ static inline int netvsc_send_pkt(
 int netvsc_send(struct hv_device *device,
struct hv_netvsc_packet *packet,
struct rndis_message *rndis_msg,
-   struct hv_page_buffer **pb)
+   struct hv_page_buffer **pb,
+   struct sk_buff *skb)
 {
struct netvsc_device *net_device;
int ret = 0, m_ret = 0;
@@ -907,7 +907,7 @@ int netvsc_send(struct hv_device *device,
}
 
if (msdp->pkt)
-   netvsc_xmit_completion(msdp->pkt);
+   dev_kfree_skb_any(skb);
 
if (packet->xmit_more && !packet->cp_partial) {
msdp->pkt = packet;
@@ -925,17 +925,17 @@ int netvsc_send(struct hv_device *device,
}
 
if (msd_send) {
-   m_ret = netvsc_send_pkt(msd_send, net_device, pb);
+   m_ret = netvsc_send_pkt(msd_send, net_device, pb, skb);
 
if (m_ret != 0) {
netvsc_free_send_slot(net_device,
  msd_send->send_buf_index);
-   netvsc_xmit_completion(msd_send);
+   dev_kfree_skb_any(skb);
}
}
 
if (cur_send)
-   ret = 

[PATCH net-next V2 02/17] hv_netvsc: Rearrange the hv_negtvsc_packet to be space efficient

2015-11-28 Thread K. Y. Srinivasan
Rearrange the elements of struct hv_negtvsc_packet for optimal layout -
eliminate unnecessary padding.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h |   18 ++
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 972e562..7435673 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -128,32 +128,34 @@ struct ndis_tcp_ip_checksum_info;
 struct hv_netvsc_packet {
/* Bookkeeping stuff */
u8 status;
-
u8 is_data_pkt;
u8 xmit_more; /* from skb */
u8 cp_partial; /* partial copy into send buffer */
 
-   u16 vlan_tci;
+   u8 rmsg_size; /* RNDIS header and PPI size */
+   u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
+   u8 page_buf_cnt;
+   u8 pad0;
 
+   u16 vlan_tci;
u16 q_idx;
+   u32 send_buf_index;
+
+   u32 total_data_buflen;
+   u32 pad1;
+
struct vmbus_channel *channel;
 
u64 send_completion_tid;
void *send_completion_ctx;
void (*send_completion)(void *context);
 
-   u32 send_buf_index;
 
/* This points to the memory after page_buf */
struct rndis_message *rndis_msg;
 
-   u8 rmsg_size; /* RNDIS header and PPI size */
-   u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
-
-   u32 total_data_buflen;
/* Points to the send/receive buffer where the ethernet frame is */
void *data;
-   u8 page_buf_cnt;
struct hv_page_buffer *page_buf;
 };
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 07/17] hv_netvsc: Eliminate send_completion_ctx from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate send_completion_ctx from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h |1 -
 drivers/net/hyperv/netvsc.c |3 +--
 drivers/net/hyperv/netvsc_drv.c |1 -
 3 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 9a3c972..9504ca9 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -146,7 +146,6 @@ struct hv_netvsc_packet {
 
 
u64 send_completion_tid;
-   void *send_completion_ctx;
struct hv_page_buffer *page_buf;
 };
 
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 34c16d1..0e0b723 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -653,8 +653,7 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
netvsc_free_send_slot(net_device, send_index);
q_idx = nvsc_packet->q_idx;
channel = incoming_channel;
-   netvsc_xmit_completion(nvsc_packet->
-  send_completion_ctx);
+   netvsc_xmit_completion(nvsc_packet);
}
 
num_outstanding_sends =
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 6d71a1e..947b778 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -489,7 +489,6 @@ check_size:
 
/* Set the completion routine */
packet->completion_func = 1;
-   packet->send_completion_ctx = packet;
packet->send_completion_tid = (unsigned long)skb;
 
isvlan = packet->vlan_tci & VLAN_TAG_PRESENT;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 06/17] hv_netvsc: Eliminate send_completion from struct hv_netvsc_packet

2015-11-28 Thread K. Y. Srinivasan
Eliminate send_completion from struct hv_netvsc_packet.

Signed-off-by: K. Y. Srinivasan 
Reviewed-by: Haiyang Zhang 
---
 drivers/net/hyperv/hyperv_net.h   |3 +--
 drivers/net/hyperv/netvsc.c   |6 +++---
 drivers/net/hyperv/netvsc_drv.c   |2 +-
 drivers/net/hyperv/rndis_filter.c |2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 506d552..9a3c972 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -135,7 +135,7 @@ struct hv_netvsc_packet {
u8 rmsg_size; /* RNDIS header and PPI size */
u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
u8 page_buf_cnt;
-   u8 pad0;
+   u8 completion_func;
 
u16 vlan_tci;
u16 q_idx;
@@ -147,7 +147,6 @@ struct hv_netvsc_packet {
 
u64 send_completion_tid;
void *send_completion_ctx;
-   void (*send_completion)(void *context);
struct hv_page_buffer *page_buf;
 };
 
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 8fbf816..34c16d1 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -653,8 +653,8 @@ static void netvsc_send_completion(struct netvsc_device 
*net_device,
netvsc_free_send_slot(net_device, send_index);
q_idx = nvsc_packet->q_idx;
channel = incoming_channel;
-   nvsc_packet->send_completion(nvsc_packet->
-send_completion_ctx);
+   netvsc_xmit_completion(nvsc_packet->
+  send_completion_ctx);
}
 
num_outstanding_sends =
@@ -775,7 +775,7 @@ static inline int netvsc_send_pkt(
nvmsg.msg.v1_msg.send_rndis_pkt.send_buf_section_size =
packet->total_data_buflen;
 
-   if (packet->send_completion)
+   if (packet->completion_func)
req_id = (ulong)packet;
else
req_id = 0;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index c73afb1..6d71a1e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -488,7 +488,7 @@ check_size:
memset(rndis_msg, 0, RNDIS_AND_PPI_SIZE);
 
/* Set the completion routine */
-   packet->send_completion = netvsc_xmit_completion;
+   packet->completion_func = 1;
packet->send_completion_ctx = packet;
packet->send_completion_tid = (unsigned long)skb;
 
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index be0fa9c..c8af172 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -237,7 +237,7 @@ static int rndis_filter_send_request(struct rndis_device 
*dev,
packet->page_buf[0].len;
}
 
-   packet->send_completion = NULL;
+   packet->completion_func = 0;
packet->xmit_more = false;
 
ret = netvsc_send(dev->net_dev->dev, packet, NULL);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH net-next V2 00/17] hv_netvsc: Eliminate the additional head room

2015-11-28 Thread K. Y. Srinivasan
In an attempt to avoid having to allocate memory on the send path, the netvsc
driver was requesting additional head room so that both rndis header and the
netvsc packet (the state that had to persist) could be placed in the skb.
Since the amount of head room requested was exceeding the default head room
as set in LL_MAX_HEADER, we were forcing a reallocation of skb.

With this patch-set, I have reduced the size of the netvsc packet to less
than 20 bytes and with this reduction we don't need to ask for any additional
headroom. We place the rndis header in the skb head room and we place the
netvsc packet in control buffer area in the skb.

V2:  - Addressed  review comments:
 - Eliminated more fields from netvsc packet structure.

K. Y. Srinivasan (15):
  hv_netvsc: Resize some of the variables in hv_netvsc_packet
  hv_netvsc: Rearrange the hv_negtvsc_packet to be space efficient
  hv_netvsc: Eliminate the channel field in hv_netvsc_packet structure
  hv_netvsc: Eliminate rndis_msg pointer from hv_netvsc_packet
structure
  hv_netvsc: Eliminatte the data field from struct hv_netvsc_packet
  hv_netvsc: Eliminate send_completion from struct hv_netvsc_packet
  hv_netvsc: Eliminate send_completion_ctx from struct hv_netvsc_packet
  hv_netvsc: Don't ask for additional head room in the skb
  hv_netvsc: Eliminate page_buf from struct hv_netvsc_packet
  hv_netvsc: Eliminate send_completion_tid from struct hv_netvsc_packet
  hv_netvsc: Eliminate is_data_pkt from struct hv_netvsc_packet
  hv_netvsc: Eliminate completion_func from struct hv_netvsc_packet
  hv_netvsc: Eliminate xmit_more from struct hv_netvsc_packet
  hv_netvsc: Eliminate status from struct hv_netvsc_packet
  hv_netvsc: Eliminate vlan_tci from struct hv_netvsc_packet

Vitaly Kuznetsov (2):
  hv_netvsc: move subchannel existence check to netvsc_select_queue()
  hv_netvsc: remove locking in netvsc_send()

 drivers/net/hyperv/hyperv_net.h   |   48 +++--
 drivers/net/hyperv/netvsc.c   |  102 ++---
 drivers/net/hyperv/netvsc_drv.c   |   93 +-
 drivers/net/hyperv/rndis_filter.c |   66 
 include/linux/netdevice.h |4 +-
 5 files changed, 138 insertions(+), 175 deletions(-)

-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] iwlwifi: fix compare_const_fl.cocci warnings

2015-11-28 Thread Grumbach, Emmanuel
Hi Julia,

On 11/27/2015 06:11 PM, Julia Lawall wrote:
> Move constants to the right of binary operators.
>
> Generated by: scripts/coccinelle/misc/compare_const_fl.cocci
>
> Signed-off-by: Fengguang Wu 
> Signed-off-by: Julia Lawall 
> ---
>
> This looks a bit nicer around the other way, in my opinion.

Thanks, I picked it up. I agree with your taste although having
constants on the left side can avoid the typo = instead of == since they
can't be an l-value. Obviously we never do that and prefer to have the
constant on the right side. More readable for sure.
>
>  calib.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/drivers/net/wireless/intel/iwlwifi/dvm/calib.c
> +++ b/drivers/net/wireless/intel/iwlwifi/dvm/calib.c
> @@ -311,7 +311,7 @@ static int iwl_sens_energy_cck(struct iw
>   /* If previous beacon had too many false alarms,
>*   give it some extra margin by reducing sensitivity again
>*   (but don't go below measured energy of desired Rx) */
> - if (IWL_FA_TOO_MANY == data->nrg_prev_state) {
> + if (data->nrg_prev_state == IWL_FA_TOO_MANY) {
>   IWL_DEBUG_CALIB(priv, "... increasing margin\n");
>   if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN))
>   data->nrg_th_cck -= NRG_MARGIN;
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] cris: fasttimer: fix mixed declarations and code compile warning

2015-11-28 Thread Niklas Cassel
arch/cris/arch-v32/kernel/fasttimer.c: In function ‘timer_trig_handler’:
arch/cris/arch-v32/kernel/fasttimer.c:353:2: warning: ISO C90 forbids mixed 
declarations and code [-Wdeclaration-after-statement]
  fast_timer_function_type *f;
  ^

Signed-off-by: Niklas Cassel 
---
 arch/cris/arch-v32/kernel/fasttimer.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/cris/arch-v32/kernel/fasttimer.c 
b/arch/cris/arch-v32/kernel/fasttimer.c
index 5c84dbb..5a8c428 100644
--- a/arch/cris/arch-v32/kernel/fasttimer.c
+++ b/arch/cris/arch-v32/kernel/fasttimer.c
@@ -322,6 +322,8 @@ static void timer_trig_handler(struct work_struct *work)
   reg_timer_rw_intr_mask intr_mask;
   reg_timer_rw_trig_cfg trig_cfg = { 0 };
   struct fast_timer *t;
+  fast_timer_function_type *f;
+  unsigned long d;
   unsigned long flags;
 
/* We keep interrupts disabled not only when we modify the
@@ -350,9 +352,6 @@ static void timer_trig_handler(struct work_struct *work)
   fast_timer_running = 0;
   fast_timer_ints++;
 
-   fast_timer_function_type *f;
-   unsigned long d;
-
   t = fast_timer_list;
while (t) {
struct fasttime_t tv;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] cris: intmem: fix pointer comparison compile warning

2015-11-28 Thread Niklas Cassel
The code previously depended on list_head being defined
as the first item in struct intmem_allocation.

arch/cris/arch-v32/mm/intmem.c: In function ‘crisv32_intmem_free’:
arch/cris/arch-v32/mm/intmem.c:116:14: warning: comparison of distinct pointer 
types lacks a cast
if ((prev != _allocations) &&
  ^
arch/cris/arch-v32/mm/intmem.c:123:14: warning: comparison of distinct pointer 
types lacks a cast
if ((next != _allocations) &&
  ^

Signed-off-by: Niklas Cassel 
---
 arch/cris/arch-v32/mm/intmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/cris/arch-v32/mm/intmem.c b/arch/cris/arch-v32/mm/intmem.c
index bad735d..c807284 100644
--- a/arch/cris/arch-v32/mm/intmem.c
+++ b/arch/cris/arch-v32/mm/intmem.c
@@ -113,14 +113,14 @@ void crisv32_intmem_free(void* addr)
 
allocation->status = STATUS_FREE;
/* Join with prev and/or next if also free */
-   if ((prev != _allocations) &&
+   if ((>entry != _allocations) &&
(prev->status == STATUS_FREE)) {
prev->size += allocation->size;
list_del(>entry);
kfree(allocation);
allocation = prev;
}
-   if ((next != _allocations) &&
+   if ((>entry != _allocations) &&
(next->status == STATUS_FREE)) {
allocation->size += next->size;
list_del(>entry);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] cris: irq: stop loop from accessing array out of bound

2015-11-28 Thread Niklas Cassel
array "interrupt" only has 32 or 64 elements, depending on machine.

arch/cris/arch-v32/kernel/irq.c: In function ‘init_IRQ’:
arch/cris/arch-v32/kernel/irq.c:475:3: warning: iteration 32u invokes undefined 
behavior [-Waggressive-loop-optimizations]
   set_exception_vector(i, interrupt[j]);
   ^
arch/cris/arch-v32/kernel/irq.c:474:2: note: containing loop
  for (i = FIRST_IRQ, j = 0; j < NBR_INTR_VECT; i++, j++) {
  ^

Signed-off-by: Niklas Cassel 
---
 arch/cris/arch-v32/kernel/irq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/cris/arch-v32/kernel/irq.c b/arch/cris/arch-v32/kernel/irq.c
index 6de8db6..b07da4b 100644
--- a/arch/cris/arch-v32/kernel/irq.c
+++ b/arch/cris/arch-v32/kernel/irq.c
@@ -471,9 +471,8 @@ init_IRQ(void)
irq_set_default_host(domain);
of_node_put(np);
 
-   for (i = FIRST_IRQ, j = 0; j < NBR_INTR_VECT; i++, j++) {
+   for (i = FIRST_IRQ, j = 0; j < NBR_INTR_VECT && j < MACH_IRQS; i++, j++)
set_exception_vector(i, interrupt[j]);
-   }
 
/* Mark Timer and IPI IRQs as CPU local */
irq_allocations[TIMER0_INTR_VECT - FIRST_IRQ].cpu = CPU_FIXED;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] cris: intmem: fix device_initcall compile warning

2015-11-28 Thread Niklas Cassel
Cannot add __init macro to crisv32_intmem_init,
since the function is being called by other functions.
Creating a wrapper instead.

arch/cris/arch-v32/mm/intmem.c: At top level:
arch/cris/arch-v32/mm/intmem.c:148:17: warning: initialization from 
incompatible pointer type
 device_initcall(crisv32_intmem_init);
 ^
include/linux/init.h:184:58: note: in definition of macro ‘__define_initcall’
  __attribute__((__section__(".initcall" #id ".init"))) = fn; \
  ^
arch/cris/arch-v32/mm/intmem.c:148:1: note: in expansion of macro 
‘device_initcall’
 device_initcall(crisv32_intmem_init);
 ^

Signed-off-by: Niklas Cassel 
---
 arch/cris/arch-v32/mm/intmem.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/cris/arch-v32/mm/intmem.c b/arch/cris/arch-v32/mm/intmem.c
index 9ef5609..bad735d 100644
--- a/arch/cris/arch-v32/mm/intmem.c
+++ b/arch/cris/arch-v32/mm/intmem.c
@@ -145,5 +145,12 @@ unsigned long crisv32_intmem_virt_to_phys(void* addr)
(unsigned long)intmem_virtual + MEM_INTMEM_START +
RESERVED_SIZE);
 }
-device_initcall(crisv32_intmem_init);
+
+static int __init crisv32_intmem_setup(void)
+{
+   crisv32_intmem_init();
+
+   return 0;
+}
+device_initcall(crisv32_intmem_setup);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   4   >