From patchwork Wed Dec 18 23:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13914240 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2083.outbound.protection.outlook.com [40.107.20.83]) (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 F0E431FECCF; Wed, 18 Dec 2024 23:09:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734563383; cv=fail; b=kuM9S+mIK9Fjo5tTaO2Py1wOuzCzUB9PrIK0i0e8M7oNGItkJ50E+S1KajgXNfMXAcevn/unUr5nc+QHmOhE3gFJMMpuO+Tg0Gi4NKs45p4WKivgwix8SvUNsdstOVCOQxWwOgOE66ISDT7ov2XOhd9X7AEyd0lNQ96B0LI6tSY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734563383; c=relaxed/simple; bh=l2C6LMJUqwjfL15mBdBVMv+pFsAcLtUzpfL941VFEhU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=eftJLqzlI0E0AzROhoHyKks2M7X/dnJiRNdlrFTTeK8S3FqQh+pLmn2h/8Jr9n8zVN3zSZGVDz3L/EiLDOvmBVElci452OwKBAtfFe+4AEgxAYqv5hBfqQfgIboNU0DDcPcUsqslOcqflPXPkmjQKaDuof1cucmTagsnpLWLx3o= 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=FkoWw0px; arc=fail smtp.client-ip=40.107.20.83 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="FkoWw0px" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WFu6SC2/R0VBrev13OPujGXA4mzh4USOzvNuco3IB7BrcFRJNu6mMXpv1Jz61F6wwcsvgDRYWDAi3sbR9f/zXmVeJCjim01ecOUeRs+sEi0dT1G1H199KVVEbUzlKvPhhjKl6eBCtsdTd0KNG5OMqvF4R89bQ8tvXtSCbSnBiKVBFYYTuZB6CUL0DlOTjNpTn7ofhDXNzhXU0M2KAKKnxBheO2zXiWePWq+2AXAKjnnkfAB/Q9WQcN8ZwCSWPSetJPK0k1yQ15NTAh5t0f7Z76Q1DFYdmGJhpO1QWB+GFTdC00wpdY7gG6r4wvJQX/yhi1T1bkpk7DTsNQBe2mwPvQ== 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=qMhmx3IfMKOGBT5AVmm/AVxd6Wdf4EwS7VY3c3uyOJQ=; b=D0TGwIRTSPSLIBbx36WwjCyeokt72Ujc+7K/ubEzxfDh8/SNHyg01MxuYC+sTYp5t89+a2JvNqkkKvezfY+HWPK6qRlFqTQrOExImnnRKP1YZZ72BRjUqeYoHl/ox5AI1kmLGC9DBeeu+OPp7XaJvPb6S1N9tJ8dWGmXt07ig3LafWMTfZTaLWu8JOgQ5HFy4N0X+GoA09XeLdOTM2QrUvEhA5I7oqhvdNCc7N46w/o+kmhd43TZj56xiCewZzRDm+9bmic+Vyj3TjvpIaHg5Iz+wr14NjMK/PgHCKl1nUWeP0Y2aML9i8plrWMROFXu5stKwJ4vPQsYu1uaI7k1ZQ== 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=qMhmx3IfMKOGBT5AVmm/AVxd6Wdf4EwS7VY3c3uyOJQ=; b=FkoWw0pxN73Pc0zHafqohI6P3FSl1/jOxVG9Ow1kwWDzFLBpoDnBQGZYl8FzulDQayZGIrUeCp7fTUgpcQGYgFeaL3gOZg7+gFR7yJXSh6KaapNdCUFZFNGCElGJF9zLND/HiVDGWhmITZ2hfwuglD5fymPbICOZd1Bsp8l0t3jAja5Ul5OeFgLQVmNfFG+vYumNSspdkO+xgaBGofYQNoJBTkGu1vniK3oUJDbg3Z6vYVv9/pKVGH+5xwUYaNSMauDbp1ohGe7XEs2WptRJxBB9rg2l6dI6jdCHJ9h2mPbezbj3m+kdrabySLYxcT/7JbrRni0WL636Kke3nEEcKQ== 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 DB9PR04MB9939.eurprd04.prod.outlook.com (2603:10a6:10:4c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Wed, 18 Dec 2024 23:09:38 +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.8272.005; Wed, 18 Dec 2024 23:09:38 +0000 From: Frank Li Date: Wed, 18 Dec 2024 18:08:43 -0500 Subject: [PATCH v13 8/9] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241218-ep-msi-v13-8-646e2192dc24@nxp.com> References: <20241218-ep-msi-v13-0-646e2192dc24@nxp.com> In-Reply-To: <20241218-ep-msi-v13-0-646e2192dc24@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 , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1734563339; l=5981; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=l2C6LMJUqwjfL15mBdBVMv+pFsAcLtUzpfL941VFEhU=; b=91oNFsG/tnoV+sN6DpKwYVDM/B8v2uynPI0+sX3ID3wYxbkT5ABMfcnrDgnFh0e8F5EyGWcYy CqBo5OASkCwDzFU8LgGfGB40n6qYwgzCRiAxJdAduyWosOcUOadnu/J X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0075.namprd13.prod.outlook.com (2603:10b6:a03:2c4::20) 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_|DB9PR04MB9939:EE_ X-MS-Office365-Filtering-Correlation-Id: 60a3e669-3326-4d3f-8d2a-08dd1fb90bfe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|366016|52116014|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?WT8Mn6pwwygjvKcJSljnn/U8udU69Hl?= =?utf-8?q?XXEu5py9JZAcob6Pg7lWaYaMXaf95XJPv5DNGe0RVirh0WwRsCJPubrGt3eYMCOl+?= =?utf-8?q?a+EN54mchdzufAjFJZGR7mLshAJxkyMzHo8MC8ERmtE5fU6qqx4gdz0aVI1CFJGNp?= =?utf-8?q?aqFKNi8nRsbjr8ZaSNnW/zlJ3uZw21SlhxYz+TIBgsE+1yVNuORcVl2/LEewliS9l?= =?utf-8?q?GAm+keWV3K99dSun9XKGEQdgcLnFH+ufwVA0V+A6GFzWIt9SISN4d6Et7ksAlsLEd?= =?utf-8?q?whMayL3tNAsY89E9VRh8CobJbrQkZLu4TwkKEHg46s+ljkO64n/cb1iK6yiWpYwy1?= =?utf-8?q?4OFGwJ74Pz43lx1lOMXcLleBFwSYvA8xWRLKSeHPe4LGvnGIa23cZndc75LYsi6DJ?= =?utf-8?q?d+ZJm/W/3+lWgVwO/Uu2ZuUvcqEfPCBrNMPfyKm7hanM8gWZlrKGgYn23AEupja2p?= =?utf-8?q?8KyakzLBhR3tRWdu40oxRh79T/MoFJUf5o3DP1zYmdYbfI0u2mCmPNB3CtndG0XiJ?= =?utf-8?q?uJZvbRoFvx5rYhMsOXu6bTzRLgoQNEEJsQ1x2GE+TDC/bIycxwtZgRPzwXx9XVx8x?= =?utf-8?q?lNtI9opdmbfCWzmnNm/QYsMRmrb7E+1D3Np1hmoRdVBgeXsaWTDlgoSMLA4yXyeB/?= =?utf-8?q?RP2fPjyFBUMgpCQetWxPPUzGTpmjvbJlXTl1UCjCQbDMbF2eaVNsP85kiQyChUBm0?= =?utf-8?q?QE618dB1LAQ3llxK5V0KTJLOlkKBX2axiqpV3eSbyyrj6w+hOYdZ9NtLDKXRsrId9?= =?utf-8?q?vBJ+S9wwueXVPkP4h86JLtV7TqYO6Ob8Lu0yxyaeCDjcQT016pIEgVcsxM8K3S7It?= =?utf-8?q?k9zW3YPa5/+qVdvr/5TFimoWLNC3dJFkb7b9a5FEauSQ+L4sD82nBSVDIIjMeQ7bn?= =?utf-8?q?9/IxiXapccl5h4wu2NOiOVGd4z38RR6tFnD2F9n/yb8tBEreklDLK8Arzm/kBG2s5?= =?utf-8?q?GN8HMIPf1u6g3MBARBbqMxARPwfrmkQZDC4iZtaSTcSRYmeJwGGLK8/Z/v+WE3Jl2?= =?utf-8?q?pCKKkzTM5rGVa0reHNczsa1nA38r0x2qEA//0X6B5UnZ25R/IcdPzEWdSfoZA/ujA?= =?utf-8?q?/rXpidFltqI3vIFpImf36hicCU8HNk5a3c4RU2ZCPuA6KMOqTBBDHkQYlhldx7CRg?= =?utf-8?q?JbqTY3C4xtZjrHepqYqi3dxlSl9K5OU2VzJtpD8pPLvnNzr6j2W1Cr8/OSIOa5IRE?= =?utf-8?q?Rj803NQj1TRrnEW5Z2K7ExbeaCul3G4qzOvxz4ivPOPZ/aHvR6GLW1IjJUFhVvjUY?= =?utf-8?q?P0ac2ioveXpvY1yNzZDx7AzJxXYU0jJNrGsEMof7U9VhIfAdkkBnDnFOCED+5p38J?= =?utf-8?q?WZugfSiuPIIWod0umrLgAr0LQEpsHfxehXqIB8anu3H16hgCJ90oMYy0VVUjb/mY0?= =?utf-8?q?v83TrgRQ9Duarq77lf5+UjmUqIrCOgvKQ=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)(376014)(7416014)(1800799024)(366016)(52116014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AXXc6svhBdfJrSuYjs3xbsBS26Ni?= =?utf-8?q?MvUXchcm8RSXJAbCILwEVhfAyoT+FW2zX/iJPOKLtvvjcVhogCyKrtB/4Pchn7KML?= =?utf-8?q?JuNMtOkLze/EjbBTNhcTa7tz+JyPMB5wE3LqJMtFVFieveB0iynu4z9XRniSbnlIo?= =?utf-8?q?t5I3BE2zL85MkJA8KeV4EmRNCHpCIctR3KM3yqkmHHff5mC6g9aJiDVJTGpkJf82L?= =?utf-8?q?5ZRn2VGQTemG4iPGiBf2qZr9YVLi1kIWZnA+rJBRUW11NXTV1bO0RvLI+0KhofpWx?= =?utf-8?q?M/DOiTeJyoT4kcyQoxTyGnThYUXoWNvMRR+MeBZ+W3X2FQEwFHwViIYPm/o0brbv9?= =?utf-8?q?hhPavQwm7w5h5aSdOV0TCcjfb+ojHMA7G3tCsC89xc/eUnw3Chu3rq3YTcVWkONWY?= =?utf-8?q?zssGGkTKt6ITZC1Sg2uPua2SLsJXX4BOkYS1DMih5Gj7a7SnEz0nmJoTZp/gAjWG0?= =?utf-8?q?f8Q9DTF06c3nHI7TSInaNPiy6AmLsFN9u5xlWbUFNOOC0dA9DuGrpGB6Wj6TUyTIY?= =?utf-8?q?Fx3voCPXrmmSVW0I0Ijp0LF3P2TjWPWv/kRz3Xyd7l4q7cPed1sTJfbK3ImnpnVjJ?= =?utf-8?q?oXbtV+n8hLlX7UrrkXLGmMJA0mRxT1iNxR1YHXNq/r6FYk3y5dX6Zp/VwxZMj9Ymj?= =?utf-8?q?y7QAkNlnF9u9mZZFYS7ZqwrRjiGI/0yJPbmg+Yl/dticO94fc2BQaWfuM/JxaUQ/8?= =?utf-8?q?PYhtG8j0JtWcB1AXlRtbAOf2xrzLTx+BvqTr46pCTeKqhsPKe82gDvRF7s5GX6SKk?= =?utf-8?q?jTldzMEAdVx+u4bDL2iAhyN/NRUGJXxJMUCew/4QR/GtjtD8OuHZUTSPuiWQNlHcy?= =?utf-8?q?chlSjwisv1iNLUDIYEj9FfBre1dwHOarSucZnNXgkL8JdsJUT66sdb7Pl8EGat5j4?= =?utf-8?q?AHqXwVrxl2a662QEn5f9K+ErZD3Pr6JbFPH10879mO+jAAIVRcG40den9W+EvDevB?= =?utf-8?q?hR9/0UtblzsAhdX9+CL0/HnA/Wb2lcRvTMOUn9X+Pkmz+2qTVEuiMFusFjWV73Yll?= =?utf-8?q?32mCoaWTvAxYNJ8+vo67YDztrB97TljHutQoLavGXGauuwKPHYnzM44cglBJa5m54?= =?utf-8?q?dqn2IWVyB1vsS5xYadl0+lNT49GvllFEs6AMdSJFKnKg5olTXxySPb2Knkv+iIOhY?= =?utf-8?q?hbQynp082HNt1QDiZWDzFHGNo/Oj0D8RsUUQ+/XvFKKwEY0xG9ed1y/EFwbsKaUPA?= =?utf-8?q?nI3yLR/+KTjpnpjd50rip2whUnpkSp4a+eFeDiDrFBQf1VLIcRINB9gjAXBoHKINu?= =?utf-8?q?Koew0QEDcwNb7Ku1jTErCq4WPpKeNcLPwXXe+KjgIYTi6SFSpOOr9zU2QraRWOSEq?= =?utf-8?q?STK+UgoX1hEWt0c4VXeDPl5qOZiqY0HtZJ5o+7RifCPrqzK1QjmUOiwpgZtXS3pfm?= =?utf-8?q?/Fe7Q8rySyuFS8Qga57YbG+Kr4BIGOaVrXUygJJNOe9RsUn2lTEGAvgZub05uVN5H?= =?utf-8?q?60hFHTwzGJgsynYK8XORLc1Co+NAihjWLD+9pBo2oNQ3MuE5kyA8ZS/4dnOw7DIiF?= =?utf-8?q?nNDY8X83GgK1?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60a3e669-3326-4d3f-8d2a-08dd1fb90bfe X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2024 23:09:38.7910 (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: E6NatG5Afnz7WEyiQJTfL7pW8DfbYaGto6o8qKXS908t3ayNWyJ2PE9FjOnP/uHqsc+NdFVFcHJRuDhU56cicg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9939 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 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 | 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