firefly-linux-kernel-4.4.55.git
8 years agocpufreq: interactive: add io_is_busy interface
Lianwei Wang [Fri, 22 Feb 2013 03:39:18 +0000 (11:39 +0800)]
cpufreq: interactive: add io_is_busy interface

Previously the idle time returned from get_cpu_idle_time_us included the
iowait time. So the iowait time was always calculated as idle time.

But now the idle time returned from get_cpu_idle_time_us does not include
the iowait time anymore because of below commit which cause the iowait time
always calculated as busy time:
    6beea0c nohz: Fix update_ts_time_stat idle accounting

Add the io_is_busy interface, as does the ondemand governor, and let the user
configure the iowait time as busy or idle through the io_is_busy sysfs
interface.

By default, io_is_busy is disabled.

[toddpoynor@google.com: minor updates]
Change-Id: If7d70ff864c43bc9c8d7fd7cfc66f930d339f9b4
Signed-off-by: Lianwei Wang <lian-wei.wang@motorola.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: allow arbitrary speed / delay mappings
Minsung Kim [Mon, 25 Feb 2013 14:48:04 +0000 (23:48 +0900)]
cpufreq: interactive: allow arbitrary speed / delay mappings

Accept a string of delays and speeds at which to apply the delay before
raising each step above hispeed. For example, "80000 1300000:200000
1500000:40000" means that the delay at or above 1GHz, until 1.3GHz is 80 msecs,
the delay until 1.5GHz is 200 msecs and the delay at or above 1.5GHz is 40
msecs when hispeed_freq is 1GHz.

[toddpoynor@google.com: add documentation]
Change-Id: Ifeebede8b1acbdd0a53e5c6916bccbf764dc854f
Signed-off-by: Minsung Kim <ms925.kim@samsung.com>
8 years agocpufreq: interactive: fix race on governor start/stop
Lianwei Wang [Mon, 7 Jan 2013 06:15:51 +0000 (14:15 +0800)]
cpufreq: interactive: fix race on governor start/stop

There is race condition when both two cpu do CPUFREQ_GOV_STOP and one cpu
do CPUFREQ_GOV_START soon. The sysfs_remove_group is not done yet on one
cpu, but sysfs_create_group is called on another cpu, which cause governor
start failed and then kernel panic in timer callback because the policy and
cpu mask are all kfree in cpufreq driver.

Replace atomic with mutex to lock the whole START/STOP sequence.

Change-Id: I3762b3d44315ae021b8275aca84f5ea9147cc540
Signed-off-by: Lianwei Wang <a22439@motorola.com>
8 years agocpufreq: interactive: fix deadlock on spinlock in timer
Todd Poynor [Wed, 2 Jan 2013 21:14:00 +0000 (13:14 -0800)]
cpufreq: interactive: fix deadlock on spinlock in timer

Need to use irqsave/restore spinlock calls to avoid a deadlock in calls
from the timer.

Change-Id: I15b6b590045ba1447e34ca7b5ff342723e53a605
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: don't handle transition notification if not enabled
Todd Poynor [Sun, 23 Dec 2012 20:28:49 +0000 (12:28 -0800)]
cpufreq: interactive: don't handle transition notification if not enabled

If multiple governors are in use then avoid processing frequency transition
notifications for CPUs on which the interactive governor is not enabled.

Change-Id: Ibd75255b921d887501a64774a8c4f62302f2d4e4
Reported-by: Francisco Franco <francisco.franco@cloudcar.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: init default values at compile time
Todd Poynor [Fri, 21 Dec 2012 23:32:21 +0000 (15:32 -0800)]
cpufreq: interactive: init default values at compile time

Change-Id: Ia4966e949a6c24c34fdbd4a6e522cd7c37e4108e
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: default go_hispeed_load 99%, doc updates
Todd Poynor [Fri, 21 Dec 2012 23:13:01 +0000 (15:13 -0800)]
cpufreq: interactive: default go_hispeed_load 99%, doc updates

Update default go_hispeed_load from 85% to 99%.  Recent changes to the
governor now use a default target_load of 90%.  go_hispeed_load should
not be lower than the target load for hispeed_freq, which could lead
to oscillating speed decisions.  Other recent changes reduce the need
to dampen speed jumps on load spikes, while input event boosts from
userspace are the preferred method for anticipating load spikes with
UI impacts.

General update to the documentation to reflect recent changes.

Change-Id: I1b92f3091f42c04b10503cd1169a943b5dfd6faf
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: fix race on timer restart on governor start
Todd Poynor [Thu, 20 Dec 2012 23:51:00 +0000 (15:51 -0800)]
cpufreq: interactive: fix race on timer restart on governor start

Starting the governor, or restarting on a hotplugged-in CPU, can race
with the timer start in idle, triggering a BUG on timer already pending.
Start the timer before setting the enable flag, and use enable_sem to
protect the sequence (and ensure correct order of the update to the
enable flag).  Delete any existing timer for safety.

Change-Id: Ife77cf9fe099e8fd8543224cbf148c6722c2ffb0
Reported-by: Francisco Franco <francisco.franco@cloudcar.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: fix racy timer stopping
Todd Poynor [Wed, 19 Dec 2012 01:50:44 +0000 (17:50 -0800)]
cpufreq: interactive: fix racy timer stopping

When stopping the governor, del_timer_sync() can race against an
invocation of the idle notifier callback, which has the potential
to reactivate the timer.

To fix this issue, a read-write semaphore is used. Multiple readers are
allowed as long as pcpu->governor_enabled is true.  However it can be
moved to false only after taking a write semaphore which would wait for
any on-going asynchronous activities to complete and prevent any more of
those activities to be initiated.

[toddpoynor@google.com: cosmetic and commit text changes]
Change-Id: Ib51165a735d73dcf964a06754c48bdc1913e13d0
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
8 years agocpufreq: interactive: fix boosting logic
Todd Poynor [Thu, 20 Dec 2012 00:06:48 +0000 (16:06 -0800)]
cpufreq: interactive: fix boosting logic

35a84de cpufreq: interactive: apply above_hispeed_delay to each step above hispeed

caused the speed choice logic to osciallate between boosting and not boosting.
Add back code to ensure speed does not drop below boost frequency while
boosting.

Change-Id: Id420068480fcc7f5c4989ff523e2a8d22e2f4db2
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: add timer slack to limit idle at speed > min
Todd Poynor [Wed, 19 Dec 2012 01:50:10 +0000 (17:50 -0800)]
cpufreq: interactive: add timer slack to limit idle at speed > min

Always use deferrable timer for load sampling.

Set a non-deferrable timer to an additional slack time to allow prior to
waking up from idle to drop speed when not at minimum speed.  Slack value
-1 avoids wakeups to drop speed.  Default is 80ms.

Remove the governidle module param and its timer management in idle.  For
platforms on which holding speed above mimum in idle costs power, use the
new timer slack to select how long to wait before waking up to drop speed.

Change-Id: I270b3980667e2c70a68e5bff534124b4411dbad5
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: specify duration of CPU speed boost pulse
Todd Poynor [Sat, 15 Dec 2012 01:31:19 +0000 (17:31 -0800)]
cpufreq: interactive: specify duration of CPU speed boost pulse

Sysfs attribute boostpulse_duration specifies the duration of boosting CPU
speed in response to bootpulse events.  Duration is specified in usecs,
default 80ms.

