We want the USB fixes in here as well.
Unified · Split
| @@ -21,6 +21,7 @@ Andrey Ryabinin <ryabinin.a.a@gmail.com> <a.ryabinin@samsung.com> · 20 unmodified lines | |||
| 21 | Andrew Morton <akpm@linux-foundation.org> | 21 | Andrew Morton <akpm@linux-foundation.org> |
| 22 | Andrew Vasquez <andrew.vasquez@qlogic.com> | 22 | Andrew Vasquez <andrew.vasquez@qlogic.com> |
| 23 | Andy Adamson <andros@citi.umich.edu> | 23 | Andy Adamson <andros@citi.umich.edu> |
| 24 | Antonio Ospite <ao2@ao2.it> <ao2@amarulasolutions.com> | ||
| 24 | Archit Taneja <archit@ti.com> | 25 | Archit Taneja <archit@ti.com> |
| 25 | Arnaud Patard <arnaud.patard@rtp-net.org> | 26 | Arnaud Patard <arnaud.patard@rtp-net.org> |
| 26 | Arnd Bergmann <arnd@arndb.de> | 27 | Arnd Bergmann <arnd@arndb.de> |
| @@ -3,7 +3,7 @@ Linux IOMMU Support · 2 unmodified lines | |||
| 3 | 3 | ||
| 4 | The architecture spec can be obtained from the below location. | 4 | The architecture spec can be obtained from the below location. |
| 5 | 5 | ||
| 6 | http://www.intel.com/technology/virtualization/ | 6 | http://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf |
| 7 | 7 | ||
| 8 | This guide gives a quick cheat sheet for some basic understanding. | 8 | This guide gives a quick cheat sheet for some basic understanding. |
| 9 | 9 | ||
| @@ -3025,7 +3025,7 @@ len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0 · 3024 unmodified lines | |||
| 3025 | and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq), | 3025 | and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq), |
| 3026 | which is the maximum number of possibly pending cpu-local interrupts. | 3026 | which is the maximum number of possibly pending cpu-local interrupts. |
| 3027 | 3027 | ||
| 3028 | 4.90 KVM_SMI | 3028 | 4.96 KVM_SMI |
| 3029 | 3029 | ||
| 3030 | Capability: KVM_CAP_X86_SMM | 3030 | Capability: KVM_CAP_X86_SMM |
| 3031 | Architectures: x86 | 3031 | Architectures: x86 |
| @@ -1,7 +1,7 @@ | |||
| 1 | VERSION = 4 | 1 | VERSION = 4 |
| 2 | PATCHLEVEL = 5 | 2 | PATCHLEVEL = 5 |
| 3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
| 4 | EXTRAVERSION = -rc1 | 4 | EXTRAVERSION = -rc2 |
| 5 | NAME = Blurry Fish Butt | 5 | NAME = Blurry Fish Butt |
| 6 | 6 | ||
| 7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
| @@ -106,6 +106,15 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS) · 105 unmodified lines | |||
| 106 | KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) | 106 | KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) |
| 107 | endif | 107 | endif |
| 108 | 108 | ||
| 109 | # -fstack-protector-strong triggers protection checks in this code, | ||
| 110 | # but it is being used too early to link to meaningful stack_chk logic. | ||
| 111 | nossp_flags := $(call cc-option, -fno-stack-protector) | ||
| 112 | CFLAGS_atags_to_fdt.o := $(nossp_flags) | ||
| 113 | CFLAGS_fdt.o := $(nossp_flags) | ||
| 114 | CFLAGS_fdt_ro.o := $(nossp_flags) | ||
| 115 | CFLAGS_fdt_rw.o := $(nossp_flags) | ||
| 116 | CFLAGS_fdt_wip.o := $(nossp_flags) | ||
| 117 | |||
| 109 | ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj) | 118 | ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj) |
| 110 | asflags-y := -DZIMAGE | 119 | asflags-y := -DZIMAGE |
| 111 | 120 | ||
| @@ -417,6 +417,7 @@ · 416 unmodified lines | |||
| 417 | #define __NR_userfaultfd (__NR_SYSCALL_BASE+388) | 417 | #define __NR_userfaultfd (__NR_SYSCALL_BASE+388) |
| 418 | #define __NR_membarrier (__NR_SYSCALL_BASE+389) | 418 | #define __NR_membarrier (__NR_SYSCALL_BASE+389) |
| 419 | #define __NR_mlock2 (__NR_SYSCALL_BASE+390) | 419 | #define __NR_mlock2 (__NR_SYSCALL_BASE+390) |
| 420 | #define __NR_copy_file_range (__NR_SYSCALL_BASE+391) | ||
| 420 | 421 | ||
| 421 | /* | 422 | /* |
| 422 | * The following SWIs are ARM private. | 423 | * The following SWIs are ARM private. |
| @@ -400,6 +400,7 @@ · 399 unmodified lines | |||
| 400 | CALL(sys_userfaultfd) | 400 | CALL(sys_userfaultfd) |
| 401 | CALL(sys_membarrier) | 401 | CALL(sys_membarrier) |
| 402 | CALL(sys_mlock2) | 402 | CALL(sys_mlock2) |
| 403 | CALL(sys_copy_file_range) | ||
| 403 | #ifndef syscalls_counted | 404 | #ifndef syscalls_counted |
| 404 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls | 405 | .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls |
| 405 | #define syscalls_counted | 406 | #define syscalls_counted |
| @@ -27,6 +27,8 @@ $(warning LSE atomics not supported by binutils) · 26 unmodified lines | |||
| 27 | endif | 27 | endif |
| 28 | 28 | ||
| 29 | KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) | 29 | KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) |
| 30 | KBUILD_CFLAGS += -fno-asynchronous-unwind-tables | ||
| 31 | KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads) | ||
| 30 | KBUILD_AFLAGS += $(lseinstr) | 32 | KBUILD_AFLAGS += $(lseinstr) |
| 31 | 33 | ||
| 32 | ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) | 34 | ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) |
| @@ -16,7 +16,6 @@ CONFIG_IKCONFIG_PROC=y · 15 unmodified lines | |||
| 16 | CONFIG_LOG_BUF_SHIFT=14 | 16 | CONFIG_LOG_BUF_SHIFT=14 |
| 17 | CONFIG_MEMCG=y | 17 | CONFIG_MEMCG=y |
| 18 | CONFIG_MEMCG_SWAP=y | 18 | CONFIG_MEMCG_SWAP=y |
| 19 | CONFIG_MEMCG_KMEM=y | ||
| 20 | CONFIG_CGROUP_HUGETLB=y | 19 | CONFIG_CGROUP_HUGETLB=y |
| 21 | # CONFIG_UTS_NS is not set | 20 | # CONFIG_UTS_NS is not set |
| 22 | # CONFIG_IPC_NS is not set | 21 | # CONFIG_IPC_NS is not set |
| @@ -37,15 +36,13 @@ CONFIG_ARCH_EXYNOS7=y · 14 unmodified lines | |||
| 37 | CONFIG_ARCH_LAYERSCAPE=y | 36 | CONFIG_ARCH_LAYERSCAPE=y |
| 38 | CONFIG_ARCH_HISI=y | 37 | CONFIG_ARCH_HISI=y |
| 39 | CONFIG_ARCH_MEDIATEK=y | 38 | CONFIG_ARCH_MEDIATEK=y |
| 39 | CONFIG_ARCH_QCOM=y | ||
| 40 | CONFIG_ARCH_ROCKCHIP=y | 40 | CONFIG_ARCH_ROCKCHIP=y |
| 41 | CONFIG_ARCH_SEATTLE=y | 41 | CONFIG_ARCH_SEATTLE=y |
| 42 | CONFIG_ARCH_RENESAS=y | 42 | CONFIG_ARCH_RENESAS=y |
| 43 | CONFIG_ARCH_R8A7795=y | 43 | CONFIG_ARCH_R8A7795=y |
| 44 | CONFIG_ARCH_STRATIX10=y | 44 | CONFIG_ARCH_STRATIX10=y |
| 45 | CONFIG_ARCH_TEGRA=y | 45 | CONFIG_ARCH_TEGRA=y |
| 46 | CONFIG_ARCH_TEGRA_132_SOC=y | ||
| 47 | CONFIG_ARCH_TEGRA_210_SOC=y | ||
| 48 | CONFIG_ARCH_QCOM=y | ||
| 49 | CONFIG_ARCH_SPRD=y | 46 | CONFIG_ARCH_SPRD=y |
| 50 | CONFIG_ARCH_THUNDER=y | 47 | CONFIG_ARCH_THUNDER=y |
| 51 | CONFIG_ARCH_UNIPHIER=y | 48 | CONFIG_ARCH_UNIPHIER=y |
| @@ -54,14 +51,19 @@ CONFIG_ARCH_XGENE=y · 2 unmodified lines | |||
| 54 | CONFIG_ARCH_ZYNQMP=y | 51 | CONFIG_ARCH_ZYNQMP=y |
| 55 | CONFIG_PCI=y | 52 | CONFIG_PCI=y |
| 56 | CONFIG_PCI_MSI=y | 53 | CONFIG_PCI_MSI=y |
| 54 | CONFIG_PCI_IOV=y | ||
| 55 | CONFIG_PCI_RCAR_GEN2_PCIE=y | ||
| 57 | CONFIG_PCI_HOST_GENERIC=y | 56 | CONFIG_PCI_HOST_GENERIC=y |
| 58 | CONFIG_PCI_XGENE=y | 57 | CONFIG_PCI_XGENE=y |
| 59 | CONFIG_SMP=y | 58 | CONFIG_PCI_LAYERSCAPE=y |
| 59 | CONFIG_PCI_HISI=y | ||
| 60 | CONFIG_PCIE_QCOM=y | ||
| 60 | CONFIG_SCHED_MC=y | 61 | CONFIG_SCHED_MC=y |
| 61 | CONFIG_PREEMPT=y | 62 | CONFIG_PREEMPT=y |
| 62 | CONFIG_KSM=y | 63 | CONFIG_KSM=y |
| 63 | CONFIG_TRANSPARENT_HUGEPAGE=y | 64 | CONFIG_TRANSPARENT_HUGEPAGE=y |
| 64 | CONFIG_CMA=y | 65 | CONFIG_CMA=y |
| 66 | CONFIG_XEN=y | ||
| 65 | CONFIG_CMDLINE="console=ttyAMA0" | 67 | CONFIG_CMDLINE="console=ttyAMA0" |
| 66 | # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set | 68 | # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set |
| 67 | CONFIG_COMPAT=y | 69 | CONFIG_COMPAT=y |
| @@ -100,7 +102,11 @@ CONFIG_PATA_OF_PLATFORM=y · 32 unmodified lines | |||
| 100 | CONFIG_NETDEVICES=y | 102 | CONFIG_NETDEVICES=y |
| 101 | CONFIG_TUN=y | 103 | CONFIG_TUN=y |
| 102 | CONFIG_VIRTIO_NET=y | 104 | CONFIG_VIRTIO_NET=y |
| 105 | CONFIG_AMD_XGBE=y | ||
| 103 | CONFIG_NET_XGENE=y | 106 | CONFIG_NET_XGENE=y |
| 107 | CONFIG_E1000E=y | ||
| 108 | CONFIG_IGB=y | ||
| 109 | CONFIG_IGBVF=y | ||
| 104 | CONFIG_SKY2=y | 110 | CONFIG_SKY2=y |
| 105 | CONFIG_RAVB=y | 111 | CONFIG_RAVB=y |
| 106 | CONFIG_SMC91X=y | 112 | CONFIG_SMC91X=y |
| @@ -117,25 +123,23 @@ CONFIG_SERIAL_8250_CONSOLE=y · 10 unmodified lines | |||
| 117 | CONFIG_SERIAL_8250_DW=y | 123 | CONFIG_SERIAL_8250_DW=y |
| 118 | CONFIG_SERIAL_8250_MT6577=y | 124 | CONFIG_SERIAL_8250_MT6577=y |
| 119 | CONFIG_SERIAL_8250_UNIPHIER=y | 125 | CONFIG_SERIAL_8250_UNIPHIER=y |
| 126 | CONFIG_SERIAL_OF_PLATFORM=y | ||
| 120 | CONFIG_SERIAL_AMBA_PL011=y | 127 | CONFIG_SERIAL_AMBA_PL011=y |
| 121 | CONFIG_SERIAL_AMBA_PL011_CONSOLE=y | 128 | CONFIG_SERIAL_AMBA_PL011_CONSOLE=y |
| 122 | CONFIG_SERIAL_SAMSUNG=y | 129 | CONFIG_SERIAL_SAMSUNG=y |
| 123 | CONFIG_SERIAL_SAMSUNG_UARTS_4=y | ||
| 124 | CONFIG_SERIAL_SAMSUNG_UARTS=4 | ||
| 125 | CONFIG_SERIAL_SAMSUNG_CONSOLE=y | 130 | CONFIG_SERIAL_SAMSUNG_CONSOLE=y |
| 131 | CONFIG_SERIAL_TEGRA=y | ||
| 126 | CONFIG_SERIAL_SH_SCI=y | 132 | CONFIG_SERIAL_SH_SCI=y |
| 127 | CONFIG_SERIAL_SH_SCI_NR_UARTS=11 | 133 | CONFIG_SERIAL_SH_SCI_NR_UARTS=11 |
| 128 | CONFIG_SERIAL_SH_SCI_CONSOLE=y | 134 | CONFIG_SERIAL_SH_SCI_CONSOLE=y |
| 129 | CONFIG_SERIAL_TEGRA=y | ||
| 130 | CONFIG_SERIAL_MSM=y | 135 | CONFIG_SERIAL_MSM=y |
| 131 | CONFIG_SERIAL_MSM_CONSOLE=y | 136 | CONFIG_SERIAL_MSM_CONSOLE=y |
| 132 | CONFIG_SERIAL_OF_PLATFORM=y | ||
| 133 | CONFIG_SERIAL_XILINX_PS_UART=y | 137 | CONFIG_SERIAL_XILINX_PS_UART=y |
| 134 | CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y | 138 | CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y |
| 135 | CONFIG_VIRTIO_CONSOLE=y | 139 | CONFIG_VIRTIO_CONSOLE=y |
| 136 | # CONFIG_HW_RANDOM is not set | 140 | # CONFIG_HW_RANDOM is not set |
| 137 | CONFIG_I2C=y | ||
| 138 | CONFIG_I2C_QUP=y | 141 | CONFIG_I2C_QUP=y |
| 142 | CONFIG_I2C_UNIPHIER_F=y | ||
| 139 | CONFIG_I2C_RCAR=y | 143 | CONFIG_I2C_RCAR=y |
| 140 | CONFIG_SPI=y | 144 | CONFIG_SPI=y |
| 141 | CONFIG_SPI_PL022=y | 145 | CONFIG_SPI_PL022=y |
| @@ -176,8 +180,6 @@ CONFIG_MMC_SDHCI_PLTFM=y · 34 unmodified lines | |||
| 176 | CONFIG_MMC_SDHCI_TEGRA=y | 180 | CONFIG_MMC_SDHCI_TEGRA=y |
| 177 | CONFIG_MMC_SPI=y | 181 | CONFIG_MMC_SPI=y |
| 178 | CONFIG_MMC_DW=y | 182 | CONFIG_MMC_DW=y |
| 179 | CONFIG_MMC_DW_IDMAC=y | ||
| 180 | CONFIG_MMC_DW_PLTFM=y | ||
| 181 | CONFIG_MMC_DW_EXYNOS=y | 183 | CONFIG_MMC_DW_EXYNOS=y |
| 182 | CONFIG_NEW_LEDS=y | 184 | CONFIG_NEW_LEDS=y |
| 183 | CONFIG_LEDS_CLASS=y | 185 | CONFIG_LEDS_CLASS=y |
| @@ -187,28 +189,33 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y · 3 unmodified lines | |||
| 187 | CONFIG_LEDS_TRIGGER_CPU=y | 189 | CONFIG_LEDS_TRIGGER_CPU=y |
| 188 | CONFIG_RTC_CLASS=y | 190 | CONFIG_RTC_CLASS=y |
| 189 | CONFIG_RTC_DRV_EFI=y | 191 | CONFIG_RTC_DRV_EFI=y |
| 192 | CONFIG_RTC_DRV_PL031=y | ||
| 190 | CONFIG_RTC_DRV_XGENE=y | 193 | CONFIG_RTC_DRV_XGENE=y |
| 191 | CONFIG_DMADEVICES=y | 194 | CONFIG_DMADEVICES=y |
| 192 | CONFIG_RCAR_DMAC=y | ||
| 193 | CONFIG_QCOM_BAM_DMA=y | 195 | CONFIG_QCOM_BAM_DMA=y |
| 194 | CONFIG_TEGRA20_APB_DMA=y | 196 | CONFIG_TEGRA20_APB_DMA=y |
| 197 | CONFIG_RCAR_DMAC=y | ||
| 198 | CONFIG_VFIO=y | ||
| 199 | CONFIG_VFIO_PCI=y | ||
| 195 | CONFIG_VIRTIO_PCI=y | 200 | CONFIG_VIRTIO_PCI=y |
| 196 | CONFIG_VIRTIO_BALLOON=y | 201 | CONFIG_VIRTIO_BALLOON=y |
| 197 | CONFIG_VIRTIO_MMIO=y | 202 | CONFIG_VIRTIO_MMIO=y |
| 203 | CONFIG_XEN_GNTDEV=y | ||
| 204 | CONFIG_XEN_GRANT_DEV_ALLOC=y | ||
| 198 | CONFIG_COMMON_CLK_CS2000_CP=y | 205 | CONFIG_COMMON_CLK_CS2000_CP=y |
| 199 | CONFIG_COMMON_CLK_QCOM=y | 206 | CONFIG_COMMON_CLK_QCOM=y |
| 200 | CONFIG_MSM_GCC_8916=y | 207 | CONFIG_MSM_GCC_8916=y |
| 201 | CONFIG_HWSPINLOCK_QCOM=y | 208 | CONFIG_HWSPINLOCK_QCOM=y |
| 202 | # CONFIG_IOMMU_SUPPORT is not set | 209 | CONFIG_ARM_SMMU=y |
| 203 | CONFIG_QCOM_SMEM=y | 210 | CONFIG_QCOM_SMEM=y |
| 204 | CONFIG_QCOM_SMD=y | 211 | CONFIG_QCOM_SMD=y |
| 205 | CONFIG_QCOM_SMD_RPM=y | 212 | CONFIG_QCOM_SMD_RPM=y |
| 213 | CONFIG_ARCH_TEGRA_132_SOC=y | ||
| 214 | CONFIG_ARCH_TEGRA_210_SOC=y | ||
| 215 | CONFIG_HISILICON_IRQ_MBIGEN=y | ||
| 206 | CONFIG_PHY_XGENE=y | 216 | CONFIG_PHY_XGENE=y |
| 207 | CONFIG_EXT2_FS=y | 217 | CONFIG_EXT2_FS=y |
| 208 | CONFIG_EXT3_FS=y | 218 | CONFIG_EXT3_FS=y |
| 209 | # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set | ||
| 210 | # CONFIG_EXT3_FS_XATTR is not set | ||
| 211 | CONFIG_EXT4_FS=y | ||
| 212 | CONFIG_FANOTIFY=y | 219 | CONFIG_FANOTIFY=y |
| 213 | CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y | 220 | CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y |
| 214 | CONFIG_QUOTA=y | 221 | CONFIG_QUOTA=y |
| @@ -239,6 +246,7 @@ CONFIG_LOCKUP_DETECTOR=y · 24 unmodified lines | |||
| 239 | # CONFIG_FTRACE is not set | 246 | # CONFIG_FTRACE is not set |
| 240 | CONFIG_MEMTEST=y | 247 | CONFIG_MEMTEST=y |
| 241 | CONFIG_SECURITY=y | 248 | CONFIG_SECURITY=y |
| 249 | CONFIG_CRYPTO_ECHAINIV=y | ||
| 242 | CONFIG_CRYPTO_ANSI_CPRNG=y | 250 | CONFIG_CRYPTO_ANSI_CPRNG=y |
| 243 | CONFIG_ARM64_CRYPTO=y | 251 | CONFIG_ARM64_CRYPTO=y |
| 244 | CONFIG_CRYPTO_SHA1_ARM64_CE=y | 252 | CONFIG_CRYPTO_SHA1_ARM64_CE=y |
| @@ -67,11 +67,11 @@ extern void __pgd_error(const char *file, int line, unsigned long val); · 66 unmodified lines | |||
| 67 | #define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) | 67 | #define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) |
| 68 | #define PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) | 68 | #define PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) |
| 69 | 69 | ||
| 70 | #define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) | 70 | #define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) |
| 71 | #define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE)) | 71 | #define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE)) |
| 72 | #define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL_NC)) | 72 | #define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC)) |
| 73 | #define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL_WT)) | 73 | #define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT)) |
| 74 | #define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL)) | 74 | #define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL)) |
| 75 | 75 | ||
| 76 | #define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE)) | 76 | #define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE)) |
| 77 | #define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL)) | 77 | #define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL)) |
| @@ -81,7 +81,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val); · 3 unmodified lines | |||
| 81 | 81 | ||
| 82 | #define PAGE_KERNEL __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE) | 82 | #define PAGE_KERNEL __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE) |
| 83 | #define PAGE_KERNEL_RO __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_RDONLY) | 83 | #define PAGE_KERNEL_RO __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_RDONLY) |
| 84 | #define PAGE_KERNEL_ROX __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY) | 84 | #define PAGE_KERNEL_ROX __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY) |
| 85 | #define PAGE_KERNEL_EXEC __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE) | 85 | #define PAGE_KERNEL_EXEC __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE) |
| 86 | #define PAGE_KERNEL_EXEC_CONT __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT) | 86 | #define PAGE_KERNEL_EXEC_CONT __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT) |
| 87 | 87 | ||
| @@ -153,6 +153,7 @@ extern struct page *empty_zero_page; · 65 unmodified lines | |||
| 153 | #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE)) | 153 | #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE)) |
| 154 | #define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) | 154 | #define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) |
| 155 | #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT)) | 155 | #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT)) |
| 156 | #define pte_user(pte) (!!(pte_val(pte) & PTE_USER)) | ||
| 156 | 157 | ||
| 157 | #ifdef CONFIG_ARM64_HW_AFDBM | 158 | #ifdef CONFIG_ARM64_HW_AFDBM |
| 158 | #define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY)) | 159 | #define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY)) |
| @@ -163,8 +164,6 @@ extern struct page *empty_zero_page; · 4 unmodified lines | |||
| 163 | #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte)) | 164 | #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte)) |
| 164 | 165 | ||
| 165 | #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID)) | 166 | #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID)) |
| 166 | #define pte_valid_user(pte) \ | ||
| 167 | ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) | ||
| 168 | #define pte_valid_not_user(pte) \ | 167 | #define pte_valid_not_user(pte) \ |
| 169 | ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID) | 168 | ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID) |
| 170 | #define pte_valid_young(pte) \ | 169 | #define pte_valid_young(pte) \ |
| @@ -278,13 +277,13 @@ extern void __sync_icache_dcache(pte_t pteval, unsigned long addr); · 107 unmodified lines | |||
| 278 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, | 277 | static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, |
| 279 | pte_t *ptep, pte_t pte) | 278 | pte_t *ptep, pte_t pte) |
| 280 | { | 279 | { |
| 281 | if (pte_valid_user(pte)) { | 280 | if (pte_valid(pte)) { |
| 282 | if (!pte_special(pte) && pte_exec(pte)) | ||
| 283 | __sync_icache_dcache(pte, addr); | ||
| 284 | if (pte_sw_dirty(pte) && pte_write(pte)) | 281 | if (pte_sw_dirty(pte) && pte_write(pte)) |
| 285 | pte_val(pte) &= ~PTE_RDONLY; | 282 | pte_val(pte) &= ~PTE_RDONLY; |
| 286 | else | 283 | else |
| 287 | pte_val(pte) |= PTE_RDONLY; | 284 | pte_val(pte) |= PTE_RDONLY; |
| 285 | if (pte_user(pte) && pte_exec(pte) && !pte_special(pte)) | ||
| 286 | __sync_icache_dcache(pte, addr); | ||
| 288 | } | 287 | } |
| 289 | 288 | ||
| 290 | /* | 289 | /* |
| @@ -514,9 +514,14 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems · 513 unmodified lines | |||
| 514 | #endif | 514 | #endif |
| 515 | 515 | ||
| 516 | /* EL2 debug */ | 516 | /* EL2 debug */ |
| 517 | mrs x0, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer | ||
| 518 | sbfx x0, x0, #8, #4 | ||
| 519 | cmp x0, #1 | ||
| 520 | b.lt 4f // Skip if no PMU present | ||
| 517 | mrs x0, pmcr_el0 // Disable debug access traps | 521 | mrs x0, pmcr_el0 // Disable debug access traps |
| 518 | ubfx x0, x0, #11, #5 // to EL2 and allow access to | 522 | ubfx x0, x0, #11, #5 // to EL2 and allow access to |
| 519 | msr mdcr_el2, x0 // all PMU counters from EL1 | 523 | msr mdcr_el2, x0 // all PMU counters from EL1 |
| 524 | 4: | ||
| 520 | 525 | ||
| 521 | /* Stage-2 translation */ | 526 | /* Stage-2 translation */ |
| 522 | msr vttbr_el2, xzr | 527 | msr vttbr_el2, xzr |
| @@ -64,6 +64,16 @@ · 63 unmodified lines | |||
| 64 | 64 | ||
| 65 | #ifdef CONFIG_EFI | 65 | #ifdef CONFIG_EFI |
| 66 | 66 | ||
| 67 | /* | ||
| 68 | * Prevent the symbol aliases below from being emitted into the kallsyms | ||
| 69 | * table, by forcing them to be absolute symbols (which are conveniently | ||
| 70 | * ignored by scripts/kallsyms) rather than section relative symbols. | ||
| 71 | * The distinction is only relevant for partial linking, and only for symbols | ||
| 72 | * that are defined within a section declaration (which is not the case for | ||
| 73 | * the definitions below) so the resulting values will be identical. | ||
| 74 | */ | ||
| 75 | #define KALLSYMS_HIDE(sym) ABSOLUTE(sym) | ||
| 76 | |||
| 67 | /* | 77 | /* |
| 68 | * The EFI stub has its own symbol namespace prefixed by __efistub_, to | 78 | * The EFI stub has its own symbol namespace prefixed by __efistub_, to |
| 69 | * isolate it from the kernel proper. The following symbols are legally | 79 | * isolate it from the kernel proper. The following symbols are legally |
| @@ -73,25 +83,25 @@ · 3 unmodified lines | |||
| 73 | * linked at. The routines below are all implemented in assembler in a | 83 | * linked at. The routines below are all implemented in assembler in a |
| 74 | * position independent manner | 84 | * position independent manner |
| 75 | */ | 85 | */ |
| 76 | __efistub_memcmp = __pi_memcmp; | 86 | __efistub_memcmp = KALLSYMS_HIDE(__pi_memcmp); |
| 77 | __efistub_memchr = __pi_memchr; | 87 | __efistub_memchr = KALLSYMS_HIDE(__pi_memchr); |
| 78 | __efistub_memcpy = __pi_memcpy; | 88 | __efistub_memcpy = KALLSYMS_HIDE(__pi_memcpy); |
| 79 | __efistub_memmove = __pi_memmove; | 89 | __efistub_memmove = KALLSYMS_HIDE(__pi_memmove); |
| 80 | __efistub_memset = __pi_memset; | 90 | __efistub_memset = KALLSYMS_HIDE(__pi_memset); |
| 81 | __efistub_strlen = __pi_strlen; | 91 | __efistub_strlen = KALLSYMS_HIDE(__pi_strlen); |
| 82 | __efistub_strcmp = __pi_strcmp; | 92 | __efistub_strcmp = KALLSYMS_HIDE(__pi_strcmp); |
| 83 | __efistub_strncmp = __pi_strncmp; | 93 | __efistub_strncmp = KALLSYMS_HIDE(__pi_strncmp); |
| 84 | __efistub___flush_dcache_area = __pi___flush_dcache_area; | 94 | __efistub___flush_dcache_area = KALLSYMS_HIDE(__pi___flush_dcache_area); |
| 85 | 95 | ||
| 86 | #ifdef CONFIG_KASAN | 96 | #ifdef CONFIG_KASAN |
| 87 | __efistub___memcpy = __pi_memcpy; | 97 | __efistub___memcpy = KALLSYMS_HIDE(__pi_memcpy); |
| 88 | __efistub___memmove = __pi_memmove; | 98 | __efistub___memmove = KALLSYMS_HIDE(__pi_memmove); |
| 89 | __efistub___memset = __pi_memset; | 99 | __efistub___memset = KALLSYMS_HIDE(__pi_memset); |
| 90 | #endif | 100 | #endif |
| 91 | 101 | ||
| 92 | __efistub__text = _text; | 102 | __efistub__text = KALLSYMS_HIDE(_text); |
| 93 | __efistub__end = _end; | 103 | __efistub__end = KALLSYMS_HIDE(_end); |
| 94 | __efistub__edata = _edata; | 104 | __efistub__edata = KALLSYMS_HIDE(_edata); |
| 95 | 105 | ||
| 96 | #endif | 106 | #endif |
| 97 | 107 | ||
| @@ -46,7 +46,7 @@ enum address_markers_idx { · 45 unmodified lines | |||
| 46 | PCI_START_NR, | 46 | PCI_START_NR, |
| 47 | PCI_END_NR, | 47 | PCI_END_NR, |
| 48 | MODULES_START_NR, | 48 | MODULES_START_NR, |
| 49 | MODUELS_END_NR, | 49 | MODULES_END_NR, |
| 50 | KERNEL_SPACE_NR, | 50 | KERNEL_SPACE_NR, |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| @@ -120,6 +120,7 @@ static void __init cpu_set_ttbr1(unsigned long ttbr1) · 119 unmodified lines | |||
| 120 | void __init kasan_init(void) | 120 | void __init kasan_init(void) |
| 121 | { | 121 | { |
| 122 | struct memblock_region *reg; | 122 | struct memblock_region *reg; |
| 123 | int i; | ||
| 123 | 124 | ||
| 124 | /* | 125 | /* |
| 125 | * We are going to perform proper setup of shadow memory. | 126 | * We are going to perform proper setup of shadow memory. |
| @@ -155,6 +156,14 @@ void __init kasan_init(void) · 29 unmodified lines | |||
| 155 | pfn_to_nid(virt_to_pfn(start))); | 156 | pfn_to_nid(virt_to_pfn(start))); |
| 156 | } | 157 | } |
| 157 | 158 | ||
| 159 | /* | ||
| 160 | * KAsan may reuse the contents of kasan_zero_pte directly, so we | ||
| 161 | * should make sure that it maps the zero page read-only. | ||
| 162 | */ | ||
| 163 | for (i = 0; i < PTRS_PER_PTE; i++) | ||
| 164 | set_pte(&kasan_zero_pte[i], | ||
| 165 | pfn_pte(virt_to_pfn(kasan_zero_page), PAGE_KERNEL_RO)); | ||
| 166 | |||
| 158 | memset(kasan_zero_page, 0, PAGE_SIZE); | 167 | memset(kasan_zero_page, 0, PAGE_SIZE); |
| 159 | cpu_set_ttbr1(__pa(swapper_pg_dir)); | 168 | cpu_set_ttbr1(__pa(swapper_pg_dir)); |
| 160 | flush_tlb_all(); | 169 | flush_tlb_all(); |
| @@ -57,6 +57,9 @@ static int change_memory_common(unsigned long addr, int numpages, · 56 unmodified lines | |||
| 57 | if (end < MODULES_VADDR || end >= MODULES_END) | 57 | if (end < MODULES_VADDR || end >= MODULES_END) |
| 58 | return -EINVAL; | 58 | return -EINVAL; |
| 59 | 59 | ||
| 60 | if (!numpages) | ||
| 61 | return 0; | ||
| 62 | |||
| 60 | data.set_mask = set_mask; | 63 | data.set_mask = set_mask; |
| 61 | data.clear_mask = clear_mask; | 64 | data.clear_mask = clear_mask; |
| 62 | 65 | ||
| @@ -84,3 +84,15 @@ · 83 unmodified lines | |||
| 84 | b.lo 9998b | 84 | b.lo 9998b |
| 85 | dsb \domain | 85 | dsb \domain |
| 86 | .endm | 86 | .endm |
| 87 | |||
| 88 | /* | ||
| 89 | * reset_pmuserenr_el0 - reset PMUSERENR_EL0 if PMUv3 present | ||
| 90 | */ | ||
| 91 | .macro reset_pmuserenr_el0, tmpreg | ||
| 92 | mrs \tmpreg, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer | ||
| 93 | sbfx \tmpreg, \tmpreg, #8, #4 | ||
| 94 | cmp \tmpreg, #1 // Skip if no PMU present | ||
| 95 | b.lt 9000f | ||
| 96 | msr pmuserenr_el0, xzr // Disable PMU access from EL0 | ||
| 97 | 9000: | ||
| 98 | .endm | ||
| @@ -117,7 +117,7 @@ ENTRY(cpu_do_resume) · 116 unmodified lines | |||
| 117 | */ | 117 | */ |
| 118 | ubfx x11, x11, #1, #1 | 118 | ubfx x11, x11, #1, #1 |
| 119 | msr oslar_el1, x11 | 119 | msr oslar_el1, x11 |
| 120 | msr pmuserenr_el0, xzr // Disable PMU access from EL0 | 120 | reset_pmuserenr_el0 x0 // Disable PMU access from EL0 |
| 121 | mov x0, x12 | 121 | mov x0, x12 |
| 122 | dsb nsh // Make sure local tlb invalidation completed | 122 | dsb nsh // Make sure local tlb invalidation completed |
| 123 | isb | 123 | isb |
| @@ -154,7 +154,7 @@ ENTRY(__cpu_setup) · 30 unmodified lines | |||
| 154 | msr cpacr_el1, x0 // Enable FP/ASIMD | 154 | msr cpacr_el1, x0 // Enable FP/ASIMD |
| 155 | mov x0, #1 << 12 // Reset mdscr_el1 and disable | 155 | mov x0, #1 << 12 // Reset mdscr_el1 and disable |
| 156 | msr mdscr_el1, x0 // access to the DCC from EL0 | 156 | msr mdscr_el1, x0 // access to the DCC from EL0 |
| 157 | msr pmuserenr_el0, xzr // Disable PMU access from EL0 | 157 | reset_pmuserenr_el0 x0 // Disable PMU access from EL0 |
| 158 | /* | 158 | /* |
| 159 | * Memory region attributes for LPAE: | 159 | * Memory region attributes for LPAE: |
| 160 | * | 160 | * |
| @@ -19,6 +19,8 @@ · 18 unmodified lines | |||
| 19 | 19 | ||
| 20 | #include <bcm63xx_nvram.h> | 20 | #include <bcm63xx_nvram.h> |
| 21 | 21 | ||
| 22 | #define BCM63XX_DEFAULT_PSI_SIZE 64 | ||
| 23 | |||
| 22 | static struct bcm963xx_nvram nvram; | 24 | static struct bcm963xx_nvram nvram; |
| 23 | static int mac_addr_used; | 25 | static int mac_addr_used; |
| 24 | 26 | ||
| @@ -85,3 +87,12 @@ int bcm63xx_nvram_get_mac_address(u8 *mac) · 60 unmodified lines | |||
| 85 | return 0; | 87 | return 0; |
| 86 | } | 88 | } |
| 87 | EXPORT_SYMBOL(bcm63xx_nvram_get_mac_address); | 89 | EXPORT_SYMBOL(bcm63xx_nvram_get_mac_address); |
| 90 | |||
| 91 | int bcm63xx_nvram_get_psi_size(void) | ||
| 92 | { | ||
| 93 | if (nvram.psi_size > 0) | ||
| 94 | return nvram.psi_size; | ||
| 95 | |||
| 96 | return BCM63XX_DEFAULT_PSI_SIZE; | ||
| 97 | } | ||
| 98 | EXPORT_SYMBOL(bcm63xx_nvram_get_psi_size); | ||
| @@ -30,4 +30,6 @@ u8 *bcm63xx_nvram_get_name(void); · 29 unmodified lines | |||
| 30 | */ | 30 | */ |
| 31 | int bcm63xx_nvram_get_mac_address(u8 *mac); | 31 | int bcm63xx_nvram_get_mac_address(u8 *mac); |
| 32 | 32 | ||
| 33 | int bcm63xx_nvram_get_psi_size(void); | ||
| 34 | |||
| 33 | #endif /* BCM63XX_NVRAM_H */ | 35 | #endif /* BCM63XX_NVRAM_H */ |
| @@ -50,7 +50,9 @@ · 49 unmodified lines | |||
| 50 | * set of bits not changed in pmd_modify. | 50 | * set of bits not changed in pmd_modify. |
| 51 | */ | 51 | */ |
| 52 | #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ | 52 | #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ |
| 53 | _PAGE_ACCESSED | _PAGE_THP_HUGE) | 53 | _PAGE_ACCESSED | _PAGE_THP_HUGE | _PAGE_PTE | \ |
| 54 | _PAGE_SOFT_DIRTY) | ||
| 55 | |||
| 54 | 56 | ||
| 55 | #ifdef CONFIG_PPC_64K_PAGES | 57 | #ifdef CONFIG_PPC_64K_PAGES |
| 56 | #include <asm/book3s/64/hash-64k.h> | 58 | #include <asm/book3s/64/hash-64k.h> |
| @@ -223,7 +223,6 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd) · 222 unmodified lines | |||
| 223 | #define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd)) | 223 | #define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd)) |
| 224 | #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd)) | 224 | #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd)) |
| 225 | #define pmd_young(pmd) pte_young(pmd_pte(pmd)) | 225 | #define pmd_young(pmd) pte_young(pmd_pte(pmd)) |
| 226 | #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd)) | ||
| 227 | #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd))) | 226 | #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd))) |
| 228 | #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd))) | 227 | #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd))) |
| 229 | #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd))) | 228 | #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd))) |
| @@ -38,8 +38,7 @@ · 37 unmodified lines | |||
| 38 | 38 | ||
| 39 | #define KVM_MAX_VCPUS NR_CPUS | 39 | #define KVM_MAX_VCPUS NR_CPUS |
| 40 | #define KVM_MAX_VCORES NR_CPUS | 40 | #define KVM_MAX_VCORES NR_CPUS |
| 41 | #define KVM_USER_MEM_SLOTS 32 | 41 | #define KVM_USER_MEM_SLOTS 512 |
| 42 | #define KVM_MEM_SLOTS_NUM KVM_USER_MEM_SLOTS | ||
| 43 | 42 | ||
| 44 | #ifdef CONFIG_KVM_MMIO | 43 | #ifdef CONFIG_KVM_MMIO |
| 45 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 | 44 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 |
| @@ -383,3 +383,4 @@ SYSCALL(ni_syscall) · 382 unmodified lines | |||
| 383 | SYSCALL(ni_syscall) | 383 | SYSCALL(ni_syscall) |
| 384 | SYSCALL(ni_syscall) | 384 | SYSCALL(ni_syscall) |
| 385 | SYSCALL(mlock2) | 385 | SYSCALL(mlock2) |
| 386 | SYSCALL(copy_file_range) | ||
| @@ -12,7 +12,7 @@ · 11 unmodified lines | |||
| 12 | #include <uapi/asm/unistd.h> | 12 | #include <uapi/asm/unistd.h> |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | #define NR_syscalls 379 | 15 | #define NR_syscalls 380 |
| 16 | 16 | ||
| 17 | #define __NR__exit __NR_exit | 17 | #define __NR__exit __NR_exit |
| 18 | 18 | ||
| @@ -389,5 +389,6 @@ · 388 unmodified lines | |||
| 389 | #define __NR_userfaultfd 364 | 389 | #define __NR_userfaultfd 364 |
| 390 | #define __NR_membarrier 365 | 390 | #define __NR_membarrier 365 |
| 391 | #define __NR_mlock2 378 | 391 | #define __NR_mlock2 378 |
| 392 | #define __NR_copy_file_range 379 | ||
| 392 | 393 | ||
| 393 | #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ | 394 | #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ |
| @@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe) · 882 unmodified lines | |||
| 883 | const char *eeh_pe_loc_get(struct eeh_pe *pe) | 883 | const char *eeh_pe_loc_get(struct eeh_pe *pe) |
| 884 | { | 884 | { |
| 885 | struct pci_bus *bus = eeh_pe_bus_get(pe); | 885 | struct pci_bus *bus = eeh_pe_bus_get(pe); |
| 886 | struct device_node *dn = pci_bus_to_OF_node(bus); | 886 | struct device_node *dn; |
| 887 | const char *loc = NULL; | 887 | const char *loc = NULL; |
| 888 | 888 | ||
| 889 | if (!dn) | 889 | while (bus) { |
| 890 | goto out; | 890 | dn = pci_bus_to_OF_node(bus); |
| 891 | if (!dn) { | ||
| 892 | bus = bus->parent; | ||
| 893 | continue; | ||
| 894 | } | ||
| 891 | 895 | ||
| 892 | /* PHB PE or root PE ? */ | 896 | if (pci_is_root_bus(bus)) |
| 893 | if (pci_is_root_bus(bus)) { | ||
| 894 | loc = of_get_property(dn, "ibm,loc-code", NULL); | ||
| 895 | if (!loc) | ||
| 896 | loc = of_get_property(dn, "ibm,io-base-loc-code", NULL); | 897 | loc = of_get_property(dn, "ibm,io-base-loc-code", NULL); |
| 898 | else | ||
| 899 | loc = of_get_property(dn, "ibm,slot-location-code", | ||
| 900 | NULL); | ||
| 901 | |||
| 897 | if (loc) | 902 | if (loc) |
| 898 | goto out; | 903 | return loc; |
| 899 | 904 | ||
| 900 | /* Check the root port */ | 905 | bus = bus->parent; |
| 901 | dn = dn->child; | ||
| 902 | if (!dn) | ||
| 903 | goto out; | ||
| 904 | } | 906 | } |
| 905 | 907 | ||
| 906 | loc = of_get_property(dn, "ibm,loc-code", NULL); | 908 | return "N/A"; |
| 907 | if (!loc) | ||
| 908 | loc = of_get_property(dn, "ibm,slot-location-code", NULL); | ||
| 909 | |||
| 910 | out: | ||
| 911 | return loc ? loc : "N/A"; | ||
| 912 | } | 909 | } |
| 913 | 910 | ||
| 914 | /** | 911 | /** |
| @@ -701,31 +701,3 @@ _GLOBAL(kexec_sequence) · 700 unmodified lines | |||
| 701 | li r5,0 | 701 | li r5,0 |
| 702 | blr /* image->start(physid, image->start, 0); */ | 702 | blr /* image->start(physid, image->start, 0); */ |
| 703 | #endif /* CONFIG_KEXEC */ | 703 | #endif /* CONFIG_KEXEC */ |
| 704 | |||
| 705 | #ifdef CONFIG_MODULES | ||
| 706 | #if defined(_CALL_ELF) && _CALL_ELF == 2 | ||
| 707 | |||
| 708 | #ifdef CONFIG_MODVERSIONS | ||
| 709 | .weak __crc_TOC. | ||
| 710 | .section "___kcrctab+TOC.","a" | ||
| 711 | .globl __kcrctab_TOC. | ||
| 712 | __kcrctab_TOC.: | ||
| 713 | .llong __crc_TOC. | ||
| 714 | #endif | ||
| 715 | |||
| 716 | /* | ||
| 717 | * Export a fake .TOC. since both modpost and depmod will complain otherwise. | ||
| 718 | * Both modpost and depmod strip the leading . so we do the same here. | ||
| 719 | */ | ||
| 720 | .section "__ksymtab_strings","a" | ||
| 721 | __kstrtab_TOC.: | ||
| 722 | .asciz "TOC." | ||
| 723 | |||
| 724 | .section "___ksymtab+TOC.","a" | ||
| 725 | /* This symbol name is important: it's used by modpost to find exported syms */ | ||
| 726 | .globl __ksymtab_TOC. | ||
| 727 | __ksymtab_TOC.: | ||
| 728 | .llong 0 /* .value */ | ||
| 729 | .llong __kstrtab_TOC. | ||
| 730 | #endif /* ELFv2 */ | ||
| 731 | #endif /* MODULES */ | ||
| @@ -326,7 +326,10 @@ static void dedotify_versions(struct modversion_info *vers, · 325 unmodified lines | |||
| 326 | } | 326 | } |
| 327 | } | 327 | } |
| 328 | 328 | ||
| 329 | /* Undefined symbols which refer to .funcname, hack to funcname (or .TOC.) */ | 329 | /* |
| 330 | * Undefined symbols which refer to .funcname, hack to funcname. Make .TOC. | ||
| 331 | * seem to be defined (value set later). | ||
| 332 | */ | ||
| 330 | static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab) | 333 | static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab) |
| 331 | { | 334 | { |
| 332 | unsigned int i; | 335 | unsigned int i; |
| @@ -334,8 +337,11 @@ static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab) · 1 unmodified line | |||
| 334 | for (i = 1; i < numsyms; i++) { | 337 | for (i = 1; i < numsyms; i++) { |
| 335 | if (syms[i].st_shndx == SHN_UNDEF) { | 338 | if (syms[i].st_shndx == SHN_UNDEF) { |
| 336 | char *name = strtab + syms[i].st_name; | 339 | char *name = strtab + syms[i].st_name; |
| 337 | if (name[0] == '.') | 340 | if (name[0] == '.') { |
| 341 | if (strcmp(name+1, "TOC.") == 0) | ||
| 342 | syms[i].st_shndx = SHN_ABS; | ||
| 338 | memmove(name, name+1, strlen(name)); | 343 | memmove(name, name+1, strlen(name)); |
| 344 | } | ||
| 339 | } | 345 | } |
| 340 | } | 346 | } |
| 341 | } | 347 | } |
| @@ -351,7 +357,7 @@ static Elf64_Sym *find_dot_toc(Elf64_Shdr *sechdrs, · 9 unmodified lines | |||
| 351 | numsyms = sechdrs[symindex].sh_size / sizeof(Elf64_Sym); | 357 | numsyms = sechdrs[symindex].sh_size / sizeof(Elf64_Sym); |
| 352 | 358 | ||
| 353 | for (i = 1; i < numsyms; i++) { | 359 | for (i = 1; i < numsyms; i++) { |
| 354 | if (syms[i].st_shndx == SHN_UNDEF | 360 | if (syms[i].st_shndx == SHN_ABS |
| 355 | && strcmp(strtab + syms[i].st_name, "TOC.") == 0) | 361 | && strcmp(strtab + syms[i].st_name, "TOC.") == 0) |
| 356 | return &syms[i]; | 362 | return &syms[i]; |
| 357 | } | 363 | } |
| @@ -377,15 +377,12 @@ no_seg_found: · 376 unmodified lines | |||
| 377 | 377 | ||
| 378 | static void kvmppc_mmu_book3s_64_slbmte(struct kvm_vcpu *vcpu, u64 rs, u64 rb) | 378 | static void kvmppc_mmu_book3s_64_slbmte(struct kvm_vcpu *vcpu, u64 rs, u64 rb) |
| 379 | { | 379 | { |
| 380 | struct kvmppc_vcpu_book3s *vcpu_book3s; | ||
| 381 | u64 esid, esid_1t; | 380 | u64 esid, esid_1t; |
| 382 | int slb_nr; | 381 | int slb_nr; |
| 383 | struct kvmppc_slb *slbe; | 382 | struct kvmppc_slb *slbe; |
| 384 | 383 | ||
| 385 | dprintk("KVM MMU: slbmte(0x%llx, 0x%llx)\n", rs, rb); | 384 | dprintk("KVM MMU: slbmte(0x%llx, 0x%llx)\n", rs, rb); |
| 386 | 385 | ||
| 387 | vcpu_book3s = to_book3s(vcpu); | ||
| 388 | |||
| 389 | esid = GET_ESID(rb); | 386 | esid = GET_ESID(rb); |
| 390 | esid_1t = GET_ESID_1T(rb); | 387 | esid_1t = GET_ESID_1T(rb); |
| 391 | slb_nr = rb & 0xfff; | 388 | slb_nr = rb & 0xfff; |
| @@ -833,6 +833,24 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu, · 832 unmodified lines | |||
| 833 | 833 | ||
| 834 | vcpu->stat.sum_exits++; | 834 | vcpu->stat.sum_exits++; |
| 835 | 835 | ||
| 836 | /* | ||
| 837 | * This can happen if an interrupt occurs in the last stages | ||
| 838 | * of guest entry or the first stages of guest exit (i.e. after | ||
| 839 | * setting paca->kvm_hstate.in_guest to KVM_GUEST_MODE_GUEST_HV | ||
| 840 | * and before setting it to KVM_GUEST_MODE_HOST_HV). | ||
| 841 | * That can happen due to a bug, or due to a machine check | ||
| 842 | * occurring at just the wrong time. | ||
| 843 | */ | ||
| 844 | if (vcpu->arch.shregs.msr & MSR_HV) { | ||
| 845 | printk(KERN_EMERG "KVM trap in HV mode!\n"); | ||
| 846 | printk(KERN_EMERG "trap=0x%x | pc=0x%lx | msr=0x%llx\n", | ||
| 847 | vcpu->arch.trap, kvmppc_get_pc(vcpu), | ||
| 848 | vcpu->arch.shregs.msr); | ||
| 849 | kvmppc_dump_regs(vcpu); | ||
| 850 | run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | ||
| 851 | run->hw.hardware_exit_reason = vcpu->arch.trap; | ||
| 852 | return RESUME_HOST; | ||
| 853 | } | ||
| 836 | run->exit_reason = KVM_EXIT_UNKNOWN; | 854 | run->exit_reason = KVM_EXIT_UNKNOWN; |
| 837 | run->ready_for_interrupt_injection = 1; | 855 | run->ready_for_interrupt_injection = 1; |
| 838 | switch (vcpu->arch.trap) { | 856 | switch (vcpu->arch.trap) { |
| @@ -2153,7 +2153,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) · 2152 unmodified lines | |||
| 2153 | 2153 | ||
| 2154 | /* Emulate H_SET_DABR/X on P8 for the sake of compat mode guests */ | 2154 | /* Emulate H_SET_DABR/X on P8 for the sake of compat mode guests */ |
| 2155 | 2: rlwimi r5, r4, 5, DAWRX_DR | DAWRX_DW | 2155 | 2: rlwimi r5, r4, 5, DAWRX_DR | DAWRX_DW |
| 2156 | rlwimi r5, r4, 1, DAWRX_WT | 2156 | rlwimi r5, r4, 2, DAWRX_WT |
| 2157 | clrrdi r4, r4, 3 | 2157 | clrrdi r4, r4, 3 |
| 2158 | std r4, VCPU_DAWR(r3) | 2158 | std r4, VCPU_DAWR(r3) |
| 2159 | std r5, VCPU_DAWRX(r3) | 2159 | std r5, VCPU_DAWRX(r3) |
| @@ -2404,6 +2404,8 @@ machine_check_realmode: · 244 unmodified lines | |||
| 2404 | * guest as machine check causing guest to crash. | 2404 | * guest as machine check causing guest to crash. |
| 2405 | */ | 2405 | */ |
| 2406 | ld r11, VCPU_MSR(r9) | 2406 | ld r11, VCPU_MSR(r9) |
| 2407 | rldicl. r0, r11, 64-MSR_HV_LG, 63 /* check if it happened in HV mode */ | ||
| 2408 | bne mc_cont /* if so, exit to host */ | ||
| 2407 | andi. r10, r11, MSR_RI /* check for unrecoverable exception */ | 2409 | andi. r10, r11, MSR_RI /* check for unrecoverable exception */ |
| 2408 | beq 1f /* Deliver a machine check to guest */ | 2410 | beq 1f /* Deliver a machine check to guest */ |
| 2409 | ld r10, VCPU_PC(r9) | 2411 | ld r10, VCPU_PC(r9) |
| @@ -919,21 +919,17 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) · 918 unmodified lines | |||
| 919 | r = -ENXIO; | 919 | r = -ENXIO; |
| 920 | break; | 920 | break; |
| 921 | } | 921 | } |
| 922 | vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval; | 922 | val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0]; |
| 923 | break; | 923 | break; |
| 924 | case KVM_REG_PPC_VSCR: | 924 | case KVM_REG_PPC_VSCR: |
| 925 | if (!cpu_has_feature(CPU_FTR_ALTIVEC)) { | 925 | if (!cpu_has_feature(CPU_FTR_ALTIVEC)) { |
| 926 | r = -ENXIO; | 926 | r = -ENXIO; |
| 927 | break; | 927 | break; |
| 928 | } | 928 | } |
| 929 | vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val); | 929 | val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]); |
| 930 | break; | 930 | break; |
| 931 | case KVM_REG_PPC_VRSAVE: | 931 | case KVM_REG_PPC_VRSAVE: |
| 932 | if (!cpu_has_feature(CPU_FTR_ALTIVEC)) { | 932 | val = get_reg_val(reg->id, vcpu->arch.vrsave); |
| 933 | r = -ENXIO; | ||
| 934 | break; | ||
| 935 | } | ||
| 936 | vcpu->arch.vrsave = set_reg_val(reg->id, val); | ||
| 937 | break; | 933 | break; |
| 938 | #endif /* CONFIG_ALTIVEC */ | 934 | #endif /* CONFIG_ALTIVEC */ |
| 939 | default: | 935 | default: |
| @@ -974,17 +970,21 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) · 34 unmodified lines | |||
| 974 | r = -ENXIO; | 970 | r = -ENXIO; |
| 975 | break; | 971 | break; |
| 976 | } | 972 | } |
| 977 | val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0]; | 973 | vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval; |
| 978 | break; | 974 | break; |
| 979 | case KVM_REG_PPC_VSCR: | 975 | case KVM_REG_PPC_VSCR: |
| 980 | if (!cpu_has_feature(CPU_FTR_ALTIVEC)) { | 976 | if (!cpu_has_feature(CPU_FTR_ALTIVEC)) { |
| 981 | r = -ENXIO; | 977 | r = -ENXIO; |
| 982 | break; | 978 | break; |
| 983 | } | 979 | } |
| 984 | val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]); | 980 | vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val); |
| 985 | break; | 981 | break; |
| 986 | case KVM_REG_PPC_VRSAVE: | 982 | case KVM_REG_PPC_VRSAVE: |
| 987 | val = get_reg_val(reg->id, vcpu->arch.vrsave); | 983 | if (!cpu_has_feature(CPU_FTR_ALTIVEC)) { |
| 984 | r = -ENXIO; | ||
| 985 | break; | ||
| 986 | } | ||
| 987 | vcpu->arch.vrsave = set_reg_val(reg->id, val); | ||
| 988 | break; | 988 | break; |
| 989 | #endif /* CONFIG_ALTIVEC */ | 989 | #endif /* CONFIG_ALTIVEC */ |
| 990 | default: | 990 | default: |
| @@ -560,12 +560,12 @@ subsys_initcall(add_system_ram_resources); · 559 unmodified lines | |||
| 560 | */ | 560 | */ |
| 561 | int devmem_is_allowed(unsigned long pfn) | 561 | int devmem_is_allowed(unsigned long pfn) |
| 562 | { | 562 | { |
| 563 | if (page_is_rtas_user_buf(pfn)) | ||
| 564 | return 1; | ||
| 563 | if (iomem_is_exclusive(PFN_PHYS(pfn))) | 565 | if (iomem_is_exclusive(PFN_PHYS(pfn))) |
| 564 | return 0; | 566 | return 0; |
| 565 | if (!page_is_ram(pfn)) | 567 | if (!page_is_ram(pfn)) |
| 566 | return 1; | 568 | return 1; |
| 567 | if (page_is_rtas_user_buf(pfn)) | ||
| 568 | return 1; | ||
| 569 | return 0; | 569 | return 0; |
| 570 | } | 570 | } |
| 571 | #endif /* CONFIG_STRICT_DEVMEM */ | 571 | #endif /* CONFIG_STRICT_DEVMEM */ |
| @@ -816,7 +816,7 @@ static struct power_pmu power8_pmu = { · 815 unmodified lines | |||
| 816 | .get_constraint = power8_get_constraint, | 816 | .get_constraint = power8_get_constraint, |
| 817 | .get_alternatives = power8_get_alternatives, | 817 | .get_alternatives = power8_get_alternatives, |
| 818 | .disable_pmc = power8_disable_pmc, | 818 | .disable_pmc = power8_disable_pmc, |
| 819 | .flags = PPMU_HAS_SSLOT | PPMU_HAS_SIER | PPMU_ARCH_207S, | 819 | .flags = PPMU_HAS_SIER | PPMU_ARCH_207S, |
| 820 | .n_generic = ARRAY_SIZE(power8_generic_events), | 820 | .n_generic = ARRAY_SIZE(power8_generic_events), |
| 821 | .generic_events = power8_generic_events, | 821 | .generic_events = power8_generic_events, |
| 822 | .cache_events = &power8_cache_events, | 822 | .cache_events = &power8_cache_events, |
| @@ -8,6 +8,8 @@ · 7 unmodified lines | |||
| 8 | 8 | ||
| 9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 10 | 10 | ||
| 11 | #define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8)) | ||
| 12 | |||
| 11 | /* store then OR system mask. */ | 13 | /* store then OR system mask. */ |
| 12 | #define __arch_local_irq_stosm(__or) \ | 14 | #define __arch_local_irq_stosm(__or) \ |
| 13 | ({ \ | 15 | ({ \ |
| @@ -54,14 +56,17 @@ static inline notrace void arch_local_irq_enable(void) · 40 unmodified lines | |||
| 54 | __arch_local_irq_stosm(0x03); | 56 | __arch_local_irq_stosm(0x03); |
| 55 | } | 57 | } |
| 56 | 58 | ||
| 59 | /* This only restores external and I/O interrupt state */ | ||
| 57 | static inline notrace void arch_local_irq_restore(unsigned long flags) | 60 | static inline notrace void arch_local_irq_restore(unsigned long flags) |
| 58 | { | 61 | { |
| 59 | __arch_local_irq_ssm(flags); | 62 | /* only disabled->disabled and disabled->enabled is valid */ |
| 63 | if (flags & ARCH_IRQ_ENABLED) | ||
| 64 | arch_local_irq_enable(); | ||
| 60 | } | 65 | } |
| 61 | 66 | ||
| 62 | static inline notrace bool arch_irqs_disabled_flags(unsigned long flags) | 67 | static inline notrace bool arch_irqs_disabled_flags(unsigned long flags) |
| 63 | { | 68 | { |
| 64 | return !(flags & (3UL << (BITS_PER_LONG - 8))); | 69 | return !(flags & ARCH_IRQ_ENABLED); |
| 65 | } | 70 | } |
| 66 | 71 | ||
| 67 | static inline notrace bool arch_irqs_disabled(void) | 72 | static inline notrace bool arch_irqs_disabled(void) |
| @@ -546,7 +546,6 @@ struct kvm_vcpu_arch { · 545 unmodified lines | |||
| 546 | struct kvm_s390_sie_block *sie_block; | 546 | struct kvm_s390_sie_block *sie_block; |
| 547 | unsigned int host_acrs[NUM_ACRS]; | 547 | unsigned int host_acrs[NUM_ACRS]; |
| 548 | struct fpu host_fpregs; | 548 | struct fpu host_fpregs; |
| 549 | struct fpu guest_fpregs; | ||
| 550 | struct kvm_s390_local_interrupt local_int; | 549 | struct kvm_s390_local_interrupt local_int; |
| 551 | struct hrtimer ckc_timer; | 550 | struct hrtimer ckc_timer; |
| 552 | struct kvm_s390_pgm_info pgm; | 551 | struct kvm_s390_pgm_info pgm; |
| @@ -8,10 +8,13 @@ · 7 unmodified lines | |||
| 8 | #include <asm/pci_insn.h> | 8 | #include <asm/pci_insn.h> |
| 9 | 9 | ||
| 10 | /* I/O Map */ | 10 | /* I/O Map */ |
| 11 | #define ZPCI_IOMAP_MAX_ENTRIES 0x7fff | 11 | #define ZPCI_IOMAP_SHIFT 48 |
| 12 | #define ZPCI_IOMAP_ADDR_BASE 0x8000000000000000ULL | 12 | #define ZPCI_IOMAP_ADDR_BASE 0x8000000000000000UL |
| 13 | #define ZPCI_IOMAP_ADDR_IDX_MASK 0x7fff000000000000ULL | 13 | #define ZPCI_IOMAP_ADDR_OFF_MASK ((1UL << ZPCI_IOMAP_SHIFT) - 1) |
| 14 | #define ZPCI_IOMAP_ADDR_OFF_MASK 0x0000ffffffffffffULL | 14 | #define ZPCI_IOMAP_MAX_ENTRIES \ |
| 15 | ((ULONG_MAX - ZPCI_IOMAP_ADDR_BASE + 1) / (1UL << ZPCI_IOMAP_SHIFT)) | ||
| 16 | #define ZPCI_IOMAP_ADDR_IDX_MASK \ | ||
| 17 | (~ZPCI_IOMAP_ADDR_OFF_MASK - ZPCI_IOMAP_ADDR_BASE) | ||
| 15 | 18 | ||
| 16 | struct zpci_iomap_entry { | 19 | struct zpci_iomap_entry { |
| 17 | u32 fh; | 20 | u32 fh; |
| @@ -21,8 +24,9 @@ struct zpci_iomap_entry { · 3 unmodified lines | |||
| 21 | 24 | ||
| 22 | extern struct zpci_iomap_entry *zpci_iomap_start; | 25 | extern struct zpci_iomap_entry *zpci_iomap_start; |
| 23 | 26 | ||
| 27 | #define ZPCI_ADDR(idx) (ZPCI_IOMAP_ADDR_BASE | ((u64) idx << ZPCI_IOMAP_SHIFT)) | ||
| 24 | #define ZPCI_IDX(addr) \ | 28 | #define ZPCI_IDX(addr) \ |
| 25 | (((__force u64) addr & ZPCI_IOMAP_ADDR_IDX_MASK) >> 48) | 29 | (((__force u64) addr & ZPCI_IOMAP_ADDR_IDX_MASK) >> ZPCI_IOMAP_SHIFT) |
| 26 | #define ZPCI_OFFSET(addr) \ | 30 | #define ZPCI_OFFSET(addr) \ |
| 27 | ((__force u64) addr & ZPCI_IOMAP_ADDR_OFF_MASK) | 31 | ((__force u64) addr & ZPCI_IOMAP_ADDR_OFF_MASK) |
| 28 | 32 | ||
| @@ -166,14 +166,14 @@ extern __vector128 init_task_fpu_regs[__NUM_VXRS]; · 165 unmodified lines | |||
| 166 | */ | 166 | */ |
| 167 | #define start_thread(regs, new_psw, new_stackp) do { \ | 167 | #define start_thread(regs, new_psw, new_stackp) do { \ |
| 168 | regs->psw.mask = PSW_USER_BITS | PSW_MASK_EA | PSW_MASK_BA; \ | 168 | regs->psw.mask = PSW_USER_BITS | PSW_MASK_EA | PSW_MASK_BA; \ |
| 169 | regs->psw.addr = new_psw | PSW_ADDR_AMODE; \ | 169 | regs->psw.addr = new_psw; \ |
| 170 | regs->gprs[15] = new_stackp; \ | 170 | regs->gprs[15] = new_stackp; \ |
| 171 | execve_tail(); \ | 171 | execve_tail(); \ |
| 172 | } while (0) | 172 | } while (0) |
| 173 | 173 | ||
| 174 | #define start_thread31(regs, new_psw, new_stackp) do { \ | 174 | #define start_thread31(regs, new_psw, new_stackp) do { \ |
| 175 | regs->psw.mask = PSW_USER_BITS | PSW_MASK_BA; \ | 175 | regs->psw.mask = PSW_USER_BITS | PSW_MASK_BA; \ |
| 176 | regs->psw.addr = new_psw | PSW_ADDR_AMODE; \ | 176 | regs->psw.addr = new_psw; \ |
| 177 | regs->gprs[15] = new_stackp; \ | 177 | regs->gprs[15] = new_stackp; \ |
| 178 | crst_table_downgrade(current->mm, 1UL << 31); \ | 178 | crst_table_downgrade(current->mm, 1UL << 31); \ |
| 179 | execve_tail(); \ | 179 | execve_tail(); \ |
| @@ -149,7 +149,7 @@ static inline int test_pt_regs_flag(struct pt_regs *regs, int flag) · 148 unmodified lines | |||
| 149 | #define arch_has_block_step() (1) | 149 | #define arch_has_block_step() (1) |
| 150 | 150 | ||
| 151 | #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) | 151 | #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) |
| 152 | #define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN) | 152 | #define instruction_pointer(regs) ((regs)->psw.addr) |
| 153 | #define user_stack_pointer(regs)((regs)->gprs[15]) | 153 | #define user_stack_pointer(regs)((regs)->gprs[15]) |
| 154 | #define profile_pc(regs) instruction_pointer(regs) | 154 | #define profile_pc(regs) instruction_pointer(regs) |
| 155 | 155 | ||
| @@ -161,7 +161,7 @@ static inline long regs_return_value(struct pt_regs *regs) · 5 unmodified lines | |||
| 161 | static inline void instruction_pointer_set(struct pt_regs *regs, | 161 | static inline void instruction_pointer_set(struct pt_regs *regs, |
| 162 | unsigned long val) | 162 | unsigned long val) |
| 163 | { | 163 | { |
| 164 | regs->psw.addr = val | PSW_ADDR_AMODE; | 164 | regs->psw.addr = val; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | int regs_query_register_offset(const char *name); | 167 | int regs_query_register_offset(const char *name); |
| @@ -171,7 +171,7 @@ unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n); · 3 unmodified lines | |||
| 171 | 171 | ||
| 172 | static inline unsigned long kernel_stack_pointer(struct pt_regs *regs) | 172 | static inline unsigned long kernel_stack_pointer(struct pt_regs *regs) |
| 173 | { | 173 | { |
| 174 | return regs->gprs[15] & PSW_ADDR_INSN; | 174 | return regs->gprs[15]; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | #endif /* __ASSEMBLY__ */ | 177 | #endif /* __ASSEMBLY__ */ |
| @@ -310,7 +310,8 @@ · 309 unmodified lines | |||
| 310 | #define __NR_recvmsg 372 | 310 | #define __NR_recvmsg 372 |
| 311 | #define __NR_shutdown 373 | 311 | #define __NR_shutdown 373 |
| 312 | #define __NR_mlock2 374 | 312 | #define __NR_mlock2 374 |
| 313 | #define NR_syscalls 375 | 313 | #define __NR_copy_file_range 375 |
| 314 | #define NR_syscalls 376 | ||
| 314 | 315 | ||
| 315 | /* | 316 | /* |
| 316 | * There are some system calls that are not present on 64 bit, some | 317 | * There are some system calls that are not present on 64 bit, some |
| @@ -177,3 +177,4 @@ COMPAT_SYSCALL_WRAP3(getsockname, int, fd, struct sockaddr __user *, usockaddr, · 176 unmodified lines | |||
| 177 | COMPAT_SYSCALL_WRAP3(getpeername, int, fd, struct sockaddr __user *, usockaddr, int __user *, usockaddr_len); | 177 | COMPAT_SYSCALL_WRAP3(getpeername, int, fd, struct sockaddr __user *, usockaddr, int __user *, usockaddr_len); |
| 178 | COMPAT_SYSCALL_WRAP6(sendto, int, fd, void __user *, buff, size_t, len, unsigned int, flags, struct sockaddr __user *, addr, int, addr_len); | 178 | COMPAT_SYSCALL_WRAP6(sendto, int, fd, void __user *, buff, size_t, len, unsigned int, flags, struct sockaddr __user *, addr, int, addr_len); |
| 179 | COMPAT_SYSCALL_WRAP3(mlock2, unsigned long, start, size_t, len, int, flags); | 179 | COMPAT_SYSCALL_WRAP3(mlock2, unsigned long, start, size_t, len, int, flags); |
| 180 | COMPAT_SYSCALL_WRAP6(copy_file_range, int, fd_in, loff_t __user *, off_in, int, fd_out, loff_t __user *, off_out, size_t, len, unsigned int, flags); | ||
| @@ -59,8 +59,6 @@ struct save_area * __init save_area_alloc(bool is_boot_cpu) · 58 unmodified lines | |||
| 59 | struct save_area *sa; | 59 | struct save_area *sa; |
| 60 | 60 | ||
| 61 | sa = (void *) memblock_alloc(sizeof(*sa), 8); | 61 | sa = (void *) memblock_alloc(sizeof(*sa), 8); |
| 62 | if (!sa) | ||
| 63 | return NULL; | ||
| 64 | if (is_boot_cpu) | 62 | if (is_boot_cpu) |
| 65 | list_add(&sa->list, &dump_save_areas); | 63 | list_add(&sa->list, &dump_save_areas); |
| 66 | else | 64 | else |
| @@ -1470,7 +1470,7 @@ debug_dflt_header_fn(debug_info_t * id, struct debug_view *view, · 1469 unmodified lines | |||
| 1470 | except_str = "*"; | 1470 | except_str = "*"; |
| 1471 | else | 1471 | else |
| 1472 | except_str = "-"; | 1472 | except_str = "-"; |
| 1473 | caller = ((unsigned long) entry->caller) & PSW_ADDR_INSN; | 1473 | caller = (unsigned long) entry->caller; |
| 1474 | rc += sprintf(out_buf, "%02i %011lld:%06lu %1u %1s %02i %p ", | 1474 | rc += sprintf(out_buf, "%02i %011lld:%06lu %1u %1s %02i %p ", |
| 1475 | area, (long long)time_spec.tv_sec, | 1475 | area, (long long)time_spec.tv_sec, |
| 1476 | time_spec.tv_nsec / 1000, level, except_str, | 1476 | time_spec.tv_nsec / 1000, level, except_str, |
| @@ -34,22 +34,21 @@ __show_trace(unsigned long sp, unsigned long low, unsigned long high) · 33 unmodified lines | |||
| 34 | unsigned long addr; | 34 | unsigned long addr; |
| 35 | 35 | ||
| 36 | while (1) { | 36 | while (1) { |
| 37 | sp = sp & PSW_ADDR_INSN; | ||
| 38 | if (sp < low || sp > high - sizeof(*sf)) | 37 | if (sp < low || sp > high - sizeof(*sf)) |
| 39 | return sp; | 38 | return sp; |
| 40 | sf = (struct stack_frame *) sp; | 39 | sf = (struct stack_frame *) sp; |
| 41 | addr = sf->gprs[8] & PSW_ADDR_INSN; | 40 | addr = sf->gprs[8]; |
| 42 | printk("([<%016lx>] %pSR)\n", addr, (void *)addr); | 41 | printk("([<%016lx>] %pSR)\n", addr, (void *)addr); |
| 43 | /* Follow the backchain. */ | 42 | /* Follow the backchain. */ |
| 44 | while (1) { | 43 | while (1) { |
| 45 | low = sp; | 44 | low = sp; |
| 46 | sp = sf->back_chain & PSW_ADDR_INSN; | 45 | sp = sf->back_chain; |
| 47 | if (!sp) | 46 | if (!sp) |
| 48 | break; | 47 | break; |
| 49 | if (sp <= low || sp > high - sizeof(*sf)) | 48 | if (sp <= low || sp > high - sizeof(*sf)) |
| 50 | return sp; | 49 | return sp; |
| 51 | sf = (struct stack_frame *) sp; | 50 | sf = (struct stack_frame *) sp; |
| 52 | addr = sf->gprs[8] & PSW_ADDR_INSN; | 51 | addr = sf->gprs[8]; |
| 53 | printk(" [<%016lx>] %pSR\n", addr, (void *)addr); | 52 | printk(" [<%016lx>] %pSR\n", addr, (void *)addr); |
| 54 | } | 53 | } |
| 55 | /* Zero backchain detected, check for interrupt frame. */ | 54 | /* Zero backchain detected, check for interrupt frame. */ |
| @@ -57,7 +56,7 @@ __show_trace(unsigned long sp, unsigned long low, unsigned long high) · 1 unmodified line | |||
| 57 | if (sp <= low || sp > high - sizeof(*regs)) | 56 | if (sp <= low || sp > high - sizeof(*regs)) |
| 58 | return sp; | 57 | return sp; |
| 59 | regs = (struct pt_regs *) sp; | 58 | regs = (struct pt_regs *) sp; |
| 60 | addr = regs->psw.addr & PSW_ADDR_INSN; | 59 | addr = regs->psw.addr; |
| 61 | printk(" [<%016lx>] %pSR\n", addr, (void *)addr); | 60 | printk(" [<%016lx>] %pSR\n", addr, (void *)addr); |
| 62 | low = sp; | 61 | low = sp; |
| 63 | sp = regs->gprs[15]; | 62 | sp = regs->gprs[15]; |
| @@ -252,14 +252,14 @@ static void early_pgm_check_handler(void) · 251 unmodified lines | |||
| 252 | unsigned long addr; | 252 | unsigned long addr; |
| 253 | 253 | ||
| 254 | addr = S390_lowcore.program_old_psw.addr; | 254 | addr = S390_lowcore.program_old_psw.addr; |
| 255 | fixup = search_exception_tables(addr & PSW_ADDR_INSN); | 255 | fixup = search_exception_tables(addr); |
| 256 | if (!fixup) | 256 | if (!fixup) |
| 257 | disabled_wait(0); | 257 | disabled_wait(0); |
| 258 | /* Disable low address protection before storing into lowcore. */ | 258 | /* Disable low address protection before storing into lowcore. */ |
| 259 | __ctl_store(cr0, 0, 0); | 259 | __ctl_store(cr0, 0, 0); |
| 260 | cr0_new = cr0 & ~(1UL << 28); | 260 | cr0_new = cr0 & ~(1UL << 28); |
| 261 | __ctl_load(cr0_new, 0, 0); | 261 | __ctl_load(cr0_new, 0, 0); |
| 262 | S390_lowcore.program_old_psw.addr = extable_fixup(fixup)|PSW_ADDR_AMODE; | 262 | S390_lowcore.program_old_psw.addr = extable_fixup(fixup); |
| 263 | __ctl_load(cr0, 0, 0); | 263 | __ctl_load(cr0, 0, 0); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| @@ -268,9 +268,9 @@ static noinline __init void setup_lowcore_early(void) · 2 unmodified lines | |||
| 268 | psw_t psw; | 268 | psw_t psw; |
| 269 | 269 | ||
| 270 | psw.mask = PSW_MASK_BASE | PSW_DEFAULT_KEY | PSW_MASK_EA | PSW_MASK_BA; | 270 | psw.mask = PSW_MASK_BASE | PSW_DEFAULT_KEY | PSW_MASK_EA | PSW_MASK_BA; |
| 271 | psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_ext_handler; | 271 | psw.addr = (unsigned long) s390_base_ext_handler; |
| 272 | S390_lowcore.external_new_psw = psw; | 272 | S390_lowcore.external_new_psw = psw; |
| 273 | psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; | 273 | psw.addr = (unsigned long) s390_base_pgm_handler; |
| 274 | S390_lowcore.program_new_psw = psw; | 274 | S390_lowcore.program_new_psw = psw; |
| 275 | s390_base_pgm_handler_fn = early_pgm_check_handler; | 275 | s390_base_pgm_handler_fn = early_pgm_check_handler; |
| 276 | } | 276 | } |
| @@ -203,7 +203,7 @@ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip) · 202 unmodified lines | |||
| 203 | goto out; | 203 | goto out; |
| 204 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) | 204 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) |
| 205 | goto out; | 205 | goto out; |
| 206 | ip = (ip & PSW_ADDR_INSN) - MCOUNT_INSN_SIZE; | 206 | ip -= MCOUNT_INSN_SIZE; |
| 207 | trace.func = ip; | 207 | trace.func = ip; |
| 208 | trace.depth = current->curr_ret_stack + 1; | 208 | trace.depth = current->curr_ret_stack + 1; |
| 209 | /* Only trace if the calling function expects to. */ | 209 | /* Only trace if the calling function expects to. */ |
| @@ -2057,12 +2057,12 @@ void s390_reset_system(void) · 2056 unmodified lines | |||
| 2057 | /* Set new machine check handler */ | 2057 | /* Set new machine check handler */ |
| 2058 | S390_lowcore.mcck_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT; | 2058 | S390_lowcore.mcck_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT; |
| 2059 | S390_lowcore.mcck_new_psw.addr = | 2059 | S390_lowcore.mcck_new_psw.addr = |
| 2060 | PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler; | 2060 | (unsigned long) s390_base_mcck_handler; |
| 2061 | 2061 | ||
| 2062 | /* Set new program check handler */ | 2062 | /* Set new program check handler */ |
| 2063 | S390_lowcore.program_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT; | 2063 | S390_lowcore.program_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT; |
| 2064 | S390_lowcore.program_new_psw.addr = | 2064 | S390_lowcore.program_new_psw.addr = |
| 2065 | PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; | 2065 | (unsigned long) s390_base_pgm_handler; |
| 2066 | 2066 | ||
| 2067 | /* | 2067 | /* |
| 2068 | * Clear subchannel ID and number to signal new kernel that no CCW or | 2068 | * Clear subchannel ID and number to signal new kernel that no CCW or |
| @@ -226,7 +226,7 @@ static void enable_singlestep(struct kprobe_ctlblk *kcb, · 225 unmodified lines | |||
| 226 | __ctl_load(per_kprobe, 9, 11); | 226 | __ctl_load(per_kprobe, 9, 11); |
| 227 | regs->psw.mask |= PSW_MASK_PER; | 227 | regs->psw.mask |= PSW_MASK_PER; |
| 228 | regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT); | 228 | regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT); |
| 229 | regs->psw.addr = ip | PSW_ADDR_AMODE; | 229 | regs->psw.addr = ip; |
| 230 | } | 230 | } |
| 231 | NOKPROBE_SYMBOL(enable_singlestep); | 231 | NOKPROBE_SYMBOL(enable_singlestep); |
| 232 | 232 | ||
| @@ -238,7 +238,7 @@ static void disable_singlestep(struct kprobe_ctlblk *kcb, · 5 unmodified lines | |||
| 238 | __ctl_load(kcb->kprobe_saved_ctl, 9, 11); | 238 | __ctl_load(kcb->kprobe_saved_ctl, 9, 11); |
| 239 | regs->psw.mask &= ~PSW_MASK_PER; | 239 | regs->psw.mask &= ~PSW_MASK_PER; |
| 240 | regs->psw.mask |= kcb->kprobe_saved_imask; | 240 | regs->psw.mask |= kcb->kprobe_saved_imask; |
| 241 | regs->psw.addr = ip | PSW_ADDR_AMODE; | 241 | regs->psw.addr = ip; |
| 242 | } | 242 | } |
| 243 | NOKPROBE_SYMBOL(disable_singlestep); | 243 | NOKPROBE_SYMBOL(disable_singlestep); |
| 244 | 244 | ||
| @@ -310,7 +310,7 @@ static int kprobe_handler(struct pt_regs *regs) · 65 unmodified lines | |||
| 310 | */ | 310 | */ |
| 311 | preempt_disable(); | 311 | preempt_disable(); |
| 312 | kcb = get_kprobe_ctlblk(); | 312 | kcb = get_kprobe_ctlblk(); |
| 313 | p = get_kprobe((void *)((regs->psw.addr & PSW_ADDR_INSN) - 2)); | 313 | p = get_kprobe((void *)(regs->psw.addr - 2)); |
| 314 | 314 | ||
| 315 | if (p) { | 315 | if (p) { |
| 316 | if (kprobe_running()) { | 316 | if (kprobe_running()) { |
| @@ -460,7 +460,7 @@ static int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) · 143 unmodified lines | |||
| 460 | break; | 460 | break; |
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | regs->psw.addr = orig_ret_address | PSW_ADDR_AMODE; | 463 | regs->psw.addr = orig_ret_address; |
| 464 | 464 | ||
| 465 | pop_kprobe(get_kprobe_ctlblk()); | 465 | pop_kprobe(get_kprobe_ctlblk()); |
| 466 | kretprobe_hash_unlock(current, &flags); | 466 | kretprobe_hash_unlock(current, &flags); |
| @@ -490,7 +490,7 @@ NOKPROBE_SYMBOL(trampoline_probe_handler); · 23 unmodified lines | |||
| 490 | static void resume_execution(struct kprobe *p, struct pt_regs *regs) | 490 | static void resume_execution(struct kprobe *p, struct pt_regs *regs) |
| 491 | { | 491 | { |
| 492 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); | 492 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); |
| 493 | unsigned long ip = regs->psw.addr & PSW_ADDR_INSN; | 493 | unsigned long ip = regs->psw.addr; |
| 494 | int fixup = probe_get_fixup_type(p->ainsn.insn); | 494 | int fixup = probe_get_fixup_type(p->ainsn.insn); |
| 495 | 495 | ||
| 496 | /* Check if the kprobes location is an enabled ftrace caller */ | 496 | /* Check if the kprobes location is an enabled ftrace caller */ |
| @@ -605,9 +605,9 @@ static int kprobe_trap_handler(struct pt_regs *regs, int trapnr) · 108 unmodified lines | |||
| 605 | * In case the user-specified fault handler returned | 605 | * In case the user-specified fault handler returned |
| 606 | * zero, try to fix up. | 606 | * zero, try to fix up. |
| 607 | */ | 607 | */ |
| 608 | entry = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN); | 608 | entry = search_exception_tables(regs->psw.addr); |
| 609 | if (entry) { | 609 | if (entry) { |
| 610 | regs->psw.addr = extable_fixup(entry) | PSW_ADDR_AMODE; | 610 | regs->psw.addr = extable_fixup(entry); |
| 611 | return 1; | 611 | return 1; |
| 612 | } | 612 | } |
| 613 | 613 | ||
| @@ -683,7 +683,7 @@ int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) · 69 unmodified lines | |||
| 683 | memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs)); | 683 | memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs)); |
| 684 | 684 | ||
| 685 | /* setup return addr to the jprobe handler routine */ | 685 | /* setup return addr to the jprobe handler routine */ |
| 686 | regs->psw.addr = (unsigned long) jp->entry | PSW_ADDR_AMODE; | 686 | regs->psw.addr = (unsigned long) jp->entry; |
| 687 | regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT); | 687 | regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT); |
| 688 | 688 | ||
| 689 | /* r15 is the stack pointer */ | 689 | /* r15 is the stack pointer */ |
| @@ -74,7 +74,7 @@ static unsigned long guest_is_user_mode(struct pt_regs *regs) · 73 unmodified lines | |||
| 74 | 74 | ||
| 75 | static unsigned long instruction_pointer_guest(struct pt_regs *regs) | 75 | static unsigned long instruction_pointer_guest(struct pt_regs *regs) |
| 76 | { | 76 | { |
| 77 | return sie_block(regs)->gpsw.addr & PSW_ADDR_INSN; | 77 | return sie_block(regs)->gpsw.addr; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | unsigned long perf_instruction_pointer(struct pt_regs *regs) | 80 | unsigned long perf_instruction_pointer(struct pt_regs *regs) |
| @@ -231,29 +231,27 @@ static unsigned long __store_trace(struct perf_callchain_entry *entry, · 150 unmodified lines | |||
| 231 | struct pt_regs *regs; | 231 | struct pt_regs *regs; |
| 232 | 232 | ||
| 233 | while (1) { | 233 | while (1) { |
| 234 | sp = sp & PSW_ADDR_INSN; | ||
| 235 | if (sp < low || sp > high - sizeof(*sf)) | 234 | if (sp < low || sp > high - sizeof(*sf)) |
| 236 | return sp; | 235 | return sp; |
| 237 | sf = (struct stack_frame *) sp; | 236 | sf = (struct stack_frame *) sp; |
| 238 | perf_callchain_store(entry, sf->gprs[8] & PSW_ADDR_INSN); | 237 | perf_callchain_store(entry, sf->gprs[8]); |
| 239 | /* Follow the backchain. */ | 238 | /* Follow the backchain. */ |
| 240 | while (1) { | 239 | while (1) { |
| 241 | low = sp; | 240 | low = sp; |
| 242 | sp = sf->back_chain & PSW_ADDR_INSN; | 241 | sp = sf->back_chain; |
| 243 | if (!sp) | 242 | if (!sp) |
| 244 | break; | 243 | break; |
| 245 | if (sp <= low || sp > high - sizeof(*sf)) | 244 | if (sp <= low || sp > high - sizeof(*sf)) |
| 246 | return sp; | 245 | return sp; |
| 247 | sf = (struct stack_frame *) sp; | 246 | sf = (struct stack_frame *) sp; |
| 248 | perf_callchain_store(entry, | 247 | perf_callchain_store(entry, sf->gprs[8]); |
| 249 | sf->gprs[8] & PSW_ADDR_INSN); | ||
| 250 | } | 248 | } |
| 251 | /* Zero backchain detected, check for interrupt frame. */ | 249 | /* Zero backchain detected, check for interrupt frame. */ |
| 252 | sp = (unsigned long) (sf + 1); | 250 | sp = (unsigned long) (sf + 1); |
| 253 | if (sp <= low || sp > high - sizeof(*regs)) | 251 | if (sp <= low || sp > high - sizeof(*regs)) |
| 254 | return sp; | 252 | return sp; |
| 255 | regs = (struct pt_regs *) sp; | 253 | regs = (struct pt_regs *) sp; |
| 256 | perf_callchain_store(entry, sf->gprs[8] & PSW_ADDR_INSN); | 254 | perf_callchain_store(entry, sf->gprs[8]); |
| 257 | low = sp; | 255 | low = sp; |
| 258 | sp = regs->gprs[15]; | 256 | sp = regs->gprs[15]; |
| 259 | } | 257 | } |
| @@ -56,10 +56,10 @@ unsigned long thread_saved_pc(struct task_struct *tsk) · 55 unmodified lines | |||
| 56 | return 0; | 56 | return 0; |
| 57 | low = task_stack_page(tsk); | 57 | low = task_stack_page(tsk); |
| 58 | high = (struct stack_frame *) task_pt_regs(tsk); | 58 | high = (struct stack_frame *) task_pt_regs(tsk); |
| 59 | sf = (struct stack_frame *) (tsk->thread.ksp & PSW_ADDR_INSN); | 59 | sf = (struct stack_frame *) tsk->thread.ksp; |
| 60 | if (sf <= low || sf > high) | 60 | if (sf <= low || sf > high) |
| 61 | return 0; | 61 | return 0; |
| 62 | sf = (struct stack_frame *) (sf->back_chain & PSW_ADDR_INSN); | 62 | sf = (struct stack_frame *) sf->back_chain; |
| 63 | if (sf <= low || sf > high) | 63 | if (sf <= low || sf > high) |
| 64 | return 0; | 64 | return 0; |
| 65 | return sf->gprs[8]; | 65 | return sf->gprs[8]; |
| @@ -154,7 +154,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, · 88 unmodified lines | |||
| 154 | memset(&frame->childregs, 0, sizeof(struct pt_regs)); | 154 | memset(&frame->childregs, 0, sizeof(struct pt_regs)); |
| 155 | frame->childregs.psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT | | 155 | frame->childregs.psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT | |
| 156 | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK; | 156 | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK; |
| 157 | frame->childregs.psw.addr = PSW_ADDR_AMODE | | 157 | frame->childregs.psw.addr = |
| 158 | (unsigned long) kernel_thread_starter; | 158 | (unsigned long) kernel_thread_starter; |
| 159 | frame->childregs.gprs[9] = new_stackp; /* function */ | 159 | frame->childregs.gprs[9] = new_stackp; /* function */ |
| 160 | frame->childregs.gprs[10] = arg; | 160 | frame->childregs.gprs[10] = arg; |
| @@ -220,14 +220,14 @@ unsigned long get_wchan(struct task_struct *p) · 59 unmodified lines | |||
| 220 | return 0; | 220 | return 0; |
| 221 | low = task_stack_page(p); | 221 | low = task_stack_page(p); |
| 222 | high = (struct stack_frame *) task_pt_regs(p); | 222 | high = (struct stack_frame *) task_pt_regs(p); |
| 223 | sf = (struct stack_frame *) (p->thread.ksp & PSW_ADDR_INSN); | 223 | sf = (struct stack_frame *) p->thread.ksp; |
| 224 | if (sf <= low || sf > high) | 224 | if (sf <= low || sf > high) |
| 225 | return 0; | 225 | return 0; |
| 226 | for (count = 0; count < 16; count++) { | 226 | for (count = 0; count < 16; count++) { |
| 227 | sf = (struct stack_frame *) (sf->back_chain & PSW_ADDR_INSN); | 227 | sf = (struct stack_frame *) sf->back_chain; |
| 228 | if (sf <= low || sf > high) | 228 | if (sf <= low || sf > high) |
| 229 | return 0; | 229 | return 0; |
| 230 | return_address = sf->gprs[8] & PSW_ADDR_INSN; | 230 | return_address = sf->gprs[8]; |
| 231 | if (!in_sched_functions(return_address)) | 231 | if (!in_sched_functions(return_address)) |
| 232 | return return_address; | 232 | return return_address; |
| 233 | } | 233 | } |
| @@ -84,7 +84,7 @@ void update_cr_regs(struct task_struct *task) · 83 unmodified lines | |||
| 84 | if (test_tsk_thread_flag(task, TIF_UPROBE_SINGLESTEP)) | 84 | if (test_tsk_thread_flag(task, TIF_UPROBE_SINGLESTEP)) |
| 85 | new.control |= PER_EVENT_IFETCH; | 85 | new.control |= PER_EVENT_IFETCH; |
| 86 | new.start = 0; | 86 | new.start = 0; |
| 87 | new.end = PSW_ADDR_INSN; | 87 | new.end = -1UL; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | /* Take care of the PER enablement bit in the PSW. */ | 90 | /* Take care of the PER enablement bit in the PSW. */ |
| @@ -148,7 +148,7 @@ static inline unsigned long __peek_user_per(struct task_struct *child, · 57 unmodified lines | |||
| 148 | else if (addr == (addr_t) &dummy->cr11) | 148 | else if (addr == (addr_t) &dummy->cr11) |
| 149 | /* End address of the active per set. */ | 149 | /* End address of the active per set. */ |
| 150 | return test_thread_flag(TIF_SINGLE_STEP) ? | 150 | return test_thread_flag(TIF_SINGLE_STEP) ? |
| 151 | PSW_ADDR_INSN : child->thread.per_user.end; | 151 | -1UL : child->thread.per_user.end; |
| 152 | else if (addr == (addr_t) &dummy->bits) | 152 | else if (addr == (addr_t) &dummy->bits) |
| 153 | /* Single-step bit. */ | 153 | /* Single-step bit. */ |
| 154 | return test_thread_flag(TIF_SINGLE_STEP) ? | 154 | return test_thread_flag(TIF_SINGLE_STEP) ? |
| @@ -495,8 +495,6 @@ long arch_ptrace(struct task_struct *child, long request, · 340 unmodified lines | |||
| 495 | } | 495 | } |
| 496 | return 0; | 496 | return 0; |
| 497 | default: | 497 | default: |
| 498 | /* Removing high order bit from addr (only for 31 bit). */ | ||
| 499 | addr &= PSW_ADDR_INSN; | ||
| 500 | return ptrace_request(child, request, addr, data); | 498 | return ptrace_request(child, request, addr, data); |
| 501 | } | 499 | } |
| 502 | } | 500 | } |
| @@ -301,25 +301,21 @@ static void __init setup_lowcore(void) · 300 unmodified lines | |||
| 301 | BUILD_BUG_ON(sizeof(struct lowcore) != LC_PAGES * 4096); | 301 | BUILD_BUG_ON(sizeof(struct lowcore) != LC_PAGES * 4096); |
| 302 | lc = __alloc_bootmem_low(LC_PAGES * PAGE_SIZE, LC_PAGES * PAGE_SIZE, 0); | 302 | lc = __alloc_bootmem_low(LC_PAGES * PAGE_SIZE, LC_PAGES * PAGE_SIZE, 0); |
| 303 | lc->restart_psw.mask = PSW_KERNEL_BITS; | 303 | lc->restart_psw.mask = PSW_KERNEL_BITS; |
| 304 | lc->restart_psw.addr = | 304 | lc->restart_psw.addr = (unsigned long) restart_int_handler; |
| 305 | PSW_ADDR_AMODE | (unsigned long) restart_int_handler; | ||
| 306 | lc->external_new_psw.mask = PSW_KERNEL_BITS | | 305 | lc->external_new_psw.mask = PSW_KERNEL_BITS | |
| 307 | PSW_MASK_DAT | PSW_MASK_MCHECK; | 306 | PSW_MASK_DAT | PSW_MASK_MCHECK; |
| 308 | lc->external_new_psw.addr = | 307 | lc->external_new_psw.addr = (unsigned long) ext_int_handler; |
| 309 | PSW_ADDR_AMODE | (unsigned long) ext_int_handler; | ||
| 310 | lc->svc_new_psw.mask = PSW_KERNEL_BITS | | 308 | lc->svc_new_psw.mask = PSW_KERNEL_BITS | |
| 311 | PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK; | 309 | PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK; |
| 312 | lc->svc_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) system_call; | 310 | lc->svc_new_psw.addr = (unsigned long) system_call; |
| 313 | lc->program_new_psw.mask = PSW_KERNEL_BITS | | 311 | lc->program_new_psw.mask = PSW_KERNEL_BITS | |
| 314 | PSW_MASK_DAT | PSW_MASK_MCHECK; | 312 | PSW_MASK_DAT | PSW_MASK_MCHECK; |
| 315 | lc->program_new_psw.addr = | 313 | lc->program_new_psw.addr = (unsigned long) pgm_check_handler; |
| 316 | PSW_ADDR_AMODE | (unsigned long) pgm_check_handler; | ||
| 317 | lc->mcck_new_psw.mask = PSW_KERNEL_BITS; | 314 | lc->mcck_new_psw.mask = PSW_KERNEL_BITS; |
| 318 | lc->mcck_new_psw.addr = | 315 | lc->mcck_new_psw.addr = (unsigned long) mcck_int_handler; |
| 319 | PSW_ADDR_AMODE | (unsigned long) mcck_int_handler; | ||
| 320 | lc->io_new_psw.mask = PSW_KERNEL_BITS | | 316 | lc->io_new_psw.mask = PSW_KERNEL_BITS | |
| 321 | PSW_MASK_DAT | PSW_MASK_MCHECK; | 317 | PSW_MASK_DAT | PSW_MASK_MCHECK; |
| 322 | lc->io_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) io_int_handler; | 318 | lc->io_new_psw.addr = (unsigned long) io_int_handler; |
| 323 | lc->clock_comparator = -1ULL; | 319 | lc->clock_comparator = -1ULL; |
| 324 | lc->kernel_stack = ((unsigned long) &init_thread_union) | 320 | lc->kernel_stack = ((unsigned long) &init_thread_union) |
| 325 | + THREAD_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs); | 321 | + THREAD_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs); |
| @@ -331,13 +331,13 @@ static int setup_frame(int sig, struct k_sigaction *ka, · 330 unmodified lines | |||
| 331 | /* Set up to return from userspace. If provided, use a stub | 331 | /* Set up to return from userspace. If provided, use a stub |
| 332 | already in userspace. */ | 332 | already in userspace. */ |
| 333 | if (ka->sa.sa_flags & SA_RESTORER) { | 333 | if (ka->sa.sa_flags & SA_RESTORER) { |
| 334 | restorer = (unsigned long) ka->sa.sa_restorer | PSW_ADDR_AMODE; | 334 | restorer = (unsigned long) ka->sa.sa_restorer; |
| 335 | } else { | 335 | } else { |
| 336 | /* Signal frame without vector registers are short ! */ | 336 | /* Signal frame without vector registers are short ! */ |
| 337 | __u16 __user *svc = (void __user *) frame + frame_size - 2; | 337 | __u16 __user *svc = (void __user *) frame + frame_size - 2; |
| 338 | if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn, svc)) | 338 | if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn, svc)) |
| 339 | return -EFAULT; | 339 | return -EFAULT; |
| 340 | restorer = (unsigned long) svc | PSW_ADDR_AMODE; | 340 | restorer = (unsigned long) svc; |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | /* Set up registers for signal handler */ | 343 | /* Set up registers for signal handler */ |
| @@ -347,7 +347,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, · 3 unmodified lines | |||
| 347 | regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA | | 347 | regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA | |
| 348 | (PSW_USER_BITS & PSW_MASK_ASC) | | 348 | (PSW_USER_BITS & PSW_MASK_ASC) | |
| 349 | (regs->psw.mask & ~PSW_MASK_ASC); | 349 | (regs->psw.mask & ~PSW_MASK_ASC); |
| 350 | regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE; | 350 | regs->psw.addr = (unsigned long) ka->sa.sa_handler; |
| 351 | 351 | ||
| 352 | regs->gprs[2] = sig; | 352 | regs->gprs[2] = sig; |
| 353 | regs->gprs[3] = (unsigned long) &frame->sc; | 353 | regs->gprs[3] = (unsigned long) &frame->sc; |
| @@ -394,13 +394,12 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, · 40 unmodified lines | |||
| 394 | /* Set up to return from userspace. If provided, use a stub | 394 | /* Set up to return from userspace. If provided, use a stub |
| 395 | already in userspace. */ | 395 | already in userspace. */ |
| 396 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { | 396 | if (ksig->ka.sa.sa_flags & SA_RESTORER) { |
| 397 | restorer = (unsigned long) | 397 | restorer = (unsigned long) ksig->ka.sa.sa_restorer; |
| 398 | ksig->ka.sa.sa_restorer | PSW_ADDR_AMODE; | ||
| 399 | } else { | 398 | } else { |
| 400 | __u16 __user *svc = &frame->svc_insn; | 399 | __u16 __user *svc = &frame->svc_insn; |
| 401 | if (__put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn, svc)) | 400 | if (__put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn, svc)) |
| 402 | return -EFAULT; | 401 | return -EFAULT; |
| 403 | restorer = (unsigned long) svc | PSW_ADDR_AMODE; | 402 | restorer = (unsigned long) svc; |
| 404 | } | 403 | } |
| 405 | 404 | ||
| 406 | /* Create siginfo on the signal stack */ | 405 | /* Create siginfo on the signal stack */ |
| @@ -426,7 +425,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, · 19 unmodified lines | |||
| 426 | regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA | | 425 | regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA | |
| 427 | (PSW_USER_BITS & PSW_MASK_ASC) | | 426 | (PSW_USER_BITS & PSW_MASK_ASC) | |
| 428 | (regs->psw.mask & ~PSW_MASK_ASC); | 427 | (regs->psw.mask & ~PSW_MASK_ASC); |
| 429 | regs->psw.addr = (unsigned long) ksig->ka.sa.sa_handler | PSW_ADDR_AMODE; | 428 | regs->psw.addr = (unsigned long) ksig->ka.sa.sa_handler; |
| 430 | 429 | ||
| 431 | regs->gprs[2] = ksig->sig; | 430 | regs->gprs[2] = ksig->sig; |
| 432 | regs->gprs[3] = (unsigned long) &frame->info; | 431 | regs->gprs[3] = (unsigned long) &frame->info; |
| @@ -623,8 +623,6 @@ void __init smp_save_dump_cpus(void) · 622 unmodified lines | |||
| 623 | return; | 623 | return; |
| 624 | /* Allocate a page as dumping area for the store status sigps */ | 624 | /* Allocate a page as dumping area for the store status sigps */ |
| 625 | page = memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, 1UL << 31); | 625 | page = memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, 1UL << 31); |
| 626 | if (!page) | ||
| 627 | panic("could not allocate memory for save area\n"); | ||
| 628 | /* Set multi-threading state to the previous system. */ | 626 | /* Set multi-threading state to the previous system. */ |
| 629 | pcpu_set_smt(sclp.mtid_prev); | 627 | pcpu_set_smt(sclp.mtid_prev); |
| 630 | boot_cpu_addr = stap(); | 628 | boot_cpu_addr = stap(); |
| @@ -21,12 +21,11 @@ static unsigned long save_context_stack(struct stack_trace *trace, · 20 unmodified lines | |||
| 21 | unsigned long addr; | 21 | unsigned long addr; |
| 22 | 22 | ||
| 23 | while(1) { | 23 | while(1) { |
| 24 | sp &= PSW_ADDR_INSN; | ||
| 25 | if (sp < low || sp > high) | 24 | if (sp < low || sp > high) |
| 26 | return sp; | 25 | return sp; |
| 27 | sf = (struct stack_frame *)sp; | 26 | sf = (struct stack_frame *)sp; |
| 28 | while(1) { | 27 | while(1) { |
| 29 | addr = sf->gprs[8] & PSW_ADDR_INSN; | 28 | addr = sf->gprs[8]; |
| 30 | if (!trace->skip) | 29 | if (!trace->skip) |
| 31 | trace->entries[trace->nr_entries++] = addr; | 30 | trace->entries[trace->nr_entries++] = addr; |
| 32 | else | 31 | else |
| @@ -34,7 +33,7 @@ static unsigned long save_context_stack(struct stack_trace *trace, · 1 unmodified line | |||
| 34 | if (trace->nr_entries >= trace->max_entries) | 33 | if (trace->nr_entries >= trace->max_entries) |
| 35 | return sp; | 34 | return sp; |
| 36 | low = sp; | 35 | low = sp; |
| 37 | sp = sf->back_chain & PSW_ADDR_INSN; | 36 | sp = sf->back_chain; |
| 38 | if (!sp) | 37 | if (!sp) |
| 39 | break; | 38 | break; |
| 40 | if (sp <= low || sp > high - sizeof(*sf)) | 39 | if (sp <= low || sp > high - sizeof(*sf)) |
| @@ -46,7 +45,7 @@ static unsigned long save_context_stack(struct stack_trace *trace, · 5 unmodified lines | |||
| 46 | if (sp <= low || sp > high - sizeof(*regs)) | 45 | if (sp <= low || sp > high - sizeof(*regs)) |
| 47 | return sp; | 46 | return sp; |
| 48 | regs = (struct pt_regs *)sp; | 47 | regs = (struct pt_regs *)sp; |
| 49 | addr = regs->psw.addr & PSW_ADDR_INSN; | 48 | addr = regs->psw.addr; |
| 50 | if (savesched || !in_sched_functions(addr)) { | 49 | if (savesched || !in_sched_functions(addr)) { |
| 51 | if (!trace->skip) | 50 | if (!trace->skip) |
| 52 | trace->entries[trace->nr_entries++] = addr; | 51 | trace->entries[trace->nr_entries++] = addr; |
| @@ -65,7 +64,7 @@ void save_stack_trace(struct stack_trace *trace) · 12 unmodified lines | |||
| 65 | register unsigned long sp asm ("15"); | 64 | register unsigned long sp asm ("15"); |
| 66 | unsigned long orig_sp, new_sp; | 65 | unsigned long orig_sp, new_sp; |
| 67 | 66 | ||
| 68 | orig_sp = sp & PSW_ADDR_INSN; | 67 | orig_sp = sp; |
| 69 | new_sp = save_context_stack(trace, orig_sp, | 68 | new_sp = save_context_stack(trace, orig_sp, |
| 70 | S390_lowcore.panic_stack - PAGE_SIZE, | 69 | S390_lowcore.panic_stack - PAGE_SIZE, |
| 71 | S390_lowcore.panic_stack, 1); | 70 | S390_lowcore.panic_stack, 1); |
| @@ -86,7 +85,7 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) · 14 unmodified lines | |||
| 86 | { | 85 | { |
| 87 | unsigned long sp, low, high; | 86 | unsigned long sp, low, high; |
| 88 | 87 | ||
| 89 | sp = tsk->thread.ksp & PSW_ADDR_INSN; | 88 | sp = tsk->thread.ksp; |
| 90 | low = (unsigned long) task_stack_page(tsk); | 89 | low = (unsigned long) task_stack_page(tsk); |
| 91 | high = (unsigned long) task_pt_regs(tsk); | 90 | high = (unsigned long) task_pt_regs(tsk); |
| 92 | save_context_stack(trace, sp, low, high, 0); | 91 | save_context_stack(trace, sp, low, high, 0); |
| @@ -383,3 +383,4 @@ SYSCALL(sys_recvfrom,compat_sys_recvfrom) · 382 unmodified lines | |||
| 383 | SYSCALL(sys_recvmsg,compat_sys_recvmsg) | 383 | SYSCALL(sys_recvmsg,compat_sys_recvmsg) |
| 384 | SYSCALL(sys_shutdown,sys_shutdown) | 384 | SYSCALL(sys_shutdown,sys_shutdown) |
| 385 | SYSCALL(sys_mlock2,compat_sys_mlock2) | 385 | SYSCALL(sys_mlock2,compat_sys_mlock2) |
| 386 | SYSCALL(sys_copy_file_range,compat_sys_copy_file_range) /* 375 */ | ||
| @@ -32,8 +32,7 @@ static inline void __user *get_trap_ip(struct pt_regs *regs) · 31 unmodified lines | |||
| 32 | address = *(unsigned long *)(current->thread.trap_tdb + 24); | 32 | address = *(unsigned long *)(current->thread.trap_tdb + 24); |
| 33 | else | 33 | else |
| 34 | address = regs->psw.addr; | 34 | address = regs->psw.addr; |
| 35 | return (void __user *) | 35 | return (void __user *) (address - (regs->int_code >> 16)); |
| 36 | ((address - (regs->int_code >> 16)) & PSW_ADDR_INSN); | ||
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | static inline void report_user_fault(struct pt_regs *regs, int signr) | 38 | static inline void report_user_fault(struct pt_regs *regs, int signr) |
| @@ -46,7 +45,7 @@ static inline void report_user_fault(struct pt_regs *regs, int signr) · 6 unmodified lines | |||
| 46 | return; | 45 | return; |
| 47 | printk("User process fault: interruption code %04x ilc:%d ", | 46 | printk("User process fault: interruption code %04x ilc:%d ", |
| 48 | regs->int_code & 0xffff, regs->int_code >> 17); | 47 | regs->int_code & 0xffff, regs->int_code >> 17); |
| 49 | print_vma_addr("in ", regs->psw.addr & PSW_ADDR_INSN); | 48 | print_vma_addr("in ", regs->psw.addr); |
| 50 | printk("\n"); | 49 | printk("\n"); |
| 51 | show_regs(regs); | 50 | show_regs(regs); |
| 52 | } | 51 | } |
| @@ -69,13 +68,13 @@ void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str) · 16 unmodified lines | |||
| 69 | report_user_fault(regs, si_signo); | 68 | report_user_fault(regs, si_signo); |
| 70 | } else { | 69 | } else { |
| 71 | const struct exception_table_entry *fixup; | 70 | const struct exception_table_entry *fixup; |
| 72 | fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN); | 71 | fixup = search_exception_tables(regs->psw.addr); |
| 73 | if (fixup) | 72 | if (fixup) |
| 74 | regs->psw.addr = extable_fixup(fixup) | PSW_ADDR_AMODE; | 73 | regs->psw.addr = extable_fixup(fixup); |
| 75 | else { | 74 | else { |
| 76 | enum bug_trap_type btt; | 75 | enum bug_trap_type btt; |
| 77 | 76 | ||
| 78 | btt = report_bug(regs->psw.addr & PSW_ADDR_INSN, regs); | 77 | btt = report_bug(regs->psw.addr, regs); |
| 79 | if (btt == BUG_TRAP_TYPE_WARN) | 78 | if (btt == BUG_TRAP_TYPE_WARN) |
| 80 | return; | 79 | return; |
| 81 | die(regs, str); | 80 | die(regs, str); |
| @@ -29,6 +29,7 @@ config KVM · 28 unmodified lines | |||
| 29 | select HAVE_KVM_IRQFD | 29 | select HAVE_KVM_IRQFD |
| 30 | select HAVE_KVM_IRQ_ROUTING | 30 | select HAVE_KVM_IRQ_ROUTING |
| 31 | select SRCU | 31 | select SRCU |
| 32 | select KVM_VFIO | ||
| 32 | ---help--- | 33 | ---help--- |
| 33 | Support hosting paravirtualized guest machines using the SIE | 34 | Support hosting paravirtualized guest machines using the SIE |
| 34 | virtualization capability on the mainframe. This should work | 35 | virtualization capability on the mainframe. This should work |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | # as published by the Free Software Foundation. | 7 | # as published by the Free Software Foundation. |
| 8 | 8 | ||
| 9 | KVM := ../../../virt/kvm | 9 | KVM := ../../../virt/kvm |
| 10 | common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqchip.o | 10 | common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqchip.o $(KVM)/vfio.o |
| 11 | 11 | ||
| 12 | ccflags-y := -Ivirt/kvm -Iarch/s390/kvm | 12 | ccflags-y := -Ivirt/kvm -Iarch/s390/kvm |
| 13 | 13 | ||
| @@ -116,7 +116,7 @@ static void enable_all_hw_wp(struct kvm_vcpu *vcpu) · 115 unmodified lines | |||
| 116 | if (*cr9 & PER_EVENT_STORE && *cr9 & PER_CONTROL_ALTERATION) { | 116 | if (*cr9 & PER_EVENT_STORE && *cr9 & PER_CONTROL_ALTERATION) { |
| 117 | *cr9 &= ~PER_CONTROL_ALTERATION; | 117 | *cr9 &= ~PER_CONTROL_ALTERATION; |
| 118 | *cr10 = 0; | 118 | *cr10 = 0; |
| 119 | *cr11 = PSW_ADDR_INSN; | 119 | *cr11 = -1UL; |
| 120 | } else { | 120 | } else { |
| 121 | *cr9 &= ~PER_CONTROL_ALTERATION; | 121 | *cr9 &= ~PER_CONTROL_ALTERATION; |
| 122 | *cr9 |= PER_EVENT_STORE; | 122 | *cr9 |= PER_EVENT_STORE; |
| @@ -159,7 +159,7 @@ void kvm_s390_patch_guest_per_regs(struct kvm_vcpu *vcpu) · 36 unmodified lines | |||
| 159 | vcpu->arch.sie_block->gcr[0] &= ~0x800ul; | 159 | vcpu->arch.sie_block->gcr[0] &= ~0x800ul; |
| 160 | vcpu->arch.sie_block->gcr[9] |= PER_EVENT_IFETCH; | 160 | vcpu->arch.sie_block->gcr[9] |= PER_EVENT_IFETCH; |
| 161 | vcpu->arch.sie_block->gcr[10] = 0; | 161 | vcpu->arch.sie_block->gcr[10] = 0; |
| 162 | vcpu->arch.sie_block->gcr[11] = PSW_ADDR_INSN; | 162 | vcpu->arch.sie_block->gcr[11] = -1UL; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | if (guestdbg_hw_bp_enabled(vcpu)) { | 165 | if (guestdbg_hw_bp_enabled(vcpu)) { |
| @@ -1423,44 +1423,18 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) · 1422 unmodified lines | |||
| 1423 | return 0; | 1423 | return 0; |
| 1424 | } | 1424 | } |
| 1425 | 1425 | ||
| 1426 | /* | ||
| 1427 | * Backs up the current FP/VX register save area on a particular | ||
| 1428 | * destination. Used to switch between different register save | ||
| 1429 | * areas. | ||
| 1430 | */ | ||
| 1431 | static inline void save_fpu_to(struct fpu *dst) | ||
| 1432 | { | ||
| 1433 | dst->fpc = current->thread.fpu.fpc; | ||
| 1434 | dst->regs = current->thread.fpu.regs; | ||
| 1435 | } | ||
| 1436 | |||
| 1437 | /* | ||
| 1438 | * Switches the FP/VX register save area from which to lazy | ||
| 1439 | * restore register contents. | ||
| 1440 | */ | ||
| 1441 | static inline void load_fpu_from(struct fpu *from) | ||
| 1442 | { | ||
| 1443 | current->thread.fpu.fpc = from->fpc; | ||
| 1444 | current->thread.fpu.regs = from->regs; | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | 1426 | void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) |
| 1448 | { | 1427 | { |
| 1449 | /* Save host register state */ | 1428 | /* Save host register state */ |
| 1450 | save_fpu_regs(); | 1429 | save_fpu_regs(); |
| 1451 | save_fpu_to(&vcpu->arch.host_fpregs); | 1430 | vcpu->arch.host_fpregs.fpc = current->thread.fpu.fpc; |
| 1452 | 1431 | vcpu->arch.host_fpregs.regs = current->thread.fpu.regs; | |
| 1453 | if (test_kvm_facility(vcpu->kvm, 129)) { | ||
| 1454 | current->thread.fpu.fpc = vcpu->run->s.regs.fpc; | ||
| 1455 | /* | ||
| 1456 | * Use the register save area in the SIE-control block | ||
| 1457 | * for register restore and save in kvm_arch_vcpu_put() | ||
| 1458 | */ | ||
| 1459 | current->thread.fpu.vxrs = | ||
| 1460 | (__vector128 *)&vcpu->run->s.regs.vrs; | ||
| 1461 | } else | ||
| 1462 | load_fpu_from(&vcpu->arch.guest_fpregs); | ||
| 1463 | 1432 | ||
| 1433 | /* Depending on MACHINE_HAS_VX, data stored to vrs either | ||
| 1434 | * has vector register or floating point register format. | ||
| 1435 | */ | ||
| 1436 | current->thread.fpu.regs = vcpu->run->s.regs.vrs; | ||
| 1437 | current->thread.fpu.fpc = vcpu->run->s.regs.fpc; | ||
| 1464 | if (test_fp_ctl(current->thread.fpu.fpc)) | 1438 | if (test_fp_ctl(current->thread.fpu.fpc)) |
| 1465 | /* User space provided an invalid FPC, let's clear it */ | 1439 | /* User space provided an invalid FPC, let's clear it */ |
| 1466 | current->thread.fpu.fpc = 0; | 1440 | current->thread.fpu.fpc = 0; |
| @@ -1476,19 +1450,13 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) · 9 unmodified lines | |||
| 1476 | atomic_andnot(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); | 1450 | atomic_andnot(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); |
| 1477 | gmap_disable(vcpu->arch.gmap); | 1451 | gmap_disable(vcpu->arch.gmap); |
| 1478 | 1452 | ||
| 1453 | /* Save guest register state */ | ||
| 1479 | save_fpu_regs(); | 1454 | save_fpu_regs(); |
| 1455 | vcpu->run->s.regs.fpc = current->thread.fpu.fpc; | ||
| 1480 | 1456 | ||
| 1481 | if (test_kvm_facility(vcpu->kvm, 129)) | 1457 | /* Restore host register state */ |
| 1482 | /* | 1458 | current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc; |
| 1483 | * kvm_arch_vcpu_load() set up the register save area to | 1459 | current->thread.fpu.regs = vcpu->arch.host_fpregs.regs; |
| 1484 | * the &vcpu->run->s.regs.vrs and, thus, the vector registers | ||
| 1485 | * are already saved. Only the floating-point control must be | ||
| 1486 | * copied. | ||
| 1487 | */ | ||
| 1488 | vcpu->run->s.regs.fpc = current->thread.fpu.fpc; | ||
| 1489 | else | ||
| 1490 | save_fpu_to(&vcpu->arch.guest_fpregs); | ||
| 1491 | load_fpu_from(&vcpu->arch.host_fpregs); | ||
| 1492 | 1460 | ||
| 1493 | save_access_regs(vcpu->run->s.regs.acrs); | 1461 | save_access_regs(vcpu->run->s.regs.acrs); |
| 1494 | restore_access_regs(vcpu->arch.host_acrs); | 1462 | restore_access_regs(vcpu->arch.host_acrs); |
| @@ -1506,8 +1474,9 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu) · 11 unmodified lines | |||
| 1506 | memset(vcpu->arch.sie_block->gcr, 0, 16 * sizeof(__u64)); | 1474 | memset(vcpu->arch.sie_block->gcr, 0, 16 * sizeof(__u64)); |
| 1507 | vcpu->arch.sie_block->gcr[0] = 0xE0UL; | 1475 | vcpu->arch.sie_block->gcr[0] = 0xE0UL; |
| 1508 | vcpu->arch.sie_block->gcr[14] = 0xC2000000UL; | 1476 | vcpu->arch.sie_block->gcr[14] = 0xC2000000UL; |
| 1509 | vcpu->arch.guest_fpregs.fpc = 0; | 1477 | /* make sure the new fpc will be lazily loaded */ |
| 1510 | asm volatile("lfpc %0" : : "Q" (vcpu->arch.guest_fpregs.fpc)); | 1478 | save_fpu_regs(); |
| 1479 | current->thread.fpu.fpc = 0; | ||
| 1511 | vcpu->arch.sie_block->gbea = 1; | 1480 | vcpu->arch.sie_block->gbea = 1; |
| 1512 | vcpu->arch.sie_block->pp = 0; | 1481 | vcpu->arch.sie_block->pp = 0; |
| 1513 | vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; | 1482 | vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; |
| @@ -1648,17 +1617,6 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, · 134 unmodified lines | |||
| 1648 | vcpu->arch.local_int.wq = &vcpu->wq; | 1617 | vcpu->arch.local_int.wq = &vcpu->wq; |
| 1649 | vcpu->arch.local_int.cpuflags = &vcpu->arch.sie_block->cpuflags; | 1618 | vcpu->arch.local_int.cpuflags = &vcpu->arch.sie_block->cpuflags; |
| 1650 | 1619 | ||
| 1651 | /* | ||
| 1652 | * Allocate a save area for floating-point registers. If the vector | ||
| 1653 | * extension is available, register contents are saved in the SIE | ||
| 1654 | * control block. The allocated save area is still required in | ||
| 1655 | * particular places, for example, in kvm_s390_vcpu_store_status(). | ||
| 1656 | */ | ||
| 1657 | vcpu->arch.guest_fpregs.fprs = kzalloc(sizeof(freg_t) * __NUM_FPRS, | ||
| 1658 | GFP_KERNEL); | ||
| 1659 | if (!vcpu->arch.guest_fpregs.fprs) | ||
| 1660 | goto out_free_sie_block; | ||
| 1661 | |||
| 1662 | rc = kvm_vcpu_init(vcpu, kvm, id); | 1620 | rc = kvm_vcpu_init(vcpu, kvm, id); |
| 1663 | if (rc) | 1621 | if (rc) |
| 1664 | goto out_free_sie_block; | 1622 | goto out_free_sie_block; |
| @@ -1879,19 +1837,27 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, · 214 unmodified lines | |||
| 1879 | 1837 | ||
| 1880 | int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | 1838 | int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) |
| 1881 | { | 1839 | { |
| 1840 | /* make sure the new values will be lazily loaded */ | ||
| 1841 | save_fpu_regs(); | ||
| 1882 | if (test_fp_ctl(fpu->fpc)) | 1842 | if (test_fp_ctl(fpu->fpc)) |
| 1883 | return -EINVAL; | 1843 | return -EINVAL; |
| 1884 | memcpy(vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs)); | 1844 | current->thread.fpu.fpc = fpu->fpc; |
| 1885 | vcpu->arch.guest_fpregs.fpc = fpu->fpc; | 1845 | if (MACHINE_HAS_VX) |
| 1886 | save_fpu_regs(); | 1846 | convert_fp_to_vx(current->thread.fpu.vxrs, (freg_t *)fpu->fprs); |
| 1887 | load_fpu_from(&vcpu->arch.guest_fpregs); | 1847 | else |
| 1848 | memcpy(current->thread.fpu.fprs, &fpu->fprs, sizeof(fpu->fprs)); | ||
| 1888 | return 0; | 1849 | return 0; |
| 1889 | } | 1850 | } |
| 1890 | 1851 | ||
| 1891 | int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) | 1852 | int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) |
| 1892 | { | 1853 | { |
| 1893 | memcpy(&fpu->fprs, vcpu->arch.guest_fpregs.fprs, sizeof(fpu->fprs)); | 1854 | /* make sure we have the latest values */ |
| 1894 | fpu->fpc = vcpu->arch.guest_fpregs.fpc; | 1855 | save_fpu_regs(); |
| 1856 | if (MACHINE_HAS_VX) | ||
| 1857 | convert_vx_to_fp((freg_t *)fpu->fprs, current->thread.fpu.vxrs); | ||
| 1858 | else | ||
| 1859 | memcpy(fpu->fprs, current->thread.fpu.fprs, sizeof(fpu->fprs)); | ||
| 1860 | fpu->fpc = current->thread.fpu.fpc; | ||
| 1895 | return 0; | 1861 | return 0; |
| 1896 | } | 1862 | } |
| 1897 | 1863 | ||
| @@ -2396,6 +2362,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) · 498 unmodified lines | |||
| 2396 | int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa) | 2362 | int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa) |
| 2397 | { | 2363 | { |
| 2398 | unsigned char archmode = 1; | 2364 | unsigned char archmode = 1; |
| 2365 | freg_t fprs[NUM_FPRS]; | ||
| 2399 | unsigned int px; | 2366 | unsigned int px; |
| 2400 | u64 clkcomp; | 2367 | u64 clkcomp; |
| 2401 | int rc; | 2368 | int rc; |
| @@ -2411,8 +2378,16 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa) · 9 unmodified lines | |||
| 2411 | gpa = px; | 2378 | gpa = px; |
| 2412 | } else | 2379 | } else |
| 2413 | gpa -= __LC_FPREGS_SAVE_AREA; | 2380 | gpa -= __LC_FPREGS_SAVE_AREA; |
| 2414 | rc = write_guest_abs(vcpu, gpa + __LC_FPREGS_SAVE_AREA, | 2381 | |
| 2415 | vcpu->arch.guest_fpregs.fprs, 128); | 2382 | /* manually convert vector registers if necessary */ |
| 2383 | if (MACHINE_HAS_VX) { | ||
| 2384 | convert_vx_to_fp(fprs, current->thread.fpu.vxrs); | ||
| 2385 | rc = write_guest_abs(vcpu, gpa + __LC_FPREGS_SAVE_AREA, | ||
| 2386 | fprs, 128); | ||
| 2387 | } else { | ||
| 2388 | rc = write_guest_abs(vcpu, gpa + __LC_FPREGS_SAVE_AREA, | ||
| 2389 | vcpu->run->s.regs.vrs, 128); | ||
| 2390 | } | ||
| 2416 | rc |= write_guest_abs(vcpu, gpa + __LC_GPREGS_SAVE_AREA, | 2391 | rc |= write_guest_abs(vcpu, gpa + __LC_GPREGS_SAVE_AREA, |
| 2417 | vcpu->run->s.regs.gprs, 128); | 2392 | vcpu->run->s.regs.gprs, 128); |
| 2418 | rc |= write_guest_abs(vcpu, gpa + __LC_PSW_SAVE_AREA, | 2393 | rc |= write_guest_abs(vcpu, gpa + __LC_PSW_SAVE_AREA, |
| @@ -2420,7 +2395,7 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa) · 1 unmodified line | |||
| 2420 | rc |= write_guest_abs(vcpu, gpa + __LC_PREFIX_SAVE_AREA, | 2395 | rc |= write_guest_abs(vcpu, gpa + __LC_PREFIX_SAVE_AREA, |
| 2421 | &px, 4); | 2396 | &px, 4); |
| 2422 | rc |= write_guest_abs(vcpu, gpa + __LC_FP_CREG_SAVE_AREA, | 2397 | rc |= write_guest_abs(vcpu, gpa + __LC_FP_CREG_SAVE_AREA, |
| 2423 | &vcpu->arch.guest_fpregs.fpc, 4); | 2398 | &vcpu->run->s.regs.fpc, 4); |
| 2424 | rc |= write_guest_abs(vcpu, gpa + __LC_TOD_PROGREG_SAVE_AREA, | 2399 | rc |= write_guest_abs(vcpu, gpa + __LC_TOD_PROGREG_SAVE_AREA, |
| 2425 | &vcpu->arch.sie_block->todpr, 4); | 2400 | &vcpu->arch.sie_block->todpr, 4); |
| 2426 | rc |= write_guest_abs(vcpu, gpa + __LC_CPU_TIMER_SAVE_AREA, | 2401 | rc |= write_guest_abs(vcpu, gpa + __LC_CPU_TIMER_SAVE_AREA, |
| @@ -2443,19 +2418,7 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr) · 16 unmodified lines | |||
| 2443 | * it into the save area | 2418 | * it into the save area |
| 2444 | */ | 2419 | */ |
| 2445 | save_fpu_regs(); | 2420 | save_fpu_regs(); |
| 2446 | if (test_kvm_facility(vcpu->kvm, 129)) { | 2421 | vcpu->run->s.regs.fpc = current->thread.fpu.fpc; |
| 2447 | /* | ||
| 2448 | * If the vector extension is available, the vector registers | ||
| 2449 | * which overlaps with floating-point registers are saved in | ||
| 2450 | * the SIE-control block. Hence, extract the floating-point | ||
| 2451 | * registers and the FPC value and store them in the | ||
| 2452 | * guest_fpregs structure. | ||
| 2453 | */ | ||
| 2454 | vcpu->arch.guest_fpregs.fpc = current->thread.fpu.fpc; | ||
| 2455 | convert_vx_to_fp(vcpu->arch.guest_fpregs.fprs, | ||
| 2456 | current->thread.fpu.vxrs); | ||
| 2457 | } else | ||
| 2458 | save_fpu_to(&vcpu->arch.guest_fpregs); | ||
| 2459 | save_access_regs(vcpu->run->s.regs.acrs); | 2422 | save_access_regs(vcpu->run->s.regs.acrs); |
| 2460 | 2423 | ||
| 2461 | return kvm_s390_store_status_unloaded(vcpu, addr); | 2424 | return kvm_s390_store_status_unloaded(vcpu, addr); |
| @@ -228,7 +228,7 @@ static inline void report_user_fault(struct pt_regs *regs, long signr) · 227 unmodified lines | |||
| 228 | return; | 228 | return; |
| 229 | printk(KERN_ALERT "User process fault: interruption code %04x ilc:%d ", | 229 | printk(KERN_ALERT "User process fault: interruption code %04x ilc:%d ", |
| 230 | regs->int_code & 0xffff, regs->int_code >> 17); | 230 | regs->int_code & 0xffff, regs->int_code >> 17); |
| 231 | print_vma_addr(KERN_CONT "in ", regs->psw.addr & PSW_ADDR_INSN); | 231 | print_vma_addr(KERN_CONT "in ", regs->psw.addr); |
| 232 | printk(KERN_CONT "\n"); | 232 | printk(KERN_CONT "\n"); |
| 233 | printk(KERN_ALERT "failing address: %016lx TEID: %016lx\n", | 233 | printk(KERN_ALERT "failing address: %016lx TEID: %016lx\n", |
| 234 | regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long); | 234 | regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long); |
| @@ -256,9 +256,9 @@ static noinline void do_no_context(struct pt_regs *regs) · 21 unmodified lines | |||
| 256 | const struct exception_table_entry *fixup; | 256 | const struct exception_table_entry *fixup; |
| 257 | 257 | ||
| 258 | /* Are we prepared to handle this kernel fault? */ | 258 | /* Are we prepared to handle this kernel fault? */ |
| 259 | fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN); | 259 | fixup = search_exception_tables(regs->psw.addr); |
| 260 | if (fixup) { | 260 | if (fixup) { |
| 261 | regs->psw.addr = extable_fixup(fixup) | PSW_ADDR_AMODE; | 261 | regs->psw.addr = extable_fixup(fixup); |
| 262 | return; | 262 | return; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| @@ -98,7 +98,7 @@ void __init paging_init(void) · 97 unmodified lines | |||
| 98 | __ctl_load(S390_lowcore.kernel_asce, 1, 1); | 98 | __ctl_load(S390_lowcore.kernel_asce, 1, 1); |
| 99 | __ctl_load(S390_lowcore.kernel_asce, 7, 7); | 99 | __ctl_load(S390_lowcore.kernel_asce, 7, 7); |
| 100 | __ctl_load(S390_lowcore.kernel_asce, 13, 13); | 100 | __ctl_load(S390_lowcore.kernel_asce, 13, 13); |
| 101 | arch_local_irq_restore(4UL << (BITS_PER_LONG - 8)); | 101 | __arch_local_irq_stosm(0x04); |
| 102 | 102 | ||
| 103 | sparse_memory_present_with_active_regions(MAX_NUMNODES); | 103 | sparse_memory_present_with_active_regions(MAX_NUMNODES); |
| 104 | sparse_init(); | 104 | sparse_init(); |
| @@ -169,12 +169,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, · 168 unmodified lines | |||
| 169 | 169 | ||
| 170 | int s390_mmap_check(unsigned long addr, unsigned long len, unsigned long flags) | 170 | int s390_mmap_check(unsigned long addr, unsigned long len, unsigned long flags) |
| 171 | { | 171 | { |
| 172 | if (is_compat_task() || (TASK_SIZE >= (1UL << 53))) | 172 | if (is_compat_task() || TASK_SIZE >= TASK_MAX_SIZE) |
| 173 | return 0; | 173 | return 0; |
| 174 | if (!(flags & MAP_FIXED)) | 174 | if (!(flags & MAP_FIXED)) |
| 175 | addr = 0; | 175 | addr = 0; |
| 176 | if ((addr + len) >= TASK_SIZE) | 176 | if ((addr + len) >= TASK_SIZE) |
| 177 | return crst_table_upgrade(current->mm, 1UL << 53); | 177 | return crst_table_upgrade(current->mm, TASK_MAX_SIZE); |
| 178 | return 0; | 178 | return 0; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| @@ -189,9 +189,9 @@ s390_get_unmapped_area(struct file *filp, unsigned long addr, · 8 unmodified lines | |||
| 189 | area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); | 189 | area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); |
| 190 | if (!(area & ~PAGE_MASK)) | 190 | if (!(area & ~PAGE_MASK)) |
| 191 | return area; | 191 | return area; |
| 192 | if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { | 192 | if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < TASK_MAX_SIZE) { |
| 193 | /* Upgrade the page table to 4 levels and retry. */ | 193 | /* Upgrade the page table to 4 levels and retry. */ |
| 194 | rc = crst_table_upgrade(mm, 1UL << 53); | 194 | rc = crst_table_upgrade(mm, TASK_MAX_SIZE); |
| 195 | if (rc) | 195 | if (rc) |
| 196 | return (unsigned long) rc; | 196 | return (unsigned long) rc; |
| 197 | area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); | 197 | area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); |
| @@ -211,9 +211,9 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr, · 13 unmodified lines | |||
| 211 | area = arch_get_unmapped_area_topdown(filp, addr, len, pgoff, flags); | 211 | area = arch_get_unmapped_area_topdown(filp, addr, len, pgoff, flags); |
| 212 | if (!(area & ~PAGE_MASK)) | 212 | if (!(area & ~PAGE_MASK)) |
| 213 | return area; | 213 | return area; |
| 214 | if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { | 214 | if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < TASK_MAX_SIZE) { |
| 215 | /* Upgrade the page table to 4 levels and retry. */ | 215 | /* Upgrade the page table to 4 levels and retry. */ |
| 216 | rc = crst_table_upgrade(mm, 1UL << 53); | 216 | rc = crst_table_upgrade(mm, TASK_MAX_SIZE); |
| 217 | if (rc) | 217 | if (rc) |
| 218 | return (unsigned long) rc; | 218 | return (unsigned long) rc; |
| 219 | area = arch_get_unmapped_area_topdown(filp, addr, len, | 219 | area = arch_get_unmapped_area_topdown(filp, addr, len, |
| @@ -55,7 +55,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long limit) · 54 unmodified lines | |||
| 55 | unsigned long entry; | 55 | unsigned long entry; |
| 56 | int flush; | 56 | int flush; |
| 57 | 57 | ||
| 58 | BUG_ON(limit > (1UL << 53)); | 58 | BUG_ON(limit > TASK_MAX_SIZE); |
| 59 | flush = 0; | 59 | flush = 0; |
| 60 | repeat: | 60 | repeat: |
| 61 | table = crst_table_alloc(mm); | 61 | table = crst_table_alloc(mm); |
| @@ -57,9 +57,7 @@ static __init pg_data_t *alloc_node_data(void) · 56 unmodified lines | |||
| 57 | { | 57 | { |
| 58 | pg_data_t *res; | 58 | pg_data_t *res; |
| 59 | 59 | ||
| 60 | res = (pg_data_t *) memblock_alloc(sizeof(pg_data_t), 1); | 60 | res = (pg_data_t *) memblock_alloc(sizeof(pg_data_t), 8); |
| 61 | if (!res) | ||
| 62 | panic("Could not allocate memory for node data!\n"); | ||
| 63 | memset(res, 0, sizeof(pg_data_t)); | 61 | memset(res, 0, sizeof(pg_data_t)); |
| 64 | return res; | 62 | return res; |
| 65 | } | 63 | } |
| @@ -162,7 +160,7 @@ static int __init numa_init_late(void) · 96 unmodified lines | |||
| 162 | register_one_node(nid); | 160 | register_one_node(nid); |
| 163 | return 0; | 161 | return 0; |
| 164 | } | 162 | } |
| 165 | device_initcall(numa_init_late); | 163 | arch_initcall(numa_init_late); |
| 166 | 164 | ||
| 167 | static int __init parse_debug(char *parm) | 165 | static int __init parse_debug(char *parm) |
| 168 | { | 166 | { |
| @@ -16,24 +16,23 @@ __show_trace(unsigned int *depth, unsigned long sp, · 15 unmodified lines | |||
| 16 | struct pt_regs *regs; | 16 | struct pt_regs *regs; |
| 17 | 17 | ||
| 18 | while (*depth) { | 18 | while (*depth) { |
| 19 | sp = sp & PSW_ADDR_INSN; | ||
| 20 | if (sp < low || sp > high - sizeof(*sf)) | 19 | if (sp < low || sp > high - sizeof(*sf)) |
| 21 | return sp; | 20 | return sp; |
| 22 | sf = (struct stack_frame *) sp; | 21 | sf = (struct stack_frame *) sp; |
| 23 | (*depth)--; | 22 | (*depth)--; |
| 24 | oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN); | 23 | oprofile_add_trace(sf->gprs[8]); |
| 25 | 24 | ||
| 26 | /* Follow the backchain. */ | 25 | /* Follow the backchain. */ |
| 27 | while (*depth) { | 26 | while (*depth) { |
| 28 | low = sp; | 27 | low = sp; |
| 29 | sp = sf->back_chain & PSW_ADDR_INSN; | 28 | sp = sf->back_chain; |
| 30 | if (!sp) | 29 | if (!sp) |
| 31 | break; | 30 | break; |
| 32 | if (sp <= low || sp > high - sizeof(*sf)) | 31 | if (sp <= low || sp > high - sizeof(*sf)) |
| 33 | return sp; | 32 | return sp; |
| 34 | sf = (struct stack_frame *) sp; | 33 | sf = (struct stack_frame *) sp; |
| 35 | (*depth)--; | 34 | (*depth)--; |
| 36 | oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN); | 35 | oprofile_add_trace(sf->gprs[8]); |
| 37 | 36 | ||
| 38 | } | 37 | } |
| 39 | 38 | ||
| @@ -46,7 +45,7 @@ __show_trace(unsigned int *depth, unsigned long sp, · 6 unmodified lines | |||
| 46 | return sp; | 45 | return sp; |
| 47 | regs = (struct pt_regs *) sp; | 46 | regs = (struct pt_regs *) sp; |
| 48 | (*depth)--; | 47 | (*depth)--; |
| 49 | oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN); | 48 | oprofile_add_trace(sf->gprs[8]); |
| 50 | low = sp; | 49 | low = sp; |
| 51 | sp = regs->gprs[15]; | 50 | sp = regs->gprs[15]; |
| 52 | } | 51 | } |
| @@ -68,9 +68,12 @@ static struct airq_struct zpci_airq = { · 67 unmodified lines | |||
| 68 | .isc = PCI_ISC, | 68 | .isc = PCI_ISC, |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | /* I/O Map */ | 71 | #define ZPCI_IOMAP_ENTRIES \ |
| 72 | min(((unsigned long) CONFIG_PCI_NR_FUNCTIONS * PCI_BAR_COUNT), \ | ||
| 73 | ZPCI_IOMAP_MAX_ENTRIES) | ||
| 74 | |||
| 72 | static DEFINE_SPINLOCK(zpci_iomap_lock); | 75 | static DEFINE_SPINLOCK(zpci_iomap_lock); |
| 73 | static DECLARE_BITMAP(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES); | 76 | static unsigned long *zpci_iomap_bitmap; |
| 74 | struct zpci_iomap_entry *zpci_iomap_start; | 77 | struct zpci_iomap_entry *zpci_iomap_start; |
| 75 | EXPORT_SYMBOL_GPL(zpci_iomap_start); | 78 | EXPORT_SYMBOL_GPL(zpci_iomap_start); |
| 76 | 79 | ||
| @@ -265,27 +268,20 @@ void __iomem *pci_iomap_range(struct pci_dev *pdev, · 188 unmodified lines | |||
| 265 | unsigned long max) | 268 | unsigned long max) |
| 266 | { | 269 | { |
| 267 | struct zpci_dev *zdev = to_zpci(pdev); | 270 | struct zpci_dev *zdev = to_zpci(pdev); |
| 268 | u64 addr; | ||
| 269 | int idx; | 271 | int idx; |
| 270 | 272 | ||
| 271 | if ((bar & 7) != bar) | 273 | if (!pci_resource_len(pdev, bar)) |
| 272 | return NULL; | 274 | return NULL; |
| 273 | 275 | ||
| 274 | idx = zdev->bars[bar].map_idx; | 276 | idx = zdev->bars[bar].map_idx; |
| 275 | spin_lock(&zpci_iomap_lock); | 277 | spin_lock(&zpci_iomap_lock); |
| 276 | if (zpci_iomap_start[idx].count++) { | ||
| 277 | BUG_ON(zpci_iomap_start[idx].fh != zdev->fh || | ||
| 278 | zpci_iomap_start[idx].bar != bar); | ||
| 279 | } else { | ||
| 280 | zpci_iomap_start[idx].fh = zdev->fh; | ||
| 281 | zpci_iomap_start[idx].bar = bar; | ||
| 282 | } | ||
| 283 | /* Detect overrun */ | 278 | /* Detect overrun */ |
| 284 | BUG_ON(!zpci_iomap_start[idx].count); | 279 | WARN_ON(!++zpci_iomap_start[idx].count); |
| 280 | zpci_iomap_start[idx].fh = zdev->fh; | ||
| 281 | zpci_iomap_start[idx].bar = bar; | ||
| 285 | spin_unlock(&zpci_iomap_lock); | 282 | spin_unlock(&zpci_iomap_lock); |
| 286 | 283 | ||
| 287 | addr = ZPCI_IOMAP_ADDR_BASE | ((u64) idx << 48); | 284 | return (void __iomem *) ZPCI_ADDR(idx) + offset; |
| 288 | return (void __iomem *) addr + offset; | ||
| 289 | } | 285 | } |
| 290 | EXPORT_SYMBOL(pci_iomap_range); | 286 | EXPORT_SYMBOL(pci_iomap_range); |
| 291 | 287 | ||
| @@ -297,12 +293,11 @@ EXPORT_SYMBOL(pci_iomap); · 5 unmodified lines | |||
| 297 | 293 | ||
| 298 | void pci_iounmap(struct pci_dev *pdev, void __iomem *addr) | 294 | void pci_iounmap(struct pci_dev *pdev, void __iomem *addr) |
| 299 | { | 295 | { |
| 300 | unsigned int idx; | 296 | unsigned int idx = ZPCI_IDX(addr); |
| 301 | 297 | ||
| 302 | idx = (((__force u64) addr) & ~ZPCI_IOMAP_ADDR_BASE) >> 48; | ||
| 303 | spin_lock(&zpci_iomap_lock); | 298 | spin_lock(&zpci_iomap_lock); |
| 304 | /* Detect underrun */ | 299 | /* Detect underrun */ |
| 305 | BUG_ON(!zpci_iomap_start[idx].count); | 300 | WARN_ON(!zpci_iomap_start[idx].count); |
| 306 | if (!--zpci_iomap_start[idx].count) { | 301 | if (!--zpci_iomap_start[idx].count) { |
| 307 | zpci_iomap_start[idx].fh = 0; | 302 | zpci_iomap_start[idx].fh = 0; |
| 308 | zpci_iomap_start[idx].bar = 0; | 303 | zpci_iomap_start[idx].bar = 0; |
| @@ -544,15 +539,15 @@ static void zpci_irq_exit(void) · 235 unmodified lines | |||
| 544 | 539 | ||
| 545 | static int zpci_alloc_iomap(struct zpci_dev *zdev) | 540 | static int zpci_alloc_iomap(struct zpci_dev *zdev) |
| 546 | { | 541 | { |
| 547 | int entry; | 542 | unsigned long entry; |
| 548 | 543 | ||
| 549 | spin_lock(&zpci_iomap_lock); | 544 | spin_lock(&zpci_iomap_lock); |
| 550 | entry = find_first_zero_bit(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES); | 545 | entry = find_first_zero_bit(zpci_iomap_bitmap, ZPCI_IOMAP_ENTRIES); |
| 551 | if (entry == ZPCI_IOMAP_MAX_ENTRIES) { | 546 | if (entry == ZPCI_IOMAP_ENTRIES) { |
| 552 | spin_unlock(&zpci_iomap_lock); | 547 | spin_unlock(&zpci_iomap_lock); |
| 553 | return -ENOSPC; | 548 | return -ENOSPC; |
| 554 | } | 549 | } |
| 555 | set_bit(entry, zpci_iomap); | 550 | set_bit(entry, zpci_iomap_bitmap); |
| 556 | spin_unlock(&zpci_iomap_lock); | 551 | spin_unlock(&zpci_iomap_lock); |
| 557 | return entry; | 552 | return entry; |
| 558 | } | 553 | } |
| @@ -561,7 +556,7 @@ static void zpci_free_iomap(struct zpci_dev *zdev, int entry) · 2 unmodified lines | |||
| 561 | { | 556 | { |
| 562 | spin_lock(&zpci_iomap_lock); | 557 | spin_lock(&zpci_iomap_lock); |
| 563 | memset(&zpci_iomap_start[entry], 0, sizeof(struct zpci_iomap_entry)); | 558 | memset(&zpci_iomap_start[entry], 0, sizeof(struct zpci_iomap_entry)); |
| 564 | clear_bit(entry, zpci_iomap); | 559 | clear_bit(entry, zpci_iomap_bitmap); |
| 565 | spin_unlock(&zpci_iomap_lock); | 560 | spin_unlock(&zpci_iomap_lock); |
| 566 | } | 561 | } |
| 567 | 562 | ||
| @@ -611,8 +606,7 @@ static int zpci_setup_bus_resources(struct zpci_dev *zdev, · 43 unmodified lines | |||
| 611 | if (zdev->bars[i].val & 4) | 606 | if (zdev->bars[i].val & 4) |
| 612 | flags |= IORESOURCE_MEM_64; | 607 | flags |= IORESOURCE_MEM_64; |
| 613 | 608 | ||
| 614 | addr = ZPCI_IOMAP_ADDR_BASE + ((u64) entry << 48); | 609 | addr = ZPCI_ADDR(entry); |
| 615 | |||
| 616 | size = 1UL << zdev->bars[i].size; | 610 | size = 1UL << zdev->bars[i].size; |
| 617 | 611 | ||
| 618 | res = __alloc_res(zdev, addr, size, flags); | 612 | res = __alloc_res(zdev, addr, size, flags); |
| @@ -873,23 +867,30 @@ static int zpci_mem_init(void) · 254 unmodified lines | |||
| 873 | zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb), | 867 | zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb), |
| 874 | 16, 0, NULL); | 868 | 16, 0, NULL); |
| 875 | if (!zdev_fmb_cache) | 869 | if (!zdev_fmb_cache) |
| 876 | goto error_zdev; | 870 | goto error_fmb; |
| 877 | 871 | ||
| 878 | /* TODO: use realloc */ | 872 | zpci_iomap_start = kcalloc(ZPCI_IOMAP_ENTRIES, |
| 879 | zpci_iomap_start = kzalloc(ZPCI_IOMAP_MAX_ENTRIES * sizeof(*zpci_iomap_start), | 873 | sizeof(*zpci_iomap_start), GFP_KERNEL); |
| 880 | GFP_KERNEL); | ||
| 881 | if (!zpci_iomap_start) | 874 | if (!zpci_iomap_start) |
| 882 | goto error_iomap; | 875 | goto error_iomap; |
| 883 | return 0; | ||
| 884 | 876 | ||
| 877 | zpci_iomap_bitmap = kcalloc(BITS_TO_LONGS(ZPCI_IOMAP_ENTRIES), | ||
| 878 | sizeof(*zpci_iomap_bitmap), GFP_KERNEL); | ||
| 879 | if (!zpci_iomap_bitmap) | ||
| 880 | goto error_iomap_bitmap; | ||
| 881 | |||
| 882 | return 0; | ||
| 883 | error_iomap_bitmap: | ||
| 884 | kfree(zpci_iomap_start); | ||
| 885 | error_iomap: | 885 | error_iomap: |
| 886 | kmem_cache_destroy(zdev_fmb_cache); | 886 | kmem_cache_destroy(zdev_fmb_cache); |
| 887 | error_zdev: | 887 | error_fmb: |
| 888 | return -ENOMEM; | 888 | return -ENOMEM; |
| 889 | } | 889 | } |
| 890 | 890 | ||
| 891 | static void zpci_mem_exit(void) | 891 | static void zpci_mem_exit(void) |
| 892 | { | 892 | { |
| 893 | kfree(zpci_iomap_bitmap); | ||
| 893 | kfree(zpci_iomap_start); | 894 | kfree(zpci_iomap_start); |
| 894 | kmem_cache_destroy(zdev_fmb_cache); | 895 | kmem_cache_destroy(zdev_fmb_cache); |
| 895 | } | 896 | } |
| @@ -53,6 +53,11 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf) · 52 unmodified lines | |||
| 53 | 53 | ||
| 54 | pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n", | 54 | pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n", |
| 55 | pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); | 55 | pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); |
| 56 | |||
| 57 | if (!pdev) | ||
| 58 | return; | ||
| 59 | |||
| 60 | pdev->error_state = pci_channel_io_perm_failure; | ||
| 56 | } | 61 | } |
| 57 | 62 | ||
| 58 | void zpci_event_error(void *data) | 63 | void zpci_event_error(void *data) |
| @@ -33,7 +33,6 @@ · 32 unmodified lines | |||
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0) | 35 | #define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0) |
| 36 | #define smp_store_mb(var, value) __smp_store_mb(var, value) | ||
| 37 | 36 | ||
| 38 | #include <asm-generic/barrier.h> | 37 | #include <asm-generic/barrier.h> |
| 39 | 38 | ||
| @@ -509,11 +509,10 @@ config X86_INTEL_CE · 508 unmodified lines | |||
| 509 | 509 | ||
| 510 | config X86_INTEL_MID | 510 | config X86_INTEL_MID |
| 511 | bool "Intel MID platform support" | 511 | bool "Intel MID platform support" |
| 512 | depends on X86_32 | ||
| 513 | depends on X86_EXTENDED_PLATFORM | 512 | depends on X86_EXTENDED_PLATFORM |
| 514 | depends on X86_PLATFORM_DEVICES | 513 | depends on X86_PLATFORM_DEVICES |
| 515 | depends on PCI | 514 | depends on PCI |
| 516 | depends on PCI_GOANY | 515 | depends on X86_64 || (PCI_GOANY && X86_32) |
| 517 | depends on X86_IO_APIC | 516 | depends on X86_IO_APIC |
| 518 | select SFI | 517 | select SFI |
| 519 | select I2C | 518 | select I2C |
| @@ -23,11 +23,13 @@ extern void irq_ctx_init(int cpu); · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | #define __ARCH_HAS_DO_SOFTIRQ | 24 | #define __ARCH_HAS_DO_SOFTIRQ |
| 25 | 25 | ||
| 26 | struct irq_desc; | ||
| 27 | |||
| 26 | #ifdef CONFIG_HOTPLUG_CPU | 28 | #ifdef CONFIG_HOTPLUG_CPU |
| 27 | #include <linux/cpumask.h> | 29 | #include <linux/cpumask.h> |
| 28 | extern int check_irq_vectors_for_cpu_disable(void); | 30 | extern int check_irq_vectors_for_cpu_disable(void); |
| 29 | extern void fixup_irqs(void); | 31 | extern void fixup_irqs(void); |
| 30 | extern void irq_force_complete_move(int); | 32 | extern void irq_force_complete_move(struct irq_desc *desc); |
| 31 | #endif | 33 | #endif |
| 32 | 34 | ||
| 33 | #ifdef CONFIG_HAVE_KVM | 35 | #ifdef CONFIG_HAVE_KVM |
| @@ -37,7 +39,6 @@ extern void kvm_set_posted_intr_wakeup_handler(void (*handler)(void)); · 3 unmodified lines | |||
| 37 | extern void (*x86_platform_ipi_callback)(void); | 39 | extern void (*x86_platform_ipi_callback)(void); |
| 38 | extern void native_init_IRQ(void); | 40 | extern void native_init_IRQ(void); |
| 39 | 41 | ||
| 40 | struct irq_desc; | ||
| 41 | extern bool handle_irq(struct irq_desc *desc, struct pt_regs *regs); | 42 | extern bool handle_irq(struct irq_desc *desc, struct pt_regs *regs); |
| 42 | 43 | ||
| 43 | extern __visible unsigned int do_IRQ(struct pt_regs *regs); | 44 | extern __visible unsigned int do_IRQ(struct pt_regs *regs); |
| @@ -366,20 +366,18 @@ static inline enum page_cache_mode pgprot2cachemode(pgprot_t pgprot) · 365 unmodified lines | |||
| 366 | } | 366 | } |
| 367 | static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot) | 367 | static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot) |
| 368 | { | 368 | { |
| 369 | pgprotval_t val = pgprot_val(pgprot); | ||
| 369 | pgprot_t new; | 370 | pgprot_t new; |
| 370 | unsigned long val; | ||
| 371 | 371 | ||
| 372 | val = pgprot_val(pgprot); | ||
| 373 | pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) | | 372 | pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) | |
| 374 | ((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT)); | 373 | ((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT)); |
| 375 | return new; | 374 | return new; |
| 376 | } | 375 | } |
| 377 | static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot) | 376 | static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot) |
| 378 | { | 377 | { |
| 378 | pgprotval_t val = pgprot_val(pgprot); | ||
| 379 | pgprot_t new; | 379 | pgprot_t new; |
| 380 | unsigned long val; | ||
| 381 | 380 | ||
| 382 | val = pgprot_val(pgprot); | ||
| 383 | pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) | | 381 | pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) | |
| 384 | ((val & _PAGE_PAT_LARGE) >> | 382 | ((val & _PAGE_PAT_LARGE) >> |
| 385 | (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT)); | 383 | (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT)); |
| @@ -2521,6 +2521,7 @@ void __init setup_ioapic_dest(void) · 2520 unmodified lines | |||
| 2521 | { | 2521 | { |
| 2522 | int pin, ioapic, irq, irq_entry; | 2522 | int pin, ioapic, irq, irq_entry; |
| 2523 | const struct cpumask *mask; | 2523 | const struct cpumask *mask; |
| 2524 | struct irq_desc *desc; | ||
| 2524 | struct irq_data *idata; | 2525 | struct irq_data *idata; |
| 2525 | struct irq_chip *chip; | 2526 | struct irq_chip *chip; |
| 2526 | 2527 | ||
| @@ -2536,7 +2537,9 @@ void __init setup_ioapic_dest(void) · 9 unmodified lines | |||
| 2536 | if (irq < 0 || !mp_init_irq_at_boot(ioapic, irq)) | 2537 | if (irq < 0 || !mp_init_irq_at_boot(ioapic, irq)) |
| 2537 | continue; | 2538 | continue; |
| 2538 | 2539 | ||
| 2539 | idata = irq_get_irq_data(irq); | 2540 | desc = irq_to_desc(irq); |
| 2541 | raw_spin_lock_irq(&desc->lock); | ||
| 2542 | idata = irq_desc_get_irq_data(desc); | ||
| 2540 | 2543 | ||
| 2541 | /* | 2544 | /* |
| 2542 | * Honour affinities which have been set in early boot | 2545 | * Honour affinities which have been set in early boot |
| @@ -2550,6 +2553,7 @@ void __init setup_ioapic_dest(void) · 7 unmodified lines | |||
| 2550 | /* Might be lapic_chip for irq 0 */ | 2553 | /* Might be lapic_chip for irq 0 */ |
| 2551 | if (chip->irq_set_affinity) | 2554 | if (chip->irq_set_affinity) |
| 2552 | chip->irq_set_affinity(idata, mask, false); | 2555 | chip->irq_set_affinity(idata, mask, false); |
| 2556 | raw_spin_unlock_irq(&desc->lock); | ||
| 2553 | } | 2557 | } |
| 2554 | } | 2558 | } |
| 2555 | #endif | 2559 | #endif |
| @@ -31,7 +31,7 @@ struct apic_chip_data { · 30 unmodified lines | |||
| 31 | struct irq_domain *x86_vector_domain; | 31 | struct irq_domain *x86_vector_domain; |
| 32 | EXPORT_SYMBOL_GPL(x86_vector_domain); | 32 | EXPORT_SYMBOL_GPL(x86_vector_domain); |
| 33 | static DEFINE_RAW_SPINLOCK(vector_lock); | 33 | static DEFINE_RAW_SPINLOCK(vector_lock); |
| 34 | static cpumask_var_t vector_cpumask; | 34 | static cpumask_var_t vector_cpumask, vector_searchmask, searched_cpumask; |
| 35 | static struct irq_chip lapic_controller; | 35 | static struct irq_chip lapic_controller; |
| 36 | #ifdef CONFIG_X86_IO_APIC | 36 | #ifdef CONFIG_X86_IO_APIC |
| 37 | static struct apic_chip_data *legacy_irq_data[NR_IRQS_LEGACY]; | 37 | static struct apic_chip_data *legacy_irq_data[NR_IRQS_LEGACY]; |
| @@ -118,35 +118,47 @@ static int __assign_irq_vector(int irq, struct apic_chip_data *d, · 80 unmodified lines | |||
| 118 | */ | 118 | */ |
| 119 | static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; | 119 | static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; |
| 120 | static int current_offset = VECTOR_OFFSET_START % 16; | 120 | static int current_offset = VECTOR_OFFSET_START % 16; |
| 121 | int cpu, err; | 121 | int cpu, vector; |
| 122 | 122 | ||
| 123 | if (d->move_in_progress) | 123 | /* |
| 124 | * If there is still a move in progress or the previous move has not | ||
| 125 | * been cleaned up completely, tell the caller to come back later. | ||
| 126 | */ | ||
| 127 | if (d->move_in_progress || | ||
| 128 | cpumask_intersects(d->old_domain, cpu_online_mask)) | ||
| 124 | return -EBUSY; | 129 | return -EBUSY; |
| 125 | 130 | ||
| 126 | /* Only try and allocate irqs on cpus that are present */ | 131 | /* Only try and allocate irqs on cpus that are present */ |
| 127 | err = -ENOSPC; | ||
| 128 | cpumask_clear(d->old_domain); | 132 | cpumask_clear(d->old_domain); |
| 133 | cpumask_clear(searched_cpumask); | ||
| 129 | cpu = cpumask_first_and(mask, cpu_online_mask); | 134 | cpu = cpumask_first_and(mask, cpu_online_mask); |
| 130 | while (cpu < nr_cpu_ids) { | 135 | while (cpu < nr_cpu_ids) { |
| 131 | int new_cpu, vector, offset; | 136 | int new_cpu, offset; |
| 132 | 137 | ||
| 138 | /* Get the possible target cpus for @mask/@cpu from the apic */ | ||
| 133 | apic->vector_allocation_domain(cpu, vector_cpumask, mask); | 139 | apic->vector_allocation_domain(cpu, vector_cpumask, mask); |
| 134 | 140 | ||
| 141 | /* | ||
| 142 | * Clear the offline cpus from @vector_cpumask for searching | ||
| 143 | * and verify whether the result overlaps with @mask. If true, | ||
| 144 | * then the call to apic->cpu_mask_to_apicid_and() will | ||
| 145 | * succeed as well. If not, no point in trying to find a | ||
| 146 | * vector in this mask. | ||
| 147 | */ | ||
| 148 | cpumask_and(vector_searchmask, vector_cpumask, cpu_online_mask); | ||
| 149 | if (!cpumask_intersects(vector_searchmask, mask)) | ||
| 150 | goto next_cpu; | ||
| 151 | |||
| 135 | if (cpumask_subset(vector_cpumask, d->domain)) { | 152 | if (cpumask_subset(vector_cpumask, d->domain)) { |
| 136 | err = 0; | ||
| 137 | if (cpumask_equal(vector_cpumask, d->domain)) | 153 | if (cpumask_equal(vector_cpumask, d->domain)) |
| 138 | break; | 154 | goto success; |
| 139 | /* | 155 | /* |
| 140 | * New cpumask using the vector is a proper subset of | 156 | * Mark the cpus which are not longer in the mask for |
| 141 | * the current in use mask. So cleanup the vector | 157 | * cleanup. |
| 142 | * allocation for the members that are not used anymore. | ||
| 143 | */ | 158 | */ |
| 144 | cpumask_andnot(d->old_domain, d->domain, | 159 | cpumask_andnot(d->old_domain, d->domain, vector_cpumask); |
| 145 | vector_cpumask); | 160 | vector = d->cfg.vector; |
| 146 | d->move_in_progress = | 161 | goto update; |
| 147 | cpumask_intersects(d->old_domain, cpu_online_mask); | ||
| 148 | cpumask_and(d->domain, d->domain, vector_cpumask); | ||
| 149 | break; | ||
| 150 | } | 162 | } |
| 151 | 163 | ||
| 152 | vector = current_vector; | 164 | vector = current_vector; |
| @@ -158,45 +170,60 @@ next: · 5 unmodified lines | |||
| 158 | vector = FIRST_EXTERNAL_VECTOR + offset; | 170 | vector = FIRST_EXTERNAL_VECTOR + offset; |
| 159 | } | 171 | } |
| 160 | 172 | ||
| 161 | if (unlikely(current_vector == vector)) { | 173 | /* If the search wrapped around, try the next cpu */ |
| 162 | cpumask_or(d->old_domain, d->old_domain, | 174 | if (unlikely(current_vector == vector)) |
| 163 | vector_cpumask); | 175 | goto next_cpu; |
| 164 | cpumask_andnot(vector_cpumask, mask, d->old_domain); | ||
| 165 | cpu = cpumask_first_and(vector_cpumask, | ||
| 166 | cpu_online_mask); | ||
| 167 | continue; | ||
| 168 | } | ||
| 169 | 176 | ||
| 170 | if (test_bit(vector, used_vectors)) | 177 | if (test_bit(vector, used_vectors)) |
| 171 | goto next; | 178 | goto next; |
| 172 | 179 | ||
| 173 | for_each_cpu_and(new_cpu, vector_cpumask, cpu_online_mask) { | 180 | for_each_cpu(new_cpu, vector_searchmask) { |
| 174 | if (!IS_ERR_OR_NULL(per_cpu(vector_irq, new_cpu)[vector])) | 181 | if (!IS_ERR_OR_NULL(per_cpu(vector_irq, new_cpu)[vector])) |
| 175 | goto next; | 182 | goto next; |
| 176 | } | 183 | } |
| 177 | /* Found one! */ | 184 | /* Found one! */ |
| 178 | current_vector = vector; | 185 | current_vector = vector; |
| 179 | current_offset = offset; | 186 | current_offset = offset; |
| 180 | if (d->cfg.vector) { | 187 | /* Schedule the old vector for cleanup on all cpus */ |
| 188 | if (d->cfg.vector) | ||
| 181 | cpumask_copy(d->old_domain, d->domain); | 189 | cpumask_copy(d->old_domain, d->domain); |
| 182 | d->move_in_progress = | 190 | for_each_cpu(new_cpu, vector_searchmask) |
| 183 | cpumask_intersects(d->old_domain, cpu_online_mask); | ||
| 184 | } | ||
| 185 | for_each_cpu_and(new_cpu, vector_cpumask, cpu_online_mask) | ||
| 186 | per_cpu(vector_irq, new_cpu)[vector] = irq_to_desc(irq); | 191 | per_cpu(vector_irq, new_cpu)[vector] = irq_to_desc(irq); |
| 187 | d->cfg.vector = vector; | 192 | goto update; |
| 188 | cpumask_copy(d->domain, vector_cpumask); | ||
| 189 | err = 0; | ||
| 190 | break; | ||
| 191 | } | ||
| 192 | 193 | ||
| 193 | if (!err) { | 194 | next_cpu: |
| 194 | /* cache destination APIC IDs into cfg->dest_apicid */ | 195 | /* |
| 195 | err = apic->cpu_mask_to_apicid_and(mask, d->domain, | 196 | * We exclude the current @vector_cpumask from the requested |
| 196 | &d->cfg.dest_apicid); | 197 | * @mask and try again with the next online cpu in the |
| 198 | * result. We cannot modify @mask, so we use @vector_cpumask | ||
| 199 | * as a temporary buffer here as it will be reassigned when | ||
| 200 | * calling apic->vector_allocation_domain() above. | ||
| 201 | */ | ||
| 202 | cpumask_or(searched_cpumask, searched_cpumask, vector_cpumask); | ||
| 203 | cpumask_andnot(vector_cpumask, mask, searched_cpumask); | ||
| 204 | cpu = cpumask_first_and(vector_cpumask, cpu_online_mask); | ||
| 205 | continue; | ||
| 197 | } | 206 | } |
| 207 | return -ENOSPC; | ||
| 198 | 208 | ||
| 199 | return err; | 209 | update: |
| 210 | /* | ||
| 211 | * Exclude offline cpus from the cleanup mask and set the | ||
| 212 | * move_in_progress flag when the result is not empty. | ||
| 213 | */ | ||
| 214 | cpumask_and(d->old_domain, d->old_domain, cpu_online_mask); | ||
| 215 | d->move_in_progress = !cpumask_empty(d->old_domain); | ||
| 216 | d->cfg.vector = vector; | ||
| 217 | cpumask_copy(d->domain, vector_cpumask); | ||
| 218 | success: | ||
| 219 | /* | ||
| 220 | * Cache destination APIC IDs into cfg->dest_apicid. This cannot fail | ||
| 221 | * as we already established, that mask & d->domain & cpu_online_mask | ||
| 222 | * is not empty. | ||
| 223 | */ | ||
| 224 | BUG_ON(apic->cpu_mask_to_apicid_and(mask, d->domain, | ||
| 225 | &d->cfg.dest_apicid)); | ||
| 226 | return 0; | ||
| 200 | } | 227 | } |
| 201 | 228 | ||
| 202 | static int assign_irq_vector(int irq, struct apic_chip_data *data, | 229 | static int assign_irq_vector(int irq, struct apic_chip_data *data, |
| @@ -226,10 +253,8 @@ static int assign_irq_vector_policy(int irq, int node, · 23 unmodified lines | |||
| 226 | static void clear_irq_vector(int irq, struct apic_chip_data *data) | 253 | static void clear_irq_vector(int irq, struct apic_chip_data *data) |
| 227 | { | 254 | { |
| 228 | struct irq_desc *desc; | 255 | struct irq_desc *desc; |
| 229 | unsigned long flags; | ||
| 230 | int cpu, vector; | 256 | int cpu, vector; |
| 231 | 257 | ||
| 232 | raw_spin_lock_irqsave(&vector_lock, flags); | ||
| 233 | BUG_ON(!data->cfg.vector); | 258 | BUG_ON(!data->cfg.vector); |
| 234 | 259 | ||
| 235 | vector = data->cfg.vector; | 260 | vector = data->cfg.vector; |
| @@ -239,10 +264,13 @@ static void clear_irq_vector(int irq, struct apic_chip_data *data) · 3 unmodified lines | |||
| 239 | data->cfg.vector = 0; | 264 | data->cfg.vector = 0; |
| 240 | cpumask_clear(data->domain); | 265 | cpumask_clear(data->domain); |
| 241 | 266 | ||
| 242 | if (likely(!data->move_in_progress)) { | 267 | /* |
| 243 | raw_spin_unlock_irqrestore(&vector_lock, flags); | 268 | * If move is in progress or the old_domain mask is not empty, |
| 269 | * i.e. the cleanup IPI has not been processed yet, we need to remove | ||
| 270 | * the old references to desc from all cpus vector tables. | ||
| 271 | */ | ||
| 272 | if (!data->move_in_progress && cpumask_empty(data->old_domain)) | ||
| 244 | return; | 273 | return; |
| 245 | } | ||
| 246 | 274 | ||
| 247 | desc = irq_to_desc(irq); | 275 | desc = irq_to_desc(irq); |
| 248 | for_each_cpu_and(cpu, data->old_domain, cpu_online_mask) { | 276 | for_each_cpu_and(cpu, data->old_domain, cpu_online_mask) { |
| @@ -255,7 +283,6 @@ static void clear_irq_vector(int irq, struct apic_chip_data *data) · 6 unmodified lines | |||
| 255 | } | 283 | } |
| 256 | } | 284 | } |
| 257 | data->move_in_progress = 0; | 285 | data->move_in_progress = 0; |
| 258 | raw_spin_unlock_irqrestore(&vector_lock, flags); | ||
| 259 | } | 286 | } |
| 260 | 287 | ||
| 261 | void init_irq_alloc_info(struct irq_alloc_info *info, | 288 | void init_irq_alloc_info(struct irq_alloc_info *info, |
| @@ -276,19 +303,24 @@ void copy_irq_alloc_info(struct irq_alloc_info *dst, struct irq_alloc_info *src) · 14 unmodified lines | |||
| 276 | static void x86_vector_free_irqs(struct irq_domain *domain, | 303 | static void x86_vector_free_irqs(struct irq_domain *domain, |
| 277 | unsigned int virq, unsigned int nr_irqs) | 304 | unsigned int virq, unsigned int nr_irqs) |
| 278 | { | 305 | { |
| 306 | struct apic_chip_data *apic_data; | ||
| 279 | struct irq_data *irq_data; | 307 | struct irq_data *irq_data; |
| 308 | unsigned long flags; | ||
| 280 | int i; | 309 | int i; |
| 281 | 310 | ||
| 282 | for (i = 0; i < nr_irqs; i++) { | 311 | for (i = 0; i < nr_irqs; i++) { |
| 283 | irq_data = irq_domain_get_irq_data(x86_vector_domain, virq + i); | 312 | irq_data = irq_domain_get_irq_data(x86_vector_domain, virq + i); |
| 284 | if (irq_data && irq_data->chip_data) { | 313 | if (irq_data && irq_data->chip_data) { |
| 314 | raw_spin_lock_irqsave(&vector_lock, flags); | ||
| 285 | clear_irq_vector(virq + i, irq_data->chip_data); | 315 | clear_irq_vector(virq + i, irq_data->chip_data); |
| 286 | free_apic_chip_data(irq_data->chip_data); | 316 | apic_data = irq_data->chip_data; |
| 317 | irq_domain_reset_irq_data(irq_data); | ||
| 318 | raw_spin_unlock_irqrestore(&vector_lock, flags); | ||
| 319 | free_apic_chip_data(apic_data); | ||
| 287 | #ifdef CONFIG_X86_IO_APIC | 320 | #ifdef CONFIG_X86_IO_APIC |
| 288 | if (virq + i < nr_legacy_irqs()) | 321 | if (virq + i < nr_legacy_irqs()) |
| 289 | legacy_irq_data[virq + i] = NULL; | 322 | legacy_irq_data[virq + i] = NULL; |
| 290 | #endif | 323 | #endif |
| 291 | irq_domain_reset_irq_data(irq_data); | ||
| 292 | } | 324 | } |
| 293 | } | 325 | } |
| 294 | } | 326 | } |
| @@ -406,6 +438,8 @@ int __init arch_early_irq_init(void) · 111 unmodified lines | |||
| 406 | arch_init_htirq_domain(x86_vector_domain); | 438 | arch_init_htirq_domain(x86_vector_domain); |
| 407 | 439 | ||
| 408 | BUG_ON(!alloc_cpumask_var(&vector_cpumask, GFP_KERNEL)); | 440 | BUG_ON(!alloc_cpumask_var(&vector_cpumask, GFP_KERNEL)); |
| 441 | BUG_ON(!alloc_cpumask_var(&vector_searchmask, GFP_KERNEL)); | ||
| 442 | BUG_ON(!alloc_cpumask_var(&searched_cpumask, GFP_KERNEL)); | ||
| 409 | 443 | ||
| 410 | return arch_early_ioapic_init(); | 444 | return arch_early_ioapic_init(); |
| 411 | } | 445 | } |
| @@ -494,14 +528,7 @@ static int apic_set_affinity(struct irq_data *irq_data, · 82 unmodified lines | |||
| 494 | return -EINVAL; | 528 | return -EINVAL; |
| 495 | 529 | ||
| 496 | err = assign_irq_vector(irq, data, dest); | 530 | err = assign_irq_vector(irq, data, dest); |
| 497 | if (err) { | 531 | return err ? err : IRQ_SET_MASK_OK; |
| 498 | if (assign_irq_vector(irq, data, | ||
| 499 | irq_data_get_affinity_mask(irq_data))) | ||
| 500 | pr_err("Failed to recover vector for irq %d\n", irq); | ||
| 501 | return err; | ||
| 502 | } | ||
| 503 | |||
| 504 | return IRQ_SET_MASK_OK; | ||
| 505 | } | 532 | } |
| 506 | 533 | ||
| 507 | static struct irq_chip lapic_controller = { | 534 | static struct irq_chip lapic_controller = { |
| @@ -513,20 +540,12 @@ static struct irq_chip lapic_controller = { · 5 unmodified lines | |||
| 513 | #ifdef CONFIG_SMP | 540 | #ifdef CONFIG_SMP |
| 514 | static void __send_cleanup_vector(struct apic_chip_data *data) | 541 | static void __send_cleanup_vector(struct apic_chip_data *data) |
| 515 | { | 542 | { |
| 516 | cpumask_var_t cleanup_mask; | 543 | raw_spin_lock(&vector_lock); |
| 517 | 544 | cpumask_and(data->old_domain, data->old_domain, cpu_online_mask); | |
| 518 | if (unlikely(!alloc_cpumask_var(&cleanup_mask, GFP_ATOMIC))) { | ||
| 519 | unsigned int i; | ||
| 520 | |||
| 521 | for_each_cpu_and(i, data->old_domain, cpu_online_mask) | ||
| 522 | apic->send_IPI_mask(cpumask_of(i), | ||
| 523 | IRQ_MOVE_CLEANUP_VECTOR); | ||
| 524 | } else { | ||
| 525 | cpumask_and(cleanup_mask, data->old_domain, cpu_online_mask); | ||
| 526 | apic->send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); | ||
| 527 | free_cpumask_var(cleanup_mask); | ||
| 528 | } | ||
| 529 | data->move_in_progress = 0; | 545 | data->move_in_progress = 0; |
| 546 | if (!cpumask_empty(data->old_domain)) | ||
| 547 | apic->send_IPI_mask(data->old_domain, IRQ_MOVE_CLEANUP_VECTOR); | ||
| 548 | raw_spin_unlock(&vector_lock); | ||
| 530 | } | 549 | } |
| 531 | 550 | ||
| 532 | void send_cleanup_vector(struct irq_cfg *cfg) | 551 | void send_cleanup_vector(struct irq_cfg *cfg) |
| @@ -570,12 +589,25 @@ asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) · 37 unmodified lines | |||
| 570 | goto unlock; | 589 | goto unlock; |
| 571 | 590 | ||
| 572 | /* | 591 | /* |
| 573 | * Check if the irq migration is in progress. If so, we | 592 | * Nothing to cleanup if irq migration is in progress |
| 574 | * haven't received the cleanup request yet for this irq. | 593 | * or this cpu is not set in the cleanup mask. |
| 575 | */ | 594 | */ |
| 576 | if (data->move_in_progress) | 595 | if (data->move_in_progress || |
| 596 | !cpumask_test_cpu(me, data->old_domain)) | ||
| 577 | goto unlock; | 597 | goto unlock; |
| 578 | 598 | ||
| 599 | /* | ||
| 600 | * We have two cases to handle here: | ||
| 601 | * 1) vector is unchanged but the target mask got reduced | ||
| 602 | * 2) vector and the target mask has changed | ||
| 603 | * | ||
| 604 | * #1 is obvious, but in #2 we have two vectors with the same | ||
| 605 | * irq descriptor: the old and the new vector. So we need to | ||
| 606 | * make sure that we only cleanup the old vector. The new | ||
| 607 | * vector has the current @vector number in the config and | ||
| 608 | * this cpu is part of the target mask. We better leave that | ||
| 609 | * one alone. | ||
| 610 | */ | ||
| 579 | if (vector == data->cfg.vector && | 611 | if (vector == data->cfg.vector && |
| 580 | cpumask_test_cpu(me, data->domain)) | 612 | cpumask_test_cpu(me, data->domain)) |
| 581 | goto unlock; | 613 | goto unlock; |
| @@ -593,6 +625,7 @@ asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) · 11 unmodified lines | |||
| 593 | goto unlock; | 625 | goto unlock; |
| 594 | } | 626 | } |
| 595 | __this_cpu_write(vector_irq[vector], VECTOR_UNUSED); | 627 | __this_cpu_write(vector_irq[vector], VECTOR_UNUSED); |
| 628 | cpumask_clear_cpu(me, data->old_domain); | ||
| 596 | unlock: | 629 | unlock: |
| 597 | raw_spin_unlock(&desc->lock); | 630 | raw_spin_unlock(&desc->lock); |
| 598 | } | 631 | } |
| @@ -621,12 +654,48 @@ void irq_complete_move(struct irq_cfg *cfg) · 22 unmodified lines | |||
| 621 | __irq_complete_move(cfg, ~get_irq_regs()->orig_ax); | 654 | __irq_complete_move(cfg, ~get_irq_regs()->orig_ax); |
| 622 | } | 655 | } |
| 623 | 656 | ||
| 624 | void irq_force_complete_move(int irq) | 657 | /* |
| 658 | * Called with @desc->lock held and interrupts disabled. | ||
| 659 | */ | ||
| 660 | void irq_force_complete_move(struct irq_desc *desc) | ||
| 625 | { | 661 | { |
| 626 | struct irq_cfg *cfg = irq_cfg(irq); | 662 | struct irq_data *irqdata = irq_desc_get_irq_data(desc); |
| 663 | struct apic_chip_data *data = apic_chip_data(irqdata); | ||
| 664 | struct irq_cfg *cfg = data ? &data->cfg : NULL; | ||
| 627 | 665 | ||
| 628 | if (cfg) | 666 | if (!cfg) |
| 629 | __irq_complete_move(cfg, cfg->vector); | 667 | return; |
| 668 | |||
| 669 | __irq_complete_move(cfg, cfg->vector); | ||
| 670 | |||
| 671 | /* | ||
| 672 | * This is tricky. If the cleanup of @data->old_domain has not been | ||
| 673 | * done yet, then the following setaffinity call will fail with | ||
| 674 | * -EBUSY. This can leave the interrupt in a stale state. | ||
| 675 | * | ||
| 676 | * The cleanup cannot make progress because we hold @desc->lock. So in | ||
| 677 | * case @data->old_domain is not yet cleaned up, we need to drop the | ||
| 678 | * lock and acquire it again. @desc cannot go away, because the | ||
| 679 | * hotplug code holds the sparse irq lock. | ||
| 680 | */ | ||
| 681 | raw_spin_lock(&vector_lock); | ||
| 682 | /* Clean out all offline cpus (including ourself) first. */ | ||
| 683 | cpumask_and(data->old_domain, data->old_domain, cpu_online_mask); | ||
| 684 | while (!cpumask_empty(data->old_domain)) { | ||
| 685 | raw_spin_unlock(&vector_lock); | ||
| 686 | raw_spin_unlock(&desc->lock); | ||
| 687 | cpu_relax(); | ||
| 688 | raw_spin_lock(&desc->lock); | ||
| 689 | /* | ||
| 690 | * Reevaluate apic_chip_data. It might have been cleared after | ||
| 691 | * we dropped @desc->lock. | ||
| 692 | */ | ||
| 693 | data = apic_chip_data(irqdata); | ||
| 694 | if (!data) | ||
| 695 | return; | ||
| 696 | raw_spin_lock(&vector_lock); | ||
| 697 | } | ||
| 698 | raw_spin_unlock(&vector_lock); | ||
| 630 | } | 699 | } |
| 631 | #endif | 700 | #endif |
| 632 | 701 | ||
| @@ -889,7 +889,10 @@ void __init uv_system_init(void) · 888 unmodified lines | |||
| 889 | return; | 889 | return; |
| 890 | } | 890 | } |
| 891 | pr_info("UV: Found %s hub\n", hub); | 891 | pr_info("UV: Found %s hub\n", hub); |
| 892 | map_low_mmrs(); | 892 | |
| 893 | /* We now only need to map the MMRs on UV1 */ | ||
| 894 | if (is_uv1_hub()) | ||
| 895 | map_low_mmrs(); | ||
| 893 | 896 | ||
| 894 | m_n_config.v = uv_read_local_mmr(UVH_RH_GAM_CONFIG_MMR ); | 897 | m_n_config.v = uv_read_local_mmr(UVH_RH_GAM_CONFIG_MMR ); |
| 895 | m_val = m_n_config.s.m_skt; | 898 | m_val = m_n_config.s.m_skt; |
| @@ -1960,7 +1960,8 @@ intel_bts_constraints(struct perf_event *event) · 1959 unmodified lines | |||
| 1960 | 1960 | ||
| 1961 | static int intel_alt_er(int idx, u64 config) | 1961 | static int intel_alt_er(int idx, u64 config) |
| 1962 | { | 1962 | { |
| 1963 | int alt_idx; | 1963 | int alt_idx = idx; |
| 1964 | |||
| 1964 | if (!(x86_pmu.flags & PMU_FL_HAS_RSP_1)) | 1965 | if (!(x86_pmu.flags & PMU_FL_HAS_RSP_1)) |
| 1965 | return idx; | 1966 | return idx; |
| 1966 | 1967 | ||
| @@ -2897,14 +2898,12 @@ static void intel_pmu_cpu_starting(int cpu) · 930 unmodified lines | |||
| 2897 | return; | 2898 | return; |
| 2898 | 2899 | ||
| 2899 | if (!(x86_pmu.flags & PMU_FL_NO_HT_SHARING)) { | 2900 | if (!(x86_pmu.flags & PMU_FL_NO_HT_SHARING)) { |
| 2900 | void **onln = &cpuc->kfree_on_online[X86_PERF_KFREE_SHARED]; | ||
| 2901 | |||
| 2902 | for_each_cpu(i, topology_sibling_cpumask(cpu)) { | 2901 | for_each_cpu(i, topology_sibling_cpumask(cpu)) { |
| 2903 | struct intel_shared_regs *pc; | 2902 | struct intel_shared_regs *pc; |
| 2904 | 2903 | ||
| 2905 | pc = per_cpu(cpu_hw_events, i).shared_regs; | 2904 | pc = per_cpu(cpu_hw_events, i).shared_regs; |
| 2906 | if (pc && pc->core_id == core_id) { | 2905 | if (pc && pc->core_id == core_id) { |
| 2907 | *onln = cpuc->shared_regs; | 2906 | cpuc->kfree_on_online[0] = cpuc->shared_regs; |
| 2908 | cpuc->shared_regs = pc; | 2907 | cpuc->shared_regs = pc; |
| 2909 | break; | 2908 | break; |
| 2910 | } | 2909 | } |
| @@ -995,6 +995,9 @@ static int __init uncore_pci_init(void) · 994 unmodified lines | |||
| 995 | case 87: /* Knights Landing */ | 995 | case 87: /* Knights Landing */ |
| 996 | ret = knl_uncore_pci_init(); | 996 | ret = knl_uncore_pci_init(); |
| 997 | break; | 997 | break; |
| 998 | case 94: /* SkyLake */ | ||
| 999 | ret = skl_uncore_pci_init(); | ||
| 1000 | break; | ||
| 998 | default: | 1001 | default: |
| 999 | return 0; | 1002 | return 0; |
| 1000 | } | 1003 | } |
| @@ -336,6 +336,7 @@ int snb_uncore_pci_init(void); · 335 unmodified lines | |||
| 336 | int ivb_uncore_pci_init(void); | 336 | int ivb_uncore_pci_init(void); |
| 337 | int hsw_uncore_pci_init(void); | 337 | int hsw_uncore_pci_init(void); |
| 338 | int bdw_uncore_pci_init(void); | 338 | int bdw_uncore_pci_init(void); |
| 339 | int skl_uncore_pci_init(void); | ||
| 339 | void snb_uncore_cpu_init(void); | 340 | void snb_uncore_cpu_init(void); |
| 340 | void nhm_uncore_cpu_init(void); | 341 | void nhm_uncore_cpu_init(void); |
| 341 | int snb_pci2phy_map_init(int devid); | 342 | int snb_pci2phy_map_init(int devid); |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #define PCI_DEVICE_ID_INTEL_HSW_IMC 0x0c00 | 8 | #define PCI_DEVICE_ID_INTEL_HSW_IMC 0x0c00 |
| 9 | #define PCI_DEVICE_ID_INTEL_HSW_U_IMC 0x0a04 | 9 | #define PCI_DEVICE_ID_INTEL_HSW_U_IMC 0x0a04 |
| 10 | #define PCI_DEVICE_ID_INTEL_BDW_IMC 0x1604 | 10 | #define PCI_DEVICE_ID_INTEL_BDW_IMC 0x1604 |
| 11 | #define PCI_DEVICE_ID_INTEL_SKL_IMC 0x191f | ||
| 11 | 12 | ||
| 12 | /* SNB event control */ | 13 | /* SNB event control */ |
| 13 | #define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff | 14 | #define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff |
| @@ -524,6 +525,14 @@ static const struct pci_device_id bdw_uncore_pci_ids[] = { · 510 unmodified lines | |||
| 524 | { /* end: all zeroes */ }, | 525 | { /* end: all zeroes */ }, |
| 525 | }; | 526 | }; |
| 526 | 527 | ||
| 528 | static const struct pci_device_id skl_uncore_pci_ids[] = { | ||
| 529 | { /* IMC */ | ||
| 530 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_IMC), | ||
| 531 | .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0), | ||
| 532 | }, | ||
| 533 | { /* end: all zeroes */ }, | ||
| 534 | }; | ||
| 535 | |||
| 527 | static struct pci_driver snb_uncore_pci_driver = { | 536 | static struct pci_driver snb_uncore_pci_driver = { |
| 528 | .name = "snb_uncore", | 537 | .name = "snb_uncore", |
| 529 | .id_table = snb_uncore_pci_ids, | 538 | .id_table = snb_uncore_pci_ids, |
| @@ -544,6 +553,11 @@ static struct pci_driver bdw_uncore_pci_driver = { · 14 unmodified lines | |||
| 544 | .id_table = bdw_uncore_pci_ids, | 553 | .id_table = bdw_uncore_pci_ids, |
| 545 | }; | 554 | }; |
| 546 | 555 | ||
| 556 | static struct pci_driver skl_uncore_pci_driver = { | ||
| 557 | .name = "skl_uncore", | ||
| 558 | .id_table = skl_uncore_pci_ids, | ||
| 559 | }; | ||
| 560 | |||
| 547 | struct imc_uncore_pci_dev { | 561 | struct imc_uncore_pci_dev { |
| 548 | __u32 pci_id; | 562 | __u32 pci_id; |
| 549 | struct pci_driver *driver; | 563 | struct pci_driver *driver; |
| @@ -558,6 +572,7 @@ static const struct imc_uncore_pci_dev desktop_imc_pci_ids[] = { · 8 unmodified lines | |||
| 558 | IMC_DEV(HSW_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core Processor */ | 572 | IMC_DEV(HSW_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core Processor */ |
| 559 | IMC_DEV(HSW_U_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core ULT Mobile Processor */ | 573 | IMC_DEV(HSW_U_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core ULT Mobile Processor */ |
| 560 | IMC_DEV(BDW_IMC, &bdw_uncore_pci_driver), /* 5th Gen Core U */ | 574 | IMC_DEV(BDW_IMC, &bdw_uncore_pci_driver), /* 5th Gen Core U */ |
| 575 | IMC_DEV(SKL_IMC, &skl_uncore_pci_driver), /* 6th Gen Core */ | ||
| 561 | { /* end marker */ } | 576 | { /* end marker */ } |
| 562 | }; | 577 | }; |
| 563 | 578 | ||
| @@ -610,6 +625,11 @@ int bdw_uncore_pci_init(void) · 46 unmodified lines | |||
| 610 | return imc_uncore_pci_init(); | 625 | return imc_uncore_pci_init(); |
| 611 | } | 626 | } |
| 612 | 627 | ||
| 628 | int skl_uncore_pci_init(void) | ||
| 629 | { | ||
| 630 | return imc_uncore_pci_init(); | ||
| 631 | } | ||
| 632 | |||
| 613 | /* end of Sandy Bridge uncore support */ | 633 | /* end of Sandy Bridge uncore support */ |
| 614 | 634 | ||
| 615 | /* Nehalem uncore support */ | 635 | /* Nehalem uncore support */ |
| @@ -192,5 +192,13 @@ void __init x86_64_start_reservations(char *real_mode_data) · 191 unmodified lines | |||
| 192 | 192 | ||
| 193 | reserve_ebda_region(); | 193 | reserve_ebda_region(); |
| 194 | 194 | ||
| 195 | switch (boot_params.hdr.hardware_subarch) { | ||
| 196 | case X86_SUBARCH_INTEL_MID: | ||
| 197 | x86_intel_mid_early_setup(); | ||
| 198 | break; | ||
| 199 | default: | ||
| 200 | break; | ||
| 201 | } | ||
| 202 | |||
| 195 | start_kernel(); | 203 | start_kernel(); |
| 196 | } | 204 | } |
| @@ -462,7 +462,7 @@ void fixup_irqs(void) · 461 unmodified lines | |||
| 462 | * non intr-remapping case, we can't wait till this interrupt | 462 | * non intr-remapping case, we can't wait till this interrupt |
| 463 | * arrives at this cpu before completing the irq move. | 463 | * arrives at this cpu before completing the irq move. |
| 464 | */ | 464 | */ |
| 465 | irq_force_complete_move(irq); | 465 | irq_force_complete_move(desc); |
| 466 | 466 | ||
| 467 | if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) { | 467 | if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) { |
| 468 | break_affinity = 1; | 468 | break_affinity = 1; |
| @@ -470,6 +470,15 @@ void fixup_irqs(void) · 1 unmodified line | |||
| 470 | } | 470 | } |
| 471 | 471 | ||
| 472 | chip = irq_data_get_irq_chip(data); | 472 | chip = irq_data_get_irq_chip(data); |
| 473 | /* | ||
| 474 | * The interrupt descriptor might have been cleaned up | ||
| 475 | * already, but it is not yet removed from the radix tree | ||
| 476 | */ | ||
| 477 | if (!chip) { | ||
| 478 | raw_spin_unlock(&desc->lock); | ||
| 479 | continue; | ||
| 480 | } | ||
| 481 | |||
| 473 | if (!irqd_can_move_in_process_context(data) && chip->irq_mask) | 482 | if (!irqd_can_move_in_process_context(data) && chip->irq_mask) |
| 474 | chip->irq_mask(data); | 483 | chip->irq_mask(data); |
| 475 | 484 | ||
| @@ -33,7 +33,7 @@ struct cpa_data { · 32 unmodified lines | |||
| 33 | pgd_t *pgd; | 33 | pgd_t *pgd; |
| 34 | pgprot_t mask_set; | 34 | pgprot_t mask_set; |
| 35 | pgprot_t mask_clr; | 35 | pgprot_t mask_clr; |
| 36 | int numpages; | 36 | unsigned long numpages; |
| 37 | int flags; | 37 | int flags; |
| 38 | unsigned long pfn; | 38 | unsigned long pfn; |
| 39 | unsigned force_split : 1; | 39 | unsigned force_split : 1; |
| @@ -1350,7 +1350,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) · 1310 unmodified lines | |||
| 1350 | * CPA operation. Either a large page has been | 1350 | * CPA operation. Either a large page has been |
| 1351 | * preserved or a single page update happened. | 1351 | * preserved or a single page update happened. |
| 1352 | */ | 1352 | */ |
| 1353 | BUG_ON(cpa->numpages > numpages); | 1353 | BUG_ON(cpa->numpages > numpages || !cpa->numpages); |
| 1354 | numpages -= cpa->numpages; | 1354 | numpages -= cpa->numpages; |
| 1355 | if (cpa->flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) | 1355 | if (cpa->flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) |
| 1356 | cpa->curpage++; | 1356 | cpa->curpage++; |
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <linux/memblock.h> | 8 | #include <linux/memblock.h> |
| 9 | #include <linux/bootmem.h> | 9 | #include <linux/bootmem.h> |
| 10 | #include <linux/acpi.h> | 10 | #include <linux/acpi.h> |
| 11 | #include <linux/dmi.h> | ||
| 11 | #include <asm/efi.h> | 12 | #include <asm/efi.h> |
| 12 | #include <asm/uv/uv.h> | 13 | #include <asm/uv/uv.h> |
| 13 | 14 | ||
| @@ -248,6 +249,16 @@ out: · 234 unmodified lines | |||
| 248 | return ret; | 249 | return ret; |
| 249 | } | 250 | } |
| 250 | 251 | ||
| 252 | static const struct dmi_system_id sgi_uv1_dmi[] = { | ||
| 253 | { NULL, "SGI UV1", | ||
| 254 | { DMI_MATCH(DMI_PRODUCT_NAME, "Stoutland Platform"), | ||
| 255 | DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"), | ||
| 256 | DMI_MATCH(DMI_BIOS_VENDOR, "SGI.COM"), | ||
| 257 | } | ||
| 258 | }, | ||
| 259 | { } /* NULL entry stops DMI scanning */ | ||
| 260 | }; | ||
| 261 | |||
| 251 | void __init efi_apply_memmap_quirks(void) | 262 | void __init efi_apply_memmap_quirks(void) |
| 252 | { | 263 | { |
| 253 | /* | 264 | /* |
| @@ -260,10 +271,8 @@ void __init efi_apply_memmap_quirks(void) · 6 unmodified lines | |||
| 260 | efi_unmap_memmap(); | 271 | efi_unmap_memmap(); |
| 261 | } | 272 | } |
| 262 | 273 | ||
| 263 | /* | 274 | /* UV2+ BIOS has a fix for this issue. UV1 still needs the quirk. */ |
| 264 | * UV doesn't support the new EFI pagetable mapping yet. | 275 | if (dmi_check_system(sgi_uv1_dmi)) |
| 265 | */ | ||
| 266 | if (is_uv_system()) | ||
| 267 | set_bit(EFI_OLD_MEMMAP, &efi.flags); | 276 | set_bit(EFI_OLD_MEMMAP, &efi.flags); |
| 268 | } | 277 | } |
| 269 | 278 | ||
| @@ -138,7 +138,7 @@ static void intel_mid_arch_setup(void) · 137 unmodified lines | |||
| 138 | intel_mid_ops = get_intel_mid_ops[__intel_mid_cpu_chip](); | 138 | intel_mid_ops = get_intel_mid_ops[__intel_mid_cpu_chip](); |
| 139 | else { | 139 | else { |
| 140 | intel_mid_ops = get_intel_mid_ops[INTEL_MID_CPU_CHIP_PENWELL](); | 140 | intel_mid_ops = get_intel_mid_ops[INTEL_MID_CPU_CHIP_PENWELL](); |
| 141 | pr_info("ARCH: Unknown SoC, assuming PENWELL!\n"); | 141 | pr_info("ARCH: Unknown SoC, assuming Penwell!\n"); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | out: | 144 | out: |
| @@ -214,12 +214,10 @@ static inline int __init setup_x86_intel_mid_timer(char *arg) · 69 unmodified lines | |||
| 214 | else if (strcmp("lapic_and_apbt", arg) == 0) | 214 | else if (strcmp("lapic_and_apbt", arg) == 0) |
| 215 | intel_mid_timer_options = INTEL_MID_TIMER_LAPIC_APBT; | 215 | intel_mid_timer_options = INTEL_MID_TIMER_LAPIC_APBT; |
| 216 | else { | 216 | else { |
| 217 | pr_warn("X86 INTEL_MID timer option %s not recognised" | 217 | pr_warn("X86 INTEL_MID timer option %s not recognised use x86_intel_mid_timer=apbt_only or lapic_and_apbt\n", |
| 218 | " use x86_intel_mid_timer=apbt_only or lapic_and_apbt\n", | 218 | arg); |
| 219 | arg); | ||
| 220 | return -EINVAL; | 219 | return -EINVAL; |
| 221 | } | 220 | } |
| 222 | return 0; | 221 | return 0; |
| 223 | } | 222 | } |
| 224 | __setup("x86_intel_mid_timer=", setup_x86_intel_mid_timer); | 223 | __setup("x86_intel_mid_timer=", setup_x86_intel_mid_timer); |
| 225 | |||
| @@ -220,11 +220,12 @@ static int imr_dbgfs_state_show(struct seq_file *s, void *unused) · 219 unmodified lines | |||
| 220 | if (imr_is_enabled(&imr)) { | 220 | if (imr_is_enabled(&imr)) { |
| 221 | base = imr_to_phys(imr.addr_lo); | 221 | base = imr_to_phys(imr.addr_lo); |
| 222 | end = imr_to_phys(imr.addr_hi) + IMR_MASK; | 222 | end = imr_to_phys(imr.addr_hi) + IMR_MASK; |
| 223 | size = end - base + 1; | ||
| 223 | } else { | 224 | } else { |
| 224 | base = 0; | 225 | base = 0; |
| 225 | end = 0; | 226 | end = 0; |
| 227 | size = 0; | ||
| 226 | } | 228 | } |
| 227 | size = end - base; | ||
| 228 | seq_printf(s, "imr%02i: base=%pa, end=%pa, size=0x%08zx " | 229 | seq_printf(s, "imr%02i: base=%pa, end=%pa, size=0x%08zx " |
| 229 | "rmask=0x%08x, wmask=0x%08x, %s, %s\n", i, | 230 | "rmask=0x%08x, wmask=0x%08x, %s, %s\n", i, |
| 230 | &base, &end, size, imr.rmask, imr.wmask, | 231 | &base, &end, size, imr.rmask, imr.wmask, |
| @@ -579,6 +580,7 @@ static void __init imr_fixup_memmap(struct imr_device *idev) · 348 unmodified lines | |||
| 579 | { | 580 | { |
| 580 | phys_addr_t base = virt_to_phys(&_text); | 581 | phys_addr_t base = virt_to_phys(&_text); |
| 581 | size_t size = virt_to_phys(&__end_rodata) - base; | 582 | size_t size = virt_to_phys(&__end_rodata) - base; |
| 583 | unsigned long start, end; | ||
| 582 | int i; | 584 | int i; |
| 583 | int ret; | 585 | int ret; |
| 584 | 586 | ||
| @@ -586,18 +588,24 @@ static void __init imr_fixup_memmap(struct imr_device *idev) · 1 unmodified line | |||
| 586 | for (i = 0; i < idev->max_imr; i++) | 588 | for (i = 0; i < idev->max_imr; i++) |
| 587 | imr_clear(i); | 589 | imr_clear(i); |
| 588 | 590 | ||
| 591 | start = (unsigned long)_text; | ||
| 592 | end = (unsigned long)__end_rodata - 1; | ||
| 593 | |||
| 589 | /* | 594 | /* |
| 590 | * Setup a locked IMR around the physical extent of the kernel | 595 | * Setup a locked IMR around the physical extent of the kernel |
| 591 | * from the beginning of the .text secton to the end of the | 596 | * from the beginning of the .text secton to the end of the |
| 592 | * .rodata section as one physically contiguous block. | 597 | * .rodata section as one physically contiguous block. |
| 598 | * | ||
| 599 | * We don't round up @size since it is already PAGE_SIZE aligned. | ||
| 600 | * See vmlinux.lds.S for details. | ||
| 593 | */ | 601 | */ |
| 594 | ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true); | 602 | ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true); |
| 595 | if (ret < 0) { | 603 | if (ret < 0) { |
| 596 | pr_err("unable to setup IMR for kernel: (%p - %p)\n", | 604 | pr_err("unable to setup IMR for kernel: %zu KiB (%lx - %lx)\n", |
| 597 | &_text, &__end_rodata); | 605 | size / 1024, start, end); |
| 598 | } else { | 606 | } else { |
| 599 | pr_info("protecting kernel .text - .rodata: %zu KiB (%p - %p)\n", | 607 | pr_info("protecting kernel .text - .rodata: %zu KiB (%lx - %lx)\n", |
| 600 | size / 1024, &_text, &__end_rodata); | 608 | size / 1024, start, end); |
| 601 | } | 609 | } |
| 602 | 610 | ||
| 603 | } | 611 | } |
| @@ -70,6 +70,18 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q, · 69 unmodified lines | |||
| 70 | return bio_split(bio, q->limits.max_write_same_sectors, GFP_NOIO, bs); | 70 | return bio_split(bio, q->limits.max_write_same_sectors, GFP_NOIO, bs); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static inline unsigned get_max_io_size(struct request_queue *q, | ||
| 74 | struct bio *bio) | ||
| 75 | { | ||
| 76 | unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector); | ||
| 77 | unsigned mask = queue_logical_block_size(q) - 1; | ||
| 78 | |||
| 79 | /* aligned to logical block size */ | ||
| 80 | sectors &= ~(mask >> 9); | ||
| 81 | |||
| 82 | return sectors; | ||
| 83 | } | ||
| 84 | |||
| 73 | static struct bio *blk_bio_segment_split(struct request_queue *q, | 85 | static struct bio *blk_bio_segment_split(struct request_queue *q, |
| 74 | struct bio *bio, | 86 | struct bio *bio, |
| 75 | struct bio_set *bs, | 87 | struct bio_set *bs, |
| @@ -81,6 +93,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, · 5 unmodified lines | |||
| 81 | unsigned front_seg_size = bio->bi_seg_front_size; | 93 | unsigned front_seg_size = bio->bi_seg_front_size; |
| 82 | bool do_split = true; | 94 | bool do_split = true; |
| 83 | struct bio *new = NULL; | 95 | struct bio *new = NULL; |
| 96 | const unsigned max_sectors = get_max_io_size(q, bio); | ||
| 84 | 97 | ||
| 85 | bio_for_each_segment(bv, bio, iter) { | 98 | bio_for_each_segment(bv, bio, iter) { |
| 86 | /* | 99 | /* |
| @@ -90,20 +103,19 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, · 3 unmodified lines | |||
| 90 | if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset)) | 103 | if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset)) |
| 91 | goto split; | 104 | goto split; |
| 92 | 105 | ||
| 93 | if (sectors + (bv.bv_len >> 9) > | 106 | if (sectors + (bv.bv_len >> 9) > max_sectors) { |
| 94 | blk_max_size_offset(q, bio->bi_iter.bi_sector)) { | ||
| 95 | /* | 107 | /* |
| 96 | * Consider this a new segment if we're splitting in | 108 | * Consider this a new segment if we're splitting in |
| 97 | * the middle of this vector. | 109 | * the middle of this vector. |
| 98 | */ | 110 | */ |
| 99 | if (nsegs < queue_max_segments(q) && | 111 | if (nsegs < queue_max_segments(q) && |
| 100 | sectors < blk_max_size_offset(q, | 112 | sectors < max_sectors) { |
| 101 | bio->bi_iter.bi_sector)) { | ||
| 102 | nsegs++; | 113 | nsegs++; |
| 103 | sectors = blk_max_size_offset(q, | 114 | sectors = max_sectors; |
| 104 | bio->bi_iter.bi_sector); | ||
| 105 | } | 115 | } |
| 106 | goto split; | 116 | if (sectors) |
| 117 | goto split; | ||
| 118 | /* Make this single bvec as the 1st segment */ | ||
| 107 | } | 119 | } |
| 108 | 120 | ||
| 109 | if (bvprvp && blk_queue_cluster(q)) { | 121 | if (bvprvp && blk_queue_cluster(q)) { |
| @@ -135,14 +135,6 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 134 unmodified lines | |||
| 135 | DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), | 135 | DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), |
| 136 | }, | 136 | }, |
| 137 | }, | 137 | }, |
| 138 | { | ||
| 139 | .callback = video_detect_force_vendor, | ||
| 140 | .ident = "Dell Inspiron 5737", | ||
| 141 | .matches = { | ||
| 142 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
| 143 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"), | ||
| 144 | }, | ||
| 145 | }, | ||
| 146 | 138 | ||
| 147 | /* | 139 | /* |
| 148 | * These models have a working acpi_video backlight control, and using | 140 | * These models have a working acpi_video backlight control, and using |
| @@ -284,6 +284,7 @@ out_free_priv_data: · 283 unmodified lines | |||
| 284 | 284 | ||
| 285 | return err; | 285 | return err; |
| 286 | } | 286 | } |
| 287 | EXPORT_SYMBOL_GPL(platform_msi_domain_alloc_irqs); | ||
| 287 | 288 | ||
| 288 | /** | 289 | /** |
| 289 | * platform_msi_domain_free_irqs - Free MSI interrupts for @dev | 290 | * platform_msi_domain_free_irqs - Free MSI interrupts for @dev |
| @@ -301,6 +302,7 @@ void platform_msi_domain_free_irqs(struct device *dev) · 11 unmodified lines | |||
| 301 | msi_domain_free_irqs(dev->msi_domain, dev); | 302 | msi_domain_free_irqs(dev->msi_domain, dev); |
| 302 | platform_msi_free_descs(dev, 0, MAX_DEV_MSIS); | 303 | platform_msi_free_descs(dev, 0, MAX_DEV_MSIS); |
| 303 | } | 304 | } |
| 305 | EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs); | ||
| 304 | 306 | ||
| 305 | /** | 307 | /** |
| 306 | * platform_msi_get_host_data - Query the private data associated with | 308 | * platform_msi_get_host_data - Query the private data associated with |
| @@ -558,10 +558,15 @@ static int platform_drv_probe(struct device *_dev) · 557 unmodified lines | |||
| 558 | return ret; | 558 | return ret; |
| 559 | 559 | ||
| 560 | ret = dev_pm_domain_attach(_dev, true); | 560 | ret = dev_pm_domain_attach(_dev, true); |
| 561 | if (ret != -EPROBE_DEFER && drv->probe) { | 561 | if (ret != -EPROBE_DEFER) { |
| 562 | ret = drv->probe(dev); | 562 | if (drv->probe) { |
| 563 | if (ret) | 563 | ret = drv->probe(dev); |
| 564 | dev_pm_domain_detach(_dev, true); | 564 | if (ret) |
| 565 | dev_pm_domain_detach(_dev, true); | ||
| 566 | } else { | ||
| 567 | /* don't fail if just dev_pm_domain_attach failed */ | ||
| 568 | ret = 0; | ||
| 569 | } | ||
| 565 | } | 570 | } |
| 566 | 571 | ||
| 567 | if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) { | 572 | if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) { |
| @@ -162,7 +162,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool timed) · 161 unmodified lines | |||
| 162 | 162 | ||
| 163 | /** | 163 | /** |
| 164 | * genpd_queue_power_off_work - Queue up the execution of genpd_poweroff(). | 164 | * genpd_queue_power_off_work - Queue up the execution of genpd_poweroff(). |
| 165 | * @genpd: PM domait to power off. | 165 | * @genpd: PM domain to power off. |
| 166 | * | 166 | * |
| 167 | * Queue up the execution of genpd_poweroff() unless it's already been done | 167 | * Queue up the execution of genpd_poweroff() unless it's already been done |
| 168 | * before. | 168 | * before. |
| @@ -172,16 +172,15 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) · 3 unmodified lines | |||
| 172 | queue_work(pm_wq, &genpd->power_off_work); | 172 | queue_work(pm_wq, &genpd->power_off_work); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | static int genpd_poweron(struct generic_pm_domain *genpd); | ||
| 176 | |||
| 177 | /** | 175 | /** |
| 178 | * __genpd_poweron - Restore power to a given PM domain and its masters. | 176 | * __genpd_poweron - Restore power to a given PM domain and its masters. |
| 179 | * @genpd: PM domain to power up. | 177 | * @genpd: PM domain to power up. |
| 178 | * @depth: nesting count for lockdep. | ||
| 180 | * | 179 | * |
| 181 | * Restore power to @genpd and all of its masters so that it is possible to | 180 | * Restore power to @genpd and all of its masters so that it is possible to |
| 182 | * resume a device belonging to it. | 181 | * resume a device belonging to it. |
| 183 | */ | 182 | */ |
| 184 | static int __genpd_poweron(struct generic_pm_domain *genpd) | 183 | static int __genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth) |
| 185 | { | 184 | { |
| 186 | struct gpd_link *link; | 185 | struct gpd_link *link; |
| 187 | int ret = 0; | 186 | int ret = 0; |
| @@ -196,11 +195,16 @@ static int __genpd_poweron(struct generic_pm_domain *genpd) · 8 unmodified lines | |||
| 196 | * with it. | 195 | * with it. |
| 197 | */ | 196 | */ |
| 198 | list_for_each_entry(link, &genpd->slave_links, slave_node) { | 197 | list_for_each_entry(link, &genpd->slave_links, slave_node) { |
| 199 | genpd_sd_counter_inc(link->master); | 198 | struct generic_pm_domain *master = link->master; |
| 199 | |||
| 200 | genpd_sd_counter_inc(master); | ||
| 201 | |||
| 202 | mutex_lock_nested(&master->lock, depth + 1); | ||
| 203 | ret = __genpd_poweron(master, depth + 1); | ||
| 204 | mutex_unlock(&master->lock); | ||
| 200 | 205 | ||
| 201 | ret = genpd_poweron(link->master); | ||
| 202 | if (ret) { | 206 | if (ret) { |
| 203 | genpd_sd_counter_dec(link->master); | 207 | genpd_sd_counter_dec(master); |
| 204 | goto err; | 208 | goto err; |
| 205 | } | 209 | } |
| 206 | } | 210 | } |
| @@ -232,11 +236,12 @@ static int genpd_poweron(struct generic_pm_domain *genpd) · 25 unmodified lines | |||
| 232 | int ret; | 236 | int ret; |
| 233 | 237 | ||
| 234 | mutex_lock(&genpd->lock); | 238 | mutex_lock(&genpd->lock); |
| 235 | ret = __genpd_poweron(genpd); | 239 | ret = __genpd_poweron(genpd, 0); |
| 236 | mutex_unlock(&genpd->lock); | 240 | mutex_unlock(&genpd->lock); |
| 237 | return ret; | 241 | return ret; |
| 238 | } | 242 | } |
| 239 | 243 | ||
| 244 | |||
| 240 | static int genpd_save_dev(struct generic_pm_domain *genpd, struct device *dev) | 245 | static int genpd_save_dev(struct generic_pm_domain *genpd, struct device *dev) |
| 241 | { | 246 | { |
| 242 | return GENPD_DEV_CALLBACK(genpd, int, save_state, dev); | 247 | return GENPD_DEV_CALLBACK(genpd, int, save_state, dev); |
| @@ -484,7 +489,7 @@ static int pm_genpd_runtime_resume(struct device *dev) · 241 unmodified lines | |||
| 484 | } | 489 | } |
| 485 | 490 | ||
| 486 | mutex_lock(&genpd->lock); | 491 | mutex_lock(&genpd->lock); |
| 487 | ret = __genpd_poweron(genpd); | 492 | ret = __genpd_poweron(genpd, 0); |
| 488 | mutex_unlock(&genpd->lock); | 493 | mutex_unlock(&genpd->lock); |
| 489 | 494 | ||
| 490 | if (ret) | 495 | if (ret) |
| @@ -1339,8 +1344,8 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, · 848 unmodified lines | |||
| 1339 | if (!link) | 1344 | if (!link) |
| 1340 | return -ENOMEM; | 1345 | return -ENOMEM; |
| 1341 | 1346 | ||
| 1342 | mutex_lock(&genpd->lock); | 1347 | mutex_lock(&subdomain->lock); |
| 1343 | mutex_lock_nested(&subdomain->lock, SINGLE_DEPTH_NESTING); | 1348 | mutex_lock_nested(&genpd->lock, SINGLE_DEPTH_NESTING); |
| 1344 | 1349 | ||
| 1345 | if (genpd->status == GPD_STATE_POWER_OFF | 1350 | if (genpd->status == GPD_STATE_POWER_OFF |
| 1346 | && subdomain->status != GPD_STATE_POWER_OFF) { | 1351 | && subdomain->status != GPD_STATE_POWER_OFF) { |
| @@ -1363,8 +1368,8 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, · 16 unmodified lines | |||
| 1363 | genpd_sd_counter_inc(genpd); | 1368 | genpd_sd_counter_inc(genpd); |
| 1364 | 1369 | ||
| 1365 | out: | 1370 | out: |
| 1366 | mutex_unlock(&subdomain->lock); | ||
| 1367 | mutex_unlock(&genpd->lock); | 1371 | mutex_unlock(&genpd->lock); |
| 1372 | mutex_unlock(&subdomain->lock); | ||
| 1368 | if (ret) | 1373 | if (ret) |
| 1369 | kfree(link); | 1374 | kfree(link); |
| 1370 | return ret; | 1375 | return ret; |
| @@ -1385,7 +1390,8 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, · 14 unmodified lines | |||
| 1385 | if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)) | 1390 | if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)) |
| 1386 | return -EINVAL; | 1391 | return -EINVAL; |
| 1387 | 1392 | ||
| 1388 | mutex_lock(&genpd->lock); | 1393 | mutex_lock(&subdomain->lock); |
| 1394 | mutex_lock_nested(&genpd->lock, SINGLE_DEPTH_NESTING); | ||
| 1389 | 1395 | ||
| 1390 | if (!list_empty(&subdomain->slave_links) || subdomain->device_count) { | 1396 | if (!list_empty(&subdomain->slave_links) || subdomain->device_count) { |
| 1391 | pr_warn("%s: unable to remove subdomain %s\n", genpd->name, | 1397 | pr_warn("%s: unable to remove subdomain %s\n", genpd->name, |
| @@ -1398,22 +1404,19 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, · 6 unmodified lines | |||
| 1398 | if (link->slave != subdomain) | 1404 | if (link->slave != subdomain) |
| 1399 | continue; | 1405 | continue; |
| 1400 | 1406 | ||
| 1401 | mutex_lock_nested(&subdomain->lock, SINGLE_DEPTH_NESTING); | ||
| 1402 | |||
| 1403 | list_del(&link->master_node); | 1407 | list_del(&link->master_node); |
| 1404 | list_del(&link->slave_node); | 1408 | list_del(&link->slave_node); |
| 1405 | kfree(link); | 1409 | kfree(link); |
| 1406 | if (subdomain->status != GPD_STATE_POWER_OFF) | 1410 | if (subdomain->status != GPD_STATE_POWER_OFF) |
| 1407 | genpd_sd_counter_dec(genpd); | 1411 | genpd_sd_counter_dec(genpd); |
| 1408 | 1412 | ||
| 1409 | mutex_unlock(&subdomain->lock); | ||
| 1410 | |||
| 1411 | ret = 0; | 1413 | ret = 0; |
| 1412 | break; | 1414 | break; |
| 1413 | } | 1415 | } |
| 1414 | 1416 | ||
| 1415 | out: | 1417 | out: |
| 1416 | mutex_unlock(&genpd->lock); | 1418 | mutex_unlock(&genpd->lock); |
| 1419 | mutex_unlock(&subdomain->lock); | ||
| 1417 | 1420 | ||
| 1418 | return ret; | 1421 | return ret; |
| 1419 | } | 1422 | } |
| @@ -30,6 +30,8 @@ config CLKSRC_MMIO · 29 unmodified lines | |||
| 30 | config DIGICOLOR_TIMER | 30 | config DIGICOLOR_TIMER |
| 31 | bool "Digicolor timer driver" if COMPILE_TEST | 31 | bool "Digicolor timer driver" if COMPILE_TEST |
| 32 | depends on GENERIC_CLOCKEVENTS | 32 | depends on GENERIC_CLOCKEVENTS |
| 33 | select CLKSRC_MMIO | ||
| 34 | depends on HAS_IOMEM | ||
| 33 | help | 35 | help |
| 34 | Enables the support for the digicolor timer driver. | 36 | Enables the support for the digicolor timer driver. |
| 35 | 37 | ||
| @@ -55,6 +57,7 @@ config ARMADA_370_XP_TIMER · 19 unmodified lines | |||
| 55 | bool "Armada 370 and XP timer driver" if COMPILE_TEST | 57 | bool "Armada 370 and XP timer driver" if COMPILE_TEST |
| 56 | depends on ARM | 58 | depends on ARM |
| 57 | select CLKSRC_OF | 59 | select CLKSRC_OF |
| 60 | select CLKSRC_MMIO | ||
| 58 | help | 61 | help |
| 59 | Enables the support for the Armada 370 and XP timer driver. | 62 | Enables the support for the Armada 370 and XP timer driver. |
| 60 | 63 | ||
| @@ -76,6 +79,7 @@ config ORION_TIMER · 15 unmodified lines | |||
| 76 | config SUN4I_TIMER | 79 | config SUN4I_TIMER |
| 77 | bool "Sun4i timer driver" if COMPILE_TEST | 80 | bool "Sun4i timer driver" if COMPILE_TEST |
| 78 | depends on GENERIC_CLOCKEVENTS | 81 | depends on GENERIC_CLOCKEVENTS |
| 82 | depends on HAS_IOMEM | ||
| 79 | select CLKSRC_MMIO | 83 | select CLKSRC_MMIO |
| 80 | help | 84 | help |
| 81 | Enables support for the Sun4i timer. | 85 | Enables support for the Sun4i timer. |
| @@ -89,6 +93,7 @@ config SUN5I_HSTIMER · 7 unmodified lines | |||
| 89 | 93 | ||
| 90 | config TEGRA_TIMER | 94 | config TEGRA_TIMER |
| 91 | bool "Tegra timer driver" if COMPILE_TEST | 95 | bool "Tegra timer driver" if COMPILE_TEST |
| 96 | select CLKSRC_MMIO | ||
| 92 | depends on ARM | 97 | depends on ARM |
| 93 | help | 98 | help |
| 94 | Enables support for the Tegra driver. | 99 | Enables support for the Tegra driver. |
| @@ -96,6 +101,7 @@ config TEGRA_TIMER · 1 unmodified line | |||
| 96 | config VT8500_TIMER | 101 | config VT8500_TIMER |
| 97 | bool "VT8500 timer driver" if COMPILE_TEST | 102 | bool "VT8500 timer driver" if COMPILE_TEST |
| 98 | depends on GENERIC_CLOCKEVENTS | 103 | depends on GENERIC_CLOCKEVENTS |
| 104 | depends on HAS_IOMEM | ||
| 99 | help | 105 | help |
| 100 | Enables support for the VT8500 driver. | 106 | Enables support for the VT8500 driver. |
| 101 | 107 | ||
| @@ -131,6 +137,7 @@ config CLKSRC_NOMADIK_MTU_SCHED_CLOCK · 29 unmodified lines | |||
| 131 | config CLKSRC_DBX500_PRCMU | 137 | config CLKSRC_DBX500_PRCMU |
| 132 | bool "Clocksource PRCMU Timer" if COMPILE_TEST | 138 | bool "Clocksource PRCMU Timer" if COMPILE_TEST |
| 133 | depends on GENERIC_CLOCKEVENTS | 139 | depends on GENERIC_CLOCKEVENTS |
| 140 | depends on HAS_IOMEM | ||
| 134 | help | 141 | help |
| 135 | Use the always on PRCMU Timer as clocksource | 142 | Use the always on PRCMU Timer as clocksource |
| 136 | 143 | ||
| @@ -248,6 +255,7 @@ config CLKSRC_EXYNOS_MCT · 111 unmodified lines | |||
| 248 | config CLKSRC_SAMSUNG_PWM | 255 | config CLKSRC_SAMSUNG_PWM |
| 249 | bool "PWM timer drvier for Samsung S3C, S5P" if COMPILE_TEST | 256 | bool "PWM timer drvier for Samsung S3C, S5P" if COMPILE_TEST |
| 250 | depends on GENERIC_CLOCKEVENTS | 257 | depends on GENERIC_CLOCKEVENTS |
| 258 | depends on HAS_IOMEM | ||
| 251 | help | 259 | help |
| 252 | This is a new clocksource driver for the PWM timer found in | 260 | This is a new clocksource driver for the PWM timer found in |
| 253 | Samsung S3C, S5P and Exynos SoCs, replacing an earlier driver | 261 | Samsung S3C, S5P and Exynos SoCs, replacing an earlier driver |
| @@ -257,12 +265,14 @@ config CLKSRC_SAMSUNG_PWM · 3 unmodified lines | |||
| 257 | config FSL_FTM_TIMER | 265 | config FSL_FTM_TIMER |
| 258 | bool "Freescale FlexTimer Module driver" if COMPILE_TEST | 266 | bool "Freescale FlexTimer Module driver" if COMPILE_TEST |
| 259 | depends on GENERIC_CLOCKEVENTS | 267 | depends on GENERIC_CLOCKEVENTS |
| 268 | depends on HAS_IOMEM | ||
| 260 | select CLKSRC_MMIO | 269 | select CLKSRC_MMIO |
| 261 | help | 270 | help |
| 262 | Support for Freescale FlexTimer Module (FTM) timer. | 271 | Support for Freescale FlexTimer Module (FTM) timer. |
| 263 | 272 | ||
| 264 | config VF_PIT_TIMER | 273 | config VF_PIT_TIMER |
| 265 | bool | 274 | bool |
| 275 | select CLKSRC_MMIO | ||
| 266 | help | 276 | help |
| 267 | Support for Period Interrupt Timer on Freescale Vybrid Family SoCs. | 277 | Support for Period Interrupt Timer on Freescale Vybrid Family SoCs. |
| 268 | 278 | ||
| @@ -360,6 +370,7 @@ config CLKSRC_TANGO_XTAL · 91 unmodified lines | |||
| 360 | config CLKSRC_PXA | 370 | config CLKSRC_PXA |
| 361 | bool "Clocksource for PXA or SA-11x0 platform" if COMPILE_TEST | 371 | bool "Clocksource for PXA or SA-11x0 platform" if COMPILE_TEST |
| 362 | depends on GENERIC_CLOCKEVENTS | 372 | depends on GENERIC_CLOCKEVENTS |
| 373 | depends on HAS_IOMEM | ||
| 363 | select CLKSRC_MMIO | 374 | select CLKSRC_MMIO |
| 364 | help | 375 | help |
| 365 | This enables OST0 support available on PXA and SA-11x0 | 376 | This enables OST0 support available on PXA and SA-11x0 |
| @@ -394,6 +405,7 @@ config CLKSRC_ST_LPC · 28 unmodified lines | |||
| 394 | bool "Low power clocksource found in the LPC" if COMPILE_TEST | 405 | bool "Low power clocksource found in the LPC" if COMPILE_TEST |
| 395 | select CLKSRC_OF if OF | 406 | select CLKSRC_OF if OF |
| 396 | depends on HAS_IOMEM | 407 | depends on HAS_IOMEM |
| 408 | select CLKSRC_MMIO | ||
| 397 | help | 409 | help |
| 398 | Enable this option to use the Low Power controller timer | 410 | Enable this option to use the Low Power controller timer |
| 399 | as clocksource. | 411 | as clocksource. |
| @@ -98,7 +98,8 @@ static int tc_shutdown(struct clock_event_device *d) · 97 unmodified lines | |||
| 98 | 98 | ||
| 99 | __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR)); | 99 | __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR)); |
| 100 | __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR)); | 100 | __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR)); |
| 101 | clk_disable(tcd->clk); | 101 | if (!clockevent_state_detached(d)) |
| 102 | clk_disable(tcd->clk); | ||
| 102 | 103 | ||
| 103 | return 0; | 104 | return 0; |
| 104 | } | 105 | } |
| @@ -142,15 +142,16 @@ static int allocate_resources(int cpu, struct device **cdev, · 141 unmodified lines | |||
| 142 | 142 | ||
| 143 | try_again: | 143 | try_again: |
| 144 | cpu_reg = regulator_get_optional(cpu_dev, reg); | 144 | cpu_reg = regulator_get_optional(cpu_dev, reg); |
| 145 | if (IS_ERR(cpu_reg)) { | 145 | ret = PTR_ERR_OR_ZERO(cpu_reg); |
| 146 | if (ret) { | ||
| 146 | /* | 147 | /* |
| 147 | * If cpu's regulator supply node is present, but regulator is | 148 | * If cpu's regulator supply node is present, but regulator is |
| 148 | * not yet registered, we should try defering probe. | 149 | * not yet registered, we should try defering probe. |
| 149 | */ | 150 | */ |
| 150 | if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { | 151 | if (ret == -EPROBE_DEFER) { |
| 151 | dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n", | 152 | dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n", |
| 152 | cpu); | 153 | cpu); |
| 153 | return -EPROBE_DEFER; | 154 | return ret; |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | /* Try with "cpu-supply" */ | 157 | /* Try with "cpu-supply" */ |
| @@ -159,18 +160,16 @@ try_again: · 2 unmodified lines | |||
| 159 | goto try_again; | 160 | goto try_again; |
| 160 | } | 161 | } |
| 161 | 162 | ||
| 162 | dev_dbg(cpu_dev, "no regulator for cpu%d: %ld\n", | 163 | dev_dbg(cpu_dev, "no regulator for cpu%d: %d\n", cpu, ret); |
| 163 | cpu, PTR_ERR(cpu_reg)); | ||
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | cpu_clk = clk_get(cpu_dev, NULL); | 166 | cpu_clk = clk_get(cpu_dev, NULL); |
| 167 | if (IS_ERR(cpu_clk)) { | 167 | ret = PTR_ERR_OR_ZERO(cpu_clk); |
| 168 | if (ret) { | ||
| 168 | /* put regulator */ | 169 | /* put regulator */ |
| 169 | if (!IS_ERR(cpu_reg)) | 170 | if (!IS_ERR(cpu_reg)) |
| 170 | regulator_put(cpu_reg); | 171 | regulator_put(cpu_reg); |
| 171 | 172 | ||
| 172 | ret = PTR_ERR(cpu_clk); | ||
| 173 | |||
| 174 | /* | 173 | /* |
| 175 | * If cpu's clk node is present, but clock is not yet | 174 | * If cpu's clk node is present, but clock is not yet |
| 176 | * registered, we should try defering probe. | 175 | * registered, we should try defering probe. |
| @@ -48,11 +48,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy, · 47 unmodified lines | |||
| 48 | bool active) | 48 | bool active) |
| 49 | { | 49 | { |
| 50 | do { | 50 | do { |
| 51 | policy = list_next_entry(policy, policy_list); | ||
| 52 | |||
| 53 | /* No more policies in the list */ | 51 | /* No more policies in the list */ |
| 54 | if (&policy->policy_list == &cpufreq_policy_list) | 52 | if (list_is_last(&policy->policy_list, &cpufreq_policy_list)) |
| 55 | return NULL; | 53 | return NULL; |
| 54 | |||
| 55 | policy = list_next_entry(policy, policy_list); | ||
| 56 | } while (!suitable_policy(policy, active)); | 56 | } while (!suitable_policy(policy, active)); |
| 57 | 57 | ||
| 58 | return policy; | 58 | return policy; |
| @@ -387,16 +387,18 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy, · 386 unmodified lines | |||
| 387 | if (!have_governor_per_policy()) | 387 | if (!have_governor_per_policy()) |
| 388 | cdata->gdbs_data = dbs_data; | 388 | cdata->gdbs_data = dbs_data; |
| 389 | 389 | ||
| 390 | policy->governor_data = dbs_data; | ||
| 391 | |||
| 390 | ret = sysfs_create_group(get_governor_parent_kobj(policy), | 392 | ret = sysfs_create_group(get_governor_parent_kobj(policy), |
| 391 | get_sysfs_attr(dbs_data)); | 393 | get_sysfs_attr(dbs_data)); |
| 392 | if (ret) | 394 | if (ret) |
| 393 | goto reset_gdbs_data; | 395 | goto reset_gdbs_data; |
| 394 | 396 | ||
| 395 | policy->governor_data = dbs_data; | ||
| 396 | |||
| 397 | return 0; | 397 | return 0; |
| 398 | 398 | ||
| 399 | reset_gdbs_data: | 399 | reset_gdbs_data: |
| 400 | policy->governor_data = NULL; | ||
| 401 | |||
| 400 | if (!have_governor_per_policy()) | 402 | if (!have_governor_per_policy()) |
| 401 | cdata->gdbs_data = NULL; | 403 | cdata->gdbs_data = NULL; |
| 402 | cdata->exit(dbs_data, !policy->governor->initialized); | 404 | cdata->exit(dbs_data, !policy->governor->initialized); |
| @@ -417,16 +419,19 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy, · 14 unmodified lines | |||
| 417 | if (!cdbs->shared || cdbs->shared->policy) | 419 | if (!cdbs->shared || cdbs->shared->policy) |
| 418 | return -EBUSY; | 420 | return -EBUSY; |
| 419 | 421 | ||
| 420 | policy->governor_data = NULL; | ||
| 421 | if (!--dbs_data->usage_count) { | 422 | if (!--dbs_data->usage_count) { |
| 422 | sysfs_remove_group(get_governor_parent_kobj(policy), | 423 | sysfs_remove_group(get_governor_parent_kobj(policy), |
| 423 | get_sysfs_attr(dbs_data)); | 424 | get_sysfs_attr(dbs_data)); |
| 424 | 425 | ||
| 426 | policy->governor_data = NULL; | ||
| 427 | |||
| 425 | if (!have_governor_per_policy()) | 428 | if (!have_governor_per_policy()) |
| 426 | cdata->gdbs_data = NULL; | 429 | cdata->gdbs_data = NULL; |
| 427 | 430 | ||
| 428 | cdata->exit(dbs_data, policy->governor->initialized == 1); | 431 | cdata->exit(dbs_data, policy->governor->initialized == 1); |
| 429 | kfree(dbs_data); | 432 | kfree(dbs_data); |
| 433 | } else { | ||
| 434 | policy->governor_data = NULL; | ||
| 430 | } | 435 | } |
| 431 | 436 | ||
| 432 | free_common_dbs_info(policy, cdata); | 437 | free_common_dbs_info(policy, cdata); |
| @@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void) · 201 unmodified lines | |||
| 202 | } | 202 | } |
| 203 | } | 203 | } |
| 204 | #else | 204 | #else |
| 205 | static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq) | 205 | static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq) |
| 206 | { | 206 | { |
| 207 | return 0; | 207 | return 0; |
| 208 | } | 208 | } |
| @@ -119,7 +119,6 @@ struct cpuidle_coupled { · 118 unmodified lines | |||
| 119 | 119 | ||
| 120 | #define CPUIDLE_COUPLED_NOT_IDLE (-1) | 120 | #define CPUIDLE_COUPLED_NOT_IDLE (-1) |
| 121 | 121 | ||
| 122 | static DEFINE_MUTEX(cpuidle_coupled_lock); | ||
| 123 | static DEFINE_PER_CPU(struct call_single_data, cpuidle_coupled_poke_cb); | 122 | static DEFINE_PER_CPU(struct call_single_data, cpuidle_coupled_poke_cb); |
| 124 | 123 | ||
| 125 | /* | 124 | /* |
| @@ -153,7 +153,7 @@ int cpuidle_enter_freeze(struct cpuidle_driver *drv, struct cpuidle_device *dev) · 152 unmodified lines | |||
| 153 | * be frozen safely. | 153 | * be frozen safely. |
| 154 | */ | 154 | */ |
| 155 | index = find_deepest_state(drv, dev, UINT_MAX, 0, true); | 155 | index = find_deepest_state(drv, dev, UINT_MAX, 0, true); |
| 156 | if (index >= 0) | 156 | if (index > 0) |
| 157 | enter_freeze_proper(drv, dev, index); | 157 | enter_freeze_proper(drv, dev, index); |
| 158 | 158 | ||
| 159 | return index; | 159 | return index; |
| @@ -2278,60 +2278,60 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) · 2277 unmodified lines | |||
| 2278 | #define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e)) | 2278 | #define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e)) |
| 2279 | 2279 | ||
| 2280 | #define amdgpu_dpm_get_temperature(adev) \ | 2280 | #define amdgpu_dpm_get_temperature(adev) \ |
| 2281 | (adev)->pp_enabled ? \ | 2281 | ((adev)->pp_enabled ? \ |
| 2282 | (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \ | 2282 | (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \ |
| 2283 | (adev)->pm.funcs->get_temperature((adev)) | 2283 | (adev)->pm.funcs->get_temperature((adev))) |
| 2284 | 2284 | ||
| 2285 | #define amdgpu_dpm_set_fan_control_mode(adev, m) \ | 2285 | #define amdgpu_dpm_set_fan_control_mode(adev, m) \ |
| 2286 | (adev)->pp_enabled ? \ | 2286 | ((adev)->pp_enabled ? \ |
| 2287 | (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \ | 2287 | (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \ |
| 2288 | (adev)->pm.funcs->set_fan_control_mode((adev), (m)) | 2288 | (adev)->pm.funcs->set_fan_control_mode((adev), (m))) |
| 2289 | 2289 | ||
| 2290 | #define amdgpu_dpm_get_fan_control_mode(adev) \ | 2290 | #define amdgpu_dpm_get_fan_control_mode(adev) \ |
| 2291 | (adev)->pp_enabled ? \ | 2291 | ((adev)->pp_enabled ? \ |
| 2292 | (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \ | 2292 | (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \ |
| 2293 | (adev)->pm.funcs->get_fan_control_mode((adev)) | 2293 | (adev)->pm.funcs->get_fan_control_mode((adev))) |
| 2294 | 2294 | ||
| 2295 | #define amdgpu_dpm_set_fan_speed_percent(adev, s) \ | 2295 | #define amdgpu_dpm_set_fan_speed_percent(adev, s) \ |
| 2296 | (adev)->pp_enabled ? \ | 2296 | ((adev)->pp_enabled ? \ |
| 2297 | (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ | 2297 | (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ |
| 2298 | (adev)->pm.funcs->set_fan_speed_percent((adev), (s)) | 2298 | (adev)->pm.funcs->set_fan_speed_percent((adev), (s))) |
| 2299 | 2299 | ||
| 2300 | #define amdgpu_dpm_get_fan_speed_percent(adev, s) \ | 2300 | #define amdgpu_dpm_get_fan_speed_percent(adev, s) \ |
| 2301 | (adev)->pp_enabled ? \ | 2301 | ((adev)->pp_enabled ? \ |
| 2302 | (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ | 2302 | (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ |
| 2303 | (adev)->pm.funcs->get_fan_speed_percent((adev), (s)) | 2303 | (adev)->pm.funcs->get_fan_speed_percent((adev), (s))) |
| 2304 | 2304 | ||
| 2305 | #define amdgpu_dpm_get_sclk(adev, l) \ | 2305 | #define amdgpu_dpm_get_sclk(adev, l) \ |
| 2306 | (adev)->pp_enabled ? \ | 2306 | ((adev)->pp_enabled ? \ |
| 2307 | (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \ | 2307 | (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \ |
| 2308 | (adev)->pm.funcs->get_sclk((adev), (l)) | 2308 | (adev)->pm.funcs->get_sclk((adev), (l))) |
| 2309 | 2309 | ||
| 2310 | #define amdgpu_dpm_get_mclk(adev, l) \ | 2310 | #define amdgpu_dpm_get_mclk(adev, l) \ |
| 2311 | (adev)->pp_enabled ? \ | 2311 | ((adev)->pp_enabled ? \ |
| 2312 | (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \ | 2312 | (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \ |
| 2313 | (adev)->pm.funcs->get_mclk((adev), (l)) | 2313 | (adev)->pm.funcs->get_mclk((adev), (l))) |
| 2314 | 2314 | ||
| 2315 | 2315 | ||
| 2316 | #define amdgpu_dpm_force_performance_level(adev, l) \ | 2316 | #define amdgpu_dpm_force_performance_level(adev, l) \ |
| 2317 | (adev)->pp_enabled ? \ | 2317 | ((adev)->pp_enabled ? \ |
| 2318 | (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \ | 2318 | (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \ |
| 2319 | (adev)->pm.funcs->force_performance_level((adev), (l)) | 2319 | (adev)->pm.funcs->force_performance_level((adev), (l))) |
| 2320 | 2320 | ||
| 2321 | #define amdgpu_dpm_powergate_uvd(adev, g) \ | 2321 | #define amdgpu_dpm_powergate_uvd(adev, g) \ |
| 2322 | (adev)->pp_enabled ? \ | 2322 | ((adev)->pp_enabled ? \ |
| 2323 | (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \ | 2323 | (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \ |
| 2324 | (adev)->pm.funcs->powergate_uvd((adev), (g)) | 2324 | (adev)->pm.funcs->powergate_uvd((adev), (g))) |
| 2325 | 2325 | ||
| 2326 | #define amdgpu_dpm_powergate_vce(adev, g) \ | 2326 | #define amdgpu_dpm_powergate_vce(adev, g) \ |
| 2327 | (adev)->pp_enabled ? \ | 2327 | ((adev)->pp_enabled ? \ |
| 2328 | (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \ | 2328 | (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \ |
| 2329 | (adev)->pm.funcs->powergate_vce((adev), (g)) | 2329 | (adev)->pm.funcs->powergate_vce((adev), (g))) |
| 2330 | 2330 | ||
| 2331 | #define amdgpu_dpm_debugfs_print_current_performance_level(adev, m) \ | 2331 | #define amdgpu_dpm_debugfs_print_current_performance_level(adev, m) \ |
| 2332 | (adev)->pp_enabled ? \ | 2332 | ((adev)->pp_enabled ? \ |
| 2333 | (adev)->powerplay.pp_funcs->print_current_performance_level((adev)->powerplay.pp_handle, (m)) : \ | 2333 | (adev)->powerplay.pp_funcs->print_current_performance_level((adev)->powerplay.pp_handle, (m)) : \ |
| 2334 | (adev)->pm.funcs->debugfs_print_current_performance_level((adev), (m)) | 2334 | (adev)->pm.funcs->debugfs_print_current_performance_level((adev), (m))) |
| 2335 | 2335 | ||
| 2336 | #define amdgpu_dpm_get_current_power_state(adev) \ | 2336 | #define amdgpu_dpm_get_current_power_state(adev) \ |
| 2337 | (adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle) | 2337 | (adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle) |
| @@ -478,9 +478,9 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bo · 477 unmodified lines | |||
| 478 | struct amdgpu_fpriv *fpriv = parser->filp->driver_priv; | 478 | struct amdgpu_fpriv *fpriv = parser->filp->driver_priv; |
| 479 | unsigned i; | 479 | unsigned i; |
| 480 | 480 | ||
| 481 | amdgpu_vm_move_pt_bos_in_lru(parser->adev, &fpriv->vm); | ||
| 482 | |||
| 483 | if (!error) { | 481 | if (!error) { |
| 482 | amdgpu_vm_move_pt_bos_in_lru(parser->adev, &fpriv->vm); | ||
| 483 | |||
| 484 | /* Sort the buffer list from the smallest to largest buffer, | 484 | /* Sort the buffer list from the smallest to largest buffer, |
| 485 | * which affects the order of buffers in the LRU list. | 485 | * which affects the order of buffers in the LRU list. |
| 486 | * This assures that the smallest buffers are added first | 486 | * This assures that the smallest buffers are added first |
| @@ -333,6 +333,10 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev) · 332 unmodified lines | |||
| 333 | if (!adev->mode_info.mode_config_initialized) | 333 | if (!adev->mode_info.mode_config_initialized) |
| 334 | return 0; | 334 | return 0; |
| 335 | 335 | ||
| 336 | /* don't init fbdev if there are no connectors */ | ||
| 337 | if (list_empty(&adev->ddev->mode_config.connector_list)) | ||
| 338 | return 0; | ||
| 339 | |||
| 336 | /* select 8 bpp console on low vram cards */ | 340 | /* select 8 bpp console on low vram cards */ |
| 337 | if (adev->mc.real_vram_size <= (32*1024*1024)) | 341 | if (adev->mc.real_vram_size <= (32*1024*1024)) |
| 338 | bpp_sel = 8; | 342 | bpp_sel = 8; |
| @@ -399,7 +399,8 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, · 398 unmodified lines | |||
| 399 | } | 399 | } |
| 400 | if (fpfn > bo->placements[i].fpfn) | 400 | if (fpfn > bo->placements[i].fpfn) |
| 401 | bo->placements[i].fpfn = fpfn; | 401 | bo->placements[i].fpfn = fpfn; |
| 402 | if (lpfn && lpfn < bo->placements[i].lpfn) | 402 | if (!bo->placements[i].lpfn || |
| 403 | (lpfn && lpfn < bo->placements[i].lpfn)) | ||
| 403 | bo->placements[i].lpfn = lpfn; | 404 | bo->placements[i].lpfn = lpfn; |
| 404 | bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT; | 405 | bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT; |
| 405 | } | 406 | } |
| @@ -99,13 +99,24 @@ static int amdgpu_pp_early_init(void *handle) · 98 unmodified lines | |||
| 99 | 99 | ||
| 100 | #ifdef CONFIG_DRM_AMD_POWERPLAY | 100 | #ifdef CONFIG_DRM_AMD_POWERPLAY |
| 101 | switch (adev->asic_type) { | 101 | switch (adev->asic_type) { |
| 102 | case CHIP_TONGA: | 102 | case CHIP_TONGA: |
| 103 | case CHIP_FIJI: | 103 | case CHIP_FIJI: |
| 104 | adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false; | 104 | adev->pp_enabled = (amdgpu_powerplay == 0) ? false : true; |
| 105 | break; | 105 | break; |
| 106 | default: | 106 | case CHIP_CARRIZO: |
| 107 | adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false; | 107 | case CHIP_STONEY: |
| 108 | break; | 108 | adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false; |
| 109 | break; | ||
| 110 | /* These chips don't have powerplay implemenations */ | ||
| 111 | case CHIP_BONAIRE: | ||
| 112 | case CHIP_HAWAII: | ||
| 113 | case CHIP_KABINI: | ||
| 114 | case CHIP_MULLINS: | ||
| 115 | case CHIP_KAVERI: | ||
| 116 | case CHIP_TOPAZ: | ||
| 117 | default: | ||
| 118 | adev->pp_enabled = false; | ||
| 119 | break; | ||
| 109 | } | 120 | } |
| 110 | #else | 121 | #else |
| 111 | adev->pp_enabled = false; | 122 | adev->pp_enabled = false; |
| @@ -487,7 +487,7 @@ static int amdgpu_debugfs_ring_info(struct seq_file *m, void *data) · 486 unmodified lines | |||
| 487 | seq_printf(m, "rptr: 0x%08x [%5d]\n", | 487 | seq_printf(m, "rptr: 0x%08x [%5d]\n", |
| 488 | rptr, rptr); | 488 | rptr, rptr); |
| 489 | 489 | ||
| 490 | rptr_next = ~0; | 490 | rptr_next = le32_to_cpu(*ring->next_rptr_cpu_addr); |
| 491 | 491 | ||
| 492 | seq_printf(m, "driver's copy of the wptr: 0x%08x [%5d]\n", | 492 | seq_printf(m, "driver's copy of the wptr: 0x%08x [%5d]\n", |
| 493 | ring->wptr, ring->wptr); | 493 | ring->wptr, ring->wptr); |
| @@ -1282,7 +1282,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 1281 unmodified lines | |||
| 1282 | { | 1282 | { |
| 1283 | const unsigned align = min(AMDGPU_VM_PTB_ALIGN_SIZE, | 1283 | const unsigned align = min(AMDGPU_VM_PTB_ALIGN_SIZE, |
| 1284 | AMDGPU_VM_PTE_COUNT * 8); | 1284 | AMDGPU_VM_PTE_COUNT * 8); |
| 1285 | unsigned pd_size, pd_entries, pts_size; | 1285 | unsigned pd_size, pd_entries; |
| 1286 | int i, r; | 1286 | int i, r; |
| 1287 | 1287 | ||
| 1288 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { | 1288 | for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { |
| @@ -1300,8 +1300,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 11 unmodified lines | |||
| 1300 | pd_entries = amdgpu_vm_num_pdes(adev); | 1300 | pd_entries = amdgpu_vm_num_pdes(adev); |
| 1301 | 1301 | ||
| 1302 | /* allocate page table array */ | 1302 | /* allocate page table array */ |
| 1303 | pts_size = pd_entries * sizeof(struct amdgpu_vm_pt); | 1303 | vm->page_tables = drm_calloc_large(pd_entries, sizeof(struct amdgpu_vm_pt)); |
| 1304 | vm->page_tables = kzalloc(pts_size, GFP_KERNEL); | ||
| 1305 | if (vm->page_tables == NULL) { | 1304 | if (vm->page_tables == NULL) { |
| 1306 | DRM_ERROR("Cannot allocate memory for page table array\n"); | 1305 | DRM_ERROR("Cannot allocate memory for page table array\n"); |
| 1307 | return -ENOMEM; | 1306 | return -ENOMEM; |
| @@ -1361,7 +1360,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 53 unmodified lines | |||
| 1361 | 1360 | ||
| 1362 | for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) | 1361 | for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) |
| 1363 | amdgpu_bo_unref(&vm->page_tables[i].entry.robj); | 1362 | amdgpu_bo_unref(&vm->page_tables[i].entry.robj); |
| 1364 | kfree(vm->page_tables); | 1363 | drm_free_large(vm->page_tables); |
| 1365 | 1364 | ||
| 1366 | amdgpu_bo_unref(&vm->page_directory); | 1365 | amdgpu_bo_unref(&vm->page_directory); |
| 1367 | fence_put(vm->page_directory_fence); | 1366 | fence_put(vm->page_directory_fence); |
| @@ -4186,7 +4186,18 @@ static int gfx_v8_0_soft_reset(void *handle) · 4185 unmodified lines | |||
| 4186 | gfx_v8_0_cp_gfx_enable(adev, false); | 4186 | gfx_v8_0_cp_gfx_enable(adev, false); |
| 4187 | 4187 | ||
| 4188 | /* Disable MEC parsing/prefetching */ | 4188 | /* Disable MEC parsing/prefetching */ |
| 4189 | /* XXX todo */ | 4189 | gfx_v8_0_cp_compute_enable(adev, false); |
| 4190 | |||
| 4191 | if (grbm_soft_reset || srbm_soft_reset) { | ||
| 4192 | tmp = RREG32(mmGMCON_DEBUG); | ||
| 4193 | tmp = REG_SET_FIELD(tmp, | ||
| 4194 | GMCON_DEBUG, GFX_STALL, 1); | ||
| 4195 | tmp = REG_SET_FIELD(tmp, | ||
| 4196 | GMCON_DEBUG, GFX_CLEAR, 1); | ||
| 4197 | WREG32(mmGMCON_DEBUG, tmp); | ||
| 4198 | |||
| 4199 | udelay(50); | ||
| 4200 | } | ||
| 4190 | 4201 | ||
| 4191 | if (grbm_soft_reset) { | 4202 | if (grbm_soft_reset) { |
| 4192 | tmp = RREG32(mmGRBM_SOFT_RESET); | 4203 | tmp = RREG32(mmGRBM_SOFT_RESET); |
| @@ -4215,6 +4226,16 @@ static int gfx_v8_0_soft_reset(void *handle) · 22 unmodified lines | |||
| 4215 | WREG32(mmSRBM_SOFT_RESET, tmp); | 4226 | WREG32(mmSRBM_SOFT_RESET, tmp); |
| 4216 | tmp = RREG32(mmSRBM_SOFT_RESET); | 4227 | tmp = RREG32(mmSRBM_SOFT_RESET); |
| 4217 | } | 4228 | } |
| 4229 | |||
| 4230 | if (grbm_soft_reset || srbm_soft_reset) { | ||
| 4231 | tmp = RREG32(mmGMCON_DEBUG); | ||
| 4232 | tmp = REG_SET_FIELD(tmp, | ||
| 4233 | GMCON_DEBUG, GFX_STALL, 0); | ||
| 4234 | tmp = REG_SET_FIELD(tmp, | ||
| 4235 | GMCON_DEBUG, GFX_CLEAR, 0); | ||
| 4236 | WREG32(mmGMCON_DEBUG, tmp); | ||
| 4237 | } | ||
| 4238 | |||
| 4218 | /* Wait a little for things to settle down */ | 4239 | /* Wait a little for things to settle down */ |
| 4219 | udelay(50); | 4240 | udelay(50); |
| 4220 | gfx_v8_0_print_status((void *)adev); | 4241 | gfx_v8_0_print_status((void *)adev); |
| @@ -122,25 +122,12 @@ static int tonga_dpm_hw_fini(void *handle) · 121 unmodified lines | |||
| 122 | 122 | ||
| 123 | static int tonga_dpm_suspend(void *handle) | 123 | static int tonga_dpm_suspend(void *handle) |
| 124 | { | 124 | { |
| 125 | return 0; | 125 | return tonga_dpm_hw_fini(handle); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | static int tonga_dpm_resume(void *handle) | 128 | static int tonga_dpm_resume(void *handle) |
| 129 | { | 129 | { |
| 130 | int ret; | 130 | return tonga_dpm_hw_init(handle); |
| 131 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | ||
| 132 | |||
| 133 | mutex_lock(&adev->pm.mutex); | ||
| 134 | |||
| 135 | ret = tonga_smu_start(adev); | ||
| 136 | if (ret) { | ||
| 137 | DRM_ERROR("SMU start failed\n"); | ||
| 138 | goto fail; | ||
| 139 | } | ||
| 140 | |||
| 141 | fail: | ||
| 142 | mutex_unlock(&adev->pm.mutex); | ||
| 143 | return ret; | ||
| 144 | } | 131 | } |
| 145 | 132 | ||
| 146 | static int tonga_dpm_set_clockgating_state(void *handle, | 133 | static int tonga_dpm_set_clockgating_state(void *handle, |
| @@ -64,6 +64,11 @@ static int pp_sw_init(void *handle) · 63 unmodified lines | |||
| 64 | if (ret == 0) | 64 | if (ret == 0) |
| 65 | ret = hwmgr->hwmgr_func->backend_init(hwmgr); | 65 | ret = hwmgr->hwmgr_func->backend_init(hwmgr); |
| 66 | 66 | ||
| 67 | if (ret) | ||
| 68 | printk("amdgpu: powerplay initialization failed\n"); | ||
| 69 | else | ||
| 70 | printk("amdgpu: powerplay initialized\n"); | ||
| 71 | |||
| 67 | return ret; | 72 | return ret; |
| 68 | } | 73 | } |
| 69 | 74 | ||
| @@ -272,6 +272,9 @@ static int cz_start_smu(struct pp_smumgr *smumgr) · 271 unmodified lines | |||
| 272 | UCODE_ID_CP_MEC_JT1_MASK | | 272 | UCODE_ID_CP_MEC_JT1_MASK | |
| 273 | UCODE_ID_CP_MEC_JT2_MASK; | 273 | UCODE_ID_CP_MEC_JT2_MASK; |
| 274 | 274 | ||
| 275 | if (smumgr->chip_id == CHIP_STONEY) | ||
| 276 | fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK); | ||
| 277 | |||
| 275 | cz_request_smu_load_fw(smumgr); | 278 | cz_request_smu_load_fw(smumgr); |
| 276 | cz_check_fw_load_finish(smumgr, fw_to_check); | 279 | cz_check_fw_load_finish(smumgr, fw_to_check); |
| 277 | 280 | ||
| @@ -282,7 +285,7 @@ static int cz_start_smu(struct pp_smumgr *smumgr) · 4 unmodified lines | |||
| 282 | return ret; | 285 | return ret; |
| 283 | } | 286 | } |
| 284 | 287 | ||
| 285 | static uint8_t cz_translate_firmware_enum_to_arg( | 288 | static uint8_t cz_translate_firmware_enum_to_arg(struct pp_smumgr *smumgr, |
| 286 | enum cz_scratch_entry firmware_enum) | 289 | enum cz_scratch_entry firmware_enum) |
| 287 | { | 290 | { |
| 288 | uint8_t ret = 0; | 291 | uint8_t ret = 0; |
| @@ -292,7 +295,10 @@ static uint8_t cz_translate_firmware_enum_to_arg( · 3 unmodified lines | |||
| 292 | ret = UCODE_ID_SDMA0; | 295 | ret = UCODE_ID_SDMA0; |
| 293 | break; | 296 | break; |
| 294 | case CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1: | 297 | case CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1: |
| 295 | ret = UCODE_ID_SDMA1; | 298 | if (smumgr->chip_id == CHIP_STONEY) |
| 299 | ret = UCODE_ID_SDMA0; | ||
| 300 | else | ||
| 301 | ret = UCODE_ID_SDMA1; | ||
| 296 | break; | 302 | break; |
| 297 | case CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE: | 303 | case CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE: |
| 298 | ret = UCODE_ID_CP_CE; | 304 | ret = UCODE_ID_CP_CE; |
| @@ -307,7 +313,10 @@ static uint8_t cz_translate_firmware_enum_to_arg( · 8 unmodified lines | |||
| 307 | ret = UCODE_ID_CP_MEC_JT1; | 313 | ret = UCODE_ID_CP_MEC_JT1; |
| 308 | break; | 314 | break; |
| 309 | case CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2: | 315 | case CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2: |
| 310 | ret = UCODE_ID_CP_MEC_JT2; | 316 | if (smumgr->chip_id == CHIP_STONEY) |
| 317 | ret = UCODE_ID_CP_MEC_JT1; | ||
| 318 | else | ||
| 319 | ret = UCODE_ID_CP_MEC_JT2; | ||
| 311 | break; | 320 | break; |
| 312 | case CZ_SCRATCH_ENTRY_UCODE_ID_GMCON_RENG: | 321 | case CZ_SCRATCH_ENTRY_UCODE_ID_GMCON_RENG: |
| 313 | ret = UCODE_ID_GMCON_RENG; | 322 | ret = UCODE_ID_GMCON_RENG; |
| @@ -396,7 +405,7 @@ static int cz_smu_populate_single_scratch_task( · 82 unmodified lines | |||
| 396 | struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++]; | 405 | struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++]; |
| 397 | 406 | ||
| 398 | task->type = type; | 407 | task->type = type; |
| 399 | task->arg = cz_translate_firmware_enum_to_arg(fw_enum); | 408 | task->arg = cz_translate_firmware_enum_to_arg(smumgr, fw_enum); |
| 400 | task->next = is_last ? END_OF_TASK_LIST : cz_smu->toc_entry_used_count; | 409 | task->next = is_last ? END_OF_TASK_LIST : cz_smu->toc_entry_used_count; |
| 401 | 410 | ||
| 402 | for (i = 0; i < cz_smu->scratch_buffer_length; i++) | 411 | for (i = 0; i < cz_smu->scratch_buffer_length; i++) |
| @@ -433,7 +442,7 @@ static int cz_smu_populate_single_ucode_load_task( · 30 unmodified lines | |||
| 433 | struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++]; | 442 | struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++]; |
| 434 | 443 | ||
| 435 | task->type = TASK_TYPE_UCODE_LOAD; | 444 | task->type = TASK_TYPE_UCODE_LOAD; |
| 436 | task->arg = cz_translate_firmware_enum_to_arg(fw_enum); | 445 | task->arg = cz_translate_firmware_enum_to_arg(smumgr, fw_enum); |
| 437 | task->next = is_last ? END_OF_TASK_LIST : cz_smu->toc_entry_used_count; | 446 | task->next = is_last ? END_OF_TASK_LIST : cz_smu->toc_entry_used_count; |
| 438 | 447 | ||
| 439 | for (i = 0; i < cz_smu->driver_buffer_length; i++) | 448 | for (i = 0; i < cz_smu->driver_buffer_length; i++) |
| @@ -509,8 +518,14 @@ static int cz_smu_construct_toc_for_vddgfx_exit(struct pp_smumgr *smumgr) · 69 unmodified lines | |||
| 509 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); | 518 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); |
| 510 | cz_smu_populate_single_ucode_load_task(smumgr, | 519 | cz_smu_populate_single_ucode_load_task(smumgr, |
| 511 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | 520 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); |
| 512 | cz_smu_populate_single_ucode_load_task(smumgr, | 521 | |
| 522 | if (smumgr->chip_id == CHIP_STONEY) | ||
| 523 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
| 524 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | ||
| 525 | else | ||
| 526 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
| 513 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); | 527 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); |
| 528 | |||
| 514 | cz_smu_populate_single_ucode_load_task(smumgr, | 529 | cz_smu_populate_single_ucode_load_task(smumgr, |
| 515 | CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, false); | 530 | CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, false); |
| 516 | 531 | ||
| @@ -551,7 +566,11 @@ static int cz_smu_construct_toc_for_bootup(struct pp_smumgr *smumgr) · 34 unmodified lines | |||
| 551 | 566 | ||
| 552 | cz_smu_populate_single_ucode_load_task(smumgr, | 567 | cz_smu_populate_single_ucode_load_task(smumgr, |
| 553 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); | 568 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); |
| 554 | cz_smu_populate_single_ucode_load_task(smumgr, | 569 | if (smumgr->chip_id == CHIP_STONEY) |
| 570 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
| 571 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false); | ||
| 572 | else | ||
| 573 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
| 555 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, false); | 574 | CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, false); |
| 556 | cz_smu_populate_single_ucode_load_task(smumgr, | 575 | cz_smu_populate_single_ucode_load_task(smumgr, |
| 557 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE, false); | 576 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE, false); |
| @@ -561,7 +580,11 @@ static int cz_smu_construct_toc_for_bootup(struct pp_smumgr *smumgr) · 3 unmodified lines | |||
| 561 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); | 580 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false); |
| 562 | cz_smu_populate_single_ucode_load_task(smumgr, | 581 | cz_smu_populate_single_ucode_load_task(smumgr, |
| 563 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | 582 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); |
| 564 | cz_smu_populate_single_ucode_load_task(smumgr, | 583 | if (smumgr->chip_id == CHIP_STONEY) |
| 584 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
| 585 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false); | ||
| 586 | else | ||
| 587 | cz_smu_populate_single_ucode_load_task(smumgr, | ||
| 565 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); | 588 | CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false); |
| 566 | cz_smu_populate_single_ucode_load_task(smumgr, | 589 | cz_smu_populate_single_ucode_load_task(smumgr, |
| 567 | CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, true); | 590 | CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, true); |
| @@ -618,7 +641,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr) · 50 unmodified lines | |||
| 618 | 641 | ||
| 619 | for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) { | 642 | for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) { |
| 620 | 643 | ||
| 621 | firmware_type = cz_translate_firmware_enum_to_arg( | 644 | firmware_type = cz_translate_firmware_enum_to_arg(smumgr, |
| 622 | firmware_list[i]); | 645 | firmware_list[i]); |
| 623 | 646 | ||
| 624 | ucode_id = cz_convert_fw_type_to_cgs(firmware_type); | 647 | ucode_id = cz_convert_fw_type_to_cgs(firmware_type); |
| @@ -946,9 +946,23 @@ static void wait_for_fences(struct drm_device *dev, · 945 unmodified lines | |||
| 946 | } | 946 | } |
| 947 | } | 947 | } |
| 948 | 948 | ||
| 949 | static bool framebuffer_changed(struct drm_device *dev, | 949 | /** |
| 950 | struct drm_atomic_state *old_state, | 950 | * drm_atomic_helper_framebuffer_changed - check if framebuffer has changed |
| 951 | struct drm_crtc *crtc) | 951 | * @dev: DRM device |
| 952 | * @old_state: atomic state object with old state structures | ||
| 953 | * @crtc: DRM crtc | ||
| 954 | * | ||
| 955 | * Checks whether the framebuffer used for this CRTC changes as a result of | ||
| 956 | * the atomic update. This is useful for drivers which cannot use | ||
| 957 | * drm_atomic_helper_wait_for_vblanks() and need to reimplement its | ||
| 958 | * functionality. | ||
| 959 | * | ||
| 960 | * Returns: | ||
| 961 | * true if the framebuffer changed. | ||
| 962 | */ | ||
| 963 | bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev, | ||
| 964 | struct drm_atomic_state *old_state, | ||
| 965 | struct drm_crtc *crtc) | ||
| 952 | { | 966 | { |
| 953 | struct drm_plane *plane; | 967 | struct drm_plane *plane; |
| 954 | struct drm_plane_state *old_plane_state; | 968 | struct drm_plane_state *old_plane_state; |
| @@ -965,6 +979,7 @@ static bool framebuffer_changed(struct drm_device *dev, · 10 unmodified lines | |||
| 965 | 979 | ||
| 966 | return false; | 980 | return false; |
| 967 | } | 981 | } |
| 982 | EXPORT_SYMBOL(drm_atomic_helper_framebuffer_changed); | ||
| 968 | 983 | ||
| 969 | /** | 984 | /** |
| 970 | * drm_atomic_helper_wait_for_vblanks - wait for vblank on crtcs | 985 | * drm_atomic_helper_wait_for_vblanks - wait for vblank on crtcs |
| @@ -999,7 +1014,8 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, · 28 unmodified lines | |||
| 999 | if (old_state->legacy_cursor_update) | 1014 | if (old_state->legacy_cursor_update) |
| 1000 | continue; | 1015 | continue; |
| 1001 | 1016 | ||
| 1002 | if (!framebuffer_changed(dev, old_state, crtc)) | 1017 | if (!drm_atomic_helper_framebuffer_changed(dev, |
| 1018 | old_state, crtc)) | ||
| 1003 | continue; | 1019 | continue; |
| 1004 | 1020 | ||
| 1005 | ret = drm_crtc_vblank_get(crtc); | 1021 | ret = drm_crtc_vblank_get(crtc); |
| @@ -8,8 +8,8 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng · 7 unmodified lines | |||
| 8 | git clone git://0x04.net/rules-ng-ng | 8 | git clone git://0x04.net/rules-ng-ng |
| 9 | 9 | ||
| 10 | The rules-ng-ng source files this header was generated from are: | 10 | The rules-ng-ng source files this header was generated from are: |
| 11 | - state_vg.xml ( 5973 bytes, from 2015-03-25 11:26:01) | 11 | - state_hi.xml ( 24309 bytes, from 2015-12-12 09:02:53) |
| 12 | - common.xml ( 18437 bytes, from 2015-03-25 11:27:41) | 12 | - common.xml ( 18379 bytes, from 2015-12-12 09:02:53) |
| 13 | 13 | ||
| 14 | Copyright (C) 2015 | 14 | Copyright (C) 2015 |
| 15 | */ | 15 | */ |
| @@ -30,15 +30,19 @@ Copyright (C) 2015 · 14 unmodified lines | |||
| 30 | #define ENDIAN_MODE_NO_SWAP 0x00000000 | 30 | #define ENDIAN_MODE_NO_SWAP 0x00000000 |
| 31 | #define ENDIAN_MODE_SWAP_16 0x00000001 | 31 | #define ENDIAN_MODE_SWAP_16 0x00000001 |
| 32 | #define ENDIAN_MODE_SWAP_32 0x00000002 | 32 | #define ENDIAN_MODE_SWAP_32 0x00000002 |
| 33 | #define chipModel_GC200 0x00000200 | ||
| 33 | #define chipModel_GC300 0x00000300 | 34 | #define chipModel_GC300 0x00000300 |
| 34 | #define chipModel_GC320 0x00000320 | 35 | #define chipModel_GC320 0x00000320 |
| 36 | #define chipModel_GC328 0x00000328 | ||
| 35 | #define chipModel_GC350 0x00000350 | 37 | #define chipModel_GC350 0x00000350 |
| 36 | #define chipModel_GC355 0x00000355 | 38 | #define chipModel_GC355 0x00000355 |
| 37 | #define chipModel_GC400 0x00000400 | 39 | #define chipModel_GC400 0x00000400 |
| 38 | #define chipModel_GC410 0x00000410 | 40 | #define chipModel_GC410 0x00000410 |
| 39 | #define chipModel_GC420 0x00000420 | 41 | #define chipModel_GC420 0x00000420 |
| 42 | #define chipModel_GC428 0x00000428 | ||
| 40 | #define chipModel_GC450 0x00000450 | 43 | #define chipModel_GC450 0x00000450 |
| 41 | #define chipModel_GC500 0x00000500 | 44 | #define chipModel_GC500 0x00000500 |
| 45 | #define chipModel_GC520 0x00000520 | ||
| 42 | #define chipModel_GC530 0x00000530 | 46 | #define chipModel_GC530 0x00000530 |
| 43 | #define chipModel_GC600 0x00000600 | 47 | #define chipModel_GC600 0x00000600 |
| 44 | #define chipModel_GC700 0x00000700 | 48 | #define chipModel_GC700 0x00000700 |
| @@ -46,9 +50,16 @@ Copyright (C) 2015 · 1 unmodified line | |||
| 46 | #define chipModel_GC860 0x00000860 | 50 | #define chipModel_GC860 0x00000860 |
| 47 | #define chipModel_GC880 0x00000880 | 51 | #define chipModel_GC880 0x00000880 |
| 48 | #define chipModel_GC1000 0x00001000 | 52 | #define chipModel_GC1000 0x00001000 |
| 53 | #define chipModel_GC1500 0x00001500 | ||
| 49 | #define chipModel_GC2000 0x00002000 | 54 | #define chipModel_GC2000 0x00002000 |
| 50 | #define chipModel_GC2100 0x00002100 | 55 | #define chipModel_GC2100 0x00002100 |
| 56 | #define chipModel_GC2200 0x00002200 | ||
| 57 | #define chipModel_GC2500 0x00002500 | ||
| 58 | #define chipModel_GC3000 0x00003000 | ||
| 51 | #define chipModel_GC4000 0x00004000 | 59 | #define chipModel_GC4000 0x00004000 |
| 60 | #define chipModel_GC5000 0x00005000 | ||
| 61 | #define chipModel_GC5200 0x00005200 | ||
| 62 | #define chipModel_GC6400 0x00006400 | ||
| 52 | #define RGBA_BITS_R 0x00000001 | 63 | #define RGBA_BITS_R 0x00000001 |
| 53 | #define RGBA_BITS_G 0x00000002 | 64 | #define RGBA_BITS_G 0x00000002 |
| 54 | #define RGBA_BITS_B 0x00000004 | 65 | #define RGBA_BITS_B 0x00000004 |
| @@ -160,7 +171,7 @@ Copyright (C) 2015 · 105 unmodified lines | |||
| 160 | #define chipMinorFeatures2_UNK8 0x00000100 | 171 | #define chipMinorFeatures2_UNK8 0x00000100 |
| 161 | #define chipMinorFeatures2_UNK9 0x00000200 | 172 | #define chipMinorFeatures2_UNK9 0x00000200 |
| 162 | #define chipMinorFeatures2_UNK10 0x00000400 | 173 | #define chipMinorFeatures2_UNK10 0x00000400 |
| 163 | #define chipMinorFeatures2_SAMPLERBASE_16 0x00000800 | 174 | #define chipMinorFeatures2_HALTI1 0x00000800 |
| 164 | #define chipMinorFeatures2_UNK12 0x00001000 | 175 | #define chipMinorFeatures2_UNK12 0x00001000 |
| 165 | #define chipMinorFeatures2_UNK13 0x00002000 | 176 | #define chipMinorFeatures2_UNK13 0x00002000 |
| 166 | #define chipMinorFeatures2_UNK14 0x00004000 | 177 | #define chipMinorFeatures2_UNK14 0x00004000 |
| @@ -189,7 +200,7 @@ Copyright (C) 2015 · 22 unmodified lines | |||
| 189 | #define chipMinorFeatures3_UNK5 0x00000020 | 200 | #define chipMinorFeatures3_UNK5 0x00000020 |
| 190 | #define chipMinorFeatures3_UNK6 0x00000040 | 201 | #define chipMinorFeatures3_UNK6 0x00000040 |
| 191 | #define chipMinorFeatures3_UNK7 0x00000080 | 202 | #define chipMinorFeatures3_UNK7 0x00000080 |
| 192 | #define chipMinorFeatures3_UNK8 0x00000100 | 203 | #define chipMinorFeatures3_FAST_MSAA 0x00000100 |
| 193 | #define chipMinorFeatures3_UNK9 0x00000200 | 204 | #define chipMinorFeatures3_UNK9 0x00000200 |
| 194 | #define chipMinorFeatures3_BUG_FIXES10 0x00000400 | 205 | #define chipMinorFeatures3_BUG_FIXES10 0x00000400 |
| 195 | #define chipMinorFeatures3_UNK11 0x00000800 | 206 | #define chipMinorFeatures3_UNK11 0x00000800 |
| @@ -199,7 +210,7 @@ Copyright (C) 2015 · 3 unmodified lines | |||
| 199 | #define chipMinorFeatures3_UNK15 0x00008000 | 210 | #define chipMinorFeatures3_UNK15 0x00008000 |
| 200 | #define chipMinorFeatures3_UNK16 0x00010000 | 211 | #define chipMinorFeatures3_UNK16 0x00010000 |
| 201 | #define chipMinorFeatures3_UNK17 0x00020000 | 212 | #define chipMinorFeatures3_UNK17 0x00020000 |
| 202 | #define chipMinorFeatures3_UNK18 0x00040000 | 213 | #define chipMinorFeatures3_ACE 0x00040000 |
| 203 | #define chipMinorFeatures3_UNK19 0x00080000 | 214 | #define chipMinorFeatures3_UNK19 0x00080000 |
| 204 | #define chipMinorFeatures3_UNK20 0x00100000 | 215 | #define chipMinorFeatures3_UNK20 0x00100000 |
| 205 | #define chipMinorFeatures3_UNK21 0x00200000 | 216 | #define chipMinorFeatures3_UNK21 0x00200000 |
| @@ -207,7 +218,7 @@ Copyright (C) 2015 · 1 unmodified line | |||
| 207 | #define chipMinorFeatures3_UNK23 0x00800000 | 218 | #define chipMinorFeatures3_UNK23 0x00800000 |
| 208 | #define chipMinorFeatures3_UNK24 0x01000000 | 219 | #define chipMinorFeatures3_UNK24 0x01000000 |
| 209 | #define chipMinorFeatures3_UNK25 0x02000000 | 220 | #define chipMinorFeatures3_UNK25 0x02000000 |
| 210 | #define chipMinorFeatures3_UNK26 0x04000000 | 221 | #define chipMinorFeatures3_NEW_HZ 0x04000000 |
| 211 | #define chipMinorFeatures3_UNK27 0x08000000 | 222 | #define chipMinorFeatures3_UNK27 0x08000000 |
| 212 | #define chipMinorFeatures3_UNK28 0x10000000 | 223 | #define chipMinorFeatures3_UNK28 0x10000000 |
| 213 | #define chipMinorFeatures3_UNK29 0x20000000 | 224 | #define chipMinorFeatures3_UNK29 0x20000000 |
| @@ -229,9 +240,9 @@ Copyright (C) 2015 · 15 unmodified lines | |||
| 229 | #define chipMinorFeatures4_UNK13 0x00002000 | 240 | #define chipMinorFeatures4_UNK13 0x00002000 |
| 230 | #define chipMinorFeatures4_UNK14 0x00004000 | 241 | #define chipMinorFeatures4_UNK14 0x00004000 |
| 231 | #define chipMinorFeatures4_UNK15 0x00008000 | 242 | #define chipMinorFeatures4_UNK15 0x00008000 |
| 232 | #define chipMinorFeatures4_UNK16 0x00010000 | 243 | #define chipMinorFeatures4_HALTI2 0x00010000 |
| 233 | #define chipMinorFeatures4_UNK17 0x00020000 | 244 | #define chipMinorFeatures4_UNK17 0x00020000 |
| 234 | #define chipMinorFeatures4_UNK18 0x00040000 | 245 | #define chipMinorFeatures4_SMALL_MSAA 0x00040000 |
| 235 | #define chipMinorFeatures4_UNK19 0x00080000 | 246 | #define chipMinorFeatures4_UNK19 0x00080000 |
| 236 | #define chipMinorFeatures4_UNK20 0x00100000 | 247 | #define chipMinorFeatures4_UNK20 0x00100000 |
| 237 | #define chipMinorFeatures4_UNK21 0x00200000 | 248 | #define chipMinorFeatures4_UNK21 0x00200000 |
| @@ -245,5 +256,37 @@ Copyright (C) 2015 · 7 unmodified lines | |||
| 245 | #define chipMinorFeatures4_UNK29 0x20000000 | 256 | #define chipMinorFeatures4_UNK29 0x20000000 |
| 246 | #define chipMinorFeatures4_UNK30 0x40000000 | 257 | #define chipMinorFeatures4_UNK30 0x40000000 |
| 247 | #define chipMinorFeatures4_UNK31 0x80000000 | 258 | #define chipMinorFeatures4_UNK31 0x80000000 |
| 259 | #define chipMinorFeatures5_UNK0 0x00000001 | ||
| 260 | #define chipMinorFeatures5_UNK1 0x00000002 | ||
| 261 | #define chipMinorFeatures5_UNK2 0x00000004 | ||
| 262 | #define chipMinorFeatures5_UNK3 0x00000008 | ||
| 263 | #define chipMinorFeatures5_UNK4 0x00000010 | ||
| 264 | #define chipMinorFeatures5_UNK5 0x00000020 | ||
| 265 | #define chipMinorFeatures5_UNK6 0x00000040 | ||
| 266 | #define chipMinorFeatures5_UNK7 0x00000080 | ||
| 267 | #define chipMinorFeatures5_UNK8 0x00000100 | ||
| 268 | #define chipMinorFeatures5_HALTI3 0x00000200 | ||
| 269 | #define chipMinorFeatures5_UNK10 0x00000400 | ||
| 270 | #define chipMinorFeatures5_UNK11 0x00000800 | ||
| 271 | #define chipMinorFeatures5_UNK12 0x00001000 | ||
| 272 | #define chipMinorFeatures5_UNK13 0x00002000 | ||
| 273 | #define chipMinorFeatures5_UNK14 0x00004000 | ||
| 274 | #define chipMinorFeatures5_UNK15 0x00008000 | ||
| 275 | #define chipMinorFeatures5_UNK16 0x00010000 | ||
| 276 | #define chipMinorFeatures5_UNK17 0x00020000 | ||
| 277 | #define chipMinorFeatures5_UNK18 0x00040000 | ||
| 278 | #define chipMinorFeatures5_UNK19 0x00080000 | ||
| 279 | #define chipMinorFeatures5_UNK20 0x00100000 | ||
| 280 | #define chipMinorFeatures5_UNK21 0x00200000 | ||
| 281 | #define chipMinorFeatures5_UNK22 0x00400000 | ||
| 282 | #define chipMinorFeatures5_UNK23 0x00800000 | ||
| 283 | #define chipMinorFeatures5_UNK24 0x01000000 | ||
| 284 | #define chipMinorFeatures5_UNK25 0x02000000 | ||
| 285 | #define chipMinorFeatures5_UNK26 0x04000000 | ||
| 286 | #define chipMinorFeatures5_UNK27 0x08000000 | ||
| 287 | #define chipMinorFeatures5_UNK28 0x10000000 | ||
| 288 | #define chipMinorFeatures5_UNK29 0x20000000 | ||
| 289 | #define chipMinorFeatures5_UNK30 0x40000000 | ||
| 290 | #define chipMinorFeatures5_UNK31 0x80000000 | ||
| 248 | 291 | ||
| 249 | #endif /* COMMON_XML */ | 292 | #endif /* COMMON_XML */ |
| @@ -668,7 +668,6 @@ static struct platform_driver etnaviv_platform_driver = { · 667 unmodified lines | |||
| 668 | .probe = etnaviv_pdev_probe, | 668 | .probe = etnaviv_pdev_probe, |
| 669 | .remove = etnaviv_pdev_remove, | 669 | .remove = etnaviv_pdev_remove, |
| 670 | .driver = { | 670 | .driver = { |
| 671 | .owner = THIS_MODULE, | ||
| 672 | .name = "etnaviv", | 671 | .name = "etnaviv", |
| 673 | .of_match_table = dt_match, | 672 | .of_match_table = dt_match, |
| 674 | }, | 673 | }, |
| @@ -85,7 +85,7 @@ struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, · 84 unmodified lines | |||
| 85 | struct dma_buf_attachment *attach, struct sg_table *sg); | 85 | struct dma_buf_attachment *attach, struct sg_table *sg); |
| 86 | int etnaviv_gem_prime_pin(struct drm_gem_object *obj); | 86 | int etnaviv_gem_prime_pin(struct drm_gem_object *obj); |
| 87 | void etnaviv_gem_prime_unpin(struct drm_gem_object *obj); | 87 | void etnaviv_gem_prime_unpin(struct drm_gem_object *obj); |
| 88 | void *etnaviv_gem_vaddr(struct drm_gem_object *obj); | 88 | void *etnaviv_gem_vmap(struct drm_gem_object *obj); |
| 89 | int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, | 89 | int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op, |
| 90 | struct timespec *timeout); | 90 | struct timespec *timeout); |
| 91 | int etnaviv_gem_cpu_fini(struct drm_gem_object *obj); | 91 | int etnaviv_gem_cpu_fini(struct drm_gem_object *obj); |
| @@ -201,7 +201,9 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) · 200 unmodified lines | |||
| 201 | 201 | ||
| 202 | obj = vram->object; | 202 | obj = vram->object; |
| 203 | 203 | ||
| 204 | mutex_lock(&obj->lock); | ||
| 204 | pages = etnaviv_gem_get_pages(obj); | 205 | pages = etnaviv_gem_get_pages(obj); |
| 206 | mutex_unlock(&obj->lock); | ||
| 205 | if (pages) { | 207 | if (pages) { |
| 206 | int j; | 208 | int j; |
| 207 | 209 | ||
| @@ -213,8 +215,8 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) · 5 unmodified lines | |||
| 213 | 215 | ||
| 214 | iter.hdr->iova = cpu_to_le64(vram->iova); | 216 | iter.hdr->iova = cpu_to_le64(vram->iova); |
| 215 | 217 | ||
| 216 | vaddr = etnaviv_gem_vaddr(&obj->base); | 218 | vaddr = etnaviv_gem_vmap(&obj->base); |
| 217 | if (vaddr && !IS_ERR(vaddr)) | 219 | if (vaddr) |
| 218 | memcpy(iter.data, vaddr, obj->base.size); | 220 | memcpy(iter.data, vaddr, obj->base.size); |
| 219 | 221 | ||
| 220 | etnaviv_core_dump_header(&iter, ETDUMP_BUF_BO, iter.data + | 222 | etnaviv_core_dump_header(&iter, ETDUMP_BUF_BO, iter.data + |
| @@ -353,25 +353,39 @@ void etnaviv_gem_put_iova(struct etnaviv_gpu *gpu, struct drm_gem_object *obj) · 352 unmodified lines | |||
| 353 | drm_gem_object_unreference_unlocked(obj); | 353 | drm_gem_object_unreference_unlocked(obj); |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | void *etnaviv_gem_vaddr(struct drm_gem_object *obj) | 356 | void *etnaviv_gem_vmap(struct drm_gem_object *obj) |
| 357 | { | 357 | { |
| 358 | struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); | 358 | struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); |
| 359 | 359 | ||
| 360 | mutex_lock(&etnaviv_obj->lock); | 360 | if (etnaviv_obj->vaddr) |
| 361 | if (!etnaviv_obj->vaddr) { | 361 | return etnaviv_obj->vaddr; |
| 362 | struct page **pages = etnaviv_gem_get_pages(etnaviv_obj); | ||
| 363 | |||
| 364 | if (IS_ERR(pages)) | ||
| 365 | return ERR_CAST(pages); | ||
| 366 | 362 | ||
| 367 | etnaviv_obj->vaddr = vmap(pages, obj->size >> PAGE_SHIFT, | 363 | mutex_lock(&etnaviv_obj->lock); |
| 368 | VM_MAP, pgprot_writecombine(PAGE_KERNEL)); | 364 | /* |
| 369 | } | 365 | * Need to check again, as we might have raced with another thread |
| 366 | * while waiting for the mutex. | ||
| 367 | */ | ||
| 368 | if (!etnaviv_obj->vaddr) | ||
| 369 | etnaviv_obj->vaddr = etnaviv_obj->ops->vmap(etnaviv_obj); | ||
| 370 | mutex_unlock(&etnaviv_obj->lock); | 370 | mutex_unlock(&etnaviv_obj->lock); |
| 371 | 371 | ||
| 372 | return etnaviv_obj->vaddr; | 372 | return etnaviv_obj->vaddr; |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | static void *etnaviv_gem_vmap_impl(struct etnaviv_gem_object *obj) | ||
| 376 | { | ||
| 377 | struct page **pages; | ||
| 378 | |||
| 379 | lockdep_assert_held(&obj->lock); | ||
| 380 | |||
| 381 | pages = etnaviv_gem_get_pages(obj); | ||
| 382 | if (IS_ERR(pages)) | ||
| 383 | return NULL; | ||
| 384 | |||
| 385 | return vmap(pages, obj->base.size >> PAGE_SHIFT, | ||
| 386 | VM_MAP, pgprot_writecombine(PAGE_KERNEL)); | ||
| 387 | } | ||
| 388 | |||
| 375 | static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op) | 389 | static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op) |
| 376 | { | 390 | { |
| 377 | if (op & ETNA_PREP_READ) | 391 | if (op & ETNA_PREP_READ) |
| @@ -522,6 +536,7 @@ static void etnaviv_gem_shmem_release(struct etnaviv_gem_object *etnaviv_obj) · 144 unmodified lines | |||
| 522 | static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = { | 536 | static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = { |
| 523 | .get_pages = etnaviv_gem_shmem_get_pages, | 537 | .get_pages = etnaviv_gem_shmem_get_pages, |
| 524 | .release = etnaviv_gem_shmem_release, | 538 | .release = etnaviv_gem_shmem_release, |
| 539 | .vmap = etnaviv_gem_vmap_impl, | ||
| 525 | }; | 540 | }; |
| 526 | 541 | ||
| 527 | void etnaviv_gem_free_object(struct drm_gem_object *obj) | 542 | void etnaviv_gem_free_object(struct drm_gem_object *obj) |
| @@ -866,6 +881,7 @@ static void etnaviv_gem_userptr_release(struct etnaviv_gem_object *etnaviv_obj) · 338 unmodified lines | |||
| 866 | static const struct etnaviv_gem_ops etnaviv_gem_userptr_ops = { | 881 | static const struct etnaviv_gem_ops etnaviv_gem_userptr_ops = { |
| 867 | .get_pages = etnaviv_gem_userptr_get_pages, | 882 | .get_pages = etnaviv_gem_userptr_get_pages, |
| 868 | .release = etnaviv_gem_userptr_release, | 883 | .release = etnaviv_gem_userptr_release, |
| 884 | .vmap = etnaviv_gem_vmap_impl, | ||
| 869 | }; | 885 | }; |
| 870 | 886 | ||
| 871 | int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file, | 887 | int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file, |
| @@ -78,6 +78,7 @@ struct etnaviv_gem_object *to_etnaviv_bo(struct drm_gem_object *obj) · 77 unmodified lines | |||
| 78 | struct etnaviv_gem_ops { | 78 | struct etnaviv_gem_ops { |
| 79 | int (*get_pages)(struct etnaviv_gem_object *); | 79 | int (*get_pages)(struct etnaviv_gem_object *); |
| 80 | void (*release)(struct etnaviv_gem_object *); | 80 | void (*release)(struct etnaviv_gem_object *); |
| 81 | void *(*vmap)(struct etnaviv_gem_object *); | ||
| 81 | }; | 82 | }; |
| 82 | 83 | ||
| 83 | static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj) | 84 | static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj) |
| @@ -31,7 +31,7 @@ struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj) · 30 unmodified lines | |||
| 31 | 31 | ||
| 32 | void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj) | 32 | void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj) |
| 33 | { | 33 | { |
| 34 | return etnaviv_gem_vaddr(obj); | 34 | return etnaviv_gem_vmap(obj); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) | 37 | void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) |
| @@ -77,9 +77,17 @@ static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj) · 39 unmodified lines | |||
| 77 | drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt); | 77 | drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj) | ||
| 81 | { | ||
| 82 | lockdep_assert_held(&etnaviv_obj->lock); | ||
| 83 | |||
| 84 | return dma_buf_vmap(etnaviv_obj->base.import_attach->dmabuf); | ||
| 85 | } | ||
| 86 | |||
| 80 | static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = { | 87 | static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = { |
| 81 | /* .get_pages should never be called */ | 88 | /* .get_pages should never be called */ |
| 82 | .release = etnaviv_gem_prime_release, | 89 | .release = etnaviv_gem_prime_release, |
| 90 | .vmap = etnaviv_gem_prime_vmap_impl, | ||
| 83 | }; | 91 | }; |
| 84 | 92 | ||
| 85 | struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, | 93 | struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, |
| @@ -72,6 +72,14 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) · 71 unmodified lines | |||
| 72 | *value = gpu->identity.minor_features3; | 72 | *value = gpu->identity.minor_features3; |
| 73 | break; | 73 | break; |
| 74 | 74 | ||
| 75 | case ETNAVIV_PARAM_GPU_FEATURES_5: | ||
| 76 | *value = gpu->identity.minor_features4; | ||
| 77 | break; | ||
| 78 | |||
| 79 | case ETNAVIV_PARAM_GPU_FEATURES_6: | ||
| 80 | *value = gpu->identity.minor_features5; | ||
| 81 | break; | ||
| 82 | |||
| 75 | case ETNAVIV_PARAM_GPU_STREAM_COUNT: | 83 | case ETNAVIV_PARAM_GPU_STREAM_COUNT: |
| 76 | *value = gpu->identity.stream_count; | 84 | *value = gpu->identity.stream_count; |
| 77 | break; | 85 | break; |
| @@ -112,6 +120,10 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) · 34 unmodified lines | |||
| 112 | *value = gpu->identity.num_constants; | 120 | *value = gpu->identity.num_constants; |
| 113 | break; | 121 | break; |
| 114 | 122 | ||
| 123 | case ETNAVIV_PARAM_GPU_NUM_VARYINGS: | ||
| 124 | *value = gpu->identity.varyings_count; | ||
| 125 | break; | ||
| 126 | |||
| 115 | default: | 127 | default: |
| 116 | DBG("%s: invalid param: %u", dev_name(gpu->dev), param); | 128 | DBG("%s: invalid param: %u", dev_name(gpu->dev), param); |
| 117 | return -EINVAL; | 129 | return -EINVAL; |
| @@ -120,46 +132,56 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) · 2 unmodified lines | |||
| 120 | return 0; | 132 | return 0; |
| 121 | } | 133 | } |
| 122 | 134 | ||
| 135 | |||
| 136 | #define etnaviv_is_model_rev(gpu, mod, rev) \ | ||
| 137 | ((gpu)->identity.model == chipModel_##mod && \ | ||
| 138 | (gpu)->identity.revision == rev) | ||
| 139 | #define etnaviv_field(val, field) \ | ||
| 140 | (((val) & field##__MASK) >> field##__SHIFT) | ||
| 141 | |||
| 123 | static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) | 142 | static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) |
| 124 | { | 143 | { |
| 125 | if (gpu->identity.minor_features0 & | 144 | if (gpu->identity.minor_features0 & |
| 126 | chipMinorFeatures0_MORE_MINOR_FEATURES) { | 145 | chipMinorFeatures0_MORE_MINOR_FEATURES) { |
| 127 | u32 specs[2]; | 146 | u32 specs[4]; |
| 147 | unsigned int streams; | ||
| 128 | 148 | ||
| 129 | specs[0] = gpu_read(gpu, VIVS_HI_CHIP_SPECS); | 149 | specs[0] = gpu_read(gpu, VIVS_HI_CHIP_SPECS); |
| 130 | specs[1] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_2); | 150 | specs[1] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_2); |
| 131 | 151 | specs[2] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_3); | |
| 132 | gpu->identity.stream_count = | 152 | specs[3] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_4); |
| 133 | (specs[0] & VIVS_HI_CHIP_SPECS_STREAM_COUNT__MASK) | 153 | |
| 134 | >> VIVS_HI_CHIP_SPECS_STREAM_COUNT__SHIFT; | 154 | gpu->identity.stream_count = etnaviv_field(specs[0], |
| 135 | gpu->identity.register_max = | 155 | VIVS_HI_CHIP_SPECS_STREAM_COUNT); |
| 136 | (specs[0] & VIVS_HI_CHIP_SPECS_REGISTER_MAX__MASK) | 156 | gpu->identity.register_max = etnaviv_field(specs[0], |
| 137 | >> VIVS_HI_CHIP_SPECS_REGISTER_MAX__SHIFT; | 157 | VIVS_HI_CHIP_SPECS_REGISTER_MAX); |
| 138 | gpu->identity.thread_count = | 158 | gpu->identity.thread_count = etnaviv_field(specs[0], |
| 139 | (specs[0] & VIVS_HI_CHIP_SPECS_THREAD_COUNT__MASK) | 159 | VIVS_HI_CHIP_SPECS_THREAD_COUNT); |
| 140 | >> VIVS_HI_CHIP_SPECS_THREAD_COUNT__SHIFT; | 160 | gpu->identity.vertex_cache_size = etnaviv_field(specs[0], |
| 141 | gpu->identity.vertex_cache_size = | 161 | VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE); |
| 142 | (specs[0] & VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE__MASK) | 162 | gpu->identity.shader_core_count = etnaviv_field(specs[0], |
| 143 | >> VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE__SHIFT; | 163 | VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT); |
| 144 | gpu->identity.shader_core_count = | 164 | gpu->identity.pixel_pipes = etnaviv_field(specs[0], |
| 145 | (specs[0] & VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT__MASK) | 165 | VIVS_HI_CHIP_SPECS_PIXEL_PIPES); |
| 146 | >> VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT__SHIFT; | ||
| 147 | gpu->identity.pixel_pipes = | ||
| 148 | (specs[0] & VIVS_HI_CHIP_SPECS_PIXEL_PIPES__MASK) | ||
| 149 | >> VIVS_HI_CHIP_SPECS_PIXEL_PIPES__SHIFT; | ||
| 150 | gpu->identity.vertex_output_buffer_size = | 166 | gpu->identity.vertex_output_buffer_size = |
| 151 | (specs[0] & VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE__MASK) | 167 | etnaviv_field(specs[0], |
| 152 | >> VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE__SHIFT; | 168 | VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE); |
| 153 | 169 | ||
| 154 | gpu->identity.buffer_size = | 170 | gpu->identity.buffer_size = etnaviv_field(specs[1], |
| 155 | (specs[1] & VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE__MASK) | 171 | VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE); |
| 156 | >> VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE__SHIFT; | 172 | gpu->identity.instruction_count = etnaviv_field(specs[1], |
| 157 | gpu->identity.instruction_count = | 173 | VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT); |
| 158 | (specs[1] & VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT__MASK) | 174 | gpu->identity.num_constants = etnaviv_field(specs[1], |
| 159 | >> VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT__SHIFT; | 175 | VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS); |
| 160 | gpu->identity.num_constants = | 176 | |
| 161 | (specs[1] & VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS__MASK) | 177 | gpu->identity.varyings_count = etnaviv_field(specs[2], |
| 162 | >> VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS__SHIFT; | 178 | VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT); |
| 179 | |||
| 180 | /* This overrides the value from older register if non-zero */ | ||
| 181 | streams = etnaviv_field(specs[3], | ||
| 182 | VIVS_HI_CHIP_SPECS_4_STREAM_COUNT); | ||
| 183 | if (streams) | ||
| 184 | gpu->identity.stream_count = streams; | ||
| 163 | } | 185 | } |
| 164 | 186 | ||
| 165 | /* Fill in the stream count if not specified */ | 187 | /* Fill in the stream count if not specified */ |
| @@ -173,7 +195,7 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 7 unmodified lines | |||
| 173 | /* Convert the register max value */ | 195 | /* Convert the register max value */ |
| 174 | if (gpu->identity.register_max) | 196 | if (gpu->identity.register_max) |
| 175 | gpu->identity.register_max = 1 << gpu->identity.register_max; | 197 | gpu->identity.register_max = 1 << gpu->identity.register_max; |
| 176 | else if (gpu->identity.model == 0x0400) | 198 | else if (gpu->identity.model == chipModel_GC400) |
| 177 | gpu->identity.register_max = 32; | 199 | gpu->identity.register_max = 32; |
| 178 | else | 200 | else |
| 179 | gpu->identity.register_max = 64; | 201 | gpu->identity.register_max = 64; |
| @@ -181,10 +203,10 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 1 unmodified line | |||
| 181 | /* Convert thread count */ | 203 | /* Convert thread count */ |
| 182 | if (gpu->identity.thread_count) | 204 | if (gpu->identity.thread_count) |
| 183 | gpu->identity.thread_count = 1 << gpu->identity.thread_count; | 205 | gpu->identity.thread_count = 1 << gpu->identity.thread_count; |
| 184 | else if (gpu->identity.model == 0x0400) | 206 | else if (gpu->identity.model == chipModel_GC400) |
| 185 | gpu->identity.thread_count = 64; | 207 | gpu->identity.thread_count = 64; |
| 186 | else if (gpu->identity.model == 0x0500 || | 208 | else if (gpu->identity.model == chipModel_GC500 || |
| 187 | gpu->identity.model == 0x0530) | 209 | gpu->identity.model == chipModel_GC530) |
| 188 | gpu->identity.thread_count = 128; | 210 | gpu->identity.thread_count = 128; |
| 189 | else | 211 | else |
| 190 | gpu->identity.thread_count = 256; | 212 | gpu->identity.thread_count = 256; |
| @@ -206,7 +228,7 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 15 unmodified lines | |||
| 206 | if (gpu->identity.vertex_output_buffer_size) { | 228 | if (gpu->identity.vertex_output_buffer_size) { |
| 207 | gpu->identity.vertex_output_buffer_size = | 229 | gpu->identity.vertex_output_buffer_size = |
| 208 | 1 << gpu->identity.vertex_output_buffer_size; | 230 | 1 << gpu->identity.vertex_output_buffer_size; |
| 209 | } else if (gpu->identity.model == 0x0400) { | 231 | } else if (gpu->identity.model == chipModel_GC400) { |
| 210 | if (gpu->identity.revision < 0x4000) | 232 | if (gpu->identity.revision < 0x4000) |
| 211 | gpu->identity.vertex_output_buffer_size = 512; | 233 | gpu->identity.vertex_output_buffer_size = 512; |
| 212 | else if (gpu->identity.revision < 0x4200) | 234 | else if (gpu->identity.revision < 0x4200) |
| @@ -219,9 +241,8 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 6 unmodified lines | |||
| 219 | 241 | ||
| 220 | switch (gpu->identity.instruction_count) { | 242 | switch (gpu->identity.instruction_count) { |
| 221 | case 0: | 243 | case 0: |
| 222 | if ((gpu->identity.model == 0x2000 && | 244 | if (etnaviv_is_model_rev(gpu, GC2000, 0x5108) || |
| 223 | gpu->identity.revision == 0x5108) || | 245 | gpu->identity.model == chipModel_GC880) |
| 224 | gpu->identity.model == 0x880) | ||
| 225 | gpu->identity.instruction_count = 512; | 246 | gpu->identity.instruction_count = 512; |
| 226 | else | 247 | else |
| 227 | gpu->identity.instruction_count = 256; | 248 | gpu->identity.instruction_count = 256; |
| @@ -242,6 +263,30 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 14 unmodified lines | |||
| 242 | 263 | ||
| 243 | if (gpu->identity.num_constants == 0) | 264 | if (gpu->identity.num_constants == 0) |
| 244 | gpu->identity.num_constants = 168; | 265 | gpu->identity.num_constants = 168; |
| 266 | |||
| 267 | if (gpu->identity.varyings_count == 0) { | ||
| 268 | if (gpu->identity.minor_features1 & chipMinorFeatures1_HALTI0) | ||
| 269 | gpu->identity.varyings_count = 12; | ||
| 270 | else | ||
| 271 | gpu->identity.varyings_count = 8; | ||
| 272 | } | ||
| 273 | |||
| 274 | /* | ||
| 275 | * For some cores, two varyings are consumed for position, so the | ||
| 276 | * maximum varying count needs to be reduced by one. | ||
| 277 | */ | ||
| 278 | if (etnaviv_is_model_rev(gpu, GC5000, 0x5434) || | ||
| 279 | etnaviv_is_model_rev(gpu, GC4000, 0x5222) || | ||
| 280 | etnaviv_is_model_rev(gpu, GC4000, 0x5245) || | ||
| 281 | etnaviv_is_model_rev(gpu, GC4000, 0x5208) || | ||
| 282 | etnaviv_is_model_rev(gpu, GC3000, 0x5435) || | ||
| 283 | etnaviv_is_model_rev(gpu, GC2200, 0x5244) || | ||
| 284 | etnaviv_is_model_rev(gpu, GC2100, 0x5108) || | ||
| 285 | etnaviv_is_model_rev(gpu, GC2000, 0x5108) || | ||
| 286 | etnaviv_is_model_rev(gpu, GC1500, 0x5246) || | ||
| 287 | etnaviv_is_model_rev(gpu, GC880, 0x5107) || | ||
| 288 | etnaviv_is_model_rev(gpu, GC880, 0x5106)) | ||
| 289 | gpu->identity.varyings_count -= 1; | ||
| 245 | } | 290 | } |
| 246 | 291 | ||
| 247 | static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) | 292 | static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) |
| @@ -251,12 +296,10 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 3 unmodified lines | |||
| 251 | chipIdentity = gpu_read(gpu, VIVS_HI_CHIP_IDENTITY); | 296 | chipIdentity = gpu_read(gpu, VIVS_HI_CHIP_IDENTITY); |
| 252 | 297 | ||
| 253 | /* Special case for older graphic cores. */ | 298 | /* Special case for older graphic cores. */ |
| 254 | if (((chipIdentity & VIVS_HI_CHIP_IDENTITY_FAMILY__MASK) | 299 | if (etnaviv_field(chipIdentity, VIVS_HI_CHIP_IDENTITY_FAMILY) == 0x01) { |
| 255 | >> VIVS_HI_CHIP_IDENTITY_FAMILY__SHIFT) == 0x01) { | 300 | gpu->identity.model = chipModel_GC500; |
| 256 | gpu->identity.model = 0x500; /* gc500 */ | 301 | gpu->identity.revision = etnaviv_field(chipIdentity, |
| 257 | gpu->identity.revision = | 302 | VIVS_HI_CHIP_IDENTITY_REVISION); |
| 258 | (chipIdentity & VIVS_HI_CHIP_IDENTITY_REVISION__MASK) | ||
| 259 | >> VIVS_HI_CHIP_IDENTITY_REVISION__SHIFT; | ||
| 260 | } else { | 303 | } else { |
| 261 | 304 | ||
| 262 | gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL); | 305 | gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL); |
| @@ -269,13 +312,12 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 6 unmodified lines | |||
| 269 | * same. Only for GC400 family. | 312 | * same. Only for GC400 family. |
| 270 | */ | 313 | */ |
| 271 | if ((gpu->identity.model & 0xff00) == 0x0400 && | 314 | if ((gpu->identity.model & 0xff00) == 0x0400 && |
| 272 | gpu->identity.model != 0x0420) { | 315 | gpu->identity.model != chipModel_GC420) { |
| 273 | gpu->identity.model = gpu->identity.model & 0x0400; | 316 | gpu->identity.model = gpu->identity.model & 0x0400; |
| 274 | } | 317 | } |
| 275 | 318 | ||
| 276 | /* Another special case */ | 319 | /* Another special case */ |
| 277 | if (gpu->identity.model == 0x300 && | 320 | if (etnaviv_is_model_rev(gpu, GC300, 0x2201)) { |
| 278 | gpu->identity.revision == 0x2201) { | ||
| 279 | u32 chipDate = gpu_read(gpu, VIVS_HI_CHIP_DATE); | 321 | u32 chipDate = gpu_read(gpu, VIVS_HI_CHIP_DATE); |
| 280 | u32 chipTime = gpu_read(gpu, VIVS_HI_CHIP_TIME); | 322 | u32 chipTime = gpu_read(gpu, VIVS_HI_CHIP_TIME); |
| 281 | 323 | ||
| @@ -295,11 +337,13 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 13 unmodified lines | |||
| 295 | gpu->identity.features = gpu_read(gpu, VIVS_HI_CHIP_FEATURE); | 337 | gpu->identity.features = gpu_read(gpu, VIVS_HI_CHIP_FEATURE); |
| 296 | 338 | ||
| 297 | /* Disable fast clear on GC700. */ | 339 | /* Disable fast clear on GC700. */ |
| 298 | if (gpu->identity.model == 0x700) | 340 | if (gpu->identity.model == chipModel_GC700) |
| 299 | gpu->identity.features &= ~chipFeatures_FAST_CLEAR; | 341 | gpu->identity.features &= ~chipFeatures_FAST_CLEAR; |
| 300 | 342 | ||
| 301 | if ((gpu->identity.model == 0x500 && gpu->identity.revision < 2) || | 343 | if ((gpu->identity.model == chipModel_GC500 && |
| 302 | (gpu->identity.model == 0x300 && gpu->identity.revision < 0x2000)) { | 344 | gpu->identity.revision < 2) || |
| 345 | (gpu->identity.model == chipModel_GC300 && | ||
| 346 | gpu->identity.revision < 0x2000)) { | ||
| 303 | 347 | ||
| 304 | /* | 348 | /* |
| 305 | * GC500 rev 1.x and GC300 rev < 2.0 doesn't have these | 349 | * GC500 rev 1.x and GC300 rev < 2.0 doesn't have these |
| @@ -309,6 +353,8 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 3 unmodified lines | |||
| 309 | gpu->identity.minor_features1 = 0; | 353 | gpu->identity.minor_features1 = 0; |
| 310 | gpu->identity.minor_features2 = 0; | 354 | gpu->identity.minor_features2 = 0; |
| 311 | gpu->identity.minor_features3 = 0; | 355 | gpu->identity.minor_features3 = 0; |
| 356 | gpu->identity.minor_features4 = 0; | ||
| 357 | gpu->identity.minor_features5 = 0; | ||
| 312 | } else | 358 | } else |
| 313 | gpu->identity.minor_features0 = | 359 | gpu->identity.minor_features0 = |
| 314 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_0); | 360 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_0); |
| @@ -321,6 +367,10 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 6 unmodified lines | |||
| 321 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_2); | 367 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_2); |
| 322 | gpu->identity.minor_features3 = | 368 | gpu->identity.minor_features3 = |
| 323 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_3); | 369 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_3); |
| 370 | gpu->identity.minor_features4 = | ||
| 371 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_4); | ||
| 372 | gpu->identity.minor_features5 = | ||
| 373 | gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_5); | ||
| 324 | } | 374 | } |
| 325 | 375 | ||
| 326 | /* GC600 idle register reports zero bits where modules aren't present */ | 376 | /* GC600 idle register reports zero bits where modules aren't present */ |
| @@ -441,10 +491,9 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu) · 114 unmodified lines | |||
| 441 | { | 491 | { |
| 442 | u16 prefetch; | 492 | u16 prefetch; |
| 443 | 493 | ||
| 444 | if (gpu->identity.model == chipModel_GC320 && | 494 | if ((etnaviv_is_model_rev(gpu, GC320, 0x5007) || |
| 445 | gpu_read(gpu, VIVS_HI_CHIP_TIME) != 0x2062400 && | 495 | etnaviv_is_model_rev(gpu, GC320, 0x5220)) && |
| 446 | (gpu->identity.revision == 0x5007 || | 496 | gpu_read(gpu, VIVS_HI_CHIP_TIME) != 0x2062400) { |
| 447 | gpu->identity.revision == 0x5220)) { | ||
| 448 | u32 mc_memory_debug; | 497 | u32 mc_memory_debug; |
| 449 | 498 | ||
| 450 | mc_memory_debug = gpu_read(gpu, VIVS_MC_DEBUG_MEMORY) & ~0xff; | 499 | mc_memory_debug = gpu_read(gpu, VIVS_MC_DEBUG_MEMORY) & ~0xff; |
| @@ -466,7 +515,7 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu) · 15 unmodified lines | |||
| 466 | VIVS_HI_AXI_CONFIG_ARCACHE(2)); | 515 | VIVS_HI_AXI_CONFIG_ARCACHE(2)); |
| 467 | 516 | ||
| 468 | /* GC2000 rev 5108 needs a special bus config */ | 517 | /* GC2000 rev 5108 needs a special bus config */ |
| 469 | if (gpu->identity.model == 0x2000 && gpu->identity.revision == 0x5108) { | 518 | if (etnaviv_is_model_rev(gpu, GC2000, 0x5108)) { |
| 470 | u32 bus_config = gpu_read(gpu, VIVS_MC_BUS_CONFIG); | 519 | u32 bus_config = gpu_read(gpu, VIVS_MC_BUS_CONFIG); |
| 471 | bus_config &= ~(VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG__MASK | | 520 | bus_config &= ~(VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG__MASK | |
| 472 | VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG__MASK); | 521 | VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG__MASK); |
| @@ -511,8 +560,16 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 38 unmodified lines | |||
| 511 | 560 | ||
| 512 | if (gpu->identity.model == 0) { | 561 | if (gpu->identity.model == 0) { |
| 513 | dev_err(gpu->dev, "Unknown GPU model\n"); | 562 | dev_err(gpu->dev, "Unknown GPU model\n"); |
| 514 | pm_runtime_put_autosuspend(gpu->dev); | 563 | ret = -ENXIO; |
| 515 | return -ENXIO; | 564 | goto fail; |
| 565 | } | ||
| 566 | |||
| 567 | /* Exclude VG cores with FE2.0 */ | ||
| 568 | if (gpu->identity.features & chipFeatures_PIPE_VG && | ||
| 569 | gpu->identity.features & chipFeatures_FE20) { | ||
| 570 | dev_info(gpu->dev, "Ignoring GPU with VG and FE2.0\n"); | ||
| 571 | ret = -ENXIO; | ||
| 572 | goto fail; | ||
| 516 | } | 573 | } |
| 517 | 574 | ||
| 518 | ret = etnaviv_hw_reset(gpu); | 575 | ret = etnaviv_hw_reset(gpu); |
| @@ -539,10 +596,9 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 20 unmodified lines | |||
| 539 | goto fail; | 596 | goto fail; |
| 540 | } | 597 | } |
| 541 | 598 | ||
| 542 | /* TODO: we will leak here memory - fix it! */ | ||
| 543 | |||
| 544 | gpu->mmu = etnaviv_iommu_new(gpu, iommu, version); | 599 | gpu->mmu = etnaviv_iommu_new(gpu, iommu, version); |
| 545 | if (!gpu->mmu) { | 600 | if (!gpu->mmu) { |
| 601 | iommu_domain_free(iommu); | ||
| 546 | ret = -ENOMEM; | 602 | ret = -ENOMEM; |
| 547 | goto fail; | 603 | goto fail; |
| 548 | } | 604 | } |
| @@ -552,7 +608,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 3 unmodified lines | |||
| 552 | if (!gpu->buffer) { | 608 | if (!gpu->buffer) { |
| 553 | ret = -ENOMEM; | 609 | ret = -ENOMEM; |
| 554 | dev_err(gpu->dev, "could not create command buffer\n"); | 610 | dev_err(gpu->dev, "could not create command buffer\n"); |
| 555 | goto fail; | 611 | goto destroy_iommu; |
| 556 | } | 612 | } |
| 557 | if (gpu->buffer->paddr - gpu->memory_base > 0x80000000) { | 613 | if (gpu->buffer->paddr - gpu->memory_base > 0x80000000) { |
| 558 | ret = -EINVAL; | 614 | ret = -EINVAL; |
| @@ -582,6 +638,9 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 23 unmodified lines | |||
| 582 | free_buffer: | 638 | free_buffer: |
| 583 | etnaviv_gpu_cmdbuf_free(gpu->buffer); | 639 | etnaviv_gpu_cmdbuf_free(gpu->buffer); |
| 584 | gpu->buffer = NULL; | 640 | gpu->buffer = NULL; |
| 641 | destroy_iommu: | ||
| 642 | etnaviv_iommu_destroy(gpu->mmu); | ||
| 643 | gpu->mmu = NULL; | ||
| 585 | fail: | 644 | fail: |
| 586 | pm_runtime_mark_last_busy(gpu->dev); | 645 | pm_runtime_mark_last_busy(gpu->dev); |
| 587 | pm_runtime_put_autosuspend(gpu->dev); | 646 | pm_runtime_put_autosuspend(gpu->dev); |
| @@ -642,6 +701,10 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) · 54 unmodified lines | |||
| 642 | gpu->identity.minor_features2); | 701 | gpu->identity.minor_features2); |
| 643 | seq_printf(m, "\t minor_features3: 0x%08x\n", | 702 | seq_printf(m, "\t minor_features3: 0x%08x\n", |
| 644 | gpu->identity.minor_features3); | 703 | gpu->identity.minor_features3); |
| 704 | seq_printf(m, "\t minor_features4: 0x%08x\n", | ||
| 705 | gpu->identity.minor_features4); | ||
| 706 | seq_printf(m, "\t minor_features5: 0x%08x\n", | ||
| 707 | gpu->identity.minor_features5); | ||
| 645 | 708 | ||
| 646 | seq_puts(m, "\tspecs\n"); | 709 | seq_puts(m, "\tspecs\n"); |
| 647 | seq_printf(m, "\t stream_count: %d\n", | 710 | seq_printf(m, "\t stream_count: %d\n", |
| @@ -664,6 +727,8 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) · 16 unmodified lines | |||
| 664 | gpu->identity.instruction_count); | 727 | gpu->identity.instruction_count); |
| 665 | seq_printf(m, "\t num_constants: %d\n", | 728 | seq_printf(m, "\t num_constants: %d\n", |
| 666 | gpu->identity.num_constants); | 729 | gpu->identity.num_constants); |
| 730 | seq_printf(m, "\t varyings_count: %d\n", | ||
| 731 | gpu->identity.varyings_count); | ||
| 667 | 732 | ||
| 668 | seq_printf(m, "\taxi: 0x%08x\n", axi); | 733 | seq_printf(m, "\taxi: 0x%08x\n", axi); |
| 669 | seq_printf(m, "\tidle: 0x%08x\n", idle); | 734 | seq_printf(m, "\tidle: 0x%08x\n", idle); |
| @@ -46,6 +46,12 @@ struct etnaviv_chip_identity { · 45 unmodified lines | |||
| 46 | /* Supported minor feature 3 fields. */ | 46 | /* Supported minor feature 3 fields. */ |
| 47 | u32 minor_features3; | 47 | u32 minor_features3; |
| 48 | 48 | ||
| 49 | /* Supported minor feature 4 fields. */ | ||
| 50 | u32 minor_features4; | ||
| 51 | |||
| 52 | /* Supported minor feature 5 fields. */ | ||
| 53 | u32 minor_features5; | ||
| 54 | |||
| 49 | /* Number of streams supported. */ | 55 | /* Number of streams supported. */ |
| 50 | u32 stream_count; | 56 | u32 stream_count; |
| 51 | 57 | ||
| @@ -75,6 +81,9 @@ struct etnaviv_chip_identity { · 23 unmodified lines | |||
| 75 | 81 | ||
| 76 | /* Buffer size */ | 82 | /* Buffer size */ |
| 77 | u32 buffer_size; | 83 | u32 buffer_size; |
| 84 | |||
| 85 | /* Number of varyings */ | ||
| 86 | u8 varyings_count; | ||
| 78 | }; | 87 | }; |
| 79 | 88 | ||
| 80 | struct etnaviv_event { | 89 | struct etnaviv_event { |
| @@ -8,8 +8,8 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng · 7 unmodified lines | |||
| 8 | git clone git://0x04.net/rules-ng-ng | 8 | git clone git://0x04.net/rules-ng-ng |
| 9 | 9 | ||
| 10 | The rules-ng-ng source files this header was generated from are: | 10 | The rules-ng-ng source files this header was generated from are: |
| 11 | - state_hi.xml ( 23420 bytes, from 2015-03-25 11:47:21) | 11 | - state_hi.xml ( 24309 bytes, from 2015-12-12 09:02:53) |
| 12 | - common.xml ( 18437 bytes, from 2015-03-25 11:27:41) | 12 | - common.xml ( 18437 bytes, from 2015-12-12 09:02:53) |
| 13 | 13 | ||
| 14 | Copyright (C) 2015 | 14 | Copyright (C) 2015 |
| 15 | */ | 15 | */ |
| @@ -182,8 +182,25 @@ Copyright (C) 2015 · 166 unmodified lines | |||
| 182 | 182 | ||
| 183 | #define VIVS_HI_CHIP_MINOR_FEATURE_3 0x00000088 | 183 | #define VIVS_HI_CHIP_MINOR_FEATURE_3 0x00000088 |
| 184 | 184 | ||
| 185 | #define VIVS_HI_CHIP_SPECS_3 0x0000008c | ||
| 186 | #define VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__MASK 0x000001f0 | ||
| 187 | #define VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__SHIFT 4 | ||
| 188 | #define VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT(x) (((x) << VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__SHIFT) & VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__MASK) | ||
| 189 | #define VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__MASK 0x00000007 | ||
| 190 | #define VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__SHIFT 0 | ||
| 191 | #define VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT(x) (((x) << VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__SHIFT) & VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__MASK) | ||
| 192 | |||
| 185 | #define VIVS_HI_CHIP_MINOR_FEATURE_4 0x00000094 | 193 | #define VIVS_HI_CHIP_MINOR_FEATURE_4 0x00000094 |
| 186 | 194 | ||
| 195 | #define VIVS_HI_CHIP_SPECS_4 0x0000009c | ||
| 196 | #define VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__MASK 0x0001f000 | ||
| 197 | #define VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__SHIFT 12 | ||
| 198 | #define VIVS_HI_CHIP_SPECS_4_STREAM_COUNT(x) (((x) << VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__SHIFT) & VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__MASK) | ||
| 199 | |||
| 200 | #define VIVS_HI_CHIP_MINOR_FEATURE_5 0x000000a0 | ||
| 201 | |||
| 202 | #define VIVS_HI_CHIP_PRODUCT_ID 0x000000a8 | ||
| 203 | |||
| 187 | #define VIVS_PM 0x00000000 | 204 | #define VIVS_PM 0x00000000 |
| 188 | 205 | ||
| 189 | #define VIVS_PM_POWER_CONTROLS 0x00000100 | 206 | #define VIVS_PM_POWER_CONTROLS 0x00000100 |
| @@ -206,6 +223,11 @@ Copyright (C) 2015 · 16 unmodified lines | |||
| 206 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_FE 0x00000001 | 223 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_FE 0x00000001 |
| 207 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_DE 0x00000002 | 224 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_DE 0x00000002 |
| 208 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_PE 0x00000004 | 225 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_PE 0x00000004 |
| 226 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_SH 0x00000008 | ||
| 227 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_PA 0x00000010 | ||
| 228 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_SE 0x00000020 | ||
| 229 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_RA 0x00000040 | ||
| 230 | #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_TX 0x00000080 | ||
| 209 | 231 | ||
| 210 | #define VIVS_PM_PULSE_EATER 0x0000010c | 232 | #define VIVS_PM_PULSE_EATER 0x0000010c |
| 211 | 233 | ||
| @@ -304,18 +304,10 @@ void dce6_dp_audio_set_dto(struct radeon_device *rdev, · 303 unmodified lines | |||
| 304 | unsigned int div = (RREG32(DENTIST_DISPCLK_CNTL) & | 304 | unsigned int div = (RREG32(DENTIST_DISPCLK_CNTL) & |
| 305 | DENTIST_DPREFCLK_WDIVIDER_MASK) >> | 305 | DENTIST_DPREFCLK_WDIVIDER_MASK) >> |
| 306 | DENTIST_DPREFCLK_WDIVIDER_SHIFT; | 306 | DENTIST_DPREFCLK_WDIVIDER_SHIFT; |
| 307 | 307 | div = radeon_audio_decode_dfs_div(div); | |
| 308 | if (div < 128 && div >= 96) | ||
| 309 | div -= 64; | ||
| 310 | else if (div >= 64) | ||
| 311 | div = div / 2 - 16; | ||
| 312 | else if (div >= 8) | ||
| 313 | div /= 4; | ||
| 314 | else | ||
| 315 | div = 0; | ||
| 316 | 308 | ||
| 317 | if (div) | 309 | if (div) |
| 318 | clock = rdev->clock.gpupll_outputfreq * 10 / div; | 310 | clock = clock * 100 / div; |
| 319 | 311 | ||
| 320 | WREG32(DCE8_DCCG_AUDIO_DTO1_PHASE, 24000); | 312 | WREG32(DCE8_DCCG_AUDIO_DTO1_PHASE, 24000); |
| 321 | WREG32(DCE8_DCCG_AUDIO_DTO1_MODULE, clock); | 313 | WREG32(DCE8_DCCG_AUDIO_DTO1_MODULE, clock); |
| @@ -289,6 +289,16 @@ void dce4_dp_audio_set_dto(struct radeon_device *rdev, · 288 unmodified lines | |||
| 289 | * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE | 289 | * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE |
| 290 | * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator | 290 | * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator |
| 291 | */ | 291 | */ |
| 292 | if (ASIC_IS_DCE41(rdev)) { | ||
| 293 | unsigned int div = (RREG32(DCE41_DENTIST_DISPCLK_CNTL) & | ||
| 294 | DENTIST_DPREFCLK_WDIVIDER_MASK) >> | ||
| 295 | DENTIST_DPREFCLK_WDIVIDER_SHIFT; | ||
| 296 | div = radeon_audio_decode_dfs_div(div); | ||
| 297 | |||
| 298 | if (div) | ||
| 299 | clock = 100 * clock / div; | ||
| 300 | } | ||
| 301 | |||
| 292 | WREG32(DCCG_AUDIO_DTO1_PHASE, 24000); | 302 | WREG32(DCCG_AUDIO_DTO1_PHASE, 24000); |
| 293 | WREG32(DCCG_AUDIO_DTO1_MODULE, clock); | 303 | WREG32(DCCG_AUDIO_DTO1_MODULE, clock); |
| 294 | } | 304 | } |
| @@ -511,6 +511,11 @@ · 510 unmodified lines | |||
| 511 | #define DCCG_AUDIO_DTO1_CNTL 0x05cc | 511 | #define DCCG_AUDIO_DTO1_CNTL 0x05cc |
| 512 | # define DCCG_AUDIO_DTO1_USE_512FBR_DTO (1 << 3) | 512 | # define DCCG_AUDIO_DTO1_USE_512FBR_DTO (1 << 3) |
| 513 | 513 | ||
| 514 | #define DCE41_DENTIST_DISPCLK_CNTL 0x049c | ||
| 515 | # define DENTIST_DPREFCLK_WDIVIDER(x) (((x) & 0x7f) << 24) | ||
| 516 | # define DENTIST_DPREFCLK_WDIVIDER_MASK (0x7f << 24) | ||
| 517 | # define DENTIST_DPREFCLK_WDIVIDER_SHIFT 24 | ||
| 518 | |||
| 514 | /* DCE 4.0 AFMT */ | 519 | /* DCE 4.0 AFMT */ |
| 515 | #define HDMI_CONTROL 0x7030 | 520 | #define HDMI_CONTROL 0x7030 |
| 516 | # define HDMI_KEEPOUT_MODE (1 << 0) | 521 | # define HDMI_KEEPOUT_MODE (1 << 0) |
| @@ -268,7 +268,7 @@ struct radeon_clock { · 267 unmodified lines | |||
| 268 | uint32_t current_dispclk; | 268 | uint32_t current_dispclk; |
| 269 | uint32_t dp_extclk; | 269 | uint32_t dp_extclk; |
| 270 | uint32_t max_pixel_clock; | 270 | uint32_t max_pixel_clock; |
| 271 | uint32_t gpupll_outputfreq; | 271 | uint32_t vco_freq; |
| 272 | }; | 272 | }; |
| 273 | 273 | ||
| 274 | /* | 274 | /* |
| @@ -1106,6 +1106,31 @@ union firmware_info { · 1105 unmodified lines | |||
| 1106 | ATOM_FIRMWARE_INFO_V2_2 info_22; | 1106 | ATOM_FIRMWARE_INFO_V2_2 info_22; |
| 1107 | }; | 1107 | }; |
| 1108 | 1108 | ||
| 1109 | union igp_info { | ||
| 1110 | struct _ATOM_INTEGRATED_SYSTEM_INFO info; | ||
| 1111 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2; | ||
| 1112 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V6 info_6; | ||
| 1113 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 info_7; | ||
| 1114 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_8 info_8; | ||
| 1115 | }; | ||
| 1116 | |||
| 1117 | static void radeon_atombios_get_dentist_vco_freq(struct radeon_device *rdev) | ||
| 1118 | { | ||
| 1119 | struct radeon_mode_info *mode_info = &rdev->mode_info; | ||
| 1120 | int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); | ||
| 1121 | union igp_info *igp_info; | ||
| 1122 | u8 frev, crev; | ||
| 1123 | u16 data_offset; | ||
| 1124 | |||
| 1125 | if (atom_parse_data_header(mode_info->atom_context, index, NULL, | ||
| 1126 | &frev, &crev, &data_offset)) { | ||
| 1127 | igp_info = (union igp_info *)(mode_info->atom_context->bios + | ||
| 1128 | data_offset); | ||
| 1129 | rdev->clock.vco_freq = | ||
| 1130 | le32_to_cpu(igp_info->info_6.ulDentistVCOFreq); | ||
| 1131 | } | ||
| 1132 | } | ||
| 1133 | |||
| 1109 | bool radeon_atom_get_clock_info(struct drm_device *dev) | 1134 | bool radeon_atom_get_clock_info(struct drm_device *dev) |
| 1110 | { | 1135 | { |
| 1111 | struct radeon_device *rdev = dev->dev_private; | 1136 | struct radeon_device *rdev = dev->dev_private; |
| @@ -1257,12 +1282,18 @@ bool radeon_atom_get_clock_info(struct drm_device *dev) · 145 unmodified lines | |||
| 1257 | rdev->mode_info.firmware_flags = | 1282 | rdev->mode_info.firmware_flags = |
| 1258 | le16_to_cpu(firmware_info->info.usFirmwareCapability.susAccess); | 1283 | le16_to_cpu(firmware_info->info.usFirmwareCapability.susAccess); |
| 1259 | 1284 | ||
| 1260 | if (ASIC_IS_DCE8(rdev)) { | 1285 | if (ASIC_IS_DCE8(rdev)) |
| 1261 | rdev->clock.gpupll_outputfreq = | 1286 | rdev->clock.vco_freq = |
| 1262 | le32_to_cpu(firmware_info->info_22.ulGPUPLL_OutputFreq); | 1287 | le32_to_cpu(firmware_info->info_22.ulGPUPLL_OutputFreq); |
| 1263 | if (rdev->clock.gpupll_outputfreq == 0) | 1288 | else if (ASIC_IS_DCE5(rdev)) |
| 1264 | rdev->clock.gpupll_outputfreq = 360000; /* 3.6 GHz */ | 1289 | rdev->clock.vco_freq = rdev->clock.current_dispclk; |
| 1265 | } | 1290 | else if (ASIC_IS_DCE41(rdev)) |
| 1291 | radeon_atombios_get_dentist_vco_freq(rdev); | ||
| 1292 | else | ||
| 1293 | rdev->clock.vco_freq = rdev->clock.current_dispclk; | ||
| 1294 | |||
| 1295 | if (rdev->clock.vco_freq == 0) | ||
| 1296 | rdev->clock.vco_freq = 360000; /* 3.6 GHz */ | ||
| 1266 | 1297 | ||
| 1267 | return true; | 1298 | return true; |
| 1268 | } | 1299 | } |
| @@ -1270,14 +1301,6 @@ bool radeon_atom_get_clock_info(struct drm_device *dev) · 1 unmodified line | |||
| 1270 | return false; | 1301 | return false; |
| 1271 | } | 1302 | } |
| 1272 | 1303 | ||
| 1273 | union igp_info { | ||
| 1274 | struct _ATOM_INTEGRATED_SYSTEM_INFO info; | ||
| 1275 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2; | ||
| 1276 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V6 info_6; | ||
| 1277 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 info_7; | ||
| 1278 | struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_8 info_8; | ||
| 1279 | }; | ||
| 1280 | |||
| 1281 | bool radeon_atombios_sideport_present(struct radeon_device *rdev) | 1304 | bool radeon_atombios_sideport_present(struct radeon_device *rdev) |
| 1282 | { | 1305 | { |
| 1283 | struct radeon_mode_info *mode_info = &rdev->mode_info; | 1306 | struct radeon_mode_info *mode_info = &rdev->mode_info; |
| @@ -739,9 +739,6 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder, · 738 unmodified lines | |||
| 739 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); | 739 | struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); |
| 740 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; | 740 | struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; |
| 741 | struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); | 741 | struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); |
| 742 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | ||
| 743 | struct radeon_connector_atom_dig *dig_connector = | ||
| 744 | radeon_connector->con_priv; | ||
| 745 | 742 | ||
| 746 | if (!dig || !dig->afmt) | 743 | if (!dig || !dig->afmt) |
| 747 | return; | 744 | return; |
| @@ -753,10 +750,7 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder, · 5 unmodified lines | |||
| 753 | radeon_audio_write_speaker_allocation(encoder); | 750 | radeon_audio_write_speaker_allocation(encoder); |
| 754 | radeon_audio_write_sad_regs(encoder); | 751 | radeon_audio_write_sad_regs(encoder); |
| 755 | radeon_audio_write_latency_fields(encoder, mode); | 752 | radeon_audio_write_latency_fields(encoder, mode); |
| 756 | if (rdev->clock.dp_extclk || ASIC_IS_DCE5(rdev)) | 753 | radeon_audio_set_dto(encoder, rdev->clock.vco_freq * 10); |
| 757 | radeon_audio_set_dto(encoder, rdev->clock.default_dispclk * 10); | ||
| 758 | else | ||
| 759 | radeon_audio_set_dto(encoder, dig_connector->dp_clock); | ||
| 760 | radeon_audio_set_audio_packet(encoder); | 754 | radeon_audio_set_audio_packet(encoder); |
| 761 | radeon_audio_select_pin(encoder); | 755 | radeon_audio_select_pin(encoder); |
| 762 | 756 | ||
| @@ -781,3 +775,15 @@ void radeon_audio_dpms(struct drm_encoder *encoder, int mode) · 18 unmodified lines | |||
| 781 | if (radeon_encoder->audio && radeon_encoder->audio->dpms) | 775 | if (radeon_encoder->audio && radeon_encoder->audio->dpms) |
| 782 | radeon_encoder->audio->dpms(encoder, mode == DRM_MODE_DPMS_ON); | 776 | radeon_encoder->audio->dpms(encoder, mode == DRM_MODE_DPMS_ON); |
| 783 | } | 777 | } |
| 778 | |||
| 779 | unsigned int radeon_audio_decode_dfs_div(unsigned int div) | ||
| 780 | { | ||
| 781 | if (div >= 8 && div < 64) | ||
| 782 | return (div - 8) * 25 + 200; | ||
| 783 | else if (div >= 64 && div < 96) | ||
| 784 | return (div - 64) * 50 + 1600; | ||
| 785 | else if (div >= 96 && div < 128) | ||
| 786 | return (div - 96) * 100 + 3200; | ||
| 787 | else | ||
| 788 | return 0; | ||
| 789 | } | ||
| @@ -79,5 +79,6 @@ void radeon_audio_fini(struct radeon_device *rdev); · 78 unmodified lines | |||
| 79 | void radeon_audio_mode_set(struct drm_encoder *encoder, | 79 | void radeon_audio_mode_set(struct drm_encoder *encoder, |
| 80 | struct drm_display_mode *mode); | 80 | struct drm_display_mode *mode); |
| 81 | void radeon_audio_dpms(struct drm_encoder *encoder, int mode); | 81 | void radeon_audio_dpms(struct drm_encoder *encoder, int mode); |
| 82 | unsigned int radeon_audio_decode_dfs_div(unsigned int div); | ||
| 82 | 83 | ||
| 83 | #endif | 84 | #endif |
| @@ -1670,8 +1670,10 @@ int radeon_modeset_init(struct radeon_device *rdev) · 1669 unmodified lines | |||
| 1670 | /* setup afmt */ | 1670 | /* setup afmt */ |
| 1671 | radeon_afmt_init(rdev); | 1671 | radeon_afmt_init(rdev); |
| 1672 | 1672 | ||
| 1673 | radeon_fbdev_init(rdev); | 1673 | if (!list_empty(&rdev->ddev->mode_config.connector_list)) { |
| 1674 | drm_kms_helper_poll_init(rdev->ddev); | 1674 | radeon_fbdev_init(rdev); |
| 1675 | drm_kms_helper_poll_init(rdev->ddev); | ||
| 1676 | } | ||
| 1675 | 1677 | ||
| 1676 | /* do pm late init */ | 1678 | /* do pm late init */ |
| 1677 | ret = radeon_pm_late_init(rdev); | 1679 | ret = radeon_pm_late_init(rdev); |
| @@ -663,6 +663,7 @@ int radeon_gem_va_ioctl(struct drm_device *dev, void *data, · 662 unmodified lines | |||
| 663 | bo_va = radeon_vm_bo_find(&fpriv->vm, rbo); | 663 | bo_va = radeon_vm_bo_find(&fpriv->vm, rbo); |
| 664 | if (!bo_va) { | 664 | if (!bo_va) { |
| 665 | args->operation = RADEON_VA_RESULT_ERROR; | 665 | args->operation = RADEON_VA_RESULT_ERROR; |
| 666 | radeon_bo_unreserve(rbo); | ||
| 666 | drm_gem_object_unreference_unlocked(gobj); | 667 | drm_gem_object_unreference_unlocked(gobj); |
| 667 | return -ENOENT; | 668 | return -ENOENT; |
| 668 | } | 669 | } |
| @@ -178,12 +178,12 @@ int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t *data) · 177 unmodified lines | |||
| 178 | return -EINVAL; | 178 | return -EINVAL; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | for (i = 0; i < sign->num; ++i) { | 181 | for (i = 0; i < le32_to_cpu(sign->num); ++i) { |
| 182 | if (sign->val[i].chip_id == chip_id) | 182 | if (le32_to_cpu(sign->val[i].chip_id) == chip_id) |
| 183 | break; | 183 | break; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | if (i == sign->num) | 186 | if (i == le32_to_cpu(sign->num)) |
| 187 | return -EINVAL; | 187 | return -EINVAL; |
| 188 | 188 | ||
| 189 | data += (256 - 64) / 4; | 189 | data += (256 - 64) / 4; |
| @@ -191,18 +191,18 @@ int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t *data) · 1 unmodified line | |||
| 191 | data[1] = sign->val[i].nonce[1]; | 191 | data[1] = sign->val[i].nonce[1]; |
| 192 | data[2] = sign->val[i].nonce[2]; | 192 | data[2] = sign->val[i].nonce[2]; |
| 193 | data[3] = sign->val[i].nonce[3]; | 193 | data[3] = sign->val[i].nonce[3]; |
| 194 | data[4] = sign->len + 64; | 194 | data[4] = cpu_to_le32(le32_to_cpu(sign->len) + 64); |
| 195 | 195 | ||
| 196 | memset(&data[5], 0, 44); | 196 | memset(&data[5], 0, 44); |
| 197 | memcpy(&data[16], &sign[1], rdev->vce_fw->size - sizeof(*sign)); | 197 | memcpy(&data[16], &sign[1], rdev->vce_fw->size - sizeof(*sign)); |
| 198 | 198 | ||
| 199 | data += data[4] / 4; | 199 | data += le32_to_cpu(data[4]) / 4; |
| 200 | data[0] = sign->val[i].sigval[0]; | 200 | data[0] = sign->val[i].sigval[0]; |
| 201 | data[1] = sign->val[i].sigval[1]; | 201 | data[1] = sign->val[i].sigval[1]; |
| 202 | data[2] = sign->val[i].sigval[2]; | 202 | data[2] = sign->val[i].sigval[2]; |
| 203 | data[3] = sign->val[i].sigval[3]; | 203 | data[3] = sign->val[i].sigval[3]; |
| 204 | 204 | ||
| 205 | rdev->vce.keyselect = sign->val[i].keyselect; | 205 | rdev->vce.keyselect = le32_to_cpu(sign->val[i].keyselect); |
| 206 | 206 | ||
| 207 | return 0; | 207 | return 0; |
| 208 | } | 208 | } |
| @@ -2,11 +2,11 @@ · 1 unmodified line | |||
| 2 | # Makefile for the drm device driver. This driver provides support for the | 2 | # Makefile for the drm device driver. This driver provides support for the |
| 3 | # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. | 3 | # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. |
| 4 | 4 | ||
| 5 | rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \ | 5 | rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \ |
| 6 | rockchip_drm_gem.o | 6 | rockchip_drm_gem.o rockchip_drm_vop.o |
| 7 | rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o | ||
| 7 | 8 | ||
| 8 | obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o | 9 | obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o |
| 9 | obj-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o | 10 | obj-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o |
| 10 | 11 | ||
| 11 | obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o \ | 12 | obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_vop_reg.o |
| 12 | rockchip_vop_reg.o | ||
| @@ -461,10 +461,11 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi) · 460 unmodified lines | |||
| 461 | 461 | ||
| 462 | static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi) | 462 | static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi) |
| 463 | { | 463 | { |
| 464 | unsigned int bpp, i, pre; | 464 | unsigned int i, pre; |
| 465 | unsigned long mpclk, pllref, tmp; | 465 | unsigned long mpclk, pllref, tmp; |
| 466 | unsigned int m = 1, n = 1, target_mbps = 1000; | 466 | unsigned int m = 1, n = 1, target_mbps = 1000; |
| 467 | unsigned int max_mbps = dptdin_map[ARRAY_SIZE(dptdin_map) - 1].max_mbps; | 467 | unsigned int max_mbps = dptdin_map[ARRAY_SIZE(dptdin_map) - 1].max_mbps; |
| 468 | int bpp; | ||
| 468 | 469 | ||
| 469 | bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); | 470 | bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); |
| 470 | if (bpp < 0) { | 471 | if (bpp < 0) { |
| @@ -55,14 +55,12 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, · 54 unmodified lines | |||
| 55 | 55 | ||
| 56 | return arm_iommu_attach_device(dev, mapping); | 56 | return arm_iommu_attach_device(dev, mapping); |
| 57 | } | 57 | } |
| 58 | EXPORT_SYMBOL_GPL(rockchip_drm_dma_attach_device); | ||
| 59 | 58 | ||
| 60 | void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, | 59 | void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, |
| 61 | struct device *dev) | 60 | struct device *dev) |
| 62 | { | 61 | { |
| 63 | arm_iommu_detach_device(dev); | 62 | arm_iommu_detach_device(dev); |
| 64 | } | 63 | } |
| 65 | EXPORT_SYMBOL_GPL(rockchip_drm_dma_detach_device); | ||
| 66 | 64 | ||
| 67 | int rockchip_register_crtc_funcs(struct drm_crtc *crtc, | 65 | int rockchip_register_crtc_funcs(struct drm_crtc *crtc, |
| 68 | const struct rockchip_crtc_funcs *crtc_funcs) | 66 | const struct rockchip_crtc_funcs *crtc_funcs) |
| @@ -77,7 +75,6 @@ int rockchip_register_crtc_funcs(struct drm_crtc *crtc, · 8 unmodified lines | |||
| 77 | 75 | ||
| 78 | return 0; | 76 | return 0; |
| 79 | } | 77 | } |
| 80 | EXPORT_SYMBOL_GPL(rockchip_register_crtc_funcs); | ||
| 81 | 78 | ||
| 82 | void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc) | 79 | void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc) |
| 83 | { | 80 | { |
| @@ -89,7 +86,6 @@ void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc) · 5 unmodified lines | |||
| 89 | 86 | ||
| 90 | priv->crtc_funcs[pipe] = NULL; | 87 | priv->crtc_funcs[pipe] = NULL; |
| 91 | } | 88 | } |
| 92 | EXPORT_SYMBOL_GPL(rockchip_unregister_crtc_funcs); | ||
| 93 | 89 | ||
| 94 | static struct drm_crtc *rockchip_crtc_from_pipe(struct drm_device *drm, | 90 | static struct drm_crtc *rockchip_crtc_from_pipe(struct drm_device *drm, |
| 95 | int pipe) | 91 | int pipe) |
| @@ -39,7 +39,6 @@ struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb, · 38 unmodified lines | |||
| 39 | 39 | ||
| 40 | return rk_fb->obj[plane]; | 40 | return rk_fb->obj[plane]; |
| 41 | } | 41 | } |
| 42 | EXPORT_SYMBOL_GPL(rockchip_fb_get_gem_obj); | ||
| 43 | 42 | ||
| 44 | static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb) | 43 | static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb) |
| 45 | { | 44 | { |
| @@ -177,8 +176,23 @@ static void rockchip_crtc_wait_for_update(struct drm_crtc *crtc) · 131 unmodified lines | |||
| 177 | crtc_funcs->wait_for_update(crtc); | 176 | crtc_funcs->wait_for_update(crtc); |
| 178 | } | 177 | } |
| 179 | 178 | ||
| 179 | /* | ||
| 180 | * We can't use drm_atomic_helper_wait_for_vblanks() because rk3288 and rk3066 | ||
| 181 | * have hardware counters for neither vblanks nor scanlines, which results in | ||
| 182 | * a race where: | ||
| 183 | * | <-- HW vsync irq and reg take effect | ||
| 184 | * plane_commit --> | | ||
| 185 | * get_vblank and wait --> | | ||
| 186 | * | <-- handle_vblank, vblank->count + 1 | ||
| 187 | * cleanup_fb --> | | ||
| 188 | * iommu crash --> | | ||
| 189 | * | <-- HW vsync irq and reg take effect | ||
| 190 | * | ||
| 191 | * This function is equivalent but uses rockchip_crtc_wait_for_update() instead | ||
| 192 | * of waiting for vblank_count to change. | ||
| 193 | */ | ||
| 180 | static void | 194 | static void |
| 181 | rockchip_atomic_wait_for_complete(struct drm_atomic_state *old_state) | 195 | rockchip_atomic_wait_for_complete(struct drm_device *dev, struct drm_atomic_state *old_state) |
| 182 | { | 196 | { |
| 183 | struct drm_crtc_state *old_crtc_state; | 197 | struct drm_crtc_state *old_crtc_state; |
| 184 | struct drm_crtc *crtc; | 198 | struct drm_crtc *crtc; |
| @@ -194,6 +208,10 @@ rockchip_atomic_wait_for_complete(struct drm_atomic_state *old_state) · 9 unmodified lines | |||
| 194 | if (!crtc->state->active) | 208 | if (!crtc->state->active) |
| 195 | continue; | 209 | continue; |
| 196 | 210 | ||
| 211 | if (!drm_atomic_helper_framebuffer_changed(dev, | ||
| 212 | old_state, crtc)) | ||
| 213 | continue; | ||
| 214 | |||
| 197 | ret = drm_crtc_vblank_get(crtc); | 215 | ret = drm_crtc_vblank_get(crtc); |
| 198 | if (ret != 0) | 216 | if (ret != 0) |
| 199 | continue; | 217 | continue; |
| @@ -241,7 +259,7 @@ rockchip_atomic_commit_complete(struct rockchip_atomic_commit *commit) · 41 unmodified lines | |||
| 241 | 259 | ||
| 242 | drm_atomic_helper_commit_planes(dev, state, true); | 260 | drm_atomic_helper_commit_planes(dev, state, true); |
| 243 | 261 | ||
| 244 | rockchip_atomic_wait_for_complete(state); | 262 | rockchip_atomic_wait_for_complete(dev, state); |
| 245 | 263 | ||
| 246 | drm_atomic_helper_cleanup_planes(dev, state); | 264 | drm_atomic_helper_cleanup_planes(dev, state); |
| 247 | 265 | ||
| @@ -15,7 +15,18 @@ · 14 unmodified lines | |||
| 15 | #ifndef _ROCKCHIP_DRM_FBDEV_H | 15 | #ifndef _ROCKCHIP_DRM_FBDEV_H |
| 16 | #define _ROCKCHIP_DRM_FBDEV_H | 16 | #define _ROCKCHIP_DRM_FBDEV_H |
| 17 | 17 | ||
| 18 | #ifdef CONFIG_DRM_FBDEV_EMULATION | ||
| 18 | int rockchip_drm_fbdev_init(struct drm_device *dev); | 19 | int rockchip_drm_fbdev_init(struct drm_device *dev); |
| 19 | void rockchip_drm_fbdev_fini(struct drm_device *dev); | 20 | void rockchip_drm_fbdev_fini(struct drm_device *dev); |
| 21 | #else | ||
| 22 | static inline int rockchip_drm_fbdev_init(struct drm_device *dev) | ||
| 23 | { | ||
| 24 | return 0; | ||
| 25 | } | ||
| 26 | |||
| 27 | static inline void rockchip_drm_fbdev_fini(struct drm_device *dev) | ||
| 28 | { | ||
| 29 | } | ||
| 30 | #endif | ||
| 20 | 31 | ||
| 21 | #endif /* _ROCKCHIP_DRM_FBDEV_H */ | 32 | #endif /* _ROCKCHIP_DRM_FBDEV_H */ |
| @@ -234,13 +234,8 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, · 233 unmodified lines | |||
| 234 | /* | 234 | /* |
| 235 | * align to 64 bytes since Mali requires it. | 235 | * align to 64 bytes since Mali requires it. |
| 236 | */ | 236 | */ |
| 237 | min_pitch = ALIGN(min_pitch, 64); | 237 | args->pitch = ALIGN(min_pitch, 64); |
| 238 | 238 | args->size = args->pitch * args->height; | |
| 239 | if (args->pitch < min_pitch) | ||
| 240 | args->pitch = min_pitch; | ||
| 241 | |||
| 242 | if (args->size < args->pitch * args->height) | ||
| 243 | args->size = args->pitch * args->height; | ||
| 244 | 239 | ||
| 245 | rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size, | 240 | rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size, |
| 246 | &args->handle); | 241 | &args->handle); |
| @@ -43,8 +43,8 @@ · 42 unmodified lines | |||
| 43 | 43 | ||
| 44 | #define REG_SET(x, base, reg, v, mode) \ | 44 | #define REG_SET(x, base, reg, v, mode) \ |
| 45 | __REG_SET_##mode(x, base + reg.offset, reg.mask, reg.shift, v) | 45 | __REG_SET_##mode(x, base + reg.offset, reg.mask, reg.shift, v) |
| 46 | #define REG_SET_MASK(x, base, reg, v, mode) \ | 46 | #define REG_SET_MASK(x, base, reg, mask, v, mode) \ |
| 47 | __REG_SET_##mode(x, base + reg.offset, reg.mask, reg.shift, v) | 47 | __REG_SET_##mode(x, base + reg.offset, mask, reg.shift, v) |
| 48 | 48 | ||
| 49 | #define VOP_WIN_SET(x, win, name, v) \ | 49 | #define VOP_WIN_SET(x, win, name, v) \ |
| 50 | REG_SET(x, win->base, win->phy->name, v, RELAXED) | 50 | REG_SET(x, win->base, win->phy->name, v, RELAXED) |
| @@ -58,16 +58,18 @@ · 7 unmodified lines | |||
| 58 | #define VOP_INTR_GET(vop, name) \ | 58 | #define VOP_INTR_GET(vop, name) \ |
| 59 | vop_read_reg(vop, 0, &vop->data->ctrl->name) | 59 | vop_read_reg(vop, 0, &vop->data->ctrl->name) |
| 60 | 60 | ||
| 61 | #define VOP_INTR_SET(vop, name, v) \ | 61 | #define VOP_INTR_SET(vop, name, mask, v) \ |
| 62 | REG_SET(vop, 0, vop->data->intr->name, v, NORMAL) | 62 | REG_SET_MASK(vop, 0, vop->data->intr->name, mask, v, NORMAL) |
| 63 | #define VOP_INTR_SET_TYPE(vop, name, type, v) \ | 63 | #define VOP_INTR_SET_TYPE(vop, name, type, v) \ |
| 64 | do { \ | 64 | do { \ |
| 65 | int i, reg = 0; \ | 65 | int i, reg = 0, mask = 0; \ |
| 66 | for (i = 0; i < vop->data->intr->nintrs; i++) { \ | 66 | for (i = 0; i < vop->data->intr->nintrs; i++) { \ |
| 67 | if (vop->data->intr->intrs[i] & type) \ | 67 | if (vop->data->intr->intrs[i] & type) { \ |
| 68 | reg |= (v) << i; \ | 68 | reg |= (v) << i; \ |
| 69 | mask |= 1 << i; \ | ||
| 70 | } \ | ||
| 69 | } \ | 71 | } \ |
| 70 | VOP_INTR_SET(vop, name, reg); \ | 72 | VOP_INTR_SET(vop, name, mask, reg); \ |
| 71 | } while (0) | 73 | } while (0) |
| 72 | #define VOP_INTR_GET_TYPE(vop, name, type) \ | 74 | #define VOP_INTR_GET_TYPE(vop, name, type) \ |
| 73 | vop_get_intr_type(vop, &vop->data->intr->name, type) | 75 | vop_get_intr_type(vop, &vop->data->intr->name, type) |
| @@ -144,19 +144,16 @@ int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused) · 143 unmodified lines | |||
| 144 | } | 144 | } |
| 145 | #endif /* CONFIG_DEBUG_FS */ | 145 | #endif /* CONFIG_DEBUG_FS */ |
| 146 | 146 | ||
| 147 | /* | ||
| 148 | * Asks the firmware to turn on power to the V3D engine. | ||
| 149 | * | ||
| 150 | * This may be doable with just the clocks interface, though this | ||
| 151 | * packet does some other register setup from the firmware, too. | ||
| 152 | */ | ||
| 153 | int | 147 | int |
| 154 | vc4_v3d_set_power(struct vc4_dev *vc4, bool on) | 148 | vc4_v3d_set_power(struct vc4_dev *vc4, bool on) |
| 155 | { | 149 | { |
| 156 | if (on) | 150 | /* XXX: This interface is needed for GPU reset, and the way to |
| 157 | return pm_generic_poweroff(&vc4->v3d->pdev->dev); | 151 | * do it is to turn our power domain off and back on. We |
| 158 | else | 152 | * can't just reset from within the driver, because the reset |
| 159 | return pm_generic_resume(&vc4->v3d->pdev->dev); | 153 | * bits are in the power domain's register area, and get set |
| 154 | * during the poweron process. | ||
| 155 | */ | ||
| 156 | return 0; | ||
| 160 | } | 157 | } |
| 161 | 158 | ||
| 162 | static void vc4_v3d_init_hw(struct drm_device *dev) | 159 | static void vc4_v3d_init_hw(struct drm_device *dev) |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | |||
| 25 | * | 25 | * |
| 26 | **************************************************************************/ | 26 | **************************************************************************/ |
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/console.h> | ||
| 28 | 29 | ||
| 29 | #include <drm/drmP.h> | 30 | #include <drm/drmP.h> |
| 30 | #include "vmwgfx_drv.h" | 31 | #include "vmwgfx_drv.h" |
| @@ -1538,6 +1539,12 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 1507 unmodified lines | |||
| 1538 | static int __init vmwgfx_init(void) | 1539 | static int __init vmwgfx_init(void) |
| 1539 | { | 1540 | { |
| 1540 | int ret; | 1541 | int ret; |
| 1542 | |||
| 1543 | #ifdef CONFIG_VGA_CONSOLE | ||
| 1544 | if (vgacon_text_force()) | ||
| 1545 | return -EINVAL; | ||
| 1546 | #endif | ||
| 1547 | |||
| 1541 | ret = drm_pci_init(&driver, &vmw_pci_driver); | 1548 | ret = drm_pci_init(&driver, &vmw_pci_driver); |
| 1542 | if (ret) | 1549 | if (ret) |
| 1543 | DRM_ERROR("Failed initializing DRM.\n"); | 1550 | DRM_ERROR("Failed initializing DRM.\n"); |
| @@ -930,6 +930,17 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { · 929 unmodified lines | |||
| 930 | MODULE_DEVICE_TABLE(dmi, i8k_dmi_table); | 930 | MODULE_DEVICE_TABLE(dmi, i8k_dmi_table); |
| 931 | 931 | ||
| 932 | static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = { | 932 | static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = { |
| 933 | { | ||
| 934 | /* | ||
| 935 | * CPU fan speed going up and down on Dell Studio XPS 8000 | ||
| 936 | * for unknown reasons. | ||
| 937 | */ | ||
| 938 | .ident = "Dell Studio XPS 8000", | ||
| 939 | .matches = { | ||
| 940 | DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
| 941 | DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Studio XPS 8000"), | ||
| 942 | }, | ||
| 943 | }, | ||
| 933 | { | 944 | { |
| 934 | /* | 945 | /* |
| 935 | * CPU fan speed going up and down on Dell Studio XPS 8100 | 946 | * CPU fan speed going up and down on Dell Studio XPS 8100 |
| @@ -90,7 +90,15 @@ static ssize_t show_power(struct device *dev, · 89 unmodified lines | |||
| 90 | pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5), | 90 | pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5), |
| 91 | REG_TDP_LIMIT3, &val); | 91 | REG_TDP_LIMIT3, &val); |
| 92 | 92 | ||
| 93 | tdp_limit = val >> 16; | 93 | /* |
| 94 | * On Carrizo and later platforms, ApmTdpLimit bit field | ||
| 95 | * is extended to 16:31 from 16:28. | ||
| 96 | */ | ||
| 97 | if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) | ||
| 98 | tdp_limit = val >> 16; | ||
| 99 | else | ||
| 100 | tdp_limit = (val >> 16) & 0x1fff; | ||
| 101 | |||
| 94 | curr_pwr_watts = ((u64)(tdp_limit + | 102 | curr_pwr_watts = ((u64)(tdp_limit + |
| 95 | data->base_tdp)) << running_avg_range; | 103 | data->base_tdp)) << running_avg_range; |
| 96 | curr_pwr_watts -= running_avg_capture; | 104 | curr_pwr_watts -= running_avg_capture; |
| @@ -874,7 +874,8 @@ int i2c_dw_probe(struct dw_i2c_dev *dev) · 873 unmodified lines | |||
| 874 | i2c_set_adapdata(adap, dev); | 874 | i2c_set_adapdata(adap, dev); |
| 875 | 875 | ||
| 876 | i2c_dw_disable_int(dev); | 876 | i2c_dw_disable_int(dev); |
| 877 | r = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr, IRQF_SHARED, | 877 | r = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr, |
| 878 | IRQF_SHARED | IRQF_COND_SUSPEND, | ||
| 878 | dev_name(dev->dev), dev); | 879 | dev_name(dev->dev), dev); |
| 879 | if (r) { | 880 | if (r) { |
| 880 | dev_err(dev->dev, "failure requesting irq %i: %d\n", | 881 | dev_err(dev->dev, "failure requesting irq %i: %d\n", |
| @@ -137,10 +137,11 @@ static const struct dmi_system_id piix4_dmi_ibm[] = { · 136 unmodified lines | |||
| 137 | }; | 137 | }; |
| 138 | 138 | ||
| 139 | /* SB800 globals */ | 139 | /* SB800 globals */ |
| 140 | static DEFINE_MUTEX(piix4_mutex_sb800); | ||
| 140 | static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = { | 141 | static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = { |
| 141 | "SDA0", "SDA2", "SDA3", "SDA4" | 142 | " port 0", " port 2", " port 3", " port 4" |
| 142 | }; | 143 | }; |
| 143 | static const char *piix4_aux_port_name_sb800 = "SDA1"; | 144 | static const char *piix4_aux_port_name_sb800 = " port 1"; |
| 144 | 145 | ||
| 145 | struct i2c_piix4_adapdata { | 146 | struct i2c_piix4_adapdata { |
| 146 | unsigned short smba; | 147 | unsigned short smba; |
| @@ -148,7 +149,6 @@ struct i2c_piix4_adapdata { · 1 unmodified line | |||
| 148 | /* SB800 */ | 149 | /* SB800 */ |
| 149 | bool sb800_main; | 150 | bool sb800_main; |
| 150 | unsigned short port; | 151 | unsigned short port; |
| 151 | struct mutex *mutex; | ||
| 152 | }; | 152 | }; |
| 153 | 153 | ||
| 154 | static int piix4_setup(struct pci_dev *PIIX4_dev, | 154 | static int piix4_setup(struct pci_dev *PIIX4_dev, |
| @@ -275,10 +275,12 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, · 120 unmodified lines | |||
| 275 | else | 275 | else |
| 276 | smb_en = (aux) ? 0x28 : 0x2c; | 276 | smb_en = (aux) ? 0x28 : 0x2c; |
| 277 | 277 | ||
| 278 | mutex_lock(&piix4_mutex_sb800); | ||
| 278 | outb_p(smb_en, SB800_PIIX4_SMB_IDX); | 279 | outb_p(smb_en, SB800_PIIX4_SMB_IDX); |
| 279 | smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); | 280 | smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); |
| 280 | outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); | 281 | outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); |
| 281 | smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); | 282 | smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); |
| 283 | mutex_unlock(&piix4_mutex_sb800); | ||
| 282 | 284 | ||
| 283 | if (!smb_en) { | 285 | if (!smb_en) { |
| 284 | smb_en_status = smba_en_lo & 0x10; | 286 | smb_en_status = smba_en_lo & 0x10; |
| @@ -559,7 +561,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, · 274 unmodified lines | |||
| 559 | u8 port; | 561 | u8 port; |
| 560 | int retval; | 562 | int retval; |
| 561 | 563 | ||
| 562 | mutex_lock(adapdata->mutex); | 564 | mutex_lock(&piix4_mutex_sb800); |
| 563 | 565 | ||
| 564 | outb_p(SB800_PIIX4_PORT_IDX, SB800_PIIX4_SMB_IDX); | 566 | outb_p(SB800_PIIX4_PORT_IDX, SB800_PIIX4_SMB_IDX); |
| 565 | smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); | 567 | smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); |
| @@ -574,7 +576,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, · 8 unmodified lines | |||
| 574 | 576 | ||
| 575 | outb_p(smba_en_lo, SB800_PIIX4_SMB_IDX + 1); | 577 | outb_p(smba_en_lo, SB800_PIIX4_SMB_IDX + 1); |
| 576 | 578 | ||
| 577 | mutex_unlock(adapdata->mutex); | 579 | mutex_unlock(&piix4_mutex_sb800); |
| 578 | 580 | ||
| 579 | return retval; | 581 | return retval; |
| 580 | } | 582 | } |
| @@ -625,6 +627,7 @@ static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS]; · 44 unmodified lines | |||
| 625 | static struct i2c_adapter *piix4_aux_adapter; | 627 | static struct i2c_adapter *piix4_aux_adapter; |
| 626 | 628 | ||
| 627 | static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, | 629 | static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, |
| 630 | bool sb800_main, unsigned short port, | ||
| 628 | const char *name, struct i2c_adapter **padap) | 631 | const char *name, struct i2c_adapter **padap) |
| 629 | { | 632 | { |
| 630 | struct i2c_adapter *adap; | 633 | struct i2c_adapter *adap; |
| @@ -639,7 +642,8 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 8 unmodified lines | |||
| 639 | 642 | ||
| 640 | adap->owner = THIS_MODULE; | 643 | adap->owner = THIS_MODULE; |
| 641 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | 644 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
| 642 | adap->algo = &smbus_algorithm; | 645 | adap->algo = sb800_main ? &piix4_smbus_algorithm_sb800 |
| 646 | : &smbus_algorithm; | ||
| 643 | 647 | ||
| 644 | adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL); | 648 | adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL); |
| 645 | if (adapdata == NULL) { | 649 | if (adapdata == NULL) { |
| @@ -649,12 +653,14 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 3 unmodified lines | |||
| 649 | } | 653 | } |
| 650 | 654 | ||
| 651 | adapdata->smba = smba; | 655 | adapdata->smba = smba; |
| 656 | adapdata->sb800_main = sb800_main; | ||
| 657 | adapdata->port = port; | ||
| 652 | 658 | ||
| 653 | /* set up the sysfs linkage to our parent device */ | 659 | /* set up the sysfs linkage to our parent device */ |
| 654 | adap->dev.parent = &dev->dev; | 660 | adap->dev.parent = &dev->dev; |
| 655 | 661 | ||
| 656 | snprintf(adap->name, sizeof(adap->name), | 662 | snprintf(adap->name, sizeof(adap->name), |
| 657 | "SMBus PIIX4 adapter %s at %04x", name, smba); | 663 | "SMBus PIIX4 adapter%s at %04x", name, smba); |
| 658 | 664 | ||
| 659 | i2c_set_adapdata(adap, adapdata); | 665 | i2c_set_adapdata(adap, adapdata); |
| 660 | 666 | ||
| @@ -673,30 +679,16 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 12 unmodified lines | |||
| 673 | 679 | ||
| 674 | static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba) | 680 | static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba) |
| 675 | { | 681 | { |
| 676 | struct mutex *mutex; | ||
| 677 | struct i2c_piix4_adapdata *adapdata; | 682 | struct i2c_piix4_adapdata *adapdata; |
| 678 | int port; | 683 | int port; |
| 679 | int retval; | 684 | int retval; |
| 680 | 685 | ||
| 681 | mutex = kzalloc(sizeof(*mutex), GFP_KERNEL); | ||
| 682 | if (mutex == NULL) | ||
| 683 | return -ENOMEM; | ||
| 684 | |||
| 685 | mutex_init(mutex); | ||
| 686 | |||
| 687 | for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) { | 686 | for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) { |
| 688 | retval = piix4_add_adapter(dev, smba, | 687 | retval = piix4_add_adapter(dev, smba, true, port, |
| 689 | piix4_main_port_names_sb800[port], | 688 | piix4_main_port_names_sb800[port], |
| 690 | &piix4_main_adapters[port]); | 689 | &piix4_main_adapters[port]); |
| 691 | if (retval < 0) | 690 | if (retval < 0) |
| 692 | goto error; | 691 | goto error; |
| 693 | |||
| 694 | piix4_main_adapters[port]->algo = &piix4_smbus_algorithm_sb800; | ||
| 695 | |||
| 696 | adapdata = i2c_get_adapdata(piix4_main_adapters[port]); | ||
| 697 | adapdata->sb800_main = true; | ||
| 698 | adapdata->port = port; | ||
| 699 | adapdata->mutex = mutex; | ||
| 700 | } | 692 | } |
| 701 | 693 | ||
| 702 | return retval; | 694 | return retval; |
| @@ -714,19 +706,20 @@ error: · 11 unmodified lines | |||
| 714 | } | 706 | } |
| 715 | } | 707 | } |
| 716 | 708 | ||
| 717 | kfree(mutex); | ||
| 718 | |||
| 719 | return retval; | 709 | return retval; |
| 720 | } | 710 | } |
| 721 | 711 | ||
| 722 | static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) | 712 | static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) |
| 723 | { | 713 | { |
| 724 | int retval; | 714 | int retval; |
| 715 | bool is_sb800 = false; | ||
| 725 | 716 | ||
| 726 | if ((dev->vendor == PCI_VENDOR_ID_ATI && | 717 | if ((dev->vendor == PCI_VENDOR_ID_ATI && |
| 727 | dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && | 718 | dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS && |
| 728 | dev->revision >= 0x40) || | 719 | dev->revision >= 0x40) || |
| 729 | dev->vendor == PCI_VENDOR_ID_AMD) { | 720 | dev->vendor == PCI_VENDOR_ID_AMD) { |
| 721 | is_sb800 = true; | ||
| 722 | |||
| 730 | if (!request_region(SB800_PIIX4_SMB_IDX, 2, "smba_idx")) { | 723 | if (!request_region(SB800_PIIX4_SMB_IDX, 2, "smba_idx")) { |
| 731 | dev_err(&dev->dev, | 724 | dev_err(&dev->dev, |
| 732 | "SMBus base address index region 0x%x already in use!\n", | 725 | "SMBus base address index region 0x%x already in use!\n", |
| @@ -756,7 +749,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 23 unmodified lines | |||
| 756 | return retval; | 749 | return retval; |
| 757 | 750 | ||
| 758 | /* Try to register main SMBus adapter, give up if we can't */ | 751 | /* Try to register main SMBus adapter, give up if we can't */ |
| 759 | retval = piix4_add_adapter(dev, retval, "main", | 752 | retval = piix4_add_adapter(dev, retval, false, 0, "", |
| 760 | &piix4_main_adapters[0]); | 753 | &piix4_main_adapters[0]); |
| 761 | if (retval < 0) | 754 | if (retval < 0) |
| 762 | return retval; | 755 | return retval; |
| @@ -783,7 +776,8 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 20 unmodified lines | |||
| 783 | if (retval > 0) { | 776 | if (retval > 0) { |
| 784 | /* Try to add the aux adapter if it exists, | 777 | /* Try to add the aux adapter if it exists, |
| 785 | * piix4_add_adapter will clean up if this fails */ | 778 | * piix4_add_adapter will clean up if this fails */ |
| 786 | piix4_add_adapter(dev, retval, piix4_aux_port_name_sb800, | 779 | piix4_add_adapter(dev, retval, false, 0, |
| 780 | is_sb800 ? piix4_aux_port_name_sb800 : "", | ||
| 787 | &piix4_aux_adapter); | 781 | &piix4_aux_adapter); |
| 788 | } | 782 | } |
| 789 | 783 | ||
| @@ -798,10 +792,8 @@ static void piix4_adap_remove(struct i2c_adapter *adap) · 8 unmodified lines | |||
| 798 | i2c_del_adapter(adap); | 792 | i2c_del_adapter(adap); |
| 799 | if (adapdata->port == 0) { | 793 | if (adapdata->port == 0) { |
| 800 | release_region(adapdata->smba, SMBIOSIZE); | 794 | release_region(adapdata->smba, SMBIOSIZE); |
| 801 | if (adapdata->sb800_main) { | 795 | if (adapdata->sb800_main) |
| 802 | kfree(adapdata->mutex); | ||
| 803 | release_region(SB800_PIIX4_SMB_IDX, 2); | 796 | release_region(SB800_PIIX4_SMB_IDX, 2); |
| 804 | } | ||
| 805 | } | 797 | } |
| 806 | kfree(adapdata); | 798 | kfree(adapdata); |
| 807 | kfree(adap); | 799 | kfree(adap); |
| @@ -43,7 +43,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, · 42 unmodified lines | |||
| 43 | return -ENOMEM; | 43 | return -ENOMEM; |
| 44 | 44 | ||
| 45 | rx = adis->buffer; | 45 | rx = adis->buffer; |
| 46 | tx = rx + indio_dev->scan_bytes; | 46 | tx = rx + scan_count; |
| 47 | 47 | ||
| 48 | spi_message_init(&adis->msg); | 48 | spi_message_init(&adis->msg); |
| 49 | 49 | ||
| @@ -2049,7 +2049,7 @@ static void do_attach(struct iommu_dev_data *dev_data, · 2048 unmodified lines | |||
| 2049 | /* Update device table */ | 2049 | /* Update device table */ |
| 2050 | set_dte_entry(dev_data->devid, domain, ats); | 2050 | set_dte_entry(dev_data->devid, domain, ats); |
| 2051 | if (alias != dev_data->devid) | 2051 | if (alias != dev_data->devid) |
| 2052 | set_dte_entry(dev_data->devid, domain, ats); | 2052 | set_dte_entry(alias, domain, ats); |
| 2053 | 2053 | ||
| 2054 | device_flush_dte(dev_data); | 2054 | device_flush_dte(dev_data); |
| 2055 | } | 2055 | } |
| @@ -1489,7 +1489,7 @@ static void iommu_disable_dev_iotlb(struct device_domain_info *info) · 1488 unmodified lines | |||
| 1489 | { | 1489 | { |
| 1490 | struct pci_dev *pdev; | 1490 | struct pci_dev *pdev; |
| 1491 | 1491 | ||
| 1492 | if (dev_is_pci(info->dev)) | 1492 | if (!dev_is_pci(info->dev)) |
| 1493 | return; | 1493 | return; |
| 1494 | 1494 | ||
| 1495 | pdev = to_pci_dev(info->dev); | 1495 | pdev = to_pci_dev(info->dev); |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | |||
| 25 | #include <linux/sizes.h> | 25 | #include <linux/sizes.h> |
| 26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
| 27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
| 28 | #include <linux/dma-mapping.h> | ||
| 28 | 29 | ||
| 29 | #include <asm/barrier.h> | 30 | #include <asm/barrier.h> |
| 30 | 31 | ||
| @@ -159,6 +159,7 @@ config TB10X_IRQC · 158 unmodified lines | |||
| 159 | config TS4800_IRQ | 159 | config TS4800_IRQ |
| 160 | tristate "TS-4800 IRQ controller" | 160 | tristate "TS-4800 IRQ controller" |
| 161 | select IRQ_DOMAIN | 161 | select IRQ_DOMAIN |
| 162 | depends on HAS_IOMEM | ||
| 162 | help | 163 | help |
| 163 | Support for the TS-4800 FPGA IRQ controller | 164 | Support for the TS-4800 FPGA IRQ controller |
| 164 | 165 | ||
| @@ -86,7 +86,7 @@ int aic_common_set_priority(int priority, unsigned *val) · 85 unmodified lines | |||
| 86 | priority > AT91_AIC_IRQ_MAX_PRIORITY) | 86 | priority > AT91_AIC_IRQ_MAX_PRIORITY) |
| 87 | return -EINVAL; | 87 | return -EINVAL; |
| 88 | 88 | ||
| 89 | *val &= AT91_AIC_PRIOR; | 89 | *val &= ~AT91_AIC_PRIOR; |
| 90 | *val |= priority; | 90 | *val |= priority; |
| 91 | 91 | ||
| 92 | return 0; | 92 | return 0; |
| @@ -875,6 +875,7 @@ static int its_alloc_tables(const char *node_name, struct its_node *its) · 874 unmodified lines | |||
| 875 | } | 875 | } |
| 876 | 876 | ||
| 877 | alloc_size = (1 << order) * PAGE_SIZE; | 877 | alloc_size = (1 << order) * PAGE_SIZE; |
| 878 | retry_alloc_baser: | ||
| 878 | alloc_pages = (alloc_size / psz); | 879 | alloc_pages = (alloc_size / psz); |
| 879 | if (alloc_pages > GITS_BASER_PAGES_MAX) { | 880 | if (alloc_pages > GITS_BASER_PAGES_MAX) { |
| 880 | alloc_pages = GITS_BASER_PAGES_MAX; | 881 | alloc_pages = GITS_BASER_PAGES_MAX; |
| @@ -938,13 +939,16 @@ retry_baser: · 57 unmodified lines | |||
| 938 | * size and retry. If we reach 4K, then | 939 | * size and retry. If we reach 4K, then |
| 939 | * something is horribly wrong... | 940 | * something is horribly wrong... |
| 940 | */ | 941 | */ |
| 942 | free_pages((unsigned long)base, order); | ||
| 943 | its->tables[i] = NULL; | ||
| 944 | |||
| 941 | switch (psz) { | 945 | switch (psz) { |
| 942 | case SZ_16K: | 946 | case SZ_16K: |
| 943 | psz = SZ_4K; | 947 | psz = SZ_4K; |
| 944 | goto retry_baser; | 948 | goto retry_alloc_baser; |
| 945 | case SZ_64K: | 949 | case SZ_64K: |
| 946 | psz = SZ_16K; | 950 | psz = SZ_16K; |
| 947 | goto retry_baser; | 951 | goto retry_alloc_baser; |
| 948 | } | 952 | } |
| 949 | } | 953 | } |
| 950 | 954 | ||
| @@ -241,6 +241,7 @@ static int __init asm9260_of_init(struct device_node *np, · 240 unmodified lines | |||
| 241 | writel(0, icoll_priv.intr + i); | 241 | writel(0, icoll_priv.intr + i); |
| 242 | 242 | ||
| 243 | icoll_add_domain(np, ASM9260_NUM_IRQS); | 243 | icoll_add_domain(np, ASM9260_NUM_IRQS); |
| 244 | set_handle_irq(icoll_handle_irq); | ||
| 244 | 245 | ||
| 245 | return 0; | 246 | return 0; |
| 246 | } | 247 | } |
| @@ -605,7 +605,7 @@ err: · 604 unmodified lines | |||
| 605 | return ERR_PTR(ret); | 605 | return ERR_PTR(ret); |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | static struct s3c_irq_data init_eint[32] = { | 608 | static struct s3c_irq_data __maybe_unused init_eint[32] = { |
| 609 | { .type = S3C_IRQTYPE_NONE, }, /* reserved */ | 609 | { .type = S3C_IRQTYPE_NONE, }, /* reserved */ |
| 610 | { .type = S3C_IRQTYPE_NONE, }, /* reserved */ | 610 | { .type = S3C_IRQTYPE_NONE, }, /* reserved */ |
| 611 | { .type = S3C_IRQTYPE_NONE, }, /* reserved */ | 611 | { .type = S3C_IRQTYPE_NONE, }, /* reserved */ |
| @@ -679,18 +679,6 @@ u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in) · 678 unmodified lines | |||
| 679 | return __of_msi_map_rid(dev, &msi_np, rid_in); | 679 | return __of_msi_map_rid(dev, &msi_np, rid_in); |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | static struct irq_domain *__of_get_msi_domain(struct device_node *np, | ||
| 683 | enum irq_domain_bus_token token) | ||
| 684 | { | ||
| 685 | struct irq_domain *d; | ||
| 686 | |||
| 687 | d = irq_find_matching_host(np, token); | ||
| 688 | if (!d) | ||
| 689 | d = irq_find_host(np); | ||
| 690 | |||
| 691 | return d; | ||
| 692 | } | ||
| 693 | |||
| 694 | /** | 682 | /** |
| 695 | * of_msi_map_get_device_domain - Use msi-map to find the relevant MSI domain | 683 | * of_msi_map_get_device_domain - Use msi-map to find the relevant MSI domain |
| 696 | * @dev: device for which the mapping is to be done. | 684 | * @dev: device for which the mapping is to be done. |
| @@ -706,7 +694,7 @@ struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 rid) · 9 unmodified lines | |||
| 706 | struct device_node *np = NULL; | 694 | struct device_node *np = NULL; |
| 707 | 695 | ||
| 708 | __of_msi_map_rid(dev, &np, rid); | 696 | __of_msi_map_rid(dev, &np, rid); |
| 709 | return __of_get_msi_domain(np, DOMAIN_BUS_PCI_MSI); | 697 | return irq_find_matching_host(np, DOMAIN_BUS_PCI_MSI); |
| 710 | } | 698 | } |
| 711 | 699 | ||
| 712 | /** | 700 | /** |
| @@ -730,7 +718,7 @@ struct irq_domain *of_msi_get_domain(struct device *dev, · 17 unmodified lines | |||
| 730 | /* Check for a single msi-parent property */ | 718 | /* Check for a single msi-parent property */ |
| 731 | msi_np = of_parse_phandle(np, "msi-parent", 0); | 719 | msi_np = of_parse_phandle(np, "msi-parent", 0); |
| 732 | if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) { | 720 | if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) { |
| 733 | d = __of_get_msi_domain(msi_np, token); | 721 | d = irq_find_matching_host(msi_np, token); |
| 734 | if (!d) | 722 | if (!d) |
| 735 | of_node_put(msi_np); | 723 | of_node_put(msi_np); |
| 736 | return d; | 724 | return d; |
| @@ -744,7 +732,7 @@ struct irq_domain *of_msi_get_domain(struct device *dev, · 7 unmodified lines | |||
| 744 | while (!of_parse_phandle_with_args(np, "msi-parent", | 732 | while (!of_parse_phandle_with_args(np, "msi-parent", |
| 745 | "#msi-cells", | 733 | "#msi-cells", |
| 746 | index, &args)) { | 734 | index, &args)) { |
| 747 | d = __of_get_msi_domain(args.np, token); | 735 | d = irq_find_matching_host(args.np, token); |
| 748 | if (d) | 736 | if (d) |
| 749 | return d; | 737 | return d; |
| 750 | 738 | ||
| @@ -953,8 +953,10 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) · 952 unmodified lines | |||
| 953 | { | 953 | { |
| 954 | pci_lock_rescan_remove(); | 954 | pci_lock_rescan_remove(); |
| 955 | 955 | ||
| 956 | if (slot->flags & SLOT_IS_GOING_AWAY) | 956 | if (slot->flags & SLOT_IS_GOING_AWAY) { |
| 957 | pci_unlock_rescan_remove(); | ||
| 957 | return -ENODEV; | 958 | return -ENODEV; |
| 959 | } | ||
| 958 | 960 | ||
| 959 | /* configure all functions */ | 961 | /* configure all functions */ |
| 960 | if (!(slot->flags & SLOT_ENABLED)) | 962 | if (!(slot->flags & SLOT_ENABLED)) |
| @@ -139,11 +139,11 @@ static ssize_t chp_measurement_chars_read(struct file *filp, · 138 unmodified lines | |||
| 139 | 139 | ||
| 140 | device = container_of(kobj, struct device, kobj); | 140 | device = container_of(kobj, struct device, kobj); |
| 141 | chp = to_channelpath(device); | 141 | chp = to_channelpath(device); |
| 142 | if (!chp->cmg_chars) | 142 | if (chp->cmg == -1) |
| 143 | return 0; | 143 | return 0; |
| 144 | 144 | ||
| 145 | return memory_read_from_buffer(buf, count, &off, | 145 | return memory_read_from_buffer(buf, count, &off, &chp->cmg_chars, |
| 146 | chp->cmg_chars, sizeof(struct cmg_chars)); | 146 | sizeof(chp->cmg_chars)); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | static struct bin_attribute chp_measurement_chars_attr = { | 149 | static struct bin_attribute chp_measurement_chars_attr = { |
| @@ -416,7 +416,8 @@ static void chp_release(struct device *dev) · 266 unmodified lines | |||
| 416 | * chp_update_desc - update channel-path description | 416 | * chp_update_desc - update channel-path description |
| 417 | * @chp - channel-path | 417 | * @chp - channel-path |
| 418 | * | 418 | * |
| 419 | * Update the channel-path description of the specified channel-path. | 419 | * Update the channel-path description of the specified channel-path |
| 420 | * including channel measurement related information. | ||
| 420 | * Return zero on success, non-zero otherwise. | 421 | * Return zero on success, non-zero otherwise. |
| 421 | */ | 422 | */ |
| 422 | int chp_update_desc(struct channel_path *chp) | 423 | int chp_update_desc(struct channel_path *chp) |
| @@ -428,8 +429,10 @@ int chp_update_desc(struct channel_path *chp) · 5 unmodified lines | |||
| 428 | return rc; | 429 | return rc; |
| 429 | 430 | ||
| 430 | rc = chsc_determine_fmt1_channel_path_desc(chp->chpid, &chp->desc_fmt1); | 431 | rc = chsc_determine_fmt1_channel_path_desc(chp->chpid, &chp->desc_fmt1); |
| 432 | if (rc) | ||
| 433 | return rc; | ||
| 431 | 434 | ||
| 432 | return rc; | 435 | return chsc_get_channel_measurement_chars(chp); |
| 433 | } | 436 | } |
| 434 | 437 | ||
| 435 | /** | 438 | /** |
| @@ -466,14 +469,6 @@ int chp_new(struct chp_id chpid) · 30 unmodified lines | |||
| 466 | ret = -ENODEV; | 469 | ret = -ENODEV; |
| 467 | goto out_free; | 470 | goto out_free; |
| 468 | } | 471 | } |
| 469 | /* Get channel-measurement characteristics. */ | ||
| 470 | if (css_chsc_characteristics.scmc && css_chsc_characteristics.secm) { | ||
| 471 | ret = chsc_get_channel_measurement_chars(chp); | ||
| 472 | if (ret) | ||
| 473 | goto out_free; | ||
| 474 | } else { | ||
| 475 | chp->cmg = -1; | ||
| 476 | } | ||
| 477 | dev_set_name(&chp->dev, "chp%x.%02x", chpid.cssid, chpid.id); | 472 | dev_set_name(&chp->dev, "chp%x.%02x", chpid.cssid, chpid.id); |
| 478 | 473 | ||
| 479 | /* make it known to the system */ | 474 | /* make it known to the system */ |
| @@ -48,7 +48,7 @@ struct channel_path { · 47 unmodified lines | |||
| 48 | /* Channel-measurement related stuff: */ | 48 | /* Channel-measurement related stuff: */ |
| 49 | int cmg; | 49 | int cmg; |
| 50 | int shared; | 50 | int shared; |
| 51 | void *cmg_chars; | 51 | struct cmg_chars cmg_chars; |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | /* Return channel_path struct for given chpid. */ | 54 | /* Return channel_path struct for given chpid. */ |
| @@ -14,6 +14,7 @@ · 13 unmodified lines | |||
| 14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
| 15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> | 16 | #include <linux/device.h> |
| 17 | #include <linux/mutex.h> | ||
| 17 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
| 18 | 19 | ||
| 19 | #include <asm/cio.h> | 20 | #include <asm/cio.h> |
| @@ -224,8 +225,9 @@ out_unreg: · 204 unmodified lines | |||
| 224 | 225 | ||
| 225 | void chsc_chp_offline(struct chp_id chpid) | 226 | void chsc_chp_offline(struct chp_id chpid) |
| 226 | { | 227 | { |
| 227 | char dbf_txt[15]; | 228 | struct channel_path *chp = chpid_to_chp(chpid); |
| 228 | struct chp_link link; | 229 | struct chp_link link; |
| 230 | char dbf_txt[15]; | ||
| 229 | 231 | ||
| 230 | sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id); | 232 | sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id); |
| 231 | CIO_TRACE_EVENT(2, dbf_txt); | 233 | CIO_TRACE_EVENT(2, dbf_txt); |
| @@ -236,6 +238,11 @@ void chsc_chp_offline(struct chp_id chpid) · 4 unmodified lines | |||
| 236 | link.chpid = chpid; | 238 | link.chpid = chpid; |
| 237 | /* Wait until previous actions have settled. */ | 239 | /* Wait until previous actions have settled. */ |
| 238 | css_wait_for_slow_path(); | 240 | css_wait_for_slow_path(); |
| 241 | |||
| 242 | mutex_lock(&chp->lock); | ||
| 243 | chp_update_desc(chp); | ||
| 244 | mutex_unlock(&chp->lock); | ||
| 245 | |||
| 239 | for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link); | 246 | for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link); |
| 240 | } | 247 | } |
| 241 | 248 | ||
| @@ -690,8 +697,9 @@ static void chsc_process_crw(struct crw *crw0, struct crw *crw1, int overflow) · 448 unmodified lines | |||
| 690 | 697 | ||
| 691 | void chsc_chp_online(struct chp_id chpid) | 698 | void chsc_chp_online(struct chp_id chpid) |
| 692 | { | 699 | { |
| 693 | char dbf_txt[15]; | 700 | struct channel_path *chp = chpid_to_chp(chpid); |
| 694 | struct chp_link link; | 701 | struct chp_link link; |
| 702 | char dbf_txt[15]; | ||
| 695 | 703 | ||
| 696 | sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id); | 704 | sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id); |
| 697 | CIO_TRACE_EVENT(2, dbf_txt); | 705 | CIO_TRACE_EVENT(2, dbf_txt); |
| @@ -701,6 +709,11 @@ void chsc_chp_online(struct chp_id chpid) · 3 unmodified lines | |||
| 701 | link.chpid = chpid; | 709 | link.chpid = chpid; |
| 702 | /* Wait until previous actions have settled. */ | 710 | /* Wait until previous actions have settled. */ |
| 703 | css_wait_for_slow_path(); | 711 | css_wait_for_slow_path(); |
| 712 | |||
| 713 | mutex_lock(&chp->lock); | ||
| 714 | chp_update_desc(chp); | ||
| 715 | mutex_unlock(&chp->lock); | ||
| 716 | |||
| 704 | for_each_subchannel_staged(__s390_process_res_acc, NULL, | 717 | for_each_subchannel_staged(__s390_process_res_acc, NULL, |
| 705 | &link); | 718 | &link); |
| 706 | css_schedule_reprobe(); | 719 | css_schedule_reprobe(); |
| @@ -967,22 +980,19 @@ static void · 260 unmodified lines | |||
| 967 | chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv, | 980 | chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv, |
| 968 | struct cmg_chars *chars) | 981 | struct cmg_chars *chars) |
| 969 | { | 982 | { |
| 970 | struct cmg_chars *cmg_chars; | ||
| 971 | int i, mask; | 983 | int i, mask; |
| 972 | 984 | ||
| 973 | cmg_chars = chp->cmg_chars; | ||
| 974 | for (i = 0; i < NR_MEASUREMENT_CHARS; i++) { | 985 | for (i = 0; i < NR_MEASUREMENT_CHARS; i++) { |
| 975 | mask = 0x80 >> (i + 3); | 986 | mask = 0x80 >> (i + 3); |
| 976 | if (cmcv & mask) | 987 | if (cmcv & mask) |
| 977 | cmg_chars->values[i] = chars->values[i]; | 988 | chp->cmg_chars.values[i] = chars->values[i]; |
| 978 | else | 989 | else |
| 979 | cmg_chars->values[i] = 0; | 990 | chp->cmg_chars.values[i] = 0; |
| 980 | } | 991 | } |
| 981 | } | 992 | } |
| 982 | 993 | ||
| 983 | int chsc_get_channel_measurement_chars(struct channel_path *chp) | 994 | int chsc_get_channel_measurement_chars(struct channel_path *chp) |
| 984 | { | 995 | { |
| 985 | struct cmg_chars *cmg_chars; | ||
| 986 | int ccode, ret; | 996 | int ccode, ret; |
| 987 | 997 | ||
| 988 | struct { | 998 | struct { |
| @@ -1006,10 +1016,11 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) · 17 unmodified lines | |||
| 1006 | u32 data[NR_MEASUREMENT_CHARS]; | 1016 | u32 data[NR_MEASUREMENT_CHARS]; |
| 1007 | } __attribute__ ((packed)) *scmc_area; | 1017 | } __attribute__ ((packed)) *scmc_area; |
| 1008 | 1018 | ||
| 1009 | chp->cmg_chars = NULL; | 1019 | chp->shared = -1; |
| 1010 | cmg_chars = kmalloc(sizeof(*cmg_chars), GFP_KERNEL); | 1020 | chp->cmg = -1; |
| 1011 | if (!cmg_chars) | 1021 | |
| 1012 | return -ENOMEM; | 1022 | if (!css_chsc_characteristics.scmc || !css_chsc_characteristics.secm) |
| 1023 | return 0; | ||
| 1013 | 1024 | ||
| 1014 | spin_lock_irq(&chsc_page_lock); | 1025 | spin_lock_irq(&chsc_page_lock); |
| 1015 | memset(chsc_page, 0, PAGE_SIZE); | 1026 | memset(chsc_page, 0, PAGE_SIZE); |
| @@ -1031,25 +1042,19 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) · 15 unmodified lines | |||
| 1031 | scmc_area->response.code); | 1042 | scmc_area->response.code); |
| 1032 | goto out; | 1043 | goto out; |
| 1033 | } | 1044 | } |
| 1034 | if (scmc_area->not_valid) { | 1045 | if (scmc_area->not_valid) |
| 1035 | chp->cmg = -1; | ||
| 1036 | chp->shared = -1; | ||
| 1037 | goto out; | 1046 | goto out; |
| 1038 | } | 1047 | |
| 1039 | chp->cmg = scmc_area->cmg; | 1048 | chp->cmg = scmc_area->cmg; |
| 1040 | chp->shared = scmc_area->shared; | 1049 | chp->shared = scmc_area->shared; |
| 1041 | if (chp->cmg != 2 && chp->cmg != 3) { | 1050 | if (chp->cmg != 2 && chp->cmg != 3) { |
| 1042 | /* No cmg-dependent data. */ | 1051 | /* No cmg-dependent data. */ |
| 1043 | goto out; | 1052 | goto out; |
| 1044 | } | 1053 | } |
| 1045 | chp->cmg_chars = cmg_chars; | ||
| 1046 | chsc_initialize_cmg_chars(chp, scmc_area->cmcv, | 1054 | chsc_initialize_cmg_chars(chp, scmc_area->cmcv, |
| 1047 | (struct cmg_chars *) &scmc_area->data); | 1055 | (struct cmg_chars *) &scmc_area->data); |
| 1048 | out: | 1056 | out: |
| 1049 | spin_unlock_irq(&chsc_page_lock); | 1057 | spin_unlock_irq(&chsc_page_lock); |
| 1050 | if (!chp->cmg_chars) | ||
| 1051 | kfree(cmg_chars); | ||
| 1052 | |||
| 1053 | return ret; | 1058 | return ret; |
| 1054 | } | 1059 | } |
| 1055 | 1060 | ||
| @@ -112,9 +112,10 @@ static inline int convert_error(struct zcrypt_device *zdev, · 111 unmodified lines | |||
| 112 | atomic_set(&zcrypt_rescan_req, 1); | 112 | atomic_set(&zcrypt_rescan_req, 1); |
| 113 | zdev->online = 0; | 113 | zdev->online = 0; |
| 114 | pr_err("Cryptographic device %x failed and was set offline\n", | 114 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 115 | zdev->ap_dev->qid); | 115 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 116 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 116 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
| 117 | zdev->ap_dev->qid, zdev->online, ehdr->reply_code); | 117 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online, |
| 118 | ehdr->reply_code); | ||
| 118 | return -EAGAIN; | 119 | return -EAGAIN; |
| 119 | case REP82_ERROR_TRANSPORT_FAIL: | 120 | case REP82_ERROR_TRANSPORT_FAIL: |
| 120 | case REP82_ERROR_MACHINE_FAILURE: | 121 | case REP82_ERROR_MACHINE_FAILURE: |
| @@ -123,16 +124,18 @@ static inline int convert_error(struct zcrypt_device *zdev, · 2 unmodified lines | |||
| 123 | atomic_set(&zcrypt_rescan_req, 1); | 124 | atomic_set(&zcrypt_rescan_req, 1); |
| 124 | zdev->online = 0; | 125 | zdev->online = 0; |
| 125 | pr_err("Cryptographic device %x failed and was set offline\n", | 126 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 126 | zdev->ap_dev->qid); | 127 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 127 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 128 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
| 128 | zdev->ap_dev->qid, zdev->online, ehdr->reply_code); | 129 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online, |
| 130 | ehdr->reply_code); | ||
| 129 | return -EAGAIN; | 131 | return -EAGAIN; |
| 130 | default: | 132 | default: |
| 131 | zdev->online = 0; | 133 | zdev->online = 0; |
| 132 | pr_err("Cryptographic device %x failed and was set offline\n", | 134 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 133 | zdev->ap_dev->qid); | 135 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 134 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 136 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
| 135 | zdev->ap_dev->qid, zdev->online, ehdr->reply_code); | 137 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online, |
| 138 | ehdr->reply_code); | ||
| 136 | return -EAGAIN; /* repeat the request on a different device. */ | 139 | return -EAGAIN; /* repeat the request on a different device. */ |
| 137 | } | 140 | } |
| 138 | } | 141 | } |
| @@ -336,9 +336,10 @@ static int convert_type80(struct zcrypt_device *zdev, · 335 unmodified lines | |||
| 336 | /* The result is too short, the CEX2A card may not do that.. */ | 336 | /* The result is too short, the CEX2A card may not do that.. */ |
| 337 | zdev->online = 0; | 337 | zdev->online = 0; |
| 338 | pr_err("Cryptographic device %x failed and was set offline\n", | 338 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 339 | zdev->ap_dev->qid); | 339 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 340 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 340 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
| 341 | zdev->ap_dev->qid, zdev->online, t80h->code); | 341 | AP_QID_DEVICE(zdev->ap_dev->qid), |
| 342 | zdev->online, t80h->code); | ||
| 342 | 343 | ||
| 343 | return -EAGAIN; /* repeat the request on a different device. */ | 344 | return -EAGAIN; /* repeat the request on a different device. */ |
| 344 | } | 345 | } |
| @@ -368,9 +369,9 @@ static int convert_response(struct zcrypt_device *zdev, · 23 unmodified lines | |||
| 368 | default: /* Unknown response type, this should NEVER EVER happen */ | 369 | default: /* Unknown response type, this should NEVER EVER happen */ |
| 369 | zdev->online = 0; | 370 | zdev->online = 0; |
| 370 | pr_err("Cryptographic device %x failed and was set offline\n", | 371 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 371 | zdev->ap_dev->qid); | 372 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 372 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | 373 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", |
| 373 | zdev->ap_dev->qid, zdev->online); | 374 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online); |
| 374 | return -EAGAIN; /* repeat the request on a different device. */ | 375 | return -EAGAIN; /* repeat the request on a different device. */ |
| 375 | } | 376 | } |
| 376 | } | 377 | } |
| @@ -572,9 +572,9 @@ static int convert_type86_ica(struct zcrypt_device *zdev, · 571 unmodified lines | |||
| 572 | return -EINVAL; | 572 | return -EINVAL; |
| 573 | zdev->online = 0; | 573 | zdev->online = 0; |
| 574 | pr_err("Cryptographic device %x failed and was set offline\n", | 574 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 575 | zdev->ap_dev->qid); | 575 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 576 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", | 576 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d", |
| 577 | zdev->ap_dev->qid, zdev->online, | 577 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online, |
| 578 | msg->hdr.reply_code); | 578 | msg->hdr.reply_code); |
| 579 | return -EAGAIN; /* repeat the request on a different device. */ | 579 | return -EAGAIN; /* repeat the request on a different device. */ |
| 580 | } | 580 | } |
| @@ -715,9 +715,9 @@ static int convert_response_ica(struct zcrypt_device *zdev, · 134 unmodified lines | |||
| 715 | default: /* Unknown response type, this should NEVER EVER happen */ | 715 | default: /* Unknown response type, this should NEVER EVER happen */ |
| 716 | zdev->online = 0; | 716 | zdev->online = 0; |
| 717 | pr_err("Cryptographic device %x failed and was set offline\n", | 717 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 718 | zdev->ap_dev->qid); | 718 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 719 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | 719 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", |
| 720 | zdev->ap_dev->qid, zdev->online); | 720 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online); |
| 721 | return -EAGAIN; /* repeat the request on a different device. */ | 721 | return -EAGAIN; /* repeat the request on a different device. */ |
| 722 | } | 722 | } |
| 723 | } | 723 | } |
| @@ -747,9 +747,9 @@ static int convert_response_xcrb(struct zcrypt_device *zdev, · 23 unmodified lines | |||
| 747 | xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ | 747 | xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ |
| 748 | zdev->online = 0; | 748 | zdev->online = 0; |
| 749 | pr_err("Cryptographic device %x failed and was set offline\n", | 749 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 750 | zdev->ap_dev->qid); | 750 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 751 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | 751 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", |
| 752 | zdev->ap_dev->qid, zdev->online); | 752 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online); |
| 753 | return -EAGAIN; /* repeat the request on a different device. */ | 753 | return -EAGAIN; /* repeat the request on a different device. */ |
| 754 | } | 754 | } |
| 755 | } | 755 | } |
| @@ -773,9 +773,9 @@ static int convert_response_ep11_xcrb(struct zcrypt_device *zdev, · 17 unmodified lines | |||
| 773 | default: /* Unknown response type, this should NEVER EVER happen */ | 773 | default: /* Unknown response type, this should NEVER EVER happen */ |
| 774 | zdev->online = 0; | 774 | zdev->online = 0; |
| 775 | pr_err("Cryptographic device %x failed and was set offline\n", | 775 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 776 | zdev->ap_dev->qid); | 776 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 777 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | 777 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", |
| 778 | zdev->ap_dev->qid, zdev->online); | 778 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online); |
| 779 | return -EAGAIN; /* repeat the request on a different device. */ | 779 | return -EAGAIN; /* repeat the request on a different device. */ |
| 780 | } | 780 | } |
| 781 | } | 781 | } |
| @@ -800,9 +800,9 @@ static int convert_response_rng(struct zcrypt_device *zdev, · 18 unmodified lines | |||
| 800 | default: /* Unknown response type, this should NEVER EVER happen */ | 800 | default: /* Unknown response type, this should NEVER EVER happen */ |
| 801 | zdev->online = 0; | 801 | zdev->online = 0; |
| 802 | pr_err("Cryptographic device %x failed and was set offline\n", | 802 | pr_err("Cryptographic device %x failed and was set offline\n", |
| 803 | zdev->ap_dev->qid); | 803 | AP_QID_DEVICE(zdev->ap_dev->qid)); |
| 804 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", | 804 | ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail", |
| 805 | zdev->ap_dev->qid, zdev->online); | 805 | AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online); |
| 806 | return -EAGAIN; /* repeat the request on a different device. */ | 806 | return -EAGAIN; /* repeat the request on a different device. */ |
| 807 | } | 807 | } |
| 808 | } | 808 | } |
| @@ -1,5 +1,7 @@ | |||
| 1 | config SCSI_HISI_SAS | 1 | config SCSI_HISI_SAS |
| 2 | tristate "HiSilicon SAS" | 2 | tristate "HiSilicon SAS" |
| 3 | depends on HAS_DMA | ||
| 4 | depends on ARM64 || COMPILE_TEST | ||
| 3 | select SCSI_SAS_LIBSAS | 5 | select SCSI_SAS_LIBSAS |
| 4 | select BLK_DEV_INTEGRITY | 6 | select BLK_DEV_INTEGRITY |
| 5 | help | 7 | help |
| @@ -2893,7 +2893,7 @@ static int sd_revalidate_disk(struct gendisk *disk) · 2892 unmodified lines | |||
| 2893 | sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS && | 2893 | sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS && |
| 2894 | sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE) | 2894 | sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE) |
| 2895 | rw_max = q->limits.io_opt = | 2895 | rw_max = q->limits.io_opt = |
| 2896 | logical_to_sectors(sdp, sdkp->opt_xfer_blocks); | 2896 | sdkp->opt_xfer_blocks * sdp->sector_size; |
| 2897 | else | 2897 | else |
| 2898 | rw_max = BLK_DEF_MAX_SECTORS; | 2898 | rw_max = BLK_DEF_MAX_SECTORS; |
| 2899 | 2899 | ||
| @@ -3268,8 +3268,8 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) · 368 unmodified lines | |||
| 3268 | struct scsi_disk *sdkp = dev_get_drvdata(dev); | 3268 | struct scsi_disk *sdkp = dev_get_drvdata(dev); |
| 3269 | int ret = 0; | 3269 | int ret = 0; |
| 3270 | 3270 | ||
| 3271 | if (!sdkp) | 3271 | if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ |
| 3272 | return 0; /* this can happen */ | 3272 | return 0; |
| 3273 | 3273 | ||
| 3274 | if (sdkp->WCE && sdkp->media_present) { | 3274 | if (sdkp->WCE && sdkp->media_present) { |
| 3275 | sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); | 3275 | sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); |
| @@ -3308,6 +3308,9 @@ static int sd_resume(struct device *dev) · 32 unmodified lines | |||
| 3308 | { | 3308 | { |
| 3309 | struct scsi_disk *sdkp = dev_get_drvdata(dev); | 3309 | struct scsi_disk *sdkp = dev_get_drvdata(dev); |
| 3310 | 3310 | ||
| 3311 | if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ | ||
| 3312 | return 0; | ||
| 3313 | |||
| 3311 | if (!sdkp->device->manage_start_stop) | 3314 | if (!sdkp->device->manage_start_stop) |
| 3312 | return 0; | 3315 | return 0; |
| 3313 | 3316 | ||
| @@ -144,6 +144,9 @@ static int sr_runtime_suspend(struct device *dev) · 143 unmodified lines | |||
| 144 | { | 144 | { |
| 145 | struct scsi_cd *cd = dev_get_drvdata(dev); | 145 | struct scsi_cd *cd = dev_get_drvdata(dev); |
| 146 | 146 | ||
| 147 | if (!cd) /* E.g.: runtime suspend following sr_remove() */ | ||
| 148 | return 0; | ||
| 149 | |||
| 147 | if (cd->media_present) | 150 | if (cd->media_present) |
| 148 | return -EBUSY; | 151 | return -EBUSY; |
| 149 | else | 152 | else |
| @@ -985,6 +988,7 @@ static int sr_remove(struct device *dev) · 835 unmodified lines | |||
| 985 | scsi_autopm_get_device(cd->device); | 988 | scsi_autopm_get_device(cd->device); |
| 986 | 989 | ||
| 987 | del_gendisk(cd->disk); | 990 | del_gendisk(cd->disk); |
| 991 | dev_set_drvdata(dev, NULL); | ||
| 988 | 992 | ||
| 989 | mutex_lock(&sr_ref_mutex); | 993 | mutex_lock(&sr_ref_mutex); |
| 990 | kref_put(&cd->kref, sr_kref_release); | 994 | kref_put(&cd->kref, sr_kref_release); |
| @@ -825,8 +825,7 @@ static void lcd_write_cmd_s(int cmd) · 824 unmodified lines | |||
| 825 | lcd_send_serial(0x1F); /* R/W=W, RS=0 */ | 825 | lcd_send_serial(0x1F); /* R/W=W, RS=0 */ |
| 826 | lcd_send_serial(cmd & 0x0F); | 826 | lcd_send_serial(cmd & 0x0F); |
| 827 | lcd_send_serial((cmd >> 4) & 0x0F); | 827 | lcd_send_serial((cmd >> 4) & 0x0F); |
| 828 | /* the shortest command takes at least 40 us */ | 828 | udelay(40); /* the shortest command takes at least 40 us */ |
| 829 | usleep_range(40, 100); | ||
| 830 | spin_unlock_irq(&pprt_lock); | 829 | spin_unlock_irq(&pprt_lock); |
| 831 | } | 830 | } |
| 832 | 831 | ||
| @@ -837,8 +836,7 @@ static void lcd_write_data_s(int data) · 4 unmodified lines | |||
| 837 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ | 836 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ |
| 838 | lcd_send_serial(data & 0x0F); | 837 | lcd_send_serial(data & 0x0F); |
| 839 | lcd_send_serial((data >> 4) & 0x0F); | 838 | lcd_send_serial((data >> 4) & 0x0F); |
| 840 | /* the shortest data takes at least 40 us */ | 839 | udelay(40); /* the shortest data takes at least 40 us */ |
| 841 | usleep_range(40, 100); | ||
| 842 | spin_unlock_irq(&pprt_lock); | 840 | spin_unlock_irq(&pprt_lock); |
| 843 | } | 841 | } |
| 844 | 842 | ||
| @@ -848,20 +846,19 @@ static void lcd_write_cmd_p8(int cmd) · 3 unmodified lines | |||
| 848 | spin_lock_irq(&pprt_lock); | 846 | spin_lock_irq(&pprt_lock); |
| 849 | /* present the data to the data port */ | 847 | /* present the data to the data port */ |
| 850 | w_dtr(pprt, cmd); | 848 | w_dtr(pprt, cmd); |
| 851 | /* maintain the data during 20 us before the strobe */ | 849 | udelay(20); /* maintain the data during 20 us before the strobe */ |
| 852 | usleep_range(20, 100); | ||
| 853 | 850 | ||
| 854 | bits.e = BIT_SET; | 851 | bits.e = BIT_SET; |
| 855 | bits.rs = BIT_CLR; | 852 | bits.rs = BIT_CLR; |
| 856 | bits.rw = BIT_CLR; | 853 | bits.rw = BIT_CLR; |
| 857 | set_ctrl_bits(); | 854 | set_ctrl_bits(); |
| 858 | 855 | ||
| 859 | usleep_range(40, 100); /* maintain the strobe during 40 us */ | 856 | udelay(40); /* maintain the strobe during 40 us */ |
| 860 | 857 | ||
| 861 | bits.e = BIT_CLR; | 858 | bits.e = BIT_CLR; |
| 862 | set_ctrl_bits(); | 859 | set_ctrl_bits(); |
| 863 | 860 | ||
| 864 | usleep_range(120, 500); /* the shortest command takes at least 120 us */ | 861 | udelay(120); /* the shortest command takes at least 120 us */ |
| 865 | spin_unlock_irq(&pprt_lock); | 862 | spin_unlock_irq(&pprt_lock); |
| 866 | } | 863 | } |
| 867 | 864 | ||
| @@ -871,20 +868,19 @@ static void lcd_write_data_p8(int data) · 3 unmodified lines | |||
| 871 | spin_lock_irq(&pprt_lock); | 868 | spin_lock_irq(&pprt_lock); |
| 872 | /* present the data to the data port */ | 869 | /* present the data to the data port */ |
| 873 | w_dtr(pprt, data); | 870 | w_dtr(pprt, data); |
| 874 | /* maintain the data during 20 us before the strobe */ | 871 | udelay(20); /* maintain the data during 20 us before the strobe */ |
| 875 | usleep_range(20, 100); | ||
| 876 | 872 | ||
| 877 | bits.e = BIT_SET; | 873 | bits.e = BIT_SET; |
| 878 | bits.rs = BIT_SET; | 874 | bits.rs = BIT_SET; |
| 879 | bits.rw = BIT_CLR; | 875 | bits.rw = BIT_CLR; |
| 880 | set_ctrl_bits(); | 876 | set_ctrl_bits(); |
| 881 | 877 | ||
| 882 | usleep_range(40, 100); /* maintain the strobe during 40 us */ | 878 | udelay(40); /* maintain the strobe during 40 us */ |
| 883 | 879 | ||
| 884 | bits.e = BIT_CLR; | 880 | bits.e = BIT_CLR; |
| 885 | set_ctrl_bits(); | 881 | set_ctrl_bits(); |
| 886 | 882 | ||
| 887 | usleep_range(45, 100); /* the shortest data takes at least 45 us */ | 883 | udelay(45); /* the shortest data takes at least 45 us */ |
| 888 | spin_unlock_irq(&pprt_lock); | 884 | spin_unlock_irq(&pprt_lock); |
| 889 | } | 885 | } |
| 890 | 886 | ||
| @@ -894,7 +890,7 @@ static void lcd_write_cmd_tilcd(int cmd) · 3 unmodified lines | |||
| 894 | spin_lock_irq(&pprt_lock); | 890 | spin_lock_irq(&pprt_lock); |
| 895 | /* present the data to the control port */ | 891 | /* present the data to the control port */ |
| 896 | w_ctr(pprt, cmd); | 892 | w_ctr(pprt, cmd); |
| 897 | usleep_range(60, 120); | 893 | udelay(60); |
| 898 | spin_unlock_irq(&pprt_lock); | 894 | spin_unlock_irq(&pprt_lock); |
| 899 | } | 895 | } |
| 900 | 896 | ||
| @@ -904,7 +900,7 @@ static void lcd_write_data_tilcd(int data) · 3 unmodified lines | |||
| 904 | spin_lock_irq(&pprt_lock); | 900 | spin_lock_irq(&pprt_lock); |
| 905 | /* present the data to the data port */ | 901 | /* present the data to the data port */ |
| 906 | w_dtr(pprt, data); | 902 | w_dtr(pprt, data); |
| 907 | usleep_range(60, 120); | 903 | udelay(60); |
| 908 | spin_unlock_irq(&pprt_lock); | 904 | spin_unlock_irq(&pprt_lock); |
| 909 | } | 905 | } |
| 910 | 906 | ||
| @@ -947,7 +943,7 @@ static void lcd_clear_fast_s(void) · 36 unmodified lines | |||
| 947 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ | 943 | lcd_send_serial(0x5F); /* R/W=W, RS=1 */ |
| 948 | lcd_send_serial(' ' & 0x0F); | 944 | lcd_send_serial(' ' & 0x0F); |
| 949 | lcd_send_serial((' ' >> 4) & 0x0F); | 945 | lcd_send_serial((' ' >> 4) & 0x0F); |
| 950 | usleep_range(40, 100); /* the shortest data takes at least 40 us */ | 946 | udelay(40); /* the shortest data takes at least 40 us */ |
| 951 | } | 947 | } |
| 952 | spin_unlock_irq(&pprt_lock); | 948 | spin_unlock_irq(&pprt_lock); |
| 953 | 949 | ||
| @@ -971,7 +967,7 @@ static void lcd_clear_fast_p8(void) · 17 unmodified lines | |||
| 971 | w_dtr(pprt, ' '); | 967 | w_dtr(pprt, ' '); |
| 972 | 968 | ||
| 973 | /* maintain the data during 20 us before the strobe */ | 969 | /* maintain the data during 20 us before the strobe */ |
| 974 | usleep_range(20, 100); | 970 | udelay(20); |
| 975 | 971 | ||
| 976 | bits.e = BIT_SET; | 972 | bits.e = BIT_SET; |
| 977 | bits.rs = BIT_SET; | 973 | bits.rs = BIT_SET; |
| @@ -979,13 +975,13 @@ static void lcd_clear_fast_p8(void) · 1 unmodified line | |||
| 979 | set_ctrl_bits(); | 975 | set_ctrl_bits(); |
| 980 | 976 | ||
| 981 | /* maintain the strobe during 40 us */ | 977 | /* maintain the strobe during 40 us */ |
| 982 | usleep_range(40, 100); | 978 | udelay(40); |
| 983 | 979 | ||
| 984 | bits.e = BIT_CLR; | 980 | bits.e = BIT_CLR; |
| 985 | set_ctrl_bits(); | 981 | set_ctrl_bits(); |
| 986 | 982 | ||
| 987 | /* the shortest data takes at least 45 us */ | 983 | /* the shortest data takes at least 45 us */ |
| 988 | usleep_range(45, 100); | 984 | udelay(45); |
| 989 | } | 985 | } |
| 990 | spin_unlock_irq(&pprt_lock); | 986 | spin_unlock_irq(&pprt_lock); |
| 991 | 987 | ||
| @@ -1007,7 +1003,7 @@ static void lcd_clear_fast_tilcd(void) · 15 unmodified lines | |||
| 1007 | for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) { | 1003 | for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) { |
| 1008 | /* present the data to the data port */ | 1004 | /* present the data to the data port */ |
| 1009 | w_dtr(pprt, ' '); | 1005 | w_dtr(pprt, ' '); |
| 1010 | usleep_range(60, 120); | 1006 | udelay(60); |
| 1011 | } | 1007 | } |
| 1012 | 1008 | ||
| 1013 | spin_unlock_irq(&pprt_lock); | 1009 | spin_unlock_irq(&pprt_lock); |
| @@ -264,8 +264,9 @@ static struct notifier_block vt_notifier_block = { · 263 unmodified lines | |||
| 264 | .notifier_call = vt_notifier_call, | 264 | .notifier_call = vt_notifier_call, |
| 265 | }; | 265 | }; |
| 266 | 266 | ||
| 267 | static unsigned char get_attributes(u16 *pos) | 267 | static unsigned char get_attributes(struct vc_data *vc, u16 *pos) |
| 268 | { | 268 | { |
| 269 | pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1); | ||
| 269 | return (u_char) (scr_readw(pos) >> 8); | 270 | return (u_char) (scr_readw(pos) >> 8); |
| 270 | } | 271 | } |
| 271 | 272 | ||
| @@ -275,7 +276,7 @@ static void speakup_date(struct vc_data *vc) · 3 unmodified lines | |||
| 275 | spk_y = spk_cy = vc->vc_y; | 276 | spk_y = spk_cy = vc->vc_y; |
| 276 | spk_pos = spk_cp = vc->vc_pos; | 277 | spk_pos = spk_cp = vc->vc_pos; |
| 277 | spk_old_attr = spk_attr; | 278 | spk_old_attr = spk_attr; |
| 278 | spk_attr = get_attributes((u_short *) spk_pos); | 279 | spk_attr = get_attributes(vc, (u_short *)spk_pos); |
| 279 | } | 280 | } |
| 280 | 281 | ||
| 281 | static void bleep(u_short val) | 282 | static void bleep(u_short val) |
| @@ -469,8 +470,12 @@ static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs) · 187 unmodified lines | |||
| 469 | u16 ch = ' '; | 470 | u16 ch = ' '; |
| 470 | 471 | ||
| 471 | if (vc && pos) { | 472 | if (vc && pos) { |
| 472 | u16 w = scr_readw(pos); | 473 | u16 w; |
| 473 | u16 c = w & 0xff; | 474 | u16 c; |
| 475 | |||
| 476 | pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1); | ||
| 477 | w = scr_readw(pos); | ||
| 478 | c = w & 0xff; | ||
| 474 | 479 | ||
| 475 | if (w & vc->vc_hi_font_mask) | 480 | if (w & vc->vc_hi_font_mask) |
| 476 | c |= 0x100; | 481 | c |= 0x100; |
| @@ -746,7 +751,7 @@ static int get_line(struct vc_data *vc) · 269 unmodified lines | |||
| 746 | u_char tmp2; | 751 | u_char tmp2; |
| 747 | 752 | ||
| 748 | spk_old_attr = spk_attr; | 753 | spk_old_attr = spk_attr; |
| 749 | spk_attr = get_attributes((u_short *) spk_pos); | 754 | spk_attr = get_attributes(vc, (u_short *)spk_pos); |
| 750 | for (i = 0; i < vc->vc_cols; i++) { | 755 | for (i = 0; i < vc->vc_cols; i++) { |
| 751 | buf[i] = (u_char) get_char(vc, (u_short *) tmp, &tmp2); | 756 | buf[i] = (u_char) get_char(vc, (u_short *) tmp, &tmp2); |
| 752 | tmp += 2; | 757 | tmp += 2; |
| @@ -811,7 +816,7 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to, · 58 unmodified lines | |||
| 811 | u_short saved_punc_mask = spk_punc_mask; | 816 | u_short saved_punc_mask = spk_punc_mask; |
| 812 | 817 | ||
| 813 | spk_old_attr = spk_attr; | 818 | spk_old_attr = spk_attr; |
| 814 | spk_attr = get_attributes((u_short *) from); | 819 | spk_attr = get_attributes(vc, (u_short *)from); |
| 815 | while (from < to) { | 820 | while (from < to) { |
| 816 | buf[i++] = (char)get_char(vc, (u_short *) from, &tmp); | 821 | buf[i++] = (char)get_char(vc, (u_short *) from, &tmp); |
| 817 | from += 2; | 822 | from += 2; |
| @@ -886,7 +891,7 @@ static int get_sentence_buf(struct vc_data *vc, int read_punc) · 68 unmodified lines | |||
| 886 | sentmarks[bn][0] = &sentbuf[bn][0]; | 891 | sentmarks[bn][0] = &sentbuf[bn][0]; |
| 887 | i = 0; | 892 | i = 0; |
| 888 | spk_old_attr = spk_attr; | 893 | spk_old_attr = spk_attr; |
| 889 | spk_attr = get_attributes((u_short *) start); | 894 | spk_attr = get_attributes(vc, (u_short *)start); |
| 890 | 895 | ||
| 891 | while (start < end) { | 896 | while (start < end) { |
| 892 | sentbuf[bn][i] = (char)get_char(vc, (u_short *) start, &tmp); | 897 | sentbuf[bn][i] = (char)get_char(vc, (u_short *) start, &tmp); |
| @@ -1585,7 +1590,7 @@ static int count_highlight_color(struct vc_data *vc) · 692 unmodified lines | |||
| 1585 | u16 *ptr; | 1590 | u16 *ptr; |
| 1586 | 1591 | ||
| 1587 | for (ptr = start; ptr < end; ptr++) { | 1592 | for (ptr = start; ptr < end; ptr++) { |
| 1588 | ch = get_attributes(ptr); | 1593 | ch = get_attributes(vc, ptr); |
| 1589 | bg = (ch & 0x70) >> 4; | 1594 | bg = (ch & 0x70) >> 4; |
| 1590 | speakup_console[vc_num]->ht.bgcount[bg]++; | 1595 | speakup_console[vc_num]->ht.bgcount[bg]++; |
| 1591 | } | 1596 | } |
| @@ -142,7 +142,9 @@ static void __speakup_paste_selection(struct work_struct *work) · 141 unmodified lines | |||
| 142 | struct tty_ldisc *ld; | 142 | struct tty_ldisc *ld; |
| 143 | DECLARE_WAITQUEUE(wait, current); | 143 | DECLARE_WAITQUEUE(wait, current); |
| 144 | 144 | ||
| 145 | ld = tty_ldisc_ref_wait(tty); | 145 | ld = tty_ldisc_ref(tty); |
| 146 | if (!ld) | ||
| 147 | goto tty_unref; | ||
| 146 | tty_buffer_lock_exclusive(&vc->port); | 148 | tty_buffer_lock_exclusive(&vc->port); |
| 147 | 149 | ||
| 148 | add_wait_queue(&vc->paste_wait, &wait); | 150 | add_wait_queue(&vc->paste_wait, &wait); |
| @@ -162,6 +164,7 @@ static void __speakup_paste_selection(struct work_struct *work) · 13 unmodified lines | |||
| 162 | 164 | ||
| 163 | tty_buffer_unlock_exclusive(&vc->port); | 165 | tty_buffer_unlock_exclusive(&vc->port); |
| 164 | tty_ldisc_deref(ld); | 166 | tty_ldisc_deref(ld); |
| 167 | tty_unref: | ||
| 165 | tty_kref_put(tty); | 168 | tty_kref_put(tty); |
| 166 | } | 169 | } |
| 167 | 170 | ||
| @@ -6,6 +6,11 @@ · 5 unmodified lines | |||
| 6 | #include "spk_priv.h" | 6 | #include "spk_priv.h" |
| 7 | #include "serialio.h" | 7 | #include "serialio.h" |
| 8 | 8 | ||
| 9 | #include <linux/serial_core.h> | ||
| 10 | /* WARNING: Do not change this to <linux/serial.h> without testing that | ||
| 11 | * SERIAL_PORT_DFNS does get defined to the appropriate value. */ | ||
| 12 | #include <asm/serial.h> | ||
| 13 | |||
| 9 | #ifndef SERIAL_PORT_DFNS | 14 | #ifndef SERIAL_PORT_DFNS |
| 10 | #define SERIAL_PORT_DFNS | 15 | #define SERIAL_PORT_DFNS |
| 11 | #endif | 16 | #endif |
| @@ -23,9 +28,15 @@ const struct old_serial_port *spk_serial_init(int index) · 11 unmodified lines | |||
| 23 | int baud = 9600, quot = 0; | 28 | int baud = 9600, quot = 0; |
| 24 | unsigned int cval = 0; | 29 | unsigned int cval = 0; |
| 25 | int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8; | 30 | int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8; |
| 26 | const struct old_serial_port *ser = rs_table + index; | 31 | const struct old_serial_port *ser; |
| 27 | int err; | 32 | int err; |
| 28 | 33 | ||
| 34 | if (index >= ARRAY_SIZE(rs_table)) { | ||
| 35 | pr_info("no port info for ttyS%d\n", index); | ||
| 36 | return NULL; | ||
| 37 | } | ||
| 38 | ser = rs_table + index; | ||
| 39 | |||
| 29 | /* Divisor, bytesize and parity */ | 40 | /* Divisor, bytesize and parity */ |
| 30 | quot = ser->baud_base / baud; | 41 | quot = ser->baud_base / baud; |
| 31 | cval = cflag & (CSIZE | CSTOPB); | 42 | cval = cflag & (CSIZE | CSTOPB); |
| @@ -269,16 +269,13 @@ static void n_tty_check_throttle(struct tty_struct *tty) · 268 unmodified lines | |||
| 269 | 269 | ||
| 270 | static void n_tty_check_unthrottle(struct tty_struct *tty) | 270 | static void n_tty_check_unthrottle(struct tty_struct *tty) |
| 271 | { | 271 | { |
| 272 | if (tty->driver->type == TTY_DRIVER_TYPE_PTY && | 272 | if (tty->driver->type == TTY_DRIVER_TYPE_PTY) { |
| 273 | tty->link->ldisc->ops->write_wakeup == n_tty_write_wakeup) { | ||
| 274 | if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) | 273 | if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE) |
| 275 | return; | 274 | return; |
| 276 | if (!tty->count) | 275 | if (!tty->count) |
| 277 | return; | 276 | return; |
| 278 | n_tty_kick_worker(tty); | 277 | n_tty_kick_worker(tty); |
| 279 | n_tty_write_wakeup(tty->link); | 278 | tty_wakeup(tty->link); |
| 280 | if (waitqueue_active(&tty->link->write_wait)) | ||
| 281 | wake_up_interruptible_poll(&tty->link->write_wait, POLLOUT); | ||
| 282 | return; | 279 | return; |
| 283 | } | 280 | } |
| 284 | 281 | ||
| @@ -1379,6 +1379,9 @@ ce4100_serial_setup(struct serial_private *priv, · 1378 unmodified lines | |||
| 1379 | #define PCI_DEVICE_ID_INTEL_BSW_UART1 0x228a | 1379 | #define PCI_DEVICE_ID_INTEL_BSW_UART1 0x228a |
| 1380 | #define PCI_DEVICE_ID_INTEL_BSW_UART2 0x228c | 1380 | #define PCI_DEVICE_ID_INTEL_BSW_UART2 0x228c |
| 1381 | 1381 | ||
| 1382 | #define PCI_DEVICE_ID_INTEL_BDW_UART1 0x9ce3 | ||
| 1383 | #define PCI_DEVICE_ID_INTEL_BDW_UART2 0x9ce4 | ||
| 1384 | |||
| 1382 | #define BYT_PRV_CLK 0x800 | 1385 | #define BYT_PRV_CLK 0x800 |
| 1383 | #define BYT_PRV_CLK_EN (1 << 0) | 1386 | #define BYT_PRV_CLK_EN (1 << 0) |
| 1384 | #define BYT_PRV_CLK_M_VAL_SHIFT 1 | 1387 | #define BYT_PRV_CLK_M_VAL_SHIFT 1 |
| @@ -1461,11 +1464,13 @@ byt_serial_setup(struct serial_private *priv, · 76 unmodified lines | |||
| 1461 | switch (pdev->device) { | 1464 | switch (pdev->device) { |
| 1462 | case PCI_DEVICE_ID_INTEL_BYT_UART1: | 1465 | case PCI_DEVICE_ID_INTEL_BYT_UART1: |
| 1463 | case PCI_DEVICE_ID_INTEL_BSW_UART1: | 1466 | case PCI_DEVICE_ID_INTEL_BSW_UART1: |
| 1467 | case PCI_DEVICE_ID_INTEL_BDW_UART1: | ||
| 1464 | rx_param->src_id = 3; | 1468 | rx_param->src_id = 3; |
| 1465 | tx_param->dst_id = 2; | 1469 | tx_param->dst_id = 2; |
| 1466 | break; | 1470 | break; |
| 1467 | case PCI_DEVICE_ID_INTEL_BYT_UART2: | 1471 | case PCI_DEVICE_ID_INTEL_BYT_UART2: |
| 1468 | case PCI_DEVICE_ID_INTEL_BSW_UART2: | 1472 | case PCI_DEVICE_ID_INTEL_BSW_UART2: |
| 1473 | case PCI_DEVICE_ID_INTEL_BDW_UART2: | ||
| 1469 | rx_param->src_id = 5; | 1474 | rx_param->src_id = 5; |
| 1470 | tx_param->dst_id = 4; | 1475 | tx_param->dst_id = 4; |
| 1471 | break; | 1476 | break; |
| @@ -2062,6 +2067,20 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { · 590 unmodified lines | |||
| 2062 | .subdevice = PCI_ANY_ID, | 2067 | .subdevice = PCI_ANY_ID, |
| 2063 | .setup = byt_serial_setup, | 2068 | .setup = byt_serial_setup, |
| 2064 | }, | 2069 | }, |
| 2070 | { | ||
| 2071 | .vendor = PCI_VENDOR_ID_INTEL, | ||
| 2072 | .device = PCI_DEVICE_ID_INTEL_BDW_UART1, | ||
| 2073 | .subvendor = PCI_ANY_ID, | ||
| 2074 | .subdevice = PCI_ANY_ID, | ||
| 2075 | .setup = byt_serial_setup, | ||
| 2076 | }, | ||
| 2077 | { | ||
| 2078 | .vendor = PCI_VENDOR_ID_INTEL, | ||
| 2079 | .device = PCI_DEVICE_ID_INTEL_BDW_UART2, | ||
| 2080 | .subvendor = PCI_ANY_ID, | ||
| 2081 | .subdevice = PCI_ANY_ID, | ||
| 2082 | .setup = byt_serial_setup, | ||
| 2083 | }, | ||
| 2065 | /* | 2084 | /* |
| 2066 | * ITE | 2085 | * ITE |
| 2067 | */ | 2086 | */ |
| @@ -5506,6 +5525,16 @@ static struct pci_device_id serial_pci_tbl[] = { · 3438 unmodified lines | |||
| 5506 | PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, | 5525 | PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, |
| 5507 | pbn_byt }, | 5526 | pbn_byt }, |
| 5508 | 5527 | ||
| 5528 | /* Intel Broadwell */ | ||
| 5529 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BDW_UART1, | ||
| 5530 | PCI_ANY_ID, PCI_ANY_ID, | ||
| 5531 | PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, | ||
| 5532 | pbn_byt }, | ||
| 5533 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BDW_UART2, | ||
| 5534 | PCI_ANY_ID, PCI_ANY_ID, | ||
| 5535 | PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, | ||
| 5536 | pbn_byt }, | ||
| 5537 | |||
| 5509 | /* | 5538 | /* |
| 5510 | * Intel Quark x1000 | 5539 | * Intel Quark x1000 |
| 5511 | */ | 5540 | */ |
| @@ -1463,13 +1463,13 @@ static int tty_reopen(struct tty_struct *tty) · 1462 unmodified lines | |||
| 1463 | { | 1463 | { |
| 1464 | struct tty_driver *driver = tty->driver; | 1464 | struct tty_driver *driver = tty->driver; |
| 1465 | 1465 | ||
| 1466 | if (!tty->count) | ||
| 1467 | return -EIO; | ||
| 1468 | |||
| 1469 | if (driver->type == TTY_DRIVER_TYPE_PTY && | 1466 | if (driver->type == TTY_DRIVER_TYPE_PTY && |
| 1470 | driver->subtype == PTY_TYPE_MASTER) | 1467 | driver->subtype == PTY_TYPE_MASTER) |
| 1471 | return -EIO; | 1468 | return -EIO; |
| 1472 | 1469 | ||
| 1470 | if (!tty->count) | ||
| 1471 | return -EAGAIN; | ||
| 1472 | |||
| 1473 | if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) | 1473 | if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN)) |
| 1474 | return -EBUSY; | 1474 | return -EBUSY; |
| 1475 | 1475 | ||
| @@ -2065,7 +2065,12 @@ retry_open: · 589 unmodified lines | |||
| 2065 | 2065 | ||
| 2066 | if (tty) { | 2066 | if (tty) { |
| 2067 | mutex_unlock(&tty_mutex); | 2067 | mutex_unlock(&tty_mutex); |
| 2068 | tty_lock(tty); | 2068 | retval = tty_lock_interruptible(tty); |
| 2069 | if (retval) { | ||
| 2070 | if (retval == -EINTR) | ||
| 2071 | retval = -ERESTARTSYS; | ||
| 2072 | goto err_unref; | ||
| 2073 | } | ||
| 2069 | /* safe to drop the kref from tty_driver_lookup_tty() */ | 2074 | /* safe to drop the kref from tty_driver_lookup_tty() */ |
| 2070 | tty_kref_put(tty); | 2075 | tty_kref_put(tty); |
| 2071 | retval = tty_reopen(tty); | 2076 | retval = tty_reopen(tty); |
| @@ -2083,7 +2088,11 @@ retry_open: · 11 unmodified lines | |||
| 2083 | 2088 | ||
| 2084 | if (IS_ERR(tty)) { | 2089 | if (IS_ERR(tty)) { |
| 2085 | retval = PTR_ERR(tty); | 2090 | retval = PTR_ERR(tty); |
| 2086 | goto err_file; | 2091 | if (retval != -EAGAIN || signal_pending(current)) |
| 2092 | goto err_file; | ||
| 2093 | tty_free_file(filp); | ||
| 2094 | schedule(); | ||
| 2095 | goto retry_open; | ||
| 2087 | } | 2096 | } |
| 2088 | 2097 | ||
| 2089 | tty_add_file(tty, filp); | 2098 | tty_add_file(tty, filp); |
| @@ -2152,6 +2161,7 @@ retry_open: · 62 unmodified lines | |||
| 2152 | return 0; | 2161 | return 0; |
| 2153 | err_unlock: | 2162 | err_unlock: |
| 2154 | mutex_unlock(&tty_mutex); | 2163 | mutex_unlock(&tty_mutex); |
| 2164 | err_unref: | ||
| 2155 | /* after locks to avoid deadlock */ | 2165 | /* after locks to avoid deadlock */ |
| 2156 | if (!IS_ERR_OR_NULL(driver)) | 2166 | if (!IS_ERR_OR_NULL(driver)) |
| 2157 | tty_driver_kref_put(driver); | 2167 | tty_driver_kref_put(driver); |
| @@ -2648,6 +2658,28 @@ static int tiocsetd(struct tty_struct *tty, int __user *p) · 490 unmodified lines | |||
| 2648 | return ret; | 2658 | return ret; |
| 2649 | } | 2659 | } |
| 2650 | 2660 | ||
| 2661 | /** | ||
| 2662 | * tiocgetd - get line discipline | ||
| 2663 | * @tty: tty device | ||
| 2664 | * @p: pointer to user data | ||
| 2665 | * | ||
| 2666 | * Retrieves the line discipline id directly from the ldisc. | ||
| 2667 | * | ||
| 2668 | * Locking: waits for ldisc reference (in case the line discipline | ||
| 2669 | * is changing or the tty is being hungup) | ||
| 2670 | */ | ||
| 2671 | |||
| 2672 | static int tiocgetd(struct tty_struct *tty, int __user *p) | ||
| 2673 | { | ||
| 2674 | struct tty_ldisc *ld; | ||
| 2675 | int ret; | ||
| 2676 | |||
| 2677 | ld = tty_ldisc_ref_wait(tty); | ||
| 2678 | ret = put_user(ld->ops->num, p); | ||
| 2679 | tty_ldisc_deref(ld); | ||
| 2680 | return ret; | ||
| 2681 | } | ||
| 2682 | |||
| 2651 | /** | 2683 | /** |
| 2652 | * send_break - performed time break | 2684 | * send_break - performed time break |
| 2653 | * @tty: device to break on | 2685 | * @tty: device to break on |
| @@ -2874,7 +2906,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 220 unmodified lines | |||
| 2874 | case TIOCGSID: | 2906 | case TIOCGSID: |
| 2875 | return tiocgsid(tty, real_tty, p); | 2907 | return tiocgsid(tty, real_tty, p); |
| 2876 | case TIOCGETD: | 2908 | case TIOCGETD: |
| 2877 | return put_user(tty->ldisc->ops->num, (int __user *)p); | 2909 | return tiocgetd(tty, p); |
| 2878 | case TIOCSETD: | 2910 | case TIOCSETD: |
| 2879 | return tiocsetd(tty, p); | 2911 | return tiocsetd(tty, p); |
| 2880 | case TIOCVHANGUP: | 2912 | case TIOCVHANGUP: |
| @@ -19,6 +19,14 @@ void __lockfunc tty_lock(struct tty_struct *tty) · 18 unmodified lines | |||
| 19 | } | 19 | } |
| 20 | EXPORT_SYMBOL(tty_lock); | 20 | EXPORT_SYMBOL(tty_lock); |
| 21 | 21 | ||
| 22 | int tty_lock_interruptible(struct tty_struct *tty) | ||
| 23 | { | ||
| 24 | if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty)) | ||
| 25 | return -EIO; | ||
| 26 | tty_kref_get(tty); | ||
| 27 | return mutex_lock_interruptible(&tty->legacy_mutex); | ||
| 28 | } | ||
| 29 | |||
| 22 | void __lockfunc tty_unlock(struct tty_struct *tty) | 30 | void __lockfunc tty_unlock(struct tty_struct *tty) |
| 23 | { | 31 | { |
| 24 | if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty)) | 32 | if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty)) |
| @@ -4250,6 +4250,7 @@ unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) · 4249 unmodified lines | |||
| 4250 | { | 4250 | { |
| 4251 | return screenpos(vc, 2 * w_offset, viewed); | 4251 | return screenpos(vc, 2 * w_offset, viewed); |
| 4252 | } | 4252 | } |
| 4253 | EXPORT_SYMBOL_GPL(screen_pos); | ||
| 4253 | 4254 | ||
| 4254 | void getconsxy(struct vc_data *vc, unsigned char *p) | 4255 | void getconsxy(struct vc_data *vc, unsigned char *p) |
| 4255 | { | 4256 | { |
| @@ -428,7 +428,8 @@ static void acm_read_bulk_callback(struct urb *urb) · 427 unmodified lines | |||
| 428 | set_bit(rb->index, &acm->read_urbs_free); | 428 | set_bit(rb->index, &acm->read_urbs_free); |
| 429 | dev_dbg(&acm->data->dev, "%s - non-zero urb status: %d\n", | 429 | dev_dbg(&acm->data->dev, "%s - non-zero urb status: %d\n", |
| 430 | __func__, status); | 430 | __func__, status); |
| 431 | return; | 431 | if ((status != -ENOENT) || (urb->actual_length == 0)) |
| 432 | return; | ||
| 432 | } | 433 | } |
| 433 | 434 | ||
| 434 | usb_mark_last_busy(acm->dev); | 435 | usb_mark_last_busy(acm->dev); |
| @@ -1404,6 +1405,8 @@ made_compressed_probe: · 969 unmodified lines | |||
| 1404 | usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), | 1405 | usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), |
| 1405 | NULL, acm->writesize, acm_write_bulk, snd); | 1406 | NULL, acm->writesize, acm_write_bulk, snd); |
| 1406 | snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 1407 | snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 1408 | if (quirks & SEND_ZERO_PACKET) | ||
| 1409 | snd->urb->transfer_flags |= URB_ZERO_PACKET; | ||
| 1407 | snd->instance = acm; | 1410 | snd->instance = acm; |
| 1408 | } | 1411 | } |
| 1409 | 1412 | ||
| @@ -1838,6 +1841,11 @@ static const struct usb_device_id acm_ids[] = { · 428 unmodified lines | |||
| 1838 | }, | 1841 | }, |
| 1839 | #endif | 1842 | #endif |
| 1840 | 1843 | ||
| 1844 | /*Samsung phone in firmware update mode */ | ||
| 1845 | { USB_DEVICE(0x04e8, 0x685d), | ||
| 1846 | .driver_info = IGNORE_DEVICE, | ||
| 1847 | }, | ||
| 1848 | |||
| 1841 | /* Exclude Infineon Flash Loader utility */ | 1849 | /* Exclude Infineon Flash Loader utility */ |
| 1842 | { USB_DEVICE(0x058b, 0x0041), | 1850 | { USB_DEVICE(0x058b, 0x0041), |
| 1843 | .driver_info = IGNORE_DEVICE, | 1851 | .driver_info = IGNORE_DEVICE, |
| @@ -1861,6 +1869,10 @@ static const struct usb_device_id acm_ids[] = { · 17 unmodified lines | |||
| 1861 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, | 1869 | { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, |
| 1862 | USB_CDC_ACM_PROTO_AT_CDMA) }, | 1870 | USB_CDC_ACM_PROTO_AT_CDMA) }, |
| 1863 | 1871 | ||
| 1872 | { USB_DEVICE(0x1519, 0x0452), /* Intel 7260 modem */ | ||
| 1873 | .driver_info = SEND_ZERO_PACKET, | ||
| 1874 | }, | ||
| 1875 | |||
| 1864 | { } | 1876 | { } |
| 1865 | }; | 1877 | }; |
| 1866 | 1878 | ||
| @@ -134,3 +134,4 @@ struct acm { · 133 unmodified lines | |||
| 134 | #define IGNORE_DEVICE BIT(5) | 134 | #define IGNORE_DEVICE BIT(5) |
| 135 | #define QUIRK_CONTROL_LINE_STATE BIT(6) | 135 | #define QUIRK_CONTROL_LINE_STATE BIT(6) |
| 136 | #define CLEAR_HALT_CONDITIONS BIT(7) | 136 | #define CLEAR_HALT_CONDITIONS BIT(7) |
| 137 | #define SEND_ZERO_PACKET BIT(8) | ||
| @@ -5457,7 +5457,6 @@ static int usb_reset_and_verify_device(struct usb_device *udev) · 5456 unmodified lines | |||
| 5457 | } | 5457 | } |
| 5458 | 5458 | ||
| 5459 | bos = udev->bos; | 5459 | bos = udev->bos; |
| 5460 | udev->bos = NULL; | ||
| 5461 | 5460 | ||
| 5462 | for (i = 0; i < SET_CONFIG_TRIES; ++i) { | 5461 | for (i = 0; i < SET_CONFIG_TRIES; ++i) { |
| 5463 | 5462 | ||
| @@ -5550,8 +5549,11 @@ done: · 86 unmodified lines | |||
| 5550 | usb_set_usb2_hardware_lpm(udev, 1); | 5549 | usb_set_usb2_hardware_lpm(udev, 1); |
| 5551 | usb_unlocked_enable_lpm(udev); | 5550 | usb_unlocked_enable_lpm(udev); |
| 5552 | usb_enable_ltm(udev); | 5551 | usb_enable_ltm(udev); |
| 5553 | usb_release_bos_descriptor(udev); | 5552 | /* release the new BOS descriptor allocated by hub_port_init() */ |
| 5554 | udev->bos = bos; | 5553 | if (udev->bos != bos) { |
| 5554 | usb_release_bos_descriptor(udev); | ||
| 5555 | udev->bos = bos; | ||
| 5556 | } | ||
| 5555 | return 0; | 5557 | return 0; |
| 5556 | 5558 | ||
| 5557 | re_enumerate: | 5559 | re_enumerate: |
| @@ -99,6 +99,7 @@ static const struct usb_device_id id_table[] = { · 98 unmodified lines | |||
| 99 | { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ | 99 | { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ |
| 100 | { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */ | 100 | { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */ |
| 101 | { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ | 101 | { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ |
| 102 | { USB_DEVICE(0x10C4, 0x81D7) }, /* IAI Corp. RCB-CV-USB USB to RS485 Adaptor */ | ||
| 102 | { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ | 103 | { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ |
| 103 | { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ | 104 | { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ |
| 104 | { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */ | 105 | { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */ |
| @@ -824,6 +824,7 @@ static const struct usb_device_id id_table_combined[] = { · 823 unmodified lines | |||
| 824 | { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID), | 824 | { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID), |
| 825 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 825 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 826 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, | 826 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, |
| 827 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_SCU18) }, | ||
| 827 | { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, | 828 | { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, |
| 828 | 829 | ||
| 829 | /* Papouch devices based on FTDI chip */ | 830 | /* Papouch devices based on FTDI chip */ |
| @@ -615,6 +615,7 @@ · 614 unmodified lines | |||
| 615 | */ | 615 | */ |
| 616 | #define RATOC_VENDOR_ID 0x0584 | 616 | #define RATOC_VENDOR_ID 0x0584 |
| 617 | #define RATOC_PRODUCT_ID_USB60F 0xb020 | 617 | #define RATOC_PRODUCT_ID_USB60F 0xb020 |
| 618 | #define RATOC_PRODUCT_ID_SCU18 0xb03a | ||
| 618 | 619 | ||
| 619 | /* | 620 | /* |
| 620 | * Infineon Technologies | 621 | * Infineon Technologies |
| @@ -368,6 +368,16 @@ static int mxu1_port_probe(struct usb_serial_port *port) · 367 unmodified lines | |||
| 368 | return 0; | 368 | return 0; |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | static int mxu1_port_remove(struct usb_serial_port *port) | ||
| 372 | { | ||
| 373 | struct mxu1_port *mxport; | ||
| 374 | |||
| 375 | mxport = usb_get_serial_port_data(port); | ||
| 376 | kfree(mxport); | ||
| 377 | |||
| 378 | return 0; | ||
| 379 | } | ||
| 380 | |||
| 371 | static int mxu1_startup(struct usb_serial *serial) | 381 | static int mxu1_startup(struct usb_serial *serial) |
| 372 | { | 382 | { |
| 373 | struct mxu1_device *mxdev; | 383 | struct mxu1_device *mxdev; |
| @@ -427,6 +437,14 @@ err_free_mxdev: · 53 unmodified lines | |||
| 427 | return err; | 437 | return err; |
| 428 | } | 438 | } |
| 429 | 439 | ||
| 440 | static void mxu1_release(struct usb_serial *serial) | ||
| 441 | { | ||
| 442 | struct mxu1_device *mxdev; | ||
| 443 | |||
| 444 | mxdev = usb_get_serial_data(serial); | ||
| 445 | kfree(mxdev); | ||
| 446 | } | ||
| 447 | |||
| 430 | static int mxu1_write_byte(struct usb_serial_port *port, u32 addr, | 448 | static int mxu1_write_byte(struct usb_serial_port *port, u32 addr, |
| 431 | u8 mask, u8 byte) | 449 | u8 mask, u8 byte) |
| 432 | { | 450 | { |
| @@ -957,7 +975,9 @@ static struct usb_serial_driver mxu11x0_device = { · 524 unmodified lines | |||
| 957 | .id_table = mxu1_idtable, | 975 | .id_table = mxu1_idtable, |
| 958 | .num_ports = 1, | 976 | .num_ports = 1, |
| 959 | .port_probe = mxu1_port_probe, | 977 | .port_probe = mxu1_port_probe, |
| 978 | .port_remove = mxu1_port_remove, | ||
| 960 | .attach = mxu1_startup, | 979 | .attach = mxu1_startup, |
| 980 | .release = mxu1_release, | ||
| 961 | .open = mxu1_open, | 981 | .open = mxu1_open, |
| 962 | .close = mxu1_close, | 982 | .close = mxu1_close, |
| 963 | .ioctl = mxu1_ioctl, | 983 | .ioctl = mxu1_ioctl, |
| @@ -268,6 +268,8 @@ static void option_instat_callback(struct urb *urb); · 267 unmodified lines | |||
| 268 | #define TELIT_PRODUCT_CC864_SINGLE 0x1006 | 268 | #define TELIT_PRODUCT_CC864_SINGLE 0x1006 |
| 269 | #define TELIT_PRODUCT_DE910_DUAL 0x1010 | 269 | #define TELIT_PRODUCT_DE910_DUAL 0x1010 |
| 270 | #define TELIT_PRODUCT_UE910_V2 0x1012 | 270 | #define TELIT_PRODUCT_UE910_V2 0x1012 |
| 271 | #define TELIT_PRODUCT_LE922_USBCFG0 0x1042 | ||
| 272 | #define TELIT_PRODUCT_LE922_USBCFG3 0x1043 | ||
| 271 | #define TELIT_PRODUCT_LE920 0x1200 | 273 | #define TELIT_PRODUCT_LE920 0x1200 |
| 272 | #define TELIT_PRODUCT_LE910 0x1201 | 274 | #define TELIT_PRODUCT_LE910 0x1201 |
| 273 | 275 | ||
| @@ -615,6 +617,16 @@ static const struct option_blacklist_info telit_le920_blacklist = { · 341 unmodified lines | |||
| 615 | .reserved = BIT(1) | BIT(5), | 617 | .reserved = BIT(1) | BIT(5), |
| 616 | }; | 618 | }; |
| 617 | 619 | ||
| 620 | static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = { | ||
| 621 | .sendsetup = BIT(2), | ||
| 622 | .reserved = BIT(0) | BIT(1) | BIT(3), | ||
| 623 | }; | ||
| 624 | |||
| 625 | static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = { | ||
| 626 | .sendsetup = BIT(0), | ||
| 627 | .reserved = BIT(1) | BIT(2) | BIT(3), | ||
| 628 | }; | ||
| 629 | |||
| 618 | static const struct usb_device_id option_ids[] = { | 630 | static const struct usb_device_id option_ids[] = { |
| 619 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, | 631 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, |
| 620 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, | 632 | { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, |
| @@ -1160,6 +1172,10 @@ static const struct usb_device_id option_ids[] = { · 539 unmodified lines | |||
| 1160 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, | 1172 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, |
| 1161 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, | 1173 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, |
| 1162 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, | 1174 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, |
| 1175 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0), | ||
| 1176 | .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, | ||
| 1177 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3), | ||
| 1178 | .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, | ||
| 1163 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), | 1179 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), |
| 1164 | .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, | 1180 | .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, |
| 1165 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), | 1181 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), |
| @@ -1679,7 +1695,7 @@ static const struct usb_device_id option_ids[] = { · 513 unmodified lines | |||
| 1679 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, | 1695 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, |
| 1680 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8), | 1696 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8), |
| 1681 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 1697 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 1682 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) }, | 1698 | { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) }, |
| 1683 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX), | 1699 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX), |
| 1684 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 1700 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 1685 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, | 1701 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, |
| @@ -544,6 +544,11 @@ static int treo_attach(struct usb_serial *serial) · 543 unmodified lines | |||
| 544 | (serial->num_interrupt_in == 0)) | 544 | (serial->num_interrupt_in == 0)) |
| 545 | return 0; | 545 | return 0; |
| 546 | 546 | ||
| 547 | if (serial->num_bulk_in < 2 || serial->num_interrupt_in < 2) { | ||
| 548 | dev_err(&serial->interface->dev, "missing endpoints\n"); | ||
| 549 | return -ENODEV; | ||
| 550 | } | ||
| 551 | |||
| 547 | /* | 552 | /* |
| 548 | * It appears that Treos and Kyoceras want to use the | 553 | * It appears that Treos and Kyoceras want to use the |
| 549 | * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, | 554 | * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, |
| @@ -597,8 +602,10 @@ static int clie_5_attach(struct usb_serial *serial) · 47 unmodified lines | |||
| 597 | */ | 602 | */ |
| 598 | 603 | ||
| 599 | /* some sanity check */ | 604 | /* some sanity check */ |
| 600 | if (serial->num_ports < 2) | 605 | if (serial->num_bulk_out < 2) { |
| 601 | return -1; | 606 | dev_err(&serial->interface->dev, "missing bulk out endpoints\n"); |
| 607 | return -ENODEV; | ||
| 608 | } | ||
| 602 | 609 | ||
| 603 | /* port 0 now uses the modified endpoint Address */ | 610 | /* port 0 now uses the modified endpoint Address */ |
| 604 | port = serial->port[0]; | 611 | port = serial->port[0]; |
| @@ -123,8 +123,8 @@ struct iommu_group *vfio_iommu_group_get(struct device *dev) · 122 unmodified lines | |||
| 123 | /* | 123 | /* |
| 124 | * With noiommu enabled, an IOMMU group will be created for a device | 124 | * With noiommu enabled, an IOMMU group will be created for a device |
| 125 | * that doesn't already have one and doesn't have an iommu_ops on their | 125 | * that doesn't already have one and doesn't have an iommu_ops on their |
| 126 | * bus. We use iommu_present() again in the main code to detect these | 126 | * bus. We set iommudata simply to be able to identify these groups |
| 127 | * fake groups. | 127 | * as special use and for reclamation later. |
| 128 | */ | 128 | */ |
| 129 | if (group || !noiommu || iommu_present(dev->bus)) | 129 | if (group || !noiommu || iommu_present(dev->bus)) |
| 130 | return group; | 130 | return group; |
| @@ -134,6 +134,7 @@ struct iommu_group *vfio_iommu_group_get(struct device *dev) · 3 unmodified lines | |||
| 134 | return NULL; | 134 | return NULL; |
| 135 | 135 | ||
| 136 | iommu_group_set_name(group, "vfio-noiommu"); | 136 | iommu_group_set_name(group, "vfio-noiommu"); |
| 137 | iommu_group_set_iommudata(group, &noiommu, NULL); | ||
| 137 | ret = iommu_group_add_device(group, dev); | 138 | ret = iommu_group_add_device(group, dev); |
| 138 | iommu_group_put(group); | 139 | iommu_group_put(group); |
| 139 | if (ret) | 140 | if (ret) |
| @@ -158,7 +159,7 @@ EXPORT_SYMBOL_GPL(vfio_iommu_group_get); · 18 unmodified lines | |||
| 158 | void vfio_iommu_group_put(struct iommu_group *group, struct device *dev) | 159 | void vfio_iommu_group_put(struct iommu_group *group, struct device *dev) |
| 159 | { | 160 | { |
| 160 | #ifdef CONFIG_VFIO_NOIOMMU | 161 | #ifdef CONFIG_VFIO_NOIOMMU |
| 161 | if (!iommu_present(dev->bus)) | 162 | if (iommu_group_get_iommudata(group) == &noiommu) |
| 162 | iommu_group_remove_device(dev); | 163 | iommu_group_remove_device(dev); |
| 163 | #endif | 164 | #endif |
| 164 | 165 | ||
| @@ -190,16 +191,10 @@ static long vfio_noiommu_ioctl(void *iommu_data, · 25 unmodified lines | |||
| 190 | return -ENOTTY; | 191 | return -ENOTTY; |
| 191 | } | 192 | } |
| 192 | 193 | ||
| 193 | static int vfio_iommu_present(struct device *dev, void *unused) | ||
| 194 | { | ||
| 195 | return iommu_present(dev->bus) ? 1 : 0; | ||
| 196 | } | ||
| 197 | |||
| 198 | static int vfio_noiommu_attach_group(void *iommu_data, | 194 | static int vfio_noiommu_attach_group(void *iommu_data, |
| 199 | struct iommu_group *iommu_group) | 195 | struct iommu_group *iommu_group) |
| 200 | { | 196 | { |
| 201 | return iommu_group_for_each_dev(iommu_group, NULL, | 197 | return iommu_group_get_iommudata(iommu_group) == &noiommu ? 0 : -EINVAL; |
| 202 | vfio_iommu_present) ? -EINVAL : 0; | ||
| 203 | } | 198 | } |
| 204 | 199 | ||
| 205 | static void vfio_noiommu_detach_group(void *iommu_data, | 200 | static void vfio_noiommu_detach_group(void *iommu_data, |
| @@ -323,8 +318,7 @@ static void vfio_group_unlock_and_free(struct vfio_group *group) · 117 unmodified lines | |||
| 323 | /** | 318 | /** |
| 324 | * Group objects - create, release, get, put, search | 319 | * Group objects - create, release, get, put, search |
| 325 | */ | 320 | */ |
| 326 | static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group, | 321 | static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group) |
| 327 | bool iommu_present) | ||
| 328 | { | 322 | { |
| 329 | struct vfio_group *group, *tmp; | 323 | struct vfio_group *group, *tmp; |
| 330 | struct device *dev; | 324 | struct device *dev; |
| @@ -342,7 +336,9 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group, · 11 unmodified lines | |||
| 342 | atomic_set(&group->container_users, 0); | 336 | atomic_set(&group->container_users, 0); |
| 343 | atomic_set(&group->opened, 0); | 337 | atomic_set(&group->opened, 0); |
| 344 | group->iommu_group = iommu_group; | 338 | group->iommu_group = iommu_group; |
| 345 | group->noiommu = !iommu_present; | 339 | #ifdef CONFIG_VFIO_NOIOMMU |
| 340 | group->noiommu = (iommu_group_get_iommudata(iommu_group) == &noiommu); | ||
| 341 | #endif | ||
| 346 | 342 | ||
| 347 | group->nb.notifier_call = vfio_iommu_group_notifier; | 343 | group->nb.notifier_call = vfio_iommu_group_notifier; |
| 348 | 344 | ||
| @@ -767,7 +763,7 @@ int vfio_add_group_dev(struct device *dev, · 418 unmodified lines | |||
| 767 | 763 | ||
| 768 | group = vfio_group_get_from_iommu(iommu_group); | 764 | group = vfio_group_get_from_iommu(iommu_group); |
| 769 | if (!group) { | 765 | if (!group) { |
| 770 | group = vfio_create_group(iommu_group, iommu_present(dev->bus)); | 766 | group = vfio_create_group(iommu_group); |
| 771 | if (IS_ERR(group)) { | 767 | if (IS_ERR(group)) { |
| 772 | iommu_group_put(iommu_group); | 768 | iommu_group_put(iommu_group); |
| 773 | return PTR_ERR(group); | 769 | return PTR_ERR(group); |
| @@ -545,6 +545,7 @@ err_enable_device: · 544 unmodified lines | |||
| 545 | static void virtio_pci_remove(struct pci_dev *pci_dev) | 545 | static void virtio_pci_remove(struct pci_dev *pci_dev) |
| 546 | { | 546 | { |
| 547 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); | 547 | struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); |
| 548 | struct device *dev = get_device(&vp_dev->vdev.dev); | ||
| 548 | 549 | ||
| 549 | unregister_virtio_device(&vp_dev->vdev); | 550 | unregister_virtio_device(&vp_dev->vdev); |
| 550 | 551 | ||
| @@ -554,6 +555,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) · 3 unmodified lines | |||
| 554 | virtio_pci_modern_remove(vp_dev); | 555 | virtio_pci_modern_remove(vp_dev); |
| 555 | 556 | ||
| 556 | pci_disable_device(pci_dev); | 557 | pci_disable_device(pci_dev); |
| 558 | put_device(dev); | ||
| 557 | } | 559 | } |
| 558 | 560 | ||
| 559 | static struct pci_driver virtio_pci_driver = { | 561 | static struct pci_driver virtio_pci_driver = { |
| @@ -242,7 +242,7 @@ static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize) · 241 unmodified lines | |||
| 242 | return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize); | 242 | return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | static struct cleancache_ops tmem_cleancache_ops = { | 245 | static const struct cleancache_ops tmem_cleancache_ops = { |
| 246 | .put_page = tmem_cleancache_put_page, | 246 | .put_page = tmem_cleancache_put_page, |
| 247 | .get_page = tmem_cleancache_get_page, | 247 | .get_page = tmem_cleancache_get_page, |
| 248 | .invalidate_page = tmem_cleancache_flush_page, | 248 | .invalidate_page = tmem_cleancache_flush_page, |
| @@ -328,8 +328,8 @@ static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq, · 327 unmodified lines | |||
| 328 | list_add_tail(&work->ordered_list, &wq->ordered_list); | 328 | list_add_tail(&work->ordered_list, &wq->ordered_list); |
| 329 | spin_unlock_irqrestore(&wq->list_lock, flags); | 329 | spin_unlock_irqrestore(&wq->list_lock, flags); |
| 330 | } | 330 | } |
| 331 | queue_work(wq->normal_wq, &work->normal_work); | ||
| 332 | trace_btrfs_work_queued(work); | 331 | trace_btrfs_work_queued(work); |
| 332 | queue_work(wq->normal_wq, &work->normal_work); | ||
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | void btrfs_queue_work(struct btrfs_workqueue *wq, | 335 | void btrfs_queue_work(struct btrfs_workqueue *wq, |
| @@ -182,6 +182,7 @@ static struct btrfs_lockdep_keyset { · 181 unmodified lines | |||
| 182 | { .id = BTRFS_TREE_RELOC_OBJECTID, .name_stem = "treloc" }, | 182 | { .id = BTRFS_TREE_RELOC_OBJECTID, .name_stem = "treloc" }, |
| 183 | { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, .name_stem = "dreloc" }, | 183 | { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, .name_stem = "dreloc" }, |
| 184 | { .id = BTRFS_UUID_TREE_OBJECTID, .name_stem = "uuid" }, | 184 | { .id = BTRFS_UUID_TREE_OBJECTID, .name_stem = "uuid" }, |
| 185 | { .id = BTRFS_FREE_SPACE_TREE_OBJECTID, .name_stem = "free-space" }, | ||
| 185 | { .id = 0, .name_stem = "tree" }, | 186 | { .id = 0, .name_stem = "tree" }, |
| 186 | }; | 187 | }; |
| 187 | 188 | ||
| @@ -1787,7 +1788,6 @@ static int cleaner_kthread(void *arg) · 1599 unmodified lines | |||
| 1787 | int again; | 1788 | int again; |
| 1788 | struct btrfs_trans_handle *trans; | 1789 | struct btrfs_trans_handle *trans; |
| 1789 | 1790 | ||
| 1790 | set_freezable(); | ||
| 1791 | do { | 1791 | do { |
| 1792 | again = 0; | 1792 | again = 0; |
| 1793 | 1793 | ||
| @@ -153,6 +153,20 @@ static inline u32 free_space_bitmap_size(u64 size, u32 sectorsize) · 152 unmodified lines | |||
| 153 | 153 | ||
| 154 | static unsigned long *alloc_bitmap(u32 bitmap_size) | 154 | static unsigned long *alloc_bitmap(u32 bitmap_size) |
| 155 | { | 155 | { |
| 156 | void *mem; | ||
| 157 | |||
| 158 | /* | ||
| 159 | * The allocation size varies, observed numbers were < 4K up to 16K. | ||
| 160 | * Using vmalloc unconditionally would be too heavy, we'll try | ||
| 161 | * contiguous allocations first. | ||
| 162 | */ | ||
| 163 | if (bitmap_size <= PAGE_SIZE) | ||
| 164 | return kzalloc(bitmap_size, GFP_NOFS); | ||
| 165 | |||
| 166 | mem = kzalloc(bitmap_size, GFP_NOFS | __GFP_NOWARN); | ||
| 167 | if (mem) | ||
| 168 | return mem; | ||
| 169 | |||
| 156 | return __vmalloc(bitmap_size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO, | 170 | return __vmalloc(bitmap_size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO, |
| 157 | PAGE_KERNEL); | 171 | PAGE_KERNEL); |
| 158 | } | 172 | } |
| @@ -289,7 +303,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, · 130 unmodified lines | |||
| 289 | 303 | ||
| 290 | ret = 0; | 304 | ret = 0; |
| 291 | out: | 305 | out: |
| 292 | vfree(bitmap); | 306 | kvfree(bitmap); |
| 293 | if (ret) | 307 | if (ret) |
| 294 | btrfs_abort_transaction(trans, root, ret); | 308 | btrfs_abort_transaction(trans, root, ret); |
| 295 | return ret; | 309 | return ret; |
| @@ -438,7 +452,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans, · 142 unmodified lines | |||
| 438 | 452 | ||
| 439 | ret = 0; | 453 | ret = 0; |
| 440 | out: | 454 | out: |
| 441 | vfree(bitmap); | 455 | kvfree(bitmap); |
| 442 | if (ret) | 456 | if (ret) |
| 443 | btrfs_abort_transaction(trans, root, ret); | 457 | btrfs_abort_transaction(trans, root, ret); |
| 444 | return ret; | 458 | return ret; |
| @@ -7116,21 +7116,41 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode, · 7115 unmodified lines | |||
| 7116 | if (ret) | 7116 | if (ret) |
| 7117 | return ERR_PTR(ret); | 7117 | return ERR_PTR(ret); |
| 7118 | 7118 | ||
| 7119 | em = create_pinned_em(inode, start, ins.offset, start, ins.objectid, | 7119 | /* |
| 7120 | ins.offset, ins.offset, ins.offset, 0); | 7120 | * Create the ordered extent before the extent map. This is to avoid |
| 7121 | if (IS_ERR(em)) { | 7121 | * races with the fast fsync path that would lead to it logging file |
| 7122 | btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1); | 7122 | * extent items that point to disk extents that were not yet written to. |
| 7123 | return em; | 7123 | * The fast fsync path collects ordered extents into a local list and |
| 7124 | } | 7124 | * then collects all the new extent maps, so we must create the ordered |
| 7125 | 7125 | * extent first and make sure the fast fsync path collects any new | |
| 7126 | * ordered extents after collecting new extent maps as well. | ||
| 7127 | * The fsync path simply can not rely on inode_dio_wait() because it | ||
| 7128 | * causes deadlock with AIO. | ||
| 7129 | */ | ||
| 7126 | ret = btrfs_add_ordered_extent_dio(inode, start, ins.objectid, | 7130 | ret = btrfs_add_ordered_extent_dio(inode, start, ins.objectid, |
| 7127 | ins.offset, ins.offset, 0); | 7131 | ins.offset, ins.offset, 0); |
| 7128 | if (ret) { | 7132 | if (ret) { |
| 7129 | btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1); | 7133 | btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1); |
| 7130 | free_extent_map(em); | ||
| 7131 | return ERR_PTR(ret); | 7134 | return ERR_PTR(ret); |
| 7132 | } | 7135 | } |
| 7133 | 7136 | ||
| 7137 | em = create_pinned_em(inode, start, ins.offset, start, ins.objectid, | ||
| 7138 | ins.offset, ins.offset, ins.offset, 0); | ||
| 7139 | if (IS_ERR(em)) { | ||
| 7140 | struct btrfs_ordered_extent *oe; | ||
| 7141 | |||
| 7142 | btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1); | ||
| 7143 | oe = btrfs_lookup_ordered_extent(inode, start); | ||
| 7144 | ASSERT(oe); | ||
| 7145 | if (WARN_ON(!oe)) | ||
| 7146 | return em; | ||
| 7147 | set_bit(BTRFS_ORDERED_IOERR, &oe->flags); | ||
| 7148 | set_bit(BTRFS_ORDERED_IO_DONE, &oe->flags); | ||
| 7149 | btrfs_remove_ordered_extent(inode, oe); | ||
| 7150 | /* Once for our lookup and once for the ordered extents tree. */ | ||
| 7151 | btrfs_put_ordered_extent(oe); | ||
| 7152 | btrfs_put_ordered_extent(oe); | ||
| 7153 | } | ||
| 7134 | return em; | 7154 | return em; |
| 7135 | } | 7155 | } |
| 7136 | 7156 | ||
| @@ -575,7 +575,8 @@ static int is_cowonly_root(u64 root_objectid) · 574 unmodified lines | |||
| 575 | root_objectid == BTRFS_TREE_LOG_OBJECTID || | 575 | root_objectid == BTRFS_TREE_LOG_OBJECTID || |
| 576 | root_objectid == BTRFS_CSUM_TREE_OBJECTID || | 576 | root_objectid == BTRFS_CSUM_TREE_OBJECTID || |
| 577 | root_objectid == BTRFS_UUID_TREE_OBJECTID || | 577 | root_objectid == BTRFS_UUID_TREE_OBJECTID || |
| 578 | root_objectid == BTRFS_QUOTA_TREE_OBJECTID) | 578 | root_objectid == BTRFS_QUOTA_TREE_OBJECTID || |
| 579 | root_objectid == BTRFS_FREE_SPACE_TREE_OBJECTID) | ||
| 579 | return 1; | 580 | return 1; |
| 580 | return 0; | 581 | return 0; |
| 581 | } | 582 | } |
| @@ -202,6 +202,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(extended_iref, EXTENDED_IREF); · 201 unmodified lines | |||
| 202 | BTRFS_FEAT_ATTR_INCOMPAT(raid56, RAID56); | 202 | BTRFS_FEAT_ATTR_INCOMPAT(raid56, RAID56); |
| 203 | BTRFS_FEAT_ATTR_INCOMPAT(skinny_metadata, SKINNY_METADATA); | 203 | BTRFS_FEAT_ATTR_INCOMPAT(skinny_metadata, SKINNY_METADATA); |
| 204 | BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES); | 204 | BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES); |
| 205 | BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE); | ||
| 205 | 206 | ||
| 206 | static struct attribute *btrfs_supported_feature_attrs[] = { | 207 | static struct attribute *btrfs_supported_feature_attrs[] = { |
| 207 | BTRFS_FEAT_ATTR_PTR(mixed_backref), | 208 | BTRFS_FEAT_ATTR_PTR(mixed_backref), |
| @@ -213,6 +214,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = { · 5 unmodified lines | |||
| 213 | BTRFS_FEAT_ATTR_PTR(raid56), | 214 | BTRFS_FEAT_ATTR_PTR(raid56), |
| 214 | BTRFS_FEAT_ATTR_PTR(skinny_metadata), | 215 | BTRFS_FEAT_ATTR_PTR(skinny_metadata), |
| 215 | BTRFS_FEAT_ATTR_PTR(no_holes), | 216 | BTRFS_FEAT_ATTR_PTR(no_holes), |
| 217 | BTRFS_FEAT_ATTR_PTR(free_space_tree), | ||
| 216 | NULL | 218 | NULL |
| 217 | }; | 219 | }; |
| 218 | 220 | ||
| @@ -780,6 +782,39 @@ failure: · 561 unmodified lines | |||
| 780 | return error; | 782 | return error; |
| 781 | } | 783 | } |
| 782 | 784 | ||
| 785 | |||
| 786 | /* | ||
| 787 | * Change per-fs features in /sys/fs/btrfs/UUID/features to match current | ||
| 788 | * values in superblock. Call after any changes to incompat/compat_ro flags | ||
| 789 | */ | ||
| 790 | void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, | ||
| 791 | u64 bit, enum btrfs_feature_set set) | ||
| 792 | { | ||
| 793 | struct btrfs_fs_devices *fs_devs; | ||
| 794 | struct kobject *fsid_kobj; | ||
| 795 | u64 features; | ||
| 796 | int ret; | ||
| 797 | |||
| 798 | if (!fs_info) | ||
| 799 | return; | ||
| 800 | |||
| 801 | features = get_features(fs_info, set); | ||
| 802 | ASSERT(bit & supported_feature_masks[set]); | ||
| 803 | |||
| 804 | fs_devs = fs_info->fs_devices; | ||
| 805 | fsid_kobj = &fs_devs->fsid_kobj; | ||
| 806 | |||
| 807 | if (!fsid_kobj->state_initialized) | ||
| 808 | return; | ||
| 809 | |||
| 810 | /* | ||
| 811 | * FIXME: this is too heavy to update just one value, ideally we'd like | ||
| 812 | * to use sysfs_update_group but some refactoring is needed first. | ||
| 813 | */ | ||
| 814 | sysfs_remove_group(fsid_kobj, &btrfs_feature_attr_group); | ||
| 815 | ret = sysfs_create_group(fsid_kobj, &btrfs_feature_attr_group); | ||
| 816 | } | ||
| 817 | |||
| 783 | static int btrfs_init_debugfs(void) | 818 | static int btrfs_init_debugfs(void) |
| 784 | { | 819 | { |
| 785 | #ifdef CONFIG_DEBUG_FS | 820 | #ifdef CONFIG_DEBUG_FS |
| @@ -56,7 +56,7 @@ static struct btrfs_feature_attr btrfs_attr_##_name = { \ · 55 unmodified lines | |||
| 56 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ | 56 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ |
| 57 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) | 57 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) |
| 58 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ | 58 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ |
| 59 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature) | 59 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT_RO, feature) |
| 60 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ | 60 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ |
| 61 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) | 61 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) |
| 62 | 62 | ||
| @@ -90,4 +90,7 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, · 27 unmodified lines | |||
| 90 | struct kobject *parent); | 90 | struct kobject *parent); |
| 91 | int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs); | 91 | int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs); |
| 92 | void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); | 92 | void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); |
| 93 | void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, | ||
| 94 | u64 bit, enum btrfs_feature_set set); | ||
| 95 | |||
| 93 | #endif /* _BTRFS_SYSFS_H_ */ | 96 | #endif /* _BTRFS_SYSFS_H_ */ |
| @@ -82,18 +82,18 @@ void btrfs_destroy_test_fs(void) · 81 unmodified lines | |||
| 82 | struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void) | 82 | struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void) |
| 83 | { | 83 | { |
| 84 | struct btrfs_fs_info *fs_info = kzalloc(sizeof(struct btrfs_fs_info), | 84 | struct btrfs_fs_info *fs_info = kzalloc(sizeof(struct btrfs_fs_info), |
| 85 | GFP_NOFS); | 85 | GFP_KERNEL); |
| 86 | 86 | ||
| 87 | if (!fs_info) | 87 | if (!fs_info) |
| 88 | return fs_info; | 88 | return fs_info; |
| 89 | fs_info->fs_devices = kzalloc(sizeof(struct btrfs_fs_devices), | 89 | fs_info->fs_devices = kzalloc(sizeof(struct btrfs_fs_devices), |
| 90 | GFP_NOFS); | 90 | GFP_KERNEL); |
| 91 | if (!fs_info->fs_devices) { | 91 | if (!fs_info->fs_devices) { |
| 92 | kfree(fs_info); | 92 | kfree(fs_info); |
| 93 | return NULL; | 93 | return NULL; |
| 94 | } | 94 | } |
| 95 | fs_info->super_copy = kzalloc(sizeof(struct btrfs_super_block), | 95 | fs_info->super_copy = kzalloc(sizeof(struct btrfs_super_block), |
| 96 | GFP_NOFS); | 96 | GFP_KERNEL); |
| 97 | if (!fs_info->super_copy) { | 97 | if (!fs_info->super_copy) { |
| 98 | kfree(fs_info->fs_devices); | 98 | kfree(fs_info->fs_devices); |
| 99 | kfree(fs_info); | 99 | kfree(fs_info); |
| @@ -180,11 +180,11 @@ btrfs_alloc_dummy_block_group(unsigned long length) · 80 unmodified lines | |||
| 180 | { | 180 | { |
| 181 | struct btrfs_block_group_cache *cache; | 181 | struct btrfs_block_group_cache *cache; |
| 182 | 182 | ||
| 183 | cache = kzalloc(sizeof(*cache), GFP_NOFS); | 183 | cache = kzalloc(sizeof(*cache), GFP_KERNEL); |
| 184 | if (!cache) | 184 | if (!cache) |
| 185 | return NULL; | 185 | return NULL; |
| 186 | cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl), | 186 | cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl), |
| 187 | GFP_NOFS); | 187 | GFP_KERNEL); |
| 188 | if (!cache->free_space_ctl) { | 188 | if (!cache->free_space_ctl) { |
| 189 | kfree(cache); | 189 | kfree(cache); |
| 190 | return NULL; | 190 | return NULL; |
| @@ -94,7 +94,7 @@ static int test_find_delalloc(void) · 93 unmodified lines | |||
| 94 | * test. | 94 | * test. |
| 95 | */ | 95 | */ |
| 96 | for (index = 0; index < (total_dirty >> PAGE_CACHE_SHIFT); index++) { | 96 | for (index = 0; index < (total_dirty >> PAGE_CACHE_SHIFT); index++) { |
| 97 | page = find_or_create_page(inode->i_mapping, index, GFP_NOFS); | 97 | page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL); |
| 98 | if (!page) { | 98 | if (!page) { |
| 99 | test_msg("Failed to allocate test page\n"); | 99 | test_msg("Failed to allocate test page\n"); |
| 100 | ret = -ENOMEM; | 100 | ret = -ENOMEM; |
| @@ -113,7 +113,7 @@ static int test_find_delalloc(void) · 12 unmodified lines | |||
| 113 | * |--- delalloc ---| | 113 | * |--- delalloc ---| |
| 114 | * |--- search ---| | 114 | * |--- search ---| |
| 115 | */ | 115 | */ |
| 116 | set_extent_delalloc(&tmp, 0, 4095, NULL, GFP_NOFS); | 116 | set_extent_delalloc(&tmp, 0, 4095, NULL, GFP_KERNEL); |
| 117 | start = 0; | 117 | start = 0; |
| 118 | end = 0; | 118 | end = 0; |
| 119 | found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, | 119 | found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, |
| @@ -144,7 +144,7 @@ static int test_find_delalloc(void) · 24 unmodified lines | |||
| 144 | test_msg("Couldn't find the locked page\n"); | 144 | test_msg("Couldn't find the locked page\n"); |
| 145 | goto out_bits; | 145 | goto out_bits; |
| 146 | } | 146 | } |
| 147 | set_extent_delalloc(&tmp, 4096, max_bytes - 1, NULL, GFP_NOFS); | 147 | set_extent_delalloc(&tmp, 4096, max_bytes - 1, NULL, GFP_KERNEL); |
| 148 | start = test_start; | 148 | start = test_start; |
| 149 | end = 0; | 149 | end = 0; |
| 150 | found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, | 150 | found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, |
| @@ -199,7 +199,7 @@ static int test_find_delalloc(void) · 48 unmodified lines | |||
| 199 | * | 199 | * |
| 200 | * We are re-using our test_start from above since it works out well. | 200 | * We are re-using our test_start from above since it works out well. |
| 201 | */ | 201 | */ |
| 202 | set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, NULL, GFP_NOFS); | 202 | set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, NULL, GFP_KERNEL); |
| 203 | start = test_start; | 203 | start = test_start; |
| 204 | end = 0; | 204 | end = 0; |
| 205 | found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, | 205 | found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, |
| @@ -262,7 +262,7 @@ static int test_find_delalloc(void) · 56 unmodified lines | |||
| 262 | } | 262 | } |
| 263 | ret = 0; | 263 | ret = 0; |
| 264 | out_bits: | 264 | out_bits: |
| 265 | clear_extent_bits(&tmp, 0, total_dirty - 1, (unsigned)-1, GFP_NOFS); | 265 | clear_extent_bits(&tmp, 0, total_dirty - 1, (unsigned)-1, GFP_KERNEL); |
| 266 | out: | 266 | out: |
| 267 | if (locked_page) | 267 | if (locked_page) |
| 268 | page_cache_release(locked_page); | 268 | page_cache_release(locked_page); |
| @@ -360,7 +360,7 @@ static int test_eb_bitmaps(void) · 91 unmodified lines | |||
| 360 | 360 | ||
| 361 | test_msg("Running extent buffer bitmap tests\n"); | 361 | test_msg("Running extent buffer bitmap tests\n"); |
| 362 | 362 | ||
| 363 | bitmap = kmalloc(len, GFP_NOFS); | 363 | bitmap = kmalloc(len, GFP_KERNEL); |
| 364 | if (!bitmap) { | 364 | if (!bitmap) { |
| 365 | test_msg("Couldn't allocate test bitmap\n"); | 365 | test_msg("Couldn't allocate test bitmap\n"); |
| 366 | return -ENOMEM; | 366 | return -ENOMEM; |
| @@ -974,7 +974,7 @@ static int test_extent_accounting(void) · 973 unmodified lines | |||
| 974 | (BTRFS_MAX_EXTENT_SIZE >> 1) + 4095, | 974 | (BTRFS_MAX_EXTENT_SIZE >> 1) + 4095, |
| 975 | EXTENT_DELALLOC | EXTENT_DIRTY | | 975 | EXTENT_DELALLOC | EXTENT_DIRTY | |
| 976 | EXTENT_UPTODATE | EXTENT_DO_ACCOUNTING, 0, 0, | 976 | EXTENT_UPTODATE | EXTENT_DO_ACCOUNTING, 0, 0, |
| 977 | NULL, GFP_NOFS); | 977 | NULL, GFP_KERNEL); |
| 978 | if (ret) { | 978 | if (ret) { |
| 979 | test_msg("clear_extent_bit returned %d\n", ret); | 979 | test_msg("clear_extent_bit returned %d\n", ret); |
| 980 | goto out; | 980 | goto out; |
| @@ -1045,7 +1045,7 @@ static int test_extent_accounting(void) · 64 unmodified lines | |||
| 1045 | BTRFS_MAX_EXTENT_SIZE+8191, | 1045 | BTRFS_MAX_EXTENT_SIZE+8191, |
| 1046 | EXTENT_DIRTY | EXTENT_DELALLOC | | 1046 | EXTENT_DIRTY | EXTENT_DELALLOC | |
| 1047 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, | 1047 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, |
| 1048 | NULL, GFP_NOFS); | 1048 | NULL, GFP_KERNEL); |
| 1049 | if (ret) { | 1049 | if (ret) { |
| 1050 | test_msg("clear_extent_bit returned %d\n", ret); | 1050 | test_msg("clear_extent_bit returned %d\n", ret); |
| 1051 | goto out; | 1051 | goto out; |
| @@ -1079,7 +1079,7 @@ static int test_extent_accounting(void) · 27 unmodified lines | |||
| 1079 | ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1, | 1079 | ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1, |
| 1080 | EXTENT_DIRTY | EXTENT_DELALLOC | | 1080 | EXTENT_DIRTY | EXTENT_DELALLOC | |
| 1081 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, | 1081 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, |
| 1082 | NULL, GFP_NOFS); | 1082 | NULL, GFP_KERNEL); |
| 1083 | if (ret) { | 1083 | if (ret) { |
| 1084 | test_msg("clear_extent_bit returned %d\n", ret); | 1084 | test_msg("clear_extent_bit returned %d\n", ret); |
| 1085 | goto out; | 1085 | goto out; |
| @@ -1096,7 +1096,7 @@ out: · 10 unmodified lines | |||
| 1096 | clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1, | 1096 | clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1, |
| 1097 | EXTENT_DIRTY | EXTENT_DELALLOC | | 1097 | EXTENT_DIRTY | EXTENT_DELALLOC | |
| 1098 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, | 1098 | EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0, |
| 1099 | NULL, GFP_NOFS); | 1099 | NULL, GFP_KERNEL); |
| 1100 | iput(inode); | 1100 | iput(inode); |
| 1101 | btrfs_free_dummy_root(root); | 1101 | btrfs_free_dummy_root(root); |
| 1102 | return ret; | 1102 | return ret; |
| @@ -4127,7 +4127,9 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, · 4126 unmodified lines | |||
| 4127 | struct inode *inode, | 4127 | struct inode *inode, |
| 4128 | struct btrfs_path *path, | 4128 | struct btrfs_path *path, |
| 4129 | struct list_head *logged_list, | 4129 | struct list_head *logged_list, |
| 4130 | struct btrfs_log_ctx *ctx) | 4130 | struct btrfs_log_ctx *ctx, |
| 4131 | const u64 start, | ||
| 4132 | const u64 end) | ||
| 4131 | { | 4133 | { |
| 4132 | struct extent_map *em, *n; | 4134 | struct extent_map *em, *n; |
| 4133 | struct list_head extents; | 4135 | struct list_head extents; |
| @@ -4166,7 +4168,13 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, · 32 unmodified lines | |||
| 4166 | } | 4168 | } |
| 4167 | 4169 | ||
| 4168 | list_sort(NULL, &extents, extent_cmp); | 4170 | list_sort(NULL, &extents, extent_cmp); |
| 4169 | 4171 | /* | |
| 4172 | * Collect any new ordered extents within the range. This is to | ||
| 4173 | * prevent logging file extent items without waiting for the disk | ||
| 4174 | * location they point to being written. We do this only to deal | ||
| 4175 | * with races against concurrent lockless direct IO writes. | ||
| 4176 | */ | ||
| 4177 | btrfs_get_logged_extents(inode, logged_list, start, end); | ||
| 4170 | process: | 4178 | process: |
| 4171 | while (!list_empty(&extents)) { | 4179 | while (!list_empty(&extents)) { |
| 4172 | em = list_entry(extents.next, struct extent_map, list); | 4180 | em = list_entry(extents.next, struct extent_map, list); |
| @@ -4701,7 +4709,7 @@ log_extents: · 528 unmodified lines | |||
| 4701 | goto out_unlock; | 4709 | goto out_unlock; |
| 4702 | } | 4710 | } |
| 4703 | ret = btrfs_log_changed_extents(trans, root, inode, dst_path, | 4711 | ret = btrfs_log_changed_extents(trans, root, inode, dst_path, |
| 4704 | &logged_list, ctx); | 4712 | &logged_list, ctx, start, end); |
| 4705 | if (ret) { | 4713 | if (ret) { |
| 4706 | err = ret; | 4714 | err = ret; |
| 4707 | goto out_unlock; | 4715 | goto out_unlock; |
| @@ -153,7 +153,7 @@ static ktime_t timerfd_get_remaining(struct timerfd_ctx *ctx) · 152 unmodified lines | |||
| 153 | if (isalarm(ctx)) | 153 | if (isalarm(ctx)) |
| 154 | remaining = alarm_expires_remaining(&ctx->t.alarm); | 154 | remaining = alarm_expires_remaining(&ctx->t.alarm); |
| 155 | else | 155 | else |
| 156 | remaining = hrtimer_expires_remaining(&ctx->t.tmr); | 156 | remaining = hrtimer_expires_remaining_adjusted(&ctx->t.tmr); |
| 157 | 157 | ||
| 158 | return remaining.tv64 < 0 ? ktime_set(0, 0): remaining; | 158 | return remaining.tv64 < 0 ? ktime_set(0, 0): remaining; |
| 159 | } | 159 | } |
| @@ -42,6 +42,10 @@ int drm_atomic_helper_commit(struct drm_device *dev, · 41 unmodified lines | |||
| 42 | struct drm_atomic_state *state, | 42 | struct drm_atomic_state *state, |
| 43 | bool async); | 43 | bool async); |
| 44 | 44 | ||
| 45 | bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev, | ||
| 46 | struct drm_atomic_state *old_state, | ||
| 47 | struct drm_crtc *crtc); | ||
| 48 | |||
| 45 | void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, | 49 | void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, |
| 46 | struct drm_atomic_state *old_state); | 50 | struct drm_atomic_state *old_state); |
| 47 | 51 | ||
| @@ -37,7 +37,7 @@ struct cleancache_ops { · 36 unmodified lines | |||
| 37 | void (*invalidate_fs)(int); | 37 | void (*invalidate_fs)(int); |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | extern int cleancache_register_ops(struct cleancache_ops *ops); | 40 | extern int cleancache_register_ops(const struct cleancache_ops *ops); |
| 41 | extern void __cleancache_init_fs(struct super_block *); | 41 | extern void __cleancache_init_fs(struct super_block *); |
| 42 | extern void __cleancache_init_shared_fs(struct super_block *); | 42 | extern void __cleancache_init_shared_fs(struct super_block *); |
| 43 | extern int __cleancache_get_page(struct page *); | 43 | extern int __cleancache_get_page(struct page *); |
| @@ -48,14 +48,14 @@ extern void __cleancache_invalidate_fs(struct super_block *); · 4 unmodified lines | |||
| 48 | 48 | ||
| 49 | #ifdef CONFIG_CLEANCACHE | 49 | #ifdef CONFIG_CLEANCACHE |
| 50 | #define cleancache_enabled (1) | 50 | #define cleancache_enabled (1) |
| 51 | static inline bool cleancache_fs_enabled(struct page *page) | ||
| 52 | { | ||
| 53 | return page->mapping->host->i_sb->cleancache_poolid >= 0; | ||
| 54 | } | ||
| 55 | static inline bool cleancache_fs_enabled_mapping(struct address_space *mapping) | 51 | static inline bool cleancache_fs_enabled_mapping(struct address_space *mapping) |
| 56 | { | 52 | { |
| 57 | return mapping->host->i_sb->cleancache_poolid >= 0; | 53 | return mapping->host->i_sb->cleancache_poolid >= 0; |
| 58 | } | 54 | } |
| 55 | static inline bool cleancache_fs_enabled(struct page *page) | ||
| 56 | { | ||
| 57 | return cleancache_fs_enabled_mapping(page->mapping); | ||
| 58 | } | ||
| 59 | #else | 59 | #else |
| 60 | #define cleancache_enabled (0) | 60 | #define cleancache_enabled (0) |
| 61 | #define cleancache_fs_enabled(_page) (0) | 61 | #define cleancache_fs_enabled(_page) (0) |
| @@ -89,11 +89,9 @@ static inline void cleancache_init_shared_fs(struct super_block *sb) · 27 unmodified lines | |||
| 89 | 89 | ||
| 90 | static inline int cleancache_get_page(struct page *page) | 90 | static inline int cleancache_get_page(struct page *page) |
| 91 | { | 91 | { |
| 92 | int ret = -1; | ||
| 93 | |||
| 94 | if (cleancache_enabled && cleancache_fs_enabled(page)) | 92 | if (cleancache_enabled && cleancache_fs_enabled(page)) |
| 95 | ret = __cleancache_get_page(page); | 93 | return __cleancache_get_page(page); |
| 96 | return ret; | 94 | return -1; |
| 97 | } | 95 | } |
| 98 | 96 | ||
| 99 | static inline void cleancache_put_page(struct page *page) | 97 | static inline void cleancache_put_page(struct page *page) |
| @@ -165,7 +165,6 @@ struct ftrace_ops { · 164 unmodified lines | |||
| 165 | ftrace_func_t saved_func; | 165 | ftrace_func_t saved_func; |
| 166 | int __percpu *disabled; | 166 | int __percpu *disabled; |
| 167 | #ifdef CONFIG_DYNAMIC_FTRACE | 167 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 168 | int nr_trampolines; | ||
| 169 | struct ftrace_ops_hash local_hash; | 168 | struct ftrace_ops_hash local_hash; |
| 170 | struct ftrace_ops_hash *func_hash; | 169 | struct ftrace_ops_hash *func_hash; |
| 171 | struct ftrace_ops_hash old_hash; | 170 | struct ftrace_ops_hash old_hash; |
| @@ -87,7 +87,8 @@ enum hrtimer_restart { · 86 unmodified lines | |||
| 87 | * @function: timer expiry callback function | 87 | * @function: timer expiry callback function |
| 88 | * @base: pointer to the timer base (per cpu and per clock) | 88 | * @base: pointer to the timer base (per cpu and per clock) |
| 89 | * @state: state information (See bit values above) | 89 | * @state: state information (See bit values above) |
| 90 | * @start_pid: timer statistics field to store the pid of the task which | 90 | * @is_rel: Set if the timer was armed relative |
| 91 | * @start_pid: timer statistics field to store the pid of the task which | ||
| 91 | * started the timer | 92 | * started the timer |
| 92 | * @start_site: timer statistics field to store the site where the timer | 93 | * @start_site: timer statistics field to store the site where the timer |
| 93 | * was started | 94 | * was started |
| @@ -101,7 +102,8 @@ struct hrtimer { · 7 unmodified lines | |||
| 101 | ktime_t _softexpires; | 102 | ktime_t _softexpires; |
| 102 | enum hrtimer_restart (*function)(struct hrtimer *); | 103 | enum hrtimer_restart (*function)(struct hrtimer *); |
| 103 | struct hrtimer_clock_base *base; | 104 | struct hrtimer_clock_base *base; |
| 104 | unsigned long state; | 105 | u8 state; |
| 106 | u8 is_rel; | ||
| 105 | #ifdef CONFIG_TIMER_STATS | 107 | #ifdef CONFIG_TIMER_STATS |
| 106 | int start_pid; | 108 | int start_pid; |
| 107 | void *start_site; | 109 | void *start_site; |
| @@ -321,6 +323,27 @@ static inline void clock_was_set_delayed(void) { } · 213 unmodified lines | |||
| 321 | 323 | ||
| 322 | #endif | 324 | #endif |
| 323 | 325 | ||
| 326 | static inline ktime_t | ||
| 327 | __hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now) | ||
| 328 | { | ||
| 329 | ktime_t rem = ktime_sub(timer->node.expires, now); | ||
| 330 | |||
| 331 | /* | ||
| 332 | * Adjust relative timers for the extra we added in | ||
| 333 | * hrtimer_start_range_ns() to prevent short timeouts. | ||
| 334 | */ | ||
| 335 | if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel) | ||
| 336 | rem.tv64 -= hrtimer_resolution; | ||
| 337 | return rem; | ||
| 338 | } | ||
| 339 | |||
| 340 | static inline ktime_t | ||
| 341 | hrtimer_expires_remaining_adjusted(const struct hrtimer *timer) | ||
| 342 | { | ||
| 343 | return __hrtimer_expires_remaining_adjusted(timer, | ||
| 344 | timer->base->get_time()); | ||
| 345 | } | ||
| 346 | |||
| 324 | extern void clock_was_set(void); | 347 | extern void clock_was_set(void); |
| 325 | #ifdef CONFIG_TIMERFD | 348 | #ifdef CONFIG_TIMERFD |
| 326 | extern void timerfd_clock_was_set(void); | 349 | extern void timerfd_clock_was_set(void); |
| @@ -390,7 +413,12 @@ static inline void hrtimer_restart(struct hrtimer *timer) · 63 unmodified lines | |||
| 390 | } | 413 | } |
| 391 | 414 | ||
| 392 | /* Query timers: */ | 415 | /* Query timers: */ |
| 393 | extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer); | 416 | extern ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust); |
| 417 | |||
| 418 | static inline ktime_t hrtimer_get_remaining(const struct hrtimer *timer) | ||
| 419 | { | ||
| 420 | return __hrtimer_get_remaining(timer, false); | ||
| 421 | } | ||
| 394 | 422 | ||
| 395 | extern u64 hrtimer_get_next_event(void); | 423 | extern u64 hrtimer_get_next_event(void); |
| 396 | 424 | ||
| @@ -133,8 +133,9 @@ struct iommu_dm_region { · 132 unmodified lines | |||
| 133 | 133 | ||
| 134 | /** | 134 | /** |
| 135 | * struct iommu_ops - iommu ops and capabilities | 135 | * struct iommu_ops - iommu ops and capabilities |
| 136 | * @domain_init: init iommu domain | 136 | * @capable: check capability |
| 137 | * @domain_destroy: destroy iommu domain | 137 | * @domain_alloc: allocate iommu domain |
| 138 | * @domain_free: free iommu domain | ||
| 138 | * @attach_dev: attach device to an iommu domain | 139 | * @attach_dev: attach device to an iommu domain |
| 139 | * @detach_dev: detach device from an iommu domain | 140 | * @detach_dev: detach device from an iommu domain |
| 140 | * @map: map a physically contiguous memory region to an iommu domain | 141 | * @map: map a physically contiguous memory region to an iommu domain |
| @@ -144,8 +145,15 @@ struct iommu_dm_region { · 3 unmodified lines | |||
| 144 | * @iova_to_phys: translate iova to physical address | 145 | * @iova_to_phys: translate iova to physical address |
| 145 | * @add_device: add device to iommu grouping | 146 | * @add_device: add device to iommu grouping |
| 146 | * @remove_device: remove device from iommu grouping | 147 | * @remove_device: remove device from iommu grouping |
| 148 | * @device_group: find iommu group for a particular device | ||
| 147 | * @domain_get_attr: Query domain attributes | 149 | * @domain_get_attr: Query domain attributes |
| 148 | * @domain_set_attr: Change domain attributes | 150 | * @domain_set_attr: Change domain attributes |
| 151 | * @get_dm_regions: Request list of direct mapping requirements for a device | ||
| 152 | * @put_dm_regions: Free list of direct mapping requirements for a device | ||
| 153 | * @domain_window_enable: Configure and enable a particular window for a domain | ||
| 154 | * @domain_window_disable: Disable a particular window for a domain | ||
| 155 | * @domain_set_windows: Set the number of windows for a domain | ||
| 156 | * @domain_get_windows: Return the number of windows for a domain | ||
| 149 | * @of_xlate: add OF master IDs to iommu grouping | 157 | * @of_xlate: add OF master IDs to iommu grouping |
| 150 | * @pgsize_bitmap: bitmap of supported page sizes | 158 | * @pgsize_bitmap: bitmap of supported page sizes |
| 151 | * @priv: per-instance data private to the iommu driver | 159 | * @priv: per-instance data private to the iommu driver |
| @@ -182,9 +190,9 @@ struct iommu_ops { · 30 unmodified lines | |||
| 182 | int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, | 190 | int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr, |
| 183 | phys_addr_t paddr, u64 size, int prot); | 191 | phys_addr_t paddr, u64 size, int prot); |
| 184 | void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr); | 192 | void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr); |
| 185 | /* Set the numer of window per domain */ | 193 | /* Set the number of windows per domain */ |
| 186 | int (*domain_set_windows)(struct iommu_domain *domain, u32 w_count); | 194 | int (*domain_set_windows)(struct iommu_domain *domain, u32 w_count); |
| 187 | /* Get the numer of window per domain */ | 195 | /* Get the number of windows per domain */ |
| 188 | u32 (*domain_get_windows)(struct iommu_domain *domain); | 196 | u32 (*domain_get_windows)(struct iommu_domain *domain); |
| 189 | 197 | ||
| 190 | #ifdef CONFIG_OF_IOMMU | 198 | #ifdef CONFIG_OF_IOMMU |
| @@ -70,6 +70,7 @@ struct irq_fwspec { · 69 unmodified lines | |||
| 70 | */ | 70 | */ |
| 71 | enum irq_domain_bus_token { | 71 | enum irq_domain_bus_token { |
| 72 | DOMAIN_BUS_ANY = 0, | 72 | DOMAIN_BUS_ANY = 0, |
| 73 | DOMAIN_BUS_WIRED, | ||
| 73 | DOMAIN_BUS_PCI_MSI, | 74 | DOMAIN_BUS_PCI_MSI, |
| 74 | DOMAIN_BUS_PLATFORM_MSI, | 75 | DOMAIN_BUS_PLATFORM_MSI, |
| 75 | DOMAIN_BUS_NEXUS, | 76 | DOMAIN_BUS_NEXUS, |
| @@ -634,9 +634,6 @@ struct perf_event_context { · 633 unmodified lines | |||
| 634 | int nr_cgroups; /* cgroup evts */ | 634 | int nr_cgroups; /* cgroup evts */ |
| 635 | void *task_ctx_data; /* pmu specific data */ | 635 | void *task_ctx_data; /* pmu specific data */ |
| 636 | struct rcu_head rcu_head; | 636 | struct rcu_head rcu_head; |
| 637 | |||
| 638 | struct delayed_work orphans_remove; | ||
| 639 | bool orphans_remove_sched; | ||
| 640 | }; | 637 | }; |
| 641 | 638 | ||
| 642 | /* | 639 | /* |
| @@ -729,7 +726,7 @@ extern int perf_event_init_task(struct task_struct *child); · 86 unmodified lines | |||
| 729 | extern void perf_event_exit_task(struct task_struct *child); | 726 | extern void perf_event_exit_task(struct task_struct *child); |
| 730 | extern void perf_event_free_task(struct task_struct *task); | 727 | extern void perf_event_free_task(struct task_struct *task); |
| 731 | extern void perf_event_delayed_put(struct task_struct *task); | 728 | extern void perf_event_delayed_put(struct task_struct *task); |
| 732 | extern struct perf_event *perf_event_get(unsigned int fd); | 729 | extern struct file *perf_event_get(unsigned int fd); |
| 733 | extern const struct perf_event_attr *perf_event_attrs(struct perf_event *event); | 730 | extern const struct perf_event_attr *perf_event_attrs(struct perf_event *event); |
| 734 | extern void perf_event_print_debug(void); | 731 | extern void perf_event_print_debug(void); |
| 735 | extern void perf_pmu_disable(struct pmu *pmu); | 732 | extern void perf_pmu_disable(struct pmu *pmu); |
| @@ -1044,7 +1041,7 @@ extern void perf_swevent_put_recursion_context(int rctx); · 308 unmodified lines | |||
| 1044 | extern u64 perf_swevent_set_period(struct perf_event *event); | 1041 | extern u64 perf_swevent_set_period(struct perf_event *event); |
| 1045 | extern void perf_event_enable(struct perf_event *event); | 1042 | extern void perf_event_enable(struct perf_event *event); |
| 1046 | extern void perf_event_disable(struct perf_event *event); | 1043 | extern void perf_event_disable(struct perf_event *event); |
| 1047 | extern int __perf_event_disable(void *info); | 1044 | extern void perf_event_disable_local(struct perf_event *event); |
| 1048 | extern void perf_event_task_tick(void); | 1045 | extern void perf_event_task_tick(void); |
| 1049 | #else /* !CONFIG_PERF_EVENTS: */ | 1046 | #else /* !CONFIG_PERF_EVENTS: */ |
| 1050 | static inline void * | 1047 | static inline void * |
| @@ -1070,7 +1067,7 @@ static inline int perf_event_init_task(struct task_struct *child) { return 0; } · 19 unmodified lines | |||
| 1070 | static inline void perf_event_exit_task(struct task_struct *child) { } | 1067 | static inline void perf_event_exit_task(struct task_struct *child) { } |
| 1071 | static inline void perf_event_free_task(struct task_struct *task) { } | 1068 | static inline void perf_event_free_task(struct task_struct *task) { } |
| 1072 | static inline void perf_event_delayed_put(struct task_struct *task) { } | 1069 | static inline void perf_event_delayed_put(struct task_struct *task) { } |
| 1073 | static inline struct perf_event *perf_event_get(unsigned int fd) { return ERR_PTR(-EINVAL); } | 1070 | static inline struct file *perf_event_get(unsigned int fd) { return ERR_PTR(-EINVAL); } |
| 1074 | static inline const struct perf_event_attr *perf_event_attrs(struct perf_event *event) | 1071 | static inline const struct perf_event_attr *perf_event_attrs(struct perf_event *event) |
| 1075 | { | 1072 | { |
| 1076 | return ERR_PTR(-EINVAL); | 1073 | return ERR_PTR(-EINVAL); |
| @@ -1,10 +1,13 @@ | |||
| 1 | #ifndef __LINUX_SWIOTLB_H | 1 | #ifndef __LINUX_SWIOTLB_H |
| 2 | #define __LINUX_SWIOTLB_H | 2 | #define __LINUX_SWIOTLB_H |
| 3 | 3 | ||
| 4 | #include <linux/dma-direction.h> | ||
| 5 | #include <linux/init.h> | ||
| 4 | #include <linux/types.h> | 6 | #include <linux/types.h> |
| 5 | 7 | ||
| 6 | struct device; | 8 | struct device; |
| 7 | struct dma_attrs; | 9 | struct dma_attrs; |
| 10 | struct page; | ||
| 8 | struct scatterlist; | 11 | struct scatterlist; |
| 9 | 12 | ||
| 10 | extern int swiotlb_force; | 13 | extern int swiotlb_force; |
| @@ -649,6 +649,7 @@ extern long vt_compat_ioctl(struct tty_struct *tty, · 648 unmodified lines | |||
| 649 | /* tty_mutex.c */ | 649 | /* tty_mutex.c */ |
| 650 | /* functions for preparation of BKL removal */ | 650 | /* functions for preparation of BKL removal */ |
| 651 | extern void __lockfunc tty_lock(struct tty_struct *tty); | 651 | extern void __lockfunc tty_lock(struct tty_struct *tty); |
| 652 | extern int tty_lock_interruptible(struct tty_struct *tty); | ||
| 652 | extern void __lockfunc tty_unlock(struct tty_struct *tty); | 653 | extern void __lockfunc tty_unlock(struct tty_struct *tty); |
| 653 | extern void __lockfunc tty_lock_slave(struct tty_struct *tty); | 654 | extern void __lockfunc tty_lock_slave(struct tty_struct *tty); |
| 654 | extern void __lockfunc tty_unlock_slave(struct tty_struct *tty); | 655 | extern void __lockfunc tty_unlock_slave(struct tty_struct *tty); |
| @@ -17,7 +17,7 @@ TRACE_EVENT(fence_annotate_wait_on, · 16 unmodified lines | |||
| 17 | 17 | ||
| 18 | TP_STRUCT__entry( | 18 | TP_STRUCT__entry( |
| 19 | __string(driver, fence->ops->get_driver_name(fence)) | 19 | __string(driver, fence->ops->get_driver_name(fence)) |
| 20 | __string(timeline, fence->ops->get_driver_name(fence)) | 20 | __string(timeline, fence->ops->get_timeline_name(fence)) |
| 21 | __field(unsigned int, context) | 21 | __field(unsigned int, context) |
| 22 | __field(unsigned int, seqno) | 22 | __field(unsigned int, seqno) |
| 23 | 23 | ||
| @@ -48,6 +48,8 @@ struct drm_etnaviv_timespec { · 47 unmodified lines | |||
| 48 | #define ETNAVIV_PARAM_GPU_FEATURES_2 0x05 | 48 | #define ETNAVIV_PARAM_GPU_FEATURES_2 0x05 |
| 49 | #define ETNAVIV_PARAM_GPU_FEATURES_3 0x06 | 49 | #define ETNAVIV_PARAM_GPU_FEATURES_3 0x06 |
| 50 | #define ETNAVIV_PARAM_GPU_FEATURES_4 0x07 | 50 | #define ETNAVIV_PARAM_GPU_FEATURES_4 0x07 |
| 51 | #define ETNAVIV_PARAM_GPU_FEATURES_5 0x08 | ||
| 52 | #define ETNAVIV_PARAM_GPU_FEATURES_6 0x09 | ||
| 51 | 53 | ||
| 52 | #define ETNAVIV_PARAM_GPU_STREAM_COUNT 0x10 | 54 | #define ETNAVIV_PARAM_GPU_STREAM_COUNT 0x10 |
| 53 | #define ETNAVIV_PARAM_GPU_REGISTER_MAX 0x11 | 55 | #define ETNAVIV_PARAM_GPU_REGISTER_MAX 0x11 |
| @@ -59,6 +61,7 @@ struct drm_etnaviv_timespec { · 5 unmodified lines | |||
| 59 | #define ETNAVIV_PARAM_GPU_BUFFER_SIZE 0x17 | 61 | #define ETNAVIV_PARAM_GPU_BUFFER_SIZE 0x17 |
| 60 | #define ETNAVIV_PARAM_GPU_INSTRUCTION_COUNT 0x18 | 62 | #define ETNAVIV_PARAM_GPU_INSTRUCTION_COUNT 0x18 |
| 61 | #define ETNAVIV_PARAM_GPU_NUM_CONSTANTS 0x19 | 63 | #define ETNAVIV_PARAM_GPU_NUM_CONSTANTS 0x19 |
| 64 | #define ETNAVIV_PARAM_GPU_NUM_VARYINGS 0x1a | ||
| 62 | 65 | ||
| 63 | #define ETNA_MAX_PIPES 4 | 66 | #define ETNA_MAX_PIPES 4 |
| 64 | 67 | ||
| @@ -291,10 +291,13 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd) · 290 unmodified lines | |||
| 291 | { | 291 | { |
| 292 | struct perf_event *event; | 292 | struct perf_event *event; |
| 293 | const struct perf_event_attr *attr; | 293 | const struct perf_event_attr *attr; |
| 294 | struct file *file; | ||
| 294 | 295 | ||
| 295 | event = perf_event_get(fd); | 296 | file = perf_event_get(fd); |
| 296 | if (IS_ERR(event)) | 297 | if (IS_ERR(file)) |
| 297 | return event; | 298 | return file; |
| 299 | |||
| 300 | event = file->private_data; | ||
| 298 | 301 | ||
| 299 | attr = perf_event_attrs(event); | 302 | attr = perf_event_attrs(event); |
| 300 | if (IS_ERR(attr)) | 303 | if (IS_ERR(attr)) |
| @@ -304,24 +307,22 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd) · 3 unmodified lines | |||
| 304 | goto err; | 307 | goto err; |
| 305 | 308 | ||
| 306 | if (attr->type == PERF_TYPE_RAW) | 309 | if (attr->type == PERF_TYPE_RAW) |
| 307 | return event; | 310 | return file; |
| 308 | 311 | ||
| 309 | if (attr->type == PERF_TYPE_HARDWARE) | 312 | if (attr->type == PERF_TYPE_HARDWARE) |
| 310 | return event; | 313 | return file; |
| 311 | 314 | ||
| 312 | if (attr->type == PERF_TYPE_SOFTWARE && | 315 | if (attr->type == PERF_TYPE_SOFTWARE && |
| 313 | attr->config == PERF_COUNT_SW_BPF_OUTPUT) | 316 | attr->config == PERF_COUNT_SW_BPF_OUTPUT) |
| 314 | return event; | 317 | return file; |
| 315 | err: | 318 | err: |
| 316 | perf_event_release_kernel(event); | 319 | fput(file); |
| 317 | return ERR_PTR(-EINVAL); | 320 | return ERR_PTR(-EINVAL); |
| 318 | } | 321 | } |
| 319 | 322 | ||
| 320 | static void perf_event_fd_array_put_ptr(void *ptr) | 323 | static void perf_event_fd_array_put_ptr(void *ptr) |
| 321 | { | 324 | { |
| 322 | struct perf_event *event = ptr; | 325 | fput((struct file *)ptr); |
| 323 | |||
| 324 | perf_event_release_kernel(event); | ||
| 325 | } | 326 | } |
| 326 | 327 | ||
| 327 | static const struct bpf_map_ops perf_event_array_ops = { | 328 | static const struct bpf_map_ops perf_event_array_ops = { |
| @@ -49,8 +49,6 @@ · 48 unmodified lines | |||
| 49 | 49 | ||
| 50 | #include <asm/irq_regs.h> | 50 | #include <asm/irq_regs.h> |
| 51 | 51 | ||
| 52 | static struct workqueue_struct *perf_wq; | ||
| 53 | |||
| 54 | typedef int (*remote_function_f)(void *); | 52 | typedef int (*remote_function_f)(void *); |
| 55 | 53 | ||
| 56 | struct remote_function_call { | 54 | struct remote_function_call { |
| @@ -126,44 +124,181 @@ static int cpu_function_call(int cpu, remote_function_f func, void *info) · 69 unmodified lines | |||
| 126 | return data.ret; | 124 | return data.ret; |
| 127 | } | 125 | } |
| 128 | 126 | ||
| 129 | static void event_function_call(struct perf_event *event, | 127 | static inline struct perf_cpu_context * |
| 130 | int (*active)(void *), | 128 | __get_cpu_context(struct perf_event_context *ctx) |
| 131 | void (*inactive)(void *), | 129 | { |
| 132 | void *data) | 130 | return this_cpu_ptr(ctx->pmu->pmu_cpu_context); |
| 131 | } | ||
| 132 | |||
| 133 | static void perf_ctx_lock(struct perf_cpu_context *cpuctx, | ||
| 134 | struct perf_event_context *ctx) | ||
| 133 | { | 135 | { |
| 136 | raw_spin_lock(&cpuctx->ctx.lock); | ||
| 137 | if (ctx) | ||
| 138 | raw_spin_lock(&ctx->lock); | ||
| 139 | } | ||
| 140 | |||
| 141 | static void perf_ctx_unlock(struct perf_cpu_context *cpuctx, | ||
| 142 | struct perf_event_context *ctx) | ||
| 143 | { | ||
| 144 | if (ctx) | ||
| 145 | raw_spin_unlock(&ctx->lock); | ||
| 146 | raw_spin_unlock(&cpuctx->ctx.lock); | ||
| 147 | } | ||
| 148 | |||
| 149 | #define TASK_TOMBSTONE ((void *)-1L) | ||
| 150 | |||
| 151 | static bool is_kernel_event(struct perf_event *event) | ||
| 152 | { | ||
| 153 | return READ_ONCE(event->owner) == TASK_TOMBSTONE; | ||
| 154 | } | ||
| 155 | |||
| 156 | /* | ||
| 157 | * On task ctx scheduling... | ||
| 158 | * | ||
| 159 | * When !ctx->nr_events a task context will not be scheduled. This means | ||
| 160 | * we can disable the scheduler hooks (for performance) without leaving | ||
| 161 | * pending task ctx state. | ||
| 162 | * | ||
| 163 | * This however results in two special cases: | ||
| 164 | * | ||
| 165 | * - removing the last event from a task ctx; this is relatively straight | ||
| 166 | * forward and is done in __perf_remove_from_context. | ||
| 167 | * | ||
| 168 | * - adding the first event to a task ctx; this is tricky because we cannot | ||
| 169 | * rely on ctx->is_active and therefore cannot use event_function_call(). | ||
| 170 | * See perf_install_in_context(). | ||
| 171 | * | ||
| 172 | * This is because we need a ctx->lock serialized variable (ctx->is_active) | ||
| 173 | * to reliably determine if a particular task/context is scheduled in. The | ||
| 174 | * task_curr() use in task_function_call() is racy in that a remote context | ||
| 175 | * switch is not a single atomic operation. | ||
| 176 | * | ||
| 177 | * As is, the situation is 'safe' because we set rq->curr before we do the | ||
| 178 | * actual context switch. This means that task_curr() will fail early, but | ||
| 179 | * we'll continue spinning on ctx->is_active until we've passed | ||
| 180 | * perf_event_task_sched_out(). | ||
| 181 | * | ||
| 182 | * Without this ctx->lock serialized variable we could have race where we find | ||
| 183 | * the task (and hence the context) would not be active while in fact they are. | ||
| 184 | * | ||
| 185 | * If ctx->nr_events, then ctx->is_active and cpuctx->task_ctx are set. | ||
| 186 | */ | ||
| 187 | |||
| 188 | typedef void (*event_f)(struct perf_event *, struct perf_cpu_context *, | ||
| 189 | struct perf_event_context *, void *); | ||
| 190 | |||
| 191 | struct event_function_struct { | ||
| 192 | struct perf_event *event; | ||
| 193 | event_f func; | ||
| 194 | void *data; | ||
| 195 | }; | ||
| 196 | |||
| 197 | static int event_function(void *info) | ||
| 198 | { | ||
| 199 | struct event_function_struct *efs = info; | ||
| 200 | struct perf_event *event = efs->event; | ||
| 134 | struct perf_event_context *ctx = event->ctx; | 201 | struct perf_event_context *ctx = event->ctx; |
| 135 | struct task_struct *task = ctx->task; | 202 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); |
| 203 | struct perf_event_context *task_ctx = cpuctx->task_ctx; | ||
| 204 | int ret = 0; | ||
| 205 | |||
| 206 | WARN_ON_ONCE(!irqs_disabled()); | ||
| 207 | |||
| 208 | perf_ctx_lock(cpuctx, task_ctx); | ||
| 209 | /* | ||
| 210 | * Since we do the IPI call without holding ctx->lock things can have | ||
| 211 | * changed, double check we hit the task we set out to hit. | ||
| 212 | */ | ||
| 213 | if (ctx->task) { | ||
| 214 | if (ctx->task != current) { | ||
| 215 | ret = -EAGAIN; | ||
| 216 | goto unlock; | ||
| 217 | } | ||
| 218 | |||
| 219 | /* | ||
| 220 | * We only use event_function_call() on established contexts, | ||
| 221 | * and event_function() is only ever called when active (or | ||
| 222 | * rather, we'll have bailed in task_function_call() or the | ||
| 223 | * above ctx->task != current test), therefore we must have | ||
| 224 | * ctx->is_active here. | ||
| 225 | */ | ||
| 226 | WARN_ON_ONCE(!ctx->is_active); | ||
| 227 | /* | ||
| 228 | * And since we have ctx->is_active, cpuctx->task_ctx must | ||
| 229 | * match. | ||
| 230 | */ | ||
| 231 | WARN_ON_ONCE(task_ctx != ctx); | ||
| 232 | } else { | ||
| 233 | WARN_ON_ONCE(&cpuctx->ctx != ctx); | ||
| 234 | } | ||
| 235 | |||
| 236 | efs->func(event, cpuctx, ctx, efs->data); | ||
| 237 | unlock: | ||
| 238 | perf_ctx_unlock(cpuctx, task_ctx); | ||
| 239 | |||
| 240 | return ret; | ||
| 241 | } | ||
| 242 | |||
| 243 | static void event_function_local(struct perf_event *event, event_f func, void *data) | ||
| 244 | { | ||
| 245 | struct event_function_struct efs = { | ||
| 246 | .event = event, | ||
| 247 | .func = func, | ||
| 248 | .data = data, | ||
| 249 | }; | ||
| 250 | |||
| 251 | int ret = event_function(&efs); | ||
| 252 | WARN_ON_ONCE(ret); | ||
| 253 | } | ||
| 254 | |||
| 255 | static void event_function_call(struct perf_event *event, event_f func, void *data) | ||
| 256 | { | ||
| 257 | struct perf_event_context *ctx = event->ctx; | ||
| 258 | struct task_struct *task = READ_ONCE(ctx->task); /* verified in event_function */ | ||
| 259 | struct event_function_struct efs = { | ||
| 260 | .event = event, | ||
| 261 | .func = func, | ||
| 262 | .data = data, | ||
| 263 | }; | ||
| 264 | |||
| 265 | if (!event->parent) { | ||
| 266 | /* | ||
| 267 | * If this is a !child event, we must hold ctx::mutex to | ||
| 268 | * stabilize the the event->ctx relation. See | ||
| 269 | * perf_event_ctx_lock(). | ||
| 270 | */ | ||
| 271 | lockdep_assert_held(&ctx->mutex); | ||
| 272 | } | ||
| 136 | 273 | ||
| 137 | if (!task) { | 274 | if (!task) { |
| 138 | cpu_function_call(event->cpu, active, data); | 275 | cpu_function_call(event->cpu, event_function, &efs); |
| 139 | return; | 276 | return; |
| 140 | } | 277 | } |
| 141 | 278 | ||
| 142 | again: | 279 | again: |
| 143 | if (!task_function_call(task, active, data)) | 280 | if (task == TASK_TOMBSTONE) |
| 281 | return; | ||
| 282 | |||
| 283 | if (!task_function_call(task, event_function, &efs)) | ||
| 144 | return; | 284 | return; |
| 145 | 285 | ||
| 146 | raw_spin_lock_irq(&ctx->lock); | 286 | raw_spin_lock_irq(&ctx->lock); |
| 147 | if (ctx->is_active) { | 287 | /* |
| 148 | /* | 288 | * Reload the task pointer, it might have been changed by |
| 149 | * Reload the task pointer, it might have been changed by | 289 | * a concurrent perf_event_context_sched_out(). |
| 150 | * a concurrent perf_event_context_sched_out(). | 290 | */ |
| 151 | */ | 291 | task = ctx->task; |
| 152 | task = ctx->task; | 292 | if (task != TASK_TOMBSTONE) { |
| 153 | raw_spin_unlock_irq(&ctx->lock); | 293 | if (ctx->is_active) { |
| 154 | goto again; | 294 | raw_spin_unlock_irq(&ctx->lock); |
| 295 | goto again; | ||
| 296 | } | ||
| 297 | func(event, NULL, ctx, data); | ||
| 155 | } | 298 | } |
| 156 | inactive(data); | ||
| 157 | raw_spin_unlock_irq(&ctx->lock); | 299 | raw_spin_unlock_irq(&ctx->lock); |
| 158 | } | 300 | } |
| 159 | 301 | ||
| 160 | #define EVENT_OWNER_KERNEL ((void *) -1) | ||
| 161 | |||
| 162 | static bool is_kernel_event(struct perf_event *event) | ||
| 163 | { | ||
| 164 | return event->owner == EVENT_OWNER_KERNEL; | ||
| 165 | } | ||
| 166 | |||
| 167 | #define PERF_FLAG_ALL (PERF_FLAG_FD_NO_GROUP |\ | 302 | #define PERF_FLAG_ALL (PERF_FLAG_FD_NO_GROUP |\ |
| 168 | PERF_FLAG_FD_OUTPUT |\ | 303 | PERF_FLAG_FD_OUTPUT |\ |
| 169 | PERF_FLAG_PID_CGROUP |\ | 304 | PERF_FLAG_PID_CGROUP |\ |
| @@ -368,28 +503,6 @@ static inline u64 perf_event_clock(struct perf_event *event) · 198 unmodified lines | |||
| 368 | return event->clock(); | 503 | return event->clock(); |
| 369 | } | 504 | } |
| 370 | 505 | ||
| 371 | static inline struct perf_cpu_context * | ||
| 372 | __get_cpu_context(struct perf_event_context *ctx) | ||
| 373 | { | ||
| 374 | return this_cpu_ptr(ctx->pmu->pmu_cpu_context); | ||
| 375 | } | ||
| 376 | |||
| 377 | static void perf_ctx_lock(struct perf_cpu_context *cpuctx, | ||
| 378 | struct perf_event_context *ctx) | ||
| 379 | { | ||
| 380 | raw_spin_lock(&cpuctx->ctx.lock); | ||
| 381 | if (ctx) | ||
| 382 | raw_spin_lock(&ctx->lock); | ||
| 383 | } | ||
| 384 | |||
| 385 | static void perf_ctx_unlock(struct perf_cpu_context *cpuctx, | ||
| 386 | struct perf_event_context *ctx) | ||
| 387 | { | ||
| 388 | if (ctx) | ||
| 389 | raw_spin_unlock(&ctx->lock); | ||
| 390 | raw_spin_unlock(&cpuctx->ctx.lock); | ||
| 391 | } | ||
| 392 | |||
| 393 | #ifdef CONFIG_CGROUP_PERF | 506 | #ifdef CONFIG_CGROUP_PERF |
| 394 | 507 | ||
| 395 | static inline bool | 508 | static inline bool |
| @@ -579,13 +692,7 @@ static inline void perf_cgroup_sched_out(struct task_struct *task, · 183 unmodified lines | |||
| 579 | * we are holding the rcu lock | 692 | * we are holding the rcu lock |
| 580 | */ | 693 | */ |
| 581 | cgrp1 = perf_cgroup_from_task(task, NULL); | 694 | cgrp1 = perf_cgroup_from_task(task, NULL); |
| 582 | 695 | cgrp2 = perf_cgroup_from_task(next, NULL); | |
| 583 | /* | ||
| 584 | * next is NULL when called from perf_event_enable_on_exec() | ||
| 585 | * that will systematically cause a cgroup_switch() | ||
| 586 | */ | ||
| 587 | if (next) | ||
| 588 | cgrp2 = perf_cgroup_from_task(next, NULL); | ||
| 589 | 696 | ||
| 590 | /* | 697 | /* |
| 591 | * only schedule out current cgroup events if we know | 698 | * only schedule out current cgroup events if we know |
| @@ -611,8 +718,6 @@ static inline void perf_cgroup_sched_in(struct task_struct *prev, · 19 unmodified lines | |||
| 611 | * we are holding the rcu lock | 718 | * we are holding the rcu lock |
| 612 | */ | 719 | */ |
| 613 | cgrp1 = perf_cgroup_from_task(task, NULL); | 720 | cgrp1 = perf_cgroup_from_task(task, NULL); |
| 614 | |||
| 615 | /* prev can never be NULL */ | ||
| 616 | cgrp2 = perf_cgroup_from_task(prev, NULL); | 721 | cgrp2 = perf_cgroup_from_task(prev, NULL); |
| 617 | 722 | ||
| 618 | /* | 723 | /* |
| @@ -917,7 +1022,7 @@ static void put_ctx(struct perf_event_context *ctx) · 298 unmodified lines | |||
| 917 | if (atomic_dec_and_test(&ctx->refcount)) { | 1022 | if (atomic_dec_and_test(&ctx->refcount)) { |
| 918 | if (ctx->parent_ctx) | 1023 | if (ctx->parent_ctx) |
| 919 | put_ctx(ctx->parent_ctx); | 1024 | put_ctx(ctx->parent_ctx); |
| 920 | if (ctx->task) | 1025 | if (ctx->task && ctx->task != TASK_TOMBSTONE) |
| 921 | put_task_struct(ctx->task); | 1026 | put_task_struct(ctx->task); |
| 922 | call_rcu(&ctx->rcu_head, free_ctx); | 1027 | call_rcu(&ctx->rcu_head, free_ctx); |
| 923 | } | 1028 | } |
| @@ -934,9 +1039,8 @@ static void put_ctx(struct perf_event_context *ctx) · 10 unmodified lines | |||
| 934 | * perf_event_context::mutex nests and those are: | 1039 | * perf_event_context::mutex nests and those are: |
| 935 | * | 1040 | * |
| 936 | * - perf_event_exit_task_context() [ child , 0 ] | 1041 | * - perf_event_exit_task_context() [ child , 0 ] |
| 937 | * __perf_event_exit_task() | 1042 | * perf_event_exit_event() |
| 938 | * sync_child_event() | 1043 | * put_event() [ parent, 1 ] |
| 939 | * put_event() [ parent, 1 ] | ||
| 940 | * | 1044 | * |
| 941 | * - perf_event_init_context() [ parent, 0 ] | 1045 | * - perf_event_init_context() [ parent, 0 ] |
| 942 | * inherit_task_group() | 1046 | * inherit_task_group() |
| @@ -979,8 +1083,8 @@ static void put_ctx(struct perf_event_context *ctx) · 36 unmodified lines | |||
| 979 | * Lock order: | 1083 | * Lock order: |
| 980 | * task_struct::perf_event_mutex | 1084 | * task_struct::perf_event_mutex |
| 981 | * perf_event_context::mutex | 1085 | * perf_event_context::mutex |
| 982 | * perf_event_context::lock | ||
| 983 | * perf_event::child_mutex; | 1086 | * perf_event::child_mutex; |
| 1087 | * perf_event_context::lock | ||
| 984 | * perf_event::mmap_mutex | 1088 | * perf_event::mmap_mutex |
| 985 | * mmap_sem | 1089 | * mmap_sem |
| 986 | */ | 1090 | */ |
| @@ -1078,6 +1182,7 @@ static u64 primary_event_id(struct perf_event *event) · 91 unmodified lines | |||
| 1078 | 1182 | ||
| 1079 | /* | 1183 | /* |
| 1080 | * Get the perf_event_context for a task and lock it. | 1184 | * Get the perf_event_context for a task and lock it. |
| 1185 | * | ||
| 1081 | * This has to cope with with the fact that until it is locked, | 1186 | * This has to cope with with the fact that until it is locked, |
| 1082 | * the context could get moved to another task. | 1187 | * the context could get moved to another task. |
| 1083 | */ | 1188 | */ |
| @@ -1118,9 +1223,12 @@ retry: · 34 unmodified lines | |||
| 1118 | goto retry; | 1223 | goto retry; |
| 1119 | } | 1224 | } |
| 1120 | 1225 | ||
| 1121 | if (!atomic_inc_not_zero(&ctx->refcount)) { | 1226 | if (ctx->task == TASK_TOMBSTONE || |
| 1227 | !atomic_inc_not_zero(&ctx->refcount)) { | ||
| 1122 | raw_spin_unlock(&ctx->lock); | 1228 | raw_spin_unlock(&ctx->lock); |
| 1123 | ctx = NULL; | 1229 | ctx = NULL; |
| 1230 | } else { | ||
| 1231 | WARN_ON_ONCE(ctx->task != task); | ||
| 1124 | } | 1232 | } |
| 1125 | } | 1233 | } |
| 1126 | rcu_read_unlock(); | 1234 | rcu_read_unlock(); |
| @@ -1246,6 +1354,8 @@ ctx_group_list(struct perf_event *event, struct perf_event_context *ctx) · 119 unmodified lines | |||
| 1246 | static void | 1354 | static void |
| 1247 | list_add_event(struct perf_event *event, struct perf_event_context *ctx) | 1355 | list_add_event(struct perf_event *event, struct perf_event_context *ctx) |
| 1248 | { | 1356 | { |
| 1357 | lockdep_assert_held(&ctx->lock); | ||
| 1358 | |||
| 1249 | WARN_ON_ONCE(event->attach_state & PERF_ATTACH_CONTEXT); | 1359 | WARN_ON_ONCE(event->attach_state & PERF_ATTACH_CONTEXT); |
| 1250 | event->attach_state |= PERF_ATTACH_CONTEXT; | 1360 | event->attach_state |= PERF_ATTACH_CONTEXT; |
| 1251 | 1361 | ||
| @@ -1448,11 +1558,14 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) · 196 unmodified lines | |||
| 1448 | 1558 | ||
| 1449 | if (is_cgroup_event(event)) { | 1559 | if (is_cgroup_event(event)) { |
| 1450 | ctx->nr_cgroups--; | 1560 | ctx->nr_cgroups--; |
| 1561 | /* | ||
| 1562 | * Because cgroup events are always per-cpu events, this will | ||
| 1563 | * always be called from the right CPU. | ||
| 1564 | */ | ||
| 1451 | cpuctx = __get_cpu_context(ctx); | 1565 | cpuctx = __get_cpu_context(ctx); |
| 1452 | /* | 1566 | /* |
| 1453 | * if there are no more cgroup events | 1567 | * If there are no more cgroup events then clear cgrp to avoid |
| 1454 | * then cler cgrp to avoid stale pointer | 1568 | * stale pointer in update_cgrp_time_from_cpuctx(). |
| 1455 | * in update_cgrp_time_from_cpuctx() | ||
| 1456 | */ | 1569 | */ |
| 1457 | if (!ctx->nr_cgroups) | 1570 | if (!ctx->nr_cgroups) |
| 1458 | cpuctx->cgrp = NULL; | 1571 | cpuctx->cgrp = NULL; |
| @@ -1530,45 +1643,11 @@ out: · 71 unmodified lines | |||
| 1530 | perf_event__header_size(tmp); | 1643 | perf_event__header_size(tmp); |
| 1531 | } | 1644 | } |
| 1532 | 1645 | ||
| 1533 | /* | ||
| 1534 | * User event without the task. | ||
| 1535 | */ | ||
| 1536 | static bool is_orphaned_event(struct perf_event *event) | 1646 | static bool is_orphaned_event(struct perf_event *event) |
| 1537 | { | 1647 | { |
| 1538 | return event && !is_kernel_event(event) && !event->owner; | 1648 | return event->state == PERF_EVENT_STATE_EXIT; |
| 1539 | } | 1649 | } |
| 1540 | 1650 | ||
| 1541 | /* | ||
| 1542 | * Event has a parent but parent's task finished and it's | ||
| 1543 | * alive only because of children holding refference. | ||
| 1544 | */ | ||
| 1545 | static bool is_orphaned_child(struct perf_event *event) | ||
| 1546 | { | ||
| 1547 | return is_orphaned_event(event->parent); | ||
| 1548 | } | ||
| 1549 | |||
| 1550 | static void orphans_remove_work(struct work_struct *work); | ||
| 1551 | |||
| 1552 | static void schedule_orphans_remove(struct perf_event_context *ctx) | ||
| 1553 | { | ||
| 1554 | if (!ctx->task || ctx->orphans_remove_sched || !perf_wq) | ||
| 1555 | return; | ||
| 1556 | |||
| 1557 | if (queue_delayed_work(perf_wq, &ctx->orphans_remove, 1)) { | ||
| 1558 | get_ctx(ctx); | ||
| 1559 | ctx->orphans_remove_sched = true; | ||
| 1560 | } | ||
| 1561 | } | ||
| 1562 | |||
| 1563 | static int __init perf_workqueue_init(void) | ||
| 1564 | { | ||
| 1565 | perf_wq = create_singlethread_workqueue("perf"); | ||
| 1566 | WARN(!perf_wq, "failed to create perf workqueue\n"); | ||
| 1567 | return perf_wq ? 0 : -1; | ||
| 1568 | } | ||
| 1569 | |||
| 1570 | core_initcall(perf_workqueue_init); | ||
| 1571 | |||
| 1572 | static inline int pmu_filter_match(struct perf_event *event) | 1651 | static inline int pmu_filter_match(struct perf_event *event) |
| 1573 | { | 1652 | { |
| 1574 | struct pmu *pmu = event->pmu; | 1653 | struct pmu *pmu = event->pmu; |
| @@ -1629,9 +1708,6 @@ event_sched_out(struct perf_event *event, · 54 unmodified lines | |||
| 1629 | if (event->attr.exclusive || !cpuctx->active_oncpu) | 1708 | if (event->attr.exclusive || !cpuctx->active_oncpu) |
| 1630 | cpuctx->exclusive = 0; | 1709 | cpuctx->exclusive = 0; |
| 1631 | 1710 | ||
| 1632 | if (is_orphaned_child(event)) | ||
| 1633 | schedule_orphans_remove(ctx); | ||
| 1634 | |||
| 1635 | perf_pmu_enable(event->pmu); | 1711 | perf_pmu_enable(event->pmu); |
| 1636 | } | 1712 | } |
| 1637 | 1713 | ||
| @@ -1655,21 +1731,8 @@ group_sched_out(struct perf_event *group_event, · 17 unmodified lines | |||
| 1655 | cpuctx->exclusive = 0; | 1731 | cpuctx->exclusive = 0; |
| 1656 | } | 1732 | } |
| 1657 | 1733 | ||
| 1658 | struct remove_event { | 1734 | #define DETACH_GROUP 0x01UL |
| 1659 | struct perf_event *event; | 1735 | #define DETACH_STATE 0x02UL |
| 1660 | bool detach_group; | ||
| 1661 | }; | ||
| 1662 | |||
| 1663 | static void ___perf_remove_from_context(void *info) | ||
| 1664 | { | ||
| 1665 | struct remove_event *re = info; | ||
| 1666 | struct perf_event *event = re->event; | ||
| 1667 | struct perf_event_context *ctx = event->ctx; | ||
| 1668 | |||
| 1669 | if (re->detach_group) | ||
| 1670 | perf_group_detach(event); | ||
| 1671 | list_del_event(event, ctx); | ||
| 1672 | } | ||
| 1673 | 1736 | ||
| 1674 | /* | 1737 | /* |
| 1675 | * Cross CPU call to remove a performance event | 1738 | * Cross CPU call to remove a performance event |
| @@ -1677,33 +1740,33 @@ static void ___perf_remove_from_context(void *info) · 1 unmodified line | |||
| 1677 | * We disable the event on the hardware level first. After that we | 1740 | * We disable the event on the hardware level first. After that we |
| 1678 | * remove it from the context list. | 1741 | * remove it from the context list. |
| 1679 | */ | 1742 | */ |
| 1680 | static int __perf_remove_from_context(void *info) | 1743 | static void |
| 1744 | __perf_remove_from_context(struct perf_event *event, | ||
| 1745 | struct perf_cpu_context *cpuctx, | ||
| 1746 | struct perf_event_context *ctx, | ||
| 1747 | void *info) | ||
| 1681 | { | 1748 | { |
| 1682 | struct remove_event *re = info; | 1749 | unsigned long flags = (unsigned long)info; |
| 1683 | struct perf_event *event = re->event; | ||
| 1684 | struct perf_event_context *ctx = event->ctx; | ||
| 1685 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | ||
| 1686 | 1750 | ||
| 1687 | raw_spin_lock(&ctx->lock); | ||
| 1688 | event_sched_out(event, cpuctx, ctx); | 1751 | event_sched_out(event, cpuctx, ctx); |
| 1689 | if (re->detach_group) | 1752 | if (flags & DETACH_GROUP) |
| 1690 | perf_group_detach(event); | 1753 | perf_group_detach(event); |
| 1691 | list_del_event(event, ctx); | 1754 | list_del_event(event, ctx); |
| 1692 | if (!ctx->nr_events && cpuctx->task_ctx == ctx) { | 1755 | if (flags & DETACH_STATE) |
| 1756 | event->state = PERF_EVENT_STATE_EXIT; | ||
| 1757 | |||
| 1758 | if (!ctx->nr_events && ctx->is_active) { | ||
| 1693 | ctx->is_active = 0; | 1759 | ctx->is_active = 0; |
| 1694 | cpuctx->task_ctx = NULL; | 1760 | if (ctx->task) { |
| 1761 | WARN_ON_ONCE(cpuctx->task_ctx != ctx); | ||
| 1762 | cpuctx->task_ctx = NULL; | ||
| 1763 | } | ||
| 1695 | } | 1764 | } |
| 1696 | raw_spin_unlock(&ctx->lock); | ||
| 1697 | |||
| 1698 | return 0; | ||
| 1699 | } | 1765 | } |
| 1700 | 1766 | ||
| 1701 | /* | 1767 | /* |
| 1702 | * Remove the event from a task's (or a CPU's) list of events. | 1768 | * Remove the event from a task's (or a CPU's) list of events. |
| 1703 | * | 1769 | * |
| 1704 | * CPU events are removed with a smp call. For task events we only | ||
| 1705 | * call when the task is on a CPU. | ||
| 1706 | * | ||
| 1707 | * If event->ctx is a cloned context, callers must make sure that | 1770 | * If event->ctx is a cloned context, callers must make sure that |
| 1708 | * every task struct that event->ctx->task could possibly point to | 1771 | * every task struct that event->ctx->task could possibly point to |
| 1709 | * remains valid. This is OK when called from perf_release since | 1772 | * remains valid. This is OK when called from perf_release since |
| @@ -1711,73 +1774,32 @@ static int __perf_remove_from_context(void *info) · 1 unmodified line | |||
| 1711 | * When called from perf_event_exit_task, it's OK because the | 1774 | * When called from perf_event_exit_task, it's OK because the |
| 1712 | * context has been detached from its task. | 1775 | * context has been detached from its task. |
| 1713 | */ | 1776 | */ |
| 1714 | static void perf_remove_from_context(struct perf_event *event, bool detach_group) | 1777 | static void perf_remove_from_context(struct perf_event *event, unsigned long flags) |
| 1715 | { | 1778 | { |
| 1716 | struct perf_event_context *ctx = event->ctx; | 1779 | lockdep_assert_held(&event->ctx->mutex); |
| 1717 | struct remove_event re = { | ||
| 1718 | .event = event, | ||
| 1719 | .detach_group = detach_group, | ||
| 1720 | }; | ||
| 1721 | 1780 | ||
| 1722 | lockdep_assert_held(&ctx->mutex); | 1781 | event_function_call(event, __perf_remove_from_context, (void *)flags); |
| 1723 | |||
| 1724 | event_function_call(event, __perf_remove_from_context, | ||
| 1725 | ___perf_remove_from_context, &re); | ||
| 1726 | } | 1782 | } |
| 1727 | 1783 | ||
| 1728 | /* | 1784 | /* |
| 1729 | * Cross CPU call to disable a performance event | 1785 | * Cross CPU call to disable a performance event |
| 1730 | */ | 1786 | */ |
| 1731 | int __perf_event_disable(void *info) | 1787 | static void __perf_event_disable(struct perf_event *event, |
| 1732 | { | 1788 | struct perf_cpu_context *cpuctx, |
| 1733 | struct perf_event *event = info; | 1789 | struct perf_event_context *ctx, |
| 1734 | struct perf_event_context *ctx = event->ctx; | 1790 | void *info) |
| 1735 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | ||
| 1736 | |||
| 1737 | /* | ||
| 1738 | * If this is a per-task event, need to check whether this | ||
| 1739 | * event's task is the current task on this cpu. | ||
| 1740 | * | ||
| 1741 | * Can trigger due to concurrent perf_event_context_sched_out() | ||
| 1742 | * flipping contexts around. | ||
| 1743 | */ | ||
| 1744 | if (ctx->task && cpuctx->task_ctx != ctx) | ||
| 1745 | return -EINVAL; | ||
| 1746 | |||
| 1747 | raw_spin_lock(&ctx->lock); | ||
| 1748 | |||
| 1749 | /* | ||
| 1750 | * If the event is on, turn it off. | ||
| 1751 | * If it is in error state, leave it in error state. | ||
| 1752 | */ | ||
| 1753 | if (event->state >= PERF_EVENT_STATE_INACTIVE) { | ||
| 1754 | update_context_time(ctx); | ||
| 1755 | update_cgrp_time_from_event(event); | ||
| 1756 | update_group_times(event); | ||
| 1757 | if (event == event->group_leader) | ||
| 1758 | group_sched_out(event, cpuctx, ctx); | ||
| 1759 | else | ||
| 1760 | event_sched_out(event, cpuctx, ctx); | ||
| 1761 | event->state = PERF_EVENT_STATE_OFF; | ||
| 1762 | } | ||
| 1763 | |||
| 1764 | raw_spin_unlock(&ctx->lock); | ||
| 1765 | |||
| 1766 | return 0; | ||
| 1767 | } | ||
| 1768 | |||
| 1769 | void ___perf_event_disable(void *info) | ||
| 1770 | { | 1791 | { |
| 1771 | struct perf_event *event = info; | 1792 | if (event->state < PERF_EVENT_STATE_INACTIVE) |
| 1793 | return; | ||
| 1772 | 1794 | ||
| 1773 | /* | 1795 | update_context_time(ctx); |
| 1774 | * Since we have the lock this context can't be scheduled | 1796 | update_cgrp_time_from_event(event); |
| 1775 | * in, so we can change the state safely. | 1797 | update_group_times(event); |
| 1776 | */ | 1798 | if (event == event->group_leader) |
| 1777 | if (event->state == PERF_EVENT_STATE_INACTIVE) { | 1799 | group_sched_out(event, cpuctx, ctx); |
| 1778 | update_group_times(event); | 1800 | else |
| 1779 | event->state = PERF_EVENT_STATE_OFF; | 1801 | event_sched_out(event, cpuctx, ctx); |
| 1780 | } | 1802 | event->state = PERF_EVENT_STATE_OFF; |
| 1781 | } | 1803 | } |
| 1782 | 1804 | ||
| 1783 | /* | 1805 | /* |
| @@ -1788,7 +1810,8 @@ void ___perf_event_disable(void *info) · 4 unmodified lines | |||
| 1788 | * remains valid. This condition is satisifed when called through | 1810 | * remains valid. This condition is satisifed when called through |
| 1789 | * perf_event_for_each_child or perf_event_for_each because they | 1811 | * perf_event_for_each_child or perf_event_for_each because they |
| 1790 | * hold the top-level event's child_mutex, so any descendant that | 1812 | * hold the top-level event's child_mutex, so any descendant that |
| 1791 | * goes to exit will block in sync_child_event. | 1813 | * goes to exit will block in perf_event_exit_event(). |
| 1814 | * | ||
| 1792 | * When called from perf_pending_event it's OK because event->ctx | 1815 | * When called from perf_pending_event it's OK because event->ctx |
| 1793 | * is the current context on this CPU and preemption is disabled, | 1816 | * is the current context on this CPU and preemption is disabled, |
| 1794 | * hence we can't get into perf_event_task_sched_out for this context. | 1817 | * hence we can't get into perf_event_task_sched_out for this context. |
| @@ -1804,8 +1827,12 @@ static void _perf_event_disable(struct perf_event *event) · 9 unmodified lines | |||
| 1804 | } | 1827 | } |
| 1805 | raw_spin_unlock_irq(&ctx->lock); | 1828 | raw_spin_unlock_irq(&ctx->lock); |
| 1806 | 1829 | ||
| 1807 | event_function_call(event, __perf_event_disable, | 1830 | event_function_call(event, __perf_event_disable, NULL); |
| 1808 | ___perf_event_disable, event); | 1831 | } |
| 1832 | |||
| 1833 | void perf_event_disable_local(struct perf_event *event) | ||
| 1834 | { | ||
| 1835 | event_function_local(event, __perf_event_disable, NULL); | ||
| 1809 | } | 1836 | } |
| 1810 | 1837 | ||
| 1811 | /* | 1838 | /* |
| @@ -1918,9 +1945,6 @@ event_sched_in(struct perf_event *event, · 106 unmodified lines | |||
| 1918 | if (event->attr.exclusive) | 1945 | if (event->attr.exclusive) |
| 1919 | cpuctx->exclusive = 1; | 1946 | cpuctx->exclusive = 1; |
| 1920 | 1947 | ||
| 1921 | if (is_orphaned_child(event)) | ||
| 1922 | schedule_orphans_remove(ctx); | ||
| 1923 | |||
| 1924 | out: | 1948 | out: |
| 1925 | perf_pmu_enable(event->pmu); | 1949 | perf_pmu_enable(event->pmu); |
| 1926 | 1950 | ||
| @@ -2039,7 +2063,8 @@ static void add_event_to_ctx(struct perf_event *event, · 112 unmodified lines | |||
| 2039 | event->tstamp_stopped = tstamp; | 2063 | event->tstamp_stopped = tstamp; |
| 2040 | } | 2064 | } |
| 2041 | 2065 | ||
| 2042 | static void task_ctx_sched_out(struct perf_event_context *ctx); | 2066 | static void task_ctx_sched_out(struct perf_cpu_context *cpuctx, |
| 2067 | struct perf_event_context *ctx); | ||
| 2043 | static void | 2068 | static void |
| 2044 | ctx_sched_in(struct perf_event_context *ctx, | 2069 | ctx_sched_in(struct perf_event_context *ctx, |
| 2045 | struct perf_cpu_context *cpuctx, | 2070 | struct perf_cpu_context *cpuctx, |
| @@ -2058,16 +2083,15 @@ static void perf_event_sched_in(struct perf_cpu_context *cpuctx, · 12 unmodified lines | |||
| 2058 | ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE, task); | 2083 | ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE, task); |
| 2059 | } | 2084 | } |
| 2060 | 2085 | ||
| 2061 | static void ___perf_install_in_context(void *info) | 2086 | static void ctx_resched(struct perf_cpu_context *cpuctx, |
| 2087 | struct perf_event_context *task_ctx) | ||
| 2062 | { | 2088 | { |
| 2063 | struct perf_event *event = info; | 2089 | perf_pmu_disable(cpuctx->ctx.pmu); |
| 2064 | struct perf_event_context *ctx = event->ctx; | 2090 | if (task_ctx) |
| 2065 | 2091 | task_ctx_sched_out(cpuctx, task_ctx); | |
| 2066 | /* | 2092 | cpu_ctx_sched_out(cpuctx, EVENT_ALL); |
| 2067 | * Since the task isn't running, its safe to add the event, us holding | 2093 | perf_event_sched_in(cpuctx, task_ctx, current); |
| 2068 | * the ctx->lock ensures the task won't get scheduled in. | 2094 | perf_pmu_enable(cpuctx->ctx.pmu); |
| 2069 | */ | ||
| 2070 | add_event_to_ctx(event, ctx); | ||
| 2071 | } | 2095 | } |
| 2072 | 2096 | ||
| 2073 | /* | 2097 | /* |
| @@ -2077,55 +2101,31 @@ static void ___perf_install_in_context(void *info) · 3 unmodified lines | |||
| 2077 | */ | 2101 | */ |
| 2078 | static int __perf_install_in_context(void *info) | 2102 | static int __perf_install_in_context(void *info) |
| 2079 | { | 2103 | { |
| 2080 | struct perf_event *event = info; | 2104 | struct perf_event_context *ctx = info; |
| 2081 | struct perf_event_context *ctx = event->ctx; | ||
| 2082 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | 2105 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); |
| 2083 | struct perf_event_context *task_ctx = cpuctx->task_ctx; | 2106 | struct perf_event_context *task_ctx = cpuctx->task_ctx; |
| 2084 | struct task_struct *task = current; | ||
| 2085 | |||
| 2086 | perf_ctx_lock(cpuctx, task_ctx); | ||
| 2087 | perf_pmu_disable(cpuctx->ctx.pmu); | ||
| 2088 | 2107 | ||
| 2089 | /* | 2108 | raw_spin_lock(&cpuctx->ctx.lock); |
| 2090 | * If there was an active task_ctx schedule it out. | 2109 | if (ctx->task) { |
| 2091 | */ | ||
| 2092 | if (task_ctx) | ||
| 2093 | task_ctx_sched_out(task_ctx); | ||
| 2094 | |||
| 2095 | /* | ||
| 2096 | * If the context we're installing events in is not the | ||
| 2097 | * active task_ctx, flip them. | ||
| 2098 | */ | ||
| 2099 | if (ctx->task && task_ctx != ctx) { | ||
| 2100 | if (task_ctx) | ||
| 2101 | raw_spin_unlock(&task_ctx->lock); | ||
| 2102 | raw_spin_lock(&ctx->lock); | 2110 | raw_spin_lock(&ctx->lock); |
| 2111 | /* | ||
| 2112 | * If we hit the 'wrong' task, we've since scheduled and | ||
| 2113 | * everything should be sorted, nothing to do! | ||
| 2114 | */ | ||
| 2103 | task_ctx = ctx; | 2115 | task_ctx = ctx; |
| 2104 | } | 2116 | if (ctx->task != current) |
| 2117 | goto unlock; | ||
| 2105 | 2118 | ||
| 2106 | if (task_ctx) { | 2119 | /* |
| 2107 | cpuctx->task_ctx = task_ctx; | 2120 | * If task_ctx is set, it had better be to us. |
| 2108 | task = task_ctx->task; | 2121 | */ |
| 2122 | WARN_ON_ONCE(cpuctx->task_ctx != ctx && cpuctx->task_ctx); | ||
| 2123 | } else if (task_ctx) { | ||
| 2124 | raw_spin_lock(&task_ctx->lock); | ||
| 2109 | } | 2125 | } |
| 2110 | 2126 | ||
| 2111 | cpu_ctx_sched_out(cpuctx, EVENT_ALL); | 2127 | ctx_resched(cpuctx, task_ctx); |
| 2112 | 2128 | unlock: | |
| 2113 | update_context_time(ctx); | ||
| 2114 | /* | ||
| 2115 | * update cgrp time only if current cgrp | ||
| 2116 | * matches event->cgrp. Must be done before | ||
| 2117 | * calling add_event_to_ctx() | ||
| 2118 | */ | ||
| 2119 | update_cgrp_time_from_event(event); | ||
| 2120 | |||
| 2121 | add_event_to_ctx(event, ctx); | ||
| 2122 | |||
| 2123 | /* | ||
| 2124 | * Schedule everything back in | ||
| 2125 | */ | ||
| 2126 | perf_event_sched_in(cpuctx, task_ctx, task); | ||
| 2127 | |||
| 2128 | perf_pmu_enable(cpuctx->ctx.pmu); | ||
| 2129 | perf_ctx_unlock(cpuctx, task_ctx); | 2129 | perf_ctx_unlock(cpuctx, task_ctx); |
| 2130 | 2130 | ||
| 2131 | return 0; | 2131 | return 0; |
| @@ -2133,27 +2133,54 @@ static int __perf_install_in_context(void *info) · 1 unmodified line | |||
| 2133 | 2133 | ||
| 2134 | /* | 2134 | /* |
| 2135 | * Attach a performance event to a context | 2135 | * Attach a performance event to a context |
| 2136 | * | ||
| 2137 | * First we add the event to the list with the hardware enable bit | ||
| 2138 | * in event->hw_config cleared. | ||
| 2139 | * | ||
| 2140 | * If the event is attached to a task which is on a CPU we use a smp | ||
| 2141 | * call to enable it in the task context. The task might have been | ||
| 2142 | * scheduled away, but we check this in the smp call again. | ||
| 2143 | */ | 2136 | */ |
| 2144 | static void | 2137 | static void |
| 2145 | perf_install_in_context(struct perf_event_context *ctx, | 2138 | perf_install_in_context(struct perf_event_context *ctx, |
| 2146 | struct perf_event *event, | 2139 | struct perf_event *event, |
| 2147 | int cpu) | 2140 | int cpu) |
| 2148 | { | 2141 | { |
| 2142 | struct task_struct *task = NULL; | ||
| 2143 | |||
| 2149 | lockdep_assert_held(&ctx->mutex); | 2144 | lockdep_assert_held(&ctx->mutex); |
| 2150 | 2145 | ||
| 2151 | event->ctx = ctx; | 2146 | event->ctx = ctx; |
| 2152 | if (event->cpu != -1) | 2147 | if (event->cpu != -1) |
| 2153 | event->cpu = cpu; | 2148 | event->cpu = cpu; |
| 2154 | 2149 | ||
| 2155 | event_function_call(event, __perf_install_in_context, | 2150 | /* |
| 2156 | ___perf_install_in_context, event); | 2151 | * Installing events is tricky because we cannot rely on ctx->is_active |
| 2152 | * to be set in case this is the nr_events 0 -> 1 transition. | ||
| 2153 | * | ||
| 2154 | * So what we do is we add the event to the list here, which will allow | ||
| 2155 | * a future context switch to DTRT and then send a racy IPI. If the IPI | ||
| 2156 | * fails to hit the right task, this means a context switch must have | ||
| 2157 | * happened and that will have taken care of business. | ||
| 2158 | */ | ||
| 2159 | raw_spin_lock_irq(&ctx->lock); | ||
| 2160 | task = ctx->task; | ||
| 2161 | /* | ||
| 2162 | * Worse, we cannot even rely on the ctx actually existing anymore. If | ||
| 2163 | * between find_get_context() and perf_install_in_context() the task | ||
| 2164 | * went through perf_event_exit_task() its dead and we should not be | ||
| 2165 | * adding new events. | ||
| 2166 | */ | ||
| 2167 | if (task == TASK_TOMBSTONE) { | ||
| 2168 | raw_spin_unlock_irq(&ctx->lock); | ||
| 2169 | return; | ||
| 2170 | } | ||
| 2171 | update_context_time(ctx); | ||
| 2172 | /* | ||
| 2173 | * Update cgrp time only if current cgrp matches event->cgrp. | ||
| 2174 | * Must be done before calling add_event_to_ctx(). | ||
| 2175 | */ | ||
| 2176 | update_cgrp_time_from_event(event); | ||
| 2177 | add_event_to_ctx(event, ctx); | ||
| 2178 | raw_spin_unlock_irq(&ctx->lock); | ||
| 2179 | |||
| 2180 | if (task) | ||
| 2181 | task_function_call(task, __perf_install_in_context, ctx); | ||
| 2182 | else | ||
| 2183 | cpu_function_call(cpu, __perf_install_in_context, ctx); | ||
| 2157 | } | 2184 | } |
| 2158 | 2185 | ||
| 2159 | /* | 2186 | /* |
| @@ -2180,43 +2207,30 @@ static void __perf_event_mark_enabled(struct perf_event *event) · 20 unmodified lines | |||
| 2180 | /* | 2207 | /* |
| 2181 | * Cross CPU call to enable a performance event | 2208 | * Cross CPU call to enable a performance event |
| 2182 | */ | 2209 | */ |
| 2183 | static int __perf_event_enable(void *info) | 2210 | static void __perf_event_enable(struct perf_event *event, |
| 2211 | struct perf_cpu_context *cpuctx, | ||
| 2212 | struct perf_event_context *ctx, | ||
| 2213 | void *info) | ||
| 2184 | { | 2214 | { |
| 2185 | struct perf_event *event = info; | ||
| 2186 | struct perf_event_context *ctx = event->ctx; | ||
| 2187 | struct perf_event *leader = event->group_leader; | 2215 | struct perf_event *leader = event->group_leader; |
| 2188 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | 2216 | struct perf_event_context *task_ctx; |
| 2189 | int err; | ||
| 2190 | 2217 | ||
| 2191 | /* | 2218 | if (event->state >= PERF_EVENT_STATE_INACTIVE || |
| 2192 | * There's a time window between 'ctx->is_active' check | 2219 | event->state <= PERF_EVENT_STATE_ERROR) |
| 2193 | * in perf_event_enable function and this place having: | 2220 | return; |
| 2194 | * - IRQs on | ||
| 2195 | * - ctx->lock unlocked | ||
| 2196 | * | ||
| 2197 | * where the task could be killed and 'ctx' deactivated | ||
| 2198 | * by perf_event_exit_task. | ||
| 2199 | */ | ||
| 2200 | if (!ctx->is_active) | ||
| 2201 | return -EINVAL; | ||
| 2202 | 2221 | ||
| 2203 | raw_spin_lock(&ctx->lock); | ||
| 2204 | update_context_time(ctx); | 2222 | update_context_time(ctx); |
| 2205 | |||
| 2206 | if (event->state >= PERF_EVENT_STATE_INACTIVE) | ||
| 2207 | goto unlock; | ||
| 2208 | |||
| 2209 | /* | ||
| 2210 | * set current task's cgroup time reference point | ||
| 2211 | */ | ||
| 2212 | perf_cgroup_set_timestamp(current, ctx); | ||
| 2213 | |||
| 2214 | __perf_event_mark_enabled(event); | 2223 | __perf_event_mark_enabled(event); |
| 2215 | 2224 | ||
| 2225 | if (!ctx->is_active) | ||
| 2226 | return; | ||
| 2227 | |||
| 2216 | if (!event_filter_match(event)) { | 2228 | if (!event_filter_match(event)) { |
| 2217 | if (is_cgroup_event(event)) | 2229 | if (is_cgroup_event(event)) { |
| 2230 | perf_cgroup_set_timestamp(current, ctx); // XXX ? | ||
| 2218 | perf_cgroup_defer_enabled(event); | 2231 | perf_cgroup_defer_enabled(event); |
| 2219 | goto unlock; | 2232 | } |
| 2233 | return; | ||
| 2220 | } | 2234 | } |
| 2221 | 2235 | ||
| 2222 | /* | 2236 | /* |
| @@ -2224,41 +2238,13 @@ static int __perf_event_enable(void *info) · 1 unmodified line | |||
| 2224 | * then don't put it on unless the group is on. | 2238 | * then don't put it on unless the group is on. |
| 2225 | */ | 2239 | */ |
| 2226 | if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE) | 2240 | if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE) |
| 2227 | goto unlock; | 2241 | return; |
| 2228 | |||
| 2229 | if (!group_can_go_on(event, cpuctx, 1)) { | ||
| 2230 | err = -EEXIST; | ||
| 2231 | } else { | ||
| 2232 | if (event == leader) | ||
| 2233 | err = group_sched_in(event, cpuctx, ctx); | ||
| 2234 | else | ||
| 2235 | err = event_sched_in(event, cpuctx, ctx); | ||
| 2236 | } | ||
| 2237 | |||
| 2238 | if (err) { | ||
| 2239 | /* | ||
| 2240 | * If this event can't go on and it's part of a | ||
| 2241 | * group, then the whole group has to come off. | ||
| 2242 | */ | ||
| 2243 | if (leader != event) { | ||
| 2244 | group_sched_out(leader, cpuctx, ctx); | ||
| 2245 | perf_mux_hrtimer_restart(cpuctx); | ||
| 2246 | } | ||
| 2247 | if (leader->attr.pinned) { | ||
| 2248 | update_group_times(leader); | ||
| 2249 | leader->state = PERF_EVENT_STATE_ERROR; | ||
| 2250 | } | ||
| 2251 | } | ||
| 2252 | |||
| 2253 | unlock: | ||
| 2254 | raw_spin_unlock(&ctx->lock); | ||
| 2255 | 2242 | ||
| 2256 | return 0; | 2243 | task_ctx = cpuctx->task_ctx; |
| 2257 | } | 2244 | if (ctx->task) |
| 2245 | WARN_ON_ONCE(task_ctx != ctx); | ||
| 2258 | 2246 | ||
| 2259 | void ___perf_event_enable(void *info) | 2247 | ctx_resched(cpuctx, task_ctx); |
| 2260 | { | ||
| 2261 | __perf_event_mark_enabled((struct perf_event *)info); | ||
| 2262 | } | 2248 | } |
| 2263 | 2249 | ||
| 2264 | /* | 2250 | /* |
| @@ -2275,7 +2261,8 @@ static void _perf_event_enable(struct perf_event *event) · 10 unmodified lines | |||
| 2275 | struct perf_event_context *ctx = event->ctx; | 2261 | struct perf_event_context *ctx = event->ctx; |
| 2276 | 2262 | ||
| 2277 | raw_spin_lock_irq(&ctx->lock); | 2263 | raw_spin_lock_irq(&ctx->lock); |
| 2278 | if (event->state >= PERF_EVENT_STATE_INACTIVE) { | 2264 | if (event->state >= PERF_EVENT_STATE_INACTIVE || |
| 2265 | event->state < PERF_EVENT_STATE_ERROR) { | ||
| 2279 | raw_spin_unlock_irq(&ctx->lock); | 2266 | raw_spin_unlock_irq(&ctx->lock); |
| 2280 | return; | 2267 | return; |
| 2281 | } | 2268 | } |
| @@ -2291,8 +2278,7 @@ static void _perf_event_enable(struct perf_event *event) · 9 unmodified lines | |||
| 2291 | event->state = PERF_EVENT_STATE_OFF; | 2278 | event->state = PERF_EVENT_STATE_OFF; |
| 2292 | raw_spin_unlock_irq(&ctx->lock); | 2279 | raw_spin_unlock_irq(&ctx->lock); |
| 2293 | 2280 | ||
| 2294 | event_function_call(event, __perf_event_enable, | 2281 | event_function_call(event, __perf_event_enable, NULL); |
| 2295 | ___perf_event_enable, event); | ||
| 2296 | } | 2282 | } |
| 2297 | 2283 | ||
| 2298 | /* | 2284 | /* |
| @@ -2342,12 +2328,27 @@ static void ctx_sched_out(struct perf_event_context *ctx, · 43 unmodified lines | |||
| 2342 | struct perf_cpu_context *cpuctx, | 2328 | struct perf_cpu_context *cpuctx, |
| 2343 | enum event_type_t event_type) | 2329 | enum event_type_t event_type) |
| 2344 | { | 2330 | { |
| 2345 | struct perf_event *event; | ||
| 2346 | int is_active = ctx->is_active; | 2331 | int is_active = ctx->is_active; |
| 2332 | struct perf_event *event; | ||
| 2347 | 2333 | ||
| 2348 | ctx->is_active &= ~event_type; | 2334 | lockdep_assert_held(&ctx->lock); |
| 2349 | if (likely(!ctx->nr_events)) | 2335 | |
| 2336 | if (likely(!ctx->nr_events)) { | ||
| 2337 | /* | ||
| 2338 | * See __perf_remove_from_context(). | ||
| 2339 | */ | ||
| 2340 | WARN_ON_ONCE(ctx->is_active); | ||
| 2341 | if (ctx->task) | ||
| 2342 | WARN_ON_ONCE(cpuctx->task_ctx); | ||
| 2350 | return; | 2343 | return; |
| 2344 | } | ||
| 2345 | |||
| 2346 | ctx->is_active &= ~event_type; | ||
| 2347 | if (ctx->task) { | ||
| 2348 | WARN_ON_ONCE(cpuctx->task_ctx != ctx); | ||
| 2349 | if (!ctx->is_active) | ||
| 2350 | cpuctx->task_ctx = NULL; | ||
| 2351 | } | ||
| 2351 | 2352 | ||
| 2352 | update_context_time(ctx); | 2353 | update_context_time(ctx); |
| 2353 | update_cgrp_time_from_cpuctx(cpuctx); | 2354 | update_cgrp_time_from_cpuctx(cpuctx); |
| @@ -2518,17 +2519,21 @@ static void perf_event_context_sched_out(struct task_struct *task, int ctxn, · 164 unmodified lines | |||
| 2518 | raw_spin_lock(&ctx->lock); | 2519 | raw_spin_lock(&ctx->lock); |
| 2519 | raw_spin_lock_nested(&next_ctx->lock, SINGLE_DEPTH_NESTING); | 2520 | raw_spin_lock_nested(&next_ctx->lock, SINGLE_DEPTH_NESTING); |
| 2520 | if (context_equiv(ctx, next_ctx)) { | 2521 | if (context_equiv(ctx, next_ctx)) { |
| 2521 | /* | 2522 | WRITE_ONCE(ctx->task, next); |
| 2522 | * XXX do we need a memory barrier of sorts | 2523 | WRITE_ONCE(next_ctx->task, task); |
| 2523 | * wrt to rcu_dereference() of perf_event_ctxp | ||
| 2524 | */ | ||
| 2525 | task->perf_event_ctxp[ctxn] = next_ctx; | ||
| 2526 | next->perf_event_ctxp[ctxn] = ctx; | ||
| 2527 | ctx->task = next; | ||
| 2528 | next_ctx->task = task; | ||
| 2529 | 2524 | ||
| 2530 | swap(ctx->task_ctx_data, next_ctx->task_ctx_data); | 2525 | swap(ctx->task_ctx_data, next_ctx->task_ctx_data); |
| 2531 | 2526 | ||
| 2527 | /* | ||
| 2528 | * RCU_INIT_POINTER here is safe because we've not | ||
| 2529 | * modified the ctx and the above modification of | ||
| 2530 | * ctx->task and ctx->task_ctx_data are immaterial | ||
| 2531 | * since those values are always verified under | ||
| 2532 | * ctx->lock which we're now holding. | ||
| 2533 | */ | ||
| 2534 | RCU_INIT_POINTER(task->perf_event_ctxp[ctxn], next_ctx); | ||
| 2535 | RCU_INIT_POINTER(next->perf_event_ctxp[ctxn], ctx); | ||
| 2536 | |||
| 2532 | do_switch = 0; | 2537 | do_switch = 0; |
| 2533 | 2538 | ||
| 2534 | perf_event_sync_stat(ctx, next_ctx); | 2539 | perf_event_sync_stat(ctx, next_ctx); |
| @@ -2541,8 +2546,7 @@ unlock: · 6 unmodified lines | |||
| 2541 | 2546 | ||
| 2542 | if (do_switch) { | 2547 | if (do_switch) { |
| 2543 | raw_spin_lock(&ctx->lock); | 2548 | raw_spin_lock(&ctx->lock); |
| 2544 | ctx_sched_out(ctx, cpuctx, EVENT_ALL); | 2549 | task_ctx_sched_out(cpuctx, ctx); |
| 2545 | cpuctx->task_ctx = NULL; | ||
| 2546 | raw_spin_unlock(&ctx->lock); | 2550 | raw_spin_unlock(&ctx->lock); |
| 2547 | } | 2551 | } |
| 2548 | } | 2552 | } |
| @@ -2637,10 +2641,9 @@ void __perf_event_task_sched_out(struct task_struct *task, · 88 unmodified lines | |||
| 2637 | perf_cgroup_sched_out(task, next); | 2641 | perf_cgroup_sched_out(task, next); |
| 2638 | } | 2642 | } |
| 2639 | 2643 | ||
| 2640 | static void task_ctx_sched_out(struct perf_event_context *ctx) | 2644 | static void task_ctx_sched_out(struct perf_cpu_context *cpuctx, |
| 2645 | struct perf_event_context *ctx) | ||
| 2641 | { | 2646 | { |
| 2642 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | ||
| 2643 | |||
| 2644 | if (!cpuctx->task_ctx) | 2647 | if (!cpuctx->task_ctx) |
| 2645 | return; | 2648 | return; |
| 2646 | 2649 | ||
| @@ -2648,7 +2651,6 @@ static void task_ctx_sched_out(struct perf_event_context *ctx) · 1 unmodified line | |||
| 2648 | return; | 2651 | return; |
| 2649 | 2652 | ||
| 2650 | ctx_sched_out(ctx, cpuctx, EVENT_ALL); | 2653 | ctx_sched_out(ctx, cpuctx, EVENT_ALL); |
| 2651 | cpuctx->task_ctx = NULL; | ||
| 2652 | } | 2654 | } |
| 2653 | 2655 | ||
| 2654 | /* | 2656 | /* |
| @@ -2725,13 +2727,22 @@ ctx_sched_in(struct perf_event_context *ctx, · 70 unmodified lines | |||
| 2725 | enum event_type_t event_type, | 2727 | enum event_type_t event_type, |
| 2726 | struct task_struct *task) | 2728 | struct task_struct *task) |
| 2727 | { | 2729 | { |
| 2728 | u64 now; | ||
| 2729 | int is_active = ctx->is_active; | 2730 | int is_active = ctx->is_active; |
| 2731 | u64 now; | ||
| 2732 | |||
| 2733 | lockdep_assert_held(&ctx->lock); | ||
| 2730 | 2734 | ||
| 2731 | ctx->is_active |= event_type; | ||
| 2732 | if (likely(!ctx->nr_events)) | 2735 | if (likely(!ctx->nr_events)) |
| 2733 | return; | 2736 | return; |
| 2734 | 2737 | ||
| 2738 | ctx->is_active |= event_type; | ||
| 2739 | if (ctx->task) { | ||
| 2740 | if (!is_active) | ||
| 2741 | cpuctx->task_ctx = ctx; | ||
| 2742 | else | ||
| 2743 | WARN_ON_ONCE(cpuctx->task_ctx != ctx); | ||
| 2744 | } | ||
| 2745 | |||
| 2735 | now = perf_clock(); | 2746 | now = perf_clock(); |
| 2736 | ctx->timestamp = now; | 2747 | ctx->timestamp = now; |
| 2737 | perf_cgroup_set_timestamp(task, ctx); | 2748 | perf_cgroup_set_timestamp(task, ctx); |
| @@ -2773,12 +2784,7 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx, · 35 unmodified lines | |||
| 2773 | * cpu flexible, task flexible. | 2784 | * cpu flexible, task flexible. |
| 2774 | */ | 2785 | */ |
| 2775 | cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE); | 2786 | cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE); |
| 2776 | 2787 | perf_event_sched_in(cpuctx, ctx, task); | |
| 2777 | if (ctx->nr_events) | ||
| 2778 | cpuctx->task_ctx = ctx; | ||
| 2779 | |||
| 2780 | perf_event_sched_in(cpuctx, cpuctx->task_ctx, task); | ||
| 2781 | |||
| 2782 | perf_pmu_enable(ctx->pmu); | 2788 | perf_pmu_enable(ctx->pmu); |
| 2783 | perf_ctx_unlock(cpuctx, ctx); | 2789 | perf_ctx_unlock(cpuctx, ctx); |
| 2784 | } | 2790 | } |
| @@ -2800,6 +2806,16 @@ void __perf_event_task_sched_in(struct task_struct *prev, · 15 unmodified lines | |||
| 2800 | struct perf_event_context *ctx; | 2806 | struct perf_event_context *ctx; |
| 2801 | int ctxn; | 2807 | int ctxn; |
| 2802 | 2808 | ||
| 2809 | /* | ||
| 2810 | * If cgroup events exist on this CPU, then we need to check if we have | ||
| 2811 | * to switch in PMU state; cgroup event are system-wide mode only. | ||
| 2812 | * | ||
| 2813 | * Since cgroup events are CPU events, we must schedule these in before | ||
| 2814 | * we schedule in the task events. | ||
| 2815 | */ | ||
| 2816 | if (atomic_read(this_cpu_ptr(&perf_cgroup_events))) | ||
| 2817 | perf_cgroup_sched_in(prev, task); | ||
| 2818 | |||
| 2803 | for_each_task_context_nr(ctxn) { | 2819 | for_each_task_context_nr(ctxn) { |
| 2804 | ctx = task->perf_event_ctxp[ctxn]; | 2820 | ctx = task->perf_event_ctxp[ctxn]; |
| 2805 | if (likely(!ctx)) | 2821 | if (likely(!ctx)) |
| @@ -2807,13 +2823,6 @@ void __perf_event_task_sched_in(struct task_struct *prev, · 1 unmodified line | |||
| 2807 | 2823 | ||
| 2808 | perf_event_context_sched_in(ctx, task); | 2824 | perf_event_context_sched_in(ctx, task); |
| 2809 | } | 2825 | } |
| 2810 | /* | ||
| 2811 | * if cgroup events exist on this CPU, then we need | ||
| 2812 | * to check if we have to switch in PMU state. | ||
| 2813 | * cgroup event are system-wide mode only | ||
| 2814 | */ | ||
| 2815 | if (atomic_read(this_cpu_ptr(&perf_cgroup_events))) | ||
| 2816 | perf_cgroup_sched_in(prev, task); | ||
| 2817 | 2826 | ||
| 2818 | if (atomic_read(&nr_switch_events)) | 2827 | if (atomic_read(&nr_switch_events)) |
| 2819 | perf_event_switch(task, prev, true); | 2828 | perf_event_switch(task, prev, true); |
| @@ -3099,46 +3108,30 @@ static int event_enable_on_exec(struct perf_event *event, · 279 unmodified lines | |||
| 3099 | static void perf_event_enable_on_exec(int ctxn) | 3108 | static void perf_event_enable_on_exec(int ctxn) |
| 3100 | { | 3109 | { |
| 3101 | struct perf_event_context *ctx, *clone_ctx = NULL; | 3110 | struct perf_event_context *ctx, *clone_ctx = NULL; |
| 3111 | struct perf_cpu_context *cpuctx; | ||
| 3102 | struct perf_event *event; | 3112 | struct perf_event *event; |
| 3103 | unsigned long flags; | 3113 | unsigned long flags; |
| 3104 | int enabled = 0; | 3114 | int enabled = 0; |
| 3105 | int ret; | ||
| 3106 | 3115 | ||
| 3107 | local_irq_save(flags); | 3116 | local_irq_save(flags); |
| 3108 | ctx = current->perf_event_ctxp[ctxn]; | 3117 | ctx = current->perf_event_ctxp[ctxn]; |
| 3109 | if (!ctx || !ctx->nr_events) | 3118 | if (!ctx || !ctx->nr_events) |
| 3110 | goto out; | 3119 | goto out; |
| 3111 | 3120 | ||
| 3112 | /* | 3121 | cpuctx = __get_cpu_context(ctx); |
| 3113 | * We must ctxsw out cgroup events to avoid conflict | 3122 | perf_ctx_lock(cpuctx, ctx); |
| 3114 | * when invoking perf_task_event_sched_in() later on | 3123 | list_for_each_entry(event, &ctx->event_list, event_entry) |
| 3115 | * in this function. Otherwise we end up trying to | 3124 | enabled |= event_enable_on_exec(event, ctx); |
| 3116 | * ctxswin cgroup events which are already scheduled | ||
| 3117 | * in. | ||
| 3118 | */ | ||
| 3119 | perf_cgroup_sched_out(current, NULL); | ||
| 3120 | |||
| 3121 | raw_spin_lock(&ctx->lock); | ||
| 3122 | task_ctx_sched_out(ctx); | ||
| 3123 | |||
| 3124 | list_for_each_entry(event, &ctx->event_list, event_entry) { | ||
| 3125 | ret = event_enable_on_exec(event, ctx); | ||
| 3126 | if (ret) | ||
| 3127 | enabled = 1; | ||
| 3128 | } | ||
| 3129 | 3125 | ||
| 3130 | /* | 3126 | /* |
| 3131 | * Unclone this context if we enabled any event. | 3127 | * Unclone and reschedule this context if we enabled any event. |
| 3132 | */ | 3128 | */ |
| 3133 | if (enabled) | 3129 | if (enabled) { |
| 3134 | clone_ctx = unclone_ctx(ctx); | 3130 | clone_ctx = unclone_ctx(ctx); |
| 3131 | ctx_resched(cpuctx, ctx); | ||
| 3132 | } | ||
| 3133 | perf_ctx_unlock(cpuctx, ctx); | ||
| 3135 | 3134 | ||
| 3136 | raw_spin_unlock(&ctx->lock); | ||
| 3137 | |||
| 3138 | /* | ||
| 3139 | * Also calls ctxswin for cgroup events, if any: | ||
| 3140 | */ | ||
| 3141 | perf_event_context_sched_in(ctx, ctx->task); | ||
| 3142 | out: | 3135 | out: |
| 3143 | local_irq_restore(flags); | 3136 | local_irq_restore(flags); |
| 3144 | 3137 | ||
| @@ -3334,7 +3327,6 @@ static void __perf_event_init_context(struct perf_event_context *ctx) · 189 unmodified lines | |||
| 3334 | INIT_LIST_HEAD(&ctx->flexible_groups); | 3327 | INIT_LIST_HEAD(&ctx->flexible_groups); |
| 3335 | INIT_LIST_HEAD(&ctx->event_list); | 3328 | INIT_LIST_HEAD(&ctx->event_list); |
| 3336 | atomic_set(&ctx->refcount, 1); | 3329 | atomic_set(&ctx->refcount, 1); |
| 3337 | INIT_DELAYED_WORK(&ctx->orphans_remove, orphans_remove_work); | ||
| 3338 | } | 3330 | } |
| 3339 | 3331 | ||
| 3340 | static struct perf_event_context * | 3332 | static struct perf_event_context * |
| @@ -3521,11 +3513,13 @@ static void unaccount_event_cpu(struct perf_event *event, int cpu) · 180 unmodified lines | |||
| 3521 | 3513 | ||
| 3522 | static void unaccount_event(struct perf_event *event) | 3514 | static void unaccount_event(struct perf_event *event) |
| 3523 | { | 3515 | { |
| 3516 | bool dec = false; | ||
| 3517 | |||
| 3524 | if (event->parent) | 3518 | if (event->parent) |
| 3525 | return; | 3519 | return; |
| 3526 | 3520 | ||
| 3527 | if (event->attach_state & PERF_ATTACH_TASK) | 3521 | if (event->attach_state & PERF_ATTACH_TASK) |
| 3528 | static_key_slow_dec_deferred(&perf_sched_events); | 3522 | dec = true; |
| 3529 | if (event->attr.mmap || event->attr.mmap_data) | 3523 | if (event->attr.mmap || event->attr.mmap_data) |
| 3530 | atomic_dec(&nr_mmap_events); | 3524 | atomic_dec(&nr_mmap_events); |
| 3531 | if (event->attr.comm) | 3525 | if (event->attr.comm) |
| @@ -3535,12 +3529,15 @@ static void unaccount_event(struct perf_event *event) · 3 unmodified lines | |||
| 3535 | if (event->attr.freq) | 3529 | if (event->attr.freq) |
| 3536 | atomic_dec(&nr_freq_events); | 3530 | atomic_dec(&nr_freq_events); |
| 3537 | if (event->attr.context_switch) { | 3531 | if (event->attr.context_switch) { |
| 3538 | static_key_slow_dec_deferred(&perf_sched_events); | 3532 | dec = true; |
| 3539 | atomic_dec(&nr_switch_events); | 3533 | atomic_dec(&nr_switch_events); |
| 3540 | } | 3534 | } |
| 3541 | if (is_cgroup_event(event)) | 3535 | if (is_cgroup_event(event)) |
| 3542 | static_key_slow_dec_deferred(&perf_sched_events); | 3536 | dec = true; |
| 3543 | if (has_branch_stack(event)) | 3537 | if (has_branch_stack(event)) |
| 3538 | dec = true; | ||
| 3539 | |||
| 3540 | if (dec) | ||
| 3544 | static_key_slow_dec_deferred(&perf_sched_events); | 3541 | static_key_slow_dec_deferred(&perf_sched_events); |
| 3545 | 3542 | ||
| 3546 | unaccount_event_cpu(event, event->cpu); | 3543 | unaccount_event_cpu(event, event->cpu); |
| @@ -3556,7 +3553,7 @@ static void unaccount_event(struct perf_event *event) · 9 unmodified lines | |||
| 3556 | * 3) two matching events on the same context. | 3553 | * 3) two matching events on the same context. |
| 3557 | * | 3554 | * |
| 3558 | * The former two cases are handled in the allocation path (perf_event_alloc(), | 3555 | * The former two cases are handled in the allocation path (perf_event_alloc(), |
| 3559 | * __free_event()), the latter -- before the first perf_install_in_context(). | 3556 | * _free_event()), the latter -- before the first perf_install_in_context(). |
| 3560 | */ | 3557 | */ |
| 3561 | static int exclusive_event_init(struct perf_event *event) | 3558 | static int exclusive_event_init(struct perf_event *event) |
| 3562 | { | 3559 | { |
| @@ -3631,29 +3628,6 @@ static bool exclusive_event_installable(struct perf_event *event, · 68 unmodified lines | |||
| 3631 | return true; | 3628 | return true; |
| 3632 | } | 3629 | } |
| 3633 | 3630 | ||
| 3634 | static void __free_event(struct perf_event *event) | ||
| 3635 | { | ||
| 3636 | if (!event->parent) { | ||
| 3637 | if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) | ||
| 3638 | put_callchain_buffers(); | ||
| 3639 | } | ||
| 3640 | |||
| 3641 | perf_event_free_bpf_prog(event); | ||
| 3642 | |||
| 3643 | if (event->destroy) | ||
| 3644 | event->destroy(event); | ||
| 3645 | |||
| 3646 | if (event->ctx) | ||
| 3647 | put_ctx(event->ctx); | ||
| 3648 | |||
| 3649 | if (event->pmu) { | ||
| 3650 | exclusive_event_destroy(event); | ||
| 3651 | module_put(event->pmu->module); | ||
| 3652 | } | ||
| 3653 | |||
| 3654 | call_rcu(&event->rcu_head, free_event_rcu); | ||
| 3655 | } | ||
| 3656 | |||
| 3657 | static void _free_event(struct perf_event *event) | 3631 | static void _free_event(struct perf_event *event) |
| 3658 | { | 3632 | { |
| 3659 | irq_work_sync(&event->pending); | 3633 | irq_work_sync(&event->pending); |
| @@ -3675,7 +3649,25 @@ static void _free_event(struct perf_event *event) · 15 unmodified lines | |||
| 3675 | if (is_cgroup_event(event)) | 3649 | if (is_cgroup_event(event)) |
| 3676 | perf_detach_cgroup(event); | 3650 | perf_detach_cgroup(event); |
| 3677 | 3651 | ||
| 3678 | __free_event(event); | 3652 | if (!event->parent) { |
| 3653 | if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) | ||
| 3654 | put_callchain_buffers(); | ||
| 3655 | } | ||
| 3656 | |||
| 3657 | perf_event_free_bpf_prog(event); | ||
| 3658 | |||
| 3659 | if (event->destroy) | ||
| 3660 | event->destroy(event); | ||
| 3661 | |||
| 3662 | if (event->ctx) | ||
| 3663 | put_ctx(event->ctx); | ||
| 3664 | |||
| 3665 | if (event->pmu) { | ||
| 3666 | exclusive_event_destroy(event); | ||
| 3667 | module_put(event->pmu->module); | ||
| 3668 | } | ||
| 3669 | |||
| 3670 | call_rcu(&event->rcu_head, free_event_rcu); | ||
| 3679 | } | 3671 | } |
| 3680 | 3672 | ||
| 3681 | /* | 3673 | /* |
| @@ -3702,14 +3694,13 @@ static void perf_remove_from_owner(struct perf_event *event) · 20 unmodified lines | |||
| 3702 | struct task_struct *owner; | 3694 | struct task_struct *owner; |
| 3703 | 3695 | ||
| 3704 | rcu_read_lock(); | 3696 | rcu_read_lock(); |
| 3705 | owner = ACCESS_ONCE(event->owner); | ||
| 3706 | /* | 3697 | /* |
| 3707 | * Matches the smp_wmb() in perf_event_exit_task(). If we observe | 3698 | * Matches the smp_store_release() in perf_event_exit_task(). If we |
| 3708 | * !owner it means the list deletion is complete and we can indeed | 3699 | * observe !owner it means the list deletion is complete and we can |
| 3709 | * free this event, otherwise we need to serialize on | 3700 | * indeed free this event, otherwise we need to serialize on |
| 3710 | * owner->perf_event_mutex. | 3701 | * owner->perf_event_mutex. |
| 3711 | */ | 3702 | */ |
| 3712 | smp_read_barrier_depends(); | 3703 | owner = lockless_dereference(event->owner); |
| 3713 | if (owner) { | 3704 | if (owner) { |
| 3714 | /* | 3705 | /* |
| 3715 | * Since delayed_put_task_struct() also drops the last | 3706 | * Since delayed_put_task_struct() also drops the last |
| @@ -3737,8 +3728,10 @@ static void perf_remove_from_owner(struct perf_event *event) · 21 unmodified lines | |||
| 3737 | * ensured they're done, and we can proceed with freeing the | 3728 | * ensured they're done, and we can proceed with freeing the |
| 3738 | * event. | 3729 | * event. |
| 3739 | */ | 3730 | */ |
| 3740 | if (event->owner) | 3731 | if (event->owner) { |
| 3741 | list_del_init(&event->owner_entry); | 3732 | list_del_init(&event->owner_entry); |
| 3733 | smp_store_release(&event->owner, NULL); | ||
| 3734 | } | ||
| 3742 | mutex_unlock(&owner->perf_event_mutex); | 3735 | mutex_unlock(&owner->perf_event_mutex); |
| 3743 | put_task_struct(owner); | 3736 | put_task_struct(owner); |
| 3744 | } | 3737 | } |
| @@ -3746,36 +3739,98 @@ static void perf_remove_from_owner(struct perf_event *event) · 1 unmodified line | |||
| 3746 | 3739 | ||
| 3747 | static void put_event(struct perf_event *event) | 3740 | static void put_event(struct perf_event *event) |
| 3748 | { | 3741 | { |
| 3749 | struct perf_event_context *ctx; | ||
| 3750 | |||
| 3751 | if (!atomic_long_dec_and_test(&event->refcount)) | 3742 | if (!atomic_long_dec_and_test(&event->refcount)) |
| 3752 | return; | 3743 | return; |
| 3753 | 3744 | ||
| 3745 | _free_event(event); | ||
| 3746 | } | ||
| 3747 | |||
| 3748 | /* | ||
| 3749 | * Kill an event dead; while event:refcount will preserve the event | ||
| 3750 | * object, it will not preserve its functionality. Once the last 'user' | ||
| 3751 | * gives up the object, we'll destroy the thing. | ||
| 3752 | */ | ||
| 3753 | int perf_event_release_kernel(struct perf_event *event) | ||
| 3754 | { | ||
| 3755 | struct perf_event_context *ctx; | ||
| 3756 | struct perf_event *child, *tmp; | ||
| 3757 | |||
| 3754 | if (!is_kernel_event(event)) | 3758 | if (!is_kernel_event(event)) |
| 3755 | perf_remove_from_owner(event); | 3759 | perf_remove_from_owner(event); |
| 3756 | 3760 | ||
| 3761 | ctx = perf_event_ctx_lock(event); | ||
| 3762 | WARN_ON_ONCE(ctx->parent_ctx); | ||
| 3763 | perf_remove_from_context(event, DETACH_GROUP | DETACH_STATE); | ||
| 3764 | perf_event_ctx_unlock(event, ctx); | ||
| 3765 | |||
| 3757 | /* | 3766 | /* |
| 3758 | * There are two ways this annotation is useful: | 3767 | * At this point we must have event->state == PERF_EVENT_STATE_EXIT, |
| 3768 | * either from the above perf_remove_from_context() or through | ||
| 3769 | * perf_event_exit_event(). | ||
| 3759 | * | 3770 | * |
| 3760 | * 1) there is a lock recursion from perf_event_exit_task | 3771 | * Therefore, anybody acquiring event->child_mutex after the below |
| 3761 | * see the comment there. | 3772 | * loop _must_ also see this, most importantly inherit_event() which |
| 3773 | * will avoid placing more children on the list. | ||
| 3762 | * | 3774 | * |
| 3763 | * 2) there is a lock-inversion with mmap_sem through | 3775 | * Thus this guarantees that we will in fact observe and kill _ALL_ |
| 3764 | * perf_read_group(), which takes faults while | 3776 | * child events. |
| 3765 | * holding ctx->mutex, however this is called after | ||
| 3766 | * the last filedesc died, so there is no possibility | ||
| 3767 | * to trigger the AB-BA case. | ||
| 3768 | */ | 3777 | */ |
| 3769 | ctx = perf_event_ctx_lock_nested(event, SINGLE_DEPTH_NESTING); | 3778 | WARN_ON_ONCE(event->state != PERF_EVENT_STATE_EXIT); |
| 3770 | WARN_ON_ONCE(ctx->parent_ctx); | ||
| 3771 | perf_remove_from_context(event, true); | ||
| 3772 | perf_event_ctx_unlock(event, ctx); | ||
| 3773 | 3779 | ||
| 3774 | _free_event(event); | 3780 | again: |
| 3775 | } | 3781 | mutex_lock(&event->child_mutex); |
| 3782 | list_for_each_entry(child, &event->child_list, child_list) { | ||
| 3776 | 3783 | ||
| 3777 | int perf_event_release_kernel(struct perf_event *event) | 3784 | /* |
| 3778 | { | 3785 | * Cannot change, child events are not migrated, see the |
| 3786 | * comment with perf_event_ctx_lock_nested(). | ||
| 3787 | */ | ||
| 3788 | ctx = lockless_dereference(child->ctx); | ||
| 3789 | /* | ||
| 3790 | * Since child_mutex nests inside ctx::mutex, we must jump | ||
| 3791 | * through hoops. We start by grabbing a reference on the ctx. | ||
| 3792 | * | ||
| 3793 | * Since the event cannot get freed while we hold the | ||
| 3794 | * child_mutex, the context must also exist and have a !0 | ||
| 3795 | * reference count. | ||
| 3796 | */ | ||
| 3797 | get_ctx(ctx); | ||
| 3798 | |||
| 3799 | /* | ||
| 3800 | * Now that we have a ctx ref, we can drop child_mutex, and | ||
| 3801 | * acquire ctx::mutex without fear of it going away. Then we | ||
| 3802 | * can re-acquire child_mutex. | ||
| 3803 | */ | ||
| 3804 | mutex_unlock(&event->child_mutex); | ||
| 3805 | mutex_lock(&ctx->mutex); | ||
| 3806 | mutex_lock(&event->child_mutex); | ||
| 3807 | |||
| 3808 | /* | ||
| 3809 | * Now that we hold ctx::mutex and child_mutex, revalidate our | ||
| 3810 | * state, if child is still the first entry, it didn't get freed | ||
| 3811 | * and we can continue doing so. | ||
| 3812 | */ | ||
| 3813 | tmp = list_first_entry_or_null(&event->child_list, | ||
| 3814 | struct perf_event, child_list); | ||
| 3815 | if (tmp == child) { | ||
| 3816 | perf_remove_from_context(child, DETACH_GROUP); | ||
| 3817 | list_del(&child->child_list); | ||
| 3818 | free_event(child); | ||
| 3819 | /* | ||
| 3820 | * This matches the refcount bump in inherit_event(); | ||
| 3821 | * this can't be the last reference. | ||
| 3822 | */ | ||
| 3823 | put_event(event); | ||
| 3824 | } | ||
| 3825 | |||
| 3826 | mutex_unlock(&event->child_mutex); | ||
| 3827 | mutex_unlock(&ctx->mutex); | ||
| 3828 | put_ctx(ctx); | ||
| 3829 | goto again; | ||
| 3830 | } | ||
| 3831 | mutex_unlock(&event->child_mutex); | ||
| 3832 | |||
| 3833 | /* Must be the last reference */ | ||
| 3779 | put_event(event); | 3834 | put_event(event); |
| 3780 | return 0; | 3835 | return 0; |
| 3781 | } | 3836 | } |
| @@ -3786,46 +3841,10 @@ EXPORT_SYMBOL_GPL(perf_event_release_kernel); · 4 unmodified lines | |||
| 3786 | */ | 3841 | */ |
| 3787 | static int perf_release(struct inode *inode, struct file *file) | 3842 | static int perf_release(struct inode *inode, struct file *file) |
| 3788 | { | 3843 | { |
| 3789 | put_event(file->private_data); | 3844 | perf_event_release_kernel(file->private_data); |
| 3790 | return 0; | 3845 | return 0; |
| 3791 | } | 3846 | } |
| 3792 | 3847 | ||
| 3793 | /* | ||
| 3794 | * Remove all orphanes events from the context. | ||
| 3795 | */ | ||
| 3796 | static void orphans_remove_work(struct work_struct *work) | ||
| 3797 | { | ||
| 3798 | struct perf_event_context *ctx; | ||
| 3799 | struct perf_event *event, *tmp; | ||
| 3800 | |||
| 3801 | ctx = container_of(work, struct perf_event_context, | ||
| 3802 | orphans_remove.work); | ||
| 3803 | |||
| 3804 | mutex_lock(&ctx->mutex); | ||
| 3805 | list_for_each_entry_safe(event, tmp, &ctx->event_list, event_entry) { | ||
| 3806 | struct perf_event *parent_event = event->parent; | ||
| 3807 | |||
| 3808 | if (!is_orphaned_child(event)) | ||
| 3809 | continue; | ||
| 3810 | |||
| 3811 | perf_remove_from_context(event, true); | ||
| 3812 | |||
| 3813 | mutex_lock(&parent_event->child_mutex); | ||
| 3814 | list_del_init(&event->child_list); | ||
| 3815 | mutex_unlock(&parent_event->child_mutex); | ||
| 3816 | |||
| 3817 | free_event(event); | ||
| 3818 | put_event(parent_event); | ||
| 3819 | } | ||
| 3820 | |||
| 3821 | raw_spin_lock_irq(&ctx->lock); | ||
| 3822 | ctx->orphans_remove_sched = false; | ||
| 3823 | raw_spin_unlock_irq(&ctx->lock); | ||
| 3824 | mutex_unlock(&ctx->mutex); | ||
| 3825 | |||
| 3826 | put_ctx(ctx); | ||
| 3827 | } | ||
| 3828 | |||
| 3829 | u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running) | 3848 | u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running) |
| 3830 | { | 3849 | { |
| 3831 | struct perf_event *child; | 3850 | struct perf_event *child; |
| @@ -4054,7 +4073,7 @@ static void _perf_event_reset(struct perf_event *event) · 222 unmodified lines | |||
| 4054 | /* | 4073 | /* |
| 4055 | * Holding the top-level event's child_mutex means that any | 4074 | * Holding the top-level event's child_mutex means that any |
| 4056 | * descendant process that has inherited this event will block | 4075 | * descendant process that has inherited this event will block |
| 4057 | * in sync_child_event if it goes to exit, thus satisfying the | 4076 | * in perf_event_exit_event() if it goes to exit, thus satisfying the |
| 4058 | * task existence requirements of perf_event_enable/disable. | 4077 | * task existence requirements of perf_event_enable/disable. |
| 4059 | */ | 4078 | */ |
| 4060 | static void perf_event_for_each_child(struct perf_event *event, | 4079 | static void perf_event_for_each_child(struct perf_event *event, |
| @@ -4086,36 +4105,14 @@ static void perf_event_for_each(struct perf_event *event, · 25 unmodified lines | |||
| 4086 | perf_event_for_each_child(sibling, func); | 4105 | perf_event_for_each_child(sibling, func); |
| 4087 | } | 4106 | } |
| 4088 | 4107 | ||
| 4089 | struct period_event { | 4108 | static void __perf_event_period(struct perf_event *event, |
| 4090 | struct perf_event *event; | 4109 | struct perf_cpu_context *cpuctx, |
| 4091 | u64 value; | 4110 | struct perf_event_context *ctx, |
| 4092 | }; | 4111 | void *info) |
| 4093 | |||
| 4094 | static void ___perf_event_period(void *info) | ||
| 4095 | { | ||
| 4096 | struct period_event *pe = info; | ||
| 4097 | struct perf_event *event = pe->event; | ||
| 4098 | u64 value = pe->value; | ||
| 4099 | |||
| 4100 | if (event->attr.freq) { | ||
| 4101 | event->attr.sample_freq = value; | ||
| 4102 | } else { | ||
| 4103 | event->attr.sample_period = value; | ||
| 4104 | event->hw.sample_period = value; | ||
| 4105 | } | ||
| 4106 | |||
| 4107 | local64_set(&event->hw.period_left, 0); | ||
| 4108 | } | ||
| 4109 | |||
| 4110 | static int __perf_event_period(void *info) | ||
| 4111 | { | 4112 | { |
| 4112 | struct period_event *pe = info; | 4113 | u64 value = *((u64 *)info); |
| 4113 | struct perf_event *event = pe->event; | ||
| 4114 | struct perf_event_context *ctx = event->ctx; | ||
| 4115 | u64 value = pe->value; | ||
| 4116 | bool active; | 4114 | bool active; |
| 4117 | 4115 | ||
| 4118 | raw_spin_lock(&ctx->lock); | ||
| 4119 | if (event->attr.freq) { | 4116 | if (event->attr.freq) { |
| 4120 | event->attr.sample_freq = value; | 4117 | event->attr.sample_freq = value; |
| 4121 | } else { | 4118 | } else { |
| @@ -4135,14 +4132,10 @@ static int __perf_event_period(void *info) · 13 unmodified lines | |||
| 4135 | event->pmu->start(event, PERF_EF_RELOAD); | 4132 | event->pmu->start(event, PERF_EF_RELOAD); |
| 4136 | perf_pmu_enable(ctx->pmu); | 4133 | perf_pmu_enable(ctx->pmu); |
| 4137 | } | 4134 | } |
| 4138 | raw_spin_unlock(&ctx->lock); | ||
| 4139 | |||
| 4140 | return 0; | ||
| 4141 | } | 4135 | } |
| 4142 | 4136 | ||
| 4143 | static int perf_event_period(struct perf_event *event, u64 __user *arg) | 4137 | static int perf_event_period(struct perf_event *event, u64 __user *arg) |
| 4144 | { | 4138 | { |
| 4145 | struct period_event pe = { .event = event, }; | ||
| 4146 | u64 value; | 4139 | u64 value; |
| 4147 | 4140 | ||
| 4148 | if (!is_sampling_event(event)) | 4141 | if (!is_sampling_event(event)) |
| @@ -4157,10 +4150,7 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg) · 8 unmodified lines | |||
| 4157 | if (event->attr.freq && value > sysctl_perf_event_sample_rate) | 4150 | if (event->attr.freq && value > sysctl_perf_event_sample_rate) |
| 4158 | return -EINVAL; | 4151 | return -EINVAL; |
| 4159 | 4152 | ||
| 4160 | pe.value = value; | 4153 | event_function_call(event, __perf_event_period, &value); |
| 4161 | |||
| 4162 | event_function_call(event, __perf_event_period, | ||
| 4163 | ___perf_event_period, &pe); | ||
| 4164 | 4154 | ||
| 4165 | return 0; | 4155 | return 0; |
| 4166 | } | 4156 | } |
| @@ -4932,7 +4922,7 @@ static void perf_pending_event(struct irq_work *entry) · 765 unmodified lines | |||
| 4932 | 4922 | ||
| 4933 | if (event->pending_disable) { | 4923 | if (event->pending_disable) { |
| 4934 | event->pending_disable = 0; | 4924 | event->pending_disable = 0; |
| 4935 | __perf_event_disable(event); | 4925 | perf_event_disable_local(event); |
| 4936 | } | 4926 | } |
| 4937 | 4927 | ||
| 4938 | if (event->pending_wakeup) { | 4928 | if (event->pending_wakeup) { |
| @@ -7753,11 +7743,13 @@ static void account_event_cpu(struct perf_event *event, int cpu) · 2814 unmodified lines | |||
| 7753 | 7743 | ||
| 7754 | static void account_event(struct perf_event *event) | 7744 | static void account_event(struct perf_event *event) |
| 7755 | { | 7745 | { |
| 7746 | bool inc = false; | ||
| 7747 | |||
| 7756 | if (event->parent) | 7748 | if (event->parent) |
| 7757 | return; | 7749 | return; |
| 7758 | 7750 | ||
| 7759 | if (event->attach_state & PERF_ATTACH_TASK) | 7751 | if (event->attach_state & PERF_ATTACH_TASK) |
| 7760 | static_key_slow_inc(&perf_sched_events.key); | 7752 | inc = true; |
| 7761 | if (event->attr.mmap || event->attr.mmap_data) | 7753 | if (event->attr.mmap || event->attr.mmap_data) |
| 7762 | atomic_inc(&nr_mmap_events); | 7754 | atomic_inc(&nr_mmap_events); |
| 7763 | if (event->attr.comm) | 7755 | if (event->attr.comm) |
| @@ -7770,11 +7762,14 @@ static void account_event(struct perf_event *event) · 6 unmodified lines | |||
| 7770 | } | 7762 | } |
| 7771 | if (event->attr.context_switch) { | 7763 | if (event->attr.context_switch) { |
| 7772 | atomic_inc(&nr_switch_events); | 7764 | atomic_inc(&nr_switch_events); |
| 7773 | static_key_slow_inc(&perf_sched_events.key); | 7765 | inc = true; |
| 7774 | } | 7766 | } |
| 7775 | if (has_branch_stack(event)) | 7767 | if (has_branch_stack(event)) |
| 7776 | static_key_slow_inc(&perf_sched_events.key); | 7768 | inc = true; |
| 7777 | if (is_cgroup_event(event)) | 7769 | if (is_cgroup_event(event)) |
| 7770 | inc = true; | ||
| 7771 | |||
| 7772 | if (inc) | ||
| 7778 | static_key_slow_inc(&perf_sched_events.key); | 7773 | static_key_slow_inc(&perf_sched_events.key); |
| 7779 | 7774 | ||
| 7780 | account_event_cpu(event, event->cpu); | 7775 | account_event_cpu(event, event->cpu); |
| @@ -8422,11 +8417,11 @@ SYSCALL_DEFINE5(perf_event_open, · 641 unmodified lines | |||
| 8422 | * See perf_event_ctx_lock() for comments on the details | 8417 | * See perf_event_ctx_lock() for comments on the details |
| 8423 | * of swizzling perf_event::ctx. | 8418 | * of swizzling perf_event::ctx. |
| 8424 | */ | 8419 | */ |
| 8425 | perf_remove_from_context(group_leader, false); | 8420 | perf_remove_from_context(group_leader, 0); |
| 8426 | 8421 | ||
| 8427 | list_for_each_entry(sibling, &group_leader->sibling_list, | 8422 | list_for_each_entry(sibling, &group_leader->sibling_list, |
| 8428 | group_entry) { | 8423 | group_entry) { |
| 8429 | perf_remove_from_context(sibling, false); | 8424 | perf_remove_from_context(sibling, 0); |
| 8430 | put_ctx(gctx); | 8425 | put_ctx(gctx); |
| 8431 | } | 8426 | } |
| 8432 | 8427 | ||
| @@ -8479,6 +8474,8 @@ SYSCALL_DEFINE5(perf_event_open, · 46 unmodified lines | |||
| 8479 | perf_event__header_size(event); | 8474 | perf_event__header_size(event); |
| 8480 | perf_event__id_header_size(event); | 8475 | perf_event__id_header_size(event); |
| 8481 | 8476 | ||
| 8477 | event->owner = current; | ||
| 8478 | |||
| 8482 | perf_install_in_context(ctx, event, event->cpu); | 8479 | perf_install_in_context(ctx, event, event->cpu); |
| 8483 | perf_unpin_context(ctx); | 8480 | perf_unpin_context(ctx); |
| 8484 | 8481 | ||
| @@ -8488,8 +8485,6 @@ SYSCALL_DEFINE5(perf_event_open, · 3 unmodified lines | |||
| 8488 | 8485 | ||
| 8489 | put_online_cpus(); | 8486 | put_online_cpus(); |
| 8490 | 8487 | ||
| 8491 | event->owner = current; | ||
| 8492 | |||
| 8493 | mutex_lock(¤t->perf_event_mutex); | 8488 | mutex_lock(¤t->perf_event_mutex); |
| 8494 | list_add_tail(&event->owner_entry, ¤t->perf_event_list); | 8489 | list_add_tail(&event->owner_entry, ¤t->perf_event_list); |
| 8495 | mutex_unlock(¤t->perf_event_mutex); | 8490 | mutex_unlock(¤t->perf_event_mutex); |
| @@ -8556,7 +8551,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu, · 60 unmodified lines | |||
| 8556 | } | 8551 | } |
| 8557 | 8552 | ||
| 8558 | /* Mark owner so we could distinguish it from user events. */ | 8553 | /* Mark owner so we could distinguish it from user events. */ |
| 8559 | event->owner = EVENT_OWNER_KERNEL; | 8554 | event->owner = TASK_TOMBSTONE; |
| 8560 | 8555 | ||
| 8561 | account_event(event); | 8556 | account_event(event); |
| 8562 | 8557 | ||
| @@ -8606,7 +8601,7 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu) · 43 unmodified lines | |||
| 8606 | mutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex); | 8601 | mutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex); |
| 8607 | list_for_each_entry_safe(event, tmp, &src_ctx->event_list, | 8602 | list_for_each_entry_safe(event, tmp, &src_ctx->event_list, |
| 8608 | event_entry) { | 8603 | event_entry) { |
| 8609 | perf_remove_from_context(event, false); | 8604 | perf_remove_from_context(event, 0); |
| 8610 | unaccount_event_cpu(event, src_cpu); | 8605 | unaccount_event_cpu(event, src_cpu); |
| 8611 | put_ctx(src_ctx); | 8606 | put_ctx(src_ctx); |
| 8612 | list_add(&event->migrate_entry, &events); | 8607 | list_add(&event->migrate_entry, &events); |
| @@ -8673,33 +8668,15 @@ static void sync_child_event(struct perf_event *child_event, · 60 unmodified lines | |||
| 8673 | &parent_event->child_total_time_enabled); | 8668 | &parent_event->child_total_time_enabled); |
| 8674 | atomic64_add(child_event->total_time_running, | 8669 | atomic64_add(child_event->total_time_running, |
| 8675 | &parent_event->child_total_time_running); | 8670 | &parent_event->child_total_time_running); |
| 8676 | |||
| 8677 | /* | ||
| 8678 | * Remove this event from the parent's list | ||
| 8679 | */ | ||
| 8680 | WARN_ON_ONCE(parent_event->ctx->parent_ctx); | ||
| 8681 | mutex_lock(&parent_event->child_mutex); | ||
| 8682 | list_del_init(&child_event->child_list); | ||
| 8683 | mutex_unlock(&parent_event->child_mutex); | ||
| 8684 | |||
| 8685 | /* | ||
| 8686 | * Make sure user/parent get notified, that we just | ||
| 8687 | * lost one event. | ||
| 8688 | */ | ||
| 8689 | perf_event_wakeup(parent_event); | ||
| 8690 | |||
| 8691 | /* | ||
| 8692 | * Release the parent event, if this was the last | ||
| 8693 | * reference to it. | ||
| 8694 | */ | ||
| 8695 | put_event(parent_event); | ||
| 8696 | } | 8671 | } |
| 8697 | 8672 | ||
| 8698 | static void | 8673 | static void |
| 8699 | __perf_event_exit_task(struct perf_event *child_event, | 8674 | perf_event_exit_event(struct perf_event *child_event, |
| 8700 | struct perf_event_context *child_ctx, | 8675 | struct perf_event_context *child_ctx, |
| 8701 | struct task_struct *child) | 8676 | struct task_struct *child) |
| 8702 | { | 8677 | { |
| 8678 | struct perf_event *parent_event = child_event->parent; | ||
| 8679 | |||
| 8703 | /* | 8680 | /* |
| 8704 | * Do not destroy the 'original' grouping; because of the context | 8681 | * Do not destroy the 'original' grouping; because of the context |
| 8705 | * switch optimization the original events could've ended up in a | 8682 | * switch optimization the original events could've ended up in a |
| @@ -8712,57 +8689,86 @@ __perf_event_exit_task(struct perf_event *child_event, · 6 unmodified lines | |||
| 8712 | * Do destroy all inherited groups, we don't care about those | 8689 | * Do destroy all inherited groups, we don't care about those |
| 8713 | * and being thorough is better. | 8690 | * and being thorough is better. |
| 8714 | */ | 8691 | */ |
| 8715 | perf_remove_from_context(child_event, !!child_event->parent); | 8692 | raw_spin_lock_irq(&child_ctx->lock); |
| 8693 | WARN_ON_ONCE(child_ctx->is_active); | ||
| 8694 | |||
| 8695 | if (parent_event) | ||
| 8696 | perf_group_detach(child_event); | ||
| 8697 | list_del_event(child_event, child_ctx); | ||
| 8698 | child_event->state = PERF_EVENT_STATE_EXIT; /* see perf_event_release_kernel() */ | ||
| 8699 | raw_spin_unlock_irq(&child_ctx->lock); | ||
| 8716 | 8700 | ||
| 8717 | /* | 8701 | /* |
| 8718 | * It can happen that the parent exits first, and has events | 8702 | * Parent events are governed by their filedesc, retain them. |
| 8719 | * that are still around due to the child reference. These | ||
| 8720 | * events need to be zapped. | ||
| 8721 | */ | 8703 | */ |
| 8722 | if (child_event->parent) { | 8704 | if (!parent_event) { |
| 8723 | sync_child_event(child_event, child); | ||
| 8724 | free_event(child_event); | ||
| 8725 | } else { | ||
| 8726 | child_event->state = PERF_EVENT_STATE_EXIT; | ||
| 8727 | perf_event_wakeup(child_event); | 8705 | perf_event_wakeup(child_event); |
| 8706 | return; | ||
| 8728 | } | 8707 | } |
| 8708 | /* | ||
| 8709 | * Child events can be cleaned up. | ||
| 8710 | */ | ||
| 8711 | |||
| 8712 | sync_child_event(child_event, child); | ||
| 8713 | |||
| 8714 | /* | ||
| 8715 | * Remove this event from the parent's list | ||
| 8716 | */ | ||
| 8717 | WARN_ON_ONCE(parent_event->ctx->parent_ctx); | ||
| 8718 | mutex_lock(&parent_event->child_mutex); | ||
| 8719 | list_del_init(&child_event->child_list); | ||
| 8720 | mutex_unlock(&parent_event->child_mutex); | ||
| 8721 | |||
| 8722 | /* | ||
| 8723 | * Kick perf_poll() for is_event_hup(). | ||
| 8724 | */ | ||
| 8725 | perf_event_wakeup(parent_event); | ||
| 8726 | free_event(child_event); | ||
| 8727 | put_event(parent_event); | ||
| 8729 | } | 8728 | } |
| 8730 | 8729 | ||
| 8731 | static void perf_event_exit_task_context(struct task_struct *child, int ctxn) | 8730 | static void perf_event_exit_task_context(struct task_struct *child, int ctxn) |
| 8732 | { | 8731 | { |
| 8733 | struct perf_event *child_event, *next; | ||
| 8734 | struct perf_event_context *child_ctx, *clone_ctx = NULL; | 8732 | struct perf_event_context *child_ctx, *clone_ctx = NULL; |
| 8735 | unsigned long flags; | 8733 | struct perf_event *child_event, *next; |
| 8734 | |||
| 8735 | WARN_ON_ONCE(child != current); | ||
| 8736 | 8736 | ||
| 8737 | if (likely(!child->perf_event_ctxp[ctxn])) | 8737 | child_ctx = perf_pin_task_context(child, ctxn); |
| 8738 | if (!child_ctx) | ||
| 8738 | return; | 8739 | return; |
| 8739 | 8740 | ||
| 8740 | local_irq_save(flags); | ||
| 8741 | /* | 8741 | /* |
| 8742 | * We can't reschedule here because interrupts are disabled, | 8742 | * In order to reduce the amount of tricky in ctx tear-down, we hold |
| 8743 | * and either child is current or it is a task that can't be | 8743 | * ctx::mutex over the entire thing. This serializes against almost |
| 8744 | * scheduled, so we are now safe from rescheduling changing | 8744 | * everything that wants to access the ctx. |
| 8745 | * our context. | 8745 | * |
| 8746 | * The exception is sys_perf_event_open() / | ||
| 8747 | * perf_event_create_kernel_count() which does find_get_context() | ||
| 8748 | * without ctx::mutex (it cannot because of the move_group double mutex | ||
| 8749 | * lock thing). See the comments in perf_install_in_context(). | ||
| 8746 | */ | 8750 | */ |
| 8747 | child_ctx = rcu_dereference_raw(child->perf_event_ctxp[ctxn]); | 8751 | mutex_lock(&child_ctx->mutex); |
| 8748 | 8752 | ||
| 8749 | /* | 8753 | /* |
| 8750 | * Take the context lock here so that if find_get_context is | 8754 | * In a single ctx::lock section, de-schedule the events and detach the |
| 8751 | * reading child->perf_event_ctxp, we wait until it has | 8755 | * context from the task such that we cannot ever get it scheduled back |
| 8752 | * incremented the context's refcount before we do put_ctx below. | 8756 | * in. |
| 8753 | */ | 8757 | */ |
| 8754 | raw_spin_lock(&child_ctx->lock); | 8758 | raw_spin_lock_irq(&child_ctx->lock); |
| 8755 | task_ctx_sched_out(child_ctx); | 8759 | task_ctx_sched_out(__get_cpu_context(child_ctx), child_ctx); |
| 8756 | child->perf_event_ctxp[ctxn] = NULL; | ||
| 8757 | 8760 | ||
| 8758 | /* | 8761 | /* |
| 8759 | * If this context is a clone; unclone it so it can't get | 8762 | * Now that the context is inactive, destroy the task <-> ctx relation |
| 8760 | * swapped to another process while we're removing all | 8763 | * and mark the context dead. |
| 8761 | * the events from it. | ||
| 8762 | */ | 8764 | */ |
| 8765 | RCU_INIT_POINTER(child->perf_event_ctxp[ctxn], NULL); | ||
| 8766 | put_ctx(child_ctx); /* cannot be last */ | ||
| 8767 | WRITE_ONCE(child_ctx->task, TASK_TOMBSTONE); | ||
| 8768 | put_task_struct(current); /* cannot be last */ | ||
| 8769 | |||
| 8763 | clone_ctx = unclone_ctx(child_ctx); | 8770 | clone_ctx = unclone_ctx(child_ctx); |
| 8764 | update_context_time(child_ctx); | 8771 | raw_spin_unlock_irq(&child_ctx->lock); |
| 8765 | raw_spin_unlock_irqrestore(&child_ctx->lock, flags); | ||
| 8766 | 8772 | ||
| 8767 | if (clone_ctx) | 8773 | if (clone_ctx) |
| 8768 | put_ctx(clone_ctx); | 8774 | put_ctx(clone_ctx); |
| @@ -8774,20 +8780,8 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn) · 5 unmodified lines | |||
| 8774 | */ | 8780 | */ |
| 8775 | perf_event_task(child, child_ctx, 0); | 8781 | perf_event_task(child, child_ctx, 0); |
| 8776 | 8782 | ||
| 8777 | /* | ||
| 8778 | * We can recurse on the same lock type through: | ||
| 8779 | * | ||
| 8780 | * __perf_event_exit_task() | ||
| 8781 | * sync_child_event() | ||
| 8782 | * put_event() | ||
| 8783 | * mutex_lock(&ctx->mutex) | ||
| 8784 | * | ||
| 8785 | * But since its the parent context it won't be the same instance. | ||
| 8786 | */ | ||
| 8787 | mutex_lock(&child_ctx->mutex); | ||
| 8788 | |||
| 8789 | list_for_each_entry_safe(child_event, next, &child_ctx->event_list, event_entry) | 8783 | list_for_each_entry_safe(child_event, next, &child_ctx->event_list, event_entry) |
| 8790 | __perf_event_exit_task(child_event, child_ctx, child); | 8784 | perf_event_exit_event(child_event, child_ctx, child); |
| 8791 | 8785 | ||
| 8792 | mutex_unlock(&child_ctx->mutex); | 8786 | mutex_unlock(&child_ctx->mutex); |
| 8793 | 8787 | ||
| @@ -8812,8 +8806,7 @@ void perf_event_exit_task(struct task_struct *child) · 18 unmodified lines | |||
| 8812 | * the owner, closes a race against perf_release() where | 8806 | * the owner, closes a race against perf_release() where |
| 8813 | * we need to serialize on the owner->perf_event_mutex. | 8807 | * we need to serialize on the owner->perf_event_mutex. |
| 8814 | */ | 8808 | */ |
| 8815 | smp_wmb(); | 8809 | smp_store_release(&event->owner, NULL); |
| 8816 | event->owner = NULL; | ||
| 8817 | } | 8810 | } |
| 8818 | mutex_unlock(&child->perf_event_mutex); | 8811 | mutex_unlock(&child->perf_event_mutex); |
| 8819 | 8812 | ||
| @@ -8896,21 +8889,20 @@ void perf_event_delayed_put(struct task_struct *task) · 76 unmodified lines | |||
| 8896 | WARN_ON_ONCE(task->perf_event_ctxp[ctxn]); | 8889 | WARN_ON_ONCE(task->perf_event_ctxp[ctxn]); |
| 8897 | } | 8890 | } |
| 8898 | 8891 | ||
| 8899 | struct perf_event *perf_event_get(unsigned int fd) | 8892 | struct file *perf_event_get(unsigned int fd) |
| 8900 | { | 8893 | { |
| 8901 | int err; | 8894 | struct file *file; |
| 8902 | struct fd f; | ||
| 8903 | struct perf_event *event; | ||
| 8904 | 8895 | ||
| 8905 | err = perf_fget_light(fd, &f); | 8896 | file = fget_raw(fd); |
| 8906 | if (err) | 8897 | if (!file) |
| 8907 | return ERR_PTR(err); | 8898 | return ERR_PTR(-EBADF); |
| 8908 | 8899 | ||
| 8909 | event = f.file->private_data; | 8900 | if (file->f_op != &perf_fops) { |
| 8910 | atomic_long_inc(&event->refcount); | 8901 | fput(file); |
| 8911 | fdput(f); | 8902 | return ERR_PTR(-EBADF); |
| 8903 | } | ||
| 8912 | 8904 | ||
| 8913 | return event; | 8905 | return file; |
| 8914 | } | 8906 | } |
| 8915 | 8907 | ||
| 8916 | const struct perf_event_attr *perf_event_attrs(struct perf_event *event) | 8908 | const struct perf_event_attr *perf_event_attrs(struct perf_event *event) |
| @@ -8953,8 +8945,16 @@ inherit_event(struct perf_event *parent_event, · 36 unmodified lines | |||
| 8953 | if (IS_ERR(child_event)) | 8945 | if (IS_ERR(child_event)) |
| 8954 | return child_event; | 8946 | return child_event; |
| 8955 | 8947 | ||
| 8948 | /* | ||
| 8949 | * is_orphaned_event() and list_add_tail(&parent_event->child_list) | ||
| 8950 | * must be under the same lock in order to serialize against | ||
| 8951 | * perf_event_release_kernel(), such that either we must observe | ||
| 8952 | * is_orphaned_event() or they will observe us on the child_list. | ||
| 8953 | */ | ||
| 8954 | mutex_lock(&parent_event->child_mutex); | ||
| 8956 | if (is_orphaned_event(parent_event) || | 8955 | if (is_orphaned_event(parent_event) || |
| 8957 | !atomic_long_inc_not_zero(&parent_event->refcount)) { | 8956 | !atomic_long_inc_not_zero(&parent_event->refcount)) { |
| 8957 | mutex_unlock(&parent_event->child_mutex); | ||
| 8958 | free_event(child_event); | 8958 | free_event(child_event); |
| 8959 | return NULL; | 8959 | return NULL; |
| 8960 | } | 8960 | } |
| @@ -9002,8 +9002,6 @@ inherit_event(struct perf_event *parent_event, · 41 unmodified lines | |||
| 9002 | /* | 9002 | /* |
| 9003 | * Link this into the parent event's child list | 9003 | * Link this into the parent event's child list |
| 9004 | */ | 9004 | */ |
| 9005 | WARN_ON_ONCE(parent_event->ctx->parent_ctx); | ||
| 9006 | mutex_lock(&parent_event->child_mutex); | ||
| 9007 | list_add_tail(&child_event->child_list, &parent_event->child_list); | 9005 | list_add_tail(&child_event->child_list, &parent_event->child_list); |
| 9008 | mutex_unlock(&parent_event->child_mutex); | 9006 | mutex_unlock(&parent_event->child_mutex); |
| 9009 | 9007 | ||
| @@ -9221,13 +9219,14 @@ static void perf_event_init_cpu(int cpu) · 211 unmodified lines | |||
| 9221 | #if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC_CORE | 9219 | #if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC_CORE |
| 9222 | static void __perf_event_exit_context(void *__info) | 9220 | static void __perf_event_exit_context(void *__info) |
| 9223 | { | 9221 | { |
| 9224 | struct remove_event re = { .detach_group = true }; | ||
| 9225 | struct perf_event_context *ctx = __info; | 9222 | struct perf_event_context *ctx = __info; |
| 9223 | struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); | ||
| 9224 | struct perf_event *event; | ||
| 9226 | 9225 | ||
| 9227 | rcu_read_lock(); | 9226 | raw_spin_lock(&ctx->lock); |
| 9228 | list_for_each_entry_rcu(re.event, &ctx->event_list, event_entry) | 9227 | list_for_each_entry(event, &ctx->event_list, event_entry) |
| 9229 | __perf_remove_from_context(&re); | 9228 | __perf_remove_from_context(event, cpuctx, ctx, (void *)DETACH_GROUP); |
| 9230 | rcu_read_unlock(); | 9229 | raw_spin_unlock(&ctx->lock); |
| 9231 | } | 9230 | } |
| 9232 | 9231 | ||
| 9233 | static void perf_event_exit_cpu_context(int cpu) | 9232 | static void perf_event_exit_cpu_context(int cpu) |
| @@ -444,7 +444,7 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att · 443 unmodified lines | |||
| 444 | * current task. | 444 | * current task. |
| 445 | */ | 445 | */ |
| 446 | if (irqs_disabled() && bp->ctx && bp->ctx->task == current) | 446 | if (irqs_disabled() && bp->ctx && bp->ctx->task == current) |
| 447 | __perf_event_disable(bp); | 447 | perf_event_disable_local(bp); |
| 448 | else | 448 | else |
| 449 | perf_event_disable(bp); | 449 | perf_event_disable(bp); |
| 450 | 450 | ||
| @@ -459,6 +459,25 @@ static void rb_free_aux_page(struct ring_buffer *rb, int idx) · 458 unmodified lines | |||
| 459 | __free_page(page); | 459 | __free_page(page); |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | static void __rb_free_aux(struct ring_buffer *rb) | ||
| 463 | { | ||
| 464 | int pg; | ||
| 465 | |||
| 466 | if (rb->aux_priv) { | ||
| 467 | rb->free_aux(rb->aux_priv); | ||
| 468 | rb->free_aux = NULL; | ||
| 469 | rb->aux_priv = NULL; | ||
| 470 | } | ||
| 471 | |||
| 472 | if (rb->aux_nr_pages) { | ||
| 473 | for (pg = 0; pg < rb->aux_nr_pages; pg++) | ||
| 474 | rb_free_aux_page(rb, pg); | ||
| 475 | |||
| 476 | kfree(rb->aux_pages); | ||
| 477 | rb->aux_nr_pages = 0; | ||
| 478 | } | ||
| 479 | } | ||
| 480 | |||
| 462 | int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, | 481 | int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, |
| 463 | pgoff_t pgoff, int nr_pages, long watermark, int flags) | 482 | pgoff_t pgoff, int nr_pages, long watermark, int flags) |
| 464 | { | 483 | { |
| @@ -547,30 +566,11 @@ out: · 82 unmodified lines | |||
| 547 | if (!ret) | 566 | if (!ret) |
| 548 | rb->aux_pgoff = pgoff; | 567 | rb->aux_pgoff = pgoff; |
| 549 | else | 568 | else |
| 550 | rb_free_aux(rb); | 569 | __rb_free_aux(rb); |
| 551 | 570 | ||
| 552 | return ret; | 571 | return ret; |
| 553 | } | 572 | } |
| 554 | 573 | ||
| 555 | static void __rb_free_aux(struct ring_buffer *rb) | ||
| 556 | { | ||
| 557 | int pg; | ||
| 558 | |||
| 559 | if (rb->aux_priv) { | ||
| 560 | rb->free_aux(rb->aux_priv); | ||
| 561 | rb->free_aux = NULL; | ||
| 562 | rb->aux_priv = NULL; | ||
| 563 | } | ||
| 564 | |||
| 565 | if (rb->aux_nr_pages) { | ||
| 566 | for (pg = 0; pg < rb->aux_nr_pages; pg++) | ||
| 567 | rb_free_aux_page(rb, pg); | ||
| 568 | |||
| 569 | kfree(rb->aux_pages); | ||
| 570 | rb->aux_nr_pages = 0; | ||
| 571 | } | ||
| 572 | } | ||
| 573 | |||
| 574 | void rb_free_aux(struct ring_buffer *rb) | 574 | void rb_free_aux(struct ring_buffer *rb) |
| 575 | { | 575 | { |
| 576 | if (atomic_dec_and_test(&rb->aux_refcount)) | 576 | if (atomic_dec_and_test(&rb->aux_refcount)) |
| @@ -1191,7 +1191,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this, · 1190 unmodified lines | |||
| 1191 | if (pi_state->owner != current) | 1191 | if (pi_state->owner != current) |
| 1192 | return -EINVAL; | 1192 | return -EINVAL; |
| 1193 | 1193 | ||
| 1194 | raw_spin_lock(&pi_state->pi_mutex.wait_lock); | 1194 | raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock); |
| 1195 | new_owner = rt_mutex_next_owner(&pi_state->pi_mutex); | 1195 | new_owner = rt_mutex_next_owner(&pi_state->pi_mutex); |
| 1196 | 1196 | ||
| 1197 | /* | 1197 | /* |
| @@ -1217,22 +1217,22 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this, · 19 unmodified lines | |||
| 1217 | else if (curval != uval) | 1217 | else if (curval != uval) |
| 1218 | ret = -EINVAL; | 1218 | ret = -EINVAL; |
| 1219 | if (ret) { | 1219 | if (ret) { |
| 1220 | raw_spin_unlock(&pi_state->pi_mutex.wait_lock); | 1220 | raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); |
| 1221 | return ret; | 1221 | return ret; |
| 1222 | } | 1222 | } |
| 1223 | 1223 | ||
| 1224 | raw_spin_lock_irq(&pi_state->owner->pi_lock); | 1224 | raw_spin_lock(&pi_state->owner->pi_lock); |
| 1225 | WARN_ON(list_empty(&pi_state->list)); | 1225 | WARN_ON(list_empty(&pi_state->list)); |
| 1226 | list_del_init(&pi_state->list); | 1226 | list_del_init(&pi_state->list); |
| 1227 | raw_spin_unlock_irq(&pi_state->owner->pi_lock); | 1227 | raw_spin_unlock(&pi_state->owner->pi_lock); |
| 1228 | 1228 | ||
| 1229 | raw_spin_lock_irq(&new_owner->pi_lock); | 1229 | raw_spin_lock(&new_owner->pi_lock); |
| 1230 | WARN_ON(!list_empty(&pi_state->list)); | 1230 | WARN_ON(!list_empty(&pi_state->list)); |
| 1231 | list_add(&pi_state->list, &new_owner->pi_state_list); | 1231 | list_add(&pi_state->list, &new_owner->pi_state_list); |
| 1232 | pi_state->owner = new_owner; | 1232 | pi_state->owner = new_owner; |
| 1233 | raw_spin_unlock_irq(&new_owner->pi_lock); | 1233 | raw_spin_unlock(&new_owner->pi_lock); |
| 1234 | 1234 | ||
| 1235 | raw_spin_unlock(&pi_state->pi_mutex.wait_lock); | 1235 | raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock); |
| 1236 | 1236 | ||
| 1237 | deboost = rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q); | 1237 | deboost = rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q); |
| 1238 | 1238 | ||
| @@ -2127,11 +2127,11 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) · 888 unmodified lines | |||
| 2127 | * we returned due to timeout or signal without taking the | 2127 | * we returned due to timeout or signal without taking the |
| 2128 | * rt_mutex. Too late. | 2128 | * rt_mutex. Too late. |
| 2129 | */ | 2129 | */ |
| 2130 | raw_spin_lock(&q->pi_state->pi_mutex.wait_lock); | 2130 | raw_spin_lock_irq(&q->pi_state->pi_mutex.wait_lock); |
| 2131 | owner = rt_mutex_owner(&q->pi_state->pi_mutex); | 2131 | owner = rt_mutex_owner(&q->pi_state->pi_mutex); |
| 2132 | if (!owner) | 2132 | if (!owner) |
| 2133 | owner = rt_mutex_next_owner(&q->pi_state->pi_mutex); | 2133 | owner = rt_mutex_next_owner(&q->pi_state->pi_mutex); |
| 2134 | raw_spin_unlock(&q->pi_state->pi_mutex.wait_lock); | 2134 | raw_spin_unlock_irq(&q->pi_state->pi_mutex.wait_lock); |
| 2135 | ret = fixup_pi_state_owner(uaddr, q, owner); | 2135 | ret = fixup_pi_state_owner(uaddr, q, owner); |
| 2136 | goto out; | 2136 | goto out; |
| 2137 | } | 2137 | } |
| @@ -138,7 +138,8 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc) · 137 unmodified lines | |||
| 138 | unsigned int flags = 0, irq = desc->irq_data.irq; | 138 | unsigned int flags = 0, irq = desc->irq_data.irq; |
| 139 | struct irqaction *action = desc->action; | 139 | struct irqaction *action = desc->action; |
| 140 | 140 | ||
| 141 | do { | 141 | /* action might have become NULL since we dropped the lock */ |
| 142 | while (action) { | ||
| 142 | irqreturn_t res; | 143 | irqreturn_t res; |
| 143 | 144 | ||
| 144 | trace_irq_handler_entry(irq, action); | 145 | trace_irq_handler_entry(irq, action); |
| @@ -173,7 +174,7 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc) · 28 unmodified lines | |||
| 173 | 174 | ||
| 174 | retval |= res; | 175 | retval |= res; |
| 175 | action = action->next; | 176 | action = action->next; |
| 176 | } while (action); | 177 | } |
| 177 | 178 | ||
| 178 | add_interrupt_randomness(irq, flags); | 179 | add_interrupt_randomness(irq, flags); |
| 179 | 180 | ||
| @@ -575,10 +575,15 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · 574 unmodified lines | |||
| 575 | unsigned int type = IRQ_TYPE_NONE; | 575 | unsigned int type = IRQ_TYPE_NONE; |
| 576 | int virq; | 576 | int virq; |
| 577 | 577 | ||
| 578 | if (fwspec->fwnode) | 578 | if (fwspec->fwnode) { |
| 579 | domain = irq_find_matching_fwnode(fwspec->fwnode, DOMAIN_BUS_ANY); | 579 | domain = irq_find_matching_fwnode(fwspec->fwnode, |
| 580 | else | 580 | DOMAIN_BUS_WIRED); |
| 581 | if (!domain) | ||
| 582 | domain = irq_find_matching_fwnode(fwspec->fwnode, | ||
| 583 | DOMAIN_BUS_ANY); | ||
| 584 | } else { | ||
| 581 | domain = irq_default_domain; | 585 | domain = irq_default_domain; |
| 586 | } | ||
| 582 | 587 | ||
| 583 | if (!domain) { | 588 | if (!domain) { |
| 584 | pr_warn("no irq domain found for %s !\n", | 589 | pr_warn("no irq domain found for %s !\n", |
| @@ -99,13 +99,14 @@ static inline void mark_rt_mutex_waiters(struct rt_mutex *lock) · 98 unmodified lines | |||
| 99 | * 2) Drop lock->wait_lock | 99 | * 2) Drop lock->wait_lock |
| 100 | * 3) Try to unlock the lock with cmpxchg | 100 | * 3) Try to unlock the lock with cmpxchg |
| 101 | */ | 101 | */ |
| 102 | static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock) | 102 | static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock, |
| 103 | unsigned long flags) | ||
| 103 | __releases(lock->wait_lock) | 104 | __releases(lock->wait_lock) |
| 104 | { | 105 | { |
| 105 | struct task_struct *owner = rt_mutex_owner(lock); | 106 | struct task_struct *owner = rt_mutex_owner(lock); |
| 106 | 107 | ||
| 107 | clear_rt_mutex_waiters(lock); | 108 | clear_rt_mutex_waiters(lock); |
| 108 | raw_spin_unlock(&lock->wait_lock); | 109 | raw_spin_unlock_irqrestore(&lock->wait_lock, flags); |
| 109 | /* | 110 | /* |
| 110 | * If a new waiter comes in between the unlock and the cmpxchg | 111 | * If a new waiter comes in between the unlock and the cmpxchg |
| 111 | * we have two situations: | 112 | * we have two situations: |
| @@ -147,11 +148,12 @@ static inline void mark_rt_mutex_waiters(struct rt_mutex *lock) · 35 unmodified lines | |||
| 147 | /* | 148 | /* |
| 148 | * Simple slow path only version: lock->owner is protected by lock->wait_lock. | 149 | * Simple slow path only version: lock->owner is protected by lock->wait_lock. |
| 149 | */ | 150 | */ |
| 150 | static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock) | 151 | static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock, |
| 152 | unsigned long flags) | ||
| 151 | __releases(lock->wait_lock) | 153 | __releases(lock->wait_lock) |
| 152 | { | 154 | { |
| 153 | lock->owner = NULL; | 155 | lock->owner = NULL; |
| 154 | raw_spin_unlock(&lock->wait_lock); | 156 | raw_spin_unlock_irqrestore(&lock->wait_lock, flags); |
| 155 | return true; | 157 | return true; |
| 156 | } | 158 | } |
| 157 | #endif | 159 | #endif |
| @@ -433,7 +435,6 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 275 unmodified lines | |||
| 433 | int ret = 0, depth = 0; | 435 | int ret = 0, depth = 0; |
| 434 | struct rt_mutex *lock; | 436 | struct rt_mutex *lock; |
| 435 | bool detect_deadlock; | 437 | bool detect_deadlock; |
| 436 | unsigned long flags; | ||
| 437 | bool requeue = true; | 438 | bool requeue = true; |
| 438 | 439 | ||
| 439 | detect_deadlock = rt_mutex_cond_detect_deadlock(orig_waiter, chwalk); | 440 | detect_deadlock = rt_mutex_cond_detect_deadlock(orig_waiter, chwalk); |
| @@ -476,7 +477,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 36 unmodified lines | |||
| 476 | /* | 477 | /* |
| 477 | * [1] Task cannot go away as we did a get_task() before ! | 478 | * [1] Task cannot go away as we did a get_task() before ! |
| 478 | */ | 479 | */ |
| 479 | raw_spin_lock_irqsave(&task->pi_lock, flags); | 480 | raw_spin_lock_irq(&task->pi_lock); |
| 480 | 481 | ||
| 481 | /* | 482 | /* |
| 482 | * [2] Get the waiter on which @task is blocked on. | 483 | * [2] Get the waiter on which @task is blocked on. |
| @@ -560,7 +561,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 77 unmodified lines | |||
| 560 | * operations. | 561 | * operations. |
| 561 | */ | 562 | */ |
| 562 | if (!raw_spin_trylock(&lock->wait_lock)) { | 563 | if (!raw_spin_trylock(&lock->wait_lock)) { |
| 563 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 564 | raw_spin_unlock_irq(&task->pi_lock); |
| 564 | cpu_relax(); | 565 | cpu_relax(); |
| 565 | goto retry; | 566 | goto retry; |
| 566 | } | 567 | } |
| @@ -591,7 +592,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 24 unmodified lines | |||
| 591 | /* | 592 | /* |
| 592 | * No requeue[7] here. Just release @task [8] | 593 | * No requeue[7] here. Just release @task [8] |
| 593 | */ | 594 | */ |
| 594 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 595 | raw_spin_unlock(&task->pi_lock); |
| 595 | put_task_struct(task); | 596 | put_task_struct(task); |
| 596 | 597 | ||
| 597 | /* | 598 | /* |
| @@ -599,14 +600,14 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 1 unmodified line | |||
| 599 | * If there is no owner of the lock, end of chain. | 600 | * If there is no owner of the lock, end of chain. |
| 600 | */ | 601 | */ |
| 601 | if (!rt_mutex_owner(lock)) { | 602 | if (!rt_mutex_owner(lock)) { |
| 602 | raw_spin_unlock(&lock->wait_lock); | 603 | raw_spin_unlock_irq(&lock->wait_lock); |
| 603 | return 0; | 604 | return 0; |
| 604 | } | 605 | } |
| 605 | 606 | ||
| 606 | /* [10] Grab the next task, i.e. owner of @lock */ | 607 | /* [10] Grab the next task, i.e. owner of @lock */ |
| 607 | task = rt_mutex_owner(lock); | 608 | task = rt_mutex_owner(lock); |
| 608 | get_task_struct(task); | 609 | get_task_struct(task); |
| 609 | raw_spin_lock_irqsave(&task->pi_lock, flags); | 610 | raw_spin_lock(&task->pi_lock); |
| 610 | 611 | ||
| 611 | /* | 612 | /* |
| 612 | * No requeue [11] here. We just do deadlock detection. | 613 | * No requeue [11] here. We just do deadlock detection. |
| @@ -621,8 +622,8 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 8 unmodified lines | |||
| 621 | top_waiter = rt_mutex_top_waiter(lock); | 622 | top_waiter = rt_mutex_top_waiter(lock); |
| 622 | 623 | ||
| 623 | /* [13] Drop locks */ | 624 | /* [13] Drop locks */ |
| 624 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 625 | raw_spin_unlock(&task->pi_lock); |
| 625 | raw_spin_unlock(&lock->wait_lock); | 626 | raw_spin_unlock_irq(&lock->wait_lock); |
| 626 | 627 | ||
| 627 | /* If owner is not blocked, end of chain. */ | 628 | /* If owner is not blocked, end of chain. */ |
| 628 | if (!next_lock) | 629 | if (!next_lock) |
| @@ -643,7 +644,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 14 unmodified lines | |||
| 643 | rt_mutex_enqueue(lock, waiter); | 644 | rt_mutex_enqueue(lock, waiter); |
| 644 | 645 | ||
| 645 | /* [8] Release the task */ | 646 | /* [8] Release the task */ |
| 646 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 647 | raw_spin_unlock(&task->pi_lock); |
| 647 | put_task_struct(task); | 648 | put_task_struct(task); |
| 648 | 649 | ||
| 649 | /* | 650 | /* |
| @@ -661,14 +662,14 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 11 unmodified lines | |||
| 661 | */ | 662 | */ |
| 662 | if (prerequeue_top_waiter != rt_mutex_top_waiter(lock)) | 663 | if (prerequeue_top_waiter != rt_mutex_top_waiter(lock)) |
| 663 | wake_up_process(rt_mutex_top_waiter(lock)->task); | 664 | wake_up_process(rt_mutex_top_waiter(lock)->task); |
| 664 | raw_spin_unlock(&lock->wait_lock); | 665 | raw_spin_unlock_irq(&lock->wait_lock); |
| 665 | return 0; | 666 | return 0; |
| 666 | } | 667 | } |
| 667 | 668 | ||
| 668 | /* [10] Grab the next task, i.e. the owner of @lock */ | 669 | /* [10] Grab the next task, i.e. the owner of @lock */ |
| 669 | task = rt_mutex_owner(lock); | 670 | task = rt_mutex_owner(lock); |
| 670 | get_task_struct(task); | 671 | get_task_struct(task); |
| 671 | raw_spin_lock_irqsave(&task->pi_lock, flags); | 672 | raw_spin_lock(&task->pi_lock); |
| 672 | 673 | ||
| 673 | /* [11] requeue the pi waiters if necessary */ | 674 | /* [11] requeue the pi waiters if necessary */ |
| 674 | if (waiter == rt_mutex_top_waiter(lock)) { | 675 | if (waiter == rt_mutex_top_waiter(lock)) { |
| @@ -722,8 +723,8 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 47 unmodified lines | |||
| 722 | top_waiter = rt_mutex_top_waiter(lock); | 723 | top_waiter = rt_mutex_top_waiter(lock); |
| 723 | 724 | ||
| 724 | /* [13] Drop the locks */ | 725 | /* [13] Drop the locks */ |
| 725 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 726 | raw_spin_unlock(&task->pi_lock); |
| 726 | raw_spin_unlock(&lock->wait_lock); | 727 | raw_spin_unlock_irq(&lock->wait_lock); |
| 727 | 728 | ||
| 728 | /* | 729 | /* |
| 729 | * Make the actual exit decisions [12], based on the stored | 730 | * Make the actual exit decisions [12], based on the stored |
| @@ -746,7 +747,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 16 unmodified lines | |||
| 746 | goto again; | 747 | goto again; |
| 747 | 748 | ||
| 748 | out_unlock_pi: | 749 | out_unlock_pi: |
| 749 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 750 | raw_spin_unlock_irq(&task->pi_lock); |
| 750 | out_put_task: | 751 | out_put_task: |
| 751 | put_task_struct(task); | 752 | put_task_struct(task); |
| 752 | 753 | ||
| @@ -756,7 +757,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 3 unmodified lines | |||
| 756 | /* | 757 | /* |
| 757 | * Try to take an rt-mutex | 758 | * Try to take an rt-mutex |
| 758 | * | 759 | * |
| 759 | * Must be called with lock->wait_lock held. | 760 | * Must be called with lock->wait_lock held and interrupts disabled |
| 760 | * | 761 | * |
| 761 | * @lock: The lock to be acquired. | 762 | * @lock: The lock to be acquired. |
| 762 | * @task: The task which wants to acquire the lock | 763 | * @task: The task which wants to acquire the lock |
| @@ -766,8 +767,6 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 3 unmodified lines | |||
| 766 | static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task, | 767 | static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task, |
| 767 | struct rt_mutex_waiter *waiter) | 768 | struct rt_mutex_waiter *waiter) |
| 768 | { | 769 | { |
| 769 | unsigned long flags; | ||
| 770 | |||
| 771 | /* | 770 | /* |
| 772 | * Before testing whether we can acquire @lock, we set the | 771 | * Before testing whether we can acquire @lock, we set the |
| 773 | * RT_MUTEX_HAS_WAITERS bit in @lock->owner. This forces all | 772 | * RT_MUTEX_HAS_WAITERS bit in @lock->owner. This forces all |
| @@ -852,7 +851,7 @@ static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task, · 78 unmodified lines | |||
| 852 | * case, but conditionals are more expensive than a redundant | 851 | * case, but conditionals are more expensive than a redundant |
| 853 | * store. | 852 | * store. |
| 854 | */ | 853 | */ |
| 855 | raw_spin_lock_irqsave(&task->pi_lock, flags); | 854 | raw_spin_lock(&task->pi_lock); |
| 856 | task->pi_blocked_on = NULL; | 855 | task->pi_blocked_on = NULL; |
| 857 | /* | 856 | /* |
| 858 | * Finish the lock acquisition. @task is the new owner. If | 857 | * Finish the lock acquisition. @task is the new owner. If |
| @@ -861,7 +860,7 @@ static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task, · 2 unmodified lines | |||
| 861 | */ | 860 | */ |
| 862 | if (rt_mutex_has_waiters(lock)) | 861 | if (rt_mutex_has_waiters(lock)) |
| 863 | rt_mutex_enqueue_pi(task, rt_mutex_top_waiter(lock)); | 862 | rt_mutex_enqueue_pi(task, rt_mutex_top_waiter(lock)); |
| 864 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 863 | raw_spin_unlock(&task->pi_lock); |
| 865 | 864 | ||
| 866 | takeit: | 865 | takeit: |
| 867 | /* We got the lock. */ | 866 | /* We got the lock. */ |
| @@ -883,7 +882,7 @@ takeit: · 15 unmodified lines | |||
| 883 | * | 882 | * |
| 884 | * Prepare waiter and propagate pi chain | 883 | * Prepare waiter and propagate pi chain |
| 885 | * | 884 | * |
| 886 | * This must be called with lock->wait_lock held. | 885 | * This must be called with lock->wait_lock held and interrupts disabled |
| 887 | */ | 886 | */ |
| 888 | static int task_blocks_on_rt_mutex(struct rt_mutex *lock, | 887 | static int task_blocks_on_rt_mutex(struct rt_mutex *lock, |
| 889 | struct rt_mutex_waiter *waiter, | 888 | struct rt_mutex_waiter *waiter, |
| @@ -894,7 +893,6 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 4 unmodified lines | |||
| 894 | struct rt_mutex_waiter *top_waiter = waiter; | 893 | struct rt_mutex_waiter *top_waiter = waiter; |
| 895 | struct rt_mutex *next_lock; | 894 | struct rt_mutex *next_lock; |
| 896 | int chain_walk = 0, res; | 895 | int chain_walk = 0, res; |
| 897 | unsigned long flags; | ||
| 898 | 896 | ||
| 899 | /* | 897 | /* |
| 900 | * Early deadlock detection. We really don't want the task to | 898 | * Early deadlock detection. We really don't want the task to |
| @@ -908,7 +906,7 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 7 unmodified lines | |||
| 908 | if (owner == task) | 906 | if (owner == task) |
| 909 | return -EDEADLK; | 907 | return -EDEADLK; |
| 910 | 908 | ||
| 911 | raw_spin_lock_irqsave(&task->pi_lock, flags); | 909 | raw_spin_lock(&task->pi_lock); |
| 912 | __rt_mutex_adjust_prio(task); | 910 | __rt_mutex_adjust_prio(task); |
| 913 | waiter->task = task; | 911 | waiter->task = task; |
| 914 | waiter->lock = lock; | 912 | waiter->lock = lock; |
| @@ -921,12 +919,12 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 6 unmodified lines | |||
| 921 | 919 | ||
| 922 | task->pi_blocked_on = waiter; | 920 | task->pi_blocked_on = waiter; |
| 923 | 921 | ||
| 924 | raw_spin_unlock_irqrestore(&task->pi_lock, flags); | 922 | raw_spin_unlock(&task->pi_lock); |
| 925 | 923 | ||
| 926 | if (!owner) | 924 | if (!owner) |
| 927 | return 0; | 925 | return 0; |
| 928 | 926 | ||
| 929 | raw_spin_lock_irqsave(&owner->pi_lock, flags); | 927 | raw_spin_lock(&owner->pi_lock); |
| 930 | if (waiter == rt_mutex_top_waiter(lock)) { | 928 | if (waiter == rt_mutex_top_waiter(lock)) { |
| 931 | rt_mutex_dequeue_pi(owner, top_waiter); | 929 | rt_mutex_dequeue_pi(owner, top_waiter); |
| 932 | rt_mutex_enqueue_pi(owner, waiter); | 930 | rt_mutex_enqueue_pi(owner, waiter); |
| @@ -941,7 +939,7 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 8 unmodified lines | |||
| 941 | /* Store the lock on which owner is blocked or NULL */ | 939 | /* Store the lock on which owner is blocked or NULL */ |
| 942 | next_lock = task_blocked_on_lock(owner); | 940 | next_lock = task_blocked_on_lock(owner); |
| 943 | 941 | ||
| 944 | raw_spin_unlock_irqrestore(&owner->pi_lock, flags); | 942 | raw_spin_unlock(&owner->pi_lock); |
| 945 | /* | 943 | /* |
| 946 | * Even if full deadlock detection is on, if the owner is not | 944 | * Even if full deadlock detection is on, if the owner is not |
| 947 | * blocked itself, we can avoid finding this out in the chain | 945 | * blocked itself, we can avoid finding this out in the chain |
| @@ -957,12 +955,12 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 9 unmodified lines | |||
| 957 | */ | 955 | */ |
| 958 | get_task_struct(owner); | 956 | get_task_struct(owner); |
| 959 | 957 | ||
| 960 | raw_spin_unlock(&lock->wait_lock); | 958 | raw_spin_unlock_irq(&lock->wait_lock); |
| 961 | 959 | ||
| 962 | res = rt_mutex_adjust_prio_chain(owner, chwalk, lock, | 960 | res = rt_mutex_adjust_prio_chain(owner, chwalk, lock, |
| 963 | next_lock, waiter, task); | 961 | next_lock, waiter, task); |
| 964 | 962 | ||
| 965 | raw_spin_lock(&lock->wait_lock); | 963 | raw_spin_lock_irq(&lock->wait_lock); |
| 966 | 964 | ||
| 967 | return res; | 965 | return res; |
| 968 | } | 966 | } |
| @@ -971,15 +969,14 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 2 unmodified lines | |||
| 971 | * Remove the top waiter from the current tasks pi waiter tree and | 969 | * Remove the top waiter from the current tasks pi waiter tree and |
| 972 | * queue it up. | 970 | * queue it up. |
| 973 | * | 971 | * |
| 974 | * Called with lock->wait_lock held. | 972 | * Called with lock->wait_lock held and interrupts disabled. |
| 975 | */ | 973 | */ |
| 976 | static void mark_wakeup_next_waiter(struct wake_q_head *wake_q, | 974 | static void mark_wakeup_next_waiter(struct wake_q_head *wake_q, |
| 977 | struct rt_mutex *lock) | 975 | struct rt_mutex *lock) |
| 978 | { | 976 | { |
| 979 | struct rt_mutex_waiter *waiter; | 977 | struct rt_mutex_waiter *waiter; |
| 980 | unsigned long flags; | ||
| 981 | 978 | ||
| 982 | raw_spin_lock_irqsave(¤t->pi_lock, flags); | 979 | raw_spin_lock(¤t->pi_lock); |
| 983 | 980 | ||
| 984 | waiter = rt_mutex_top_waiter(lock); | 981 | waiter = rt_mutex_top_waiter(lock); |
| 985 | 982 | ||
| @@ -1001,7 +998,7 @@ static void mark_wakeup_next_waiter(struct wake_q_head *wake_q, · 15 unmodified lines | |||
| 1001 | */ | 998 | */ |
| 1002 | lock->owner = (void *) RT_MUTEX_HAS_WAITERS; | 999 | lock->owner = (void *) RT_MUTEX_HAS_WAITERS; |
| 1003 | 1000 | ||
| 1004 | raw_spin_unlock_irqrestore(¤t->pi_lock, flags); | 1001 | raw_spin_unlock(¤t->pi_lock); |
| 1005 | 1002 | ||
| 1006 | wake_q_add(wake_q, waiter->task); | 1003 | wake_q_add(wake_q, waiter->task); |
| 1007 | } | 1004 | } |
| @@ -1009,7 +1006,7 @@ static void mark_wakeup_next_waiter(struct wake_q_head *wake_q, · 1 unmodified line | |||
| 1009 | /* | 1006 | /* |
| 1010 | * Remove a waiter from a lock and give up | 1007 | * Remove a waiter from a lock and give up |
| 1011 | * | 1008 | * |
| 1012 | * Must be called with lock->wait_lock held and | 1009 | * Must be called with lock->wait_lock held and interrupts disabled. I must |
| 1013 | * have just failed to try_to_take_rt_mutex(). | 1010 | * have just failed to try_to_take_rt_mutex(). |
| 1014 | */ | 1011 | */ |
| 1015 | static void remove_waiter(struct rt_mutex *lock, | 1012 | static void remove_waiter(struct rt_mutex *lock, |
| @@ -1018,12 +1015,11 @@ static void remove_waiter(struct rt_mutex *lock, · 2 unmodified lines | |||
| 1018 | bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock)); | 1015 | bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock)); |
| 1019 | struct task_struct *owner = rt_mutex_owner(lock); | 1016 | struct task_struct *owner = rt_mutex_owner(lock); |
| 1020 | struct rt_mutex *next_lock; | 1017 | struct rt_mutex *next_lock; |
| 1021 | unsigned long flags; | ||
| 1022 | 1018 | ||
| 1023 | raw_spin_lock_irqsave(¤t->pi_lock, flags); | 1019 | raw_spin_lock(¤t->pi_lock); |
| 1024 | rt_mutex_dequeue(lock, waiter); | 1020 | rt_mutex_dequeue(lock, waiter); |
| 1025 | current->pi_blocked_on = NULL; | 1021 | current->pi_blocked_on = NULL; |
| 1026 | raw_spin_unlock_irqrestore(¤t->pi_lock, flags); | 1022 | raw_spin_unlock(¤t->pi_lock); |
| 1027 | 1023 | ||
| 1028 | /* | 1024 | /* |
| 1029 | * Only update priority if the waiter was the highest priority | 1025 | * Only update priority if the waiter was the highest priority |
| @@ -1032,7 +1028,7 @@ static void remove_waiter(struct rt_mutex *lock, · 2 unmodified lines | |||
| 1032 | if (!owner || !is_top_waiter) | 1028 | if (!owner || !is_top_waiter) |
| 1033 | return; | 1029 | return; |
| 1034 | 1030 | ||
| 1035 | raw_spin_lock_irqsave(&owner->pi_lock, flags); | 1031 | raw_spin_lock(&owner->pi_lock); |
| 1036 | 1032 | ||
| 1037 | rt_mutex_dequeue_pi(owner, waiter); | 1033 | rt_mutex_dequeue_pi(owner, waiter); |
| 1038 | 1034 | ||
| @@ -1044,7 +1040,7 @@ static void remove_waiter(struct rt_mutex *lock, · 5 unmodified lines | |||
| 1044 | /* Store the lock on which owner is blocked or NULL */ | 1040 | /* Store the lock on which owner is blocked or NULL */ |
| 1045 | next_lock = task_blocked_on_lock(owner); | 1041 | next_lock = task_blocked_on_lock(owner); |
| 1046 | 1042 | ||
| 1047 | raw_spin_unlock_irqrestore(&owner->pi_lock, flags); | 1043 | raw_spin_unlock(&owner->pi_lock); |
| 1048 | 1044 | ||
| 1049 | /* | 1045 | /* |
| 1050 | * Don't walk the chain, if the owner task is not blocked | 1046 | * Don't walk the chain, if the owner task is not blocked |
| @@ -1056,12 +1052,12 @@ static void remove_waiter(struct rt_mutex *lock, · 5 unmodified lines | |||
| 1056 | /* gets dropped in rt_mutex_adjust_prio_chain()! */ | 1052 | /* gets dropped in rt_mutex_adjust_prio_chain()! */ |
| 1057 | get_task_struct(owner); | 1053 | get_task_struct(owner); |
| 1058 | 1054 | ||
| 1059 | raw_spin_unlock(&lock->wait_lock); | 1055 | raw_spin_unlock_irq(&lock->wait_lock); |
| 1060 | 1056 | ||
| 1061 | rt_mutex_adjust_prio_chain(owner, RT_MUTEX_MIN_CHAINWALK, lock, | 1057 | rt_mutex_adjust_prio_chain(owner, RT_MUTEX_MIN_CHAINWALK, lock, |
| 1062 | next_lock, NULL, current); | 1058 | next_lock, NULL, current); |
| 1063 | 1059 | ||
| 1064 | raw_spin_lock(&lock->wait_lock); | 1060 | raw_spin_lock_irq(&lock->wait_lock); |
| 1065 | } | 1061 | } |
| 1066 | 1062 | ||
| 1067 | /* | 1063 | /* |
| @@ -1097,11 +1093,11 @@ void rt_mutex_adjust_pi(struct task_struct *task) · 29 unmodified lines | |||
| 1097 | * __rt_mutex_slowlock() - Perform the wait-wake-try-to-take loop | 1093 | * __rt_mutex_slowlock() - Perform the wait-wake-try-to-take loop |
| 1098 | * @lock: the rt_mutex to take | 1094 | * @lock: the rt_mutex to take |
| 1099 | * @state: the state the task should block in (TASK_INTERRUPTIBLE | 1095 | * @state: the state the task should block in (TASK_INTERRUPTIBLE |
| 1100 | * or TASK_UNINTERRUPTIBLE) | 1096 | * or TASK_UNINTERRUPTIBLE) |
| 1101 | * @timeout: the pre-initialized and started timer, or NULL for none | 1097 | * @timeout: the pre-initialized and started timer, or NULL for none |
| 1102 | * @waiter: the pre-initialized rt_mutex_waiter | 1098 | * @waiter: the pre-initialized rt_mutex_waiter |
| 1103 | * | 1099 | * |
| 1104 | * lock->wait_lock must be held by the caller. | 1100 | * Must be called with lock->wait_lock held and interrupts disabled |
| 1105 | */ | 1101 | */ |
| 1106 | static int __sched | 1102 | static int __sched |
| 1107 | __rt_mutex_slowlock(struct rt_mutex *lock, int state, | 1103 | __rt_mutex_slowlock(struct rt_mutex *lock, int state, |
| @@ -1129,13 +1125,13 @@ __rt_mutex_slowlock(struct rt_mutex *lock, int state, · 21 unmodified lines | |||
| 1129 | break; | 1125 | break; |
| 1130 | } | 1126 | } |
| 1131 | 1127 | ||
| 1132 | raw_spin_unlock(&lock->wait_lock); | 1128 | raw_spin_unlock_irq(&lock->wait_lock); |
| 1133 | 1129 | ||
| 1134 | debug_rt_mutex_print_deadlock(waiter); | 1130 | debug_rt_mutex_print_deadlock(waiter); |
| 1135 | 1131 | ||
| 1136 | schedule(); | 1132 | schedule(); |
| 1137 | 1133 | ||
| 1138 | raw_spin_lock(&lock->wait_lock); | 1134 | raw_spin_lock_irq(&lock->wait_lock); |
| 1139 | set_current_state(state); | 1135 | set_current_state(state); |
| 1140 | } | 1136 | } |
| 1141 | 1137 | ||
| @@ -1172,17 +1168,26 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, · 30 unmodified lines | |||
| 1172 | enum rtmutex_chainwalk chwalk) | 1168 | enum rtmutex_chainwalk chwalk) |
| 1173 | { | 1169 | { |
| 1174 | struct rt_mutex_waiter waiter; | 1170 | struct rt_mutex_waiter waiter; |
| 1171 | unsigned long flags; | ||
| 1175 | int ret = 0; | 1172 | int ret = 0; |
| 1176 | 1173 | ||
| 1177 | debug_rt_mutex_init_waiter(&waiter); | 1174 | debug_rt_mutex_init_waiter(&waiter); |
| 1178 | RB_CLEAR_NODE(&waiter.pi_tree_entry); | 1175 | RB_CLEAR_NODE(&waiter.pi_tree_entry); |
| 1179 | RB_CLEAR_NODE(&waiter.tree_entry); | 1176 | RB_CLEAR_NODE(&waiter.tree_entry); |
| 1180 | 1177 | ||
| 1181 | raw_spin_lock(&lock->wait_lock); | 1178 | /* |
| 1179 | * Technically we could use raw_spin_[un]lock_irq() here, but this can | ||
| 1180 | * be called in early boot if the cmpxchg() fast path is disabled | ||
| 1181 | * (debug, no architecture support). In this case we will acquire the | ||
| 1182 | * rtmutex with lock->wait_lock held. But we cannot unconditionally | ||
| 1183 | * enable interrupts in that early boot case. So we need to use the | ||
| 1184 | * irqsave/restore variants. | ||
| 1185 | */ | ||
| 1186 | raw_spin_lock_irqsave(&lock->wait_lock, flags); | ||
| 1182 | 1187 | ||
| 1183 | /* Try to acquire the lock again: */ | 1188 | /* Try to acquire the lock again: */ |
| 1184 | if (try_to_take_rt_mutex(lock, current, NULL)) { | 1189 | if (try_to_take_rt_mutex(lock, current, NULL)) { |
| 1185 | raw_spin_unlock(&lock->wait_lock); | 1190 | raw_spin_unlock_irqrestore(&lock->wait_lock, flags); |
| 1186 | return 0; | 1191 | return 0; |
| 1187 | } | 1192 | } |
| 1188 | 1193 | ||
| @@ -1211,7 +1216,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, · 22 unmodified lines | |||
| 1211 | */ | 1216 | */ |
| 1212 | fixup_rt_mutex_waiters(lock); | 1217 | fixup_rt_mutex_waiters(lock); |
| 1213 | 1218 | ||
| 1214 | raw_spin_unlock(&lock->wait_lock); | 1219 | raw_spin_unlock_irqrestore(&lock->wait_lock, flags); |
| 1215 | 1220 | ||
| 1216 | /* Remove pending timer: */ | 1221 | /* Remove pending timer: */ |
| 1217 | if (unlikely(timeout)) | 1222 | if (unlikely(timeout)) |
| @@ -1227,6 +1232,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, · 9 unmodified lines | |||
| 1227 | */ | 1232 | */ |
| 1228 | static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) | 1233 | static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) |
| 1229 | { | 1234 | { |
| 1235 | unsigned long flags; | ||
| 1230 | int ret; | 1236 | int ret; |
| 1231 | 1237 | ||
| 1232 | /* | 1238 | /* |
| @@ -1238,10 +1244,10 @@ static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) · 5 unmodified lines | |||
| 1238 | return 0; | 1244 | return 0; |
| 1239 | 1245 | ||
| 1240 | /* | 1246 | /* |
| 1241 | * The mutex has currently no owner. Lock the wait lock and | 1247 | * The mutex has currently no owner. Lock the wait lock and try to |
| 1242 | * try to acquire the lock. | 1248 | * acquire the lock. We use irqsave here to support early boot calls. |
| 1243 | */ | 1249 | */ |
| 1244 | raw_spin_lock(&lock->wait_lock); | 1250 | raw_spin_lock_irqsave(&lock->wait_lock, flags); |
| 1245 | 1251 | ||
| 1246 | ret = try_to_take_rt_mutex(lock, current, NULL); | 1252 | ret = try_to_take_rt_mutex(lock, current, NULL); |
| 1247 | 1253 | ||
| @@ -1251,7 +1257,7 @@ static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) · 3 unmodified lines | |||
| 1251 | */ | 1257 | */ |
| 1252 | fixup_rt_mutex_waiters(lock); | 1258 | fixup_rt_mutex_waiters(lock); |
| 1253 | 1259 | ||
| 1254 | raw_spin_unlock(&lock->wait_lock); | 1260 | raw_spin_unlock_irqrestore(&lock->wait_lock, flags); |
| 1255 | 1261 | ||
| 1256 | return ret; | 1262 | return ret; |
| 1257 | } | 1263 | } |
| @@ -1263,7 +1269,10 @@ static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) · 5 unmodified lines | |||
| 1263 | static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, | 1269 | static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, |
| 1264 | struct wake_q_head *wake_q) | 1270 | struct wake_q_head *wake_q) |
| 1265 | { | 1271 | { |
| 1266 | raw_spin_lock(&lock->wait_lock); | 1272 | unsigned long flags; |
| 1273 | |||
| 1274 | /* irqsave required to support early boot calls */ | ||
| 1275 | raw_spin_lock_irqsave(&lock->wait_lock, flags); | ||
| 1267 | 1276 | ||
| 1268 | debug_rt_mutex_unlock(lock); | 1277 | debug_rt_mutex_unlock(lock); |
| 1269 | 1278 | ||
| @@ -1302,10 +1311,10 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, · 32 unmodified lines | |||
| 1302 | */ | 1311 | */ |
| 1303 | while (!rt_mutex_has_waiters(lock)) { | 1312 | while (!rt_mutex_has_waiters(lock)) { |
| 1304 | /* Drops lock->wait_lock ! */ | 1313 | /* Drops lock->wait_lock ! */ |
| 1305 | if (unlock_rt_mutex_safe(lock) == true) | 1314 | if (unlock_rt_mutex_safe(lock, flags) == true) |
| 1306 | return false; | 1315 | return false; |
| 1307 | /* Relock the rtmutex and try again */ | 1316 | /* Relock the rtmutex and try again */ |
| 1308 | raw_spin_lock(&lock->wait_lock); | 1317 | raw_spin_lock_irqsave(&lock->wait_lock, flags); |
| 1309 | } | 1318 | } |
| 1310 | 1319 | ||
| 1311 | /* | 1320 | /* |
| @@ -1316,7 +1325,7 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, · 4 unmodified lines | |||
| 1316 | */ | 1325 | */ |
| 1317 | mark_wakeup_next_waiter(wake_q, lock); | 1326 | mark_wakeup_next_waiter(wake_q, lock); |
| 1318 | 1327 | ||
| 1319 | raw_spin_unlock(&lock->wait_lock); | 1328 | raw_spin_unlock_irqrestore(&lock->wait_lock, flags); |
| 1320 | 1329 | ||
| 1321 | /* check PI boosting */ | 1330 | /* check PI boosting */ |
| 1322 | return true; | 1331 | return true; |
| @@ -1596,10 +1605,10 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock, · 273 unmodified lines | |||
| 1596 | { | 1605 | { |
| 1597 | int ret; | 1606 | int ret; |
| 1598 | 1607 | ||
| 1599 | raw_spin_lock(&lock->wait_lock); | 1608 | raw_spin_lock_irq(&lock->wait_lock); |
| 1600 | 1609 | ||
| 1601 | if (try_to_take_rt_mutex(lock, task, NULL)) { | 1610 | if (try_to_take_rt_mutex(lock, task, NULL)) { |
| 1602 | raw_spin_unlock(&lock->wait_lock); | 1611 | raw_spin_unlock_irq(&lock->wait_lock); |
| 1603 | return 1; | 1612 | return 1; |
| 1604 | } | 1613 | } |
| 1605 | 1614 | ||
| @@ -1620,7 +1629,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock, · 14 unmodified lines | |||
| 1620 | if (unlikely(ret)) | 1629 | if (unlikely(ret)) |
| 1621 | remove_waiter(lock, waiter); | 1630 | remove_waiter(lock, waiter); |
| 1622 | 1631 | ||
| 1623 | raw_spin_unlock(&lock->wait_lock); | 1632 | raw_spin_unlock_irq(&lock->wait_lock); |
| 1624 | 1633 | ||
| 1625 | debug_rt_mutex_print_deadlock(waiter); | 1634 | debug_rt_mutex_print_deadlock(waiter); |
| 1626 | 1635 | ||
| @@ -1668,7 +1677,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock, · 41 unmodified lines | |||
| 1668 | { | 1677 | { |
| 1669 | int ret; | 1678 | int ret; |
| 1670 | 1679 | ||
| 1671 | raw_spin_lock(&lock->wait_lock); | 1680 | raw_spin_lock_irq(&lock->wait_lock); |
| 1672 | 1681 | ||
| 1673 | set_current_state(TASK_INTERRUPTIBLE); | 1682 | set_current_state(TASK_INTERRUPTIBLE); |
| 1674 | 1683 | ||
| @@ -1684,7 +1693,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock, · 9 unmodified lines | |||
| 1684 | */ | 1693 | */ |
| 1685 | fixup_rt_mutex_waiters(lock); | 1694 | fixup_rt_mutex_waiters(lock); |
| 1686 | 1695 | ||
| 1687 | raw_spin_unlock(&lock->wait_lock); | 1696 | raw_spin_unlock_irq(&lock->wait_lock); |
| 1688 | 1697 | ||
| 1689 | return ret; | 1698 | return ret; |
| 1690 | } | 1699 | } |
| @@ -588,7 +588,7 @@ void __init pidhash_init(void) · 587 unmodified lines | |||
| 588 | 588 | ||
| 589 | void __init pidmap_init(void) | 589 | void __init pidmap_init(void) |
| 590 | { | 590 | { |
| 591 | /* Veryify no one has done anything silly */ | 591 | /* Verify no one has done anything silly: */ |
| 592 | BUILD_BUG_ON(PID_MAX_LIMIT >= PIDNS_HASH_ADDING); | 592 | BUILD_BUG_ON(PID_MAX_LIMIT >= PIDNS_HASH_ADDING); |
| 593 | 593 | ||
| 594 | /* bump default and minimum pid_max based on number of cpus */ | 594 | /* bump default and minimum pid_max based on number of cpus */ |
| @@ -235,7 +235,7 @@ config PM_TRACE_RTC · 234 unmodified lines | |||
| 235 | 235 | ||
| 236 | config APM_EMULATION | 236 | config APM_EMULATION |
| 237 | tristate "Advanced Power Management Emulation" | 237 | tristate "Advanced Power Management Emulation" |
| 238 | depends on PM && SYS_SUPPORTS_APM_EMULATION | 238 | depends on SYS_SUPPORTS_APM_EMULATION |
| 239 | help | 239 | help |
| 240 | APM is a BIOS specification for saving power using several different | 240 | APM is a BIOS specification for saving power using several different |
| 241 | techniques. This is mostly useful for battery powered laptops with | 241 | techniques. This is mostly useful for battery powered laptops with |
| @@ -6840,7 +6840,7 @@ static void sched_init_numa(void) · 6839 unmodified lines | |||
| 6840 | 6840 | ||
| 6841 | sched_domains_numa_masks[i][j] = mask; | 6841 | sched_domains_numa_masks[i][j] = mask; |
| 6842 | 6842 | ||
| 6843 | for (k = 0; k < nr_node_ids; k++) { | 6843 | for_each_node(k) { |
| 6844 | if (node_distance(j, k) > sched_domains_numa_distance[i]) | 6844 | if (node_distance(j, k) > sched_domains_numa_distance[i]) |
| 6845 | continue; | 6845 | continue; |
| 6846 | 6846 | ||
| @@ -1220,8 +1220,6 @@ static void task_numa_assign(struct task_numa_env *env, · 1219 unmodified lines | |||
| 1220 | { | 1220 | { |
| 1221 | if (env->best_task) | 1221 | if (env->best_task) |
| 1222 | put_task_struct(env->best_task); | 1222 | put_task_struct(env->best_task); |
| 1223 | if (p) | ||
| 1224 | get_task_struct(p); | ||
| 1225 | 1223 | ||
| 1226 | env->best_task = p; | 1224 | env->best_task = p; |
| 1227 | env->best_imp = imp; | 1225 | env->best_imp = imp; |
| @@ -1289,20 +1287,30 @@ static void task_numa_compare(struct task_numa_env *env, · 61 unmodified lines | |||
| 1289 | long imp = env->p->numa_group ? groupimp : taskimp; | 1287 | long imp = env->p->numa_group ? groupimp : taskimp; |
| 1290 | long moveimp = imp; | 1288 | long moveimp = imp; |
| 1291 | int dist = env->dist; | 1289 | int dist = env->dist; |
| 1290 | bool assigned = false; | ||
| 1292 | 1291 | ||
| 1293 | rcu_read_lock(); | 1292 | rcu_read_lock(); |
| 1294 | 1293 | ||
| 1295 | raw_spin_lock_irq(&dst_rq->lock); | 1294 | raw_spin_lock_irq(&dst_rq->lock); |
| 1296 | cur = dst_rq->curr; | 1295 | cur = dst_rq->curr; |
| 1297 | /* | 1296 | /* |
| 1298 | * No need to move the exiting task, and this ensures that ->curr | 1297 | * No need to move the exiting task or idle task. |
| 1299 | * wasn't reaped and thus get_task_struct() in task_numa_assign() | ||
| 1300 | * is safe under RCU read lock. | ||
| 1301 | * Note that rcu_read_lock() itself can't protect from the final | ||
| 1302 | * put_task_struct() after the last schedule(). | ||
| 1303 | */ | 1298 | */ |
| 1304 | if ((cur->flags & PF_EXITING) || is_idle_task(cur)) | 1299 | if ((cur->flags & PF_EXITING) || is_idle_task(cur)) |
| 1305 | cur = NULL; | 1300 | cur = NULL; |
| 1301 | else { | ||
| 1302 | /* | ||
| 1303 | * The task_struct must be protected here to protect the | ||
| 1304 | * p->numa_faults access in the task_weight since the | ||
| 1305 | * numa_faults could already be freed in the following path: | ||
| 1306 | * finish_task_switch() | ||
| 1307 | * --> put_task_struct() | ||
| 1308 | * --> __put_task_struct() | ||
| 1309 | * --> task_numa_free() | ||
| 1310 | */ | ||
| 1311 | get_task_struct(cur); | ||
| 1312 | } | ||
| 1313 | |||
| 1306 | raw_spin_unlock_irq(&dst_rq->lock); | 1314 | raw_spin_unlock_irq(&dst_rq->lock); |
| 1307 | 1315 | ||
| 1308 | /* | 1316 | /* |
| @@ -1386,6 +1394,7 @@ balance: · 77 unmodified lines | |||
| 1386 | */ | 1394 | */ |
| 1387 | if (!load_too_imbalanced(src_load, dst_load, env)) { | 1395 | if (!load_too_imbalanced(src_load, dst_load, env)) { |
| 1388 | imp = moveimp - 1; | 1396 | imp = moveimp - 1; |
| 1397 | put_task_struct(cur); | ||
| 1389 | cur = NULL; | 1398 | cur = NULL; |
| 1390 | goto assign; | 1399 | goto assign; |
| 1391 | } | 1400 | } |
| @@ -1411,9 +1420,16 @@ balance: · 19 unmodified lines | |||
| 1411 | env->dst_cpu = select_idle_sibling(env->p, env->dst_cpu); | 1420 | env->dst_cpu = select_idle_sibling(env->p, env->dst_cpu); |
| 1412 | 1421 | ||
| 1413 | assign: | 1422 | assign: |
| 1423 | assigned = true; | ||
| 1414 | task_numa_assign(env, cur, imp); | 1424 | task_numa_assign(env, cur, imp); |
| 1415 | unlock: | 1425 | unlock: |
| 1416 | rcu_read_unlock(); | 1426 | rcu_read_unlock(); |
| 1427 | /* | ||
| 1428 | * The dst_rq->curr isn't assigned. The protection for task_struct is | ||
| 1429 | * finished. | ||
| 1430 | */ | ||
| 1431 | if (cur && !assigned) | ||
| 1432 | put_task_struct(cur); | ||
| 1417 | } | 1433 | } |
| 1418 | 1434 | ||
| 1419 | static void task_numa_find_cpu(struct task_numa_env *env, | 1435 | static void task_numa_find_cpu(struct task_numa_env *env, |
| @@ -162,7 +162,7 @@ static void cpuidle_idle_call(void) · 161 unmodified lines | |||
| 162 | */ | 162 | */ |
| 163 | if (idle_should_freeze()) { | 163 | if (idle_should_freeze()) { |
| 164 | entered_state = cpuidle_enter_freeze(drv, dev); | 164 | entered_state = cpuidle_enter_freeze(drv, dev); |
| 165 | if (entered_state >= 0) { | 165 | if (entered_state > 0) { |
| 166 | local_irq_enable(); | 166 | local_irq_enable(); |
| 167 | goto exit_idle; | 167 | goto exit_idle; |
| 168 | } | 168 | } |
| @@ -316,24 +316,24 @@ static inline void seccomp_sync_threads(void) · 315 unmodified lines | |||
| 316 | put_seccomp_filter(thread); | 316 | put_seccomp_filter(thread); |
| 317 | smp_store_release(&thread->seccomp.filter, | 317 | smp_store_release(&thread->seccomp.filter, |
| 318 | caller->seccomp.filter); | 318 | caller->seccomp.filter); |
| 319 | |||
| 320 | /* | ||
| 321 | * Don't let an unprivileged task work around | ||
| 322 | * the no_new_privs restriction by creating | ||
| 323 | * a thread that sets it up, enters seccomp, | ||
| 324 | * then dies. | ||
| 325 | */ | ||
| 326 | if (task_no_new_privs(caller)) | ||
| 327 | task_set_no_new_privs(thread); | ||
| 328 | |||
| 319 | /* | 329 | /* |
| 320 | * Opt the other thread into seccomp if needed. | 330 | * Opt the other thread into seccomp if needed. |
| 321 | * As threads are considered to be trust-realm | 331 | * As threads are considered to be trust-realm |
| 322 | * equivalent (see ptrace_may_access), it is safe to | 332 | * equivalent (see ptrace_may_access), it is safe to |
| 323 | * allow one thread to transition the other. | 333 | * allow one thread to transition the other. |
| 324 | */ | 334 | */ |
| 325 | if (thread->seccomp.mode == SECCOMP_MODE_DISABLED) { | 335 | if (thread->seccomp.mode == SECCOMP_MODE_DISABLED) |
| 326 | /* | ||
| 327 | * Don't let an unprivileged task work around | ||
| 328 | * the no_new_privs restriction by creating | ||
| 329 | * a thread that sets it up, enters seccomp, | ||
| 330 | * then dies. | ||
| 331 | */ | ||
| 332 | if (task_no_new_privs(caller)) | ||
| 333 | task_set_no_new_privs(thread); | ||
| 334 | |||
| 335 | seccomp_assign_mode(thread, SECCOMP_MODE_FILTER); | 336 | seccomp_assign_mode(thread, SECCOMP_MODE_FILTER); |
| 336 | } | ||
| 337 | } | 337 | } |
| 338 | } | 338 | } |
| 339 | 339 | ||
| @@ -897,10 +897,10 @@ static int enqueue_hrtimer(struct hrtimer *timer, · 896 unmodified lines | |||
| 897 | */ | 897 | */ |
| 898 | static void __remove_hrtimer(struct hrtimer *timer, | 898 | static void __remove_hrtimer(struct hrtimer *timer, |
| 899 | struct hrtimer_clock_base *base, | 899 | struct hrtimer_clock_base *base, |
| 900 | unsigned long newstate, int reprogram) | 900 | u8 newstate, int reprogram) |
| 901 | { | 901 | { |
| 902 | struct hrtimer_cpu_base *cpu_base = base->cpu_base; | 902 | struct hrtimer_cpu_base *cpu_base = base->cpu_base; |
| 903 | unsigned int state = timer->state; | 903 | u8 state = timer->state; |
| 904 | 904 | ||
| 905 | timer->state = newstate; | 905 | timer->state = newstate; |
| 906 | if (!(state & HRTIMER_STATE_ENQUEUED)) | 906 | if (!(state & HRTIMER_STATE_ENQUEUED)) |
| @@ -930,7 +930,7 @@ static inline int · 23 unmodified lines | |||
| 930 | remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, bool restart) | 930 | remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, bool restart) |
| 931 | { | 931 | { |
| 932 | if (hrtimer_is_queued(timer)) { | 932 | if (hrtimer_is_queued(timer)) { |
| 933 | unsigned long state = timer->state; | 933 | u8 state = timer->state; |
| 934 | int reprogram; | 934 | int reprogram; |
| 935 | 935 | ||
| 936 | /* | 936 | /* |
| @@ -954,6 +954,22 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, bool rest · 17 unmodified lines | |||
| 954 | return 0; | 954 | return 0; |
| 955 | } | 955 | } |
| 956 | 956 | ||
| 957 | static inline ktime_t hrtimer_update_lowres(struct hrtimer *timer, ktime_t tim, | ||
| 958 | const enum hrtimer_mode mode) | ||
| 959 | { | ||
| 960 | #ifdef CONFIG_TIME_LOW_RES | ||
| 961 | /* | ||
| 962 | * CONFIG_TIME_LOW_RES indicates that the system has no way to return | ||
| 963 | * granular time values. For relative timers we add hrtimer_resolution | ||
| 964 | * (i.e. one jiffie) to prevent short timeouts. | ||
| 965 | */ | ||
| 966 | timer->is_rel = mode & HRTIMER_MODE_REL; | ||
| 967 | if (timer->is_rel) | ||
| 968 | tim = ktime_add_safe(tim, ktime_set(0, hrtimer_resolution)); | ||
| 969 | #endif | ||
| 970 | return tim; | ||
| 971 | } | ||
| 972 | |||
| 957 | /** | 973 | /** |
| 958 | * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU | 974 | * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU |
| 959 | * @timer: the timer to be added | 975 | * @timer: the timer to be added |
| @@ -974,19 +990,10 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, · 14 unmodified lines | |||
| 974 | /* Remove an active timer from the queue: */ | 990 | /* Remove an active timer from the queue: */ |
| 975 | remove_hrtimer(timer, base, true); | 991 | remove_hrtimer(timer, base, true); |
| 976 | 992 | ||
| 977 | if (mode & HRTIMER_MODE_REL) { | 993 | if (mode & HRTIMER_MODE_REL) |
| 978 | tim = ktime_add_safe(tim, base->get_time()); | 994 | tim = ktime_add_safe(tim, base->get_time()); |
| 979 | /* | 995 | |
| 980 | * CONFIG_TIME_LOW_RES is a temporary way for architectures | 996 | tim = hrtimer_update_lowres(timer, tim, mode); |
| 981 | * to signal that they simply return xtime in | ||
| 982 | * do_gettimeoffset(). In this case we want to round up by | ||
| 983 | * resolution when starting a relative timer, to avoid short | ||
| 984 | * timeouts. This will go away with the GTOD framework. | ||
| 985 | */ | ||
| 986 | #ifdef CONFIG_TIME_LOW_RES | ||
| 987 | tim = ktime_add_safe(tim, ktime_set(0, hrtimer_resolution)); | ||
| 988 | #endif | ||
| 989 | } | ||
| 990 | 997 | ||
| 991 | hrtimer_set_expires_range_ns(timer, tim, delta_ns); | 998 | hrtimer_set_expires_range_ns(timer, tim, delta_ns); |
| 992 | 999 | ||
| @@ -1074,19 +1081,23 @@ EXPORT_SYMBOL_GPL(hrtimer_cancel); · 81 unmodified lines | |||
| 1074 | /** | 1081 | /** |
| 1075 | * hrtimer_get_remaining - get remaining time for the timer | 1082 | * hrtimer_get_remaining - get remaining time for the timer |
| 1076 | * @timer: the timer to read | 1083 | * @timer: the timer to read |
| 1084 | * @adjust: adjust relative timers when CONFIG_TIME_LOW_RES=y | ||
| 1077 | */ | 1085 | */ |
| 1078 | ktime_t hrtimer_get_remaining(const struct hrtimer *timer) | 1086 | ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust) |
| 1079 | { | 1087 | { |
| 1080 | unsigned long flags; | 1088 | unsigned long flags; |
| 1081 | ktime_t rem; | 1089 | ktime_t rem; |
| 1082 | 1090 | ||
| 1083 | lock_hrtimer_base(timer, &flags); | 1091 | lock_hrtimer_base(timer, &flags); |
| 1084 | rem = hrtimer_expires_remaining(timer); | 1092 | if (IS_ENABLED(CONFIG_TIME_LOW_RES) && adjust) |
| 1093 | rem = hrtimer_expires_remaining_adjusted(timer); | ||
| 1094 | else | ||
| 1095 | rem = hrtimer_expires_remaining(timer); | ||
| 1085 | unlock_hrtimer_base(timer, &flags); | 1096 | unlock_hrtimer_base(timer, &flags); |
| 1086 | 1097 | ||
| 1087 | return rem; | 1098 | return rem; |
| 1088 | } | 1099 | } |
| 1089 | EXPORT_SYMBOL_GPL(hrtimer_get_remaining); | 1100 | EXPORT_SYMBOL_GPL(__hrtimer_get_remaining); |
| 1090 | 1101 | ||
| 1091 | #ifdef CONFIG_NO_HZ_COMMON | 1102 | #ifdef CONFIG_NO_HZ_COMMON |
| 1092 | /** | 1103 | /** |
| @@ -1219,6 +1230,14 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, · 126 unmodified lines | |||
| 1219 | timer_stats_account_hrtimer(timer); | 1230 | timer_stats_account_hrtimer(timer); |
| 1220 | fn = timer->function; | 1231 | fn = timer->function; |
| 1221 | 1232 | ||
| 1233 | /* | ||
| 1234 | * Clear the 'is relative' flag for the TIME_LOW_RES case. If the | ||
| 1235 | * timer is restarted with a period then it becomes an absolute | ||
| 1236 | * timer. If its not restarted it does not matter. | ||
| 1237 | */ | ||
| 1238 | if (IS_ENABLED(CONFIG_TIME_LOW_RES)) | ||
| 1239 | timer->is_rel = false; | ||
| 1240 | |||
| 1222 | /* | 1241 | /* |
| 1223 | * Because we run timers from hardirq context, there is no chance | 1242 | * Because we run timers from hardirq context, there is no chance |
| 1224 | * they get migrated to another cpu, therefore its safe to unlock | 1243 | * they get migrated to another cpu, therefore its safe to unlock |
| @@ -26,7 +26,7 @@ · 25 unmodified lines | |||
| 26 | */ | 26 | */ |
| 27 | static struct timeval itimer_get_remtime(struct hrtimer *timer) | 27 | static struct timeval itimer_get_remtime(struct hrtimer *timer) |
| 28 | { | 28 | { |
| 29 | ktime_t rem = hrtimer_get_remaining(timer); | 29 | ktime_t rem = __hrtimer_get_remaining(timer, true); |
| 30 | 30 | ||
| 31 | /* | 31 | /* |
| 32 | * Racy but safe: if the itimer expires after the above | 32 | * Racy but safe: if the itimer expires after the above |
| @@ -685,8 +685,18 @@ int ntp_validate_timex(struct timex *txc) · 684 unmodified lines | |||
| 685 | if (!capable(CAP_SYS_TIME)) | 685 | if (!capable(CAP_SYS_TIME)) |
| 686 | return -EPERM; | 686 | return -EPERM; |
| 687 | 687 | ||
| 688 | if (!timeval_inject_offset_valid(&txc->time)) | 688 | if (txc->modes & ADJ_NANO) { |
| 689 | return -EINVAL; | 689 | struct timespec ts; |
| 690 | |||
| 691 | ts.tv_sec = txc->time.tv_sec; | ||
| 692 | ts.tv_nsec = txc->time.tv_usec; | ||
| 693 | if (!timespec_inject_offset_valid(&ts)) | ||
| 694 | return -EINVAL; | ||
| 695 | |||
| 696 | } else { | ||
| 697 | if (!timeval_inject_offset_valid(&txc->time)) | ||
| 698 | return -EINVAL; | ||
| 699 | } | ||
| 690 | } | 700 | } |
| 691 | 701 | ||
| 692 | /* | 702 | /* |
| @@ -760,7 +760,7 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) · 759 unmodified lines | |||
| 760 | (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) | 760 | (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) |
| 761 | timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv); | 761 | timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv); |
| 762 | 762 | ||
| 763 | remaining = ktime_sub(hrtimer_get_expires(timer), now); | 763 | remaining = __hrtimer_expires_remaining_adjusted(timer, now); |
| 764 | /* Return 0 only, when the timer is expired and not pending */ | 764 | /* Return 0 only, when the timer is expired and not pending */ |
| 765 | if (remaining.tv64 <= 0) { | 765 | if (remaining.tv64 <= 0) { |
| 766 | /* | 766 | /* |
| @@ -36,16 +36,17 @@ · 35 unmodified lines | |||
| 36 | */ | 36 | */ |
| 37 | static DEFINE_PER_CPU(struct tick_sched, tick_cpu_sched); | 37 | static DEFINE_PER_CPU(struct tick_sched, tick_cpu_sched); |
| 38 | 38 | ||
| 39 | /* | ||
| 40 | * The time, when the last jiffy update happened. Protected by jiffies_lock. | ||
| 41 | */ | ||
| 42 | static ktime_t last_jiffies_update; | ||
| 43 | |||
| 44 | struct tick_sched *tick_get_tick_sched(int cpu) | 39 | struct tick_sched *tick_get_tick_sched(int cpu) |
| 45 | { | 40 | { |
| 46 | return &per_cpu(tick_cpu_sched, cpu); | 41 | return &per_cpu(tick_cpu_sched, cpu); |
| 47 | } | 42 | } |
| 48 | 43 | ||
| 44 | #if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS) | ||
| 45 | /* | ||
| 46 | * The time, when the last jiffy update happened. Protected by jiffies_lock. | ||
| 47 | */ | ||
| 48 | static ktime_t last_jiffies_update; | ||
| 49 | |||
| 49 | /* | 50 | /* |
| 50 | * Must be called with interrupts disabled ! | 51 | * Must be called with interrupts disabled ! |
| 51 | */ | 52 | */ |
| @@ -151,6 +152,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs) · 99 unmodified lines | |||
| 151 | update_process_times(user_mode(regs)); | 152 | update_process_times(user_mode(regs)); |
| 152 | profile_tick(CPU_PROFILING); | 153 | profile_tick(CPU_PROFILING); |
| 153 | } | 154 | } |
| 155 | #endif | ||
| 154 | 156 | ||
| 155 | #ifdef CONFIG_NO_HZ_FULL | 157 | #ifdef CONFIG_NO_HZ_FULL |
| 156 | cpumask_var_t tick_nohz_full_mask; | 158 | cpumask_var_t tick_nohz_full_mask; |
| @@ -993,9 +995,9 @@ static void tick_nohz_switch_to_nohz(void) · 836 unmodified lines | |||
| 993 | /* Get the next period */ | 995 | /* Get the next period */ |
| 994 | next = tick_init_jiffy_update(); | 996 | next = tick_init_jiffy_update(); |
| 995 | 997 | ||
| 996 | hrtimer_forward_now(&ts->sched_timer, tick_period); | ||
| 997 | hrtimer_set_expires(&ts->sched_timer, next); | 998 | hrtimer_set_expires(&ts->sched_timer, next); |
| 998 | tick_program_event(next, 1); | 999 | hrtimer_forward_now(&ts->sched_timer, tick_period); |
| 1000 | tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); | ||
| 999 | tick_nohz_activate(ts, NOHZ_MODE_LOWRES); | 1001 | tick_nohz_activate(ts, NOHZ_MODE_LOWRES); |
| 1000 | } | 1002 | } |
| 1001 | 1003 | ||
| @@ -69,7 +69,7 @@ print_timer(struct seq_file *m, struct hrtimer *taddr, struct hrtimer *timer, · 68 unmodified lines | |||
| 69 | print_name_offset(m, taddr); | 69 | print_name_offset(m, taddr); |
| 70 | SEQ_printf(m, ", "); | 70 | SEQ_printf(m, ", "); |
| 71 | print_name_offset(m, timer->function); | 71 | print_name_offset(m, timer->function); |
| 72 | SEQ_printf(m, ", S:%02lx", timer->state); | 72 | SEQ_printf(m, ", S:%02x", timer->state); |
| 73 | #ifdef CONFIG_TIMER_STATS | 73 | #ifdef CONFIG_TIMER_STATS |
| 74 | SEQ_printf(m, ", "); | 74 | SEQ_printf(m, ", "); |
| 75 | print_name_offset(m, timer->start_site); | 75 | print_name_offset(m, timer->start_site); |
| @@ -191,14 +191,17 @@ static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5) · 190 unmodified lines | |||
| 191 | struct bpf_map *map = (struct bpf_map *) (unsigned long) r1; | 191 | struct bpf_map *map = (struct bpf_map *) (unsigned long) r1; |
| 192 | struct bpf_array *array = container_of(map, struct bpf_array, map); | 192 | struct bpf_array *array = container_of(map, struct bpf_array, map); |
| 193 | struct perf_event *event; | 193 | struct perf_event *event; |
| 194 | struct file *file; | ||
| 194 | 195 | ||
| 195 | if (unlikely(index >= array->map.max_entries)) | 196 | if (unlikely(index >= array->map.max_entries)) |
| 196 | return -E2BIG; | 197 | return -E2BIG; |
| 197 | 198 | ||
| 198 | event = (struct perf_event *)array->ptrs[index]; | 199 | file = (struct file *)array->ptrs[index]; |
| 199 | if (!event) | 200 | if (unlikely(!file)) |
| 200 | return -ENOENT; | 201 | return -ENOENT; |
| 201 | 202 | ||
| 203 | event = file->private_data; | ||
| 204 | |||
| 202 | /* make sure event is local and doesn't have pmu::count */ | 205 | /* make sure event is local and doesn't have pmu::count */ |
| 203 | if (event->oncpu != smp_processor_id() || | 206 | if (event->oncpu != smp_processor_id() || |
| 204 | event->pmu->count) | 207 | event->pmu->count) |
| @@ -228,6 +231,7 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 index, u64 r4, u64 size) · 23 unmodified lines | |||
| 228 | void *data = (void *) (long) r4; | 231 | void *data = (void *) (long) r4; |
| 229 | struct perf_sample_data sample_data; | 232 | struct perf_sample_data sample_data; |
| 230 | struct perf_event *event; | 233 | struct perf_event *event; |
| 234 | struct file *file; | ||
| 231 | struct perf_raw_record raw = { | 235 | struct perf_raw_record raw = { |
| 232 | .size = size, | 236 | .size = size, |
| 233 | .data = data, | 237 | .data = data, |
| @@ -236,10 +240,12 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 index, u64 r4, u64 size) · 2 unmodified lines | |||
| 236 | if (unlikely(index >= array->map.max_entries)) | 240 | if (unlikely(index >= array->map.max_entries)) |
| 237 | return -E2BIG; | 241 | return -E2BIG; |
| 238 | 242 | ||
| 239 | event = (struct perf_event *)array->ptrs[index]; | 243 | file = (struct file *)array->ptrs[index]; |
| 240 | if (unlikely(!event)) | 244 | if (unlikely(!file)) |
| 241 | return -ENOENT; | 245 | return -ENOENT; |
| 242 | 246 | ||
| 247 | event = file->private_data; | ||
| 248 | |||
| 243 | if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE || | 249 | if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE || |
| 244 | event->attr.config != PERF_COUNT_SW_BPF_OUTPUT)) | 250 | event->attr.config != PERF_COUNT_SW_BPF_OUTPUT)) |
| 245 | return -EINVAL; | 251 | return -EINVAL; |
| @@ -1751,7 +1751,7 @@ void trace_buffer_unlock_commit_regs(struct trace_array *tr, · 1750 unmodified lines | |||
| 1751 | { | 1751 | { |
| 1752 | __buffer_unlock_commit(buffer, event); | 1752 | __buffer_unlock_commit(buffer, event); |
| 1753 | 1753 | ||
| 1754 | ftrace_trace_stack(tr, buffer, flags, 6, pc, regs); | 1754 | ftrace_trace_stack(tr, buffer, flags, 0, pc, regs); |
| 1755 | ftrace_trace_userstack(buffer, flags, pc); | 1755 | ftrace_trace_userstack(buffer, flags, pc); |
| 1756 | } | 1756 | } |
| 1757 | EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit_regs); | 1757 | EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit_regs); |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | |||
| 21 | #define ODEBUG_HASH_BITS 14 | 21 | #define ODEBUG_HASH_BITS 14 |
| 22 | #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS) | 22 | #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS) |
| 23 | 23 | ||
| 24 | #define ODEBUG_POOL_SIZE 512 | 24 | #define ODEBUG_POOL_SIZE 1024 |
| 25 | #define ODEBUG_POOL_MIN_LEVEL 256 | 25 | #define ODEBUG_POOL_MIN_LEVEL 256 |
| 26 | 26 | ||
| 27 | #define ODEBUG_CHUNK_SHIFT PAGE_SHIFT | 27 | #define ODEBUG_CHUNK_SHIFT PAGE_SHIFT |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | * cleancache_ops is set by cleancache_register_ops to contain the pointers | 22 | * cleancache_ops is set by cleancache_register_ops to contain the pointers |
| 23 | * to the cleancache "backend" implementation functions. | 23 | * to the cleancache "backend" implementation functions. |
| 24 | */ | 24 | */ |
| 25 | static struct cleancache_ops *cleancache_ops __read_mostly; | 25 | static const struct cleancache_ops *cleancache_ops __read_mostly; |
| 26 | 26 | ||
| 27 | /* | 27 | /* |
| 28 | * Counters available via /sys/kernel/debug/cleancache (if debugfs is | 28 | * Counters available via /sys/kernel/debug/cleancache (if debugfs is |
| @@ -49,7 +49,7 @@ static void cleancache_register_ops_sb(struct super_block *sb, void *unused) · 20 unmodified lines | |||
| 49 | /* | 49 | /* |
| 50 | * Register operations for cleancache. Returns 0 on success. | 50 | * Register operations for cleancache. Returns 0 on success. |
| 51 | */ | 51 | */ |
| 52 | int cleancache_register_ops(struct cleancache_ops *ops) | 52 | int cleancache_register_ops(const struct cleancache_ops *ops) |
| 53 | { | 53 | { |
| 54 | if (cmpxchg(&cleancache_ops, NULL, ops)) | 54 | if (cmpxchg(&cleancache_ops, NULL, ops)) |
| 55 | return -EBUSY; | 55 | return -EBUSY; |
| @@ -594,7 +594,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) · 593 unmodified lines | |||
| 594 | if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 || | 594 | if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 || |
| 595 | strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 || | 595 | strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 || |
| 596 | strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || | 596 | strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || |
| 597 | strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0) | 597 | strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0 || |
| 598 | strcmp(symname, ".TOC.") == 0) | ||
| 598 | return 1; | 599 | return 1; |
| 599 | /* Do not ignore this symbol */ | 600 | /* Do not ignore this symbol */ |
| 600 | return 0; | 601 | return 0; |
| @@ -430,7 +430,8 @@ static int __key_instantiate_and_link(struct key *key, · 429 unmodified lines | |||
| 430 | 430 | ||
| 431 | /* and link it into the destination keyring */ | 431 | /* and link it into the destination keyring */ |
| 432 | if (keyring) { | 432 | if (keyring) { |
| 433 | set_bit(KEY_FLAG_KEEP, &key->flags); | 433 | if (test_bit(KEY_FLAG_KEEP, &keyring->flags)) |
| 434 | set_bit(KEY_FLAG_KEEP, &key->flags); | ||
| 434 | 435 | ||
| 435 | __key_link(key, _edit); | 436 | __key_link(key, _edit); |
| 436 | } | 437 | } |
| @@ -97,11 +97,11 @@ config SND_PCM_TIMER · 96 unmodified lines | |||
| 97 | bool "PCM timer interface" if EXPERT | 97 | bool "PCM timer interface" if EXPERT |
| 98 | default y | 98 | default y |
| 99 | help | 99 | help |
| 100 | If you disable this option, pcm timer will be inavailable, so | 100 | If you disable this option, pcm timer will be unavailable, so |
| 101 | those stubs used pcm timer (e.g. dmix, dsnoop & co) may work | 101 | those stubs that use pcm timer (e.g. dmix, dsnoop & co) may work |
| 102 | incorrectlly. | 102 | incorrectlly. |
| 103 | 103 | ||
| 104 | For some embedded device, we may disable it to reduce memory | 104 | For some embedded devices, we may disable it to reduce memory |
| 105 | footprint, about 20KB on x86_64 platform. | 105 | footprint, about 20KB on x86_64 platform. |
| 106 | 106 | ||
| 107 | config SND_SEQUENCER_OSS | 107 | config SND_SEQUENCER_OSS |
| @@ -46,6 +46,13 @@ · 45 unmodified lines | |||
| 46 | #include <sound/compress_offload.h> | 46 | #include <sound/compress_offload.h> |
| 47 | #include <sound/compress_driver.h> | 47 | #include <sound/compress_driver.h> |
| 48 | 48 | ||
| 49 | /* struct snd_compr_codec_caps overflows the ioctl bit size for some | ||
| 50 | * architectures, so we need to disable the relevant ioctls. | ||
| 51 | */ | ||
| 52 | #if _IOC_SIZEBITS < 14 | ||
| 53 | #define COMPR_CODEC_CAPS_OVERFLOW | ||
| 54 | #endif | ||
| 55 | |||
| 49 | /* TODO: | 56 | /* TODO: |
| 50 | * - add substream support for multiple devices in case of | 57 | * - add substream support for multiple devices in case of |
| 51 | * SND_DYNAMIC_MINORS is not used | 58 | * SND_DYNAMIC_MINORS is not used |
| @@ -440,6 +447,7 @@ out: · 388 unmodified lines | |||
| 440 | return retval; | 447 | return retval; |
| 441 | } | 448 | } |
| 442 | 449 | ||
| 450 | #ifndef COMPR_CODEC_CAPS_OVERFLOW | ||
| 443 | static int | 451 | static int |
| 444 | snd_compr_get_codec_caps(struct snd_compr_stream *stream, unsigned long arg) | 452 | snd_compr_get_codec_caps(struct snd_compr_stream *stream, unsigned long arg) |
| 445 | { | 453 | { |
| @@ -463,6 +471,7 @@ out: · 17 unmodified lines | |||
| 463 | kfree(caps); | 471 | kfree(caps); |
| 464 | return retval; | 472 | return retval; |
| 465 | } | 473 | } |
| 474 | #endif /* !COMPR_CODEC_CAPS_OVERFLOW */ | ||
| 466 | 475 | ||
| 467 | /* revisit this with snd_pcm_preallocate_xxx */ | 476 | /* revisit this with snd_pcm_preallocate_xxx */ |
| 468 | static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, | 477 | static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, |
| @@ -801,9 +810,11 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) · 332 unmodified lines | |||
| 801 | case _IOC_NR(SNDRV_COMPRESS_GET_CAPS): | 810 | case _IOC_NR(SNDRV_COMPRESS_GET_CAPS): |
| 802 | retval = snd_compr_get_caps(stream, arg); | 811 | retval = snd_compr_get_caps(stream, arg); |
| 803 | break; | 812 | break; |
| 813 | #ifndef COMPR_CODEC_CAPS_OVERFLOW | ||
| 804 | case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS): | 814 | case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS): |
| 805 | retval = snd_compr_get_codec_caps(stream, arg); | 815 | retval = snd_compr_get_codec_caps(stream, arg); |
| 806 | break; | 816 | break; |
| 817 | #endif | ||
| 807 | case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS): | 818 | case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS): |
| 808 | retval = snd_compr_set_params(stream, arg); | 819 | retval = snd_compr_set_params(stream, arg); |
| 809 | break; | 820 | break; |
| @@ -202,7 +202,7 @@ snd_seq_oss_open(struct file *file, int level) · 201 unmodified lines | |||
| 202 | 202 | ||
| 203 | dp->index = i; | 203 | dp->index = i; |
| 204 | if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) { | 204 | if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) { |
| 205 | pr_err("ALSA: seq_oss: too many applications\n"); | 205 | pr_debug("ALSA: seq_oss: too many applications\n"); |
| 206 | rc = -ENOMEM; | 206 | rc = -ENOMEM; |
| 207 | goto _error; | 207 | goto _error; |
| 208 | } | 208 | } |
| @@ -308,7 +308,7 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp) · 307 unmodified lines | |||
| 308 | struct seq_oss_synth *rec; | 308 | struct seq_oss_synth *rec; |
| 309 | struct seq_oss_synthinfo *info; | 309 | struct seq_oss_synthinfo *info; |
| 310 | 310 | ||
| 311 | if (snd_BUG_ON(dp->max_synthdev >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS)) | 311 | if (snd_BUG_ON(dp->max_synthdev > SNDRV_SEQ_OSS_MAX_SYNTH_DEVS)) |
| 312 | return; | 312 | return; |
| 313 | for (i = 0; i < dp->max_synthdev; i++) { | 313 | for (i = 0; i < dp->max_synthdev; i++) { |
| 314 | info = &dp->synths[i]; | 314 | info = &dp->synths[i]; |
| @@ -87,7 +87,7 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-128) for dummy driver."); · 86 unmodified lines | |||
| 87 | module_param(fake_buffer, bool, 0444); | 87 | module_param(fake_buffer, bool, 0444); |
| 88 | MODULE_PARM_DESC(fake_buffer, "Fake buffer allocations."); | 88 | MODULE_PARM_DESC(fake_buffer, "Fake buffer allocations."); |
| 89 | #ifdef CONFIG_HIGH_RES_TIMERS | 89 | #ifdef CONFIG_HIGH_RES_TIMERS |
| 90 | module_param(hrtimer, bool, 0644); | 90 | module_param(hrtimer, bool, 0444); |
| 91 | MODULE_PARM_DESC(hrtimer, "Use hrtimer as the timer source."); | 91 | MODULE_PARM_DESC(hrtimer, "Use hrtimer as the timer source."); |
| 92 | #endif | 92 | #endif |
| 93 | 93 | ||
| @@ -47,14 +47,16 @@ static const unsigned int bridgeco_freq_table[] = { · 46 unmodified lines | |||
| 47 | [6] = 0x07, | 47 | [6] = 0x07, |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | static unsigned int | 50 | static int |
| 51 | get_formation_index(unsigned int rate) | 51 | get_formation_index(unsigned int rate, unsigned int *index) |
| 52 | { | 52 | { |
| 53 | unsigned int i; | 53 | unsigned int i; |
| 54 | 54 | ||
| 55 | for (i = 0; i < ARRAY_SIZE(snd_bebob_rate_table); i++) { | 55 | for (i = 0; i < ARRAY_SIZE(snd_bebob_rate_table); i++) { |
| 56 | if (snd_bebob_rate_table[i] == rate) | 56 | if (snd_bebob_rate_table[i] == rate) { |
| 57 | return i; | 57 | *index = i; |
| 58 | return 0; | ||
| 59 | } | ||
| 58 | } | 60 | } |
| 59 | return -EINVAL; | 61 | return -EINVAL; |
| 60 | } | 62 | } |
| @@ -425,7 +427,9 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate) · 364 unmodified lines | |||
| 425 | goto end; | 427 | goto end; |
| 426 | 428 | ||
| 427 | /* confirm params for both streams */ | 429 | /* confirm params for both streams */ |
| 428 | index = get_formation_index(rate); | 430 | err = get_formation_index(rate, &index); |
| 431 | if (err < 0) | ||
| 432 | goto end; | ||
| 429 | pcm_channels = bebob->tx_stream_formations[index].pcm; | 433 | pcm_channels = bebob->tx_stream_formations[index].pcm; |
| 430 | midi_channels = bebob->tx_stream_formations[index].midi; | 434 | midi_channels = bebob->tx_stream_formations[index].midi; |
| 431 | err = amdtp_am824_set_parameters(&bebob->tx_stream, rate, | 435 | err = amdtp_am824_set_parameters(&bebob->tx_stream, rate, |
| @@ -3,6 +3,7 @@ · 2 unmodified lines | |||
| 3 | config SND_WSS_LIB | 3 | config SND_WSS_LIB |
| 4 | tristate | 4 | tristate |
| 5 | select SND_PCM | 5 | select SND_PCM |
| 6 | select SND_TIMER | ||
| 6 | 7 | ||
| 7 | config SND_SB_COMMON | 8 | config SND_SB_COMMON |
| 8 | tristate | 9 | tristate |
| @@ -42,6 +43,7 @@ config SND_AD1816A · 33 unmodified lines | |||
| 42 | select SND_OPL3_LIB | 43 | select SND_OPL3_LIB |
| 43 | select SND_MPU401_UART | 44 | select SND_MPU401_UART |
| 44 | select SND_PCM | 45 | select SND_PCM |
| 46 | select SND_TIMER | ||
| 45 | help | 47 | help |
| 46 | Say Y here to include support for Analog Devices SoundPort | 48 | Say Y here to include support for Analog Devices SoundPort |
| 47 | AD1816A or compatible sound chips. | 49 | AD1816A or compatible sound chips. |
| @@ -209,6 +211,7 @@ config SND_GUSCLASSIC · 161 unmodified lines | |||
| 209 | tristate "Gravis UltraSound Classic" | 211 | tristate "Gravis UltraSound Classic" |
| 210 | select SND_RAWMIDI | 212 | select SND_RAWMIDI |
| 211 | select SND_PCM | 213 | select SND_PCM |
| 214 | select SND_TIMER | ||
| 212 | help | 215 | help |
| 213 | Say Y here to include support for Gravis UltraSound Classic | 216 | Say Y here to include support for Gravis UltraSound Classic |
| 214 | soundcards. | 217 | soundcards. |
| @@ -221,6 +224,7 @@ config SND_GUSEXTREME · 6 unmodified lines | |||
| 221 | select SND_OPL3_LIB | 224 | select SND_OPL3_LIB |
| 222 | select SND_MPU401_UART | 225 | select SND_MPU401_UART |
| 223 | select SND_PCM | 226 | select SND_PCM |
| 227 | select SND_TIMER | ||
| 224 | help | 228 | help |
| 225 | Say Y here to include support for Gravis UltraSound Extreme | 229 | Say Y here to include support for Gravis UltraSound Extreme |
| 226 | soundcards. | 230 | soundcards. |
| @@ -155,6 +155,7 @@ config SND_AZT3328 · 154 unmodified lines | |||
| 155 | select SND_PCM | 155 | select SND_PCM |
| 156 | select SND_RAWMIDI | 156 | select SND_RAWMIDI |
| 157 | select SND_AC97_CODEC | 157 | select SND_AC97_CODEC |
| 158 | select SND_TIMER | ||
| 158 | depends on ZONE_DMA | 159 | depends on ZONE_DMA |
| 159 | help | 160 | help |
| 160 | Say Y here to include support for Aztech AZF3328 (PCI168) | 161 | Say Y here to include support for Aztech AZF3328 (PCI168) |
| @@ -463,6 +464,7 @@ config SND_EMU10K1 · 302 unmodified lines | |||
| 463 | select SND_HWDEP | 464 | select SND_HWDEP |
| 464 | select SND_RAWMIDI | 465 | select SND_RAWMIDI |
| 465 | select SND_AC97_CODEC | 466 | select SND_AC97_CODEC |
| 467 | select SND_TIMER | ||
| 466 | depends on ZONE_DMA | 468 | depends on ZONE_DMA |
| 467 | help | 469 | help |
| 468 | Say Y to include support for Sound Blaster PCI 512, Live!, | 470 | Say Y to include support for Sound Blaster PCI 512, Live!, |
| @@ -889,6 +891,7 @@ config SND_YMFPCI · 420 unmodified lines | |||
| 889 | select SND_OPL3_LIB | 891 | select SND_OPL3_LIB |
| 890 | select SND_MPU401_UART | 892 | select SND_MPU401_UART |
| 891 | select SND_AC97_CODEC | 893 | select SND_AC97_CODEC |
| 894 | select SND_TIMER | ||
| 892 | help | 895 | help |
| 893 | Say Y here to include support for Yamaha PCI audio chips - | 896 | Say Y here to include support for Yamaha PCI audio chips - |
| 894 | YMF724, YMF724F, YMF740, YMF740C, YMF744, YMF754. | 897 | YMF724, YMF724F, YMF740, YMF740C, YMF744, YMF754. |
| @@ -90,6 +90,8 @@ enum { · 89 unmodified lines | |||
| 90 | #define NVIDIA_HDA_ENABLE_COHBIT 0x01 | 90 | #define NVIDIA_HDA_ENABLE_COHBIT 0x01 |
| 91 | 91 | ||
| 92 | /* Defines for Intel SCH HDA snoop control */ | 92 | /* Defines for Intel SCH HDA snoop control */ |
| 93 | #define INTEL_HDA_CGCTL 0x48 | ||
| 94 | #define INTEL_HDA_CGCTL_MISCBDCGE (0x1 << 6) | ||
| 93 | #define INTEL_SCH_HDA_DEVC 0x78 | 95 | #define INTEL_SCH_HDA_DEVC 0x78 |
| 94 | #define INTEL_SCH_HDA_DEVC_NOSNOOP (0x1<<11) | 96 | #define INTEL_SCH_HDA_DEVC_NOSNOOP (0x1<<11) |
| 95 | 97 | ||
| @@ -534,10 +536,21 @@ static void hda_intel_init_chip(struct azx *chip, bool full_reset) · 438 unmodified lines | |||
| 534 | { | 536 | { |
| 535 | struct hdac_bus *bus = azx_bus(chip); | 537 | struct hdac_bus *bus = azx_bus(chip); |
| 536 | struct pci_dev *pci = chip->pci; | 538 | struct pci_dev *pci = chip->pci; |
| 539 | u32 val; | ||
| 537 | 540 | ||
| 538 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) | 541 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) |
| 539 | snd_hdac_set_codec_wakeup(bus, true); | 542 | snd_hdac_set_codec_wakeup(bus, true); |
| 543 | if (IS_BROXTON(pci)) { | ||
| 544 | pci_read_config_dword(pci, INTEL_HDA_CGCTL, &val); | ||
| 545 | val = val & ~INTEL_HDA_CGCTL_MISCBDCGE; | ||
| 546 | pci_write_config_dword(pci, INTEL_HDA_CGCTL, val); | ||
| 547 | } | ||
| 540 | azx_init_chip(chip, full_reset); | 548 | azx_init_chip(chip, full_reset); |
| 549 | if (IS_BROXTON(pci)) { | ||
| 550 | pci_read_config_dword(pci, INTEL_HDA_CGCTL, &val); | ||
| 551 | val = val | INTEL_HDA_CGCTL_MISCBDCGE; | ||
| 552 | pci_write_config_dword(pci, INTEL_HDA_CGCTL, val); | ||
| 553 | } | ||
| 541 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) | 554 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) |
| 542 | snd_hdac_set_codec_wakeup(bus, false); | 555 | snd_hdac_set_codec_wakeup(bus, false); |
| 543 | 556 | ||
| @@ -3653,6 +3653,7 @@ HDA_CODEC_ENTRY(0x10de0070, "GPU 70 HDMI/DP", patch_nvhdmi), · 3652 unmodified lines | |||
| 3653 | HDA_CODEC_ENTRY(0x10de0071, "GPU 71 HDMI/DP", patch_nvhdmi), | 3653 | HDA_CODEC_ENTRY(0x10de0071, "GPU 71 HDMI/DP", patch_nvhdmi), |
| 3654 | HDA_CODEC_ENTRY(0x10de0072, "GPU 72 HDMI/DP", patch_nvhdmi), | 3654 | HDA_CODEC_ENTRY(0x10de0072, "GPU 72 HDMI/DP", patch_nvhdmi), |
| 3655 | HDA_CODEC_ENTRY(0x10de007d, "GPU 7d HDMI/DP", patch_nvhdmi), | 3655 | HDA_CODEC_ENTRY(0x10de007d, "GPU 7d HDMI/DP", patch_nvhdmi), |
| 3656 | HDA_CODEC_ENTRY(0x10de0083, "GPU 83 HDMI/DP", patch_nvhdmi), | ||
| 3656 | HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI", patch_nvhdmi_2ch), | 3657 | HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI", patch_nvhdmi_2ch), |
| 3657 | HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP", patch_via_hdmi), | 3658 | HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP", patch_via_hdmi), |
| 3658 | HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP", patch_via_hdmi), | 3659 | HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP", patch_via_hdmi), |
| @@ -22,6 +22,7 @@ config SND_SUN_AMD7930 · 21 unmodified lines | |||
| 22 | config SND_SUN_CS4231 | 22 | config SND_SUN_CS4231 |
| 23 | tristate "Sun CS4231" | 23 | tristate "Sun CS4231" |
| 24 | select SND_PCM | 24 | select SND_PCM |
| 25 | select SND_TIMER | ||
| 25 | help | 26 | help |
| 26 | Say Y here to include support for CS4231 sound device on Sun. | 27 | Say Y here to include support for CS4231 sound device on Sun. |
| 27 | 28 | ||
| @@ -1205,8 +1205,12 @@ void snd_usb_set_interface_quirk(struct usb_device *dev) · 1204 unmodified lines | |||
| 1205 | * "Playback Design" products need a 50ms delay after setting the | 1205 | * "Playback Design" products need a 50ms delay after setting the |
| 1206 | * USB interface. | 1206 | * USB interface. |
| 1207 | */ | 1207 | */ |
| 1208 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) | 1208 | switch (le16_to_cpu(dev->descriptor.idVendor)) { |
| 1209 | case 0x23ba: /* Playback Design */ | ||
| 1210 | case 0x0644: /* TEAC Corp. */ | ||
| 1209 | mdelay(50); | 1211 | mdelay(50); |
| 1212 | break; | ||
| 1213 | } | ||
| 1210 | } | 1214 | } |
| 1211 | 1215 | ||
| 1212 | void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, | 1216 | void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, |
| @@ -1221,6 +1225,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, · 8 unmodified lines | |||
| 1221 | (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) | 1225 | (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) |
| 1222 | mdelay(20); | 1226 | mdelay(20); |
| 1223 | 1227 | ||
| 1228 | /* | ||
| 1229 | * "TEAC Corp." products need a 20ms delay after each | ||
| 1230 | * class compliant request | ||
| 1231 | */ | ||
| 1232 | if ((le16_to_cpu(dev->descriptor.idVendor) == 0x0644) && | ||
| 1233 | (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) | ||
| 1234 | mdelay(20); | ||
| 1235 | |||
| 1224 | /* Marantz/Denon devices with USB DAC functionality need a delay | 1236 | /* Marantz/Denon devices with USB DAC functionality need a delay |
| 1225 | * after each class compliant request | 1237 | * after each class compliant request |
| 1226 | */ | 1238 | */ |
| @@ -77,6 +77,9 @@ include config/utilities.mak · 76 unmodified lines | |||
| 77 | # Define NO_AUXTRACE if you do not want AUX area tracing support | 77 | # Define NO_AUXTRACE if you do not want AUX area tracing support |
| 78 | # | 78 | # |
| 79 | # Define NO_LIBBPF if you do not want BPF support | 79 | # Define NO_LIBBPF if you do not want BPF support |
| 80 | # | ||
| 81 | # Define FEATURES_DUMP to provide features detection dump file | ||
| 82 | # and bypass the feature detection | ||
| 80 | 83 | ||
| 81 | # As per kernel Makefile, avoid funny character set dependencies | 84 | # As per kernel Makefile, avoid funny character set dependencies |
| 82 | unexport LC_ALL | 85 | unexport LC_ALL |
| @@ -166,6 +169,15 @@ ifeq ($(config),1) · 83 unmodified lines | |||
| 166 | include config/Makefile | 169 | include config/Makefile |
| 167 | endif | 170 | endif |
| 168 | 171 | ||
| 172 | # The FEATURE_DUMP_EXPORT holds location of the actual | ||
| 173 | # FEATURE_DUMP file to be used to bypass feature detection | ||
| 174 | # (for bpf or any other subproject) | ||
| 175 | ifeq ($(FEATURES_DUMP),) | ||
| 176 | FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP) | ||
| 177 | else | ||
| 178 | FEATURE_DUMP_EXPORT := $(FEATURES_DUMP) | ||
| 179 | endif | ||
| 180 | |||
| 169 | export prefix bindir sharedir sysconfdir DESTDIR | 181 | export prefix bindir sharedir sysconfdir DESTDIR |
| 170 | 182 | ||
| 171 | # sparse is architecture-neutral, which means that we need to tell it | 183 | # sparse is architecture-neutral, which means that we need to tell it |
| @@ -436,7 +448,7 @@ $(LIBAPI)-clean: · 264 unmodified lines | |||
| 436 | $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null | 448 | $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null |
| 437 | 449 | ||
| 438 | $(LIBBPF): fixdep FORCE | 450 | $(LIBBPF): fixdep FORCE |
| 439 | $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(realpath $(OUTPUT)FEATURE-DUMP) | 451 | $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) |
| 440 | 452 | ||
| 441 | $(LIBBPF)-clean: | 453 | $(LIBBPF)-clean: |
| 442 | $(call QUIET_CLEAN, libbpf) | 454 | $(call QUIET_CLEAN, libbpf) |
| @@ -610,6 +622,17 @@ clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean · 167 unmodified lines | |||
| 610 | $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean | 622 | $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean |
| 611 | $(python-clean) | 623 | $(python-clean) |
| 612 | 624 | ||
| 625 | # | ||
| 626 | # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY) | ||
| 627 | # file if defined, with no further action. | ||
| 628 | feature-dump: | ||
| 629 | ifdef FEATURE_DUMP_COPY | ||
| 630 | @cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY) | ||
| 631 | @echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)" | ||
| 632 | else | ||
| 633 | @echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP" | ||
| 634 | endif | ||
| 635 | |||
| 613 | # | 636 | # |
| 614 | # Trick: if ../../.git does not exist - we are building out of tree for example, | 637 | # Trick: if ../../.git does not exist - we are building out of tree for example, |
| 615 | # then force version regeneration: | 638 | # then force version regeneration: |
| @@ -17,7 +17,7 @@ static pid_t spawn(void) · 16 unmodified lines | |||
| 17 | if (pid) | 17 | if (pid) |
| 18 | return pid; | 18 | return pid; |
| 19 | 19 | ||
| 20 | while(1); | 20 | while(1) |
| 21 | sleep(5); | 21 | sleep(5); |
| 22 | return 0; | 22 | return 0; |
| 23 | } | 23 | } |
| @@ -181,7 +181,11 @@ LDFLAGS += -Wl,-z,noexecstack · 180 unmodified lines | |||
| 181 | 181 | ||
| 182 | EXTLIBS = -lpthread -lrt -lm -ldl | 182 | EXTLIBS = -lpthread -lrt -lm -ldl |
| 183 | 183 | ||
| 184 | ifeq ($(FEATURES_DUMP),) | ||
| 184 | include $(srctree)/tools/build/Makefile.feature | 185 | include $(srctree)/tools/build/Makefile.feature |
| 186 | else | ||
| 187 | include $(FEATURES_DUMP) | ||
| 188 | endif | ||
| 185 | 189 | ||
| 186 | ifeq ($(feature-stackprotector-all), 1) | 190 | ifeq ($(feature-stackprotector-all), 1) |
| 187 | CFLAGS += -fstack-protector-all | 191 | CFLAGS += -fstack-protector-all |
| @@ -5,7 +5,7 @@ ifeq ($(MAKECMDGOALS),) · 4 unmodified lines | |||
| 5 | # no target specified, trigger the whole suite | 5 | # no target specified, trigger the whole suite |
| 6 | all: | 6 | all: |
| 7 | @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile | 7 | @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile |
| 8 | @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf | 8 | @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf SET_PARALLEL=1 SET_O=1 |
| 9 | else | 9 | else |
| 10 | # run only specific test over 'Makefile' | 10 | # run only specific test over 'Makefile' |
| 11 | %: | 11 | %: |
| @@ -13,6 +13,26 @@ else · 1 unmodified line | |||
| 13 | endif | 13 | endif |
| 14 | else | 14 | else |
| 15 | PERF := . | 15 | PERF := . |
| 16 | PERF_O := $(PERF) | ||
| 17 | O_OPT := | ||
| 18 | |||
| 19 | ifneq ($(O),) | ||
| 20 | FULL_O := $(shell readlink -f $(O) || echo $(O)) | ||
| 21 | PERF_O := $(FULL_O) | ||
| 22 | ifeq ($(SET_O),1) | ||
| 23 | O_OPT := 'O=$(FULL_O)' | ||
| 24 | endif | ||
| 25 | K_O_OPT := 'O=$(FULL_O)' | ||
| 26 | endif | ||
| 27 | |||
| 28 | PARALLEL_OPT= | ||
| 29 | ifeq ($(SET_PARALLEL),1) | ||
| 30 | cores := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) | ||
| 31 | ifeq ($(cores),0) | ||
| 32 | cores := 1 | ||
| 33 | endif | ||
| 34 | PARALLEL_OPT="-j$(cores)" | ||
| 35 | endif | ||
| 16 | 36 | ||
| 17 | # As per kernel Makefile, avoid funny character set dependencies | 37 | # As per kernel Makefile, avoid funny character set dependencies |
| 18 | unexport LC_ALL | 38 | unexport LC_ALL |
| @@ -156,11 +176,11 @@ test_make_doc := $(test_ok) · 137 unmodified lines | |||
| 156 | test_make_help_O := $(test_ok) | 176 | test_make_help_O := $(test_ok) |
| 157 | test_make_doc_O := $(test_ok) | 177 | test_make_doc_O := $(test_ok) |
| 158 | 178 | ||
| 159 | test_make_python_perf_so := test -f $(PERF)/python/perf.so | 179 | test_make_python_perf_so := test -f $(PERF_O)/python/perf.so |
| 160 | 180 | ||
| 161 | test_make_perf_o := test -f $(PERF)/perf.o | 181 | test_make_perf_o := test -f $(PERF_O)/perf.o |
| 162 | test_make_util_map_o := test -f $(PERF)/util/map.o | 182 | test_make_util_map_o := test -f $(PERF_O)/util/map.o |
| 163 | test_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o | 183 | test_make_util_pmu_bison_o := test -f $(PERF_O)/util/pmu-bison.o |
| 164 | 184 | ||
| 165 | define test_dest_files | 185 | define test_dest_files |
| 166 | for file in $(1); do \ | 186 | for file in $(1); do \ |
| @@ -227,7 +247,7 @@ test_make_perf_o_O := test -f $$TMP_O/perf.o · 60 unmodified lines | |||
| 227 | test_make_util_map_o_O := test -f $$TMP_O/util/map.o | 247 | test_make_util_map_o_O := test -f $$TMP_O/util/map.o |
| 228 | test_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o | 248 | test_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o |
| 229 | 249 | ||
| 230 | test_default = test -x $(PERF)/perf | 250 | test_default = test -x $(PERF_O)/perf |
| 231 | test = $(if $(test_$1),$(test_$1),$(test_default)) | 251 | test = $(if $(test_$1),$(test_$1),$(test_default)) |
| 232 | 252 | ||
| 233 | test_default_O = test -x $$TMP_O/perf | 253 | test_default_O = test -x $$TMP_O/perf |
| @@ -247,12 +267,12 @@ endif · 13 unmodified lines | |||
| 247 | 267 | ||
| 248 | MAKEFLAGS := --no-print-directory | 268 | MAKEFLAGS := --no-print-directory |
| 249 | 269 | ||
| 250 | clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null) | 270 | clean := @(cd $(PERF); make -s -f $(MK) $(O_OPT) clean >/dev/null) |
| 251 | 271 | ||
| 252 | $(run): | 272 | $(run): |
| 253 | $(call clean) | 273 | $(call clean) |
| 254 | @TMP_DEST=$$(mktemp -d); \ | 274 | @TMP_DEST=$$(mktemp -d); \ |
| 255 | cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \ | 275 | cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST $($@)"; \ |
| 256 | echo "- $@: $$cmd" && echo $$cmd > $@ && \ | 276 | echo "- $@: $$cmd" && echo $$cmd > $@ && \ |
| 257 | ( eval $$cmd ) >> $@ 2>&1; \ | 277 | ( eval $$cmd ) >> $@ 2>&1; \ |
| 258 | echo " test: $(call test,$@)" >> $@ 2>&1; \ | 278 | echo " test: $(call test,$@)" >> $@ 2>&1; \ |
| @@ -263,7 +283,7 @@ $(run_O): · 4 unmodified lines | |||
| 263 | $(call clean) | 283 | $(call clean) |
| 264 | @TMP_O=$$(mktemp -d); \ | 284 | @TMP_O=$$(mktemp -d); \ |
| 265 | TMP_DEST=$$(mktemp -d); \ | 285 | TMP_DEST=$$(mktemp -d); \ |
| 266 | cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \ | 286 | cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \ |
| 267 | echo "- $@: $$cmd" && echo $$cmd > $@ && \ | 287 | echo "- $@: $$cmd" && echo $$cmd > $@ && \ |
| 268 | ( eval $$cmd ) >> $@ 2>&1 && \ | 288 | ( eval $$cmd ) >> $@ 2>&1 && \ |
| 269 | echo " test: $(call test_O,$@)" >> $@ 2>&1; \ | 289 | echo " test: $(call test_O,$@)" >> $@ 2>&1; \ |
| @@ -276,17 +296,22 @@ tarpkg: · 6 unmodified lines | |||
| 276 | ( eval $$cmd ) >> $@ 2>&1 && \ | 296 | ( eval $$cmd ) >> $@ 2>&1 && \ |
| 277 | rm -f $@ | 297 | rm -f $@ |
| 278 | 298 | ||
| 299 | KERNEL_O := ../.. | ||
| 300 | ifneq ($(O),) | ||
| 301 | KERNEL_O := $(O) | ||
| 302 | endif | ||
| 303 | |||
| 279 | make_kernelsrc: | 304 | make_kernelsrc: |
| 280 | @echo "- make -C <kernelsrc> tools/perf" | 305 | @echo "- make -C <kernelsrc> $(PARALLEL_OPT) $(K_O_OPT) tools/perf" |
| 281 | $(call clean); \ | 306 | $(call clean); \ |
| 282 | (make -C ../.. tools/perf) > $@ 2>&1 && \ | 307 | (make -C ../.. $(PARALLEL_OPT) $(K_O_OPT) tools/perf) > $@ 2>&1 && \ |
| 283 | test -x perf && rm -f $@ || (cat $@ ; false) | 308 | test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false) |
| 284 | 309 | ||
| 285 | make_kernelsrc_tools: | 310 | make_kernelsrc_tools: |
| 286 | @echo "- make -C <kernelsrc>/tools perf" | 311 | @echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) $(K_O_OPT) perf" |
| 287 | $(call clean); \ | 312 | $(call clean); \ |
| 288 | (make -C ../../tools perf) > $@ 2>&1 && \ | 313 | (make -C ../../tools $(PARALLEL_OPT) $(K_O_OPT) perf) > $@ 2>&1 && \ |
| 289 | test -x perf && rm -f $@ || (cat $@ ; false) | 314 | test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false) |
| 290 | 315 | ||
| 291 | all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools | 316 | all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools |
| 292 | @echo OK | 317 | @echo OK |
| @@ -755,11 +755,11 @@ static int annotate_browser__run(struct annotate_browser *browser, · 754 unmodified lines | |||
| 755 | nd = browser->curr_hot; | 755 | nd = browser->curr_hot; |
| 756 | break; | 756 | break; |
| 757 | case K_UNTAB: | 757 | case K_UNTAB: |
| 758 | if (nd != NULL) | 758 | if (nd != NULL) { |
| 759 | nd = rb_next(nd); | 759 | nd = rb_next(nd); |
| 760 | if (nd == NULL) | 760 | if (nd == NULL) |
| 761 | nd = rb_first(&browser->entries); | 761 | nd = rb_first(&browser->entries); |
| 762 | else | 762 | } else |
| 763 | nd = browser->curr_hot; | 763 | nd = browser->curr_hot; |
| 764 | break; | 764 | break; |
| 765 | case K_F1: | 765 | case K_F1: |
| @@ -131,6 +131,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) · 130 unmodified lines | |||
| 131 | symlen = unresolved_col_width + 4 + 2; | 131 | symlen = unresolved_col_width + 4 + 2; |
| 132 | hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, | 132 | hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, |
| 133 | symlen); | 133 | symlen); |
| 134 | hists__new_col_len(hists, HISTC_MEM_DCACHELINE, | ||
| 135 | symlen); | ||
| 134 | } | 136 | } |
| 135 | 137 | ||
| 136 | if (h->mem_info->iaddr.sym) { | 138 | if (h->mem_info->iaddr.sym) { |
| @@ -1149,7 +1149,7 @@ static struct machine *machines__find_for_cpumode(struct machines *machines, · 1148 unmodified lines | |||
| 1149 | 1149 | ||
| 1150 | machine = machines__find(machines, pid); | 1150 | machine = machines__find(machines, pid); |
| 1151 | if (!machine) | 1151 | if (!machine) |
| 1152 | machine = machines__find(machines, DEFAULT_GUEST_KERNEL_ID); | 1152 | machine = machines__findnew(machines, DEFAULT_GUEST_KERNEL_ID); |
| 1153 | return machine; | 1153 | return machine; |
| 1154 | } | 1154 | } |
| 1155 | 1155 | ||
| @@ -310,7 +310,6 @@ int perf_stat_process_counter(struct perf_stat_config *config, · 309 unmodified lines | |||
| 310 | int i, ret; | 310 | int i, ret; |
| 311 | 311 | ||
| 312 | aggr->val = aggr->ena = aggr->run = 0; | 312 | aggr->val = aggr->ena = aggr->run = 0; |
| 313 | init_stats(ps->res_stats); | ||
| 314 | 313 | ||
| 315 | if (counter->per_pkg) | 314 | if (counter->per_pkg) |
| 316 | zero_per_pkg(counter); | 315 | zero_per_pkg(counter); |
| @@ -1466,7 +1466,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) · 1465 unmodified lines | |||
| 1466 | * Read the build id if possible. This is required for | 1466 | * Read the build id if possible. This is required for |
| 1467 | * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work | 1467 | * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work |
| 1468 | */ | 1468 | */ |
| 1469 | if (filename__read_build_id(dso->name, build_id, BUILD_ID_SIZE) > 0) | 1469 | if (filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0) |
| 1470 | dso__set_build_id(dso, build_id); | 1470 | dso__set_build_id(dso, build_id); |
| 1471 | 1471 | ||
| 1472 | /* | 1472 | /* |
| @@ -45,7 +45,17 @@ static inline int ksft_exit_fail(void) · 44 unmodified lines | |||
| 45 | } | 45 | } |
| 46 | #endif | 46 | #endif |
| 47 | 47 | ||
| 48 | #define NSEC_PER_SEC 1000000000L | 48 | #define NSEC_PER_SEC 1000000000LL |
| 49 | #define USEC_PER_SEC 1000000LL | ||
| 50 | |||
| 51 | #define ADJ_SETOFFSET 0x0100 | ||
| 52 | |||
| 53 | #include <sys/syscall.h> | ||
| 54 | static int clock_adjtime(clockid_t id, struct timex *tx) | ||
| 55 | { | ||
| 56 | return syscall(__NR_clock_adjtime, id, tx); | ||
| 57 | } | ||
| 58 | |||
| 49 | 59 | ||
| 50 | /* clear NTP time_status & time_state */ | 60 | /* clear NTP time_status & time_state */ |
| 51 | int clear_time_state(void) | 61 | int clear_time_state(void) |
| @@ -193,10 +203,137 @@ out: · 141 unmodified lines | |||
| 193 | } | 203 | } |
| 194 | 204 | ||
| 195 | 205 | ||
| 206 | int set_offset(long long offset, int use_nano) | ||
| 207 | { | ||
| 208 | struct timex tmx = {}; | ||
| 209 | int ret; | ||
| 210 | |||
| 211 | tmx.modes = ADJ_SETOFFSET; | ||
| 212 | if (use_nano) { | ||
| 213 | tmx.modes |= ADJ_NANO; | ||
| 214 | |||
| 215 | tmx.time.tv_sec = offset / NSEC_PER_SEC; | ||
| 216 | tmx.time.tv_usec = offset % NSEC_PER_SEC; | ||
| 217 | |||
| 218 | if (offset < 0 && tmx.time.tv_usec) { | ||
| 219 | tmx.time.tv_sec -= 1; | ||
| 220 | tmx.time.tv_usec += NSEC_PER_SEC; | ||
| 221 | } | ||
| 222 | } else { | ||
| 223 | tmx.time.tv_sec = offset / USEC_PER_SEC; | ||
| 224 | tmx.time.tv_usec = offset % USEC_PER_SEC; | ||
| 225 | |||
| 226 | if (offset < 0 && tmx.time.tv_usec) { | ||
| 227 | tmx.time.tv_sec -= 1; | ||
| 228 | tmx.time.tv_usec += USEC_PER_SEC; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | |||
| 232 | ret = clock_adjtime(CLOCK_REALTIME, &tmx); | ||
| 233 | if (ret < 0) { | ||
| 234 | printf("(sec: %ld usec: %ld) ", tmx.time.tv_sec, tmx.time.tv_usec); | ||
| 235 | printf("[FAIL]\n"); | ||
| 236 | return -1; | ||
| 237 | } | ||
| 238 | return 0; | ||
| 239 | } | ||
| 240 | |||
| 241 | int set_bad_offset(long sec, long usec, int use_nano) | ||
| 242 | { | ||
| 243 | struct timex tmx = {}; | ||
| 244 | int ret; | ||
| 245 | |||
| 246 | tmx.modes = ADJ_SETOFFSET; | ||
| 247 | if (use_nano) | ||
| 248 | tmx.modes |= ADJ_NANO; | ||
| 249 | |||
| 250 | tmx.time.tv_sec = sec; | ||
| 251 | tmx.time.tv_usec = usec; | ||
| 252 | ret = clock_adjtime(CLOCK_REALTIME, &tmx); | ||
| 253 | if (ret >= 0) { | ||
| 254 | printf("Invalid (sec: %ld usec: %ld) did not fail! ", tmx.time.tv_sec, tmx.time.tv_usec); | ||
| 255 | printf("[FAIL]\n"); | ||
| 256 | return -1; | ||
| 257 | } | ||
| 258 | return 0; | ||
| 259 | } | ||
| 260 | |||
| 261 | int validate_set_offset(void) | ||
| 262 | { | ||
| 263 | printf("Testing ADJ_SETOFFSET... "); | ||
| 264 | |||
| 265 | /* Test valid values */ | ||
| 266 | if (set_offset(NSEC_PER_SEC - 1, 1)) | ||
| 267 | return -1; | ||
| 268 | |||
| 269 | if (set_offset(-NSEC_PER_SEC + 1, 1)) | ||
| 270 | return -1; | ||
| 271 | |||
| 272 | if (set_offset(-NSEC_PER_SEC - 1, 1)) | ||
| 273 | return -1; | ||
| 274 | |||
| 275 | if (set_offset(5 * NSEC_PER_SEC, 1)) | ||
| 276 | return -1; | ||
| 277 | |||
| 278 | if (set_offset(-5 * NSEC_PER_SEC, 1)) | ||
| 279 | return -1; | ||
| 280 | |||
| 281 | if (set_offset(5 * NSEC_PER_SEC + NSEC_PER_SEC / 2, 1)) | ||
| 282 | return -1; | ||
| 283 | |||
| 284 | if (set_offset(-5 * NSEC_PER_SEC - NSEC_PER_SEC / 2, 1)) | ||
| 285 | return -1; | ||
| 286 | |||
| 287 | if (set_offset(USEC_PER_SEC - 1, 0)) | ||
| 288 | return -1; | ||
| 289 | |||
| 290 | if (set_offset(-USEC_PER_SEC + 1, 0)) | ||
| 291 | return -1; | ||
| 292 | |||
| 293 | if (set_offset(-USEC_PER_SEC - 1, 0)) | ||
| 294 | return -1; | ||
| 295 | |||
| 296 | if (set_offset(5 * USEC_PER_SEC, 0)) | ||
| 297 | return -1; | ||
| 298 | |||
| 299 | if (set_offset(-5 * USEC_PER_SEC, 0)) | ||
| 300 | return -1; | ||
| 301 | |||
| 302 | if (set_offset(5 * USEC_PER_SEC + USEC_PER_SEC / 2, 0)) | ||
| 303 | return -1; | ||
| 304 | |||
| 305 | if (set_offset(-5 * USEC_PER_SEC - USEC_PER_SEC / 2, 0)) | ||
| 306 | return -1; | ||
| 307 | |||
| 308 | /* Test invalid values */ | ||
| 309 | if (set_bad_offset(0, -1, 1)) | ||
| 310 | return -1; | ||
| 311 | if (set_bad_offset(0, -1, 0)) | ||
| 312 | return -1; | ||
| 313 | if (set_bad_offset(0, 2 * NSEC_PER_SEC, 1)) | ||
| 314 | return -1; | ||
| 315 | if (set_bad_offset(0, 2 * USEC_PER_SEC, 0)) | ||
| 316 | return -1; | ||
| 317 | if (set_bad_offset(0, NSEC_PER_SEC, 1)) | ||
| 318 | return -1; | ||
| 319 | if (set_bad_offset(0, USEC_PER_SEC, 0)) | ||
| 320 | return -1; | ||
| 321 | if (set_bad_offset(0, -NSEC_PER_SEC, 1)) | ||
| 322 | return -1; | ||
| 323 | if (set_bad_offset(0, -USEC_PER_SEC, 0)) | ||
| 324 | return -1; | ||
| 325 | |||
| 326 | printf("[OK]\n"); | ||
| 327 | return 0; | ||
| 328 | } | ||
| 329 | |||
| 196 | int main(int argc, char **argv) | 330 | int main(int argc, char **argv) |
| 197 | { | 331 | { |
| 198 | if (validate_freq()) | 332 | if (validate_freq()) |
| 199 | return ksft_exit_fail(); | 333 | return ksft_exit_fail(); |
| 200 | 334 | ||
| 335 | if (validate_set_offset()) | ||
| 336 | return ksft_exit_fail(); | ||
| 337 | |||
| 201 | return ksft_exit_pass(); | 338 | return ksft_exit_pass(); |
| 202 | } | 339 | } |
| @@ -1,15 +1,19 @@ | |||
| 1 | #if defined(__i386__) || defined(__x86_64__) | 1 | #if defined(__i386__) || defined(__x86_64__) |
| 2 | #define barrier() asm volatile("" ::: "memory") | 2 | #define barrier() asm volatile("" ::: "memory") |
| 3 | #define mb() __sync_synchronize() | 3 | #define virt_mb() __sync_synchronize() |
| 4 | 4 | #define virt_rmb() barrier() | |
| 5 | #define smp_mb() mb() | 5 | #define virt_wmb() barrier() |
| 6 | # define dma_rmb() barrier() | 6 | /* Atomic store should be enough, but gcc generates worse code in that case. */ |
| 7 | # define dma_wmb() barrier() | 7 | #define virt_store_mb(var, value) do { \ |
| 8 | # define smp_rmb() barrier() | 8 | typeof(var) virt_store_mb_value = (value); \ |
| 9 | # define smp_wmb() barrier() | 9 | __atomic_exchange(&(var), &virt_store_mb_value, &virt_store_mb_value, \ |
| 10 | __ATOMIC_SEQ_CST); \ | ||
| 11 | barrier(); \ | ||
| 12 | } while (0); | ||
| 10 | /* Weak barriers should be used. If not - it's a bug */ | 13 | /* Weak barriers should be used. If not - it's a bug */ |
| 11 | # define rmb() abort() | 14 | # define mb() abort() |
| 12 | # define wmb() abort() | 15 | # define rmb() abort() |
| 16 | # define wmb() abort() | ||
| 13 | #else | 17 | #else |
| 14 | #error Please fill in barrier macros | 18 | #error Please fill in barrier macros |
| 15 | #endif | 19 | #endif |
| @@ -0,0 +1,9 @@ | |||
| 1 | #ifndef LINUX_COMPILER_H | ||
| 2 | #define LINUX_COMPILER_H | ||
| 3 | |||
| 4 | #define WRITE_ONCE(var, val) \ | ||
| 5 | (*((volatile typeof(val) *)(&(var))) = (val)) | ||
| 6 | |||
| 7 | #define READ_ONCE(var) (*((volatile typeof(val) *)(&(var)))) | ||
| 8 | |||
| 9 | #endif | ||
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <assert.h> | 8 | #include <assert.h> |
| 9 | #include <stdarg.h> | 9 | #include <stdarg.h> |
| 10 | 10 | ||
| 11 | #include <linux/compiler.h> | ||
| 11 | #include <linux/types.h> | 12 | #include <linux/types.h> |
| 12 | #include <linux/printk.h> | 13 | #include <linux/printk.h> |
| 13 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
| @@ -0,0 +1,22 @@ | |||
| 1 | all: | ||
| 2 | |||
| 3 | all: ring virtio_ring_0_9 virtio_ring_poll | ||
| 4 | |||
| 5 | CFLAGS += -Wall | ||
| 6 | CFLAGS += -pthread -O2 -ggdb | ||
| 7 | LDFLAGS += -pthread -O2 -ggdb | ||
| 8 | |||
| 9 | main.o: main.c main.h | ||
| 10 | ring.o: ring.c main.h | ||
| 11 | virtio_ring_0_9.o: virtio_ring_0_9.c main.h | ||
| 12 | virtio_ring_poll.o: virtio_ring_poll.c virtio_ring_0_9.c main.h | ||
| 13 | ring: ring.o main.o | ||
| 14 | virtio_ring_0_9: virtio_ring_0_9.o main.o | ||
| 15 | virtio_ring_poll: virtio_ring_poll.o main.o | ||
| 16 | clean: | ||
| 17 | -rm main.o | ||
| 18 | -rm ring.o ring | ||
| 19 | -rm virtio_ring_0_9.o virtio_ring_0_9 | ||
| 20 | -rm virtio_ring_poll.o virtio_ring_poll | ||
| 21 | |||
| 22 | .PHONY: all clean | ||
| @@ -0,0 +1,2 @@ | |||
| 1 | Partial implementation of various ring layouts, useful to tune virtio design. | ||
| 2 | Uses shared memory heavily. | ||
| @@ -0,0 +1,366 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2016 Red Hat, Inc. | ||
| 3 | * Author: Michael S. Tsirkin <mst@redhat.com> | ||
| 4 | * This work is licensed under the terms of the GNU GPL, version 2. | ||
| 5 | * | ||
| 6 | * Command line processing and common functions for ring benchmarking. | ||
| 7 | */ | ||
| 8 | #define _GNU_SOURCE | ||
| 9 | #include <getopt.h> | ||
| 10 | #include <pthread.h> | ||
| 11 | #include <assert.h> | ||
| 12 | #include <sched.h> | ||
| 13 | #include "main.h" | ||
| 14 | #include <sys/eventfd.h> | ||
| 15 | #include <stdlib.h> | ||
| 16 | #include <stdio.h> | ||
| 17 | #include <unistd.h> | ||
| 18 | #include <limits.h> | ||
| 19 | |||
| 20 | int runcycles = 10000000; | ||
| 21 | int max_outstanding = INT_MAX; | ||
| 22 | int batch = 1; | ||
| 23 | |||
| 24 | bool do_sleep = false; | ||
| 25 | bool do_relax = false; | ||
| 26 | bool do_exit = true; | ||
| 27 | |||
| 28 | unsigned ring_size = 256; | ||
| 29 | |||
| 30 | static int kickfd = -1; | ||
| 31 | static int callfd = -1; | ||
| 32 | |||
| 33 | void notify(int fd) | ||
| 34 | { | ||
| 35 | unsigned long long v = 1; | ||
| 36 | int r; | ||
| 37 | |||
| 38 | vmexit(); | ||
| 39 | r = write(fd, &v, sizeof v); | ||
| 40 | assert(r == sizeof v); | ||
| 41 | vmentry(); | ||
| 42 | } | ||
| 43 | |||
| 44 | void wait_for_notify(int fd) | ||
| 45 | { | ||
| 46 | unsigned long long v = 1; | ||
| 47 | int r; | ||
| 48 | |||
| 49 | vmexit(); | ||
| 50 | r = read(fd, &v, sizeof v); | ||
| 51 | assert(r == sizeof v); | ||
| 52 | vmentry(); | ||
| 53 | } | ||
| 54 | |||
| 55 | void kick(void) | ||
| 56 | { | ||
| 57 | notify(kickfd); | ||
| 58 | } | ||
| 59 | |||
| 60 | void wait_for_kick(void) | ||
| 61 | { | ||
| 62 | wait_for_notify(kickfd); | ||
| 63 | } | ||
| 64 | |||
| 65 | void call(void) | ||
| 66 | { | ||
| 67 | notify(callfd); | ||
| 68 | } | ||
| 69 | |||
| 70 | void wait_for_call(void) | ||
| 71 | { | ||
| 72 | wait_for_notify(callfd); | ||
| 73 | } | ||
| 74 | |||
| 75 | void set_affinity(const char *arg) | ||
| 76 | { | ||
| 77 | cpu_set_t cpuset; | ||
| 78 | int ret; | ||
| 79 | pthread_t self; | ||
| 80 | long int cpu; | ||
| 81 | char *endptr; | ||
| 82 | |||
| 83 | if (!arg) | ||
| 84 | return; | ||
| 85 | |||
| 86 | cpu = strtol(arg, &endptr, 0); | ||
| 87 | assert(!*endptr); | ||
| 88 | |||
| 89 | assert(cpu >= 0 || cpu < CPU_SETSIZE); | ||
| 90 | |||
| 91 | self = pthread_self(); | ||
| 92 | CPU_ZERO(&cpuset); | ||
| 93 | CPU_SET(cpu, &cpuset); | ||
| 94 | |||
| 95 | ret = pthread_setaffinity_np(self, sizeof(cpu_set_t), &cpuset); | ||
| 96 | assert(!ret); | ||
| 97 | } | ||
| 98 | |||
| 99 | static void run_guest(void) | ||
| 100 | { | ||
| 101 | int completed_before; | ||
| 102 | int completed = 0; | ||
| 103 | int started = 0; | ||
| 104 | int bufs = runcycles; | ||
| 105 | int spurious = 0; | ||
| 106 | int r; | ||
| 107 | unsigned len; | ||
| 108 | void *buf; | ||
| 109 | int tokick = batch; | ||
| 110 | |||
| 111 | for (;;) { | ||
| 112 | if (do_sleep) | ||
| 113 | disable_call(); | ||
| 114 | completed_before = completed; | ||
| 115 | do { | ||
| 116 | if (started < bufs && | ||
| 117 | started - completed < max_outstanding) { | ||
| 118 | r = add_inbuf(0, NULL, "Hello, world!"); | ||
| 119 | if (__builtin_expect(r == 0, true)) { | ||
| 120 | ++started; | ||
| 121 | if (!--tokick) { | ||
| 122 | tokick = batch; | ||
| 123 | if (do_sleep) | ||
| 124 | kick_available(); | ||
| 125 | } | ||
| 126 | |||
| 127 | } | ||
| 128 | } else | ||
| 129 | r = -1; | ||
| 130 | |||
| 131 | /* Flush out completed bufs if any */ | ||
| 132 | if (get_buf(&len, &buf)) { | ||
| 133 | ++completed; | ||
| 134 | if (__builtin_expect(completed == bufs, false)) | ||
| 135 | return; | ||
| 136 | r = 0; | ||
| 137 | } | ||
| 138 | } while (r == 0); | ||
| 139 | if (completed == completed_before) | ||
| 140 | ++spurious; | ||
| 141 | assert(completed <= bufs); | ||
| 142 | assert(started <= bufs); | ||
| 143 | if (do_sleep) { | ||
| 144 | if (enable_call()) | ||
| 145 | wait_for_call(); | ||
| 146 | } else { | ||
| 147 | poll_used(); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | static void run_host(void) | ||
| 153 | { | ||
| 154 | int completed_before; | ||
| 155 | int completed = 0; | ||
| 156 | int spurious = 0; | ||
| 157 | int bufs = runcycles; | ||
| 158 | unsigned len; | ||
| 159 | void *buf; | ||
| 160 | |||
| 161 | for (;;) { | ||
| 162 | if (do_sleep) { | ||
| 163 | if (enable_kick()) | ||
| 164 | wait_for_kick(); | ||
| 165 | } else { | ||
| 166 | poll_avail(); | ||
| 167 | } | ||
| 168 | if (do_sleep) | ||
| 169 | disable_kick(); | ||
| 170 | completed_before = completed; | ||
| 171 | while (__builtin_expect(use_buf(&len, &buf), true)) { | ||
| 172 | if (do_sleep) | ||
| 173 | call_used(); | ||
| 174 | ++completed; | ||
| 175 | if (__builtin_expect(completed == bufs, false)) | ||
| 176 | return; | ||
| 177 | } | ||
| 178 | if (completed == completed_before) | ||
| 179 | ++spurious; | ||
| 180 | assert(completed <= bufs); | ||
| 181 | if (completed == bufs) | ||
| 182 | break; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | void *start_guest(void *arg) | ||
| 187 | { | ||
| 188 | set_affinity(arg); | ||
| 189 | run_guest(); | ||
| 190 | pthread_exit(NULL); | ||
| 191 | } | ||
| 192 | |||
| 193 | void *start_host(void *arg) | ||
| 194 | { | ||
| 195 | set_affinity(arg); | ||
| 196 | run_host(); | ||
| 197 | pthread_exit(NULL); | ||
| 198 | } | ||
| 199 | |||
| 200 | static const char optstring[] = ""; | ||
| 201 | static const struct option longopts[] = { | ||
| 202 | { | ||
| 203 | .name = "help", | ||
| 204 | .has_arg = no_argument, | ||
| 205 | .val = 'h', | ||
| 206 | }, | ||
| 207 | { | ||
| 208 | .name = "host-affinity", | ||
| 209 | .has_arg = required_argument, | ||
| 210 | .val = 'H', | ||
| 211 | }, | ||
| 212 | { | ||
| 213 | .name = "guest-affinity", | ||
| 214 | .has_arg = required_argument, | ||
| 215 | .val = 'G', | ||
| 216 | }, | ||
| 217 | { | ||
| 218 | .name = "ring-size", | ||
| 219 | .has_arg = required_argument, | ||
| 220 | .val = 'R', | ||
| 221 | }, | ||
| 222 | { | ||
| 223 | .name = "run-cycles", | ||
| 224 | .has_arg = required_argument, | ||
| 225 | .val = 'C', | ||
| 226 | }, | ||
| 227 | { | ||
| 228 | .name = "outstanding", | ||
| 229 | .has_arg = required_argument, | ||
| 230 | .val = 'o', | ||
| 231 | }, | ||
| 232 | { | ||
| 233 | .name = "batch", | ||
| 234 | .has_arg = required_argument, | ||
| 235 | .val = 'b', | ||
| 236 | }, | ||
| 237 | { | ||
| 238 | .name = "sleep", | ||
| 239 | .has_arg = no_argument, | ||
| 240 | .val = 's', | ||
| 241 | }, | ||
| 242 | { | ||
| 243 | .name = "relax", | ||
| 244 | .has_arg = no_argument, | ||
| 245 | .val = 'x', | ||
| 246 | }, | ||
| 247 | { | ||
| 248 | .name = "exit", | ||
| 249 | .has_arg = no_argument, | ||
| 250 | .val = 'e', | ||
| 251 | }, | ||
| 252 | { | ||
| 253 | } | ||
| 254 | }; | ||
| 255 | |||
| 256 | static void help(void) | ||
| 257 | { | ||
| 258 | fprintf(stderr, "Usage: <test> [--help]" | ||
| 259 | " [--host-affinity H]" | ||
| 260 | " [--guest-affinity G]" | ||
| 261 | " [--ring-size R (default: %d)]" | ||
| 262 | " [--run-cycles C (default: %d)]" | ||
| 263 | " [--batch b]" | ||
| 264 | " [--outstanding o]" | ||
| 265 | " [--sleep]" | ||
| 266 | " [--relax]" | ||
| 267 | " [--exit]" | ||
| 268 | "\n", | ||
| 269 | ring_size, | ||
| 270 | runcycles); | ||
| 271 | } | ||
| 272 | |||
| 273 | int main(int argc, char **argv) | ||
| 274 | { | ||
| 275 | int ret; | ||
| 276 | pthread_t host, guest; | ||
| 277 | void *tret; | ||
| 278 | char *host_arg = NULL; | ||
| 279 | char *guest_arg = NULL; | ||
| 280 | char *endptr; | ||
| 281 | long int c; | ||
| 282 | |||
| 283 | kickfd = eventfd(0, 0); | ||
| 284 | assert(kickfd >= 0); | ||
| 285 | callfd = eventfd(0, 0); | ||
| 286 | assert(callfd >= 0); | ||
| 287 | |||
| 288 | for (;;) { | ||
| 289 | int o = getopt_long(argc, argv, optstring, longopts, NULL); | ||
| 290 | switch (o) { | ||
| 291 | case -1: | ||
| 292 | goto done; | ||
| 293 | case '?': | ||
| 294 | help(); | ||
| 295 | exit(2); | ||
| 296 | case 'H': | ||
| 297 | host_arg = optarg; | ||
| 298 | break; | ||
| 299 | case 'G': | ||
| 300 | guest_arg = optarg; | ||
| 301 | break; | ||
| 302 | case 'R': | ||
| 303 | ring_size = strtol(optarg, &endptr, 0); | ||
| 304 | assert(ring_size && !(ring_size & (ring_size - 1))); | ||
| 305 | assert(!*endptr); | ||
| 306 | break; | ||
| 307 | case 'C': | ||
| 308 | c = strtol(optarg, &endptr, 0); | ||
| 309 | assert(!*endptr); | ||
| 310 | assert(c > 0 && c < INT_MAX); | ||
| 311 | runcycles = c; | ||
| 312 | break; | ||
| 313 | case 'o': | ||
| 314 | c = strtol(optarg, &endptr, 0); | ||
| 315 | assert(!*endptr); | ||
| 316 | assert(c > 0 && c < INT_MAX); | ||
| 317 | max_outstanding = c; | ||
| 318 | break; | ||
| 319 | case 'b': | ||
| 320 | c = strtol(optarg, &endptr, 0); | ||
| 321 | assert(!*endptr); | ||
| 322 | assert(c > 0 && c < INT_MAX); | ||
| 323 | batch = c; | ||
| 324 | break; | ||
| 325 | case 's': | ||
| 326 | do_sleep = true; | ||
| 327 | break; | ||
| 328 | case 'x': | ||
| 329 | do_relax = true; | ||
| 330 | break; | ||
| 331 | case 'e': | ||
| 332 | do_exit = true; | ||
| 333 | break; | ||
| 334 | default: | ||
| 335 | help(); | ||
| 336 | exit(4); | ||
| 337 | break; | ||
| 338 | } | ||
| 339 | } | ||
| 340 | |||
| 341 | /* does nothing here, used to make sure all smp APIs compile */ | ||
| 342 | smp_acquire(); | ||
| 343 | smp_release(); | ||
| 344 | smp_mb(); | ||
| 345 | done: | ||
| 346 | |||
| 347 | if (batch > max_outstanding) | ||
| 348 | batch = max_outstanding; | ||
| 349 | |||
| 350 | if (optind < argc) { | ||
| 351 | help(); | ||
| 352 | exit(4); | ||
| 353 | } | ||
| 354 | alloc_ring(); | ||
| 355 | |||
| 356 | ret = pthread_create(&host, NULL, start_host, host_arg); | ||
| 357 | assert(!ret); | ||
| 358 | ret = pthread_create(&guest, NULL, start_guest, guest_arg); | ||
| 359 | assert(!ret); | ||
| 360 | |||
| 361 | ret = pthread_join(guest, &tret); | ||
| 362 | assert(!ret); | ||
| 363 | ret = pthread_join(host, &tret); | ||
| 364 | assert(!ret); | ||
| 365 | return 0; | ||
| 366 | } | ||
| @@ -0,0 +1,119 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2016 Red Hat, Inc. | ||
| 3 | * Author: Michael S. Tsirkin <mst@redhat.com> | ||
| 4 | * This work is licensed under the terms of the GNU GPL, version 2. | ||
| 5 | * | ||
| 6 | * Common macros and functions for ring benchmarking. | ||
| 7 | */ | ||
| 8 | #ifndef MAIN_H | ||
| 9 | #define MAIN_H | ||
| 10 | |||
| 11 | #include <stdbool.h> | ||
| 12 | |||
| 13 | extern bool do_exit; | ||
| 14 | |||
| 15 | #if defined(__x86_64__) || defined(__i386__) | ||
| 16 | #include "x86intrin.h" | ||
| 17 | |||
| 18 | static inline void wait_cycles(unsigned long long cycles) | ||
| 19 | { | ||
| 20 | unsigned long long t; | ||
| 21 | |||
| 22 | t = __rdtsc(); | ||
| 23 | while (__rdtsc() - t < cycles) {} | ||
| 24 | } | ||
| 25 | |||
| 26 | #define VMEXIT_CYCLES 500 | ||
| 27 | #define VMENTRY_CYCLES 500 | ||
| 28 | |||
| 29 | #else | ||
| 30 | static inline void wait_cycles(unsigned long long cycles) | ||
| 31 | { | ||
| 32 | _Exit(5); | ||
| 33 | } | ||
| 34 | #define VMEXIT_CYCLES 0 | ||
| 35 | #define VMENTRY_CYCLES 0 | ||
| 36 | #endif | ||
| 37 | |||
| 38 | static inline void vmexit(void) | ||
| 39 | { | ||
| 40 | if (!do_exit) | ||
| 41 | return; | ||
| 42 | |||
| 43 | wait_cycles(VMEXIT_CYCLES); | ||
| 44 | } | ||
| 45 | static inline void vmentry(void) | ||
| 46 | { | ||
| 47 | if (!do_exit) | ||
| 48 | return; | ||
| 49 | |||
| 50 | wait_cycles(VMENTRY_CYCLES); | ||
| 51 | } | ||
| 52 | |||
| 53 | /* implemented by ring */ | ||
| 54 | void alloc_ring(void); | ||
| 55 | /* guest side */ | ||
| 56 | int add_inbuf(unsigned, void *, void *); | ||
| 57 | void *get_buf(unsigned *, void **); | ||
| 58 | void disable_call(); | ||
| 59 | bool enable_call(); | ||
| 60 | void kick_available(); | ||
| 61 | void poll_used(); | ||
| 62 | /* host side */ | ||
| 63 | void disable_kick(); | ||
| 64 | bool enable_kick(); | ||
| 65 | bool use_buf(unsigned *, void **); | ||
| 66 | void call_used(); | ||
| 67 | void poll_avail(); | ||
| 68 | |||
| 69 | /* implemented by main */ | ||
| 70 | extern bool do_sleep; | ||
| 71 | void kick(void); | ||
| 72 | void wait_for_kick(void); | ||
| 73 | void call(void); | ||
| 74 | void wait_for_call(void); | ||
| 75 | |||
| 76 | extern unsigned ring_size; | ||
| 77 | |||
| 78 | /* Compiler barrier - similar to what Linux uses */ | ||
| 79 | #define barrier() asm volatile("" ::: "memory") | ||
| 80 | |||
| 81 | /* Is there a portable way to do this? */ | ||
| 82 | #if defined(__x86_64__) || defined(__i386__) | ||
| 83 | #define cpu_relax() asm ("rep; nop" ::: "memory") | ||
| 84 | #else | ||
| 85 | #define cpu_relax() assert(0) | ||
| 86 | #endif | ||
| 87 | |||
| 88 | extern bool do_relax; | ||
| 89 | |||
| 90 | static inline void busy_wait(void) | ||
| 91 | { | ||
| 92 | if (do_relax) | ||
| 93 | cpu_relax(); | ||
| 94 | else | ||
| 95 | /* prevent compiler from removing busy loops */ | ||
| 96 | barrier(); | ||
| 97 | } | ||
| 98 | |||
| 99 | /* | ||
| 100 | * Not using __ATOMIC_SEQ_CST since gcc docs say they are only synchronized | ||
| 101 | * with other __ATOMIC_SEQ_CST calls. | ||
| 102 | */ | ||
| 103 | #define smp_mb() __sync_synchronize() | ||
| 104 | |||
| 105 | /* | ||
| 106 | * This abuses the atomic builtins for thread fences, and | ||
| 107 | * adds a compiler barrier. | ||
| 108 | */ | ||
| 109 | #define smp_release() do { \ | ||
| 110 | barrier(); \ | ||
| 111 | __atomic_thread_fence(__ATOMIC_RELEASE); \ | ||
| 112 | } while (0) | ||
| 113 | |||
| 114 | #define smp_acquire() do { \ | ||
| 115 | __atomic_thread_fence(__ATOMIC_ACQUIRE); \ | ||
| 116 | barrier(); \ | ||
| 117 | } while (0) | ||
| 118 | |||
| 119 | #endif | ||
| @@ -0,0 +1,272 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2016 Red Hat, Inc. | ||
| 3 | * Author: Michael S. Tsirkin <mst@redhat.com> | ||
| 4 | * This work is licensed under the terms of the GNU GPL, version 2. | ||
| 5 | * | ||
| 6 | * Simple descriptor-based ring. virtio 0.9 compatible event index is used for | ||
| 7 | * signalling, unconditionally. | ||
| 8 | */ | ||
| 9 | #define _GNU_SOURCE | ||
| 10 | #include "main.h" | ||
| 11 | #include <stdlib.h> | ||
| 12 | #include <stdio.h> | ||
| 13 | #include <string.h> | ||
| 14 | |||
| 15 | /* Next - Where next entry will be written. | ||
| 16 | * Prev - "Next" value when event triggered previously. | ||
| 17 | * Event - Peer requested event after writing this entry. | ||
| 18 | */ | ||
| 19 | static inline bool need_event(unsigned short event, | ||
| 20 | unsigned short next, | ||
| 21 | unsigned short prev) | ||
| 22 | { | ||
| 23 | return (unsigned short)(next - event - 1) < (unsigned short)(next - prev); | ||
| 24 | } | ||
| 25 | |||
| 26 | /* Design: | ||
| 27 | * Guest adds descriptors with unique index values and DESC_HW in flags. | ||
| 28 | * Host overwrites used descriptors with correct len, index, and DESC_HW clear. | ||
| 29 | * Flags are always set last. | ||
| 30 | */ | ||
| 31 | #define DESC_HW 0x1 | ||
| 32 | |||
| 33 | struct desc { | ||
| 34 | unsigned short flags; | ||
| 35 | unsigned short index; | ||
| 36 | unsigned len; | ||
| 37 | unsigned long long addr; | ||
| 38 | }; | ||
| 39 | |||
| 40 | /* how much padding is needed to avoid false cache sharing */ | ||
| 41 | #define HOST_GUEST_PADDING 0x80 | ||
| 42 | |||
| 43 | /* Mostly read */ | ||
| 44 | struct event { | ||
| 45 | unsigned short kick_index; | ||
| 46 | unsigned char reserved0[HOST_GUEST_PADDING - 2]; | ||
| 47 | unsigned short call_index; | ||
| 48 | unsigned char reserved1[HOST_GUEST_PADDING - 2]; | ||
| 49 | }; | ||
| 50 | |||
| 51 | struct data { | ||
| 52 | void *buf; /* descriptor is writeable, we can't get buf from there */ | ||
| 53 | void *data; | ||
| 54 | } *data; | ||
| 55 | |||
| 56 | struct desc *ring; | ||
| 57 | struct event *event; | ||
| 58 | |||
| 59 | struct guest { | ||
| 60 | unsigned avail_idx; | ||
| 61 | unsigned last_used_idx; | ||
| 62 | unsigned num_free; | ||
| 63 | unsigned kicked_avail_idx; | ||
| 64 | unsigned char reserved[HOST_GUEST_PADDING - 12]; | ||
| 65 | } guest; | ||
| 66 | |||
| 67 | struct host { | ||
| 68 | /* we do not need to track last avail index | ||
| 69 | * unless we have more than one in flight. | ||
| 70 | */ | ||
| 71 | unsigned used_idx; | ||
| 72 | unsigned called_used_idx; | ||
| 73 | unsigned char reserved[HOST_GUEST_PADDING - 4]; | ||
| 74 | } host; | ||
| 75 | |||
| 76 | /* implemented by ring */ | ||
| 77 | void alloc_ring(void) | ||
| 78 | { | ||
| 79 | int ret; | ||
| 80 | int i; | ||
| 81 | |||
| 82 | ret = posix_memalign((void **)&ring, 0x1000, ring_size * sizeof *ring); | ||
| 83 | if (ret) { | ||
| 84 | perror("Unable to allocate ring buffer.\n"); | ||
| 85 | exit(3); | ||
| 86 | } | ||
| 87 | event = malloc(sizeof *event); | ||
| 88 | if (!event) { | ||
| 89 | perror("Unable to allocate event buffer.\n"); | ||
| 90 | exit(3); | ||
| 91 | } | ||
| 92 | memset(event, 0, sizeof *event); | ||
| 93 | guest.avail_idx = 0; | ||
| 94 | guest.kicked_avail_idx = -1; | ||
| 95 | guest.last_used_idx = 0; | ||
| 96 | host.used_idx = 0; | ||
| 97 | host.called_used_idx = -1; | ||
| 98 | for (i = 0; i < ring_size; ++i) { | ||
| 99 | struct desc desc = { | ||
| 100 | .index = i, | ||
| 101 | }; | ||
| 102 | ring[i] = desc; | ||
| 103 | } | ||
| 104 | guest.num_free = ring_size; | ||
| 105 | data = malloc(ring_size * sizeof *data); | ||
| 106 | if (!data) { | ||
| 107 | perror("Unable to allocate data buffer.\n"); | ||
| 108 | exit(3); | ||
| 109 | } | ||
| 110 | memset(data, 0, ring_size * sizeof *data); | ||
| 111 | } | ||
| 112 | |||
| 113 | /* guest side */ | ||
| 114 | int add_inbuf(unsigned len, void *buf, void *datap) | ||
| 115 | { | ||
| 116 | unsigned head, index; | ||
| 117 | |||
| 118 | if (!guest.num_free) | ||
| 119 | return -1; | ||
| 120 | |||
| 121 | guest.num_free--; | ||
| 122 | head = (ring_size - 1) & (guest.avail_idx++); | ||
| 123 | |||
| 124 | /* Start with a write. On MESI architectures this helps | ||
| 125 | * avoid a shared state with consumer that is polling this descriptor. | ||
| 126 | */ | ||
| 127 | ring[head].addr = (unsigned long)(void*)buf; | ||
| 128 | ring[head].len = len; | ||
| 129 | /* read below might bypass write above. That is OK because it's just an | ||
| 130 | * optimization. If this happens, we will get the cache line in a | ||
| 131 | * shared state which is unfortunate, but probably not worth it to | ||
| 132 | * add an explicit full barrier to avoid this. | ||
| 133 | */ | ||
| 134 | barrier(); | ||
| 135 | index = ring[head].index; | ||
| 136 | data[index].buf = buf; | ||
| 137 | data[index].data = datap; | ||
| 138 | /* Barrier A (for pairing) */ | ||
| 139 | smp_release(); | ||
| 140 | ring[head].flags = DESC_HW; | ||
| 141 | |||
| 142 | return 0; | ||
| 143 | } | ||
| 144 | |||
| 145 | void *get_buf(unsigned *lenp, void **bufp) | ||
| 146 | { | ||
| 147 | unsigned head = (ring_size - 1) & guest.last_used_idx; | ||
| 148 | unsigned index; | ||
| 149 | void *datap; | ||
| 150 | |||
| 151 | if (ring[head].flags & DESC_HW) | ||
| 152 | return NULL; | ||
| 153 | /* Barrier B (for pairing) */ | ||
| 154 | smp_acquire(); | ||
| 155 | *lenp = ring[head].len; | ||
| 156 | index = ring[head].index & (ring_size - 1); | ||
| 157 | datap = data[index].data; | ||
| 158 | *bufp = data[index].buf; | ||
| 159 | data[index].buf = NULL; | ||
| 160 | data[index].data = NULL; | ||
| 161 | guest.num_free++; | ||
| 162 | guest.last_used_idx++; | ||
| 163 | return datap; | ||
| 164 | } | ||
| 165 | |||
| 166 | void poll_used(void) | ||
| 167 | { | ||
| 168 | unsigned head = (ring_size - 1) & guest.last_used_idx; | ||
| 169 | |||
| 170 | while (ring[head].flags & DESC_HW) | ||
| 171 | busy_wait(); | ||
| 172 | } | ||
| 173 | |||
| 174 | void disable_call() | ||
| 175 | { | ||
| 176 | /* Doing nothing to disable calls might cause | ||
| 177 | * extra interrupts, but reduces the number of cache misses. | ||
| 178 | */ | ||
| 179 | } | ||
| 180 | |||
| 181 | bool enable_call() | ||
| 182 | { | ||
| 183 | unsigned head = (ring_size - 1) & guest.last_used_idx; | ||
| 184 | |||
| 185 | event->call_index = guest.last_used_idx; | ||
| 186 | /* Flush call index write */ | ||
| 187 | /* Barrier D (for pairing) */ | ||
| 188 | smp_mb(); | ||
| 189 | return ring[head].flags & DESC_HW; | ||
| 190 | } | ||
| 191 | |||
| 192 | void kick_available(void) | ||
| 193 | { | ||
| 194 | /* Flush in previous flags write */ | ||
| 195 | /* Barrier C (for pairing) */ | ||
| 196 | smp_mb(); | ||
| 197 | if (!need_event(event->kick_index, | ||
| 198 | guest.avail_idx, | ||
| 199 | guest.kicked_avail_idx)) | ||
| 200 | return; | ||
| 201 | |||
| 202 | guest.kicked_avail_idx = guest.avail_idx; | ||
| 203 | kick(); | ||
| 204 | } | ||
| 205 | |||
| 206 | /* host side */ | ||
| 207 | void disable_kick() | ||
| 208 | { | ||
| 209 | /* Doing nothing to disable kicks might cause | ||
| 210 | * extra interrupts, but reduces the number of cache misses. | ||
| 211 | */ | ||
| 212 | } | ||
| 213 | |||
| 214 | bool enable_kick() | ||
| 215 | { | ||
| 216 | unsigned head = (ring_size - 1) & host.used_idx; | ||
| 217 | |||
| 218 | event->kick_index = host.used_idx; | ||
| 219 | /* Barrier C (for pairing) */ | ||
| 220 | smp_mb(); | ||
| 221 | return !(ring[head].flags & DESC_HW); | ||
| 222 | } | ||
| 223 | |||
| 224 | void poll_avail(void) | ||
| 225 | { | ||
| 226 | unsigned head = (ring_size - 1) & host.used_idx; | ||
| 227 | |||
| 228 | while (!(ring[head].flags & DESC_HW)) | ||
| 229 | busy_wait(); | ||
| 230 | } | ||
| 231 | |||
| 232 | bool use_buf(unsigned *lenp, void **bufp) | ||
| 233 | { | ||
| 234 | unsigned head = (ring_size - 1) & host.used_idx; | ||
| 235 | |||
| 236 | if (!(ring[head].flags & DESC_HW)) | ||
| 237 | return false; | ||
| 238 | |||
| 239 | /* make sure length read below is not speculated */ | ||
| 240 | /* Barrier A (for pairing) */ | ||
| 241 | smp_acquire(); | ||
| 242 | |||
| 243 | /* simple in-order completion: we don't need | ||
| 244 | * to touch index at all. This also means we | ||
| 245 | * can just modify the descriptor in-place. | ||
| 246 | */ | ||
| 247 | ring[head].len--; | ||
| 248 | /* Make sure len is valid before flags. | ||
| 249 | * Note: alternative is to write len and flags in one access - | ||
| 250 | * possible on 64 bit architectures but wmb is free on Intel anyway | ||
| 251 | * so I have no way to test whether it's a gain. | ||
| 252 | */ | ||
| 253 | /* Barrier B (for pairing) */ | ||
| 254 | smp_release(); | ||
| 255 | ring[head].flags = 0; | ||
| 256 | host.used_idx++; | ||
| 257 | return true; | ||
| 258 | } | ||
| 259 | |||
| 260 | void call_used(void) | ||
| 261 | { | ||
| 262 | /* Flush in previous flags write */ | ||
| 263 | /* Barrier D (for pairing) */ | ||
| 264 | smp_mb(); | ||
| 265 | if (!need_event(event->call_index, | ||
| 266 | host.used_idx, | ||
| 267 | host.called_used_idx)) | ||
| 268 | return; | ||
| 269 | |||
| 270 | host.called_used_idx = host.used_idx; | ||
| 271 | call(); | ||
| 272 | } | ||
| @@ -0,0 +1,24 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | #use last CPU for host. Why not the first? | ||
| 4 | #many devices tend to use cpu0 by default so | ||
| 5 | #it tends to be busier | ||
| 6 | HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1) | ||
| 7 | |||
| 8 | #run command on all cpus | ||
| 9 | for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n); | ||
| 10 | do | ||
| 11 | #Don't run guest and host on same CPU | ||
| 12 | #It actually works ok if using signalling | ||
| 13 | if | ||
| 14 | (echo "$@" | grep -e "--sleep" > /dev/null) || \ | ||
| 15 | test $HOST_AFFINITY '!=' $cpu | ||
| 16 | then | ||
| 17 | echo "GUEST AFFINITY $cpu" | ||
| 18 | "$@" --host-affinity $HOST_AFFINITY --guest-affinity $cpu | ||
| 19 | fi | ||
| 20 | done | ||
| 21 | echo "NO GUEST AFFINITY" | ||
| 22 | "$@" --host-affinity $HOST_AFFINITY | ||
| 23 | echo "NO AFFINITY" | ||
| 24 | "$@" | ||
| @@ -0,0 +1,316 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2016 Red Hat, Inc. | ||
| 3 | * Author: Michael S. Tsirkin <mst@redhat.com> | ||
| 4 | * This work is licensed under the terms of the GNU GPL, version 2. | ||
| 5 | * | ||
| 6 | * Partial implementation of virtio 0.9. event index is used for signalling, | ||
| 7 | * unconditionally. Design roughly follows linux kernel implementation in order | ||
| 8 | * to be able to judge its performance. | ||
| 9 | */ | ||
| 10 | #define _GNU_SOURCE | ||
| 11 | #include "main.h" | ||
| 12 | #include <stdlib.h> | ||
| 13 | #include <stdio.h> | ||
| 14 | #include <assert.h> | ||
| 15 | #include <string.h> | ||
| 16 | #include <linux/virtio_ring.h> | ||
| 17 | |||
| 18 | struct data { | ||
| 19 | void *data; | ||
| 20 | } *data; | ||
| 21 | |||
| 22 | struct vring ring; | ||
| 23 | |||
| 24 | /* enabling the below activates experimental ring polling code | ||
| 25 | * (which skips index reads on consumer in favor of looking at | ||
| 26 | * high bits of ring id ^ 0x8000). | ||
| 27 | */ | ||
| 28 | /* #ifdef RING_POLL */ | ||
| 29 | |||
| 30 | /* how much padding is needed to avoid false cache sharing */ | ||
| 31 | #define HOST_GUEST_PADDING 0x80 | ||
| 32 | |||
| 33 | struct guest { | ||
| 34 | unsigned short avail_idx; | ||
| 35 | unsigned short last_used_idx; | ||
| 36 | unsigned short num_free; | ||
| 37 | unsigned short kicked_avail_idx; | ||
| 38 | unsigned short free_head; | ||
| 39 | unsigned char reserved[HOST_GUEST_PADDING - 10]; | ||
| 40 | } guest; | ||
| 41 | |||
| 42 | struct host { | ||
| 43 | /* we do not need to track last avail index | ||
| 44 | * unless we have more than one in flight. | ||
| 45 | */ | ||
| 46 | unsigned short used_idx; | ||
| 47 | unsigned short called_used_idx; | ||
| 48 | unsigned char reserved[HOST_GUEST_PADDING - 4]; | ||
| 49 | } host; | ||
| 50 | |||
| 51 | /* implemented by ring */ | ||
| 52 | void alloc_ring(void) | ||
| 53 | { | ||
| 54 | int ret; | ||
| 55 | int i; | ||
| 56 | void *p; | ||
| 57 | |||
| 58 | ret = posix_memalign(&p, 0x1000, vring_size(ring_size, 0x1000)); | ||
| 59 | if (ret) { | ||
| 60 | perror("Unable to allocate ring buffer.\n"); | ||
| 61 | exit(3); | ||
| 62 | } | ||
| 63 | memset(p, 0, vring_size(ring_size, 0x1000)); | ||
| 64 | vring_init(&ring, ring_size, p, 0x1000); | ||
| 65 | |||
| 66 | guest.avail_idx = 0; | ||
| 67 | guest.kicked_avail_idx = -1; | ||
| 68 | guest.last_used_idx = 0; | ||
| 69 | /* Put everything in free lists. */ | ||
| 70 | guest.free_head = 0; | ||
| 71 | for (i = 0; i < ring_size - 1; i++) | ||
| 72 | ring.desc[i].next = i + 1; | ||
| 73 | host.used_idx = 0; | ||
| 74 | host.called_used_idx = -1; | ||
| 75 | guest.num_free = ring_size; | ||
| 76 | data = malloc(ring_size * sizeof *data); | ||
| 77 | if (!data) { | ||
| 78 | perror("Unable to allocate data buffer.\n"); | ||
| 79 | exit(3); | ||
| 80 | } | ||
| 81 | memset(data, 0, ring_size * sizeof *data); | ||
| 82 | } | ||
| 83 | |||
| 84 | /* guest side */ | ||
| 85 | int add_inbuf(unsigned len, void *buf, void *datap) | ||
| 86 | { | ||
| 87 | unsigned head, avail; | ||
| 88 | struct vring_desc *desc; | ||
| 89 | |||
| 90 | if (!guest.num_free) | ||
| 91 | return -1; | ||
| 92 | |||
| 93 | head = guest.free_head; | ||
| 94 | guest.num_free--; | ||
| 95 | |||
| 96 | desc = ring.desc; | ||
| 97 | desc[head].flags = VRING_DESC_F_NEXT; | ||
| 98 | desc[head].addr = (unsigned long)(void *)buf; | ||
| 99 | desc[head].len = len; | ||
| 100 | /* We do it like this to simulate the way | ||
| 101 | * we'd have to flip it if we had multiple | ||
| 102 | * descriptors. | ||
| 103 | */ | ||
| 104 | desc[head].flags &= ~VRING_DESC_F_NEXT; | ||
| 105 | guest.free_head = desc[head].next; | ||
| 106 | |||
| 107 | data[head].data = datap; | ||
| 108 | |||
| 109 | #ifdef RING_POLL | ||
| 110 | /* Barrier A (for pairing) */ | ||
| 111 | smp_release(); | ||
| 112 | avail = guest.avail_idx++; | ||
| 113 | ring.avail->ring[avail & (ring_size - 1)] = | ||
| 114 | (head | (avail & ~(ring_size - 1))) ^ 0x8000; | ||
| 115 | #else | ||
| 116 | avail = (ring_size - 1) & (guest.avail_idx++); | ||
| 117 | ring.avail->ring[avail] = head; | ||
| 118 | /* Barrier A (for pairing) */ | ||
| 119 | smp_release(); | ||
| 120 | #endif | ||
| 121 | ring.avail->idx = guest.avail_idx; | ||
| 122 | return 0; | ||
| 123 | } | ||
| 124 | |||
| 125 | void *get_buf(unsigned *lenp, void **bufp) | ||
| 126 | { | ||
| 127 | unsigned head; | ||
| 128 | unsigned index; | ||
| 129 | void *datap; | ||
| 130 | |||
| 131 | #ifdef RING_POLL | ||
| 132 | head = (ring_size - 1) & guest.last_used_idx; | ||
| 133 | index = ring.used->ring[head].id; | ||
| 134 | if ((index ^ guest.last_used_idx ^ 0x8000) & ~(ring_size - 1)) | ||
| 135 | return NULL; | ||
| 136 | /* Barrier B (for pairing) */ | ||
| 137 | smp_acquire(); | ||
| 138 | index &= ring_size - 1; | ||
| 139 | #else | ||
| 140 | if (ring.used->idx == guest.last_used_idx) | ||
| 141 | return NULL; | ||
| 142 | /* Barrier B (for pairing) */ | ||
| 143 | smp_acquire(); | ||
| 144 | head = (ring_size - 1) & guest.last_used_idx; | ||
| 145 | index = ring.used->ring[head].id; | ||
| 146 | #endif | ||
| 147 | *lenp = ring.used->ring[head].len; | ||
| 148 | datap = data[index].data; | ||
| 149 | *bufp = (void*)(unsigned long)ring.desc[index].addr; | ||
| 150 | data[index].data = NULL; | ||
| 151 | ring.desc[index].next = guest.free_head; | ||
| 152 | guest.free_head = index; | ||
| 153 | guest.num_free++; | ||
| 154 | guest.last_used_idx++; | ||
| 155 | return datap; | ||
| 156 | } | ||
| 157 | |||
| 158 | void poll_used(void) | ||
| 159 | { | ||
| 160 | #ifdef RING_POLL | ||
| 161 | unsigned head = (ring_size - 1) & guest.last_used_idx; | ||
| 162 | |||
| 163 | for (;;) { | ||
| 164 | unsigned index = ring.used->ring[head].id; | ||
| 165 | |||
| 166 | if ((index ^ guest.last_used_idx ^ 0x8000) & ~(ring_size - 1)) | ||
| 167 | busy_wait(); | ||
| 168 | else | ||
| 169 | break; | ||
| 170 | } | ||
| 171 | #else | ||
| 172 | unsigned head = guest.last_used_idx; | ||
| 173 | |||
| 174 | while (ring.used->idx == head) | ||
| 175 | busy_wait(); | ||
| 176 | #endif | ||
| 177 | } | ||
| 178 | |||
| 179 | void disable_call() | ||
| 180 | { | ||
| 181 | /* Doing nothing to disable calls might cause | ||
| 182 | * extra interrupts, but reduces the number of cache misses. | ||
| 183 | */ | ||
| 184 | } | ||
| 185 | |||
| 186 | bool enable_call() | ||
| 187 | { | ||
| 188 | unsigned short last_used_idx; | ||
| 189 | |||
| 190 | vring_used_event(&ring) = (last_used_idx = guest.last_used_idx); | ||
| 191 | /* Flush call index write */ | ||
| 192 | /* Barrier D (for pairing) */ | ||
| 193 | smp_mb(); | ||
| 194 | #ifdef RING_POLL | ||
| 195 | { | ||
| 196 | unsigned short head = last_used_idx & (ring_size - 1); | ||
| 197 | unsigned index = ring.used->ring[head].id; | ||
| 198 | |||
| 199 | return (index ^ last_used_idx ^ 0x8000) & ~(ring_size - 1); | ||
| 200 | } | ||
| 201 | #else | ||
| 202 | return ring.used->idx == last_used_idx; | ||
| 203 | #endif | ||
| 204 | } | ||
| 205 | |||
| 206 | void kick_available(void) | ||
| 207 | { | ||
| 208 | /* Flush in previous flags write */ | ||
| 209 | /* Barrier C (for pairing) */ | ||
| 210 | smp_mb(); | ||
| 211 | if (!vring_need_event(vring_avail_event(&ring), | ||
| 212 | guest.avail_idx, | ||
| 213 | guest.kicked_avail_idx)) | ||
| 214 | return; | ||
| 215 | |||
| 216 | guest.kicked_avail_idx = guest.avail_idx; | ||
| 217 | kick(); | ||
| 218 | } | ||
| 219 | |||
| 220 | /* host side */ | ||
| 221 | void disable_kick() | ||
| 222 | { | ||
| 223 | /* Doing nothing to disable kicks might cause | ||
| 224 | * extra interrupts, but reduces the number of cache misses. | ||
| 225 | */ | ||
| 226 | } | ||
| 227 | |||
| 228 | bool enable_kick() | ||
| 229 | { | ||
| 230 | unsigned head = host.used_idx; | ||
| 231 | |||
| 232 | vring_avail_event(&ring) = head; | ||
| 233 | /* Barrier C (for pairing) */ | ||
| 234 | smp_mb(); | ||
| 235 | #ifdef RING_POLL | ||
| 236 | { | ||
| 237 | unsigned index = ring.avail->ring[head & (ring_size - 1)]; | ||
| 238 | |||
| 239 | return (index ^ head ^ 0x8000) & ~(ring_size - 1); | ||
| 240 | } | ||
| 241 | #else | ||
| 242 | return head == ring.avail->idx; | ||
| 243 | #endif | ||
| 244 | } | ||
| 245 | |||
| 246 | void poll_avail(void) | ||
| 247 | { | ||
| 248 | unsigned head = host.used_idx; | ||
| 249 | #ifdef RING_POLL | ||
| 250 | for (;;) { | ||
| 251 | unsigned index = ring.avail->ring[head & (ring_size - 1)]; | ||
| 252 | if ((index ^ head ^ 0x8000) & ~(ring_size - 1)) | ||
| 253 | busy_wait(); | ||
| 254 | else | ||
| 255 | break; | ||
| 256 | } | ||
| 257 | #else | ||
| 258 | while (ring.avail->idx == head) | ||
| 259 | busy_wait(); | ||
| 260 | #endif | ||
| 261 | } | ||
| 262 | |||
| 263 | bool use_buf(unsigned *lenp, void **bufp) | ||
| 264 | { | ||
| 265 | unsigned used_idx = host.used_idx; | ||
| 266 | struct vring_desc *desc; | ||
| 267 | unsigned head; | ||
| 268 | |||
| 269 | #ifdef RING_POLL | ||
| 270 | head = ring.avail->ring[used_idx & (ring_size - 1)]; | ||
| 271 | if ((used_idx ^ head ^ 0x8000) & ~(ring_size - 1)) | ||
| 272 | return false; | ||
| 273 | /* Barrier A (for pairing) */ | ||
| 274 | smp_acquire(); | ||
| 275 | |||
| 276 | used_idx &= ring_size - 1; | ||
| 277 | desc = &ring.desc[head & (ring_size - 1)]; | ||
| 278 | #else | ||
| 279 | if (used_idx == ring.avail->idx) | ||
| 280 | return false; | ||
| 281 | |||
| 282 | /* Barrier A (for pairing) */ | ||
| 283 | smp_acquire(); | ||
| 284 | |||
| 285 | used_idx &= ring_size - 1; | ||
| 286 | head = ring.avail->ring[used_idx]; | ||
| 287 | desc = &ring.desc[head]; | ||
| 288 | #endif | ||
| 289 | |||
| 290 | *lenp = desc->len; | ||
| 291 | *bufp = (void *)(unsigned long)desc->addr; | ||
| 292 | |||
| 293 | /* now update used ring */ | ||
| 294 | ring.used->ring[used_idx].id = head; | ||
| 295 | ring.used->ring[used_idx].len = desc->len - 1; | ||
| 296 | /* Barrier B (for pairing) */ | ||
| 297 | smp_release(); | ||
| 298 | host.used_idx++; | ||
| 299 | ring.used->idx = host.used_idx; | ||
| 300 | |||
| 301 | return true; | ||
| 302 | } | ||
| 303 | |||
| 304 | void call_used(void) | ||
| 305 | { | ||
| 306 | /* Flush in previous flags write */ | ||
| 307 | /* Barrier D (for pairing) */ | ||
| 308 | smp_mb(); | ||
| 309 | if (!vring_need_event(vring_used_event(&ring), | ||
| 310 | host.used_idx, | ||
| 311 | host.called_used_idx)) | ||
| 312 | return; | ||
| 313 | |||
| 314 | host.called_used_idx = host.used_idx; | ||
| 315 | call(); | ||
| 316 | } | ||
| @@ -0,0 +1,2 @@ | |||
| 1 | #define RING_POLL 1 | ||
| 2 | #include "virtio_ring_0_9.c" | ||