Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54820530 authored by Michael Ellerman's avatar Michael Ellerman
Browse files

powerpc/powernv: Enable TM without suspend if possible



Some Power9 revisions can run in a mode where TM operates without
suspended state. If we find ourself on a CPU that might be in this
mode, we query OPAL to check, and if so we reenable TM in CPU
features, and enable a new user feature to signal to userspace that we
are in this mode.

We do not enable the "normal" user feature, PPC_FEATURE2_HTM, but we
do enable PPC_FEATURE2_HTM_NOSC because that indicates to userspace
that the kernel will abort transactions on syscall entry, which is
true regardless of the suspend mode.

Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent cba6ac48
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -896,6 +896,8 @@ enum {
	 */
	OPAL_REINIT_CPUS_MMU_HASH	= (1 << 2),
	OPAL_REINIT_CPUS_MMU_RADIX	= (1 << 3),

	OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED = (1 << 4),
};

typedef struct oppanel_line {
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ extern void pnv_npu2_destroy_context(struct npu_context *context,
extern int pnv_npu2_handle_fault(struct npu_context *context, uintptr_t *ea,
				unsigned long *flags, unsigned long *status,
				int count);

void pnv_tm_init(void);
#else
static inline void powernv_set_nmmu_ptcr(unsigned long ptcr) { }
static inline struct npu_context *pnv_npu2_init_context(struct pci_dev *gpdev,
@@ -36,6 +38,8 @@ static inline int pnv_npu2_handle_fault(struct npu_context *context,
					unsigned long *status, int count) {
	return -ENODEV;
}

static inline void pnv_tm_init(void) { }
#endif

#endif /* _ASM_POWERNV_H */
+2 −0
Original line number Diff line number Diff line
@@ -19,4 +19,6 @@ extern void tm_abort(uint8_t cause);
extern void tm_save_sprs(struct thread_struct *thread);
extern void tm_restore_sprs(struct thread_struct *thread);

extern bool tm_suspend_disabled;

#endif /* __ASSEMBLY__ */
+7 −0
Original line number Diff line number Diff line
@@ -77,6 +77,13 @@
extern unsigned long _get_SP(void);

#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
/*
 * Are we running in "Suspend disabled" mode? If so we have to block any
 * sigreturn that would get us into suspended state, and we also warn in some
 * other paths that we should never reach with suspend disabled.
 */
bool tm_suspend_disabled __ro_after_init = false;

static void check_if_tm_restore_required(struct task_struct *tsk)
{
	/*
+4 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include <asm/mmu.h>
#include <asm/paca.h>
#include <asm/pgtable.h>
#include <asm/powernv.h>
#include <asm/iommu.h>
#include <asm/btext.h>
#include <asm/sections.h>
@@ -681,7 +682,10 @@ static void __init tm_init(void)
		cur_cpu_spec->cpu_user_features2 &=
			~(PPC_FEATURE2_HTM_NOSC | PPC_FEATURE2_HTM);
		cur_cpu_spec->cpu_features &= ~CPU_FTR_TM;
		return;
	}

	pnv_tm_init();
}
#else
static void tm_init(void) { }
Loading