diff options
Diffstat (limited to 'drivers/misc/cxl/api.c')
-rw-r--r-- | drivers/misc/cxl/api.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index a0c44d16bf30..7c11bad5cded 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers/misc/cxl/api.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/mount.h> | 16 | #include <linux/mount.h> |
17 | #include <linux/sched/mm.h> | 17 | #include <linux/sched/mm.h> |
18 | #include <linux/mmu_context.h> | ||
18 | 19 | ||
19 | #include "cxl.h" | 20 | #include "cxl.h" |
20 | 21 | ||
@@ -331,9 +332,12 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, | |||
331 | /* ensure this mm_struct can't be freed */ | 332 | /* ensure this mm_struct can't be freed */ |
332 | cxl_context_mm_count_get(ctx); | 333 | cxl_context_mm_count_get(ctx); |
333 | 334 | ||
334 | /* decrement the use count */ | 335 | if (ctx->mm) { |
335 | if (ctx->mm) | 336 | /* decrement the use count from above */ |
336 | mmput(ctx->mm); | 337 | mmput(ctx->mm); |
338 | /* make TLBIs for this context global */ | ||
339 | mm_context_add_copro(ctx->mm); | ||
340 | } | ||
337 | } | 341 | } |
338 | 342 | ||
339 | /* | 343 | /* |
@@ -342,13 +346,19 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed, | |||
342 | */ | 346 | */ |
343 | cxl_ctx_get(); | 347 | cxl_ctx_get(); |
344 | 348 | ||
349 | /* See the comment in afu_ioctl_start_work() */ | ||
350 | smp_mb(); | ||
351 | |||
345 | if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { | 352 | if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { |
346 | put_pid(ctx->pid); | 353 | put_pid(ctx->pid); |
347 | ctx->pid = NULL; | 354 | ctx->pid = NULL; |
348 | cxl_adapter_context_put(ctx->afu->adapter); | 355 | cxl_adapter_context_put(ctx->afu->adapter); |
349 | cxl_ctx_put(); | 356 | cxl_ctx_put(); |
350 | if (task) | 357 | if (task) { |
351 | cxl_context_mm_count_put(ctx); | 358 | cxl_context_mm_count_put(ctx); |
359 | if (ctx->mm) | ||
360 | mm_context_remove_copro(ctx->mm); | ||
361 | } | ||
352 | goto out; | 362 | goto out; |
353 | } | 363 | } |
354 | 364 | ||