platform/kernel/linux-exynos.git
7 years agosrcu: Fix rcutorture-statistics typo
Paul E. McKenney [Mon, 15 May 2017 00:06:30 +0000 (17:06 -0700)]
srcu: Fix rcutorture-statistics typo

The function srcutorture_get_gp_data() duplicated the check for
sp->batch_check0.head instead of also checking sp->batch_check1.head.
The only effect of this typo would be for rcutorture statistics to
understate the fraction of time that an SRCU grace period was in flight,
and only for Classic SRCU.  This commit fixes this typo.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Remove SPARSE_RCU_POINTER Kconfig option
Paul E. McKenney [Fri, 12 May 2017 22:56:35 +0000 (15:56 -0700)]
rcu: Remove SPARSE_RCU_POINTER Kconfig option

The sparse-based checking for non-RCU accesses to RCU-protected pointers
has been around for a very long time, and it is now the only type of
sparse-based checking that is optional.  This commit therefore makes
it unconditional.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
7 years agorcu: Remove the now-obsolete PROVE_RCU_REPEATEDLY Kconfig option
Paul E. McKenney [Fri, 12 May 2017 21:37:19 +0000 (14:37 -0700)]
rcu: Remove the now-obsolete PROVE_RCU_REPEATEDLY Kconfig option

The PROVE_RCU_REPEATEDLY Kconfig option was initially added due to
the volume of messages from PROVE_RCU: Doing just one per boot would
have required excessive numbers of boots to locate them all.  However,
PROVE_RCU messages are now relatively rare, so there is no longer any
reason to need more than one such message per boot.  This commit therefore
removes the PROVE_RCU_REPEATEDLY Kconfig option.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
7 years agorcu: Remove typecheck() from RCU locking wrapper functions
Paul E. McKenney [Thu, 11 May 2017 22:33:23 +0000 (15:33 -0700)]
rcu: Remove typecheck() from RCU locking wrapper functions

Because raw_spin_lock_irqsave() and raw_spin_unlock_irqrestore()
both do typecheck() on their flags argument, there is no point in
duplicating this check in raw_spin_lock_irqsave_rcu_node() and
raw_spin_unlock_irqrestore_rcu_node().  This commit therefore saves
a few lines by removing this duplicated check.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Remove #ifdef moving rcu_end_inkernel_boot from rcupdate.h
Paul E. McKenney [Thu, 11 May 2017 19:01:50 +0000 (12:01 -0700)]
rcu: Remove #ifdef moving rcu_end_inkernel_boot from rcupdate.h

This commit removes a #ifdef and saves a few lines of code by moving
the rcu_end_inkernel_boot() function from include/linux/rcupdate.h to
include/linux/rcutiny.h (for TINY_RCU) and to include/linux/rcutree.h
(for TREE_RCU).

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Remove nohz_full full-system-idle state machine
Paul E. McKenney [Thu, 11 May 2017 18:26:22 +0000 (11:26 -0700)]
rcu: Remove nohz_full full-system-idle state machine

The NO_HZ_FULL_SYSIDLE full-system-idle capability was added in 2013
by commit 0edd1b1784cb ("nohz_full: Add full-system-idle state machine"),
but has not been used.  This commit therefore removes it.

If it turns out to be needed later, this commit can always be reverted.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
7 years agorcu: Remove the RCU_KTHREAD_PRIO Kconfig option
Paul E. McKenney [Wed, 10 May 2017 22:57:16 +0000 (15:57 -0700)]
rcu: Remove the RCU_KTHREAD_PRIO Kconfig option

Anything that can be done with the RCU_KTHREAD_PRIO Kconfig option can
also be done with the rcutree.kthread_prio kernel boot parameter.
This commit therefore removes this Kconfig option.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
7 years agorcu: Remove *_SLOW_* Kconfig options
Paul E. McKenney [Wed, 10 May 2017 21:36:55 +0000 (14:36 -0700)]
rcu: Remove *_SLOW_* Kconfig options

The RCU_TORTURE_TEST_SLOW_PREINIT, RCU_TORTURE_TEST_SLOW_PREINIT_DELAY,
RCU_TORTURE_TEST_SLOW_PREINIT_DELAY, RCU_TORTURE_TEST_SLOW_INIT,
RCU_TORTURE_TEST_SLOW_INIT_DELAY, RCU_TORTURE_TEST_SLOW_CLEANUP,
and RCU_TORTURE_TEST_SLOW_CLEANUP_DELAY Kconfig options are only
useful for torture testing, and there are the rcutree.gp_cleanup_delay,
rcutree.gp_init_delay, and rcutree.gp_preinit_delay kernel boot parameters
that rcutorture can use instead.  The effect of these parameters is to
artificially slow down grace period initialization and cleanup in order
to make some types of race conditions happen more often.

This commit therefore simplifies Tree RCU a bit by removing the Kconfig
options and adding the corresponding kernel parameters to rcutorture's
.boot files instead.  However, this commit also leaves out the kernel
parameters for TREE02, TREE04, and TREE07 in order to have about the
same number of tests slowed as not slowed.  TREE01, TREE03, TREE05,
and TREE06 are slowed, and the rest are not slowed.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Use rnp->lock wrappers to replace explicit memory barriers
Paul E. McKenney [Tue, 9 May 2017 22:00:14 +0000 (15:00 -0700)]
srcu: Use rnp->lock wrappers to replace explicit memory barriers

This commit uses TREE RCU's rnp->lock wrappers to replace a few explicit
memory barriers.  This change also has the advantage of making SRCU's
memory-ordering properties be implemented in roughly the same way as they
are in Tree RCU.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move rnp->lock wrappers for SRCU use
Paul E. McKenney [Tue, 9 May 2017 20:28:51 +0000 (13:28 -0700)]
rcu: Move rnp->lock wrappers for SRCU use

This commit moves the now-generic rnp->lock wrapper macros from
kernel/rcu/tree.h to kernel/rcu/rcu.h, thus allowing SRCU to use them.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Convert rnp->lock wrappers to macros for SRCU use
Paul E. McKenney [Tue, 9 May 2017 19:05:46 +0000 (12:05 -0700)]
rcu: Convert rnp->lock wrappers to macros for SRCU use

Use of smp_mb__after_unlock_lock() would allow SRCU to omit a full
memory barrier during callback execution, so this commit converts
raw_spin_lock_rcu_node() from inline functions to type-generic macros
to allow them to handle locks in srcu_node structures as well as
rcu_node structures.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Refactor #includes from include/linux/rcupdate.h
Paul E. McKenney [Wed, 3 May 2017 22:24:25 +0000 (15:24 -0700)]
rcu: Refactor #includes from include/linux/rcupdate.h

The list of #includes from include/linux/rcupdate.h has grown quite
a bit, so it is time to trim it.  This commit moves the #include
of include/linux/ktime.h to include/linux/rcutiny.h, along with the
Tiny-RCU-only function that was the only thing needing ktimem.h.  It then
reconstructs the files included into include/linux/ktime.h based on what
is actually needed, with significant help from the 0day Test Robot.

This single change reduces the .i file footprint from rcupdate.h from
9018 lines to 7101 lines.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agobcm47xx: Fix build regression
Arnd Bergmann [Wed, 31 May 2017 16:26:07 +0000 (09:26 -0700)]
bcm47xx: Fix build regression

Commit 0bc2d534708b ("rcu: Refactor #includes from include/linux/rcupdate.h")
caused a build regression in an MTD partition driver:

In file included from drivers/mtd/bcm47xxpart.c:12:0:
include/linux/bcm47xx_nvram.h: In function 'bcm47xx_nvram_init_from_mem':
include/linux/bcm47xx_nvram.h:27:10: error: 'ENOTSUPP' undeclared (first use in this function)

The rcupdate.h file has no particular need for linux/errno.h, so this
commit includes linux/errno.h into bcm47xx_nvram.h.

Fixes: 0bc2d534708b ("rcu: Refactor #includes from include/linux/rcupdate.h")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agolockdep: Use consistent printing primitives
Paul E. McKenney [Thu, 4 May 2017 22:44:38 +0000 (15:44 -0700)]
lockdep: Use consistent printing primitives

