Commit a98e6e9f authored by Ian Munsie's avatar Ian Munsie Committed by Michael Ellerman

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: default avatarIan Munsie <imunsie@au1.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent ee41d11d
...@@ -277,6 +277,7 @@ static int do_process_element_cmd(struct cxl_context *ctx, ...@@ -277,6 +277,7 @@ static int do_process_element_cmd(struct cxl_context *ctx,
u64 cmd, u64 pe_state) u64 cmd, u64 pe_state)
{ {
u64 state; u64 state;
unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT);
WARN_ON(!ctx->afu->enabled); WARN_ON(!ctx->afu->enabled);
...@@ -286,6 +287,10 @@ static int do_process_element_cmd(struct cxl_context *ctx, ...@@ -286,6 +287,10 @@ static int do_process_element_cmd(struct cxl_context *ctx,
smp_mb(); smp_mb();
cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe); cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe);
while (1) { while (1) {
if (time_after_eq(jiffies, timeout)) {
dev_warn(&ctx->afu->dev, "WARNING: Process Element Command timed out!\n");
return -EBUSY;
}
state = be64_to_cpup(ctx->afu->sw_command_status); state = be64_to_cpup(ctx->afu->sw_command_status);
if (state == ~0ULL) { if (state == ~0ULL) {
pr_err("cxl: Error adding process element to AFU\n"); pr_err("cxl: Error adding process element to AFU\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment