Commit 583f12a8 authored by Ofir Bitton's avatar Ofir Bitton Committed by Oded Gabbay
Browse files

accel/habanalabs: remove support for mmu disable



As mmu disable mode is only used for bring-up stages, let's remove this
option and all code related to it.

Signed-off-by: default avatarOfir Bitton <obitton@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent b2d61fec
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -27,12 +27,6 @@ static int cb_map_mem(struct hl_ctx *ctx, struct hl_cb *cb)
		return -EINVAL;
	}

	if (!hdev->mmu_enable) {
		dev_err_ratelimited(hdev->dev,
				"Cannot map CB because MMU is disabled\n");
		return -EINVAL;
	}

	if (cb->is_mmu_mapped)
		return 0;

+7 −15
Original line number Diff line number Diff line
@@ -280,14 +280,8 @@ bool cs_needs_timeout(struct hl_cs *cs)

static bool is_cb_patched(struct hl_device *hdev, struct hl_cs_job *job)
{
	/*
	 * Patched CB is created for external queues jobs, and for H/W queues
	 * jobs if the user CB was allocated by driver and MMU is disabled.
	 */
	return (job->queue_type == QUEUE_TYPE_EXT ||
			(job->queue_type == QUEUE_TYPE_HW &&
					job->is_kernel_allocated_cb &&
					!hdev->mmu_enable));
	/* Patched CB is created for external queues jobs */
	return (job->queue_type == QUEUE_TYPE_EXT);
}

