From nobody Sun Sep 14 14:29:56 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 87805C27C7C for ; Fri, 20 Jan 2023 14:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230171AbjATOkO (ORCPT ); Fri, 20 Jan 2023 09:40:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbjATOkF (ORCPT ); Fri, 20 Jan 2023 09:40:05 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0CECFD3B for ; Fri, 20 Jan 2023 06:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225569; x=1705761569; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wIqkIRLk97mVy76bXMdNE/RNNtTIHIYTZDRNoDes7MQ=; b=mJ6asm7QUVN8JOmvf0nBU881UxE7iAHCYB09wNGwNsl8KZlHpibe1Kp4 lCnAUfvr9DPt3PtPdbs2w8k8Ff3yOjNSrWkIWgGedutF82Qr6VttMJE7F x1np+cqtWvVRrX488fQxiZ8Z8jNK6uLmz0/Z3CjKyQsemX812bJ2AMdCJ pKdObYaO4u9MWPH6ioqu1fLruS0qyyxh1t7nDA1UaQBD1JKdYLyjctjOI jTHccNNYKbGw1h7aTyzD8iIdB9Nq+WdGO5JmKP4K4eUYZ1yv3EIbg3Xs2 fhDhhJIfdkyw5C82dgptRXRFDZggkg27PtN+uJvvUZHW/gDubRJHy2exI Q==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="197471514" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 07:38:14 -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:11 -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:10 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 1/7] mailbox: mpfs: fix an incorrect mask width Date: Fri, 20 Jan 2023 14:37:29 +0000 Message-ID: <20230120143734.3438755-2-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" The system controller registers on PolarFire SoC are 32 bits wide, so 16 + 16 as the first input to GENMASK_ULL() gives a 33 bit wide mask. It probably should have been immediately obvious when it was pointed out during review that the width required using GENMASK_ULL() - but I scarcely knew what I was doing at the time and missed it. The mistake ends up being moot as it is a mask after all, but it is incorrect and should be fixed. No functional change intended. Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index 853901acaeec..d37560e91116 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -39,7 +39,7 @@ #define SCB_CTRL_NOTIFY_MASK BIT(SCB_CTRL_NOTIFY) =20 #define SCB_CTRL_POS (16) -#define SCB_CTRL_MASK GENMASK_ULL(SCB_CTRL_POS + SCB_MASK_WIDTH, SCB_CTRL_= POS) +#define SCB_CTRL_MASK GENMASK(SCB_CTRL_POS + SCB_MASK_WIDTH - 1, SCB_CTRL_= POS) =20 /* SCBCTRL service status register */ =20 @@ -118,6 +118,7 @@ static int mpfs_mbox_send_data(struct mbox_chan *chan, = void *data) } =20 opt_sel =3D ((msg->mbox_offset << 7u) | (msg->cmd_opcode & 0x7fu)); + tx_trigger =3D (opt_sel << SCB_CTRL_POS) & SCB_CTRL_MASK; tx_trigger |=3D SCB_CTRL_REQ_MASK | SCB_STATUS_NOTIFY_MASK; writel_relaxed(tx_trigger, mbox->ctrl_base + SERVICES_CR_OFFSET); --=20 2.39.0 From nobody Sun Sep 14 14:29:56 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 22058C25B4E for ; Fri, 20 Jan 2023 14:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbjATOkV (ORCPT ); Fri, 20 Jan 2023 09:40:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjATOkN (ORCPT ); Fri, 20 Jan 2023 09:40:13 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCA26D05CF for ; Fri, 20 Jan 2023 06:39:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225582; x=1705761582; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1o9L/4gS6hFw7QhrPiNy1BOlai1A8GCWCQbQw2g35go=; b=N8KoVEws+IE8jm989gzVYiwvDTSE+7fVDlhRMvEbRgGPxRJBAZ0N988A 0Qj5vOtAQpC39UJjXcCdJcZJUMrOp2VuNHSNNmcxUNX98QLKH7gCNhCcT e92nA+p2d/l4TmTbYTfvaI5bDB7brPi2SCYauZZtFpD9W0ZNN5qqt6VmT +8VbyqMdYfjV6CcJs+OsckZ+m+7VBzt/M+uoGqIdzVm3cW4gmOCreQHcC jB4MFdQZsVwnSicEOM1oF/Lq362WH5clBzuV4+nOYZ7uZ+vObbc0f0ngM 2KKFfsi2tK2ouMMuh3aZmyGFfJKdTyNe+s4MEGiGMuW0XBI1ETRWTw+s8 g==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="208646900" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 07:38:13 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) 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:13 -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:12 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 2/7] mailbox: mpfs: switch to txdone_poll Date: Fri, 20 Jan 2023 14:37:30 +0000 Message-ID: <20230120143734.3438755-3-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" The system controller on PolarFire SoC has no interrupt to signify that the TX has been completed. The interrupt instead signals that a service requested by the mailbox client has succeeded. If a service fails, there will be no interrupt delivered. Switch to polling the busy register to determine whether transmission has completed. Fixes: 83d7b1560810 ("mbox: add polarfire soc system controller mailbox") Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index d37560e91116..e0e825bdbad9 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -79,6 +79,13 @@ static bool mpfs_mbox_busy(struct mpfs_mbox *mbox) return status & SCB_STATUS_BUSY_MASK; } =20 +static bool mpfs_mbox_last_tx_done(struct mbox_chan *chan) +{ + struct mpfs_mbox *mbox =3D (struct mpfs_mbox *)chan->con_priv; + + return !mpfs_mbox_busy(mbox); +} + static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data) { struct mpfs_mbox *mbox =3D (struct mpfs_mbox *)chan->con_priv; @@ -183,7 +190,6 @@ static irqreturn_t mpfs_mbox_inbox_isr(int irq, void *d= ata) =20 mpfs_mbox_rx_data(chan); =20 - mbox_chan_txdone(chan, 0); return IRQ_HANDLED; } =20 @@ -213,6 +219,7 @@ static const struct mbox_chan_ops mpfs_mbox_ops =3D { .send_data =3D mpfs_mbox_send_data, .startup =3D mpfs_mbox_startup, .shutdown =3D mpfs_mbox_shutdown, + .last_tx_done =3D mpfs_mbox_last_tx_done, }; =20 static int mpfs_mbox_probe(struct platform_device *pdev) @@ -248,7 +255,8 @@ static int mpfs_mbox_probe(struct platform_device *pdev) mbox->controller.num_chans =3D 1; mbox->controller.chans =3D mbox->chans; mbox->controller.ops =3D &mpfs_mbox_ops; - mbox->controller.txdone_irq =3D true; + mbox->controller.txdone_poll =3D true; + mbox->controller.txpoll_period =3D 10u; =20 ret =3D devm_mbox_controller_register(&pdev->dev, &mbox->controller); if (ret) { --=20 2.39.0 From nobody Sun Sep 14 14:29:56 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 3632DC25B4E for ; Fri, 20 Jan 2023 14:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbjATOkQ (ORCPT ); Fri, 20 Jan 2023 09:40:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230077AbjATOkF (ORCPT ); Fri, 20 Jan 2023 09:40:05 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B540E42BFA for ; Fri, 20 Jan 2023 06:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225569; x=1705761569; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FCOl+T+5C62VF4k5ASrJAWhazXtjeEzsINHVVaIW+hk=; b=BZGfal6b9V7vhVSLhQo9C76kBTqnV/Lh3b2O8YQ924WEB8UOF+T0+RIn hkMuRXLsl1+PCPcxjZlMpntouM3laDJpHrATZlGqGrhnaaTLpM+Q0eB6y D5XjB06rHLnfm2CsMcWKkem1B7bnpPWIQxs9iidqfrhRHXn5+lz7BlmYo v8MiEKuBrNQ0Uja9vi8oSd/YdyxViwptlTRYQhwx56r3ean4x7KWcsiOQ rmMvMDIDoFsNMIIBBAoUKNibrzvb7Pd9pMyQ7ca/IW76wBzBSXv13aBva RNTLMBfILYtd/qE68yxei4pf/kYErvt8dl0hgX0WQvU6oJaTdNn+kKJ+y Q==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="196713305" 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:14 -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:14 -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:13 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 3/7] mailbox: mpfs: ditch a useless busy check Date: Fri, 20 Jan 2023 14:37:31 +0000 Message-ID: <20230120143734.3438755-4-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" mpfs_mbox_rx_data() already checks if the system controller is busy before attempting to do anything, so drop the second check before reading any data. No functional change intended. Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index e0e825bdbad9..0d176aba3462 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -170,12 +170,10 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan) if (response->resp_status) return; =20 - if (!mpfs_mbox_busy(mbox)) { - for (i =3D 0; i < num_words; i++) { - response->resp_msg[i] =3D - readl_relaxed(mbox->mbox_base - + mbox->resp_offset + i * 0x4); - } + for (i =3D 0; i < num_words; i++) { + response->resp_msg[i] =3D + readl_relaxed(mbox->mbox_base + + mbox->resp_offset + i * 0x4); } =20 mbox_chan_received_data(chan, response); --=20 2.39.0 From nobody Sun Sep 14 14:29:56 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 B1E40C05027 for ; Fri, 20 Jan 2023 14:40:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbjATOkq (ORCPT ); Fri, 20 Jan 2023 09:40:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230332AbjATOko (ORCPT ); Fri, 20 Jan 2023 09:40:44 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBDF8457DE for ; Fri, 20 Jan 2023 06:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225614; x=1705761614; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D44+KU7ZiM3CE8om7qWz+e12D8GVZHQeVAMd689yP1o=; b=ZOJ0lZH1/VHO0NBPO/IcrpWwnF8G8LhwljM2IX08cX9K57YCi9ZBJQFc waqPXcWPLvVfSry9hmRf8qZDRrW7+foe0PbmzaRLneU6pafqXZoDIf0zN ypKnp9WhtqwyGUezGMNpmQL0S8Z/mGT7cFvMLvd7BZ+bfb5+sMWGQVdWD DveuDMccAAzl7PmB4i9QjbG++uzRj+Z/FhK5/WhfZqlNDWRKYSe+PQ4Xe ml0jk98o5mU7d+FWxfbRzrcPj7DY3+BM3i46s78+mAqgxkXASJYiBSrlO sCY30LRvDHFAXr2gGgkTCNRQPE2sX3IcRGGb+2NGs+gqcbMebU76TDgKH Q==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="208646907" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 07:38:16 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) 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:15 -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:14 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 4/7] soc: microchip: mpfs: fix some horrible alignment Date: Fri, 20 Jan 2023 14:37:32 +0000 Message-ID: <20230120143734.3438755-5-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" mpfs_sys_controller_delete() has some horrible alignment that upsets my OCD... Move the RHS of the assignment to a new line for greater satifaction. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/micr= ochip/mpfs-sys-controller.c index 6e20207b5756..12039cb38b33 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -66,8 +66,8 @@ static void rx_callback(struct mbox_client *client, void = *msg) =20 static void mpfs_sys_controller_delete(struct kref *kref) { - struct mpfs_sys_controller *sys_controller =3D container_of(kref, struct = mpfs_sys_controller, - consumers); + struct mpfs_sys_controller *sys_controller =3D + container_of(kref, struct mpfs_sys_controller, consumers); =20 mbox_free_channel(sys_controller->chan); kfree(sys_controller); --=20 2.39.0 From nobody Sun Sep 14 14:29:56 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 From nobody Sun Sep 14 14:29:56 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 8029DC27C7C for ; Fri, 20 Jan 2023 14:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbjATOlL (ORCPT ); Fri, 20 Jan 2023 09:41:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbjATOlG (ORCPT ); Fri, 20 Jan 2023 09:41:06 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C915643446 for ; Fri, 20 Jan 2023 06:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225644; x=1705761644; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ETrCqr1esSdpLl/whNaGbQbj8ly4dFAvvv640kfUFd4=; b=v+G4fhXRROkNubAj9uB8lEyZjJ5c33z2Wv5dzL2pLaNfZPQWKvooQekl vOU8Sb5JtDL+Y1/KILRUGMEteQtygXX1mhKLSY0en621bcJHPBnqBe3eZ d1sY5EfQkDC7sWzp0nkWSvYvYpxkINvswm7tEXj3viC7MTARUsq8lXeon kOAVxKJPW2QaY09Z3yzrafqeS+fZrBGDCrAO0UOq6O23gM5RpGrHTWjXo U+kLTJsFoJ/R2pORqieSVfoYolu4RIpNQJC8QeiMbPMT+YkVBA86XFodj jYQtyWHrMAdegEZMtMCHNfd5jE8turwb+v3nHn+vEZ/V2PVeJMiamJ6m2 A==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="208646938" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 07:38:25 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) 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:18 -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:17 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 6/7] soc: microchip: mpfs: simplify error handling in mpfs_blocking_transaction() Date: Fri, 20 Jan 2023 14:37:34 +0000 Message-ID: <20230120143734.3438755-7-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" The error handling has a kinda weird nested-if setup that is not really adding anything. Switch it to more of an early return arrangement as a predatory step for adding different handing for timeouts and failed services. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 28 ++++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/micr= ochip/mpfs-sys-controller.c index e76a5e38f655..da9cfeda6f78 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -36,28 +36,26 @@ struct mpfs_sys_controller { 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; + int ret; =20 - err =3D mutex_lock_interruptible(&transaction_lock); - if (err) - return err; + ret =3D mutex_lock_interruptible(&transaction_lock); + if (ret) + return ret; =20 reinit_completion(&sys_controller->c); =20 ret =3D mbox_send_message(sys_controller->chan, msg); - if (ret >=3D 0) { - if (wait_for_completion_timeout(&sys_controller->c, timeout)) { - ret =3D 0; - } else { - ret =3D -ETIMEDOUT; - dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); - } - } else { - dev_err(sys_controller->client.dev, - "mpfs sys controller transaction returned %d\n", ret); + if (ret < 0) + goto out; + + ret =3D 0; /* mbox_send_message returns positive integers on success */ + if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { + ret =3D -ETIMEDOUT; + dev_warn(sys_controller->client.dev, + "MPFS sys controller transaction timeout\n"); } =20 +out: mutex_unlock(&transaction_lock); =20 return ret; --=20 2.39.0 From nobody Sun Sep 14 14:29:56 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 E5E6AC05027 for ; Fri, 20 Jan 2023 14:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbjATOkg (ORCPT ); Fri, 20 Jan 2023 09:40:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230352AbjATOke (ORCPT ); Fri, 20 Jan 2023 09:40:34 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178002A14C for ; Fri, 20 Jan 2023 06:40:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225605; x=1705761605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oYx+ncPt3aXXBAx6eIW+t/dOXcIk5sAoEFiHLkKETcY=; b=zQaHWIH9n/1VWrZ95QPeUIsJ1l80G2GhUyXIRB+aSirK7CDFEf9XVpTq eyBTqPLx6Zq/9tAtgcjHfu5cHXMCzbzvvVm6cB/JH5XqYbmPpJoO/bNlK EeS3K8uPqJaL7Tt2aBm370+EbEQCB8cRswaNDpFwFstxl7asvbdr6IHpH vhzn/DYin6dFqjM7TFI/SzbMoECKVOeJbFZGn3iPr4fx1bwJ5C7W6uno8 Xj/i3OOO11Z3VOqswHrzAHR5h9pci5ySP/XDlh57g8l2Ptd+jkauwuVmi Awb3D0ZWfXfB1nzr8Fl2WS/OAGfiTFecmr+HuU0gkNAuA54ZwRVgzl8Xf A==; X-IronPort-AV: E=Sophos;i="5.97,232,1669100400"; d="scan'208";a="197471546" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jan 2023 07:38:22 -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:19 -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:18 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v2 7/7] soc: microchip: mpfs: handle timeouts and failed services differently Date: Fri, 20 Jan 2023 14:37:35 +0000 Message-ID: <20230120143734.3438755-8-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" 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/micr= ochip/mpfs-sys-controller.c index da9cfeda6f78..2dd100ab21b1 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -45,14 +45,25 @@ int mpfs_blocking_transaction(struct mpfs_sys_controlle= r *sys_controller, struct reinit_completion(&sys_controller->c); =20 ret =3D 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; + } =20 ret =3D 0; /* mbox_send_message returns positive 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 =3D -ETIMEDOUT; + ret =3D -EBADMSG; dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); + "MPFS sys controller service failed\n"); } =20 out: @@ -110,6 +121,7 @@ static int mpfs_sys_controller_probe(struct platform_de= vice *pdev) sys_controller->client.dev =3D dev; sys_controller->client.rx_callback =3D rx_callback; sys_controller->client.tx_block =3D 1U; + sys_controller->client.tx_tout =3D msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT= _MS); =20 sys_controller->chan =3D mbox_request_channel(&sys_controller->client, 0); if (IS_ERR(sys_controller->chan)) { --=20 2.39.0