Commit a5dd63efda3d ("lockdep: Use "WARNING" tag on lockdep splats")
substituted pr_warn() for printk() in places called out by Dmitry Vyukov.
However, this resulted in an ugly mix of pr_warn() and printk().  This
commit therefore changes printk() to pr_warn() or pr_cont(), depending
on the absence or presence of KERN_CONT.  This is done in all functions
that had printk() changed to pr_warn() by the aforementioned commit.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Apply trivial callback lists to shrink Tiny SRCU
Paul E. McKenney [Thu, 4 May 2017 21:29:16 +0000 (14:29 -0700)]
srcu: Apply trivial callback lists to shrink Tiny SRCU

The rcu_segcblist structure provides quite a bit of functionality, and
Tiny SRCU needs almost none of it.  So this commit replaces Tiny SRCU's
uses of rcu_segcblist with a simple singly linked list with tail pointer.
This change significantly reduces Tiny SRCU's memory footprint, more
than making up for the growth caused by the creation of rcu_segcblist.c

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Shrink srcu.h by moving docbook and private function
Paul E. McKenney [Thu, 4 May 2017 18:31:04 +0000 (11:31 -0700)]
srcu: Shrink srcu.h by moving docbook and private function

The call_srcu() docbook entry is currently in include/linux/srcu.h,
which causes needless processing for each include point.  This commit
therefore moves this entry to kernel/rcu/srcutree.c, which the compiler
reads only once.  In addition, the srcu_batches_completed() function is
used only within RCU and its torture-test suites.  This commit therefore
also moves this function's declaration from include/linux/srcutiny.h,
include/linux/srcutree.h, and include/linux/srcuclassic.h to
kernel/rcu/rcu.h.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Prevent sdp->srcu_gp_seq_needed counter wrap
Paul E. McKenney [Wed, 3 May 2017 22:35:32 +0000 (15:35 -0700)]
srcu: Prevent sdp->srcu_gp_seq_needed counter wrap

If a given CPU never happens to ever start an SRCU grace period, the
grace-period sequence counter might wrap.  If this CPU were to decide to
finally start a grace period, the state of its sdp->srcu_gp_seq_needed
might make it appear that it has already requested this grace period,
which would prevent starting the grace period.  If no other CPU ever started
a grace period again, this would look like a grace-period hang.  Even
if some other CPU took pity and started the needed grace period, the
leaf rcu_node structure's ->srcu_data_have_cbs field won't have record
of the fact that this CPU has a callback pending, which would look like
a very localized grace-period hang.

This might seem very unlikely, but SRCU grace periods can take less than
a microsecond on small systems, which means that overflow can happen
in much less than an hour on a 32-bit embedded system.  And embedded
systems are especially likely to have long-term idle CPUs.  Therefore,
it makes sense to prevent this scenario from happening.

This commit therefore scans each srcu_data structure occasionally,
with frequency controlled by the srcutree.counter_wrap_check kernel
boot parameter.  This parameter can be set to something like 255
in order to exercise the counter-wrap-prevention code.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move rcutiny.h to new empty/true/false-function style
Paul E. McKenney [Wed, 3 May 2017 20:51:42 +0000 (13:51 -0700)]
rcu: Move rcutiny.h to new empty/true/false-function style

This commit saves a few lines in include/linux/rcutiny.h by moving
to single-line definitions for empty functions, instead of the old
style where the two curly braces each get their own line.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move rcu_request_urgent_qs_task() out of rcutiny.h and rcutree.h
Paul E. McKenney [Wed, 3 May 2017 20:45:51 +0000 (13:45 -0700)]
rcu: Move rcu_request_urgent_qs_task() out of rcutiny.h and rcutree.h

The rcu_request_urgent_qs_task() function is used only within RCU,
so there is no point in exporting it to the rest of the kernel from
nclude/linux/rcutiny.h and include/linux/rcutree.h.  This commit therefore
moves this function to kernel/rcu/rcu.h.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move torture-related functions out of rcutiny.h and rcutree.h
Paul E. McKenney [Wed, 3 May 2017 20:37:16 +0000 (13:37 -0700)]
rcu: Move torture-related functions out of rcutiny.h and rcutree.h

The various functions similar to rcu_batches_started(), the
function show_rcu_gp_kthreads(), the various functions similar to
rcu_force_quiescent_state(), and the variables rcutorture_testseq and
rcutorture_vernum are used only within RCU.  There is therefore no point
in exporting them to the kernel at large from include/linux/rcutiny.h
and include/linux/rcutree.h.  This commit therefore moves all of these
to kernel/rcu/rcu.h.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: move rcupdate.h to the new true/false-function style
Paul E. McKenney [Wed, 3 May 2017 19:32:55 +0000 (12:32 -0700)]
rcu: move rcupdate.h to the new true/false-function style

This commit saves a few lines in include/linux/rcupdate.h by moving
to single-line definitions for functions that just return either true
or false, instead of the old style where the two curly braces each get
their own line.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move rcu_ftrace_dump() from rcupdate.h to rcu.h
Paul E. McKenney [Wed, 3 May 2017 19:28:59 +0000 (12:28 -0700)]
rcu: Move rcu_ftrace_dump() from rcupdate.h to rcu.h

The rcu_ftrace_dump() function is used only internally to RCU.  This
commit therefore moves its declaration from include/linux/rcupdate.h
to kernel/rcu/rcu.h.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move rcu_is_nocb_cpu() from rcupdate.h to rcu.h
Paul E. McKenney [Wed, 3 May 2017 19:25:50 +0000 (12:25 -0700)]
rcu: Move rcu_is_nocb_cpu() from rcupdate.h to rcu.h

The rcu_is_nocb_cpu() function is used only internally to RCU.  This
commit therefore moves its declaration from include/linux/rcupdate.h
to kernel/rcu/rcu.h.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Improve __call_rcu() debug-objects error message
Paul E. McKenney [Wed, 3 May 2017 18:38:55 +0000 (11:38 -0700)]
rcu: Improve __call_rcu() debug-objects error message

The "__call_rcu(): Leaked duplicate callback" error message from
__call_rcu() has proven to be unhelpful.  This commit therefore changes
it to "__call_rcu(): Double-freed CB" and adds the value of the pointer
passed in.  The value of the pointer improves debuggability by allowing
correlation with tracing output, for example, the rcu:rcu_callback trace
event.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Remove linux/debugobjects.h from rcupdate.h
Paul E. McKenney [Wed, 3 May 2017 18:18:01 +0000 (11:18 -0700)]
rcu: Remove linux/debugobjects.h from rcupdate.h

The include/linux/rcupdate.h file does not actually need anything from
linux/debugobjects.h, so this commit removes the inclusion.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move the RCU_SCHEDULER_ definitions from rcupdate.h
Paul E. McKenney [Wed, 3 May 2017 18:13:24 +0000 (11:13 -0700)]
rcu: Move the RCU_SCHEDULER_ definitions from rcupdate.h

The RCU_SCHEDULER_INACTIVE, RCU_SCHEDULER_INIT, and RCU_SCHEDULER_RUNNING
definitions are used only within RCU, so this commit moves them from
include/linux/rcupdate.h to kernel/rcu/rcu.h.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Eliminate the unused __rcu_is_watching() function
Paul E. McKenney [Wed, 3 May 2017 18:06:05 +0000 (11:06 -0700)]
rcu: Eliminate the unused __rcu_is_watching() function

The __rcu_is_watching() function is currently not used, aside from
to implement the rcu_is_watching() function.  This commit therefore
eliminates __rcu_is_watching(), which has the beneficial side-effect
of shrinking include/linux/rcupdate.h a bit.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move rcupdate.h to new empty-function style
Paul E. McKenney [Wed, 3 May 2017 17:52:10 +0000 (10:52 -0700)]
rcu: Move rcupdate.h to new empty-function style

This commit saves a few lines in include/linux/rcupdate.h by moving
to single-line definitions for empty functions, instead of the old
style where the two curly braces each get their own line.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Remove UINT_CMP_GE() and UINT_CMP_LT()
Paul E. McKenney [Wed, 3 May 2017 17:36:36 +0000 (10:36 -0700)]
rcu: Remove UINT_CMP_GE() and UINT_CMP_LT()

