History log of /frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
371bf907fe24c01a03f526b15ead08f7261350ce 11-Jan-2018 John Bates <jbates@google.com> Rearm pdx fd on errors

This is not necessarily fixing anything, because we haven't
seen these errors in logs to confirm that they are problems.

However, we should always rearm on non-fatal errors.

Bug: 71759645
Test: Manually built and ran, but unclear how to trigger those errors.
Change-Id: Ia2bf3e6affaf8905d56fd82e0bbd0fbc9bf4f304
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
52ea25cf06cef250ec73052611b48556b3fce4d5 14-Sep-2017 Corey Tabaka <eieio@google.com> Add shared memory based buffer metadata

This CLs reduces BufferHub CPU consumption by adding asynchronous
state transition so that out-of-process VR composition can run on 2016
pixel devices smoothly. In addition, this CL addresses a couple corner
cases in the existing bufferhub logic, which fixes various blackscreen
issues.

1/ Tracks buffer transition states (gained, posted, acquired, released)
from the client side via atomic shared memory and adds
PostAsync/AcquireAsync/ReleaseAsync/GainAsync with metadata and
fence support.
2/ Adds dequeue order guarantee for buffers enqueued with
dvrWriteBufferQueuePostBuffer.
3/ Synchronous BuffeHub operations are still supported.
4/ Bump up the bufferhubd's soft limit of open file descriptor.
5/ Handle orphaned consumer in acquired state. This is a corner case
that consumer process goes aways (most likely due to a crash) leaving
buffer stuck in acquired state with inconsistent buffer state.
6/ Fixes a race condition for released buffer to be Gain'ed and
Acquire'd when a new consumer is created in released state.
7/ Improve silent consumer queue efficiency: Silent queues no longer
import buffers or receive signals about new buffers and they are
limited to only spawning other consumers and notifications about
producers hanging up.
8/ Modify PDX/UDS channel event signaling to work around epoll
behavior. PDX UDS uses a combination of an eventfd and an epoll set
to simulate the original PDX transport channel events. An odd
behavior discovered in the kernel implementation of epoll was found
that causes the epoll fd to "unsignal" itself whenever epoll_wait()
is called on it, regardless of whether it should still be
pending. This breaks the edge triggerd behavior in nested epoll sets
that channel events depend on. Since this is unlikely to ever be
fixed in the kernel we work around the behavior by using the epoll
set only as a logical OR of two eventfds and never calling
epoll_wait() on it. When polling is required we use regluar poll()
with the eventfds and data fd to avoid the bad behavior in
epoll_wait().
9/ Keep reading data after PDX hangup signal. UDS will signal hangup
when the other end of the socket closes. However, data could still be
in the kerenl buffer and should be consumed. Fix an issue where the
service misses an impulse sent right before the socket is closed.

Bug: 65455724
Bug: 65458354
Bug: 65458312
Bug: 64027135
Bug: 67424527
Test: libpdx_uds_tests
bufferhub_tests
buffer_hub_queue-test
buffer_hub_queue_producer-test
dvr_api-test

Change-Id: Id07db1f206ccf4e06f7ee3c671193334408971ca
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
4a7762afb4fa8495e711fcc2da322fc388e700bc 02-May-2017 Alex Vakulenko <avakulenko@google.com> Apply correct SELinux labels to PDX endpoint and channel sockets.

Bug: 37646189
Test: Compiled for sailfish-eng
Device booted, normal 2D UI works as before
Was able to run Daydream app and CubeSea (before O1 VR rendering
path was disabled by recent change in HW composer).

Change-Id: I1f7040324992d3c784f072ea6b64a65fa7ed0589
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
e41826ac301b9afad1cbfe59c57e27f2495be968 02-May-2017 Alex Vakulenko <avakulenko@google.com> libpdx_uds: Always create channel sockets in the server process

Whenever a client connects to PDX service endpoint, the connected
socket was being used as the channel connection. This makes it
difficult to ensure that the socket has the appropriate SELinux
label applied.

Changed the implementation to make sure that the actual channel socket
pair is created in one place in the server process.

The new Endpoint::CreateChannelSocketPair() is now being used to
create the channel sockets when an incoming connection is accepted
and when PushChannel request is received.

The newly created channel socket is sent to the client in response
to connection request.

Bug: 37646189
Test: Device boots. CubeSea launches.
Change-Id: Id3158484aeb18007f18b279afc60613076f80f14
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
6eefa42d33bdddc3603211634f98937b00abc532 18-Apr-2017 Alex Vakulenko <avakulenko@google.com> libpdx_uds: Allow to create Endpoint/ClientChannel from a socket pair

This is important to enable Service/Client operation in unit tests.
Being able to create a pair of Unix domain sockets and construct both
Service and Client so that they can talk to each other without having
to create a physical socket file is convenient.

