firefly-linux-kernel-4.4.55.git
8 years agopower: wakeup_reason: rename irq_count to irqcount
Greg Hackmann [Mon, 10 Mar 2014 21:21:30 +0000 (14:21 -0700)]
power: wakeup_reason: rename irq_count to irqcount

On x86, irq_count conflicts with a declaration in
arch/x86/include/asm/processor.h

Change-Id: I3e4fde0ff64ef59ff5ed2adc0ea3a644641ee0b7
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agoPower: Add guard condition for maximum wakeup reasons
Ruchi Kandoi [Fri, 7 Mar 2014 20:54:30 +0000 (12:54 -0800)]
Power: Add guard condition for maximum wakeup reasons

Ensure the array for the wakeup reason IRQs does not overflow.

Change-Id: Iddc57a3aeb1888f39d4e7b004164611803a4d37c
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
(cherry picked from commit b5ea40cdfcf38296535f931a7e5e7bf47b6fad7f)

8 years agoPOWER: fix compile warnings in log_wakeup_reason
Ruchi Kandoi [Fri, 21 Feb 2014 03:47:38 +0000 (19:47 -0800)]
POWER: fix compile warnings in log_wakeup_reason

Change I81addaf420f1338255c5d0638b0d244a99d777d1 introduced compile
warnings, fix these.

Change-Id: I05482a5335599ab96c0a088a7d175c8d4cf1cf69
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agoPower: add an API to log wakeup reasons
Ruchi Kandoi [Wed, 19 Feb 2014 23:30:47 +0000 (15:30 -0800)]
Power: add an API to log wakeup reasons

Add API log_wakeup_reason() and expose it to userspace via sysfs path
/sys/kernel/wakeup_reasons/last_resume_reason

Change-Id: I81addaf420f1338255c5d0638b0d244a99d777d1
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agoPM / Suspend: Print wall time at suspend entry and exit
Todd Poynor [Wed, 30 May 2012 00:33:56 +0000 (17:33 -0700)]
PM / Suspend: Print wall time at suspend entry and exit

Change-Id: I92f252414c013b018b9a392eae1ee039aa0e89dc
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agodrivers: power: Add watchdog timer to catch drivers which lockup during suspend.
Benoit Goby [Thu, 13 Aug 2009 16:40:42 +0000 (09:40 -0700)]
drivers: power: Add watchdog timer to catch drivers which lockup during suspend.

Rather than hard-lock the kernel, dump the suspend thread stack and
BUG() when a driver takes too long to suspend.  The timeout is set
to 12 seconds to be longer than the usbhid 10 second timeout.

Exclude from the watchdog the time spent waiting for children that
are resumed asynchronously and time every device, whether or not they
resumed synchronously.

Change-Id: Ifd211c06b104860c2fee6eecfe0d61774aa4508a
Original-author: San Mehat <san@google.com>
Signed-off-by: Benoit Goby <benoit@android.com>
8 years agopower: power_supply: add POWER_SUPPLY_PROP_CHARGE_ENABLED
Todd Poynor [Wed, 18 Jul 2012 23:28:50 +0000 (16:28 -0700)]
power: power_supply: add POWER_SUPPLY_PROP_CHARGE_ENABLED

Change-Id: I3e93b502452811cbfc4d904202b4f1d94edc143d
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agopower: power_supply: add POWER_SUPPLY_PROP_USB_OTG
Todd Poynor [Fri, 13 Jul 2012 20:30:04 +0000 (13:30 -0700)]
power: power_supply: add POWER_SUPPLY_PROP_USB_OTG

Change-Id: Idfc6ef2e37d62aad6f26cc8eafa53db642cd352b
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agopower: power_supply: move POWER_SUPPLY_PROP_USB_HC to type 'int' order
Todd Poynor [Fri, 13 Jul 2012 03:27:16 +0000 (20:27 -0700)]
power: power_supply: move POWER_SUPPLY_PROP_USB_HC to type 'int' order

Change-Id: I001af30ab5fe06dde5f368241f21b9e0864777a1
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agopower_supply: Add custom property for USB High Current mode
Todd Poynor [Tue, 3 Jul 2012 22:41:20 +0000 (15:41 -0700)]
power_supply: Add custom property for USB High Current mode

For smb347.

Change-Id: I3323469072e1ee5085d61af8a89612b06b91f94a
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agotrace: power: add trace_clock_set_parent
Colin Cross [Wed, 9 May 2012 23:09:50 +0000 (16:09 -0700)]
trace: power: add trace_clock_set_parent

Adds a new trace event to be called from clk_set_parent.  Some
cpufreq drivers, including Tegra, reparent the cpu clock to a
slower clock while the main pll is relocking, tracing
clk_set_parent allows traces to show how for long the cpu is
running slower.

Uses a separate TRACE_EVENT instead of the clock event class to
allow the event to contain string names for the child and the
parent.

Signed-off-by: Colin Cross <ccross@android.com>
8 years agomisc seq_printf fixes for 4.4
Amit Pundir [Thu, 1 Oct 2015 05:14:36 +0000 (10:44 +0530)]
misc seq_printf fixes for 4.4

Update seq_printf() usage in aosp patches to align
with changes from mainline commit 6798a8caaf64
"fs/seq_file: convert int seq_vprint/seq_printf/etc...
returns to void".

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agomisc: uidstat: Remove use of obsolete create_proc_read_entry api
Arve Hjønnevåg [Tue, 14 May 2013 03:34:22 +0000 (20:34 -0700)]
misc: uidstat: Remove use of obsolete create_proc_read_entry api

Signed-off-by: Arve Hjønnevåg <arve@android.com>
8 years agomisc: uidstat: avoid create_stat() race and blockage.
JP Abgrall [Thu, 30 May 2013 22:31:17 +0000 (15:31 -0700)]
misc: uidstat: avoid create_stat() race and blockage.

* create_stat() race would lead to:
  [   58.132324] proc_dir_entry 'uid_stat/10061' already registered

* blocking kmalloc reported by sbranden
 tcp_read_sock()
  uid_stat_tcp_rcv()
    create_stat()
      kmalloc(GFP_KERNEL)

Signed-off-by: JP Abgrall <jpa@google.com>
8 years agotrace: cpufreq: Add tracing for min/max cpufreq
Ruchi Kandoi [Fri, 20 Nov 2015 00:07:19 +0000 (16:07 -0800)]
trace: cpufreq: Add tracing for min/max cpufreq

