From patchwork Tue May 7 15:35:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13657298 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 69AF2C10F1A for ; Tue, 7 May 2024 15:27:33 +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:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=oW8lNYkhp/54FhM+uPx1F1gEBG0BMhsCCrHzShv0FA0=; b=aqqJU4HSwFhXWpnQcGKAIIn9Kb 5rgNWq2RhRO5cjyF8Utcn+c7JD9Y6N1juuSbm6c+hsf+sNDJ8pBBXkTwixX9WsKBJLFoGhCAnHMbx VjET3B+FeN3fasjwykhizZ/KXa0ngynCUNkR5uSQfVVE133EEfEZpTK2smQhFGHzFzxZroChnZfNh pNHPuYyXi9JIXeewFkR0nkvowNVdRw4Hp3WE+/XGqUtm7kmCyIujNacOV+TZchxcfqhC+9ZqPYmSv d9xq5HiQFQKyPWf0HRqOaR6fTsEU0xIQXkaU2dCZqjUYle9XcENQOwI42DyfwBep48ect4wryJH8x 9aiNxH6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4Mit-0000000Bjkm-0Jdj; Tue, 07 May 2024 15:27:19 +0000 Received: from mail-db8eur05on20626.outbound.protection.outlook.com ([2a01:111:f400:7e1a::626] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4Mio-0000000Bjgf-3OOs for linux-arm-kernel@lists.infradead.org; Tue, 07 May 2024 15:27:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FmfLTSsJE309wxGqF284eaBJe78SVtJJuvMsGiqQv6Y1b0kUgrX14d+b21MA44Jm9d2mOQunYcd0qmPGSt9/33D/s3FXZTvBO7ecr8qd4QcDYp0d+/XKGaEeiEwmaVZtoUFZEII8srFoTZfLacB9QNK4zpOOn0/P4Htjb6W3EqKz7++PwnNoMoMFI9NRBwI2OHhj695h7QXouyKjYjwtT5BIaNdoTOnhZEVG0xp4YhkCKCB3u2Nhq38vFZu2Ezn0t1uuoc+UDgpmrrG1oXgeidQi5v1kigzr47lc9BcZ4CM43nTtsZfnR04Y5byLj/3zrJWFTnf1ogCyVv4NzWpgsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b8W6QroVXRCpCfE3XgHPNIW55+hj09hN6D5oQdhQUfU=; b=I1kZijLJxdJn+G+4ttjJthquTlTJG2Sgcx+/eQ+b7IgcOjOcDGPl6IGqY3dYYqEcAcXr00SUfRp9b+kUpI0LtgtYING0Sp+pAnxaNVTQTWtoDAOfUAk9S5Z5PBdWRwukxL+r3wggcdgMJciXJB/dJRvh3L4GoV8quC4JvsacMAOQc7Vn7FabBNLaD9VcpwPhTmCesSbEcsUP1wi7/HtixPGvFSbn5Imx4ckYrnf+4zf+Jx2z8NhaHY7PlLZcWPvniUAfpOG7wVALnyDMbzFW/xs0xgC60j2pffaCBJ/vtBDq2Qid1r1gDM3Ewr2vQ9valqrmEYoLRFi1DfVdRFEbAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b8W6QroVXRCpCfE3XgHPNIW55+hj09hN6D5oQdhQUfU=; b=fY8S2lN0vHYe/bXdyYpcZ42PkgvAPCZnpFpjrCYWHUlTPwATKzA4EjhBLiQ53CfXeqKJAD9z44PrDoRc9zbWsKS0roErdduktiirAKQytQotHr0WFSKpMvWDeXw70HmwrkXU9/NvKsBcudz2AFn+iUw5jSEUq1Pu39h3qHYLYyk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB9014.eurprd04.prod.outlook.com (2603:10a6:20b:430::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.42; Tue, 7 May 2024 15:27:09 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7544.041; Tue, 7 May 2024 15:27:09 +0000 From: "Peng Fan (OSS)" Date: Tue, 07 May 2024 23:35:01 +0800 Subject: [PATCH 2/2] firmware: arm_scmi: mailbox: support P2A channel completion Message-Id: <20240507-scmi-notify-v1-2-1fdefc984d53@nxp.com> References: <20240507-scmi-notify-v1-0-1fdefc984d53@nxp.com> In-Reply-To: <20240507-scmi-notify-v1-0-1fdefc984d53@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715096110; l=6970; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=NraZrTIh1CTKRDWgkHiH7fWJ14BXSdQDjIzIxPoolEU=; b=NidSZ+xByfvkRpnRR9RsCgCyIKNIB7dWBiIwq2/doiQs66LRCA9mMc0tWtrbRhID4GDrZicth S63ujB+PVvjCjG3GULCyRWnyGqUnVBItuHUXbhS3uKGC6X8FLjOv3gP X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2P153CA0018.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::9) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB9014:EE_ X-MS-Office365-Filtering-Correlation-Id: 8454446d-98d0-46b0-9e32-08dc6eaa28cf X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|376005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?nNIYPrWHIFhtnHtdJnjG4rzPag/DYf+?= =?utf-8?q?LeGMEjUpa5uhayRwKzxhQNCxhAiqEUbFm7FI3750UTekbJ2AZT9KNgG4FGW3JP6cT?= =?utf-8?q?0fb4VGiYCmvDWLpLZdpO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DF/DJchLNsDuno06g8/MbY7Ct4E1Tv?= =?utf-8?q?WKX3AZmJOc9KGPpxxaDIjjXKXC5gLZSCcy8/c1r+T9xUhLByWvspYQ/LvdvN+bS/4?= =?utf-8?q?y7JE6ZV6pAF2UBjnwXRXRX+x/vH8jsDH3mJLYsDyN9ZEkg5WBdHhhsm7PLqSH+g4F?= =?utf-8?q?5mrbsbDtOTY4IyiZiHCKW8R9+0HBayk4QvSDOpl6FUHkZ3hZPi+8M1WaZgDzq7zCN?= =?utf-8?q?MtS6ULGMTO9DtKcX5Lt6KUnuSj57LiaaDNx1jr2g6i+y9soEyWDvT0lsoJpVjUSEb?= =?utf-8?q?drbA35gbIzSixknrVWSnhpEHjKUJrph5LEw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(376005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/wE/d9B9B66fGnUgNQ9xLhddgDKU?= =?utf-8?q?zUioPmBwv3YlEmXY+w8HxGTc1QmirJZ4Q/jv2L9qBuEq0CX14/f3t2ZgY8cheCDij?= =?utf-8?q?EOXdwdpZ26XvEOsalaU08wx4/Y9ZjozwPoiXwjzK4vrnxfVKz7592dxE9N+ma5nyH?= =?utf-8?q?5CPolgVJ8ev8ztMvFZsF7Qob8WGNRNQQ3I6LilYpT36qhUNah1KkYOpfdDWomshMo?= =?utf-8?q?ZppHNfq5E7g4zpTRGg7UaUVJh5npe/A6+dd6aODaI5GldFLxKVmmGyV/NfApzZsqW?= =?utf-8?q?Yo47vmParbbx59glSBugyG6d16HGjr07j8zatL8GJG8PnWoVlonhXRNHxwZtfieCf?= =?utf-8?q?0UZ/6YuGinVBb/SqlqeFEGvUN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AnzbhpRV3KGyKnVtB4AHsDie4CZ69I2fm?= =?utf-8?q?cz3AMpFb0KvGS+FaBh9Hr/P39wY3xQaq3s7Up4vMnrliGpckStDvGBBHPtO38Fj17?= =?utf-8?q?6hVnUsBT1N+Kx2m0dSzRz19rBpMynY6AFVNuJGhyt1xcke8p105mr0Xb/dilzQYaW?= =?utf-8?q?HZiG2296scey+wA0H/DnOTsVXi/2+pCXPj7/msAu7n4f+Qg8y+z99Xhm88wGfd/1r?= =?utf-8?q?qkQ6pzmMOHpXwMWlig/1d3YvrdKPeS1FtqQHVS0mAi3o9Dr93gDEF0KE5ugid+6KY?= =?utf-8?q?VQ6b7C/jfHcO?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8454446d-98d0-46b0-9e32-08dc6eaa28cf X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2024 15:27:08.9349 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RbMNZXrV61PcoVBRbyov7DTClo7yCrSlpw0XK5QvCSc9DYdLEF9SfdaIQ6PB479FK/L7e5tyhp/aYg/Hw/woMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB9014 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240507_082715_058394_35972A0B X-CRM114-Status: GOOD ( 18.93 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan i.MX95 System Manager firmware is fully interrupt driven. The notification channel needs completion interrupt to drive its notification queue. Without completion interrupt, the notification will work abnormal. Add an optional mailbox channel. If the channel flag has INTR set, and the completion interrupt channel is provided, issue the mbox message to Platform after the channel is freed. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/common.h | 1 + drivers/firmware/arm_scmi/mailbox.c | 51 ++++++++++++++++++++++++++++++++----- drivers/firmware/arm_scmi/shmem.c | 5 ++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index b5ac25dbc1ca..4b8c5250cdb5 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -326,6 +326,7 @@ void shmem_clear_channel(struct scmi_shared_mem __iomem *shmem); bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem, struct scmi_xfer *xfer); bool shmem_channel_free(struct scmi_shared_mem __iomem *shmem); +bool shmem_channel_intr_enabled(struct scmi_shared_mem __iomem *shmem); /* declarations for message passing transports */ struct scmi_msg_payld; diff --git a/drivers/firmware/arm_scmi/mailbox.c b/drivers/firmware/arm_scmi/mailbox.c index 615a3b2ad83d..59a3085ce366 100644 --- a/drivers/firmware/arm_scmi/mailbox.c +++ b/drivers/firmware/arm_scmi/mailbox.c @@ -21,6 +21,7 @@ * @cl: Mailbox Client * @chan: Transmit/Receive mailbox uni/bi-directional channel * @chan_receiver: Optional Receiver mailbox unidirectional channel + * @chan_platform_receiver: Optional Platform Receiver mailbox unidirectional channel * @cinfo: SCMI channel info * @shmem: Transmit/Receive shared memory area */ @@ -28,6 +29,7 @@ struct scmi_mailbox { struct mbox_client cl; struct mbox_chan *chan; struct mbox_chan *chan_receiver; + struct mbox_chan *chan_platform_receiver; struct scmi_chan_info *cinfo; struct scmi_shared_mem __iomem *shmem; }; @@ -91,6 +93,8 @@ static bool mailbox_chan_available(struct device_node *of_node, int idx) * for replies on the a2p channel. Set as zero if not present. * @p2a_chan: A reference to the optional p2a channel. * Set as zero if not present. + * @p2a_rx_chan: A reference to the optional p2a completion channel. + * Set as zero if not present. * * At first, validate the transport configuration as described in terms of * 'mboxes' and 'shmem', then determin which mailbox channel indexes are @@ -98,8 +102,8 @@ static bool mailbox_chan_available(struct device_node *of_node, int idx) * * Return: 0 on Success or error */ -static int mailbox_chan_validate(struct device *cdev, - int *a2p_rx_chan, int *p2a_chan) +static int mailbox_chan_validate(struct device *cdev, int *a2p_rx_chan, + int *p2a_chan, int *p2a_rx_chan) { int num_mb, num_sh, ret = 0; struct device_node *np = cdev->of_node; @@ -109,8 +113,9 @@ static int mailbox_chan_validate(struct device *cdev, dev_dbg(cdev, "Found %d mboxes and %d shmems !\n", num_mb, num_sh); /* Bail out if mboxes and shmem descriptors are inconsistent */ - if (num_mb <= 0 || num_sh <= 0 || num_sh > 2 || num_mb > 3 || - (num_mb == 1 && num_sh != 1) || (num_mb == 3 && num_sh != 2)) { + if (num_mb <= 0 || num_sh <= 0 || num_sh > 2 || num_mb > 4 || + (num_mb == 1 && num_sh != 1) || (num_mb == 3 && num_sh != 2) || + (num_mb == 4 && num_sh != 2)) { dev_warn(cdev, "Invalid channel descriptor for '%s' - mbs:%d shm:%d\n", of_node_full_name(np), num_mb, num_sh); @@ -139,6 +144,7 @@ static int mailbox_chan_validate(struct device *cdev, case 1: *a2p_rx_chan = 0; *p2a_chan = 0; + *p2a_rx_chan = 0; break; case 2: if (num_sh == 2) { @@ -148,10 +154,17 @@ static int mailbox_chan_validate(struct device *cdev, *a2p_rx_chan = 1; *p2a_chan = 0; } + *p2a_rx_chan = 0; break; case 3: *a2p_rx_chan = 1; *p2a_chan = 2; + *p2a_rx_chan = 0; + break; + case 4: + *a2p_rx_chan = 1; + *p2a_chan = 2; + *p2a_rx_chan = 3; break; } } @@ -166,12 +179,12 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, struct device *cdev = cinfo->dev; struct scmi_mailbox *smbox; struct device_node *shmem; - int ret, a2p_rx_chan, p2a_chan, idx = tx ? 0 : 1; + int ret, a2p_rx_chan, p2a_chan, p2a_rx_chan, idx = tx ? 0 : 1; struct mbox_client *cl; resource_size_t size; struct resource res; - ret = mailbox_chan_validate(cdev, &a2p_rx_chan, &p2a_chan); + ret = mailbox_chan_validate(cdev, &a2p_rx_chan, &p2a_chan, &p2a_rx_chan); if (ret) return ret; @@ -229,6 +242,17 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, } } + if (!tx && p2a_rx_chan) { + smbox->chan_platform_receiver = mbox_request_channel(cl, p2a_rx_chan); + if (IS_ERR(smbox->chan_platform_receiver)) { + ret = PTR_ERR(smbox->chan_platform_receiver); + if (ret != -EPROBE_DEFER) + dev_err(cdev, "failed to request SCMI P2A Receiver mailbox\n"); + return ret; + } + } + + cinfo->transport_info = smbox; smbox->cinfo = cinfo; @@ -243,9 +267,11 @@ static int mailbox_chan_free(int id, void *p, void *data) if (smbox && !IS_ERR(smbox->chan)) { mbox_free_channel(smbox->chan); mbox_free_channel(smbox->chan_receiver); + mbox_free_channel(smbox->chan_platform_receiver); cinfo->transport_info = NULL; smbox->chan = NULL; smbox->chan_receiver = NULL; + smbox->chan_platform_receiver = NULL; smbox->cinfo = NULL; } @@ -300,8 +326,21 @@ static void mailbox_fetch_notification(struct scmi_chan_info *cinfo, static void mailbox_clear_channel(struct scmi_chan_info *cinfo) { struct scmi_mailbox *smbox = cinfo->transport_info; + int ret; shmem_clear_channel(smbox->shmem); + + if (smbox->chan_platform_receiver) { + if (!shmem_channel_intr_enabled(smbox->shmem)) + return; + + ret = mbox_send_message(smbox->chan_platform_receiver, NULL); + /* mbox_send_message returns non-negative value on success, so reset */ + if (ret > 0) + ret = 0; + + mbox_client_txdone(smbox->chan_platform_receiver, ret); + } } static bool diff --git a/drivers/firmware/arm_scmi/shmem.c b/drivers/firmware/arm_scmi/shmem.c index 8bf495bcad09..b74e5a740f2c 100644 --- a/drivers/firmware/arm_scmi/shmem.c +++ b/drivers/firmware/arm_scmi/shmem.c @@ -128,3 +128,8 @@ bool shmem_channel_free(struct scmi_shared_mem __iomem *shmem) return (ioread32(&shmem->channel_status) & SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE); } + +bool shmem_channel_intr_enabled(struct scmi_shared_mem __iomem *shmem) +{ + return ioread32(&shmem->flags) & SCMI_SHMEM_FLAG_INTR_ENABLED; +}