The UINT_CMP_GE() and UINT_CMP_LT() macros are not used, so this
commit removes them.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move torture-related definitions from rcupdate.h to rcu.h
Paul E. McKenney [Wed, 3 May 2017 17:22:57 +0000 (10:22 -0700)]
rcu: Move torture-related definitions from rcupdate.h to rcu.h

The include/linux/rcupdate.h file contains a number of definitions that
are used only to communicate between rcutorture, rcuperf, and the RCU code
itself.  There is no point in having these definitions exposed globally
throughout the kernel, so this commit moves them to kernel/rcu/rcu.h.
This change has the added benefit of shrinking rcupdate.h.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move expediting-related access/control out of rcupdate.h
Paul E. McKenney [Wed, 3 May 2017 16:51:55 +0000 (09:51 -0700)]
rcu: Move expediting-related access/control out of rcupdate.h

The rcu_gp_is_normal(), rcu_gp_is_expedited(), rcu_expedite_gp(), and
rcu_unexpedite_gp() functions are intended only for use within the
RCU implementation itself -- the sysfs access is what should be used
outside of RCU.  This commit therefore moves the declarations for
these functions to kernel/rcu/rcu.h, and also includes this file into
kernel/rcu/rcutorture.c and kernel/rcu/rcuperf.c.  This also has the
beneficial effect of shrinking rcupdate.c a bit.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move rcu_expedited and rcu_normal externs from rcupdate.h
Paul E. McKenney [Wed, 3 May 2017 16:27:15 +0000 (09:27 -0700)]
rcu: Move rcu_expedited and rcu_normal externs from rcupdate.h

The rcu_expedited and rcu_normal variables are used only by sysctl
and kernel/rcu/update.c, so it does not make sense to their extern
declarations in rcupdate.h.  This commit therefore moves these
extern declarations to update.c.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Move docbook comments out of rcupdate.h
Paul E. McKenney [Wed, 3 May 2017 15:34:57 +0000 (08:34 -0700)]
rcu: Move docbook comments out of rcupdate.h

The include/linux/rcupdate.h file is included by more than 200
files, so shrinking it should provide some build-time benefits.
This commit therefore moves several docbook comments from rcupdate.h to
kernel/rcu/update.c, kernel/rcu/tree.c, and kernel/rcu/tree_plugin.h, thus
reducing the number of times that the compiler has to scan these comments.
This likely provides only a small benefit, but every little bit helps.

This commit also fixes a malformed bulleted list noted by the 0day
Test Robot.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Flag need for rcu_node_tree.h and rcu_segcblist.h visibility
Paul E. McKenney [Tue, 2 May 2017 16:39:09 +0000 (09:39 -0700)]
rcu: Flag need for rcu_node_tree.h and rcu_segcblist.h visibility

The rcu_node_tree.h and rcu_segcblist.h header files in the include/linux
directory might appear at first sight to be internal to the RCU
implementation.  However, the definitions in these files are needed to
determine the size of TREE SRCU's srcu_struct structure, so they must
be externally visible, which is why they live in include/linux.

This commit adds comments to this effect to those files.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Add memory barriers for NOCB leader wakeup
Paul E. McKenney [Sat, 29 Apr 2017 03:11:09 +0000 (20:11 -0700)]
rcu: Add memory barriers for NOCB leader wakeup

Wait/wakeup operations do not guarantee ordering on their own.  Instead,
either locking or memory barriers are required.  This commit therefore
adds memory barriers to wake_nocb_leader() and nocb_leader_wait().

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Tested-by: Krister Johansen <kjlx@templeofstupid.com>
Cc: <stable@vger.kernel.org> # 4.6.x
7 years agorcu: Use RCU_NOCB_WAKE rather than RCU_NOGP_WAKE
Paul E. McKenney [Sat, 29 Apr 2017 00:04:09 +0000 (17:04 -0700)]
rcu: Use RCU_NOCB_WAKE rather than RCU_NOGP_WAKE

The RCU_NOGP_WAKE_NOT, RCU_NOGP_WAKE, and RCU_NOGP_WAKE_FORCE flags
are used to mediate wakeups for the no-CBs CPU kthreads.  The "NOGP"
really doesn't make any sense, so this commit does s/NOGP/NOCB/.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosched: Rely on synchronize_rcu_mult() de-duplication
Paul E. McKenney [Fri, 28 Apr 2017 23:33:07 +0000 (16:33 -0700)]
sched: Rely on synchronize_rcu_mult() de-duplication

The synchronize_rcu_mult() function now detects duplicate requests
for the same grace-period flavor and waits only once for each flavor.
This commit therefore removes the ugly #ifdef from sched_cpu_deactivate()
because synchronize_rcu_mult(call_rcu, call_rcu_sched) now does what
the #ifdef used to be needed for.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
7 years agorcu: Make synchronize_rcu_mult() check for duplicates
Paul E. McKenney [Fri, 28 Apr 2017 23:19:07 +0000 (16:19 -0700)]
rcu: Make synchronize_rcu_mult() check for duplicates

Currently, doing synchronize_rcu_mult(call_rcu, call_rcu) might
(or might not) wait for two RCU grace periods.  One approach is
of course "don't do that!", but in CONFIG_PREEMPT=n kernels,
synchronize_rcu_mult(call_rcu, call_rcu_sched) does exactly that.
This results in an ugly #ifdef in sched_cpu_deactivate().

This commit therefore makes __wait_rcu_gp() check for duplicates,
which in turn allows duplicates to be passed to synchronize_rcu_mult()
without risk of waiting twice on the same type of grace period.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Add DEBUG_OBJECTS_RCU_HEAD functionality
Paul E. McKenney [Fri, 28 Apr 2017 22:39:34 +0000 (15:39 -0700)]
srcu: Add DEBUG_OBJECTS_RCU_HEAD functionality

This commit adds DEBUG_OBJECTS_RCU_HEAD checking to detect call_srcu()
counterparts to double-free bugs.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Shrink Tiny SRCU a bit
Paul E. McKenney [Fri, 28 Apr 2017 21:16:16 +0000 (14:16 -0700)]
srcu: Shrink Tiny SRCU a bit

In Tiny SRCU, __srcu_read_lock() is a trivial function, outweighed by
its EXPORT_SYMBOL_GPL(), and on many architectures, its call sequence.
This commit therefore moves it to srcutiny.h so that it can be inlined.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Make SRCU be once again optional
Paul E. McKenney [Fri, 28 Apr 2017 20:53:04 +0000 (13:53 -0700)]
srcu: Make SRCU be once again optional

Commit d160a727c40e ("srcu: Make SRCU be built by default") in response
to build errors, which were caused by code that included srcu.h
despite !SRCU.  However, srcutiny.o is almost 2K of code, which is not
insignificant for those attempting to run the Linux kernel on IoT devices.
This commit therefore makes SRCU be once again optional, and adjusts
srcu.h to allow error-free inclusion in !SRCU kernel builds.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
7 years agorcu: Add lockdep_assert_held() teeth to tree_plugin.h
Paul E. McKenney [Fri, 28 Apr 2017 20:19:28 +0000 (13:19 -0700)]
rcu: Add lockdep_assert_held() teeth to tree_plugin.h

Comments can be helpful, but assertions carry more force.  This commit
therefore adds lockdep_assert_held() and RCU_LOCKDEP_WARN() calls to
enforce lock-held and interrupt-disabled preconditions.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Add lockdep_assert_held() teeth to tree.c
Paul E. McKenney [Fri, 28 Apr 2017 19:32:15 +0000 (12:32 -0700)]
rcu: Add lockdep_assert_held() teeth to tree.c

Comments can be helpful, but assertions carry more force.  This
commit therefore adds lockdep_assert_held() and RCU_LOCKDEP_WARN()
calls to enforce lock-held and interrupt-disabled preconditions.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Print non-default exp_holdoff values at boot time
Paul E. McKenney [Fri, 28 Apr 2017 18:24:22 +0000 (11:24 -0700)]
srcu: Print non-default exp_holdoff values at boot time

This commit makes srcu_bootup_announce() check for non-default values
of the auto-expedite holdoff time exp_holdoff and print a message if so.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Make exp_holdoff module parameter be static
Paul E. McKenney [Fri, 28 Apr 2017 18:20:29 +0000 (11:20 -0700)]
srcu: Make exp_holdoff module parameter be static

