Commit 234caa52 authored by Bharat Jauhari's avatar Bharat Jauhari Committed by Oded Gabbay
Browse files

habanalabs: rename reset flags



Rename reset flags for better readability as compared to
HL_RESET_CAUSE* enum shared with the f/w.

Signed-off-by: default avatarBharat Jauhari <bjauhari@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent e84e31a9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -767,7 +767,7 @@ static void cs_timedout(struct work_struct *work)

	if (likely(!skip_reset_on_timeout)) {
		if (hdev->reset_on_lockup)
			hl_device_reset(hdev, HL_RESET_TDR);
			hl_device_reset(hdev, HL_DRV_RESET_TDR);
		else
			hdev->needs_reset = true;
	}
+20 −20
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ static void hpriv_release(struct kref *ref)

	if ((hdev->reset_if_device_not_idle && !device_is_idle)
			|| hdev->reset_upon_device_release)
		hl_device_reset(hdev, HL_RESET_DEVICE_RELEASE);
		hl_device_reset(hdev, HL_DRV_RESET_DEV_RELEASE);

	/* Now we can mark the compute_ctx as empty. Even if a reset is running in a different
	 * thread, we don't care because the in_reset is marked so if a user will try to open
@@ -330,10 +330,10 @@ static void device_hard_reset_pending(struct work_struct *work)
	u32 flags;
	int rc;

	flags = HL_RESET_HARD | HL_RESET_FROM_RESET_THREAD;
	flags = HL_DRV_RESET_HARD | HL_DRV_RESET_FROM_RESET_THR;

	if (device_reset_work->fw_reset)
		flags |= HL_RESET_FW;
		flags |= HL_DRV_RESET_BYPASS_REQ_TO_FW;

	rc = hl_device_reset(hdev, flags);
	if ((rc == -EBUSY) && !hdev->device_fini_pending) {
@@ -541,7 +541,7 @@ static void hl_device_heartbeat(struct work_struct *work)
		goto reschedule;

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

	return;

@@ -552,7 +552,7 @@ static void hl_device_heartbeat(struct work_struct *work)
	 * If control reached here, then at least one heartbeat work has been
	 * scheduled since last reset/init cycle.
	 * So if the device is not already in reset cycle, reset the flag
	 * prev_reset_trigger as no reset occurred with HL_RESET_FW_FATAL_ERR
	 * prev_reset_trigger as no reset occurred with HL_DRV_RESET_FW_FATAL_ERR
	 * status for at least one heartbeat. From this point driver restarts
	 * tracking future consecutive fatal errors.
	 */
