]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
staging: vchiq_core: Return -EINTR when bulk transfers are interrupted
authorUmang Jain <umang.jain@ideasonboard.com>
Wed, 18 Sep 2024 16:30:58 +0000 (22:00 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Oct 2024 09:58:47 +0000 (11:58 +0200)
Bulk transfers for various VCHIQ modes use mutex_lock_killable() and
wait_for_completion_killable() variations. Currently, -EAGAIN is
returned if these are interrupted by a fatal signal.

-EAGAIN may mislead the caller into thinking the operation can be
retried, while in reality, the process has received a fatal signal
and is terminating. Therefore, we should update the return value to
align with what these killable functions would return, specifically
-EINTR (Interrupted system call).

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20240918163100.870596-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

index 3d469b88a1182771e6c8149f4464b3e9eea5d793..d4c70a220b9e363ec09275e863562aa5d8d1b650 100644 (file)
@@ -870,11 +870,11 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const
                }
 
                /*
-                * vchiq_*_bulk_transfer() may return -EAGAIN, so we need
+                * vchiq_*_bulk_transfer() may return -EINTR, so we need
                 * to implement a retry mechanism since this function is
                 * supposed to block until queued
                 */
-               if (ret != -EAGAIN)
+               if (ret != -EINTR)
                        break;
 
                msleep(1);
@@ -906,11 +906,11 @@ int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int handle,
                }
 
                /*
-                * vchiq_*_bulk_transfer() may return -EAGAIN, so we need
+                * vchiq_*_bulk_transfer() may return -EINTR, so we need
                 * to implement a retry mechanism since this function is
                 * supposed to block until queued
                 */
-               if (ret != -EAGAIN)
+               if (ret != -EINTR)
                        break;
 
                msleep(1);
index d7b22e37c2ff64ac9679566fddbb82d02c08ca39..426e729b71ee87a58f5eb23920d3556346f9902d 100644 (file)
@@ -2689,16 +2689,16 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
                &service->bulk_tx : &service->bulk_rx;
 
        if (mutex_lock_killable(&service->bulk_mutex))
-               return -EAGAIN;
+               return -EINTR;
 
        if (queue->local_insert == queue->remove + VCHIQ_NUM_SERVICE_BULKS) {
                VCHIQ_SERVICE_STATS_INC(service, bulk_stalls);
                do {
                        mutex_unlock(&service->bulk_mutex);
                        if (wait_for_completion_killable(&service->bulk_remove_event))
-                               return -EAGAIN;
+                               return -EINTR;
                        if (mutex_lock_killable(&service->bulk_mutex))
-                               return -EAGAIN;
+                               return -EINTR;
                } while (queue->local_insert == queue->remove +
                                VCHIQ_NUM_SERVICE_BULKS);
        }
@@ -2729,7 +2729,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
         * claim it here to ensure that isn't happening
         */
        if (mutex_lock_killable(&state->slot_mutex)) {
-               status = -EAGAIN;
+               status = -EINTR;
                goto cancel_bulk_error_exit;
        }
 
@@ -2764,7 +2764,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service,
         if (bulk_waiter) {
                 bulk_waiter->bulk = bulk;
                if (wait_for_completion_killable(&bulk_waiter->event))
-                        status = -EAGAIN;
+                       status = -EINTR;
                 else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED)
                         status = -EINVAL;
         }
@@ -3203,7 +3203,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instance,
        status = 0;
 
        if (wait_for_completion_killable(&bulk_waiter->event))
-               return -EAGAIN;
+               return -EINTR;
        else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED)
                return -EINVAL;