Because exp_holdoff is not used outside of srcutree.c, it can be static.
This commit therefore makes this change.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Update rcu_bootup_announce_oddness()
Paul E. McKenney [Fri, 28 Apr 2017 18:12:34 +0000 (11:12 -0700)]
rcu: Update rcu_bootup_announce_oddness()

This commit updates rcu_bootup_announce_oddness() to check additional
Kconfig options and module/boot parameters.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Print out rcupdate.c non-default boot-time settings
Paul E. McKenney [Fri, 28 Apr 2017 17:20:28 +0000 (10:20 -0700)]
rcu: Print out rcupdate.c non-default boot-time settings

This commit adds a rcupdate_announce_bootup_oddness() function to
print out non-default values of significant kernel boot parameter
settings to aid in debugging.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Add preemptibility checks in rcu_sched_qs() and rcu_bh_qs()
Paul E. McKenney [Thu, 27 Apr 2017 23:13:53 +0000 (16:13 -0700)]
rcu: Add preemptibility checks in rcu_sched_qs() and rcu_bh_qs()

This commit adds WARN_ON_ONCE() calls that trigger if either
rcu_sched_qs() or rcu_bh_qs() are invoked with preemption enabled.
In the immortal words of Peter Zijlstra: "these are much harder to ignore
than comments".

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agodoc: Take tail recursion into account in RCU requirements
Paul E. McKenney [Thu, 27 Apr 2017 20:25:41 +0000 (13:25 -0700)]
doc: Take tail recursion into account in RCU requirements

This commit classifies tail recursion as an alternative way to write
a loop, with similar limitations.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Document auto-expediting requirement
Paul E. McKenney [Thu, 27 Apr 2017 20:16:15 +0000 (13:16 -0700)]
srcu: Document auto-expediting requirement

This commit documents the auto-expediting requirement satisfied by
commits 2da4b2a7fd8d ("srcu: Expedite first synchronize_srcu() when idle")
and 22607d66bbc3 ("srcu: Specify auto-expedite holdoff time").

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Add "git diff" output to testid.txt file
Paul E. McKenney [Thu, 27 Apr 2017 17:24:08 +0000 (10:24 -0700)]
rcutorture: Add "git diff" output to testid.txt file

Currently, when running from a git archive, the testid.txt file contains
only the branch name, the output of "git status", and the SHA-1 of
the current HEAD.  This is useful, but does not uniquely identify the
source code that was built.  This commit therefore adds the output of
"git diff HEAD", which means that if two testid.txt files compare equal,
they correspond to exactly the same source code.  Give or take the
possibility of SHA-1 collisions, that is.  ;-)

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Add writer_holdoff boot parameter
Paul E. McKenney [Tue, 25 Apr 2017 22:12:56 +0000 (15:12 -0700)]
rcuperf: Add writer_holdoff boot parameter

This commit adds a writer_holdoff boot parameter to rcuperf, which is
intended to be used to test Tree SRCU's auto-expediting.  This
boot parameter is in microseconds, and defaults to zero (that is,
disabled).  Set it to a bit larger than srcutree.exp_holdoff,
keeping the nanosecond/microsecond conversion, to force Tree SRCU
to auto-expedite more aggressively.

This commit also adds documentation for this parameter, and fixes some
alphabetization while in the neighborhood.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu-cbmc: Use /usr/bin/awk instead of /bin/awk
Priyalee Kushwaha [Sat, 22 Apr 2017 17:17:11 +0000 (10:17 -0700)]
srcu-cbmc: Use /usr/bin/awk instead of /bin/awk

Most OS distribution have awk in /usr/bin not in /bin
Without this patch, kernel-devsrc fails to build as
runtime dependency for srcu-cbmc script /bin/awk is
not found.

Signed-off-by: Kushwaha, Priyalee <priyalee.kushwaha@intel.com>
Acked-by: Lance Roy <ldr709@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Set more user-friendly defaults
Paul E. McKenney [Fri, 21 Apr 2017 23:09:15 +0000 (16:09 -0700)]
rcuperf: Set more user-friendly defaults

Common-case use of rcuperf must set rcuperf.nreaders=0 and if not built
as a module, rcuperf.shutdown.  This commit therefore sets the default
for rcuperf.nreaders to zero and sets the default for rcuperf.shutdown
to zero if rcuperf is built as a module and to one otherwise.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Shrink Tiny SRCU a bit more
Paul E. McKenney [Fri, 21 Apr 2017 20:33:20 +0000 (13:33 -0700)]
srcu: Shrink Tiny SRCU a bit more

This commit rearranges Tiny SRCU's srcu_struct structure, substitutes
u8 for bool, and shrinks counters down to short.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Reduce CPUs dedicated to testing Classic SRCU
Paul E. McKenney [Fri, 21 Apr 2017 19:01:32 +0000 (12:01 -0700)]
rcutorture: Reduce CPUs dedicated to testing Classic SRCU

Given that the plan is to retire Classic SRCU in the near future, this
commit reduces the number of CPUs dedicated to testing Classic SRCU.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Make Classic and Tree SRCU announce themselves at bootup
Paul E. McKenney [Fri, 21 Apr 2017 18:16:32 +0000 (11:16 -0700)]
srcu: Make Classic and Tree SRCU announce themselves at bootup

Currently, the only way to tell whether a given kernel is running
Classic, Tiny, or Tree SRCU is to look at the .config file, which
can easily be lost or associated with the wrong kernel.  This commit
therefore has Classic and Tree SRCU identify themselves at boot time.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Add the ability to test tiny RCU flavors
Paul E. McKenney [Fri, 21 Apr 2017 00:17:27 +0000 (17:17 -0700)]
rcuperf: Add the ability to test tiny RCU flavors

This commit adds a TINY rcuperf test scenario, which allows performance
testing of Tiny RCU and Tiny SRCU.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agodocs: Fix typo in Documentation/memory-barriers.txt
Stan Drozd [Thu, 20 Apr 2017 09:03:36 +0000 (11:03 +0200)]
docs: Fix typo in Documentation/memory-barriers.txt

This commit changes "architecure" to the correct spelling,
"architecture".

Signed-off-by: Stan Drozd <drozdziak1@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agoatomics: Add header comment so spin_unlock_wait()
Paul E. McKenney [Wed, 19 Apr 2017 23:20:07 +0000 (16:20 -0700)]
atomics: Add header comment so spin_unlock_wait()

There is material describing the ordering guarantees provided by
spin_unlock_wait(), but it is not necessarily easy to find.  This commit
therefore adds a docbook header comment to this function informally
describing its semantics.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
7 years agodoc/atomic_ops: Clarify smp_mb__{before,after}_atomic()
Paul E. McKenney [Wed, 19 Apr 2017 21:30:37 +0000 (14:30 -0700)]
doc/atomic_ops: Clarify smp_mb__{before,after}_atomic()

This commit explicitly states that surrounding a non-value-returning
atomic read-modify atomic operations provides full ordering, just as
is provided by value-returning atomic read-modify-write operations.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Add test for dynamically initialized srcu_struct
Paul E. McKenney [Wed, 19 Apr 2017 20:43:21 +0000 (13:43 -0700)]
rcuperf: Add test for dynamically initialized srcu_struct

This commit adds a perf_type of "srcud", which species that rcuperf
test SRCU on a dynamically initialized srcu_struct.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agocheckpatch: Remove checks for expedited grace periods
Paul E. McKenney [Wed, 19 Apr 2017 14:37:45 +0000 (07:37 -0700)]
checkpatch: Remove checks for expedited grace periods

There was a time when the expedited grace-period primitives
(synchronize_rcu_expedited(), synchronize_rcu_bh_expedited(), and
synchronize_sched_expedited()) used rather antisocial kernel
facilities like try_stop_cpus().  However, they have since been
housebroken to use only single-CPU IPIs, and typically cause less
disturbance than a scheduling-clock interrupt.  Furthermore, this
disturbance can be eliminated entirely using NO_HZ_FULL on the
one hand or the rcupdate.rcu_normal boot parameter on the other.

