UBUNTU: SAUCE: trace: add trace events for open(), exec() and uselib()

BugLink: http://bugs.launchpad.net/bugs/462111

This patch uses TRACE_EVENT to add tracepoints for the open(),
exec() and uselib() syscalls so that ureadahead can cheaply trace
the boot sequence to determine what to read to speed up the next.

It's not upstream because it will need to be rebased onto the syscall
trace events whenever that gets merged, and is a stop-gap.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Andy Whitcroft <andy.whitcroft@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
CHROMIUM: NET: USBNET: move tegra 32 byte alignment issue

We need to ensure the sk buf is 32 byte aligned, and it seems that the
asix controller touches the sk buffer in the tx_fixup callback that
changed this alignment. The misaligned buffer gets stuck in the usb
controller and doesn't get issued, causing the timeout.

BUG=https://code.google.com/p/chrome-os-partner/issues/detail?id=1672
TEST=can browse web steadily without seeing the problem

Change-Id: I2efeaa00766c1611feecccf36c59946b5798a691
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Olof Johansson <olofj@chromium.org>

Review URL: http://codereview.chromium.org/5211005
MOBLIN: fastboot: remove "wait for all devices before mounting root" delay

In the non-initrd case, we wait for all devices to finish their
probing before we try to mount the rootfs.
In practice, this means that we end up waiting 2 extra seconds for
the PS/2 mouse probing even though the root holding device has been
ready since a long time.

The previous two patches in this series made the RAID autodetect code
do it's own "wait for probing to be done" code, and added
"wait and retry" functionality in case the root device isn't actually
available.

These two changes should make it safe to remove the delay itself,
and this patch does this. On my test laptop, this reduces the boot time
by 2 seconds (kernel time goes from 3.9 to 1.9 seconds).

Change-Id: Ie32e9d5f93b35b1aed0d955e8e472b9fc73227e4
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/1667
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: Write the initial TSC at early kernel init

BUG=1344

Signed-off-by: Ken Mixter <kmixter@google.com>

Review URL: http://codereview.chromium.org/581008
CHROMIUM: x86: print out initial usec value calculated from TSC and CPU HZ

This is to give an idea of how much time was spent in firmware and kernel
prior to timekeeping initialization in the kernel.  We print out TSC now,
but printing out usec is more portable across architectures.  We can
remove the raw TSC print once the scripts have been changed over to use
usec.

BUG=chromium-os:4900
TEST=boot on an x86 platform, verify that there is a line in the
kernel log saying "Initial usec timer"

Change-Id: I0a90643f383a937821f8a6439e994ffdaf43d454
Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/7584
Reviewed-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: Add /proc/breakme support

Signed-off-by: Martin Bligh <mbligh@google.com>
[olofj: fix compilation error for 3.0]
Signed-off-by: Olof Johansson <olofj@chromium.org>
CHROMIUM: breakme: add hungtask support to /proc/breakme

Adding this so that we can test the hung_task detector.

BUG=chromium-os:15086
TEST=see below

$ echo hungtask > /proc/breakme &
[1] 3755
$ dmesg
...
[  240.844119] INFO: task bash:3755 blocked for more than 120 seconds.
[  240.844130] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  240.844139] bash            D b6d629b8  7188  3755   3753 0x00000000
[  240.844165]  ac207ea4 00000082 795b6004 b6d629b8 79633f40 ac222780 79633f40 ac2229f4
[  240.844185]  ac2229f0 ac2229f0 79633f40 79633f40 dfec48db 00000015 dfe6517e 00000015
[  240.844204]  ac222780 ac3c46e4 00000002 01000041 795b59c0 00000002 000000d0 ac222780
[  240.844223] Call Trace:
[  240.844247]  [<793c9371>] schedule_timeout+0x1b/0x95
[  240.844262]  [<790980ff>] ? lru_cache_add_lru+0x3d/0x3f
[  240.844275]  [<790ac8c6>] ? page_add_new_anon_rmap+0x61/0x6f
[  240.844287]  [<790a554e>] ? handle_pte_fault+0x248/0x984
[  240.844301]  [<79199f30>] ? _copy_from_user+0x32/0x6e
[  240.844312]  [<793c9405>] schedule_timeout_uninterruptible+0x1a/0x1c
[  240.844325]  [<790f92d6>] write_breakme+0x9e/0x124
[  240.844337]  [<790a6a99>] ? handle_mm_fault+0x131/0x143
[  240.844350]  [<790f3996>] proc_reg_write+0x5f/0x73
[  240.844361]  [<790f9238>] ? write_breakme+0x0/0x124
[  240.844374]  [<790bd9e8>] vfs_write+0x8f/0x12c
[  240.844385]  [<790f3937>] ? proc_reg_write+0x0/0x73
[  240.844396]  [<790bdb26>] sys_write+0x40/0x65
[  240.844408]  [<790028cc>] sysenter_do_call+0x12/0x22

Change-Id: Iff031f084c4a12349e37ecea1319e2ed069f3592
Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/739
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
CHROMIUM: Make tsl2583 do async suspend/resume