Change-Id: Ifd41625574891a44f1787a4e85d1e7b4f2afb52b
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: adjust load for changes in speed
Todd Poynor [Wed, 12 Dec 2012 00:05:03 +0000 (16:05 -0800)]
cpufreq: interactive: adjust load for changes in speed

Add notifier for speed transitions.  Keep a count of CPU active
microseconds times current frequency, converted to a percentage relative
to the current frequency when load is evaluated.

Change-Id: I5c27adb11081c50490219784ca57cc46e97fc28c
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: remove load since last speed change
Todd Poynor [Sat, 8 Dec 2012 04:08:45 +0000 (20:08 -0800)]
cpufreq: interactive: remove load since last speed change

The longer-term load since last speed change isn't terribly useful,
may delay recognition of dropping load, and would need forthcoming
changes to adjust load for changing CPU speeds.  Drop it.

Change-Id: Ic3cbb0542cc3484617031787e03ed9bdd632dec1
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: allow arbitrary speed / target load mappings
Todd Poynor [Wed, 14 Nov 2012 19:41:21 +0000 (11:41 -0800)]
cpufreq: interactive: allow arbitrary speed / target load mappings

Accept a string of target loads and speeds at which to apply the
target loads, per the documentation update in this patch.  For example,
"85 1000000:90 1700000:99" targets CPU load 85% below speed 1GHz,  90%
at or above 1GHz, until 1.7GHz and above, at which load 99% is targeted.

Attempt to avoid oscillations by evaluating the current speed
weighted by current load against each new choice of speed, choosing a
higher speed if the current load requires a higher speed.

Change-Id: Ie3300206047c84eca5a26b0b63ea512e5207550e
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: apply above_hispeed_delay to each step above hispeed
Todd Poynor [Thu, 8 Nov 2012 23:06:55 +0000 (15:06 -0800)]
cpufreq: interactive: apply above_hispeed_delay to each step above hispeed

Apply above_hispeed_delay whenever increasing speed to a new speed above
hispeed (not just the first step above hispeed).

Change-Id: Ibb7add7db47f2a4306a9458c4e1ebabb60698636
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: change speed according to current speed and target load
Todd Poynor [Thu, 29 Nov 2012 01:58:17 +0000 (17:58 -0800)]
cpufreq: interactive: change speed according to current speed and target load

Add a target_load attribute that specifies how aggressively the governor is
to adjust speed to meet the observed load.  New target speed is calculated
as the current actual speed (may be higher than target speed on SMP) times
the CPU load (as a fraction) divided by target load (fraction).

cpufreq_frequency_table_target() call use CPUFREQ_RELATION_L to set
the next higher speed rather than next lower speed.

Change-Id: If432451da82f5fed12e15c9421d7d27792376150
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: trace actual speed in target speed decisions
Todd Poynor [Thu, 29 Nov 2012 01:56:09 +0000 (17:56 -0800)]
cpufreq: interactive: trace actual speed in target speed decisions

Tracing adds actual speed since this is expected to be key to the
choice of target speed.

Change-Id: Iec936102d0010c4e9dfa143c38a9fd0d551189c3
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: kick timer on idle exit past expiry
Todd Poynor [Tue, 9 Oct 2012 03:14:34 +0000 (20:14 -0700)]
cpufreq: interactive: kick timer on idle exit past expiry

The deferrable timer list isn't checked on all idle exits, such as when
hi-res timers expire or ISRs schedule workers.  If the idle loop is
exited and it's past time to run the governor load polling timer,
run it immediately.  This ensures we handle load spikes caused by actvity
that does not run the normal timer list.

Rename the field that timestamps the "time_in_idle" value to be more
accurate.

Change-Id: Ied590ecbefc83c9a9ec5eb9e31903557f6fa1614
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: use deferrable timer by default
Lianwei Wang [Thu, 1 Nov 2012 01:59:52 +0000 (09:59 +0800)]
cpufreq: interactive: use deferrable timer by default

Avoid wakeups only to handle the governor timer when the system is otherwise
idle.

For platforms where the power cost of remaining in idle at higher CPU
speed may outweigh the cost of a governor wakeup from idle to lower the speed,
set parameter cpufreq_interactive.governidle=1.

Change-Id: Id6c43eb35caecf9b0574fcdd5b769711bc7e6de6
Signed-off-by: LianWei WANG <a22439@motorola.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: pin timers to associated CPU
Todd Poynor [Mon, 5 Nov 2012 21:09:03 +0000 (13:09 -0800)]
cpufreq: interactive: pin timers to associated CPU

Helps avoid waking up other CPUs to react to activity on the local CPU.

Change-Id: Ife272aaa7916894a437705d44521b1a1693fbe8e
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: run at fraction of hispeed_freq when load is low
Todd Poynor [Wed, 3 Oct 2012 07:39:56 +0000 (00:39 -0700)]
cpufreq: interactive: run at fraction of hispeed_freq when load is low

When load is below go_hispeed_load, apply the percentage of CPU load to
a max frequency of hispeed_freq instead of the max speed.  This avoids
jumping too quickly to hispeed_freq when it is a relatively low
percentage of max speed.  This also allows go_hispeed_load to be set to
a high percentage relative to hispeed_freq (as a percentage of max speed,
again useful when hispeed_freq is a low fraction of max speed), to cap
larger loads at hispeed_freq.  For example, a load of 60% will typically
move to 60% of hispeed_freq, not 60% of max speed.  This causes the
governor to apply two different speed caps, depending on whether load is
below or above go_hispeed_load.

Also fix the type of hispeed_freq, which was u64, to match other
speed data types (and avoid overhead and allow division).

Change-Id: Ie2d0668be161c074aaad77db2037505431457b3a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: always limit initial speed bump to hispeed
Todd Poynor [Tue, 25 Sep 2012 01:03:58 +0000 (18:03 -0700)]
cpufreq: interactive: always limit initial speed bump to hispeed

First bump speed up to hispeed_freq whenever the current speed is below
hispeed_freq, instead of only when the current speed is the minimum speed.
The previous code made it too difficult to use hispeed_freq as a common
intermediate speed on systems that frequently run at speeds between
minimum and hispeed_freq.

Change-Id: I04ec30bafabf5741e267ff289209b8c2d846824b
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: remove input_boost handling
Todd Poynor [Tue, 17 Jul 2012 00:32:44 +0000 (17:32 -0700)]
cpufreq: interactive: remove input_boost handling

Now handled in userspace Power HAL instead.

Change-Id: I78a4a2fd471308bfcd785bbefcc65fede27314cf
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: handle speed up and down in the realtime task
Todd Poynor [Tue, 17 Jul 2012 00:07:15 +0000 (17:07 -0700)]
cpufreq: interactive: handle speed up and down in the realtime task

Not useful to have a separate, non-realtime workqueue for speed down
events, avoid priority inversion for speed up events.

Change-Id: Iddcd05545245c847aa1bbe0b8790092914c813d2
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: keep freezer happy when not current governor
Sam Leffler [Wed, 27 Jun 2012 19:55:56 +0000 (12:55 -0700)]
cpufreq: interactive: keep freezer happy when not current governor

Fix a problem where the hung task mechanism was deeming the interactive
clock boost thread as hung.  This was because the thread is created at
module init but never run/woken up until needed.  If the governor is not
being used this can be forever.  To workaround this explicitly wake up
the thread once all the necessary data structures are initialized.  The
latter required some minor code shuffle.