Change-Id: I73f6ec437c1f805437d9376abb6510d1364b07ec
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agotracing/sched: Add trace events to track cpu hotplug.
Arun Bharadwaj [Wed, 3 Jul 2013 17:35:02 +0000 (10:35 -0700)]
tracing/sched: Add trace events to track cpu hotplug.

Add ftrace event trace_sched_cpu_hotplug to track cpu
hot-add and hot-remove events.

This is useful in a variety of power, performance and
debug analysis scenarios.

Change-Id: I5d202c7a229ffacc3aafb7cf9afee0b0ee7b0931
Signed-off-by: Arun Bharadwaj <abharadw@codeaurora.org>
8 years agotrace: fix compilation for 4.1
Dmitry Shmidt [Wed, 28 Oct 2015 17:45:04 +0000 (10:45 -0700)]
trace: fix compilation for 4.1

Change-Id: Id88b5d30847bc6d3cfe1d8cd00cbdc975c9712d1
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
8 years agommc: Add tracepoints of mmc block operations
Ken Sumrall [Thu, 16 May 2013 03:13:13 +0000 (20:13 -0700)]
mmc: Add tracepoints of mmc block operations

Add tracepoints to record the start and end of each mmc block
operation.  This includes read, write, erase, secure erase,
trim, secure trim1 and secure trim 2, discard and
sanitize commands.

Change-Id: Ic5d1cbdb9adb940d8b1a2a13c73970023575df50
Signed-off-by: Ken Sumrall <ksumrall@android.com>
8 years agotrace/events: fix gpu event timestamp formatting
Jamie Gennis [Fri, 19 Apr 2013 03:36:21 +0000 (20:36 -0700)]
trace/events: fix gpu event timestamp formatting

This change fixes the how the gpu_sched_switch timestamp field is formatted.

Signed-off-by: Jamie Gennis <jgennis@google.com>
Change-Id: I273234935254ed15772c9e561c9af20e480004ae

8 years agotrace: add non-hierarchical function_graph option
Jamie Gennis [Thu, 22 Nov 2012 04:14:09 +0000 (20:14 -0800)]
trace: add non-hierarchical function_graph option

Add the 'funcgraph-flat' option to the function_graph tracer to use the default
trace printing format rather than the hierarchical formatting normally used.

Change-Id: If2900bfb86e6f8f51379f56da4f6fabafa630909
Signed-off-by: Jamie Gennis <jgennis@google.com>
8 years agotrace: Add an option to show tgids in trace output
Jamie Gennis [Wed, 21 Nov 2012 23:04:25 +0000 (15:04 -0800)]
trace: Add an option to show tgids in trace output

The tgids are tracked along side the saved_cmdlines tracking, and can be
included in trace output by enabling the 'print-tgid' trace option. This is
useful when doing post-processing of the trace data, as it allows events to be
grouped by tgid.

Change-Id: I52ed04c3a8ca7fddbb868b792ce5d21ceb76250e
Signed-off-by: Jamie Gennis <jgennis@google.com>
8 years agotrace/events: add gpu trace events
Jamie Gennis [Fri, 22 Feb 2013 01:55:28 +0000 (17:55 -0800)]
trace/events: add gpu trace events

Change-Id: I0607b9c776acf61cb796b8572cf8cfb8b2dc1377
Signed-off-by: Jamie Gennis <jgennis@google.com>
8 years agoCHROMIUM: android: Unconditionally remove callbacks in sync_fence_free()
Andrew Bresticker [Mon, 12 Oct 2015 20:31:45 +0000 (13:31 -0700)]
CHROMIUM: android: Unconditionally remove callbacks in sync_fence_free()

Using fence->status to determine whether or not there are callbacks
remaining on the sync_fence is racy since fence->status may have been
decremented to 0 on another CPU before fence_check_cb_func() has
completed.  By unconditionally calling fence_remove_callback() for each
fence in the sync_fence, we guarantee that each callback has either
completed (since fence_remove_callback() grabs the fence lock) or been
removed.

BUG=chrome-os-partner:46382
TEST=Reboot cycle test on Smaug; no crashes seen.

Change-Id: I837180ef633aed3c5ae1e52e0d6ded838342b8fa
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305331
Reviewed-by: Puneet Kumar <puneetster@chromium.org>
8 years agoCHROMIUM: android: fix warning when releasing active sync point
Dmitry Torokhov [Wed, 9 Sep 2015 00:30:52 +0000 (17:30 -0700)]
CHROMIUM: android: fix warning when releasing active sync point

Userspace can close the sync device while there are still active fence
points, in which case kernel produces the following warning:

[   43.853176] ------------[ cut here ]------------
[   43.857834] WARNING: CPU: 0 PID: 892 at /mnt/host/source/src/third_party/kernel/v3.18/drivers/staging/android/sync.c:439 android_fence_release+0x88/0x104()
[   43.871741] CPU: 0 PID: 892 Comm: Binder_5 Tainted: G     U 3.18.0-07661-g0550ce9 #1
[   43.880176] Hardware name: Google Tegra210 Smaug Rev 1+ (DT)
[   43.885834] Call trace:
[   43.888294] [<ffffffc000207464>] dump_backtrace+0x0/0x10c
[   43.893697] [<ffffffc000207580>] show_stack+0x10/0x1c
[   43.898756] [<ffffffc000ab1258>] dump_stack+0x74/0xb8
[   43.903814] [<ffffffc00021d414>] warn_slowpath_common+0x84/0xb0
[   43.909736] [<ffffffc00021d530>] warn_slowpath_null+0x14/0x20
[   43.915482] [<ffffffc00088aefc>] android_fence_release+0x84/0x104
[   43.921582] [<ffffffc000671cc4>] fence_release+0x104/0x134
[   43.927066] [<ffffffc00088b0cc>] sync_fence_free+0x74/0x9c
[   43.932552] [<ffffffc00088b128>] sync_fence_release+0x34/0x48
[   43.938304] [<ffffffc000317bbc>] __fput+0x100/0x1b8
[   43.943185] [<ffffffc000317cc8>] ____fput+0x8/0x14
[   43.947982] [<ffffffc000237f38>] task_work_run+0xb0/0xe4
[   43.953297] [<ffffffc000207074>] do_notify_resume+0x44/0x5c
[   43.958867] ---[ end trace 5a2aa4027cc5d171 ]---

Let's fix it by introducing a new optional callback (disable_signaling)
to fence operations so that drivers can do proper clean ups when we
remove last callback for given fence.

BUG=chrome-os-partner:40303
TEST=Boot Smaug and observe that warning is gone.

