From patchwork Tue Nov 12 17:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13872697 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) (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 BA79D216DFB; Tue, 12 Nov 2024 17:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731433734; cv=fail; b=htZFLWRGfou3e/d6SA68VoTsz2Ny6IMxnRNWDZAyVvhS24/4v2qTVpCiHYI+pMSlxFLnBDwBCLtLslH+OlDRh9gZM5qQQcsKz5vC2md3A/U0ns8Pw+4BmsUP9yIQbT+VvikLr0HZ9xX4skGob0B0p7bKZLs8j7ypmGwSfpd0wMw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731433734; c=relaxed/simple; bh=mRSIYGyE7Zx5MR9tyPF4Gn3e1jwej2qgCm7SNors/a4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=F2pscnVTJXdaluBAyiYCuFSH5EllqepwkPdgS+1WhtxQNxI+rxJPUKddaDbrKdDb23N3oH3l+PVHJ1nraHZ0L3cOFcdW/LNZsFjATl6VHdp1dBJoVPFxiAXMwKcahn8Y2YHhymXlj7DKFzryVffqw8F0vldB35rg/XnH99N+1uQ= 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=C6fwcaBW; arc=fail smtp.client-ip=40.107.20.62 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="C6fwcaBW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=slGLSFIbO3nElqxOyFr0zMQFg4iRlVxXDGq5crgl9rFkjliRbVpGpqyJHg5ZMWSZUTQ0mkI8LYlCStxRmn/x2ZaGq7ENry5Clky05D4a/xYDWJVzYHqnM1FG1mHYUov3c3oJHlChHxINTJDcbz32vt3iobWidL+iZ2FnGpCoeRQppDbvDoGa7krb3g4bknCgbjjeL685p7PMBNOx01cpaYNhHxQGRmUy319/74/G3PfK+w2SASpxriuO9jBeG6sxzWd0i0VI0EiItON4GpQo6jtke2BXzsrCIHUiRFNxiAHSE7xlHVrXvSZ8dCsaU8Aa03Dk3Fmotzrt/wzfO+1wjA== 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=FqrRfjNvc6E0BC0Bxoerwxqq9oC9JL7vqGF8/bfEknY=; b=U3F1jFOOIYhcJ3zIO2p73x3j0uekH8NA9TK6cTGom963YsKFN6fLf2BzXKciOFGFaya6maW6mk7MXuzroQsjHnacKPXTTZt3Q1tVZuMCq/FfrXyiujiV3C4fu6F5JsFEEjPJKF2UHOWDJv+6KtV2jBRwaNgx2q6SBwLbmGmQWzi1JxMJa6iSL+PGB/iMlkQ/kxOlF1mSCkVb/0v5OagH/lf16h7XfjoVuPmgOLmAdjFp8E1Jf7P+cWpgwoNvm1SPaV9O9ma8bwHWeAbDxOtdaQ2UQzSHfMJLNkdn2ZTV5CP3IhZmw1/aesjTHkIF9R5XeXqDoKY5Kfox33+2X6fWEQ== 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=FqrRfjNvc6E0BC0Bxoerwxqq9oC9JL7vqGF8/bfEknY=; b=C6fwcaBW0uMOw+VKuR+/JLOBV0WFVlDiv1es9PMpUFiD+tJxwJ3jtZgCU2t3cyyiX8i/1bbjlPZHqQ3ZsLlycgONAhpVIfjmFMrghnhsjHj8jG/L5lgU1cPfEEd9P7zqm95BgRsCtonRpF5mx0bVjRdoIwP/17XqEz+1OgMC3Go9ompAjcI1xNLfyA/jnZIDuuQNrfG6XjnNcra2EHzq9XyOk2WQu8/pMSW6kTfLFmIkgfpsbcfP4taFBUaE/W9dNvUj/UmBz6cLpm7gsKvQz9hktriPLtx7iJq9pifilH+dNKOOcsCHv+LjOMB8DqeCyA3r1lVdrE3xQYZe3lPmgw== 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 AS8PR04MB9510.eurprd04.prod.outlook.com (2603:10a6:20b:44a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Tue, 12 Nov 2024 17:48:51 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8137.027; Tue, 12 Nov 2024 17:48:51 +0000 From: Frank Li Date: Tue, 12 Nov 2024 12:48:17 -0500 Subject: [PATCH v6 4/5] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241112-ep-msi-v6-4-45f9722e3c2a@nxp.com> References: <20241112-ep-msi-v6-0-45f9722e3c2a@nxp.com> In-Reply-To: <20241112-ep-msi-v6-0-45f9722e3c2a@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1731433711; l=5495; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=mRSIYGyE7Zx5MR9tyPF4Gn3e1jwej2qgCm7SNors/a4=; b=NXmYNgTDzlS+Hq5U4WYuoGLf8occAlD/CCAGqkAlLRZnc4PFuv+F0gpZsIxFueTf0Ine0Borv XHxiZ13h8IbBCLm7Gbh7I4eNcVMNIrnNU1tUOwb50LiMc3YOL787EOY X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR03CA0076.namprd03.prod.outlook.com (2603:10b6:a03:331::21) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB9510:EE_ X-MS-Office365-Filtering-Correlation-Id: 4838bbc9-baf0-4f89-9493-08dd03424481 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?0Wd7eE/xIjFefrvFy6sBwDjWuGC1XLq?= =?utf-8?q?aSCn9H4pLu2d2qVlwHndDj59UOX5RWxm9O94VxJ0zUAMA7hzjWmLK9Py6mvgdo+R/?= =?utf-8?q?rlkKNq5scBSREmc/2KERP1o4frR6CK7pw4QIzbyTpiztLMoF/garmI1sSwNsXO2ZM?= =?utf-8?q?BKsQYCCYW3QoaeIKZhBc6UcaNfWr0tZ90wCFg5CmkuaLaDoIuRJHhTQTRwKzZMyYv?= =?utf-8?q?UPMqjZMTyyCf2XjoDwPDZ4Vdne5N+AI9GlovrrrzVnpbq0ih75zttvPNu2o0VlcB+?= =?utf-8?q?u3JLjueNr+U3UnzMElt27cQu5HYcJSzzM+USlkEgzz6SPsViJSUMU0C6zZnuPyZZ/?= =?utf-8?q?3rtzKl6f8iKdFNFAEzjINOCfAnBFpn3x0aT9TBVqNPyhEoHMHjUipZC+hnhGWod7H?= =?utf-8?q?wsrZ41qbhRQZJcaJszs5EN3RzxrrOJDRGOtqv6wYHlqmuxA3Y1iKGdb3CvwaIl5SO?= =?utf-8?q?DtnMPCli5hGNok1Dcz/cnSfyYft43p9zUOwPMS3OhjMd5PcWa4Xdc+SOzFu0d1k+c?= =?utf-8?q?C6nqzZcyqM+/uR2rwVekgX+1JJDzddjF+v53mrL9TlSk5208bxyp7apq8AD50C8dR?= =?utf-8?q?zjYr3B1y1ELOZmfbN88xUEGD5b15oZOAyPo84Lj2i7XDLJ5e/0aIPSF39//MKhedZ?= =?utf-8?q?xAs3XNXHKdDn/8lhCECqVRdHCHLXOuT33p+DiuXyGoL1HzRKDKXw7GhzuPS0/cUPK?= =?utf-8?q?Uk1pjqGA9agey4mZwWhA0aQdFsqX7F6UjuocpTk/sdVx7dtt9h6T3dXO4XE7y9fdk?= =?utf-8?q?v9+Sr5jalLY4/bRJHpqYHuDD5oH9fuKg0MFHV08/A6yqtQUo68nM0WWS0UfeMUWA0?= =?utf-8?q?ppHW5vwRlPsPBWMr36m5No23T4FUFxapl95+LXBcwGppuG6xlJGmODcQgpEMqvD8T?= =?utf-8?q?9msTlo0FZvxt7DqMimgUe6KW70TLmkbgzdjx/LxJWuJIfodx8VxFcbmH6fsrz3NvI?= =?utf-8?q?ld1lhgrfJgWix4xjBIIgviquXxvuL6SsoxLG4QKdXTFuA6q+hmp7QLPFSBj5w8ewW?= =?utf-8?q?wHobEsA2I6xARNCxv81w8ARs2yR3JXlnUi12HF8eLmSfBb7p406C227OKo9y0VHk1?= =?utf-8?q?smmtpromeN4pmb/QwtZ9SAHKN+uR1RmBu8lwleoL6yPpjcXds7PmCz90Kfsz+7dMG?= =?utf-8?q?2YteSBJYr5C8pX/kkWwNR9ENn+p8UHMGkfbkf4z1xvm5PrN8bLfMRTBzFvYjVoVTG?= =?utf-8?q?CP1oqpudUJfX71BsQyDVM2tzRY0w2Yk/nTW4k3pAuB0NoM+v2FkK5Yzka/DiE89r2?= =?utf-8?q?dAW46x9onNAJN615rNkWGv5CruluDHIUSL+Boygb5L7zq6L/wwgJtcBk=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)(376014)(7416014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?DOz7wVhAXml0EEWZIqEDH0l1n8FK?= =?utf-8?q?sgVcBC+Dxwesm+sW7rdeeJC67OTJYdtFnY3vfwyffCHUU2JC0t/zWfwgSDTL7tk4u?= =?utf-8?q?yE9BR0Ofg1++yc3lZJfFE5g5LClqqo74k/IeilmNQMQb0zhaO1At9x7i1fK88nmGO?= =?utf-8?q?jd8ARh7FroJKhpRbMdaSir5HyFYJPJBs5iw4hTvrWTD9idC2htt8UaVWZKG44xY9t?= =?utf-8?q?GsfrSOOXYjxvfujQ3HwzGnaviYRYaVVjapBMfgkDR83OBePgxqxKb30c8bnLobS2Z?= =?utf-8?q?KX52uYcjnZNKv4Xpl8gKDjYDpoc7hq6StkOu0Uqno8ggTSVl0nE3fdGyWUtcoDVZf?= =?utf-8?q?0/qCc3ToBiMBCrgDp5MSNW13IjVAdh2iuDkvGEXZ9k33UfEZi+LKaEJKIX8l8uMmX?= =?utf-8?q?LqXJlwG14yChtGRS8fxbhD1681l/jKOOxSnoYqov1Io+tjzxsJEq0Gc8uLCcq7zLG?= =?utf-8?q?DZXPen1jCcdMVSZpu0wvk2kS/xQGW9FU2G7CrtqBECma8SuBPg289IZoheFPDwqzO?= =?utf-8?q?XGT+LZcDcQ/ABQEs3hlzMrAEmK8REDPACq3fcymIR8TOuKFHIpUgT3uVrqQCp3in6?= =?utf-8?q?j/hVIgMZ85796ywF6hTEpHb1u2qhQJwUG0h3em3P7U8rEpL+OzFNqcx7CXy54wDfe?= =?utf-8?q?AkSLlRcrtIt7MP1U34n4vffipUrpFLkeA+YZhOeS6GTBDLe7aEpfk8KPxVMeBoFH0?= =?utf-8?q?EgnQAs40f2Z++t1Jab4EOXyi9pvEvuTwr5xSX8VNXE5iP7HqFzCbrVge8OLjFUzQz?= =?utf-8?q?tTnTIcPweS0TCDZAJsAeBEXeHRwQRgoaB+bv8hJ2szO7IuzJFaJ49TE0pat+FFzft?= =?utf-8?q?vBwVcaTCyM7NShXb3CuDPLDXj5vTmzZ/0HCGzqc1KDvLfIl0OCFkyRrLYO8RS4HAD?= =?utf-8?q?i6mOgeSwLLI7JU1H9OnaglOcjFyMcskH+r+pc0rrpLGdgeXiyEAI9+poJXzqr5Xiv?= =?utf-8?q?PQUjPRdifZ+lagdJ4PMFf1tLnjOds0eQ/NTdBnN59vsS6UxvH382IpR3O7lLnU30I?= =?utf-8?q?FqJxPrX1Z1d07KGmOuP9bGKBIxASELoApIvo5zF8LSEIi5kiOFyo9PC4UhLHOJuJw?= =?utf-8?q?IMsJcLCPihn5Yq4GMX83SH+wadRkaYfSh71tftGjny0t4cKQ47dd+3CPdcFmEoGBR?= =?utf-8?q?xagx5t7F2uZLDcWu9qp13XIJtd1lGWZnlIFXR0kmfQ4nUa5kToF9lvCZSAq8QE9iH?= =?utf-8?q?ao3X+4z1WhNBwcXRJWejO+EK/Bo2MKIvxBG7KxHB9kcIsZCWUZA7uZXcQlY+nnBni?= =?utf-8?q?HWok9lEM+rV7fWfgU1qGj3hCUPL7LbaRszlS3FMpFcyJoloMDtiZtqeANCpBAMgml?= =?utf-8?q?FoCNKGSwpKarH32J9QIhGmN7KtkfR/Kgmc/lTaMuQ/pBVMGM5xQgg+S3qFbAbDacu?= =?utf-8?q?/lKzqoxs1hdTteUABMmFI7I424sUcqXWSkvuojGDPIdgPp/owOVMRZ9Za9dUpYl+B?= =?utf-8?q?37QHv4vnUO0hHiruwuzjbGQprcXG4YJ+6kKF/P3RpBjbVu/XrIGHo4t4=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4838bbc9-baf0-4f89-9493-08dd03424481 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 17:48:50.9661 (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: naHTFPrVEySCb0JrFKpRrjcuwUJWUmg8Wsjrpu5dyRgokYdGwXJMQSm2Sm1ELBUWpCzJd8BK9j+hZcbrsv+3BQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9510 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. 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 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 | 71 ++++++++++++++++++++++++++++++++++++++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 72 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 3aaaf47fa4ee2..dc766055aa594 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,62 @@ 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) + 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); + + 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_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 +861,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..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) #define PCITEST_FLAGS_USE_DMA 0x00000001