• Felix Kuehling's avatar
    drm/amdkfd: HMM migrate ram to vram · 0b0e518d
    Felix Kuehling authored
    Register svm range with same address and size but perferred_location
    is changed from CPU to GPU or from GPU to CPU, trigger migration the svm
    range from ram to vram or from vram to ram.
    If svm range prefetch location is GPU with flags
    KFD_IOCTL_SVM_FLAG_HOST_ACCESS, validate the svm range on ram first,
    then migrate it from ram to vram.
    After migrating to vram is done, CPU access will have cpu page fault,
    page fault handler migrate it back to ram and resume cpu access.
    Migration steps:
    1. migrate_vma_pages get svm range ram pages, notify the
    interval is invalidated and unmap from CPU page table, HMM interval
    notifier callback evict process queues
    2. Allocate new pages in vram using TTM
    3. Use svm copy memory to sdma copy data from ram to vram
    4. migrate_vma_pages copy ram pages structure to vram pages structure
    5. migrate_vma_finalize put ram pages to free ram pages and memory
    6. Restore work wait for migration is finished, then update GPUs page
    table mapping to new vram pages, resume process queues
    If migrate_vma_setup failed to collect all ram pages of range, retry 3
    times until success to start migration.
    Signed-off-by: Philip Yang's avatarPhilip Yang <Philip.Yang@amd.com>
    Reviewed-by: Felix Kuehling's avatarFelix Kuehling <Felix.Kuehling@amd.com>
    Signed-off-by: Felix Kuehling's avatarFelix Kuehling <Felix.Kuehling@amd.com>
    Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>