Signed-off-by: Sam Leffler <sleffler@chromium.org>
Change-Id: Ie2c058dd75dcb6460ea10e7ac997e46baf66b1fe

8 years agocpufreq: interactive: take idle notifications only when active
Sam Leffler [Wed, 27 Jun 2012 17:12:04 +0000 (10:12 -0700)]
cpufreq: interactive: take idle notifications only when active

Register an idle notifier only when the governor is active.  Also
short-circuit work of idle end if the governor is not enabled.

Signed-off-by: Sam Leffler <sleffler@chromium.org>
Change-Id: I4cae36dd2e7389540d337d74745ffbaa0131870f

8 years agocpufreq: interactive: fixup trace of string params
Todd Poynor [Fri, 11 May 2012 18:06:09 +0000 (11:06 -0700)]
cpufreq: interactive: fixup trace of string params

Change-Id: Iac47f62437e61b13724afbbf9df1a0729f58f236
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: restart above_hispeed_delay at each hispeed load
Todd Poynor [Fri, 11 May 2012 06:28:06 +0000 (23:28 -0700)]
cpufreq: interactive: restart above_hispeed_delay at each hispeed load

Change-Id: I2e5b91d45e8806b0ab94ca2301ed671c9af9ab13
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq-interactive: Compile fixup
John Stultz [Tue, 1 May 2012 21:10:31 +0000 (14:10 -0700)]
cpufreq-interactive: Compile fixup

Looks like AOSP has a compile bug. Fix it up.

Signed-off-by: John Stultz <john.stultz@linaro.org>
8 years agocpufreq: interactive: add boost pulse interface
Todd Poynor [Thu, 3 May 2012 07:16:55 +0000 (00:16 -0700)]
cpufreq: interactive: add boost pulse interface

Change-Id: Icf1e86d2065cc8f0816ba9c6b065eb056d4e8249
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: set floor for boosted speed
Todd Poynor [Fri, 27 Apr 2012 04:41:40 +0000 (21:41 -0700)]
cpufreq: interactive: set floor for boosted speed

Allow speed to drop to flooor frequency but not below, don't pin
to speed at last boost.

Change-Id: I0147c2b7a2e61ba16820605af6baaf09570be787
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: Add sysfs boost interface for hints from userspace
Todd Poynor [Tue, 24 Apr 2012 03:42:41 +0000 (20:42 -0700)]
cpufreq: interactive: Add sysfs boost interface for hints from userspace

The explicit hint on/off version.

Change-Id: Ibf62b6d45bf6fb8c9c055b9bdaf074ce9374c04f
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: remove unused target_validate_time_in_idle
Todd Poynor [Tue, 24 Apr 2012 04:22:45 +0000 (21:22 -0700)]
cpufreq: interactive: remove unused target_validate_time_in_idle

Change-Id: I37c5085b91318242612440dfd775ad762996612f
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: Boost frequency on touchscreen input
Todd Poynor [Tue, 3 Apr 2012 00:17:14 +0000 (17:17 -0700)]
cpufreq: interactive: Boost frequency on touchscreen input

Based on previous patches by Tero Kristo <tero.kristo@nokia.com>,
Brian Steuer <bsteuer@codeaurora.org>,
David Ng <dave@codeaurora.org>,
Antti P Miettinen <amiettinen@nvidia.com>, and
Thomas Renninger <trenn@suse.de>

Change-Id: Ic55fedcf6f9310f43a7022fb88e23b0392122769
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: Separate speed target revalidate time and initial set time
Todd Poynor [Fri, 20 Apr 2012 20:18:32 +0000 (13:18 -0700)]
cpufreq: interactive: Separate speed target revalidate time and initial set time

Allow speed drop after min_sample_time elapses from last time
the current speed was last re-validated as appropriate for
current load / input boost.

Allow speed bump after min_sample_time (or above_hispeed_delay)
elapses from the time the current speed was originally set.

Change-Id: Ic25687a7a53d25e6544c30c47d7ab6f27a47bee8
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: base hispeed bump on target freq, not actual
Todd Poynor [Thu, 19 Apr 2012 19:52:48 +0000 (12:52 -0700)]
cpufreq: interactive: base hispeed bump on target freq, not actual

For systems that set a common speed for all CPUs, checking current
speed here could bypass the intermediate hispeed bump decision for
this CPU when another CPU was already at hispeed.  This could
result in an overly high setting (for all CPUs) in situations
where all CPUs were about to drop to load levels that map to
hispeed or below.

Change-Id: I186f23dcfc5e2b6336cab8b0327f0c8a9a4482bc
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: adjust code and documentation to match
Todd Poynor [Wed, 18 Apr 2012 00:39:34 +0000 (17:39 -0700)]
cpufreq: interactive: adjust code and documentation to match

Change-Id: If59c668d514a29febe5c35404fd9d01df8548eb1
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: configurable delay before raising above hispeed
Todd Poynor [Sat, 14 Apr 2012 03:18:02 +0000 (20:18 -0700)]
cpufreq: interactive: configurable delay before raising above hispeed

Change-Id: I4d6ac40b23a3790d48e30c37408284e9f955e8fa
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: don't drop speed if recently at higher load
Todd Poynor [Sat, 7 Apr 2012 02:59:36 +0000 (19:59 -0700)]
cpufreq: interactive: don't drop speed if recently at higher load

Apply min_sample_time to the last time the current target speed
was originally requested or re-validated as appropriate for the
current load, not to the time since the current speed was
originally set.  Avoids periodic dips in speed during bursty
loads.

Change-Id: I250bda657985de60373f9897cc41f480664d51a1
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: set at least hispeed when above hispeed load
Todd Poynor [Sat, 7 Apr 2012 02:50:12 +0000 (19:50 -0700)]
cpufreq: interactive: set at least hispeed when above hispeed load

If load is above go_hispeed_load, always go to at least hispeed_freq,
even when reducing speed from a higher speed, not just when jumping
up from minimum speed.  Avoids running at a lower than intended
speed after a burst of even higher load.

Change-Id: I5b9d2a15ba25ce609b21bac7c724265cf6838dee
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: apply intermediate load to max speed not current
Todd Poynor [Fri, 6 Apr 2012 08:13:09 +0000 (01:13 -0700)]
cpufreq: interactive: apply intermediate load to max speed not current

Evaluate spikes in load (below go_hispeed_load) against the maximum
speed supported by the device, not the current speed (which tends to
make it too difficult to raise speed to intermediate levels until
very busy).

Change-Id: Ib937006abf8bedb60891a739acd733e89b732ae0
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq interactive governor: event tracing
Todd Poynor [Fri, 17 Feb 2012 00:27:59 +0000 (16:27 -0800)]
cpufreq interactive governor: event tracing

Change-Id: Ic13614a3da2faa2d4bd215ca3eb7191614f0cf66
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: New 'interactive' governor
Mike Chan [Tue, 22 Jun 2010 18:26:45 +0000 (11:26 -0700)]
cpufreq: interactive: New 'interactive' governor

This governor is designed for latency-sensitive workloads, such as
interactive user interfaces.  The interactive governor aims to be
significantly more responsive to ramp CPU quickly up when CPU-intensive
activity begins.

Existing governors sample CPU load at a particular rate, typically
every X ms.  This can lead to under-powering UI threads for the period of
time during which the user begins interacting with a previously-idle system
until the next sample period happens.