This commit therefore removes checkpatch's complaints about use
of the expedited RCU primitives.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Make sync_rcu_preempt_exp_done() return bool
Paul E. McKenney [Tue, 18 Apr 2017 16:53:07 +0000 (09:53 -0700)]
rcu: Make sync_rcu_preempt_exp_done() return bool

The sync_rcu_preempt_exp_done() function returns a logical expression,
but its return type is nevertheless int.  This commit therefore changes
the return type to bool.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Add a Kconfig-fragment file for Classic SRCU
Paul E. McKenney [Mon, 17 Apr 2017 21:53:23 +0000 (14:53 -0700)]
rcuperf: Add a Kconfig-fragment file for Classic SRCU

This commit adds a Kconfig-fragment file for Classic SRCU to ease
performance comparisons with Tree SRCU.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Add ability to performance-test call_rcu() and friends
Paul E. McKenney [Mon, 17 Apr 2017 19:47:10 +0000 (12:47 -0700)]
rcuperf: Add ability to performance-test call_rcu() and friends

This commit upgrades rcuperf so that it can do performance testing on
asynchronous grace-period primitives such as call_srcu().  There is
a new rcuperf.gp_async module parameter that specifies this new behavior,
with the pre-existing rcuperf.gp_exp testing expedited grace periods such as
synchronize_rcu_expedited, and with the default being to test synchronous
non-expedited grace periods such as synchronize_rcu().

There is also a new rcuperf.gp_async_max module parameter that specifies
the maximum number of outstanding callbacks per writer kthread, defaulting
to 1,000.  When this limit is exceeded, the writer thread invokes the
appropriate flavor of rcu_barrier() to wait for callbacks to drain.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
[ paulmck: Removed the redundant initialization noted by Arnd Bergmann. ]

7 years agorcu: Remove obsolete reference to synchronize_kernel()
Paul E. McKenney [Mon, 17 Apr 2017 16:59:53 +0000 (09:59 -0700)]
rcu: Remove obsolete reference to synchronize_kernel()

