From patchwork Wed Nov 30 00:10:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13059361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2922C4167B for ; Wed, 30 Nov 2022 00:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230242AbiK3AK3 (ORCPT ); Tue, 29 Nov 2022 19:10:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbiK3AK0 (ORCPT ); Tue, 29 Nov 2022 19:10:26 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2079.outbound.protection.outlook.com [40.107.95.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA01303C8 for ; Tue, 29 Nov 2022 16:10:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HgoHtZbDAHqdeW+8aQR8/bzddq2cgIHbFUxtACCzD5Hs3HwrYMLll0US0POq7Xz1MysQYyke1wrMGmp0iBifohSbCC+Lzx6vr+5Ysp75q+sTlBikOgh/mvFkulLdyhpfjIONMhd44Mdj8tzKZi6OHClrwaWsdLASQNdVv2altbEiUrsKFlIeLitZuj5gxdQgSFCwthY9UHQK+9VPd0kCP7ky+DAxobwmt3pzJee1q+BWJJxRaWggUnc/qyIb77uxCZFNWozlObtCy3dmwuN0XlC0DDqNgocU3f5OnepUgfzqCrjJS/TBukgqCcKk/XY9FHJmGPeArVnIdixmfwhM3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jiwe55+5XzojHHBu0bgH+CUW0f7/keT5MIZteY5G8YA=; b=BJpwOXFBgJQUOm2WFnViyAZuiP764GNLPNt3aK3/9Tnx8NBba50puv0SUYr/50naoK6CaNb2FamnXJtFR/3Yn8+D3lDEtRPL+PJjwjBoabLYaNLQvOm4I1IAmSn1AoC4xEP4oLNoDsPm3rVdQ5+5me6MG/neG744Z5IML8ZbpLyXHcgiZt/LeIL1Q4pbPliOaG4jOzXXCLxuwGTBxZtvEmQpP2l4H6lFSFQ99Zi/W+AmYirSvT1DUzkmx1V2F8iIKhIyNxMb/DkPfL7DRcTAgqaA+WW6EXL9gDvj7R3a0mXbdGJkrNNfrSVSDe9Zv/dT0/UVUWE5XeZH8XBpqG3ISA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=jiwe55+5XzojHHBu0bgH+CUW0f7/keT5MIZteY5G8YA=; b=k/Q4ZCW8Ly228igcYii5uw6Fcas1rboHbGciaas3CUbvQ7R5FEt9cOUloKAyMpstZHNF39+iAGcpKTP7V2CjTKJnNDdD6qf5EZQfgu6AC/ApaJQ3+St30o8ibuPkMbQlPXH/X++Ll00MXm69vzYWNxh5leRTaIM43pnamB5iKqkb3LQw+0zM/IX6adrXmY3k4PRGbJptuukb9kPbQniIQ2fnnakuvGa7UYS2qt6d980a7XE5LQ1RzK/oG1N2TJeFYSPveGTqIrsO85SGoWa5BJNOTE+2B8S0kF9fU8Ti84CLeEX2JOfZpmM6VW2qsbp44+nBPZ/MKVlcN6NPoUgxXQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB7411.namprd12.prod.outlook.com (2603:10b6:806:2b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 00:10:24 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%8]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 00:10:24 +0000 From: Jason Gunthorpe To: Alex Williamson , Cornelia Huck , kvm@vger.kernel.org Cc: Christoph Hellwig , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 1/5] vfio/pci: Move all the SPAPR PCI specific logic to vfio_pci_core.ko Date: Tue, 29 Nov 2022 20:10:18 -0400 Message-Id: <1-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> In-Reply-To: <0-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR05CA0020.namprd05.prod.outlook.com (2603:10b6:208:36e::23) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB7411:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d471e06-55e5-448c-e0db-08dad26746de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6WS0aj0LGYqIdZOpYVoKg6UCmMyuj5Bzfvmz2viOeHYC0A+HbPgLSqoR2rLoz+/2ylmwRONNUFAGJi9kBU4EjafvZiUlAm3vnoqQpxA7xu6rhUr28nh4c2B/6S4NKaiL3JqYSBJ8ywiWduSFCEa6Bj7nlf3eVwArGogACrxfI5KxDY9cfTLOJOn9EpeH37DlKf+Wva6O13TaB+Im+jAevhMgmEl+4OQx+hLL3VpLG/DSM2ZsOxh+C+XPb+mHjU1PvvNHgaOE3xE7OvJE+y8IFtbhX4FBW7MgD8oSthxwO8WYJmoGvacWR5pXPeQQgSnQYf8OmLabxFl7JcjA4JwIYhunt/tG1CkkggCkYAC0WiJmzHE4LVDgG04raCsgNBHcNgdZUsJuEzJpqMqhQDdo5+L5jpDO5yCW9nWdJONUWf7lYTo2ttCbyjQdYNivL/Fb5hVKlHvVG4b6F0OMZIYocgXwP93RsN/adi/hiZZXTjRwPm4tp8WtNuk5mEIVsgHjUq5/iEucfo1Ds2/Z+o8wlEzTQOlttpjY1xPUtC+FhSSWEPTeLFN8BEzb7YoKiO6Yq9xSfCs2AYVdP872L7ZmapgaPD+ml1zzyvLyhk3ZNq9gDmcYMqBfDW87bBhC3YLRFmIC60DvIk1BB9CQLgAX58zmAuei+RKmnVbWx4q3hlK8itghQsFczEktttC3NKqx X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(366004)(39860400002)(136003)(451199015)(6506007)(110136005)(2616005)(316002)(54906003)(6512007)(478600001)(26005)(6486002)(36756003)(186003)(38100700002)(86362001)(6666004)(83380400001)(66946007)(4326008)(8676002)(5660300002)(66556008)(8936002)(66476007)(41300700001)(2906002)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cZL2ItBLtQ+glO2tBK4JUTo43p/JBvdXgbTfxGZhkDHlkuhtFAeKqh/rC76mYjDRrEFbbaiHOX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wVlVzacG4ORICFWgzXrXHU07QLnpaLRnnz4QDlcOHSWTNf7g1InuMOWg9yVH/PTQ3CI4RMopm1rCyIj8jUCuyiYTYugt4ceyV/IqMdlot1UFFEY10KsSiKNtcQaSDkGXwnlqBkVEC7HlNKW2cGjDj5eHmLi+t2yVvLrS/Vi40FnsWWrDxMRZKhXYrEsIkxHmSYh4VC8IDtnRgzpl36VotdJ7KVFtmFVSR3qhksx6QUJ4ecNazKlkDJ1l8ujjTHY3hW8RakFX9T+uvK0w8NLEnLa0oPzUVGRxuSdpepqRxHx+wAxnAISSXOFsWGHtvaGPrROHEcIoCgl+Tlrii8auTSAGugki64WPBd80QAiPXsRONpMlm4wivtBKZYQ5oUodebCfj03+Uw+EefOPDKwxvsYte1JSY= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d471e06-55e5-448c-e0db-08dad26746de X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 00:10:24.0072 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kdqnqsMGSEd33w+yAtnSZYaERkd6zMVt8F90r4V7vc5I/1IkpWldp+WeQiPCNkWx X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7411 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The vfio_spapr_pci_eeh_open/release() functions are one line wrappers around an arch function. Just call them directly and move them into vfio_pci_priv.h. This eliminates some weird exported symbols that don't need to exist. Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe --- drivers/vfio/pci/vfio_pci_core.c | 11 +++++++++-- drivers/vfio/pci/vfio_pci_priv.h | 1 - drivers/vfio/vfio_spapr_eeh.c | 13 ------------- include/linux/vfio.h | 11 ----------- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index badc9d828cac20..c8b8a7a03eae7e 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -27,6 +27,9 @@ #include #include #include +#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) +#include +#endif #include "vfio_pci_priv.h" @@ -686,7 +689,9 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev) vdev->sriov_pf_core_dev->vf_token->users--; mutex_unlock(&vdev->sriov_pf_core_dev->vf_token->lock); } - vfio_spapr_pci_eeh_release(vdev->pdev); +#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) + eeh_dev_release(vdev->pdev); +#endif vfio_pci_core_disable(vdev); mutex_lock(&vdev->igate); @@ -705,7 +710,9 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_close_device); void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev) { vfio_pci_probe_mmaps(vdev); - vfio_spapr_pci_eeh_open(vdev->pdev); +#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) + eeh_dev_open(vdev->pdev); +#endif if (vdev->sriov_pf_core_dev) { mutex_lock(&vdev->sriov_pf_core_dev->vf_token->lock); diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_priv.h index 5e4fa69aee16c1..13c0858eb5df28 100644 --- a/drivers/vfio/pci/vfio_pci_priv.h +++ b/drivers/vfio/pci/vfio_pci_priv.h @@ -100,5 +100,4 @@ static inline bool vfio_pci_is_vga(struct pci_dev *pdev) { return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; } - #endif diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c index 67f55ac1d459cc..c9d102aafbcd11 100644 --- a/drivers/vfio/vfio_spapr_eeh.c +++ b/drivers/vfio/vfio_spapr_eeh.c @@ -15,19 +15,6 @@ #define DRIVER_AUTHOR "Gavin Shan, IBM Corporation" #define DRIVER_DESC "VFIO IOMMU SPAPR EEH" -/* We might build address mapping here for "fast" path later */ -void vfio_spapr_pci_eeh_open(struct pci_dev *pdev) -{ - eeh_dev_open(pdev); -} -EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_open); - -void vfio_spapr_pci_eeh_release(struct pci_dev *pdev) -{ - eeh_dev_release(pdev); -} -EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_release); - long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, unsigned int cmd, unsigned long arg) { diff --git a/include/linux/vfio.h b/include/linux/vfio.h index e7cebeb875dd1a..e8a5a9cdb9067f 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -231,21 +231,10 @@ int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr, int num_irqs, int max_irq_type, size_t *data_size); -struct pci_dev; #if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) -void vfio_spapr_pci_eeh_open(struct pci_dev *pdev); -void vfio_spapr_pci_eeh_release(struct pci_dev *pdev); long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, unsigned int cmd, unsigned long arg); #else -static inline void vfio_spapr_pci_eeh_open(struct pci_dev *pdev) -{ -} - -static inline void vfio_spapr_pci_eeh_release(struct pci_dev *pdev) -{ -} - static inline long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, unsigned int cmd, unsigned long arg) From patchwork Wed Nov 30 00:10:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13059362 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E9E4C433FE for ; Wed, 30 Nov 2022 00:10:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230356AbiK3AKh (ORCPT ); Tue, 29 Nov 2022 19:10:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbiK3AK3 (ORCPT ); Tue, 29 Nov 2022 19:10:29 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B2D132064 for ; Tue, 29 Nov 2022 16:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hEiBNyw3h/Pf/HSWbjA5sLDLrUTw/IaEOj8fbehmLIgP1auGxztcMWnCLQQpJ/MkZNLE+eqdmDQePnhzqRIMmB/00j02/DLLWiT1qlUS7N/DLoVkGhD4dtkCr2NafPl0oQ2CGBhib67RGKtfqZJD9zQ2LaVnp9zcslqvLdS+RSoFJGkb/ckkh2XaqrMNapyhLpptAGm/j8+NmCxP4eZ1Ec5KX3r8OIH9tu7E83GFf0EmH2605iXcrLxqX5uSZo7aoRLzCwbBnx3JCQLDPBNk9FtmSg9Ddv1onFING1Bn/owjjkHMBMh64ASdIq1/hZyvGw6/SJPJiL3ulrPrczMISA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UAs9ZZgcvkgCemtD4DNGDFuL5sM2lb8xOFx0kvPzz2w=; b=ZLuXiZ9U2QQwS69jY0IcSrsW8EHc/xqPdXIFONv/TMj1tKeTizr9ZDbar5l8GOrSC/ikc4bcAyHxpgLLZstcl3iWY9H9/9pxvQ1e2VADL7bR1bpEvUZTaxWxzQXiixHX+DH89vSXu3HsLBmgms5UIZCnLLyqx4u8dTs4bkQXPr+aT4jPCFiz71h1Aus6/O0SKMkc5c8VYSB1GTlo6uY52lkyu9zQOpOj/MJtWh1+tFY974jssa5CSFamBTKGXXvtfdo2ZIQURfI+MtGv048CGVQ47lop5qACKfKdI2HYZVz+GZK3wLAEA33JUcWALXYoncyx9fxzlzh49+/FXBpYDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=UAs9ZZgcvkgCemtD4DNGDFuL5sM2lb8xOFx0kvPzz2w=; b=fy0M/nPDBdwc/MwlwxwISRf8x1Kj4v0Imkpxt5OWh0RgCzBbm+SQNSx1v5qHJYEfn8qLz3WeeOWdJ4KfYPvUfrSYxOO3zsUVaBpaQrTi9lfD4niUqdk581oDMtCKUC0r/0zdnmFwmaRwRVN/vkOf/CGTjOYCJxd7NXT+MB7CYeBNGMeNvoWEwzo1/o9ZdzL7jSlNstlqMKCT5ao3XjLwxZz6m+MtHD0w0DhNLvZ4C1vsrJHvBnCUjAsrJdHuLzNVTuNhZDk05gMXppDuZP8DS+BQ9HoaphzeAlLCIjNcrzeU3UxMyCGKvw/qj+v+H+qvEfTcgpCzNIbJmtB7NPFPVg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB7411.namprd12.prod.outlook.com (2603:10b6:806:2b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 00:10:25 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%8]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 00:10:25 +0000 From: Jason Gunthorpe To: Alex Williamson , Cornelia Huck , kvm@vger.kernel.org Cc: Christoph Hellwig , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 2/5] vfio/spapr: Move VFIO_CHECK_EXTENSION into tce_iommu_ioctl() Date: Tue, 29 Nov 2022 20:10:19 -0400 Message-Id: <2-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> In-Reply-To: <0-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0331.namprd13.prod.outlook.com (2603:10b6:208:2c6::6) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB7411:EE_ X-MS-Office365-Filtering-Correlation-Id: 75ecb609-c9c5-4066-c916-08dad2674709 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ns1M4g+GnTEkBLwFGEPFtpTn3+wMltiHUU5ZH1yHgWMfz8/zufTcK/Tc1r8f0Wb8y4wSZxU6j+ep47xhyBCSiDdwRoZVjTLx3fRQQtEnLcDopqYfPscS5Jsw/myoMsYoH6Jnm1mDZFes/l0p/5i/ZULhzmjs9wCtq2UcKRLlSedDwyPKkra8f3Z/L1YFdwsBW0jwB+GIejKdrF55hE0/ylJ6/incuTymAOWJXWkddBF6t2Yr8CQ+cKLHBADzBYPJR0y0Mq8ACvW/hN261PY3/wEtZF2FsU5oJdCSD8HmroEWqIoxMA7B8f8pFWxxe2N0WByUhbgrwiO5lC0uoSm/M96159z8PNjKDu/25VW5GP7c/Dq+AP+LIOzB38CWZq1DwLLp27QtX5dUn8j4NezM3sFbIa9vLjLIvyTyDgkPRuLFOUpQfx+Xidq1DBRCwnLxme5JZVpN29USZATPKhfszGTu00HRgkrSNYS70r6VBsYHUivLf6SScsj5cAGuarnEk5eUnG+ZQVENk0GBd2tbKqAtIsz9KuDbBZou4f/qEpb1g6NxaI9Z0HHA71+pu7LYHAOwR+Sgtv1/JrmsToHLopA8/qCzuoMD26W4qNF1IWEoVHAsVQemGDxmIJnckd16K6FA4TWse0j4iMD99K6AaaUnUV021fvkPA0SjPzLEehNBh7jRGF+IKy4XPEKHZow X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(366004)(39860400002)(136003)(451199015)(6506007)(110136005)(2616005)(316002)(54906003)(6512007)(478600001)(26005)(6486002)(36756003)(186003)(38100700002)(86362001)(6666004)(83380400001)(66946007)(4326008)(8676002)(5660300002)(66556008)(8936002)(66476007)(41300700001)(2906002)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mHiq5NFfWIlBy6YXkx5NNehjPKAr?= =?utf-8?q?yTZsViPE/wlc1dUFJUmR+yF175XnSM83KMJ5TunswTNWFWCemsfIZSthIpmAnLqyP?= =?utf-8?q?MYaW6BHkrMAHqkByUgsDJYIazwZ0Uw5+uP8ShGcaFTmry0QEYkTXjN0lNI9wvgtHR?= =?utf-8?q?Ix1yp18PGi5kfvi6hdohlfrK3M9U3W8mO9NcjJMJ3ikxVGIiB9HjSgwUxBKyaXI7d?= =?utf-8?q?RDuHW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lLPSGEYrr/hu29bArAsSbZrHN4u0207Mn303Vka+2oXFxL0E0vbX1/?= =?utf-8?q?1dz6tmO/2Qc/ItyiCNQuUg6f3bZjUe/2EJc7X83QxPUASakga2tWWESQ1g55330ue?= =?utf-8?q?tPK1yAwue6JMjgT09QCdnCHnmmSgt31QcYwkCcuppR/fq0Nfoq8rqWsjgwwG8obl0?= =?utf-8?q?wd+a0s/XWsZyyL2WtDPec1CIue3WEg2ubDsNO9QWp4oDBpwtvf/yZsiKhS43hDNZu?= =?utf-8?q?ATGmBAUqN+cYwAYc7GrwzhxZH6kzPm9LuwvN9tpRU7LxjFGR7z6IBH8hDKu5viob2?= =?utf-8?q?JdPDd4yt/JgSQbo0EuW047KEoZ077n7Fk24JwUsfjmRlhGw4vb2XBfunwv36iLPSP?= =?utf-8?q?dx/Dt7vEQMZeKhXhzCXZ08zk32ic7ycMLXL0RdL74AbRvfOSXYtkg6Gs=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75ecb609-c9c5-4066-c916-08dad2674709 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 00:10:24.2571 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CG5Mu92swornCGC1oVgTAl04tBVPZ9rnismkOypuiiyaDXJHZv235et6Qvq1lwt+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7411 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The PPC64 kconfig is a bit of a rats nest, but it turns out that if CONFIG_SPAPR_TCE_IOMMU is on then EEH must be too: config SPAPR_TCE_IOMMU bool "sPAPR TCE IOMMU Support" depends on PPC_POWERNV || PPC_PSERIES select IOMMU_API help Enables bits of IOMMU API required by VFIO. The iommu_ops is not implemented as it is not necessary for VFIO. config PPC_POWERNV select FORCE_PCI config PPC_PSERIES select FORCE_PCI config EEH bool depends on (PPC_POWERNV || PPC_PSERIES) && PCI default y So, just open code the call to eeh_enabled() into tce_iommu_ioctl(). Reviewed-by: Christoph Hellwig Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Jason Gunthorpe Reviewed-by: Cornelia Huck --- drivers/vfio/vfio_iommu_spapr_tce.c | 10 ++++------ drivers/vfio/vfio_spapr_eeh.c | 6 ------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index 169f07ac162d9c..73cec2beae70b1 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -785,14 +785,12 @@ static long tce_iommu_ioctl(void *iommu_data, switch (arg) { case VFIO_SPAPR_TCE_IOMMU: case VFIO_SPAPR_TCE_v2_IOMMU: - ret = 1; - break; + return 1; + case VFIO_EEH: + return eeh_enabled(); default: - ret = vfio_spapr_iommu_eeh_ioctl(NULL, cmd, arg); - break; + return 0; } - - return (ret < 0) ? 0 : ret; } /* diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c index c9d102aafbcd11..221b1b637e18b0 100644 --- a/drivers/vfio/vfio_spapr_eeh.c +++ b/drivers/vfio/vfio_spapr_eeh.c @@ -24,12 +24,6 @@ long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, long ret = -EINVAL; switch (cmd) { - case VFIO_CHECK_EXTENSION: - if (arg == VFIO_EEH) - ret = eeh_enabled() ? 1 : 0; - else - ret = 0; - break; case VFIO_EEH_PE_OP: pe = eeh_iommu_group_to_pe(group); if (!pe) From patchwork Wed Nov 30 00:10:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13059365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9CC5C46467 for ; Wed, 30 Nov 2022 00:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbiK3AKo (ORCPT ); Tue, 29 Nov 2022 19:10:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230194AbiK3AKd (ORCPT ); Tue, 29 Nov 2022 19:10:33 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEAAD3FBAE for ; Tue, 29 Nov 2022 16:10:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BHGJ8ljLY8nOgUAtC2aEuFpr/75MqU8PyEJoKwXE1JzA6Y0CvaqO3KtsaBsL3aw1wOS/nGTjaUnPv6WxL6q07tttX7gOek/8Y5ZIfMrijw9WfkyWZpEk6Ui1g22ALu4HldsbB+kKOOPR81OEm4Zr58mCYYByx0DjCjeOGASdMIKCwr5/nF5xrNKDkw2Gp4fyYfvnSzFdiuw4knrEL1noWx20+pGWSU1Ln1BKT0mK5Oy6TVM2Y4qxHovJdD7amoUWqL97Mdcm5HRyQTSNGCLmygCf5ji/+uiILG8HMPz0ZGF7lcKeFYeTXFnC88lsnVckw6+wivT6vE/7q/7Quv8MRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+pMOJ3jKpj1zGjN0hjZrEYlt3jYFeuj51czu0vc7GLo=; b=N895NnvC3tGxnjTeHI+fTQOm41MxeJSIwMhI0yWaZ48N435uOsMgDOvpKdxuYCV6oY72k3Lesof5nhTIkzE7iPl6YA7JuAHHaFTKGJ0IcXEu1XkWRJ7DUyrtACtBPzi9ALDk5hZ624rFCqdU5OONWhTpUPk4ItZcWfPpAAR1WzBb4vn8wGJ0jb7hkpmgSy0M7Au0uVeDTpRQihC5w5MYkknJQQddbuzL2UHizZKYFPP96/yZqECQi0A8v4oSTAVl0ukLQV7ar8yrl90TUelNBGwMGybXqPRcHf7TIWQEpBXtJOn7fSMjrWz4Cu6cUvf4mRr/FO0vjpK0w+6YaeuETQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=+pMOJ3jKpj1zGjN0hjZrEYlt3jYFeuj51czu0vc7GLo=; b=bLtaFJihrVvLzhEaBsLoIsd/zz8/S1eVQcEhJp03GOzAL9WTIUssbS+IABqWcsNuzMBoWs2pB+Y0+5mmeJBC+SeiZ8rHSn5g5SfCTqfUVDW0h/JJWZvVK4ZCRfzynbQLTPOBTJGkZVkajVN5qMcHBSd7Urb+mjAtiMn4O0F/Pkodi3BC+4mQ9AGQN7C6F0+1rmX6byXhb0Se2J4U16lBVd+Jgp79tFZYo6l6wS5GeqbyOjFq5Mz75qXiHJWzkwCtOA+Fx1HYq3clTZ9JJOkUQNV7R5JSsK+lRAKAqxVjdZxR+L60yVn/gMUpphcbj206ZDok+De5uRLKBG1nHCMU3Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB7411.namprd12.prod.outlook.com (2603:10b6:806:2b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 00:10:25 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%8]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 00:10:25 +0000 From: Jason Gunthorpe To: Alex Williamson , Cornelia Huck , kvm@vger.kernel.org Cc: Christoph Hellwig , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 3/5] vfio: Move vfio_spapr_iommu_eeh_ioctl into vfio_iommu_spapr_tce.c Date: Tue, 29 Nov 2022 20:10:20 -0400 Message-Id: <3-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> In-Reply-To: <0-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0410.namprd13.prod.outlook.com (2603:10b6:208:2c2::25) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB7411:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f566430-23f9-4e4e-f2b7-08dad26746f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ziLEkguZXgwGQ8+ITnnaGrZpT4BrdVWcVt+2DAVpyr/3WYKbuLfw92rEpYQdSaBJsLmQm96be44N+bttz77zMARapFU+DoaTw/rPlj9gyT8Egzjlr/n4o3n4JtMENIJZ1DU7gUhXa0XdNF/MHVSgwwbAuUFMSLI82Wr3KErT5R+2n8PnLsW/qthYJzAbxV5GDZ369yo1BwBzVyPdm5fX2G97Q80ign3Wn7pNPq/LkPiQ39DF3Hu/SfrJzvrVwX37go0hcHbwdCYVKfLYwNU5bAGOLCc5Qzpayta6cF1JfS5zT8GdIoyxBYfs3l91wovJl3Ik1r0hJvEMDa+SyeBCxXaBSmFw21ey7enA3iQUZ/9CCVQIRwUbjqDTgAsvp0Lv0I6nFj+OloetLi/i06P8ircGLJPBjfr2w7dvYY03ZEYpNd81HwLSjd8pJtDaBRXlbzha6DkpfG3dGF1EuZYeOwL8lInese8asWXeS4/HKPGiWjWDuubjjkulod3xoaFdCHpUamjKHCLMDW2AZd06JOxlqNfLbN9MkOIzmRfkGJ/B/jv7giMeUdeIXMYQI85m1jXRI9/YKi9MNOdQOx6LNkewcg1YonIYgndCAOZ9xnw2nhfDSX51aHtTMPKQpXxL3LQQN7sN8fuHSNo8oZj+ShkfA2kZIhffq1GJBKvrVFXWEUuB3fuCA3s+O8/i/LZd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(366004)(39860400002)(136003)(451199015)(6506007)(110136005)(2616005)(316002)(54906003)(6512007)(478600001)(26005)(6486002)(36756003)(186003)(38100700002)(86362001)(6666004)(83380400001)(66946007)(4326008)(8676002)(5660300002)(66556008)(8936002)(66476007)(41300700001)(2906002)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WT/hTnLIJJPvsNxyoFumu1Fqa7xv/nZtk3hvqeaFHWIuihUdU0JLtZVRrR2RMLnmLBa1jCJtRnHFKS3NFt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q3KKyjlYzFQseHoML2srvI9vR4TE/ZrJldWQ7KPA+1TW0M2CoMF5DPWrFkCmSuU31SDdlRwLTYcDj47F09ySxC6AZNWK1bhVGeX7HbYwUkAdkOF061j0o1uRQPq8nriYplFSM7W2JR8Aq805C7yo80ZY3FHi86tyv0lmaNBYC1DExK0ySS55TvBHbuvmgo3tSgR5339wb2LWv8sjzElypK/24jJvaiGjjOz7EAlKxE5xnGvF6vofclAG+PR3gFrADlkO6ZJDXmfa3s4OUhPA6zfemvIpOFEsIBo62H7KiRNJqTjP4FyUmRVq//cTmCv2p8jmyzuvwNwx7cS8CEZ8nwSyiRsa/s52A3qv/dVpmtmSo66kO1qo8m7l9l8EsMn3bpjwcTlLJBmhxEfi7xw/01syhp1bskdLULaRyrCr8v3e0M= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f566430-23f9-4e4e-f2b7-08dad26746f1 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 00:10:24.1322 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qp1lP3kFgWdXVNT8LFe3N2lfvtUCFUqNF3WG51SYQjQgs71ACRuzTRW2TeWT111j X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7411 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org As with the previous patch EEH is always enabled if SPAPR_TCE_IOMMU, so move this last bit of code into the main module. Now that this function only processes VFIO_EEH_PE_OP remove a level of indenting as well, it is only called by a case statement that already checked VFIO_EEH_PE_OP. This eliminates an unnecessary module and SPAPR code in a global header. Reviewed-by: Christoph Hellwig Signed-off-by: Jason Gunthorpe Reviewed-by: Cornelia Huck --- drivers/vfio/Makefile | 1 - drivers/vfio/vfio_iommu_spapr_tce.c | 55 +++++++++++++++++- drivers/vfio/vfio_spapr_eeh.c | 88 ----------------------------- include/linux/vfio.h | 12 ---- 4 files changed, 53 insertions(+), 103 deletions(-) delete mode 100644 drivers/vfio/vfio_spapr_eeh.c diff --git a/drivers/vfio/Makefile b/drivers/vfio/Makefile index b693a1169286f8..50b8e8e3fb10dd 100644 --- a/drivers/vfio/Makefile +++ b/drivers/vfio/Makefile @@ -10,7 +10,6 @@ vfio-y += vfio_main.o \ obj-$(CONFIG_VFIO_VIRQFD) += vfio_virqfd.o obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o -obj-$(CONFIG_VFIO_SPAPR_EEH) += vfio_spapr_eeh.o obj-$(CONFIG_VFIO_PCI) += pci/ obj-$(CONFIG_VFIO_PLATFORM) += platform/ obj-$(CONFIG_VFIO_MDEV) += mdev/ diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index 73cec2beae70b1..60a50ce8701e5c 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -4,6 +4,7 @@ * * Copyright (C) 2013 IBM Corp. All rights reserved. * Author: Alexey Kardashevskiy + * Copyright Gavin Shan, IBM Corporation 2014. * * Derived from original vfio_iommu_type1.c: * Copyright (C) 2012 Red Hat, Inc. All rights reserved. @@ -773,6 +774,57 @@ static long tce_iommu_create_default_window(struct tce_container *container) return ret; } +static long vfio_spapr_ioctl_eeh_pe_op(struct iommu_group *group, + unsigned long arg) +{ + struct eeh_pe *pe; + struct vfio_eeh_pe_op op; + unsigned long minsz; + + pe = eeh_iommu_group_to_pe(group); + if (!pe) + return -ENODEV; + + minsz = offsetofend(struct vfio_eeh_pe_op, op); + if (copy_from_user(&op, (void __user *)arg, minsz)) + return -EFAULT; + if (op.argsz < minsz || op.flags) + return -EINVAL; + + switch (op.op) { + case VFIO_EEH_PE_DISABLE: + return eeh_pe_set_option(pe, EEH_OPT_DISABLE); + case VFIO_EEH_PE_ENABLE: + return eeh_pe_set_option(pe, EEH_OPT_ENABLE); + case VFIO_EEH_PE_UNFREEZE_IO: + return eeh_pe_set_option(pe, EEH_OPT_THAW_MMIO); + case VFIO_EEH_PE_UNFREEZE_DMA: + return eeh_pe_set_option(pe, EEH_OPT_THAW_DMA); + case VFIO_EEH_PE_GET_STATE: + return eeh_pe_get_state(pe); + break; + case VFIO_EEH_PE_RESET_DEACTIVATE: + return eeh_pe_reset(pe, EEH_RESET_DEACTIVATE, true); + case VFIO_EEH_PE_RESET_HOT: + return eeh_pe_reset(pe, EEH_RESET_HOT, true); + case VFIO_EEH_PE_RESET_FUNDAMENTAL: + return eeh_pe_reset(pe, EEH_RESET_FUNDAMENTAL, true); + case VFIO_EEH_PE_CONFIGURE: + return eeh_pe_configure(pe); + case VFIO_EEH_PE_INJECT_ERR: + minsz = offsetofend(struct vfio_eeh_pe_op, err.mask); + if (op.argsz < minsz) + return -EINVAL; + if (copy_from_user(&op, (void __user *)arg, minsz)) + return -EFAULT; + + return eeh_pe_inject_err(pe, op.err.type, op.err.func, + op.err.addr, op.err.mask); + default: + return -EINVAL; + } +} + static long tce_iommu_ioctl(void *iommu_data, unsigned int cmd, unsigned long arg) { @@ -1044,8 +1096,7 @@ static long tce_iommu_ioctl(void *iommu_data, ret = 0; list_for_each_entry(tcegrp, &container->group_list, next) { - ret = vfio_spapr_iommu_eeh_ioctl(tcegrp->grp, - cmd, arg); + ret = vfio_spapr_ioctl_eeh_pe_op(tcegrp->grp, arg); if (ret) return ret; } diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c deleted file mode 100644 index 221b1b637e18b0..00000000000000 --- a/drivers/vfio/vfio_spapr_eeh.c +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * EEH functionality support for VFIO devices. The feature is only - * available on sPAPR compatible platforms. - * - * Copyright Gavin Shan, IBM Corporation 2014. - */ - -#include -#include -#include -#include - -#define DRIVER_VERSION "0.1" -#define DRIVER_AUTHOR "Gavin Shan, IBM Corporation" -#define DRIVER_DESC "VFIO IOMMU SPAPR EEH" - -long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, - unsigned int cmd, unsigned long arg) -{ - struct eeh_pe *pe; - struct vfio_eeh_pe_op op; - unsigned long minsz; - long ret = -EINVAL; - - switch (cmd) { - case VFIO_EEH_PE_OP: - pe = eeh_iommu_group_to_pe(group); - if (!pe) - return -ENODEV; - - minsz = offsetofend(struct vfio_eeh_pe_op, op); - if (copy_from_user(&op, (void __user *)arg, minsz)) - return -EFAULT; - if (op.argsz < minsz || op.flags) - return -EINVAL; - - switch (op.op) { - case VFIO_EEH_PE_DISABLE: - ret = eeh_pe_set_option(pe, EEH_OPT_DISABLE); - break; - case VFIO_EEH_PE_ENABLE: - ret = eeh_pe_set_option(pe, EEH_OPT_ENABLE); - break; - case VFIO_EEH_PE_UNFREEZE_IO: - ret = eeh_pe_set_option(pe, EEH_OPT_THAW_MMIO); - break; - case VFIO_EEH_PE_UNFREEZE_DMA: - ret = eeh_pe_set_option(pe, EEH_OPT_THAW_DMA); - break; - case VFIO_EEH_PE_GET_STATE: - ret = eeh_pe_get_state(pe); - break; - case VFIO_EEH_PE_RESET_DEACTIVATE: - ret = eeh_pe_reset(pe, EEH_RESET_DEACTIVATE, true); - break; - case VFIO_EEH_PE_RESET_HOT: - ret = eeh_pe_reset(pe, EEH_RESET_HOT, true); - break; - case VFIO_EEH_PE_RESET_FUNDAMENTAL: - ret = eeh_pe_reset(pe, EEH_RESET_FUNDAMENTAL, true); - break; - case VFIO_EEH_PE_CONFIGURE: - ret = eeh_pe_configure(pe); - break; - case VFIO_EEH_PE_INJECT_ERR: - minsz = offsetofend(struct vfio_eeh_pe_op, err.mask); - if (op.argsz < minsz) - return -EINVAL; - if (copy_from_user(&op, (void __user *)arg, minsz)) - return -EFAULT; - - ret = eeh_pe_inject_err(pe, op.err.type, op.err.func, - op.err.addr, op.err.mask); - break; - default: - ret = -EINVAL; - } - } - - return ret; -} -EXPORT_SYMBOL_GPL(vfio_spapr_iommu_eeh_ioctl); - -MODULE_VERSION(DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/include/linux/vfio.h b/include/linux/vfio.h index e8a5a9cdb9067f..bd9faaab85de18 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -231,18 +231,6 @@ int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr, int num_irqs, int max_irq_type, size_t *data_size); -#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) -long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, unsigned int cmd, - unsigned long arg); -#else -static inline long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, - unsigned int cmd, - unsigned long arg) -{ - return -ENOTTY; -} -#endif /* CONFIG_VFIO_SPAPR_EEH */ - /* * IRQfd - generic */ From patchwork Wed Nov 30 00:10:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13059363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5676CC4167B for ; Wed, 30 Nov 2022 00:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbiK3AKj (ORCPT ); Tue, 29 Nov 2022 19:10:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbiK3AK3 (ORCPT ); Tue, 29 Nov 2022 19:10:29 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2046.outbound.protection.outlook.com [40.107.100.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3943610EC for ; Tue, 29 Nov 2022 16:10:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vw7Bqj8YodSgs+rRtObXYchabvQdQIHcPHYAUSAiH7BkXPZ650bKBoXwr1x+1IFJOI0QVkgbn/cUDeubJtkMvNuLsbeudXssUc35lGEWiBrg+pSpna2RIXv8yINJM+/Xyte3BBAhD9JFSaaCpIhxNkO+nvd8/zFO/8/R2i3l5bLeqG1TRTA9fOUK3OOlVw53sYpibKZtlPpomAJ7IHU8FtFAHNE1v884mh0MFAhejLMr68mtnbzhkYsf1rxEkomjZzeK8PQiAzbr1EYJRMdGuRbgjnLSgwLvkSzLx2/xuv3HO2/bOmjotarFmCu0F8L0N1gEadG+N6Dp05XKdv9XAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RAuKs7WuMxQ5r9KAnAiSSSSqB4FCpvhHtYqUIiDdXE4=; b=ekLAEwLgUQszoHm6KXLIQnMFU/iHduMv+PK2Iqkbolq2Oqhdkb7+ts3DFyKlwLdrs0I7bqvQxZUMhW+WwPKclVbCY90S2ETvwl2lEFCtp313rzyhV2ynL7kZMHz5yFuVyjjOM8Mrasv1luRG739m1kLJ8y7knCD40YBOLe/xwOrGVW6rPIo5ql0RWdyt+nhspadV/DvOA5dyiFo7q6ALImC0W8503F54nCeob7f9+8PZZt+UJ5dbc+ZYeBClrdWE6XNosxponcg3aNESW5LkQwv0Smxmjh3uHT8g7M5AR7NkZ0occqW4VE0tvyTGY70KXI80R0K3E8nCrH4kKdheVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=RAuKs7WuMxQ5r9KAnAiSSSSqB4FCpvhHtYqUIiDdXE4=; b=CcG2XK61szimSai77j9XBmOgSv5CrGAu+dTIjk/ITvoUNFJcLnAXFbt9wzCC+cwMy+KH+8vDkVy+jDJTgkYwtwye5uLXt3Cuwr68oS1WSilqhubL9vlMQlALFUg43/a7yeMzQ8xMbZLyko1IwdDe3TCYcJ3foP7Z0Sj2Zm2Wa6AnUuKpz1sf2u0+k1L93B8pmQiIbvVygqjjuF2D7K9L4RYtcMspgFJQUXNrFYYUPWDcZlJkgbQjKMc1GeMsH34dEzPmtZVOrkeZeM16U1Owtla+qYBCxY8JEhigsIR1XyGv4BgbCecsUp4AucxYeQtwGhiWzZzOuGLtJ6I5olfZZA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB7411.namprd12.prod.outlook.com (2603:10b6:806:2b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 00:10:26 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%8]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 00:10:26 +0000 From: Jason Gunthorpe To: Alex Williamson , Cornelia Huck , kvm@vger.kernel.org Cc: Christoph Hellwig , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 4/5] vfio: Remove CONFIG_VFIO_SPAPR_EEH Date: Tue, 29 Nov 2022 20:10:21 -0400 Message-Id: <4-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> In-Reply-To: <0-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR01CA0049.prod.exchangelabs.com (2603:10b6:208:23f::18) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB7411:EE_ X-MS-Office365-Filtering-Correlation-Id: e472ac7b-fec2-494c-8d7b-08dad267470e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J1l9hjsVWAZGbCEozeSx9Jp1qcTmSKOJxC+PoxS7yn1lmaaJt5Mgmq/vNk0CKAXFiATfqfG8TnAwsL/oMlgxHHa+gK55/uqN2PBUeXvxGvA2/opeq6lfeNL7hCCYh8fmqOv7MJ6BsCwl6jzFJKE82y19BDDrbA861ImX5CanhQbXypxrDZrxvPSBiun/vXSVRrqR+S+3YkD6kFr5opmkD9umE+BDULiyOTV35V4V9/acF633W3x7tQSw/wWilLVE00+VxHb4H8y5LYjdzFwthJkX7GTddhiwsxOiOaZym0I79FINNNyOTyVDAy1GPySfZJfhxbkUi8qmHG5bvvGHroC1cC/59ZyVGxW4IHnGwqjvBnAXsf1DWSEXlLtRE8LKz3pqZ7xJHYCUC+Nr3FAXAUOJ1WPjuW/VERjymiBQH8d3Do5nlxOlgOXAFeC7Qy96zUnMocc/Chb7Jj0pybQgsIs89cFQpe5HmrNgLvoBwj3fQQGveqT6vcVaeJMGGUATqfI91MW9oP+ifQBbp9CaRrZCXbPh8u63PiGa2mTDIPQJTIzVgP3kpVD7Mr3TAw0M+6uoXf+SQaExaYez2WPKaiP6ZLixB0DGHuRrnWK+we0alGEpKBKgbJTMI/3A9gjOdGF+YNwMelX3H345auoYqI/2bfGIW3H/AUmpwfEZQq4uZXFHa67s2HbUDY+kDWKl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(366004)(39860400002)(136003)(451199015)(6506007)(110136005)(2616005)(316002)(54906003)(6512007)(478600001)(26005)(6486002)(36756003)(186003)(38100700002)(86362001)(6666004)(83380400001)(66946007)(4326008)(8676002)(5660300002)(66556008)(8936002)(66476007)(41300700001)(2906002)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OCeTA39xrPzhk5FDL8jFFMDq/wfb7HABH/eR2IFy25cOnDl9106bOqMkm1UXY882A4Zy08yuXAsyNjJT66cFioT5Bqk0JaYnpmrAFGGnfPriGeFumODoYBr1aPzHbuan//JUg1I/iIEItPulmgZyjl5J+ahOWWWMv197vHCXAVsnjQkxp+rPGoeFShVcyQZci6nORpsMj4/NDK0LpYq+Acpn6P7Y7t+XfVF5+iSjCV1HxfZ1tsVk3BgLhpSd2O6GNu+280ewLNrQZaz8qxUPt3KascDobP2eCNcigDKqkzugAkJhag1zj0FwrmNIDg1agKWrOh3H02OCHWnS/yxv8V0IvZ7sfiK2qJc2hnUDCFwdW2oG7feGxFl/Hi9IyCtCGs5Q4pmHmT9M/jR1cUzuQiq2ql1ngS2mTb+V7rq4yTyBo2RHhOLgkvfN5uK7gVVFf5TUTcTqExgWc4ncaJkIrGkoKv4kk/JAXHQn7fNlrpUmId7DME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nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e472ac7b-fec2-494c-8d7b-08dad267470e X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 00:10:24.3040 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9dGeRRZlNi2xFh0RcAE/mixlgxcpmvKQCBpPh090FHmKwEVBdVuU+czhL7Ng/ELR X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7411 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We don't need a kconfig symbol for this, just directly test CONFIG_EEH in the few places that needs it. Signed-off-by: Jason Gunthorpe Reviewed-by: Christoph Hellwig Reviewed-by: Cornelia Huck --- drivers/vfio/Kconfig | 5 ----- drivers/vfio/pci/vfio_pci_core.c | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index 86c381ceb9a1e9..d25b91adfd64cd 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -20,11 +20,6 @@ config VFIO_IOMMU_SPAPR_TCE depends on SPAPR_TCE_IOMMU default VFIO -config VFIO_SPAPR_EEH - tristate - depends on EEH && VFIO_IOMMU_SPAPR_TCE - default VFIO - config VFIO_VIRQFD tristate select EVENTFD diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index c8b8a7a03eae7e..b0c83e1fce6eb6 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -27,7 +27,7 @@ #include #include #include -#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) +#if IS_ENABLED(CONFIG_EEH) #include #endif @@ -689,7 +689,7 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev) vdev->sriov_pf_core_dev->vf_token->users--; mutex_unlock(&vdev->sriov_pf_core_dev->vf_token->lock); } -#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) +#if IS_ENABLED(CONFIG_EEH) eeh_dev_release(vdev->pdev); #endif vfio_pci_core_disable(vdev); @@ -710,7 +710,7 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_close_device); void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev) { vfio_pci_probe_mmaps(vdev); -#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH) +#if IS_ENABLED(CONFIG_EEH) eeh_dev_open(vdev->pdev); #endif From patchwork Wed Nov 30 00:10:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13059360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4B6CC433FE for ; Wed, 30 Nov 2022 00:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbiK3AKf (ORCPT ); Tue, 29 Nov 2022 19:10:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbiK3AK1 (ORCPT ); Tue, 29 Nov 2022 19:10:27 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2079.outbound.protection.outlook.com [40.107.95.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 641DE3FBAE for ; Tue, 29 Nov 2022 16:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EPbU8geSKJnc5akHKEFd14Qxa6ppplnuKfKOovu+KKh9oIQAFlS//h7SwSwVggFVteh8SIsRM6GOe8MvrQE7eKIN5a02ikAZr89Mfvjxqvsn67yfZU0yKB76Ig0QF5KVFjBpMwS6obmKmSW3xjap/rtxr+uvY+T1WLNSWP+P40KGaKAkY0hg4A1Jkr1+lTMAqCBOXcnWb3t5i5nFuvVpDB4HkZeykZiHsdMVRyiPBGRSTpd5wAXz22VOcUhnbnCbczj3/BNITkDeanb0TJXbqpY/WctSPyvkrkbiWqqWJKnwYyvd70lqpxfiozC3Ga3iOE62au8Kgdha+X7RRz1NqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QkEbUK++3Pz31BCbkoOE33dzIv+e41BvXcURJA5t+pY=; b=Qx6pSNyRASGmgtVvKY3LMvjWLlj2ua15n9y8B6QK67D66Xt8bF9wWiIdasOZ1kfizFv49a+d3gHy5dALC9v5VzJcnQEu3n2XuZgggji3ybS48mjGFFci56qygOO7cRNHfHyf3eXeFKu1FUoYA/efy1wvMr8EG0Bs3VdpxQS1gDHCYsnC2YDfWcgGbln9Pue0/edAyTBDLeo0oQ3jLwBw1jey6A3g5RlQzRET1BzmS4P/UFTd/h8Z50XcxPJryNXf42eFV9uVEDM5r0bVfetn6X7CbnG+33C/QX9sKN8S1FXzDnysSxvgKfuRKQw8yyWCMYs3MFaRFaG81IFa0N3sLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=QkEbUK++3Pz31BCbkoOE33dzIv+e41BvXcURJA5t+pY=; b=tVNua4KkBBiwbkGN11auvziuFhd8Dg+L1bdWwTDNnzscbasoP3c26nzdnkMKTPNyrgt371gaG0UHhTv/mUjoKTTRYCd9C1n1evZ1YHhmYBB/ySWaE9OA1vHrhYJb3zq2qvZipiFQNuFcL5PRQYxyKqlEI2CQ0hSfhg7nFDABLi9uArYQLBDIHQLkI020TerpkZS0X58QfiNyFkA+RwMF0kQ7lwpW9lrWOEYttgmOpzmRulZI7+qfS/ma/0YCnwwwU8BZOwdc8CZVi2SB7b511Z3ZH7cId4PeDOlWqsBJQOBXOzEOR48VpK0A+zXIJMWUszoWADiM/+J5zus5oSDBMQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SA1PR12MB7411.namprd12.prod.outlook.com (2603:10b6:806:2b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 00:10:24 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f8b0:df13:5f8d:12a%8]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 00:10:24 +0000 From: Jason Gunthorpe To: Alex Williamson , Cornelia Huck , kvm@vger.kernel.org Cc: Christoph Hellwig , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 5/5] vfio: Fold vfio_virqfd.ko into vfio.ko Date: Tue, 29 Nov 2022 20:10:22 -0400 Message-Id: <5-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> In-Reply-To: <0-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com> References: X-ClientProxiedBy: BL1PR13CA0360.namprd13.prod.outlook.com (2603:10b6:208:2c6::35) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SA1PR12MB7411:EE_ X-MS-Office365-Filtering-Correlation-Id: 72f6cf11-94d0-417d-69cd-08dad26746e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LLDfHh8e4WHJLr0oQOPvOW6pqj4SyE89nID+69VzpkUiGKLzKYI5lrNVvu3O1ewuaIJACF6n3CgJqzWI+rmVCUq3h1P+/CVPAQjb6Ji34XuYmacfquf0c29j4z7cj2Gtbr3uJ0aCwPoIgksQArH4tm1q2uiHomIv6Ju3850rGRPRc1fjXJJj+ceB9yi/YUO+tm6MOtyFFTsob4ensnaNfnwBdQrPPq22zGUJgM35jNSHHT+afPpJtZPacu+hBD4DxnSxLl+F6sk0F4ktKtKc50E7cQwcr+kQodRt3idpyKLOF6aIG81aoe3D93QX6XUGpCI2XcLGYE6jUVntRQlDhmWZuQGfxdCcRccAo+lDL9YIx0gqsMkevDgwhmQZ1D4LHLScw/mlmluJPyZ30GAwTXUbC3tFVjElsTneNo0FZqtcXCt2xmqZkTAYmPAK8Y6F6MVq+bh31gQ3KWz64X1RqT7L+LI550wHlizPZ5Y5g+l4lRAC3d1CHv/bCr8Js1ZGAP4E74uC0wPFgUfxcDeE2M5yzaGZhH3i0ACftMaJc6Qzqjmzd2Qv+rLpKYx3+0/jbSlx/Vsv260I4ufj42t/I62NckqO2wAT6q70NByRuiOXrh8SwY/H5Rztecg/yyNaumJQZgcMKpJ3kaLlUs/QFZS7enpiBgNgLwXzKyatR6w= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(366004)(39860400002)(136003)(451199015)(6506007)(110136005)(2616005)(316002)(54906003)(6512007)(478600001)(26005)(6486002)(36756003)(186003)(38100700002)(86362001)(83380400001)(66946007)(4326008)(8676002)(5660300002)(66556008)(8936002)(66476007)(41300700001)(2906002)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SpVLVn0ShWo8NdVQLClCjjMAb5KCQVo7rZcmyrRMgJiOqNjANhnO+puhvKNOmN2rxGDOrkSC/f438MUcj27+2rA96aK0MgeX7WFGAWDzgzrKm1jJeOCds2TpxCJTw4LMQqHIvAJrdzWH2ddDlJy1LA4YVmqzZKvPQ1ZbAEcHAUgkJCipim4ICWfYEvfNseOJhNgaQ3X4kkK0/mgnHUZNoPkK0c09Fa0LhHHT/E8Elc2VuzMKxqAozrKb/aC4aIcTGUEAB7yfoyetMoH30XHfJgmpX1pW9QCnUuRX9Cy/K5RDqm3RyUvlYz8YAUatJJz+k8JJCrXqeLOAFxjme8VX2ysgsGoybFfYK69rrcsRyobXXO5KvZzqsWde/Ha+C8Oi1wJpfh7YbXgC/EsMomCONiwVb7X+DBMdbg+KmmiLV3uhknYIjbXVhw2eX376kZixBpw5aHs58gPXnRw4+V5zUcZPcQ50cWMtwiftGZ03hcF/4zSC8OHFpHxz/gE8NFzz9XwVQmUC4srmA0pfjCc55DYGAWmQvDvbTbgWkvR3YC1+LX/te0vg+2YL0+avtXOq8onhN2KdCsO63VTyVDxxkouBGT0i5kb6zX+p9bv4mEb1ZoIadE0hVpCLuSNxTt5XK8e1LASdEPew/0Ab2ESpUGDGpYZVde9CFP1O2AAuUFp3VlKWwr9RglJcE3VktdvTvEEATakIhcz1TxApQ63LNZm83vbb4m93dh664Yo9kYRCK40XspHsFiaXEo1zYqoKmZ85pAzFpdjvHm6/ExM+6gWeSgq1KfewVvob0pcEj1XNvsYrUCAewGiWNlC7tmf3ZKhLaAOZNs3h3GJA/S1v1DiW9MQEz6hPIalue9WGXljgdXMcJgsHxHsG9GbG3syAT5At3bm6UhfGoA+QS1wDLdv/qEmQIkwfINP7RXJd9Sl7wTMOdQybSowcq+AiGDn5b3F2X/kFdMSD0W6hfaX50OtjI4b80SFKaXhyXawH2W6RTCd3eCkc4lrEfO/0o4B7bQuFhHIbskz7OSwoKZ1y287clH4LcMzM9U83VPOlMVTBLga2Ujs2VFTX3jRvPkSkQxs2KA37xKa/mI/cuPCklY+n/hWDdykTZlTC9Ivi/3/mOdb5pUgYtBZrx6C+ctJSZHI2P5uktTb5QYuSfhD/emtmMZoiYHti1erThZJHTXkNJu9JMLTpTAVydbUb5x+K3aFzPGA6qYqUka2tTOEzWoFAdtpYWA2PrjsZu9VIfxshep3LWLY2vU7tLwd04FixIc1ZbUVugT+Iy86C0LTAoW1irQGV4sM87CT2fL7pbAXQDwMNbo9LWS5pXT+Fa25sEYT48Tve5MNQP6qoK1BwPyP3PWCKO/5DU1bkzme8B+J5sbNB+xCWKj44bfP0IAmjyMisCBaxc8DowVkBmU7qJon980oGD5vOdTzotznvlzWx/1FV4sSslh/t9CcgPdy9+ikWJ+UFzkY1juo8svAfIYEUyG2NOGjb6n5I+PzZv2ZDV/+H9r4lfs7NMWqdrHQ9yt9HUc5RfiHxLTGYXdzm5GhtWhYdH3S3rzgZVVAJPzA= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72f6cf11-94d0-417d-69cd-08dad26746e8 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2022 00:10:24.0541 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Xw0Hr3akYITBX7s/sub4Jp8gONCUCb9QthcWYLP5blCyVnBgN5fTRO7u/u6fJB3j X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7411 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This is only 1.8k, putting it in its own module is not really necessary. The kconfig infrastructure is still there to completely remove it for systems that are trying for small footprint. Put it in the main vfio.ko module now that kbuild can support multiple .c files. Signed-off-by: Jason Gunthorpe Reviewed-by: Cornelia Huck --- drivers/vfio/Kconfig | 2 +- drivers/vfio/Makefile | 4 +--- drivers/vfio/vfio.h | 13 +++++++++++++ drivers/vfio/vfio_main.c | 7 +++++++ drivers/vfio/virqfd.c | 17 +++-------------- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index d25b91adfd64cd..0b8d53f63c7e5c 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -21,7 +21,7 @@ config VFIO_IOMMU_SPAPR_TCE default VFIO config VFIO_VIRQFD - tristate + bool select EVENTFD default n diff --git a/drivers/vfio/Makefile b/drivers/vfio/Makefile index 50b8e8e3fb10dd..0721ed4831c92f 100644 --- a/drivers/vfio/Makefile +++ b/drivers/vfio/Makefile @@ -1,13 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 -vfio_virqfd-y := virqfd.o - obj-$(CONFIG_VFIO) += vfio.o vfio-y += vfio_main.o \ iova_bitmap.o \ container.o +vfio-$(CONFIG_VFIO_VIRQFD) += virqfd.o -obj-$(CONFIG_VFIO_VIRQFD) += vfio_virqfd.o obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o obj-$(CONFIG_VFIO_PCI) += pci/ diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h index bcad54bbab08c4..a7113b4baaa242 100644 --- a/drivers/vfio/vfio.h +++ b/drivers/vfio/vfio.h @@ -124,6 +124,19 @@ long vfio_container_ioctl_check_extension(struct vfio_container *container, int __init vfio_container_init(void); void vfio_container_cleanup(void); +#if IS_ENABLED(CONFIG_VFIO_VIRQFD) +int __init vfio_virqfd_init(void); +void vfio_virqfd_exit(void); +#else +static inline int __init vfio_virqfd_init(void) +{ + return 0; +} +static inline void vfio_virqfd_exit(void) +{ +} +#endif + #ifdef CONFIG_VFIO_NOIOMMU extern bool vfio_noiommu __read_mostly; #else diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 2d168793d4e1ce..97d7b88c8fe1f4 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -1814,6 +1814,10 @@ static int __init vfio_init(void) if (ret) return ret; + ret = vfio_virqfd_init(); + if (ret) + goto err_virqfd; + /* /dev/vfio/$GROUP */ vfio.class = class_create(THIS_MODULE, "vfio"); if (IS_ERR(vfio.class)) { @@ -1844,6 +1848,8 @@ static int __init vfio_init(void) class_destroy(vfio.class); vfio.class = NULL; err_group_class: + vfio_virqfd_exit(); +err_virqfd: vfio_container_cleanup(); return ret; } @@ -1858,6 +1864,7 @@ static void __exit vfio_cleanup(void) class_destroy(vfio.device_class); vfio.device_class = NULL; class_destroy(vfio.class); + vfio_virqfd_exit(); vfio_container_cleanup(); vfio.class = NULL; xa_destroy(&vfio_device_set_xa); diff --git a/drivers/vfio/virqfd.c b/drivers/vfio/virqfd.c index 414e98d82b02e5..497a17b3786568 100644 --- a/drivers/vfio/virqfd.c +++ b/drivers/vfio/virqfd.c @@ -12,15 +12,12 @@ #include #include #include - -#define DRIVER_VERSION "0.1" -#define DRIVER_AUTHOR "Alex Williamson " -#define DRIVER_DESC "IRQFD support for VFIO bus drivers" +#include "vfio.h" static struct workqueue_struct *vfio_irqfd_cleanup_wq; static DEFINE_SPINLOCK(virqfd_lock); -static int __init vfio_virqfd_init(void) +int __init vfio_virqfd_init(void) { vfio_irqfd_cleanup_wq = create_singlethread_workqueue("vfio-irqfd-cleanup"); @@ -30,7 +27,7 @@ static int __init vfio_virqfd_init(void) return 0; } -static void __exit vfio_virqfd_exit(void) +void vfio_virqfd_exit(void) { destroy_workqueue(vfio_irqfd_cleanup_wq); } @@ -216,11 +213,3 @@ void vfio_virqfd_disable(struct virqfd **pvirqfd) flush_workqueue(vfio_irqfd_cleanup_wq); } EXPORT_SYMBOL_GPL(vfio_virqfd_disable); - -module_init(vfio_virqfd_init); -module_exit(vfio_virqfd_exit); - -MODULE_VERSION(DRIVER_VERSION); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR(DRIVER_AUTHOR); -MODULE_DESCRIPTION(DRIVER_DESC);