@@ -831,7 +831,7 @@ int hl_device_resume(struct hl_device *hdev)
	hdev->disabled = false;
	atomic_set(&hdev->in_reset, 0);

	rc = hl_device_reset(hdev, HL_RESET_HARD);
	rc = hl_device_reset(hdev, HL_DRV_RESET_HARD);
	if (rc) {
		dev_err(hdev->dev, "Failed to reset device during resume\n");
		goto disable_device;
@@ -948,15 +948,15 @@ static void handle_reset_trigger(struct hl_device *hdev, u32 flags)
	 * ('in_reset' makes sure of it). This makes sure that
	 * 'reset_cause' will continue holding its 1st recorded reason!
	 */
	if (flags & HL_RESET_HEARTBEAT) {
	if (flags & HL_DRV_RESET_HEARTBEAT) {
		hdev->curr_reset_cause = HL_RESET_CAUSE_HEARTBEAT;
		cur_reset_trigger = HL_RESET_HEARTBEAT;
	} else if (flags & HL_RESET_TDR) {
		cur_reset_trigger = HL_DRV_RESET_HEARTBEAT;
	} else if (flags & HL_DRV_RESET_TDR) {
		hdev->curr_reset_cause = HL_RESET_CAUSE_TDR;
		cur_reset_trigger = HL_RESET_TDR;
	} else if (flags & HL_RESET_FW_FATAL_ERR) {
		cur_reset_trigger = HL_DRV_RESET_TDR;
	} else if (flags & HL_DRV_RESET_FW_FATAL_ERR) {
		hdev->curr_reset_cause = HL_RESET_CAUSE_UNKNOWN;
		cur_reset_trigger = HL_RESET_FW_FATAL_ERR;
		cur_reset_trigger = HL_DRV_RESET_FW_FATAL_ERR;
	} else {
		hdev->curr_reset_cause = HL_RESET_CAUSE_UNKNOWN;
	}
@@ -979,8 +979,8 @@ static void handle_reset_trigger(struct hl_device *hdev, u32 flags)
	 * If F/W is performing the reset, no need to send it a message to disable
	 * PCI access
	 */
	if ((flags & HL_RESET_HARD) &&
			!(flags & (HL_RESET_HEARTBEAT | HL_RESET_FW))) {
	if ((flags & HL_DRV_RESET_HARD) &&
			!(flags & (HL_DRV_RESET_HEARTBEAT | HL_DRV_RESET_BYPASS_REQ_TO_FW))) {
		/* 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
@@ -1025,9 +1025,9 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
		return 0;
	}

	hard_reset = !!(flags & HL_RESET_HARD);
	from_hard_reset_thread = !!(flags & HL_RESET_FROM_RESET_THREAD);
	fw_reset = !!(flags & HL_RESET_FW);
	hard_reset = !!(flags & HL_DRV_RESET_HARD);
	from_hard_reset_thread = !!(flags & HL_DRV_RESET_FROM_RESET_THR);
	fw_reset = !!(flags & HL_DRV_RESET_BYPASS_REQ_TO_FW);

	if (!hard_reset && !hdev->supports_soft_reset) {
		hard_instead_soft = true;
@@ -1035,7 +1035,7 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
	}

	if (hdev->reset_upon_device_release &&
			(flags & HL_RESET_DEVICE_RELEASE)) {
			(flags & HL_DRV_RESET_DEV_RELEASE)) {
		dev_dbg(hdev->dev,
			"Perform %s-reset upon device release\n",
			hard_reset ? "hard" : "soft");
@@ -1075,7 +1075,7 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)

		if (hard_reset)
			dev_info(hdev->dev, "Going to reset device\n");
		else if (flags & HL_RESET_DEVICE_RELEASE)
		else if (flags & HL_DRV_RESET_DEV_RELEASE)
			dev_info(hdev->dev,
				"Going to reset device after it was released by user\n");
		else
@@ -1171,7 +1171,7 @@ int hl_device_reset(struct hl_device *hdev, u32 flags)
		hdev->hard_reset_pending = false;

		if (hdev->reset_trigger_repeated &&
				(hdev->prev_reset_trigger == HL_RESET_FW_FATAL_ERR)) {
				(hdev->prev_reset_trigger == HL_DRV_RESET_FW_FATAL_ERR)) {
			/* if there 2 back to back resets from FW,
			 * ensure driver puts the driver in a unusable state
			 */
+14 −14
Original line number Diff line number Diff line
@@ -120,37 +120,37 @@ enum hl_mmu_page_table_location {
/*
 * Reset Flags
 *
 * - HL_RESET_HARD
 * - HL_DRV_RESET_HARD
 *       If set do hard reset to all engines. If not set reset just
 *       compute/DMA engines.
 *
 * - HL_RESET_FROM_RESET_THREAD
 * - HL_DRV_RESET_FROM_RESET_THR
 *       Set if the caller is the hard-reset thread
 *
 * - HL_RESET_HEARTBEAT
 * - HL_DRV_RESET_HEARTBEAT
 *       Set if reset is due to heartbeat
 *
 * - HL_RESET_TDR
 * - HL_DRV_RESET_TDR
 *       Set if reset is due to TDR
 *
 * - HL_RESET_DEVICE_RELEASE
 * - HL_DRV_RESET_DEV_RELEASE
 *       Set if reset is due to device release
 *
 * - HL_RESET_FW
 * - HL_DRV_RESET_BYPASS_REQ_TO_FW
 *       F/W will perform the reset. No need to ask it to reset the device. This is relevant
 *       only when running with secured f/w
 *
 * - HL_RESET_FW_FATAL_ERR
 * - HL_DRV_RESET_FW_FATAL_ERR
 *       Set if reset is due to a fatal error from FW
 */

#define HL_RESET_HARD			(1 << 0)
#define HL_RESET_FROM_RESET_THREAD	(1 << 1)
#define HL_RESET_HEARTBEAT		(1 << 2)
#define HL_RESET_TDR			(1 << 3)
#define HL_RESET_DEVICE_RELEASE		(1 << 4)
#define HL_RESET_FW			(1 << 5)
#define HL_RESET_FW_FATAL_ERR		(1 << 6)
#define HL_DRV_RESET_HARD		(1 << 0)
#define HL_DRV_RESET_FROM_RESET_THR	(1 << 1)
#define HL_DRV_RESET_HEARTBEAT		(1 << 2)
#define HL_DRV_RESET_TDR		(1 << 3)
#define HL_DRV_RESET_DEV_RELEASE	(1 << 4)
#define HL_DRV_RESET_BYPASS_REQ_TO_FW	(1 << 5)
#define HL_DRV_RESET_FW_FATAL_ERR	(1 << 6)

#define HL_MAX_SOBS_PER_MONITOR	8

+1 −1
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ static int free_phys_pg_pack(struct hl_device *hdev,
	}

	if (rc && !hdev->disabled)
		hl_device_reset(hdev, HL_RESET_HARD);
		hl_device_reset(hdev, HL_DRV_RESET_HARD);

end:
	kvfree(phys_pg_pack->pages);
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ static ssize_t hard_reset_store(struct device *dev,

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

	hl_device_reset(hdev, HL_RESET_HARD);
	hl_device_reset(hdev, HL_DRV_RESET_HARD);

out:
	return count;
Loading