[PATCH v4] perf record: encode -k clockid frequency into Perf trace

2018-10-08 Thread Alexey Budankov


Store -k clockid frequency into Perf trace to enable timestamps 
derived metrics conversion into wall clock time on reporting stage.

Below is the example of perf report output:

tools/perf/perf record -k raw -- ../../matrix/linux/matrix.gcc
...
[ perf record: Captured and wrote 31.222 MB perf.data (818054 samples) ]

tools/perf/perf report --header
# 
...
# event : name = cycles:ppp, , size = 112, { sample_period, sample_freq } = 
4000, sample_type = IP|TID|TIME|PERIOD, disabled = 1, inherit = 1, mmap = 1, 
comm = 1, freq = 1, enable_on_exec = 1, task = 1, precise_ip = 3, sample_id_all 
= 1, exclude_guest = 1, mmap2 = 1, comm_exec = 1, use_clockid = 1, clockid = 4
...
# clockid frequency: 1000 MHz
...
# 

Signed-off-by: Alexey Budankov 
---
Changes in v4:
 - addressed compilation issues on 32bit platforms
Changes in v3:
 - moved header's clockid_res_ns initialization out of record__init_features()
 - added explicit warning for case of failed clock_getres() call
Changes in v2:
 - renamed clockid_freq to clockid_res_ns and get_clockid_freq() to 
get_clockid_res()
 - avoided redundant define of NSEC_IN_SEC, reused linux/time64.h:NSEC_PER_SEC
 - moved MHz conversion into print_clockid() and shortened write_clockid()
---
 tools/perf/builtin-record.c | 24 ++--
 tools/perf/perf.h   |  1 +
 tools/perf/util/env.h   |  1 +
 tools/perf/util/header.c| 28 
 tools/perf/util/header.h|  1 +
 5 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 0980dfe3396b..d803d3264465 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -592,6 +592,9 @@ static void record__init_features(struct record *rec)
if (!rec->opts.full_auxtrace)
perf_header__clear_feat(&session->header, HEADER_AUXTRACE);
 
+   if (!(rec->opts.use_clockid && rec->opts.clockid_res_ns))
+   perf_header__clear_feat(&session->header, HEADER_CLOCKID);
+
perf_header__clear_feat(&session->header, HEADER_STAT);
 }
 
@@ -897,6 +900,9 @@ static int __cmd_record(struct record *rec, int argc, const 
char **argv)
 
record__init_features(rec);
 
+   if (rec->opts.use_clockid && rec->opts.clockid_res_ns)
+   session->header.env.clockid_res_ns = rec->opts.clockid_res_ns;
+
if (forks) {
err = perf_evlist__prepare_workload(rec->evlist, &opts->target,
argv, data->is_pipe,
@@ -1337,6 +1343,19 @@ static const struct clockid_map clockids[] = {
CLOCKID_END,
 };
 
+static int get_clockid_res(clockid_t clk_id, size_t *res_ns)
+{
+   struct timespec res;
+
+   *res_ns = 0;
+   if (!clock_getres(clk_id, &res))
+   *res_ns = res.tv_nsec + res.tv_sec * NSEC_PER_SEC;
+   else
+   pr_warning("WARNING: Failed to determine specified clock 
resolution.\n");
+
+   return 0;
+}
+
 static int parse_clockid(const struct option *opt, const char *str, int unset)
 {
struct record_opts *opts = (struct record_opts *)opt->value;
@@ -1360,7 +1379,7 @@ static int parse_clockid(const struct option *opt, const 
char *str, int unset)
 
/* if its a number, we're done */
if (sscanf(str, "%d", &opts->clockid) == 1)
-   return 0;
+   return get_clockid_res(opts->clockid, &opts->clockid_res_ns);
 
/* allow a "CLOCK_" prefix to the name */
if (!strncasecmp(str, "CLOCK_", 6))
@@ -1369,7 +1388,8 @@ static int parse_clockid(const struct option *opt, const 
char *str, int unset)
for (cm = clockids; cm->name; cm++) {
if (!strcasecmp(str, cm->name)) {
opts->clockid = cm->clockid;
-   return 0;
+   return get_clockid_res(opts->clockid,
+  &opts->clockid_res_ns);
}
}
 
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 21bf7f5a3cf5..981db3c2ed60 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -81,6 +81,7 @@ struct record_opts {
unsigned initial_delay;
bool use_clockid;
clockid_tclockid;
+   size_t   clockid_res_ns;
unsigned int proc_map_timeout;
 };
 
diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h
index 1f3ccc368530..b167a54d635f 100644
--- a/tools/perf/util/env.h
+++ b/tools/perf/util/env.h
@@ -63,6 +63,7 @@ struct perf_env {
struct numa_node*numa_nodes;
struct memory_node  *memory_nodes;
unsigned long long   memory_bsize;
+   size_t   clockid_res_ns;
 };
 
 extern struct perf_env perf_env;
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 1ec1d9bc2d63..702e0cce63da 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1034,6 +1034,14 @@ static int 

Re: [PATCH 4.9 069/101] ubi: fastmap: Correctly handle interrupted erasures in EBA

2018-10-08 Thread Lars Persson
On Mon, Sep 24, 2018 at 8:32 AM Richard Weinberger  wrote:
>
> Lars,
>
> Am Sonntag, 23. September 2018, 15:49:42 CEST schrieb Lars Persson:
> > Hi Richard
> >
> > Sorry, I assumed this omission from -stable was a mistake.
> >
> > The timing for our boot increased from 45 seconds to 55 seconds on one
> > chip and 42 seconds to 48 seconds on another chip. The regression was
> > completely fixed by applying the extra patches. The way I see it the
> > first patch is a significant slow-down so the second patch is required
> > to restore performance.
>
> okay, this is not good. Let's put the performance patch also into -stable
> to get rid of that regression.
> Usually I'm rather conservative with adding non-trivial material to -stable.
> As history has shown, Fastmap is special. ;-)
>
> Out of interest, what flashes are these? I'm interested in page vs. erase 
> size.
> Did you give UBIFS bulk-read try?
>

Richard, sorry for the late follow-up. Below are the NAND chips that
we use on the affected products.
The products have different NAND timings, some ONFI mode 0 and some
ONFI mode 2, so not lightning fast access to the NAND.

nand: Toshiba NAND 256MiB 3,3V 8-bit
nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 128

nand: Micron MT29F2G08ABAFA 2G 3.3V 8-bit
nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 128

nand: AMD/Spansion S34ML04G2
nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 128

- Lars


Re: [PATCH] mfd: arizona: Correct link for sound binding document

2018-10-08 Thread Lee Jones
On Fri, 28 Sep 2018, Rob Herring wrote:

> On Fri, Sep 28, 2018 at 12:46 AM Lee Jones  wrote:
> >
> > On Wed, 26 Sep 2018, Rob Herring wrote:
> >
> > > On Mon, Sep 17, 2018 at 04:33:22PM +0100, Charles Keepax wrote:
> > > > Signed-off-by: Charles Keepax 
> > > > ---
> > > >  Documentation/devicetree/bindings/mfd/arizona.txt | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > Applied.
> >
> > Probably won't do any harm in this instance, but it's usually better
> > for MFD binding changes to go through the MFD tree to avoid
> > merge-conflicts.
> 
> It had been sitting there for a while, so I picked it up. Plus if we

A little over a week is not 'a while'. :)

> have conflicts within a binding (other than tree wide clean ups I do),
> that's not a good sign that the binding is changing.

Not sure I understand this.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


[PATCH v2 1/3] namei: implement O_BENEATH-style AT_* flags

2018-10-08 Thread Aleksa Sarai
Add the following flags to allow various restrictions on path
resolution (these affect the *entire* resolution, rather than just the
final path component -- as is the case with most other AT_* flags).

The primary justification for these flags is to allow for programs to be
far more strict about how they want path resolution to handle symlinks,
mountpoint crossings, and paths that escape the dirfd (through an
absolute path or ".." shenanigans).

This is of particular concern to container runtimes that want to be very
careful about malicious root filesystems that a container's init might
have screwed around with (and there is no real way to protect against
this in userspace if you consider potential races against a malicious
container's init). More classical applications (which have their own
potentially buggy userspace path sanitisation code) include web
servers, archive extraction tools, network file servers, and so on.

* AT_XDEV: Disallow mount-point crossing (both *down* into one, or *up*
  from one). The primary "scoping" use is to blocking resolution that
  crosses a bind-mount, which has a similar property to a symlink (in
  the way that it allows for escape from the starting-point). Since it
  is not possible to differentiate bind-mounts However since
  bind-mounting requires privileges (in ways symlinks don't) this has
  been split from LOOKUP_BENEATH. The naming is based on "find -xdev"
  (though find(1) doesn't walk upwards, the semantics seem obvious).

* AT_NO_PROCLINK: Disallows ->get_link "symlink" jumping. This is a very
  specific restriction, and it exists because /proc/$pid/fd/...
  "symlinks" allow for access outside nd->root and pose risk to
  container runtimes that don't want to be tricked into accessing a host
  path (but do want to allow no-funny-business symlink resolution).

* AT_NO_SYMLINK: Disallows symlink jumping *of any kind*. Implies
  AT_NO_PROCLINK (obviously).

* AT_BENEATH: Disallow "escapes" from the starting point of the
  filesystem tree during resolution (you must stay "beneath" the
  starting point at all times). Currently this is done by disallowing
  ".." and absolute paths (either in the given path or found during
  symlink resolution) entirely, as well as all "proclink" jumping.

  The wholesale banning of ".." is because it is currently not safe to
  allow ".." resolution (races can cause the path to be moved outside of
  the root -- this is conceptually similar to historical chroot(2)
  escape attacks). Future patches in this series will address this, and
  will re-enable ".." resolution once it is safe. With those patches,
  ".." resolution will only be allowed if it remains in the root
  throughout resolution (such as "a/../b" not "a/../../outside/b").

  The banning of "proclink" jumping is done because it is not clear
  whether semantically they should be allowed -- while some "proclinks"
  are safe there are many that can cause escapes (and once a resolution
  is outside of the root, AT_BENEATH will no longer detect it). Future
  patches may re-enable "proclink" jumping when such jumps would remain
  inside the root.

The AT_NO_*LINK flags return -ELOOP if path resolution would violates
their requirement, while the others all return -EXDEV. Currently these
are only enabled for openat(2) (which has its own brand of O_* flags
with the same semantics). However the AT_* flags have been reserved for
future support in other *at(2) syscalls (though because of AT_EMPTY_PATH
many *at(2) operations will not need to support these flags directly).

This is a refresh of Al's AT_NO_JUMPS patchset[1] (which was a variation
on David Drysdale's O_BENEATH patchset[2], which in turn was based on
the Capsicum project[3]). Input from Linus and Andy in the AT_NO_JUMPS
thread[4] determined most of the API changes made in this refresh.

[1]: https://lwn.net/Articles/721443/
[2]: https://lwn.net/Articles/619151/
[3]: https://lwn.net/Articles/603929/
[4]: https://lwn.net/Articles/723057/

Cc: Eric Biederman 
Cc: Christian Brauner 
Suggested-by: David Drysdale 
Suggested-by: Al Viro 
Suggested-by: Andy Lutomirski 
Suggested-by: Linus Torvalds 
Signed-off-by: Aleksa Sarai 
---
 fs/fcntl.c   |   2 +-
 fs/namei.c   | 174 ++-
 fs/open.c|   8 ++
 fs/stat.c|   4 +-
 include/linux/fcntl.h|   3 +-
 include/linux/namei.h|   7 ++
 include/uapi/asm-generic/fcntl.h |  17 +++
 include/uapi/linux/fcntl.h   |   8 ++
 8 files changed, 167 insertions(+), 56 deletions(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 4137d96534a6..e343618736f7 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -1031,7 +1031,7 @@ static int __init fcntl_init(void)
 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
 * is defined as O_NONBLOCK on some platforms and not on others.
 */
-   BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ !=
+  

[PATCH v2 0/3] namei: implement various lookup restriction AT_* flags

2018-10-08 Thread Aleksa Sarai
The need for some sort of control over VFS's path resolution (to avoid
malicious paths resulting in inadvertent breakouts) has been a very
long-standing desire of many userspace applications. This patchset is a
revival of Al Viro's old AT_NO_JUMPS[1,2] patchset (which was a variant
of David Drysdale's O_BENEATH patchset[3] which was a spin-off of the
Capsicum project[4]) with a few additions and changes made based on the
previous discussion within [5] as well as others I felt were useful.

As per the discussion in the AT_NO_JUMPS thread, AT_NO_JUMPS has been
split into separate flags.

  * AT_XDEV blocks mountpoint crossings (both upwards and downwards).
  openat("/", "tmp", AT_XDEV); // blocked
  openat("/tmp", "..", AT_XDEV); // blocked
  openat("/tmp", "/", AT_XDEV); // blocked

  * AT_NO_PROCLINKS blocks all resolution through /proc/$pid/fd/$fd
"symlinks". Specifically, this blocks all jumps caused by a
filesystem using nd_jump_link() to shove you around in the
filesystem tree (these are referred to as "proclinks" in lieu of a
better name).
  openat(AT_FDCWD, "/proc/self/root", AT_NO_PROCLINKS); // blocked
  openat(AT_FDCWD, "/proc/self/fd/0", AT_NO_PROCLINKS); // blocked
  openat(AT_FDCWD, "/proc/self/ns/mnt", AT_NO_PROCLINKS); // blocked

  * AT_BENEATH disallows escapes from the starting dirfd using ".." or
absolute paths (either in the path or during symlink resolution).
Conceptually this flag ensures that you "stay below" the starting
point in the filesystem tree. ".." resolution is allowed if it
doesn't land you outside of the starting point (this is made safe
against races by patch 3 in this series).
  openat("/root", "foo", AT_BENEATH); // *not* blocked
  openat("/root", "a/../b", AT_BENEATH); // *not* blocked
  openat("/root", "a/../../root/b", AT_BENEATH); // blocked
  openat("/root", "/root", AT_BENEATH); // blocked

AT_BENEATH also currently disallows all "proclink" resolution
because they can trivially throw you outside of the starting point.
In a future patch we might allow such resolution (as long as it
stays within the root).
  openat("/", "proc/self/exe", AT_BENEATH); // blocked

In addition, two more flags have been added to the series:

  * AT_NO_SYMLINKS disallows *all* symlink resolution, and thus implies
AT_NO_PROCLINKS. Linus mentioned this is something that git would
like to have in the original discussion[5].
  // assuming 'ln -s / /usr'
  openat("/", "/usr/bin", AT_NO_SYMLINKS); // blocked
  openat("/", "/proc/self/root", AT_NO_PROCLINKS); // blocked

  * AT_THIS_ROOT is a very similar idea to AT_BENEATH, but it serves a
very different purpose. Rather than blocking resolutions if they
would go outside of the starting point, it treats the starting point
as a form of chroot(2). Container runtimes are one of the primary
justifications for this flag, as they currently have to implement
this sort of path handling racily in userspace[6].

The restrictions on "proclink" resolution are the same as with
AT_BENEATH (though in AT_THIS_ROOT's case it's not really clear how
"proclink" jumps outside of the root should be handled), and patch 3
in this series was also required to make ".." resolution safe.

Currently all of these flags are only enabled for openat(2) (and thus
have their own O_* flag names), but the corresponding AT_* flags have
been reserved so they can be added to syscalls where openat(O_PATH) is
not sufficient.

Patch changelog:
  v2:
* Made ".." resolution with AT_THIS_ROOT and AT_BENEATH safe(r) with
  some semi-aggressive __d_path checking (see patch 3).
* Disallowed "proclinks" with AT_THIS_ROOT and AT_BENEATH, in the
  hopes they can be re-enabled once safe.
* Removed the selftests as they will be reimplemented as xfstests.
* Removed stat(2) support, since you can already get it through
  O_PATH and fstatat(2).

[1]: https://lwn.net/Articles/721443/
[2]: https://lore.kernel.org/patchwork/patch/784221/
[3]: https://lwn.net/Articles/619151/
[4]: https://lwn.net/Articles/603929/
[5]: https://lwn.net/Articles/723057/
[6]: https://github.com/cyphar/filepath-securejoin

Cc: Al Viro 
Cc: Eric Biederman 
Cc: Andy Lutomirski 
Cc: David Howells 
Cc: Jann Horn 
Cc: Christian Brauner 
Cc: David Drysdale 
Cc: 
Cc: 
Cc: 

Aleksa Sarai (3):
  namei: implement O_BENEATH-style AT_* flags
  namei: implement AT_THIS_ROOT chroot-like path resolution
  namei: aggressively check for nd->root escape on ".." resolution

 fs/fcntl.c   |   2 +-
 fs/namei.c   | 241 +++
 fs/open.c|  10 ++
 fs/stat.c|   4 +-
 include/linux/fcntl.h|   3 +-
 includ

[PATCH v2 0/3] namei: implement various lookup restriction AT_* flags

2018-10-08 Thread Aleksa Sarai
The need for some sort of control over VFS's path resolution (to avoid
malicious paths resulting in inadvertent breakouts) has been a very
long-standing desire of many userspace applications. This patchset is a
revival of Al Viro's old AT_NO_JUMPS[1,2] patchset (which was a variant
of David Drysdale's O_BENEATH patchset[3] which was a spin-off of the
capsicum patchset[4]) with a few additions and changes made based on the
previous discussion within [5] as well as others I felt were useful.

As per the discussion in the AT_NO_JUMPS thread, AT_NO_JUMPS has been
split into separate flags.

  * AT_XDEV blocks mountpoint crossings (both upwards and downwards).
  openat("/", "tmp", AT_XDEV); // blocked
  openat("/tmp", "..", AT_XDEV); // blocked
  openat("/tmp", "/", AT_XDEV); // blocked

  * AT_NO_PROCLINKS blocks all resolution through /proc/$pid/fd/$fd
"symlinks". Specifically, this blocks all jumps caused by a
filesystem using nd_jump_link() to shove you around in the
filesystem tree (these are referred to as "proclinks" in lieu of a
better name).

  * AT_BENEATH disallows escapes from the starting dirfd using ".." or
absolute paths (either in the path or during symlink resolution).
Conceptually this flag ensures that you "stay below" the starting
point in the filesystem tree. ".." resolution is allowed if it
doesn't land you outside of the starting point (this is made safe
against races by patch 3 in this series).

AT_BENEATH also currently disallows all "proclink" resolution
because they can trivially throw you outside of the starting point.
In a future patch we might allow such resolution (as long as it
stays within the root).

In addition, two more flags have been added to the series:

  * AT_NO_SYMLINKS disallows *all* symlink resolution, and thus implies
AT_NO_PROCLINKS. Linus mentioned this is something that git would
like to have in the original discussion[5].

  * AT_THIS_ROOT is a very similar idea to AT_BENEATH, but it serves a
very different purpose. Rather than blocking resolutions if they
would go outside of the starting point, it treats the starting point
as a form of chroot(2). Container runtimes are one of the primary
justifications for this flag, as they currently have to implement
this sort of path handling racily in userspace[6].

The restrictions on "proclink" resolution are the same as with
AT_BENEATH (though in AT_THIS_ROOT's case it's not really clear how
"proclink" jumps outside of the root should be handled), and patch 3
in this series was also required to make ".." resolution safe.

Patch changelog:
  v2:
* Made ".." resolution with AT_THIS_ROOT and AT_BENEATH safe by
  through __d_path checking (see patch 3).
* Disallowed "proclinks" with AT_THIS_ROOT and AT_BENEATH, in the
  hopes they can be re-enabled once safe.
* Removed the selftests as they will be reimplemented as xfstests.

[1]: https://lwn.net/Articles/721443/
[2]: https://lore.kernel.org/patchwork/patch/784221/
[3]: https://lwn.net/Articles/619151/
[4]: https://lwn.net/Articles/603929/
[5]: https://lwn.net/Articles/723057/
[6]: https://github.com/cyphar/filepath-securejoin

Aleksa Sarai (3):
  namei: implement O_BENEATH-style AT_* flags
  namei: implement AT_THIS_ROOT chroot-like path resolution
  namei: aggressively check nd->root on ".." resolution

 fs/fcntl.c   |   2 +-
 fs/namei.c   | 192 ++-
 fs/open.c|  10 ++
 fs/stat.c|   4 +-
 include/linux/fcntl.h|   3 +-
 include/linux/namei.h|   8 ++
 include/uapi/asm-generic/fcntl.h |  20 
 include/uapi/linux/fcntl.h   |  10 ++
 8 files changed, 193 insertions(+), 56 deletions(-)

-- 
2.19.0



linux-next: manual merge of the akpm tree with the s390 tree

2018-10-08 Thread Stephen Rothwell
Hi Andrew,

Today's linux-next merge of the akpm-current tree got a conflict in:

  arch/s390/kernel/setup.c

between commit:

  b45248da1a33 ("s390: unify stack size definitions")
  ee46f78659ac ("s390: add support for virtually mapped kernel stacks")

from the s390 tree and commit:

  ab9c2b8deb1b ("memblock: remove _virt from APIs returning virtual address")

from the akpm 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.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/s390/kernel/setup.c
index 2a20e6ef8369,2e29456ca11e..
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@@ -418,12 -357,8 +418,12 @@@ static void __init setup_lowcore(void
lc->last_update_timer = S390_lowcore.last_update_timer;
lc->last_update_clock = S390_lowcore.last_update_clock;
  
 -  restart_stack = memblock_alloc(ASYNC_SIZE, ASYNC_SIZE);
 -  restart_stack += ASYNC_SIZE;
 +  /*
 +   * Allocate the global restart stack which is the same for
 +   * all CPUs in cast *one* of them does a PSW restart.
 +   */
-   restart_stack = memblock_virt_alloc(THREAD_SIZE, THREAD_SIZE);
++  restart_stack = memblock_alloc(THREAD_SIZE, THREAD_SIZE);
 +  restart_stack += STACK_INIT_OFFSET;
  
/*
 * Set up PSW restart to call ipl.c:do_restart(). Copy the relevant


pgpUZU3jUmGj7.pgp
Description: OpenPGP digital signature


[PATCH RESEND v3 0/3] drivers/qcom: add additional functionality to RPMH

2018-10-08 Thread Raju P.L.S.S.S.N
Resend:
 - removed unnecessary new line in patch 3. sorry for resend

Changes in v3:
 - Simplify TCS locking - added a new patch
 - Add lock check to avoid potential race as suggested by Matthias
 - Add functionality to RSC controller to disallow active requests
   if solver mode is not set 
 - Removed independent patches and posted as separate series[2]

Changes in v2:
 - Remove unnecessary EXPORT_SYMBOL in rpmh-rsc

This set of patches add additional functionality to RPMH drivers[1].

PM drivers can choose to disallow idle modes when RSC controller is busy
sending or processing requests. The patches add necessary functions to
query the controller status.

The controllers may be in 'solver' state, where they could be in autonomous
mode executing low power modes for their hardware and as such are not
available for sending active votes. Functionality to get notified about
such state and disallow requests for state change in that case is added
in these patches.

Please consider reviewing this patchset.

This series is based on other patchset[2] 


v1:https://lkml.org/lkml/2018/7/19/213
v2:https://patchwork.kernel.org/cover/10546863/



[1] https://lkml.org/lkml/2018/6/20/519
[2] https://lkml.org/lkml/2018/10/3/422


Lina Iyer (2):
  drivers: qcom: rpmh-rsc: return if the controller is idle
  drivers: qcom: rpmh: disallow active requests in solver mode

Raju P.L.S.S.S.N (1):
  drivers: qcom: rpmh-rsc: simplify TCS locking

 drivers/soc/qcom/rpmh-internal.h |  8 +++-
 drivers/soc/qcom/rpmh-rsc.c  | 91 +---
 drivers/soc/qcom/rpmh.c  | 84 +++--
 include/soc/qcom/rpmh.h  | 10 +
 4 files changed, 155 insertions(+), 38 deletions(-)

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of the Code Aurora Forum, hosted by The Linux Foundation.



[PATCH RESEND v3 2/3] drivers: qcom: rpmh-rsc: return if the controller is idle

2018-10-08 Thread Raju P.L.S.S.S.N
From: Lina Iyer 

Allow the controller status be queried. The controller is busy if it is
actively processing request. Also allow the controller state be read by
platform drivers. This is useful for PM drivers which can choose to
disallow idle modes when the controller is busy.

Signed-off-by: Lina Iyer 
Signed-off-by: Raju P.L.S.S.S.N 
---
changes in v3
- Add lock check to avoid potential race as suggested by Matthias
---
 drivers/soc/qcom/rpmh-internal.h |  1 +
 drivers/soc/qcom/rpmh-rsc.c  | 24 
 drivers/soc/qcom/rpmh.c  | 13 +
 include/soc/qcom/rpmh.h  |  5 +
 4 files changed, 43 insertions(+)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 2e3ffcd..4b891c23 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -109,6 +109,7 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv,
 const struct tcs_request *msg);
 int rpmh_rsc_invalidate(struct rsc_drv *drv);
 int rpmh_rsc_write_pdc_data(struct rsc_drv *drv, const struct tcs_request 
*msg);
+bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv);
 void rpmh_tx_done(const struct tcs_request *msg, int r);
 
 #endif /* __RPM_INTERNAL_H__ */
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index d6b834e..9cc303e 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -525,6 +525,30 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const 
struct tcs_request *msg)
 }
 
 /**
+ *  rpmh_rsc_ctrlr_is_idle: Check if any of the AMCs are busy.
+ *
+ *  @drv: The controller
+ *
+ *  Returns true if the TCSes are engaged in handling requests.
+ */
+bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv)
+{
+   int m;
+   struct tcs_group *tcs = get_tcs_of_type(drv, ACTIVE_TCS);
+
+   spin_lock(&drv->lock);
+   for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
+   if (!tcs_is_free(drv, m)) {
+   spin_unlock(&drv->lock);
+   return false;
+   }
+   }
+   spin_unlock(&drv->lock);
+
+   return true;
+}
+
+/**
  * rpmh_rsc_write_ctrl_data: Write request to the controller
  *
  * @drv: the controller
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 297d6cc..43eb981 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -535,3 +535,16 @@ int rpmh_invalidate(const struct device *dev)
return ret;
 }
 EXPORT_SYMBOL(rpmh_invalidate);
+
+/**
+ * rpmh_ctrlr_idle: Return the controller idle status
+ *
+ * @dev: the device making the request
+ */
+int rpmh_ctrlr_idle(const struct device *dev)
+{
+   struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
+
+   return rpmh_rsc_ctrlr_is_idle(ctrlr_to_drv(ctrlr));
+}
+EXPORT_SYMBOL(rpmh_ctrlr_idle);
diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h
index b05e31a..4c4b013 100644
--- a/include/soc/qcom/rpmh.h
+++ b/include/soc/qcom/rpmh.h
@@ -27,6 +27,8 @@ int rpmh_write_batch(const struct device *dev, enum 
rpmh_state state,
 int rpmh_write_pdc_data(const struct device *dev,
const struct tcs_cmd *cmd, u32 n);
 
+int rpmh_ctrlr_idle(const struct device *dev);
+
 #else
 
 static inline int rpmh_write(const struct device *dev, enum rpmh_state state,
@@ -53,6 +55,9 @@ static inline int rpmh_write_pdc_data(const struct device 
*dev,
  const struct tcs_cmd *cmd, u32 n)
 { return -ENODEV; }
 
+static inline int rpmh_ctrlr_idle(const struct device *dev)
+{ return -ENODEV; }
+
 #endif /* CONFIG_QCOM_RPMH */
 
 #endif /* __SOC_QCOM_RPMH_H__ */
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of the Code Aurora Forum, hosted by The Linux Foundation.



[PATCH RESEND v3 1/3] drivers: qcom: rpmh-rsc: simplify TCS locking

2018-10-08 Thread Raju P.L.S.S.S.N
tcs->lock was introduced to serialize access with in TCS group. But
even without tcs->lock, drv->lock is serving the same purpose. So
use single drv->lock.

Other optimizations include -
 - Remove locking around clear_bit() in IRQ handler. clear_bit() is
   atomic.
 - Remove redundant read of TCS registers.
 - Use spin_lock instead of _irq variants as the locks are not held
   in interrupt context

Suggested-by: Lina Iyer 
Signed-off-by: Raju P.L.S.S.S.N 
---
This patch is based on https://lkml.org/lkml/2018/10/3/422
---
 drivers/soc/qcom/rpmh-internal.h |  2 --
 drivers/soc/qcom/rpmh-rsc.c  | 37 +
 drivers/soc/qcom/rpmh.c  | 20 
 3 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 8c316b4..2e3ffcd 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -28,7 +28,6 @@
  * @offset:start of the TCS group relative to the TCSes in the RSC
  * @num_tcs:   number of TCSes in this type
  * @ncpt:  number of commands in each TCS
- * @lock:  lock for synchronizing this TCS writes
  * @req:   requests that are sent from the TCS
  * @cmd_cache: flattened cache of cmds in sleep/wake TCS
  * @slots: indicates which of @cmd_addr are occupied
@@ -40,7 +39,6 @@ struct tcs_group {
u32 offset;
int num_tcs;
int ncpt;
-   spinlock_t lock;
const struct tcs_request *req[MAX_TCS_PER_TYPE];
u32 *cmd_cache;
DECLARE_BITMAP(slots, MAX_TCS_SLOTS);
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 73d5b98..d6b834e 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -98,8 +98,7 @@ static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, 
int tcs_id,
 
 static bool tcs_is_free(struct rsc_drv *drv, int tcs_id)
 {
-   return !test_bit(tcs_id, drv->tcs_in_use) &&
-  read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id, 0);
+   return !test_bit(tcs_id, drv->tcs_in_use);
 }
 
 static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type)
@@ -109,29 +108,28 @@ static struct tcs_group *get_tcs_of_type(struct rsc_drv 
*drv, int type)
 
 static int tcs_invalidate(struct rsc_drv *drv, int type)
 {
-   int m;
+   int m, ret = 0;
struct tcs_group *tcs;
 
tcs = get_tcs_of_type(drv, type);
 
-   spin_lock(&tcs->lock);
-   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) {
-   spin_unlock(&tcs->lock);
-   return 0;
-   }
+   spin_lock(&drv->lock);
+   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
+   goto done;
 
for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
if (!tcs_is_free(drv, m)) {
-   spin_unlock(&tcs->lock);
-   return -EAGAIN;
+   ret = -EAGAIN;
+   goto done;
}
write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0);
write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0);
}
bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
-   spin_unlock(&tcs->lock);
 
-   return 0;
+done:
+   spin_unlock(&drv->lock);
+   return ret;
 }
 
 /**
@@ -298,9 +296,7 @@ static irqreturn_t tcs_tx_done(int irq, void *p)
write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i, 0);
write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, i, 0);
write_tcs_reg(drv, RSC_DRV_IRQ_CLEAR, 0, BIT(i));
-   spin_lock(&drv->lock);
clear_bit(i, drv->tcs_in_use);
-   spin_unlock(&drv->lock);
if (req)
rpmh_tx_done(req, err);
}
@@ -383,14 +379,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
 {
struct tcs_group *tcs;
int tcs_id;
-   unsigned long flags;
int ret;
 
tcs = get_tcs_for_msg(drv, msg);
if (IS_ERR(tcs))
return PTR_ERR(tcs);
 
-   spin_lock_irqsave(&tcs->lock, flags);
spin_lock(&drv->lock);
/*
 * The h/w does not like if we send a request to the same address,
@@ -398,14 +392,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
 */
ret = check_for_req_inflight(drv, tcs, msg);
if (ret) {
-   spin_unlock(&drv->lock);
goto done_write;
}
 
tcs_id = find_free_tcs(tcs);
if (tcs_id < 0) {
ret = tcs_id;
-   spin_unlock(&drv->lock);
goto done_write;
}
 
@@ -413,13 +405,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
set_bit(tcs_id, drv->tcs_in_use);
if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS)
enable_tcs_irq(drv, tcs_id, true);
-   spin

[PATCH RESEND v3 3/3] drivers: qcom: rpmh: disallow active requests in solver mode

2018-10-08 Thread Raju P.L.S.S.S.N
From: Lina Iyer 

Controllers may be in 'solver' state, where they could be in autonomous
mode executing low power modes for their hardware and as such are not
available for sending active votes. Device driver may notify RPMH API
that the controller is in solver mode and when in such mode, disallow
requests from platform drivers for state change using the RSC.

Signed-off-by: Lina Iyer 
Signed-off-by: Raju P.L.S.S.S.N 
---
Chanages in v3
 - Add functionality to set solver mode for RSC controller
 - return -EINVAL if active requests are sent in solver mode
---
 drivers/soc/qcom/rpmh-internal.h |  5 
 drivers/soc/qcom/rpmh-rsc.c  | 30 +++
 drivers/soc/qcom/rpmh.c  | 51 
 include/soc/qcom/rpmh.h  |  5 
 4 files changed, 91 insertions(+)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 4b891c23..0923c45 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -70,12 +70,14 @@ struct rpmh_request {
  * @cache_lock: synchronize access to the cache data
  * @dirty: was the cache updated since flush
  * @batch_cache: Cache sleep and wake requests sent as batch
+ * @in_solver_mode: Controller is busy in solver mode
  */
 struct rpmh_ctrlr {
struct list_head cache;
spinlock_t cache_lock;
bool dirty;
struct list_head batch_cache;
+   bool in_solver_mode;
 };
 
 /**
@@ -86,6 +88,7 @@ struct rpmh_ctrlr {
  * @base:   start address of the RSC's DRV registers
  * @tcs_base:   start address of the TCS registers in this controller
  * @id: instance id in the controller (Direct Resource Voter)
+ * @in_solver_mode: Controller is in solver mode
  * @num_tcs:number of TCSes in this DRV
  * @tcs:TCS groups
  * @tcs_in_use: s/w state of the TCS
@@ -97,6 +100,7 @@ struct rsc_drv {
void __iomem *base;
void __iomem *tcs_base;
int id;
+   bool in_solver_mode;
int num_tcs;
struct tcs_group tcs[TCS_TYPE_NR];
DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR);
@@ -107,6 +111,7 @@ struct rsc_drv {
 int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg);
 int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv,
 const struct tcs_request *msg);
+void rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable);
 int rpmh_rsc_invalidate(struct rsc_drv *drv);
 int rpmh_rsc_write_pdc_data(struct rsc_drv *drv, const struct tcs_request 
*msg);
 bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv);
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 9cc303e..10b3102 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -386,6 +386,11 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
return PTR_ERR(tcs);
 
spin_lock(&drv->lock);
+
+   if (msg->state == RPMH_ACTIVE_ONLY_STATE && drv->in_solver_mode) {
+   ret = -EINVAL;
+   goto done_write;
+   }
/*
 * The h/w does not like if we send a request to the same address,
 * when one is already in-flight or being processed.
@@ -525,6 +530,30 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const 
struct tcs_request *msg)
 }
 
 /**
+ *  rpmh_rsc_mode_solver_set: Enable/disable solver mode
+ *
+ *  @drv: The controller
+ *
+ *  enable: boolean state to be set - true/false
+ */
+void rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable)
+{
+   int m;
+   struct tcs_group *tcs = get_tcs_of_type(drv, ACTIVE_TCS);
+
+again:
+   spin_lock(&drv->lock);
+   for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
+   if (!tcs_is_free(drv, m)) {
+   spin_unlock(&drv->lock);
+   goto again;
+   }
+   }
+   drv->in_solver_mode = enable;
+   spin_unlock(&drv->lock);
+}
+
+/**
  *  rpmh_rsc_ctrlr_is_idle: Check if any of the AMCs are busy.
  *
  *  @drv: The controller
@@ -718,6 +747,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
return ret;
 
spin_lock_init(&drv->lock);
+   drv->in_solver_mode = false;
bitmap_zero(drv->tcs_in_use, MAX_TCS_NR);
 
irq = platform_get_irq(pdev, drv->id);
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 43eb981..e6e98d4 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,6 +76,42 @@ static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device 
*dev)
return &drv->client;
 }
 
+static int check_ctrlr_state(struct rpmh_ctrlr *ctrlr, enum rpmh_state state)
+{
+   int ret = 0;
+
+   /* Do not allow setting active votes when in solver mode */
+   spin_lock(&ctrlr->cache_lock);
+   if (ctrlr->in_solver_mode && state == RPMH_ACTIVE_ONLY_STATE)
+  

