Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Paul E. McKenney
On Sat, Oct 01, 2016 at 08:00:49PM -0400, Rich Felker wrote:
> On Sat, Oct 01, 2016 at 10:58:37AM -0700, Paul E. McKenney wrote:
> > On Sat, Oct 01, 2016 at 01:05:08PM -0400, Rich Felker wrote:
> > > On Fri, Sep 30, 2016 at 06:48:35AM -0700, Paul E. McKenney wrote:
> > > > On Fri, Sep 30, 2016 at 03:15:11PM +0200, Thomas Gleixner wrote:
> > > > > On Tue, 27 Sep 2016, Rich Felker wrote:
> > > > > > I've managed to get a trace with a stall. I'm not sure what the best
> > > > > > way to share the full thing is, since it's large, but here are the
> > > > > > potentially interesting parts.
> > > > 
> > > > [ . . . ]
> > > > 
> > > > Some RCU commentary, on the off-chance that it helps...
> > > > 
> > > > > So that should kick rcu_sched-7 in 10ms, latest 20ms from now and 
> > > > > CPU1 goes
> > > > > into a NOHZ idle sleep.
> > > > > 
> > > > > >   -0 [001] d...   109.953436: tick_stop: 
> > > > > > success=1 dependency=NONE
> > > > > >   -0 [001] d...   109.953617: hrtimer_cancel: 
> > > > > > hrtimer=109f449c
> > > > > >   -0 [001] d...   109.953818: hrtimer_start: 
> > > > > > hrtimer=109f449c function=tick_sched_timer expires=10988000 
> > > > > > softexpires=10988000
> > > > > 
> > > > > which is (using the 0.087621us delta between the trace clock and clock
> > > > > MONO) at: 109.880 + 0.087621 = 109.968
> > > > > 
> > > > > Which is about correct as we expect the RCU timer to fire at:
> > > > >   
> > > > >   109.952633 + 0.01 = 109.963633
> > > > > 
> > > > > or latest at
> > > > > 
> > > > >   109.952633 + 0.02 = 109.983633
> > > > >
> > > > > There is another caveat. That nohz stuff can queue the rcu timer on 
> > > > > CPU0, which
> > > > > it did not because:
> > > > 
> > > > Just for annoying completeness, the location of the timer depends on how
> > > > the rcuo callback-offload kthreads are constrained.  And yes, in the 
> > > > most
> > > > constrained case where all CPUs except for CPU 0 are nohz CPUs, they 
> > > > will
> > > > by default all run on CPU 0.
> > > 
> > > In default full nohz configuration, am I correct that all cpus except
> > > cpu0 willd be nohz and that the rcu callbacks then have to run on
> > > cpu0?
> > 
> > In recent kernels, it looks to me that the default is that none of the
> > CPUs will be nohz by default.  You have to build with both NO_HZ_FULL
> > and NO_HZ_FULL_ALL to get the everything-on-CPU-0 behavior.
> 
> Actually NO_HZ_FULL is not supported because
> HAVE_VIRT_CPU_ACCOUNTING_GEN and HAVE_CONTEXT_TRACKING are missing, so
> it's just normal NO_HZ. I listed the relevant config items somewhere
> earlier in this thread I think.

Very good.  Please feel free to go back and double-check, if you wish.

> > But are there rcu0 kthreads running on your system?
> 
> Apparently not:
> 
> # ps aux | grep rcu
> 7 root   0:00 [rcu_sched]
> 8 root   0:00 [rcu_bh]
>   395 root   0:00 grep rcu

OK, you do not have callback-offloading enabled.  We can therefore eliminate
the possibility that you are being hit by callback-offloading logic.

> > > > > >rcu_sched-7 [001] d...   109.952633: timer_start: 
> > > > > > timer=160a9eb0 function=process_timeout expires=4294948284 
> > > > > > [timeout=1] flags=0x0001
> > > > > 
> > > > > The CPU nr encoded in flags is: 1
> > > > > 
> > > > > Now we cancel and restart the timer w/o seing the interrupt expiring
> > > > > it. And that expiry should have happened at 109.968000 !?!
> > > > > 
> > > > > >   -0 [001] d...   109.968225: hrtimer_cancel: 
> > > > > > hrtimer=109f449c
> > > > > >   -0 [001] d...   109.968526: hrtimer_start: 
> > > > > > hrtimer=109f449c function=tick_sched_timer expires=10989000 
> > > > > > softexpires=10989000
> > > > > 
> > > > > So this advances the next tick even further out. And CPU 0 sets the 
> > > > > timer to
> > > > > the exact smae value:
> > > > > 
> > > > > >   -0 [000] d.h.   109.969104: hrtimer_start: 
> > > > > > hrtimer=109e949c function=tick_sched_timer expires=10989000 
> > > > > > softexpires=10989000
> > > > > 
> > > > > 
> > > > > >   -0 [000] d.h.   109.977690: irq_handler_entry: 
> > > > > > irq=16 name=jcore_pit
> > > > > >   -0 [000] d.h.   109.977911: hrtimer_cancel: 
> > > > > > hrtimer=109e949c
> > > > > >   -0 [000] d.h.   109.978053: 
> > > > > > hrtimer_expire_entry: hrtimer=109e949c function=tick_sched_timer 
> > > > > > now=109890434160
> > > > > 
> > > > > Which expires here. And CPU1 instead of getting an interrupt and 
> > > > > expiring
> > > > > the timer does the cancel/restart to the next jiffie again:
> > > > > 
> > > > > >   -0 [001] d...   109.978206: hrtimer_cancel: 
> > > > > > hrtimer=109f449c
> > > > > >   -0 [001] d...   109.978495: hrtimer_start: 
> > > > > > hrtimer=109f449c function=tick_sched_timer expires=1099 
> > > > > > softexpires=1099
>

arch/ia64/kernel/entry.S:621: Error: Operand 2 of `adds' should be a 14-bit integer (-8192-8191)

2016-10-01 Thread kbuild test robot
Hi Will,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: da48d094ce5d7c7dcdad9011648a81c42fd1c2ef Kconfig: remove 
HAVE_LATENCYTOP_SUPPORT
date:   9 months ago
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout da48d094ce5d7c7dcdad9011648a81c42fd1c2ef
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   arch/ia64/kernel/entry.S: Assembler messages:
>> arch/ia64/kernel/entry.S:621: Error: Operand 2 of `adds' should be a 14-bit 
>> integer (-8192-8191)
   arch/ia64/kernel/entry.S:728: Error: Operand 2 of `adds' should be a 14-bit 
integer (-8192-8191)
   arch/ia64/kernel/entry.S:859: Error: Operand 2 of `adds' should be a 14-bit 
integer (-8192-8191)
--
   arch/ia64/kernel/fsys.S: Assembler messages:
>> arch/ia64/kernel/fsys.S:67: Error: Operand 3 of `add' should be a general 
>> register r0-r3
   arch/ia64/kernel/fsys.S:97: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:193: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:336: Error: Operand 3 of `add' should be a general 
register r0-r3
   arch/ia64/kernel/fsys.S:338: Error: Operand 3 of `add' should be a general 
register r0-r3
--
   arch/ia64/kernel/ivt.S: Assembler messages:
>> arch/ia64/kernel/ivt.S:759: Error: Operand 3 of `add' should be a general 
>> register r0-r3

vim +621 arch/ia64/kernel/entry.S

^1da177e Linus Torvalds 2005-04-16  605 PT_REGS_UNWIND_INFO(0)
^1da177e Linus Torvalds 2005-04-16  606  {  /*
^1da177e Linus Torvalds 2005-04-16  607  * Some versions of gas 
generate bad unwind info if the first instruction of a
^1da177e Linus Torvalds 2005-04-16  608  * procedure doesn't go into 
the first slot of a bundle.  This is a workaround.
^1da177e Linus Torvalds 2005-04-16  609  */
^1da177e Linus Torvalds 2005-04-16  610 nop.m 0
^1da177e Linus Torvalds 2005-04-16  611 nop.i 0
^1da177e Linus Torvalds 2005-04-16  612 /*
^1da177e Linus Torvalds 2005-04-16  613  * We need to call 
schedule_tail() to complete the scheduling process.
^1da177e Linus Torvalds 2005-04-16  614  * Called by ia64_switch_to() 
after do_fork()->copy_thread().  r8 contains the
^1da177e Linus Torvalds 2005-04-16  615  * address of the previously 
executing task.
^1da177e Linus Torvalds 2005-04-16  616  */
^1da177e Linus Torvalds 2005-04-16  617 br.call.sptk.many 
rp=ia64_invoke_schedule_tail
^1da177e Linus Torvalds 2005-04-16  618  }
^1da177e Linus Torvalds 2005-04-16  619  .ret8:
54d496c3 Al Viro2012-10-14  620  (pKStk)br.call.sptk.many 
rp=call_payload
^1da177e Linus Torvalds 2005-04-16 @621 adds 
r2=TI_FLAGS+IA64_TASK_SIZE,r13
^1da177e Linus Torvalds 2005-04-16  622 ;;
^1da177e Linus Torvalds 2005-04-16  623 ld4 r2=[r2]
^1da177e Linus Torvalds 2005-04-16  624 ;;
^1da177e Linus Torvalds 2005-04-16  625 mov r8=0
^1da177e Linus Torvalds 2005-04-16  626 and 
r2=_TIF_SYSCALL_TRACEAUDIT,r2
^1da177e Linus Torvalds 2005-04-16  627 ;;
^1da177e Linus Torvalds 2005-04-16  628 cmp.ne p6,p0=r2,r0
^1da177e Linus Torvalds 2005-04-16  629  (p6)   br.cond.spnt 
.strace_check_retval

:: The code at line 621 was first introduced by commit
:: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:: TO: Linus Torvalds 
:: CC: Linus Torvalds 

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


.config.gz
Description: application/gzip


[PATCH] drm: Release resources with a safer function

2016-10-01 Thread Christophe JAILLET
We should use 'ida_simple_remove()' instead of 'ida_remove()' when freeing
resources allocated with 'ida_simple_get()'.

This as been spotted with the following coccinelle script which tries to
detect missing 'ida_simple_remove()' call in error handling paths.

///
@@
expression x;
identifier l;
@@

*   x = ida_simple_get(...);
...
if (...) {
...
}
...
if (...) {
   ...
   goto l;
}
...
*   l: ... when != ida_simple_remove(...);

Signed-off-by: Christophe JAILLET 
---
 drivers/gpu/drm/drm_connector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 26bb78c76481..2e7430283043 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -250,10 +250,10 @@ int drm_connector_init(struct drm_device *dev,
connector->debugfs_entry = NULL;
 out_put_type_id:
if (ret)
-   ida_remove(connector_ida, connector->connector_type_id);
+   ida_simple_remove(connector_ida, connector->connector_type_id);
 out_put_id:
if (ret)
-   ida_remove(&config->connector_ida, connector->index);
+   ida_simple_remove(&config->connector_ida, connector->index);
 out_put:
if (ret)
drm_mode_object_unregister(dev, &connector->base);
-- 
2.7.4



Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Paul E. McKenney
On Sat, Oct 01, 2016 at 11:59:25PM -0400, Rich Felker wrote:
> On Sat, Oct 01, 2016 at 08:00:49PM -0400, Rich Felker wrote:
> > > > > > > - During the whole sequence, hrtimer expiration times are being 
> > > > > > > set to
> > > > > > >   exact jiffies (@ 100 Hz), whereas before it they're quite 
> > > > > > > arbitrary.
> > > > > > 
> > > > > > When a CPU goes into NOHZ idle and the next (timer/hrtimer) is 
> > > > > > farther out
> > > > > > than the next tick, then tick_sched_timer is set to this next event 
> > > > > > which
> > > > > > can be far out. So that's expected.
> > > > > > 
> > > > > > > - The CLOCK_MONOTONIC hrtimer times do not match up with the
> > > > > > >   timestamps; they're off by about 0.087s. I assume this is just
> > > > > > >   sched_clock vs clocksource time and not a big deal.
> > > > > > 
> > > > > > Yes. You can tell the tracer to use clock monotonic so then they 
> > > > > > should match.
> > > > > > 
> > > > > > > - The rcu_sched process is sleeping with timeout=1. This seems
> > > > > > >   odd/excessive.
> > > > > > 
> > > > > > Why is that odd? That's one tick, i.e. 10ms in your case. And 
> > > > > > that's not
> > > > > > the problem at all. The problem is your timer not firing, but the 
> > > > > > cpu is
> > > > > > obviously either getting out of idle and then moves the tick ahead 
> > > > > > for some
> > > > > > unknown reason.
> > > > > 
> > > > > And a one-jiffy timeout is in fact expected behavior when HZ=100.
> > > > > You have to be running HZ=250 or better to have two-jiffy timeouts,
> > > > > and HZ=500 or better for three-jiffy timeouts.
> > > > 
> > > > One possible theory I'm looking at is that the two cpus are both
> > > > waking up (leaving cpu_idle_poll or cpuidle_idle_call) every jiffy
> > > > with sufficient consistency that every time the rcu_gp_fqs_check_wake
> > > > loop wakes up in rcu_gp_kthread, the other cpu is in cpu_idle_loop but
> > > > outside the rcu_idle_enter/rcu_idle_exit range. Would this block
> > > > forward process? I added an LED indicator in rcu_gp_fqs_check_wake
> > > > that shows the low 2 bits of rnp->qsmask every time it's called, and
> > > > under normal operation the LEDs just flash on momentarily or just one
> > > > stays on for a few seconds then goes off. During a stall both are
> > > > stuck on. I'm still trying to make sense of the code but my impression
> > > > so far is that, on a 2-cpu machine, this is a leaf node and the 2 bits
> > > > correspond directly to cpus; is that right? If so I'm a bit confused
> > > > because I don't see how forward progress could ever happen if the cpu
> > > > on which rcu_gp_kthread is blocking forward progress of
> > > > rcu_gp_kthread.
> > > 
> > > No.  If the CPUs are entering and leaving idle, and if your timers
> > > were waking up rcu_sched every few jiffies like it asks, then the
> > > repeated idle entry/exit events would be noticed, courtesy of the atomic
> > > increments of ->dynticks and the rcu_sched kthread's snapshotting and
> > > checking of this value.
> > 
> > I don't see how rcu_sched could notice the changes if it's stuck in
> > the wait loop I think it's stuck in. There is no check of ->dynticks
> > in rcu_gp_fqs_check_wake. Just in case checking *gfp & RCU_GP_FLAG_FQS
> > accomplishes this, I updated my LED hacks to clear the LEDs in that
> > exit path (and killed the other place that could turn them back on
> > from cpu_idle_loop) but I still get 2 LEDs on for 21s followed by a
> > stall message.
> > 
> > > Even if the CPUs were always non-idle on every
> > > time force_quiescent_state() is invoked, give or take the possibility
> > > of counter wrap -- but even on a 32-bit system, that takes awhile.
> > 
> > Perhaps force_quiescent_state is not getting invoked? Does that sound
> > plausible, and if so, how should I go about debugging it? I see it is
> > called from the stall reporting code, so that's presumably what's
> > breaking the stalls.
> 
> I can confirm that force_quiescent_state is not being called at all
> except from the stall handler. Where is it supposed to be called from?
> I can't find any code paths to it except the stall handler and
> __call_rcu_core, but the latter seems to only be called when adding
> new rcu callbacks, not as a response to a stalled rcu_sched thread.
> Maybe I'm missing something but this seems like incorrect logic in the
> rcu subsystem.

This is the RCU logic you are missing within the RCU grace-period kthread:

ret = swait_event_interruptible_timeout(rsp->gp_wq,
rcu_gp_fqs_check_wake(rsp, &gf), j);

On your system, j==1, which means that when the RCU grace-period kthread
sleeps during a grace period, it is supposed to be awakened after one
jiffy regardless of anything else.  On your system (and apparently -only-
your system), this wakeup is not happening.

RCU reacts to your system's failure to awaken it by giving you an RCU
CPU stall warning.

So please do tw

[PATCH] staging: sm750fb: rename macro roundedDiv to rounded_div in ddk750_chip.c

2016-10-01 Thread Moshe Green
Rename CamelCased macro roundedDiv to rounded_div.

This issue was found by checkpatch.pl

Signed-off-by: Moshe Green 
---
 drivers/staging/sm750fb/ddk750_chip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_chip.c 
b/drivers/staging/sm750fb/ddk750_chip.c
index 3a0afe1..e4efe91 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -7,7 +7,7 @@
 #include "ddk750_power.h"
 
 /* n / d + 1 / 2 = (2n + d) / 2d */
-#define roundedDiv(num, denom) ((2 * (num) + (denom)) / (2 * (denom)))
+#define rounded_div(num, denom)((2 * (num) + (denom)) / (2 * (denom)))
 #define MHz(x) ((x) * 100)
 
 logical_chip_type_t sm750_get_chip_type(void)
@@ -102,7 +102,7 @@ static void setMemoryClock(unsigned int frequency)
frequency = MHz(336);
 
/* Calculate the divisor */
-   divisor = roundedDiv(get_mxclk_freq(), frequency);
+   divisor = rounded_div(get_mxclk_freq(), frequency);
 
/* Set the corresponding divisor in the register. */
reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_M2XCLK_MASK;
@@ -152,7 +152,7 @@ static void setMasterClock(unsigned int frequency)
frequency = MHz(190);
 
/* Calculate the divisor */
-   divisor = roundedDiv(get_mxclk_freq(), frequency);
+   divisor = rounded_div(get_mxclk_freq(), frequency);
 
/* Set the corresponding divisor in the register. */
reg = PEEK32(CURRENT_GATE) & ~CURRENT_GATE_MCLK_MASK;
-- 
2.7.4



Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Rich Felker
On Sat, Oct 01, 2016 at 08:00:49PM -0400, Rich Felker wrote:
> > > > > > - During the whole sequence, hrtimer expiration times are being set 
> > > > > > to
> > > > > >   exact jiffies (@ 100 Hz), whereas before it they're quite 
> > > > > > arbitrary.
> > > > > 
> > > > > When a CPU goes into NOHZ idle and the next (timer/hrtimer) is 
> > > > > farther out
> > > > > than the next tick, then tick_sched_timer is set to this next event 
> > > > > which
> > > > > can be far out. So that's expected.
> > > > > 
> > > > > > - The CLOCK_MONOTONIC hrtimer times do not match up with the
> > > > > >   timestamps; they're off by about 0.087s. I assume this is just
> > > > > >   sched_clock vs clocksource time and not a big deal.
> > > > > 
> > > > > Yes. You can tell the tracer to use clock monotonic so then they 
> > > > > should match.
> > > > > 
> > > > > > - The rcu_sched process is sleeping with timeout=1. This seems
> > > > > >   odd/excessive.
> > > > > 
> > > > > Why is that odd? That's one tick, i.e. 10ms in your case. And that's 
> > > > > not
> > > > > the problem at all. The problem is your timer not firing, but the cpu 
> > > > > is
> > > > > obviously either getting out of idle and then moves the tick ahead 
> > > > > for some
> > > > > unknown reason.
> > > > 
> > > > And a one-jiffy timeout is in fact expected behavior when HZ=100.
> > > > You have to be running HZ=250 or better to have two-jiffy timeouts,
> > > > and HZ=500 or better for three-jiffy timeouts.
> > > 
> > > One possible theory I'm looking at is that the two cpus are both
> > > waking up (leaving cpu_idle_poll or cpuidle_idle_call) every jiffy
> > > with sufficient consistency that every time the rcu_gp_fqs_check_wake
> > > loop wakes up in rcu_gp_kthread, the other cpu is in cpu_idle_loop but
> > > outside the rcu_idle_enter/rcu_idle_exit range. Would this block
> > > forward process? I added an LED indicator in rcu_gp_fqs_check_wake
> > > that shows the low 2 bits of rnp->qsmask every time it's called, and
> > > under normal operation the LEDs just flash on momentarily or just one
> > > stays on for a few seconds then goes off. During a stall both are
> > > stuck on. I'm still trying to make sense of the code but my impression
> > > so far is that, on a 2-cpu machine, this is a leaf node and the 2 bits
> > > correspond directly to cpus; is that right? If so I'm a bit confused
> > > because I don't see how forward progress could ever happen if the cpu
> > > on which rcu_gp_kthread is blocking forward progress of
> > > rcu_gp_kthread.
> > 
> > No.  If the CPUs are entering and leaving idle, and if your timers
> > were waking up rcu_sched every few jiffies like it asks, then the
> > repeated idle entry/exit events would be noticed, courtesy of the atomic
> > increments of ->dynticks and the rcu_sched kthread's snapshotting and
> > checking of this value.
> 
> I don't see how rcu_sched could notice the changes if it's stuck in
> the wait loop I think it's stuck in. There is no check of ->dynticks
> in rcu_gp_fqs_check_wake. Just in case checking *gfp & RCU_GP_FLAG_FQS
> accomplishes this, I updated my LED hacks to clear the LEDs in that
> exit path (and killed the other place that could turn them back on
> from cpu_idle_loop) but I still get 2 LEDs on for 21s followed by a
> stall message.
> 
> > Even if the CPUs were always non-idle on every
> > time force_quiescent_state() is invoked, give or take the possibility
> > of counter wrap -- but even on a 32-bit system, that takes awhile.
> 
> Perhaps force_quiescent_state is not getting invoked? Does that sound
> plausible, and if so, how should I go about debugging it? I see it is
> called from the stall reporting code, so that's presumably what's
> breaking the stalls.

I can confirm that force_quiescent_state is not being called at all
except from the stall handler. Where is it supposed to be called from?
I can't find any code paths to it except the stall handler and
__call_rcu_core, but the latter seems to only be called when adding
new rcu callbacks, not as a response to a stalled rcu_sched thread.
Maybe I'm missing something but this seems like incorrect logic in the
rcu subsystem.

Rich


[PATCH perf/core] perf script: fix a use after free crash.

2016-10-01 Thread Krister Johansen
If dso__load_kcore frees all of the existing maps, but one has already
been attached to a callchain cursor node, then we can get a SIGSEGV in
any function that happens to try to use this cursor with the invalid
map.  Use the existing map refcount mechanism to forestall cleanup of a
map until the cursor iterates past the node.

Signed-off-by: Krister Johansen 
---
 tools/perf/util/callchain.c | 12 ++--
 tools/perf/util/callchain.h | 20 
 tools/perf/util/hist.c  |  4 
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 07fd30b..15c89b2 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -439,7 +439,7 @@ fill_node(struct callchain_node *node, struct 
callchain_cursor *cursor)
}
call->ip = cursor_node->ip;
call->ms.sym = cursor_node->sym;
-   call->ms.map = cursor_node->map;
+   call->ms.map = map__get(cursor_node->map);
list_add_tail(&call->list, &node->val);
 
callchain_cursor_advance(cursor);
@@ -464,6 +464,7 @@ add_child(struct callchain_node *parent,
 
list_for_each_entry_safe(call, tmp, &new->val, list) {
list_del(&call->list);
+   map__zput(call->ms.map);
free(call);
}
free(new);
@@ -732,6 +733,7 @@ merge_chain_branch(struct callchain_cursor *cursor,
callchain_cursor_append(cursor, list->ip,
list->ms.map, list->ms.sym);
list_del(&list->list);
+   map__zput(list->ms.map);
free(list);
}
 
@@ -780,7 +782,8 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
}
 
node->ip = ip;
-   node->map = map;
+   map__zput(node->map);
+   node->map = map__get(map);
node->sym = sym;
 
cursor->nr++;
@@ -830,6 +833,8 @@ int fill_callchain_info(struct addr_location *al, struct 
callchain_cursor_node *
goto out;
}
 
