From patchwork Wed Aug 25 13:51:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C81FC4338F for ; Wed, 25 Aug 2021 13:52:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F83960F45 for ; Wed, 25 Aug 2021 13:52:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241441AbhHYNww (ORCPT ); Wed, 25 Aug 2021 09:52:52 -0400 Received: from mail-bn7nam10on2055.outbound.protection.outlook.com ([40.107.92.55]:53144 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240294AbhHYNwv (ORCPT ); Wed, 25 Aug 2021 09:52:51 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bYUsdWfy8QEiovp4fQTQGVnBrUpfww2EA1KM34zCy4TjbiLUc16KanVWusIyP1YadNYepH/Ys5Yumz49cRZOHz93BavtLuCdlk+dZfTTJdlOgTF2AEtrG4liXKGRiXYtluceJkonb30FX2obo4HH0N08qNWxmKtMBMTcu/ZKAQUetj0P2Mt21bQs1qMQcD+bbIJoKgcfwy8zQBPBludH8YKqIj1BXeEFiKATuhAJDJXUToedSKsWdtV9u7g8RTPgB91k+7lZYzk9hoGR18Xat3qi7y27zus85FoKmHLykkUYKUNxJgRE9fzZ0/8WoqZ8zf37GIWP8p8tLZobUFDAbw== 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-SenderADCheck; bh=8zp+Wv3I6Lwwlt2ddO5B9K3CvX1Q/7KFCOBAY9VFDsM=; b=EypXfk0L83bP7Gr6Bq9eNezbUSTenNUg70IZrjlc0aawJivpsWCnIa10Uw5WDXXMm/BspVnNdJquoOwt+2mqFIiA2bOONq0X9yjmErKbGlSXa6J95IazqUTheGj5KXCSYdd+qoKxvlIQ+MP0zx0s8eSqgslGMjuJaOF9x1czryhM7G/0kBAPl0kJdG9mLrzWhQ0pIAESQvNEqJSn/SnOMIa4E8tY2/SMhH7ZsLohmW+h57u5fFjj0MMmCjb3vDW/U6aoVH+179vzbzmThkcURm6rQxXaFC6HXcmLIyExaO8aCq1zzNCIYaBK4XS4i2swPQ8GB1QI6HNSO+YU17H1wA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=markovi.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8zp+Wv3I6Lwwlt2ddO5B9K3CvX1Q/7KFCOBAY9VFDsM=; b=beypHP0HpsTco9B+ryZ/Fn7lU5KDrcjOBTbPDAqnANvzM+fxaD2j9INTrasgo7sEnttGrIBH4F5i2feZ9ejEruMZVK/N7cKE4JZRHEyNfJjGdzm1QoSgEMlmtBS6G3On3I/B7c5SC7HdqmWW2Wt6drFGUtSE71b9esqGS0hfO+oeXJ4Ls6cnfnyLdD7+k9iJF0CTtlRQsHsPWENbZ8BDQyS313S/FX1N8qJNpIGBANXAxYlyvyWucBUVmc8I4X5cINAhFfzxjOkGsdXc1n7WwQUmTnyNJ4KvILN7/YdZnWjRBklZv8knCKx3g7hvxAjApnWEGcbTUTswAaStQ96QCw== Received: from BN8PR15CA0063.namprd15.prod.outlook.com (2603:10b6:408:80::40) by MN2PR12MB4799.namprd12.prod.outlook.com (2603:10b6:208:a2::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 13:52:04 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:80:cafe::34) by BN8PR15CA0063.outlook.office365.com (2603:10b6:408:80::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; markovi.net; dkim=none (message not signed) header.d=none;markovi.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:03 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:02 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:01 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:51:57 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 01/13] vfio/pci: Rename vfio_pci.c to vfio_pci_core.c Date: Wed, 25 Aug 2021 16:51:27 +0300 Message-ID: <20210825135139.79034-2-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 19c6dc4e-1f54-4cd5-47a8-08d967cf84ce X-MS-TrafficTypeDiagnostic: MN2PR12MB4799: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gvpwlPNiVM7SWdBi667gozND36nIYOWrDWpl+Z0h6Vb+v+AiSY3hPtTsLtHBFxWCuUoL/c43wDBHFN/LW31r1S+uunJnB1tb1YIEvk8Bqs7sdewwvCG+YLFP+AEl+OI4LZ37855o2iFKqQk/SngBp7mBs2omDe2Kqp+a1qzgccR29IVlKOMWQfQQvh146zJAg7Jmd6YS3VFdT/jHcQnSR5pf+rOqCFU8a1oJ+M51vmfbaLJG2rku4X1FZi/nv44vyF0u0PsE4Gz+fsOVvhVJvqCnaRED3g7o8XCbtDVaKbJwPcjzMdR8y2NkYPUP7n6I9KNyGktF6x6Ovfof09YfaCHHZFzsFMTwEUFzvgtx8l8kjwnKAvZsWZngp6EOD+NvBIJJWhZ3egOYkAFWu2dorIZuuOea4/Lyl1LEgJ/mdwX/gSlfba9vP8RlX8A2PLMqNcP8LXJ2NZN7KkxQBIyB1VmdLhlaup4AisszfOtmbPQ7nTeB3VdEiYCBXugPAzS2CRWEMC2EpKt3zMUAk0LFj+iV/DiD3jjPCxHg14X7P0FuivQNYOrpnvvC0A1yzH+QK0jSB9BK7ng/cnXlG6h6YaHjnPob3Gz50LUrxeArvComQcnUoLgStOd85v0FrFzlPJVk01EZOoTWQy0A6dOHbQ1VXZDirklf6C1u20U6Qi3JwAqBINCwuk/a60nq5F6RmNatQC1I9xLcW/PnzP20uLni9BhnEnNbqYlbQIglBZM= X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(39860400002)(346002)(136003)(376002)(46966006)(36840700001)(82740400003)(7696005)(426003)(4326008)(186003)(70206006)(70586007)(7416002)(316002)(8676002)(6666004)(5660300002)(54906003)(26005)(356005)(107886003)(110136005)(47076005)(82310400003)(1076003)(36906005)(36860700001)(86362001)(36756003)(478600001)(83380400001)(336012)(7636003)(8936002)(2906002)(2616005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:03.2009 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19c6dc4e-1f54-4cd5-47a8-08d967cf84ce X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4799 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy This is a preparation patch for separating the vfio_pci driver to a subsystem driver and a generic pci driver. This patch doesn't change any logic. Signed-off-by: Max Gurtovoy Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/Makefile | 2 +- drivers/vfio/pci/{vfio_pci.c => vfio_pci_core.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/vfio/pci/{vfio_pci.c => vfio_pci_core.c} (100%) diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile index 3ff42093962f..66a40488e967 100644 --- a/drivers/vfio/pci/Makefile +++ b/drivers/vfio/pci/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -vfio-pci-y := vfio_pci.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o +vfio-pci-y := vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o vfio-pci-$(CONFIG_S390) += vfio_pci_zdev.o diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci_core.c similarity index 100% rename from drivers/vfio/pci/vfio_pci.c rename to drivers/vfio/pci/vfio_pci_core.c From patchwork Wed Aug 25 13:51:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71E53C432BE for ; Wed, 25 Aug 2021 13:52:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A7C86115A for ; Wed, 25 Aug 2021 13:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240416AbhHYNxB (ORCPT ); Wed, 25 Aug 2021 09:53:01 -0400 Received: from mail-mw2nam12on2056.outbound.protection.outlook.com ([40.107.244.56]:60161 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240294AbhHYNxA (ORCPT ); Wed, 25 Aug 2021 09:53:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VOAHRqpAbh/WwBaOUki0Ln6FiSdHTDSfGSNQP6By1VSmMat9YNR+MVn6zNB912qQauqn4Gy24GI9VPHmN7yZAMgFLwuCqhBeyWpNQwLQGa6qAK0zp/ZSLLEvokhmVBIYKLkf4u/VBYjMtdfWG8A4oTTRDUueFRLIqj8hBswEdbaRqFqO0AiyacOezRyT3tUlK3g2AQFKow5KCJlVJa7331XWTBVEho2zpHMLfhorrRVIEQsC2PSBL9dr3yT8amT/CJXd8QwJVYbzojwhNOgDijAOmVc0fKGi+86ZcbwtLT1VvZ0yTPy8x4zGMJm2Xl7V+eU7Bt6wk7Lm/r/YuMwB9g== 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-SenderADCheck; bh=avPJWx9gy4zVxC1qWS4sqVAT0xbrd6qNQq/ja6mJt34=; b=OwLdgaGpnRjf9XVqgix+0XmGXOYL6mXm1DmkNquPL8iOmO16H8LqW1rNWlQvi5H2RrP15b6SHB7rzwzsGqxdk1b9EjiTUGVEje8fHywlcFOl9/eCaHsmvYgKnxk2lq96WKXEwn8RUjVD8WV9QLKP2nBOmTp+PI9/Y2Bx+tpftFbSMYEhk/tRicJeJuaybcnz5GLacZKGqAtb2sXdIImEnHuFF3Lofj/w+Y/98dC915/ird6/Hw04up6TRkIDg4mvFIEL1MlvLiOTKjRAOWtA7k1jfDi8Yfc2wIqn9Yzm1BaUsyIN6zHeef44JRburN42F3WN0kr+K93j1ZAvRFdiuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=avPJWx9gy4zVxC1qWS4sqVAT0xbrd6qNQq/ja6mJt34=; b=g1cw1H33wmOz37m/krmq7gFR3lPHLm+Ml9X0DY09Or8wH4SPoUINosjgKXcXCmYUJbZXpwh9G06Gc7Pab+UxwmUNtB2IkvgyN4NamVWw+4c4vNgIvVywbD5+xj5mBEpQ7Y7ZBRSTAaXV6YRHa5909KI1wwwXiXLTOAq66ONLliTTHw3JgBrA4PLxwFHpvMBsLcUks0/HfHhbIWBi5dWm9f53GcoG7TG27RoKa8kX7J4qKuXgxo3oa8xktHZvPShOoiIFs4xKRjafz26v4mUoEU7tSMJbJH8FtQ/gS9dfkCauhhYwCF9Whc+ZJgnNXbzTkrdvCllB+7ITy5uCj1xhvA== Received: from MW4PR03CA0356.namprd03.prod.outlook.com (2603:10b6:303:dc::31) by MN2PR12MB2976.namprd12.prod.outlook.com (2603:10b6:208:c2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 13:52:07 +0000 Received: from CO1NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dc:cafe::56) by MW4PR03CA0356.outlook.office365.com (2603:10b6:303:dc::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Wed, 25 Aug 2021 13:52:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT018.mail.protection.outlook.com (10.13.175.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:07 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 06:52:05 -0700 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:02 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 02/13] vfio/pci: Rename vfio_pci_private.h to vfio_pci_core.h Date: Wed, 25 Aug 2021 16:51:28 +0300 Message-ID: <20210825135139.79034-3-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b589d2c-5228-4c16-90b4-08d967cf870f X-MS-TrafficTypeDiagnostic: MN2PR12MB2976: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zhooTGu4cw6FS7mMwC6fMYk4XH1AsXvp1zF6dKzSOwftaXTIesXZ5Y7zSYeV29fTeHO0/2IG5FtozB/h6dWVAeo4Np2HqrJD0x21Tvb//+OsIJEWKBv2AcQHbh32Sa0ROtdFlf+UycL+bX29fXxo5cQVus7LODaGyt7nkA3uyaAdiida5ay1v6IoqP5kqApc/qZZQMCBLYlUAUqLyxfCsCnt3yts6IYwD1theWbE02vuRil5CXXFz0Rc2DoVlvo6qoSQh1qfTNgROW2xmi4qCDXmDF/R2Lz0FiHFwkcqodIL/CulhHW/7cqUxF8mbuQfIZrJbi696DQfCdSkgBR3PI3nSmHZNHFTaYZdPnJegz4gGhvRA0/Mg3L2/qgE3oK0WMRfXHIZZAgEisJ82fkhfzhqq+Mur7eHI+T4Na5XAZGcm5m9s8wDhsS4a5h+KGMqUKSUEfG1aBojmFBXn2SQUwoHodRPPpuM/ZKpbxP0AKYzXryHa/XOpCalEvb/a+drLmCu+4dVuYR81L0Qozt7P8n+OzPOyHE9bx3WUl/EuGIDWgrLNP+TTLAxHLZC0LLuolTtEhqJWtwh9a460wGOwPQb+hfs+WMQycBuVDzlUtsbw948mZQAr2wXCa9qUBLpynhEYvmIng3B306buG/M+U9peCTqYyFP11CXGMUtUdxsxp2NzCReV3nTk7ABjGPfIobwIX2n5IzpkLt+GvU3BEVzzW4U8Jf/bgst8Jw6t84= X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(39860400002)(376002)(346002)(136003)(36840700001)(46966006)(316002)(36756003)(36860700001)(6666004)(478600001)(7696005)(2906002)(107886003)(47076005)(82740400003)(4326008)(7636003)(70586007)(70206006)(110136005)(54906003)(186003)(8676002)(2616005)(8936002)(7416002)(336012)(426003)(5660300002)(83380400001)(1076003)(356005)(86362001)(26005)(82310400003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:07.0361 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b589d2c-5228-4c16-90b4-08d967cf870f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2976 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy This is a preparation patch for separating the vfio_pci driver to a subsystem driver and a generic pci driver. This patch doesn't change any logic. Signed-off-by: Max Gurtovoy Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/vfio_pci_config.c | 2 +- drivers/vfio/pci/vfio_pci_core.c | 2 +- drivers/vfio/pci/{vfio_pci_private.h => vfio_pci_core.h} | 6 +++--- drivers/vfio/pci/vfio_pci_igd.c | 2 +- drivers/vfio/pci/vfio_pci_intrs.c | 2 +- drivers/vfio/pci/vfio_pci_rdwr.c | 2 +- drivers/vfio/pci/vfio_pci_zdev.c | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename drivers/vfio/pci/{vfio_pci_private.h => vfio_pci_core.h} (98%) diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index 70e28efbc51f..0bc269c0b03f 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -26,7 +26,7 @@ #include #include -#include "vfio_pci_private.h" +#include "vfio_pci_core.h" /* Fake capability ID for standard config space */ #define PCI_CAP_ID_BASIC 0 diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index a4f44ea52fa3..2a5dca0823c4 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -28,7 +28,7 @@ #include #include -#include "vfio_pci_private.h" +#include "vfio_pci_core.h" #define DRIVER_VERSION "0.2" #define DRIVER_AUTHOR "Alex Williamson " diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_core.h similarity index 98% rename from drivers/vfio/pci/vfio_pci_private.h rename to drivers/vfio/pci/vfio_pci_core.h index 70414b6c904d..ef26e781961d 100644 --- a/drivers/vfio/pci/vfio_pci_private.h +++ b/drivers/vfio/pci/vfio_pci_core.h @@ -15,8 +15,8 @@ #include #include -#ifndef VFIO_PCI_PRIVATE_H -#define VFIO_PCI_PRIVATE_H +#ifndef VFIO_PCI_CORE_H +#define VFIO_PCI_CORE_H #define VFIO_PCI_OFFSET_SHIFT 40 @@ -205,4 +205,4 @@ static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev, } #endif -#endif /* VFIO_PCI_PRIVATE_H */ +#endif /* VFIO_PCI_CORE_H */ diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c index aa0a29fd2762..d57c409b4033 100644 --- a/drivers/vfio/pci/vfio_pci_igd.c +++ b/drivers/vfio/pci/vfio_pci_igd.c @@ -15,7 +15,7 @@ #include #include -#include "vfio_pci_private.h" +#include "vfio_pci_core.h" #define OPREGION_SIGNATURE "IntelGraphicsMem" #define OPREGION_SIZE (8 * 1024) diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index 869dce5f134d..df1e8c8c274c 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -20,7 +20,7 @@ #include #include -#include "vfio_pci_private.h" +#include "vfio_pci_core.h" /* * INTx diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c index a0b5fc8e46f4..667e82726e75 100644 --- a/drivers/vfio/pci/vfio_pci_rdwr.c +++ b/drivers/vfio/pci/vfio_pci_rdwr.c @@ -17,7 +17,7 @@ #include #include -#include "vfio_pci_private.h" +#include "vfio_pci_core.h" #ifdef __LITTLE_ENDIAN #define vfio_ioread64 ioread64 diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index 7b011b62c766..ecae0c3d95a0 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -19,7 +19,7 @@ #include #include -#include "vfio_pci_private.h" +#include "vfio_pci_core.h" /* * Add the Base PCI Function information to the device info region. From patchwork Wed Aug 25 13:51:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E366C43214 for ; Wed, 25 Aug 2021 13:52:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 479FD610E8 for ; Wed, 25 Aug 2021 13:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241486AbhHYNxJ (ORCPT ); Wed, 25 Aug 2021 09:53:09 -0400 Received: from mail-bn1nam07on2057.outbound.protection.outlook.com ([40.107.212.57]:1806 "EHLO NAM02-BN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241467AbhHYNxC (ORCPT ); Wed, 25 Aug 2021 09:53:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KdOgwCEO08cYjzyvXa1isJNzeH1O53Uu+YFnkMvN4L7370bi65dI3uPtw1ad971cn3EebgAZrqSm1ES1bWKlujQ3BGNZ/HpuD0OoVV0Wot+d5D1aiXedB+RmzbgcNZ/cVZnIHxKhigir9QVkGQ0g6nyXpZ3JBhwAafYaOJTujNyqpRCtsKbMY0jAXCiSOLIQCU5NDXWnIp6zIls5CvQ2AX7qojikRCETNnMMjNN7yRF/M/EKWoIlgH8LsQYs3omG6ZzdNhOEyJ5gW01bdD9kyPel0X4P+PN8C3dFEckubZ4rNcN896LNKi2a3hNJ29ys1XwDYP/q3XThwJtp5gRQjA== 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-SenderADCheck; bh=ZsdBtj9wo82yKnZ4DcPbHBJpSKchUPH724zKdfw2mck=; b=I5zfqRgoYHRgKpYoxewDSp47IlgiLT4NAtPojwbquKObyINvQ3up1UV4R8b3yh6lO+yh1b16d0gg/A6p0l8tCgaqNVSy6c/MXSLQAquPKun5r9R5rx5jkPTf9KevbEvDhG5q2solwLCPd0VhGNLnAw07jL1O/VSWte7IB0vk+NLipw5LAdwsOZer+UE04Q9GhS5RSKesnZ5jvROgpnctW0dPTetktqDe6rrWqpoUSagg7j+S2QayPwbZ/7NIg+FTPVAhEPV3hUh+RlbGMJ9kn1ov9VSP5bGyPdQLuiQv8gBDj8DUGM47F8l1rBHyMZ4oiu8FcmFa0INjRhzfhru6GA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=markovi.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZsdBtj9wo82yKnZ4DcPbHBJpSKchUPH724zKdfw2mck=; b=JpwS9NGLXE5/I32OhBK2U3eDclGpIB9Y30ziXBnkTXzHtYGySAXDEFIPdsrYRQEsH7D+cYjRuVA9EbAYRtDfHMUuV2+0WlHsFNueISZYIXQlMg+mMEP/nsNxFco9IlibgIW3qW19XOm8QTJGsvTXyoapo0XukqResMjqBucK1IQQHQShl2vAppuu+MATYly172oDimjFbMPViWjAWBzG673S8OkJ9UlZjuOcz5KwRyh+HvqEnyxk/R+s6vfDRxv1P5FoWACEoN4sNopgFsQJJ3FBSeptMUyerMek3RFHavz1dgJL7fhuReIavQB6MPLZc06gMOI5ahJx7+wVfFXfEg== Received: from MWHPR13CA0008.namprd13.prod.outlook.com (2603:10b6:300:16::18) by DM6PR12MB4516.namprd12.prod.outlook.com (2603:10b6:5:2ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 13:52:12 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:300:16:cafe::7b) by MWHPR13CA0008.outlook.office365.com (2603:10b6:300:16::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.6 via Frontend Transport; Wed, 25 Aug 2021 13:52:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; markovi.net; dkim=none (message not signed) header.d=none;markovi.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 13:52:10 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 06:52:10 -0700 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:10 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:06 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 03/13] vfio/pci: Rename vfio_pci_device to vfio_pci_core_device Date: Wed, 25 Aug 2021 16:51:29 +0300 Message-ID: <20210825135139.79034-4-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf3d8bd6-1876-419c-2fb3-08d967cf8964 X-MS-TrafficTypeDiagnostic: DM6PR12MB4516: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aGetcHxw/Whg2PYgkZU1yYrYurARVsOpUJMR3cBCrPNLAQCYptZE0Br9TCaeyFIav4cNjs9sRLP/uXZwGMg5lhf1VYU1Dt8zqCnxDihCSzc+FcpywGKI5Sb/iKwLbsx42A1vVeWsqDlBU2mB4nsZj8wBj5ccgloE8XVGQivZeDziMAww36pbQzK2Bbq6j3eOH0UZ9nn+aPreZfCW9rL/xbZcpqPK9joiYewqTXeSRWRuUGDESGDAz9qxj+3Q1tkSHbLFYD2HGQcEWpw70O5ocykY71QyJb0Gg5u/uV0HE7kc7GNoQhSmQFnbPbIEzZghiGr6TM//Ls7lNIadg+U3HQQOfhqRMJMjspC+/FZwy+gIEmDW9rrjdoMnkaaKKOGZMjou+5rYAdkoLHzcyARKyhPZgNskJD5IS2tZOrJNR0ejiRUK7vwWWBPnR2HHIGdVn33HLrt7UwEm9YVIXe7/u4y7j1nbYA62dXu/EEkGxLDt7mrR82gOfTCOJ6qwcQwQMjmn8scjXXyny33m3/iJ+MeQH6DeqvtHqPxufhgOeKF2cqZCe0RKzRAoe8yNrwt22PI3wCk8lZe3snweAytL1X4PWHN+WNCBsaWX0lGOw/wlWqhi1Bx57z5poZfKrt8Yor0H+PBXq9yl/XSd4PeRoH+GtGEdSCps6LIXO1Huhn17wk6+XdxRyNlKboY7yCiRX6jxhWvhwwgjuXn+he2q77JXwLGSUWBoIACVUsaU8HE= X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(39860400002)(346002)(376002)(136003)(396003)(46966006)(36840700001)(8676002)(336012)(110136005)(186003)(47076005)(7416002)(36756003)(70586007)(70206006)(2906002)(5660300002)(86362001)(6666004)(26005)(4326008)(54906003)(478600001)(2616005)(356005)(7636003)(7696005)(1076003)(82740400003)(426003)(30864003)(107886003)(8936002)(316002)(82310400003)(83380400001)(36860700001)(2101003)(579004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:10.9372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf3d8bd6-1876-419c-2fb3-08d967cf8964 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4516 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy This is a preparation patch for separating the vfio_pci driver to a subsystem driver and a generic pci driver. This patch doesn't change any logic. The new vfio_pci_core_device structure will be the main structure of the core driver and later on vfio_pci_device structure will be the main structure of the generic vfio_pci driver. Signed-off-by: Max Gurtovoy Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/vfio_pci_config.c | 68 ++++++++--------- drivers/vfio/pci/vfio_pci_core.c | 118 +++++++++++++++-------------- drivers/vfio/pci/vfio_pci_core.h | 52 ++++++------- drivers/vfio/pci/vfio_pci_igd.c | 17 +++-- drivers/vfio/pci/vfio_pci_intrs.c | 40 +++++----- drivers/vfio/pci/vfio_pci_rdwr.c | 16 ++-- drivers/vfio/pci/vfio_pci_zdev.c | 2 +- 7 files changed, 158 insertions(+), 155 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index 0bc269c0b03f..1f034f768a27 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -108,9 +108,9 @@ static const u16 pci_ext_cap_length[PCI_EXT_CAP_ID_MAX + 1] = { struct perm_bits { u8 *virt; /* read/write virtual data, not hw */ u8 *write; /* writeable bits */ - int (*readfn)(struct vfio_pci_device *vdev, int pos, int count, + int (*readfn)(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 *val); - int (*writefn)(struct vfio_pci_device *vdev, int pos, int count, + int (*writefn)(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val); }; @@ -171,7 +171,7 @@ static int vfio_user_config_write(struct pci_dev *pdev, int offset, return ret; } -static int vfio_default_config_read(struct vfio_pci_device *vdev, int pos, +static int vfio_default_config_read(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 *val) { @@ -197,7 +197,7 @@ static int vfio_default_config_read(struct vfio_pci_device *vdev, int pos, return count; } -static int vfio_default_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_default_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -244,7 +244,7 @@ static int vfio_default_config_write(struct vfio_pci_device *vdev, int pos, } /* Allow direct read from hardware, except for capability next pointer */ -static int vfio_direct_config_read(struct vfio_pci_device *vdev, int pos, +static int vfio_direct_config_read(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 *val) { @@ -269,7 +269,7 @@ static int vfio_direct_config_read(struct vfio_pci_device *vdev, int pos, } /* Raw access skips any kind of virtualization */ -static int vfio_raw_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_raw_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -282,7 +282,7 @@ static int vfio_raw_config_write(struct vfio_pci_device *vdev, int pos, return count; } -static int vfio_raw_config_read(struct vfio_pci_device *vdev, int pos, +static int vfio_raw_config_read(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 *val) { @@ -296,7 +296,7 @@ static int vfio_raw_config_read(struct vfio_pci_device *vdev, int pos, } /* Virt access uses only virtualization */ -static int vfio_virt_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_virt_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -304,7 +304,7 @@ static int vfio_virt_config_write(struct vfio_pci_device *vdev, int pos, return count; } -static int vfio_virt_config_read(struct vfio_pci_device *vdev, int pos, +static int vfio_virt_config_read(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 *val) { @@ -396,7 +396,7 @@ static inline void p_setd(struct perm_bits *p, int off, u32 virt, u32 write) } /* Caller should hold memory_lock semaphore */ -bool __vfio_pci_memory_enabled(struct vfio_pci_device *vdev) +bool __vfio_pci_memory_enabled(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; u16 cmd = le16_to_cpu(*(__le16 *)&vdev->vconfig[PCI_COMMAND]); @@ -413,7 +413,7 @@ bool __vfio_pci_memory_enabled(struct vfio_pci_device *vdev) * Restore the *real* BARs after we detect a FLR or backdoor reset. * (backdoor = some device specific technique that we didn't catch) */ -static void vfio_bar_restore(struct vfio_pci_device *vdev) +static void vfio_bar_restore(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; u32 *rbar = vdev->rbar; @@ -460,7 +460,7 @@ static __le32 vfio_generate_bar_flags(struct pci_dev *pdev, int bar) * Pretend we're hardware and tweak the values of the *virtual* PCI BARs * to reflect the hardware capabilities. This implements BAR sizing. */ -static void vfio_bar_fixup(struct vfio_pci_device *vdev) +static void vfio_bar_fixup(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; int i; @@ -514,7 +514,7 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev) vdev->bardirty = false; } -static int vfio_basic_config_read(struct vfio_pci_device *vdev, int pos, +static int vfio_basic_config_read(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 *val) { @@ -536,7 +536,7 @@ static int vfio_basic_config_read(struct vfio_pci_device *vdev, int pos, } /* Test whether BARs match the value we think they should contain */ -static bool vfio_need_bar_restore(struct vfio_pci_device *vdev) +static bool vfio_need_bar_restore(struct vfio_pci_core_device *vdev) { int i = 0, pos = PCI_BASE_ADDRESS_0, ret; u32 bar; @@ -552,7 +552,7 @@ static bool vfio_need_bar_restore(struct vfio_pci_device *vdev) return false; } -static int vfio_basic_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_basic_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -692,7 +692,7 @@ static int __init init_pci_cap_basic_perm(struct perm_bits *perm) return 0; } -static int vfio_pm_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_pm_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -747,7 +747,7 @@ static int __init init_pci_cap_pm_perm(struct perm_bits *perm) return 0; } -static int vfio_vpd_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_vpd_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -829,7 +829,7 @@ static int __init init_pci_cap_pcix_perm(struct perm_bits *perm) return 0; } -static int vfio_exp_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_exp_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -913,7 +913,7 @@ static int __init init_pci_cap_exp_perm(struct perm_bits *perm) return 0; } -static int vfio_af_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_af_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -1072,7 +1072,7 @@ int __init vfio_pci_init_perm_bits(void) return ret; } -static int vfio_find_cap_start(struct vfio_pci_device *vdev, int pos) +static int vfio_find_cap_start(struct vfio_pci_core_device *vdev, int pos) { u8 cap; int base = (pos >= PCI_CFG_SPACE_SIZE) ? PCI_CFG_SPACE_SIZE : @@ -1089,7 +1089,7 @@ static int vfio_find_cap_start(struct vfio_pci_device *vdev, int pos) return pos; } -static int vfio_msi_config_read(struct vfio_pci_device *vdev, int pos, +static int vfio_msi_config_read(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 *val) { @@ -1109,7 +1109,7 @@ static int vfio_msi_config_read(struct vfio_pci_device *vdev, int pos, return vfio_default_config_read(vdev, pos, count, perm, offset, val); } -static int vfio_msi_config_write(struct vfio_pci_device *vdev, int pos, +static int vfio_msi_config_write(struct vfio_pci_core_device *vdev, int pos, int count, struct perm_bits *perm, int offset, __le32 val) { @@ -1189,7 +1189,7 @@ static int init_pci_cap_msi_perm(struct perm_bits *perm, int len, u16 flags) } /* Determine MSI CAP field length; initialize msi_perms on 1st call per vdev */ -static int vfio_msi_cap_len(struct vfio_pci_device *vdev, u8 pos) +static int vfio_msi_cap_len(struct vfio_pci_core_device *vdev, u8 pos) { struct pci_dev *pdev = vdev->pdev; int len, ret; @@ -1222,7 +1222,7 @@ static int vfio_msi_cap_len(struct vfio_pci_device *vdev, u8 pos) } /* Determine extended capability length for VC (2 & 9) and MFVC */ -static int vfio_vc_cap_len(struct vfio_pci_device *vdev, u16 pos) +static int vfio_vc_cap_len(struct vfio_pci_core_device *vdev, u16 pos) { struct pci_dev *pdev = vdev->pdev; u32 tmp; @@ -1263,7 +1263,7 @@ static int vfio_vc_cap_len(struct vfio_pci_device *vdev, u16 pos) return len; } -static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos) +static int vfio_cap_len(struct vfio_pci_core_device *vdev, u8 cap, u8 pos) { struct pci_dev *pdev = vdev->pdev; u32 dword; @@ -1338,7 +1338,7 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos) return 0; } -static int vfio_ext_cap_len(struct vfio_pci_device *vdev, u16 ecap, u16 epos) +static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epos) { struct pci_dev *pdev = vdev->pdev; u8 byte; @@ -1412,7 +1412,7 @@ static int vfio_ext_cap_len(struct vfio_pci_device *vdev, u16 ecap, u16 epos) return 0; } -static int vfio_fill_vconfig_bytes(struct vfio_pci_device *vdev, +static int vfio_fill_vconfig_bytes(struct vfio_pci_core_device *vdev, int offset, int size) { struct pci_dev *pdev = vdev->pdev; @@ -1459,7 +1459,7 @@ static int vfio_fill_vconfig_bytes(struct vfio_pci_device *vdev, return ret; } -static int vfio_cap_init(struct vfio_pci_device *vdev) +static int vfio_cap_init(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; u8 *map = vdev->pci_config_map; @@ -1549,7 +1549,7 @@ static int vfio_cap_init(struct vfio_pci_device *vdev) return 0; } -static int vfio_ecap_init(struct vfio_pci_device *vdev) +static int vfio_ecap_init(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; u8 *map = vdev->pci_config_map; @@ -1669,7 +1669,7 @@ static const struct pci_device_id known_bogus_vf_intx_pin[] = { * for each area requiring emulated bits, but the array of pointers * would be comparable in size (at least for standard config space). */ -int vfio_config_init(struct vfio_pci_device *vdev) +int vfio_config_init(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; u8 *map, *vconfig; @@ -1773,7 +1773,7 @@ int vfio_config_init(struct vfio_pci_device *vdev) return pcibios_err_to_errno(ret); } -void vfio_config_free(struct vfio_pci_device *vdev) +void vfio_config_free(struct vfio_pci_core_device *vdev) { kfree(vdev->vconfig); vdev->vconfig = NULL; @@ -1790,7 +1790,7 @@ void vfio_config_free(struct vfio_pci_device *vdev) * Find the remaining number of bytes in a dword that match the given * position. Stop at either the end of the capability or the dword boundary. */ -static size_t vfio_pci_cap_remaining_dword(struct vfio_pci_device *vdev, +static size_t vfio_pci_cap_remaining_dword(struct vfio_pci_core_device *vdev, loff_t pos) { u8 cap = vdev->pci_config_map[pos]; @@ -1802,7 +1802,7 @@ static size_t vfio_pci_cap_remaining_dword(struct vfio_pci_device *vdev, return i; } -static ssize_t vfio_config_do_rw(struct vfio_pci_device *vdev, char __user *buf, +static ssize_t vfio_config_do_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) { struct pci_dev *pdev = vdev->pdev; @@ -1885,7 +1885,7 @@ static ssize_t vfio_config_do_rw(struct vfio_pci_device *vdev, char __user *buf, return ret; } -ssize_t vfio_pci_config_rw(struct vfio_pci_device *vdev, char __user *buf, +ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) { size_t done = 0; diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 2a5dca0823c4..2729479390a0 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -121,7 +121,7 @@ static bool vfio_pci_is_denylisted(struct pci_dev *pdev) */ static unsigned int vfio_pci_set_vga_decode(void *opaque, bool single_vga) { - struct vfio_pci_device *vdev = opaque; + struct vfio_pci_core_device *vdev = opaque; struct pci_dev *tmp = NULL, *pdev = vdev->pdev; unsigned char max_busnr; unsigned int decodes; @@ -155,7 +155,7 @@ static inline bool vfio_pci_is_vga(struct pci_dev *pdev) return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; } -static void vfio_pci_probe_mmaps(struct vfio_pci_device *vdev) +static void vfio_pci_probe_mmaps(struct vfio_pci_core_device *vdev) { struct resource *res; int i; @@ -225,7 +225,7 @@ static void vfio_pci_probe_mmaps(struct vfio_pci_device *vdev) struct vfio_pci_group_info; static bool vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set); -static void vfio_pci_disable(struct vfio_pci_device *vdev); +static void vfio_pci_disable(struct vfio_pci_core_device *vdev); static int vfio_pci_dev_set_hot_reset(struct vfio_device_set *dev_set, struct vfio_pci_group_info *groups); @@ -260,7 +260,7 @@ static bool vfio_pci_nointx(struct pci_dev *pdev) return false; } -static void vfio_pci_probe_power_state(struct vfio_pci_device *vdev) +static void vfio_pci_probe_power_state(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; u16 pmcsr; @@ -280,7 +280,7 @@ static void vfio_pci_probe_power_state(struct vfio_pci_device *vdev) * by PM capability emulation and separately from pci_dev internal saved state * to avoid it being overwritten and consumed around other resets. */ -int vfio_pci_set_power_state(struct vfio_pci_device *vdev, pci_power_t state) +int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev, pci_power_t state) { struct pci_dev *pdev = vdev->pdev; bool needs_restore = false, needs_save = false; @@ -311,7 +311,7 @@ int vfio_pci_set_power_state(struct vfio_pci_device *vdev, pci_power_t state) return ret; } -static int vfio_pci_enable(struct vfio_pci_device *vdev) +static int vfio_pci_enable(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; int ret; @@ -399,7 +399,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev) return ret; } -static void vfio_pci_disable(struct vfio_pci_device *vdev) +static void vfio_pci_disable(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; struct vfio_pci_dummy_resource *dummy_res, *tmp; @@ -498,7 +498,7 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev) static struct pci_driver vfio_pci_driver; -static struct vfio_pci_device *get_pf_vdev(struct vfio_pci_device *vdev) +static struct vfio_pci_core_device *get_pf_vdev(struct vfio_pci_core_device *vdev) { struct pci_dev *physfn = pci_physfn(vdev->pdev); struct vfio_device *pf_dev; @@ -515,12 +515,12 @@ static struct vfio_pci_device *get_pf_vdev(struct vfio_pci_device *vdev) return NULL; } - return container_of(pf_dev, struct vfio_pci_device, vdev); + return container_of(pf_dev, struct vfio_pci_core_device, vdev); } -static void vfio_pci_vf_token_user_add(struct vfio_pci_device *vdev, int val) +static void vfio_pci_vf_token_user_add(struct vfio_pci_core_device *vdev, int val) { - struct vfio_pci_device *pf_vdev = get_pf_vdev(vdev); + struct vfio_pci_core_device *pf_vdev = get_pf_vdev(vdev); if (!pf_vdev) return; @@ -535,8 +535,8 @@ static void vfio_pci_vf_token_user_add(struct vfio_pci_device *vdev, int val) static void vfio_pci_close_device(struct vfio_device *core_vdev) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); vfio_pci_vf_token_user_add(vdev, -1); vfio_spapr_pci_eeh_release(vdev->pdev); @@ -556,8 +556,8 @@ static void vfio_pci_close_device(struct vfio_device *core_vdev) static int vfio_pci_open_device(struct vfio_device *core_vdev) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); int ret = 0; ret = vfio_pci_enable(vdev); @@ -569,7 +569,7 @@ static int vfio_pci_open_device(struct vfio_device *core_vdev) return 0; } -static int vfio_pci_get_irq_count(struct vfio_pci_device *vdev, int irq_type) +static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_type) { if (irq_type == VFIO_PCI_INTX_IRQ_INDEX) { u8 pin; @@ -690,7 +690,7 @@ static int vfio_pci_for_each_slot_or_bus(struct pci_dev *pdev, return walk.ret; } -static int msix_mmappable_cap(struct vfio_pci_device *vdev, +static int msix_mmappable_cap(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps) { struct vfio_info_cap_header header = { @@ -701,7 +701,7 @@ static int msix_mmappable_cap(struct vfio_pci_device *vdev, return vfio_info_add_capability(caps, &header, sizeof(header)); } -int vfio_pci_register_dev_region(struct vfio_pci_device *vdev, +int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev, unsigned int type, unsigned int subtype, const struct vfio_pci_regops *ops, size_t size, u32 flags, void *data) @@ -730,8 +730,8 @@ int vfio_pci_register_dev_region(struct vfio_pci_device *vdev, static long vfio_pci_ioctl(struct vfio_device *core_vdev, unsigned int cmd, unsigned long arg) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); unsigned long minsz; if (cmd == VFIO_DEVICE_GET_INFO) { @@ -1271,7 +1271,7 @@ static long vfio_pci_ioctl(struct vfio_device *core_vdev, return -ENOTTY; } -static ssize_t vfio_pci_rw(struct vfio_pci_device *vdev, char __user *buf, +static ssize_t vfio_pci_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) { unsigned int index = VFIO_PCI_OFFSET_TO_INDEX(*ppos); @@ -1305,8 +1305,8 @@ static ssize_t vfio_pci_rw(struct vfio_pci_device *vdev, char __user *buf, static ssize_t vfio_pci_read(struct vfio_device *core_vdev, char __user *buf, size_t count, loff_t *ppos) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); if (!count) return 0; @@ -1317,8 +1317,8 @@ static ssize_t vfio_pci_read(struct vfio_device *core_vdev, char __user *buf, static ssize_t vfio_pci_write(struct vfio_device *core_vdev, const char __user *buf, size_t count, loff_t *ppos) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); if (!count) return 0; @@ -1327,7 +1327,7 @@ static ssize_t vfio_pci_write(struct vfio_device *core_vdev, const char __user * } /* Return 1 on zap and vma_lock acquired, 0 on contention (only with @try) */ -static int vfio_pci_zap_and_vma_lock(struct vfio_pci_device *vdev, bool try) +static int vfio_pci_zap_and_vma_lock(struct vfio_pci_core_device *vdev, bool try) { struct vfio_pci_mmap_vma *mmap_vma, *tmp; @@ -1415,14 +1415,14 @@ static int vfio_pci_zap_and_vma_lock(struct vfio_pci_device *vdev, bool try) } } -void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_device *vdev) +void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_core_device *vdev) { vfio_pci_zap_and_vma_lock(vdev, false); down_write(&vdev->memory_lock); mutex_unlock(&vdev->vma_lock); } -u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_device *vdev) +u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_core_device *vdev) { u16 cmd; @@ -1435,14 +1435,14 @@ u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_device *vdev) return cmd; } -void vfio_pci_memory_unlock_and_restore(struct vfio_pci_device *vdev, u16 cmd) +void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev, u16 cmd) { pci_write_config_word(vdev->pdev, PCI_COMMAND, cmd); up_write(&vdev->memory_lock); } /* Caller holds vma_lock */ -static int __vfio_pci_add_vma(struct vfio_pci_device *vdev, +static int __vfio_pci_add_vma(struct vfio_pci_core_device *vdev, struct vm_area_struct *vma) { struct vfio_pci_mmap_vma *mmap_vma; @@ -1468,7 +1468,7 @@ static void vfio_pci_mmap_open(struct vm_area_struct *vma) static void vfio_pci_mmap_close(struct vm_area_struct *vma) { - struct vfio_pci_device *vdev = vma->vm_private_data; + struct vfio_pci_core_device *vdev = vma->vm_private_data; struct vfio_pci_mmap_vma *mmap_vma; mutex_lock(&vdev->vma_lock); @@ -1485,7 +1485,7 @@ static void vfio_pci_mmap_close(struct vm_area_struct *vma) static vm_fault_t vfio_pci_mmap_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; - struct vfio_pci_device *vdev = vma->vm_private_data; + struct vfio_pci_core_device *vdev = vma->vm_private_data; struct vfio_pci_mmap_vma *mmap_vma; vm_fault_t ret = VM_FAULT_NOPAGE; @@ -1535,8 +1535,8 @@ static const struct vm_operations_struct vfio_pci_mmap_ops = { static int vfio_pci_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); struct pci_dev *pdev = vdev->pdev; unsigned int index; u64 phys_len, req_len, pgoff, req_start; @@ -1606,8 +1606,8 @@ static int vfio_pci_mmap(struct vfio_device *core_vdev, struct vm_area_struct *v static void vfio_pci_request(struct vfio_device *core_vdev, unsigned int count) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); struct pci_dev *pdev = vdev->pdev; mutex_lock(&vdev->igate); @@ -1626,7 +1626,7 @@ static void vfio_pci_request(struct vfio_device *core_vdev, unsigned int count) mutex_unlock(&vdev->igate); } -static int vfio_pci_validate_vf_token(struct vfio_pci_device *vdev, +static int vfio_pci_validate_vf_token(struct vfio_pci_core_device *vdev, bool vf_token, uuid_t *uuid) { /* @@ -1658,7 +1658,7 @@ static int vfio_pci_validate_vf_token(struct vfio_pci_device *vdev, return 0; /* No VF token provided or required */ if (vdev->pdev->is_virtfn) { - struct vfio_pci_device *pf_vdev = get_pf_vdev(vdev); + struct vfio_pci_core_device *pf_vdev = get_pf_vdev(vdev); bool match; if (!pf_vdev) { @@ -1722,8 +1722,8 @@ static int vfio_pci_validate_vf_token(struct vfio_pci_device *vdev, static int vfio_pci_match(struct vfio_device *core_vdev, char *buf) { - struct vfio_pci_device *vdev = - container_of(core_vdev, struct vfio_pci_device, vdev); + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); bool vf_token = false; uuid_t uuid; int ret; @@ -1785,8 +1785,8 @@ static const struct vfio_device_ops vfio_pci_ops = { static int vfio_pci_bus_notifier(struct notifier_block *nb, unsigned long action, void *data) { - struct vfio_pci_device *vdev = container_of(nb, - struct vfio_pci_device, nb); + struct vfio_pci_core_device *vdev = container_of(nb, + struct vfio_pci_core_device, nb); struct device *dev = data; struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *physfn = pci_physfn(pdev); @@ -1810,7 +1810,7 @@ static int vfio_pci_bus_notifier(struct notifier_block *nb, return 0; } -static int vfio_pci_vf_init(struct vfio_pci_device *vdev) +static int vfio_pci_vf_init(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; int ret; @@ -1834,7 +1834,7 @@ static int vfio_pci_vf_init(struct vfio_pci_device *vdev) return 0; } -static void vfio_pci_vf_uninit(struct vfio_pci_device *vdev) +static void vfio_pci_vf_uninit(struct vfio_pci_core_device *vdev) { if (!vdev->vf_token) return; @@ -1845,7 +1845,7 @@ static void vfio_pci_vf_uninit(struct vfio_pci_device *vdev) kfree(vdev->vf_token); } -static int vfio_pci_vga_init(struct vfio_pci_device *vdev) +static int vfio_pci_vga_init(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; int ret; @@ -1860,7 +1860,7 @@ static int vfio_pci_vga_init(struct vfio_pci_device *vdev) return 0; } -static void vfio_pci_vga_uninit(struct vfio_pci_device *vdev) +static void vfio_pci_vga_uninit(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; @@ -1874,7 +1874,7 @@ static void vfio_pci_vga_uninit(struct vfio_pci_device *vdev) static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - struct vfio_pci_device *vdev; + struct vfio_pci_core_device *vdev; struct iommu_group *group; int ret; @@ -1978,7 +1978,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) static void vfio_pci_remove(struct pci_dev *pdev) { - struct vfio_pci_device *vdev = dev_get_drvdata(&pdev->dev); + struct vfio_pci_core_device *vdev = dev_get_drvdata(&pdev->dev); pci_disable_sriov(pdev); @@ -2002,14 +2002,14 @@ static void vfio_pci_remove(struct pci_dev *pdev) static pci_ers_result_t vfio_pci_aer_err_detected(struct pci_dev *pdev, pci_channel_state_t state) { - struct vfio_pci_device *vdev; + struct vfio_pci_core_device *vdev; struct vfio_device *device; device = vfio_device_get_from_dev(&pdev->dev); if (device == NULL) return PCI_ERS_RESULT_DISCONNECT; - vdev = container_of(device, struct vfio_pci_device, vdev); + vdev = container_of(device, struct vfio_pci_core_device, vdev); mutex_lock(&vdev->igate); @@ -2060,7 +2060,7 @@ static struct pci_driver vfio_pci_driver = { .err_handler = &vfio_err_handlers, }; -static bool vfio_dev_in_groups(struct vfio_pci_device *vdev, +static bool vfio_dev_in_groups(struct vfio_pci_core_device *vdev, struct vfio_pci_group_info *groups) { unsigned int i; @@ -2104,7 +2104,8 @@ vfio_pci_dev_set_resettable(struct vfio_device_set *dev_set) * reset, so any pci_dev will have the same outcomes for * pci_probe_reset_*() and pci_reset_bus(). */ - pdev = list_first_entry(&dev_set->device_list, struct vfio_pci_device, + pdev = list_first_entry(&dev_set->device_list, + struct vfio_pci_core_device, vdev.dev_set_list)->pdev; /* pci_reset_bus() is supported */ @@ -2126,16 +2127,17 @@ vfio_pci_dev_set_resettable(struct vfio_device_set *dev_set) static int vfio_pci_dev_set_hot_reset(struct vfio_device_set *dev_set, struct vfio_pci_group_info *groups) { - struct vfio_pci_device *cur_mem; - struct vfio_pci_device *cur_vma; - struct vfio_pci_device *cur; + struct vfio_pci_core_device *cur_mem; + struct vfio_pci_core_device *cur_vma; + struct vfio_pci_core_device *cur; struct pci_dev *pdev; bool is_mem = true; int ret; mutex_lock(&dev_set->lock); cur_mem = list_first_entry(&dev_set->device_list, - struct vfio_pci_device, vdev.dev_set_list); + struct vfio_pci_core_device, + vdev.dev_set_list); pdev = vfio_pci_dev_set_resettable(dev_set); if (!pdev) { @@ -2193,7 +2195,7 @@ static int vfio_pci_dev_set_hot_reset(struct vfio_device_set *dev_set, static bool vfio_pci_dev_set_needs_reset(struct vfio_device_set *dev_set) { - struct vfio_pci_device *cur; + struct vfio_pci_core_device *cur; bool needs_reset = false; list_for_each_entry(cur, &dev_set->device_list, vdev.dev_set_list) { @@ -2215,7 +2217,7 @@ static bool vfio_pci_dev_set_needs_reset(struct vfio_device_set *dev_set) */ static bool vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set) { - struct vfio_pci_device *cur; + struct vfio_pci_core_device *cur; struct pci_dev *pdev; int ret; diff --git a/drivers/vfio/pci/vfio_pci_core.h b/drivers/vfio/pci/vfio_pci_core.h index ef26e781961d..2ceaa6e4ca25 100644 --- a/drivers/vfio/pci/vfio_pci_core.h +++ b/drivers/vfio/pci/vfio_pci_core.h @@ -33,7 +33,7 @@ struct vfio_pci_ioeventfd { struct list_head next; - struct vfio_pci_device *vdev; + struct vfio_pci_core_device *vdev; struct virqfd *virqfd; void __iomem *addr; uint64_t data; @@ -52,18 +52,18 @@ struct vfio_pci_irq_ctx { struct irq_bypass_producer producer; }; -struct vfio_pci_device; +struct vfio_pci_core_device; struct vfio_pci_region; struct vfio_pci_regops { - ssize_t (*rw)(struct vfio_pci_device *vdev, char __user *buf, + ssize_t (*rw)(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite); - void (*release)(struct vfio_pci_device *vdev, + void (*release)(struct vfio_pci_core_device *vdev, struct vfio_pci_region *region); - int (*mmap)(struct vfio_pci_device *vdev, + int (*mmap)(struct vfio_pci_core_device *vdev, struct vfio_pci_region *region, struct vm_area_struct *vma); - int (*add_capability)(struct vfio_pci_device *vdev, + int (*add_capability)(struct vfio_pci_core_device *vdev, struct vfio_pci_region *region, struct vfio_info_cap *caps); }; @@ -94,7 +94,7 @@ struct vfio_pci_mmap_vma { struct list_head vma_next; }; -struct vfio_pci_device { +struct vfio_pci_core_device { struct vfio_device vdev; struct pci_dev *pdev; void __iomem *barmap[PCI_STD_NUM_BARS]; @@ -144,61 +144,61 @@ struct vfio_pci_device { #define is_irq_none(vdev) (!(is_intx(vdev) || is_msi(vdev) || is_msix(vdev))) #define irq_is(vdev, type) (vdev->irq_type == type) -extern void vfio_pci_intx_mask(struct vfio_pci_device *vdev); -extern void vfio_pci_intx_unmask(struct vfio_pci_device *vdev); +extern void vfio_pci_intx_mask(struct vfio_pci_core_device *vdev); +extern void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev); -extern int vfio_pci_set_irqs_ioctl(struct vfio_pci_device *vdev, +extern int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev, uint32_t flags, unsigned index, unsigned start, unsigned count, void *data); -extern ssize_t vfio_pci_config_rw(struct vfio_pci_device *vdev, +extern ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite); -extern ssize_t vfio_pci_bar_rw(struct vfio_pci_device *vdev, char __user *buf, +extern ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite); -extern ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf, +extern ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite); -extern long vfio_pci_ioeventfd(struct vfio_pci_device *vdev, loff_t offset, +extern long vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset, uint64_t data, int count, int fd); extern int vfio_pci_init_perm_bits(void); extern void vfio_pci_uninit_perm_bits(void); -extern int vfio_config_init(struct vfio_pci_device *vdev); -extern void vfio_config_free(struct vfio_pci_device *vdev); +extern int vfio_config_init(struct vfio_pci_core_device *vdev); +extern void vfio_config_free(struct vfio_pci_core_device *vdev); -extern int vfio_pci_register_dev_region(struct vfio_pci_device *vdev, +extern int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev, unsigned int type, unsigned int subtype, const struct vfio_pci_regops *ops, size_t size, u32 flags, void *data); -extern int vfio_pci_set_power_state(struct vfio_pci_device *vdev, +extern int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev, pci_power_t state); -extern bool __vfio_pci_memory_enabled(struct vfio_pci_device *vdev); -extern void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_device +extern bool __vfio_pci_memory_enabled(struct vfio_pci_core_device *vdev); +extern void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_core_device *vdev); -extern u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_device *vdev); -extern void vfio_pci_memory_unlock_and_restore(struct vfio_pci_device *vdev, +extern u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_core_device *vdev); +extern void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev, u16 cmd); #ifdef CONFIG_VFIO_PCI_IGD -extern int vfio_pci_igd_init(struct vfio_pci_device *vdev); +extern int vfio_pci_igd_init(struct vfio_pci_core_device *vdev); #else -static inline int vfio_pci_igd_init(struct vfio_pci_device *vdev) +static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) { return -ENODEV; } #endif #ifdef CONFIG_S390 -extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev, +extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps); #else -static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev, +static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps) { return -ENODEV; diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c index d57c409b4033..a324ca7e6b5a 100644 --- a/drivers/vfio/pci/vfio_pci_igd.c +++ b/drivers/vfio/pci/vfio_pci_igd.c @@ -25,8 +25,9 @@ #define OPREGION_RVDS 0x3c2 #define OPREGION_VERSION 0x16 -static ssize_t vfio_pci_igd_rw(struct vfio_pci_device *vdev, char __user *buf, - size_t count, loff_t *ppos, bool iswrite) +static ssize_t vfio_pci_igd_rw(struct vfio_pci_core_device *vdev, + char __user *buf, size_t count, loff_t *ppos, + bool iswrite) { unsigned int i = VFIO_PCI_OFFSET_TO_INDEX(*ppos) - VFIO_PCI_NUM_REGIONS; void *base = vdev->region[i].data; @@ -45,7 +46,7 @@ static ssize_t vfio_pci_igd_rw(struct vfio_pci_device *vdev, char __user *buf, return count; } -static void vfio_pci_igd_release(struct vfio_pci_device *vdev, +static void vfio_pci_igd_release(struct vfio_pci_core_device *vdev, struct vfio_pci_region *region) { memunmap(region->data); @@ -56,7 +57,7 @@ static const struct vfio_pci_regops vfio_pci_igd_regops = { .release = vfio_pci_igd_release, }; -static int vfio_pci_igd_opregion_init(struct vfio_pci_device *vdev) +static int vfio_pci_igd_opregion_init(struct vfio_pci_core_device *vdev) { __le32 *dwordp = (__le32 *)(vdev->vconfig + OPREGION_PCI_ADDR); u32 addr, size; @@ -160,7 +161,7 @@ static int vfio_pci_igd_opregion_init(struct vfio_pci_device *vdev) return ret; } -static ssize_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev, +static ssize_t vfio_pci_igd_cfg_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) { @@ -253,7 +254,7 @@ static ssize_t vfio_pci_igd_cfg_rw(struct vfio_pci_device *vdev, return count; } -static void vfio_pci_igd_cfg_release(struct vfio_pci_device *vdev, +static void vfio_pci_igd_cfg_release(struct vfio_pci_core_device *vdev, struct vfio_pci_region *region) { struct pci_dev *pdev = region->data; @@ -266,7 +267,7 @@ static const struct vfio_pci_regops vfio_pci_igd_cfg_regops = { .release = vfio_pci_igd_cfg_release, }; -static int vfio_pci_igd_cfg_init(struct vfio_pci_device *vdev) +static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev) { struct pci_dev *host_bridge, *lpc_bridge; int ret; @@ -314,7 +315,7 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_device *vdev) return 0; } -int vfio_pci_igd_init(struct vfio_pci_device *vdev) +int vfio_pci_igd_init(struct vfio_pci_core_device *vdev) { int ret; diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index df1e8c8c274c..945ddbdf4d11 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -27,13 +27,13 @@ */ static void vfio_send_intx_eventfd(void *opaque, void *unused) { - struct vfio_pci_device *vdev = opaque; + struct vfio_pci_core_device *vdev = opaque; if (likely(is_intx(vdev) && !vdev->virq_disabled)) eventfd_signal(vdev->ctx[0].trigger, 1); } -void vfio_pci_intx_mask(struct vfio_pci_device *vdev) +void vfio_pci_intx_mask(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; unsigned long flags; @@ -73,7 +73,7 @@ void vfio_pci_intx_mask(struct vfio_pci_device *vdev) */ static int vfio_pci_intx_unmask_handler(void *opaque, void *unused) { - struct vfio_pci_device *vdev = opaque; + struct vfio_pci_core_device *vdev = opaque; struct pci_dev *pdev = vdev->pdev; unsigned long flags; int ret = 0; @@ -107,7 +107,7 @@ static int vfio_pci_intx_unmask_handler(void *opaque, void *unused) return ret; } -void vfio_pci_intx_unmask(struct vfio_pci_device *vdev) +void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev) { if (vfio_pci_intx_unmask_handler(vdev, NULL) > 0) vfio_send_intx_eventfd(vdev, NULL); @@ -115,7 +115,7 @@ void vfio_pci_intx_unmask(struct vfio_pci_device *vdev) static irqreturn_t vfio_intx_handler(int irq, void *dev_id) { - struct vfio_pci_device *vdev = dev_id; + struct vfio_pci_core_device *vdev = dev_id; unsigned long flags; int ret = IRQ_NONE; @@ -139,7 +139,7 @@ static irqreturn_t vfio_intx_handler(int irq, void *dev_id) return ret; } -static int vfio_intx_enable(struct vfio_pci_device *vdev) +static int vfio_intx_enable(struct vfio_pci_core_device *vdev) { if (!is_irq_none(vdev)) return -EINVAL; @@ -168,7 +168,7 @@ static int vfio_intx_enable(struct vfio_pci_device *vdev) return 0; } -static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd) +static int vfio_intx_set_signal(struct vfio_pci_core_device *vdev, int fd) { struct pci_dev *pdev = vdev->pdev; unsigned long irqflags = IRQF_SHARED; @@ -223,7 +223,7 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd) return 0; } -static void vfio_intx_disable(struct vfio_pci_device *vdev) +static void vfio_intx_disable(struct vfio_pci_core_device *vdev) { vfio_virqfd_disable(&vdev->ctx[0].unmask); vfio_virqfd_disable(&vdev->ctx[0].mask); @@ -244,7 +244,7 @@ static irqreturn_t vfio_msihandler(int irq, void *arg) return IRQ_HANDLED; } -static int vfio_msi_enable(struct vfio_pci_device *vdev, int nvec, bool msix) +static int vfio_msi_enable(struct vfio_pci_core_device *vdev, int nvec, bool msix) { struct pci_dev *pdev = vdev->pdev; unsigned int flag = msix ? PCI_IRQ_MSIX : PCI_IRQ_MSI; @@ -285,7 +285,7 @@ static int vfio_msi_enable(struct vfio_pci_device *vdev, int nvec, bool msix) return 0; } -static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, +static int vfio_msi_set_vector_signal(struct vfio_pci_core_device *vdev, int vector, int fd, bool msix) { struct pci_dev *pdev = vdev->pdev; @@ -364,7 +364,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, return 0; } -static int vfio_msi_set_block(struct vfio_pci_device *vdev, unsigned start, +static int vfio_msi_set_block(struct vfio_pci_core_device *vdev, unsigned start, unsigned count, int32_t *fds, bool msix) { int i, j, ret = 0; @@ -385,7 +385,7 @@ static int vfio_msi_set_block(struct vfio_pci_device *vdev, unsigned start, return ret; } -static void vfio_msi_disable(struct vfio_pci_device *vdev, bool msix) +static void vfio_msi_disable(struct vfio_pci_core_device *vdev, bool msix) { struct pci_dev *pdev = vdev->pdev; int i; @@ -417,7 +417,7 @@ static void vfio_msi_disable(struct vfio_pci_device *vdev, bool msix) /* * IOCTL support */ -static int vfio_pci_set_intx_unmask(struct vfio_pci_device *vdev, +static int vfio_pci_set_intx_unmask(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { @@ -444,7 +444,7 @@ static int vfio_pci_set_intx_unmask(struct vfio_pci_device *vdev, return 0; } -static int vfio_pci_set_intx_mask(struct vfio_pci_device *vdev, +static int vfio_pci_set_intx_mask(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { @@ -464,7 +464,7 @@ static int vfio_pci_set_intx_mask(struct vfio_pci_device *vdev, return 0; } -static int vfio_pci_set_intx_trigger(struct vfio_pci_device *vdev, +static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { @@ -507,7 +507,7 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_device *vdev, return 0; } -static int vfio_pci_set_msi_trigger(struct vfio_pci_device *vdev, +static int vfio_pci_set_msi_trigger(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { @@ -613,7 +613,7 @@ static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx, return -EINVAL; } -static int vfio_pci_set_err_trigger(struct vfio_pci_device *vdev, +static int vfio_pci_set_err_trigger(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { @@ -624,7 +624,7 @@ static int vfio_pci_set_err_trigger(struct vfio_pci_device *vdev, count, flags, data); } -static int vfio_pci_set_req_trigger(struct vfio_pci_device *vdev, +static int vfio_pci_set_req_trigger(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { @@ -635,11 +635,11 @@ static int vfio_pci_set_req_trigger(struct vfio_pci_device *vdev, count, flags, data); } -int vfio_pci_set_irqs_ioctl(struct vfio_pci_device *vdev, uint32_t flags, +int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev, uint32_t flags, unsigned index, unsigned start, unsigned count, void *data) { - int (*func)(struct vfio_pci_device *vdev, unsigned index, + int (*func)(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) = NULL; diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c index 667e82726e75..8fff4689dd44 100644 --- a/drivers/vfio/pci/vfio_pci_rdwr.c +++ b/drivers/vfio/pci/vfio_pci_rdwr.c @@ -38,7 +38,7 @@ #define vfio_iowrite8 iowrite8 #define VFIO_IOWRITE(size) \ -static int vfio_pci_iowrite##size(struct vfio_pci_device *vdev, \ +static int vfio_pci_iowrite##size(struct vfio_pci_core_device *vdev, \ bool test_mem, u##size val, void __iomem *io) \ { \ if (test_mem) { \ @@ -65,7 +65,7 @@ VFIO_IOWRITE(64) #endif #define VFIO_IOREAD(size) \ -static int vfio_pci_ioread##size(struct vfio_pci_device *vdev, \ +static int vfio_pci_ioread##size(struct vfio_pci_core_device *vdev, \ bool test_mem, u##size *val, void __iomem *io) \ { \ if (test_mem) { \ @@ -94,7 +94,7 @@ VFIO_IOREAD(32) * reads with -1. This is intended for handling MSI-X vector tables and * leftover space for ROM BARs. */ -static ssize_t do_io_rw(struct vfio_pci_device *vdev, bool test_mem, +static ssize_t do_io_rw(struct vfio_pci_core_device *vdev, bool test_mem, void __iomem *io, char __user *buf, loff_t off, size_t count, size_t x_start, size_t x_end, bool iswrite) @@ -200,7 +200,7 @@ static ssize_t do_io_rw(struct vfio_pci_device *vdev, bool test_mem, return done; } -static int vfio_pci_setup_barmap(struct vfio_pci_device *vdev, int bar) +static int vfio_pci_setup_barmap(struct vfio_pci_core_device *vdev, int bar) { struct pci_dev *pdev = vdev->pdev; int ret; @@ -224,7 +224,7 @@ static int vfio_pci_setup_barmap(struct vfio_pci_device *vdev, int bar) return 0; } -ssize_t vfio_pci_bar_rw(struct vfio_pci_device *vdev, char __user *buf, +ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) { struct pci_dev *pdev = vdev->pdev; @@ -288,7 +288,7 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_device *vdev, char __user *buf, return done; } -ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf, +ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) { int ret; @@ -384,7 +384,7 @@ static void vfio_pci_ioeventfd_do_write(struct vfio_pci_ioeventfd *ioeventfd, static int vfio_pci_ioeventfd_handler(void *opaque, void *unused) { struct vfio_pci_ioeventfd *ioeventfd = opaque; - struct vfio_pci_device *vdev = ioeventfd->vdev; + struct vfio_pci_core_device *vdev = ioeventfd->vdev; if (ioeventfd->test_mem) { if (!down_read_trylock(&vdev->memory_lock)) @@ -410,7 +410,7 @@ static void vfio_pci_ioeventfd_thread(void *opaque, void *unused) vfio_pci_ioeventfd_do_write(ioeventfd, ioeventfd->test_mem); } -long vfio_pci_ioeventfd(struct vfio_pci_device *vdev, loff_t offset, +long vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset, uint64_t data, int count, int fd) { struct pci_dev *pdev = vdev->pdev; diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index ecae0c3d95a0..2ffbdc11f089 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -114,7 +114,7 @@ static int zpci_pfip_cap(struct zpci_dev *zdev, struct vfio_info_cap *caps) /* * Add all supported capabilities to the VFIO_DEVICE_GET_INFO capability chain. */ -int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev, +int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, struct vfio_info_cap *caps) { struct zpci_dev *zdev = to_zpci(vdev->pdev); From patchwork Wed Aug 25 13:51:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44C40C25AEB for ; Wed, 25 Aug 2021 13:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DD9761214 for ; Wed, 25 Aug 2021 13:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241510AbhHYNxJ (ORCPT ); Wed, 25 Aug 2021 09:53:09 -0400 Received: from mail-dm6nam12on2065.outbound.protection.outlook.com ([40.107.243.65]:52449 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241482AbhHYNxD (ORCPT ); Wed, 25 Aug 2021 09:53:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8/3w+jqAm/RM/luMAuYQ96WL+ZGtxrFhKPkMolfcdyyrOjEt9ke91F/Pms2GwsLKzw66uh7pdpL+LCdfvqPv+SE8JLMyKD2YY5ibHyfjOR8arrbBvOmywu8fR85fOGGbCTZftDmHawA6tgPnEttLH+661VRUpE6LzO+Gh5opsUCataN+VxAAZs8OjkjAu3pk5DqMdgvwyIZKA6yFc9INRysHah4bjxpRwMFL2XDo0AAmb41XAGJGhjZbyKHONuLxL7aABE1O0YFwCF2yt3FDarbHjjk/MXCOGSB3I+vsYnRxbd5Cn9sVKw6SHBabhnMIA+7ygMWLsSmUt/BiJSekg== 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-SenderADCheck; bh=fk6eiJRzhHqxXMmQf+G6er3GAE5IGBFw1AxsURvDILY=; b=WXdcTh6rtoUCMNYLx5Fn0028iUqfQA0ap3CzD6U2XPEw7SB29/knZpzlV8hqMJMdjLDFpVez6O5quUjSB6MJxmPUKWM6E0xr+Icl2ERHSzTZStuPi7l7mc+UjeYM5yDHuBMveaKpiAeWqh86CgmziNbuavD1OQeYI8zo1kcXp69PsZ3c/mLmdu7CaoSkaClYLS29a6I9kJUtZzjMa9S+0mFctETKSEed3xAsYmgmMqSHr5zJgNyZt1eSP7L9eTrdbOd8bwCuks/PvRsV1ac3xJgi3fk5t9IgEQiuwjcq+xYt8N8hCqHd9+O+IZaGsqmgjZxV4V4XpuyNCWaoPLKDAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fk6eiJRzhHqxXMmQf+G6er3GAE5IGBFw1AxsURvDILY=; b=OskupZFQ/wszM2nBkZFCSacqVCkApzP02peteb3pKc+b8dyX3Mv6k6TkXurgQ7XTS+c8JxuWOQVTS5lrXY0W9tACVjUmQIRzzi33jYHJjXT9Hhm5zId5P9z5FhhxFZcwaXiYfYvxKile0HM6Uwz0i7OkB4kpWC96N2Z2s4vSmY0F3eGDmcPRYh4ZN2X9cIouPkouGdzaeSFrC4TQKKeXS0NvxAy+KLPzw46yx0thHYjxFRfiUA7ceoYF4NSNDEt9Li6at4X9Q547jMrMkyxDiQ3SF769s30tGkRdZHcuzac2MfBK97c+BGzeoH/gTasZUirJvrMb5c7LsWEFWXCXoQ== Received: from CO1PR15CA0109.namprd15.prod.outlook.com (2603:10b6:101:21::29) by MWHPR12MB1407.namprd12.prod.outlook.com (2603:10b6:300:15::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.19; Wed, 25 Aug 2021 13:52:16 +0000 Received: from CO1NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:101:21:cafe::42) by CO1PR15CA0109.outlook.office365.com (2603:10b6:101:21::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Wed, 25 Aug 2021 13:52:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT036.mail.protection.outlook.com (10.13.174.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:15 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 06:52:14 -0700 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:10 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 04/13] vfio/pci: Rename ops functions to fit core namings Date: Wed, 25 Aug 2021 16:51:30 +0300 Message-ID: <20210825135139.79034-5-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 693e6453-8fcf-47fd-8406-08d967cf8c60 X-MS-TrafficTypeDiagnostic: MWHPR12MB1407: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eX+t6Cx0LYSFZVqhuerTVP2ieiHyvkTXu4659i5BjL78gZbAHHCoS6r9iKOce3uo2vgrkdp7L0Dxo+iBBfgLJL094N3uaeatu08xI9AvPIHu4VapONtD9K0JFzS3wZDh3pJjUPGRZ4wpwrXX2Ikr49J3r3nBmzkE/Q3S6wJ01UF0f3HkSvTUHi/nVJ9QbSpivJmZX8dRIDBzsu3O+gFsJfuVI6z885PhYHVqsmgtKW2Jh23pFEvKuT6c1A5e0a27LSiqIBIk5RRWZIha5s14uvkeaK3xXj+Qx4QLcvYiUrWKLwp59Se1tU58iCPjVWwKvaeH5pcgUSo7YSD+oEAF0uo3XPE29VvCyh/g2s2I6Ls5F366mn8HIUvd7x7YKLGmCnQBgmgsw/2jUAAzYa7Bq11kCD1F2OvQt+t0p6ybdH8iMG3njI2Kc8vC7DnwAneaoNGZKU/3mNIDhgxadtpuVdnU06X15AXPXnVMJ3CmhA0JlXr/BQXSIluVmatfOe8OjjWIX1l4TxZspmZ1KDIyRX71Uj6Db23F3vAMYqTMDlpaD3rrApzgvPYxpWHd4a/aRQlwQog8Cjg5AphHSCMGA632AOQ8G3Tcd+doncEKdlhwFrQFMwBGoFK55LD8GyGVueQfeiD8XTt+bBIbS8q3Mzfxylr71vldgW3Kc49R8cLAtuKolFKbidrxUnHsEf6sDQWOB5nHO3eG1Mii/JHzVG9+5orvu8i2tHpp04ak2CU= X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(8676002)(1076003)(82310400003)(83380400001)(2906002)(4326008)(7636003)(186003)(8936002)(7696005)(508600001)(356005)(86362001)(70206006)(7416002)(426003)(54906003)(2616005)(107886003)(36756003)(70586007)(26005)(110136005)(6666004)(47076005)(36860700001)(316002)(336012)(5660300002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:15.8533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 693e6453-8fcf-47fd-8406-08d967cf8c60 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1407 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy This is another preparation patch for separating the vfio_pci driver to a subsystem driver and a generic pci driver. This patch doesn't change any logic. Signed-off-by: Max Gurtovoy Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/vfio_pci_core.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 2729479390a0..ee5c8fe2a324 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -533,7 +533,7 @@ static void vfio_pci_vf_token_user_add(struct vfio_pci_core_device *vdev, int va vfio_device_put(&pf_vdev->vdev); } -static void vfio_pci_close_device(struct vfio_device *core_vdev) +static void vfio_pci_core_close_device(struct vfio_device *core_vdev) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -554,7 +554,7 @@ static void vfio_pci_close_device(struct vfio_device *core_vdev) mutex_unlock(&vdev->igate); } -static int vfio_pci_open_device(struct vfio_device *core_vdev) +static int vfio_pci_core_open_device(struct vfio_device *core_vdev) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -727,7 +727,7 @@ int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev, return 0; } -static long vfio_pci_ioctl(struct vfio_device *core_vdev, +static long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, unsigned long arg) { struct vfio_pci_core_device *vdev = @@ -1302,7 +1302,7 @@ static ssize_t vfio_pci_rw(struct vfio_pci_core_device *vdev, char __user *buf, return -EINVAL; } -static ssize_t vfio_pci_read(struct vfio_device *core_vdev, char __user *buf, +static ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *buf, size_t count, loff_t *ppos) { struct vfio_pci_core_device *vdev = @@ -1314,7 +1314,7 @@ static ssize_t vfio_pci_read(struct vfio_device *core_vdev, char __user *buf, return vfio_pci_rw(vdev, buf, count, ppos, false); } -static ssize_t vfio_pci_write(struct vfio_device *core_vdev, const char __user *buf, +static ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *buf, size_t count, loff_t *ppos) { struct vfio_pci_core_device *vdev = @@ -1533,7 +1533,7 @@ static const struct vm_operations_struct vfio_pci_mmap_ops = { .fault = vfio_pci_mmap_fault, }; -static int vfio_pci_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma) +static int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1604,7 +1604,7 @@ static int vfio_pci_mmap(struct vfio_device *core_vdev, struct vm_area_struct *v return 0; } -static void vfio_pci_request(struct vfio_device *core_vdev, unsigned int count) +static void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1720,7 +1720,7 @@ static int vfio_pci_validate_vf_token(struct vfio_pci_core_device *vdev, #define VF_TOKEN_ARG "vf_token=" -static int vfio_pci_match(struct vfio_device *core_vdev, char *buf) +static int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1772,14 +1772,14 @@ static int vfio_pci_match(struct vfio_device *core_vdev, char *buf) static const struct vfio_device_ops vfio_pci_ops = { .name = "vfio-pci", - .open_device = vfio_pci_open_device, - .close_device = vfio_pci_close_device, - .ioctl = vfio_pci_ioctl, - .read = vfio_pci_read, - .write = vfio_pci_write, - .mmap = vfio_pci_mmap, - .request = vfio_pci_request, - .match = vfio_pci_match, + .open_device = vfio_pci_core_open_device, + .close_device = vfio_pci_core_close_device, + .ioctl = vfio_pci_core_ioctl, + .read = vfio_pci_core_read, + .write = vfio_pci_core_write, + .mmap = vfio_pci_core_mmap, + .request = vfio_pci_core_request, + .match = vfio_pci_core_match, }; static int vfio_pci_bus_notifier(struct notifier_block *nb, From patchwork Wed Aug 25 13:51:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A38B8C25AF0 for ; Wed, 25 Aug 2021 13:52:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D05D61183 for ; Wed, 25 Aug 2021 13:52:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241509AbhHYNxM (ORCPT ); Wed, 25 Aug 2021 09:53:12 -0400 Received: from mail-dm6nam10on2063.outbound.protection.outlook.com ([40.107.93.63]:59120 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240294AbhHYNxJ (ORCPT ); Wed, 25 Aug 2021 09:53:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BuylUnUKL+9dUk9GbCnyjgsNVvaO+92QJvHbKWFUZd5cNq3hupnduo9qCtEGTY3JoHOigD5j8ZHBTiFQoH7aDXkkLUqgsFZ+rbHdMNUz26oeMkQxuIaUZlseClBmmTzQQFKAg6RtAlA6rp8M5JFsEBTzoSod6nUm+ymFkqf0pIke7eyWN6s7aTTi4ONZPwWQR9GTw97NXE71oqwWIF0+4Lu3llHEboFz3XX7VJU4XinrIPvO0EXfxvde0MGPZveDMS3QWN40+xO2JNWlVHbIUYLfsG0DBel2iwnfPnn/i6K6zMHXUF6UD5/QODp3asAkwe11zvrIy2v1Zuf66+ZcEg== 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-SenderADCheck; bh=EA12dOSs+X500lgNhQm9waVsEnhHX7aMIyxRdvZyw+8=; b=Er9vG6FGv0UDa8UHRVWDiyZP9Zin6afYbRAXdn1ID+2rRwH5rfv5Oqg1AciDlMKWBA2C9PDz8COGsNIsKvS7bWDIoDmdG+IfccjRNmi4tUlIVr7VCOnuCRlfx+Z00IIA3VgDL6dww9SzcwaW2rS3fDKePjMOPDg/rGA12hXCJDVBVppygNs1LGsNBu/aG8qBr2lwlXodk2SQPI+aOZBfUp+GBHXLM5Zq/meuYFzCfq1fHCBbAKGQYSoyfJTB/pKeZu+hZ9Gk8NgOa8W6+rS2cdMB308+Z5T8XijDDSyLe9MV6GQouXo2sjOY7GNfn+tFRpkrlK4h1c/ClokoN+tyow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=markovi.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EA12dOSs+X500lgNhQm9waVsEnhHX7aMIyxRdvZyw+8=; b=tNHpCxG47eprM4B+KhSnq3rpeag0RzMjzSOgb+YbfgoZfiHoV1C4VbABu2ZKmrfRfnDf/y7Zp1ky4Hayl6NDyh5QDlSa8MFN32CHyRUJJ1UGLBuwnyDr0QpcPpxWfT9hWHqLy69kSk46LbCtYqY9+gbVI7ziStBgXwx+ZTf/T/bzFupKYX/znUJ080tWtQ3nD5y2HCD9+E55UsWYjwnPNqM2+jqunJ3WJAYTTpQEstmVAONPKl7j6ZGYzJq60y5bW7dvueANaRDLJ636XVaaAjXwUnympc0KiNaUs5I+TKOB6mvcRSeYud7Svokh/79WtVyRXE6OFo8oqgQSMunFpg== Received: from MWHPR17CA0087.namprd17.prod.outlook.com (2603:10b6:300:c2::25) by BYAPR12MB2677.namprd12.prod.outlook.com (2603:10b6:a03:69::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 13:52:21 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:300:c2:cafe::c3) by MWHPR17CA0087.outlook.office365.com (2603:10b6:300:c2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; markovi.net; dkim=none (message not signed) header.d=none;markovi.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:20 +0000 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:19 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:19 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:15 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 05/13] vfio/pci: Include vfio header in vfio_pci_core.h Date: Wed, 25 Aug 2021 16:51:31 +0300 Message-ID: <20210825135139.79034-6-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10a4c34b-4bdd-45fa-136a-08d967cf8f14 X-MS-TrafficTypeDiagnostic: BYAPR12MB2677: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KbZWxMXDw5wy9rvJTBbV1ZNKQqmk3KhymFEgy975fWZq+WnibKlqJ0oE0mZyRPQj9MQhpZaRo/JHrfyVJOqhdc/sSpdQI53A/Su1UFFe0v4xiIFOG9oGu7L5lDeCjJztVnFhxPavR9mhe4js9xUPJXrrlIPdzGmfME0QQoH6yn9LDwB7UMn/L5CukHyWf39wyIJDWENW12+L7aCYxCv3J5RNXnD+gFVWT2biMAupV3igDyHyfgjZRjlbyus7YkAWhn4pse+ydw7+rAgmPo0GkxwPn4cI9aeqqJboextdmlQBIBEdG9N7tZpZkSuRQkA3NH1lzR5TLB8NCSzaYE/5C5rNlo/Lraa29hwB/Si5bDugWKtyww+NkYow3cPj/UByV/3I9xlWZLW68iThoYRtHrrxJJzIwEpAGa3yz0d30KhuB1JUdayM4s4gEg+u0CHtzp/0Wg86Q56+5Ib6JqQgsHebqCyYlgUPym3f73CtfSOsquCTSP4Pr5UtBwHi4zx/kiGb/ayjWV5hxf478JdOdU1ewCwFerQLIv+cCZTpfpiFiupe3aEP/DJKBad8yEJt0e2nVCkjymkn+CGC+YmmA41j45KIuMb8QcRymW2zf3DP9B0A+/UQ1IiJ1ZzIZllPBoFzS4KMas31gTKxKioaOU48oklP9Qg8rbK3TyIyEx2PpBar9XXudty+K1+nuTDAr9guxcejAUnWWo5QZ+QDkK+VUoB5fP+rdRT1iZZQgXA= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(39860400002)(376002)(46966006)(36840700001)(2906002)(4326008)(36756003)(478600001)(2616005)(107886003)(7416002)(186003)(316002)(47076005)(1076003)(70586007)(7636003)(336012)(82310400003)(82740400003)(110136005)(54906003)(7696005)(83380400001)(6666004)(26005)(5660300002)(8676002)(8936002)(36906005)(70206006)(356005)(426003)(86362001)(36860700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:20.4875 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10a4c34b-4bdd-45fa-136a-08d967cf8f14 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2677 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy The vfio_device structure is embedded into the vfio_pci_core_device structure, so there is no reason for not including the header file in the vfio_pci_core header as well. Signed-off-by: Max Gurtovoy Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/vfio_pci_core.c | 1 - drivers/vfio/pci/vfio_pci_core.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index ee5c8fe2a324..94f062818e0c 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/vfio/pci/vfio_pci_core.h b/drivers/vfio/pci/vfio_pci_core.h index 2ceaa6e4ca25..17ad048752b6 100644 --- a/drivers/vfio/pci/vfio_pci_core.h +++ b/drivers/vfio/pci/vfio_pci_core.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include From patchwork Wed Aug 25 13:51:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCEB0C25AF2 for ; Wed, 25 Aug 2021 13:52:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C09C6610E8 for ; Wed, 25 Aug 2021 13:52:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241460AbhHYNxO (ORCPT ); Wed, 25 Aug 2021 09:53:14 -0400 Received: from mail-bn7nam10on2073.outbound.protection.outlook.com ([40.107.92.73]:2682 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241520AbhHYNxN (ORCPT ); Wed, 25 Aug 2021 09:53:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kvEn3veYeNWKjIompB0tWh7K2e9vGB2WZIHnfzxyniTIFrgqMBBZbu5RyLtNj4bM92/OTorTCyGQQAQLjysvmJHNbnhF3ZMQ4weQv/7u0Ted8naYehH6MzblbJw0KoLAH2i4Fy2DjtEG2PisiWm0HIOxoN+i8vBfg57JjixZ1CBUCUyewPu24FdJtawE23W9uxnB0bWhyUDeyPRaz3NBsLC+dcQKvYzfytLM/hiRunbad/9DyyplNgxn/ogEVKgh0GOVFq841qsryPgXZHfAnPEvxPHW/QHzaluQ6c/J53RkcYmPHtsQFfEljFzQ0l6iLODuIGSC+QatuaZ2yoQONw== 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-SenderADCheck; bh=acghMo7AeJTZCvdKkOWB71Ju2N0iDpebGpBRFBII36s=; b=mPYwD0Oqd349HjI/d5ze86dOJSy65Ae70Ue93JoL6SHeYN/NvvTcb+TCJdSAUBghqAaWRIicmhPXticzpxjZBma/7E103c2k8TAVn8ezoNrvDBySJ6MgGNEX0O2CwimcZfkbnPoXpJW88OZON6g7iBMIs9yP8srzdTez4bhu3NgQYPQ9U3vXrIi8OqNLE0+lNHpwg55xUJEyGjutJGnrouNTcJvrL8Ysfpcgjp41Pu+3jb3KmcMNDP3jS9zTsyl7YFp0IfoWVqPym+G5g6/KNhY5eBjYOmuqaYYTNXVNjpXb84pZiEehVToCXLjnn9E7vRnWqkh/YZiINL8XgYXfaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=acghMo7AeJTZCvdKkOWB71Ju2N0iDpebGpBRFBII36s=; b=JO4wFcVGet9uReKLklNz8IlFKhUsjLiQrW5MldxgylUgdK4eMFBjIidfxtAsKesOeUjd7AeHewZL1CHgywn8VcV/jCxEEa1RrTJXOwMaDzgrCQiEJ8KkBIWwCPe+yZ/lyuUdr36sRqbveZC05/SSo+TUuHO6C8ZQGi0UpAXm2cGWZx4jumPxN+x+P0V/y5GX/3lRB0TXCsFSDcQQWmzSylBNp0txKd8KVNZaqlZP3Fxkilkf+/W9wa9ieU4ux67+y0YTNYAVpnCeNqYEJZ5qecAIwHDzA8uQa7RxZPaMUUK4ev3G5GQP2WXJ+LAmk8xjHZA76tU/mm0ws+LxKcUb7w== Received: from BN9PR03CA0764.namprd03.prod.outlook.com (2603:10b6:408:13a::19) by MN2PR12MB2990.namprd12.prod.outlook.com (2603:10b6:208:cc::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 13:52:24 +0000 Received: from BN8NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13a:cafe::b9) by BN9PR03CA0764.outlook.office365.com (2603:10b6:408:13a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by BN8NAM11FT035.mail.protection.outlook.com (10.13.177.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:24 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:23 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:19 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 06/13] vfio/pci: Split the pci_driver code out of vfio_pci_core.c Date: Wed, 25 Aug 2021 16:51:32 +0300 Message-ID: <20210825135139.79034-7-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad21aa42-655f-4f76-7524-08d967cf918a X-MS-TrafficTypeDiagnostic: MN2PR12MB2990: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YxWT+f7MECMhiFvZX7Md14D9ixrdiaEwlTXi2cOYvhqSkOs/3gsPUTPRBW+hOUtrWyPR0nR4yhSXmEALkI1djq/Kaq/kL+mISGdAds73nBVKettkobEHgRVwQ+x+wfiwR8XaFgbo3uaG9J9NAXcbfj7PD/g4NocJwD1xc3dPB9uC4IKxchqW6N6ImkHM2uAPSL2HiBs+i5Vv7RlRiNzCP7Q8u774bllhJBa0ETDdKWK93CR9VSlQqZtctst5WtJgDbiIUXWciWVxzYvyLJyxKv9ZOFP8jMFb3lGOspBfnJWU8P+u7cqYLqtneAMv0FCouYCTDRMICxRjJ2mCKU5ncSFB6ZLaeZo1Iw2Lksh7BFGbMaKoGXnpMVmmXH2tetITuCsPK+WDWjy2T0m1hIfqHX5b9oYvGkea+8sBkDQzm3RWJJsgTSwmT8qg/yZc1sVGZQtqPKXOGCT0I6GSqyYEgkGHthVjDmHwQEwH1WtSAEJNaLrDiO5wEuFbMTWQXDt3/M6rVIsqVfDFrIrecGwq3LzymQwenulRL53fSrNadAU1DE3gmoGKHhxEa31iAsGCHDYgWc06K2qOvrh2Ig9d7zU3SgBKIAA9glpQlpCo/JHNPLFuD95Pv6ICD2zCbugW5NiBk1E4A4qwE4L2cWfMlo7GYFZ3AFTPWL3l1Ev22Tf7hf6wbS62UAh4r1SqaleC3zbdLoGdtb6FSyBxlVGJkA1UqYY9L/5xthIXSSIyzhg= X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(136003)(39860400002)(376002)(346002)(396003)(36840700001)(46966006)(2616005)(316002)(36860700001)(36906005)(54906003)(86362001)(110136005)(6666004)(82310400003)(1076003)(4326008)(70206006)(70586007)(107886003)(426003)(336012)(356005)(30864003)(7416002)(5660300002)(8936002)(7636003)(36756003)(478600001)(83380400001)(82740400003)(47076005)(2906002)(7696005)(26005)(186003)(8676002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:24.3479 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad21aa42-655f-4f76-7524-08d967cf918a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2990 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy Split the vfio_pci driver into two logical parts, the 'struct pci_driver' (vfio_pci.c) which implements "Generic VFIO support for any PCI device" and a library of code (vfio_pci_core.c) that helps implementing a struct vfio_device on top of a PCI device. vfio_pci.ko continues to present the same interface under sysfs and this change should have no functional impact. Following patches will turn vfio_pci and vfio_pci_core into a separate module. This is a preparation for allowing another module to provide the pci_driver and allow that module to customize how VFIO is setup, inject its own operations, and easily extend vendor specific functionality. At this point the vfio_pci_core still contains a lot of vfio_pci functionality mixed into it. Following patches will move more of the large scale items out, but another cleanup series will be needed to get everything. Signed-off-by: Max Gurtovoy Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/Makefile | 2 +- drivers/vfio/pci/vfio_pci.c | 223 +++++++++++++++++++++++++ drivers/vfio/pci/vfio_pci_core.c | 271 +++++++------------------------ drivers/vfio/pci/vfio_pci_core.h | 23 +++ 4 files changed, 304 insertions(+), 215 deletions(-) create mode 100644 drivers/vfio/pci/vfio_pci.c diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile index 66a40488e967..8aa517b4b671 100644 --- a/drivers/vfio/pci/Makefile +++ b/drivers/vfio/pci/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -vfio-pci-y := vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o +vfio-pci-y := vfio_pci.o vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o vfio-pci-$(CONFIG_S390) += vfio_pci_zdev.o diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c new file mode 100644 index 000000000000..4e31bd3001ad --- /dev/null +++ b/drivers/vfio/pci/vfio_pci.c @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved + * + * Copyright (C) 2012 Red Hat, Inc. All rights reserved. + * Author: Alex Williamson + * + * Derived from original vfio: + * Copyright 2010 Cisco Systems, Inc. All rights reserved. + * Author: Tom Lyon, pugs@cisco.com + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vfio_pci_core.h" + +#define DRIVER_AUTHOR "Alex Williamson " +#define DRIVER_DESC "VFIO PCI - User Level meta-driver" + +static char ids[1024] __initdata; +module_param_string(ids, ids, sizeof(ids), 0); +MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the vfio driver, format is \"vendor:device[:subvendor[:subdevice[:class[:class_mask]]]]\" and multiple comma separated entries can be specified"); + +static bool enable_sriov; +#ifdef CONFIG_PCI_IOV +module_param(enable_sriov, bool, 0644); +MODULE_PARM_DESC(enable_sriov, "Enable support for SR-IOV configuration. Enabling SR-IOV on a PF typically requires support of the userspace PF driver, enabling VFs without such support may result in non-functional VFs or PF."); +#endif + +static bool disable_denylist; +module_param(disable_denylist, bool, 0444); +MODULE_PARM_DESC(disable_denylist, "Disable use of device denylist. Disabling the denylist allows binding to devices with known errata that may lead to exploitable stability or security issues when accessed by untrusted users."); + +static bool vfio_pci_dev_in_denylist(struct pci_dev *pdev) +{ + switch (pdev->vendor) { + case PCI_VENDOR_ID_INTEL: + switch (pdev->device) { + case PCI_DEVICE_ID_INTEL_QAT_C3XXX: + case PCI_DEVICE_ID_INTEL_QAT_C3XXX_VF: + case PCI_DEVICE_ID_INTEL_QAT_C62X: + case PCI_DEVICE_ID_INTEL_QAT_C62X_VF: + case PCI_DEVICE_ID_INTEL_QAT_DH895XCC: + case PCI_DEVICE_ID_INTEL_QAT_DH895XCC_VF: + return true; + default: + return false; + } + } + + return false; +} + +static bool vfio_pci_is_denylisted(struct pci_dev *pdev) +{ + if (!vfio_pci_dev_in_denylist(pdev)) + return false; + + if (disable_denylist) { + pci_warn(pdev, + "device denylist disabled - allowing device %04x:%04x.\n", + pdev->vendor, pdev->device); + return false; + } + + pci_warn(pdev, "%04x:%04x exists in vfio-pci device denylist, driver probing disallowed.\n", + pdev->vendor, pdev->device); + + return true; +} + +static const struct vfio_device_ops vfio_pci_ops = { + .name = "vfio-pci", + .open_device = vfio_pci_core_open_device, + .close_device = vfio_pci_core_close_device, + .ioctl = vfio_pci_core_ioctl, + .read = vfio_pci_core_read, + .write = vfio_pci_core_write, + .mmap = vfio_pci_core_mmap, + .request = vfio_pci_core_request, + .match = vfio_pci_core_match, +}; + +static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct vfio_pci_core_device *vdev; + int ret; + + if (vfio_pci_is_denylisted(pdev)) + return -EINVAL; + + vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); + if (!vdev) + return -ENOMEM; + vfio_pci_core_init_device(vdev, pdev, &vfio_pci_ops); + + ret = vfio_pci_core_register_device(vdev); + if (ret) + goto out_free; + return 0; + +out_free: + vfio_pci_core_uninit_device(vdev); + kfree(vdev); + return ret; +} + +static void vfio_pci_remove(struct pci_dev *pdev) +{ + struct vfio_pci_core_device *vdev = dev_get_drvdata(&pdev->dev); + + vfio_pci_core_unregister_device(vdev); + vfio_pci_core_uninit_device(vdev); + kfree(vdev); +} + +static int vfio_pci_sriov_configure(struct pci_dev *pdev, int nr_virtfn) +{ + if (!enable_sriov) + return -ENOENT; + + return vfio_pci_core_sriov_configure(pdev, nr_virtfn); +} + +static struct pci_driver vfio_pci_driver = { + .name = "vfio-pci", + .id_table = NULL, /* only dynamic ids */ + .probe = vfio_pci_probe, + .remove = vfio_pci_remove, + .sriov_configure = vfio_pci_sriov_configure, + .err_handler = &vfio_pci_core_err_handlers, +}; + +static void __init vfio_pci_fill_ids(void) +{ + char *p, *id; + int rc; + + /* no ids passed actually */ + if (ids[0] == '\0') + return; + + /* add ids specified in the module parameter */ + p = ids; + while ((id = strsep(&p, ","))) { + unsigned int vendor, device, subvendor = PCI_ANY_ID, + subdevice = PCI_ANY_ID, class = 0, class_mask = 0; + int fields; + + if (!strlen(id)) + continue; + + fields = sscanf(id, "%x:%x:%x:%x:%x:%x", + &vendor, &device, &subvendor, &subdevice, + &class, &class_mask); + + if (fields < 2) { + pr_warn("invalid id string \"%s\"\n", id); + continue; + } + + rc = pci_add_dynid(&vfio_pci_driver, vendor, device, + subvendor, subdevice, class, class_mask, 0); + if (rc) + pr_warn("failed to add dynamic id [%04x:%04x[%04x:%04x]] class %#08x/%08x (%d)\n", + vendor, device, subvendor, subdevice, + class, class_mask, rc); + else + pr_info("add [%04x:%04x[%04x:%04x]] class %#08x/%08x\n", + vendor, device, subvendor, subdevice, + class, class_mask); + } +} + +static int __init vfio_pci_init(void) +{ + int ret; + + ret = vfio_pci_core_init(); + if (ret) + return ret; + + /* Register and scan for devices */ + ret = pci_register_driver(&vfio_pci_driver); + if (ret) + goto out; + + vfio_pci_fill_ids(); + + if (disable_denylist) + pr_warn("device denylist disabled.\n"); + + return 0; + +out: + vfio_pci_core_cleanup(); + return ret; +} +module_init(vfio_pci_init); + +static void __exit vfio_pci_cleanup(void) +{ + pci_unregister_driver(&vfio_pci_driver); + vfio_pci_core_cleanup(); +} +module_exit(vfio_pci_cleanup); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 94f062818e0c..c0d71f72d4f1 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -8,8 +8,6 @@ * Author: Tom Lyon, pugs@cisco.com */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - #include #include #include @@ -29,14 +27,6 @@ #include "vfio_pci_core.h" -#define DRIVER_VERSION "0.2" -#define DRIVER_AUTHOR "Alex Williamson " -#define DRIVER_DESC "VFIO PCI - User Level meta-driver" - -static char ids[1024] __initdata; -module_param_string(ids, ids, sizeof(ids), 0); -MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the vfio driver, format is \"vendor:device[:subvendor[:subdevice[:class[:class_mask]]]]\" and multiple comma separated entries can be specified"); - static bool nointxmask; module_param_named(nointxmask, nointxmask, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(nointxmask, @@ -53,16 +43,6 @@ module_param(disable_idle_d3, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(disable_idle_d3, "Disable using the PCI D3 low power state for idle, unused devices"); -static bool enable_sriov; -#ifdef CONFIG_PCI_IOV -module_param(enable_sriov, bool, 0644); -MODULE_PARM_DESC(enable_sriov, "Enable support for SR-IOV configuration. Enabling SR-IOV on a PF typically requires support of the userspace PF driver, enabling VFs without such support may result in non-functional VFs or PF."); -#endif - -static bool disable_denylist; -module_param(disable_denylist, bool, 0444); -MODULE_PARM_DESC(disable_denylist, "Disable use of device denylist. Disabling the denylist allows binding to devices with known errata that may lead to exploitable stability or security issues when accessed by untrusted users."); - static inline bool vfio_vga_disabled(void) { #ifdef CONFIG_VFIO_PCI_VGA @@ -72,44 +52,6 @@ static inline bool vfio_vga_disabled(void) #endif } -static bool vfio_pci_dev_in_denylist(struct pci_dev *pdev) -{ - switch (pdev->vendor) { - case PCI_VENDOR_ID_INTEL: - switch (pdev->device) { - case PCI_DEVICE_ID_INTEL_QAT_C3XXX: - case PCI_DEVICE_ID_INTEL_QAT_C3XXX_VF: - case PCI_DEVICE_ID_INTEL_QAT_C62X: - case PCI_DEVICE_ID_INTEL_QAT_C62X_VF: - case PCI_DEVICE_ID_INTEL_QAT_DH895XCC: - case PCI_DEVICE_ID_INTEL_QAT_DH895XCC_VF: - return true; - default: - return false; - } - } - - return false; -} - -static bool vfio_pci_is_denylisted(struct pci_dev *pdev) -{ - if (!vfio_pci_dev_in_denylist(pdev)) - return false; - - if (disable_denylist) { - pci_warn(pdev, - "device denylist disabled - allowing device %04x:%04x.\n", - pdev->vendor, pdev->device); - return false; - } - - pci_warn(pdev, "%04x:%04x exists in vfio-pci device denylist, driver probing disallowed.\n", - pdev->vendor, pdev->device); - - return true; -} - /* * Our VGA arbiter participation is limited since we don't know anything * about the device itself. However, if the device is the only VGA device @@ -495,8 +437,6 @@ static void vfio_pci_disable(struct vfio_pci_core_device *vdev) vfio_pci_set_power_state(vdev, PCI_D3hot); } -static struct pci_driver vfio_pci_driver; - static struct vfio_pci_core_device *get_pf_vdev(struct vfio_pci_core_device *vdev) { struct pci_dev *physfn = pci_physfn(vdev->pdev); @@ -509,7 +449,7 @@ static struct vfio_pci_core_device *get_pf_vdev(struct vfio_pci_core_device *vde if (!pf_dev) return NULL; - if (pci_dev_driver(physfn) != &vfio_pci_driver) { + if (pci_dev_driver(physfn) != pci_dev_driver(vdev->pdev)) { vfio_device_put(pf_dev); return NULL; } @@ -532,7 +472,7 @@ static void vfio_pci_vf_token_user_add(struct vfio_pci_core_device *vdev, int va vfio_device_put(&pf_vdev->vdev); } -static void vfio_pci_core_close_device(struct vfio_device *core_vdev) +void vfio_pci_core_close_device(struct vfio_device *core_vdev) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -553,7 +493,7 @@ static void vfio_pci_core_close_device(struct vfio_device *core_vdev) mutex_unlock(&vdev->igate); } -static int vfio_pci_core_open_device(struct vfio_device *core_vdev) +int vfio_pci_core_open_device(struct vfio_device *core_vdev) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -726,8 +666,8 @@ int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev, return 0; } -static long vfio_pci_core_ioctl(struct vfio_device *core_vdev, - unsigned int cmd, unsigned long arg) +long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, + unsigned long arg) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1301,8 +1241,8 @@ static ssize_t vfio_pci_rw(struct vfio_pci_core_device *vdev, char __user *buf, return -EINVAL; } -static ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *buf, - size_t count, loff_t *ppos) +ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *buf, + size_t count, loff_t *ppos) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1313,8 +1253,8 @@ static ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *bu return vfio_pci_rw(vdev, buf, count, ppos, false); } -static ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *buf, - size_t count, loff_t *ppos) +ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *buf, + size_t count, loff_t *ppos) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1532,7 +1472,7 @@ static const struct vm_operations_struct vfio_pci_mmap_ops = { .fault = vfio_pci_mmap_fault, }; -static int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma) +int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1603,7 +1543,7 @@ static int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_stru return 0; } -static void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count) +void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1719,7 +1659,7 @@ static int vfio_pci_validate_vf_token(struct vfio_pci_core_device *vdev, #define VF_TOKEN_ARG "vf_token=" -static int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf) +int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf) { struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); @@ -1769,18 +1709,6 @@ static int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf) return 1; /* Match */ } -static const struct vfio_device_ops vfio_pci_ops = { - .name = "vfio-pci", - .open_device = vfio_pci_core_open_device, - .close_device = vfio_pci_core_close_device, - .ioctl = vfio_pci_core_ioctl, - .read = vfio_pci_core_read, - .write = vfio_pci_core_write, - .mmap = vfio_pci_core_mmap, - .request = vfio_pci_core_request, - .match = vfio_pci_core_match, -}; - static int vfio_pci_bus_notifier(struct notifier_block *nb, unsigned long action, void *data) { @@ -1795,15 +1723,16 @@ static int vfio_pci_bus_notifier(struct notifier_block *nb, pci_info(vdev->pdev, "Captured SR-IOV VF %s driver_override\n", pci_name(pdev)); pdev->driver_override = kasprintf(GFP_KERNEL, "%s", - vfio_pci_ops.name); + vdev->vdev.ops->name); } else if (action == BUS_NOTIFY_BOUND_DRIVER && pdev->is_virtfn && physfn == vdev->pdev) { struct pci_driver *drv = pci_dev_driver(pdev); - if (drv && drv != &vfio_pci_driver) + if (drv && drv != pci_dev_driver(vdev->pdev)) pci_warn(vdev->pdev, - "VF %s bound to driver %s while PF bound to vfio-pci\n", - pci_name(pdev), drv->name); + "VF %s bound to driver %s while PF bound to driver %s\n", + pci_name(pdev), drv->name, + pci_dev_driver(vdev->pdev)->name); } return 0; @@ -1871,15 +1800,39 @@ static void vfio_pci_vga_uninit(struct vfio_pci_core_device *vdev) VGA_RSRC_LEGACY_MEM); } -static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) +void vfio_pci_core_init_device(struct vfio_pci_core_device *vdev, + struct pci_dev *pdev, + const struct vfio_device_ops *vfio_pci_ops) { - struct vfio_pci_core_device *vdev; + vfio_init_group_dev(&vdev->vdev, &pdev->dev, vfio_pci_ops); + vdev->pdev = pdev; + vdev->irq_type = VFIO_PCI_NUM_IRQS; + mutex_init(&vdev->igate); + spin_lock_init(&vdev->irqlock); + mutex_init(&vdev->ioeventfds_lock); + INIT_LIST_HEAD(&vdev->dummy_resources_list); + INIT_LIST_HEAD(&vdev->ioeventfds_list); + mutex_init(&vdev->vma_lock); + INIT_LIST_HEAD(&vdev->vma_list); + init_rwsem(&vdev->memory_lock); +} + +void vfio_pci_core_uninit_device(struct vfio_pci_core_device *vdev) +{ + mutex_destroy(&vdev->igate); + mutex_destroy(&vdev->ioeventfds_lock); + mutex_destroy(&vdev->vma_lock); + vfio_uninit_group_dev(&vdev->vdev); + kfree(vdev->region); + kfree(vdev->pm_save); +} + +int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev) +{ + struct pci_dev *pdev = vdev->pdev; struct iommu_group *group; int ret; - if (vfio_pci_is_denylisted(pdev)) - return -EINVAL; - if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL) return -EINVAL; @@ -1900,24 +1853,6 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (!group) return -EINVAL; - vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); - if (!vdev) { - ret = -ENOMEM; - goto out_group_put; - } - - vfio_init_group_dev(&vdev->vdev, &pdev->dev, &vfio_pci_ops); - vdev->pdev = pdev; - vdev->irq_type = VFIO_PCI_NUM_IRQS; - mutex_init(&vdev->igate); - spin_lock_init(&vdev->irqlock); - mutex_init(&vdev->ioeventfds_lock); - INIT_LIST_HEAD(&vdev->dummy_resources_list); - INIT_LIST_HEAD(&vdev->ioeventfds_list); - mutex_init(&vdev->vma_lock); - INIT_LIST_HEAD(&vdev->vma_list); - init_rwsem(&vdev->memory_lock); - if (pci_is_root_bus(pdev->bus)) { ret = vfio_assign_device_set(&vdev->vdev, vdev); } else if (!pci_probe_reset_slot(pdev->slot)) { @@ -1931,10 +1866,10 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) } if (ret) - goto out_uninit; + goto out_group_put; ret = vfio_pci_vf_init(vdev); if (ret) - goto out_uninit; + goto out_group_put; ret = vfio_pci_vga_init(vdev); if (ret) goto out_vf; @@ -1966,36 +1901,26 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) vfio_pci_set_power_state(vdev, PCI_D0); out_vf: vfio_pci_vf_uninit(vdev); -out_uninit: - vfio_uninit_group_dev(&vdev->vdev); - kfree(vdev->pm_save); - kfree(vdev); out_group_put: vfio_iommu_group_put(group, &pdev->dev); return ret; } -static void vfio_pci_remove(struct pci_dev *pdev) +void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev) { - struct vfio_pci_core_device *vdev = dev_get_drvdata(&pdev->dev); + struct pci_dev *pdev = vdev->pdev; pci_disable_sriov(pdev); vfio_unregister_group_dev(&vdev->vdev); vfio_pci_vf_uninit(vdev); - vfio_uninit_group_dev(&vdev->vdev); vfio_pci_vga_uninit(vdev); vfio_iommu_group_put(pdev->dev.iommu_group, &pdev->dev); if (!disable_idle_d3) vfio_pci_set_power_state(vdev, PCI_D0); - - mutex_destroy(&vdev->ioeventfds_lock); - kfree(vdev->region); - kfree(vdev->pm_save); - kfree(vdev); } static pci_ers_result_t vfio_pci_aer_err_detected(struct pci_dev *pdev, @@ -2022,16 +1947,11 @@ static pci_ers_result_t vfio_pci_aer_err_detected(struct pci_dev *pdev, return PCI_ERS_RESULT_CAN_RECOVER; } -static int vfio_pci_sriov_configure(struct pci_dev *pdev, int nr_virtfn) +int vfio_pci_core_sriov_configure(struct pci_dev *pdev, int nr_virtfn) { struct vfio_device *device; int ret = 0; - might_sleep(); - - if (!enable_sriov) - return -ENOENT; - device = vfio_device_get_from_dev(&pdev->dev); if (!device) return -ENODEV; @@ -2046,19 +1966,10 @@ static int vfio_pci_sriov_configure(struct pci_dev *pdev, int nr_virtfn) return ret < 0 ? ret : nr_virtfn; } -static const struct pci_error_handlers vfio_err_handlers = { +const struct pci_error_handlers vfio_pci_core_err_handlers = { .error_detected = vfio_pci_aer_err_detected, }; -static struct pci_driver vfio_pci_driver = { - .name = "vfio-pci", - .id_table = NULL, /* only dynamic ids */ - .probe = vfio_pci_probe, - .remove = vfio_pci_remove, - .sriov_configure = vfio_pci_sriov_configure, - .err_handler = &vfio_err_handlers, -}; - static bool vfio_dev_in_groups(struct vfio_pci_core_device *vdev, struct vfio_pci_group_info *groups) { @@ -2239,83 +2150,15 @@ static bool vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set) return true; } -static void __exit vfio_pci_cleanup(void) +/* This will become the __exit function of vfio_pci_core.ko */ +void vfio_pci_core_cleanup(void) { - pci_unregister_driver(&vfio_pci_driver); vfio_pci_uninit_perm_bits(); } -static void __init vfio_pci_fill_ids(void) +/* This will become the __init function of vfio_pci_core.ko */ +int __init vfio_pci_core_init(void) { - char *p, *id; - int rc; - - /* no ids passed actually */ - if (ids[0] == '\0') - return; - - /* add ids specified in the module parameter */ - p = ids; - while ((id = strsep(&p, ","))) { - unsigned int vendor, device, subvendor = PCI_ANY_ID, - subdevice = PCI_ANY_ID, class = 0, class_mask = 0; - int fields; - - if (!strlen(id)) - continue; - - fields = sscanf(id, "%x:%x:%x:%x:%x:%x", - &vendor, &device, &subvendor, &subdevice, - &class, &class_mask); - - if (fields < 2) { - pr_warn("invalid id string \"%s\"\n", id); - continue; - } - - rc = pci_add_dynid(&vfio_pci_driver, vendor, device, - subvendor, subdevice, class, class_mask, 0); - if (rc) - pr_warn("failed to add dynamic id [%04x:%04x[%04x:%04x]] class %#08x/%08x (%d)\n", - vendor, device, subvendor, subdevice, - class, class_mask, rc); - else - pr_info("add [%04x:%04x[%04x:%04x]] class %#08x/%08x\n", - vendor, device, subvendor, subdevice, - class, class_mask); - } -} - -static int __init vfio_pci_init(void) -{ - int ret; - /* Allocate shared config space permission data used by all devices */ - ret = vfio_pci_init_perm_bits(); - if (ret) - return ret; - - /* Register and scan for devices */ - ret = pci_register_driver(&vfio_pci_driver); - if (ret) - goto out_driver; - - vfio_pci_fill_ids(); - - if (disable_denylist) - pr_warn("device denylist disabled.\n"); - - return 0; - -out_driver: - vfio_pci_uninit_perm_bits(); - return ret; + return vfio_pci_init_perm_bits(); } - -module_init(vfio_pci_init); -module_exit(vfio_pci_cleanup); - -MODULE_VERSION(DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/vfio/pci/vfio_pci_core.h b/drivers/vfio/pci/vfio_pci_core.h index 17ad048752b6..7dbdd4dda5c0 100644 --- a/drivers/vfio/pci/vfio_pci_core.h +++ b/drivers/vfio/pci/vfio_pci_core.h @@ -206,4 +206,27 @@ static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, } #endif +/* Will be exported for vfio pci drivers usage */ +void vfio_pci_core_cleanup(void); +int vfio_pci_core_init(void); +void vfio_pci_core_close_device(struct vfio_device *core_vdev); +int vfio_pci_core_open_device(struct vfio_device *core_vdev); +void vfio_pci_core_init_device(struct vfio_pci_core_device *vdev, + struct pci_dev *pdev, + const struct vfio_device_ops *vfio_pci_ops); +int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev); +void vfio_pci_core_uninit_device(struct vfio_pci_core_device *vdev); +void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev); +int vfio_pci_core_sriov_configure(struct pci_dev *pdev, int nr_virtfn); +extern const struct pci_error_handlers vfio_pci_core_err_handlers; +long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, + unsigned long arg); +ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *buf, + size_t count, loff_t *ppos); +ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *buf, + size_t count, loff_t *ppos); +int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma); +void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count); +int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf); + #endif /* VFIO_PCI_CORE_H */ From patchwork Wed Aug 25 13:51:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F412DC43214 for ; Wed, 25 Aug 2021 13:53:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D59C560E93 for ; Wed, 25 Aug 2021 13:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241139AbhHYNyV (ORCPT ); Wed, 25 Aug 2021 09:54:21 -0400 Received: from mail-bn7nam10on2072.outbound.protection.outlook.com ([40.107.92.72]:36196 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241238AbhHYNyE (ORCPT ); Wed, 25 Aug 2021 09:54:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IXOirWqB8/Qwie/9DMumHeohUN6s9adXGucda3XQoNxY+B1HBk5wnehkzSLZH/e4hWcrXWFaMfZ+U18KJ736wfu0hhVFI2jK+rWQSUCjSJfxaKX+2t71SQBXtzDc8ejINU6aXogNndokSsmF55J/ZbvmMa4BxbFIPW4Bb/S6RMuaMxLLaB/igXL02cd0OIjg378qfaWhJLIJ0TQdy3Y0glTcxDdBm9p8bHp+Y46ALXn8tSYZeEgj3IlKhcxxjUwYTVRo4Y+4kYaUF+0gKbpQZF3bGMrNoBSIrNIHfLB4T+DckusLaQmdj5VuNH7tn4gpKiHMLnbqSiTWQPTm2wh3+w== 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-SenderADCheck; bh=DatpDBmFPtOp7btyGUUOB0LDoqTeUHQqApMGXwDBhAk=; b=JpKR1h8AsyCiELSIdKbHFSDZ90k/FB/GA7lDwJSPx/wIlPMZwaeLXpISlWTme/OnxcNqMqy6rpVrHiZmhw6tnwNDP/3ijAG+bZ8omPAFUWHiP4MEPZZO/gHhJHGKt4acNka94TmvDl+3IQOKOJwaUXjy6DqmHL9U6LRBhVFIE+sx/miyb19VpiLkbzamoWH36lWCgApTS5+yQupZNZHPWG2+oy6xJ9I02quWtiaIrnF0E8jgiGBzIdclEMwg8Xzm4PqlccToDEf9G1DPAUAGd1+dvFMYjFM1MEQ0MUWS9Z3Bjwu1PpTkphWMJbEjfeNsLv7AmkvRQaLMKVI9TiPAgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.35) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DatpDBmFPtOp7btyGUUOB0LDoqTeUHQqApMGXwDBhAk=; b=IZtRLf8QMDtPOmRy1C8trDXYDVCP2A5SpnylyGgqj8hofXB40xBClz0Jwg7slsmYSReDWhmQ2lHaSK26CYEM7Yo+cd9XqDhlFhiWKbqYT/AnJH3Is5ZU0S92KdrZcRdHkxLt/ei+Sc0ajefY+WnAm1BxWkMXgd4gIatREr2Jfw9M4CK3P3ssmKx8PgL+7JVG1RQODa7aVFvEp1db5qp3/rWG/lALlt7LpdXAxkvuhKW0ZBETWOlH50ol1JzPcjUjuYRPhqzqgq/x91lWMqSHTbBt5NjJ9I+r5ygcyN252Zdad+gWHgo7Nvqxvqbv10xYnysr5BiL8sl+D6vZZNSK5w== Received: from MWHPR18CA0026.namprd18.prod.outlook.com (2603:10b6:320:31::12) by DM6PR12MB3881.namprd12.prod.outlook.com (2603:10b6:5:148::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Wed, 25 Aug 2021 13:53:14 +0000 Received: from CO1NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:320:31:cafe::35) by MWHPR18CA0026.outlook.office365.com (2603:10b6:320:31::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Wed, 25 Aug 2021 13:53:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.35) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.35 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.35; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.35) by CO1NAM11FT058.mail.protection.outlook.com (10.13.174.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:53:13 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:27 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:23 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 07/13] vfio/pci: Move igd initialization to vfio_pci.c Date: Wed, 25 Aug 2021 16:51:33 +0300 Message-ID: <20210825135139.79034-8-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ef15838-64cf-484a-bc5a-08d967cfaee2 X-MS-TrafficTypeDiagnostic: DM6PR12MB3881: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tnStzsk0SaLhP1qLGipe+4hHtVTqtvFsfdDZeU/FvTHMuwmPA2+tu8WqgM1ii2i/UdFNt3f29q5sTIcPwWYr2960ogEy1rOQOKsjtURlEXrhXy1jcmD69UzxPYKgh5/2fQbqoAXwQjC/qWHfkowPTYo3rt9pRG97h2WQa2vmj/I+dvLyHt7URG4/GnIfVZR9wmyVvtqGz1mYeToS2/6mBPFe1DPLNsS79yw/Knt9wWLt6/3xE+Sm59XrgTaf7kS0/V02ooy98U04rqYw1epOJOKJTtrmxUjaPTPKU/UdBMNPf4NiODNkVhZH8MvSgW/c+HLrUoxp7/4UfdqbBfrmF+zQRe8EweIwhuVCQbSkpmvGJoRSJlQYrsFPnOnl6pXZDrkRazyYbET1wcA4NtxEhlgfjPPd/xqNzlWs2rfoenpgUZ+Qzt+J7nRa0FQKOQwlemRAeMT4XzOBOcnigu8Oo2zTaAjzWs4+kjcmCYSiZkaZdScFc6TrnTSMJMC7bkulry/YXNLqebYqoOaK+fHxGo5+XzmmeK6LgxEVj9vojoLYAiqqUFD4ZWBkbShX7+3s7n3XxyXbkx0vKsa2cM43AdmjxigdrjAi3PXnMxxTgmreuL+6TCcgBqgT/+/kvCQ/xFi8j6tOSUbj+LIEhcauwJu3h35awNokwaGM9x+Z0XTC/4rFZgeq6K1Xc7nmliAmVJK8wmVFXRg19p65pZaXFiWHcFYgbbGBWvxxEOSmfa4= X-Forefront-Antispam-Report: CIP:216.228.112.35;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid02.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(36906005)(316002)(54906003)(2616005)(2906002)(110136005)(70206006)(7416002)(6666004)(8676002)(26005)(356005)(8936002)(82310400003)(426003)(1076003)(107886003)(508600001)(86362001)(83380400001)(70586007)(47076005)(336012)(36860700001)(7696005)(4326008)(186003)(7636003)(36756003)(5660300002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:53:13.8492 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ef15838-64cf-484a-bc5a-08d967cfaee2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.35];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3881 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy igd is related to the vfio_pci pci_driver implementation, move it out of vfio_pci_core.c. This is preparation for splitting vfio_pci.ko into 2 drivers. Signed-off-by: Max Gurtovoy Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/vfio_pci.c | 29 +++++++++++++++++++++++- drivers/vfio/pci/vfio_pci_core.c | 39 ++++---------------------------- drivers/vfio/pci/vfio_pci_core.h | 9 +++++++- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 4e31bd3001ad..2729b777a56d 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -82,9 +82,36 @@ static bool vfio_pci_is_denylisted(struct pci_dev *pdev) return true; } +static int vfio_pci_open_device(struct vfio_device *core_vdev) +{ + struct vfio_pci_core_device *vdev = + container_of(core_vdev, struct vfio_pci_core_device, vdev); + struct pci_dev *pdev = vdev->pdev; + int ret; + + ret = vfio_pci_core_enable(vdev); + if (ret) + return ret; + + if (vfio_pci_is_vga(pdev) && + pdev->vendor == PCI_VENDOR_ID_INTEL && + IS_ENABLED(CONFIG_VFIO_PCI_IGD)) { + ret = vfio_pci_igd_init(vdev); + if (ret && ret != -ENODEV) { + pci_warn(pdev, "Failed to setup Intel IGD regions\n"); + vfio_pci_core_disable(vdev); + return ret; + } + } + + vfio_pci_core_finish_enable(vdev); + + return 0; +} + static const struct vfio_device_ops vfio_pci_ops = { .name = "vfio-pci", - .open_device = vfio_pci_core_open_device, + .open_device = vfio_pci_open_device, .close_device = vfio_pci_core_close_device, .ioctl = vfio_pci_core_ioctl, .read = vfio_pci_core_read, diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index c0d71f72d4f1..3b3bf7445367 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -91,11 +91,6 @@ static unsigned int vfio_pci_set_vga_decode(void *opaque, bool single_vga) return decodes; } -static inline bool vfio_pci_is_vga(struct pci_dev *pdev) -{ - return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; -} - static void vfio_pci_probe_mmaps(struct vfio_pci_core_device *vdev) { struct resource *res; @@ -166,7 +161,6 @@ static void vfio_pci_probe_mmaps(struct vfio_pci_core_device *vdev) struct vfio_pci_group_info; static bool vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set); -static void vfio_pci_disable(struct vfio_pci_core_device *vdev); static int vfio_pci_dev_set_hot_reset(struct vfio_device_set *dev_set, struct vfio_pci_group_info *groups); @@ -252,7 +246,7 @@ int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev, pci_power_t stat return ret; } -static int vfio_pci_enable(struct vfio_pci_core_device *vdev) +int vfio_pci_core_enable(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; int ret; @@ -321,26 +315,11 @@ static int vfio_pci_enable(struct vfio_pci_core_device *vdev) if (!vfio_vga_disabled() && vfio_pci_is_vga(pdev)) vdev->has_vga = true; - if (vfio_pci_is_vga(pdev) && - pdev->vendor == PCI_VENDOR_ID_INTEL && - IS_ENABLED(CONFIG_VFIO_PCI_IGD)) { - ret = vfio_pci_igd_init(vdev); - if (ret && ret != -ENODEV) { - pci_warn(pdev, "Failed to setup Intel IGD regions\n"); - goto disable_exit; - } - } - - vfio_pci_probe_mmaps(vdev); return 0; - -disable_exit: - vfio_pci_disable(vdev); - return ret; } -static void vfio_pci_disable(struct vfio_pci_core_device *vdev) +void vfio_pci_core_disable(struct vfio_pci_core_device *vdev) { struct pci_dev *pdev = vdev->pdev; struct vfio_pci_dummy_resource *dummy_res, *tmp; @@ -479,7 +458,7 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev) vfio_pci_vf_token_user_add(vdev, -1); vfio_spapr_pci_eeh_release(vdev->pdev); - vfio_pci_disable(vdev); + vfio_pci_core_disable(vdev); mutex_lock(&vdev->igate); if (vdev->err_trigger) { @@ -493,19 +472,11 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev) mutex_unlock(&vdev->igate); } -int vfio_pci_core_open_device(struct vfio_device *core_vdev) +void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev) { - struct vfio_pci_core_device *vdev = - container_of(core_vdev, struct vfio_pci_core_device, vdev); - int ret = 0; - - ret = vfio_pci_enable(vdev); - if (ret) - return ret; - + vfio_pci_probe_mmaps(vdev); vfio_spapr_pci_eeh_open(vdev->pdev); vfio_pci_vf_token_user_add(vdev, 1); - return 0; } static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_type) diff --git a/drivers/vfio/pci/vfio_pci_core.h b/drivers/vfio/pci/vfio_pci_core.h index 7dbdd4dda5c0..ffaf544f35db 100644 --- a/drivers/vfio/pci/vfio_pci_core.h +++ b/drivers/vfio/pci/vfio_pci_core.h @@ -210,7 +210,6 @@ static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, void vfio_pci_core_cleanup(void); int vfio_pci_core_init(void); void vfio_pci_core_close_device(struct vfio_device *core_vdev); -int vfio_pci_core_open_device(struct vfio_device *core_vdev); void vfio_pci_core_init_device(struct vfio_pci_core_device *vdev, struct pci_dev *pdev, const struct vfio_device_ops *vfio_pci_ops); @@ -228,5 +227,13 @@ ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *bu int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma); void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count); int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf); +int vfio_pci_core_enable(struct vfio_pci_core_device *vdev); +void vfio_pci_core_disable(struct vfio_pci_core_device *vdev); +void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev); + +static inline bool vfio_pci_is_vga(struct pci_dev *pdev) +{ + return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; +} #endif /* VFIO_PCI_CORE_H */ From patchwork Wed Aug 25 13:51:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74123C4338F for ; Wed, 25 Aug 2021 13:52:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60BD860EBC for ; Wed, 25 Aug 2021 13:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241528AbhHYNx1 (ORCPT ); Wed, 25 Aug 2021 09:53:27 -0400 Received: from mail-mw2nam10on2087.outbound.protection.outlook.com ([40.107.94.87]:13761 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241548AbhHYNxV (ORCPT ); Wed, 25 Aug 2021 09:53:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0X+OOiHm0zy6fBjmhD5AAMonlszVMvZjcRr4AInWHkjP0rpZhsIbcR7T6Gs/C1bNZG8NJpYSftutOVX/w6Xs3orp/ssjS3vUXCelDX/xIP3+c0NPXXDeno7COfTjqc7V0m0kGX5lBxo9WnlKsIpUthcDgg4DRSEXzY+QdiAFkvkEHAdiYlhQaVaQLbdwKnV4dLbTiwnHkyt3ztVE0DQMr0Y5Ik0SZezMpSb6fBKFN9fd/xUWUIiSVX8K2fYF9pfTePbJB+O9zxY3joU5ixeq7pxl6zoTCOawR5GZoA9GAg49cLDlUmFVJBX0+OhXg99TvCws/sRFPublSlWBaNIOw== 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-SenderADCheck; bh=/UHQwRjPpZ2S7q9O8WpCaY6gZO2rDNrbtMFwTeI8xws=; b=QilhA+801L4Ag9bHlSdQWPv2fE2lCnwMjKdKcJAi+Qwqy+lrqL/rIv0WkDILmKKT5Q8AFWrl24tysUFC1BzlTMJ+OlQA2WL9Sq/2M8Jrm6FKvD75+QTB2H/lBz3+v0y6XOQYnN/cyHR2SlZBYoEW8Sc/gbJheBiXUujQLalv6rnpRjviYfecyu2LWiM/c5GpDl+1JOMrohPI+WDhEwIFVQRhCV5uFVsLAll0uwZpmhos8lC3cc0be+UEB/fDMaAq94NOA/NWnTTVXI9Cj2Ph3E6m+ylip/o0hEAglHHtPVzYSpMJNnPTu299EDSTRypNZvYGwpom7Y9YrSykWCZUpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/UHQwRjPpZ2S7q9O8WpCaY6gZO2rDNrbtMFwTeI8xws=; b=ksxo9bLi5rZsiJZLwC921bqzDYB6X+dAxqVzs6tglqAm1Eaylfi5IqEyJMWApHsxYCqdX9NTMDPb9HrV4e1v1X05uCzzqdKpCBWhglJ3b7Gt7FUo6LPfoWVEiU17u5MGjdO1o70IxQIiFjeZOIVf3T04FKe8RQJrvItz93VExeYk2lAeiak6D/xXHfKb9yE6qO7pH6/XbHJx7aqyancNcNoZzMPK2IkuxFl0qa2BqMM1McSJ9zuMfujppTpQRfMEQZiLwf3tb3zaver+ZxJv/cIGCVrUniBRj+rGUj6wUvdUfzNH/TCpD5VqSVDlO9WUtS8pHGHRdozu82pbeZue1Q== Received: from MWHPR19CA0069.namprd19.prod.outlook.com (2603:10b6:300:94::31) by DM6PR12MB3403.namprd12.prod.outlook.com (2603:10b6:5:11d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.21; Wed, 25 Aug 2021 13:52:32 +0000 Received: from CO1NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:300:94:cafe::4f) by MWHPR19CA0069.outlook.office365.com (2603:10b6:300:94::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 13:52:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT058.mail.protection.outlook.com (10.13.174.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:32 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 06:52:32 -0700 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:28 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 08/13] vfio/pci: Move module parameters to vfio_pci.c Date: Wed, 25 Aug 2021 16:51:34 +0300 Message-ID: <20210825135139.79034-9-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 957c3814-3789-437c-bf7b-08d967cf964e X-MS-TrafficTypeDiagnostic: DM6PR12MB3403: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tv6ENG2GZN+qmcgDTthlOrCEc7wqw+OB0F2gsM5sHRkWnD4TLORJEwEOFK8mb4WtpHLTfYZ7EhCsHDv6YBT3292aXfDm4ntHeSt8imrYJh+haiWQrpW9w/uouzWTSQzpIUDntJKdsamA7n6UAG7x2AK6WNG/CTh3yGnlLDPboj1uuaAobSR1QV3Wh1q1mnYeOr5OFrVV0nHY3d5PNC86WCxscycPUeM3zYMGQT9ZbP71GyJaqkhtdBRMHc6EoVIxnAA1Y0DOOYLJ7Ix9AsjJ/NKj/+kg2GgtxU7QXeY9phi2aE3ny14fy/DAPWYsyAYf3RB+MgJaQ16SfO7OaDpDS+GPi2S4rcvGLx+SzhUtFkQTwqxSxyCW5kGmAhrBhmg/NYGAKYlB2GykNdms/vVCtK+RirXhbbesi0TtwqeVAKTVhm6J1WzIGTYRG7a8jEt+Zdp/OMRvcgauzTvRZcJsHwW4H77df66ZidF/MA5zo3xVzTFejyxQmPiIqLo4zPIR+jm390aw5Fv/zOteenL4lW5YqnpLbeYGR3HvvMNV5MU2uB2RP3WLBQxWzVoQiAy114EJvH6W1MgrHDqBlnLWE+XTANS2hX5eEMu4X9tdqk3Jm2efM6Ya8yD9S0bpX6QKpQvpd+BHGiYa+c0l1whYaLIGH35TxOmDUVDBtTu5sNqw/L13Or4kPtn727xvtRWlZG1UAg/ZyTF8uZmODJ0Cm/f3pOCsjKBG5NNUxF2o8Yo= X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(136003)(39860400002)(376002)(396003)(346002)(46966006)(36840700001)(107886003)(186003)(7636003)(36756003)(8936002)(1076003)(336012)(26005)(82740400003)(70206006)(426003)(8676002)(6666004)(356005)(36860700001)(4326008)(5660300002)(47076005)(110136005)(54906003)(7416002)(2616005)(83380400001)(2906002)(478600001)(86362001)(7696005)(82310400003)(316002)(70586007)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:32.6000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 957c3814-3789-437c-bf7b-08d967cf964e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3403 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org This is a preparation before splitting vfio_pci.ko to 2 modules. As module parameters are a kind of uAPI they need to stay on vfio_pci.ko to avoid a user visible impact. For now continue to keep the implementation of these options in vfio_pci_core.c. Arguably they are vfio_pci functionality, but further splitting of vfio_pci_core.c will be better done in another series Signed-off-by: Yishai Hadas Signed-off-by: Jason Gunthorpe Reviewed-by: Christoph Hellwig --- drivers/vfio/pci/vfio_pci.c | 23 +++++++++++++++++++++++ drivers/vfio/pci/vfio_pci_core.c | 20 ++++++++------------ drivers/vfio/pci/vfio_pci_core.h | 2 ++ 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 2729b777a56d..163e560c4495 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -34,6 +34,22 @@ static char ids[1024] __initdata; module_param_string(ids, ids, sizeof(ids), 0); MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the vfio driver, format is \"vendor:device[:subvendor[:subdevice[:class[:class_mask]]]]\" and multiple comma separated entries can be specified"); +static bool nointxmask; +module_param_named(nointxmask, nointxmask, bool, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(nointxmask, + "Disable support for PCI 2.3 style INTx masking. If this resolves problems for specific devices, report lspci -vvvxxx to linux-pci@vger.kernel.org so the device can be fixed automatically via the broken_intx_masking flag."); + +#ifdef CONFIG_VFIO_PCI_VGA +static bool disable_vga; +module_param(disable_vga, bool, S_IRUGO); +MODULE_PARM_DESC(disable_vga, "Disable VGA resource access through vfio-pci"); +#endif + +static bool disable_idle_d3; +module_param(disable_idle_d3, bool, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(disable_idle_d3, + "Disable using the PCI D3 low power state for idle, unused devices"); + static bool enable_sriov; #ifdef CONFIG_PCI_IOV module_param(enable_sriov, bool, 0644); @@ -215,6 +231,13 @@ static void __init vfio_pci_fill_ids(void) static int __init vfio_pci_init(void) { int ret; + bool is_disable_vga = true; + +#ifdef CONFIG_VFIO_PCI_VGA + is_disable_vga = disable_vga; +#endif + + vfio_pci_core_set_params(nointxmask, is_disable_vga, disable_idle_d3); ret = vfio_pci_core_init(); if (ret) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 3b3bf7445367..65eafaafb2e0 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -28,20 +28,8 @@ #include "vfio_pci_core.h" static bool nointxmask; -module_param_named(nointxmask, nointxmask, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(nointxmask, - "Disable support for PCI 2.3 style INTx masking. If this resolves problems for specific devices, report lspci -vvvxxx to linux-pci@vger.kernel.org so the device can be fixed automatically via the broken_intx_masking flag."); - -#ifdef CONFIG_VFIO_PCI_VGA static bool disable_vga; -module_param(disable_vga, bool, S_IRUGO); -MODULE_PARM_DESC(disable_vga, "Disable VGA resource access through vfio-pci"); -#endif - static bool disable_idle_d3; -module_param(disable_idle_d3, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(disable_idle_d3, - "Disable using the PCI D3 low power state for idle, unused devices"); static inline bool vfio_vga_disabled(void) { @@ -2121,6 +2109,14 @@ static bool vfio_pci_dev_set_try_reset(struct vfio_device_set *dev_set) return true; } +void vfio_pci_core_set_params(bool is_nointxmask, bool is_disable_vga, + bool is_disable_idle_d3) +{ + nointxmask = is_nointxmask; + disable_vga = is_disable_vga; + disable_idle_d3 = is_disable_idle_d3; +} + /* This will become the __exit function of vfio_pci_core.ko */ void vfio_pci_core_cleanup(void) { diff --git a/drivers/vfio/pci/vfio_pci_core.h b/drivers/vfio/pci/vfio_pci_core.h index ffaf544f35db..7a2da1e14de3 100644 --- a/drivers/vfio/pci/vfio_pci_core.h +++ b/drivers/vfio/pci/vfio_pci_core.h @@ -209,6 +209,8 @@ static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, /* Will be exported for vfio pci drivers usage */ void vfio_pci_core_cleanup(void); int vfio_pci_core_init(void); +void vfio_pci_core_set_params(bool nointxmask, bool is_disable_vga, + bool is_disable_idle_d3); void vfio_pci_core_close_device(struct vfio_device *core_vdev); void vfio_pci_core_init_device(struct vfio_pci_core_device *vdev, struct pci_dev *pdev, From patchwork Wed Aug 25 13:51:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB7E4C19F37 for ; Wed, 25 Aug 2021 13:52:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA459610E8 for ; Wed, 25 Aug 2021 13:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241535AbhHYNx2 (ORCPT ); Wed, 25 Aug 2021 09:53:28 -0400 Received: from mail-dm6nam12on2059.outbound.protection.outlook.com ([40.107.243.59]:40298 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241531AbhHYNxY (ORCPT ); Wed, 25 Aug 2021 09:53:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V+PxW+icyblQr0vG1T17CskMdXHPwhUP/oEGD2ilMVLpaAJpP4lHgJ/3DRa7pk94/oTNymJPuUkogLp+Rx5DkSJjRPx2svEkVs5hiSJkaa462x9xlgYKB8mKWWQB288g11QFshxjCHFJnE0XJWInGe/5vlVKD3ESsHf51y6pO9o8Ogy+WkC1iWrTfT9FXBoHEywv9TscDmYixBJNkg3gmoNFlaqT9+Q7C7scU4xLzNHii81jGFyY7pcXqmE1lawmSEzTGy58kKI0rNaiL0YWltxWFVIGWYwdgXZ9KQZvJ35XH6PxGMjCITFMf1OGvpQVRkonzBxTyb/+xDP3fYNwPw== 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-SenderADCheck; bh=B0jxLfSLQhTamdl86+R8B7UypRkdNcOGdJYHo3zm0n8=; b=L2hIlfj72UkCaFH1VjHfoYPsyefiucTdpWYsOvQ50UcAQhyQOsc6Pxr9uh4sfMsu6hvID8FBKhGGo8M4+/aU7fDvjlXheaRN3iGcgIQKMMWWlZJ2lFsU8YgPVzWhE3JzbTn5mYVSLk31It4m5wBYa+IPdHpG9Jqm7BxOs1zPtb4qx4pOhzyTyWUimahOA1SJkug2it+QxCBNxZI9i8M5S+Sb1acoj14ZGRcsirxFnu9ugUVXFlRM+k4USu4SqlGagQJLYx5GlleXwaoTeM40GglbmyQtHe0gbnBg2KUL1HH1ITniD4rn2bRZN/28h68myvf8zWmKnCfxxFsIBWL5ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B0jxLfSLQhTamdl86+R8B7UypRkdNcOGdJYHo3zm0n8=; b=H2VJUt4DDt+DDh5n48olBbROEABkxwqjrenjhrxswP5E/09tl9w6hqQZNdFlHrfoBSPcBPruSzWBjugW/0KdDmaZwzThEqqkCdgBxQjesTW4PJQ6E/Bmg1LC8JOGnbelmhY1WB5nQnKb4NV/kiNEoz635DjCCamM+a6LBypNODxl6UflYa/zc9PHT4ypvUm3efIpjJJOH9Dk/PapY6D4+03eR+2w1GUU43toYeSHLMjfpcmjdoFFHPWws47a2pwxsRZHxPT2oVml13mNBiOCeOvbl/AIZw4eHCwME7zm2HDufhpUEAfR6PaKIcIeyRPxaWzH1DK0u9ZWeypO5DMGgg== Received: from BN9PR03CA0936.namprd03.prod.outlook.com (2603:10b6:408:108::11) by DM6PR12MB4825.namprd12.prod.outlook.com (2603:10b6:5:1d4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.19; Wed, 25 Aug 2021 13:52:37 +0000 Received: from BN8NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:408:108:cafe::ef) by BN9PR03CA0936.outlook.office365.com (2603:10b6:408:108::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 13:52:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by BN8NAM11FT059.mail.protection.outlook.com (10.13.177.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:37 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:36 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:32 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 09/13] PCI: Add 'override_only' field to struct pci_device_id Date: Wed, 25 Aug 2021 16:51:35 +0300 Message-ID: <20210825135139.79034-10-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 46cb73b8-2171-47c8-cc74-08d967cf9932 X-MS-TrafficTypeDiagnostic: DM6PR12MB4825: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vIAitb8w8Ki+8tbxmEAyNIgw7IwdYVBzm+xdcHDlyw26VPSibSYDcu5zAj/aaH3UpOQ2y98avtlYKC75T2j/e34EW+1lZ/P5W/lwh1zTb6y8TVnnNgGe8G7VlnBULQcthVRgP8JZRyg8+4BAYZX1mL/UDk6C4autQFMzZ8SVOQ/onJ4e6ddr0rvhT97JJ+58B318bukwlR8ttHa1i/qJZiIrmeb9cDeOBaEGXC+4wxGSCa3PBWCp8YH0X8cSHgi3gDKw9rXOz9nT3OSKt0w3Vb5X6Uq44WDtfYq8YG85tqJsExlc2VjnZ4b3h5OhWC9Cfh7ddT/N9Q/qDKISSO1yWYTIqMUXu13DQAn4Lv8xDQ30fYD8f8uhxRVh6B0hiz29ySrh4wUhl14A/uPqkkNfv4G5OB0klShB59RvWE8WnmRYjwYvYObhznKhz4IgX39TyPcMFJhzR2GJPnTDE9+mO3OHAGIWqj8ayq1JBc1azUQQPFshKaDsaZub7iFBmMR9jpEDcSOpUQYZFJTdex66g1650qXiHG6PkTnlu/xHkDTRjyNrjgw0S+GN1Eb0PUs/O+0amTK8oRAHT6q7sQiTBE0E2ws85n+jCu5n9nEkSHWwX+85v38TOMRLawDvSsUuzDC4u9bZvWNrwK1j3t32B6mhFWeNcWF3L1ujY/7QmdNbAqAw8Jny0ntdKrsAGI3vbXUEtCo/guuhBAKif6YEyyX4M8Z0GAToTiVHVGx8GGU= X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(376002)(39860400002)(396003)(136003)(346002)(36840700001)(46966006)(1076003)(5660300002)(70206006)(4326008)(82310400003)(54906003)(110136005)(70586007)(8936002)(316002)(36906005)(8676002)(7636003)(47076005)(2906002)(82740400003)(7416002)(26005)(426003)(7696005)(86362001)(336012)(186003)(36860700001)(478600001)(356005)(2616005)(83380400001)(36756003)(107886003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:37.4161 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46cb73b8-2171-47c8-cc74-08d967cf9932 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4825 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy Add 'override_only' field to struct pci_device_id to be used as part of pci_match_device(). When set, it means that matching is true only when dev->driver_override is this driver. In addition, add a helper macro named 'PCI_DEVICE_DRIVER_OVERRIDE' to enable setting some data on it. Next patch from this series will use the above functionality. Signed-off-by: Max Gurtovoy Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas Acked-by: Bjorn Helgaas --- Documentation/PCI/pci.rst | 1 + drivers/pci/pci-driver.c | 28 +++++++++++++++++++++------- include/linux/mod_devicetable.h | 2 ++ include/linux/pci.h | 15 +++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Documentation/PCI/pci.rst b/Documentation/PCI/pci.rst index fa651e25d98c..87c6f4a6ca32 100644 --- a/Documentation/PCI/pci.rst +++ b/Documentation/PCI/pci.rst @@ -103,6 +103,7 @@ need pass only as many optional fields as necessary: - subvendor and subdevice fields default to PCI_ANY_ID (FFFFFFFF) - class and classmask fields default to 0 - driver_data defaults to 0UL. + - override_only field defaults to 0. Note that driver_data must match the value used by any of the pci_device_id entries defined in the driver. This makes the driver_data field mandatory diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 3a72352aa5cf..123c590ebe1d 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -136,7 +136,7 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv, struct pci_dev *dev) { struct pci_dynid *dynid; - const struct pci_device_id *found_id = NULL; + const struct pci_device_id *found_id = NULL, *ids; /* When driver_override is set, only bind to the matching driver */ if (dev->driver_override && strcmp(dev->driver_override, drv->name)) @@ -152,14 +152,28 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv, } spin_unlock(&drv->dynids.lock); - if (!found_id) - found_id = pci_match_id(drv->id_table, dev); + if (found_id) + return found_id; - /* driver_override will always match, send a dummy id */ - if (!found_id && dev->driver_override) - found_id = &pci_device_id_any; + for (ids = drv->id_table; (found_id = pci_match_id(ids, dev)); + ids = found_id + 1) { + /* + * The match table is split based on driver_override. + * In case override_only was set, enforce driver_override + * matching. + */ + if (found_id->override_only) { + if (dev->driver_override) + return found_id; + } else { + return found_id; + } + } - return found_id; + /* driver_override will always match, send a dummy id */ + if (dev->driver_override) + return &pci_device_id_any; + return NULL; } /** diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 8e291cfdaf06..2e3ba6d9ece0 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -34,12 +34,14 @@ typedef unsigned long kernel_ulong_t; * Best practice is to use driver_data as an index * into a static list of equivalent device types, * instead of using it as a pointer. + * @override_only: Match only when dev->driver_override is this driver. */ struct pci_device_id { __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/ __u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */ __u32 class, class_mask; /* (class,subclass,prog-if) triplet */ kernel_ulong_t driver_data; /* Data private to the driver */ + __u32 override_only; }; diff --git a/include/linux/pci.h b/include/linux/pci.h index 540b377ca8f6..0506b1a8c921 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -901,6 +901,21 @@ struct pci_driver { .vendor = (vend), .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID +/** + * PCI_DEVICE_DRIVER_OVERRIDE - macro used to describe a PCI device with + * override_only flags. + * @vend: the 16 bit PCI Vendor ID + * @dev: the 16 bit PCI Device ID + * @driver_override: the 32 bit PCI Device override_only + * + * This macro is used to create a struct pci_device_id that matches only a + * driver_override device. The subvendor and subdevice fields will be set to + * PCI_ANY_ID. + */ +#define PCI_DEVICE_DRIVER_OVERRIDE(vend, dev, driver_override) \ + .vendor = (vend), .device = (dev), .subvendor = PCI_ANY_ID, \ + .subdevice = PCI_ANY_ID, .override_only = (driver_override) + /** * PCI_DEVICE_SUB - macro used to describe a specific PCI device with subsystem * @vend: the 16 bit PCI Vendor ID From patchwork Wed Aug 25 13:51:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31E08C4320A for ; Wed, 25 Aug 2021 13:52:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DEEF60EBC for ; Wed, 25 Aug 2021 13:52:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241548AbhHYNxc (ORCPT ); Wed, 25 Aug 2021 09:53:32 -0400 Received: from mail-bn8nam12on2069.outbound.protection.outlook.com ([40.107.237.69]:46625 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241539AbhHYNxa (ORCPT ); Wed, 25 Aug 2021 09:53:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GY6SFbqXBhsO2iMl8Ml8pNFJ72wOZQxtOAal7Gxa3C+WcXDwek5Of6muqYF/Gimaae3uCYU+T3KvdmsDEoxi9NSymdGB7feoYG87xOAsoO7GaiuGUqI0Ag96uI9TIxhw3DTRD5hgloVIuP4PUAnrCgDCOWeKHQQ4rpa1iBbBhcf+KWqZF0sQeEnCflo6AyFj6vxiePVzgsVrVPy1MeD4yt4poHtYNJ+MUh/wCesyB52YhRtbnTjpPDOYVP4nBLI7XoQ8YiWl8HHyR96m+iEwSE3xbdKfFTdkp2g+EWBazH+NdNq2HE0pISmKKSplZVxyCWeXtdC3ep7K0w5j151HRg== 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-SenderADCheck; bh=lybDEgD89Iu+brGZXFo8/8cT6avyp1myjn9U09oznq0=; b=Mq5Q8H8SfzhcZ/U96oZsX+Kh2my06wXkbqXD/I8QqVfspG5UJZadWKeKXAjcNvHmK0QizfYsl54z9qgsuhE+gClCXBkfsXuOSfNEhuxFtg+YQ6VUNkQvSGW3ofEqsWoRl9jxTkbWLsQrxKRfEP8xbsRUpJu2139hcN8IjVa7FQyUUilqHkCv9cqHUFYZ2p1jcMk7/REUKjMQUaKL9JpmKlLckfBwefNCgLcVq/eTCgb1PXD7PcpL6XDZfn0uP9cPwrbR+sLVLgoluGJ2XTTy4Rc3DyKk8fSyn2TaEodmu2IMn+7eAYN8yIVooC+lrLt9LXMRaoU+PRrTUAsl+mS7iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lybDEgD89Iu+brGZXFo8/8cT6avyp1myjn9U09oznq0=; b=eVFAGXMJMJf4yg5eXCweJ0CESUIUEGF+k8lqx5EM4U+2kDwXO3SAV9tDtOeD/bxQ/U9DSzqxwYbakOjn+MEWaGAymfEd0OQJx8+BX4uotgZtY9CPMQn3U01dyDEK7nqLs24ySEFrL3rMX9QhYOmfM8Noj2E+8TZiI1YSVxTHY0K14I55WKajH+ey/WvdMeNq0hIpj7PFhlYvcmrH0tlrACOHGoOVWhpel/OXGl6RsmKtHhlPUiPELY2KekUR0KlDbfUAPFknTKefoqYknn+ym6gB2vsbGW+P+lKXQ6CJKX1xHsHUaHCPt3NzBiAsnDWD8mNa+gR/PgZSasc+GiyRMA== Received: from MWHPR22CA0062.namprd22.prod.outlook.com (2603:10b6:300:12a::24) by DM6PR12MB2731.namprd12.prod.outlook.com (2603:10b6:5:45::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 13:52:42 +0000 Received: from CO1NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:300:12a:cafe::cf) by MWHPR22CA0062.outlook.office365.com (2603:10b6:300:12a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 13:52:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT014.mail.protection.outlook.com (10.13.175.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:41 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 06:52:40 -0700 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:36 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 10/13] PCI / VFIO: Add 'override_only' support for VFIO PCI sub system Date: Wed, 25 Aug 2021 16:51:36 +0300 Message-ID: <20210825135139.79034-11-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fef2c87e-6b77-4e4f-533f-08d967cf9be2 X-MS-TrafficTypeDiagnostic: DM6PR12MB2731: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TIdk0aW3S8NEixzuUWMNOJC3RqAjJIi6Rd6b56MXuw91BR76laf78FFCU/gYqgBGt/ZwcVsfLczl2RBjjs2TV7yjCwA12H6ndf5UpVj4M4d5it7pqyz8GeSARGrVPcTBthW8BD0J2Sh9gj3UANLurD52mRuBC9SNSanO5tiLB5bHAZW/P+EexnLBo2JB25WmjtN/+RwN259T0Quf0/y83lAwm6PnL52qLk2h9DEqzFv/KVCXAdltGVLWdjBoNDBJpj4fWeqf19LXlsrVLO6lPQNQHANrL8i6VcIK5h/K3nlViVdx6Yn16cUzfwabIWrOqmCZ0nRyigDgJfRvAx8M9DzdDfpkRnUJ3pKoVpG/C8mWWoisBihcopz+JIsYA/uj7x9wEJrIPra182BKeQr0oIBR5p93a1KbI+gIs9gRJpoVBscU1m7sxOC/dbXFJNYLfjHXAqv6Wam0u2cz3zr9nChqUPohoXIes5dE0k3cyY+twkd4Do7GkrFyfxVcYmWyTY8c2cJnkmuxWWGG1Pu5/Tf0rKEPGmPMOOziS23d72K2oETB6AHlkT6SzzG56mE8KuZkGm8sT3RybryriGh6livf+hdVlyNfmkTpizY/wi0yYKzTqfAG3dUMaQrKLRU4+E9OnY0sInk74Kh/H3DIJ0LfsBzNIJhc61GL+Pn7wh71sFXK6DMr0yrcMcxBXS0NUydfnQ+vWH+4b4DvQWOfWk3e885Sz2lqz+GuNztGxxw= X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(346002)(136003)(396003)(376002)(39860400002)(46966006)(36840700001)(47076005)(7416002)(186003)(2906002)(7696005)(86362001)(26005)(1076003)(478600001)(8936002)(8676002)(336012)(5660300002)(426003)(82740400003)(54906003)(36756003)(107886003)(4326008)(83380400001)(82310400003)(36860700001)(316002)(7636003)(70586007)(70206006)(356005)(110136005)(2616005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:41.9618 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fef2c87e-6b77-4e4f-533f-08d967cf9be2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2731 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy Expose an 'override_only' helper macro (i.e. PCI_DRIVER_OVERRIDE_DEVICE_VFIO) for VFIO PCI sub system and add the required code to prefix its matching entries with "vfio_" in modules.alias file. It allows VFIO device drivers to include match entries in the modules.alias file produced by kbuild that are not used for normal driver autoprobing and module autoloading. Drivers using these match entries can be connected to the PCI device manually, by userspace, using the existing driver_override sysfs. For example the resulting modules.alias may have: alias pci:v000015B3d00001021sv*sd*bc*sc*i* mlx5_core alias vfio_pci:v000015B3d00001021sv*sd*bc*sc*i* mlx5_vfio_pci alias vfio_pci:v*d*sv*sd*bc*sc*i* vfio_pci In this example mlx5_core and mlx5_vfio_pci match to the same PCI device. The kernel will autoload and autobind to mlx5_core but the kernel and udev mechanisms will ignore mlx5_vfio_pci. When userspace wants to change a device to the VFIO subsystem it can implement a generic algorithm: 1) Identify the sysfs path to the device: /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 2) Get the modalias string from the kernel: $ cat /sys/bus/pci/devices/0000:01:00.0/modalias pci:v000015B3d00001021sv000015B3sd00000001bc02sc00i00 3) Prefix it with vfio_: vfio_pci:v000015B3d00001021sv000015B3sd00000001bc02sc00i00 4) Search modules.alias for the above string and select the entry that has the fewest *'s: alias vfio_pci:v000015B3d00001021sv*sd*bc*sc*i* mlx5_vfio_pci 5) modprobe the matched module name: $ modprobe mlx5_vfio_pci 6) cat the matched module name to driver_override: echo mlx5_vfio_pci > /sys/bus/pci/devices/0000:01:00.0/driver_override 7) unbind device from original module echo 0000:01:00.0 > /sys/bus/pci/devices/0000:01:00.0/driver/unbind 8) probe PCI drivers (or explicitly bind to mlx5_vfio_pci) echo 0000:01:00.0 > /sys/bus/pci/drivers_probe The algorithm is independent of bus type. In future the other buses with VFIO device drivers, like platform and ACPI, can use this algorithm as well. This patch is the infrastructure to provide the information in the modules.alias to userspace. Convert the only VFIO pci_driver which results in one new line in the modules.alias: alias vfio_pci:v*d*sv*sd*bc*sc*i* vfio_pci Later series introduce additional HW specific VFIO PCI drivers, such as mlx5_vfio_pci. Signed-off-by: Max Gurtovoy Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas Acked-by: Bjorn Helgaas # for pci.h --- drivers/vfio/pci/vfio_pci.c | 9 ++++++++- include/linux/mod_devicetable.h | 4 ++++ include/linux/pci.h | 14 ++++++++++++++ scripts/mod/devicetable-offsets.c | 1 + scripts/mod/file2alias.c | 8 ++++++-- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 163e560c4495..85fd638a5955 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -178,9 +178,16 @@ static int vfio_pci_sriov_configure(struct pci_dev *pdev, int nr_virtfn) return vfio_pci_core_sriov_configure(pdev, nr_virtfn); } +static const struct pci_device_id vfio_pci_table[] = { + { PCI_DRIVER_OVERRIDE_DEVICE_VFIO(PCI_ANY_ID, PCI_ANY_ID) }, /* match all by default */ + {} +}; + +MODULE_DEVICE_TABLE(pci, vfio_pci_table); + static struct pci_driver vfio_pci_driver = { .name = "vfio-pci", - .id_table = NULL, /* only dynamic ids */ + .id_table = vfio_pci_table, .probe = vfio_pci_probe, .remove = vfio_pci_remove, .sriov_configure = vfio_pci_sriov_configure, diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 2e3ba6d9ece0..f0325a172f87 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -16,6 +16,10 @@ typedef unsigned long kernel_ulong_t; #define PCI_ANY_ID (~0) +enum { + PCI_ID_F_VFIO_DRIVER_OVERRIDE = 1 << 0, +}; + /** * struct pci_device_id - PCI device ID structure * @vendor: Vendor ID to match (or PCI_ANY_ID) diff --git a/include/linux/pci.h b/include/linux/pci.h index 0506b1a8c921..527a1dfd1d06 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -916,6 +916,20 @@ struct pci_driver { .vendor = (vend), .device = (dev), .subvendor = PCI_ANY_ID, \ .subdevice = PCI_ANY_ID, .override_only = (driver_override) +/** + * PCI_DRIVER_OVERRIDE_DEVICE_VFIO - macro used to describe a VFIO + * "driver_override" PCI device. + * @vend: the 16 bit PCI Vendor ID + * @dev: the 16 bit PCI Device ID + * + * This macro is used to create a struct pci_device_id that matches a + * specific device. The subvendor and subdevice fields will be set to + * PCI_ANY_ID and the driver_override will be set to + * PCI_ID_F_VFIO_DRIVER_OVERRIDE. + */ +#define PCI_DRIVER_OVERRIDE_DEVICE_VFIO(vend, dev) \ + PCI_DEVICE_DRIVER_OVERRIDE(vend, dev, PCI_ID_F_VFIO_DRIVER_OVERRIDE) + /** * PCI_DEVICE_SUB - macro used to describe a specific PCI device with subsystem * @vend: the 16 bit PCI Vendor ID diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index 9bb6c7edccc4..cc3625617a0e 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -42,6 +42,7 @@ int main(void) DEVID_FIELD(pci_device_id, subdevice); DEVID_FIELD(pci_device_id, class); DEVID_FIELD(pci_device_id, class_mask); + DEVID_FIELD(pci_device_id, override_only); DEVID(ccw_device_id); DEVID_FIELD(ccw_device_id, match_flags); diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 7c97fa8e36bc..c3edbf73157e 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -426,7 +426,7 @@ static int do_ieee1394_entry(const char *filename, return 1; } -/* Looks like: pci:vNdNsvNsdNbcNscNiN. */ +/* Looks like: pci:vNdNsvNsdNbcNscNiN or _pci:vNdNsvNsdNbcNscNiN. */ static int do_pci_entry(const char *filename, void *symval, char *alias) { @@ -440,8 +440,12 @@ static int do_pci_entry(const char *filename, DEF_FIELD(symval, pci_device_id, subdevice); DEF_FIELD(symval, pci_device_id, class); DEF_FIELD(symval, pci_device_id, class_mask); + DEF_FIELD(symval, pci_device_id, override_only); - strcpy(alias, "pci:"); + if (override_only & PCI_ID_F_VFIO_DRIVER_OVERRIDE) + strcpy(alias, "vfio_pci:"); + else + strcpy(alias, "pci:"); ADD(alias, "v", vendor != PCI_ANY_ID, vendor); ADD(alias, "d", device != PCI_ANY_ID, device); ADD(alias, "sv", subvendor != PCI_ANY_ID, subvendor); From patchwork Wed Aug 25 13:51:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 822F4C432BE for ; Wed, 25 Aug 2021 13:52:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DBAE611AF for ; Wed, 25 Aug 2021 13:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241472AbhHYNxf (ORCPT ); Wed, 25 Aug 2021 09:53:35 -0400 Received: from mail-mw2nam10on2075.outbound.protection.outlook.com ([40.107.94.75]:7863 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241553AbhHYNxd (ORCPT ); Wed, 25 Aug 2021 09:53:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H7Fnxshk+yjdYrJdYjcG1Bv+gu1bsaL/wV4Hycsd8gKvysGFcUujKsXg5jy0eViHl3Q1HOJxelbUXSlDGclrhLqAuMcEI+JpNwL7r8kvCw1wzUFa5qWdY+WkfBHyeGl2QaqguBffMPcCeclJYXtvnWGSOkt0/60Iu3pRTDa3N1gjHj0RgDjN93mZREkA6BCqMxSSWd3fJFSqYWRPsk7c/TdrWrff04EpHsPW4O2nL/7Lhb/ad01KXUeyCJlw29syrwg/T4I6LKID3kVbD7ZFEkS4ecjPrvSDHei4WHr9URNwhG3uR30I24NMHXwIi6gtJEX9HAGJgs1cQmLCTvwnMQ== 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-SenderADCheck; bh=hcoz+mtO8t1q9AsRo4d5AWcflMVS8b8syDqG8CJho7c=; b=JBVChuPz4ArIZWNKMTskVnG/RFLSiUZh2wplNK9aLOuewWusKh8egGCpuQEV7G31xoGglRh3kBYgaDOY7GV5jsAR7sLDLAdiS72yJcn4JFXAyhKLe6qnm2mP0hRSQ8mRsjkArByrsOvhOnTh4wuSHtOA+VG1Tm4rg7HXkEQq2BBc2OpG/ZBq5r93r/Qs2szrRNAMsXJ8rgZoYqUbcn9+k1doyQU7KmOStJNBEgvX4QWb7adQhSrpADsFqOa9nGUeUGBpYmebT5JlxhvoqI1ZHALhiJ+Az5i2POgPFBvp82tzmMcflHPFrPIBP3q/mgDYOLeEmzJ9qzsbw/T1CzPaWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hcoz+mtO8t1q9AsRo4d5AWcflMVS8b8syDqG8CJho7c=; b=mrkvbiUbX6YeAQDUXRkRt31i2YM6WNZiAHYi674C6zG+NCV/NtPrNXLpVPNBetMgMbVQqLHF53MwWfgUSKRbAJX2OghVQFrnAnUwhG38QaQyPr1pU2stMZd3IRI8hE4U0oJDVec1UfurZxp56y1um7C7DvN/gVNb7UDMbaCQTcUXDKheZD2sTY9Vz1DqUJenk59uHaxS+JOu9KAx2+CViOYvnKdLUo7WuYUuu9ROMWxmyGaGk0IsUidDR/MpR7FiC4cb70htrpgTZBr/BbO3CTqIm7WEO4Y2CSRDVIMMgDr5k83tTaXbebC/MDl9keFfD1b854Tj/hIGA8pPLy8vjQ== Received: from MWHPR12CA0038.namprd12.prod.outlook.com (2603:10b6:301:2::24) by CH2PR12MB4101.namprd12.prod.outlook.com (2603:10b6:610:a8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 13:52:46 +0000 Received: from CO1NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:301:2:cafe::c8) by MWHPR12CA0038.outlook.office365.com (2603:10b6:301:2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.18 via Frontend Transport; Wed, 25 Aug 2021 13:52:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT053.mail.protection.outlook.com (10.13.175.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:45 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:45 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:41 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 11/13] vfio: Use select for eventfd Date: Wed, 25 Aug 2021 16:51:37 +0300 Message-ID: <20210825135139.79034-12-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4bfde61f-2b1b-4d84-a3f2-08d967cf9e11 X-MS-TrafficTypeDiagnostic: CH2PR12MB4101: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DLOQZc4T3M87sKLsFmS1vDQr/wEEmx5DMQXuu8mdsGieOd3se9JKBoCs5XmFrcQT3hHdfUPmp0by+GLwXHtPsJmeyX5cXkax7Ji3zLs+6EeMx/UnIYFMI2XuRslrzEoagEQ7pIU/VfUF7sJleTtyLT9NtHpUcLhLD+c17SNjQV+TwHmD+/c/s527YxE92sEbte4ULL2dOk9cXqTXrS/BmSTuqJlmcgKjelD17GZ8CZeGJYhSPMBmbno2n0PClOlWst5XNnbYNM2AVNNKZolWV5z3WzcnN9pPfGlsTHeMtiORc/0rCXmKxzK2rR7SYKcIQGGJWCu/8/XdaWsNmjAe0/GwjC426nXwDoDI3FTVKxuKXMq4sq1NpUOOYU/oz0Sn51daE42TZ+iry676D0g/jxrvAsxxCkly8/J7tUEk1emC9cZEd66gIqp2c49idXJQjn7LXuGtcgkQEp5dp7dNYj1syeT9y3qcqy6sLDIkJk2KARaUrub0PPAqpO2T8EiV+7C4FS9nnXlKelSGfOtm5D8gQMGhMG/tnpOyO8sWD6Zv2C1lXeeJDTX2zSQr1541TBFZP5cGv4pcSqMlIxZposc/J1AfBHTAI//x9nwR1CtqdpnK7GxkgwcEjjQMAtHmOf5IbWlAgnjgdfOOUwPobIrfK0c5Cy2kIsfDLNuo9eEnVH+UMG1EPjF7cYFliEP2x2kzRmfrYA+bVcER9AAeL/94FQs/AQXoun1rSzWHhQc= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(1076003)(508600001)(4326008)(82310400003)(336012)(47076005)(6666004)(8936002)(36860700001)(426003)(107886003)(7636003)(7696005)(83380400001)(186003)(5660300002)(36906005)(70206006)(316002)(8676002)(86362001)(26005)(36756003)(54906003)(110136005)(2906002)(7416002)(70586007)(356005)(2616005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:45.6403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bfde61f-2b1b-4d84-a3f2-08d967cf9e11 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4101 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Jason Gunthorpe If VFIO_VIRQFD is required then turn on eventfd automatically. The majority of kconfig users of the EVENTFD use select not depends on. Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/Kconfig | 3 ++- drivers/vfio/fsl-mc/Kconfig | 3 ++- drivers/vfio/pci/Kconfig | 2 +- drivers/vfio/platform/Kconfig | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index e44bf736e2b2..698ca35b3f03 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -16,7 +16,8 @@ config VFIO_SPAPR_EEH config VFIO_VIRQFD tristate - depends on VFIO && EVENTFD + depends on VFIO + select EVENTFD default n menuconfig VFIO diff --git a/drivers/vfio/fsl-mc/Kconfig b/drivers/vfio/fsl-mc/Kconfig index b1a527d6b6f2..6df66813c882 100644 --- a/drivers/vfio/fsl-mc/Kconfig +++ b/drivers/vfio/fsl-mc/Kconfig @@ -1,6 +1,7 @@ config VFIO_FSL_MC tristate "VFIO support for QorIQ DPAA2 fsl-mc bus devices" - depends on VFIO && FSL_MC_BUS && EVENTFD + depends on VFIO && FSL_MC_BUS + select EVENTFD help Driver to enable support for the VFIO QorIQ DPAA2 fsl-mc (Management Complex) devices. This is required to passthrough diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 5e2e1b9a9fd3..d208a95a2767 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config VFIO_PCI tristate "VFIO support for PCI devices" - depends on VFIO && PCI && EVENTFD + depends on VFIO && PCI depends on MMU select VFIO_VIRQFD select IRQ_BYPASS_MANAGER diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig index ab341108a0be..7f78eb96a5d5 100644 --- a/drivers/vfio/platform/Kconfig +++ b/drivers/vfio/platform/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config VFIO_PLATFORM tristate "VFIO support for platform devices" - depends on VFIO && EVENTFD && (ARM || ARM64 || COMPILE_TEST) + depends on VFIO && (ARM || ARM64 || COMPILE_TEST) select VFIO_VIRQFD help Support for platform devices with VFIO. This is required to make From patchwork Wed Aug 25 13:51:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C413C4320A for ; Wed, 25 Aug 2021 13:52:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14FC360EBC for ; Wed, 25 Aug 2021 13:52:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241555AbhHYNxj (ORCPT ); Wed, 25 Aug 2021 09:53:39 -0400 Received: from mail-bn8nam12on2065.outbound.protection.outlook.com ([40.107.237.65]:32384 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241567AbhHYNxi (ORCPT ); Wed, 25 Aug 2021 09:53:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BllVdBFl+9LOI2pnl2zJAxBZsYbBx5C/BtEw7zvM447oqdrHR674eDxGLTHRmdaGwvcrug8eYRUaefQwz44eDbOikPhsvipsFVcdByC3nL77mvdgbXrP8dSo+u2f2nti1mLnBD4N8vXbE1H5ZmhWZLEgYMH6KMI3CqELVdKWXj+4UpMkLXo0DnjdVUCrRPfy6jYkvC2SM3v4Sb7COROGUJzcm8YSDeHruzGHpOJQtdEpabeIPvwQXy22Ey9z3roLvJnpxfuSsvdVUj3gnbuKEUeUZNCYX2AKQRyazDy2sJpZxDJ0j71Qa0BrugToXk6Vt3AS8j8hGQKiIRRCzHhq8g== 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-SenderADCheck; bh=ScvnVbH5aFpm4+rLMaeiRmg0U15ebcGKQVsrvV9fT14=; b=CKrOl6v9otGZJCaA+MqVncr1Nj+gmchdC63PCBfzMoOYfefxex1UadIbV18fjEfiamvLXiNfE3X34YrgOlbRFqoLJYQZGmdiDzfS5LPCs24JUP6VJaAwii7LeejyuNC1cB1j+2sVdvbwUrcmYEYc1fLhkcO+XXADB/PVmhFMkIxiyVdM42p+Bwku2xwmiL3LOe7Bw/mZWR2j4dXyuI4KHlfCN+xcDDfHn5CU0ahyiOQAlL7RFfrf9hKo6E8683ixmQUtzVRBcbmOwnuSAs2vMr5qYObAkAQlhb5NLtbWVKz/gxnegeZQrwI91dZ+z5ZwO2d3z87lsxwNMZtdANN17A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ScvnVbH5aFpm4+rLMaeiRmg0U15ebcGKQVsrvV9fT14=; b=K0pBPxHo/sGkPZ4QtyMolPSasOe0VPcI4dd06DMEvlM3T3SbILCFjQrleEqG9Op5+fNgMx7/RyDaHmdvFGGcsK9A30u9o+KGYqAJQto8A6IzMw5zopAMAwkpVuiX5rmrpjvkkdLwl72GZVQczr+kEBejmOYS9A3+tGMeIIRl7aVnSuZYYKlSewmwIr41ui839NS8V1lYdw9QWBZeiu1YFFTYp5hyCOErf7r+awgkg2nk8Kw56GhsfiTgBcZe4mjJTt0R3Raew/iqZJ39oZQDqe01gEAFl1mbg11FiK7D3FHivZoAWzWrt4x5JH8/d70VgQC051VJebpf3j/mmL8k/g== Received: from MW4PR04CA0014.namprd04.prod.outlook.com (2603:10b6:303:69::19) by DM6PR12MB2809.namprd12.prod.outlook.com (2603:10b6:5:4a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17; Wed, 25 Aug 2021 13:52:50 +0000 Received: from CO1NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:303:69:cafe::54) by MW4PR04CA0014.outlook.office365.com (2603:10b6:303:69::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by CO1NAM11FT028.mail.protection.outlook.com (10.13.175.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:50 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 06:52:49 -0700 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:45 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 12/13] vfio: Use kconfig if XX/endif blocks instead of repeating 'depends on' Date: Wed, 25 Aug 2021 16:51:38 +0300 Message-ID: <20210825135139.79034-13-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0b8cfc58-0ac3-43a8-f6cb-08d967cfa0dd X-MS-TrafficTypeDiagnostic: DM6PR12MB2809: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nOj9zq1ex0oXN1vjRynpwgp8d6c718HLLCANGp9hdcxOG0in+CHuwT4wrFsU/FFJbl9RWpp6VSoGf6DMLEKA2W0mEosO+zkc0qd+tPzgK3bM5nm/7m6VKZUlkMKtUsMD+MpO3YBoEX29kMMMFX0cjIu16pnYVgzLAZATsWBWQybaiE5vO4IQx4AgIJwUOXjECeQArIhr5askAvs/AuRoAP98RR3ljazc2Hdd0fwHH6TsdQ6gf3GVoGTgXBPcin2qBgzGla1yJNwq+3HCDc75Ubv2xYx3gdUzZE0k+BNHIm6DmQ8SoBVd4e3CyNi7oWne7DLqCxpoXqJiYDQ6bsyQN+wwOzPYv3gwHKNuiVU1YYmSkgUI43pm9MiL+5b3jwgxkfMWrWWsRvysuYCsD54qeAcm1eZn624NLtZM5ttREFyREsDl4QcAeLsLJyzhle1wDn200Db94dL2PlFfN/740ISss8FFCyAe2aadx0X4keh3yGmx5N3cKjl7J9v20F0hYvYezpJxTL4JH9tqyK7yq1TIdbqLq2ta3c/5DO43b1MoqlLeYa3TQeGj5GlNCBhOOFsvWCsU0s0mjIfrcRqRLl8CoqtUZ3KVi+l9R84dECvi8GrU4/lzY2R0EjNnS3L6OI/um9rMYdhSrFzyx+gN3rsRB8UNAlJl961pxuM6Ph37MkwTb9KdswK4UocnLqaR8iIS+I/8xk+4k64o2G5XHHawxdziKMYpm+5ORCfbdQQ= X-Forefront-Antispam-Report: CIP:216.228.112.32;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid01.nvidia.com;CAT:NONE;SFS:(4636009)(376002)(396003)(136003)(346002)(39860400002)(46966006)(36840700001)(70586007)(426003)(70206006)(7696005)(356005)(86362001)(1076003)(2616005)(336012)(8676002)(7636003)(82740400003)(8936002)(36756003)(7416002)(6666004)(83380400001)(4326008)(110136005)(107886003)(26005)(316002)(54906003)(5660300002)(82310400003)(186003)(2906002)(478600001)(47076005)(36860700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:50.3458 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b8cfc58-0ac3-43a8-f6cb-08d967cfa0dd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.32];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2809 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Jason Gunthorpe This results in less kconfig wordage and a simpler understanding of the required "depends on" to create the menu structure. The next patch increases the nesting level a lot so this is a nice preparatory simplification. Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- drivers/vfio/Kconfig | 28 ++++++++++++++-------------- drivers/vfio/fsl-mc/Kconfig | 2 +- drivers/vfio/mdev/Kconfig | 1 - drivers/vfio/pci/Kconfig | 11 ++++++----- drivers/vfio/platform/Kconfig | 6 ++++-- drivers/vfio/platform/reset/Kconfig | 4 +--- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index 698ca35b3f03..6130d00252ed 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -1,12 +1,22 @@ # SPDX-License-Identifier: GPL-2.0-only +menuconfig VFIO + tristate "VFIO Non-Privileged userspace driver framework" + select IOMMU_API + select VFIO_IOMMU_TYPE1 if MMU && (X86 || S390 || ARM || ARM64) + help + VFIO provides a framework for secure userspace device drivers. + See Documentation/driver-api/vfio.rst for more details. + + If you don't know what to do here, say N. + +if VFIO config VFIO_IOMMU_TYPE1 tristate - depends on VFIO default n config VFIO_IOMMU_SPAPR_TCE tristate - depends on VFIO && SPAPR_TCE_IOMMU + depends on SPAPR_TCE_IOMMU default VFIO config VFIO_SPAPR_EEH @@ -16,23 +26,11 @@ config VFIO_SPAPR_EEH config VFIO_VIRQFD tristate - depends on VFIO select EVENTFD default n -menuconfig VFIO - tristate "VFIO Non-Privileged userspace driver framework" - select IOMMU_API - select VFIO_IOMMU_TYPE1 if MMU && (X86 || S390 || ARM || ARM64) - help - VFIO provides a framework for secure userspace device drivers. - See Documentation/driver-api/vfio.rst for more details. - - If you don't know what to do here, say N. - config VFIO_NOIOMMU bool "VFIO No-IOMMU support" - depends on VFIO help VFIO is built on the ability to isolate devices using the IOMMU. Only with an IOMMU can userspace access to DMA capable devices be @@ -49,4 +47,6 @@ source "drivers/vfio/pci/Kconfig" source "drivers/vfio/platform/Kconfig" source "drivers/vfio/mdev/Kconfig" source "drivers/vfio/fsl-mc/Kconfig" +endif + source "virt/lib/Kconfig" diff --git a/drivers/vfio/fsl-mc/Kconfig b/drivers/vfio/fsl-mc/Kconfig index 6df66813c882..597d338c5c8a 100644 --- a/drivers/vfio/fsl-mc/Kconfig +++ b/drivers/vfio/fsl-mc/Kconfig @@ -1,6 +1,6 @@ config VFIO_FSL_MC tristate "VFIO support for QorIQ DPAA2 fsl-mc bus devices" - depends on VFIO && FSL_MC_BUS + depends on FSL_MC_BUS select EVENTFD help Driver to enable support for the VFIO QorIQ DPAA2 fsl-mc diff --git a/drivers/vfio/mdev/Kconfig b/drivers/vfio/mdev/Kconfig index 763c877a1318..646dbed44eb2 100644 --- a/drivers/vfio/mdev/Kconfig +++ b/drivers/vfio/mdev/Kconfig @@ -2,7 +2,6 @@ config VFIO_MDEV tristate "Mediated device driver framework" - depends on VFIO default n help Provides a framework to virtualize devices. diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index d208a95a2767..afdab7d71e98 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config VFIO_PCI tristate "VFIO support for PCI devices" - depends on VFIO && PCI + depends on PCI depends on MMU select VFIO_VIRQFD select IRQ_BYPASS_MANAGER @@ -11,9 +11,10 @@ config VFIO_PCI If you don't know what to do here, say N. +if VFIO_PCI config VFIO_PCI_VGA bool "VFIO PCI support for VGA devices" - depends on VFIO_PCI && X86 && VGA_ARB + depends on X86 && VGA_ARB help Support for VGA extension to VFIO PCI. This exposes an additional region on VGA devices for accessing legacy VGA addresses used by @@ -22,16 +23,14 @@ config VFIO_PCI_VGA If you don't know what to do here, say N. config VFIO_PCI_MMAP - depends on VFIO_PCI def_bool y if !S390 config VFIO_PCI_INTX - depends on VFIO_PCI def_bool y if !S390 config VFIO_PCI_IGD bool "VFIO PCI extensions for Intel graphics (GVT-d)" - depends on VFIO_PCI && X86 + depends on X86 default y help Support for Intel IGD specific extensions to enable direct @@ -40,3 +39,5 @@ config VFIO_PCI_IGD and LPC bridge config space. To enable Intel IGD assignment through vfio-pci, say Y. + +endif diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig index 7f78eb96a5d5..331a5920f5ab 100644 --- a/drivers/vfio/platform/Kconfig +++ b/drivers/vfio/platform/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config VFIO_PLATFORM tristate "VFIO support for platform devices" - depends on VFIO && (ARM || ARM64 || COMPILE_TEST) + depends on ARM || ARM64 || COMPILE_TEST select VFIO_VIRQFD help Support for platform devices with VFIO. This is required to make @@ -10,9 +10,10 @@ config VFIO_PLATFORM If you don't know what to do here, say N. +if VFIO_PLATFORM config VFIO_AMBA tristate "VFIO support for AMBA devices" - depends on VFIO_PLATFORM && (ARM_AMBA || COMPILE_TEST) + depends on ARM_AMBA || COMPILE_TEST help Support for ARM AMBA devices with VFIO. This is required to make use of ARM AMBA devices present on the system using the VFIO @@ -21,3 +22,4 @@ config VFIO_AMBA If you don't know what to do here, say N. source "drivers/vfio/platform/reset/Kconfig" +endif diff --git a/drivers/vfio/platform/reset/Kconfig b/drivers/vfio/platform/reset/Kconfig index 1edbe9ee7356..12f5f3d80387 100644 --- a/drivers/vfio/platform/reset/Kconfig +++ b/drivers/vfio/platform/reset/Kconfig @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only config VFIO_PLATFORM_CALXEDAXGMAC_RESET tristate "VFIO support for calxeda xgmac reset" - depends on VFIO_PLATFORM help Enables the VFIO platform driver to handle reset for Calxeda xgmac @@ -9,7 +8,6 @@ config VFIO_PLATFORM_CALXEDAXGMAC_RESET config VFIO_PLATFORM_AMDXGBE_RESET tristate "VFIO support for AMD XGBE reset" - depends on VFIO_PLATFORM help Enables the VFIO platform driver to handle reset for AMD XGBE @@ -17,7 +15,7 @@ config VFIO_PLATFORM_AMDXGBE_RESET config VFIO_PLATFORM_BCMFLEXRM_RESET tristate "VFIO support for Broadcom FlexRM reset" - depends on VFIO_PLATFORM && (ARCH_BCM_IPROC || COMPILE_TEST) + depends on ARCH_BCM_IPROC || COMPILE_TEST default ARCH_BCM_IPROC help Enables the VFIO platform driver to handle reset for Broadcom FlexRM From patchwork Wed Aug 25 13:51:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 12457625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-24.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DFBDC4320A for ; Wed, 25 Aug 2021 13:53:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C12460E93 for ; Wed, 25 Aug 2021 13:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240738AbhHYNyT (ORCPT ); Wed, 25 Aug 2021 09:54:19 -0400 Received: from mail-bn7nam10on2087.outbound.protection.outlook.com ([40.107.92.87]:50838 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241074AbhHYNxn (ORCPT ); Wed, 25 Aug 2021 09:53:43 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YDgb1ZhVOpkn4rej6P5CgQPdyhs3BqQyjgLXQK4FfBRBQNZ4yEwU7UfkHfEHcFsxYZ65n0Tw/r4jB29AZs3mDutl4TGdRaBkWGIlsDR+MM9we63iugsTtBPzENL/ylKJugd4PA/qGpP9ZETId1zc6FRQrWNoA2d5Vdshuo08LssCIu5Wb8iZtanCVVqvk89od1Ck/Q7DIqIveJOyWyfBkgfb/Jq4zAoB8Q1F9cUALryMya0+CS/E7hpWJzfVaSUz74PfKF/NJ84fiRMNAzAlnTntr0Uu0ZUtTMcLexOl7PBsQXJQ8Cc5XWFttrITqgt5hpxwqrZV/js/6J1FYm6AJQ== 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-SenderADCheck; bh=OK4ZVhOygLsghi5ckOtSqxgto2C5jDi5olS+tNNQVSE=; b=ZCpXVO9RHBLJa0exlaz0dxM5cbrus9fZ4UJQ/i4wpXfYhSReZULGkCWEPeniS0h8cPgKJvquUoxvZa53bW/EFBkkV8Pr7G9vAGFp7299INsAgjxWk6R2/gxIPCoADxiVsagT/fbteZNNb4eSuBvPIJ4YrW/1OCc57Y4elsMqsc4zWyM89HedK3815hKW8A6ZInCEr0NABQdgVOlcbdunWVl0/aMyFk2gQDjJg/IOHk7/hCbXBca5MKskbAXkAmqmPvgsV1sM9nSZtSvJG3BvADRkFCO8Nn5Lzs34t3D/bG+PyEPaOlVFAFZTH1WmLxiMEV8ylWHXj8CplAHcN4gAAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OK4ZVhOygLsghi5ckOtSqxgto2C5jDi5olS+tNNQVSE=; b=lyU/4GRXnbjk/3jz46Gj1aiDzr68nq0v00dnr+W0Pjo6+3Nzl0XDFpa4aZtiM8XZxlpfoiNvxUvc92iTN9a5bkodPYqn8mzmFkF8Q04P+XBvwgxfybVUaSbEW749ljOkwCBPOXQFmqwHNUm/ebQS3VlPRJUggEuOFwRfmoxBx6L9H2PwbMXxeHq6HriEUsJ4zjIYD7vJ3/BnyOiu47o2wfAHCHotqscaWwyxgh5rLczJ58hkHz6u+mrSzbsfyz6duIE9jVRcuo+72LC322QOYnVSTXNyuwtT41DcGUdCuOuEgtDuloqbsOENtiP24U00wMS1crYfAIVVV7gSBmibdQ== Received: from BN9PR03CA0302.namprd03.prod.outlook.com (2603:10b6:408:112::7) by CH2PR12MB3685.namprd12.prod.outlook.com (2603:10b6:610:2d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.22; Wed, 25 Aug 2021 13:52:54 +0000 Received: from BN8NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::81) by BN9PR03CA0302.outlook.office365.com (2603:10b6:408:112::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Wed, 25 Aug 2021 13:52:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by BN8NAM11FT041.mail.protection.outlook.com (10.13.177.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4457.17 via Frontend Transport; Wed, 25 Aug 2021 13:52:54 +0000 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 25 Aug 2021 13:52:53 +0000 Received: from vdi.nvidia.com (172.20.187.5) by mail.nvidia.com (172.20.187.15) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 25 Aug 2021 06:52:49 -0700 From: Yishai Hadas To: , , , , , , , CC: , , , , , , , , , Subject: [PATCH V4 13/13] vfio/pci: Introduce vfio_pci_core.ko Date: Wed, 25 Aug 2021 16:51:39 +0300 Message-ID: <20210825135139.79034-14-yishaih@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210825135139.79034-1-yishaih@nvidia.com> References: <20210825135139.79034-1-yishaih@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6b5cc121-a020-43cb-1c4e-08d967cfa34a X-MS-TrafficTypeDiagnostic: CH2PR12MB3685: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yNA/Wv3agtQQreLw5Z9VRg+STretq1NLU2Cq1M8JJ7ADo1lniQ6dX5e0g0BEfFLyuTZKQsQ6lx1+9lIo3XpPWO9J1Y5hDllwPLOrzOCU38sCgxGyHuKeOTqG7Hm02HLUaxCR1QtnHAuzguOmMOeswyRSlnNvjTYOuhwirOj2bqFn2DTcWOKYbl/ZEDSUgIYY9MKmKoCEB+VBl0svTFzILWx0gkmebyJtgR7eAN371yb53vyaIy2sxSU7Q18LXZw0EfiHcQsyX1U8fpfJkJT3FS5aZImFofRx/azY0QahtV577y5wsdJvLSZRXEDRWa5R9fCN/DB+jit+C61yMdSrX2iQJOuOUcQ9IHBM4NaRRpRaexXyImCOn6HK7BN0yhGwBrYZzZJcfH5QSldqHHUumGWXcsG9FbNazDtYoAH7KShG/CmDHXOo02VD7fqBWi0RLq0YYXImj5/rbpUZeZkk3TIkqqTcR6izNcdDnOOK85XxMMNSnE4GBR0tJ0Y3ubuJFxLdHrsvNsEmsf1pALeSuPylT75h6eiiRK4AHZWKU7jYc45ggnhvfasEzqfSM4TZM6CRizojNRjJhxwY3qcZq8Ciasl9KnFaPzaUkuio+L5LOeHnFvzZSBGZy93stnHl8Bc2aFzslDpt9EJciBJ/CR1ewey4aa2w4ZmrwIzs8RfIsno1UDUYffdZeQE1EJHoGdX26FMCeSylHefz92LS0bfAncjvKHNKtyeat3c+KIs= X-Forefront-Antispam-Report: CIP:216.228.112.36;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid05.nvidia.com;CAT:NONE;SFS:(4636009)(376002)(396003)(39860400002)(136003)(346002)(36840700001)(46966006)(6666004)(4326008)(5660300002)(107886003)(30864003)(82310400003)(83380400001)(8936002)(36860700001)(2906002)(2616005)(47076005)(70586007)(36756003)(8676002)(70206006)(186003)(26005)(356005)(86362001)(1076003)(7636003)(36906005)(54906003)(316002)(7416002)(7696005)(426003)(336012)(82740400003)(110136005)(478600001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2021 13:52:54.3391 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6b5cc121-a020-43cb-1c4e-08d967cfa34a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.36];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3685 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org From: Max Gurtovoy Now that vfio_pci has been split into two source modules, one focusing on the "struct pci_driver" (vfio_pci.c) and a toolbox library of code (vfio_pci_core.c), complete the split and move them into two different kernel modules. As before vfio_pci.ko continues to present the same interface under sysfs and this change will have no functional impact. Splitting into another module and adding exports allows creating new HW specific VFIO PCI drivers that can implement device specific functionality, such as VFIO migration interfaces or specialized device requirements. Signed-off-by: Max Gurtovoy Signed-off-by: Jason Gunthorpe Signed-off-by: Yishai Hadas Reviewed-by: Christoph Hellwig --- MAINTAINERS | 1 + drivers/vfio/pci/Kconfig | 33 +++++++++------- drivers/vfio/pci/Makefile | 8 ++-- drivers/vfio/pci/vfio_pci.c | 14 ++----- drivers/vfio/pci/vfio_pci_config.c | 2 +- drivers/vfio/pci/vfio_pci_core.c | 39 ++++++++++++++++--- drivers/vfio/pci/vfio_pci_igd.c | 2 +- drivers/vfio/pci/vfio_pci_intrs.c | 2 +- drivers/vfio/pci/vfio_pci_rdwr.c | 2 +- drivers/vfio/pci/vfio_pci_zdev.c | 2 +- .../pci => include/linux}/vfio_pci_core.h | 2 - 11 files changed, 65 insertions(+), 42 deletions(-) rename {drivers/vfio/pci => include/linux}/vfio_pci_core.h (99%) diff --git a/MAINTAINERS b/MAINTAINERS index c9467d2839f5..7f0fcaa8ee67 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19466,6 +19466,7 @@ T: git git://github.com/awilliam/linux-vfio.git F: Documentation/driver-api/vfio.rst F: drivers/vfio/ F: include/linux/vfio.h +F: include/linux/vfio_pci_core.h F: include/uapi/linux/vfio.h VFIO FSL-MC DRIVER diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index afdab7d71e98..860424ccda1b 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -1,19 +1,28 @@ # SPDX-License-Identifier: GPL-2.0-only -config VFIO_PCI - tristate "VFIO support for PCI devices" - depends on PCI - depends on MMU +if PCI && MMU +config VFIO_PCI_CORE + tristate select VFIO_VIRQFD select IRQ_BYPASS_MANAGER + +config VFIO_PCI_MMAP + def_bool y if !S390 + +config VFIO_PCI_INTX + def_bool y if !S390 + +config VFIO_PCI + tristate "Generic VFIO support for any PCI device" + select VFIO_PCI_CORE help - Support for the PCI VFIO bus driver. This is required to make - use of PCI drivers using the VFIO framework. + Support for the generic PCI VFIO bus driver which can connect any + PCI device to the VFIO framework. If you don't know what to do here, say N. if VFIO_PCI config VFIO_PCI_VGA - bool "VFIO PCI support for VGA devices" + bool "Generic VFIO PCI support for VGA devices" depends on X86 && VGA_ARB help Support for VGA extension to VFIO PCI. This exposes an additional @@ -22,14 +31,8 @@ config VFIO_PCI_VGA If you don't know what to do here, say N. -config VFIO_PCI_MMAP - def_bool y if !S390 - -config VFIO_PCI_INTX - def_bool y if !S390 - config VFIO_PCI_IGD - bool "VFIO PCI extensions for Intel graphics (GVT-d)" + bool "Generic VFIO PCI extensions for Intel graphics (GVT-d)" depends on X86 default y help @@ -39,5 +42,5 @@ config VFIO_PCI_IGD and LPC bridge config space. To enable Intel IGD assignment through vfio-pci, say Y. - +endif endif diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile index 8aa517b4b671..349d68d242b4 100644 --- a/drivers/vfio/pci/Makefile +++ b/drivers/vfio/pci/Makefile @@ -1,7 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only -vfio-pci-y := vfio_pci.o vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o -vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o -vfio-pci-$(CONFIG_S390) += vfio_pci_zdev.o +vfio-pci-core-y := vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio_pci_config.o +vfio-pci-core-$(CONFIG_S390) += vfio_pci_zdev.o +obj-$(CONFIG_VFIO_PCI_CORE) += vfio-pci-core.o +vfio-pci-y := vfio_pci.o +vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o obj-$(CONFIG_VFIO_PCI) += vfio-pci.o diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 85fd638a5955..a5ce92beb655 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -25,7 +25,7 @@ #include #include -#include "vfio_pci_core.h" +#include #define DRIVER_AUTHOR "Alex Williamson " #define DRIVER_DESC "VFIO PCI - User Level meta-driver" @@ -153,6 +153,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret = vfio_pci_core_register_device(vdev); if (ret) goto out_free; + dev_set_drvdata(&pdev->dev, vdev); return 0; out_free: @@ -246,14 +247,10 @@ static int __init vfio_pci_init(void) vfio_pci_core_set_params(nointxmask, is_disable_vga, disable_idle_d3); - ret = vfio_pci_core_init(); - if (ret) - return ret; - /* Register and scan for devices */ ret = pci_register_driver(&vfio_pci_driver); if (ret) - goto out; + return ret; vfio_pci_fill_ids(); @@ -261,17 +258,12 @@ static int __init vfio_pci_init(void) pr_warn("device denylist disabled.\n"); return 0; - -out: - vfio_pci_core_cleanup(); - return ret; } module_init(vfio_pci_init); static void __exit vfio_pci_cleanup(void) { pci_unregister_driver(&vfio_pci_driver); - vfio_pci_core_cleanup(); } module_exit(vfio_pci_cleanup); diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c index 1f034f768a27..6e58b4bf7a60 100644 --- a/drivers/vfio/pci/vfio_pci_config.c +++ b/drivers/vfio/pci/vfio_pci_config.c @@ -26,7 +26,7 @@ #include #include -#include "vfio_pci_core.h" +#include /* Fake capability ID for standard config space */ #define PCI_CAP_ID_BASIC 0 diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 65eafaafb2e0..675616e08897 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -8,6 +8,8 @@ * Author: Tom Lyon, pugs@cisco.com */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -25,7 +27,10 @@ #include #include -#include "vfio_pci_core.h" +#include + +#define DRIVER_AUTHOR "Alex Williamson " +#define DRIVER_DESC "core driver for VFIO based PCI devices" static bool nointxmask; static bool disable_vga; @@ -306,6 +311,7 @@ int vfio_pci_core_enable(struct vfio_pci_core_device *vdev) return 0; } +EXPORT_SYMBOL_GPL(vfio_pci_core_enable); void vfio_pci_core_disable(struct vfio_pci_core_device *vdev) { @@ -403,6 +409,7 @@ void vfio_pci_core_disable(struct vfio_pci_core_device *vdev) if (!vfio_pci_dev_set_try_reset(vdev->vdev.dev_set) && !disable_idle_d3) vfio_pci_set_power_state(vdev, PCI_D3hot); } +EXPORT_SYMBOL_GPL(vfio_pci_core_disable); static struct vfio_pci_core_device *get_pf_vdev(struct vfio_pci_core_device *vdev) { @@ -459,6 +466,7 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev) } mutex_unlock(&vdev->igate); } +EXPORT_SYMBOL_GPL(vfio_pci_core_close_device); void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev) { @@ -466,6 +474,7 @@ void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev) vfio_spapr_pci_eeh_open(vdev->pdev); vfio_pci_vf_token_user_add(vdev, 1); } +EXPORT_SYMBOL_GPL(vfio_pci_core_finish_enable); static int vfio_pci_get_irq_count(struct vfio_pci_core_device *vdev, int irq_type) { @@ -624,6 +633,7 @@ int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev, return 0; } +EXPORT_SYMBOL_GPL(vfio_pci_register_dev_region); long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, unsigned long arg) @@ -1168,6 +1178,7 @@ long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd, return -ENOTTY; } +EXPORT_SYMBOL_GPL(vfio_pci_core_ioctl); static ssize_t vfio_pci_rw(struct vfio_pci_core_device *vdev, char __user *buf, size_t count, loff_t *ppos, bool iswrite) @@ -1211,6 +1222,7 @@ ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *buf, return vfio_pci_rw(vdev, buf, count, ppos, false); } +EXPORT_SYMBOL_GPL(vfio_pci_core_read); ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *buf, size_t count, loff_t *ppos) @@ -1223,6 +1235,7 @@ ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *bu return vfio_pci_rw(vdev, (char __user *)buf, count, ppos, true); } +EXPORT_SYMBOL_GPL(vfio_pci_core_write); /* Return 1 on zap and vma_lock acquired, 0 on contention (only with @try) */ static int vfio_pci_zap_and_vma_lock(struct vfio_pci_core_device *vdev, bool try) @@ -1501,6 +1514,7 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma return 0; } +EXPORT_SYMBOL_GPL(vfio_pci_core_mmap); void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count) { @@ -1523,6 +1537,7 @@ void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count) mutex_unlock(&vdev->igate); } +EXPORT_SYMBOL_GPL(vfio_pci_core_request); static int vfio_pci_validate_vf_token(struct vfio_pci_core_device *vdev, bool vf_token, uuid_t *uuid) @@ -1667,6 +1682,7 @@ int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf) return 1; /* Match */ } +EXPORT_SYMBOL_GPL(vfio_pci_core_match); static int vfio_pci_bus_notifier(struct notifier_block *nb, unsigned long action, void *data) @@ -1775,6 +1791,7 @@ void vfio_pci_core_init_device(struct vfio_pci_core_device *vdev, INIT_LIST_HEAD(&vdev->vma_list); init_rwsem(&vdev->memory_lock); } +EXPORT_SYMBOL_GPL(vfio_pci_core_init_device); void vfio_pci_core_uninit_device(struct vfio_pci_core_device *vdev) { @@ -1785,6 +1802,7 @@ void vfio_pci_core_uninit_device(struct vfio_pci_core_device *vdev) kfree(vdev->region); kfree(vdev->pm_save); } +EXPORT_SYMBOL_GPL(vfio_pci_core_uninit_device); int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev) { @@ -1852,7 +1870,6 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev) ret = vfio_register_group_dev(&vdev->vdev); if (ret) goto out_power; - dev_set_drvdata(&pdev->dev, vdev); return 0; out_power: @@ -1864,6 +1881,7 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev) vfio_iommu_group_put(group, &pdev->dev); return ret; } +EXPORT_SYMBOL_GPL(vfio_pci_core_register_device); void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev) { @@ -1881,6 +1899,7 @@ void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev) if (!disable_idle_d3) vfio_pci_set_power_state(vdev, PCI_D0); } +EXPORT_SYMBOL_GPL(vfio_pci_core_unregister_device); static pci_ers_result_t vfio_pci_aer_err_detected(struct pci_dev *pdev, pci_channel_state_t state) @@ -1924,10 +1943,12 @@ int vfio_pci_core_sriov_configure(struct pci_dev *pdev, int nr_virtfn) return ret < 0 ? ret : nr_virtfn; } +EXPORT_SYMBOL_GPL(vfio_pci_core_sriov_configure); const struct pci_error_handlers vfio_pci_core_err_handlers = { .error_detected = vfio_pci_aer_err_detected, }; +EXPORT_SYMBOL_GPL(vfio_pci_core_err_handlers); static bool vfio_dev_in_groups(struct vfio_pci_core_device *vdev, struct vfio_pci_group_info *groups) @@ -2116,16 +2137,22 @@ void vfio_pci_core_set_params(bool is_nointxmask, bool is_disable_vga, disable_vga = is_disable_vga; disable_idle_d3 = is_disable_idle_d3; } +EXPORT_SYMBOL_GPL(vfio_pci_core_set_params); -/* This will become the __exit function of vfio_pci_core.ko */ -void vfio_pci_core_cleanup(void) +static void vfio_pci_core_cleanup(void) { vfio_pci_uninit_perm_bits(); } -/* This will become the __init function of vfio_pci_core.ko */ -int __init vfio_pci_core_init(void) +static int __init vfio_pci_core_init(void) { /* Allocate shared config space permission data used by all devices */ return vfio_pci_init_perm_bits(); } + +module_init(vfio_pci_core_init); +module_exit(vfio_pci_core_cleanup); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c index a324ca7e6b5a..7ca4109bba48 100644 --- a/drivers/vfio/pci/vfio_pci_igd.c +++ b/drivers/vfio/pci/vfio_pci_igd.c @@ -15,7 +15,7 @@ #include #include -#include "vfio_pci_core.h" +#include #define OPREGION_SIGNATURE "IntelGraphicsMem" #define OPREGION_SIZE (8 * 1024) diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index 945ddbdf4d11..6069a11fb51a 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -20,7 +20,7 @@ #include #include -#include "vfio_pci_core.h" +#include /* * INTx diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c index 8fff4689dd44..57d3b2cbbd8e 100644 --- a/drivers/vfio/pci/vfio_pci_rdwr.c +++ b/drivers/vfio/pci/vfio_pci_rdwr.c @@ -17,7 +17,7 @@ #include #include -#include "vfio_pci_core.h" +#include #ifdef __LITTLE_ENDIAN #define vfio_ioread64 ioread64 diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c index 2ffbdc11f089..fe4def9ffffb 100644 --- a/drivers/vfio/pci/vfio_pci_zdev.c +++ b/drivers/vfio/pci/vfio_pci_zdev.c @@ -19,7 +19,7 @@ #include #include -#include "vfio_pci_core.h" +#include /* * Add the Base PCI Function information to the device info region. diff --git a/drivers/vfio/pci/vfio_pci_core.h b/include/linux/vfio_pci_core.h similarity index 99% rename from drivers/vfio/pci/vfio_pci_core.h rename to include/linux/vfio_pci_core.h index 7a2da1e14de3..ef9a44b6cf5d 100644 --- a/drivers/vfio/pci/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -207,8 +207,6 @@ static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev, #endif /* Will be exported for vfio pci drivers usage */ -void vfio_pci_core_cleanup(void); -int vfio_pci_core_init(void); void vfio_pci_core_set_params(bool nointxmask, bool is_disable_vga, bool is_disable_idle_d3); void vfio_pci_core_close_device(struct vfio_device *core_vdev);