From patchwork Fri Jan 20 14:37:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13110038 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 446DEC25B4E for ; Fri, 20 Jan 2023 14:39:02 +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=m4FdqFipXn6APq 7s3gPHCEmdjEIssTsOWKB7/+5XNzQxlchClQ+jEaaEe8lv30BoTkCa+hROWMywmpbXrt4iIqCFMEV PWUOb5/YI0ixZ6yE/DBXlCFv0laDAmBmxaF1wHQgSunaI9QGtN9jwme9OMt3tARYt0VRFO2xUDv2Q TwctuNeF88unVyaXlE8vtZTokRXhK1AhN7w3XpPPYGcKV+hB79BgEyyDKaNDQI2ck5BrZZKFeWq80 JgOURhxsu9uzUlqrQtSiS+lRvk4mAgfWvCgeFXOadplg1qGxRqAgMtHuHc2AC2veCZBdRg4hVuUi2 5v9sJDUsYSczeBOQijbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsXe-00Akf0-5i; Fri, 20 Jan 2023 14:38:54 +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 1pIsX1-00AkNR-2g for linux-riscv@lists.infradead.org; Fri, 20 Jan 2023 14:38:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225494; x=1705761494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wIqkIRLk97mVy76bXMdNE/RNNtTIHIYTZDRNoDes7MQ=; b=w5T9+8jHRRTNIxVun7TVPNf4rEbzRJiwg/X114VpKiPvS7U3eyc5XAUc Asw+geA6mosNG2lEa+aoc07Z9++WQkhpQxetVhuGjzQx0NjnhoSJHf44T +Ur/u59+yKKqAozpOjfvWjqWXZW2KRbGYluwS7ogB4pTw2bJ7MJx5Uyyd EEJH1nEw3aM06pbiuIj00NZlGFxW2X+ES0+0O3AI64paLSIMVlmr784sv HLZ7nVdftN/mtIaDTynNNyJJRIFY6T0o72J9O/gx6BNVk04eKJtX1ZIk0 /Vg9/PZsnLhndGwirEBdtUXcM8qRU3LXWDPKL3NRYf0WfJx8eZPPiFkRt A==; 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_063815_165712_D1C76868 X-CRM114-Status: GOOD ( 10.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 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 Fri Jan 20 14:37:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13110043 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 24A13C05027 for ; Fri, 20 Jan 2023 14:40:55 +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=nL6TuSD0FdspEo VFmyPCeYnLB+jt603cGYI547DprjcBrUHXge6wBOshSdEC+gOv+Z6TwARk6odjyPtvJM9d9A94Av7 jK/SlmLxoJMCRifCL8ZpJrtSGdr4QdNlyueOdl02FA4D2POpmcr6GA2tQjbQcXeJp7cFkTFa0IAI8 6bXKvI0CypyORFChzZMDkQKzWJAhO0UsnUYhyamzGGOKSbAzxkUug8p346zzYpbu8woWfWUGQwh3U 7GXpA74HCgSyWaee95kkeCm5aVDyN3mMLoVlDGn6XXagqL1sOWtTDdg1Dj/y9zWmiTZr06duG/byG qmo76bQLh0NpADXLT+Kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsZR-00Alq7-Qj; Fri, 20 Jan 2023 14:40:45 +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 1pIsXT-00AkZh-Fl for linux-riscv@lists.infradead.org; Fri, 20 Jan 2023 14:38:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225523; x=1705761523; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1o9L/4gS6hFw7QhrPiNy1BOlai1A8GCWCQbQw2g35go=; b=hP00YmgmCvB+zcbZNgXqxKrCsoI5JSULRlSqneyyodLOjWsOUMU9nmIh jP4Ac2cHNnoTD9WvjNSjpvUhCJBjNIbAfRtk8y3QMA9cXsy7nNG2DBXfr Fa5bhyUzoqly/0qbtGW62wOhP+pQukS3elrZDi/ie0E3yF6/J/DJ0jIDV C9i7LMcK8+YlXYThyZ39jNrSavicBeE756uUn5ubH4Xqs76LcovBT4r/I ZL5ahSJrT+CUWmLWInpBS3aibpYvm0F86a2E9WdzjHVt+ZHeFvHp8eMhM fN5F7CNVsrj9rqtWQmoYkfIJvgRbDeJDpp0jWnKWeApH2Z88wc2PzQfIJ 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_063843_690714_9C39BFAF X-CRM114-Status: GOOD ( 10.15 ) 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 Fri Jan 20 14:37:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13110039 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 0CF8AC27C7C for ; Fri, 20 Jan 2023 14:39:15 +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=Xhp/hI6NlAXkZ8 JLsvEnWcr4y+m4lWDGjwkzx2bcFPf8plCD3O0zrwEenztvUgNEprOKI2OcmRAMscAxtUqM4HyyfQu YEyI1ZS4f60fRq7716ttX/ryVfGExYtgFcx6yYn6jLhUyP/kJT3fqlXFfaVRauR/kJ4gzhFSeVEMS Xvh0JTXx0GsokhBPzgx1SA0mP5fP1ykMbPupMNFXZ1EVc5aj2xuW0bx6IgtQwi0E0iWfsPViBNT0C XINdOj98O2jSKNifXRjAb+TG2jiuqqTnH2rpdAgzz4TIxCkiH9REWraZmJBfMqwF3+z+ouCApKtla RmyiiLpQgFNAj8FQrqRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsXq-00AklK-57; Fri, 20 Jan 2023 14:39:06 +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 1pIsX1-00AkM5-3W for linux-riscv@lists.infradead.org; Fri, 20 Jan 2023 14:38:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225494; x=1705761494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FCOl+T+5C62VF4k5ASrJAWhazXtjeEzsINHVVaIW+hk=; b=THh8voBAZJSmvMrDn7awRHGb2pg9yBfX/4ctG0T3PYfzqE0XWDngyczd 5ZdkONEsWNZiG/xHEmKXTjT6IOHLnQL9Fg/ykaOWGrI/CyC0Fgdf+F/6x 8a1Kqwfth2PzAy+J3T1DULSVZeRsZfpN2aGQLLiKfGU3w0gJlijKJprn3 VxIiP4rXJF1hqYlm9sE42/ChLxB/5pwUmiBjrTiygsPPfr85cuWsl7vdo Qg5heFU/LVj74TihbKRAFDzKvFiX4jaDAoaXfecL/7O39yJCm18RAczYu UZz+sM3WMxo2sKDMQsEn+CfNfFL+z7Ss8504soq4sbvdJzIv2SAx14Qao w==; 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_063815_303567_FED86F0D X-CRM114-Status: UNSURE ( 9.51 ) X-CRM114-Notice: Please train this message. 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 Fri Jan 20 14:37:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13110042 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 994EFC25B4E for ; Fri, 20 Jan 2023 14:40: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=J3X2TD8KPKq9DNBw1R+LLXslWk/KoBWF+RWAfgT+IYE=; b=Dw2L/IErJaKFgP 7Yxps9HoIpxJA04YwvX9ffIYE++pQntMfhVdYNsfCgLeeQImh7s9f/ighrU83G/xgiNDJStMoSCN2 JW+Gx2GFyFDmkEECV6TCwaeE2F20zK9xvY4uPwZNZ3rTZ13iLEXPRT1NNs+xqfYN7L/5YDDMg7U68 1kQWVKFaDLlkgdOmrlKKD8lwo7BX3HHqoIpW/Sp5w987oMehqjvv0kZSUoIr4tueJwvZHT2ZU8gZZ 1vxgQGIPm24sobFX7f4YIje2oILzV9IvBKyvJ37hLdGGGKAHo7LJVVRT+mJEl99F1lT7Aiadi1ICc Q16FeRCgecSRe3u9M8Dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsZP-00AloG-BG; Fri, 20 Jan 2023 14:40:43 +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 1pIsXV-00Akau-O5 for linux-riscv@lists.infradead.org; Fri, 20 Jan 2023 14:38:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225525; x=1705761525; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D44+KU7ZiM3CE8om7qWz+e12D8GVZHQeVAMd689yP1o=; b=hO/1hFtizMk9mCbdoiKG0KoxFZ1kBB+17rWHLJF9eN+xo1iR3W7lpSha bxMXX6dmq/XugtxsfRTYYx5NL0itsHIR+IB/SMcuBjJemoBZIoxIJyZjt v63FbmsdYQoUjPCwQe8hDgHvjiwIabKHxLDUiDjktAEPvIv1b2CG2/tpK P4wXffSn/5QuaO21IUz80dAzNRmcgXN38rPE/bvTujtcD+0JLDLux3yiq SLez7E0IDOqbcoxAn//aAKSSqBONs8TYQKG20KvHjd5X86qwIkUJT4iI0 6hqEmprDEJmNoEMPVriPtntt5yXvjl3qb1IwbRWZGH8iBWODpruKZvWfh g==; 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_063846_570545_C90113B9 X-CRM114-Status: UNSURE ( 9.30 ) X-CRM114-Notice: Please train this message. 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 Fri Jan 20 14:37:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13110040 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 921CFC25B4E for ; Fri, 20 Jan 2023 14:39: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=MXQ4ZCG5cBYFDbbQ00BlZ8cC6Gl3V64BImC5oJ7GlJ4=; b=g30sF8jqWx3Rex 3ZOHCixMUmqoGsBKxAUHfQZ9kI8IqMZ+oMUh1+AzePbccaP7pm8wqXXlYKcToyfohjAvRpI6vq3ba eEVHj38pj3OchUE6T9P8srSb0a2GFlRb961bbfhJd4ZGnXsfMSuZWCjEHMnC8MFJCNSZZwsN4xkOz KcVBq9bleK05keNYv0E+0XUR3cKVwXYMO7F+LJkh7//vAGFoyGjzJgrC42Fe6utdzbYy83NbuByyI TG/7xugFqeqYOQsUoQOQorOgwTRMXUe+pMNXX4jjonrj9CsVQZgI/FymBCMR+AQXVKKiAv54RHGsN NwJwPFqEtZmk8rBIA5xA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsYE-00Al0b-Ot; Fri, 20 Jan 2023 14:39:30 +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 1pIsX3-00AkM5-WA for linux-riscv@lists.infradead.org; Fri, 20 Jan 2023 14:38:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225497; x=1705761497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vswoNz7W4YNtXxpN9gjNGU8G3StYy1AGUcDydMeUCxM=; b=C1mX0euObCmwYB4eYxDx6IFS7iBAkXFXjznBuyU51gzX1tEDf4lcnlns bO2GXW3QDTjkrwKuhYtupdfCTD1CwY5NZoHq/01gLerqegc17e6QuS5Bj M7XhBbn5ccBGnG7s1RKhq4VZA/lpjwUJzHmFOlmhE591VJmx5AKPi+1Wv wAp8pzyqZMR9PYLS0FstK+HyTe0OUrz7tpq/ueNQN6xdf4+LDp/iaIxIu KQISz0Wox380baUB2P+k3xnWPIEZ6Hmkg+8p0VWTS8rvAnT/XU4TRzerJ C78Fg1dZj6isLUy6ur0PrP1eSv5lcH9OODSN8z90m8GoijXTmfl8aW2Zi Q==; 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_063818_175904_B8A784F1 X-CRM114-Status: GOOD ( 10.97 ) 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. Since a define is being created where one previously did not exist, pick a suitable timeout duration. Most services will complete nearly immediately, but those relating to image verification and re-programming the FPGA take significant amounts of time. 30 seconds is a suitable timeout for those situations, although most services will complete in under 100 ms. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c index 12039cb38b33..e76a5e38f655 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -11,12 +11,19 @@ #include #include #include +#include #include #include #include #include #include +/* + * This timeout must be long, as some services (example: image authentication) + * take many seconds to complete + */ +#define MPFS_SYS_CTRL_TIMEOUT_MS 30000 + static DEFINE_MUTEX(transaction_lock); struct mpfs_sys_controller { @@ -28,6 +35,7 @@ struct mpfs_sys_controller { int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg) { + unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); int ret, err; err = mutex_lock_interruptible(&transaction_lock); @@ -38,7 +46,7 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct ret = mbox_send_message(sys_controller->chan, msg); if (ret >= 0) { - if (wait_for_completion_timeout(&sys_controller->c, HZ)) { + if (wait_for_completion_timeout(&sys_controller->c, timeout)) { ret = 0; } else { ret = -ETIMEDOUT; From patchwork Fri Jan 20 14:37:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13110044 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 0A5F5C05027 for ; Fri, 20 Jan 2023 14:40:58 +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=lOvgvIf3QQYbIW+aXJR/ZH3gnzeUlS4KzvDGUXQYeqA=; b=laMeUg/Tj/fu3Z ZHUYK2Qj1+XCacT9qZx3qLiRf1J+eMEwrvME0P7ItOF7AI79OxgrMp80bocev8R4OMul9UFv8NlFY I86c+0OyzfkIP3GsmBHKBdeEl335Sv53raCIId7xpqFyVrgIb39k3dQv4Uf97cP5gYzFu21oS6Nvr 1Ol0X7oGcj1mvANWKZoAM6tKP3kOdFCA2itGZudr1KPXB0asWE0JqnFluT0rarIYZauMoBVk0sORy yziHumcEnxqOj2b9ZtyI85D/FymiXvKlS3dX5R+DWQGLHDtL+XrpQfxA6wNMobBxx5fo8j2Lh5ulp gTyBeRX+prhQXoaoMBLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsZU-00Alsp-Q7; Fri, 20 Jan 2023 14:40:48 +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 1pIsXk-00Akil-Vx for linux-riscv@lists.infradead.org; Fri, 20 Jan 2023 14:39:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225540; x=1705761540; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ETrCqr1esSdpLl/whNaGbQbj8ly4dFAvvv640kfUFd4=; b=Cxq8Ki7dgAf79FImNhm5wn+TRcVNdxvFXvYMRUMnk97Zo+A1TUKJKmYF gi5BWDnkaPSl5p9NWo90LtwOwh/I+dGhSSC4gCWZkkXhAB0D5mq0ihIKg rLqWk+YINikoNVe5n1nIZFUVyOC9K5z6gGcs8GYxpJ9nC5wXg8r5HHEea KFoUKfRyU+2qElTVTbUP6I3CFTyW5jgMETybvv1j9fRSy/kHD5bvQsrke Pd3DVt536K52TdFWcL0H3Fukwxl95bSRTGd7yHoNG31b5vQYUdJ4kBsFi Gx95R/ZCep5eK/HZwmlrydc85CJw24gbmnu4qyzEFZ2yZwYOcEq+4VERo g==; 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_063901_118772_9D18F284 X-CRM114-Status: GOOD ( 11.45 ) 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 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 = 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 positive 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 Fri Jan 20 14:37:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13110041 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 E894DC25B4E for ; Fri, 20 Jan 2023 14:40:05 +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=6FIlNPKpqIFvoF3iNJqLtM4OLSojHj6WAl6g2jAVpb0=; b=U/xa8FG3WbAaBx syivDCwmqX6QMV297rpOTcatEvh6jG38Hj/YGIxjPS9Stz4E3/r9LHoZNF8L8a9BEx/OLfHEkMqex s3NQuUYRDb2E7SBiNqoSEcv1advis7xdyvqm0jgQjbYQyyd+KGzhOzlq4hSBkpW+Pp35FnzkatfRp Y3t2Llxhe/URrYpWbBmeqCsG91/naqqmrIFeD/lCz2NUUhiJhEit72bpz31SNvXQgT7GwVhh7Knud vflc1yT/ZzB4nGET+CtSs0rmlAo2yhoSv1rgNoHXYn7bhX58UwLA2+odE8BlP7+gh7Oj4NLGAbN+w JfjR7i6wuNVKLHIAzOgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIsYe-00AlGb-Vb; Fri, 20 Jan 2023 14:39:57 +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 1pIsX9-00AkR5-IW for linux-riscv@lists.infradead.org; Fri, 20 Jan 2023 14:38:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674225503; x=1705761503; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oYx+ncPt3aXXBAx6eIW+t/dOXcIk5sAoEFiHLkKETcY=; b=mYVdSepH5XeEH52pRfYAkOB2yn1/IOSVbVt/HRJkg7kDe0hcaKDvwVJt 2VC4Lzm3N1NNSwMR0x8fBPFNq/du5Bt0FlEo/3hgwx+8nAiuAprnYxgd4 VJwktymVQlfquvb1KU3hcD17rs6QZw279PW/QPISFkjCL7U5XNNcO1dO6 d1jIhbsrEezGyp/zD6T6yKEt4KtpmActvFLMnTjKDapkMqvnnF670xnUO +Nesnka5TTZYzDZM6pmwf6Y+1eYdUJPRQtBQOrRk0kD5ZIU8tZfGpauOP KByuYMODIkDxH9cVhyruekXKtfZQREG0OBJc8PecAtBvkG3KBG+qIKe7y w==; 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_063823_699270_9F22ECEB X-CRM114-Status: GOOD ( 14.96 ) 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 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_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 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 = -ETIMEDOUT; + ret = -EBADMSG; dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); + "MPFS sys controller service failed\n"); } out: @@ -110,6 +121,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)) {