Commit 3fc25267 authored by Ohad Sharabi's avatar Ohad Sharabi Committed by Oded Gabbay
Browse files

habanalabs/gaudi2: use DIV_ROUND_UP_SECTOR_T instead of roundup



roundup will create an error in 32-bit architectures as we use
64-bit variables.

Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarOhad Sharabi <osharabi@habana.ai>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent b596ad6f
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1796,10 +1796,10 @@ static int gaudi2_set_dram_properties(struct hl_device *hdev)
	prop->hints_dram_reserved_va_range.start_addr = RESERVED_VA_RANGE_FOR_ARC_ON_HBM_START;
	prop->hints_dram_reserved_va_range.end_addr = RESERVED_VA_RANGE_FOR_ARC_ON_HBM_END;

	/* since DRAM page size differs from dmmu page size we need to allocate
	/* since DRAM page size differs from DMMU page size we need to allocate
	 * DRAM memory in units of dram_page size and mapping this memory in
	 * units of DMMU page size. we overcome this size mismatch using a
	 * scarmbling routine which takes a DRAM page and converts it to a DMMU
	 * scrambling routine which takes a DRAM page and converts it to a DMMU
	 * page.
	 * We therefore:
	 * 1. partition the virtual address space to DRAM-page (whole) pages.
@@ -1814,7 +1814,8 @@ static int gaudi2_set_dram_properties(struct hl_device *hdev)
	 *    the DRAM address MSBs (63:48) are not part of the roundup calculation
	 */
	prop->dmmu.start_addr = prop->dram_base_address +
			roundup(prop->dram_size, prop->dram_page_size);
			(prop->dram_page_size *
				DIV_ROUND_UP_SECTOR_T(prop->dram_size, prop->dram_page_size));

	prop->dmmu.end_addr = prop->dmmu.start_addr + prop->dram_page_size *
			div_u64((VA_HBM_SPACE_END - prop->dmmu.start_addr), prop->dmmu.page_size);