From patchwork Fri Apr 4 19:01:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 14038798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20687C3601E for ; Fri, 4 Apr 2025 19:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F8Qp5FfqRuQHFYCFtVEMJWoCYl4K1g4dfDwvdzdP/uM=; b=TDtRgM60LefAoimVvcqhL+Z74b 0uWydDXjNUCQKY5WxgAZpU4zVAZSRvz9kvZpVoiWEEKYYae2aOxSLURgQqzvM4yymhww1P8emcfut 0XOxPpq6DUQJEH/Id4sCpvoy5AIex+IEWN7kTpZvy1WfISXnq0+WP2zlFNAXUsHwZmxlfPJHefgTD vI/5Jv5bBjxuv+fgmUnG10yMQyYtBfPOndg97A9YwQUl80yQG47BCwxFT+YuuTHZSIToB/xNGErR5 3zscRkT8OAy2/1EQleztHL4qJbSa21MtRus4JemeeOAWE9sNv/oEMyJyzI54TbJ4l3NkrRks+hKpN 63DvgqwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u0mdy-0000000CcfB-2jUN; Fri, 04 Apr 2025 19:23:58 +0000 Received: from mail-vi1eur05on20610.outbound.protection.outlook.com ([2a01:111:f403:2613::610] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.1 #2 (Red Hat Linux)) id 1u0mJT-0000000CaBA-17Be for linux-arm-kernel@lists.infradead.org; Fri, 04 Apr 2025 19:02:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XXGSHWr9dap1Blbb13VIoKe+qj6nTiNKx4jReMPFedfukZSM0gIsp3g76RxkxnCQdhBWwckFkTqR4Odpoth2LcXVszHgsAns40tnKWSWxel/pH1ptZHdcsjb9XSLwWTc65f4pn1Mw5LVFQylXHwBOxejxwjf3bfAELToT9xoJUrGO5eRDXz6NnCWJDBVEMnqxCtxFGPyys3KhAY5eirdK6nWxsomxnGHXO/yVtba4A45a4Ilx0N3+IQe99XY3rGVmBlyvsEFbhpuY/NBUeyUpMfD/WV4Abuoy4gINtybdyeorVZpl1g5+qLIs3DP5lCLwbYn+/DTNQ/ZhqD/gxeMUA== 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=F8Qp5FfqRuQHFYCFtVEMJWoCYl4K1g4dfDwvdzdP/uM=; b=VxEHIuqDi8VVQxh0fy/qifMmDfn8vpSczgCu9Ivzs2GQhE8ihVCRqwPZ/P2/QfPiEtbzYuGut2h5PdebUxP3/nhZ+OsLnliyjoniVbLvkOCA+zjWCnINk9p7DGDCF8PdQ9sgmGjRmTd4gu694GTMdv5VLlcjza9Z1+XMOJ2DTEEFns6XxAgqWoh9Tv2V3fJ9U51crp+UReEPGFndMCpo8vmgF2+HX02nX5zUjb+LbJeCviaKfAjUQQUtvHEEhcGrudCfupt8F1IXYw+lsbD4VtnbJw4PXZKIYeLySbkh/EMoLpkgBOwPcLspw6sa/81XhT3t7P/tMGpxOXg+F0n6sQ== 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=F8Qp5FfqRuQHFYCFtVEMJWoCYl4K1g4dfDwvdzdP/uM=; b=dh5KooKHMLZVXBloBmvHAEcaHLNZLMFg+8wSVX+40YSsK1xkJUgNgNy/Dl1fGJe7sYbN8+SZf74BFWtPTPc4SGwCv+7MJts0KvEmZ/Wb+UOSpEn+pOe+7VH8+Or/TY2Envk9+2QYqupuRCodGpMCQepQxl3CrlDUA5Tbb9J1IdJqV2FEcVeCv8PVK8I5oLN31Fggu0QJK7D5+ZThJ4v36MHomHZNjvO/4d8GBd0l9n/p6PmzHu1qJxl6JrlvR2ZvZGFFp4LJ/c3VfCyYYEEfWJDlrL73RnBUa+RwG2XD0oVb8FaqLtA5v18MvBNdxSQTWWXqtPwJdDRovQGhjh69dA== 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 VI1PR04MB6957.eurprd04.prod.outlook.com (2603:10a6:803:135::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.49; Fri, 4 Apr 2025 19:02:43 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%2]) with mapi id 15.20.8534.048; Fri, 4 Apr 2025 19:02:42 +0000 From: Frank Li Date: Fri, 04 Apr 2025 15:01:12 -0400 Subject: [PATCH v16 11/15] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20250404-ep-msi-v16-11-d4919d68c0d0@nxp.com> References: <20250404-ep-msi-v16-0-d4919d68c0d0@nxp.com> In-Reply-To: <20250404-ep-msi-v16-0-d4919d68c0d0@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 , Manivannan Sadhasivam , =?utf-8?q?Krzysz?= =?utf-8?q?tof_Wilczy=C5=84ski?= , 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 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, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1743793288; l=6407; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Q75HpsG7AQZeyq/78WIzVSdGpQ6JBJuHxf6b6uNsmfE=; b=WRu+IoMWoqtu3189fKogov2fWi5tGK4z5IYCSWXQ5FJbDPnf7uMmz1cXChrqGnA76x3T9eQN8 uT275y8hRePAeA/BQbFSbTOOJWqHGwnkVoKBDHtSBpY2c4/7S+xykZ+ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: PH8P222CA0011.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:2d7::35) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|VI1PR04MB6957:EE_ X-MS-Office365-Filtering-Correlation-Id: 59b3342b-4f2e-41d3-69ba-08dd73ab4731 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|1800799024|366016|7416014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?odQ0H+C8qrZkjB6i/E7V24F8d358ch9?= =?utf-8?q?a8nGIx4rDKowW5iF8QkU2Qxz/rPBMxVXZHow78cX2TZFeyAnskFrauV6Qky6cpNVq?= =?utf-8?q?CPW01d2gluoiyYI/35Tzwq66CwdAdFb2YJpCrid/suvtedBEzd3F4WgpH/Aw3gFr4?= =?utf-8?q?V6i7GYTaGARulmgKbxOx/0AfzsU7Iis9MzRcR3LJvPoiNI1Dk1qFcRVD0vNRF+ba3?= =?utf-8?q?77HnfNVckUDLctRd+yn7kq47P9UF+/DI2xmIFLvf5X4P5l0P9yWp8KT0A9x1R7A4e?= =?utf-8?q?QjVPROFR1yJvfQcqU5HrJqswQ5a5M4G0Vu5Cw/j7PlX6IYnEl1L4DK4rxaiWUzUb4?= =?utf-8?q?L+fTKdSqoErKUdo4hgVfUnNF8byj8wm/1O3DQ+FimgNKxxo60DlvJQ3CbP8Wu2CNB?= =?utf-8?q?hnDbATQI9fEI1OWcixU9wcfvJcnVnaynbeTuFt8reW5b+2XJJyyS7rpzAqEp7zyiM?= =?utf-8?q?jz6ehspEeqTXUc0XsHbAudC1jOIOt7mb7uJEVOYYLkaH0m81dgE/fUrQ4Hx4AUUQ/?= =?utf-8?q?kFrHtOuMuO1rSYpyr+jRFqmGpeMWLTGRTM1CG5/JHbrQY0xmq54U6aVLBXckMG7PV?= =?utf-8?q?QkIRgsorUffQNLMF6lVUhCqfyQXDW1Ehh5mDCShgnXzKilGzPsXjzpC2Uj7M5ISee?= =?utf-8?q?i0D0g37Xp8Ot4FI8VwQQJ8aI+bsJXCzRmkoWs5ncuZfzNxyfGw4sfv02VWJRxGjGY?= =?utf-8?q?jkk2lmAusscFfoEHFMsnVKz93QPwvwMuXZoLi/z3Rj5O8O4DAe42OUq8O2r/0npMs?= =?utf-8?q?2QcDTKd8SyIEEZ3CAdnDVY9FpVhvNCEstcaz3FH960ZR3gGXCEslmOuWjAKj0lFsy?= =?utf-8?q?7ctGxTXUUWOjnq/C95vqNjGiXFyYzWuzjdTkVAX6XfErZmjgXTMn628HoWQUb47o2?= =?utf-8?q?AESy5aMAkFTsdzpIzZlTWOh5hylLPlYkpEUCzaLeyKfjMgAUX0wf31IeAyu61Kp2h?= =?utf-8?q?KixhmT5Q3L2FGaqKHpjwXPbrBTij6aryxVZ9LIWTHYox7bwLmv4LhLtnCpP1Jwl0B?= =?utf-8?q?wnQOKsbd5VZ6jaWEOfp7bebq41E9cA5t7JWwzoNt8LFX9p8yR42X+XHAeyo49J1xL?= =?utf-8?q?0qgYc0ZOOjheLDJckBeOEH7kFgLQX/QwddRCgVpWHwN3knHYC/5u5wyHoAbDbu/lq?= =?utf-8?q?hR9sMnra4bN0SxzqRbcPG2D8M1aRoz1T2mB5bUpj+mBG+X4Gu1yQRfq56asvZfvoW?= =?utf-8?q?MECS4lu04hYDf8+1swC78duz2UF4UMdnpcFSF/iThpmrKA8Rc1Ag9b31mNIOwgUpq?= =?utf-8?q?RcxI08cSZqyBR1oaSqIDJgj9OcoQZyNZ4FTAJKnArqsVPGQ4TGY7S9amfotFcJnsI?= =?utf-8?q?DQ7nnFr4Jl2Y0GxouDLuFBa8scOJNUFUSRWuF1K/bnd8otNTMicDok4tDPmlgoMLI?= =?utf-8?q?rxctJWeOQaOp7pnAkcE5ckgaUPFvqOpFA=3D=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)(52116014)(1800799024)(366016)(7416014)(376014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?UmFrYaQmiQkU61dqmDRN7W8EL/yO?= =?utf-8?q?+TsQ5uo2NxrSoEnS00B0pKPqY3CGsPxLZkhx6zgvpOkzlOitt1uDIrIogEtwJwhTL?= =?utf-8?q?TU8hPIpdlXYfLnkW4hz7t0XK70Fmf8ApXDD8hQsjOwGEpfrIt3TQhn8Py+ugmZuoz?= =?utf-8?q?fG6Vxr90UBuGQUoMxig7jGP7eAjeWAVCHTdIgdUygXwaiHoYCrRKTJuiRgw8JP2hP?= =?utf-8?q?VmV8brpsPxrsAVOSvuIZAPB2FCQjWLpYa36jrIxzcbJdKsPJ0wjx8556DnHdV6ki4?= =?utf-8?q?bC78RP1+x/bPKibmYdBjY32AR7WKivS3pncO4HC4i5qamdcsTM5jAlposxmSwDqEp?= =?utf-8?q?6cVgf/Br0kQhi9iqJX6bnmW+yI4Vm5FMO3CBfj9JlJBmEnJK9AsZEJgeyB5nVk6hm?= =?utf-8?q?iLiTMUIN/tYPzFLb6ULbEOjN4a6usD5vLRkNqbHp1jtW4Z0m7PkvVy0xXiueXpb/9?= =?utf-8?q?uQ/dyADlyYPZfG3nqtNaS47m+JoN9kRrzB+8S1zRdIEKdJ+55cJj2WDdoxX5gFYMC?= =?utf-8?q?Xyx4hPh0Vg6Zt1LEklm5Wjh2Zoq1LJU3aKgPwFMlA8NWG7uzFoc0YXuecS0kUS89M?= =?utf-8?q?ech74FeuGvkPmfwB3xLTqDuEA2m2/WAJAC8z0rW0+EmcwlpHTr7CkdSfEABIxY1Vj?= =?utf-8?q?Q6Xy2KNzq+sFh0n4rSuXZ/WF63jeYq4lI5JNFQfRAxT/+ZucaSAmXsml37dzAD+h5?= =?utf-8?q?i3cMNbGhWhK1kwrjH4NrqNFupDpEHPVezlMsRmpArJDLem5oIqze/FpQInVC4VGEY?= =?utf-8?q?PK6gaeW7iN9dXT4L/X6bzdbk+2/ZpjkXfAYcdJQ68rW5vfOcScvb9+r7bmaY71/vT?= =?utf-8?q?ZSefSzcJA+e7UKhR+3MOQ6psLEf1GErfOpEauE8RnV2+i2BRepYoRxRd4C7DD3lun?= =?utf-8?q?964Q3qMjKb8NfihOcuGF98WoL5oCIwrz6J0Hic043xsILCUfJ65sukbPXh88/vtvw?= =?utf-8?q?H6NZEsfSsKsHEh9PEr5rpTLEIgZqZKZIeB1IIECfnWxn8tvdf4HZIjgwmIiDdPZ66?= =?utf-8?q?8a68P1+LFFmjj56rxOKn16M2hL6yJ/Cb9K2Kx851vjKiosmHc+nReWdgPQvfhWZFf?= =?utf-8?q?sI8tSFXCHPK6fg1dWsdk5b6Ow86KVT5PoqJUup75kJjgJ6HmFUomz5ZF0u5xl3/Fx?= =?utf-8?q?kOcgYXRas0gtKdFBIX4STwSGh3Rm5kEGb28xjJZz00RH/OA4BMFxFTPi3Zh9vbYDT?= =?utf-8?q?TrAJoAqwkpcrt6B3eIz3M/NSpSX30ZOQA/LWP6zrmroufdDyR6Lk4eZJZD2uRhMuw?= =?utf-8?q?kXMMrXP7g3bsNLb/ZTTqwpiivh2wXMGoCr72vUNHRc4XgkWNxIusShrJ4/gd0nBke?= =?utf-8?q?mefxUzyUY7jN2TQFwo4djRpnshUc4QnyfGCcN0NsPLcyS4/N/dGfvnt2QeQ6YVa8p?= =?utf-8?q?58n5aaWm5ly9ZZe9P+4ptrB9Zt5d7ts2TLE1beyDfhBo4m9hwt7HKgSugffUjMDhy?= =?utf-8?q?jtXq/z9JVF+ULLSg9Ia5SkBRSNuT9IFEY/rlZxkjejhAxMPFv57EJuNY=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59b3342b-4f2e-41d3-69ba-08dd73ab4731 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2025 19:02:42.8824 (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: 5mcV7vY9bP5MX1PD1CCnSmdfY2uJ6y7GpZ3EjqTVvjgqPjEQSx/i4GmAfA06GeXOsKXFbcnG60PW/yiNrw6Ojw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6957 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250404_120247_482798_1C663C2C X-CRM114-Status: GOOD ( 16.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Tested-by: Niklas Cassel Signed-off-by: Frank Li --- 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 | 82 ++++++++++++++++++++++++++++++++++++++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 83 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index c4e5e2c977be2..0f3af7adea107 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) #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) #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 #define PCI_ENDPOINT_TEST_FLAGS 0x2c + #define FLAG_USE_DMA BIT(0) #define PCI_ENDPOINT_TEST_CAPS 0x30 @@ -70,6 +78,10 @@ #define CAP_MSIX BIT(2) #define CAP_INTX BIT(3) +#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 = -1, }; struct pci_endpoint_test { @@ -841,6 +854,72 @@ static int pci_endpoint_test_set_irq(struct pci_endpoint_test *test, return 0; } +static int pci_endpoint_test_doorbell(struct pci_endpoint_test *test) +{ + struct pci_dev *pdev = test->pdev; + struct device *dev = &pdev->dev; + int irq_type = test->irq_type; + enum pci_barno bar; + u32 data, status; + u32 addr; + + 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); + + wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); + + status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + if (status & STATUS_DOORBELL_ENABLE_FAIL) { + dev_err(dev, "Failed to enable doorbell\n"); + return -EINVAL; + } + + data = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_DATA); + addr = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_OFFSET); + bar = 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 = 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 = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + + if (!(status & STATUS_DOORBELL_SUCCESS)) + dev_err(dev, "Endpoint have not received Doorbell\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 |= 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 +970,9 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, case PCITEST_CLEAR_IRQ: ret = pci_endpoint_test_clear_irq(test); break; + case PCITEST_DOORBELL: + ret = pci_endpoint_test_doorbell(test); + break; } ret: diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h index d3aa8715a525e..d6023a45a9d03 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) #define PCITEST_IRQ_TYPE_UNDEFINED -1