Skip to content

Commit 583f12a

Browse files
ofirbittogabbay
authored andcommitted
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: Ofir Bitton <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent b2d61fe commit 583f12a

File tree

11 files changed

+26
-232
lines changed

11 files changed

+26
-232
lines changed

drivers/accel/habanalabs/common/command_buffer.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ static int cb_map_mem(struct hl_ctx *ctx, struct hl_cb *cb)
2727
return -EINVAL;
2828
}
2929

30-
if (!hdev->mmu_enable) {
31-
dev_err_ratelimited(hdev->dev,
32-
"Cannot map CB because MMU is disabled\n");
33-
return -EINVAL;
34-
}
35-
3630
if (cb->is_mmu_mapped)
3731
return 0;
3832

drivers/accel/habanalabs/common/command_submission.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,8 @@ bool cs_needs_timeout(struct hl_cs *cs)
280280

281281
static bool is_cb_patched(struct hl_device *hdev, struct hl_cs_job *job)
282282
{
283-
/*
284-
* Patched CB is created for external queues jobs, and for H/W queues
285-
* jobs if the user CB was allocated by driver and MMU is disabled.
286-
*/
287-
return (job->queue_type == QUEUE_TYPE_EXT ||
288-
(job->queue_type == QUEUE_TYPE_HW &&
289-
job->is_kernel_allocated_cb &&
290-
!hdev->mmu_enable));
283+
/* Patched CB is created for external queues jobs */
284+
return (job->queue_type == QUEUE_TYPE_EXT);
291285
}
292286

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

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

1954-
cb = hl_cb_kernel_create(hdev, cb_size,
1955-
q_type == QUEUE_TYPE_HW && hdev->mmu_enable);
1947+
cb = hl_cb_kernel_create(hdev, cb_size, q_type == QUEUE_TYPE_HW);
19561948
if (!cb) {
19571949
atomic64_inc(&ctx->cs_counters.out_of_mem_drop_cnt);
19581950
atomic64_inc(&cntr->out_of_mem_drop_cnt);

drivers/accel/habanalabs/common/debugfs.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,6 @@ static int vm_show(struct seq_file *s, void *data)
255255
u64 j;
256256
int i;
257257

258-
if (!dev_entry->hdev->mmu_enable)
259-
return 0;
260-
261258
mutex_lock(&dev_entry->ctx_mem_hash_mutex);
262259

263260
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)
436433
u64 virt_addr = dev_entry->mmu_addr, phys_addr;
437434
int i;
438435

