From patchwork Wed Jan 11 13:45:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13096686 X-Patchwork-Delegate: mail@conchuod.ie 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 29884C5479D for ; Wed, 11 Jan 2023 13:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i3SWwquVUhJqq+BDHQijg9ohtosjxcI2yXLrDZgkWhA=; b=jZtBvOfg/VO1gH ceZB4l2Op/eW+m273cJ+/NPwqaDQqsgeZ8zTkSrWLozT6bcUoeYpQBFdJkWJc2nHq4bU74asj77l0 uj63o29UcAlJSAQA91zW73pKrnSTNHkG0PAcrW9s6zy0izEWkzNEOdlVCdxxiTiKXv5d0KNCZS9oF +rA5UnJb6G9gYjvLgN+cp7NJC/ujVrvyK+DSBrSQpHcpj/+7Ej8/R3bHcVs+oKuGUWBy/lDvuabqS /1YK+M4m0AjhRECkxrfkHJEwS3vaG648pBA00875eXhUE8BRI/SuRh7savDMW7dlYfsvQ8p+F8LHb Gfu4Bixt1ibRQTBve9fA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQV-00Bere-EL; Wed, 11 Jan 2023 13:45:59 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQQ-00Beof-BT for linux-riscv@lists.infradead.org; Wed, 11 Jan 2023 13:45:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444754; x=1704980754; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wIqkIRLk97mVy76bXMdNE/RNNtTIHIYTZDRNoDes7MQ=; b=DAFge+a9tN9ypsiMKvJ9BRIcwsn8cBRSIozlUcvMEHJeprwGWuNaVwmn 3W+tsqPBbed/UDlLFUjYbv7OcSKhuNbI4vRimNfoxElrv0MxTVlqFvI27 QBYqj/r5B0yjgBVrggRBCXJuHaxQH1zquotM5iC/z/76fDm1eGlamjUy2 i+flIEAAFZUCuEe3u+ovOeFdIKDJKnqqzLyQXte4xz9UswrjeXFEbIXCc Rgwh6IeR+SHocpNlXa1V2yLoyUvOI57fD7GmhedAS6YT2ytRKVWf5mpQD wbHer0GZYoa9LSYFJjLfcnnTnspFUNso4ka+bDGpl8WJn733+9inMfKVH A==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="196212592" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Jan 2023 06:45:49 -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:49 -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:48 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 1/7] mailbox: mpfs: fix an incorrect mask width Date: Wed, 11 Jan 2023 13:45:07 +0000 Message-ID: <20230111134513.2495510-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_054554_587394_424FB2CC X-CRM114-Status: GOOD ( 10.73 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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) #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) /* SCBCTRL service status register */ @@ -118,6 +118,7 @@ static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data) } opt_sel = ((msg->mbox_offset << 7u) | (msg->cmd_opcode & 0x7fu)); + tx_trigger = (opt_sel << SCB_CTRL_POS) & SCB_CTRL_MASK; tx_trigger |= SCB_CTRL_REQ_MASK | SCB_STATUS_NOTIFY_MASK; writel_relaxed(tx_trigger, mbox->ctrl_base + SERVICES_CR_OFFSET); From patchwork Wed Jan 11 13:45:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13096690 X-Patchwork-Delegate: mail@conchuod.ie 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 9F6E0C54EBC for ; Wed, 11 Jan 2023 13:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KSarQS/f87cii62U80hE1elGsd/Gykw95KzwHArrXFs=; b=dxozxqUYLYA2oe Clu06ahRiRjZL3mxP1OdDz3pSqvdyhnfVQoXF7Tp5XPWllf1XISEaCuBF6mXVYDNr6j5BObrexw8V 6R6sBL7qJqo3g2E/5lHiG5hxUgM26DCInqBmX+T1jdxPhJb4QYFSfKjdX0h4XsQPSGt8HP1TVQM6g JqrrrNhzkL7IvXRB2KOuFDomPUApoQS3w4m28TjKKED3apzgLKYVkK6hMBcuQTLM7j0yORzS7VLYO atiUGni1DgkbNTTcW7+mjTRIilD2ru9jOyiFziwChvoiwRuyTbIPZhKubsPZAhB8/6e+hzZLpJTe1 ENcV0Dmr16plKLO25hWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQb-00Beum-Q8; Wed, 11 Jan 2023 13:46:05 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQY-00Bera-Mi for linux-riscv@lists.infradead.org; Wed, 11 Jan 2023 13:46:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444762; x=1704980762; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1o9L/4gS6hFw7QhrPiNy1BOlai1A8GCWCQbQw2g35go=; b=MfduGl2CZlOsKV8rmVmL9KSavSUP+GQLKXi9TLR9YPFtHD1T30TR748E T4Y/lepU6fT1TKpInXsXWpRE0byb5Sod/HFiLEJtFhqjGwGuQMm3uaxTA ITGNW3kMhtPNsRMsHnlUFhk+tM4KbJkrnx6tIu772bjyrJrCi7p/vYkA0 uaZUmSWVMedUB7nysEzYJ6nELuQRTcvlPmTTN7Hb6gkSagv7xRqOq2MJt 4XzTIWqzBitbEOdGYJk5GpinL77AE3CIu/M0nLlLuS5oBB2e8u0NiSKbj 0eQs7InboevhI3xtroE4z3Cqh6ExkP2CIDOrVDf+UGMeV/8aXEa/qt1kO A==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="131834648" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Jan 2023 06:45:54 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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; Wed, 11 Jan 2023 06:45:50 -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:49 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 2/7] mailbox: mpfs: switch to txdone_poll Date: Wed, 11 Jan 2023 13:45:08 +0000 Message-ID: <20230111134513.2495510-3-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_054602_822575_4A7262CB X-CRM114-Status: GOOD ( 11.33 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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; } +static bool mpfs_mbox_last_tx_done(struct mbox_chan *chan) +{ + struct mpfs_mbox *mbox = (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 = (struct mpfs_mbox *)chan->con_priv; @@ -183,7 +190,6 @@ static irqreturn_t mpfs_mbox_inbox_isr(int irq, void *data) mpfs_mbox_rx_data(chan); - mbox_chan_txdone(chan, 0); return IRQ_HANDLED; } @@ -213,6 +219,7 @@ static const struct mbox_chan_ops mpfs_mbox_ops = { .send_data = mpfs_mbox_send_data, .startup = mpfs_mbox_startup, .shutdown = mpfs_mbox_shutdown, + .last_tx_done = mpfs_mbox_last_tx_done, }; 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 = 1; mbox->controller.chans = mbox->chans; mbox->controller.ops = &mpfs_mbox_ops; - mbox->controller.txdone_irq = true; + mbox->controller.txdone_poll = true; + mbox->controller.txpoll_period = 10u; ret = devm_mbox_controller_register(&pdev->dev, &mbox->controller); if (ret) { From patchwork Wed Jan 11 13:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13096691 X-Patchwork-Delegate: mail@conchuod.ie 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 B702EC46467 for ; Wed, 11 Jan 2023 13:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i5XOrYsIltK1sKwQ2T3i1/1UoFNv/8sadn6pC+IPJCg=; b=K+679C9SfuMKAO 9e2U+RS3tWDRIc/EP3zSXmGwzfoiqgIp3ECMEkfdG9QjeFFKFx5gwzcgExf7Szyl2wU1R1NqJl5KI UgGe8WGT3E6y7ZdX9wxcKHyj2iHgTGH3ZgOVvWGDiKl6QXob6khD2YNNnmRQGgSCM4cizTYJ+4VaG H/A0oPbtZCilnLj5w32lY1GAWClJJpbg0YTHWCukxBhASZCf6bIeoqi19U1ML1r+VnXTEqe9rVm1B txQjp3bI+43nPRNFniXAjqVnwnwt2tbXUHu95DuiSmTmV9QiKlEX+/sgXH3WOf3GPFY09ChEU3BI0 6HqJlJRaUYMY4LQhbQsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQe-00BewP-D3; Wed, 11 Jan 2023 13:46:08 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQa-00Bera-NV for linux-riscv@lists.infradead.org; Wed, 11 Jan 2023 13:46:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444764; x=1704980764; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FCOl+T+5C62VF4k5ASrJAWhazXtjeEzsINHVVaIW+hk=; b=SbY4ZurLO4zbPdedNmdvBCcVsPyGoqrsZR9NnL3XbEXEiUc3sQ/n8YP7 0fdc8VgZUlAPwcUQDygLnRKkcfJkvhq9pBK4W92O7h85sDj1B+jDlcMFd jwT4er7YKLaRAVAn7BNwS0WRbfboyl4J+Vho0+7/0rx9SthO0Br9XXWyw mMOuyAIS5GalzKQFDt9TVTieA8TvVOBuk0rq78G0TMtP7Lv6h/sNxeTqM 21LA146/DJIdPzWp1/aKJIEVnHRK0Le2/03eUGJdpzn6qEB26IlBymlkJ IlIdGE9jd7lRMxweSdvsvKzlq9dMTGSOu00rpt2i7XeiZQRcXA98/24/X Q==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="131834650" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Jan 2023 06:45:54 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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; Wed, 11 Jan 2023 06:45:52 -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:51 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 3/7] mailbox: mpfs: ditch a useless busy check Date: Wed, 11 Jan 2023 13:45:09 +0000 Message-ID: <20230111134513.2495510-4-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_054604_846792_006D8AA8 X-CRM114-Status: GOOD ( 10.13 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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; - if (!mpfs_mbox_busy(mbox)) { - for (i = 0; i < num_words; i++) { - response->resp_msg[i] = - readl_relaxed(mbox->mbox_base - + mbox->resp_offset + i * 0x4); - } + for (i = 0; i < num_words; i++) { + response->resp_msg[i] = + readl_relaxed(mbox->mbox_base + + mbox->resp_offset + i * 0x4); } mbox_chan_received_data(chan, response); From patchwork Wed Jan 11 13:45:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13096697 X-Patchwork-Delegate: mail@conchuod.ie 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 9912DC5479D for ; Wed, 11 Jan 2023 13:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J3X2TD8KPKq9DNBw1R+LLXslWk/KoBWF+RWAfgT+IYE=; b=V1LFvX4/70GCt1 EifxaCW27ZXcRhawGRcWSjDxu45M542si9wX48ZZBTst5dHYN+4qpB+N1C6GNhYCRTA77iX26SDAU N8I1aCoTB0wWr63Hr3CrpkMeFxdQ67eqlrX+KFmSjmsJ7mEWSLD/r+khSs1bZPs2ojrjI5BrI67v0 Xh7wUYZmZt9rflq8bXA9qlZDd7mVX0fgdtdwFbfk9D2zmgaVwS3PHY3joDxHsfcAgGB4vbu0bGocD AG01UT1mJ8kAtJGFWff7LnVAgcMCZizfDiJg6DXhK/a9K65uPq5mcEXqoYgz55JBZpincwezWR45V Y3pFgmeg/F4i5VNQ+sig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQf-00BexN-Ol; Wed, 11 Jan 2023 13:46:09 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQa-00Beu9-VC for linux-riscv@lists.infradead.org; Wed, 11 Jan 2023 13:46:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444764; x=1704980764; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D44+KU7ZiM3CE8om7qWz+e12D8GVZHQeVAMd689yP1o=; b=RFHsWiBdVrCyjBWuonZxAvAbjb0OCofdIajISmCWTEkv0AgElBJ6HJHT fmEHVsT6ZNIVR5l7Zf3gfA+lYWP8rTm61NUWTrJrFURMcoehJebQo6w0A 6hb4V5BzBrtWYvDlfqa5Jcd9gn/SoOqq0Zd/4ZhcctqRwNlEGDVt4SQX3 lbpoBZFY38kx+7g9iYgrGqz7h9JU5pvRtmaIZQrajeNj6+WNgPt5AGoE+ QzpgRivdnt4nZ4uQLfLMWQGYWdUnPuApCdBVeFJ3WTdKy9+MBzJGFLjlm xM60CGxoOXdi56R1qNIPBJr0Orl4yapkidwGmjWMRAsCULauLnI4mD3sj A==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="131834651" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Jan 2023 06:45:55 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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; Wed, 11 Jan 2023 06:45:53 -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:52 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 4/7] soc: microchip: mpfs: fix some horrible alignment Date: Wed, 11 Jan 2023 13:45:10 +0000 Message-ID: <20230111134513.2495510-5-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_054605_082522_51A29D59 X-CRM114-Status: GOOD ( 10.21 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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/microchip/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) static void mpfs_sys_controller_delete(struct kref *kref) { - struct mpfs_sys_controller *sys_controller = container_of(kref, struct mpfs_sys_controller, - consumers); + struct mpfs_sys_controller *sys_controller = + container_of(kref, struct mpfs_sys_controller, consumers); mbox_free_channel(sys_controller->chan); kfree(sys_controller); From patchwork Wed Jan 11 13:45:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13096688 X-Patchwork-Delegate: mail@conchuod.ie 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 46FF8C46467 for ; Wed, 11 Jan 2023 13:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ni5OiWVtUIrx12zZ27WqTlfLvp+lCUrZtLgYS+aBnFM=; b=KM9HpHKf/ejC0h KUsNLamLfCF6PzByA+Hmi7jqEhnaMV/aUjsAFSa0q32zvdGm3wrzz3CTapoN2MYdLN6aLojCbsFId BFuZ/MQISl2v2SmXya1rjxRPp3iDuzMyav9Uq8e0PiZx5DNCPOBsN+9TiB52YwwhaHZRARp642Zky BDETMvWIKmqepDhi51QfqlsNGvtpD96bjNvf7HGQwQ7WN4Ii6fiUqof0tAGXDWotyJW/d0U19/0cg E3wFjrgBVuUMYPomayZ84KMIgi+4GPn9pjT+bg/dUxINNViBT3mgbnvBbE288lO/zCxIclSDB4kA6 suhG1RkPcZyDkO9Bzhag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQZ-00BetH-3A; Wed, 11 Jan 2023 13:46:03 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQS-00BeqO-3q for linux-riscv@lists.infradead.org; Wed, 11 Jan 2023 13:45:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444756; x=1704980756; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YmvtEgsExmKnHFKrtsTC1qEk3keDAXMIHIB9CsFESV4=; b=zKZszEXdZklD1KO8d4uYwczISh562yVjFFauMdwKdOboYkFJp/VIqFzJ eWO6m6ngO3GWGPIR9ZLzS0mEZIaMielxhiorITJtW8nR79hbqBKP+4sCe RUNArZQrVzBFLKGqxlZy5C75K+p8yHHIwQxaZGYotuHfxfACVHUBD95cM JTr+cmGmZUxE9f5QKPa80k9UTN9VNWfxJlkFJo+sb0HFG6Jf/0kvtzTXf WwJZ7bDn8bX+vQmmUdS3KaoPU+JyONq1OgnIeXL6ZsYe5DLl0O+0Ng5az g+mfPfbFztQXoq6KFvTYKPx4O5eTBxnwr1bA+WHwe8tMwFSq0dk8ntsuS Q==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="207325803" 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:55 -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:55 -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:54 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 5/7] soc: microchip: mpfs: use a consistent completion timeout Date: Wed, 11 Jan 2023 13:45:11 +0000 Message-ID: <20230111134513.2495510-6-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_054556_184481_196903BC X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index 12039cb38b33..738ecd624d64 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -11,12 +11,15 @@ #include #include #include +#include #include #include #include #include #include +#define MPFS_SYS_CTRL_TIMEOUT_MS 100 + static DEFINE_MUTEX(transaction_lock); struct mpfs_sys_controller { @@ -28,6 +31,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 +42,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; From patchwork Wed Jan 11 13:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13096698 X-Patchwork-Delegate: mail@conchuod.ie 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 33788C54EBC for ; Wed, 11 Jan 2023 13:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vvr+Nbin1rcqH9KszwgFrXPntzBvP8TOlRUNUTMJYUQ=; b=U/Mr81AmJgObue rgfto+dZRuJwlvrBXAxBL0dM0sFB3qXCWRaJAAW+ZMZLHWqM/lf5NQeEfmCtkxM9mcJWIS3Re9wwf fGJKr7OsnJ/4gQenyXaqZj/ckLNuwo8rPcgwwjURVPk1w1cJ6WhIyxNoLzOaj//LS+XldAGYUscI1 bCj5IC4kEN/Tw6ftN5IPHFNBWajUBP55Q6bFfbO7Y1pyH31yKvGXy8q9iLZJrlsSNpLs1vW6QbOLb kRPdmYLPGly926gWc4VBbujWoi/mmqaqEpVRXMN3ndEztbZDy9dXgBiG3S7XxLe6BjkvhPDrn5lSq WLNe9hrkeNL/nqFGRtVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQh-00BeyR-En; Wed, 11 Jan 2023 13:46:11 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQc-00Bera-2r for linux-riscv@lists.infradead.org; Wed, 11 Jan 2023 13:46:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444766; x=1704980766; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dqNf1ACM7VOxiqPM+Nc/J8oy1t3x6F1UdtTIb0rpr7I=; b=HsBK4H+lV8KXwBFy01ER/um9sBONdC890Z+wWNMHvnTkggwsxn5R04fY NTe7eclokUQPFCLH1IjuMMBILfe7LfGINaK2CliihwosBi86vmUT1Kqq/ alRYco5Ny+V9l9Z4O84vVAO1vVx3/sXH3fjDVxQqgBux7dTUW/RW6oFva TEtAJk35xJaHJicFSJaUT4l4mymUOQEtbeEEUoSs4BFKrgEcvKgWzLtbQ BGgOUodsfSEmhbQ+z5+0Ab69lL3J7I49Fr5641OzqQUNPXNlAMoM5Ip2Q c1wX7how6tHuSNxJWz9c4qqhXQ1D5v4tGMZazKu9YXJv9tf6+Fzp//xTM g==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="131834669" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Jan 2023 06:45:56 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) 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; Wed, 11 Jan 2023 06:45:56 -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:55 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 6/7] soc: microchip: mpfs: simplify error handling in mpfs_blocking_transaction() Date: Wed, 11 Jan 2023 13:45:12 +0000 Message-ID: <20230111134513.2495510-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_054606_222437_47E2D4B7 X-CRM114-Status: GOOD ( 11.89 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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/microchip/mpfs-sys-controller.c index 738ecd624d64..4aadd05769d2 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -32,28 +32,26 @@ 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; + int ret; - err = mutex_lock_interruptible(&transaction_lock); - if (err) - return err; + ret = mutex_lock_interruptible(&transaction_lock); + if (ret) + return ret; reinit_completion(&sys_controller->c); ret = mbox_send_message(sys_controller->chan, msg); - if (ret >= 0) { - if (wait_for_completion_timeout(&sys_controller->c, timeout)) { - ret = 0; - } else { - ret = -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 = 0; /* mbox_send_message returns postitive integers on success */ + if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { + ret = -ETIMEDOUT; + dev_warn(sys_controller->client.dev, + "MPFS sys controller transaction timeout\n"); } +out: mutex_unlock(&transaction_lock); return ret; From patchwork Wed Jan 11 13:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13096689 X-Patchwork-Delegate: mail@conchuod.ie 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 C2376C5479D for ; Wed, 11 Jan 2023 13:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4f39+qnj6OkHAsM+YZgNAtnpeQQybeWlBaPe5JrV8VE=; b=RbcR/IByU6E1dF uPvi0yzEveT5EW6cRR+L1OF7Et1vUSbbnT612hJVNNmEzj7rGJvFOzeFnhXhngpPf2r3fnX7cCBet /wdjgW1wwK8UqdyQyLmuPlszh3aRo3LOMU7QAIkznjS5Iv+KGzMCqWMiqutP6qCQPGmBIb9cVIoPx houB8H0RIa7KAUSTxDh9//B/UvATIiPC+KIehsmcYTiuFQaUXonnwLX5r+A44da9dgG8dwRb3oy2b fNLvdQlpMxZDK4PR2S0NGIzFlrO61ZUCFAP4jbSIwm56z9P4x+lqixvbDOBltHkS4qS31BYtNdCmX 5Rl0sNsV4XPmSQy8ig8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQa-00Betl-D2; Wed, 11 Jan 2023 13:46:04 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbQU-00BerD-FI for linux-riscv@lists.infradead.org; Wed, 11 Jan 2023 13:45:59 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_054558_564752_56DDC7F3 X-CRM114-Status: GOOD ( 15.78 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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)) {