History

accel/habanalabs: add support for TPC assert

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.

Ofir Bitton committed 3 years ago

Commit 4713ace1 parent bcfcd088 files · +52 −4Browse files

Unified · Split

8 files
  1. drivers/accel/habanalabs/common/habanalabs.h +5 −0
  2. drivers/accel/habanalabs/common/habanalabs_ioctl.c +1 −0
  3. drivers/accel/habanalabs/common/irq.c +18 −0
  4. drivers/accel/habanalabs/gaudi/gaudi.c +1 −0
  5. drivers/accel/habanalabs/gaudi2/gaudi2.c +22 −3
  6. drivers/accel/habanalabs/gaudi2/gaudi2P.h +2 −0
  7. drivers/accel/habanalabs/goya/goya.c +1 −0
  8. include/uapi/drm/habanalabs_accel.h +2 −1
drivers/accel/habanalabs/common/habanalabs.h+5−0
@@ -665,6 +665,7 @@ struct hl_hints_range { · 664 unmodified lines
665665 * @first_available_cq: first available CQ for the user.
666666 * @user_interrupt_count: number of user interrupts.
667667 * @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.
668669 * @cache_line_size: device cache line size.
669670 * @server_type: Server type that the ASIC is currently installed in.
670671 * The value is according to enum hl_server_type in uapi file.
@@ -791,6 +792,7 @@ struct asic_fixed_properties { · 120 unmodified lines
791792 u16 first_available_cq[HL_MAX_DCORES];
792793 u16 user_interrupt_count;
793794 u16 user_dec_intr_count;
795+ u16 tpc_interrupt_id;
794796 u16 cache_line_size;
795797 u16 server_type;
796798 u8 completion_queues_count;
@@ -1099,6 +1101,7 @@ struct hl_cq { · 302 unmodified lines
10991101 enum hl_user_interrupt_type {
11001102 HL_USR_INTERRUPT_CQ = 0,
11011103 HL_USR_INTERRUPT_DECODER,
1104+ HL_USR_INTERRUPT_TPC
11021105 };
11031106
11041107 /**
@@ -3148,6 +3151,7 @@ struct hl_reset_info { · 2043 unmodified lines
31483151 * @user_interrupt: array of hl_user_interrupt. upon the corresponding user
31493152 * interrupt, driver will monitor the list of fences
31503153 * registered to this interrupt.
3154+ * @tpc_interrupt: single TPC interrupt for all TPCs.
31513155 * @common_user_cq_interrupt: common user CQ interrupt for all user CQ interrupts.
31523156 * upon any user CQ interrupt, driver will monitor the
31533157 * list of fences registered to this common structure.
@@ -3332,6 +3336,7 @@ struct hl_device { · 178 unmodified lines
33323336 enum hl_asic_type asic_type;
33333337 struct hl_cq *completion_queue;
33343338 struct hl_user_interrupt *user_interrupt;
3339+ struct hl_user_interrupt tpc_interrupt;
33353340 struct hl_user_interrupt common_user_cq_interrupt;
33363341 struct hl_user_interrupt common_decoder_interrupt;
33373342 struct hl_cs **shadow_cs_queue;
drivers/accel/habanalabs/common/habanalabs_ioctl.c+1−0
@@ -102,6 +102,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args) · 101 unmodified lines
102102 hw_ip.mme_master_slave_mode = prop->mme_master_slave_mode;
103103 hw_ip.first_available_interrupt_id = prop->first_available_user_interrupt;
104104 hw_ip.number_of_user_interrupts = prop->user_interrupt_count;
105+ hw_ip.tpc_interrupt_id = prop->tpc_interrupt_id;
105106
106107 hw_ip.edma_enabled_mask = prop->edma_enabled_mask;
107108 hw_ip.server_type = prop->server_type;
drivers/accel/habanalabs/common/irq.c+18−0
@@ -325,6 +325,21 @@ static void handle_user_interrupt(struct hl_device *hdev, struct hl_user_interru · 324 unmodified lines
325325 }
326326 }
327327
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+
328343 /**
329344 * hl_irq_handler_user_interrupt - irq handler for user interrupts
330345 *
@@ -367,6 +382,9 @@ irqreturn_t hl_irq_user_interrupt_thread_handler(int irq, void *arg) · 36 unmodified lines
367382 /* Handle decoder interrupt registered on this specific irq */
368383 handle_user_interrupt(hdev, user_int);
369384 break;
385+ case HL_USR_INTERRUPT_TPC:
386+ handle_tpc_interrupt(hdev);
387+ break;
370388 default:
371389 break;
372390 }
drivers/accel/habanalabs/gaudi/gaudi.c+1−0
@@ -679,6 +679,7 @@ static int gaudi_set_fixed_properties(struct hl_device *hdev) · 678 unmodified lines
679679 (num_sync_stream_queues * HL_RSVD_MONS);
680680
681681 prop->first_available_user_interrupt = USHRT_MAX;
682+ prop->tpc_interrupt_id = USHRT_MAX;
682683
683684 for (i = 0 ; i < HL_MAX_DCORES ; i++)
684685 prop->first_available_cq[i] = USHRT_MAX;
drivers/accel/habanalabs/gaudi2/gaudi2.c+22−3
@@ -2348,6 +2348,7 @@ static int gaudi2_set_fixed_properties(struct hl_device *hdev) · 2347 unmodified lines
23482348 (num_sync_stream_queues * HL_RSVD_MONS);
23492349
23502350 prop->first_available_user_interrupt = GAUDI2_IRQ_NUM_USER_FIRST;
2351+ prop->tpc_interrupt_id = GAUDI2_IRQ_NUM_TPC_ASSERT;
23512352
23522353 prop->first_available_cq[0] = GAUDI2_RESERVED_CQ_NUMBER;
23532354
@@ -3235,6 +3236,9 @@ static void gaudi2_user_interrupt_setup(struct hl_device *hdev) · 881 unmodified lines
32353236 struct asic_fixed_properties *prop = &hdev->asic_prop;
32363237 int i, j, k;
32373238
3239+ /* Initialize TPC interrupt */
3240+ HL_USR_INTR_STRUCT_INIT(hdev->tpc_interrupt, hdev, 0, HL_USR_INTERRUPT_TPC);
3241+
32383242 /* Initialize common user CQ interrupt */
32393243 HL_USR_INTR_STRUCT_INIT(hdev->common_user_cq_interrupt, hdev,
32403244 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
38923896 return "gaudi2 completion";
38933897 case GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM ... GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM:
38943898 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";
38953901 case GAUDI2_IRQ_NUM_USER_FIRST ... GAUDI2_IRQ_NUM_USER_LAST:
38963902 return "gaudi2 user completion";
38973903 default:
@@ -4004,6 +4010,15 @@ static int gaudi2_enable_msix(struct hl_device *hdev) · 106 unmodified lines
40044010 goto free_event_irq;
40054011 }
40064012
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+
40074022 for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = prop->user_dec_intr_count, user_irq_init_cnt = 0;
40084023 user_irq_init_cnt < prop->user_interrupt_count;
40094024 i++, j++, user_irq_init_cnt++) {
@@ -4031,9 +4046,8 @@ free_user_irq: · 21 unmodified lines
40314046 irq = pci_irq_vector(hdev->pdev, i);
40324047 free_irq(irq, &hdev->user_interrupt[j]);
40334048 }
4034−
4035− gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM + 1);
4036−
4049+free_dec_irq:
4050+ gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_DEC_LAST + 1);
40374051 free_event_irq:
40384052 irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_EVENT_QUEUE);
40394053 free_irq(irq, cq);
@@ -4065,6 +4079,8 @@ static void gaudi2_sync_irqs(struct hl_device *hdev) · 25 unmodified lines
40654079 synchronize_irq(irq);
40664080 }
40674081
4082+ synchronize_irq(pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_TPC_ASSERT));
4083+
40684084 for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = 0 ; j < hdev->asic_prop.user_interrupt_count;
40694085 i++, j++) {
40704086 irq = pci_irq_vector(hdev->pdev, i);
@@ -4091,6 +4107,9 @@ static void gaudi2_disable_msix(struct hl_device *hdev) · 20 unmodified lines
40914107
40924108 gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM + 1);
40934109
4110+ irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_TPC_ASSERT);
4111+ free_irq(irq, &hdev->tpc_interrupt);
4112+
40944113 for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = prop->user_dec_intr_count, k = 0;
40954114 k < hdev->asic_prop.user_interrupt_count ; i++, j++, k++) {
40964115
drivers/accel/habanalabs/gaudi2/gaudi2P.h+2−0
@@ -410,9 +410,11 @@ enum gaudi2_irq_num { · 409 unmodified lines
410410 GAUDI2_IRQ_NUM_SHARED_DEC0_ABNRM,
411411 GAUDI2_IRQ_NUM_SHARED_DEC1_NRM,
412412 GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,
413+ GAUDI2_IRQ_NUM_DEC_LAST = GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,
413414 GAUDI2_IRQ_NUM_COMPLETION,
414415 GAUDI2_IRQ_NUM_NIC_PORT_FIRST,
415416 GAUDI2_IRQ_NUM_NIC_PORT_LAST = (GAUDI2_IRQ_NUM_NIC_PORT_FIRST + NIC_NUMBER_OF_PORTS - 1),
417+ GAUDI2_IRQ_NUM_TPC_ASSERT,
416418 GAUDI2_IRQ_NUM_RESERVED_FIRST,
417419 GAUDI2_IRQ_NUM_RESERVED_LAST = (GAUDI2_MSIX_ENTRIES - GAUDI2_NUM_USER_INTERRUPTS - 1),
418420 GAUDI2_IRQ_NUM_USER_FIRST,
drivers/accel/habanalabs/goya/goya.c+1−0
@@ -472,6 +472,7 @@ int goya_set_fixed_properties(struct hl_device *hdev) · 471 unmodified lines
472472 prop->max_pending_cs = GOYA_MAX_PENDING_CS;
473473
474474 prop->first_available_user_interrupt = USHRT_MAX;
475+ prop->tpc_interrupt_id = USHRT_MAX;
475476
476477 for (i = 0 ; i < HL_MAX_DCORES ; i++)
477478 prop->first_available_cq[i] = USHRT_MAX;
include/uapi/drm/habanalabs_accel.h+2−1
@@ -885,6 +885,7 @@ enum hl_server_type { · 884 unmodified lines
885885 * application to use. Relevant for Gaudi2 and later.
886886 * @device_mem_alloc_default_page_size: default page size used in device memory allocation.
887887 * @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.
888889 * @engine_core_interrupt_reg_addr: interrupt register address for engine core to use
889890 * in order to raise events toward FW.
890891 */
@@ -922,7 +923,7 @@ struct hl_info_hw_ip_info { · 31 unmodified lines
922923 __u32 reserved7;
923924 __u8 reserved8;
924925 __u8 revision_id;
925− __u8 pad[2];
926+ __u16 tpc_interrupt_id;
926927 __u32 reserved9;
927928 __u8 pad3[4];
928929 __u64 engine_core_interrupt_reg_addr;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t