Blame view
drivers/vfio/vfio_spapr_eeh.c
2.62 KB
d2912cb15 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
1b69be5e8 drivers/vfio: EEH... |
2 3 4 5 6 |
/* * EEH functionality support for VFIO devices. The feature is only * available on sPAPR compatible platforms. * * Copyright Gavin Shan, IBM Corporation 2014. |
1b69be5e8 drivers/vfio: EEH... |
7 |
*/ |
89a2edd62 drivers/vfio: All... |
8 |
#include <linux/module.h> |
1b69be5e8 drivers/vfio: EEH... |
9 10 11 |
#include <linux/uaccess.h> #include <linux/vfio.h> #include <asm/eeh.h> |
89a2edd62 drivers/vfio: All... |
12 13 14 |
#define DRIVER_VERSION "0.1" #define DRIVER_AUTHOR "Gavin Shan, IBM Corporation" #define DRIVER_DESC "VFIO IOMMU SPAPR EEH" |
1b69be5e8 drivers/vfio: EEH... |
15 |
/* We might build address mapping here for "fast" path later */ |
9b936c960 drivers/vfio: Ena... |
16 |
void vfio_spapr_pci_eeh_open(struct pci_dev *pdev) |
1b69be5e8 drivers/vfio: EEH... |
17 |
{ |
9b936c960 drivers/vfio: Ena... |
18 |
eeh_dev_open(pdev); |
1b69be5e8 drivers/vfio: EEH... |
19 |
} |
92d18a685 drivers/vfio: Fix... |
20 |
EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_open); |
1b69be5e8 drivers/vfio: EEH... |
21 22 23 24 25 |
void vfio_spapr_pci_eeh_release(struct pci_dev *pdev) { eeh_dev_release(pdev); } |
92d18a685 drivers/vfio: Fix... |
26 |
EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_release); |
1b69be5e8 drivers/vfio: EEH... |
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
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_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) 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: |
1ef52073f powerpc/eeh: Impr... |
71 |
ret = eeh_pe_reset(pe, EEH_RESET_DEACTIVATE, true); |
1b69be5e8 drivers/vfio: EEH... |
72 73 |
break; case VFIO_EEH_PE_RESET_HOT: |
1ef52073f powerpc/eeh: Impr... |
74 |
ret = eeh_pe_reset(pe, EEH_RESET_HOT, true); |
1b69be5e8 drivers/vfio: EEH... |
75 76 |
break; case VFIO_EEH_PE_RESET_FUNDAMENTAL: |
1ef52073f powerpc/eeh: Impr... |
77 |
ret = eeh_pe_reset(pe, EEH_RESET_FUNDAMENTAL, true); |
1b69be5e8 drivers/vfio: EEH... |
78 79 80 81 |
break; case VFIO_EEH_PE_CONFIGURE: ret = eeh_pe_configure(pe); break; |
68cbbc3a9 drivers/vfio: Sup... |
82 83 84 85 86 87 88 89 90 91 |
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; |
1b69be5e8 drivers/vfio: EEH... |
92 93 94 95 96 97 98 |
default: ret = -EINVAL; } } return ret; } |
0f905ce2b drivers/vfio: Exp... |
99 |
EXPORT_SYMBOL_GPL(vfio_spapr_iommu_eeh_ioctl); |
89a2edd62 drivers/vfio: All... |
100 101 102 103 104 |
MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); |