From patchwork Wed Jul 20 21:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12924528 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 83D98C433EF for ; Wed, 20 Jul 2022 21:32:26 +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=sbwAwXtmEXyOwK Qzewxnah14vKLf377nAfXJtpaJUKCjeX1SdIxW1iNppaV+vUyJE2p5RLEQ8z6yhUrL6OVpwDYzTfF +I4lDAf2w3739L9whIOCGAZOGOl+objZC6MqpbLIF+Q2w8vqE+r1nIgH+ZYWmE6oioLu/ozuw6Je2 5/+xhelV0RxnsSbYlVKbyTOfFFsUS9d/LHd8s6y6zSQxKFVoHwIhwm6pC5AK4/zX+3YIeMPqd/0BH XGYQOcu7XMBTTumw+cog1LYDHRzLj0qVGGkLutLRgLLGNl5ZcYbtOa3TOWQvbx6ToSPyxeRfjzycw TkOaqSff4C5PQUkKaxmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHHq-00BUQX-Tf; Wed, 20 Jul 2022 21:31:19 +0000 Received: from mail-db8eur05on2044.outbound.protection.outlook.com ([40.107.20.44] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHHe-00BU9z-Q6 for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 21:31:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ALFNS4jjIJObqTOJr1FAlo1yOXDsUQWDhxjZWs7djfQXasvIlOW5rne/Mhfvjn1nyF015+3ZdjM5XgEfDNx6+ZQgAK18MpgLur958v4C+zAOyhEIzAtxn3T8fGMEW99qigJAs00mdm8fpk88z2RxEwmN1AsCTCjcW2pOc4UgIpRCs9jjbaXaq6xeOC6B6h/GBqNxpmIfZpJlBSbm83078NvF82Udbbc07G9ReMcNQD01fl5f0miRZ+whe7nf+h7E0x/DQGiuf7/58djcfjQGwb1dApuXXOR9c8rENHBI8ymL/bs48FF+WRp3TWjndt/heIgTosb1BgIAnXFnIMt+zA== 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=F1jUSeSPwq+4cboTF/Ls2z6q4kNerFSKLs9XWIJM0lvRdESz4io2zVDT124pLjujSdyBBgsjK5z+S4VegedSE2CpoK3sKAG/Rji/A9C2iY3VEKujauRhsOJiEKLCu/ZGRsV8uI8U31Kzt36gIsJiTn0k4g7apL9TAcJ52s28rE0XJsnMc14DnEocaGEi6tEWHaWDvSv6OnchLAH3PoGnzgPn0oNFSES9tRXbY01CA0JdrsaEmclgiGF789UYfA4JI2vUW5u7Hbf6HI2gYsrrM6BwDfhkXrGMg2EGmiCGN5iQIEPebW6X+WWJhANfmdSri3Ve1H56I0YNMjResAlFfA== 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=F/DhJU49uXAWsT1UUmFg2jMphUVGP9LyMYPh0uf7Gbmnpq3JSl3om39cxhwLWYJDmeBR8v6j8c2Qm3cYBCIXBdiJJ/fTM6Fz507NUZlfpFFjwB0RgAhWYQm3bFRLCBLOJq/hlLrObETjXbfpjSiY1p4ZxRV/E6TarjRVdcZthGo= 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 AM0PR04MB5409.eurprd04.prod.outlook.com (2603:10a6:208:120::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Wed, 20 Jul 2022 21:31:03 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab%9]) with mapi id 15.20.5438.023; Wed, 20 Jul 2022 21:31:03 +0000 From: Frank Li To: jdmason@kudzu.us, 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: 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, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev Subject: [PATCH v3 1/4] irqchip: allow pass down .pm field at IRQCHIP_PLATFORM_DRIVER_END Date: Wed, 20 Jul 2022 16:30:33 -0500 Message-Id: <20220720213036.1738628-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220720213036.1738628-1-Frank.Li@nxp.com> References: <20220720213036.1738628-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0005.namprd10.prod.outlook.com (2603:10b6:a03:255::10) 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: e42d61b1-aa3a-454a-b8a6-08da6a97259b X-MS-TrafficTypeDiagnostic: AM0PR04MB5409:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KmH/rzUDrxtGGplsV3bVLlhBSGCJ2GzivaguZNNkgzoxqdPmvKxjZpP8QfLRMcT+qYd7qr3FziDybCLSpvmKONj0pCaM/ZsRthFxbhvdBgBwLqRYKm3iB39Q5S+i9zz0rowWchH9/UQ3+r0ds1a3qgmNzYj2NudaS9sUotSA/hm9sZlFd5U/CWwRjVQjB6Rqfyfztzb5KwFQIZPkqwh8/wnmHMemWDclHUZpl5RHJ3aBfFQKO7xbv1CFUb4+jaA3VDxCHMZgjYJp5476epHC56YRmK+mTtkRAvAM/OB8oxmd+/4AYeXc4NGvw6HEgm3TWyduh/6/soAU8YjWDP7xe2bSCdw5ojxZ2F5Kml4QhTj0jcQ6ZGLoNd7R58Wb9YyFjWctLKQNDcPtDWENINRkJ8Mue1yFF5F/l6WESYQC4/2JS8G5Jlvlk+ALZdTv2FjlZnL6KO71Ty8zBeZDUACIA8N0ga1ovJkVQVWp437vQbzMwOlP4lcXrATsL2G2hW4vwR8uMwqTZgwlMWlIToym8hNli/fOY8eG6Rjrytn+5IKEz/enaf/J/M9B1lOXM7FKNoevxTYpyxoSQmPNpth4ATWC1IpNfcaSRBedB1EFv/p0Fx9dcsv1ql34B8dQgX423IJNbA4uNJFjHWiLk3rZVawUaUu5CXmK7pm82VbPKh2llqBchlBQi6aar78o9h+Q54iEn9sP/zcaYKNqoRcsLX57WEyy1GxuF0iXBsatzjPPG0ULHxlcvmUcW6J5UK+WFx4o48ymEr+AmNN2MXbqTUerrmzykqBXVulecgv1bo6c5JrknJUzHxR5+1+1EFFQ 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)(376002)(366004)(136003)(346002)(39860400002)(396003)(316002)(38350700002)(6486002)(83380400001)(6666004)(52116002)(478600001)(41300700001)(2616005)(36756003)(6512007)(186003)(1076003)(8676002)(7416002)(66476007)(6506007)(66556008)(5660300002)(2906002)(4326008)(8936002)(66946007)(26005)(86362001)(38100700002)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SRs6it8tqBAMCIIBcUuz8RJbrdst9NyM0JAuXcSOcRrfEY0rukeVOUvW0VIJsDn3aGPetEdQM8+cP1CSRU64QFgayrE2JK5q1iKM8aK4YaI21Rx4xUvKHMsoxUqvAPQpuc6OMwxy1fOcOXEh2MEBZ4FCSEpbtNM30D3GzTBcfPldSVgmEMrKxspdGjlUFAZX83gEzirZjwPeAxbpgWyROKeF87FQjg/h9Q3JghCy4u9/SPWvevLbBYC+Le3JXO8GtICs4oGdhX7grukKTtPdNKBryuQGOOcoM8ucVC/vxGID3snegU7dUMmmyQoiyMCc0diBSP6Vzq5tMl3ZezNGyGvf1IORmPAP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Sss5bwcyt0rjU50nUgnxDdS9B5bJsTBjrGsDQCnY+B+r82isLs+83nh/wl64nZFSnuQZIDVOuvhPDovT4F9wL6syddhrvMOUIHqsWVySrNaF20A0DcbPtusQA3kDxpvmWC/J4XCVgiUCTLZ9mCV51i3feDM= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e42d61b1-aa3a-454a-b8a6-08da6a97259b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 21:31:03.3039 (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: DyOUMYaEDyWDztITxVO57XQA25ALnWNFW0Vp2/Tl3y6vp0iWuQ98Z4Y4GzO7zAbkk2gpf8aJhVxIx5VL2YIw0Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5409 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_143106_872985_9C1CEDF2 X-CRM114-Status: GOOD ( 10.99 ) 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 Wed Jul 20 21:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12924530 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 00251C43334 for ; Wed, 20 Jul 2022 21:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ATAeErfJqnFUQA83tMRvGF1nMAjfe+ejpjnNlvD3JzU=; b=QWPXd2t6J6b+BL JaikwJDAyeHHDD3vn3Cbbci7UKjkXJQ84bTfTgXiR1/mZDiWFnESjEFu938gqxB8XAMEGWtJdoAUq PbO/rRzRuLqevKOVLb/Tj9/gQePeIBLWGildP7JvJjpjfdk8ocpaCSQep7NTGMFbz3B0BgSVgLuxd dQYCzMxxpPAxDDkdtDpgPtJseHwnitH1SfY6r/vJ5NBev1GljP/1vre9AL6a564HTwORmJ/7rqbmp gF5qF4NcGfye+6I5BXYPnNiiezEkeY6q4CX7rwi9LRuJyWfDe8Wpj0GTKBwJtSzQRaDKkW3QDEsMu OuqlH6anp884ib4wTosQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHI1-00BUcG-MQ; Wed, 20 Jul 2022 21:31:29 +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 1oEHHl-00BUHJ-Iz for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 21:31:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X90R6p9JEMMhLKacNu369y/ZOdCwX/2naelsum9C3ecvAZlwrQR3XiqNRrPye+vdyMbyjBzgFqBjnKCwm/aBlIzzkrZvt/QCd/5x8YsMsnH7Ir6OpOVmS7TFCj3E9XMZkYZXRK9wdVFcs4ktouC+oOSAKQpQ2A+A7O/93lwfS0vvPFrCeSdzWJeEdxiE4LcQMuV150tgxX9cWH+EoWYeMfdVtap+BpSQyqHJt95J0LGmgH9NB5j8PWun8W/WkEA7582ke7d2+Vr4LxB5+Y7mdZTED6iJSNCMl5H1m8Pgr6dpqsvvIv27YpaWmuDFjlNFvKRTRMxpeSMrYF9l96xJIQ== 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=asF68cMe4bNr/uSmcUlFQoSaQguF0PwRWXCflrxEx8I=; b=QFdOBkiVOpfSf3YFRyAwjfxG0PTAkGDtsfgD2dJd+DetSMzz4dw+jLiPqCVGvdsqcSb8Y7BKMxLJdDPvJJ9+W1hqco2LbYpyifJ2YhAIlkGKVjuDTjpPKZJjybrsNTC1uYnbYJViDTxkJfGwuX88dUZcLIx++Txm5aV2Qitvg/NRQQ0vSgzq3BAmXamgE7DZMv9gmNOMU3SsG8uK6fWmDXRb5/yoHq9qZAObOswtv4BCHtKZL7ggMsY2lHsfKChl0x+hrci6URzlD9ZRjsfKxUGNhOcBu1y5ShNegFPc8mAs+EUde631hsCFI1EnBk653OL8PviGZnP6P6WwO9B8qA== 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=asF68cMe4bNr/uSmcUlFQoSaQguF0PwRWXCflrxEx8I=; b=BPEpGnf7MBXl/eE20N2ZI5MKxEdhpcKRTjuT90fDbPou+6xkxUqy75d6t3byee4516cavNdEPkM7w3+kH8wzFEggkXc+q9YrFJOF4rjdGQda6FWCHUtm+6tEsh1JwWt5Rf9sRxD8c9mMsUkZ6SDttYjUwrgjqR6BiAL7TSZQq9M= 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 AM0PR04MB5409.eurprd04.prod.outlook.com (2603:10a6:208:120::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.23; Wed, 20 Jul 2022 21:31:08 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab%9]) with mapi id 15.20.5438.023; Wed, 20 Jul 2022 21:31:08 +0000 From: Frank Li To: jdmason@kudzu.us, 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: 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, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev Subject: [PATCH v3 2/4] irqchip: imx mu worked as msi controller Date: Wed, 20 Jul 2022 16:30:34 -0500 Message-Id: <20220720213036.1738628-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220720213036.1738628-1-Frank.Li@nxp.com> References: <20220720213036.1738628-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0005.namprd10.prod.outlook.com (2603:10b6:a03:255::10) 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: 6950f99c-3c55-437b-032c-08da6a972899 X-MS-TrafficTypeDiagnostic: AM0PR04MB5409:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mtM356TK5IG7oeDak7/nc1UpOPfk9DrH0RbR7wxtqP/MS8DmjFh8cJUilQEw+lcXvtbh9J/ewsMmKXUIQYQFW4SlAQd+GUU2fb3h5M0Temw42XyTA/+ydM5qAeuUpHH3OvGQiXOVOVpbj99dK7Y48jV1FgA4EKGeROA6TJ22tRbzah66I4UcmToDnwF5o265TX2e3fLG+vHSE4Z1EZKUs1VQ/X/I5F4HWGSp6W7sUfAkGqNm2Q2tLycEdN0UZ0SlaVz6jaAz1zFaGCFSBGKYW3nfm8AyXwGiblDLcbjp1KWrWX6eAzZJmXmjrALNx3v2pj7TwJEKRznSN4redw4WjHxP7aWAqGvH7t3ChbAzyuE6aOVpqYNm8+NfFgvw2lM/g+TPj164EkdQ16vG6Nxuk9+sBAk+EJUcUJPXc3aNUBT0JHgZ61y0q7QlMFClXsRA2nNmpoZLOmjuYTHMmJ+NRAJdhG4Gdeu+cnXp/k9x0Djaes2EgseV/g7TsNUc6WwCJh9EpG5z7Dws+Aib7gQTbnnEKiFUCG+ZYp7FoTCmL53VkNex8+K9OJKR2eiI1DNnZDkYvZjVZzb65pE4Bup5PFYR2/T9E0FwJkVYA6XLZ31cPBe8cDeL5B279vY3BgM5Qsxoeih8YbgWZsho9ZdT2uKURrgUvK9ySoB61wercinjnys1Ayx6BkpsvU4Xm2JtKgAXjkppIdJ7METIsMeDvFzMlWMq3IskcHRlFLUuJOyvIzv3QvSQZbfxyCnVOIdyyT0GuRBXGe/TFXG1/aiYppHX4LUZQ009ozOzmBKgTQE= 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)(376002)(366004)(136003)(346002)(39860400002)(396003)(316002)(38350700002)(6486002)(83380400001)(6666004)(52116002)(478600001)(41300700001)(2616005)(36756003)(6512007)(186003)(1076003)(8676002)(30864003)(7416002)(66476007)(6506007)(66556008)(5660300002)(2906002)(4326008)(8936002)(66946007)(26005)(86362001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-M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K3pmfoQV8WIWD+VhZb/evzihXaOCDJYWvRb8e5OMnJweHxPlGwLr7He9JA9FL4dx0+w1vHQoUszF8LfPOujB62AHTjkEiYPNWVJCI1sIQP2p4vkNAhjLreSKjhTFTtHh8HRQMm+++oxBJjR1yu28bE+uPez3bwiHceQqAZV8jZXvgygrAeQmhOmT8z85XjDqu8LItnx9Dy8xVYdrMR3VyE+SNks35Zom73N0ZNfKVRWdIw5JKkOiej5X8OWuR3jGhZqcLFxxrZ1aY8EttrxQnBQU7Z3+0kuWdaTSBr+gt+CNN0cnAqqltWUt/TtCZe5m7b+6E2awrBwOOZaRSR9eXm24kjAmZ/S8IKV2Q8rr24kh2RJ22i2VlJ1GeXsY5B6Pl6NV2FWpENgb66R3dGOX6VxbcQfBex8bsHc9NfCb/+q22eDiRWxsiDKbj4mJS8629TKW9+B9xwLX+XJ4GX3Lr8jGW/uHItxaL10hP5oja1K+u8JJmFA47ULryevkzMaKFcfqNQDq5WXG9/lh9VUjqgnoY97RFEs7VbdF26rAfZ+cs= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6950f99c-3c55-437b-032c-08da6a972899 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 21:31:08.2880 (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: aSMRX0KGA82qK0CkHUYRwIDcIv20kO3ubyAjlBpJjowQ2Uq5L7G7Az2ioo8if1d9Dz7BuDskuwli4zET48BUYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5409 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_143113_799011_0A1AC9E0 X-CRM114-Status: GOOD ( 21.07 ) 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 MU support generate irq by write data to a register. This patch make mu worked as msi controller. So MU can do doorbell by using standard msi api. Signed-off-by: Frank Li --- drivers/irqchip/Kconfig | 7 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-imx-mu-msi.c | 462 +++++++++++++++++++++++++++++++ 3 files changed, 470 insertions(+) create mode 100644 drivers/irqchip/irq-imx-mu-msi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 5e4e50122777d..4599471d880c0 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -470,6 +470,13 @@ 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 + 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..8277dba857759 --- /dev/null +++ b/drivers/irqchip/irq-imx-mu-msi.c @@ -0,0 +1,462 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * NXP 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(type, x) (type & IMX_MU_V2 ? BIT(x) : BIT(24 + (3 - (x)))) +#define IMX_MU_xSR_RFn(type, x) (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; + struct platform_device *pdev; + struct irq_domain *parent; + struct irq_domain *msi_domain; + void __iomem *regs; + phys_addr_t msiir_addr; + const struct imx_mu_dcfg *cfg; + unsigned long used; + u32 gic_irq; + struct clk *clk; + struct device *pd_a; + struct device *pd_b; + struct device_link *pd_link_a; + struct device_link *pd_link_b; +}; + +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; + + spin_lock_irqsave(&msi_data->lock, 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]); + spin_unlock_irqrestore(&msi_data->lock, flags); + + return val; +} + +static void imx_mu_msi_mask_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data->parent_data); + + imx_mu_xcr_rmw(msi_data, IMX_MU_RCR, 0, IMX_MU_xCR_RIEn(msi_data->cfg->type, data->hwirq)); +} + +static void imx_mu_msi_unmask_irq(struct irq_data *data) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data->parent_data); + + imx_mu_xcr_rmw(msi_data, IMX_MU_RCR, IMX_MU_xCR_RIEn(msi_data->cfg->type, data->hwirq), 0); +} + +static struct irq_chip imx_mu_msi_irq_chip = { + .name = "MU-MSI", + .irq_mask = imx_mu_msi_mask_irq, + .irq_unmask = imx_mu_msi_unmask_irq, +}; + +static struct msi_domain_ops its_pmsi_ops = { +}; + +static struct msi_domain_info imx_mu_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | + MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSIX), + .ops = &its_pmsi_ops, + .chip = &imx_mu_msi_irq_chip, +}; + +static void imx_mu_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) +{ + struct imx_mu_msi *msi_data = irq_data_get_irq_chip_data(data); + + msg->address_hi = upper_32_bits(msi_data->msiir_addr); + msg->address_lo = lower_32_bits(msi_data->msiir_addr + 4 * data->hwirq); + msg->data = data->hwirq; + + iommu_dma_compose_msi_msg(irq_data_get_msi_desc(data), msg); +} + +static int imx_mu_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) + +{ + return IRQ_SET_MASK_OK; +} + +static struct irq_chip imx_mu_msi_parent_chip = { + .name = "MU", + .irq_compose_msi_msg = imx_mu_msi_compose_msg, + .irq_set_affinity = imx_mu_msi_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; + msi_alloc_info_t *info = args; + int pos, err = 0; + + WARN_ON(nr_irqs != 1); + + spin_lock(&msi_data->lock); + 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(&msi_data->lock); + + if (err) + return err; + + err = iommu_dma_prepare_msi(info->desc, msi_data->msiir_addr + pos * 4); + if (err) + return err; + + irq_domain_set_info(domain, virq, pos, + &imx_mu_msi_parent_chip, msi_data, + handle_simple_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); + + spin_lock(&msi_data->lock); + __clear_bit(d->hwirq, &msi_data->used); + spin_unlock(&msi_data->lock); +} + +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); + u32 status; + int i; + + status = imx_mu_read(msi_data, msi_data->cfg->xSR[IMX_MU_RSR]); + + chained_irq_enter(irq_desc_get_chip(desc), desc); + for (i = 0; i < IMX_MU_CHANS; i++) { + if (status & IMX_MU_xSR_RFn(msi_data->cfg->type, i)) { + imx_mu_read(msi_data, msi_data->cfg->xRR + i * 4); + generic_handle_domain_irq(msi_data->parent, i); + } + } + chained_irq_exit(irq_desc_get_chip(desc), desc); +} + +static int imx_mu_msi_domains_init(struct imx_mu_msi *msi_data) +{ + /* Initialize MSI domain parent */ + msi_data->parent = irq_domain_add_linear(dev_of_node(&msi_data->pdev->dev), + IMX_MU_CHANS, + &imx_mu_msi_domain_ops, + msi_data); + if (!msi_data->parent) { + dev_err(&msi_data->pdev->dev, "failed to create IRQ domain\n"); + return -ENOMEM; + } + + msi_data->msi_domain = platform_msi_create_irq_domain( + of_node_to_fwnode(msi_data->pdev->dev.of_node), + &imx_mu_msi_domain_info, + msi_data->parent); + + if (!msi_data->msi_domain) { + dev_err(&msi_data->pdev->dev, "failed to create MSI domain\n"); + irq_domain_remove(msi_data->parent); + return -ENOMEM; + } + + irq_domain_set_pm_device(msi_data->parent, &msi_data->pdev->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 imx_mu_msi *msi_data, *priv; + struct resource *res; + struct device *dev; + int ret; + + if (!pdev) + return -ENODEV; + + dev = &pdev->dev; + + priv = 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, "a"); + 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, "b"); + if (!res) + return -EIO; + + msi_data->msiir_addr = res->start + msi_data->cfg->xTR; + + msi_data->pdev = pdev; + + msi_data->gic_irq = platform_get_irq(msi_data->pdev, 0); + if (msi_data->gic_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; + } + + ret = clk_prepare_enable(msi_data->clk); + if (ret) { + dev_err(dev, "Failed to enable clock\n"); + return ret; + } + + priv->pd_a = dev_pm_domain_attach_by_name(dev, "a"); + if (IS_ERR(priv->pd_a)) + return PTR_ERR(priv->pd_a); + + priv->pd_link_a = device_link_add(dev, priv->pd_a, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + + if (!priv->pd_link_a) { + dev_err(dev, "Failed to add device_link to mu a.\n"); + return -EINVAL; + } + + priv->pd_b = dev_pm_domain_attach_by_name(dev, "b"); + if (IS_ERR(priv->pd_b)) + return PTR_ERR(priv->pd_b); + + priv->pd_link_b = device_link_add(dev, priv->pd_b, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + + if (!priv->pd_link_b) { + dev_err(dev, "Failed to add device_link to mu a.\n"); + return -EINVAL; + } + + ret = imx_mu_msi_domains_init(msi_data); + if (ret) + return ret; + + irq_set_chained_handler_and_data(msi_data->gic_irq, + imx_mu_msi_irq_handler, + msi_data); + + pm_runtime_enable(dev); + + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + goto disable_runtime_pm; + } + + ret = pm_runtime_put_sync(dev); + if (ret < 0) + goto disable_runtime_pm; + + clk_disable_unprepare(msi_data->clk); + + return 0; + +disable_runtime_pm: + pm_runtime_disable(dev); + clk_disable_unprepare(msi_data->clk); + + return ret; +} + +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 work as MSI controller driver"); +MODULE_LICENSE("GPL"); From patchwork Wed Jul 20 21:30:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12924531 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 6809EC43334 for ; Wed, 20 Jul 2022 21:32:52 +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=HlWpXnhzjS01wLAd+QuEsS5ayy1UJGeb43idChngezc=; b=PIqkMs/5rxKYA4 M4j1PCwjEM1OP0OKvh1q3rkrSLZB8BaLC9bbUBd3uFVr6m2ZKuq9x4rS/7FSwKBhQ7SW/dgc6gept +ya6uy/slGahJCmZJSWJIaQI38YmvfsB1DjfXitFEX+UFPh6z0TwR3O3HLkh4GawCsv5V7s27flYf pAvPt27DL+cvYP3UTfpCFF0q61gQUzz02gn+5MPCYQJWR0ubEYK7e+/+rLxU7nocdInjO24uIS5rk lB2P+kfJffdnFjC6S5NVu80GluEfsPEK9S7mVGBXLXK+mB+aUCW2jc9LnOKJ4ghRRItuMLmLy6dkc dPCCFAbeoO42+oQrZ2Gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHIF-00BUvZ-4q; Wed, 20 Jul 2022 21:31:43 +0000 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHHq-00BULX-Oj for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 21:31:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lIILyRtfj5I+MUq58laD7y8LxAKf/EeNdPHD6oF9HQnDVml9lgheq253Vq5MQNFyB4EwOKhVTyIkWd1jEkhjOAGl/JoXfG052MDYdrCh42Gf9EUS1gk7H6EmwH7LMyrmkxqPajHcVVg/RyhRPeyF4Em6UGQ6PZk3Qf5ofryJFem5/UtZNDqB0LVMw0UUsJtX6fFlOwLlhs47h5mlJqg/mXGxcTdMPC5+9fra+hkjap3LJEB7wJdhCkS45q+xNNL8X1SovlymJgd9xOGw76b3EncOp7d2uq+whjYAI7rph7AW6WHC872CUlVCeWCTSEUYuEoXFrBvlA5NAUWsVArR9Q== 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=FkwQ47gYhSAEPm++wPMu0IyfyIHL4r7W3jd+aeYHTnk=; b=A57rQvMAaYyaPrhkUQ07FLyWcR8y3HNxI/lMTdGHaDGcB0rxftpWkXvwHrfCnxrkXWArTv99X0Or5n0fx3rOh2dMzj3WxogcZMsyIafQwpKHjIIqvNAI3RlutJzyPghsNF84qyeQq/mmM4salqqYWsU9hgZ6Qj7wIS+jVbw06ojn0Ukea1Z0jpQwKVMz3X7dJMkYaoGgJ35d4vxiZ/AwcUNx5QmMxL6mA0cJppMwbpIDKwK8fhwVrhUmM+lzZaU9hurBkN6ERmStIJJog7SOW2JSfyZLDkfFg3nWW0F8u0wUqX1kV4XNMQ9BAbqLGi6McYzqoWXltkHJzEwMAVXJ3w== 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=FkwQ47gYhSAEPm++wPMu0IyfyIHL4r7W3jd+aeYHTnk=; b=fP3RE8db0GgY0JDrd0rwa3ktDuqvCiPmbu/VCYjIahKlruiQGodHJS8F2JKiBbaZSWjeV+Yot9mpT4cvL03P+p72/RUY6D4odTuDCXq4iX+KGjneZ7L3o8Epdkh9A0+GWNayXR/VREsqvM9MNqT+20CTmNePJ+NnvKzuAD6FRnE= 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 AS1PR04MB9479.eurprd04.prod.outlook.com (2603:10a6:20b:4d7::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.24; Wed, 20 Jul 2022 21:31:13 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab%9]) with mapi id 15.20.5438.023; Wed, 20 Jul 2022 21:31:13 +0000 From: Frank Li To: jdmason@kudzu.us, 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: 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, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev Subject: [PATCH v3 3/4] dt-bindings: irqchip: imx mu work as msi controller Date: Wed, 20 Jul 2022 16:30:35 -0500 Message-Id: <20220720213036.1738628-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220720213036.1738628-1-Frank.Li@nxp.com> References: <20220720213036.1738628-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0005.namprd10.prod.outlook.com (2603:10b6:a03:255::10) 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: b54f57e2-39fc-4645-48fb-08da6a972bb8 X-MS-TrafficTypeDiagnostic: AS1PR04MB9479:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eqe4MlNXG2K90gu0RHvdBhi2f8E7nxvuV3SXUQUB0fKQEVejx6cGIyVODeqeLBS2jBLm45ogIS7JTANHoFeP/MHCm347kg/wt6ZAMgnPj5QvNMWO4wqZOrZMrhW0IARai3WwWZoG3eaymmEMlXnMIaR9bcMOwlGVwrESp2XtR/5fePBJRD75ClSuoDB5GIxU+WHd4CPMI/HwNUIpNAKcGRafhavqAbdC9W3b4v2hL9PZCvdI0Ui83VNFI0etPGuiJxJKAIEollwpOTXM901yBjjPvh0mGvvKQQL8LJ05aj0FUK1VVYyP+YuJRN7qCIRd3RDe6pSNnQKNuQpOaXSIE1DaDry6V+079zNvyvnze2wm+kl7nFUZcV1D7aV7I41d6vyytserBg7PQt1TV7axFdEMyhgcC43ANDnfhHxPWg3aqW2bVaGSQkyOJUJ1331w3nEMsbVfYxSAB5EKcotrjAUTbkQafhkwHujN+g6A90velrYFdpYWQ33WRvM1p1WLkD5bcGXDlXbUVqNutdzN6mXKuRtBnAICRlHNvTO+NGjsPOrvXHxIFaTlj2iOoBoiEy/8+rrTHkJ4n/dpBkSW3FlI0mTj58bLx0sHsWURKQuCu7f9z8RJ06Bj9+hueJsctwxZTCecH4FoTK5ZwOnmPqKgcCxCdDH8z4iiIqjfcv4Kc/W2I1HDhkldmSpTfU0Avo+59HzjUbj81ZY5dlIE0C/kJQoEphqwrXHE2Q3APKlEOvNmIBDl2PtIRSMSgFCerfXmxLzwV5iZ7h+lq8uh9G2gSvgxxmP+oy0lf9vI2pw1NE0FSNGVfIUrVUbdkK6DLcQgiv9SfyUg06oXwu5ouP5x14Z1yKLCcBr8aYX4P64= 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)(346002)(376002)(136003)(396003)(366004)(39860400002)(4326008)(66556008)(66476007)(36756003)(966005)(83380400001)(6486002)(86362001)(8936002)(478600001)(5660300002)(316002)(7416002)(66946007)(1076003)(6666004)(6506007)(8676002)(186003)(38350700002)(41300700001)(38100700002)(52116002)(2616005)(2906002)(26005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sICV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D6+4SblVa7UJed02N4Me8wzBLdx2NFPnL2GJTuXrgv3ImM0bSxGktBzgwrxsyp7/HYGJSfDiMURABuRpXz4nAFXBRH73vx1FLXjnm7ZB0mPTQ2uRCj4XpBdNk7pPQ9Sbxx/drV6zk0X8jm9astZoVlggklpQIXjDc6S7wSqz9Sa+Cimrpuj2qLrxgafzFwAV6IZzhvJthG0KYBRMC5VeSX4qVbnk6cJSq6Tzjq5BYlS4yihOLc88EudMMomZlKsSxTte1RIa05S/zRehuB0sRit8US4LBPERJVxXUrq2mvVg3mxcVJauGJNHvr1oHCMlSzAXDQEYX8wrTNbh6hqV0BDcQ3iZBoXoU4h2Qxn5Pwov47ZyWZpqvWgqOXQ+AWeFieVnUZ0+/s3lUTcG0cUk1ighla2LhG8bXlkaBd7EPr6WE7hx3LCFkAV2fuyIFyFzGs8UmfkbcnvHAMb7c6AwCLX1jB+inPGz5kFqNU= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b54f57e2-39fc-4645-48fb-08da6a972bb8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 21:31:13.4168 (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: yO/XoPUQTTB2uV80xgypaculIhP3AUuAouvYQPhWE5RMMzTNH9lXVL949yoxKCYJ/BWdkXKA3su6Q4loM77x5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9479 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_143118_876270_457C58BC X-CRM114-Status: GOOD ( 12.57 ) 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 imx mu support generate irq by write a register. provide msi controller support so other driver can use it by standard msi interface. Signed-off-by: Frank Li --- .../interrupt-controller/fsl,mu-msi.yaml | 88 +++++++++++++++++++ 1 file changed, 88 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..e125294243af3 --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/fsl,mu-msi.yaml @@ -0,0 +1,88 @@ +# 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: 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 to signal the other processor 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: + minItems: 2 + + reg-names: + items: + - const: a + - const: b + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + power-domains: + maxItems: 2 + + power-domain-names: + items: + - const: a + - const: b + + interrupt-controller: true + + msi-controller: true + +required: + - compatible + - reg + - interrupts + - msi-controller + - interrupt-controller + +additionalProperties: false + +examples: + - | + #include + #include + + lsio_mu12: msi-controller@5d270000 { + compatible = "fsl,imx6sx-mu-msi"; + msi-controller; + interrupt-controller; + reg = <0x5d270000 0x10000>, /* A side */ + <0x5d300000 0x10000>; /* B side */ + reg-names = "a", "b"; + interrupts = ; + power-domains = <&pd IMX_SC_R_MU_12A>, + <&pd IMX_SC_R_MU_12B>; + power-domain-names = "a", "b"; + }; From patchwork Wed Jul 20 21:30:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12924532 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 CE411C43334 for ; Wed, 20 Jul 2022 21:33: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=oU+c0u4ual5Z025vqi6chLwS6tUAmZomku003BwwmII=; b=yB4VBmDQmxqOAu nEH4GdvWLjpts858Owvxqk4rAauo2ilyDl19c7JEkMoLI9aNNJT1zaypYzzVjRzAr5hzavrB4fs2i Mz3mesm2pXb63kFoaGq4PC4BMQG3eQJ03Gv0Xoul61TSszcOgjjnzYGkiUzyuhrEJ6VVEVwyle+MZ rAfOfYxSSbngXgZtKS+aLFAT3k05NP3BR/t7wL26EFdvyuO31eiJ7+SOsDS9T1f1du0jO6bL5MIxD 5qJyVCSwKtLpZMhQVzotGQD8zRdUSCPgSoFY8qZcLU6kG7eC3sM0yzUs8drvHMsYevEd13g6O3UZo jzA+Mj2wKx0sYBY2PcWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHIS-00BVAw-Om; Wed, 20 Jul 2022 21:31:57 +0000 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHHs-00BULX-Tz for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 21:31:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cabb3J4IT6Vr6cg0mPtQjUFurOPXWKWAxuL6KOqkW3k9FMeE8TOo6wAujMMaPCBgDX//7HofKdFSuwDzBF6a0y4AR+Xljw6lBokH/wx0MWLH2zHw1e2tEmMOWR3R7xXbMV+9uL6oW4t/klP6A9UJNcRxOzJ9FDUvDP69OsCPrbHEvA/UY9S1eo5Uh63JOK8R8xT5m5JIpKx5jvKkSzdvvatI8xE+i1ozH7RihkHBbbxhl8R9WvNHoMQQuGePpUhp8k1+5nFHofYONHQAVznj9rf51rOS83JZB91bBeNDA1R8LbuMtouC62YnIntCRxepCNnCXCP8xUKj5AOsY5cYUw== 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=1hJeUUxqEQAHaeavRRaTbNVbuGmClsA5qDf+Wpd5vng=; b=Rm82Pbbm4zb6WRLe7dszfOVrcePrlGLCc+dN3wpABItvleHWElQB6x2dbJaQYTzVcd/4sFvGM66PBavDaUSpYeYf7Pjw8QuNhtf9E16uhVxJHE0ZebEzgQTW5Ltm0DqBEqY/osF/oyvwIBIGhwjrOldpWFVWHA/6kimZ7RahQtphR5o1cMExLoPGqQkk+rMSp+noiLlQAKd24NHUh8L+AebQvN7htAIo0e8ohe6yXDBHD170iErGvfpYyJa+JifOPwg/VVjrBzQf8Zq4eev8ob2S4IT9dEefXzUe2pmaMBE7yDSTJz/qMjlfpoxMyXJcQT7cw2IAa2/avFHZG5ri6A== 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=1hJeUUxqEQAHaeavRRaTbNVbuGmClsA5qDf+Wpd5vng=; b=c0rtKHqm/nKxtfzTqWyWMrgQmvNscz2XOOxwWchyzA76Zq1gL5/fVIyI1bXRDYcFltSX08ESreDfkddaTZuKTxO/d5XO6MZZB/1C3i0DwQYf/VyuqdkNwYaOAr7hEa/d0kv6JJwau17dpc8v0pNZTLYErkRb0oX2gMFsVKoc2MQ= 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 AS1PR04MB9479.eurprd04.prod.outlook.com (2603:10a6:20b:4d7::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.24; Wed, 20 Jul 2022 21:31:18 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab%9]) with mapi id 15.20.5438.023; Wed, 20 Jul 2022 21:31:18 +0000 From: Frank Li To: jdmason@kudzu.us, 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: 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, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev Subject: [PATCH v3 4/4] pcie: endpoint: pci-epf-vntb: add endpoint MSI support Date: Wed, 20 Jul 2022 16:30:36 -0500 Message-Id: <20220720213036.1738628-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220720213036.1738628-1-Frank.Li@nxp.com> References: <20220720213036.1738628-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0005.namprd10.prod.outlook.com (2603:10b6:a03:255::10) 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: 6846439a-0165-4f2c-1e2a-08da6a972eb8 X-MS-TrafficTypeDiagnostic: AS1PR04MB9479:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZPMvpDGemGjD3TuBkShhE8xDZi9qUXNyhNU/kGSmYSMM7UMHOekpaCheb4gS7j6EfF2Vb91t6TDQgOnwVRYphfGDGR+0dwldY1mcHaa05ObC1cWrONPtrnLkQhsI0zk1+yypqMKHZxAOA6+pj6qMSllj69aDVDUfW7rsUPyGT+zD+Y3xrEH4CtHiIPhgETfb/nOaVvjYugxMTfHESceRDSrL700ywZy7c/GTh0M3DiZk+iujXO/DKXiUdBk2JazfQfYDzXbGd7RRMMF5utJpS8FqIoh8BJnKQwJs52qAYDOaPL7TosdVKrFlHzvTatnMmLRax/CR5dfwg+0rclwBbaiq3hm77vBw1PdvSXDVaggOZxZSk07fpUAmIqggh1m81NGcSgROUt06vL+jweeeHJVlBQEiQWmzY4sO5wMsm/UskDKVtkwLk29P3XGkPz4i+p247di69boForifbN6t9Jg33qNmlqOSJvTYX9ZhSovFdM4YHPQeG0XOQ8uHbcfGXyxy2NXW6pnoLFiQLDud7cA/SQzPC61+rbjZEQPgS0nJyn7mhNa16db/6L52cSeVrDZcpYgFFnhIKpseeZGMnE7jRdlyzUq4T633Ou40aOQWaifbUbGz93tcS4nFa12/Px6UAs72g8fyELTU4Adlgpb7cJXlgvK65E5/fexGgstmcVbifw+zbSWGSlLeSPwY9ggXSnL/CMq4LgjKYJumgEaavVc8aEWK8WiJ4c/xfCO8Uq715arHnpO5zc40hBDXOkVYc4oaHWSoGSK4uby10sw1qa6au7AfMKoAu/3eKYE= 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)(346002)(376002)(136003)(396003)(366004)(39860400002)(4326008)(66556008)(66476007)(36756003)(83380400001)(6486002)(86362001)(8936002)(478600001)(5660300002)(316002)(7416002)(66946007)(1076003)(6666004)(6506007)(8676002)(186003)(38350700002)(41300700001)(38100700002)(52116002)(2616005)(2906002)(26005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?bbap0hkcJrjaHqLFdNK4aE+tJing?= =?utf-8?q?Bmep8zAZgtpzcyFwDu6uWj686n8AQOqKr3Mn7+TUSe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Ogq3I/eFpCwToXPpNP?= =?utf-8?q?eWtUVnKoy4Ir4nbXrLZnEqvJVL11eVLA/q9kbVmjt4CkCMDY72DnWOmKiI0a0mUXg?= =?utf-8?q?wwNLAW68esg3Zv90bkNQGC7andyLtCggsVmvOz0rHfWDqchXLrq6FMHrA5sIJBjjv?= =?utf-8?q?tOYVlBThfuCwbSpva9CLJxx1wg1UwWw+lM535olEul9nUPCobibrIz+aT4iPNfjrI?= =?utf-8?q?OGkb5RZR40lez1WIcCz/C+tQ0zWLWrZ9mZCQHpjWhX23utQ4u+C4k5AePCBbIErYV?= =?utf-8?q?vsotCeHk37teK5snuJDXklIrgg/UghGR+MhsLjuVjASlWoB26qX/QYUej89/ecMbJ?= =?utf-8?q?CPdI/YZxxWVIn/A/QRrQLg8T8+pqOYNHkP7e7GVCo9PJAQGAvNuQo5iOLp/I1YPRa?= =?utf-8?q?2fL4waRcxoqH7MdsrLJ2ktPr23Oj5xgRZEeTPZvP/RWrHkQDWP9o+UvsVzMUWmNt1?= =?utf-8?q?Rg3NhgiZUE8EBfp93Q7VIdgSzhh6ZXuTsx/+ktqwOXEvNsBaIfXsWzVl0nUJyYmVI?= =?utf-8?q?9K+HY8gXVWGBUyOCBVwviKHA7OWsXNI1DLH6uycqwrxMZ4nV2Ci6Stu0=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6846439a-0165-4f2c-1e2a-08da6a972eb8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 21:31:18.5739 (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: MuLbAOhBAtXR0mKy44dsCrZTRd4dDm/mHdCWsApNACoDwwNghhJOVjhcQVgrlkCeg+lGR+98H/dhhsorRcCpEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9479 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_143121_006191_E0D9EDC5 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 ┌───────┐ ┌──────────┐ │ │ │ │ ┌─────────────┐ │ │ │ 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..cf55fa402049a 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;