The 'interactive' governor uses a different approach. Instead of sampling
the CPU at a specified rate, the governor will check whether to scale the
CPU frequency up soon after coming out of idle.  When the CPU comes out of
idle, a timer is configured to fire within 1-2 ticks.  If the CPU is very
busy from exiting idle to when the timer fires then we assume the CPU is
underpowered and ramp to MAX speed.

If the CPU was not sufficiently busy to immediately ramp to MAX speed, then
the governor evaluates the CPU load since the last speed adjustment,
choosing the highest value between that longer-term load or the short-term
load since idle exit to determine the CPU speed to ramp to.

A realtime thread is used for scaling up, giving the remaining tasks the
CPU performance benefit, unlike existing governors which are more likely to
schedule rampup work to occur after your performance starved tasks have
completed.

The tuneables for this governor are:
/sys/devices/system/cpu/cpufreq/interactive/min_sample_time:
The minimum amount of time to spend at the current frequency before
ramping down. This is to ensure that the governor has seen enough
historic CPU load data to determine the appropriate workload.
Default is 80000 uS.
/sys/devices/system/cpu/cpufreq/interactive/go_maxspeed_load
The CPU load at which to ramp to max speed.  Default is 85.

Change-Id: Ib2b362607c62f7c56d35f44a9ef3280f98c17585
Signed-off-by: Mike Chan <mike@android.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Bug: 3152864

8 years agoARM: Call idle notifiers
Todd Poynor [Thu, 16 Jun 2011 00:44:50 +0000 (17:44 -0700)]
ARM: Call idle notifiers

Change-Id: Id833e61c13baa1783705ac9e9046d1f0cc90c95e
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agoMove x86_64 idle notifiers to generic
Todd Poynor [Thu, 16 Jun 2011 00:21:57 +0000 (17:21 -0700)]
Move x86_64 idle notifiers to generic

Move the x86_64 idle notifiers originally by Andi Kleen and Venkatesh
Pallipadi to generic.

Change-Id: Idf29cda15be151f494ff245933c12462643388d5
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpuidle: governor: menu: don't use loadavg
Colin Cross [Mon, 19 Sep 2011 23:42:44 +0000 (16:42 -0700)]
cpuidle: governor: menu: don't use loadavg

get_loadavg doesn't work as intended.  According to the comments, it
should be returning an average over a few seconds, but it is actually
reading the instantaneous load.  It is almost always returning 0, but
can sometimes, depending on workload, spike very high into the hundreds
even when the average cpu load is under 10%.  Disable it for now.

Change-Id: I63ed100af1cf9463549939b8113ed83676db5f86
Signed-off-by: Colin Cross <ccross@android.com>
8 years agosched: add sched blocked tracepoint which dumps out context of sleep.
Riley Andrews [Fri, 2 Oct 2015 07:39:53 +0000 (00:39 -0700)]
sched: add sched blocked tracepoint which dumps out context of sleep.

Decare war on uninterruptible sleep. Add a tracepoint which
walks the kernel stack and dumps the first non-scheduler function
called before the scheduler is invoked.

Change-Id: I19e965d5206329360a92cbfe2afcc8c30f65c229
Signed-off-by: Riley Andrews <riandrews@google.com>
8 years agosched: Enable might_sleep before initializing drivers.
Arve Hjønnevåg [Thu, 11 Dec 2008 04:06:28 +0000 (20:06 -0800)]
sched: Enable might_sleep before initializing drivers.

This allows detection of init bugs in built-in drivers.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agofiq_debugger: Build fixes for 4.1
John Stultz [Fri, 4 Dec 2015 19:32:21 +0000 (11:32 -0800)]
fiq_debugger: Build fixes for 4.1

Small build updates for 4.1

Signed-off-by: John Stultz <john.stultz@linaro.org>
8 years agofiq_debugger: Add fiq_watchdog_triggered api
Arve Hjønnevåg [Sat, 3 May 2014 03:31:07 +0000 (20:31 -0700)]
fiq_debugger: Add fiq_watchdog_triggered api

Dumps registers and stacktrace into console-ramoops when called
from a watchdog fiq.

Change-Id: Ib6fab5a52f670db18e64214d5e4890e8292a749c
Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agofiq_debugger: Call fiq_debugger_printf through a function pointer from cpu specific...
Arve Hjønnevåg [Sat, 3 May 2014 02:52:54 +0000 (19:52 -0700)]
fiq_debugger: Call fiq_debugger_printf through a function pointer from cpu specific code

This allows the output from the register and stack trace code to be
sent elsewhere.

Change-Id: I41bb0d5a25e1b9ca55feef5dbd675818b2f832d5
Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agofiq_debugger: add ARM64 support
Colin Cross [Thu, 3 Apr 2014 01:49:39 +0000 (18:49 -0700)]
fiq_debugger: add ARM64 support

Add fiq_debugger_arm64.c that implements the platform-specific
functions.

Change-Id: I4d8b96777bb8503a93d4eb47bbde8e018740a5bf
Signed-off-by: Colin Cross <ccross@android.com>
8 years agofiq_debugger: split arm support into fiq_debugger_arm.c
Colin Cross [Thu, 3 Apr 2014 01:42:13 +0000 (18:42 -0700)]
fiq_debugger: split arm support into fiq_debugger_arm.c

Split arm support into a separate .c file that is only built for
CONFIG_ARM.

Change-Id: Iba16f4d51608bf9c3e5c8acefefcd38fead9797c
Signed-off-by: Colin Cross <ccross@android.com>
8 years agofiq_debugger: use pt_regs for registers
Colin Cross [Sat, 5 Apr 2014 00:05:19 +0000 (17:05 -0700)]
fiq_debugger: use pt_regs for registers

IRQ mode already passes in a struct pt_regs from get_irq_regs().
FIQ mode passes in something similar but not identical to a
struct pt_regs - FIQ mode stores the spsr of the interrupted mode
in slot 17, while pt_regs expects orig_r0.

Replace the existing mixture of void *regs, unsigned *regs, and
struct pt_regs * const with const struct pt_regs *.  Modify
dump_regs not to print the spsr since it won't be there in a
struct pt_regs anyways.  Modify dump_allregs to highlight the
mode that was interrupted, making spsr easy to find there.

Change-Id: Ibfe1723d702306c7605fd071737d7be9ee9d8c12
Signed-off-by: Colin Cross <ccross@android.com>
8 years agofiq_debugger: allow compiling without CONFIG_FIQ_GLUE
Colin Cross [Thu, 3 Apr 2014 01:37:29 +0000 (18:37 -0700)]
fiq_debugger: allow compiling without CONFIG_FIQ_GLUE

Allow compiling fiq_debugger.c without CONFIG_FIQ_GLUE for
platforms that don't support FIQs.

Change-Id: Iabdfd790d24fa9d47b29d2f850c567af2dcad78f
Signed-off-by: Colin Cross <ccross@android.com>
8 years agofiq_debugger: rename debug->fiq_debugger
Colin Cross [Sat, 5 Apr 2014 05:58:23 +0000 (22:58 -0700)]
fiq_debugger: rename debug->fiq_debugger

Rename variables and functions in the global namespace to avoid
future collisions.

Change-Id: Ic23a304b0f794efc94cc6d086fddd63231d99c98
Signed-off-by: Colin Cross <ccross@android.com>
8 years agofiq_debugger: move into drivers/staging/android/fiq_debugger/
Colin Cross [Thu, 3 Apr 2014 01:30:04 +0000 (18:30 -0700)]
fiq_debugger: move into drivers/staging/android/fiq_debugger/

