From patchwork Thu Oct 31 16:27:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13858180 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2045.outbound.protection.outlook.com [40.107.21.45]) (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 EBA4E1C9DCD; Thu, 31 Oct 2024 16:27:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392059; cv=fail; b=td+nhlcu7XeYul0WdqgwjmnrJGRCbIFzcZ/lMTYu4MwY4UhGcN49MCqDumMPEdTJgPAKX72ziPdl8IBgFUIeehelMWGPwZypt+8I7ZiFrufSihd8037fiPC2kxtZMh+rTAWYbf74lKGDuWc2a3FgmjQFOj6NPya79GE3jEx2gCI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730392059; c=relaxed/simple; bh=i6aZ3BpLlZvTDNHNcifM1VjlyX/rs1wNUbpxzMJy3Ik=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=bqt6cyqC3XvGHLn98DRchu8zE1tmHKvkDZH0dd78GTfNNJulW5Tgsl/LJUbf9NbP2w/Mc0TXUHHHk8ZBHqMdt7omK3fP2agkD2wa7xAWLug6U9b8GjCl7tle2xJgAiRyf+V3YU2IpPOtayKOyOaEUmrnSO6EzA1OPL28IoleaMc= 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=UJAm8Gea; arc=fail smtp.client-ip=40.107.21.45 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="UJAm8Gea" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o98czCV4LFC+SDKgiCWv4HrYfo2UZU6FVqX+IO+cofqvXjJJJzLKdaJLwukDkxlwi/ehKv47MQEhvqHUwIK0pwUqKtskbY6UlGM+kQNttUltyKb/xPVRu64JCM+Y0/1drWq+zfXhjbDJtC+3wAt3DNxX5xWgZXBYAUHXFNwIEDzSRbepiViccBNxr07Y0SCYnlb1jQWKABmDT6R7gZK6ZAohDwvG72wHq3YPyJOjXTnnZwq4FUtCm4D6PvnMt3J/O5bnF5zapObjp+41pnLLuWDNQpEXR8fPiZLXNVcUAUheX9kfziKchXvko2M8PcHX10p/woW2NOhgLJyO4o7iOg== 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=bdsDZcZopyzwIsuh8/N0Z3TaMLcl/E/eqRHf10fBk4A=; b=aRARyyujoXSSoHwTQch8M1SKXZrLQzi4+JoT7gXHFJqM8HlTLt9BKeDCH5NeBOy71NgUnIknzIdwUo0kpGdnC0H79IJXgD0eFnTFNSOb3IVQUI1FJl5bvPxcyFdjonF1whBgPCCr80+K28Hh57g6bUP40WTAs+q5WBS9ikWmuNF0tS5vexe9CFFlGfV7KmNKDqzHjAxStTyD20WgmTvq/pr+QAWqzcWPpjBvgd0fnkx0hqVmODCUyyeQBdFyCbYKLGX8OmRZs2aiPqqEhTH/1WG13NxhBzxVJBYWrelrdIato2TLVKZuxSZnqSirPLUWVNERnM+Mn9szJNTDPUXGlg== 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=bdsDZcZopyzwIsuh8/N0Z3TaMLcl/E/eqRHf10fBk4A=; b=UJAm8GeaNVNtWEwcQZ+4XyKzNdNTW5sGzo+54SPaYYPyIM6eCnySMeWsWyJz7KaQ+ONg2OTwRAERUv1pyWlyxoK5bhZi/nb5Hn4T5+Hn45cVCU5ek22lBZ4Wpjj28Mzk0aJ+HgWX8tUgfAqgsHaQHNSghqsrP4F9QmG3ViIikOQA7NeDGmCzwO3Bo9IfdnmQOjXESrRhAtWbRdtth3pp/4fIoZz0kD+qIadcDwRrzcRU8hSBSYXM4S1VWSWzufBS6Hp+WuBL9+2N2t3nw4D/OYY18YDYUa0RKj1Zn4Au/2sBVwK9QcOXiUqePg83mLHPTVhIPy62en9DMDuKC2Af0Q== 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 PA1PR04MB11081.eurprd04.prod.outlook.com (2603:10a6:102:485::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 31 Oct 2024 16:27:28 +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.8093.027; Thu, 31 Oct 2024 16:27:27 +0000 From: Frank Li Date: Thu, 31 Oct 2024 12:27:03 -0400 Subject: [PATCH v4 4/5] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241031-ep-msi-v4-4-717da2d99b28@nxp.com> References: <20241031-ep-msi-v4-0-717da2d99b28@nxp.com> In-Reply-To: <20241031-ep-msi-v4-0-717da2d99b28@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=1730392028; l=5224; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=i6aZ3BpLlZvTDNHNcifM1VjlyX/rs1wNUbpxzMJy3Ik=; b=5jELuiH5oQz+YJD33m0qwKHJuSgQnlfEdt3F7+EOGKN3nfGuwoR0EzfLnaC1WJnhQTaKPi9Af HMOguLXZSh9BlWtf4mkSpwoi1/n+vsifws3EQ8W+bi5VDMNZbNbowDC X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR08CA0056.namprd08.prod.outlook.com (2603:10b6:a03:117::33) 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_|PA1PR04MB11081:EE_ X-MS-Office365-Filtering-Correlation-Id: ec108188-9697-44fe-ac73-08dcf9c8e8c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|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A9?= =?utf-8?q?JhUXs/CB0D02jkdti6Q45LZ+RQJ1oMm/WYZb0wxdvt4wOCoi4PdUsHogmE/qrVIZP?= =?utf-8?q?f5o/THAhm6YTKZ0yYRBsqDbi/IbUSPOGNOA2WUCvQZaLgrrkPdVHBBWyvE0Xedbuz?= =?utf-8?q?JZ4RiO0CB8wIgV1Xk2BlorJ2uZ+C35calD7ckKkVrqYm/D34q7gB/l+4CemQRlFft?= =?utf-8?q?zDbdMhptearVrFtuPJ6p7kGTWrsUBtSqVKlPjrCBudeMk0zO/+epI6/+869/SCpyG?= =?utf-8?q?DXQOo7Aa1ShNKgJkOKvgM3QIyGCbOLj1m60hhtOFUB/MH2D+xHr287Ex5ust5smx9?= =?utf-8?q?P0x96IrSNljCS+htekeZiJygPjUCbQLdHMooXEWOGs1GZM3i3yyWFlgCsd7wpmyna?= =?utf-8?q?WDpt3cCl9S0Z7YgzUbpIvfcX3Yu6bD3HVWepUYqmHv/6rDTDhjqbSufBEQof9X6ve?= =?utf-8?q?d2acQ8g33pHWeaICv82cg/jFuGGfckF2OUkzg97wyqq+VdaKD0gHbUso=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)(366016)(376014)(52116014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?QOpY41+m3tp5b5+xYkh50Wnq56sr?= =?utf-8?q?CrO56SFAHuH3c79gWiJmo9HiEzdEtsn6IyOszRpG08IEn0M6wXZOx/WvPoiNrWWGn?= =?utf-8?q?8+HLC7YlaQBZFjkPvV+XE4tMdSNN61YxNzp7mXIUf17T8+4uDuahFuK2cT+oZxQz+?= =?utf-8?q?DkRyr0qnySmGWyWmWlQEae6FQyXwkNWXhwUxQi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Qwm?= =?utf-8?q?zgiCYkHBTdovzV+beUPl1Zyt0DpZJAId+ZnizTX6cCdeMdPK6qyMFgVrAlja5FKQY?= =?utf-8?q?c7PlbRm16GcN7v/hmKAkC7d7LrvBs1eUmat0UBOqBIysLv8DYlyYVaousglyWCNLV?= =?utf-8?q?+tbm9U5P6N21Lg2xKwKaATJsqPlhyT6CIvkFDRJVRwBtbr6xZbw52HWkXnQgkeJto?= =?utf-8?q?m/pJM2xOjmd5Kwq6Bomf1wZOpVr552qZlvMaWoukeDz9COX+WKWX/1o+b3sQLGhGo?= =?utf-8?q?BZfdOPOgA4nESbVOvPC9lF63rSFQiHiMeipIYBuyt0yiVz4p6X1IbR7n93s5OyX64?= =?utf-8?q?u9rDzM9jq2ba/pdmimqa+UpN62G5SJUivMjyYPFerahGVbwvvhWayx2NBa/x86mwc?= =?utf-8?q?/NQPPWECpRowloD1PE+F5EY6/Ff8DgI3gB3GQ4cMDJ9rT6Ygr9HQD6pk=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec108188-9697-44fe-ac73-08dcf9c8e8c6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 16:27:27.5115 (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: wEpcAi2OqKo1sim7hcv0WG/wURBMySfU4Fi+D+XPC2NRotx5hJeYfctbLmjmyjnepiJlnvVuhYXvBR5m2LuXAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB11081 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_ADDR 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. Signed-off-by: Frank Li --- change from v3 to v4 - Add COMMAND_ENABLE_DOORBELL and COMMAND_DISABLE_DOORBELL. - Remove new DID requirement. --- drivers/misc/pci_endpoint_test.c | 63 ++++++++++++++++++++++++++++++++++++++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 64 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 3aaaf47fa4ee2..d8193626c8965 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,7 +74,12 @@ #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_ADDR 0x34 +#define PCI_ENDPOINT_TEST_DB_DATA 0x38 + #define FLAG_USE_DMA BIT(0) +#define FLAG_SUPPORT_DOORBELL BIT(1) #define PCI_DEVICE_ID_TI_AM654 0xb00c #define PCI_DEVICE_ID_TI_J7200 0xb00f @@ -75,6 +87,7 @@ #define PCI_DEVICE_ID_TI_J721S2 0xb013 #define PCI_DEVICE_ID_LS1088A 0x80c0 #define PCI_DEVICE_ID_IMX8 0x0808 +#define PCI_DEVICE_ID_IMX8_DB 0x080c #define is_am654_pci_dev(pdev) \ ((pdev)->device == PCI_DEVICE_ID_TI_AM654) @@ -108,6 +121,7 @@ enum pci_barno { BAR_3, BAR_4, BAR_5, + NO_BAR = -1, }; struct pci_endpoint_test { @@ -746,6 +760,52 @@ 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) +{ + enum pci_barno bar; + u32 data, status; + u32 addr; + + 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_ADDR); + 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 +853,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