Skip to content

Commit 95dff48

Browse files
committed
Merge branch 'fixes' into next
Merge our fixes branch from the 4.16 cycle. There were a number of important fixes merged, in particular some Power9 workarounds that we want in next for testing purposes. There's also been some conflicting changes in the CPU features code which are best merged and tested before going upstream.
2 parents c0b3467 + 5239650 commit 95dff48

File tree

21 files changed

+223
-94
lines changed

21 files changed

+223
-94
lines changed

Documentation/accelerators/ocxl.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ OCXL_IOCTL_IRQ_SET_FD:
152152
Associate an event fd to an AFU interrupt so that the user process
153153
can be notified when the AFU sends an interrupt.
154154

155+
OCXL_IOCTL_GET_METADATA:
156+
157+
Obtains configuration information from the card, such at the size of
158+
MMIO areas, the AFU version, and the PASID for the current context.
159+
155160

156161
mmap
157162
----

arch/powerpc/boot/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ $(addprefix $(obj)/,$(zlib-y)): \
101101
libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c
102102
libfdtheader := fdt.h libfdt.h libfdt_internal.h
103103

104-
$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \
104+
$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o \
105+
treeboot-akebono.o treeboot-currituck.o treeboot-iss4xx.o): \
105106
$(addprefix $(obj)/,$(libfdtheader))
106107

107108
src-wlib-y := string.S crt0.S stdio.c decompress.c main.c \

arch/powerpc/include/asm/book3s/64/mmu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ typedef struct {
9797
/* Number of bits in the mm_cpumask */
9898
atomic_t active_cpus;
9999

100+
/* Number of users of the external (Nest) MMU */
101+
atomic_t copros;
102+
100103
/* NPU NMMU context */
101104
struct npu_context *npu_context;
102105

arch/powerpc/include/asm/book3s/64/tlbflush-radix.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ extern void radix__flush_tlb_page_psize(struct mm_struct *mm, unsigned long vmad
4747
#endif
4848
extern void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr);
4949
extern void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr);
50-
extern void radix__flush_tlb_lpid_va(unsigned long lpid, unsigned long gpa,
51-
unsigned long page_size);
52-
extern void radix__flush_tlb_lpid(unsigned long lpid);
5350
extern void radix__flush_tlb_all(void);
5451
extern void radix__flush_tlb_pte_p9_dd1(unsigned long old_pte, struct mm_struct *mm,
5552
unsigned long address);

arch/powerpc/include/asm/cputable.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ static inline void cpu_feature_keys_init(void) { }
215215
#define CPU_FTR_POWER9_DD2_1 LONG_ASM_CONST(0x0000080000000000)
216216
#define CPU_FTR_P9_TM_HV_ASSIST LONG_ASM_CONST(0x0000100000000000)
217217
#define CPU_FTR_P9_TM_XER_SO_BUG LONG_ASM_CONST(0x0000200000000000)
218+
#define CPU_FTR_P9_TLBIE_BUG LONG_ASM_CONST(0x0000400000000000)
218219

219220
#ifndef __ASSEMBLY__
220221

@@ -465,7 +466,8 @@ static inline void cpu_feature_keys_init(void) { }
465466
CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
466467
CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
467468
CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
468-
CPU_FTR_TM_COMP | CPU_FTR_ARCH_300 | CPU_FTR_PKEY)
469+
CPU_FTR_TM_COMP | CPU_FTR_ARCH_300 | CPU_FTR_PKEY | \
470+
CPU_FTR_P9_TLBIE_BUG)
469471
#define CPU_FTRS_POWER9_DD1 ((CPU_FTRS_POWER9 | CPU_FTR_POWER9_DD1) & \
470472
(~CPU_FTR_SAO))
471473
#define CPU_FTRS_POWER9_DD2_0 CPU_FTRS_POWER9

