In order to allow TPC engines to raise an assert, we must expose the relevant MSIX interrupt to the user so he will configure the engine correctly. In addition, we implement the corresponding interrupt handler that will notify the user upon such an event.
Unified · Split
| @@ -665,6 +665,7 @@ struct hl_hints_range { · 664 unmodified lines | |||
| 665 | * @first_available_cq: first available CQ for the user. | 665 | * @first_available_cq: first available CQ for the user. |
| 666 | * @user_interrupt_count: number of user interrupts. | 666 | * @user_interrupt_count: number of user interrupts. |
| 667 | * @user_dec_intr_count: number of decoder interrupts exposed to user. | 667 | * @user_dec_intr_count: number of decoder interrupts exposed to user. |
| 668 | * @tpc_interrupt_id: interrupt id for TPC to use in order to raise events towards the host. | ||
| 668 | * @cache_line_size: device cache line size. | 669 | * @cache_line_size: device cache line size. |
| 669 | * @server_type: Server type that the ASIC is currently installed in. | 670 | * @server_type: Server type that the ASIC is currently installed in. |
| 670 | * The value is according to enum hl_server_type in uapi file. | 671 | * The value is according to enum hl_server_type in uapi file. |
| @@ -791,6 +792,7 @@ struct asic_fixed_properties { · 120 unmodified lines | |||
| 791 | u16 first_available_cq[HL_MAX_DCORES]; | 792 | u16 first_available_cq[HL_MAX_DCORES]; |
| 792 | u16 user_interrupt_count; | 793 | u16 user_interrupt_count; |
| 793 | u16 user_dec_intr_count; | 794 | u16 user_dec_intr_count; |
| 795 | u16 tpc_interrupt_id; | ||
| 794 | u16 cache_line_size; | 796 | u16 cache_line_size; |
| 795 | u16 server_type; | 797 | u16 server_type; |
| 796 | u8 completion_queues_count; | 798 | u8 completion_queues_count; |
| @@ -1099,6 +1101,7 @@ struct hl_cq { · 302 unmodified lines | |||
| 1099 | enum hl_user_interrupt_type { | 1101 | enum hl_user_interrupt_type { |
| 1100 | HL_USR_INTERRUPT_CQ = 0, | 1102 | HL_USR_INTERRUPT_CQ = 0, |
| 1101 | HL_USR_INTERRUPT_DECODER, | 1103 | HL_USR_INTERRUPT_DECODER, |
| 1104 | HL_USR_INTERRUPT_TPC | ||
| 1102 | }; | 1105 | }; |
| 1103 | 1106 | ||
| 1104 | /** | 1107 | /** |
| @@ -3148,6 +3151,7 @@ struct hl_reset_info { · 2043 unmodified lines | |||
| 3148 | * @user_interrupt: array of hl_user_interrupt. upon the corresponding user | 3151 | * @user_interrupt: array of hl_user_interrupt. upon the corresponding user |
| 3149 | * interrupt, driver will monitor the list of fences | 3152 | * interrupt, driver will monitor the list of fences |
| 3150 | * registered to this interrupt. | 3153 | * registered to this interrupt. |
| 3154 | * @tpc_interrupt: single TPC interrupt for all TPCs. | ||
| 3151 | * @common_user_cq_interrupt: common user CQ interrupt for all user CQ interrupts. | 3155 | * @common_user_cq_interrupt: common user CQ interrupt for all user CQ interrupts. |
| 3152 | * upon any user CQ interrupt, driver will monitor the | 3156 | * upon any user CQ interrupt, driver will monitor the |
| 3153 | * list of fences registered to this common structure. | 3157 | * list of fences registered to this common structure. |
| @@ -3332,6 +3336,7 @@ struct hl_device { · 178 unmodified lines | |||
| 3332 | enum hl_asic_type asic_type; | 3336 | enum hl_asic_type asic_type; |
| 3333 | struct hl_cq *completion_queue; | 3337 | struct hl_cq *completion_queue; |
| 3334 | struct hl_user_interrupt *user_interrupt; | 3338 | struct hl_user_interrupt *user_interrupt; |
| 3339 | struct hl_user_interrupt tpc_interrupt; | ||
| 3335 | struct hl_user_interrupt common_user_cq_interrupt; | 3340 | struct hl_user_interrupt common_user_cq_interrupt; |
| 3336 | struct hl_user_interrupt common_decoder_interrupt; | 3341 | struct hl_user_interrupt common_decoder_interrupt; |
| 3337 | struct hl_cs **shadow_cs_queue; | 3342 | struct hl_cs **shadow_cs_queue; |
| @@ -102,6 +102,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args) · 101 unmodified lines | |||
| 102 | hw_ip.mme_master_slave_mode = prop->mme_master_slave_mode; | 102 | hw_ip.mme_master_slave_mode = prop->mme_master_slave_mode; |
| 103 | hw_ip.first_available_interrupt_id = prop->first_available_user_interrupt; | 103 | hw_ip.first_available_interrupt_id = prop->first_available_user_interrupt; |
| 104 | hw_ip.number_of_user_interrupts = prop->user_interrupt_count; | 104 | hw_ip.number_of_user_interrupts = prop->user_interrupt_count; |
| 105 | hw_ip.tpc_interrupt_id = prop->tpc_interrupt_id; | ||
| 105 | 106 | ||
| 106 | hw_ip.edma_enabled_mask = prop->edma_enabled_mask; | 107 | hw_ip.edma_enabled_mask = prop->edma_enabled_mask; |
| 107 | hw_ip.server_type = prop->server_type; | 108 | hw_ip.server_type = prop->server_type; |
| @@ -325,6 +325,21 @@ static void handle_user_interrupt(struct hl_device *hdev, struct hl_user_interru · 324 unmodified lines | |||
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | static void handle_tpc_interrupt(struct hl_device *hdev) | ||
| 329 | { | ||
| 330 | u64 event_mask; | ||
| 331 | u32 flags; | ||
| 332 | |||
| 333 | event_mask = HL_NOTIFIER_EVENT_TPC_ASSERT | | ||
| 334 | HL_NOTIFIER_EVENT_USER_ENGINE_ERR | | ||
| 335 | HL_NOTIFIER_EVENT_DEVICE_RESET; | ||
| 336 | |||
| 337 | flags = HL_DRV_RESET_DELAY; | ||
| 338 | |||
| 339 | dev_err_ratelimited(hdev->dev, "Received TPC assert\n"); | ||
| 340 | hl_device_cond_reset(hdev, flags, event_mask); | ||
| 341 | } | ||
| 342 | |||
| 328 | /** | 343 | /** |
| 329 | * hl_irq_handler_user_interrupt - irq handler for user interrupts | 344 | * hl_irq_handler_user_interrupt - irq handler for user interrupts |
| 330 | * | 345 | * |
| @@ -367,6 +382,9 @@ irqreturn_t hl_irq_user_interrupt_thread_handler(int irq, void *arg) · 36 unmodified lines | |||
| 367 | /* Handle decoder interrupt registered on this specific irq */ | 382 | /* Handle decoder interrupt registered on this specific irq */ |
| 368 | handle_user_interrupt(hdev, user_int); | 383 | handle_user_interrupt(hdev, user_int); |
| 369 | break; | 384 | break; |
| 385 | case HL_USR_INTERRUPT_TPC: | ||
| 386 | handle_tpc_interrupt(hdev); | ||
| 387 | break; | ||
| 370 | default: | 388 | default: |
| 371 | break; | 389 | break; |
| 372 | } | 390 | } |
| @@ -679,6 +679,7 @@ static int gaudi_set_fixed_properties(struct hl_device *hdev) · 678 unmodified lines | |||
| 679 | (num_sync_stream_queues * HL_RSVD_MONS); | 679 | (num_sync_stream_queues * HL_RSVD_MONS); |
| 680 | 680 | ||
| 681 | prop->first_available_user_interrupt = USHRT_MAX; | 681 | prop->first_available_user_interrupt = USHRT_MAX; |
| 682 | prop->tpc_interrupt_id = USHRT_MAX; | ||
| 682 | 683 | ||
| 683 | for (i = 0 ; i < HL_MAX_DCORES ; i++) | 684 | for (i = 0 ; i < HL_MAX_DCORES ; i++) |
| 684 | prop->first_available_cq[i] = USHRT_MAX; | 685 | prop->first_available_cq[i] = USHRT_MAX; |
| @@ -2348,6 +2348,7 @@ static int gaudi2_set_fixed_properties(struct hl_device *hdev) · 2347 unmodified lines | |||
| 2348 | (num_sync_stream_queues * HL_RSVD_MONS); | 2348 | (num_sync_stream_queues * HL_RSVD_MONS); |
| 2349 | 2349 | ||
| 2350 | prop->first_available_user_interrupt = GAUDI2_IRQ_NUM_USER_FIRST; | 2350 | prop->first_available_user_interrupt = GAUDI2_IRQ_NUM_USER_FIRST; |
| 2351 | prop->tpc_interrupt_id = GAUDI2_IRQ_NUM_TPC_ASSERT; | ||
| 2351 | 2352 | ||
| 2352 | prop->first_available_cq[0] = GAUDI2_RESERVED_CQ_NUMBER; | 2353 | prop->first_available_cq[0] = GAUDI2_RESERVED_CQ_NUMBER; |
| 2353 | 2354 | ||
| @@ -3235,6 +3236,9 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev) · 881 unmodified lines | |||
| 3235 | struct asic_fixed_properties *prop = &hdev->asic_prop; | 3236 | struct asic_fixed_properties *prop = &hdev->asic_prop; |
| 3236 | int i, j, k; | 3237 | int i, j, k; |
| 3237 | 3238 | ||
| 3239 | /* Initialize TPC interrupt */ | ||
| 3240 | HL_USR_INTR_STRUCT_INIT(hdev->tpc_interrupt, hdev, 0, HL_USR_INTERRUPT_TPC); | ||
| 3241 | |||
| 3238 | /* Initialize common user CQ interrupt */ | 3242 | /* Initialize common user CQ interrupt */ |
| 3239 | HL_USR_INTR_STRUCT_INIT(hdev->common_user_cq_interrupt, hdev, | 3243 | HL_USR_INTR_STRUCT_INIT(hdev->common_user_cq_interrupt, hdev, |
| 3240 | HL_COMMON_USER_CQ_INTERRUPT_ID, HL_USR_INTERRUPT_CQ); | 3244 | HL_COMMON_USER_CQ_INTERRUPT_ID, HL_USR_INTERRUPT_CQ); |
| @@ -3892,6 +3896,8 @@ static const char *gaudi2_irq_name(u16 irq_number) · 651 unmodified lines | |||
| 3892 | return "gaudi2 completion"; | 3896 | return "gaudi2 completion"; |
| 3893 | case GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM ... GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM: | 3897 | case GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM ... GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM: |
| 3894 | return gaudi2_vdec_irq_name[irq_number - GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM]; | 3898 | return gaudi2_vdec_irq_name[irq_number - GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM]; |
| 3899 | case GAUDI2_IRQ_NUM_TPC_ASSERT: | ||
| 3900 | return "gaudi2 tpc assert"; | ||
| 3895 | case GAUDI2_IRQ_NUM_USER_FIRST ... GAUDI2_IRQ_NUM_USER_LAST: | 3901 | case GAUDI2_IRQ_NUM_USER_FIRST ... GAUDI2_IRQ_NUM_USER_LAST: |
| 3896 | return "gaudi2 user completion"; | 3902 | return "gaudi2 user completion"; |
| 3897 | default: | 3903 | default: |
| @@ -4004,6 +4010,15 @@ static int gaudi2_enable_msix(struct hl_device *hdev) · 106 unmodified lines | |||
| 4004 | goto free_event_irq; | 4010 | goto free_event_irq; |
| 4005 | } | 4011 | } |
| 4006 | 4012 | ||
| 4013 | irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_TPC_ASSERT); | ||
| 4014 | rc = request_threaded_irq(irq, hl_irq_handler_user_interrupt, | ||
| 4015 | hl_irq_user_interrupt_thread_handler, IRQF_ONESHOT, | ||
| 4016 | gaudi2_irq_name(GAUDI2_IRQ_NUM_TPC_ASSERT), &hdev->tpc_interrupt); | ||
| 4017 | if (rc) { | ||
| 4018 | dev_err(hdev->dev, "Failed to request IRQ %d", irq); | ||
| 4019 | goto free_dec_irq; | ||
| 4020 | } | ||
| 4021 | |||
| 4007 | for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = prop->user_dec_intr_count, user_irq_init_cnt = 0; | 4022 | for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = prop->user_dec_intr_count, user_irq_init_cnt = 0; |
| 4008 | user_irq_init_cnt < prop->user_interrupt_count; | 4023 | user_irq_init_cnt < prop->user_interrupt_count; |
| 4009 | i++, j++, user_irq_init_cnt++) { | 4024 | i++, j++, user_irq_init_cnt++) { |
| @@ -4031,9 +4046,8 @@ free_user_irq: · 21 unmodified lines | |||
| 4031 | irq = pci_irq_vector(hdev->pdev, i); | 4046 | irq = pci_irq_vector(hdev->pdev, i); |
| 4032 | free_irq(irq, &hdev->user_interrupt[j]); | 4047 | free_irq(irq, &hdev->user_interrupt[j]); |
| 4033 | } | 4048 | } |
| 4034 | 4049 | free_dec_irq: | |
| 4035 | gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM + 1); | 4050 | gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_DEC_LAST + 1); |
| 4036 | |||
| 4037 | free_event_irq: | 4051 | free_event_irq: |
| 4038 | irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_EVENT_QUEUE); | 4052 | irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_EVENT_QUEUE); |
| 4039 | free_irq(irq, cq); | 4053 | free_irq(irq, cq); |
| @@ -4065,6 +4079,8 @@ static void gaudi2_sync_irqs(struct hl_device *hdev) · 25 unmodified lines | |||
| 4065 | synchronize_irq(irq); | 4079 | synchronize_irq(irq); |
| 4066 | } | 4080 | } |
| 4067 | 4081 | ||
| 4082 | synchronize_irq(pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_TPC_ASSERT)); | ||
| 4083 | |||
| 4068 | for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = 0 ; j < hdev->asic_prop.user_interrupt_count; | 4084 | for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = 0 ; j < hdev->asic_prop.user_interrupt_count; |
| 4069 | i++, j++) { | 4085 | i++, j++) { |
| 4070 | irq = pci_irq_vector(hdev->pdev, i); | 4086 | irq = pci_irq_vector(hdev->pdev, i); |
| @@ -4091,6 +4107,9 @@ static void gaudi2_disable_msix(struct hl_device *hdev) · 20 unmodified lines | |||
| 4091 | 4107 | ||
| 4092 | gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM + 1); | 4108 | gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM + 1); |
| 4093 | 4109 | ||
| 4110 | irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_TPC_ASSERT); | ||
| 4111 | free_irq(irq, &hdev->tpc_interrupt); | ||
| 4112 | |||
| 4094 | for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = prop->user_dec_intr_count, k = 0; | 4113 | for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = prop->user_dec_intr_count, k = 0; |
| 4095 | k < hdev->asic_prop.user_interrupt_count ; i++, j++, k++) { | 4114 | k < hdev->asic_prop.user_interrupt_count ; i++, j++, k++) { |
| 4096 | 4115 | ||
| @@ -410,9 +410,11 @@ enum gaudi2_irq_num { · 409 unmodified lines | |||
| 410 | GAUDI2_IRQ_NUM_SHARED_DEC0_ABNRM, | 410 | GAUDI2_IRQ_NUM_SHARED_DEC0_ABNRM, |
| 411 | GAUDI2_IRQ_NUM_SHARED_DEC1_NRM, | 411 | GAUDI2_IRQ_NUM_SHARED_DEC1_NRM, |
| 412 | GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM, | 412 | GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM, |
| 413 | GAUDI2_IRQ_NUM_DEC_LAST = GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM, | ||
| 413 | GAUDI2_IRQ_NUM_COMPLETION, | 414 | GAUDI2_IRQ_NUM_COMPLETION, |
| 414 | GAUDI2_IRQ_NUM_NIC_PORT_FIRST, | 415 | GAUDI2_IRQ_NUM_NIC_PORT_FIRST, |
| 415 | GAUDI2_IRQ_NUM_NIC_PORT_LAST = (GAUDI2_IRQ_NUM_NIC_PORT_FIRST + NIC_NUMBER_OF_PORTS - 1), | 416 | GAUDI2_IRQ_NUM_NIC_PORT_LAST = (GAUDI2_IRQ_NUM_NIC_PORT_FIRST + NIC_NUMBER_OF_PORTS - 1), |
| 417 | GAUDI2_IRQ_NUM_TPC_ASSERT, | ||
| 416 | GAUDI2_IRQ_NUM_RESERVED_FIRST, | 418 | GAUDI2_IRQ_NUM_RESERVED_FIRST, |
| 417 | GAUDI2_IRQ_NUM_RESERVED_LAST = (GAUDI2_MSIX_ENTRIES - GAUDI2_NUM_USER_INTERRUPTS - 1), | 419 | GAUDI2_IRQ_NUM_RESERVED_LAST = (GAUDI2_MSIX_ENTRIES - GAUDI2_NUM_USER_INTERRUPTS - 1), |
| 418 | GAUDI2_IRQ_NUM_USER_FIRST, | 420 | GAUDI2_IRQ_NUM_USER_FIRST, |
| @@ -472,6 +472,7 @@ int goya_set_fixed_properties(struct hl_device *hdev) · 471 unmodified lines | |||
| 472 | prop->max_pending_cs = GOYA_MAX_PENDING_CS; | 472 | prop->max_pending_cs = GOYA_MAX_PENDING_CS; |
| 473 | 473 | ||
| 474 | prop->first_available_user_interrupt = USHRT_MAX; | 474 | prop->first_available_user_interrupt = USHRT_MAX; |
| 475 | prop->tpc_interrupt_id = USHRT_MAX; | ||
| 475 | 476 | ||
| 476 | for (i = 0 ; i < HL_MAX_DCORES ; i++) | 477 | for (i = 0 ; i < HL_MAX_DCORES ; i++) |
| 477 | prop->first_available_cq[i] = USHRT_MAX; | 478 | prop->first_available_cq[i] = USHRT_MAX; |
| @@ -885,6 +885,7 @@ enum hl_server_type { · 884 unmodified lines | |||
| 885 | * application to use. Relevant for Gaudi2 and later. | 885 | * application to use. Relevant for Gaudi2 and later. |
| 886 | * @device_mem_alloc_default_page_size: default page size used in device memory allocation. | 886 | * @device_mem_alloc_default_page_size: default page size used in device memory allocation. |
| 887 | * @revision_id: PCI revision ID of the ASIC. | 887 | * @revision_id: PCI revision ID of the ASIC. |
| 888 | * @tpc_interrupt_id: interrupt id for TPC to use in order to raise events towards the host. | ||
| 888 | * @engine_core_interrupt_reg_addr: interrupt register address for engine core to use | 889 | * @engine_core_interrupt_reg_addr: interrupt register address for engine core to use |
| 889 | * in order to raise events toward FW. | 890 | * in order to raise events toward FW. |
| 890 | */ | 891 | */ |
| @@ -922,7 +923,7 @@ struct hl_info_hw_ip_info { · 31 unmodified lines | |||
| 922 | __u32 reserved7; | 923 | __u32 reserved7; |
| 923 | __u8 reserved8; | 924 | __u8 reserved8; |
| 924 | __u8 revision_id; | 925 | __u8 revision_id; |
| 925 | __u8 pad[2]; | 926 | __u16 tpc_interrupt_id; |
| 926 | __u32 reserved9; | 927 | __u32 reserved9; |
| 927 | __u8 pad3[4]; | 928 | __u8 pad3[4]; |
| 928 | __u64 engine_core_interrupt_reg_addr; | 929 | __u64 engine_core_interrupt_reg_addr; |