From nobody Fri Nov 29 15:30:19 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5195F1474D8 for ; Wed, 18 Sep 2024 16:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677103; cv=none; b=O8mM1Io1pTFLXoSMXeCdFoSQErZJyn+auyfuqrYLaQ8Hnd9ZPP7u+maEDBx5ZeOd7VpckCospzBAmLK0YOmNuJNo+a5J1EVYA+czLIJWNAq7/4VKAIbsZsYl7jx5jyMS7sLKvCjPKHdSX88GXnBFUonjjfYLqJoNKed4pPm80Yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677103; c=relaxed/simple; bh=fr72GNiWGGMkBaBJOsubgeHDmrGDhVY9fNs4q1znF1A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dra+TedHRXaV7ntSLGIxcdoFIt902hAc4MHftN4jFDjIGNR0NFgZWhB/fnapNicRv41EJUiSRdN2As9V+hSUzut5FWtT/gpkRxpqKRjoQSJbYVpbukJtMMPjr14DacxYFm31Gb07zKSE7Je+6LLSNMwJA3mLDGhstFLK/TZOuxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=AI6IzqsT; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AI6IzqsT" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9AB052C6; Wed, 18 Sep 2024 18:30:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726677011; bh=fr72GNiWGGMkBaBJOsubgeHDmrGDhVY9fNs4q1znF1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AI6IzqsT89qkaqhmtL3Op4ayghGkft3bX+EGOklLgOPcZFFQXND03SO6lsMfzZi3u 1A/FsF2wS/Ctk42VbDxzpFCD9vSW1WlkT1EgzSoiE0MWE9HZFv1U43Fx5E/cksjIUz MOIY47X1pQLNCf0Miao23TMWBT8sceULA9GOxPOE= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Arnd Bergmann , Stefan Wahren , Laurent Pinchart , Nicolas Saenz Julienne , Umang Jain Subject: [PATCH 1/6] staging: vchiq_core: Use killable wait completions for bulk transfers Date: Wed, 18 Sep 2024 22:00:55 +0530 Message-ID: <20240918163100.870596-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240918163100.870596-1-umang.jain@ideasonboard.com> References: <20240918163100.870596-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores") introduced completions for events in vchiq interface. It introduced _interruptible() version of completions for waiting on events. However, it missed a subtle down_interruptible() macro override in vchiq_killable.h, which used to mask most of the signals and only interrupt on fatal ones. The above issue was fixed in commit a772f116702e ("staging: vchiq: switch to wait_for_completion_killable"). Given the override logic of down_interruptible() that existed in vchiq_killable.h, that commit fixed the completions with the correct variation i.e. killable() family of functions. However, commit a772f116702e ("staging: vchiq: switch to wait_for_completion_killable") later got reverted [1] due to high CPU load noticed by various downstream and upstream distributions [2]. Reverting the commit solved this problem but the root cause was never diagonsed and the entire commit was reverted. This patch brings back killable version of wait events but only for bulk transfers and queue_message() transfer code paths. The idea is to bring back killable versions for various event completions in a phased manner so that we do not re-regress again as noticed in [2]. Hence, no other wait events are converted from interruptible -> killable in this patch. Since the bulk transfers are no longer interruptible (but killable), drop the "_interruptible" suffix from all vchiq_bulk_xfer_* functions. [1]: commit 086efbabdc04 ("staging: vchiq: revert "switch to wait_for_compl= etion_killable"") [2]: https://patchwork.kernel.org/project/linux-arm-kernel/cover/2019050914= 3137.31254-1-nsaenzjulienne@suse.de/ Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 17 +++---- .../interface/vchiq_arm/vchiq_core.c | 46 +++++++++---------- .../interface/vchiq_arm/vchiq_core.h | 18 ++++---- .../interface/vchiq_arm/vchiq_dev.c | 14 +++--- 4 files changed, 46 insertions(+), 49 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 3dbeffc650d3..661b3a9a8280 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -857,10 +857,9 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, u= nsigned int handle, const switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: case VCHIQ_BULK_MODE_CALLBACK: - ret =3D vchiq_bulk_xfer_callback_interruptible(instance, handle, - (void *)data, NULL, - size, mode, userdata, - VCHIQ_BULK_TRANSMIT); + ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, + NULL, size, mode, userdata, + VCHIQ_BULK_TRANSMIT); break; case VCHIQ_BULK_MODE_BLOCKING: ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, si= ze, @@ -895,10 +894,8 @@ int vchiq_bulk_receive(struct vchiq_instance *instance= , unsigned int handle, switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: case VCHIQ_BULK_MODE_CALLBACK: - ret =3D vchiq_bulk_xfer_callback_interruptible(instance, handle, - (void *)data, NULL, - size, mode, userdata, - VCHIQ_BULK_RECEIVE); + ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, NULL, + size, mode, userdata, VCHIQ_BULK_RECEIVE); break; case VCHIQ_BULK_MODE_BLOCKING: ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, si= ze, @@ -969,8 +966,8 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *ins= tance, unsigned int handl return -ENOMEM; } =20 - ret =3D vchiq_bulk_xfer_blocking_interruptible(instance, handle, data, NU= LL, size, - &waiter->bulk_waiter, dir); + ret =3D vchiq_bulk_xfer_blocking(instance, handle, data, NULL, size, + &waiter->bulk_waiter, dir); if ((ret !=3D -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_= waiter.bulk) { struct vchiq_bulk *bulk =3D waiter->bulk_waiter.bulk; =20 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 1f94db6e0cd9..a381a633d3d5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -962,7 +962,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, spin_unlock(&state->quota_spinlock); mutex_unlock(&state->slot_mutex); =20 - if (wait_for_completion_interruptible(&state->data_quota_event)) + if (wait_for_completion_killable(&state->data_quota_event)) return -EAGAIN; =20 mutex_lock(&state->slot_mutex); @@ -986,7 +986,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, quota->message_use_count, quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_interruptible("a->quota_event)) + if (wait_for_completion_killable("a->quota_event)) return -EAGAIN; if (service->closing) return -EHOSTDOWN; @@ -2662,11 +2662,11 @@ close_service_complete(struct vchiq_service *servic= e, int failstate) * returned to user context. */ static int -vchiq_bulk_xfer_queue_msg_interruptible(struct vchiq_service *service, - void *offset, void __user *uoffset, - int size, void *userdata, - enum vchiq_bulk_mode mode, - enum vchiq_bulk_dir dir) +vchiq_bulk_xfer_queue_msg_killable(struct vchiq_service *service, + void *offset, void __user *uoffset, + int size, void *userdata, + enum vchiq_bulk_mode mode, + enum vchiq_bulk_dir dir) { struct vchiq_bulk_queue *queue; struct bulk_waiter *bulk_waiter =3D NULL; @@ -2695,7 +2695,7 @@ vchiq_bulk_xfer_queue_msg_interruptible(struct vchiq_= service *service, VCHIQ_SERVICE_STATS_INC(service, bulk_stalls); do { mutex_unlock(&service->bulk_mutex); - if (wait_for_completion_interruptible(&service->bulk_remove_event)) + if (wait_for_completion_killable(&service->bulk_remove_event)) return -EAGAIN; if (mutex_lock_killable(&service->bulk_mutex)) return -EAGAIN; @@ -2763,7 +2763,7 @@ vchiq_bulk_xfer_queue_msg_interruptible(struct vchiq_= service *service, =20 if (bulk_waiter) { bulk_waiter->bulk =3D bulk; - if (wait_for_completion_interruptible(&bulk_waiter->event)) + if (wait_for_completion_killable(&bulk_waiter->event)) status =3D -EAGAIN; else if (bulk_waiter->actual =3D=3D VCHIQ_BULK_ACTUAL_ABOR= TED) status =3D -EINVAL; @@ -3105,9 +3105,9 @@ vchiq_remove_service(struct vchiq_instance *instance,= unsigned int handle) } =20 int -vchiq_bulk_xfer_blocking_interruptible(struct vchiq_instance *instance, un= signed int handle, - void *offset, void __user *uoffset, int size, - void __user *userdata, enum vchiq_bulk_dir dir) +vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int han= dle, + void *offset, void __user *uoffset, int size, + void __user *userdata, enum vchiq_bulk_dir dir) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); enum vchiq_bulk_mode mode =3D VCHIQ_BULK_MODE_BLOCKING; @@ -3126,8 +3126,8 @@ vchiq_bulk_xfer_blocking_interruptible(struct vchiq_i= nstance *instance, unsigned goto error_exit; =20 =20 - status =3D vchiq_bulk_xfer_queue_msg_interruptible(service, offset, uoffs= et, size, - userdata, mode, dir); + status =3D vchiq_bulk_xfer_queue_msg_killable(service, offset, uoffset, s= ize, + userdata, mode, dir); =20 error_exit: vchiq_service_put(service); @@ -3136,10 +3136,10 @@ vchiq_bulk_xfer_blocking_interruptible(struct vchiq= _instance *instance, unsigned } =20 int -vchiq_bulk_xfer_callback_interruptible(struct vchiq_instance *instance, un= signed int handle, - void *offset, void __user *uoffset, int size, - enum vchiq_bulk_mode mode, void *userdata, - enum vchiq_bulk_dir dir) +vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int han= dle, + void *offset, void __user *uoffset, int size, + enum vchiq_bulk_mode mode, void *userdata, + enum vchiq_bulk_dir dir) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); int status =3D -EINVAL; @@ -3160,8 +3160,8 @@ vchiq_bulk_xfer_callback_interruptible(struct vchiq_i= nstance *instance, unsigned if (vchiq_check_service(service)) goto error_exit; =20 - status =3D vchiq_bulk_xfer_queue_msg_interruptible(service, offset, uoffs= et, - size, userdata, mode, dir); + status =3D vchiq_bulk_xfer_queue_msg_killable(service, offset, uoffset, + size, userdata, mode, dir); =20 error_exit: vchiq_service_put(service); @@ -3175,8 +3175,8 @@ vchiq_bulk_xfer_callback_interruptible(struct vchiq_i= nstance *instance, unsigned * 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) +vchiq_bulk_xfer_waiting(struct vchiq_instance *instance, + unsigned int handle, struct bulk_waiter *userdata) { struct vchiq_service *service =3D find_service_by_handle(instance, handle= ); struct bulk_waiter *bulk_waiter; @@ -3200,7 +3200,7 @@ vchiq_bulk_xfer_waiting_interruptible(struct vchiq_in= stance *instance, =20 status =3D 0; =20 - if (wait_for_completion_interruptible(&bulk_waiter->event)) + if (wait_for_completion_killable(&bulk_waiter->event)) return -EAGAIN; else if (bulk_waiter->actual =3D=3D VCHIQ_BULK_ACTUAL_ABORTED) return -EINVAL; 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 468463f31801..5bf543dfc9c7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -471,19 +471,19 @@ extern void remote_event_pollall(struct vchiq_state *state); =20 extern int -vchiq_bulk_xfer_waiting_interruptible(struct vchiq_instance *instance, - unsigned int handle, struct bulk_waiter *userdata); +vchiq_bulk_xfer_waiting(struct vchiq_instance *instance, unsigned int hand= le, + struct bulk_waiter *userdata); =20 extern int -vchiq_bulk_xfer_blocking_interruptible(struct vchiq_instance *instance, un= signed int handle, - void *offset, void __user *uoffset, int size, - void __user *userdata, enum vchiq_bulk_dir dir); +vchiq_bulk_xfer_blocking(struct vchiq_instance *instance, unsigned int han= dle, + void *offset, void __user *uoffset, int size, + void __user *userdata, enum vchiq_bulk_dir dir); =20 extern int -vchiq_bulk_xfer_callback_interruptible(struct vchiq_instance *instance, un= signed int handle, - void *offset, void __user *uoffset, int size, - enum vchiq_bulk_mode mode, void *userdata, - enum vchiq_bulk_dir dir); +vchiq_bulk_xfer_callback(struct vchiq_instance *instance, unsigned int han= dle, + void *offset, void __user *uoffset, int size, + enum vchiq_bulk_mode mode, void *userdata, + enum vchiq_bulk_dir dir); =20 extern void vchiq_dump_state(struct seq_file *f, struct vchiq_state *state); 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 d41a4624cc92..aca237919696 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -305,9 +305,9 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_inst= ance *instance, =20 userdata =3D &waiter->bulk_waiter; =20 - status =3D vchiq_bulk_xfer_blocking_interruptible(instance, args->handle, - NULL, args->data, args->size, - userdata, dir); + status =3D vchiq_bulk_xfer_blocking(instance, args->handle, + NULL, args->data, args->size, + userdata, dir); =20 } else if (args->mode =3D=3D VCHIQ_BULK_MODE_WAITING) { mutex_lock(&instance->bulk_waiter_list_mutex); @@ -330,13 +330,13 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_in= stance *instance, waiter, current->pid); userdata =3D &waiter->bulk_waiter; =20 - status =3D vchiq_bulk_xfer_waiting_interruptible(instance, args->handle,= userdata); + status =3D vchiq_bulk_xfer_waiting(instance, args->handle, userdata); } else { userdata =3D args->userdata; =20 - status =3D vchiq_bulk_xfer_callback_interruptible(instance, args->handle= , NULL, - args->data, args->size, - args->mode, userdata, dir); + status =3D vchiq_bulk_xfer_callback(instance, args->handle, NULL, + args->data, args->size, + args->mode, userdata, dir); =20 } =20 --=20 2.45.2 From nobody Fri Nov 29 15:30:19 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B23E91C9872 for ; Wed, 18 Sep 2024 16:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677106; cv=none; b=tGfs3mkYzh8iiCzUTI1pglj6MCUnsDO52+SkJe3u7m+KyYeIuHdqvd6lefAQStEHtatbCnZ3JDLn5DwCf0iMudZ3tzZT7yYmmxcXTW66cxUGmGXR1tlNw3juBP1vkNMYI6YT8tOuNbtrOnz9R1YcVb4Huxcp3te24acDOgcjW8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677106; c=relaxed/simple; bh=sHrmkv7qdL/VGUyX+8A53+Ph6+f7Wq5flFy4YcSlqf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GyMLxLEVMdgznRsa/hmSo/qZg/XoFWF0NWuHFYUOudFG/jAGAcqDsb0lE+qAMn1l1eG3i4M54Eyh993ZPnsPZAyNSYUlwctyIB47X7z3qNEzcIYQM001Ayf1z2aOz6CQMKrO04sVXHhN558HIy4AKiBeVxmf5tD/oqtbbJvOonM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=O2aULEyI; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="O2aULEyI" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DC194593; Wed, 18 Sep 2024 18:30:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726677013; bh=sHrmkv7qdL/VGUyX+8A53+Ph6+f7Wq5flFy4YcSlqf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2aULEyIGBmK0xBduyXBqZiu5uggYc7cDcj+2oqnmqG0u7cTYbVAYILxKb9T13LzC dlpumv/jOYknAem5RAKbpRhLXZ4bvFib6Nv3ooT364tdMPxj8BQdjeZ26/lkPVqand AGTCqW0/K8/0eM7yU0SuRgFweyQmEpen8PrJCRpY= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Arnd Bergmann , Stefan Wahren , Laurent Pinchart , Nicolas Saenz Julienne , Umang Jain Subject: [PATCH 2/6] staging: vchiq_core: Return on all errors from queue_message() Date: Wed, 18 Sep 2024 22:00:56 +0530 Message-ID: <20240918163100.870596-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240918163100.870596-1-umang.jain@ideasonboard.com> References: <20240918163100.870596-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In vchiq_connect_internal(), a MAKE_CONNECT message is queued if the connection is disconnected, but only -EAGAIN error is checked on the error path and returned. However, queue_message() can fail with other errors as well hence, vchiq_connect_internal() should return in those cases as well. Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 a381a633d3d5..4279dd182a98 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2945,6 +2945,7 @@ int vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *i= nstance) { struct vchiq_service *service; + int status =3D 0; int i; =20 /* Find all services registered to this client and enable them. */ @@ -2956,9 +2957,10 @@ vchiq_connect_internal(struct vchiq_state *state, st= ruct vchiq_instance *instanc } =20 if (state->conn_state =3D=3D VCHIQ_CONNSTATE_DISCONNECTED) { - if (queue_message(state, NULL, MAKE_CONNECT, NULL, NULL, 0, - QMFLAGS_IS_BLOCKING) =3D=3D -EAGAIN) - return -EAGAIN; + status =3D queue_message(state, NULL, MAKE_CONNECT, NULL, NULL, 0, + QMFLAGS_IS_BLOCKING); + if (status) + return status; =20 vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTING); } @@ -2971,7 +2973,7 @@ vchiq_connect_internal(struct vchiq_state *state, str= uct vchiq_instance *instanc complete(&state->connect); } =20 - return 0; + return status; } =20 void --=20 2.45.2 From nobody Fri Nov 29 15:30:19 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C39501C9878 for ; Wed, 18 Sep 2024 16:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677106; cv=none; b=m/9Rnset5nTJwH0A9u85Jtdb7nAm08eXxHbVEK2j6CZQyt7MpUNiB4hDK8kg6lordROUORE8yCl7U9HX58+ZIHtkbwDWN0rPc4263txsimnXnWcECYYDWtxK/CrLAorDJkzdEJLgxgHloBNNBUBrWiz4QrQfF4lxbhACA/4N3oA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677106; c=relaxed/simple; bh=sPFkvcNPaqTNv6pNG8JxZmx068ImTFIjLol71A2L6QU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pz8qEReMJfimI4Vp0HQaZx/VPraB3nt3xTiD1Mufb9WQBiblPspsCgHHO8BMPiK2DF/N61BxoovnGGrDMbI2Hqzfb9ihqzmwqnnw8xw12glDCsZvvzIWSHf3VfmKAzy6/SOpeWzi3fOl3iRbqdpYLUM5iVgz4vNvpFAhQ+YXYCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=qnyGr0eF; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qnyGr0eF" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C835A57; Wed, 18 Sep 2024 18:30:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726677016; bh=sPFkvcNPaqTNv6pNG8JxZmx068ImTFIjLol71A2L6QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qnyGr0eFR8qGVYkeSmP9GDP+7sJPB/XjomcF9wxWVPAdF84rv8ChMNLaAPF1VtLXZ aYN7a8puZIul8hsYYRfcqmbxkp5lnq0+hk+KdBXIj2dKF5YLYJnijq78tO0sdYtzUl dr7SFDyzRAge2e2clZJCF9yFwBk0jZBRPI3t3/2E= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Arnd Bergmann , Stefan Wahren , Laurent Pinchart , Nicolas Saenz Julienne , Umang Jain Subject: [PATCH 3/6] staging: vchiq_core: Return -EINTR in queue_message() on interrupt Date: Wed, 18 Sep 2024 22:00:57 +0530 Message-ID: <20240918163100.870596-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240918163100.870596-1-umang.jain@ideasonboard.com> References: <20240918163100.870596-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" queue_message() uses mutex_lock_killable() and wait_for_completion_killable() variations of locking and wait event completions respectively. These functions return either 0 (on success) or -EINTR, if interrupted by a fatal signal (as documented in the kernel). However, queue_message() is currently returning -EAGAIN if these killable functions are interrupted by fatal signals. Bubbling up -EAGAIN might give a sense to the caller, that the code path can be re-tried however, in actual sense, a fatal signal has been received by the process and the process is going away. Hence, we should align the return value with what these killable versions will return i.e. -EINTR (Interrupted system call). Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_core.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 4279dd182a98..d7b22e37c2ff 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -922,7 +922,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, =20 if (!(flags & QMFLAGS_NO_MUTEX_LOCK) && mutex_lock_killable(&state->slot_mutex)) - return -EAGAIN; + return -EINTR; =20 if (type =3D=3D VCHIQ_MSG_DATA) { int tx_end_index; @@ -963,7 +963,7 @@ queue_message(struct vchiq_state *state, struct vchiq_s= ervice *service, mutex_unlock(&state->slot_mutex); =20 if (wait_for_completion_killable(&state->data_quota_event)) - return -EAGAIN; + return -EINTR; =20 mutex_lock(&state->slot_mutex); spin_lock(&state->quota_spinlock); @@ -987,11 +987,11 @@ queue_message(struct vchiq_state *state, struct vchiq= _service *service, VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); if (wait_for_completion_killable("a->quota_event)) - return -EAGAIN; + return -EINTR; if (service->closing) return -EHOSTDOWN; if (mutex_lock_killable(&state->slot_mutex)) - return -EAGAIN; + return -EINTR; if (service->srvstate !=3D VCHIQ_SRVSTATE_OPEN) { /* The service has been closed */ mutex_unlock(&state->slot_mutex); @@ -1524,7 +1524,7 @@ parse_open(struct vchiq_state *state, struct vchiq_he= ader *header) set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); } else { if (queue_message(state, NULL, openack_id, memcpy_copy_callback, - &ack_payload, sizeof(ack_payload), 0) =3D=3D -EAGAIN) + &ack_payload, sizeof(ack_payload), 0) =3D=3D -EINTR) goto bail_not_ready; =20 /* The service is now open */ @@ -1539,7 +1539,7 @@ parse_open(struct vchiq_state *state, struct vchiq_he= ader *header) fail_open: /* No available service, or an invalid request - send a CLOSE */ if (queue_message(state, NULL, MAKE_CLOSE(0, VCHIQ_MSG_SRCPORT(msgid)), - NULL, NULL, 0, 0) =3D=3D -EAGAIN) + NULL, NULL, 0, 0) =3D=3D -EINTR) goto bail_not_ready; =20 return 1; @@ -1786,7 +1786,7 @@ parse_message(struct vchiq_state *state, struct vchiq= _header *header) if (state->conn_state !=3D VCHIQ_CONNSTATE_PAUSE_SENT) { /* Send a PAUSE in response */ if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) =3D=3D -EAGAIN) + QMFLAGS_NO_MUTEX_UNLOCK) =3D=3D -EINTR) goto bail_not_ready; } /* At this point slot_mutex is held */ @@ -1903,7 +1903,7 @@ handle_poll(struct vchiq_state *state) =20 case VCHIQ_CONNSTATE_PAUSING: if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) !=3D -EAGAIN) { + QMFLAGS_NO_MUTEX_UNLOCK) !=3D -EINTR) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSE_SENT); } else { /* Retry later */ @@ -1913,7 +1913,7 @@ handle_poll(struct vchiq_state *state) =20 case VCHIQ_CONNSTATE_RESUMING: if (queue_message(state, NULL, MAKE_RESUME, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_LOCK) !=3D -EAGAIN) { + QMFLAGS_NO_MUTEX_LOCK) !=3D -EINTR) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); } else { /* @@ -3276,11 +3276,11 @@ int vchiq_queue_kernel_message(struct vchiq_instanc= e *instance, unsigned int han data, size); =20 /* - * vchiq_queue_message() may return -EAGAIN, so we need to + * vchiq_queue_message() may return -EINTR, so we need to * implement a retry mechanism since this function is supposed * to block until queued */ - if (status !=3D -EAGAIN) + if (status !=3D -EINTR) break; =20 msleep(1); --=20 2.45.2 From nobody Fri Nov 29 15:30:19 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03ACF1C9EB2 for ; Wed, 18 Sep 2024 16:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677109; cv=none; b=tSvWPeXpMtE3szAkHdUAqUO5rG+xoaeUAJ8cghGcmfozS3fE9Cw1dUcCuZ5ELJT13ZLLPz823CYN3rlmpEj9M+5e25i9o+XP8DDsHszY9YS6L639nzAvoHgzrPSKTPW3bfiB7n5hduUnYxysM2iuY9t11qtg9BR6AUDd5n0A0Tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677109; c=relaxed/simple; bh=IOIPt9AVMml8XUc4ADrmjHxDtvBlrA5jWwdoFYKT1j8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XlwPI2b4rkyxW4Rqw/IKLQVFiYXeTOb4VjeAz48L3dH2vShRpj+pRH889xWyW7w+AiPxMZRrDw8v9Q23PGinu3knIa/HIjJtn8fhP+pASmsVjDjVULZ4zjyoXPTNk17stp0i7s/4YSus6eQSv2noNET/LmlG3G8u5de8RjaNGrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=WO6bIGq4; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WO6bIGq4" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BD3061111; Wed, 18 Sep 2024 18:30:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726677018; bh=IOIPt9AVMml8XUc4ADrmjHxDtvBlrA5jWwdoFYKT1j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WO6bIGq4fR5ZldqhBYs6Ls+o5SqReFrjaP2h+rL1LcG0A0j8GOLHk+HFPa3rH0iyA 16OyiobEWGWMyUJd47BdWJef2OxlhaY5F+w7qE6m0xKT7Cf7Dt0cO80fkMRt8UP7wU A22+zX4seVKssMZCrJR3IDwhZRE+pi79n9vez4wY= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Arnd Bergmann , Stefan Wahren , Laurent Pinchart , Nicolas Saenz Julienne , Umang Jain Subject: [PATCH 4/6] staging: vchiq_core: Return -EINTR when bulk transfers are interrupted Date: Wed, 18 Sep 2024 22:00:58 +0530 Message-ID: <20240918163100.870596-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240918163100.870596-1-umang.jain@ideasonboard.com> References: <20240918163100.870596-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 8 ++++---- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 12 ++++++------ 2 files changed, 10 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 661b3a9a8280..d5b23f3fee87 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -870,11 +870,11 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, = unsigned int handle, const } =20 /* - * 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 !=3D -EAGAIN) + if (ret !=3D -EINTR) break; =20 msleep(1); @@ -906,11 +906,11 @@ int vchiq_bulk_receive(struct vchiq_instance *instanc= e, unsigned int handle, } =20 /* - * 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 !=3D -EAGAIN) + if (ret !=3D -EINTR) break; =20 msleep(1); 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 d7b22e37c2ff..426e729b71ee 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2689,16 +2689,16 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_ser= vice *service, &service->bulk_tx : &service->bulk_rx; =20 if (mutex_lock_killable(&service->bulk_mutex)) - return -EAGAIN; + return -EINTR; =20 if (queue->local_insert =3D=3D 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 =3D=3D queue->remove + VCHIQ_NUM_SERVICE_BULKS); } @@ -2729,7 +2729,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, * claim it here to ensure that isn't happening */ if (mutex_lock_killable(&state->slot_mutex)) { - status =3D -EAGAIN; + status =3D -EINTR; goto cancel_bulk_error_exit; } =20 @@ -2764,7 +2764,7 @@ vchiq_bulk_xfer_queue_msg_killable(struct vchiq_servi= ce *service, if (bulk_waiter) { bulk_waiter->bulk =3D bulk; if (wait_for_completion_killable(&bulk_waiter->event)) - status =3D -EAGAIN; + status =3D -EINTR; else if (bulk_waiter->actual =3D=3D VCHIQ_BULK_ACTUAL_ABOR= TED) status =3D -EINVAL; } @@ -3203,7 +3203,7 @@ vchiq_bulk_xfer_waiting(struct vchiq_instance *instan= ce, status =3D 0; =20 if (wait_for_completion_killable(&bulk_waiter->event)) - return -EAGAIN; + return -EINTR; else if (bulk_waiter->actual =3D=3D VCHIQ_BULK_ACTUAL_ABORTED) return -EINVAL; =20 --=20 2.45.2 From nobody Fri Nov 29 15:30:19 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36CC31C9EB6 for ; Wed, 18 Sep 2024 16:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677109; cv=none; b=edA7n6mlcW034VEuzlp/BLLEoV0vsuYFCcCB7FUc8g/ylUVc1btLvEr/qpNYzlUnZL2R71HIIh7F1xYeq/FAnwD7dL92Z78G4lbKWtwZ9myqbQ7gH/OTfpMQO979yCFYYnZYCpPVDRLMgIs8rALlO5G6Qrk3qcg/fHEnQ6CHhDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677109; c=relaxed/simple; bh=349glJfpIeTFW2mCeCBwQ4Qkx92zWKGbpqqM1CAa22U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GAUbffggkd4+X81KVJJAdcAg3PXsvavKsnrvtNmNKJFu7nG+BXoZdJPIkoWZkIpnvnwZ7Mls68MnAFAVfPQG3ADB6ZO3qaUoBdzWgVM0h3SSdbG1DKND2ATdIcmQGCrNOpqy6GmjH7x3pZ6ryhckJjsPRQCN1ieh0tA2vIsBL9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=IDzWrYTJ; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IDzWrYTJ" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0B8D4173E; Wed, 18 Sep 2024 18:30:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726677020; bh=349glJfpIeTFW2mCeCBwQ4Qkx92zWKGbpqqM1CAa22U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IDzWrYTJJy9RoAMynBQb678LUOaxzzLNT8O6pIymYX4FFer/09cXoVxjYd/X3y6zs qQJvHJuzFPk8tnb3q7MKiF1/7sbwHEIB/NQ0qQEW1CvB4M1U2uuysY+1vV5u0QbE2c 4fEBhMqVt3gOXSVFPVb7AymBJ5IfsKG0F85cRmiw= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Arnd Bergmann , Stefan Wahren , Laurent Pinchart , Nicolas Saenz Julienne , Umang Jain Subject: [PATCH 5/6] staging: vchiq_arm: Do not retry bulk transfers on -EINTR Date: Wed, 18 Sep 2024 22:00:59 +0530 Message-ID: <20240918163100.870596-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240918163100.870596-1-umang.jain@ideasonboard.com> References: <20240918163100.870596-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" -EINTR is returned by various vchiq bulk transfer code paths on receiving a fatal signal to the process. Since the process is deemed to be terminated anyway, do not retry the bulk transfer on -EINTR. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 74 +++++++------------ 1 file changed, 25 insertions(+), 49 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 d5b23f3fee87..c44b4dc79c03 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -853,31 +853,19 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, = unsigned int handle, const { int ret; =20 - while (1) { - switch (mode) { - case VCHIQ_BULK_MODE_NOCALLBACK: - case VCHIQ_BULK_MODE_CALLBACK: - ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, - NULL, size, mode, userdata, - VCHIQ_BULK_TRANSMIT); - break; - case VCHIQ_BULK_MODE_BLOCKING: - ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, si= ze, - VCHIQ_BULK_TRANSMIT); - break; - default: - return -EINVAL; - } - - /* - * 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 !=3D -EINTR) - break; - - msleep(1); + switch (mode) { + case VCHIQ_BULK_MODE_NOCALLBACK: + case VCHIQ_BULK_MODE_CALLBACK: + ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, + NULL, size, mode, userdata, + VCHIQ_BULK_TRANSMIT); + break; + case VCHIQ_BULK_MODE_BLOCKING: + ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, siz= e, + VCHIQ_BULK_TRANSMIT); + break; + default: + return -EINVAL; } =20 return ret; @@ -890,30 +878,18 @@ int vchiq_bulk_receive(struct vchiq_instance *instanc= e, unsigned int handle, { int ret; =20 - while (1) { - switch (mode) { - case VCHIQ_BULK_MODE_NOCALLBACK: - case VCHIQ_BULK_MODE_CALLBACK: - ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, NULL, - size, mode, userdata, VCHIQ_BULK_RECEIVE); - break; - case VCHIQ_BULK_MODE_BLOCKING: - ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, si= ze, - VCHIQ_BULK_RECEIVE); - break; - default: - return -EINVAL; - } - - /* - * 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 !=3D -EINTR) - break; - - msleep(1); + switch (mode) { + case VCHIQ_BULK_MODE_NOCALLBACK: + case VCHIQ_BULK_MODE_CALLBACK: + ret =3D vchiq_bulk_xfer_callback(instance, handle, (void *)data, NULL, + size, mode, userdata, VCHIQ_BULK_RECEIVE); + break; + case VCHIQ_BULK_MODE_BLOCKING: + ret =3D vchiq_blocking_bulk_transfer(instance, handle, (void *)data, siz= e, + VCHIQ_BULK_RECEIVE); + break; + default: + return -EINVAL; } =20 return ret; --=20 2.45.2 From nobody Fri Nov 29 15:30:19 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0C2C189F47 for ; Wed, 18 Sep 2024 16:31:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677112; cv=none; b=NCrKNfnuwj/o10M66xCShX1S2KxRT7lgMqFfqh1x2RQvsVZFj4xO5BQCOPWBWU5Sx+6odZeheZmUZtFXBivBHDQeayMQwMRdgzrwMBzvrRoYr8/lGosHA/Zn6Na3fwtxtdC81AsWomjihqfEl/EAn3Gmpb+ndhdoyMsq4pMzuI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726677112; c=relaxed/simple; bh=Gve0uMYsv6ZYvapmFb9XKu322dhAffKigvnNzUNpz/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uSpwKdnd/LqN1K0tufSK8NDzjXyCReKI3hfxb2E02gYBZwiHrMzayWMQlOMAsnrzcldFO0GU7t2dwHFG0eCkatXz75kW7pBnS2Mz0YtUY/WnJyY6JRVW9jErucTfzN71oKAlX4r43q57u/aK4dVV2eRAepy1wEOkmjn8im0u9mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=TRGAXEFQ; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TRGAXEFQ" Received: from umang.jain (unknown [IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4DAE9D52; Wed, 18 Sep 2024 18:30:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726677023; bh=Gve0uMYsv6ZYvapmFb9XKu322dhAffKigvnNzUNpz/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TRGAXEFQUU/4iV+pRTWVna2lvwGjEvRRvcpZ+p3jwT0Ej651GsbIzfkgc/9aF33uc 3zt5TTtFAJ11NdTpewbfoJ/WpifHPNnWmW4lCPyVsLfTb5MdCblz1ia7kzEJ7s59/K 7CmTChUuZVQng2reLs1IbCGeb3XFotvod8VErK0Q= From: Umang Jain To: Greg Kroah-Hartman , Broadcom internal kernel review list Cc: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kieran Bingham , Arnd Bergmann , Stefan Wahren , Laurent Pinchart , Nicolas Saenz Julienne , Umang Jain Subject: [PATCH 6/6] staging: vchiq_core: Drop retry loop on -EINTR Date: Wed, 18 Sep 2024 22:01:00 +0530 Message-ID: <20240918163100.870596-7-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240918163100.870596-1-umang.jain@ideasonboard.com> References: <20240918163100.870596-1-umang.jain@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" -EINTR is returned by vchiq_queue_message() on receiving a fatal signal to the process. Since the process is deemed to be terminated anyway, do not retry queuing with vchiq_queue_message() on -EINTR. Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_core.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) 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 426e729b71ee..7ad43a3d1bab 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3269,24 +3269,9 @@ vchiq_queue_message(struct vchiq_instance *instance,= unsigned int handle, int vchiq_queue_kernel_message(struct vchiq_instance *instance, unsigned i= nt handle, void *data, unsigned int size) { - int status; - - while (1) { - status =3D vchiq_queue_message(instance, handle, memcpy_copy_callback, - data, size); - - /* - * vchiq_queue_message() may return -EINTR, so we need to - * implement a retry mechanism since this function is supposed - * to block until queued - */ - if (status !=3D -EINTR) - break; =20 - msleep(1); - } - - return status; + return vchiq_queue_message(instance, handle, memcpy_copy_callback, + data, size); } EXPORT_SYMBOL(vchiq_queue_kernel_message); =20 --=20 2.45.2