/*
@@ -363,14 +357,13 @@ static void hl_complete_job(struct hl_device *hdev, struct hl_cs_job *job)
		}
	}

	/* For H/W queue jobs, if a user CB was allocated by driver and MMU is
	 * enabled, the user CB isn't released in cs_parser() and thus should be
	/* For H/W queue jobs, if a user CB was allocated by driver,
	 * the user CB isn't released in cs_parser() and thus should be
	 * released here. This is also true for INT queues jobs which were
	 * allocated by driver.
	 */
	if ((job->is_kernel_allocated_cb &&
		((job->queue_type == QUEUE_TYPE_HW && hdev->mmu_enable) ||
				job->queue_type == QUEUE_TYPE_INT))) {
	if (job->is_kernel_allocated_cb &&
			(job->queue_type == QUEUE_TYPE_HW || job->queue_type == QUEUE_TYPE_INT)) {
		atomic_dec(&job->user_cb->cs_cnt);
		hl_cb_put(job->user_cb);
	}
@@ -1951,8 +1944,7 @@ static int cs_ioctl_signal_wait_create_jobs(struct hl_device *hdev,
	else
		cb_size = hdev->asic_funcs->get_signal_cb_size(hdev);

	cb = hl_cb_kernel_create(hdev, cb_size,
				q_type == QUEUE_TYPE_HW && hdev->mmu_enable);
	cb = hl_cb_kernel_create(hdev, cb_size, q_type == QUEUE_TYPE_HW);
	if (!cb) {
		atomic64_inc(&ctx->cs_counters.out_of_mem_drop_cnt);
		atomic64_inc(&cntr->out_of_mem_drop_cnt);
+1 −22
Original line number Diff line number Diff line
@@ -255,9 +255,6 @@ static int vm_show(struct seq_file *s, void *data)
	u64 j;
	int i;

	if (!dev_entry->hdev->mmu_enable)
		return 0;

	mutex_lock(&dev_entry->ctx_mem_hash_mutex);

	list_for_each_entry(ctx, &dev_entry->ctx_mem_hash_list, debugfs_list) {
@@ -436,9 +433,6 @@ static int mmu_show(struct seq_file *s, void *data)
	u64 virt_addr = dev_entry->mmu_addr, phys_addr;
	int i;

	if (!hdev->mmu_enable)
		return 0;

	if (dev_entry->mmu_asid == HL_KERNEL_ASID_ID)
		ctx = hdev->kernel_ctx;
	else
@@ -496,9 +490,6 @@ static ssize_t mmu_asid_va_write(struct file *file, const char __user *buf,
	char *c;
	ssize_t rc;

	if (!hdev->mmu_enable)
		return count;

	if (count > sizeof(kbuf) - 1)
		goto err;
	if (copy_from_user(kbuf, buf, count))
@@ -535,9 +526,6 @@ static int mmu_ack_error(struct seq_file *s, void *data)
	struct hl_device *hdev = dev_entry->hdev;
	int rc;

	if (!hdev->mmu_enable)
		return 0;

	if (!dev_entry->mmu_cap_mask) {
		dev_err(hdev->dev, "mmu_cap_mask is not set\n");
		goto err;
@@ -563,9 +551,6 @@ static ssize_t mmu_ack_error_value_write(struct file *file,
	char kbuf[MMU_KBUF_SIZE];
	ssize_t rc;

	if (!hdev->mmu_enable)
		return count;

	if (count > sizeof(kbuf) - 1)
		goto err;

@@ -661,9 +646,6 @@ static bool hl_is_device_va(struct hl_device *hdev, u64 addr)
{
	struct asic_fixed_properties *prop = &hdev->asic_prop;

	if (!hdev->mmu_enable)
		goto out;

	if (prop->dram_supports_virtual_memory &&
		(addr >= prop->dmmu.start_addr && addr < prop->dmmu.end_addr))
		return true;
@@ -675,7 +657,7 @@ static bool hl_is_device_va(struct hl_device *hdev, u64 addr)
	if (addr >= prop->pmmu_huge.start_addr &&
		addr < prop->pmmu_huge.end_addr)
		return true;
out:

	return false;
}

@@ -685,9 +667,6 @@ static bool hl_is_device_internal_memory_va(struct hl_device *hdev, u64 addr,
	struct asic_fixed_properties *prop = &hdev->asic_prop;
	u64 dram_start_addr, dram_end_addr;

	if (!hdev->mmu_enable)
		return false;

	if (prop->dram_supports_virtual_memory) {
		dram_start_addr = prop->dmmu.start_addr;
		dram_end_addr = prop->dmmu.end_addr;
+2 −16
Original line number Diff line number Diff line
@@ -115,18 +115,6 @@ enum hl_mmu_page_table_location {
	MMU_NUM_PGT_LOCATIONS	/* num of PGT locations */
};

/**
 * enum hl_mmu_enablement - what mmu modules to enable
 * @MMU_EN_NONE: mmu disabled.
 * @MMU_EN_ALL: enable all.
 * @MMU_EN_PMMU_ONLY: Enable only the PMMU leaving the DMMU disabled.
 */
enum hl_mmu_enablement {
	MMU_EN_NONE = 0,
	MMU_EN_ALL = 1,
	MMU_EN_PMMU_ONLY = 3,	/* N/A for Goya/Gaudi */
};

/*
 * HL_RSVD_SOBS 'sync stream' reserved sync objects per QMAN stream
 * HL_RSVD_MONS 'sync stream' reserved monitors per QMAN stream
@@ -3319,7 +3307,7 @@ struct hl_reset_info {
 * @nic_ports_mask: Controls which NIC ports are enabled. Used only for testing.
 * @fw_components: Controls which f/w components to load to the device. There are multiple f/w
 *                 stages and sometimes we want to stop at a certain stage. Used only for testing.
 * @mmu_enable: Whether to enable or disable the device MMU(s). Used only for testing.
 * @mmu_disable: Disable the device MMU(s). Used only for testing.
 * @cpu_queues_enable: Whether to enable queues communication vs. the f/w. Used only for testing.
 * @pldm: Whether we are running in Palladium environment. Used only for testing.
 * @hard_reset_on_fw_events: Whether to do device hard-reset when a fatal event is received from
@@ -3482,7 +3470,7 @@ struct hl_device {
	/* Parameters for bring-up to be upstreamed */
	u64				nic_ports_mask;
	u64				fw_components;
	u8				mmu_enable;
	u8				mmu_disable;
	u8				cpu_queues_enable;
	u8				pldm;
	u8				hard_reset_on_fw_events;
@@ -3827,8 +3815,6 @@ struct pgt_info *hl_mmu_hr_get_alloc_next_hop(struct hl_ctx *ctx,
							u64 curr_pte, bool *is_new_hop);
int hl_mmu_hr_get_tlb_info(struct hl_ctx *ctx, u64 virt_addr, struct hl_mmu_hop_info *hops,
							struct hl_hr_mmu_funcs *hr_func);
void hl_mmu_swap_out(struct hl_ctx *ctx);
void hl_mmu_swap_in(struct hl_ctx *ctx);
int hl_mmu_if_set_funcs(struct hl_device *hdev);
void hl_mmu_v1_set_funcs(struct hl_device *hdev, struct hl_mmu_funcs *mmu);
void hl_mmu_v2_hr_set_funcs(struct hl_device *hdev, struct hl_mmu_funcs *mmu);
+0 −2
Original line number Diff line number Diff line
@@ -307,7 +307,6 @@ static void set_driver_behavior_per_device(struct hl_device *hdev)
{
	hdev->nic_ports_mask = 0;
	hdev->fw_components = FW_TYPE_ALL_TYPES;
	hdev->mmu_enable = MMU_EN_ALL;
	hdev->cpu_queues_enable = 1;
	hdev->pldm = 0;
	hdev->hard_reset_on_fw_events = 1;
@@ -382,7 +381,6 @@ static int fixup_device_params(struct hl_device *hdev)
	/* If CPU queues not enabled, no way to do heartbeat */
	if (!hdev->cpu_queues_enable)
		hdev->heartbeat = 0;

	fixup_device_params_per_asic(hdev, tmp_timeout);

	return 0;
Loading