From patchwork Tue Dec 3 20:36:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13892941 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2079.outbound.protection.outlook.com [40.107.20.79]) (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 3F68F20A5F3 for ; Tue, 3 Dec 2024 20:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733258255; cv=fail; b=SpbZRXZVlfEGSBbonvOQCrUq0+dQLbUqQaubb1qUkHIBBu2bo7fqcinEDdFSN0JcMEQqj4YtFpTeGXTWTnLRavelNHk1ZHZ7POXNroMaH+S+Ms/JIARTgWthW4xH9iY8WUSjjpf5k6jNb902dXoy2CaxKMGA7zHupxp3l2mGJY8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733258255; c=relaxed/simple; bh=o5EKIj3vNC7YvPmJEwQfL1pJ0yVh5RKNjyYncOCamTU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Q/+TGzkOt4UGmGNU6iJ2Qj86QVZj+UqbxdTcqebEAVSx08ig3tJ21PgRecUUZ7jpGMldS8tCNa5DopsAs5/NKle8bROtcEqWxgL2PfQhdM/Bcgx7qmCH6q8Uk5+jLRjDBSIWR9QsXu6o7VIFE+P1LzCyOhYWhvS62c5HexJzTjM= 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=mh1EEYqH; arc=fail smtp.client-ip=40.107.20.79 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="mh1EEYqH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rLqgLeAmopfgb7DsouyC/kmPVvHs7DHct6/jogQAjoPkC2D9kqOKEiG8oD5TyYaCpZeFf/uAx1EDiyq81UyFvkqWS8E1Acg1I45WCArC/XLg7xf4xGtA6UbGDXCY/JkumCssA3iBi8/LpBUGgNpHBgrv30R6+rO5W3ASfjn6oqLUDQM/VKzIOL/dsQlROOHmMvmG0X0G8JH/1Hi09K+C3WGMPesMmjNBgVItZu+0Azy6yjWsAEMaGytgic2hT6tqrwYhnTFQRmIS2WHUW9pw9n02Z15VjmXiTAaNXNcIGIUGS9zgiShDdf9UJIiyKqWWBz2s1Vdf+yG3DvdpDWOy0g== 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=CgVPjIxixay55JQCXGUQeF5Pm0xBX2Gb/KuEgDxzx2k=; b=UBiYigYtytls4KD4whu4cXIhoLBGzeFtiDWnfKBV9ncdghF63tOzJ27E+rrsqitbMWMBAB/BMlMM1xvAoJ/WTxyqr4FB+fAUt49VxWhDnK/elo2biOcf7XA1wI++ICxq8wRRscGe34G7dXYuu0txBSU+w16FTYzaacyMjiKQAtAqVZxyzSNW7+MNiqFujGUG1AnB4TJ0H0yQLrSHj2VJStq51JjQv46L9/l+6aQRs6Za0ppxjWp2lq0k4LN/0fCIVMrQqaPacAW585SwgkWBsND2jkz7jIqefZv3+K/t/k2ns9MPsYU1iWFOu8wlYqHumA/hkXpQrd3d/O647xTh4Q== 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=CgVPjIxixay55JQCXGUQeF5Pm0xBX2Gb/KuEgDxzx2k=; b=mh1EEYqHoOwKhYgrjR8aws8noZDHurZHhqW7KAhRvvqYsdrLPl8ebAN8tsLWmNNeDT/j42FCq3zvukn9xDagv5Ub3drRXs9cqqwS8oGcGRcJsCpgMbsOfBxgnd+tE8fL3wW3GJ/ZFzWQOufZf7iTeEntjPe2k3Q19h8OK3yVtjT3Ae6VAapRPbR800jpUjzML2P/FPcMPdvLLxT6idatBVyMr4fsD6uYJ93HLpe3IU2BH7UGpBD/skZiAZYFZ7qM7PiCwHkKUo5WgpPAd5JsEtxNR9TrA1kz7LHRtm11KdIrTVkOxTmctLSlRwLocZR+Up0l7Z7TZlpAn7m66upSyQ== 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 AM9PR04MB8730.eurprd04.prod.outlook.com (2603:10a6:20b:43d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.10; Tue, 3 Dec 2024 20:37:30 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8207.017; Tue, 3 Dec 2024 20:37:30 +0000 From: Frank Li Date: Tue, 03 Dec 2024 15:36:54 -0500 Subject: [PATCH v9 5/6] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241203-ep-msi-v9-5-a60dbc3f15dd@nxp.com> References: <20241203-ep-msi-v9-0-a60dbc3f15dd@nxp.com> In-Reply-To: <20241203-ep-msi-v9-0-a60dbc3f15dd@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 , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733258225; l=5948; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=o5EKIj3vNC7YvPmJEwQfL1pJ0yVh5RKNjyYncOCamTU=; b=1oGpdo808LSKWefQoCYEAZjxj2YrDNBTNO8Z17lkQJYo9T0m3xl48/XXkYKGIYtCv+zxgiwaG /tuFOfBMZWiDzuh797sqg1Pk8N8CuRec3c1gCfVLKh2+bWgI8hFS0J7 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR05CA0013.namprd05.prod.outlook.com (2603:10b6:a03:c0::26) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8730:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b8bc1d2-873e-49eb-30f8-08dd13da4ee7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?cFQyxZ4A0BmS5HqBlijY8OipxO3ozMs?= =?utf-8?q?U9XZ+p/YONVgoVmzvho6km6ixLwGClEcjUuOy96sfu7R0OcOoHlMMqjvIfInM2If4?= =?utf-8?q?TMZ1brKQVsKjAHu/U69VtI29qSW6OGX9XbT35W1j1ZS0UF6AsD4WTeTyvH/5MT1cY?= =?utf-8?q?rn+tEF7g+XfOJxo4yr0o87XmSWJy/PAsnJjCaNmhuN96fbH5q7PPdYtIqipHWFHRp?= =?utf-8?q?noOIKFBTxgjDL6gqkIcxWiDt5e+oZ/UVDVOpASQJzx80Y2Dl4zLw33wS0sx/ToXq7?= =?utf-8?q?9a8wNfe60sn+18nKEIPf1uo8Mg0nZyhYwldzSkcVJE5SgjsKF4yheUJtBZiXsNnNb?= =?utf-8?q?Pos0Elh5C1BMnQFNWKkc2d5hUyTdRCt6Oz/IIwjRQ42z2REPiFKADbhD1dwZzVLLx?= =?utf-8?q?TFshMGV5jGBfDxmsUaD/2snOJSZJ9QXiFTVxoBIIVmkXEaZyVFI+OHQvb2wpL67Wu?= =?utf-8?q?W0361KYoPqQG6zy4Fgf2xJp/B2+SgdXe0DG48hQCBG9tMdARY3paiefKXz9YuD+wq?= =?utf-8?q?+7PTyRXxgV3SHLr5HM4Wyf1x3kfj+dVHdXFJzNkk6dK4FgRl1oqMOD3Lr2OQDolXZ?= =?utf-8?q?bOkpshbc9e8U5o7TPy7r2d7+prgrBwyXIlXVk5r4JUfF4vWnXbztrS4kUJe5t3qcg?= =?utf-8?q?3mwdeKgX46oIYVrhfOKK+ojkgwgVznT3CcjpXufoZ5oye6vILobmzY4trw6ae3EzG?= =?utf-8?q?OGS/7KbYpU6906nsiV5wWK/ZZZe5hlCxFHEyssj36JPaf5NMf17bYyEMoFLGrc/uN?= =?utf-8?q?URZQgKZezo4lpzAPtAeHsG5ydPXbCQRAA+rWs3azQ7AoG3Dd33rTTNtlZBbFI4zW3?= =?utf-8?q?0QbwGB7Fc1zolIquQKLpmQSpRwr6iZcfUvPQ+RrDKzEmnlt5lGtRb24sKGr/URRgM?= =?utf-8?q?nSJmtC9Spa2JPXV2R1IlZT/lkmV/cLWw1KBFhVeE9Q9nMWibrelHblX5eR4PAMH/X?= =?utf-8?q?hxyd9tgObElY6Enha/kJPOn8/kwN6FZTCJy0CeoN+V08CanKJf3Ex5dofLFmOle/a?= =?utf-8?q?os8VrQ4RBO/2JA8qFuZ47Gh9yqU0p5JcSCBNTcE9Azl/zn7l9RVAT4ktnKBfROJ8I?= =?utf-8?q?dYarcnX2o4hpkSClZnscR8GytyvDo7AocDkvSrj6su6uKnPnB4R/UV3qVL5kk3AMH?= =?utf-8?q?D6tx5ulGtFM39sTHtBLSdGilzZvNAuxDHh7KVnZgYtkdEBvBJN8R+zww1HGHq2F0Q?= =?utf-8?q?rbQ13sgaWQ/WN8VR/frNmYJu64syKjLHDUK8c10DAvaGlTN3W/IitFEfGVmINagSM?= =?utf-8?q?UDW5NDbz5FsipzmaQUfw9VxnWPE0RrxMzYBNWi/Hv6uirIHncjPMwGLKuJ4Y0ACSu?= =?utf-8?q?ADhjpcUTFELCyMr3wHQR1MlWIr00Uk4igw=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)(1800799024)(7416014)(376014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?8dkjJKmWA/XiXoBkjSkh21oYpYH+?= =?utf-8?q?a8TxO/T2ud7oNZ84uyWNZmuuZNAu98SRfAWFcXhRYitXn7PP/yIvbvD8B7/njW/6a?= =?utf-8?q?EZXtLarmgcovzi7WLxc2PmdtAGWUwNycy2IFHPgebIRkt2c5hzwkka4jabjwWRAtH?= =?utf-8?q?ZAVQsjhA5REFEOPwtb5zpzyVWg6Ibd6jrwaR6UhitxU60GkFshhpAsMwNAKs8CoDp?= =?utf-8?q?iVNUJZC0n6zNY32UppRT0bA6pafKHszpDEp7xjOwQ//Ah0CIgc7qSjSYMcz5uFwfm?= =?utf-8?q?4YRNLSyeZdeDWFAnQZPdBvc48r0pUPeBQFjsAggEuvU1t9V3xJgS4wFuwRpjAXR2t?= =?utf-8?q?CAA0xQWfOPJwjIf8aPdQout0gagTKMPsyeMjaT1pdcivSQq/JJejNA4mIx86nG4dg?= =?utf-8?q?R7FvOqAru0P6tAX/d8egzZ8Cdw0JXSu3v5NX8w8fyb8D/KZqdStryHZEr8jfVnBfm?= =?utf-8?q?Ntzv3E/ootUfA0Z1CGL0UkCyqkUZJRxTy1Ms9RkBEcH9hCwEs4YbA3sDFwujVIYrA?= =?utf-8?q?6NCGnxB9p1MjIzCl3LdUA3h7ofagt52ikfsMQYJkrS18DakgagSTW5MMpOAZ5J5UD?= =?utf-8?q?IgPLXXsAsDhRx+buIUXIQpsH3loMTujDjIH7TpL9T5JVDfMKMsQoAchw0NJ4j4566?= =?utf-8?q?1Sv3gplj7eCcg3QJDvsrum0LOP/jvGxvFmVIIxYKllHnfWGY8dEnxBk2KyGNieKFY?= =?utf-8?q?5AW49BPrtK+df486Uf8nsRMbz7Xy61jLTwemPVDjQadS5BmgH0E0nfkxPtoHVnjE3?= =?utf-8?q?Vyc5iBrbcWbS8b8p/2/e3UQh5mbBi+lBj8Pd/nN4jpqiiokbAT02ONQTY3CfPbbxd?= =?utf-8?q?8S00vSka0hf/jW8qcgKq85IoSymQghxAoOYdynpj/1+ah+eIZEmnm1DBAx/6sFRlq?= =?utf-8?q?D7MViwFGMFMh1UGJ9Bs1vFlUD6jfrc1kA6I8+8hT+QjICY3Uf8MzVMBxLOWO4fEWw?= =?utf-8?q?j5U4TxamyMLDmYaY1NWFi6jkbOKi2y1Lc0pLnd1Fmq9Kr4XzMcc9W7oIl9d2t5l01?= =?utf-8?q?dKKEsvKaX6+2WO3DW2qMm1aTefzKs/yS25aNEPGR28lTaV0RPkj+/tnLOoIC1xN5D?= =?utf-8?q?d8pJC2yOFiJZuBzwtIsa1szBWlcbbyioP3pQx930ZMq+qt1JJk9e3cqKdXRWDM2ka?= =?utf-8?q?LX3h8FzXLu320jSnuPfKK8B9j5/7DyESH4/AgRaeJnMSekepVvD8+nFn9AOk0/nb2?= =?utf-8?q?KyueIFzzvsG7Ri2PJW1Lkg1gAAHYVWuoz86+hpST804J+mZj8XjNmv640eIjjxdzP?= =?utf-8?q?mzPkAlTi1sPqMLQzUGmM1TMhyvfK6LjhMh2ImhS3WA5O5YCbZIf0mlSO7BRj7Kfim?= =?utf-8?q?XbMH428S+Dz7Bt/wdtj5NyoHctmpGp9gVU1+SZTBFgu9sc4g7H/6i1SmWshew2JmM?= =?utf-8?q?AhWRqEF9XV6ePsonxPAddzoZKZdKTNaawCfSuyd6CBScCNtxB7pZqY9veI09GsLHj?= =?utf-8?q?VUsWYXxFwjMScvV5beA8eTBkEt9GErswERc6nI0/FOK5eGIk7TozZors=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b8bc1d2-873e-49eb-30f8-08dd13da4ee7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2024 20:37:30.5102 (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: 0DKSDeMt08UFTvMbLpMnRiIIUBZo6F8RhPYCs8SKprjSwnYsnKMSCm1ZcBB8M3Six+D90cjC1ZnVn7AYrvjMiw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8730 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, 'pcitest -B' return success. If EP side doesn't support MSI, the same to 'F'. F: 'pcitest -B' return failure, other case as usual. Tested-by: Niklas Cassel Signed-off-by: Frank Li --- 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 | 80 ++++++++++++++++++++++++++++++++++++++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 81 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 3aaaf47fa4ee2..b3f36b6ba8ba2 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) #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) #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 @@ -67,6 +74,10 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 #define PCI_ENDPOINT_TEST_FLAGS 0x2c +#define PCI_ENDPOINT_TEST_DB_BAR 0x30 +#define PCI_ENDPOINT_TEST_DB_OFFSET 0x34 +#define PCI_ENDPOINT_TEST_DB_DATA 0x38 + #define FLAG_USE_DMA BIT(0) #define PCI_DEVICE_ID_TI_AM654 0xb00c @@ -108,6 +119,7 @@ enum pci_barno { BAR_3, BAR_4, BAR_5, + NO_BAR = -1, }; struct pci_endpoint_test { @@ -746,6 +758,71 @@ static bool pci_endpoint_test_set_irq(struct pci_endpoint_test *test, return false; } +static bool 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 < IRQ_TYPE_INTX || irq_type > IRQ_TYPE_MSIX) { + dev_err(dev, "Invalid IRQ type option\n"); + return false; + } + + 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 false; + } + + 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 false; + } + + if (!(status & STATUS_DOORBELL_SUCCESS)) + return false; + + return true; +} + static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -793,6 +870,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 94b46b043b536..b82e7f2ed937d 100644 --- a/include/uapi/linux/pcitest.h +++ b/include/uapi/linux/pcitest.h @@ -20,6 +20,7 @@ #define PCITEST_MSIX _IOW('P', 0x7, int) #define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int) #define PCITEST_GET_IRQTYPE _IO('P', 0x9) +#define PCITEST_DOORBELL _IO('P', 0xa) #define PCITEST_CLEAR_IRQ _IO('P', 0x10) #define PCITEST_FLAGS_USE_DMA 0x00000001