From patchwork Thu Aug 18 15:11:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12947293 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 06661C00140 for ; Thu, 18 Aug 2022 15:17:35 +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=YBOfdq82Qq4mS1G3VKoPNjXA+lpyFDtGYW3MX358oME=; b=r+Zd5rPZrQsKSo 2isFvCNA+QeIVhOCx1v4tbtUqb/IXt07WTLL3C8Kpj/TY8wLbLskDmXcwLeBydx0I66tthMtgM36a hOtFvzUCOehZ9EGTB1GBREuVuG1KJ24KpXZSXh+wcPyr0ryyn/LoG/Ia7IGeL2KxQ5i+d66z2oVxJ NsMFp2Oz6NAh8VGzVjq5F9+39gndpeH6177tSn8oxdbrV4FeWv8doYIOf0urDVsdnPhyyICSE7SJo +hPsmkaX2Horx/q6mX5SWD9UTV8majy9Q7oaj9yQwr9dTVMWQnVLCLNcXXiMBZ3BWgi3cD9lF9HsD 9cQwmXbCDROOZXCXfg4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhFc-006Vpn-Ns; Thu, 18 Aug 2022 15:16:06 +0000 Received: from mail-am6eur05on2080.outbound.protection.outlook.com ([40.107.22.80] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhBd-006TWK-Tt for linux-arm-kernel@lists.infradead.org; Thu, 18 Aug 2022 15:11:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FilaJm8WJ4mv8K7SkKAnTzQCdvO8KB974EEYb18SnExW3Kr2/c8KtA7jwTnLvoRp6X4zKZH9fLLyyhw9ek1+rp719oWS6An6OGGf0dfHi9CVjf936F0VqIv7nNjPeoik/oerqLQgOKLaCR56V1G1uup9l73Mh4IQLA/z8bw5zqJbZxpgGVq9J1NRssWBrvDVhNj4VYzgTT6WPkseEENNE6P6ULrlu35jVq0HTUiLv1d7IKRs+lo4AvQqjD4J0z0CpRj1XZ2ADrwGigNdd2ApMXIvwK7iywi3/TJeFGoiV7Qi6NUerOkYldFV6x6eCKBQu7+/FnR1kahXuTDLOg7oug== 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=PxyZmoQ4HPxt9JAZN3QVzBllZWpIazPpqniEWrzTllw=; b=BprdSuTI+P64SOqeTQzWn/O+FrdrqbR5bcNvLLtsq80lt/lyxqdTo+QiN+aVhRywr2kPZSNk3fwQYKupVI/xmRyh2GmP3IWtXz+Fuq20bEDpfg/tvmXeu6p2Wyes+VQVk73QTH9/IZlttHpQQL7/gcWd1ZgKrG1SYm8+TPqN2fXbKkGg5UTxG7lGfbXTLiI+nrGzAkfllVNeyChBTvC74OYHsweoIpDcLgefFjpd8lpR8oTaKeJA1hq5jDC07YwAQleNhMG/DQyff2PZ8etGGK06v+xF4fcDHnoqrFQgwdfYkb+10l5j2tx0q3oAuIZK6QOwj0fn8f13wtwyCEij0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PxyZmoQ4HPxt9JAZN3QVzBllZWpIazPpqniEWrzTllw=; b=JqOYbackT+upKDF5Qbg15kkR77MfoYd0HVJPnnS0YH8eMAFx0fu8kAwAMHlNVM6nuHwfIvknSuAj13jCihQNyxuGqq/Ilq90SmFLcydGAirjtPbQMjTWNrZUHuIDeR/SPNjhGyaxFOPqMMrzC/Myc3Tr45+G7czLweLDeBjOZGc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB5713.eurprd04.prod.outlook.com (2603:10a6:208:125::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:11:53 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c%3]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:11:53 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com Subject: [PATCH v6 1/4] irqchip: allow pass down .pm field at IRQCHIP_PLATFORM_DRIVER_END Date: Thu, 18 Aug 2022 10:11:24 -0500 Message-Id: <20220818151127.2449064-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818151127.2449064-1-Frank.Li@nxp.com> References: <20220818151127.2449064-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0141.namprd13.prod.outlook.com (2603:10b6:a03:2c6::26) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e208eae-693c-42e4-9a3a-08da812bfb8d X-MS-TrafficTypeDiagnostic: AM0PR04MB5713:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bvfwWvBA5amL9yHYFfkpE1WDS7ibdl1vEbbL9hWOH0tBFiWlHoV21qL5yGR0mQLbk/BqW2JIFW3YZTY0SMd/eWt3fRjXEefEWwGBBotCtcfKpa0dTXOdvN5jmeOTXQpZoVWu1ZyBK4W45QhUpwgsVEg0vrK1qVKlC1LYSTAdsaYvYyHHOuGor+rLY69CSV/JFGV0dh3CqcoR2sv1CilZDlXNK0M0/lia2xhxVOt9SGmqp7bYpYLbqwkmAVEA74ya6Z3ysEafZPbIMYJNDmRMzOZJdGckGgih62oZj8Ky1kQBM68U0NqvT/4ww2VhsBvMbkvk7hua8ZaN7ha+CyF7qP3vTpJT5ls7frw5j5noGgN0bHdHipiNs1SxDaaHFWSuUJwWs+bmLwCL+0fPv8zM0U3kHOhZU/QT7Ks1z0N0Nq0lBXhx+1GWYvJTzwPeb8jkYM0O5VoUeUcL6rRnHpPqNr76Fm94aIqBWoDi8M4XDnzZEoAxBgNSaBQ/8ZXzxP2z2TvLTEpzH6TRAJy9/sJvL2t9UYol0fDpYGhRU0qieA61yttryd3gt0esnmtED1PaGQkRWr/G7g89LmOXfLxmotUqQe5wfiMbwc42IMIEdw11O4InGoAWT6GwjwScMuXucOj+NhEi1S0J9B/SalR9PqmdOKaBZnuA03gmFKTj9idbj1xBhw+JIfBHUIbBf1L6TOJMjrWgkbszrjZgb9aFOVNQWxreR1Z1bVIwYtHmw2mvkyzzZQORfnAvlZHe5dkPJSseLOzI7B+tYcazWiLOfw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2616005)(316002)(1076003)(186003)(83380400001)(36756003)(38350700002)(38100700002)(6506007)(52116002)(4326008)(66946007)(66476007)(66556008)(2906002)(8676002)(6486002)(86362001)(6512007)(41300700001)(478600001)(26005)(6666004)(8936002)(5660300002)(7416002)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PrJHPDQliS87q+bg9R7PHgtQ2fJtToVoan0SFxHjojiiV/YvfAbKt8nAkGmR2wYedH/dnH2Pao4bS0+bAUut1hvPazRRrAX8Z3X/SVZ5AtVXAj85GS5jrH82dgSTDHUbG7qhzfGXnIk3vJcQJKQ5lMGCfMy2VLAX7sxQczhGwJfMuWZ0hhNZt0CyK/PwRjYumuXjfzrlXh50G6TwavpoHojz77x8MGe714UIrMah17kFYeEt+mt5eeicl3eFdpQpxzCG+Fd3rcarmkYwg27jh3sYvhTp5cWGcOPFqoedfZM2FxNpSVsLvBZdkWvnZpPWzMiyKku8mP7cj3gXhETKXUNFL5+T/hKh6iSdFPdkm9R2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aedkEGh+EHu8N6y1tZ6IuCt1K5/178dt/2iN0xWQpzhy3/fCnbLZE8R0c8Z4OUSF8uSdHhQR9fsnVwZ7LBZQ+CknEDHzQvWq1Rmq5fb1rl+3iL6Em39mkmoYmDyD9yz96tNbR2BrYuzZqqhdE= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e208eae-693c-42e4-9a3a-08da812bfb8d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:11:53.4971 (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: 4jobOm0K/E/a/JCE+0jARUIrdM3wjIzW8CELUJ6HOQMOMXyGj6IOjdQMLsQs7PsGHF/Gt8VvlpGXLD/oxzG9aA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5713 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220818_081158_001272_EF6A5A7D X-CRM114-Status: GOOD ( 11.42 ) 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 IRQCHIP_PLATFORM_DRIVER_* compilation define platform_driver for irqchip. But can't set .pm field of platform_driver. Added variadic macros to set .pm field or other field if need. Signed-off-by: Frank Li --- include/linux/irqchip.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h index 3a091d0710ae1..d5e6024cb2a8c 100644 --- a/include/linux/irqchip.h +++ b/include/linux/irqchip.h @@ -44,7 +44,8 @@ static const struct of_device_id drv_name##_irqchip_match_table[] = { #define IRQCHIP_MATCH(compat, fn) { .compatible = compat, \ .data = typecheck_irq_init_cb(fn), }, -#define IRQCHIP_PLATFORM_DRIVER_END(drv_name) \ + +#define IRQCHIP_PLATFORM_DRIVER_END(drv_name, ...) \ {}, \ }; \ MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table); \ @@ -56,6 +57,7 @@ static struct platform_driver drv_name##_driver = { \ .owner = THIS_MODULE, \ .of_match_table = drv_name##_irqchip_match_table, \ .suppress_bind_attrs = true, \ + __VA_ARGS__ \ }, \ }; \ builtin_platform_driver(drv_name##_driver) From patchwork Thu Aug 18 15:11:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12947294 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 87247C00140 for ; Thu, 18 Aug 2022 15:18:32 +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=7I1U+t41AzMFbU8zTnGX4R9uyGLeNRa2tsUGeV794rQ=; b=0+AUMZGxUUo4E0 p8LCElwvvtmUV0nNtr6rm5MiyYzh8u/f6mYY19meJlNilVWajZm9VM/Hr6w1w3ATnJf+PYZJ0be1L UUgWrA2HjSzEDYdIxqlX4WOxATIotKPzktHSA63AmFyk7B1Sln49iax05+4qpExrevrCsumzHvu2B 7LqDL5KdCSmkEult6Vyrx2RPu6hYuz//CWp7n4jWxN4aqBYReqyv3ERn80loa8vmjnbR9q2BaaXI4 ol3ckjGLxuOCE5oEyeJJVJImvmgz1JxM73bf1HOEDnXOERv5LRBXQhD6b191A0W+zTGnvj/cFpeUj bmP5CwM+VL82zV1zT1mA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhGM-006WJp-Vf; Thu, 18 Aug 2022 15:16:53 +0000 Received: from mail-db8eur05on2064.outbound.protection.outlook.com ([40.107.20.64] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhBj-006TfN-Sa for linux-arm-kernel@lists.infradead.org; Thu, 18 Aug 2022 15:12:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bdr981/0MXCj7CiebgeePX0Ux6NJBpQyw9TTQMyvEjFnjHqSx0foIDT2SqczLvxr8q1kV9ATc7wR9rA2zTW/qzrcNRtpEjz0C8JGn2KOiKYo+F1Ju8wakLrOXq89MkImRSVvdP5Dd0iDzZD5/PjJrxIK9ugJXsu+OaXpNj5q0mzbWz4dUXrHT+DZXX1P2xjjI/ENttXL+rL/zQ1pBmf967SPtlGyYt68hfc8m/vqsy3ISGojinsa0cEB62b8Zo5aPC2q5alijU+4jo/hP7Eq6qntp82bPB9G9hdtiwXLSdTmXe4+lgtipz08nTyJ/PLFwRzRioMUJTKGAfpExBiEog== 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=0FTN6H7ukeDkJqVfwyfo0imFQDw/M5zvxApyhzWREEs=; b=S82FDo6HxXwXfDzlhfrdH0KwyePr/wfz6undhnkH5FXQ2FvYSt7yf5s+Gq11DSrEH9MmksRcXUnwfLdnNi2Gixu5lfKW78T4pS+LrWmlFwGPWbs4r0BF+h1T4bM6jbSMuuh95xBTF8PHcjJLoEXjcqIY4V1ac6fe1s2T0q2F1tDo+od92Y5ypqwp8TEe+oAebvlojkhJ7kkwssitieCN02DvPHVVTQQy1Hz1Ll5rbKPdR2L+RSOj7gcU47FdQhGBBJPWOxwu5Eq5XVlBZW3Vg4GaOfA/b9Q0w5irunYbE2h7Zozro1t5xy2/NWmPYi3RxO5IUI86a8lDVfqdzwjiwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0FTN6H7ukeDkJqVfwyfo0imFQDw/M5zvxApyhzWREEs=; b=e0V2N5nV1B/UOi9vvHbbwJjZvrBmAcxzzQjkRkuS70XQqb6PB1srBMopni4USAf18keb0P1wuX2L1T+mdvO9EPzDAYA4oGUjtT9DJJMRJBgoQAFMMaCRwonk4K40Y8lEjXmRy2EQ661wkcKZ1CLA/3Ux3jahgvpIAiw4ZsFCUoQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB5713.eurprd04.prod.outlook.com (2603:10a6:208:125::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:11:59 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c%3]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:11:59 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com Subject: [PATCH v6 2/4] irqchip: Add IMX MU MSI controller driver Date: Thu, 18 Aug 2022 10:11:25 -0500 Message-Id: <20220818151127.2449064-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818151127.2449064-1-Frank.Li@nxp.com> References: <20220818151127.2449064-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0141.namprd13.prod.outlook.com (2603:10b6:a03:2c6::26) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b3571e1-49e8-447e-9bc3-08da812bff4c X-MS-TrafficTypeDiagnostic: AM0PR04MB5713:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SMgbQl+sKmukAu5jwqIka5KMKS/TM1Smi9sfLjDVk5ka2Pfq6ZJw4XdflgzhV1ziy9y6Rt25rN6TY0oZwLPq16huyFp1bB9tNw1+n2u4Nwh6B7RkVNJu5kM4vKe10YL5R1auzIishcAROIE41dMrjYJktT5wiBrn7Zy7dr4OTkB77UV1XoOTNBx8j6J/Tf7XIrk+tA+4yjuqZ9shhEvuQFmIpml3rnFi1N7dMXUemyXR4FMsQ3iF3NkvOa4dyer61PIdVIhvvM2os5egW1DAuFE3vMvZQdvga5yvun6mQ0Z/z8ohrVaBzULo2pp2ABJZ+7iGMVzk/jDqI+1uuVfCTswO8GwnvmGUpHbQqfvKa/1AXkhdZLMRr1ZFO1+FjCwq9ThhYrFjyhgfSmogeGs3EqAsJk3pcbucdAj1svEMPqEvPk3Cxpo1vgR5/Nu6B1a8aAOZrC8lxZWbzgWEamTcrnz+Xv5pWDsxHnSG84y8yF0yGS2l7oDacJLBEDEgr6c9EQzhy0p6hjej+qLGzsBvfIVAV+LC7DhgI87sz+GkSpqO/45FfhO710PVMVpVOd7RV3xPDs4mn8JdEdPqV+RJ11uJQRtz/Syu7xrhwrH6Aj0TNyXioBwEo9gL2Qa7ainJXrYoZR5+Pxa19UeFdF7I6Fvesm2kKQBVianYwbrljRl8ZKwQDbQhVG/6NwQksMxpPwR35FzpB/jweP2U1zdYgLHItX4nWUoCz1cUorT8woG+5uoAfiPD4sg598a4/91ep2PIDdWofRcf3KyHaZ+AFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2616005)(316002)(1076003)(186003)(83380400001)(36756003)(38350700002)(38100700002)(6506007)(52116002)(4326008)(66946007)(66476007)(66556008)(2906002)(8676002)(6486002)(86362001)(6512007)(41300700001)(478600001)(26005)(6666004)(8936002)(5660300002)(7416002)(30864003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData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J30SqFCA+eXy48oGGnh2Jza6C4UFBJBbTAe0i5upv4o+G+VVIpqh5U/lgQ6eodFT/u+2l3/MaPhnmP8w7xnHbzilC2RyAAtWxoexRMQGk3+Pv+EOghuFAZgYOe9kuHXk9J0d6teotiQKzpS6oW/cX2LmF9VerduJXJyeQwhE2w7E/iV76fjGzx3JTQAv3uf55IjxhfpqLTJzk/bydQB93bPwF+AgTtIRPg8UUKV+nVkFSRmNSAwUHGNTaD9/wB3Lurc7jfKEuSSnm3TXUyZfDLGA3PSuptShimplq9cXGlShaFn6hpO57czwEeBF+ldmWz2Ol9LPyxOTqRL71GTrVsPlc+c0/ikxycmdJmbI95wKknF/JG0yyuTdAHNoTcyiYEqhXNtb744aMfjACXFXHoi3MsqgQyW2zeSWI/IBXpCqicBZMdWVaIYnwtljzyhr1vVq3LCmFUM6bilT76XbxLdWfASmNn9r8jyORRPLudiCzRWfsa0E7fqEJMOuiwfEKqUETAYkGgCOdLz24= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b3571e1-49e8-447e-9bc3-08da812bff4c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:11:59.7195 (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: lkfH0RzbAGyBsmH6vB3lVFX02/3H8nBJqLd4guCGnDojM1Q04++41APZY51kil+1urPKigX8hmzttHCVSF436w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5713 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220818_081204_134855_368FDAE6 X-CRM114-Status: GOOD ( 21.39 ) 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 The MU block found in a number of Freescale/NXP SoCs supports generating IRQs by writing data to a register This enables the MU block to be used as a MSI controller, by leveraging the platform-MSI API Signed-off-by: Frank Li --- drivers/irqchip/Kconfig | 9 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-imx-mu-msi.c | 451 +++++++++++++++++++++++++++++++ 3 files changed, 461 insertions(+) create mode 100644 drivers/irqchip/irq-imx-mu-msi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 5e4e50122777d..e04c6521dce55 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -470,6 +470,15 @@ config IMX_INTMUX help Support for the i.MX INTMUX interrupt multiplexer. +config IMX_MU_MSI + bool "i.MX MU work as MSI controller" + default y if ARCH_MXC + select IRQ_DOMAIN + select IRQ_DOMAIN_HIERARCHY + select GENERIC_MSI_IRQ_DOMAIN + help + MU work as MSI controller to do general doorbell + config LS1X_IRQ bool "Loongson-1 Interrupt Controller" depends on MACH_LOONGSON32 diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 5d8e21d3dc6d8..870423746c783 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -98,6 +98,7 @@ obj-$(CONFIG_RISCV_INTC) += irq-riscv-intc.o obj-$(CONFIG_SIFIVE_PLIC) += irq-sifive-plic.o obj-$(CONFIG_IMX_IRQSTEER) += irq-imx-irqsteer.o obj-$(CONFIG_IMX_INTMUX) += irq-imx-intmux.o +obj-$(CONFIG_IMX_MU_MSI) += irq-imx-mu-msi.o obj-$(CONFIG_MADERA_IRQ) += irq-madera.o obj-$(CONFIG_LS1X_IRQ) += irq-ls1x.o obj-$(CONFIG_TI_SCI_INTR_IRQCHIP) += irq-ti-sci-intr.o diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-msi.c new file mode 100644 index 0000000000000..110e5df1d6aa8 --- /dev/null +++ b/drivers/irqchip/irq-imx-mu-msi.c @@ -0,0 +1,451 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Freescale MU worked as MSI controller + * + * Copyright (c) 2018 Pengutronix, Oleksij Rempel + * Copyright 2022 NXP + * Frank Li + * Peng Fan + * + * Based on drivers/mailbox/imx-mailbox.c + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define IMX_MU_CHANS 4 + +enum imx_mu_xcr { + IMX_MU_GIER, + IMX_MU_GCR, + IMX_MU_TCR, + IMX_MU_RCR, + IMX_MU_xCR_MAX, +}; + +enum imx_mu_xsr { + IMX_MU_SR, + IMX_MU_GSR, + IMX_MU_TSR, + IMX_MU_RSR, +}; + +enum imx_mu_type { + IMX_MU_V1 = BIT(0), + IMX_MU_V2 = BIT(1), + IMX_MU_V2_S4 = BIT(15), +}; + +/* Receive Interrupt Enable */ +#define IMX_MU_xCR_RIEn(data, x) ((data->cfg->type) & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x)))) +#define IMX_MU_xSR_RFn(data, x) ((data->cfg->type) & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x)))) + +struct imx_mu_dcfg { + enum imx_mu_type type; + u32 xTR; /* Transmit Register0 */ + u32 xRR; /* Receive Register0 */ + u32 xSR[4]; /* Status Registers */ + u32 xCR[4]; /* Control Registers */ +}; + +struct imx_mu_msi { + spinlock_t lock; + raw_spinlock_t reglock; + struct irq_domain *msi_domain; + void __iomem *regs; + phys_addr_t msiir_addr; + const struct imx_mu_dcfg *cfg; + unsigned long used; + struct clk *clk; +}; + +static void imx_mu_write(struct imx_mu_msi *msi_data, u32 val, u32 offs) +{ + iowrite32(val, msi_data->regs + offs); +} + +static u32 imx_mu_read(struct imx_mu_msi *msi_data, u32 offs) +{ + return ioread32(msi_data->regs + offs); +} + +static u32 imx_mu_xcr_rmw(struct imx_mu_msi *msi_data, enum imx_mu_xcr type, u32 set, u32 clr) +{ + unsigned long flags; + u32 val; + + raw_spin_lock_irqsave(&msi_data->reglock, flags); + val = imx_mu_read(msi_data, msi_data->cfg->xCR[type]); + val &= ~clr; + val |= set; + imx_mu_write(msi_data, val, msi_data->cfg->xCR[type]); + raw_spin_unlock_irqrestore(&msi_data->reglock, flags); + + return val; +} + +static void imx_mu_msi_parent_mask_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + + imx_mu_xcr_rmw(msi_data, IMX_MU_RCR, 0, IMX_MU_xCR_RIEn(msi_data, data->hwirq)); +} + +static void imx_mu_msi_parent_unmask_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + + imx_mu_xcr_rmw(msi_data, IMX_MU_RCR, IMX_MU_xCR_RIEn(msi_data, data->hwirq), 0); +} + +static void imx_mu_msi_parent_ack_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + + imx_mu_read(msi_data, msi_data->cfg->xRR + data->hwirq * 4); +} + +static struct irq_chip imx_mu_msi_irq_chip = { + .name = "MU-MSI", + .irq_ack = irq_chip_ack_parent, +}; + +static struct msi_domain_ops imx_mu_msi_irq_ops = { +}; + +static struct msi_domain_info imx_mu_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS), + .ops = &imx_mu_msi_irq_ops, + .chip = &imx_mu_msi_irq_chip, +}; + +static void imx_mu_msi_parent_compose_msg(struct irq_data *data, + struct msi_msg *msg) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + u64 addr = msi_data->msiir_addr + 4 * data->hwirq; + + msg->address_hi = upper_32_bits(addr); + msg->address_lo = lower_32_bits(addr); + msg->data = data->hwirq; +} + +static int imx_mu_msi_parent_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) +{ + return -EINVAL; +} + +static struct irq_chip imx_mu_msi_parent_chip = { + .name = "MU", + .irq_mask = imx_mu_msi_parent_mask_irq, + .irq_unmask = imx_mu_msi_parent_unmask_irq, + .irq_ack = imx_mu_msi_parent_ack_irq, + .irq_compose_msi_msg = imx_mu_msi_parent_compose_msg, + .irq_set_affinity = imx_mu_msi_parent_set_affinity, +}; + +static int imx_mu_msi_domain_irq_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) +{ + struct imx_mu_msi *msi_data = domain->host_data; + unsigned long flags; + int pos, err = 0; + + WARN_ON(nr_irqs != 1); + + spin_lock_irqsave(&msi_data->lock, flags); + pos = find_first_zero_bit(&msi_data->used, IMX_MU_CHANS); + if (pos < IMX_MU_CHANS) + __set_bit(pos, &msi_data->used); + else + err = -ENOSPC; + spin_unlock_irqrestore(&msi_data->lock, flags); + + if (err) + return err; + + irq_domain_set_info(domain, virq, pos, + &imx_mu_msi_parent_chip, msi_data, + handle_edge_irq, NULL, NULL); + return 0; +} + +static void imx_mu_msi_domain_irq_free(struct irq_domain *domain, + unsigned int virq, unsigned int nr_irqs) +{ + struct irq_data *d = irq_domain_get_irq_data(domain, virq); + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(d); + unsigned long flags; + + spin_lock_irqsave(&msi_data->lock, flags); + __clear_bit(d->hwirq, &msi_data->used); + spin_unlock_irqrestore(&msi_data->lock, flags); +} + +static const struct irq_domain_ops imx_mu_msi_domain_ops = { + .alloc = imx_mu_msi_domain_irq_alloc, + .free = imx_mu_msi_domain_irq_free, +}; + +static void imx_mu_msi_irq_handler(struct irq_desc *desc) +{ + struct imx_mu_msi *msi_data = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + u32 status; + int i; + + status = imx_mu_read(msi_data, msi_data->cfg->xSR[IMX_MU_RSR]); + + chained_irq_enter(chip, desc); + for (i = 0; i < IMX_MU_CHANS; i++) { + if (status & IMX_MU_xSR_RFn(msi_data, i)) + generic_handle_domain_irq(msi_data->msi_domain, i); + } + chained_irq_exit(chip, desc); +} + +static int imx_mu_msi_domains_init(struct imx_mu_msi *msi_data, struct device *dev) +{ + struct fwnode_handle *fwnodes = dev_fwnode(dev); + struct irq_domain *parent; + + /* Initialize MSI domain parent */ + parent = irq_domain_create_linear(fwnodes, + IMX_MU_CHANS, + &imx_mu_msi_domain_ops, + msi_data); + if (!parent) { + dev_err(dev, "failed to create IRQ domain\n"); + return -ENOMEM; + } + + irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS); + + msi_data->msi_domain = platform_msi_create_irq_domain( + fwnodes, + &imx_mu_msi_domain_info, + parent); + + if (!msi_data->msi_domain) { + dev_err(dev, "failed to create MSI domain\n"); + irq_domain_remove(parent); + return -ENOMEM; + } + + irq_domain_set_pm_device(msi_data->msi_domain, dev); + + return 0; +} + +/* Register offset of different version MU IP */ +static const struct imx_mu_dcfg imx_mu_cfg_imx6sx = { + .xTR = 0x0, + .xRR = 0x10, + .xSR = {0x20, 0x20, 0x20, 0x20}, + .xCR = {0x24, 0x24, 0x24, 0x24}, +}; + +static const struct imx_mu_dcfg imx_mu_cfg_imx7ulp = { + .xTR = 0x20, + .xRR = 0x40, + .xSR = {0x60, 0x60, 0x60, 0x60}, + .xCR = {0x64, 0x64, 0x64, 0x64}, +}; + +static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp = { + .type = IMX_MU_V2, + .xTR = 0x200, + .xRR = 0x280, + .xSR = {0xC, 0x118, 0x124, 0x12C}, + .xCR = {0x110, 0x114, 0x120, 0x128}, +}; + +static const struct imx_mu_dcfg imx_mu_cfg_imx8ulp_s4 = { + + .type = IMX_MU_V2 | IMX_MU_V2_S4, + .xTR = 0x200, + .xRR = 0x280, + .xSR = {0xC, 0x118, 0x124, 0x12C}, + .xCR = {0x110, 0x114, 0x120, 0x128}, +}; + +static int __init imx_mu_of_init(struct device_node *dn, + struct device_node *parent, + const struct imx_mu_dcfg *cfg + ) +{ + struct platform_device *pdev = of_find_device_by_node(dn); + struct device_link *pd_link_a; + struct device_link *pd_link_b; + struct imx_mu_msi *msi_data; + struct resource *res; + struct device *pd_a; + struct device *pd_b; + struct device *dev; + int ret; + int irq; + + if (!pdev) + return -ENODEV; + + dev = &pdev->dev; + + msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL); + if (!msi_data) + return -ENOMEM; + + msi_data->cfg = cfg; + + msi_data->regs = devm_platform_ioremap_resource_byname(pdev, "processor a-facing"); + if (IS_ERR(msi_data->regs)) { + dev_err(&pdev->dev, "failed to initialize 'regs'\n"); + return PTR_ERR(msi_data->regs); + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "processor b-facing"); + if (!res) + return -EIO; + + msi_data->msiir_addr = res->start + msi_data->cfg->xTR; + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) + return -ENODEV; + + platform_set_drvdata(pdev, msi_data); + + msi_data->clk = devm_clk_get(dev, NULL); + if (IS_ERR(msi_data->clk)) { + if (PTR_ERR(msi_data->clk) != -ENOENT) + return PTR_ERR(msi_data->clk); + + msi_data->clk = NULL; + } + + pd_a = dev_pm_domain_attach_by_name(dev, "processor a-facing"); + if (IS_ERR(pd_a)) + return PTR_ERR(pd_a); + + pd_b = dev_pm_domain_attach_by_name(dev, "processor b-facing"); + if (IS_ERR(pd_b)) + return PTR_ERR(pd_b); + + pd_link_a = device_link_add(dev, pd_a, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + + if (!pd_link_a) { + dev_err(dev, "Failed to add device_link to mu a.\n"); + goto err_pd_a; + } + + pd_link_b = device_link_add(dev, pd_b, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + + + if (!pd_link_b) { + dev_err(dev, "Failed to add device_link to mu a.\n"); + goto err_pd_b; + } + + ret = imx_mu_msi_domains_init(msi_data, dev); + if (ret) + goto err_dm_init; + + irq_set_chained_handler_and_data(irq, + imx_mu_msi_irq_handler, + msi_data); + + pm_runtime_enable(dev); + + return 0; + +err_dm_init: + device_link_remove(dev, pd_b); +err_pd_b: + device_link_remove(dev, pd_a); +err_pd_a: + return -EINVAL; +} + +static int __maybe_unused imx_mu_runtime_suspend(struct device *dev) +{ + struct imx_mu_msi *priv = dev_get_drvdata(dev); + + clk_disable_unprepare(priv->clk); + + return 0; +} + +static int __maybe_unused imx_mu_runtime_resume(struct device *dev) +{ + struct imx_mu_msi *priv = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(priv->clk); + if (ret) + dev_err(dev, "failed to enable clock\n"); + + return ret; +} + +static const struct dev_pm_ops imx_mu_pm_ops = { + SET_RUNTIME_PM_OPS(imx_mu_runtime_suspend, + imx_mu_runtime_resume, NULL) +}; + +static int __init imx_mu_imx7ulp_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx7ulp); +} + +static int __init imx_mu_imx6sx_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx6sx); +} + +static int __init imx_mu_imx8ulp_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx8ulp); +} + +static int __init imx_mu_imx8ulp_s4_of_init(struct device_node *dn, + struct device_node *parent) +{ + return imx_mu_of_init(dn, parent, &imx_mu_cfg_imx8ulp_s4); +} + +IRQCHIP_PLATFORM_DRIVER_BEGIN(imx_mu_msi) +IRQCHIP_MATCH("fsl,imx7ulp-mu-msi", imx_mu_imx7ulp_of_init) +IRQCHIP_MATCH("fsl,imx6sx-mu-msi", imx_mu_imx6sx_of_init) +IRQCHIP_MATCH("fsl,imx8ulp-mu-msi", imx_mu_imx8ulp_of_init) +IRQCHIP_MATCH("fsl,imx8ulp-mu-msi-s4", imx_mu_imx8ulp_s4_of_init) +IRQCHIP_PLATFORM_DRIVER_END(imx_mu_msi, .pm = &imx_mu_pm_ops) + + +MODULE_AUTHOR("Frank Li "); +MODULE_DESCRIPTION("Freescale MU MSI controller driver"); +MODULE_LICENSE("GPL"); From patchwork Thu Aug 18 15:11:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12947295 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 3AABAC00140 for ; Thu, 18 Aug 2022 15:19:17 +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=yWjEcPXbZKDS9LV/ZmXI/sgtVTqWTEZIFzOS1D1VELw=; b=rdbNgHLeHCYtG2 H2w+AAz9T15xSGa5ommQurVWnDEqJDDH3DsRFF9T9YPK9dGYKtyd9AtjdPWSkWeMkmnIdUJvornHt iotU4lqDeH2MGpAgXgpWZRk+4PtDTcvG3w9bbdJOcV4ZeRZ7OQqq1raaipEZKEAAPDIIpThmjfsVR Z4PSJuGXjTv7Csb/1JQIYwXf1+M4z+nX6Avhui0UtVL5i5iZBCETlnttEOCYGC1Y42Y208M/qNwbW FarS0slrDm2M18mbqzVqctfsJNIf1MMnaM4DpoJPtCPUrw2xo3iApAwwEcWcWjivdyFu1V7ecEdIU fw0xAPIKPhu+jeYtIQhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhHJ-006Wk5-PW; Thu, 18 Aug 2022 15:17:51 +0000 Received: from mail-db8eur05on2064.outbound.protection.outlook.com ([40.107.20.64] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhBm-006TfN-PJ for linux-arm-kernel@lists.infradead.org; Thu, 18 Aug 2022 15:12:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SpLSUfyEY2okFKNvyDJzPlhqGcjx1og0EkYo+5WVTIoUP9YGOznv6rzqfsRNzl3XjsrouSvTTXUxY/w+zmY1BOzy/L87BUQ9JWSZPR1NHg3e7JTAXJevvf08uL72Cn/35mSDgLPUzhel90Iq0phiS4DPubyXtctigYy7qYAMzfPvRDIudWCv0ifWbDz+nXsG3la7ucvUNo9k2v8q4B2HyGn6Toet79tOVv2qIs0Z/qb67AGa73qf/wkMbXRlVRI6fC5i0KOPRzvZN/NbfiJQFIiLkTmN8CQa1IbW53YmoylAobkgF5iwLPE/4aULM+Ls3Mg3w8KFW0DHAdbCWX3KJg== 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=OVFJJkHBYbxdRZKhWWlDd3nZUmM3IMXu087up/Kc5H4=; b=O5s6Pvtj2B9C4YCwtwG9rXb69LP6RtjKzb5sFlOo1bEnlfqZBoiRLU15gkCCf0UMb5aGI09wNZpLINf10lIsA/p8hys75vCYTwsuG9eIUzXl/3cSWxOlmFYD4IndssBUqv7gu3a2g+20PjcVIN78iX/cBPq7MlGJseJwedpMQ5fWNdnj9urfzlsPKrQOvvDlilMGbGIPEexez29jGBFtp5a1/ny4bWUBc3JKltbr7rXCUecoLoTle+MqU9LH/UhEX3QoReDbebO6F/ZswoRVuOiKRUG6AG6nSsvWcmVEliuhkwBIOZU846GAxbHhXZOKX8zKO2wNjEt8esDzJ0+s0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OVFJJkHBYbxdRZKhWWlDd3nZUmM3IMXu087up/Kc5H4=; b=E/ZPgUp/zqQkHgvNj0UJ65OD0sFOaeRGmOzk5qKNao5IHjAlfki+bvFRXniWsYNy3UnJlgw4tGMQvSnBTmCe6tg5/i6hDO9jY/L+WqPCOhBoRw+jvK0uR5PfAekSUDQbGyHMY5D1QGoEC0Q03L297ZRRqb/cdJN0YbWyWym0IT8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB5713.eurprd04.prod.outlook.com (2603:10a6:208:125::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:12:05 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c%3]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:12:05 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com Subject: [PATCH v6 3/4] dt-bindings: irqchip: imx mu work as msi controller Date: Thu, 18 Aug 2022 10:11:26 -0500 Message-Id: <20220818151127.2449064-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818151127.2449064-1-Frank.Li@nxp.com> References: <20220818151127.2449064-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0141.namprd13.prod.outlook.com (2603:10b6:a03:2c6::26) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86e43333-e1b3-4fd0-57b7-08da812c02af X-MS-TrafficTypeDiagnostic: AM0PR04MB5713:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WDXnbX+NmEhXbbCh0soY36n1+mp636e/o7t78uHbjgvGs0gck+JKr001AWzefEKq3aGEaca4TGlFDROVBO3tjNjC1R02Ph42fn/La25Iuv4BOFksID+RKCRtcCNpru0vWyxANV0+3XJerofMjxoco7kicvG7J+l7tLwhSJVCQveUL5Z8SIMJwAu3+NxxBUPCJ1DgybGrhNw9+RllV2zP2xMUGuo22ThromRn+Mb9Eoj7WKX+MouJPpaMcDItfDtwrRJ9AjpHXNq7xX8cUQ/jPxd4MoS5IDUrd8do9v5CUSewyMfR5SnQRK3LfR4PpiKPotY2oXWKrsao/VrXQPps9OLPkbFMxMeWvwnno/RUtK2cuLJ3fi44uJh2By/JDuXcnDYejuWTPuQWKtAP4HysqNwYYIXAzTvdt9mQgUgM09B0yLXcyGpRbhcm5VuTiZLQoca9haZ8jVMR27yv1YlLEI3a4hHDXeGJAbzyH4auJ7HymLrm5QC42G9HADpS1UXv1DCD861ngomDDFgTqSIfaoigFkEqAveNZLFm2PNs3epxIFvBsAdcidRYo/EvtVKSOcrOILM9d6pjv18cnr/rL101BVIf/MYLxRIwotcWSCoaai3458mxnxQ+ac99stBbcdYCUXxjKglfuueO5gI1I+pjfY06Rk34kg00sX+MKR8y23AIlAhHFaXFCQAphf7f/F0bJnyzxROCt+yPP/RuF29VZnzxL7Je0jLKex3XSRRAchjcyXxOZZeax4Hv89UGI4nIAqvsfd7FqAn/R6w2sTlmeOpv/Xh2ej67YgsHuJUGeEuM8Jme4v3ZpTx61RcArX2kDWKWRmkv7lYuPQ2kEQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2616005)(316002)(1076003)(186003)(83380400001)(36756003)(38350700002)(38100700002)(6506007)(52116002)(4326008)(66946007)(66476007)(66556008)(2906002)(966005)(8676002)(6486002)(86362001)(6512007)(41300700001)(478600001)(26005)(6666004)(8936002)(5660300002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IdT9FKOLTxYQhwjOtn+FN5TxysrNpXrTAfLVFOKPX/FUee9KDVMRAWO1diFm14UcllcgLffvezNG06UqAFSv4rQz2H4xw91n8VnI7iTaEnYWPtcyfgL4bXqrFxfeiyVloo1TEiviC1sXadXSv9/PClTN2I7Fn2vBbn4guEDlHElM9kRrLKJ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7203z0hugADmsIfGDWkGickiST/hA/Z3tsoLwNcbV72lG4AX4LrLyy+maZOfvzxUlhOT9oyEZQr31rwszuNufsbSjhQGw18y0U5Jx1KZhxrICqmtuJr0Zuoo5OJwMfrUwMI86fQRR0zS44/8fo26GEvF/iweFoNR+5F5lAeOZBRC5pI6uIB61slzneVwtIJ2f1TMw2l8ZLoGoMyMx45oWwodnIco92GOjgSQ76ASejXdS7QrAlm8S5smMuGLUx5xv52iDiie5NKdTMDgveq6EJLlIFcCCNVmLrzxoRFy+v35nbUe8kXAaLu60rZVlZTks7M3AgV8yJzo= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86e43333-e1b3-4fd0-57b7-08da812c02af X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:12:05.1655 (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: xxaGMpG9UAw9kgszJwa36ylzNyD8m3VKKShSH00EzFyTi55gySMariJ6b42OpqvU8peD7Ua5yjIej5c9Y0o9+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5713 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220818_081206_881703_6D5DDE30 X-CRM114-Status: GOOD ( 13.86 ) 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 I.MX mu support generate irq by write a register. Provide msi controller support so other driver such as PCI EP can use it by standard msi interface as doorbell. Signed-off-by: Frank Li --- .../interrupt-controller/fsl,mu-msi.yaml | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml diff --git a/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml b/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml new file mode 100644 index 0000000000000..ac07b138e24c0 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml @@ -0,0 +1,98 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/interrupt-controller/fsl,mu-msi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Freescale/NXP i.MX Messaging Unit (MU) work as msi controller + +maintainers: + - Frank Li + +description: | + The Messaging Unit module enables two processors within the SoC to + communicate and coordinate by passing messages (e.g. data, status + and control) through the MU interface. The MU also provides the ability + for one processor (A side) to signal the other processor (B side) using + interrupts. + + Because the MU manages the messaging between processors, the MU uses + different clocks (from each side of the different peripheral buses). + Therefore, the MU must synchronize the accesses from one side to the + other. The MU accomplishes synchronization using two sets of matching + registers (Processor A-facing, Processor B-facing). + + MU can work as msi interrupt controller to do doorbell + +allOf: + - $ref: /schemas/interrupt-controller/msi-controller.yaml# + +properties: + compatible: + enum: + - fsl,imx6sx-mu-msi + - fsl,imx7ulp-mu-msi + - fsl,imx8ulp-mu-msi + - fsl,imx8ulp-mu-msi-s4 + + reg: + items: + - description: a side register base address + - description: b side register base address + + reg-names: + items: + - const: processor a-facing + - const: processor b-facing + + interrupts: + description: a side interrupt number. + maxItems: 1 + + clocks: + maxItems: 1 + + power-domains: + items: + - description: a side power domain + - description: b side power domain + + power-domain-names: + items: + - const: processor a-facing + - const: processor b-facing + + interrupt-controller: true + + msi-controller: true + + "#msi-cells": + const: 0 + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - msi-controller + +additionalProperties: false + +examples: + - | + #include + #include + + msi-controller@5d270000 { + compatible = "fsl,imx6sx-mu-msi"; + msi-controller; + #msi-cells = <0>; + interrupt-controller; + reg = <0x5d270000 0x10000>, /* A side */ + <0x5d300000 0x10000>; /* B side */ + reg-names = "processor a-facing", "processor b-facing"; + interrupts = ; + power-domains = <&pd IMX_SC_R_MU_12A>, + <&pd IMX_SC_R_MU_12B>; + power-domain-names = "processor a-facing", "processor b-facing"; + }; From patchwork Thu Aug 18 15:11:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12947296 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 09AC6C00140 for ; Thu, 18 Aug 2022 15:20:22 +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=UdvQwyeaeWi92Dea9uIy1cBLbnvjSti9btrp/lpvt8o=; b=Kh0F+i/xIvI8bz HCAD/hD3KYGpX7zpT/zVEWjYGFO8KOK19KWorW39ViH25uQRgAhM1Sn65GKF7DBHGZFieP+KdobM8 +XZAwvoOZT6I1R+np6Ez/h0ap4KBSL0YchzCXwvARe0F9EZtlFfWI0d9NbXdyc1vuR7duEfo7tNHT WWKwq7G3HfsiJyNl3omuLt8cPu6gsNBnkddfFtwrZPrbfRZoPQtP41fFJdpnydUnquyvL7Mrbou0q 0p27BkKxrkJs6oBsjR3tBV6FgEG4KixxN85+oP0efUKYiL0PGZZZRPDNvwr/YVXhFGGOo+U5Hf767 cTLpYjJEJunUkXAY7pZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhII-006XF4-LI; Thu, 18 Aug 2022 15:18:51 +0000 Received: from mail-am6eur05on2048.outbound.protection.outlook.com ([40.107.22.48] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oOhBu-006TnS-W0 for linux-arm-kernel@lists.infradead.org; Thu, 18 Aug 2022 15:12:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k2Wo0/IV+WVfok7DEk20VU8vVibjyKzySi9IHHfBKODLezSTDO5clzW25Nv/ncRwZTRBHh7q6D5MD+m0RJS1oKOEj9H04uhStT0RR0/ykApBrt5IZgz4BI9N7z1NpHUlwYWPfRNwrOFfAJqRVPFcnTEYpwL889/NsKrpoY3SSGms1BuTqCQlkZAmSR/AbVX1wl6V2lf3qgQYmz9a6Wqwry3Uw6sCVfZnnPHNzShxqh4MBdSCsE+oBpEcPsNuORJelbdEl1G1L7D5DwNofnIwVYlsUj0XCsQtB+g3M3HBIMRuRoY6rn2ExceShJgXBAGYRlVGKirAOxHNx0XyUJiEtQ== 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=g1NdUcLeUXF4fzJDgh+3FCiqhJxBXQ8qbrSj5WgwzKo=; b=GpskljL6i91pwjDY1KtPzRBB+VEklgvxglOvwXIsMLYCfaIzi9bb1hWBaDbcB/hEkEpSBd0kPY6jKKTLafZGdfQXhK4Qhd1xG84wKhZrmIxTccJxOjs7m7x2xZkWr8c79MdtJ0FNVI6/vjtrKXfdTewH0REkzbc7cvyv8lsEYFPeFurYTqopBpAhNU98+Pz84ybPSZv+GHqJJHFpNYusZlspL5cAl7cIzK7MTZlMRPqAiSdm/6+PsmVp8vtQpizHSU2C/V5fP2ryneMiv88t9gFhehI93NsHDJWOrff9Tl/g3aUk1y463t7MjZnFmsCLKj0JAG3HbG1NGGXjGH2SVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g1NdUcLeUXF4fzJDgh+3FCiqhJxBXQ8qbrSj5WgwzKo=; b=jqpMV+abWyWFXop5n1wuqQPMvpg2V9CU8yRiUQTNJrwXVlcKUsBHc9EyqCyKytXZHqMR1WcfTE2zLY6b9Y4B5edbCRPq+ZtcDpLDTFRyahgxcvFp3gdk/294mGBAUBDuc11Zr8KuWrO3Zb0tUCzv5TVFnc5/bmS11E9KZ3eiCe4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AM0PR04MB5713.eurprd04.prod.outlook.com (2603:10a6:208:125::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Thu, 18 Aug 2022 15:12:11 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::40a9:93e4:75d4:f73c%3]) with mapi id 15.20.5546.016; Thu, 18 Aug 2022 15:12:10 +0000 From: Frank Li To: maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, jdmason@kudzu.us, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev, lznuaa@gmail.com Subject: [PATCH v6 4/4] pcie: endpoint: pci-epf-vntb: add endpoint MSI support Date: Thu, 18 Aug 2022 10:11:27 -0500 Message-Id: <20220818151127.2449064-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818151127.2449064-1-Frank.Li@nxp.com> References: <20220818151127.2449064-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0141.namprd13.prod.outlook.com (2603:10b6:a03:2c6::26) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bbd2ff3-ab45-4661-bc50-08da812c0613 X-MS-TrafficTypeDiagnostic: AM0PR04MB5713:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S8A04qEaiew4yspKLGL9XKD5QKhJCHIpQCS/0KSbT2doQKTySCav6c+KHJiBcDWHNEm3jo1xX5Mu82rdEnab4wlwjQ8uaV7E4nBRHgM7s6+mkNLk4/Fbp1Sb8z1k7C6US4ZJvmUkYPL5ajaCXdhhXpgd8IdMBehHxd0Wu7cnxNfswsj9coeSx0Oa9/5JvP7++dH7R+0hhGgtPdA/5OhmJjfRDiSQznJb+PtKELxMPAkNziW7bqd5LPQVf0nKvrLyUWncpXVWQbE73bttkaDFd3JdNR9mayp6rOVIK+Tw0tbY5WFmiebw1Hia6rwVve5CBLuMF04s2lVhTrh4PZLAQbeHGtyvLjt/hKrfXmmW/tHPBcnMD8va3aagV4I6kIfa+JGlSgaAbwXSMWeRwwR8lhC5RYaHzNiZTrl6fn99s6eZGlaK6xgIBrNcy7KChOrCCOYefvxx1zqlpbLXjRe4mE03ETb5kBOXoNShsEXutCS0ZBZdJ51T+exaw91zFrTkvAMR2iftLIzOmvuhtxjavz5tJuFK5uSMG4LlqL/NtuC80rkisuJC44ckZdqRqutoGb1qxc1m49q47Js8f9ZLQvVUCvXqkXBiochJtcYTS/+EQnzPPG4kMj+ZRd7wdb9s7/3MT44ESsqJmaj97gD1To4uRbQbBmfyrf9trx8IjC1QHI93diD9UZvfeEhcjU5StCABtG44p+oWsY5v46lPQelNX2h5Zlm/hXAkE8zxIpcGNr8oUGUfmJ1+HgJgsO9L2kArhwXwYM91hxE7vowd9w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2616005)(316002)(1076003)(186003)(83380400001)(36756003)(38350700002)(38100700002)(6506007)(52116002)(4326008)(66946007)(66476007)(66556008)(2906002)(8676002)(6486002)(86362001)(6512007)(41300700001)(478600001)(26005)(6666004)(8936002)(5660300002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LGp1P7vOJZh8c86CiivGbMJ0IIqd?= =?utf-8?q?dqdZMSkoQvlIWEYwEbCIMeMnTC626IbaJnh1cZjhFXTn2J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nsre5ZY?= =?utf-8?q?ZOkAzDhn1FUZjeBF16BbD2MYuQi3SjazGMCOnwXT1CQkHR8kenAWSnyXILqlavqhh?= =?utf-8?q?zdJV33ML7zMNj+gu6uuw5XnBfmPquWWd4MCX9E1h6Qhu43N2Kbmqyaa2sBJCedgRi?= =?utf-8?q?l4HshDUGj8KwlWY7lYUuWvazP66kFk6sGyD+RBS4pPJ3XWQ7Iu/vvhZtx7FNq4h9/?= =?utf-8?q?Yz/9y4yNuqyZ9W7I6idA2HFBV3qz+x72l3R9YlJFfjwPqmYNSrpOqD2oBGog5S1ln?= =?utf-8?q?QKU7+2moxgzrBqOtZo1oLioZdy8/N+0ULVyd5b7WFm9nC2D7fWu4v+dC5uTM8c3s8?= =?utf-8?q?AnLfzE+xMCREW/LKDFg7Z6IA91EAnHMvKUPN1oQMcmf5j1ipF3wScGXF1clp4CWKI?= =?utf-8?q?1eU++lxS57Zr16vUBb3N+sDPwlggMYuFwTln56Xp46pvpamv21Z6XftV5/gulwHIr?= =?utf-8?q?6qPupKAY4yy+HfA9UXuDXaDXm3Nn41aCOIg5jhV96npYwEMQhcr+W9sGKJV8gKvTI?= =?utf-8?q?Efb477kp6pvbYjis3ZhTQlfoCIIsFqHUAXtQ1I59PHXXYkXjUawa+SvQ=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bbd2ff3-ab45-4661-bc50-08da812c0613 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2022 15:12:10.8878 (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: zDE5gIA9p6DHAuzYbEkVdgz4Jd9ssdkKzSIc2T/zDw5PFnNpX0aHZ7H4r1mj9wjtwzeMb8bKdaWow8pBKYTi8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5713 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220818_081215_242324_F249EDB8 X-CRM114-Status: GOOD ( 21.92 ) 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 ┌───────┐ ┌──────────┐ │ │ │ │ ┌─────────────┐ │ │ │ PCI Host │ │ MSI │◄┐ │ │ │ │ │ Controller │ │ │ │ │ │ └─────────────┘ └─┼───────┼──────────┼─BAR0 │ │ PCI │ │ BAR1 │ │ Func │ │ BAR2 │ │ │ │ BAR3 │ │ │ │ BAR4 │ │ ├─────────►│ │ └───────┘ └──────────┘ Linux supports endpoint functions. PCI Host write BAR space like write to memory. The EP side can't know memory changed by the host driver. PCI Spec has not defined a standard method to do that. Only define MSI(x) to let EP notified RC status change. The basic idea is to trigger an IRQ when PCI RC writes to a memory address. That's what MSI controller provided. EP drivers just need to request a platform MSI interrupt, struct msi_msg *msg will pass down a memory address and data. EP driver will map such memory address to one of PCI BAR. Host just writes such an address to trigger EP side irq. Add MSI support for pci-epf-vntb. pci-epf-vntb driver query if system have MSI controller. Setup doorbell address according to struct msi_msg. So PCIe host can write this doorbell address to triger EP side's irq. If no MSI controller exist, fall back to software polling. Signed-off-by: Frank Li --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 134 +++++++++++++++--- 1 file changed, 112 insertions(+), 22 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index 1466dd1904175..ad4f7ec8a39fc 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -44,6 +44,7 @@ #include #include #include +#include static struct workqueue_struct *kpcintb_workqueue; @@ -143,6 +144,8 @@ struct epf_ntb { void __iomem *vpci_mw_addr[MAX_MW]; struct delayed_work cmd_handler; + + int msi_virqbase; }; #define to_epf_ntb(epf_group) container_of((epf_group), struct epf_ntb, group) @@ -253,7 +256,7 @@ static void epf_ntb_cmd_handler(struct work_struct *work) ntb = container_of(work, struct epf_ntb, cmd_handler.work); - for (i = 1; i < ntb->db_count; i++) { + for (i = 1; i < ntb->db_count && !ntb->epf_db_phy; i++) { if (readl(ntb->epf_db + i * 4)) { if (readl(ntb->epf_db + i * 4)) ntb->db |= 1 << (i - 1); @@ -454,11 +457,9 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb) ctrl->num_mws = ntb->num_mws; ntb->spad_size = spad_size; - ctrl->db_entry_size = 4; - for (i = 0; i < ntb->db_count; i++) { ntb->reg->db_data[i] = 1 + i; - ntb->reg->db_offset[i] = 0; + ntb->reg->db_offset[i] = 4 * i; } return 0; @@ -509,6 +510,28 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb) return 0; } +static int epf_ntb_db_size(struct epf_ntb *ntb) +{ + const struct pci_epc_features *epc_features; + size_t size = 4 * ntb->db_count; + u32 align; + + epc_features = pci_epc_get_features(ntb->epf->epc, + ntb->epf->func_no, + ntb->epf->vfunc_no); + align = epc_features->align; + + if (size < 128) + size = 128; + + if (align) + size = ALIGN(size, align); + else + size = roundup_pow_of_two(size); + + return size; +} + /** * epf_ntb_db_bar_init() - Configure Doorbell window BARs * @ntb: NTB device that facilitates communication between HOST and vHOST @@ -520,35 +543,33 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb) struct device *dev = &ntb->epf->dev; int ret; struct pci_epf_bar *epf_bar; - void __iomem *mw_addr; + void __iomem *mw_addr = NULL; enum pci_barno barno; - size_t size = 4 * ntb->db_count; + size_t size; epc_features = pci_epc_get_features(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no); align = epc_features->align; - - if (size < 128) - size = 128; - - if (align) - size = ALIGN(size, align); - else - size = roundup_pow_of_two(size); + size = epf_ntb_db_size(ntb); barno = ntb->epf_ntb_bar[BAR_DB]; + epf_bar = &ntb->epf->bar[barno]; - mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); - if (!mw_addr) { - dev_err(dev, "Failed to allocate OB address\n"); - return -ENOMEM; + if (!ntb->epf_db_phy) { + mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); + if (!mw_addr) { + dev_err(dev, "Failed to allocate OB address\n"); + return -ENOMEM; + } + } else { + epf_bar->phys_addr = ntb->epf_db_phy; + epf_bar->barno = barno; + epf_bar->size = size; } ntb->epf_db = mw_addr; - epf_bar = &ntb->epf->bar[barno]; - ret = pci_epc_set_bar(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no, epf_bar); if (ret) { dev_err(dev, "Doorbell BAR set failed\n"); @@ -704,6 +725,74 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) return 0; } +static void epf_ntb_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) +{ + struct epf_ntb *ntb = dev_get_drvdata(desc->dev); + struct epf_ntb_ctrl *reg = ntb->reg; + int size = epf_ntb_db_size(ntb); + u64 addr; + + addr = msg->address_hi; + addr <<= 32; + addr |= msg->address_lo; + + reg->db_data[desc->msi_index] = msg->data; + + if (desc->msi_index == 0) + ntb->epf_db_phy = round_down(addr, size); + + reg->db_offset[desc->msi_index] = addr - ntb->epf_db_phy; +} + +static irqreturn_t epf_ntb_interrupt_handler(int irq, void *data) +{ + struct epf_ntb *ntb = data; + int index; + + index = irq - ntb->msi_virqbase; + ntb->db |= 1 << (index - 1); + ntb_db_event(&ntb->ntb, index); + + return IRQ_HANDLED; +} + +static void epf_ntb_epc_msi_init(struct epf_ntb *ntb) +{ + struct device *dev = &ntb->epf->dev; + struct irq_domain *domain; + int virq; + int ret; + int i; + + domain = dev_get_msi_domain(ntb->epf->epc->dev.parent); + if (!domain) + return; + + dev_set_msi_domain(dev, domain); + + if (platform_msi_domain_alloc_irqs(&ntb->epf->dev, + ntb->db_count, + epf_ntb_write_msi_msg)) { + dev_info(dev, "Can't allocate MSI, fall back to poll mode\n"); + return; + } + + dev_info(dev, "vntb use MSI as doorbell\n"); + + for (i = 0; i < ntb->db_count; i++) { + virq = msi_get_virq(dev, i); + ret = devm_request_irq(dev, virq, + epf_ntb_interrupt_handler, 0, + "ntb", ntb); + + if (ret) + dev_err(dev, "devm_request_irq() failure\n"); + + if (!i) + ntb->msi_virqbase = virq; + } +} + /** * epf_ntb_epc_init() - Initialize NTB interface * @ntb: NTB device that facilitates communication between HOST and vHOST2 @@ -1299,14 +1388,15 @@ static int epf_ntb_bind(struct pci_epf *epf) goto err_bar_alloc; } + epf_set_drvdata(epf, ntb); + epf_ntb_epc_msi_init(ntb); + ret = epf_ntb_epc_init(ntb); if (ret) { dev_err(dev, "Failed to initialize EPC\n"); goto err_bar_alloc; } - epf_set_drvdata(epf, ntb); - pci_space[0] = (ntb->vntb_pid << 16) | ntb->vntb_vid; pci_vntb_table[0].vendor = ntb->vntb_vid; pci_vntb_table[0].device = ntb->vntb_pid;