Commit 4745b2f0 authored by farah kassabri's avatar farah kassabri Committed by Oded Gabbay
Browse files

habanalabs: send device active message to f/w



As part of the RAS that is done by the f/w, we should send a message
to the f/w when a user either acquires or releases the device.

Signed-off-by: default avatarfarah kassabri <fkassabri@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 0855bf8b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -470,6 +470,8 @@ static int hl_device_release(struct inode *inode, struct file *filp)
	hdev->last_open_session_duration_jif =
		jiffies - hdev->last_successful_open_jif;

	hdev->asic_funcs->send_device_activity(hdev, false);

	return 0;
}

+15 −0
Original line number Diff line number Diff line
@@ -454,6 +454,21 @@ void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size,
			size);
}

int hl_fw_send_device_activity(struct hl_device *hdev, bool open)
{
	struct cpucp_packet pkt;
	int rc;

	memset(&pkt, 0, sizeof(pkt));
	pkt.ctl = cpu_to_le32(CPUCP_PACKET_ACTIVE_STATUS_SET <<	CPUCP_PKT_CTL_OPCODE_SHIFT);
	pkt.value = cpu_to_le64(open);
	rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL);
	if (rc)
		dev_err(hdev->dev, "failed to send device activity msg(%u)\n", open);

	return rc;
}

int hl_fw_send_heartbeat(struct hl_device *hdev)
{
	struct cpucp_packet hb_pkt;
+3 −0
Original line number Diff line number Diff line
@@ -1528,6 +1528,7 @@ struct engines_data {
 * @access_dev_mem: access device memory
 * @set_dram_bar_base: set the base of the DRAM BAR
 * @set_engine_cores: set a config command to enigne cores
 * @send_device_activity: indication to FW about device availability
 */
struct hl_asic_funcs {
	int (*early_init)(struct hl_device *hdev);
@@ -1664,6 +1665,7 @@ struct hl_asic_funcs {
	u64 (*set_dram_bar_base)(struct hl_device *hdev, u64 addr);
	int (*set_engine_cores)(struct hl_device *hdev, u32 *core_ids,
					u32 num_cores, u32 core_command);
	int (*send_device_activity)(struct hl_device *hdev, bool open);
};


@@ -3715,6 +3717,7 @@ int hl_fw_dram_replaced_row_get(struct hl_device *hdev,
				struct cpucp_hbm_row_info *info);
int hl_fw_dram_pending_row_get(struct hl_device *hdev, u32 *pend_rows_num);
int hl_fw_cpucp_engine_core_asid_set(struct hl_device *hdev, u32 asid);
int hl_fw_send_device_activity(struct hl_device *hdev, bool open);
int hl_pci_bars_map(struct hl_device *hdev, const char * const name[3],
			bool is_wc[3]);
int hl_pci_elbi_read(struct hl_device *hdev, u64 addr, u32 *data);
+2 −0
Original line number Diff line number Diff line
@@ -204,6 +204,8 @@ int hl_device_open(struct inode *inode, struct file *filp)
		goto out_err;
	}

	rc = hdev->asic_funcs->send_device_activity(hdev, true);

	list_add(&hpriv->dev_node, &hdev->fpriv_list);
	mutex_unlock(&hdev->fpriv_list_lock);

+6 −0
Original line number Diff line number Diff line
@@ -9132,6 +9132,11 @@ static void gaudi_add_device_attr(struct hl_device *hdev, struct attribute_group
	dev_vrm_attr_grp->attrs = gaudi_vrm_dev_attrs;
}

static int gaudi_send_device_activity(struct hl_device *hdev, bool open)
{
	return 0;
}

static const struct hl_asic_funcs gaudi_funcs = {
	.early_init = gaudi_early_init,
	.early_fini = gaudi_early_fini,
@@ -9224,6 +9229,7 @@ static const struct hl_asic_funcs gaudi_funcs = {
	.mmu_get_real_page_size = hl_mmu_get_real_page_size,
	.access_dev_mem = hl_access_dev_mem,
	.set_dram_bar_base = gaudi_set_hbm_bar_base,
	.send_device_activity = gaudi_send_device_activity,
};

/**
Loading