libhsakmt: Try to use CPU addr as GPU addr for userptrs

If the CPU addr of a userptr is accessible by the GPU, try to use it
instead of allocating a different GPU address. If something else is
already registered with an overlapping address range, we still need to
allocate a GPU address, because KFD does not support overlapping GPUVM
mappings.

Change-Id: I452963ee45a454f735755a0b43122b9aee5d55be
Signed-off-by: Felix Kuehling <felix.kuehling@gmail.com>


[ROCm/ROCR-Runtime commit: ab181c46c0]
Tento commit je obsažen v:
Felix Kuehling
2018-08-05 13:56:27 -04:00
odevzdal Felix Kuehling
rodič 3dfb956bd5
revize 84bb9072c0
2 změnil soubory, kde provedl 66 přidání a 7 odebrání
+3 -1
Zobrazit soubor
@@ -65,8 +65,10 @@ extern int PAGE_SHIFT;
do { if ((uint64_t)PORT_VPTR_TO_UINT64(x) % PAGE_SIZE) return HSAKMT_STATUS_INVALID_PARAMETER; } while(0)
#define ALIGN_UP(x,align) (((uint64_t)(x) + (align) - 1) & ~(uint64_t)((align)-1))
#define ALIGN_DOWN(x,align) ((uint64_t)(x) & ~(uint64_t)((align)-1))
#define ALIGN_UP_32(x,align) (((uint32_t)(x) + (align) - 1) & ~(uint32_t)((align)-1))
#define PAGE_ALIGN_UP(x) ALIGN_UP(x,PAGE_SIZE)
#define PAGE_ALIGN_UP(x) ALIGN_UP((x),PAGE_SIZE)
#define PAGE_ALIGN_DOWN(x) ALIGN_DOWN((x),PAGE_SIZE)
#define BITMASK(n) (((n) < sizeof(1ULL) * CHAR_BIT ? (1ULL << (n)) : 0) - 1ULL)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))