History

habanalabs: Add busy engines bitmask to HW idle IOCTL

The information which is currently provided as a response to the "HL_INFO_HW_IDLE" IOCTL is merely a general boolean value. This patch extends it and provides also a bitmask that indicates which of the device engines are busy.

Tomer Tayar committed 7 years ago

Commit e8960ca1 parent 06deb865 files · +43 −6Browse files

Unified · Split

5 files
  1. drivers/misc/habanalabs/debugfs.c +1 −1
  2. drivers/misc/habanalabs/goya/goya.c +9 −2
  3. drivers/misc/habanalabs/habanalabs.h +2 −1
  4. drivers/misc/habanalabs/habanalabs_ioctl.c +2 −1
  5. include/uapi/misc/habanalabs.h +29 −1
drivers/misc/habanalabs/debugfs.c+1−1
@@ -506,7 +506,7 @@ static int engines_show(struct seq_file *s, void *data) · 505 unmodified lines
506506 struct hl_dbg_device_entry *dev_entry = entry->dev_entry;
507507 struct hl_device *hdev = dev_entry->hdev;
508508
509− hdev->asic_funcs->is_device_idle(hdev, s);
509+ hdev->asic_funcs->is_device_idle(hdev, NULL, s);
510510
511511 return 0;
512512 }
drivers/misc/habanalabs/goya/goya.c+9−2
@@ -2828,7 +2828,7 @@ static int goya_send_job_on_qman0(struct hl_device *hdev, struct hl_cs_job *job) · 2827 unmodified lines
28282828 else
28292829 timeout = HL_DEVICE_TIMEOUT_USEC;
28302830
2831− if (!hdev->asic_funcs->is_device_idle(hdev, NULL)) {
2831+ if (!hdev->asic_funcs->is_device_idle(hdev, NULL, NULL)) {
28322832 dev_err_ratelimited(hdev->dev,
28332833 "Can't send KMD job on QMAN0 because the device is not idle\n");
28342834 return -EBUSY;
@@ -4914,7 +4914,8 @@ int goya_armcp_info_get(struct hl_device *hdev) · 2079 unmodified lines
49144914 return 0;
49154915 }
49164916
4917−static bool goya_is_device_idle(struct hl_device *hdev, struct seq_file *s)
4917+static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask,
4918+ struct seq_file *s)
49184919 {
49194920 const char *fmt = "%-5d%-9s%#-14x%#-16x%#x\n";
49204921 const char *dma_fmt = "%-5d%-9s%#-14x%#x\n";
@@ -4937,6 +4938,8 @@ static bool goya_is_device_idle(struct hl_device *hdev, struct seq_file *s) · 16 unmodified lines
49374938 IS_DMA_IDLE(dma_core_sts0);
49384939 is_idle &= is_eng_idle;
49394940
4941+ if (mask)
4942+ *mask |= !is_eng_idle << (GOYA_ENGINE_ID_DMA_0 + i);
49404943 if (s)
49414944 seq_printf(s, dma_fmt, i, is_eng_idle ? "Y" : "N",
49424945 qm_glbl_sts0, dma_core_sts0);
@@ -4958,6 +4961,8 @@ static bool goya_is_device_idle(struct hl_device *hdev, struct seq_file *s) · 15 unmodified lines
49584961 IS_TPC_IDLE(tpc_cfg_sts);
49594962 is_idle &= is_eng_idle;
49604963
4964+ if (mask)
4965+ *mask |= !is_eng_idle << (GOYA_ENGINE_ID_TPC_0 + i);
49614966 if (s)
49624967 seq_printf(s, fmt, i, is_eng_idle ? "Y" : "N",
49634968 qm_glbl_sts0, cmdq_glbl_sts0, tpc_cfg_sts);
@@ -4976,6 +4981,8 @@ static bool goya_is_device_idle(struct hl_device *hdev, struct seq_file *s) · 12 unmodified lines
49764981 IS_MME_IDLE(mme_arch_sts);
49774982 is_idle &= is_eng_idle;
49784983
4984+ if (mask)
4985+ *mask |= !is_eng_idle << GOYA_ENGINE_ID_MME_0;
49794986 if (s) {
49804987 seq_printf(s, fmt, 0, is_eng_idle ? "Y" : "N", qm_glbl_sts0,
49814988 cmdq_glbl_sts0, mme_arch_sts);
drivers/misc/habanalabs/habanalabs.h+2−1
@@ -557,7 +557,8 @@ struct hl_asic_funcs { · 556 unmodified lines
557557 u32 asid, u64 va, u64 size);
558558 int (*send_heartbeat)(struct hl_device *hdev);
559559 int (*debug_coresight)(struct hl_device *hdev, void *data);
560− bool (*is_device_idle)(struct hl_device *hdev, struct seq_file *s);
560+ bool (*is_device_idle)(struct hl_device *hdev, u32 *mask,
561+ struct seq_file *s);
561562 int (*soft_reset_late_init)(struct hl_device *hdev);
562563 void (*hw_queues_lock)(struct hl_device *hdev);
563564 void (*hw_queues_unlock)(struct hl_device *hdev);
drivers/misc/habanalabs/habanalabs_ioctl.c+2−1
@@ -119,7 +119,8 @@ static int hw_idle(struct hl_device *hdev, struct hl_info_args *args) · 118 unmodified lines
119119 if ((!max_size) || (!out))
120120 return -EINVAL;
121121
122− hw_idle.is_idle = hdev->asic_funcs->is_device_idle(hdev, NULL);
122+ hw_idle.is_idle = hdev->asic_funcs->is_device_idle(hdev,
123+ &hw_idle.busy_engines_mask, NULL);
123124
124125 return copy_to_user(out, &hw_idle,
125126 min((size_t) max_size, sizeof(hw_idle))) ? -EFAULT : 0;
include/uapi/misc/habanalabs.h+29−1
@@ -45,6 +45,30 @@ enum goya_queue_id { · 44 unmodified lines
4545 GOYA_QUEUE_ID_SIZE
4646 };
4747
48+/*
49+ * Engine Numbering
50+ *
51+ * Used in the "busy_engines_mask" field in `struct hl_info_hw_idle'
52+ */
53+
54+enum goya_engine_id {
55+ GOYA_ENGINE_ID_DMA_0 = 0,
56+ GOYA_ENGINE_ID_DMA_1,
57+ GOYA_ENGINE_ID_DMA_2,
58+ GOYA_ENGINE_ID_DMA_3,
59+ GOYA_ENGINE_ID_DMA_4,
60+ GOYA_ENGINE_ID_MME_0,
61+ GOYA_ENGINE_ID_TPC_0,
62+ GOYA_ENGINE_ID_TPC_1,
63+ GOYA_ENGINE_ID_TPC_2,
64+ GOYA_ENGINE_ID_TPC_3,
65+ GOYA_ENGINE_ID_TPC_4,
66+ GOYA_ENGINE_ID_TPC_5,
67+ GOYA_ENGINE_ID_TPC_6,
68+ GOYA_ENGINE_ID_TPC_7,
69+ GOYA_ENGINE_ID_SIZE
70+};
71+
4872 enum hl_device_status {
4973 HL_DEVICE_STATUS_OPERATIONAL,
5074 HL_DEVICE_STATUS_IN_RESET,
@@ -86,7 +110,11 @@ struct hl_info_dram_usage { · 35 unmodified lines
86110
87111 struct hl_info_hw_idle {
88112 __u32 is_idle;
89− __u32 pad;
113+ /*
114+ * Bitmask of busy engines.
115+ * Bits definition is according to `enum <chip>_enging_id'.
116+ */
117+ __u32 busy_engines_mask;
90118 };
91119
92120 struct hl_info_device_status {