diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-06 11:16:33 -0400 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-06 11:16:33 -0400 | 
| commit | 135c5504a600ff9b06e321694fbcac78a9530cd4 (patch) | |
| tree | 8d22ed739b0e85954010a964a9aeadf3c692c977 /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |
| parent | af6c5d5e01ad9f2c9ca38cccaae6b5d67ddd241f (diff) | |
| parent | 568cf2e6aa0c762f14d2d0d481a006f93c63ab7a (diff) | |
Merge tag 'drm-next-2018-06-06-1' of git://anongit.freedesktop.org/drm/drm
Pull drm updates from Dave Airlie:
 "This starts to support NVIDIA volta hardware with nouveau, and adds
  amdgpu support for the GPU in the Kabylake-G (the intel + radeon
  single package chip), along with some initial Intel icelake enabling.
  Summary:
  New Drivers:
   - v3d - driver for broadcom V3D V3.x+ hardware
   - xen-front - XEN PV display frontend
  core:
   - handle zpos normalization in the core
   - stop looking at legacy pointers in atomic paths
   - improved scheduler documentation
   - improved aspect ratio validation
   - aspect ratio support for 64:27 and 256:135
   - drop unused control node code.
  i915:
   - Icelake (ICL) enabling
   - GuC/HuC refactoring
   - PSR/PSR2 enabling and fixes
   - DPLL management refactoring
   - DP MST fixes
   - NV12 enabling
   - HDCP improvements
   - GEM/Execlist/reset improvements
   - GVT improvements
   - stolen memory first 4k fix
  amdgpu:
   - Vega 20 support
   - VEGAM support (Kabylake-G)
   - preOS scanout buffer reservation
   - power management gfxoff support for raven
   - SR-IOV fixes
   - Vega10 power profiles and clock voltage control
   - scatter/gather display support on CZ/ST
  amdkfd:
   - GFX9 dGPU support
   - userptr memory mapping
  nouveau:
   - major refactoring for Volta GV100 support
  tda998x:
   - HDMI i2c CEC support
  etnaviv:
   - removed unused logging code
   - license text cleanups
   - MMU handling improvements
   - timeout fence fix for 50 days uptime
  tegra:
   - IOMMU support in gr2d/gr3d drivers
   - zpos support
  vc4:
   - syncobj support
   - CTM, plane alpha and async cursor support
  analogix_dp:
   - HPD and aux chan fixes
  sun4i:
   - MIPI DSI support
  tilcdc:
   - clock divider fixes for OMAP-l138 LCDK board
  rcar-du:
   - R8A77965 support
   - dma-buf fences fixes
   - hardware indexed crtc/du group handling
   - generic zplane property support
  atmel-hclcdc:
   - generic zplane property support
  mediatek:
   - use generic video mode function
  exynos:
   - S5PV210 FIMD variant support
   - IPP v2 framework
   - more HW overlays support"
