From patchwork Wed Sep 18 16:30:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13807014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8A80CDD548 for ; Wed, 18 Sep 2024 16:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=neG2QGQERHSYa9KiCLBdV60/5da5KIUZto0fnk5Y/9g=; b=u6hT09sa7RMiq3bG7d3vVRNaO1 dwJ2t1p18kT7qHTfBZh0vUucLlTDr/k6IvZP9xnIf4b12pDBS0UAb4b/p3kYaua0aARdHX16RJIss ewTx7sRNjMYhhujYt2VDKOSuc/icnW05SaHslQo4+Eg01vbCDVR5upfMFAAqzFONfYY6IgVCXDKM1 ZVFyqoaVc/qgZPR1TrYBfmg+UBR1Ss/xhHgZDkzhm8XMOnUQHoev3BUWkrqCnTvra45FMQYOm1WJR J2LedOlnMRZ4aXKYTKVDWiU5H6tJTzH2Bo4+gH3ZdXZ890L30o6MJR+pdQsECSlBQpmCD9kITK0pu AvwA1bTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sqxib-00000008eQG-3VMS; Wed, 18 Sep 2024 16:39:53 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sqxae-00000008dI9-01P1; Wed, 18 Sep 2024 16:31:41 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240918_093140_211974_F75F91E6 X-CRM114-Status: GOOD ( 17.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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_service *service, if (!(flags & QMFLAGS_NO_MUTEX_LOCK) && mutex_lock_killable(&state->slot_mutex)) - return -EAGAIN; + return -EINTR; if (type == VCHIQ_MSG_DATA) { int tx_end_index; @@ -963,7 +963,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, mutex_unlock(&state->slot_mutex); if (wait_for_completion_killable(&state->data_quota_event)) - return -EAGAIN; + return -EINTR; 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 != 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_header *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) == -EAGAIN) + &ack_payload, sizeof(ack_payload), 0) == -EINTR) goto bail_not_ready; /* The service is now open */ @@ -1539,7 +1539,7 @@ parse_open(struct vchiq_state *state, struct vchiq_header *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) == -EAGAIN) + NULL, NULL, 0, 0) == -EINTR) goto bail_not_ready; return 1; @@ -1786,7 +1786,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) if (state->conn_state != VCHIQ_CONNSTATE_PAUSE_SENT) { /* Send a PAUSE in response */ if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) == -EAGAIN) + QMFLAGS_NO_MUTEX_UNLOCK) == -EINTR) goto bail_not_ready; } /* At this point slot_mutex is held */ @@ -1903,7 +1903,7 @@ handle_poll(struct vchiq_state *state) case VCHIQ_CONNSTATE_PAUSING: if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) != -EAGAIN) { + QMFLAGS_NO_MUTEX_UNLOCK) != -EINTR) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSE_SENT); } else { /* Retry later */ @@ -1913,7 +1913,7 @@ handle_poll(struct vchiq_state *state) case VCHIQ_CONNSTATE_RESUMING: if (queue_message(state, NULL, MAKE_RESUME, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_LOCK) != -EAGAIN) { + QMFLAGS_NO_MUTEX_LOCK) != -EINTR) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); } else { /* @@ -3276,11 +3276,11 @@ int vchiq_queue_kernel_message(struct vchiq_instance *instance, unsigned int han data, size); /* - * 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 != -EAGAIN) + if (status != -EINTR) break; msleep(1);