habanalabs: check TPC vector pipe is empty
authorOded Gabbay <oded.gabbay@gmail.com>
Wed, 12 Aug 2020 08:28:13 +0000 (11:28 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Tue, 22 Sep 2020 15:49:50 +0000 (18:49 +0300)
The driver waits for the TPC vector pipe to be empty before checking if the
TPC kernel has finished executing, but the code doesn't validate that the
pipe was indeed empty, it just wait for it without checking the return
value.

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/misc/habanalabs/gaudi/gaudi.c

index 1cf37332a0ff50767bffa62edd3d492f8fa4bedd..a0932261e67cff3a19369c5093526364f36ff429 100644 (file)
@@ -6304,6 +6304,15 @@ static int gaudi_run_tpc_kernel(struct hl_device *hdev, u64 tpc_kernel,
                1000,
                kernel_timeout);
 
+       if (rc) {
+               dev_err(hdev->dev,
+                       "Timeout while waiting for TPC%d vector pipe\n",
+                       tpc_id);
+               hdev->asic_funcs->set_clock_gating(hdev);
+               mutex_unlock(&gaudi->clk_gate_mutex);
+               return -EIO;
+       }
+
        rc = hl_poll_timeout(
                hdev,
                mmTPC0_CFG_WQ_INFLIGHT_CNTR + offset,