From nobody Fri Nov 29 17:30:24 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