* tag 'drm-next-2018-06-06-1' of git://anongit.freedesktop.org/drm/drm: (1286 commits)
  drm/amdgpu: fix 32-bit build warning
  drm/exynos: fimc: signedness bug in fimc_setup_clocks()
  drm/exynos: scaler: fix static checker warning
  drm/amdgpu: Use dev_info() to report amdkfd is not supported for this ASIC
  drm/amd/display: Remove use of division operator for long longs
  drm/amdgpu: Update GFX info structure to match what vega20 used
  drm/amdgpu/pp: remove duplicate assignment
  drm/sched: add rcu_barrier after entity fini
  drm/amdgpu: move VM BOs on LRU again
  drm/amdgpu: consistenly use VM moved flag
  drm/amdgpu: kmap PDs/PTs in amdgpu_vm_update_directories
  drm/amdgpu: further optimize amdgpu_vm_handle_moved
  drm/amdgpu: cleanup amdgpu_vm_validate_pt_bos v2
  drm/amdgpu: rework VM state machine lock handling v2
  drm/amdgpu: Add runtime VCN PG support
  drm/amdgpu: Enable VCN static PG by default on RV
  drm/amdgpu: Add VCN static PG support on RV
  drm/amdgpu: Enable VCN CG by default on RV
  drm/amdgpu: Add static CG control for VCN on RV
  drm/exynos: Fix default value for zpos plane property
  ...
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 120 | 
1 files changed, 72 insertions, 48 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 6d08cde8443c..6a9e46ae7f0a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
| @@ -191,14 +191,21 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev, | |||
| 191 | u32 domain, struct amdgpu_bo **bo_ptr, | 191 | u32 domain, struct amdgpu_bo **bo_ptr, | 
| 192 | u64 *gpu_addr, void **cpu_addr) | 192 | u64 *gpu_addr, void **cpu_addr) | 
| 193 | { | 193 | { | 
| 194 | struct amdgpu_bo_param bp; | ||
| 194 | bool free = false; | 195 | bool free = false; | 
| 195 | int r; | 196 | int r; | 
| 196 | 197 | ||
| 198 | memset(&bp, 0, sizeof(bp)); | ||
| 199 | bp.size = size; | ||
| 200 | bp.byte_align = align; | ||
| 201 | bp.domain = domain; | ||
| 202 | bp.flags = AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | ||
| 203 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS; | ||
| 204 | bp.type = ttm_bo_type_kernel; | ||
| 205 | bp.resv = NULL; | ||
| 206 | |||
| 197 | if (!*bo_ptr) { | 207 | if (!*bo_ptr) { | 
| 198 | r = amdgpu_bo_create(adev, size, align, domain, | 208 | r = amdgpu_bo_create(adev, &bp, bo_ptr); | 
| 199 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | ||
| 200 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, | ||
| 201 | ttm_bo_type_kernel, NULL, bo_ptr); | ||
| 202 | if (r) { | 209 | if (r) { | 
| 203 | dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", | 210 | dev_err(adev->dev, "(%d) failed to allocate kernel bo\n", | 
| 204 | r); | 211 | r); | 
| @@ -341,27 +348,25 @@ fail: | |||
| 341 | return false; | 348 | return false; | 
| 342 | } | 349 | } | 
| 343 | 350 | ||
| 344 | static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size, | 351 | static int amdgpu_bo_do_create(struct amdgpu_device *adev, | 
| 345 | int byte_align, u32 domain, | 352 | struct amdgpu_bo_param *bp, | 
| 346 | u64 flags, enum ttm_bo_type type, | ||
| 347 | struct reservation_object *resv, | ||
| 348 | struct amdgpu_bo **bo_ptr) | 353 | struct amdgpu_bo **bo_ptr) | 
| 349 | { | 354 | { | 
| 350 | struct ttm_operation_ctx ctx = { | 355 | struct ttm_operation_ctx ctx = { | 
| 351 | .interruptible = (type != ttm_bo_type_kernel), | 356 | .interruptible = (bp->type != ttm_bo_type_kernel), | 
| 352 | .no_wait_gpu = false, | 357 | .no_wait_gpu = false, | 
| 353 | .resv = resv, | 358 | .resv = bp->resv, | 
| 354 | .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT | 359 | .flags = TTM_OPT_FLAG_ALLOW_RES_EVICT | 
| 355 | }; | 360 | }; | 
| 356 | struct amdgpu_bo *bo; | 361 | struct amdgpu_bo *bo; | 
| 357 | unsigned long page_align; | 362 | unsigned long page_align, size = bp->size; | 
| 358 | size_t acc_size; | 363 | size_t acc_size; | 
| 359 | int r; | 364 | int r; | 
| 360 | 365 | ||
| 361 | page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT; | 366 | page_align = roundup(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT; | 
| 362 | size = ALIGN(size, PAGE_SIZE); | 367 | size = ALIGN(size, PAGE_SIZE); | 
| 363 | 368 | ||
| 364 | if (!amdgpu_bo_validate_size(adev, size, domain)) | 369 | if (!amdgpu_bo_validate_size(adev, size, bp->domain)) | 
| 365 | return -ENOMEM; | 370 | return -ENOMEM; | 
| 366 | 371 | ||
| 367 | *bo_ptr = NULL; | 372 | *bo_ptr = NULL; | 
| @@ -375,18 +380,14 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size, | |||
| 375 | drm_gem_private_object_init(adev->ddev, &bo->gem_base, size); | 380 | drm_gem_private_object_init(adev->ddev, &bo->gem_base, size); | 
| 376 | INIT_LIST_HEAD(&bo->shadow_list); | 381 | INIT_LIST_HEAD(&bo->shadow_list); | 
| 377 | INIT_LIST_HEAD(&bo->va); | 382 | INIT_LIST_HEAD(&bo->va); | 
| 378 | bo->preferred_domains = domain & (AMDGPU_GEM_DOMAIN_VRAM | | 383 | bo->preferred_domains = bp->preferred_domain ? bp->preferred_domain : | 
| 379 | AMDGPU_GEM_DOMAIN_GTT | | 384 | bp->domain; | 
| 380 | AMDGPU_GEM_DOMAIN_CPU | | ||
| 381 | AMDGPU_GEM_DOMAIN_GDS | | ||
| 382 | AMDGPU_GEM_DOMAIN_GWS | | ||
| 383 | AMDGPU_GEM_DOMAIN_OA); | ||
| 384 | bo->allowed_domains = bo->preferred_domains; | 385 | bo->allowed_domains = bo->preferred_domains; | 
| 385 | if (type != ttm_bo_type_kernel && | 386 | if (bp->type != ttm_bo_type_kernel && | 
| 386 | bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM) | 387 | bo->allowed_domains == AMDGPU_GEM_DOMAIN_VRAM) | 
| 387 | bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT; | 388 | bo->allowed_domains |= AMDGPU_GEM_DOMAIN_GTT; | 
| 388 | 389 | ||
| 389 | bo->flags = flags; | 390 | bo->flags = bp->flags; | 
| 390 | 391 | ||
| 391 | #ifdef CONFIG_X86_32 | 392 | #ifdef CONFIG_X86_32 | 
| 392 | /* XXX: Write-combined CPU mappings of GTT seem broken on 32-bit | 393 | /* XXX: Write-combined CPU mappings of GTT seem broken on 32-bit | 
| @@ -417,11 +418,13 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size, | |||
| 417 | #endif | 418 | #endif | 
| 418 | 419 | ||
| 419 | bo->tbo.bdev = &adev->mman.bdev; | 420 | bo->tbo.bdev = &adev->mman.bdev; | 
| 420 | amdgpu_ttm_placement_from_domain(bo, domain); | 421 | amdgpu_ttm_placement_from_domain(bo, bp->domain); | 
| 422 | if (bp->type == ttm_bo_type_kernel) | ||
| 423 | bo->tbo.priority = 1; | ||
| 421 | 424 | ||
| 422 | r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, | 425 | r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, | 
| 423 | &bo->placement, page_align, &ctx, acc_size, | 426 | &bo->placement, page_align, &ctx, acc_size, | 
| 424 | NULL, resv, &amdgpu_ttm_bo_destroy); | 427 | NULL, bp->resv, &amdgpu_ttm_bo_destroy); | 
| 425 | if (unlikely(r != 0)) | 428 | if (unlikely(r != 0)) | 
| 426 | return r; | 429 | return r; | 
| 427 | 430 | ||
| @@ -433,10 +436,7 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size, | |||
| 433 | else | 436 | else | 
| 434 | amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); | 437 | amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); | 
| 435 | 438 | ||
| 436 | if (type == ttm_bo_type_kernel) | 439 | if (bp->flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && | 
| 437 | bo->tbo.priority = 1; | ||
| 438 | |||
| 439 | if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && | ||
| 440 | bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { | 440 | bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { | 
| 441 | struct dma_fence *fence; | 441 | struct dma_fence *fence; | 
| 442 | 442 | ||
| @@ -449,20 +449,20 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, unsigned long size, | |||
| 449 | bo->tbo.moving = dma_fence_get(fence); | 449 | bo->tbo.moving = dma_fence_get(fence); | 
| 450 | dma_fence_put(fence); | 450 | dma_fence_put(fence); | 
| 451 | } | 451 | } | 
| 452 | if (!resv) | 452 | if (!bp->resv) | 
| 453 | amdgpu_bo_unreserve(bo); | 453 | amdgpu_bo_unreserve(bo); | 
| 454 | *bo_ptr = bo; | 454 | *bo_ptr = bo; | 
| 455 | 455 | ||
| 456 | trace_amdgpu_bo_create(bo); | 456 | trace_amdgpu_bo_create(bo); | 
| 457 | 457 | ||
| 458 | /* Treat CPU_ACCESS_REQUIRED only as a hint if given by UMD */ | 458 | /* Treat CPU_ACCESS_REQUIRED only as a hint if given by UMD */ | 
| 459 | if (type == ttm_bo_type_device) | 459 | if (bp->type == ttm_bo_type_device) | 
| 460 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; | 460 | bo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED; | 
| 461 | 461 | ||
| 462 | return 0; | 462 | return 0; | 
| 463 | 463 | ||
| 464 | fail_unreserve: | 464 | fail_unreserve: | 
| 465 | if (!resv) | 465 | if (!bp->resv) | 
| 466 | ww_mutex_unlock(&bo->tbo.resv->lock); | 466 | ww_mutex_unlock(&bo->tbo.resv->lock); | 
| 467 | amdgpu_bo_unref(&bo); | 467 | amdgpu_bo_unref(&bo); | 
| 468 | return r; | 468 | return r; | 
| @@ -472,16 +472,22 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev, | |||
| 472 | unsigned long size, int byte_align, | 472 | unsigned long size, int byte_align, | 
| 473 | struct amdgpu_bo *bo) | 473 | struct amdgpu_bo *bo) | 
| 474 | { | 474 | { | 
| 475 | struct amdgpu_bo_param bp; | ||
| 475 | int r; | 476 | int r; | 
| 476 | 477 | ||
| 477 | if (bo->shadow) | 478 | if (bo->shadow) | 
| 478 | return 0; | 479 | return 0; | 
| 479 | 480 | ||
| 480 | r = amdgpu_bo_do_create(adev, size, byte_align, AMDGPU_GEM_DOMAIN_GTT, | 481 | memset(&bp, 0, sizeof(bp)); | 
| 481 | AMDGPU_GEM_CREATE_CPU_GTT_USWC | | 482 | bp.size = size; | 
| 482 | AMDGPU_GEM_CREATE_SHADOW, | 483 | bp.byte_align = byte_align; | 
| 483 | ttm_bo_type_kernel, | 484 | bp.domain = AMDGPU_GEM_DOMAIN_GTT; | 
| 484 | bo->tbo.resv, &bo->shadow); | 485 | bp.flags = AMDGPU_GEM_CREATE_CPU_GTT_USWC | | 
| 486 | AMDGPU_GEM_CREATE_SHADOW; | ||
| 487 | bp.type = ttm_bo_type_kernel; | ||
| 488 | bp.resv = bo->tbo.resv; | ||
| 489 | |||
| 490 | r = amdgpu_bo_do_create(adev, &bp, &bo->shadow); | ||
| 485 | if (!r) { | 491 | if (!r) { | 
| 486 | bo->shadow->parent = amdgpu_bo_ref(bo); | 492 | bo->shadow->parent = amdgpu_bo_ref(bo); | 
| 487 | mutex_lock(&adev->shadow_list_lock); | 493 | mutex_lock(&adev->shadow_list_lock); | 
| @@ -492,28 +498,26 @@ static int amdgpu_bo_create_shadow(struct amdgpu_device *adev, | |||
| 492 | return r; | 498 | return r; | 
| 493 | } | 499 | } | 
| 494 | 500 | ||
| 495 | int amdgpu_bo_create(struct amdgpu_device *adev, unsigned long size, | 501 | int amdgpu_bo_create(struct amdgpu_device *adev, | 
| 496 | int byte_align, u32 domain, | 502 | struct amdgpu_bo_param *bp, | 
| 497 | u64 flags, enum ttm_bo_type type, | ||
| 498 | struct reservation_object *resv, | ||
| 499 | struct amdgpu_bo **bo_ptr) | 503 | struct amdgpu_bo **bo_ptr) | 
| 500 | { | 504 | { | 
| 501 | uint64_t parent_flags = flags & ~AMDGPU_GEM_CREATE_SHADOW; | 505 | u64 flags = bp->flags; | 
| 502 | int r; | 506 | int r; | 
| 503 | 507 | ||
| 504 | r = amdgpu_bo_do_create(adev, size, byte_align, domain, | 508 | bp->flags = bp->flags & ~AMDGPU_GEM_CREATE_SHADOW; | 
| 505 | parent_flags, type, resv, bo_ptr); | 509 | r = amdgpu_bo_do_create(adev, bp, bo_ptr); | 
| 506 | if (r) | 510 | if (r) | 
| 507 | return r; | 511 | return r; | 
| 508 | 512 | ||
| 509 | if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) { | 513 | if ((flags & AMDGPU_GEM_CREATE_SHADOW) && amdgpu_need_backup(adev)) { | 
| 510 | if (!resv) | 514 | if (!bp->resv) | 
| 511 | WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, | 515 | WARN_ON(reservation_object_lock((*bo_ptr)->tbo.resv, | 
| 512 | NULL)); | 516 | NULL)); | 
| 513 | 517 | ||
| 514 | r = amdgpu_bo_create_shadow(adev, size, byte_align, (*bo_ptr)); | 518 | r = amdgpu_bo_create_shadow(adev, bp->size, bp->byte_align, (*bo_ptr)); | 
| 515 | 519 | ||
| 516 | if (!resv) | 520 | if (!bp->resv) | 
| 517 | reservation_object_unlock((*bo_ptr)->tbo.resv); | 521 | reservation_object_unlock((*bo_ptr)->tbo.resv); | 
| 518 | 522 | ||
| 519 | if (r) | 523 | if (r) | 
| @@ -689,8 +693,21 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, | |||
| 689 | return -EINVAL; | 693 | return -EINVAL; | 
| 690 | 694 | ||
| 691 | /* A shared bo cannot be migrated to VRAM */ | 695 | /* A shared bo cannot be migrated to VRAM */ | 
| 692 | if (bo->prime_shared_count && (domain == AMDGPU_GEM_DOMAIN_VRAM)) | 696 | if (bo->prime_shared_count) { | 
| 693 | return -EINVAL; | 697 | if (domain & AMDGPU_GEM_DOMAIN_GTT) | 
| 698 | domain = AMDGPU_GEM_DOMAIN_GTT; | ||
| 699 | else | ||
| 700 | return -EINVAL; | ||
| 701 | } | ||
| 702 | |||
| 703 | /* This assumes only APU display buffers are pinned with (VRAM|GTT). | ||
| 704 | * See function amdgpu_display_supported_domains() | ||
| 705 | */ | ||
| 706 | if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) { | ||
| 707 | domain = AMDGPU_GEM_DOMAIN_VRAM; | ||
| 708 | if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD) | ||
| 709 | domain = AMDGPU_GEM_DOMAIN_GTT; | ||
| 710 | } | ||
| 694 | 711 | ||
| 695 | if (bo->pin_count) { | 712 | if (bo->pin_count) { | 
| 696 | uint32_t mem_type = bo->tbo.mem.mem_type; | 713 | uint32_t mem_type = bo->tbo.mem.mem_type; | 
| @@ -838,6 +855,13 @@ int amdgpu_bo_init(struct amdgpu_device *adev) | |||
| 838 | return amdgpu_ttm_init(adev); | 855 | return amdgpu_ttm_init(adev); | 
| 839 | } | 856 | } | 
| 840 | 857 | ||
| 858 | int amdgpu_bo_late_init(struct amdgpu_device *adev) | ||
| 859 | { | ||
| 860 | amdgpu_ttm_late_init(adev); | ||
| 861 | |||
| 862 | return 0; | ||
| 863 | } | ||
| 864 | |||
| 841 | void amdgpu_bo_fini(struct amdgpu_device *adev) | 865 | void amdgpu_bo_fini(struct amdgpu_device *adev) | 
| 842 | { | 866 | { | 
| 843 | amdgpu_ttm_fini(adev); | 867 | amdgpu_ttm_fini(adev); | 