+   map__get(al->map);
+
if (al->map->groups == &al->machine->kmaps) {
if (machine__is_host(al->machine)) {
al->cpumode = PERF_RECORD_MISC_KERNEL;
@@ -947,11 +952,13 @@ static void free_callchain_node(struct callchain_node 
*node)
 
list_for_each_entry_safe(list, tmp, &node->parent_val, list) {
list_del(&list->list);
+   map__zput(list->ms.map);
free(list);
}
 
list_for_each_entry_safe(list, tmp, &node->val, list) {
list_del(&list->list);
+   map__zput(list->ms.map);
free(list);
}
 
@@ -1035,6 +1042,7 @@ int callchain_node__make_parent_list(struct 
callchain_node *node)
 out:
list_for_each_entry_safe(chain, new, &head, list) {
list_del(&chain->list);
+   map__zput(chain->ms.map);
free(chain);
}
return -ENOMEM;
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 13e7554..0d944ef 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -5,6 +5,7 @@
 #include 
 #include 
 #include "event.h"
+#include "map.h"
 #include "symbol.h"
 
 #define HELP_PAD "\t\t\t\t"
@@ -178,8 +179,13 @@ int callchain_merge(struct callchain_cursor *cursor,
  */
 static inline void callchain_cursor_reset(struct callchain_cursor *cursor)
 {
+   struct callchain_cursor_node *node;
+
cursor->nr = 0;
cursor->last = &cursor->first;
+
+   for (node = cursor->first; node != NULL; node = node->next)
+   map__zput(node->map);
 }
 
 int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
@@ -238,12 +244,26 @@ int perf_callchain_config(const char *var, const char 
*value);
 static inline void callchain_cursor_snapshot(struct callchain_cursor *dest,
 struct callchain_cursor *src)
 {
+   struct callchain_cursor_node *node;
+
*dest = *src;
 
dest->first = src->curr;
dest->nr -= src->pos;
+
+   for (node = dest->first; node != NULL; node = node->next)
+   map__get(node->map);
 }
 
+static inline void callchain_cursor_snapshot_rele(struct callchain_cursor 
*curs)
+{
+   struct callchain_cursor_node *node;
+
+   for (node = curs->first; node != NULL; node = node->next)
+   map__put(node->map);
+}
+
+
 #ifdef HAVE_SKIP_CALLCHAIN_IDX
 int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain);
 #else
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index b02992e..f8335e8 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -1,6 +1,7 @@
 #include "util.h"
 #include "build-id.h"
 #include "hist.h"
+#include "map.h"
 #include "session.h"

arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3900' requires '-mfp32'

2016-10-01 Thread kbuild test robot
Hi Guenter,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e MIPS: VDSO: Fix build error 
with binutils 2.24 and earlier
date:   9 months ago
config: mips-jmr3927_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 398c7500a1f5f74e207bd2edca1b1721b3cc1f1e
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/gettimeofday.c:1:0: error: '-march=r3900' requires '-mfp32'
/*


vim +1 arch/mips/vdso/gettimeofday.c

a7f4df4e Alex Smith 2015-10-21 @1  /*
a7f4df4e Alex Smith 2015-10-21  2   * Copyright (C) 2015 Imagination 
Technologies
a7f4df4e Alex Smith 2015-10-21  3   * Author: Alex Smith 
a7f4df4e Alex Smith 2015-10-21  4   *
a7f4df4e Alex Smith 2015-10-21  5   * This program is free software; you can 
redistribute it and/or modify it
a7f4df4e Alex Smith 2015-10-21  6   * under the terms of the GNU General Public 
License as published by the
a7f4df4e Alex Smith 2015-10-21  7   * Free Software Foundation;  either version 
2 of the  License, or (at your
a7f4df4e Alex Smith 2015-10-21  8   * option) any later version.
a7f4df4e Alex Smith 2015-10-21  9   */

:: The code at line 1 was first introduced by commit
:: a7f4df4e21dd8a8dab96e88acd2c9c5017b83fc6 MIPS: VDSO: Add implementations 
of gettimeofday() and clock_gettime()

:: TO: Alex Smith 
:: CC: Ralf Baechle 

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


.config.gz
Description: application/gzip


arch/mips/vdso/elf.S:1:0: error: '-march=r3900' requires '-mfp32'

2016-10-01 Thread kbuild test robot
Hi Alex,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: ebb5e78cc63417a35254a791de66e1cc84f963cc MIPS: Initial implementation 
of a VDSO
date:   11 months ago
config: mips-jmr3927_defconfig (attached as .config)
compiler: mips-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout ebb5e78cc63417a35254a791de66e1cc84f963cc
# save the attached .config to linux build tree
make.cross ARCH=mips 

All errors (new ones prefixed by >>):

>> arch/mips/vdso/elf.S:1:0: error: '-march=r3900' requires '-mfp32'
/*

--
>> arch/mips/vdso/sigreturn.S:1:0: error: '-march=r3900' requires '-mfp32'
/*


vim +1 arch/mips/vdso/elf.S

   > 1  /*
 2   * Copyright (C) 2015 Imagination Technologies
 3   * Author: Alex Smith 
 4   *

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


.config.gz
Description: application/gzip


[PATCH] selftests/futex: Check ANSI terminal color support

2016-10-01 Thread SeongJae Park
Because test for color support of the running shell does not aware ANSI
type terminals, it does not print colorful messages on some environemnt.
This commit modifies the test to aware ANSI type terminal, too.

Signed-off-by: SeongJae Park 
---
 tools/testing/selftests/futex/functional/run.sh | 2 +-
 tools/testing/selftests/futex/run.sh| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/run.sh 
b/tools/testing/selftests/futex/functional/run.sh
index e87dbe2a0b0d..7ff002eed624 100755
--- a/tools/testing/selftests/futex/functional/run.sh
+++ b/tools/testing/selftests/futex/functional/run.sh
@@ -24,7 +24,7 @@
 
 # Test for a color capable console
 if [ -z "$USE_COLOR" ]; then
-tput setf 7
+tput setf 7 || tput setaf 7
 if [ $? -eq 0 ]; then
 USE_COLOR=1
 tput sgr0
diff --git a/tools/testing/selftests/futex/run.sh 
b/tools/testing/selftests/futex/run.sh
index 4126312ad64e..88bcb1767362 100755
--- a/tools/testing/selftests/futex/run.sh
+++ b/tools/testing/selftests/futex/run.sh
@@ -23,7 +23,7 @@
 
 # Test for a color capable shell and pass the result to the subdir scripts
 USE_COLOR=0
-tput setf 7
+tput setf 7 || tput setaf 7
 if [ $? -eq 0 ]; then
 USE_COLOR=1
 tput sgr0
-- 
2.10.0



[PATCH] padata: add helper function for queue length

2016-10-01 Thread Jason A. Donenfeld
Since padata has a maximum number of inflight jobs, currently 1000, it's
very useful to know how many jobs are currently queued up. This adds a
simple helper function to expose this information.

Signed-off-by: Jason A. Donenfeld 
---
 include/linux/padata.h |  2 ++
 kernel/padata.c| 16 
 2 files changed, 18 insertions(+)

diff --git a/include/linux/padata.h b/include/linux/padata.h
index 113ee62..4840ae4 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2008, 2009 secunet Security Networks AG
  * Copyright (C) 2008, 2009 Steffen Klassert 
+ * Copyright (C) 2016 Jason A. Donenfeld 
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -181,4 +182,5 @@ extern int padata_register_cpumask_notifier(struct 
padata_instance *pinst,
struct notifier_block *nblock);
 extern int padata_unregister_cpumask_notifier(struct padata_instance *pinst,
  struct notifier_block *nblock);
+extern int padata_queue_len(struct padata_instance *pinst);
 #endif
diff --git a/kernel/padata.c b/kernel/padata.c
index 9932788..17c1e08 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2008, 2009 secunet Security Networks AG
  * Copyright (C) 2008, 2009 Steffen Klassert 
+ * Copyright (C) 2016 Jason A. Donenfeld 
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -1039,3 +1040,18 @@ void padata_free(struct padata_instance *pinst)
kobject_put(&pinst->kobj);
 }
 EXPORT_SYMBOL(padata_free);
+
+/**
+ * padata_queue_len - retreive the number of in progress jobs
+ *
+ * @padata_inst: padata instance from which to read the queue size
+ */
+int padata_queue_len(struct padata_instance *pinst)
+{
+   int len;
+   rcu_read_lock_bh();
+   len = atomic_read(&rcu_dereference_bh(pinst->pd)->refcnt);
+   rcu_read_unlock_bh();
+   return len;
+}
+EXPORT_SYMBOL(padata_queue_len);
-- 
2.10.0



vgacon.c:undefined reference to `screen_info'

2016-10-01 Thread kbuild test robot
Hi Chen,

It's probably a bug fix that unveils the link errors.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: f69405ce6c0fc9f4a039011007371b31f80b470d openrisc: include: asm: 
Kbuild: add default "vga.h"
date:   2 years, 11 months ago
config: openrisc-alldefconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout f69405ce6c0fc9f4a039011007371b31f80b470d
# save the attached .config to linux build tree
make.cross ARCH=openrisc 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `vgacon_save_screen':
>> vgacon.c:(.text+0x20e0): undefined reference to `screen_info'
   vgacon.c:(.text+0x20e8): undefined reference to `screen_info'
   drivers/built-in.o: In function `vgacon_init':
   vgacon.c:(.text+0x284c): undefined reference to `screen_info'
   vgacon.c:(.text+0x2850): undefined reference to `screen_info'
   drivers/built-in.o: In function `vgacon_startup':
   vgacon.c:(.text+0x28d8): undefined reference to `screen_info'
   drivers/built-in.o:vgacon.c:(.text+0x28f0): more undefined references to 
`screen_info' follow

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


.config.gz
Description: application/gzip


include/linux/kprobes.h:361:2: error: invalid use of undefined type 'struct kprobe_ctlblk'

2016-10-01 Thread kbuild test robot
Hi Russell,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: b2c0b2cbb282f0cf42518ffacbe197e6f2884168 nmi: create generic NMI 
backtrace implementation
date:   1 year, 3 months ago
config: mn10300-allyesconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout b2c0b2cbb282f0cf42518ffacbe197e6f2884168
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All errors (new ones prefixed by >>):

   In file included from lib/nmi_backtrace.c:17:0:
   include/linux/kprobes.h: In function 'get_kprobe_ctlblk':
>> include/linux/kprobes.h:361:2: error: invalid use of undefined type 'struct 
>> kprobe_ctlblk'
 return this_cpu_ptr(&kprobe_ctlblk);
 ^~

vim +361 include/linux/kprobes.h

e65845235 Ananth N Mavinakayanahalli 2005-11-07  355  {
b76834bc1 Christoph Lameter  2010-12-06  356
__this_cpu_write(current_kprobe, NULL);
e65845235 Ananth N Mavinakayanahalli 2005-11-07  357  }
e65845235 Ananth N Mavinakayanahalli 2005-11-07  358  
e65845235 Ananth N Mavinakayanahalli 2005-11-07  359  static inline struct 
kprobe_ctlblk *get_kprobe_ctlblk(void)
e65845235 Ananth N Mavinakayanahalli 2005-11-07  360  {
bdffd893a Christoph Lameter  2014-04-29 @361return 
this_cpu_ptr(&kprobe_ctlblk);
e65845235 Ananth N Mavinakayanahalli 2005-11-07  362  }
e65845235 Ananth N Mavinakayanahalli 2005-11-07  363  
^1da177e4 Linus Torvalds 2005-04-16  364  int 
register_kprobe(struct kprobe *p);

:: The code at line 361 was first introduced by commit
:: bdffd893a0e9c431304142d12d9a0a21d365c502 tracing: Replace __get_cpu_var 
uses with this_cpu_ptr

:: TO: Christoph Lameter 
:: CC: Steven Rostedt 

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


.config.gz
Description: application/gzip


[PATCH] ARM: dts: vfxxx: Add node corresponding to OCOTP

2016-10-01 Thread Andrey Smirnov
Add node corresponding to OCOTP IP block.

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boot/dts/vfxxx.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/vfxxx.dtsi b/arch/arm/boot/dts/vfxxx.dtsi
index 2c13ec6..75850c0 100644
--- a/arch/arm/boot/dts/vfxxx.dtsi
+++ b/arch/arm/boot/dts/vfxxx.dtsi
@@ -520,6 +520,12 @@
status = "disabled";
};
 
+   ocotp: ocotp@400a5000 {
+   compatible = "fsl,vf610-ocotp";
+   reg = <0x400a5000 0x1000>;
+   clocks = <&clks VF610_CLK_OCOTP>;
+   };
+
snvs0: snvs@400a7000 {
compatible = "fsl,sec-v4.0-mon", "syscon", 
"simple-mfd";
reg = <0x400a7000 0x2000>;
-- 
2.5.5



[PATCH] ARM: dts: vf610-zii-dev-rev-b: Remove I2C3

2016-10-01 Thread Andrey Smirnov
I2C3 bus was only brought out in revision A1 of the board and revision
B1 only brings out 3 I2C busses (I2C0, I2C1 and I2C2).

Signed-off-by: Andrey Smirnov 
---
 arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 14 --
 1 file changed, 14 deletions(-)

diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts 
b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
index 5c1fcab..fa19cfd 100644
--- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
+++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
@@ -499,13 +499,6 @@
};
 };
 
-&i2c3 {
-   clock-frequency = <10>;
-   pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_i2c3>;
-   status = "okay";
-};
-
 &uart0 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_uart0>;
@@ -663,13 +656,6 @@
>;
};
 