Move fiq_debugger into drivers/staging/android/fiq_debugger/ to
allow for sharing between ARM and ARM64.

Change-Id: I6ca5e8b7e3d000f57da3234260261c5592cef2a8
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_glue: Add custom fiq return handler api.
Arve Hjønnevåg [Tue, 25 Jun 2013 01:02:05 +0000 (18:02 -0700)]
ARM: fiq_glue: Add custom fiq return handler api.

Change-Id: I5ff2764e85151ca0a88576542fda07c2d33dd065
Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agoARM: kgdb: ignore breakpoint instructions from user mode
Todd Poynor [Wed, 3 Jul 2013 22:48:04 +0000 (15:48 -0700)]
ARM: kgdb: ignore breakpoint instructions from user mode

Avoid conflicts with user mode usage of the same instructions, as with
Clang -ftrapv.

Change-Id: I12d1c6d8f94376bfd2503cb0be843d7e478fb6ea
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agoARM: fiq_debugger: Update tty code for 3.9
Arve Hjønnevåg [Tue, 15 Jan 2013 23:10:31 +0000 (15:10 -0800)]
ARM: fiq_debugger: Update tty code for 3.9

Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agoARM: fiq_debugger: Use kmsg_dumper to dump kernel logs
Arve Hjønnevåg [Tue, 27 Nov 2012 04:05:37 +0000 (20:05 -0800)]
ARM: fiq_debugger: Use kmsg_dumper to dump kernel logs

Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agoARM: fiq_debugger: Fix to compile on 3.7
Arve Hjønnevåg [Tue, 27 Nov 2012 00:23:33 +0000 (16:23 -0800)]
ARM: fiq_debugger: Fix to compile on 3.7

Use for_each_irq_desc in arch/arm/common/fiq_debugger.c

Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agoARM: fiq_debugger: fix uninitialised spin_lock.
Mars [Sat, 3 Nov 2012 04:15:38 +0000 (12:15 +0800)]
ARM: fiq_debugger: fix uninitialised spin_lock.

Backtrace:
[<c0045ea0>] (dump_backtrace+0x0/0x10c) from [<c0575c60>] (dump_stack+0x1)
 r6:c07a489c r5:c0c9b9dc r4:00000002 r3:271aed3b
[<c0575c48>] (dump_stack+0x0/0x1c) from [<c00b1b00>] (__lock_acquire+0x93)
[<c00b11c8>] (__lock_acquire+0x0/0xad4) from [<c00b219c>] (lock_acquire+0)
[<c00b210c>] (lock_acquire+0x0/0xa4) from [<c057e544>] (_raw_spin_lock_ir)
[<c057e4f8>] (_raw_spin_lock_irq+0x0/0x5c) from [<c005297c>] (fiq_tty_wri)
 r5:e30f0000 r4:e36f0c00
[<c005293c>] (fiq_tty_write+0x0/0x80) from [<c023168c>] (n_tty_write+0x18)
 r8:e370fc40 r7:e378a000 r6:e3572d1c r5:e36f0c00 r4:00000002
r3:c005293c
[<c0231500>] (n_tty_write+0x0/0x440) from [<c022d4a4>] (tty_write+0x100/0)
[<c022d3a4>] (tty_write+0x0/0x2a8) from [<c0100b80>] (vfs_write+0xa4/0x14)
[<c0100adc>] (vfs_write+0x0/0x148) from [<c0100cdc>] (sys_write+0x40/0x78)
 r8:00000002 r7:4076d2c4 r6:e370fc40 r5:00000000 r4:00000000
[<c0100c9c>] (sys_write+0x0/0x78) from [<c0041740>] (ret_fast_syscall+0x0)
 r8:c0041908 r7:00000004 r6:00000002 r5:00000000 r4:4007cbe0

