From patchwork Tue Mar 7 20:22:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164684 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 F0D59C6FA99 for ; Tue, 7 Mar 2023 20:23:38 +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=dxhxjn8WRK8Kz6GJqPKfUsUWORbuE9BcreeyL0I8m7k=; b=PEBm/RzD7kSEdH vdT1nFJfbHDtAI3R+dqJQA0as1Pu9upRyN/d5cobrTcJ3SL55+CZRffB3VxzT8A1RIT9C+aaGSGKX 3BkKl8URHDnKiKco5G19dyUdorTvLSTPCtbnZCS8WKkg/6BxA4isuXPxzxfJWY8SbbJ7RpTwNbCr3 PB4j4G+weEtNJHGcl/brBY7vrctAZS6UuY/6p4UJ39uKb81p1as4BancvJpyixLNQBzRGOPiTgMAd 9TdeDFegt1vrpi0UJ52+9UTiY2Kx+TqmIAlqZYmgCNkPdNLDg4XQbrmEVKgASYGS0FlDmB5TlIGQO +PGo5dqiGAxhUmEhuzag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqN-002MNR-Ql; Tue, 07 Mar 2023 20:23:31 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqJ-002MLP-DU for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:28 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4A6EE61522; Tue, 7 Mar 2023 20:23:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EDA2C433A1; Tue, 7 Mar 2023 20:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220605; bh=x+8F7ELtsW/BQB3u+HCi4ETUUZR7Hhz1aXJMSp6UPQU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZtZSFRIoN3Dk9IaS71f+Vi0gbcEz/eCmHEBigAl8IcconSATVF61MN1GhhQwkCitD jAY7f2olbsMcii5YlQxr0YWpqHPD4jS8CFiFI7mnCRkDIh4GzVGOR+BatsULKGv8mA 4Wc9BKdAy1ecelH2XuJoO9v8cNesJSTEa9Bf2MeeOuSBdsZdZUVKjtJ7ed1HzRHX0Q Q1g5o4gHW6LZpwsZQjAPwS5k9KWTMWndaYBkaU2i8p6hUbp+xxyPzp1mnTl3qgADlM 49SwhSxnJUtPSOJmUpUna9vm2yoeTzv/n/K+YsOKZ3FxQhQXQy5Smzy94n1owWRP1D MdgXM/P2+3opw== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 1/8] mailbox: mpfs: fix an incorrect mask width Date: Tue, 7 Mar 2023 20:22:51 +0000 Message-Id: <20230307202257.1762151-2-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1509; i=conor.dooley@microchip.com; h=from:subject; bh=N+Fmo03qeVhPTJ2ouN+nX4YhvmUTQ6mGrE0sJhfEG04=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4XOqS91dHS5c+zaHbc75y70ZwR90D7jPWPBYbuAJ f0ua98ZdZSyMIhxMMiKKbIk3u5rkVr/x2WHc89bmDmsTCBDGLg4BWAiH28w/LP80GRfqdDw5M7R GT++qmY5eUXd2nfWRmRK1uO5qVqizCUM/1Nzv7fZZxQuf6hqa2HZ0rDrf+Tyu5xXzqeo6vq357z 7zgEA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122327_541207_75FFE636 X-CRM114-Status: GOOD ( 12.91 ) 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 From: Conor Dooley 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 Tue Mar 7 20:22:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164686 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 0F6A8C74A44 for ; Tue, 7 Mar 2023 20:23:40 +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=c6tBKt1zu1ySsn3GaeeYzGuGUu/VT9Q3tnRdvD8/Dps=; b=epkDIMFoHvi3rX LnAyNi717BHGGh9ssau68MFH0DsbPTm1MKBS9hdM5R/IN/iQHgJqhq+A/Y1TngzDG4FEhPGAUtYVv Nguq1BS1P8ZXDmtF1v0cVjM9HwOj4c5AKYgMok8i3AbTKFlM/UI6l9UrHxRDatZTD9ftFAUvDOzJO X/GHrZ2WRBVFhRVjL8rRWZw8vnJvwi+TqaoyySaFspN73za3hNm6+VZHBpgAkRyd4wS5N8t498Gg/ S48aBM9O/OH0omtoABYofwckELqvjir85Z16oKqpiwKWXmjibhU09tvY+ii80FPnXn7Y399K6VuOA B289kJEOJElFHiLJ/oaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqO-002MNr-T8; Tue, 07 Mar 2023 20:23:32 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqM-002MMa-4S for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:31 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CA4E0B81A1F; Tue, 7 Mar 2023 20:23:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28EA2C4339E; Tue, 7 Mar 2023 20:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220607; bh=sx9Ska8GnWbf3HJSlVgv4lIynyLqn9kogPDu8a552jI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HATc+3nZBgpYA7WxgcsLrrwNmWlMvHUUg0l8blmDSDPZMlvnW+Td0ZVFQJk+Bj0k8 AhHpJZw7SDYavoRNPxGJEiXx+j2kTT3jMLN3kz1APKIcIwmEQ9lwbmmckGaJ9NnXk7 ABwuO8G502gOeWuFDtWt12zFs0qMFc+HVEaQ107uRW1AOzg4IF5t3+gL/iVvi+yZ3N N9UOknTK1+HpIcBick8jlK4gP49QeYT5vE28RkRbNYrhtLTw8iMQzhgebFwB+EX8W1 8HTVZbDsAX1Y1SsBd9CSIL1lQ2eab++Y404P4Sy8rHmwYRYL4bRWx0dvr7YVOcGsQT a8I8o8pzvnZLg== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 2/8] mailbox: mpfs: switch to txdone_poll Date: Tue, 7 Mar 2023 20:22:52 +0000 Message-Id: <20230307202257.1762151-3-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2089; i=conor.dooley@microchip.com; h=from:subject; bh=pqrvE31Z8S43X6j0wjeGX8SFR94cn2rhVr8RYJQR2+M=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4W2PxUvdBePK1wZ+ubiL2b7mqTsytN3p0iYqvNO9 Nx92Seoo5SFQYyDQVZMkSXxdl+L1Po/Ljuce97CzGFlAhnCwMUpABOZO4PhD5/qMzbTpXzH10w1 ratfY/Lr+atDlznLH8XkX5vhMSH/XibDH/5tjKUzDJ6e4N7QmMFyxMvcIC/sVNUxj1Mrei6kqGi ZcwMA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122330_480118_7C4F6647 X-CRM114-Status: GOOD ( 13.54 ) 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 From: Conor Dooley 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 Tue Mar 7 20:22:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164685 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 A65F3C742A7 for ; Tue, 7 Mar 2023 20:23:40 +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=x1t7rKv4asGKQzlGZEDVXAMFHIm1E+xY+LnB2LcplqM=; b=sPbCqlVrvsG3AS LA83sMkoNcAmisn7zDWbi8bxA0/wXhpiAFoJHnpfMMSGoEloyfqhqMTgKlb07QjeIGjVGLSY7koKo /q6GCoJZEoXnEgb6q53EIcnPGb9H3mCul58efkjXf3FrwgWPCZImXjjFKw/AfYJtUc9YmZUHtUcay +gTJ9B2OWPBLWwjC7RuDRuYX3i8H8X96619aFxGySfkPQWa4kcBu4BtOCfJAupsxZdnBFPdbSTKTb 5o9YqydX20BK1/oXpcPQTj4GADt/90hZWlmj2MdMgr59TSXfxrLoEovrVSid2yAq5y/22Z+Bux3pA 2ow+pgcKi9GshfkDJUCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqP-002MOF-UH; Tue, 07 Mar 2023 20:23:33 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqM-002MMe-G5 for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:31 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D594B61522; Tue, 7 Mar 2023 20:23:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8914C433EF; Tue, 7 Mar 2023 20:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220609; bh=VALLXa4RfjgD9/IaizhQxdY6y9Xca49NdnfoOQ47Y+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nBr9Ztu2PNBF/a1Vij6drPfXyPlA06m7KIJsTbnWXbmOq+UrBScPikzMRIZw3qhfp AQ7rSrhZ1Q8/8FoV0Sw18GSufFJrL0ZKlGVCOQTaOvMwnqqMlvxGfqMyZCcvDQvWWZ YxG9Sp7BixBDAh7MKV8wKP2JNLlxaka50790bIIzqHd9ADjfyC64PUaMtDqnDDMxRq 8UgUatZ7Uzy7BsSFOgXE8PMIJFum2eTkPCIEFs9Wt0jhGuTQJja6QzBKRaR5DfwpJQ cGGi2Ot2fBbXfTXhaQhQyWzlSkzNMSN1Ac54XMdB6Eg+ZFPz7p4lR6kBYnZl7as9Fj 5rguI7kVgEwAg== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 3/8] mailbox: mpfs: ditch a useless busy check Date: Tue, 7 Mar 2023 20:22:53 +0000 Message-Id: <20230307202257.1762151-4-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1067; i=conor.dooley@microchip.com; h=from:subject; bh=3TqNg+2iuqTO/EgEaud+uW5LomESwP/fUE4ltR1iLac=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4WyHSY+Wt4RdWbzMT3OCQZ3EuTZs1ns6pn2xYSzr Dzu81iko5SFQYyDQVZMkSXxdl+L1Po/Ljuce97CzGFlAhnCwMUpABOpOsXwP9CY27mex73y3I6j TUdyE4v9GizYw29b9p/yP7F4AvvzdIZ/pkfbvrwXYU14Eihi9rE0IStHwWDL4+zprzc8Yfkj2Li cDQA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122330_596840_F0FF4BAE X-CRM114-Status: GOOD ( 12.03 ) 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 From: Conor Dooley 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 Tue Mar 7 20:22:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164687 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 CBF4CC678D5 for ; Tue, 7 Mar 2023 20:23:43 +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=YFdxDKpNHuc2J4hhQXBBsaejK9lXgHNht7sOD5xW2x0=; b=DqXl/CniVTyAMm uqAWH3HuX97m+WOeC3T7ivJmkEtiT8L75a/bvBhw+d692J3egBPEQCp/+G6Dw3Rg8SGyrhgCiR6dy MvaJ/Ep73WUlBDZ8g+zJkbvgRXql5cH9tkqCbrtfY4xVxNpGR6KTnuCGyx+bQBveht/YF5lvGNKf2 tg0O46g9GXjksIZ/iWmYUiBPsC4+nwI8A9BAWtNay8w5DGu0t5kPAIOHy6DABx4pSOchc3I3PgFKc puC6uY8oSUA5Si0Uo9WHxS34up2qLKJ75zhd7qOAn4ylsBK5fUnm5IPqVOFqUJfU2CgmvavoHM2Fo lw2oMgByG4E7PS+OdzZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqT-002MPf-1c; Tue, 07 Mar 2023 20:23:37 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqP-002MNn-If for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:35 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4497CB819C2; Tue, 7 Mar 2023 20:23:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B422EC433D2; Tue, 7 Mar 2023 20:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220611; bh=5GC6Xd8kpVJdJrXJgNpGEg8xE8m+vrwYddohfQEV6Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s8ZS4K0ejWbpsXZLRFRCKxmQ4WAZftHhv/K8zgGPeaJuMpuztgTiJw8nyaN7wEbo9 b8yi6Noir/ArspesdwUwYwnwsn0iNEnipMHaiY7aYiZWl6SaDcRUpAsttm+sDldcTJ 7gxhAcL/IdcAepI7KG0cweAjz+G419EuPn8veTX5/nv4WKQ9Pz01IELiovaFxvc6gz 1ZC13+KdGdRfChpLFuaGmcoIVMdcnPug/1cGh1pEaTGMkHNw5t/diZz3/NxmuWiYx4 LE7kJ1HK6LPgFb9tEwR8oVzzLmz0zko9yE+ilV60x9Hy4G5xUSrCHogoFoVCVAJkwb ZdygT8mW5720w== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 4/8] mailbox: mpfs: check the service status in .tx_done() Date: Tue, 7 Mar 2023 20:22:54 +0000 Message-Id: <20230307202257.1762151-5-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3704; i=conor.dooley@microchip.com; h=from:subject; bh=qPU3Aj/HVaUNRSs2BviPXZLOR6A20/dd47WYx9ii+Hk=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4WsnV7lmz3Z8qttYi3bP3XuCReyg5iXFPH9tbb74 BNjwmjUUcrCIMbBICumyJJ4u69Fav0flx3OPW9h5rAygQxh4OIUgInMDGRk+HpWR2X74pMnHu5d dSd6XrZM2Pn3dw7kWy5l6OaYqjjfdTfDP4u6W+tETlXGL+TTa3rusV+7xc0hZ93cBd9/ZHjtXB/ 6mB0A X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122333_934376_C0CF3F5E X-CRM114-Status: GOOD ( 24.08 ) 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 From: Conor Dooley Services are supposed to generate an interrupt once completed, whether or not they have do so successfully. What appears to be a bug in the system controller means that interrupts are only generated for *successful* services. Currently, the status of a service is only checked in the mpfs_mbox_rx_data() once an interrupt is received. As it turns out, this is not really helpful where the potentially buggy behaviour is present, as we'll only see the status for successes where it is moot anyway. Jassi suggested moving the check to the .tx_done() callback instead. This makes sense, as the busy bit that tx_done() is polling will be lowered on completion, regardless of whether the service passed or failed. That allows us to check the status bits for all services, whether they generate an interrupt or not & pass something more informative than -EBADMSG back to the drivers implementing individual services. Suggested-by: Jassi Brar Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index 0d176aba3462..162df49654fb 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -82,8 +82,22 @@ static bool mpfs_mbox_busy(struct mpfs_mbox *mbox) static bool mpfs_mbox_last_tx_done(struct mbox_chan *chan) { struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; + struct mpfs_mss_response *response = mbox->response; + u32 val; + + if (mpfs_mbox_busy(mbox)) + return false; + + /* + * The service status is stored in bits 31:16 of the SERVICES_SR + * register & is only valid when the system controller is not busy. + * Failed services are intended to generated interrupts, but in reality + * this does not happen, so the status must be checked here. + */ + val = readl_relaxed(mbox->ctrl_base + SERVICES_SR_OFFSET); + response->resp_status = (val & SCB_STATUS_MASK) >> SCB_STATUS_POS; - return !mpfs_mbox_busy(mbox); + return true; } static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data) @@ -138,7 +152,7 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan) struct mpfs_mbox *mbox = (struct mpfs_mbox *)chan->con_priv; struct mpfs_mss_response *response = mbox->response; u16 num_words = ALIGN((response->resp_size), (4)) / 4U; - u32 i, status; + u32 i; if (!response->resp_msg) { dev_err(mbox->dev, "failed to assign memory for response %d\n", -ENOMEM); @@ -146,8 +160,6 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan) } /* - * The status is stored in bits 31:16 of the SERVICES_SR register. - * It is only valid when BUSY == 0. * We should *never* get an interrupt while the controller is * still in the busy state. If we do, something has gone badly * wrong & the content of the mailbox would not be valid. @@ -158,18 +170,6 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan) return; } - status = readl_relaxed(mbox->ctrl_base + SERVICES_SR_OFFSET); - - /* - * If the status of the individual servers is non-zero, the service has - * failed. The contents of the mailbox at this point are not be valid, - * so don't bother reading them. Set the status so that the driver - * implementing the service can handle the result. - */ - response->resp_status = (status & SCB_STATUS_MASK) >> SCB_STATUS_POS; - if (response->resp_status) - return; - for (i = 0; i < num_words; i++) { response->resp_msg[i] = readl_relaxed(mbox->mbox_base From patchwork Tue Mar 7 20:22:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164689 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 9D459C742A7 for ; Tue, 7 Mar 2023 20:23:44 +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=2Vzzx9Tp74CL/wvcJEU+IHfirHMfQbD6zO9Mi2CSkaE=; b=gCMxL/vG/iSmEQ DSbuK02nqq3flUz4i0PYyv8+COwYLH2+Jkj++0ddxpsD/xfFEWyasCIxZwyHTaFBZJFK8FjKX7oFe P/hhfZQMAQWe0jELx1XiPJSVX6qGIOjrfpRoDqUH1O49fqSKpEpAbUoDnGLkzp3W0iUXUysbE0bPP sShnPsY0hYQJktW+qNuIQPSXvo+0K+tvptM8/DRdhfzq2f74MUlF8RTnD2TmR63koJBS8CbPEV9sR IQBlpd0pJLhElLmWVGOsrZkQE805lzmWepY0XEBn8kHUK0kzvRe8eYIgY7zJX96jG8EEos7RPjNat eXn0BefZC4skL10iT5jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqU-002MQV-5X; Tue, 07 Mar 2023 20:23:38 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqR-002MOg-GO for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:36 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 298ADB81A1D; Tue, 7 Mar 2023 20:23:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D9B4C433EF; Tue, 7 Mar 2023 20:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220612; bh=zr/RXQEP9kEo+EnwwW4EkZXzcH8/Cm+sddrH4zbpuOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C2kReW2u9cd8hgfPUoK1mj5efaFk+oe+RpaNULZCMGcXQaXB8pAT2R0JGpv7ybRSh shh8tERapttCn/eBkpt7KrPwQACDKAuXbbb1WwBhbmmQMXQwYgQ7Pl9pdsZKG+oyiJ utdctq3VAWgEuEf0oyuHHsAAxW/oUIR3Tdz0+dYT79CDUKJQkg8S8VYn3OaOmZa8Dm AwZl9dvRI+1X87y5D/vQTvbSoW8qqIOjXmb9wphwdaTPW2DZSHYj7565oLl7UsBYu6 Q4TKNJKLoiWHsZUbva1Bk13dhHLVbyhDU755sGz70xQ6LnbOqQoxi5ASnsCMI9WkzQ hQ+gj5XGk5fzg== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 5/8] soc: microchip: mpfs: fix some horrible alignment Date: Tue, 7 Mar 2023 20:22:55 +0000 Message-Id: <20230307202257.1762151-6-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1038; i=conor.dooley@microchip.com; h=from:subject; bh=MwKJyVjv8Jbuiia0A7TcpOXo3jezcv525pOH2lez0W8=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4XYHMSvishN+y87ZUlG/srobd+OFpfOUS+fEKEsP kn97q+jHaUsDGIcDLJiiiyJt/tapNb/cdnh3PMWZg4rE8gQBi5OAZjI6n6Gf+a6tm1cCZtzF2/Z X/tDcaVIYGaJzdcAj39HonZl8R0ULWH4n2i66/HXZzYnlpW5ikszPrp8SkmV8dHxhVlNOu6HI4v zOAA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122335_714937_3515103B X-CRM114-Status: GOOD ( 11.74 ) 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 From: Conor Dooley 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 Tue Mar 7 20:22:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164688 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 E961CC6FD1E for ; Tue, 7 Mar 2023 20:23:45 +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=VIlv/dLu2WbmwO+vD4XPMoF+wAb1FX/w+Jwgo6WmGLs=; b=nprT4q7ypyRoQs sn+J8Oj4PFOIoeiOTtjqCxZZskGhqKGm05lR37N8dEa+cz6qJZ/BpUwB/rqLJM2cMEBv2dHCpHJiT 1YebQz8GnJ7xLFcOll6tm2gmHdKQGcU0xu9kJVHbBcKinN021hdV/Ou1q6TymeQYnEDTEwpHeNg+H CflyGI38gTz8Q8amwQ5E/y0TrwiocKHvXSolbl4OIHQ5rIRN/GRHXXGBlvAc7J5A2YNrJZArwm6IS uZD/kQdj+vg7jL0i6eTEnhp6hRRbbuzBKiVJ4ZpukT62K0yhEwxRgW0ApYowpchC7yZOgwQY0ssLz mNw+JQ93LFf+UMyl/V1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqV-002MRE-9i; Tue, 07 Mar 2023 20:23:39 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqT-002MPS-68 for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:38 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D0040B819C2; Tue, 7 Mar 2023 20:23:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47D51C4339C; Tue, 7 Mar 2023 20:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220614; bh=9ftp4XSRep9CAFGl5I/cGlZ4Bn7VzUhE3/7xrZNvJco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wd5oeeEbSyUVMox8/3SeOUbDKlFtbRdeXF9mclqCpw3C4RnGRUW3XkI4N2cQdqeMY HNTa4jT6BBHAtJSRSvItJ1s8d7UqoDawunE6T9glEmXXSGzkD3HYZqbduxk3M/u37C 2wkPwVEXGAmIMWF2/c7wbstNCL+ZoMdneRmFxcUFV2oOleV3cYKJM6tfkCCgBu5JWN e0vnSP1I6/mzgHXfIiZQNn3dsVPi8Lv0a81dfvHleVpEYgurCq8cKcYvpwd+9rIKll vWnqJwVaVsdH0fZ1FmGTV1ZBEniEB2CSWgg+lu2fiwP1mgDh9XpsAi2M4v3knia7p5 u3gGVujZx1eRw== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 6/8] soc: microchip: mpfs: use a consistent completion timeout Date: Tue, 7 Mar 2023 20:22:56 +0000 Message-Id: <20230307202257.1762151-7-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1695; i=conor.dooley@microchip.com; h=from:subject; bh=ZbvEWn53vw1ASCu/srw+heRkVpLXaO8RXoKnQ2EVF7c=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4W7eJJZMt9POxp7cEmjxazMm1nzXhSmnGC8ucvtv dYXc8OQjlIWBjEOBlkxRZbE230tUuv/uOxw7nkLM4eVCWQIAxenAEzk71+Gv+JJD104p1R3PxHg KNmxu0fdrmunZcLsV8eU4y3+z6vyqmFkuDPx/z6e+7YL3Y/vtTPUlrh/at7B+hKBfsXvEhPkC5s +cQMA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122337_398885_AAEAA8D7 X-CRM114-Status: GOOD ( 12.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 From: Conor Dooley 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 Tue Mar 7 20:22:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164690 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 A2282C6FA99 for ; Tue, 7 Mar 2023 20:23:48 +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=8gYmWVIaOrwoVNPGAXuhKcMuivxOyR1e4JXjCEV0fHA=; b=l0w4w3n95t2HRS WYTZnvkxW9MoApyg9RGmflst5jrdbyWJu33R/OdvRPxn/znPxLIFp2xL61X0dnRW8c52zKj0OaEH7 UwQZSAG8OQvoiDrELbtSGv/U4o2BFWLdp8gps3UypjYhh3VXYjffy+G/o0CQQ1TFJBFLsWTKMKFFh z1MwZ9OUEOlbFOORYVI//H8WnTo/lCGB1DBErBf7Hta2fgWWFSGHYZ8rd+q6OXoe12oUEgE1a2xlX sk/bWjcg5d8yDgVxDl8uzwXL+gOa8XC0rhU99FtiHvwGpnspkqdz2zugg6UqMtddgkb3XycpAODVu FNh2JmlfR0fnpFCaEEow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqX-002MTD-IR; Tue, 07 Mar 2023 20:23:41 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqV-002MQY-1h for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:40 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B4F8FB81A1D; Tue, 7 Mar 2023 20:23:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1252FC433EF; Tue, 7 Mar 2023 20:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220616; bh=Hyj1AzwSvpLlh1c+5n8He7fqMvxbQ+81FBS9Lk+fweU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPzHXOuv7fRzzZAIoUsTGBHAIQ+kSCElxymLxPu3KJJQFNFj82hJ+TYhuGIuXD9SU 5jvKSpZiiM7iokRN/p15cNZ5Y1R05X/yXWYbdEvptAkHN5EP8931cZnErgzj4OA9G7 Lv2qZ7Ypn+ZVkwh/kpAy9lTEk3yYqLAph4r0mHH+icyhcyOwGzrRWwJU9dcsWaNNdC WH1MYjzvL7pb39MXGy8dHxZ8PTlLSFPRGPGTxbG8YOtTXyLsZiX8/n7zb1VYerk1b/ FwfMBTwbUOH+WsKVtcIGg5qVxBJYVebxSfIxTgvaKluWdhva5CvdN3OPSTNs+uDmYe i09pITodsp17Q== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 7/8] soc: microchip: mpfs: simplify error handling in mpfs_blocking_transaction() Date: Tue, 7 Mar 2023 20:22:57 +0000 Message-Id: <20230307202257.1762151-8-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1912; i=conor.dooley@microchip.com; h=from:subject; bh=TiTo00L6NEuRkl9W6QwqcYPRUYBdT9OXo1cRIbTtbsQ=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4W3n14zrYEnhHdHxbpXh8XmqTFZx2T1bdjlEeM57 zj7Ab3QjlIWBjEOBlkxRZbE230tUuv/uOxw7nkLM4eVCWQIAxenAEykdRsjw2JPr/llRYzH+bbz 5hX98zlQnnWbfefuAytTfq6ZyVP8MpCRYf+rqHO7WuoyNql/u3MxxbOc0/Xaasmgd4xLfA1/9M9 IZQcA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122339_262717_C8427F4F X-CRM114-Status: GOOD ( 14.00 ) 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 From: Conor Dooley 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 | 27 ++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index 738ecd624d64..e61ba9b7aae3 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -32,28 +32,27 @@ 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"); - } + if (ret < 0) + goto out; + + if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { + 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); + /* mbox_send_message() returns positive integers on success */ + ret = 0; } +out: mutex_unlock(&transaction_lock); return ret; From patchwork Tue Mar 7 20:22:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13164691 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 427F4C6FD1E for ; Tue, 7 Mar 2023 20:23:50 +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=69Ie05hnkQpLOBMFxOR1SC4xevg1ZxtAf083rBX/ka0=; b=ZJj3IzmdOx8iBF xufxd4Q1Ly5WiyLBWyy9RgEu8tS5fQftpau6ZDcyKjrvnwRWl+YuLmhf6vthyBnAorhZ0ChdE2Sp7 pl/GS95b9znEIEQggSg/ZRl5uLdsc5Hfbt7M1mnOhImNkdY4+LKLwsDSOaYwJHdg5NgB63MlLmODk lWOrCyY5ROnFMS24Qb2u5+2PmYCTjjIXB1C8M+QXlCie0wEGLhfaB3DJ+zpiYeEkNUJaFsIiXTDpa hz+yX2dsf38bDX3kCJlKSuB64MQnFMBOo1HbBS1GqNRfUDhDUxgy3L/X5esnRMBbgIug82yO/ax9R x+aO5HCxqxdzlMJOUy5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqY-002MUG-Tb; Tue, 07 Mar 2023 20:23:42 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZdqV-002MPS-Vi for linux-riscv@lists.infradead.org; Tue, 07 Mar 2023 20:23:41 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8C370B81A13; Tue, 7 Mar 2023 20:23:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0C12C4339C; Tue, 7 Mar 2023 20:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678220618; bh=zda+VbG39EuOmqkJEqNyN6EQjdt58w158b+x94tcTtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNTBs9H86YYrMsI6GY62OKUY/zA+Y/N4//bAkoDBohiDpxWf3xg5Fvuj3jmSgnsYy 847gso8bU/q2cYiZE1keCVkfpHTHzYgfdyc6i3gXwOSHZlJMhBxhvQcmp294dgO1Y9 smnUpiczFeYWtJuG2zo+5N/mlJgtdI86csYALnq6rArW+1GY5n3ET2TQkw+GmLp8Rm okAAtihHtRyVci0pm0STHpam0M/ms20FbdLvXCBtfrFYs1tgcDkRljYzMuJg/8ncup 2u8Z9OH5FbscqGPaPbNu6lDIodWhb4KXVwMZOJivlCSvi6gM8fYhZneZIrGkPAL9hY /brzgVWQSitJA== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Jassi Brar , linux-kernel@vger.kernel.org Subject: [PATCH v3 8/8] soc: microchip: mpfs: handle timeouts and failed services differently Date: Tue, 7 Mar 2023 20:22:58 +0000 Message-Id: <20230307202257.1762151-9-conor@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307202257.1762151-1-conor@kernel.org> References: <20230307202257.1762151-1-conor@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3200; i=conor.dooley@microchip.com; h=from:subject; bh=pwrSJrBRsgiePyr0G5aY+e8m9Q0BM9VvEVyERBwr1ik=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCnsc4V5zm27ymprZ7VAkrUva0X8rPMu97a4F7ucz+T22 /UxbM6+jlIWBjEOBlkxRZbE230tUuv/uOxw7nkLM4eVCWQIAxenAEykgJeRYfpcZy2PGvs1v1cf urPvW+3Mp3MMjA9oXX7pJvrqyvvgW38Z/pe+cf/f52Ir4R5w0Vrc+t/E/v1Sq/i2zS4umpD0t4r 1CRsA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_122340_344399_B1549F2B X-CRM114-Status: GOOD ( 20.34 ) 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 From: Conor Dooley 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 | 27 +++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index e61ba9b7aae3..ceaeebc1fc6b 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -18,7 +18,11 @@ #include #include -#define MPFS_SYS_CTRL_TIMEOUT_MS 100 +/* + * This timeout must be long, as some services (example: image authentication) + * take significant time to complete + */ +#define MPFS_SYS_CTRL_TIMEOUT_MS 30000 static DEFINE_MUTEX(transaction_lock); @@ -41,14 +45,26 @@ 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; + } + /* + * 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. + * The caller can then interrogate msg::response::resp_status to + * determine the cause of the failure. + * mbox_send_message() returns positive integers in the success path, so + * ret needs to be cleared if we do get an interrupt. + */ if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { - ret = -ETIMEDOUT; - dev_warn(sys_controller->client.dev, "MPFS sys controller transaction timeout\n"); + ret = -EBADMSG; + dev_warn(sys_controller->client.dev, "MPFS sys controller service failed\n"); } else { - /* mbox_send_message() returns positive integers on success */ ret = 0; } @@ -107,6 +123,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)) {