arch/powerpc/include/asm/mmu_context.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,23 @@ static inline void dec_mm_active_cpus(struct mm_struct *mm)
9292
static inline void mm_context_add_copro(struct mm_struct *mm)
9393
{
9494
/*
95-
* On hash, should only be called once over the lifetime of
96-
* the context, as we can't decrement the active cpus count
97-
* and flush properly for the time being.
95+
* If any copro is in use, increment the active CPU count
96+
* in order to force TLB invalidations to be global as to
97+
* propagate to the Nest MMU.
9898
*/
99-
inc_mm_active_cpus(mm);
99+
if (atomic_inc_return(&mm->context.copros) == 1)
100+
inc_mm_active_cpus(mm);
100101
}
101102

102103
static inline void mm_context_remove_copro(struct mm_struct *mm)
103104
{
105+
int c;
106+
107+
c = atomic_dec_if_positive(&mm->context.copros);
108+
109+
/* Detect imbalance between add and remove */
110+
WARN_ON(c < 0);
111+
104112
/*
105113
* Need to broadcast a global flush of the full mm before
106114
* decrementing active_cpus count, as the next TLBI may be
@@ -111,7 +119,7 @@ static inline void mm_context_remove_copro(struct mm_struct *mm)
111119
* for the time being. Invalidations will remain global if
112120
* used on hash.
113121
*/
114-
if (radix_enabled()) {
122+
if (c == 0 && radix_enabled()) {
115123
flush_all_mm(mm);
116124
dec_mm_active_cpus(mm);
117125
}

arch/powerpc/kernel/dt_cpu_ftrs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,10 @@ static __init void cpufeatures_cpu_quirks(void)
714714
cur_cpu_spec->cpu_features |= CPU_FTR_P9_TM_HV_ASSIST |
715715
CPU_FTR_P9_TM_XER_SO_BUG;
716716

717-
if ((version & 0xffff0000) == 0x004e0000)
717+
if ((version & 0xffff0000) == 0x004e0000) {
718718
cur_cpu_spec->cpu_features &= ~(CPU_FTR_DAWR);
719+
cur_cpu_spec->cpu_features |= CPU_FTR_P9_TLBIE_BUG;
720+
}
719721
}
720722

721723
static void __init cpufeatures_setup_finished(void)
@@ -727,6 +729,9 @@ static void __init cpufeatures_setup_finished(void)
727729
cur_cpu_spec->cpu_features |= CPU_FTR_HVMODE;
728730
}
729731

732+
/* Make sure powerpc_base_platform is non-NULL */
733+
powerpc_base_platform = cur_cpu_spec->platform;
734+
730735
system_registers.lpcr = mfspr(SPRN_LPCR);
731736
system_registers.hfscr = mfspr(SPRN_HFSCR);
732737
system_registers.fscr = mfspr(SPRN_FSCR);

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ EXC_COMMON_BEGIN(bad_addr_slb)
706706
ld r3, PACA_EXSLB+EX_DAR(r13)
707707
std r3, _DAR(r1)
708708
beq cr6, 2f
709-
li r10, 0x480 /* fix trap number for I-SLB miss */
709+
li r10, 0x481 /* fix trap number for I-SLB miss */
710710
std r10, _TRAP(r1)
711711
2: bl save_nvgprs
712712
addi r3, r1, STACK_FRAME_OVERHEAD

arch/powerpc/kernel/irq.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,14 @@ void force_external_irq_replay(void)
476476
*/
477477
WARN_ON(!arch_irqs_disabled());
478478

479+
/*
480+
* Interrupts must always be hard disabled before irq_happened is
481+
* modified (to prevent lost update in case of interrupt between
482+
* load and store).
483+
*/
484+
__hard_irq_disable();
485+
local_paca->irq_happened |= PACA_IRQ_HARD_DIS;
486+
479487
/* Indicate in the PACA that we have an interrupt to replay */
480488
local_paca->irq_happened |= PACA_IRQ_EE;
481489
}

arch/powerpc/kernel/prom_init.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,6 @@ struct ibm_arch_vec __cacheline_aligned ibm_architecture_vec = {
874874
.mmu = 0,
875875
.hash_ext = 0,
876876
.radix_ext = 0,
877-
.byte22 = 0,
878877
},
879878

880879
/* option vector 6: IBM PAPR hints */

