708364 Commits

Author SHA1 Message Date
Tushar Behera
f1c8e6f39c ANDROID: net: paranoid: security: Add proper checks for Android specific capability checks
Commit b641072 ("security: Add AID_NET_RAW and AID_NET_ADMIN capability
check in cap_capable().") introduces additional checks for AID_NET_xxx
macros. Since the header file including those macros are conditionally
included, the checks should also be conditionally executed.

Change-Id: Iaec5208d5b95a46b1ac3f2db8449c661e803fa5b
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
2017-12-18 21:11:22 +05:30
Chia-chi Yeh
eaacc57b23 ANDROID: net: paranoid: Only NET_ADMIN is allowed to fully control TUN interfaces.
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
2017-12-18 21:11:22 +05:30
Chia-chi Yeh
d846068e98 ANDROID: net: paranoid: Replace AID_NET_RAW checks with capable(CAP_NET_RAW).
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
2017-12-18 21:11:22 +05:30
Chia-chi Yeh
36ac63e701 ANDROID: net: paranoid: security: Add AID_NET_RAW and AID_NET_ADMIN capability check in cap_capable().
Signed-off-by: Chia-chi Yeh <chiachi@android.com>
2017-12-18 21:11:22 +05:30
Robert Love
7bafcbf59a ANDROID: net: Paranoid network.
With CONFIG_ANDROID_PARANOID_NETWORK, require specific uids/gids to instantiate
network sockets.

Signed-off-by: Robert Love <rlove@google.com>

paranoid networking: Use in_egroup_p() to check group membership

The previous group_search() caused trouble for partners with module builds.
in_egroup_p() is also cleaner.

Signed-off-by: Nick Pelly <npelly@google.com>

Fix 2.6.29 build.

Signed-off-by: Arve Hjønnevåg <arve@android.com>

net: Fix compilation of the IPv6 module

Fix compilation of the IPv6 module -- current->euid does not exist anymore,
current_euid() is what needs to be used.

Signed-off-by: Steinar H. Gunderson <sesse@google.com>

net: bluetooth: Remove the AID_NET_BT* gid numbers

Removed bluetooth checks for AID_NET_BT and AID_NET_BT_ADMIN
which are not useful anymore.
This is in preparation for getting rid of all the AID_* gids.

Change-Id: I879d7181f07532784499ef152288d12a03ab6354
Signed-off-by: JP Abgrall <jpa@google.com>

[AmitP: Folded following android-4.9 commit changes into this patch
        a2624d7b9d73 ("ANDROID: Add android_aid.h")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Jin Qian
b0cd15c76b ANDROID: mmc: core: export emmc revision
Change-Id: If23bc838327ef751ee65baadc429e218eaa2a848
Signed-off-by: Jin Qian <jinqian@google.com>
2017-12-18 21:11:22 +05:30
Tim Murray
52678eeea3 ANDROID: mmc: core: move to a SCHED_FIFO thread
(cherry picked from commit 011e507b413393eab8279dac8b778ad9b6e9971b)

Running mmcqd as a prio 120 thread forces it to compete with standard
user processes for IO performance, especially when the system is under
severe CPU load. Move it to a SCHED_FIFO thread to reduce the impact of
load on IO performance.

Signed-off-by: Tim Murray <timmurray@google.com>
Bug: 25392275
Change-Id: I1edfe73baa25e181367c30c1f40fee886e92b60d

[AmitP: Include <uapi/linux/sched/types.h> for struct sched_param]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Dmitry Shmidt
bc310dc57a ANDROID: mmc: core: Add "ignore mmc pm notify" functionality
Change-Id: I20821a82831b07ca037973d5d92e832372c6b583
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-12-18 21:11:22 +05:30
San Mehat
c951eac027 ANDROID: mmc: sdio: Add concept of an 'embedded' SDIO device.
This is required to support chips which use SDIO for signaling/
communication but do not implement the various card enumeration registers
as required for full SD / SDIO cards.

mmc: sdio: Fix bug where we're freeing the CIS tables we never allocated when using EMBEDDED_SDIO
mmc: Add max_blksize to embedded SDIO data

Change-Id: Ibff2e3e991e5522f55ec8c6edc25ed09f2553736
Signed-off-by: San Mehat <san@google.com>

[AmitP: Rebased the original commit to align with the upstream commit
        5fc3d80ef496 ("mmc: sdio: don't use rocr to check if the card could support UHS mode")

        Also folded following android-4.9 commit changes into this patch
        d775b65ecaf6 ("ANDROID: mmc: core: Remove stray CONFIG_EXPERIMENTAL dependencies")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
San Mehat
c2cac75711 ANDROID: mmc: sd: Add retries in re-detection
Signed-off-by: San Mehat <san@android.com>

mmc: sd: Remove debugging printk

Signed-off-by: Dima Zavin <dima@android.com>
2017-12-18 21:11:22 +05:30
San Mehat
0a830ddfec ANDROID: mmc: sd: When resuming, try a little harder to init the card
Signed-off-by: San Mehat <san@android.com>
2017-12-18 21:11:22 +05:30
San Mehat
ff172d75e3 ANDROID: mmc: sd: Add new CONFIG_MMC_PARANOID_SD_INIT for enabling retries during SD detection
Change-Id: I4e6b9d9a3600d7efbee1d8379e45db11c57827f2
Signed-off-by: San Mehat <san@google.com>
2017-12-18 21:11:22 +05:30
Colin Cross
8392add7be ANDROID: mm: add a field to store names for private anonymous memory
Userspace processes often have multiple allocators that each do
anonymous mmaps to get memory.  When examining memory usage of
individual processes or systems as a whole, it is useful to be
able to break down the various heaps that were allocated by
each layer and examine their size, RSS, and physical memory
usage.

This patch adds a user pointer to the shared union in
vm_area_struct that points to a null terminated string inside
the user process containing a name for the vma.  vmas that
point to the same address will be merged, but vmas that
point to equivalent strings at different addresses will
not be merged.

Userspace can set the name for a region of memory by calling
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, start, len, (unsigned long)name);
Setting the name to NULL clears it.

The names of named anonymous vmas are shown in /proc/pid/maps
as [anon:<name>] and in /proc/pid/smaps in a new "Name" field
that is only present for named vmas.  If the userspace pointer
is no longer valid all or part of the name will be replaced
with "<fault>".

The idea to store a userspace pointer to reduce the complexity
within mm (at the expense of the complexity of reading
/proc/pid/mem) came from Dave Hansen.  This results in no
runtime overhead in the mm subsystem other than comparing
the anon_name pointers when considering vma merging.  The pointer
is stored in a union with fieds that are only used on file-backed
mappings, so it does not increase memory usage.

Includes fix from Jed Davis <jld@mozilla.com> for typo in
prctl_set_vma_anon_name, which could attempt to set the name
across two vmas at the same time due to a typo, which might
corrupt the vma list.  Fix it to use tmp instead of end to limit
the name setting to a single vma at a time.

Change-Id: I9aa7b6b5ef536cd780599ba4e2fba8ceebe8b59f
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>

[AmitP: Fix get_user_pages_remote() call to align with upstream commit
        5b56d49fc31d ("mm: add locked parameter to get_user_pages_remote()")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Greg Hackmann
1416d1c439 ANDROID: HACK: arm64: use -mno-implicit-float instead of -mgeneral-regs-only
LLVM bug 30792 causes clang's AArch64 backend to crash compiling
arch/arm64/crypto/aes-ce-cipher.c.  Replacing -mgeneral-regs-only with
-mno-implicit-float is the suggested workaround.

Drop this patch once the clang bug has been fixed.

Change-Id: I89fda12d826783ffe18142ba048ff10bd769e240
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>

[AmitP: Refactored the changes to align with changes from upstream commit
        bbb56c27228d ("arm64: Add detection code for broken .inst support in binutils")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Greg Hackmann
b9b964626e ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple
Android has an unusual setup where the kernel needs to target
[arch]-linux-gnu to avoid Android userspace-specific flags and
optimizations, but AOSP doesn't ship a matching binutils.

Add a new variable CLANG_TRIPLE which can override the "-target" triple
used to compile the kernel, while using a different CROSS_COMPILE to
pick the binutils/gcc installation.  For Android you'd do something
like:

  export CLANG_TRIPLE=aarch64-linux-gnu-
  export CROSS_COMPILE=aarch64-linux-android-

If you don't need something like this, leave CLANG_TRIPLE unset and it
will default to CROSS_COMPILE.

Change-Id: I85d63599c6ab8ed458071cdf9197d85b1f7f150b
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2017-12-18 21:11:22 +05:30
Matthias Kaehlcke
8c82740b2d CHROMIUM: arm64: Disable asm-operand-width warning for clang
clang raises 'asm-operand-widths' warnings in inline assembly code when
the size of an operand is < 64 bits and the operand width is unspecified.
Most warnings are raised in macros, i.e. the datatype of the operand may
vary. Most of these warnings are fixed in upstream, however we consider it
isn't worth the effort/risk to backport all the necessary changes. On
future CrOS kernels >= v4.13 the warning should be re-enabled.

Change-Id: Ie44748344853f5a394879718ad5d6f610f3c396a
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
2017-12-18 21:11:22 +05:30
Matthias Kaehlcke
4cd9453d6a CHROMIUM: kbuild: clang: Disable the 'duplicate-decl-specifier' warning
clang generates plenty of these warnings in different parts of the code.
They are mostly caused by container_of() and other macros which declare
a "const <type> *" variable for their internal use which triggers a
"duplicate 'const' specifier" warning if the <type> is already const
qualified.

Change-Id: I3ad9d33e31b7b40f926554eed2afeea1ebb7e961
Wording-mostly-from: Michael Davidson <md@google.com>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
2017-12-18 21:11:22 +05:30
Amit Pundir
44ffc07716 ANDROID: kbuild: Makefile.clean: make Kbuild and Makefile optional
AOSP commit b13ce9f4aa6f "ARM64: add option to build
Image.gz/dtb combo" broke archclean / mrproper build
targets and we run into:
----------
./scripts/Makefile.clean:14: arch/arm64/boot/amd/Makefile: No such file or directory
make[2]: *** No rule to make target `arch/arm64/boot/amd/Makefile'.  Stop.
make[1]: *** [arch/arm64/boot/amd] Error 2
make: *** [archclean] Error 2
----------

This patch skip the missing Kbuild/Makefile reporting
error. It does the job (i.e cleanup dts/*/*.dtb and
do not spit out missing file error messages as well).

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Rom Lemarchand
ef1b6e4e1e ANDROID: kbuild: make it possible to specify the module output dir
Make modinst_dir user-defined on the command line.

This allows to do things like:
make MODLIB=output/ modinst_dir=. modules_install

to ensure all the .ko are in the output/ directory.

Change-Id: I2bc007eea27ee744d35289e26e4a8ac43ba04151
Signed-off-by: Rom Lemarchand <romlem@android.com>
2017-12-18 21:11:22 +05:30
Lingfeng Yang
94a421ba2a ANDROID: input: goldfish_events: no extra EV_SYN; register goldfish
If we send SYN_REPORT on every single
multitouch event, it breaks the multitouch.

The multitouch becomes janky and
having to click 2-3 times to
do stuff (plus randomly activating notification
bars when not clicking)

If we suppress these SYN_REPORTS,
multitouch will work fine, plus the events
will have a protocol that looks nice.

In addition, we need to register Goldfish Events
as a multitouch device by issuing
input_mt_init_slots, otherwise
input_handle_abs_event in drivers/input/input.c
will silently drop all ABS_MT_SLOT events,
making it so that touches with more than 1 finger
do not work properly.

Signed-off-by: "Lingfeng Yang" <lfy@google.com>
Change-Id: Ib2350f7d1732449d246f6f0d9b7b08f02cc7c2dd
(cherry picked from commit 6cf40d0a16330e1ef42bdf07d9aba6c16ee11fbc)
2017-12-18 21:11:22 +05:30
Mohan Srinivasan
29be5c0c2e ANDROID: input: keychord: Fix for a memory leak in keychord.
Fixes a steady memory leak in the keychord release code. A close of
the keychord device will leak 1 keychord structure. Easily
reproducible by a simple program that does an open()->write()->close()
of the keychord device.

Bug: 64483974
Change-Id: I1fa402c666cffb00b8cfd6379d9fe47a0989152c
Signed-off-by: Mohan Srinivasan <srmohan@google.com>
2017-12-18 21:11:22 +05:30
Mohan Srinivasan
8253552b99 ANDROID: input: keychord: Fix races in keychord_write.
There are multiple bugs caused by threads racing in keychord_write.
1) Threads racing through this function can cause the same element to
be added to a linked list twice (multiple calls to
input_register_handler() for the same input_handler struct). And the
races can also cause an element in a linked list that doesn't exist
attempted to be removed (multiple calls to input_unregister_handler()
with the same input_handler struct).
2) The races can also cause duplicate kfree's of the keychords
struct.

Bug: 64133562
Bug: 63974334
Change-Id: I6329a4d58c665fab5d3e96ef96391e07b4941e80
Signed-off-by: Mohan Srinivasan <srmohan@google.com>
2017-12-18 21:11:22 +05:30
Mohan Srinivasan
92fc7f9aa0 ANDROID: input: keychord: Fix a slab out-of-bounds read.
Fix a slab out of bounds read in keychord_write(), detected by KASAN.

Signed-off-by: Mohan Srinivasan <srmohan@google.com>
Bug: 63962952
Change-Id: Iafef48b5d7283750ac0f39f5aaa767b1c3bf2004

[AmitP: Folded following android-4.9 commit changes into this patch
        a1e4c795e1b6 ("Use %zu to print resid (size_t).")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
JP Abgrall
4017c45e8b ANDROID: input: keychord: log when keychord triggered
log keychord id at info level just before waking up processes.

Signed-off-by: JP Abgrall <jpa@google.com>

[AmitP: Rename task_list in wait_queue_head{} to align with upstream commit
        2055da97389a ("sched/wait: Disambiguate wq_entry->task_list and wq_head->task_list naming")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Eric Ernst
3ed870f4b0 ANDROID: input: keyreset: switch to orderly_reboot
Prior restart function would make a call to sys_sync and then
execute a kernel reset.  Rather than call the sync directly,
thus necessitating this driver to be builtin, call orderly_reboot,
which will take care of the file system sync.

Note: since CONFIG_INPUT Kconfig is tristate, this driver can be built
as module, despite being marked bool.

Signed-off-by: Eric Ernst <eric.ernst@linux.intel.com>
2017-12-18 21:11:22 +05:30
Daniel Rosenberg
514c1205c9 ANDROID: input: keyreset: Made keyreset more robust
Switched do_restart to run in a seperate workqueue to  handle
cases where kernel_restart hangs.

Change-Id: I1ecd61f8d0859f1a86d37c692351d644b5db9c69
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2017-12-18 21:11:22 +05:30
Daniel Rosenberg
e82706f010 ANDROID: input: keyreset: Changed keyreset to act as a wrapper for keycombo.
keyreset now registers a keycombo driver that acts as the old
keyreset driver acted.

Change-Id: I08f5279e3a33b267571b699697f9f54508868983
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2017-12-18 21:11:22 +05:30
Daniel Rosenberg
c0f873e9ac ANDROID: input: keycombo: add keycombo, a general key combo driver.
Keycombo lets you provide a key up and key down function, and an
optional time delay for key down. The driver will call the key
down function after the specified key combo has been held for the
speicified time delay. After you release the combo, if the key down
has happened, it calls key up.

Change-Id: I6a9a94e96a8f58fadd908fd1dc7944b9102a089f
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2017-12-18 21:11:22 +05:30
Mike Lockwood
08a0437bf8 ANDROID: input: keychord: Add keychord driver
This driver allows userspace to receive notification when client
specified key combinations are pressed.
The client opens /dev/keychord and writes a list of keychords
for the driver to monitor.
The client then reads or polls /dev/keychord for notifications.
A client specified ID for the keychord is returned from read()
when a keychord press is detected.

Signed-off-by: Mike Lockwood <lockwood@android.com>

keychord: fix to build without CONFIG_PREEMPT

Change-Id: I911f13aeda4224b6fa57863bc7e8972fec8837fb

[AmitP: Folded following android-4.9 commit changes into this patch
        f4d1cf1208fe ("ANDROID: input: misc: keychord: move header to uapi")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Arve Hjønnevåg
dd06fdde72 ANDROID: input: keyreset: Add keyreset driver.
Add a platform device in the board file to specify a reset key-combo.
The first time the key-combo is detected a work function that syncs
the filesystems is scheduled. If all the keys are released and then
pressed again, it calls panic. Reboot on panic should be set for
this to work.

Change-Id: I9d54283ca1fba45e4b1ae1a407524cdda8171143
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2017-12-18 21:11:22 +05:30
Dmitry Shmidt
bbaee1971e ANDROID: input: gpio_matrix: Remove wakelock.h dependencies
Change-Id: I228bcdebf28f5c67765002043d3f919718827316
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-12-18 21:11:22 +05:30
Todd Poynor
a177fb102f ANDROID: input: gpio_input: convert from wakelocks to wakeup sources
And add device names to wakeup source names

Change-Id: Ia5f2723319a2e749f00d6ec7d846edff6af6d5c2
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2017-12-18 21:11:22 +05:30
Colin Cross
1e8d9257c6 ANDROID: input: gpio_event: remove early suspend
Remove the early suspend handler.  Leave the suspend functions
for now, they should eventually get called through a userspace
interface.x

Change-Id: I67f9dafe32fe32577bab93c42b95824db96c215c
Signed-off-by: Colin Cross <ccross@android.com>
2017-12-18 21:11:22 +05:30
Arve Hjønnevåg
df4ef815c8 ANDROID: input: Generic GPIO Input devices
Supports keyboard matrixces, direct inputs, direct outputs and axes connected to gpios.

Change-Id: I5e921e6e3a1cc169316ee3b665f4cc21b5735114
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Nick Pelly <npelly@google.com>

[AmitP: Use ktime directly to align with upstream commit
        2456e8553544 ("ktime: Get rid of the union")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Rom Lemarchand
6a45470bc3 ANDROID: initramfs: Add skip_initramfs command line option
Add a skip_initramfs option to allow choosing whether to boot using
the initramfs or not at runtime.

Change-Id: If30428fa748c1d4d3d7b9d97c1f781de5e4558c3
Signed-off-by: Rom Lemarchand <romlem@google.com>
2017-12-18 21:11:22 +05:30
Jin Qian
d02a7ff02e ANDROID: build: add build server configs for goldfish
Change-Id: Icd7a8d44df2b09394be5c6230c64ecb374cae236

[AmitP: Folded following android-4.9 commit changes into this patch
        d7d2efab84d5 ("ANDROID: build: fix build config kernel_dir")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Jin Qian
b57a40f564 ANDROID: goldfish: add ranchu defconfigs
Change-Id: I73ef1b132b6203ae921a1e1d4850eaadf58f8926

[AmitP: Folded following android-4.9 commit changes into this patch
        b821439faf75 ("ANDROID: arm64: rename ranchu defconfig to ranchu64")
        1a03fc05a569 ("ANDROID: goldfish: enable CONFIG_INET_DIAG_DESTROY")
        2bed6160b367 ("ANDROID: goldfish: disable GOLDFISH_SYNC")
        ec6a764367a4 ("ANDROID: goldfish_sync: update defconfig for 4.9-compatible version")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Amit Pundir
0eb2b3b251 ANDROID: goldfish_sync_timeline: Rename fence to dma_fence
Rename fence interfaces to dma_fence to match with the upstream
commit, f54d1867005c ("dma-buf: Rename struct fence to dma_fence"),
changes.

FIXME: Might be a good idea to remove goldfish_sync_timeline and
       use upstream sync_timeline interfaces instead.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Lingfeng Yang
ad2d529e6d ANDROID: goldfish_sync: 32 max cmds to save stack
We never use the 64 anyway.

Should fix compile warning.

Change-Id: I384155cc24e0a259d7d3898f310fc33154991311
Signed-off-by: Lingfeng Yang <lfy@google.com>
2017-12-18 21:11:22 +05:30
Dmitry Shmidt
deb85ad87d ANDROID: goldfish_sync: Fix sync_file_obj is NULL but dereferenced problem
Change-Id: I22c1e8c96a62ceaf3b0088b0b81dced6889334ab
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-12-18 21:11:22 +05:30
Dmitry Shmidt
3e59166fc3 ANDROID: goldfish_sync: Isolate single module to fix compilation
ERROR: "goldfish_sync_timeline_signal_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!
ERROR: "goldfish_sync_timeline_create_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!
ERROR: "goldfish_sync_pt_create_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!
ERROR: "goldfish_sync_timeline_put_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!

Change-Id: I2a97c2a33b38ceeb696d28187539c158aa97a620
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-12-18 21:11:22 +05:30
Lingfeng Yang
d1c4322ea1 ANDROID: goldfish_sync: upgrade to new fence sync api
goldfish_sync requires the following modifications
to bring it up:

- Copy and integrate goldfish_sync version of
sw_sync, from out of dma-buf driver.
- Don't delete timelines by itself; rely on put

Change-Id: Ie88d506955dbf5c8532281f122471dc7b1c0bccb
Signed-off-by: Lingfeng Yang <lfy@google.com>
2017-12-18 21:11:22 +05:30
Lingfeng Yang
818555892c ANDROID: goldfish_sync: Add goldfish sync driver
This is kernel driver for controlling the Goldfish sync
device on the host. It is used to maintain ordering
in critical OpenGL state changes while using
GPU emulation.

The guest open()'s the Goldfish sync device to create
a context for possibly maintaining sync timeline and fences.
There is a 1:1 correspondence between such sync contexts
and OpenGL contexts in the guest that need synchronization
(which in turn, is anything involving swapping buffers,
SurfaceFlinger, or Hardware Composer).

The ioctl QUEUE_WORK takes a handle to a sync object
and attempts to tell the host GPU to wait on the sync object
and deal with signaling it. It possibly outputs
a fence FD on which the Android systems that use them
(GLConsumer, SurfaceFlinger, anything employing
EGL_ANDROID_native_fence_sync) can use to wait.

Design decisions and work log:

- New approach is to have the guest issue ioctls that
  trigger host wait, and then host increments timeline.
- We need the host's sync object handle and sync thread handle
  as the necessary information for that.
- ioctl() from guest can work simultaneously with the
  interrupt handling for commands from host.
- optimization: don't write back on timeline inc
- Change spin lock design to be much more lightweight;
  do not call sw_sync functions or loop too long
  anywhere.
- Send read/write commands in batches to minimize guest/host
  transitions.
- robustness: BUG if we will overrun the cmd buffer.
- robustness: return fd -1 if we cannot get an unused fd.
- correctness: remove global mutex
- cleanup pass done, incl. but not limited to:
    - removal of clear_upto and
    - switching to devm_***

This is part of a sequential, multi-CL change:

external/qemu:

https://android-review.googlesource.com/239442 <- host-side device's
host interface

https://android-review.googlesource.com/221593
https://android-review.googlesource.com/248563
https://android-review.googlesource.com/248564
https://android-review.googlesource.com/223032

external/qemu-android:

https://android-review.googlesource.com/238790 <- host-side device
implementation

kernel/goldfish:

https://android-review.googlesource.com/232631 <- needed
https://android-review.googlesource.com/238399 <- this CL

Also squash following bug fixes from android-goldfish-3.18 branch.

b44d486 goldfish_sync: provide a signal to detect reboot
ad1f597 goldfish_sync: fix stalls by avoiding early kfree()
de208e8 [goldfish-sync] Fix possible race between kernel and user space

Change-Id: I22f8a0e824717a7e751b1b0e1b461455501502b6
2017-12-18 21:11:22 +05:30
Joshua Lang
bdcc178732 ANDROID: goldfish_audio: Clear audio read buffer status after each read
The buffer_status field is interrupt updated. After every read request,
the buffer_status read field should be reset so that on the next loop
iteration we don't read a stale value and read data before the
device is ready.

Signed-off-by: “Joshua Lang” <joshualang@google.com>
Change-Id: I4943d5aaada1cad9c7e59a94a87c387578dabe86
2017-12-18 21:11:22 +05:30
Yu Ning
038357818e ANDROID: goldfish_audio: Enable ACPI-based enumeration for goldfish audio
Follow the same way in which ACPI was enabled for goldfish battery. See
commit d3be10e for details.

Change-Id: I6ffe38ebc80fb8af8322152370b9d1fd227eaf50
Signed-off-by: Yu Ning <yu.ning@intel.com>
2017-12-18 21:11:22 +05:30
Christoffer Dall
670b5d24dd ANDROID: goldfishfb: Set pixclock = 0
User space Android code identifies pixclock == 0 as a sign for emulation
and will set the frame rate to 60 fps when reading this value, which is
the desired outcome.

Change-Id: I759bf518bf6683446bc786bf1be3cafa02dd8d42
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-12-18 21:11:22 +05:30
Yu Ning
32302fb983 ANDROID: goldfishfb: Enable ACPI-based enumeration for goldfish framebuffer
Follow the same way in which ACPI was enabled for goldfish battery. See
commit d3be10e for details.

Note that this patch also depends on commit af33cac.

Change-Id: Ic63b6e7e0a4b9896ef9a9d0ed135a7796a4c1fdb
Signed-off-by: Yu Ning <yu.ning@intel.com>
2017-12-18 21:11:22 +05:30
Greg Hackmann
89d5196454 ANDROID: goldfishfb: add devicetree bindings
Change-Id: I5f4ba861b981edf39af537001f8ac72202927031
Signed-off-by: Greg Hackmann <ghackmann@google.com>

[AmitP: Folded following android-4.9 commit changes into this patch
        e4bc8c96ba03 ("ANDROID: video: goldfishfb: fix platform_no_drv_owner.cocci warnings")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Christian Poetzsch
078204d5b8 ANDROID: fs: Fix for in kernel emergency remount when loop mounts are used
adb reboot calls /proc/sysrq-trigger to force an emergency remount (ro) of all
mounted disks. This is executed in the order of the time the mount was originally
done. Because we have a test system which loop mount images from an extra
partition, we see errors cause the loop mounted partitions gets remounted after
this physical partition was set to read only already.

Fix this by reversing the order of the emergency remount. This will remount the
disk first which have been mounted last.

So instead of remounting in this order:
 /dev/sda1
 /dev/loop1
 /dev/loop2
we now remount in this order:
 /dev/loop2
 /dev/loop1
 /dev/sda1

Change-Id: I68fe7e16cc9400ab5278877af70c9ea1d9b57936
Signed-off-by: Christian Poetzsch <christian.potzsch@imgtec.com>
2017-12-18 21:11:22 +05:30
Mohan Srinivasan
a59d873237 ANDROID: fs: Refactor FS readpage/write tracepoints.
Refactor the fs readpage/write tracepoints to move the
inode->path lookup outside the tracepoint code, and pass a pointer
to the path into the tracepoint code instead. This is necessary
because the tracepoint code runs non-preemptible. Thanks to
Trilok Soni for catching this in 4.4.

Signed-off-by: Mohan Srinivasan <srmohan@google.com>

[AmitP: Folded following android-4.9 commit changes into this patch
        a5c4dbb05ab7 ("ANDROID: Replace spaces by '_' for some android filesystem tracepoints.")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30