The synchronize_kernel() primitive was removed in favor of
synchronize_sched() more than a decade ago, and it seems likely that
rather few kernel hackers are familiar with it.  Its continued presence
is therefore providing more confusion than enlightenment.  This commit
therefore removes the reference from the synchronize_sched() header
comment, and adds the corresponding information to the synchronize_rcu(0
header comment.

Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Remove conflicting Kconfig options
Paul E. McKenney [Sat, 15 Apr 2017 02:12:36 +0000 (19:12 -0700)]
rcuperf: Remove conflicting Kconfig options

The TREE and TREE54 rcuperf scenarios' Kconfig fragment files specified
conflicting values for CONFIG_RCU_TRACE.  This commit therefore removes
the =n line in favor of the =y line.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcuperf: Defer expedited/normal check to end of test
Paul E. McKenney [Fri, 14 Apr 2017 23:12:52 +0000 (16:12 -0700)]
rcuperf: Defer expedited/normal check to end of test

Current rcuperf startup checks to see if the user asked to measure
only expedited grace periods, yet constrained all grace periods to be
normal, or if the user asked to measure only normal grace periods, yet
constrained all grace periods to be expedited.  Useless tests of this
sort are aborted.

Unfortunately, making RCU work through the mid-boot dead zone [1] puts
RCU into expedited-only mode during that zone.  Which happens to also
be the exact time that rcuperf carries out the aforementioned check.
So if the user asks rcuperf to measure only normal grace periods (the
default), rcuperf will now always complain and terminate the test.

This commit therefore moves the checks to rcu_perf_cleanup().  This has
the disadvantage of failing to abort useless tests, but avoids the need to
create yet another kthread and the need to do fiddly checks involving the
holdoff time.  (Yes, another approach is to do the checks in a late-stage
init function, but that would require some way to communicate badness
to rcuperf's kthreads, and seems not worth the bother.)

[1] https://lwn.net/Articles/716148/

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Complain if blocking in preemptible RCU read-side critical section
Paul E. McKenney [Wed, 12 Apr 2017 22:29:14 +0000 (15:29 -0700)]
rcu: Complain if blocking in preemptible RCU read-side critical section

Although preemptible RCU allows its read-side critical sections to be
preempted, general blocking is forbidden.  The reason for this is that
excessive preemption times can be handled by CONFIG_RCU_BOOST=y, but a
voluntarily blocked task doesn't care how high you boost its priority.
Because preemptible RCU is a global mechanism, one ill-behaved reader
hurts everyone.  Hence the prohibition against general blocking in
RCU-preempt read-side critical sections.  Preemption yes, blocking no.

This commit enforces this prohibition.

There is a special exception for the -rt patchset (which they kindly
volunteered to implement):  It is OK to block (as opposed to merely being
preempted) within an RCU-preempt read-side critical section, but only if
the blocking is subject to priority inheritance.  This exception permits
CONFIG_RCU_BOOST=y to get -rt RCU readers out of trouble.

Why doesn't this exception also apply to mainline's rt_mutex?  Because
of the possibility that someone does general blocking while holding
an rt_mutex.  Yes, the priority boosting will affect the rt_mutex,
but it won't help with the task doing general blocking while holding
that rt_mutex.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Eliminate possibility of destructive counter overflow
Paul E. McKenney [Wed, 12 Apr 2017 22:16:50 +0000 (15:16 -0700)]
srcu: Eliminate possibility of destructive counter overflow

Earlier versions of Tree SRCU were subject to a counter overflow bug that
could theoretically result in too-short grace periods.  This commit
eliminates this problem by adding an update-side memory barrier.
The short explanation is that if the updater sums the unlock counts
too late to see a given __srcu_read_unlock() increment, that CPU's
next __srcu_read_lock() must see the new value of ->srcu_idx, thus
incrementing the other bank of counters.  This eliminates the possibility
of destructive counter overflow as long as the srcu_read_lock() nesting
level does not exceed floor(ULONG_MAX/NR_CPUS/2), which should be an
eminently reasonable nesting limit, especially on 64-bit systems.

Reported-by: Lance Roy <ldr709@gmail.com>
Suggested-by: Lance Roy <ldr709@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Update test scenarios based on new Kconfig dependencies
Paul E. McKenney [Mon, 10 Apr 2017 23:22:08 +0000 (16:22 -0700)]
rcutorture: Update test scenarios based on new Kconfig dependencies

A number of the rcutorture test scenarios were not using the desired
Kconfig options because dependencies were preventing the selections in the
Kconfig-fragment files from being honored.  This commit therefore updates
the Kconfig-fragment files to account for these changes in dependencies.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Correctly handle CONFIG_RCU_TORTURE_TEST_* options
Paul E. McKenney [Mon, 10 Apr 2017 23:15:06 +0000 (16:15 -0700)]
rcutorture: Correctly handle CONFIG_RCU_TORTURE_TEST_* options

The rcutorture scripting handles the CONFIG_*_TORTURE_TEST Kconfig
options specially, and therefore greps them out of the Kconfig-fragment
files.  Unfortunately, a poor choice of grep pattern means that the
CONFIG_RCU_TORTURE_TEST_SLOW_CLEANUP, CONFIG_RCU_TORTURE_TEST_SLOW_INIT,
and CONFIG_RCU_TORTURE_TEST_SLOW_PREINIT Kconfig options are also grepped
out, preventing rcutorture from using them.  This commit therefore fixes
the offending grep pattern to focus only on the CONFIG_*_TORTURE_TEST
Kconfig options.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcu: Prevent rcu_barrier() from starting needless grace periods
Paul E. McKenney [Mon, 10 Apr 2017 22:40:35 +0000 (15:40 -0700)]
rcu: Prevent rcu_barrier() from starting needless grace periods

Currently rcu_barrier() uses call_rcu() to enqueue new callbacks
on each CPU with a non-empty callback list.  This works, but means
that rcu_barrier() forces grace periods that are not otherwise needed.
The key point is that rcu_barrier() never needs to wait for a grace
period, but instead only for all pre-existing callbacks to be invoked.
This means that rcu_barrier()'s new callbacks should be placed in
the callback-list segment containing the last pre-existing callback.

This commit makes this change using the new rcu_segcblist_entrain()
function.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Add a scenario for Classic SRCU
Paul E. McKenney [Mon, 10 Apr 2017 20:49:03 +0000 (13:49 -0700)]
rcutorture: Add a scenario for Classic SRCU

A robust combination of paranoia and cowardice has resulted in retaining
Classic SRCU (CONFIG_CLASSIC_SRCU) as a backup for the shiny new Tiny
and Tree SRCU implementations.  If it is to be a viable backup, it of
course needs to be tested.  This commit therefore adds an rcutorture
scenario named SRCU-C for Classic SRCU.  This commit also adds this
scenario to the set that are run by default.

Once sufficient good experience has accumulated for Tiny and Tree SRCU,
this test will be removed, along with the Classic SRCU implementation
itself.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Add a scenario for Tiny SRCU
Paul E. McKenney [Mon, 10 Apr 2017 18:39:08 +0000 (11:39 -0700)]
rcutorture: Add a scenario for Tiny SRCU

This commit adds an SRCU-t rcutorture scenario for the new Tiny SRCU
implementation, removing the need to pass the --bootargs parameter to
kvm.sh to run Tiny SRCU tests.  This commit also adds SRCU-t to the set
of scenarios that are run by default.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Fix bug in reporting Kconfig mis-settings
Paul E. McKenney [Mon, 10 Apr 2017 17:48:42 +0000 (10:48 -0700)]
rcutorture: Fix bug in reporting Kconfig mis-settings

Kconfig "select" clauses can defeat Kconfig-fragment file attempts to
clear a given Kconfig variable, and dependencies can defeat attempts to
set a given Kconfig variable.  Because "select" clauses and dependencies
can be added at any time, there needs to be a way to verify that the
Kconfig-fragment file's requests were honored.  And there is, except
that it is buggy.  This commit therefore provides the needed fix.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Add three-level tree test for Tree SRCU
Paul E. McKenney [Mon, 10 Apr 2017 17:27:19 +0000 (10:27 -0700)]
rcutorture: Add three-level tree test for Tree SRCU

This commit adds a test for a three-level srcu_node tree for Tree SRCU
in the existing SRCU-P scenario.  This requires enabling CONFIG_RCU_EXPERT,
so the CONFIG_RCU_EXPERT=n scenario is now SRCU-N.  The reason for using
SRCU-P for the tall tree is that preemption raises the possibility of
locating more bugs than does the non-preemptive SRCU-N.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agorcutorture: Add lockdep to one of the SRCU scenarios
Paul E. McKenney [Mon, 10 Apr 2017 01:55:21 +0000 (18:55 -0700)]
rcutorture: Add lockdep to one of the SRCU scenarios

Back when SRCU was simpler, there wasn't much need for lockdep.
However, with Tree SRCU, it is needed.  This commit therefore adds
CONFIG_PROVE_LOCKING to the SRCU-P scenario.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Allow use of Classic SRCU from both process and interrupt context
Paolo Bonzini [Wed, 31 May 2017 12:03:11 +0000 (14:03 +0200)]
srcu: Allow use of Classic SRCU from both process and interrupt context

Linu Cherian reported a WARN in cleanup_srcu_struct() when shutting
down a guest running iperf on a VFIO assigned device.  This happens
because irqfd_wakeup() calls srcu_read_lock(&kvm->irq_srcu) in interrupt
context, while a worker thread does the same inside kvm_set_irq().  If the
interrupt happens while the worker thread is executing __srcu_read_lock(),
updates to the Classic SRCU ->lock_count[] field or the Tree SRCU
->srcu_lock_count[] field can be lost.

The docs say you are not supposed to call srcu_read_lock() and
srcu_read_unlock() from irq context, but KVM interrupt injection happens
from (host) interrupt context and it would be nice if SRCU supported the
use case.  KVM is using SRCU here not really for the "sleepable" part,
but rather due to its IPI-free fast detection of grace periods.  It is
therefore not desirable to switch back to RCU, which would effectively
revert commit 719d93cd5f5c ("kvm/irqchip: Speed up KVM_SET_GSI_ROUTING",
2014-01-16).

However, the docs are overly conservative.  You can have an SRCU instance
only has users in irq context, and you can mix process and irq context
as long as process context users disable interrupts.  In addition,
__srcu_read_unlock() actually uses this_cpu_dec() on both Tree SRCU and
Classic SRCU.  For those two implementations, only srcu_read_lock()
is unsafe.

When Classic SRCU's __srcu_read_unlock() was changed to use this_cpu_dec(),
in commit 5a41344a3d83 ("srcu: Simplify __srcu_read_unlock() via
this_cpu_dec()", 2012-11-29), __srcu_read_lock() did two increments.
Therefore it kept __this_cpu_inc(), with preempt_disable/enable in
the caller.  Tree SRCU however only does one increment, so on most
architectures it is more efficient for __srcu_read_lock() to use
this_cpu_inc(), and any performance differences appear to be down in
the noise.

Cc: stable@vger.kernel.org
Fixes: 719d93cd5f5c ("kvm/irqchip: Speed up KVM_SET_GSI_ROUTING")
Reported-by: Linu Cherian <linuc.decode@gmail.com>
Suggested-by: Linu Cherian <linuc.decode@gmail.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
7 years agosrcu: Allow use of Tiny/Tree SRCU from both process and interrupt context
Paolo Bonzini [Wed, 31 May 2017 12:03:10 +0000 (14:03 +0200)]
srcu: Allow use of Tiny/Tree SRCU from both process and interrupt context

Linu Cherian reported a WARN in cleanup_srcu_struct() when shutting
down a guest running iperf on a VFIO assigned device.  This happens
because irqfd_wakeup() calls srcu_read_lock(&kvm->irq_srcu) in interrupt
context, while a worker thread does the same inside kvm_set_irq().  If the
interrupt happens while the worker thread is executing __srcu_read_lock(),
updates to the Classic SRCU ->lock_count[] field or the Tree SRCU
->srcu_lock_count[] field can be lost.

The docs say you are not supposed to call srcu_read_lock() and
srcu_read_unlock() from irq context, but KVM interrupt injection happens
from (host) interrupt context and it would be nice if SRCU supported the
use case.  KVM is using SRCU here not really for the "sleepable" part,
but rather due to its IPI-free fast detection of grace periods.  It is
therefore not desirable to switch back to RCU, which would effectively
revert commit 719d93cd5f5c ("kvm/irqchip: Speed up KVM_SET_GSI_ROUTING",
2014-01-16).

However, the docs are overly conservative.  You can have an SRCU instance
only has users in irq context, and you can mix process and irq context
as long as process context users disable interrupts.  In addition,
__srcu_read_unlock() actually uses this_cpu_dec() on both Tree SRCU and
Classic SRCU.  For those two implementations, only srcu_read_lock()
is unsafe.

When Classic SRCU's __srcu_read_unlock() was changed to use this_cpu_dec(),
in commit 5a41344a3d83 ("srcu: Simplify __srcu_read_unlock() via
this_cpu_dec()", 2012-11-29), __srcu_read_lock() did two increments.
Therefore it kept __this_cpu_inc(), with preempt_disable/enable in
the caller.  Tree SRCU however only does one increment, so on most
architectures it is more efficient for __srcu_read_lock() to use
this_cpu_inc(), and any performance differences appear to be down in
the noise.

Unlike Classic and Tree SRCU, Tiny SRCU does increments and decrements on
a single variable.  Therefore, as Peter Zijlstra pointed out, Tiny SRCU's
implementation already supports mixed-context use of srcu_read_lock()
and srcu_read_unlock(), at least as long as uses of srcu_read_lock()
and srcu_read_unlock() in each handler are nested and paired properly.
In other words, it is still illegal to (say) invoke srcu_read_lock()
in an interrupt handler and to invoke the matching srcu_read_unlock()
in a softirq handler.  Therefore, the only change required for Tiny SRCU
is to its comments.

Fixes: 719d93cd5f5c ("kvm/irqchip: Speed up KVM_SET_GSI_ROUTING")
Reported-by: Linu Cherian <linuc.decode@gmail.com>
Suggested-by: Linu Cherian <linuc.decode@gmail.com>
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
7 years agoLinux 4.12-rc4 v4.12-rc4
Linus Torvalds [Sun, 4 Jun 2017 23:47:43 +0000 (16:47 -0700)]
Linux 4.12-rc4

7 years agofs/ufs: Set UFS default maximum bytes per file
Richard Narron [Sun, 4 Jun 2017 23:23:18 +0000 (16:23 -0700)]
fs/ufs: Set UFS default maximum bytes per file

This fixes a problem with reading files larger than 2GB from a UFS-2
file system:

    https://bugzilla.kernel.org/show_bug.cgi?id=195721

The incorrect UFS s_maxsize limit became a problem as of commit
c2a9737f45e2 ("vfs,mm: fix a dead loop in truncate_inode_pages_range()")
which started using s_maxbytes to avoid a page index overflow in
do_generic_file_read().

That caused files to be truncated on UFS-2 file systems because the
default maximum file size is 2GB (MAX_NON_LFS) and UFS didn't update it.

Here I simply increase the default to a common value used by other file
systems.

Signed-off-by: Richard Narron <comet.berkeley@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Will B <will.brokenbourgh2877@gmail.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: <stable@vger.kernel.org> # v4.9 and backports of c2a9737f45e2
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
7 years agoMerge tag 'nfs-for-4.12-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Linus Torvalds [Sun, 4 Jun 2017 18:56:53 +0000 (11:56 -0700)]
Merge tag 'nfs-for-4.12-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs

Pull NFS client bugfixes from Trond Myklebust:
 "Bugfixes include:

   - Fix a typo in commit e092693443b ("NFS append COMMIT after
     synchronous COPY") that breaks copy offload

   - Fix the connect error propagation in xs_tcp_setup_socket()

   - Fix a lock leak in nfs40_walk_client_list

   - Verify that pNFS requests lie within the offset range of the layout
     segment"

* tag 'nfs-for-4.12-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
  nfs: Mark unnecessarily extern functions as static
  SUNRPC: ensure correct error is reported by xs_tcp_setup_socket()
  NFSv4.0: Fix a lock leak in nfs40_walk_client_list
  pnfs: Fix the check for requests in range of layout segment
  xprtrdma: Delete an error message for a failed memory allocation in xprt_rdma_bc_setup()
  pNFS/flexfiles: missing error code in ff_layout_alloc_lseg()
  NFS fix COMMIT after COPY

7 years agoMerge tag 'tty-4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Linus Torvalds [Sun, 4 Jun 2017 18:41:41 +0000 (11:41 -0700)]
Merge tag 'tty-4.12-rc4' of git://git./linux/kernel/git/gregkh/tty

Pull tty fix from Greg KH:
 "Here is a single tty core fix for 4.12-rc4. It reverts a patch that a
  lot of people reported as causing lockdep and other warnings.

  Right after I reverted this in my tree, it seems like another
  "correct" fix might have shown up, but it's too late in the release
  cycle to be messing with tty core locking, so let's just revert this
  for now to go back how things always have been and try it again for
  4.13.

  This has not been in linux-next as I only reverted it a few hours ago"

* tag 'tty-4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
  Revert "tty: fix port buffer locking"

7 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Linus Torvalds [Sun, 4 Jun 2017 18:37:42 +0000 (11:37 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/dtor/input

Pull input subsystem fixes from Dmitry Torokhov:

 - a couple of regression fixes in synaptics and axp20x-pek drivers

 - try to ease transition from PS/2 to RMI for Synaptics touchpad users
   by ensuring we do not try to activate RMI mode when RMI SMBus support
   is not enabled, and nag users a bit to enable it

 - plus a couple of other changes that seemed worthwhile for this
   release

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: axp20x-pek - switch to acpi_dev_present and check for ACPI0011 too
  Input: axp20x-pek - only check for "INTCFD9" ACPI device on Cherry Trail
  Input: tm2-touchkey - use LEN_ON as boolean value instead of LED_FULL
  Input: synaptics - tell users to report when they should be using rmi-smbus
  Input: synaptics - warn the users when there is a better mode
  Input: synaptics - keep PS/2 around when RMI4_SMB is not enabled
  Input: synaptics - clear device info before filling in
  Input: silead - disable interrupt during suspend

7 years agoMerge tag 'rtc-4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni...
Linus Torvalds [Sun, 4 Jun 2017 18:29:32 +0000 (11:29 -0700)]
Merge tag 'rtc-4.12-2' of git://git./linux/kernel/git/abelloni/linux

Pull RTC fixlet from Alexandre Belloni:
 "A single patch, not really a fix but I don't think there is any reason
  to delay it.

  Change the mailing list address"

* tag 'rtc-4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux:
  MAINTAINERS: update RTC mailing list

7 years agoMerge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Sun, 4 Jun 2017 18:15:43 +0000 (11:15 -0700)]
Merge tag 'scsi-fixes' of git://git./linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "This is nine fixes, seven of which are for the qedi driver (new as of
  4.10) the other two are a use after free in the cxgbi drivers and a
  potential NULL dereference in the rdac device handler"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: libcxgbi: fix skb use after free
  scsi: qedi: Fix endpoint NULL panic during recovery.
  scsi: qedi: set max_fin_rt default value
  scsi: qedi: Set firmware tcp msl timer value.
  scsi: qedi: Fix endpoint NULL panic in qedi_set_path.
  scsi: qedi: Set dma_boundary to 0xfff.
  scsi: qedi: Correctly set firmware max supported BDs.
  scsi: qedi: Fix bad pte call trace when iscsiuio is stopped.
  scsi: scsi_dh_rdac: Use ctlr directly in rdac_failover_get()

7 years agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma
Linus Torvalds [Sun, 4 Jun 2017 17:41:32 +0000 (10:41 -0700)]
Merge tag 'for-linus' of git://git./linux/kernel/git/dledford/rdma

Pull rdma fixes from Doug Ledford:
 "For the most part this is just a minor -rc cycle for the rdma
  subsystem. Even given that this is all of the -rc patches since the
  merge window closed, it's still only about 25 patches:

   - Multiple i40iw, nes, iw_cxgb4, hfi1, qib, mlx4, mlx5 fixes

   - A few upper layer protocol fixes (IPoIB, iSER, SRP)

   - A modest number of core fixes"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (26 commits)
  RDMA/SA: Fix kernel panic in CMA request handler flow
  RDMA/umem: Fix missing mmap_sem in get umem ODP call
  RDMA/core: not to set page dirty bit if it's already set.
  RDMA/uverbs: Declare local function static and add brackets to sizeof
  RDMA/netlink: Reduce exposure of RDMA netlink functions
  RDMA/srp: Fix NULL deref at srp_destroy_qp()
  RDMA/IPoIB: Limit the ipoib_dev_uninit_default scope
  RDMA/IPoIB: Replace netdev_priv with ipoib_priv for ipoib_get_link_ksettings
  RDMA/qedr: add null check before pointer dereference
  RDMA/mlx5: set UMR wqe fence according to HCA cap
  net/mlx5: Define interface bits for fencing UMR wqe
  RDMA/mlx4: Fix MAD tunneling when SRIOV is enabled
  RDMA/qib,hfi1: Fix MR reference count leak on write with immediate
  RDMA/hfi1: Defer setting VL15 credits to link-up interrupt
  RDMA/hfi1: change PCI bar addr assignments to Linux API functions
  RDMA/hfi1: fix array termination by appending NULL to attr array
  RDMA/iw_cxgb4: fix the calculation of ipv6 header size
  RDMA/iw_cxgb4: calculate t4_eq_status_entries properly
  RDMA/iw_cxgb4: Avoid touch after free error in ARP failure handlers
  RDMA/nes: ACK MPA Reply frame
  ...

7 years agoRevert "tty: fix port buffer locking"
Greg Kroah-Hartman [Sun, 4 Jun 2017 08:23:25 +0000 (10:23 +0200)]
Revert "tty: fix port buffer locking"

This reverts commit 925bb1ce47f429f69aad35876df7ecd8c53deb7e.

It causes lots of warnings and problems so for now, let's just revert
it.

Reported-by: <valdis.kletnieks@vt.edu>
Reported-by: Russell King <linux@armlinux.org.uk>
Reported-by: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reported-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agonfs: Mark unnecessarily extern functions as static
Jan Kara [Tue, 16 May 2017 10:18:11 +0000 (12:18 +0200)]
nfs: Mark unnecessarily extern functions as static

nfs_initialise_sb() and nfs_clone_super() are declared as extern even
though they are used only in fs/nfs/super.c. Mark them as static.

Also remove explicit 'inline' directive from nfs_initialise_sb() and
leave it upto compiler to decide whether inlining is worth it.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
7 years agoMerge tag 'hwmon-for-linus-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 3 Jun 2017 15:45:03 +0000 (08:45 -0700)]
Merge tag 'hwmon-for-linus-v4.12-rc4' of git://git./linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:
 "A couple of patches for the aspeed pwm fan driver"

* tag 'hwmon-for-linus-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (aspeed-pwm-tacho) make fan/pwm names start with index 1
  hwmon: (aspeed-pwm-tacho) Call of_node_put() on a node not claimed
  hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT
  hwmon: (aspeed-pwm-tacho) Select REGMAP

7 years agoMerge tag 'for-linus-20170602' of git://git.infradead.org/linux-mtd
Linus Torvalds [Sat, 3 Jun 2017 15:42:30 +0000 (08:42 -0700)]
Merge tag 'for-linus-20170602' of git://git.infradead.org/linux-mtd

Pull MTD fixes from Brian Norris:
 "NAND updates from Boris:

  tango fixes:
   - Add missing MODULE_DEVICE_TABLE() in tango_nand.c
   - Update the number of corrected bitflips

  core fixes:
   - Fix a long standing memory leak in nand_scan_tail()
   - Fix several bugs introduced by the per-vendor init/detection
     infrastructure (introduced in 4.12)
   - Add a static specifier to nand_ooblayout_lp_hamming_ops definition"

* tag 'for-linus-20170602' of git://git.infradead.org/linux-mtd:
  mtd: nand: make nand_ooblayout_lp_hamming_ops static
  mtd: nand: tango: Update ecc_stats.corrected
  mtd: nand: tango: Export OF device ID table as module aliases
  mtd: nand: samsung: warn about un-parseable ECC info
  mtd: nand: free vendor-specific resources in init failure paths
  mtd: nand: drop unneeded module.h include
  mtd: nand: don't leak buffers when ->scan_bbt() fails

7 years agohwmon: (aspeed-pwm-tacho) make fan/pwm names start with index 1
Stefan Schaeckeler [Fri, 2 Jun 2017 19:43:28 +0000 (12:43 -0700)]
hwmon: (aspeed-pwm-tacho) make fan/pwm names start with index 1

Make fan and pwm names in sysfs start with index 1 in accordance to
Documentation/hwmon/sysfs-interface conventions.

Current implementation starts with index 0, making tools such as
sensors(1) skip the first fan.

Signed-off-by: Stefan Schaeckeler <sschaeck@cisco.com>
Fixes: 2d7a548a3eff ("drivers: hwmon: Support for ASPEED PWM/Fan tach")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 years agohwmon: (aspeed-pwm-tacho) Call of_node_put() on a node not claimed
Stefan Schaeckeler [Fri, 2 Jun 2017 19:42:08 +0000 (12:42 -0700)]
hwmon: (aspeed-pwm-tacho) Call of_node_put() on a node not claimed

Call of_node_put() on a node claimed with of_node_get() or by any other
means such as for_each_child_of_node().

Signed-off-by: Stefan Schaeckeler <sschaeck@cisco.com>
Fixes: 2d7a548a3eff ("drivers: hwmon: Support for ASPEED PWM/Fan tach")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7 years agoInput: axp20x-pek - switch to acpi_dev_present and check for ACPI0011 too
Hans de Goede [Sat, 3 Jun 2017 00:50:22 +0000 (17:50 -0700)]
Input: axp20x-pek - switch to acpi_dev_present and check for ACPI0011 too

acpi_dev_found checks that there is a matching ACPI node, but it
may be disabled (_STA method returns 0) in which case the
soc_button_array driver will not bind to it and axp20x-pek should
handle the power-button.

This commit switches from acpi_dev_found to acpi_dev_present to
avoid not registering an input-dev for the powerbutton when there
is a disabled PNP0C40 device.

The ACPI-6.0 standard defines a standard gpio button device using
the ACPI0011 HID replacing the custom PNP0C40 gpio device, many
newer devices define both PNP0C40 and ACPI0011 devices enabling one
or the other depending on whether the BIOS thinks it is going to boot
Android or Windows.

This commit adds a check for the ACPI0011 device, so that if
either device is present *and* enabled we don't register an input-dev
for the powerbutton.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
7 years agoInput: axp20x-pek - only check for "INTCFD9" ACPI device on Cherry Trail
Hans de Goede [Sat, 3 Jun 2017 00:18:47 +0000 (17:18 -0700)]
Input: axp20x-pek - only check for "INTCFD9" ACPI device on Cherry Trail

Commit 9b13a4ca8d2c ("Input: axp20x-pek - do not register input device
on some systems") added a check for the INTCFD9 ACPI device which also
handles the powerbutton as on some systems the powerbutton is connected
to both the PMIC, handled by axp20x-pek, and to a gpio on the SoC, handled
by soc_button_array which attaches itself to the INTCFD9 ACPI device.

Testing + comparing DSDTs has shown that this only happens on Cherry
Trail devices with an AXP288 PMIC, the AXP288 PMIC is also used on
Bay Trail devices but there the power button is only connected to
the PMIC and not handled by soc_button_array.

This means that the INTCFD9 check has caused a regression on Bay Trail
devices, causing power-button presses to no longer be seen.

This commit fixes this by limiting the check to devices where the ACPI
node for the AXP288 contains a _HRV (hardware revision) attribute with
a value of 3 which indicates we are dealing with a Cherry Trail platform.

Fixes: 9b13a4ca8d2c ("Input: axp20x-pek - do not register input ...")
Reported-by: Сергей Трусов <t.rus76@ya.ru>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
7 years agoMerge tag 'v4.12-rc3' into for-linus
Dmitry Torokhov [Sat, 3 Jun 2017 00:49:10 +0000 (17:49 -0700)]
Merge tag 'v4.12-rc3' into for-linus

Merge with mainline to get acpi_dev_present() needed by patches to
axp20x-pek driver.

7 years agoMerge tag 'acpi-4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
Linus Torvalds [Fri, 2 Jun 2017 23:36:23 +0000 (16:36 -0700)]
Merge tag 'acpi-4.12-rc4' of git://git./linux/kernel/git/rafael/linux-pm

Pull ACPI fixes from Rafael Wysocki:
 "These revert one more problematic commit related to the ACPI-based
  handling of laptop lids and make some unuseful error messages coming
  from ACPICA go away.

  Specifics:

   - Revert one more commit related to the ACPI-based handling of laptop
     lids that changed the default behavior on laptops that booted with
     closed lids and introduced a regression there (Benjamin Tissoires).

   - Add a missing acpi_put_table() to the code implementing the
     /sys/firmware/acpi/tables interface to prevent a counter in the
     ACPICA core from overflowing (Dan Williams).

   - Drop error messages printed by ACPICA on acpi_get_table() reference
     counting mismatches as they need not indicate real errors at this
     point (Lv Zheng)"

* tag 'acpi-4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPICA: Tables: Fix regression introduced by a too early mechanism enabling
  Revert "ACPI / button: Change default behavior to lid_init_state=open"
  ACPI / sysfs: fix acpi_get_table() leak / acpi-sysfs denial of service

7 years agoMerge tag 'pm-4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Linus Torvalds [Fri, 2 Jun 2017 23:33:33 +0000 (16:33 -0700)]
Merge tag 'pm-4.12-rc4' of git://git./linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "These fix two bugs in error code paths in the cpufreq core and in the
  kirkwood-cpufreq driver.

  Specifics:

   - Make cpufreq_register_driver() return an error if the ->init()
     calls fail for all CPUs to prevent non-functional drivers from
     hanging around for no reason (David Arcari).

   - Make kirkwood-cpufreq check the return value of
     clk_prepare_enable() (which may fail) as appropriate (Arvind
     Yadav)"

* tag 'pm-4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable()
  cpufreq: cpufreq_register_driver() should return -ENODEV if init fails