Change-Id: I05c34dcf74438c28405438c7ead0706b1f810fff
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/303409
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
8 years agosync: add Documentation/sync.txt
Erik Gilling [Fri, 14 Sep 2012 21:36:34 +0000 (14:36 -0700)]
sync: add Documentation/sync.txt

Change-Id: Ic7f3a6d4622083be607b82ddd8d676609225bb8f
Signed-off-by: Erik Gilling <konkers@android.com>
8 years agovideo: adf: build fixes for 4.1
Amit Pundir [Mon, 6 Jul 2015 19:39:40 +0000 (01:09 +0530)]
video: adf: build fixes for 4.1

Couple of ADF build fixes for v4.1

adf/adf_fops.c fix:
get_unused_fd() is obsolete, use get_unused_fd_flags(O_CLOEXEC)
instead to allocate a default file descriptor. This fix is a
followup of upstream commit f938612dd97d "include/linux/file.h:
remove get_unused_fd() macro".

adf/adf_memblock.c fix:
Fix dma_buf_export() call. Based on mainline commit d8fbe341beb6
"dma-buf: cleanup dma_buf_export() to make it easily extensible".

Otherwise we run into following build failures:
----------
  CC      drivers/video/adf/adf_fops.o
  CC      drivers/video/adf/adf_memblock.o
drivers/video/adf/adf_memblock.c: In function ‘adf_memblock_export’:
drivers/video/adf/adf_memblock.c:154:2: warning: passing argument 1 of ‘dma_buf_export’ from incompatible pointer type [enabled by default]
In file included from drivers/video/adf/adf_memblock.c:15:0:
include/linux/dma-buf.h:211:17: note: expected ‘const struct dma_buf_export_info *’ but argument is of type ‘struct adf_memblock_pdata *’
drivers/video/adf/adf_memblock.c:154:2: error: too many arguments to function ‘dma_buf_export’
In file included from drivers/video/adf/adf_memblock.c:15:0:
include/linux/dma-buf.h:211:17: note: declared here
make[3]: *** [drivers/video/adf/adf_memblock.o] Error 1
make[3]: *** Waiting for unfinished jobs....
drivers/video/adf/adf_fops.c: In function ‘adf_device_post_config’:
drivers/video/adf/adf_fops.c:228:2: error: implicit declaration of function ‘get_unused_fd’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[3]: *** [drivers/video/adf/adf_fops.o] Error 1
make[2]: *** [drivers/video/adf] Error 2
make[2]: *** Waiting for unfinished jobs....
----------

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agovideo: adf: fix memblock build failure
Amit Pundir [Wed, 1 Apr 2015 11:14:44 +0000 (16:44 +0530)]
video: adf: fix memblock build failure

Pass 'NULL' as the 5th argument to dma_buf_export() to fix
the following build failure:
----------
  CC      drivers/video/adf/adf_memblock.o
drivers/video/adf/adf_memblock.c: In function ‘adf_memblock_export’:
drivers/video/adf/adf_memblock.c:154:60: error: macro "dma_buf_export" requires 5 arguments, but only 4 given
drivers/video/adf/adf_memblock.c:154:8: error: ‘dma_buf_export’ undeclared (first use in this function)
drivers/video/adf/adf_memblock.c:154:8: note: each undeclared identifier is reported only once for each function it appears in
make[3]: *** [drivers/video/adf/adf_memblock.o] Error 1
make[2]: *** [drivers/video/adf] Error 2
----------

5th argument to dma_buf_export() is a pointer to 'reservation-object'
and a new 'reservation-object' is allocated in case 'NULL' is passed.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agovideo: adf: fix wrong bitops in adf_modeinfo_to_fb_videomode()
Greg Hackmann [Tue, 16 Dec 2014 23:59:51 +0000 (15:59 -0800)]
video: adf: fix wrong bitops in adf_modeinfo_to_fb_videomode()

Change-Id: I1296153e382c0b66b713a0e7d09665ed5961f13d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
8 years agovideo: adf: Cleanup sw_sync timeline at adf_device_destroy
Jonathan Hamilton [Thu, 17 Jul 2014 22:54:44 +0000 (15:54 -0700)]
video: adf: Cleanup sw_sync timeline at adf_device_destroy

If a sw_sync timeline was created by ADF (for drivers that do not implement
ops->complete_fence) we should clean it up when the ADF device is
destroyed.

Change-Id: Idd90180fcae56a87111f7d12bdd80190756a6b80
Signed-off-by: Jonathan Hamilton <jonathan.hamilton@imgtec.com>
8 years agovideo: adf: fbdev: add stubs for kernels without ADF_FBDEV
Greg Hackmann [Tue, 29 Apr 2014 18:18:45 +0000 (11:18 -0700)]
video: adf: fbdev: add stubs for kernels without ADF_FBDEV

Change-Id: I42e087cddc29f6b93749791606e80dbd3e6f59ce
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: memblock: map buffer for dma
Greg Hackmann [Tue, 29 Apr 2014 00:00:44 +0000 (17:00 -0700)]
video: adf: memblock: map buffer for dma

Change-Id: I4df13c8b45b57fd0594b5e7bf351a4da33a8cb11
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: use rb_erase in adf_obj_destroy.
Alistair Strachan [Mon, 21 Apr 2014 20:09:23 +0000 (13:09 -0700)]
video: adf: use rb_erase in adf_obj_destroy.

Not calling rb_erase() can cause slab corruption, as the rb_first() call
after kfree() in adf_obj_destroy() can return the same node twice unless
it is erased.

This problem was reproduced by unloading a kernel module that used the
adf framework *after* a vsync event was registered. A crash would occur
in rb_first(). (Just loading and immediately unloading the module without
the vsync event worked correctly.)

Change-Id: I9fa7cb5d7519691e38a281439844aa193da13d1b
Signed-off-by: Alistair Strachan <alistair.strachan@imgtec.com>
Cc: Jonathan Hamilton <jonathan.hamilton@imgtec.com>
Cc: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: adf_memblock_export symbol should be exported
Greg Hackmann [Tue, 8 Apr 2014 20:07:29 +0000 (13:07 -0700)]
video: adf: adf_memblock_export symbol should be exported

Change-Id: I228db28da885b47b6fa9fc7e4001663797d24f49
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add buffer padding quirk
Greg Hackmann [Tue, 8 Apr 2014 19:36:41 +0000 (12:36 -0700)]
video: adf: add buffer padding quirk

Quirks specify common behaviors that vary slightly among devices, and
which ADF must account for.

