From patchwork Mon Aug 22 15:51:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12950880 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 4DE68C28D13 for ; Mon, 22 Aug 2022 15:53:39 +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=PdhHVmvtWX4d15GhBGWIqpEtZ0M0acCkqw1d+LUONWs=; b=OB7We25ViYjJXL hKWB80l8E6M9hv7XOrEtrCENmITjkQ+SCzvNovNwutBpvX7EuMHjBMyRqmTpfGim/gviRkKmAJNcC /sBv14+2i8biZ3voQjiET5/ca/+6ln9C7y4AQNqI52mJDysZz1smKSFah45pwpeP52E4l+ss95J26 5NK4bsr0EZMtOMxKaNn7+wCWtTEkIFMYQajiKoO97nznko9h/+1y6IVzscyTpM0NCqRlSIsT5e9gx UVoCCzAnpE7pJMAKK9836HuBujgMJCNVjpL6nDmITKGc67vupBjNeG4BFhMPSzlGqUsP6+pnpoRd1 q7z6ELsuDgwASjKkyDvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQ9ie-00CQT8-EE; Mon, 22 Aug 2022 15:52:11 +0000 Received: from mail-am6eur05on2075.outbound.protection.outlook.com ([40.107.22.75] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQ9iZ-00CQMm-QT for linux-arm-kernel@lists.infradead.org; Mon, 22 Aug 2022 15:52:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qz0rmHKs5p2Q1gh+S9fh4i4MG8hnRoDPrAIyNBXUKBYyFJHyyQZ3ZjEx0efihqHEXVFJU+LWwqkoyrr57RTZ1dI++7ejc69iqSCjV7KuV0HQXY36iE0OKLGtHPszSdui4Vs1rs0xifGXLFLY5bjG0odh8aZ1EDnu4ih4m6x/ua3RJBESYJgIeicIDn163fZjtvKQzfjmwZ473tHNtm+ODkUu1dHADevVQbd0aJVeE0knELDcmT07oKDTIIyiXCJzu6S0dSFaZEnVumWR7wtvnOz0x1anKQ6CnTLj1IxOjEHhxIqudPU9lc9vLSYmy2brEATBkkuEmx5ClR/pw9/4Pw== 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=CJlixqmQQxoLKu6qGTAVvd95979GeiOaY4aPCwvlxjs=; b=KTo7wPJYQxGCNTS+dKJNXx3R5J9CE6DheE+7ViCNt6h/CEvcIwHytXYQr9vDxQIbbGHGzIPK/NIJLqg477K0mUvek8awTvG1czMVOgAipuURy9BkyZoi1rcjwij1blDoked40OnxZskSsdE5LYA7RYNvpbZX5XA759olbMxMsDq5fFVsilUM5KdBL2SMm1p0NQMF7QdiqQ6hHcZyTf8qTZ0rcBxD53v9+ppVgz+wtoIsErGrsxVXImcQEUjqFLF1Qj3SdOW0UuLukYGpK4IwBMETy5AJigJfB+Qxz5bZT/uKIjWaGffM6vhwpT+K2X9urx1JBceqDt9b3P5k4fP1Mw== 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=CJlixqmQQxoLKu6qGTAVvd95979GeiOaY4aPCwvlxjs=; b=JSKlLCTAsGysH97ISYHeTycODCOBiwIgMGFHppV5iMW4jh9ZVkUMWxxXA8SQNyKYhEtp6B2F0RHfqy/JQk0V18woUe9DySE5XyctLZw1ehFvRkYiP/FZWY9if6y7SvcZlxNrTbD+dA1TElDgEcxaPfWfBu8JMyiAx5rUzozJXfQ= 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 AM5PR04MB3169.eurprd04.prod.outlook.com (2603:10a6:206:4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.22; Mon, 22 Aug 2022 15:51:50 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::85cb:614b:9f52:2dba]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::85cb:614b:9f52:2dba%4]) with mapi id 15.20.5546.022; Mon, 22 Aug 2022 15:51:50 +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 v7 0/4] PCI EP driver support MSI doorbell from host Date: Mon, 22 Aug 2022 10:51:26 -0500 Message-Id: <20220822155130.2491006-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SJ0PR13CA0038.namprd13.prod.outlook.com (2603:10b6:a03:2c2::13) 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: 1a09cbf7-3f7a-48cc-8ba0-08da84563a07 X-MS-TrafficTypeDiagnostic: AM5PR04MB3169:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BXcWSMLSSfVFcifcbSte0pRpFWw36ZqqiprdHSJj/s75Ok5uaJ5mFd8Vkh+/Q+4hb9aaQn4b1SQWbuj5IxWMtsfC3ZUqEDBL3AVCp0ygbRIXIijSMzp9YRi1lrnXVOzgqnC2sCUgBZmNyMEV5FIBlIqnu6Rj81pvlfFeuRKqpZVocPO/wzYBaLZzAhEM8EndaoG2NfeliW3COEwS6Lx8EFUET6MgAXUAjy+0qGfaDGA5m1+eOlE5rQakq23PMevcoLyYrPFf1fPWC43uLaFPG1zFDIafgFYbk52XbKa2jgER8ZZH8XZaNv6a4BHk3AYc9HBh97R0YCXAa2ULt4gGhQhPIa9a3NoNY/9M4ROOuA8j0YtUi7r4CuW63VXoDR7VX0H8oaqE5Yx/xBbR1CqerRFADb1wMplz2UvDuym0H1h2jIfEP0uGC1vl/2LUh/stoW4eh8mzJo0LUrBTFngiizJktqJHtREOedoDPraeGe8FkDsmfIzs41bHhsbdUpOCuzi4g5Ev1cjToc8EjKe3cCaG5TSJE+gxfpP0RPL1NsU+OtYrvH43FBeRaNq3T9qLa7j5xOnN1jJHFOWoaFZb6dDpaPidwwYAv28lMr/qcs/FtcNWvINP0YqgKxGrDxrzwwxSU1G5cgZNMsskTe6uHZH4EsuJI3VK8WXAaDiHIhmWI6SqU5NIj7EjEqWlkWRK1YBwO/zNaDZ/r3AT9+kp1g18QYzBDcQCSkBv8LXbiVMPcTs30yj3gfFL58Rwut+EkbDoT7tS6KJtspEx6bBFZG2jzVL9V9qMYM322q4LNUc= 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)(39860400002)(366004)(136003)(396003)(376002)(316002)(86362001)(38100700002)(38350700002)(36756003)(41300700001)(83380400001)(26005)(6506007)(52116002)(6666004)(6486002)(966005)(6512007)(478600001)(2906002)(66946007)(66556008)(66476007)(1076003)(8936002)(5660300002)(8676002)(7416002)(2616005)(4326008)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Ve0KKYu4kzBGmYBmnKqpv2Q0qZiG?= =?utf-8?q?duc8GvESMcIY0TUZdU1EhvQsa+DGueyeZkiWgOc3OEyNNeoGU6FXqf3tcT8xsXGFd?= =?utf-8?q?ArziCPzYhjQzGpLR2MEV11cy5O/5lBqSKyA7lCb8kM+ugG6F6Mg5rvVwuzPmrRYQz?= =?utf-8?q?43LwW9KIMvG3hCHpWH+b8vaXRravleu++SCfhhbFyiZjiYL79a119P5rgI6JEL3cX?= =?utf-8?q?8VA4dzQeAHpmdm21YqNLr3qBITb7p3bOgU2aB3mgQ8MSc3rxdFBBd9s1fV4vWUx+j?= =?utf-8?q?xRtF6i46o5+409Ns7s3quaQJhH94VAposZ47GHSm3YrFwZUmLB5Vz/bDuHiNbVEL4?= =?utf-8?q?f6p7pjiU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QEEXezAAVhj6uU2sDOnTVbN7l5CmQuuswi/VzX5VCbyvDSLd7lU?= =?utf-8?q?ZSYDRK6IT1L/T0oS/4UHFFRpIlHApOUfT1ucviNPAYGugrNq1Q88J3s8niP9kX3Au?= =?utf-8?q?q+3hlm/eBfljKHpPNbiX/2M66/71ylHUo5RX2VHe/RnIBU9/CpQtZDZgu0s4V7/0S?= =?utf-8?q?N9Xh5kHmhFwMidOHh/0VOhR8Tuki89LVxpnydFHSNZO1mt6NMlNvlDd6Z+0YB2waE?= =?utf-8?q?r9DtD22QFLR8+Hr6RPOIFjb1y2iSVsIFF+MLcyUAm0A0dc8aeUvbvxgA=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a09cbf7-3f7a-48cc-8ba0-08da84563a07 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2022 15:51:50.4316 (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: MgXmT04uH6mytudEOD7s3LutrjSQ1T33ZVV9WYLCBKD1xpB2JPGnVZIXmEjfNSps9lgimPATFo7WztAce1UIrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR04MB3169 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220822_085159_910152_84FDF971 X-CRM114-Status: GOOD ( 14.29 ) 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 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 v6 to v7 pcie: endpoint: add endpoint MSI support