Commit e42a6400 authored by Ohad Sharabi's avatar Ohad Sharabi Committed by Oded Gabbay
Browse files

habanalabs: skip DISABLE PCI packet to FW on heartbeat



if reset is due to heartbeat, device CPU is no responsive in which
case no point sending PCI disable message to it.

Signed-off-by: default avatarOhad Sharabi <osharabi@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent d5eb8373
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -620,7 +620,7 @@ static void cs_timedout(struct work_struct *work)
	cs_put(cs);

	if (hdev->reset_on_lockup)
		hl_device_reset(hdev, false, false);
		hl_device_reset(hdev, 0);
	else
		hdev->needs_reset = true;
}
@@ -1473,7 +1473,7 @@ static int hl_cs_ctx_switch(struct hl_fpriv *hpriv, union hl_cs_args *args,

out:
	if ((rc == -ETIMEDOUT || rc == -EBUSY) && (need_soft_reset))
		hl_device_reset(hdev, false, false);
		hl_device_reset(hdev, 0);

	return rc;
}
+1 −1
Original line number Diff line number Diff line
@@ -887,7 +887,7 @@ static ssize_t hl_stop_on_err_write(struct file *f, const char __user *buf,

	hdev->stop_on_err = value ? 1 : 0;

	hl_device_reset(hdev, false, false);
	hl_device_reset(hdev, 0);

	return count;
}
+15 −10
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ static void hpriv_release(struct kref *ref)
	kfree(hpriv);

	if (hdev->reset_upon_device_release)
		hl_device_reset(hdev, false, false);
		hl_device_reset(hdev, 0);
}

void hl_hpriv_get(struct hl_fpriv *hpriv)
@@ -293,7 +293,7 @@ static void device_hard_reset_pending(struct work_struct *work)
	struct hl_device *hdev = device_reset_work->hdev;
	int rc;

	rc = hl_device_reset(hdev, true, true);
	rc = hl_device_reset(hdev, HL_RESET_HARD | HL_RESET_FROM_RESET_THREAD);
	if ((rc == -EBUSY) && !hdev->device_fini_pending) {
		dev_info(hdev->dev,
			"Could not reset device. will try again in %u seconds",
@@ -495,7 +495,7 @@ static void hl_device_heartbeat(struct work_struct *work)
		goto reschedule;

	dev_err(hdev->dev, "Device heartbeat failed!\n");
	hl_device_reset(hdev, true, false);
	hl_device_reset(hdev, HL_RESET_HARD | HL_RESET_HEARTBEAT);

	return;

@@ -819,7 +819,7 @@ int hl_device_resume(struct hl_device *hdev)
	hdev->disabled = false;
	atomic_set(&hdev->in_reset, 0);

	rc = hl_device_reset(hdev, true, false);
	rc = hl_device_reset(hdev, HL_RESET_HARD);
	if (rc) {
		dev_err(hdev->dev, "Failed to reset device during resume\n");
		goto disable_device;
@@ -925,9 +925,7 @@ static void device_disable_open_processes(struct hl_device *hdev)
 * hl_device_reset - reset the device
 *
 * @hdev: pointer to habanalabs device structure
 * @hard_reset: should we do hard reset to all engines or just reset the
 *              compute/dma engines
 * @from_hard_reset_thread: is the caller the hard-reset thread
 * @flags: reset flags.
 *
 * Block future CS and wait for pending CS to be enqueued
 * Call ASIC H/W fini
@@ -939,10 +937,10 @@ static void device_disable_open_processes(struct hl_device *hdev)
 *
 * Returns 0 for success or an error on failure.
 */
int hl_device_reset(struct hl_device *hdev, bool hard_reset,
			bool from_hard_reset_thread)
int hl_device_reset(struct hl_device *hdev, u32 flags)
{
	u64 idle_mask[HL_BUSY_ENGINES_MASK_EXT_SIZE] = {0};
	bool hard_reset, from_hard_reset_thread;
	int i, rc;

	if (!hdev->init_done) {
@@ -951,6 +949,9 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
		return 0;
	}

	hard_reset = (flags & HL_RESET_HARD) != 0;
	from_hard_reset_thread = (flags & HL_RESET_FROM_RESET_THREAD) != 0;

	if ((!hard_reset) && (!hdev->supports_soft_reset)) {
		dev_dbg(hdev->dev, "Doing hard-reset instead of soft-reset\n");
		hard_reset = true;
@@ -971,7 +972,11 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
		if (rc)
			return 0;

		if (hard_reset) {
		/*
		 * if reset is due to heartbeat, device CPU is no responsive in
		 * which case no point sending PCI disable message to it
		 */
		if (hard_reset && !(flags & HL_RESET_HEARTBEAT)) {
			/* Disable PCI access from device F/W so he won't send
			 * us additional interrupts. We disable MSI/MSI-X at
			 * the halt_engines function and we can't have the F/W
+18 −2
Original line number Diff line number Diff line
@@ -104,6 +104,23 @@ enum hl_mmu_page_table_location {

#define HL_MAX_DCORES			4

/*
 * Reset Flags
 *
 * - HL_RESET_HARD
 *       If set do hard reset to all engines. If not set reset just
 *       compute/DMA engines.
 *
 * - HL_RESET_FROM_RESET_THREAD
 *       Set if the caller is the hard-reset thread
 *
 * - HL_RESET_HEARTBEAT
 *       Set if reset is due to heartbeat
 */
#define HL_RESET_HARD			(1 << 0)
#define HL_RESET_FROM_RESET_THREAD	(1 << 1)
#define HL_RESET_HEARTBEAT		(1 << 2)

#define HL_MAX_SOBS_PER_MONITOR	8

/**
@@ -2242,8 +2259,7 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass);
void hl_device_fini(struct hl_device *hdev);
int hl_device_suspend(struct hl_device *hdev);
int hl_device_resume(struct hl_device *hdev);
int hl_device_reset(struct hl_device *hdev, bool hard_reset,
			bool from_hard_reset_thread);
int hl_device_reset(struct hl_device *hdev, u32 flags);
void hl_hpriv_get(struct hl_fpriv *hpriv);
int hl_hpriv_put(struct hl_fpriv *hpriv);
int hl_device_set_frequency(struct hl_device *hdev, enum hl_pll_frequency freq);
+2 −2
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ static ssize_t soft_reset_store(struct device *dev,

	dev_warn(hdev->dev, "Soft-Reset requested through sysfs\n");

	hl_device_reset(hdev, false, false);
	hl_device_reset(hdev, 0);

out:
	return count;
@@ -226,7 +226,7 @@ static ssize_t hard_reset_store(struct device *dev,

	dev_warn(hdev->dev, "Hard-Reset requested through sysfs\n");

	hl_device_reset(hdev, true, false);
	hl_device_reset(hdev, HL_RESET_HARD);

out:
	return count;
Loading