aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-05-27 02:03:48 -0400
committerDave Airlie <airlied@redhat.com>2016-05-27 02:03:48 -0400
commit79b3c7164c18e2fe9e69b0dcc0d45bab7ae3c968 (patch)
treea4a376cefd4c8632a39cd7ee3d734a62ebb2fa07
parente411295e3ec0b470795a860ec3cc51edf64407c4 (diff)
parent425c452b547622fb728c9ed4fe99c3f2f51d816d (diff)
Merge branch 'drm-next-4.7' of git://people.freedesktop.org/~agd5f/linux into drm-next
AMD GPU bugfixes: - Various powerplay bug fixes - Add some new polaris pci ids - misc bug fixes and code cleanups * 'drm-next-4.7' of git://people.freedesktop.org/~agd5f/linux: (27 commits) drm/amd: add Kconfig dependency for ACP on DRM_AMDGPU drm/amdgpu: Fix hdmi deep color support. drm/amdgpu: fix bug in fence driver fini drm/amd/powerplay/hwmgr: use kmemdup drm/amd/powerplay/hwmgr: use kmemdup drm/amd/powerplay/hwmgr: use kmemdup drm/amd/powerplay: fix bugs of checking if dpm is running on Tonga drm/amdgpu: update Polaris11 golden setting drm/amdgpu: Add more Polaris 11 PCI IDs drm/amdgpu: update Polaris10 golden setting drm/amdgpu: add more Polaris10 DID drm/amd/amdgpu : Remove unused variable drm/amd/amdgpu : Remove unused variable drm/amd/amdgpu : Remove unused variable drm/amd/amdgpu/cz_dpm: Remove unused variable drm/amd/amdgpu : Remove unused variable drm/amd/powerplay: use ARRAY_SIZE() to calculate array size. drm/amdgpu: fix array out of bounds drm/radeon: fix array out of bounds drm/amd/powerplay: fix a bug on updating sclk for Tonga ...
-rw-r--r--drivers/gpu/drm/amd/acp/Kconfig1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c25
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c27
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c111
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cik_ih.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cz_dpm.c13
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cz_ih.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/dce_v11_0.c4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/iceland_ih.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/kv_dpm.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/tonga_ih.c3
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c45
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c38
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c44
-rw-r--r--drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c16
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/hwmgr.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c2
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.c2
22 files changed, 183 insertions, 182 deletions
diff --git a/drivers/gpu/drm/amd/acp/Kconfig b/drivers/gpu/drm/amd/acp/Kconfig
index ca77ec10147c..e503e3d6d920 100644
--- a/drivers/gpu/drm/amd/acp/Kconfig
+++ b/drivers/gpu/drm/amd/acp/Kconfig
@@ -2,6 +2,7 @@ menu "ACP (Audio CoProcessor) Configuration"
2 2
3config DRM_AMD_ACP 3config DRM_AMD_ACP
4 bool "Enable AMD Audio CoProcessor IP support" 4 bool "Enable AMD Audio CoProcessor IP support"
5 depends on DRM_AMDGPU
5 select MFD_CORE 6 select MFD_CORE
6 select PM_GENERIC_DOMAINS if PM 7 select PM_GENERIC_DOMAINS if PM
7 help 8 help
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 2a009c398dcb..992f00b65be4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -602,6 +602,8 @@ int amdgpu_sync_wait(struct amdgpu_sync *sync);
602void amdgpu_sync_free(struct amdgpu_sync *sync); 602void amdgpu_sync_free(struct amdgpu_sync *sync);
603int amdgpu_sync_init(void); 603int amdgpu_sync_init(void);
604void amdgpu_sync_fini(void); 604void amdgpu_sync_fini(void);
605int amdgpu_fence_slab_init(void);
606void amdgpu_fence_slab_fini(void);
605 607
606/* 608/*
607 * GART structures, functions & helpers 609 * GART structures, functions & helpers
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index 60a0c9ac11b2..cb07da41152b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -194,12 +194,12 @@ int amdgpu_connector_get_monitor_bpc(struct drm_connector *connector)
194 bpc = 8; 194 bpc = 8;
195 DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n", 195 DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n",
196 connector->name, bpc); 196 connector->name, bpc);
197 } else if (bpc > 8) {
198 /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
199 DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
200 connector->name);
201 bpc = 8;
202 } 197 }
198 } else if (bpc > 8) {
199 /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */
200 DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n",
201 connector->name);
202 bpc = 8;
203 } 203 }
204 } 204 }
205 205
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 1dab5f2b725b..f888c015f76c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -50,9 +50,11 @@
50 * KMS wrapper. 50 * KMS wrapper.
51 * - 3.0.0 - initial driver 51 * - 3.0.0 - initial driver
52 * - 3.1.0 - allow reading more status registers (GRBM, SRBM, SDMA, CP) 52 * - 3.1.0 - allow reading more status registers (GRBM, SRBM, SDMA, CP)
53 * - 3.2.0 - GFX8: Uses EOP_TC_WB_ACTION_EN, so UMDs don't have to do the same
54 * at the end of IBs.
53 */ 55 */
54#define KMS_DRIVER_MAJOR 3 56#define KMS_DRIVER_MAJOR 3
55#define KMS_DRIVER_MINOR 1 57#define KMS_DRIVER_MINOR 2
56#define KMS_DRIVER_PATCHLEVEL 0 58#define KMS_DRIVER_PATCHLEVEL 0
57 59
58int amdgpu_vram_limit = 0; 60int amdgpu_vram_limit = 0;
@@ -279,14 +281,26 @@ static const struct pci_device_id pciidlist[] = {
279 {0x1002, 0x98E4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_STONEY|AMD_IS_APU}, 281 {0x1002, 0x98E4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_STONEY|AMD_IS_APU},
280 /* Polaris11 */ 282 /* Polaris11 */
281 {0x1002, 0x67E0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11}, 283 {0x1002, 0x67E0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
282 {0x1002, 0x67E1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11}, 284 {0x1002, 0x67E3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
283 {0x1002, 0x67E8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11}, 285 {0x1002, 0x67E8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
284 {0x1002, 0x67E9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
285 {0x1002, 0x67EB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11}, 286 {0x1002, 0x67EB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
287 {0x1002, 0x67EF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
286 {0x1002, 0x67FF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11}, 288 {0x1002, 0x67FF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
289 {0x1002, 0x67E1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
290 {0x1002, 0x67E7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
291 {0x1002, 0x67E9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS11},
287 /* Polaris10 */ 292 /* Polaris10 */
288 {0x1002, 0x67C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10}, 293 {0x1002, 0x67C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
294 {0x1002, 0x67C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
295 {0x1002, 0x67C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
296 {0x1002, 0x67C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
297 {0x1002, 0x67C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
289 {0x1002, 0x67DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10}, 298 {0x1002, 0x67DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
299 {0x1002, 0x67C8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
300 {0x1002, 0x67C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
301 {0x1002, 0x67CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
302 {0x1002, 0x67CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
303 {0x1002, 0x67CF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_POLARIS10},
290 304
291 {0, 0, 0} 305 {0, 0, 0}
292}; 306};
@@ -563,9 +577,12 @@ static struct pci_driver amdgpu_kms_pci_driver = {
563 .driver.pm = &amdgpu_pm_ops, 577 .driver.pm = &amdgpu_pm_ops,
564}; 578};
565 579
580
581
566static int __init amdgpu_init(void) 582static int __init amdgpu_init(void)
567{ 583{
568 amdgpu_sync_init(); 584 amdgpu_sync_init();
585 amdgpu_fence_slab_init();
569 if (vgacon_text_force()) { 586 if (vgacon_text_force()) {
570 DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n"); 587 DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n");
571 return -EINVAL; 588 return -EINVAL;
@@ -576,7 +593,6 @@ static int __init amdgpu_init(void)
576 driver->driver_features |= DRIVER_MODESET; 593 driver->driver_features |= DRIVER_MODESET;
577 driver->num_ioctls = amdgpu_max_kms_ioctl; 594 driver->num_ioctls = amdgpu_max_kms_ioctl;
578 amdgpu_register_atpx_handler(); 595 amdgpu_register_atpx_handler();
579
580 /* let modprobe override vga console setting */ 596 /* let modprobe override vga console setting */
581 return drm_pci_init(driver, pdriver); 597 return drm_pci_init(driver, pdriver);
582} 598}
@@ -587,6 +603,7 @@ static void __exit amdgpu_exit(void)
587 drm_pci_exit(driver, pdriver); 603 drm_pci_exit(driver, pdriver);
588 amdgpu_unregister_atpx_handler(); 604 amdgpu_unregister_atpx_handler();
589 amdgpu_sync_fini(); 605 amdgpu_sync_fini();
606 amdgpu_fence_slab_fini();
590} 607}
591 608
592module_init(amdgpu_init); 609module_init(amdgpu_init);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index ba9c04283d01..d1558768cfb7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -55,8 +55,21 @@ struct amdgpu_fence {
55}; 55};
56 56
57static struct kmem_cache *amdgpu_fence_slab; 57static struct kmem_cache *amdgpu_fence_slab;
58static atomic_t amdgpu_fence_slab_ref = ATOMIC_INIT(0);
59 58
59int amdgpu_fence_slab_init(void)
60{
61 amdgpu_fence_slab = kmem_cache_create(
62 "amdgpu_fence", sizeof(struct amdgpu_fence), 0,
63 SLAB_HWCACHE_ALIGN, NULL);
64 if (!amdgpu_fence_slab)
65 return -ENOMEM;
66 return 0;
67}
68
69void amdgpu_fence_slab_fini(void)
70{
71 kmem_cache_destroy(amdgpu_fence_slab);
72}
60/* 73/*
61 * Cast helper 74 * Cast helper
62 */ 75 */
@@ -396,13 +409,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
396 */ 409 */
397int amdgpu_fence_driver_init(struct amdgpu_device *adev) 410int amdgpu_fence_driver_init(struct amdgpu_device *adev)
398{ 411{
399 if (atomic_inc_return(&amdgpu_fence_slab_ref) == 1) {
400 amdgpu_fence_slab = kmem_cache_create(
401 "amdgpu_fence", sizeof(struct amdgpu_fence), 0,
402 SLAB_HWCACHE_ALIGN, NULL);
403 if (!amdgpu_fence_slab)
404 return -ENOMEM;
405 }
406 if (amdgpu_debugfs_fence_init(adev)) 412 if (amdgpu_debugfs_fence_init(adev))
407 dev_err(adev->dev, "fence debugfs file creation failed\n"); 413 dev_err(adev->dev, "fence debugfs file creation failed\n");
408 414
@@ -437,13 +443,10 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev)
437 amd_sched_fini(&ring->sched); 443 amd_sched_fini(&ring->sched);
438 del_timer_sync(&ring->fence_drv.fallback_timer); 444 del_timer_sync(&ring->fence_drv.fallback_timer);
439 for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) 445 for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
440 fence_put(ring->fence_drv.fences[i]); 446 fence_put(ring->fence_drv.fences[j]);
441 kfree(ring->fence_drv.fences); 447 kfree(ring->fence_drv.fences);
442 ring->fence_drv.initialized = false; 448 ring->fence_drv.initialized = false;
443 } 449 }
444
445 if (atomic_dec_and_test(&amdgpu_fence_slab_ref))
446 kmem_cache_destroy(amdgpu_fence_slab);
447} 450}
448 451
449/** 452/**
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ea708cb94862..9f36ed30ba11 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -53,6 +53,18 @@
53/* Special value that no flush is necessary */ 53/* Special value that no flush is necessary */
54#define AMDGPU_VM_NO_FLUSH (~0ll) 54#define AMDGPU_VM_NO_FLUSH (~0ll)
55 55
56/* Local structure. Encapsulate some VM table update parameters to reduce
57 * the number of function parameters
58 */
59struct amdgpu_vm_update_params {
60 /* address where to copy page table entries from */
61 uint64_t src;
62 /* DMA addresses to use for mapping */
63 dma_addr_t *pages_addr;
64 /* indirect buffer to fill with commands */
65 struct amdgpu_ib *ib;
66};
67
56/** 68/**
57 * amdgpu_vm_num_pde - return the number of page directory entries 69 * amdgpu_vm_num_pde - return the number of page directory entries
58 * 70 *
@@ -389,9 +401,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,
389 * amdgpu_vm_update_pages - helper to call the right asic function 401 * amdgpu_vm_update_pages - helper to call the right asic function
390 * 402 *
391 * @adev: amdgpu_device pointer 403 * @adev: amdgpu_device pointer
392 * @src: address where to copy page table entries from 404 * @vm_update_params: see amdgpu_vm_update_params definition
393 * @pages_addr: DMA addresses to use for mapping
394 * @ib: indirect buffer to fill with commands
395 * @pe: addr of the page entry 405 * @pe: addr of the page entry
396 * @addr: dst addr to write into pe 406 * @addr: dst addr to write into pe
397 * @count: number of page entries to update 407 * @count: number of page entries to update
@@ -402,29 +412,29 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,
402 * to setup the page table using the DMA. 412 * to setup the page table using the DMA.
403 */ 413 */
404static void amdgpu_vm_update_pages(struct amdgpu_device *adev, 414static void amdgpu_vm_update_pages(struct amdgpu_device *adev,
405 uint64_t src, 415 struct amdgpu_vm_update_params
406 dma_addr_t *pages_addr, 416 *vm_update_params,
407 struct amdgpu_ib *ib,
408 uint64_t pe, uint64_t addr, 417 uint64_t pe, uint64_t addr,
409 unsigned count, uint32_t incr, 418 unsigned count, uint32_t incr,
410 uint32_t flags) 419 uint32_t flags)
411{ 420{
412 trace_amdgpu_vm_set_page(pe, addr, count, incr, flags); 421 trace_amdgpu_vm_set_page(pe, addr, count, incr, flags);
413 422
414 if (src) { 423 if (vm_update_params->src) {
415 src += (addr >> 12) * 8; 424 amdgpu_vm_copy_pte(adev, vm_update_params->ib,
416 amdgpu_vm_copy_pte(adev, ib, pe, src, count); 425 pe, (vm_update_params->src + (addr >> 12) * 8), count);
417 426
418 } else if (pages_addr) { 427 } else if (vm_update_params->pages_addr) {
419 amdgpu_vm_write_pte(adev, ib, pages_addr, pe, addr, 428 amdgpu_vm_write_pte(adev, vm_update_params->ib,
420 count, incr, flags); 429 vm_update_params->pages_addr,
430 pe, addr, count, incr, flags);
421 431
422 } else if (count < 3) { 432 } else if (count < 3) {
423 amdgpu_vm_write_pte(adev, ib, NULL, pe, addr, 433 amdgpu_vm_write_pte(adev, vm_update_params->ib, NULL, pe, addr,
424 count, incr, flags); 434 count, incr, flags);
425 435
426 } else { 436 } else {
427 amdgpu_vm_set_pte_pde(adev, ib, pe, addr, 437 amdgpu_vm_set_pte_pde(adev, vm_update_params->ib, pe, addr,
428 count, incr, flags); 438 count, incr, flags);
429 } 439 }
430} 440}
@@ -444,10 +454,12 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
444 struct amdgpu_ring *ring; 454 struct amdgpu_ring *ring;
445 struct fence *fence = NULL; 455 struct fence *fence = NULL;
446 struct amdgpu_job *job; 456 struct amdgpu_job *job;
457 struct amdgpu_vm_update_params vm_update_params;
447 unsigned entries; 458 unsigned entries;
448 uint64_t addr; 459 uint64_t addr;
449 int r; 460 int r;
450 461
462 memset(&vm_update_params, 0, sizeof(vm_update_params));
451 ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); 463 ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
452 464
453 r = reservation_object_reserve_shared(bo->tbo.resv); 465 r = reservation_object_reserve_shared(bo->tbo.resv);
@@ -465,7 +477,8 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
465 if (r) 477 if (r)
466 goto error; 478 goto error;
467 479
468 amdgpu_vm_update_pages(adev, 0, NULL, &job->ibs[0], addr, 0, entries, 480 vm_update_params.ib = &job->ibs[0];
481 amdgpu_vm_update_pages(adev, &vm_update_params, addr, 0, entries,
469 0, 0); 482 0, 0);
470 amdgpu_ring_pad_ib(ring, &job->ibs[0]); 483 amdgpu_ring_pad_ib(ring, &job->ibs[0]);
471 484
@@ -538,11 +551,12 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
538 uint64_t last_pde = ~0, last_pt = ~0; 551 uint64_t last_pde = ~0, last_pt = ~0;
539 unsigned count = 0, pt_idx, ndw; 552 unsigned count = 0, pt_idx, ndw;
540 struct amdgpu_job *job; 553 struct amdgpu_job *job;
541 struct amdgpu_ib *ib; 554 struct amdgpu_vm_update_params vm_update_params;
542 struct fence *fence = NULL; 555 struct fence *fence = NULL;
543 556
544 int r; 557 int r;
545 558
559 memset(&vm_update_params, 0, sizeof(vm_update_params));
546 ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); 560 ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
547 561
548 /* padding, etc. */ 562 /* padding, etc. */
@@ -555,7 +569,7 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
555 if (r) 569 if (r)
556 return r; 570 return r;
557 571
558 ib = &job->ibs[0]; 572 vm_update_params.ib = &job->ibs[0];
559 573
560 /* walk over the address space and update the page directory */ 574 /* walk over the address space and update the page directory */
561 for (pt_idx = 0; pt_idx <= vm->max_pde_used; ++pt_idx) { 575 for (pt_idx = 0; pt_idx <= vm->max_pde_used; ++pt_idx) {
@@ -575,7 +589,7 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
575 ((last_pt + incr * count) != pt)) { 589 ((last_pt + incr * count) != pt)) {
576 590
577 if (count) { 591 if (count) {
578 amdgpu_vm_update_pages(adev, 0, NULL, ib, 592 amdgpu_vm_update_pages(adev, &vm_update_params,
579 last_pde, last_pt, 593 last_pde, last_pt,
580 count, incr, 594 count, incr,
581 AMDGPU_PTE_VALID); 595 AMDGPU_PTE_VALID);
@@ -590,14 +604,15 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
590 } 604 }
591 605
592 if (count) 606 if (count)
593 amdgpu_vm_update_pages(adev, 0, NULL, ib, last_pde, last_pt, 607 amdgpu_vm_update_pages(adev, &vm_update_params,
594 count, incr, AMDGPU_PTE_VALID); 608 last_pde, last_pt,
609 count, incr, AMDGPU_PTE_VALID);
595 610
596 if (ib->length_dw != 0) { 611 if (vm_update_params.ib->length_dw != 0) {
597 amdgpu_ring_pad_ib(ring, ib); 612 amdgpu_ring_pad_ib(ring, vm_update_params.ib);
598 amdgpu_sync_resv(adev, &job->sync, pd->tbo.resv, 613 amdgpu_sync_resv(adev, &job->sync, pd->tbo.resv,
599 AMDGPU_FENCE_OWNER_VM); 614 AMDGPU_FENCE_OWNER_VM);
600 WARN_ON(ib->length_dw > ndw); 615 WARN_ON(vm_update_params.ib->length_dw > ndw);
601 r = amdgpu_job_submit(job, ring, &vm->entity, 616 r = amdgpu_job_submit(job, ring, &vm->entity,
602 AMDGPU_FENCE_OWNER_VM, &fence); 617 AMDGPU_FENCE_OWNER_VM, &fence);
603 if (r) 618 if (r)
@@ -623,18 +638,15 @@ error_free:
623 * amdgpu_vm_frag_ptes - add fragment information to PTEs 638 * amdgpu_vm_frag_ptes - add fragment information to PTEs
624 * 639 *
625 * @adev: amdgpu_device pointer 640 * @adev: amdgpu_device pointer
626 * @src: address where to copy page table entries from 641 * @vm_update_params: see amdgpu_vm_update_params definition
627 * @pages_addr: DMA addresses to use for mapping
628 * @ib: IB for the update
629 * @pe_start: first PTE to handle 642 * @pe_start: first PTE to handle
630 * @pe_end: last PTE to handle 643 * @pe_end: last PTE to handle
631 * @addr: addr those PTEs should point to 644 * @addr: addr those PTEs should point to
632 * @flags: hw mapping flags 645 * @flags: hw mapping flags
633 */ 646 */
634static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev, 647static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,
635 uint64_t src, 648 struct amdgpu_vm_update_params
636 dma_addr_t *pages_addr, 649 *vm_update_params,
637 struct amdgpu_ib *ib,
638 uint64_t pe_start, uint64_t pe_end, 650 uint64_t pe_start, uint64_t pe_end,
639 uint64_t addr, uint32_t flags) 651 uint64_t addr, uint32_t flags)
640{ 652{
@@ -671,11 +683,11 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,
671 return; 683 return;
672 684
673 /* system pages are non continuously */ 685 /* system pages are non continuously */
674 if (src || pages_addr || !(flags & AMDGPU_PTE_VALID) || 686 if (vm_update_params->src || vm_update_params->pages_addr ||
675 (frag_start >= frag_end)) { 687 !(flags & AMDGPU_PTE_VALID) || (frag_start >= frag_end)) {
676 688
677 count = (pe_end - pe_start) / 8; 689 count = (pe_end - pe_start) / 8;
678 amdgpu_vm_update_pages(adev, src, pages_addr, ib, pe_start, 690 amdgpu_vm_update_pages(adev, vm_update_params, pe_start,
679 addr, count, AMDGPU_GPU_PAGE_SIZE, 691 addr, count, AMDGPU_GPU_PAGE_SIZE,
680 flags); 692 flags);
681 return; 693 return;
@@ -684,21 +696,21 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,
684 /* handle the 4K area at the beginning */ 696 /* handle the 4K area at the beginning */
685 if (pe_start != frag_start) { 697 if (pe_start != frag_start) {
686 count = (frag_start - pe_start) / 8; 698 count = (frag_start - pe_start) / 8;
687 amdgpu_vm_update_pages(adev, 0, NULL, ib, pe_start, addr, 699 amdgpu_vm_update_pages(adev, vm_update_params, pe_start, addr,
688 count, AMDGPU_GPU_PAGE_SIZE, flags); 700 count, AMDGPU_GPU_PAGE_SIZE, flags);
689 addr += AMDGPU_GPU_PAGE_SIZE * count; 701 addr += AMDGPU_GPU_PAGE_SIZE * count;
690 } 702 }
691 703
692 /* handle the area in the middle */ 704 /* handle the area in the middle */
693 count = (frag_end - frag_start) / 8; 705 count = (frag_end - frag_start) / 8;
694 amdgpu_vm_update_pages(adev, 0, NULL, ib, frag_start, addr, count, 706 amdgpu_vm_update_pages(adev, vm_update_params, frag_start, addr, count,
695 AMDGPU_GPU_PAGE_SIZE, flags | frag_flags); 707 AMDGPU_GPU_PAGE_SIZE, flags | frag_flags);
696 708
697 /* handle the 4K area at the end */ 709 /* handle the 4K area at the end */
698 if (frag_end != pe_end) { 710 if (frag_end != pe_end) {
699 addr += AMDGPU_GPU_PAGE_SIZE * count; 711 addr += AMDGPU_GPU_PAGE_SIZE * count;
700 count = (pe_end - frag_end) / 8; 712 count = (pe_end - frag_end) / 8;
701 amdgpu_vm_update_pages(adev, 0, NULL, ib, frag_end, addr, 713 amdgpu_vm_update_pages(adev, vm_update_params, frag_end, addr,
702 count, AMDGPU_GPU_PAGE_SIZE, flags); 714 count, AMDGPU_GPU_PAGE_SIZE, flags);
703 } 715 }
704} 716}
@@ -707,8 +719,7 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,
707 * amdgpu_vm_update_ptes - make sure that page tables are valid 719 * amdgpu_vm_update_ptes - make sure that page tables are valid
708 * 720 *
709 * @adev: amdgpu_device pointer 721 * @adev: amdgpu_device pointer
710 * @src: address where to copy page table entries from 722 * @vm_update_params: see amdgpu_vm_update_params definition
711 * @pages_addr: DMA addresses to use for mapping
712 * @vm: requested vm 723 * @vm: requested vm
713 * @start: start of GPU address range 724 * @start: start of GPU address range
714 * @end: end of GPU address range 725 * @end: end of GPU address range
@@ -718,10 +729,9 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,
718 * Update the page tables in the range @start - @end. 729 * Update the page tables in the range @start - @end.
719 */ 730 */
720static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, 731static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
721 uint64_t src, 732 struct amdgpu_vm_update_params
722 dma_addr_t *pages_addr, 733 *vm_update_params,
723 struct amdgpu_vm *vm, 734 struct amdgpu_vm *vm,
724 struct amdgpu_ib *ib,
725 uint64_t start, uint64_t end, 735 uint64_t start, uint64_t end,
726 uint64_t dst, uint32_t flags) 736 uint64_t dst, uint32_t flags)
727{ 737{
@@ -747,7 +757,7 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
747 757
748 if (last_pe_end != pe_start) { 758 if (last_pe_end != pe_start) {
749 759
750 amdgpu_vm_frag_ptes(adev, src, pages_addr, ib, 760 amdgpu_vm_frag_ptes(adev, vm_update_params,
751 last_pe_start, last_pe_end, 761 last_pe_start, last_pe_end,
752 last_dst, flags); 762 last_dst, flags);
753 763
@@ -762,7 +772,7 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev,
762 dst += nptes * AMDGPU_GPU_PAGE_SIZE; 772 dst += nptes * AMDGPU_GPU_PAGE_SIZE;
763 } 773 }
764 774
765 amdgpu_vm_frag_ptes(adev, src, pages_addr, ib, last_pe_start, 775 amdgpu_vm_frag_ptes(adev, vm_update_params, last_pe_start,
766 last_pe_end, last_dst, flags); 776 last_pe_end, last_dst, flags);
767} 777}
768 778
@@ -794,11 +804,14 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
794 void *owner = AMDGPU_FENCE_OWNER_VM; 804 void *owner = AMDGPU_FENCE_OWNER_VM;
795 unsigned nptes, ncmds, ndw; 805 unsigned nptes, ncmds, ndw;
796 struct amdgpu_job *job; 806 struct amdgpu_job *job;
797 struct amdgpu_ib *ib; 807 struct amdgpu_vm_update_params vm_update_params;
798 struct fence *f = NULL; 808 struct fence *f = NULL;
799 int r; 809 int r;
800 810
801 ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); 811 ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
812 memset(&vm_update_params, 0, sizeof(vm_update_params));
813 vm_update_params.src = src;
814 vm_update_params.pages_addr = pages_addr;
802 815
803 /* sync to everything on unmapping */ 816 /* sync to everything on unmapping */
804 if (!(flags & AMDGPU_PTE_VALID)) 817 if (!(flags & AMDGPU_PTE_VALID))
@@ -815,11 +828,11 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
815 /* padding, etc. */ 828 /* padding, etc. */
816 ndw = 64; 829 ndw = 64;
817 830
818 if (src) { 831 if (vm_update_params.src) {
819 /* only copy commands needed */ 832 /* only copy commands needed */
820 ndw += ncmds * 7; 833 ndw += ncmds * 7;
821 834
822 } else if (pages_addr) { 835 } else if (vm_update_params.pages_addr) {
823 /* header for write data commands */ 836 /* header for write data commands */
824 ndw += ncmds * 4; 837 ndw += ncmds * 4;
825 838
@@ -838,7 +851,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
838 if (r) 851 if (r)
839 return r; 852 return r;
840 853
841 ib = &job->ibs[0]; 854 vm_update_params.ib = &job->ibs[0];
842 855
843 r = amdgpu_sync_resv(adev, &job->sync, vm->page_directory->tbo.resv, 856 r = amdgpu_sync_resv(adev, &job->sync, vm->page_directory->tbo.resv,
844 owner); 857 owner);
@@ -849,11 +862,11 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
849 if (r) 862 if (r)
850 goto error_free; 863 goto error_free;
851 864
852 amdgpu_vm_update_ptes(adev, src, pages_addr, vm, ib, start, 865 amdgpu_vm_update_ptes(adev, &vm_update_params, vm, start,
853 last + 1, addr, flags); 866 last + 1, addr, flags);
854 867
855 amdgpu_ring_pad_ib(ring, ib); 868 amdgpu_ring_pad_ib(ring, vm_update_params.ib);
856 WARN_ON(ib->length_dw > ndw); 869 WARN_ON(vm_update_params.ib->length_dw > ndw);
857 r = amdgpu_job_submit(job, ring, &vm->entity, 870 r = amdgpu_job_submit(job, ring, &vm->entity,
858 AMDGPU_FENCE_OWNER_VM, &f); 871 AMDGPU_FENCE_OWNER_VM, &f);
859 if (r) 872 if (r)
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_ih.c b/drivers/gpu/drm/amd/amdgpu/cik_ih.c
index 845c21b1b2ee..be3d6f79a864 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_ih.c
@@ -103,7 +103,6 @@ static void cik_ih_disable_interrupts(struct amdgpu_device *adev)
103 */ 103 */
104static int cik_ih_irq_init(struct amdgpu_device *adev) 104static int cik_ih_irq_init(struct amdgpu_device *adev)
105{ 105{
106 int ret = 0;
107 int rb_bufsz; 106 int rb_bufsz;
108 u32 interrupt_cntl, ih_cntl, ih_rb_cntl; 107 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
109 u64 wptr_off; 108 u64 wptr_off;
@@ -156,7 +155,7 @@ static int cik_ih_irq_init(struct amdgpu_device *adev)
156 /* enable irqs */ 155 /* enable irqs */
157 cik_ih_enable_interrupts(adev); 156 cik_ih_enable_interrupts(adev);
158 157
159 return ret; 158 return 0;
160} 159}
161 160
162/** 161/**
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
index fa4449e126e6..933e425a8154 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/cz_dpm.c
@@ -1579,7 +1579,6 @@ static int cz_dpm_update_sclk_limit(struct amdgpu_device *adev)
1579 1579
1580static int cz_dpm_set_deep_sleep_sclk_threshold(struct amdgpu_device *adev) 1580static int cz_dpm_set_deep_sleep_sclk_threshold(struct amdgpu_device *adev)
1581{ 1581{
1582 int ret = 0;
1583 struct cz_power_info *pi = cz_get_pi(adev); 1582 struct cz_power_info *pi = cz_get_pi(adev);
1584 1583
1585 if (pi->caps_sclk_ds) { 1584 if (pi->caps_sclk_ds) {
@@ -1588,20 +1587,19 @@ static int cz_dpm_set_deep_sleep_sclk_threshold(struct amdgpu_device *adev)
1588 CZ_MIN_DEEP_SLEEP_SCLK); 1587 CZ_MIN_DEEP_SLEEP_SCLK);
1589 } 1588 }
1590 1589
1591 return ret; 1590 return 0;
1592} 1591}
1593 1592
1594/* ?? without dal support, is this still needed in setpowerstate list*/ 1593/* ?? without dal support, is this still needed in setpowerstate list*/
1595static int cz_dpm_set_watermark_threshold(struct amdgpu_device *adev) 1594static int cz_dpm_set_watermark_threshold(struct amdgpu_device *adev)
1596{ 1595{
1597 int ret = 0;
1598 struct cz_power_info *pi = cz_get_pi(adev); 1596 struct cz_power_info *pi = cz_get_pi(adev);
1599 1597
1600 cz_send_msg_to_smc_with_parameter(adev, 1598 cz_send_msg_to_smc_with_parameter(adev,
1601 PPSMC_MSG_SetWatermarkFrequency, 1599 PPSMC_MSG_SetWatermarkFrequency,
1602 pi->sclk_dpm.soft_max_clk); 1600 pi->sclk_dpm.soft_max_clk);
1603 1601
1604 return ret; 1602 return 0;
1605} 1603}
1606 1604
1607static int cz_dpm_enable_nbdpm(struct amdgpu_device *adev) 1605static int cz_dpm_enable_nbdpm(struct amdgpu_device *adev)
@@ -1636,7 +1634,6 @@ static void cz_dpm_nbdpm_lm_pstate_enable(struct amdgpu_device *adev,
1636 1634
1637static int cz_dpm_update_low_memory_pstate(struct amdgpu_device *adev) 1635static int cz_dpm_update_low_memory_pstate(struct amdgpu_device *adev)
1638{ 1636{
1639 int ret = 0;
1640 struct cz_power_info *pi = cz_get_pi(adev); 1637 struct cz_power_info *pi = cz_get_pi(adev);
1641 struct cz_ps *ps = &pi->requested_ps; 1638 struct cz_ps *ps = &pi->requested_ps;
1642 1639
@@ -1647,21 +1644,19 @@ static int cz_dpm_update_low_memory_pstate(struct amdgpu_device *adev)
1647 cz_dpm_nbdpm_lm_pstate_enable(adev, true); 1644 cz_dpm_nbdpm_lm_pstate_enable(adev, true);
1648 } 1645 }
1649 1646
1650 return ret; 1647 return 0;
1651} 1648}
1652 1649
1653/* with dpm enabled */ 1650/* with dpm enabled */
1654static int cz_dpm_set_power_state(struct amdgpu_device *adev) 1651static int cz_dpm_set_power_state(struct amdgpu_device *adev)
1655{ 1652{
1656 int ret = 0;
1657
1658 cz_dpm_update_sclk_limit(adev); 1653 cz_dpm_update_sclk_limit(adev);
1659 cz_dpm_set_deep_sleep_sclk_threshold(adev); 1654 cz_dpm_set_deep_sleep_sclk_threshold(adev);
1660 cz_dpm_set_watermark_threshold(adev); 1655 cz_dpm_set_watermark_threshold(adev);
1661 cz_dpm_enable_nbdpm(adev); 1656 cz_dpm_enable_nbdpm(adev);
1662 cz_dpm_update_low_memory_pstate(adev); 1657 cz_dpm_update_low_memory_pstate(adev);
1663 1658
1664 return ret; 1659 return 0;
1665} 1660}
1666 1661
1667static void cz_dpm_post_set_power_state(struct amdgpu_device *adev) 1662static void cz_dpm_post_set_power_state(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_ih.c b/drivers/gpu/drm/amd/amdgpu/cz_ih.c
index 863cb16f6126..3d23a70b6432 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/cz_ih.c
@@ -103,7 +103,6 @@ static void cz_ih_disable_interrupts(struct amdgpu_device *adev)
103 */ 103 */
104static int cz_ih_irq_init(struct amdgpu_device *adev) 104static int cz_ih_irq_init(struct amdgpu_device *adev)
105{ 105{
106 int ret = 0;
107 int rb_bufsz; 106 int rb_bufsz;
108 u32 interrupt_cntl, ih_cntl, ih_rb_cntl; 107 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
109 u64 wptr_off; 108 u64 wptr_off;
@@ -157,7 +156,7 @@ static int cz_ih_irq_init(struct amdgpu_device *adev)
157 /* enable interrupts */ 156 /* enable interrupts */
158 cz_ih_enable_interrupts(adev); 157 cz_ih_enable_interrupts(adev);
159 158
160 return ret; 159 return 0;
161} 160}
162 161
163/** 162/**
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index c11b6007af80..af26ec0bc59d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -137,7 +137,7 @@ static const u32 polaris11_golden_settings_a11[] =
137 mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 137 mmDCI_CLK_CNTL, 0x00000080, 0x00000000,
138 mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 138 mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070,
139 mmFBC_DEBUG1, 0xffffffff, 0x00000008, 139 mmFBC_DEBUG1, 0xffffffff, 0x00000008,
140 mmFBC_MISC, 0x9f313fff, 0x14300008, 140 mmFBC_MISC, 0x9f313fff, 0x14302008,
141 mmHDMI_CONTROL, 0x313f031f, 0x00000011, 141 mmHDMI_CONTROL, 0x313f031f, 0x00000011,
142}; 142};
143 143
@@ -145,7 +145,7 @@ static const u32 polaris10_golden_settings_a11[] =
145{ 145{
146 mmDCI_CLK_CNTL, 0x00000080, 0x00000000, 146 mmDCI_CLK_CNTL, 0x00000080, 0x00000000,
147 mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070, 147 mmFBC_DEBUG_COMP, 0x000000f0, 0x00000070,
148 mmFBC_MISC, 0x9f313fff, 0x14300008, 148 mmFBC_MISC, 0x9f313fff, 0x14302008,
149 mmHDMI_CONTROL, 0x313f031f, 0x00000011, 149 mmHDMI_CONTROL, 0x313f031f, 0x00000011,
150}; 150};
151 151
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 92647fbf5b8b..f19bab68fd83 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -267,10 +267,13 @@ static const u32 tonga_mgcg_cgcg_init[] =
267 267
268static const u32 golden_settings_polaris11_a11[] = 268static const u32 golden_settings_polaris11_a11[] =
269{ 269{
270 mmCB_HW_CONTROL, 0xfffdf3cf, 0x00006208,
270 mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040, 271 mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040,
271 mmDB_DEBUG2, 0xf00fffff, 0x00000400, 272 mmDB_DEBUG2, 0xf00fffff, 0x00000400,
272 mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, 273 mmPA_SC_ENHANCE, 0xffffffff, 0x20000001,
273 mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000, 274 mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
275 mmPA_SC_RASTER_CONFIG, 0x3f3fffff, 0x16000012,
276 mmPA_SC_RASTER_CONFIG_1, 0x0000003f, 0x00000000,
274 mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0001003c, 277 mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0001003c,
275 mmRLC_CGCG_CGLS_CTRL_3D, 0xffffffff, 0x0001003c, 278 mmRLC_CGCG_CGLS_CTRL_3D, 0xffffffff, 0x0001003c,
276 mmSQ_CONFIG, 0x07f80000, 0x07180000, 279 mmSQ_CONFIG, 0x07f80000, 0x07180000,
@@ -284,8 +287,6 @@ static const u32 golden_settings_polaris11_a11[] =
284static const u32 polaris11_golden_common_all[] = 287static const u32 polaris11_golden_common_all[] =
285{ 288{
286 mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000, 289 mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
287 mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x16000012,
288 mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x00000000,
289 mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002, 290 mmGB_ADDR_CONFIG, 0xffffffff, 0x22011002,
290 mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800, 291 mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800,
291 mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800, 292 mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800,
@@ -296,6 +297,7 @@ static const u32 polaris11_golden_common_all[] =
296static const u32 golden_settings_polaris10_a11[] = 297static const u32 golden_settings_polaris10_a11[] =
297{ 298{
298 mmATC_MISC_CG, 0x000c0fc0, 0x000c0200, 299 mmATC_MISC_CG, 0x000c0fc0, 0x000c0200,
300 mmCB_HW_CONTROL, 0xfffdf3cf, 0x00006208,
299 mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040, 301 mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040,
300 mmDB_DEBUG2, 0xf00fffff, 0x00000400, 302 mmDB_DEBUG2, 0xf00fffff, 0x00000400,
301 mmPA_SC_ENHANCE, 0xffffffff, 0x20000001, 303 mmPA_SC_ENHANCE, 0xffffffff, 0x20000001,
@@ -5725,6 +5727,7 @@ static void gfx_v8_0_ring_emit_fence_gfx(struct amdgpu_ring *ring, u64 addr,
5725 amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4)); 5727 amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
5726 amdgpu_ring_write(ring, (EOP_TCL1_ACTION_EN | 5728 amdgpu_ring_write(ring, (EOP_TCL1_ACTION_EN |
5727 EOP_TC_ACTION_EN | 5729 EOP_TC_ACTION_EN |
5730 EOP_TC_WB_ACTION_EN |
5728 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | 5731 EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) |
5729 EVENT_INDEX(5))); 5732 EVENT_INDEX(5)));
5730 amdgpu_ring_write(ring, addr & 0xfffffffc); 5733 amdgpu_ring_write(ring, addr & 0xfffffffc);
diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
index 39bfc52d0b42..3b8906ce3511 100644
--- a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
@@ -103,7 +103,6 @@ static void iceland_ih_disable_interrupts(struct amdgpu_device *adev)
103 */ 103 */
104static int iceland_ih_irq_init(struct amdgpu_device *adev) 104static int iceland_ih_irq_init(struct amdgpu_device *adev)
105{ 105{
106 int ret = 0;
107 int rb_bufsz; 106 int rb_bufsz;
108 u32 interrupt_cntl, ih_cntl, ih_rb_cntl; 107 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
109 u64 wptr_off; 108 u64 wptr_off;
@@ -157,7 +156,7 @@ static int iceland_ih_irq_init(struct amdgpu_device *adev)
157 /* enable interrupts */ 156 /* enable interrupts */
158 iceland_ih_enable_interrupts(adev); 157 iceland_ih_enable_interrupts(adev);
159 158
160 return ret; 159 return 0;
161} 160}
162 161
163/** 162/**
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
index b45f54714574..a789a863d677 100644
--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
+++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
@@ -2252,7 +2252,7 @@ static void kv_apply_state_adjust_rules(struct amdgpu_device *adev,
2252 if (pi->caps_stable_p_state) { 2252 if (pi->caps_stable_p_state) {
2253 stable_p_state_sclk = (max_limits->sclk * 75) / 100; 2253 stable_p_state_sclk = (max_limits->sclk * 75) / 100;
2254 2254
2255 for (i = table->count - 1; i >= 0; i++) { 2255 for (i = table->count - 1; i >= 0; i--) {
2256 if (stable_p_state_sclk >= table->entries[i].clk) { 2256 if (stable_p_state_sclk >= table->entries[i].clk) {
2257 stable_p_state_sclk = table->entries[i].clk; 2257 stable_p_state_sclk = table->entries[i].clk;
2258 break; 2258 break;
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index 063f08a9957a..31d99b0010f7 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -109,10 +109,12 @@ static const u32 fiji_mgcg_cgcg_init[] =
109static const u32 golden_settings_polaris11_a11[] = 109static const u32 golden_settings_polaris11_a11[] =
110{ 110{
111 mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007, 111 mmSDMA0_CHICKEN_BITS, 0xfc910007, 0x00810007,
112 mmSDMA0_CLK_CTRL, 0xff000fff, 0x00000000,
112 mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100, 113 mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100,
113 mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100, 114 mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100,
114 mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100, 115 mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100,
115 mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007, 116 mmSDMA1_CHICKEN_BITS, 0xfc910007, 0x00810007,
117 mmSDMA1_CLK_CTRL, 0xff000fff, 0x00000000,
116 mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100, 118 mmSDMA1_GFX_IB_CNTL, 0x800f0111, 0x00000100,
117 mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100, 119 mmSDMA1_RLC0_IB_CNTL, 0x800f0111, 0x00000100,
118 mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100, 120 mmSDMA1_RLC1_IB_CNTL, 0x800f0111, 0x00000100,
diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
index f036af937fbc..c92055805a45 100644
--- a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
@@ -99,7 +99,6 @@ static void tonga_ih_disable_interrupts(struct amdgpu_device *adev)
99 */ 99 */
100static int tonga_ih_irq_init(struct amdgpu_device *adev) 100static int tonga_ih_irq_init(struct amdgpu_device *adev)
101{ 101{
102 int ret = 0;
103 int rb_bufsz; 102 int rb_bufsz;
104 u32 interrupt_cntl, ih_rb_cntl, ih_doorbell_rtpr; 103 u32 interrupt_cntl, ih_rb_cntl, ih_doorbell_rtpr;
105 u64 wptr_off; 104 u64 wptr_off;
@@ -165,7 +164,7 @@ static int tonga_ih_irq_init(struct amdgpu_device *adev)
165 /* enable interrupts */ 164 /* enable interrupts */
166 tonga_ih_enable_interrupts(adev); 165 tonga_ih_enable_interrupts(adev);
167 166
168 return ret; 167 return 0;
169} 168}
170 169
171/** 170/**
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
index c94f9faa220a..24a16e49b571 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c
@@ -3573,46 +3573,11 @@ static int fiji_force_dpm_highest(struct pp_hwmgr *hwmgr)
3573 return 0; 3573 return 0;
3574} 3574}
3575 3575
3576static void fiji_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr)
3577{
3578 struct phm_ppt_v1_information *table_info =
3579 (struct phm_ppt_v1_information *)hwmgr->pptable;
3580 struct phm_clock_voltage_dependency_table *table =
3581 table_info->vddc_dep_on_dal_pwrl;
3582 struct phm_ppt_v1_clock_voltage_dependency_table *vddc_table;
3583 enum PP_DAL_POWERLEVEL dal_power_level = hwmgr->dal_power_level;
3584 uint32_t req_vddc = 0, req_volt, i;
3585
3586 if (!table && !(dal_power_level >= PP_DAL_POWERLEVEL_ULTRALOW &&
3587 dal_power_level <= PP_DAL_POWERLEVEL_PERFORMANCE))
3588 return;
3589
3590 for (i= 0; i < table->count; i++) {
3591 if (dal_power_level == table->entries[i].clk) {
3592 req_vddc = table->entries[i].v;
3593 break;
3594 }
3595 }
3596
3597 vddc_table = table_info->vdd_dep_on_sclk;
3598 for (i= 0; i < vddc_table->count; i++) {
3599 if (req_vddc <= vddc_table->entries[i].vddc) {
3600 req_volt = (((uint32_t)vddc_table->entries[i].vddc) * VOLTAGE_SCALE)
3601 << VDDC_SHIFT;
3602 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
3603 PPSMC_MSG_VddC_Request, req_volt);
3604 return;
3605 }
3606 }
3607 printk(KERN_ERR "DAL requested level can not"
3608 " found a available voltage in VDDC DPM Table \n");
3609}
3610
3611static int fiji_upload_dpmlevel_enable_mask(struct pp_hwmgr *hwmgr) 3576static int fiji_upload_dpmlevel_enable_mask(struct pp_hwmgr *hwmgr)
3612{ 3577{
3613 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); 3578 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
3614 3579
3615 fiji_apply_dal_min_voltage_request(hwmgr); 3580 phm_apply_dal_min_voltage_request(hwmgr);
3616 3581
3617 if (!data->sclk_dpm_key_disabled) { 3582 if (!data->sclk_dpm_key_disabled) {
3618 if (data->dpm_level_enable_mask.sclk_dpm_enable_mask) 3583 if (data->dpm_level_enable_mask.sclk_dpm_enable_mask)
@@ -4349,7 +4314,7 @@ static int fiji_populate_and_upload_sclk_mclk_dpm_levels(
4349 4314
4350 if (data->need_update_smu7_dpm_table & 4315 if (data->need_update_smu7_dpm_table &
4351 (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK)) { 4316 (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK)) {
4352 result = fiji_populate_all_memory_levels(hwmgr); 4317 result = fiji_populate_all_graphic_levels(hwmgr);
4353 PP_ASSERT_WITH_CODE((0 == result), 4318 PP_ASSERT_WITH_CODE((0 == result),
4354 "Failed to populate SCLK during PopulateNewDPMClocksStates Function!", 4319 "Failed to populate SCLK during PopulateNewDPMClocksStates Function!",
4355 return result); 4320 return result);
@@ -5109,11 +5074,11 @@ static int fiji_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
5109 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend); 5074 struct fiji_hwmgr *data = (struct fiji_hwmgr *)(hwmgr->backend);
5110 5075
5111 if (!data->soft_pp_table) { 5076 if (!data->soft_pp_table) {
5112 data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL); 5077 data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
5078 hwmgr->soft_pp_table_size,
5079 GFP_KERNEL);
5113 if (!data->soft_pp_table) 5080 if (!data->soft_pp_table)
5114 return -ENOMEM; 5081 return -ENOMEM;
5115 memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
5116 hwmgr->soft_pp_table_size);
5117 } 5082 }
5118 5083
5119 *table = (char *)&data->soft_pp_table; 5084 *table = (char *)&data->soft_pp_table;
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index 7d69ed635bc2..1c48917da3cf 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -30,6 +30,9 @@
30#include "pppcielanes.h" 30#include "pppcielanes.h"
31#include "pp_debug.h" 31#include "pp_debug.h"
32#include "ppatomctrl.h" 32#include "ppatomctrl.h"
33#include "ppsmc.h"
34
35#define VOLTAGE_SCALE 4
33 36
34extern int cz_hwmgr_init(struct pp_hwmgr *hwmgr); 37extern int cz_hwmgr_init(struct pp_hwmgr *hwmgr);
35extern int tonga_hwmgr_init(struct pp_hwmgr *hwmgr); 38extern int tonga_hwmgr_init(struct pp_hwmgr *hwmgr);
@@ -566,3 +569,38 @@ uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask)
566 569
567 return level; 570 return level;
568} 571}
572
573void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr)
574{
575 struct phm_ppt_v1_information *table_info =
576 (struct phm_ppt_v1_information *)hwmgr->pptable;
577 struct phm_clock_voltage_dependency_table *table =
578 table_info->vddc_dep_on_dal_pwrl;
579 struct phm_ppt_v1_clock_voltage_dependency_table *vddc_table;
580 enum PP_DAL_POWERLEVEL dal_power_level = hwmgr->dal_power_level;
581 uint32_t req_vddc = 0, req_volt, i;
582
583 if (!table || table->count <= 0
584 || dal_power_level < PP_DAL_POWERLEVEL_ULTRALOW
585 || dal_power_level > PP_DAL_POWERLEVEL_PERFORMANCE)
586 return;
587
588 for (i = 0; i < table->count; i++) {
589 if (dal_power_level == table->entries[i].clk) {
590 req_vddc = table->entries[i].v;
591 break;
592 }
593 }
594
595 vddc_table = table_info->vdd_dep_on_sclk;
596 for (i = 0; i < vddc_table->count; i++) {
597 if (req_vddc <= vddc_table->entries[i].vddc) {
598 req_volt = (((uint32_t)vddc_table->entries[i].vddc) * VOLTAGE_SCALE);
599 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
600 PPSMC_MSG_VddC_Request, req_volt);
601 return;
602 }
603 }
604 printk(KERN_ERR "DAL requested level can not"
605 " found a available voltage in VDDC DPM Table \n");
606}
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
index 93768fa1dcdc..aa6be033f21b 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/polaris10_hwmgr.c
@@ -189,41 +189,6 @@ int phm_get_current_pcie_lane_number(struct pp_hwmgr *hwmgr)
189 return decode_pcie_lane_width(link_width); 189 return decode_pcie_lane_width(link_width);
190} 190}
191 191
192void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr)
193{
194 struct phm_ppt_v1_information *table_info =
195 (struct phm_ppt_v1_information *)hwmgr->pptable;
196 struct phm_clock_voltage_dependency_table *table =
197 table_info->vddc_dep_on_dal_pwrl;
198 struct phm_ppt_v1_clock_voltage_dependency_table *vddc_table;
199 enum PP_DAL_POWERLEVEL dal_power_level = hwmgr->dal_power_level;
200 uint32_t req_vddc = 0, req_volt, i;
201
202 if (!table && !(dal_power_level >= PP_DAL_POWERLEVEL_ULTRALOW &&
203 dal_power_level <= PP_DAL_POWERLEVEL_PERFORMANCE))
204 return;
205
206 for (i = 0; i < table->count; i++) {
207 if (dal_power_level == table->entries[i].clk) {
208 req_vddc = table->entries[i].v;
209 break;
210 }
211 }
212
213 vddc_table = table_info->vdd_dep_on_sclk;
214 for (i = 0; i < vddc_table->count; i++) {
215 if (req_vddc <= vddc_table->entries[i].vddc) {
216 req_volt = (((uint32_t)vddc_table->entries[i].vddc) * VOLTAGE_SCALE)
217 << VDDC_SHIFT;
218 smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
219 PPSMC_MSG_VddC_Request, req_volt);
220 return;
221 }
222 }
223 printk(KERN_ERR "DAL requested level can not"
224 " found a available voltage in VDDC DPM Table \n");
225}
226
227/** 192/**
228* Enable voltage control 193* Enable voltage control
229* 194*
@@ -2091,7 +2056,7 @@ static int polaris10_init_smc_table(struct pp_hwmgr *hwmgr)
2091 "Failed to populate Clock Stretcher Data Table!", 2056 "Failed to populate Clock Stretcher Data Table!",
2092 return result); 2057 return result);
2093 } 2058 }
2094 2059 table->CurrSclkPllRange = 0xff;
2095 table->GraphicsVoltageChangeEnable = 1; 2060 table->GraphicsVoltageChangeEnable = 1;
2096 table->GraphicsThermThrottleEnable = 1; 2061 table->GraphicsThermThrottleEnable = 1;
2097 table->GraphicsInterval = 1; 2062 table->GraphicsInterval = 1;
@@ -2184,6 +2149,7 @@ static int polaris10_init_smc_table(struct pp_hwmgr *hwmgr)
2184 CONVERT_FROM_HOST_TO_SMC_UL(table->SmioMask1); 2149 CONVERT_FROM_HOST_TO_SMC_UL(table->SmioMask1);
2185 CONVERT_FROM_HOST_TO_SMC_UL(table->SmioMask2); 2150 CONVERT_FROM_HOST_TO_SMC_UL(table->SmioMask2);
2186 CONVERT_FROM_HOST_TO_SMC_UL(table->SclkStepSize); 2151 CONVERT_FROM_HOST_TO_SMC_UL(table->SclkStepSize);
2152 CONVERT_FROM_HOST_TO_SMC_UL(table->CurrSclkPllRange);
2187 CONVERT_FROM_HOST_TO_SMC_US(table->TemperatureLimitHigh); 2153 CONVERT_FROM_HOST_TO_SMC_US(table->TemperatureLimitHigh);
2188 CONVERT_FROM_HOST_TO_SMC_US(table->TemperatureLimitLow); 2154 CONVERT_FROM_HOST_TO_SMC_US(table->TemperatureLimitLow);
2189 CONVERT_FROM_HOST_TO_SMC_US(table->VoltageResponseTime); 2155 CONVERT_FROM_HOST_TO_SMC_US(table->VoltageResponseTime);
@@ -4760,11 +4726,11 @@ static int polaris10_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
4760 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend); 4726 struct polaris10_hwmgr *data = (struct polaris10_hwmgr *)(hwmgr->backend);
4761 4727
4762 if (!data->soft_pp_table) { 4728 if (!data->soft_pp_table) {
4763 data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL); 4729 data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
4730 hwmgr->soft_pp_table_size,
4731 GFP_KERNEL);
4764 if (!data->soft_pp_table) 4732 if (!data->soft_pp_table)
4765 return -ENOMEM; 4733 return -ENOMEM;
4766 memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
4767 hwmgr->soft_pp_table_size);
4768 } 4734 }
4769 4735
4770 *table = (char *)&data->soft_pp_table; 4736 *table = (char *)&data->soft_pp_table;
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
index 1faad92b50d3..16fed487973b 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
@@ -5331,7 +5331,7 @@ static int tonga_freeze_sclk_mclk_dpm(struct pp_hwmgr *hwmgr)
5331 (data->need_update_smu7_dpm_table & 5331 (data->need_update_smu7_dpm_table &
5332 (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK))) { 5332 (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK))) {
5333 PP_ASSERT_WITH_CODE( 5333 PP_ASSERT_WITH_CODE(
5334 true == tonga_is_dpm_running(hwmgr), 5334 0 == tonga_is_dpm_running(hwmgr),
5335 "Trying to freeze SCLK DPM when DPM is disabled", 5335 "Trying to freeze SCLK DPM when DPM is disabled",
5336 ); 5336 );
5337 PP_ASSERT_WITH_CODE( 5337 PP_ASSERT_WITH_CODE(
@@ -5344,7 +5344,7 @@ static int tonga_freeze_sclk_mclk_dpm(struct pp_hwmgr *hwmgr)
5344 if ((0 == data->mclk_dpm_key_disabled) && 5344 if ((0 == data->mclk_dpm_key_disabled) &&
5345 (data->need_update_smu7_dpm_table & 5345 (data->need_update_smu7_dpm_table &
5346 DPMTABLE_OD_UPDATE_MCLK)) { 5346 DPMTABLE_OD_UPDATE_MCLK)) {
5347 PP_ASSERT_WITH_CODE(true == tonga_is_dpm_running(hwmgr), 5347 PP_ASSERT_WITH_CODE(0 == tonga_is_dpm_running(hwmgr),
5348 "Trying to freeze MCLK DPM when DPM is disabled", 5348 "Trying to freeze MCLK DPM when DPM is disabled",
5349 ); 5349 );
5350 PP_ASSERT_WITH_CODE( 5350 PP_ASSERT_WITH_CODE(
@@ -5445,7 +5445,7 @@ static int tonga_populate_and_upload_sclk_mclk_dpm_levels(struct pp_hwmgr *hwmgr
5445 } 5445 }
5446 5446
5447 if (data->need_update_smu7_dpm_table & (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK)) { 5447 if (data->need_update_smu7_dpm_table & (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK)) {
5448 result = tonga_populate_all_memory_levels(hwmgr); 5448 result = tonga_populate_all_graphic_levels(hwmgr);
5449 PP_ASSERT_WITH_CODE((0 == result), 5449 PP_ASSERT_WITH_CODE((0 == result),
5450 "Failed to populate SCLK during PopulateNewDPMClocksStates Function!", 5450 "Failed to populate SCLK during PopulateNewDPMClocksStates Function!",
5451 return result); 5451 return result);
@@ -5647,7 +5647,7 @@ static int tonga_unfreeze_sclk_mclk_dpm(struct pp_hwmgr *hwmgr)
5647 (data->need_update_smu7_dpm_table & 5647 (data->need_update_smu7_dpm_table &
5648 (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK))) { 5648 (DPMTABLE_OD_UPDATE_SCLK + DPMTABLE_UPDATE_SCLK))) {
5649 5649
5650 PP_ASSERT_WITH_CODE(true == tonga_is_dpm_running(hwmgr), 5650 PP_ASSERT_WITH_CODE(0 == tonga_is_dpm_running(hwmgr),
5651 "Trying to Unfreeze SCLK DPM when DPM is disabled", 5651 "Trying to Unfreeze SCLK DPM when DPM is disabled",
5652 ); 5652 );
5653 PP_ASSERT_WITH_CODE( 5653 PP_ASSERT_WITH_CODE(
@@ -5661,7 +5661,7 @@ static int tonga_unfreeze_sclk_mclk_dpm(struct pp_hwmgr *hwmgr)
5661 (data->need_update_smu7_dpm_table & DPMTABLE_OD_UPDATE_MCLK)) { 5661 (data->need_update_smu7_dpm_table & DPMTABLE_OD_UPDATE_MCLK)) {
5662 5662
5663 PP_ASSERT_WITH_CODE( 5663 PP_ASSERT_WITH_CODE(
5664 true == tonga_is_dpm_running(hwmgr), 5664 0 == tonga_is_dpm_running(hwmgr),
5665 "Trying to Unfreeze MCLK DPM when DPM is disabled", 5665 "Trying to Unfreeze MCLK DPM when DPM is disabled",
5666 ); 5666 );
5667 PP_ASSERT_WITH_CODE( 5667 PP_ASSERT_WITH_CODE(
@@ -6056,11 +6056,11 @@ static int tonga_get_pp_table(struct pp_hwmgr *hwmgr, char **table)
6056 struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend); 6056 struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend);
6057 6057
6058 if (!data->soft_pp_table) { 6058 if (!data->soft_pp_table) {
6059 data->soft_pp_table = kzalloc(hwmgr->soft_pp_table_size, GFP_KERNEL); 6059 data->soft_pp_table = kmemdup(hwmgr->soft_pp_table,
6060 hwmgr->soft_pp_table_size,
6061 GFP_KERNEL);
6060 if (!data->soft_pp_table) 6062 if (!data->soft_pp_table)
6061 return -ENOMEM; 6063 return -ENOMEM;
6062 memcpy(data->soft_pp_table, hwmgr->soft_pp_table,
6063 hwmgr->soft_pp_table_size);
6064 } 6064 }
6065 6065
6066 *table = (char *)&data->soft_pp_table; 6066 *table = (char *)&data->soft_pp_table;
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index fd4ce7aaeee9..28f571449495 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -673,7 +673,7 @@ extern int phm_get_sclk_for_voltage_evv(struct pp_hwmgr *hwmgr, phm_ppt_v1_volta
673extern int phm_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr); 673extern int phm_initializa_dynamic_state_adjustment_rule_settings(struct pp_hwmgr *hwmgr);
674extern int phm_hwmgr_backend_fini(struct pp_hwmgr *hwmgr); 674extern int phm_hwmgr_backend_fini(struct pp_hwmgr *hwmgr);
675extern uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask); 675extern uint32_t phm_get_lowest_enabled_level(struct pp_hwmgr *hwmgr, uint32_t mask);
676 676extern void phm_apply_dal_min_voltage_request(struct pp_hwmgr *hwmgr);
677 677
678#define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU 678#define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU
679 679
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
index da18f44fd1c8..87c023e518ab 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
@@ -639,7 +639,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr)
639 639
640 cz_smu->driver_buffer_length = 0; 640 cz_smu->driver_buffer_length = 0;
641 641
642 for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) { 642 for (i = 0; i < ARRAY_SIZE(firmware_list); i++) {
643 643
644 firmware_type = cz_translate_firmware_enum_to_arg(smumgr, 644 firmware_type = cz_translate_firmware_enum_to_arg(smumgr,
645 firmware_list[i]); 645 firmware_list[i]);
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index d0240743a17c..a7e978677937 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -2164,7 +2164,7 @@ static void kv_apply_state_adjust_rules(struct radeon_device *rdev,
2164 if (pi->caps_stable_p_state) { 2164 if (pi->caps_stable_p_state) {
2165 stable_p_state_sclk = (max_limits->sclk * 75) / 100; 2165 stable_p_state_sclk = (max_limits->sclk * 75) / 100;
2166 2166
2167 for (i = table->count - 1; i >= 0; i++) { 2167 for (i = table->count - 1; i >= 0; i--) {
2168 if (stable_p_state_sclk >= table->entries[i].clk) { 2168 if (stable_p_state_sclk >= table->entries[i].clk) {
2169 stable_p_state_sclk = table->entries[i].clk; 2169 stable_p_state_sclk = table->entries[i].clk;
2170 break; 2170 break;