timer: optimize apply_slack()

__fls(mask) is equivalent to find_last_bit(&mask, BITS_PER_LONG), but cheaper.
find_last_bit was showing up high on the list when I was profiling for stalls
on icache misses on a system with very small cache size (MIPS).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Revert "ARM: 7482/1: topology: fix section mismatch warning for init_cpu_topology"

This reverts commit d34aecb57f8c05dd669ff8ac1660397065bb0775.
Revert "ARM: 7463/1: topology: Update cpu_power according to DT information"

This reverts commit 156a6e938d631c3348fbbf35afcd07c5158ed71c.
Revert "ARM: 7462/1: topology: factorize the update of sibling masks"

This reverts commit e09e1c7b8b6faf2363a7c05444922361837c00fc.
Revert "ARM: 7461/1: topology: Add arch_scale_freq_power function"

This reverts commit d076156868f33536bf264645ca94ed03b280a155.
Revert "alarmtimer: Use hrtimer per-alarm instead of per-base"

This reverts commit bff93fc77a0b0fe82ccdbdcb6c1120211c539adb.
Revert qualcomm's contributions on mutex.h

Signed-off-by: Iliyan Malchev <malchev@google.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ARM: 7467/1: mutex: use generic xchg-based implementation for ARMv6+

The open-coded mutex implementation for ARMv6+ cores suffers from a
severe lack of barriers, so in the uncontended case we don't actually
protect any accesses performed during the critical section.

Furthermore, the code is largely a duplication of the ARMv6+ atomic_dec
code but optimised to remove a branch instruction, as the mutex fastpath
was previously inlined. Now that this is executed out-of-line, we can
reuse the atomic access code for the locking (in fact, we use the xchg
code as this produces shorter critical sections).

This patch uses the generic xchg based implementation for mutexes on
ARMv6+, which introduces barriers to the lock/unlock operations and also
has the benefit of removing a fair amount of inline assembly code.

Cc: <stable@vger.kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Nicolas Pitre <nico@linaro.org>
Reported-by: Shan Kang <kangshan0910@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ARM: 7495/1: mutex: use generic atomic_dec-based implementation for ARMv6+

Commit a76d7bd96d65 ("ARM: 7467/1: mutex: use generic xchg-based
implementation for ARMv6+") removed the barrier-less, ARM-specific
mutex implementation in favour of the generic xchg-based code.

Since then, a bug was uncovered in the xchg code when running on SMP
platforms, due to interactions between the locking paths and the
MUTEX_SPIN_ON_OWNER code. This was fixed in 0bce9c46bf3b ("mutex: place
lock in contended state after fastpath_lock failure"), however, the
atomic_dec-based mutex algorithm is now marginally more efficient for
ARM (~0.5% improvement in hackbench scores on dual A15).

This patch moves ARMv6+ platforms to the atomic_dec-based mutex code.

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
PM / wakeup: Use irqsave/irqrestore for events_lock

Jon Medhurst (Tixy) recently noticed a problem with the
events_lock usage. One of the Android patches that uses
wakeup_sources calls wakeup_source_add() with irqs disabled.
However, the event_lock usage in wakeup_source_add() uses
spin_lock_irq()/spin_unlock_irq(), which reenables interrupts.
This results in lockdep warnings.

The fix is to use spin_lock_irqsave()/spin_lock_irqrestore()
instead for the events_lock.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Linux 3.4.76

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
drivers: power: Reduce battery logspam

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: mdss: set vsync clock rate

Vsync clock rate is not set when vsync clock is enabled.
This cause command mode TE logic not works.

Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: mdss: Fix race condition for vsync irq enable/disable

Disable and enable of vsync happens in separate thread, which
may lead to a race condition where enable/disable may
happen at the same time and resulting irq in disable state.
Add lock to properly synchronize the enabling/disabling
of vsync interrupts to fix race condition.

Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
USB: u_serial: Don't free usb_requests in gs_close and reuse them

Commit "USB: Gadget: u_serial: Freeing usb requests as a
part of gs_close" results in freeing requests and flushing the EP
on every port close even if USB connection is present. These requests
are allocated again on port open. Also, EP flush call may result in
unclocked access of USB hardware if USB BUS state was suspended at
the time of port_close. This patch fixes that and also addresses the
original issue of gs_open allocating usb requests on every port_open
by adding a condition to allocate USB requests in port open only if
they are not already allocated.

Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: smd_tty: add new SMD TTY port

Add new port for exporting DATA4 (ATCoP) to userspace.

Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: smd_tty: add device tree support to smd_tty drivers

SMD TTY is configured using local tables that do not
allow customization on a per-target basis.

Add device tree support to configure SMD TTY devices.

Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: smd_tty: replace wake lock with wakeup source

Wake locks have been deprecated.

Remove deprecated wake lock calls and replace with wakeup sources and
power-management calls.

Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: camera: Limit prints in isp

Change every pr_err in msm_vfe_process_error_status to
pr_err_ratelimited to avoid watchdog reset

Signed-off-by: Yiduo Wang <yiduow@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
sched: set sched_mc_power_savings to 2

This is highest power saving possible value for this tunable.
Basically according to
 http://elinux.org/images/1/1d/Comparing_Power_Saving_Techniques_For_Multicore_ARM_Platforms.pdf
 this tunable provides serious power saving improvements close to the power
 savings of hotpluging cores. Since in this Kernel we're using always a
 minimum of 2 cpus online at any time during screen off we might actually
 benefit from this because this feature packs tasks together and try to bind
 them to cpu0, which in theory will let cpu1 idle longer, thus improving
 battery life.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>