Skip to content

Commit 1b18cf3

Browse files
Tomer Tayarogabbay
authored andcommitted
habanalabs: make print of engines idle mask more readable
The engines idle mask was increased to be an array of 4 u64 entries. To make the print of this mask more readable, remove the "0x" prefix, and zero-pad each u64 to 16 bytes if either it isn't zero or if any of the higher-order u64's is not zero. Signed-off-by: Tomer Tayar <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent 893afb2 commit 1b18cf3

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

drivers/misc/habanalabs/common/device.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,23 @@ bool hl_ctrl_device_operational(struct hl_device *hdev,
386386
}
387387
}
388388

389+
static void print_idle_status_mask(struct hl_device *hdev, const char *message,
390+
u64 idle_mask[HL_BUSY_ENGINES_MASK_EXT_SIZE])
391+
{
392+
u32 pad_width[HL_BUSY_ENGINES_MASK_EXT_SIZE] = {};
393+
394+
BUILD_BUG_ON(HL_BUSY_ENGINES_MASK_EXT_SIZE != 4);
395+
396+
pad_width[3] = idle_mask[3] ? 16 : 0;
397+
pad_width[2] = idle_mask[2] || pad_width[3] ? 16 : 0;
398+
pad_width[1] = idle_mask[1] || pad_width[2] ? 16 : 0;
399+
pad_width[0] = idle_mask[0] || pad_width[1] ? 16 : 0;
400+
401+
dev_err(hdev->dev, "%s (mask %0*llx_%0*llx_%0*llx_%0*llx)\n",
402+
message, pad_width[3], idle_mask[3], pad_width[2], idle_mask[2],
403+
pad_width[1], idle_mask[1], pad_width[0], idle_mask[0]);
404+
}
405+
389406
static void hpriv_release(struct kref *ref)
390407
{
391408
u64 idle_mask[HL_BUSY_ENGINES_MASK_EXT_SIZE] = {0};
@@ -416,9 +433,8 @@ static void hpriv_release(struct kref *ref)
416433
device_is_idle = hdev->asic_funcs->is_device_idle(hdev, idle_mask,
417434
HL_BUSY_ENGINES_MASK_EXT_SIZE, NULL);
418435
if (!device_is_idle) {
419-
dev_err(hdev->dev,
420-
"device not idle after user context is closed (0x%llx_%llx_%llx_%llx)\n",
421-
idle_mask[3], idle_mask[2], idle_mask[1], idle_mask[0]);
436+
print_idle_status_mask(hdev, "device is not idle after user context is closed",
437+
idle_mask);
422438
reset_device = true;
423439
}
424440

@@ -1673,9 +1689,8 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
16731689

16741690
/* If device is not idle fail the reset process */
16751691
if (!hdev->asic_funcs->is_device_idle(hdev, idle_mask,
1676-
HL_BUSY_ENGINES_MASK_EXT_SIZE, NULL)) {
1677-
dev_err(hdev->dev, "device is not idle (mask 0x%llx_%llx_%llx_%llx) after reset\n",
1678-
idle_mask[3], idle_mask[2], idle_mask[1], idle_mask[0]);
1692+
HL_BUSY_ENGINES_MASK_EXT_SIZE, NULL)) {
1693+
print_idle_status_mask(hdev, "device is not idle after reset", idle_mask);
16791694
rc = -EIO;
16801695
goto out_err;
16811696
}

0 commit comments

Comments
 (0)