439-
if (!hdev->mmu_enable)
440-
return 0;
441-
442436
if (dev_entry->mmu_asid == HL_KERNEL_ASID_ID)
443437
ctx = hdev->kernel_ctx;
444438
else
@@ -496,9 +490,6 @@ static ssize_t mmu_asid_va_write(struct file *file, const char __user *buf,
496490
char *c;
497491
ssize_t rc;
498492

499-
if (!hdev->mmu_enable)
500-
return count;
501-
502493
if (count > sizeof(kbuf) - 1)
503494
goto err;
504495
if (copy_from_user(kbuf, buf, count))
@@ -535,9 +526,6 @@ static int mmu_ack_error(struct seq_file *s, void *data)
535526
struct hl_device *hdev = dev_entry->hdev;
536527
int rc;
537528

538-
if (!hdev->mmu_enable)
539-
return 0;
540-
541529
if (!dev_entry->mmu_cap_mask) {
542530
dev_err(hdev->dev, "mmu_cap_mask is not set\n");
543531
goto err;
@@ -563,9 +551,6 @@ static ssize_t mmu_ack_error_value_write(struct file *file,
563551
char kbuf[MMU_KBUF_SIZE];
564552
ssize_t rc;
565553

566-
if (!hdev->mmu_enable)
567-
return count;
568-
569554
if (count > sizeof(kbuf) - 1)
570555
goto err;
571556

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

664-
if (!hdev->mmu_enable)
665-
goto out;
666-
667649
if (prop->dram_supports_virtual_memory &&
668650
(addr >= prop->dmmu.start_addr && addr < prop->dmmu.end_addr))
669651
return true;
@@ -675,7 +657,7 @@ static bool hl_is_device_va(struct hl_device *hdev, u64 addr)
675657
if (addr >= prop->pmmu_huge.start_addr &&
676658
addr < prop->pmmu_huge.end_addr)
677659
return true;
678-
out:
660+
679661
return false;
680662
}
681663

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

688-
if (!hdev->mmu_enable)
689-
return false;
690-
691670
if (prop->dram_supports_virtual_memory) {
692671
dram_start_addr = prop->dmmu.start_addr;
693672
dram_end_addr = prop->dmmu.end_addr;

drivers/accel/habanalabs/common/habanalabs.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,6 @@ enum hl_mmu_page_table_location {
115115
MMU_NUM_PGT_LOCATIONS /* num of PGT locations */
116116
};
117117

118-
/**
119-
* enum hl_mmu_enablement - what mmu modules to enable
120-
* @MMU_EN_NONE: mmu disabled.
121-
* @MMU_EN_ALL: enable all.
122-
* @MMU_EN_PMMU_ONLY: Enable only the PMMU leaving the DMMU disabled.
123-
*/
124-
enum hl_mmu_enablement {
125-
MMU_EN_NONE = 0,
126-
MMU_EN_ALL = 1,
127-
MMU_EN_PMMU_ONLY = 3, /* N/A for Goya/Gaudi */
128-
};
129-
130118
/*
131119
* HL_RSVD_SOBS 'sync stream' reserved sync objects per QMAN stream
132120
* HL_RSVD_MONS 'sync stream' reserved monitors per QMAN stream
@@ -3319,7 +3307,7 @@ struct hl_reset_info {
33193307
* @nic_ports_mask: Controls which NIC ports are enabled. Used only for testing.
33203308
* @fw_components: Controls which f/w components to load to the device. There are multiple f/w
33213309
* stages and sometimes we want to stop at a certain stage. Used only for testing.
3322-
* @mmu_enable: Whether to enable or disable the device MMU(s). Used only for testing.
3310+
* @mmu_disable: Disable the device MMU(s). Used only for testing.
33233311
* @cpu_queues_enable: Whether to enable queues communication vs. the f/w. Used only for testing.
33243312
* @pldm: Whether we are running in Palladium environment. Used only for testing.
33253313
* @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 {
34823470
/* Parameters for bring-up to be upstreamed */
34833471
u64 nic_ports_mask;
34843472
u64 fw_components;
3485-
u8 mmu_enable;
3473+
u8 mmu_disable;
34863474
u8 cpu_queues_enable;
34873475
u8 pldm;
34883476
u8 hard_reset_on_fw_events;
@@ -3827,8 +3815,6 @@ struct pgt_info *hl_mmu_hr_get_alloc_next_hop(struct hl_ctx *ctx,
38273815
u64 curr_pte, bool *is_new_hop);
38283816
int hl_mmu_hr_get_tlb_info(struct hl_ctx *ctx, u64 virt_addr, struct hl_mmu_hop_info *hops,
38293817
struct hl_hr_mmu_funcs *hr_func);
3830-
void hl_mmu_swap_out(struct hl_ctx *ctx);
3831-
void hl_mmu_swap_in(struct hl_ctx *ctx);
38323818
int hl_mmu_if_set_funcs(struct hl_device *hdev);
38333819
void hl_mmu_v1_set_funcs(struct hl_device *hdev, struct hl_mmu_funcs *mmu);
38343820
void hl_mmu_v2_hr_set_funcs(struct hl_device *hdev, struct hl_mmu_funcs *mmu);

drivers/accel/habanalabs/common/habanalabs_drv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ static void set_driver_behavior_per_device(struct hl_device *hdev)
307307
{
308308
hdev->nic_ports_mask = 0;
309309
hdev->fw_components = FW_TYPE_ALL_TYPES;
310-
hdev->mmu_enable = MMU_EN_ALL;
311310
hdev->cpu_queues_enable = 1;
312311
hdev->pldm = 0;
313312
hdev->hard_reset_on_fw_events = 1;
@@ -382,7 +381,6 @@ static int fixup_device_params(struct hl_device *hdev)
382381
/* If CPU queues not enabled, no way to do heartbeat */
383382
if (!hdev->cpu_queues_enable)
384383
hdev->heartbeat = 0;
385-
386384
fixup_device_params_per_asic(hdev, tmp_timeout);
387385

388386
return 0;

drivers/accel/habanalabs/common/habanalabs_ioctl.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
6262
hw_ip.device_id = hdev->asic_funcs->get_pci_id(hdev);
6363
hw_ip.sram_base_address = prop->sram_user_base_address;
6464
hw_ip.dram_base_address =
65-
hdev->mmu_enable && prop->dram_supports_virtual_memory ?
65+
prop->dram_supports_virtual_memory ?
6666
prop->dmmu.start_addr : prop->dram_user_base_address;
6767
hw_ip.tpc_enabled_mask = prop->tpc_enabled_mask & 0xFF;
6868
hw_ip.tpc_enabled_mask_ext = prop->tpc_enabled_mask;
@@ -71,11 +71,8 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
7171

7272
dram_available_size = prop->dram_size - dram_kmd_size;
7373

74-
if (hdev->mmu_enable == MMU_EN_ALL)
75-
hw_ip.dram_size = DIV_ROUND_DOWN_ULL(dram_available_size,
76-
prop->dram_page_size) * prop->dram_page_size;
77-
else
78-
hw_ip.dram_size = dram_available_size;
74+
hw_ip.dram_size = DIV_ROUND_DOWN_ULL(dram_available_size, prop->dram_page_size) *
75+
prop->dram_page_size;
7976

8077
if (hw_ip.dram_size > PAGE_SIZE)
8178
hw_ip.dram_enabled = 1;

drivers/accel/habanalabs/common/memory.c

Lines changed: 2 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,30 +1034,6 @@ static void unmap_phys_pg_pack(struct hl_ctx *ctx, u64 vaddr,
10341034
}
10351035
}
10361036

1037-
static int get_paddr_from_handle(struct hl_ctx *ctx, struct hl_mem_in *args,
1038-
u64 *paddr)
1039-
{
1040-
struct hl_device *hdev = ctx->hdev;
1041-
struct hl_vm *vm = &hdev->vm;
1042-
struct hl_vm_phys_pg_pack *phys_pg_pack;
1043-
u32 handle;
1044-
1045-
handle = lower_32_bits(args->map_device.handle);
1046-
spin_lock(&vm->idr_lock);
1047-
phys_pg_pack = idr_find(&vm->phys_pg_pack_handles, handle);
1048-
if (!phys_pg_pack) {
1049-
spin_unlock(&vm->idr_lock);
1050-
dev_err(hdev->dev, "no match for handle %u\n", handle);
1051-
return -EINVAL;
1052-
}
1053-
1054-
*paddr = phys_pg_pack->pages[0];
1055-
1056-
spin_unlock(&vm->idr_lock);
1057-
1058-
return 0;
1059-
}
1060-
10611037
/**
10621038
* map_device_va() - map the given memory.
10631039
* @ctx: pointer to the context structure.
@@ -2094,76 +2070,6 @@ static int export_dmabuf_from_addr(struct hl_ctx *ctx, u64 addr, u64 size, u64 o
20942070
return rc;
20952071
}
20962072

2097-
static int mem_ioctl_no_mmu(struct hl_fpriv *hpriv, union hl_mem_args *args)
2098-
{
2099-
struct hl_device *hdev = hpriv->hdev;
2100-
u64 block_handle, device_addr = 0;
2101-
struct hl_ctx *ctx = hpriv->ctx;
2102-
u32 handle = 0, block_size;
2103-
int rc;
2104-
2105-
switch (args->in.op) {
2106-
case HL_MEM_OP_ALLOC:
2107-
if (args->in.alloc.mem_size == 0) {
2108-
dev_err(hdev->dev, "alloc size must be larger than 0\n");
2109-
rc = -EINVAL;
2110-
goto out;
2111-
}
2112-
2113-
/* Force contiguous as there are no real MMU
2114-
* translations to overcome physical memory gaps
2115-
*/
2116-
args->in.flags |= HL_MEM_CONTIGUOUS;
2117-
rc = alloc_device_memory(ctx, &args->in, &handle);
2118-
2119-
memset(args, 0, sizeof(*args));
2120-
args->out.handle = (__u64) handle;
2121-
break;
2122-
2123-
case HL_MEM_OP_FREE:
2124-
rc = free_device_memory(ctx, &args->in);
2125-
break;
2126-
2127-
case HL_MEM_OP_MAP:
2128-
if (args->in.flags & HL_MEM_USERPTR) {
2129-
dev_err(hdev->dev, "Failed to map host memory when MMU is disabled\n");
2130-
rc = -EPERM;
2131-
} else {
2132-
rc = get_paddr_from_handle(ctx, &args->in, &device_addr);
2133-
memset(args, 0, sizeof(*args));
2134-
args->out.device_virt_addr = device_addr;
2135-
}
2136-
2137-
break;
2138-
2139-
case HL_MEM_OP_UNMAP:
2140-
rc = 0;
2141-
break;
2142-
2143-
case HL_MEM_OP_MAP_BLOCK:
2144-
rc = map_block(hdev, args->in.map_block.block_addr, &block_handle, &block_size);
2145-
args->out.block_handle = block_handle;
2146-
args->out.block_size = block_size;
2147-
break;
2148-
2149-
case HL_MEM_OP_EXPORT_DMABUF_FD:
2150-
dev_err(hdev->dev, "Failed to export dma-buf object when MMU is disabled\n");
2151-
rc = -EPERM;
2152-
break;
2153-
2154-
case HL_MEM_OP_TS_ALLOC:
2155-
rc = allocate_timestamps_buffers(hpriv, &args->in, &args->out.handle);
2156-
break;
2157-
default:
2158-
dev_err(hdev->dev, "Unknown opcode for memory IOCTL\n");
2159-
rc = -EINVAL;
2160-
break;
2161-
}
2162-
2163-
out:
2164-
return rc;
2165-
}
2166-
21672073
static void ts_buff_release(struct hl_mmap_mem_buf *buf)
21682074
{
21692075
struct hl_ts_buff *ts_buff = buf->private;
@@ -2282,9 +2188,6 @@ int hl_mem_ioctl(struct hl_fpriv *hpriv, void *data)
22822188
return -EBUSY;
22832189
}
22842190

2285-
if (!hdev->mmu_enable)
2286-
return mem_ioctl_no_mmu(hpriv, args);
2287-
22882191
switch (args->in.op) {
22892192
case HL_MEM_OP_ALLOC:
22902193
if (args->in.alloc.mem_size == 0) {
@@ -2779,13 +2682,10 @@ int hl_vm_ctx_init(struct hl_ctx *ctx)
27792682
atomic64_set(&ctx->dram_phys_mem, 0);
27802683

27812684
/*
2782-
* - If MMU is enabled, init the ranges as usual.
2783-
* - If MMU is disabled, in case of host mapping, the returned address
2784-
* is the given one.
27852685
* In case of DRAM mapping, the returned address is the physical
27862686
* address of the memory related to the given handle.
27872687
*/
2788-
if (!ctx->hdev->mmu_enable)
2688+
if (ctx->hdev->mmu_disable)
27892689
return 0;
27902690

27912691
dram_range_start = prop->dmmu.start_addr;
@@ -2835,7 +2735,7 @@ void hl_vm_ctx_fini(struct hl_ctx *ctx)
28352735
struct hl_mem_in args;
28362736
int i;
28372737

2838-
if (!hdev->mmu_enable)
2738+
if (hdev->mmu_disable)
28392739
return;
28402740

28412741
hl_debugfs_remove_ctx_mem_hash(hdev, ctx);

0 commit comments

Comments
 (0)