diff options
author | Oded Gabbay <oded.gabbay@gmail.com> | 2019-11-17 17:41:57 +0200 |
---|---|---|
committer | Oded Gabbay <oded.gabbay@gmail.com> | 2019-11-21 11:35:47 +0200 |
commit | 55f6d680970ea922d4ee23d5ac88d3a8046221fb (patch) | |
tree | e699504b680a0ce9d75ea9d21be4776f6eef98e2 | |
parent | 1af69d30c41d0b0f15d8be80c100cefaa909816c (diff) | |
download | linux-55f6d680970ea922d4ee23d5ac88d3a8046221fb.tar.gz linux-55f6d680970ea922d4ee23d5ac88d3a8046221fb.tar.bz2 linux-55f6d680970ea922d4ee23d5ac88d3a8046221fb.zip |
habanalabs: flush EQ workers in hard reset
During hard-reset, there can be multiple events received from the H/W. For
each event, the driver opens a worker thread to handle it. For some of the
events, the driver will read/write registers in the code that handles the
event.
In case of hard-reset, we must prevent reads/writes to the registers during
the reset operation because the device might get stuck if that happens.
Therefore, flush the EQ workers before resetting the device (in hard-reset
only). Additional events won't arrive as we synced and disabled the
interrupts.
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
-rw-r--r-- | drivers/misc/habanalabs/device.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c index 80205d8584ce..b155e9549076 100644 --- a/drivers/misc/habanalabs/device.c +++ b/drivers/misc/habanalabs/device.c @@ -887,13 +887,19 @@ again: /* Go over all the queues, release all CS and their jobs */ hl_cs_rollback_all(hdev); - /* Kill processes here after CS rollback. This is because the process - * can't really exit until all its CSs are done, which is what we - * do in cs rollback - */ - if (hard_reset) + if (hard_reset) { + /* Kill processes here after CS rollback. This is because the + * process can't really exit until all its CSs are done, which + * is what we do in cs rollback + */ device_kill_open_processes(hdev); + /* Flush the Event queue workers to make sure no other thread is + * reading or writing to registers during the reset + */ + flush_workqueue(hdev->eq_wq); + } + /* Release kernel context */ if ((hard_reset) && (hl_ctx_put(hdev->kernel_ctx) == 1)) hdev->kernel_ctx = NULL; |