Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9504775rwl; Wed, 11 Jan 2023 06:34:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXfdaQbwHpa9jhmk+kUmgd77lJi9ND0N+FMYqBExAVzg4BDkOP7SQCdqEpNVvA2o8Qvxxa X-Received: by 2002:a05:6a20:4985:b0:ac:a2bb:96e6 with SMTP id fs5-20020a056a20498500b000aca2bb96e6mr72071923pzb.56.1673447680772; Wed, 11 Jan 2023 06:34:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673447680; cv=none; d=google.com; s=arc-20160816; b=aFSPo2mHmp36AAyNqUSLGqRL3KbpoWP82Y3tpVWMvps4oHZNEzgormRsK3hT+FjOlb Ydri4JLnoApiYO1Bl7/Qy10ueM3jtTTkLcucdFcAGFMP22/bc5IqfCCU5f3+fM20X7xj OHW96i1WZKiOaseYa5E/6jxZQb5/wXHHG/dUiEkh1mHAQLRP0VffmdbgFFwGvSvWh2lv uUURTDp3tO2dwhJqE5bDjiJy/hvRKtL7oXmX25nD+pKRsz9qJmyKLqL85iEWzO5XuO52 XMJY1A7ApPukOBWhFeGSglffgPbXKpu6y9PMnWyrq8sqAsFEts0bXcHKYr9O0yDr3p1V 2ohA== 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=swA6hlITWj9ZQxEE7Y3/72RWhkNQGEUc5WspLWumkII=; b=Jdym36JcGc2z74OuQiaoltiE94nOqZ6MOuF/EbLihp/QtZ0iOirJlDos9UQVQL00Mz 0I1AzXtEVz7SMREoYHC80JAcSS6rN9/S11NCl9Zg15GmvSawOFhsImZrj6R2dG11S8Eu F/tWsbbPN6GmMS80ziUxyfgJ7bawKE53n4f0HH3+8hwm58TqD/5+G41szGRIg44vjK32 8JzVw/IoQXDka997BpFXJ4TSm3EatuZHsJlBR6wuKhOzbM/vqridg63BjY8SGXXOlA1m n00BLl+L6B5nGvUXO+jsj9nyzpIiSVoAoYDmtBYk4+5BPYO96WJsQvps7RkomviWli+7 EmCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=IY+z7nnF; 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 p10-20020a634f4a000000b0047586ee5f6asi15032290pgl.857.2023.01.11.06.34.34; Wed, 11 Jan 2023 06:34:40 -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=IY+z7nnF; 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 S239465AbjAKNqm (ORCPT + 53 others); Wed, 11 Jan 2023 08:46:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234223AbjAKNqV (ORCPT ); Wed, 11 Jan 2023 08:46:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE159631F for ; Wed, 11 Jan 2023 05:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444758; x=1704980758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M0K6BPFNHtGJsQXxOTjDHE/+MPRCH1csScxb1OhpftI=; b=IY+z7nnF75FxHIjyUCWASBE/iT77zAxfQ0+7+RFL/5igR8V1dMYlB7/e nXgokxFI3ZEMwwhGHnWtKo6QWffS1+uj76NYfJ3tutXMvvK6xisYHXGY1 iZLIR/lgcm7wnFfbhNdY7slRIngY3zI3xpqV2ebzQj3WpzokZa/VrDgZr Mfsvpqa7+qAaztSIkuwXyB988BAJQnULiNXdneMAEAfXH63eTHDRa2Kue 80Z6MteiZYicH3rBRV4C8E+d4iX0NwfNNQwiHJe6FFz+VqfVwzOClVVuN 1c5tRlVDhnaVagmeiBpnUQdF+ih9SjiMw9QZ6FFvmTw/4rTLONSCTLGXB A==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="207325811" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Jan 2023 06:45:58 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Wed, 11 Jan 2023 06:45:57 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Wed, 11 Jan 2023 06:45:56 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 7/7] soc: microchip: mpfs: handle timeouts and failed services differently Date: Wed, 11 Jan 2023 13:45:13 +0000 Message-ID: <20230111134513.2495510-8-conor.dooley@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111134513.2495510-1-conor.dooley@microchip.com> References: <20230111134513.2495510-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 The system controller will only deliver an interrupt if a service succeeds. This leaves us in the unfortunate position with current code where there is no way to differentiate between a legitimate timeout where the service has not completed & where it has completed, but failed. mbox_send_message() has its own completion, and it will time out of the system controller does not lower the busy flag. In this case, a timeout has occurred and the error can be propagated back to the caller. If the busy flag is lowered, but no interrupt has arrived to trigger the rx callback, the service can be deemed to have failed. Report EBADMSG in this case so that callers can differentiate. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index 4aadd05769d2..75422db75fe5 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -41,14 +41,25 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct reinit_completion(&sys_controller->c); ret = mbox_send_message(sys_controller->chan, msg); - if (ret < 0) + if (ret < 0) { + dev_warn(sys_controller->client.dev, + "MPFS sys controller service timeout\n"); goto out; + } ret = 0; /* mbox_send_message returns postitive integers on success */ + + /* + * Unfortunately, the system controller will only deliver an interrupt + * if a service succeeds. mbox_send_message() will block until the busy + * flag is gone. If the busy flag is gone but no interrupt has arrived + * to trigger the rx callback then the service can be deemed to have + * failed. + */ if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { - ret = -ETIMEDOUT; + ret = -EBADMSG; dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); + "MPFS sys controller service failed\n"); } out: @@ -106,6 +117,7 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev) sys_controller->client.dev = dev; sys_controller->client.rx_callback = rx_callback; sys_controller->client.tx_block = 1U; + sys_controller->client.tx_tout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); sys_controller->chan = mbox_request_channel(&sys_controller->client, 0); if (IS_ERR(sys_controller->chan)) { -- 2.39.0