From nobody Sat Dec 28 19:06:48 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2065.outbound.protection.outlook.com [40.107.20.65]) (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 A859E1FD78C; Wed, 18 Dec 2024 23:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734563356; cv=fail; b=kNnELR3jD6Jtc+KLPdmM5MuIFBsHZZ+N/0MaTErraZS3/LzoV+tY/uwrWo8cGMX5ID30wzfzpHGkmCtALYUGcBvqkDDmFNPCfTuaQ9qymm2h6+Bbh3gko3fL1rZZSbq3mYzKnjhOU7yhj+au7BNFWsfe0JkFMiWD3rlBtH8BdkY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734563356; c=relaxed/simple; bh=8xX2O9aY64VFlNrJ4JMgzHNkAgqXMerbLBmBZNQGjz4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=SaMn/w4PRe8URe05Xs/1kDqhwqsiEklvuQnaEih2lq+pfeuzInGkrYE81Ni0AW7WnREmJGauVZLONcwNghTJJoWT6Yr3oDE01PsphQujg1WrW6uYDKzdF2taJygFDNPyaZ3MWoO331mt848EszAYIJAjQYJS6535J1geTEs/aQA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=d9tYeYXh; arc=fail smtp.client-ip=40.107.20.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="d9tYeYXh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L2odVTGpHsQGT4I57ySQgdqfrpU9ngIbQQcUOg3Gbr9/QorDlBQUEWmeXu3nausyWKWKNi0WkWghSLEBw7rWV4r61LOdR/1/amnzOqfOk2M/Pp+lLirzhDIct8ludNuUOCCaFJgumI4yeKi4fwQuLTXW+B/pMLfrUEpZ87Xlv6zv7+B3wg+4iS0XD3yIr5sJsK4KLazhOf1P2SCCVO5bOHh0mWyPRy6mIFmR1ZGzDiV93hgHwdZK1ftBvt0JoDP5Z5f/z+bTSqHv4EONy0ioqVYo2L+VXn28zznDhAL1V2PYxmPEJaD+42N4024aBzBc8swVrekmRGmSFNZ8eZT2zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=qpwCdcZnpLhPQg1A7kmXJAjEvFPbhbqVp3GHX678bwU=; b=qPAM/ZpXQNEGFjxANvgBO632EEWldEWzZ9D8wSRL0LuVrzIDEKGmPi9Is407hKpqR1ORBgeBup6LfHQy0cx82/AoC4GBEkY0Pp8iNHOmtIa0bzqim16vbbe5uY1qautQ4gH2qEZoPJAVeMFYwbsZQtsKeN0/Fh+O/sG464c+jZ6R4JEn/Cx7PJMc7yAyBJYsW758j743xqcM0wrHQhIc55PPxdOAIgrRZvScgagLC1G9RNGLhZKSefjAtYSLC+JFosMNTQZaB7Bj7R9kJOjJLIiKpLmJ5VSg0ERxnorog4/ZrEdFW9c+gaZ+PFyJB5kl/SzSQYr1NKfmmvzxxxoJBw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qpwCdcZnpLhPQg1A7kmXJAjEvFPbhbqVp3GHX678bwU=; b=d9tYeYXh38HYN6LSwAabCbAAh8zSjgbD/xDUIn9LVbQNxvSWHFkXUsoMBm5AxI3/2Zb8jCefJzsuBB1pAv2NoL5U4XmS0seawniikuJMIIxW0yQfZZUwGin1R2uxBFktrggP3ffcPSF6BEnf0/xNTBop4qjoXumAdY3qTC9b0aXU/gUUXcv0vlZtv+8sF/DbdL+BaIsnGgWwycNKpoRnK0hV7yfg9g82Q6IUPg+bWM1twBuiriTVA4ErVO2/Ez1I8/MsUCyFj3cRJK6gRUhg4qN+kAs3Hm3FVLuhP/Nk2UHbB1sNvtFVf3cX4X+9noZZNzXK2V/ZmX5qPrW8B4nKlA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Wed, 18 Dec 2024 23:09:12 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8272.005; Wed, 18 Dec 2024 23:09:12 +0000 From: Frank Li Date: Wed, 18 Dec 2024 18:08:37 -0500 Subject: [PATCH v13 2/9] PCI: EP: Add helper function pci_epf_msi_domain_get_msi_rid() Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241218-ep-msi-v13-2-646e2192dc24@nxp.com> References: <20241218-ep-msi-v13-0-646e2192dc24@nxp.com> In-Reply-To: <20241218-ep-msi-v13-0-646e2192dc24@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1734563338; l=2838; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=8xX2O9aY64VFlNrJ4JMgzHNkAgqXMerbLBmBZNQGjz4=; b=4g3MAO978FVxgvHLb5QWKbUbMkZqfKtyTdfff+gf+cXJVSTis8LFOmkaEsaV7iJbi37aX4tUu bwAocx0Wl/pCT8ZyKH65Y7Mshm+6cJDZgx908faRugQGZ7F6i19R7V3 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0075.namprd13.prod.outlook.com (2603:10b6:a03:2c4::20) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c48fefa-cc85-4491-8ae2-08dd1fb8fc28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|52116014|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?= =?utf-8?B?a01tL1JQRFY4MjBJUi9Hb3dxQmFmNzNpRTVvREJraTFxVStpNS9FY3pWRVdY?= =?utf-8?B?NDI4NG1TMi9kUGFvaWM0bGhBcEtnRk9QWkxwQm1NMEd3UG01a2phR3N0WEhy?= =?utf-8?B?R3pNYWNPc1V2TXA1RThIbU1jbEdCZmtsQm9uQkFXbVdxQXR6U0lxVUw5WUtE?= =?utf-8?B?WllDUFBFYjYxclRDNllsamZ1S2hRSy94Sk4vK3NObGEyVyt0dE9JSW0wWTc3?= =?utf-8?B?b3ppY0s3YUx3PT0=?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(366016)(52116014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QVdMdXN3N29NcE4rTENkNGpJQUgzbUhvTWx4b2xMQUh3SmZDZWwrTVFaaVdI?= =?utf-8?B?SVlFZFRXRVpSdCtlSWRYQzloU2tqN0RsYnYwYjFmVEIwYlNkTTVxMmI1YzZM?= =?utf-8?B?MEo3YitWL1g2ZklVbSszZklKOFR2akd1K2tIcVh0QUt3MEFhM3lOOGYrQ2FP?= =?utf-8?B?RFlMY3FwR0ppRUtEZkhUZU9nWXVFT3BTODRYVy93TUtuTDYwMStueUgrcUtm?= =?utf-8?B?U0lIVlhZV1MzOHpmcVJFRHNGWWdiMFB3WURVZ0NBZjIvQnI1aGZVa0pBS0Y2?= =?utf-8?B?NmJjUk03WVhDTXhtZFNPYUh3SjBJdGVvV1p3bkI4bmZNNGgwS2YvZ1p5ajRj?= =?utf-8?B?UUFLK0w0ZlpxYTM3Ymx0cktIMTFncENIM2xqZWZMUzkrZG16dHFFSzRnUDMy?= =?utf-8?B?TkMz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X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2024 23:09:12.2241 (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: KnED7z48Ll3DzSbNKiGr1BANMMMDCpZNePQPpfhclIw/zRGCy6JDdFNkZTh7Wy/SNdtMXzI2JrBYdGdfbd7DXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 Add helper function pci_epf_msi_domain_get_msi_rid() to convert EP device id to msi domain's request ID to pave the road to support RC-to-EP doorbell with platform MSI controller. Signed-off-by: Frank Li --- change from v12 to v13 - new patch --- drivers/pci/endpoint/Makefile | 2 +- drivers/pci/endpoint/pci-ep-msi.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pci-ep-msi.h | 21 +++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/Makefile b/drivers/pci/endpoint/Makefile index 95b2fe47e3b06..a1ccce440c2c5 100644 --- a/drivers/pci/endpoint/Makefile +++ b/drivers/pci/endpoint/Makefile @@ -5,4 +5,4 @@ =20 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/ + pci-epc-mem.o pci-ep-msi.o functions/ diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-e= p-msi.c new file mode 100644 index 0000000000000..7aedc1cafbd14 --- /dev/null +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PCI Endpoint *Controller* (EPC) MSI library + * + * Copyright (C) 2024 NXP + * Author: Frank Li + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int pci_epf_msi_domain_get_msi_rid(struct device *dev, u32 *rid) +{ + struct pci_epf *epf =3D to_pci_epf(dev); + struct pci_epc *epc =3D epf->epc; + + if (!rid) + return -EINVAL; + + /* + * PCI Endpoint device ID can't full reuse PCI's BDF, BUS number is + * Root Complex Bus number, which is no means for EP side. Move func_no + * as low 3 bits to partially match PCI's BDF. + */ + *rid =3D of_msi_map_id(epc->dev.parent, NULL, (epf->func_no & 0x7) | (epf= ->vfunc_no << 3)); + + return 0; +} +EXPORT_SYMBOL_GPL(pci_epf_msi_domain_get_msi_rid); diff --git a/include/linux/pci-ep-msi.h b/include/linux/pci-ep-msi.h new file mode 100644 index 0000000000000..75236867426a4 --- /dev/null +++ b/include/linux/pci-ep-msi.h @@ -0,0 +1,21 @@ +/* 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__ + +#ifdef CONFIG_PCI_ENDPOINT +int pci_epf_msi_domain_get_msi_rid(struct device *dev, u32 *rid); +#else +static inline int pci_epf_msi_domain_get_msi_rid(struct device *dev, u32 *= rid) +{ + return -EINVAL; +} +#endif + +#endif /* __PCI_EP_MSI__ */ --=20 2.34.1