[PATCH 4.4 19/37] i2c: rcar: refactor setup of a msg

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Wolfram Sang 

commit b9d0684c79c4b9d30ce0d47d3270493dd0e76e59 upstream.

We want to reuse this function later.

Signed-off-by: Wolfram Sang 
Signed-off-by: Wolfram Sang 
Signed-off-by: Fabrizio Castro 
Reviewed-by: Chris Paterson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/i2c/busses/i2c-rcar.c |   15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -106,7 +106,8 @@ enum rcar_i2c_type {
 struct rcar_i2c_priv {
void __iomem *io;
struct i2c_adapter adap;
-   struct i2c_msg  *msg;
+   struct i2c_msg *msg;
+   int msgs_left;
struct clk *clk;
 
wait_queue_head_t wait;
@@ -255,6 +256,11 @@ static void rcar_i2c_prepare_msg(struct
 {
int read = !!rcar_i2c_is_recv(priv);
 
+   priv->pos = 0;
+   priv->flags = 0;
+   if (priv->msgs_left == 1)
+   rcar_i2c_flags_set(priv, ID_LAST_MSG);
+
rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read);
rcar_i2c_write(priv, ICMSR, 0);
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
@@ -499,11 +505,8 @@ static int rcar_i2c_master_xfer(struct i
}
 
/* init each data */
-   priv->msg   = [i];
-   priv->pos   = 0;
-   priv->flags = 0;
-   if (i == num - 1)
-   rcar_i2c_flags_set(priv, ID_LAST_MSG);
+   priv->msg = [i];
+   priv->msgs_left = num - i;
 
rcar_i2c_prepare_msg(priv);
 




[PATCH 4.4 16/37] i2c: rcar: rework hw init

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Wolfram Sang 

commit 2c78cdc1c06308a59d6ed4145cdba73fdeff8c0d upstream.

We don't need to init HW before every transfer since we know the HW
state then. HW init at probe time is enough. While here, add setting the
clock register which belongs to init HW. Also, set MDBS bit since not
setting it is prohibited according to the manual.

Signed-off-by: Wolfram Sang 
Signed-off-by: Wolfram Sang 
Signed-off-by: Fabrizio Castro 
Reviewed-by: Chris Paterson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/i2c/busses/i2c-rcar.c |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -144,9 +144,10 @@ static void rcar_i2c_init(struct rcar_i2
 {
/* reset master mode */
rcar_i2c_write(priv, ICMIER, 0);
-   rcar_i2c_write(priv, ICMCR, 0);
+   rcar_i2c_write(priv, ICMCR, MDBS);
rcar_i2c_write(priv, ICMSR, 0);
-   rcar_i2c_write(priv, ICMAR, 0);
+   /* start clock */
+   rcar_i2c_write(priv, ICCCR, priv->icccr);
 }
 
 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
@@ -496,16 +497,6 @@ static int rcar_i2c_master_xfer(struct i
 
pm_runtime_get_sync(dev);
 
-   /*-- spin lock -*/
-   spin_lock_irqsave(>lock, flags);
-
-   rcar_i2c_init(priv);
-   /* start clock */
-   rcar_i2c_write(priv, ICCCR, priv->icccr);
-
-   spin_unlock_irqrestore(>lock, flags);
-   /*-- spin unlock -*/
-
ret = rcar_i2c_bus_barrier(priv);
if (ret < 0)
goto out;
@@ -666,6 +657,7 @@ static int rcar_i2c_probe(struct platfor
if (ret < 0)
goto out_pm_put;
 
+   rcar_i2c_init(priv);
pm_runtime_put(dev);
 
irq = platform_get_irq(pdev, 0);




[PATCH 4.4 15/37] i2c: rcar: make sure clocks are on when doing clock calculation

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Wolfram Sang 

commit e43e0df13f8528ca55ed79f469c4b2af897fa796 upstream.

When calculating the bus speed, the clock should be on, of course. Most
bootloaders left them on, so this went unnoticed so far.

Move the ioremapping out of this clock-enabled-block and prepare for
adding hw initialization there, too.

Reported-by: Kuninori Morimoto 
Signed-off-by: Wolfram Sang 
Signed-off-by: Wolfram Sang 
Signed-off-by: Fabrizio Castro 
Reviewed-by: Chris Paterson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/i2c/busses/i2c-rcar.c |   26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -650,19 +650,23 @@ static int rcar_i2c_probe(struct platfor
return PTR_ERR(priv->clk);
}
 
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   priv->io = devm_ioremap_resource(dev, res);
+   if (IS_ERR(priv->io))
+   return PTR_ERR(priv->io);
+
bus_speed = 10; /* default 100 kHz */
of_property_read_u32(dev->of_node, "clock-frequency", _speed);
 
priv->devtype = (enum rcar_i2c_type)of_match_device(rcar_i2c_dt_ids, 
dev)->data;
 
+   pm_runtime_enable(dev);
+   pm_runtime_get_sync(dev);
ret = rcar_i2c_clock_calculate(priv, bus_speed, dev);
if (ret < 0)
-   return ret;
+   goto out_pm_put;
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   priv->io = devm_ioremap_resource(dev, res);
-   if (IS_ERR(priv->io))
-   return PTR_ERR(priv->io);
+   pm_runtime_put(dev);
 
irq = platform_get_irq(pdev, 0);
init_waitqueue_head(>wait);
@@ -682,22 +686,26 @@ static int rcar_i2c_probe(struct platfor
   dev_name(dev), priv);
if (ret < 0) {
dev_err(dev, "cannot get irq %d\n", irq);
-   return ret;
+   goto out_pm_disable;
}
 
-   pm_runtime_enable(dev);
platform_set_drvdata(pdev, priv);
 
ret = i2c_add_numbered_adapter(adap);
if (ret < 0) {
dev_err(dev, "reg adap failed: %d\n", ret);
-   pm_runtime_disable(dev);
-   return ret;
+   goto out_pm_disable;
}
 
dev_info(dev, "probed\n");
 
return 0;
+
+ out_pm_put:
+   pm_runtime_put(dev);
+ out_pm_disable:
+   pm_runtime_disable(dev);
+   return ret;
 }
 
 static int rcar_i2c_remove(struct platform_device *pdev)




[PATCH 4.4 14/37] tcp: avoid integer overflows in tcp_rcv_space_adjust()

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Eric Dumazet 

commit 607065bad9931e72207b0cac365d7d4abc06bd99 upstream.

When using large tcp_rmem[2] values (I did tests with 500 MB),
I noticed overflows while computing rcvwin.

Lets fix this before the following patch.

Signed-off-by: Eric Dumazet 
Acked-by: Soheil Hassas Yeganeh 
Acked-by: Wei Wang 
Acked-by: Neal Cardwell 
Signed-off-by: David S. Miller 
[Backport: sysctl_tcp_rmem is not Namespace-ify'd in older kernels]
Signed-off-by: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/tcp.h  |2 +-
 net/ipv4/tcp_input.c |   10 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -324,7 +324,7 @@ struct tcp_sock {
 
 /* Receiver queue space */
struct {
-   int space;
+   u32 space;
u32 seq;
u32 time;
} rcvq_space;
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -557,8 +557,8 @@ static inline void tcp_rcv_rtt_measure_t
 void tcp_rcv_space_adjust(struct sock *sk)
 {
struct tcp_sock *tp = tcp_sk(sk);
+   u32 copied;
int time;
-   int copied;
 
time = tcp_time_stamp - tp->rcvq_space.time;
if (time < (tp->rcv_rtt_est.rtt >> 3) || tp->rcv_rtt_est.rtt == 0)
@@ -580,12 +580,13 @@ void tcp_rcv_space_adjust(struct sock *s
 
if (sysctl_tcp_moderate_rcvbuf &&
!(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) {
-   int rcvwin, rcvmem, rcvbuf;
+   int rcvmem, rcvbuf;
+   u64 rcvwin;
 
/* minimal window to cope with packet losses, assuming
 * steady state. Add some cushion because of small variations.
 */
-   rcvwin = (copied << 1) + 16 * tp->advmss;
+   rcvwin = ((u64)copied << 1) + 16 * tp->advmss;
 
/* If rate increased by 25%,
 *  assume slow start, rcvwin = 3 * copied
@@ -605,7 +606,8 @@ void tcp_rcv_space_adjust(struct sock *s
while (tcp_win_from_space(rcvmem) < tp->advmss)
rcvmem += 128;
 
-   rcvbuf = min(rcvwin / tp->advmss * rcvmem, sysctl_tcp_rmem[2]);
+   do_div(rcvwin, tp->advmss);
+   rcvbuf = min_t(u64, rcvwin * rcvmem, sysctl_tcp_rmem[2]);
if (rcvbuf > sk->sk_rcvbuf) {
sk->sk_rcvbuf = rcvbuf;
 




[PATCH 15/46] perf tools: Ditch the symbol_conf.nr_events global

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Since over time the places where we need to pass this got reduced
because we can obtain it from evsel->evlist->nr_entries, no need to have
this global anymore.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-ovhikrfj8pzdv93yq3gt6...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-kvm.c | 2 --
 tools/perf/builtin-top.c | 2 --
 tools/perf/util/header.c | 4 
 tools/perf/util/symbol.h | 1 -
 4 files changed, 9 deletions(-)

diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 72e2ca096bf5..2b1ef704169f 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1438,8 +1438,6 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
goto out;
}
 
-   symbol_conf.nr_events = kvm->evlist->nr_entries;
-
if (perf_evlist__create_maps(kvm->evlist, >opts.target) < 0)
usage_with_options(live_usage, live_options);
 
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 04fe04885e99..4284840022a3 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1462,8 +1462,6 @@ int cmd_top(int argc, const char **argv)
goto out_delete_evlist;
}
 
-   symbol_conf.nr_events = top.evlist->nr_entries;
-
if (top.delay_secs < 1)
top.delay_secs = 1;
 
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index a8bff2178fbc..2625cc38a0d6 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3312,8 +3312,6 @@ int perf_session__read_header(struct perf_session 
*session)
lseek(fd, tmp, SEEK_SET);
}
 
-   symbol_conf.nr_events = nr_attrs;
-
perf_header__process_sections(header, fd, >tevent,
  perf_file_section__process);
 
@@ -3739,8 +3737,6 @@ int perf_event__process_attr(struct perf_tool *tool 
__maybe_unused,
perf_evlist__id_add(evlist, evsel, 0, i, event->attr.id[i]);
}
 
-   symbol_conf.nr_events = evlist->nr_entries;
-
return 0;
 }
 
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 1a16438eb3ce..1be9a6bad967 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -90,7 +90,6 @@ struct intlist;
 
 struct symbol_conf {
unsigned short  priv_size;
-   unsigned short  nr_events;
booltry_vmlinux_path,
init_annotation,
force,
-- 
2.14.3



[PATCH 11/46] perf annotate: Introduce symbol__hists()

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

In this case we're wanting just notes->src->histograms, allocating it if needed.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-4iatualjskia7sojmdb65...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 28 
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index a5a6d686004e..467bae0279ce 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -863,18 +863,38 @@ static struct annotation *symbol__get_annotation(struct 
symbol *sym, bool cycles
return notes;
 }
 
+static struct annotated_source *symbol__hists(struct symbol *sym)
+{
+   struct annotation *notes = symbol__annotation(sym);
+
+   if (notes->src == NULL) {
+   notes->src = annotated_source__new();
+   if (notes->src == NULL)
+   return NULL;
+   goto alloc_histograms;
+   }
+
+   if (notes->src->histograms == NULL) {
+alloc_histograms:
+   annotated_source__alloc_histograms(notes->src, 
symbol__size(sym),
+  symbol_conf.nr_events);
+   }
+
+   return notes->src;
+}
+
 static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
struct perf_evsel *evsel, u64 addr,
struct perf_sample *sample)
 {
-   struct annotation *notes;
+   struct annotated_source *src;
 
if (sym == NULL)
return 0;
-   notes = symbol__get_annotation(sym, false);
-   if (notes == NULL)
+   src = symbol__hists(sym);
+   if (src == NULL)
return -ENOMEM;
-   return __symbol__inc_addr_samples(sym, map, notes->src, evsel->idx, 
addr, sample);
+   return __symbol__inc_addr_samples(sym, map, src, evsel->idx, addr, 
sample);
 }
 
 static int symbol__account_cycles(u64 addr, u64 start,
-- 
2.14.3



[PATCH 14/46] perf annotate: Replace symbol__alloc_hists() with symbol__hists()

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Its a bit shorter, so ditch the old symbol__alloc_hists() function.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-m7tienxk7dijh5ln62yln...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-top.c  |  8 +---
 tools/perf/ui/browsers/annotate.c |  2 +-
 tools/perf/util/annotate.c| 21 ++---
 tools/perf/util/annotate.h|  2 +-
 4 files changed, 5 insertions(+), 28 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index bc71e899096d..04fe04885e99 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -123,14 +123,9 @@ static int perf_top__parse_source(struct perf_top *top, 
struct hist_entry *he)
}
 
notes = symbol__annotation(sym);
-   if (notes->src != NULL) {
-   pthread_mutex_lock(>lock);
-   goto out_assign;
-   }
-
pthread_mutex_lock(>lock);
 
-   if (symbol__alloc_hist(sym) < 0) {
+   if (!symbol__hists(sym, top->evlist->nr_entries)) {
pthread_mutex_unlock(>lock);
pr_err("Not enough memory for annotating '%s' symbol!\n",
   sym->name);
@@ -140,7 +135,6 @@ static int perf_top__parse_source(struct perf_top *top, 
struct hist_entry *he)
 
err = symbol__annotate(sym, map, evsel, 0, NULL);
if (err == 0) {
-out_assign:
top->sym_filter_entry = he;
} else {
char msg[BUFSIZ];
diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 8be40fa903aa..3bfe17e176fe 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -410,7 +410,7 @@ static bool annotate_browser__callq(struct annotate_browser 
*browser,
notes = symbol__annotation(dl->ops.target.sym);
pthread_mutex_lock(>lock);
 
-   if (notes->src == NULL && symbol__alloc_hist(dl->ops.target.sym) < 0) {
+   if (!symbol__hists(dl->ops.target.sym, evsel->evlist->nr_entries)) {
pthread_mutex_unlock(>lock);
ui__warning("Not enough memory for annotating '%s' symbol!\n",
dl->ops.target.sym->name);
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 7c194b04a2da..bcd5d3e17b85 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -689,7 +689,7 @@ static struct annotated_source *annotated_source__new(void)
return src;
 }
 
-static void annotated_source__delete(struct annotated_source *src)
+static __maybe_unused void annotated_source__delete(struct annotated_source 
*src)
 {
if (src == NULL)
return;
@@ -729,23 +729,6 @@ static int annotated_source__alloc_histograms(struct 
annotated_source *src,
return src->histograms ? 0 : -1;
 }
 
-int symbol__alloc_hist(struct symbol *sym)
-{
-   size_t size = symbol__size(sym);
-   struct annotation *notes = symbol__annotation(sym);
-
-   notes->src = annotated_source__new();
-   if (notes->src == NULL)
-   return -1;
-
-   if (annotated_source__alloc_histograms(notes->src, size, 
symbol_conf.nr_events) < 0) {
-   annotated_source__delete(notes->src);
-   notes->src = NULL;
-   return -1;
-   }
-   return 0;
-}
-
 /* The cycles histogram is lazily allocated. */
 static int symbol__alloc_hist_cycles(struct symbol *sym)
 {
@@ -868,7 +851,7 @@ static struct cyc_hist *symbol__cycles_hist(struct symbol 
*sym)
return notes->src->cycles_hist;
 }
 
-static struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists)
+struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists)
 {
struct annotation *notes = symbol__annotation(sym);
 
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 2a73f9084930..7ad503fbff74 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -292,7 +292,7 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol 
*ams,
 int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample 
*sample,
 struct perf_evsel *evsel, u64 addr);
 
-int symbol__alloc_hist(struct symbol *sym);
+struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists);
 void symbol__annotate_zero_histograms(struct symbol *sym);
 
 int symbol__annotate(struct symbol *sym, struct map *map,
-- 
2.14.3



[PATCH 23/46] perf annotate: Move disassembler_style global to annotation_options

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Continuing to group annotation specific stuff into a struct.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-p3cdhltj58jt0byjzg3g7...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-annotate.c | 2 +-
 tools/perf/builtin-report.c   | 2 +-
 tools/perf/builtin-top.c  | 2 +-
 tools/perf/util/annotate.c| 5 ++---
 tools/perf/util/annotate.h| 3 +--
 5 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 2ca7172f0780..3ee063598364 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -519,7 +519,7 @@ int cmd_annotate(int argc, const char **argv)
"Interleave source code with assembly code (default)"),
OPT_BOOLEAN(0, "asm-raw", _asm_raw,
"Display raw encoding of assembly instructions (default)"),
-   OPT_STRING('M', "disassembler-style", _style, 
"disassembler style",
+   OPT_STRING('M', "disassembler-style", 
_style, "disassembler style",
   "Specify disassembler style (e.g. -M intel for intel 
syntax)"),
OPT_STRING(0, "objdump", _path, "path",
   "objdump binary to use for disassembly and annotations"),
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index bee6dbfbf11e..c74f9a219ad1 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1083,7 +1083,7 @@ int cmd_report(int argc, const char **argv)
"Interleave source code with assembly code (default)"),
OPT_BOOLEAN(0, "asm-raw", _opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"),
-   OPT_STRING('M', "disassembler-style", _style, 
"disassembler style",
+   OPT_STRING('M', "disassembler-style", 
_opts.disassembler_style, "disassembler style",
   "Specify disassembler style (e.g. -M intel for intel 
syntax)"),
OPT_BOOLEAN(0, "show-total-period", _conf.show_total_period,
"Show a column with the sum of periods"),
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index e65e72c06a01..739c158fb39e 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1348,7 +1348,7 @@ int cmd_top(int argc, const char **argv)
"Enable kernel symbol demangling"),
OPT_STRING(0, "objdump", _path, "path",
"objdump binary to use for disassembly and annotations"),
-   OPT_STRING('M', "disassembler-style", _style, 
"disassembler style",
+   OPT_STRING('M', "disassembler-style", 
_opts.disassembler_style, "disassembler style",
   "Specify disassembler style (e.g. -M intel for intel 
syntax)"),
OPT_STRING('u', "uid", >uid_str, "user", "user to profile"),
OPT_CALLBACK(0, "percent-limit", , "percent",
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ff8f4f474b22..a9017b60 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -51,7 +51,6 @@ struct annotation_options annotation__default_options = {
.offset_level   = ANNOTATION__OFFSET_JUMP_TARGETS,
 };
 
-const char *disassembler_style;
 const char *objdump_path;
 static regex_t  file_lineno;
 
@@ -1659,8 +1658,8 @@ static int symbol__disassemble(struct symbol *sym, struct 
annotate_args *args)
 " --stop-address=0x%016" PRIx64
 " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
 objdump_path ? objdump_path : "objdump",
-disassembler_style ? "-M " : "",
-disassembler_style ? disassembler_style : "",
+opts->disassembler_style ? "-M " : "",
+opts->disassembler_style ?: "",
 map__rip_2objdump(map, sym->start),
 map__rip_2objdump(map, sym->end),
 opts->show_asm_raw ? "" : "--no-show-raw",
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 476ea2a25649..71a734b86873 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -80,6 +80,7 @@ struct annotation_options {
int  min_pcnt;
int  max_lines;
int  context;
+   const char *disassembler_style;
 };
 
 enum {
@@ -368,8 +369,6 @@ static inline int symbol__tui_annotate(struct symbol *sym 
__maybe_unused,
 }
 #endif
 
-extern const char  *disassembler_style;
-
 void annotation_config__init(void);
 
 #endif /* __PERF_ANNOTATE_H */
-- 
2.14.3



[PATCH 30/46] perf sched: Use sched->show_callchain where appropriate

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Instead of using symbol_conf.use_callchain, reducing its usage a bit
more.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-edgwb1b2mpbrdeg0w64wp...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 97f9e755e8e6..cbf39dab19c1 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2143,7 +2143,7 @@ static void save_task_callchain(struct perf_sched *sched,
return;
}
 
-   if (!symbol_conf.use_callchain || sample->callchain == NULL)
+   if (!sched->show_callchain || sample->callchain == NULL)
return;
 
if (thread__resolve_callchain(thread, cursor, evsel, sample,
@@ -2271,10 +2271,11 @@ static struct thread *get_idle_thread(int cpu)
return idle_threads[cpu];
 }
 
-static void save_idle_callchain(struct idle_thread_runtime *itr,
+static void save_idle_callchain(struct perf_sched *sched,
+   struct idle_thread_runtime *itr,
struct perf_sample *sample)
 {
-   if (!symbol_conf.use_callchain || sample->callchain == NULL)
+   if (!sched->show_callchain || sample->callchain == NULL)
return;
 
callchain_cursor__copy(>cursor, _cursor);
@@ -2320,7 +2321,7 @@ static struct thread *timehist_get_thread(struct 
perf_sched *sched,
 
/* copy task callchain when entering to idle */
if (perf_evsel__intval(evsel, sample, "next_pid") == 0)
-   save_idle_callchain(itr, sample);
+   save_idle_callchain(sched, itr, sample);
}
}
 
@@ -2849,7 +2850,7 @@ static void timehist_print_summary(struct perf_sched 
*sched,
printf("CPU %2d idle entire time window\n", i);
}
 
-   if (sched->idle_hist && symbol_conf.use_callchain) {
+   if (sched->idle_hist && sched->show_callchain) {
callchain_param.mode  = CHAIN_FOLDED;
callchain_param.value = CCVAL_PERIOD;
 
-- 
2.14.3



[PATCH 24/46] perf hists browser: Pass annotation_options from tool to browser

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

So that things changed in the command line may percolate to the browser
code without using globals.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-5daawc40zhl6gcs600com...@git.kernel.org
[ Merged fix for NO_SLANG=1 build provided by Jiri Olsa ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-annotate.c |  2 +-
 tools/perf/builtin-report.c   |  2 +-
 tools/perf/builtin-top.c  |  3 ++-
 tools/perf/ui/browsers/annotate.c | 19 ---
 tools/perf/ui/browsers/hists.c| 29 -
 tools/perf/ui/browsers/hists.h|  3 +++
 tools/perf/util/annotate.h|  7 ---
 tools/perf/util/hist.h| 20 ++--
 8 files changed, 57 insertions(+), 28 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 3ee063598364..2339ae719e1d 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -341,7 +341,7 @@ static void hists__find_annotations(struct hists *hists,
/* skip missing symbols */
nd = rb_next(nd);
} else if (use_browser == 1) {
-   key = hist_entry__tui_annotate(he, evsel, NULL);
+   key = hist_entry__tui_annotate(he, evsel, NULL, 
>opts);
 
switch (key) {
case -1:
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index c74f9a219ad1..14b516a3a0de 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -561,7 +561,7 @@ static int report__browse_hists(struct report *rep)
ret = perf_evlist__tui_browse_hists(evlist, help, NULL,
rep->min_percent,
>header.env,
-   true);
+   true, 
>annotation_opts);
/*
 * Usually "ret" is the last pressed key, and we only
 * care if the key notifies us to switch data file.
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 739c158fb39e..bd60a631a481 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -606,7 +606,8 @@ static void *display_thread_tui(void *arg)
perf_evlist__tui_browse_hists(top->evlist, help, ,
  top->min_percent,
  >session->header.env,
- !top->record_opts.overwrite);
+ !top->record_opts.overwrite,
+ >annotation_opts);
 
done = 1;
return NULL;
diff --git a/tools/perf/ui/browsers/annotate.c 
b/tools/perf/ui/browsers/annotate.c
index 3bfe17e176fe..3b4f1c10ff57 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -29,6 +29,7 @@ struct annotate_browser {
struct rb_node *curr_hot;
struct annotation_line *selection;
struct arch*arch;
+   struct annotation_options  *opts;
boolsearching_backwards;
charsearch_bf[128];
 };
@@ -418,7 +419,7 @@ static bool annotate_browser__callq(struct annotate_browser 
*browser,
}
 
pthread_mutex_unlock(>lock);
-   symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt);
+   symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, 
browser->opts);
sym_title(ms->sym, ms->map, title, sizeof(title));
ui_browser__show_title(>b, title);
return true;
@@ -817,24 +818,27 @@ static int annotate_browser__run(struct annotate_browser 
*browser,
 }
 
 int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
-struct hist_browser_timer *hbt)
+struct hist_browser_timer *hbt,
+struct annotation_options *opts)
 {
-   return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt);
+   return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt, opts);
 }
 
 int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
-struct hist_browser_timer *hbt)
+struct hist_browser_timer *hbt,
+struct annotation_options *opts)
 {
/* reset abort key so that it can get Ctrl-C as a key */
SLang_reset_tty();
SLang_init_tty(0, 0, 0);
 
-   return map_symbol__tui_annotate(>ms, evsel, hbt);
+   return map_symbol__tui_annotate(>ms, evsel, hbt, opts);
 }
 
 int symbol__tui_annotate(struct symbol *sym, struct map *map,
 struct perf_evsel *evsel,
-   

[PATCH 22/46] perf annotate: Adopt anotation options from symbol_conf

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Continuing to group annotation options in an annotation specific struct.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-astei92tzxp4yccag5pxb...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-annotate.c | 4 ++--
 tools/perf/builtin-report.c   | 6 --
 tools/perf/builtin-top.c  | 4 ++--
 tools/perf/util/annotate.c| 6 --
 tools/perf/util/annotate.h| 4 +++-
 tools/perf/util/symbol.c  | 1 -
 tools/perf/util/symbol.h  | 2 --
 7 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 7238010f28d4..2ca7172f0780 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -515,9 +515,9 @@ int cmd_annotate(int argc, const char **argv)
OPT_CALLBACK(0, "symfs", NULL, "directory",
 "Look for files with symbols relative to this directory",
 symbol__config_symfs),
-   OPT_BOOLEAN(0, "source", _conf.annotate_src,
+   OPT_BOOLEAN(0, "source", _src,
"Interleave source code with assembly code (default)"),
-   OPT_BOOLEAN(0, "asm-raw", _conf.annotate_asm_raw,
+   OPT_BOOLEAN(0, "asm-raw", _asm_raw,
"Display raw encoding of assembly instructions (default)"),
OPT_STRING('M', "disassembler-style", _style, 
"disassembler style",
   "Specify disassembler style (e.g. -M intel for intel 
syntax)"),
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 7a689c933f04..bee6dbfbf11e 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -71,6 +71,7 @@ struct report {
boolgroup_set;
int max_stack;
struct perf_read_values show_threads_values;
+   struct annotation_options annotation_opts;
const char  *pretty_printing_style;
const char  *cpu_list;
const char  *symbol_filter_str;
@@ -988,6 +989,7 @@ int cmd_report(int argc, const char **argv)
.max_stack   = PERF_MAX_STACK_DEPTH,
.pretty_printing_style   = "normal",
.socket_filter   = -1,
+   .annotation_opts = annotation__default_options,
};
const struct option options[] = {
OPT_STRING('i', "input", _name, "file",
@@ -1077,9 +1079,9 @@ int cmd_report(int argc, const char **argv)
   "list of cpus to profile"),
OPT_BOOLEAN('I', "show-info", _full_info,
"Display extended information about perf.data file"),
-   OPT_BOOLEAN(0, "source", _conf.annotate_src,
+   OPT_BOOLEAN(0, "source", _opts.annotate_src,
"Interleave source code with assembly code (default)"),
-   OPT_BOOLEAN(0, "asm-raw", _conf.annotate_asm_raw,
+   OPT_BOOLEAN(0, "asm-raw", _opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"),
OPT_STRING('M', "disassembler-style", _style, 
"disassembler style",
   "Specify disassembler style (e.g. -M intel for intel 
syntax)"),
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 2c14ca61c657..e65e72c06a01 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1340,9 +1340,9 @@ int cmd_top(int argc, const char **argv)
   "only consider symbols in these comms"),
OPT_STRING(0, "symbols", _conf.sym_list_str, 
"symbol[,symbol...]",
   "only consider these symbols"),
-   OPT_BOOLEAN(0, "source", _conf.annotate_src,
+   OPT_BOOLEAN(0, "source", _opts.annotate_src,
"Interleave source code with assembly code (default)"),
-   OPT_BOOLEAN(0, "asm-raw", _conf.annotate_asm_raw,
+   OPT_BOOLEAN(0, "asm-raw", _opts.show_asm_raw,
"Display raw encoding of assembly instructions (default)"),
OPT_BOOLEAN(0, "demangle-kernel", _conf.demangle_kernel,
"Enable kernel symbol demangling"),
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 502f9d124a44..ff8f4f474b22 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -47,6 +47,7 @@
 struct annotation_options annotation__default_options = {
.use_offset = true,
.jump_arrows= true,
+   .annotate_src   = true,
.offset_level   = ANNOTATION__OFFSET_JUMP_TARGETS,
 };
 
@@ -1609,6 +1610,7 @@ static int dso__disassemble_filename(struct dso *dso, 
char *filename, size_t fil
 
 static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 {
+   struct annotation_options *opts = args->options;
struct map *map = args->ms.map;
struct dso *dso = map->dso;
char *command;
@@ -1661,8 +1663,8 

[PATCH 25/46] perf annotate: Move objdump_path to struct annotation_options

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

One more step in grouping annotation options.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-sogzdhugoavm6fyw60jnb...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/arch/common.c   | 4 ++--
 tools/perf/arch/common.h   | 4 +---
 tools/perf/builtin-annotate.c  | 7 ---
 tools/perf/builtin-report.c| 2 +-
 tools/perf/builtin-top.c   | 7 ---
 tools/perf/ui/browsers/hists.c | 3 ++-
 tools/perf/util/annotate.c | 3 +--
 tools/perf/util/annotate.h | 1 +
 8 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index c6f373508a4f..82657c01a3b8 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -189,7 +189,7 @@ static int perf_env__lookup_binutils_path(struct perf_env 
*env,
return -1;
 }
 
-int perf_env__lookup_objdump(struct perf_env *env)
+int perf_env__lookup_objdump(struct perf_env *env, const char **path)
 {
/*
 * For live mode, env->arch will be NULL and we can use
@@ -198,5 +198,5 @@ int perf_env__lookup_objdump(struct perf_env *env)
if (env->arch == NULL)
return 0;
 
-   return perf_env__lookup_binutils_path(env, "objdump", _path);
+   return perf_env__lookup_binutils_path(env, "objdump", path);
 }
diff --git a/tools/perf/arch/common.h b/tools/perf/arch/common.h
index 2d875baa92e6..2167001b18c5 100644
--- a/tools/perf/arch/common.h
+++ b/tools/perf/arch/common.h
@@ -4,8 +4,6 @@
 
 #include "../util/env.h"
 
-extern const char *objdump_path;
-
-int perf_env__lookup_objdump(struct perf_env *env);
+int perf_env__lookup_objdump(struct perf_env *env, const char **path);
 
 #endif /* ARCH_PERF_COMMON_H */
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 2339ae719e1d..5eb22cc56363 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -388,8 +388,9 @@ static int __cmd_annotate(struct perf_annotate *ann)
goto out;
}
 
-   if (!objdump_path) {
-   ret = perf_env__lookup_objdump(>header.env);
+   if (!ann->opts.objdump_path) {
+   ret = perf_env__lookup_objdump(>header.env,
+  >opts.objdump_path);
if (ret)
goto out;
}
@@ -521,7 +522,7 @@ int cmd_annotate(int argc, const char **argv)
"Display raw encoding of assembly instructions (default)"),
OPT_STRING('M', "disassembler-style", 
_style, "disassembler style",
   "Specify disassembler style (e.g. -M intel for intel 
syntax)"),
-   OPT_STRING(0, "objdump", _path, "path",
+   OPT_STRING(0, "objdump", _path, "path",
   "objdump binary to use for disassembly and annotations"),
OPT_BOOLEAN(0, "group", _conf.event_group,
"Show event group information together"),
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 14b516a3a0de..bc133e7a7ac2 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1094,7 +1094,7 @@ int cmd_report(int argc, const char **argv)
parse_branch_mode),
OPT_BOOLEAN(0, "branch-history", _call_mode,
"add last branch records to call history"),
-   OPT_STRING(0, "objdump", _path, "path",
+   OPT_STRING(0, "objdump", _opts.objdump_path, "path",
   "objdump binary to use for disassembly and annotations"),
OPT_BOOLEAN(0, "demangle", _conf.demangle,
"Disable symbol demangling"),
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index bd60a631a481..ffdc2769ff9f 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1077,8 +1077,9 @@ static int __cmd_top(struct perf_top *top)
if (top->session == NULL)
return -1;
 
-   if (!objdump_path) {
-   ret = perf_env__lookup_objdump(>session->header.env);
+   if (!top->annotation_opts.objdump_path) {
+   ret = perf_env__lookup_objdump(>session->header.env,
+  
>annotation_opts.objdump_path);
if (ret)
goto out_delete;
}
@@ -1347,7 +1348,7 @@ int cmd_top(int argc, const char **argv)
"Display raw encoding of assembly instructions (default)"),
OPT_BOOLEAN(0, "demangle-kernel", _conf.demangle_kernel,
"Enable kernel symbol demangling"),
-   OPT_STRING(0, "objdump", _path, "path",
+   OPT_STRING(0, "objdump", _opts.objdump_path, "path",
"objdump binary to use for disassembly and annotations"),
OPT_STRING('M', "disassembler-style", 
_opts.disassembler_style, "disassembler style",
   "Specify disassembler style 

[PATCH 21/46] perf annotate: Pass annotation_options to symbol__annotate()

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Now all callers to symbol__disassemble() can hand it the per-tool
annotation_options, which will allow us to remove lots of stuff
from symbol_options, the kitchen sink of perf configs, reducing its
size and getting annotation specific stuff grouped together.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-vpr7ys7ggvs2fzpg8wbjc...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-top.c | 2 +-
 tools/perf/ui/gtk/annotate.c | 2 +-
 tools/perf/util/annotate.c   | 7 +--
 tools/perf/util/annotate.h   | 1 +
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 5e58cd4de90b..2c14ca61c657 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -133,7 +133,7 @@ static int perf_top__parse_source(struct perf_top *top, 
struct hist_entry *he)
return err;
}
 
-   err = symbol__annotate(sym, map, evsel, 0, NULL);
+   err = symbol__annotate(sym, map, evsel, 0, >annotation_opts, NULL);
if (err == 0) {
top->sym_filter_entry = he;
} else {
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index aeeaf15029f0..48428c9acd89 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -169,7 +169,7 @@ static int symbol__gtk_annotate(struct symbol *sym, struct 
map *map,
if (map->dso->annotate_warned)
return -1;
 
-   err = symbol__annotate(sym, map, evsel, 0, NULL);
+   err = symbol__annotate(sym, map, evsel, 0, 
__default_options, NULL);
if (err) {
char msg[BUFSIZ];
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index abcc7e24c365..502f9d124a44 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1067,6 +1067,7 @@ struct annotate_args {
struct arch *arch;
struct map_symbolms;
struct perf_evsel   *evsel;
+   struct annotation_options *options;
s64  offset;
char*line;
int  line_nr;
@@ -1803,11 +1804,13 @@ void symbol__calc_percent(struct symbol *sym, struct 
perf_evsel *evsel)
 
 int symbol__annotate(struct symbol *sym, struct map *map,
 struct perf_evsel *evsel, size_t privsize,
+struct annotation_options *options,
 struct arch **parch)
 {
struct annotate_args args = {
.privsize   = privsize,
.evsel  = evsel,
+   .options= options,
};
struct perf_env *env = perf_evsel__env(evsel);
const char *arch_name = perf_env__arch(env);
@@ -2409,7 +2412,7 @@ int symbol__tty_annotate(struct symbol *sym, struct map 
*map,
struct dso *dso = map->dso;
struct rb_root source_line = RB_ROOT;
 
-   if (symbol__annotate(sym, map, evsel, 0, NULL) < 0)
+   if (symbol__annotate(sym, map, evsel, 0, opts, NULL) < 0)
return -1;
 
symbol__calc_percent(sym, evsel);
@@ -2655,7 +2658,7 @@ int symbol__annotate2(struct symbol *sym, struct map 
*map, struct perf_evsel *ev
if (perf_evsel__is_group_event(evsel))
nr_pcnt = evsel->nr_members;
 
-   err = symbol__annotate(sym, map, evsel, 0, parch);
+   err = symbol__annotate(sym, map, evsel, 0, options, parch);
if (err)
goto out_free_offsets;
 
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 20f3326cc640..013d414b0e57 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -306,6 +306,7 @@ void symbol__annotate_zero_histograms(struct symbol *sym);
 
 int symbol__annotate(struct symbol *sym, struct map *map,
 struct perf_evsel *evsel, size_t privsize,
+struct annotation_options *options,
 struct arch **parch);
 int symbol__annotate2(struct symbol *sym, struct map *map,
  struct perf_evsel *evsel,
-- 
2.14.3



Re: [PATCH] mremap: Avoid TLB flushing anonymous pages that are not in swap cache

2018-06-05 Thread Dave Hansen
On 06/05/2018 10:13 AM, Mel Gorman wrote:
> The anonymous page race fix is overkill for two reasons. Pages that are not
> in the swap cache are not going to be issued for IO and if a stale TLB entry
> is used, the write still occurs on the same physical page. Any race with
> mmap replacing the address space is handled by mmap_sem. As anonymous pages
> are often dirty, it can mean that mremap always has to flush even when it is
> not necessary.

This looks fine to me.  One nit on the description: I found myself
wondering if we skip the flush under the ptl where the flush is
eventually done.  That code is a bit out of the context, so we don't see
it in the patch.

We have two modes of flushing during move_ptes():
1. The flush_tlb_range() while holding the ptl in move_ptes().
2. A flush_tlb_range() at the end of move_table_tables(), driven by
  'need_flush' which will be set any time move_ptes() does *not* flush.

This patch broadens the scope where move_ptes() does not flush and
shifts the burden to the flush inside move_table_tables().

Right?

Other minor nits:

> +/* Returns true if a TLB must be flushed before PTL is dropped */
> +static bool should_force_flush(pte_t *pte)
> +{

I usually try to make the non-pte-modifying functions take a pte_t
instead of 'pte_t *' to make it obvious that there no modification going
on.  Any reason not to do that here?

> + if (!trylock_page(page))
> + return true;
> + is_swapcache = PageSwapCache(page);
> + unlock_page(page);
> +
> + return is_swapcache;
> +}

I was hoping we didn't have to go as far as taking the page lock, but I
guess the proof is in the pudding that this tradeoff is worth it.

BTW, do you want to add a tiny comment about why we do the
trylock_page()?  I assume it's because we don't want to wait on finding
an exact answer: we just assume it is in the swap cache if the page is
locked and flush regardless.


Re: [PATCH] sparc: fix compat siginfo ABI regression

2018-06-05 Thread David Miller
From: "Dmitry V. Levin" 
Date: Fri, 13 Apr 2018 17:19:02 +0300

> Starting with commit v4.14-rc1~60^2^2~1, a SIGFPE signal sent via kill
> results to wrong values in si_pid and si_uid fields of compat siginfo_t.
> 
> This happens due to FPE_FIXME being defined to 0 for sparc, and at the
> same time siginfo_layout() introduced by the same commit returns
> SIL_FAULT for SIGFPE if si_code == SI_USER and FPE_FIXME is defined to 0.
> 
> Fix this regression by removing FPE_FIXME macro and changing all its users
> to assign FPE_FLTUNK to si_code instead of FPE_FIXME.
> 
> Note that FPE_FLTUNK is a new macro introduced by commit
> 266da65e9156d93e1126e185259a4aae68188d0e.
> 
> Tested with commit v4.16-11958-g16e205cf42da.
> 
> This bug was found by strace test suite.
> 
> Link: https://github.com/strace/strace/issues/21
> Fixes: cc731525f26a ("signal: Remove kernel interal si_code magic")
> Thanks-to: Anatoly Pugachev 
> Signed-off-by: Dmitry V. Levin 

Applied and queued up for -stable, thank you.


Re: [alsa-devel] [PATCH 0/3] ASoC: stm32: sai: add support of iec958 controls

2018-06-05 Thread Takashi Iwai
On Tue, 05 Jun 2018 17:50:57 +0200,
Arnaud Pouliquen wrote:
> 
> Hi Takashi,
> 
> On 04/17/2018 01:17 PM, Mark Brown wrote:
> > On Tue, Apr 17, 2018 at 08:29:17AM +, Olivier MOYSAN wrote:
> > 
> >> I guess the blocking patch in this patchset is the patch "add IEC958 
> >> channel status control helper". This patch has been reviewed several 
> >> times, but did not get a ack so far.
> >> If you think these helpers will not be merged, I will reintegrate the 
> >> corresponding code in stm driver.
> >> Please let me know, if I need to prepare a v2 without helpers, or if we 
> >> can go further in the review of iec helpers patch ?
> > 
> > I don't mind either way but you're right here, I'm waiting for Takashi
> > to review the first patch.  I'd probably be OK with it just integrated
> > into the driver if we have to go that way though.
> 
> Gentlemen reminder for this patch set. We would appreciate to have your
> feedback on iec helper.
> From our point of view it could be useful to have a generic management
> of the iec controls based on helpers instead of redefining them in DAIs.
> Having the same behavior for these controls could be useful to ensure
> coherence of the control management used by application (for instance
> Gstreamer uses it to determine iec raw mode capability for iec61937 streams)

Oh sorry for the late reply, I've totally overlooked the thread.

And, another sorry: the patchset doesn't look convincing enough to
me.

First off, the provided API definition appears somewhat
unconventional, the mixture of the ops, the static data and the
dynamic data.

Moreover, this is only for your driver, ATM.  If it were an API that
does clean up the already existing usages, I'd happily apply it. There
are lots of drivers creating and controlling the IEC958 ctls even
now.

Also, the patchset requires more fine-tuning, in anyways.  The changes
in create_iec958_consumre() are basically irrelevant, should be split
off as an individual fix.  Also, the new function doesn't create the
"XXX Mask" controls.  And the byte comparison should be replaced with
memcmp(), etc, etc.

So, please proceed rather with the open codes for now.  If you can
provide a patch that cleans up the *multiple* driver codes, again,
I'll happily take it.  But it can be done anytime later, too.


thanks,

Takashi


Re: building in 32bit chroot on x86_64 host broken

2018-06-05 Thread Thomas Backlund



Den 2018-06-05 kl. 21:38, skrev Linus Torvalds:

On Tue, Jun 5, 2018 at 11:23 AM Thomas Backlund  wrote:

   #
-# CONFIG_64BIT is not set

So something _does_ strip away the needed config bit

Why do you need it?

I get

   CONFIG_X86_32=y
   CONFIG_X86=y

and CONFIG_64BIT never gets set.

It is true that I don't get the

   # CONFIG_64BIT is not set

line, but why do you care?

 Linus


Because without it running the build in the 32bit chroot will get the 
initial reported issue:



$ uname -m
i686
$ make oldconfig
scripts/kconfig/conf  --oldconfig Kconfig
*
* Restart config...
*
*
* Linux/x86 4.17.0 Kernel Configuration
*
64-bit kernel (64BIT) [Y/n/?] (NEW)


which breaks our buildbots running in chroots...


Now I can work around it by adding the config bit myself, but I'd like 
to understand what changed and why...


--
Thomas



Re: [PATCH v2] drivers: base: cacheinfo: use OF property_read_u32 instead of get_property,read_number

2018-06-05 Thread Andy Shevchenko
On Tue, Jun 5, 2018 at 7:26 PM, Sudeep Holla  wrote:
>
>
> On 05/06/18 17:21, Andy Shevchenko wrote:
>> On Mon, May 21, 2018 at 3:53 PM, Sudeep Holla  wrote:
>>> of_property_read_u32 searches for a property in a device node and read
>>> a 32-bit value from it. Instead of using of_get_property to get the
>>> property and then read 32-bit value using of_read_number, we can
>>> simplify it by using of_property_read_u32.
>>>
>>
>> LGTM.
>> Thanks!
>>
>
> Thanks, can I take is Ack ?
>
> Anyways it's too late for v4.18, will repost after the merge window for
> v4.19 with your Ack if you agree.

You can consider like this, though it makes a little change here since
I'm not a maintainer of the code.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v1] kthread/smpboot: Serialize kthread parking against wakeup

2018-06-05 Thread Oleg Nesterov
On 06/05, Peter Zijlstra wrote:
>
> On Tue, Jun 05, 2018 at 05:22:12PM +0200, Peter Zijlstra wrote:
> 
> > > OK, but __kthread_parkme() can be preempted before it calls schedule(), 
> > > so the
> > > caller still can be migrated? Plus kthread_park_complete() can be called 
> > > twice.
> > 
> > Argh... I forgot TASK_DEAD does the whole thing with preempt_disable().
> > Let me stare at that a bit.
> 
> This should ensure we only ever complete when we read PARKED, right?
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 8d59b259af4a..e513b4600796 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2641,7 +2641,7 @@ prepare_task_switch(struct rq *rq, struct task_struct 
> *prev,
>   * past. prev == current is still correct but we need to recalculate this_rq
>   * because prev may have moved to another CPU.
>   */
> -static struct rq *finish_task_switch(struct task_struct *prev)
> +static struct rq *finish_task_switch(struct task_struct *prev, bool preempt)
>   __releases(rq->lock)
>  {
>   struct rq *rq = this_rq();
> @@ -2674,7 +2674,7 @@ static struct rq *finish_task_switch(struct task_struct 
> *prev)
>*
>* We must observe prev->state before clearing prev->on_cpu (in
>* finish_task), otherwise a concurrent wakeup can get prev
> -  * running on another CPU and we could rave with its RUNNING -> DEAD
> +  * running on another CPU and we could race with its RUNNING -> DEAD
>* transition, resulting in a double drop.
>*/
>   prev_state = prev->state;
> @@ -2720,7 +2720,8 @@ static struct rq *finish_task_switch(struct task_struct 
> *prev)
>   break;
>
>   case TASK_PARKED:
> - kthread_park_complete(prev);
> + if (!preempt)
> + kthread_park_complete(prev);


Yes, but this won't fix the race decribed by Kohli...

Plus this complicates the schedule() paths for the very special case, and to me
it seems that all this kthread_park/unpark logic needs some serious cleanups...

Not that I can suggest something better right now.

Oleg.



[PATCH 4.4 02/37] powerpc/64s: Clear PCR on boot

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Neuling 

commit faf37c44a105f3608115785f17cbbf3500f8bc71 upstream.

Clear the PCR (Processor Compatibility Register) on boot to ensure we
are not running in a compatibility mode.

We've seen this cause problems when a crash (and kdump) occurs while
running compat mode guests. The kdump kernel then runs with the PCR
set and causes problems. The symptom in the kdump kernel (also seen in
petitboot after fast-reboot) is early userspace programs taking
sigills on newer instructions (seen in libc).

Signed-off-by: Michael Neuling 
Cc: sta...@vger.kernel.org
Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/powerpc/kernel/cpu_setup_power.S |4 
 1 file changed, 4 insertions(+)

--- a/arch/powerpc/kernel/cpu_setup_power.S
+++ b/arch/powerpc/kernel/cpu_setup_power.S
@@ -27,6 +27,7 @@ _GLOBAL(__setup_cpu_power7)
beqlr
li  r0,0
mtspr   SPRN_LPID,r0
+   mtspr   SPRN_PCR,r0
mfspr   r3,SPRN_LPCR
bl  __init_LPCR
bl  __init_tlb_power7
@@ -40,6 +41,7 @@ _GLOBAL(__restore_cpu_power7)
beqlr
li  r0,0
mtspr   SPRN_LPID,r0
+   mtspr   SPRN_PCR,r0
mfspr   r3,SPRN_LPCR
bl  __init_LPCR
bl  __init_tlb_power7
@@ -55,6 +57,7 @@ _GLOBAL(__setup_cpu_power8)
beqlr
li  r0,0
mtspr   SPRN_LPID,r0
+   mtspr   SPRN_PCR,r0
mfspr   r3,SPRN_LPCR
ori r3, r3, LPCR_PECEDH
bl  __init_LPCR
@@ -74,6 +77,7 @@ _GLOBAL(__restore_cpu_power8)
beqlr
li  r0,0
mtspr   SPRN_LPID,r0
+   mtspr   SPRN_PCR,r0
mfspr   r3,SPRN_LPCR
ori r3, r3, LPCR_PECEDH
bl  __init_LPCR




[PATCH 4.4 22/37] i2c: rcar: check master irqs before slave irqs

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Wolfram Sang 

commit c3be0af15959e11fa535d5332ab3d7cf34abd09b upstream.

Due to the HW design, master IRQs are timing critical, so give them
precedence over slave IRQ.

Signed-off-by: Wolfram Sang 
Signed-off-by: Wolfram Sang 
Signed-off-by: Fabrizio Castro 
Reviewed-by: Biju Das 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/i2c/busses/i2c-rcar.c |   13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -432,19 +432,17 @@ static bool rcar_i2c_slave_irq(struct rc
 static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
 {
struct rcar_i2c_priv *priv = ptr;
-   irqreturn_t result = IRQ_HANDLED;
u32 msr;
 
-   if (rcar_i2c_slave_irq(priv))
-   goto exit;
-
msr = rcar_i2c_read(priv, ICMSR);
 
/* Only handle interrupts that are currently enabled */
msr &= rcar_i2c_read(priv, ICMIER);
if (!msr) {
-   result = IRQ_NONE;
-   goto exit;
+   if (rcar_i2c_slave_irq(priv))
+   return IRQ_HANDLED;
+
+   return IRQ_NONE;
}
 
/* Arbitration lost */
@@ -481,8 +479,7 @@ out:
wake_up(>wait);
}
 
-exit:
-   return result;
+   return IRQ_HANDLED;
 }
 
 static int rcar_i2c_master_xfer(struct i2c_adapter *adap,




[PATCH 4.4 03/37] USB: serial: cp210x: use tcflag_t to fix incompatible pointer type

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Geert Uytterhoeven 

commit 009615ab7fd4e43b82a38e4e6adc5e23c1ee567f upstream.

On sparc32, tcflag_t is unsigned long, unlike all other architectures:

drivers/usb/serial/cp210x.c: In function 'cp210x_get_termios':
drivers/usb/serial/cp210x.c:717:3: warning: passing argument 2 of 
'cp210x_get_termios_port' from incompatible pointer type
   cp210x_get_termios_port(tty->driver_data,
   ^
drivers/usb/serial/cp210x.c:35:13: note: expected 'unsigned int *' but 
argument is of type 'tcflag_t *'
 static void cp210x_get_termios_port(struct usb_serial_port *port,
 ^

Consistently use tcflag_t to fix this.

Signed-off-by: Geert Uytterhoeven 
Signed-off-by: Johan Hovold 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/serial/cp210x.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -33,7 +33,7 @@ static int cp210x_open(struct tty_struct
 static void cp210x_close(struct usb_serial_port *);
 static void cp210x_get_termios(struct tty_struct *, struct usb_serial_port *);
 static void cp210x_get_termios_port(struct usb_serial_port *port,
-   unsigned int *cflagp, unsigned int *baudp);
+   tcflag_t *cflagp, unsigned int *baudp);
 static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
struct ktermios *);
 static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
@@ -515,7 +515,7 @@ static void cp210x_get_termios(struct tt
>termios.c_cflag, );
tty_encode_baud_rate(tty, baud, baud);
} else {
-   unsigned int cflag;
+   tcflag_t cflag;
cflag = 0;
cp210x_get_termios_port(port, , );
}
@@ -526,10 +526,11 @@ static void cp210x_get_termios(struct tt
  * This is the heart of cp210x_get_termios which always uses a 
_serial_port.
  */
 static void cp210x_get_termios_port(struct usb_serial_port *port,
-   unsigned int *cflagp, unsigned int *baudp)
+   tcflag_t *cflagp, unsigned int *baudp)
 {
struct device *dev = >dev;
-   unsigned int cflag, modem_ctl[4];
+   tcflag_t cflag;
+   unsigned int modem_ctl[4];
unsigned int baud;
unsigned int bits;
 




[PATCH 4.4 21/37] i2c: rcar: dont issue stop when HW does it automatically

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Wolfram Sang 

commit d89667b14f9d13b684287f6189ca209af5feee43 upstream.

The manual says (55.4.8.6) that HW does automatically send STOP after
NACK was received. My measuerments confirm that.

Signed-off-by: Wolfram Sang 
Signed-off-by: Wolfram Sang 
Signed-off-by: Fabrizio Castro 
Reviewed-by: Biju Das 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/i2c/busses/i2c-rcar.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -455,8 +455,8 @@ static irqreturn_t rcar_i2c_irq(int irq,
 
/* Nack */
if (msr & MNR) {
-   /* go to stop phase */
-   rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
+   /* HW automatically sends STOP after received NACK */
+   rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP);
rcar_i2c_flags_set(priv, ID_NACK);
goto out;




[PATCH 4.4 28/37] scsi: scsi_transport_srp: Fix shost to rport translation

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Bart Van Assche 

commit c9ddf73476ff4fffb7a87bd5107a0705bf2cf64b upstream.

Since an SRP remote port is attached as a child to shost->shost_gendev
and as the only child, the translation from the shost pointer into an
rport pointer must happen by looking up the shost child that is an
rport. This patch fixes the following KASAN complaint:

BUG: KASAN: slab-out-of-bounds in srp_timed_out+0x57/0x110 [scsi_transport_srp]
Read of size 4 at addr 880035d3fcc0 by task kworker/1:0H/19

CPU: 1 PID: 19 Comm: kworker/1:0H Not tainted 4.16.0-rc3-dbg+ #1
Workqueue: kblockd blk_mq_timeout_work
Call Trace:
dump_stack+0x85/0xc7
print_address_description+0x65/0x270
kasan_report+0x231/0x350
srp_timed_out+0x57/0x110 [scsi_transport_srp]
scsi_times_out+0xc7/0x3f0 [scsi_mod]
blk_mq_terminate_expired+0xc2/0x140
bt_iter+0xbc/0xd0
blk_mq_queue_tag_busy_iter+0x1c7/0x350
blk_mq_timeout_work+0x325/0x3f0
process_one_work+0x441/0xa50
worker_thread+0x76/0x6c0
kthread+0x1b2/0x1d0
ret_from_fork+0x24/0x30

Fixes: e68ca75200fe ("scsi_transport_srp: Reduce failover time")
Signed-off-by: Bart Van Assche 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
Cc: Jason Gunthorpe 
Cc: Doug Ledford 
Cc: Laurence Oberman 
Cc: sta...@vger.kernel.org
Reviewed-by: Johannes Thumshirn 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/scsi/scsi_transport_srp.c |   22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -52,6 +52,8 @@ struct srp_internal {
struct transport_container rport_attr_cont;
 };
 
+static int scsi_is_srp_rport(const struct device *dev);
+
 #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t)
 
 #definedev_to_rport(d) container_of(d, struct srp_rport, dev)
@@ -61,9 +63,24 @@ static inline struct Scsi_Host *rport_to
return dev_to_shost(r->dev.parent);
 }
 
+static int find_child_rport(struct device *dev, void *data)
+{
+   struct device **child = data;
+
+   if (scsi_is_srp_rport(dev)) {
+   WARN_ON_ONCE(*child);
+   *child = dev;
+   }
+   return 0;
+}
+
 static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost)
 {
-   return transport_class_to_srp_rport(>shost_gendev);
+   struct device *child = NULL;
+
+   WARN_ON_ONCE(device_for_each_child(>shost_gendev, ,
+  find_child_rport) < 0);
+   return child ? dev_to_rport(child) : NULL;
 }
 
 /**
@@ -637,7 +654,8 @@ static enum blk_eh_timer_return srp_time
struct srp_rport *rport = shost_to_rport(shost);
 
pr_debug("timeout for sdev %s\n", dev_name(>sdev_gendev));
-   return rport->fast_io_fail_tmo < 0 && rport->dev_loss_tmo < 0 &&
+   return rport && rport->fast_io_fail_tmo < 0 &&
+   rport->dev_loss_tmo < 0 &&
i->f->reset_timer_if_blocked && scsi_device_blocked(sdev) ?
BLK_EH_RESET_TIMER : BLK_EH_NOT_HANDLED;
 }




[PATCH 4.4 33/37] fix io_destroy()/aio_complete() race

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Al Viro 

commit 4faa99965e027cc057c5145ce45fa772caa04e8d upstream.

If io_destroy() gets to cancelling everything that can be cancelled and
gets to kiocb_cancel() calling the function driver has left in ->ki_cancel,
it becomes vulnerable to a race with IO completion.  At that point req
is already taken off the list and aio_complete() does *NOT* spin until
we (in free_ioctx_users()) releases ->ctx_lock.  As the result, it proceeds
to kiocb_free(), freing req just it gets passed to ->ki_cancel().

Fix is simple - remove from the list after the call of kiocb_cancel().  All
instances of ->ki_cancel() already have to cope with the being called with
iocb still on list - that's what happens in io_cancel(2).

Cc: sta...@kernel.org
Fixes: 0460fef2a921 "aio: use cancellation list lazily"
Signed-off-by: Al Viro 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/aio.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/aio.c
+++ b/fs/aio.c
@@ -628,9 +628,8 @@ static void free_ioctx_users(struct perc
while (!list_empty(>active_reqs)) {
req = list_first_entry(>active_reqs,
   struct aio_kiocb, ki_list);
-
-   list_del_init(>ki_list);
kiocb_cancel(req);
+   list_del_init(>ki_list);
}
 
spin_unlock_irq(>ctx_lock);




Re: linux-next: manual merge of the kvm tree with the arm64 tree

2018-06-05 Thread Paolo Bonzini
On 04/06/2018 09:33, Dave Martin wrote:
> On Mon, Jun 04, 2018 at 04:57:54PM +1000, Stephen Rothwell wrote:
>> Hi all,
>>
>> Today's linux-next merge of the kvm tree got a conflict in:
>>
>>   arch/arm64/include/asm/processor.h
>>
>> between commit:
>>
>>   94b07c1f8c39 ("arm64: signal: Report signal frame size to userspace via 
>> auxv")
>>
>> from the arm64 tree and commit:
>>
>>   9a6e594869b2 ("arm64/sve: Move sve_pffr() to fpsimd.h and make inline")
>>
>> from the kvm tree.
>>
>> I fixed it up (see below) and can carry the fix as necessary. This
>> is now fixed as far as linux-next is concerned, but any non trivial
>> conflicts should be mentioned to your upstream maintainer when your tree
>> is submitted for merging.  You may also want to consider cooperating
>> with the maintainer of the conflicting tree to minimise any particularly
>> complex conflicts.
> 
> The resolution looks fine here, thanks.

Looks good, but it would have been even better if the ARM64 tree
provided a topic branch and the kvm/arm tree pulled it.

Thanks,

Paolo

> ---Dave
> 
>>
>> -- 
>> Cheers,
>> Stephen Rothwell
>>
>> diff --cc arch/arm64/include/asm/processor.h
>> index 65ab83e8926e,c99e657fdd57..
>> --- a/arch/arm64/include/asm/processor.h
>> +++ b/arch/arm64/include/asm/processor.h
>> @@@ -246,9 -246,17 +248,20 @@@ void cpu_enable_pan(const struct arm64_
>>   void cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities 
>> *__unused);
>>   void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused);
>>   
>>  +extern unsigned long __ro_after_init signal_minsigstksz; /* sigframe size 
>> */
>>  +extern void __init minsigstksz_setup(void);
>>  +
>> + /*
>> +  * Not at the top of the file due to a direct #include cycle between
>> +  *  and .  Deferring this #include
>> +  * ensures that contents of processor.h are visible to fpsimd.h even if
>> +  * processor.h is included first.
>> +  *
>> +  * These prctl helpers are the only things in this file that require
>> +  * fpsimd.h.  The core code expects them to be in this header.
>> +  */
>> + #include 
>> + 
>>   /* Userspace interface for PR_SVE_{SET,GET}_VL prctl()s: */
>>   #define SVE_SET_VL(arg)sve_set_current_vl(arg)
>>   #define SVE_GET_VL()   sve_get_current_vl()
> 
> 



[PATCH 4.9 03/61] USB: serial: cp210x: use tcflag_t to fix incompatible pointer type

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Geert Uytterhoeven 

commit 009615ab7fd4e43b82a38e4e6adc5e23c1ee567f upstream.

On sparc32, tcflag_t is unsigned long, unlike all other architectures:

drivers/usb/serial/cp210x.c: In function 'cp210x_get_termios':
drivers/usb/serial/cp210x.c:717:3: warning: passing argument 2 of 
'cp210x_get_termios_port' from incompatible pointer type
   cp210x_get_termios_port(tty->driver_data,
   ^
drivers/usb/serial/cp210x.c:35:13: note: expected 'unsigned int *' but 
argument is of type 'tcflag_t *'
 static void cp210x_get_termios_port(struct usb_serial_port *port,
 ^

Consistently use tcflag_t to fix this.

Signed-off-by: Geert Uytterhoeven 
Signed-off-by: Johan Hovold 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/usb/serial/cp210x.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -33,7 +33,7 @@ static int cp210x_open(struct tty_struct
 static void cp210x_close(struct usb_serial_port *);
 static void cp210x_get_termios(struct tty_struct *, struct usb_serial_port *);
 static void cp210x_get_termios_port(struct usb_serial_port *port,
-   unsigned int *cflagp, unsigned int *baudp);
+   tcflag_t *cflagp, unsigned int *baudp);
 static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
struct ktermios *);
 static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
@@ -728,7 +728,7 @@ static void cp210x_get_termios(struct tt
>termios.c_cflag, );
tty_encode_baud_rate(tty, baud, baud);
} else {
-   unsigned int cflag;
+   tcflag_t cflag;
cflag = 0;
cp210x_get_termios_port(port, , );
}
@@ -739,10 +739,10 @@ static void cp210x_get_termios(struct tt
  * This is the heart of cp210x_get_termios which always uses a 
_serial_port.
  */
 static void cp210x_get_termios_port(struct usb_serial_port *port,
-   unsigned int *cflagp, unsigned int *baudp)
+   tcflag_t *cflagp, unsigned int *baudp)
 {
struct device *dev = >dev;
-   unsigned int cflag;
+   tcflag_t cflag;
struct cp210x_flow_ctl flow_ctl;
u32 baud;
u16 bits;




[PATCH 4.9 58/61] fix io_destroy()/aio_complete() race

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Al Viro 

commit 4faa99965e027cc057c5145ce45fa772caa04e8d upstream.

If io_destroy() gets to cancelling everything that can be cancelled and
gets to kiocb_cancel() calling the function driver has left in ->ki_cancel,
it becomes vulnerable to a race with IO completion.  At that point req
is already taken off the list and aio_complete() does *NOT* spin until
we (in free_ioctx_users()) releases ->ctx_lock.  As the result, it proceeds
to kiocb_free(), freing req just it gets passed to ->ki_cancel().

Fix is simple - remove from the list after the call of kiocb_cancel().  All
instances of ->ki_cancel() already have to cope with the being called with
iocb still on list - that's what happens in io_cancel(2).

Cc: sta...@kernel.org
Fixes: 0460fef2a921 "aio: use cancellation list lazily"
Signed-off-by: Al Viro 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/aio.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/aio.c
+++ b/fs/aio.c
@@ -636,9 +636,8 @@ static void free_ioctx_users(struct perc
while (!list_empty(>active_reqs)) {
req = list_first_entry(>active_reqs,
   struct aio_kiocb, ki_list);
-
-   list_del_init(>ki_list);
kiocb_cancel(req);
+   list_del_init(>ki_list);
}
 
spin_unlock_irq(>ctx_lock);




[PATCH 4.9 24/61] powerpc/rfi-flush: Move out of HARDLOCKUP_DETECTOR #ifdef

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Ellerman 

The backport of the RFI flush support, done by me, has a minor bug in
that the code is inside an #ifdef CONFIG_HARDLOCKUP_DETECTOR, which is
incorrect.

This doesn't matter with common configs because we enable
HARDLOCKUP_DETECTOR, but with future patches it will break the build.
So fix it.

Fixes: c3b82ebee6e0 ("powerpc/64s: Add support for RFI flush of L1-D cache")
Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/kernel/setup_64.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -679,6 +679,7 @@ static int __init disable_hardlockup_det
return 0;
 }
 early_initcall(disable_hardlockup_detector);
+#endif /* CONFIG_HARDLOCKUP_DETECTOR */
 
 #ifdef CONFIG_PPC_BOOK3S_64
 static enum l1d_flush_type enabled_flush_types;
@@ -806,4 +807,3 @@ ssize_t cpu_show_meltdown(struct device
return sprintf(buf, "Vulnerable\n");
 }
 #endif /* CONFIG_PPC_BOOK3S_64 */
-#endif




[PATCH 4.9 33/61] powerpc: Add security feature flags for Spectre/Meltdown

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Ellerman 

commit 9a868f634349e62922c226834aa23e3d1329ae7f upstream.

This commit adds security feature flags to reflect the settings we
receive from firmware regarding Spectre/Meltdown mitigations.

The feature names reflect the names we are given by firmware on bare
metal machines. See the hostboot source for details.

Arguably these could be firmware features, but that then requires them
to be read early in boot so they're available prior to asm feature
patching, but we don't actually want to use them for patching. We may
also want to dynamically update them in future, which would be
incompatible with the way firmware features work (at the moment at
least). So for now just make them separate flags.

Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/include/asm/security_features.h |   65 +++
 arch/powerpc/kernel/Makefile |2 
 arch/powerpc/kernel/security.c   |   15 ++
 3 files changed, 81 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/include/asm/security_features.h
 create mode 100644 arch/powerpc/kernel/security.c

--- /dev/null
+++ b/arch/powerpc/include/asm/security_features.h
@@ -0,0 +1,65 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Security related feature bit definitions.
+ *
+ * Copyright 2018, Michael Ellerman, IBM Corporation.
+ */
+
+#ifndef _ASM_POWERPC_SECURITY_FEATURES_H
+#define _ASM_POWERPC_SECURITY_FEATURES_H
+
+
+extern unsigned long powerpc_security_features;
+
+static inline void security_ftr_set(unsigned long feature)
+{
+   powerpc_security_features |= feature;
+}
+
+static inline void security_ftr_clear(unsigned long feature)
+{
+   powerpc_security_features &= ~feature;
+}
+
+static inline bool security_ftr_enabled(unsigned long feature)
+{
+   return !!(powerpc_security_features & feature);
+}
+
+
+// Features indicating support for Spectre/Meltdown mitigations
+
+// The L1-D cache can be flushed with ori r30,r30,0
+#define SEC_FTR_L1D_FLUSH_ORI300x0001ull
+
+// The L1-D cache can be flushed with mtspr 882,r0 (aka SPRN_TRIG2)
+#define SEC_FTR_L1D_FLUSH_TRIG20x0002ull
+
+// ori r31,r31,0 acts as a speculation barrier
+#define SEC_FTR_SPEC_BAR_ORI31 0x0004ull
+
+// Speculation past bctr is disabled
+#define SEC_FTR_BCCTRL_SERIALISED  0x0008ull
+
+// Entries in L1-D are private to a SMT thread
+#define SEC_FTR_L1D_THREAD_PRIV0x0010ull
+
+// Indirect branch prediction cache disabled
+#define SEC_FTR_COUNT_CACHE_DISABLED   0x0020ull
+
+
+// Features indicating need for Spectre/Meltdown mitigations
+
+// The L1-D cache should be flushed on MSR[HV] 1->0 transition (hypervisor to 
guest)
+#define SEC_FTR_L1D_FLUSH_HV   0x0040ull
+
+// The L1-D cache should be flushed on MSR[PR] 0->1 transition (kernel to 
userspace)
+#define SEC_FTR_L1D_FLUSH_PR   0x0080ull
+
+// A speculation barrier should be used for bounds checks (Spectre variant 1)
+#define SEC_FTR_BNDS_CHK_SPEC_BAR  0x0100ull
+
+// Firmware configuration indicates user favours security over performance
+#define SEC_FTR_FAVOUR_SECURITY0x0200ull
+
+#endif /* _ASM_POWERPC_SECURITY_FEATURES_H */
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -44,7 +44,7 @@ obj-$(CONFIG_PPC64)   += setup_64.o sys_p
 obj-$(CONFIG_VDSO32)   += vdso32/
 obj-$(CONFIG_HAVE_HW_BREAKPOINT)   += hw_breakpoint.o
 obj-$(CONFIG_PPC_BOOK3S_64)+= cpu_setup_ppc970.o cpu_setup_pa6t.o
-obj-$(CONFIG_PPC_BOOK3S_64)+= cpu_setup_power.o
+obj-$(CONFIG_PPC_BOOK3S_64)+= cpu_setup_power.o security.o
 obj-$(CONFIG_PPC_BOOK3S_64)+= mce.o mce_power.o
 obj-$(CONFIG_PPC_BOOK3E_64)+= exceptions-64e.o idle_book3e.o
 obj-$(CONFIG_PPC64)+= vdso64/
--- /dev/null
+++ b/arch/powerpc/kernel/security.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Security related flags and so on.
+//
+// Copyright 2018, Michael Ellerman, IBM Corporation.
+
+#include 
+#include 
+
+
+unsigned long powerpc_security_features __read_mostly = \
+   SEC_FTR_L1D_FLUSH_HV | \
+   SEC_FTR_L1D_FLUSH_PR | \
+   SEC_FTR_BNDS_CHK_SPEC_BAR | \
+   SEC_FTR_FAVOUR_SECURITY;




[PATCH 4.9 31/61] powerpc/rfi-flush: Call setup_rfi_flush() after LPM migration

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Ellerman 

commit 921bc6cf807ceb2ab8005319cf39f33494d6b100 upstream.

We might have migrated to a machine that uses a different flush type,
or doesn't need flushing at all.

Signed-off-by: Michael Ellerman 
Signed-off-by: Mauricio Faria de Oliveira 
Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/pseries/mobility.c |3 +++
 arch/powerpc/platforms/pseries/pseries.h  |2 ++
 arch/powerpc/platforms/pseries/setup.c|2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -314,6 +314,9 @@ void post_mobility_fixup(void)
printk(KERN_ERR "Post-mobility device tree update "
"failed: %d\n", rc);
 
+   /* Possibly switch to a new RFI flush type */
+   pseries_setup_rfi_flush();
+
return;
 }
 
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -79,4 +79,6 @@ extern struct pci_controller_ops pseries
 
 unsigned long pseries_memory_block_size(void);
 
+void pseries_setup_rfi_flush(void);
+
 #endif /* _PSERIES_PSERIES_H */
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -450,7 +450,7 @@ static void __init find_and_init_phbs(vo
of_pci_check_probe_only();
 }
 
-static void pseries_setup_rfi_flush(void)
+void pseries_setup_rfi_flush(void)
 {
struct h_cpu_char_result result;
enum l1d_flush_type types;




[PATCH 4.9 18/61] tcp: avoid integer overflows in tcp_rcv_space_adjust()

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Eric Dumazet 

commit 607065bad9931e72207b0cac365d7d4abc06bd99 upstream.

When using large tcp_rmem[2] values (I did tests with 500 MB),
I noticed overflows while computing rcvwin.

Lets fix this before the following patch.

Signed-off-by: Eric Dumazet 
Acked-by: Soheil Hassas Yeganeh 
Acked-by: Wei Wang 
Acked-by: Neal Cardwell 
Signed-off-by: David S. Miller 
[Backport: sysctl_tcp_rmem is not Namespace-ify'd in older kernels]
Signed-off-by: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/tcp.h  |2 +-
 net/ipv4/tcp_input.c |   10 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -337,7 +337,7 @@ struct tcp_sock {
 
 /* Receiver queue space */
struct {
-   int space;
+   u32 space;
u32 seq;
u32 time;
} rcvq_space;
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -581,8 +581,8 @@ static inline void tcp_rcv_rtt_measure_t
 void tcp_rcv_space_adjust(struct sock *sk)
 {
struct tcp_sock *tp = tcp_sk(sk);
+   u32 copied;
int time;
-   int copied;
 
time = tcp_time_stamp - tp->rcvq_space.time;
if (time < (tp->rcv_rtt_est.rtt >> 3) || tp->rcv_rtt_est.rtt == 0)
@@ -604,12 +604,13 @@ void tcp_rcv_space_adjust(struct sock *s
 
if (sysctl_tcp_moderate_rcvbuf &&
!(sk->sk_userlocks & SOCK_RCVBUF_LOCK)) {
-   int rcvwin, rcvmem, rcvbuf;
+   int rcvmem, rcvbuf;
+   u64 rcvwin;
 
/* minimal window to cope with packet losses, assuming
 * steady state. Add some cushion because of small variations.
 */
-   rcvwin = (copied << 1) + 16 * tp->advmss;
+   rcvwin = ((u64)copied << 1) + 16 * tp->advmss;
 
/* If rate increased by 25%,
 *  assume slow start, rcvwin = 3 * copied
@@ -629,7 +630,8 @@ void tcp_rcv_space_adjust(struct sock *s
while (tcp_win_from_space(rcvmem) < tp->advmss)
rcvmem += 128;
 
-   rcvbuf = min(rcvwin / tp->advmss * rcvmem, sysctl_tcp_rmem[2]);
+   do_div(rcvwin, tp->advmss);
+   rcvbuf = min_t(u64, rcvwin * rcvmem, sysctl_tcp_rmem[2]);
if (rcvbuf > sk->sk_rcvbuf) {
sk->sk_rcvbuf = rcvbuf;
 




RE: [PATCH v3 03/10] mfd: da9063: Rename PMIC_DA9063 to PMIC_CHIP_ID_DA9063

2018-06-05 Thread Steve Twiss


On 04 June 2018 19:32, Marek Vasut wrote,

> Subject: Re: [PATCH v3 03/10] mfd: da9063: Rename PMIC_DA9063 to
> PMIC_CHIP_ID_DA9063
> 
> On 06/04/2018 02:26 PM, Lee Jones wrote:
> > On Sat, 02 Jun 2018, Marek Vasut wrote:
> >
> >> The PMIC_DA9063 is a complete misnomer, it denotes the value of the
> >> DA9063 chip ID register, so rename it as such. It is also the value
> >> of chip ID register of DA9063L though, so drop the enum as all the
> >> DA9063 "models" share the same chip ID and thus the distinction will
> >> have to be made using DT or otherwise.
> >>
> >> Signed-off-by: Marek Vasut 
> >> Cc: Geert Uytterhoeven 
> >> Cc: Lee Jones 
> >> Cc: Mark Brown 
> >> Cc: Steve Twiss 
> >> Cc: Wolfram Sang 
> >> Cc: linux-renesas-...@vger.kernel.org
> >> Acked-by: Mark Brown 
> >> Reviewed-by: Geert Uytterhoeven 
> >> ---
> >> V2: No change
> >> V3: No change
> >> ---
> >>  drivers/mfd/da9063-core.c| 2 +-
> >>  drivers/mfd/da9063-i2c.c | 2 +-
> >>  drivers/regulator/da9063-regulator.c | 2 +-
> >>  include/linux/mfd/da9063/core.h  | 4 +---
> >>  4 files changed, 4 insertions(+), 6 deletions(-)
> >
> > For my own reference:
> >   Acked-for-MFD-by: Lee Jones 
> 
> Thanks.
> 
> Any other comments before I submit the next round in a few days?
> 

Hi Marek,

Thanks.
I'm reviewing it now.
Could you hold off until tomorrow please?

Regards,
Steve


[RFC/PATCH] Input: make input_report_slot_state() return boolean

2018-06-05 Thread Dmitry Torokhov
Let's make input_report_slot_state() return boolean representing whether
the contact is active or not. This will allow writing code like:

if (input_mt_report_slot_state(input, obj->mt_tool,
obj->type != RMI_2D_OBJECT_NONE) {

input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x);
input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y);
...
}

instead of:

input_mt_report_slot_state(input, obj->mt_tool,
   obj->type != RMI_2D_OBJECT_NONE);
if (obj->type != RMI_2D_OBJECT_NONE) {
input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x);
input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y);
...
}

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/input-mt.c | 10 +++---
 include/linux/input/mt.h |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index 7ca4b318ed419..4a69716e54614 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -131,8 +131,10 @@ EXPORT_SYMBOL(input_mt_destroy_slots);
  * inactive, or if the tool type is changed, a new tracking id is
  * assigned to the slot. The tool type is only reported if the
  * corresponding absbit field is set.
+ *
+ * Returns true if contact is active.
  */
-void input_mt_report_slot_state(struct input_dev *dev,
+bool input_mt_report_slot_state(struct input_dev *dev,
unsigned int tool_type, bool active)
 {
struct input_mt *mt = dev->mt;
@@ -140,14 +142,14 @@ void input_mt_report_slot_state(struct input_dev *dev,
int id;
 
if (!mt)
-   return;
+   return false;
 
slot = >slots[mt->slot];
slot->frame = mt->frame;
 
if (!active) {
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
-   return;
+   return false;
}
 
id = input_mt_get_value(slot, ABS_MT_TRACKING_ID);
@@ -156,6 +158,8 @@ void input_mt_report_slot_state(struct input_dev *dev,
 
input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, id);
input_event(dev, EV_ABS, ABS_MT_TOOL_TYPE, tool_type);
+
+   return true;
 }
 EXPORT_SYMBOL(input_mt_report_slot_state);
 
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index d7188de4db968..3f4bf60b0bb55 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -100,7 +100,7 @@ static inline bool input_is_mt_axis(int axis)
return axis == ABS_MT_SLOT || input_is_mt_value(axis);
 }
 
-void input_mt_report_slot_state(struct input_dev *dev,
+bool input_mt_report_slot_state(struct input_dev *dev,
unsigned int tool_type, bool active);
 
 void input_mt_report_finger_count(struct input_dev *dev, int count);
-- 
2.17.1.1185.g55be947832-goog


-- 
Dmitry


[PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations

2018-06-05 Thread Nick Desaulniers
Functions marked extern inline do not emit an externally visible
function when the gnu89 C standard is used. Some KBUILD Makefiles
overwrite KBUILD_CFLAGS. This is an issue for GCC 5.1+ users as without
an explicit C standard specified, the default is gnu11. Since c99, the
semantics of extern inline have changed such that an externally visible
function is always emitted. This can lead to multiple definition errors
of extern inline functions at link time of compilation units whose build
files have removed an explicit C standard compiler flag for users of GCC
5.1+ or Clang.

Signed-off-by: Nick Desaulniers 
Suggested-by: H. Peter Anvin 
Tested-by: Sedat Dilek 
---
 include/linux/compiler-gcc.h | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index b4bf73f5e38f..7827bdf0e5e9 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -72,17 +72,24 @@
  * -Wunused-function.  This turns out to avoid the need for complex #ifdef
  * directives.  Suppress the warning in clang as well by using "unused"
  * function attribute, which is redundant but not harmful for gcc.
+ * Prefer gnu_inline, so that extern inline functions do not emit an
+ * externally visible function. This makes extern inline behave as per gnu89
+ * semantics rather than c99. This prevents multiple symbol definition errors
+ * of extern inline functions at link time.
  */
 #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) ||   \
 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
-#define inline inline  __attribute__((always_inline,unused)) notrace
-#define __inline__ __inline__  __attribute__((always_inline,unused)) notrace
-#define __inline __inline  __attribute__((always_inline,unused)) notrace
+#define inline \
+   inline __attribute__((always_inline, unused, gnu_inline)) notrace
+#define __inline__ \
+   __inline__ __attribute__((always_inline, unused, gnu_inline)) notrace
+#define __inline \
+   __inline __attribute__((always_inline, unused, gnu_inline)) notrace
 #else
 /* A lot of inline functions can cause havoc with function tracing */
-#define inline inline  __attribute__((unused)) notrace
-#define __inline__ __inline__  __attribute__((unused)) notrace
-#define __inline __inline  __attribute__((unused)) notrace
+#define inline inline  __attribute__((unused, gnu_inline)) notrace
+#define __inline__ __inline__  __attribute__((unused, gnu_inline)) notrace
+#define __inline __inline  __attribute__((unused, gnu_inline)) notrace
 #endif
 
 #define __always_inlineinline __attribute__((always_inline))
-- 
2.17.1.1185.g55be947832-goog



[PATCH 4.4 29/37] stm class: Use vmalloc for the master map

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Alexander Shishkin 

commit b5e2ced9bf81393034072dd4d372f6b430bc1f0a upstream.

Fengguang is running into a warning from the buddy allocator:

> swapper/0: page allocation failure: order:9, 
> mode:0x14040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null)
> CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.17.0-rc1 #262
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 
> 04/01/2014
> Call Trace:
...
>  __kmalloc+0x14b/0x180: cache_alloc at mm/slab.c:3127
>  stm_register_device+0xf3/0x5c0: stm_register_device at 
> drivers/hwtracing/stm/core.c:695
...

Which is basically a result of the stm class trying to allocate ~512kB
for the dummy_stm with its default parameters. There's no reason, however,
for it not to be vmalloc()ed instead, which is what this patch does.

Reported-by: Fengguang Wu 
Signed-off-by: Alexander Shishkin 
CC: sta...@vger.kernel.org # v4.4+
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/hwtracing/stm/core.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -602,7 +602,7 @@ static void stm_device_release(struct de
 {
struct stm_device *stm = to_stm_device(dev);
 
-   kfree(stm);
+   vfree(stm);
 }
 
 int stm_register_device(struct device *parent, struct stm_data *stm_data,
@@ -619,7 +619,7 @@ int stm_register_device(struct device *p
return -EINVAL;
 
nmasters = stm_data->sw_end - stm_data->sw_start;
-   stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL);
+   stm = vzalloc(sizeof(*stm) + nmasters * sizeof(void *));
if (!stm)
return -ENOMEM;
 
@@ -656,7 +656,7 @@ int stm_register_device(struct device *p
 err_device:
put_device(>dev);
 err_free:
-   kfree(stm);
+   vfree(stm);
 
return err;
 }




[PATCH 4.4 23/37] i2c: rcar: revoke START request early

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Wolfram Sang 

commit 52df445f29b79006d8b2dcd129152987c0d3bd64 upstream.

If we don't clear START generation as soon as possible, it may cause
another message to be generated, e.g. when receiving NACK in address
phase. To keep the race window as small as possible, we clear it right
at the beginning of the interrupt. We don't need any checks since we
always want to stop START and STOP generation on the next occasion after
we started it.

This patch improves the situation but sadly does not completely fix it.
It is still to be researched if we can do better given this HW design.

Signed-off-by: Wolfram Sang 
Signed-off-by: Wolfram Sang 
Signed-off-by: Fabrizio Castro 
Reviewed-by: Biju Das 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/i2c/busses/i2c-rcar.c |   23 +++
 1 file changed, 7 insertions(+), 16 deletions(-)

--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -83,6 +83,7 @@
 
 #define RCAR_BUS_PHASE_START   (MDBS | MIE | ESG)
 #define RCAR_BUS_PHASE_DATA(MDBS | MIE)
+#define RCAR_BUS_MASK_DATA (~(ESG | FSB) & 0xFF)
 #define RCAR_BUS_PHASE_STOP(MDBS | MIE | FSB)
 
 #define RCAR_IRQ_SEND  (MNR | MAL | MST | MAT | MDE)
@@ -289,13 +290,6 @@ static void rcar_i2c_irq_send(struct rca
if (!(msr & MDE))
return;
 
-   /*
-* If address transfer phase finished,
-* goto data phase.
-*/
-   if (msr & MAT)
-   rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
-
if (priv->pos < msg->len) {
/*
 * Prepare next data to ICRXTX register.
@@ -345,11 +339,7 @@ static void rcar_i2c_irq_recv(struct rca
return;
 
if (msr & MAT) {
-   /*
-* Address transfer phase finished,
-* but, there is no data at this point.
-* Do nothing.
-*/
+   /* Address transfer phase finished, but no data at this point. 
*/
} else if (priv->pos < msg->len) {
/*
 * get received data
@@ -365,8 +355,6 @@ static void rcar_i2c_irq_recv(struct rca
 */
if (priv->pos + 1 >= msg->len)
rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
-   else
-   rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
 
if (priv->pos == msg->len && !(priv->flags & ID_LAST_MSG))
rcar_i2c_next_msg(priv);
@@ -432,7 +420,11 @@ static bool rcar_i2c_slave_irq(struct rc
 static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
 {
struct rcar_i2c_priv *priv = ptr;
-   u32 msr;
+   u32 msr, val;
+
+   /* Clear START or STOP as soon as we can */
+   val = rcar_i2c_read(priv, ICMCR);
+   rcar_i2c_write(priv, ICMCR, val & RCAR_BUS_MASK_DATA);
 
msr = rcar_i2c_read(priv, ICMSR);
 
@@ -454,7 +446,6 @@ static irqreturn_t rcar_i2c_irq(int irq,
/* Nack */
if (msr & MNR) {
/* HW automatically sends STOP after received NACK */
-   rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP);
rcar_i2c_flags_set(priv, ID_NACK);
goto out;




[PATCH 4.4 25/37] iio:kfifo_buf: check for uint overflow

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Martin Kelly 

commit 3d13de4b027d5f6276c0f9d3a264f518747d83f2 upstream.

Currently, the following causes a kernel OOPS in memcpy:

echo 1073741825 > buffer/length
echo 1 > buffer/enable

Note that using 1073741824 instead of 1073741825 causes "write error:
Cannot allocate memory" but no OOPS.

This is because 1073741824 == 2^30 and 1073741825 == 2^30+1. Since kfifo
rounds up to the nearest power of 2, it will actually call kmalloc with
roundup_pow_of_two(length) * bytes_per_datum.

Using length == 1073741825 and bytes_per_datum == 2, we get:

kmalloc(roundup_pow_of_two(1073741825) * 2
or kmalloc(2147483648 * 2)
or kmalloc(4294967296)
or kmalloc(UINT_MAX + 1)

so this overflows to 0, causing kmalloc to return ZERO_SIZE_PTR and
subsequent memcpy to fail once the device is enabled.

Fix this by checking for overflow prior to allocating a kfifo. With this
check added, the above code returns -EINVAL when enabling the buffer,
rather than causing an OOPS.

Signed-off-by: Martin Kelly 
cc: 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/iio/buffer/kfifo_buf.c |7 +++
 1 file changed, 7 insertions(+)

--- a/drivers/iio/buffer/kfifo_buf.c
+++ b/drivers/iio/buffer/kfifo_buf.c
@@ -24,6 +24,13 @@ static inline int __iio_allocate_kfifo(s
if ((length == 0) || (bytes_per_datum == 0))
return -EINVAL;
 
+   /*
+* Make sure we don't overflow an unsigned int after kfifo rounds up to
+* the next power of 2.
+*/
+   if (roundup_pow_of_two(length) > UINT_MAX / bytes_per_datum)
+   return -EINVAL;
+
return __kfifo_alloc((struct __kfifo *)>kf, length,
 bytes_per_datum, GFP_KERNEL);
 }




Re: [PATCH v10 0/5] Kernel parameter parser cleanup/enhancement

2018-06-05 Thread Michal Suchánek
On Tue, 5 Jun 2018 20:05:50 +0300
Andy Shevchenko  wrote:

> On Tue, Jun 5, 2018 at 7:43 PM, Michal Suchanek 
> wrote:
> > Hello,
> >
> > due to work on the fadump_extra_args I looked at the kernel
> > parameter parser and found its grammar rather curious.
> >
> > It supports double quotes but not any other quoting characters so
> > double quotes cannot be quoted. What's more, the quotes can be
> > anywhere in the parameter name or value and are interpteted but are
> > removed only from start and end of the parameter value.
> >
> > These are the patches not specific to fadump which somewhat
> > straighten the qouting grammar to make it on par with common shell
> > interpreters.  
> 
> I didn't notice any use of string_unescape_*() functionality. So, your
> patch is kinda very specific to some narrow subset of escaping and
> unescaping stuff.

It does what it says. It cannot use string_unescape because it needs to
determine the boundaries of quoted strings.

> Thus, it's still not on par with shell, right?

It does not interpret special character sequences other than quoting.

The feature would not be hard to add but I do not see the need.

Unfortunately, the existing string_unescape is totally not fitting to
be integrated into the parser for the purpose.

Thanks

Michal

> 
> >
> > Specifically double and single quotes can be used for quoting as
> > well as backslashes with the usual shell semantic. All quoting
> > characters are removed while the parameters are parsed.
> >


[PATCH 4.4 24/37] dmaengine: usb-dmac: fix endless loop in usb_dmac_chan_terminate_all()

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Yoshihiro Shimoda 

commit d9f5efade2cfd729138a7cafb46d01044da40f5e upstream.

This patch fixes an issue that list_for_each_entry() in
usb_dmac_chan_terminate_all() is possible to cause endless loop because
this will move own desc to the desc_freed. So, this driver should use
list_for_each_entry_safe() instead of list_for_each_entry().

Signed-off-by: Yoshihiro Shimoda 
Signed-off-by: Vinod Koul 
Signed-off-by: Biju Das 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/dma/sh/usb-dmac.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/dma/sh/usb-dmac.c
+++ b/drivers/dma/sh/usb-dmac.c
@@ -448,7 +448,7 @@ usb_dmac_prep_slave_sg(struct dma_chan *
 static int usb_dmac_chan_terminate_all(struct dma_chan *chan)
 {
struct usb_dmac_chan *uchan = to_usb_dmac_chan(chan);
-   struct usb_dmac_desc *desc;
+   struct usb_dmac_desc *desc, *_desc;
unsigned long flags;
LIST_HEAD(head);
LIST_HEAD(list);
@@ -459,7 +459,7 @@ static int usb_dmac_chan_terminate_all(s
if (uchan->desc)
uchan->desc = NULL;
list_splice_init(>desc_got, );
-   list_for_each_entry(desc, , node)
+   list_for_each_entry_safe(desc, _desc, , node)
list_move_tail(>node, >desc_freed);
spin_unlock_irqrestore(>vc.lock, flags);
vchan_dma_desc_free_list(>vc, );




[PATCH v2 3/8] mfd: cros_ec: Add or fix SPDX-License-Identifier in all files.

2018-06-05 Thread Enric Balletbo i Serra
And get rid of the license text that is no longer necessary. Also fix
the license as sometimes doesn't match what the header with the value in
the MODULE_LICENSE macro. Assuming that the desired license is GPL-2.0+,
all the files are updated to this license version.

Signed-off-by: Enric Balletbo i Serra 
---

Changes in v2: None

 drivers/mfd/cros_ec.c| 26 --
 drivers/mfd/cros_ec_dev.c| 23 +--
 drivers/mfd/cros_ec_dev.h| 16 ++--
 drivers/mfd/cros_ec_i2c.c| 18 --
 drivers/mfd/cros_ec_spi.c| 20 +---
 include/linux/mfd/cros_ec.h  | 10 +-
 include/linux/mfd/cros_ec_commands.h | 10 +-
 include/linux/mfd/cros_ec_lpc_mec.h  | 14 +++---
 include/linux/mfd/cros_ec_lpc_reg.h  | 14 +++---
 9 files changed, 32 insertions(+), 119 deletions(-)

diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index 58e05069163e..5b6a1c541543 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -1,21 +1,11 @@
-/*
- * ChromeOS EC multi-function device
- *
- * Copyright (C) 2012 Google, Inc
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * The ChromeOS EC multi function device is used to mux all the requests
- * to the EC device for its multiple features: keyboard controller,
- * battery charging and regulator control, firmware update.
- */
+// SPDX-License-Identifier: GPL-2.0+
+// ChromeOS EC multi-function device.
+//
+// Copyright (C) 2012 Google, Inc
+//
+// The ChromeOS EC multi function device is used to mux all the requests
+// to the EC device for its multiple features: keyboard controller,
+// battery charging and regulator control, firmware update.
 
 #include 
 #include 
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index d37c79426c87..0ce7be132a09 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -1,21 +1,8 @@
-/*
- * cros_ec_dev - expose the Chrome OS Embedded Controller to user-space
- *
- * Copyright (C) 2014 Google, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
+// SPDX-License-Identifier: GPL-2.0+
+// Expose the ChromeOS Embedded Controller to user-space.
+//
+// Copyright (C) 2014 Google, Inc.
+// Author: Bill Richardson 
 
 #include 
 #include 
diff --git a/drivers/mfd/cros_ec_dev.h b/drivers/mfd/cros_ec_dev.h
index 45e9453608c5..a63cf80234c7 100644
--- a/drivers/mfd/cros_ec_dev.h
+++ b/drivers/mfd/cros_ec_dev.h
@@ -1,20 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * cros_ec_dev - expose the Chrome OS Embedded Controller to userspace
+ * Expose the ChromeOS Embedded Controller to userspace
  *
  * Copyright (C) 2014 Google, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
  */
 
 #ifndef _CROS_EC_DEV_H_
diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c
index ef9b4763356f..5f3a356467df 100644
--- a/drivers/mfd/cros_ec_i2c.c
+++ b/drivers/mfd/cros_ec_i2c.c
@@ -1,17 +1,7 @@
-/*
- * ChromeOS EC multi-function device (I2C)
- *
- * Copyright (C) 2012 Google, Inc
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in 

[PATCH v2 7/8] extcon: usbc-cros-ec: Switch to SPDX identifier.

2018-06-05 Thread Enric Balletbo i Serra
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Enric Balletbo i Serra 
---

Changes in v2:
- [8/9] Fixed wrong copyright year.

 drivers/extcon/extcon-usbc-cros-ec.c | 20 +---
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/extcon/extcon-usbc-cros-ec.c 
b/drivers/extcon/extcon-usbc-cros-ec.c
index 6721ab01fe7d..ef5a23e46e71 100644
--- a/drivers/extcon/extcon-usbc-cros-ec.c
+++ b/drivers/extcon/extcon-usbc-cros-ec.c
@@ -1,18 +1,8 @@
-/**
- * drivers/extcon/extcon-usbc-cros-ec - ChromeOS Embedded Controller extcon
- *
- * Copyright (C) 2017 Google, Inc
- * Author: Benson Leung 
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+// SPDX-License-Identifier: GPL-2.0+
+// ChromeOS Embedded Controller extcon
+//
+// Copyright (C) 2017 Google, Inc.
+// Author: Benson Leung 
 
 #include 
 #include 
-- 
2.17.1



[PATCH v2 6/8] pwm: cros-ec: Switch to SPDX identifier.

2018-06-05 Thread Enric Balletbo i Serra
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Enric Balletbo i Serra 
---

Changes in v2: None

 drivers/pwm/pwm-cros-ec.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c
index 9c13694eaa24..9bf4cde86765 100644
--- a/drivers/pwm/pwm-cros-ec.c
+++ b/drivers/pwm/pwm-cros-ec.c
@@ -1,12 +1,7 @@
-/*
- * Copyright (C) 2016 Google, Inc
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2, as published by
- * the Free Software Foundation.
- *
- * Expose a PWM controlled by the ChromeOS EC to the host processor.
- */
+// SPDX-License-Identifier: GPL-2.0
+// Expose a PWM controlled by the ChromeOS EC to the host processor.
+//
+// Copyright (C) 2016 Google, Inc.
 
 #include 
 #include 
-- 
2.17.1



[PATCH v2 8/8] i2c: i2c-cros-ec-tunnel: Switch to SPDX identifier.

2018-06-05 Thread Enric Balletbo i Serra
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Enric Balletbo i Serra 
---

Changes in v2: None

 drivers/i2c/busses/i2c-cros-ec-tunnel.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c 
b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
index eb76b76f4754..82bcd9a78759 100644
--- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c
+++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
@@ -1,13 +1,7 @@
-/*
- *  Copyright (C) 2013 Google, Inc
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- * Expose an I2C passthrough to the ChromeOS EC.
- */
+// SPDX-License-Identifier: GPL-2.0+
+// Expose an I2C passthrough to the ChromeOS EC.
+//
+// Copyright (C) 2013 Google, Inc.
 
 #include 
 #include 
-- 
2.17.1



[PATCH v2 2/8] platform/chrome: pstore: Switch to SPDX identifier.

2018-06-05 Thread Enric Balletbo i Serra
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Enric Balletbo i Serra 
---

Changes in v2: None

 drivers/platform/chrome/chromeos_pstore.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/chrome/chromeos_pstore.c 
b/drivers/platform/chrome/chromeos_pstore.c
index b0693fdec8c6..4d3d3459e2f9 100644
--- a/drivers/platform/chrome/chromeos_pstore.c
+++ b/drivers/platform/chrome/chromeos_pstore.c
@@ -1,12 +1,7 @@
-/*
- *  chromeos_pstore.c - Driver to instantiate Chromebook ramoops device
- *
- *  Copyright (C) 2013 Google, Inc.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, version 2 of the License.
- */
+// SPDX-License-Identifier: GPL-2.0+
+// Driver to instantiate Chromebook ramoops device.
+//
+// Copyright (C) 2013 Google, Inc.
 
 #include 
 #include 
-- 
2.17.1



[PATCH 17/46] perf annotate stdio: Use annotation_options consistently

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Accross all the routines, this way we can have eventually have a
consistent set of defaults for all UIs.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-6qgtixurjgdk5u0n3rw78...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-annotate.c | 15 +++
 tools/perf/builtin-top.c  | 14 --
 tools/perf/util/annotate.c| 31 +++
 tools/perf/util/annotate.h| 15 +--
 tools/perf/util/top.h |  3 ++-
 5 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 2b21bbcd70ea..7238010f28d4 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -40,9 +40,8 @@
 struct perf_annotate {
struct perf_tool tool;
struct perf_session *session;
+   struct annotation_options opts;
bool   use_tui, use_stdio, use_stdio2, use_gtk;
-   bool   full_paths;
-   bool   print_line;
bool   skip_missing;
bool   has_br_stack;
bool   group_set;
@@ -289,10 +288,9 @@ static int hist_entry__tty_annotate(struct hist_entry *he,
struct perf_annotate *ann)
 {
if (!ann->use_stdio2)
-   return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel,
-   ann->print_line, ann->full_paths, 
0, 0);
-   return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel,
-ann->print_line, ann->full_paths);
+   return symbol__tty_annotate(he->ms.sym, he->ms.map, evsel, 
>opts);
+
+   return symbol__tty_annotate2(he->ms.sym, he->ms.map, evsel, >opts);
 }
 
 static void hists__find_annotations(struct hists *hists,
@@ -476,6 +474,7 @@ int cmd_annotate(int argc, const char **argv)
.ordered_events = true,
.ordering_requires_timestamps = true,
},
+   .opts = annotation__default_options,
};
struct perf_data data = {
.mode  = PERF_DATA_MODE_READ,
@@ -503,9 +502,9 @@ int cmd_annotate(int argc, const char **argv)
   "file", "vmlinux pathname"),
OPT_BOOLEAN('m', "modules", _conf.use_modules,
"load module symbols - WARNING: use only with -k and LIVE 
kernel"),
-   OPT_BOOLEAN('l', "print-line", _line,
+   OPT_BOOLEAN('l', "print-line", _lines,
"print matching source lines (may be slow)"),
-   OPT_BOOLEAN('P', "full-paths", _paths,
+   OPT_BOOLEAN('P', "full-paths", _path,
"Don't shorten the displayed pathnames"),
OPT_BOOLEAN(0, "skip-missing", _missing,
"Skip symbols that cannot be annotated"),
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 4284840022a3..5e58cd4de90b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -243,10 +243,9 @@ static void perf_top__show_details(struct perf_top *top)
goto out_unlock;
 
printf("Showing %s for %s\n", perf_evsel__name(top->sym_evsel), 
symbol->name);
-   printf("  Events  Pcnt (>=%d%%)\n", top->sym_pcnt_filter);
+   printf("  Events  Pcnt (>=%d%%)\n", top->annotation_opts.min_pcnt);
 
-   more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel,
-  0, top->sym_pcnt_filter, 
top->print_entries, 4);
+   more = symbol__annotate_printf(symbol, he->ms.map, top->sym_evsel, 
>annotation_opts);
 
if (top->evlist->enabled) {
if (top->zero)
@@ -406,7 +405,7 @@ static void perf_top__print_mapped_keys(struct perf_top 
*top)
 
fprintf(stdout, "\t[f] profile display filter (count).
\t(%d)\n", top->count_filter);
 
-   fprintf(stdout, "\t[F] annotate display filter (percent). 
\t(%d%%)\n", top->sym_pcnt_filter);
+   fprintf(stdout, "\t[F] annotate display filter (percent). 
\t(%d%%)\n", top->annotation_opts.min_pcnt);
fprintf(stdout, "\t[s] annotate symbol.   
\t(%s)\n", name?: "NULL");
fprintf(stdout, "\t[S] stop annotation.\n");
 
@@ -509,7 +508,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, 
int c)
prompt_integer(>count_filter, "Enter display event 
count filter");
break;
case 'F':
-   prompt_percent(>sym_pcnt_filter,
+   prompt_percent(>annotation_opts.min_pcnt,
   "Enter details display event filter 
(percent)");
break;
case 'K':
@@ -1259,7 +1258,7 @@ int cmd_top(int argc, const char **argv)
.overwrite  = 1,
},

Re: [PATCH v2 5/8] Input: cros_ec_keyb - Switch to SPDX identifier.

2018-06-05 Thread Fabio Estevam
Hi Enric,

On Tue, Jun 5, 2018 at 3:14 PM, Enric Balletbo i Serra
 wrote:

> Right, but the module license is set to GPL which means GNU Public License v2 
> or
> later, see [1]. So, there is a mismatch. In such cases I assumed GPL-2.0+ as 
> the
> default. These mismatches are common so I think that should be fine for the
> authors, if someone is disagree just let me know and I will change.

Ok, but I think you should add this explanation in the commit log to
make it clearer.


Re: [PATCH 5/5] mm, hmm: mark hmm_devmem_{add, add_resource} EXPORT_SYMBOL_GPL

2018-06-05 Thread Jerome Glisse
On Tue, May 22, 2018 at 02:31:21PM -0700, Andrew Morton wrote:
> On Tue, 22 May 2018 08:32:36 +0200 Christoph Hellwig  wrote:
> 
> > On Mon, May 21, 2018 at 03:35:40PM -0700, Dan Williams wrote:
> > > The routines hmm_devmem_add(), and hmm_devmem_add_resource() are small
> > > wrappers around devm_memremap_pages(). The devm_memremap_pages()
> > > interface is a subset of the hmm functionality which has more and deeper
> > > ties into the kernel memory management implementation. It was an
> > > oversight that these symbols were not marked EXPORT_SYMBOL_GPL from the
> > > outset due to how they originally copied (and now reuse)
> > > devm_memremap_pages().
> > 
> > If we end up keeping this code: absolutely.  Then again I think without
> > an actual user this should have never been merged, and should be removed
> > until one shows up.
> > 
> 
> It wasn't simple.  Quite a lot of manufacturers were (are?) developing
> quite complex driver code which utilizes hmm.  Merging hmm to give a
> stable target for that development and in the expectation that those
> things would be coming along was a risk and I don't think we yet know
> the outcome.
> 
> Jerome, are you able to provide any updates on all of this?

Sorry for taking so long to reply to this, I am just back from vacation.

I posted a v1 for nouveau to use HMM back in April or early May. I want
to post a v2 soon in June. For it to get upstream it needs to fullfill
linux drm sub-system requirement which are an open source userspace for
any functionality added to GPU driver. Work for this have been going
on for a while too and userspace bits are slowly getting upstream inside
Mesa. I need to sync up to see what is still missing in Mesa.

So i won't be able to get nouveau HMM bits merge before the userspace
bits are merge too. I was hopping for 4.18 but more likely 4.19.

I know HMM have been a big chicken and egg thing and that timing for
the egg did not match the timing for the chicken :) But it is getting
there.


Also I expect more hardware and associated upstream driver to make use
of HMM but i can not comment further on that at this time because of
NDA.

Cheers,
Jérôme


Re: [PATCH v6 0/2] sparc64: Add privileged ADI driver

2018-06-05 Thread David Miller
From: Tom Hromatka 
Date: Thu, 26 Apr 2018 10:54:07 -0600

> ADI is a feature supported on SPARC M7 and newer processors to allow
> hardware to catch rogue accesses to memory. ADI is supported for data
> fetches only and not instruction fetches. An app can enable ADI on its
> data pages, set version tags on them and use versioned addresses to
> access the data pages. Upper bits of the address contain the version
> tag. On M7 processors, upper four bits (bits 63-60) contain the version
> tag. If a rogue app attempts to access ADI enabled data pages, its
> access is blocked and processor generates an exception. Please see
> Documentation/sparc/adi.txt for further details.
> 
> This patchset implements a char driver to read/write ADI versions from
> privileged user space processes.  Intended consumers are makedumpfile
> and crash.

Series applied, but there is one thing I am not happy with.

The hard coded ADI block size.

This value is at least theoretically dynamic, and that is why
it is passed into userspace programs via the ELF AUX vector
at exec() time.

So they should really fetch it from there.


Re: [PATCH v2 5/8] Input: cros_ec_keyb - Switch to SPDX identifier.

2018-06-05 Thread Dmitry Torokhov
On Tue, Jun 05, 2018 at 03:16:40PM -0300, Fabio Estevam wrote:
> Hi Enric,
> 
> On Tue, Jun 5, 2018 at 3:14 PM, Enric Balletbo i Serra
>  wrote:
> 
> > Right, but the module license is set to GPL which means GNU Public License 
> > v2 or
> > later, see [1]. So, there is a mismatch. In such cases I assumed GPL-2.0+ 
> > as the
> > default. These mismatches are common so I think that should be fine for the
> > authors, if someone is disagree just let me know and I will change.
> 
> Ok, but I think you should add this explanation in the commit log to
> make it clearer.

If there is a conflict between the license notice and MODULE_LICENSE()
we should go by the license notice. The license note is usually approved
by companies, whereas MIODULE_LICENSE()s get moved, adjusted, etc.

For ChromeOS kernel changes license notice is GPL v2 as documented at:

https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/kernel-faq

section "Which copyright header should I use?"

Thanks.

-- 
Dmitry


Re: [PATCH 5/9] rtc: cros-ec: Switch to SPDX identifier.

2018-06-05 Thread Enric Balletbo i Serra
Hi Alexandre,

On 05/06/18 11:46, Alexandre Belloni wrote:
> On 05/06/2018 11:22:05+0200, Enric Balletbo i Serra wrote:
>> Adopt the SPDX license identifier headers to ease license compliance
>> management.
>>
>> Signed-off-by: Enric Balletbo i Serra 
>> ---
>>
>>  drivers/rtc/rtc-cros-ec.c | 21 +
>>  1 file changed, 5 insertions(+), 16 deletions(-)
>>
> Applied, thanks.
> 

Looks like all the ChromeOS drivers should be licensed as GPL v2 only. There was
a mismatch between what the header says and the MODULE_LICENSE and I wrongly
assumed that the MODULE_LICENSE is the one I should follow. So could you not
apply this patch for now and I'll send another version with the correct license?

Thanks and sorry for the inconvenience this may cause you,
 Enric


[GIT PULL] Char/Misc driver patches for 4.18-rc1

2018-06-05 Thread Greg KH
The following changes since commit 6da6c0db5316275015e8cc2959f12a17584aeb64:

  Linux v4.17-rc3 (2018-04-29 14:17:42 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/ 
tags/char-misc-4.18-rc1

for you to fetch changes up to b23220fe054e92f616b82450fae8cd3ab176cc60:

  vmw_balloon: fixing double free when batching mode is off (2018-06-02 
19:34:13 +0200)


Char/Misc driver patches for 4.18-rc1

Here is the "big" char and misc driver patches for 4.18-rc1.

It's not a lot of stuff here, but there are some highlights:
- coreboot driver updates
- soundwire driver updates
- android binder updates
- fpga big sync, mostly documentation
- lots of minor driver updates

All of these have been in linux-next for a while with no reported
issues.

Signed-off-by: Greg Kroah-Hartman 


Alan Tull (15):
  fpga: fpga-region: comment on fpga_region_program_fpga locking
  fpga: region: don't use drvdata in common fpga code
  fpga: manager: change api, don't use drvdata
  fpga: bridge: change api, don't use drvdata
  fpga: region: change api, add fpga_region_create/free
  fpga: use SPDX
  fpga: mgr: kernel-doc fixes
  fpga: bridge: kernel-doc fixes
  fpga: region: kernel-doc fixes
  Documentation: fpga: move fpga overview to driver-api
  documentation: fpga: move fpga-mgr.txt to driver-api
  documentation: fpga: add bridge document to driver-api
  documentation: fpga: move fpga-region.txt to driver-api
  fpga: clarify that unregister functions also free
  MAINTAINERS: Add driver-api/fpga path

Alexander Kapshuk (2):
  ver_linux: Move stderr redirection from function parameter to function 
body
  ver_linux: Drop redundant calls to system() to test if file is readable

Andrew F. Davis (1):
  rpmsg: Correct support for MODULE_DEVICE_TABLE()

Andrew Lunn (1):
  drivers: nvmem: Export nvmem_add_cells()

Andrey Smirnov (2):
  dt-bindings: nvmem: Add binding for RAVE SP EEPROM driver
  nvmem: Add RAVE SP EEPROM driver

Arvind Yadav (1):
  coresight: use put_device() instead of kfree()

Bryant G. Ly (1):
  misc: IBM Virtual Management Channel Driver (VMC)

Dan Carpenter (1):
  ANDROID: binder: re-order some conditions

Dexuan Cui (2):
  Drivers: hv: vmbus: enable VMBus protocol version 5.0
  Drivers: hv: vmbus: Removed an unnecessary cast from void *

Fabio Estevam (1):
  uio: uio_fsl_elbc_gpcm: Remove owner assignment from platform_driver

Finn Thain (1):
  nubus: Call bus_register unconditionally

Geert Uytterhoeven (2):
  fpga: Remove depends on HAS_DMA in case of platform dependency
  ARM: amba: Fix wrong indentation in driver_override_store()

Gil Kupfer (1):
  vmw_balloon: fixing double free when batching mode is off

Greg Kroah-Hartman (2):
  Merge 4.17-rc3 into char-misc-next
  Merge tag 'soundwire-streaming' of 
git://git.kernel.org/.../vkoul/soundwire into char-misc-next

Hamish Martin (2):
  uio: Reduce return paths from uio_write()
  uio: Prevent device destruction while fds are open

Ingo Flaschberger (1):
  1wire: family module autoload fails because of upper/lower case mismatch.

Jerome Brunet (3):
  nvmem: meson-efuse: remove econfig global
  nvmem: meson-efuse: simplify read callback
  nvmem: meson-efuse: add write support

Jia-Ju Bai (1):
  misc: ti-st: Replace GFP_ATOMIC with GFP_KERNEL in kim_probe

Laura Abbott (1):
  misc: tifm: Remove VLA

Leo Yan (1):
  coresight: Remove %px for printing pcsr value

Luc Van Oostenryck (1):
  sgi-xp: fix xpnet_dev_hard_start_xmit()'s return type

Martijn Coenen (1):
  ANDROID: binder: remove 32-bit binder interface.

Mathieu Malaterre (1):
  nvmem: properly handle returned value nvmem_reg_read

Mathieu Poirier (4):
  coresight: Moving framework and drivers to SPDX identifier
  coresight tmc etr: Make memory check consistent in the same function
  coresight tmc etr: Fix uninitialised variable
  coresight tmc etr: Removing extra newline

Minchan Kim (1):
  ANDROID: binder: change down_write to down_read

Paolo Pisati (2):
  dt: bindings: fpga: add lattice machxo2 slave spi binding description
  fpga: lattice machxo2: Add Lattice MachXO2 support

Peter Rosin (1):
  mux: adg792a: switch to using .probe_new

Samuel Holland (5):
  firmware: coreboot: Expose the coreboot table as a bus
  firmware: memconsole: Probe via coreboot bus
  firmware: vpd: Probe via coreboot bus
  firmware: coreboot: Remove unused coreboot_table_find
  firmware: coreboot: Add coreboot framebuffer driver

Sanyog Kale (7):
  Documentation: soundwire: Add more documentation
  soundwire: Add support for SoundWire stream management
  soundwire: 

Re: [PATCH 5/9] rtc: cros-ec: Switch to SPDX identifier.

2018-06-05 Thread Alexandre Belloni
On 05/06/2018 20:51:06+0200, Enric Balletbo i Serra wrote:
> Hi Alexandre,
> 
> On 05/06/18 11:46, Alexandre Belloni wrote:
> > On 05/06/2018 11:22:05+0200, Enric Balletbo i Serra wrote:
> >> Adopt the SPDX license identifier headers to ease license compliance
> >> management.
> >>
> >> Signed-off-by: Enric Balletbo i Serra 
> >> ---
> >>
> >>  drivers/rtc/rtc-cros-ec.c | 21 +
> >>  1 file changed, 5 insertions(+), 16 deletions(-)
> >>
> > Applied, thanks.
> > 
> 
> Looks like all the ChromeOS drivers should be licensed as GPL v2 only. There 
> was
> a mismatch between what the header says and the MODULE_LICENSE and I wrongly
> assumed that the MODULE_LICENSE is the one I should follow. So could you not
> apply this patch for now and I'll send another version with the correct 
> license?
> 

Hum, ok, this seemed to be the correct way to solve the mismatch to me.


-- 
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com


[GIT PULL] xfs: 4.18 merge, part 1

2018-06-05 Thread Darrick J. Wong
Hi Linus,

Here's the first round of patches for XFS for 4.18.  New features this
cycle include the ability to relabel mounted filesystems, support for
fallocated swapfiles, and using FUA for pure data O_DSYNC directio
writes.  With this cycle we begin to integrate online filesystem repair
and refactor the growfs code in preparation for eventual subvolume
support, though the road ahead for both features is quite long.

There are also numerous refactorings of the iomap code to remove
unnecessary log overhead, to disentangle some of the quota code, and to
prepare for buffer head removal in a future upstream kernel.

Metadata validation continues to improve, both in the hot path veifiers
and the online filesystem check code.  I anticipate sending a second
pull request in a few days with more metadata validation improvements.

This series has been run through a full xfstests run over the weekend
and through a quick xfstests run against this morning's master, with no
major failures reported.

There's a merge conflict between one of the iomap refactorings and the
gfs2 changes in your master branch.  The file in question is
fs/gfs2/bmap.c.  I resolved the conflict and pushed the result as a
branch[1] into my git tree, and the resolved file should look like[2].
Let me know if things get hairy enough that you want me to take another
look at that.

--D

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/log/?h=xfs-4.18-merge-conflicts
[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/diff/fs/gfs2/bmap.c?h=xfs-4.18-merge-conflicts=54195b796f10860d1778dc09a9e9b1543a70301e

The following changes since commit 75bc37fefc4471e718ba8e651aa74673d4e0a9eb:

  Linux 4.17-rc4 (2018-05-06 16:57:38 -1000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git tags/xfs-4.18-merge-3

for you to fetch changes up to afd9d6a1df75807684fa40dab77c52e104e5c74b:

  fs: use ->is_partially_uptodate in page_cache_seek_hole_data (2018-06-01 
18:37:33 -0700)


Changes for 4.18:
- Strengthen inode number and structure validation when allocating inodes.
- Reduce pointless buffer allocations during cache miss
- Use FUA for pure data O_DSYNC directio writes
- Various iomap refactorings
- Strengthen quota metadata verification to avoid unfixable broken quota
- Make AGFL block freeing a deferred operation to avoid blowing out
  transaction reservations when running complex operations
- Get rid of the log item descriptors to reduce log overhead
- Fix various reflink bugs where inodes were double-joined to
  transactions
- Don't issue discards when trimming unwritten extents
- Refactor incore dquot initialization and retrieval interfaces
- Fix some locking problmes in the quota scrub code
- Strengthen btree structure checks in scrub code
- Rewrite swapfile activation to use iomap and support unwritten extents
- Make scrub exit to userspace sooner when corruptions or
  cross-referencing problems are found
- Make scrub invoke the data fork scrubber directly on metadata inodes
- Don't do background reclamation of post-eof and cow blocks when the fs
  is suspended
- Fix secondary superblock buffer lifespan hinting
- Refactor growfs to use table-dispatched functions instead of long
  stringy functions
- Move growfs code to libxfs
- Implement online fs label getting and setting
- Introduce online filesystem repair (in a very limited capacity)
- Fix unit conversion problems in the realtime freemap iteration
  functions
- Various refactorings and cleanups in preparation to remove buffer
  heads in a future release
- Reimplement the old bmap call with iomap
- Remove direct buffer head accesses from seek hole/data
- Various bug fixes


Brian Foster (10):
  xfs: create agfl block free helper function
  xfs: defer agfl block frees when dfops is available
  xfs: defer agfl block frees from deferred ops processing context
  xfs: defer agfl frees from inode inactivation
  xfs: defer frees from common inode allocation paths
  xfs: defer agfl frees from directory op transactions
  xfs: add bmapi nodiscard flag
  xfs: skip online discard during eofblocks trims
  xfs: don't discard on free of unwritten extents
  xfs: factor out nodiscard helpers

Christoph Hellwig (14):
  block: add a lower-level bio_add_page interface
  mm: give the 'ret' variable a better name __do_page_cache_readahead
  mm: return an unsigned int from __do_page_cache_readahead
  mm: split ->readpages calls to avoid non-contiguous pages lists
  iomap: inline data should be an iomap type, not a flag
  iomap: fix the comment describing IOMAP_NOWAIT
  iomap: move IOMAP_F_BOUNDARY to gfs2
  iomap: use __bio_add_page in iomap_dio_zero
  iomap: add a iomap_sector helper
  iomap: add an iomap-based bmap implementation
 

[GIT PULL] TTY/Serial patches for 4.18-rc1

2018-06-05 Thread Greg KH
The following changes since commit 6da6c0db5316275015e8cc2959f12a17584aeb64:

  Linux v4.17-rc3 (2018-04-29 14:17:42 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/ 
tags/tty-4.18-rc1

for you to fetch changes up to 4b4ecd9cb853c14913a3726cfcc60ccda1d2924a:

  vt: Perform safe console erase only once (2018-05-25 18:01:16 +0200)


TTY/Serial patches for 4.18-rc1

Here is the big tty/serial driver update for 4.18-rc1.

There's nothing major here, just lots of serial driver updates.  Full
details are in the shortlog, nothing anything specific to call out here.

All have been in linux-next for a while with no reported issues.

Signed-off-by: Greg Kroah-Hartman 


Colin Ian King (1):
  tty: nozomi: fix spelling mistake in macro NOZOMI_STATE_UKNOWN

DaeRyong Jeong (1):
  tty: Fix data race in tty_insert_flip_string_fixed_flag

Dan Carpenter (1):
  serial/aspeed-vuart: fix a couple mod_timer() calls

Daniel Wagner (1):
  serial: sh-sci: Use spin_{try}lock_irqsave instead of open coding version

Dave Martin (1):
  tty: pl011: Avoid spuriously stuck-off interrupts

Douglas Anderson (1):
  serial: core: Make sure compiler barfs for 16-byte earlycon names

Evan Green (1):
  tty: serial: msm_geni_serial: Fix TX infinite loop

Geert Uytterhoeven (2):
  serial: sh-sci: Add support for dynamic instances
  serial: Remove depends on HAS_DMA in case of platform dependency

Giulio Benetti (1):
  tty: fix typo in ASYNCB_FOURPORT comment

Greg Kroah-Hartman (1):
  Merge 4.17-rc3 into tty-next

Jeremy Kerr (4):
  serial: Introduce UPSTAT_SYNC_FIFO for synchronised FIFOs
  serial/8250: export serial8250_read_char
  serial/aspeed-vuart: Implement rx throttling
  serial/aspeed-vuart: Implement quick throttle mechanism

Jia-Ju Bai (1):
  tty: ipwireless: Replace GFP_ATOMIC with GFP_KERNEL in 
ipwireless_network_create

Joey Pabalinas (2):
  tty/nozomi: cleanup DUMP() macro
  tty/nozomi: fix inconsistent indentation

John Crispin (1):
  tty: serial: drop ATH79 specific SoC symbols

John Garry (1):
  serial: 8250_of: Add IO space support

Joshua Scott (1):
  serial: 8250_dw: Limit dw8250_tx_wait_empty quirk to armada-38x devices

Karthikeyan Ramasubramanian (8):
  tty: serial: qcom_geni_serial: Add comments for clarification
  tty: serial: qcom_geni_serial: Cleanup redundant code
  tty: serial: qcom_geni_serial: Use min3 to find minimum of 3 values
  tty: serial: qcom_geni_serial: Initialize console port statically
  tty: serial: qcom_geni_serial: Remove unnecessary memory barrier
  tty: serial: qcom_geni_serial: Use iowrite32_rep to write to FIFO
  tty: serial: qcom_geni_serial: Return IRQ_NONE for spurious interrupts
  tty: serial: qcom_geni_serial: Add early console support

Kurt Kanzenbach (1):
  tty: serial: 8250: pass IRQ shared flag to UART ports

Luc Van Oostenryck (1):
  tty: n_gsm: fix gsm_mux_net_start_xmit()'s return type

Marek Szyprowski (2):
  serial: samsung: fix maxburst parameter for DMA transactions
  serial: samsung: check DMA engine capabilities before using DMA mode

Marek Vasut (1):
  serial: 8250: Add missing rxtrig_bytes on Altera 16550 UART

Michal Simek (7):
  earlycon: Initialize port->uartclk based on clock-frequency property
  serial: 8250_early: Setup divider when uartclk is passed
  serial: uartps: Remove console_initcall from the driver
  serial: uartps: Use dynamic array for console port
  serial: uartps: Move cnds_uart_get_port to probe
  serial: uartps: Remove static port array
  earlycon: Remove hardcoded port->uartclk initialization in 
of_setup_earlycon

Miquel Raynal (1):
  serial: mvebu-uart: add suspend/resume support

Nicolas Pitre (1):
  vt: Perform safe console erase only once

Pascal Huerst (2):
  tty: serial: msm_serial: Add support for suspend/resume
  tty: serial: msm_serial: Add __maybe_unused to suspend/resume callbacks

Phil Edworthy (1):
  serial: 8250_dw: Fix runtime PM handling

Sebastian Andrzej Siewior (1):
  tty/serial: atmel: use port->name as name in request_irq()

Sebastian Reichel (4):
  serial: imx: cleanup imx_uart_disable_dma()
  serial: imx: dma_unmap_sg buffers on shutdown
  serial: imx: drop CTS/RTS handling from shutdown
  serial: imx: disable UCR4_OREN on shutdown

Stefan Potyra (1):
  sc16is7xx: Check for an error when the clock is enabled.

Tony Lindgren (1):
  serial: 8250: omap: Fix idling of clocks for unused uarts

Ulrich Hecht (1):
  serial: sh-sci: Support for HSCIF RX sampling point adjustment

Vignesh R (1):
  serial: 8250: omap: Provide ability to enable/disable UART as wakeup 
source

Wolfram Sang (1):
  tty: serial: simplify getting .drvdata


[GIT PULL] Driver core patches for 4.18-rc1

2018-06-05 Thread Greg KH
The following changes since commit 6da6c0db5316275015e8cc2959f12a17584aeb64:

  Linux v4.17-rc3 (2018-04-29 14:17:42 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/ 
tags/driver-core-4.18-rc1

for you to fetch changes up to 8c97a46af04b4f7c0a0dded031fef1806872e648:

  driver core: hold dev's parent lock when needed (2018-05-31 10:12:07 +0200)


Driver core changes for 4.18-rc1

Here is the driver core patchset for 4.18-rc1.

The large chunk of these are firmware core documentation and api
updates.  Nothing major there, just better descriptions for others to be
able to understand the firmware code better.  There's also a user for a
new firmware api call.

Other than that, there are some minor updates for debugfs, kernfs, and
the driver core itself.

All of these have been in linux-next for a while with no reported
issues.

Signed-off-by: Greg Kroah-Hartman 


Andres Rodriguez (6):
  firmware: wrap FW_OPT_* into an enum
  firmware: use () to terminate kernel-doc function names
  firmware: rename fw_sysfs_fallback to firmware_fallback_sysfs()
  firmware: add firmware_request_nowarn() - load firmware without warnings
  ath10k: use firmware_request_nowarn() to load firmware
  ath10k: re-enable the firmware fallback mechanism for testmode

Andy Shevchenko (1):
  debugfs: Re-use kstrtobool_from_user()

Arvind Yadav (1):
  mm: memory_hotplug: use put_device() if device_register fail

Florian Schmaus (1):
  driver-core: return EINVAL error instead of BUG_ON()

Greg Kroah-Hartman (1):
  Merge 4.17-rc3 into driver-core-next

Luis R. Rodriguez (8):
  firmware_loader: document firmware_sysfs_fallback()
  firmware_loader: enhance Kconfig documentation over FW_LOADER
  firmware_loader: replace ---help--- with help
  firmware_loader: move kconfig FW_LOADER entries to its own file
  firmware_loader: make firmware_fallback_sysfs() print more useful
  Documentation: fix few typos and clarifications for the firmware loader
  Documentation: remove stale firmware API reference
  Documentation: clarify firmware_class provenance and why we can't rename 
the module

Martin Liu (1):
  driver core: hold dev's parent lock when needed

Mathieu Malaterre (1):
  driver core: add __printf verification to device_create_groups_vargs

Souptick Joarder (1):
  fs: kernfs: Adding new return type vm_fault_t

Tetsuo Handa (1):
  driver core: Don't ignore class_dir_create_and_add() failure.

Thomas Richter (1):
  debugfs: inode: debugfs_create_dir uses mode permission from parent

Wolfram Sang (1):
  base: core: fix typo 'can by' to 'can be'

 Documentation/dell_rbu.txt |   5 +-
 .../driver-api/firmware/fallback-mechanisms.rst|  14 +-
 .../driver-api/firmware/firmware_cache.rst |   4 +-
 .../driver-api/firmware/request_firmware.rst   |   5 +
 drivers/base/Kconfig   |  90 +++-
 drivers/base/bus.c |  16 +--
 drivers/base/core.c|  18 ++-
 drivers/base/dd.c  |   8 +-
 drivers/base/driver.c  |   6 +-
 drivers/base/firmware_loader/Kconfig   | 154 +
 drivers/base/firmware_loader/fallback.c|  53 +--
 drivers/base/firmware_loader/fallback.h|  18 +--
 drivers/base/firmware_loader/firmware.h|  37 +++--
 drivers/base/firmware_loader/main.c|  57 ++--
 drivers/base/memory.c  |   8 +-
 drivers/net/wireless/ath/ath10k/core.c |   2 +-
 drivers/net/wireless/ath/ath10k/testmode.c |   2 +-
 drivers/usb/core/driver.c  |   1 +
 fs/debugfs/file.c  |  10 +-
 fs/debugfs/inode.c |   4 +-
 fs/kernfs/file.c   |   8 +-
 include/linux/device.h |   3 +
 include/linux/firmware.h   |  10 ++
 23 files changed, 371 insertions(+), 162 deletions(-)
 create mode 100644 drivers/base/firmware_loader/Kconfig


[PATCH v2 2/2] arm64: dts: Add Mediatek X20 Development Board support

2018-06-05 Thread Manivannan Sadhasivam
Add initial device tree support for Mediatek X20 Development Board
based on MT6797 Deca core SoC. This board is one of the 96Boards
Consumer Edition platform.

Signed-off-by: Manivannan Sadhasivam 
---
 arch/arm64/boot/dts/mediatek/Makefile |  1 +
 .../boot/dts/mediatek/mt6797-x20-dev.dts  | 33 +++
 2 files changed, 34 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts

diff --git a/arch/arm64/boot/dts/mediatek/Makefile 
b/arch/arm64/boot/dts/mediatek/Makefile
index ac17f60f998c..5b7fd6ad96e4 100644
--- a/arch/arm64/boot/dts/mediatek/Makefile
+++ b/arch/arm64/boot/dts/mediatek/Makefile
@@ -3,5 +3,6 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt2712-evb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt6755-evb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt6795-evb.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-evb.dtb
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-x20-dev.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-rfb1.dtb
 dtb-$(CONFIG_ARCH_MEDIATEK) += mt8173-evb.dtb
diff --git a/arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts 
b/arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts
new file mode 100644
index ..2c09ca95d9e2
--- /dev/null
+++ b/arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source for MediaTek X20 Development Board
+ *
+ * Copyright (C) 2018, Linaro Ltd.
+ *
+ */
+
+/dts-v1/;
+
+#include "mt6797.dtsi"
+
+/ {
+   model = "Mediatek X20 Development Board";
+   compatible = "archermind,mt6797-x20-dev", "mediatek,mt6797";
+
+   aliases {
+   serial0 = 
+   };
+
+   memory@4000 {
+   device_type = "memory";
+   reg = <0 0x4000 0 0x1e605000>;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+};
+
+ {
+   status = "okay";
+};
-- 
2.17.0



[PATCH v2 1/2] dt-bindings: arm: mediatek: Document Mediatek X20 Development Board

2018-06-05 Thread Manivannan Sadhasivam
Document Mediatek X20 Development Board which is a 96Boards Consumer
Edition platform based on MT6797 SoC.

Signed-off-by: Manivannan Sadhasivam 
---
 Documentation/devicetree/bindings/arm/mediatek.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/mediatek.txt 
b/Documentation/devicetree/bindings/arm/mediatek.txt
index 7d21ab37c19c..356df1ee11b9 100644
--- a/Documentation/devicetree/bindings/arm/mediatek.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek.txt
@@ -47,6 +47,9 @@ Supported boards:
 - Evaluation board for MT6797(Helio X20):
 Required root node properties:
   - compatible = "mediatek,mt6797-evb", "mediatek,mt6797";
+- Mediatek X20 Development Board:
+Required root node properties:
+  - compatible = "archermind,mt6797-x20-dev", "mediatek,mt6797";
 - Reference board variant 1 for MT7622:
 Required root node properties:
   - compatible = "mediatek,mt7622-rfb1", "mediatek,mt7622";
-- 
2.17.0



[PATCH v2 0/2] Add Mediatek X20 Development Board support

2018-06-05 Thread Manivannan Sadhasivam
Add devicetree support for Mediatek X20 Development Board by Archermind.
This board is based on the Deca-Core MT6797 SoC from Mediatek and is
one of the 96Boards Consumer Edition platform.

With this devicetree change, board can boot into initramfs.

More information about this board can be found in 96Boards product page:
https://www.96boards.org/product/mediatek-x20/

Thanks,
Mani

Changes in v2:

* Added documentation for board compatible
* Dropped vendor documetation patch since it got applied

Manivannan Sadhasivam (2):
  dt-bindings: arm: mediatek: Document Mediatek X20 Development Board
  arm64: dts: Add Mediatek X20 Development Board support

 .../devicetree/bindings/arm/mediatek.txt  |  3 ++
 arch/arm64/boot/dts/mediatek/Makefile |  1 +
 .../boot/dts/mediatek/mt6797-x20-dev.dts  | 33 +++
 3 files changed, 37 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts

-- 
2.17.0



[PATCH] scripts: Use SPDX tag in get_maintainer and checkpatch

2018-06-05 Thread Joe Perches
Add the appropriate SPDX tag to these scripts.

Miscellanea:

o Add my copyright to checkpatch

Signed-off-by: Joe Perches 
---
 scripts/checkpatch.pl | 4 +++-
 scripts/get_maintainer.pl | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2d42eb9cd1a5..7aadfded3fe0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1,9 +1,11 @@
 #!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+#
 # (c) 2001, Dave Jones. (the file handling bit)
 # (c) 2005, Joel Schopp  (the ugly bit)
 # (c) 2007,2008, Andy Whitcroft  (new conditions, test suite)
 # (c) 2008-2010 Andy Whitcroft 
-# Licensed under the terms of the GNU GPL License version 2
+# (c) 2010-2018 Joe Perches 
 
 use strict;
 use warnings;
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 99c96e86eccb..30eca36b4dad 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -1,4 +1,6 @@
 #!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
+#
 # (c) 2007, Joe Perches 
 #   created from checkpatch.pl
 #
@@ -7,8 +9,6 @@
 #
 # usage: perl scripts/get_maintainer.pl [OPTIONS] 
 #perl scripts/get_maintainer.pl [OPTIONS] -f 
-#
-# Licensed under the terms of the GNU GPL License version 2
 
 use warnings;
 use strict;



RE: [RFC Patch 1/3] X86/Hyper-V: Add flush HvFlushGuestPhysicalAddressSpace hypercall support

2018-06-05 Thread Michael Kelley (EOSG)
> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org  
> On Behalf
> Of Tianyu Lan
> Sent: Monday, June 4, 2018 2:08 AM
> Cc: Tianyu Lan ; KY Srinivasan 
> ; Haiyang
> Zhang ; Stephen Hemminger ;
> t...@linutronix.de; mi...@redhat.com; h...@zytor.com; x...@kernel.org;
> pbonz...@redhat.com; rkrc...@redhat.com; de...@linuxdriverproject.org; linux-
> ker...@vger.kernel.org; k...@vger.kernel.org; vkuzn...@redhat.com
> Subject: [RFC Patch 1/3] X86/Hyper-V: Add flush 
> HvFlushGuestPhysicalAddressSpace hypercall
> support
> 
> Hyper-V provides a pv hypercall HvFlushGuestPhysicalAddressSpace to flush
> nested VM address space mapping in l1 hypervisor and it's to reduce overhead
> of flushing ept tlb among vcpus. This patch is to implement it.
> 
> Signed-off-by: Lan Tianyu 
> ---
> diff --git a/arch/x86/hyperv/nested.c b/arch/x86/hyperv/nested.c
> new file mode 100644
> index ..17f7c288eccc
> --- /dev/null
> +++ b/arch/x86/hyperv/nested.c
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +int hyperv_flush_guest_mapping(u64 as)
> +{
> + struct hv_guest_mapping_flush **flush_pcpu;
> + struct hv_guest_mapping_flush *flush;
> + u64 status = U64_MAX;

Initializing status to U64_MAX doesn't seem necessary.

> + unsigned long flags;
> + int ret = -EFAULT;
> +
> + if (!hv_hypercall_pg)
> + goto fault;
> +
> + local_irq_save(flags);
> +
> + flush_pcpu = (struct hv_guest_mapping_flush **)
> + this_cpu_ptr(hyperv_pcpu_input_arg);
> +
> + flush = *flush_pcpu;
> +
> + if (unlikely(!flush)) {
> + local_irq_restore(flags);
> + goto fault;
> + }
> +
> + flush->address_space = as;
> + flush->flags = 0;
> +
> + status = hv_do_hypercall(HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE,
> +  flush, NULL);
> + local_irq_restore(flags);
> +
> + if (!(status & HV_HYPERCALL_RESULT_MASK))
> + ret = 0;
> +
> +fault:
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);
> diff --git a/arch/x86/include/asm/hyperv-tlfs.h 
> b/arch/x86/include/asm/hyperv-tlfs.h
> index b8c89265baf0..53bbeb08faea 100644
> --- a/arch/x86/include/asm/hyperv-tlfs.h
> +++ b/arch/x86/include/asm/hyperv-tlfs.h
> @@ -309,6 +309,7 @@ struct ms_hyperv_tsc_page {
>  #define HV_X64_MSR_REENLIGHTENMENT_CONTROL   0x4106
> 
>  /* Nested features (CPUID 0x400A) EAX */
> +#define HV_X64_NESTED_GUSET_MAPPING_FLUSHBIT(18)

The #define name is misspelled.  "_GUSET_" should be "_GUEST_".
And the matching usage in patch 3/3 will need to be updated as well.

Michael


[PATCH v2] dmaengine: ti: omap-dma: Fix OMAP1510 incorrect residue_granularity

2018-06-05 Thread Janusz Krzysztofik
Commit 0198d7bb8a0c ("ASoC: omap-mcbsp: Convert to use the sdma-pcm
instead of omap-pcm") resulted in broken audio playback on OMAP1510
(discovered on Amstrad Delta).

When running on OMAP1510, omap-pcm used to obtain DMA offset from
snd_dmaengine_pcm_pointer_no_residue() based on DMA interrupt triggered
software calculations instead of snd_dmaengine_pcm_pointer() which
depended on residue value calculated from omap_dma_get_src_pos().
Similar code path is still available in now used
sound/soc/soc-generic-dmaengine-pcm.c but it is not triggered.

It was verified already before that omap_get_dma_src_pos() from
arch/arm/plat-omap/dma.c didn't work correctly for OMAP1510 - see
commit 1bdd7419910c ("ASoC: OMAP: fix OMAP1510 broken PCM pointer
callback") for details.  Apparently the same applies to its successor,
omap_dma_get_src_pos() from drivers/dma/ti/omap-dma.c.

On the other hand, snd_dmaengine_pcm_pointer_no_residue() is described
as depreciated and discouraged for use in new drivers because of its
unreliable accuracy.  However, it seems the only working option for
OPAM1510 now, as long as a software calculated residue is not
implemented as OMAP1510 fallback in omap-dma.

Using snd_dmaengine_pcm_pointer_no_residue() code path instead of
snd_dmaengine_pcm_pointer() in sound/soc/soc-generic-dmaengine-pcm.c
can be triggered in two ways:
- by passing pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE from
  sound/soc/omap/sdma-pcm.c,
- by passing dma_caps.residue_granularity =
  DMA_RESIDUE_GRANULARITY_DESCRIPTOR from DMA engine.

Let's do the latter.

Created and tested against next-20180531 tag from linux-next tree.

Signed-off-by: Janusz Krzysztofik 
Acked-by: Peter Ujfalusi 
---
Changelog:
v2: fix subject as requested by Peter.

 drivers/dma/ti/omap-dma.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
index b73fb51fbc81..96b5096c26dd 100644
--- a/drivers/dma/ti/omap-dma.c
+++ b/drivers/dma/ti/omap-dma.c
@@ -1485,7 +1485,11 @@ static int omap_dma_probe(struct platform_device *pdev)
od->ddev.src_addr_widths = OMAP_DMA_BUSWIDTHS;
od->ddev.dst_addr_widths = OMAP_DMA_BUSWIDTHS;
od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
-   od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
+   if (__dma_omap15xx(od->plat->dma_attr))
+   od->ddev.residue_granularity =
+   DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
+   else
+   od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
od->ddev.max_burst = SZ_16M - 1; /* CCEN: 24bit unsigned */
od->ddev.dev = >dev;
INIT_LIST_HEAD(>ddev.channels);
-- 
2.16.1



[PATCH 4.9 51/61] scsi: scsi_transport_srp: Fix shost to rport translation

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Bart Van Assche 

commit c9ddf73476ff4fffb7a87bd5107a0705bf2cf64b upstream.

Since an SRP remote port is attached as a child to shost->shost_gendev
and as the only child, the translation from the shost pointer into an
rport pointer must happen by looking up the shost child that is an
rport. This patch fixes the following KASAN complaint:

BUG: KASAN: slab-out-of-bounds in srp_timed_out+0x57/0x110 [scsi_transport_srp]
Read of size 4 at addr 880035d3fcc0 by task kworker/1:0H/19

CPU: 1 PID: 19 Comm: kworker/1:0H Not tainted 4.16.0-rc3-dbg+ #1
Workqueue: kblockd blk_mq_timeout_work
Call Trace:
dump_stack+0x85/0xc7
print_address_description+0x65/0x270
kasan_report+0x231/0x350
srp_timed_out+0x57/0x110 [scsi_transport_srp]
scsi_times_out+0xc7/0x3f0 [scsi_mod]
blk_mq_terminate_expired+0xc2/0x140
bt_iter+0xbc/0xd0
blk_mq_queue_tag_busy_iter+0x1c7/0x350
blk_mq_timeout_work+0x325/0x3f0
process_one_work+0x441/0xa50
worker_thread+0x76/0x6c0
kthread+0x1b2/0x1d0
ret_from_fork+0x24/0x30

Fixes: e68ca75200fe ("scsi_transport_srp: Reduce failover time")
Signed-off-by: Bart Van Assche 
Cc: Hannes Reinecke 
Cc: Johannes Thumshirn 
Cc: Jason Gunthorpe 
Cc: Doug Ledford 
Cc: Laurence Oberman 
Cc: sta...@vger.kernel.org
Reviewed-by: Johannes Thumshirn 
Signed-off-by: Martin K. Petersen 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/scsi/scsi_transport_srp.c |   22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -52,6 +52,8 @@ struct srp_internal {
struct transport_container rport_attr_cont;
 };
 
+static int scsi_is_srp_rport(const struct device *dev);
+
 #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t)
 
 #definedev_to_rport(d) container_of(d, struct srp_rport, dev)
@@ -61,9 +63,24 @@ static inline struct Scsi_Host *rport_to
return dev_to_shost(r->dev.parent);
 }
 
+static int find_child_rport(struct device *dev, void *data)
+{
+   struct device **child = data;
+
+   if (scsi_is_srp_rport(dev)) {
+   WARN_ON_ONCE(*child);
+   *child = dev;
+   }
+   return 0;
+}
+
 static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost)
 {
-   return transport_class_to_srp_rport(>shost_gendev);
+   struct device *child = NULL;
+
+   WARN_ON_ONCE(device_for_each_child(>shost_gendev, ,
+  find_child_rport) < 0);
+   return child ? dev_to_rport(child) : NULL;
 }
 
 /**
@@ -637,7 +654,8 @@ static enum blk_eh_timer_return srp_time
struct srp_rport *rport = shost_to_rport(shost);
 
pr_debug("timeout for sdev %s\n", dev_name(>sdev_gendev));
-   return rport->fast_io_fail_tmo < 0 && rport->dev_loss_tmo < 0 &&
+   return rport && rport->fast_io_fail_tmo < 0 &&
+   rport->dev_loss_tmo < 0 &&
i->f->reset_timer_if_blocked && scsi_device_blocked(sdev) ?
BLK_EH_RESET_TIMER : BLK_EH_NOT_HANDLED;
 }




[PATCH 4.9 47/61] net/mlx4_en: fix potential use-after-free with dma_unmap_page

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Sarah Newman 

[ Not relevant upstream, therefore no upstream commit. ]

To fix, unmap the page as soon as possible.

When swiotlb is in use, calling dma_unmap_page means that
the original page mapped with dma_map_page must still be valid,
as swiotlb will copy data from its internal cache back to the
originally requested DMA location.

When GRO is enabled, before this patch all references to the
original frag may be put and the page freed before dma_unmap_page
in mlx4_en_free_frag is called.

It is possible there is a path where the use-after-free occurs
even with GRO disabled, but this has not been observed so far.

The bug can be trivially detected by doing the following:

* Compile the kernel with DEBUG_PAGEALLOC
* Run the kernel as a Xen Dom0
* Leave GRO enabled on the interface
* Run a 10 second or more test with iperf over the interface.

This bug was likely introduced in
commit 4cce66cdd14a ("mlx4_en: map entire pages to increase throughput"),
first part of u3.6.

It was incidentally fixed in
commit 34db548bfb95 ("mlx4: add page recycling in receive path"),
first part of v4.12.

This version applies to the v4.9 series.

Signed-off-by: Sarah Newman 
Tested-by: Sarah Newman 
Cc: Tariq Toukan 
Cc: Yishai Hadas 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c |   32 ++---
 1 file changed, 20 insertions(+), 12 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -142,16 +142,17 @@ static void mlx4_en_free_frag(struct mlx
  struct mlx4_en_rx_alloc *frags,
  int i)
 {
-   const struct mlx4_en_frag_info *frag_info = >frag_info[i];
-   u32 next_frag_end = frags[i].page_offset + 2 * frag_info->frag_stride;
-
-
-   if (next_frag_end > frags[i].page_size)
-   dma_unmap_page(priv->ddev, frags[i].dma, frags[i].page_size,
-  frag_info->dma_dir);
+   if (frags[i].page) {
+   const struct mlx4_en_frag_info *frag_info = >frag_info[i];
+   u32 next_frag_end = frags[i].page_offset +
+   2 * frag_info->frag_stride;
 
-   if (frags[i].page)
+   if (next_frag_end > frags[i].page_size) {
+   dma_unmap_page(priv->ddev, frags[i].dma,
+  frags[i].page_size, frag_info->dma_dir);
+   }
put_page(frags[i].page);
+   }
 }
 
 static int mlx4_en_init_allocator(struct mlx4_en_priv *priv,
@@ -586,21 +587,28 @@ static int mlx4_en_complete_rx_desc(stru
int length)
 {
struct skb_frag_struct *skb_frags_rx = skb_shinfo(skb)->frags;
-   struct mlx4_en_frag_info *frag_info;
int nr;
dma_addr_t dma;
 
/* Collect used fragments while replacing them in the HW descriptors */
for (nr = 0; nr < priv->num_frags; nr++) {
-   frag_info = >frag_info[nr];
+   struct mlx4_en_frag_info *frag_info = >frag_info[nr];
+   u32 next_frag_end = frags[nr].page_offset +
+   2 * frag_info->frag_stride;
+
if (length <= frag_info->frag_prefix_size)
break;
if (unlikely(!frags[nr].page))
goto fail;
 
dma = be64_to_cpu(rx_desc->data[nr].addr);
-   dma_sync_single_for_cpu(priv->ddev, dma, frag_info->frag_size,
-   DMA_FROM_DEVICE);
+   if (next_frag_end > frags[nr].page_size)
+   dma_unmap_page(priv->ddev, frags[nr].dma,
+  frags[nr].page_size, frag_info->dma_dir);
+   else
+   dma_sync_single_for_cpu(priv->ddev, dma,
+   frag_info->frag_size,
+   DMA_FROM_DEVICE);
 
/* Save page reference in skb */
__skb_frag_set_page(_frags_rx[nr], frags[nr].page);




[PATCH 4.9 61/61] serial: pl011: add console matching function

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Aleksey Makarov 

commit 10879ae5f12e9cab3c4e8e9504c1aaa8a033bde7 upstream.

This patch adds function pl011_console_match() that implements
method match of struct console.  It allows to match consoles against
data specified in a string, for example taken from command line or
compiled by ACPI SPCR table handler.

This patch was merged to tty-next but then reverted because of
conflict with

commit 46e36683f433 ("serial: earlycon: Extend earlycon command line option to 
support 64-bit addresses")

Now it is fixed.

Signed-off-by: Aleksey Makarov 
Reviewed-by: Peter Hurley 
Acked-by: Russell King 
Tested-by: Christopher Covington 
Signed-off-by: Ard Biesheuvel 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/tty/serial/amba-pl011.c |   55 
 1 file changed, 55 insertions(+)

--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2320,12 +2320,67 @@ static int __init pl011_console_setup(st
return uart_set_options(>port, co, baud, parity, bits, flow);
 }
 
+/**
+ * pl011_console_match - non-standard console matching
+ * @co:  registering console
+ * @name:name from console command line
+ * @idx: index from console command line
+ * @options: ptr to option string from console command line
+ *
+ * Only attempts to match console command lines of the form:
+ * console=pl011,mmio|mmio32,[,]
+ * console=pl011,0x[,]
+ * This form is used to register an initial earlycon boot console and
+ * replace it with the amba_console at pl011 driver init.
+ *
+ * Performs console setup for a match (as required by interface)
+ * If no  are specified, then assume the h/w is already setup.
+ *
+ * Returns 0 if console matches; otherwise non-zero to use default matching
+ */
+static int __init pl011_console_match(struct console *co, char *name, int idx,
+ char *options)
+{
+   unsigned char iotype;
+   resource_size_t addr;
+   int i;
+
+   if (strcmp(name, "pl011") != 0)
+   return -ENODEV;
+
+   if (uart_parse_earlycon(options, , , ))
+   return -ENODEV;
+
+   if (iotype != UPIO_MEM && iotype != UPIO_MEM32)
+   return -ENODEV;
+
+   /* try to match the port specified on the command line */
+   for (i = 0; i < ARRAY_SIZE(amba_ports); i++) {
+   struct uart_port *port;
+
+   if (!amba_ports[i])
+   continue;
+
+   port = _ports[i]->port;
+
+   if (port->mapbase != addr)
+   continue;
+
+   co->index = i;
+   port->cons = co;
+   return pl011_console_setup(co, options);
+   }
+
+   return -ENODEV;
+}
+
 static struct uart_driver amba_reg;
 static struct console amba_console = {
.name   = "ttyAMA",
.write  = pl011_console_write,
.device = uart_console_device,
.setup  = pl011_console_setup,
+   .match  = pl011_console_match,
.flags  = CON_PRINTBUFFER,
.index  = -1,
.data   = _reg,




[PATCH 4.9 49/61] MIPS: ptrace: Fix PTRACE_PEEKUSR requests for 64-bit FGRs

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Maciej W. Rozycki 

commit c7e814628df65f424fe197dde73bfc67e4a244d7 upstream.

Use 64-bit accesses for 64-bit floating-point general registers with
PTRACE_PEEKUSR, removing the truncation of their upper halves in the
FR=1 mode, caused by commit bbd426f542cb ("MIPS: Simplify FP context
access"), which inadvertently switched them to using 32-bit accesses.

The PTRACE_POKEUSR side is fine as it's never been broken and continues
using 64-bit accesses.

Fixes: bbd426f542cb ("MIPS: Simplify FP context access")
Signed-off-by: Maciej W. Rozycki 
Cc: Ralf Baechle 
Cc: linux-m...@linux-mips.org
Cc:  # 3.15+
Patchwork: https://patchwork.linux-mips.org/patch/19334/
Signed-off-by: James Hogan 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/mips/kernel/ptrace.c   |2 +-
 arch/mips/kernel/ptrace32.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -838,7 +838,7 @@ long arch_ptrace(struct task_struct *chi
break;
}
 #endif
-   tmp = get_fpr32([addr - FPR_BASE], 0);
+   tmp = get_fpr64([addr - FPR_BASE], 0);
break;
case PC:
tmp = regs->cp0_epc;
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -107,7 +107,7 @@ long compat_arch_ptrace(struct task_stru
addr & 1);
break;
}
-   tmp = get_fpr32([addr - FPR_BASE], 0);
+   tmp = get_fpr64([addr - FPR_BASE], 0);
break;
case PC:
tmp = regs->cp0_epc;




[PATCH 4.9 54/61] IB/core: Fix error code for invalid GID entry

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Parav Pandit 

commit a840c93ca7582bb6c88df2345a33f979b7a67874 upstream.

When a GID entry is invalid EAGAIN is returned. This is an incorrect error
code, there is nothing that will make this GID entry valid again in
bounded time.

Some user space tools fail incorrectly if EAGAIN is returned here, and
this represents a small ABI change from earlier kernels.

The first patch in the Fixes list makes entries that were valid before
to become invalid, allowing this code to trigger, while the second patch
in the Fixes list introduced the wrong EAGAIN.

Therefore revert the return result to EINVAL which matches the historical
expectations of the ibv_query_gid_type() API of the libibverbs user space
library.

Cc: 
Fixes: 598ff6bae689 ("IB/core: Refactor GID modify code for RoCE")
Fixes: 03db3a2d81e6 ("IB/core: Add RoCE GID table management")
Reviewed-by: Daniel Jurgens 
Signed-off-by: Parav Pandit 
Signed-off-by: Leon Romanovsky 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/cache.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -437,7 +437,7 @@ static int __ib_cache_gid_get(struct ib_
return -EINVAL;
 
if (table->data_vec[index].props & GID_TABLE_ENTRY_INVALID)
-   return -EAGAIN;
+   return -EINVAL;
 
memcpy(gid, >data_vec[index].gid, sizeof(*gid));
if (attr) {




Re: [PATCH v2 2/3] ACPI / PPTT: fix build when CONFIG_ACPI_PPTT is not enabled

2018-06-05 Thread Catalin Marinas
On Tue, Jun 05, 2018 at 03:35:03PM +0100, Sudeep Holla wrote:
> Though CONFIG_ACPI_PPTT is selected by platforms and nor user visible,
> it may be useful to support the build with CONFIG_ACPI_PPTT disabled.
> 
> This patch adds the missing dummy/boiler plate implementation to fix
> the build.
> 
> Cc: "Rafael J. Wysocki" 
> Signed-off-by: Sudeep Holla 
> ---
>  include/linux/acpi.h  | 15 +++
>  include/linux/cacheinfo.h |  2 +-
>  2 files changed, 16 insertions(+), 1 deletion(-)

I queued this patch for now, it's a good clean-up regardless of whether
we disable PPTT temporarily or not.

Thanks.

-- 
Catalin


[PATCH 4.9 50/61] MIPS: prctl: Disallow FRE without FR with PR_SET_FP_MODE requests

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Maciej W. Rozycki 

commit 28e4213dd331e944e7fca1954a946829162ed9d4 upstream.

Having PR_FP_MODE_FRE (i.e. Config5.FRE) set without PR_FP_MODE_FR (i.e.
Status.FR) is not supported as the lone purpose of Config5.FRE is to
emulate Status.FR=0 handling on FPU hardware that has Status.FR=1
hardwired[1][2].  Also we do not handle this case elsewhere, and assume
throughout our code that TIF_HYBRID_FPREGS and TIF_32BIT_FPREGS cannot
be set both at once for a task, leading to inconsistent behaviour if
this does happen.

Return unsuccessfully then from prctl(2) PR_SET_FP_MODE calls requesting
PR_FP_MODE_FRE to be set with PR_FP_MODE_FR clear.  This corresponds to
modes allowed by `mips_set_personality_fp'.

References:

[1] "MIPS Architecture For Programmers, Vol. III: MIPS32 / microMIPS32
Privileged Resource Architecture", Imagination Technologies,
Document Number: MD00090, Revision 6.02, July 10, 2015, Table 9.69
"Config5 Register Field Descriptions", p. 262

[2] "MIPS Architecture For Programmers, Volume III: MIPS64 / microMIPS64
Privileged Resource Architecture", Imagination Technologies,
Document Number: MD00091, Revision 6.03, December 22, 2015, Table
9.72 "Config5 Register Field Descriptions", p. 288

Fixes: 9791554b45a2 ("MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS")
Signed-off-by: Maciej W. Rozycki 
Cc: Ralf Baechle 
Cc: linux-m...@linux-mips.org
Cc:  # 4.0+
Patchwork: https://patchwork.linux-mips.org/patch/19327/
Signed-off-by: James Hogan 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/mips/kernel/process.c |4 
 1 file changed, 4 insertions(+)

--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -699,6 +699,10 @@ int mips_set_process_fp_mode(struct task
if (value & ~known_bits)
return -EOPNOTSUPP;
 
+   /* Setting FRE without FR is not supported.  */
+   if ((value & (PR_FP_MODE_FR | PR_FP_MODE_FRE)) == PR_FP_MODE_FRE)
+   return -EOPNOTSUPP;
+
/* Avoid inadvertently triggering emulation */
if ((value & PR_FP_MODE_FR) && raw_cpu_has_fpu &&
!(raw_current_cpu_data.fpu_id & MIPS_FPIR_F64))




[PATCH 4.9 53/61] hwtracing: stm: fix build error on some arches

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Greg Kroah-Hartman 

commit 806e30873f0e74d9d41b0ef761bd4d3e55c7d510 upstream.

Commit b5e2ced9bf81 ("stm class: Use vmalloc for the master map") caused
a build error on some arches as vmalloc.h was not explicitly included.

Fix that by adding it to the list of includes.

Fixes: b5e2ced9bf81 ("stm class: Use vmalloc for the master map")
Reported-by: kbuild test robot 
Cc: Alexander Shishkin 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/hwtracing/stm/core.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "stm.h"
 
 #include 




[PATCH 4.9 48/61] iio:kfifo_buf: check for uint overflow

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Martin Kelly 

commit 3d13de4b027d5f6276c0f9d3a264f518747d83f2 upstream.

Currently, the following causes a kernel OOPS in memcpy:

echo 1073741825 > buffer/length
echo 1 > buffer/enable

Note that using 1073741824 instead of 1073741825 causes "write error:
Cannot allocate memory" but no OOPS.

This is because 1073741824 == 2^30 and 1073741825 == 2^30+1. Since kfifo
rounds up to the nearest power of 2, it will actually call kmalloc with
roundup_pow_of_two(length) * bytes_per_datum.

Using length == 1073741825 and bytes_per_datum == 2, we get:

kmalloc(roundup_pow_of_two(1073741825) * 2
or kmalloc(2147483648 * 2)
or kmalloc(4294967296)
or kmalloc(UINT_MAX + 1)

so this overflows to 0, causing kmalloc to return ZERO_SIZE_PTR and
subsequent memcpy to fail once the device is enabled.

Fix this by checking for overflow prior to allocating a kfifo. With this
check added, the above code returns -EINVAL when enabling the buffer,
rather than causing an OOPS.

Signed-off-by: Martin Kelly 
cc: 
Signed-off-by: Jonathan Cameron 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/iio/buffer/kfifo_buf.c |7 +++
 1 file changed, 7 insertions(+)

--- a/drivers/iio/buffer/kfifo_buf.c
+++ b/drivers/iio/buffer/kfifo_buf.c
@@ -24,6 +24,13 @@ static inline int __iio_allocate_kfifo(s
if ((length == 0) || (bytes_per_datum == 0))
return -EINVAL;
 
+   /*
+* Make sure we don't overflow an unsigned int after kfifo rounds up to
+* the next power of 2.
+*/
+   if (roundup_pow_of_two(length) > UINT_MAX / bytes_per_datum)
+   return -EINVAL;
+
return __kfifo_alloc((struct __kfifo *)>kf, length,
 bytes_per_datum, GFP_KERNEL);
 }




[PATCH 4.9 52/61] stm class: Use vmalloc for the master map

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Alexander Shishkin 

commit b5e2ced9bf81393034072dd4d372f6b430bc1f0a upstream.

Fengguang is running into a warning from the buddy allocator:

> swapper/0: page allocation failure: order:9, 
> mode:0x14040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null)
> CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.17.0-rc1 #262
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 
> 04/01/2014
> Call Trace:
...
>  __kmalloc+0x14b/0x180: cache_alloc at mm/slab.c:3127
>  stm_register_device+0xf3/0x5c0: stm_register_device at 
> drivers/hwtracing/stm/core.c:695
...

Which is basically a result of the stm class trying to allocate ~512kB
for the dummy_stm with its default parameters. There's no reason, however,
for it not to be vmalloc()ed instead, which is what this patch does.

Reported-by: Fengguang Wu 
Signed-off-by: Alexander Shishkin 
CC: sta...@vger.kernel.org # v4.4+
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/hwtracing/stm/core.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/hwtracing/stm/core.c
+++ b/drivers/hwtracing/stm/core.c
@@ -682,7 +682,7 @@ static void stm_device_release(struct de
 {
struct stm_device *stm = to_stm_device(dev);
 
-   kfree(stm);
+   vfree(stm);
 }
 
 int stm_register_device(struct device *parent, struct stm_data *stm_data,
@@ -699,7 +699,7 @@ int stm_register_device(struct device *p
return -EINVAL;
 
nmasters = stm_data->sw_end - stm_data->sw_start + 1;
-   stm = kzalloc(sizeof(*stm) + nmasters * sizeof(void *), GFP_KERNEL);
+   stm = vzalloc(sizeof(*stm) + nmasters * sizeof(void *));
if (!stm)
return -ENOMEM;
 
@@ -752,7 +752,7 @@ err_device:
/* matches device_initialize() above */
put_device(>dev);
 err_free:
-   kfree(stm);
+   vfree(stm);
 
return err;
 }




[PATCH 4.9 59/61] mm: fix the NULL mapping case in __isolate_lru_page()

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Hugh Dickins 

commit 145e1a71e090575c74969e3daa8136d1e5b99fc8 upstream.

George Boole would have noticed a slight error in 4.16 commit
69d763fc6d3a ("mm: pin address_space before dereferencing it while
isolating an LRU page").  Fix it, to match both the comment above it,
and the original behaviour.

Although anonymous pages are not marked PageDirty at first, we have an
old habit of calling SetPageDirty when a page is removed from swap
cache: so there's a category of ex-swap pages that are easily
migratable, but were inadvertently excluded from compaction's async
migration in 4.16.

Link: http://lkml.kernel.org/r/alpine.LSU.2.11.1805302014001.12558@eggly.anvils
Fixes: 69d763fc6d3a ("mm: pin address_space before dereferencing it while 
isolating an LRU page")
Signed-off-by: Hugh Dickins 
Acked-by: Minchan Kim 
Acked-by: Mel Gorman 
Reported-by:  Ivan Kalvachev 
Cc: "Huang, Ying" 
Cc: Jan Kara 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 mm/vmscan.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1393,7 +1393,7 @@ int __isolate_lru_page(struct page *page
return ret;
 
mapping = page_mapping(page);
-   migrate_dirty = mapping && mapping->a_ops->migratepage;
+   migrate_dirty = !mapping || mapping->a_ops->migratepage;
unlock_page(page);
if (!migrate_dirty)
return ret;




[PATCH 4.9 38/61] powerpc/powernv: Use the security flags in pnv_setup_rfi_flush()

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Ellerman 

commit 37c0bdd00d3ae83369ab60a6712c28e11e6458d5 upstream.

Now that we have the security flags we can significantly simplify the
code in pnv_setup_rfi_flush(), because we can use the flags instead of
checking device tree properties and because the security flags have
pessimistic defaults.

Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/powernv/setup.c |   41 -
 1 file changed, 10 insertions(+), 31 deletions(-)

--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -65,7 +65,7 @@ static void init_fw_feat_flags(struct de
if (fw_feature_is("enabled", "fw-bcctrl-serialized", np))
security_ftr_set(SEC_FTR_BCCTRL_SERIALISED);
 
-   if (fw_feature_is("enabled", "inst-spec-barrier-ori31,31,0", np))
+   if (fw_feature_is("enabled", "inst-l1d-flush-ori30,30,0", np))
security_ftr_set(SEC_FTR_L1D_FLUSH_ORI30);
 
if (fw_feature_is("enabled", "inst-l1d-flush-trig2", np))
@@ -98,11 +98,10 @@ static void pnv_setup_rfi_flush(void)
 {
struct device_node *np, *fw_features;
enum l1d_flush_type type;
-   int enable;
+   bool enable;
 
/* Default to fallback in case fw-features are not available */
type = L1D_FLUSH_FALLBACK;
-   enable = 1;
 
np = of_find_node_by_name(NULL, "ibm,opal");
fw_features = of_get_child_by_name(np, "fw-features");
@@ -110,40 +109,20 @@ static void pnv_setup_rfi_flush(void)
 
if (fw_features) {
init_fw_feat_flags(fw_features);
+   of_node_put(fw_features);
 
-   np = of_get_child_by_name(fw_features, "inst-l1d-flush-trig2");
-   if (np && of_property_read_bool(np, "enabled"))
+   if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_TRIG2))
type = L1D_FLUSH_MTTRIG;
 
-   of_node_put(np);
-
-   np = of_get_child_by_name(fw_features, 
"inst-l1d-flush-ori30,30,0");
-   if (np && of_property_read_bool(np, "enabled"))
+   if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_ORI30))
type = L1D_FLUSH_ORI;
-
-   of_node_put(np);
-
-   /* Enable unless firmware says NOT to */
-   enable = 2;
-   np = of_get_child_by_name(fw_features, 
"needs-l1d-flush-msr-hv-1-to-0");
-   if (np && of_property_read_bool(np, "disabled"))
-   enable--;
-
-   of_node_put(np);
-
-   np = of_get_child_by_name(fw_features, 
"needs-l1d-flush-msr-pr-0-to-1");
-   if (np && of_property_read_bool(np, "disabled"))
-   enable--;
-
-   np = of_get_child_by_name(fw_features, 
"speculation-policy-favor-security");
-   if (np && of_property_read_bool(np, "disabled"))
-   enable = 0;
-
-   of_node_put(np);
-   of_node_put(fw_features);
}
 
-   setup_rfi_flush(type, enable > 0);
+   enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && \
+(security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR)   || \
+ security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV));
+
+   setup_rfi_flush(type, enable);
 }
 
 static void __init pnv_setup_arch(void)




[PATCH 4.9 36/61] powerpc/64s: Move cpu_show_meltdown()

2018-06-05 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Ellerman 

commit 8ad33041563a10b34988800c682ada14b2612533 upstream.

This landed in setup_64.c for no good reason other than we had nowhere
else to put it. Now that we have a security-related file, that is a
better place for it so move it.

[mpe: Add extern for rfi_flush to fix bisection break]
Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/include/asm/security_features.h |1 +
 arch/powerpc/kernel/security.c   |   11 +++
 arch/powerpc/kernel/setup_64.c   |8 
 3 files changed, 12 insertions(+), 8 deletions(-)

--- a/arch/powerpc/include/asm/security_features.h
+++ b/arch/powerpc/include/asm/security_features.h
@@ -10,6 +10,7 @@
 
 
 extern unsigned long powerpc_security_features;
+extern bool rfi_flush;
 
 static inline void security_ftr_set(unsigned long feature)
 {
--- a/arch/powerpc/kernel/security.c
+++ b/arch/powerpc/kernel/security.c
@@ -5,6 +5,8 @@
 // Copyright 2018, Michael Ellerman, IBM Corporation.
 
 #include 
+#include 
+
 #include 
 
 
@@ -13,3 +15,12 @@ unsigned long powerpc_security_features
SEC_FTR_L1D_FLUSH_PR | \
SEC_FTR_BNDS_CHK_SPEC_BAR | \
SEC_FTR_FAVOUR_SECURITY;
+
+
+ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, 
char *buf)
+{
+   if (rfi_flush)
+   return sprintf(buf, "Mitigation: RFI Flush\n");
+
+   return sprintf(buf, "Vulnerable\n");
+}
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -805,12 +805,4 @@ static __init int rfi_flush_debugfs_init
 }
 device_initcall(rfi_flush_debugfs_init);
 #endif
-
-ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, 
char *buf)
-{
-   if (rfi_flush)
-   return sprintf(buf, "Mitigation: RFI Flush\n");
-
-   return sprintf(buf, "Vulnerable\n");
-}
 #endif /* CONFIG_PPC_BOOK3S_64 */




[PATCH 4.4 35/37] sparc64: Add __multi3 for gcc 7.x and later.

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: David S. Miller 

commit 1b4af13ff2cc6897557bb0b8d9e2fad4fa4d67aa upstream.

Reported-by: Waldemar Brodkorb 
Signed-off-by: David S. Miller 
Cc: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/sparc/lib/Makefile |1 +
 arch/sparc/lib/multi3.S |   35 +++
 2 files changed, 36 insertions(+)

--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -15,6 +15,7 @@ lib-$(CONFIG_SPARC32) += copy_user.o loc
 lib-$(CONFIG_SPARC64) += atomic_64.o
 lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o
 lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o
+lib-$(CONFIG_SPARC64) += multi3.o
 
 lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o
 lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o
--- /dev/null
+++ b/arch/sparc/lib/multi3.S
@@ -0,0 +1,35 @@
+#include 
+#include 
+
+   .text
+   .align  4
+ENTRY(__multi3) /* %o0 = u, %o1 = v */
+   mov %o1, %g1
+   srl %o3, 0, %g4
+   mulx%g4, %g1, %o1
+   srlx%g1, 0x20, %g3
+   mulx%g3, %g4, %g5
+   sllx%g5, 0x20, %o5
+   srl %g1, 0, %g4
+   sub %o1, %o5, %o5
+   srlx%o5, 0x20, %o5
+   addcc   %g5, %o5, %g5
+   srlx%o3, 0x20, %o5
+   mulx%g4, %o5, %g4
+   mulx%g3, %o5, %o5
+   sethi   %hi(0x8000), %g3
+   addcc   %g5, %g4, %g5
+   srlx%g5, 0x20, %g5
+   add %g3, %g3, %g3
+   movcc   %xcc, %g0, %g3
+   addcc   %o5, %g5, %o5
+   sllx%g4, 0x20, %g4
+   add %o1, %g4, %o1
+   add %o5, %g3, %g2
+   mulx%g1, %o2, %g1
+   add %g1, %g2, %g1
+   mulx%o0, %o3, %o0
+   retl
+add%g1, %o0, %o0
+ENDPROC(__multi3)
+EXPORT_SYMBOL(__multi3)




Re: [PATCH] slab: Clean up the code comment in slab kmem_cache struct

2018-06-05 Thread Christopher Lameter
On Sun, 3 Jun 2018, Baoquan He wrote:

> diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
> index d9228e4d0320..3485c58cfd1c 100644
> --- a/include/linux/slab_def.h
> +++ b/include/linux/slab_def.h
> @@ -67,9 +67,10 @@ struct kmem_cache {
>
>   /*
>* If debugging is enabled, then the allocator can add additional
> -  * fields and/or padding to every object. size contains the total
> -  * object size including these internal fields, the following two
> -  * variables contain the offset to the user object and its size.
> +  * fields and/or padding to every object. 'size' contains the total
> +  * object size including these internal fields, while 'obj_offset'
> +  * and 'object_size' contain the offset to the user object and its
> +  * size.
>*/
>   int obj_offset;
>  #endif /* CONFIG_DEBUG_SLAB */
>

Wish we had some more consistent naming. object_size and obj_offset??? And
the fields better be as close together as possible.


Acked-by: Christoph Lameter 



[PATCH 4.4 08/37] tracing: Fix crash when freeing instances with event triggers

2018-06-05 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Steven Rostedt (VMware) 

commit 86b389ff22bd6ad8fd3cb98e41cd271886c6d023 upstream.

If a instance has an event trigger enabled when it is freed, it could cause
an access of free memory. Here's the case that crashes:

 # cd /sys/kernel/tracing
 # mkdir instances/foo
 # echo snapshot > instances/foo/events/initcall/initcall_start/trigger
 # rmdir instances/foo

Would produce:

 general protection fault:  [#1] PREEMPT SMP PTI
 Modules linked in: tun bridge ...
 CPU: 5 PID: 6203 Comm: rmdir Tainted: GW 4.17.0-rc4-test+ #933
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 
07/14/2016
 RIP: 0010:clear_event_triggers+0x3b/0x70
 RSP: 0018:c90003783de0 EFLAGS: 00010286
 RAX:  RBX: 6b6b6b6b6b6b6b2b RCX: 
 RDX:  RSI:  RDI: 8800c7130ba0
 RBP: c90003783e00 R08: 8801131993f8 R09: 000100230016
 R10: c90003783d80 R11:  R12: 8800c7130ba0
 R13: 8800c7130bd8 R14: 8800cc093768 R15: ff9c
 FS:  7f6f4aa86700() GS:88011eb4() knlGS:
 CS:  0010 DS:  ES:  CR0: 80050033
 CR2: 7f6f4a5aed60 CR3: cd552001 CR4: 001606e0
 Call Trace:
  event_trace_del_tracer+0x2a/0xc5
  instance_rmdir+0x15c/0x200
  tracefs_syscall_rmdir+0x52/0x90
  vfs_rmdir+0xdb/0x160
  do_rmdir+0x16d/0x1c0
  __x64_sys_rmdir+0x17/0x20
  do_syscall_64+0x55/0x1a0
  entry_SYSCALL_64_after_hwframe+0x49/0xbe

This was due to the call the clears out the triggers when an instance is
being deleted not removing the trigger from the link list.

Cc: sta...@vger.kernel.org
Fixes: 85f2b08268c01 ("tracing: Add basic event trigger framework")
Signed-off-by: Steven Rostedt (VMware) 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/trace/trace_events_trigger.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -469,9 +469,10 @@ clear_event_triggers(struct trace_array
struct trace_event_file *file;
 
list_for_each_entry(file, >events, list) {
-   struct event_trigger_data *data;
-   list_for_each_entry_rcu(data, >triggers, list) {
+   struct event_trigger_data *data, *n;
+   list_for_each_entry_safe(data, n, >triggers, list) {
trace_event_trigger_enable_disable(file, 0);
+   list_del_rcu(>list);
if (data->ops->free)
data->ops->free(data->ops, data);
}




Re: [GIT PULL] Device properties framework update for v4.18-rc1

2018-06-05 Thread Linus Torvalds
On Mon, Jun 4, 2018 at 4:31 AM Rafael J. Wysocki  wrote:
>
>  device property: Get rid of union aliasing

Honestly, this looks questionable to me.

I'm not talking about the changes themselves - I can live with them.
But the _rationale_ is pure and utter garbage, and dangerously so.

The fact is, using a union to do type punning is the traditional AND
STANDARD way to do type punning in gcc. In fact, it is the
*documented* way to do it for gcc, when you are a f*cking moron and
use "-fstrict-aliasing" and need to undo the braindamage that that
piece of garbage C standard imposes.

So the commit message that talks about how horrible union aliasing is
is pushing a story that is simply wrong. Using the standard to push it
- the same standard that came up with the completely mis-guided
aliasing rules - is not a valid argument.

Andy, what is the background for trying to push this idiocy? Don't
tell me "the C standard is unclear". The C standard is _clearly_ bogus
shit (see above on strict aliasing rules), and when it is bogus
garbage, it needs to be explicitly ignored, and it needs per-compiler
workarounds for braindamage. The exact same situation is true when
there is some lack of clarity.

This is why we use -fwrapv, -fno-strict-aliasing etc. The standard
simply is not *important*, when it is in direct conflict with reality
and reliable code generation.

The *fact* is that gcc documents type punning through unions as the
"right way". You may disagree with that, but putting some theoretical
standards language over the *explicit* and long-time documentation of
the main compiler we use is pure and utter bullshit.

I've said this before, and I'll say it again: a standards paper is
just so much toilet paper when it conflicts with reality. It has
absolutely _zero_ relevance. In fact, I'll take real toilet paper over
standards any day, because at least that way I won't have splinters
and ink up my arse.

So I want to see actual real arguments, not "the standard is unclear".
When documented gcc behavior says one thing, and the standard might be
unclear, we really don't care one whit about the lack of clarity in
some standard.

So what's the _real_ reason for avoiding union aliasing?

There are competent people on standards bodies. But they aren't
_always_ competent, and the translation of intent to English isn't
always perfect either. So standards are not some kind of holy book
that has to be revered. Standards too need to be questioned.

 Linus


Re: How to print stack uses of IRQ in ARM64

2018-06-05 Thread James Morse
Hi Vishun,

(CC: +linux-arm-kernel list)

On 05/06/18 14:12, Andy Shevchenko wrote:
> On Thu, May 31, 2018 at 1:01 PM, Vishnu Motghare
>  wrote:
>> My understanding is each CPU  getting its own IRQ stack. So is it
>> possible to print the stack uses of each IRQ handler?

The stacks are per-cpu not per-handler, so you would get a jumble of different
interrupt-handlers, mixed up with softirq that runs on the same stack.


>> like, How much stack is used & how much left free ?

What would you do with the information?


>> like in process context we have API like stack_not_used(struct
>> task_struct *p) to get the unused stack  of processes.

Isn't this only printed when the process exits?
When would you print it for an irqstack?

To get this information you would need to mask interrupts, then search backwards
on the irq-stack to find the 'last' value. I think it would always be more
useful to take interrupts in that time...


>> So, is it possible to get the similar result for IRQ?

Probably, but I don't think its useful.
If you're debugging a stack-overflow, its much better to use vmap stacks, which
will give you the function and stack trace that triggered the overflow.


Thanks,

James


Re: [CFT][PATCH] kernfs: Correct kernfs directory seeks.

2018-06-05 Thread Eric W. Biederman
"'t...@kernel.org'"  writes:

> Hello,
>
> On Tue, Jun 05, 2018 at 10:31:36AM -0500, Eric W. Biederman wrote:
>> What I have above is not the clearest, and in fact the logic could be
>> better.
>> 
>> The fundamental challenge is because hash collisions are possible a file
>> offset does not hold complete position information in a directory.
>> 
>> So the kernfs node that is to be read/displayed next is saved in the
>> struct file.  The it is tested if the saved kernfs node is usable
>> for finding the location in the directory.  Several things may have
>> gone wrong.
>> 
>> - Someone may have called seekdir.
>> - The saved kernfs node may have been renamed.
>> - The saved kernfs node may have been moved to a different directory in
>>   kernfs.
>> - the saved kernfs node may have been deleted.
>> 
>> If any of those are true the code needs to do the rbtree lookup.
>
> So, given that the whole thing is protected by a mutex which protects
> modifications, it could be an option to simply keep track of who's
> iterating what and shift them on removals.  IOW, always keep cursor
> pointing to the next thing to visit and if that gets removed shift the
> cursor to the next one.

Yes.  We could.

The primary case we have to worry about is someone using seekdir,
and for that we always need the rbtree lookup.   For seekdir
we could invalidate the saved entry and make things simpler
that way.

We could add list_head to the kernfs_node and create:
struct kernfs_dir_file {
struct list_head entry;
struct kernfs_node *kn;
}
And point at that from struct file->private_data.

I don't know if it would be worth the trouble to do that over a quick
check to make certain the kernfs_node is what it is expected to be.
But that is an option.

Part of the pain of supporting seekdir is that the offset we expose
to userspace in has to be 32bit to support 32bit userspace applications.
Which unfortunately is small enough that if nothing else a name
collision can be brute forced.  So we can not avoid handling collisions.


Sigh,  I have found another issue with kernfs_fop_readdir.

We are not currently protecting file->private_data with the kernfs_mutex
or any other kind of serialization.  Which means if two processes are
calling readdir on the same file descriptor we might get unpredictable
behavior.

It doesn't look too bad and easy enough to fix, but definitely something
to be watchful of.

Eric


[PATCH 43/46] perf intel-pt: Fix sync_switch INTEL_PT_SS_NOT_TRACING

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Adrian Hunter 

sync_switch is a facility to synchronize decoding more closely with the
point in the kernel when the context actually switched.

In one case, INTEL_PT_SS_NOT_TRACING state was not correctly
transitioning to INTEL_PT_SS_TRACING state due to a missing case clause.
Add it.

Signed-off-by: Adrian Hunter 
Cc: sta...@vger.kernel.org
Link: 
http://lkml.kernel.org/r/1527762225-26024-2-git-send-email-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/intel-pt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 492986a25ef6..3db7f0ee52a8 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1521,6 +1521,7 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)
 
if (intel_pt_is_switch_ip(ptq, state->to_ip)) {
switch (ptq->switch_state) {
+   case INTEL_PT_SS_NOT_TRACING:
case INTEL_PT_SS_UNKNOWN:
case INTEL_PT_SS_EXPECTING_SWITCH_IP:
err = intel_pt_next_tid(pt, ptq);
-- 
2.14.3



[PATCH 41/46] perf test record+probe_libc_inet_pton: Ask 'nm' for dynamic symbols

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Adrian reported that this test fails in his system where:

  probe libc's inet_pton & backtrace it with ping: FAILED!
  root@kbl04:~/git/linux-perf# nm -g /lib/x86_64-linux-gnu/libc-2.19.so | grep 
inet_pton
  nm: /lib/x86_64-linux-gnu/libc-2.19.so: no symbols

This fails on ubuntu systems, with Adrian's being kubuntu 14.04, I
tested with ubuntu 14.04.4 and 18.04, and there we need to use the
-D/--dynamic 'nm' option to have this test working. And it works as well
with that on fedora 27, so use it.

Reported-by: Adrian Hunter 
Cc: David Ahern 
Cc: Heiko Carstens 
Cc: Hendrik Brueckner 
Cc: Jiri Olsa 
Cc: Martin Schwidefsky 
Cc: Namhyung Kim 
Cc: Naveen N. Rao 
Cc: Sandipan Das 
Cc: Thomas Richter 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-zlfnbauad3ljlmtjgo0v6...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 650b208f700f..263057039693 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
 . $(dirname $0)/lib/probe.sh
 
 libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254
 
 trace_libc_inet_pton_backtrace() {
idx=0
-- 
2.14.3



[PATCH 40/46] perf map: Consider PTI entry trampolines in rip_2objdump()

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Adrian Hunter 

perf tools uses map__rip_2objdump() to calculate objdump virtual addresses.
map__rip_2objdump() needs to be amended to deal with PTI entry trampolines.

Signed-off-by: Adrian Hunter 
Reported-by: Arnaldo Carvalho de Melo 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Link: 
http://lkml.kernel.org/r/1528183800-21577-1-git-send-email-adrian.hun...@intel.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/map.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 92abc8e248c5..89ac5b5dc218 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -449,6 +449,20 @@ int map__fprintf_srcline(struct map *map, u64 addr, const 
char *prefix,
  */
 u64 map__rip_2objdump(struct map *map, u64 rip)
 {
+   struct kmap *kmap = __map__kmap(map);
+
+   /*
+* vmlinux does not have program headers for PTI entry trampolines and
+* kcore may not either. However the trampoline object code is on the
+* main kernel map, so just use that instead.
+*/
+   if (kmap && is_entry_trampoline(kmap->name) && kmap->kmaps && 
kmap->kmaps->machine) {
+   struct map *kernel_map = 
machine__kernel_map(kmap->kmaps->machine);
+
+   if (kernel_map)
+   map = kernel_map;
+   }
+
if (!map->dso->adjust_symbols)
return rip;
 
-- 
2.14.3



[PATCH v2 5/8] Input: cros_ec_keyb - Switch to SPDX identifier.

2018-06-05 Thread Enric Balletbo i Serra
Adopt the SPDX license identifier headers to ease license compliance
management.

Signed-off-by: Enric Balletbo i Serra 
---

Changes in v2:
- [6/9] Do not remove last paragraph.

 drivers/input/keyboard/cros_ec_keyb.c | 34 ++-
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/input/keyboard/cros_ec_keyb.c 
b/drivers/input/keyboard/cros_ec_keyb.c
index 79eb29550c34..91b2839c12df 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -1,25 +1,15 @@
-/*
- * ChromeOS EC keyboard driver
- *
- * Copyright (C) 2012 Google, Inc
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * This driver uses the Chrome OS EC byte-level message-based protocol for
- * communicating the keyboard state (which keys are pressed) from a keyboard EC
- * to the AP over some bus (such as i2c, lpc, spi).  The EC does debouncing,
- * but everything else (including deghosting) is done here.  The main
- * motivation for this is to keep the EC firmware as simple as possible, since
- * it cannot be easily upgraded and EC flash/IRAM space is relatively
- * expensive.
- */
+// SPDX-License-Identifier: GPL-2.0+
+// ChromeOS EC keyboard driver
+//
+// Copyright (C) 2012 Google, Inc.
+//
+// This driver uses the ChromeOS EC byte-level message-based protocol for
+// communicating the keyboard state (which keys are pressed) from a keyboard EC
+// to the AP over some bus (such as i2c, lpc, spi).  The EC does debouncing,
+// but everything else (including deghosting) is done here.  The main
+// motivation for this is to keep the EC firmware as simple as possible, since
+// it cannot be easily upgraded and EC flash/IRAM space is relatively
+// expensive.
 
 #include 
 #include 
-- 
2.17.1



Re: [PATCH v5 1/2] mm: memcg: remote memcg charging for kmem allocations

2018-06-05 Thread Shakeel Butt
On Mon, Apr 16, 2018 at 1:51 PM, Shakeel Butt  wrote:
> Introduce the memcg variant for kmalloc[_node] and
> kmem_cache_alloc[_node].  For kmem_cache_alloc, the kernel switches the
> root kmem cache with the memcg specific kmem cache for __GFP_ACCOUNT
> allocations to charge those allocations to the memcg.  However, the memcg
> to charge is extracted from the current task_struct.  This patch
> introduces the variant of kmem cache allocation functions where the memcg
> can be provided explicitly by the caller instead of deducing the memcg
> from the current task.
>
> The kmalloc allocations are underlying served using the kmem caches unless
> the size of the allocation request is larger than KMALLOC_MAX_CACHE_SIZE,
> in which case, the kmem caches are bypassed and the request is routed
> directly to page allocator.  So, for __GFP_ACCOUNT kmalloc allocations,
> the memcg of current task is charged.  This patch introduces memcg variant
> of kmalloc functions to allow callers to provide memcg for charging.
>
> These functions are useful for use-cases where the allocations should be
> charged to the memcg different from the memcg of the caller.  One such
> concrete use-case is the allocations for fsnotify event objects where the
> objects should be charged to the listener instead of the producer.
>
> One requirement to call these functions is that the caller must have the
> reference to the memcg.  Using kmalloc_memcg and kmem_cache_alloc_memcg
> implicitly assumes that the caller is requesting a __GFP_ACCOUNT
> allocation.
>
> Signed-off-by: Shakeel Butt 

I will send the v6 of this patchset after this merge window. In v6, I
will make memalloc_memcg_[save|restore] scope API similar to NOFS,
NOIO and NORECLAIM APIs.

> ---
> Changelog since v4:
> - Removed branch from hot path of memory charging.
>
> Changelog since v3:
> - Added node variant of directed kmem allocation functions.
>
> Changelog since v2:
> - Merge the kmalloc_memcg patch into this patch.
> - Instead of plumbing memcg throughout, use field in task_struct to pass
>   the target_memcg.
>
> Changelog since v1:
> - Fixed build for SLOB
>


[PATCH 26/46] perf test: Use header file util/debug.h

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Thomas Richter 

Use the header file util/debug.h instead of declaration of verbose
variable.

Signed-off-by: Thomas Richter 
Cc: Heiko Carstens 
Cc: Hendrik Brueckner 
Cc: Martin Schwidefsky 
Link: http://lkml.kernel.org/r/20180528134817.36643-1-tmri...@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/python-use.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index 5d2df65ada6a..40ab72149ce1 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -7,8 +7,7 @@
 #include 
 #include 
 #include "tests.h"
-
-extern int verbose;
+#include "util/debug.h"
 
 int test__python_use(struct test *test __maybe_unused, int subtest 
__maybe_unused)
 {
-- 
2.14.3



[PATCH 29/46] perf script: Check if evsel has callchains before trying to use it

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

We were checking just if callchain processing was asked for by the
user, not if the evsel itself has callchains, and since we can have
some evsels with callchains and others without, check that.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-inxl7k49q9f9w1se039fb...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 48e940efb3cb..b3bf35512d21 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -606,7 +606,7 @@ static int perf_sample__fprintf_start(struct perf_sample 
*sample,
if (PRINT_FIELD(COMM)) {
if (latency_format)
printed += fprintf(fp, "%8.8s ", 
thread__comm_str(thread));
-   else if (PRINT_FIELD(IP) && symbol_conf.use_callchain)
+   else if (PRINT_FIELD(IP) && evsel__has_callchain(evsel) && 
symbol_conf.use_callchain)
printed += fprintf(fp, "%s ", thread__comm_str(thread));
else
printed += fprintf(fp, "%16s ", 
thread__comm_str(thread));
-- 
2.14.3



[PATCH 28/46] perf evsel: Add has_callchain() helper to make code more compact/clear

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Its common to have the (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN),
so add an evsel__has_callchain(evsel) helper.

This will actually get more uses as we check that instead of
symbol_conf.use_callchain in places where that produces the same result
but makes this decision to be more fine grained, per evsel.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-145340oytbthatpfeaq1d...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-sched.c  |  3 +--
 tools/perf/builtin-script.c | 10 +++---
 tools/perf/builtin-trace.c  |  2 +-
 tools/perf/tests/parse-events.c |  4 ++--
 tools/perf/util/evsel.c |  4 ++--
 tools/perf/util/evsel.h |  5 +
 tools/perf/util/hist.c  |  2 +-
 tools/perf/util/session.c   |  2 +-
 8 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 4dfdee668b0c..97f9e755e8e6 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -2933,8 +2933,7 @@ static int timehist_check_attr(struct perf_sched *sched,
return -1;
}
 
-   if (sched->show_callchain &&
-   !(evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN)) {
+   if (sched->show_callchain && !evsel__has_callchain(evsel)) {
pr_info("Samples do not have callchains.\n");
sched->show_callchain = 0;
symbol_conf.use_callchain = 0;
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index cefc8813e91e..48e940efb3cb 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -517,7 +517,7 @@ static int perf_session__check_output_opt(struct 
perf_session *session)
 
evlist__for_each_entry(session->evlist, evsel) {
not_pipe = true;
-   if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
+   if (evsel__has_callchain(evsel)) {
use_callchain = true;
break;
}
@@ -532,22 +532,18 @@ static int perf_session__check_output_opt(struct 
perf_session *session)
 */
if (symbol_conf.use_callchain &&
!output[PERF_TYPE_TRACEPOINT].user_set) {
-   struct perf_event_attr *attr;
-
j = PERF_TYPE_TRACEPOINT;
 
evlist__for_each_entry(session->evlist, evsel) {
if (evsel->attr.type != j)
continue;
 
-   attr = >attr;
-
-   if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) {
+   if (evsel__has_callchain(evsel)) {
output[j].fields |= PERF_OUTPUT_IP;
output[j].fields |= PERF_OUTPUT_SYM;
output[j].fields |= PERF_OUTPUT_SYMOFFSET;
output[j].fields |= PERF_OUTPUT_DSO;
-   set_print_ip_opts(attr);
+   set_print_ip_opts(>attr);
goto out;
}
}
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 560aed7da36a..6a748eca2edb 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2491,7 +2491,7 @@ static int trace__run(struct trace *trace, int argc, 
const char **argv)
 * to override an explicitely set --max-stack global setting.
 */
evlist__for_each_entry(evlist, evsel) {
-   if ((evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) &&
+   if (evsel__has_callchain(evsel) &&
evsel->attr.sample_max_stack == 0)
evsel->attr.sample_max_stack = trace->max_stack;
}
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index b9ebe15afb13..7d4077068454 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -499,7 +499,7 @@ static int 
test__checkevent_pmu_partial_time_callgraph(struct perf_evlist *evlis
 * while this test executes only parse events method.
 */
TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period);
-   TEST_ASSERT_VAL("wrong callgraph",  !(PERF_SAMPLE_CALLCHAIN & 
evsel->attr.sample_type));
+   TEST_ASSERT_VAL("wrong callgraph",  !evsel__has_callchain(evsel));
TEST_ASSERT_VAL("wrong time",  !(PERF_SAMPLE_TIME & 
evsel->attr.sample_type));
 
/* cpu/config=2,call-graph=no,time=0,period=2000/ */
@@ -512,7 +512,7 @@ static int 
test__checkevent_pmu_partial_time_callgraph(struct perf_evlist *evlis
 * while this test executes only parse events method.
 */

[PATCH 27/46] perf report: No need to have report_callchain_help as a global

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

It is used in a single place, move the declaration to that function.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-p650ofrl8xike4dewxod5...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-report.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index bc133e7a7ac2..cdb5b6949832 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -946,12 +946,6 @@ parse_percent_limit(const struct option *opt, const char 
*str,
return 0;
 }
 
-#define CALLCHAIN_DEFAULT_OPT  "graph,0.5,caller,function,percent"
-
-const char report_callchain_help[] = "Display call graph (stack 
chain/backtrace):\n\n"
-CALLCHAIN_REPORT_HELP
-"\n\t\t\t\tDefault: " 
CALLCHAIN_DEFAULT_OPT;
-
 int cmd_report(int argc, const char **argv)
 {
struct perf_session *session;
@@ -960,6 +954,10 @@ int cmd_report(int argc, const char **argv)
bool has_br_stack = false;
int branch_mode = -1;
bool branch_call_mode = false;
+#define CALLCHAIN_DEFAULT_OPT  "graph,0.5,caller,function,percent"
+   const char report_callchain_help[] = "Display call graph (stack 
chain/backtrace):\n\n"
+CALLCHAIN_REPORT_HELP
+"\n\t\t\t\tDefault: " 
CALLCHAIN_DEFAULT_OPT;
char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT;
const char * const report_usage[] = {
"perf report []",
-- 
2.14.3



[PATCH 31/46] perf hists: Do not allocate space for callchains for evsels without them

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

This is another case were a big switch for callchains,
symbol_conf.use_callchain, is inconvenient, as we can have both events
with and without callchains, no point in checking a single switch to
decide to allocate space for callchains.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-62q64m7x7kqpb4g7boqc2...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/hist.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 34864c87cd3c..496913eeed75 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -461,14 +461,19 @@ static struct hist_entry *hist_entry__new(struct 
hist_entry *template,
  bool sample_self)
 {
struct hist_entry_ops *ops = template->ops;
+   struct perf_evsel *evsel = hists_to_evsel(template->hists);
size_t callchain_size = 0;
struct hist_entry *he;
int err = 0;
 
if (!ops)
ops = template->ops = _ops;
-
-   if (symbol_conf.use_callchain)
+   /*
+* It is possible to have callchains for some evsels but not for others,
+* e.g.:  'perf record -e cycles,cache-misses/max-stack=10/', so lets
+* not waste space for that.
+*/
+   if (symbol_conf.use_callchain && evsel__has_callchain(evsel))
callchain_size = sizeof(struct callchain_root);
 
he = ops->new(callchain_size);
-- 
2.14.3



[GIT PULL 00/46] perf/core fixes and improvements

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

Hi Ingo,

Please consider pulling,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit 7869e5889477e4e32e4024d665431b35e8b7b693:

  Merge remote-tracking branch 'tip/perf/urgent' into perf/core (2018-06-04 
10:28:20 -0300)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
tags/perf-core-for-mingo-4.18-20180605

for you to fetch changes up to 03ac4e71cd120d2c3411d106d00d266114575f74:

  perf intel-pt: Fix "Unexpected indirect branch" error (2018-06-05 12:28:52 
-0300)


perf/core improvements and fixes:

perf stat:

. Display user and system time for workload targets (Jiri Olsa)

perf record:

. Enable arbitrary event names thru name= modifier (Alexey Budankov)

PowerPC:

. Add a python script for hypervisor call statistics (Ravi Bangoria)

Intel PT: (Adrian Hunter)

. Fix sync_switch INTEL_PT_SS_NOT_TRACING

. Fix decoding to accept CBR between FUP and corresponding TIP

. Fix MTC timing after overflow

. Fix "Unexpected indirect branch" error

perf test:

. record+probe_libc_inet_pton:

  .  To get the symbol table for dynamic
 shared objects on ubuntu we need to pass the -D/--dynamic command line
 option, unlike with the fedora distros (Arnaldo Carvalho de Melo)

. code-reading:

  . Fix perf_env setup for PTI entry trampolines (Adrian Hunter)

. kmod-path:

  . Add tests for vdso32 and vdsox32 (Adrian Hunter)

. Use header file util/debug.h (Thomas Richter)

perf annotate:

. Make the various UI backends (stdio, TUI, gtk) use more consistently
  structs with annotation options as specified by the user (Arnaldo Carvalho de 
Melo)

. Move annotation specific knobs from the symbol_conf global kitchen
  sink to the annotation option structs (Arnaldo Carvalho de Melo)

Core:

. Fix misleading error for some unparsable events mentioning PMUs when
  those are not involved in the problem (Jiri Olsa)

- Fix symbol and object code resolution for vdso32 and vdsox32 (Adrian Hunter)

. No need to check for null when passing pointers to foo__get() style
  refcount grabbing helpers, just like in the kernel and with free(),
  its safe to pass a NULL pointer to avoid having to check it before
  each and every foo__get() call (Arnaldo Carvalho de Melo)

. Remove some dead code (quote.[ch]) (Arnaldo Carvalho de Melo)

. Remove some needless globals, making them local (Arnaldo Carvalho de Melo)

. Reduce usage of symbol_conf.use_callchain, using other means of
  finding out if callchains are in use or available for specific events,
  as we evolved this codebase to allow requesting callchains for just
  a subset of the monitored events. In time it will help polish
  recording and showing mixed sets accross the various tools:

perf record -e 
cycles/call-graph=fp/,cache-misses/call-graph=dwarf/,instructions

  (Arnaldo Carvalho de Melo)

. Consider PTI entry trampolines in map__rip_2objdump() (Adrian Hunter)

Signed-off-by: Arnaldo Carvalho de Melo 


Adrian Hunter (8):
  perf tests kmod-path: Add tests for vdso32 and vdsox32
  perf tools: Fix symbol and object code resolution for vdso32 and vdsox32
  perf test code-reading: Fix perf_env setup for PTI entry trampolines
  perf map: Consider PTI entry trampolines in rip_2objdump()
  perf intel-pt: Fix sync_switch INTEL_PT_SS_NOT_TRACING
  perf intel-pt: Fix decoding to accept CBR between FUP and corresponding 
TIP
  perf intel-pt: Fix MTC timing after overflow
  perf intel-pt: Fix "Unexpected indirect branch" error

Alexey Budankov (1):
  perf record: Enable arbitrary event names thru name= modifier

Arnaldo Carvalho de Melo (33):
  perf tools: Remove dead quote.[ch] code
  perf probe: Use return of map__get() to make code more compact
  perf cgroup: Make evlist__find_cgroup() more compact
  perf tools: No need to check if the argument to __get() function is NULL
  perf annotate: Pass perf_evsel instead of just evsel->idx
  perf annotate: __symbol__acount_cycles doesn't need notes
  perf annotate: Split allocation of annotated_source struct
  perf annotate: Introduce constructor/destructor for annotated_source
  perf annotate: Introduce annotated_source__alloc_histograms
  perf annotate: __symbol__inc_addr_samples() needs just annotated_source
  perf annotate: Introduce symbol__hists()
  perf annotate: Introduce symbol__cycle_hists()
  perf annotate: Stop using symbol_conf.nr_events global in symbol__hists()
  perf annotate: Replace symbol__alloc_hists() with symbol__hists()
  perf tools: Ditch the symbol_conf.nr_events global
  perf annotate: Add comment about annotated_src->nr_histograms
  perf annotate stdio: Use annotation_options consistently
  

[PATCH 07/46] perf annotate: Split allocation of annotated_source struct

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

So that we can allocate just the notes->src->cyc_hist, that, unlike
notes->src->histograms, is not per event, and in paths where we
need to lazily allocate notes->src->cyc_hist we don't have the
number of events handy to also allocate ->histograms.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-tsx7dhxzpi0criyx0sio3...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 10 +++---
 tools/perf/util/annotate.h |  6 +++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index a7221f9fa504..f0c6941bca6c 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -701,13 +701,17 @@ int symbol__alloc_hist(struct symbol *sym)
sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(struct 
sym_hist_entry));
 
/* Check for overflow in zalloc argument */
-   if (sizeof_sym_hist > (SIZE_MAX - sizeof(*notes->src))
-   / symbol_conf.nr_events)
+   if (sizeof_sym_hist > SIZE_MAX / symbol_conf.nr_events)
return -1;
 
-   notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * 
sizeof_sym_hist);
+   notes->src = zalloc(sizeof(*notes->src));
if (notes->src == NULL)
return -1;
+   notes->src->histograms = calloc(symbol_conf.nr_events, sizeof_sym_hist);
+   if (notes->src->histograms == NULL) {
+   zfree(>src);
+   return -1;
+   }
notes->src->sizeof_sym_hist = sizeof_sym_hist;
notes->src->nr_histograms   = symbol_conf.nr_events;
INIT_LIST_HEAD(>src->source);
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index aef9eae4f125..94b60e34c3a7 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -201,7 +201,7 @@ struct cyc_hist {
 
 /** struct annotated_source - symbols with hits have this attached as in 
sannotation
  *
- * @histogram: Array of addr hit histograms per event being monitored
+ * @histograms: Array of addr hit histograms per event being monitored
  * @lines: If 'print_lines' is specified, per source code line percentages
  * @source: source parsed from a disassembler like objdump -dS
  * @cyc_hist: Average cycles per basic block
@@ -217,7 +217,7 @@ struct annotated_source {
intnr_histograms;
size_t sizeof_sym_hist;
struct cyc_hist*cycles_hist;
-   struct sym_histhistograms[0];
+   struct sym_hist*histograms;
 };
 
 struct annotation {
@@ -269,7 +269,7 @@ void annotation__init_column_widths(struct annotation 
*notes, struct symbol *sym
 
 static inline struct sym_hist *annotation__histogram(struct annotation *notes, 
int idx)
 {
-   return (((void *)>src->histograms) +
+   return (((void *)notes->src->histograms) +
(notes->src->sizeof_sym_hist * idx));
 }
 
-- 
2.14.3



[PATCH 09/46] perf annotate: Introduce annotated_source__alloc_histograms

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

So that we can call it independently, in contexts were we know we
already have notes->src allocated.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-f5fn7tr1asey6g013wavp...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index f6c9bb29ac84..a6fa49bf879b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -697,10 +697,9 @@ static void annotated_source__delete(struct 
annotated_source *src)
free(src);
 }
 
-int symbol__alloc_hist(struct symbol *sym)
+static int annotated_source__alloc_histograms(struct annotated_source *src,
+ size_t size, int nr_hists)
 {
-   struct annotation *notes = symbol__annotation(sym);
-   size_t size = symbol__size(sym);
size_t sizeof_sym_hist;
 
/*
@@ -720,20 +719,29 @@ int symbol__alloc_hist(struct symbol *sym)
sizeof_sym_hist = (sizeof(struct sym_hist) + size * sizeof(struct 
sym_hist_entry));
 
/* Check for overflow in zalloc argument */
-   if (sizeof_sym_hist > SIZE_MAX / symbol_conf.nr_events)
+   if (sizeof_sym_hist > SIZE_MAX / nr_hists)
return -1;
 
+   src->sizeof_sym_hist = sizeof_sym_hist;
+   src->nr_histograms   = nr_hists;
+   src->histograms  = calloc(nr_hists, sizeof_sym_hist) ;
+   return src->histograms ? 0 : -1;
+}
+
+int symbol__alloc_hist(struct symbol *sym)
+{
+   size_t size = symbol__size(sym);
+   struct annotation *notes = symbol__annotation(sym);
+
notes->src = annotated_source__new();
if (notes->src == NULL)
return -1;
-   notes->src->histograms = calloc(symbol_conf.nr_events, sizeof_sym_hist);
-   if (notes->src->histograms == NULL) {
+
+   if (annotated_source__alloc_histograms(notes->src, size, 
symbol_conf.nr_events) < 0) {
annotated_source__delete(notes->src);
notes->src = NULL;
return -1;
}
-   notes->src->sizeof_sym_hist = sizeof_sym_hist;
-   notes->src->nr_histograms   = symbol_conf.nr_events;
return 0;
 }
 
-- 
2.14.3



[PATCH 03/46] perf cgroup: Make evlist__find_cgroup() more compact

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

By taking advantage that __get() routines return the pointer to the
object for which a reference count is being get.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Stephane Eranian 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-xnvd07rdxliy04oi062sa...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/cgroup.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index decb91f9da82..ccd02634a616 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -93,20 +93,17 @@ static int open_cgroup(const char *name)
 static struct cgroup *evlist__find_cgroup(struct perf_evlist *evlist, const 
char *str)
 {
struct perf_evsel *counter;
-   struct cgroup *cgrp = NULL;
/*
 * check if cgrp is already defined, if so we reuse it
 */
evlist__for_each_entry(evlist, counter) {
if (!counter->cgrp)
continue;
-   if (!strcmp(counter->cgrp->name, str)) {
-   cgrp = cgroup__get(counter->cgrp);
-   break;
-   }
+   if (!strcmp(counter->cgrp->name, str))
+   return cgroup__get(counter->cgrp);
}
 
-   return cgrp;
+   return NULL;
 }
 
 static struct cgroup *cgroup__new(const char *name)
-- 
2.14.3



[PATCH 06/46] perf annotate: __symbol__acount_cycles doesn't need notes

2018-06-05 Thread Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo 

It only operates on the notes->src->cyc_hist, just pass that to it.

Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-zd1cu4zwmu21k0cxlr83y...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 0f5ed6091e00..a7221f9fa504 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -741,14 +741,11 @@ void symbol__annotate_zero_histograms(struct symbol *sym)
pthread_mutex_unlock(>lock);
 }
 
-static int __symbol__account_cycles(struct annotation *notes,
+static int __symbol__account_cycles(struct cyc_hist *ch,
u64 start,
unsigned offset, unsigned cycles,
unsigned have_start)
 {
-   struct cyc_hist *ch;
-
-   ch = notes->src->cycles_hist;
/*
 * For now we can only account one basic block per
 * final jump. But multiple could be overlapping.
@@ -870,7 +867,7 @@ static int symbol__account_cycles(u64 addr, u64 start,
start = 0;
}
offset = addr - sym->start;
-   return __symbol__account_cycles(notes,
+   return __symbol__account_cycles(notes->src->cycles_hist,
start ? start - sym->start : 0,
offset, cycles,
!!start);
-- 
2.14.3



Re: [PATCH v2 5/8] Input: cros_ec_keyb - Switch to SPDX identifier.

2018-06-05 Thread Enric Balletbo i Serra
Hi Fabio,

On 05/06/18 20:04, Fabio Estevam wrote:
> Hi Enric,
> 
> On Tue, Jun 5, 2018 at 2:54 PM, Enric Balletbo i Serra
>  wrote:
>> Adopt the SPDX license identifier headers to ease license compliance
>> management.
>>
>> Signed-off-by: Enric Balletbo i Serra 
>> ---
>>
>> Changes in v2:
>> - [6/9] Do not remove last paragraph.
>>
>>  drivers/input/keyboard/cros_ec_keyb.c | 34 ++-
>>  1 file changed, 12 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/input/keyboard/cros_ec_keyb.c 
>> b/drivers/input/keyboard/cros_ec_keyb.c
>> index 79eb29550c34..91b2839c12df 100644
>> --- a/drivers/input/keyboard/cros_ec_keyb.c
>> +++ b/drivers/input/keyboard/cros_ec_keyb.c
>> @@ -1,25 +1,15 @@
>> -/*
>> - * ChromeOS EC keyboard driver
>> - *
>> - * Copyright (C) 2012 Google, Inc
>> - *
>> - * This software is licensed under the terms of the GNU General Public
>> - * License version 2, as published by the Free Software Foundation, and
> 
> Original text says GPL-2.0...
> 
>> - * may be copied, distributed, and modified under those terms.
>> - *
>> - * This program is distributed in the hope that it will be useful,
>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> - * GNU General Public License for more details.
>> - *
>> - * This driver uses the Chrome OS EC byte-level message-based protocol for
>> - * communicating the keyboard state (which keys are pressed) from a 
>> keyboard EC
>> - * to the AP over some bus (such as i2c, lpc, spi).  The EC does debouncing,
>> - * but everything else (including deghosting) is done here.  The main
>> - * motivation for this is to keep the EC firmware as simple as possible, 
>> since
>> - * it cannot be easily upgraded and EC flash/IRAM space is relatively
>> - * expensive.
>> - */
>> +// SPDX-License-Identifier: GPL-2.0+
> 
> but here you add a GPL-2.0+ type.
> 

Right, but the module license is set to GPL which means GNU Public License v2 or
later, see [1]. So, there is a mismatch. In such cases I assumed GPL-2.0+ as the
default. These mismatches are common so I think that should be fine for the
authors, if someone is disagree just let me know and I will change.

Best regards,
 Enric

[1]
https://elixir.bootlin.com/linux/v4.17/source/drivers/input/keyboard/cros_ec_keyb.c#L677


[GIT PULL] Security subsystem: general updates for v4.18

2018-06-05 Thread James Morris
Please pull these general security subsystem updates for v4.18.

Summary:

- Incorporate new socketpair() hook into LSM and wire up the SELinux and 
  Smack modules.  From David Herrmann:

   "The idea is to allow SO_PEERSEC to be called on AF_UNIX sockets 
created via socketpair(2), and return the same information as if you 
emulated socketpair(2) via a temporary listener socket. Right now 
SO_PEERSEC will return the unlabeled credentials for a socketpair, 
rather than the actual credentials of the creating process."

- Sargun Dhillon removed the unused security_settime LSM hook.

- Tycho Andersen removed some stack allocated arrays from the keys code.

---

The following changes since commit 6da6c0db5316275015e8cc2959f12a17584aeb64:

  Linux v4.17-rc3 (2018-04-29 14:17:42 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git 
next-general

for you to fetch changes up to 890e2abe1028c39e5399101a2c277219cd637aaa:

  dh key: get rid of stack allocated array for zeroes (2018-05-11 13:07:49 
-0700)


David Herrmann (3):
  security: add hook for socketpair()
  net: hook socketpair() into LSM
  selinux: provide socketpair callback

James Morris (2):
  Merge tag 'v4.17-rc2' into next-general
  Merge tag 'v4.17-rc3' into next-general

Sargun Dhillon (1):
  security: remove security_settime

Tom Gundersen (1):
  smack: provide socketpair callback

Tycho Andersen (3):
  big key: get rid of stack array allocation
  dh key: get rid of stack allocated array
  dh key: get rid of stack allocated array for zeroes

 include/linux/lsm_hooks.h  |  7 +++
 include/linux/security.h   | 21 +++--
 net/socket.c   |  7 +++
 security/keys/big_key.c| 11 ++-
 security/keys/dh.c | 35 +--
 security/security.c|  6 ++
 security/selinux/hooks.c   | 13 +
 security/smack/smack_lsm.c | 22 ++
 8 files changed, 85 insertions(+), 37 deletions(-)


Re: [PATCH v2 5/8] Input: cros_ec_keyb - Switch to SPDX identifier.

2018-06-05 Thread Dmitry Torokhov
On Tue, Jun 05, 2018 at 08:45:44PM +0200, Enric Balletbo i Serra wrote:
> Hi Dmitry,
> 
> On 05/06/18 20:29, Dmitry Torokhov wrote:
> > On Tue, Jun 05, 2018 at 03:16:40PM -0300, Fabio Estevam wrote:
> >> Hi Enric,
> >>
> >> On Tue, Jun 5, 2018 at 3:14 PM, Enric Balletbo i Serra
> >>  wrote:
> >>
> >>> Right, but the module license is set to GPL which means GNU Public 
> >>> License v2 or
> >>> later, see [1]. So, there is a mismatch. In such cases I assumed GPL-2.0+ 
> >>> as the
> >>> default. These mismatches are common so I think that should be fine for 
> >>> the
> >>> authors, if someone is disagree just let me know and I will change.
> >>
> >> Ok, but I think you should add this explanation in the commit log to
> >> make it clearer.
> > 
> > If there is a conflict between the license notice and MODULE_LICENSE()
> > we should go by the license notice. The license note is usually approved
> > by companies, whereas MIODULE_LICENSE()s get moved, adjusted, etc.
> > 
> > For ChromeOS kernel changes license notice is GPL v2 as documented at:
> > 
> > https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/kernel-faq
> > 
> > section "Which copyright header should I use?"
> > 
> 
> Many thanks to share and clarify this.
> 
> There is lots of mismatches so I'll send another version fixing this and
> changing all to GPL v2. I assume I should also modify the MODULE_LICENSE when
> it's wrong.

I'd have a round of changes having MODULE_LICENSE() match the license
notice, and then separate patches for changing over to SPDX tags.

Thanks.

-- 
Dmitry


Re: [PATCH v2] drivers: base: cacheinfo: use OF property_read_u32 instead of get_property,read_number

2018-06-05 Thread Sudeep Holla



On 05/06/18 17:21, Andy Shevchenko wrote:
> On Mon, May 21, 2018 at 3:53 PM, Sudeep Holla  wrote:
>> of_property_read_u32 searches for a property in a device node and read
>> a 32-bit value from it. Instead of using of_get_property to get the
>> property and then read 32-bit value using of_read_number, we can
>> simplify it by using of_property_read_u32.
>>
> 
> LGTM.
> Thanks!
> 

Thanks, can I take is Ack ?

Anyways it's too late for v4.18, will repost after the merge window for
v4.19 with your Ack if you agree.

-- 
Regards,
Sudeep


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