summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnkit Goyal <layog@google.com>2021-10-08 05:27:36 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-10-08 05:27:36 +0000
commit4a222191824349d125db714c281b9c09d88c2d0a (patch)
tree179130bb685a4c0998e7a9b13847f92d89c4d959
parent5489b4d8ac5103eb3fe9c8e22d0b09986d919f94 (diff)
parent03316c5e63d1db54ae060c2f4212868e40fcb0dc (diff)
downloadgchips-4a222191824349d125db714c281b9c09d88c2d0a.tar.gz
Merge "Maximize the priority of gralloc allocator thread" into sc-qpr1-dev am: 03316c5e63
Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/google/gchips/+/15980928 Change-Id: I82a2e9adbe0de6838f891cd4d1481171c782d8b0
-rw-r--r--gralloc4/service/4.x/Android.bp4
-rw-r--r--gralloc4/service/4.x/service.cpp27
-rw-r--r--gralloc4/src/4.x/GrallocAllocator.cpp10
3 files changed, 28 insertions, 13 deletions
diff --git a/gralloc4/service/4.x/Android.bp b/gralloc4/service/4.x/Android.bp
index de06942..5bd81bc 100644
--- a/gralloc4/service/4.x/Android.bp
+++ b/gralloc4/service/4.x/Android.bp
@@ -29,8 +29,12 @@ cc_binary {
init_rc: [
"android.hardware.graphics.allocator@4.0-service.rc",
],
+ header_libs: [
+ "libgralloc_headers",
+ ],
shared_libs: [
"android.hardware.graphics.allocator@4.0",
+ "android.hardware.graphics.allocator@4.0-impl",
"libhidlbase",
"liblog",
"libutils",
diff --git a/gralloc4/service/4.x/service.cpp b/gralloc4/service/4.x/service.cpp
index bd28407..d540086 100644
--- a/gralloc4/service/4.x/service.cpp
+++ b/gralloc4/service/4.x/service.cpp
@@ -16,13 +16,30 @@
*/
#define LOG_TAG "android.hardware.graphics.allocator@4.0-service"
-#include <android/hardware/graphics/allocator/4.0/IAllocator.h>
+#include <hidl/HidlTransportSupport.h>
+#include <hidl/Status.h>
+#include <utils/StrongPointer.h>
-#include <hidl/LegacySupport.h>
+#include "4.x/GrallocAllocator.h"
-using android::hardware::defaultPassthroughServiceImplementation;
-using android::hardware::graphics::allocator::V4_0::IAllocator;
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::hardware::setMinSchedulerPolicy;
+using arm::allocator::GrallocAllocator;
int main() {
- return defaultPassthroughServiceImplementation<IAllocator>(/*maxThreads*/ 4);
+ android::sp<GrallocAllocator> service = new GrallocAllocator();
+ configureRpcThreadpool(4, true /* callerWillJoin */);
+
+ if (!setMinSchedulerPolicy(service, SCHED_NORMAL, -20)) {
+ ALOGW("Cannot bump allocator priority");
+ }
+
+ if (service->registerAsService() != android::OK) {
+ ALOGE("Cannot register allocator service");
+ return -EINVAL;
+ }
+
+ joinRpcThreadpool();
+ return 0;
}
diff --git a/gralloc4/src/4.x/GrallocAllocator.cpp b/gralloc4/src/4.x/GrallocAllocator.cpp
index 4e074b5..0ac81fd 100644
--- a/gralloc4/src/4.x/GrallocAllocator.cpp
+++ b/gralloc4/src/4.x/GrallocAllocator.cpp
@@ -40,6 +40,8 @@ unsigned long callingPid() {
GrallocAllocator::GrallocAllocator()
{
+ MALI_GRALLOC_LOGV("Arm Module IAllocator %d.%d, pid = %d ppid = %d", GRALLOC_VERSION_MAJOR,
+ (HIDL_ALLOCATOR_VERSION_SCALED - (GRALLOC_VERSION_MAJOR * 100)) / 10, getpid(), getppid());
}
GrallocAllocator::~GrallocAllocator()
@@ -64,11 +66,3 @@ Return<void> GrallocAllocator::allocate(const BufferDescriptor &descriptor, uint
} // namespace allocator
} // namespace arm
-
-extern "C" IAllocator *HIDL_FETCH_IAllocator(const char * /* name */)
-{
- MALI_GRALLOC_LOGV("Arm Module IAllocator %d.%d, pid = %d ppid = %d", GRALLOC_VERSION_MAJOR,
- (HIDL_ALLOCATOR_VERSION_SCALED - (GRALLOC_VERSION_MAJOR * 100)) / 10, getpid(), getppid());
-
- return new arm::allocator::GrallocAllocator();
-}