Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/eeh: Introduce eeh_pe_inject_err()

The patch defines PCI error types and functions in uapi/asm/eeh.h
and exports function eeh_pe_inject_err(), which will be called by
VFIO driver to inject the specified PCI error to the indicated
PE for testing purpose.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Gavin Shan and committed by
Michael Ellerman
ec33d36e ed3e81ff

+63
+2
arch/powerpc/include/asm/eeh.h
··· 291 291 int eeh_pe_get_state(struct eeh_pe *pe); 292 292 int eeh_pe_reset(struct eeh_pe *pe, int option); 293 293 int eeh_pe_configure(struct eeh_pe *pe); 294 + int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func, 295 + unsigned long addr, unsigned long mask); 294 296 295 297 /** 296 298 * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
+26
arch/powerpc/include/uapi/asm/eeh.h
··· 27 27 #define EEH_PE_STATE_STOPPED_DMA 4 /* Stopped DMA only */ 28 28 #define EEH_PE_STATE_UNAVAIL 5 /* Unavailable */ 29 29 30 + /* EEH error types and functions */ 31 + #define EEH_ERR_TYPE_32 0 /* 32-bits error */ 32 + #define EEH_ERR_TYPE_64 1 /* 64-bits error */ 33 + #define EEH_ERR_FUNC_MIN 0 34 + #define EEH_ERR_FUNC_LD_MEM_ADDR 0 /* Memory load */ 35 + #define EEH_ERR_FUNC_LD_MEM_DATA 1 36 + #define EEH_ERR_FUNC_LD_IO_ADDR 2 /* IO load */ 37 + #define EEH_ERR_FUNC_LD_IO_DATA 3 38 + #define EEH_ERR_FUNC_LD_CFG_ADDR 4 /* Config load */ 39 + #define EEH_ERR_FUNC_LD_CFG_DATA 5 40 + #define EEH_ERR_FUNC_ST_MEM_ADDR 6 /* Memory store */ 41 + #define EEH_ERR_FUNC_ST_MEM_DATA 7 42 + #define EEH_ERR_FUNC_ST_IO_ADDR 8 /* IO store */ 43 + #define EEH_ERR_FUNC_ST_IO_DATA 9 44 + #define EEH_ERR_FUNC_ST_CFG_ADDR 10 /* Config store */ 45 + #define EEH_ERR_FUNC_ST_CFG_DATA 11 46 + #define EEH_ERR_FUNC_DMA_RD_ADDR 12 /* DMA read */ 47 + #define EEH_ERR_FUNC_DMA_RD_DATA 13 48 + #define EEH_ERR_FUNC_DMA_RD_MASTER 14 49 + #define EEH_ERR_FUNC_DMA_RD_TARGET 15 50 + #define EEH_ERR_FUNC_DMA_WR_ADDR 16 /* DMA write */ 51 + #define EEH_ERR_FUNC_DMA_WR_DATA 17 52 + #define EEH_ERR_FUNC_DMA_WR_MASTER 18 53 + #define EEH_ERR_FUNC_DMA_WR_TARGET 19 54 + #define EEH_ERR_FUNC_MAX 19 55 + 30 56 #endif /* _ASM_POWERPC_EEH_H */
+35
arch/powerpc/kernel/eeh.c
··· 1647 1647 } 1648 1648 EXPORT_SYMBOL_GPL(eeh_pe_configure); 1649 1649 1650 + /** 1651 + * eeh_pe_inject_err - Injecting the specified PCI error to the indicated PE 1652 + * @pe: the indicated PE 1653 + * @type: error type 1654 + * @function: error function 1655 + * @addr: address 1656 + * @mask: address mask 1657 + * 1658 + * The routine is called to inject the specified PCI error, which 1659 + * is determined by @type and @function, to the indicated PE for 1660 + * testing purpose. 1661 + */ 1662 + int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func, 1663 + unsigned long addr, unsigned long mask) 1664 + { 1665 + /* Invalid PE ? */ 1666 + if (!pe) 1667 + return -ENODEV; 1668 + 1669 + /* Unsupported operation ? */ 1670 + if (!eeh_ops || !eeh_ops->err_inject) 1671 + return -ENOENT; 1672 + 1673 + /* Check on PCI error type */ 1674 + if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64) 1675 + return -EINVAL; 1676 + 1677 + /* Check on PCI error function */ 1678 + if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX) 1679 + return -EINVAL; 1680 + 1681 + return eeh_ops->err_inject(pe, type, func, addr, mask); 1682 + } 1683 + EXPORT_SYMBOL_GPL(eeh_pe_inject_err); 1684 + 1650 1685 static int proc_eeh_show(struct seq_file *m, void *v) 1651 1686 { 1652 1687 if (!eeh_enabled()) {