]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
accel/habanalabs: increase user interrupt grace time
authorOfir Bitton <obitton@habana.ai>
Wed, 18 Jan 2023 07:46:16 +0000 (09:46 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Wed, 15 Mar 2023 11:29:11 +0000 (13:29 +0200)
Currently we support scenarios where a timestamp registration request
of a certain offset is received during the interrupt handling of the
same offset. In this case we give a grace period of up to 100us for
the interrupt handler to finish.
It seems that sometimes the interrupt handling takes more than expected,
and therefore this path should be optimized. Until that happens, let's
increase the grace period in order not to reach timeout which will
cause user call to be rejected.

Signed-off-by: Ofir Bitton <obitton@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
drivers/accel/habanalabs/common/command_submission.c

index 8270db0a72a26b44bb9c7ee8bee88729559c554e..2b8a027f7d09dfb4297165371f57222241fb461f 100644 (file)
@@ -17,7 +17,7 @@
                        HL_CS_FLAGS_FLUSH_PCI_HBW_WRITES)
 
 
-#define MAX_TS_ITER_NUM 10
+#define MAX_TS_ITER_NUM 100
 
 /**
  * enum hl_cs_wait_status - cs wait status
@@ -3145,6 +3145,7 @@ static int ts_buff_get_kernel_ts_record(struct hl_mmap_mem_buf *buf,
                        (ts_buff->kernel_buff_size / sizeof(struct hl_user_pending_interrupt));
        unsigned long flags, iter_counter = 0;
        u64 current_cq_counter;
+       ktime_t timestamp;
 
        /* Validate ts_offset not exceeding last max */
        if (requested_offset_record >= cb_last) {
@@ -3153,6 +3154,8 @@ static int ts_buff_get_kernel_ts_record(struct hl_mmap_mem_buf *buf,
                return -EINVAL;
        }
 
+       timestamp = ktime_get();
+
 start_over:
        spin_lock_irqsave(wait_list_lock, flags);
 
@@ -3178,11 +3181,12 @@ start_over:
 
                        /* irq handling in the middle give it time to finish */
                        spin_unlock_irqrestore(wait_list_lock, flags);
-                       usleep_range(1, 10);
+                       usleep_range(100, 1000);
                        if (++iter_counter == MAX_TS_ITER_NUM) {
                                dev_err(buf->mmg->dev,
-                                       "handling registration interrupt took too long!!\n");
-                               return -EINVAL;
+                                       "Timestamp offset processing reached timeout of %lld ms\n",
+                                       ktime_ms_delta(ktime_get(), timestamp));
+                               return -EAGAIN;
                        }
 
                        goto start_over;