Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2740717rwb; Fri, 20 Jan 2023 06:53:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXv3knqxw8mfKADsLy3jmPNCnytVjXmcClvJONHKDhiaCc7QjvjujhF2/lOxRjgQQvlKE59y X-Received: by 2002:a17:906:d787:b0:872:5c0a:5597 with SMTP id pj7-20020a170906d78700b008725c0a5597mr14547450ejb.70.1674226379784; Fri, 20 Jan 2023 06:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674226379; cv=none; d=google.com; s=arc-20160816; b=aZVgIEfXfuCL9eIWpwX6CnLb6Uc3M9hC2Rh1MvkAAiFKrgLufuRyebjuw+bx0s9rb/ TDIB26BRWpTmuJaZaQf+RPQyk/EnEcM0P9Zok/5xMnnx9y7Gwd6MREStLAQ0CAvMXW50 JdeG77bkhr6McCWJLAtRHpMZBX/3rxepcLNBQJo0gR90PvH23dmzD1TqhEVqN+zwARbf fXwsyN+Mlttlgoq8aIzNSOyfUYF6uY6KtPqdGQbl11YQzzLjnzwDS62ju+wx6AEjc8sn N4RJhYlCpNNJI8hp68YMKI2vU+TnEKF0JMzF4xpIKGqu8K1a7vAiLQQ6GfKY6SWj7jy9 xJ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jNfPJFyOxVWXnp5WJoh4NUWB1+UPtKRTPD7FcyjyvLg=; b=CMERTTajn3KNCrq19lCF0+tbmtCM+RakZC4/j5vfUhaWE3I3CC9H48eTqGh+dVRdFv JFGuSgvY1EyuYg2QyENiifbF6FXb30TMe80A2p2KttKU8eTqaWz1mgyNa6T6+dFfMiQc h6ocInYKKdS0aGelqzztY5wvnDewFN4wB821r1ddzhBdF+fPo5jZqZNu+J/n7/Y+Do4L jon0QEHSq6vTE+mDZQQvoRiHm+8ZU3Is5ettv90pkK11sq/7CEUtVJgAfqAs8ew2kNCY w/uG2wOtxaKWAHNFLQAl4bXBBmsvY5Mh1UOJrLYKz8K4X1m6TO313KE/f8+Vt3evbOi5 QrMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=bK31pkgE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xe6-20020a170907318600b00780488c11bbsi45856154ejb.388.2023.01.20.06.52.46; Fri, 20 Jan 2023 06:52:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=bK31pkgE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbjATOkY (ORCPT + 49 others); Fri, 20 Jan 2023 09:40:24 -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: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/microchip/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 +/* + * This timeout must be long, as some services (example: image authentication) + * take many seconds to complete + */ +#define MPFS_SYS_CTRL_TIMEOUT_MS 30000 + static DEFINE_MUTEX(transaction_lock); struct mpfs_sys_controller { @@ -28,6 +35,7 @@ struct mpfs_sys_controller { int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg) { + unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); int ret, err; err = mutex_lock_interruptible(&transaction_lock); @@ -38,7 +46,7 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct ret = mbox_send_message(sys_controller->chan, msg); if (ret >= 0) { - if (wait_for_completion_timeout(&sys_controller->c, HZ)) { + if (wait_for_completion_timeout(&sys_controller->c, timeout)) { ret = 0; } else { ret = -ETIMEDOUT; -- 2.39.0