Commit 75d9a2a0 authored by Alon Mizrahi's avatar Alon Mizrahi Committed by Oded Gabbay
Browse files

habanalabs: replace WARN/WARN_ON with dev_crit in driver



Often WARN is defined in data-centers as BUG and we would like to
avoid hanging the entire server on some internal error of the driver
(important as it might be).

Therefore, use dev_crit instead.

Signed-off-by: default avatarAlon Mizrahi <amizrahi@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 0eda23d7
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -50,8 +50,10 @@ unsigned long hl_asid_alloc(struct hl_device *hdev)

void hl_asid_free(struct hl_device *hdev, unsigned long asid)
{
	if (WARN((asid == 0 || asid >= hdev->asic_prop.max_asid),
						"Invalid ASID %lu", asid))
	if (asid == HL_KERNEL_ASID_ID || asid >= hdev->asic_prop.max_asid) {
		dev_crit(hdev->dev, "Invalid ASID %lu", asid);
		return;
	}

	clear_bit(asid, hdev->asid_bitmap);
}
+5 −3
Original line number Diff line number Diff line
@@ -635,10 +635,12 @@ struct hl_cb *hl_cb_kernel_create(struct hl_device *hdev, u32 cb_size,

	cb_handle >>= PAGE_SHIFT;
	cb = hl_cb_get(hdev, &hdev->kernel_cb_mgr, (u32) cb_handle);
	/* hl_cb_get should never fail here so use kernel WARN */
	WARN(!cb, "Kernel CB handle invalid 0x%x\n", (u32) cb_handle);
	if (!cb)
	/* hl_cb_get should never fail here */
	if (!cb) {
		dev_crit(hdev->dev, "Kernel CB handle invalid 0x%x\n",
				(u32) cb_handle);
		goto destroy_cb;
	}

	return cb;

+2 −1
Original line number Diff line number Diff line
@@ -1485,7 +1485,8 @@ void hl_device_fini(struct hl_device *hdev)
		usleep_range(50, 200);
		rc = atomic_cmpxchg(&hdev->in_reset, 0, 1);
		if (ktime_compare(ktime_get(), timeout) > 0) {
			WARN(1, "Failed to remove device because reset function did not finish\n");
			dev_crit(hdev->dev,
				"Failed to remove device because reset function did not finish\n");
			return;
		}
	}
+4 −3
Original line number Diff line number Diff line
@@ -261,7 +261,8 @@ int hl_mmu_map_page(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr,
		return -EFAULT;
	}

	WARN_ONCE((phys_addr & (real_page_size - 1)),
	if (phys_addr & (real_page_size - 1))
		dev_crit(hdev->dev,
			"Mapping 0x%llx with page size of 0x%x is erroneous! Address must be divisible by page size",
			phys_addr, real_page_size);

+7 −7
Original line number Diff line number Diff line
@@ -5308,10 +5308,10 @@ static int gaudi_parse_cb_mmu(struct hl_device *hdev,
	patched_cb_handle >>= PAGE_SHIFT;
	parser->patched_cb = hl_cb_get(hdev, &hdev->kernel_cb_mgr,
				(u32) patched_cb_handle);
	/* hl_cb_get should never fail here so use kernel WARN */
	WARN(!parser->patched_cb, "DMA CB handle invalid 0x%x\n",
			(u32) patched_cb_handle);
	/* hl_cb_get should never fail */
	if (!parser->patched_cb) {
		dev_crit(hdev->dev, "DMA CB handle invalid 0x%x\n",
			(u32) patched_cb_handle);
		rc = -EFAULT;
		goto out;
	}
@@ -5380,10 +5380,10 @@ static int gaudi_parse_cb_no_mmu(struct hl_device *hdev,
	patched_cb_handle >>= PAGE_SHIFT;
	parser->patched_cb = hl_cb_get(hdev, &hdev->kernel_cb_mgr,
				(u32) patched_cb_handle);
	/* hl_cb_get should never fail here so use kernel WARN */
	WARN(!parser->patched_cb, "DMA CB handle invalid 0x%x\n",
			(u32) patched_cb_handle);
	/* hl_cb_get should never fail here */
	if (!parser->patched_cb) {
		dev_crit(hdev->dev, "DMA CB handle invalid 0x%x\n",
				(u32) patched_cb_handle);
		rc = -EFAULT;
		goto out;
	}
@@ -5928,7 +5928,7 @@ static void gaudi_mmu_prepare(struct hl_device *hdev, u32 asid)
		return;

	if (asid & ~DMA0_QM_GLBL_NON_SECURE_PROPS_0_ASID_MASK) {
		WARN(1, "asid %u is too big\n", asid);
		dev_crit(hdev->dev, "asid %u is too big\n", asid);
		return;
	}

Loading