From patchwork Fri Nov 8 19:43:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13868866 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2054.outbound.protection.outlook.com [40.107.22.54]) (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 668A71C1F24; Fri, 8 Nov 2024 19:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731095037; cv=fail; b=mOugpms6ASrlrIBBCRhomZSxdSqX9RSyNT7tV2PeFTKEN3hlura91dapuwHRFiT/9EMvLqN+E4Z7t3fILiJK4njDASotnDnKEVh+wmuG3PlLfhspwC6OMC1EOH7sBXzsOyqcFUtly8Ysz/6DXO8cX6pmsbqq2yAf6a2tPQfokfk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731095037; c=relaxed/simple; bh=qYxIU8kchQtHsEa3c+NUqckv3V8JSjV+g2iyHqr0Y9w=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FOY8zNN6QtuoIru+xv9CH54DgPbtbddYtOMA0IF4/8GCJZ/KgxHME1y1Vyf+Qcg/BBttAOFBHYbFn/Y+rkI1COsfz3HlZHblN6ytnULKUwD9vU9xwvgyorO7iywoxGU8Q2qRKzRK90s/0vR6LFiPPXOq05pesDniBQOd9RxJsTk= 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=kC1LrNR+; arc=fail smtp.client-ip=40.107.22.54 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="kC1LrNR+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mjr2r76tOPXDIddMzEF/ZZjkKPq8qXgguWSB0vW6Lh/BhySWa6uEAFuIUMXKnNCA/lqNyv0c28N+tyjy/AQpkge3LlEkOGn5iNLq0eTB1wH+yAZE+69/mSI4pNMsWipvnUZEUPUBGDbpbfB9MQIscG+pMh0MqNMAi8SvuWSphJa5OLG5jW4wTvBwYNVXHs57xmEDOxh/Tmo/8O655oLXQ/cvaI0HsABUL3D4ysZyxh8tckRddFetsVhXKUCejzrOEeo9eGK98EXX5ss7JKRZmysyylpoAyMfbXj7WW1+DlaICUAEnGtmaD4FTtF7XXt02wMce15n/rN6PjBTKna2wA== 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=z2SKH2oS8EKt3hJu2TO5lwqproQ90A1PIbYf5vAd3Yw=; b=k3dHLY3j2mSpX9NDrpE9a/mQpfftGPG6LmcT4Mht1F2SBSVbctISWVB3OqRRSCQPG129RR9IOGbsov7vyjFMJsuSagctw/ixQAKgbs0MQ/rQbwAPjBHRVtw1HSPAEqnWs2dRPg85kgBrb3thG11EqFUqqRwbAVpPdEDZeE+J7DfsCvjLcUJO7Jy3ZKIwqvYKwssSRmj2HZ8s6cxsh1wQHWLwNLQtHA2Rps6XKhbrmqu6ul6IpP7ygsOHX84cbhb+LEl+16RG8n/+NgZ4Gzs7Wkr66wL9YC995jZUbHUqHqvFhWIa/u7uJyb7YJWsXXFIh2IruCknNk4OrwTFMLEJcw== 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=z2SKH2oS8EKt3hJu2TO5lwqproQ90A1PIbYf5vAd3Yw=; b=kC1LrNR+9kV5edRjY+UVsZwJLJT0Ad04ZwcvlQT/Vx0eScrtx1C32l7THJ4o3Y1u0EsHKFzyar3oHvw4grWXyajeZqPaetosQaBEhxx/+ic6yv4hzEKzlmSaq9zneud70wis+TnQROyLA/jbJMiMX1+w2G+DYr9eCPAUzDQ8Yp6oxCF8sqS4GfU6chdXgru1/LWFcqSO+fexBmafrr1+MmTg1M5j9wMMJ0t0LpaDhFIBErpEP/8/0XQaCRS7Z51d6gpPbzvthFaWuBumgBZkHCQ04yPBybyUtUK+VzXoMrJVh4llutHelkThQ7CE07uju2zgtKy0ZSCGrkBzTxxKQw== 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 PAXPR04MB8669.eurprd04.prod.outlook.com (2603:10a6:102:21c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Fri, 8 Nov 2024 19:43:53 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8137.021; Fri, 8 Nov 2024 19:43:53 +0000 From: Frank Li Date: Fri, 08 Nov 2024 14:43:29 -0500 Subject: [PATCH v5 2/5] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller Message-Id: <20241108-ep-msi-v5-2-a14951c0d007@nxp.com> References: <20241108-ep-msi-v5-0-a14951c0d007@nxp.com> In-Reply-To: <20241108-ep-msi-v5-0-a14951c0d007@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1731095022; l=6220; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=qYxIU8kchQtHsEa3c+NUqckv3V8JSjV+g2iyHqr0Y9w=; b=B/e51zaazNqgVAEv7Uyg42iGV3dN+UwtuAT8I2kJeQRw9NZeabJN8dxxMdVuIuXuIBRPUXf/P HfiMe08bSL4BwAIX7a/Bpxd5Raq3wx4zWssS8I2eswr0sNijtWc2tF1 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY1P220CA0026.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::17) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAXPR04MB8669:EE_ X-MS-Office365-Filtering-Correlation-Id: 61523f2f-c7e5-4bc6-23f1-08dd002dacfe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016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hHFO?= =?utf-8?q?vwVEEcqHeiS/RDzDjgYPLeyvPpS4KP5O6+GQJWJEkT0E095dtFTRdHKNMKo0QatnK?= =?utf-8?q?zjUbOHiolApMFfdV+TQq7JPg34Bvoe7v1ToZJ1Ucj0Mb/AlExYlU2ImrHB0QM1N/c?= =?utf-8?q?aUf8ZS/iADQjIj6gwhPQpd0Kgm2EQdSILiFuMRN5pXugweuFfHbri7nI9KT9X75Bw?= =?utf-8?q?qqTUbBxSrgA9TmaoNGA/6D4t0pxAEEuEa2Aio+NeqcbDVFtR+btkiZmkjTahFFvNx?= =?utf-8?q?8C/FAlMoDwlSuZ1EPFMd3pPefZ+EqNOi4VTs/JyjSEqlddvoHCTsXwoWA3ro3RUem?= =?utf-8?q?gQyQXNAZR3rQx9twT6b6SF0eaKx0z+ht+HZcVR5WgJUFaTJ7bCRh864Dbs7fK3XEU?= =?utf-8?q?STan5Q7nfXdcD2U/FvIO2xicodu4eM3gkdTwhITr10KxIN3R8Twnfkjco7naGHnxe?= =?utf-8?q?lwANHUDXo+DGt9nkcw/vEgYJWk82hSg1Inwl4C1/S1SsW2e7M0bqgSAY=3D?= 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)(1800799024)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?A4aqoM0heLO+5JUwqbq3cYB4H1lq?= =?utf-8?q?4Z+jmrTxMawi3TX5tgtC5y9htjIAjrXWBPgJrib6griji2t2tvhpZg2MvNGlZZ4ie?= =?utf-8?q?ZC3tWM84Dr+cYqfSuKpz8Tbg3jL8Q1qgbe+YbRT92Bk3MNbJbBUHBakbv5w0vqP5I?= =?utf-8?q?fx3fgBXNZ5qRE22cwCL5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6AwY+NlmD4JVsNR8FWyMABbDNFYQofxjwUQOgi?= =?utf-8?q?EYSWZj9Ry3ZgYFsfzvA0322DKkaqJDgmh234I/a/kBQCZ0m6bjwKId5v7KFSasUSr?= =?utf-8?q?JrxzmVRJZMUrNcvprLt1T8ICd3FPBd2q56ph0KbxHDxKDig6DavUBHIAfR4VRQyHZ?= =?utf-8?q?Q9+/IZ9GRMeGN4bJnlEEEHQ5F37EYKNef7fK387vOF5W1SUFrzUmGHN82KdU4CxAv?= =?utf-8?q?shY4lMpCytEz6Um/oKw8fn5gbrWef7YwCqIxcNMu9MPPB7wawvbIY2BriVcI4dESP?= =?utf-8?q?D503IpphWDBIsc1dnKLT6g0urg4y/yvewJlBvHgNtGYvsF7l8gUEbRkOS4d1SKRoK?= =?utf-8?q?Yj6LhHRAlAMcDGHNKIBZ70tmnMK5NXQsnVAyXv8f7plUTWm3r4UnuVoLZS8JwT5zy?= =?utf-8?q?ZLMfNcfbRpU39ir7+7h5TwmzsLbJGIbqwp/qZNEle69/Bwp/3Sv+XoM5UFfKYztzN?= =?utf-8?q?1q2nUworJl0N?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61523f2f-c7e5-4bc6-23f1-08dd002dacfe X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2024 19:43:53.3086 (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: aCWTffUS4Lbs1e4uyU1obX18Ar5BLYOvbF4VPNqae6/nkseXbNsrASowY3chT4orWb3KdheJeLnUcJ5VeRfXzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8669 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 --- 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/Makefile | 2 +- drivers/pci/endpoint/pci-ep-msi.c | 99 +++++++++++++++++++++++++++++++++++++++ include/linux/pci-ep-msi.h | 15 ++++++ include/linux/pci-epf.h | 16 +++++++ 4 files changed, 131 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 @@ obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) += pci-ep-cfs.o obj-$(CONFIG_PCI_ENDPOINT) += 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-ep-msi.c new file mode 100644 index 0000000000000..7868a529dce37 --- /dev/null +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -0,0 +1,99 @@ +// 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 + +static bool pci_epc_match_parent(struct device *dev, void *param) +{ + return dev->parent == param; +} + +static void pci_epc_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) +{ + struct pci_epc *epc __free(pci_epc_put) = NULL; + struct pci_epf *epf; + + epc = pci_epc_get_fn(pci_epc_match_parent, desc->dev); + if (!epc) + return; + + /* Only support one EPF for doorbell */ + epf = 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)); +} + +static void pci_epc_free_doorbell(struct pci_epc *epc, struct pci_epf *epf) +{ + guard(mutex)(&epc->lock); + + platform_device_msi_free_irqs_all(epc->dev.parent); +} + +static int pci_epc_alloc_doorbell(struct pci_epc *epc, struct pci_epf *epf) +{ + struct device *dev = epc->dev.parent; + u16 num_db = epf->num_db; + int i = 0; + int ret; + + guard(mutex)(&epc->lock); + + ret = platform_device_msi_init_and_alloc_irqs(dev, num_db, pci_epc_write_msi_msg); + if (ret) { + dev_err(dev, "Failed to allocate MSI, may miss 'msi-parent' at your DTS\n"); + return -ENOMEM; + } + + for (i = 0; i < num_db; i++) + epf->db_msg[i].virq = msi_get_virq(dev, i); + + return 0; +}; + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) +{ + struct pci_epc *epc = epf->epc; + void *msg; + int ret; + + msg = kcalloc(num_db, sizeof(struct pci_epf_doorbell_msg), GFP_KERNEL); + if (!msg) + return -ENOMEM; + + epf->num_db = num_db; + epf->db_msg = msg; + + ret = pci_epc_alloc_doorbell(epc, epf); + if (ret) + kfree(msg); + + return ret; +} +EXPORT_SYMBOL_GPL(pci_epf_alloc_doorbell); + +void pci_epf_free_doorbell(struct pci_epf *epf) +{ + struct pci_epc *epc = epf->epc; + + pci_epc_free_doorbell(epc, epf); + + kfree(epf->db_msg); + epf->db_msg = NULL; + epf->num_db = 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 0000000000000..f0cfecf491199 --- /dev/null +++ b/include/linux/pci-ep-msi.h @@ -0,0 +1,15 @@ +/* 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__ + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 nums); +void pci_epf_free_doorbell(struct pci_epf *epf); + +#endif /* __PCI_EP_MSI__ */ diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 18a3aeb62ae4e..5374e6515ffa0 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -12,6 +12,7 @@ #include #include #include +#include #include struct pci_epf; @@ -125,6 +126,17 @@ struct pci_epf_bar { int flags; }; +/** + * struct pci_epf_doorbell_msg - represents doorbell message + * @msi_msg: MSI message + * @virq: irq number of this doorbell MSI message + * @name: irq name for doorbell interrupt + */ +struct pci_epf_doorbell_msg { + struct msi_msg msg; + int virq; +}; + /** * struct pci_epf - represents the PCI EPF device * @dev: the PCI EPF device @@ -152,6 +164,8 @@ struct pci_epf_bar { * @vfunction_num_map: bitmap to manage virtual function number * @pci_vepf: list of virtual endpoint functions associated with this function * @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; @@ -182,6 +196,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; }; /**