cpufreq: Return directly in __cpufreq_get if policy is NULL

__cpufreq_get() checks whether policy->cur matches frequency returned
by cpufreq device driver and acts accordingly. However, policy could
be NULL if the CPU is being hotplugged. Current implementation crashes
when trying to dereference the NULL policy.

Return the frequency provided by cpufreq device driver directly if
policy is not available.

Change-Id: I1f2ba4028c259392bf730db37dbec2d8c5ae3fa4
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
cpufreq: Protect against hotplug in cpufreq_register_driver()

cpufreq_register_driver() could race with CPU hotplug during
bootup. Since hotplug notification is not registered when
subsys_interface_register() is being executed, it's possible
cpufreq's view of online CPUs becomes stale before it registers
for hotplug notification.

Register for hotplug notification first and protect
subsys_interface_register() against hotplug using
get/put_online_cpus().

Change-Id: I26b2908f1d167c2becc4e8664c357bb7c6162406
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
msm: perf: tracectr: Initialize cnts after hotplug

Due to the mismatch between counter values saved across CPU hotplug
by perf and tracecounter logic, incorrect values are calculated
for first entry in trace buffer.
Ignore the first entry when CPU comes out of hotplug and set previous
counter values in this scenario.

Change-Id: Ieeeaa301d713f338f11f6e84aeb984a3708e45fc
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>
Perf: Reset pmu after hotplug

The counter enable bits were staying in undefined state after CPU
came out of hotplug when perf was not enabled.
This was resulting into non-zero values for counters in ftrace
buffer which were not enabled by perf.
Clear the pmu when CPU comes out of hotplug and perf is not enabled.

Change-Id: I31e17565ad914650a12102a5c359b363f8f2ca2a
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>
msm: perf: set filter bits for cycle counter on krait

When programming the cycle counter on krait, the filter
register needs to be programmed in order to set the
usermode/kernelmode filter options.

Change-Id: Ifd5b032c9a5df4821706438d4359f84d8f614468
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/perf_debug.c
Perf: Fix hrtimer operation across hotplug

Stop hrtimer associated with CPU clock event when
core goes down. Start the timer when core comes back up.
This is needed to ensure proper software timer operation
across hotplug.

Change-Id: I027bf2718d177fa31be2a7cfe7ef98f93cb4aeda
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>
Perf: add perf user-mode permissions

Allow user-mode applications to use the performance
counters for debugging and performance analysis.

Change-Id: I0caed53dafb9965b8eece92762a0b67a40ff3be5
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
Perf: Add event type check in hrtimer hotplug fix

The hrtimer hotplug fix was missing event_type check due to which
the check was passing both software clock and hardware cycles.

Change-Id: I1d16d0ccc6ce27963ace9d2f3e1e1eab8f8c7d18
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>
Perf: Add debugfs node to clear PMU

Create debugfs node to clear PMU and some internal variables
used by Perf code. This provides a recovery path for
PMU related unexpected error scenarios.

Change-Id: I88ae9dda0888db9316ce123f6f3a58faec4d69ee
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>

Conflicts:
	arch/arm/Kconfig
msm: perf: reset perf cycle counter on krait

The cycle counter was not included in the list of
counters being reset. This could result in the cc
enable bit being set randomly, leading to spurious
interrupts when the counter overflowed, even though
the cc was not being used.

Change-Id: Ic7da5e78f932a25d05ce116aeec7a0709ddbb20e
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
Perf: interrupt disable without bringing cpus up

Refactor the interrupt disabling so that interrupts
are disabled when a cpu is hotplugged out, even if
there are no perf events on that cpu, but it holds
the PMU irq. This means that when perf ends it does
not have to re-enable an offline cpu just to disable
its irq.

Change-Id: Id0e052e4386173e107abe0eb6e80cb130d92ec24
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>

Conflicts:
	arch/arm/kernel/perf_event_cpu.c
Perf: stop counters when going into hotplug

Hotplug disables the pmu irq, but if counters are
running in the window before the CPU is hotplugged off
they can overflow and generate an interrupt. Because the
interrupt is disabled, this prevents the cpu from going
down which leads to a spin loop in the cpu_down driver
which consumes 100% cpu.

Events are stopped during hotplug processing. However,
perf is hooked into the timer tick, and restarts enabled
events on every tick, even if they were stopped. Change
the event state to OFF to prevent this.

Processing for stop reads the counters, so a separate call
is no longer needed. Start processing re-enables events so
the from_idle flag is not needed during pmu_enable.

Change-Id: I27ded876315147b50d9f85c09487b107a9216641
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
msm: perf: Refine disable/enable in tracecounters

Tracecounter code was not disabling counters as early as possible
and enabling them as late as possible. Refine the logic so cycles
spent inside the handler are as lower. This results in more accurate
per-process counter values.

Change-Id: Ib8bb17b1212ddf9e3d1c33a00ae486d885a36e45
Signed-off-by: Sheetal Sahasrabudhe <sheetals@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/perf_debug.c
Perf: reset pmu enables when starting perf

PMU enable registers are not cleared when coming out
of cpu idle and perf is not running. This means that
enable bits may be set when perf starts. This is not normally
a problem because perf only looks at the counters it enables.
But per-pid tracing will see the enabled counters and the
garbage count values that get put into trace records, and generally
be unable to distinguish them from good values.

Clear the counters when perf starts. Then also reset them when coming
out of cpu idle. The existing test was to do this when a perf
event was running on a cpu, but there is a window between init and
starting events where drop into cpu idle could happen and allow garbage
values to be loaded into the enable register again. So change the
criterion for reset after cpu idle to be whenever the PMU is running.

Change-Id: Ie807363de92d166994ebbb9369132176ceaa4f68
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
Perf: make debug dir handle exportable

The perf debug directory is exported so that other
drivers can place nodes there.

Change-Id: I255ff9435a40fbd0f9202ec99b380bd81207d492
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
power: smb135x: bump up 300-400mA for PC/USB charging
net: wirelss:bcmdhd revert roaming patch

1) The patch was needed for roaming patch in the FW.
However, we need to revert this code because we revert
the roaming patch in new FW(7.35.79.49)
2) Bug : 18541286
Signed-off-by: Ecco park <eccopark@broadcom.com>

Change-Id: I66123f0911670a66e923353ae112d492a3b3869a
dts: 8084: add 2.9ghz slot

* probably not too stable
dts: bump voltage slightly for 2.9ghz slot for pvs1-15
dts: add 223 Mhz slot