arch/powerpc/kvm/book3s_64_mmu_radix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ static void kvmppc_radix_tlbie_page(struct kvm *kvm, unsigned long addr,
157157
asm volatile("ptesync": : :"memory");
158158
asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1)
159159
: : "r" (addr), "r" (kvm->arch.lpid) : "memory");
160+
if (cpu_has_feature(CPU_FTR_P9_TLBIE_BUG))
161+
asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1)
162+
: : "r" (addr), "r" (kvm->arch.lpid) : "memory");
160163
asm volatile("ptesync": : :"memory");
161164
}
162165

arch/powerpc/kvm/book3s_hv_rm_mmu.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,17 @@ static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues,
473473
trace_tlbie(kvm->arch.lpid, 0, rbvalues[i],
474474
kvm->arch.lpid, 0, 0, 0);
475475
}
476+
477+
if (cpu_has_feature(CPU_FTR_P9_TLBIE_BUG)) {
478+
/*
479+
* Need the extra ptesync to make sure we don't
480+
* re-order the tlbie
481+
*/
482+
asm volatile("ptesync": : :"memory");
483+
asm volatile(PPC_TLBIE_5(%0,%1,0,0,0) : :
484+
"r" (rbvalues[0]), "r" (kvm->arch.lpid));
485+
}
486+
476487
asm volatile("eieio; tlbsync; ptesync" : : : "memory");
477488
kvm->arch.tlbie_lock = 0;
478489
} else {

arch/powerpc/mm/hash_native_64.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ static inline unsigned long ___tlbie(unsigned long vpn, int psize,
201201
return va;
202202
}
203203

204+
static inline void fixup_tlbie(unsigned long vpn, int psize, int apsize, int ssize)
205+
{
206+
if (cpu_has_feature(CPU_FTR_P9_TLBIE_BUG)) {
207+
/* Need the extra ptesync to ensure we don't reorder tlbie*/
208+
asm volatile("ptesync": : :"memory");
209+
___tlbie(vpn, psize, apsize, ssize);
210+
}
211+
}
212+
204213
static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
205214
{
206215
unsigned long rb;
@@ -278,6 +287,7 @@ static inline void tlbie(unsigned long vpn, int psize, int apsize,
278287
asm volatile("ptesync": : :"memory");
279288
} else {
280289
__tlbie(vpn, psize, apsize, ssize);
290+
fixup_tlbie(vpn, psize, apsize, ssize);
281291
asm volatile("eieio; tlbsync; ptesync": : :"memory");
282292
}
283293
if (lock_tlbie && !use_local)
@@ -771,7 +781,7 @@ static void native_hpte_clear(void)
771781
*/
772782
static void native_flush_hash_range(unsigned long number, int local)
773783
{
774-
unsigned long vpn;
784+
unsigned long vpn = 0;
775785
unsigned long hash, index, hidx, shift, slot;
776786
struct hash_pte *hptep;
777787
unsigned long hpte_v;
@@ -843,6 +853,10 @@ static void native_flush_hash_range(unsigned long number, int local)
843853
__tlbie(vpn, psize, psize, ssize);
844854
} pte_iterate_hashed_end();
845855
}
856+
/*
857+
* Just do one more with the last used values.
858+
*/
859+
fixup_tlbie(vpn, psize, psize, ssize);
846860
asm volatile("eieio; tlbsync; ptesync":::"memory");
847861

848862
if (lock_tlbie)

arch/powerpc/mm/mmu_context_book3s64.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
166166
mm_iommu_init(mm);
167167
#endif
168168
atomic_set(&mm->context.active_cpus, 0);
169+
atomic_set(&mm->context.copros, 0);
169170

170171
return 0;
171172
}

arch/powerpc/mm/pgtable_64.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ void mmu_partition_table_set_entry(unsigned int lpid, unsigned long dw0,
481481
"r" (TLBIEL_INVAL_SET_LPID), "r" (lpid));
482482
trace_tlbie(lpid, 0, TLBIEL_INVAL_SET_LPID, lpid, 2, 0, 0);
483483
}
484+
/* do we need fixup here ?*/
484485
asm volatile("eieio; tlbsync; ptesync" : : : "memory");
485486
}
486487
EXPORT_SYMBOL_GPL(mmu_partition_table_set_entry);

0 commit comments

Comments
 (0)