[ccross: moved spin_lock_init into existing #ifdef]
Change-Id: If400d084eb20433c126ea1dd027a6be7f2ebb1f6
Signed-off-by: Mars <caoziqiang@meizu.com>
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_debugger: lock between tty and console writes
Colin Cross [Thu, 1 Nov 2012 00:41:39 +0000 (17:41 -0700)]
ARM: fiq_debugger: lock between tty and console writes

debug_console_write calls debug_uart_flush, which will usually wait
until the serial port fifo empties.  If another thread is continuously
calling fiq_tty_write, the fifo will constantly be refilled and
debug_uart_flush might never return.

Add a spinlock that is locked in debug_console_write and fiq_tty_write
to ensure they can't run at the same time.  This has an extra advantage
of preventing lines from the console and tty from being mixed together.

Also reduce the size returned by fiq_tty_write_room to keep the time
spent with the spinlock held to a reasonable value.

In addition, make sure fiq context can't loop forever by never calling
debug_uart_flush when the console is enabled.

Change-Id: I5712b01f740ca0c84f680d2032c9fa16b7656939
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_debugger: add process context reboot command
Colin Cross [Fri, 20 Jul 2012 01:40:04 +0000 (18:40 -0700)]
ARM: fiq_debugger: add process context reboot command

kernel_restart cannot be called from interrupt context.  Add support for
commands called from a work function, and implement the "reboot" command
there.  Also rename the existing irq-mode command to "reset" and change
it to use machine_restart instead of kernel_restart.

Change-Id: I3c423147c01db03d89e95a5b99096ca89462079f
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_debugger: fix multiple consoles and make it a preferred console
Colin Cross [Sun, 18 Mar 2012 22:25:55 +0000 (15:25 -0700)]
ARM: fiq_debugger: fix multiple consoles and make it a preferred console

Fix setting up consoles on multiple fiq debugger devices by
splitting the tty driver init into the initcall, and initializing
the single tty device during probe.  Has the side effect of moving
the tty device node to /dev/ttyFIQx, where x is the platform device
id, which should normally match the serial port.

To avoid having to pass a different console=/dev/ttyFIQx for every
device, make the fiq debugger a preferred console that will be used
by default if no console was passed on the command line.

Change-Id: I6cc2670628a41e84615859bc96adba189966d647
Signed-off-by: Colin Cross <ccross@android.com>
8 years agokdb: support new lines without carriage returns
Colin Cross [Thu, 15 Mar 2012 02:26:53 +0000 (19:26 -0700)]
kdb: support new lines without carriage returns

kdb expects carriage returns through the serial port to terminate
commands.  Modify it to accept the first seen carriage return or
new line as a terminator, but not treat \r\n as two terminators.

Change-Id: I06166017e7703d24310eefcb71c3a7d427088db7
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_debugger: add support for kgdb
Colin Cross [Thu, 15 Mar 2012 02:23:29 +0000 (19:23 -0700)]
ARM: fiq_debugger: add support for kgdb

Adds polling tty ops to the fiq debugger console tty, which allows
kgdb to run against an fiq debugger console.

Add a check in do_sysrq to prevent enabling kgdb from the fiq
debugger unless a flag (writable only by root) has been set. This
should make it safe to enable KGDB on a production device.

Also add a shortcut to enable the console and kgdb together, to
allow kgdb to be enabled when the shell on the console is not
responding.

Change-Id: Ifc65239ca96c9887431a6a36b9b44a539002f544
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_debugger: add debug_putc
Colin Cross [Thu, 15 Mar 2012 19:57:20 +0000 (12:57 -0700)]
ARM: fiq_debugger: add debug_putc

Convert all the calls to state->pdata->uart_putc to a debug_putc
helper.

Change-Id: Idc007bd170ff1b51d0325e238105ae0c86d23777
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_debugger: add support for reboot commands
Colin Cross [Wed, 14 Mar 2012 23:29:47 +0000 (16:29 -0700)]
ARM: fiq_debugger: add support for reboot commands

Pass the rest of the reboot command to kernel_restart to allow
reboot bootloader to work from FIQ debugger.

Change-Id: I4e7b366a69268dda17ffcf4c84f2373d15cb1271
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: fiq_debugger: fix compiling for v3.3
Colin Cross [Wed, 14 Mar 2012 23:28:45 +0000 (16:28 -0700)]
ARM: fiq_debugger: fix compiling for v3.3

Call kernel_restart instead of arch_reset, the ARM reset handling
has changed.

Remove localtimer irq printing, they now show up in the regular
irq stats.

Change-Id: I523da343b292c5711f3e1cbfd766d32eea2da84e
Signed-off-by: Colin Cross <ccross@android.com>
8 years agoARM: Add generic fiq serial debugger
Iliyan Malchev [Sun, 6 Jun 2010 00:36:24 +0000 (17:36 -0700)]
ARM: Add generic fiq serial debugger

Change-Id: Ibb536c88f0dbaf4766d0599296907e35e42cbfd6
Signed-off-by: Iliyan Malchev <malchev@google.com>
Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agoARM: Add fiq_glue
Arve Hjønnevåg [Tue, 28 Sep 2010 00:50:00 +0000 (17:50 -0700)]
ARM: Add fiq_glue

Change-Id: I27d2554e07d9de204e0a06696d38db51608d9f6b
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Colin Cross <ccross@android.com>
8 years agofix false disconnect due to a signal sent to the reading process
keunyoung [Wed, 29 Jan 2014 20:41:50 +0000 (12:41 -0800)]
fix false disconnect due to a signal sent to the reading process

- In the current implementation, when a signal is sent to the reading process,
  read is cancelled by calling usb_ep_dequeue, which lead into calling
  acc_complete_out with ECONNRESET, but the current logic treats it as
  disconnection, which makes the device inaccessible until cable is actually
  disconnected.
- The fix calls disconnect only when ESHUTDOWN error is passed.
- If data has already arrived while trying cancelling, the data is marked
  as available, and it will be read out on the next read. This is necessary
  as USB bulk is assumed to guarantee no data loss.

Signed-off-by: keunyoung <keunyoung@google.com>
8 years agousb: gadget: u_ether: use %z format specifier for size_t
Amit Pundir [Fri, 8 Jan 2016 14:06:02 +0000 (19:36 +0530)]
usb: gadget: u_ether: use %z format specifier for size_t

Use '%zd' format specifier for size_t type instead
of '%d' to fix build warnings like:

drivers/usb/gadget/function/u_ether.c: In function ‘rx_submit’:
drivers/usb/gadget/function/u_ether.c:244:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘size_t’ [-Wformat=]
  DBG(dev, "%s: size: %d\n", __func__, size);
  ^

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: gadget: rndis: fix broken build for 4.4
Amit Pundir [Mon, 21 Dec 2015 08:33:15 +0000 (14:03 +0530)]
usb: gadget: rndis: fix broken build for 4.4

Use rndis_params instead of configNr to align with
changes from mainline commit 83210e59ee15
"usb: gadget: rndis: use rndis_params instead of configNr".

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: gadget: rndis: fix broken data aggregation build
Amit Pundir [Mon, 21 Dec 2015 08:45:58 +0000 (14:15 +0530)]
usb: gadget: rndis: fix broken data aggregation build

Declare "cdev" to fix broken AOSP commit
"RNDIS: Add Data aggregation (multi packet) support",
otherwise we run into following build failure:

  CC      drivers/usb/gadget/function/f_rndis.o
drivers/usb/gadget/function/f_rndis.c: In function ‘rndis_command_complete’:
drivers/usb/gadget/function/f_rndis.c:479:3: error: ‘cdev’ undeclared (first use in this function)
drivers/usb/gadget/function/f_rndis.c:479:3: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [drivers/usb/gadget/function/f_rndis.o] Error 1

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: gadget: rndis: use %z format specifier for size_t
Amit Pundir [Tue, 29 Dec 2015 21:35:44 +0000 (03:05 +0530)]
usb: gadget: rndis: use %z format specifier for size_t

Use '%z' format specifier for sizeof operator instead
of '%u' to fix build warnings like:

    warning: format '%u' expects type 'unsigned int', but argument 3 has type 'long unsigned int'

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: gadget: cleanup: fix unused variable and function warnings
Amit Pundir [Tue, 25 Aug 2015 07:39:31 +0000 (13:09 +0530)]
usb: gadget: cleanup: fix unused variable and function warnings

Remove unused variables and functions to fix following
build warnings:

  CC      drivers/usb/gadget/configfs.o
drivers/usb/gadget/configfs.c: In function ‘gadgets_make’:
drivers/usb/gadget/configfs.c:1710:6: warning: unused variable ‘err’ [-Wunused-variable]
  int err;
      ^
drivers/usb/gadget/configfs.c:1709:27: warning: unused variable ‘attr’ [-Wunused-variable]
  struct device_attribute *attr;
                           ^
drivers/usb/gadget/configfs.c:1708:28: warning: unused variable ‘attrs’ [-Wunused-variable]
  struct device_attribute **attrs;
                            ^
drivers/usb/gadget/configfs.c: In function ‘gadgets_drop’:
drivers/usb/gadget/configfs.c:1774:27: warning: unused variable ‘attr’ [-Wunused-variable]
  struct device_attribute *attr;
                           ^
drivers/usb/gadget/configfs.c:1773:28: warning: unused variable ‘attrs’ [-Wunused-variable]
  struct device_attribute **attrs;
                            ^
<snip>...
  CC      drivers/usb/gadget/function/f_mtp.o
drivers/usb/gadget/function/f_mtp.c:1219:12: warning: ‘mtp_bind_config’ defined but not used [-Wunused-function]
 static int mtp_bind_config(struct usb_configuration *c, bool ptp_config)
            ^
drivers/usb/gadget/function/f_mtp.c:1300:12: warning: ‘mtp_setup’ defined but not used [-Wunused-function]
 static int mtp_setup(void)
            ^
<snip>...
  CC      drivers/usb/gadget/function/f_accessory.o
drivers/usb/gadget/function/f_accessory.c:969:1: warning: ‘acc_function_bind’ defined but not used [-Wunused-function]
 acc_function_bind(struct usb_configuration *c, struct usb_function *f) {
 ^
drivers/usb/gadget/function/f_accessory.c:1172:12: warning: ‘acc_bind_config’ defined but not used [-Wunused-function]
 static int acc_bind_config(struct usb_configuration *c)
            ^

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: gadget: build audio_source function only if SND is enabled
Amit Pundir [Thu, 29 Oct 2015 21:30:20 +0000 (03:00 +0530)]
usb: gadget: build audio_source function only if SND is enabled

Also select SND_PCM while building f_audio_source
otherwise we run into following build error:

  LD      init/built-in.o
drivers/built-in.o: In function `audio_data_complete':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:458: undefined reference to `snd_pcm_period_elapsed'
drivers/built-in.o: In function `audio_pcm_hw_free':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:770: undefined reference to `snd_pcm_lib_free_vmalloc_buffer'
drivers/built-in.o: In function `snd_pcm_lib_alloc_vmalloc_buffer':
/linaro/android/kernel/linaro-android/include/sound/pcm.h:1179: undefined reference to `_snd_pcm_lib_alloc_vmalloc_buffer'
drivers/built-in.o: In function `audio_pcm_open':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:734: undefined reference to `snd_pcm_limit_hw_rates'
drivers/built-in.o: In function `snd_card_setup':
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:888: undefined reference to `snd_pcm_new'
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:898: undefined reference to `snd_pcm_set_ops'
/linaro/android/kernel/linaro-android/drivers/usb/gadget/function/f_audio_source.c:899: undefined reference to `snd_pcm_lib_preallocate_pages_for_all'
drivers/built-in.o:(.data+0x1fd28): undefined reference to `snd_pcm_lib_ioctl'
make: *** [vmlinux] Error 1

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: gadget: configfs: handle gadget reset request for android
Amit Pundir [Tue, 6 Oct 2015 15:23:27 +0000 (20:53 +0530)]
usb: gadget: configfs: handle gadget reset request for android

There is this new mandatory UDC->reset API in v3.18+ kernels,
commit ef979a26 "usb: gadget: add reset API at usb_gadget_driver".

Let android_disconnect handle that for Android, similar to
how composite_disconnect is handling the generic ConfigFS
gadget reset request.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agoANDROID: usb: gadget: create F_midi device
Badhri Jagan Sridharan [Thu, 3 Sep 2015 05:49:10 +0000 (22:49 -0700)]
ANDROID: usb: gadget: create F_midi device

Android frameworks relies on the alsa
config reported by the f_midi device.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I0695e00b166fd953f50acea93802245b0d5a5240

8 years agousb: gadget: Add device attribute to determine gadget state
Badhri Jagan Sridharan [Sun, 9 Aug 2015 22:12:50 +0000 (15:12 -0700)]
usb: gadget: Add device attribute to determine gadget state

Android frameworks (UsbDeviceManager) relies on gadget state exported
through device attributes.  This CL adds the device attribute to export
USB gadget state.

Change-Id: Id0391810d75b58c579610fbec6e37ab22f28886d
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
8 years agousb: phy: fix dual role sysfs build if kernel modules are supported
Amit Pundir [Wed, 2 Sep 2015 11:08:31 +0000 (16:38 +0530)]
usb: phy: fix dual role sysfs build if kernel modules are supported

Add a missing ";" after EXPORT_SYMBOL() otherwise we run
into following build error if Kernel Modules are supported:
----------
  CC      drivers/usb/phy/class-dual-role.o
drivers/usb/phy/class-dual-role.c:91:1: error: expected ',' or ';' before 'int'
 int dual_role_get_property(struct dual_role_phy_instance *dual_role,
 ^
make[3]: *** [drivers/usb/phy/class-dual-role.o] Error 1
----------

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: phy: Dual role sysfs class definition
Badhri Jagan Sridharan [Tue, 1 Sep 2015 04:36:07 +0000 (21:36 -0700)]
usb: phy: Dual role sysfs class definition

This CL adds a new class to monitor and change
dual role usb ports from userspace. The usb
phy drivers can register to the dual_role_usb
class and expose the capabilities of the ports.
The phy drivers can decide on whether a specific
attribute can be changed from userspace by
choosing to implement the appropriate callback.

Cherry-picked from
https://android-review.googlesource.com/#/c/167310/

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Bug: 21615151
Change-Id: Id1c4aaa97e898264d7006381a7badd029b5d9789

8 years agousb: gadget: fix NULL ptr derefer while symlinking PTP func
Amit Pundir [Fri, 31 Jul 2015 21:56:51 +0000 (03:26 +0530)]
usb: gadget: fix NULL ptr derefer while symlinking PTP func

Fix NULL pointer dereference while trying to link PTP
function to a gadget configuration without creating
MTP function.

PTP piggyback on MTP function so make sure we have
MTP function created beforehand. Otherwise we run
into following kernel panic:
-----------------------
[   70.329957] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[   70.330738] pgd = dd8ec000
[   70.330916] [00000000] *pgd=00000000
[   70.331663] Internal error: Oops: 805 [#1] SMP THUMB2
[   70.332155] CPU: 0 PID: 2067 Comm: ln Not tainted 3.18.0-00587-gdfa582e #1
[   70.332511] task: dd9c92c0 ti: dd822000 task.ti: dd822000
[   70.333094] PC is at function_alloc_mtp_ptp+0xe/0x68
[   70.333311] LR is at usb_get_function+0x11/0x1c
[   70.333489] pc : [<c034ec12>]    lr : [<c033cce9>]    psr: 60070033
<..snip..>
[   70.384111] 3fc0: bec14ae4 00000004 bec14c0a 00000053 00000004 b6f0422d 00000000 bec14adc
[   70.384369] 3fe0: bec14af8 bec14a98 b6f071f3 b6e8977c 20070010 bec14c0d 00000000 00000000
[   70.384832] [<c034ec12>] (function_alloc_mtp_ptp) from [<c033cce9>] (usb_get_function+0x11/0x1c)
[   70.385146] [<c033cce9>] (usb_get_function) from [<c033da9b>] (config_usb_cfg_link+0x87/0xa8)
[   70.385421] [<c033da9b>] (config_usb_cfg_link) from [<c011f417>] (configfs_symlink+0xb7/0x1c8)
[   70.385696] [<c011f417>] (configfs_symlink) from [<c00dcd8d>] (vfs_symlink+0x85/0xc0)
[   70.386010] [<c00dcd8d>] (vfs_symlink) from [<c00dce0b>] (SyS_symlinkat+0x43/0x70)
[   70.386261] [<c00dce0b>] (SyS_symlinkat) from [<c000ce41>] (ret_fast_syscall+0x1/0x5c)
[   70.386610] Code: eb04 4a0f 6e03 480f (e883) 0005
[   70.387346] ---[ end trace 8dba7c552e02f8fa ]---
[   70.387647] Kernel panic - not syncing: Fatal exception
[   70.387980] ---[ end Kernel panic - not syncing: Fatal exception
-----------------------

Steps to reproduce the kernel panic:

mount -t configfs none /config
mkdir /config/usb_gadget/g1
cd /config/usb_gadget/g1
echo 0x18d1 > idVendor
echo 0x4e26 > idProduct
mkdir strings/0x409
echo 0123459876 > strings/0x409/serialnumber
echo Asus > strings/0x409/manufacturer
echo Nexus7 > strings/0x409/product
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "Conf 1" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower
mkdir functions/ptp.ptp
ln -s functions/ptp.ptp configs/c.1/ptp.ptp

Also MTP and PTP are mutually exclusive functions
so make sure we have only one of it linked to a
configuration at a time. Otherwise it opens up
another set of bug(s?).

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb:gadget:Add "state" attribute to android_device
Badhri Jagan Sridharan [Tue, 14 Jul 2015 22:46:11 +0000 (15:46 -0700)]
usb:gadget:Add "state" attribute to android_device

Added a device attribute to android_device to
determine USB_GADGET's state

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I17f8903120df96bf2f4bf441940b53a87b818230

8 years agousb: gadget: Do not disconnect unregistered dev
Badhri Jagan Sridharan [Wed, 6 May 2015 20:40:15 +0000 (13:40 -0700)]
usb: gadget: Do not disconnect unregistered dev

configfs_composite_unbind sets the gadget data
to null. Therefore, add check in disconnect
function to make sure that cdev is not NULL.
Prints a WARN message if the driver tries to
redundantly disconnect a gadget.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I248cb7175d0dd9a51c18053dd39475d8b3284f6d

8 years agousb: gadget: Relocate f_accessory
Badhri Jagan Sridharan [Mon, 30 Mar 2015 22:32:22 +0000 (15:32 -0700)]
usb: gadget: Relocate f_accessory

3.18 kernel has reorganized drivers/usb/gadget
directory. Moving accessory gadget driver from
drivers/usb/gadget to drivers/usb/gadget/function

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: If73c6df0537c4b1f51338ed3b0db817e51f06b4a

8 years agousb: gadget: Accessory:Migrate to USB_FUNCTION API
Badhri Jagan Sridharan [Mon, 24 Nov 2014 01:21:22 +0000 (17:21 -0800)]
usb: gadget: Accessory:Migrate to USB_FUNCTION API

This patch adds support to use Android accessory
gadget function through the
DECLARE_USB_FUNCTION_INIT interface.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: Ib352752d5bc905fa1df9049b53eabf1294930db7

8 years agousb: gadget: Move gadget functions code
Badhri Jagan Sridharan [Fri, 27 Mar 2015 21:49:55 +0000 (14:49 -0700)]
usb: gadget: Move gadget functions code

3.18 kernel has reorganized drivers/usb/gadget
directory. Moving gadget functions drivers from
drivers/usb/gadget to drivers/usb/gadget/function

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I1eab0190f8d42e3be1b4e91ad3bc3a2dc853b0ef

8 years agousb:gadget:audio_source: Move to USB_FUNCTION API
Badhri Jagan Sridharan [Sun, 23 Nov 2014 21:51:28 +0000 (13:51 -0800)]
usb:gadget:audio_source: Move to USB_FUNCTION API

This patch adds support to use audio_source
gadget function through DECLARE_USB_FUNCTION_INIT
interface.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I1fc6c9ea07105ae4eb785eebd3bb925bfdd8bc6b

8 years agousb: gadget: Add function devices to the parent
Badhri Jagan Sridharan [Fri, 27 Mar 2015 21:15:19 +0000 (14:15 -0700)]
usb: gadget: Add function devices to the parent

Added create_function_device to create child
function devices for USB gadget functions.
Android UsbDeviceManager relies on communicating
to the devices created by the gadget functions
to implement functions such as audio_source.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I0df9ad86ac32d8cdacdea164e9fed49891b45fc2

8 years agousb: gadget: f_audio_source:replace deprecated API
Badhri Jagan Sridharan [Wed, 25 Mar 2015 21:37:23 +0000 (14:37 -0700)]
usb: gadget: f_audio_source:replace deprecated API

Replace snd_card_create with snd_card_new.
snd_card_create depcrecated starting form v3.15

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I76f7d753812963d595055bce7d3e6518163482f5

8 years agousb: gadget: check for accessory device before disconnecting HIDs
Amit Pundir [Fri, 16 Jan 2015 00:11:10 +0000 (05:41 +0530)]
usb: gadget: check for accessory device before disconnecting HIDs

While disabling ConfigFS Android gadget, android_disconnect() calls
kill_all_hid_devices(), if CONFIG_USB_CONFIGFS_F_ACC is enabled, to free
the registered HIDs without checking whether the USB accessory device
really exist or not. If USB accessory device doesn't exist then we run into
following kernel panic:
----8<----
[  136.724761] Unable to handle kernel NULL pointer dereference at virtual address 00000064
[  136.724809] pgd = c0204000
[  136.731924] [00000064] *pgd=00000000
[  136.737830] Internal error: Oops: 5 [#1] SMP ARM
[  136.738108] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.18.0-rc4-00400-gf75300e-dirty #76
[  136.742788] task: c0fb19d8 ti: c0fa4000 task.ti: c0fa4000
[  136.750890] PC is at _raw_spin_lock_irqsave+0x24/0x60
[  136.756246] LR is at kill_all_hid_devices+0x24/0x114
---->8----

This patch adds a test to check if USB Accessory device exists before freeing HIDs.

Change-Id: Ie229feaf0de3f4f7a151fcaa9a994e34e15ff73b
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agousb: u_ether: Fix compile errors
Praneeth Bajjuri [Thu, 22 Jan 2015 22:38:56 +0000 (16:38 -0600)]
usb: u_ether: Fix compile errors

commit f1a1823ff24fa4e3412b5078f20021cf40834946
usb: gadget: u_ether: convert into module

changes qlen function definition. and this has to be fixed
accordingly in current u_ether driver.

This patch fixes following compile error in u_ether caused by commit.

drivers/usb/gadget/u_ether.c: In function 'rx_fill':
drivers/usb/gadget/u_ether.c:416:3: error: too few arguments to function 'qlen'
   if (++req_cnt > qlen(dev->gadget))
   ^

drivers/usb/gadget/u_ether.c: In function 'eth_start_xmit':
drivers/usb/gadget/u_ether.c:738:24: error: 'qmult' undeclared (first use in this function)
   if (dev->tx_qlen == (qmult/2)) {

which was caused by commits
commit 79467317949e1621240f632acfb7453783bec2e7
USB: gadget: u_ether: Fix data stall issue in RNDIS tethering mode

commit 68b91e8c54f5c091986c5719631893b10eab760a
usb: u_ether: Add workqueue as bottom half handler for rx data path

Change-Id: Ic4e5a1e08cb688e5a606c7c1895f869d8f887b9f
Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
8 years agousb: gadget: Add Uevent to notify userspace
Badhri Jagan Sridharan [Mon, 15 Dec 2014 18:44:47 +0000 (10:44 -0800)]
usb: gadget: Add Uevent to notify userspace

Android userspace UsbDeviceManager relies on the
uevents generated by the composition driver to
generate user notifications. This CL adds uevents
to be generated whenever USB changes its state
i.e. connected, disconnected, configured.

This CL also intercepts the setup requests from
the usb_core anb routes it to the specific
usb function if required.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: Ib3d3a78255a532f7449dac286f776c2966caf8c1

8 years agousb: gadget: configfs: Add usb_function ptr to fi struct
Badhri Jagan Sridharan [Tue, 16 Dec 2014 00:42:27 +0000 (16:42 -0800)]
usb: gadget: configfs: Add usb_function ptr to fi struct

Add a pointer to the usb_function inside the
usb_function_instance structure to service
functions specific setup requests even before
the function gets added to the usb_gadget

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I6f457006f6c5516cc6986ec2acdf5b1ecf259d0c

8 years agousb: gadget: mtp/ptp: Migrate functions to the USB_FUNCTION interface
Badhri Jagan Sridharan [Tue, 18 Nov 2014 05:11:23 +0000 (21:11 -0800)]
usb: gadget: mtp/ptp: Migrate functions to the USB_FUNCTION interface

This patch adds support to use mtp/ptp gadget functions
through the DECLARE_USB_FUNCTION_INIT interface.

enabling USB_CONFIGFS_F_MTP config compiles f_mtp.c
thereby providing support for MTP gadget

enabling USB_CONFIGFS_F_PTP config compiles f_ptp.c
thereby providing support for PTP gadget

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Change-Id: I38d7b570e8886d155ef10cd2c839b2232dcb3158