From patchwork Wed Sep 7 03:48:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12968420 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 C405EECAAD3 for ; Wed, 7 Sep 2022 03:50:59 +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: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:In-Reply-To:References: List-Owner; bh=kpjTZFWcKZ/ObGmBS3z7cbf+6a5v3vOt1CTEeEXeElY=; b=n+QU9hOuYIa+NK wYKdkVivzZNNWz5y3NWIuVMWXjC6TGl66nVXtY0nhPYFnnEclXEXM3+c4yMS0MpsdeLIzkgMXGobH LwO7wzO6DL4EK0U+UszUf+KSMzEd5SYnFvwqqgGhDB1IXX7CMJ7pmTlR+GyykKLyN1vhEroSKDmsv IX48Sv5M6GdQXW/JlEURnox/txG0tHW2pMI9k1AGr03+yu2xF7yG54lo0a5Vmfw9jXxnngN3ujo49 RxNe2jtG8BMYAuTPrXeaQLbi5hH3SQkazNJrjvv3BZqhXDKxkXzVLA0y6f3gzHrdYycWduoDrC3zW mgtQfPgSVkuC9KNz9rWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVm43-002Aw8-9f; Wed, 07 Sep 2022 03:49:23 +0000 Received: from mail-eopbgr60086.outbound.protection.outlook.com ([40.107.6.86] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVm3z-002AuL-NS for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2022 03:49:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lv+V7WM+axmvhYW1YTqf5ga6dY5QbfgCKZBIb47+VNuGOxQWU+TiFb9CRrKvsa8hStYUQi6jBXtWqLLSZ80rXbXA8LOpdQUL6vIb4rMpeIItK2aW14CCe5S86dQmxdAtTxabxTE2Osle0iEFJf4b/4S4SZ+bMlU6FGWrSlYxqI6Yp+kyFCNHiicUNTorKamZMMFuEt/8JEil4rRhZbhvApRvJyesrCV5AQ8XLPgfPXzzgJ5bzaTY5Hye6XZaz+hQPxWop/Ej4gq2aOvrIHtfnjm+hMX2xDs2RHy79QGfipLsj4wAP+ogf3XvT+WIqrKovOmnwxhECpXyDa1eMfXeQg== 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=EboxE/oIDfdpYsVhHzlfpx9ijZ471IzZ7V1h82uuIS0=; b=Hboc4LPBCwgMbrT26SLZkrGZ6+roi0pPBUrPjhF9ey9zdokHn3l+PJ0D7siqxUbBrQkOcyw2LrJ+6fnzgcv5aGBb20Lv3ydS+3XXpRURFC3k/bqKQJajtpxQXkfHawz4xIMOKvoRlITYIsvXfCJvd4e7AYc3G7IXaCGvRoFWcxM98kuNYpwE8IcS1J77hUZjmwfUro6+1WHeHUCAI4fW0XJqmBjwW41fRjeBb+Mtu5c4jUoFTFyVLnToc0faXYOmryo9zKCfnJqhYRcyHNjN6n4aifFeSTw5esERy2Ez3rG6w+HyL9M2EgrF2103R+VioxNUqEvEMWN6Ho+1djzw0g== 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=EboxE/oIDfdpYsVhHzlfpx9ijZ471IzZ7V1h82uuIS0=; b=Y27DuReB635Fas74xw8DvV2zwc1HKaczv9L5Y40rVfCAkfhbeD2avfG+luKEL+UShLGTTlhpaqURpWWiW2ZR/SezgIYFpW0KIX0RMIak7ZPffZIBEzJayc43i8LqZKogK7tNHohhKuehZnt/Ec1OaPVDUSe1lIpIVD6RzlboNZU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) by AM6PR04MB5382.eurprd04.prod.outlook.com (2603:10a6:20b:96::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.14; Wed, 7 Sep 2022 03:49:15 +0000 Received: from AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb]) by AM9PR04MB8793.eurprd04.prod.outlook.com ([fe80::1c3e:36a0:1adc:beb%9]) with mapi id 15.20.5612.012; Wed, 7 Sep 2022 03:49:15 +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, imx@lists.linux.dev, manivannan.sadhasivam@linaro.org Subject: [PATCH v9 0/4] PCI EP driver support MSI doorbell from host Date: Tue, 6 Sep 2022 22:48:52 -0500 Message-Id: <20220907034856.3101570-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: BY3PR04CA0009.namprd04.prod.outlook.com (2603:10b6:a03:217::14) To AM9PR04MB8793.eurprd04.prod.outlook.com (2603:10a6:20b:408::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8793:EE_|AM6PR04MB5382:EE_ X-MS-Office365-Filtering-Correlation-Id: ae12c00a-cc44-429e-eb18-08da9083ef46 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kaaPJFs+snRVPGN1iDV0bRCUBIQLBzOi2tgK4lw9xT68JVB+VsNy7t3Z8Hbz6Pqpt4gMc0nFzOWlmvY+85gOgnBbmn6Dty6208MYKAGtG4YdOB0KYFFg8GaEszZ7hIzcaF0ggQrdZigrAEpvXLh7lro5lL0HToIch2dUSC1X6bjlhJbZ4U0DpRQ6FvULh0L1mR97UDcP1DVfDW+8vbevABx2P3yGeJrLhTLj6JtuxqR9xWr+s12w6+X9yjGhcRc837DVnSCG7l6DBRuh/oayQTLxCkFzwwsRCukjZIm1Qs6Xw4tWFtDGIZdtydmGK+FGYJNJ4vfJ/yxIWTahtunsg8i288wpacc1tBeNZ4SAbfSSavuyNVMmijHTR70ipYGyzPi1FSMO6QPvhhK1BbvtIXyTZmzsxmiXc3nBT9HYG+kPN4zkpFnElorNG3p6ec81s9X9lwaTQWJdSkYdjQMxNb6moP+tlv27XSybvTVVWmB4lXt9TUlxeA8c3XKmyLyJGHMeY5C1KfYuPQ3FHOTESlXwHBNPYfN/ZfUMDCdyxiLyiZ3btj9l4cnUKTU5MvjoD+cxaJjzlEhyrb0j/setRT2/21s/c8Ig/b80pE3ea5czItJnr85d3NxZYIoAIcO2sFFwIIOiiMCjwEibMmblVpsJyLvK4P5wrZVVYkg2lOObCV6hW4tUIXIz65pDBTBYAiDtWsEJiEbgkzCrIjNdyFtyaRC0grM6rY+ied3NfLd+VUr5Ccl7Kx4KqRXCFiatNFctxd8HlKJzlh4VrIECu+WmIPoSGehpiIwLbL2A+TeT0yY7PvLAawFZihMVHEnukkoIxPah+27fDpIxJ68CeQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8793.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(346002)(136003)(366004)(376002)(396003)(6506007)(52116002)(26005)(41300700001)(478600001)(6666004)(966005)(6486002)(83380400001)(2616005)(186003)(1076003)(2906002)(8936002)(7416002)(5660300002)(6512007)(316002)(4326008)(66946007)(66556008)(8676002)(66476007)(38100700002)(38350700002)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?VIb1aPnjHLcp6nqffMxOVx2DEfJ+?= =?utf-8?q?nJjsqqfJ4XP0CQ1YefpANHnwS88I2DKOpFyKI9K1lHj55al2E+2+5G808np8ghf1K?= =?utf-8?q?UQCu2Fj/y4UIt8r+BvCEDGmat5SSzRyi4if8aJhMFjaQEbPbj8xbKua/7Onwuho1o?= =?utf-8?q?DMDSwziL4PorjOZwwpr5OFSDOnPytdlMyXgFFzVrkhHH79h0jxOqmnFYDVUmReC4d?= =?utf-8?q?Zu8Ggwz0rSxKwksFevMnVHn7z9qEZZTJDfqKD4PlEQilNb9u2IIZLgbzevmc49pC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GXpk/?= =?utf-8?q?tcOKhvk+NvCEvKUH9o2YrSwX8sCu1AjjUW2AGP1Rek0ENgwM49XSt5u0E6HAxJ4cj?= =?utf-8?q?Qbm1WQGRs2hKjbuRADE+mD7K83N75h3y6qE3PzmjBH8T1SbNhQGdP6WRv6M5+S9Q0?= =?utf-8?q?66LsV86jAVrjerywiGinG96rH++hn0hgTnpR9UkBUrC4nxdFsliAmDUEQqwFUayVt?= =?utf-8?q?A8nlP+r0Xqo4P5SDNobK9iOQJGEcJhJhNNy1jN1w8h5S0KoTJYrq5P14B4ZUSCybb?= =?utf-8?q?La9Hy0VKoTZat+kTRmvTM8pfkMw1SikI8wgiABVmPEsQQeKjPKMu59Rhs0xdBPORw?= =?utf-8?q?tdZoLrtPZfHsG6omwhQa0NTZ4aWql7E5e9jmzxvawG6PqnztW04ajosU=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae12c00a-cc44-429e-eb18-08da9083ef46 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8793.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2022 03:49:15.7874 (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: f/xVwIf3DDM1cc65rgy8Xc+mWMFp/4eTaObTASTMaDksaiVjPfWfghuW01+gb1iAHuyOifMiTFZJrnjdtH0XUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5382 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_204920_121525_06DB2974 X-CRM114-Status: GOOD ( 15.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 ┌───────┐ ┌──────────┐ │ │ │ │ ┌─────────────┐ │ │ │ PCI Host │ │ MSI │◄┐ │ │ │ │ │ Controller │ │ │ │ │ │ └─────────────┘ └─┼───────┼──────────┼─Bar0 │ │ PCI │ │ Bar1 │ │ Func │ │ Bar2 │ │ │ │ Bar3 │ │ │ │ Bar4 │ │ ├─────────►│ │ └───────┘ └──────────┘ Many PCI controllers provided Endpoint functions. Generally PCI endpoint is hardware, which is not running a rich OS, like linux. But Linux also 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. If system have gic-its, only need update PCI EP side driver. But i.MX have not chip support gic-its yet. So we have to use MU to simulate a MSI controller. Although only 4 MSI IRQs are simulated, it matched vntb(pci-epf-vntb) network requirement. After enable MSI, ping delay reduce < 1ms from ~8ms IRQchip: imx mu worked as MSI controller: let imx mu worked as MSI controllers. Although IP is not design as MSI controller, we still can use it if limited IRQ number to 4. pcie: endpoint: pci-epf-vntb: add endpoint MSI support Based on ntb-next branch. https://github.com/jonmason/ntb/commits/ntb-next Using MSI as door bell registers This patch is totally independent on previous on. It can be applied to ntb-next seperately. i.MX EP function driver is upstreaming by Richard Zhu. Some dts change missed at this patches. below is reference dts change - Change from v7 to v8 irqchip: using name process-a-side as resource bind name pcie: endpoint: - fix build error reported by kernel test robot - rename epf_db_phy to epf_db_phys - rework error message - rework commit message - change ntb to vtb at apply irq. - kept name msi_virqbase because it is msi irq base number, not base address. - Change from v6 to v7 pcie: endpoint: add endpoint MSI support Fine tuning commit message Fixed issues, reviewed by Bjorn Helgaas - Change from v5 to v6 Fixed build error found by kernel test robot - Change from v4 to v5 Fixed dt-binding document add msi-cell add interrupt max number update naming reg-names and power-domain-names. Fixed irqchip-Add-IMX-MU-MSI-controller-driver.patch rework commit message remove some field in struct imx_mu_dcfg error handle when link power domain failure. add irq_domain_update_bus_token - Change from v3 to v4 Fixed dt-binding document according to Krzysztof Kozlowski's feedback Fixed irqchip-imx-mu-worked-as-msi-controller according to Marc Zyngier's comments. There are still two important points, which I am not sure. 1. clean irq_set_affinity after platform_msi_create_irq_domain. Some function, like platform_msi_write_msg() is static. so I have to set MSI_FLAG_USE_DEF_CHIP_OPS flags, which will set irq_set_affinity to default one. 2. about comments > + 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); "And you don't get an error due to the fact that you use the same fwnode for both domains without overriding the domain bus token?" I did not understand yet. Fixed static check warning, reported by Dan Carpenter pcie: endpoint: pci-epf-vntb: add endpoint MSI support - Change from v2 to v3 Fixed dt-binding docment check failure Fixed typo a cover letter. Change according Bjorn's comments at patch pcie: endpoint: pci-epf-vntb: add endpoint MSI support - from V1 to V2 Fixed fsl,mu-msi.yaml's problem Fixed irq-imx-mu-msi.c problem according Marc Zyngier's feeback Added a new patch to allow pass down .pm by IRQCHIP_PLATFORM_DRIVER_END --- a/arch/arm64/boot/dts/freescale/imx8-ss-hsio.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8-ss-hsio.dtsi @@ -160,5 +160,6 @@ pcieb_ep: pcie_ep@5f010000 { num-ib-windows = <6>; num-ob-windows = <6>; status = "disabled"; + MSI-parent = <&lsio_mu12>; }; --- a/arch/arm64/boot/dts/freescale/imx8-ss-lsio.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8-ss-lsio.dtsi @@ -172,6 +172,19 @@ lsio_mu6: mailbox@5d210000 { status = "disabled"; }; + lsio_mu12: mailbox@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"; + }; + Change Log - Change from v8 to v9 fix dt_bind_check error