Refactor the wait-for-user-interrupt routine to make it more generic for re-use for other user exposed h/w interfaces in future ASICs.
Unified · Split
| @@ -2782,12 +2782,12 @@ static inline unsigned long hl_usecs64_to_jiffies(const u64 usecs) · 2781 unmodified lines | ||
| 2782 | 2782 | |
| 2783 | 2783 | static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, |
| 2784 | 2784 | u64 timeout_us, u64 user_address, |
| 2785 | − u64 target_value, u16 interrupt_offset, | |
| 2785 | + u64 target_value, struct hl_user_interrupt *interrupt, | |
| 2786 | + | |
| 2786 | 2787 | u32 *status, |
| 2787 | 2788 | u64 *timestamp) |
| 2788 | 2789 | { |
| 2789 | 2790 | struct hl_user_pending_interrupt *pend; |
| 2790 | − struct hl_user_interrupt *interrupt; | |
| 2791 | 2791 | unsigned long timeout, flags; |
| 2792 | 2792 | u64 completion_value; |
| 2793 | 2793 | long completion_rc; |
| @@ -2805,11 +2805,6 @@ static int _hl_interrupt_wait_ioctl(struct hl_device *hdev, struct hl_ctx *ctx, · 11 unmodified lines | ||
| 2805 | 2805 | |
| 2806 | 2806 | hl_fence_init(&pend->fence, ULONG_MAX); |
| 2807 | 2807 | |
| 2808 | − if (interrupt_offset == HL_COMMON_USER_INTERRUPT_ID) | |
| 2809 | − interrupt = &hdev->common_user_interrupt; | |
| 2810 | − else | |
| 2811 | − interrupt = &hdev->user_interrupt[interrupt_offset]; | |
| 2812 | − | |
| 2813 | 2808 | /* Add pending user interrupt to relevant list for the interrupt |
| 2814 | 2809 | * handler to monitor |
| 2815 | 2810 | */ |
| @@ -2898,9 +2893,10 @@ remove_pending_user_interrupt: · 82 unmodified lines | ||
| 2898 | 2893 | |
| 2899 | 2894 | static int hl_interrupt_wait_ioctl(struct hl_fpriv *hpriv, void *data) |
| 2900 | 2895 | { |
| 2901 | − u16 interrupt_id, interrupt_offset, first_interrupt, last_interrupt; | |
| 2896 | + u16 interrupt_id, first_interrupt, last_interrupt; | |
| 2902 | 2897 | struct hl_device *hdev = hpriv->hdev; |
| 2903 | 2898 | struct asic_fixed_properties *prop; |
| 2899 | + struct hl_user_interrupt *interrupt; | |
| 2904 | 2900 | union hl_wait_cs_args *args = data; |
| 2905 | 2901 | u32 status = HL_WAIT_CS_STATUS_BUSY; |
| 2906 | 2902 | u64 timestamp; |
| @@ -2913,8 +2909,7 @@ static int hl_interrupt_wait_ioctl(struct hl_fpriv *hpriv, void *data) · 6 unmodified lines | ||
| 2913 | 2909 | return -EPERM; |
| 2914 | 2910 | } |
| 2915 | 2911 | |
| 2916 | − interrupt_id = | |
| 2917 | − FIELD_GET(HL_WAIT_CS_FLAGS_INTERRUPT_MASK, args->in.flags); | |
| 2912 | + interrupt_id = FIELD_GET(HL_WAIT_CS_FLAGS_INTERRUPT_MASK, args->in.flags); | |
| 2918 | 2913 | |
| 2919 | 2914 | first_interrupt = prop->first_available_user_msix_interrupt; |
| 2920 | 2915 | last_interrupt = prop->first_available_user_msix_interrupt + |
| @@ -2927,15 +2922,14 @@ static int hl_interrupt_wait_ioctl(struct hl_fpriv *hpriv, void *data) · 6 unmodified lines | ||
| 2927 | 2922 | } |
| 2928 | 2923 | |
| 2929 | 2924 | if (interrupt_id == HL_COMMON_USER_INTERRUPT_ID) |
| 2930 | − interrupt_offset = HL_COMMON_USER_INTERRUPT_ID; | |
| 2925 | + interrupt = &hdev->common_user_interrupt; | |
| 2931 | 2926 | else |
| 2932 | − interrupt_offset = interrupt_id - first_interrupt; | |
| 2927 | + interrupt = &hdev->user_interrupt[interrupt_id - first_interrupt]; | |
| 2933 | 2928 | |
| 2934 | 2929 | rc = _hl_interrupt_wait_ioctl(hdev, hpriv->ctx, |
| 2935 | 2930 | args->in.interrupt_timeout_us, args->in.addr, |
| 2936 | − args->in.target, interrupt_offset, &status, | |
| 2931 | + args->in.target, interrupt, &status, | |
| 2937 | 2932 | ×tamp); |
| 2938 | − | |
| 2939 | 2933 | if (rc) { |
| 2940 | 2934 | if (rc != -EINTR) |
| 2941 | 2935 | dev_err_ratelimited(hdev->dev, |