The i2c based tsl2583 must re-write all registers after suspend
which can take a considerable portion of kernel resume time.
Make this device fully asynchronous for suspend/resume

BUG=15489
TEST=suspend/resume and make sure light sensor works afterward

Change-Id: I3334ef3313694889da409b3b9e1ecccee79e4387
Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/1662
Reviewed-by: Sameer Nanda <snanda@chromium.org>
CHROMIUM: light sensor: Add a calibration file to the isl29018 driver.

Backport a patch recently accepted upstream.

Defaulting to 1, this gives a way to amplify the lux value before being
reduced by the programmed adc_bit shift.
Only support whole numbers right now.  When this driver is converted to the new
IIO_CHAN framework, it will be easy to support the framework's pseudo float.

Add illuminance0_calibscale documentation to sysfs-bus-iio-light.

BUG=chrome-os-partner:1959
TEST=Confirm illuminance0_calibscale amplifies illuminance0_input values.

Signed-off-by: Bryan Freed <bfreed@chromium.org>

Change-Id: I003d0ce2fac78eadeb8e0d39ab4916105c9aabe9
Reviewed-on: http://gerrit.chromium.org/gerrit/2458
Tested-by: Bryan Freed <bfreed@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
CHROMIUM: iio: light sensor: Improve granularity of tsl2583 lux values.

When illuminance0_calibbias gets 4000 (for a 4x multiplier), we see lux
granularity of 4.  Reversing the order of the right shift and multiplication
retains the precision of the unadjusted lux value.

BUG=chromium-os:23451
TEST='while :;do cat illuminance0_input;done' gives granularity of 1.

Signed-off-by: Bryan Freed <bfreed@chromium.org>
Change-Id: I92667cb04007ac17e91e0e3da10d691f774a753d
Reviewed-on: https://gerrit.chromium.org/gerrit/12394
Reviewed-by: Benson Leung <bleung@chromium.org>
CHROMIUM: ata: remove 200 ms sleep in sata_link_resume

This saves us 200 ms on boot (once other changes are applied).

BUG=chromium-os:15409,chromium-os:12110,chromium-os:15653
TEST=Booted x86-generic on Mario.

Change-Id: I419622c7329d30e39809f6d08972034a1ac6d3dc
Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/1372
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Add /proc/<pid>/totmaps

BUG=None
TEST=Manual

/proc/<pid>/totmaps is an alternative to /proc/<pid>/smaps. It contains a
summary of all memory displayed in smaps, while hiding the memory page
addresses. Thus, it is possible to access any process's totmaps info.
totmaps also gets the information from the PTEs, like smaps. Furthermore,
it also gives more detailed and accurate information about the memory
usage of a process than statm. The fields available in totmaps are Rss,
totmaps, Shared_Clean, Shared_Dirty, Private_clean, Private_Dirty,
Referenced, Anonymous, AnonHugePages, Swap and Locked.

Sample output:

Rss:                6120 kB
Pss:                3335 kB
Shared_Clean:       1008 kB
Shared_Dirty:       4012 kB
Private_Clean:         4 kB
Private_Dirty:      1096 kB
Referenced:         1812 kB
Anonymous:          5108 kB
AnonHugePages:         0 kB
Swap:                  0 kB
Locked:                0 kB

Change-Id: I4867554c1a4d200d304c3765447977767b7b3c72
Signed-off-by: Thiago Goncales <thiagog@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28731
Reviewed-by: Kees Cook <keescook@chromium.org>
CHROMIUM:staging:iio:light: fix ISL29018 sensor operation after a brownout

After a voltage brownout, sensor will now operate correctly.

Page 10 of ISL29018 data sheet and the Intersil Application Note 1534
describe the required initialization sequence:
1. Write 0x00 to register 0x08 (TEST)
2. Write 0x00 to register 0x00 (CMD1)
3. msleep(1)
4. program remaining registers as before

BUG=chrome-os-partner:5351,chrome-os-partner:4752
TEST=manual (boots and light sensor responds after 5 seconds)

Change-Id: I09738e3680cacfa9f71e2173cdd02aae82e26dd5
Signed-off-by: Grant Grundler <grundler@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/5474
Reviewed-by: Bryan Freed <bfreed@chromium.org>
Tested-by: Bryan Freed <bfreed@chromium.org>
CHROMIUM: x86: don't print platform in show_regs

We don't care what the platform is, and it's easier if it's just omitted.

BUG=none
TEST=none

Change-Id: I8f3685d36c86563ee6aa4b7f6f44975009720196
Signed-off-by: Olof Johansson <olof@lixom.net>
Reviewed-on: https://gerrit.chromium.org/gerrit/13696
Tested-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Ready: Olof Johansson <olofj@chromium.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
CHROMIUM: Add CLOCK_SYSTEM_TRACE to export the trace clock to user space.

