@@ -2740,14 +2740,10 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
2740
2740
else
2741
2741
interrupt = & hdev -> user_interrupt [interrupt_offset ];
2742
2742
2743
- spin_lock_irqsave (& interrupt -> wait_list_lock , flags );
2744
-
2745
- if (copy_from_user (& completion_value , u64_to_user_ptr (user_address ),
2746
- 4 )) {
2747
- dev_err (hdev -> dev ,
2748
- "Failed to copy completion value from user\n" );
2743
+ if (copy_from_user (& completion_value , u64_to_user_ptr (user_address ), 4 )) {
2744
+ dev_err (hdev -> dev , "Failed to copy completion value from user\n" );
2749
2745
rc = - EFAULT ;
2750
- goto unlock_and_free_fence ;
2746
+ goto free_fence ;
2751
2747
}
2752
2748
2753
2749
if (completion_value >= target_value )
@@ -2756,42 +2752,35 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
2756
2752
* status = CS_WAIT_STATUS_BUSY ;
2757
2753
2758
2754
if (!timeout_us || (* status == CS_WAIT_STATUS_COMPLETED ))
2759
- goto unlock_and_free_fence ;
2755
+ goto free_fence ;
2760
2756
2761
2757
/* Add pending user interrupt to relevant list for the interrupt
2762
2758
* handler to monitor
2763
2759
*/
2760
+ spin_lock_irqsave (& interrupt -> wait_list_lock , flags );
2764
2761
list_add_tail (& pend -> wait_list_node , & interrupt -> wait_list_head );
2765
2762
spin_unlock_irqrestore (& interrupt -> wait_list_lock , flags );
2766
2763
2767
2764
wait_again :
2768
2765
/* Wait for interrupt handler to signal completion */
2769
- completion_rc =
2770
- wait_for_completion_interruptible_timeout (
2771
- & pend -> fence .completion , timeout );
2766
+ completion_rc = wait_for_completion_interruptible_timeout (& pend -> fence .completion ,
2767
+ timeout );
2772
2768
2773
2769
/* If timeout did not expire we need to perform the comparison.
2774
2770
* If comparison fails, keep waiting until timeout expires
2775
2771
*/
2776
2772
if (completion_rc > 0 ) {
2777
- spin_lock_irqsave (& interrupt -> wait_list_lock , flags );
2778
-
2779
- if (copy_from_user (& completion_value ,
2780
- u64_to_user_ptr (user_address ), 4 )) {
2781
-
2782
- spin_unlock_irqrestore (& interrupt -> wait_list_lock , flags );
2783
-
2784
- dev_err (hdev -> dev ,
2785
- "Failed to copy completion value from user\n" );
2773
+ if (copy_from_user (& completion_value , u64_to_user_ptr (user_address ), 4 )) {
2774
+ dev_err (hdev -> dev , "Failed to copy completion value from user\n" );
2786
2775
rc = - EFAULT ;
2787
2776
2788
2777
goto remove_pending_user_interrupt ;
2789
2778
}
2790
2779
2791
2780
if (completion_value >= target_value ) {
2792
- spin_unlock_irqrestore (& interrupt -> wait_list_lock , flags );
2793
2781
* status = CS_WAIT_STATUS_COMPLETED ;
2794
2782
} else {
2783
+ spin_lock_irqsave (& interrupt -> wait_list_lock , flags );
2795
2784
reinit_completion (& pend -> fence .completion );
2796
2785
timeout = completion_rc ;
2797
2786
@@ -2811,9 +2800,9 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx,
2811
2800
remove_pending_user_interrupt :
2812
2801
spin_lock_irqsave (& interrupt -> wait_list_lock , flags );
2813
2802
list_del (& pend -> wait_list_node );
2814
-
2815
- unlock_and_free_fence :
2816
2803
spin_unlock_irqrestore (& interrupt -> wait_list_lock , flags );
2804
+
2805
+ free_fence :
2817
2806
kfree (pend );
2818
2807
hl_ctx_put (ctx );
2819
2808
0 commit comments