This change makes it possible to create an instance of Endpoint and
ClientChannel classes based just on a pair of sockets (Endpoint does
take another socket to simulate the main endpoint FD to accept incoming
connection on, but it is not used for this, only the shutdown events
are received from that main socket. Endpoint uses the channel FD to
perform actual communication with the client).

Bug: 37443070
Test: `libpdx_uds_tests` pass
Change-Id: Ifa1a9d03b97bd90282a04715c2105ad37a8de936
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
09aa736ee6136787b18807d7ab459feba23cec04 06-Apr-2017 Alex Vakulenko <avakulenko@google.com> libpdx_uds: Fix RPC channel ID allocation to not recycle values as often

The value of channel ID for PDX service on UDS transport was actual file
descriptor value for the data socket. Since channels are open and closed
constantly, it is quite often that channel ID is being reused immediately,
so it is almost impossible to use `cid` as unique identifier for objects
being passed around.

Instead, we now use monotonically growing channel ID value.

To prevent the possibility of using channel ID as the socket FD and vice
versa, changed all helper functions that used to take socket_fd as an int
to explicitly use BorrowedHandle which disables implicit conversion from
int (and hence makes it impossible to mistakenly pass in the channel ID).

Bug: 37082296
Test: `m -j32` succeeds for sailfish-eng
Ran libpdx_uds_tests on the device -> all pass
Device boots and CubeSea and VrHome render correctly with vr_flinger

Change-Id: Ibb8dfee4d6c3f4b6120c0b6e20a253f1b9307c19
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
409c6eecdca80e95a110d63bc70b1c2dfcf49100 24-Mar-2017 Alex Vakulenko <avakulenko@google.com> Make init process create PDX sockets for services

To help us control the creation of PDX sockets and properly labeling
them for SELinux, let the init process create sockets for us based on
the settings specified in .rc files for service processes.

For (test) services that are meant to be started manually from command
line (e.g. test services), keep the old functionality as an option so
that UDS endpoint can be created in a way that it automatically creates
the socket in the service itself.

Bug: 35220925
Test: `m -j32` succeeds. Ran sailfish in VR mode and made sure all the
services (surfaceflinger, performanced, sensord, bufferhub).
`m -j32 checkbuild` succeeds as well.

Change-Id: Ief733b41b534cea19b1bea31de76b06051aa50ab
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
f0a7bd033941e26e380232a0515e903cf8e678e5 01-Apr-2017 Alex Vakulenko <avakulenko@google.com> pdx: Rework error reporting when transfering file and channel handles

There is a lot of confusion about reporting errors when passing file
and channel handles over PDX transport between client and service.

Methods like Message::PushFileHandle return an integer which means
both a file handle reference value (if positive) and a possible error
code (if negative). But file handles could contain negative values too
(when they are empty). This is used frequently when passing buffer
fences around (when a fence is not being used, its fd is set to -1).

This results in a special case of when PushFileHandle is called with
a file handle with value of -1, the return value is actually "-errno"
which becomes dependent on a global state (errno is not set by
PushFileHandle itself in case file handle value is negative) and results
in unpredicted behavior (sometimes errno is 0, sometimes its >0).

Cleaned this all up by using Status<T> everywhere we used an int to
pass value payload along with possible error code.

Now the semantics of the calls are more clear.

Bug: 36866492
Test: `m -j32` for sailfish-eng succeeds
Ran unit tests on device (pdx_tests, libpdx_uds_tests, bufferhub_tests,
buffer_hub_queue-test, buffer_hub_queue_producer-test), all pass
Ran CubeSea, NativeTreasureHunt and Ithaca on Sailfish with vrflinger
enabled, was able to use controller and screen rendered correctly.

Change-Id: I0f40c3f356fcba8bc217d5219a0ddf9685e57fd7
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
6890d95ec8b96970202518b439bfa8ab2d9dbf77 20-Jan-2017 Corey Tabaka <eieio@google.com> libpdx: Add support for more event bits.

- Add generic abstraction for multiple event bits with an implementation-
defined mechanism to deliver the bits.
- Update ServiceFS backend to pass through event bits.
- Implement EPOLLIN, EPOLLPRI, and EPOLLHUP event bit for UDS backed.

Bug: 34466748
Test: Build/flash system; observe stable operation.

Change-Id: I86afb5645b72ec69c095734c7891a690432150a3
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp
e4eec20f6263f4a42ae462456f60ea6c4518bb0a 27-Jan-2017 Alex Vakulenko <avakulenko@google.com> Add DaydreamVR native libraries and services

Upstreaming the main VR system components from master-dreamos-dev
into goog/master.

Bug: None
Test: `m -j32` succeeds. Sailfish boots and basic_vr sample app works
Change-Id: I853015872afc443aecee10411ef2d6b79184d051
/frameworks/native/libs/vr/libpdx_uds/service_endpoint.cpp