From nobody Mon Nov 25 00:32:38 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2045.outbound.protection.outlook.com [40.107.21.45]) (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 2F78D2E406; Thu, 31 Oct 2024 16:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392043; cv=fail; b=fwYoDsyWbL6aVCV5eicad1PhR3mCErjECUfk9vZd2bfaFdCXS6A5LnrBXOYi7lH1I8vtDcozBqoNeonAchgzODo3Z3MWow8OJv5SiL71NfsUrZIHC3PT0vQq/CJQ3RcpijgvrG4HaaGj9UjADXjmlaovn4scWINelNHOHJfnTEg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392043; c=relaxed/simple; bh=WztdJXCK+bOn8jeGvfQAh0AF4COBEh+c0a1xNE6MdUc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=O222GVxHvhCZCLSP4gL1h5eYJgIABOnto1AMmZnGCua8CQ03p5FbPwUv+H3XmzaaYvDDvMtJrNM4UYomsLmk8i5TCfflKuA0z/UMTeKOkPSEMW/6aS5VrufrdKav8LBi7XFSmT7m8RppEsN0XrFZGflIdQ/g3gZuAes9ruOywS8= 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=Bz+Q8Wdi; arc=fail smtp.client-ip=40.107.21.45 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="Bz+Q8Wdi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OUZIFn7/A2V2TsW3x3N3GGhrbAD1xOCpEfiCUuKW77KckS0+SjK/YdH+du9TLwZiUKCKUI5ff5O5xUiesTE4FfLTOsMkCjni6oQbrlwE167rdhBlhLjKOa2y077LNl37aqstITiZkOsN3eWI+Dxk2WMA4ryFwUDgQ3ghBIIOc6PkEazsRE6tBNhp77Msp4gIeLCvUX9UmY5TGzX+uqCKteFHexGs+PqHiNwtWJIyH8IkaqI5uZziSvFTqeYNtd0mW7aAzX/+sIt39QtKCngzvRTWCaHs/c30qiT93yMS1WbqvgWPUrdPfL3tQstQPfiP9BmXQt9dmC6uM5fBxsTjhQ== 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=Oan0nT460bnBSfdOKCXlsarwBLEOZ6HSByQIFZo5Sn4=; b=rN/wty1IPczsVy4Z+8AGBwTW+oUQs/hvWhoBL7XBY6JLSngz/GLrN1qEsghctkdU9I1BAeMHVouQjC9CaQBRyeg900pptNo9BB41thQWsYHaVRryVhkvhFGFRals8xWloAQE3gXvjJ1gnjDCIK52D+/Tk2C2/H1gzG9KlGKbKIGGzX0mn0nhNDbp+/eDVmWcIgyIsObPKnXCInCvnipD9kWy/Eb8Fwv4VxWdlth70hpacaHhpp0uGV0tkIfW14+WCoQ0zipnQrFJg47MfZcm/hKF1D07h0nv6rZcvX2T6y4qHHrt2KKGcUE7Bc1nqxwQB5ADxxlhNFEiYIdIHxCozQ== 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=Oan0nT460bnBSfdOKCXlsarwBLEOZ6HSByQIFZo5Sn4=; b=Bz+Q8Wdif90oVm6wCofNWsvzKqPytHIH7O7fij6LknfwV+XPrLCc6RImiqorCUal+bD2w2ySRwRJ5msUz2AlE/GLU50NY6OtsvRKrZvdVMGh7n9fAPIm2P2lD2mf+xGjf1zIB5CCaCnVERkiAMzW/Klx9msoRl225jqmPkEK4+lYIoFpPV2R5fvy4nNgYqRpz+ce1J+coam/cw6+zzQW/jmQKlZjjdKfSoNlfYMk62B9hg6WsKueoHnFu+gdpE3g8QjhvCh6e2JLXuW9xyBR93+BGaMM6Xa7Kxp46rxiypsWPBKpSYxCyu9XaziK1TRVix6Jv7xGC9jHYwcOQ5yzyQ== 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 PA1PR04MB11081.eurprd04.prod.outlook.com (2603:10a6:102:485::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 31 Oct 2024 16:27:17 +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.8093.027; Thu, 31 Oct 2024 16:27:16 +0000 From: Frank Li Date: Thu, 31 Oct 2024 12:27:00 -0400 Subject: [PATCH v4 1/5] PCI: endpoint: Add pci_epc_get_fn() API for customizable filtering Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241031-ep-msi-v4-1-717da2d99b28@nxp.com> References: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> In-Reply-To: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_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=1730392028; l=3101; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=WztdJXCK+bOn8jeGvfQAh0AF4COBEh+c0a1xNE6MdUc=; b=5R7ouNHd90vplufWGmVJaXnpYoRGO/hg16Xps5b38myeJ5Rvm7rUk9iQDjrnayCIReb1GHWsh I7Qu7uZx4FfBE8DwSjryyLQy5AqsqdkTvNlxPbHByxwA2nccdUyPCrd X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0056.namprd08.prod.outlook.com (2603:10b6:a03:117::33) 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_|PA1PR04MB11081:EE_ X-MS-Office365-Filtering-Correlation-Id: 1af4b9e5-ba50-4a91-2294-08dcf9c8e20f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?czV4QVZMM0N2QkgwMFYvVWVVSk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8?Q?Zh5c+5rBeI+vVK6vsn262O7PWhYMVb7ECZVMc=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?B?cnBnVXRTSE9DVENBYTFxREF1a0JFdERKUWhESnhXMFJuZGd4Z2dpMkxtMDNN?= =?utf-8?B?djFQbmI2Q3VQK3E5elZrWG8wcUdTdUVHeUNBN3VOUFBZYUNPYXQvOXJiQnR0?= =?utf-8?B?REhKbmJQS2UzNnVjTU5Wd0M0YldmN09HYm5zdG9vazROMUE5MytWcFhmS25x?= =?utf-8?B?Rzl3R3B0bjMyZk1idGo5ZDRGUm8raDF6cTNUaGNhY3Zjb2ZTdGJKYmlxc3Rm?= =?utf-8?B?L1EzcEo4a3o3UzZ1UmZUZkdDSlBIblZMeEV4RjRJYVRPdmhsQVpIWmM0clZo?= =?utf-8?B?aHBrVEFuU0RsZkhsSW02TkZSRnhKYmVQRHRpNU83dWZiZVVVWWljNG5ycnRw?= =?utf-8?B?OXdQRkRUQnM2cjdEa0JIdE1ZNkFESVAzcGRZdkN2UFgwdDF6K29jU0FzbG5P?= =?utf-8?B?a2puaDNPZEVYMnd2Q0haMVBBN1RNM3ZGQkVGVC9mTVhvT0dYY24yaCtHMW5Z?= =?utf-8?B?UVdDdTB5bWN3SDFZRnp4ZXJUQlNGeCs0a1p3U0FqMDVNR0o2aGFmYXdhUFhJ?= =?utf-8?B?SktIcXFqWXNtRzhZekhaU0RXL2RNWUxMMWloWUw5UXBPRlNsNzR3bk9uS2pR?= =?utf-8?B?Q3ViNDBuUGhBa3haL0xaWm02Vld5U2FEYjBnby85MVZGOFFLVWhadmVpS1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TEtIVEtoMEI0WlhuSGV3?= =?utf-8?B?aXFPditGcU91RjA0Nmk4c3cveHU2KzRjOUgwTkIrT1hMNi9HdHZKZDZPMVdx?= =?utf-8?B?VVFnUGYwMXNpbE1OcWUxcmtYVVQrQS9kN2pMUUlHVGY4ZFRsejlWTzBPRVpv?= =?utf-8?B?QmNURzZKMzdmWEw3OEw1RUhLVWNZVUpqTTJYUWlscGhnUU03emZzK0ZXenVO?= =?utf-8?B?ZWdJa3lNYWMvU05xMzlKWm4rOXZHRndINkJNK09jNkR1RFFmYXVOeWdRZEV5?= =?utf-8?B?OWdCeDA4ZHVITUFJSW5uamY3VDhVTys3MDNyTjl0SklCQU1zYWRYLzRZUW8r?= =?utf-8?B?enBsNlJXdkNEV3lGYkxCU0NxUmVjQTdJTXhnQXhCbTdFcHhUOWVvWjdyVi9r?= =?utf-8?B?eVdkUTg1ZVN6QWJabythWkFMRmt0OE5jamxvdXVKK1picEFhUnRmMTFPY1pF?= =?utf-8?B?SGRUOHk4RWNtb3NuUWVvcjJ3aEVHN1RYbG9zK29kSjVFZUZXTWR2OFNmYmha?= =?utf-8?B?UlVxbURrTHBoTmlQSWF3bnhjbjRock56amF6czNDcHNrbjlpODQyczl0MHBz?= =?utf-8?Q?Pbn8=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1af4b9e5-ba50-4a91-2294-08dcf9c8e20f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 16:27:16.2338 (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: 8gtkQKvmiGvI98OyIatVYcmvRcEYlgXl3v6i6O2ByG0jjg49qgoajaEGNbPFX7JKg5nJvj9/3gAVT1wDlflBzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB11081 Introduce the pci_epc_get_fn() API, allowing a custom filter callback function to be passed. Reimplement pci_epc_get() using pci_epc_get_fn() with a match name callback. Prepare the codebase for adding RC-to-EP doorbell support. Add DEFINE_FREE(pci_epc_put) to implement scope based auto cleanup. Signed-off-by: Frank Li --- change from v3 to v4 - none --- drivers/pci/endpoint/pci-epc-core.c | 23 +++++++++++++++++++++-- include/linux/pci-epc.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci= -epc-core.c index 17f0071092550..14e6011df4b2c 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -48,6 +48,11 @@ void pci_epc_put(struct pci_epc *epc) } EXPORT_SYMBOL_GPL(pci_epc_put); =20 +static bool pci_epc_match_name(struct device *dev, void *name) +{ + return strcmp(dev_name(dev), name) =3D=3D 0; +} + /** * pci_epc_get() - get the PCI endpoint controller * @epc_name: device name of the endpoint controller @@ -56,6 +61,20 @@ EXPORT_SYMBOL_GPL(pci_epc_put); * endpoint controller */ struct pci_epc *pci_epc_get(const char *epc_name) +{ + return pci_epc_get_fn(pci_epc_match_name, (void *)epc_name); +} +EXPORT_SYMBOL_GPL(pci_epc_get); + +/** + * pci_epc_get_fn() - get the PCI endpoint controller + * @fn: callback match filter function, return true when matched + * @param: parameter for callback function fn + * + * Invoke to get struct pci_epc * corresponding to the device name of the + * endpoint controller + */ +struct pci_epc *pci_epc_get_fn(bool (*fn)(struct device *dev, void *param)= , void *param) { int ret =3D -EINVAL; struct pci_epc *epc; @@ -64,7 +83,7 @@ struct pci_epc *pci_epc_get(const char *epc_name) =20 class_dev_iter_init(&iter, &pci_epc_class, NULL, NULL); while ((dev =3D class_dev_iter_next(&iter))) { - if (strcmp(epc_name, dev_name(dev))) + if (!fn(dev, param)) continue; =20 epc =3D to_pci_epc(dev); @@ -82,7 +101,7 @@ struct pci_epc *pci_epc_get(const char *epc_name) class_dev_iter_exit(&iter); return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(pci_epc_get); +EXPORT_SYMBOL_GPL(pci_epc_get_fn); =20 /** * pci_epc_get_first_free_bar() - helper to get first unreserved BAR diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 42ef06136bd1a..682808f4510be 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -266,7 +266,9 @@ pci_epc_get_first_free_bar(const struct pci_epc_feature= s *epc_features); enum pci_barno pci_epc_get_next_free_bar(const struct pci_epc_features *epc_features, enum pci_barno bar); struct pci_epc *pci_epc_get(const char *epc_name); +struct pci_epc *pci_epc_get_fn(bool (*fn)(struct device *dev, void *param)= , void *param); void pci_epc_put(struct pci_epc *epc); +DEFINE_FREE(pci_epc_put, void *, if (!(_T)) pci_epc_put(_T)) =20 int pci_epc_mem_init(struct pci_epc *epc, phys_addr_t base, size_t size, size_t page_size); --=20 2.34.1 From nobody Mon Nov 25 00:32:38 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2045.outbound.protection.outlook.com [40.107.21.45]) (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 D9D061C57A0; Thu, 31 Oct 2024 16:27:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392051; cv=fail; b=PJcXyIXLSeuPahNQrAKRtJpIi0oMCyRCgreYwfFwEwwjumpVrFAjx1RqdlgpEikKL8VnV3/um67X9UZLmHTRjD1nI0oFtEqjRBTrTbvrGhzdo6+AUJV5gpobIs2kH2FZwzFbW2YUs+7D5johtoSLIZ+xWoqGoGRvA1iR98iM9rI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392051; c=relaxed/simple; bh=86w1a1XMlWfuSdwPQdmN0jUXDLe71oOcpkgioiRNwn8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=iIR4jlVTToQtbJBpYe2iDu9vBj2eE7HrpvdxwqO4vetddsYMBf54otP/7g9Mub+7ilqIhDJf+5u4FjyBQ8goDftSftk5qKfJUB8IJ6Nw6hMuu4k/dZlVeoh9hTdD0XyeWakNVsLetWeHfeFpzy3WweHXU8XDBtFZd/RdAYQCONQ= 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=ht7dQOvC; arc=fail smtp.client-ip=40.107.21.45 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="ht7dQOvC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cF6HEfjo4H0D9XuIfEDOesG5ZjDKkkxwUZflaUYzT5CzFxd9yrL2KPCQX/6CkDliwXMfkakOI9qN+70bkHRa05A8T+9C/oVRabJbn8xoYTJeevvROSqWS/dljvjFXk75D54gQxdIcstE8BSeTBdX699GKdsoQkVWfOoqVaAVTLeDaIX1D/G9i4k36xI5LQXSAt7GteQIO/EKihl15pkI/wWbHxKmFGtIgy+OFfRcEWfJOn+HOrCOwbIGbQoMKAdKZ3dKj+bQznvxCS0BsGGB+Os0s0l1NWk8L0icWvSWxgIdS02ldkpBEZOZCVmtTkZ2eeqpdhPpRHL5+uHUfnMuog== 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=3cvWynPFHPf07oWxi8rpPdNTX2d96vmSUu2BSeQ+qNo=; b=cpmAF6tv3VRU2PWPl0zcZ3tqp49idxdiV7zlmXUQ92td/4Tn0lvkgg1MO3Js+7UbmrXX5bS8JNBR6AerF1nPpq90hXg/k4McNY0sfNqdNMCHQf16RYuatNzmSHegl+lOKT8vjpeAjQCnQMLElbjLdlE39gtMvpfhqSMIBRFjlYk/t+slS+LOUfQBlpz68y4nIRMZWdll7q2pEhEDRgvGA6Cvu4gtSQFC5ms+P9uan/cF8B0TiLGjI0TJzmG4dmSSn1yffUQL1FzbHHjBz94gCTFZPCDzZdxtlahH2mu5HN0k+WB3QBQQ3QCKMNfJN39EsQmIOHmI6DVI62dF3zFRgQ== 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=3cvWynPFHPf07oWxi8rpPdNTX2d96vmSUu2BSeQ+qNo=; b=ht7dQOvCWErj22QXpnKF2/zKboJSQnuGF+KSrAZqRIdPqlMTYSEwztgy69Jax/xFe7TNkDy39VBZ79i7Y60nUL763I08Fsn6x9WoToNL+DNSMg4Oz1xmBHEsT0Bkr+b4egnJBG96a9z6dxwd0N+zav9K39BRrJCXGgvxAn9IggfuNUAHq6Bf8RWx/n39jHQXF3Jln9u35GRaaTHwRxinoQKcfoAViqeIRzivJzus7h+tvYJhb8nboZI3c5Qfa5Ecksd5tQwtFL+5kZwy4Ymv3yjneI4VfJZTTQSWVStguQkq9eMevcZz06t99MKLzjrSeiNX/a93AtEbqV6U4zuh4A== 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 PA1PR04MB11081.eurprd04.prod.outlook.com (2603:10a6:102:485::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 31 Oct 2024 16:27:20 +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.8093.027; Thu, 31 Oct 2024 16:27:20 +0000 From: Frank Li Date: Thu, 31 Oct 2024 12:27:01 -0400 Subject: [PATCH v4 2/5] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241031-ep-msi-v4-2-717da2d99b28@nxp.com> References: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> In-Reply-To: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_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=1730392028; l=7322; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=86w1a1XMlWfuSdwPQdmN0jUXDLe71oOcpkgioiRNwn8=; b=Erbraa3lsZzknZGivE+84oK60M+flb/gF0e77hX/NWhTBmb/4Fv2V9SDcue/dnaM6Yr3otQWY Nj8ux8LJNtUCL+TTzRHEDBJSc/BTiSKVg3NyDMucbA62MPprlfnikLM X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0056.namprd08.prod.outlook.com (2603:10b6:a03:117::33) 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_|PA1PR04MB11081:EE_ X-MS-Office365-Filtering-Correlation-Id: fd943788-ace9-494a-cc8a-08dcf9c8e44c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?UERmMTJES0ZYcjU0RzVQdno5cTIrZWJhTnlDQktyalhqUXp0bHhJNDJrUUhl?= =?utf-8?B?WXZ2RkRwbG5UQkRhQVRWdkk2VEt5RTM1blBza280WVAwN2sxRjJCbzlJcmhR?= =?utf-8?B?MG1IYWwwTXM2S1YyU2owOTUzZ09HK09nK2s1N1MwR3pBYlhHK0lTbWpTWjFN?= =?utf-8?B?Q0Y5eG0zL2p0R1VLZi9nSnNzWXNFWHpYZWs1Wkx3N2N6VlhyNnl5QXJZNHRC?= =?utf-8?B?NTVSaWg3MGpKSGFydm5wYmZEaGRUbDFHWTI1VE02UEJuVmliTm1TWTQ4a2g1?= =?utf-8?B?eUNSMnRtKzVFSndLUDFUa1RBcEpOSVFRQWhqeG9yQmdhUFN4WHRjdHdvYXU5?= =?utf-8?B?VnpZSTdBVWpZWDU1VzZDaG02UjVmaUFGbndQVU53aTFKcFRzaEJIOHB4TlFj?= =?utf-8?B?dH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mhFaGpBc3VUSTZCZkZXTVkybXpuL0ZIdUdBWFJTdUtCQjEzbmZZaGcv?= =?utf-8?B?U1hrZEZLaGNGT09aMDV2WitGODI2akJyZHhoYlgzRGltM1Y4S1hERHpjZTc4?= =?utf-8?B?U0lIN1JJWk9vYllFemYzUFpRbDZwdmVDK01pUnZOTGNWSzBRUnh1WUxtcHV1?= =?utf-8?B?a2wwYnVabVR5c24rTGZRQlZYT1hBTW1CT2tRUEg0K2ZsNFBSNWJuaG9PT2to?= =?utf-8?B?YklFK1dvSnhBNHFlUEZ4ckR1R2s4WjcvNjhzUHNMM3FWd2FDdXllVE9xZ0Jj?= =?utf-8?B?TlVQdjAyV2Vram0xeUpRMGx6MkdnYkVqZUpBaStCYmdxNHJxMWFRUWU1d1lO?= =?utf-8?B?WXNVajZqV0RERC9SQ0FHcjFaZXlSbnY2c0xWcmZIRDJmaTZGWXFDWG84Y1d2?= =?utf-8?B?Ni95K0Y1WXF3QmVRcXdyMzIxRVp3NzhjOXl4VWx3ZXNLMjVvdGxxelhwV1A4?= =?utf-8?Q?FOVbjg0Z6cvvafG3NFMdRGhAVUvM5rHe7ClnM=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?B?U1ByTGFKVG44Qnlxc2JBVm9HS1FqamxPdFNhQjdwZnRZa0ozMUtiYTEvVmJV?= =?utf-8?B?Rnp1d1JjM2VsaUpLdUMxMStmSHFOQzdIeU05a0Zqc0FERjJZc3k4MGZxazc4?= =?utf-8?B?MXNYbkRTQkVhYlgvYTliNXRvY2xHY1hLVTd6cEpLNERqcUorbHAvWnplY0Va?= =?utf-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LaTZ4aWx2R0VVNUswb1FHR3VtSks5NjhZRC9O?= =?utf-8?B?d29UcEhIaFpTeGt1K2NCVytpeFlNU25EbDR2WWtiU3Rkdmg3SW80S1RWU2xU?= =?utf-8?B?MldlZG1SaVgyaXdpbVhiVEUyYm9aMkRJUEVyRjVLZDFwRHJKeUptYXZuazJL?= =?utf-8?Q?ALtY=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd943788-ace9-494a-cc8a-08dcf9c8e44c X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 16:27:20.0550 (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: YLxwMhjvEXGTZP4T6hLcaYhnFKI8fZqNPBGpEoMGDbBSZNFaXWNsPyBAm9/1K4eJ5A9IWOwM8mon/Lyi9UMfzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB11081 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 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 | 128 ++++++++++++++++++++++++++++++++++= ++++ include/linux/pci-ep-msi.h | 15 +++++ include/linux/pci-epf.h | 19 ++++++ 4 files changed, 163 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..91207fb66db32 --- /dev/null +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -0,0 +1,128 @@ +// 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 irqreturn_t pci_epf_doorbell_handler(int irq, void *data) +{ + struct pci_epf *epf =3D data; + struct msi_desc *desc =3D irq_get_msi_desc(irq); + + if (desc && epf->event_ops && epf->event_ops->doorbell) + epf->event_ops->doorbell(epf, desc->msi_index); + + return IRQ_HANDLED; +} + +static bool pci_epc_match_parent(struct device *dev, void *param) +{ + return dev->parent =3D=3D param; +} + +static void pci_epc_write_msi_msg(struct msi_desc *desc, struct msi_msg *m= sg) +{ + struct pci_epc *epc __free(pci_epc_put) =3D NULL; + struct pci_epf *epf; + + epc =3D pci_epc_get_fn(pci_epc_match_parent, desc->dev); + if (!epc) + return; + + /* Only support one EPF for doorbell */ + 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)); +} + +static void pci_epc_free_doorbell(struct pci_epc *epc, struct pci_epf *epf) +{ + int i; + + guard(mutex)(&epc->lock); + + for (i =3D 0; i < epf->num_db && epf->db_msg[i].virq; i++) { + free_irq(epf->db_msg[i].virq, epf); + epf->db_msg[i].virq =3D 0; + kfree(epf->db_msg[i].name); + epf->db_msg[i].name =3D NULL; + } + + 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 =3D epc->dev.parent; + u16 num_db =3D epf->num_db; + int i =3D 0; + int ret; + + guard(mutex)(&epc->lock); + + ret =3D platform_device_msi_init_and_alloc_irqs(dev, num_db, pci_epc_writ= e_msi_msg); + if (ret) { + dev_err(dev, "Failed to allocate MSI\n"); + return -ENOMEM; + } + + for (i =3D 0; i < num_db; i++) { + epf->db_msg[i].virq =3D msi_get_virq(dev, i); + epf->db_msg[i].name =3D kasprintf(GFP_KERNEL, "pci-epc-doorbell%d", i); + ret =3D request_irq(epf->db_msg[i].virq, pci_epf_doorbell_handler, 0, + epf->db_msg[i].name, epf); + if (ret) { + dev_err(dev, "Failed to request doorbell\n"); + pci_epc_free_doorbell(epc, epf); + return ret; + } + } + + return 0; +}; + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) +{ + struct pci_epc *epc =3D epf->epc; + void *msg; + int ret; + + 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 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 =3D epf->epc; + + pci_epc_free_doorbell(epc, epf); + + 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 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..50c0f877f2efb 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; @@ -75,6 +76,7 @@ struct pci_epf_ops { * @link_up: Callback for the EPC link up event * @link_down: Callback for the EPC link down event * @bus_master_enable: Callback for the EPC Bus Master Enable event + * @doorbell: Callback for EPC receive MSI from RC side */ struct pci_epc_event_ops { int (*epc_init)(struct pci_epf *epf); @@ -82,6 +84,7 @@ struct pci_epc_event_ops { int (*link_up)(struct pci_epf *epf); int (*link_down)(struct pci_epf *epf); int (*bus_master_enable)(struct pci_epf *epf); + int (*doorbell)(struct pci_epf *epf, int index); }; =20 /** @@ -125,6 +128,18 @@ 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 + * @name: irq name for doorbell interrupt + */ +struct pci_epf_doorbell_msg { + struct msi_msg msg; + int virq; + char *name; +}; + /** * struct pci_epf - represents the PCI EPF device * @dev: the PCI EPF device @@ -152,6 +167,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; @@ -182,6 +199,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 Mon Nov 25 00:32:38 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2045.outbound.protection.outlook.com [40.107.21.45]) (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 08ED91BC9FC; Thu, 31 Oct 2024 16:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392055; cv=fail; b=IDBUdbkPaOOqOyD1jLTfcer5CIWH/GNy5fI172bdohGZwF15xO/QsNzUVckt0l0itOauFBPVI9GIm6JyrU1qFr0NU+nUG9KpYD6mNilQelx93peBpIqoc7gp/YEpujDa6ZCnB3RnPH08yMpE5hmvcW4v4kfMURu0pBjaECd2ZCo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392055; c=relaxed/simple; bh=JYWf7Ivf0hxPXaDhUGKHvnfXMpLlf1E7XiPYVstdBQk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=PMS5uysOhHUHj4YTv9647sMvwr6hCRYgP5uOD548C4WHzlJlDUE6Nrm33/4e5//q+leYXW2A0/B8v5yigBbR0pTdpdkhIhCHoUxw8blJroVYF42EiZJ7hURFH5w1EGzv9ygAGnNL5U6gnX4pLKuw2+K/f3J/2Zk5mJ8GpaB096w= 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=eMGmy3BH; arc=fail smtp.client-ip=40.107.21.45 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="eMGmy3BH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rst8UucvP2zB3S+01x9o/LesiTsMhT6gOiA75G/kBIkDqidqFKJfm0Ru8ZlxXsApWADvE5KugjJnswC8z7TCdSqqkBvm9MoHHx5Q16UIPNhcyPmrOlclr/YpMmheolXlKAF7HmJA/0ahIjUUKJ5BTcClckabo8n+9MJDH46wpNBRRiofI8N3zuKKPoAxQb6fQVn3aRdppymKGup6Sy4jqOned7G8MFeO9oEmKDHB+ZaeW0lLb4SAB9YB8fbfMSnMJ8yaQJdAAGfEBAanWzPTuN5C+7khKoLKjCjHj1Qfe/iDGn+W/hfGUwsdVVZba/Wu26Qgn/SZaKEihiMbl6C/wg== 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=rSHhGQNj+pSFlSAACu8GErRxT1442ZWIsPF1u4YQz+A=; b=aao/Y9NalEB2TlHKMUhd0FFrSJEX2QDAEZT80PSXQfcWXJ9ZyBdEkNsAHLj9rNrU7g+Sd1HEy7lLg50PUv6C/ahtuwxVL+ZsjjwnJTus0tR93QdJ5rfrcOcUfsp7PULdMdM3AkIz5yMQgaAzqHHXt6Ifvp4CBOuUS/NFvZvqDYGG8NEjRuYRH6o0OlrYkcfiiTGKXE9AOJicB77l8DCxtdvSxCLeXCxR9bAXXdBxNyJUmc2uSEtpOE1Vt6MPZNnpylgWs73G5roYNSZ3xgGcq/WAMLLe8sDnUHNzmleScviYbHv/J86KQpDH/AhpvgFTk4o35GJtpnXsBZV0yWw2Jw== 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=rSHhGQNj+pSFlSAACu8GErRxT1442ZWIsPF1u4YQz+A=; b=eMGmy3BH8LF/YEXD0foZZGCT62ZoKBwX/2KGTdEqilBl30s1qQvmjLxSo+nnHmNg0lakVtMRUmVzXrrr0P4jynRmBpnLPdjZ7snNOZEuazj2gRmNlLH080zLz4Z5PARN/mk3XNHitifschAApwN5X4QBRae8EVCI9yAgiMDTuLS7SpVbVxuaad/3tZXge+wbteoyLnAfmo7FYubu2zGDYMFVewFkICdtqmayANGt3QETQJoASR41ZCSHn+C24mioZcIiVgTNTRkp/yISdLu93vMybafORoxlYm+fcUjIZnRt/2p5mK7xRIJNoconspObjWuWvlsEmT7xsAqy9gu/Ug== 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 PA1PR04MB11081.eurprd04.prod.outlook.com (2603:10a6:102:485::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 31 Oct 2024 16:27:23 +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.8093.027; Thu, 31 Oct 2024 16:27:23 +0000 From: Frank Li Date: Thu, 31 Oct 2024 12:27:02 -0400 Subject: [PATCH v4 3/5] PCI: endpoint: pci-epf-test: Add doorbell test support Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241031-ep-msi-v4-3-717da2d99b28@nxp.com> References: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> In-Reply-To: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_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=1730392028; l=6630; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=JYWf7Ivf0hxPXaDhUGKHvnfXMpLlf1E7XiPYVstdBQk=; b=OeCLCcpHihO4JQsIb48Ao7gjrAZLLw/jpot03X9xaFEBbgSjRF6gQfbIE8OMXTIo99EeQR2S3 m548nd/NW42AxAH2xW8nHiU1wImcEA8E+jKaxz8S+4gLd4d+xxwf2it X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0056.namprd08.prod.outlook.com (2603:10b6:a03:117::33) 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_|PA1PR04MB11081:EE_ X-MS-Office365-Filtering-Correlation-Id: 519c698d-5aa3-4e35-579c-08dcf9c8e695 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8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Gw1eVkyc09YRW05RkpRdmI1bTB5?= =?utf-8?Q?lGHCHcqgeC0hWC03VeudusS00qkJGNEQ4btNA=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?B?ODFZZjdUcHFkUFFVSG14Z3V4RlAvUW1lb2hmQ25qa081Vk1Ea21sNEladGxK?= =?utf-8?B?WmFCTUdrTE8zaStOSmF3Rm5na2F0cmhGZWxCTXcxcjBmbmovaHdrUGVkZ2dv?= =?utf-8?B?ZHdrWXpTa2w5ZHhKeHc2TFJIazhmdlFaaU9RbzFaVVo4eFU2U21PNmV3VXRo?= =?utf-8?B?Ty9RWFl3dVZUU0dUY1ErUExNcWRZa1pPVmdYUDF3YWZlMEpVTHRoOWNwSGdS?= =?utf-8?B?RG91MEl5SU95ZGkxQkExQVJKYytpdXo2OXNMS093MnV4U0Y4WWFWeWJIc3pR?= =?utf-8?B?ekR0NCtsZWNtMnFNV00zcFQ4cUtkSHdtaU9pSjl5b1RFb1hhRGVNUUZVbnFB?= =?utf-8?B?cXhDR1B0MkhXaWVNTkdpMjRZQ0cyVUhuZzhCRFUrVE0vSjZKdDJNMU1STk1O?= =?utf-8?B?R2tQeUM5WXhzZWZXcytNNFFaekZGRkNQMU5sQUN4L2V2OUJoVFVoYWZ0ZHd1?= =?utf-8?B?U2ozdnJRdFJVdnlLSFlxYm5WamR0ZWhUMFlrNlMydXYvb1c4Y3RyUEs1Rlp3?= =?utf-8?B?OW5sdlNhejlSQ1RJTFhGcEVXNWk1WTM1YVZvcVpsZHMwMFMvTUpaTk5Tck5l?= =?utf-8?B?N1JGZ0dYUEtITXBLUmV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B?QnRxMzFlTHJ5eHFPakRxTyt2RHh6b0M0SDJObCtkVEQ5TktxLy9tcVdiakNm?= =?utf-8?B?ZzM5QitJS1Jvc0p4UTVJR3lEWlVoTU43bkY1UVRvZ3U1anhFTk93VEJjMWN3?= =?utf-8?B?N01tcCs0R1pUUVRLWnJRM0VrV0pGYno3T1VKSnZhWC9qby9BTHJUMVMxWWFY?= =?utf-8?B?ZmwzbHcwQUNPTVZiWmp3VmtQd3NGZlExKy9wTVUrS2FRS3RxMk1OZTVadzlC?= =?utf-8?B?TUdrZzdybFhqbThqbWZ4c2dTU09Ga2VmUGgxYSt6WVdXajRPdm9lUnBaYXps?= =?utf-8?B?SURvRkJ3L3J5UXhnWDFHdnh1bjZKdC9zZnBrU3lFanFyYWZVdEZJbDNFUStr?= =?utf-8?B?MFFyVnRpeEFzU0RxcWlTenpibVpVQmsyNlJGSy8zWlRreEplWHgwSUtIRFdS?= =?utf-8?B?TDlKKzRocVJOODZaWUFCUVlqWnVQUWNRYXY0VVV5SUdMOG5ycWhJb2kvZzcw?= =?utf-8?B?VVU1Ylo1dDk3V25hNTg2OGpWZVNlNW0zTmJiZUd1OW1oeVI5WjEyc0h6blFz?= =?utf-8?B?cjhONzFLcitueGxXRWpvUHB2MlZVVGVuS0NQMVV0MUdKM0dnMGIwQVdhZDBX?= =?utf-8?Q?ji0k=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 519c698d-5aa3-4e35-579c-08dcf9c8e695 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 16:27:23.7961 (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: pT1r3NF/laGZcn/LH6azim2vKAanO8vDhBu6aua1+1Y2g4JRsHNhc015jqKjJU5yjFuAELzRDKKERlnVcRJMwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB11081 Add three registers: doorbell_bar, doorbell_addr, and doorbell_data, along with doorbell_done. 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 doorbell_done in the doorbell callback to indicate completion. To avoid broken compatibility, 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, 'pcitest -B' return success. If EP side doesn't support MSI, the same to 'F'. F: 'pcitest -B' return failure, other case as usual. Signed-off-by: Frank Li --- 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 | 104 ++++++++++++++++++++++= ++++ 1 file changed, 104 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/en= dpoint/functions/pci-epf-test.c index 7c2ed6eae53ad..dcb69921497fd 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 @@ -74,6 +83,9 @@ struct pci_epf_test_reg { u32 irq_type; u32 irq_number; u32 flags; + u32 doorbell_bar; + u32 doorbell_addr; + u32 doorbell_data; } __packed; =20 static struct pci_epf_header test_header =3D { @@ -630,6 +642,60 @@ static void pci_epf_test_raise_irq(struct pci_epf_test= *epf_test, } } =20 +static void pci_epf_enable_doorbell(struct pci_epf_test *epf_test, struct = pci_epf_test_reg *reg) +{ + enum pci_barno bar =3D reg->doorbell_bar; + struct pci_epf *epf =3D epf_test->epf; + struct pci_epc *epc =3D epf->epc; + struct pci_epf_bar db_bar; + struct msi_msg *msg; + u64 doorbell_addr; + u32 align; + int ret; + + align =3D epf_test->epc_features->align; + align =3D align ? align : 128; + + if (bar < BAR_0 || bar =3D=3D epf_test->test_reg_bar || !epf->db_msg) { + reg->status |=3D STATUS_DOORBELL_ENABLE_FAIL; + return; + } + + msg =3D &epf->db_msg[0].msg; + doorbell_addr =3D msg->address_hi; + doorbell_addr <<=3D 32; + doorbell_addr |=3D msg->address_lo; + + db_bar.phys_addr =3D round_down(doorbell_addr, align); + db_bar.barno =3D bar; + db_bar.size =3D epf->bar[bar].size; + db_bar.flags =3D epf->bar[bar].flags; + db_bar.addr =3D NULL; + + ret =3D pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &db_bar); + if (!ret) + reg->status |=3D STATUS_DOORBELL_ENABLE_SUCCESS; +} + +static void pci_epf_disable_doorbell(struct pci_epf_test *epf_test, struct= pci_epf_test_reg *reg) +{ + enum pci_barno bar =3D reg->doorbell_bar; + struct pci_epf *epf =3D epf_test->epf; + struct pci_epc *epc =3D epf->epc; + int ret; + + if (bar < BAR_0 || bar =3D=3D epf_test->test_reg_bar || !epf->db_msg) { + reg->status |=3D STATUS_DOORBELL_DISABLE_FAIL; + return; + } + + ret =3D pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, &epf->bar[bar]); + if (ret) + reg->status |=3D STATUS_DOORBELL_DISABLE_FAIL; + else + reg->status |=3D STATUS_DOORBELL_DISABLE_SUCCESS; +} + static void pci_epf_test_cmd_handler(struct work_struct *work) { u32 command; @@ -676,6 +742,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_enable_doorbell(epf_test, reg); + pci_epf_test_raise_irq(epf_test, reg); + break; + case COMMAND_DISABLE_DOORBELL: + pci_epf_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; @@ -810,11 +884,24 @@ static int pci_epf_test_link_down(struct pci_epf *epf) return 0; } =20 +static int pci_epf_test_doorbell(struct pci_epf *epf, int index) +{ + struct pci_epf_test *epf_test =3D epf_get_drvdata(epf); + 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]; + + reg->status |=3D STATUS_DOORBELL_SUCCESS; + pci_epf_test_raise_irq(epf_test, reg); + + return 0; +} + static const struct pci_epc_event_ops pci_epf_test_event_ops =3D { .epc_init =3D pci_epf_test_epc_init, .epc_deinit =3D pci_epf_test_epc_deinit, .link_up =3D pci_epf_test_link_up, .link_down =3D pci_epf_test_link_down, + .doorbell =3D pci_epf_test_doorbell, }; =20 static int pci_epf_test_alloc_space(struct pci_epf *epf) @@ -909,6 +996,23 @@ static int pci_epf_test_bind(struct pci_epf *epf) if (ret) return ret; =20 + ret =3D pci_epf_alloc_doorbell(epf, 1); + if (!ret) { + struct pci_epf_test_reg *reg =3D epf_test->reg[test_reg_bar]; + struct msi_msg *msg =3D &epf->db_msg[0].msg; + u32 align =3D epc_features->align; + u64 doorbell_addr; + + align =3D align ? align : 128; + doorbell_addr =3D msg->address_hi; + doorbell_addr <<=3D 32; + doorbell_addr |=3D msg->address_lo; + + reg->doorbell_addr =3D doorbell_addr & (align - 1); + reg->doorbell_data =3D msg->data; + reg->doorbell_bar =3D pci_epc_get_next_free_bar(epc_features, test_reg_b= ar + 1); + } + return 0; } =20 --=20 2.34.1 From nobody Mon Nov 25 00:32:38 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2045.outbound.protection.outlook.com [40.107.21.45]) (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 EBA4E1C9DCD; Thu, 31 Oct 2024 16:27:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392059; cv=fail; b=td+nhlcu7XeYul0WdqgwjmnrJGRCbIFzcZ/lMTYu4MwY4UhGcN49MCqDumMPEdTJgPAKX72ziPdl8IBgFUIeehelMWGPwZypt+8I7ZiFrufSihd8037fiPC2kxtZMh+rTAWYbf74lKGDuWc2a3FgmjQFOj6NPya79GE3jEx2gCI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392059; c=relaxed/simple; bh=i6aZ3BpLlZvTDNHNcifM1VjlyX/rs1wNUbpxzMJy3Ik=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=bqt6cyqC3XvGHLn98DRchu8zE1tmHKvkDZH0dd78GTfNNJulW5Tgsl/LJUbf9NbP2w/Mc0TXUHHHk8ZBHqMdt7omK3fP2agkD2wa7xAWLug6U9b8GjCl7tle2xJgAiRyf+V3YU2IpPOtayKOyOaEUmrnSO6EzA1OPL28IoleaMc= 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=UJAm8Gea; arc=fail smtp.client-ip=40.107.21.45 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="UJAm8Gea" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o98czCV4LFC+SDKgiCWv4HrYfo2UZU6FVqX+IO+cofqvXjJJJzLKdaJLwukDkxlwi/ehKv47MQEhvqHUwIK0pwUqKtskbY6UlGM+kQNttUltyKb/xPVRu64JCM+Y0/1drWq+zfXhjbDJtC+3wAt3DNxX5xWgZXBYAUHXFNwIEDzSRbepiViccBNxr07Y0SCYnlb1jQWKABmDT6R7gZK6ZAohDwvG72wHq3YPyJOjXTnnZwq4FUtCm4D6PvnMt3J/O5bnF5zapObjp+41pnLLuWDNQpEXR8fPiZLXNVcUAUheX9kfziKchXvko2M8PcHX10p/woW2NOhgLJyO4o7iOg== 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=bdsDZcZopyzwIsuh8/N0Z3TaMLcl/E/eqRHf10fBk4A=; b=aRARyyujoXSSoHwTQch8M1SKXZrLQzi4+JoT7gXHFJqM8HlTLt9BKeDCH5NeBOy71NgUnIknzIdwUo0kpGdnC0H79IJXgD0eFnTFNSOb3IVQUI1FJl5bvPxcyFdjonF1whBgPCCr80+K28Hh57g6bUP40WTAs+q5WBS9ikWmuNF0tS5vexe9CFFlGfV7KmNKDqzHjAxStTyD20WgmTvq/pr+QAWqzcWPpjBvgd0fnkx0hqVmODCUyyeQBdFyCbYKLGX8OmRZs2aiPqqEhTH/1WG13NxhBzxVJBYWrelrdIato2TLVKZuxSZnqSirPLUWVNERnM+Mn9szJNTDPUXGlg== 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=bdsDZcZopyzwIsuh8/N0Z3TaMLcl/E/eqRHf10fBk4A=; b=UJAm8GeaNVNtWEwcQZ+4XyKzNdNTW5sGzo+54SPaYYPyIM6eCnySMeWsWyJz7KaQ+ONg2OTwRAERUv1pyWlyxoK5bhZi/nb5Hn4T5+Hn45cVCU5ek22lBZ4Wpjj28Mzk0aJ+HgWX8tUgfAqgsHaQHNSghqsrP4F9QmG3ViIikOQA7NeDGmCzwO3Bo9IfdnmQOjXESrRhAtWbRdtth3pp/4fIoZz0kD+qIadcDwRrzcRU8hSBSYXM4S1VWSWzufBS6Hp+WuBL9+2N2t3nw4D/OYY18YDYUa0RKj1Zn4Au/2sBVwK9QcOXiUqePg83mLHPTVhIPy62en9DMDuKC2Af0Q== 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 PA1PR04MB11081.eurprd04.prod.outlook.com (2603:10a6:102:485::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 31 Oct 2024 16:27:28 +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.8093.027; Thu, 31 Oct 2024 16:27:27 +0000 From: Frank Li Date: Thu, 31 Oct 2024 12:27:03 -0400 Subject: [PATCH v4 4/5] misc: pci_endpoint_test: Add doorbell test case Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241031-ep-msi-v4-4-717da2d99b28@nxp.com> References: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> In-Reply-To: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_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=1730392028; l=5224; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=i6aZ3BpLlZvTDNHNcifM1VjlyX/rs1wNUbpxzMJy3Ik=; b=5jELuiH5oQz+YJD33m0qwKHJuSgQnlfEdt3F7+EOGKN3nfGuwoR0EzfLnaC1WJnhQTaKPi9Af HMOguLXZSh9BlWtf4mkSpwoi1/n+vsifws3EQ8W+bi5VDMNZbNbowDC X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0056.namprd08.prod.outlook.com (2603:10b6:a03:117::33) 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_|PA1PR04MB11081:EE_ X-MS-Office365-Filtering-Correlation-Id: ec108188-9697-44fe-ac73-08dcf9c8e8c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?T2xoUFVTaWJBVmJJVk1ha0RxZDJ0cHdqOWhOZWljWi9JM0llbDNqeGdsZXov?= =?utf-8?B?MzlhSmJ6a015RFIwNzBtM0dWbUhXSnp6MHJjWUVVSjBXcW80VFU3eThROG5D?= =?utf-8?B?NERXbnhzTEdsOFEzcFhGanh0WEpCWWdRTjRTVGRIVjRxNldYR0JKZDM5MTJw?= =?utf-8?B?YnhhN1d2U2xVSTNCWERhQk90U1dQbGtidjZXMlVjSk5HV2xDZXZzTXZidWhN?= =?utf-8?B?R2tPUDU1ZEhOaE5qWm1PNk1ETTZNZlJZK1VJam91aE13RDB5aCs2dFozTmR4?= =?utf-8?B?dzJHa1BwSFNTd3AyOHhUeVNLSm5aZFRvOFUwai9VVnZ5N1hRK0l4UmpHQmdy?= =?utf-8?B?c3RZazFtWGhaRjZMczVBMGVwNVVDYVV1VFNjYjcva0lKay9KLzI3WWpwVzRu?= =?utf-8?B?MDV3NEZIY0tnUnVMejR6QzVPMnlCT1dGRVJOZ1RZc0hKZjR5d1lNdFF3SzZH?= =?utf-8?B?elh6TEZxMTFnemFDU3VEd0V4WkxEQ2xHN1pRaXdaS3ZsYlZZNlgvTnhOWDNT?= =?utf-8?B?Ull5WnBNdStFYjJscmZFbnpNc0tXOER6Q1FZQzVHZWdIS0Z4QUJ2bzZFc2t3?= =?utf-8?B?d3lSS3Br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k2?= =?utf-8?B?Lys4NjkvU0NweUdEWFFPbzdBYTFTaE5LZ0prT0t2Z00zUUl5R0NiT0xqMW02?= =?utf-8?B?MGhodE9GVUIvTUgyRCt4SHIyODdFeDV1c3Q1c214OVAweDk2SXJTTmxqQ1Mr?= =?utf-8?B?aHRla2VaaUp5Z1BqVUNiUUxkSE1vb1hFV09HczFHWk0zaTN5eVdGbGdDc2Q3?= =?utf-8?B?d3BteW5hV0RwdDNjQ2w5UzBaN1lnelVicEl2ZmNYM1l1NmJEM0hWV2VwVVlx?= =?utf-8?B?bUh2LzZyRFREaGpxYlN1ZkJFUW9mOVg2dmVkMmFjUThnMzNwSFdlYUlDdjgy?= =?utf-8?Q?cg/jFuGGfckF2OUkzg97wyqq+VdaKD0gHbUso=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?B?UU9wWTQxK20zdHA1YjUreFlraDUwV25xNTZzckNyTzU2U0ZBSHVIM2M3OWdX?= =?utf-8?B?aUptbzlIaUV6ZEV0c242SXlPc3pScEcwOElFbjBNNndYWk94L1d2UG9pTnJX?= =?utf-8?B?V0duOCtITEM3WWxhUUJaRmprUHZWK1hFNHRNZFNOTjYxWXhOenA3bVhJVWYx?= =?utf-8?B?N1Q4KzR1RHVhaEZ1SzJjVCtvWnhReitEa1J5cjBxbnlTbUdXeVdtV2xRRWFl?= =?utf-8?B?NkZReVh3a05XWGh3VXhRaXkwcWI1ektuR0hwWURzc3VwT2lSenloclVMTmQ2?= =?utf-8?B?SjV5V3RydG1NZEt4QmRFVXJpdWNOTDRURHZic1BsdE9oMVVmRlBMNFpSdG1v?= =?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-Exchange-CrossTenant-Network-Message-Id: ec108188-9697-44fe-ac73-08dcf9c8e8c6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 16:27:27.5115 (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: wEpcAi2OqKo1sim7hcv0WG/wURBMySfU4Fi+D+XPC2NRotx5hJeYfctbLmjmyjnepiJlnvVuhYXvBR5m2LuXAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB11081 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_ADDR 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. Host side new driver Host side old driver EP: new driver S F EP: old driver F F S: If EP side support MSI, 'pcitest -B' return success. If EP side doesn't support MSI, the same to 'F'. F: 'pcitest -B' return failure, other case as usual. Signed-off-by: Frank Li --- change from v3 to v4 - Add COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. - Remove new DID requirement. --- drivers/misc/pci_endpoint_test.c | 63 ++++++++++++++++++++++++++++++++++++= ++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 64 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index 3aaaf47fa4ee2..d8193626c8965 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -42,6 +42,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) @@ -53,6 +55,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 @@ -67,7 +74,12 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 =20 #define PCI_ENDPOINT_TEST_FLAGS 0x2c +#define PCI_ENDPOINT_TEST_DB_BAR 0x30 +#define PCI_ENDPOINT_TEST_DB_ADDR 0x34 +#define PCI_ENDPOINT_TEST_DB_DATA 0x38 + #define FLAG_USE_DMA BIT(0) +#define FLAG_SUPPORT_DOORBELL BIT(1) =20 #define PCI_DEVICE_ID_TI_AM654 0xb00c #define PCI_DEVICE_ID_TI_J7200 0xb00f @@ -75,6 +87,7 @@ #define PCI_DEVICE_ID_TI_J721S2 0xb013 #define PCI_DEVICE_ID_LS1088A 0x80c0 #define PCI_DEVICE_ID_IMX8 0x0808 +#define PCI_DEVICE_ID_IMX8_DB 0x080c =20 #define is_am654_pci_dev(pdev) \ ((pdev)->device =3D=3D PCI_DEVICE_ID_TI_AM654) @@ -108,6 +121,7 @@ enum pci_barno { BAR_3, BAR_4, BAR_5, + NO_BAR =3D -1, }; =20 struct pci_endpoint_test { @@ -746,6 +760,52 @@ static bool pci_endpoint_test_set_irq(struct pci_endpo= int_test *test, return false; } =20 +static bool pci_endpoint_test_doorbell(struct pci_endpoint_test *test) +{ + enum pci_barno bar; + u32 data, status; + u32 addr; + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND, + COMMAND_ENABLE_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_ENABLE_FAIL) + return false; + + data =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_DATA); + addr =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_ADDR); + 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); + + wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); + + status =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + + 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_SUCCESS) && + (status & STATUS_DOORBELL_DISABLE_SUCCESS)) + return true; + + return false; +} + static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -793,6 +853,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 94b46b043b536..06d9f548b510e 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_CLEAR_IRQ _IO('P', 0x10) +#define PCITEST_DOORBELL _IO('P', 0x11) =20 #define PCITEST_FLAGS_USE_DMA 0x00000001 =20 --=20 2.34.1 From nobody Mon Nov 25 00:32:38 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2045.outbound.protection.outlook.com [40.107.21.45]) (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 C92671C9EC6; Thu, 31 Oct 2024 16:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392063; cv=fail; b=AIxQ6xcI3JlYLQJ8IxFwh88U0AAqf+/0OISBBfbfrbTLJG+CWZ4y7QBYJVNWRE314LpqFZNkZxAkbL5DL4UrvOQTYGzyOPoe44iJSj9GsjQHst30PtthvuS9iXU6PuPN0CUHBVQauVQQd5FPIlCn3PE3ICnnMNsP6mC1jXVG0E0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392063; c=relaxed/simple; bh=QXAZUTo25wHxfm2hPmZ2UTgDrVKcvTZyNirR6BThLKo=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=K8w40xb2v3Yn96LLK/w44L5Cvl1WaGneav04vHlQJch+SCcjrqXSVyKsR0LqX6JpPnjIfbF97qoEpR4uvue8Gv6wYEkK1KFSZRj+xk07qWGJ19qEtn7N+bu09znMeBgYAUzBaU6T8InQLzAUdHjxK0CKAJkqNEBfwL6GoDhIrDs= 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=MPVfBtPv; arc=fail smtp.client-ip=40.107.21.45 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="MPVfBtPv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PUxCIuKqdmCDTModtyCkmeEz2bnXhTbBBsIcfio1iyA8hTZS7PPGJuXe7WMJiff6Fas17ecGSpOgypYlTHG3Srp2txVyV8MBwVI2iP47262I/ztsB3mQlzA7m8J3J6/oLmqDo/1t3K4eKtghwBK2RtMS3v0jMG44I1jof6YiTWzE6LvBwLt7VJZ+mViMilpsvrUsraDKTsVbtMakKVykFRHgFUvxQm6PvVU4xnQBRx65KQutqEV4ohQbMtRejof/37mF4tbqOWMTJpUkVm7gnDThI58VT4MtBUCcFSoSmGbapTAjW07fNLvjPBVZXCRsbcKE0xHg9XcT6FwL0J0v+g== 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=3XsfDMu3OuLSSl5vBa2X1Qbhd1a7N+LYSe23dI9037Y=; b=PI1CHFsL3qF4WTopF3MlBfYI0/Fuz93szg/Ura9QW4JzcENEqyrjHrkbkj4XTK6Dj7JVMMqljvAmt1PzqHj9EPysH4Lkym2fPKO3BlN7FoxL7JGo6zuRzgvMD31rN1BpfUVHI7j8Iglzon4KY12CxGgW5A8V9c60WY0ZFupZ+5gdvashc+FahN3FASGAaI78dAhL6vWSKGYDR6CROOahyqyKpsfsTf6Vrw3ANdASXKXS0iwIRXV9ck4dqyvOMoOXnpstwLvWNacRMqRAmriJ/B8UfDaEflhY3VZCO7zhlgu5JD9f9Tk44480HiGqABs/oZuSh/rJ7ib6ARwr/4fFiw== 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=3XsfDMu3OuLSSl5vBa2X1Qbhd1a7N+LYSe23dI9037Y=; b=MPVfBtPvQyXmC1OCKcgIjhxQ+3e3lZMkNCXPjTEF2gxDH1zOD/xRr7be/u0ZJAWo+GkD0ZmHJDLwrElXIsGafqYi0V+1nyWep0O8UIBPwZKW5+VKC4cEq/66S++8Qot62ivihejNAmCuUENHeZeYFU3PYvO/xh3szpkncqx4PksbdgpES4h8yiOg2YRx25YmW38GmlIoBNLALk/hn1veIULG2gMqpbJgCJn02j+Vca4mocBlyaNn9SZPJjT1NKWGgo1M9ZBPzbWtMUrxneeSaESP6edH00TN75eWW5p0UG7+JezSfeb9Wq486AxAgxuc8Pbe7ycOWESYyhHh3O5KGA== 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 PA1PR04MB11081.eurprd04.prod.outlook.com (2603:10a6:102:485::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 31 Oct 2024 16:27:31 +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.8093.027; Thu, 31 Oct 2024 16:27:31 +0000 From: Frank Li Date: Thu, 31 Oct 2024 12:27:04 -0400 Subject: [PATCH v4 5/5] tools: PCI: Add 'B' option for test doorbell Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241031-ep-msi-v4-5-717da2d99b28@nxp.com> References: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> In-Reply-To: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_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=1730392028; l=1804; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=QXAZUTo25wHxfm2hPmZ2UTgDrVKcvTZyNirR6BThLKo=; b=BQijpRRjBWhkiRVjXCG9igHmC6uR8sz0/GFvhgRsJ8HN54IWhy9aDPakxpCM3SJFG892FIb6I iQgBv1l3WBqBuS4OdfyuX4I+xZ2jOX9dUmetDCRJ3QQKjqqe4LkrSfi X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0056.namprd08.prod.outlook.com (2603:10b6:a03:117::33) 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_|PA1PR04MB11081:EE_ X-MS-Office365-Filtering-Correlation-Id: 345de0ef-540f-42a2-754f-08dcf9c8eafb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dVJyUW5IYmZja2E3THZ2ci9nSmxleFBMdEpyeFM5cGdQOXQrUk8raHJqZUdJ?= =?utf-8?B?djc5VDl4QWJRODdqTS9wRXpOcHlKRllieEdXbzdQNnV1MEtWa3EzMUp3aFhk?= =?utf-8?B?V1ZrRjU4U1BSNVl4ZzBEbkF3Q0lwcmNxc3puNzZsUWlYOW9sdGZEZGlxWDBn?= =?utf-8?B?NzErS1F0RjJnbWN3TGdLNWVmQTh5U2djT2J6U3AxamV5QnpTb2RQOS9NZEJD?= =?utf-8?B?Q0hFWUl5Yy9oa2dmdmNYdFVON2FyeE5zWVhGMmtMVUlMZ09zbVNFcGo2VzdY?= =?utf-8?B?cnFOWFVTMDVQRmpPYlpSWHhyMlBwVGJvTldpdFh3Z0hDb0xNVFl5dEtvTFB0?= =?utf-8?B?dDNVMUdJa082TWcyMC84aEVnemcvcVp1Mmp6cVBtdy8vcUFXbDM0Si92V0Vw?= =?utf-8?B?ZTlRK01PUTI5RmQzOGQyOTJ6dWNXcFF5OGtzUFZ1L2NPTDFtQ0RRWVV4NXRN?= =?utf-8?B?NjNEUGpDTGxrclpvZ2VOWE00ZzNIMVVBUXpNU0RLK3ZLbXdPUG9DUlZpa3E0?= =?utf-8?B?MlFiT0VrelpXZThWTTNiY2xCVGdCdFBTNXgzRi9EejFRQlV1WFFsRnhVaXo0?= =?utf-8?B?bjBIazZoNkNQVFRaWU1pUmtxV2EvUzRqV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lFFYTZiL1hZcFBtNmJhWGVPTFN4L2JnWE10S1hlTWE5K1FtOG5w?= =?utf-8?B?aVJKNWQvMnVFV01aN0czMDNJZWZlcGczc2x6U0VLRTRKVDJjMFhlWXhaVHlk?= =?utf-8?B?M21WTzIwUlQ2c1FrZVhjbW1IejNQVFRCUlJQT3hEZmpnNzNIeklqM1VxMlVE?= =?utf-8?B?cGl3c3RmS0tNclVXNHBRcnNVSEpUK0VwZXFUMjVRSmRBeFhNV1VKQ1VTV3Bz?= =?utf-8?B?Q0RXeTQzb29YNVZmcVphUnNGdlAvUFh3YzdlaUhIUmxZRk84bm9vU0E3RWxk?= =?utf-8?Q?9N25jCC4rfen0jOa0lFzBZsCp+vfqJUsM1EBA=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?B?bkwralhHSUt0RlAvNXhieXV4TXkxYk1xZWlVdVlmTi9udkNMRjlFTEdGTnhC?= =?utf-8?B?di9ET2g2cDNGbkFkNVJBS0p3U3dzbjVlMENkd2RhUUF5a1ZxNlJxMFpmWDFQ?= =?utf-8?B?YUdjQWxKT1ZRczhHd25mcmVxa0MwQkYyemtDL2Q5MHA2eitkcHk0NndCcnZi?= =?utf-8?B?NE1LcGhhakh4dmgxZmNYTWhhSWJiN1ltdi9BdmhJVG1EL2FnVFJ5TGRRby81?= =?utf-8?B?alJzWXhnUVp0MlBURE9jNXRJNkhhZGtVb3o1Nk1CUUVIU3o3S2Q5ZUR2Yk4r?= =?utf-8?B?RVZmVFlJOTVsQ2VCcXE0UnI5NzM5UHRESlRvU2tmdnRPQmlQbFQwaFpRSS9P?= =?utf-8?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MS-Exchange-CrossTenant-Network-Message-Id: 345de0ef-540f-42a2-754f-08dcf9c8eafb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 16:27:31.1832 (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: oFGAb8Ivl5lUQGVialAs8G0BY+IwyQ2FWqlS3p48nGxmhyL/aYCtND+8lBvErXyt4LxDzWS0+zOdfUs2KMwlkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB11081 Add doorbell test support. Signed-off-by: Frank Li --- Change from v3 to v4 - none --- tools/pci/pcitest.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index 470258009ddc2..bbe26ebbfd945 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -34,6 +34,7 @@ struct pci_test { bool copy; unsigned long size; bool use_dma; + bool doorbell; }; =20 static int run_test(struct pci_test *test) @@ -147,6 +148,15 @@ static int run_test(struct pci_test *test) fprintf(stdout, "%s\n", result[ret]); } =20 + if (test->doorbell) { + ret =3D ioctl(fd, PCITEST_DOORBELL, 0); + fprintf(stdout, "Ringing doorbell on the EP\t\t"); + if (ret < 0) + fprintf(stdout, "TEST FAILED\n"); + else + fprintf(stdout, "%s\n", result[ret]); + } + fflush(stdout); close(fd); return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */ @@ -172,7 +182,7 @@ int main(int argc, char **argv) /* set default endpoint device */ test->device =3D "/dev/pci-endpoint-test.0"; =20 - while ((c =3D getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) !=3D EOF) + while ((c =3D getopt(argc, argv, "D:b:m:x:i:BdeIlhrwcs:")) !=3D EOF) switch (c) { case 'D': test->device =3D optarg; @@ -222,6 +232,9 @@ int main(int argc, char **argv) case 'd': test->use_dma =3D true; continue; + case 'B': + test->doorbell =3D true; + continue; case 'h': default: usage: @@ -241,6 +254,7 @@ int main(int argc, char **argv) "\t-w Write buffer test\n" "\t-c Copy buffer test\n" "\t-s Size of buffer {default: 100KB}\n" + "\t-B Doorbell test\n" "\t-h Print this help message\n", argv[0]); return -EINVAL; --=20 2.34.1