mirror of https://gitee.com/openkylin/linux.git
habanalabs: move asic property to correct structure
Whether an ASIC has MMU towards its DRAM is an ASIC property, so move it to the asic fixed properties structure. Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
This commit is contained in:
parent
be91b91fa4
commit
7f070c913c
|
@ -598,7 +598,7 @@ static bool hl_is_device_va(struct hl_device *hdev, u64 addr)
|
|||
if (!hdev->mmu_enable)
|
||||
goto out;
|
||||
|
||||
if (hdev->dram_supports_virtual_memory &&
|
||||
if (prop->dram_supports_virtual_memory &&
|
||||
(addr >= prop->dmmu.start_addr && addr < prop->dmmu.end_addr))
|
||||
return true;
|
||||
|
||||
|
|
|
@ -411,6 +411,7 @@ struct hl_mmu_properties {
|
|||
* false otherwise
|
||||
* @fw_security_status_valid: security status bits are valid and can be fetched
|
||||
* from BOOT_DEV_STS0
|
||||
* @dram_supports_virtual_memory: is there an MMU towards the DRAM
|
||||
*/
|
||||
struct asic_fixed_properties {
|
||||
struct hw_queue_properties *hw_queues_props;
|
||||
|
@ -467,6 +468,7 @@ struct asic_fixed_properties {
|
|||
u8 completion_queues_count;
|
||||
u8 fw_security_disabled;
|
||||
u8 fw_security_status_valid;
|
||||
u8 dram_supports_virtual_memory;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1772,7 +1774,6 @@ struct hl_mmu_funcs {
|
|||
* @heartbeat: is heartbeat sanity check towards CPU-CP enabled.
|
||||
* @reset_on_lockup: true if a reset should be done in case of stuck CS, false
|
||||
* otherwise.
|
||||
* @dram_supports_virtual_memory: is MMU enabled towards DRAM.
|
||||
* @dram_default_page_mapping: is DRAM default page mapping enabled.
|
||||
* @memory_scrub: true to perform device memory scrub in various locations,
|
||||
* such as context-switch, context close, page free, etc.
|
||||
|
@ -1886,7 +1887,6 @@ struct hl_device {
|
|||
u8 hard_reset_pending;
|
||||
u8 heartbeat;
|
||||
u8 reset_on_lockup;
|
||||
u8 dram_supports_virtual_memory;
|
||||
u8 dram_default_page_mapping;
|
||||
u8 memory_scrub;
|
||||
u8 pmmu_huge_range;
|
||||
|
|
|
@ -1351,7 +1351,7 @@ int hl_mem_ioctl(struct hl_fpriv *hpriv, void *data)
|
|||
* the user's input, the driver can't ensure the validity
|
||||
* of this accounting.
|
||||
*/
|
||||
if (!hdev->dram_supports_virtual_memory) {
|
||||
if (!hdev->asic_prop.dram_supports_virtual_memory) {
|
||||
atomic64_add(args->in.alloc.mem_size,
|
||||
&ctx->dram_phys_mem);
|
||||
atomic64_add(args->in.alloc.mem_size,
|
||||
|
@ -1380,7 +1380,7 @@ int hl_mem_ioctl(struct hl_fpriv *hpriv, void *data)
|
|||
* the user's input, the driver can't ensure the validity
|
||||
* of this accounting.
|
||||
*/
|
||||
if (!hdev->dram_supports_virtual_memory) {
|
||||
if (!hdev->asic_prop.dram_supports_virtual_memory) {
|
||||
atomic64_sub(args->in.alloc.mem_size,
|
||||
&ctx->dram_phys_mem);
|
||||
atomic64_sub(args->in.alloc.mem_size,
|
||||
|
@ -1915,7 +1915,7 @@ void hl_vm_ctx_fini(struct hl_ctx *ctx)
|
|||
* because the user notifies us on allocations. If the user is no more,
|
||||
* all DRAM is available
|
||||
*/
|
||||
if (!ctx->hdev->dram_supports_virtual_memory)
|
||||
if (!ctx->hdev->asic_prop.dram_supports_virtual_memory)
|
||||
atomic64_set(&ctx->hdev->dram_used_mem, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ static int dram_default_mapping_init(struct hl_ctx *ctx)
|
|||
hop2_pte_addr, hop3_pte_addr, pte_val;
|
||||
int rc, i, j, hop3_allocated = 0;
|
||||
|
||||
if ((!hdev->dram_supports_virtual_memory) ||
|
||||
if ((!prop->dram_supports_virtual_memory) ||
|
||||
(!hdev->dram_default_page_mapping) ||
|
||||
(ctx->asid == HL_KERNEL_ASID_ID))
|
||||
return 0;
|
||||
|
@ -362,7 +362,7 @@ static void dram_default_mapping_fini(struct hl_ctx *ctx)
|
|||
hop2_pte_addr, hop3_pte_addr;
|
||||
int i, j;
|
||||
|
||||
if ((!hdev->dram_supports_virtual_memory) ||
|
||||
if ((!prop->dram_supports_virtual_memory) ||
|
||||
(!hdev->dram_default_page_mapping) ||
|
||||
(ctx->asid == HL_KERNEL_ASID_ID))
|
||||
return;
|
||||
|
|
|
@ -462,6 +462,7 @@ static int gaudi_get_fixed_properties(struct hl_device *hdev)
|
|||
prop->mmu_hop_table_size = HOP_TABLE_SIZE;
|
||||
prop->mmu_hop0_tables_total_size = HOP0_TABLES_TOTAL_SIZE;
|
||||
prop->dram_page_size = PAGE_SIZE_2MB;
|
||||
prop->dram_supports_virtual_memory = false;
|
||||
|
||||
prop->pmmu.hop0_shift = HOP0_SHIFT;
|
||||
prop->pmmu.hop1_shift = HOP1_SHIFT;
|
||||
|
@ -3562,8 +3563,6 @@ static int gaudi_mmu_init(struct hl_device *hdev)
|
|||
if (gaudi->hw_cap_initialized & HW_CAP_MMU)
|
||||
return 0;
|
||||
|
||||
hdev->dram_supports_virtual_memory = false;
|
||||
|
||||
for (i = 0 ; i < prop->max_asid ; i++) {
|
||||
hop0_addr = prop->mmu_pgt_addr +
|
||||
(i * prop->mmu_hop_table_size);
|
||||
|
|
|
@ -410,6 +410,7 @@ int goya_get_fixed_properties(struct hl_device *hdev)
|
|||
prop->mmu_hop_table_size = HOP_TABLE_SIZE;
|
||||
prop->mmu_hop0_tables_total_size = HOP0_TABLES_TOTAL_SIZE;
|
||||
prop->dram_page_size = PAGE_SIZE_2MB;
|
||||
prop->dram_supports_virtual_memory = true;
|
||||
|
||||
prop->dmmu.hop0_shift = HOP0_SHIFT;
|
||||
prop->dmmu.hop1_shift = HOP1_SHIFT;
|
||||
|
@ -2481,7 +2482,6 @@ int goya_mmu_init(struct hl_device *hdev)
|
|||
if (goya->hw_cap_initialized & HW_CAP_MMU)
|
||||
return 0;
|
||||
|
||||
hdev->dram_supports_virtual_memory = true;
|
||||
hdev->dram_default_page_mapping = true;
|
||||
|
||||
for (i = 0 ; i < prop->max_asid ; i++) {
|
||||
|
|
Loading…
Reference in New Issue