Message ID | 20240831162435.191084-2-umang.jain@ideasonboard.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | staging: vchiq_core: Refactor vchiq_bulk_transfer() logic | expand |
Hi Umang, kernel test robot noticed the following build warnings: [auto build test WARNING on staging/staging-testing] url: https://github.com/intel-lab-lkp/linux/commits/Umang-Jain/staging-vchiq-Factor-out-bulk-transfer-for-VCHIQ_BULK_MODE_WAITING/20240901-002839 base: staging/staging-testing patch link: https://lore.kernel.org/r/20240831162435.191084-2-umang.jain%40ideasonboard.com patch subject: [PATCH v2 1/7] staging: vchiq: Factor out bulk transfer for VCHIQ_BULK_MODE_WAITING config: i386-buildonly-randconfig-001-20240901 (https://download.01.org/0day-ci/archive/20240901/202409011052.hHoEnTUy-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240901/202409011052.hHoEnTUy-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202409011052.hHoEnTUy-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c: In function 'vchiq_bulk_xfer_waiting_interruptible': >> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c:3152:28: warning: variable 'bulk' set but not used [-Wunused-but-set-variable] 3152 | struct vchiq_bulk *bulk; | ^~~~ vim +/bulk +3152 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 3140 3141 /* 3142 * This function is called by VCHIQ ioctl interface and is interruptible. 3143 * It may receive -EAGAIN to indicate that a signal has been received 3144 * and the call should be retried after being returned to user context. 3145 */ 3146 int 3147 vchiq_bulk_xfer_waiting_interruptible(struct vchiq_instance *instance, 3148 unsigned int handle, struct bulk_waiter *userdata) 3149 { 3150 struct vchiq_service *service = find_service_by_handle(instance, handle); 3151 struct bulk_waiter *bulk_waiter; > 3152 struct vchiq_bulk *bulk; 3153 int status = -EINVAL; 3154 3155 if (!service) 3156 goto error_exit; 3157 3158 if (!userdata) 3159 goto error_exit; 3160 3161 if (service->srvstate != VCHIQ_SRVSTATE_OPEN) 3162 goto error_exit; 3163 3164 if (vchiq_check_service(service)) 3165 goto error_exit; 3166 3167 bulk_waiter = userdata; 3168 bulk = bulk_waiter->bulk; 3169 3170 vchiq_service_put(service); 3171 3172 status = 0; 3173 3174 if (wait_for_completion_interruptible(&bulk_waiter->event)) 3175 return -EAGAIN; 3176 else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED) 3177 return -EINVAL; 3178 3179 return status; 3180 3181 error_exit: 3182 if (service) 3183 vchiq_service_put(service); 3184 return status; 3185 } 3186
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 50af04b217f4..7db76e309d3f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3023,10 +3023,6 @@ int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, bulk_waiter->actual = 0; bulk_waiter->bulk = NULL; break; - case VCHIQ_BULK_MODE_WAITING: - bulk_waiter = userdata; - bulk = bulk_waiter->bulk; - goto waiting; default: goto error_exit; } @@ -3115,7 +3111,6 @@ int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, state->id, service->localport, dir_char, queue->local_insert, queue->remote_insert, queue->process); -waiting: vchiq_service_put(service); status = 0; @@ -3143,6 +3138,52 @@ int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, return status; } +/* + * This function is called by VCHIQ ioctl interface and is interruptible. + * It may receive -EAGAIN to indicate that a signal has been received + * and the call should be retried after being returned to user context. + */ +int +vchiq_bulk_xfer_waiting_interruptible(struct vchiq_instance *instance, + unsigned int handle, struct bulk_waiter *userdata) +{ + struct vchiq_service *service = find_service_by_handle(instance, handle); + struct bulk_waiter *bulk_waiter; + struct vchiq_bulk *bulk; + int status = -EINVAL; + + if (!service) + goto error_exit; + + if (!userdata) + goto error_exit; + + if (service->srvstate != VCHIQ_SRVSTATE_OPEN) + goto error_exit; + + if (vchiq_check_service(service)) + goto error_exit; + + bulk_waiter = userdata; + bulk = bulk_waiter->bulk; + + vchiq_service_put(service); + + status = 0; + + if (wait_for_completion_interruptible(&bulk_waiter->event)) + return -EAGAIN; + else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED) + return -EINVAL; + + return status; + +error_exit: + if (service) + vchiq_service_put(service); + return status; +} + int vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, 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 77cc4d7ac077..985d9ea3a06a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -470,6 +470,10 @@ vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instan extern void remote_event_pollall(struct vchiq_state *state); +extern int +vchiq_bulk_xfer_waiting_interruptible(struct vchiq_instance *instance, + unsigned int handle, struct bulk_waiter *userdata); + 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, 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 9cd2a64dce5e..550838d2863b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -324,6 +324,10 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, dev_dbg(service->state->dev, "arm: found bulk_waiter %pK for pid %d\n", waiter, current->pid); userdata = &waiter->bulk_waiter; + + status = vchiq_bulk_xfer_waiting_interruptible(instance, args->handle, userdata); + + goto bulk_transfer_handled; } else { userdata = args->userdata; } @@ -331,6 +335,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, status = vchiq_bulk_transfer(instance, args->handle, NULL, args->data, args->size, userdata, args->mode, dir); +bulk_transfer_handled: if (!waiter) { ret = 0; goto out;
The bulk transfer is VCHIQ_BULK_MODE_WAITING is used by VCHIQ ioctl interface. It is factored out to a separate function from vchiq_bulk_transfer() to bulk_xfer_waiting_interruptible(). This is a part of vchiq_bulk_transfer refactoring. Each bulk mode will have their dedicated functions to execute bulk transfers. Each mode will be handled separately in subsequent patches. bulk_xfer_waiting_interruptible() is suffixed with "_interruptible" to denote that it can be interrupted when a signal is received. -EAGAIN maybe returned in those cases, similar to what vchiq_bulk_transfer() does. Adjust the vchiq_irq_queue_bulk_tx_rx() in the vchiq-dev.c to call bulk_xfer_waiting_interruptible() for waiting mode. A temporary goto label has been introduced to jump the call execution over vchiq_bulk_transfer() for waiting mode only. When all dedicated bulk transfer calls are introduced, this label shall be dropped. No function changes intended in this patch. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> --- .../interface/vchiq_arm/vchiq_core.c | 51 +++++++++++++++++-- .../interface/vchiq_arm/vchiq_core.h | 4 ++ .../interface/vchiq_arm/vchiq_dev.c | 5 ++ 3 files changed, 55 insertions(+), 5 deletions(-)