89 lines · c
1/* SPDX-License-Identifier: MIT */2/*3 * Copyright © 2022 Intel Corporation4 */5 6#ifndef _XE_MIGRATE_DOC_H_7#define _XE_MIGRATE_DOC_H_8 9/**10 * DOC: Migrate Layer11 *12 * The XE migrate layer is used generate jobs which can copy memory (eviction),13 * clear memory, or program tables (binds). This layer exists in every GT, has14 * a migrate engine, and uses a special VM for all generated jobs.15 *16 * Special VM details17 * ==================18 *19 * The special VM is configured with a page structure where we can dynamically20 * map BOs which need to be copied and cleared, dynamically map other VM's page21 * table BOs for updates, and identity map the entire device's VRAM with 1 GB22 * pages.23 *24 * Currently the page structure consists of 32 physical pages with 16 being25 * reserved for BO mapping during copies and clear, 1 reserved for kernel binds,26 * several pages are needed to setup the identity mappings (exact number based27 * on how many bits of address space the device has), and the rest are reserved28 * user bind operations.29 *30 * TODO: Diagram of layout31 *32 * Bind jobs33 * =========34 *35 * A bind job consist of two batches and runs either on the migrate engine36 * (kernel binds) or the bind engine passed in (user binds). In both cases the37 * VM of the engine is the migrate VM.38 *39 * The first batch is used to update the migration VM page structure to point to40 * the bind VM page table BOs which need to be updated. A physical page is41 * required for this. If it is a user bind, the page is allocated from pool of42 * pages reserved user bind operations with drm_suballoc managing this pool. If43 * it is a kernel bind, the page reserved for kernel binds is used.44 *45 * The first batch is only required for devices without VRAM as when the device46 * has VRAM the bind VM page table BOs are in VRAM and the identity mapping can47 * be used.48 *49 * The second batch is used to program page table updated in the bind VM. Why50 * not just one batch? Well the TLBs need to be invalidated between these two51 * batches and that only can be done from the ring.52 *53 * When the bind job complete, the page allocated is returned the pool of pages54 * reserved for user bind operations if a user bind. No need do this for kernel55 * binds as the reserved kernel page is serially used by each job.56 *57 * Copy / clear jobs58 * =================59 *60 * A copy or clear job consist of two batches and runs on the migrate engine.61 *62 * Like binds, the first batch is used update the migration VM page structure.63 * In copy jobs, we need to map the source and destination of the BO into page64 * the structure. In clear jobs, we just need to add 1 mapping of BO into the65 * page structure. We use the 16 reserved pages in migration VM for mappings,66 * this gives us a maximum copy size of 16 MB and maximum clear size of 32 MB.67 *68 * The second batch is used do either do the copy or clear. Again similar to69 * binds, two batches are required as the TLBs need to be invalidated from the70 * ring between the batches.71 *72 * More than one job will be generated if the BO is larger than maximum copy /73 * clear size.74 *75 * Future work76 * ===========77 *78 * Update copy and clear code to use identity mapped VRAM.79 *80 * Can we rework the use of the pages async binds to use all the entries in each81 * page?82 *83 * Using large pages for sysmem mappings.84 *85 * Is it possible to identity map the sysmem? We should explore this.86 */87 88#endif89