From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59F352FD5B3; Thu, 10 Jul 2025 19:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; cv=none; b=KBn3kIM35d1mHGUZ/vuxRLl+OL75jI4UQBKZkER8B7+Y4kmE5iQWZhVFGnUP14xYQdgHsZsevHE8l/l7oCVWrd5s21p7iaObOfMPHDStMkLgdEFgpehor4hWydr+sVwVbczsj8PeFFL+5/ARuEO0km6jQSdLVPfR6AzEyxweSlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; c=relaxed/simple; bh=yfPKmVMhY+gbXvaT/+cR0sE6ZwAyCoBhja/l0byv5u0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VCG7chmMHJu2ynd7qRsNIJFiY2XwZRDCvrz/U4AjT0riW0faVCuM27kLhnw3DWWO/FHRYA5uumNtphSrc7PJ9iql91dFRFtADh9PwbW7b7CxgoLJrVc3quIMZhWHWFg73j+sABRiIJ25gifckNmiPGjivNwGkN/1RK+BDbpQMxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T251JgUf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T251JgUf" Received: by smtp.kernel.org (Postfix) with ESMTPS id BF7F4C4CEF1; Thu, 10 Jul 2025 19:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174837; bh=yfPKmVMhY+gbXvaT/+cR0sE6ZwAyCoBhja/l0byv5u0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=T251JgUfQqkL9mMN9Vezo2QxC8kuwV4QxdRvfzReb0/q7e4Bz5uTLHwMOvYCpYgE1 /INpBVCidZVrZmLgjhKrDteYqlc5/oKI/SMVY2dFGSihqzHHfknmra/mUTLCKVeVt8 38ho9A34bxzZgHDhn9jPJa1219xCojGm3c5XZpYkPIMrxPfxhwri+2vrjFnqZjPdRR GSUJEiQLDYoI8Rn2DhxRsCScv/+9+v4p2p6q4AdycIpbG3ZBayUSBCN8AHm3G5G5JB DQdABgF780tR0MQjDZfiAmTkLlnlADip2uaDBIiMMjCuuNIXZ8HL1f0szYyjMxSeUg O+ex5doYHvrbQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACDD8C83F1B; Thu, 10 Jul 2025 19:13:57 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:47 -0400 Subject: [PATCH v21 1/9] PCI: imx6: Add helper function imx_pcie_add_lut_by_rid() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-1-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=1939; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=FTsRKbmGJkqXdF0l3uL9gIhRFF4JXE9vNw1HW1VASns=; b=pl4q2ntiFNC+d0WkC3fXBmdd1gqe/CxBTx1BZqQJEmeumRTScrSLvt3T8awwwY9n6HD/z7skj 3YNPpGXey6rAS+uVXG9/oWf2slSD0psgmFdz42M2s6eWD2I+0J7wxqM X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Add helper function imx_pcie_add_lut_by_rid(), which will be used for MSI doorbell support in endpoint mode in the future. No functional change. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- - change in v20 - update commit message. change from v14 to v16 - none change from v13 to v14 - new patch --- drivers/pci/controller/dwc/pci-imx6.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller= /dwc/pci-imx6.c index 5a38cfaf989b1c9606660f2e0bcd10d88fa2d6b1..032b906c44dfaa374a32f511098= 402a494ef5677 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1096,18 +1096,14 @@ static void imx_pcie_remove_lut(struct imx_pcie *im= x_pcie, u16 rid) } } =20 -static int imx_pcie_enable_device(struct pci_host_bridge *bridge, - struct pci_dev *pdev) +static int imx_pcie_add_lut_by_rid(struct imx_pcie *imx_pcie, u32 rid) { - struct imx_pcie *imx_pcie =3D to_imx_pcie(to_dw_pcie_from_pp(bridge->sysd= ata)); - u32 sid_i, sid_m, rid =3D pci_dev_id(pdev); + struct device *dev =3D imx_pcie->pci->dev; struct device_node *target; - struct device *dev; + u32 sid_i, sid_m; int err_i, err_m; u32 sid =3D 0; =20 - dev =3D imx_pcie->pci->dev; - target =3D NULL; err_i =3D of_map_id(dev->of_node, rid, "iommu-map", "iommu-map-mask", &target, &sid_i); @@ -1182,6 +1178,13 @@ static int imx_pcie_enable_device(struct pci_host_br= idge *bridge, return imx_pcie_add_lut(imx_pcie, rid, sid); } =20 +static int imx_pcie_enable_device(struct pci_host_bridge *bridge, struct p= ci_dev *pdev) +{ + struct imx_pcie *imx_pcie =3D to_imx_pcie(to_dw_pcie_from_pp(bridge->sysd= ata)); + + return imx_pcie_add_lut_by_rid(imx_pcie, pci_dev_id(pdev)); +} + static void imx_pcie_disable_device(struct pci_host_bridge *bridge, struct pci_dev *pdev) { --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 578752FD5AD; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; cv=none; b=OLHM/VTsu2xcr39ruAJQPXhtHqFmi9pl6Y0UmRfmpAG6l2KY+8oUGt86QsTnwHsGm8DOtYSt6zgjOQ3N576OdNVHUoFT1aoFUivWE9QH7nTunr4bWu44crNr3tuQj7ekamXf8GnXK4ew/HhzWiV5LPb4oPlGt8j0mv41oCsTXI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; c=relaxed/simple; bh=htJO8DNvMG8JfxhKULyjO956ceacV6C/omT3F7WroKI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=clT5nRXv0ekvR5F4Ojogiusk6Q01ufJqSSNP88y2avi42TrF430bH6FBhArTjwbFUGyk3gBOrJPCmMc0dqDlkfU0x0+0rAZNkmVe+IMxDqR1wpKSwclPK3D63ebQGO/CFvVni0K58m0MvfFGXgrJFHZFLRp2SezV02qHW+wUE/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gDqDZa/H; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gDqDZa/H" Received: by smtp.kernel.org (Postfix) with ESMTPS id E1B9EC4CEFC; Thu, 10 Jul 2025 19:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=htJO8DNvMG8JfxhKULyjO956ceacV6C/omT3F7WroKI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gDqDZa/HYADSuBS0ZXQcP5lEyyrst3Sk0XlI/GpM5xW9udm48YitXX492j2VEH7OW xMVrs56m0fFtwqiZ9LFWw1JoJp0yKVNh131tz+6BQS+WrsmjaPMSfB9YX3h6oDwh5X XLpmQm5spN+kDEFdDaOj6wbW0qg4JHFkQbiCD05EnVh5bI1GX8RbJyBe6MckGZIvxO jcdtGiOyodOoyzRqja+Go4HPvzu5MZddj14uqunt245lay6PvVDq+3zE8NVjCutoiy LbJPEpubuH/nltyVzBTad5WLNIPZroJrjnRhTxKWy8kFqA5p33su1D1BjN6wedVQUY xIpSw3jyP3QIQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5865C83F21; Thu, 10 Jul 2025 19:13:57 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:48 -0400 Subject: [PATCH v21 2/9] PCI: imx6: Add LUT configuration for MSI/IOMMU in Endpoint mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-2-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=1837; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=undgD4r0xoItEmBKrD+Vrj1bBDbTL2OdUvPEHbj/82U=; b=l+XFGUURzdxzcmkKjct4/0IkcPsOSWsD8L8ONKwjhtN98Cagqt/z/sosYt8lYSneyYhenkY94 WoOhFqexlkKCMETvGGhnYSvxKxjeW2v/K+qewEnrGs6JSOBN/ZdF3FV X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Add LUT entry for Endpoint mode by calling imx_pcie_add_lut_by_rid(0), since only one physical function is supported. This sets up a single LUT entry required for MSI or IOMMU. The Endpoint function can operate without LUT if neither IOMMU nor MSI is used. This LUT setup enables the EP doorbell feature by allowing the Root Complex to trigger the EP=E2=80=99s MSI controller. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- change in v20 - update commit message change from v14 to v16 - none change from v13 to v14 - new patch --- drivers/pci/controller/dwc/pci-imx6.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller= /dwc/pci-imx6.c index 032b906c44dfaa374a32f511098402a494ef5677..3123bf49e209cc0fc448d6e02a4= 72e280d538033 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -1063,7 +1063,10 @@ static int imx_pcie_add_lut(struct imx_pcie *imx_pci= e, u16 rid, u8 sid) data1 |=3D IMX95_PE0_LUT_VLD; regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA1, data1); =20 - data2 =3D IMX95_PE0_LUT_MASK; /* Match all bits of RID */ + if (imx_pcie->drvdata->mode =3D=3D DW_PCIE_EP_TYPE) + data2 =3D 0x7; /* EP side's RID from RC, only 'D' is meansful */ + else + data2 =3D IMX95_PE0_LUT_MASK; /* Match all bits of RID */ data2 |=3D FIELD_PREP(IMX95_PE0_LUT_REQID, rid); regmap_write(imx_pcie->iomuxc_gpr, IMX95_PE0_LUT_DATA2, data2); =20 @@ -1767,6 +1770,9 @@ static int imx_pcie_probe(struct platform_device *pde= v) ret =3D imx_add_pcie_ep(imx_pcie, pdev); if (ret < 0) return ret; + + /* Only support one physical function */ + imx_pcie_add_lut_by_rid(imx_pcie, 0); } else { pci->pp.use_atu_msg =3D true; ret =3D dw_pcie_host_init(&pci->pp); --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 578DE2FD5B0; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; cv=none; b=FGl/dFRPVNbF22NAGmflF6FBMpemz9bj7nZLi/q+Zu/ZdWOk2KszA6dWFPysVQnNaZJvKD9wnxCYURUuaKOYjjFmiyJzpm4UvmucLOLSa7lIDHtJhjxCskQERISPeVrJkaLpW20fLTh5pud9Z8M+xhjTVd8DvULmdkHkEsGxUAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; c=relaxed/simple; bh=FbFfJ0O8Cxn9ky/KBPJJ3vCgtFRuln3RMTTcy+zzSU8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pc+E6Q9eOlk857DXjXDTGRohDTmGpho7HLngjJFY1bFEjoJmtamesvTZLgWg2yAEVuT983RY+DEog7qxnV9Ebu2MdubHfY/uWkAM+NoTTS5rkcKcVvm3hmkT+AhKnOr0ABRbe+FdMfqzGbqYn3/oNL2WlUnHi2MsQ2FwVwuHRTo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TPqItiAw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TPqItiAw" Received: by smtp.kernel.org (Postfix) with ESMTPS id F3D90C116D0; Thu, 10 Jul 2025 19:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=FbFfJ0O8Cxn9ky/KBPJJ3vCgtFRuln3RMTTcy+zzSU8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=TPqItiAwnC6GIDTSE9E+qpLjD3ClT/p0c8RKavoRF+T6OLGB7LviYRDWxYQMvHXjh ZoGhyNNOAiUYBFH+XiIdnmzZsgRmxd1ESQHCx4G8f194YnCwyK5Z0FtNTFGIXgEXOQ qdQy/qAZHA1nZoQJtB6VirBLuQ3Z80ukdXNKnaSmRZF4cDTntiIv50AFhPJecf3Ar4 00HVEavFF7DU8ZCB6wCE0kWAnijknAvGEzjW0O/YrlAKQ1CPqdHO9WTlqUVkFx2YoY letcxwFtlWluRSYeJIXHOVLci7pc5tL/dDXmQcVb34ciKLkiG7Dy+HYQj0V6XGIdZp BYc7mtDiU0lbg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7D6AC83F17; Thu, 10 Jul 2025 19:13:57 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:49 -0400 Subject: [PATCH v21 3/9] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-3-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=9861; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=DjOBYFEm2LaVAMsRUL0bGftXbmddhhW5FmKcXkwYvPg=; b=5epIOygrfiLqtiT+xKA9OCWQIwi/Gw3faEVxEZYYmU+JCj0Z5pJGvoKgKuPaC+IKLmPHDQycs +e0MoFJ+0zzDowavu4eq/Df4xIeh9MHl7gG1t0zQRHt3wdJVRDRivp8 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Doorbell feature is implemented by mapping the EP's MSI interrupt controller message address to a dedicated BAR in the EPC core. It is the responsibility of the EPF driver to pass the actual message data to be written by the host to the doorbell BAR region through its own logic. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- change in v20 - remove Niklas Cassel test-by tag - rollback to use epc and only support one epf to void touch epf's of_node - add new config PCI_ENDPOINT_MSI_DOORBELL - error code change to ENODATA - don't overwrite return value of platform_device_msi_init_and_alloc_irqs() - remove comment @name in struct pci_epf_doorbell_msg - Add #include to fix kbuild warning Change from v15 to v16 - fix rebase conflict Change from v14 to v15 - check CONFIG_GENERIC_MSI Fix below build error | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202502082204.6PRR3cfG-lkp@i= ntel.com/ All errors (new ones prefixed by >>): drivers/pci/endpoint/pci-ep-msi.c: In function 'pci_epf_alloc_doorbell': >> drivers/pci/endpoint/pci-ep-msi.c:53:15: error: implicit declaration of = function 'platform_device_msi_init_and_alloc_irqs' [-Werror=3Dimplicit-func= tion-declaration] 53 | ret =3D platform_device_msi_init_and_alloc_irqs(&epf->de= v, num_db, pci_epf_write_msi_msg); | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202502082242.pOq1hB1d-lkp@i= ntel.com/ All errors (new ones prefixed by >>): drivers/pci/endpoint/pci-ep-msi.c: In function 'pci_epf_alloc_doorbell': >> drivers/pci/endpoint/pci-ep-msi.c:49:14: error: implicit declaration of = function 'irq_domain_is_msi_immutable'; did you mean 'irq_domain_is_msi_dev= ice'? [-Werror=3Dimplicit-function-declaration] 49 | if (!irq_domain_is_msi_immutable(dom)) { Change from v13 to v14 - basic roll back to v9 - use device:id as msi-map input, its will handle it - use existed platform_device_msi_init_and_alloc_irqs() - pass down epf->dev point, because epf->dev of-node will be the same as epc's parent. Change from v12 to v13 - Use DOMAIN_BUS_DEVICE_PCI_EP_MSI Change from v10 to v12 - none Change from v9 to v10 - Create msi domain for each function device. - Remove only function support limiation. My hardware only support one function, so not test more than one case. - use "msi-map" descript msi information msi-map =3D ; Chagne from v8 to v9 - sort header file - use pci_epc_get(dev_name(msi_desc_to_dev(desc))); - check epf number at pci_epf_alloc_doorbell - Add comments for miss msi-parent case change from v5 to v8 -none Change from v4 to v5 - Remove request_irq() in pci_epc_alloc_doorbell() and leave to EP function driver, so ep function driver can register differece call back function for difference doorbell events and set irq affinity to differece CPU core. - Improve error message when MSI allocate failure. Change from v3 to v4 - msi change to use msi_get_virq() avoid use msi_for_each_desc(). - add new struct for pci_epf_doorbell_msg to msi msg,virq and irq name. - move mutex lock to epc function - initialize variable at declear place. - passdown epf to epc*() function to simplify code. --- drivers/pci/endpoint/Kconfig | 8 ++++ drivers/pci/endpoint/Makefile | 1 + drivers/pci/endpoint/pci-ep-msi.c | 90 +++++++++++++++++++++++++++++++++++= ++++ include/linux/pci-ep-msi.h | 28 ++++++++++++ include/linux/pci-epf.h | 15 +++++++ 5 files changed, 142 insertions(+) diff --git a/drivers/pci/endpoint/Kconfig b/drivers/pci/endpoint/Kconfig index 1c5d82eb57d440fb18c788921fc27096b75b061e..72f82ae98f94556ec5cd734e452= 5b363879aa340 100644 --- a/drivers/pci/endpoint/Kconfig +++ b/drivers/pci/endpoint/Kconfig @@ -28,6 +28,14 @@ config PCI_ENDPOINT_CONFIGFS configure the endpoint function and used to bind the function with an endpoint controller. =20 +config PCI_ENDPOINT_MSI_DOORBELL + bool "PCI Endpoint MSI Doorbell Support" + depends on PCI_ENDPOINT && GENERIC_MSI_IRQ + help + This enables the EP's MSI interrupt controller to function as a + doorbell. The RC can then notify the EP by writing data to dedicated + BAR, which the EP maps to the controller's message address. + source "drivers/pci/endpoint/functions/Kconfig" =20 endmenu diff --git a/drivers/pci/endpoint/Makefile b/drivers/pci/endpoint/Makefile index 95b2fe47e3b06be6ecd210e8d834610021a22470..b4869d52053aade87298289b29b= 3beb547001bfa 100644 --- a/drivers/pci/endpoint/Makefile +++ b/drivers/pci/endpoint/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) +=3D pci-ep-cfs.o obj-$(CONFIG_PCI_ENDPOINT) +=3D pci-epc-core.o pci-epf-core.o\ pci-epc-mem.o functions/ +obj-$(CONFIG_PCI_ENDPOINT_MSI_DOORBELL) +=3D pci-ep-msi.o diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-e= p-msi.c new file mode 100644 index 0000000000000000000000000000000000000000..de610c16f68986eb0a5f4a0f23b= d0136aa169f97 --- /dev/null +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PCI Endpoint *Controller* (EPC) MSI library + * + * Copyright (C) 2025 NXP + * Author: Frank Li + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void pci_epf_write_msi_msg(struct msi_desc *desc, struct msi_msg *m= sg) +{ + struct pci_epc *epc; + struct pci_epf *epf; + + epc =3D pci_epc_get(dev_name(msi_desc_to_dev(desc))); + if (!epc) + return; + + epf =3D list_first_entry_or_null(&epc->pci_epf, struct pci_epf, list); + + if (epf && epf->db_msg && desc->msi_index < epf->num_db) + memcpy(&epf->db_msg[desc->msi_index].msg, msg, sizeof(*msg)); + + pci_epc_put(epc); +} + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) +{ + struct pci_epc *epc =3D epf->epc; + struct device *dev =3D &epf->dev; + struct irq_domain *dom; + void *msg; + int ret; + int i; + + if (list_first_entry_or_null(&epc->pci_epf, struct pci_epf, list) !=3D ep= f) { + dev_err(dev, "MSI doorbell only support one endpoint function\n"); + return -EINVAL; + } + + dom =3D of_msi_map_get_device_domain(epc->dev.parent, 0, DOMAIN_BUS_PLATF= ORM_MSI); + if (!dom) { + dev_err(dev, "Can't find MSI domain for parent device\n"); + return -ENODEV; + } + + dev_set_msi_domain(epc->dev.parent, dom); + + msg =3D kcalloc(num_db, sizeof(struct pci_epf_doorbell_msg), GFP_KERNEL); + if (!msg) + return -ENOMEM; + + epf->num_db =3D num_db; + epf->db_msg =3D msg; + + ret =3D platform_device_msi_init_and_alloc_irqs(epc->dev.parent, num_db, + pci_epf_write_msi_msg); + if (ret) { + dev_err(dev, "Failed to allocate MSI\n"); + kfree(msg); + return ret; + } + + for (i =3D 0; i < num_db; i++) + epf->db_msg[i].virq =3D msi_get_virq(epc->dev.parent, i); + + return ret; +} +EXPORT_SYMBOL_GPL(pci_epf_alloc_doorbell); + +void pci_epf_free_doorbell(struct pci_epf *epf) +{ + platform_device_msi_free_irqs_all(epf->epc->dev.parent); + + kfree(epf->db_msg); + epf->db_msg =3D NULL; + epf->num_db =3D 0; +} +EXPORT_SYMBOL_GPL(pci_epf_free_doorbell); diff --git a/include/linux/pci-ep-msi.h b/include/linux/pci-ep-msi.h new file mode 100644 index 0000000000000000000000000000000000000000..7c5db90f96204559b4be0c88055= 65f210461ac75 --- /dev/null +++ b/include/linux/pci-ep-msi.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * PCI Endpoint *Function* side MSI header file + * + * Copyright (C) 2024 NXP + * Author: Frank Li + */ + +#ifndef __PCI_EP_MSI__ +#define __PCI_EP_MSI__ + +struct pci_epf; + +#ifdef CONFIG_PCI_ENDPOINT_MSI_DOORBELL +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 nums); +void pci_epf_free_doorbell(struct pci_epf *epf); +#else +static inline int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 nums) +{ + return -ENODATA; +} + +static inline void pci_epf_free_doorbell(struct pci_epf *epf) +{ +} +#endif /* CONFIG_GENERIC_MSI_IRQ */ + +#endif /* __PCI_EP_MSI__ */ diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 749cee0bcf2cc0600ad3be1582b0c497c5a21bed..a3b1a1d90d18356e8cda966c700= 4c3be93962a0d 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -12,6 +12,7 @@ #include #include #include +#include #include =20 struct pci_epf; @@ -128,6 +129,16 @@ struct pci_epf_bar { int flags; }; =20 +/** + * struct pci_epf_doorbell_msg - represents doorbell message + * @msi_msg: MSI message + * @virq: irq number of this doorbell MSI message + */ +struct pci_epf_doorbell_msg { + struct msi_msg msg; + int virq; +}; + /** * struct pci_epf - represents the PCI EPF device * @dev: the PCI EPF device @@ -155,6 +166,8 @@ struct pci_epf_bar { * @vfunction_num_map: bitmap to manage virtual function number * @pci_vepf: list of virtual endpoint functions associated with this func= tion * @event_ops: callbacks for capturing the EPC events + * @db_msg: data for MSI from RC side + * @num_db: number of doorbells */ struct pci_epf { struct device dev; @@ -185,6 +198,8 @@ struct pci_epf { unsigned long vfunction_num_map; struct list_head pci_vepf; const struct pci_epc_event_ops *event_ops; + struct pci_epf_doorbell_msg *db_msg; + u16 num_db; }; =20 /** --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCE1A2FE327; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; cv=none; b=UL6SGlXd8nNC+17oftGY5KrXoCmqzuWw+ujzyeSvKc/alF7DsL+2LViZdLWAio5WYnVjGB/MjSqnJhH8wZpZP7ok+cfpN7rVK72seMJY7T8OZ6aHzG4sKcz/VqA3+dM0VC6SHjPSEF/YAK1lKLjRUYR+WwYSQgj5XuS+gVHrob0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174838; c=relaxed/simple; bh=AyOagcGSXpBuGhg+sk+h2sw3geLwEXSyFxwH/3Qmsrc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=usArHRmZYI1YlXJKx7zWJBjep6+STb4D0O/DOVKXb0xedZVdgbPMIY20LAPnFGUyDiuVmlpffCOFIWoSgzArRwaR5+YM9wEnlDmO0Sm4LPUqojHYbA5LZSPHLd4HItzd1bLR8+9L/+3f0txheOqQVl9YwRLty7ln5ngSXtkIei0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qxYJwpnO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qxYJwpnO" Received: by smtp.kernel.org (Postfix) with ESMTPS id 15046C19421; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=AyOagcGSXpBuGhg+sk+h2sw3geLwEXSyFxwH/3Qmsrc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qxYJwpnOgdp6i/MsXiIMVeKPHmcOAStOalVJORjViqAZwcx93yEY9E4sECOQe2xXO b5BNma3tA6SSWESJCbyehXvXk+aY3kVWZUzDUx09WCT3GlKWyHvTY/wvoklUSQBt5O oucoCsK8h/hGLa4FiSReOk/OOsJ0FnM2FjfVBbs+JkkIoHKRQXUa62078JksXi3Q2s R4p11NrYhBcreehDBPgxlD5AwAHcI1wwQs4NE9/qfhP/13YobcANccpk0DYX9r0sLn qtiaWDExu7UU4MPh2PFDMeOMPDG+0rXLKhZCkZI08eYiWcfKG7U4hnW3MfPVEpcLE5 ATSr+C5Z8um0w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04E53C83F1B; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:50 -0400 Subject: [PATCH v21 4/9] PCI: endpoint: pci-ep-msi: Add MSI address/data pair mutable check Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-4-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=1452; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=5GnLijRH62gBTUdnVBRu9d7hyvLf0+eT6hrBiV+MYG4=; b=L2fisuczw40QBhMHVWvKZlHl+ivJhSeTrPDRL1yujDkngHoAuZxODt+gGwgTwwaumwaPHxAJ8 IIude4pEMWeALEBm43Q6meOerlETZX6WDL9ailiwfhENDBtlJl0z8Dr X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Some MSI controller change address/data pair when irq_set_affinity(). Current PCI endpoint can't support this type MSI controller. Call irq_domain_is_msi_immutable() check if address/data pair immutable. Also ensure it is parent MSI domains, not device-specific MSI domains, since device MSI domains do not allocate address/data pairs. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- change in v20 - update commit message - change return error code to ENODEV change in v18 - update commit message. remove 'include/linux/msi.h' part. change from v14 to v17 - none change from v13 to v14 - bring v10 back Change from v9 to v10 - new patch --- drivers/pci/endpoint/pci-ep-msi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-e= p-msi.c index de610c16f68986eb0a5f4a0f23bd0136aa169f97..2b4405cfeb6f8f3cbe9782c7936= 04a10dcaa4eb7 100644 --- a/drivers/pci/endpoint/pci-ep-msi.c +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -55,6 +55,14 @@ int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_= db) return -ENODEV; } =20 + if (!irq_domain_is_msi_parent(dom)) + return -ENODEV; + + if (!irq_domain_is_msi_immutable(dom)) { + dev_err(dev, "MSI controller not supported\n"); + return -ENODEV; + } + dev_set_msi_domain(epc->dev.parent, dom); =20 msg =3D kcalloc(num_db, sizeof(struct pci_epf_doorbell_msg), GFP_KERNEL); --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 211932FE363; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; cv=none; b=Cd8HghkbnnKhotG9MaRE0NOJCS1Mr18Bwwm+21+7ddyc3MWPYU9z2XXQSfS8biTvbnZ4ht4CGL7HbeM7ZSw+PH5YyYJr6Q/JRmGEgZ4xVxWNt5if4QRgucLki3WcRPETh4LmfxzwHQh4f6ZL03tOTi0ShByXH+N3NSLiNLpFcTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; c=relaxed/simple; bh=HU6ZKi+uSDs3PydEoJ74Aj3O4Kf3sl4dWHMWujWPI6Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kwINv5V4dRJv3eK+kYxajXZ0ChWAf3VW2uohGAmJSA9XavMctN3MlRNHsEI/KBResqNTz1GWacCtS/SOHIZiyWllQpy7vQBDcnAXWqQKwIlo7F/Jusrt2KSeLEm/lTnlm+cE0i9+I88pthpmmmVrXxwuDSaCfeoAkHqXlxgRebg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dIN9j1ur; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dIN9j1ur" Received: by smtp.kernel.org (Postfix) with ESMTPS id 24A82C2BCB6; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=HU6ZKi+uSDs3PydEoJ74Aj3O4Kf3sl4dWHMWujWPI6Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dIN9j1ur9o34Fggh50RDPATtgMusqVjjT4pLPQTLQiruSpIVOsYZ90nXY/V7VF0h7 Jc85Gji8bSV6qOnf+B2OG+gokV/4ESnzkrr0gmc6qSiK/+DGGVC8et4iK2bFHQWnRL B4/c84xt/PNViEzk4KEVyRsaceG9jaBAcc4DN66r/UxaKm79o2WKlq71Yn6L03ZHQJ 2tHP/mcd+xJQ7COizxErC/3TGGMoYX4oq/71GYMYBuCiF7BTTMetUS0NkZOhvqOrfo ONcVYsKGNX5ofwf6GhrIzA/xhJfm0ZZE9tDWKADK0FqRh+pjgiprRqFjgzzcL8yJrE uLBhQtSdMuYLw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 171A5C83F22; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:51 -0400 Subject: [PATCH v21 5/9] PCI: endpoint: Add pci_epf_align_inbound_addr() helper for address alignment Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-5-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=4465; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=eJY/O6s4mvGH2YiCbt2NqyZL0ADWa6DzNB6o60H9qvk=; b=KCrszxk0CYMML509QFJVQjkBnkOxkEjuqrSEzy1aSwTV75sp1AYyEsGHlVe2kqcc5VRurkDIJ laxSTjBVCMlBMtxa2UQ7mT49UQ7gnH+Dk8g0/9bB/2wMT5LpfNurnUC X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Introduce the helper function pci_epf_align_inbound_addr() to adjust addresses according to PCI BAR alignment requirements, converting addresses into base and offset values. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- Changes in v21 - align to bar size Changes in V20 - update function kdoc comments. - 128 come from pci_epf_alloc_space() drivers/pci/endpoint/pci-epf-core.c Change from v15 to v16 - none Change from v14 to v15 - change out address type to dma_addr_t to fix below build issue | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202502082311.G1hWGggF-lkp@i= ntel.com/ All errors (new ones prefixed by >>): drivers/pci/endpoint/functions/pci-epf-test.c: In function 'pci_epf_test= _enable_doorbell': >> drivers/pci/endpoint/functions/pci-epf-test.c:726:42: error: passing arg= ument 4 of 'pci_epf_align_inbound_addr' from incompatible pointer type [-We= rror=3Dincompatible-pointer-types] 726 | &epf_test->db_bar.phys_= addr, &offset); | ^~~~~~~~~~~~~~~~~~~~~~~= ~~~~ | | | dma_addr_t * {aka unsig= ned int *} In file included from include/linux/pci-epc.h:12, Change form v9 to v14 - none change from v8 to v9 - pci_epf_align_inbound_addr(), base and off must be not NULL - rm pci_epf_align_inbound_addr_lo_hi() change from v7 to v8 - change name to pci_epf_align_inbound_addr() - update comment said only need for memory, which not allocated by pci_epf_alloc_space(). change from v6 to v7 - new patch --- drivers/pci/endpoint/pci-epf-core.c | 36 +++++++++++++++++++++++++++++++++= +++ include/linux/pci-epf.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci= -epf-core.c index 577a9e490115c9dd5d7fb624c4a3001f39b97e78..2947ca52edbe8834f09313249ad= 3871bc7a462b1 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -477,6 +477,42 @@ struct pci_epf *pci_epf_create(const char *name) } EXPORT_SYMBOL_GPL(pci_epf_create); =20 +/** + * pci_epf_align_inbound_addr() - Align the given address based on the BAR + * alignment requirement + * @epf: the EPF device + * @addr: inbound address to be aligned + * @bar: the BAR number corresponding to the given addr + * @base: base address matching the @bar alignment requirement. + * @off: offset to be added to the @base address. + * + * Helper function to align input 'addr' to base and offset, which match + * BAR's alignment requirement. + * + * The pci_epf_alloc_space() function already accounts for alignment. This= is + * primarily intended for use with other memory regions not allocated by + * pci_epf_alloc_space(), such as peripheral register spaces or the trigger + * address for a platform MSI controller. + */ +int pci_epf_align_inbound_addr(struct pci_epf *epf, enum pci_barno bar, + u64 addr, dma_addr_t *base, size_t *off) +{ + /* + * Most EP controllers require the BAR start address to be aligned to + * the BAR size, because they mask off the lower bits. + * + * Alignment to BAR size also works for controllers that support + * unaligned addresses. + */ + u64 align =3D epf->bar[bar].size; + + *base =3D round_down(addr, align); + *off =3D addr & (align - 1); + + return 0; +} +EXPORT_SYMBOL_GPL(pci_epf_align_inbound_addr); + static void pci_epf_dev_release(struct device *dev) { struct pci_epf *epf =3D to_pci_epf(dev); diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index a3b1a1d90d18356e8cda966c7004c3be93962a0d..0ca08f0d05d7439ef4043a77c20= 4062989a27bd9 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -241,6 +241,9 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t s= ize, enum pci_barno bar, enum pci_epc_interface_type type); void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno ba= r, enum pci_epc_interface_type type); + +int pci_epf_align_inbound_addr(struct pci_epf *epf, enum pci_barno bar, + u64 addr, dma_addr_t *base, size_t *off); int pci_epf_bind(struct pci_epf *epf); void pci_epf_unbind(struct pci_epf *epf); int pci_epf_add_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf); --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A2A52FE36B; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; cv=none; b=XmocBXoHtzSAIYfk6soFW0juCZ5aLgk6ZWhGPtXRYQw7VvryK0MnlPKm9OzAvcNuDse3M/dYoMNyHcRw4D2VijyBAs6zkex8fHqUNZTT9uSx733QF637qCLRUnqX0xrSvu0zEccltVRWOygFGlC2TckMmdMggFW8mozWXc3d080= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; c=relaxed/simple; bh=Q8B1Dku/Ofi9wXT/6+cHHNsu15ChbWIvtmxnF+vBdXc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CrM190NTB4hDA8pZEw48+2nUKr20EXYUBppu7oi/I7oOE6rFK5zRrmltmKaT/lqBGbsvfzhZvXT0Knsm+4iPwtUf6sBw1ZEcvQK/F16VTty9AXhS4kt9uQeQCJ9/+svY3PTMx6NiSMhwUxJ8rde+ZR5Qr417ugmGLM6yN0rd7X4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BJDj8mYY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BJDj8mYY" Received: by smtp.kernel.org (Postfix) with ESMTPS id 33D27C2BCB7; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=Q8B1Dku/Ofi9wXT/6+cHHNsu15ChbWIvtmxnF+vBdXc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=BJDj8mYYiG6MzngJ9d5Ref1hr8BIUKVfAp+XAgm1gYQ8O5UGw0VVeeX8MXltqs+gc VpcxjRlT18cGReKqxQNGwHxC3rKI3jAurocSq74HEIAHB8zZ1/RDmOJzJU6lYK5wsG qVNQvqcYtFYcNtqk0MKWAs8wdOSKHT5yj1O+S/cQR/PiIQlTob+sGbbBEXI2uKXXEm eGkgX1/Rh6V99+o2JMjirkslxsmNlJ8h+e75y3bpWqAdkY06mlJfxMv9YAE+JdFNh2 N/sowlgm2CjkAgNm2ow6vnibFKma6eqJN3t+edG02iaXuBpm5HiOM77h5tmVrDXoIK lw3qvKs3OMN5Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28ADEC83F1A; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:52 -0400 Subject: [PATCH v21 6/9] PCI: endpoint: pci-epf-test: Add doorbell test support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-6-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=8374; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=h3fz11rXH/NSr5dAlWLYpR+aWlg/xF+Fa/15kBgdL7U=; b=PvcWb4jQzLWifjuXvJSL0yYesAGlfsSnCeHa4xorafY+4p55wcHo720uUJNLyXF9OZFmAT7F9 Nfy07L3n4ctCugRuwcaUt5Y5DWbkFNtYmv6FYxLXDnj5KgykLQC4F0z X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Add three registers: doorbell_bar, doorbell_addr, and doorbell_data. Use pci_epf_alloc_doorbell() to allocate a doorbell address space. Enable the Root Complex (RC) side driver to trigger pci-epc-test's doorbell callback handler by writing doorbell_data to the mapped doorbell_bar's address space. Set STATUS_DOORBELL_SUCCESS in the doorbell callback to indicate completion. Avoid breaking compatibility between host and endpoint, add new command COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. Host side need send COMMAND_ENABLE_DOORBELL to map one bar's inbound address to MSI space. the command COMMAND_DISABLE_DOORBELL to recovery original inbound address mapping. Host side new driver Host side old driver EP: new driver S F EP: old driver F F S: If EP side support MSI, 'pci_endpoint_test -f pcie_ep_doorbell' return success. If EP side doesn't support MSI, the same to 'F'. F: 'pci_endpoint_test -f pcie_ep_doorbell' return failure, other case as usual. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- changes in v20 - simple error handle by goto - remove unecessary check - remove Tested-by: Niklas Cassel change from v15 to v16 - use le32 for doorbell_* register and use cpu_to_le32() and le32_to_cpu() when use it. change from v14 to v15 - none Change from v9 to v14 - update commit message by use pci_endpoint_test -f pcie_ep_doorbell Change from v8 to v9 - move pci_epf_alloc_doorbell() into pci_epf_{enable/disable}_doorbell(). - remove doorbell_done in commit message. - rename pci_epf_{enable/disable}_doorbell() to pci_epf_test_{enable/disable}_doorbell() to align corrent code style. Change from v7 to v8 - rename to pci_epf_align_inbound_addr_lo_hi() Change from v6 to v7 - use help function pci_epf_align_addr_lo_hi() Change from v5 to v6 - rename doorbell_addr to doorbell_offset Chagne from v4 to v5 - Add doorbell free at unbind function. - Move msi irq handler to here to more complex user case, such as differece doorbell can use difference handler function. - Add Niklas's code to handle fixed bar's case. If need add your signed-off tag or co-developer tag, please let me know. change from v3 to v4 - remove revid requirement - Add command COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. - call pci_epc_set_bar() to map inbound address to MSI space only at COMMAND_ENABLE_DOORBELL. --- drivers/pci/endpoint/functions/pci-epf-test.c | 136 ++++++++++++++++++++++= ++++ 1 file changed, 136 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/en= dpoint/functions/pci-epf-test.c index 50eb4106369f41afa00ed3ae58c84922e0a49e51..dfdd25cfc003948fbb54a4313f1= 759994e67df99 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include =20 #include #include +#include #include =20 #define IRQ_TYPE_INTX 0 @@ -29,6 +31,8 @@ #define COMMAND_READ BIT(3) #define COMMAND_WRITE BIT(4) #define COMMAND_COPY BIT(5) +#define COMMAND_ENABLE_DOORBELL BIT(6) +#define COMMAND_DISABLE_DOORBELL BIT(7) =20 #define STATUS_READ_SUCCESS BIT(0) #define STATUS_READ_FAIL BIT(1) @@ -39,6 +43,11 @@ #define STATUS_IRQ_RAISED BIT(6) #define STATUS_SRC_ADDR_INVALID BIT(7) #define STATUS_DST_ADDR_INVALID BIT(8) +#define STATUS_DOORBELL_SUCCESS BIT(9) +#define STATUS_DOORBELL_ENABLE_SUCCESS BIT(10) +#define STATUS_DOORBELL_ENABLE_FAIL BIT(11) +#define STATUS_DOORBELL_DISABLE_SUCCESS BIT(12) +#define STATUS_DOORBELL_DISABLE_FAIL BIT(13) =20 #define FLAG_USE_DMA BIT(0) =20 @@ -66,6 +75,7 @@ struct pci_epf_test { bool dma_supported; bool dma_private; const struct pci_epc_features *epc_features; + struct pci_epf_bar db_bar; }; =20 struct pci_epf_test_reg { @@ -80,6 +90,9 @@ struct pci_epf_test_reg { __le32 irq_number; __le32 flags; __le32 caps; + __le32 doorbell_bar; + __le32 doorbell_offset; + __le32 doorbell_data; } __packed; =20 static struct pci_epf_header test_header =3D { @@ -667,6 +680,121 @@ static void pci_epf_test_raise_irq(struct pci_epf_tes= t *epf_test, } } =20 +static irqreturn_t pci_epf_test_doorbell_handler(int irq, void *data) +{ + struct pci_epf_test *epf_test =3D data; + enum pci_barno test_reg_bar =3D epf_test->test_reg_bar; + struct pci_epf_test_reg *reg =3D epf_test->reg[test_reg_bar]; + u32 status =3D le32_to_cpu(reg->status); + + status |=3D STATUS_DOORBELL_SUCCESS; + reg->status =3D cpu_to_le32(status); + pci_epf_test_raise_irq(epf_test, reg); + + return IRQ_HANDLED; +} + +static void pci_epf_test_doorbell_cleanup(struct pci_epf_test *epf_test) +{ + struct pci_epf_test_reg *reg =3D epf_test->reg[epf_test->test_reg_bar]; + struct pci_epf *epf =3D epf_test->epf; + + free_irq(epf->db_msg[0].virq, epf_test); + reg->doorbell_bar =3D cpu_to_le32(NO_BAR); + + pci_epf_free_doorbell(epf); +} + +static void pci_epf_test_enable_doorbell(struct pci_epf_test *epf_test, + struct pci_epf_test_reg *reg) +{ + u32 status =3D le32_to_cpu(reg->status); + struct pci_epf *epf =3D epf_test->epf; + struct pci_epc *epc =3D epf->epc; + struct msi_msg *msg; + enum pci_barno bar; + size_t offset; + int ret; + + ret =3D pci_epf_alloc_doorbell(epf, 1); + if (ret) + goto set_status_err; + + msg =3D &epf->db_msg[0].msg; + bar =3D pci_epc_get_next_free_bar(epf_test->epc_features, epf_test->test_= reg_bar + 1); + if (bar < BAR_0) + goto err_doorbell; + + ret =3D request_irq(epf->db_msg[0].virq, pci_epf_test_doorbell_handler, 0, + "pci-ep-test-doorbell", epf_test); + if (ret) { + dev_err(&epf->dev, + "Failed to request doorbell IRQ: %d\n", + epf->db_msg[0].virq); + goto err_doorbell; + } + + reg->doorbell_data =3D cpu_to_le32(msg->data); + reg->doorbell_bar =3D cpu_to_le32(bar); + + msg =3D &epf->db_msg[0].msg; + ret =3D pci_epf_align_inbound_addr(epf, bar, ((u64)msg->address_hi << 32)= | msg->address_lo, + &epf_test->db_bar.phys_addr, &offset); + + if (ret) + goto err_doorbell; + + reg->doorbell_offset =3D cpu_to_le32(offset); + + epf_test->db_bar.barno =3D bar; + epf_test->db_bar.size =3D epf->bar[bar].size; + epf_test->db_bar.flags =3D epf->bar[bar].flags; + + ret =3D pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &epf_test->db_b= ar); + if (ret) + goto err_doorbell_set_bar; + + status |=3D STATUS_DOORBELL_ENABLE_SUCCESS; + reg->status =3D cpu_to_le32(status); + return; + +err_doorbell_set_bar: + pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &epf->bar[bar]); +err_doorbell: + pci_epf_test_doorbell_cleanup(epf_test); +set_status_err: + status |=3D STATUS_DOORBELL_ENABLE_FAIL; + reg->status =3D cpu_to_le32(status); +} + +static void pci_epf_test_disable_doorbell(struct pci_epf_test *epf_test, + struct pci_epf_test_reg *reg) +{ + enum pci_barno bar =3D le32_to_cpu(reg->doorbell_bar); + u32 status =3D le32_to_cpu(reg->status); + struct pci_epf *epf =3D epf_test->epf; + struct pci_epc *epc =3D epf->epc; + int ret; + + if (bar < BAR_0) + goto set_status_err; + + pci_epf_test_doorbell_cleanup(epf_test); + + ret =3D pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &epf->bar[bar]); + if (ret) + goto set_status_err; + + status |=3D STATUS_DOORBELL_DISABLE_SUCCESS; + reg->status =3D cpu_to_le32(status); + + return; + +set_status_err: + status |=3D STATUS_DOORBELL_DISABLE_FAIL; + reg->status =3D cpu_to_le32(status); +} + static void pci_epf_test_cmd_handler(struct work_struct *work) { u32 command; @@ -714,6 +842,14 @@ static void pci_epf_test_cmd_handler(struct work_struc= t *work) pci_epf_test_copy(epf_test, reg); pci_epf_test_raise_irq(epf_test, reg); break; + case COMMAND_ENABLE_DOORBELL: + pci_epf_test_enable_doorbell(epf_test, reg); + pci_epf_test_raise_irq(epf_test, reg); + break; + case COMMAND_DISABLE_DOORBELL: + pci_epf_test_disable_doorbell(epf_test, reg); + pci_epf_test_raise_irq(epf_test, reg); + break; default: dev_err(dev, "Invalid command 0x%x\n", command); break; --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A3792FE36C; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; cv=none; b=Kc0RoDSqVBNMnVv/bPs/VZ+GQjPLPdMXAZet//q5MxLrgYKTfK/75pTRrfbsHFeGR5jlJLyUYeqZ2+sT1ft+2SKSkRkv+Ib5Cvdag7yhuGo2zZ7zmYaQhEkR9fRsbXZ+WjyVxrsd2MgPrLSU6dAx93Istgqp2URanMRS5f+FPm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; c=relaxed/simple; bh=qzQN1/FxrgD81U6ooAWpH7PxpXbtzfixiuy2FxBNv1o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iUFJDR2J/z6b/nCFCQihDreBfp1NqxELBak64iAbObODFXcifccpY+w1xFpZ2qbNrSEzOgWgscp+LRVMjU0uAzyB5+4GQnPsZVXq9QHtJBN36wLRoFuhjlIl2f4qxMsMor2dRQXD6W96+yylVhYeFFKTmfTSOZj2uwrCWr7Wn80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Axoa9fc2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Axoa9fc2" Received: by smtp.kernel.org (Postfix) with ESMTPS id 44106C4AF68; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=qzQN1/FxrgD81U6ooAWpH7PxpXbtzfixiuy2FxBNv1o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Axoa9fc2nj/uOknEtcUiwCuZxK9O7gx3kBpaEtwJM9lUyy/Np5bTHqxiVx2CCK6/9 TNN9ZM2RhFo6ix5K8HSjRx62NwZRXqpyW/ztwN1AeWUvxvS3kG10LbbZpTDFdVXya6 xtWUexLfRfedx9zk6BF/RR2Q9KhdXQl8CfWYoZq/GlEuVxnj0sooeL02ph8tFxykHh Rn1qHOko97HglWDhcQcNJYNeiFatG/00AeR7ly7ak3uFMmdt7HhF9HE/rc20JRuP8I AXf1H6TwFk+mp9NlMFq7WvpFWWjlveO3yUKXR1u7I8hQjULjKZ2BSWt1dErsw2xLHC m8M9uR5Yg/K1Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A5D5C83F17; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:53 -0400 Subject: [PATCH v21 7/9] misc: pci_endpoint_test: Add doorbell test case Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-7-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=6983; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=FoxgpA+/NWTzqQeIBBDO30/i05zAkjJdsIvFlu/mx1M=; b=XpGMozBidTxLuAF61PACjGXZEfB2hr2pnL6D8lpZk4dxZ7lYSsMY5DKafbT015pqozhFvfwaV 5je1qFLKnneB65i2Lyn4XQs2ctGU2w7P4ZfEswnG3SiT3l0Uzl51OQq X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Add three registers: PCIE_ENDPOINT_TEST_DB_BAR, PCIE_ENDPOINT_TEST_DB_ADDR, and PCIE_ENDPOINT_TEST_DB_DATA. Trigger the doorbell by writing data from PCI_ENDPOINT_TEST_DB_DATA to the address provided by PCI_ENDPOINT_TEST_DB_OFFSET and wait for endpoint feedback. Add two command to COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL to enable EP side's doorbell support and avoid compatible problem, which host side driver miss-match with endpoint side function driver. See below table: Host side new driver Host side old driver EP: new driver S F EP: old driver F F S: If EP side support MSI, 'pci_endpoint_test -f pcie_ep_doorbell' return success. If EP side doesn't support MSI, the same to 'F'. F: 'pci_endpoint_test -f pcie_ep_doorbell' return failure, other case as usual. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- changes in v20 - add return value check of wait_for_completion_timeout() - fix some error message - remove Tested-by: Niklas Cassel change from v14 to v16 - none Change from v13 to v14 - update to use pci_endpoint_test -f pcie_ep_doorbell - change ioctrl id to fix conflict Change from v9 to v13 - none Change from v8 to v9 - change PCITEST_DOORBELL to 0xa Change form v6 to v8 - none Change from v5 to v6 - %s/PCI_ENDPOINT_TEST_DB_ADDR/PCI_ENDPOINT_TEST_DB_OFFSET/g Change from v4 to v5 - remove unused varible - add irq_type at pci_endpoint_test_doorbell(); change from v3 to v4 - Add COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. - Remove new DID requirement. --- drivers/misc/pci_endpoint_test.c | 85 ++++++++++++++++++++++++++++++++++++= +++- include/uapi/linux/pcitest.h | 1 + 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index c4e5e2c977be27adf1451b67ee10cc3ae6fb0cef..254b7f9cbe87b97b4d5d555ffbc= cc9055fc52330 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -37,6 +37,8 @@ #define COMMAND_READ BIT(3) #define COMMAND_WRITE BIT(4) #define COMMAND_COPY BIT(5) +#define COMMAND_ENABLE_DOORBELL BIT(6) +#define COMMAND_DISABLE_DOORBELL BIT(7) =20 #define PCI_ENDPOINT_TEST_STATUS 0x8 #define STATUS_READ_SUCCESS BIT(0) @@ -48,6 +50,11 @@ #define STATUS_IRQ_RAISED BIT(6) #define STATUS_SRC_ADDR_INVALID BIT(7) #define STATUS_DST_ADDR_INVALID BIT(8) +#define STATUS_DOORBELL_SUCCESS BIT(9) +#define STATUS_DOORBELL_ENABLE_SUCCESS BIT(10) +#define STATUS_DOORBELL_ENABLE_FAIL BIT(11) +#define STATUS_DOORBELL_DISABLE_SUCCESS BIT(12) +#define STATUS_DOORBELL_DISABLE_FAIL BIT(13) =20 #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 @@ -62,6 +69,7 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 =20 #define PCI_ENDPOINT_TEST_FLAGS 0x2c + #define FLAG_USE_DMA BIT(0) =20 #define PCI_ENDPOINT_TEST_CAPS 0x30 @@ -70,6 +78,10 @@ #define CAP_MSIX BIT(2) #define CAP_INTX BIT(3) =20 +#define PCI_ENDPOINT_TEST_DB_BAR 0x34 +#define PCI_ENDPOINT_TEST_DB_OFFSET 0x38 +#define PCI_ENDPOINT_TEST_DB_DATA 0x3c + #define PCI_DEVICE_ID_TI_AM654 0xb00c #define PCI_DEVICE_ID_TI_J7200 0xb00f #define PCI_DEVICE_ID_TI_AM64 0xb010 @@ -100,6 +112,7 @@ enum pci_barno { BAR_3, BAR_4, BAR_5, + NO_BAR =3D -1, }; =20 struct pci_endpoint_test { @@ -505,7 +518,7 @@ static int pci_endpoint_test_copy(struct pci_endpoint_t= est *test, =20 if (irq_type < PCITEST_IRQ_TYPE_INTX || irq_type > PCITEST_IRQ_TYPE_MSIX) { - dev_err(dev, "Invalid IRQ type option\n"); + dev_err(dev, "Invalid IRQ type\n"); return -EINVAL; } =20 @@ -841,6 +854,73 @@ static int pci_endpoint_test_set_irq(struct pci_endpoi= nt_test *test, return 0; } =20 +static int pci_endpoint_test_doorbell(struct pci_endpoint_test *test) +{ + struct pci_dev *pdev =3D test->pdev; + struct device *dev =3D &pdev->dev; + int irq_type =3D test->irq_type; + enum pci_barno bar; + u32 data, status; + u32 addr; + int left; + + if (irq_type < PCITEST_IRQ_TYPE_INTX || + irq_type > PCITEST_IRQ_TYPE_MSIX) { + dev_err(dev, "Invalid IRQ type option\n"); + return -EINVAL; + } + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, + COMMAND_ENABLE_DOORBELL); + + left =3D wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(= 1000)); + + status =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + if (!left || (status & STATUS_DOORBELL_ENABLE_FAIL)) { + dev_err(dev, "Failed to enable doorbell\n"); + return -EINVAL; + } + + data =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_DATA); + addr =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_OFFSET); + bar =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_STATUS, 0); + + bar =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); + + writel(data, test->bar[bar] + addr); + + left =3D wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(= 1000)); + + status =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + + if (!left || !(status & STATUS_DOORBELL_SUCCESS)) + dev_err(dev, "Failed to trigger doorbell in endpoint\n"); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, + COMMAND_DISABLE_DOORBELL); + + wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); + + status |=3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + + if (status & STATUS_DOORBELL_DISABLE_FAIL) { + dev_err(dev, "Failed to disable doorbell\n"); + return -EINVAL; + } + + if (!(status & STATUS_DOORBELL_SUCCESS)) + return -EINVAL; + + return 0; +} + static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -891,6 +971,9 @@ static long pci_endpoint_test_ioctl(struct file *file, = unsigned int cmd, case PCITEST_CLEAR_IRQ: ret =3D pci_endpoint_test_clear_irq(test); break; + case PCITEST_DOORBELL: + ret =3D pci_endpoint_test_doorbell(test); + break; } =20 ret: diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h index d3aa8715a525ea47485db734a42d13d333399112..d6023a45a9d03416e220c98643c= 4e86d144898ae 100644 --- a/include/uapi/linux/pcitest.h +++ b/include/uapi/linux/pcitest.h @@ -21,6 +21,7 @@ #define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int) #define PCITEST_GET_IRQTYPE _IO('P', 0x9) #define PCITEST_BARS _IO('P', 0xa) +#define PCITEST_DOORBELL _IO('P', 0xb) #define PCITEST_CLEAR_IRQ _IO('P', 0x10) =20 #define PCITEST_IRQ_TYPE_UNDEFINED -1 --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A2202FE36A; Thu, 10 Jul 2025 19:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; cv=none; b=fwsDXcm30cjtmCkySaUclS5iatl9S9DQ8y2Q5K/DSaAMcdGYOkVF7nYJpOvAL6gvTjZiPrX02TVLYuEESldj/iovh1hEOdQzGylXn6rqK63DaJ4w8pWKNvdA0JukbB/pc5O5XdjG7bI1obWPdVKcPj4g3dxiCsE205Izb6RgtrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; c=relaxed/simple; bh=ZhOpD4uE06bSl49Vy//uqz1o4AjQqGjxPfMTgkddWP8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=elHxgQp3LCWCu7rQ/VJVHh6LhdE8mr2QmucSmIkzOY5FO7g+mfAautQ7ij9bYsnn5xobg9BA94cGvU7unLPGMm+neVz7Ih7B8ygWiHHVbU08vv+jBvevyBdvBiKTmn6odLElt3y9neMnIJ3GjnbVMq6jF3eHJtUn30JUnv6DYe4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VTvVuHo+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VTvVuHo+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 54B29C2BCFA; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=ZhOpD4uE06bSl49Vy//uqz1o4AjQqGjxPfMTgkddWP8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VTvVuHo+1QMcjvL4lBbivogileoz7xkPn/yJXZj0/lXYh8qolGRjMdO1EO9t3zf92 y05YYQDWvXbR2e7irt2TW1f3ncn65Fv9G7798JMHugJ0ueZrR0Jr7YnoFQshj55il/ cOTPVj7wQ80ChmxA8qrTUzfQ7gXKs3wsRbXWkbugtEeCtsM0gPGvyC+XM9UmarQtvw ANLAXDQ/Co5x+H/Maxl5IhfbrhtJ4TrPQFHppDnj1DsU9bzBiNs19dumB2z6+WmRyd SW9+tAgSMdvTr2ZBzRXbLxznC1r0XUQdBEwOl1F8YZSlETcy/izs5C2Tt3wKp+arcD BT4B9SJldw7kg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A59BC83F21; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:54 -0400 Subject: [PATCH v21 8/9] selftests: pci_endpoint: Add doorbell test case Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-8-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=2413; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=DF/gzaI0MKU27j4SEtbbhXRg9y3PEJqjIqoano8U714=; b=6FIBzlhLvKK9PMtRFgv9fQ0u15RhOYaMaf9U560iK36vP7lgw6gVapL02c73Pu/nxmQww9moK MkPvMxbACpZBtrbLyQv46qo1NUMvbpVFKhdkfpsbE14aoTCK68v2+Op X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Add doorbell test case. Signed-off-by: Frank Li Tested-by: Niklas Cassel --- change in v20 - update document change from v14 to v16 - Add set IRQ type change from v13 to v14 - merge to selftests framework --- Documentation/PCI/endpoint/pci-test-howto.rst | 14 +++++++++++ .../selftests/pci_endpoint/pci_endpoint_test.c | 28 ++++++++++++++++++= ++++ 2 files changed, 42 insertions(+) diff --git a/Documentation/PCI/endpoint/pci-test-howto.rst b/Documentation/= PCI/endpoint/pci-test-howto.rst index aafc17ef3fd31f6ada38c82c8df133b87f7a1ae1..0cee35dcb29cc938823de53ef6e= 1a1cd81d49d52 100644 --- a/Documentation/PCI/endpoint/pci-test-howto.rst +++ b/Documentation/PCI/endpoint/pci-test-howto.rst @@ -203,3 +203,17 @@ controllers, it is advisable to skip this testcase usi= ng this command:: =20 # pci_endpoint_test -f pci_ep_bar -f pci_ep_basic -v memcpy -T COPY_TEST = -v dma + +Kselftest EP Doorbell +~~~~~~~~~~~~~~~~~~~~~ + +If EP side have MSI controller, run below command to test doorbell functio= n. + + # pci_endpoint_test -f pcie_ep_doorbell + + # Starting 1 tests from 1 test cases. + # RUN pcie_ep_doorbell.DOORBELL_TEST ... + # OK pcie_ep_doorbell.DOORBELL_TEST + ok 1 pcie_ep_doorbell.DOORBELL_TEST + # PASSED: 1 / 1 tests passed. + # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0 diff --git a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c b/too= ls/testing/selftests/pci_endpoint/pci_endpoint_test.c index ac26481d29d9dce5d07de563048850c55c58c22d..da0db0e7c9693f11b4975ca0e68= 30174229983ba 100644 --- a/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c +++ b/tools/testing/selftests/pci_endpoint/pci_endpoint_test.c @@ -229,4 +229,32 @@ TEST_F(pci_ep_data_transfer, COPY_TEST) test_size[i]); } } + +FIXTURE(pcie_ep_doorbell) +{ + int fd; +}; + +FIXTURE_SETUP(pcie_ep_doorbell) +{ + self->fd =3D open(test_device, O_RDWR); + + ASSERT_NE(-1, self->fd) TH_LOG("Can't open PCI Endpoint Test device"); +}; + +FIXTURE_TEARDOWN(pcie_ep_doorbell) +{ + close(self->fd); +}; + +TEST_F(pcie_ep_doorbell, DOORBELL_TEST) +{ + int ret; + + pci_ep_ioctl(PCITEST_SET_IRQTYPE, PCITEST_IRQ_TYPE_AUTO); + ASSERT_EQ(0, ret) TH_LOG("Can't set AUTO IRQ type"); + + pci_ep_ioctl(PCITEST_DOORBELL, 0); + EXPECT_FALSE(ret) TH_LOG("Test failed for Doorbell\n"); +} TEST_HARNESS_MAIN --=20 2.34.1 From nobody Tue Oct 7 09:56:59 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FDE92FE36D; Thu, 10 Jul 2025 19:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; cv=none; b=NcbGZEODEM9gYceUwkvXzLFnPgbloI6wJqt1rWtehb57zlq9EAIwam7Uwm4Gw1oad76b8oAGkAP+J4l8hJ/fYhhziCCPEqRqLNQ6v6LAZ7ZXCyGuJUBXpEcpkGLntW78F0OxAizhEKSG7WFP4T9cWsV5L9CbkPRKqi0seaVY54s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752174839; c=relaxed/simple; bh=UfZBgPNXsNVvIoKoizlLf9l//dyhqb8DPMRaq9LzZjs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RjQQzBVkZw93Cd8TN3Steza+S5dTDRkK2KLesJc3hSYqj/Xm8GoLyz+tdRmBXRGouUGOIZR0jRnY7Wj2Qzm+tPgN30zh4Sbk8OB6eCoi4Z1cyhJZ6bv5wC+3Sw2xDDpt0YP3IZaAfDOGTZFO7LtJD2VGRZN95TT/vKP7oD7Tkk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fhZZ3o+B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fhZZ3o+B" Received: by smtp.kernel.org (Postfix) with ESMTPS id 65B66C4CEF4; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752174838; bh=UfZBgPNXsNVvIoKoizlLf9l//dyhqb8DPMRaq9LzZjs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=fhZZ3o+B1YOtPqq/GZDBQRyKrQ3TA+FY7IoW3Vu6T9SZCiKzb77vnw8i9XEQipqI8 WMqg8ezFZbAY1pc+/AIQxlfckXGS2K3ISIu+WtoFIWTrHQY1mZNvEzTXDGJXQh19vx 6b8xfhJpsa/fCfIJbxjJm01axbc1fwN8gfUXhUdyVRY9qxvGS9/1dQEKwLKJQsEhNn e5ZN2V8W73yZkCLaWqGkx8DZlBF9jrDLv5P0EZk8CyE9O8UEsmxdSQh7KLT9Y8b/Ou U90yI9q9WncbdbxEoX5jPprj2N1ZEpuu0AD8iqg3Dgb9idLWQfhfuTEAZ2JuPxDVeV 2a91VLn1XDq4A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B55AC83F22; Thu, 10 Jul 2025 19:13:58 +0000 (UTC) From: Frank Li via B4 Relay Date: Thu, 10 Jul 2025 15:13:55 -0400 Subject: [PATCH v21 9/9] arm64: dts: imx95: Add msi-map for pci-ep device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250710-ep-msi-v21-9-57683fc7fb25@nxp.com> References: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> In-Reply-To: <20250710-ep-msi-v21-0-57683fc7fb25@nxp.com> To: Kishon Vijay Abraham I , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Kishon Vijay Abraham I , Marc Zyngier , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Shuah Khan , Richard Zhu , Lucas Stach , Lorenzo Pieralisi , Rob Herring , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= Cc: Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-kselftest@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, Niklas Cassel , Frank Li , Manivannan Sadhasivam X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752174836; l=973; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=wW9Nwm5vAKtBf5Pux9lo/+uSvITxDxxhF8J82uPpSQ8=; b=VtcLSyohMB2FbPRKwdeAd1gT+yHIS4yjiZLuRPs9oX0oesyANEabrauubaRWQWZI0Hoa9Tyqq pt88S7wZQTQB5u0CTEtvjMU/70Lk/gnk03eIJ59F7pIgZX/e5D2tHlw X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-Endpoint-Received: by B4 Relay for Frank.Li@nxp.com/20240130 with auth_id=121 X-Original-From: Frank Li Reply-To: Frank.Li@nxp.com From: Frank Li Add msi-map for pci-ep device. Acked-by: Manivannan Sadhasivam Signed-off-by: Frank Li Tested-by: Niklas Cassel --- change in v20 - add Manivannan's ACK change from v14 to v16 - none change from v13 to v14 - new patch --- arch/arm64/boot/dts/freescale/imx95.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/freescale/imx95.dtsi b/arch/arm64/boot/dts= /freescale/imx95.dtsi index 632631a2911224cadc16a943cdb467e091e43384..c59d11eb7a581a500d381ef96f1= e44533052c2a2 100644 --- a/arch/arm64/boot/dts/freescale/imx95.dtsi +++ b/arch/arm64/boot/dts/freescale/imx95.dtsi @@ -1797,6 +1797,7 @@ pcie1_ep: pcie-ep@4c380000 { assigned-clock-rates =3D <3600000000>, <100000000>, <10000000>; assigned-clock-parents =3D <0>, <0>, <&scmi_clk IMX95_CLK_SYSPLL1_PFD1_DIV2>; + msi-map =3D <0x0 &its 0x98 0x1>; power-domains =3D <&scmi_devpd IMX95_PD_HSIO_TOP>; status =3D "disabled"; }; --=20 2.34.1