diff options
| author | Ian Munsie <imunsie@au1.ibm.com> | 2014-12-08 03:17:56 -0500 |
|---|---|---|
| committer | Michael Ellerman <mpe@ellerman.id.au> | 2014-12-11 21:06:47 -0500 |
| commit | a98e6e9f4e0224d85b4d951edc44af16dfe6094a (patch) | |
| tree | 9278fae691319e781d42d0278038786da3e449df /drivers/misc | |
| parent | ee41d11d53c8fc4968f0816504651541d606cf40 (diff) | |
cxl: Add timeout to process element commands
In the event that something goes wrong in the hardware and it is unable
to complete a process element comment we would end up polling forever,
effectively making the associated process unkillable.
This patch adds a timeout to the process element command code path, so
that we will give up if the hardware does not respond in a reasonable
time.
Cc: stable@vger.kernel.org
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc')
| -rw-r--r-- | drivers/misc/cxl/native.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c index 1001cf49af94..f2b37b41a0da 100644 --- a/drivers/misc/cxl/native.c +++ b/drivers/misc/cxl/native.c | |||
| @@ -277,6 +277,7 @@ static int do_process_element_cmd(struct cxl_context *ctx, | |||
| 277 | u64 cmd, u64 pe_state) | 277 | u64 cmd, u64 pe_state) |
| 278 | { | 278 | { |
| 279 | u64 state; | 279 | u64 state; |
| 280 | unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT); | ||
| 280 | 281 | ||
| 281 | WARN_ON(!ctx->afu->enabled); | 282 | WARN_ON(!ctx->afu->enabled); |
| 282 | 283 | ||
| @@ -286,6 +287,10 @@ static int do_process_element_cmd(struct cxl_context *ctx, | |||
| 286 | smp_mb(); | 287 | smp_mb(); |
| 287 | cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe); | 288 | cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe); |
| 288 | while (1) { | 289 | while (1) { |
| 290 | if (time_after_eq(jiffies, timeout)) { | ||
| 291 | dev_warn(&ctx->afu->dev, "WARNING: Process Element Command timed out!\n"); | ||
| 292 | return -EBUSY; | ||
| 293 | } | ||
| 289 | state = be64_to_cpup(ctx->afu->sw_command_status); | 294 | state = be64_to_cpup(ctx->afu->sw_command_status); |
| 290 | if (state == ~0ULL) { | 295 | if (state == ~0ULL) { |
| 291 | pr_err("cxl: Error adding process element to AFU\n"); | 296 | pr_err("cxl: Error adding process element to AFU\n"); |
