From patchwork Sat Nov 16 14:40:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13877601 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013010.outbound.protection.outlook.com [52.101.67.10]) (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 BDEDA38F9C; Sat, 16 Nov 2024 14:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.10 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731768084; cv=fail; b=LMxZ32HTKczWglYf6SXVJspR2aUW6JPvsbPZc17r02U46Fyk6xQmyZO5ne150b+ERHhJwi2Lb269dS4/kd8OXEF+4C6HtxqCMcT7IeGruVHhlpT3xSmJSw90I6l8K4RaOLtV7/td1ytYDsw1NoPRJ8TbTaBt8LyorBtuTWF1kjs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731768084; c=relaxed/simple; bh=bfBlohtvx2bmitM09sd2P0/1msiF1RQlPsCuEI4gWds=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=AxXDWYtaPhDU91L5uREdnVOzZbiA5ViiyjGOZ1d6mI17PssoD7ehhzxB9VDAR16N4HNwf31Z5o8Tg4LQKJseqlQ6LJyjgRSqEy0Q2roMSzNKUegYQz2GPfgx+y6RgqVNtcvX8EuEuj5BJuv2qbGuj8+KqP+cK8TFsFm0khzPmSM= 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=Em70wJrX; arc=fail smtp.client-ip=52.101.67.10 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="Em70wJrX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yUPAes3xkdt3aj0dclhi2rtwtKmr43o/MdQwFFgdJAMDIsm8HNYZjPRzP9PpyEgxR9BA5YNennzwSrxkngrW8bJFiMszdLUh/jvyPILoSYe1bYfKlDHKEKRX3XN5b+OOghV6t41xaI6Ni9XC6WQGsC/6E5qjHMF5rt2rE3/cyFX5VfgCmD3K02sa00Ri+unrMapRXXSDjCAszjZlm+QGWBWMFUu6fnFhHNk/8ICjoZAbRcKVGoUf4SArXdkUHVApneDntYQxA1y9y0NtZRazBJuJsrThaVpTQN/HFZn5YSCqpLBZg8WiFhJnuNG1NxZH+sl0HcNMewAeszwBk0Aj8g== 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=sPLSAjBxVhmW/iYWYZ4v4ELai9IvZTkeFFwJE94I+Ww=; b=Dk0GX3ypQa9NdnxPOkwHb0bqBnoXJwkeEn8zvOfmzOrafBrxK+hG4WDI+Cb9VIDlBmsnCotxiPGHtXEJxtPJqdDcglHiGfudiWcLcJw90dybRJ18KH1/k3PzQkBR+dkt8oqbJ4WjnI/7HqsogKYBsGBPI1pPjuy7SMxclmtTUguEEw0mEjcQCD60uUkoUpAaGpeTxG5Umj71/zeAS8AqVwD7SZt5L2sMh+UXszLgkrR14krWO0Y2eRhAQKJDgCT474ET2870hCsUIuFJTu5qxCzW4ZCTW/4kszBvG/qA9kn/KOx9IUvSSEjEE7RQ9sfW6fmgYdk+JDQQR6YWmD7qrg== 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=sPLSAjBxVhmW/iYWYZ4v4ELai9IvZTkeFFwJE94I+Ww=; b=Em70wJrXGL49ancuIJAdvqVAMXtEX1nyZgS5QiRTXGvakNekPe3n39GCVpLvRnCyIO5tfS1/Bqy8imNQCRvUIIEuR8YVBzNhyQTqv13lXiiNDSPkAh4cySjpDLmqKbe25mY5aqIA76xkjIm6AWCI2Gt/vb+nKq7zic/lbrMiUH5uSHvVFeZFBhWorgtHPqPZJTI0bB2RKZpP5gVmLTQoOLx62dMSy2DtwszJC7D1e3zvc3kpTR2oPwCWSbFW+FadZSwkl2l/2fBAeWj1tCSotUqG8WZbVdbG8s/4v5ybjrjN207AbswJbma+y2kmvr7KsulEDBbOBm8MhISUuWxPZA== 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 AM8PR04MB7265.eurprd04.prod.outlook.com (2603:10a6:20b:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Sat, 16 Nov 2024 14:41:20 +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.8158.017; Sat, 16 Nov 2024 14:41:20 +0000 From: Frank Li Date: Sat, 16 Nov 2024 09:40:45 -0500 Subject: [PATCH v8 5/6] misc: pci_endpoint_test: Add doorbell test case Message-Id: <20241116-ep-msi-v8-5-6f1f68ffd1bb@nxp.com> References: <20241116-ep-msi-v8-0-6f1f68ffd1bb@nxp.com> In-Reply-To: <20241116-ep-msi-v8-0-6f1f68ffd1bb@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=1731768057; l=5527; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=bfBlohtvx2bmitM09sd2P0/1msiF1RQlPsCuEI4gWds=; b=R7yeWlooL09qMBHQ6B5jA/netTygU+2xCXeQeYPhP+4oTtMk6hlya2JAMPdOt0Vf3T3S8Yn25 btDmwrEgvaHC4gfzw8jCL01LTijIf38ZbKNdoh06soCMTO8Oh6eK/0I X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0210.namprd13.prod.outlook.com (2603:10b6:a03:2c3::35) 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_|AM8PR04MB7265:EE_ X-MS-Office365-Filtering-Correlation-Id: fa82eb39-b14d-47bf-2fd5-08dd064cbc42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|7416014|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?utf-8?q?pJeEqf1o2tokNQT9lXFvnihWPBKzpqF+g/iORwPSPYNeR/T0Stxfza38FS2Dm+Rql?= =?utf-8?q?g4uQAs4Q9GU/BfpCVOjmTIQ6ezZWKjjPuku8qWXyH0vY0iyzJz4MYDzPeqxLv0V7f?= =?utf-8?q?4fYguagU2ICuzergp79GbvlHu+8aM4i+CgT4D8bble2fybipGuvs3um/yaMSy7/u3?= =?utf-8?q?+1iexyO5YfrIs+vEk+5GMstpLGfiClnQksrUhoV3+YJIYfX3PgzlwHbDNa4w/GuoK?= =?utf-8?q?7vfxiBGph+2EzP+a2twobgedOGHtBiEdruPHtajS4N1h6LjiAGTkbQzw96xiQg2oP?= =?utf-8?q?EUp97fKxxBa0PzXrW7ujpAOjCAWR4QGYWqyX/7NdP7iORtbUd8acKIpAwsMhiKh9O?= =?utf-8?q?X1AUpzJMAAIWfUXELBsMRBIjwCm58FkXwaHsa0AX9n6vVn7xSzruyFGYWLhCAf+zY?= =?utf-8?q?Xr+mQj1/KVo3kaU7wi4K76gxy3g0tqpNqOET5YnKgw30U/nHtYmZIKEw=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?9yKk09pwJK2nTkBSvtJG6bPQjsJ+?= =?utf-8?q?SPk+Fw01Ki1K7AzPVQTlJDyH4VKKcUig9quxaumJfON0YrF74tk+WIlxXG0ffU7fi?= =?utf-8?q?4nvuyugrbXG5sHgLzOKShFc6NKesHBD61QnZmgqmzzagrA5rzR9s8edWpbBgX/BWj?= =?utf-8?q?X0ZKqwLQSHp3G1OlAECMOcVt1tPkYdb1Qd1CAHb0VriBSui7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vsbdSfOSUu9w4o5ZRi6HZY86UwvgvoJor6fy1SQh8Qkw2K9Feefot/ct7nOOKTHs?= =?utf-8?q?5eyayz8HIF9X1QniMkxyqlJY6IHfvUHUA2N5GHwdDCAaPSBGTIJ1K9n3drZeuX4Ug?= =?utf-8?q?FIzOHyarwiKUgEH+d5gIGIQGso2meV+UclNcOsn5Sah8HakvM0Sv/JZmK879fRURb?= =?utf-8?q?EKDbP2OgyjZdrzO4nikiE4yXatUEyK47ntDRcK/81M+j0WMQm1hHvaIlacPwmiJAn?= =?utf-8?q?0RjnoYum560luUafBM88z+xNsrvHO4l6Je0OXEzcooZzFWpD6rn3NAqAAn1MkGC+U?= =?utf-8?q?IqSC21dJV3zCZW6bSnxQ1W6ovE2D/NIyRnCvEMeoQ3Db8nsb7prLhoDPfO31jcivg?= =?utf-8?q?EGSQbmpO3cpfXdxJoQVPlBAx3TDE646bhhq4wQqXROoluY3LP6b9p7KQ=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa82eb39-b14d-47bf-2fd5-08dd064cbc42 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2024 14:41:20.2970 (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: Ty/GE/nqDJ8h0fSl6AgUCQ7yhYY2iGRdWNSTO0FHJWo25HH0FlDwnJ3deqDM93ckkhreJeVGq8XhV1FEDcVZRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7265 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 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 | 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