aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/cxl/file.c')
-rw-r--r--drivers/misc/cxl/file.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index e9f2f10dbb37..2364bcadb9a9 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -23,6 +23,7 @@
23#include <asm/copro.h> 23#include <asm/copro.h>
24 24
25#include "cxl.h" 25#include "cxl.h"
26#include "trace.h"
26 27
27#define CXL_NUM_MINORS 256 /* Total to reserve */ 28#define CXL_NUM_MINORS 256 /* Total to reserve */
28#define CXL_DEV_MINORS 13 /* 1 control + 4 AFUs * 3 (dedicated/master/shared) */ 29#define CXL_DEV_MINORS 13 /* 1 control + 4 AFUs * 3 (dedicated/master/shared) */
@@ -140,18 +141,20 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
140 141
141 pr_devel("%s: pe: %i\n", __func__, ctx->pe); 142 pr_devel("%s: pe: %i\n", __func__, ctx->pe);
142 143
143 mutex_lock(&ctx->status_mutex); 144 /* Do this outside the status_mutex to avoid a circular dependency with
144 if (ctx->status != OPENED) { 145 * the locking in cxl_mmap_fault() */
145 rc = -EIO;
146 goto out;
147 }
148
149 if (copy_from_user(&work, uwork, 146 if (copy_from_user(&work, uwork,
150 sizeof(struct cxl_ioctl_start_work))) { 147 sizeof(struct cxl_ioctl_start_work))) {
151 rc = -EFAULT; 148 rc = -EFAULT;
152 goto out; 149 goto out;
153 } 150 }
154 151
152 mutex_lock(&ctx->status_mutex);
153 if (ctx->status != OPENED) {
154 rc = -EIO;
155 goto out;
156 }
157
155 /* 158 /*
156 * if any of the reserved fields are set or any of the unused 159 * if any of the reserved fields are set or any of the unused
157 * flags are set it's invalid 160 * flags are set it's invalid
@@ -184,9 +187,13 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
184 */ 187 */
185 ctx->pid = get_pid(get_task_pid(current, PIDTYPE_PID)); 188 ctx->pid = get_pid(get_task_pid(current, PIDTYPE_PID));
186 189
190 trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr);
191
187 if ((rc = cxl_attach_process(ctx, false, work.work_element_descriptor, 192 if ((rc = cxl_attach_process(ctx, false, work.work_element_descriptor,
188 amr))) 193 amr))) {
194 afu_release_irqs(ctx);
189 goto out; 195 goto out;
196 }
190 197
191 ctx->status = STARTED; 198 ctx->status = STARTED;
192 rc = 0; 199 rc = 0;