From patchwork Thu Nov 14 22:52:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13875709 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013034.outbound.protection.outlook.com [52.101.67.34]) (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 55F881B3956; Thu, 14 Nov 2024 22:53:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731624794; cv=fail; b=o8r0SViS3wzswqVbVfbZg/ysOpRQ2yTsG8lZR0azDJAnusZ6oKUScQ+PpTu9JNgt1eSgPkAfdQTH/R/BUEZHUMmi8h5/IiQxoMAbUAiOG/Q6zhs6l6S65BJtxDIyNQpWVNcTTZrNtc7fozZa1caCuO7pPAz5ASkTk6UFmRBQyIo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731624794; c=relaxed/simple; bh=QTWqCilF4zeHBfeRMKTgOmEbv94DuAHrD35HEjvlft8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=MmrFHOMoVPzb+CL8W550xEf+ZDrJghKtBhmCCMlO0znDPK1oWrCXSSGYCP6wK31r8sBgkf4CYl8JYkMIPd1Y0vToEnrleRUW1WjKH5QUKUCnmhCK+1yw2JVcIFDuTkSYOXbjq/YdoRMcSxOEaXInP++RZ/2kz1ikZ6sm9JFDh8Q= 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=mf5hW/Dj; arc=fail smtp.client-ip=52.101.67.34 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="mf5hW/Dj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=X0yHbBgcPQsW7keSYSozGbjb+AMbFgIXm+1k2q4NQiIlrUxQCUsw2n/fiuCeifxIC7YLAbwmzWg5esUexuGBl2M8WBOAS3cLzr3vljeyNaJhwJc79tCG/tNJY8GKf8R0XepQfJ5SmK4sTZLCjjkHGpFThmMCYB1eKW9Bb5annUe8AQh/TVjLi4ClmpNX9azH3LZ6gYbHlz34CPVZp0dcpj8gLk/62xRJNqsvAV+kgv8dqWHV4r3p0IRzbKQomuWpt4wBFYZ5WQ/XppaWunmdr3VgW9XOGuNVgHYUXnrpDSTrSO9D/f8TqQFnR9mJihiuOxKrEn/n+EyJjAQiLyFyEA== 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=95seh1SLCdzbaMMMU9WaEBSdML7dm8hPVr5F6qDIHEo=; b=qmdJVo1AqDAlnUlI6jFTsr3RPFud+rapsDtn2eXL7Mev7om1reFWqqCZZ9r10PFamcLbdL2FW7sJiCem9l62uikpRAaITE9QcK4CfrMl44kA/o31FRHsF72gV12GKVSN3PMg0I7/HTTbiIO+APR1II5EK36PIVCOW0R03y7ZgEuyTdrAw3MrBJMrdFI7mgJUpYdhdwHinzH4hiIntVfTx7oVHx76GK91BSAym7L/jFoFbI31n7NY+Gv++3kYkoz9Z5v6oPjdj9SuDSyxYrInEJ/Kwj0suzt0ljulKcKeVLwlQ86hwcWjMwcBb+mT9h1q+5LtxPurwC8Dn36XhJqlPg== 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=95seh1SLCdzbaMMMU9WaEBSdML7dm8hPVr5F6qDIHEo=; b=mf5hW/DjQ894C1SKRhYNjEtp/zPi6XEEX/KwBfcgMQv3VuQYI4P/LgNc7HuY8CHCzSoZS8lQkSZajjRNkxS99swXZpmsU4IJ0nh/sW/3bNst9Ua58rbyfa7bqPlsNh6tjHiGT1OG5WvrKOzhPBT8DuXgH68+elCYGK8Gh371k97yFZqAnEAkiPvgT6wU3YL5IdoaGmxnA730Ip85hDxkSyhzcAECpX9FLQptA07DjCXACcR3ex5Z533c8EB310GYmzm2wofzwWIuHqtnYIPvinA7nrOJROAbpX1vAz+Iv1IUbdPdKLM6Z3K44BElCwkEVmEBzhlQ7xZS8sVRgn5maQ== 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 DUZPR04MB9967.eurprd04.prod.outlook.com (2603:10a6:10:4dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Thu, 14 Nov 2024 22:53:11 +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; Thu, 14 Nov 2024 22:53:11 +0000 From: Frank Li Date: Thu, 14 Nov 2024 17:52:41 -0500 Subject: [PATCH v7 5/6] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241114-ep-msi-v7-5-d4ac7aafbd2c@nxp.com> References: <20241114-ep-msi-v7-0-d4ac7aafbd2c@nxp.com> In-Reply-To: <20241114-ep-msi-v7-0-d4ac7aafbd2c@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=1731624768; l=5527; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=QTWqCilF4zeHBfeRMKTgOmEbv94DuAHrD35HEjvlft8=; b=A4qJoTr2gXtOiudcsj8dKulpIdx+DfKQ+rWaDyuzLoFSoZaT4JDWva4fMaYuIzJiyyQgXdqzg NOGm9dE9jptCj/oJEEj/RKt/QQoAuKuN86K2ha9rRENdhNfvW4EEarV X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR03CA0166.namprd03.prod.outlook.com (2603:10b6:a03:338::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_|DUZPR04MB9967:EE_ X-MS-Office365-Filtering-Correlation-Id: 05103112-3b53-4e3a-6a9b-08dd04ff1d1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7416014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?zc/pW3VEpALCtm63g2YuGQPxJ3v0hhn?= =?utf-8?q?BrebrEWj0W+akgZJFyPswcIZf0Z0wqzm2z+czbI+r6B4ZG1nFmym+99mKT86P03P9?= =?utf-8?q?kMjBHYfC0UHM5BE1SO7ItuBI/lSMo+0yBf/VelB4rIDS1ryulLThphgRWwPJe6nE+?= =?utf-8?q?GGniYTr+9e5Yy/Z1lzyQsTuvj8cGZ8vQaD6NZnGQfldqo8Co2qvS164mieWn95LnJ?= =?utf-8?q?jN9I1dJsBhtvuU/6B9pAy+7Ugf19eBIfOVkumoN1vUAnNxHWZAS/3LxoOilBnpg4B?= =?utf-8?q?r4AgYE0ptpfHWJaliYS2b2xU/MWeOPP1sHhOmXQgDdH3THeJEaxlXJ00oNgYDJ6bS?= =?utf-8?q?gN6Pc6euScOwtDMCVSnWVDcVblfJmlTn9vHwLS90H4TsN5I3QJK3AkMAPqBah8Kvd?= =?utf-8?q?PH+yX7/JRTHrywxAf4LJGbL8TP70NjNwmTG4da5rf7lzlSeFoEJe0CyACymtbfpjb?= =?utf-8?q?jG4OpJ37JuMikwlyxz0WLC3rWCFv74bwhc0Oicl4KzmmMO7Ru6+trjvbG7GA54+JA?= =?utf-8?q?WNT3GNlYc13eKop62P4PdmK4TDgI6JJiunVqC3HH2O983F2+a0O0iLFlTNXFf8i8d?= =?utf-8?q?aC0BI2iAx44EvzH/Ax87CP8bY0243xqp+QCP95G/Hksw/4j7TZFqUwx/SmJP9EKMG?= =?utf-8?q?K7mVrcSqBHb/ZVLfeFBtO87q3g6+MHtuz2oQPweguJWQSojkw3/V0jUu9lWR5bvCK?= =?utf-8?q?8ZD+n2V68ZPtlTFrw84eF04Z6OJv8/wxyQl+CWqcKUWkIC7/L08tu6ZQeL+FjBTj9?= =?utf-8?q?WQTqIOYKQOUzpgYz9h2OxGvHlLWBDyyka6wcFogtFdk4X3XgtXeaw+4aNHPYvuoFa?= =?utf-8?q?T3M2sKXmarKxQlZgSKIITgGoMv42JnofXzeW99xsl/HCp+uH4TMlBlu97WNRXKkNr?= =?utf-8?q?Q0Onyo8j4Uko8T2TxS/ZR0YItfhwF0qLpecN5Bhi5zG8iaXuefq1G1ra4HcAkh99M?= =?utf-8?q?gFa/MbHdPd46Sbw8o4AUZgb3/BAWIWt1+b74nVG7toEnPJrk2sEQv8CZBksKnkBw1?= =?utf-8?q?bZ+nCT/kx6+k2eaKkdtEeitGC71ff1oQrg06Dx52I+DGU8lublcsFpvdaopfHD1Qb?= =?utf-8?q?/lGr2Mrm5uJIkR74mzKNq8+gzVH29OOgxE0CrrWoODiiCTB17oXXKpYjZVxpTQvHo?= =?utf-8?q?QIhGq3NvdGxQXL1Ot4noq4b2mi4WGWjt2XQCJruSP4QDHmOv06OKHdq0b68SXJQby?= =?utf-8?q?6i92saf7Ldwb2sXIMAZoZutMpX4YwyrlPOdzYxI/XXqojAIHi9QNflJ8J30wc6JhM?= =?utf-8?q?0uRsEIbP1wcKYl3lz+jj3ppu2emZI7ogBhIcFMHFxrOGfhhE/lTGYgIM=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)(52116014)(7416014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fgAYNK5AGjYOEhfZcVPCxh869mbM?= =?utf-8?q?1CbvppcSbHn7pU4I7dtrzWE2v1OY7piKxibDhcB3KMPjZMUaDF+IvCCO9Z2Kl/UOm?= =?utf-8?q?Cpp8A8PHN8Od5OcL595ADSByKAjcgqGmokxpsYteEXLIeb13Qx7fQR8Tj25yoJZsB?= =?utf-8?q?QqeSZ5wOg4HuO0sxtcAq4d8LgPyM4NqlM+0Vjd7uyDMRyiw7yMXy9NojXHouVVe93?= =?utf-8?q?QCd3/vEhhmkRUBWACAnyIq0CZJsi2vZjoCFM0qlE5uLpcO69yXlj3z8JNflD+AVtp?= =?utf-8?q?x35RfH6YwhqFI/0xxOLeBVzQwGjy+y6zQylxB4pjrit1S+DiZS8/WW+odHMB2V14S?= =?utf-8?q?3VtNmeZkm57aXj3i0SficCFNgSlJs7xYTdAsDwlSlUOWbN76PRDSQ1rHwIvxYGYW3?= =?utf-8?q?cWnlqiWW1gSGSFTzVG4464QdjYa5TQQ7FMbQZm5KtL8xhIai5nZofPOxwHzDo7ttb?= =?utf-8?q?7KGXX6HWnDfS8oGmLI/+XWRjGBglikUbhIMpF8gESUnkpPG/OzC6aXaEEli4gVLaA?= =?utf-8?q?vbSz2+EPbrk0E9pk7kDjiF2XbzlFxjwZz4groO11ligNAtnoOp2sJq8Y5GqeSZIpC?= =?utf-8?q?jvbpvkh6/lZVY10t+IuPUeqjPtddixae1OHkbFH+HGVYRYDhDJ8nMojJOVDAKgUcR?= =?utf-8?q?IgDUR28aQQugwKWCulBsw9Trz/IOkSp0q5lRF4/rysJLtGdNDxFmt7TauF1QnTKX3?= =?utf-8?q?bZA8b9974Hw7ekcDlGoH4GETTbMqgZ6YEpu90jGA4hBWGIs9Ph8Gn+WS8LgYmPYrA?= =?utf-8?q?uGv+mlsVgx7tJ/skRWEuYyhPwqwV29JaJLxbsbxVK8ySBbQGIx0u7pXMfHzBNpG6h?= =?utf-8?q?8uLEgKDkMa7tebiPOOOPStjJ30oaXePDClLwe9MIY6VW8XQqTMEa56t3d4/yp8Qj3?= =?utf-8?q?l9bhPi+D+6wy+nkQm9Flgg4MBBL5iDMq/9gQLoGdtUxwHdem/oPXilng11i1osr55?= =?utf-8?q?2Psj3nRCIDmvcl1G6iynXnR/0B1EEDgPhBkK8E7rsC09waUWSrXjjqzr/BFZQqsIu?= =?utf-8?q?RL7ktz5a5xrjVOp7MntUQB8u0mylk0SBWx4iumbtZLoJtI521ddC/utdghgTQ8I18?= =?utf-8?q?iQV04gDW6mE2pWpXbkS82sToQ9f2C67F+Yu/fuuYB78kweOT7PNuj8kw2sEi3MAjG?= =?utf-8?q?kwAE1bsESMWvZbo2kxE9p0j7edAhpGJdIFwhqovML2k6fAyq/W2CZqbxtJKgINlc0?= =?utf-8?q?3zacIattzRf+hfwx/rSCy75eZPDidqdcgV2UR9P83wnvb2KEAbAdkI0VscTHexbEp?= =?utf-8?q?FT3zFN4jfLfiP1UsVF9FhvEwkOCsSnlMJacJsPpaC5mBNibCqoKjjGmV+53zqZajS?= =?utf-8?q?agqiPQB8M4k0E60bNyZc29jLig9hywxZVQFDzR4tLlo6z2uafxUsexSVeR0gX1eOq?= =?utf-8?q?qaNa0ZtzCSfjaZLBSIDPN8us0albQ/FT8RTI+YMKGyL3IVVX/iaxju6DNBriFauwN?= =?utf-8?q?jXWoj7WLcGzXMGwjIOP/Q93IT/4/o33HVOgBHgJ6Ow/lRYiIm/a0CQgI=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05103112-3b53-4e3a-6a9b-08dd04ff1d1e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2024 22:53:10.9464 (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: aBUpvDhni6lNoHoLArVYorCmqZciuSLvLwUhX+zpmifXBZBm7C0j1SNifb8HDy3Nqvh5gdHAOqwc222KzX621A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DUZPR04MB9967 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 form v6 to v7 - 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 | 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