diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-28 19:52:28 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-28 19:52:28 -0400 |
| commit | 6fcc8cea8279a0d37143e9af806aa9989193a8dd (patch) | |
| tree | 9fa68307fc291259bb49f1bc23ba60d8fa32be71 | |
| parent | b49c3170bf2803329c0daff8e386e08f50f1729d (diff) | |
| parent | fb479e44a9e240a23c2d208c2ace23542a47f41c (diff) | |
Merge tag 'powerpc-4.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman:
"Fixes marked for stable:
- Convert cmp to cmpd in idle enter sequence (Segher Boessenkool)
- cxl: Fix leaking pid refs in some error paths (Vaibhav Jain)
- Re-fix race condition between going idle and entering guest (Paul Mackerras)
- Fix race condition in setting lock bit in idle/wakeup code (Paul Mackerras)
- radix: Use tlbiel only if we ever ran on the current cpu (Aneesh Kumar K.V)
- relocation, register save fixes for system reset interrupt (Nicholas Piggin)
Fixes for code merged this cycle:
- Fix CONFIG_ALIVEC typo in restore_tm_state() (Valentin Rothberg)
- KVM: PPC: Book3S HV: Fix build error when SMP=n (Michael Ellerman)"
* tag 'powerpc-4.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/64s: relocation, register save fixes for system reset interrupt
powerpc/mm/radix: Use tlbiel only if we ever ran on the current cpu
powerpc/process: Fix CONFIG_ALIVEC typo in restore_tm_state()
powerpc/64: Fix race condition in setting lock bit in idle/wakeup code
powerpc/64: Re-fix race condition between going idle and entering guest
cxl: Fix leaking pid refs in some error paths
powerpc: Convert cmp to cmpd in idle enter sequence
KVM: PPC: Book3S HV: Fix build error when SMP=n
| -rw-r--r-- | arch/powerpc/include/asm/cpuidle.h | 2 | ||||
| -rw-r--r-- | arch/powerpc/include/asm/exception-64s.h | 16 | ||||
| -rw-r--r-- | arch/powerpc/include/asm/tlb.h | 12 | ||||
| -rw-r--r-- | arch/powerpc/kernel/exceptions-64s.S | 50 | ||||
| -rw-r--r-- | arch/powerpc/kernel/idle_book3s.S | 35 | ||||
| -rw-r--r-- | arch/powerpc/kernel/process.c | 2 | ||||
| -rw-r--r-- | arch/powerpc/kvm/book3s_hv_rm_xics.c | 1 | ||||
| -rw-r--r-- | arch/powerpc/mm/tlb-radix.c | 8 | ||||
| -rw-r--r-- | drivers/misc/cxl/api.c | 2 | ||||
| -rw-r--r-- | drivers/misc/cxl/file.c | 22 |
10 files changed, 108 insertions, 42 deletions
diff --git a/arch/powerpc/include/asm/cpuidle.h b/arch/powerpc/include/asm/cpuidle.h index 01b8a13f0224..3919332965af 100644 --- a/arch/powerpc/include/asm/cpuidle.h +++ b/arch/powerpc/include/asm/cpuidle.h | |||
| @@ -26,7 +26,7 @@ extern u64 pnv_first_deep_stop_state; | |||
| 26 | std r0,0(r1); \ | 26 | std r0,0(r1); \ |
| 27 | ptesync; \ | 27 | ptesync; \ |
| 28 | ld r0,0(r1); \ | 28 | ld r0,0(r1); \ |
| 29 | 1: cmp cr0,r0,r0; \ | 29 | 1: cmpd cr0,r0,r0; \ |
| 30 | bne 1b; \ | 30 | bne 1b; \ |
| 31 | IDLE_INST; \ | 31 | IDLE_INST; \ |
| 32 | b . | 32 | b . |
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h index 2e4e7d878c8e..84d49b197c32 100644 --- a/arch/powerpc/include/asm/exception-64s.h +++ b/arch/powerpc/include/asm/exception-64s.h | |||
| @@ -93,6 +93,10 @@ | |||
| 93 | ld reg,PACAKBASE(r13); /* get high part of &label */ \ | 93 | ld reg,PACAKBASE(r13); /* get high part of &label */ \ |
| 94 | ori reg,reg,(FIXED_SYMBOL_ABS_ADDR(label))@l; | 94 | ori reg,reg,(FIXED_SYMBOL_ABS_ADDR(label))@l; |
| 95 | 95 | ||
| 96 | #define __LOAD_HANDLER(reg, label) \ | ||
| 97 | ld reg,PACAKBASE(r13); \ | ||
| 98 | ori reg,reg,(ABS_ADDR(label))@l; | ||
| 99 | |||
| 96 | /* Exception register prefixes */ | 100 | /* Exception register prefixes */ |
| 97 | #define EXC_HV H | 101 | #define EXC_HV H |
| 98 | #define EXC_STD | 102 | #define EXC_STD |
| @@ -208,6 +212,18 @@ END_FTR_SECTION_NESTED(ftr,ftr,943) | |||
| 208 | #define kvmppc_interrupt kvmppc_interrupt_pr | 212 | #define kvmppc_interrupt kvmppc_interrupt_pr |
| 209 | #endif | 213 | #endif |
| 210 | 214 | ||
| 215 | #ifdef CONFIG_RELOCATABLE | ||
| 216 | #define BRANCH_TO_COMMON(reg, label) \ | ||
| 217 | __LOAD_HANDLER(reg, label); \ | ||
| 218 | mtctr reg; \ | ||
| 219 | bctr | ||
| 220 | |||
| 221 | #else | ||
| 222 | #define BRANCH_TO_COMMON(reg, label) \ | ||
| 223 | b label | ||
| 224 | |||
| 225 | #endif | ||
| 226 | |||
| 211 | #define __KVM_HANDLER_PROLOG(area, n) \ | 227 | #define __KVM_HANDLER_PROLOG(area, n) \ |
| 212 | BEGIN_FTR_SECTION_NESTED(947) \ | 228 | BEGIN_FTR_SECTION_NESTED(947) \ |
| 213 | ld r10,area+EX_CFAR(r13); \ | 229 | ld r10,area+EX_CFAR(r13); \ |
diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h index f6f68f73e858..99e1397b71da 100644 --- a/arch/powerpc/include/asm/tlb.h +++ b/arch/powerpc/include/asm/tlb.h | |||
| @@ -52,11 +52,23 @@ static inline int mm_is_core_local(struct mm_struct *mm) | |||
| 52 | return cpumask_subset(mm_cpumask(mm), | 52 | return cpumask_subset(mm_cpumask(mm), |
| 53 | topology_sibling_cpumask(smp_processor_id())); | 53 | topology_sibling_cpumask(smp_processor_id())); |
| 54 | } | 54 | } |
| 55 | |||
| 56 | static inline int mm_is_thread_local(struct mm_struct *mm) | ||
| 57 | { | ||
| 58 | return cpumask_equal(mm_cpumask(mm), | ||
| 59 | cpumask_of(smp_processor_id())); | ||
| 60 | } | ||
| 61 | |||
| 55 | #else | 62 | #else |
| 56 | static inline int mm_is_core_local(struct mm_struct *mm) | 63 | static inline int mm_is_core_local(struct mm_struct *mm) |
| 57 | { | 64 | { |
| 58 | return 1; | 65 | return 1; |
| 59 | } | 66 | } |
| 67 | |||
| 68 | static inline int mm_is_thread_local(struct mm_struct *mm) | ||
| 69 | { | ||
| 70 | return 1; | ||
| 71 | } | ||
| 60 | #endif | 72 | #endif |
| 61 | 73 | ||
| 62 | #endif /* __KERNEL__ */ | 74 | #endif /* __KERNEL__ */ |
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index f129408c6022..08ba447a4b3d 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S | |||
| @@ -95,19 +95,35 @@ __start_interrupts: | |||
| 95 | /* No virt vectors corresponding with 0x0..0x100 */ | 95 | /* No virt vectors corresponding with 0x0..0x100 */ |
| 96 | EXC_VIRT_NONE(0x4000, 0x4100) | 96 | EXC_VIRT_NONE(0x4000, 0x4100) |
| 97 | 97 | ||
| 98 | EXC_REAL_BEGIN(system_reset, 0x100, 0x200) | 98 | |
| 99 | SET_SCRATCH0(r13) | ||
| 100 | #ifdef CONFIG_PPC_P7_NAP | 99 | #ifdef CONFIG_PPC_P7_NAP |
| 101 | BEGIN_FTR_SECTION | 100 | /* |
| 102 | /* Running native on arch 2.06 or later, check if we are | 101 | * If running native on arch 2.06 or later, check if we are waking up |
| 103 | * waking up from nap/sleep/winkle. | 102 | * from nap/sleep/winkle, and branch to idle handler. |
| 104 | */ | 103 | */ |
| 105 | mfspr r13,SPRN_SRR1 | 104 | #define IDLETEST(n) \ |
| 106 | rlwinm. r13,r13,47-31,30,31 | 105 | BEGIN_FTR_SECTION ; \ |
| 107 | beq 9f | 106 | mfspr r10,SPRN_SRR1 ; \ |
| 107 | rlwinm. r10,r10,47-31,30,31 ; \ | ||
| 108 | beq- 1f ; \ | ||
| 109 | cmpwi cr3,r10,2 ; \ | ||
| 110 | BRANCH_TO_COMMON(r10, system_reset_idle_common) ; \ | ||
| 111 | 1: \ | ||
| 112 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) | ||
| 113 | #else | ||
| 114 | #define IDLETEST NOTEST | ||
| 115 | #endif | ||
| 108 | 116 | ||
| 109 | cmpwi cr3,r13,2 | 117 | EXC_REAL_BEGIN(system_reset, 0x100, 0x200) |
| 110 | GET_PACA(r13) | 118 | SET_SCRATCH0(r13) |
| 119 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, | ||
| 120 | IDLETEST, 0x100) | ||
| 121 | |||
| 122 | EXC_REAL_END(system_reset, 0x100, 0x200) | ||
| 123 | EXC_VIRT_NONE(0x4100, 0x4200) | ||
| 124 | |||
| 125 | #ifdef CONFIG_PPC_P7_NAP | ||
| 126 | EXC_COMMON_BEGIN(system_reset_idle_common) | ||
| 111 | bl pnv_restore_hyp_resource | 127 | bl pnv_restore_hyp_resource |
| 112 | 128 | ||
| 113 | li r0,PNV_THREAD_RUNNING | 129 | li r0,PNV_THREAD_RUNNING |
| @@ -130,14 +146,8 @@ BEGIN_FTR_SECTION | |||
| 130 | blt cr3,2f | 146 | blt cr3,2f |
| 131 | b pnv_wakeup_loss | 147 | b pnv_wakeup_loss |
| 132 | 2: b pnv_wakeup_noloss | 148 | 2: b pnv_wakeup_noloss |
| 149 | #endif | ||
| 133 | 150 | ||
| 134 | 9: | ||
| 135 | END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) | ||
| 136 | #endif /* CONFIG_PPC_P7_NAP */ | ||
| 137 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD, | ||
| 138 | NOTEST, 0x100) | ||
| 139 | EXC_REAL_END(system_reset, 0x100, 0x200) | ||
| 140 | EXC_VIRT_NONE(0x4100, 0x4200) | ||
| 141 | EXC_COMMON(system_reset_common, 0x100, system_reset_exception) | 151 | EXC_COMMON(system_reset_common, 0x100, system_reset_exception) |
| 142 | 152 | ||
| 143 | #ifdef CONFIG_PPC_PSERIES | 153 | #ifdef CONFIG_PPC_PSERIES |
| @@ -817,10 +827,8 @@ EXC_VIRT(trap_0b, 0x4b00, 0x4c00, 0xb00) | |||
| 817 | TRAMP_KVM(PACA_EXGEN, 0xb00) | 827 | TRAMP_KVM(PACA_EXGEN, 0xb00) |
| 818 | EXC_COMMON(trap_0b_common, 0xb00, unknown_exception) | 828 | EXC_COMMON(trap_0b_common, 0xb00, unknown_exception) |
| 819 | 829 | ||
| 820 | 830 | #define LOAD_SYSCALL_HANDLER(reg) \ | |
| 821 | #define LOAD_SYSCALL_HANDLER(reg) \ | 831 | __LOAD_HANDLER(reg, system_call_common) |
| 822 | ld reg,PACAKBASE(r13); \ | ||
| 823 | ori reg,reg,(ABS_ADDR(system_call_common))@l; | ||
| 824 | 832 | ||
| 825 | /* Syscall routine is used twice, in reloc-off and reloc-on paths */ | 833 | /* Syscall routine is used twice, in reloc-off and reloc-on paths */ |
| 826 | #define SYSCALL_PSERIES_1 \ | 834 | #define SYSCALL_PSERIES_1 \ |
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S index bd739fed26e3..72dac0b58061 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S | |||
| @@ -90,6 +90,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300) | |||
| 90 | * Threads will spin in HMT_LOW until the lock bit is cleared. | 90 | * Threads will spin in HMT_LOW until the lock bit is cleared. |
| 91 | * r14 - pointer to core_idle_state | 91 | * r14 - pointer to core_idle_state |
| 92 | * r15 - used to load contents of core_idle_state | 92 | * r15 - used to load contents of core_idle_state |
| 93 | * r9 - used as a temporary variable | ||
| 93 | */ | 94 | */ |
| 94 | 95 | ||
| 95 | core_idle_lock_held: | 96 | core_idle_lock_held: |
| @@ -99,6 +100,8 @@ core_idle_lock_held: | |||
| 99 | bne 3b | 100 | bne 3b |
| 100 | HMT_MEDIUM | 101 | HMT_MEDIUM |
| 101 | lwarx r15,0,r14 | 102 | lwarx r15,0,r14 |
| 103 | andi. r9,r15,PNV_CORE_IDLE_LOCK_BIT | ||
| 104 | bne core_idle_lock_held | ||
| 102 | blr | 105 | blr |
| 103 | 106 | ||
| 104 | /* | 107 | /* |
| @@ -163,12 +166,6 @@ _GLOBAL(pnv_powersave_common) | |||
| 163 | std r9,_MSR(r1) | 166 | std r9,_MSR(r1) |
| 164 | std r1,PACAR1(r13) | 167 | std r1,PACAR1(r13) |
| 165 | 168 | ||
| 166 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE | ||
| 167 | /* Tell KVM we're entering idle */ | ||
| 168 | li r4,KVM_HWTHREAD_IN_IDLE | ||
| 169 | stb r4,HSTATE_HWTHREAD_STATE(r13) | ||
| 170 | #endif | ||
| 171 | |||
| 172 | /* | 169 | /* |
| 173 | * Go to real mode to do the nap, as required by the architecture. | 170 | * Go to real mode to do the nap, as required by the architecture. |
| 174 | * Also, we need to be in real mode before setting hwthread_state, | 171 | * Also, we need to be in real mode before setting hwthread_state, |
| @@ -185,6 +182,26 @@ _GLOBAL(pnv_powersave_common) | |||
| 185 | 182 | ||
| 186 | .globl pnv_enter_arch207_idle_mode | 183 | .globl pnv_enter_arch207_idle_mode |
| 187 | pnv_enter_arch207_idle_mode: | 184 | pnv_enter_arch207_idle_mode: |
| 185 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE | ||
| 186 | /* Tell KVM we're entering idle */ | ||
| 187 | li r4,KVM_HWTHREAD_IN_IDLE | ||
| 188 | /******************************************************/ | ||
| 189 | /* N O T E W E L L ! ! ! N O T E W E L L */ | ||
| 190 | /* The following store to HSTATE_HWTHREAD_STATE(r13) */ | ||
| 191 | /* MUST occur in real mode, i.e. with the MMU off, */ | ||
| 192 | /* and the MMU must stay off until we clear this flag */ | ||
| 193 | /* and test HSTATE_HWTHREAD_REQ(r13) in the system */ | ||
| 194 | /* reset interrupt vector in exceptions-64s.S. */ | ||
| 195 | /* The reason is that another thread can switch the */ | ||
| 196 | /* MMU to a guest context whenever this flag is set */ | ||
| 197 | /* to KVM_HWTHREAD_IN_IDLE, and if the MMU was on, */ | ||
| 198 | /* that would potentially cause this thread to start */ | ||
| 199 | /* executing instructions from guest memory in */ | ||
| 200 | /* hypervisor mode, leading to a host crash or data */ | ||
| 201 | /* corruption, or worse. */ | ||
| 202 | /******************************************************/ | ||
| 203 | stb r4,HSTATE_HWTHREAD_STATE(r13) | ||
| 204 | #endif | ||
| 188 | stb r3,PACA_THREAD_IDLE_STATE(r13) | 205 | stb r3,PACA_THREAD_IDLE_STATE(r13) |
| 189 | cmpwi cr3,r3,PNV_THREAD_SLEEP | 206 | cmpwi cr3,r3,PNV_THREAD_SLEEP |
| 190 | bge cr3,2f | 207 | bge cr3,2f |
| @@ -250,6 +267,12 @@ enter_winkle: | |||
| 250 | * r3 - requested stop state | 267 | * r3 - requested stop state |
| 251 | */ | 268 | */ |
| 252 | power_enter_stop: | 269 | power_enter_stop: |
| 270 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE | ||
| 271 | /* Tell KVM we're entering idle */ | ||
| 272 | li r4,KVM_HWTHREAD_IN_IDLE | ||
| 273 | /* DO THIS IN REAL MODE! See comment above. */ | ||
| 274 | stb r4,HSTATE_HWTHREAD_STATE(r13) | ||
| 275 | #endif | ||
| 253 | /* | 276 | /* |
| 254 | * Check if the requested state is a deep idle state. | 277 | * Check if the requested state is a deep idle state. |
| 255 | */ | 278 | */ |
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 9e7c10fe205f..ce6dc61b15b2 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c | |||
| @@ -1012,7 +1012,7 @@ void restore_tm_state(struct pt_regs *regs) | |||
| 1012 | /* Ensure that restore_math() will restore */ | 1012 | /* Ensure that restore_math() will restore */ |
| 1013 | if (msr_diff & MSR_FP) | 1013 | if (msr_diff & MSR_FP) |
| 1014 | current->thread.load_fp = 1; | 1014 | current->thread.load_fp = 1; |
| 1015 | #ifdef CONFIG_ALIVEC | 1015 | #ifdef CONFIG_ALTIVEC |
| 1016 | if (cpu_has_feature(CPU_FTR_ALTIVEC) && msr_diff & MSR_VEC) | 1016 | if (cpu_has_feature(CPU_FTR_ALTIVEC) && msr_diff & MSR_VEC) |
| 1017 | current->thread.load_vec = 1; | 1017 | current->thread.load_vec = 1; |
| 1018 | #endif | 1018 | #endif |
diff --git a/arch/powerpc/kvm/book3s_hv_rm_xics.c b/arch/powerpc/kvm/book3s_hv_rm_xics.c index 82ff5de8b1e7..a0ea63ac2b52 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_xics.c +++ b/arch/powerpc/kvm/book3s_hv_rm_xics.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <asm/ppc-opcode.h> | 23 | #include <asm/ppc-opcode.h> |
| 24 | #include <asm/pnv-pci.h> | 24 | #include <asm/pnv-pci.h> |
| 25 | #include <asm/opal.h> | 25 | #include <asm/opal.h> |
| 26 | #include <asm/smp.h> | ||
| 26 | 27 | ||
| 27 | #include "book3s_xics.h" | 28 | #include "book3s_xics.h" |
| 28 | 29 | ||
diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c index 0e49ec541ab5..bda8c43be78a 100644 --- a/arch/powerpc/mm/tlb-radix.c +++ b/arch/powerpc/mm/tlb-radix.c | |||
| @@ -175,7 +175,7 @@ void radix__flush_tlb_mm(struct mm_struct *mm) | |||
| 175 | if (unlikely(pid == MMU_NO_CONTEXT)) | 175 | if (unlikely(pid == MMU_NO_CONTEXT)) |
| 176 | goto no_context; | 176 | goto no_context; |
| 177 | 177 | ||
| 178 | if (!mm_is_core_local(mm)) { | 178 | if (!mm_is_thread_local(mm)) { |
| 179 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); | 179 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); |
| 180 | 180 | ||
| 181 | if (lock_tlbie) | 181 | if (lock_tlbie) |
| @@ -201,7 +201,7 @@ void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr) | |||
| 201 | if (unlikely(pid == MMU_NO_CONTEXT)) | 201 | if (unlikely(pid == MMU_NO_CONTEXT)) |
| 202 | goto no_context; | 202 | goto no_context; |
| 203 | 203 | ||
| 204 | if (!mm_is_core_local(mm)) { | 204 | if (!mm_is_thread_local(mm)) { |
| 205 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); | 205 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); |
| 206 | 206 | ||
| 207 | if (lock_tlbie) | 207 | if (lock_tlbie) |
| @@ -226,7 +226,7 @@ void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmaddr, | |||
| 226 | pid = mm ? mm->context.id : 0; | 226 | pid = mm ? mm->context.id : 0; |
| 227 | if (unlikely(pid == MMU_NO_CONTEXT)) | 227 | if (unlikely(pid == MMU_NO_CONTEXT)) |
| 228 | goto bail; | 228 | goto bail; |
| 229 | if (!mm_is_core_local(mm)) { | 229 | if (!mm_is_thread_local(mm)) { |
| 230 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); | 230 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); |
| 231 | 231 | ||
| 232 | if (lock_tlbie) | 232 | if (lock_tlbie) |
| @@ -321,7 +321,7 @@ void radix__flush_tlb_range_psize(struct mm_struct *mm, unsigned long start, | |||
| 321 | { | 321 | { |
| 322 | unsigned long pid; | 322 | unsigned long pid; |
| 323 | unsigned long addr; | 323 | unsigned long addr; |
| 324 | int local = mm_is_core_local(mm); | 324 | int local = mm_is_thread_local(mm); |
| 325 | unsigned long ap = mmu_get_ap(psize); | 325 | unsigned long ap = mmu_get_ap(psize); |
| 326 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); | 326 | int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); |
| 327 | unsigned long page_size = 1UL << mmu_psize_defs[psize].shift; | 327 | unsigned long page_size = 1UL << mmu_psize_defs[psize].shift; |
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index af23d7dfe752..2e5233b60971 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c | |||
| @@ -247,7 +247,9 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, | |||
| 247 | cxl_ctx_get(); | 247 | cxl_ctx_get(); |
| 248 | 248 | ||
| 249 | if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { | 249 | if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { |
| 250 | put_pid(ctx->glpid); | ||
| 250 | put_pid(ctx->pid); | 251 | put_pid(ctx->pid); |
| 252 | ctx->glpid = ctx->pid = NULL; | ||
| 251 | cxl_adapter_context_put(ctx->afu->adapter); | 253 | cxl_adapter_context_put(ctx->afu->adapter); |
| 252 | cxl_ctx_put(); | 254 | cxl_ctx_put(); |
| 253 | goto out; | 255 | goto out; |
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c index d0b421f49b39..77080cc5fa0a 100644 --- a/drivers/misc/cxl/file.c +++ b/drivers/misc/cxl/file.c | |||
| @@ -194,6 +194,16 @@ static long afu_ioctl_start_work(struct cxl_context *ctx, | |||
| 194 | ctx->mmio_err_ff = !!(work.flags & CXL_START_WORK_ERR_FF); | 194 | ctx->mmio_err_ff = !!(work.flags & CXL_START_WORK_ERR_FF); |
| 195 | 195 | ||
| 196 | /* | 196 | /* |
| 197 | * Increment the mapped context count for adapter. This also checks | ||
| 198 | * if adapter_context_lock is taken. | ||
| 199 | */ | ||
| 200 | rc = cxl_adapter_context_get(ctx->afu->adapter); | ||
| 201 | if (rc) { | ||
| 202 | afu_release_irqs(ctx, ctx); | ||
| 203 | goto out; | ||
| 204 | } | ||
| 205 | |||
| 206 | /* | ||
| 197 | * We grab the PID here and not in the file open to allow for the case | 207 | * We grab the PID here and not in the file open to allow for the case |
| 198 | * where a process (master, some daemon, etc) has opened the chardev on | 208 | * where a process (master, some daemon, etc) has opened the chardev on |
| 199 | * behalf of another process, so the AFU's mm gets bound to the process | 209 | * behalf of another process, so the AFU's mm gets bound to the process |
| @@ -205,15 +215,6 @@ static long afu_ioctl_start_work(struct cxl_context *ctx, | |||
| 205 | ctx->pid = get_task_pid(current, PIDTYPE_PID); | 215 | ctx->pid = get_task_pid(current, PIDTYPE_PID); |
| 206 | ctx->glpid = get_task_pid(current->group_leader, PIDTYPE_PID); | 216 | ctx->glpid = get_task_pid(current->group_leader, PIDTYPE_PID); |
| 207 | 217 | ||
| 208 | /* | ||
| 209 | * Increment the mapped context count for adapter. This also checks | ||
| 210 | * if adapter_context_lock is taken. | ||
| 211 | */ | ||
| 212 | rc = cxl_adapter_context_get(ctx->afu->adapter); | ||
| 213 | if (rc) { | ||
| 214 | afu_release_irqs(ctx, ctx); | ||
| 215 | goto out; | ||
| 216 | } | ||
| 217 | 218 | ||
| 218 | trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr); | 219 | trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr); |
| 219 | 220 | ||
| @@ -221,6 +222,9 @@ static long afu_ioctl_start_work(struct cxl_context *ctx, | |||
| 221 | amr))) { | 222 | amr))) { |
| 222 | afu_release_irqs(ctx, ctx); | 223 | afu_release_irqs(ctx, ctx); |
| 223 | cxl_adapter_context_put(ctx->afu->adapter); | 224 | cxl_adapter_context_put(ctx->afu->adapter); |
| 225 | put_pid(ctx->glpid); | ||
| 226 | put_pid(ctx->pid); | ||
| 227 | ctx->glpid = ctx->pid = NULL; | ||
| 224 | goto out; | 228 | goto out; |
| 225 | } | 229 | } |
| 226 | 230 | ||
