From nobody Mon Sep 15 15:58:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EED8C46467 for ; Wed, 11 Jan 2023 13:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233371AbjAKNp6 (ORCPT ); Wed, 11 Jan 2023 08:45:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbjAKNpv (ORCPT ); Wed, 11 Jan 2023 08:45:51 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70BF9C5 for ; Wed, 11 Jan 2023 05:45:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444750; x=1704980750; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wIqkIRLk97mVy76bXMdNE/RNNtTIHIYTZDRNoDes7MQ=; b=bn9ak/smUMyoVZHeTgE1EZgjXWF7sIOJTUh3rNujdMo40RGcbojrzGOY FOlVBWhFVdmay3qBIEQxqDVIRY1acRe5eeIx5af4oUBRrXh25iWytAwv5 O9kA/AuBLiCe7oV5SLuLD5tOBeG4A/kqtQXkZ4nDxX3jp6iMf5CWupj76 qKtg8216d7U/Oz8QW8IpkeRRbG/TYVQtjj2UvYz+C7kcpgzWUV0uMwN3O uCdDlu7RcDzzz5SWjtPzqTU9yErTaC2+lhyJp+Ap4N2/u/4Jz3P4DZysN 6D9IpHWL+BxF+M0v3FyVE8zMyXi1sLykbCYRaM9hqRL/x/ycHy3+fSOwJ g==; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The system controller registers on PolarFire SoC are 32 bits wide, so 16 + 16 as the first input to GENMASK_ULL() gives a 33 bit wide mask. It probably should have been immediately obvious when it was pointed out during review that the width required using GENMASK_ULL() - but I scarcely knew what I was doing at the time and missed it. The mistake ends up being moot as it is a mask after all, but it is incorrect and should be fixed. No functional change intended. Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index 853901acaeec..d37560e91116 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -39,7 +39,7 @@ #define SCB_CTRL_NOTIFY_MASK BIT(SCB_CTRL_NOTIFY) =20 #define SCB_CTRL_POS (16) -#define SCB_CTRL_MASK GENMASK_ULL(SCB_CTRL_POS + SCB_MASK_WIDTH, SCB_CTRL_= POS) +#define SCB_CTRL_MASK GENMASK(SCB_CTRL_POS + SCB_MASK_WIDTH - 1, SCB_CTRL_= POS) =20 /* SCBCTRL service status register */ =20 @@ -118,6 +118,7 @@ static int mpfs_mbox_send_data(struct mbox_chan *chan, = void *data) } =20 opt_sel =3D ((msg->mbox_offset << 7u) | (msg->cmd_opcode & 0x7fu)); + tx_trigger =3D (opt_sel << SCB_CTRL_POS) & SCB_CTRL_MASK; tx_trigger |=3D SCB_CTRL_REQ_MASK | SCB_STATUS_NOTIFY_MASK; writel_relaxed(tx_trigger, mbox->ctrl_base + SERVICES_CR_OFFSET); --=20 2.39.0 From nobody Mon Sep 15 15:58:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8063FC46467 for ; Wed, 11 Jan 2023 13:46:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234184AbjAKNq0 (ORCPT ); Wed, 11 Jan 2023 08:46:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233532AbjAKNqV (ORCPT ); Wed, 11 Jan 2023 08:46:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6EBD5F5E for ; Wed, 11 Jan 2023 05:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444755; x=1704980755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1o9L/4gS6hFw7QhrPiNy1BOlai1A8GCWCQbQw2g35go=; b=FBi6yMeFn6kY4CuF0OtYFitOBkKBRbUtRGzPmSK+hIG+Z1l6/3ZbQGJN zpua8RYpDEPpkEJEh/oGiPycJLz54sEQ7y3/AZkK1A6McCxnfeNvLhOnl B3XTBgR2KPstelKZVKw+UOrn/j1+J+A+VCDNXo5yGv50t+RcXKo9eINnl 0mc4j/HJ8Jsga4AE8B7GcA9LNQ5zR1+jkuoFa0z5o8GKMayWu+qcqRc0S MQMsMAY1KPzzRIS+JcJ/Lf9/o1/+VNlDhFh7pQByH+5It7r2v+RG6/6/f BCqBUBKnx/9UORQyOvkrAUnmwXQrnQqCm67Ke34rWsR7k8/9V98nZYzBh 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The system controller on PolarFire SoC has no interrupt to signify that the TX has been completed. The interrupt instead signals that a service requested by the mailbox client has succeeded. If a service fails, there will be no interrupt delivered. Switch to polling the busy register to determine whether transmission has completed. Fixes: 83d7b1560810 ("mbox: add polarfire soc system controller mailbox") Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index d37560e91116..e0e825bdbad9 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -79,6 +79,13 @@ static bool mpfs_mbox_busy(struct mpfs_mbox *mbox) return status & SCB_STATUS_BUSY_MASK; } =20 +static bool mpfs_mbox_last_tx_done(struct mbox_chan *chan) +{ + struct mpfs_mbox *mbox =3D (struct mpfs_mbox *)chan->con_priv; + + return !mpfs_mbox_busy(mbox); +} + static int mpfs_mbox_send_data(struct mbox_chan *chan, void *data) { struct mpfs_mbox *mbox =3D (struct mpfs_mbox *)chan->con_priv; @@ -183,7 +190,6 @@ static irqreturn_t mpfs_mbox_inbox_isr(int irq, void *d= ata) =20 mpfs_mbox_rx_data(chan); =20 - mbox_chan_txdone(chan, 0); return IRQ_HANDLED; } =20 @@ -213,6 +219,7 @@ static const struct mbox_chan_ops mpfs_mbox_ops =3D { .send_data =3D mpfs_mbox_send_data, .startup =3D mpfs_mbox_startup, .shutdown =3D mpfs_mbox_shutdown, + .last_tx_done =3D mpfs_mbox_last_tx_done, }; =20 static int mpfs_mbox_probe(struct platform_device *pdev) @@ -248,7 +255,8 @@ static int mpfs_mbox_probe(struct platform_device *pdev) mbox->controller.num_chans =3D 1; mbox->controller.chans =3D mbox->chans; mbox->controller.ops =3D &mpfs_mbox_ops; - mbox->controller.txdone_irq =3D true; + mbox->controller.txdone_poll =3D true; + mbox->controller.txpoll_period =3D 10u; =20 ret =3D devm_mbox_controller_register(&pdev->dev, &mbox->controller); if (ret) { --=20 2.39.0 From nobody Mon Sep 15 15:58:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4988C5479D for ; Wed, 11 Jan 2023 13:46:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238698AbjAKNqg (ORCPT ); Wed, 11 Jan 2023 08:46:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234188AbjAKNqV (ORCPT ); Wed, 11 Jan 2023 08:46:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F07DCD9 for ; Wed, 11 Jan 2023 05:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444758; x=1704980758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FCOl+T+5C62VF4k5ASrJAWhazXtjeEzsINHVVaIW+hk=; b=0Ry91HPtVZCDtQ/Bh54bCilOLnnLD20Dyl1BsJc4GAe3ZmvgRP5MxdNe c/DvDQS/WwK9EOUh9WPBeOjMtMnBgZXn8s99ItWu2Og9YVQ8+Kl/maa7F JKx4ffICnj+6ikIVTir0dwZzHH5DogThOaQwWbf0MPcCTL3UMQTwVD/iy uFfUhQDAW3Dg94pnEDUlZ7Nk4+Cum3sOpVE9jL5oe7pt0ttEFANP34Rsj ErPZEuDQ2PFG6fPRuktsubnUqRbUgd3fRjJRP0ymiyTmsuozhDQFFXnrZ PsTS10TTmXzfs9SE5oNNpd+j6HKNvhb8x3FDD1z4oYqU4nrxLwpxJ1+oS w==; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" mpfs_mbox_rx_data() already checks if the system controller is busy before attempting to do anything, so drop the second check before reading any data. No functional change intended. Signed-off-by: Conor Dooley --- drivers/mailbox/mailbox-mpfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/mailbox/mailbox-mpfs.c b/drivers/mailbox/mailbox-mpfs.c index e0e825bdbad9..0d176aba3462 100644 --- a/drivers/mailbox/mailbox-mpfs.c +++ b/drivers/mailbox/mailbox-mpfs.c @@ -170,12 +170,10 @@ static void mpfs_mbox_rx_data(struct mbox_chan *chan) if (response->resp_status) return; =20 - if (!mpfs_mbox_busy(mbox)) { - for (i =3D 0; i < num_words; i++) { - response->resp_msg[i] =3D - readl_relaxed(mbox->mbox_base - + mbox->resp_offset + i * 0x4); - } + for (i =3D 0; i < num_words; i++) { + response->resp_msg[i] =3D + readl_relaxed(mbox->mbox_base + + mbox->resp_offset + i * 0x4); } =20 mbox_chan_received_data(chan, response); --=20 2.39.0 From nobody Mon Sep 15 15:58:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44E97C46467 for ; Wed, 11 Jan 2023 13:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232784AbjAKNqd (ORCPT ); Wed, 11 Jan 2023 08:46:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbjAKNqV (ORCPT ); Wed, 11 Jan 2023 08:46:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE21D632D for ; Wed, 11 Jan 2023 05:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444758; x=1704980758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D44+KU7ZiM3CE8om7qWz+e12D8GVZHQeVAMd689yP1o=; b=erJV2dWJIoYskshxn0APA0VGPgK4CRTaLGZddGtx9K6aI8tRa9jGPsXs lUohED6SNfMiOWox3qXHkKreUlJ+lqEigOY5OP4rvZb9EHfhN0+aeQTnn WUg3gjMNfDeHuhto0VwrDENawr1DQV1pHi4607OZ6Tab1Qz9fSOv+MMyU kKNRTzBbfDRGNoTrxGlxaATe+HGnhbToDUURQAxqFfu7Xj8mvLc1ceZ14 rnqKwIb74b2GPUbjF/O/AgNf5PFu0k/vvgEx4KFCfZi78h7i1nXSSV3DJ mzHl8hwAUmOLZwxNdZUlCdUybJc1vIkGbTJG+ZLyDL7NO1V5imC3hCULp g==; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" mpfs_sys_controller_delete() has some horrible alignment that upsets my OCD... Move the RHS of the assignment to a new line for greater satifaction. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/micr= ochip/mpfs-sys-controller.c index 6e20207b5756..12039cb38b33 100644 --- a/drivers/soc/microchip/mpfs-sys-controller.c +++ b/drivers/soc/microchip/mpfs-sys-controller.c @@ -66,8 +66,8 @@ static void rx_callback(struct mbox_client *client, void = *msg) =20 static void mpfs_sys_controller_delete(struct kref *kref) { - struct mpfs_sys_controller *sys_controller =3D container_of(kref, struct = mpfs_sys_controller, - consumers); + struct mpfs_sys_controller *sys_controller =3D + container_of(kref, struct mpfs_sys_controller, consumers); =20 mbox_free_channel(sys_controller->chan); kfree(sys_controller); --=20 2.39.0 From nobody Mon Sep 15 15:58:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4CF8C46467 for ; Wed, 11 Jan 2023 13:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239391AbjAKNqa (ORCPT ); Wed, 11 Jan 2023 08:46:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233600AbjAKNqV (ORCPT ); Wed, 11 Jan 2023 08:46:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E40496265 for ; Wed, 11 Jan 2023 05:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444755; x=1704980755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YmvtEgsExmKnHFKrtsTC1qEk3keDAXMIHIB9CsFESV4=; b=DiijypHa7U81PoTg+Wr23aa0/TGNT2bfODEbzF0bDge4omZlrRrTOmVm ZH4JCUL0anpHrYJIQjUrax03exEDa5MnT0j4FlA+sdyOcP021DU4CvbCT Vy07/lztFIs1mcdHi4msnIdITR+aunpJI7fE9gn3y+mkr9L/sXoDVE+Wo PlxWOnKFjLj/MkyG+9XdR2E1A4AJdARitsj9jQah2lUVvr4ZjhvphwMGB ObMEj3IXuFKw5SB7aY9UI4a8PKxxK3rygpk4fIvmn7kNcfACE/G9OjOl7 idpLvc6c+mLSUuk9T5uoqCiKkI2FW2e/3h2Xgi09O0wRRsTF9QmSFK1hw A==; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Completion timeouts use jiffies, so passing a number directly will produce inconsistent timeouts depending on config. Define the timeout in ms and convert it to jiffies instead. 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/micr= ochip/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 =20 +#define MPFS_SYS_CTRL_TIMEOUT_MS 100 + static DEFINE_MUTEX(transaction_lock); =20 struct mpfs_sys_controller { @@ -28,6 +31,7 @@ struct mpfs_sys_controller { =20 int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, = struct mpfs_mss_msg *msg) { + unsigned long timeout =3D msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); int ret, err; =20 err =3D mutex_lock_interruptible(&transaction_lock); @@ -38,7 +42,7 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller = *sys_controller, struct =20 ret =3D mbox_send_message(sys_controller->chan, msg); if (ret >=3D 0) { - if (wait_for_completion_timeout(&sys_controller->c, HZ)) { + if (wait_for_completion_timeout(&sys_controller->c, timeout)) { ret =3D 0; } else { ret =3D -ETIMEDOUT; --=20 2.39.0 From nobody Mon Sep 15 15:58:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5913DC46467 for ; Wed, 11 Jan 2023 13:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239457AbjAKNqk (ORCPT ); Wed, 11 Jan 2023 08:46:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234525AbjAKNqV (ORCPT ); Wed, 11 Jan 2023 08:46:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 897C96377 for ; Wed, 11 Jan 2023 05:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444760; x=1704980760; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dqNf1ACM7VOxiqPM+Nc/J8oy1t3x6F1UdtTIb0rpr7I=; b=HNgQT6/xqaclpb6BB9Ms3IT/aqfWjwVaIw2SeWoG+7pJBAlm+XlfWRn5 b/wOm2xqlXW+DswFNVuvQ+WV4lF2w3MsEmN0erqf234Afo8L/F1Xo87eG v+t/GnPTBkxeAW0Y+gMxNq8m5OdLp/CjeNp8dSIOILV0wTAHzLKaXJBIv JHGtJiLnyLjWNpuOxs1sUSBG182yzWVmWJ0strW6QyEtvm9dNDcPOg/Ff sot3XpAY3dvfHmvF2mi3tkbaTXSyU3y/+I5k8auFunfQrODP6dNYmND7+ LnCe25E5VEHj6mXlcC83kXAoszQWtCvibXCOMIbHezUyumnpjLXqo3Eo4 w==; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The error handling has a kinda weird nested-if setup that is not really adding anything. Switch it to more of an early return arrangement as a predatory step for adding different handing for timeouts and failed services. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 28 ++++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/micr= ochip/mpfs-sys-controller.c index 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 =3D msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS); - int ret, err; + int ret; =20 - err =3D mutex_lock_interruptible(&transaction_lock); - if (err) - return err; + ret =3D mutex_lock_interruptible(&transaction_lock); + if (ret) + return ret; =20 reinit_completion(&sys_controller->c); =20 ret =3D mbox_send_message(sys_controller->chan, msg); - if (ret >=3D 0) { - if (wait_for_completion_timeout(&sys_controller->c, timeout)) { - ret =3D 0; - } else { - ret =3D -ETIMEDOUT; - dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); - } - } else { - dev_err(sys_controller->client.dev, - "mpfs sys controller transaction returned %d\n", ret); + if (ret < 0) + goto out; + + ret =3D 0; /* mbox_send_message returns postitive integers on success */ + if (!wait_for_completion_timeout(&sys_controller->c, timeout)) { + ret =3D -ETIMEDOUT; + dev_warn(sys_controller->client.dev, + "MPFS sys controller transaction timeout\n"); } =20 +out: mutex_unlock(&transaction_lock); =20 return ret; --=20 2.39.0 From nobody Mon Sep 15 15:58:01 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C555EC46467 for ; Wed, 11 Jan 2023 13:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232874AbjAKNqn (ORCPT ); Wed, 11 Jan 2023 08:46:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234223AbjAKNqV (ORCPT ); Wed, 11 Jan 2023 08:46:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE159631F for ; Wed, 11 Jan 2023 05:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673444758; x=1704980758; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M0K6BPFNHtGJsQXxOTjDHE/+MPRCH1csScxb1OhpftI=; b=IY+z7nnF75FxHIjyUCWASBE/iT77zAxfQ0+7+RFL/5igR8V1dMYlB7/e nXgokxFI3ZEMwwhGHnWtKo6QWffS1+uj76NYfJ3tutXMvvK6xisYHXGY1 iZLIR/lgcm7wnFfbhNdY7slRIngY3zI3xpqV2ebzQj3WpzokZa/VrDgZr Mfsvpqa7+qAaztSIkuwXyB988BAJQnULiNXdneMAEAfXH63eTHDRa2Kue 80Z6MteiZYicH3rBRV4C8E+d4iX0NwfNNQwiHJe6FFz+VqfVwzOClVVuN 1c5tRlVDhnaVagmeiBpnUQdF+ih9SjiMw9QZ6FFvmTw/4rTLONSCTLGXB A==; X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="207325811" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 11 Jan 2023 06:45:58 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Wed, 11 Jan 2023 06:45:57 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Wed, 11 Jan 2023 06:45:56 -0700 From: Conor Dooley To: Jassi Brar CC: Conor Dooley , Daire McNamara , , Subject: [PATCH v1 7/7] soc: microchip: mpfs: handle timeouts and failed services differently Date: Wed, 11 Jan 2023 13:45:13 +0000 Message-ID: <20230111134513.2495510-8-conor.dooley@microchip.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230111134513.2495510-1-conor.dooley@microchip.com> References: <20230111134513.2495510-1-conor.dooley@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The system controller will only deliver an interrupt if a service succeeds. This leaves us in the unfortunate position with current code where there is no way to differentiate between a legitimate timeout where the service has not completed & where it has completed, but failed. mbox_send_message() has its own completion, and it will time out of the system controller does not lower the busy flag. In this case, a timeout has occurred and the error can be propagated back to the caller. If the busy flag is lowered, but no interrupt has arrived to trigger the rx callback, the service can be deemed to have failed. Report EBADMSG in this case so that callers can differentiate. Signed-off-by: Conor Dooley --- drivers/soc/microchip/mpfs-sys-controller.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/micr= ochip/mpfs-sys-controller.c index 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_controlle= r *sys_controller, struct reinit_completion(&sys_controller->c); =20 ret =3D mbox_send_message(sys_controller->chan, msg); - if (ret < 0) + if (ret < 0) { + dev_warn(sys_controller->client.dev, + "MPFS sys controller service timeout\n"); goto out; + } =20 ret =3D 0; /* mbox_send_message returns 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 =3D -ETIMEDOUT; + ret =3D -EBADMSG; dev_warn(sys_controller->client.dev, - "MPFS sys controller transaction timeout\n"); + "MPFS sys controller service failed\n"); } =20 out: @@ -106,6 +117,7 @@ static int mpfs_sys_controller_probe(struct platform_de= vice *pdev) sys_controller->client.dev =3D dev; sys_controller->client.rx_callback =3D rx_callback; sys_controller->client.tx_block =3D 1U; + sys_controller->client.tx_tout =3D msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT= _MS); =20 sys_controller->chan =3D mbox_request_channel(&sys_controller->client, 0); if (IS_ERR(sys_controller->chan)) { --=20 2.39.0