-   pinctrl_i2c3: i2c3grp {
-   fsl,pins = <
-   VF610_PAD_PTA30__I2C3_SCL   0x37ff
-   VF610_PAD_PTA31__I2C3_SDA   0x37ff
-   >;
-   };
-
pinctrl_leds_debug: pinctrl-leds-debug {
fsl,pins = <
 VF610_PAD_PTD20__GPIO_74   0x31c2
-- 
2.5.5



drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used uninitialized in this function

2016-10-01 Thread kbuild test robot
Hi Dave,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91 drm/i915: Introduce & use new 
lightweight SGL iterators
date:   5 months ago
config: x86_64-randconfig-s0-10020750 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
git checkout 85d1225ec066b2ef46fbd0ed1bae78ae1f3e6c91
# save the attached .config to linux build tree
make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All errors (new ones prefixed by >>):

   cc1: warnings being treated as errors
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen8_ggtt_insert_entries':
>> drivers/gpu/drm/i915/i915_gem_gtt.c:2367: error: 'gtt_entry' may be used 
>> uninitialized in this function
   drivers/gpu/drm/i915/i915_gem_gtt.c: In function 'gen6_ggtt_insert_entries':
   drivers/gpu/drm/i915/i915_gem_gtt.c:2442: error: 'gtt_entry' may be used 
uninitialized in this function

vim +/gtt_entry +2367 drivers/gpu/drm/i915/i915_gem_gtt.c

  2361   enum i915_cache_level level, u32 
unused)
  2362  {
  2363  struct drm_i915_private *dev_priv = to_i915(vm->dev);
  2364  struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
  2365  struct sgt_iter sgt_iter;
  2366  gen8_pte_t __iomem *gtt_entries;
> 2367  gen8_pte_t gtt_entry;
  2368  dma_addr_t addr;
  2369  int rpm_atomic_seq;
  2370  int i = 0;

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


.config.gz
Description: application/gzip


Re: [PATCH v3 07/13] futex: Throughput-optimized (TP) futexes

2016-10-01 Thread Waiman Long

On 10/01/2016 02:47 AM, Thomas Gleixner wrote:

On Fri, 30 Sep 2016, Waiman Long wrote:

+   WRITE_ONCE(state->owner, current);
+   preempt_disable();
+   for (;;) {
+   ret = futex_trylock(uaddr, vpid,&uval, true);

Did you actually read what I said? You CANNOT access userspace in a preempt
disabled region without disabling pagefaults and handle the resulting
wreckage yourself.


I think I had missed that comment. My bad:-(

I will fix that with the code changes below. I will also double-check 
your comments again to see if I miss some others.


Cheers,
Longman


---[ cut here 
]-


diff --git a/kernel/futex.c b/kernel/futex.c
index bc16eca..132a36d 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -3520,6 +3520,13 @@ static int futex_spin_on_owner(u32 __user *uaddr, 
u32 vpid,

bool on_owner_pi_list = false;

WRITE_ONCE(state->owner, current);
+retry:
+   /*
+* The preempt_disable() has similar effect as pagefault_disable().
+* As a result, we will have to disable page fault as well and 
handle

+* the case of faulting in the futex word.
+*/
+   pagefault_disable();
preempt_disable();
for (;; loop--) {
ret = futex_trylock(uaddr, vpid, &uval, true);
@@ -3648,6 +3655,14 @@ static int futex_spin_on_owner(u32 __user *uaddr, 
u32 vpid,

}
 out:
preempt_enable();
+   pagefault_enable();
+
+   if (ret == -EFAULT) {
+   ret = fault_in_user_writeable(uaddr);
+   if (!ret)
+   goto retry;
+   }
+
if (owner_task) {
if (on_owner_pi_list)
task_pi_list_del(owner_task, state, false);



Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Rik van Riel
On Sat, 2016-10-01 at 16:44 -0700, Andy Lutomirski wrote:
> On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> > 
> > 
> > +static inline void switch_fpu_finish(void)
> >  {
> > +   set_thread_flag(TIF_LOAD_FPU);
> >  }
> 
> I can imagine this causing problems with kernel code that accesses
> current's FPU state, e.g. get_xsave_field_ptr(). 

That makes me wonder, what test programs do people have
to verify the correctness of the FPU switching code?

I have a few floating point benchmarks that check
the results for correctness, but nothing that adds in
signals, for example.

What do people use?

-- 
All Rights Reversed.

signature.asc
Description: This is a digitally signed message part


Re: [PATCH v2 1/1] mm/percpu.c: fix potential memory leakage for pcpu_embed_first_chunk()

2016-10-01 Thread zijun_hu
Hi Tejun,
  as we discussed, i include some discussion content in the commit message.
could you give some new comments or acknowledgment for this patch?

On 2016/9/30 19:30, zijun_hu wrote:
> From: zijun_hu 
> 
> it will cause memory leakage for pcpu_embed_first_chunk() to go to
> label @out_free if the chunk spans over 3/4 VMALLOC area. all memory
> are allocated and recorded into array @areas for each CPU group, but
> the memory allocated aren't be freed before returning after going to
> label @out_free.
> 
> in order to fix this bug, we check chunk spanned area immediately
> after completing memory allocation for all CPU group, we go to label
> @out_free_areas other than @out_free to free all memory allocated if
> the checking is failed.
> 
> in order to verify the approach, we dump all memory allocated then
> enforce the jump then dump all memory freed, the result is okay after
> checking whether we free all memory we allocate in this function.
> 
> BTW, The approach is chosen after thinking over the below scenes
>  - we don't go to label @out_free directly to fix this issue since we
>maybe free several allocated memory blocks twice
>  - the aim of jumping after pcpu_setup_first_chunk() is bypassing free
>usable memory other than handling error, moreover, the function does
>not return error code in any case, it either panics due to BUG_ON()
>or return 0.
> 
> Signed-off-by: zijun_hu 
> Tested-by: zijun_hu 
> ---
>  this patch is based on mmotm/linux-next branch so can be
>  applied to them directly
> 
>  Changes in v2: 
>   - more detailed commit message is provided as discussed
> with t...@kernel.org
> 
>  mm/percpu.c | 36 ++--
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/mm/percpu.c b/mm/percpu.c
> index 41d9d0b35801..7a5dae185ce1 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1963,7 +1963,7 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, 
> size_t dyn_size,
>   struct pcpu_alloc_info *ai;
>   size_t size_sum, areas_size;
>   unsigned long max_distance;
> - int group, i, rc;
> + int group, i, j, rc;
>  
>   ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size,
>  cpu_distance_fn);
> @@ -1979,7 +1979,8 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, 
> size_t dyn_size,
>   goto out_free;
>   }
>  
> - /* allocate, copy and determine base address */
> + /* allocate, copy and determine base address & max_distance */
> + j = 0;
>   for (group = 0; group < ai->nr_groups; group++) {
>   struct pcpu_group_info *gi = &ai->groups[group];
>   unsigned int cpu = NR_CPUS;
> @@ -2000,6 +2001,21 @@ int __init pcpu_embed_first_chunk(size_t 
> reserved_size, size_t dyn_size,
>   areas[group] = ptr;
>  
>   base = min(ptr, base);
> + if (ptr > areas[j])
> + j = group;
> + }
> + max_distance = areas[j] - base;
> + max_distance += ai->unit_size * ai->groups[j].nr_units;
> +
> + /* warn if maximum distance is further than 75% of vmalloc space */
> + if (max_distance > VMALLOC_TOTAL * 3 / 4) {
> + pr_warn("max_distance=0x%lx too large for vmalloc space 
> 0x%lx\n",
> + max_distance, VMALLOC_TOTAL);
> +#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
> + /* and fail if we have fallback */
> + rc = -EINVAL;
> + goto out_free_areas;
> +#endif
>   }
>  
>   /*
> @@ -2024,24 +2040,8 @@ int __init pcpu_embed_first_chunk(size_t 
> reserved_size, size_t dyn_size,
>   }
>  
>   /* base address is now known, determine group base offsets */
> - i = 0;
>   for (group = 0; group < ai->nr_groups; group++) {
>   ai->groups[group].base_offset = areas[group] - base;
> - if (areas[group] > areas[i])
> - i = group;
> - }
> - max_distance = ai->groups[i].base_offset +
> - (unsigned long)ai->unit_size * ai->groups[i].nr_units;
> -
> - /* warn if maximum distance is further than 75% of vmalloc space */
> - if (max_distance > VMALLOC_TOTAL * 3 / 4) {
> - pr_warn("max_distance=0x%lx too large for vmalloc space 
> 0x%lx\n",
> - max_distance, VMALLOC_TOTAL);
> -#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
> - /* and fail if we have fallback */
> - rc = -EINVAL;
> - goto out_free;
> -#endif
>   }
>  
>   pr_info("Embedded %zu pages/cpu @%p s%zu r%zu d%zu u%zu\n",
> 



Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Rik van Riel
On Sat, 2016-10-01 at 16:44 -0700, Andy Lutomirski wrote:
> On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> > 
> >  #define CREATE_TRACE_POINTS
> >  #include 
> > @@ -197,6 +198,9 @@ __visible inline void
> > prepare_exit_to_usermode(struct pt_regs *regs)
> > if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
> > exit_to_usermode_loop(regs, cached_flags);
> > 
> > +   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
> > +   switch_fpu_return();
> > +
> 
> How about:
> 
> if (unlikely(...)) {
>   exit_to_usermode_loop(regs, cached_flags);
>   cached_flags = READ_ONCE(ti->flags);
> }
> 
> if (ti->flags & _TIF_LOAD_FPU) {
>   clear_thread_flag(TIF_LOAD_FPU);
>   switch_fpu_return();
> }

It looks like test_thread_flag should be fine for avoiding
atomics, too?

  if (unlikely(test_thread_flag(TIF_LOAD_FPU))) {
      clear_thread_flag(TIF_LOAD_FPU);
      switch_fpu_return();
  }


> > +static inline void switch_fpu_finish(void)
> >  {
> > +   set_thread_flag(TIF_LOAD_FPU);
> >  }
> 
> I can imagine this causing problems with kernel code that accesses
> current's FPU state, e.g. get_xsave_field_ptr().  I wonder if it
> would
> make sense to make your changes deeper into the FPU core innards so
> that, for example, we'd have explicit functions that cause the

Whereabouts do you have in mind?

I like your general idea, but am not sure quite where
to put it.

> in-memory state for current to be up-to-date and readable, to cause
> the in-memory state to be up-to-date and writable (which is the same
> thing + TIF_FPU_LOAD + whatever other bookkeeping), and causing the
> in-CPU state to be up-to-date (possibly readable and writable).
> TIF_LOAD_FPU would trigger the latter.
> 
> I've often found it confusing that fpu__save by itself has somewhat
> ill-defined effects.

Fully agreed on both. I guess that means we want a few
different functions:

1) initialize FPU state, both in memory and in registers

2) cause FPU state in registers to be updated from memory,
   if necessary

3) cause FPU state in memory to be updated from registers,
   if necessary

The latter functions could use fpu->fpregs_active to see
whether any action is required, and be called from various
places in the code.

The signal code in particular is doing some strange things
that should probably be hidden away in FPU specific functions.

> 
> > 
> > +/*
> > + * Set up the userspace FPU context before returning to userspace.
> > + */
> > +void switch_fpu_return(void)
> > +{
> > +   struct fpu *fpu = ¤t->thread.fpu;
> > +   bool preload;
> > +   /*
> > +* If the task has used the math, pre-load the FPU on xsave
> > processors
> > +* or if the past 5 consecutive context-switches used math.
> > +*/
> > +   preload = static_cpu_has(X86_FEATURE_FPU) &&
> > + fpu->fpstate_active &&
> > + (use_eager_fpu() || fpu->counter > 5);
> > +
> > +   if (preload) {
> > +   prefetch(&fpu->state);
> > +   fpu->counter++;
> > +   __fpregs_activate(fpu);
> > +   trace_x86_fpu_regs_activated(fpu);
> > +
> > +   /* Don't change CR0.TS if we just switch! */
> > +   if (!__this_cpu_read(fpu_active)) {
> > +   __fpregs_activate_hw();
> > +   __this_cpu_write(fpu_active, true);
> > +   }
> 
> We should just finish getting rid of all TS uses.

Agreed. I will rebase on top of your FPU changes, that
will make things easier for everybody.

-- 
All Rights Reversed.

signature.asc
Description: This is a digitally signed message part


Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Rich Felker
On Sat, Oct 01, 2016 at 10:58:37AM -0700, Paul E. McKenney wrote:
> On Sat, Oct 01, 2016 at 01:05:08PM -0400, Rich Felker wrote:
> > On Fri, Sep 30, 2016 at 06:48:35AM -0700, Paul E. McKenney wrote:
> > > On Fri, Sep 30, 2016 at 03:15:11PM +0200, Thomas Gleixner wrote:
> > > > On Tue, 27 Sep 2016, Rich Felker wrote:
> > > > > I've managed to get a trace with a stall. I'm not sure what the best
> > > > > way to share the full thing is, since it's large, but here are the
> > > > > potentially interesting parts.
> > > 
> > > [ . . . ]
> > > 
> > > Some RCU commentary, on the off-chance that it helps...
> > > 
> > > > So that should kick rcu_sched-7 in 10ms, latest 20ms from now and CPU1 
> > > > goes
> > > > into a NOHZ idle sleep.
> > > > 
> > > > >   -0 [001] d...   109.953436: tick_stop: success=1 
> > > > > dependency=NONE
> > > > >   -0 [001] d...   109.953617: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.953818: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=10988000 
> > > > > softexpires=10988000
> > > > 
> > > > which is (using the 0.087621us delta between the trace clock and clock
> > > > MONO) at: 109.880 + 0.087621 = 109.968
> > > > 
> > > > Which is about correct as we expect the RCU timer to fire at:
> > > >   
> > > >   109.952633 + 0.01 = 109.963633
> > > > 
> > > > or latest at
> > > > 
> > > >   109.952633 + 0.02 = 109.983633
> > > >
> > > > There is another caveat. That nohz stuff can queue the rcu timer on 
> > > > CPU0, which
> > > > it did not because:
> > > 
> > > Just for annoying completeness, the location of the timer depends on how
> > > the rcuo callback-offload kthreads are constrained.  And yes, in the most
> > > constrained case where all CPUs except for CPU 0 are nohz CPUs, they will
> > > by default all run on CPU 0.
> > 
> > In default full nohz configuration, am I correct that all cpus except
> > cpu0 willd be nohz and that the rcu callbacks then have to run on
> > cpu0?
> 
> In recent kernels, it looks to me that the default is that none of the
> CPUs will be nohz by default.  You have to build with both NO_HZ_FULL
> and NO_HZ_FULL_ALL to get the everything-on-CPU-0 behavior.

Actually NO_HZ_FULL is not supported because
HAVE_VIRT_CPU_ACCOUNTING_GEN and HAVE_CONTEXT_TRACKING are missing, so
it's just normal NO_HZ. I listed the relevant config items somewhere
earlier in this thread I think.

> But are there rcu0 kthreads running on your system?

Apparently not:

# ps aux | grep rcu
7 root   0:00 [rcu_sched]
8 root   0:00 [rcu_bh]
  395 root   0:00 grep rcu
  
> > > > >rcu_sched-7 [001] d...   109.952633: timer_start: 
> > > > > timer=160a9eb0 function=process_timeout expires=4294948284 
> > > > > [timeout=1] flags=0x0001
> > > > 
> > > > The CPU nr encoded in flags is: 1
> > > > 
> > > > Now we cancel and restart the timer w/o seing the interrupt expiring
> > > > it. And that expiry should have happened at 109.968000 !?!
> > > > 
> > > > >   -0 [001] d...   109.968225: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.968526: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=10989000 
> > > > > softexpires=10989000
> > > > 
> > > > So this advances the next tick even further out. And CPU 0 sets the 
> > > > timer to
> > > > the exact smae value:
> > > > 
> > > > >   -0 [000] d.h.   109.969104: hrtimer_start: 
> > > > > hrtimer=109e949c function=tick_sched_timer expires=10989000 
> > > > > softexpires=10989000
> > > > 
> > > > 
> > > > >   -0 [000] d.h.   109.977690: irq_handler_entry: 
> > > > > irq=16 name=jcore_pit
> > > > >   -0 [000] d.h.   109.977911: hrtimer_cancel: 
> > > > > hrtimer=109e949c
> > > > >   -0 [000] d.h.   109.978053: hrtimer_expire_entry: 
> > > > > hrtimer=109e949c function=tick_sched_timer now=109890434160
> > > > 
> > > > Which expires here. And CPU1 instead of getting an interrupt and 
> > > > expiring
> > > > the timer does the cancel/restart to the next jiffie again:
> > > > 
> > > > >   -0 [001] d...   109.978206: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > >   -0 [001] d...   109.978495: hrtimer_start: 
> > > > > hrtimer=109f449c function=tick_sched_timer expires=1099 
> > > > > softexpires=1099
> > > > 
> > > > And this repeats;
> > > > 
> > > > >   -0 [000] d.h.   109.987726: irq_handler_entry: 
> > > > > irq=16 name=jcore_pit
> > > > >   -0 [000] d.h.   109.987954: hrtimer_cancel: 
> > > > > hrtimer=109e949c
> > > > >   -0 [000] d.h.   109.988095: hrtimer_expire_entry: 
> > > > > hrtimer=109e949c function=tick_sched_timer now=109900474620
> > > > 
> > > > >   -0 [001] d...   109.988243: hrtimer_cancel: 
> > > > > hrtimer=109f449c
> > > > > 

[PATCH] fnic: Use time64_t to represent trace timestamps

2016-10-01 Thread Deepa Dinamani
trace timestamps use struct timespec and CURRENT_TIME which
are not y2038 safe.
These timestamps are only part of the trace log on the machine
and are not shared with the fnic.
Replace then with y2038 safe struct timespec64 and
ktime_get_real_ts64(), respectively.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Hiral Patel 
Cc: Suma Ramars 
Cc: Brian Uchino 
Cc: "James E.J. Bottomley" 
Cc: "Martin K. Petersen" 
Cc: linux-s...@vger.kernel.org
---
 drivers/scsi/fnic/fnic_trace.c | 4 ++--
 drivers/scsi/fnic/fnic_trace.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 4e15c4b..5a5fa01 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -613,7 +613,7 @@ int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
fc_trace_entries.rd_idx = 0;
}
 
-   fc_buf->time_stamp = CURRENT_TIME;
+   ktime_get_real_ts64(&fc_buf->time_stamp);
fc_buf->host_no = host_no;
fc_buf->frame_type = frame_type;
 
@@ -740,7 +740,7 @@ void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
 
len = *orig_len;
 
-   time_to_tm(tdata->time_stamp.tv_sec, 0, &tm);
+   time64_to_tm(tdata->time_stamp.tv_sec, 0, &tm);
 
fmt = "%02d:%02d:%04ld %02d:%02d:%02d.%09lu ns%8x   %c%8x\t";
len += snprintf(fnic_dbgfs_prt->buffer + len,
diff --git a/drivers/scsi/fnic/fnic_trace.h b/drivers/scsi/fnic/fnic_trace.h
index a8aa057..e375d0c 100644
--- a/drivers/scsi/fnic/fnic_trace.h
+++ b/drivers/scsi/fnic/fnic_trace.h
@@ -72,7 +72,7 @@ struct fnic_trace_data {
 typedef struct fnic_trace_data fnic_trace_data_t;
 
 struct fc_trace_hdr {
-   struct timespec time_stamp;
+   struct timespec64 time_stamp;
u32 host_no;
u8 frame_type;
u8 frame_len;
-- 
2.7.4



[PATCH] fs: nfs: Make nfs boot time y2038 safe

2016-10-01 Thread Deepa Dinamani
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 and ktime_t for
all internal kernel representation of timestamps.
CURRENT_TIME will also be removed.

boot_time is used to construct the nfs client boot verifier.

Use ktime_t to represent boot_time and ktime_get_real() for
the boot_time value.

Following Trond's request https://lkml.org/lkml/2016/6/9/22 ,
use ktime_t instead of converting to struct timespec64.

Use higher and lower 32 bit parts of ktime_t for the boot
verifier.

Use the lower 32 bit part of ktime_t for the authsys_parms
stamp field.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Trond Myklebust 
Cc: Anna Schumaker 
Cc: linux-...@vger.kernel.org
---
 fs/nfs/client.c   |  2 +-
 fs/nfs/netns.h|  2 +-
 fs/nfs/nfs4proc.c | 10 ++
 fs/nfs/nfs4xdr.c  |  2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 1e10678..44d42a4 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1078,7 +1078,7 @@ void nfs_clients_init(struct net *net)
idr_init(&nn->cb_ident_idr);
 #endif
spin_lock_init(&nn->nfs_client_lock);
-   nn->boot_time = CURRENT_TIME;
+   nn->boot_time = ktime_get_real();
 }
 
 #ifdef CONFIG_PROC_FS
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index f0e06e4..fbce0d8 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -29,7 +29,7 @@ struct nfs_net {
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
 #endif
spinlock_t nfs_client_lock;
-   struct timespec boot_time;
+   ktime_t boot_time;
 #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs;
 #endif
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a9dec32..b517cc2 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5123,12 +5123,14 @@ static void nfs4_init_boot_verifier(const struct 
nfs_client *clp,
if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) {
/* An impossible timestamp guarantees this value
 * will never match a generated boot time. */
-   verf[0] = 0;
-   verf[1] = cpu_to_be32(NSEC_PER_SEC + 1);
+   verf[0] = cpu_to_be32(U32_MAX);
+   verf[1] = cpu_to_be32(U32_MAX);
} else {
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
-   verf[0] = cpu_to_be32(nn->boot_time.tv_sec);
-   verf[1] = cpu_to_be32(nn->boot_time.tv_nsec);
+   u64 ns = ktime_to_ns(nn->boot_time);
+
+   verf[0] = cpu_to_be32(ns >> 32);
+   verf[1] = cpu_to_be32(ns);
}
memcpy(bootverf->data, verf, sizeof(bootverf->data));
 }
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 7bd3a5c..a961e15 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr,
*p++ = cpu_to_be32(RPC_AUTH_UNIX);  /* auth_sys */
 
/* authsys_parms rfc1831 */
-   *p++ = cpu_to_be32(nn->boot_time.tv_nsec);  /* stamp */
+   *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
*p++ = cpu_to_be32(0);  /* UID */
*p++ = cpu_to_be32(0);  /* GID */
-- 
2.7.4



net/sunrpc/stats.c:204: undefined reference to `_GLOBAL_OFFSET_TABLE_'

2016-10-01 Thread kbuild test robot
Hi Nicolas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: 461a5e51060c93f5844113f4be9dba513cc92830 do_div(): generic optimization 
for constant divisor on 32-bit machines
date:   11 months ago
config: microblaze-mmu_defconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 461a5e51060c93f5844113f4be9dba513cc92830
# save the attached .config to linux build tree
make.cross ARCH=microblaze 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `rpc_print_iostats':
>> net/sunrpc/stats.c:204: undefined reference to `_GLOBAL_OFFSET_TABLE_'
   scripts/link-vmlinux.sh: line 52: 107322 Segmentation fault  ${LD} 
${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} -T ${lds} ${KBUILD_VMLINUX_INIT} 
--start-group ${KBUILD_VMLINUX_MAIN} --end-group ${1}

vim +204 net/sunrpc/stats.c

840210fc Weston Andros Adamson 2014-06-24  188  
  &stats[task->tk_msg.rpc_proc->p_statidx]);
840210fc Weston Andros Adamson 2014-06-24  189  }
0a702195 Weston Andros Adamson 2012-02-17  190  
EXPORT_SYMBOL_GPL(rpc_count_iostats);
11c556b3 Chuck Lever   2006-03-20  191  
ec535ce1 Adrian Bunk   2006-04-18  192  static void _print_name(struct 
seq_file *seq, unsigned int op,
ec535ce1 Adrian Bunk   2006-04-18  193  struct 
rpc_procinfo *procs)
cc0175c1 Chuck Lever   2006-03-20  194  {
cc0175c1 Chuck Lever   2006-03-20  195  if (procs[op].p_name)
cc0175c1 Chuck Lever   2006-03-20  196  seq_printf(seq, 
"\t%12s: ", procs[op].p_name);
cc0175c1 Chuck Lever   2006-03-20  197  else if (op == 0)
cc0175c1 Chuck Lever   2006-03-20  198  seq_printf(seq, 
"\tNULL: ");
cc0175c1 Chuck Lever   2006-03-20  199  else
cc0175c1 Chuck Lever   2006-03-20  200  seq_printf(seq, 
"\t%12u: ", op);
cc0175c1 Chuck Lever   2006-03-20  201  }
cc0175c1 Chuck Lever   2006-03-20  202  
11c556b3 Chuck Lever   2006-03-20  203  void rpc_print_iostats(struct 
seq_file *seq, struct rpc_clnt *clnt)
11c556b3 Chuck Lever   2006-03-20 @204  {
11c556b3 Chuck Lever   2006-03-20  205  struct rpc_iostats 
*stats = clnt->cl_metrics;
2446ab60 Trond Myklebust   2012-03-01  206  struct rpc_xprt *xprt;
11c556b3 Chuck Lever   2006-03-20  207  unsigned int op, 
maxproc = clnt->cl_maxproc;
11c556b3 Chuck Lever   2006-03-20  208  
11c556b3 Chuck Lever   2006-03-20  209  if (!stats)
11c556b3 Chuck Lever   2006-03-20  210  return;
11c556b3 Chuck Lever   2006-03-20  211  
11c556b3 Chuck Lever   2006-03-20  212  seq_printf(seq, "\tRPC 
iostats version: %s  ", RPC_IOSTATS_VERS);

:: The code at line 204 was first introduced by commit
:: 11c556b3d8d481829ab5f9933a25d29b00913b5a SUNRPC: provide a mechanism for 
collecting stats in the RPC client

:: TO: Chuck Lever 
:: CC: Trond Myklebust 

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


.config.gz
Description: application/gzip


Re: [PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread Andy Lutomirski
On Sat, Oct 1, 2016 at 1:31 PM,   wrote:
> From: Rik van Riel 
>
> Delay the loading of FPU registers until a process switches back to
> userspace. This allows us to skip FPU saving & restoring for kernel
> threads, the idle task, and tasks that are spinning in kernel space.
>
> It also allows us to not repeatedly save & restore the userspace FPU
> context on repeated invocations of kernel_fpu_start & kernel_fpu_end.
>
> Not overwriting the FPU state of a task unless we need to also allows
> us to be be lazier about restoring it, in a future patch.
>
> Signed-off-by: Rik van Riel 
> ---
>  arch/x86/entry/common.c |  4 
>  arch/x86/include/asm/fpu/api.h  |  5 +
>  arch/x86/include/asm/fpu/internal.h | 44 
> +
>  arch/x86/include/asm/thread_info.h  |  4 +++-
>  arch/x86/kernel/fpu/core.c  | 17 --
>  arch/x86/kernel/process.c   | 35 +
>  arch/x86/kernel/process_32.c|  5 ++---
>  arch/x86/kernel/process_64.c|  5 ++---
>  8 files changed, 71 insertions(+), 48 deletions(-)
>
> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> index 1433f6b4607d..a69bbefa3408 100644
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #define CREATE_TRACE_POINTS
>  #include 
> @@ -197,6 +198,9 @@ __visible inline void prepare_exit_to_usermode(struct 
> pt_regs *regs)
> if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
> exit_to_usermode_loop(regs, cached_flags);
>
> +   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
> +   switch_fpu_return();
> +

How about:

if (unlikely(...)) {
  exit_to_usermode_loop(regs, cached_flags);
  cached_flags = READ_ONCE(ti->flags);
}

if (ti->flags & _TIF_LOAD_FPU) {
  clear_thread_flag(TIF_LOAD_FPU);
  switch_fpu_return();
}

or something along those lines.  The issue is that
test_and_clear_thread_flag is unconditionally atomic, which means that
it will slow down the common fast case by quite a bit.

Alternatively, you could try to jam it into thread_struct::status,
which would let you avoid an atomic operation when you clear it, but
you'd still need an atomic op to set it, so this might not be a win.


> +static inline void switch_fpu_finish(void)
>  {
> -   bool preload;
> -   /*
> -* If the task has used the math, pre-load the FPU on xsave processors
> -* or if the past 5 consecutive context-switches used math.
> -*/
> -   preload = static_cpu_has(X86_FEATURE_FPU) &&
> - new_fpu->fpstate_active &&
> - (use_eager_fpu() || new_fpu->counter > 5);
> -
> -   if (preload) {
> -   prefetch(&new_fpu->state);
> -   new_fpu->counter++;
> -   __fpregs_activate(new_fpu);
> -   trace_x86_fpu_regs_activated(new_fpu);
> -
> -   /* Don't change CR0.TS if we just switch! */
> -   if (!__this_cpu_read(fpu_active)) {
> -   __fpregs_activate_hw();
> -   __this_cpu_write(fpu_active, true);
> -   }
> -
> -   copy_kernel_to_fpregs(&new_fpu->state);
> -   } else if (__this_cpu_read(fpu_active)) {
> -   __this_cpu_write(fpu_active, false);
> -   __fpregs_deactivate_hw();
> -   }
> +   set_thread_flag(TIF_LOAD_FPU);
>  }

I can imagine this causing problems with kernel code that accesses
current's FPU state, e.g. get_xsave_field_ptr().  I wonder if it would
make sense to make your changes deeper into the FPU core innards so
that, for example, we'd have explicit functions that cause the
in-memory state for current to be up-to-date and readable, to cause
the in-memory state to be up-to-date and writable (which is the same
thing + TIF_FPU_LOAD + whatever other bookkeeping), and causing the
in-CPU state to be up-to-date (possibly readable and writable).
TIF_LOAD_FPU would trigger the latter.

I've often found it confusing that fpu__save by itself has somewhat
ill-defined effects.


> +/*
> + * Set up the userspace FPU context before returning to userspace.
> + */
> +void switch_fpu_return(void)
> +{
> +   struct fpu *fpu = ¤t->thread.fpu;
> +   bool preload;
> +   /*
> +* If the task has used the math, pre-load the FPU on xsave processors
> +* or if the past 5 consecutive context-switches used math.
> +*/
> +   preload = static_cpu_has(X86_FEATURE_FPU) &&
> + fpu->fpstate_active &&
> + (use_eager_fpu() || fpu->counter > 5);
> +
> +   if (preload) {
> +   prefetch(&fpu->state);
> +   fpu->counter++;
> +   __fpregs_activate(fpu);
> +   trace_x86_fpu_regs_activated(fpu);
> +
> +   /* Don't change CR0.TS if we just switch! */
> +   if (!__this_cpu_read(fpu_a

[PATCH] audit: Use timespec64 to represent audit timestamps

2016-10-01 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Audit timestamps are recorded in string format into
an audit buffer for a given context.
These mark the entry timestamps for the syscalls.
Use y2038 safe struct timespec64 to represent the times.
The log strings can handle this transition as strings can
hold upto 1024 characters.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Acked-by: Paul Moore 
Acked-by: Richard Guy Briggs 
Cc: Eric Paris 
Cc: Paul Moore 
Cc: Richard Guy Briggs 
Cc: linux-au...@redhat.com
---
 include/linux/audit.h |  4 ++--
 kernel/audit.c| 10 +-
 kernel/audit.h|  2 +-
 kernel/auditsc.c  |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/audit.h b/include/linux/audit.h
index 9d4443f..e51782b 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -332,7 +332,7 @@ static inline void audit_ptrace(struct task_struct *t)
/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
 extern int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial);
+ struct timespec64 *t, unsigned int *serial);
 extern int audit_set_loginuid(kuid_t loginuid);
 
 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
@@ -490,7 +490,7 @@ static inline void __audit_seccomp(unsigned long syscall, 
long signr, int code)
 static inline void audit_seccomp(unsigned long syscall, long signr, int code)
 { }
 static inline int auditsc_get_stamp(struct audit_context *ctx,
- struct timespec *t, unsigned int *serial)
+ struct timespec64 *t, unsigned int *serial)
 {
return 0;
 }
diff --git a/kernel/audit.c b/kernel/audit.c
index a8a91bd..b03b6c7 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1325,10 +1325,10 @@ unsigned int audit_serial(void)
 }
 
 static inline void audit_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx || !auditsc_get_stamp(ctx, t, serial)) {
-   *t = CURRENT_TIME;
+   ktime_get_real_ts64(t);
*serial = audit_serial();
}
 }
@@ -1370,7 +1370,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 int type)
 {
struct audit_buffer *ab = NULL;
-   struct timespec t;
+   struct timespec64   t;
unsigned intuninitialized_var(serial);
int reserve = 5; /* Allow atomic callers to go up to five
entries over the normal backlog limit */
@@ -1422,8 +1422,8 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
 
audit_get_stamp(ab->ctx, &t, &serial);
 
-   audit_log_format(ab, "audit(%lu.%03lu:%u): ",
-t.tv_sec, t.tv_nsec/100, serial);
+   audit_log_format(ab, "audit(%llu.%03lu:%u): ",
+(unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
return ab;
 }
 
diff --git a/kernel/audit.h b/kernel/audit.h
index 431444c..55d1ca2 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -112,7 +112,7 @@ struct audit_context {
enum audit_statestate, current_state;
unsigned intserial; /* serial number for record */
int major;  /* syscall number */
-   struct timespec ctime;  /* time of syscall entry */
+   struct timespec64   ctime;  /* time of syscall entry */
unsigned long   argv[4];/* syscall arguments */
longreturn_code;/* syscall return code */
u64 prio;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 5abf1dc..8dc7fe9 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1522,7 +1522,7 @@ void __audit_syscall_entry(int major, unsigned long a1, 
unsigned long a2,
return;
 
context->serial = 0;
-   context->ctime  = CURRENT_TIME;
+   ktime_get_real_ts64(&context->ctime);
context->in_syscall = 1;
context->current_state  = state;
context->ppid   = 0;
@@ -1931,13 +1931,13 @@ EXPORT_SYMBOL_GPL(__audit_inode_child);
 /**
  * auditsc_get_stamp - get local copies of audit_context values
  * @ctx: audit_context for the task
- * @t: timespec to store time recorded in the audit_context
+ * @t: timespec64 to store time recorded in the audit_context
  * @serial: serial value that is recorded in the audit_context
  *
  * Also sets the context as auditable.
  */
 int auditsc_get_stamp(struct audit_context *ctx,
-  struct timespec *t, unsigned int *serial)
+  struct timespec64 *t, unsigned int *serial)
 {
if (!ctx->in_s

[PATCH] fs: ocfs2: Replace CURRENT_TIME macro

2016-10-01 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.

Use y2038 safe ktime_get_real_seconds() here for timestamps.
struct heartbeat_block's hb_seq and deletetion time are already
64 bits wide and accommodate times beyond y2038.

Also use y2038 safe ktime_get_real_ts64() for on disk inode
timestamps.
These are also wide enough to accommodate time64_t.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/cluster/heartbeat.c | 2 +-
 fs/ocfs2/inode.c | 2 +-
 fs/ocfs2/namei.c | 6 --
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 636abcb..9158c98 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -741,7 +741,7 @@ static inline void o2hb_prepare_block(struct o2hb_region 
*reg,
hb_block = (struct o2hb_disk_heartbeat_block *)slot->ds_raw_block;
memset(hb_block, 0, reg->hr_block_bytes);
/* TODO: time stuff */
-   cputime = CURRENT_TIME.tv_sec;
+   cputime = ktime_get_real_seconds();
if (!cputime)
cputime = 1;
 
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index c56a767..382401d 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -703,7 +703,7 @@ static int ocfs2_remove_inode(struct inode *inode,
goto bail_commit;
}
 
-   di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec);
+   di->i_dtime = cpu_to_le64(ktime_get_real_seconds());
di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL));
ocfs2_journal_dirty(handle, di_bh);
 
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index a8f1225..e96ed24 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -516,6 +516,7 @@ static int __ocfs2_mknod_locked(struct inode *dir,
struct ocfs2_extent_list *fel;
u16 feat;
struct ocfs2_inode_info *oi = OCFS2_I(inode);
+   struct timespec64 ts;
 
*new_fe_bh = NULL;
 
@@ -564,10 +565,11 @@ static int __ocfs2_mknod_locked(struct inode *dir,
fe->i_last_eb_blk = 0;
strcpy(fe->i_signature, OCFS2_INODE_SIGNATURE);
fe->i_flags |= cpu_to_le32(OCFS2_VALID_FL);
+   ktime_get_real_ts64(&ts);
fe->i_atime = fe->i_ctime = fe->i_mtime =
-   cpu_to_le64(CURRENT_TIME.tv_sec);
+   cpu_to_le64(ts.tv_sec);
fe->i_mtime_nsec = fe->i_ctime_nsec = fe->i_atime_nsec =
-   cpu_to_le32(CURRENT_TIME.tv_nsec);
+   cpu_to_le32(ts.tv_nsec);
fe->i_dtime = 0;
 
/*
-- 
2.7.4



[PATCH] fs: ocfs2: Use time64_t to represent orphan scan times

2016-10-01 Thread Deepa Dinamani
struct timespec is not y2038 safe.
Use time64_t which is y2038 safe to represent orphan
scan times.
time64_t is sufficient here as only the seconds delta
times are relevant.

Also use appropriate time functions that return time in
time64_t format. Time functions now return monotonic
time instead of real time as only delta scan times are
relevant and these values are not persistent across
reboots.

The format string for the debug print is still using long
as this is only the time elapsed since the last scan and
long is sufficient to represent this value.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Mark Fasheh 
Cc: Joel Becker 
Cc: ocfs2-de...@oss.oracle.com
---
 fs/ocfs2/journal.c | 4 ++--
 fs/ocfs2/ocfs2.h   | 2 +-
 fs/ocfs2/super.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index a244f14..d5e5fa7 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1947,7 +1947,7 @@ static void ocfs2_queue_orphan_scan(struct ocfs2_super 
*osb)
 */
seqno++;
os->os_count++;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
 unlock:
ocfs2_orphan_scan_unlock(osb, seqno);
 out:
@@ -2004,7 +2004,7 @@ void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
struct ocfs2_orphan_scan *os;
 
os = &osb->osb_orphan_scan;
-   os->os_scantime = CURRENT_TIME;
+   os->os_scantime = ktime_get_seconds();
if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
else {
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index e63af7d..7e5958b 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -224,7 +224,7 @@ struct ocfs2_orphan_scan {
struct ocfs2_super  *os_osb;
struct ocfs2_lock_res   os_lockres; /* lock to synchronize scans */
struct delayed_work os_orphan_scan_work;
-   struct timespec os_scantime;  /* time this node ran the scan */
+   time64_tos_scantime;  /* time this node ran the scan */
u32 os_count;  /* tracks node specific scans */
u32 os_seqno;   /* tracks cluster wide scans */
atomic_tos_state;  /* ACTIVE or INACTIVE */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 603b28d..bf3ca30 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -337,7 +337,7 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char 
*buf, int len)
out += snprintf(buf + out, len - out, "Disabled\n");
else
out += snprintf(buf + out, len - out, "%lu seconds ago\n",
-   (get_seconds() - os->os_scantime.tv_sec));
+   (unsigned long)(ktime_get_seconds() - 
os->os_scantime));
 
out += snprintf(buf + out, len - out, "%10s => %3s  %10s\n",
"Slots", "Num", "RecoGen");
-- 
2.7.4



Re: [PATCH v4 2/5] driver core: Functional dependencies tracking support

2016-10-01 Thread Rafael J. Wysocki
On Sat, Oct 1, 2016 at 9:43 AM, Lukas Wunner  wrote:
> On Thu, Sep 29, 2016 at 02:38:04AM +0200, Rafael J. Wysocki wrote:
>> +static int device_reorder_to_tail(struct device *dev, void *not_used)
>> +{
>> + struct device_link *link;
>> +
>> + /*
>> +  * Devices that have not been registered yet will be put to the ends
>> +  * of the lists during the registratio, so skip them here.
>   ^
>   n
>
>> + if (device_is_registered(dev))
>> + devices_kset_move_last(dev);
>> +
>> + if (device_pm_initialized(dev))
>> + device_pm_move_last(dev);
>
> Clever solution to this problem.  So little code!
>
>
>> +/**
>> + * device_links_check_suppliers - Check presence of supplier drivers.
>> + * @dev: Consumer device.
>> + *
>> + * Check links from this device to any suppliers.  Walk the list of the 
>> device's
>> + * consumer links and see if all of the suppliers are available.  If not, 
>> simply
>   
>  "supplier links and see if all if them are available."
>
>
>> +/*
>> + * Device link flags.
>> + *
>> + * STATELESS: The core won't track the presence of supplier/consumer 
>> drivers.
>> + * AUTOREMOVE: Remove this link automatically on cunsumer driver unbind.
>  ^
>  o
>
>
> Apart from these nits patch [2/5] LGTM, so FWIW:
>
> Reviewed-by: Lukas Wunner 

Thanks for the review, much appreciated!

Cheers,
Rafael


[PATCH] fs: f2fs: Use ktime_get_real_seconds for sit_info times

2016-10-01 Thread Deepa Dinamani
CURRENT_TIME_SEC is not y2038 safe.

Replace use of CURRENT_TIME_SEC with ktime_get_real_seconds
in segment timestamps used by GC algorithm including the
segment mtime timestamps.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Jaegeuk Kim 
Cc: Changman Lee 
Cc: linux-f2fs-de...@lists.sourceforge.net
---
 fs/f2fs/segment.c | 2 +-
 fs/f2fs/segment.h | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a46296f..34bb30e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2168,7 +2168,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
sit_i->dirty_sentries = 0;
sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
-   sit_i->mounted_time = CURRENT_TIME_SEC.tv_sec;
+   sit_i->mounted_time = ktime_get_real_seconds();
mutex_init(&sit_i->sentry_lock);
return 0;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index b33f73e..2423749 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -662,8 +662,9 @@ static inline void set_to_next_sit(struct sit_info *sit_i, 
unsigned int start)
 static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
 {
struct sit_info *sit_i = SIT_I(sbi);
-   return sit_i->elapsed_time + CURRENT_TIME_SEC.tv_sec -
-   sit_i->mounted_time;
+   time64_t now = ktime_get_real_seconds();
+
+   return sit_i->elapsed_time + now - sit_i->mounted_time;
 }
 
 static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
-- 
2.7.4



Re: [PATCH RFC 1/5] x86,fpu: split prev/next task fpu state handling

2016-10-01 Thread Andy Lutomirski
On Oct 1, 2016 1:49 PM,  wrote:
>
> From: Rik van Riel 
>
> Move all handling of the next state FPU state handling into
> switch_fpu_finish, in preparation for more lazily switching
> FPU states.
>
> CR0.TS state is mirrored in a per-cpu variable, instead of
> being passed around in a local variable, because that will
> not be possible later in the series.

This seems reasonable in principle, but IMO it would be less scary if
you rebased onto this:

https://git.kernel.org/cgit/linux/kernel/git/luto/linux.git/log/?h=x86/fpu

Because the amount of testing needed and the amount of code that gets
rearranged would be reduced.  Want to fold those patches into you
series?  I can also just send them in directly, although this is an
awkward time to do so.

--Andy


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-10-01 at 16:32 -0400, Jes Sorensen wrote:
>> Your output shows it moving to the text segment - if it's in a different
>> segment, eg. rodata, you should use output demonstrating that to justify
>> the change.
>
> For size, rodata _is_ text

Well then maybe use something which provides accurate data.

Jes


cris-linux-objcopy: error: the input file 'arch/cris/boot/rescue/rescue.o' has no sections

2016-10-01 Thread kbuild test robot
Hi Joe,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   f51fdffad5b7709d0ade40736b58a2da2707fa15
commit: cb984d101b30eb7478d32df56a0023e4603cba7f compiler-gcc: integrate the 
various compiler-gcc[345].h files
date:   1 year, 3 months ago
config: cris-alldefconfig (attached as .config)
compiler: cris-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout cb984d101b30eb7478d32df56a0023e4603cba7f
# save the attached .config to linux build tree
make.cross ARCH=cris 

All errors (new ones prefixed by >>):

>> cris-linux-objcopy: error: the input file 'arch/cris/boot/rescue/rescue.o' 
>> has no sections

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


.config.gz
Description: application/gzip


Re: [PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime

2016-10-01 Thread David Sterba
On Sat, Oct 01, 2016 at 10:23:34AM -0700, Deepa Dinamani wrote:
> btrfs_root_item maintains the ctime for root updates.
> This is not part of vfs_inode.
> 
> Since current_time() uses struct inode* as an argument
> as Linus suggested, this cannot be used to update root
> times unless, we modify the signature to use inode.
> 
> Since btrfs uses nanosecond time granularity, it can also
> use ktime_get_real_ts directly to obtain timestamp for
> the root. It is necessary to use the timespec time api
> here because the same btrfs_set_stack_timespec_*() apis
> are used for vfs inode times as well. These can be
> transitioned to using timespec64 when btrfs internally
> changes to use timespec64 as well.
> 
> Signed-off-by: Deepa Dinamani 
> Cc: Chris Mason 
> Cc: David Sterba 

Acked-by: David Sterba 

> Cc: Josef Bacik 
> Cc: linux-bt...@vger.kernel.org
> ---
> Changes from previous version:
> * Separated from the current_time() api series.
> * Moved ktime_get_real_ts() outside of spin lock.
> 
> fs/btrfs/root-tree.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
> index 0912960..17e5a5f 100644
> --- a/fs/btrfs/root-tree.c
> +++ b/fs/btrfs/root-tree.c
> @@ -505,8 +505,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
> *trans,
>struct btrfs_root *root)
>  {
>   struct btrfs_root_item *item = &root->root_item;
> - struct timespec ct = current_fs_time(root->fs_info->sb);
> + struct timespec ct;
>  
> + ktime_get_real_ts(&ct);
>   spin_lock(&root->root_item_lock);
>   btrfs_set_root_ctransid(item, trans->transid);
>   btrfs_set_stack_timespec_sec(&item->ctime, ct.tv_sec);
> -- 
> 2.7.4
> 
> 


[PATCH] usb: xhci: add support for performing fake doorbell

2016-10-01 Thread Rafał Miłecki
From: Rafał Miłecki 

Broadcom's Northstar XHCI controllers seem to need a special start
procedure to work correctly. There isn't any official documentation on
this, the problem is that controller doesn't detect any connected
devices with default setup. Moreover connecting USB device to controller
that doesn't run properly can cause SoC's watchdog issues.

A workaround that was successfully tested on multiple devices is to
perform a fake doorbell. This patch adds code for doing that and a DT
binding enabling it.

Signed-off-by: Rafał Miłecki 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |  2 +
 drivers/usb/host/xhci-plat.c   |  6 +++
 drivers/usb/host/xhci.c| 63 --
 drivers/usb/host/xhci.h|  1 +
 4 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 966885c..ce01b7f 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -26,6 +26,8 @@ Required properties:
 Optional properties:
   - clocks: reference to a clock
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
+  - usb3-fake-doorbell: determines if controller requires a fake doorbell when
+   starting it
 
 Example:
usb@f0931000 {
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..c26dc77 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -56,12 +56,18 @@ static int xhci_priv_init_quirk(struct usb_hcd *hcd)
 
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
+   struct platform_device  *pdev = to_platform_device(dev);
+   struct device_node  *node = pdev->dev.of_node;
+
/*
 * As of now platform drivers don't provide MSI support so we ensure
 * here that the generic code does not try to make a pci_dev from our
 * dev struct in order to setup MSI
 */
xhci->quirks |= XHCI_PLAT;
+
+   if (node && of_property_read_bool(node, "usb3-fake-doorbell"))
+   xhci->quirks |= XHCI_FAKE_DOORBELL;
 }
 
 /* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1a4ca02..c77035e9b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -153,6 +153,49 @@ static int xhci_start(struct xhci_hcd *xhci)
return ret;
 }
 
+/**
+ * xhci_fake_doorbell - Perform a fake doorbell on a specified slot
+ *
+ * Some controllers require a fake doorbell to start correctly. Without that
+ * they simply don't detect any devices.
+ */
+static int xhci_fake_doorbell(struct xhci_hcd *xhci, int slot_id)
+{
+   u32 temp;
+
+   /* Alloc a virt device for that slot */
+   if (!xhci_alloc_virt_device(xhci, slot_id, NULL, GFP_NOIO)) {
+   xhci_warn(xhci, "Could not allocate xHCI USB device data 
structures\n");
+   return -ENOMEM;
+   }
+
+   /* Ring fake doorbell for slot_id ep 0 */
+   xhci_ring_ep_doorbell(xhci, slot_id, 0, 0);
+   usleep_range(1000, 1500);
+
+   /* Read the status to check if HSE is set or not */
+   temp = readl(&xhci->op_regs->status);
+
+   /* Clear HSE if set */
+   if (temp & STS_FATAL) {
+   xhci_dbg(xhci, "HSE problem detected, status: 0x%08x\n", temp);
+   temp &= ~0x1fff;
+   temp |= STS_FATAL;
+   writel(temp, &xhci->op_regs->status);
+   usleep_range(1000, 1500);
+   readl(&xhci->op_regs->status);
+   }
+
+   /* Free virt device */
+   xhci_free_virt_device(xhci, slot_id);
+
+   /* We're done if controller is already running */
+   if (readl(&xhci->op_regs->command) & CMD_RUN)
+   return 0;
+
+   return xhci_start(xhci);
+}
+
 /*
  * Reset a halted HC.
  *
@@ -565,10 +608,20 @@ int xhci_init(struct usb_hcd *hcd)
 
 static int xhci_run_finished(struct xhci_hcd *xhci)
 {
-   if (xhci_start(xhci)) {
-   xhci_halt(xhci);
-   return -ENODEV;
+   int err;
+
+   err = xhci_start(xhci);
+   if (err) {
+   err = -ENODEV;
+   goto err_halt;
+   }
+
+   if (xhci->quirks & XHCI_FAKE_DOORBELL) {
+   err = xhci_fake_doorbell(xhci, 1);
+   if (err)
+   goto err_halt;
}
+
xhci->shared_hcd->state = HC_STATE_RUNNING;
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
 
@@ -578,6 +631,10 @@ static int xhci_run_finished(struct xhci_hcd *xhci)
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB3 roothub");
return 0;
+
+err_halt:
+   xhci_halt(xhci);
+   return err;
 }
 
 /*
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
in

Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Joe Perches
On Sat, 2016-10-01 at 16:32 -0400, Jes Sorensen wrote:
> Your output shows it moving to the text segment - if it's in a different
> segment, eg. rodata, you should use output demonstrating that to justify
> the change.

For size, rodata _is_ text


Re: [PATCH] Coccinelle: limit memdup_user transformation to GFP_KERNEL case

2016-10-01 Thread Michal Marek
Dne 21.9.2016 v 17:48 Julia Lawall napsal(a):
> Memdup_user encapsulates a memory allocation with the flag GFP_KERNEL, so
> only allow this flag in the original code.
> 
> Signed-off-by: Julia Lawall 

Applied to kbuild.git#misc.

Thanks,
Michal



Re: [PATCH] Coccinelle: pm_runtime: ensure relevance of pm_runtime reports

2016-10-01 Thread Michal Marek
Dne 22.9.2016 v 10:28 Julia Lawall napsal(a):
> pm_runtime.cocci starts with one rule that searches for a variety of
> functions calls, followed by various rules that report errors.  Previously,
> the only connection between the first rule and the rest was to check that
> the first rule had matched somewhere.  Change the rules to propagate a
> position from the first rule to the others, to make sure that the sites
> reported on are the same as the sites that were identified as having the
> relevant functions.
> 
> Signed-off-by: Julia Lawall 

Applied to kbuild.git#misc.

Thanks,
Michal



[PATCH] [media] : Removing warnings caught by checkpatch.pl

2016-10-01 Thread Harman Kalra
Removing warnings caught by checkpatch.pl

Signed-off-by: Harman Kalra 
---
 drivers/staging/media/omap4iss/iss_video.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/omap4iss/iss_video.c 
b/drivers/staging/media/omap4iss/iss_video.c
index c16927a..7cc1691 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -297,8 +297,8 @@ static void iss_video_pix_to_mbus(const struct 
v4l2_pix_format *pix,
  */

 static int iss_video_queue_setup(struct vb2_queue *vq,
-unsigned int *count, unsigned int *num_planes,
-unsigned int sizes[], struct device 
*alloc_devs[])
+   unsigned int *count, unsigned int *num_planes,
+   unsigned int sizes[], struct device *alloc_devs[])
 {
struct iss_video_fh *vfh = vb2_get_drv_priv(vq);
struct iss_video *video = vfh->video;
@@ -678,8 +678,8 @@ void omap4iss_video_cancel_stream(struct iss_video *video)
if (subdev == NULL)
return -EINVAL;

-   /* Try the get selection operation first and fallback to get format if 
not
-* implemented.
+   /* Try the get selection operation first and
+* fallback to get format if not implemented.
 */
sdsel.pad = pad;
ret = v4l2_subdev_call(subdev, pad, get_selection, NULL, &sdsel);
--
1.7.9.5



[PATCH 01/15 v2] UBIFS: improve function-level documentation

2016-10-01 Thread Julia Lawall
Fix various inconsistencies in the documentation associated with various
functions.

In the case of fs/ubifs/lprops.c, the second parameter of
ubifs_get_lp_stats was renamed from st to lst in commit 84abf972ccff
("UBIFS: add re-mount debugging checks")

In the case of fs/ubifs/lpt_commit.c, the excess variables have never
existed in the associated functions since the code was introduced into the
kernel.

The others appear to be straightforward typos.

Issues detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
v2: improve reference to earlier commit

 fs/ubifs/file.c   |2 +-
 fs/ubifs/gc.c |2 +-
 fs/ubifs/lprops.c |2 +-
 fs/ubifs/lpt_commit.c |4 +---
 fs/ubifs/replay.c |2 +-
 5 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index b0a6a53..629c719 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1397,7 +1397,7 @@ int ubifs_update_time(struct inode *inode, struct 
timespec *time,
 #endif

 /**
- * update_ctime - update mtime and ctime of an inode.
+ * update_mctime - update mtime and ctime of an inode.
  * @inode: inode to update
  *
  * This function updates mtime and ctime of the inode if it is not equivalent 
to
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 821b348..e845c64 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -113,7 +113,7 @@ static int switch_gc_head(struct ubifs_info *c)
  * data_nodes_cmp - compare 2 data nodes.
  * @priv: UBIFS file-system description object
  * @a: first data node
- * @a: second data node
+ * @b: second data node
  *
  * This function compares data nodes @a and @b. Returns %1 if @a has greater
  * inode or block number, and %-1 otherwise.
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index a0011aa..6c3a1ab 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -636,7 +636,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct 
ubifs_info *c,
 /**
  * ubifs_get_lp_stats - get lprops statistics.
  * @c: UBIFS file-system description object
- * @st: return statistics
+ * @lst: return statistics
  */
 void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst)
 {
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index ce89bdc..235654c 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -34,7 +34,6 @@

 /**
  * first_dirty_cnode - find first dirty cnode.
- * @c: UBIFS file-system description object
  * @nnode: nnode at which to start
  *
  * This function returns the first dirty cnode or %NULL if there is not one.
@@ -1623,7 +1622,6 @@ static int dbg_is_node_dirty(struct ubifs_info *c, int 
node_type, int lnum,
  * dbg_check_ltab_lnum - check the ltab for a LPT LEB number.
  * @c: the UBIFS file-system description object
  * @lnum: LEB number where node was written
- * @offs: offset where node was written
  *
  * This function returns %0 on success and a negative error code on failure.
  */
@@ -1870,7 +1868,7 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int 
len)
 }

 /**
- * ubifs_dump_lpt_leb - dump an LPT LEB.
+ * dump_lpt_leb - dump an LPT LEB.
  * @c: UBIFS file-system description object
  * @lnum: LEB number to dump
  *
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 3ca4540..fb0f44c 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -267,7 +267,7 @@ static int apply_replay_entry(struct ubifs_info *c, struct 
replay_entry *r)
  * replay_entries_cmp - compare 2 replay entries.
  * @priv: UBIFS file-system description object
  * @a: first replay entry
- * @a: second replay entry
+ * @b: second replay entry
  *
  * This is a comparios function for 'list_sort()' which compares 2 replay
  * entries @a and @b by comparing their sequence numer.  Returns %1 if @a has



[PATCH RFC 4/5] x86,fpu: lazily skip FPU restore when still loaded

2016-10-01 Thread riel
From: Rik van Riel 

When the FPU register set has not been touched by anybody else,
we can lazily skip the restore.

Intel has a number of clever optimizations to reduce the FPU
restore overhead, but those optimizations do not work across
the guest/host virtualization boundary, and even on bare metal
it should be faster to skip the restore entirely.

This code is still BROKEN. I am not yet sure why.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/fpu/internal.h | 13 +
 arch/x86/kernel/process.c   |  3 +++
 arch/x86/kvm/x86.c  |  8 +++-
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index b5accb35e434..f69960e9aea1 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -575,6 +575,19 @@ static inline void fpregs_deactivate(struct fpu *fpu)
 }
 
 /*
+ * Check whether an FPU's register set is still loaded in the CPU.
+ */
+static inline bool fpu_lazy_skip_restore(struct fpu *fpu)
+{
+   bool still_loaded = (fpu->fpstate_active &&
+fpu->last_cpu == raw_smp_processor_id() &&
+__this_cpu_read(fpu_fpregs_owner_ctx) == fpu);
+
+   fpu->fpregs_active = still_loaded;
+   return still_loaded;
+}
+
+/*
  * FPU state switching for scheduling.
  *
  * This is a three-stage process:
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 087413be39cf..6b72415e400f 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -208,6 +208,9 @@ void switch_fpu_return(void)
  (use_eager_fpu() || fpu->counter > 5);
 
if (preload) {
+   if (fpu_lazy_skip_restore(fpu))
+   return;
+
prefetch(&fpu->state);
fpu->counter++;
__fpregs_activate(fpu);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 55c82d066d3a..16ebcd12edf7 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7346,7 +7346,12 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 
vcpu->guest_fpu_loaded = 1;
__kernel_fpu_begin(fpu);
-   __copy_kernel_to_fpregs(&fpu->state);
+
+   if (!fpu_lazy_skip_restore(fpu)) {
+   fpu->last_cpu = raw_smp_processor_id();
+   __copy_kernel_to_fpregs(&fpu->state);
+   }
+
trace_kvm_fpu(1);
 }
 
@@ -7358,6 +7363,7 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
}
 
vcpu->guest_fpu_loaded = 0;
+   vcpu->arch.guest_fpu.fpregs_active = 0;
copy_fpregs_to_fpstate(&vcpu->arch.guest_fpu);
__kernel_fpu_end();
++vcpu->stat.fpu_reload;
-- 
2.7.4



[PATCH RFC 2/5] x86,fpu: delay FPU register loading until switch to userspace

2016-10-01 Thread riel
From: Rik van Riel 

Delay the loading of FPU registers until a process switches back to
userspace. This allows us to skip FPU saving & restoring for kernel
threads, the idle task, and tasks that are spinning in kernel space.

It also allows us to not repeatedly save & restore the userspace FPU
context on repeated invocations of kernel_fpu_start & kernel_fpu_end.

Not overwriting the FPU state of a task unless we need to also allows
us to be be lazier about restoring it, in a future patch.

Signed-off-by: Rik van Riel 
---
 arch/x86/entry/common.c |  4 
 arch/x86/include/asm/fpu/api.h  |  5 +
 arch/x86/include/asm/fpu/internal.h | 44 +
 arch/x86/include/asm/thread_info.h  |  4 +++-
 arch/x86/kernel/fpu/core.c  | 17 --
 arch/x86/kernel/process.c   | 35 +
 arch/x86/kernel/process_32.c|  5 ++---
 arch/x86/kernel/process_64.c|  5 ++---
 8 files changed, 71 insertions(+), 48 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 1433f6b4607d..a69bbefa3408 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define CREATE_TRACE_POINTS
 #include 
@@ -197,6 +198,9 @@ __visible inline void prepare_exit_to_usermode(struct 
pt_regs *regs)
if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS))
exit_to_usermode_loop(regs, cached_flags);
 
+   if (unlikely(test_and_clear_thread_flag(TIF_LOAD_FPU)))
+   switch_fpu_return();
+
 #ifdef CONFIG_COMPAT
/*
 * Compat syscalls set TS_COMPAT.  Make sure we clear it before
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index 1429a7c736db..edd7dc7ae4f7 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -37,6 +37,11 @@ extern int  irq_ts_save(void);
 extern void irq_ts_restore(int TS_state);
 
 /*
+ * Set up the userspace FPU context before returning to userspace.
+ */
+extern void switch_fpu_return(void);
+
+/*
  * Query the presence of one or more xfeatures. Works on any legacy CPU as 
well.
  *
  * If 'feature_name' is set then put a human-readable description of
diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index 79e1cee9f3b0..b5accb35e434 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * High level FPU state handling functions:
@@ -576,13 +577,17 @@ static inline void fpregs_deactivate(struct fpu *fpu)
 /*
  * FPU state switching for scheduling.
  *
- * This is a two-stage process:
+ * This is a three-stage process:
  *
  *  - switch_fpu_prepare() saves the old state.
  *This is done within the context of the old process.
  *
- *  - switch_fpu_finish() restores the new state
- *and flips CR0.TS as necessary.
+ *  - switch_fpu_finish() sets TIF_LOAD_CPU, causing FPU state to
+ *be loaded when the new process returns to userspace.
+ *This is done with current_task pointing to the new process.
+ *
+ *  - switch_fpu_return() restores the new state and flips CR0.TS as
+ *necessary. This only runs if the process returns to userspace.
  */
 static inline void
 switch_fpu_prepare(struct fpu *old_fpu, int cpu)
@@ -605,38 +610,9 @@ switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 /*
  * Misc helper functions:
  */
-
-/*
- * Set up the userspace FPU context for the new task.
- */
-static inline void switch_fpu_finish(struct fpu *new_fpu)
+static inline void switch_fpu_finish(void)
 {
-   bool preload;
-   /*
-* If the task has used the math, pre-load the FPU on xsave processors
-* or if the past 5 consecutive context-switches used math.
-*/
-   preload = static_cpu_has(X86_FEATURE_FPU) &&
- new_fpu->fpstate_active &&
- (use_eager_fpu() || new_fpu->counter > 5);
-
-   if (preload) {
-   prefetch(&new_fpu->state);
-   new_fpu->counter++;
-   __fpregs_activate(new_fpu);
-   trace_x86_fpu_regs_activated(new_fpu);
-
-   /* Don't change CR0.TS if we just switch! */
-   if (!__this_cpu_read(fpu_active)) {
-   __fpregs_activate_hw();
-   __this_cpu_write(fpu_active, true);
-   }
-
-   copy_kernel_to_fpregs(&new_fpu->state);
-   } else if (__this_cpu_read(fpu_active)) {
-   __this_cpu_write(fpu_active, false);
-   __fpregs_deactivate_hw();
-   }
+   set_thread_flag(TIF_LOAD_FPU);
 }
 
 /*
diff --git a/arch/x86/include/asm/thread_info.h 
b/arch/x86/include/asm/thread_info.h
index 8b7c8d8e0852..401e9c3e6039 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -106,6 +106,7 @@ struct thread_info

[PATCH 14/15 v2] irqchip/metag-ext: improve function-level documentation

2016-10-01 Thread Julia Lawall
Drop the variable irq which ceased to be a parameter in commit bd0b9ac405e1
("genirq: Remove irq argument from irq flow handlers")

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 
Acked-by: James Hogan 

---
v2: correct commit reference, independent of the rest of the series

 drivers/irqchip/irq-metag-ext.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
index 8c38b3d..0cdd923 100644
--- a/drivers/irqchip/irq-metag-ext.c
+++ b/drivers/irqchip/irq-metag-ext.c
@@ -436,7 +436,6 @@ static int meta_intc_irq_set_type(struct irq_data *data, 
unsigned int flow_type)

 /**
  * meta_intc_irq_demux() - external irq de-multiplexer
- * @irq:   the virtual interrupt number
  * @desc:  the interrupt description structure for this irq
  *
  * The cpu receives an interrupt on TR2 when a SoC interrupt has occurred. It 
is



[PATCH RFC 3/5] x86,fpu: add kernel fpu argument to __kernel_fpu_begin

2016-10-01 Thread riel
From: Rik van Riel 

Most kernel FPU contexts are transient, but a KVM VCPU context
persists.  Add a kernel FPU argument to __kernel_fpu_begin, so
we can know whether or not the KVM VCPU context got clobbered
by another kernel FPU context.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/efi.h | 2 +-
 arch/x86/include/asm/fpu/api.h | 2 +-
 arch/x86/kernel/fpu/core.c | 6 +++---
 arch/x86/kvm/x86.c | 8 ++--
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index d0bb76d81402..603d2cdd6b82 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -71,7 +71,7 @@ struct efi_scratch {
 ({ \
efi_sync_low_kernel_mappings(); \
preempt_disable();  \
-   __kernel_fpu_begin();   \
+   __kernel_fpu_begin(NULL);   \
\
if (efi_scratch.use_pgd) {  \
efi_scratch.prev_cr3 = read_cr3();  \
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h
index edd7dc7ae4f7..f6704edf9904 100644
--- a/arch/x86/include/asm/fpu/api.h
+++ b/arch/x86/include/asm/fpu/api.h
@@ -20,7 +20,7 @@
  * All other cases use kernel_fpu_begin/end() which disable preemption
  * during kernel FPU usage.
  */
-extern void __kernel_fpu_begin(void);
+extern void __kernel_fpu_begin(struct fpu *fpu);
 extern void __kernel_fpu_end(void);
 extern void kernel_fpu_begin(void);
 extern void kernel_fpu_end(void);
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index c4350f188be1..537eb65b6ae6 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -110,7 +110,7 @@ bool irq_fpu_usable(void)
 }
 EXPORT_SYMBOL(irq_fpu_usable);
 
-void __kernel_fpu_begin(void)
+void __kernel_fpu_begin(struct fpu *kernelfpu)
 {
struct fpu *fpu = ¤t->thread.fpu;
 
@@ -118,7 +118,7 @@ void __kernel_fpu_begin(void)
 
kernel_fpu_disable();
 
-   this_cpu_write(fpu_fpregs_owner_ctx, NULL);
+   this_cpu_write(fpu_fpregs_owner_ctx, kernelfpu);
 
if (fpu->fpregs_active) {
/*
@@ -150,7 +150,7 @@ EXPORT_SYMBOL(__kernel_fpu_end);
 void kernel_fpu_begin(void)
 {
preempt_disable();
-   __kernel_fpu_begin();
+   __kernel_fpu_begin(NULL);
 }
 EXPORT_SYMBOL_GPL(kernel_fpu_begin);
 
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 699f8726539a..55c82d066d3a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7332,6 +7332,8 @@ static void fx_init(struct kvm_vcpu *vcpu)
 
 void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 {
+   struct fpu *fpu;
+
if (vcpu->guest_fpu_loaded)
return;
 
@@ -7340,9 +7342,11 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
 * and assume host would use all available bits.
 * Guest xcr0 would be loaded later.
 */
+   fpu = &vcpu->arch.guest_fpu;
+
vcpu->guest_fpu_loaded = 1;
-   __kernel_fpu_begin();
-   __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state);
+   __kernel_fpu_begin(fpu);
+   __copy_kernel_to_fpregs(&fpu->state);
trace_kvm_fpu(1);
 }
 
-- 
2.7.4



[PATCH RFC 1/5] x86,fpu: split prev/next task fpu state handling

2016-10-01 Thread riel
From: Rik van Riel 

Move all handling of the next state FPU state handling into
switch_fpu_finish, in preparation for more lazily switching
FPU states.

CR0.TS state is mirrored in a per-cpu variable, instead of
being passed around in a local variable, because that will
not be possible later in the series.

Signed-off-by: Rik van Riel 
---
 arch/x86/include/asm/fpu/internal.h | 78 -
 arch/x86/kernel/fpu/core.c  |  1 +
 arch/x86/kernel/process_32.c|  5 +--
 arch/x86/kernel/process_64.c|  5 +--
 4 files changed, 39 insertions(+), 50 deletions(-)

diff --git a/arch/x86/include/asm/fpu/internal.h 
b/arch/x86/include/asm/fpu/internal.h
index 2737366ea583..79e1cee9f3b0 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -482,6 +482,7 @@ extern int copy_fpstate_to_sigframe(void __user *buf, void 
__user *fp, int size)
  */
 
 DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx);
+DECLARE_PER_CPU(bool, fpu_active);
 
 /*
  * Must be run with preemption disabled: this clears the fpu_fpregs_owner_ctx,
@@ -577,28 +578,15 @@ static inline void fpregs_deactivate(struct fpu *fpu)
  *
  * This is a two-stage process:
  *
- *  - switch_fpu_prepare() saves the old state and
- *sets the new state of the CR0.TS bit. This is
- *done within the context of the old process.
+ *  - switch_fpu_prepare() saves the old state.
+ *This is done within the context of the old process.
  *
- *  - switch_fpu_finish() restores the new state as
- *necessary.
+ *  - switch_fpu_finish() restores the new state
+ *and flips CR0.TS as necessary.
  */
-typedef struct { int preload; } fpu_switch_t;
-
-static inline fpu_switch_t
-switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu)
+static inline void
+switch_fpu_prepare(struct fpu *old_fpu, int cpu)
 {
-   fpu_switch_t fpu;
-
-   /*
-* If the task has used the math, pre-load the FPU on xsave processors
-* or if the past 5 consecutive context-switches used math.
-*/
-   fpu.preload = static_cpu_has(X86_FEATURE_FPU) &&
- new_fpu->fpstate_active &&
- (use_eager_fpu() || new_fpu->counter > 5);
-
if (old_fpu->fpregs_active) {
if (!copy_fpregs_to_fpstate(old_fpu))
old_fpu->last_cpu = -1;
@@ -608,29 +596,10 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu 
*new_fpu, int cpu)
/* But leave fpu_fpregs_owner_ctx! */
old_fpu->fpregs_active = 0;
trace_x86_fpu_regs_deactivated(old_fpu);
-
-   /* Don't change CR0.TS if we just switch! */
-   if (fpu.preload) {
-   new_fpu->counter++;
-   __fpregs_activate(new_fpu);
-   trace_x86_fpu_regs_activated(new_fpu);
-   prefetch(&new_fpu->state);
-   } else {
-   __fpregs_deactivate_hw();
-   }
} else {
old_fpu->counter = 0;
old_fpu->last_cpu = -1;
-   if (fpu.preload) {
-   new_fpu->counter++;
-   if (fpu_want_lazy_restore(new_fpu, cpu))
-   fpu.preload = 0;
-   else
-   prefetch(&new_fpu->state);
-   fpregs_activate(new_fpu);
-   }
}
-   return fpu;
 }
 
 /*
@@ -638,15 +607,36 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu 
*new_fpu, int cpu)
  */
 
 /*
- * By the time this gets called, we've already cleared CR0.TS and
- * given the process the FPU if we are going to preload the FPU
- * state - all we need to do is to conditionally restore the register
- * state itself.
+ * Set up the userspace FPU context for the new task.
  */
-static inline void switch_fpu_finish(struct fpu *new_fpu, fpu_switch_t 
fpu_switch)
+static inline void switch_fpu_finish(struct fpu *new_fpu)
 {
-   if (fpu_switch.preload)
+   bool preload;
+   /*
+* If the task has used the math, pre-load the FPU on xsave processors
+* or if the past 5 consecutive context-switches used math.
+*/
+   preload = static_cpu_has(X86_FEATURE_FPU) &&
+ new_fpu->fpstate_active &&
+ (use_eager_fpu() || new_fpu->counter > 5);
+
+   if (preload) {
+   prefetch(&new_fpu->state);
+   new_fpu->counter++;
+   __fpregs_activate(new_fpu);
+   trace_x86_fpu_regs_activated(new_fpu);
+
+   /* Don't change CR0.TS if we just switch! */
+   if (!__this_cpu_read(fpu_active)) {
+   __fpregs_activate_hw();
+   __this_cpu_write(fpu_active, true);
+   }
+
copy_kernel_to_fpregs(&new_fpu->state);
+   } else if (__this_cpu_read(fpu_active)) {
+ 

[PATCH RFC 5/5] x86,fpu: kinda sorta fix up signal path

2016-10-01 Thread riel
From: Rik van Riel 

Need to ensure that the FPU save code and the lazy restore code
do not use invalid kernel or floating point register state and
copy it over to the other location.

I am pretty sure this is incomplete.

Signed-off-by: Rik van Riel 
---
 arch/x86/kernel/fpu/core.c   | 1 +
 arch/x86/kernel/fpu/signal.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 537eb65b6ae6..fa59cc741fa5 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -314,6 +314,7 @@ void fpu__activate_curr(struct fpu *fpu)
trace_x86_fpu_activate_state(fpu);
/* Safe to do for the current task: */
fpu->fpstate_active = 1;
+   fpu->last_cpu = -1;
}
 }
 EXPORT_SYMBOL_GPL(fpu__activate_curr);
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index a184c210efba..89f882983da7 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -171,6 +171,10 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user 
*buf_fx, int size)
(struct _fpstate_32 __user *) buf) ? -1 : 1;
 
if (fpregs_active() || using_compacted_format()) {
+   /* Compacted format, but the FP state is not loaded yet. */
+   if (unlikely(!fpu_lazy_skip_restore(&tsk->thread.fpu)))
+   copy_kernel_to_fpregs(&tsk->thread.fpu.state);
+
/* Save the live register state to the user directly. */
if (copy_fpregs_to_sigframe(buf_fx))
return -1;
-- 
2.7.4



[PATCH RFC 0/5] x86,fpu: make FPU context switching much lazier

2016-10-01 Thread riel
This series is an attempt at making the x86 FPU context switching
code much lazier.  By only reloading the FPU context when a task
switches to user mode, we can avoid switching FPU context for tasks
that spin in kernel mode, and avoid reloading the FPU context for
tasks that get interrupted by a kernel thread or briefly go idle.

It also allows us to skip restoring the userspace FPU context when
exiting a KVM guest.

This series is still BROKEN.  The first 3 patches seem to work
fine in my tests (but should not, due to missing signal path
code), while the 4th test makes it easier to trigger bugs.

I am posting this to ask about obvious issues people may see,
ideas on what direction I should take this series in, and to
avoid code conflicts with Andy's plans wrt. lazy fpu mode.



Re: [PATCH 0/2] Moving runnable code from Documentation (last 2 patches)

2016-10-01 Thread Michal Marek
Dne 1.10.2016 v 09:10 Jonathan Corbet napsal(a):
> On Fri, 30 Sep 2016 07:57:51 -0600
> Shuah Khan  wrote:
> 
>>> This patch series contains the last 2 patches to complete moving runnable
>>> code from Documentation to selftests, samples, and tools.
>>>
>>> The first patch moves blackfin gptimers-example to samples and removes
>>> CONFIG_BUILD_DOCSRC.
>>>
>>> The second one updates 00-INDEX files under Documentation to reflect the
>>> move of runnable code from Documentation.
>>>
>>> Shuah Khan (2):
>>>   samples: move blackfin gptimers-example from Documentation
>>>   Doc: update 00-INDEX files to reflect the runnable code move
>>>   
>>
>> Hi Jon and Michal,
>>
>> Do these patches look good to you? I can get these into 4.9-rc1
>> with your Ack.
> 
> Seems good to me.
> 
> Acked-by: Jonathan Corbet 

Likewise,

Acked-by: Michal Marek 

Michal



Re: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver

2016-10-01 Thread Guenter Roeck

On 10/01/2016 12:04 PM, Dmitry Torokhov wrote:

On Sat, Oct 01, 2016 at 10:27:42AM -0700, Andrew Duggan wrote:



On Fri, Sep 30, 2016, at 08:44 PM, Guenter Roeck wrote:

On 09/30/2016 04:02 PM, Dmitry Torokhov wrote:

On Fri, Sep 30, 2016 at 03:54:03PM -0700, Dmitry Torokhov wrote:

On Thu, Sep 29, 2016 at 10:55:40AM -0700, Bjorn Andersson wrote:

On Wed 28 Sep 17:37 PDT 2016, Guenter Roeck wrote:


Instantiating the rmi4 I2C transport driver without interrupts assigned
(for example using manual i2c instantiation from the command line)
caused the driver to fail to load, but it does not clean up its
regulator or transport device registrations. Result is a crash at a later
time, for example when rebooting the system.

Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator supplies")


Sorry for that.


Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport driver")
Cc: Bjorn Andersson 


Reviewed-by: Bjorn Andersson 


Applied, thank you.


I take it back. rmi_i2c_init_irq() uses devm* so this whole thing mixes
up devm* and manual unregistering and unwind order is completely
broken.


Oops ...


1. Why do we register interrupt from transport drivers and not make it
part of rmi_register_transport_device()?


Not all RMI devices will have access to interrupts (ie HID and SMBus).
The same goes for regulators. Here is a reference to a previous
discussion regarding both:
https://lkml.org/lkml/2016/5/9/1055


Yeah, I am wondering if we should not revisit this and have SMBus (and
possibly HID) actually provide us with an interrupt.

In the meantime we can just ignore interrupt value if it is set to 0.



I have another follow-up patch doing that (I have a test setup which
doesn't support interrupts); I just wasn't sure if there was interest,
so I did not yet send it out. I'll be happy to do that, though I would
prefer to keep it separate (it isn't a bug fix, after all).

Thanks,
Guenter



Re: [PATCH 00/15] improve function-level documentation

2016-10-01 Thread Julia Lawall


On Sat, 1 Oct 2016, Joe Perches wrote:

> On Sat, 2016-10-01 at 21:46 +0200, Julia Lawall wrote:
> > These patches fix cases where the documentation above a function definition
> > is not consistent with the function header.  Issues are detected using the
> > semantic patch below (http://coccinelle.lip6.fr/).  Basically, the semantic
> > patch parses a file to find comments, then matches each function header,
> > and checks that the name and parameter list in the function header are
> > compatible with the comment that preceeds it most closely.
>
> Hi Julia.
>
> Would it be possible for a semantic patch to scan for
> function definitions where the types do not have
> identifiers and update the definitions to match the
> declarations?
>
> For instance, given:
>
> 
> int foo(int);
>
> 
> int foo(int bar)
> {
>   return baz;
> }
>
> Could coccinelle output:
>
> diff a/some.h b/some.h
> []
> -int foo(int);
> +int foo(int bar);

The following seems to work:

@r@
identifier f;
position p;
type T, t;
parameter list[n] ps;
@@

T f@p(ps,t,...);

@s@
identifier r.f,x;
type r.T, r.t;
parameter list[r.n] ps;
@@

T f(ps,t x,...) { ... }

@@
identifier r.f, s.x;
position r.p;
type r.T, r.t;
parameter list[r.n] ps;
@@

T f@p(ps,t
+ x
  ,...);

After letting it run for a few minutes without making any effort to
include .h files, I get over 2700 changed lines.

julia


Re: [PATCH 14/15] irqchip/metag-ext: improve function-level documentation

2016-10-01 Thread James Hogan
Hi Julia,

On 1 October 2016 at 20:46, Julia Lawall  wrote:
> Drop the variable irq which ceased to be a parameter in bd0b9ac4.

I think 12 nibbles of the hash is recommended now due to collisions,
as is quoting the subject line, e.g. commit bd0b9ac405e1 ("genirq:
Remove irq argument from irq flow handlers").

>
> Issue detected using Coccinelle (http://coccinelle.lip6.fr/)
>
> Signed-off-by: Julia Lawall 

Acked-by: James Hogan 

Thanks
James

>
> ---
>  drivers/irqchip/irq-metag-ext.c |1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
> index 8c38b3d..0cdd923 100644
> --- a/drivers/irqchip/irq-metag-ext.c
> +++ b/drivers/irqchip/irq-metag-ext.c
> @@ -436,7 +436,6 @@ static int meta_intc_irq_set_type(struct irq_data *data, 
> unsigned int flow_type)
>
>  /**
>   * meta_intc_irq_demux() - external irq de-multiplexer
> - * @irq:   the virtual interrupt number
>   * @desc:  the interrupt description structure for this irq
>   *
>   * The cpu receives an interrupt on TR2 when a SoC interrupt has occurred. 
> It is
>


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Jes Sorensen
Joe Perches  writes:
> On Sat, 2016-10-01 at 14:53 -0400, Jes Sorensen wrote:
>> Joe Perches  writes:
>> > Make the init arrays const to reduce data.
>> > $ size drivers/net/wireless/realtek/rtl8xxxu/built-in.o*
>> > (allyesconfig: x86-32)
>> >    text   data bss dec hex filename
>> >   80107 13651 58 93816 16e78
>> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.new
>> >   65303 28435 58 93796 16e64
>> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.old
>> In total you grow the kernel by 20 bytes. You reduce the data segment
>> substantially while growing the text segment instead.
>
> No, not really.   The alignment boundaries move a bit for
> this particular compilation.  It could go the other way for
> a different compiler version or set of CONFIG options.
>
> What's important is multiple pages of .data move to .rodata.

Your output shows it moving to the text segment - if it's in a different
segment, eg. rodata, you should use output demonstrating that to justify
the change.

Jes


Re:Humanitarian Services.

2016-10-01 Thread Mrs. Kimberly Hills
I am Mrs. Kimberly Hills the wife of late Engineer William Hills We has been 
married for years before his 

sudden death although we were childless. I have been diagnosed with cancer and 
I have been battling with the 

sickness when my late lovely husband was alive.

My Husband left the sum of US $3.800 million United States Dollars in a 
fix/suspense account in one of the 

prime bank  in Cote d'Ivoire. Recently, my Doctor told me that I would not 
exceed more than five more months 

due to cancer problem. The one that disturbs me most is my blood pressure 
sickness. Having known my condition 

I decided to seek for your kind assistance to transfer this fund into your 
account and you will use it to 

train my adopted daughter who is 16yrs. You will take her as your God child and 
brought her up in a good and 

decent manner with what my late husband left behind.

I will give you more details about me and how I inherited all as soon as I 
receive your reply because I do not 

want to state all here until I see your reply, desire and commitment. Please 
can you treat this as 

confidential and keep it as a secret for security reasons between both of us.

My Best Regards.

Mrs. Kimberly Hills


Re: [PATCH 00/15] improve function-level documentation

2016-10-01 Thread Joe Perches
On Sat, 2016-10-01 at 21:46 +0200, Julia Lawall wrote:
> These patches fix cases where the documentation above a function definition
> is not consistent with the function header.  Issues are detected using the
> semantic patch below (http://coccinelle.lip6.fr/).  Basically, the semantic
> patch parses a file to find comments, then matches each function header,
> and checks that the name and parameter list in the function header are
> compatible with the comment that preceeds it most closely.

Hi Julia.

Would it be possible for a semantic patch to scan for
function definitions where the types do not have
identifiers and update the definitions to match the
declarations?

For instance, given:


int foo(int);


int foo(int bar)
{
return baz;
}

Could coccinelle output:

diff a/some.h b/some.h
[]
-int foo(int);
+int foo(int bar);


[PATCH 00/15] improve function-level documentation

2016-10-01 Thread Julia Lawall
These patches fix cases where the documentation above a function definition
is not consistent with the function header.  Issues are detected using the
semantic patch below (http://coccinelle.lip6.fr/).  Basically, the semantic
patch parses a file to find comments, then matches each function header,
and checks that the name and parameter list in the function header are
compatible with the comment that preceeds it most closely.

// 
@initialize:ocaml@
@@

let tbl = ref []
let fnstart = ref []
let success = Hashtbl.create 101
let thefile = ref ""
let parsed = ref []
let nea = ref []

let parse file =
  thefile := List.nth (Str.split (Str.regexp "linux-next/") file) 1;
  let i = open_in file in
  let startline = ref 0 in
  let fn = ref "" in
  let ids = ref [] in
  let rec inside n =
let l = input_line i in
let n = n + 1 in
match Str.split_delim (Str.regexp_string "*/") l with
  before::after::_ ->
(if not (!fn = "")
then tbl := (!startline,n,!fn,List.rev !ids)::!tbl);
startline := 0;
fn := "";
ids := [];
outside n
| _ ->
(match Str.split (Str.regexp "[ \t]+") l with
  "*"::name::rest ->
let len = String.length name in
(if !fn = "" && len > 2 && String.sub name (len-2) 2 = "()"
then fn := String.sub name 0 (len-2)
else if !fn = "" && (not (rest = [])) && List.hd rest = "-"
then
  if String.get name (len-1) = ':'
  then fn := String.sub name 0 (len-1)
  else fn := name
else if not(!fn = "") && len > 2 &&
  String.get name 0 = '@' && String.get name (len-1) = ':'
then ids := (String.sub name 1 (len-2)) :: !ids);
| _ -> ());
inside n
  and outside n =
let l = input_line i in
let n = n + 1 in
if String.length l > 2 && String.sub l 0 3 = "/**"
then
  begin
startline := n;
inside n
  end
else outside n in
  try outside 0 with End_of_file -> ()

let hashadd tbl k v =
  let cell =
try Hashtbl.find tbl k
with Not_found ->
  let cell = ref [] in
  Hashtbl.add tbl k cell;
  cell in
  cell := v :: !cell

@script:ocaml@
@@

tbl := [];
fnstart := [];
Hashtbl.clear success;
parsed := [];
nea := [];
parse (List.hd (Coccilib.files()))

@r@
identifier f;
position p;
@@

f@p(...) { ... }

@script:ocaml@
p << r.p;
f << r.f;
@@

parsed := f :: !parsed;
fnstart := (List.hd p).line :: !fnstart

@param@
identifier f;
type T;
identifier i;
parameter list[n] ps;
parameter list[n1] ps1;
position p;
@@

f@p(ps,T i,ps1) { ... }

@script:ocaml@
@@

tbl := List.rev (List.sort compare !tbl)

@script:ocaml@
p << param.p;
f << param.f;
@@

let myline = (List.hd p).line in
let prevline =
  List.fold_left
(fun prev x ->
  if x < myline
  then max x prev
  else prev)
0 !fnstart in
let _ =
  List.exists
(function (st,fn,nm,ids) ->
  if prevline < st && myline > st && prevline < fn && myline > fn
  then
begin
  (if not (String.lowercase f = String.lowercase nm)
  then
Printf.printf "%s:%d %s doesn't match preceding comment: %s\n"
  !thefile myline f nm);
  true
end
  else false)
!tbl in
()

@script:ocaml@
p << param.p;
n << param.n;
n1 << param.n1;
i << param.i;
f << param.f;
@@

let myline = (List.hd p).line in
let prevline =
  List.fold_left
(fun prev x ->
  if x < myline
  then max x prev
  else prev)
0 !fnstart in
let _ =
  List.exists
(function (st,fn,nm,ids) ->
  if prevline < st && myline > st && prevline < fn && myline > fn
  then
begin
  (if List.mem i ids then hashadd success (st,fn,nm) i);
  (if ids = [] (* arg list seems not obligatory *)
  then ()
  else if not (List.mem i ids)
  then
Printf.printf "%s:%d %s doesn't appear in ids: %s\n"
  !thefile myline i (String.concat " " ids)
  else if List.length ids <= n || List.length ids <= n1
  then
(if not (List.mem f !nea)
then
  begin
nea := f :: !nea;
Printf.printf "%s:%d %s not enough args\n" !thefile myline f;
  end)
  else
let foundid = List.nth ids n in
let efoundid = List.nth (List.rev ids) n1 in
if not(foundid = i || efoundid = i)
then
  Printf.printf "%s:%d %s wrong arg in position %d: %s\n"
!thefile myline i n foundid);
  true
end
  else false)
!tbl in
()

@script:ocaml@
@@
List.iter
  (function (st,fn,nm,ids) ->
if List.mem nm !parsed
then
  let entry =
try !(Hashtbl.find success (st,fn,nm))
with Not_found -> [] in
  List.iter
(fun id ->
  if not (List.mem id entry) && not (id = "...")
  then Printf.printf "%s:%d %s not used\n" !th

[PATCH] fs: cifs: Replace CURRENT_TIME by get_seconds

2016-10-01 Thread Deepa Dinamani
This is in preparation for the change that transitions
filesystem timestamps to use 64 bit time and hence make
them y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned patch.

Filesystems will use current_time() instead of
CURRENT_TIME.
Use ktime_get_real_seconds() here as this is not filesystem
time.
Only the seconds portion of the timestamp is necessary for
timezone calculation using server time.

Assume that the difference between server and client times
lie in the range INT_MIN..INT_MAX. This is valid because
this is the difference between current times between server
and client, and the largest timezone difference is in the
range of one day.

All cifs timestamps currently use timespec internally.
This timestamp can also be transitioned into using
timespec64 when all other timestamps for cifs is transitioned
to use timespec64.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Steve French 
---
 fs/cifs/cifssmb.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index d47197e..6c666a3 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -478,14 +478,14 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, 
NEGOTIATE_RSP *pSMBr)
 * this requirement.
 */
int val, seconds, remain, result;
-   struct timespec ts, utc;
-   utc = CURRENT_TIME;
+   struct timespec ts;
+   unsigned long utc = ktime_get_real_seconds();
ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
rsp->SrvTime.Time, 0);
cifs_dbg(FYI, "SrvTime %d sec since 1970 (utc: %d) diff: %d\n",
-(int)ts.tv_sec, (int)utc.tv_sec,
-(int)(utc.tv_sec - ts.tv_sec));
-   val = (int)(utc.tv_sec - ts.tv_sec);
+(int)ts.tv_sec, (int)utc,
+(int)(utc - ts.tv_sec));
+   val = (int)(utc - ts.tv_sec);
seconds = abs(val);
result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
remain = seconds % MIN_TZ_ADJ;
-- 
2.7.4



[PATCH 01/15] UBIFS: improve function-level documentation

2016-10-01 Thread Julia Lawall
Fix various inconsistencies in the documentation associated with various
functions.

In the case of fs/ubifs/lprops.c, the second parameter of
ubifs_get_lp_stats was renamed from st to lst in 84abf972.

In the case of fs/ubifs/lpt_commit.c, the excess variables have never
existed in the associated functions since the code was introduced into the
kernel.

The others appear to be straightforward typos.

Issues detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 fs/ubifs/file.c   |2 +-
 fs/ubifs/gc.c |2 +-
 fs/ubifs/lprops.c |2 +-
 fs/ubifs/lpt_commit.c |4 +---
 fs/ubifs/replay.c |2 +-
 5 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index b0a6a53..629c719 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1397,7 +1397,7 @@ int ubifs_update_time(struct inode *inode, struct 
timespec *time,
 #endif
 
 /**
- * update_ctime - update mtime and ctime of an inode.
+ * update_mctime - update mtime and ctime of an inode.
  * @inode: inode to update
  *
  * This function updates mtime and ctime of the inode if it is not equivalent 
to
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 821b348..e845c64 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -113,7 +113,7 @@ static int switch_gc_head(struct ubifs_info *c)
  * data_nodes_cmp - compare 2 data nodes.
  * @priv: UBIFS file-system description object
  * @a: first data node
- * @a: second data node
+ * @b: second data node
  *
  * This function compares data nodes @a and @b. Returns %1 if @a has greater
  * inode or block number, and %-1 otherwise.
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index a0011aa..6c3a1ab 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -636,7 +636,7 @@ const struct ubifs_lprops *ubifs_change_lp(struct 
ubifs_info *c,
 /**
  * ubifs_get_lp_stats - get lprops statistics.
  * @c: UBIFS file-system description object
- * @st: return statistics
+ * @lst: return statistics
  */
 void ubifs_get_lp_stats(struct ubifs_info *c, struct ubifs_lp_stats *lst)
 {
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index ce89bdc..235654c 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -34,7 +34,6 @@
 
 /**
  * first_dirty_cnode - find first dirty cnode.
- * @c: UBIFS file-system description object
  * @nnode: nnode at which to start
  *
  * This function returns the first dirty cnode or %NULL if there is not one.
@@ -1623,7 +1622,6 @@ static int dbg_is_node_dirty(struct ubifs_info *c, int 
node_type, int lnum,
  * dbg_check_ltab_lnum - check the ltab for a LPT LEB number.
  * @c: the UBIFS file-system description object
  * @lnum: LEB number where node was written
- * @offs: offset where node was written
  *
  * This function returns %0 on success and a negative error code on failure.
  */
@@ -1870,7 +1868,7 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int 
len)
 }
 
 /**
- * ubifs_dump_lpt_leb - dump an LPT LEB.
+ * dump_lpt_leb - dump an LPT LEB.
  * @c: UBIFS file-system description object
  * @lnum: LEB number to dump
  *
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index 3ca4540..fb0f44c 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -267,7 +267,7 @@ static int apply_replay_entry(struct ubifs_info *c, struct 
replay_entry *r)
  * replay_entries_cmp - compare 2 replay entries.
  * @priv: UBIFS file-system description object
  * @a: first replay entry
- * @a: second replay entry
+ * @b: second replay entry
  *
  * This is a comparios function for 'list_sort()' which compares 2 replay
  * entries @a and @b by comparing their sequence numer.  Returns %1 if @a has



[PATCH 05/15] dma-buf/sw_sync: improve function-level documentation

2016-10-01 Thread Julia Lawall
Adjust the documentation to use the names that appear in the function
parameter list.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/dma-buf/sw_sync.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
index 62e8e6d..5d2b1b6 100644
--- a/drivers/dma-buf/sw_sync.c
+++ b/drivers/dma-buf/sw_sync.c
@@ -155,11 +155,11 @@ static void sync_timeline_signal(struct sync_timeline 
*obj, unsigned int inc)
 
 /**
  * sync_pt_create() - creates a sync pt
- * @parent:fence's parent sync_timeline
+ * @obj:   fence's parent sync_timeline
  * @size:  size to allocate for this pt
- * @inc:   value of the fence
+ * @value: value of the fence
  *
- * Creates a new sync_pt as a child of @parent.  @size bytes will be
+ * Creates a new sync_pt as a child of @obj.  @size bytes will be
  * allocated allowing for implementation specific data to be kept after
  * the generic sync_timeline struct. Returns the sync_pt object or
  * NULL in case of error.



[PATCH 04/15] lru_cache: improve function-level documentation

2016-10-01 Thread Julia Lawall
Use the actual function name and reorder the listed variables to correspond
to their order in the function parameter list.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 lib/lru_cache.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/lru_cache.c b/lib/lru_cache.c
index 28ba40b..07d3507 100644
--- a/lib/lru_cache.c
+++ b/lib/lru_cache.c
@@ -639,9 +639,9 @@ void lc_set(struct lru_cache *lc, unsigned int enr, int 
index)
 }
 
 /**
- * lc_dump - Dump a complete LRU cache to seq in textual form.
- * @lc: the lru cache to operate on
+ * lc_seq_dump_details - Dump a complete LRU cache to seq in textual form.
  * @seq: the &struct seq_file pointer to seq_printf into
+ * @lc: the lru cache to operate on
  * @utext: user supplied additional "heading" or other info
  * @detail: function pointer the user may provide to dump further details
  * of the object the lc_element is embedded in. May be NULL.



[PATCH 11/15] kobject: improve function-level documentation

2016-10-01 Thread Julia Lawall
In the first case, rename the second variable to correspond to the name
found in the function parameter list.

In the remaining cases, reorder the variables to correspond to their order
in the parameter list.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 lib/kobject_uevent.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index f6c2c1e..9a2b811 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -56,7 +56,7 @@ struct uevent_sock {
  * kobject_action_type - translate action string to numeric type
  *
  * @buf: buffer containing the action string, newline is ignored
- * @len: length of buffer
+ * @count: length of buffer
  * @type: pointer to the location to store the action type
  *
  * Returns 0 if the action string was recognized.
@@ -154,8 +154,8 @@ static void cleanup_uevent_env(struct subprocess_info *info)
 /**
  * kobject_uevent_env - send an uevent with environmental data
  *
- * @action: action that is happening
  * @kobj: struct kobject that the action is happening to
+ * @action: action that is happening
  * @envp_ext: pointer to environmental data
  *
  * Returns 0 if kobject_uevent_env() is completed with success or the
@@ -363,8 +363,8 @@ int kobject_uevent_env(struct kobject *kobj, enum 
kobject_action action,
 /**
  * kobject_uevent - notify userspace by sending an uevent
  *
- * @action: action that is happening
  * @kobj: struct kobject that the action is happening to
+ * @action: action that is happening
  *
  * Returns 0 if kobject_uevent() is completed with success or the
  * corresponding error when it fails.



[PATCH 09/15] gma500: improve function-level documentation

2016-10-01 Thread Julia Lawall
Delete a reference to a variable that has never been used by the function
in the first case, and rename a variable to that of the corresponding
parameter name in the second case.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/gpu/drm/gma500/intel_i2c.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/intel_i2c.c 
b/drivers/gpu/drm/gma500/intel_i2c.c
index 98a28c2..12c40f1 100644
--- a/drivers/gpu/drm/gma500/intel_i2c.c
+++ b/drivers/gpu/drm/gma500/intel_i2c.c
@@ -95,7 +95,6 @@ static void set_data(void *data, int state_high)
 /**
  * psb_intel_i2c_create - instantiate an Intel i2c bus using the specified 
GPIO reg
  * @dev: DRM device
- * @output: driver specific output device
  * @reg: GPIO reg to use
  * @name: name for this bus
  *
@@ -155,7 +154,7 @@ struct psb_intel_i2c_chan *psb_intel_i2c_create(struct 
drm_device *dev,
 
 /**
  * psb_intel_i2c_destroy - unregister and free i2c bus resources
- * @output: channel to free
+ * @chan: channel to free
  *
  * Unregister the adapter from the i2c layer, then free the structure.
  */



[PATCH 10/15] clk: keystone: improve function-level documentation

2016-10-01 Thread Julia Lawall
Adjust the documentation to use the actual function names.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/clk/keystone/pll.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/keystone/pll.c b/drivers/clk/keystone/pll.c
index a26ba21..185f19c 100644
--- a/drivers/clk/keystone/pll.c
+++ b/drivers/clk/keystone/pll.c
@@ -154,7 +154,7 @@ static struct clk *clk_register_pll(struct device *dev,
 }
 
 /**
- * _of_clk_init - PLL initialisation via DT
+ * _of_pll_clk_init - PLL initialisation via DT
  * @node: device tree node for this clock
  * @pllctrl: If true, lower 6 bits of multiplier is in pllm register of
  * pll controller, else it is in the control register0(bit 11-6)
@@ -235,7 +235,7 @@ static void __init of_keystone_pll_clk_init(struct 
device_node *node)
of_keystone_pll_clk_init);
 
 /**
- * of_keystone_pll_main_clk_init - Main PLL initialisation DT wrapper
+ * of_keystone_main_pll_clk_init - Main PLL initialisation DT wrapper
  * @node: device tree node for this clock
  */
 static void __init of_keystone_main_pll_clk_init(struct device_node *node)



[PATCH 06/15] mfd: tc3589x: improve function-level documentation

2016-10-01 Thread Julia Lawall
Use the correct function name in one case and adjust a variable name to
that of the corresponding function parameter in another case.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/mfd/tc3589x.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index 274bf39..cc9e563 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -53,7 +53,7 @@ int tc3589x_reg_read(struct tc3589x *tc3589x, u8 reg)
 EXPORT_SYMBOL_GPL(tc3589x_reg_read);
 
 /**
- * tc3589x_reg_read() - write a single TC3589x register
+ * tc3589x_reg_write() - write a single TC3589x register
  * @tc3589x:   Device to write to
  * @reg:   Register to read
  * @data:  Value to write
@@ -118,7 +118,7 @@ int tc3589x_block_write(struct tc3589x *tc3589x, u8 reg, u8 
length,
  * @tc3589x:   Device to write to
  * @reg:   Register to write
  * @mask:  Mask of bits to set
- * @values:Value to set
+ * @val:   Value to set
  */
 int tc3589x_set_bits(struct tc3589x *tc3589x, u8 reg, u8 mask, u8 val)
 {



[PATCH 08/15] power: improve function-level documentation

2016-10-01 Thread Julia Lawall
In drivers/power/supply/ab8500_fg.c, fix two typos and adjust the function
name in two cases to correspond to the names of the defined functions.

In drivers/power/supply/power_supply_core.c, change two variable names to
the names of the corresponding parameters.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/power/supply/ab8500_fg.c |8 
 drivers/power/supply/power_supply_core.c |4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
index 2199f67..c569f82 100644
--- a/drivers/power/supply/ab8500_fg.c
+++ b/drivers/power/supply/ab8500_fg.c
@@ -1900,7 +1900,7 @@ static void ab8500_fg_low_bat_work(struct work_struct 
*work)
  * ab8500_fg_battok_calc - calculate the bit pattern corresponding
  * to the target voltage.
  * @di:   pointer to the ab8500_fg structure
- * @targettarget voltage
+ * @target:   target voltage
  *
  * Returns bit pattern closest to the target voltage
  * valid return values are 0-14. (0-BATT_OK_MAX_NR_INCREMENTS)
@@ -2391,7 +2391,7 @@ static void ab8500_fg_external_power_changed(struct 
power_supply *psy)
 }
 
 /**
- * abab8500_fg_reinit_work() - work to reset the FG algorithm
+ * ab8500_fg_reinit_work() - work to reset the FG algorithm
  * @work:  pointer to the work_struct structure
  *
  * Used to reset the current battery capacity to be able to
@@ -2528,7 +2528,7 @@ static ssize_t charge_now_store(struct ab8500_fg *di, 
const char *buf,
 };
 
 /**
- * ab8500_chargalg_sysfs_exit() - de-init of sysfs entry
+ * ab8500_fg_sysfs_exit() - de-init of sysfs entry
  * @di:pointer to the struct ab8500_chargalg
  *
  * This function removes the entry in sysfs.
@@ -2539,7 +2539,7 @@ static void ab8500_fg_sysfs_exit(struct ab8500_fg *di)
 }
 
 /**
- * ab8500_chargalg_sysfs_init() - init of sysfs entry
+ * ab8500_fg_sysfs_init() - init of sysfs entry
  * @di:pointer to the struct ab8500_chargalg
  *
  * This function adds an entry in sysfs.
diff --git a/drivers/power/supply/power_supply_core.c 
b/drivers/power/supply/power_supply_core.c
index a74d8ca..1e0960b 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -413,7 +413,7 @@ static int power_supply_match_device_node(struct device 
*dev, const void *data)
 /**
  * power_supply_get_by_phandle() - Search for a power supply and returns its 
ref
  * @np: Pointer to device node holding phandle property
- * @phandle_name: Name of property holding a power supply name
+ * @property: Name of property holding a power supply name
  *
  * If power supply was found, it increases reference count for the
  * internal power supply's device. The user should power_supply_put()
@@ -458,7 +458,7 @@ static void devm_power_supply_put(struct device *dev, void 
*res)
  * devm_power_supply_get_by_phandle() - Resource managed version of
  *  power_supply_get_by_phandle()
  * @dev: Pointer to device holding phandle property
- * @phandle_name: Name of property holding a power supply phandle
+ * @property: Name of property holding a power supply phandle
  *
  * Return: On success returns a reference to a power supply with
  * matching name equals to value under @property, NULL or ERR_PTR otherwise.



[PATCH 13/15] irqchip: vic: improve function-level documentation

2016-10-01 Thread Julia Lawall
The associated function, vic_init_cascaded, has never had a variable
irq_start.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/irqchip/irq-vic.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/irqchip/irq-vic.c b/drivers/irqchip/irq-vic.c
index f811a7d..74192f6 100644
--- a/drivers/irqchip/irq-vic.c
+++ b/drivers/irqchip/irq-vic.c
@@ -498,7 +498,6 @@ void __init vic_init(void __iomem *base, unsigned int 
irq_start,
  * vic_init_cascaded() - initialise a cascaded vectored interrupt controller
  * @base: iomem base address
  * @parent_irq: the parent IRQ we're cascaded off
- * @irq_start: starting interrupt number, must be muliple of 32
  * @vic_sources: bitmask of interrupt sources to allow
  * @resume_sources: bitmask of interrupt sources to allow for resume
  *



[PATCH 07/15] clk: sunxi: mod0: improve function-level documentation

2016-10-01 Thread Julia Lawall
Use the actual function name in the function documentation.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/clk/sunxi/clk-mod0.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/sunxi/clk-mod0.c b/drivers/clk/sunxi/clk-mod0.c
index e54266c..4417ae1 100644
--- a/drivers/clk/sunxi/clk-mod0.c
+++ b/drivers/clk/sunxi/clk-mod0.c
@@ -24,7 +24,7 @@
 #include "clk-factors.h"
 
 /**
- * sun4i_get_mod0_factors() - calculates m, n factors for MOD0-style clocks
+ * sun4i_a10_get_mod0_factors() - calculates m, n factors for MOD0-style clocks
  * MOD0 rate is calculated as follows
  * rate = (parent_rate >> p) / (m + 1);
  */



[PATCH 15/15] drm/omap: improve function-level documentation

2016-10-01 Thread Julia Lawall
Use the names of the corresponding functions.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/gpu/drm/omapdrm/omap_drv.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index e1cfba5..8d93355 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -635,7 +635,7 @@ static int ioctl_gem_info(struct drm_device *dev, void 
*data,
  */
 
 /**
- * load - setup chip and create an initial config
+ * dev_load - setup chip and create an initial config
  * @dev: DRM device
  * @flags: startup flags
  *
@@ -733,7 +733,7 @@ static int dev_open(struct drm_device *dev, struct drm_file 
*file)
 }
 
 /**
- * lastclose - clean up after all DRM clients have exited
+ * dev_lastclose - clean up after all DRM clients have exited
  * @dev: DRM device
  *
  * Take care of cleaning up after all DRM clients have exited.  In the



[PATCH 12/15] clk: tegra: dfll: improve function-level documentation

2016-10-01 Thread Julia Lawall
Adjust variables to correspond to the names used in the parameter list of
the function.  Move the struct device * variable up to the place where it
appears in the parameter list.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/clk/tegra/cvb.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/tegra/cvb.c b/drivers/clk/tegra/cvb.c
index 624115e..da9e8e7 100644
--- a/drivers/clk/tegra/cvb.c
+++ b/drivers/clk/tegra/cvb.c
@@ -92,19 +92,19 @@ static int build_opp_table(struct device *dev, const struct 
cvb_table *table,
 
 /**
  * tegra_cvb_add_opp_table - build OPP table from Tegra CVB tables
- * @cvb_tables: array of CVB tables
- * @sz: size of the previously mentioned array
+ * @dev: the struct device * for which the OPP table is built
+ * @tables: array of CVB tables
+ * @count: size of the previously mentioned array
  * @process_id: process id of the HW module
  * @speedo_id: speedo id of the HW module
  * @speedo_value: speedo value of the HW module
- * @max_rate: highest safe clock rate
- * @opp_dev: the struct device * for which the OPP table is built
+ * @max_freq: highest safe clock rate
  *
  * On Tegra, a CVB table encodes the relationship between operating voltage
  * and safe maximal frequency for a given module (e.g. GPU or CPU). This
  * function calculates the optimal voltage-frequency operating points
  * for the given arguments and exports them via the OPP library for the
- * given @opp_dev. Returns a pointer to the struct cvb_table that matched
+ * given @dev. Returns a pointer to the struct cvb_table that matched
  * or an ERR_PTR on failure.
  */
 const struct cvb_table *



[PATCH 14/15] irqchip/metag-ext: improve function-level documentation

2016-10-01 Thread Julia Lawall
Drop the variable irq which ceased to be a parameter in bd0b9ac4.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 drivers/irqchip/irq-metag-ext.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
index 8c38b3d..0cdd923 100644
--- a/drivers/irqchip/irq-metag-ext.c
+++ b/drivers/irqchip/irq-metag-ext.c
@@ -436,7 +436,6 @@ static int meta_intc_irq_set_type(struct irq_data *data, 
unsigned int flow_type)
 
 /**
  * meta_intc_irq_demux() - external irq de-multiplexer
- * @irq:   the virtual interrupt number
  * @desc:  the interrupt description structure for this irq
  *
  * The cpu receives an interrupt on TR2 when a SoC interrupt has occurred. It 
is



[PATCH 03/15] fscrypto: improve function-level documentation

2016-10-01 Thread Julia Lawall
Correct spelling mistakes in the documentation associated with two
functions in fs/crypto/crypto.c.

Use actual function names in the documentation associated with two
functions in fs/crypto/fname.c.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 fs/crypto/crypto.c |4 ++--
 fs/crypto/fname.c  |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 61057b7d..9d6ec61 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -211,7 +211,7 @@ static struct page *alloc_bounce_page(struct fscrypt_ctx 
*ctx, gfp_t gfp_flags)
 }
 
 /**
- * fscypt_encrypt_page() - Encrypts a page
+ * fscrypt_encrypt_page() - Encrypts a page
  * @inode:  The inode for which the encryption should take place
  * @plaintext_page: The page to encrypt. Must be locked.
  * @gfp_flags:  The gfp flag for memory allocation
@@ -264,7 +264,7 @@ struct page *fscrypt_encrypt_page(struct inode *inode,
 EXPORT_SYMBOL(fscrypt_encrypt_page);
 
 /**
- * f2crypt_decrypt_page() - Decrypts a page in-place
+ * fscrypt_decrypt_page() - Decrypts a page in-place
  * @page: The page to decrypt. Must be locked.
  *
  * Decrypts page in-place using the ctx encryption context.
diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
index 90697c7..4b0de94 100644
--- a/fs/crypto/fname.c
+++ b/fs/crypto/fname.c
@@ -240,7 +240,7 @@ u32 fscrypt_fname_encrypted_size(struct inode *inode, u32 
ilen)
 EXPORT_SYMBOL(fscrypt_fname_encrypted_size);
 
 /**
- * fscrypt_fname_crypto_alloc_obuff() -
+ * fscrypt_fname_alloc_buffer() -
  *
  * Allocates an output buffer that is sufficient for the crypto operation
  * specified by the context and the direction.
@@ -265,7 +265,7 @@ int fscrypt_fname_alloc_buffer(struct inode *inode,
 EXPORT_SYMBOL(fscrypt_fname_alloc_buffer);
 
 /**
- * fscrypt_fname_crypto_free_buffer() -
+ * fscrypt_fname_free_buffer() -
  *
  * Frees the buffer allocated for crypto operation.
  */



[PATCH 02/15] netlink: improve function-level documentation

2016-10-01 Thread Julia Lawall
Rename a variable in the documentation so that it corresponds to the name
of the function parameter.

Issue detected using Coccinelle (http://coccinelle.lip6.fr/)

Signed-off-by: Julia Lawall 

---
 lib/nlattr.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/nlattr.c b/lib/nlattr.c
index fce1e9a..14cb5cf 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -139,7 +139,7 @@ int nla_validate(const struct nlattr *head, int len, int 
maxtype,
 
 /**
  * nla_policy_len - Determin the max. length of a policy
- * @policy: policy to use
+ * @p: policy to use
  * @n: number of policies
  *
  * Determines the max. length of the policy.  It is currently used



[PATCH] fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts()

2016-10-01 Thread Deepa Dinamani
This is in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe.

CURRENT_TIME macro will be deleted before merging the
aforementioned patch.

Filesystem times will use current_fs_time() instead of
CURRENT_TIME.
Use ktime_get_real_ts() here as this is not filesystem time.
ktime_get_real_ts() returns the timestamp in ns which can
be used to calculate network time for NTLMv2 authentication
timestamp.

All cifs timestamps currently use timespec internally.
This timestamp can also be transitioned into using
timespec64 when all other timestamps for cifs is transitioned
to use timespec64.

Signed-off-by: Deepa Dinamani 
Reviewed-by: Arnd Bergmann 
Cc: Steve French 
---
 fs/cifs/cifsencrypt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 8347c90..fd01bf0 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -471,6 +471,7 @@ find_timestamp(struct cifs_ses *ses)
unsigned char *blobptr;
unsigned char *blobend;
struct ntlmssp2_name *attrptr;
+   struct timespec ts;
 
if (!ses->auth_key.len || !ses->auth_key.response)
return 0;
@@ -495,7 +496,8 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */
}
 
-   return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
+   ktime_get_real_ts(&ts);
+   return cpu_to_le64(cifs_UnixTimeToNT(ts));
 }
 
 static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
-- 
2.7.4



Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Joe Perches
On Sat, 2016-10-01 at 14:53 -0400, Jes Sorensen wrote:
> Joe Perches  writes:
> > Make the init arrays const to reduce data.
> > $ size drivers/net/wireless/realtek/rtl8xxxu/built-in.o* (allyesconfig: 
> > x86-32)
> >    textdata bss dec hex filename
> >   80107   13651  58   93816   16e78 
> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.new
> >   65303   28435  58   93796   16e64 
> > drivers/net/wireless/realtek/rtl8xxxu/built-in.o.old
> In total you grow the kernel by 20 bytes. You reduce the data segment
> substantially while growing the text segment instead.

No, not really.   The alignment boundaries move a bit for
this particular compilation.  It could go the other way for
a different compiler version or set of CONFIG options.

What's important is multiple pages of .data move to .rodata.



[PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir with a static array

2016-10-01 Thread Jarkko Sakkinen
This commit is based on a commit by Nayna Jain. Replaced dynamically
allocated bios_dir with a static array as the size is always constant.

Suggested-by: Jason Gunthorpe 
Signed-off-by: Nayna Jain 
Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c |  9 +++---
 drivers/char/tpm/tpm.h  |  3 +-
 drivers/char/tpm/tpm_eventlog.c | 62 +++--
 drivers/char/tpm/tpm_eventlog.h | 10 +++
 4 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index e595013..a56b609 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -278,14 +278,16 @@ static void tpm_del_char_device(struct tpm_chip *chip)
 
 static int tpm1_chip_register(struct tpm_chip *chip)
 {
+   int rc;
+
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return 0;
 
tpm_sysfs_add_device(chip);
 
-   chip->bios_dir = tpm_bios_log_setup(dev_name(&chip->dev));
+   rc = tpm_bios_log_setup(chip);
 
-   return 0;
+   return rc;
 }
 
 static void tpm1_chip_unregister(struct tpm_chip *chip)
@@ -293,8 +295,7 @@ static void tpm1_chip_unregister(struct tpm_chip *chip)
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return;
 
-   if (chip->bios_dir)
-   tpm_bios_log_teardown(chip->bios_dir);
+   tpm_bios_log_teardown(chip);
 }
 
 static void tpm_del_legacy_sysfs(struct tpm_chip *chip)
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 4d183c9..4c118a4 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -40,6 +40,7 @@ enum tpm_const {
TPM_BUFSIZE = 4096,
TPM_NUM_DEVICES = 65536,
TPM_RETRY = 50, /* 5 seconds */
+   TPM_NUM_EVENT_LOG_FILES = 3,
 };
 
 enum tpm_timeout {
@@ -171,7 +172,7 @@ struct tpm_chip {
unsigned long duration[3]; /* jiffies */
bool duration_adjusted;
 
-   struct dentry **bios_dir;
+   struct dentry *bios_dir[TPM_NUM_EVENT_LOG_FILES];
 
const struct attribute_group *groups[3];
unsigned int groups_cnt;
diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index 75e6644..f5e1d06 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -368,54 +368,50 @@ static int is_bad(void *p)
return 0;
 }
 
-struct dentry **tpm_bios_log_setup(const char *name)
+int tpm_bios_log_setup(struct tpm_chip *chip)
 {
-   struct dentry **ret = NULL, *tpm_dir, *bin_file, *ascii_file;
+   const char *name = dev_name(&chip->dev);
+   unsigned int cnt;
 
-   tpm_dir = securityfs_create_dir(name, NULL);
-   if (is_bad(tpm_dir))
-   goto out;
+   cnt = 0;
+   chip->bios_dir[cnt] =
+   securityfs_create_dir(name, NULL);
+   if (is_bad(chip->bios_dir[cnt]))
+   goto err;
+   cnt++;
 
-   bin_file =
+   chip->bios_dir[cnt] =
securityfs_create_file("binary_bios_measurements",
-  S_IRUSR | S_IRGRP, tpm_dir,
+  S_IRUSR | S_IRGRP, chip->bios_dir[0],
   (void *)&tpm_binary_b_measurments_seqops,
   &tpm_bios_measurements_ops);
-   if (is_bad(bin_file))
-   goto out_tpm;
+   if (is_bad(chip->bios_dir[cnt]))
+   goto err;
+   cnt++;
 
-   ascii_file =
+   chip->bios_dir[cnt] =
securityfs_create_file("ascii_bios_measurements",
-  S_IRUSR | S_IRGRP, tpm_dir,
+  S_IRUSR | S_IRGRP, chip->bios_dir[0],
   (void *)&tpm_ascii_b_measurments_seqops,
   &tpm_bios_measurements_ops);
-   if (is_bad(ascii_file))
-   goto out_bin;
+   if (is_bad(chip->bios_dir[cnt]))
+   goto err;
+   cnt++;
 
-   ret = kmalloc(3 * sizeof(struct dentry *), GFP_KERNEL);
-   if (!ret)
-   goto out_ascii;
-
-   ret[0] = ascii_file;
-   ret[1] = bin_file;
-   ret[2] = tpm_dir;
-
-   return ret;
+   return 0;
 
-out_ascii:
-   securityfs_remove(ascii_file);
-out_bin:
-   securityfs_remove(bin_file);
-out_tpm:
-   securityfs_remove(tpm_dir);
-out:
-   return NULL;
+err:
+   chip->bios_dir[cnt] = NULL;
+   tpm_bios_log_teardown(chip);
+   return -EIO;
 }
 
-void tpm_bios_log_teardown(struct dentry **lst)
+void tpm_bios_log_teardown(struct tpm_chip *chip)
 {
int i;
 
-   for (i = 0; i < 3; i++)
-   securityfs_remove(lst[i]);
+   for (i = (TPM_NUM_EVENT_LOG_FILES - 1); i >= 0; i--) {
+   if (chip->bios_dir[i])
+   securityfs_remove(chip->bios_dir[i]);
+   }
 }
diff --git a/drivers/char/tpm/tpm_eventlog.h b/drivers/char/tpm/tpm_eventlog.h
index 8de62b0..fd3357e 100644
--- a/drive

[PATCH RESEND 3/3] tpm: drop tpm1_chip_register(/unregister)

2016-10-01 Thread Jarkko Sakkinen
Check for TPM2 chip in tpm_sysfs_add_device, tpm_bios_log_setup and
tpm_bios_log_teardown in order to make code flow cleaner and to enable
to implement TPM 2.0 support later on. This is partially derived from
the commit by Nayna Jain with the extension that also tpm1_chip_register
is dropped.

Signed-off-by: Jarkko Sakkinen 
---
 drivers/char/tpm/tpm-chip.c | 31 +--
 drivers/char/tpm/tpm-sysfs.c|  3 +++
 drivers/char/tpm/tpm_eventlog.c |  6 ++
 3 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index a56b609..eac1f10 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -276,28 +276,6 @@ static void tpm_del_char_device(struct tpm_chip *chip)
up_write(&chip->ops_sem);
 }
 
-static int tpm1_chip_register(struct tpm_chip *chip)
-{
-   int rc;
-
-   if (chip->flags & TPM_CHIP_FLAG_TPM2)
-   return 0;
-
-   tpm_sysfs_add_device(chip);
-
-   rc = tpm_bios_log_setup(chip);
-
-   return rc;
-}
-
-static void tpm1_chip_unregister(struct tpm_chip *chip)
-{
-   if (chip->flags & TPM_CHIP_FLAG_TPM2)
-   return;
-
-   tpm_bios_log_teardown(chip);
-}
-
 static void tpm_del_legacy_sysfs(struct tpm_chip *chip)
 {
struct attribute **i;
@@ -364,7 +342,9 @@ int tpm_chip_register(struct tpm_chip *chip)
return rc;
}
 
-   rc = tpm1_chip_register(chip);
+   tpm_sysfs_add_device(chip);
+
+   rc = tpm_bios_log_setup(chip);
if (rc)
return rc;
 
@@ -372,7 +352,7 @@ int tpm_chip_register(struct tpm_chip *chip)
 
rc = tpm_add_char_device(chip);
if (rc) {
-   tpm1_chip_unregister(chip);
+   tpm_bios_log_teardown(chip);
return rc;
}
 
@@ -407,8 +387,7 @@ void tpm_chip_unregister(struct tpm_chip *chip)
return;
 
tpm_del_legacy_sysfs(chip);
-
-   tpm1_chip_unregister(chip);
+   tpm_bios_log_teardown(chip);
tpm_del_char_device(chip);
 }
 EXPORT_SYMBOL_GPL(tpm_chip_unregister);
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index a76ab4a..1eca5ec 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -284,6 +284,9 @@ static const struct attribute_group tpm_dev_group = {
 
 void tpm_sysfs_add_device(struct tpm_chip *chip)
 {
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   return;
+
/* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
 * is called before ops is null'd and the sysfs core synchronizes this
 * removal so that no callbacks are running or can run again
diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index f5e1d06..c57b981 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -373,6 +373,9 @@ int tpm_bios_log_setup(struct tpm_chip *chip)
const char *name = dev_name(&chip->dev);
unsigned int cnt;
 
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   return 0;
+
cnt = 0;
chip->bios_dir[cnt] =
securityfs_create_dir(name, NULL);
@@ -410,6 +413,9 @@ void tpm_bios_log_teardown(struct tpm_chip *chip)
 {
int i;
 
+   if (chip->flags & TPM_CHIP_FLAG_TPM2)
+   return;
+
for (i = (TPM_NUM_EVENT_LOG_FILES - 1); i >= 0; i--) {
if (chip->bios_dir[i])
securityfs_remove(chip->bios_dir[i]);
-- 
2.7.4



[PATCH RESEND 0/3] Clean up handling of event log files

2016-10-01 Thread Jarkko Sakkinen
Meld a common function for opening measurements files and keep the
dentries in a static array.

Jarkko Sakkinen (2):
  tpm: replace dynamically allocated bios_dir with a static array
  tpm: drop tpm1_chip_register(/unregister)

Nayna Jain (1):
  tpm: define a generic open() method for ascii & bios measurements

 drivers/char/tpm/tpm-chip.c |  30 ++
 drivers/char/tpm/tpm-sysfs.c|   3 +
 drivers/char/tpm/tpm.h  |   3 +-
 drivers/char/tpm/tpm_eventlog.c | 129 +++-
 drivers/char/tpm/tpm_eventlog.h |  10 ++--
 5 files changed, 64 insertions(+), 111 deletions(-)

-- 
2.7.4



[PATCH RESEND 1/3] tpm: define a generic open() method for ascii & bios measurements

2016-10-01 Thread Jarkko Sakkinen
From: Nayna Jain 

open() method for event log ascii and binary bios measurements file
operations are very similar. This patch refactors the code into a
single open() call by passing seq_operations as i_node->private data.

Suggested-by: Jason Gunthorpe 
Signed-off-by: Nayna Jain 
Reviewed-by: Jarkko Sakkinen 
Reviewed-by: Jason Gunthorpe 
---
 drivers/char/tpm/tpm_eventlog.c | 59 +
 1 file changed, 13 insertions(+), 46 deletions(-)

diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index e722886..75e6644 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -7,6 +7,7 @@
  * Stefan Berger 
  * Reiner Sailer 
  * Kylene Hall 
+ * Nayna Jain 
  *
  * Maintained by: 
  *
@@ -318,12 +319,14 @@ static const struct seq_operations 
tpm_binary_b_measurments_seqops = {
.show = tpm_binary_bios_measurements_show,
 };
 
-static int tpm_ascii_bios_measurements_open(struct inode *inode,
+static int tpm_bios_measurements_open(struct inode *inode,
struct file *file)
 {
int err;
struct tpm_bios_log *log;
struct seq_file *seq;
+   const struct seq_operations *seqops =
+   (const struct seq_operations *)inode->i_private;
 
log = kzalloc(sizeof(struct tpm_bios_log), GFP_KERNEL);
if (!log)
@@ -333,7 +336,7 @@ static int tpm_ascii_bios_measurements_open(struct inode 
*inode,
goto out_free;
 
/* now register seq file */
-   err = seq_open(file, &tpm_ascii_b_measurments_seqops);
+   err = seq_open(file, seqops);
if (!err) {
seq = file->private_data;
seq->private = log;
@@ -349,46 +352,8 @@ out_free:
goto out;
 }
 
-static const struct file_operations tpm_ascii_bios_measurements_ops = {
-   .open = tpm_ascii_bios_measurements_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = tpm_bios_measurements_release,
-};
-
-static int tpm_binary_bios_measurements_open(struct inode *inode,
-struct file *file)
-{
-   int err;
-   struct tpm_bios_log *log;
-   struct seq_file *seq;
-
-   log = kzalloc(sizeof(struct tpm_bios_log), GFP_KERNEL);
-   if (!log)
-   return -ENOMEM;
-
-   if ((err = read_log(log)))
-   goto out_free;
-
-   /* now register seq file */
-   err = seq_open(file, &tpm_binary_b_measurments_seqops);
-   if (!err) {
-   seq = file->private_data;
-   seq->private = log;
-   } else {
-   goto out_free;
-   }
-
-out:
-   return err;
-out_free:
-   kfree(log->bios_event_log);
-   kfree(log);
-   goto out;
-}
-
-static const struct file_operations tpm_binary_bios_measurements_ops = {
-   .open = tpm_binary_bios_measurements_open,
+static const struct file_operations tpm_bios_measurements_ops = {
+   .open = tpm_bios_measurements_open,
.read = seq_read,
.llseek = seq_lseek,
.release = tpm_bios_measurements_release,
@@ -413,15 +378,17 @@ struct dentry **tpm_bios_log_setup(const char *name)
 
bin_file =
securityfs_create_file("binary_bios_measurements",
-  S_IRUSR | S_IRGRP, tpm_dir, NULL,
-  &tpm_binary_bios_measurements_ops);
+  S_IRUSR | S_IRGRP, tpm_dir,
+  (void *)&tpm_binary_b_measurments_seqops,
+  &tpm_bios_measurements_ops);
if (is_bad(bin_file))
goto out_tpm;
 
ascii_file =
securityfs_create_file("ascii_bios_measurements",
-  S_IRUSR | S_IRGRP, tpm_dir, NULL,
-  &tpm_ascii_bios_measurements_ops);
+  S_IRUSR | S_IRGRP, tpm_dir,
+  (void *)&tpm_ascii_b_measurments_seqops,
+  &tpm_bios_measurements_ops);
if (is_bad(ascii_file))
goto out_bin;
 
-- 
2.7.4



Re: [PATCH 2/2] tpm: replace dynamically allocated bios_dir with a static array

2016-10-01 Thread Jarkko Sakkinen
On Sat, Oct 01, 2016 at 10:49:32AM -0600, Jason Gunthorpe wrote:
> On Sat, Oct 01, 2016 at 03:41:17PM +0300, Jarkko Sakkinen wrote:
> > -   bin_file =
> > +   chip->bios_dir[cnt] =
> > securityfs_create_file("binary_bios_measurements",
> > -  S_IRUSR | S_IRGRP, tpm_dir,
> > +  S_IRUSR | S_IRGRP, chip->bios_dir[cnt],
> 
> That is certainly not right, Nayna's version was correct, the function
> argument is the directory to create under and bios_dir[0] is setup as the
> directory for tpm. This is also why removal is done in reverse order,
> files are removed then the directory that contains them.

Right. I overlooked this.

> Jason

/Jarkko


Re: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver

2016-10-01 Thread Dmitry Torokhov
On Sat, Oct 01, 2016 at 10:27:42AM -0700, Andrew Duggan wrote:
> 
> 
> On Fri, Sep 30, 2016, at 08:44 PM, Guenter Roeck wrote:
> > On 09/30/2016 04:02 PM, Dmitry Torokhov wrote:
> > > On Fri, Sep 30, 2016 at 03:54:03PM -0700, Dmitry Torokhov wrote:
> > >> On Thu, Sep 29, 2016 at 10:55:40AM -0700, Bjorn Andersson wrote:
> > >>> On Wed 28 Sep 17:37 PDT 2016, Guenter Roeck wrote:
> > >>>
> >  Instantiating the rmi4 I2C transport driver without interrupts assigned
> >  (for example using manual i2c instantiation from the command line)
> >  caused the driver to fail to load, but it does not clean up its
> >  regulator or transport device registrations. Result is a crash at a 
> >  later
> >  time, for example when rebooting the system.
> > 
> >  Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator 
> >  supplies")
> > >>>
> > >>> Sorry for that.
> > >>>
> >  Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport 
> >  driver")
> >  Cc: Bjorn Andersson 
> > >>>
> > >>> Reviewed-by: Bjorn Andersson 
> > >>
> > >> Applied, thank you.
> > >
> > > I take it back. rmi_i2c_init_irq() uses devm* so this whole thing mixes
> > > up devm* and manual unregistering and unwind order is completely
> > > broken.
> > >
> > Oops ...
> > 
> > > 1. Why do we register interrupt from transport drivers and not make it
> > > part of rmi_register_transport_device()?
> 
> Not all RMI devices will have access to interrupts (ie HID and SMBus).
> The same goes for regulators. Here is a reference to a previous
> discussion regarding both:
> https://lkml.org/lkml/2016/5/9/1055

Yeah, I am wondering if we should not revisit this and have SMBus (and
possibly HID) actually provide us with an interrupt.

In the meantime we can just ignore interrupt value if it is set to 0.

> 
> > 
> > rmi_register_transport_device() doesn't take dev as parameter.
> > 
> > > 2. If we need to use some non-devm-ised resources we should use
> > > devm_add_action[_or_reset] to work these operations into devm stream.
> > 
> 
> Since the regulator functions have their own devm_ versions I would
> suggest switching to those functions to avoid dealing with
> unregistering. 

There is no devm* API for enabling regulators, just acquiring them.

Thanks,

-- 
Dmitry


Re: [PATCH] net: Use ns_capable_noaudit() when determining net sysctl permissions

2016-10-01 Thread Dmitry Torokhov
On Sat, Oct 01, 2016 at 03:25:04AM -0400, David Miller wrote:
> From: Dmitry Torokhov 
> Date: Fri, 30 Sep 2016 15:24:31 -0700
> 
> > From: Tyler Hicks 
> > 
> > The capability check should not be audited since it is only being used
> > to determine the inode permissions. A failed check does not indicate a
> > violation of security policy but, when an LSM is enabled, a denial audit
> > message was being generated.
> > 
> > The denial audit message caused confusion for some application authors
> > because root-running Go applications always triggered the denial. To
> > prevent this confusion, the capability check in net_ctl_permissions() is
> > switched to the noaudit variant.
> > 
> > BugLink: https://launchpad.net/bugs/1465724
> > 
> > Signed-off-by: Tyler Hicks 
> > Acked-by: Serge E. Hallyn 
> > Signed-off-by: James Morris 
> > [dtor: reapplied after e79c6a4fc923 ("net: make net namespace sysctls
> > belong to container's owner") accidentally reverted the change.]
> > Signed-off-by: Dmitry Torokhov 
> 
> Applied, but please be clear in the future what tree a patch
> is targetting, in this case 'net-next'.
> 
> You can indicate this in the Subject line "[PATCH net-next]".

Sorry, will do next time.

Thanks.

-- 
Dmitry


[PATCH 2/2] ipc/sem: Add hysteresis.

2016-10-01 Thread Manfred Spraul
sysv sem has two lock modes: One with per-semaphore locks, one lock mode
with a single global lock for the whole array.
When switching from the per-semaphore locks to the global lock, all
per-semaphore locks must be scanned for ongoing operations.

The patch adds a hysteresis for switching from the global lock to the
per semaphore locks. This reduces how often the per-semaphore locks
must be scanned.

Compared to the initial patch, this is a simplified solution:
Setting USE_GLOBAL_LOCK_HYSTERESIS to 1 restores the current behavior.

In theory, a workload with exactly 10 simple sops and then
one complex op now scales a bit worse, but this is pure theory:
If there is concurrency, the it won't be exactly 10:1:10:1:10:1:...
If there is no concurrency, then there is no need for scalability.

Signed-off-by: Manfred Spraul 
---
 include/linux/sem.h |  2 +-
 ipc/sem.c   | 87 ++---
 2 files changed, 63 insertions(+), 26 deletions(-)

diff --git a/include/linux/sem.h b/include/linux/sem.h
index d0efd6e..4fc222f 100644
--- a/include/linux/sem.h
+++ b/include/linux/sem.h
@@ -21,7 +21,7 @@ struct sem_array {
struct list_headlist_id;/* undo requests on this array 
*/
int sem_nsems;  /* no. of semaphores in array */
int complex_count;  /* pending complex operations */
-   boolcomplex_mode;   /* no parallel simple ops */
+   unsigned intuse_global_lock;/* >0: global lock required */
 };
 
 #ifdef CONFIG_SYSVIPC
diff --git a/ipc/sem.c b/ipc/sem.c
index d5f2710..0982c4d 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -161,22 +161,43 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void 
*it);
 #define SEMOPM_FAST64  /* ~ 372 bytes on stack */
 
 /*
+ * Switching from the mode suitable for simple ops
+ * to the mode for complex ops is costly. Therefore:
+ * use some hysteresis
+ */
+#define USE_GLOBAL_LOCK_HYSTERESIS 10
+
+/*
  * Locking:
  * a) global sem_lock() for read/write
  * sem_undo.id_next,
  * sem_array.complex_count,
- * sem_array.complex_mode
  * sem_array.pending{_alter,_const},
  * sem_array.sem_undo
  *
  * b) global or semaphore sem_lock() for read/write:
  * sem_array.sem_base[i].pending_{const,alter}:
- * sem_array.complex_mode (for read)
+ * sem_array.use_global_lock(for read)
  *
  * c) special:
  * sem_undo_list.list_proc:
  * * undo_list->lock for write
  * * rcu for read
+ * use_global_lock:
+ * * global sem_lock() for write
+ * * either local or global sem_lock() for read.
+ *
+ * Memory ordering:
+ * Most ordering is enforced by using spin_lock() and spin_unlock().
+ * The special case is use_global_lock:
+ * Setting it from non-zero to 0 is a RELEASE, this is ensured by
+ * using smp_store_release().
+ * Testing if it is non-zero is an ACQUIRE, this is ensured by using
+ * smp_load_acquire().
+ * Setting it from 0 to non-zero must be ordered with regards to
+ * this smp_load_acquire(), this is guaranteed because the smp_load_acquire()
+ * is inside a spin_lock() and after a write from 0 to non-zero a
+ * spin_lock()+spin_unlock() is done.
  */
 
 #define sc_semmsl  sem_ctls[0]
@@ -275,12 +296,16 @@ static void complexmode_enter(struct sem_array *sma)
int i;
struct sem *sem;
 
-   if (sma->complex_mode)  {
-   /* We are already in complex_mode. Nothing to do */
+   if (sma->use_global_lock > 0)  {
+   /*
+* We are already in global lock mode.
+* Nothing to do, just reset the
+* counter until we return to simple mode.
+*/
+   sma->use_global_lock = USE_GLOBAL_LOCK_HYSTERESIS;
return;
}
-
-   sma->complex_mode = true;
+   sma->use_global_lock = USE_GLOBAL_LOCK_HYSTERESIS;
 
for (i = 0; i < sma->sem_nsems; i++) {
sem = sma->sem_base + i;
@@ -301,13 +326,17 @@ static void complexmode_tryleave(struct sem_array *sma)
 */
return;
}
-   /*
-* Immediately after setting complex_mode to false,
-* a simple op can start. Thus: all memory writes
-* performed by the current operation must be visible
-* before we set complex_mode to false.
-*/
-   smp_store_release(&sma->complex_mode, false);
+   if (sma->use_global_lock == 1) {
+   /*
+* Immediately after setting use_global_lock to 0,
+* a simple op can start. Thus: all memory writes
+* performed by the current operation must be visible
+* before we set use_global_lock to 0.
+*/
+   smp_store_release(&sma->use_global_lock, 0);
+   } else {
+   sma->use_global_lock--;
+   }
 }
 
 #define SEM_GLOBAL_LOCK(-1)
@@ -337,22 +366,23

[PATCH 1/2] ipc/sem.c: Avoid using spin_unlock_wait()

2016-10-01 Thread Manfred Spraul
a) The ACQUIRE in spin_lock() applies to the read, not to the store,
at least for powerpc. This forces to add a smp_mb() into the fast
path.

b) The memory barrier provided by spin_unlock_wait() is right now
arch dependent.

Therefore: Use spin_lock()/spin_unlock() instead of spin_unlock_wait().

Advantage: faster single op semop calls(), observed +8.9% on
x86. (the other solution would be arch dependencies in ipc/sem).

Disadvantage: slower complex op semop calls, if (and only if)
there are no sleeping operations.

The next patch adds hysteresis, this further reduces the
probability that the slow path is used.

Signed-off-by: Manfred Spraul 
---
 ipc/sem.c | 25 +++--
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/ipc/sem.c b/ipc/sem.c
index 5e318c5..d5f2710 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -280,24 +280,13 @@ static void complexmode_enter(struct sem_array *sma)
return;
}
 
-   /* We need a full barrier after seting complex_mode:
-* The write to complex_mode must be visible
-* before we read the first sem->lock spinlock state.
-*/
-   smp_store_mb(sma->complex_mode, true);
+   sma->complex_mode = true;
 
for (i = 0; i < sma->sem_nsems; i++) {
sem = sma->sem_base + i;
-   spin_unlock_wait(&sem->lock);
+   spin_lock(&sem->lock);
+   spin_unlock(&sem->lock);
}
-   /*
-* spin_unlock_wait() is not a memory barriers, it is only a
-* control barrier. The code must pair with spin_unlock(&sem->lock),
-* thus just the control barrier is insufficient.
-*
-* smp_rmb() is sufficient, as writes cannot pass the control barrier.
-*/
-   smp_rmb();
 }
 
 /*
@@ -363,14 +352,6 @@ static inline int sem_lock(struct sem_array *sma, struct 
sembuf *sops,
 */
spin_lock(&sem->lock);
 
-   /*
-* See 51d7d5205d33
-* ("powerpc: Add smp_mb() to arch_spin_is_locked()"):
-* A full barrier is required: the write of sem->lock
-* must be visible before the read is executed
-*/
-   smp_mb();
-
if (!smp_load_acquire(&sma->complex_mode)) {
/* fast path successful! */
return sops->sem_num;
-- 
2.7.4



[PATCH 0/2] ipc/sem.c: sem_lock fixes

2016-10-01 Thread Manfred Spraul
Hi Andrew, Hi Peter, Hi Davidlohr,

New idea for ipc/sem:
The ACQUIRE from spin_lock() will continue to apply only for the load,
not for the store.

Thus: If we don't want to add arch dependencies into ipc/sem, the only
safe option is to use spin_lock()/spin_unlock() instead of spin_unlock_wait().

Or we must stay with the current code, which is a ~9% regression.

Thus:
- Patch 1 replaces spin_unlock_wait() with spin_lock()/spin_unlock() and
  removes all memory barriers that are then unnecessary.

- Patch 2 adds the hysteresis code.

What do you think?

The patches passed stress-testing.

Andrew: Could you add it into mmots? Perhaps aiming for 4.10.

--
Manfred


Re: [PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Jes Sorensen
Joe Perches  writes:
> Make the init arrays const to reduce data.
>
> $ size drivers/net/wireless/realtek/rtl8xxxu/built-in.o* (allyesconfig: 
> x86-32)
>text  data bss dec hex filename
>   80107 13651  58   93816   16e78 
> drivers/net/wireless/realtek/rtl8xxxu/built-in.o.new
>   65303 28435  58   93796   16e64 
> drivers/net/wireless/realtek/rtl8xxxu/built-in.o.old
>
> Signed-off-by: Joe Perches 

In total you grow the kernel by 20 bytes. You reduce the data segment
substantially while growing the text segment instead.

If any architecture replicates the text segment onto individual numa
nodes, this would actually be a real loss rather than a win. Some archs
used to do this, not sure if they are doing it anymore.

I am not against this patch, but I am not sure it's really a win either.

Jes


[PATCH v2 6/6] arm: dts: imx7-colibri: Use enable-gpios for BL_ON

2016-10-01 Thread Bhuvanchandra DV
Use pwm-backlight driver 'enable-gpios' property for backlight on/off control.

Signed-off-by: Bhuvanchandra DV 
---
 arch/arm/boot/dts/imx7-colibri.dtsi | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx7-colibri.dtsi 
b/arch/arm/boot/dts/imx7-colibri.dtsi
index 2af5e3e..ce5edb5 100644
--- a/arch/arm/boot/dts/imx7-colibri.dtsi
+++ b/arch/arm/boot/dts/imx7-colibri.dtsi
@@ -43,7 +43,10 @@
 / {
bl: backlight {
compatible = "pwm-backlight";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_gpio_bl_on>;
pwms = <&pwm1 0 500 0>;
+   enable-gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
};
 
reg_module_3v3: regulator-module-3v3 {
@@ -356,7 +359,6 @@
fsl,pins = <
MX7D_PAD_ECSPI2_SS0__GPIO4_IO23 0x14 /* SODIMM 
65 */
MX7D_PAD_SD1_CD_B__GPIO5_IO00x14 /* SODIMM 
69 */
-   MX7D_PAD_SD1_WP__GPIO5_IO1  0x14 /* SODIMM 
71 */
MX7D_PAD_I2C4_SDA__GPIO4_IO15   0x14 /* SODIMM 
75 */
MX7D_PAD_ECSPI1_MISO__GPIO4_IO180x14 /* SODIMM 
79 */
MX7D_PAD_I2C3_SCL__GPIO4_IO12   0x14 /* SODIMM 
81 */
@@ -388,6 +390,12 @@
>;
};
 
+   pinctrl_gpio_bl_on: gpio-bl-on {
+   fsl,pins = <
+   MX7D_PAD_SD1_WP__GPIO5_IO1  0x14
+   >;
+   };
+
pinctrl_i2c1_int: i2c1-int-grp { /* PMIC / TOUCH */
fsl,pins = <
MX7D_PAD_GPIO1_IO13__GPIO1_IO13 0x79
-- 
2.9.2



Re: [RFC] arm64: Enforce observed order for spinlock and data

2016-10-01 Thread Mark Rutland
Hi Brent,

Evidently my questions weren't sufficiently clear; even with your answers it's
not clear to me what precise issue you're attempting to solve. I've tried to be
more specific this time.

At a high-level, can you clarify whether you're attempting to solve is:

(a) a functional correctness issue (e.g. data corruption) 
(b) a performance issue

And whether this was seen in practice, or found through code inspection?

On Sat, Oct 01, 2016 at 12:11:36PM -0400, bdegr...@codeaurora.org wrote:
> On 2016-09-30 15:32, Mark Rutland wrote:
> >On Fri, Sep 30, 2016 at 01:40:57PM -0400, Brent DeGraaf wrote:
> >>+* so LSE needs an explicit barrier here as well.  Without this, the
> >>+* changed contents of the area protected by the spinlock could be
> >>+* observed prior to the lock.
> >>+*/
> >
> >By whom? We generally expect that if data is protected by a lock, you take
> >the lock before accessing it. If you expect concurrent lockless readers,
> >then there's a requirement on the writer side to explicitly provide the
> >ordering it requires -- spinlocks are not expected to provide that.
>
> More details are in my response to Robin, but there is an API arm64 supports
> in spinlock.h which is used by lockref to determine whether a lock is free or
> not.  For that code to work properly without adding these barriers, that API
> needs to take the lock.

Can you please provide a concrete example of a case where things go wrong,
citing the code (or access pattern) in question? e.g. as in the commit messages
for:

  8e86f0b409a44193 ("arm64: atomics: fix use of acquire + release for full 
barrier semantics)
  859b7a0e89120505 ("mm/slub: fix lockups on PREEMPT && !SMP kernels")

(for the latter, I messed up the register -> var mapping in one paragraph, but
the style and reasoning is otherwise sound).

In the absence of a concrete example as above, it's very difficult to reason
about what the underlying issue is, and what a valid fix would be for said
issue.

> >What pattern of accesses are made by readers and writers such that there is
> >a problem?

Please note here I was asking specifically w.r.t. the lockref code, e.g. which
loads could see stale data, and what does the code do based on this value such
that there is a problem.

> I added the barriers to the readers/writers because I do not know these are
> not similarly abused.  There is a lot of driver code out there, and ensuring
> order is the safest way to be sure we don't get burned by something similar
> to the lockref access.

Making the architecture-provided primitives overly strong harms performance and
efficiency (in general), makes the code harder to maintain and optimise in
future, and only masks the issue (which could crop up on other architectures,
for instance).

Thanks,
Mark.


Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Paul E. McKenney
On Sat, Oct 01, 2016 at 01:05:08PM -0400, Rich Felker wrote:
> On Fri, Sep 30, 2016 at 06:48:35AM -0700, Paul E. McKenney wrote:
> > On Fri, Sep 30, 2016 at 03:15:11PM +0200, Thomas Gleixner wrote:
> > > On Tue, 27 Sep 2016, Rich Felker wrote:
> > > > I've managed to get a trace with a stall. I'm not sure what the best
> > > > way to share the full thing is, since it's large, but here are the
> > > > potentially interesting parts.
> > 
> > [ . . . ]
> > 
> > Some RCU commentary, on the off-chance that it helps...
> > 
> > > So that should kick rcu_sched-7 in 10ms, latest 20ms from now and CPU1 
> > > goes
> > > into a NOHZ idle sleep.
> > > 
> > > >   -0 [001] d...   109.953436: tick_stop: success=1 
> > > > dependency=NONE
> > > >   -0 [001] d...   109.953617: hrtimer_cancel: 
> > > > hrtimer=109f449c
> > > >   -0 [001] d...   109.953818: hrtimer_start: 
> > > > hrtimer=109f449c function=tick_sched_timer expires=10988000 
> > > > softexpires=10988000
> > > 
> > > which is (using the 0.087621us delta between the trace clock and clock
> > > MONO) at: 109.880 + 0.087621 = 109.968
> > > 
> > > Which is about correct as we expect the RCU timer to fire at:
> > >   
> > >   109.952633 + 0.01 = 109.963633
> > > 
> > > or latest at
> > > 
> > >   109.952633 + 0.02 = 109.983633
> > >
> > > There is another caveat. That nohz stuff can queue the rcu timer on CPU0, 
> > > which
> > > it did not because:
> > 
> > Just for annoying completeness, the location of the timer depends on how
> > the rcuo callback-offload kthreads are constrained.  And yes, in the most
> > constrained case where all CPUs except for CPU 0 are nohz CPUs, they will
> > by default all run on CPU 0.
> 
> In default full nohz configuration, am I correct that all cpus except
> cpu0 willd be nohz and that the rcu callbacks then have to run on
> cpu0?

In recent kernels, it looks to me that the default is that none of the
CPUs will be nohz by default.  You have to build with both NO_HZ_FULL
and NO_HZ_FULL_ALL to get the everything-on-CPU-0 behavior.

But are there rcu0 kthreads running on your system?

> > > >rcu_sched-7 [001] d...   109.952633: timer_start: 
> > > > timer=160a9eb0 function=process_timeout expires=4294948284 [timeout=1] 
> > > > flags=0x0001
> > > 
> > > The CPU nr encoded in flags is: 1
> > > 
> > > Now we cancel and restart the timer w/o seing the interrupt expiring
> > > it. And that expiry should have happened at 109.968000 !?!
> > > 
> > > >   -0 [001] d...   109.968225: hrtimer_cancel: 
> > > > hrtimer=109f449c
> > > >   -0 [001] d...   109.968526: hrtimer_start: 
> > > > hrtimer=109f449c function=tick_sched_timer expires=10989000 
> > > > softexpires=10989000
> > > 
> > > So this advances the next tick even further out. And CPU 0 sets the timer 
> > > to
> > > the exact smae value:
> > > 
> > > >   -0 [000] d.h.   109.969104: hrtimer_start: 
> > > > hrtimer=109e949c function=tick_sched_timer expires=10989000 
> > > > softexpires=10989000
> > > 
> > > 
> > > >   -0 [000] d.h.   109.977690: irq_handler_entry: 
> > > > irq=16 name=jcore_pit
> > > >   -0 [000] d.h.   109.977911: hrtimer_cancel: 
> > > > hrtimer=109e949c
> > > >   -0 [000] d.h.   109.978053: hrtimer_expire_entry: 
> > > > hrtimer=109e949c function=tick_sched_timer now=109890434160
> > > 
> > > Which expires here. And CPU1 instead of getting an interrupt and expiring
> > > the timer does the cancel/restart to the next jiffie again:
> > > 
> > > >   -0 [001] d...   109.978206: hrtimer_cancel: 
> > > > hrtimer=109f449c
> > > >   -0 [001] d...   109.978495: hrtimer_start: 
> > > > hrtimer=109f449c function=tick_sched_timer expires=1099 
> > > > softexpires=1099
> > > 
> > > And this repeats;
> > > 
> > > >   -0 [000] d.h.   109.987726: irq_handler_entry: 
> > > > irq=16 name=jcore_pit
> > > >   -0 [000] d.h.   109.987954: hrtimer_cancel: 
> > > > hrtimer=109e949c
> > > >   -0 [000] d.h.   109.988095: hrtimer_expire_entry: 
> > > > hrtimer=109e949c function=tick_sched_timer now=109900474620
> > > 
> > > >   -0 [001] d...   109.988243: hrtimer_cancel: 
> > > > hrtimer=109f449c
> > > >   -0 [001] d...   109.988537: hrtimer_start: 
> > > > hrtimer=109f449c fun9c
> > > 
> > > There is something badly wrong here.
> > > 
> > > >   -0 [000] ..s.   110.019443: softirq_entry: vec=1 
> > > > [action=TIMER]
> > > >   -0 [000] ..s.   110.019617: softirq_exit: vec=1 
> > > > [action=TIMER]
> > > >   -0 [000] ..s.   110.019730: softirq_entry: vec=7 
> > > > [action=SCHED]
> > > >   -0 [000] ..s.   110.020174: softirq_exit: vec=7 
> > > > [action=SCHED]
> > > >   -0 [000] d.h.   110.027674: irq_handler_entry: 
> > > > irq=16 name=jcore_pit
> > > > 
> > > > The rcu_sche

Re: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver

2016-10-01 Thread Andrew Duggan


On Sat, Oct 1, 2016, at 10:45 AM, Guenter Roeck wrote:
> On 10/01/2016 10:27 AM, Andrew Duggan wrote:
> >
> >
> > On Fri, Sep 30, 2016, at 08:44 PM, Guenter Roeck wrote:
> >> On 09/30/2016 04:02 PM, Dmitry Torokhov wrote:
> >>> On Fri, Sep 30, 2016 at 03:54:03PM -0700, Dmitry Torokhov wrote:
>  On Thu, Sep 29, 2016 at 10:55:40AM -0700, Bjorn Andersson wrote:
> > On Wed 28 Sep 17:37 PDT 2016, Guenter Roeck wrote:
> >
> >> Instantiating the rmi4 I2C transport driver without interrupts assigned
> >> (for example using manual i2c instantiation from the command line)
> >> caused the driver to fail to load, but it does not clean up its
> >> regulator or transport device registrations. Result is a crash at a 
> >> later
> >> time, for example when rebooting the system.
> >>
> >> Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator 
> >> supplies")
> >
> > Sorry for that.
> >
> >> Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport 
> >> driver")
> >> Cc: Bjorn Andersson 
> >
> > Reviewed-by: Bjorn Andersson 
> 
>  Applied, thank you.
> >>>
> >>> I take it back. rmi_i2c_init_irq() uses devm* so this whole thing mixes
> >>> up devm* and manual unregistering and unwind order is completely
> >>> broken.
> >>>
> >> Oops ...
> >>
> >>> 1. Why do we register interrupt from transport drivers and not make it
> >>> part of rmi_register_transport_device()?
> >
> > Not all RMI devices will have access to interrupts (ie HID and SMBus).
> > The same goes for regulators. Here is a reference to a previous
> > discussion regarding both:
> > https://lkml.org/lkml/2016/5/9/1055
> >
> >>
> >> rmi_register_transport_device() doesn't take dev as parameter.
> >>
> >>> 2. If we need to use some non-devm-ised resources we should use
> >>> devm_add_action[_or_reset] to work these operations into devm stream.
> >>
> >
> > Since the regulator functions have their own devm_ versions I would
> > suggest switching to those functions to avoid dealing with
> > unregistering.
> >
> Maybe I am missing something, but I don't see a
> devm_regulator_bulk_enable().
> devm_regulator_bulk_get() is already used.
> 

Yeah, I was just double checking that too. You're right, they are
already using the devm version.

Andrew

> Guenter
> 
> > Registering and unregistering the transport device is a bit more
> > complicated since these functions add and put the rmi_dev device. But,
> > it sounds like we can handle the unregister using
> > devm_add_action_or_reset().
> >


Re: 4.7 regression: ACPI: No IRQ available for PCI Interrupt Link [LNKD]. Try pci=noacpi or acpi=off

2016-10-01 Thread Sinan Kaya
On 9/30/2016 5:27 PM, Rafael J. Wysocki wrote:
>>> >> What's the drawback, if any?
>> >
>> > I don't see any drawback to be honest.
> I'd go for it then, if Bjorn doesn't hate it.
> 

I posted a follow up patch a minute ago. 

[PATCH 1/3] Revert "ACPI,PCI,IRQ: reduce static IRQ array size to 16"
[PATCH 2/3] ACPI, PCI IRQ: add PCI_USING penalty for ISA interrupts
[PATCH 3/3] Revert "ACPI,PCI,IRQ: remove SCI penalize function"

Can we have some testing coverage? and eventually have tested-by?

-- 
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux 
Foundation Collaborative Project.


[PATCH 3/3] Revert "ACPI,PCI,IRQ: remove SCI penalize function"

2016-10-01 Thread Sinan Kaya
This reverts commit 9e5ed6d1fb87 ("ACPI,PCI,IRQ: remove SCI penalize
function"). SCI penalty API was replaced by the runtime penalty calculation
based on the value of acpi_gbl_FADT.sci_interrupt.

acpi_gbl_FADT.sci_interrupt type does not get updated at the right time
for some platforms and results in incorrect penalty assignment for PCI
IRQs as irq_get_trigger_type returns the wrong type.

Link: http://www.spinics.net/lists/linux-pci/msg54599.html
Signed-off-by: Sinan Kaya 
---
 arch/x86/kernel/acpi/boot.c |  1 +
 drivers/acpi/pci_link.c | 34 ++
 include/linux/acpi.h|  1 +
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 90d84c3..0ffd26e 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -453,6 +453,7 @@ static void __init acpi_sci_ioapic_setup(u8 bus_irq, u16 
polarity, u16 trigger,
polarity = acpi_sci_flags & ACPI_MADT_POLARITY_MASK;
 
mp_override_legacy_irq(bus_irq, polarity, trigger, gsi);
+   acpi_penalize_sci_irq(bus_irq, trigger, polarity);
 
/*
 * stash over-ride to indicate we've been here
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 06c2a11..6a2af19 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -495,27 +495,10 @@ static int acpi_irq_pci_sharing_penalty(int irq)
 
 static int acpi_irq_get_penalty(int irq)
 {
-   int penalty = 0;
-
-   /*
-   * Penalize IRQ used by ACPI SCI. If ACPI SCI pin attributes conflict
-   * with PCI IRQ attributes, mark ACPI SCI as ISA_ALWAYS so it won't be
-   * use for PCI IRQs.
-   */
-   if (irq == acpi_gbl_FADT.sci_interrupt) {
-   u32 type = irq_get_trigger_type(irq) & IRQ_TYPE_SENSE_MASK;
-
-   if (type != IRQ_TYPE_LEVEL_LOW)
-   penalty += PIRQ_PENALTY_ISA_ALWAYS;
-   else
-   penalty += PIRQ_PENALTY_PCI_USING;
-   }
-
-   if (irq < ACPI_MAX_ISA_IRQS)
-   return penalty + acpi_irq_penalty[irq];
+   if (irq < ACPI_MAX_IRQS)
+   return acpi_irq_penalty[irq];
 
-   penalty += acpi_irq_pci_sharing_penalty(irq);
-   return penalty;
+   return acpi_irq_pci_sharing_penalty(irq);
 }
 
 int __init acpi_irq_penalty_init(void)
@@ -886,6 +869,17 @@ bool acpi_isa_irq_available(int irq)
acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
 }
 
+void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
+{
+   if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
+   if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
+   polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+   acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS;
+   else
+   acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+   }
+}
+
 /*
  * Over-ride default table to reserve additional IRQs for use by ISA
  * e.g. acpi_irq_isa=5
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 4d8452c..85ac7d5 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -318,6 +318,7 @@ struct pci_dev;
 int acpi_pci_irq_enable (struct pci_dev *dev);
 void acpi_penalize_isa_irq(int irq, int active);
 bool acpi_isa_irq_available(int irq);
+void acpi_penalize_sci_irq(int irq, int trigger, int polarity);
 void acpi_pci_irq_disable (struct pci_dev *dev);
 
 extern int ec_read(u8 addr, u8 *val);
-- 
1.9.1



[PATCH 1/3] Revert "ACPI,PCI,IRQ: reduce static IRQ array size to 16"

2016-10-01 Thread Sinan Kaya
This reverts commit 5c5087a55390 ("ACPI,PCI,IRQ: reduce static IRQ array
size to 16").

The code maintains a fixed size array for IRQ penalties. The array
gets updated by external calls such as acpi_penalize_sci_irq,
acpi_penalize_isa_irq to reflect the actual interrupt usage of the
system. Since the IRQ distribution is platform specific, this is
not known ahead of time. The IRQs get updated based on the SCI
interrupt number BIOS has chosen or the ISA IRQs that were assigned
to existing peripherals.

By the time ACPI gets initialized, this code tries to determine an
IRQ number based on penalty values in this array. It will try to locate
the IRQ with the least penalty assignment so that interrupt sharing is
avoided if possible.

A couple of notes about the external APIs:
1. These API can be called before the ACPI is started. Therefore, one
cannot assume that the PCI link objects are initialized for calculating
penalties.
2. The polarity and trigger information passed via the
acpi_penalize_sci_irq from the BIOS may not match what the IRQ subsystem
is reporting as the call might have been placed before the IRQ is
registered by the interrupt subsystem.

The previous change was in the direction to remove these external API and
try to calculate the penalties at runtime for the ISA path as well. This
didn't work out well with the existing platforms.

Restoring the old behavior for IRQ < 256 and the new behavior will remain
effective for IRQ >= 256.

Link: http://www.spinics.net/lists/linux-pci/msg54599.html
Signed-off-by: Sinan Kaya 
---
 drivers/acpi/pci_link.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index c983bf7..f3792f4 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -438,6 +438,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, 
int irq)
  * enabled system.
  */
 
+#define ACPI_MAX_IRQS  256
 #define ACPI_MAX_ISA_IRQS  16
 
 #define PIRQ_PENALTY_PCI_POSSIBLE  (16*16)
@@ -446,7 +447,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, 
int irq)
 #define PIRQ_PENALTY_ISA_USED  (16*16*16*16*16)
 #define PIRQ_PENALTY_ISA_ALWAYS(16*16*16*16*16*16)
 
-static int acpi_isa_irq_penalty[ACPI_MAX_ISA_IRQS] = {
+static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
PIRQ_PENALTY_ISA_ALWAYS,/* IRQ0 timer */
PIRQ_PENALTY_ISA_ALWAYS,/* IRQ1 keyboard */
PIRQ_PENALTY_ISA_ALWAYS,/* IRQ2 cascade */
@@ -511,7 +512,7 @@ static int acpi_irq_get_penalty(int irq)
}
 
if (irq < ACPI_MAX_ISA_IRQS)
-   return penalty + acpi_isa_irq_penalty[irq];
+   return penalty + acpi_irq_penalty[irq];
 
penalty += acpi_irq_pci_sharing_penalty(irq);
return penalty;
@@ -538,14 +539,14 @@ int __init acpi_irq_penalty_init(void)
 
for (i = 0; i < link->irq.possible_count; i++) {
if (link->irq.possible[i] < ACPI_MAX_ISA_IRQS)
-   acpi_isa_irq_penalty[link->irq.
+   acpi_irq_penalty[link->irq.
 possible[i]] +=
penalty;
}
 
} else if (link->irq.active &&
-   (link->irq.active < ACPI_MAX_ISA_IRQS)) {
-   acpi_isa_irq_penalty[link->irq.active] +=
+   (link->irq.active < ACPI_MAX_IRQS)) {
+   acpi_irq_penalty[link->irq.active] +=
PIRQ_PENALTY_PCI_POSSIBLE;
}
}
@@ -828,7 +829,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
 }
 
 /*
- * modify acpi_isa_irq_penalty[] from cmdline
+ * modify acpi_irq_penalty[] from cmdline
  */
 static int __init acpi_irq_penalty_update(char *str, int used)
 {
@@ -837,24 +838,24 @@ static int __init acpi_irq_penalty_update(char *str, int 
used)
for (i = 0; i < 16; i++) {
int retval;
int irq;
-   int new_penalty;
 
retval = get_option(&str, &irq);
 
if (!retval)
break;  /* no number found */
 
-   /* see if this is a ISA IRQ */
-   if ((irq < 0) || (irq >= ACPI_MAX_ISA_IRQS))
+   if (irq < 0)
+   continue;
+
+   if (irq >= ARRAY_SIZE(acpi_irq_penalty))
continue;
 
if (used)
-   new_penalty = acpi_irq_get_penalty(irq) +
-   PIRQ_PENALTY_ISA_USED;
+   acpi_irq_penalty[irq] = acpi_irq_get_penalty(irq) +
+   PIRQ_PENALTY_ISA_USED;
else
-   new_penalty = 0;
+ 

[PATCH 2/3] ACPI, PCI IRQ: add PCI_USING penalty for ISA interrupts

2016-10-01 Thread Sinan Kaya
The change introduced in commit 103544d86976 ("ACPI,PCI,IRQ: reduce
resource requirements") removed PCI_USING penalty from
acpi_pci_link_allocate function as there is no longer a fixed size penalty
array for both PCI and IRQ interrupts.

We need to add the PCI_USING penalty for ISA interrupts too if the link is
in use and matches our ISA IRQ number.

Signed-off-by: Sinan Kaya 
---
 drivers/acpi/pci_link.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index f3792f4..06c2a11 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -620,6 +620,10 @@ static int acpi_pci_link_allocate(struct acpi_pci_link 
*link)
acpi_device_bid(link->device));
return -ENODEV;
} else {
+   if (link->irq.active < ACPI_MAX_IRQS)
+   acpi_irq_penalty[link->irq.active] +=
+   PIRQ_PENALTY_PCI_USING;
+
printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
   acpi_device_name(link->device),
   acpi_device_bid(link->device), link->irq.active);
-- 
1.9.1



Re: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver

2016-10-01 Thread Guenter Roeck

On 10/01/2016 10:27 AM, Andrew Duggan wrote:



On Fri, Sep 30, 2016, at 08:44 PM, Guenter Roeck wrote:

On 09/30/2016 04:02 PM, Dmitry Torokhov wrote:

On Fri, Sep 30, 2016 at 03:54:03PM -0700, Dmitry Torokhov wrote:

On Thu, Sep 29, 2016 at 10:55:40AM -0700, Bjorn Andersson wrote:

On Wed 28 Sep 17:37 PDT 2016, Guenter Roeck wrote:


Instantiating the rmi4 I2C transport driver without interrupts assigned
(for example using manual i2c instantiation from the command line)
caused the driver to fail to load, but it does not clean up its
regulator or transport device registrations. Result is a crash at a later
time, for example when rebooting the system.

Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator supplies")


Sorry for that.


Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport driver")
Cc: Bjorn Andersson 


Reviewed-by: Bjorn Andersson 


Applied, thank you.


I take it back. rmi_i2c_init_irq() uses devm* so this whole thing mixes
up devm* and manual unregistering and unwind order is completely
broken.


Oops ...


1. Why do we register interrupt from transport drivers and not make it
part of rmi_register_transport_device()?


Not all RMI devices will have access to interrupts (ie HID and SMBus).
The same goes for regulators. Here is a reference to a previous
discussion regarding both:
https://lkml.org/lkml/2016/5/9/1055



rmi_register_transport_device() doesn't take dev as parameter.


2. If we need to use some non-devm-ised resources we should use
devm_add_action[_or_reset] to work these operations into devm stream.




Since the regulator functions have their own devm_ versions I would
suggest switching to those functions to avoid dealing with
unregistering.


Maybe I am missing something, but I don't see a devm_regulator_bulk_enable().
devm_regulator_bulk_get() is already used.

Guenter


Registering and unregistering the transport device is a bit more
complicated since these functions add and put the rmi_dev device. But,
it sounds like we can handle the unregister using
devm_add_action_or_reset().



[PATCH] realtek: rtl8xxxu: Use const init arrays

2016-10-01 Thread Joe Perches
Make the init arrays const to reduce data.

$ size drivers/net/wireless/realtek/rtl8xxxu/built-in.o* (allyesconfig: x86-32)
   textdata bss dec hex filename
  80107   13651  58   93816   16e78 
drivers/net/wireless/realtek/rtl8xxxu/built-in.o.new
  65303   28435  58   93796   16e64 
drivers/net/wireless/realtek/rtl8xxxu/built-in.o.old

Signed-off-by: Joe Perches 
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h   |  6 +++---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c |  8 
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c |  6 +++---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c  | 16 
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index 1016628926d2..bd4449704dfa 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -1355,7 +1355,7 @@ struct rtl8xxxu_fileops {
u16 trxff_boundary;
u8 pbp_rx;
u8 pbp_tx;
-   struct rtl8xxxu_reg8val *mactable;
+   const struct rtl8xxxu_reg8val *mactable;
u8 total_page_num;
u8 page_num_hi;
u8 page_num_lo;
@@ -1364,7 +1364,7 @@ struct rtl8xxxu_fileops {
 
 extern int rtl8xxxu_debug;
 
-extern struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table[];
+extern const struct rtl8xxxu_reg8val rtl8xxxu_gen1_mac_init_table[];
 extern const u32 rtl8xxxu_iqk_phy_iq_bb_reg[];
 u8 rtl8xxxu_read8(struct rtl8xxxu_priv *priv, u16 addr);
 u16 rtl8xxxu_read16(struct rtl8xxxu_priv *priv, u16 addr);
@@ -1396,7 +1396,7 @@ int rtl8xxxu_init_phy_rf(struct rtl8xxxu_priv *priv,
 struct rtl8xxxu_rfregval *table,
 enum rtl8xxxu_rfpath path);
 int rtl8xxxu_init_phy_regs(struct rtl8xxxu_priv *priv,
-  struct rtl8xxxu_reg32val *array);
+  const struct rtl8xxxu_reg32val *array);
 int rtl8xxxu_load_firmware(struct rtl8xxxu_priv *priv, char *fw_name);
 void rtl8xxxu_firmware_self_reset(struct rtl8xxxu_priv *priv);
 void rtl8xxxu_power_off(struct rtl8xxxu_priv *priv);
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index df54d27e7851..934a380f09b1 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -40,7 +40,7 @@
 #include "rtl8xxxu.h"
 #include "rtl8xxxu_regs.h"
 
-static struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = {
+static const struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = {
{0x011, 0xeb}, {0x012, 0x07}, {0x014, 0x75}, {0x303, 0xa7},
{0x428, 0x0a}, {0x429, 0x10}, {0x430, 0x00}, {0x431, 0x00},
{0x432, 0x00}, {0x433, 0x01}, {0x434, 0x04}, {0x435, 0x05},
@@ -70,7 +70,7 @@ static struct rtl8xxxu_reg8val rtl8192e_mac_init_table[] = {
{0x, 0xff},
 };
 
-static struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] = {
+static const struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] = {
{0x800, 0x8004}, {0x804, 0x0003},
{0x808, 0xfc00}, {0x80c, 0x000a},
{0x810, 0x10001331}, {0x814, 0x020c3d10},
@@ -202,7 +202,7 @@ static struct rtl8xxxu_reg32val rtl8192eu_phy_init_table[] 
= {
{0x, 0x},
 };
 
-static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_std_table[] = {
+static const struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_std_table[] = {
{0xc78, 0xfb01}, {0xc78, 0xfb010001},
{0xc78, 0xfb020001}, {0xc78, 0xfb030001},
{0xc78, 0xfb040001}, {0xc78, 0xfb050001},
@@ -271,7 +271,7 @@ static struct rtl8xxxu_reg32val 
rtl8xxx_agc_8192eu_std_table[] = {
{0x, 0x}
 };
 
-static struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_highpa_table[] = {
+static const struct rtl8xxxu_reg32val rtl8xxx_agc_8192eu_highpa_table[] = {
{0xc78, 0xfa01}, {0xc78, 0xf9010001},
{0xc78, 0xf8020001}, {0xc78, 0xf7030001},
{0xc78, 0xf6040001}, {0xc78, 0xf5050001},
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index 6c086b5657e9..3f173b67fc0d 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -40,7 +40,7 @@
 #include "rtl8xxxu.h"
 #include "rtl8xxxu_regs.h"
 
-static struct rtl8xxxu_reg8val rtl8723b_mac_init_table[] = {
+static const struct rtl8xxxu_reg8val rtl8723b_mac_init_table[] = {
{0x02f, 0x30}, {0x035, 0x00}, {0x039, 0x08}, {0x04e, 0xe0},
{0x064, 0x00}, {0x067, 0x20}, {0x428, 0x0a}, {0x429, 0x10},
{0x430, 0x00}, {0x431, 0x00},
@@ -71,7 +71,7 @@ static struct rtl8xxxu_reg8val rtl8723b_mac_init_table[] = {
{0x, 0xff},
 };
 
-static struct rtl8xxxu_reg32val rtl8723b_phy_1t_init_table[] = {
+static const struct rtl8x

Re: [PATCH 0/4] ARM: davinci: Remove DMA resources for MMC/SPI

2016-10-01 Thread Sekhar Nori
On Wednesday 28 September 2016 04:05 PM, Peter Ujfalusi wrote:
> Hi,
> 
> The drivers for davinci MMC and SPI have been converted to the new DMAengine 
> API
> and no longer rely on the IORESOURCE_DMA.
> This is the case for at least one release cycle so now we can remove the
> IORESOURCE_DMA for these devices.

Hi Peter, applied to v4.10/cleanup branch of my tree. Thanks!

~Sekhar


Re: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver

2016-10-01 Thread Andrew Duggan


On Fri, Sep 30, 2016, at 08:44 PM, Guenter Roeck wrote:
> On 09/30/2016 04:02 PM, Dmitry Torokhov wrote:
> > On Fri, Sep 30, 2016 at 03:54:03PM -0700, Dmitry Torokhov wrote:
> >> On Thu, Sep 29, 2016 at 10:55:40AM -0700, Bjorn Andersson wrote:
> >>> On Wed 28 Sep 17:37 PDT 2016, Guenter Roeck wrote:
> >>>
>  Instantiating the rmi4 I2C transport driver without interrupts assigned
>  (for example using manual i2c instantiation from the command line)
>  caused the driver to fail to load, but it does not clean up its
>  regulator or transport device registrations. Result is a crash at a later
>  time, for example when rebooting the system.
> 
>  Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator 
>  supplies")
> >>>
> >>> Sorry for that.
> >>>
>  Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport driver")
>  Cc: Bjorn Andersson 
> >>>
> >>> Reviewed-by: Bjorn Andersson 
> >>
> >> Applied, thank you.
> >
> > I take it back. rmi_i2c_init_irq() uses devm* so this whole thing mixes
> > up devm* and manual unregistering and unwind order is completely
> > broken.
> >
> Oops ...
> 
> > 1. Why do we register interrupt from transport drivers and not make it
> > part of rmi_register_transport_device()?

Not all RMI devices will have access to interrupts (ie HID and SMBus).
The same goes for regulators. Here is a reference to a previous
discussion regarding both:
https://lkml.org/lkml/2016/5/9/1055

> 
> rmi_register_transport_device() doesn't take dev as parameter.
> 
> > 2. If we need to use some non-devm-ised resources we should use
> > devm_add_action[_or_reset] to work these operations into devm stream.
> 

Since the regulator functions have their own devm_ versions I would
suggest switching to those functions to avoid dealing with
unregistering. 

Registering and unregistering the transport device is a bit more
complicated since these functions add and put the rmi_dev device. But,
it sounds like we can handle the unregister using
devm_add_action_or_reset().

Andrew 

> Ok, no problem.
> 
> Guenter
> 
> >
> > Thanks,
> >
> >>
> >> It looks like we have similar issue in rmi_spi.c. Can I get another
> >> patch?
> >>
> >>>
> >>> Regards,
> >>> Bjorn
> >>>
>  Cc: Andrew Duggan 
>  Signed-off-by: Guenter Roeck 
>  ---
>   drivers/input/rmi4/rmi_i2c.c | 13 ++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
> 
>  diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
>  index 6f2e0e4f0296..d57b227ccd25 100644
>  --- a/drivers/input/rmi4/rmi_i2c.c
>  +++ b/drivers/input/rmi4/rmi_i2c.c
>  @@ -285,23 +285,30 @@ static int rmi_i2c_probe(struct i2c_client *client,
>   retval = rmi_set_page(rmi_i2c, 0);
>   if (retval) {
>   dev_err(&client->dev, "Failed to set page select to 
>  0.\n");
>  -return retval;
>  +goto error_disable;
>   }
> 
>   retval = rmi_register_transport_device(&rmi_i2c->xport);
>   if (retval) {
>   dev_err(&client->dev, "Failed to register transport 
>  driver at 0x%.2X.\n",
>   client->addr);
>  -return retval;
>  +goto error_disable;
>   }
> 
>   retval = rmi_i2c_init_irq(client);
>   if (retval < 0)
>  -return retval;
>  +goto error_unregister;
> 
>   dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n",
>   client->addr);
>   return 0;
>  +
>  +error_unregister:
>  +rmi_unregister_transport_device(&rmi_i2c->xport);
>  +error_disable:
>  +regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies),
>  +   rmi_i2c->supplies);
>  +return retval;
>   }
> 
>   static int rmi_i2c_remove(struct i2c_client *client)
>  --
>  2.5.0
> 
> >>
> >> --
> >> Dmitry
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fs: btrfs: Use ktime_get_real_ts for root ctime

2016-10-01 Thread Deepa Dinamani
btrfs_root_item maintains the ctime for root updates.
This is not part of vfs_inode.

Since current_time() uses struct inode* as an argument
as Linus suggested, this cannot be used to update root
times unless, we modify the signature to use inode.

Since btrfs uses nanosecond time granularity, it can also
use ktime_get_real_ts directly to obtain timestamp for
the root. It is necessary to use the timespec time api
here because the same btrfs_set_stack_timespec_*() apis
are used for vfs inode times as well. These can be
transitioned to using timespec64 when btrfs internally
changes to use timespec64 as well.

Signed-off-by: Deepa Dinamani 
Cc: Chris Mason 
Cc: David Sterba 
Cc: Josef Bacik 
Cc: linux-bt...@vger.kernel.org
---
Changes from previous version:
* Separated from the current_time() api series.
* Moved ktime_get_real_ts() outside of spin lock.

fs/btrfs/root-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index 0912960..17e5a5f 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -505,8 +505,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle 
*trans,
 struct btrfs_root *root)
 {
struct btrfs_root_item *item = &root->root_item;
-   struct timespec ct = current_fs_time(root->fs_info->sb);
+   struct timespec ct;
 
+   ktime_get_real_ts(&ct);
spin_lock(&root->root_item_lock);
btrfs_set_root_ctransid(item, trans->transid);
btrfs_set_stack_timespec_sec(&item->ctime, ct.tv_sec);
-- 
2.7.4



Re: [PATCH v7 2/2] clocksource: add J-Core timer/clocksource driver

2016-10-01 Thread Rich Felker
On Fri, Sep 30, 2016 at 06:48:35AM -0700, Paul E. McKenney wrote:
> On Fri, Sep 30, 2016 at 03:15:11PM +0200, Thomas Gleixner wrote:
> > On Tue, 27 Sep 2016, Rich Felker wrote:
> > > I've managed to get a trace with a stall. I'm not sure what the best
> > > way to share the full thing is, since it's large, but here are the
> > > potentially interesting parts.
> 
> [ . . . ]
> 
> Some RCU commentary, on the off-chance that it helps...
> 
> > So that should kick rcu_sched-7 in 10ms, latest 20ms from now and CPU1 goes
> > into a NOHZ idle sleep.
> > 
> > >   -0 [001] d...   109.953436: tick_stop: success=1 
> > > dependency=NONE
> > >   -0 [001] d...   109.953617: hrtimer_cancel: 
> > > hrtimer=109f449c
> > >   -0 [001] d...   109.953818: hrtimer_start: 
> > > hrtimer=109f449c function=tick_sched_timer expires=10988000 
> > > softexpires=10988000
> > 
> > which is (using the 0.087621us delta between the trace clock and clock
> > MONO) at: 109.880 + 0.087621 = 109.968
> > 
> > Which is about correct as we expect the RCU timer to fire at:
> >   
> >   109.952633 + 0.01 = 109.963633
> > 
> > or latest at
> > 
> >   109.952633 + 0.02 = 109.983633
> >
> > There is another caveat. That nohz stuff can queue the rcu timer on CPU0, 
> > which
> > it did not because:
> 
> Just for annoying completeness, the location of the timer depends on how
> the rcuo callback-offload kthreads are constrained.  And yes, in the most
> constrained case where all CPUs except for CPU 0 are nohz CPUs, they will
> by default all run on CPU 0.

In default full nohz configuration, am I correct that all cpus except
cpu0 willd be nohz and that the rcu callbacks then have to run on
cpu0?

> > >rcu_sched-7 [001] d...   109.952633: timer_start: 
> > > timer=160a9eb0 function=process_timeout expires=4294948284 [timeout=1] 
> > > flags=0x0001
> > 
> > The CPU nr encoded in flags is: 1
> > 
> > Now we cancel and restart the timer w/o seing the interrupt expiring
> > it. And that expiry should have happened at 109.968000 !?!
> > 
> > >   -0 [001] d...   109.968225: hrtimer_cancel: 
> > > hrtimer=109f449c
> > >   -0 [001] d...   109.968526: hrtimer_start: 
> > > hrtimer=109f449c function=tick_sched_timer expires=10989000 
> > > softexpires=10989000
> > 
> > So this advances the next tick even further out. And CPU 0 sets the timer to
> > the exact smae value:
> > 
> > >   -0 [000] d.h.   109.969104: hrtimer_start: 
> > > hrtimer=109e949c function=tick_sched_timer expires=10989000 
> > > softexpires=10989000
> > 
> > 
> > >   -0 [000] d.h.   109.977690: irq_handler_entry: irq=16 
> > > name=jcore_pit
> > >   -0 [000] d.h.   109.977911: hrtimer_cancel: 
> > > hrtimer=109e949c
> > >   -0 [000] d.h.   109.978053: hrtimer_expire_entry: 
> > > hrtimer=109e949c function=tick_sched_timer now=109890434160
> > 
> > Which expires here. And CPU1 instead of getting an interrupt and expiring
> > the timer does the cancel/restart to the next jiffie again:
> > 
> > >   -0 [001] d...   109.978206: hrtimer_cancel: 
> > > hrtimer=109f449c
> > >   -0 [001] d...   109.978495: hrtimer_start: 
> > > hrtimer=109f449c function=tick_sched_timer expires=1099 
> > > softexpires=1099
> > 
> > And this repeats;
> > 
> > >   -0 [000] d.h.   109.987726: irq_handler_entry: irq=16 
> > > name=jcore_pit
> > >   -0 [000] d.h.   109.987954: hrtimer_cancel: 
> > > hrtimer=109e949c
> > >   -0 [000] d.h.   109.988095: hrtimer_expire_entry: 
> > > hrtimer=109e949c function=tick_sched_timer now=109900474620
> > 
> > >   -0 [001] d...   109.988243: hrtimer_cancel: 
> > > hrtimer=109f449c
> > >   -0 [001] d...   109.988537: hrtimer_start: 
> > > hrtimer=109f449c fun9c
> > 
> > There is something badly wrong here.
> > 
> > >   -0 [000] ..s.   110.019443: softirq_entry: vec=1 
> > > [action=TIMER]
> > >   -0 [000] ..s.   110.019617: softirq_exit: vec=1 
> > > [action=TIMER]
> > >   -0 [000] ..s.   110.019730: softirq_entry: vec=7 
> > > [action=SCHED]
> > >   -0 [000] ..s.   110.020174: softirq_exit: vec=7 
> > > [action=SCHED]
> > >   -0 [000] d.h.   110.027674: irq_handler_entry: irq=16 
> > > name=jcore_pit
> > > 
> > > The rcu_sched process does not run again after the tick_stop until
> > > 132s, and only a few RCU softirqs happen (all shown above). During
> > > this time, cpu1 has no interrupt activity and nothing in the trace
> > > except the above hrtimer_cancel/hrtimer_start pairs (not sure how
> > > they're happening without any interrupts).
> > 
> > If you drop out of the arch idle into the core idle loop then you might end
> > up with this. You want to add a few trace points or trace_printks() to the
> > involved functions. tick_nohz_restart() tick_nohz_stop_sched_tic

[PATCH] fs: ufs: Use ktime_get_real_ts64() for birthtime

2016-10-01 Thread Deepa Dinamani
CURRENT_TIME is not y2038 safe.
Replace it with ktime_get_real_ts64().
Inode time formats are already 64 bit long and
accommodates time64_t.

Signed-off-by: Deepa Dinamani 
Cc: Evgeniy Dushistov 
---
 fs/ufs/ialloc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index fd0203c..876a478 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -176,6 +176,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
struct ufs_cg_private_info * ucpi;
struct ufs_cylinder_group * ucg;
struct inode * inode;
+   struct timespec64 ts;
unsigned cg, bit, i, j, start;
struct ufs_inode_info *ufsi;
int err = -ENOSPC;
@@ -323,8 +324,9 @@ cg_found:
lock_buffer(bh);
ufs2_inode = (struct ufs2_inode *)bh->b_data;
ufs2_inode += ufs_inotofsbo(inode->i_ino);
-   ufs2_inode->ui_birthtime = cpu_to_fs64(sb, CURRENT_TIME.tv_sec);
-   ufs2_inode->ui_birthnsec = cpu_to_fs32(sb, 
CURRENT_TIME.tv_nsec);
+   ktime_get_real_ts64(&ts);
+   ufs2_inode->ui_birthtime = cpu_to_fs64(sb, ts.tv_sec);
+   ufs2_inode->ui_birthnsec = cpu_to_fs32(sb, ts.tv_nsec);
mark_buffer_dirty(bh);
unlock_buffer(bh);
if (sb->s_flags & MS_SYNCHRONOUS)
-- 
2.7.4



Re: [PATCH net v2] L2TP:Adjust intf MTU,factor underlay L3,overlay L2

2016-10-01 Thread James Chapman
On 30/09/16 03:39, R. Parameswaran wrote:
>
>>> +   /* Adjust MTU, factor overhead - underlay L3 hdr, overlay L2 hdr*/
>>> +   if (tunnel->sock->sk_family == AF_INET)
>>> +   overhead += (ETH_HLEN + sizeof(struct iphdr));
>>> +   else if (tunnel->sock->sk_family == AF_INET6)
>>> +   overhead += (ETH_HLEN + sizeof(struct ipv6hdr));
>> What about options in the IP header? If certain options are set on the
>> socket, the IP header may be larger.
>>
> Thanks for the reply - It looks like IP options can only be 
> enabled through setsockopt on an application's socket (if there's any 
> other way to turn on IP options, please let me know - didn't see any 
> sysctl setting for transmit). This scenario would come 
> into picture when an application opens a raw IP or UDP socket such that it 
> routes into the L2TP logical interface.

No. An L2TP daemon (userspace) will open a socket for each tunnel that
it creates. Control and data packets use the same socket, which is the
socket used by this code. It may set any options on its sockets. L2TP
tunnel sockets can be created either by an L2TP daemon (managed tunnels)
or by ip l2tp commands (unmanaged tunnels).

> If you take the case of a plain IP (ethernet) interface, even if an
> application opened a socket turning on IP options, it would not change
> the MTU of the underlying interface, and it would not affect other 
> applications transacting packets on the same interface. I know its not an 
> exact parallel to this case, but since the IP option control is per 
> application, we probably should not factor it into the L2TP logical interface?
> We cannot affect other applications/processes running on the same L2TP 
> tunnel. Also, since the application  using IP options knows that it has 
> turned 
> on IP options, maybe we can count on it to factor the size of the options 
> into the size of the payload it sends into the socket, or set the mtu on the 
> L2TP interface through config? 

No. See above.

>
> Other than this, I don't see keepalives or anything else in which the 
> kernel will source its own packet into the L2TP interface, outside of 
> an application injected packet - if there is something like that, please
> let me know. The user space L2TP daemon would probably fall in the 
> category of applications.
>
> thanks,
>
> Ramkumar 
>
>




  1   2   >