Revert "gralloc: Error when locking buffer alloc'd without CPU_ usage"

This reverts commit eb0e5fa310.

Reason for revert: fix ARCVM test regressions while investigating root cause (b/371862010).

Original change's description:
> gralloc: Error when locking buffer alloc'd without CPU_ usage
>
> ... except when running with software rendering as apps do not
> know that they would need to request additional CPU_* usage
> for GPU_* usage.
>
> Bug: b/356845188
> Test: cts -m CtsNativeHardwareTestCases
> Change-Id: I3536d80469d2187550558e9d02795896de4f9827
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5893718
> Reviewed-by: Ryan Neph <ryanneph@google.com>
> Reviewed-by: Juston Li <justonli@google.com>
> Tested-by: Ryan Neph <ryanneph@google.com>
> Tested-by: Juston Li <justonli@google.com>
> Commit-Queue: Ryan Neph <ryanneph@google.com>
> Commit-Queue: Jason Macnak <natsu@google.com>

Bug: b/371862010
Change-Id: Id16c3ae1989fec9d7cd71c24b9c6d55c3d29ae45
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5915946
Auto-Submit: Ryan Neph <ryanneph@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: ChromeOS Auto Retry <chromeos-auto-retry@chromeos-bot.iam.gserviceaccount.com>
This commit is contained in:
Ryan Neph 2024-10-08 16:56:29 +00:00 committed by Chromeos LUCI
parent d56aa1353a
commit 6d687b7b62
3 changed files with 1 additions and 36 deletions

View file

@ -14,8 +14,6 @@
#include <syscall.h>
#include <xf86drm.h>
#include "../drv_helpers.h"
#include "../drv_priv.h"
#include "../util.h"
// Constants taken from pipe_loader_drm.c in Mesa
@ -157,15 +155,7 @@ static void drv_destroy_and_close(struct driver *drv)
close(fd);
}
static bool is_running_with_software_rendering()
{
const char *vulkan_driver = drv_get_os_option("ro.hardware.vulkan");
return (vulkan_driver != nullptr && strstr(vulkan_driver, "pastel") != nullptr);
}
cros_gralloc_driver::cros_gralloc_driver()
: drv_(init_try_nodes(), drv_destroy_and_close),
is_running_with_software_rendering_(is_running_with_software_rendering())
cros_gralloc_driver::cros_gralloc_driver() : drv_(init_try_nodes(), drv_destroy_and_close)
{
}
@ -188,11 +178,6 @@ bool cros_gralloc_driver::get_resolved_format_and_use_flags(
uint64_t resolved_use_flags;
struct combination *combo;
uint64_t use_flags = descriptor->use_flags;
if (is_running_with_software_rendering_ && (use_flags & BO_USE_GPU_HW) != 0) {
use_flags |= (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN);
}
drv_resolve_format_and_use_flags(drv_.get(), descriptor->drm_format, descriptor->use_flags,
&resolved_format, &resolved_use_flags);
@ -473,15 +458,6 @@ int32_t cros_gralloc_driver::lock(buffer_handle_t handle, int32_t acquire_fence,
return -EINVAL;
}
if (!is_running_with_software_rendering_) {
if ((hnd->usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) ==
0) {
ALOGE("Attempted to lock() a buffer that was not allocated with a "
"BufferUsage::CPU_* usage.");
return -EINVAL;
}
}
auto buffer = get_buffer(hnd);
if (!buffer) {
ALOGE("Invalid reference (lock() called on unregistered handle).");

View file

@ -84,9 +84,6 @@ class cros_gralloc_driver
std::mutex mutex_;
std::unordered_map<uint32_t, std::unique_ptr<cros_gralloc_buffer>> buffers_;
std::unordered_map<cros_gralloc_handle_t, cros_gralloc_imported_handle_info> handles_;
/* TODO(b/242184599): remove after SwiftShader is moved to the host. */
const bool is_running_with_software_rendering_ = false;
};
#endif

View file

@ -7,10 +7,6 @@
#ifndef DRV_HELPERS_H
#define DRV_HELPERS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include "drv.h"
@ -76,8 +72,4 @@ struct lru_entry *lru_find(struct lru *lru, bool (*eq)(struct lru_entry *e, void
void lru_insert(struct lru *lru, struct lru_entry *entry);
void lru_init(struct lru *lru, int max);
#ifdef __cplusplus
}
#endif
#endif