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
);
22 void vfio_spapr_pci_eeh_release(struct pci_dev
*pdev
)
24 eeh_dev_release(pdev
);
27 long vfio_spapr_iommu_eeh_ioctl(struct iommu_group
*group
,
28 unsigned int cmd
, unsigned long arg
)
31 struct vfio_eeh_pe_op op
;
36 case VFIO_CHECK_EXTENSION
:
38 ret
= eeh_enabled() ? 1 : 0;
43 pe
= eeh_iommu_group_to_pe(group
);
47 minsz
= offsetofend(struct vfio_eeh_pe_op
, op
);
48 if (copy_from_user(&op
, (void __user
*)arg
, minsz
))
50 if (op
.argsz
< minsz
|| op
.flags
)
54 case VFIO_EEH_PE_DISABLE
:
55 ret
= eeh_pe_set_option(pe
, EEH_OPT_DISABLE
);
57 case VFIO_EEH_PE_ENABLE
:
58 ret
= eeh_pe_set_option(pe
, EEH_OPT_ENABLE
);
60 case VFIO_EEH_PE_UNFREEZE_IO
:
61 ret
= eeh_pe_set_option(pe
, EEH_OPT_THAW_MMIO
);
63 case VFIO_EEH_PE_UNFREEZE_DMA
:
64 ret
= eeh_pe_set_option(pe
, EEH_OPT_THAW_DMA
);
66 case VFIO_EEH_PE_GET_STATE
:
67 ret
= eeh_pe_get_state(pe
);
69 case VFIO_EEH_PE_RESET_DEACTIVATE
:
70 ret
= eeh_pe_reset(pe
, EEH_RESET_DEACTIVATE
);
72 case VFIO_EEH_PE_RESET_HOT
:
73 ret
= eeh_pe_reset(pe
, EEH_RESET_HOT
);
75 case VFIO_EEH_PE_RESET_FUNDAMENTAL
:
76 ret
= eeh_pe_reset(pe
, EEH_RESET_FUNDAMENTAL
);
78 case VFIO_EEH_PE_CONFIGURE
:
79 ret
= eeh_pe_configure(pe
);