display: hwc_buffer_allocator fixes
Fixes an issue where the HWC init randomly blocks on the allocator init by doing a lazy initialization of the allocator object. The allocator may not have fully initialized at HWC init. Also, increases the allocator connection threadpool to 4. Change-Id: I38454ee25aaf2a211125e55297300eac754fb5cf CRs-Fixed: 2201202
This commit is contained in:
@@ -37,7 +37,7 @@ using android::hardware::graphics::allocator::V2_0::IAllocator;
|
|||||||
|
|
||||||
int main(int, char **) {
|
int main(int, char **) {
|
||||||
android::sp<IAllocator> service = new QtiAllocator();
|
android::sp<IAllocator> service = new QtiAllocator();
|
||||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
configureRpcThreadpool(4, true /*callerWillJoin*/);
|
||||||
if (service->registerAsService() != android::OK) {
|
if (service->registerAsService() != android::OK) {
|
||||||
ALOGE("Cannot register QTI Allocator service");
|
ALOGE("Cannot register QTI Allocator service");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|||||||
@@ -47,7 +47,12 @@ using android::hardware::hidl_vec;
|
|||||||
|
|
||||||
namespace sdm {
|
namespace sdm {
|
||||||
|
|
||||||
DisplayError HWCBufferAllocator::Init() {
|
DisplayError HWCBufferAllocator::GetGrallocInstance() {
|
||||||
|
// Lazy initialization of gralloc HALs
|
||||||
|
if (mapper_ != nullptr || allocator_ != nullptr) {
|
||||||
|
return kErrorNone;
|
||||||
|
}
|
||||||
|
|
||||||
allocator_ = IAllocator::getService();
|
allocator_ = IAllocator::getService();
|
||||||
mapper_ = IMapper::getService();
|
mapper_ = IMapper::getService();
|
||||||
|
|
||||||
@@ -58,11 +63,11 @@ DisplayError HWCBufferAllocator::Init() {
|
|||||||
return kErrorNone;
|
return kErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayError HWCBufferAllocator::Deinit() {
|
|
||||||
return kErrorNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
|
DisplayError HWCBufferAllocator::AllocateBuffer(BufferInfo *buffer_info) {
|
||||||
|
auto err = GetGrallocInstance();
|
||||||
|
if (err != kErrorNone) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
const BufferConfig &buffer_config = buffer_info->buffer_config;
|
const BufferConfig &buffer_config = buffer_info->buffer_config;
|
||||||
AllocatedBufferInfo *alloc_buffer_info = &buffer_info->alloc_buffer_info;
|
AllocatedBufferInfo *alloc_buffer_info = &buffer_info->alloc_buffer_info;
|
||||||
int format;
|
int format;
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ inline Type ALIGN(Type x, Type align) {
|
|||||||
|
|
||||||
class HWCBufferAllocator : public BufferAllocator {
|
class HWCBufferAllocator : public BufferAllocator {
|
||||||
public:
|
public:
|
||||||
DisplayError Init();
|
|
||||||
DisplayError Deinit();
|
|
||||||
DisplayError AllocateBuffer(BufferInfo *buffer_info);
|
DisplayError AllocateBuffer(BufferInfo *buffer_info);
|
||||||
DisplayError FreeBuffer(BufferInfo *buffer_info);
|
DisplayError FreeBuffer(BufferInfo *buffer_info);
|
||||||
uint32_t GetBufferSize(BufferInfo *buffer_info);
|
uint32_t GetBufferSize(BufferInfo *buffer_info);
|
||||||
@@ -66,6 +64,7 @@ class HWCBufferAllocator : public BufferAllocator {
|
|||||||
DisplayError UnmapBuffer(const private_handle_t *handle, int *release_fence);
|
DisplayError UnmapBuffer(const private_handle_t *handle, int *release_fence);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
DisplayError GetGrallocInstance();
|
||||||
android::sp<IMapper> mapper_;
|
android::sp<IMapper> mapper_;
|
||||||
android::sp<IAllocator> allocator_;
|
android::sp<IAllocator> allocator_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -160,23 +160,10 @@ int HWCSession::Init() {
|
|||||||
|
|
||||||
StartServices();
|
StartServices();
|
||||||
|
|
||||||
DisplayError error = buffer_allocator_.Init();
|
|
||||||
if (error != kErrorNone) {
|
|
||||||
ALOGE("%s::%s: Buffer allocator initialization failed. Error = %d",
|
|
||||||
__CLASS__, __FUNCTION__, error);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hwc_uevent_.Register(this);
|
g_hwc_uevent_.Register(this);
|
||||||
|
|
||||||
error = CoreInterface::CreateCore(HWCDebugHandler::Get(), &buffer_allocator_,
|
auto error = CoreInterface::CreateCore(HWCDebugHandler::Get(), &buffer_allocator_,
|
||||||
&buffer_sync_handler_, &socket_handler_, &core_intf_);
|
&buffer_sync_handler_, &socket_handler_, &core_intf_);
|
||||||
if (error != kErrorNone) {
|
|
||||||
buffer_allocator_.Deinit();
|
|
||||||
ALOGE("%s::%s: Display core initialization failed. Error = %d", __CLASS__, __FUNCTION__, error);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// If HDMI display is primary display, defer display creation until hotplug event is received.
|
// If HDMI display is primary display, defer display creation until hotplug event is received.
|
||||||
HWDisplayInterfaceInfo hw_disp_info = {};
|
HWDisplayInterfaceInfo hw_disp_info = {};
|
||||||
@@ -184,7 +171,6 @@ int HWCSession::Init() {
|
|||||||
if (error != kErrorNone) {
|
if (error != kErrorNone) {
|
||||||
g_hwc_uevent_.Register(nullptr);
|
g_hwc_uevent_.Register(nullptr);
|
||||||
CoreInterface::DestroyCore();
|
CoreInterface::DestroyCore();
|
||||||
buffer_allocator_.Deinit();
|
|
||||||
DLOGE("Primary display type not recognized. Error = %d", error);
|
DLOGE("Primary display type not recognized. Error = %d", error);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@@ -209,7 +195,6 @@ int HWCSession::Init() {
|
|||||||
if (status) {
|
if (status) {
|
||||||
g_hwc_uevent_.Register(nullptr);
|
g_hwc_uevent_.Register(nullptr);
|
||||||
CoreInterface::DestroyCore();
|
CoreInterface::DestroyCore();
|
||||||
buffer_allocator_.Deinit();
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user