The buffer padding quirk captures the way different devices fetch the
last scanline in a buffer: some devices fetch an entire line (including
padding to the pitch) while others only fetch up to the visible width.
ADF's buffer size validation now takes this quirk into account.

Change-Id: I828b13316e27621d8a9efd9d5fffa6ce12a525ff
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: document adf_format_validate_yuv's origin
Greg Hackmann [Tue, 8 Apr 2014 19:25:12 +0000 (12:25 -0700)]
video: adf: document adf_format_validate_yuv's origin

Change-Id: I929045a96a56bdb2c915be92b8ef11b560f3ab79
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: ensure consistent alignment on userspace facing structs
Greg Hackmann [Wed, 26 Mar 2014 23:43:23 +0000 (16:43 -0700)]
video: adf: ensure consistent alignment on userspace facing structs

64-bit types in structs create alignment problems when a 32-bit x86
userspace talks to an x86_64 kernel.  In most cases the 64-bit types can
be replaced with 32-bit ones, since they're being used for fds and
should have been __s32 in the first place.  For adf_vsync_event,
alignment can be enforced by making the timestamp an __aligned_u64.

Change-Id: I87cf73d8f57730bd7bb43ffce6b7b411eb0ff198
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: replace fbdev helper's open flag with refcount
Greg Hackmann [Mon, 24 Mar 2014 23:45:43 +0000 (16:45 -0700)]
video: adf: replace fbdev helper's open flag with refcount

A device's fb_info is shared between clients.  fb_release() is called
when each client is released, not just the last one.  Since the fbdev
helper needs to release its dma-buf when the last client goes away, it
must keep its own reference count.

fbmem and fbcon hold different locks while calling fb_release(), so
explicit locking is needed.

Change-Id: I42cd659f7633adba7c11f407d4b594bd43305d6a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: export the adf_attachment_allow symbol to modules.
Alistair Strachan [Tue, 11 Mar 2014 00:00:25 +0000 (17:00 -0700)]
video: adf: export the adf_attachment_allow symbol to modules.

There are no in-tree users of adf_attachment_allow, but out-of-tree
modules want to use it. It looks like this function should be
EXPORT_SYMBOL.

Change-Id: Iad522dc5d32ac09fec6483bbc317db8ecae12e97
Signed-off-by: Alistair Strachan <alistair.strachan@imgtec.com>
8 years agovideo: adf: use %zu when printing size_t
Greg Hackmann [Fri, 14 Feb 2014 23:35:38 +0000 (15:35 -0800)]
video: adf: use %zu when printing size_t

Change-Id: I9cf7ebc368bad0a83db9e5aa370feadf117b21c0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: fix compat ioctls calling ioctl with wrong cmd
Greg Hackmann [Fri, 14 Feb 2014 23:38:49 +0000 (15:38 -0800)]
video: adf: fix compat ioctls calling ioctl with wrong cmd

Change-Id: Icdbac3edd123b3114103dc138a60e6955006cda4
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: use ADF_IOCTL_TYPE in compat ioctl definitions
Greg Hackmann [Fri, 14 Feb 2014 23:39:52 +0000 (15:39 -0800)]
video: adf: use ADF_IOCTL_TYPE in compat ioctl definitions

Change-Id: I7451a282d9d972c9957568b366c164b67b4b47e8
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: define constants for device-custom ioctls
Greg Hackmann [Mon, 13 Jan 2014 23:24:24 +0000 (15:24 -0800)]
video: adf: define constants for device-custom ioctls

Device-custom ADF ioctls can use type ADF_IOCTL_TYPE and
nr >= ADF_IOCTL_NR_CUSTOM

Change-Id: Ia8270973df5100e996ca0e021ede60e54b9af72a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: fix fbdev blank -> dpms state mapping
Greg Hackmann [Fri, 22 Nov 2013 21:50:24 +0000 (13:50 -0800)]
video: adf: fix fbdev blank -> dpms state mapping

Change-Id: I96132a1b7275d389a6d0ba8899c6be838b63c422
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: validate dpms state passed to blank
Greg Hackmann [Wed, 20 Nov 2013 20:10:35 +0000 (12:10 -0800)]
video: adf: validate dpms state passed to blank

Change-Id: I3a4228d50fc4a2553b3e92e5675a94cbc6e71b8a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: fix ADF_MAX_ATTACHMENTS declaration
Greg Hackmann [Mon, 11 Nov 2013 22:31:12 +0000 (14:31 -0800)]
video: adf: fix ADF_MAX_ATTACHMENTS declaration

Userspace-facing ADF_MAX_ATTACHMENTS must be in terms of
userspace-facing struct adf_attachment_config

Change-Id: Iaaddcd6366f13b3e52eb3911efcfff8a61e0b225
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: remove PAGE_SIZE from userspace-facing header
Greg Hackmann [Wed, 20 Nov 2013 22:02:09 +0000 (14:02 -0800)]
video: adf: remove PAGE_SIZE from userspace-facing header

Systems may define PAGE_SIZE in userspace limits.h but don't have to.
PAGE_SIZE was picked as an arbitrary "reasonable" limit so just use 4096
instead.

Change-Id: I9555e39aba64a3a70f61eb6ded2a4129ab236ce0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: make device node names less hierarchical
Greg Hackmann [Thu, 7 Nov 2013 18:12:00 +0000 (10:12 -0800)]
video: adf: make device node names less hierarchical

adf/foobar/device -> adf0
adf/foobar/interface1 -> adf-interface0.1
adf/foobar/overlay-engine1 -> adf-overlay-engine0.1

Change-Id: I7af7f84ce3f101ecb02f448070c200ff3e03f2ec
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: expose adf_modeinfo_set_{name,vrefresh} to drivers
Greg Hackmann [Thu, 17 Oct 2013 20:18:53 +0000 (13:18 -0700)]
video: adf: expose adf_modeinfo_set_{name,vrefresh} to drivers

Change-Id: Id9f8b2184927a77b244ce0b33d619d6e44a0f17a
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: set default interface dpms_state to OFF
Greg Hackmann [Wed, 16 Oct 2013 21:53:12 +0000 (14:53 -0700)]
video: adf: set default interface dpms_state to OFF

Interfaces default to unplugged, so they should also default to off

Change-Id: I36500a54b11f354a0d7dd2c9924a79e0d9c6f855
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: make dpms_state sysfs attribute writable
Greg Hackmann [Thu, 15 Aug 2013 19:51:22 +0000 (12:51 -0700)]
video: adf: make dpms_state sysfs attribute writable

