Skip to content

Commit

Permalink
gralloc: use ALOGE instead of drv_log
Browse files Browse the repository at this point in the history
TEST=build

Change-Id: I78b123f395fef8853f310a567ac0341b6958c535
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761445
Reviewed-by: Jason Macnak <[email protected]>
Reviewed-by: Dominik Behr <[email protected]>
Commit-Queue: Yiwei Zhang <[email protected]>
Auto-Submit: Yiwei Zhang <[email protected]>
Tested-by: Yiwei Zhang <[email protected]>
  • Loading branch information
zhangyiwei authored and Chromeos LUCI committed Jul 15, 2022
1 parent 7648f06 commit bfb3c78
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 149 deletions.
18 changes: 9 additions & 9 deletions cros_gralloc/cros_gralloc_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ cros_gralloc_buffer::create(struct bo *acquire_bo,
auto acquire_hnd =
reinterpret_cast<struct cros_gralloc_handle *>(native_handle_clone(borrowed_handle));
if (!acquire_hnd) {
drv_log("Failed to create cros_gralloc_buffer: failed to clone handle.\n");
ALOGE("Failed to create cros_gralloc_buffer: failed to clone handle.");
return {};
}

std::unique_ptr<cros_gralloc_buffer> buffer(
new cros_gralloc_buffer(acquire_bo, acquire_hnd));
if (!buffer) {
drv_log("Failed to create cros_gralloc_buffer: failed to allocate.\n");
ALOGE("Failed to create cros_gralloc_buffer: failed to allocate.");
native_handle_close(acquire_hnd);
native_handle_delete(acquire_hnd);
return {};
Expand Down Expand Up @@ -138,7 +138,7 @@ int32_t cros_gralloc_buffer::lock(const struct rectangle *rect, uint32_t map_fla
* just use the first kernel buffer.
*/
if (drv_num_buffers_per_bo(bo_) != 1) {
drv_log("Can only support one buffer per bo.\n");
ALOGE("Can only support one buffer per bo.");
return -EINVAL;
}

Expand All @@ -162,7 +162,7 @@ int32_t cros_gralloc_buffer::lock(const struct rectangle *rect, uint32_t map_fla
}

if (vaddr == MAP_FAILED) {
drv_log("Mapping failed.\n");
ALOGE("Mapping failed.");
return -EFAULT;
}
}
Expand All @@ -177,7 +177,7 @@ int32_t cros_gralloc_buffer::lock(const struct rectangle *rect, uint32_t map_fla
int32_t cros_gralloc_buffer::unlock()
{
if (lockcount_ <= 0) {
drv_log("Buffer was not locked.\n");
ALOGE("Buffer was not locked.");
return -EINVAL;
}

Expand All @@ -201,7 +201,7 @@ int32_t cros_gralloc_buffer::resource_info(uint32_t strides[DRV_MAX_PLANES],
int32_t cros_gralloc_buffer::invalidate()
{
if (lockcount_ <= 0) {
drv_log("Buffer was not locked.\n");
ALOGE("Buffer was not locked.");
return -EINVAL;
}

Expand All @@ -214,7 +214,7 @@ int32_t cros_gralloc_buffer::invalidate()
int32_t cros_gralloc_buffer::flush()
{
if (lockcount_ <= 0) {
drv_log("Buffer was not locked.\n");
ALOGE("Buffer was not locked.");
return -EINVAL;
}

Expand All @@ -228,7 +228,7 @@ int32_t cros_gralloc_buffer::get_reserved_region(void **addr, uint64_t *size) co
{
int32_t reserved_region_fd = hnd_->fds[hnd_->num_planes];
if (reserved_region_fd < 0) {
drv_log("Buffer does not have reserved region.\n");
ALOGE("Buffer does not have reserved region.");
return -EINVAL;
}

Expand All @@ -237,7 +237,7 @@ int32_t cros_gralloc_buffer::get_reserved_region(void **addr, uint64_t *size) co
mmap(nullptr, hnd_->reserved_region_size, PROT_WRITE | PROT_READ, MAP_SHARED,
reserved_region_fd, 0);
if (reserved_region_addr_ == MAP_FAILED) {
drv_log("Failed to mmap reserved region: %s.\n", strerror(errno));
ALOGE("Failed to mmap reserved region: %s.", strerror(errno));
return -errno;
}
}
Expand Down
57 changes: 28 additions & 29 deletions cros_gralloc/cros_gralloc_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ int memfd_create_wrapper(const char *name, unsigned int flags)
#elif defined(__NR_memfd_create)
fd = syscall(__NR_memfd_create, name, flags);
#else
drv_log("Failed to create memfd '%s': memfd_create not available.", name);
ALOGE("Failed to create memfd '%s': memfd_create not available.", name);
return -1;
#endif

if (fd == -1)
drv_log("Failed to create memfd '%s': %s.\n", name, strerror(errno));
ALOGE("Failed to create memfd '%s': %s.", name, strerror(errno));

return fd;
}
Expand All @@ -53,7 +53,7 @@ int memfd_create_reserved_region(const std::string &buffer_name, uint64_t reserv
return -errno;

if (ftruncate(reserved_region_fd, reserved_region_size)) {
drv_log("Failed to set reserved region size: %s.\n", strerror(errno));
ALOGE("Failed to set reserved region size: %s.", strerror(errno));
return -errno;
}

Expand All @@ -65,7 +65,7 @@ cros_gralloc_driver *cros_gralloc_driver::get_instance()
static cros_gralloc_driver s_instance;

if (!s_instance.is_initialized()) {
drv_log("Failed to initialize driver.\n");
ALOGE("Failed to initialize driver.");
return nullptr;
}

Expand Down Expand Up @@ -215,7 +215,7 @@ int cros_gralloc_driver::create_reserved_region(const std::string &buffer_name,
if (ret >= 0)
return ret;

drv_log("Failed to create_reserved_region.\n");
ALOGE("Failed to create_reserved_region.");
return -1;
}

Expand All @@ -234,14 +234,14 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
std::unique_ptr<cros_gralloc_buffer> buffer;

if (!get_resolved_format_and_use_flags(descriptor, &resolved_format, &resolved_use_flags)) {
drv_log("Failed to resolve format and use_flags.\n");
ALOGE("Failed to resolve format and use_flags.");
return -EINVAL;
}

bo = drv_bo_create(drv_.get(), descriptor->width, descriptor->height, resolved_format,
resolved_use_flags);
if (!bo) {
drv_log("Failed to create bo.\n");
ALOGE("Failed to create bo.");
return -errno;
}

Expand All @@ -251,7 +251,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto
* send more than one fd. GL/Vulkan drivers may also have to modified.
*/
if (drv_num_buffers_per_bo(bo) != 1) {
drv_log("Can only support one buffer per bo.\n");
ALOGE("Can only support one buffer per bo.");
goto destroy_bo;
}

Expand Down Expand Up @@ -308,7 +308,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto

buffer = cros_gralloc_buffer::create(bo, hnd);
if (!buffer) {
drv_log("Failed to allocate: failed to create cros_gralloc_buffer.\n");
ALOGE("Failed to allocate: failed to create cros_gralloc_buffer.");
ret = -1;
goto destroy_hnd;
}
Expand Down Expand Up @@ -342,7 +342,7 @@ int32_t cros_gralloc_driver::retain(buffer_handle_t handle)

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

Expand Down Expand Up @@ -393,7 +393,7 @@ int32_t cros_gralloc_driver::retain(buffer_handle_t handle)

auto scoped_buffer = cros_gralloc_buffer::create(bo, hnd);
if (!scoped_buffer) {
drv_log("Failed to import: failed to create cros_gralloc_buffer.\n");
ALOGE("Failed to import: failed to create cros_gralloc_buffer.");
return -1;
}
buffer = scoped_buffer.get();
Expand All @@ -414,13 +414,13 @@ int32_t cros_gralloc_driver::release(buffer_handle_t handle)

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (release() called on unregistered handle).\n");
ALOGE("Invalid reference (release() called on unregistered handle).");
return -EINVAL;
}

Expand All @@ -446,13 +446,13 @@ int32_t cros_gralloc_driver::lock(buffer_handle_t handle, int32_t acquire_fence,

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (lock() called on unregistered handle).\n");
ALOGE("Invalid reference (lock() called on unregistered handle).");
return -EINVAL;
}

Expand All @@ -465,13 +465,13 @@ int32_t cros_gralloc_driver::unlock(buffer_handle_t handle, int32_t *release_fen

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (unlock() called on unregistered handle).\n");
ALOGE("Invalid reference (unlock() called on unregistered handle).");
return -EINVAL;
}

Expand All @@ -491,13 +491,13 @@ int32_t cros_gralloc_driver::invalidate(buffer_handle_t handle)

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (invalidate() called on unregistered handle).\n");
ALOGE("Invalid reference (invalidate() called on unregistered handle).");
return -EINVAL;
}

Expand All @@ -510,13 +510,13 @@ int32_t cros_gralloc_driver::flush(buffer_handle_t handle, int32_t *release_fenc

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (flush() called on unregistered handle).\n");
ALOGE("Invalid reference (flush() called on unregistered handle).");
return -EINVAL;
}

Expand All @@ -536,13 +536,13 @@ int32_t cros_gralloc_driver::get_backing_store(buffer_handle_t handle, uint64_t

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (get_backing_store() called on unregistered handle).\n");
ALOGE("Invalid reference (get_backing_store() called on unregistered handle).");
return -EINVAL;
}

Expand All @@ -558,13 +558,13 @@ int32_t cros_gralloc_driver::resource_info(buffer_handle_t handle, uint32_t stri

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (resource_info() called on unregistered handle).\n");
ALOGE("Invalid reference (resource_info() called on unregistered handle).");
return -EINVAL;
}

Expand All @@ -579,14 +579,13 @@ int32_t cros_gralloc_driver::get_reserved_region(buffer_handle_t handle,

auto hnd = cros_gralloc_convert_handle(handle);
if (!hnd) {
drv_log("Invalid handle.\n");
ALOGE("Invalid handle.");
return -EINVAL;
}

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log(
"Invalid reference (get_reserved_region() called on unregistered handle).\n");
ALOGE("Invalid reference (get_reserved_region() called on unregistered handle).");
return -EINVAL;
}

Expand Down Expand Up @@ -620,7 +619,7 @@ void cros_gralloc_driver::with_buffer(cros_gralloc_handle_t hnd,

auto buffer = get_buffer(hnd);
if (!buffer) {
drv_log("Invalid reference (with_buffer() called on unregistered handle).\n");
ALOGE("Invalid reference (with_buffer() called on unregistered handle).");
return;
}

Expand Down
8 changes: 4 additions & 4 deletions cros_gralloc/cros_gralloc_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ uint64_t cros_gralloc_convert_usage(uint64_t usage)
handle_usage(&usage, BUFFER_USAGE_FRONT_RENDERING, &use_flags, BO_USE_FRONT_RENDERING);

if (usage) {
drv_log("Unhandled gralloc usage: %llx\n", (unsigned long long)usage);
ALOGE("Unhandled gralloc usage: %llx", (unsigned long long)usage);
return BO_USE_NONE;
}

Expand Down Expand Up @@ -162,18 +162,18 @@ int32_t cros_gralloc_sync_wait(int32_t fence, bool close_fence)
*/
int err = sync_wait(fence, 1000);
if (err < 0) {
drv_log("Timed out on sync wait, err = %s\n", strerror(errno));
ALOGE("Timed out on sync wait, err = %s", strerror(errno));
err = sync_wait(fence, -1);
if (err < 0) {
drv_log("sync wait error = %s\n", strerror(errno));
ALOGE("sync wait error = %s", strerror(errno));
return -errno;
}
}

if (close_fence) {
err = close(fence);
if (err) {
drv_log("Unable to close fence fd, err = %s\n", strerror(errno));
ALOGE("Unable to close fence fd, err = %s", strerror(errno));
return -errno;
}
}
Expand Down
1 change: 1 addition & 0 deletions cros_gralloc/cros_gralloc_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../drv.h"
#include "cros_gralloc_handle.h"

#include <log/log.h>
#include <system/graphics.h>
#include <system/window.h>

Expand Down
Loading

0 comments on commit bfb3c78

Please sign in to comment.