From patchwork Wed Apr 26 20:34:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13224920 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D103CC77B60 for ; Wed, 26 Apr 2023 20:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229582AbjDZUfO (ORCPT ); Wed, 26 Apr 2023 16:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236226AbjDZUfI (ORCPT ); Wed, 26 Apr 2023 16:35:08 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2050.outbound.protection.outlook.com [40.107.7.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA480213B; Wed, 26 Apr 2023 13:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MHU19jNkW6Xp34HL+AzA40uZvz79f5TGCK2Ij146Bz9yGN3pi7rGkqG5cj2ea7wMQLJnNMTxKvtHB4e3jgIjyqHR1/hNJ201s5H0jrO89e/Up6MBHxZ90IPUT6SQrS8b/g9YqrsWi1qDKwLMVOCuu+EbkhRgMslTpV1ARHK6LDJDqmQ6ScEdS/9bSUzjvfljHwvo6THhKozJzkTH9J/jJ1fI1Cr8jErCzURJE4ptgAPdqN5D2hdnDOiCD6+FTEh/7uznEkTv1Ie8w6lNNV4AFMtkov/O1JS6yzu4VergC5a40ZPMNhBh7qUzPudPpac6e+JZBAYydTAEjZUTFvGX5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=kbOvwRQjUthcS7fAnYmsKAe1AJ9NOnZtXvjw14q7T+w=; b=KJiyd0JD+GJAwZ2P7+djD36GgjmtrrVG9OWPFeT2keZEIp5jFINgAMjzgDFR6ExCIm5qHnDi9c3KCEBQ2qcBm7Wq9swMcE+lgSuCpmTdl2mvzv+bzjQw5PbzbQCA1Oadjq0XPC243qtWUJukDUtc6V/kK1DmSZye1PlJy9eoGZXOK5q4FFs8J/5O01jq0YwoDtGnHmh+XHYwHBPz1G/WryabSz62OsZ63kVVX/uSJGXhrZCe+iU/pq57S2IldWQQwgt1zN8UkdvjosBbY/XAUhl2Y8SAhF6KEgGLpne+BcSOJh9YZtJSrTekOYrbHTNvEz7cehWuyHuL+C/B+GJN8w== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kbOvwRQjUthcS7fAnYmsKAe1AJ9NOnZtXvjw14q7T+w=; b=kxvaaBL7b4YtQuEbQiy0elcwvpj0Ogw8GGNaPbTlm6ew8eQr0z7ZssOQEdXRfb8eclAwltmcxE5WkTQbfOWV26xBVZ1ghNXbgmU/I8OaQiWWOzXKIoEpnl1cte0SedDAyOVniN9cSsqVbwNcKOh7nvtYYfTJs6pdpUcWIOzHV5Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by DB9PR04MB8477.eurprd04.prod.outlook.com (2603:10a6:10:2c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.22; Wed, 26 Apr 2023 20:35:02 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::f1d6:f05f:b8c6:4353]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::f1d6:f05f:b8c6:4353%7]) with mapi id 15.20.6340.021; Wed, 26 Apr 2023 20:35:02 +0000 From: Frank Li To: tglx@linutronix.de Cc: aisheng.dong@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, festevam@gmail.com, frank.li@nxp.com, imx@lists.linux.dev, jdmason@kudzu.us, kernel@pengutronix.de, kishon@ti.com, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, maz@kernel.org, ntb@lists.linux.dev, peng.fan@nxp.com, robh+dt@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH 1/3] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller Date: Wed, 26 Apr 2023 16:34:34 -0400 Message-Id: <20230426203436.1277307-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426203436.1277307-1-Frank.Li@nxp.com> References: <20230426203436.1277307-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0030.namprd03.prod.outlook.com (2603:10b6:a03:33a::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DB9PR04MB8477:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cce41bb-81f3-4db1-13b6-08db4695b5ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AZfG622uZUYh7GIYSsiACYIwzZiw5n4ylK50xOvUpor0U8R1ShcwMil8Vh/BL4iq2/TQWqm9ufNbxtM+5DKb8ePXY7v3jTx0JwjLK0rIckhlX+E6l3E7HqCoOCV5XK9Dgl/pcKm6JSyTRtk916w6jm37wEynt9QvMLgfR++QEFKgBrfLf8vNdipNwBVWo9gq275DvYIL57UzwbhyK2S1wPLY8hOhJyinXeI2MydqmJnnQ1bijoPgK3K649EwTKcEXcJz++syjoxJ+1yBJfdbgK/Wh9awLoNuqOd5u1VMZhV6bb9HK5kL2R3oTqXCtph/OHjAT62k1/DdmF2j6KkjP1cVLVGvVOztsjQIKZWCL6Ht2JqOrEJJhrcfRyCBRvbP6ET7kCsCm7WECXi9OhNbIuMfcL+vXzOykxetQ36TtyxfBJYL2Jo80st8UvOfyYF2+1JOnuqQcnV/csRxbAyVx6jajRrY25KTgiWw8YSJBHGqGHhqLzfTgy8c2Z/0oaKE/eHzRID195uj286Gu6Es1lm32KLIcw8A1JnFZPDjcBmyx+3fYSpbF8EZUVsHX3p9vSauUW4KzWyUUnk0N+jwOK2GcP5Lb5My6MSj8QPcdCVMmWgoahSkjWczsAl64Mpb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(376002)(39860400002)(136003)(346002)(396003)(451199021)(38350700002)(38100700002)(26005)(1076003)(6506007)(6512007)(186003)(2616005)(83380400001)(7416002)(2906002)(8676002)(8936002)(5660300002)(36756003)(86362001)(6666004)(478600001)(52116002)(6486002)(66476007)(66556008)(66946007)(41300700001)(4326008)(6916009)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IYwq8pj/UaQUBJE4AnF8MO5r3SqeDCThbP55L+gL9YtLZHfnGRCWKFkxHkJZXH1VfoAIRC2LNdmoG+Xi79KrOLHMwJHsuKMnvbnNrKBfAdtNMYfhYScSrGF6g7i2j4DrzQvva5sVUApY7aW7pAFM27M+L9mKgenSlgwfHJeCjpcj5qrnc9ZEOXDa13tpVzpZX95cc/mka8r/qoEz1xpIIvtDTlTqki/oNYYkMazOFVeZLppFEHflnaFt7AScq3JvSrDhIkEHxaD3pcPkr13v+fPv/7PGuMTsDwapokOq2A0DxK2AdxQVdPA2CDdZVnw9br20ci9ZKDLQZcZ2l+8PQc4WCQWG4WNxpG20TOFF3k175KKxnOgkkR6lbRkfIamMp9UXbDEqsB32gP/JB+6uil+dnBGb1hWUnpzKT7SHzkKqFdk/4biGHXomoKEbi9pFZI76b+EKbNslX1TPJ5lN91GUv9KvyvEpKOnno/nuhPYy3xDtarVQEoAKqdIhSxSMUJ4JOLUgn0PLS/IGzdTt12CV7fj1iu+duVz95LkpMI4pNyngIptY1ALQANlYcSarLlSImq0HPQgegkPFxeU3qNTqrujGsLjK7xFQbHq/aUqjsc5UYHCyu02/d9tsgIBCGFCVsvVkeHfkV8R3zTzWUwV9PXULhHM0Px9wAz91HWpyI+8JZjVz0DUfrJy8VfRTvs8oPjHF1WRqopt8MSsLmch/4dYkF3XUU30dnSxZvjnshJT5HbYLUw3HYjs/blA7BFbVrP/g8Mb7ZwVKobEnKQGIgt0vAzNiXDK31RzyuBIs2XkYkEJdmOlse3KqdZb7CgZffxPs0xRH7on/RgRRwR+nf0jlMFl9svOX0Y6D9mWWy836M6QrwMVB2Khq4/yUTJrBUHBo6ol2//UTaKg7G3O1k+h0UeunoINXcDdaMpTmm5z3Z4xOSsEmH4ki/9P2Egnyz9/Pvupte5G1YRg1vE9cANqeQLVYZOhZI17LI0fthyry9NOVWrG9mBKaR+p8RIJZCMNLcbAMAaNgRt8z/iQRU6HkSBbrQp8Hod99xUCRnpGtLfk0ck4I6lfHK78OADiQHQdW45T1BfUfBqTTuKumidwSu7xiTcx7D/7FQ4/Xtr2vEZn22lnSmkMPjnJE2ajV9e4gD8KBVFTNFmMKds+mNoFkc5Yn3uYDky0RdDgOp+wq3coO96XU9omnVN/2xjRSv2BRKt2nMBAnMQxM6gcwgZA1QDLAjg0Hk0OZfSeuL2hC9v0vQtqfCjL2keY/9E4T9mOvKEmYYmDGCnYPKQUuBOw6sAs51f6+uFduTFA4jQwxjwxYMborqXKTLuroB6Eeb7NuJNHVfDI1pkVbCwl+KktMwb8sQhUaeT/+/6omckRher1iaDgYEMH2zh0ZLDK6kq/DU0DZLc0hGi+k9i7RuEg3sYEs8waxguJAkUOtTb2q197PEsIAqOhDp449BQbiLI1ppElDRge2f1Y7+ka1zQWa0D6J5aHpixfkUfIxRrUqd9POQQUcRrugyqIeRIpeEX/WMMCgkxIOZVBG2iTUiMf5ei6qD8oqtKzvzDRySIh99y3ZoZIkPMvFsyq0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cce41bb-81f3-4db1-13b6-08db4695b5ff X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 20:35:02.2523 (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: N3hDsVvmL0HexsKzXR1EZVQdZESu62Iu1u65PdTA53F/elAhLbbs+SrGXCPgFmEMpxaOl7pcSt65g+m4ZboLSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8477 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This commit introduces a common method for sending messages from the Root Complex (RC) to the Endpoint (EP) by utilizing the platform MSI interrupt controller, such as ARM GIC, as an EP doorbell. Maps the memory assigned for the BAR region by the PCI host to the message address of the platform MSI interrupt controller in the PCI EP. As a result, when the PCI RC writes to the BAR region, it triggers an IRQ at the EP. This implementation serves as a common method for all endpoint function drivers. However, it currently supports only one EP physical function due to limitations in ARM MSI/IMS readiness. Signed-off-by: Frank Li --- drivers/pci/endpoint/pci-epf-core.c | 109 ++++++++++++++++++++++++++++ include/linux/pci-epf.h | 16 ++++ 2 files changed, 125 insertions(+) diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 355a6f56fcea..94ac82bf84c5 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -6,10 +6,12 @@ * Author: Kishon Vijay Abraham I */ +#include #include #include #include #include +#include #include #include @@ -300,6 +302,113 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar, } EXPORT_SYMBOL_GPL(pci_epf_alloc_space); +static enum irqreturn pci_epf_interrupt_handler(int irq, void *data) +{ + struct pci_epf *epf = data; + + if (epf->event_ops && epf->event_ops->doorbell) + epf->event_ops->doorbell(epf, irq - epf->virq_base); + + return IRQ_HANDLED; +} + +static void pci_epf_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) +{ + struct pci_epc *epc = container_of(desc->dev, struct pci_epc, dev); + struct pci_epf *epf; + + /* Todo: Need check correct epf if multi epf supported */ + list_for_each_entry(epf, &epc->pci_epf, list) { + if (epf->msg && desc->msi_index < epf->num_msgs) + epf->msg[desc->msi_index] = *msg; + } +} + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_msgs) +{ + struct irq_domain *domain; + struct pci_epc *epc; + struct device *dev; + int virq; + int ret; + int i; + + epc = epf->epc; + dev = &epc->dev; + + /* + * Current only support 1 function. + * PCI IMS(interrupt message store) ARM support have not been + * ready yet. + */ + if (epc->function_num_map != 1) + return -EOPNOTSUPP; + + domain = dev_get_msi_domain(dev->parent); + if (!domain) + return -EOPNOTSUPP; + dev_set_msi_domain(dev, domain); + + /* use parent of_node to get device id information */ + dev->of_node = dev->parent->of_node; + + epf->msg = kcalloc(num_msgs, sizeof(struct msi_msg), GFP_KERNEL); + if (!epf->msg) + return -ENOMEM; + + epf->num_msgs = num_msgs; + + ret = platform_msi_domain_alloc_irqs(dev, num_msgs, pci_epf_write_msi_msg); + if (ret) { + dev_err(dev, "Can't allocate MSI from system MSI controller\n"); + goto err_mem; + } + + for (i = 0; i < num_msgs; i++) { + virq = msi_get_virq(dev, i); + if (i == 0) + epf->virq_base = virq; + + ret = request_irq(virq, pci_epf_interrupt_handler, 0, + "pci-epf-doorbell", epf); + + if (ret) { + dev_err(dev, "Failure request doorbell IRQ\n"); + goto err_irq; + } + } + + epf->num_msgs = num_msgs; + return ret; + +err_irq: + platform_msi_domain_free_irqs(dev); +err_mem: + kfree(epf->msg); + epf->msg = NULL; + epf->num_msgs = 0; + + return ret; +} +EXPORT_SYMBOL_GPL(pci_epf_alloc_doorbell); + +void pci_epf_free_doorbell(struct pci_epf *epf) +{ + struct pci_epc *epc; + int i; + + epc = epf->epc; + + for (i = 0; i < epf->num_msgs; i++) + free_irq(epf->virq_base + i, epf); + + platform_msi_domain_free_irqs(&epc->dev); + kfree(epf->msg); + epf->msg = NULL; + epf->num_msgs = 0; +} +EXPORT_SYMBOL_GPL(pci_epf_free_doorbell); + static void pci_epf_remove_cfs(struct pci_epf_driver *driver) { struct config_group *group, *tmp; diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index b8441db2fa52..e187e3ee48d2 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -75,6 +75,7 @@ struct pci_epf_ops { struct pci_epc_event_ops { int (*core_init)(struct pci_epf *epf); int (*link_up)(struct pci_epf *epf); + int (*doorbell)(struct pci_epf *epf, int index); }; /** @@ -173,6 +174,9 @@ struct pci_epf { unsigned long vfunction_num_map; struct list_head pci_vepf; const struct pci_epc_event_ops *event_ops; + struct msi_msg *msg; + u16 num_msgs; + int virq_base; }; /** @@ -216,4 +220,16 @@ int pci_epf_bind(struct pci_epf *epf); void pci_epf_unbind(struct pci_epf *epf); int pci_epf_add_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf); void pci_epf_remove_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf); +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 nums); +void pci_epf_free_doorbell(struct pci_epf *epf); + +static inline struct msi_msg *epf_get_msg(struct pci_epf *epf) +{ + return epf->msg; +} + +static inline u16 epf_get_msg_num(struct pci_epf *epf) +{ + return epf->num_msgs; +} #endif /* __LINUX_PCI_EPF_H */ From patchwork Wed Apr 26 20:34:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13224921 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACCFAC7EE23 for ; Wed, 26 Apr 2023 20:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239427AbjDZUfQ (ORCPT ); Wed, 26 Apr 2023 16:35:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239315AbjDZUfO (ORCPT ); Wed, 26 Apr 2023 16:35:14 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08EAE2D49; Wed, 26 Apr 2023 13:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GdH8WJTOIxTxH5fnHFcD8xvTTwN8MrGC2o4PO+Pu2quBcqPFodaUrHfWtL9EgdRacw0zUonc4gf4QMHJkowxE5iqSd5TeuYq8mkuQAqGc3SGC72rK5TPB6I8LIohF1eI1kAudoDJgKd5/YCu66kO4PRCGsgBAXZARDLzHsW2Lu69Vz3s3KGmmVgAdZobDHwGGFpkpgOwVGSPDcDuaWc6I3Rcq3Zqk0Oq+XJDF3l/WRAqxSxQKMrhsj+f1qyaAAzOrBxwi6kYfd4WpeTf4Fm6eHete5VTq2imgypFV/P7y6Lh6qlFy73ZeqxZ+hxTwubAFAdkm6W5TDMIjUgIZO2GwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=PHKcp4gjYuw06RQS2IYRVT6NPTbhBlaTn2UgMBi694g=; b=RqraUFcH88cinyRqz5h32wwTzzHSNSg2stea2IPq17WXq/kDWJjdPW71TkU4nymdilNGsPStBMNI8yx22WLABvIHr2x1ZoiEeezn76I0wEa09oPHPVfWj155a+Oe0A4Y5W3IWEbXxMkdJhgwUaroTxS2FppQ15OhAgLHqpVhbMFOIwU6KD1ziAI6eadEuIKM3RLsYovfaB5oD3Gz43Gvhdy3nqM9WdjxjTkVev3q8J6TmHSWFJndgJTSDf2FBjgxWS9/+oMbt43iL+XVLuO1ocf55dNp/yMVEv4d7dfKxHYKD6clWA3w+kYpJal1E2UAmGBZxp1X58UPuvs2t1rcsA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PHKcp4gjYuw06RQS2IYRVT6NPTbhBlaTn2UgMBi694g=; b=mCI+Y/nptCDBD3eys4wJKpif2+KwhdF/Ch1S7AapeNrI0JzkeaCu3s7bMRWgARXIxaX2PLOipqZ29bBd5DfXl4DVxwsnFodSqg3Y9t7gYFRNpBKFZN7bXYe/l4gXtMYYDSKoiHv4Z2CKpFFw3rFzibc2rtluJr/sJa2/snSFejk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by DB9PR04MB8477.eurprd04.prod.outlook.com (2603:10a6:10:2c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.22; Wed, 26 Apr 2023 20:35:07 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::f1d6:f05f:b8c6:4353]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::f1d6:f05f:b8c6:4353%7]) with mapi id 15.20.6340.021; Wed, 26 Apr 2023 20:35:07 +0000 From: Frank Li To: tglx@linutronix.de Cc: aisheng.dong@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, festevam@gmail.com, frank.li@nxp.com, imx@lists.linux.dev, jdmason@kudzu.us, kernel@pengutronix.de, kishon@ti.com, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, maz@kernel.org, ntb@lists.linux.dev, peng.fan@nxp.com, robh+dt@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH 2/3] misc: pci_endpoint_test: Add doorbell test case Date: Wed, 26 Apr 2023 16:34:35 -0400 Message-Id: <20230426203436.1277307-3-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426203436.1277307-1-Frank.Li@nxp.com> References: <20230426203436.1277307-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0030.namprd03.prod.outlook.com (2603:10b6:a03:33a::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DB9PR04MB8477:EE_ X-MS-Office365-Filtering-Correlation-Id: e9f7863d-1886-4211-b475-08db4695b95b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LhMvvkmLDZfH5CHwTzwB0bpkWJMELY+MjSlRcBPxOHToz6O2hzlGeOKwL5JD7HFQnCKnDvSNpGje/cyd8KZKR5Jnn5+rV4SpUtEX6uMQkxWAUtqHdMSPvJvviYUEeLfebkwmO65uaVR3bRB9K0XfmFdHSmZXOFoDUK1UEFtOmjCs9guqHMn/euu4cDC3YHrbiJOh+huCKWKzS9TvxzLox0y8jk9Swh5UmXKfJsYp0JfPS3HjFRA34EgFoQkh+y5F1rE0rv+RVxZG/s7QfPVEah6At7yhW0Ie2bnNBNF2QU+OTqGbAjcRvE3pczt14zrJhDt13WftEJxdaIlabCDmVhsSAFmCzCAnb+wS6fy/qg+9Bm7mIzFOAHWA3CJ1eCafO36FuZiAY/HfD8TIKN9NPcxjqUZ2q9PLSHXEYd9WtdoJqK9HDLI8HkgSwNp+7J3hMPYrLdFHgZHclqFAKWVtHZhbsIZVCp1aEt+3rN1aYrVCuq/kNfOhuHsCPkaql5iOKq46lPCQqjceECHkFRfirbsvH0PiUuyP0D47s5vV8dBywp8zPNpCmBXGZVg5BHbLIYonaOjfu+Wy7kE/NWGMaBwib5OmnQiuNaKiyGsnbp2bkI/KxfdJ2seJ+Q8eC4V4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(376002)(39860400002)(136003)(346002)(396003)(451199021)(38350700002)(38100700002)(26005)(1076003)(6506007)(6512007)(186003)(2616005)(7416002)(2906002)(8676002)(8936002)(5660300002)(36756003)(86362001)(6666004)(478600001)(52116002)(6486002)(66476007)(66556008)(66946007)(41300700001)(4326008)(6916009)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GyNNU/YRh59MPiyDJnRG9pmg3ajK3gYoh8ku8vyo/tU9gwlGrwRe+xGoqE+6IV0AejuRNqRw/b75gzD7szGn23HPsDAn5l+aRWX10Ymtl9oTm3JBjUgjxG4zWMIn1rd5jJNAldjnkecsiOLykQWIrIyUZoj8PV3bJx7w6/JJHVYSUeF+u6FvNEhwKGvvFhLsoqCQlT9wk128U2bFrpuC1vNi3CGqZisiSCud+bVELpjN3OSXTH69cCzsqHfqO6YYdEZT2laH6mFa79Cj6ESpFVtO2Qq1blh732QUfqlSOEeIyTB2lbQ/xspgR1YDjL/Pxwvf5n0wzoTGolzZjgHOBNFy3zagKeKqsZ1gaDVklMOO3Mq5KQVxEmFQf0enDEL3esCmRC8jl5rSY56+/+cKNln8+k9ugih8tH9au1C1+AmmewyOX/vVjMPYHoVa+DzhddNNe7aPxKnp7kvcvYkOnZI0fR4ekfnHNc7a5nLbN5IR8hzqFbu6QHSRmQuazrWDLHaygaH4sUNYSWXvn4vYUPE8syOTOJJoFYOExFynGqp1viRFF5xKayFJ/FSi0OrtT28UYHywvM6xQ2agBcAw6y26g4dzc82e5GwN+PkmJdREdWxX8qpm9FIX0BkvGcTh29qAxaL4X2Loy74it9d8KfSJKZsgWqAA6armjjeCW5LCuhKU3OhVOAqgVEvTGUIM/FgBPvCOMz8Tst4dk64RosNZ4cCEiiQvzXrealS7v5h57WLwxf5NjR+WRNDLfEW8GlFb8IDFXRuTdPAVtosLFV7tXDWAms2qwb4geZXRTgZLw9RwqA83/1+FhNJONDm0UgSSFLQliKb+2cAWjpgkQW4uZQ8M6BXBNLQbECEhwMvtThg5NyKX2HNm9vXJYzIDo+ipHWJuNAfMtbHHXsy9VGzC7dABzZBGYDDr2UgdWLbIisR6v/7oC4PK0G8ljHrnLNUhh5Xk1RDIPcAD3PLbxhzIsLmyKjlyyZyMZzg+wLUpWFXlaQ9P70qMwsp+i4RT4FLVRNSPdudtSn/qnRT+TgXkmf8HpvJg2qHudTt1lmKH14V5H4TAxSz+AKGW08YQbaZ70GVtrUj+Lw5xrHhcGoZugxjuJlNQKF+sx6W9fmGr3D7qbF7XbZKTj5kO7rK8yAg/w2Q4l5eJPj5eEzTTPRmg8OtZNZZWUtG1oXV8erevtlfP6UkmtFb33/+ZBHAYBDonSLFxJwqMUGjyyb8QSWws1J2Ah/ss8ESMwFCBQPCP5awNa0T7KLpex2EKw6AtKCBO4ZBjjKCHkQLN2buyhPL2rkmVivm8sJQG6vp2tPVB29aDAlzp7uP0MTARHu5I+ezsnsUn14PnksM/AUfNZWnqI/bH9nogO+4JI8/hl2IhjYsXsQ60QRvj4pEBhilLyfm6PUAzUZEHgNFtily34H6fFeJSk4nYnPsDNedVUKvceOf37+JWelzzSyXfim9r68P6/kike19H0NhXSjgIehTohNP8HBdSZHRBBfkzTHcrrDqbPDvhXWLIG1DyLH3xJluuBp9CsIGG1R5QrUoMy4PI9D/ALifitwbiS7fuyVgmcYXyS2kHmQwBJJggyS49 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9f7863d-1886-4211-b475-08db4695b95b X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 20:35:07.8665 (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: wy36NECQqfgmfmNtzQZnNstNmxK1qJr4KRYx4O8vJfRC4hBNvsSME52vT+NwIkjmHT58F8UaCRFBzgr9uvv1jA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8477 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Reused flags as capability register in pci_endpoint_test struct to support older driver versions. Save capability flags to 'cap' field of struct pci_endpoint_test to prevent reading non-existent address. Add three registers: PCIE_ENDPOINT_TEST_DB_BAR, PCIE_ENDPOINT_TEST_DB_ADDR, PCIE_ENDPOINT_TEST_DB_DATA. Write data from PCI_ENDPOINT_TEST_DB_DATA to address from PCI_ENDPOINT_TEST_DB_ADDR to trigger doorbell and wait for remote endpoint feedback. Signed-off-by: Frank Li --- drivers/misc/pci_endpoint_test.c | 41 ++++++++++++++++++++++++++++++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 42 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index ed4d0ef5e5c3..3320a3334594 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -52,6 +52,7 @@ #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 PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 @@ -66,7 +67,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 @@ -102,6 +108,7 @@ enum pci_barno { BAR_3, BAR_4, BAR_5, + NO_BAR = -1, }; struct pci_endpoint_test { @@ -118,6 +125,7 @@ struct pci_endpoint_test { enum pci_barno test_reg_bar; size_t alignment; const char *name; + u32 cap; }; struct pci_endpoint_test_data { @@ -713,6 +721,35 @@ 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; + u32 addr; + + if (!(test->cap & FLAG_SUPPORT_DOORBELL)) + return false; + + bar = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); + if (bar == NO_BAR) + 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_STATUS, 0); + pci_endpoint_test_bar_writel(test, bar, addr, data); + + wait_for_completion(&test->irq_raised); + + data = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + if (data & STATUS_DOORBELL_SUCCESS) + return true; + + return false; +} + static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -760,6 +797,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: @@ -887,6 +927,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, misc_device->parent = &pdev->dev; misc_device->fops = &pci_endpoint_test_fops; + test->cap = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_FLAGS); err = misc_register(misc_device); if (err) { dev_err(dev, "Failed to register device\n"); diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h index f9c1af8d141b..479ca1aa3ae0 100644 --- a/include/uapi/linux/pcitest.h +++ b/include/uapi/linux/pcitest.h @@ -20,6 +20,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 From patchwork Wed Apr 26 20:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13224922 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1E40C7618E for ; Wed, 26 Apr 2023 20:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239833AbjDZUfZ (ORCPT ); Wed, 26 Apr 2023 16:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233605AbjDZUfS (ORCPT ); Wed, 26 Apr 2023 16:35:18 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2072.outbound.protection.outlook.com [40.107.7.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DBED2D50; Wed, 26 Apr 2023 13:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fs+7J5Kb44Uhz+qiW/Gm6qs18d4sfq0pZxiaV8HhD5u9qKMUnHJQQD1yui2yBw8/zcj1b9kr6GiWuG1yivBgX617enjNtN6yQKdhUAlV9oFk8DkFF8A4LHu0abhSxBiy/j4JR+aWsvVLljTLj+8M9NsRj3zzyrJ4obLZ0fdAUZBpcA7Vuhv5tSlyvZRFP4upndHPApeoFtC5Q13t6w4vo760ytJ212UlMnvxbcmi8VN4ycptdnjYZoM+lloaKtFzcurUfYaUbJZFDI8XRDDUgpOM7Tg55uzCU2kb/9IWZMjs4xjk8TfphDz6pMQcxs02U9JLpb8ZjHvvBJ+79DdNRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=WaE2Ex2VKSgfAjwB4pUsyhsi/QdPYSTdNzNyt3Ez1a4=; b=oJ/zcI5AUJT721JJv+CCkmAdC/3oWS/PJAH4DjGNSTbtbetOEFeBsX+PAq1iClc7xrAl3E/Nk+KuKy6RSo7tQ4QsyR0LZr4sacI52GaxSXgRdn/uTpD3l0I5LmGRwZPqhd8t/CmKbebJitaZNWr6ggvP8rDZOCRAdbX1ZvKIjUiIpxuCG04iQvJciAfcAdakVEaeEnOde7rKMFdPD9Pq4njGlW3K1+/WdqRQjNZNnQBTPwolGXbdkLQRd+zgAsYCmyeJgfVqqmTbGNfSSj24dCSUwPZ7JVuocHII2XIqa60lh8LMm2uagTdRiAOOx5mKhCUmIUr01DH71v5VZESGQA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WaE2Ex2VKSgfAjwB4pUsyhsi/QdPYSTdNzNyt3Ez1a4=; b=Soqk3zJaNDjIw9iGHJqE1W4Bx/fwJtbur1UnM72Blhmyqo7crGmacZVER7nfqb5IJH6yBeU7nBVO2Wv9TeqlugsCcf4m4WvwfOXu0shTr/Qi5D0kVUnUH+7Y9fc/4heqPrHO2E5kxRX8NfkuiM1xAzVRCJwTNyA3j43H2nMhs1Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by DB9PR04MB8477.eurprd04.prod.outlook.com (2603:10a6:10:2c3::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.22; Wed, 26 Apr 2023 20:35:13 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::f1d6:f05f:b8c6:4353]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::f1d6:f05f:b8c6:4353%7]) with mapi id 15.20.6340.021; Wed, 26 Apr 2023 20:35:13 +0000 From: Frank Li To: tglx@linutronix.de Cc: aisheng.dong@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, festevam@gmail.com, frank.li@nxp.com, imx@lists.linux.dev, jdmason@kudzu.us, kernel@pengutronix.de, kishon@ti.com, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lorenzo.pieralisi@arm.com, lpieralisi@kernel.org, manivannan.sadhasivam@linaro.org, maz@kernel.org, ntb@lists.linux.dev, peng.fan@nxp.com, robh+dt@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: [PATCH 3/3] tools: PCI: Add 'B' option for test doorbell Date: Wed, 26 Apr 2023 16:34:36 -0400 Message-Id: <20230426203436.1277307-4-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426203436.1277307-1-Frank.Li@nxp.com> References: <20230426203436.1277307-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0030.namprd03.prod.outlook.com (2603:10b6:a03:33a::35) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DB9PR04MB8477:EE_ X-MS-Office365-Filtering-Correlation-Id: 19d486c8-1c2c-4651-909e-08db4695bcb3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9/habAi+fH6Lzn3sfaKBp8UYc7iUTE2hpiZJ1KgupRnanWCM4ywZA+Ad2MDg30EwvvcMabduwooDXgRNQKByJd4BPds7LM+fqpumchjdN7E+kaF9cU8f7Sh+6Zwvd747hlE6xZkkvO//jkd3PFBKsK/UIB2TP6UK/GEtTgA+QD2TzKSUJNhHF5RK1UpJmOls5+fXDQ9U2KcdSqyOjJSlov0JSmiQQinDuqeFAyj0S2rTVVhJR5edQCjMQxNb7mSwTUnAF9UOYhRgbKdp0P4Y3LenkA5Vh6RiW5rEWFIpry/47JQUR9i5v9EjOyFX84edYttg4zHRfeEb2z6lugjBV347nceo2oxp/jNrBiPjYuCqzS41fKA2L2LPKusJVaqTpbmYyg9epn8l4tE22XFgzUdTXXMk6PCvVH3aFY/wLUApQf//CuhFo2y+EnuaRrzGEbRh2AKOQlSQXBPSiMjdjUdfY0J/jo2wrZ2YoazxV7NuwNmth24jPjkEKJ7o82YXAi6V04NQEpPkWHKZF4onqly+CChtSt6s1++5dNvAaOpsUCgKKC3eaYNuRilMLjncyJEi7bDuLz/Ge7ldajnZAq/cnZ4RFMD55J2Grh5ZPauz/mqjjdZdSE8DlSx3CnQg X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(376002)(39860400002)(136003)(346002)(396003)(451199021)(38350700002)(38100700002)(26005)(1076003)(6506007)(6512007)(186003)(2616005)(83380400001)(7416002)(2906002)(8676002)(8936002)(5660300002)(36756003)(86362001)(6666004)(478600001)(52116002)(6486002)(66476007)(66556008)(66946007)(41300700001)(4326008)(6916009)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: egIBqi/tNXjM9Zwu0Z+3441uxuCLUeqMKqlAkfnVdoPGeEmUJPGrRzdSryfLoOoFCjYfaTh8z8mFpMX+wFzmSuPpF+Aai1v6vWT0iSro1qXAvBfBZvfujBwM8BxiwaNxhVAkg+nqwWbUft02VcaxFk2Z/2CMkskehh5Ck42ohUGfhujrQmXUYDy2HZG0bc/qf41XEU4BdRebAfY/QK8KoJK+ENL0RiB/I4Kf5mLoWPx1rKPslZsqr4VHcAcbnleAEuBxPTo84G/1fTcp9mYi4rcDLpgN8g7Kutb2Vn+jE4MYvqsoKHKTEyv3+8IiKAOgqShPFTlx2fiDGOrZURLQrsPmvBjYukynaBMeJNhRiIaNnEY24kcSUzG5EfomDCbYEM+8GRcy9090v0P4O1c4Cj0RJxXw1YHGh/pJvdeMK4UOdNwn3BxTkIvTkxlYXGPMJRzMDLiOIn7yCdfRD2p1ldQjFu2zSRBazUEA+rqMwaKsJi00NNijXboeYX3oJhczSF+FYK/EgGw6PQhWx5bCk4dIKSH4/kd3BEeaDAL9/36+O/d3zg36V60Pg138WEFfVRqW8VR+/ZioX/Y7qKYJjVPbJ2j2MsHFnvNxWMNiO5GrmxXQDNtUK9d8YNj8sluBJNv7ONL/Wn6ixlKSfxsGe/FZwhclzkI7pC/gp0oBVam+aJQD3jM9WEdxNMRATvnwkAHBpexRWY5n+bAUYLSuBK8krmVAJtqHqSUZLLB6gf0mMUikbWUX7lISZxTan32IATKUlwA/TvSvjrajw7KyE34DqM0Vgoe3y1oPwecvDF4I+fwl7Q+y2pRnKYi0JzMlubNJyHicNgpuTjs+wFIq4n3bqmb5xIcF8KouC8m21vT26Mm2JGCcEzXMcBZ4JJLbFkrphGohJ9czNus8jVhAYu1S0VsGlogngamqIQZ8Etx+V+gOFfoUxqdkLUikkGv76hypOpG1hNnMqbJ2cReG+nsOQjpD3kWsid8O1A7IfN2XwYzJaeCY9oBxBxaYTCnIUwzfO/4rGMEqUGM1msB38ke6/O5po39tNKefzmgDvmb6Z7nM7x4zy3+W64eS13m9lK+ZBlRN1h9lHOp0fB1rKUSxN9ebix3XVCcH5PEgbQ0xU+DnIMZ11lkkMW6QmkJA726h0sSlxH4GFZwnbxsqq6X7MsWZ8K/S5V12avLFrZpGIAn2dKfchAE1Pvx0m0GNuujUglCIVd88GMqBn9MBi2tS4ZTbuhBco6K+GiL7I5N5ztJNtFll4+gDq1L6TETe6hw3uBISpuLy6g8C8aj/M2eIe/Xvko4uNm5zjfSkuwKD2bf+p2vaESu0b++tCB7JFTJn68HKo6dhekQhuZRNZIBz90o45GQvQfbZntq3f8vqkzQ3E5RCtCNPU8zo2hu/hMLCkyVYQez1IYEbsuPgiDAHc7dvWgLbSh8NSpRUoRQONhGYhw7tHzZGtXbaMZec1oXmkbrR7M7NyL3YeJKPHo0diJs4AtR9PTHqBrqIHB4hjq6Q1kWR8FKbondFOW2w+/cvkgeEZUlii5pl4YMdpti3oYxlVxXwix3TPpATTID0uxTyP+kexn6idmaBgsxz X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 19d486c8-1c2c-4651-909e-08db4695bcb3 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2023 20:35:13.5012 (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: L6rZM48/2wcxri8eJi403q8kKpHKRQ4JmI1XF0MFsQC+CTPmmT2ZZ1V03HTYZffx5AT5Rumx2m4wgTkAEYs2cA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8477 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add doorbell test support. Signed-off-by: Frank Li --- tools/pci/pcitest.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index 441b54234635..215d0aa8a09f 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -36,6 +36,7 @@ struct pci_test { bool copy; unsigned long size; bool use_dma; + bool doorbell; }; static int run_test(struct pci_test *test) @@ -149,6 +150,15 @@ static int run_test(struct pci_test *test) fprintf(stdout, "%s\n", result[ret]); } + if (test->doorbell) { + ret = ioctl(fd, PCITEST_DOORBELL, 0); + fprintf(stdout, "Push doorbell\t\t"); + if (ret < 0) + fprintf(stdout, "TEST FAILED\n"); + else + fprintf(stdout, "%s\n", result[ret]); + } + fflush(stdout); close(fd); return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */ @@ -174,7 +184,7 @@ int main(int argc, char **argv) /* set default endpoint device */ test->device = "/dev/pci-endpoint-test.0"; - while ((c = getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) != EOF) + while ((c = getopt(argc, argv, "D:b:m:x:i:BdeIlhrwcs:")) != EOF) switch (c) { case 'D': test->device = optarg; @@ -224,6 +234,9 @@ int main(int argc, char **argv) case 'd': test->use_dma = true; continue; + case 'B': + test->doorbell = true; + continue; case 'h': default: usage: @@ -243,6 +256,7 @@ int main(int argc, char **argv) "\t-w Write buffer test\n" "\t-c Copy buffer test\n" "\t-s Size of buffer {default: 100KB}\n" + "\t-B Doorbell test\n" "\t-h Print this help message\n", argv[0]); return -EINVAL;