Change-Id: I04e7785cbddac160003e6c9edaf62d20b367fdc9
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add helpers for validating custom formats
Greg Hackmann [Tue, 15 Oct 2013 19:51:20 +0000 (12:51 -0700)]
video: adf: add helpers for validating custom formats

Many custom formats look a lot like the standard ones, but with
different subsampling, bpp, etc.  Expose and document
adf_buffer_validate()'s main body, so drivers can reuse its logic when
validating these formats.

Change-Id: I1d06981c9e5aab26f3ab2956c08c679f2c823bcc
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add informational flags to interfaces
Greg Hackmann [Fri, 13 Sep 2013 18:23:05 +0000 (11:23 -0700)]
video: adf: add informational flags to interfaces

Informational flags don't affect ADF directly but may be useful to
clients.  Currently used to indicate primary and external displays.

Change-Id: I343c7f0148da0869244c8e818350e9855525df85
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add fbdev compatibility helper
Greg Hackmann [Tue, 9 Jul 2013 20:07:26 +0000 (13:07 -0700)]
video: adf: add fbdev compatibility helper

Change-Id: I2b82bb625f805e8edb27799743b290dda5befb97
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add supported formats to adf_overlay_engine_data
Greg Hackmann [Tue, 11 Jun 2013 19:59:41 +0000 (12:59 -0700)]
video: adf: add supported formats to adf_overlay_engine_data

Change-Id: If2aa783b9ece60160f465bf697508fc58682e1bc
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: support "simple" buffers
Greg Hackmann [Thu, 10 Oct 2013 20:03:26 +0000 (13:03 -0700)]
video: adf: support "simple" buffers

Simple buffers are linear RGB buffers analogous to KMS's dumb buffers.
Simple buffers can be allocated and posted to a display interface
without any driver-private data.

Internally, ADF drivers provide the driver-private data needed (if any)
to post a simple buffer to the display.

Change-Id: Ib0b737622eaf343111310f6623f99d69cf3807d2
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: adf: add memblock helper
Greg Hackmann [Mon, 8 Jul 2013 21:18:18 +0000 (14:18 -0700)]
video: adf: add memblock helper

Provides a dma-buf exporter for memblocks, mainly useful for ADF devices
to wrap their bootloader logos

Change-Id: I936a9b5df099ab6084d433fcaf50f3bc29f93289
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agovideo: add atomic display framework
Greg Hackmann [Wed, 22 May 2013 21:23:10 +0000 (14:23 -0700)]
video: add atomic display framework

Change-Id: I693257e269a99012cd0dbb57576ac222869cf4c7
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agosubsystem: CPU FREQUENCY DRIVERS- Set cpu_load calculation on current frequency
rahul.khandelwal [Fri, 17 Apr 2015 06:15:23 +0000 (11:45 +0530)]
subsystem: CPU FREQUENCY DRIVERS- Set cpu_load calculation on current frequency

In timer, cpu_load is calcuated on target_freq.
cpu_load = loadadjfreq / pcpu->target_freq;
But cpu is actually running on current freq i.e. pcpu->policy->cur. So cpu_load
should be calculated on current frequency.
cpu_load = loadadjfreq / pcpu->policy->cur;

Change-Id: I89db6b68e9f82aa52077f6bf7d819dab74265790
Signed-off-by: rahul.khandelwal <rahul.khandelwal@spreadtrum.com>
8 years agocpufreq: interactive: build fixes for 4.4
Amit Pundir [Fri, 20 Nov 2015 13:24:30 +0000 (18:54 +0530)]
cpufreq: interactive: build fixes for 4.4

Bring back cpufreq_{get,put}_global_kobject() definitions
removed by upstream commit 8eec1020f0c0 "cpufreq: create
cpu/cpufreq at boot time" to fix build failures.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agocpufreq: interactive: replace strict_strtoul() with kstrtoul()
Amit Pundir [Tue, 3 Nov 2015 15:23:29 +0000 (20:53 +0530)]
cpufreq: interactive: replace strict_strtoul() with kstrtoul()

strict_strtoul() is obsolete. Use kstrtoul() instead.
Otherwise we run into following build error:

  CC      drivers/cpufreq/cpufreq_interactive.o
drivers/cpufreq/cpufreq_interactive.c: In function ‘store_hispeed_freq’:
drivers/cpufreq/cpufreq_interactive.c:784:2: error: implicit declaration of function ‘strict_strtoul’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
make[2]: *** [drivers/cpufreq/cpufreq_interactive.o] Error 1

Change-Id: Ib91b9df3af5fe2a244861c2f598bd20ec8115e6c
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
8 years agocpufreq: interactive: Rearm governor timer at max freq
Rohit Gupta [Sat, 7 Mar 2015 02:46:04 +0000 (18:46 -0800)]
cpufreq: interactive: Rearm governor timer at max freq

Interactive governor doesn't rearm per-cpu timer if target_freq is
equal to policy->max. However, this does not have clear performance
benefits. Profiling doesn't show any difference in benchmarks, games
or other workloads, if timers are always rearmed.

At same time, there are a few issues caused by not rearming timer
at policy->max.

1) min_sample_time enforcement is inconsistent

For target frequency that is lower than policy->max, it will not
drop until min_sample_time has passed since last frequency evaluation
selected current frequency. However, for policy->max, it will
always drop immediately as long as CPU has been run for longer than
min_sample_time. This is because timer is not running and thus
floor_freq and floor_validate_time is not updated.

Example: assume min_sample_time is 59ms and timer_rate is 20ms.
Frequency X < Y. Let's say CPU would pick the following frequencies
before accounting for min_sample_time in each 20ms sampling window.
Y, Y, Y, Y, X, X, X, X, X
If Y is not policy->max, the final target_freq after considering
min_sample_time will be Y, Y, Y, Y, *Y, *Y, X, X, X
* marks the windows where frequency is prevented from dropping.
If Y is policy->max, the final target_freq will be
Y, Y, Y, Y, X, X, X, X, X

2) Rearm timer in IDLE_START does not work as intended

IDLE_START/END is sent in arch_cpu_idle_enter/exit(). However, next
wake up is decided in tick_nohz_idle_enter(), which traverses the
timer list before idle notification is sent out. Therefore, rearming
timer in idle notification won't take effect until CPU wakes up at
least once. In rare scenarios when a CPU goes to idle and sleeps for a
long time immediately after a heavy load stops, it may not wake up
to drop its frequency vote for a long time, defeating the purpose of
having a slack_timer.

3) Need to rearm timer for policy->max change

