2 * EEH functionality support for VFIO devices. The feature is only
3 * available on sPAPR compatible platforms.
5 * Copyright Gavin Shan, IBM Corporation 2014.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/uaccess.h>
13 #include <linux/vfio.h>
16 /* We might build address mapping here for "fast" path later */
17 int vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
19 return eeh_dev_open(pdev);
21 EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_open);
23 void vfio_spapr_pci_eeh_release(struct pci_dev *pdev)
25 eeh_dev_release(pdev);
27 EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_release);
29 long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
30 unsigned int cmd, unsigned long arg)
33 struct vfio_eeh_pe_op op;
38 case VFIO_CHECK_EXTENSION:
40 ret = eeh_enabled() ? 1 : 0;
45 pe = eeh_iommu_group_to_pe(group);
49 minsz = offsetofend(struct vfio_eeh_pe_op, op);
50 if (copy_from_user(&op, (void __user *)arg, minsz))
52 if (op.argsz < minsz || op.flags)
56 case VFIO_EEH_PE_DISABLE:
57 ret = eeh_pe_set_option(pe, EEH_OPT_DISABLE);
59 case VFIO_EEH_PE_ENABLE:
60 ret = eeh_pe_set_option(pe, EEH_OPT_ENABLE);
62 case VFIO_EEH_PE_UNFREEZE_IO:
63 ret = eeh_pe_set_option(pe, EEH_OPT_THAW_MMIO);
65 case VFIO_EEH_PE_UNFREEZE_DMA:
66 ret = eeh_pe_set_option(pe, EEH_OPT_THAW_DMA);
68 case VFIO_EEH_PE_GET_STATE:
69 ret = eeh_pe_get_state(pe);
71 case VFIO_EEH_PE_RESET_DEACTIVATE:
72 ret = eeh_pe_reset(pe, EEH_RESET_DEACTIVATE);
74 case VFIO_EEH_PE_RESET_HOT:
75 ret = eeh_pe_reset(pe, EEH_RESET_HOT);
77 case VFIO_EEH_PE_RESET_FUNDAMENTAL:
78 ret = eeh_pe_reset(pe, EEH_RESET_FUNDAMENTAL);
80 case VFIO_EEH_PE_CONFIGURE:
81 ret = eeh_pe_configure(pe);
90 EXPORT_SYMBOL(vfio_spapr_iommu_eeh_ioctl);