diff options
-rw-r--r-- | headers/media_plugin/media/openmax/OMX_VideoExt.h | 40 | ||||
-rw-r--r-- | libs/binder/Binder.cpp | 44 | ||||
-rw-r--r-- | libs/binder/Parcel.cpp | 24 | ||||
-rw-r--r-- | libs/binder/ProcessState.cpp | 60 | ||||
-rw-r--r-- | libs/binder/Static.cpp | 5 | ||||
-rw-r--r-- | libs/binder/Static.h | 4 | ||||
-rw-r--r-- | libs/binder/include/binder/Binder.h | 16 | ||||
-rw-r--r-- | libs/binder/include/binder/ProcessState.h | 4 | ||||
-rw-r--r-- | libs/binder/tests/binderLibTest.cpp | 32 | ||||
-rw-r--r-- | opengl/libs/EGL/egl_platform_entries.cpp | 2 | ||||
-rw-r--r-- | vulkan/libvulkan/code-generator.tmpl | 4 |
11 files changed, 193 insertions, 42 deletions
diff --git a/headers/media_plugin/media/openmax/OMX_VideoExt.h b/headers/media_plugin/media/openmax/OMX_VideoExt.h index 435fcc8cca..6dea71143b 100644 --- a/headers/media_plugin/media/openmax/OMX_VideoExt.h +++ b/headers/media_plugin/media/openmax/OMX_VideoExt.h @@ -320,6 +320,46 @@ typedef enum OMX_VIDEO_DOLBYVISIONLEVELTYPE { OMX_VIDEO_DolbyVisionLevelmax = 0x7FFFFFFF } OMX_VIDEO_DOLBYVISIONLEVELTYPE; +/** AV1 Profile enum type */ +typedef enum OMX_VIDEO_AV1PROFILETYPE { + OMX_VIDEO_AV1ProfileMain8 = 0x00000001, + OMX_VIDEO_AV1ProfileMain10 = 0x00000002, + OMX_VIDEO_AV1ProfileMain10HDR10 = 0x00001000, + OMX_VIDEO_AV1ProfileMain10HDR10Plus = 0x00002000, + OMX_VIDEO_AV1ProfileUnknown = 0x6EFFFFFF, + OMX_VIDEO_AV1ProfileMax = 0x7FFFFFFF +} OMX_VIDEO_AV1PROFILETYPE; + +/** AV1 Level enum type */ +typedef enum OMX_VIDEO_AV1LEVELTYPE { + OMX_VIDEO_AV1Level2 = 0x1, + OMX_VIDEO_AV1Level21 = 0x2, + OMX_VIDEO_AV1Level22 = 0x4, + OMX_VIDEO_AV1Level23 = 0x8, + OMX_VIDEO_AV1Level3 = 0x10, + OMX_VIDEO_AV1Level31 = 0x20, + OMX_VIDEO_AV1Level32 = 0x40, + OMX_VIDEO_AV1Level33 = 0x80, + OMX_VIDEO_AV1Level4 = 0x100, + OMX_VIDEO_AV1Level41 = 0x200, + OMX_VIDEO_AV1Level42 = 0x400, + OMX_VIDEO_AV1Level43 = 0x800, + OMX_VIDEO_AV1Level5 = 0x1000, + OMX_VIDEO_AV1Level51 = 0x2000, + OMX_VIDEO_AV1Level52 = 0x4000, + OMX_VIDEO_AV1Level53 = 0x8000, + OMX_VIDEO_AV1Level6 = 0x10000, + OMX_VIDEO_AV1Level61 = 0x20000, + OMX_VIDEO_AV1Level62 = 0x40000, + OMX_VIDEO_AV1Level63 = 0x80000, + OMX_VIDEO_AV1Level7 = 0x100000, + OMX_VIDEO_AV1Level71 = 0x200000, + OMX_VIDEO_AV1Level72 = 0x400000, + OMX_VIDEO_AV1Level73 = 0x800000, + OMX_VIDEO_AV1LevelUnknown = 0x6EFFFFFF, + OMX_VIDEO_AV1LevelMax = 0x7FFFFFFF +} OMX_VIDEO_AV1LEVELTYPE; + /** * Structure for configuring video compression intra refresh period * diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index e0fb54384e..6ca3b16324 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -24,6 +24,7 @@ #include <binder/IShellCallback.h> #include <binder/Parcel.h> +#include <linux/sched.h> #include <stdio.h> namespace android { @@ -133,6 +134,8 @@ public: // unlocked objects bool mRequestingSid = false; sp<IBinder> mExtension; + int mPolicy = SCHED_NORMAL; + int mPriority = 0; // for below objects Mutex mLock; @@ -279,6 +282,47 @@ sp<IBinder> BBinder::getExtension() { return e->mExtension; } +void BBinder::setMinSchedulerPolicy(int policy, int priority) { + switch (policy) { + case SCHED_NORMAL: + LOG_ALWAYS_FATAL_IF(priority < -20 || priority > 19, "Invalid priority for SCHED_NORMAL: %d", priority); + break; + case SCHED_RR: + case SCHED_FIFO: + LOG_ALWAYS_FATAL_IF(priority < 1 || priority > 99, "Invalid priority for sched %d: %d", policy, priority); + break; + default: + LOG_ALWAYS_FATAL("Unrecognized scheduling policy: %d", policy); + } + + Extras* e = mExtras.load(std::memory_order_acquire); + + if (e == nullptr) { + // Avoid allocations if called with default. + if (policy == SCHED_NORMAL && priority == 0) { + return; + } + + e = getOrCreateExtras(); + if (!e) return; // out of memory + } + + e->mPolicy = policy; + e->mPriority = priority; +} + +int BBinder::getMinSchedulerPolicy() { + Extras* e = mExtras.load(std::memory_order_acquire); + if (e == nullptr) return SCHED_NORMAL; + return e->mPolicy; +} + +int BBinder::getMinSchedulerPriority() { + Extras* e = mExtras.load(std::memory_order_acquire); + if (e == nullptr) return 0; + return e->mPriority; +} + pid_t BBinder::getDebugPid() { return getpid(); } diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 660b96a112..c7cb495d15 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -20,6 +20,7 @@ #include <errno.h> #include <fcntl.h> #include <inttypes.h> +#include <linux/sched.h> #include <pthread.h> #include <stdint.h> #include <stdio.h> @@ -188,16 +189,18 @@ status_t Parcel::finishUnflattenBinder( return OK; } +static constexpr inline int schedPolicyMask(int policy, int priority) { + return (priority & FLAT_BINDER_FLAG_PRIORITY_MASK) | ((policy & 3) << FLAT_BINDER_FLAG_SCHED_POLICY_SHIFT); +} + status_t Parcel::flattenBinder(const sp<IBinder>& binder) { flat_binder_object obj; + obj.flags = FLAT_BINDER_FLAG_ACCEPTS_FDS; - if (IPCThreadState::self()->backgroundSchedulingDisabled()) { - /* minimum priority for all nodes is nice 0 */ - obj.flags = FLAT_BINDER_FLAG_ACCEPTS_FDS; - } else { - /* minimum priority for all nodes is MAX_NICE(19) */ - obj.flags = 0x13 | FLAT_BINDER_FLAG_ACCEPTS_FDS; + int schedBits = 0; + if (!IPCThreadState::self()->backgroundSchedulingDisabled()) { + schedBits = schedPolicyMask(SCHED_NORMAL, 19); } if (binder != nullptr) { @@ -213,6 +216,13 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) obj.handle = handle; obj.cookie = 0; } else { + int policy = local->getMinSchedulerPolicy(); + int priority = local->getMinSchedulerPriority(); + + if (policy != 0 || priority != 0) { + // override value, since it is set explicitly + schedBits = schedPolicyMask(policy, priority); + } if (local->isRequestingSid()) { obj.flags |= FLAT_BINDER_FLAG_TXN_SECURITY_CTX; } @@ -226,6 +236,8 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) obj.cookie = 0; } + obj.flags |= schedBits; + return finishFlattenBinder(binder, obj); } diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index 0f81e0bef0..02e01934bb 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -32,6 +32,7 @@ #include <errno.h> #include <fcntl.h> +#include <mutex> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -73,38 +74,49 @@ protected: sp<ProcessState> ProcessState::self() { - Mutex::Autolock _l(gProcessMutex); - if (gProcess != nullptr) { - return gProcess; - } - gProcess = new ProcessState(kDefaultDriver); - return gProcess; + return init(kDefaultDriver, false /*requireDefault*/); } sp<ProcessState> ProcessState::initWithDriver(const char* driver) { - Mutex::Autolock _l(gProcessMutex); - if (gProcess != nullptr) { - // Allow for initWithDriver to be called repeatedly with the same - // driver. - if (!strcmp(gProcess->getDriverName().c_str(), driver)) { - return gProcess; - } - LOG_ALWAYS_FATAL("ProcessState was already initialized."); - } - - if (access(driver, R_OK) == -1) { - ALOGE("Binder driver %s is unavailable. Using /dev/binder instead.", driver); - driver = "/dev/binder"; - } - - gProcess = new ProcessState(driver); - return gProcess; + return init(driver, true /*requireDefault*/); } sp<ProcessState> ProcessState::selfOrNull() { - Mutex::Autolock _l(gProcessMutex); + return init(nullptr, false /*requireDefault*/); +} + +sp<ProcessState> ProcessState::init(const char *driver, bool requireDefault) +{ + [[clang::no_destroy]] static sp<ProcessState> gProcess; + [[clang::no_destroy]] static std::mutex gProcessMutex; + + if (driver == nullptr) { + std::lock_guard<std::mutex> l(gProcessMutex); + return gProcess; + } + + [[clang::no_destroy]] static std::once_flag gProcessOnce; + std::call_once(gProcessOnce, [&](){ + if (access(driver, R_OK) == -1) { + ALOGE("Binder driver %s is unavailable. Using /dev/binder instead.", driver); + driver = "/dev/binder"; + } + + std::lock_guard<std::mutex> l(gProcessMutex); + gProcess = new ProcessState(driver); + }); + + if (requireDefault) { + // Detect if we are trying to initialize with a different driver, and + // consider that an error. ProcessState will only be initialized once above. + LOG_ALWAYS_FATAL_IF(gProcess->getDriverName() != driver, + "ProcessState was already initialized with %s," + " can't initialize with %s.", + gProcess->getDriverName().c_str(), driver); + } + return gProcess; } diff --git a/libs/binder/Static.cpp b/libs/binder/Static.cpp index 779ed412ba..db0f1c7c3f 100644 --- a/libs/binder/Static.cpp +++ b/libs/binder/Static.cpp @@ -68,9 +68,4 @@ TextOutput& alog(*new LogTextOutput()); TextOutput& aout(*new FdTextOutput(STDOUT_FILENO)); TextOutput& aerr(*new FdTextOutput(STDERR_FILENO)); -// ------------ ProcessState.cpp - -Mutex& gProcessMutex = *new Mutex; -sp<ProcessState> gProcess; - } // namespace android diff --git a/libs/binder/Static.h b/libs/binder/Static.h index f8e0ee5f8d..83524e8575 100644 --- a/libs/binder/Static.h +++ b/libs/binder/Static.h @@ -27,8 +27,4 @@ namespace android { // For TextStream.cpp extern Vector<int32_t> gTextBuffers; -// For ProcessState.cpp -extern Mutex& gProcessMutex; -extern sp<ProcessState> gProcess; - } // namespace android diff --git a/libs/binder/include/binder/Binder.h b/libs/binder/include/binder/Binder.h index 74e52db53f..f3fea163cd 100644 --- a/libs/binder/include/binder/Binder.h +++ b/libs/binder/include/binder/Binder.h @@ -72,6 +72,22 @@ public: // This must be called before the object is sent to another process. Not thread safe. void setExtension(const sp<IBinder>& extension); + // This must be called before the object is sent to another process. Not thread safe. + // + // This function will abort if improper parameters are set. This is like + // sched_setscheduler. However, it sets the minimum scheduling policy + // only for the duration that this specific binder object is handling the + // call in a threadpool. By default, this API is set to SCHED_NORMAL/0. In + // this case, the scheduling priority will not actually be modified from + // binder defaults. See also IPCThreadState::disableBackgroundScheduling. + // + // Appropriate values are: + // SCHED_NORMAL: -20 <= priority <= 19 + // SCHED_RR/SCHED_FIFO: 1 <= priority <= 99 + void setMinSchedulerPolicy(int policy, int priority); + int getMinSchedulerPolicy(); + int getMinSchedulerPriority(); + pid_t getDebugPid(); protected: diff --git a/libs/binder/include/binder/ProcessState.h b/libs/binder/include/binder/ProcessState.h index e57ff1c260..9f5346ac27 100644 --- a/libs/binder/include/binder/ProcessState.h +++ b/libs/binder/include/binder/ProcessState.h @@ -42,6 +42,8 @@ public: * any call to ProcessState::self(). The default is /dev/vndbinder * for processes built with the VNDK and /dev/binder for those * which are not. + * + * If this is called with nullptr, the behavior is the same as selfOrNull. */ static sp<ProcessState> initWithDriver(const char *driver); @@ -90,6 +92,8 @@ public: void setCallRestriction(CallRestriction restriction); private: + static sp<ProcessState> init(const char *defaultDriver, bool requireDefault); + friend class IPCThreadState; explicit ProcessState(const char* driver); diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index 8cb06e17e9..f8ee32c70d 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -48,6 +48,9 @@ static char *binderservername; static char *binderserversuffix; static char binderserverarg[] = "--binderserver"; +static constexpr int kSchedPolicy = SCHED_RR; +static constexpr int kSchedPriority = 7; + static String16 binderLibTestServiceName = String16("test.binderLib"); enum BinderLibTestTranscationCode { @@ -73,6 +76,7 @@ enum BinderLibTestTranscationCode { BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION, BINDER_LIB_TEST_CREATE_BINDER_TRANSACTION, BINDER_LIB_TEST_GET_WORK_SOURCE_TRANSACTION, + BINDER_LIB_TEST_GET_SCHEDULING_POLICY, BINDER_LIB_TEST_ECHO_VECTOR, }; @@ -1012,6 +1016,22 @@ TEST_F(BinderLibTest, WorkSourcePropagatedForAllFollowingBinderCalls) EXPECT_EQ(NO_ERROR, ret2); } +TEST_F(BinderLibTest, SchedPolicySet) { + sp<IBinder> server = addServer(); + ASSERT_TRUE(server != nullptr); + + Parcel data, reply; + status_t ret = server->transact(BINDER_LIB_TEST_GET_SCHEDULING_POLICY, data, &reply); + EXPECT_EQ(NO_ERROR, ret); + + int policy = reply.readInt32(); + int priority = reply.readInt32(); + + EXPECT_EQ(kSchedPolicy, policy & (~SCHED_RESET_ON_FORK)); + EXPECT_EQ(kSchedPriority, priority); +} + + TEST_F(BinderLibTest, VectorSent) { Parcel data, reply; sp<IBinder> server = addServer(); @@ -1301,6 +1321,16 @@ class BinderLibTestService : public BBinder reply->writeInt32(IPCThreadState::self()->getCallingWorkSourceUid()); return NO_ERROR; } + case BINDER_LIB_TEST_GET_SCHEDULING_POLICY: { + int policy = 0; + sched_param param; + if (0 != pthread_getschedparam(pthread_self(), &policy, ¶m)) { + return UNKNOWN_ERROR; + } + reply->writeInt32(policy); + reply->writeInt32(param.sched_priority); + return NO_ERROR; + } case BINDER_LIB_TEST_ECHO_VECTOR: { std::vector<uint64_t> vector; auto err = data.readUint64Vector(&vector); @@ -1334,6 +1364,8 @@ int run_server(int index, int readypipefd, bool usePoll) { sp<BinderLibTestService> testService = new BinderLibTestService(index); + testService->setMinSchedulerPolicy(kSchedPolicy, kSchedPriority); + /* * Normally would also contain functionality as well, but we are only * testing the extension mechanism. diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp index a3bb6debe9..188d3ae9a6 100644 --- a/opengl/libs/EGL/egl_platform_entries.cpp +++ b/opengl/libs/EGL/egl_platform_entries.cpp @@ -98,7 +98,7 @@ char const * const gBuiltinExtensionString = "EGL_EXT_surface_CTA861_3_metadata " ; -// Whitelist of extensions exposed to applications if implemented in the vendor driver. +// Allowed list of extensions exposed to applications if implemented in the vendor driver. char const * const gExtensionString = "EGL_KHR_image " // mandatory "EGL_KHR_image_base " // mandatory diff --git a/vulkan/libvulkan/code-generator.tmpl b/vulkan/libvulkan/code-generator.tmpl index a5a0405f2d..f3e6ebd627 100644 --- a/vulkan/libvulkan/code-generator.tmpl +++ b/vulkan/libvulkan/code-generator.tmpl @@ -1137,7 +1137,7 @@ VK_KHR_bind_memory2 {{if not (GetAnnotation $ "pfn")}} {{$ext := GetAnnotation $ "extension"}} {{if not $ext}}true - {{else if not (Macro "IsExtensionBlacklisted" $ext)}}true + {{else if not (Macro "IsExtensionBlocked" $ext)}}true {{end}} {{end}} {{end}} @@ -1168,7 +1168,7 @@ VK_KHR_bind_memory2 Emit "true" if an extension is unsupportable on Android. ------------------------------------------------------------------------------ */}} -{{define "IsExtensionBlacklisted"}} +{{define "IsExtensionBlocked"}} {{$ext := index $.Arguments 0}} {{ if eq $ext "VK_KHR_display"}}true {{else if eq $ext "VK_KHR_display_swapchain"}}true |