commit 535a553fc1c4b4c3627c73214ade6326615a7463
(cpufreq: interactive: restructure CPUFREQ_GOV_LIMITS) mentions the
problem of timer getting indefinitely pushed back due to frequency
changes in policy->min/max. However, it still cancels and rearms timer
if policy->max is increased, and same problem could still happen if
policy->max is frequently changing after the fix. The best solution is
to always rearm timer for each CPU even if it's running at
policy->max.

Rearming timers even if target_freq is policy->max solves these
problems cleanly. It also simplifies the design and code of interactive
governor.

Change-Id: I973853d2375ea6f697fa4cee04a89efe6b8bf735
Reviewed-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
8 years agocpufreq: interactive: Implement cluster-based min_sample_time
Junjie Wu [Tue, 24 Mar 2015 22:51:10 +0000 (15:51 -0700)]
cpufreq: interactive: Implement cluster-based min_sample_time

min_sample_time needs to be cluster-based to match
above_hispeed_delay. If each CPU keeps making local decisions, it's
possible min_sample_time is not correctly enforced at cluster level,
which results in undesired frequency drops.

Change-Id: Ia2ec2ad9b7a8d715d4408c924d6762b7e532e4b4
Reviewed-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
8 years agocpufreq: interactive: Exercise hispeed settings at a policy level
Saravana Kannan [Wed, 15 Oct 2014 19:44:18 +0000 (12:44 -0700)]
cpufreq: interactive: Exercise hispeed settings at a policy level

If a heavy task migrates between otherwise idle CPUs in a policy during
every sample window, the above hispeed delay window for the CPUs would get
restarted for every sample window. Due to the continuous restart of above
hispeed delay window, none of the CPUs would ever pick a target frequency
higher than hispeed frequency. This causes the policy's frequency to be
stuck at hispeed freq even if the load justifies a higher frequency.

To fix this, the above high speed delay window is restarted only when the
policy frequency changes. This ensures that tasks migrating between CPUs in
a policy are handled correctly.

Also, the hispeed load/frequency heuristic is only necessary when the
information is insufficient to determine if the load on the CPU needs at
least hispeed frequency. When the policy frequency is already at or above
hispeed frequency, if the CPU load% based on policy frequency is not above
hispeed load, then the information is clearly sufficient to determine that
the load on the CPU does not need hispeed frequency.

Therefore, compute CPU load% (which is used only to compare against hispeed
load) based on policy frequency instead of CPU target frequency.

Change-Id: I8b5dfe6c50bee567a6719f0980e3f7757876ce4b
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
8 years agocpufreq: interactive: Round up timer_rate to match jiffy
Junjie Wu [Fri, 15 Aug 2014 23:34:37 +0000 (16:34 -0700)]
cpufreq: interactive: Round up timer_rate to match jiffy

Timers are scheduled in unit of jiffies. Round up timer_rate so that
it matches the actual sampling period.

Change-Id: I88386a5a448e40333f9a9b9f0cf72af58cb54656
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
8 years agocpufreq: interactive: Don't set floor_validate_time during boost
Junjie Wu [Mon, 6 Apr 2015 18:16:45 +0000 (11:16 -0700)]
cpufreq: interactive: Don't set floor_validate_time during boost

Frequency selection algorithm guarantees its chosen frequency
is not lower than hispeed_freq as long as boost is enabled.

Setting floor_freq and floor_validate_time during boost could block
CPU frequency from going below hispeed_freq even after
boostpulse_duration expires, if min_sample_time is higher than
boostpulse_duration. This conflicts with the intention of commit
de091367ead15b6e95dd1d0743a18f0da5a07ee5
(cpufreq: interactive: specify duration of CPU speed boost pulse)
to allow CPU to ramp down immediately after boost expires. It also
makes boost behavior inconsistent since it depends on min_sample_time.

Avoid setting floor_freq and floor_validate_time when boost starts.

Change-Id: I12852998af46cfbfaf8661eb5e8d5301b6f631e7
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
8 years agocpufreq: interactive: Put global cpufreq kobject on failure
Junjie Wu [Sat, 7 Feb 2015 04:28:37 +0000 (20:28 -0800)]
cpufreq: interactive: Put global cpufreq kobject on failure

Fix failure recovery path in cpufreq_governor_interactive(). Call
cpufreq_put_global_kobject() to release cpufreq global kobject upon
governor init failure.

Change-Id: I7a977070b7a3c75c90acccd2c117064ed1a10d0e
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
8 years agocpufreq: interactive: only boost tunable affected cpus
Lianwei Wang [Wed, 3 Dec 2014 01:20:50 +0000 (17:20 -0800)]
cpufreq: interactive: only boost tunable affected cpus

It is not correct to boost all the cpus when tunable boost
parameters are changed. It also does not need to boost the
cpus which is already boosted.

Signed-off-by: Lianwei Wang <a22439@motorola.com>
8 years agocpufreq: interactive: don't skip waking up speedchange_task if target_freq > policy...
Minsung Kim [Sat, 29 Nov 2014 12:43:53 +0000 (21:43 +0900)]
cpufreq: interactive: don't skip waking up speedchange_task if target_freq > policy->cur

When __cpufreq_driver_target() in speedchange_task failed for some reason, the
policy->cur could be lower than the target_freq. The governor misses to change
the target_freq if the target_freq is equal to the next_freq at the next sample
time.

Added a check to prevent the CPU to stay at the speed that is lower than the
target_freq for long duration.

Change-Id: Ibfdcd193b8280390b8f8374a63218aa31267f310
Signed-off-by: Minsung Kim <ms925.kim@samsung.com>
8 years agocpufreq: interactive: make common_tunables static
Cylen Yao [Sat, 6 Sep 2014 01:27:38 +0000 (18:27 -0700)]
cpufreq: interactive: make common_tunables static

common_tunables should be static.

Change-Id: I502ee3062bece5082fea7861eff2f6237e25cede
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: prevents the frequency to directly raise above the hispeed_freq...
Ruchi Kandoi [Fri, 13 Jun 2014 23:24:15 +0000 (16:24 -0700)]
cpufreq: interactive: prevents the frequency to directly raise above the hispeed_freq from a lower frequency.

When the load was below go_hispeed_load, there is a possibility that
choose_freq() would return a frequency which would be higher than the
hispeed_freq. According to the policy we should first jump to the
hispeed_freq, stay there for above_hispeed_delay and then be allowed to
raise higher than that.

Added a check to prevent the frequency to be directly raised to
something higher than the hispeed_freq.

