From nobody Sun Sep 14 16:48:32 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BBE3C05027 for ; Fri, 20 Jan 2023 14:40:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbjATOkZ (ORCPT ); Fri, 20 Jan 2023 09:40:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbjATOkR (ORCPT ); Fri, 20 Jan 2023 09:40:17 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 634586E0E7 for ; Fri, 20 Jan 2023 06:39:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225590; x=1705761590; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vswoNz7W4YNtXxpN9gjNGU8G3StYy1AGUcDydMeUCxM=; b=bK31pkgEuuSPXb3/EEDRxHgHic9PnYXuJ/KB24lAfvxeaE8OVVlyL0XC q1ek2DhVIpyJJ8Zv4WyFe1D02qYmSXnLgOFki52oj2dXIY626gRf9ddmK il1Dg1k/Q7Q6u6451SKfl1sEDbJPqfmdHwVtBUrEzWV43vWb8mcYVKbLE Ip9w7HOMZLhKDE6Tqvcktc7Iq3cO5LhJ+8AWpZ+gqyopT1JVyDbUUkEMi NsXh1LRclUl8NkZO9jAKL5RI1yrepSFzOuPQwmAorterThbfzVSaTRfHo oen41dCExY6fEuufDHN9Qo26U7HbTDN5CxOPhxUE2dcx1iBT9wLDgDbIu A==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="196713315" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 07:38:17 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 20 Jan 2023 07:38:17 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 20 Jan 2023 07:38:16 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 5/7] soc: microchip: mpfs: use a consistent completion timeout Date: Fri, 20 Jan 2023 14:37:33 +0000 Message-ID: <20230120143734.3438755-6-conor.dooley@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230120143734.3438755-1-conor.dooley@microchip.com> References: <20230120143734.3438755-1-conor.dooley@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Completion timeouts use jiffies, so passing a number directly will produce inconsistent timeouts depending on config. Define the timeout in ms and convert it to jiffies instead. Since a define is being created where one previously did not exist, pick a suitable timeout duration. Most services will complete nearly immediately, but those relating to image verification and re-programming the FPGA take significant amounts of time. 30 seconds is a suitable timeout for those situations, although most services will complete in under 100 ms. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/micr= ochip/mpfs-sys-controller.c index 12039cb38b33..e76a5e38f655 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -11,12 +11,19 @@ #include #include #include +#include #include #include #include #include #include =20 +/* + * This timeout must be long, as some services (example: image authenticat= ion) + * take many seconds to complete + */ +#define MPFS_SYS_CTRL_TIMEOUT_MS 30000 + static DEFINE_MUTEX(transaction_lock); =20 struct mpfs_sys_controller { @@ -28,6 +35,7 @@ struct mpfs_sys_controller { =20 int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, = struct mpfs_mss_msg *msg) { + unsigned long timeout =3D msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); int ret, err; =20 err =3D mutex_lock_interruptible(&transaction_lock); @@ -38,7 +46,7 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller = *sys_controller, struct =20 ret =3D mbox_send_message(sys_controller->chan, msg); if (ret >=3D 0) { - if (wait_for_completion_timeout(&sys_controller->c, HZ)) { + if (wait_for_completion_timeout(&sys_controller->c, timeout)) { ret =3D 0; } else { ret =3D -ETIMEDOUT; --=20 2.39.0