Skip to content

Commit 1f6bdee

Browse files
Alon Mizrahiogabbay
authored andcommitted
habanalabs/gaudi: add monitored SOBs to state dump
Current "state dump" is lacking of monitored SOB IDs. Add for convenience. Signed-off-by: Alon Mizrahi <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent 929cbab commit 1f6bdee

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

drivers/misc/habanalabs/gaudi/gaudi.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108

109109
#define BIN_REG_STRING_SIZE sizeof("0b10101010101010101010101010101010")
110110

111+
#define MONITOR_SOB_STRING_SIZE 256
112+
111113
static const char gaudi_irq_name[GAUDI_MSI_ENTRIES][GAUDI_MAX_STRING_LEN] = {
112114
"gaudi cq 0_0", "gaudi cq 0_1", "gaudi cq 0_2", "gaudi cq 0_3",
113115
"gaudi cq 1_0", "gaudi cq 1_1", "gaudi cq 1_2", "gaudi cq 1_3",
@@ -9184,21 +9186,52 @@ static int gaudi_monitor_valid(struct hl_mon_state_dump *mon)
91849186
mon->status);
91859187
}
91869188

9189+
static void gaudi_fill_sobs_from_mon(char *sobs, struct hl_mon_state_dump *mon)
9190+
{
9191+
const size_t max_write = 10;
9192+
u32 gid, mask, sob;
9193+
int i, offset;
9194+
9195+
/* Sync object ID is calculated as follows:
9196+
* (8 * group_id + cleared bits in mask)
9197+
*/
9198+
gid = FIELD_GET(SYNC_MNGR_W_S_SYNC_MNGR_OBJS_MON_ARM_0_SID_MASK,
9199+
mon->arm_data);
9200+
mask = FIELD_GET(SYNC_MNGR_W_S_SYNC_MNGR_OBJS_MON_ARM_0_MASK_MASK,
9201+
mon->arm_data);
9202+
9203+
for (i = 0, offset = 0; mask && offset < MONITOR_SOB_STRING_SIZE -
9204+
max_write; mask >>= 1, i++) {
9205+
if (!(mask & 1)) {
9206+
sob = gid * MONITOR_MAX_SOBS + i;
9207+
9208+
if (offset > 0)
9209+
offset += snprintf(sobs + offset, max_write,
9210+
", ");
9211+
9212+
offset += snprintf(sobs + offset, max_write, "%u", sob);
9213+
}
9214+
}
9215+
}
9216+
91879217
static int gaudi_print_single_monitor(char **buf, size_t *size, size_t *offset,
91889218
struct hl_device *hdev,
91899219
struct hl_mon_state_dump *mon)
91909220
{
91919221
const char *name;
91929222
char scratch_buf1[BIN_REG_STRING_SIZE],
91939223
scratch_buf2[BIN_REG_STRING_SIZE];
9224+
char monitored_sobs[MONITOR_SOB_STRING_SIZE] = {0};
91949225

91959226
name = hl_state_dump_get_monitor_name(hdev, mon);
91969227
if (!name)
91979228
name = "";
91989229

9230+
gaudi_fill_sobs_from_mon(monitored_sobs, mon);
9231+
91999232
return hl_snprintf_resize(
92009233
buf, size, offset,
9201-
"Mon id: %u%s, wait for group id: %u mask %s to reach val: %u and write %u to address 0x%llx. Pending: %s",
9234+
"Mon id: %u%s, wait for group id: %u mask %s to reach val: %u and write %u to address 0x%llx. Pending: %s. Means sync objects [%s] are being monitored.",
92029235
mon->id, name,
92039236
FIELD_GET(SYNC_MNGR_W_S_SYNC_MNGR_OBJS_MON_ARM_0_SID_MASK,
92049237
mon->arm_data),
@@ -9215,7 +9248,8 @@ static int gaudi_print_single_monitor(char **buf, size_t *size, size_t *offset,
92159248
scratch_buf2, sizeof(scratch_buf2),
92169249
FIELD_GET(
92179250
SYNC_MNGR_W_S_SYNC_MNGR_OBJS_MON_STATUS_0_PENDING_MASK,
9218-
mon->status)));
9251+
mon->status)),
9252+
monitored_sobs);
92199253
}
92209254

92219255

drivers/misc/habanalabs/gaudi/gaudiP.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
(((mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_MON_STATUS_511 - \
118118
mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_MON_STATUS_0) + 4) >> 2)
119119

120+
#define MONITOR_MAX_SOBS 8
120121

121122
/* DRAM Memory Map */
122123

0 commit comments

Comments
 (0)