Rev 2332 | Rev 2340 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2332 | Rev 2335 | ||
---|---|---|---|
Line 1312... | Line 1312... | ||
1312 | } |
1312 | } |
Line 1313... | Line 1313... | ||
1313 | 1313 | ||
1314 | return 0; |
1314 | return 0; |
Line -... | Line 1315... | ||
- | 1315 | } |
|
- | 1316 | ||
- | 1317 | #if 0 |
|
- | 1318 | int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj, |
|
- | 1319 | enum i915_cache_level cache_level) |
|
Line -... | Line 1320... | ||
- | 1320 | { |
|
- | 1321 | int ret; |
|
Line -... | Line 1322... | ||
- | 1322 | ||
- | 1323 | if (obj->cache_level == cache_level) |
|
- | 1324 | return 0; |
|
- | 1325 | ||
Line -... | Line 1326... | ||
- | 1326 | if (obj->pin_count) { |
|
- | 1327 | DRM_DEBUG("can not change the cache level of pinned objects\n"); |
|
- | 1328 | return -EBUSY; |
|
- | 1329 | } |
|
- | 1330 | ||
- | 1331 | if (obj->gtt_space) { |
|
- | 1332 | ret = i915_gem_object_finish_gpu(obj); |
|
- | 1333 | if (ret) |
|
- | 1334 | return ret; |
|
- | 1335 | ||
- | 1336 | i915_gem_object_finish_gtt(obj); |
|
- | 1337 | ||
- | 1338 | /* Before SandyBridge, you could not use tiling or fence |
|
- | 1339 | * registers with snooped memory, so relinquish any fences |
|
- | 1340 | * currently pointing to our region in the aperture. |
|
- | 1341 | */ |
|
Line -... | Line 1342... | ||
- | 1342 | if (INTEL_INFO(obj->base.dev)->gen < 6) { |
|
- | 1343 | ret = i915_gem_object_put_fence(obj); |
|
Line -... | Line 1344... | ||
- | 1344 | if (ret) |
|
- | 1345 | return ret; |
|
Line -... | Line 1346... | ||
- | 1346 | } |
|
- | 1347 | ||
- | 1348 | i915_gem_gtt_rebind_object(obj, cache_level); |
|
- | 1349 | } |
|
- | 1350 | ||
- | 1351 | if (cache_level == I915_CACHE_NONE) { |
|
- | 1352 | u32 old_read_domains, old_write_domain; |
|
- | 1353 | ||
- | 1354 | /* If we're coming from LLC cached, then we haven't |
|
- | 1355 | * actually been tracking whether the data is in the |
|
- | 1356 | * CPU cache or not, since we only allow one bit set |
|
- | 1357 | * in obj->write_domain and have been skipping the clflushes. |
|
- | 1358 | * Just set it to the CPU cache for now. |
|
- | 1359 | */ |
|
- | 1360 | WARN_ON(obj->base.write_domain & ~I915_GEM_DOMAIN_CPU); |
|
- | 1361 | WARN_ON(obj->base.read_domains & ~I915_GEM_DOMAIN_CPU); |
|
- | 1362 | ||
- | 1363 | old_read_domains = obj->base.read_domains; |
|
- | 1364 | old_write_domain = obj->base.write_domain; |
|
Line -... | Line 1365... | ||
- | 1365 | ||
- | 1366 | obj->base.read_domains = I915_GEM_DOMAIN_CPU; |
|
- | 1367 | obj->base.write_domain = I915_GEM_DOMAIN_CPU; |
|
- | 1368 | ||
Line -... | Line 1369... | ||
- | 1369 | trace_i915_gem_object_change_domain(obj, |
|
- | 1370 | old_read_domains, |
|
- | 1371 | old_write_domain); |
|
- | 1372 | } |
|
- | 1373 | ||
- | 1374 | obj->cache_level = cache_level; |
|
- | 1375 | return 0; |
|
- | 1376 | } |
|
- | 1377 | #endif |
|
- | 1378 | ||
- | 1379 | /* |
|
- | 1380 | * Prepare buffer for display plane (scanout, cursors, etc). |
|
- | 1381 | * Can be called from an uninterruptible phase (modesetting) and allows |
|
- | 1382 | * any flushes to be pipelined (for pageflips). |
|
- | 1383 | * |
|
- | 1384 | * For the display plane, we want to be in the GTT but out of any write |
|
- | 1385 | * domains. So in many ways this looks like set_to_gtt_domain() apart from the |
|
- | 1386 | * ability to pipeline the waits, pinning and any additional subtleties |
|
- | 1387 | * that may differentiate the display plane from ordinary buffers. |
|
- | 1388 | */ |
|
- | 1389 | int |
|
- | 1390 | i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, |
|
- | 1391 | u32 alignment, |
|
- | 1392 | struct intel_ring_buffer *pipelined) |
|
- | 1393 | { |
|
- | 1394 | u32 old_read_domains, old_write_domain; |
|
- | 1395 | int ret; |
|
Line -... | Line 1396... | ||
- | 1396 | ||
- | 1397 | ret = i915_gem_object_flush_gpu_write_domain(obj); |
|
- | 1398 | if (ret) |
|
- | 1399 | return ret; |
|
- | 1400 | ||
- | 1401 | if (pipelined != obj->ring) { |
|
- | 1402 | ret = i915_gem_object_wait_rendering(obj); |
|
- | 1403 | if (ret == -ERESTARTSYS) |
|
- | 1404 | return ret; |
|
- | 1405 | } |
|
- | 1406 | ||
- | 1407 | /* The display engine is not coherent with the LLC cache on gen6. As |
|
- | 1408 | * a result, we make sure that the pinning that is about to occur is |
|
- | 1409 | * done with uncached PTEs. This is lowest common denominator for all |
|
- | 1410 | * chipsets. |
|
- | 1411 | * |
|
- | 1412 | * However for gen6+, we could do better by using the GFDT bit instead |
|
- | 1413 | * of uncaching, which would allow us to flush all the LLC-cached data |
|
- | 1414 | * with that bit in the PTE to main memory with just one PIPE_CONTROL. |
|
- | 1415 | */ |
|
- | 1416 | // ret = i915_gem_object_set_cache_level(obj, I915_CACHE_NONE); |
|
- | 1417 | // if (ret) |
|
- | 1418 | // return ret; |
|
- | 1419 | ||
- | 1420 | /* As the user may map the buffer once pinned in the display plane |
|
- | 1421 | * (e.g. libkms for the bootup splash), we have to ensure that we |
|
- | 1422 | * always use map_and_fenceable for all scanout buffers. |
|
- | 1423 | */ |
|
- | 1424 | ret = i915_gem_object_pin(obj, alignment, true); |
|
- | 1425 | if (ret) |
|
- | 1426 | return ret; |
|
- | 1427 | ||
- | 1428 | i915_gem_object_flush_cpu_write_domain(obj); |
|
- | 1429 | ||
- | 1430 | old_write_domain = obj->base.write_domain; |
|
Line 1315... | Line 1431... | ||
1315 | } |
1431 | old_read_domains = obj->base.read_domains; |
1316 | 1432 | ||
1317 | - | ||
1318 | - | ||
1319 | - | ||
1320 | - | ||
1321 | - | ||
1322 | - | ||
1323 | - | ||
1324 | - |