Skip to content

Commit 3db65db

Browse files
Ian Munsiegregkh
authored andcommitted
cxl: Add timeout to process element commands
commit a98e6e9 upstream. 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. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d4a26d1 commit 3db65db

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎drivers/misc/cxl/native.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ static int do_process_element_cmd(struct cxl_context *ctx,
277277
u64 cmd, u64 pe_state)
278278
{
279279
u64 state;
280+
unsigned long timeout = jiffies + (HZ * CXL_TIMEOUT);
280281

281282
WARN_ON(!ctx->afu->enabled);
282283

@@ -286,6 +287,10 @@ static int do_process_element_cmd(struct cxl_context *ctx,
286287
smp_mb();
287288
cxl_p1n_write(ctx->afu, CXL_PSL_LLCMD_An, cmd | ctx->pe);
288289
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+
}
289294
state = be64_to_cpup(ctx->afu->sw_command_status);
290295
if (state == ~0ULL) {
291296
pr_err("cxl: Error adding process element to AFU\n");

0 commit comments

Comments
 (0)