]> www.infradead.org Git - linux.git/commitdiff
staging: vchiq_core: Factor out bulk transfer for (no/)callback mode
authorUmang Jain <umang.jain@ideasonboard.com>
Tue, 10 Sep 2024 05:10:04 +0000 (10:40 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Sep 2024 13:54:04 +0000 (15:54 +0200)
Factor out bulk transfer for VCHIQ_BULK_MODE_NOCALLBACK and
VCHIQ_BULK_MODE_CALLBACK mode into a separate dedicated function
bulk_xfer_callback_interruptible(). It is suffixed by "_interruptible"
to denote that it can be interrupted and -EAGAIN can be returned. It
would be up to the users of the function to retry the call in those cases.

bulk_xfer_callback_interruptible() also takes in 'mode' parameter to
differentiate between VCHIQ_BULK_MODE_NOCALLBACK and
VCHIQ_BULK_MODE_CALLBACK, which then is directly passed to
vchiq_bulk_xfer_queue_msg_interruptible() inside the function.

Adjust the calls to vchiq-dev.c ioctl interface and vchiq_arm.c
for the respective bulk transfers.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Stefan Wahren <wahrenst@gmx.net>
Link: https://lore.kernel.org/r/20240910051007.297227-5-umang.jain@ideasonboard.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c

index 688c9b1be868e8c74b1d5c54d598e41a26f15d08..3dbeffc650d339fec21461e3353643e40da892bd 100644 (file)
@@ -857,10 +857,10 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const
                switch (mode) {
                case VCHIQ_BULK_MODE_NOCALLBACK:
                case VCHIQ_BULK_MODE_CALLBACK:
-                       ret = vchiq_bulk_transfer(instance, handle,
-                                                 (void *)data, NULL,
-                                                 size, userdata, mode,
-                                                 VCHIQ_BULK_TRANSMIT);
+                       ret = vchiq_bulk_xfer_callback_interruptible(instance, handle,
+                                                                    (void *)data, NULL,
+                                                                    size, mode, userdata,
+                                                                    VCHIQ_BULK_TRANSMIT);
                        break;
                case VCHIQ_BULK_MODE_BLOCKING:
                        ret = vchiq_blocking_bulk_transfer(instance, handle, (void *)data, size,
@@ -895,9 +895,10 @@ int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int handle,
                switch (mode) {
                case VCHIQ_BULK_MODE_NOCALLBACK:
                case VCHIQ_BULK_MODE_CALLBACK:
-                       ret = vchiq_bulk_transfer(instance, handle, data, NULL,
-                                                 size, userdata,
-                                                 mode, VCHIQ_BULK_RECEIVE);
+                       ret = vchiq_bulk_xfer_callback_interruptible(instance, handle,
+                                                                    (void *)data, NULL,
+                                                                    size, mode, userdata,
+                                                                    VCHIQ_BULK_RECEIVE);
                        break;
                case VCHIQ_BULK_MODE_BLOCKING:
                        ret = vchiq_blocking_bulk_transfer(instance, handle, (void *)data, size,
index b93b7e2ba0c73ab53c74634fa71cae51548136e1..84e9059202ec1d33c26324c73ed848811b0661d9 100644 (file)
@@ -3135,6 +3135,40 @@ error_exit:
        return status;
 }
 
+int
+vchiq_bulk_xfer_callback_interruptible(struct vchiq_instance *instance, unsigned int handle,
+                                      void *offset, void __user *uoffset, int size,
+                                      enum vchiq_bulk_mode mode, void *userdata,
+                                      enum vchiq_bulk_dir dir)
+{
+       struct vchiq_service *service = find_service_by_handle(instance, handle);
+       int status = -EINVAL;
+
+       if (!service)
+               return -EINVAL;
+
+       if (mode != VCHIQ_BULK_MODE_CALLBACK &&
+           mode != VCHIQ_BULK_MODE_NOCALLBACK)
+               goto error_exit;
+
+       if (service->srvstate != VCHIQ_SRVSTATE_OPEN)
+               goto error_exit;
+
+       if (!offset && !uoffset)
+               goto error_exit;
+
+       if (vchiq_check_service(service))
+               goto error_exit;
+
+       status = vchiq_bulk_xfer_queue_msg_interruptible(service, offset, uoffset,
+                                                        size, userdata, mode, dir);
+
+error_exit:
+       vchiq_service_put(service);
+
+       return status;
+}
+
 /*
  * This function may be called by kernel threads or user threads.
  * User threads may receive -EAGAIN to indicate that a signal has been
index 2dd89101c1c661721f0b667952f1fac0849ac5c6..9c8c076eaaeb73b5993e5941bfbf670f2c669a1b 100644 (file)
@@ -479,6 +479,12 @@ vchiq_bulk_xfer_blocking_interruptible(struct vchiq_instance *instance, unsigned
                                       void *offset, void __user *uoffset, int size,
                                       void __user *userdata, enum vchiq_bulk_dir dir);
 
+extern int
+vchiq_bulk_xfer_callback_interruptible(struct vchiq_instance *instance, unsigned int handle,
+                                      void *offset, void __user *uoffset, int size,
+                                      enum vchiq_bulk_mode mode, void *userdata,
+                                      enum vchiq_bulk_dir dir);
+
 extern int
 vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *offset,
                    void __user *uoffset, int size, void *userdata, enum vchiq_bulk_mode mode,
index 830633f2326b6b15ca0df9bf6642803a4357f55e..169a2ffda9966e63508b452604a97eb1ebedc1c7 100644 (file)
@@ -336,6 +336,12 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
                goto bulk_transfer_handled;
        } else {
                userdata = args->userdata;
+
+               status = vchiq_bulk_xfer_callback_interruptible(instance, args->handle, NULL,
+                                                               args->data, args->size,
+                                                               args->mode, userdata, dir);
+
+               goto bulk_transfer_handled;
        }
 
        status = vchiq_bulk_transfer(instance, args->handle, NULL, args->data, args->size,