From patchwork Wed Dec 11 20:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904146 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2057.outbound.protection.outlook.com [40.107.104.57]) (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 BEAB423A19A; Wed, 11 Dec 2024 20:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950706; cv=fail; b=gjM1Nfp5t89oLpic3Ysy3rMLXR3tvnH5q8Hf3iOa+eeXMLZ9s0xCF7mnmgRn4/FoSW/ETGYEnixFC0YWF5Mu5LMmOaPhGStDAUUmUNKTDJZvB3qFkQnmRdUpWRn5QtBVqlCZDjO0COYGXiFzXMP7kRWsDOvW2/nf6k8GMQApuKY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950706; c=relaxed/simple; bh=04o8LvhgcqnX+pJqL3zaiO6sBmMiaAG+qaGRFs84x70=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=OVO7uPgRXm9BpXJZSAHnUI8mCYHhy3/tHSMNndVVPhOFQiwksS5ZiP5AEeer1Erry7xGk2BiOgwkS3iCl+ztBkTtcbRLoi5gkDavnZy8CTGdQVPNwe3tRV7a+pWKT/wUbUtVP3vmYeVNzQmPAkySLjOlTuUusTL9PnhALx/E4rM= 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=LQnoO+l1; arc=fail smtp.client-ip=40.107.104.57 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="LQnoO+l1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=COTJ7rskr2zHJMgsM8N1axEoimLxnBwW8tx6BvpSt63Xcq3OVF/EHlVReF83lg1n0SaUQi5SfsfMjC0z+aQOtH1BOLzOEdnctjj4QHc3XK6FA+Yqo5kJD3Slne4bG0FdxgSjNHevqFEn/1FooE3AuuagI4ZbV8QpgDVBK0e75f6AYV4EYqbUw7gw//3I8XDLFFxTKrjvMbfaQVNxkMkWAb/fpMrIKUN9WjqmZC4xoMZ+rogcdq9a498S1Ub5Z3Q07kVTgFkmnlH8OSBWofUPB8r4lJanmWs9JUvDNYCarwKAHjv8R2nTLxFhMRUORiNjKkk5YJnQaJzb0WzYpyn+nw== 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=vUfOoPgd7QzvV0XqY7bT7dT8x4B/BnsNnIWzUIpaNGg=; b=RBtG/J02M+pOFJA8l9H6KfqIG7FVWlpNNlBCaWUodmB+bI3kO6hkb0aWIdePx/GzWUlZsdfaK138Qty1OppUmNARMjbNpJLlEkiittrqT1l9AV1j4ik+MKoZGm+XehhupdoW/z1UTWm4vDXBd/T8B3S/Z8SR8YU0N6fRqseoHFafI49jGv72jgOHcONsn07SWRG09yqQRL7lcpmhwlVTWOm9Vk8lxyGpLyRZ+X/DEgYOFxJTosVLKSHlZmanAxBv2HZ1aJCAe+efyVsvN8dZuzLaZtDOpmYs75TY8fGHdSpRXvUMfAokw4KT11mrfTbJs+A/dUIZmY5OhGj4LkII7A== 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=vUfOoPgd7QzvV0XqY7bT7dT8x4B/BnsNnIWzUIpaNGg=; b=LQnoO+l1o1X2u+PLvm094ZeTk5qZBdjM6NIblFnfEiTQtj2hICaGFsnYwEvLFP26Ed45bbwDL5tdOATHy7Wvgb3IwP1xKI64eR1QX0hFDPUkh3SVMf/pMU38sngePUWaOi3uJyot7gJIOIQVWRXG9ih1buGBbfFGDzBEDfA87JTjJa6D9ASQHebic9PqJHLr517NssJLa+F1jSswfpLSyMyR/RPEgEAzbnteIcHH3M5j7MZ71XGek5/pjJXxXvGDDX136iwgJxf4FbojQy7noTbUtP4wio8cGK0CHqXnu6QivhgJuAk0Y7xvjYLgdfLASAsgWaBRa6VEBmgF4jx0Aw== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:22 +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.8230.010; Wed, 11 Dec 2024 20:58:22 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:36 -0500 Subject: [PATCH v12 8/9] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241211-ep-msi-v12-8-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@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=1733950663; l=5981; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=04o8LvhgcqnX+pJqL3zaiO6sBmMiaAG+qaGRFs84x70=; b=o9THKM1FJ1ALGXrUdJMBKl5faPEvR8P2Saya/aNWf0aFH2hPH/sQ7Jda8LeCquwk22LC70lzH dJ0jxOYf3KVAaMFAGYHOyye8fRVChQgQTmSTFyOOgq5rCKj11SD5Mpf X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) 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_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: de14f161-19a4-47f1-bb74-08dd1a268c51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?BQiS6ey9H0qxrVve6OIgMW24m95AWob?= =?utf-8?q?DdE4bej1+ZVD7ZjbCSRFuvrEVPD+wLpZGWVM+4KcYNUNvBbZF8kTSDw/W4slosI9f?= =?utf-8?q?zKU2yzc/nFByjx0GinfvWF4RQCPzQXLugccUvJjO2YHhr7wPsURsgry8Oq1tZ4h+M?= =?utf-8?q?K5ceQ/b/hPwDMwl0KWbFuO86dYQdguSAhLCfitzd+5/gBeY2+sDJzwuLR6+6/Z80I?= =?utf-8?q?Uczlq+Fss9SGKvr36/OMZsJO7g3Cy/jwnLGEjdS9nitiMI4FEr8d1Iv88yaOeCue/?= =?utf-8?q?C7FLutCw+iV8rTWcxPT3LkgJXUn/QnlpljM66Jmc0HZUbYE5sGyTlEfRlSgGtHmu6?= =?utf-8?q?sfwUJmfe1f6orRCpX7rlf4edonwGffN++jn3AUwLQSotPwMM7FH/dN4FQgy932U1K?= =?utf-8?q?wJAmzuosWgS9RXOvqIkFl8awpDY41darF6EN9ww2b53/m2FMZ88fbMo68MIGqXuCN?= =?utf-8?q?aHXzG/Oin7fFQEu6Yj1QVgHpN1//h9G4kDRaucLj0qd3u/3gtc/xtbUtSrq36f6t9?= =?utf-8?q?bGABHi/SjkpJ/ITGS72DpdaMB3Rz9vex3gCw8mUGP0uB1bcKc3LGtaBzXIJUMW9YZ?= =?utf-8?q?UAXcxlvgjD44Z/msfwbNnf+2Ac3vv4KPXfoRbNVAxd1LF/xHSlgWDz2fi+Zq8tLH3?= =?utf-8?q?fvMrbvrmgDb9fBOYr81oxGTw2cq6bfJJM3V1+mMyJeCz+PWy2w8eZvQ1Flq6hsrUb?= =?utf-8?q?yl3fkFchp8Q/0B5E+kpTcyIDoHS+mENQ/1V7STmMY+qVAXwWvmjhldMRpssenuhLq?= =?utf-8?q?U2q5/DdDjKA/v7/Jk75pdK+q3/DAl6FbXrYzGjun+VrehGCcElFp4V6enKiJGRu+8?= =?utf-8?q?2m0Ttl52171Cve1tZAdzxkI8TcqaiARFQdrgPRUhUGdkDuPzIQ6+cVPd3NUlOxc1/?= =?utf-8?q?O8pnKLBkKHe3tfcE7ZvZWCj0s5jLemTIra28ua8mlaD/UJW9xuwufM8EooETUk4cX?= =?utf-8?q?/IKHC07I9AfObiW+JLkcvZw24lzrA4WFWePV3p2De0wBR+E1ABRpypO2kSgfGxCwK?= =?utf-8?q?ZjgcIKljreDl+xTOmENxXU8Vgv4ESYqSkI7QRTHCdhwCv1swgJbMQgoLn5Z171diu?= =?utf-8?q?6ubpOANLhxq7OAOCsZcWQ7t9GJfJtnrjKfAJF6gmabyxt/neyVGuI1sxn/dsqLik7?= =?utf-8?q?QbDBt/z0hrv8NSg+P8XisWPa6vLPEEQAo8YdLU2davcDSx01AoK+GvveNkmEwQkWQ?= =?utf-8?q?iGgqMDzTjI0EYyJXu6FaFdTObTr3JG+naOYd7wm5MVO4DM+70ug1DblNQjlYAD0os?= =?utf-8?q?mvvtK/cwKNKwUDErgezdfMXplIdJkweF4LuIne3oL3eEz/ZX9lBluAtcCov7CBB6d?= =?utf-8?q?c5ifzSkC0ntk4evt6Z/uWEvkaLbOdZOC64BYa37b29C4sJ2iLOVsfN4=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)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?vFr5DLB5hZe+vRen43039+DKNlTA?= =?utf-8?q?uIcSoowNQHRAJN707DVYpSuohgdSRas63T0p8KGLZb2DmkJJK5XYiovQzWKzb8WYJ?= =?utf-8?q?2znONXnMZ7J9QohxKnO0tmrfX2OThDJqbkrm9N4YvBDSwV06+Eede9zHcAOGX+Dpj?= =?utf-8?q?C6O5F1eIfCoLBLK/nqPWjxpsu5Lv+C7rHuZY0+7rO8APuR4DxhxM+e/e4/816ob8O?= =?utf-8?q?VjHM3Ge+kdS51dbaYRIm39OFFXQaJtJM1V0K1RFJhVyp/QewXZrcE2h/GNV8yHF5V?= =?utf-8?q?kgm2dvpVckmrsZ7uhQnXxfc+Wz0WC8MVPFk6TzFJnmRp/RwvMRbnKTecr6KBv01yt?= =?utf-8?q?DwtMhiTgPviXw9HOD7VkVpkxRw8zYpaDn8XZQW+c+uG2MnxStmTH1y7wIrbUP41rX?= =?utf-8?q?rlmUoCYHtvrZaydyOsL1OSFI4KW2bg6oc9bXWc4O+mul7LPGSnpBDwg64bMGQJKdM?= =?utf-8?q?feww+kLiLFSvQpNES8qF8x8DunX2XiQB4t7X0e+oBTG5ltCZHh5CEUygsxLg8AWbv?= =?utf-8?q?ZYpKfkuFAN6B/06KLg/L6i2rDRlA6G+R0tgH73gsFS+gCtlwJrlgnxmu3s34sqsV/?= =?utf-8?q?5H2NcetXe9b4OqcD7Kn3nlA/l1N8XSGemHmnIu4irX1agwbWrpyDSAwNuOWUvNv6F?= =?utf-8?q?FKzl+Em2SLXEbmAW8/p7k5BhmWyGDqNoNzPyDK5MnNtnCuLxEt9nImYMs61sWmC4Q?= =?utf-8?q?3WDF1vF+p5oZgoIM3K8zb7yMA+zTIYQfTFq+WRg9eBqAJrsrkBwddtfkH+SRsdE1P?= =?utf-8?q?lDcN3YJBgS1h8JstFtcBzLDyDRKc1tq5Rp+krh9JPPNXd9MMUdmbP/pBzrXR0OLq3?= =?utf-8?q?1OVAsztLn0sqlD+0aV1HKacB/HQerE611xA2c1Lyda2zLr9ilnBvyWUGjz4NTYB/m?= =?utf-8?q?bianrEgwYU6cuacLWioTwu5ZB54N8ezcF/BbZ6311FDTvACopK1ebgIOeBYYiDgF7?= =?utf-8?q?clJLj+dMRq13njSfgF775tGzH2twifMSkfZ3ljqmS4Nv8xCtI7S2eIpZfNRQvjEyK?= =?utf-8?q?TxvxXJbpBbPyoTWfQVrwdPAw2kEU9Yz3ir81VjmGKxgfVShgxUlfuljBb+OzUVycx?= =?utf-8?q?PwCuo3kxkSUOwaTFSlOkExXH1cnxLot3ifd6eOROfiqBb7pN40ZEDI6SVbnstvx3W?= =?utf-8?q?yE08sCvDETqDoDh923m1OO8w4sPP7tiYyVQ4uvpDx94me4kpwfSS/DdT7CJOC1fqH?= =?utf-8?q?a3CMZeGKF5u1zj3hH1hPo4r+5CD/AFiBiEhRDWUNsdkuFPeZ8ZnnCuw2RZ0q/P9p6?= =?utf-8?q?L6w12kK3x+3V0tWJ71UY/FAN7Npho/E3oFlr7Tc+FGqsX8v88a+HkHbLBUmWybCwc?= =?utf-8?q?iT7MmbZQQS2MRVVvY0NmEldAOeuFKD0glzUgqvtacwMT/DhJcfkTIX+zu6nqzInMa?= =?utf-8?q?bRliG5Dn8pSNcYiddDdmtcC5ZmlZAhY9VOD1EGOOa+KlH+K6Nrl3wmWetb9KUaSn5?= =?utf-8?q?HXozK5vEYKxgxmz3v/6ZUn6zwhgxQtJ1wJwAsrI/8YDy7uVXQt73+8V3DQag2GI2d?= =?utf-8?q?3whTR4v4mj8S?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: de14f161-19a4-47f1-bb74-08dd1a268c51 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:22.2635 (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: xf5HYn82wiVBTzk01WXTtkfpga7Yrs4rjfAycQR1tKG7Iz3nJlwoKmOLp5ttvv1KLqVKjoZY4ccjU/M6m1Ry8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 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 v12 - 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