From patchwork Wed Dec 4 23:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13894451 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2055.outbound.protection.outlook.com [40.107.241.55]) (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 AEFC420D519 for ; Wed, 4 Dec 2024 23:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733354803; cv=fail; b=ob0kYXi2hdnsYb2xKindAn4u5CKWqS0wsaHUQb26QOwdXBowIvkK8c4DFkUKqB46u9u0eG24Hs/m3LxAknxIvZMRZB/z7094ZWPQ4JfQsxaESXLn2/fxKTu3ENUeVxpNzDUV3YrfblC4BsBZRTBlndplSqjh/ua/1vP4XrbmB10= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733354803; c=relaxed/simple; bh=pWGytAB8s6gen2m9ZI1DoOIIZFW+6li87luByAgV91Y=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=hXA2BX8BWphTJUykzwfCnyRTXTOTotEUT8+5UbuVJSiN28y8zQyL3Tbp6cPZ/1G2dDrkdlJeRWJ7urtm1nTVDiJOTxYc5qnHo/7pcZGtcqd0+fSTTkvAXrrfiuC91WznE7F8/B7WpgBA6nukXMlK9olT8+QqZTguYpQNa9eSOY4= 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=Zp97eLNS; arc=fail smtp.client-ip=40.107.241.55 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="Zp97eLNS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AyhGzTJRNW6n8NWyZF++imZUKwLgyRK57H++io1GP3JMDaCmOvNPv8+aNUbznTWGHNdPXIOdqN13g6jGjwoYkBcghL30dsckmPvO0hj67dCe9YgdRuvm6G2sMcM2coIVTPqY8isEHcynj3FG1p+xdnCmJuMk1spEQywjq83w+uHsBg0P+LEQR16mOKXWVaAlQnea/mSsyDjGwPEQU7hHRQDWaklnSIGUW2ZM9HnhE2I4jidNb4Ok9WQgxJdCs6aXBjy8XZR3bljewJyR1gZ9ZB/EmdRpe0mJBzSq9GvNyA13nyujbAvG1SHFtdMYogOURCypAu8Y9E8LTBE2yWHpaA== 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=6DCmePda4j/FCA9JotgJUo0sd4sEBON3NlxWMdS/rIo=; b=XcnJJ34TPds38JCC5CCeNVKj4qgputRU15cHPRaQ7pnM45dLHlNemSrx6nBNSc+5uxjdgbkRsllgdyrS4ayrO3cTjMAgSq6Z7MRBijLClKcMEbevbaYc9/U37NfTbc9G3Xyt+C0j9/uRSEmdL6b5MDYDGKPxEojQqQF1CMMclceu65X3aftaiGUsIuyydot9JAyv7pqO7fMbTQ/wEvnT49glospQFU8oJ41qYuO23mBKDh61zrqZnd8UA57iqfbPoqzl79KUhOAYiAhAVJMCm3cox4q0Y7VU58WvgxMa4pIIiiWqfTH88gmXqG1AGBnfxd12xjNFtgg/J7cXO43Jkw== 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=6DCmePda4j/FCA9JotgJUo0sd4sEBON3NlxWMdS/rIo=; b=Zp97eLNSyXPxWOQhW3uIPM1CIVCnSHL14rpwjQ8ciMez/m5Pk++DQpAQCzxhGK/blE3GTknicFZUND1sFthZRl//Krd5oT4mP/44zoY8E7rGgv82ICImIK6H+DwfT+CI+8tvh39Guynh1iumthupRFV2VuqgqN+LSXXmLAxMEBWkKUifLCYZJfOYkpYgylynAOgrFqjGWg0LRw2U8FYeAqqo4aYJlEE/wb/A2xJq0Z+dmJcgYylOGmm5LIxRxLCc6XiK8yMxT8KqnD1Oosnk0YjzALR39JtjPPlaaaHaEwoxCEjlR09EfrpvETjXEn+n46W560GJ1VS2Qd1HZje9HQ== 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 DU4PR04MB11006.eurprd04.prod.outlook.com (2603:10a6:10:58a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Wed, 4 Dec 2024 23:26:40 +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, 4 Dec 2024 23:26:40 +0000 From: Frank Li Date: Wed, 04 Dec 2024 18:25:56 -0500 Subject: [PATCH v10 6/7] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241204-ep-msi-v10-6-87c378dbcd6d@nxp.com> References: <20241204-ep-msi-v10-0-87c378dbcd6d@nxp.com> In-Reply-To: <20241204-ep-msi-v10-0-87c378dbcd6d@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=1733354770; l=5981; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pWGytAB8s6gen2m9ZI1DoOIIZFW+6li87luByAgV91Y=; b=5rC2pv9kTDOCXRUuBnJG0kYZKRpOSswYd299MJQeMbL9vqqitFjrREKzfTN4XKIyaJjD2UoFj gA0SxTaGa/zCgdRVDBCucNL67JFMysGxCXpCjTtQFpse4NTKqXKbTNn X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0031.namprd05.prod.outlook.com (2603:10b6:a03:33f::6) 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_|DU4PR04MB11006:EE_ X-MS-Office365-Filtering-Correlation-Id: 6794e5a7-2f72-49b9-58c8-08dd14bb1b1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7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cYWmDobPMgeplF9?= =?utf-8?q?tHQXXAu4a3xntjb1+3myNMWPJ9d1orSzaRUFn/+t/armHxDqQCiZeK5W/fdrPyG+X?= =?utf-8?q?CA2I/J0V7Hfht9o89ReJuPDixpMlxzVfST35CRK+fkD9kry51OT2U9uuLh3Q82ZXN?= =?utf-8?q?/zvFURJ3BVYtwC02d9n6AQbe0CtA76buWcc9wf4bG0k9EKwHcc//JzK95r2Rh8zkA?= =?utf-8?q?2Fsl7xGmWWjhCoC5XBZyzchRLQHvGcSiKFI4yaXOEcaYjHlSBroOW3wSTql79kPk9?= =?utf-8?q?OdKvWh2GvDRWGDNXfHONkSHDaBqyCknoy2FMsNz0Cu8y/LRMJ1RymI8i/QwWtQzqS?= =?utf-8?q?iOuURl2L3RmJPZ12OPqbCc/QEhXlDuQgfb8R7RWM8m3WigqpAWISwjgNmjTUJYPDP?= =?utf-8?q?aQ9eQPCYLnTYtnIu4WRifweoDm3j7svBSBLZV1oi6wFRat58nNeLuKU7nS99n2QUm?= =?utf-8?q?aXMfngU7doOzwxq0DgUNAPatJAdQKIaVrUFij7qhfFPxbP9r215uKFy628eUjbyM5?= =?utf-8?q?T+y3Yn0CtxMmSiD1QPT/QgrUCNZJ1/+CXIoe+v4xObD1cnk32wajH9w=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)(366016)(52116014)(376014)(7416014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?A2zApEjx9JZ1jv13/e01ysKcYKVE?= =?utf-8?q?7xOOMlBMtnMbA2ixgJFGaZoVuiWu0RuHXerZj/e+yFk1cfka89IBl2njhfHip7hwe?= =?utf-8?q?HoXrm7+9ey/9oY3EABH+LVwe9r2K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cwZu5LXI/BQWPWOCQqWzqB7LSUmyxIWudLprgCTOj?= =?utf-8?q?/9hpkYk/W9DvY6P6E21wOX5u9kCmNctwtlJsnUnbyg2+fVucx57SenNzAgo9j5UOc?= =?utf-8?q?bAY+dV4UW3m1Q8hrWo3csBXjACG9nbOJH8BakG1/6RpfD4VLgOjEloRSgzBtL23QU?= =?utf-8?q?R+vhQHty4ttUlkKZJPsfG/FHDAEjR6RY79T0kYSn4xhNHmyX//YSOGysi016WX0ha?= =?utf-8?q?q+l9hOtJTSZf6sKTOkdpEyj5/vxjvjNuCpCjwNXBQyDocY8K8fMyOnl4kBcNO6ebd?= =?utf-8?q?QzV9Ug2SNxIejf4zz3cxz6vqX0ras8cXgdh82IKr3DjAmWl/0M1RX1maU9sqNBRgX?= =?utf-8?q?OuwDY6Zn0+cVUF4xFECZLgSEgXHje+vClChQgi6ZT+nY1rdf8ldF+1KowkXuDw/in?= =?utf-8?q?LW60G7EZCxJhWud5jEsYzLJftVYJ9j9OVkP/2O+ep9TMnqE9Y7gw/EzoCnxMMW3CS?= =?utf-8?q?B1mT3BSF/BrppSqCNfOWSFZA38br70EVxIbkHCi2w8biO/GyFR6FL76k8IL2sv6gW?= =?utf-8?q?px5f+rV8KHi6?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6794e5a7-2f72-49b9-58c8-08dd14bb1b1a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2024 23:26:40.3544 (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: i0ADLOkgSHiZJG/qfPHKn/HySjQZBD33Y791ExtrgXUhMyqUzvhpD+zlciOHeqmOLZfTHKn3B8CbCH3rZ+Tiyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB11006 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 v10 - 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