Re: [PATCH] mm, oom_adj: avoid meaningless loop to find processes sharing mm

2018-10-08 Thread Michal Hocko
[I have only now noticed that the patch has been reposted]

On Mon 08-10-18 18:27:39, Tetsuo Handa wrote:
> On 2018/10/08 17:38, Yong-Taek Lee wrote:
> >>
> >> On 2018/10/08 15:14, Yong-Taek Lee wrote:
>  On 2018/10/08 10:19, Yong-Taek Lee wrote:
> > @@ -1056,6 +1056,7 @@ static int __set_oom_adj(struct file *file, int 
> > oom_adj, bool legacy)
> > struct mm_struct *mm = NULL;
> > struct task_struct *task;
> > int err = 0;
> > +   int mm_users = 0;
> >
> > task = get_proc_task(file_inode(file));
> > if (!task)
> > @@ -1092,7 +1093,8 @@ static int __set_oom_adj(struct file *file, int 
> > oom_adj, bool legacy)
> > struct task_struct *p = find_lock_task_mm(task);
> >
> > if (p) {
> > -   if (atomic_read(&p->mm->mm_users) > 1) {
> > +   mm_users = atomic_read(&p->mm->mm_users);
> > +   if ((mm_users > 1) && (mm_users != 
> > get_nr_threads(p))) {
> 
>  How can this work (even before this patch)? When clone(CLONE_VM without 
>  CLONE_THREAD/CLONE_SIGHAND)
>  is requested, copy_process() calls copy_signal() in order to copy 
>  sig->oom_score_adj and
>  sig->oom_score_adj_min before calling copy_mm() in order to increment 
>  mm->mm_users, doesn't it?
>  Then, we will get two different "struct signal_struct" with different 
>  oom_score_adj/oom_score_adj_min
>  but one "struct mm_struct" shared by two thread groups.
> 
> >>>
> >>> Are you talking about race between __set_oom_adj and copy_process?
> >>> If so, i agree with your opinion. It can not set oom_score_adj properly 
> >>> for copied process if __set_oom_adj
> >>> check mm_users before copy_process calls copy_mm after copy_signal. 
> >>> Please correct me if i misunderstood anything.
> >>
> >> You understand it correctly.
> >>
> >> Reversing copy_signal() and copy_mm() is not sufficient either. We need to 
> >> use a read/write lock
> >> (read lock for copy_process() and write lock for __set_oom_adj()) in order 
> >> to make sure that
> >> the thread created by clone() becomes reachable from for_each_process() 
> >> path in __set_oom_adj().
> >>
> > 
> > Thank you for your suggestion. But i think it would be better to seperate 
> > to 2 issues. How about think these
> > issues separately because there are no dependency between race issue and my 
> > patch. As i already explained,
> > for_each_process path is meaningless if there is only one thread group with 
> > many threads(mm_users > 1 but 
> > no other thread group sharing same mm). Do you have any other idea to avoid 
> > meaningless loop ? 
> 
> Yes. I suggest reverting commit 44a70adec910d692 ("mm, oom_adj: make sure 
> processes
> sharing mm have same view of oom_score_adj") and commit 97fd49c2355ffded 
> ("mm, oom:
> kill all tasks sharing the mm").

This would require a lot of other work for something as border line as
weird threading model like this. I will think about something more
appropriate - e.g. we can take mmap_sem for read while doing this check
and that should prevent from races with [v]fork.

-- 
Michal Hocko
SUSE Labs


[BUG -next 20181008] list corruption with "mm/slub: remove useless condition in deactivate_slab"

2018-10-08 Thread Heiko Carstens
Hello,

with linux-next for 20181008 I can reliably crash my system with lot's of
debugging options enabled on s390. List debugging triggers the list
corruption below, which I could bisect down to this commit:

fde06e07750477f049f12d7d471ffa505338a3e7 is the first bad commit
commit fde06e07750477f049f12d7d471ffa505338a3e7
Author: Pingfan Liu 
Date:   Thu Oct 4 07:43:01 2018 +1000

mm/slub: remove useless condition in deactivate_slab

The var l should be used to reflect the original list, on which the page
should be.  But c->page is not on any list.  Furthermore, the current code
does not update the value of l.  Hence remove the related logic

Link: 
http://lkml.kernel.org/r/1537941430-16217-1-git-send-email-kernelf...@gmail.com
Signed-off-by: Pingfan Liu 
Acked-by: Christoph Lameter 
Cc: Pekka Enberg 
Cc: David Rientjes 
Cc: Joonsoo Kim 
Signed-off-by: Andrew Morton 
Signed-off-by: Stephen Rothwell 

list_add double add: new=03d1029ecc08, 
prev=8ff846d0,next=03d1029ecc08.
[ cut here ]
kernel BUG at lib/list_debug.c:31!
illegal operation: 0001 ilc:1 [#1] PREEMPT SMP
Modules linked in:
CPU: 3 PID: 106 Comm: (sd-executor) Not tainted 4.19.0-rc6-00291-gfde06e077504 
#21
Hardware name: IBM 2964 NC9 702 (z/VM 6.4.0)
Krnl PSW : (ptrval) (ptrval) (__list_add_valid+0x98/0xa8)
   R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 RI:0 EA:3
Krnl GPRS: 74311fdf 8001 0058 00e7b8b2
    75438c64 a7b31928 001c007b
   8fe99d00 a7b31b40 03d1029ecc08 a7c03a80
   03d1029ecc08 8ff84680 007b5674 a7c03960
Krnl Code: 007b5668: c0200034734alarl%r2,e43cfc
   007b566e: c0e5ffd0cf51brasl   %r14,1cf510
  #007b5674: a7f40001brc 15,7b5676
  >007b5678: a7290001lghi%r2,1
   007b567c: ebcff0a4lmg %r12,%r15,160(%r15)
   007b5682: 07febcr 15,%r14
   007b5684: 0707bcr 0,%r7
   007b5686: 0707bcr 0,%r7
Call Trace:
([<007b5674>] __list_add_valid+0x94/0xa8)
 [<0037d30e>] deactivate_slab.isra.15+0x45e/0x810
 [<0037ede4>] ___slab_alloc+0x76c/0x7c0
 [<0037eeb0>] __slab_alloc.isra.16+0x78/0xa8
 [<003808c8>] kmem_cache_alloc+0x160/0x458
 [<00141a3a>] vm_area_dup+0x3a/0x60
 [<00142f0a>] copy_process+0xd72/0x2100
 [<0014449a>] _do_fork+0xba/0x688
 [<00144bb0>] sys_clone+0x48/0x50
 [<00b8faf0>] system_call+0xd8/0x2d0
INFO: lockdep is turned off.
Last Breaking-Event-Address:
 [<007b5674>] __list_add_valid+0x94/0xa8

Kernel panic - not syncing: Fatal exception: panic_on_oops



Re: [PATCH 4.4 093/113] pinctrl: msm: Really mask level interrupts to prevent latching

2018-10-08 Thread Nathan Chancellor
On Mon, Oct 08, 2018 at 08:31:34PM +0200, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.  If anyone has any objections, please let me know.
> 
> --
> 
> From: Stephen Boyd 
> 
> [ Upstream commit b55326dc969ea2d704a008d9a97583b128f54f4f ]
> 
> The interrupt controller hardware in this pin controller has two status
> enable bits. The first "normal" status enable bit enables or disables
> the summary interrupt line being raised when a gpio interrupt triggers
> and the "raw" status enable bit allows or prevents the hardware from
> latching an interrupt into the status register for a gpio interrupt.
> Currently we just toggle the "normal" status enable bit in the mask and
> unmask ops so that the summary irq interrupt going to the CPU's
> interrupt controller doesn't trigger for the masked gpio interrupt.
> 
> For a level triggered interrupt, the flow would be as follows: the pin
> controller sees the interrupt, latches the status into the status
> register, raises the summary irq to the CPU, summary irq handler runs
> and calls handle_level_irq(), handle_level_irq() masks and acks the gpio
> interrupt, the interrupt handler runs, and finally unmask the interrupt.
> When the interrupt handler completes, we expect that the interrupt line
> level will go back to the deasserted state so the genirq code can unmask
> the interrupt without it triggering again.
> 
> If we only mask the interrupt by clearing the "normal" status enable bit
> then we'll ack the interrupt but it will continue to show up as pending
> in the status register because the raw status bit is enabled, the
> hardware hasn't deasserted the line, and thus the asserted state latches
> into the status register again. When the hardware deasserts the
> interrupt the pin controller still thinks there is a pending unserviced
> level interrupt because it latched it earlier. This behavior causes
> software to see an extra interrupt for level type interrupts each time
> the interrupt is handled.
> 
> Let's fix this by clearing the raw status enable bit for level type
> interrupts so that the hardware stops latching the status of the
> interrupt after we ack it. We don't do this for edge type interrupts
> because it seems that toggling the raw status enable bit for edge type
> interrupts causes spurious edge interrupts.
> 
> Signed-off-by: Stephen Boyd 
> Reviewed-by: Douglas Anderson 
> Reviewed-by: Bjorn Andersson 
> Signed-off-by: Linus Walleij 
> Signed-off-by: Sasha Levin 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/pinctrl/qcom/pinctrl-msm.c |   24 
>  1 file changed, 24 insertions(+)
> 
> --- a/drivers/pinctrl/qcom/pinctrl-msm.c
> +++ b/drivers/pinctrl/qcom/pinctrl-msm.c
> @@ -577,6 +577,29 @@ static void msm_gpio_irq_mask(struct irq
>   spin_lock_irqsave(&pctrl->lock, flags);
>  
>   val = readl(pctrl->regs + g->intr_cfg_reg);
> + /*
> +  * There are two bits that control interrupt forwarding to the CPU. The
> +  * RAW_STATUS_EN bit causes the level or edge sensed on the line to be
> +  * latched into the interrupt status register when the hardware detects
> +  * an irq that it's configured for (either edge for edge type or level
> +  * for level type irq). The 'non-raw' status enable bit causes the
> +  * hardware to assert the summary interrupt to the CPU if the latched
> +  * status bit is set. There's a bug though, the edge detection logic
> +  * seems to have a problem where toggling the RAW_STATUS_EN bit may
> +  * cause the status bit to latch spuriously when there isn't any edge
> +  * so we can't touch that bit for edge type irqs and we have to keep
> +  * the bit set anyway so that edges are latched while the line is 
> masked.
> +  *
> +  * To make matters more complicated, leaving the RAW_STATUS_EN bit
> +  * enabled all the time causes level interrupts to re-latch into the
> +  * status register because the level is still present on the line after
> +  * we ack it. We clear the raw status enable bit during mask here and
> +  * set the bit on unmask so the interrupt can't latch into the hardware
> +  * while it's masked.
> +  */
> + if (irqd_get_trigger_type(d) & IRQ_TYPE_LEVEL_MASK)
> + val &= ~BIT(g->intr_raw_status_bit);
> +
>   val &= ~BIT(g->intr_enable_bit);
>   writel(val, pctrl->regs + g->intr_cfg_reg);
>  
> @@ -598,6 +621,7 @@ static void msm_gpio_irq_unmask(struct i
>   spin_lock_irqsave(&pctrl->lock, flags);
>  
>   val = readl(pctrl->regs + g->intr_cfg_reg);
> + val |= BIT(g->intr_raw_status_bit);
>   val |= BIT(g->intr_enable_bit);
>   writel(val, pctrl->regs + g->intr_cfg_reg);
>  
> 
> 

Sigh, sorry, I caught this after I sent my initial all good email but
this commit breaks NFC on my Pixel 2 XL (toggle becomes greyed out and
apps that want to use it ask to enable it). I can't say why, I'm more
than happy to debug but I'm assuming it's so

Re: [PATCH 1/6] dt-bindings: phy: am654-mmc-phy: Document new phy bindings

2018-10-08 Thread Faiz Abbas
Hi Andrew,

On Friday 05 October 2018 09:28 PM, Andrew F. Davis wrote:
> On 10/04/2018 06:14 AM, Faiz Abbas wrote:
>> Add information to document bindings for the MMC PHY
>> on TI's AM654 devices.
>>
>> Signed-off-by: Faiz Abbas 
>> Signed-off-by: Sekhar Nori 
>> ---
>>  .../devicetree/bindings/phy/am654-mmc-phy.txt | 42 +++
>>  1 file changed, 42 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/phy/am654-mmc-phy.txt
>>
>> diff --git a/Documentation/devicetree/bindings/phy/am654-mmc-phy.txt 
>> b/Documentation/devicetree/bindings/phy/am654-mmc-phy.txt
>> new file mode 100644
>> index ..766921612758
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/phy/am654-mmc-phy.txt
> 
> 
> Name ti,am654-mmc-phy.txt might be more consistent name.

Ok.

> 
> 
>> @@ -0,0 +1,42 @@
>> +TI AM654 MMC PHY
>> +---
>> +
>> +Required properties:
>> + - compatible: ti,am654-emmc-phy
>> + - #phy-cells: must be 0
>> + - reg: PHY registers address offset and size
>> + - clocks: must be phandle of the clock provider which is the host
>> +   controller
>> + - clock-names: must be "mmcclk"
>> + - ti,otap-del-sel: Output Tap Delay select.
>> + - ti,trm-icp: DLL trim select.
>> + - ti,driver-strength-ohm: driver strength in ohms.
>> +   Valid values are 33, 40, 50, 66, and 100 ohms.
>> +
>> +Example:
>> +mmc_phy1: mmc_phy@10100 {
>> +compatible = "ti,am654-mmc-phy";
>> +reg = <0x10100 0x34>;
>> +clocks = <&sdhci1>;
>> +clock-names = "mmcclk";
>> +#phy-cells = <0>;
>> +ti,otap-del-sel = <0x2>;
>> +ti,trm-icp = <0x8>;
>> +status = "disabled";
> 
> 
> No need for disabled in the example case. 

Ok.

> Also not sure the host
> controller example below needs to be here, there are already examples
> for that binding in mmc/arasan,sdhci.txt.
> 

I had added it because it is a clock source in clocks=<&sdhci1> so it
should have #clock-cells and clock-output-names. I suppose I can just
reference it here.

Thanks,
Faiz


Re: [PATCH] mm,numa: Remove remaining traces of rate-limiting.

2018-10-08 Thread Ingo Molnar


* Mel Gorman  wrote:

> On Sat, Oct 06, 2018 at 04:53:19PM +0530, Srikar Dronamraju wrote:
> > With Commit efaffc5e40ae ("mm, sched/numa: Remove rate-limiting of automatic
> > NUMA balancing migration"), we no more require migrate lock and its
> > initialization. Its redundant. Hence remove it.
> > 
> > Signed-off-by: Srikar Dronamraju 
> 
> Hi Ingo, 
> 
> Can this be sent with the rest of the patches that got merged for 4.19-rc7
> so they are more or less together? It's functionally harmless to delay
> until the 4.20 merge window but it's a bit untidy. The mistake was mine
> switching between a backport and mainline versions of the original patch.
> 
> Thanks

Ok, agreed and done - I queued it up in sched/urgent.

Thanks,

Ingo


Re: tracing child threads with address filtering using intel_pt in perf

2018-10-08 Thread Mansour Alharthi
Thank you Alex for the prompt response and fix!

it works perfectly now..

Mansour..


On 10/08/2018 10:25 AM, Alexander Shishkin wrote:
> Alexander Shishkin  writes:
>
>> "Alharthi, Mansour A"  writes:
>>
>>> Hello all,
>> Hi,
>>
>>> Assume this test code:
>>>
>>> thread_start(){
>>> ...
>>> test();
>>> ...
>>> }
>>>
>>> test(){
>>> printf("test");
>>> }
>>>
>>> main(){
>>> ...
>>> pthread_create(.., thread_start,);
>>> }
>> Can you include the complete test case code?
>>
>>> Tracing the above program with the following command:
>>> perf record -v -m 512,1 -e intel_pt//u -T --switch-events --filter
>>> 'filter * @ ./test' -- ./test
>> Can you run it with -vvv and also include its output?
> Scratch that. Instead, can you try the below patch and see if it works
> for you?
>
> Thanks,
> --
> Alex
>
>  From 029a726b63ed6ebef527393704c83dab9c76fb9a Mon Sep 17 00:00:00 2001
> From: Alexander Shishkin 
> Date: Mon, 8 Oct 2018 17:16:30 +0300
> Subject: [PATCH] perf: Copy parent's address filter offsets on clone
>
> When a child event is allocated in the inherit_event() path, the VMA
> based filter offsets are not copied from the parent, even though the
> address space mapping of the new task remains the same, which leads
> to no trace for the new task until exec.
>
> Signed-off-by: Alexander Shishkin 
> ---
>   kernel/events/core.c | 15 +++
>   1 file changed, 15 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index c80549bf82c6..8cecbd61cd90 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -1254,6 +1254,7 @@ static void put_ctx(struct perf_event_context *ctx)
>*perf_event_context::lock
>*  perf_event::mmap_mutex
>*  mmap_sem
> + * perf_addr_filters_head::lock
>*
>*cpu_hotplug_lock
>*  pmus_lock
> @@ -10058,6 +10059,20 @@ perf_event_alloc(struct perf_event_attr *attr, int 
> cpu,
>   goto err_per_task;
>   }
>   
> + /*
> +  * Clone the parent's vma offsets: they are valid until exec()
> +  * even if the mm is not shared with the parent.
> +  */
> + if (event->parent) {
> + struct perf_addr_filters_head *ifh = 
> perf_event_addr_filters(event);
> +
> + raw_spin_lock_irq(&ifh->lock);
> + memcpy(event->addr_filters_offs,
> +event->parent->addr_filters_offs,
> +pmu->nr_addr_filters * sizeof(unsigned long));
> + raw_spin_unlock_irq(&ifh->lock);
> + }
> +
>   /* force hw sync on the address filters */
>   event->addr_filters_gen = 1;
>   }



Re: [PATCH v2 1/2] mfd: cros: add "base attached" MKBP switch definition

2018-10-08 Thread Lee Jones
On Fri, 05 Oct 2018, Dmitry Torokhov wrote:

> This adds a "base attached" switch definition to the MKBP protocol that
> is used by Whiskers driver to properly determine device state (clamshell
> vs tablet mode).
> 
> Signed-off-by: Dmitry Torokhov 
> ---
> 
> v2 changes: None
> 
> Lee, I was wondering if it would be OK for cros_ec_commands.h to be
> merged through HID tree.

Yes, so long as it goes through in this merge-window.

Acked-by: Lee Jones 

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH] mm, oom_adj: avoid meaningless loop to find processes sharing mm

2018-10-08 Thread Michal Hocko
[Cc Oleg]

On Fri 05-10-18 15:32:08, Yong-Taek Lee wrote:
> It is introduced by commit 44a70adec910 ("mm, oom_adj: make sure
> processes sharing mm have same view of oom_score_adj"). Most of
> user process's mm_users is bigger than 1 but only one thread group.
> In this case, for_each_process loop meaninglessly try to find processes
> which sharing same mm even though there is only one thread group.
> 
> My idea is that target task's nr thread is smaller than mm_users if there
> are more thread groups sharing the same mm. So we can skip loop

I remember trying to optimize this but ended up with nothing that would
work reliable. E.g. what prevents a thread terminating right after we
read mm reference count and result in early break and other process
not being updated properly?

> if mm_user and nr_thread are same.
> 
> test result
> while true; do count=0; time while [ $count -lt 1 ]; do echo -1000 > 
> /proc/
> 1457/oom_score_adj; count=$((count+1)); done; done;

Is this overhead noticeable in a real work usecases though? Or are you
updating oom_score_adj that often really?

> before patch
> 0m00.59s real 0m00.09s user 0m00.51s system
> 0m00.59s real 0m00.14s user 0m00.45s system
> 0m00.58s real 0m00.11s user 0m00.47s system
> 0m00.58s real 0m00.10s user 0m00.48s system
> 0m00.59s real 0m00.11s user 0m00.48s system
> 
> after patch
> 0m00.15s real 0m00.07s user 0m00.08s system
> 0m00.14s real 0m00.10s user 0m00.04s system
> 0m00.14s real 0m00.10s user 0m00.05s system
> 0m00.14s real 0m00.08s user 0m00.07s system
> 0m00.14s real 0m00.08s user 0m00.07s system
> 
> Signed-off-by: Lee YongTaek 
> ---
>  fs/proc/base.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index f9f72aee6d45..54b2fb5e9c51 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1056,6 +1056,7 @@ static int __set_oom_adj(struct file *file, int oom_adj,
> bool legacy)
> struct mm_struct *mm = NULL;
> struct task_struct *task;
> int err = 0;
> +   int mm_users = 0;
> 
> task = get_proc_task(file_inode(file));
> if (!task)
> @@ -1092,7 +1093,8 @@ static int __set_oom_adj(struct file *file, int oom_adj,
> bool legacy)
> struct task_struct *p = find_lock_task_mm(task);
> 
> if (p) {
> -   if (atomic_read(&p->mm->mm_users) > 1) {
> +   mm_users = atomic_read(&p->mm->mm_users);
> +   if ((mm_users > 1) && (mm_users != get_nr_threads(p)))
> {
> mm = p->mm;
> atomic_inc(&mm->mm_count);
> }
> --
> 
> *

-- 
Michal Hocko
SUSE Labs


Re: [PATCH] remoteproc: qcom: q6v5-pil: add SCM probe dependency

2018-10-08 Thread Bjorn Andersson
On Mon 08 Oct 19:08 PDT 2018, Brian Norris wrote:

> Similar to qcom_q6v5_pas and qcom_wcnss drivers, probe will fail if SCM
> is not up.
> 

Thanks Brian, this dependency was introduced with the memory ownership
support.

I applied it with an updated conditional to make it explicit that it
related to need_mem_protection, updated the commit message to describe
actual relationship to the memory protection mechanism and added a
Fixes: tag.


Don't we also need to add the ability to disable need_mem_protection
when we're running ATF?

Regards,
Bjorn

> Signed-off-by: Brian Norris 
> ---
>  drivers/remoteproc/qcom_q6v5_mss.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/remoteproc/qcom_q6v5_mss.c 
> b/drivers/remoteproc/qcom_q6v5_mss.c
> index a839b07a58b1..8836ca1bc0c1 100644
> --- a/drivers/remoteproc/qcom_q6v5_mss.c
> +++ b/drivers/remoteproc/qcom_q6v5_mss.c
> @@ -1151,6 +1151,9 @@ static int q6v5_probe(struct platform_device *pdev)
>   if (!desc)
>   return -EINVAL;
>  
> + if (!qcom_scm_is_available())
> + return -EPROBE_DEFER;
> +
>   rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops,
>   desc->hexagon_mba_image, sizeof(*qproc));
>   if (!rproc) {


Re: [PATCH V3 0/4] Changes for SDCC5 version

2018-10-08 Thread Craig



On 9 October 2018 07:01:57 BST, Veerabhadrarao Badiganti 
 wrote:
>Hi
>
>
>On 10/8/2018 12:26 PM, Bjorn Andersson wrote:
>> On Sun 07 Oct 01:07 PDT 2018, Craig wrote:
>>
>>> Any updates on this?
>>>
>> FWIW I used qcom,sdhci-msm-v5 on QCS404 successfully.
>>
>> Regards,
>> Bjorn
>
>The base address and interrupt numbers needs to be updated in your dt.
>you can refer the below link to update interrupt number and base
>address
>https://android.googlesource.com/kernel/msm/+/android-msm-wahoo-4.4-oreo-m2/arch/arm/boot/dts/qcom/sdm660.dtsi
They look correct, driver only uses pwr irq and the actual reg field is fine, 
just node name wrong, which wouldn't cause issues.
>>> On 25 September 2018 16:39:33 BST, Craig 
>wrote:

 On 25 September 2018 12:17:26 BST, Veerabhadrarao Badiganti
  wrote:
> On 9/25/2018 1:18 AM, Craig Tatlor wrote:
>> What socs have you tested this on?
>> On sdm660 it seems to crash device
>> when writing pwr ctl.
> Hi
> We have tested this on SDM845.
> SDM660 also has SDCC5 controller, so you would need to define
> "qcom,sdhci-msm-v5" in your platform dt.
> Can you confirm if you have defined this?
>
 Hi,
 Yes my DT entry is as follows

 sdhc_1: sdhci@f9824900 {
>Update this address. This could be the reason for the crash that you
>are 
>observing.
>
  
   
 compatible = "qcom,sdhci-msm-v5";
   
 reg = <0xc0c4000 0x1000>, <0xc0c5000 0x1000>;
   
 interrupts = ;
   
>
>Please update this interrupt map aswell.
>
 interrupt-names = "pwr_irq";
   

>   
 bus-width = <8>;
   
 non-removable;
   

>   
 vmmc-supply = <&pm660l_l4>;
   
 vqmmc-supply = <&pm660_l8>;
   

>   
 pinctrl-names = "default";
   
 pinctrl-0 = <&sdc1_clk &sdc1_cmd &sdc1_data &sdc1_rclk>;
   

>   
 clocks = <&gcc GCC_SDCC1_APPS_CLK>, <&gcc GCC_SDCC1_AHB_CLK>;
   
 clock-names = "core", "iface";
   
 };

> BTW, can you please share few details of the platform that you are
> checking?
> We are not aware of any dev platform based on SDM660. This is just
>for
> my info
 I'm checking on the sony xperia xa2 (pioneer) smartphone.
>> On Tue, Jun 19, 2018 at 11:09:17AM +0530, Vijay Viswanath wrote:
>>> With SDCC5, the MCI register space got removed and the
>offset/order
> of
>>> several registers have changed. Based on SDCC version used and
>the
> register,
>>> we need to pick the base address and offset.
>>>
>>> Depends on patch series: "[PATCH V5 0/2] mmc: sdhci-msm:
 Configuring
> IO_PAD support for sdhci-msm"
>>> Changes since RFC:
>>> Dropped voltage regulator changes in sdhci-msm
>>> Split the "Register changes for sdcc V5" patch
>>> Instead of checking mci removal for deciding which base addr to
> use,
>>> new function pointers are defined for the 2 variants of sdcc:
>>> 1) MCI present
>>> 2) V5 (mci removed)
>>> Instead of string comparing with the compatible string from DT
> file,
>>> the sdhci_msm_probe will now pick the data associated with the
>>> compatible entry and use it to load variant specific address
> offsets
>>> and msm variant specific read/write ops.
>>>
>>> Changes since V1:
>>> Removed unused msm_reab & msm_writeb APIs
>>> Changed certain register addresses from uppercase to lowercase
>hex
>>> letters
>>> Removed extra lines and spaces
>>> Split "[PATCH V1 0/3] Changes for SDCC5 version" patch into
>two,
>>> one for Documentation and other for the driver changes.
>>>
>>> Changes since V2:
>>> Used lower case for macro function defenitions
>>> Removed unused function pointers for msm_readb & msm_writeb
>>>
>>>
>>> Sayali Lokhande (3):
>>> mmc: sdhci-msm: Define new Register address map
>>> Documentation: sdhci-msm: Add new compatible string for SDCC
>v5
>>> mmc: host: Register changes for sdcc V5
>>>
>>> Vijay Viswanath (1):
>>> mmc: sdhci-msm: Add msm version specific ops and data
>structures
>>>
>>>.../devicetree/bindings/mmc/sdhci-msm.txt  |   7 +-
>>>drivers/mmc/host/sdhci-msm.c   | 511
> -
>>>2 files changed, 391 insertions(+), 127 deletions(-)
>>>
>>> -- 
>>>Qua

Re: unwind_init() takes 100 ms

2018-10-08 Thread Ingo Molnar


* Josh Poimboeuf  wrote:

> > 4.  Would a command line parameter be reasonable `disable_unwind`, so people
> > could decrease their boot time with distribution kernels, and easily turn it
> > back on, when they need a stacktrace without having to rebuild the Linux
> > kernel?
> 
> I think a boot cmdline option to disable ORC would be ok.

I don't agree with such a kludge: 100 msecs isn't the end of the world for a
distro kernel bootup which takes a lot longer than that typically, and we'd 
like to
see the build time sorting implemented as well.

Let's fix this for real intstead of a workaround that is going to decrease
the debuggability of the kernel *significantly*.

> I'm not sure about a runtime toggle though.  It might be racy and I'd
> rather avoid that completely, unless there's a solid justification for
> it.

No, just no ...

Debug facilities need to be robust, dependable and as simple as possible.

Thanks,

Ingo


Re: unwind_init() takes 100 ms

2018-10-08 Thread Ingo Molnar


* Josh Poimboeuf  wrote:

> On Mon, Oct 08, 2018 at 12:34:17PM -0500, Josh Poimboeuf wrote:
> > > 4.  Would a command line parameter be reasonable `disable_unwind`, so 
> > > people
> > > could decrease their boot time with distribution kernels, and easily turn 
> > > it
> > > back on, when they need a stacktrace without having to rebuild the Linux
> > > kernel?
> > 
> > I think a boot cmdline option to disable ORC would be ok.  However,
> > disabling ORC would need to fall back to the "guess" unwinder.
> > Otherwise it would make debugging impossible.  That shouldn't be too
> > hard, but it would require restructuring the code a bit.
> 
> But I should also clarify that this option wouldn't be worth it.
> Sorting at build time is the way to go.

Yep, very much so.

Thanks,

Ingo


Re: [PATCH v3 1/7] regulator/mfd: Support ROHM BD71847 power management IC

2018-10-08 Thread Lee Jones
On Fri, 28 Sep 2018, Mark Brown wrote:

> On Fri, Sep 28, 2018 at 10:14:37AM +0300, Matti Vaittinen wrote:
> 
> > I was just wondering if I could do something to help get this patch
> > series applied? Mark, have you had the time to take a look on pickable
> > ranges addition yet? Should I do some rebasing/resending? Are you giving
> > me a nudge if I can do something?
> 
> Please don't send content free pings and please allow a reasonable time
> for review.  People get busy, go on holiday, attend conferences and so 
> on so unless there is some reason for urgency (like critical bug fixes)
> please allow at least a couple of weeks for review.  If there have been
> review comments then people may be waiting for those to be addressed.
> Sending content free pings just adds to the mail volume (if they are
> seen at all) and if something has gone wrong you'll have to resend the
> patches anyway so resending with any comments addressed is generally a 
> much better approach.

Steeling and adding to an Emacs key-combo for easy insertion into mails!

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH V3 0/4] Changes for SDCC5 version

2018-10-08 Thread Veerabhadrarao Badiganti

Hi


On 10/8/2018 12:26 PM, Bjorn Andersson wrote:

On Sun 07 Oct 01:07 PDT 2018, Craig wrote:


Any updates on this?


FWIW I used qcom,sdhci-msm-v5 on QCS404 successfully.

Regards,
Bjorn


The base address and interrupt numbers needs to be updated in your dt.
you can refer the below link to update interrupt number and base address
https://android.googlesource.com/kernel/msm/+/android-msm-wahoo-4.4-oreo-m2/arch/arm/boot/dts/qcom/sdm660.dtsi


On 25 September 2018 16:39:33 BST, Craig  wrote:


On 25 September 2018 12:17:26 BST, Veerabhadrarao Badiganti
 wrote:

On 9/25/2018 1:18 AM, Craig Tatlor wrote:

What socs have you tested this on?
On sdm660 it seems to crash device
when writing pwr ctl.

Hi
We have tested this on SDM845.
SDM660 also has SDCC5 controller, so you would need to define
"qcom,sdhci-msm-v5" in your platform dt.
Can you confirm if you have defined this?


Hi,
Yes my DT entry is as follows

sdhc_1: sdhci@f9824900 {
Update this address. This could be the reason for the crash that you are 
observing.


 
  
compatible = "qcom,sdhci-msm-v5";
  
reg = <0xc0c4000 0x1000>, <0xc0c5000 0x1000>;
  
interrupts = ;
  


Please update this interrupt map aswell.


interrupt-names = "pwr_irq";
  
   
bus-width = <8>;
  
non-removable;
  
   
vmmc-supply = <&pm660l_l4>;
  
vqmmc-supply = <&pm660_l8>;
  
   
pinctrl-names = "default";
  
pinctrl-0 = <&sdc1_clk &sdc1_cmd &sdc1_data &sdc1_rclk>;
  
   
clocks = <&gcc GCC_SDCC1_APPS_CLK>, <&gcc GCC_SDCC1_AHB_CLK>;
  
clock-names = "core", "iface";
  
};



BTW, can you please share few details of the platform that you are
checking?
We are not aware of any dev platform based on SDM660. This is just for
my info

I'm checking on the sony xperia xa2 (pioneer) smartphone.

On Tue, Jun 19, 2018 at 11:09:17AM +0530, Vijay Viswanath wrote:

With SDCC5, the MCI register space got removed and the offset/order

of

several registers have changed. Based on SDCC version used and the

register,

we need to pick the base address and offset.

Depends on patch series: "[PATCH V5 0/2] mmc: sdhci-msm:

Configuring

IO_PAD support for sdhci-msm"

Changes since RFC:
Dropped voltage regulator changes in sdhci-msm
Split the "Register changes for sdcc V5" patch
Instead of checking mci removal for deciding which base addr to

use,

new function pointers are defined for the 2 variants of sdcc:
1) MCI present
2) V5 (mci removed)
Instead of string comparing with the compatible string from DT

file,

the sdhci_msm_probe will now pick the data associated with the
compatible entry and use it to load variant specific address

offsets

and msm variant specific read/write ops.

Changes since V1:
Removed unused msm_reab & msm_writeb APIs
Changed certain register addresses from uppercase to lowercase hex
letters
Removed extra lines and spaces
Split "[PATCH V1 0/3] Changes for SDCC5 version" patch into two,
one for Documentation and other for the driver changes.

Changes since V2:
Used lower case for macro function defenitions
Removed unused function pointers for msm_readb & msm_writeb


Sayali Lokhande (3):
mmc: sdhci-msm: Define new Register address map
Documentation: sdhci-msm: Add new compatible string for SDCC v5
mmc: host: Register changes for sdcc V5

Vijay Viswanath (1):
mmc: sdhci-msm: Add msm version specific ops and data structures

   .../devicetree/bindings/mmc/sdhci-msm.txt  |   7 +-
   drivers/mmc/host/sdhci-msm.c   | 511

-

   2 files changed, 391 insertions(+), 127 deletions(-)

--
   Qualcomm India Private Limited, on behalf of Qualcomm Innovation

Center, Inc.

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,

a

Linux Foundation Collaborative Project.

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

linux-arm-msm" in

the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks,
Veera

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Thanks,
Veera


Re: [PATCH 1/4] gpio: Assign gpio_irq_chip::parents to non-stack pointer

2018-10-08 Thread Stephen Boyd
Quoting kbuild test robot (2018-10-08 21:56:25)
> Hi Stephen,
> 
> I love your patch! Perhaps something to improve:
[...]
>net/mac80211/sta_info.h:588: warning: Function parameter or member 
> 'tx_stats.packets' not described in 'sta_info'
>net/mac80211/sta_info.h:588: warning: Function parameter or member 
> 'tx_stats.bytes' not described in 'sta_info'
>net/mac80211/sta_info.h:588: warning: Function parameter or member 
> 'tx_stats.last_rate' not described in 'sta_info'
>net/mac80211/sta_info.h:588: warning: Function parameter or member 
> 'tx_stats.msdu' not described in 'sta_info'
>include/linux/dma-buf.h:304: warning: Function parameter or member 
> 'cb_excl.cb' not described in 'dma_buf'
>include/linux/dma-buf.h:304: warning: Function parameter or member 
> 'cb_excl.poll' not described in 'dma_buf'
>include/linux/dma-buf.h:304: warning: Function parameter or member 
> 'cb_excl.active' not described in 'dma_buf'
>include/linux/dma-buf.h:304: warning: Function parameter or member 
> 'cb_shared.cb' not described in 'dma_buf'
>include/linux/dma-buf.h:304: warning: Function parameter or member 
> 'cb_shared.poll' not described in 'dma_buf'
>include/linux/dma-buf.h:304: warning: Function parameter or member 
> 'cb_shared.active' not described in 'dma_buf'
>include/linux/dma-fence-array.h:54: warning: Function parameter or member 
> 'work' not described in 'dma_fence_array'
>include/linux/gpio/driver.h:105: warning: Incorrect use of kernel-doc 
> format: Documentation Makefile include scripts source private: For use by 
> gpiochip_set_cascaded_irqchip()
> >> include/linux/gpio/driver.h:167: warning: Function parameter or member 
> >> 'parent_irq' not described in 'gpio_irq_chip'

Ok! That was a little rough to pick out. Is there any way to mark
something as private with inline kernel doc?



Re: [PATCH] dt-bindings: Add bindings for aliases node

2018-10-08 Thread Stephen Boyd
Quoting Matthias Kaehlcke (2018-09-25 14:02:55)
> Add a global binding for the 'aliases' node. This includes an initial list
> of standardized alias names for some hardware components that are commonly
> found in 'aliases'.
> 
> Signed-off-by: Matthias Kaehlcke 
> ---
>  Documentation/devicetree/bindings/aliases.txt | 47 +++

Any chance we can get a documentation update for the devicetree spec as
well?

>  1 file changed, 47 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/aliases.txt
> 
> diff --git a/Documentation/devicetree/bindings/aliases.txt 
> b/Documentation/devicetree/bindings/aliases.txt
> new file mode 100644
> index ..d64ed1c7eb34
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/aliases.txt
> @@ -0,0 +1,47 @@
> +The aliases node
> +
> +
> +The aliases node contains properties that represent aliases to device tree
> +nodes. The name of the property is the alias name, the value is the path of
> +a the device tree node that corresponds to the alias. The path may be

s/a //

> +specified as a string or a phandle.
> +
> +Alias names are often suffixed with a numeric ID, especially when there may
> +be multiple instances of the same type. The ID typically corresponds to the
> +hardware layout, it may also be used by drivers for a stable mapping of
> +device names and hardware entities.

Indicate the numeric ID is a u32 or something like that?

> +
> +Alias names
> +---
> +
> +The devicetree specification doesn't require the use of specific alias
> +names to refer to hardware entities of a given type, however the Linux
> +kernel aims for a certain level of consistency.
> +
> +The following standardized alias names shall be used for their
> +corresponding hardware components:
> +
> +  bluetoothN   Bluetooth controller

Can we use syntax like:

bluetooth

to indicate that  is an unsigned integer?

> +  ethernetNEthernet interface
> +  gpioNGPIO controller
> +  i2cN i2c bus
> +  mmcN MMC bus
> +  rtcN Real time clock
> +  serialN  UART port
> +  spiN SPI bus
> +  wifiNWireless network interface
> +
> +The above list is not exhaustive and will be extended over time. Please
> +send patches to devicet...@vger.kernel.org if you think a hardware
> +component and its alias name should be on the list.
> +


[tip:irq/core] genirq: Fix grammar s/an /a /

2018-10-08 Thread tip-bot for Geert Uytterhoeven
Commit-ID:  b8d62f33b7b225935649ab165d901fe8dd7f95e5
Gitweb: https://git.kernel.org/tip/b8d62f33b7b225935649ab165d901fe8dd7f95e5
Author: Geert Uytterhoeven 
AuthorDate: Mon, 8 Oct 2018 13:17:26 +0200
Committer:  Ingo Molnar 
CommitDate: Tue, 9 Oct 2018 07:50:41 +0200

genirq: Fix grammar s/an /a /

Fix a grammar mistake in .

[ mingo: While at it also fix another similar error in another comment as well. 
]

Signed-off-by: Geert Uytterhoeven 
Cc: Jiri Kosina 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Link: http://lkml.kernel.org/r/20181008111726.26286-1-geert%2brene...@glider.be
Signed-off-by: Ingo Molnar 
---
 include/linux/interrupt.h | 2 +-
 kernel/irq/irqdomain.c| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index eeceac3376fc..1d6711c28271 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -45,7 +45,7 @@
  * IRQF_PERCPU - Interrupt is per cpu
  * IRQF_NOBALANCING - Flag to exclude this interrupt from irq balancing
  * IRQF_IRQPOLL - Interrupt is used for polling (only the interrupt that is
- *registered first in an shared interrupt is considered for
+ *registered first in a shared interrupt is considered for
  *performance reasons)
  * IRQF_ONESHOT - Interrupt is not reenabled after the hardirq handler 
finished.
  *Used by threaded interrupts which need to keep the
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 3b30a4aeb0db..3366d11c3e02 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -867,7 +867,7 @@ void irq_dispose_mapping(unsigned int virq)
 EXPORT_SYMBOL_GPL(irq_dispose_mapping);
 
 /**
- * irq_find_mapping() - Find a linux irq from an hw irq number.
+ * irq_find_mapping() - Find a linux irq from a hw irq number.
  * @domain: domain owning this hardware interrupt
  * @hwirq: hardware irq number in that domain space
  */


[PATCH 6/7] dmaengine: stm32-dma: fix max items per transfer

2018-10-08 Thread Joel Fernandes (Google)
From: Pierre Yves MORDRET 

Having 0 in item counter register is valid and stands for a "No or Ended
transfer". Therefore valid transfer starts from @+0 to @+0xFFFE leading to
unaligned scatter gather at boundary. Thus it's safer to round down this
value on its FIFO size (16 Bytes).

Signed-off-by: Pierre-Yves MORDRET 
Signed-off-by: Vinod Koul 
---
 drivers/dma/stm32-dma.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index b40486454a2c..05a2974cd2c0 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -38,10 +38,6 @@
 #define STM32_DMA_TEI  BIT(3) /* Transfer Error Interrupt */
 #define STM32_DMA_DMEI BIT(2) /* Direct Mode Error Interrupt */
 #define STM32_DMA_FEI  BIT(0) /* FIFO Error Interrupt */
-#define STM32_DMA_MASKI(STM32_DMA_TCI \
-| STM32_DMA_TEI \
-| STM32_DMA_DMEI \
-| STM32_DMA_FEI)
 
 /* DMA Stream x Configuration Register */
 #define STM32_DMA_SCR(x)   (0x0010 + 0x18 * (x)) /* x = 0..7 */
@@ -118,6 +114,13 @@
 #define STM32_DMA_FIFO_THRESHOLD_FULL  0x03
 
 #define STM32_DMA_MAX_DATA_ITEMS   0x
+/*
+ * Valid transfer starts from @0 to @0xFFFE leading to unaligned scatter
+ * gather at boundary. Thus it's safer to round down this value on FIFO
+ * size (16 Bytes)
+ */
+#define STM32_DMA_ALIGNED_MAX_DATA_ITEMS   \
+   ALIGN_DOWN(STM32_DMA_MAX_DATA_ITEMS, 16)
 #define STM32_DMA_MAX_CHANNELS 0x08
 #define STM32_DMA_MAX_REQUEST_ID   0x08
 #define STM32_DMA_MAX_DATA_PARAM   0x03
@@ -869,7 +872,7 @@ static struct dma_async_tx_descriptor 
*stm32_dma_prep_slave_sg(
desc->sg_req[i].len = sg_dma_len(sg);
 
nb_data_items = desc->sg_req[i].len / buswidth;
-   if (nb_data_items > STM32_DMA_MAX_DATA_ITEMS) {
+   if (nb_data_items > STM32_DMA_ALIGNED_MAX_DATA_ITEMS) {
dev_err(chan2dev(chan), "nb items not supported\n");
goto err;
}
@@ -935,7 +938,7 @@ static struct dma_async_tx_descriptor 
*stm32_dma_prep_dma_cyclic(
return NULL;
 
nb_data_items = period_len / buswidth;
-   if (nb_data_items > STM32_DMA_MAX_DATA_ITEMS) {
+   if (nb_data_items > STM32_DMA_ALIGNED_MAX_DATA_ITEMS) {
dev_err(chan2dev(chan), "number of items not supported\n");
return NULL;
}
@@ -985,7 +988,7 @@ static struct dma_async_tx_descriptor 
*stm32_dma_prep_dma_memcpy(
u32 num_sgs, best_burst, dma_burst, threshold;
int i;
 
-   num_sgs = DIV_ROUND_UP(len, STM32_DMA_MAX_DATA_ITEMS);
+   num_sgs = DIV_ROUND_UP(len, STM32_DMA_ALIGNED_MAX_DATA_ITEMS);
desc = stm32_dma_alloc_desc(num_sgs);
if (!desc)
return NULL;
@@ -994,7 +997,7 @@ static struct dma_async_tx_descriptor 
*stm32_dma_prep_dma_memcpy(
 
for (offset = 0, i = 0; offset < len; offset += xfer_count, i++) {
xfer_count = min_t(size_t, len - offset,
-  STM32_DMA_MAX_DATA_ITEMS);
+  STM32_DMA_ALIGNED_MAX_DATA_ITEMS);
 
/* Compute best burst size */
max_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
-- 
2.19.0.605.g01d371f741-goog



[PATCH 7/7] dmaengine: stm32-dma: properly mask irq bits

2018-10-08 Thread Joel Fernandes (Google)
From: Pierre Yves MORDRET 

A single register of the controller holds the information for four dma
channels.
The functions stm32_dma_irq_status() don't mask the relevant bits after
the shift, thus adjacent channel's status is also reported in the returned
value.
Fixed by masking the value before returning it.

Similarly, the function stm32_dma_irq_clear() don't mask the input value
before shifting it, thus an incorrect input value could disable the
interrupts of adjacent channels.
Fixed by masking the input value before using it.

Signed-off-by: Pierre-Yves MORDRET 
Signed-off-by: Antonio Borneo 
Signed-off-by: Vinod Koul 
---
 drivers/dma/stm32-dma.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 05a2974cd2c0..8c5807362a25 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -38,6 +38,10 @@
 #define STM32_DMA_TEI  BIT(3) /* Transfer Error Interrupt */
 #define STM32_DMA_DMEI BIT(2) /* Direct Mode Error Interrupt */
 #define STM32_DMA_FEI  BIT(0) /* FIFO Error Interrupt */
+#define STM32_DMA_MASKI(STM32_DMA_TCI \
+| STM32_DMA_TEI \
+| STM32_DMA_DMEI \
+| STM32_DMA_FEI)
 
 /* DMA Stream x Configuration Register */
 #define STM32_DMA_SCR(x)   (0x0010 + 0x18 * (x)) /* x = 0..7 */
@@ -405,7 +409,7 @@ static u32 stm32_dma_irq_status(struct stm32_dma_chan *chan)
 
flags = dma_isr >> (((chan->id & 2) << 3) | ((chan->id & 1) * 6));
 
-   return flags;
+   return flags & STM32_DMA_MASKI;
 }
 
 static void stm32_dma_irq_clear(struct stm32_dma_chan *chan, u32 flags)
@@ -420,6 +424,7 @@ static void stm32_dma_irq_clear(struct stm32_dma_chan 
*chan, u32 flags)
 * If (ch % 4) is 2 or 3, left shift the mask by 16 bits.
 * If (ch % 4) is 1 or 3, additionally left shift the mask by 6 bits.
 */
+   flags &= STM32_DMA_MASKI;
dma_ifcr = flags << (((chan->id & 2) << 3) | ((chan->id & 1) * 6));
 
if (chan->id & 4)
-- 
2.19.0.605.g01d371f741-goog



[PATCH 4/7] dmaengine: stm32-dma: Improve memory burst management

2018-10-08 Thread Joel Fernandes (Google)
From: Pierre Yves MORDRET 

This patch improves memory burst capability using best burst size
according to transferred buffer size from/to memory.

>From now on, memory burst is not necessarily same as with peripheral
burst one and fifo threshold is directly managed by this driver in order
to fit with computed memory burst.

Signed-off-by: M'boumba Cedric Madianga 
Signed-off-by: Pierre-Yves MORDRET 
Signed-off-by: Vinod Koul 
---
 drivers/dma/stm32-dma.c | 204 ++--
 1 file changed, 175 insertions(+), 29 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index b64e14a83dec..21ad359a5a59 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -5,6 +5,7 @@
  *
  * Copyright (C) M'boumba Cedric Madianga 2015
  * Author: M'boumba Cedric Madianga 
+ * Pierre-Yves Mordret 
  *
  * License terms:  GNU General Public License (GPL), version 2
  */
@@ -115,6 +116,8 @@
 #define STM32_DMA_MAX_CHANNELS 0x08
 #define STM32_DMA_MAX_REQUEST_ID   0x08
 #define STM32_DMA_MAX_DATA_PARAM   0x03
+#define STM32_DMA_FIFO_SIZE16  /* FIFO is 16 bytes */
+#define STM32_DMA_MIN_BURST4
 #define STM32_DMA_MAX_BURST16
 
 /* DMA Features */
@@ -184,6 +187,8 @@ struct stm32_dma_chan {
struct dma_slave_config dma_sconfig;
struct stm32_dma_chan_reg chan_reg;
u32 threshold;
+   u32 mem_burst;
+   u32 mem_width;
 };
 
 struct stm32_dma_device {
@@ -248,6 +253,85 @@ static int stm32_dma_get_width(struct stm32_dma_chan *chan,
}
 }
 
+static enum dma_slave_buswidth stm32_dma_get_max_width(u32 buf_len,
+  u32 threshold)
+{
+   enum dma_slave_buswidth max_width;
+
+   if (threshold == STM32_DMA_FIFO_THRESHOLD_FULL)
+   max_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+   else
+   max_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
+
+   while ((buf_len < max_width  || buf_len % max_width) &&
+  max_width > DMA_SLAVE_BUSWIDTH_1_BYTE)
+   max_width = max_width >> 1;
+
+   return max_width;
+}
+
+static bool stm32_dma_fifo_threshold_is_allowed(u32 burst, u32 threshold,
+   enum dma_slave_buswidth width)
+{
+   u32 remaining;
+
+   if (width != DMA_SLAVE_BUSWIDTH_UNDEFINED) {
+   if (burst != 0) {
+   /*
+* If number of beats fit in several whole bursts
+* this configuration is allowed.
+*/
+   remaining = ((STM32_DMA_FIFO_SIZE / width) *
+(threshold + 1) / 4) % burst;
+
+   if (remaining == 0)
+   return true;
+   } else {
+   return true;
+   }
+   }
+
+   return false;
+}
+
+static bool stm32_dma_is_burst_possible(u32 buf_len, u32 threshold)
+{
+   switch (threshold) {
+   case STM32_DMA_FIFO_THRESHOLD_FULL:
+   if (buf_len >= STM32_DMA_MAX_BURST)
+   return true;
+   else
+   return false;
+   case STM32_DMA_FIFO_THRESHOLD_HALFFULL:
+   if (buf_len >= STM32_DMA_MAX_BURST / 2)
+   return true;
+   else
+   return false;
+   default:
+   return false;
+   }
+}
+
+static u32 stm32_dma_get_best_burst(u32 buf_len, u32 max_burst, u32 threshold,
+   enum dma_slave_buswidth width)
+{
+   u32 best_burst = max_burst;
+
+   if (best_burst == 1 || !stm32_dma_is_burst_possible(buf_len, threshold))
+   return 0;
+
+   while ((buf_len < best_burst * width && best_burst > 1) ||
+  !stm32_dma_fifo_threshold_is_allowed(best_burst, threshold,
+   width)) {
+   if (best_burst > STM32_DMA_MIN_BURST)
+   best_burst = best_burst >> 1;
+   else
+   best_burst = 0;
+   }
+
+   return best_burst;
+}
+
 static int stm32_dma_get_burst(struct stm32_dma_chan *chan, u32 maxburst)
 {
switch (maxburst) {
@@ -267,12 +351,12 @@ static int stm32_dma_get_burst(struct stm32_dma_chan 
*chan, u32 maxburst)
 }
 
 static void stm32_dma_set_fifo_config(struct stm32_dma_chan *chan,
- u32 src_maxburst, u32 dst_maxburst)
+ u32 src_burst, u32 dst_burst)
 {
chan->chan_reg.dma_sfcr &= ~STM32_DMA_SFCR_MASK;
chan->chan_reg.dma_scr &= ~STM32_DMA_SCR_DMEIE;
 
-   if ((!src_maxburst) && (!dst_maxburst)) {
+   if (!src_burst && !dst_burst) {
/* Using direct mode */
chan->chan_reg.dma_scr |= STM32_DMA_SCR_DMEIE;
} else {
@@ -589,37 +673,52

[PATCH 3/7] dmaengine: stm32-dma: fix typo and reported checkpatch warnings

2018-10-08 Thread Joel Fernandes (Google)
From: Pierre Yves MORDRET 

Fix typo in a comment and solved reported checkpatch warnings.

Signed-off-by: Pierre-Yves MORDRET 
Signed-off-by: Vinod Koul 
---
 drivers/dma/stm32-dma.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index fae7de54f00a..b64e14a83dec 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -60,7 +60,8 @@
 #define STM32_DMA_SCR_PINC BIT(9) /* Peripheral increment mode */
 #define STM32_DMA_SCR_CIRC BIT(8) /* Circular mode */
 #define STM32_DMA_SCR_PFCTRL   BIT(5) /* Peripheral Flow Controller */
-#define STM32_DMA_SCR_TCIE BIT(4) /* Transfer Cplete Int Enable*/
+#define STM32_DMA_SCR_TCIE BIT(4) /* Transfer Complete Int Enable
+   */
 #define STM32_DMA_SCR_TEIE BIT(2) /* Transfer Error Int Enable */
 #define STM32_DMA_SCR_DMEIEBIT(1) /* Direct Mode Err Int Enable */
 #define STM32_DMA_SCR_EN   BIT(0) /* Stream Enable */
@@ -918,7 +919,7 @@ static enum dma_status stm32_dma_tx_status(struct dma_chan 
*c,
u32 residue = 0;
 
status = dma_cookie_status(c, cookie, state);
-   if ((status == DMA_COMPLETE) || (!state))
+   if (status == DMA_COMPLETE || !state)
return status;
 
spin_lock_irqsave(&chan->vchan.lock, flags);
@@ -982,7 +983,7 @@ static void stm32_dma_desc_free(struct virt_dma_desc *vdesc)
 }
 
 static void stm32_dma_set_config(struct stm32_dma_chan *chan,
- struct stm32_dma_cfg *cfg)
+struct stm32_dma_cfg *cfg)
 {
stm32_dma_clear_reg(&chan->chan_reg);
 
@@ -1015,8 +1016,8 @@ static struct dma_chan *stm32_dma_of_xlate(struct 
of_phandle_args *dma_spec,
cfg.stream_config = dma_spec->args[2];
cfg.features = dma_spec->args[3];
 
-   if ((cfg.channel_id >= STM32_DMA_MAX_CHANNELS) ||
-   (cfg.request_line >= STM32_DMA_MAX_REQUEST_ID)) {
+   if (cfg.channel_id >= STM32_DMA_MAX_CHANNELS ||
+   cfg.request_line >= STM32_DMA_MAX_REQUEST_ID) {
dev_err(dev, "Bad channel and/or request id\n");
return NULL;
}
-- 
2.19.0.605.g01d371f741-goog



[PATCH 5/7] dmaengine: stm32-dma: fix DMA IRQ status handling

2018-10-08 Thread Joel Fernandes (Google)
From: Pierre Yves MORDRET 

Update the way Transfer Complete and Half Transfer Complete status are
acknowledge. Even if HTI is not enabled its status is shown when reading
registers, driver has to clear it gently and not raise an error.

Signed-off-by: Pierre-Yves MORDRET 
Signed-off-by: Vinod Koul 
---
 drivers/dma/stm32-dma.c | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 21ad359a5a59..b40486454a2c 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -34,9 +34,14 @@
 #define STM32_DMA_LIFCR0x0008 /* DMA Low Int Flag 
Clear Reg */
 #define STM32_DMA_HIFCR0x000c /* DMA High Int Flag 
Clear Reg */
 #define STM32_DMA_TCI  BIT(5) /* Transfer Complete Interrupt */
+#define STM32_DMA_HTI  BIT(4) /* Half Transfer Interrupt */
 #define STM32_DMA_TEI  BIT(3) /* Transfer Error Interrupt */
 #define STM32_DMA_DMEI BIT(2) /* Direct Mode Error Interrupt */
 #define STM32_DMA_FEI  BIT(0) /* FIFO Error Interrupt */
+#define STM32_DMA_MASKI(STM32_DMA_TCI \
+| STM32_DMA_TEI \
+| STM32_DMA_DMEI \
+| STM32_DMA_FEI)
 
 /* DMA Stream x Configuration Register */
 #define STM32_DMA_SCR(x)   (0x0010 + 0x18 * (x)) /* x = 0..7 */
@@ -643,13 +648,29 @@ static irqreturn_t stm32_dma_chan_irq(int irq, void 
*devid)
status = stm32_dma_irq_status(chan);
scr = stm32_dma_read(dmadev, STM32_DMA_SCR(chan->id));
 
-   if ((status & STM32_DMA_TCI) && (scr & STM32_DMA_SCR_TCIE)) {
+   if (status & STM32_DMA_TCI) {
stm32_dma_irq_clear(chan, STM32_DMA_TCI);
-   stm32_dma_handle_chan_done(chan);
-
-   } else {
+   if (scr & STM32_DMA_SCR_TCIE)
+   stm32_dma_handle_chan_done(chan);
+   status &= ~STM32_DMA_TCI;
+   }
+   if (status & STM32_DMA_HTI) {
+   stm32_dma_irq_clear(chan, STM32_DMA_HTI);
+   status &= ~STM32_DMA_HTI;
+   }
+   if (status & STM32_DMA_FEI) {
+   stm32_dma_irq_clear(chan, STM32_DMA_FEI);
+   status &= ~STM32_DMA_FEI;
+   if (!(scr & STM32_DMA_SCR_EN))
+   dev_err(chan2dev(chan), "FIFO Error\n");
+   else
+   dev_dbg(chan2dev(chan), "FIFO over/underrun\n");
+   }
+   if (status) {
stm32_dma_irq_clear(chan, status);
dev_err(chan2dev(chan), "DMA error: status=0x%08x\n", status);
+   if (!(scr & STM32_DMA_SCR_EN))
+   dev_err(chan2dev(chan), "chan disabled by HW\n");
}
 
spin_unlock(&chan->vchan.lock);
-- 
2.19.0.605.g01d371f741-goog



[PATCH 2/7] dmaengine: stm32-dma: fix incomplete configuration in cyclic mode

2018-10-08 Thread Joel Fernandes (Google)
From: Pierre Yves MORDRET 

When in cyclic mode, the configuration is updated after having started the
DMA hardware (STM32_DMA_SCR_EN) leading to incomplete configuration of
SMxAR registers.

Signed-off-by: Pierre-Yves MORDRET 
Signed-off-by: Hugues Fruchet 
Signed-off-by: Vinod Koul 
---
 drivers/dma/stm32-dma.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 4099948b6914..fae7de54f00a 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -441,6 +441,8 @@ static void stm32_dma_dump_reg(struct stm32_dma_chan *chan)
dev_dbg(chan2dev(chan), "SFCR:  0x%08x\n", sfcr);
 }
 
+static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan);
+
 static void stm32_dma_start_transfer(struct stm32_dma_chan *chan)
 {
struct stm32_dma_device *dmadev = stm32_dma_get_dev(chan);
@@ -483,6 +485,9 @@ static void stm32_dma_start_transfer(struct stm32_dma_chan 
*chan)
if (status)
stm32_dma_irq_clear(chan, status);
 
+   if (chan->desc->cyclic)
+   stm32_dma_configure_next_sg(chan);
+
stm32_dma_dump_reg(chan);
 
/* Start DMA */
@@ -576,8 +581,7 @@ static void stm32_dma_issue_pending(struct dma_chan *c)
if (vchan_issue_pending(&chan->vchan) && !chan->desc && !chan->busy) {
dev_dbg(chan2dev(chan), "vchan %p: issued\n", &chan->vchan);
stm32_dma_start_transfer(chan);
-   if (chan->desc->cyclic)
-   stm32_dma_configure_next_sg(chan);
+
}
spin_unlock_irqrestore(&chan->vchan.lock, flags);
 }
-- 
2.19.0.605.g01d371f741-goog



[PATCH 0/7] NULL pointer deref fix for stm32-dma

2018-10-08 Thread Joel Fernandes (Google)
Hi Greg,

While looking at android-4.14, I found a NULL pointer deref with
stm32-dma driver using Coccicheck errors. I found that upstream had a
bunch of patches on stm32-dma that have fixed this and other issues, I
applied these patches cleanly onto Android 4.14. I believe these should
goto stable and flow into Android 4.14 from there, but I haven't tested
this since I have no hardware to do so.

Atleast I can say that the coccicheck error below goes away when running:
make coccicheck MODE=report
./drivers/dma/stm32-dma.c:567:18-24: ERROR: chan -> desc is NULL but 
dereferenced.

Anyway, please consider this series for 4.14 stable, I have CC'd the
author and others, thanks.

Pierre Yves MORDRET (7):
  dmaengine: stm32-dma: threshold manages with bitfield feature
  dmaengine: stm32-dma: fix incomplete configuration in cyclic mode
  dmaengine: stm32-dma: fix typo and reported checkpatch warnings
  dmaengine: stm32-dma: Improve memory burst management
  dmaengine: stm32-dma: fix DMA IRQ status handling
  dmaengine: stm32-dma: fix max items per transfer
  dmaengine: stm32-dma: properly mask irq bits

 drivers/dma/stm32-dma.c | 287 +---
 1 file changed, 240 insertions(+), 47 deletions(-)

-- 
2.19.0.605.g01d371f741-goog


[PATCH 1/7] dmaengine: stm32-dma: threshold manages with bitfield feature

2018-10-08 Thread Joel Fernandes (Google)
From: Pierre Yves MORDRET 

>From now on, DMA bitfield is to manage DMA FIFO Threshold.

Signed-off-by: Pierre-Yves MORDRET 
Signed-off-by: Vinod Koul 
---
 drivers/dma/stm32-dma.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 786fc8fcc38e..4099948b6914 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -116,6 +116,10 @@
 #define STM32_DMA_MAX_DATA_PARAM   0x03
 #define STM32_DMA_MAX_BURST16
 
+/* DMA Features */
+#define STM32_DMA_THRESHOLD_FTR_MASK   GENMASK(1, 0)
+#define STM32_DMA_THRESHOLD_FTR_GET(n) ((n) & STM32_DMA_THRESHOLD_FTR_MASK)
+
 enum stm32_dma_width {
STM32_DMA_BYTE,
STM32_DMA_HALF_WORD,
@@ -129,11 +133,18 @@ enum stm32_dma_burst_size {
STM32_DMA_BURST_INCR16,
 };
 
+/**
+ * struct stm32_dma_cfg - STM32 DMA custom configuration
+ * @channel_id: channel ID
+ * @request_line: DMA request
+ * @stream_config: 32bit mask specifying the DMA channel configuration
+ * @features: 32bit mask specifying the DMA Feature list
+ */
 struct stm32_dma_cfg {
u32 channel_id;
u32 request_line;
u32 stream_config;
-   u32 threshold;
+   u32 features;
 };
 
 struct stm32_dma_chan_reg {
@@ -171,6 +182,7 @@ struct stm32_dma_chan {
u32 next_sg;
struct dma_slave_config dma_sconfig;
struct stm32_dma_chan_reg chan_reg;
+   u32 threshold;
 };
 
 struct stm32_dma_device {
@@ -976,7 +988,8 @@ static void stm32_dma_set_config(struct stm32_dma_chan 
*chan,
/* Enable Interrupts  */
chan->chan_reg.dma_scr |= STM32_DMA_SCR_TEIE | STM32_DMA_SCR_TCIE;
 
-   chan->chan_reg.dma_sfcr = cfg->threshold & STM32_DMA_SFCR_FTH_MASK;
+   chan->threshold = STM32_DMA_THRESHOLD_FTR_GET(cfg->features);
+   chan->chan_reg.dma_sfcr = STM32_DMA_SFCR_FTH(chan->threshold);
 }
 
 static struct dma_chan *stm32_dma_of_xlate(struct of_phandle_args *dma_spec,
@@ -996,7 +1009,7 @@ static struct dma_chan *stm32_dma_of_xlate(struct 
of_phandle_args *dma_spec,
cfg.channel_id = dma_spec->args[0];
cfg.request_line = dma_spec->args[1];
cfg.stream_config = dma_spec->args[2];
-   cfg.threshold = dma_spec->args[3];
+   cfg.features = dma_spec->args[3];
 
if ((cfg.channel_id >= STM32_DMA_MAX_CHANNELS) ||
(cfg.request_line >= STM32_DMA_MAX_REQUEST_ID)) {
-- 
2.19.0.605.g01d371f741-goog



[tip:perf/core] tools lib traceevent: Separate out tep_strerror() for strerror_r() issues

2018-10-08 Thread tip-bot for Steven Rostedt (VMware)
Commit-ID:  bbbab191c2c474d183e93799d008b412e97f5936
Gitweb: https://git.kernel.org/tip/bbbab191c2c474d183e93799d008b412e97f5936
Author: Steven Rostedt (VMware) 
AuthorDate: Fri, 5 Oct 2018 12:18:16 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:30:45 -0300

tools lib traceevent: Separate out tep_strerror() for strerror_r() issues

While working on having PowerTop use libtracevent as a shared object
library, Tzvetomir hit "str_error_r not defined". This was added by commit
c3cec9e68f12d ("tools lib traceevent: Use str_error_r()") because
strerror_r() has two definitions, where one is GNU specific, and the other
is XSI complient. The strerror_r() is in a wrapper str_error_r() to keep the
code from having to worry about which compiler is being used.

The problem is that str_error_r() is external to libtraceevent, and not part
of the library. If it is used as a shared object then the tools using it
will need to define that function. I do not want that function defined in
libtraceevent itself, as it is out of scope for that library.

As there's only a single instance of this call, and its in the traceevent
library's own tep_strerror() function, we can copy what was done in perf,
and create yet another external file that undefs _GNU_SOURCE to use the more
portable version of the function. We don't need to worry about the errors
that strerror_r() returns. If the buffer isn't big enough, we simply
truncate it.

Reported-by: Tzvetomir Stoyanov 
Signed-off-by: Steven Rostedt (VMware) 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Tzvetomir Stoyanov (VMware) 
Cc: linux trace devel 
Link: http://lkml.kernel.org/r/20181005121816.484e6...@gandalf.local.home
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/traceevent/Build |  1 +
 tools/lib/traceevent/event-parse.c | 30 
 .../{str_error_r.c => traceevent/tep_strerror.c}   | 40 ++
 3 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/tools/lib/traceevent/Build b/tools/lib/traceevent/Build
index c681d0575d16..0050c145d806 100644
--- a/tools/lib/traceevent/Build
+++ b/tools/lib/traceevent/Build
@@ -4,6 +4,7 @@ libtraceevent-y += trace-seq.o
 libtraceevent-y += parse-filter.o
 libtraceevent-y += parse-utils.o
 libtraceevent-y += kbuffer-parse.o
+libtraceevent-y += tep_strerror.o
 
 plugin_jbd2-y += plugin_jbd2.o
 plugin_hrtimer-y  += plugin_hrtimer.o
diff --git a/tools/lib/traceevent/event-parse.c 
b/tools/lib/traceevent/event-parse.c
index 7980fc6c3bac..233179a712d6 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -6201,35 +6200,6 @@ enum tep_errno tep_parse_event(struct tep_handle 
*pevent, const char *buf,
return __parse_event(pevent, &event, buf, size, sys);
 }
 
-#undef _PE
-#define _PE(code, str) str
-static const char * const tep_error_str[] = {
-   TEP_ERRORS
-};
-#undef _PE
-
-int tep_strerror(struct tep_handle *pevent __maybe_unused,
-enum tep_errno errnum, char *buf, size_t buflen)
-{
-   int idx;
-   const char *msg;
-
-   if (errnum >= 0) {
-   str_error_r(errnum, buf, buflen);
-   return 0;
-   }
-
-   if (errnum <= __TEP_ERRNO__START ||
-   errnum >= __TEP_ERRNO__END)
-   return -1;
-
-   idx = errnum - __TEP_ERRNO__START - 1;
-   msg = tep_error_str[idx];
-   snprintf(buf, buflen, "%s", msg);
-
-   return 0;
-}
-
 int get_field_val(struct trace_seq *s, struct tep_format_field *field,
  const char *name, struct tep_record *record,
  unsigned long long *val, int err)
diff --git a/tools/lib/str_error_r.c b/tools/lib/traceevent/tep_strerror.c
similarity index 54%
copy from tools/lib/str_error_r.c
copy to tools/lib/traceevent/tep_strerror.c
index 6aad8308a0ac..4ac26445b2f6 100644
--- a/tools/lib/str_error_r.c
+++ b/tools/lib/traceevent/tep_strerror.c
@@ -1,8 +1,16 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: LGPL-2.1
 #undef _GNU_SOURCE
 #include 
 #include 
-#include 
+
+#include "event-parse.h"
+
+#undef _PE
+#define _PE(code, str) str
+static const char * const tep_error_str[] = {
+   TEP_ERRORS
+};
+#undef _PE
 
 /*
  * The tools so far have been using the strerror_r() GNU variant, that returns
@@ -18,10 +26,28 @@
  * interface, but uses the portable XSI variant of strerror_r(), so that users
  * rest asured that the provided buffer is used and it is what is returned.
  */
-char *str_error_r(int errnum, char *buf, size_t buflen)
+int tep_strerror(struct tep_handle *tep __maybe_unused,
+enum tep_errno errnum, char *buf, size_t buflen)
 {
-   int err = strerror_r(errnum, buf, buflen);
-   if (err)
-   snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, [buf], 
%zd)=%d", errnum, buflen, err);
-   r

[tip:perf/core] tools lib traceevent, perf tools: Move struct tep_handler definition in a local header file

2018-10-08 Thread tip-bot for Tzvetomir Stoyanov
Commit-ID:  bb3dd7e7c4d5e024d607c0ec06c2a2fb9408cc99
Gitweb: https://git.kernel.org/tip/bb3dd7e7c4d5e024d607c0ec06c2a2fb9408cc99
Author: Tzvetomir Stoyanov 
AuthorDate: Fri, 5 Oct 2018 12:22:25 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 15:05:37 -0300

tools lib traceevent, perf tools: Move struct tep_handler definition in a local 
header file

As traceevent is going to be transferred into a proper library,
its local data should be protected from the library users.
This patch encapsulates struct tep_handler into a local header,
not visible outside of the library. It implements also a bunch
of new APIs, which library users can use to access tep_handler members.

Signed-off-by: Tzvetomir Stoyanov 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: linux trace devel 
Cc: tzvetomir stoyanov 
Link: http://lkml.kernel.org/r/2018100515.52215...@gandalf.local.home
Signed-off-by: Steven Rostedt (VMware) 
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/traceevent/Build   |   1 +
 tools/lib/traceevent/event-parse-api.c   | 275 +++
 tools/lib/traceevent/event-parse-local.h |  92 +++
 tools/lib/traceevent/event-parse.c   |   2 +
 tools/lib/traceevent/event-parse.h   | 228 -
 tools/lib/traceevent/event-plugin.c  |   1 +
 tools/lib/traceevent/parse-filter.c  |   1 +
 tools/perf/util/trace-event-parse.c  |  25 +--
 tools/perf/util/trace-event-read.c   |   2 +-
 9 files changed, 416 insertions(+), 211 deletions(-)

diff --git a/tools/lib/traceevent/Build b/tools/lib/traceevent/Build
index 0050c145d806..ba54bfce0b0b 100644
--- a/tools/lib/traceevent/Build
+++ b/tools/lib/traceevent/Build
@@ -5,6 +5,7 @@ libtraceevent-y += parse-filter.o
 libtraceevent-y += parse-utils.o
 libtraceevent-y += kbuffer-parse.o
 libtraceevent-y += tep_strerror.o
+libtraceevent-y += event-parse-api.o
 
 plugin_jbd2-y += plugin_jbd2.o
 plugin_hrtimer-y  += plugin_hrtimer.o
diff --git a/tools/lib/traceevent/event-parse-api.c 
b/tools/lib/traceevent/event-parse-api.c
new file mode 100644
index ..61f7149085ee
--- /dev/null
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -0,0 +1,275 @@
+// SPDX-License-Identifier: LGPL-2.1
+/*
+ * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt 
+ *
+ */
+
+#include "event-parse.h"
+#include "event-parse-local.h"
+#include "event-utils.h"
+
+/**
+ * tep_get_first_event - returns the first event in the events array
+ * @tep: a handle to the tep_handle
+ *
+ * This returns pointer to the first element of the events array
+ * If @tep is NULL, NULL is returned.
+ */
+struct tep_event_format *tep_get_first_event(struct tep_handle *tep)
+{
+   if (tep && tep->events)
+   return tep->events[0];
+
+   return NULL;
+}
+
+/**
+ * tep_get_events_count - get the number of defined events
+ * @tep: a handle to the tep_handle
+ *
+ * This returns number of elements in event array
+ * If @tep is NULL, 0 is returned.
+ */
+int tep_get_events_count(struct tep_handle *tep)
+{
+   if(tep)
+   return tep->nr_events;
+   return 0;
+}
+
+/**
+ * tep_set_flag - set event parser flag
+ * @tep: a handle to the tep_handle
+ * @flag: flag, or combination of flags to be set
+ * can be any combination from enum tep_flag
+ *
+ * This sets a flag or mbination of flags  from enum tep_flag
+  */
+void tep_set_flag(struct tep_handle *tep, int flag)
+{
+   if(tep)
+   tep->flags |= flag;
+}
+
+unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data)
+{
+   unsigned short swap;
+
+   if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
+   return data;
+
+   swap = ((data & 0xffULL) << 8) |
+   ((data & (0xffULL << 8)) >> 8);
+
+   return swap;
+}
+
+unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data)
+{
+   unsigned int swap;
+
+   if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
+   return data;
+
+   swap = ((data & 0xffULL) << 24) |
+   ((data & (0xffULL << 8)) << 8) |
+   ((data & (0xffULL << 16)) >> 8) |
+   ((data & (0xffULL << 24)) >> 24);
+
+   return swap;
+}
+
+unsigned long long
+__tep_data2host8(struct tep_handle *pevent, unsigned long long data)
+{
+   unsigned long long swap;
+
+   if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
+   return data;
+
+   swap = ((data & 0xffULL) << 56) |
+   ((data & (0xffULL << 8)) << 40) |
+   ((data & (0xffULL << 16)) << 24) |
+   ((data & (0xffULL << 24)) << 8) |
+   ((data & (0xffULL << 32)) >> 8) |
+   ((data & (0xffULL << 40)) >> 24) |
+   ((data & (0xffULL << 48)) >> 40) |
+   ((data & (0xffULL << 56)) >> 56);
+
+   return swap;
+}
+
+/**
+ * tep_get_header_page_size - get size of the hea

[tip:perf/core] perf python: More portable way to make CFLAGS work with clang

2018-10-08 Thread tip-bot for Eduardo Habkost
Commit-ID:  8b2f245faa6238e28a1d801e8633515251d1acfc
Gitweb: https://git.kernel.org/tip/8b2f245faa6238e28a1d801e8633515251d1acfc
Author: Eduardo Habkost 
AuthorDate: Fri, 5 Oct 2018 17:40:58 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:30:45 -0300

perf python: More portable way to make CFLAGS work with clang

The existing code that tries to make CFLAGS compatible with clang
doesn't work with Python 3.

Instead of trying to touch _sysconfigdata.build_time_vars directly,
change the dictionary returned by disutils.sysconfig.get_config_vars().
This works on both Python 2 and Python 3.

Signed-off-by: Eduardo Habkost 
Reported-by: Arnaldo Carvalho de Melo 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: http://lkml.kernel.org/r/20181005204058.7966-3-ehabk...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/setup.py | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 261a55e7e1b2..63f758c655d5 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -9,12 +9,14 @@ def clang_has_option(option):
 
 cc = getenv("CC")
 if cc == "clang":
-from _sysconfigdata import build_time_vars
-build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", 
build_time_vars["CFLAGS"])
-if not clang_has_option("-mcet"):
-build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"])
-if not clang_has_option("-fcf-protection"):
-build_time_vars["CFLAGS"] = sub("-fcf-protection", "", 
build_time_vars["CFLAGS"])
+from distutils.sysconfig import get_config_vars
+vars = get_config_vars()
+for var in ('CFLAGS', 'OPT'):
+vars[var] = sub("-specs=[^ ]+", "", vars[var])
+if not clang_has_option("-mcet"):
+vars[var] = sub("-mcet", "", vars[var])
+if not clang_has_option("-fcf-protection"):
+vars[var] = sub("-fcf-protection", "", vars[var])
 
 from distutils.core import setup, Extension
 


[tip:perf/core] perf python: Make clang_has_option() work on Python 3

2018-10-08 Thread tip-bot for Eduardo Habkost
Commit-ID:  e13a5d69c31d35538e80176d54d95b6addf4dcbf
Gitweb: https://git.kernel.org/tip/e13a5d69c31d35538e80176d54d95b6addf4dcbf
Author: Eduardo Habkost 
AuthorDate: Fri, 5 Oct 2018 17:40:57 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:30:44 -0300

perf python: Make clang_has_option() work on Python 3

Use a bytes literal so it works with Python 3's version of Popen().
Note that the b"..." syntax requires Python 2.6+.

Signed-off-by: Eduardo Habkost 
Cc: Adrian Hunter 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: http://lkml.kernel.org/r/20181005204058.7966-2-ehabk...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 1942f6dd24f6..261a55e7e1b2 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -5,7 +5,7 @@ from subprocess import Popen, PIPE
 from re import sub
 
 def clang_has_option(option):
-return [o for o in Popen(['clang', option], 
stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
+return [o for o in Popen(['clang', option], 
stderr=PIPE).stderr.readlines() if b"unknown argument" in o] == [ ]
 
 cc = getenv("CC")
 if cc == "clang":


[tip:perf/core] perf tools: Free temporary 'sys' string in read_event_files()

2018-10-08 Thread tip-bot for Sanskriti Sharma
Commit-ID:  1e44224fb0528b4c0cc176bde2bb31e9127eb14b
Gitweb: https://git.kernel.org/tip/1e44224fb0528b4c0cc176bde2bb31e9127eb14b
Author: Sanskriti Sharma 
AuthorDate: Tue, 2 Oct 2018 10:29:14 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:46 -0300

perf tools: Free temporary 'sys' string in read_event_files()

For each system in a given pevent, read_event_files() reads in a
temporary 'sys' string.  Be sure to free this string before moving onto
to the next system and/or leaving read_event_files().

Fixes the following coverity complaints:

  Error: RESOURCE_LEAK (CWE-772):

  tools/perf/util/trace-event-read.c:343: overwrite_var: Overwriting
  "sys" in "sys = read_string()" leaks the storage that "sys" points to.

  tools/perf/util/trace-event-read.c:353: leaked_storage: Variable "sys"
  going out of scope leaks the storage it points to.

Signed-off-by: Sanskriti Sharma 
Reviewed-by: Jiri Olsa 
Cc: Joe Lawrence 
Link: 
http://lkml.kernel.org/r/1538490554-8161-6-git-send-email-sansh...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/trace-event-read.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/trace-event-read.c 
b/tools/perf/util/trace-event-read.c
index a278e1eee5f5..add8441de579 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -347,9 +347,12 @@ static int read_event_files(struct tep_handle *pevent)
for (x=0; x < count; x++) {
size = read8(pevent);
ret = read_event_file(pevent, sys, size);
-   if (ret)
+   if (ret) {
+   free(sys);
return ret;
+   }
}
+   free(sys);
}
return 0;
 }


[tip:perf/core] perf tools: Avoid double free in read_event_file()

2018-10-08 Thread tip-bot for Sanskriti Sharma
Commit-ID:  470c8f7c88de013d266e1b61044efe8937728b7f
Gitweb: https://git.kernel.org/tip/470c8f7c88de013d266e1b61044efe8937728b7f
Author: Sanskriti Sharma 
AuthorDate: Tue, 2 Oct 2018 10:29:13 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:46 -0300

perf tools: Avoid double free in read_event_file()

The temporary 'buf' buffer allocated in read_event_file() may be freed
twice.  Move the free() call to the common function exit point.

Fixes the following coverity complaints:

  Error: USE_AFTER_FREE (CWE-825):
  tools/perf/util/trace-event-read.c:309: double_free: Calling "free"
  frees pointer "buf" which has already been freed.

Signed-off-by: Sanskriti Sharma 
Reviewed-by: Jiri Olsa 
Cc: Joe Lawrence 
Link: 
http://lkml.kernel.org/r/1538490554-8161-5-git-send-email-sansh...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/trace-event-read.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/util/trace-event-read.c 
b/tools/perf/util/trace-event-read.c
index b98ee2a2eb44..a278e1eee5f5 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -297,10 +297,8 @@ static int read_event_file(struct tep_handle *pevent, char 
*sys,
}
 
ret = do_read(buf, size);
-   if (ret < 0) {
-   free(buf);
+   if (ret < 0)
goto out;
-   }
 
ret = parse_event_file(pevent, buf, size, sys);
if (ret < 0)


[tip:perf/core] perf tools: Free 'printk' string in parse_ftrace_printk()

2018-10-08 Thread tip-bot for Sanskriti Sharma
Commit-ID:  9c8a182e5a73e01afd11742a2ab887bf338fdafd
Gitweb: https://git.kernel.org/tip/9c8a182e5a73e01afd11742a2ab887bf338fdafd
Author: Sanskriti Sharma 
AuthorDate: Tue, 2 Oct 2018 10:29:12 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:45 -0300

perf tools: Free 'printk' string in parse_ftrace_printk()

parse_ftrace_printk() tokenizes and parses a line, calling strdup() each
iteration.  Add code to free this temporary format string duplicate.

Fixes the following coverity complaints:

  Error: RESOURCE_LEAK (CWE-772):
  tools/perf/util/trace-event-parse.c:158: overwrite_var: Overwriting
  "printk" in "printk = strdup(fmt + 1)" leaks the storage that "printk"
  points to.

  tools/perf/util/trace-event-parse.c:162: leaked_storage: Variable
  "printk" going out of scope leaks the storage it points to.

Signed-off-by: Sanskriti Sharma 
Reviewed-by: Jiri Olsa 
Cc: Joe Lawrence 
Link: 
http://lkml.kernel.org/r/1538490554-8161-4-git-send-email-sansh...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/trace-event-parse.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/trace-event-parse.c 
b/tools/perf/util/trace-event-parse.c
index a4d7de1c96d1..02f97f5dd588 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -158,6 +158,7 @@ void parse_ftrace_printk(struct tep_handle *pevent,
printk = strdup(fmt+1);
line = strtok_r(NULL, "\n", &next);
tep_register_print_string(pevent, printk, addr);
+   free(printk);
}
 }
 


[tip:perf/core] perf tools: Cleanup trace-event-info 'tdata' leak

2018-10-08 Thread tip-bot for Sanskriti Sharma
Commit-ID:  faedbf3fd19f2511a39397f76359e4cc6ee93072
Gitweb: https://git.kernel.org/tip/faedbf3fd19f2511a39397f76359e4cc6ee93072
Author: Sanskriti Sharma 
AuthorDate: Tue, 2 Oct 2018 10:29:11 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:45 -0300

perf tools: Cleanup trace-event-info 'tdata' leak

Free tracing_data structure in tracing_data_get() error paths.

Fixes the following coverity complaint:

  Error: RESOURCE_LEAK (CWE-772):
  leaked_storage: Variable "tdata" going out of scope leaks the storage

Signed-off-by: Sanskriti Sharma 
Reviewed-by: Jiri Olsa 
Cc: Joe Lawrence 
Link: 
http://lkml.kernel.org/r/1538490554-8161-3-git-send-email-sansh...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/trace-event-info.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/trace-event-info.c 
b/tools/perf/util/trace-event-info.c
index 7b0ca7cbb7de..8ad8e755127b 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -531,12 +531,14 @@ struct tracing_data *tracing_data_get(struct list_head 
*pattrs,
 "/tmp/perf-XX");
if (!mkstemp(tdata->temp_file)) {
pr_debug("Can't make temp file");
+   free(tdata);
return NULL;
}
 
temp_fd = open(tdata->temp_file, O_RDWR);
if (temp_fd < 0) {
pr_debug("Can't read '%s'", tdata->temp_file);
+   free(tdata);
return NULL;
}
 


[tip:perf/core] perf strbuf: Match va_{add,copy} with va_end

2018-10-08 Thread tip-bot for Sanskriti Sharma
Commit-ID:  ce49d8436cffa9b7a6a5f110879d53e89dbc6746
Gitweb: https://git.kernel.org/tip/ce49d8436cffa9b7a6a5f110879d53e89dbc6746
Author: Sanskriti Sharma 
AuthorDate: Tue, 2 Oct 2018 10:29:10 -0400
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:44 -0300

perf strbuf: Match va_{add,copy} with va_end

Ensure that all code paths in strbuf_addv() call va_end() on the
ap_saved copy that was made.

Fixes the following coverity complaint:

  Error: VARARGS (CWE-237): [#def683]
  tools/perf/util/strbuf.c:106: missing_va_end: va_end was not called
  for "ap_saved".

Signed-off-by: Sanskriti Sharma 
Reviewed-by: Jiri Olsa 
Cc: Joe Lawrence 
Link: 
http://lkml.kernel.org/r/1538490554-8161-2-git-send-email-sansh...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/strbuf.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index 3d1cf5bf7f18..9005fbe0780e 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -98,19 +98,25 @@ static int strbuf_addv(struct strbuf *sb, const char *fmt, 
va_list ap)
 
va_copy(ap_saved, ap);
len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
-   if (len < 0)
+   if (len < 0) {
+   va_end(ap_saved);
return len;
+   }
if (len > strbuf_avail(sb)) {
ret = strbuf_grow(sb, len);
-   if (ret)
+   if (ret) {
+   va_end(ap_saved);
return ret;
+   }
len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, 
ap_saved);
va_end(ap_saved);
if (len > strbuf_avail(sb)) {
pr_debug("this should not happen, your vsnprintf is 
broken");
+   va_end(ap_saved);
return -EINVAL;
}
}
+   va_end(ap_saved);
return strbuf_setlen(sb, sb->len + len);
 }
 


[tip:perf/core] perf test: S390 does not support watchpoints in test 22

2018-10-08 Thread tip-bot for Thomas Richter
Commit-ID:  0e24147d69c9357b1ccb54a9bc028eb9a9f9ed1a
Gitweb: https://git.kernel.org/tip/0e24147d69c9357b1ccb54a9bc028eb9a9f9ed1a
Author: Thomas Richter 
AuthorDate: Fri, 28 Sep 2018 12:53:35 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:44 -0300

perf test: S390 does not support watchpoints in test 22

S390 does not support the perf_event_open system call for
attribute type PERF_TYPE_BREAKPOINT. This results in test
failure for test 22:

  [root@s8360046 perf]# ./perf test 22
  22: Watchpoint:
  22.1: Read Only Watchpoint: FAILED!
  22.2: Write Only Watchpoint   : FAILED!
  22.3: Read / Write Watchpoint : FAILED!
  22.4: Modify Watchpoint   : FAILED!
  [root@s8360046 perf]#

Add s390 support to avoid these tests being executed on
s390 platform:

  [root@s8360046 perf]# ./perf test 22
  [root@s8360046 perf]# ./perf test -v 22
  22: Watchpoint: Disabled
  [root@s8360046 perf]#

Signed-off-by: Thomas Richter 
Reviewed-by: Ravi Bangoria 
Cc: Heiko Carstens 
Cc: Hendrik Brueckner 
Cc: Martin Schwidefsky 
Link: http://lkml.kernel.org/r/20180928105335.67179-1-tmri...@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/builtin-test.c |  1 +
 tools/perf/tests/tests.h|  1 +
 tools/perf/tests/wp.c   | 12 
 3 files changed, 14 insertions(+)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 54ca7d87236f..12c09e0ece71 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -123,6 +123,7 @@ static struct test generic_tests[] = {
{
.desc = "Watchpoint",
.func = test__wp,
+   .is_supported = test__wp_is_supported,
.subtest = {
.skip_if_fail   = false,
.get_nr = test__wp_subtest_get_nr,
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 8e26a4148f30..b82f55fcc294 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -109,6 +109,7 @@ int test__unit_number__scnprint(struct test *test, int 
subtest);
 int test__mem2node(struct test *t, int subtest);
 
 bool test__bp_signal_is_supported(void);
+bool test__wp_is_supported(void);
 
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index 017a99317f94..f89e6806557b 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -227,3 +227,15 @@ int test__wp(struct test *test __maybe_unused, int i)
 
return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
 }
+
+/* The s390 so far does not have support for
+ * instruction breakpoint using the perf_event_open() system call.
+ */
+bool test__wp_is_supported(void)
+{
+#if defined(__s390x__)
+   return false;
+#else
+   return true;
+#endif
+}


[tip:perf/core] perf auxtrace: Include missing asm/bitsperlong.h to get BITS_PER_LONG

2018-10-08 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  291ed51deee49ff35d0824fb7050538b449964d6
Gitweb: https://git.kernel.org/tip/291ed51deee49ff35d0824fb7050538b449964d6
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 25 Sep 2018 11:52:10 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:43 -0300

perf auxtrace: Include missing asm/bitsperlong.h to get BITS_PER_LONG

The auxtrace.h header references BITS_PER_LONG without including the
header where it is defined, getting it by luck from some other header,
fix it.

Cc: Adrian Hunter 
Cc: Alexander Sverdlin 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-v04ydmbh7tvpcctf3zld9...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/auxtrace.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 0a6ce9c4fc11..d88f6e9eb461 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../perf.h"
 #include "event.h"


[tip:perf/core] tools include: Adopt linux/bits.h

2018-10-08 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  ba4aa02b417f08a0bee5e7b8ed70cac788a7c854
Gitweb: https://git.kernel.org/tip/ba4aa02b417f08a0bee5e7b8ed70cac788a7c854
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 25 Sep 2018 10:55:59 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 8 Oct 2018 14:23:43 -0300

tools include: Adopt linux/bits.h

So that we reduce the difference of tools/include/linux/bitops.h to the
original kernel file, include/linux/bitops.h, trying to remove the need
to define BITS_PER_LONG, to avoid clashes with asm/bitsperlong.h.

And the things removed from tools/include/linux/bitops.h are really in
linux/bits.h, so that we can have a copy and then
tools/perf/check_headers.sh will tell us when new stuff gets added to
linux/bits.h so that we can check if it is useful and if any adjustment
needs to be done to the tools/{include,arch}/ copies.

Cc: Adrian Hunter 
Cc: Alexander Sverdlin 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Wang Nan 
Link: https://lkml.kernel.org/n/tip-y1sqyydvfzo0bjjoj4zsl...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/include/linux/bitops.h| 7 ++-
 {include => tools/include}/linux/bits.h | 0
 tools/perf/check-headers.sh | 1 +
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/include/linux/bitops.h b/tools/include/linux/bitops.h
index acc704bd3998..0b0ef3abc966 100644
--- a/tools/include/linux/bitops.h
+++ b/tools/include/linux/bitops.h
@@ -3,8 +3,6 @@
 #define _TOOLS_LINUX_BITOPS_H_
 
 #include 
-#include 
-
 #ifndef __WORDSIZE
 #define __WORDSIZE (__SIZEOF_LONG__ * 8)
 #endif
@@ -12,10 +10,9 @@
 #ifndef BITS_PER_LONG
 # define BITS_PER_LONG __WORDSIZE
 #endif
+#include 
+#include 
 
-#define BIT_MASK(nr)   (1UL << ((nr) % BITS_PER_LONG))
-#define BIT_WORD(nr)   ((nr) / BITS_PER_LONG)
-#define BITS_PER_BYTE  8
 #define BITS_TO_LONGS(nr)  DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
 #define BITS_TO_U64(nr)DIV_ROUND_UP(nr, BITS_PER_BYTE * 
sizeof(u64))
 #define BITS_TO_U32(nr)DIV_ROUND_UP(nr, BITS_PER_BYTE * 
sizeof(u32))
diff --git a/include/linux/bits.h b/tools/include/linux/bits.h
similarity index 100%
copy from include/linux/bits.h
copy to tools/include/linux/bits.h
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 466540ee8ea7..c72cc73a6b09 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -14,6 +14,7 @@ include/uapi/linux/sched.h
 include/uapi/linux/stat.h
 include/uapi/linux/vhost.h
 include/uapi/sound/asound.h
+include/linux/bits.h
 include/linux/hash.h
 include/uapi/linux/hw_breakpoint.h
 arch/x86/include/asm/disabled-features.h


Re: [GIT PULL 00/12] perf/core improvements and fixes

2018-10-08 Thread Ingo Molnar


* Arnaldo Carvalho de Melo  wrote:

> Hi Ingo,
> 
>   Please consider pulling,
> 
> - Arnaldo
> 
> Test results at the end of this message, as usual.
> 
> The following changes since commit 7c5314b88da6d5af98239786772a1c44cc5eb67d:
> 
>   perf/x86/intel: Add quirk for Goldmont Plus (2018-10-02 10:14:33 +0200)
> 
> 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.20-20181008
> 
> for you to fetch changes up to bb3dd7e7c4d5e024d607c0ec06c2a2fb9408cc99:
> 
>   tools lib traceevent, perf tools: Move struct tep_handler definition in a 
> local header file (2018-10-08 15:05:37 -0300)
> 
> 
> perf/core improvements and fixes:
> 
> . Fix building the python bindings with python3, which fixes some
>   problems with building with clang on Clear Linux (Eduardo Habkost)
> 
> . Fix coverity warnings, fixing up some error paths and plugging
>   some temporary small buffer leaks (Sanskriti Sharma)
> 
> . Adopt a wrapper for strerror_r() for the same reasons as recently
>   for libbpf (Steven Rostedt)
> 
> . S390 does not support watchpoints in 'perf test 22', check if
>   that test is supported by the arch. (Thomas Richter)
> 
> Signed-off-by: Arnaldo Carvalho de Melo 
> 
> 
> Arnaldo Carvalho de Melo (2):
>   tools include: Adopt linux/bits.h
>   perf auxtrace: Include missing asm/bitsperlong.h to get BITS_PER_LONG
> 
> Eduardo Habkost (2):
>   perf python: Make clang_has_option() work on Python 3
>   perf python: More portable way to make CFLAGS work with clang
> 
> Sanskriti Sharma (5):
>   perf strbuf: Match va_{add,copy} with va_end
>   perf tools: Cleanup trace-event-info 'tdata' leak
>   perf tools: Free 'printk' string in parse_ftrace_printk()
>   perf tools: Avoid double free in read_event_file()
>   perf tools: Free temporary 'sys' string in read_event_files()
> 
> Steven Rostedt (VMware) (1):
>   tools lib traceevent: Separate out tep_strerror() for strerror_r() 
> issues
> 
> Thomas Richter (1):
>   perf test: S390 does not support watchpoints in test 22
> 
> Tzvetomir Stoyanov (1):
>   tools lib traceevent, perf tools: Move struct tep_handler definition in 
> a local header file
> 
>  tools/include/linux/bitops.h |   7 +-
>  tools/include/linux/bits.h   |  26 +++
>  tools/lib/traceevent/Build   |   2 +
>  tools/lib/traceevent/event-parse-api.c   | 275 
> +++
>  tools/lib/traceevent/event-parse-local.h |  92 +++
>  tools/lib/traceevent/event-parse.c   |  32 +---
>  tools/lib/traceevent/event-parse.h   | 228 -
>  tools/lib/traceevent/event-plugin.c  |   1 +
>  tools/lib/traceevent/parse-filter.c  |   1 +
>  tools/lib/traceevent/tep_strerror.c  |  53 ++
>  tools/perf/check-headers.sh  |   1 +
>  tools/perf/tests/builtin-test.c  |   1 +
>  tools/perf/tests/tests.h |   1 +
>  tools/perf/tests/wp.c|  12 ++
>  tools/perf/util/auxtrace.h   |   1 +
>  tools/perf/util/setup.py |  16 +-
>  tools/perf/util/strbuf.c |  10 +-
>  tools/perf/util/trace-event-info.c   |   2 +
>  tools/perf/util/trace-event-parse.c  |  26 +--
>  tools/perf/util/trace-event-read.c   |  11 +-
>  20 files changed, 539 insertions(+), 259 deletions(-)
>  create mode 100644 tools/include/linux/bits.h
>  create mode 100644 tools/lib/traceevent/event-parse-api.c
>  create mode 100644 tools/lib/traceevent/event-parse-local.h
>  create mode 100644 tools/lib/traceevent/tep_strerror.c

Pulled, thanks a lot Arnaldo!

Ingo


Re: linux-next: build failure after merge of the ext4 tree

2018-10-08 Thread Theodore Y. Ts'o
On Tue, Oct 09, 2018 at 10:51:02AM +1100, Stephen Rothwell wrote:
> Hi Ted,
> 
> After merging the ext4 tree, today's linux-next build (arm
> multi_v7_defconfig) failed like this:

Oops, my bad.  Thanks for catching this.  I failed to a new helper
function inside #ifdef CONFIG_QUOTA .. #endif.

Should be fixed now.

- Ted


Re: [PATCH 2/6] phy: am654-mmc-phy: Add Support for MMC PHY on AM654 Devices

2018-10-08 Thread Kishon Vijay Abraham I
Hi Uffe,

On Monday 08 October 2018 05:02 PM, Ulf Hansson wrote:
> On 4 October 2018 at 13:14, Faiz Abbas  wrote:
>> Add driver support for the MMC physical layer present
>> on TI's AM654 devices.
>>
>> Signed-off-by: Faiz Abbas 
>> Signed-off-by: Sekhar Nori 
> 
> I assume Kishon would like to pick up this through his tree? If not,
> please tell and I can do it, with his ack.

yes, I'll pick this in my tree.

> 
> Reviewed-by: Ulf Hansson 

Thanks
Kishon

> 
> Kind regards
> Uffe
> 
>> ---
>>  drivers/phy/ti/Kconfig |   7 +
>>  drivers/phy/ti/Makefile|   1 +
>>  drivers/phy/ti/phy-am654-mmc.c | 291 +
>>  3 files changed, 299 insertions(+)
>>  create mode 100644 drivers/phy/ti/phy-am654-mmc.c
>>
>> diff --git a/drivers/phy/ti/Kconfig b/drivers/phy/ti/Kconfig
>> index 20503562666c..ea5fe4db01c8 100644
>> --- a/drivers/phy/ti/Kconfig
>> +++ b/drivers/phy/ti/Kconfig
>> @@ -76,3 +76,10 @@ config TWL4030_USB
>>   family chips (including the TWL5030 and TPS659x0 devices).
>>   This transceiver supports high and full speed devices plus,
>>   in host mode, low speed.
>> +
>> +config PHY_AM654_MMC
>> +   bool "TI AM654 MMC PHY Support"
>> +   select GENERIC_PHY
>> +   help
>> + This option enables support for the Physical layer for MMC host
>> + controllers present on TI AM654 SOCs.
>> diff --git a/drivers/phy/ti/Makefile b/drivers/phy/ti/Makefile
>> index 9f361756eaf2..5b2db2d164a5 100644
>> --- a/drivers/phy/ti/Makefile
>> +++ b/drivers/phy/ti/Makefile
>> @@ -6,3 +6,4 @@ obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o
>>  obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o
>>  obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
>>  obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
>> +obj-$(CONFIG_PHY_AM654_MMC)+= phy-am654-mmc.o
>> diff --git a/drivers/phy/ti/phy-am654-mmc.c b/drivers/phy/ti/phy-am654-mmc.c
>> new file mode 100644
>> index ..91255947fb67
>> --- /dev/null
>> +++ b/drivers/phy/ti/phy-am654-mmc.c
>> @@ -0,0 +1,291 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * phy-am654-mmc.c - MMC PHY driver for TI's AM654 SOCs
>> + *
>> + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com
>> + *
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/* MMC PHY Registers */
>> +#define PHYCTRL_CTRL1_REG  0x00
>> +#define PHYCTRL_CTRL2_REG  0x04
>> +#define PHYCTRL_CTRL3_REG  0x08
>> +#define PHYCTRL_CTRL4_REG  0x0C
>> +#define PHYCTRL_CTRL5_REG  0x10
>> +#define PHYCTRL_CTRL6_REG  0x14
>> +#define PHYCTRL_STAT1_REG  0x30
>> +#define PHYCTRL_STAT2_REG  0x34
>> +
>> +#define IOMUX_ENABLE_SHIFT 31
>> +#define IOMUX_ENABLE_MASK  BIT(IOMUX_ENABLE_SHIFT)
>> +#define OTAPDLYENA_SHIFT   20
>> +#define OTAPDLYENA_MASKBIT(OTAPDLYENA_SHIFT)
>> +#define OTAPDLYSEL_SHIFT   12
>> +#define OTAPDLYSEL_MASKGENMASK(15, 12)
>> +#define STRBSEL_SHIFT  24
>> +#define STRBSEL_MASK   GENMASK(27, 24)
>> +#define SEL50_SHIFT8
>> +#define SEL50_MASK BIT(SEL50_SHIFT)
>> +#define SEL100_SHIFT   9
>> +#define SEL100_MASKBIT(SEL100_SHIFT)
>> +#define DLL_TRIM_ICP_SHIFT 4
>> +#define DLL_TRIM_ICP_MASK  GENMASK(7, 4)
>> +#define DR_TY_SHIFT20
>> +#define DR_TY_MASK GENMASK(22, 20)
>> +#define ENDLL_SHIFT1
>> +#define ENDLL_MASK BIT(ENDLL_SHIFT)
>> +#define DLLRDY_SHIFT   0
>> +#define DLLRDY_MASKBIT(DLLRDY_SHIFT)
>> +#define PDB_SHIFT  0
>> +#define PDB_MASK   BIT(PDB_SHIFT)
>> +#define CALDONE_SHIFT  1
>> +#define CALDONE_MASK   BIT(CALDONE_SHIFT)
>> +
>> +#define DRIVER_STRENGTH_50_OHM 0x0
>> +#define DRIVER_STRENGTH_33_OHM 0x1
>> +#define DRIVER_STRENGTH_66_OHM 0x2
>> +#define DRIVER_STRENGTH_100_OHM0x3
>> +#define DRIVER_STRENGTH_40_OHM 0x4
>> +
>> +static struct regmap_config am654_mmc_phy_regmap_config = {
>> +   .reg_bits = 32,
>> +   .val_bits = 32,
>> +   .reg_stride = 4,
>> +   .fast_io = true,
>> +};
>> +
>> +struct am654_mmc_phy {
>> +   struct regmap *reg_base;
>> +   struct clk *mmcclk;
>> +   int otap_del_sel;
>> +   int trm_icp;
>> +   int drv_strength;
>> +};
>> +
>> +static int am654_mmc_phy_init(struct phy *phy)
>> +{
>> +   struct am654_mmc_phy *mmc_phy = phy_get_drvdata(phy);
>> +   int ret;
>> +   u32 val;
>> +
>> +   /* Reset registers to default value */
>> +   regmap_write(mmc_phy->reg_base, PHYCTRL_CTRL1_REG, 0x1);
>> +   regmap_write(mmc_phy->reg_base, PHYCTRL_CTRL4_REG, 0x0);
>> +   regmap_write(mmc_phy->reg_base, PHYCTRL_CTRL5_REG, 0x0);
>> +
>> +   /* Calibrate IO lines */
>> +   regmap_update_bits(mmc_phy->reg_base, PHYCTRL_CTRL1_REG,
>> +

linux-next: manual merge of the staging tree with the vfs tree

2018-10-08 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the staging tree got a conflict in:

  drivers/staging/dgnc/dgnc_tty.c

between commits:

  b68166ef8fd9 ("dgnc: leave TIOC[GS]SOFTCAR to ldisc")
  e002c6f1ccb9 ("dgnc: don't bother with (empty) stub for TCXONC")
  79273fc94ee9 ("dgnc: break-related ioctls won't reach ->ioctl()")
  246d394c9cc5 ("dgnc: TIOCM... won't reach ->ioctl()")

from the vfs tree and commit:

  3268357865d6 ("staging: dgnc: delete the driver")

from the staging tree.

I fixed it up (I just removed the file) 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.

-- 
Cheers,
Stephen Rothwell


pgp4G2TROuGFd.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/4] gpio: Assign gpio_irq_chip::parents to non-stack pointer

2018-10-08 Thread kbuild test robot
Hi Stephen,

I love your patch! Perhaps something to improve:

[auto build test WARNING on gpio/for-next]
[also build test WARNING on v4.19-rc7 next-20181008]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stephen-Boyd/gpio-chip-cascade-fixes/20181009-041639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 
for-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg80211.h:4869: warning: Excess function parameter 'ptr' 
description in 'reg_query_regdb_wmm'
   include/net/cfg8

kernel BUG at fs/block_dev.c:LINE!

2018-10-08 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:0854ba5ff5c9 Merge git://git.kernel.org/pub/scm/linux/kern..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1554ec0640
kernel config:  https://syzkaller.appspot.com/x/.config?x=88e9a8a39dc0be2d
dashboard link: https://syzkaller.appspot.com/bug?extid=82909b30c4657137bf84
compiler:   gcc (GCC) 8.0.1 20180413 (experimental)
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=1033197640
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=165db54e40

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+82909b30c4657137b...@syzkaller.appspotmail.com

 loop1: p1
 loop4: p1
 loop3: p1
 loop5: p1
[ cut here ]
kernel BUG at fs/block_dev.c:1627!
invalid opcode:  [#1] PREEMPT SMP KASAN
CPU: 1 PID: 6913 Comm: syz-executor753 Not tainted 4.19.0-rc7+ #53
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011

RIP: 0010:blkdev_get+0x65f/0xb50 fs/block_dev.c:1627
Code: ff ff ff 0f 84 4d 03 00 00 48 89 85 f0 fe ff ff e8 f6 fa 9d ff 48 8b  
85 f0 fe ff ff 48 85 c0 0f 84 9b 00 00 00 e8 e1 fa 9d ff <0f> 0b e8 da fa  
9d ff 4c 89 e2 48 b8 00 00 00 00 00 fc ff df 48 c1

RSP: 0018:8801c0a8f578 EFLAGS: 00010293
RAX: 8801c083a700 RBX:  RCX: 81e0da52
RDX:  RSI: 81e0daaf RDI: 0005
RBP: 8801c0a8f6a8 R08: 8801c083a700 R09: fbfff12424f0
R10: fbfff12424f0 R11: 89212783 R12: 8801d3ac0318
R13: 8801d3bee2d8 R14: 8801d3bee2c0 R15: 8801d3ac0280
FS:  01359880() GS:8801daf0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 00606ed8 CR3: 0001c12d3000 CR4: 001406e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 blkdev_open+0x1fb/0x280 fs/block_dev.c:1775
 do_dentry_open+0x499/0x1250 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3418 [inline]
 path_openat+0x12bf/0x5160 fs/namei.c:3534
 do_filp_open+0x255/0x380 fs/namei.c:3564
 do_sys_open+0x568/0x700 fs/open.c:1063
 __do_sys_openat fs/open.c:1090 [inline]
 __se_sys_openat fs/open.c:1084 [inline]
 __x64_sys_openat+0x9d/0x100 fs/open.c:1084
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445589
Code: fd cd fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7  
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff  
ff 0f 83 cb cd fb ff c3 66 2e 0f 1f 84 00 00 00 00

RSP: 002b:7ffd31e04eb8 EFLAGS: 0286 ORIG_RAX: 0101
RAX: ffda RBX: 2080 RCX: 00445589
RDX: 008001a0 RSI: 2080 RDI: ff9c
RBP: 706e692f7665642f R08: 0001 R09: 0001
R10:  R11: 0286 R12: 00069554
R13: 00402870 R14:  R15: 
Modules linked in:
---[ end trace bcaf07e3e9ad4219 ]---
RIP: 0010:blkdev_get+0x65f/0xb50 fs/block_dev.c:1627
Code: ff ff ff 0f 84 4d 03 00 00 48 89 85 f0 fe ff ff e8 f6 fa 9d ff 48 8b  
85 f0 fe ff ff 48 85 c0 0f 84 9b 00 00 00 e8 e1 fa 9d ff <0f> 0b e8 da fa  
9d ff 4c 89 e2 48 b8 00 00 00 00 00 fc ff df 48 c1

RSP: 0018:8801c0a8f578 EFLAGS: 00010293
RAX: 8801c083a700 RBX:  RCX: 81e0da52
RDX:  RSI: 81e0daaf RDI: 0005
RBP: 8801c0a8f6a8 R08: 8801c083a700 R09: fbfff12424f0
R10: fbfff12424f0 R11: 89212783 R12: 8801d3ac0318
R13: 8801d3bee2d8 R14: 8801d3bee2c0 R15: 8801d3ac0280
FS:  01359880() GS:8801daf0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 00606ed8 CR3: 0001c12d3000 CR4: 001406e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkal...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with  
syzbot.

syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches


Re: [PATCH] RCU: Adjust the comment of function rcu_is_watching

2018-10-08 Thread Paul E. McKenney
On Mon, Oct 08, 2018 at 06:50:41AM +, zhouzho...@gmail.com wrote:
> From: Zhouyi Zhou 
> 
> Because RCU avoids interrupting idle CPUs, rcu_is_watching is used to
> test whether or not it is currently legal to run RCU read-side 
> critical sections on this CPU. 
> 
> First sentence and last sentence of current comment for rcu_is_watching
> have opposite meaning of what is expected.  
> 
> Signed-off-by: Zhouyi Zhou 

Good eyes!  Applied and pushed, thank you!

Thanx, Paul

> ---
>  kernel/rcu/tree.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 0b760c1..adb04ea 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -1010,12 +1010,12 @@ void rcu_irq_enter_irqson(void)
>  }
> 
>  /**
> - * rcu_is_watching - see if RCU thinks that the current CPU is idle
> + * rcu_is_watching - see if RCU thinks that the current CPU is not idle
>   *
>   * Return true if RCU is watching the running CPU, which means that this
>   * CPU can safely enter RCU read-side critical sections.  In other words,
> - * if the current CPU is in its idle loop and is neither in an interrupt
> - * or NMI handler, return true.
> + * if the current CPU is not in its idle loop or is in an interrupt or
> + * NMI handler, return true.
>   */
>  bool notrace rcu_is_watching(void)
>  {
> -- 
> 2.1.4
> 



Re: [RESEND PATCH 1/2] mtd: spi-nor: add macros related to MICRON flash

2018-10-08 Thread Tudor Ambarus



On 09/19/2018 07:50 AM, Yogesh Gaur wrote:
> Some MICRON related macros in spi-nor domain were ST.
> Rename entries related to STMicroelectronics under macro SNOR_MFR_ST.
> 
> Added entry of MFR Id for Micron flashes, 0x002C.
> 
> Signed-off-by: Yogesh Gaur 

Reviewed-by: Tudor Ambarus 

> ---
>  drivers/mtd/spi-nor/spi-nor.c | 9 ++---
>  include/linux/mtd/cfi.h   | 1 +
>  include/linux/mtd/spi-nor.h   | 3 ++-
>  3 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index f028277..33a55bc 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -271,6 +271,7 @@ static inline int set_4byte(struct spi_nor *nor, const 
> struct flash_info *info,
>   u8 cmd;
>  
>   switch (JEDEC_MFR(info)) {
> + case SNOR_MFR_ST:
>   case SNOR_MFR_MICRON:
>   /* Some Micron need WREN command; all will accept it */
>   need_wren = true;
> @@ -1096,7 +1097,7 @@ static int spi_nor_is_locked(struct mtd_info *mtd, 
> loff_t ofs, uint64_t len)
>   { "mx66l1g45g",  INFO(0xc2201b, 0, 64 * 1024, 2048, SECT_4K | 
> SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
>   { "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, SPI_NOR_QUAD_READ) 
> },
>  
> - /* Micron */
> + /* Micron <--> ST Micro */
>   { "n25q016a",INFO(0x20bb15, 0, 64 * 1024,   32, SECT_4K | 
> SPI_NOR_QUAD_READ) },
>   { "n25q032", INFO(0x20ba16, 0, 64 * 1024,   64, SPI_NOR_QUAD_READ) 
> },
>   { "n25q032a",INFO(0x20bb16, 0, 64 * 1024,   64, SPI_NOR_QUAD_READ) 
> },
> @@ -2502,6 +2503,7 @@ static int spi_nor_init_params(struct spi_nor *nor,
>   params->quad_enable = macronix_quad_enable;
>   break;
>  
> + case SNOR_MFR_ST:
>   case SNOR_MFR_MICRON:
>   break;
>  
> @@ -2876,8 +2878,9 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>   mtd->_resume = spi_nor_resume;
>  
>   /* NOR protection support for STmicro/Micron chips and similar */
> - if (JEDEC_MFR(info) == SNOR_MFR_MICRON ||
> - info->flags & SPI_NOR_HAS_LOCK) {
> + if (JEDEC_MFR(info) == SNOR_MFR_ST ||
> + JEDEC_MFR(info) == SNOR_MFR_MICRON ||
> + info->flags & SPI_NOR_HAS_LOCK) {
>   nor->flash_lock = stm_lock;
>   nor->flash_unlock = stm_unlock;
>   nor->flash_is_locked = stm_is_locked;
> diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
> index 9b57a9b..cbf7716 100644
> --- a/include/linux/mtd/cfi.h
> +++ b/include/linux/mtd/cfi.h
> @@ -377,6 +377,7 @@ struct cfi_fixup {
>  #define CFI_MFR_SHARP0x00B0
>  #define CFI_MFR_SST  0x00BF
>  #define CFI_MFR_ST   0x0020 /* STMicroelectronics */
> +#define CFI_MFR_MICRON   0x002C /* Micron */
>  #define CFI_MFR_TOSHIBA  0x0098
>  #define CFI_MFR_WINBOND  0x00DA
>  
> diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
> index c922e97..f43bfc5 100644
> --- a/include/linux/mtd/spi-nor.h
> +++ b/include/linux/mtd/spi-nor.h
> @@ -23,7 +23,8 @@
>  #define SNOR_MFR_ATMEL   CFI_MFR_ATMEL
>  #define SNOR_MFR_GIGADEVICE  0xc8
>  #define SNOR_MFR_INTEL   CFI_MFR_INTEL
> -#define SNOR_MFR_MICRON  CFI_MFR_ST /* ST Micro <--> Micron */
> +#define SNOR_MFR_ST  CFI_MFR_ST  /* ST Micro */
> +#define SNOR_MFR_MICRON  CFI_MFR_MICRON  /* Micron */
>  #define SNOR_MFR_MACRONIXCFI_MFR_MACRONIX
>  #define SNOR_MFR_SPANSIONCFI_MFR_AMD
>  #define SNOR_MFR_SST CFI_MFR_SST
> 


[PATCH] mm/thp: Correctly differentiate between mapped THP and PMD migration entry

2018-10-08 Thread Anshuman Khandual
A normal mapped THP page at PMD level should be correctly differentiated
from a PMD migration entry while walking the page table. A mapped THP would
additionally check positive for pmd_present() along with pmd_trans_huge()
as compared to a PMD migration entry. This just adds a new conditional test
differentiating the two while walking the page table.

Fixes: 616b8371539a6 ("mm: thp: enable thp migration in generic path")
Signed-off-by: Anshuman Khandual 
---
On X86, pmd_trans_huge() and is_pmd_migration_entry() are always mutually
exclusive which makes the current conditional block work for both mapped
and migration entries. This is not same with arm64 where pmd_trans_huge()
returns positive for both mapped and migration entries. Could some one
please explain why pmd_trans_huge() has to return false for migration
entries which just install swap bits and its still a PMD ? Nonetheless
pmd_present() seems to be a better check to distinguish between mapped
and (non-mapped non-present) migration entries without any ambiguity.

 mm/page_vma_mapped.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index ae3c2a3..b384396 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -161,7 +161,8 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
pmde = READ_ONCE(*pvmw->pmd);
if (pmd_trans_huge(pmde) || is_pmd_migration_entry(pmde)) {
pvmw->ptl = pmd_lock(mm, pvmw->pmd);
-   if (likely(pmd_trans_huge(*pvmw->pmd))) {
+   if (likely(pmd_trans_huge(*pvmw->pmd) &&
+   pmd_present(*pvmw->pmd))) {
if (pvmw->flags & PVMW_MIGRATION)
return not_found(pvmw);
if (pmd_page(*pvmw->pmd) != page)
-- 
2.7.4



[RFC PATCH 1/2] net/ncsi: Don't enable all channels when HWA available

2018-10-08 Thread Samuel Mendoza-Jonas
NCSI hardware arbitration allows multiple packages to be enabled at once
and share the same wiring. If the NCSI driver recognises that HWA is
available it unconditionally enables all packages and channels; but that
is a configuration decision rather than something required by HWA.
Additionally the current implementation will not failover on link events
which can cause connectivity to be lost unless the interface is manually
bounced.

Retain basic HWA support but remove the separate configuration path to
enable all channels, leaving this to be handled by a later
implementation.

Signed-off-by: Samuel Mendoza-Jonas 
---
 net/ncsi/ncsi-aen.c|  3 +--
 net/ncsi/ncsi-manage.c | 51 +++---
 2 files changed, 9 insertions(+), 45 deletions(-)

diff --git a/net/ncsi/ncsi-aen.c b/net/ncsi/ncsi-aen.c
index 25e483e8278b..65f47a648be3 100644
--- a/net/ncsi/ncsi-aen.c
+++ b/net/ncsi/ncsi-aen.c
@@ -86,8 +86,7 @@ static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
!(state == NCSI_CHANNEL_ACTIVE && !(data & 0x1)))
return 0;
 
-   if (!(ndp->flags & NCSI_DEV_HWA) &&
-   state == NCSI_CHANNEL_ACTIVE)
+   if (state == NCSI_CHANNEL_ACTIVE)
ndp->flags |= NCSI_DEV_RESHUFFLE;
 
ncsi_stop_channel_monitor(nc);
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 091284760d21..665bee25ec44 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -112,10 +112,8 @@ static void ncsi_channel_monitor(struct timer_list *t)
default:
netdev_err(ndp->ndev.dev, "NCSI Channel %d timed out!\n",
   nc->id);
-   if (!(ndp->flags & NCSI_DEV_HWA)) {
-   ncsi_report_link(ndp, true);
-   ndp->flags |= NCSI_DEV_RESHUFFLE;
-   }
+   ncsi_report_link(ndp, true);
+   ndp->flags |= NCSI_DEV_RESHUFFLE;
 
ncsi_stop_channel_monitor(nc);
 
@@ -952,35 +950,6 @@ static bool ncsi_check_hwa(struct ncsi_dev_priv *ndp)
return false;
 }
 
-static int ncsi_enable_hwa(struct ncsi_dev_priv *ndp)
-{
-   struct ncsi_package *np;
-   struct ncsi_channel *nc;
-   unsigned long flags;
-
-   /* Move all available channels to processing queue */
-   spin_lock_irqsave(&ndp->lock, flags);
-   NCSI_FOR_EACH_PACKAGE(ndp, np) {
-   NCSI_FOR_EACH_CHANNEL(np, nc) {
-   WARN_ON_ONCE(nc->state != NCSI_CHANNEL_INACTIVE ||
-!list_empty(&nc->link));
-   ncsi_stop_channel_monitor(nc);
-   list_add_tail_rcu(&nc->link, &ndp->channel_queue);
-   }
-   }
-   spin_unlock_irqrestore(&ndp->lock, flags);
-
-   /* We can have no channels in extremely case */
-   if (list_empty(&ndp->channel_queue)) {
-   netdev_err(ndp->ndev.dev,
-  "NCSI: No available channels for HWA\n");
-   ncsi_report_link(ndp, false);
-   return -ENOENT;
-   }
-
-   return ncsi_process_next_channel(ndp);
-}
-
 static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
 {
struct ncsi_dev *nd = &ndp->ndev;
@@ -1047,6 +1016,10 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
ndp->active_package = list_next_entry(
ndp->active_package, node);
 
+   /* Check for HWA support */
+   if (ncsi_check_hwa(ndp))
+   netdev_info(ndp->ndev.dev, "NCSI: HWA available\n");
+
/* All available packages and channels are enumerated. The
 * enumeration happens for once when the NCSI interface is
 * started. So we need continue to start the interface after
@@ -1058,10 +1031,7 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
 */
if (!ndp->active_package) {
ndp->flags |= NCSI_DEV_PROBED;
-   if (ncsi_check_hwa(ndp))
-   ncsi_enable_hwa(ndp);
-   else
-   ncsi_choose_active_channel(ndp);
+   ncsi_choose_active_channel(ndp);
return;
}
 
@@ -1506,12 +1476,7 @@ int ncsi_start_dev(struct ncsi_dev *nd)
return 0;
}
 
-   if (ndp->flags & NCSI_DEV_HWA) {
-   netdev_info(ndp->ndev.dev, "NCSI: Enabling HWA mode\n");
-   ret = ncsi_enable_hwa(ndp);
-   } else {
-   ret = ncsi_choose_active_channel(ndp);
-   }
+   ret = ncsi_choose_active_channel(ndp);
 
return ret;
 }
-- 
2.19.0



[RFC PATCH 2/2] net/ncsi: Configure multi-package, multi-channel modes with failover

2018-10-08 Thread Samuel Mendoza-Jonas
This patch extends the ncsi-netlink interface with two new commands and
three new attributes to configure multiple packages and/or channels at
once, and configure specific failover modes.

NCSI_CMD_SET_PACKAGE mask and NCSI_CMD_SET_CHANNEL_MASK set a whitelist
of packages or channels allowed to be configured with the
NCSI_ATTR_PACKAGE_MASK and NCSI_ATTR_CHANNEL_MASK attributes
respectively. If one of these whitelists is set only packages or
channels matching the whitelist are considered for the channel queue in
ncsi_choose_active_channel().

These commands may also use the NCSI_ATTR_MULTI_FLAG to signal that
multiple packages or channels may be configured simultaneously. NCSI
hardware arbitration (HWA) must be available in order to enable
multi-package mode. Multi-channel mode is always available.

If the NCSI_ATTR_CHANNEL_ID attribute is present in the
NCSI_CMD_SET_CHANNEL_MASK command the it sets the preferred channel as
with the NCSI_CMD_SET_INTERFACE command. The combination of preferred
channel and channel whitelist defines a primary channel and the allowed
failover channels.
If the NCSI_ATTR_MULTI_FLAG attribute is also present then the preferred
channel is configured for Tx/Rx and the other channels are enabled only
for Rx.

Signed-off-by: Samuel Mendoza-Jonas 
---
 include/uapi/linux/ncsi.h |  16 +++
 net/ncsi/internal.h   |  11 +-
 net/ncsi/ncsi-aen.c   |   2 +-
 net/ncsi/ncsi-manage.c| 138 
 net/ncsi/ncsi-netlink.c   | 217 +-
 net/ncsi/ncsi-rsp.c   |   2 +-
 6 files changed, 312 insertions(+), 74 deletions(-)

diff --git a/include/uapi/linux/ncsi.h b/include/uapi/linux/ncsi.h
index 4c292ecbb748..035fba1693f9 100644
--- a/include/uapi/linux/ncsi.h
+++ b/include/uapi/linux/ncsi.h
@@ -23,6 +23,13 @@
  * optionally the preferred NCSI_ATTR_CHANNEL_ID.
  * @NCSI_CMD_CLEAR_INTERFACE: clear any preferred package/channel combination.
  * Requires NCSI_ATTR_IFINDEX.
+ * @NCSI_CMD_SET_PACKAGE_MASK: set a whitelist of allowed packages.
+ * @NCSI_CMD_SET_PACKAGE_MASK: set a whitelist of allowed channels.
+ * Requires NCSI_ATTR_IFINDEX and NCSI_ATTR_PACKAGE_MASK.
+ * @NCSI_CMD_SET_PACKAGE_MASK: set a whitelist of allowed channels.
+ * Requires NCSI_ATTR_IFINDEX, NCSI_ATTR_PACKAGE_ID, and
+ * NCSI_ATTR_CHANNEL_MASK. If NCSI_ATTR_CHANNEL_ID is present it sets
+ * the primary channel.
  * @NCSI_CMD_MAX: highest command number
  */
 enum ncsi_nl_commands {
@@ -30,6 +37,8 @@ enum ncsi_nl_commands {
NCSI_CMD_PKG_INFO,
NCSI_CMD_SET_INTERFACE,
NCSI_CMD_CLEAR_INTERFACE,
+   NCSI_CMD_SET_PACKAGE_MASK,
+   NCSI_CMD_SET_CHANNEL_MASK,
 
__NCSI_CMD_AFTER_LAST,
NCSI_CMD_MAX = __NCSI_CMD_AFTER_LAST - 1
@@ -43,6 +52,10 @@ enum ncsi_nl_commands {
  * @NCSI_ATTR_PACKAGE_LIST: nested array of NCSI_PKG_ATTR attributes
  * @NCSI_ATTR_PACKAGE_ID: package ID
  * @NCSI_ATTR_CHANNEL_ID: channel ID
+ * @NCSI_ATTR_MULTI_FLAG: flag to signal that multi-mode should be enabled with
+ * NCSI_CMD_SET_PACKAGE_MASK or NCSI_CMD_SET_CHANNEL_MASK.
+ * @NCSI_ATTR_PACKAGE_MASK: 32-bit mask of allowed packages.
+ * @NCSI_ATTR_CHANNEL_MASK: 32-bit mask of allowed channels.
  * @NCSI_ATTR_MAX: highest attribute number
  */
 enum ncsi_nl_attrs {
@@ -51,6 +64,9 @@ enum ncsi_nl_attrs {
NCSI_ATTR_PACKAGE_LIST,
NCSI_ATTR_PACKAGE_ID,
NCSI_ATTR_CHANNEL_ID,
+   NCSI_ATTR_MULTI_FLAG,
+   NCSI_ATTR_PACKAGE_MASK,
+   NCSI_ATTR_CHANNEL_MASK,
 
__NCSI_ATTR_AFTER_LAST,
NCSI_ATTR_MAX = __NCSI_ATTR_AFTER_LAST - 1
diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index 3d0a33b874f5..8437474d0a78 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -213,6 +213,10 @@ struct ncsi_package {
unsigned int channel_num; /* Number of channels */
struct list_head channels;/* List of chanels*/
struct list_head node;/* Form list of packages  */
+
+   bool multi_channel; /* Enable multiple channels  */
+   u32  channel_whitelist; /* Channels to configure */
+   struct ncsi_channel  *preferred_channel; /* Primary channel  */
 };
 
 struct ncsi_request {
@@ -280,8 +284,6 @@ struct ncsi_dev_priv {
unsigned intpackage_num; /* Number of packages */
struct list_headpackages;/* List of packages   */
struct ncsi_channel *hot_channel;/* Channel was ever active*/
-   struct ncsi_package *force_package;  /* Force a specific package   */
-   struct ncsi_channel *force_channel;  /* Force a specific channel   */
struct ncsi_request requests[256];   /* Request table  */
unsigned intrequest_id;  /* Last used request ID   */
 #define NCSI_REQ_START_IDX 1
@@ -294,6 +296,9 @@ struct ncsi_dev_priv {
struct list_headnode;/* Form 

Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function"

2018-10-08 Thread Steven Rostedt
On Mon, 8 Oct 2018 21:17:10 -0500
Josh Poimboeuf  wrote:

> I'm not really convinced we need objtool for this, maybe I'll try
> whipping up a POC.

Awesome!

I wasn't thinking of actually having objtool itself perform this task,
but instead breaking the internals of objtool up into more of a generic
infrastructure, that recordmcount.c, objtool, and whatever this does
can use.

-- Steve


Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function"

2018-10-08 Thread Steven Rostedt
On Tue, 9 Oct 2018 12:44:01 +0900
Masami Hiramatsu  wrote:

> On Fri, 05 Oct 2018 21:51:11 -0400
> Steven Rostedt  wrote:
> 
> > +typedef long dynfunc_t;
> > +
> > +struct dynfunc_struct;
> > +
> > +#define arch_dynfunc_trampoline(name, def) \
> > +   asm volatile (  \
> > +   ".globl dynfunc_" #name "; \n\t"\
> > +   "dynfunc_" #name ": \n\t"   \
> > +   "jmp " #def " \n\t" \
> > +   ".balign 8 \n \t"   \
> > +   : : : "memory" )
> > +  
> 
> I have just a question, what is this different from livepatch? :)

I actually thought about this a bit, but decided against it.

I didn't want to hook another infrastructure into the fentry nop. It's
already complex enough with kprobes, live patching and ftrace.

The ideal solution is what Peter suggested, and that's to patch the
call sites, and I think that is attainable with objtool modifications.

> 
> I think we can replace the first 5 bytes of the default function
> to jmp instruction (to alternative function) instead of making
> this trampoline.
> 
> IOW, as far as I can see, this is changing
> 
> 
> call %reg (or retpoline_reg)
> 
> 
> to 
> 
> 
> call dynfunc_A
> 
> dynfunc_A:
> jmp func_A or altered_func_A
> 
> 
> If so, why don't we put the jmp on default func_A directly?
> 
> call func_A
> 
> func_A:
> "jmp altered_func" or "original sequence"
> 
> (this is idealy same as jprobes did)
> 
> Of course we have to arbitrate it with ftrace (fentry) but it may
> not so hard (simplest way is just adding "notrace" on the default
> function)

Then we lose the 5 byte nop.

> 
> BTW, I think "dynamic_function" may not correct name, it may be
> "alternative_function" or something like that, because this
> function must be replaced system-wide and this means we can
> not use this for generic function pointer usage which depends
> on thread context (like file_operations). But good for something
> pluggable code (LSM?).

I don't like the name alternative, as that's usually a one shot deal
(SMP vs UP).

It is dynamic, as it's a function that changes dynamically. Yes its
global, but that's not mutually exclusive to dynamic.

The use case I want this for is for tracing. But it can be useful for
KVM and power management governors. Basically anything that has a
global function pointer (hmm, even the idle call can use this).

-- Steve


Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function"

2018-10-08 Thread Masami Hiramatsu
On Fri, 05 Oct 2018 21:51:11 -0400
Steven Rostedt  wrote:

> +typedef long dynfunc_t;
> +
> +struct dynfunc_struct;
> +
> +#define arch_dynfunc_trampoline(name, def)   \
> + asm volatile (  \
> + ".globl dynfunc_" #name "; \n\t"\
> + "dynfunc_" #name ": \n\t"   \
> + "jmp " #def " \n\t" \
> + ".balign 8 \n \t"   \
> + : : : "memory" )
> +

I have just a question, what is this different from livepatch? :)

I think we can replace the first 5 bytes of the default function
to jmp instruction (to alternative function) instead of making
this trampoline.

IOW, as far as I can see, this is changing


call %reg (or retpoline_reg)


to 


call dynfunc_A

dynfunc_A:
jmp func_A or altered_func_A


If so, why don't we put the jmp on default func_A directly?

call func_A

func_A:
"jmp altered_func" or "original sequence"

(this is idealy same as jprobes did)

Of course we have to arbitrate it with ftrace (fentry) but it may
not so hard (simplest way is just adding "notrace" on the default
function)

BTW, I think "dynamic_function" may not correct name, it may be
"alternative_function" or something like that, because this
function must be replaced system-wide and this means we can
not use this for generic function pointer usage which depends
on thread context (like file_operations). But good for something
pluggable code (LSM?).


Thank you,


-- 
Masami Hiramatsu 


Re: [LKP] [rcutorture] 5aa56a54ce: WARNING:at_kernel/rcu/rcutorture.c:#rcu_torture_fwd_prog

2018-10-08 Thread Paul E. McKenney
On Tue, Oct 09, 2018 at 09:52:05AM +0800, Rong Chen wrote:
> 
> 
> On 10/01/2018 07:00 AM, Paul E. McKenney wrote:
> >On Sun, Sep 30, 2018 at 11:16:14AM +0800, kernel test robot wrote:
> >>FYI, we noticed the following commit (built with gcc-7):
> >>
> >>commit: 5aa56a54ce92761e974f93592f69b75b8c2398a8 ("rcutorture: Add 
> >>call_rcu() flooding forward-progress tests")
> >>https://git.kernel.org/cgit/linux/kernel/git/paulmck/linux-rcu.git dev
> >>
> >>in testcase: trinity
> >>with following parameters:
> >>
> >>runtime: 300s
> >>
> >>test-description: Trinity is a linux system call fuzz tester.
> >>test-url: http://codemonkey.org.uk/projects/trinity/
> >>
> >>
> >>on test machine: qemu-system-x86_64 -enable-kvm -cpu Haswell,+smep,+smap 
> >>-smp 2 -m 512M
> >>
> >>caused below changes (please refer to attached dmesg/kmsg for entire 
> >>log/backtrace):
> >Ah, this is another complaint from my recent forward-progress additions
> >to rcutorture.  You can prevent rcutorture from doing this by adding
> >the rcutorture.fwd_progress=0 kernel boot parameter.
> Thanks, we will ignore the error.
> 
> >
> >But that aside, does it really make sense to run rcutorture and trinity
> >simultaneously?
> We use random kconfigs to test kernel, it's a coincidence to run
> them simultaneously.

I cannot argue with that!  Either way, the rcutorture.fwd_progress=0 kernel
boot parameter will prevent this error.

Thanx, Paul

> Best Regards,
> Rong Chen
> 
> >
> > Thanx, Paul
> >
> >>+--+++
> >>|  | 
> >>0b1aba265b | 5aa56a54ce |
> >>+--+++
> >>| boot_successes   | 0  
> >>| 0  |
> >>| boot_failures| 10 
> >>| 14 |
> >>| invoked_oom-killer:gfp_mask=0x   | 2  
> >>| 4  |
> >>| Mem-Info | 10 
> >>| 14 |
> >>| Kernel_panic-not_syncing:Out_of_memory_and_no_killable_processes | 2  
> >>| 4  |
> >>| INFO:trying_to_register_non-static_key   | 8  
> >>| 10 |
> >>| WARNING:at_mm/page_alloc.c:#__alloc_pages_slowpath   | 8  
> >>| 10 |
> >>| RIP:__alloc_pages_slowpath   | 8  
> >>| 10 |
> >>| IP-Config:Auto-configuration_of_network_failed   | 1  
> >>| 1  |
> >>| BUG:soft_lockup-CPU##stuck_for#s | 7  
> >>| 7  |
> >>| RIP:drm_mm_insert_node_in_range  | 2  
> >>| 1  |
> >>| Kernel_panic-not_syncing:softlockup:hung_tasks   | 7  
> >>| 7  |
> >>| RIP:rb_prev  | 3  
> >>| 1  |
> >>| RIP:separate_adjacent_colors | 1  
> >>| 4  |
> >>| RIP:__orc_find   | 1  
> >>||
> >>| WARNING:at_kernel/rcu/rcutorture.c:#rcu_torture_fwd_prog | 0  
> >>| 8  |
> >>| RIP:rcu_torture_fwd_prog | 0  
> >>| 8  |
> >>| RIP:add_hole | 0  
> >>| 1  |
> >>+--+++
> >>
> >>
> >>
> >>[  807.497867] WARNING: CPU: 0 PID: 74 at kernel/rcu/rcutorture.c:1840 
> >>rcu_torture_fwd_prog+0x7b6/0x967
> >>[  807.497867] CPU: 0 PID: 74 Comm: rcu_torture_fwd Tainted: GW 
> >>4.19.0-rc1-00150-g5aa56a5 #1
> >>[  807.497867] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> >>1.10.2-1 04/01/2014
> >>[  807.497867] RIP: 0010:rcu_torture_fwd_prog+0x7b6/0x967
> >>[  807.497867] Code: e3 13 00 eb bb 48 c7 05 22 08 4f 02 a0 08 08 85 c6 05 
> >>db b2 eb 03 00 e8 44 bd 0a 00 84 c0 0f 85 1a 01 00 00 49 83 fe 63 7f 02 
> >><0f> 0b 48 8b 85 60 ff ff ff 4c 8b 85 58 ff ff ff 4c 03 85 50 ff ff
> >>[  807.497867] RSP: :88000dadfe00 EFLAGS: 00010287
> >>[  807.497867] RAX:  RBX: dc00 RCX: 
> >>88000a838488
> >>[  807.497867] RDX: 110002175401 RSI: 88000fc0c5c0 RDI: 
> >>88000f1789a0
> >>[  807.497867] RBP: 88000dadfef0 R08: 0006 R09: 
> >>88000d35dc28
> >>[  807.497867] R10: 828001bf R11: 0040 R12: 
> >>000100079309
> >>[  807.497867] R13: 0009 R14: 0003 R15: 

linux-next: manual merge of the tip tree with the s290 tree

2018-10-08 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the tip tree got a conflict in:

  arch/s390/Kconfig

between commit:

  819eafaa7b58 ("s390/kasan: add initialization code and enable it")

from the s290 tree and commit:

  13ddb52c165b ("s390/jump_label: Switch to relative references")

from the tip 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.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/s390/Kconfig
index a45583f731f0,12dc4c1af96c..
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@@ -126,7 -120,7 +126,8 @@@ config S39
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_JUMP_LABEL
+   select HAVE_ARCH_JUMP_LABEL_RELATIVE
 +  select HAVE_ARCH_KASAN
select CPU_NO_EFFICIENT_FFS if !HAVE_MARCH_Z9_109_FEATURES
select HAVE_ARCH_SECCOMP_FILTER
select HAVE_ARCH_SOFT_DIRTY


pgplqwhgy867O.pgp
Description: OpenPGP digital signature


Re: [PATCH 4.18 000/168] 4.18.13-stable review

2018-10-08 Thread Andre Tomt

On 08. okt. 2018 20:29, Greg Kroah-Hartman wrote:

This is the start of the stable review cycle for the 4.18.13 release.
There are 168 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.


  CC [M]  net/ipv4/netfilter/nf_conntrack_proto_icmp.o
net/ipv4/netfilter/nf_conntrack_proto_icmp.c:373:3: error: ‘const struct 
nf_conntrack_l4proto’ has no member named ‘ctnl_timeout’; did you mean 
‘get_timeouts’?

  .ctnl_timeout  = {
   ^~~~
   get_timeouts

The problematic patch is:> 
netfilter-conntrack-timeout-interface-depend-on-config_nf_conntrack_timeout.patch


The stuff the commit message talks about seems like it was added in 
4.19-rc1, so this should not go into stable.


Kernel builds fine with this one patch reverted.


Re: [PATCH v2 2/2] treewide: use bus_find_device_by_fwnode

2018-10-08 Thread Silesh C V
Hello Rob,

Thanks for the review.

On Mon, Oct 8, 2018 at 9:15 PM Rob Herring  wrote:
>
> In the future, please use get_maintainers.pl and send to the right
> lists and people. Perhaps the coresight, i2c, network, nvmem and spi
> maintainers would like to see and be aware of this change.
>

Sure. Will send v3 with all the right people copied.

Regards,
Silesh


Re: [PATCH v2 1/2] Driver core: add bus_find_device_by_fwnode

2018-10-08 Thread Silesh C V
Hello Rafael,

On Mon, Oct 8, 2018 at 1:43 PM Rafael J. Wysocki  wrote:
>
> On Tue, Sep 25, 2018 at 7:29 AM Silesh C V  wrote:
> >
> > Some drivers need to find the device on a bus having a specific firmware
> > node. Currently, such drivers have their own implementations to do this.
> > Provide a helper similar to bus_find_device_by_name so that each driver
> > does not have to reinvent this.
> >
> > Signed-off-by: Silesh C V 
> >
> > ---
> >  drivers/base/bus.c | 26 ++
> >  include/linux/device.h |  3 +++
> >  2 files changed, 29 insertions(+)
> >
> > diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> > index 8bfd27e..148b198 100644
> > --- a/drivers/base/bus.c
> > +++ b/drivers/base/bus.c
> > @@ -17,6 +17,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include "base.h"
> >  #include "power/power.h"
> >
> > @@ -373,6 +374,31 @@ struct device *bus_find_device_by_name(struct bus_type 
> > *bus,
> >  }
> >  EXPORT_SYMBOL_GPL(bus_find_device_by_name);
> >
> > +static int match_fwnode(struct device *dev, void *data)
> > +{
> > +   struct fwnode_handle *fwnode = data;
> > +   struct device_node *of_node = to_of_node(fwnode);
> > +
> > +   if (of_node)
> > +   return dev->of_node == of_node;
> > +   else
> > +   return dev->fwnode == fwnode;
>
> Why don't you use dev_fwnode() here?
>

OK. Will send an updated patch.

Thanks,
Silesh.


Re: [PATCH v6 2/9] PCI: mediatek: Fixup class ID for MT7622 as PCI_CLASS_BRIDGE_PCI

2018-10-08 Thread Honghui Zhang
On Mon, 2018-10-08 at 18:23 +0100, Lorenzo Pieralisi wrote:
> On Mon, Oct 08, 2018 at 11:24:41AM +0800, honghui.zh...@mediatek.com wrote:
> > From: Honghui Zhang 
> > 
> > The PCIe controller of MT7622 has TYPE 1 configuration space type, but
> > the HW default class type values is invalid.
> > 
> > The commit 101c92dc80c8 ("PCI: mediatek: Set up vendor ID and class
> > type for MT7622") have set the class ID for MT7622 as
> > PCI_CLASS_BRIDGE_HOST, but it's not workable for MT7622:
> > 
> > In __pci_bus_assign_resources, the framework only setup bridge's
> > resource window only if class type is PCI_CLASS_BRIDGE_PCI. Or it
> > will leave the subordinary PCIe device's MMIO window un-touched.
> > 
> > Fixup the class type to PCI_CLASS_BRIDGE_PCI as most of the controller
> > driver do.
> 
> I think that this patch is correct but the commit log fails to pin point
> the problem. The IP you are programming is a root port, that's why you
> have to have the proper class code, the patch looks fine but I would
> like to peek Bjorn's brain on this since it is a fundamental concept.
> 

I'm a bit confused with the concepts of PCI_CLASS_BRIDGE_HOST and
PCI_CLASS_BRIDGE_PCI, from PCI express spec,
4.0r1.0(PCI_Express_Base_4.0r1.0_September-27-2017-c), Host Bridge is
"part of a Root Complex that connects a host CPU or CPUs to a
Hierarchy". While Root Complex defines as "A defined System Element that
includes at least one Host Bridge, Root port, or Root complex Integrated
Endpoint".

But according to my understanding, most of the root port IPs integrated
with a "PCI_CLASS_BRIDGE_PCI", which has type 1 configuration space and
could be saw as a pci device when using lspci.

And for MT7622, it integrated with block of internal control registers,
type 1 configuration space, and is considered as a root complex.

I'm not sure which CLASS type it should have:
>From PCI_Code-ID_r_1_10__v8-Nov_2017, class type of
0x0604(PCI_CLASS_BRIDGE_PCI) is defined as a PCI-to-PCI bridge, not
literally suitable for MT7622(which is a root complex)(In my personal
opinion). But it is the only workable CLASS type for MT7622 in current
kernel.

> If the kernel does not assign resources unless it detects a
> PCI_CLASS_BRIDGE_PCI this means that for components that are
> actually PCI_CLASS_BRIDGE_HOST their register set must come
> preprogrammed unless I am missing something.
> 

In the function pci_request_resource_alignment, it will by pass the
resource assignment for PCI_CLASS_BRIDGE_HOST, though I'm not figured
out why.

> I would like to get to the bottom of this since it is a fundamental
> enumeration concept.
> 

Do you like me to re-write the commit message for this patch and put the
above information in? Or just not mention the PCI_CLASS_BRIDGE_HOST
assign resource routine?

Thanks

> Thanks,
> Lorenzo
> 
> > 
> > Signed-off-by: Honghui Zhang 
> > Acked-by: Ryder Lee 
> > ---
> >  drivers/pci/controller/pcie-mediatek.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/pci/controller/pcie-mediatek.c 
> > b/drivers/pci/controller/pcie-mediatek.c
> > index 288b8e2..bcdac9b 100644
> > --- a/drivers/pci/controller/pcie-mediatek.c
> > +++ b/drivers/pci/controller/pcie-mediatek.c
> > @@ -432,7 +432,7 @@ static int mtk_pcie_startup_port_v2(struct 
> > mtk_pcie_port *port)
> > val = PCI_VENDOR_ID_MEDIATEK;
> > writew(val, port->base + PCIE_CONF_VEND_ID);
> >  
> > -   val = PCI_CLASS_BRIDGE_HOST;
> > +   val = PCI_CLASS_BRIDGE_PCI;
> > writew(val, port->base + PCIE_CONF_CLASS_ID);
> > }
> >  
> > -- 
> > 2.6.4
> > 




Re: [tip:x86/mm] kdump, proc/vmcore: Enable kdumping encrypted memory with SME enabled

2018-10-08 Thread lijiang
在 2018年10月08日 21:43, Borislav Petkov 写道:
> On Mon, Oct 08, 2018 at 10:59:09AM +0200, Borislav Petkov wrote:
>> On Mon, Oct 08, 2018 at 04:47:34PM +0800, lijiang wrote:
>>> It looks like a good way to avoid the 'ifdefined', and it's also good 
>>> enough for i386.
>>>
>>> But for other architectures, such as POWERPC/ARM..., we will also have to 
>>> add the same 
>>> function for every architecture. Otherwise, i guess that they also have a 
>>> same compile
>>> error on other architectures.
>>
>> Yap, just realized that and looking at the rest of fs/proc/vmcore.c -
>> such functions are defined with the __weak attribute. Lemme see if that
>> works better.
> 
> Seems so. I'll hammer on it more today:
> 
Great! Thank you, Borislav.

Regards,
Lianbo
> ---
>  fs/proc/vmcore.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
> index 42c32d06f7da..91ae16fbd7d5 100644
> --- a/fs/proc/vmcore.c
> +++ b/fs/proc/vmcore.c
> @@ -187,6 +187,16 @@ int __weak remap_oldmem_pfn_range(struct vm_area_struct 
> *vma,
>   return remap_pfn_range(vma, from, pfn, size, prot);
>  }
>  
> +/*
> + * Architectures which support memory encryption override this.
> + */
> +ssize_t __weak
> +copy_oldmem_page_encrypted(unsigned long pfn, char *buf, size_t csize,
> +unsigned long offset, int userbuf)
> +{
> + return copy_oldmem_page(pfn, buf, csize, offset, userbuf);
> +}
> +
>  /*
>   * Copy to either kernel or user space
>   */
> 


Re: [PATCH V10 1/8] irqchip: add C-SKY SMP interrupt controller

2018-10-08 Thread Guo Ren
Hi Marc,

On Mon, Oct 08, 2018 at 05:35:19PM +0100, Marc Zyngier wrote:
> Hi Guo,
> 
> On 04/10/18 18:22, Guo Ren wrote:
> >  - Irq-csky-mpintc is C-SKY smp system interrupt controller and it
> >could support 16 soft irqs, 16 private irqs, and 992 max common
> >irqs.
> >
> >Changelog:
> >  - pass checkpatch.pl
> >  - Move IPI_IRQ into the driver
> >  - Remove irq_set_default_host() and use set_ipi_irq_mapping()

 [...]

> >+#ifdef CONFIG_SMP
> >+static void csky_mpintc_send_ipi(const unsigned long *mask)
> >+{
> 
> Why isn't this a cpumask? It should be this driver's job to convert the
> cpumask to an interrupt-controller specific representation, and not the SMP
> code's.
Ok, use cpumask. 

 [...]

> >+#ifdef CONFIG_SMP
> >+set_send_ipi(&csky_mpintc_send_ipi);
> >+
> >+set_ipi_irq_mapping(&csky_mpintc_ipi_irq_mapping);
> 
> Since you seem to be inventing a new set_send_ipi callback, why don't you
> define it as:
> 
> void set_send_ipi(void (*func)(const struct cpumask *),
> unsigned int ipi_irq);
> after having created the mapping for the IPI interrupt? It would avoid this
> rather pointless mapping callback.

I'll define it to:

void set_send_ipi(void (*func)(const struct cpumask *));

IPI_IRQ only use software-irq-15 in mpintc driver, so arch needn't care
about irq-num.

/*
 * INTCL_SIGR[3:0] INTID
 * INTCL_SIGR[8:15] CPUMASK
 */
writel_relaxed((*mask) << 8 | IPI_IRQ, reg_base + INTCL_SIGR);

We direct put IPI_IRQ to the hw-reg for the target core.

Best Regards
 Guo Ren


[PATCH v8 1/5] Extract FPU context operations from entry.S

2018-10-08 Thread Alan Kao
We move __fstate_save and __fstate_restore to a new source
file, fpu.S.

Signed-off-by: Alan Kao 
Cc: Greentime Hu 
Cc: Vincent Chen 
Cc: Zong Li 
Cc: Nick Hu 
Reviewed-by: Christoph Hellwig 
---
 arch/riscv/kernel/Makefile |   1 +
 arch/riscv/kernel/entry.S  |  87 -
 arch/riscv/kernel/fpu.S| 106 +
 3 files changed, 107 insertions(+), 87 deletions(-)
 create mode 100644 arch/riscv/kernel/fpu.S

diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
index e1274fc..bd433efd 100644
--- a/arch/riscv/kernel/Makefile
+++ b/arch/riscv/kernel/Makefile
@@ -13,6 +13,7 @@ extra-y += vmlinux.lds
 obj-y  += cpu.o
 obj-y  += cpufeature.o
 obj-y  += entry.o
+obj-y  += fpu.o
 obj-y  += irq.o
 obj-y  += process.o
 obj-y  += ptrace.o
diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
index fa2c08e..59c02e2 100644
--- a/arch/riscv/kernel/entry.S
+++ b/arch/riscv/kernel/entry.S
@@ -357,93 +357,6 @@ ENTRY(__switch_to)
ret
 ENDPROC(__switch_to)
 
-ENTRY(__fstate_save)
-   li  a2,  TASK_THREAD_F0
-   add a0, a0, a2
-   li t1, SR_FS
-   csrs sstatus, t1
-   frcsr t0
-   fsd f0,  TASK_THREAD_F0_F0(a0)
-   fsd f1,  TASK_THREAD_F1_F0(a0)
-   fsd f2,  TASK_THREAD_F2_F0(a0)
-   fsd f3,  TASK_THREAD_F3_F0(a0)
-   fsd f4,  TASK_THREAD_F4_F0(a0)
-   fsd f5,  TASK_THREAD_F5_F0(a0)
-   fsd f6,  TASK_THREAD_F6_F0(a0)
-   fsd f7,  TASK_THREAD_F7_F0(a0)
-   fsd f8,  TASK_THREAD_F8_F0(a0)
-   fsd f9,  TASK_THREAD_F9_F0(a0)
-   fsd f10, TASK_THREAD_F10_F0(a0)
-   fsd f11, TASK_THREAD_F11_F0(a0)
-   fsd f12, TASK_THREAD_F12_F0(a0)
-   fsd f13, TASK_THREAD_F13_F0(a0)
-   fsd f14, TASK_THREAD_F14_F0(a0)
-   fsd f15, TASK_THREAD_F15_F0(a0)
-   fsd f16, TASK_THREAD_F16_F0(a0)
-   fsd f17, TASK_THREAD_F17_F0(a0)
-   fsd f18, TASK_THREAD_F18_F0(a0)
-   fsd f19, TASK_THREAD_F19_F0(a0)
-   fsd f20, TASK_THREAD_F20_F0(a0)
-   fsd f21, TASK_THREAD_F21_F0(a0)
-   fsd f22, TASK_THREAD_F22_F0(a0)
-   fsd f23, TASK_THREAD_F23_F0(a0)
-   fsd f24, TASK_THREAD_F24_F0(a0)
-   fsd f25, TASK_THREAD_F25_F0(a0)
-   fsd f26, TASK_THREAD_F26_F0(a0)
-   fsd f27, TASK_THREAD_F27_F0(a0)
-   fsd f28, TASK_THREAD_F28_F0(a0)
-   fsd f29, TASK_THREAD_F29_F0(a0)
-   fsd f30, TASK_THREAD_F30_F0(a0)
-   fsd f31, TASK_THREAD_F31_F0(a0)
-   sw t0, TASK_THREAD_FCSR_F0(a0)
-   csrc sstatus, t1
-   ret
-ENDPROC(__fstate_save)
-
-ENTRY(__fstate_restore)
-   li  a2,  TASK_THREAD_F0
-   add a0, a0, a2
-   li t1, SR_FS
-   lw t0, TASK_THREAD_FCSR_F0(a0)
-   csrs sstatus, t1
-   fld f0,  TASK_THREAD_F0_F0(a0)
-   fld f1,  TASK_THREAD_F1_F0(a0)
-   fld f2,  TASK_THREAD_F2_F0(a0)
-   fld f3,  TASK_THREAD_F3_F0(a0)
-   fld f4,  TASK_THREAD_F4_F0(a0)
-   fld f5,  TASK_THREAD_F5_F0(a0)
-   fld f6,  TASK_THREAD_F6_F0(a0)
-   fld f7,  TASK_THREAD_F7_F0(a0)
-   fld f8,  TASK_THREAD_F8_F0(a0)
-   fld f9,  TASK_THREAD_F9_F0(a0)
-   fld f10, TASK_THREAD_F10_F0(a0)
-   fld f11, TASK_THREAD_F11_F0(a0)
-   fld f12, TASK_THREAD_F12_F0(a0)
-   fld f13, TASK_THREAD_F13_F0(a0)
-   fld f14, TASK_THREAD_F14_F0(a0)
-   fld f15, TASK_THREAD_F15_F0(a0)
-   fld f16, TASK_THREAD_F16_F0(a0)
-   fld f17, TASK_THREAD_F17_F0(a0)
-   fld f18, TASK_THREAD_F18_F0(a0)
-   fld f19, TASK_THREAD_F19_F0(a0)
-   fld f20, TASK_THREAD_F20_F0(a0)
-   fld f21, TASK_THREAD_F21_F0(a0)
-   fld f22, TASK_THREAD_F22_F0(a0)
-   fld f23, TASK_THREAD_F23_F0(a0)
-   fld f24, TASK_THREAD_F24_F0(a0)
-   fld f25, TASK_THREAD_F25_F0(a0)
-   fld f26, TASK_THREAD_F26_F0(a0)
-   fld f27, TASK_THREAD_F27_F0(a0)
-   fld f28, TASK_THREAD_F28_F0(a0)
-   fld f29, TASK_THREAD_F29_F0(a0)
-   fld f30, TASK_THREAD_F30_F0(a0)
-   fld f31, TASK_THREAD_F31_F0(a0)
-   fscsr t0
-   csrc sstatus, t1
-   ret
-ENDPROC(__fstate_restore)
-
-
.section ".rodata"
/* Exception vector table */
 ENTRY(excp_vect_table)
diff --git a/arch/riscv/kernel/fpu.S b/arch/riscv/kernel/fpu.S
new file mode 100644
index 000..1defb06
--- /dev/null
+++ b/arch/riscv/kernel/fpu.S
@@ -0,0 +1,106 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2012 Regents of the University of California
+ * Copyright (C) 2017 SiFive
+ *
+ *   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.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ */
+
+#include 
+
+#include 
+#include 
+#inclu

[PATCH v8 3/5] Cleanup ISA string setting

2018-10-08 Thread Alan Kao
This patch cleanup the MARCH string passing to both compiler and
assembler.  Note that the CFLAGS should not contain "fd" before we
have mechnisms like kernel_fpu_begin/end in other architectures.

Signed-off-by: Alan Kao 
Cc: Greentime Hu 
Cc: Vincent Chen 
Cc: Zong Li 
Cc: Nick Hu 
---
 arch/riscv/Makefile | 19 ---
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 61ec424..01393e1 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -28,7 +28,6 @@ ifeq ($(CONFIG_ARCH_RV64I),y)

KBUILD_CFLAGS   += $(call cc-ifversion, -ge, 0500, 
-DCONFIG_ARCH_SUPPORTS_INT128)
 
-   KBUILD_MARCH = rv64im
KBUILD_LDFLAGS += -melf64lriscv
 else
BITS := 32
@@ -36,22 +35,20 @@ else
 
KBUILD_CFLAGS += -mabi=ilp32
KBUILD_AFLAGS += -mabi=ilp32
-   KBUILD_MARCH = rv32im
KBUILD_LDFLAGS += -melf32lriscv
 endif
 
 KBUILD_CFLAGS += -Wall
 
-ifeq ($(CONFIG_RISCV_ISA_A),y)
-   KBUILD_ARCH_A = a
-endif
-ifeq ($(CONFIG_RISCV_ISA_C),y)
-   KBUILD_ARCH_C = c
-endif
-
-KBUILD_AFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)fd$(KBUILD_ARCH_C)
+# ISA string setting
+riscv-march-$(CONFIG_ARCH_RV32I)   := rv32im
+riscv-march-$(CONFIG_ARCH_RV64I)   := rv64im
+riscv-march-$(CONFIG_RISCV_ISA_A)  := $(riscv-march-y)a
+riscv-march-y  := $(riscv-march-y)fd
+riscv-march-$(CONFIG_RISCV_ISA_C)  := $(riscv-march-y)c
+KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
+KBUILD_AFLAGS += -march=$(riscv-march-y)
 
-KBUILD_CFLAGS += -march=$(KBUILD_MARCH)$(KBUILD_ARCH_A)$(KBUILD_ARCH_C)
 KBUILD_CFLAGS += -mno-save-restore
 KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
 
-- 
2.7.4



[PATCH v8 5/5] Auto-detect whether a FPU exists

2018-10-08 Thread Alan Kao
We expect that a kernel with CONFIG_FPU=y can still support no-FPU
machines. To do so, the kernel should first examine the existence of a
FPU, then do nothing if a FPU does exist; otherwise, it should
disable/bypass all FPU-related functions.

In this patch, a new global variable, has_fpu, is created and determined
when parsing the hardware capability from device tree during booting.
This variable is used in those FPU-related functions.

Signed-off-by: Alan Kao 
Cc: Greentime Hu 
Cc: Vincent Chen 
Cc: Zong Li 
Cc: Nick Hu 
---
 arch/riscv/include/asm/switch_to.h | 8 
 arch/riscv/kernel/cpufeature.c | 8 
 arch/riscv/kernel/process.c| 4 +++-
 arch/riscv/kernel/signal.c | 6 --
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/riscv/include/asm/switch_to.h 
b/arch/riscv/include/asm/switch_to.h
index 093050b..7335590 100644
--- a/arch/riscv/include/asm/switch_to.h
+++ b/arch/riscv/include/asm/switch_to.h
@@ -56,13 +56,12 @@ static inline void __switch_to_aux(struct task_struct *prev,
fstate_restore(next, task_pt_regs(next));
 }
 
-#define DEFAULT_SSTATUS (SR_SPIE | SR_FS_INITIAL)
-
+extern bool has_fpu;
 #else
+#define has_fpu false
 #define fstate_save(task, regs) do { } while (0)
 #define fstate_restore(task, regs) do { } while (0)
 #define __switch_to_aux(__prev, __next) do { } while (0)
-#define DEFAULT_SSTATUS (SR_SPIE | SR_FS_OFF)
 #endif
 
 extern struct task_struct *__switch_to(struct task_struct *,
@@ -72,7 +71,8 @@ extern struct task_struct *__switch_to(struct task_struct *,
 do {   \
struct task_struct *__prev = (prev);\
struct task_struct *__next = (next);\
-   __switch_to_aux(__prev, __next);\
+   if (has_fpu)\
+   __switch_to_aux(__prev, __next);\
((last) = __switch_to(__prev, __next)); \
 } while (0)
 
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index 17011a8..46942e6 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -22,6 +22,9 @@
 #include 
 
 unsigned long elf_hwcap __read_mostly;
+#ifdef CONFIG_FPU
+bool has_fpu __read_mostly;
+#endif
 
 void riscv_fill_hwcap(void)
 {
@@ -58,4 +61,9 @@ void riscv_fill_hwcap(void)
elf_hwcap |= isa2hwcap[(unsigned char)(isa[i])];
 
pr_info("elf_hwcap is 0x%lx", elf_hwcap);
+
+#ifdef CONFIG_FPU
+   if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D))
+   has_fpu = true;
+#endif
 }
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index 07d5156..bef1999 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -76,7 +76,9 @@ void show_regs(struct pt_regs *regs)
 void start_thread(struct pt_regs *regs, unsigned long pc,
unsigned long sp)
 {
-   regs->sstatus = DEFAULT_SSTATUS;
+   regs->sstatus = SR_SPIE;
+   if (has_fpu)
+   regs->sstatus |= SR_FS_INITIAL;
regs->sepc = pc;
regs->sp = sp;
set_fs(USER_DS);
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 2450b82..f9b5e7e 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -98,7 +98,8 @@ static long restore_sigcontext(struct pt_regs *regs,
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_from_user(regs, &sc->sc_regs, sizeof(sc->sc_regs));
/* Restore the floating-point state. */
-   err |= restore_fp_state(regs, &sc->sc_fpregs);
+   if (has_fpu)
+   err |= restore_fp_state(regs, &sc->sc_fpregs);
return err;
 }
 
@@ -150,7 +151,8 @@ static long setup_sigcontext(struct rt_sigframe __user 
*frame,
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_to_user(&sc->sc_regs, regs, sizeof(sc->sc_regs));
/* Save the floating-point state. */
-   err |= save_fp_state(regs, &sc->sc_fpregs);
+   if (has_fpu)
+   err |= save_fp_state(regs, &sc->sc_fpregs);
return err;
 }
 
-- 
2.7.4



Re: [RESEND PATCH] ARM: prevent tracing IPI_CPU_BACKTRACE

2018-10-08 Thread Chunyan Zhang
Hi All,

If there's no comments, should I submit this patch on RMK's Patch system?

Thanks,
Chunyan

On 27 September 2018 at 11:41, Chunyan Zhang  wrote:
> From: Arnd Bergmann 
>
> When function tracing for IPIs is enabled, we get a warning for an
> overflow of the ipi_types array with the IPI_CPU_BACKTRACE type
> as triggered by raise_nmi():
>
> arch/arm/kernel/smp.c: In function 'raise_nmi':
> arch/arm/kernel/smp.c:489:2: error: array subscript is above array bounds 
> [-Werror=array-bounds]
> trace_ipi_raise(target, ipi_types[ipinr]);
>
> This is a correct warning as we actually overflow the array here.
>
> This patch raise_nmi() to call __smp_cross_call() instead of
> smp_cross_call(), to avoid calling into ftrace. For clarification,
> I'm also adding a two new code comments describing how this one
> is special.
>
> The warning appears to have shown up after patch e7273ff49acf
> ("ARM: 8488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI"), which
> changed the number assignment from '15' to '8', but as far as I can
> tell has existed since the IPI tracepoints were first introduced.
> If we decide to backport this patch to stable kernels, we probably
> need to backport e7273ff49acf as well.
>
> Resubmiting this patch is because that I found coverity is complaining
> the issue this patch fixed, and also I got the traces like below:
> "ipi_raise: target_mask=0001 (machine_suspend)" which actually was
> the TPS of suspend_resume[1] rather than ipi_raise.
>
> [1]
> https://elixir.bootlin.com/linux/latest/source/kernel/power/suspend.c#L80
>
> Signed-off-by: Arnd Bergmann 
> Fixes: e7273ff49acf ("ARM: 8488/1: Make IPI_CPU_BACKTRACE a "non-secure" SGI")
> Fixes: 365ec7b17327 ("ARM: add IPI tracepoints") # v3.17
> Signed-off-by: Chunyan Zhang 
> ---
>  arch/arm/include/asm/hardirq.h | 1 +
>  arch/arm/kernel/smp.c  | 6 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
> index cba23ea..7a88f16 100644
> --- a/arch/arm/include/asm/hardirq.h
> +++ b/arch/arm/include/asm/hardirq.h
> @@ -6,6 +6,7 @@
>  #include 
>  #include 
>
> +/* number of IPIS _not_ including IPI_CPU_BACKTRACE */
>  #define NR_IPI 7
>
>  typedef struct {
> diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> index 0978282..123be77 100644
> --- a/arch/arm/kernel/smp.c
> +++ b/arch/arm/kernel/smp.c
> @@ -75,6 +75,10 @@ enum ipi_msg_type {
> IPI_CPU_STOP,
> IPI_IRQ_WORK,
> IPI_COMPLETION,
> +   /*
> +* CPU_BACKTRACE is special and not included in NR_IPI
> +* or tracable with trace_ipi_*
> +*/
> IPI_CPU_BACKTRACE,
> /*
>  * SGI8-15 can be reserved by secure firmware, and thus may
> @@ -755,7 +759,7 @@ core_initcall(register_cpufreq_notifier);
>
>  static void raise_nmi(cpumask_t *mask)
>  {
> -   smp_cross_call(mask, IPI_CPU_BACKTRACE);
> +   _smp_cross_call(mask, IPI_CPU_BACKTRACE);
>  }
>
>  void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
> --
> 2.7.4
>


[PATCH v8 2/5] Refactor FPU code in signal setup/return procedures

2018-10-08 Thread Alan Kao
FPU-related logic is separated from normal signal handling path in
this patch.  Kernel can easily be configured to exclude those procedures
for no-FPU systems.

Signed-off-by: Alan Kao 
Cc: Greentime Hu 
Cc: Vincent Chen 
Cc: Zong Li 
Cc: Nick Hu 
Reviewed-by: Christoph Hellwig 
---
 arch/riscv/kernel/signal.c | 68 --
 1 file changed, 41 insertions(+), 27 deletions(-)

diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 718d0c9..6a18b98 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -37,45 +37,63 @@ struct rt_sigframe {
struct ucontext uc;
 };
 
-static long restore_d_state(struct pt_regs *regs,
-   struct __riscv_d_ext_state __user *state)
+static long restore_fp_state(struct pt_regs *regs,
+union __riscv_fp_state *sc_fpregs)
 {
long err;
+   struct __riscv_d_ext_state __user *state = &sc_fpregs->d;
+   size_t i;
+
err = __copy_from_user(¤t->thread.fstate, state, sizeof(*state));
-   if (likely(!err))
-   fstate_restore(current, regs);
+   if (unlikely(err))
+   return err;
+
+   fstate_restore(current, regs);
+
+   /* We support no other extension state at this time. */
+   for (i = 0; i < ARRAY_SIZE(sc_fpregs->q.reserved); i++) {
+   u32 value;
+
+   err = __get_user(value, &sc_fpregs->q.reserved[i]);
+   if (unlikely(err))
+   break;
+   if (value != 0)
+   return -EINVAL;
+   }
+
return err;
 }
 
-static long save_d_state(struct pt_regs *regs,
-   struct __riscv_d_ext_state __user *state)
+static long save_fp_state(struct pt_regs *regs,
+ union __riscv_fp_state *sc_fpregs)
 {
+   long err;
+   struct __riscv_d_ext_state __user *state = &sc_fpregs->d;
+   size_t i;
+
fstate_save(current, regs);
-   return __copy_to_user(state, ¤t->thread.fstate, sizeof(*state));
+   err = __copy_to_user(state, ¤t->thread.fstate, sizeof(*state));
+   if (unlikely(err))
+   return err;
+
+   /* We support no other extension state at this time. */
+   for (i = 0; i < ARRAY_SIZE(sc_fpregs->q.reserved); i++) {
+   err = __put_user(0, &sc_fpregs->q.reserved[i]);
+   if (unlikely(err))
+   break;
+   }
+
+   return err;
 }
 
 static long restore_sigcontext(struct pt_regs *regs,
struct sigcontext __user *sc)
 {
long err;
-   size_t i;
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_from_user(regs, &sc->sc_regs, sizeof(sc->sc_regs));
-   if (unlikely(err))
-   return err;
/* Restore the floating-point state. */
-   err = restore_d_state(regs, &sc->sc_fpregs.d);
-   if (unlikely(err))
-   return err;
-   /* We support no other extension state at this time. */
-   for (i = 0; i < ARRAY_SIZE(sc->sc_fpregs.q.reserved); i++) {
-   u32 value;
-   err = __get_user(value, &sc->sc_fpregs.q.reserved[i]);
-   if (unlikely(err))
-   break;
-   if (value != 0)
-   return -EINVAL;
-   }
+   err |= restore_fp_state(regs, &sc->sc_fpregs);
return err;
 }
 
@@ -124,14 +142,10 @@ static long setup_sigcontext(struct rt_sigframe __user 
*frame,
 {
struct sigcontext __user *sc = &frame->uc.uc_mcontext;
long err;
-   size_t i;
/* sc_regs is structured the same as the start of pt_regs */
err = __copy_to_user(&sc->sc_regs, regs, sizeof(sc->sc_regs));
/* Save the floating-point state. */
-   err |= save_d_state(regs, &sc->sc_fpregs.d);
-   /* We support no other extension state at this time. */
-   for (i = 0; i < ARRAY_SIZE(sc->sc_fpregs.q.reserved); i++)
-   err |= __put_user(0, &sc->sc_fpregs.q.reserved[i]);
+   err |= save_fp_state(regs, &sc->sc_fpregs);
return err;
 }
 
-- 
2.7.4



[PATCH v8 0/5] riscv: Add support to no-FPU systems

2018-10-08 Thread Alan Kao
This patchset adds an option, CONFIG_FPU, to enable/disable floating-
point procedures.

Kernel's new behavior will be as follows:

* with CONFIG_FPU=y
  All FPU codes are reserved.  If no FPU is found during booting, a
  global flag will be set, and those functions will be bypassed with
  condition check to that flag.

* with CONFIG_FPU=n
  No floating-point instructions in kernel and all related settings
  are excluded.

Changes in v8:
 - Fix a build fail introduced in v7.

Changes in v7:
 - Remove "fd" attribute from KBUILD_CFLAGS.

Changes in v6 (PATCH 0005 only):
 - Make the flag checking neater.

Changes in v5:
 - Invert the polarity of checking flag from no_fpu to has_fpu.

Changes in v4:
 - Append a new patch to detect existence of FPU and followups.
 - Add SPDX header to newly created fpu.S.
 - Fix a build error, sorry for that.
 - Fix wording, style, etc.

Changes in v3:
 - Refactor the whole patch into independent ones.

Changes in v2:
 - Various code cleanups and style fixes.

Alan Kao (5):
  Extract FPU context operations from entry.S
  Refactor FPU code in signal setup/return procedures
  Cleanup ISA string setting
  Allow to disable FPU support
  Auto-detect whether a FPU exists

 arch/riscv/Kconfig |   9 
 arch/riscv/Makefile|  19 +++
 arch/riscv/include/asm/switch_to.h |  12 -
 arch/riscv/kernel/Makefile |   1 +
 arch/riscv/kernel/cpufeature.c |   8 +++
 arch/riscv/kernel/entry.S  |  87 --
 arch/riscv/kernel/fpu.S| 106 +
 arch/riscv/kernel/process.c|   6 ++-
 arch/riscv/kernel/signal.c |  75 --
 9 files changed, 196 insertions(+), 127 deletions(-)
 create mode 100644 arch/riscv/kernel/fpu.S

-- 
2.7.4



[PATCH v8 4/5] Allow to disable FPU support

2018-10-08 Thread Alan Kao
FPU codes have been separated from common part in previous patches.
This patch add the CONFIG_FPU option and some stubs, so that a no-FPU
configuration is allowed.

Signed-off-by: Alan Kao 
Cc: Greentime Hu 
Cc: Vincent Chen 
Cc: Zong Li 
Cc: Nick Hu 
Reviewed-by: Christoph Hellwig 
---
 arch/riscv/Kconfig |  9 +
 arch/riscv/Makefile|  2 +-
 arch/riscv/include/asm/switch_to.h | 10 ++
 arch/riscv/kernel/Makefile |  2 +-
 arch/riscv/kernel/process.c|  4 +++-
 arch/riscv/kernel/signal.c |  5 +
 6 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index a344980..a63f9db 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -208,6 +208,15 @@ config RISCV_BASE_PMU
 
 endmenu
 
+config FPU
+   bool "FPU support"
+   default y
+   help
+ Say N here if you want to disable all floating-point related procedure
+ in the kernel.
+
+ If you don't know what to do here, say Y.
+
 endmenu
 
 menu "Kernel type"
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 01393e1..901770f 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -44,7 +44,7 @@ KBUILD_CFLAGS += -Wall
 riscv-march-$(CONFIG_ARCH_RV32I)   := rv32im
 riscv-march-$(CONFIG_ARCH_RV64I)   := rv64im
 riscv-march-$(CONFIG_RISCV_ISA_A)  := $(riscv-march-y)a
-riscv-march-y  := $(riscv-march-y)fd
+riscv-march-$(CONFIG_FPU)  := $(riscv-march-y)fd
 riscv-march-$(CONFIG_RISCV_ISA_C)  := $(riscv-march-y)c
 KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
 KBUILD_AFLAGS += -march=$(riscv-march-y)
diff --git a/arch/riscv/include/asm/switch_to.h 
b/arch/riscv/include/asm/switch_to.h
index dd6b05b..093050b 100644
--- a/arch/riscv/include/asm/switch_to.h
+++ b/arch/riscv/include/asm/switch_to.h
@@ -18,6 +18,7 @@
 #include 
 #include 
 
+#ifdef CONFIG_FPU
 extern void __fstate_save(struct task_struct *save_to);
 extern void __fstate_restore(struct task_struct *restore_from);
 
@@ -55,6 +56,15 @@ static inline void __switch_to_aux(struct task_struct *prev,
fstate_restore(next, task_pt_regs(next));
 }
 
+#define DEFAULT_SSTATUS (SR_SPIE | SR_FS_INITIAL)
+
+#else
+#define fstate_save(task, regs) do { } while (0)
+#define fstate_restore(task, regs) do { } while (0)
+#define __switch_to_aux(__prev, __next) do { } while (0)
+#define DEFAULT_SSTATUS (SR_SPIE | SR_FS_OFF)
+#endif
+
 extern struct task_struct *__switch_to(struct task_struct *,
   struct task_struct *);
 
diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
index bd433efd..f13f7f2 100644
--- a/arch/riscv/kernel/Makefile
+++ b/arch/riscv/kernel/Makefile
@@ -13,7 +13,6 @@ extra-y += vmlinux.lds
 obj-y  += cpu.o
 obj-y  += cpufeature.o
 obj-y  += entry.o
-obj-y  += fpu.o
 obj-y  += irq.o
 obj-y  += process.o
 obj-y  += ptrace.o
@@ -32,6 +31,7 @@ obj-y += vdso/
 
 CFLAGS_setup.o := -mcmodel=medany
 
+obj-$(CONFIG_FPU)  += fpu.o
 obj-$(CONFIG_SMP)  += smpboot.o
 obj-$(CONFIG_SMP)  += smp.o
 obj-$(CONFIG_MODULES)  += module.o
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index d7c6ca7..07d5156 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -76,7 +76,7 @@ void show_regs(struct pt_regs *regs)
 void start_thread(struct pt_regs *regs, unsigned long pc,
unsigned long sp)
 {
-   regs->sstatus = SR_SPIE /* User mode, irqs on */ | SR_FS_INITIAL;
+   regs->sstatus = DEFAULT_SSTATUS;
regs->sepc = pc;
regs->sp = sp;
set_fs(USER_DS);
@@ -84,12 +84,14 @@ void start_thread(struct pt_regs *regs, unsigned long pc,
 
 void flush_thread(void)
 {
+#ifdef CONFIG_FPU
/*
 * Reset FPU context
 *  frm: round to nearest, ties to even (IEEE default)
 *  fflags: accrued exceptions cleared
 */
memset(¤t->thread.fstate, 0, sizeof(current->thread.fstate));
+#endif
 }
 
 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 6a18b98..2450b82 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -37,6 +37,7 @@ struct rt_sigframe {
struct ucontext uc;
 };
 
+#ifdef CONFIG_FPU
 static long restore_fp_state(struct pt_regs *regs,
 union __riscv_fp_state *sc_fpregs)
 {
@@ -85,6 +86,10 @@ static long save_fp_state(struct pt_regs *regs,
 
return err;
 }
+#else
+#define save_fp_state(task, regs) (0)
+#define restore_fp_state(task, regs) (0)
+#endif
 
 static long restore_sigcontext(struct pt_regs *regs,
struct sigcontext __user *sc)
-- 
2.7.4



Re: [POC][RFC][PATCH 1/2] jump_function: Addition of new feature "jump_function"

2018-10-08 Thread Josh Poimboeuf
On Mon, Oct 08, 2018 at 09:29:56AM -0700, Andy Lutomirski wrote:
> 
> 
> > On Oct 8, 2018, at 8:57 AM, Peter Zijlstra  wrote:
> > 
> > On Mon, Oct 08, 2018 at 01:33:14AM -0700, Andy Lutomirski wrote:
> >>> Can't we hijack the relocation records for these functions before they
> >>> get thrown out in the (final) link pass or something?
> >> 
> >> I could be talking out my arse here, but I thought we could do this,
> >> too, then changed my mind.  The relocation records give us the
> >> location of the call or jump operand, but they don’t give the address
> >> of the beginning of the instruction.
> > 
> > But that's like 1 byte before the operand, right? We could even double check
> > this by reading back that byte and ensuring it is in fact 0xE8 (CALL).
> > 
> > AFAICT there is only the _1_ CALL encoding, and that is the 5 byte: E8 
> > ,
> > so if we have the PLT32 location, we also have the instruction location. Or 
> > am
> > I missing something?
> 
> There’s also JMP and Jcc, any of which can be used for rail calls, but
> those are also one byte. I suppose GCC is unlikely to emit a prefixed
> form of any of these. So maybe we really can assume they’re all one
> byte.

I'm pretty sure only a basic JMP is used for tail calls.

> But there is a nasty potential special case: anything that takes the
> function’s address. This includes jump tables, computed gotos, and
> plain old function pointers. And I suspect that any of these could
> have one of the rather large number of CALL/JMP/Jcc bytes before the
> relocation by coincidence.

But those special cases aren't in a text section, right?  If we just
make sure the relocations are applied to a text section, and that
they're preceded by the CALL or JMP byte, wouldn't that be sufficient?

I'm not really convinced we need objtool for this, maybe I'll try
whipping up a POC.

-- 
Josh


[PATCH v3 3/3] drivers: qcom: rpmh: disallow active requests in solver mode

2018-10-08 Thread Raju P.L.S.S.S.N
From: Lina Iyer 

Controllers may be in 'solver' state, where they could be in autonomous
mode executing low power modes for their hardware and as such are not
available for sending active votes. Device driver may notify RPMH API
that the controller is in solver mode and when in such mode, disallow
requests from platform drivers for state change using the RSC.

Signed-off-by: Lina Iyer 
Signed-off-by: Raju P.L.S.S.S.N 
---
Chanages in v3
 - Add functionality to set solver mode for RSC controller
 - return -EINVAL if active requests are sent in solver mode
---
 drivers/soc/qcom/rpmh-internal.h |  5 
 drivers/soc/qcom/rpmh-rsc.c  | 31 
 drivers/soc/qcom/rpmh.c  | 51 
 include/soc/qcom/rpmh.h  |  5 
 4 files changed, 92 insertions(+)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 4b891c23..0923c45 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -70,12 +70,14 @@ struct rpmh_request {
  * @cache_lock: synchronize access to the cache data
  * @dirty: was the cache updated since flush
  * @batch_cache: Cache sleep and wake requests sent as batch
+ * @in_solver_mode: Controller is busy in solver mode
  */
 struct rpmh_ctrlr {
struct list_head cache;
spinlock_t cache_lock;
bool dirty;
struct list_head batch_cache;
+   bool in_solver_mode;
 };
 
 /**
@@ -86,6 +88,7 @@ struct rpmh_ctrlr {
  * @base:   start address of the RSC's DRV registers
  * @tcs_base:   start address of the TCS registers in this controller
  * @id: instance id in the controller (Direct Resource Voter)
+ * @in_solver_mode: Controller is in solver mode
  * @num_tcs:number of TCSes in this DRV
  * @tcs:TCS groups
  * @tcs_in_use: s/w state of the TCS
@@ -97,6 +100,7 @@ struct rsc_drv {
void __iomem *base;
void __iomem *tcs_base;
int id;
+   bool in_solver_mode;
int num_tcs;
struct tcs_group tcs[TCS_TYPE_NR];
DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR);
@@ -107,6 +111,7 @@ struct rsc_drv {
 int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg);
 int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv,
 const struct tcs_request *msg);
+void rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable);
 int rpmh_rsc_invalidate(struct rsc_drv *drv);
 int rpmh_rsc_write_pdc_data(struct rsc_drv *drv, const struct tcs_request 
*msg);
 bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv);
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 9cc303e..17126be 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -386,6 +386,11 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
return PTR_ERR(tcs);
 
spin_lock(&drv->lock);
+
+   if (msg->state == RPMH_ACTIVE_ONLY_STATE && drv->in_solver_mode) {
+   ret = -EINVAL;
+   goto done_write;
+   }
/*
 * The h/w does not like if we send a request to the same address,
 * when one is already in-flight or being processed.
@@ -525,6 +530,31 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const 
struct tcs_request *msg)
 }
 
 /**
+ *  rpmh_rsc_mode_solver_set: Enable/disable solver mode
+ *
+ *  @drv: The controller
+ *
+ *  enable: boolean state to be set - true/false
+ */
+void rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable)
+{
+   int m;
+   struct tcs_group *tcs = get_tcs_of_type(drv, ACTIVE_TCS);
+
+again:
+   spin_lock(&drv->lock);
+   for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
+   if (!tcs_is_free(drv, m)) {
+   spin_unlock(&drv->lock);
+   goto again;
+   }
+   }
+   drv->in_solver_mode = enable;
+   spin_unlock(&drv->lock);
+
+}
+
+/**
  *  rpmh_rsc_ctrlr_is_idle: Check if any of the AMCs are busy.
  *
  *  @drv: The controller
@@ -718,6 +748,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
return ret;
 
spin_lock_init(&drv->lock);
+   drv->in_solver_mode = false;
bitmap_zero(drv->tcs_in_use, MAX_TCS_NR);
 
irq = platform_get_irq(pdev, drv->id);
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 43eb981..e6e98d4 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,6 +76,42 @@ static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device 
*dev)
return &drv->client;
 }
 
+static int check_ctrlr_state(struct rpmh_ctrlr *ctrlr, enum rpmh_state state)
+{
+   int ret = 0;
+
+   /* Do not allow setting active votes when in solver mode */
+   spin_lock(&ctrlr->cache_lock);
+   if (ctrlr->in_solver_mode && state == RPMH_ACTIVE_ONLY_STATE)
+   

[PATCH v3 2/3] drivers: qcom: rpmh-rsc: return if the controller is idle

2018-10-08 Thread Raju P.L.S.S.S.N
From: Lina Iyer 

Allow the controller status be queried. The controller is busy if it is
actively processing request. Also allow the controller state be read by
platform drivers. This is useful for PM drivers which can choose to
disallow idle modes when the controller is busy.

Signed-off-by: Lina Iyer 
Signed-off-by: Raju P.L.S.S.S.N 
---
changes in v3
- Add lock check to avoid potential race as suggested by Matthias
---
 drivers/soc/qcom/rpmh-internal.h |  1 +
 drivers/soc/qcom/rpmh-rsc.c  | 24 
 drivers/soc/qcom/rpmh.c  | 13 +
 include/soc/qcom/rpmh.h  |  5 +
 4 files changed, 43 insertions(+)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 2e3ffcd..4b891c23 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -109,6 +109,7 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv,
 const struct tcs_request *msg);
 int rpmh_rsc_invalidate(struct rsc_drv *drv);
 int rpmh_rsc_write_pdc_data(struct rsc_drv *drv, const struct tcs_request 
*msg);
+bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv);
 void rpmh_tx_done(const struct tcs_request *msg, int r);
 
 #endif /* __RPM_INTERNAL_H__ */
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index d6b834e..9cc303e 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -525,6 +525,30 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const 
struct tcs_request *msg)
 }
 
 /**
+ *  rpmh_rsc_ctrlr_is_idle: Check if any of the AMCs are busy.
+ *
+ *  @drv: The controller
+ *
+ *  Returns true if the TCSes are engaged in handling requests.
+ */
+bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv)
+{
+   int m;
+   struct tcs_group *tcs = get_tcs_of_type(drv, ACTIVE_TCS);
+
+   spin_lock(&drv->lock);
+   for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
+   if (!tcs_is_free(drv, m)) {
+   spin_unlock(&drv->lock);
+   return false;
+   }
+   }
+   spin_unlock(&drv->lock);
+
+   return true;
+}
+
+/**
  * rpmh_rsc_write_ctrl_data: Write request to the controller
  *
  * @drv: the controller
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index 297d6cc..43eb981 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -535,3 +535,16 @@ int rpmh_invalidate(const struct device *dev)
return ret;
 }
 EXPORT_SYMBOL(rpmh_invalidate);
+
+/**
+ * rpmh_ctrlr_idle: Return the controller idle status
+ *
+ * @dev: the device making the request
+ */
+int rpmh_ctrlr_idle(const struct device *dev)
+{
+   struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev);
+
+   return rpmh_rsc_ctrlr_is_idle(ctrlr_to_drv(ctrlr));
+}
+EXPORT_SYMBOL(rpmh_ctrlr_idle);
diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h
index b05e31a..4c4b013 100644
--- a/include/soc/qcom/rpmh.h
+++ b/include/soc/qcom/rpmh.h
@@ -27,6 +27,8 @@ int rpmh_write_batch(const struct device *dev, enum 
rpmh_state state,
 int rpmh_write_pdc_data(const struct device *dev,
const struct tcs_cmd *cmd, u32 n);
 
+int rpmh_ctrlr_idle(const struct device *dev);
+
 #else
 
 static inline int rpmh_write(const struct device *dev, enum rpmh_state state,
@@ -53,6 +55,9 @@ static inline int rpmh_write_pdc_data(const struct device 
*dev,
  const struct tcs_cmd *cmd, u32 n)
 { return -ENODEV; }
 
+static inline int rpmh_ctrlr_idle(const struct device *dev)
+{ return -ENODEV; }
+
 #endif /* CONFIG_QCOM_RPMH */
 
 #endif /* __SOC_QCOM_RPMH_H__ */
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of the Code Aurora Forum, hosted by The Linux Foundation.



[PATCH v3 1/3] drivers: qcom: rpmh-rsc: simplify TCS locking

2018-10-08 Thread Raju P.L.S.S.S.N
tcs->lock was introduced to serialize access with in TCS group. But
even without tcs->lock, drv->lock is serving the same purpose. So
use single drv->lock.

Other optimizations include -
 - Remove locking around clear_bit() in IRQ handler. clear_bit() is
   atomic.
 - Remove redundant read of TCS registers.
 - Use spin_lock instead of _irq variants as the locks are not held
   in interrupt context

Suggested-by: Lina Iyer 
Signed-off-by: Raju P.L.S.S.S.N 
---
This patch is based on https://lkml.org/lkml/2018/10/3/422
---
 drivers/soc/qcom/rpmh-internal.h |  2 --
 drivers/soc/qcom/rpmh-rsc.c  | 37 +
 drivers/soc/qcom/rpmh.c  | 20 
 3 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
index 8c316b4..2e3ffcd 100644
--- a/drivers/soc/qcom/rpmh-internal.h
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -28,7 +28,6 @@
  * @offset:start of the TCS group relative to the TCSes in the RSC
  * @num_tcs:   number of TCSes in this type
  * @ncpt:  number of commands in each TCS
- * @lock:  lock for synchronizing this TCS writes
  * @req:   requests that are sent from the TCS
  * @cmd_cache: flattened cache of cmds in sleep/wake TCS
  * @slots: indicates which of @cmd_addr are occupied
@@ -40,7 +39,6 @@ struct tcs_group {
u32 offset;
int num_tcs;
int ncpt;
-   spinlock_t lock;
const struct tcs_request *req[MAX_TCS_PER_TYPE];
u32 *cmd_cache;
DECLARE_BITMAP(slots, MAX_TCS_SLOTS);
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 73d5b98..d6b834e 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -98,8 +98,7 @@ static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, 
int tcs_id,
 
 static bool tcs_is_free(struct rsc_drv *drv, int tcs_id)
 {
-   return !test_bit(tcs_id, drv->tcs_in_use) &&
-  read_tcs_reg(drv, RSC_DRV_STATUS, tcs_id, 0);
+   return !test_bit(tcs_id, drv->tcs_in_use);
 }
 
 static struct tcs_group *get_tcs_of_type(struct rsc_drv *drv, int type)
@@ -109,29 +108,28 @@ static struct tcs_group *get_tcs_of_type(struct rsc_drv 
*drv, int type)
 
 static int tcs_invalidate(struct rsc_drv *drv, int type)
 {
-   int m;
+   int m, ret = 0;
struct tcs_group *tcs;
 
tcs = get_tcs_of_type(drv, type);
 
-   spin_lock(&tcs->lock);
-   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) {
-   spin_unlock(&tcs->lock);
-   return 0;
-   }
+   spin_lock(&drv->lock);
+   if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
+   goto done;
 
for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) {
if (!tcs_is_free(drv, m)) {
-   spin_unlock(&tcs->lock);
-   return -EAGAIN;
+   ret = -EAGAIN;
+   goto done;
}
write_tcs_reg_sync(drv, RSC_DRV_CMD_ENABLE, m, 0);
write_tcs_reg_sync(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0);
}
bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
-   spin_unlock(&tcs->lock);
 
-   return 0;
+done:
+   spin_unlock(&drv->lock);
+   return ret;
 }
 
 /**
@@ -298,9 +296,7 @@ static irqreturn_t tcs_tx_done(int irq, void *p)
write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i, 0);
write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, i, 0);
write_tcs_reg(drv, RSC_DRV_IRQ_CLEAR, 0, BIT(i));
-   spin_lock(&drv->lock);
clear_bit(i, drv->tcs_in_use);
-   spin_unlock(&drv->lock);
if (req)
rpmh_tx_done(req, err);
}
@@ -383,14 +379,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
 {
struct tcs_group *tcs;
int tcs_id;
-   unsigned long flags;
int ret;
 
tcs = get_tcs_for_msg(drv, msg);
if (IS_ERR(tcs))
return PTR_ERR(tcs);
 
-   spin_lock_irqsave(&tcs->lock, flags);
spin_lock(&drv->lock);
/*
 * The h/w does not like if we send a request to the same address,
@@ -398,14 +392,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
 */
ret = check_for_req_inflight(drv, tcs, msg);
if (ret) {
-   spin_unlock(&drv->lock);
goto done_write;
}
 
tcs_id = find_free_tcs(tcs);
if (tcs_id < 0) {
ret = tcs_id;
-   spin_unlock(&drv->lock);
goto done_write;
}
 
@@ -413,13 +405,12 @@ static int tcs_write(struct rsc_drv *drv, const struct 
tcs_request *msg)
set_bit(tcs_id, drv->tcs_in_use);
if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS)
enable_tcs_irq(drv, tcs_id, true);
-   spin

[PATCH v3 0/3] drivers/qcom: add additional functionality to RPMH

2018-10-08 Thread Raju P.L.S.S.S.N
Changes in v3:
 - Simplify TCS locking - added a new patch
 - Add lock check to avoid potential race as suggested by Matthias
 - Add functionality to RSC controller to disallow active requests
   if solver mode is not set 
 - Removed independent patches and posted as separate series[2]

Changes in v2:
 - Remove unnecessary EXPORT_SYMBOL in rpmh-rsc

This set of patches add additional functionality to RPMH drivers[1].

PM drivers can choose to disallow idle modes when RSC controller is busy
sending or processing requests. The patches add necessary functions to
query the controller status.

The controllers may be in 'solver' state, where they could be in autonomous
mode executing low power modes for their hardware and as such are not
available for sending active votes. Functionality to get notified about
such state and disallow requests for state change in that case is added
in these patches.

Please consider reviewing this patchset.

This series is based on other patchset[2] 


v1:https://lkml.org/lkml/2018/7/19/213
v2:https://patchwork.kernel.org/cover/10546863/



[1] https://lkml.org/lkml/2018/6/20/519
[2] https://lkml.org/lkml/2018/10/3/422


Lina Iyer (2):
  drivers: qcom: rpmh-rsc: return if the controller is idle
  drivers: qcom: rpmh: disallow active requests in solver mode

Raju P.L.S.S.S.N (1):
  drivers: qcom: rpmh-rsc: simplify TCS locking

 drivers/soc/qcom/rpmh-internal.h |  8 +++-
 drivers/soc/qcom/rpmh-rsc.c  | 92 +---
 drivers/soc/qcom/rpmh.c  | 84 ++--
 include/soc/qcom/rpmh.h  | 10 +
 4 files changed, 156 insertions(+), 38 deletions(-)

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of the Code Aurora Forum, hosted by The Linux Foundation.



[PATCH] remoteproc: qcom: q6v5-pil: add SCM probe dependency

2018-10-08 Thread Brian Norris
Similar to qcom_q6v5_pas and qcom_wcnss drivers, probe will fail if SCM
is not up.

Signed-off-by: Brian Norris 
---
 drivers/remoteproc/qcom_q6v5_mss.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/qcom_q6v5_mss.c 
b/drivers/remoteproc/qcom_q6v5_mss.c
index a839b07a58b1..8836ca1bc0c1 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -1151,6 +1151,9 @@ static int q6v5_probe(struct platform_device *pdev)
if (!desc)
return -EINVAL;
 
+   if (!qcom_scm_is_available())
+   return -EPROBE_DEFER;
+
rproc = rproc_alloc(&pdev->dev, pdev->name, &q6v5_ops,
desc->hexagon_mba_image, sizeof(*qproc));
if (!rproc) {
-- 
2.19.0.605.g01d371f741-goog



Re: [PATCH] KVM: LAPIC: Tune lapic_timer_advance_ns automatically

2018-10-08 Thread Wanpeng Li
On Mon, 8 Oct 2018 at 20:04, Liran Alon  wrote:
>
>
>
> > On 8 Oct 2018, at 13:59, Wanpeng Li  wrote:
> >
> > On Mon, 8 Oct 2018 at 05:02, Liran Alon  wrote:
> >>
> >>
> >>
> >>> On 28 Sep 2018, at 9:12, Wanpeng Li  wrote:
> >>>
> >>> From: Wanpeng Li 
> >>>
> >>> In cloud environment, lapic_timer_advance_ns is needed to be tuned for 
> >>> every CPU
> >>> generations, and every host kernel versions(the 
> >>> kvm-unit-tests/tscdeadline_latency.flat
> >>> is 5700 cycles for upstream kernel and 9600 cycles for our 3.10 product 
> >>> kernel,
> >>> both preemption_timer=N, Skylake server).
> >>>
> >>> This patch adds the capability to automatically tune 
> >>> lapic_timer_advance_ns
> >>> step by step, the initial value is 1000ns as d0659d946be05 (KVM: x86: add
> >>> option to advance tscdeadline hrtimer expiration) recommended, it will be
> >>> reduced when it is too early, and increased when it is too late. The 
> >>> guest_tsc
> >>> and tsc_deadline are hard to equal, so we assume we are done when the 
> >>> delta
> >>> is within a small scope e.g. 100 cycles. This patch reduces latency
> >>> (kvm-unit-tests/tscdeadline_latency, busy waits, preemption_timer enabled)
> >>> from ~2600 cyles to ~1200 cyles on our Skylake server.
> >>>
> >>> Cc: Paolo Bonzini 
> >>> Cc: Radim Krčmář 
> >>> Signed-off-by: Wanpeng Li 
> >>> ---
> >>> arch/x86/kvm/lapic.c | 7 +++
> >>> arch/x86/kvm/x86.c   | 2 +-
> >>> 2 files changed, 8 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> >>> index fbb0e6d..b756f12 100644
> >>> --- a/arch/x86/kvm/lapic.c
> >>> +++ b/arch/x86/kvm/lapic.c
> >>> @@ -70,6 +70,8 @@
> >>> #define APIC_BROADCAST0xFF
> >>> #define X2APIC_BROADCAST  0xul
> >>>
> >>> +static bool __read_mostly lapic_timer_advance_adjust_done = false;
> >>> +
> >>> static inline int apic_test_vector(int vec, void *bitmap)
> >>> {
> >>>  return test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
> >>> @@ -1492,6 +1494,11 @@ void wait_lapic_expire(struct kvm_vcpu *vcpu)
> >>>  if (guest_tsc < tsc_deadline)
> >>>  __delay(min(tsc_deadline - guest_tsc,
> >>>  nsec_to_cycles(vcpu, lapic_timer_advance_ns)));
> >>> + if (!lapic_timer_advance_adjust_done) {
> >>> + lapic_timer_advance_ns += (s64)(guest_tsc - tsc_deadline) / 
> >>> 8;
> >>
> >> I don’t understand how this “/ 8” converts between guest TSC units to host 
> >> nanoseconds.
> >
> > Oh, I miss it. In addition, /8 here I mean adjust
> > lapic_timer_advance_ns step by step. I can observe big fluctuated
>
> If that’s the case, I would also put the “8” as a #define to make it more 
> clear of it’s purpose.
>
> > value between early and late when running real guest os like linux
> > instead of kvm-unit-tests. After more testing, I saw
> > lapic_timer_advance_ns can be overflow since the delta between
> > guest_tsc and tsc_deadline is too huge.
> >
> >>
> >> I think that instead you should do something like:
> >> s64 ns = (s64)(guest_tsc - tsc_deadline) * 100ULL;
> >> do_div(ns, vcpu->arch.virtual_tsc_khz);
> >> lapic_timer_advance_ns += ns;
> >>
> >>> + if (abs(guest_tsc - tsc_deadline) < 100)
> >>
> >> I would put this “100” hard-coded value as some “#define” to make code 
> >> more clear.
> >
> > How about something like below:
> >
> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> > index fbb0e6d..354eb13c 100644
> > --- a/arch/x86/kvm/lapic.c
> > +++ b/arch/x86/kvm/lapic.c
> > @@ -70,6 +70,9 @@
> > #define APIC_BROADCAST0xFF
> > #define X2APIC_BROADCAST0xul
> >
> > +static bool __read_mostly lapic_timer_advance_adjust_done = false;
> > +#define LAPIC_TIMER_ADVANCE_ADJUST_DONE 100
> > +
> > static inline int apic_test_vector(int vec, void *bitmap)
> > {
> > return test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
> > @@ -1472,7 +1475,7 @@ static bool lapic_timer_int_injected(struct
> > kvm_vcpu *vcpu)
> > void wait_lapic_expire(struct kvm_vcpu *vcpu)
> > {
> > struct kvm_lapic *apic = vcpu->arch.apic;
> > -u64 guest_tsc, tsc_deadline;
> > +u64 guest_tsc, tsc_deadline, ns;
> >
> > if (!lapic_in_kernel(vcpu))
> > return;
> > @@ -1492,6 +1495,19 @@ void wait_lapic_expire(struct kvm_vcpu *vcpu)
> > if (guest_tsc < tsc_deadline)
> > __delay(min(tsc_deadline - guest_tsc,
> > nsec_to_cycles(vcpu, lapic_timer_advance_ns)));
> > +if (!lapic_timer_advance_adjust_done) {
> > +if (guest_tsc < tsc_deadline) {
> > +ns = (tsc_deadline - guest_tsc) * 100ULL;
> > +do_div(ns, vcpu->arch.virtual_tsc_khz);
> > +lapic_timer_advance_ns -= min((unsigned int)ns,
> > lapic_timer_advance_ns / 8);
> > +} else {
> > +ns = (guest_tsc - tsc_deadline) * 100ULL;
> > +do_div(ns, vcpu->arch.virtual_tsc_khz);
> > +lapic_timer_advance_ns += min((unsigned int

Re: CHECKPATCH: strange warning on alignment modifier

2018-10-08 Thread Joe Perches
On Mon, 2018-10-08 at 10:56 +0300, Igor Stoppa wrote:
> Hi,
> 
> I have the following fragment of code:
> 
> +struct my_struct {
> +   atomic_long_t l __aligned(sizeof(atomic_long_t));
> +} __aligned(sizeof(atomic_long_t));
> 
> 
> triggering this warning, when fed to checkpatch.pl:
> 
> WARNING: function definition argument 'atomic_long_t' should also have 
> an identifier name
> #19: FILE: path/to/file.h
> + atomic_long_t l __aligned(sizeof(atomic_long_t));
> 
> 
> gcc [(Ubuntu 7.3.0-16ubuntu3) 7.3.0] seems to be happy about it
> 
> I am using the HEAD from mainline.
> 
> My intent is to specify the alignment of both the field and the 
> structure (yes, probably redundant in this single-field case).
> 
> If I am doing something wrong, I can't figure out what it is, but I 
> don't understand why the WARNING is mentioning a function definition.

It's a defect in checkpatch.
For now, just ignore the message.
I will work on it later.




[PATCH v5 2/2] PCI: amlogic: Add the Amlogic Meson PCIe controller driver

2018-10-08 Thread Hanjie Lin
From: Yue Wang 

The Amlogic Meson PCIe host controller is based on the Synopsys DesignWare
PCI core. This patch adds the driver support for Meson PCIe controller.

Signed-off-by: Yue Wang 
Signed-off-by: Hanjie Lin 
---
 MAINTAINERS|   7 +
 drivers/pci/controller/dwc/Kconfig |  10 +
 drivers/pci/controller/dwc/Makefile|   1 +
 drivers/pci/controller/dwc/pci-meson.c | 593 +
 4 files changed, 611 insertions(+)
 create mode 100644 drivers/pci/controller/dwc/pci-meson.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 02a3961..da579ef 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11333,6 +11333,13 @@ L: linux-...@vger.kernel.org
 S: Maintained
 F: drivers/pci/controller/dwc/*spear*
 
+PCIE DRIVER FOR AMLOGIC MESON
+M: Yue Wang 
+L: linux-...@vger.kernel.org
+L: linux-amlo...@lists.infradead.org
+S: Maintained
+F: drivers/pci/controller/dwc/pci-meson.c
+
 PCMCIA SUBSYSTEM
 M: Dominik Brodowski 
 T: git git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia.git
diff --git a/drivers/pci/controller/dwc/Kconfig 
b/drivers/pci/controller/dwc/Kconfig
index 91b0194..7800322 100644
--- a/drivers/pci/controller/dwc/Kconfig
+++ b/drivers/pci/controller/dwc/Kconfig
@@ -193,4 +193,14 @@ config PCIE_HISI_STB
help
   Say Y here if you want PCIe controller support on HiSilicon STB SoCs
 
+config PCI_MESON
+   bool "MESON PCIe controller"
+   depends on PCI_MSI_IRQ_DOMAIN
+   select PCIE_DW_HOST
+   help
+ Say Y here if you want to enable PCI controller support on Amlogic
+ SoCs. The PCI controller on Amlogic is based on DesignWare hardware
+ and therefore the driver re-uses the DesignWare core functions to
+ implement the driver.
+
 endmenu
diff --git a/drivers/pci/controller/dwc/Makefile 
b/drivers/pci/controller/dwc/Makefile
index 5d2ce72..cf676bd 100644
--- a/drivers/pci/controller/dwc/Makefile
+++ b/drivers/pci/controller/dwc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_PCIE_ARMADA_8K) += pcie-armada8k.o
 obj-$(CONFIG_PCIE_ARTPEC6) += pcie-artpec6.o
 obj-$(CONFIG_PCIE_KIRIN) += pcie-kirin.o
 obj-$(CONFIG_PCIE_HISI_STB) += pcie-histb.o
+obj-$(CONFIG_PCI_MESON) += pci-meson.o
 
 # The following drivers are for devices that use the generic ACPI
 # pci_root.c driver but don't support standard ECAM config access.
diff --git a/drivers/pci/controller/dwc/pci-meson.c 
b/drivers/pci/controller/dwc/pci-meson.c
new file mode 100644
index 000..2278b48
--- /dev/null
+++ b/drivers/pci/controller/dwc/pci-meson.c
@@ -0,0 +1,593 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PCIe host controller driver for Amlogic MESON SoCs
+ *
+ * Copyright (c) 2018 Amlogic, inc.
+ * Author: Yue Wang 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pcie-designware.h"
+
+#define to_meson_pcie(x) dev_get_drvdata((x)->dev)
+
+/* External local bus interface registers */
+#define PLR_OFFSET 0x700
+#define PCIE_PORT_LINK_CTRL_OFF(PLR_OFFSET + 0x10)
+#define FAST_LINK_MODE BIT(7)
+#define LINK_CAPABLE_MASK  GENMASK(21, 16)
+#define LINK_CAPABLE_X1BIT(16)
+
+#define PCIE_GEN2_CTRL_OFF (PLR_OFFSET + 0x10c)
+#define NUM_OF_LANES_MASK  GENMASK(12, 8)
+#define NUM_OF_LANES_X1BIT(8)
+#define DIRECT_SPEED_CHANGEBIT(17)
+
+#define TYPE1_HDR_OFFSET   0x0
+#define PCIE_STATUS_COMMAND(TYPE1_HDR_OFFSET + 0x04)
+#define PCI_IO_EN  BIT(0)
+#define PCI_MEM_SPACE_EN   BIT(1)
+#define PCI_BUS_MASTER_EN  BIT(2)
+
+#define PCIE_BASE_ADDR0(TYPE1_HDR_OFFSET + 0x10)
+#define PCIE_BASE_ADDR1(TYPE1_HDR_OFFSET + 0x14)
+
+#define PCIE_CAP_OFFSET0x70
+#define PCIE_DEV_CTRL_DEV_STUS (PCIE_CAP_OFFSET + 0x08)
+#define PCIE_CAP_MAX_PAYLOAD_MASK  GENMASK(7, 5)
+#define PCIE_CAP_MAX_PAYLOAD_SIZE(x)   ((x) << 5)
+#define PCIE_CAP_MAX_READ_REQ_MASK GENMASK(14, 12)
+#define PCIE_CAP_MAX_READ_REQ_SIZE(x)  ((x) << 12)
+
+#define PCI_CLASS_REVISION_MASKGENMASK(7, 0)
+
+/* PCIe specific config registers */
+#define PCIE_CFG0  0x0
+#define APP_LTSSM_ENABLE   BIT(7)
+
+#define PCIE_CFG_STATUS12  0x30
+#define IS_SMLH_LINK_UP(x) ((x) & (1 << 6))
+#define IS_RDLH_LINK_UP(x) ((x) & (1 << 16))
+#define IS_LTSSM_UP(x) x) >> 10) & 0x1f) == 0x11)
+
+#define PCIE_CFG_STATUS17  0x44
+#define PM_CURRENT_STATE(x)(((x) >> 7) & 0x1)
+
+#define WAIT_LINKUP_TIMEOUT2000
+#define PORT_CLK_RATE  1UL
+#define MAX_PAYLOAD_SIZE   256
+#define MAX_READ_REQ_SIZE  256
+#define MESON_PCIE_PHY_POWERUP 

[PATCH v5 0/2] add the Amlogic Meson PCIe controller driver

2018-10-08 Thread Hanjie Lin
The Amlogic Meson PCIe host controller is based on the Synopsys DesignWare
PCI core. This patchset add the driver and dt-bindings of the controller.

Changes since v4: [3]
 - fix kbuild test robot and compile warnings

Changes since v3: [2]
 - modify subject format
 - update Kconfig
 - update MAINTAINER file
 - add comment and error handle for meson_pcie_get_mem_shared()
 - drop useless initialization code
 - add comment for meson_size_to_payload()
 - optimize meson_pcie_establish_link() return code
 - optimize meson_pcie_enable_interrupts() redundant function
 - drop device_attch related code
 - drop dw_pcie_ops read_dbi and write_dbi function
 - add error handle for meson_add_pcie_port() when probe

Changes since v2: [1]
 - abandon phy driver, move reset to the controller
 - use devm_add_action_or_reset() to use clock res
 - format correcting

Changes since v1: [0]
 - use gpio lib instead open code
 - move 'apb' and 'port' reset from phy driver
 - format correcting

[0] : 
https://lkml.kernel.org/r/1534227522-186798-1-git-send-email-hanjie@amlogic.com
[1] : 
https://lkml.kernel.org/r/1535096165-45827-1-git-send-email-hanjie@amlogic.com
[2] : 
https://lkml.kernel.org/r/1537509820-52040-1-git-send-email-hanjie@amlogic.com
 
[3] : 
https://lkml.kernel.org/r/1538999834-156423-3-git-send-email-hanjie@amlogic.com

Yue Wang (2):
  dt-bindings: PCI: meson: add DT bindings for Amlogic Meson PCIe
controller
  PCI: amlogic: Add the Amlogic Meson PCIe controller driver

 .../devicetree/bindings/pci/amlogic,meson-pcie.txt |  70 +++
 MAINTAINERS|   7 +
 drivers/pci/controller/dwc/Kconfig |  10 +
 drivers/pci/controller/dwc/Makefile|   1 +
 drivers/pci/controller/dwc/pci-meson.c | 593 +
 5 files changed, 681 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/amlogic,meson-pcie.txt
 create mode 100644 drivers/pci/controller/dwc/pci-meson.c

-- 
2.7.4



[PATCH v5 1/2] dt-bindings: PCI: meson: add DT bindings for Amlogic Meson PCIe controller

2018-10-08 Thread Hanjie Lin
From: Yue Wang 

The Amlogic Meson PCIe host controller is based on the Synopsys DesignWare
PCI core. This patch adds documentation for the DT bindings in Meson PCIe
controller.

Signed-off-by: Yue Wang 
Signed-off-by: Hanjie Lin 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/pci/amlogic,meson-pcie.txt | 70 ++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/amlogic,meson-pcie.txt

diff --git a/Documentation/devicetree/bindings/pci/amlogic,meson-pcie.txt 
b/Documentation/devicetree/bindings/pci/amlogic,meson-pcie.txt
new file mode 100644
index 000..12b18f8
--- /dev/null
+++ b/Documentation/devicetree/bindings/pci/amlogic,meson-pcie.txt
@@ -0,0 +1,70 @@
+Amlogic Meson AXG DWC PCIE SoC controller
+
+Amlogic Meson PCIe host controller is based on the Synopsys DesignWare PCI 
core.
+It shares common functions with the PCIe DesignWare core driver and
+inherits common properties defined in
+Documentation/devicetree/bindings/pci/designware-pci.txt.
+
+Additional properties are described here:
+
+Required properties:
+- compatible:
+   should contain "amlogic,axg-pcie" to identify the core.
+- reg:
+   should contain the configuration address space.
+- reg-names: Must be
+   - "elbi"External local bus interface registers
+   - "cfg" Meson specific registers
+   - "phy" Meson PCIE PHY registers
+   - "config"  PCIe configuration space
+- reset-gpios: The GPIO to generate PCIe PERST# assert and deassert signal.
+- clocks: Must contain an entry for each entry in clock-names.
+- clock-names: Must include the following entries:
+   - "pclk"   PCIe GEN 100M PLL clock
+   - "port"   PCIe_x(A or B) RC clock gate
+   - "general"PCIe Phy clock
+   - "mipi"   PCIe_x(A or B) 100M ref clock gate
+- resets: phandle to the reset lines.
+- reset-names: must contain "phy" "port" and "apb"
+   - "phy" Share PHY reset
+   - "port"Port A or B reset
+   - "apb" Share APB reset
+- device_type:
+   should be "pci". As specified in designware-pcie.txt
+
+
+Example configuration:
+
+   pcie: pcie@f980 {
+   compatible = "amlogic,axg-pcie", "snps,dw-pcie";
+   reg = <0x0 0xf980 0x0 0x40
+   0x0 0xff646000 0x0 0x2000
+   0x0 0xff644000 0x0 0x2000
+   0x0 0xf9f0 0x0 0x10>;
+   reg-names = "elbi", "cfg", "phy", "config";
+   reset-gpios = <&gpio GPIOX_19 GPIO_ACTIVE_HIGH>;
+   interrupts = ;
+   #interrupt-cells = <1>;
+   interrupt-map-mask = <0 0 0 0>;
+   interrupt-map = <0 0 0 0 &gic GIC_SPI 179 
IRQ_TYPE_EDGE_RISING>;
+   bus-range = <0x0 0xff>;
+   #address-cells = <3>;
+   #size-cells = <2>;
+   device_type = "pci";
+   ranges = <0x8200 0 0 0x0 0xf9c0 0 0x0030>;
+
+   clocks = <&clkc CLKID_USB
+   &clkc CLKID_MIPI_ENABLE
+   &clkc CLKID_PCIE_A
+   &clkc CLKID_PCIE_CML_EN0>;
+   clock-names = "general",
+   "mipi",
+   "pclk",
+   "port";
+   resets = <&reset RESET_PCIE_PHY>,
+   <&reset RESET_PCIE_A>,
+   <&reset RESET_PCIE_APB>;
+   reset-names = "phy",
+   "port",
+   "apb";
+   };
-- 
2.7.4



Re: [PATCH v6 0/9] PCI: mediatek: fixup find_port, enable_msi and add pm, module support

2018-10-08 Thread Honghui Zhang
On Mon, 2018-10-08 at 12:31 -0500, Bjorn Helgaas wrote:
> On Mon, Oct 08, 2018 at 11:24:39AM +0800, honghui.zh...@mediatek.com wrote:
> 
> > Honghui Zhang (9):
> >   PCI: mediatek: Using slot's devfn for compare to fix
> > mtk_pcie_find_port logic
> >   PCI: mediatek: Fixup class ID for MT7622 as PCI_CLASS_BRIDGE_PCI
> >   PCI: mediatek: Remove the redundant dev->pm_domain check
> >   PCI: mediatek: Convert to use pci_host_probe()
> >   PCI: mediatek: Move the mtk_pcie_startup_port_v2 function's define
> > after mtk_pcie_setup_irq
> >   PCI: mediatek: Fixup enable msi logic by enable msi after clock
> > enabled
> 
> s/msi/MSI/ (twice)
> 
> >   PCI: mediatek: Add system pm support for MT2712 and MT7622
> 
> s/pm/PM/
> 
> "msi" and "pm" are not English words, and capitalizing them tells the
> reader that they are acronyms or initialisms (like GIC and IRQ below).
> 

Thanks for the comments. Will fix those in the next version.

thanks.

> >   PCI: mediatek: Save the GIC IRQ in mtk_pcie_port
> >   PCI: mediatek: Add loadable kernel module support




Re: [POC][RFC][PATCH 0/2 v2] PROOF OF CONCEPT: Dynamic Functions (jump functions)

2018-10-08 Thread Steven Rostedt
On Sat, 06 Oct 2018 08:01:25 -0400
Steven Rostedt  wrote:

> [ Sending v2 because I updated quilt and it added back that stupid
>   "Content-Disposition: inline; filename=$patch" line, messing up
>   how the patches look in gmail. This should be better. ]
> 

Actually, this wasn't suppose to go out. I started to resend this, and
had my quilt send mail going, and I stopped at the "edit prologue"
where I wrote all this.

But then I postponed it to fix up the code a bit more, and in the mean
time, Peter, et. al. replied, and I figured we go down a different
path. But I forgot that I had the quilt mail opened. I came back to the
window with it up, thought it was just some text file I haven't saved
yet, typed ":wq" and then saw the "sendmail" message pop out. Oops!

This also explains why the date is set to Oct 6 (that's when I started
the quilt send mail).

Feel free to ignore this :-)

-- Steve


Re: WARNING in ext4_invalidatepage

2018-10-08 Thread Theodore Y. Ts'o
On Mon, Oct 08, 2018 at 06:29:54PM +0200, Dmitry Vyukov wrote:
> 
> The program that triggered it did the following:
> 
> 05:23:28 executing program 5:
> r0 = creat(&(0x7f0001c0)='./file0\x00', 0x0)
> socketpair$unix(0x1, 0x1, 0x0, &(0x7f000380)={0x,
> 0x})
> write$RDMA_USER_CM_CMD_CREATE_ID(r0, &(0x7f000240)={0x0, 0x18,
> 0xfa00, {0x0, &(0x7f000200)}}, 0x20)

This looks like it's doing an ioctl-like thing which is now restricted
to root --- it looks like people can do arbitrary stupid things with
it?

https://www.openwall.com/lists/oss-security/2016/05/09/11

> ioctl$PERF_EVENT_IOC_ENABLE(r1, 0x8912, 0x400200)
> ioctl$EXT4_IOC_SETFLAGS(r0, 0x4008660f, &(0x7f00)=0x4000)

Um, this doesn't seem to correspond to the stack trace:

> >  do_invalidatepage mm/truncate.c:165 [inline]
> >  truncate_cleanup_page+0x5ac/0xa90 mm/truncate.c:187
> >  truncate_inode_page+0x107/0x1a0 mm/truncate.c:229
> >  truncate_inode_pages_range+0x1382/0x2d50 mm/truncate.c:451
> >  truncate_inode_pages+0x24/0x30 mm/truncate.c:478
> >  swap_inode_boot_loader fs/ext4/ioctl.c:123 [inline]
> >  ext4_ioctl+0x1e3b/0x4210 fs/ext4/ioctl.c:865
> >  vfs_ioctl fs/ioctl.c:46 [inline]
> >  file_ioctl fs/ioctl.c:501 [inline]
> >  do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> >  ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> >  __do_sys_ioctl fs/ioctl.c:709 [inline]
> >  __se_sys_ioctl fs/ioctl.c:707 [inline]
> >  __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> >  do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> >  entry_SYSCALL_64_after_hwframe+0x49/0xbe

This looks like the program that triggered the crash was running
EXT4_IOC_SWAP_BOOT.  It may have been racing against something that's
was using RDMA, but that's not clear at all, since the write command
appears to be some weird ioctl-like interface that requires root.

It's too bad that syzbot wasn't able to come up with a clean
reproducer.  I've been doing some work to robustify the
EXT4_IOC_SWAP_ROOT.  If we had a reproducer I'd see if this patch
would address it.

http://patchwork.ozlabs.org/patch/978083/

- Ted


> > WARNING: CPU: 1 PID: 17203 at fs/ext4/inode.c:3353
> > ext4_invalidatepage+0x1c7/0x5b0 fs/ext4/inode.c:3353
> > Kernel panic - not syncing: panic_on_warn set ...
> >
> > CPU: 1 PID: 17203 Comm: syz-executor5 Not tainted 4.19.0-rc6+ #48
> > kobject: 'loop3' (2393f9b0): kobject_uevent_env
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > Call Trace:
> >  __dump_stack lib/dump_stack.c:77 [inline]
> >  dump_stack+0x1c4/0x2b4 lib/dump_stack.c:113
> > kobject: 'loop3' (2393f9b0): fill_kobj_path: path =
> > '/devices/virtual/block/loop3'
> >  panic+0x238/0x4e7 kernel/panic.c:184
> >  __warn.cold.8+0x163/0x1ba kernel/panic.c:536
> >  report_bug+0x254/0x2d0 lib/bug.c:186
> >  fixup_bug arch/x86/kernel/traps.c:178 [inline]
> >  do_error_trap+0x1fc/0x4d0 arch/x86/kernel/traps.c:296
> >  do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:316
> >  invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:993
> > RIP: 0010:ext4_invalidatepage+0x1c7/0x5b0 fs/ext4/inode.c:3353
> > Code: 80 3c 02 00 0f 85 a7 03 00 00 4d 8b 6d 00 31 ff 49 c1 ed 11 41 83 e5
> > 01 4c 89 ee e8 43 ea 67 ff 4d 85 ed 74 07 e8 09 e9 67 ff <0f> 0b e8 02 e9 67
> > ff 8b b5 34 ff ff ff 44 89 fa 4c 89 e7 e8 91 3a
> > RSP: 0018:88018590ec78 EFLAGS: 00010212
> > RAX: 0004 RBX: 110030b21d91 RCX: c9000dae4000
> > RDX: 0ece RSI: 8216ec87 RDI: 0007
> > RBP: 88018590ed50 R08: 880183018300 R09: f94000ceffc6
> > R10: f94000ceffc6 R11: ea000677fe33 R12: ea000677fe00
> > R13: 0001 R14: ea000677fe08 R15: 1000
> >  do_invalidatepage mm/truncate.c:165 [inline]
> >  truncate_cleanup_page+0x5ac/0xa90 mm/truncate.c:187
> >  truncate_inode_page+0x107/0x1a0 mm/truncate.c:229
> >  truncate_inode_pages_range+0x1382/0x2d50 mm/truncate.c:451
> >  truncate_inode_pages+0x24/0x30 mm/truncate.c:478
> >  swap_inode_boot_loader fs/ext4/ioctl.c:123 [inline]
> >  ext4_ioctl+0x1e3b/0x4210 fs/ext4/ioctl.c:865
> >  vfs_ioctl fs/ioctl.c:46 [inline]
> >  file_ioctl fs/ioctl.c:501 [inline]
> >  do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> >  ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> >  __do_sys_ioctl fs/ioctl.c:709 [inline]
> >  __se_sys_ioctl fs/ioctl.c:707 [inline]
> >  __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> >  do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> >  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> > RIP: 0033:0x457579
> > Code: 1d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7
> > 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff
> > 0f 83 eb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> > RSP: 002b:7fa151655c78 EFLAGS: 0246 ORIG_RAX: 0010
> > RAX: ffda RBX: 0003 RCX: 00457579
> > RDX: 20

[PATCH v2] mt76x0: pci: fix set external PA I/O current

2018-10-08 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/mediatek/mt76/mt76x0/pci.c: In function 
'mt76x0e_register_device':
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c:107:8: warning:
 variable 'data' set but not used [-Wunused-but-set-variable]

It seems correct value to write is 'data'

Fixes: 2b2cb40bcd7d ("mt76x0: pci: add hw initialization at bootstrap")
Signed-off-by: YueHaibing 
Acked-by: Lorenzo Bianconi 
---
v2: remove 'net-next' from patch title
---
 drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c 
b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 87997cd..0426c68 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -106,12 +106,12 @@ static int mt76x0e_register_device(struct mt76x02_dev 
*dev)
if (val & MT_EE_NIC_CONF_0_PA_IO_CURRENT) {
u32 data;
 
-   /* set external external PA I/O
+   /* set external PA I/O
 * current to 16mA
 */
data = mt76_rr(dev, 0x11c);
-   val |= 0xc03;
-   mt76_wr(dev, 0x11c, val);
+   data |= 0xc03;
+   mt76_wr(dev, 0x11c, data);
}
}



Re: [PATCH 4.9 00/59] 4.9.132-stable review

2018-10-08 Thread Nathan Chancellor
On Mon, Oct 08, 2018 at 08:31:07PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.132 release.
> There are 59 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed Oct 10 17:55:28 UTC 2018.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.132-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.9.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Merged, compiled with -Werror, and installed onto my OnePlus 6.

No initial issues noticed in dmesg or general usage.

Thanks!
Nathan


Re: [PATCH 4.4 000/113] 4.4.160-stable review

2018-10-08 Thread Nathan Chancellor
On Mon, Oct 08, 2018 at 08:30:01PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.4.160 release.
> There are 113 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed Oct 10 17:55:13 UTC 2018.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.160-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.4.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Merged, compiled with -Werror, and installed onto my Pixel 2 XL.

No initial issues noticed in dmesg or general usage.

Thanks!
Nathan


Re: [PATCH v3] ARM: dts: imx6sx-sdb: Fix enet phy regulator

2018-10-08 Thread Shawn Guo
On Mon, Oct 08, 2018 at 03:28:01PM +, Leonard Crestez wrote:
> Bindings for "fixed-regulator" only explicitly support "gpio" property,
> not "gpios". Fix by correcting the property name.
> 
> The enet PHYs on imx6sx-sdb needs to be explicitly reset after a power
> cycle, this can be handled by the phy-reset-gpios property. Sadly this
> is not handled on suspend: the fec driver turns phy-supply off but
> doesn't assert phy-reset-gpios again on resume.
> 
> Since additional phy-level work is required to support powering off the
> phy in suspend fix the problem by just marking the regulator as
> "boot-on" "always-on" so that it's never turned off. This behavior is
> equivalent to older releases.
> 
> Keep the phy-reset-gpios property on fec anyway because it is a correct
> description of board design.
> 
> This issue was exposed by commit efdfeb079cc3 ("regulator: fixed:
> Convert to use GPIO descriptor only") which causes the "gpios" property
> to also be parsed. Before that commit the "gpios" property had no
> effect, PHY reset was only handled in the the bootloader.
> 
> This fixes linux-next boot failures previously reported here:
>  https://lore.kernel.org/patchwork/patch/982437/#1177900
>  https://lore.kernel.org/patchwork/patch/994091/#1178304

So this is a fix we only need to apply for 4.20-rc, right?

Shawn

> 
> Signed-off-by: Leonard Crestez 
> 
> ---
> I attempted to fix by asserting phy-reset-gpios on resume but apparently
> phy fixups are still lost and need to be reapplied (not sure why/how).
> 
> Changes since v2:
>  * Mark as always-on boot-enable-on because phy power cycling is hard
>  * Clear Reviewed-by because of large behavior change
>  * Link to v2: https://lore.kernel.org/patchwork/patch/995520/
> 
> Changes since v1:
>  * Use 0x10b0 for phy reset pinctrl value (Fabio)
>  * Link to v1: https://lore.kernel.org/patchwork/patch/994871/
> 
>  arch/arm/boot/dts/imx6sx-sdb.dtsi | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/imx6sx-sdb.dtsi 
> b/arch/arm/boot/dts/imx6sx-sdb.dtsi
> index 53b3408b5fab..7d7d679945d2 100644
> --- a/arch/arm/boot/dts/imx6sx-sdb.dtsi
> +++ b/arch/arm/boot/dts/imx6sx-sdb.dtsi
> @@ -115,11 +115,13 @@
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_enet_3v3>;
>   regulator-name = "enet_3v3";
>   regulator-min-microvolt = <330>;
>   regulator-max-microvolt = <330>;
> - gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
> + gpio = <&gpio2 6 GPIO_ACTIVE_LOW>;
> + regulator-boot-on;
> + regulator-always-on;
>   };
>  
>   reg_pcie_gpio: regulator-pcie-gpio {
>   compatible = "regulator-fixed";
>   pinctrl-names = "default";
> @@ -178,10 +180,11 @@
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_enet1>;
>   phy-supply = <®_enet_3v3>;
>   phy-mode = "rgmii";
>   phy-handle = <ðphy1>;
> + phy-reset-gpios = <&gpio2 7 GPIO_ACTIVE_LOW>;
>   status = "okay";
>  
>   mdio {
>   #address-cells = <1>;
>   #size-cells = <0>;
> @@ -371,10 +374,12 @@
>   MX6SX_PAD_RGMII1_RD1__ENET1_RX_DATA_1   0x3081
>   MX6SX_PAD_RGMII1_RD2__ENET1_RX_DATA_2   0x3081
>   MX6SX_PAD_RGMII1_RD3__ENET1_RX_DATA_3   0x3081
>   MX6SX_PAD_RGMII1_RX_CTL__ENET1_RX_EN0x3081
>   MX6SX_PAD_ENET2_RX_CLK__ENET2_REF_CLK_25M   
> 0x91
> + /* phy reset */
> + MX6SX_PAD_ENET2_CRS__GPIO2_IO_7 0x10b0
>   >;
>   };
>  
>   pinctrl_enet_3v3: enet3v3grp {
>   fsl,pins = <
> -- 
> 2.17.1
> 


[PATCH v2] KVM: LAPIC: Tune lapic_timer_advance_ns automatically

2018-10-08 Thread Wanpeng Li
From: Wanpeng Li 

In cloud environment, lapic_timer_advance_ns is needed to be tuned for every 
CPU 
generations, and every host kernel versions(the 
kvm-unit-tests/tscdeadline_latency.flat 
is 5700 cycles for upstream kernel and 9600 cycles for our 3.10 product kernel, 
both preemption_timer=N, Skylake server).

This patch adds the capability to automatically tune lapic_timer_advance_ns
step by step, the initial value is 1000ns as 'commit d0659d946be0 ("KVM: x86: 
add option to advance tscdeadline hrtimer expiration")' recommended, it will be 
reduced when it is too early, and increased when it is too late. The guest_tsc 
and tsc_deadline are hard to equal, so we assume we are done when the delta 
is within a small scope e.g. 100 cycles. This patch reduces latency 
(kvm-unit-tests/tscdeadline_latency, busy waits, preemption_timer enabled)
from ~2600 cyles to ~1200 cyles on our Skylake server.

Cc: Paolo Bonzini 
Cc: Radim Krčmář 
Cc: Liran Alon 
Signed-off-by: Wanpeng Li 
---
v1 -> v2:
 * converts between guest TSC units to host nanoseconds correctly
 * put hard-coded numbers to #define 

 arch/x86/kvm/lapic.c | 25 -
 arch/x86/kvm/x86.c   |  2 +-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index fbb0e6d..197cf5d 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -70,6 +70,11 @@
 #define APIC_BROADCAST 0xFF
 #define X2APIC_BROADCAST   0xul
 
+static bool lapic_timer_advance_adjust_done = false;
+#define LAPIC_TIMER_ADVANCE_ADJUST_DONE 100
+/* step-by-step approximation to mitigate fluctuation */
+#define LAPIC_TIMER_ADVANCE_ADJUST_STEP 8
+
 static inline int apic_test_vector(int vec, void *bitmap)
 {
return test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
@@ -1472,7 +1477,7 @@ static bool lapic_timer_int_injected(struct kvm_vcpu 
*vcpu)
 void wait_lapic_expire(struct kvm_vcpu *vcpu)
 {
struct kvm_lapic *apic = vcpu->arch.apic;
-   u64 guest_tsc, tsc_deadline;
+   u64 guest_tsc, tsc_deadline, ns;
 
if (!lapic_in_kernel(vcpu))
return;
@@ -1492,6 +1497,24 @@ void wait_lapic_expire(struct kvm_vcpu *vcpu)
if (guest_tsc < tsc_deadline)
__delay(min(tsc_deadline - guest_tsc,
nsec_to_cycles(vcpu, lapic_timer_advance_ns)));
+
+   if (!lapic_timer_advance_adjust_done) {
+   /* too early */
+   if (guest_tsc < tsc_deadline) {
+   ns = (tsc_deadline - guest_tsc) * 100ULL;
+   do_div(ns, vcpu->arch.virtual_tsc_khz);
+   lapic_timer_advance_ns -= min((unsigned int)ns,
+   lapic_timer_advance_ns / 
LAPIC_TIMER_ADVANCE_ADJUST_STEP);
+   } else {
+   /* too late */
+   ns = (guest_tsc - tsc_deadline) * 100ULL;
+   do_div(ns, vcpu->arch.virtual_tsc_khz);
+   lapic_timer_advance_ns += min((unsigned int)ns,
+   lapic_timer_advance_ns / 
LAPIC_TIMER_ADVANCE_ADJUST_STEP);
+   }
+   if (abs(guest_tsc - tsc_deadline) < 
LAPIC_TIMER_ADVANCE_ADJUST_DONE)
+   lapic_timer_advance_adjust_done = true;
+   }
 }
 
 static void start_sw_tscdeadline(struct kvm_lapic *apic)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ca71773..1f3f955 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -136,7 +136,7 @@ static u32 __read_mostly tsc_tolerance_ppm = 250;
 module_param(tsc_tolerance_ppm, uint, S_IRUGO | S_IWUSR);
 
 /* lapic timer advance (tscdeadline mode only) in nanoseconds */
-unsigned int __read_mostly lapic_timer_advance_ns = 0;
+unsigned int __read_mostly lapic_timer_advance_ns = 1000;
 module_param(lapic_timer_advance_ns, uint, S_IRUGO | S_IWUSR);
 EXPORT_SYMBOL_GPL(lapic_timer_advance_ns);
 
-- 
2.7.4



[PATCH 07/12] perf tools: Avoid double free in read_event_file()

2018-10-08 Thread Arnaldo Carvalho de Melo
From: Sanskriti Sharma 

The temporary 'buf' buffer allocated in read_event_file() may be freed
twice.  Move the free() call to the common function exit point.

Fixes the following coverity complaints:

  Error: USE_AFTER_FREE (CWE-825):
  tools/perf/util/trace-event-read.c:309: double_free: Calling "free"
  frees pointer "buf" which has already been freed.

Signed-off-by: Sanskriti Sharma 
Reviewed-by: Jiri Olsa 
Cc: Joe Lawrence 
Link: 
http://lkml.kernel.org/r/1538490554-8161-5-git-send-email-sansh...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/trace-event-read.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/perf/util/trace-event-read.c 
b/tools/perf/util/trace-event-read.c
index b98ee2a2eb44..a278e1eee5f5 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -297,10 +297,8 @@ static int read_event_file(struct tep_handle *pevent, char 
*sys,
}
 
ret = do_read(buf, size);
-   if (ret < 0) {
-   free(buf);
+   if (ret < 0)
goto out;
-   }
 
ret = parse_event_file(pevent, buf, size, sys);
if (ret < 0)
-- 
2.14.4



[PATCH 12/12] tools lib traceevent, perf tools: Move struct tep_handler definition in a local header file

2018-10-08 Thread Arnaldo Carvalho de Melo
From: Tzvetomir Stoyanov 

As traceevent is going to be transferred into a proper library,
its local data should be protected from the library users.
This patch encapsulates struct tep_handler into a local header,
not visible outside of the library. It implements also a bunch
of new APIs, which library users can use to access tep_handler members.

Signed-off-by: Tzvetomir Stoyanov 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: linux trace devel 
Cc: tzvetomir stoyanov 
Link: http://lkml.kernel.org/r/2018100515.52215...@gandalf.local.home
Signed-off-by: Steven Rostedt (VMware) 
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/traceevent/Build   |   1 +
 tools/lib/traceevent/event-parse-api.c   | 275 +++
 tools/lib/traceevent/event-parse-local.h |  92 +++
 tools/lib/traceevent/event-parse.c   |   2 +
 tools/lib/traceevent/event-parse.h   | 228 -
 tools/lib/traceevent/event-plugin.c  |   1 +
 tools/lib/traceevent/parse-filter.c  |   1 +
 tools/perf/util/trace-event-parse.c  |  25 +--
 tools/perf/util/trace-event-read.c   |   2 +-
 9 files changed, 416 insertions(+), 211 deletions(-)
 create mode 100644 tools/lib/traceevent/event-parse-api.c
 create mode 100644 tools/lib/traceevent/event-parse-local.h

diff --git a/tools/lib/traceevent/Build b/tools/lib/traceevent/Build
index 0050c145d806..ba54bfce0b0b 100644
--- a/tools/lib/traceevent/Build
+++ b/tools/lib/traceevent/Build
@@ -5,6 +5,7 @@ libtraceevent-y += parse-filter.o
 libtraceevent-y += parse-utils.o
 libtraceevent-y += kbuffer-parse.o
 libtraceevent-y += tep_strerror.o
+libtraceevent-y += event-parse-api.o
 
 plugin_jbd2-y += plugin_jbd2.o
 plugin_hrtimer-y  += plugin_hrtimer.o
diff --git a/tools/lib/traceevent/event-parse-api.c 
b/tools/lib/traceevent/event-parse-api.c
new file mode 100644
index ..61f7149085ee
--- /dev/null
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -0,0 +1,275 @@
+// SPDX-License-Identifier: LGPL-2.1
+/*
+ * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt 
+ *
+ */
+
+#include "event-parse.h"
+#include "event-parse-local.h"
+#include "event-utils.h"
+
+/**
+ * tep_get_first_event - returns the first event in the events array
+ * @tep: a handle to the tep_handle
+ *
+ * This returns pointer to the first element of the events array
+ * If @tep is NULL, NULL is returned.
+ */
+struct tep_event_format *tep_get_first_event(struct tep_handle *tep)
+{
+   if (tep && tep->events)
+   return tep->events[0];
+
+   return NULL;
+}
+
+/**
+ * tep_get_events_count - get the number of defined events
+ * @tep: a handle to the tep_handle
+ *
+ * This returns number of elements in event array
+ * If @tep is NULL, 0 is returned.
+ */
+int tep_get_events_count(struct tep_handle *tep)
+{
+   if(tep)
+   return tep->nr_events;
+   return 0;
+}
+
+/**
+ * tep_set_flag - set event parser flag
+ * @tep: a handle to the tep_handle
+ * @flag: flag, or combination of flags to be set
+ * can be any combination from enum tep_flag
+ *
+ * This sets a flag or mbination of flags  from enum tep_flag
+  */
+void tep_set_flag(struct tep_handle *tep, int flag)
+{
+   if(tep)
+   tep->flags |= flag;
+}
+
+unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data)
+{
+   unsigned short swap;
+
+   if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
+   return data;
+
+   swap = ((data & 0xffULL) << 8) |
+   ((data & (0xffULL << 8)) >> 8);
+
+   return swap;
+}
+
+unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data)
+{
+   unsigned int swap;
+
+   if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
+   return data;
+
+   swap = ((data & 0xffULL) << 24) |
+   ((data & (0xffULL << 8)) << 8) |
+   ((data & (0xffULL << 16)) >> 8) |
+   ((data & (0xffULL << 24)) >> 24);
+
+   return swap;
+}
+
+unsigned long long
+__tep_data2host8(struct tep_handle *pevent, unsigned long long data)
+{
+   unsigned long long swap;
+
+   if (!pevent || pevent->host_bigendian == pevent->file_bigendian)
+   return data;
+
+   swap = ((data & 0xffULL) << 56) |
+   ((data & (0xffULL << 8)) << 40) |
+   ((data & (0xffULL << 16)) << 24) |
+   ((data & (0xffULL << 24)) << 8) |
+   ((data & (0xffULL << 32)) >> 8) |
+   ((data & (0xffULL << 40)) >> 24) |
+   ((data & (0xffULL << 48)) >> 40) |
+   ((data & (0xffULL << 56)) >> 56);
+
+   return swap;
+}
+
+/**
+ * tep_get_header_page_size - get size of the header page
+ * @pevent: a handle to the tep_handle
+ *
+ * This returns size of the header page
+ * If @pevent is NULL, 0 is returned.
+ */
+int tep_get_header_page_size(struct tep_handle *pevent)
+{
+   if(pevent)
+   retu

[PATCH 03/12] perf test: S390 does not support watchpoints in test 22

2018-10-08 Thread Arnaldo Carvalho de Melo
From: Thomas Richter 

S390 does not support the perf_event_open system call for
attribute type PERF_TYPE_BREAKPOINT. This results in test
failure for test 22:

  [root@s8360046 perf]# ./perf test 22
  22: Watchpoint:
  22.1: Read Only Watchpoint: FAILED!
  22.2: Write Only Watchpoint   : FAILED!
  22.3: Read / Write Watchpoint : FAILED!
  22.4: Modify Watchpoint   : FAILED!
  [root@s8360046 perf]#

Add s390 support to avoid these tests being executed on
s390 platform:

  [root@s8360046 perf]# ./perf test 22
  [root@s8360046 perf]# ./perf test -v 22
  22: Watchpoint: Disabled
  [root@s8360046 perf]#

Signed-off-by: Thomas Richter 
Reviewed-by: Ravi Bangoria 
Cc: Heiko Carstens 
Cc: Hendrik Brueckner 
Cc: Martin Schwidefsky 
Link: http://lkml.kernel.org/r/20180928105335.67179-1-tmri...@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/builtin-test.c |  1 +
 tools/perf/tests/tests.h|  1 +
 tools/perf/tests/wp.c   | 12 
 3 files changed, 14 insertions(+)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 54ca7d87236f..12c09e0ece71 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -123,6 +123,7 @@ static struct test generic_tests[] = {
{
.desc = "Watchpoint",
.func = test__wp,
+   .is_supported = test__wp_is_supported,
.subtest = {
.skip_if_fail   = false,
.get_nr = test__wp_subtest_get_nr,
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 8e26a4148f30..b82f55fcc294 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -109,6 +109,7 @@ int test__unit_number__scnprint(struct test *test, int 
subtest);
 int test__mem2node(struct test *t, int subtest);
 
 bool test__bp_signal_is_supported(void);
+bool test__wp_is_supported(void);
 
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index 017a99317f94..f89e6806557b 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -227,3 +227,15 @@ int test__wp(struct test *test __maybe_unused, int i)
 
return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
 }
+
+/* The s390 so far does not have support for
+ * instruction breakpoint using the perf_event_open() system call.
+ */
+bool test__wp_is_supported(void)
+{
+#if defined(__s390x__)
+   return false;
+#else
+   return true;
+#endif
+}
-- 
2.14.4



[PATCH 08/12] perf tools: Free temporary 'sys' string in read_event_files()

2018-10-08 Thread Arnaldo Carvalho de Melo
From: Sanskriti Sharma 

For each system in a given pevent, read_event_files() reads in a
temporary 'sys' string.  Be sure to free this string before moving onto
to the next system and/or leaving read_event_files().

Fixes the following coverity complaints:

  Error: RESOURCE_LEAK (CWE-772):

  tools/perf/util/trace-event-read.c:343: overwrite_var: Overwriting
  "sys" in "sys = read_string()" leaks the storage that "sys" points to.

  tools/perf/util/trace-event-read.c:353: leaked_storage: Variable "sys"
  going out of scope leaks the storage it points to.

Signed-off-by: Sanskriti Sharma 
Reviewed-by: Jiri Olsa 
Cc: Joe Lawrence 
Link: 
http://lkml.kernel.org/r/1538490554-8161-6-git-send-email-sansh...@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/trace-event-read.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/trace-event-read.c 
b/tools/perf/util/trace-event-read.c
index a278e1eee5f5..add8441de579 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -347,9 +347,12 @@ static int read_event_files(struct tep_handle *pevent)
for (x=0; x < count; x++) {
size = read8(pevent);
ret = read_event_file(pevent, sys, size);
-   if (ret)
+   if (ret) {
+   free(sys);
return ret;
+   }
}
+   free(sys);
}
return 0;
 }
-- 
2.14.4



  1   2   3   4   5   6   7   8   9   10   >