diff options
author | Mark Brown <broonie@kernel.org> | 2015-10-12 13:09:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-10-12 13:09:27 -0400 |
commit | 79828b4fa835f73cdaf4bffa48696abdcbea9d02 (patch) | |
tree | 5e0fa7156acb75ba603022bc807df8f2fedb97a8 /drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |
parent | 721b51fcf91898299d96f4b72cb9434cda29dce6 (diff) | |
parent | 8c1a9d6323abf0fb1e5dad96cf3f1c783505ea5a (diff) |
Merge remote-tracking branch 'asoc/fix/rt5645' into asoc-fix-rt5645
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 5533434c7a8f..22367939ebf1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/vga_switcheroo.h> | 34 | #include <linux/vga_switcheroo.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/pm_runtime.h> | 36 | #include <linux/pm_runtime.h> |
37 | #include "amdgpu_amdkfd.h" | ||
37 | 38 | ||
38 | #if defined(CONFIG_VGA_SWITCHEROO) | 39 | #if defined(CONFIG_VGA_SWITCHEROO) |
39 | bool amdgpu_has_atpx(void); | 40 | bool amdgpu_has_atpx(void); |
@@ -61,6 +62,8 @@ int amdgpu_driver_unload_kms(struct drm_device *dev) | |||
61 | 62 | ||
62 | pm_runtime_get_sync(dev->dev); | 63 | pm_runtime_get_sync(dev->dev); |
63 | 64 | ||
65 | amdgpu_amdkfd_device_fini(adev); | ||
66 | |||
64 | amdgpu_acpi_fini(adev); | 67 | amdgpu_acpi_fini(adev); |
65 | 68 | ||
66 | amdgpu_device_fini(adev); | 69 | amdgpu_device_fini(adev); |
@@ -93,8 +96,8 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) | |||
93 | 96 | ||
94 | if ((amdgpu_runtime_pm != 0) && | 97 | if ((amdgpu_runtime_pm != 0) && |
95 | amdgpu_has_atpx() && | 98 | amdgpu_has_atpx() && |
96 | ((flags & AMDGPU_IS_APU) == 0)) | 99 | ((flags & AMD_IS_APU) == 0)) |
97 | flags |= AMDGPU_IS_PX; | 100 | flags |= AMD_IS_PX; |
98 | 101 | ||
99 | /* amdgpu_device_init should report only fatal error | 102 | /* amdgpu_device_init should report only fatal error |
100 | * like memory allocation failure or iomapping failure, | 103 | * like memory allocation failure or iomapping failure, |
@@ -118,6 +121,10 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags) | |||
118 | "Error during ACPI methods call\n"); | 121 | "Error during ACPI methods call\n"); |
119 | } | 122 | } |
120 | 123 | ||
124 | amdgpu_amdkfd_load_interface(adev); | ||
125 | amdgpu_amdkfd_device_probe(adev); | ||
126 | amdgpu_amdkfd_device_init(adev); | ||
127 | |||
121 | if (amdgpu_device_is_px(dev)) { | 128 | if (amdgpu_device_is_px(dev)) { |
122 | pm_runtime_use_autosuspend(dev->dev); | 129 | pm_runtime_use_autosuspend(dev->dev); |
123 | pm_runtime_set_autosuspend_delay(dev->dev, 5000); | 130 | pm_runtime_set_autosuspend_delay(dev->dev, 5000); |
@@ -235,7 +242,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
235 | 242 | ||
236 | for (i = 0; i < adev->num_ip_blocks; i++) { | 243 | for (i = 0; i < adev->num_ip_blocks; i++) { |
237 | if (adev->ip_blocks[i].type == type && | 244 | if (adev->ip_blocks[i].type == type && |
238 | adev->ip_block_enabled[i]) { | 245 | adev->ip_block_status[i].valid) { |
239 | ip.hw_ip_version_major = adev->ip_blocks[i].major; | 246 | ip.hw_ip_version_major = adev->ip_blocks[i].major; |
240 | ip.hw_ip_version_minor = adev->ip_blocks[i].minor; | 247 | ip.hw_ip_version_minor = adev->ip_blocks[i].minor; |
241 | ip.capabilities_flags = 0; | 248 | ip.capabilities_flags = 0; |
@@ -274,7 +281,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
274 | 281 | ||
275 | for (i = 0; i < adev->num_ip_blocks; i++) | 282 | for (i = 0; i < adev->num_ip_blocks; i++) |
276 | if (adev->ip_blocks[i].type == type && | 283 | if (adev->ip_blocks[i].type == type && |
277 | adev->ip_block_enabled[i] && | 284 | adev->ip_block_status[i].valid && |
278 | count < AMDGPU_HW_IP_INSTANCE_MAX_COUNT) | 285 | count < AMDGPU_HW_IP_INSTANCE_MAX_COUNT) |
279 | count++; | 286 | count++; |
280 | 287 | ||
@@ -317,16 +324,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
317 | break; | 324 | break; |
318 | case AMDGPU_INFO_FW_GFX_RLC: | 325 | case AMDGPU_INFO_FW_GFX_RLC: |
319 | fw_info.ver = adev->gfx.rlc_fw_version; | 326 | fw_info.ver = adev->gfx.rlc_fw_version; |
320 | fw_info.feature = 0; | 327 | fw_info.feature = adev->gfx.rlc_feature_version; |
321 | break; | 328 | break; |
322 | case AMDGPU_INFO_FW_GFX_MEC: | 329 | case AMDGPU_INFO_FW_GFX_MEC: |
323 | if (info->query_fw.index == 0) | 330 | if (info->query_fw.index == 0) { |
324 | fw_info.ver = adev->gfx.mec_fw_version; | 331 | fw_info.ver = adev->gfx.mec_fw_version; |
325 | else if (info->query_fw.index == 1) | 332 | fw_info.feature = adev->gfx.mec_feature_version; |
333 | } else if (info->query_fw.index == 1) { | ||
326 | fw_info.ver = adev->gfx.mec2_fw_version; | 334 | fw_info.ver = adev->gfx.mec2_fw_version; |
327 | else | 335 | fw_info.feature = adev->gfx.mec2_feature_version; |
336 | } else | ||
328 | return -EINVAL; | 337 | return -EINVAL; |
329 | fw_info.feature = 0; | ||
330 | break; | 338 | break; |
331 | case AMDGPU_INFO_FW_SMC: | 339 | case AMDGPU_INFO_FW_SMC: |
332 | fw_info.ver = adev->pm.fw_version; | 340 | fw_info.ver = adev->pm.fw_version; |
@@ -336,7 +344,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
336 | if (info->query_fw.index >= 2) | 344 | if (info->query_fw.index >= 2) |
337 | return -EINVAL; | 345 | return -EINVAL; |
338 | fw_info.ver = adev->sdma[info->query_fw.index].fw_version; | 346 | fw_info.ver = adev->sdma[info->query_fw.index].fw_version; |
339 | fw_info.feature = 0; | 347 | fw_info.feature = adev->sdma[info->query_fw.index].feature_version; |
340 | break; | 348 | break; |
341 | default: | 349 | default: |
342 | return -EINVAL; | 350 | return -EINVAL; |
@@ -416,7 +424,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
416 | return n ? -EFAULT : 0; | 424 | return n ? -EFAULT : 0; |
417 | } | 425 | } |
418 | case AMDGPU_INFO_DEV_INFO: { | 426 | case AMDGPU_INFO_DEV_INFO: { |
419 | struct drm_amdgpu_info_device dev_info; | 427 | struct drm_amdgpu_info_device dev_info = {}; |
420 | struct amdgpu_cu_info cu_info; | 428 | struct amdgpu_cu_info cu_info; |
421 | 429 | ||
422 | dev_info.device_id = dev->pdev->device; | 430 | dev_info.device_id = dev->pdev->device; |
@@ -443,11 +451,11 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
443 | dev_info.num_hw_gfx_contexts = adev->gfx.config.max_hw_contexts; | 451 | dev_info.num_hw_gfx_contexts = adev->gfx.config.max_hw_contexts; |
444 | dev_info._pad = 0; | 452 | dev_info._pad = 0; |
445 | dev_info.ids_flags = 0; | 453 | dev_info.ids_flags = 0; |
446 | if (adev->flags & AMDGPU_IS_APU) | 454 | if (adev->flags & AMD_IS_APU) |
447 | dev_info.ids_flags |= AMDGPU_IDS_FLAGS_FUSION; | 455 | dev_info.ids_flags |= AMDGPU_IDS_FLAGS_FUSION; |
448 | dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE; | 456 | dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE; |
449 | dev_info.virtual_address_max = (uint64_t)adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE; | 457 | dev_info.virtual_address_max = (uint64_t)adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE; |
450 | dev_info.virtual_address_alignment = max(PAGE_SIZE, 0x10000UL); | 458 | dev_info.virtual_address_alignment = max((int)PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE); |
451 | dev_info.pte_fragment_size = (1 << AMDGPU_LOG2_PAGES_PER_FRAG) * | 459 | dev_info.pte_fragment_size = (1 << AMDGPU_LOG2_PAGES_PER_FRAG) * |
452 | AMDGPU_GPU_PAGE_SIZE; | 460 | AMDGPU_GPU_PAGE_SIZE; |
453 | dev_info.gart_page_size = AMDGPU_GPU_PAGE_SIZE; | 461 | dev_info.gart_page_size = AMDGPU_GPU_PAGE_SIZE; |
@@ -459,6 +467,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
459 | memcpy(&dev_info.cu_bitmap[0], &cu_info.bitmap[0], sizeof(cu_info.bitmap)); | 467 | memcpy(&dev_info.cu_bitmap[0], &cu_info.bitmap[0], sizeof(cu_info.bitmap)); |
460 | dev_info.vram_type = adev->mc.vram_type; | 468 | dev_info.vram_type = adev->mc.vram_type; |
461 | dev_info.vram_bit_width = adev->mc.vram_width; | 469 | dev_info.vram_bit_width = adev->mc.vram_width; |
470 | dev_info.vce_harvest_config = adev->vce.harvest_config; | ||
462 | 471 | ||
463 | return copy_to_user(out, &dev_info, | 472 | return copy_to_user(out, &dev_info, |
464 | min((size_t)size, sizeof(dev_info))) ? -EFAULT : 0; | 473 | min((size_t)size, sizeof(dev_info))) ? -EFAULT : 0; |
@@ -518,10 +527,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
518 | mutex_init(&fpriv->bo_list_lock); | 527 | mutex_init(&fpriv->bo_list_lock); |
519 | idr_init(&fpriv->bo_list_handles); | 528 | idr_init(&fpriv->bo_list_handles); |
520 | 529 | ||
521 | /* init context manager */ | 530 | amdgpu_ctx_mgr_init(&fpriv->ctx_mgr); |
522 | mutex_init(&fpriv->ctx_mgr.lock); | ||
523 | idr_init(&fpriv->ctx_mgr.ctx_handles); | ||
524 | fpriv->ctx_mgr.adev = adev; | ||
525 | 531 | ||
526 | file_priv->driver_priv = fpriv; | 532 | file_priv->driver_priv = fpriv; |
527 | 533 | ||
@@ -554,6 +560,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, | |||
554 | if (!fpriv) | 560 | if (!fpriv) |
555 | return; | 561 | return; |
556 | 562 | ||
563 | amdgpu_ctx_mgr_fini(&fpriv->ctx_mgr); | ||
564 | |||
557 | amdgpu_vm_fini(adev, &fpriv->vm); | 565 | amdgpu_vm_fini(adev, &fpriv->vm); |
558 | 566 | ||
559 | idr_for_each_entry(&fpriv->bo_list_handles, list, handle) | 567 | idr_for_each_entry(&fpriv->bo_list_handles, list, handle) |
@@ -562,9 +570,6 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev, | |||
562 | idr_destroy(&fpriv->bo_list_handles); | 570 | idr_destroy(&fpriv->bo_list_handles); |
563 | mutex_destroy(&fpriv->bo_list_lock); | 571 | mutex_destroy(&fpriv->bo_list_lock); |
564 | 572 | ||
565 | /* release context */ | ||
566 | amdgpu_ctx_fini(fpriv); | ||
567 | |||
568 | kfree(fpriv); | 573 | kfree(fpriv); |
569 | file_priv->driver_priv = NULL; | 574 | file_priv->driver_priv = NULL; |
570 | } | 575 | } |