[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241023110406.885199-3-umang.jain@ideasonboard.com>
Date: Wed, 23 Oct 2024 16:34:02 +0530
From: Umang Jain <umang.jain@...asonboard.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>
Cc: linux-rpi-kernel@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org,
linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Dan Carpenter <dan.carpenter@...aro.org>,
Kieran Bingham <kieran.bingham@...asonboard.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Stefan Wahren <wahrenst@....net>,
kernel-list@...pberrypi.com,
Umang Jain <umang.jain@...asonboard.com>
Subject: [PATCH 2/6] staging: vchiq_core: Bulk waiter should not piggy back on bulk userdata
Currently, struct bulk_waiter is allocated for VCHIQ_BULK_MODE_BLOCKING
bulk transfer and its pointer is assigned to vchiq_bulk->userdata. Avoid
this kind of piggybacking and introduce a dedicate 'waiter' member in
struct vchiq_bulk.
The 'userdata' is meant for VCHIQ_BULK_MODE_CALLBACK mode, to pass user
specified parameter to the actual callback function.
Signed-off-by: Umang Jain <umang.jain@...asonboard.com>
---
.../vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++---
.../vc04_services/interface/vchiq_arm/vchiq_core.c | 11 ++++++-----
.../vc04_services/interface/vchiq_arm/vchiq_core.h | 1 +
.../vc04_services/interface/vchiq_arm/vchiq_dev.c | 4 ++--
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index f23d98a1b960..ff627b297bc4 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -594,7 +594,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
* Cancel the signal when the transfer completes.
*/
spin_lock(&service->state->bulk_waiter_spinlock);
- bulk->userdata = NULL;
+ bulk->waiter = NULL;
spin_unlock(&service->state->bulk_waiter_spinlock);
}
}
@@ -604,7 +604,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
return -ENOMEM;
}
- bulk_params->userdata = &waiter->bulk_waiter;
+ bulk_params->waiter = &waiter->bulk_waiter;
ret = vchiq_bulk_xfer_blocking(instance, handle, bulk_params);
if ((ret != -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) {
@@ -613,7 +613,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
if (bulk) {
/* Cancel the signal when the transfer completes. */
spin_lock(&service->state->bulk_waiter_spinlock);
- bulk->userdata = NULL;
+ bulk->waiter = NULL;
spin_unlock(&service->state->bulk_waiter_spinlock);
}
kfree(waiter);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index 90ab780b7e94..5e52f8954be7 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -1330,7 +1330,7 @@ static int service_notify_bulk(struct vchiq_service *service,
struct bulk_waiter *waiter;
spin_lock(&service->state->bulk_waiter_spinlock);
- waiter = bulk->userdata;
+ waiter = bulk->waiter;
if (waiter) {
waiter->actual = bulk->actual;
complete(&waiter->event);
@@ -3035,7 +3035,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
int payload[2];
if (bulk_params->mode == VCHIQ_BULK_MODE_BLOCKING) {
- bulk_waiter = bulk_params->userdata;
+ bulk_waiter = bulk_params->waiter;
init_completion(&bulk_waiter->event);
bulk_waiter->actual = 0;
bulk_waiter->bulk = NULL;
@@ -3064,6 +3064,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
/* Initiliaze the 'bulk' slot with bulk parameters passed in. */
bulk->mode = bulk_params->mode;
bulk->dir = bulk_params->dir;
+ bulk->waiter = bulk_params->waiter;
bulk->userdata = bulk_params->userdata;
bulk->size = bulk_params->size;
bulk->offset = bulk_params->offset;
@@ -3533,7 +3534,7 @@ vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int handle,
*/
int
vchiq_bulk_xfer_waiting(struct vchiq_instance *instance,
- unsigned int handle, struct bulk_waiter *userdata)
+ unsigned int handle, struct bulk_waiter *waiter)
{
struct vchiq_service *service = find_service_by_handle(instance, handle);
struct bulk_waiter *bulk_waiter;
@@ -3542,7 +3543,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instance,
if (!service)
return -EINVAL;
- if (!userdata)
+ if (!waiter)
goto error_exit;
if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
@@ -3551,7 +3552,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instance,
if (vchiq_check_service(service))
goto error_exit;
- bulk_waiter = userdata;
+ bulk_waiter = waiter;
vchiq_service_put(service);
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
index 9ba4a2295dc3..88766c9180a9 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
@@ -115,6 +115,7 @@ struct vchiq_bulk {
short mode;
short dir;
void *userdata;
+ struct bulk_waiter *waiter;
dma_addr_t dma_addr;
int size;
void *remote_data;
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
index 6a9685d9fafc..3d2827446f53 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c
@@ -307,7 +307,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
bulk_params.mode = args->mode;
bulk_params.size = args->size;
bulk_params.dir = dir;
- bulk_params.userdata = &waiter->bulk_waiter;
+ bulk_params.waiter = &waiter->bulk_waiter;
status = vchiq_bulk_xfer_blocking(instance, args->handle,
&bulk_params);
@@ -354,7 +354,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
if (waiter->bulk_waiter.bulk) {
/* Cancel the signal when the transfer completes. */
spin_lock(&service->state->bulk_waiter_spinlock);
- waiter->bulk_waiter.bulk->userdata = NULL;
+ waiter->bulk_waiter.bulk->waiter = NULL;
spin_unlock(&service->state->bulk_waiter_spinlock);
}
kfree(waiter);
--
2.45.2
Powered by blists - more mailing lists