Change-Id: Icda5d848dd9beadcc18835082ddf269732c75bd0
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agocpufreq: interactive: remove compilation error from commit 49cc72365fb7ee87762a7ccc6a...
Ruchi Kandoi [Wed, 9 Apr 2014 23:47:59 +0000 (16:47 -0700)]
cpufreq: interactive: remove compilation error from commit 49cc72365fb7ee87762a7ccc6a32ef68627216c5

Change-Id: I068b18281d03ac879ef64d8ff36ed43367293767
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agocpufreq: interactive: turn boost_pulse off on boost off
Ruchi Kandoi [Thu, 3 Apr 2014 22:39:23 +0000 (15:39 -0700)]
cpufreq: interactive: turn boost_pulse off on boost off

Change-Id: I36fe217fa047d68ea90e78b12c7db4537ea8010b
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
8 years agocpufreq: interactive: restructure CPUFREQ_GOV_LIMITS
Badhri Jagan Sridharan [Tue, 8 Apr 2014 01:26:30 +0000 (18:26 -0700)]
cpufreq: interactive: restructure CPUFREQ_GOV_LIMITS

The cpufreq_interactive_timer gets cancelled and rescheduled
whenever the cpufreq_policy is changed. When the cpufreq policy is
changed at a rate faster than the sampling_rate of the interactive
governor, then the governor misses to change the target frequency
for long duration. The patch removes the need of cancelling the
timers when policy->min is changed.

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

8 years agocpufreq: interactive: hold reference on global cpufreq kobject if needed
Greg Hackmann [Mon, 8 Dec 2014 18:08:35 +0000 (10:08 -0800)]
cpufreq: interactive: hold reference on global cpufreq kobject if needed

2361be23666232dbb4851a527f466c4cbf5340fc changed cpufreq to add the
global cpufreq kobject to sysfs on demand.

To ensure this happens, cpufreq_interactive must hold a reference on
this object on devices where it intends to use it (i.e., devices where
have_governor_per_policy() returns false).  Otherwise a parentless
kobject will be passed to sysfs_create_group() which will subsequently
BUG().

Change-Id: I7dd03956e1d3c6c3c0cc17c799882c235804ae09
Signed-off-by: Greg Hackmann <ghackmann@google.com>
8 years agocpufreq: interactive: Use generic get_cpu_idle_time() from cpufreq.c
Viresh Kumar [Thu, 16 May 2013 08:52:49 +0000 (14:22 +0530)]
cpufreq: interactive: Use generic get_cpu_idle_time() from cpufreq.c

Now that a generic version of get_cpu_idle_time() is available, use that for the interactive governor.

[toddpoynor@google.com: commit text changes]
Change-Id: Ia38b57085aac99ec3d415fe44471d5dfde519c2c
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
8 years agocpufreq: interactive: fix NULL pointer dereference at sysfs ops
Minsung Kim [Sun, 19 Jan 2014 05:32:42 +0000 (14:32 +0900)]
cpufreq: interactive: fix NULL pointer dereference at sysfs ops

sysfs ops for target_loads and above_hispeed_delay can be called before
initializing tunables at CPUFREQ_GOV_POLICY_INIT. Create sysfs entries after
initialization.

Change-Id: I50356198d7629731c0d32a3066d61fe8354e0001
Signed-off-by: Minsung Kim <ms925.kim@samsung.com>
8 years agocpufreq: interactive: fix compiling warnings
Chih-Wei Huang [Tue, 24 Dec 2013 09:51:55 +0000 (17:51 +0800)]
cpufreq: interactive: fix compiling warnings

The gcc warns like:

  cpufreq_interactive.c:745:6: warning: operation on 'ret' may be undefined [-Wsequence-point]

It was introduced by commit cf0fad49d17cb8273ce555dd5b7afab67d7923bf.

Since sprintf(...) just return 1 (one character) in this case, ret should not changed.
Just discarding the result of sprintf(...) leads to the result that
the committer of cf0fad49d17cb8273ce555dd5b7afab67d7923bf wants.

Change-Id: Ifed1cef6d6a31c3ed23dad03a567b3b9eddf3a57
Signed-off-by: Chih-Wei Huang <cwhuang@android-x86.org>
8 years agocpufreq: interactive: delete timers for GOV_START
Shridhar Rasal [Mon, 9 Sep 2013 13:47:14 +0000 (19:17 +0530)]
cpufreq: interactive: delete timers for GOV_START

Make sure that timers cpu_timer and cpu_slack_timer
deactivated before addition of new.

Change-Id: If31c4049606871df6f00efdc24b1d713c86a6f69
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
Signed-off-by: Bharat Nihalani <bnihalani@nvidia.com>
8 years agocpufreq: Interactive: Implement per policy instances of governor
Viresh Kumar [Thu, 16 May 2013 09:28:54 +0000 (14:58 +0530)]
cpufreq: Interactive: Implement per policy instances of governor

If we have a multi-package system, where we have multiple instances of struct
policy (per package), currently we can't have multiple instances of same
governor. i.e. We can't have multiple instances of Interactive governor for
multiple packages.

This is a bottleneck for multicluster system, where we want different packages
to use Interactive governor, but with different tunables.

This patch uses the infrastructure provided by earlier patches pushed in
Mainline in v3.10-rc1/rc2 and implements per policy instances of Interactive
governor.

Change-Id: I70436d4a5a45c6cb6edf37f3e46d0b9fbc930982
[toddpoynor@google.com: merge with later code, minor changes]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
8 years agocpufreq: interactive: Move definition of cpufreq_gov_interactive downwards
Viresh Kumar [Thu, 16 May 2013 09:28:53 +0000 (14:58 +0530)]
cpufreq: interactive: Move definition of cpufreq_gov_interactive downwards

This moves definition of cpufreq_gov_interactive towards the bottom of file, so
that we don't have to add prototype of cpufreq_governor_interactive() in the
beginning of file.

Change-Id: I04bd1004954eb36502c5cd7e35d3d7274cddaf95
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
8 years agocpufreq: interactive: Remove unnecessary cpu_online() check
Viresh Kumar [Thu, 16 May 2013 09:28:52 +0000 (14:58 +0530)]
cpufreq: interactive: Remove unnecessary cpu_online() check

Cpufreq no longer calls governor callback for offlined cpus. i.e. All
policy->cpus are guaranteed to be online. Hence we don't need explicit check to
see if cpu is online or not.

Change-Id: I9ad85ea4addd5b4a40952e59ed730dd15e328690
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
8 years agocpufreq: interactive: fix show_target_loads and show_above_hispeed_delay
Minsung Kim [Sun, 25 Aug 2013 10:23:34 +0000 (19:23 +0900)]
cpufreq: interactive: fix show_target_loads and show_above_hispeed_delay

