cxl: Enable global TLBIs for cxl contexts
The PSL and nMMU need to see all TLB invalidations for the memory
contexts used on the adapter. For the hash memory model, it is done by
making all TLBIs global as soon as the cxl driver is in use. For
radix, we need something similar, but we can refine and only convert
to global the invalidations for contexts actually used by the device.
The new mm_context_add_copro() API increments the 'active_cpus' count
for the contexts attached to the cxl adapter. As soon as there's more
than 1 active cpu, the TLBIs for the context become global. Active cpu
count must be decremented when detaching to restore locality if
possible and to avoid overflowing the counter.
The hash memory model support is somewhat limited, as we can't
decrement the active cpus count when mm_context_remove_copro() is
called, because we can't flush the TLB for a mm on hash. So TLBIs
remain global on hash.
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Fixes: f24be42aab ("cxl: Add psl9 specific code")
Tested-by: Alistair Popple <alistair@popple.id.au>
[mpe: Fold in updated comment on the barrier from Fred]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
committed by
Michael Ellerman
parent
6110236b9b
commit
03b8abedf4
@@ -15,6 +15,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/mount.h>
|
||||
#include <linux/sched/mm.h>
|
||||
#include <linux/mmu_context.h>
|
||||
|
||||
#include "cxl.h"
|
||||
|
||||
@@ -331,9 +332,12 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,
|
||||
/* ensure this mm_struct can't be freed */
|
||||
cxl_context_mm_count_get(ctx);
|
||||
|
||||
/* decrement the use count */
|
||||
if (ctx->mm)
|
||||
if (ctx->mm) {
|
||||
/* decrement the use count from above */
|
||||
mmput(ctx->mm);
|
||||
/* make TLBIs for this context global */
|
||||
mm_context_add_copro(ctx->mm);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -342,13 +346,19 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,
|
||||
*/
|
||||
cxl_ctx_get();
|
||||
|
||||
/* See the comment in afu_ioctl_start_work() */
|
||||
smp_mb();
|
||||
|
||||
if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) {
|
||||
put_pid(ctx->pid);
|
||||
ctx->pid = NULL;
|
||||
cxl_adapter_context_put(ctx->afu->adapter);
|
||||
cxl_ctx_put();
|
||||
if (task)
|
||||
if (task) {
|
||||
cxl_context_mm_count_put(ctx);
|
||||
if (ctx->mm)
|
||||
mm_context_remove_copro(ctx->mm);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user