remove the nvlink2 pci_vfio subdriver
Subsystems (4)
Hi all,
the nvlink2 vfio subdriver is a weird beast. It supports a hardware feature without any open source component - what would normally be the normal open source userspace that we require for kernel drivers, although in this particular case user space could of course be a kernel driver in a VM. It also happens to be a complete mess that does not properly bind to PCI IDs, is hacked into the vfio_pci driver and also pulles in over 1000 lines of code always build into powerpc kernels that have Power NV support enabled. Because of all these issues and the lack of breaking userspace when it is removed I think the best idea is to simply kill.
Diffstat:
arch/powerpc/platforms/powernv/npu-dma.c | 705 --------------------------- b/arch/powerpc/include/asm/opal.h | 3 b/arch/powerpc/include/asm/pci-bridge.h | 1 b/arch/powerpc/include/asm/pci.h | 7 b/arch/powerpc/platforms/powernv/Makefile | 2 b/arch/powerpc/platforms/powernv/opal-call.c | 2 b/arch/powerpc/platforms/powernv/pci-ioda.c | 185 ------- b/arch/powerpc/platforms/powernv/pci.c | 11 b/arch/powerpc/platforms/powernv/pci.h | 17 b/arch/powerpc/platforms/pseries/pci.c | 23 b/drivers/vfio/pci/Kconfig | 6 b/drivers/vfio/pci/Makefile | 1 b/drivers/vfio/pci/vfio_pci.c | 18 b/drivers/vfio/pci/vfio_pci_private.h | 14 b/include/uapi/linux/vfio.h | 40 - drivers/vfio/pci/vfio_pci_nvlink2.c | 490 ------------------ 16 files changed, 8 insertions(+), 1517 deletions(-)
PATCH 1/2 vfio/pci: remove vfio_pci_nvlink2
This driver never had any open userspace (which for VFIO would include VM kernel drivers) that use it, and thus should never have been added by our normal userspace ABI rules.
--- drivers/vfio/pci/Kconfig | 6 - drivers/vfio/pci/Makefile | 1 - drivers/vfio/pci/vfio_pci.c | 18 - drivers/vfio/pci/vfio_pci_nvlink2.c | 490 ---------------------------- drivers/vfio/pci/vfio_pci_private.h | 14 - include/uapi/linux/vfio.h | 40 --- 6 files changed, 569 deletions(-) delete mode 100644 drivers/vfio/pci/vfio_pci_nvlink2.c
drivers/vfio/pci/Kconfig +0 -6
@@ -39,9 +39,3 @@ config VFIO_PCI_IGD and LPC bridge config space. To enable Intel IGD assignment through vfio-pci, say Y. - -config VFIO_PCI_NVLINK2 - def_bool y - depends on VFIO_PCI && PPC_POWERNV - help - VFIO PCI support for P9 Witherspoon machine with NVIDIA V100 GPUs
drivers/vfio/pci/Makefile +0 -1
@@ -2,7 +2,6 @@ vfio-pci-y := vfio_pci.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_VFIO_PCI_NVLINK2) += vfio_pci_nvlink2.o vfio-pci-$(CONFIG_S390) += vfio_pci_zdev.o obj-$(CONFIG_VFIO_PCI) += vfio-pci.o
drivers/vfio/pci/vfio_pci.c +0 -18
@@ -389,24 +389,6 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev) } } -if (pdev->vendor ==PCI_VENDOR_ID_NVIDIA && -IS_ENABLED (CONFIG_VFIO_PCI_NVLINK2 )) { - ret =vfio_pci_nvdia_v100_nvlink2_init (vdev); -if (ret && ret != -ENODEV ) { -pci_warn (pdev,"Failed to setup NVIDIA NV2 RAM region\n" ); - goto disable_exit; - } - } - -if (pdev->vendor ==PCI_VENDOR_ID_IBM && -IS_ENABLED (CONFIG_VFIO_PCI_NVLINK2 )) { - ret =vfio_pci_ibm_npu2_init (vdev); -if (ret && ret != -ENODEV ) { -pci_warn (pdev,"Failed to setup NVIDIA NV2 ATSD region\n" ); - goto disable_exit; - } - } -vfio_pci_probe_mmaps (vdev);return 0 ;
drivers/vfio/pci/vfio_pci_nvlink2.c deleted +0 -490
490 lines not on this page · raw message
drivers/vfio/pci/vfio_pci_private.h +0 -14
@@ -199,20 +199,6 @@ static inline int vfio_pci_igd_init(struct vfio_pci_device *vdev)return -ENODEV ; }#endif -#ifdef CONFIG_VFIO_PCI_NVLINK2 -extern int vfio_pci_nvdia_v100_nvlink2_init (struct vfio_pci_device *vdev); -extern int vfio_pci_ibm_npu2_init (struct vfio_pci_device *vdev); -#else -static inline int vfio_pci_nvdia_v100_nvlink2_init (struct vfio_pci_device *vdev) -{ -return -ENODEV ; -} - -static inline int vfio_pci_ibm_npu2_init (struct vfio_pci_device *vdev) -{ -return -ENODEV ; -} -#endif #ifdef CONFIG_S390 extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev,
include/uapi/linux/vfio.h +0 -40
@@ -332,19 +332,6 @@ struct vfio_region_info_cap_type {#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3) -/* 10de vendor PCI sub-types */ -/* -* NVIDIA GPU NVlink2 RAM is coherent RAM mapped onto the host address space. -*/ -#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1) - -/* 1014 vendor PCI sub-types */ -/* -* IBM NPU NVlink2 ATSD (Address Translation Shootdown) register of NPU -* to do TLB invalidation on a GPU. -*/ -#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1) -/* sub-types for VFIO_REGION_TYPE_GFX */ #define VFIO_REGION_SUBTYPE_GFX_EDID (1)
@@ -637,33 +624,6 @@ struct vfio_device_migration_info {*/ #define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3 -/* -* Capability with compressed real address (aka SSA - small system address) -* where GPU RAM is mapped on a system bus. Used by a GPU for DMA routing -* and by the userspace to associate a NVLink bridge with a GPU. -*/ -#define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT 4 - -struct vfio_region_info_cap_nvlink2_ssatgt { -struct vfio_info_cap_header header; -__u64 tgt; -}; - -/* -* Capability with an NVLink link speed. The value is read by -* the NVlink2 bridge driver from the bridge's "ibm,nvlink-speed" -* property in the device tree. The value is fixed in the hardware -* and failing to provide the correct value results in the link -* not working with no indication from the driver why. -*/ -#define VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD 5 - -struct vfio_region_info_cap_nvlink2_lnkspd { -struct vfio_info_cap_header header; -__u32 link_speed; -__u32 __pad; -}; -/** * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9, * struct vfio_irq_info)
Signature · 1 line
2.30.1
Re: [PATCH 1/2] vfio/pci: remove vfio_pci_nvlink2
Quoted 48 lines · On Mon, 22 Mar 2021 16:01:54 +0100 Christoph Hellwig <[email protected]> wrote:
include/uapi/linux/vfio.h +0
-33@@ -332,19 +332,6 @@ struct vfio_region_info_cap_type {#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3) -/* 10de vendor PCI sub-types */ -/* -* NVIDIA GPU NVlink2 RAM is coherent RAM mapped onto the host address space. -*/ -#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1) - -/* 1014 vendor PCI sub-types */ -/* -* IBM NPU NVlink2 ATSD (Address Translation Shootdown) register of NPU -* to do TLB invalidation on a GPU. -*/ -#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1) -/* sub-types for VFIO_REGION_TYPE_GFX */ #define VFIO_REGION_SUBTYPE_GFX_EDID (1)@@ -637,33 +624,6 @@ struct vfio_device_migration_info {*/ #define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3 -/* -* Capability with compressed real address (aka SSA - small system address) -* where GPU RAM is mapped on a system bus. Used by a GPU for DMA routing -* and by the userspace to associate a NVLink bridge with a GPU. -*/ -#define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT 4 - -struct vfio_region_info_cap_nvlink2_ssatgt { -struct vfio_info_cap_header header; -__u64 tgt; -}; - -/* -* Capability with an NVLink link speed. The value is read by -* the NVlink2 bridge driver from the bridge's "ibm,nvlink-speed" -* property in the device tree. The value is fixed in the hardware -* and failing to provide the correct value results in the link -* not working with no indication from the driver why. -*/ -#define VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD 5
include/uapi/linux/vfio.h struct vfio_device_migration_info { · line 629
Quoted 10 lines
include/uapi/linux/vfio.h +0
-7- -struct vfio_region_info_cap_nvlink2_lnkspd { -struct vfio_info_cap_header header; -__u32 link_speed; -__u32 __pad; -}; -/** * VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9, * struct vfio_irq_info)
I'll leave any attempt to defend keeping this code to Alexey, but minimally these region sub-types and capability IDs should probably be reserved to avoid breaking whatever userspace might exist to consume these. Our ID space is sufficiently large that we don't need to recycle them any time soon. Thanks,
Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 powerpc/powernv: remove the nvlink support
In reply to Christoph HellwigThis code was only used by the vfio-nvlink2 code, which itself had no proper use. Drop this huge chunk of code build into every powernv or generic build.
--- arch/powerpc/include/asm/opal.h | 3 - arch/powerpc/include/asm/pci-bridge.h | 1 - arch/powerpc/include/asm/pci.h | 7 - arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/npu-dma.c | 705 --------------------- arch/powerpc/platforms/powernv/opal-call.c | 2 - arch/powerpc/platforms/powernv/pci-ioda.c | 185 +----- arch/powerpc/platforms/powernv/pci.c | 11 - arch/powerpc/platforms/powernv/pci.h | 17 +- arch/powerpc/platforms/pseries/pci.c | 23 - 10 files changed, 8 insertions(+), 948 deletions(-) delete mode 100644 arch/powerpc/platforms/powernv/npu-dma.c
arch/powerpc/include/asm/opal.h +0 -3
@@ -28,9 +28,6 @@ extern struct device_node *opal_node;/* API functions */ int64_t opal_invalid_call (void ); -int64_t opal_npu_destroy_context (uint64_t phb_id,uint64_t pid,uint64_t bdf); -int64_t opal_npu_init_context (uint64_t phb_id,int pasid,uint64_t msr, -uint64_t bdf);int64_t opal_npu_map_lpar (uint64_t phb_id,uint64_t bdf,uint64_t lparid,uint64_t lpcr); int64_t opal_npu_spa_setup(uint64_t phb_id, uint32_t bdfn,
arch/powerpc/include/asm/pci-bridge.h +0 -1
@@ -126,7 +126,6 @@ struct pci_controller {#endif /* CONFIG_PPC64 */ void *private_data; -struct npu *npu; };/* These are used for config access before all the PCI probing
arch/powerpc/include/asm/pci.h +0 -7
@@ -119,11 +119,4 @@ extern void pcibios_scan_phb(struct pci_controller *hose);#endif /* __KERNEL__ */ -extern struct pci_dev *pnv_pci_get_gpu_dev (struct pci_dev *npdev); -extern struct pci_dev *pnv_pci_get_npu_dev (struct pci_dev *gpdev,int index); -extern int pnv_npu2_init (struct pci_controller *hose); -extern int pnv_npu2_map_lpar_dev (struct pci_dev *gpdev,unsigned int lparid, -unsigned long msr); -extern int pnv_npu2_unmap_lpar_dev (struct pci_dev *gpdev); -#endif /* __ASM_POWERPC_PCI_H */
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-$(CONFIG_SMP) += smp.o subcore.o subcore-asm.o obj-$(CONFIG_FA_DUMP) += opal-fadump.o obj-$(CONFIG_PRESERVE_FA_DUMP) += opal-fadump.o obj-$(CONFIG_OPAL_CORE) += opal-core.o -obj-$(CONFIG_PCI) += pci.o pci-ioda.o npu-dma.o pci-ioda-tce.o +obj-$(CONFIG_PCI) += pci.o pci-ioda.o pci-ioda-tce.o obj-$(CONFIG_PCI_IOV) += pci-sriov.o obj-$(CONFIG_CXL_BASE) += pci-cxl.o obj-$(CONFIG_EEH) += eeh-powernv.o
arch/powerpc/platforms/powernv/npu-dma.c deleted +0 -705
705 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-call.c +0 -2
@@ -267,8 +267,6 @@ OPAL_CALL(opal_xive_get_queue_state, OPAL_XIVE_GET_QUEUE_STATE);OPAL_CALL (opal_xive_set_queue_state,OPAL_XIVE_SET_QUEUE_STATE );OPAL_CALL (opal_xive_get_vp_state,OPAL_XIVE_GET_VP_STATE );OPAL_CALL (opal_signal_system_reset,OPAL_SIGNAL_SYSTEM_RESET ); -OPAL_CALL (opal_npu_init_context,OPAL_NPU_INIT_CONTEXT ); -OPAL_CALL (opal_npu_destroy_context,OPAL_NPU_DESTROY_CONTEXT );OPAL_CALL (opal_npu_map_lpar,OPAL_NPU_MAP_LPAR );OPAL_CALL (opal_imc_counters_init,OPAL_IMC_COUNTERS_INIT );OPAL_CALL (opal_imc_counters_start,OPAL_IMC_COUNTERS_START );
arch/powerpc/platforms/powernv/pci-ioda.c +4 -181
275 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.c +0 -11
@@ -926,17 +926,6 @@ void __init pnv_pci_init(void)for_each_compatible_node (np,NULL ,"ibm,ioda3-phb" )pnv_pci_init_ioda2_phb (np); -/* Look for NPU PHBs */ -for_each_compatible_node (np,NULL ,"ibm,ioda2-npu-phb" ) -pnv_pci_init_npu_phb (np); - -/* -* Look for NPU2 PHBs which we treat mostly as NPU PHBs with -* the exception of TCE kill which requires an OPAL call. -*/ -for_each_compatible_node (np,NULL ,"ibm,ioda2-npu2-phb" ) -pnv_pci_init_npu_phb (np); -/* Look for NPU2 OpenCAPI PHBs */ for_each_compatible_node (np,NULL ,"ibm,ioda2-npu2-opencapi-phb" )pnv_pci_init_npu2_opencapi_phb (np);
arch/powerpc/platforms/powernv/pci.h +3 -14
@@ -10,10 +10,9 @@struct pci_dn ;enum pnv_phb_type { -PNV_PHB_IODA1 =0 , -PNV_PHB_IODA2 =1 , -PNV_PHB_NPU_NVLINK =2 , -PNV_PHB_NPU_OCAPI =3 , +PNV_PHB_IODA1 , +PNV_PHB_IODA2 , +PNV_PHB_NPU_OCAPI , };/* Precise PHB model for error management */
@@ -21,8 +20,6 @@ enum pnv_phb_model {PNV_PHB_MODEL_UNKNOWN ,PNV_PHB_MODEL_P7IOC , PNV_PHB_MODEL_PHB3, -PNV_PHB_MODEL_NPU , - PNV_PHB_MODEL_NPU2, };#define PNV_PCI_DIAG_BUF_SIZE 8192
@@ -81,7 +78,6 @@ struct pnv_ioda_pe {/* "Base" iommu table, ie, 4K TCEs, 32-bit DMA */ struct iommu_table_group table_group; -struct npu_comp *npucomp;/* 64-bit TCE bypass region */ bool tce_bypass_enabled;
@@ -289,9 +285,7 @@ extern struct iommu_table *pnv_pci_table_alloc(int nid);extern void pnv_pci_init_ioda_hub (struct device_node *np);extern void pnv_pci_init_ioda2_phb (struct device_node *np); -extern void pnv_pci_init_npu_phb (struct device_node *np);extern void pnv_pci_init_npu2_opencapi_phb (struct device_node *np); -extern void pnv_npu2_map_lpar (struct pnv_ioda_pe *gpe,unsigned long msr);extern void pnv_pci_reset_secondary_bus (struct pci_dev *dev);extern int pnv_eeh_phb_reset (struct pci_controller *hose,int option);
@@ -314,11 +308,6 @@ extern void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level,#define pe_info (pe, fmt, ...) \ pe_level_printk(pe, KERN_INFO, fmt, ##__VA_ARGS__) -/* Nvlink functions */ -extern void pnv_npu_try_dma_set_bypass (struct pci_dev *gpdev,bool bypass); -extern void pnv_pci_ioda2_tce_invalidate_entire (struct pnv_phb *phb,bool rm); -extern void pnv_pci_npu_setup_iommu_groups (void ); -/* pci-ioda-tce.c */ #define POWERNV_IOMMU_DEFAULT_LEVELS 2#define POWERNV_IOMMU_MAX_LEVELS 5
arch/powerpc/platforms/pseries/pci.c +0 -23
@@ -224,8 +224,6 @@ static void __init pSeries_request_regions(void)void __init pSeries_final_fixup (void ) { -struct pci_controller *hose; -pSeries_request_regions ();eeh_show_enabled ();
@@ -234,27 +232,6 @@ void __init pSeries_final_fixup(void) ppc_md.pcibios_sriov_enable = pseries_pcibios_sriov_enable; ppc_md.pcibios_sriov_disable = pseries_pcibios_sriov_disable;#endif -list_for_each_entry (hose, &hose_list, list_node) { -struct device_node *dn = hose->dn, *nvdn; - -while (1 ) { - dn =of_find_all_nodes (dn); -if (!dn) -break ; - nvdn =of_parse_phandle (dn,"ibm,nvlink" ,0 ); -if (!nvdn) -continue ; -if (!of_device_is_compatible (nvdn,"ibm,npu-link" )) -continue ; -if (!of_device_is_compatible (nvdn->parent, -"ibm,power9-npu" )) -continue ; -#ifdef CONFIG_PPC_POWERNV -WARN_ON_ONCE (pnv_npu2_init (hose)); -#endif -break ; - } - } }/*
Signature · 1 line
2.30.1
Greg Kroah-Hartman
Acked-byQuoted 23 lines · Christoph Hellwig
Hi all,
the nvlink2 vfio subdriver is a weird beast. It supports a hardware feature without any open source component - what would normally be the normal open source userspace that we require for kernel drivers, although in this particular case user space could of course be a kernel driver in a VM. It also happens to be a complete mess that does not properly bind to PCI IDs, is hacked into the
vfio_pcidriver and also pulles in over 1000 lines of code always build into powerpc kernels that have Power NV support enabled. Because of all these issues and the lack of breaking userspace when it is removed I think the best idea is to simply kill.Diffstat:
arch/powerpc/platforms/powernv/npu-dma.c | 705 --------------------------- b/arch/powerpc/include/asm/opal.h | 3 b/arch/powerpc/include/asm/pci-bridge.h | 1 b/arch/powerpc/include/asm/pci.h | 7 b/arch/powerpc/platforms/powernv/Makefile | 2 b/arch/powerpc/platforms/powernv/opal-call.c | 2 b/arch/powerpc/platforms/powernv/pci-ioda.c | 185 ------- b/arch/powerpc/platforms/powernv/pci.c | 11 b/arch/powerpc/platforms/powernv/pci.h | 17
Quoted 8 lines
b/arch/powerpc/platforms/pseries/pci.c | 23 b/drivers/vfio/pci/Kconfig | 6 b/drivers/vfio/pci/Makefile | 1 b/drivers/vfio/pci/vfio_pci.c | 18 b/drivers/vfio/pci/vfio_pci_private.h | 14 b/include/uapi/linux/vfio.h | 40 - drivers/vfio/pci/vfio_pci_nvlink2.c | 490 ------------------ 16 files changed, 8 insertions(+), 1517 deletions(-)
I thought this was supposed to be removed a few years ago!
Anyway, no objection from me:
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel