habanalabs: increase timeout if working with simulator
authorDalit Ben Zoor <dbenzoor@habana.ai>
Tue, 30 Apr 2019 14:18:51 +0000 (17:18 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Tue, 30 Apr 2019 14:18:51 +0000 (17:18 +0300)
Where there is a spike in the CPU consumption, it may cause
random failures in the C/I since the KMD timeout for CPU
and/or QMAN0 jobs expires and it stops communicating to the simulator.
This commit fixes it by increasing timeout on polling functions
if working with simulator.

Signed-off-by: Dalit Ben Zoor <dbenzoor@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/misc/habanalabs/device.c
drivers/misc/habanalabs/habanalabs.h

index 0e0b9ec71c8027119b95f2f70497db37b2bef040..91a9e47a3482505ca0a77d41a9e74db0fe032286 100644 (file)
@@ -1147,7 +1147,13 @@ int hl_poll_timeout_memory(struct hl_device *hdev, u64 addr,
         * either by the direct access of the device or by another core
         */
        u32 *paddr = (u32 *) (uintptr_t) addr;
-       ktime_t timeout = ktime_add_us(ktime_get(), timeout_us);
+       ktime_t timeout;
+
+       /* timeout should be longer when working with simulator */
+       if (!hdev->pdev)
+               timeout_us *= 10;
+
+       timeout = ktime_add_us(ktime_get(), timeout_us);
 
        might_sleep();
 
index 0da80e8eab42485f3d210ace1307a0688cead932..71243b3199204c9f0bbe387fe8d8fddff929dfdc 100644 (file)
@@ -1042,7 +1042,12 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val);
 
 #define hl_poll_timeout(hdev, addr, val, cond, sleep_us, timeout_us) \
 ({ \
-       ktime_t __timeout = ktime_add_us(ktime_get(), timeout_us); \
+       ktime_t __timeout; \
+       /* timeout should be longer when working with simulator */ \
+       if (hdev->pdev) \
+               __timeout = ktime_add_us(ktime_get(), timeout_us); \
+       else \
+               __timeout = ktime_add_us(ktime_get(), (timeout_us * 10)); \
        might_sleep_if(sleep_us); \
        for (;;) { \
                (val) = RREG32(addr); \