Remove a trailing whitespace from target_loads and above_hispeed_delay. Problem
happens when user-space program tried to restore parameters that saved before
changing parameters. In this case was returned error(EINVAL).

Change-Id: I5a74e3824602cd6f2b74651adda5ec1b627e61e9
Signed-off-by: Minsung Kim <ms925.kim@samsung.com>
8 years agocpufreq: interactive: resched timer if max freq raised
Lianwei Wang [Fri, 26 Apr 2013 05:30:51 +0000 (13:30 +0800)]
cpufreq: interactive: resched timer if max freq raised

When the policy max freq is raised, and before the timer is
rescheduled in idle callback, the cpu freq may stuck at a
lower freq.

The target_freq shall be updated too, else on a high load
situation, the new_freq is always equal to target_freq and
which will cause freq stuck at a lower freq too.

Reschedule the timer on gov limits callback.

Change-Id: I6c187001ab43e859731429b64f75a74eebc37a24
Signed-off-by: Lianwei Wang <a22439@motorola.com>
8 years agocpufreq: interactive: fix race on cpufreq TRANSITION notifier
Lianwei Wang [Thu, 16 May 2013 04:07:23 +0000 (12:07 +0800)]
cpufreq: interactive: fix race on cpufreq TRANSITION notifier

The cpufreq TRANSTION notifier callback does not check the
governor_enabled state on affected CPUS, which will case
kernel panic in update_load because the policy object maybe
NULL or invalid when governor_enabled is false.

Change-Id: Ie0f1718124f61e2f9b5da57abc6981ada5b83908
Signed-off-by: Lianwei Wang <a22439@motorola.com>
8 years agocpufreq: interactive: avoid underflow on active time calculation
Minsung Kim [Tue, 23 Apr 2013 13:32:01 +0000 (22:32 +0900)]
cpufreq: interactive: avoid underflow on active time calculation

Check for idle time delta less than elapsed time delta, avoid
underflow computing active time.

Change-Id: I3e4c6ef1ad794eec49ed379c0c50fa727fd6ad28
Signed-off-by: Minsung Kim <ms925.kim@samsung.com>
8 years agocpufreq: interactive: reduce chance of zero time delta on load eval
Todd Poynor [Fri, 5 Apr 2013 20:25:21 +0000 (13:25 -0700)]
cpufreq: interactive: reduce chance of zero time delta on load eval

Reschedule load sampling timer after timestamp of sample start taken,
hold spinlock across entire sequence to avoid preemption.  Avoid the
WARN for zero time delta in the load sampling timer function.

Change-Id: Idc10a756f09141decb6df92669521a1ebf0dbc10
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: handle errors from cpufreq_frequency_table_target
Todd Poynor [Mon, 22 Apr 2013 23:44:58 +0000 (16:44 -0700)]
cpufreq: interactive: handle errors from cpufreq_frequency_table_target

Add checks for error return from cpufreq_frequency_table_target, and be
less noisy on the existing call with an error check.  CPU hotplug and
system shutdown may cause this call to return -EINVAL.

Bug: 8613560
Change-Id: Id78d8829920462c0db1c7e14e717d91740d6cb44
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: fix uninitialized spinlock
Minsung Kim [Tue, 16 Apr 2013 12:52:50 +0000 (21:52 +0900)]
cpufreq: interactive: fix uninitialized spinlock

Add missing spinlock init

Backtrace:
[<c0011ce4>] (dump_backtrace+0x0/0x10c) from [<c0662a68>] (dump_stack+0x18/0x1c)
 r6:00000032 r5:c0bd09ec r4:e6848000 r3:00000000
[<c0662a50>] (dump_stack+0x0/0x1c) from [<c06670b0>] (spin_dump+0x80/0x94)
[<c0667030>] (spin_dump+0x0/0x94) from [<c06670f0>] (spin_bug+0x2c/0x30)
 r5:c08f91fc r4:c0bd09ec
[<c06670c4>] (spin_bug+0x0/0x30) from [<c0245f74>] (do_raw_spin_unlock+0x88/0xcc)
 r5:e547bac0 r4:c0bd09ec
[<c0245eec>] (do_raw_spin_unlock+0x0/0xcc) from [<c066c9cc>] (_raw_spin_unlock_irqrestore+0x14/0x40)
 r5:e547bac0 r4:60000013
[<c066c9b8>] (_raw_spin_unlock_irqrestore+0x0/0x40) from [<c044b884>] (store_above_hispeed_delay+0x6c/0x80)
 r4:c0b4cf78 r3:00000007
[<c044b818>] (store_above_hispeed_delay+0x0/0x80) from [<c0235d24>] (kobj_attr_store+0x1c/0x28)
 r7:e68ff000 r6:00000032 r5:e58137c0 r4:e61cde80
[<c0235d08>] (kobj_attr_store+0x0/0x28) from [<c0156b78>] (sysfs_write_file+0x104/0x184)
[<c0156a74>] (sysfs_write_file+0x0/0x184) from [<c0100680>] (vfs_write+0xb0/0x140)
[<c01005d0>] (vfs_write+0x0/0x140) from [<c0100900>] (sys_write+0x44/0x70)
 r8:00000000 r7:00000004 r6:00000032 r5:bee43c90 r4:e5600300
[<c01008bc>] (sys_write+0x0/0x70) from [<c000e400>] (ret_fast_syscall+0x0/0x30)
 r9:e6842000 r8:c000e584 r6:00000032 r5:bee43c90 r4:00000009

Change-Id: I80a1e0b3fecb24adba501ff44f568479deeff7fa
Signed-off-by: Minsung Kim <ms925.kim@samsung.com>
8 years agocpufreq: interactive: base above_hispeed_delay on target freq, not current
Todd Poynor [Fri, 22 Mar 2013 03:46:00 +0000 (20:46 -0700)]
cpufreq: interactive: base above_hispeed_delay on target freq, not current

Time to wait should be based on the intended target speed, not the
actual speed (which may be held high by another CPU).

Change-Id: Ifc5bb55d06adddb9a02af90af05398a78f282272
Reported-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
8 years agocpufreq: interactive: fix crash on error paths in get_tokenized_data
Todd Poynor [Wed, 20 Mar 2013 22:40:46 +0000 (15:40 -0700)]
cpufreq: interactive: fix crash on error paths in get_tokenized_data

Use separate variable for error code, free proper pointer.

Change-Id: Ia83cccb195997789ac6afbf5b8761f7b278196d6
Reported-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
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>