Add a new clock type CLOCK_SYSTEM_TRACE to retrieve the current trace
clock value (if CONFIG_TRACING is not defined then CLOCK_SYSTEM_TRACE
returns the same value as CLOCK_MONOTONIC_RAW).  This allows user event
tracing to timestamp data with the same clock as the kernel.  This is
in-lieu of sending event data through trace_write (which is not a viable
option when there are lots of user-space events).

BUG=chromium-os:27809
TEST=manual:run test app to collect trace time and compare to data generated by the system (e.g. reading from trace)

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

Change-Id: If2167ed99291e05f8c298638f4118b10b3e710f8
Reviewed-on: https://gerrit.chromium.org/gerrit/21404
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Ready: Sam Leffler <sleffler@chromium.org>
Tested-by: Sam Leffler <sleffler@chromium.org>
CHROMIUM: scheduler: panic if schedulin while atomic

When the schduling while atomic condition is hit, currently only a
printk and dump_stack happens but the kernel continues to run.  We've
run into issues where we think this causes a hang during shutdown
eventually.

Now doing a kernel panic instead by calling BUG().  This should prevent
hangs at shutdown from happening as well as providing us stack traces
that might help us root cause the real issue.

Signed-off-by: Sameer Nanda <snanda@chromium.org>

BUG=chromium-os:29599
TEST=We don't have a good way of repro'ing the hang on shutdown so the
testing is limited to kernel building fine.

Change-Id: I52084abf64a133a00f20e2eeaeb921820755e252
Reviewed-on: https://gerrit.chromium.org/gerrit/21534
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Ready: Sameer Nanda <snanda@chromium.org>
Tested-by: Sameer Nanda <snanda@chromium.org>
CHROMIUM: drivers: net: add module param for control of ASPM  disable

ASPM has been disabled in this driver by default as its been
implicated in stability issues on at least one platform.  This CL adds
a  module parameter to allow control of ASPM disable.  The default
value is disabled to match the current upstream functionality.

BUG=chrome-os-partner:6691
TEST=manual,
1. Test default
- boot kernel on platform w/ r8169
- lspci -vvv -s <device> | grep -i aspm
	LnkCap:	Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency
	   L0 unlimited, L1 <64us
	LnkCtl:    ASPM L1 Enabled; RCB 64 bytes Disabled- Retrain-
	   CommClk+
  - Note, 'ASPM L1 Enabled'

2. Test Disabling ASPM
- echo "options r8169 aspm_disable=1" > /etc/modprobe.d/r8169.conf
- re-boot
- lspci -vvv -s <device> | grep -i aspm
  	LnkCap:	Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency
	   L0 unlimited, L1 <64us
	LnkCtl:    ASPM Disabled; RCB 64 bytes Disabled- Retrain-
	   CommClk+
  - Note, 'ASPM Disabled'

Change-Id: Iae399c08a917fcc7421cb63fb34e9cebca4ab296
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/11551
CHROMIUM: r8169: Enable suspend when device is idle from boot.

The r8169 driver supports power management and correctly transistions
from active to suspend when link transistions from connected to
disconnected.  If its not connected at boot however the device remains
active after the initial probe.

This change adds a check of the link status to the idle pm_op that
will schedule a suspend if inactive.

BUG=chrome-os-partner:7360
TEST=manual
1. boot connected to LAN.  Interface works and continues to work after
disconnect & connect.

2. boot without connected to LAN.  Device's status,
/sys/bus/pci/devices/<devnum>/power/runtime_status is 'suspended'.
Connecting LAN brings up interface and transitions to 'active'.  Test
multiple connect/discoonect still functions

Change-Id: Ia9a5cc300faebbac63f77e3b7eb7cb08491f671e
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/13516
CHROMIUM: r8169: Enable WOL from Magic Packet by default

Set the WOL config registers to only enable WOL from magic packet by
default. Without this change in place, the WOL config register
settings on warm reboot come up in an inconsistent state since these
registers don't get reset on a warm reboot.

BUG=chrome-os-partner:7026
TEST=On a system with a realtek ethernet MAC, do the following
1. run "ethtool -s eth0 wol p" to enable WOL from PHY activity
2. reboot the system
3. run "ethtool eth0" and check that "p" is not listed in "Wake-on"

Change-Id: Iee843b5a93c04a9463342bd87dc03078d37e2ef0
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/15831
Reviewed-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
CHROMIUM: r8169: transition to D0 state at shutdown

With runtime PM, if the ethernet cable is disconnected, the device is
transitioned to D3 state to conserve energy. If the system is shutdown
in this state, any register accesses in rtl_shutdown are dropped on
the floor.

This patch transitions the device back to D0 state in rtl_shutdown if
the device was runtime PM suspended. In addition, since runtime PM
also mucks around with WOL options, the saved WOL options are also
restored in rtl_shutdown.

BUG=chrome-os-partner:7026
TEST=Don't have a good black box test case. It can be tested by
modifying the driver to verify that register accesses in
rtl_shutdown go through with the cable disconnected.

Change-Id: Ic08f2c3fed22a4b1a876dc3816565156b464ec78
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/15832
Reviewed-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>