History

drm/amdgpu: vm_update_ptes remove code duplication

CPU and GPU paths were mostly the same.

Harish Kasiviswanathan committed 9 years ago

Commit 370f0921 parent 0ad6f0d1 file · +16 −57Browse files

Unified · Split

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c+16−57
@@ -1263,59 +1263,6 @@ static struct amdgpu_bo *amdgpu_vm_get_pt(struct amdgpu_pte_update_params *p, · 1262 unmodified lines
12631263 return entry->bo;
12641264 }
12651265
1266−/**
1267− * amdgpu_vm_update_ptes_cpu - Update the page tables in the range
1268− * start - @end using CPU.
1269− * See amdgpu_vm_update_ptes for parameter description.
1270− *
1271− */
1272−static int amdgpu_vm_update_ptes_cpu(struct amdgpu_pte_update_params *params,
1273− uint64_t start, uint64_t end,
1274− uint64_t dst, uint64_t flags)
1275−{
1276− struct amdgpu_device *adev = params->adev;
1277− const uint64_t mask = AMDGPU_VM_PTE_COUNT(adev) - 1;
1278− void *pe_ptr;
1279− uint64_t addr;
1280− struct amdgpu_bo *pt;
1281− unsigned int nptes;
1282− int r;
1283−
1284− /* initialize the variables */
1285− addr = start;
1286−
1287− /* walk over the address space and update the page tables */
1288− while (addr < end) {
1289− pt = amdgpu_vm_get_pt(params, addr);
1290− if (!pt) {
1291− pr_err("PT not found, aborting update_ptes\n");
1292− return -EINVAL;
1293− }
1294−
1295− WARN_ON(params->shadow);
1296−
1297− r = amdgpu_bo_kmap(pt, &pe_ptr);
1298− if (r)
1299− return r;
1300−
1301− pe_ptr += (addr & mask) * 8;
1302−
1303− if ((addr & ~mask) == (end & ~mask))
1304− nptes = end - addr;
1305− else
1306− nptes = AMDGPU_VM_PTE_COUNT(adev) - (addr & mask);
1307−
1308− params->func(params, (uint64_t)pe_ptr, dst, nptes,
1309− AMDGPU_GPU_PAGE_SIZE, flags);
1310−
1311− amdgpu_bo_kunmap(pt);
1312− addr += nptes;
1313− dst += nptes * AMDGPU_GPU_PAGE_SIZE;
1314− }
1315−
1316− return 0;
1317−}
1318−
13191266 /**
13201267 * amdgpu_vm_update_ptes - make sure that page tables are valid
13211268 *
@@ -1339,10 +1286,9 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, · 17 unmodified lines
13391286 uint64_t addr, pe_start;
13401287 struct amdgpu_bo *pt;
13411288 unsigned nptes;
1289+ int r;
1290+ bool use_cpu_update = (params->func == amdgpu_vm_cpu_set_ptes);
13421291
1343− if (params->func == amdgpu_vm_cpu_set_ptes)
1344− return amdgpu_vm_update_ptes_cpu(params, start, end,
1345− dst, flags);
13461292
13471293 /* walk over the address space and update the page tables */
13481294 for (addr = start; addr < end; addr += nptes) {
@@ -1353,6 +1299,10 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, · 4 unmodified lines
13531299 }
13541300
13551301 if (params->shadow) {
1302+ if (WARN_ONCE(use_cpu_update,
1303+ "CPU VM update doesn't suuport shadow pages"))
1304+ return 0;
1305+
13561306 if (!pt->shadow)
13571307 return 0;
13581308 pt = pt->shadow;
@@ -1363,13 +1313,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, · 4 unmodified lines
13631313 else
13641314 nptes = AMDGPU_VM_PTE_COUNT(adev) - (addr & mask);
13651315
1366− pe_start = amdgpu_bo_gpu_offset(pt);
1316+ if (use_cpu_update) {
1317+ r = amdgpu_bo_kmap(pt, (void *)&pe_start);
1318+ if (r)
1319+ return r;
1320+ } else
1321+ pe_start = amdgpu_bo_gpu_offset(pt);
1322+
13671323 pe_start += (addr & mask) * 8;
13681324
13691325 params->func(params, pe_start, dst, nptes,
13701326 AMDGPU_GPU_PAGE_SIZE, flags);
13711327
13721328 dst += nptes * AMDGPU_GPU_PAGE_SIZE;
1329+
1330+ if (use_cpu_update)
1331+ amdgpu_bo_kunmap(pt);
13731332 }
13741333
13751334 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t