From patchwork Wed Jul 20 21:30:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 12924532 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE411C43334 for ; Wed, 20 Jul 2022 21:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oU+c0u4ual5Z025vqi6chLwS6tUAmZomku003BwwmII=; b=yB4VBmDQmxqOAu nEH4GdvWLjpts858Owvxqk4rAauo2ilyDl19c7JEkMoLI9aNNJT1zaypYzzVjRzAr5hzavrB4fs2i Mz3mesm2pXb63kFoaGq4PC4BMQG3eQJ03Gv0Xoul61TSszcOgjjnzYGkiUzyuhrEJ6VVEVwyle+MZ rAfOfYxSSbngXgZtKS+aLFAT3k05NP3BR/t7wL26EFdvyuO31eiJ7+SOsDS9T1f1du0jO6bL5MIxD 5qJyVCSwKtLpZMhQVzotGQD8zRdUSCPgSoFY8qZcLU6kG7eC3sM0yzUs8drvHMsYevEd13g6O3UZo jzA+Mj2wKx0sYBY2PcWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHIS-00BVAw-Om; Wed, 20 Jul 2022 21:31:57 +0000 Received: from mail-eopbgr130081.outbound.protection.outlook.com ([40.107.13.81] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEHHs-00BULX-Tz for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 21:31:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cabb3J4IT6Vr6cg0mPtQjUFurOPXWKWAxuL6KOqkW3k9FMeE8TOo6wAujMMaPCBgDX//7HofKdFSuwDzBF6a0y4AR+Xljw6lBokH/wx0MWLH2zHw1e2tEmMOWR3R7xXbMV+9uL6oW4t/klP6A9UJNcRxOzJ9FDUvDP69OsCPrbHEvA/UY9S1eo5Uh63JOK8R8xT5m5JIpKx5jvKkSzdvvatI8xE+i1ozH7RihkHBbbxhl8R9WvNHoMQQuGePpUhp8k1+5nFHofYONHQAVznj9rf51rOS83JZB91bBeNDA1R8LbuMtouC62YnIntCRxepCNnCXCP8xUKj5AOsY5cYUw== 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=1hJeUUxqEQAHaeavRRaTbNVbuGmClsA5qDf+Wpd5vng=; b=Rm82Pbbm4zb6WRLe7dszfOVrcePrlGLCc+dN3wpABItvleHWElQB6x2dbJaQYTzVcd/4sFvGM66PBavDaUSpYeYf7Pjw8QuNhtf9E16uhVxJHE0ZebEzgQTW5Ltm0DqBEqY/osF/oyvwIBIGhwjrOldpWFVWHA/6kimZ7RahQtphR5o1cMExLoPGqQkk+rMSp+noiLlQAKd24NHUh8L+AebQvN7htAIo0e8ohe6yXDBHD170iErGvfpYyJa+JifOPwg/VVjrBzQf8Zq4eev8ob2S4IT9dEefXzUe2pmaMBE7yDSTJz/qMjlfpoxMyXJcQT7cw2IAa2/avFHZG5ri6A== 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=1hJeUUxqEQAHaeavRRaTbNVbuGmClsA5qDf+Wpd5vng=; b=c0rtKHqm/nKxtfzTqWyWMrgQmvNscz2XOOxwWchyzA76Zq1gL5/fVIyI1bXRDYcFltSX08ESreDfkddaTZuKTxO/d5XO6MZZB/1C3i0DwQYf/VyuqdkNwYaOAr7hEa/d0kv6JJwau17dpc8v0pNZTLYErkRb0oX2gMFsVKoc2MQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) by AS1PR04MB9479.eurprd04.prod.outlook.com (2603:10a6:20b:4d7::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.24; Wed, 20 Jul 2022 21:31:18 +0000 Received: from PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab]) by PAXPR04MB9186.eurprd04.prod.outlook.com ([fe80::54aa:b7cb:a13c:66ab%9]) with mapi id 15.20.5438.023; Wed, 20 Jul 2022 21:31:18 +0000 From: Frank Li To: jdmason@kudzu.us, maz@kernel.org, tglx@linutronix.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kw@linux.com, bhelgaas@google.com Cc: kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, peng.fan@nxp.com, aisheng.dong@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, kishon@ti.com, lorenzo.pieralisi@arm.com, ntb@lists.linux.dev Subject: [PATCH v3 4/4] pcie: endpoint: pci-epf-vntb: add endpoint MSI support Date: Wed, 20 Jul 2022 16:30:36 -0500 Message-Id: <20220720213036.1738628-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220720213036.1738628-1-Frank.Li@nxp.com> References: <20220720213036.1738628-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0005.namprd10.prod.outlook.com (2603:10b6:a03:255::10) To PAXPR04MB9186.eurprd04.prod.outlook.com (2603:10a6:102:232::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6846439a-0165-4f2c-1e2a-08da6a972eb8 X-MS-TrafficTypeDiagnostic: AS1PR04MB9479:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZPMvpDGemGjD3TuBkShhE8xDZi9qUXNyhNU/kGSmYSMM7UMHOekpaCheb4gS7j6EfF2Vb91t6TDQgOnwVRYphfGDGR+0dwldY1mcHaa05ObC1cWrONPtrnLkQhsI0zk1+yypqMKHZxAOA6+pj6qMSllj69aDVDUfW7rsUPyGT+zD+Y3xrEH4CtHiIPhgETfb/nOaVvjYugxMTfHESceRDSrL700ywZy7c/GTh0M3DiZk+iujXO/DKXiUdBk2JazfQfYDzXbGd7RRMMF5utJpS8FqIoh8BJnKQwJs52qAYDOaPL7TosdVKrFlHzvTatnMmLRax/CR5dfwg+0rclwBbaiq3hm77vBw1PdvSXDVaggOZxZSk07fpUAmIqggh1m81NGcSgROUt06vL+jweeeHJVlBQEiQWmzY4sO5wMsm/UskDKVtkwLk29P3XGkPz4i+p247di69boForifbN6t9Jg33qNmlqOSJvTYX9ZhSovFdM4YHPQeG0XOQ8uHbcfGXyxy2NXW6pnoLFiQLDud7cA/SQzPC61+rbjZEQPgS0nJyn7mhNa16db/6L52cSeVrDZcpYgFFnhIKpseeZGMnE7jRdlyzUq4T633Ou40aOQWaifbUbGz93tcS4nFa12/Px6UAs72g8fyELTU4Adlgpb7cJXlgvK65E5/fexGgstmcVbifw+zbSWGSlLeSPwY9ggXSnL/CMq4LgjKYJumgEaavVc8aEWK8WiJ4c/xfCO8Uq715arHnpO5zc40hBDXOkVYc4oaHWSoGSK4uby10sw1qa6au7AfMKoAu/3eKYE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9186.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(136003)(396003)(366004)(39860400002)(4326008)(66556008)(66476007)(36756003)(83380400001)(6486002)(86362001)(8936002)(478600001)(5660300002)(316002)(7416002)(66946007)(1076003)(6666004)(6506007)(8676002)(186003)(38350700002)(41300700001)(38100700002)(52116002)(2616005)(2906002)(26005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?bbap0hkcJrjaHqLFdNK4aE+tJing?= =?utf-8?q?Bmep8zAZgtpzcyFwDu6uWj686n8AQOqKr3Mn7+TUSeC7Ns8ZtS5OLswPdsAVQxCU/?= =?utf-8?q?MCvZnbpJuj8bJGaXuEa/ER900NIKf8pkvz09p1wn/E6K8uTmvBwHpbYFv3SrtKtLI?= =?utf-8?q?ZttnAp6OnXJLesYEHHxVgCH7HoxHLC6gScwpCjIZuwsqsqbxFwSTdoFMsc2jpXkbZ?= =?utf-8?q?31nvxTkDr0IDiym8ZgEtulIwIL2tQeKBjFqh6luuwW8kvYk6WqX9+zZIvOKosk351?= =?utf-8?q?or09ijCmaQdVlOz9zQMQBOnKIpwVHaVbHlVogeDOHXplhhPFKWg92ResKoGFRZV7H?= =?utf-8?q?BOnrbrC4JImRAQbmgC6BZS6ASV76JoUZlrA2/m/UG8DKAfq4B4NTnFFYikefRe9xj?= =?utf-8?q?JvsenVQkyCj26bKMqYax9A9ionnXvtzG5sSnUjZBJXuXtzQ8ETLiDK4ZNgqLKBjf7?= =?utf-8?q?kA+6Ebz0m85HnVFLxA//4S1nvx7cniQFpYoT8wuSPOgZ/VsdoAeZtOyNMu+HKGyGC?= =?utf-8?q?iCCfXE7PXaCuX23Bj9QLG0Ug0qV1LFzbYIznSBowIw5V9SI8NNPbc1QbcSs+baNaV?= =?utf-8?q?kDWD6W3pAnrlYW7uk9cp7NgGQICHOT+bzR4fKtq+R7lfoVzTfUEWy5PyQcVrJzsGe?= =?utf-8?q?fjitHHbRech1lNu6UvxV3B7oIukajDM5f/jawR6ka4nty8Z+QgojoM6WTeYd2KrVZ?= =?utf-8?q?jgLA3F+wjD1nn9f0EfoPAQC48W4LSpx05ma4tBuRsDBTgl0xq07HbDSGD77eESd6J?= =?utf-8?q?f49kwW0fkfw+cb0NCT86Qq2yoQh5DaiMUPyGFoOGiD0wO70OAYPf+UZlnv5wl9NXu?= =?utf-8?q?Aao2tt5WEZSBDQyAoD16Uh4kKZUcttSnYMGL7dQzt1m9leRxBo7uS+rygh9TQ47ym?= =?utf-8?q?I1t1G44jnmg+MQH6t81wdi+wbwEcoU98oo68xYFRJQr/WNxOgq3I/eFpCwToXPpNP?= =?utf-8?q?eWtUVnKoy4Ir4nbXrLZnEqvJVL11eVLA/q9kbVmjt4CkCMDY72DnWOmKiI0a0mUXg?= =?utf-8?q?wwNLAW68esg3Zv90bkNQGC7andyLtCggsVmvOz0rHfWDqchXLrq6FMHrA5sIJBjjv?= =?utf-8?q?tOYVlBThfuCwbSpva9CLJxx1wg1UwWw+lM535olEul9nUPCobibrIz+aT4iPNfjrI?= =?utf-8?q?OGkb5RZR40lez1WIcCz/C+tQ0zWLWrZ9mZCQHpjWhX23utQ4u+C4k5AePCBbIErYV?= =?utf-8?q?vsotCeHk37teK5snuJDXklIrgg/UghGR+MhsLjuVjASlWoB26qX/QYUej89/ecMbJ?= =?utf-8?q?CPdI/YZxxWVIn/A/QRrQLg8T8+pqOYNHkP7e7GVCo9PJAQGAvNuQo5iOLp/I1YPRa?= =?utf-8?q?2fL4waRcxoqH7MdsrLJ2ktPr23Oj5xgRZEeTPZvP/RWrHkQDWP9o+UvsVzMUWmNt1?= =?utf-8?q?Rg3NhgiZUE8EBfp93Q7VIdgSzhh6ZXuTsx/+ktqwOXEvNsBaIfXsWzVl0nUJyYmVI?= =?utf-8?q?9K+HY8gXVWGBUyOCBVwviKHA7OWsXNI1DLH6uycqwrxMZ4nV2Ci6Stu0=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6846439a-0165-4f2c-1e2a-08da6a972eb8 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9186.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2022 21:31:18.5739 (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: MuLbAOhBAtXR0mKy44dsCrZTRd4dDm/mHdCWsApNACoDwwNghhJOVjhcQVgrlkCeg+lGR+98H/dhhsorRcCpEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9479 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_143121_006191_E0D9EDC5 X-CRM114-Status: GOOD ( 21.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ┌───────┐ ┌──────────┐ │ │ │ │ ┌─────────────┐ │ │ │ PCI Host │ │ MSI │◄┐ │ │ │ │ │ Controller │ │ │ │ │ │ └─────────────┘ └─┼───────┼──────────┼─BAR0 │ │ PCI │ │ BAR1 │ │ Func │ │ BAR2 │ │ │ │ BAR3 │ │ │ │ BAR4 │ │ ├─────────►│ │ └───────┘ └──────────┘ Linux supports endpoint functions. PCI Host write BAR space like write to memory. The EP side can't know memory changed by the host driver. PCI Spec has not defined a standard method to do that. Only define MSI(x) to let EP notified RC status change. The basic idea is to trigger an IRQ when PCI RC writes to a memory address. That's what MSI controller provided. EP drivers just need to request a platform MSI interrupt, struct msi_msg *msg will pass down a memory address and data. EP driver will map such memory address to one of PCI BAR. Host just writes such an address to trigger EP side irq. Add MSI support for pci-epf-vntb. pci-epf-vntb driver query if system have MSI controller. Setup doorbell address according to struct msi_msg. So PCIe host can write this doorbell address to triger EP side's irq. If no MSI controller exist, fall back to software polling. Signed-off-by: Frank Li --- drivers/pci/endpoint/functions/pci-epf-vntb.c | 134 +++++++++++++++--- 1 file changed, 112 insertions(+), 22 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index 1466dd1904175..cf55fa402049a 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -44,6 +44,7 @@ #include #include #include +#include static struct workqueue_struct *kpcintb_workqueue; @@ -143,6 +144,8 @@ struct epf_ntb { void __iomem *vpci_mw_addr[MAX_MW]; struct delayed_work cmd_handler; + + int msi_virqbase; }; #define to_epf_ntb(epf_group) container_of((epf_group), struct epf_ntb, group) @@ -253,7 +256,7 @@ static void epf_ntb_cmd_handler(struct work_struct *work) ntb = container_of(work, struct epf_ntb, cmd_handler.work); - for (i = 1; i < ntb->db_count; i++) { + for (i = 1; i < ntb->db_count && !ntb->epf_db_phy; i++) { if (readl(ntb->epf_db + i * 4)) { if (readl(ntb->epf_db + i * 4)) ntb->db |= 1 << (i - 1); @@ -454,11 +457,9 @@ static int epf_ntb_config_spad_bar_alloc(struct epf_ntb *ntb) ctrl->num_mws = ntb->num_mws; ntb->spad_size = spad_size; - ctrl->db_entry_size = 4; - for (i = 0; i < ntb->db_count; i++) { ntb->reg->db_data[i] = 1 + i; - ntb->reg->db_offset[i] = 0; + ntb->reg->db_offset[i] = 4 * i; } return 0; @@ -509,6 +510,28 @@ static int epf_ntb_configure_interrupt(struct epf_ntb *ntb) return 0; } +static int epf_ntb_db_size(struct epf_ntb *ntb) +{ + const struct pci_epc_features *epc_features; + size_t size = 4 * ntb->db_count; + u32 align; + + epc_features = pci_epc_get_features(ntb->epf->epc, + ntb->epf->func_no, + ntb->epf->vfunc_no); + align = epc_features->align; + + if (size < 128) + size = 128; + + if (align) + size = ALIGN(size, align); + else + size = roundup_pow_of_two(size); + + return size; +} + /** * epf_ntb_db_bar_init() - Configure Doorbell window BARs * @ntb: NTB device that facilitates communication between HOST and vHOST @@ -520,35 +543,33 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb) struct device *dev = &ntb->epf->dev; int ret; struct pci_epf_bar *epf_bar; - void __iomem *mw_addr; + void __iomem *mw_addr = NULL; enum pci_barno barno; - size_t size = 4 * ntb->db_count; + size_t size; epc_features = pci_epc_get_features(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no); - align = epc_features->align; - if (size < 128) - size = 128; - - if (align) - size = ALIGN(size, align); - else - size = roundup_pow_of_two(size); + size = epf_ntb_db_size(ntb); barno = ntb->epf_ntb_bar[BAR_DB]; + epf_bar = &ntb->epf->bar[barno]; - mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); - if (!mw_addr) { - dev_err(dev, "Failed to allocate OB address\n"); - return -ENOMEM; + if (!ntb->epf_db_phy) { + mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0); + if (!mw_addr) { + dev_err(dev, "Failed to allocate OB address\n"); + return -ENOMEM; + } + } else { + epf_bar->phys_addr = ntb->epf_db_phy; + epf_bar->barno = barno; + epf_bar->size = size; } ntb->epf_db = mw_addr; - epf_bar = &ntb->epf->bar[barno]; - ret = pci_epc_set_bar(ntb->epf->epc, ntb->epf->func_no, ntb->epf->vfunc_no, epf_bar); if (ret) { dev_err(dev, "Doorbell BAR set failed\n"); @@ -704,6 +725,74 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) return 0; } +static void epf_ntb_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) +{ + struct epf_ntb *ntb = dev_get_drvdata(desc->dev); + struct epf_ntb_ctrl *reg = ntb->reg; + int size = epf_ntb_db_size(ntb); + u64 addr; + + addr = msg->address_hi; + addr <<= 32; + addr |= msg->address_lo; + + reg->db_data[desc->msi_index] = msg->data; + + if (desc->msi_index == 0) + ntb->epf_db_phy = round_down(addr, size); + + reg->db_offset[desc->msi_index] = addr - ntb->epf_db_phy; +} + +static irqreturn_t epf_ntb_interrupt_handler(int irq, void *data) +{ + struct epf_ntb *ntb = data; + int index; + + index = irq - ntb->msi_virqbase; + ntb->db |= 1 << (index - 1); + ntb_db_event(&ntb->ntb, index); + + return IRQ_HANDLED; +} + +static void epf_ntb_epc_msi_init(struct epf_ntb *ntb) +{ + struct device *dev = &ntb->epf->dev; + struct irq_domain *domain; + int virq; + int ret; + int i; + + domain = dev_get_msi_domain(ntb->epf->epc->dev.parent); + if (!domain) + return; + + dev_set_msi_domain(dev, domain); + + if (platform_msi_domain_alloc_irqs(&ntb->epf->dev, + ntb->db_count, + epf_ntb_write_msi_msg)) { + dev_info(dev, "Can't allocate MSI, fall back to poll mode\n"); + return; + } + + dev_info(dev, "vntb use MSI as doorbell\n"); + + for (i = 0; i < ntb->db_count; i++) { + virq = msi_get_virq(dev, i); + ret = devm_request_irq(dev, virq, + epf_ntb_interrupt_handler, 0, + "ntb", ntb); + + if (ret) + dev_err(dev, "devm_request_irq() failure\n"); + + if (!i) + ntb->msi_virqbase = virq; + } +} + /** * epf_ntb_epc_init() - Initialize NTB interface * @ntb: NTB device that facilitates communication between HOST and vHOST2 @@ -1299,14 +1388,15 @@ static int epf_ntb_bind(struct pci_epf *epf) goto err_bar_alloc; } + epf_set_drvdata(epf, ntb); + epf_ntb_epc_msi_init(ntb); + ret = epf_ntb_epc_init(ntb); if (ret) { dev_err(dev, "Failed to initialize EPC\n"); goto err_bar_alloc; } - epf_set_drvdata(epf, ntb); - pci_space[0] = (ntb->vntb_pid << 16) | ntb->vntb_vid; pci_vntb_table[0].vendor = ntb->vntb_vid; pci_vntb_table[0].device = ntb->vntb_pid;