summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-19 19:51:44 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-19 19:51:44 +0000
commitde81499699e65568592441151270eb95a6f8473c (patch)
tree03ab77f08ebfc6737ad52363e8040c5216d1045d
parent0b0207160031d72c4cffb717032f3864bd030f0e (diff)
parentb2d348143eab2adb6b0e37b30b83266ef3a6ab6d (diff)
downloadlwis-android-gs-shusky-5.15-android15-beta.tar.gz
Snap for 11594826 from b2d348143eab2adb6b0e37b30b83266ef3a6ab6d to android14-gs-pixel-5.15-24Q3-releaseandroid-15-beta-1_r0.8android-gs-shusky-5.15-android15-beta
Change-Id: I52d33eee227084055057c81d0089b481da911836 Signed-off-by: Coastguard Worker <android-build-coastguard-worker@google.com>
-rw-r--r--lwis_buffer.c3
-rw-r--r--lwis_fence.c58
-rw-r--r--lwis_fence.h9
-rw-r--r--lwis_transaction.c8
4 files changed, 24 insertions, 54 deletions
diff --git a/lwis_buffer.c b/lwis_buffer.c
index 988afd1..69b51b6 100644
--- a/lwis_buffer.c
+++ b/lwis_buffer.c
@@ -71,16 +71,13 @@ static void dump_total_enrolled_buffer_size(struct lwis_device *lwis_dev)
continue;
}
hash_for_each (client->enrolled_buffers, i, enrollment_list, node) {
- spin_lock_irqsave(&client->buffer_lock, flags);
buffer = list_first_entry(&enrollment_list->list,
struct lwis_enrolled_buffer, list_node);
total_enrolled_size += buffer->dma_buf->size;
num_enrolled_buffers++;
- spin_unlock_irqrestore(&client->buffer_lock, flags);
}
}
spin_unlock_irqrestore(&lwis_dev->lock, flags);
-
if (total_enrolled_size > 0) {
pr_info("%-16s: %16d %16lu kB\n", lwis_dev->name, num_enrolled_buffers,
total_enrolled_size / 1024);
diff --git a/lwis_fence.c b/lwis_fence.c
index ccfe497..a789fef 100644
--- a/lwis_fence.c
+++ b/lwis_fence.c
@@ -231,9 +231,6 @@ int lwis_fence_create(struct lwis_device *lwis_dev)
return -ENOMEM;
}
- /* Set the struct identifier to avoid type-confusion when casting from void pointer */
- new_fence->struct_id = LWIS_FENCE_IDENTIFIER;
-
/* Open a new fd for the new fence */
fd_or_err =
anon_inode_getfd("lwis_fence_file", &fence_file_ops, new_fence, O_RDWR | O_CLOEXEC);
@@ -254,35 +251,6 @@ int lwis_fence_create(struct lwis_device *lwis_dev)
return fd_or_err;
}
-struct file *lwis_fence_get(struct lwis_client *client, int fd)
-{
- struct file *fence_fp = NULL;
- struct lwis_fence *fence = NULL;
-
- fence_fp = fget(fd);
- if (fence_fp == NULL) {
- dev_err(client->lwis_dev->dev, "Fence fd %d results in NULL file pointer", fd);
- return NULL;
- }
-
- fence = fence_fp->private_data;
- if (fence->struct_id != LWIS_FENCE_IDENTIFIER) {
- fput(fence_fp);
- dev_err(client->lwis_dev->dev, "Underlying structure for fd %d is not a lwis_fence",
- fd);
- return NULL;
- }
-
- if (fence->fd != fd) {
- fput(fence_fp);
- dev_err(client->lwis_dev->dev,
- "Invalid lwis_fence with fd %d. Contains stale data \n", fd);
- return NULL;
- }
-
- return fence_fp;
-}
-
static struct lwis_fence_trigger_transaction_list *transaction_list_find(struct lwis_fence *fence,
struct lwis_client *owner)
{
@@ -321,7 +289,7 @@ static int lwis_trigger_fence_add_transaction(int fence_fd, struct lwis_client *
struct lwis_transaction *transaction)
{
unsigned long flags;
- struct file *fp = NULL;
+ struct file *fp;
struct lwis_fence *lwis_fence;
struct lwis_pending_transaction_id *pending_transaction_id;
struct lwis_fence_trigger_transaction_list *tx_list;
@@ -333,17 +301,24 @@ static int lwis_trigger_fence_add_transaction(int fence_fd, struct lwis_client *
return -EINVAL;
}
- pending_transaction_id = kmalloc(sizeof(struct lwis_pending_transaction_id), GFP_ATOMIC);
- if (!pending_transaction_id) {
- return -ENOMEM;
- }
-
- fp = lwis_fence_get(client, fence_fd);
+ fp = fget(fence_fd);
if (fp == NULL) {
+ dev_err(client->lwis_dev->dev, "Failed to find lwis_fence with fd %d\n", fence_fd);
return -EBADF;
}
lwis_fence = fp->private_data;
+ if (lwis_fence->fd != fence_fd) {
+ fput(fp);
+ dev_err(client->lwis_dev->dev,
+ "Invalid lwis_fence with fd %d. Contains stale data \n", fence_fd);
+ return -EBADF;
+ }
+ pending_transaction_id = kmalloc(sizeof(struct lwis_pending_transaction_id), GFP_ATOMIC);
+ if (!pending_transaction_id) {
+ fput(fp);
+ return -ENOMEM;
+ }
pending_transaction_id->id = transaction->info.id;
spin_lock_irqsave(&lwis_fence->lock, flags);
@@ -606,7 +581,7 @@ int lwis_initialize_transaction_fences(struct lwis_client *client,
int lwis_add_completion_fence(struct lwis_client *client, struct lwis_transaction *transaction)
{
- struct file *fp = NULL;
+ struct file *fp;
struct lwis_fence *lwis_fence;
struct lwis_fence_pending_signal *fence_pending_signal;
struct lwis_device *lwis_dev = client->lwis_dev;
@@ -624,8 +599,9 @@ int lwis_add_completion_fence(struct lwis_client *client, struct lwis_transactio
return -EPERM;
}
- fp = lwis_fence_get(client, fence_fd);
+ fp = fget(fence_fd);
if (fp == NULL) {
+ dev_err(lwis_dev->dev, "Failed to find lwis_fence with fd %d\n", fence_fd);
return -EBADF;
}
diff --git a/lwis_fence.h b/lwis_fence.h
index 5e67b5b..a79fc06 100644
--- a/lwis_fence.h
+++ b/lwis_fence.h
@@ -18,14 +18,9 @@
#define LWIS_CLIENTS_HASH_BITS 8
-/* Randomly generated number used to identify lwis_fence objects */
-#define LWIS_FENCE_IDENTIFIER 0x75A2C6BC
-
extern bool lwis_fence_debug;
struct lwis_fence {
- /* Used to identify the structure when casting from void pointer */
- int struct_id;
int fd;
int status;
spinlock_t lock;
@@ -58,9 +53,9 @@ int lwis_fence_create(struct lwis_device *lwis_dev);
int ioctl_lwis_fence_create(struct lwis_device *lwis_dev, int32_t __user *msg);
/*
- * lwis_fence_get: Get the file pointer for the lwis_fence associated with the fd.
+ * lwis_fence_get: Get the lwis_fence associated with the fd.
*/
-struct file *lwis_fence_get(struct lwis_client *client, int fd);
+struct lwis_device *lwis_fence_get(int fd);
/* Creates all fences that do not currently exist */
int lwis_initialize_transaction_fences(struct lwis_client *client,
diff --git a/lwis_transaction.c b/lwis_transaction.c
index 3274a17..0f4228b 100644
--- a/lwis_transaction.c
+++ b/lwis_transaction.c
@@ -766,10 +766,12 @@ int lwis_trigger_event_add_weak_transaction(struct lwis_client *client, int64_t
weak_transaction->is_weak_transaction = true;
weak_transaction->id = transaction_id;
if (precondition_fence_fd >= 0) {
- weak_transaction->precondition_fence_fp =
- lwis_fence_get(client, precondition_fence_fd);
+ weak_transaction->precondition_fence_fp = fget(precondition_fence_fd);
if (weak_transaction->precondition_fence_fp == NULL) {
- return -EBADF;
+ dev_err(client->lwis_dev->dev,
+ "Precondition fence %d results in NULL file pointer",
+ precondition_fence_fd);
+ return -EINVAL;
}
} else {
weak_transaction->precondition_fence_fp = NULL;